@payloadcms/next 3.0.0-beta.10 → 3.0.0-beta.12
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/exports/routes.d.ts +1 -1
- package/dist/exports/routes.d.ts.map +1 -1
- package/dist/exports/routes.js +1 -1
- package/dist/exports/routes.js.map +1 -1
- package/dist/exports/utilities.d.ts +3 -0
- package/dist/exports/utilities.d.ts.map +1 -1
- package/dist/exports/utilities.js +3 -0
- package/dist/exports/utilities.js.map +1 -1
- package/dist/next-fileupload/handlers.js.map +1 -1
- package/dist/next-fileupload/isEligibleRequest.js +1 -1
- package/dist/next-fileupload/isEligibleRequest.js.map +1 -1
- package/dist/next-fileupload/processMultipart.d.ts.map +1 -1
- package/dist/next-fileupload/processMultipart.js +29 -6
- package/dist/next-fileupload/processMultipart.js.map +1 -1
- package/dist/next-fileupload/utilities.d.ts.map +1 -1
- package/dist/next-fileupload/utilities.js +4 -4
- package/dist/next-fileupload/utilities.js.map +1 -1
- package/dist/routes/graphql/handler.d.ts.map +1 -1
- package/dist/routes/graphql/handler.js +8 -3
- package/dist/routes/graphql/handler.js.map +1 -1
- package/dist/routes/rest/auth/access.d.ts.map +1 -1
- package/dist/routes/rest/auth/access.js +5 -0
- package/dist/routes/rest/auth/access.js.map +1 -1
- package/dist/routes/rest/auth/forgotPassword.d.ts.map +1 -1
- package/dist/routes/rest/auth/forgotPassword.js +7 -2
- package/dist/routes/rest/auth/forgotPassword.js.map +1 -1
- package/dist/routes/rest/auth/init.d.ts.map +1 -1
- package/dist/routes/rest/auth/init.js +6 -0
- package/dist/routes/rest/auth/init.js.map +1 -1
- package/dist/routes/rest/auth/login.d.ts.map +1 -1
- package/dist/routes/rest/auth/login.js +8 -5
- package/dist/routes/rest/auth/login.js.map +1 -1
- package/dist/routes/rest/auth/logout.d.ts.map +1 -1
- package/dist/routes/rest/auth/logout.js +11 -6
- package/dist/routes/rest/auth/logout.js.map +1 -1
- package/dist/routes/rest/auth/me.d.ts.map +1 -1
- package/dist/routes/rest/auth/me.js +5 -0
- package/dist/routes/rest/auth/me.js.map +1 -1
- package/dist/routes/rest/auth/refresh.d.ts.map +1 -1
- package/dist/routes/rest/auth/refresh.js +11 -7
- package/dist/routes/rest/auth/refresh.js.map +1 -1
- package/dist/routes/rest/auth/registerFirstUser.d.ts.map +1 -1
- package/dist/routes/rest/auth/registerFirstUser.js +17 -5
- package/dist/routes/rest/auth/registerFirstUser.js.map +1 -1
- package/dist/routes/rest/auth/resetPassword.d.ts.map +1 -1
- package/dist/routes/rest/auth/resetPassword.js +8 -5
- package/dist/routes/rest/auth/resetPassword.js.map +1 -1
- package/dist/routes/rest/auth/unlock.d.ts.map +1 -1
- package/dist/routes/rest/auth/unlock.js +7 -2
- package/dist/routes/rest/auth/unlock.js.map +1 -1
- package/dist/routes/rest/auth/verifyEmail.d.ts.map +1 -1
- package/dist/routes/rest/auth/verifyEmail.js +7 -2
- package/dist/routes/rest/auth/verifyEmail.js.map +1 -1
- package/dist/routes/rest/buildFormState.d.ts.map +1 -1
- package/dist/routes/rest/buildFormState.js +15 -0
- package/dist/routes/rest/buildFormState.js.map +1 -1
- package/dist/routes/rest/collections/count.d.ts +3 -0
- package/dist/routes/rest/collections/count.d.ts.map +1 -0
- package/dist/routes/rest/collections/count.js +15 -0
- package/dist/routes/rest/collections/count.js.map +1 -0
- package/dist/routes/rest/collections/create.d.ts.map +1 -1
- package/dist/routes/rest/collections/create.js +5 -0
- package/dist/routes/rest/collections/create.js.map +1 -1
- package/dist/routes/rest/collections/delete.d.ts.map +1 -1
- package/dist/routes/rest/collections/delete.js +7 -0
- package/dist/routes/rest/collections/delete.js.map +1 -1
- package/dist/routes/rest/collections/deleteByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/deleteByID.js +7 -0
- package/dist/routes/rest/collections/deleteByID.js.map +1 -1
- package/dist/routes/rest/collections/docAccess.d.ts.map +1 -1
- package/dist/routes/rest/collections/docAccess.js +5 -0
- package/dist/routes/rest/collections/docAccess.js.map +1 -1
- package/dist/routes/rest/collections/duplicate.d.ts.map +1 -1
- package/dist/routes/rest/collections/duplicate.js +5 -0
- package/dist/routes/rest/collections/duplicate.js.map +1 -1
- package/dist/routes/rest/collections/find.d.ts.map +1 -1
- package/dist/routes/rest/collections/find.js +5 -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 +5 -0
- package/dist/routes/rest/collections/findByID.js.map +1 -1
- package/dist/routes/rest/collections/findVersionByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/findVersionByID.js +5 -0
- package/dist/routes/rest/collections/findVersionByID.js.map +1 -1
- package/dist/routes/rest/collections/findVersions.d.ts.map +1 -1
- package/dist/routes/rest/collections/findVersions.js +5 -0
- package/dist/routes/rest/collections/findVersions.js.map +1 -1
- package/dist/routes/rest/collections/preview.d.ts.map +1 -1
- package/dist/routes/rest/collections/preview.js +7 -1
- package/dist/routes/rest/collections/preview.js.map +1 -1
- package/dist/routes/rest/collections/restoreVersion.d.ts.map +1 -1
- package/dist/routes/rest/collections/restoreVersion.js +5 -0
- package/dist/routes/rest/collections/restoreVersion.js.map +1 -1
- package/dist/routes/rest/collections/update.d.ts.map +1 -1
- package/dist/routes/rest/collections/update.js +7 -0
- package/dist/routes/rest/collections/update.js.map +1 -1
- package/dist/routes/rest/collections/updateByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/updateByID.js +5 -0
- package/dist/routes/rest/collections/updateByID.js.map +1 -1
- package/dist/routes/rest/files/getFile.d.ts.map +1 -1
- package/dist/routes/rest/files/getFile.js +15 -8
- package/dist/routes/rest/files/getFile.js.map +1 -1
- package/dist/routes/rest/files/getFileTypeFallback.d.ts +7 -0
- package/dist/routes/rest/files/getFileTypeFallback.d.ts.map +1 -0
- package/dist/routes/rest/files/getFileTypeFallback.js +21 -0
- package/dist/routes/rest/files/getFileTypeFallback.js.map +1 -0
- package/dist/routes/rest/globals/docAccess.d.ts.map +1 -1
- package/dist/routes/rest/globals/docAccess.js +5 -0
- package/dist/routes/rest/globals/docAccess.js.map +1 -1
- package/dist/routes/rest/globals/findOne.d.ts.map +1 -1
- package/dist/routes/rest/globals/findOne.js +5 -0
- package/dist/routes/rest/globals/findOne.js.map +1 -1
- package/dist/routes/rest/globals/findVersionByID.d.ts.map +1 -1
- package/dist/routes/rest/globals/findVersionByID.js +5 -0
- package/dist/routes/rest/globals/findVersionByID.js.map +1 -1
- package/dist/routes/rest/globals/findVersions.d.ts.map +1 -1
- package/dist/routes/rest/globals/findVersions.js +5 -0
- package/dist/routes/rest/globals/findVersions.js.map +1 -1
- package/dist/routes/rest/globals/preview.d.ts.map +1 -1
- package/dist/routes/rest/globals/preview.js +7 -1
- package/dist/routes/rest/globals/preview.js.map +1 -1
- package/dist/routes/rest/globals/restoreVersion.d.ts.map +1 -1
- package/dist/routes/rest/globals/restoreVersion.js +5 -0
- package/dist/routes/rest/globals/restoreVersion.js.map +1 -1
- package/dist/routes/rest/globals/update.d.ts.map +1 -1
- package/dist/routes/rest/globals/update.js +5 -0
- package/dist/routes/rest/globals/update.js.map +1 -1
- package/dist/routes/rest/index.d.ts +1 -0
- package/dist/routes/rest/index.d.ts.map +1 -1
- package/dist/routes/rest/index.js +55 -9
- package/dist/routes/rest/index.js.map +1 -1
- package/dist/routes/rest/routeError.d.ts +5 -4
- package/dist/routes/rest/routeError.d.ts.map +1 -1
- package/dist/routes/rest/routeError.js +25 -11
- package/dist/routes/rest/routeError.js.map +1 -1
- package/dist/utilities/getDataAndFile.d.ts.map +1 -1
- package/dist/utilities/getDataAndFile.js +26 -46
- package/dist/utilities/getDataAndFile.js.map +1 -1
- package/dist/utilities/headersWithCors.d.ts +8 -0
- package/dist/utilities/headersWithCors.d.ts.map +1 -0
- package/dist/utilities/headersWithCors.js +17 -0
- package/dist/utilities/headersWithCors.js.map +1 -0
- package/dist/utilities/initPage.d.ts.map +1 -1
- package/dist/utilities/initPage.js +15 -2
- package/dist/utilities/initPage.js.map +1 -1
- package/dist/views/API/index.client.js +2 -2
- package/dist/views/API/index.client.js.map +1 -1
- package/dist/views/CreateFirstUser/index.client.js +2 -2
- package/dist/views/CreateFirstUser/index.client.js.map +1 -1
- package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/index.js +17 -0
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/Edit/Default/{SetStepNav → SetDocumentStepNav}/index.d.ts +1 -1
- package/dist/views/Edit/Default/SetDocumentStepNav/index.d.ts.map +1 -0
- package/dist/views/Edit/Default/{SetStepNav → SetDocumentStepNav}/index.js +12 -5
- package/dist/views/Edit/Default/SetDocumentStepNav/index.js.map +1 -0
- package/dist/views/Edit/Default/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/index.js +5 -4
- package/dist/views/Edit/Default/index.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts +3 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +55 -0
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -0
- package/dist/views/ForgotPassword/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/index.js +3 -39
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/List/index.js +2 -2
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/Controls/index.d.ts.map +1 -1
- package/dist/views/LivePreview/Toolbar/Controls/index.js +6 -4
- package/dist/views/LivePreview/Toolbar/Controls/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.js +2 -2
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
- package/dist/views/Login/LoginForm/index.js +26 -2
- package/dist/views/Login/LoginForm/index.js.map +1 -1
- package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
- package/dist/views/Logout/LogoutClient.js +1 -2
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/Versions/index.js +2 -2
- package/dist/views/Versions/index.js.map +1 -1
- package/package.json +10 -8
- package/dist/views/Edit/Default/SetStepNav/index.d.ts.map +0 -1
- package/dist/views/Edit/Default/SetStepNav/index.js.map +0 -1
- package/src/index.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/login.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/login.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,KAAK,EAAE,sBAuCnB,CAAA"}
|
|
@@ -2,8 +2,9 @@ import httpStatus from 'http-status';
|
|
|
2
2
|
import { generatePayloadCookie } from 'payload/auth';
|
|
3
3
|
import { loginOperation } from 'payload/operations';
|
|
4
4
|
import { isNumber } from 'payload/utilities';
|
|
5
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
6
|
export const login = async ({ collection, req })=>{
|
|
6
|
-
const { searchParams } = req;
|
|
7
|
+
const { searchParams, t } = req;
|
|
7
8
|
const depth = searchParams.get('depth');
|
|
8
9
|
const result = await loginOperation({
|
|
9
10
|
collection,
|
|
@@ -23,12 +24,14 @@ export const login = async ({ collection, req })=>{
|
|
|
23
24
|
delete result.token;
|
|
24
25
|
}
|
|
25
26
|
return Response.json({
|
|
26
|
-
|
|
27
|
-
message: 'Auth Passed',
|
|
27
|
+
message: t('authentication:passed'),
|
|
28
28
|
...result
|
|
29
29
|
}, {
|
|
30
|
-
headers:
|
|
31
|
-
|
|
30
|
+
headers: headersWithCors({
|
|
31
|
+
headers: new Headers({
|
|
32
|
+
'Set-Cookie': cookie
|
|
33
|
+
}),
|
|
34
|
+
req
|
|
32
35
|
}),
|
|
33
36
|
status: httpStatus.OK
|
|
34
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/login.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { loginOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const login: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const result = await loginOperation({\n collection,\n data: {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n },\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/login.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { loginOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const login: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n\n const result = await loginOperation({\n collection,\n data: {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n },\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n message: t('authentication:passed'),\n ...result,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generatePayloadCookie","loginOperation","isNumber","headersWithCors","login","collection","req","searchParams","t","depth","get","result","data","email","password","Number","undefined","cookie","collectionConfig","config","payload","token","auth","removeTokenFromResponses","Response","json","message","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,QAAgC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrE,MAAM,EAAEC,YAAY,EAAEC,CAAC,EAAE,GAAGF;IAC5B,MAAMG,QAAQF,aAAaG,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMV,eAAe;QAClCI;QACAO,MAAM;YACJC,OAAO,OAAOP,IAAIM,IAAI,EAAEC,UAAU,WAAWP,IAAIM,IAAI,CAACC,KAAK,GAAG;YAC9DC,UAAU,OAAOR,IAAIM,IAAI,EAAEE,aAAa,WAAWR,IAAIM,IAAI,CAACE,QAAQ,GAAG;QACzE;QACAL,OAAOP,SAASO,SAASM,OAAON,SAASO;QACzCV;IACF;IAEA,MAAMW,SAASjB,sBAAsB;QACnCkB,kBAAkBb,WAAWc,MAAM;QACnCC,SAASd,IAAIc,OAAO;QACpBC,OAAOV,OAAOU,KAAK;IACrB;IAEA,IAAIhB,WAAWc,MAAM,CAACG,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOZ,OAAOU,KAAK;IACrB;IAEA,OAAOG,SAASC,IAAI,CAClB;QACEC,SAASlB,EAAE;QACX,GAAGG,MAAM;IACX,GACA;QACEgB,SAASxB,gBAAgB;YACvBwB,SAAS,IAAIC,QAAQ;gBACnB,cAAcX;YAChB;YACAX;QACF;QACAuB,QAAQ9B,WAAW+B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/logout.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/logout.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBAwCpB,CAAA"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { generateExpiredPayloadCookie } from 'payload/auth';
|
|
3
3
|
import { logoutOperation } from 'payload/operations';
|
|
4
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
4
5
|
export const logout = async ({ collection, req })=>{
|
|
6
|
+
const { t } = req;
|
|
5
7
|
const result = await logoutOperation({
|
|
6
8
|
collection,
|
|
7
9
|
req
|
|
8
10
|
});
|
|
11
|
+
const headers = headersWithCors({
|
|
12
|
+
headers: new Headers(),
|
|
13
|
+
req
|
|
14
|
+
});
|
|
9
15
|
if (!result) {
|
|
10
16
|
return Response.json({
|
|
11
|
-
message: '
|
|
17
|
+
message: t('error:logoutFailed')
|
|
12
18
|
}, {
|
|
19
|
+
headers,
|
|
13
20
|
status: httpStatus.BAD_REQUEST
|
|
14
21
|
});
|
|
15
22
|
}
|
|
@@ -17,13 +24,11 @@ export const logout = async ({ collection, req })=>{
|
|
|
17
24
|
collectionConfig: collection.config,
|
|
18
25
|
payload: req.payload
|
|
19
26
|
});
|
|
27
|
+
headers.set('Set-Cookie', expiredCookie);
|
|
20
28
|
return Response.json({
|
|
21
|
-
|
|
22
|
-
message: 'Logout successful.'
|
|
29
|
+
message: t('authentication:logoutSuccessful')
|
|
23
30
|
}, {
|
|
24
|
-
headers
|
|
25
|
-
'Set-Cookie': expiredCookie
|
|
26
|
-
}),
|
|
31
|
+
headers,
|
|
27
32
|
status: httpStatus.OK
|
|
28
33
|
});
|
|
29
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/logout.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generateExpiredPayloadCookie } from 'payload/auth'\nimport { logoutOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const logout: CollectionRouteHandler = async ({ collection, req }) => {\n const result = await logoutOperation({\n collection,\n req,\n })\n\n if (!result) {\n return Response.json(\n {\n message: '
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/logout.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generateExpiredPayloadCookie } from 'payload/auth'\nimport { logoutOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const logout: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n const result = await logoutOperation({\n collection,\n req,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (!result) {\n return Response.json(\n {\n message: t('error:logoutFailed'),\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n const expiredCookie = generateExpiredPayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n })\n\n headers.set('Set-Cookie', expiredCookie)\n\n return Response.json(\n {\n message: t('authentication:logoutSuccessful'),\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generateExpiredPayloadCookie","logoutOperation","headersWithCors","logout","collection","req","t","result","headers","Headers","Response","json","message","status","BAD_REQUEST","expiredCookie","collectionConfig","config","payload","set","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAME,SAAS,MAAMN,gBAAgB;QACnCG;QACAC;IACF;IAEA,MAAMG,UAAUN,gBAAgB;QAC9BM,SAAS,IAAIC;QACbJ;IACF;IAEA,IAAI,CAACE,QAAQ;QACX,OAAOG,SAASC,IAAI,CAClB;YACEC,SAASN,EAAE;QACb,GACA;YACEE;YACAK,QAAQd,WAAWe,WAAW;QAChC;IAEJ;IAEA,MAAMC,gBAAgBf,6BAA6B;QACjDgB,kBAAkBZ,WAAWa,MAAM;QACnCC,SAASb,IAAIa,OAAO;IACtB;IAEAV,QAAQW,GAAG,CAAC,cAAcJ;IAE1B,OAAOL,SAASC,IAAI,CAClB;QACEC,SAASN,EAAE;IACb,GACA;QACEE;QACAK,QAAQd,WAAWqB,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/me.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/me.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,EAAE,EAAE,sBA0BhB,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { extractJWT } from 'payload/auth';
|
|
3
3
|
import { meOperation } from 'payload/operations';
|
|
4
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
4
5
|
export const me = async ({ collection, req })=>{
|
|
5
6
|
const currentToken = extractJWT(req);
|
|
6
7
|
const result = await meOperation({
|
|
@@ -15,6 +16,10 @@ export const me = async ({ collection, req })=>{
|
|
|
15
16
|
...result,
|
|
16
17
|
message: req.t('authentication:account')
|
|
17
18
|
}, {
|
|
19
|
+
headers: headersWithCors({
|
|
20
|
+
headers: new Headers(),
|
|
21
|
+
req
|
|
22
|
+
}),
|
|
18
23
|
status: httpStatus.OK
|
|
19
24
|
});
|
|
20
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/me.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT } from 'payload/auth'\nimport { meOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const me: CollectionRouteHandler = async ({ collection, req }) => {\n const currentToken = extractJWT(req)\n\n const result = await meOperation({\n collection,\n currentToken,\n req,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n ...result,\n message: req.t('authentication:account'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","extractJWT","meOperation","me","collection","req","currentToken","result","config","auth","removeTokenFromResponses","token","Response","json","message","t","status","OK"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/me.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT } from 'payload/auth'\nimport { meOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const me: CollectionRouteHandler = async ({ collection, req }) => {\n const currentToken = extractJWT(req)\n\n const result = await meOperation({\n collection,\n currentToken,\n req,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n ...result,\n message: req.t('authentication:account'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","extractJWT","meOperation","headersWithCors","me","collection","req","currentToken","result","config","auth","removeTokenFromResponses","token","Response","json","message","t","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,UAAU,QAAQ,eAAc;AACzC,SAASC,WAAW,QAAQ,qBAAoB;AAIhD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,KAA6B,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAClE,MAAMC,eAAeN,WAAWK;IAEhC,MAAME,SAAS,MAAMN,YAAY;QAC/BG;QACAE;QACAD;IACF;IAEA,IAAID,WAAWI,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOH,OAAOI,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACE,GAAGN,MAAM;QACTO,SAAST,IAAIU,CAAC,CAAC;IACjB,GACA;QACEC,SAASd,gBAAgB;YACvBc,SAAS,IAAIC;YACbZ;QACF;QACAa,QAAQnB,WAAWoB,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/refresh.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/refresh.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,OAAO,EAAE,sBAiDrB,CAAA"}
|
|
@@ -2,13 +2,19 @@ import httpStatus from 'http-status';
|
|
|
2
2
|
import { extractJWT } from 'payload/auth';
|
|
3
3
|
import { generatePayloadCookie } from 'payload/auth';
|
|
4
4
|
import { refreshOperation } from 'payload/operations';
|
|
5
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
6
|
export const refresh = async ({ collection, req })=>{
|
|
7
|
+
const { t } = req;
|
|
6
8
|
const token = typeof req.data?.token === 'string' ? req.data.token : extractJWT(req);
|
|
9
|
+
const headers = headersWithCors({
|
|
10
|
+
headers: new Headers(),
|
|
11
|
+
req
|
|
12
|
+
});
|
|
7
13
|
if (!token) {
|
|
8
14
|
return Response.json({
|
|
9
|
-
|
|
10
|
-
message: 'Token not provided.'
|
|
15
|
+
message: t('error:tokenNotProvided')
|
|
11
16
|
}, {
|
|
17
|
+
headers,
|
|
12
18
|
status: httpStatus.UNAUTHORIZED
|
|
13
19
|
});
|
|
14
20
|
}
|
|
@@ -25,14 +31,12 @@ export const refresh = async ({ collection, req })=>{
|
|
|
25
31
|
if (collection.config.auth.removeTokenFromResponses) {
|
|
26
32
|
delete result.refreshedToken;
|
|
27
33
|
}
|
|
34
|
+
headers.set('Set-Cookie', cookie);
|
|
28
35
|
return Response.json({
|
|
29
|
-
|
|
30
|
-
message: 'Token refresh successful',
|
|
36
|
+
message: t('authentication:tokenRefreshSuccessful'),
|
|
31
37
|
...result
|
|
32
38
|
}, {
|
|
33
|
-
headers
|
|
34
|
-
'Set-Cookie': cookie
|
|
35
|
-
}),
|
|
39
|
+
headers,
|
|
36
40
|
status: httpStatus.OK
|
|
37
41
|
});
|
|
38
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/refresh.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT } from 'payload/auth'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { refreshOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const refresh: CollectionRouteHandler = async ({ collection, req }) => {\n const token = typeof req.data?.token === 'string' ? req.data.token : extractJWT(req)\n\n if (!token) {\n return Response.json(\n {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/refresh.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT } from 'payload/auth'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { refreshOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const refresh: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n const token = typeof req.data?.token === 'string' ? req.data.token : extractJWT(req)\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (!token) {\n return Response.json(\n {\n message: t('error:tokenNotProvided'),\n },\n {\n headers,\n status: httpStatus.UNAUTHORIZED,\n },\n )\n }\n\n const result = await refreshOperation({\n collection,\n req,\n token,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.refreshedToken,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.refreshedToken\n }\n\n headers.set('Set-Cookie', cookie)\n\n return Response.json(\n {\n message: t('authentication:tokenRefreshSuccessful'),\n ...result,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","extractJWT","generatePayloadCookie","refreshOperation","headersWithCors","refresh","collection","req","t","token","data","headers","Headers","Response","json","message","status","UNAUTHORIZED","result","cookie","collectionConfig","config","payload","refreshedToken","auth","removeTokenFromResponses","set","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,UAAU,QAAQ,eAAc;AACzC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,gBAAgB,QAAQ,qBAAoB;AAIrD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,UAAkC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACvE,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAME,QAAQ,OAAOF,IAAIG,IAAI,EAAED,UAAU,WAAWF,IAAIG,IAAI,CAACD,KAAK,GAAGR,WAAWM;IAEhF,MAAMI,UAAUP,gBAAgB;QAC9BO,SAAS,IAAIC;QACbL;IACF;IAEA,IAAI,CAACE,OAAO;QACV,OAAOI,SAASC,IAAI,CAClB;YACEC,SAASP,EAAE;QACb,GACA;YACEG;YACAK,QAAQhB,WAAWiB,YAAY;QACjC;IAEJ;IAEA,MAAMC,SAAS,MAAMf,iBAAiB;QACpCG;QACAC;QACAE;IACF;IAEA,MAAMU,SAASjB,sBAAsB;QACnCkB,kBAAkBd,WAAWe,MAAM;QACnCC,SAASf,IAAIe,OAAO;QACpBb,OAAOS,OAAOK,cAAc;IAC9B;IAEA,IAAIjB,WAAWe,MAAM,CAACG,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOP,OAAOK,cAAc;IAC9B;IAEAZ,QAAQe,GAAG,CAAC,cAAcP;IAE1B,OAAON,SAASC,IAAI,CAClB;QACEC,SAASP,EAAE;QACX,GAAGU,MAAM;IACX,GACA;QACEP;QACAK,QAAQhB,WAAW2B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerFirstUser.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registerFirstUser.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,iBAAiB,EAAE,sBA6C/B,CAAA"}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { generatePayloadCookie } from 'payload/auth';
|
|
3
|
+
import { ValidationError } from 'payload/errors';
|
|
3
4
|
import { registerFirstUserOperation } from 'payload/operations';
|
|
5
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
4
6
|
export const registerFirstUser = async ({ collection, req })=>{
|
|
5
|
-
const data = req
|
|
7
|
+
const { data, t } = req;
|
|
8
|
+
if (data?.password !== data['confirm-password']) {
|
|
9
|
+
throw new ValidationError([
|
|
10
|
+
{
|
|
11
|
+
field: 'confirm-password',
|
|
12
|
+
message: req.t('Password and confirm password fields do not match.')
|
|
13
|
+
}
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
6
16
|
const result = await registerFirstUserOperation({
|
|
7
17
|
collection,
|
|
8
18
|
data: {
|
|
@@ -19,13 +29,15 @@ export const registerFirstUser = async ({ collection, req })=>{
|
|
|
19
29
|
});
|
|
20
30
|
return Response.json({
|
|
21
31
|
exp: result.exp,
|
|
22
|
-
|
|
23
|
-
message: 'Successfully registered first user.',
|
|
32
|
+
message: t('authentication:successfullyRegisteredFirstUser'),
|
|
24
33
|
token: result.token,
|
|
25
34
|
user: result.user
|
|
26
35
|
}, {
|
|
27
|
-
headers:
|
|
28
|
-
|
|
36
|
+
headers: headersWithCors({
|
|
37
|
+
headers: new Headers({
|
|
38
|
+
'Set-Cookie': cookie
|
|
39
|
+
}),
|
|
40
|
+
req
|
|
29
41
|
}),
|
|
30
42
|
status: httpStatus.OK
|
|
31
43
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { registerFirstUserOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const registerFirstUser: CollectionRouteHandler = async ({ collection, req }) => {\n const data = req
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { ValidationError } from 'payload/errors'\nimport { registerFirstUserOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const registerFirstUser: CollectionRouteHandler = async ({ collection, req }) => {\n const { data, t } = req\n\n if (data?.password !== data['confirm-password']) {\n throw new ValidationError([\n {\n field: 'confirm-password',\n message: req.t('Password and confirm password fields do not match.'),\n },\n ])\n }\n\n const result = await registerFirstUserOperation({\n collection,\n data: {\n ...data,\n email: typeof data?.email === 'string' ? data.email : '',\n password: typeof data?.password === 'string' ? data.password : '',\n },\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n return Response.json(\n {\n exp: result.exp,\n message: t('authentication:successfullyRegisteredFirstUser'),\n token: result.token,\n user: result.user,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generatePayloadCookie","ValidationError","registerFirstUserOperation","headersWithCors","registerFirstUser","collection","req","data","t","password","field","message","result","email","cookie","collectionConfig","config","payload","token","Response","json","exp","user","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,eAAe,QAAQ,iBAAgB;AAChD,SAASC,0BAA0B,QAAQ,qBAAoB;AAI/D,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,oBAA4C,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACjF,MAAM,EAAEC,IAAI,EAAEC,CAAC,EAAE,GAAGF;IAEpB,IAAIC,MAAME,aAAaF,IAAI,CAAC,mBAAmB,EAAE;QAC/C,MAAM,IAAIN,gBAAgB;YACxB;gBACES,OAAO;gBACPC,SAASL,IAAIE,CAAC,CAAC;YACjB;SACD;IACH;IAEA,MAAMI,SAAS,MAAMV,2BAA2B;QAC9CG;QACAE,MAAM;YACJ,GAAGA,IAAI;YACPM,OAAO,OAAON,MAAMM,UAAU,WAAWN,KAAKM,KAAK,GAAG;YACtDJ,UAAU,OAAOF,MAAME,aAAa,WAAWF,KAAKE,QAAQ,GAAG;QACjE;QACAH;IACF;IAEA,MAAMQ,SAASd,sBAAsB;QACnCe,kBAAkBV,WAAWW,MAAM;QACnCC,SAASX,IAAIW,OAAO;QACpBC,OAAON,OAAOM,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEC,KAAKT,OAAOS,GAAG;QACfV,SAASH,EAAE;QACXU,OAAON,OAAOM,KAAK;QACnBI,MAAMV,OAAOU,IAAI;IACnB,GACA;QACEC,SAASpB,gBAAgB;YACvBoB,SAAS,IAAIC,QAAQ;gBACnB,cAAcV;YAChB;YACAR;QACF;QACAmB,QAAQ1B,WAAW2B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/resetPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/resetPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,aAAa,EAAE,sBAuC3B,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { generatePayloadCookie } from 'payload/auth';
|
|
3
3
|
import { resetPasswordOperation } from 'payload/operations';
|
|
4
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
4
5
|
export const resetPassword = async ({ collection, req })=>{
|
|
5
|
-
const { searchParams } = req;
|
|
6
|
+
const { searchParams, t } = req;
|
|
6
7
|
const depth = searchParams.get('depth');
|
|
7
8
|
const result = await resetPasswordOperation({
|
|
8
9
|
collection,
|
|
@@ -22,12 +23,14 @@ export const resetPassword = async ({ collection, req })=>{
|
|
|
22
23
|
delete result.token;
|
|
23
24
|
}
|
|
24
25
|
return Response.json({
|
|
25
|
-
|
|
26
|
-
message: 'Password reset successfully.',
|
|
26
|
+
message: t('authentication:passwordResetSuccessfully'),
|
|
27
27
|
...result
|
|
28
28
|
}, {
|
|
29
|
-
headers:
|
|
30
|
-
|
|
29
|
+
headers: headersWithCors({
|
|
30
|
+
headers: new Headers({
|
|
31
|
+
'Set-Cookie': cookie
|
|
32
|
+
}),
|
|
33
|
+
req
|
|
31
34
|
}),
|
|
32
35
|
status: httpStatus.OK
|
|
33
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/resetPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { resetPasswordOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const resetPassword: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const result = await resetPasswordOperation({\n collection,\n data: {\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n token: typeof req.data?.token === 'string' ? req.data.token : '',\n },\n depth: depth ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/resetPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie } from 'payload/auth'\nimport { resetPasswordOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const resetPassword: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n\n const result = await resetPasswordOperation({\n collection,\n data: {\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n token: typeof req.data?.token === 'string' ? req.data.token : '',\n },\n depth: depth ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n message: t('authentication:passwordResetSuccessfully'),\n ...result,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generatePayloadCookie","resetPasswordOperation","headersWithCors","resetPassword","collection","req","searchParams","t","depth","get","result","data","password","token","Number","undefined","cookie","collectionConfig","config","payload","auth","removeTokenFromResponses","Response","json","message","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,sBAAsB,QAAQ,qBAAoB;AAI3D,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,gBAAwC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAC7E,MAAM,EAAEC,YAAY,EAAEC,CAAC,EAAE,GAAGF;IAC5B,MAAMG,QAAQF,aAAaG,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMT,uBAAuB;QAC1CG;QACAO,MAAM;YACJC,UAAU,OAAOP,IAAIM,IAAI,EAAEC,aAAa,WAAWP,IAAIM,IAAI,CAACC,QAAQ,GAAG;YACvEC,OAAO,OAAOR,IAAIM,IAAI,EAAEE,UAAU,WAAWR,IAAIM,IAAI,CAACE,KAAK,GAAG;QAChE;QACAL,OAAOA,QAAQM,OAAON,SAASO;QAC/BV;IACF;IAEA,MAAMW,SAAShB,sBAAsB;QACnCiB,kBAAkBb,WAAWc,MAAM;QACnCC,SAASd,IAAIc,OAAO;QACpBN,OAAOH,OAAOG,KAAK;IACrB;IAEA,IAAIT,WAAWc,MAAM,CAACE,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOX,OAAOG,KAAK;IACrB;IAEA,OAAOS,SAASC,IAAI,CAClB;QACEC,SAASjB,EAAE;QACX,GAAGG,MAAM;IACX,GACA;QACEe,SAASvB,gBAAgB;YACvBuB,SAAS,IAAIC,QAAQ;gBACnB,cAAcV;YAChB;YACAX;QACF;QACAsB,QAAQ5B,WAAW6B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/unlock.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/unlock.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBAqBpB,CAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { unlockOperation } from 'payload/operations';
|
|
3
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
3
4
|
export const unlock = async ({ collection, req })=>{
|
|
5
|
+
const { t } = req;
|
|
4
6
|
await unlockOperation({
|
|
5
7
|
collection,
|
|
6
8
|
data: {
|
|
@@ -9,9 +11,12 @@ export const unlock = async ({ collection, req })=>{
|
|
|
9
11
|
req
|
|
10
12
|
});
|
|
11
13
|
return Response.json({
|
|
12
|
-
|
|
13
|
-
message: 'Success'
|
|
14
|
+
message: t('general:success')
|
|
14
15
|
}, {
|
|
16
|
+
headers: headersWithCors({
|
|
17
|
+
headers: new Headers(),
|
|
18
|
+
req
|
|
19
|
+
}),
|
|
15
20
|
status: httpStatus.OK
|
|
16
21
|
});
|
|
17
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/unlock.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { unlockOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const unlock: CollectionRouteHandler = async ({ collection, req }) => {\n await unlockOperation({\n collection,\n data: { email: req.data.email as string },\n req,\n })\n\n return Response.json(\n {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/unlock.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { unlockOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const unlock: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n\n await unlockOperation({\n collection,\n data: { email: req.data.email as string },\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","unlockOperation","headersWithCors","unlock","collection","req","t","data","email","Response","json","message","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,CAAC,EAAE,GAAGD;IAEd,MAAMJ,gBAAgB;QACpBG;QACAG,MAAM;YAAEC,OAAOH,IAAIE,IAAI,CAACC,KAAK;QAAW;QACxCH;IACF;IAEA,OAAOI,SAASC,IAAI,CAClB;QACEC,SAASL,EAAE;IACb,GACA;QACEM,SAASV,gBAAgB;YACvBU,SAAS,IAAIC;YACbR;QACF;QACAS,QAAQd,WAAWe,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,WAAW,EAAE,4BAoBzB,CAAA"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { verifyEmailOperation } from 'payload/operations';
|
|
3
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
3
4
|
export const verifyEmail = async ({ id, collection, req })=>{
|
|
5
|
+
const { t } = req;
|
|
4
6
|
await verifyEmailOperation({
|
|
5
7
|
collection,
|
|
6
8
|
req,
|
|
7
9
|
token: id
|
|
8
10
|
});
|
|
9
11
|
return Response.json({
|
|
10
|
-
|
|
11
|
-
message: 'Email verified successfully.'
|
|
12
|
+
message: t('authentication:emailVerified')
|
|
12
13
|
}, {
|
|
14
|
+
headers: headersWithCors({
|
|
15
|
+
headers: new Headers(),
|
|
16
|
+
req
|
|
17
|
+
}),
|
|
13
18
|
status: httpStatus.OK
|
|
14
19
|
});
|
|
15
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { verifyEmailOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nexport const verifyEmail: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n await verifyEmailOperation({\n collection,\n req,\n token: id,\n })\n\n return Response.json(\n {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { verifyEmailOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const verifyEmail: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { t } = req\n await verifyEmailOperation({\n collection,\n req,\n token: id,\n })\n\n return Response.json(\n {\n message: t('authentication:emailVerified'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","verifyEmailOperation","headersWithCors","verifyEmail","id","collection","req","t","token","Response","json","message","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,oBAAoB,QAAQ,qBAAoB;AAIzD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,cAA4C,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrF,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAML,qBAAqB;QACzBI;QACAC;QACAE,OAAOJ;IACT;IAEA,OAAOK,SAASC,IAAI,CAClB;QACEC,SAASJ,EAAE;IACb,GACA;QACEK,SAASV,gBAAgB;YACvBU,SAAS,IAAIC;YACbP;QACF;QACAQ,QAAQd,WAAWe,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/buildFormState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA8B,cAAc,EAAc,MAAM,eAAe,CAAA;AAM3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAA;
|
|
1
|
+
{"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/buildFormState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA8B,cAAc,EAAc,MAAM,eAAe,CAAA;AAM3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAA;AAYlF,eAAO,MAAM,iBAAiB,QAAS,cAAc,mBAQpD,CAAA;AAED,eAAO,MAAM,cAAc,YAAmB;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,sBAmMpE,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'
|
|
|
2
2
|
import { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues';
|
|
3
3
|
import httpStatus from 'http-status';
|
|
4
4
|
import { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js';
|
|
5
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
5
6
|
let cached = global._payload_fieldSchemaMap;
|
|
6
7
|
if (!cached) {
|
|
7
8
|
// eslint-disable-next-line no-multi-assign
|
|
@@ -15,6 +16,10 @@ export const getFieldSchemaMap = (req)=>{
|
|
|
15
16
|
return cached;
|
|
16
17
|
};
|
|
17
18
|
export const buildFormState = async ({ req })=>{
|
|
19
|
+
const headers = headersWithCors({
|
|
20
|
+
headers: new Headers(),
|
|
21
|
+
req
|
|
22
|
+
});
|
|
18
23
|
try {
|
|
19
24
|
const reqData = req.data;
|
|
20
25
|
const { collectionSlug, formState, globalSlug, locale, operation, schemaPath } = reqData;
|
|
@@ -30,17 +35,20 @@ export const buildFormState = async ({ req })=>{
|
|
|
30
35
|
});
|
|
31
36
|
if (!canAccessAdmin) {
|
|
32
37
|
return Response.json(null, {
|
|
38
|
+
headers,
|
|
33
39
|
status: httpStatus.UNAUTHORIZED
|
|
34
40
|
});
|
|
35
41
|
}
|
|
36
42
|
// Match the user collection to the global admin config
|
|
37
43
|
} else if (adminUserSlug !== incomingUserSlug) {
|
|
38
44
|
return Response.json(null, {
|
|
45
|
+
headers,
|
|
39
46
|
status: httpStatus.UNAUTHORIZED
|
|
40
47
|
});
|
|
41
48
|
}
|
|
42
49
|
} else {
|
|
43
50
|
return Response.json(null, {
|
|
51
|
+
headers,
|
|
44
52
|
status: httpStatus.UNAUTHORIZED
|
|
45
53
|
});
|
|
46
54
|
}
|
|
@@ -61,6 +69,7 @@ export const buildFormState = async ({ req })=>{
|
|
|
61
69
|
return Response.json({
|
|
62
70
|
message: 'Could not find field schema for given path'
|
|
63
71
|
}, {
|
|
72
|
+
headers,
|
|
64
73
|
status: httpStatus.BAD_REQUEST
|
|
65
74
|
});
|
|
66
75
|
}
|
|
@@ -145,13 +154,19 @@ export const buildFormState = async ({ req })=>{
|
|
|
145
154
|
},
|
|
146
155
|
req
|
|
147
156
|
});
|
|
157
|
+
// Maintain form state of file
|
|
158
|
+
if (collectionSlug && req.payload.collections[collectionSlug]?.config?.upload && formState && formState.file) {
|
|
159
|
+
result.file = formState.file;
|
|
160
|
+
}
|
|
148
161
|
return Response.json(result, {
|
|
162
|
+
headers,
|
|
149
163
|
status: httpStatus.OK
|
|
150
164
|
});
|
|
151
165
|
} catch (err) {
|
|
152
166
|
return Response.json({
|
|
153
167
|
message: 'There was an error building form state'
|
|
154
168
|
}, {
|
|
169
|
+
headers,
|
|
155
170
|
status: httpStatus.BAD_REQUEST
|
|
156
171
|
});
|
|
157
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/routes/rest/buildFormState.ts"],"sourcesContent":["import type { BuildFormStateArgs } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport type { DocumentPreferences, Field, PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues'\nimport httpStatus from 'http-status'\n\nimport type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.js'\n\nimport { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js'\n\nlet cached = global._payload_fieldSchemaMap\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_fieldSchemaMap = null\n}\n\nexport const getFieldSchemaMap = (req: PayloadRequest): FieldSchemaMap => {\n if (cached && process.env.NODE_ENV !== 'development') {\n return cached\n }\n\n cached = buildFieldSchemaMap(req)\n\n return cached\n}\n\nexport const buildFormState = async ({ req }: { req: PayloadRequest }) => {\n try {\n const reqData: BuildFormStateArgs = req.data as BuildFormStateArgs\n const { collectionSlug, formState, globalSlug, locale, operation, schemaPath } = reqData\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n return Response.json(null, {\n status: httpStatus.UNAUTHORIZED,\n })\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n return Response.json(null, {\n status: httpStatus.UNAUTHORIZED,\n })\n }\n } else {\n return Response.json(null, {\n status: httpStatus.UNAUTHORIZED,\n })\n }\n\n const fieldSchemaMap = getFieldSchemaMap(req)\n\n const id = collectionSlug ? reqData.id : undefined\n const schemaPathSegments = schemaPath.split('.')\n\n let fieldSchema: Field[]\n\n if (schemaPathSegments.length === 1) {\n if (req.payload.collections[schemaPath]) {\n fieldSchema = req.payload.collections[schemaPath].config.fields\n } else {\n fieldSchema = req.payload.config.globals.find(\n (global) => global.slug === schemaPath,\n )?.fields\n }\n } else if (fieldSchemaMap.has(schemaPath)) {\n fieldSchema = fieldSchemaMap.get(schemaPath)\n }\n\n if (!fieldSchema) {\n return Response.json(\n {\n message: 'Could not find field schema for given path',\n },\n {\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n let docPreferences = reqData.docPreferences\n let data = reqData.data\n\n const promises: {\n data?: Promise<void>\n preferences?: Promise<void>\n } = {}\n\n // If the request does not include doc preferences,\n // we should fetch them. This is useful for DocumentInfoProvider\n // as it reduces the amount of client-side fetches necessary\n // when we fetch data for the Edit view\n if (!docPreferences) {\n let preferencesKey\n\n if (collectionSlug && id) {\n preferencesKey = `collection-${collectionSlug}-${id}`\n }\n\n if (globalSlug) {\n preferencesKey = `global-${globalSlug}`\n }\n\n if (preferencesKey) {\n const fetchPreferences = async () => {\n const preferencesResult = (await req.payload.find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n key: {\n equals: preferencesKey,\n },\n },\n })) as unknown as { docs: { value: DocumentPreferences }[] }\n\n if (preferencesResult?.docs?.[0]?.value) docPreferences = preferencesResult.docs[0].value\n }\n\n promises.preferences = fetchPreferences()\n }\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) data = reduceFieldsToValues(formState, true)\n\n // If we do not have data at this point,\n // we can fetch it. This is useful for DocumentInfoProvider\n // to reduce the amount of fetches required\n if (!data) {\n const fetchData = async () => {\n let resolvedData: TypeWithID\n\n if (collectionSlug && id) {\n resolvedData = await req.payload.findByID({\n id,\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n if (globalSlug && schemaPath === globalSlug) {\n resolvedData = await req.payload.findGlobal({\n slug: globalSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n data = resolvedData\n }\n\n promises.data = fetchData()\n }\n\n if (Object.keys(promises).length > 0) {\n await Promise.all(Object.values(promises))\n }\n\n const result = await buildStateFromSchema({\n id,\n data,\n fieldSchema,\n operation,\n preferences: docPreferences || { fields: {} },\n req,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n } catch (err) {\n return Response.json(\n {\n message: 'There was an error building form state',\n },\n {\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n}\n"],"names":["buildStateFromSchema","reduceFieldsToValues","httpStatus","buildFieldSchemaMap","cached","global","_payload_fieldSchemaMap","getFieldSchemaMap","req","process","env","NODE_ENV","buildFormState","reqData","data","collectionSlug","formState","globalSlug","locale","operation","schemaPath","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFunction","collections","access","canAccessAdmin","Response","json","status","UNAUTHORIZED","fieldSchemaMap","id","undefined","schemaPathSegments","split","fieldSchema","length","fields","globals","find","slug","has","get","message","BAD_REQUEST","docPreferences","promises","preferencesKey","fetchPreferences","preferencesResult","depth","limit","where","key","equals","docs","value","preferences","fetchData","resolvedData","findByID","draft","fallbackLocale","overrideAccess","findGlobal","Object","keys","Promise","all","values","result","OK","err"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,oBAAoB,QAAQ,4CAA2C;AAChF,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,OAAOC,gBAAgB,cAAa;AAIpC,SAASC,mBAAmB,QAAQ,+CAA8C;AAElF,IAAIC,SAASC,OAAOC,uBAAuB;AAE3C,IAAI,CAACF,QAAQ;IACX,2CAA2C;IAC3CA,SAASC,OAAOC,uBAAuB,GAAG;AAC5C;AAEA,OAAO,MAAMC,oBAAoB,CAACC;IAChC,IAAIJ,UAAUK,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QACpD,OAAOP;IACT;IAEAA,SAASD,oBAAoBK;IAE7B,OAAOJ;AACT,EAAC;AAED,OAAO,MAAMQ,iBAAiB,OAAO,EAAEJ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EJ,IAAIlD,kBAAkBsB,IAAI;oBACxB4B,eAAe,MAAMzD,IAAIiB,OAAO,CAACyC,QAAQ,CAAC;wBACxC7B;wBACAd,YAAYR;wBACZyC,OAAO;wBACPW,OAAO;wBACPC,gBAAgB;wBAChBlD;wBACAmD,gBAAgB;wBAChB/C,MAAMd,IAAIc,IAAI;oBAChB;gBACF;gBAEA,IAAIL,cAAcG,eAAeH,YAAY;oBAC3CgD,eAAe,MAAMzD,IAAIiB,OAAO,CAAC6C,UAAU,CAAC;wBAC1CxB,MAAM7B;wBACNuC,OAAO;wBACPW,OAAO;wBACPC,gBAAgB;wBAChBlD;wBACAmD,gBAAgB;wBAChB/C,MAAMd,IAAIc,IAAI;oBAChB;gBACF;gBAEAR,OAAOmD;YACT;YAEAb,SAAStC,IAAI,GAAGkD;QAClB;QAEA,IAAIO,OAAOC,IAAI,CAACpB,UAAUV,MAAM,GAAG,GAAG;YACpC,MAAM+B,QAAQC,GAAG,CAACH,OAAOI,MAAM,CAACvB;QAClC;QAEA,MAAMwB,SAAS,MAAM5E,qBAAqB;YACxCqC;YACAvB;YACA2B;YACAtB;YACA4C,aAAaZ,kBAAkB;gBAAER,QAAQ,CAAC;YAAE;YAC5CnC;QACF;QAEA,OAAOwB,SAASC,IAAI,CAAC2C,QAAQ;YAC3B1C,QAAQhC,WAAW2E,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZ,OAAO9C,SAASC,IAAI,CAClB;YACEgB,SAAS;QACX,GACA;YACEf,QAAQhC,WAAWgD,WAAW;QAChC;IAEJ;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/rest/buildFormState.ts"],"sourcesContent":["import type { BuildFormStateArgs } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport type { DocumentPreferences, Field, PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues'\nimport httpStatus from 'http-status'\n\nimport type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.js'\n\nimport { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nlet cached = global._payload_fieldSchemaMap\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_fieldSchemaMap = null\n}\n\nexport const getFieldSchemaMap = (req: PayloadRequest): FieldSchemaMap => {\n if (cached && process.env.NODE_ENV !== 'development') {\n return cached\n }\n\n cached = buildFieldSchemaMap(req)\n\n return cached\n}\n\nexport const buildFormState = async ({ req }: { req: PayloadRequest }) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const reqData: BuildFormStateArgs = req.data as BuildFormStateArgs\n const { collectionSlug, formState, globalSlug, locale, operation, schemaPath } = reqData\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n } else {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n\n const fieldSchemaMap = getFieldSchemaMap(req)\n\n const id = collectionSlug ? reqData.id : undefined\n const schemaPathSegments = schemaPath.split('.')\n\n let fieldSchema: Field[]\n\n if (schemaPathSegments.length === 1) {\n if (req.payload.collections[schemaPath]) {\n fieldSchema = req.payload.collections[schemaPath].config.fields\n } else {\n fieldSchema = req.payload.config.globals.find(\n (global) => global.slug === schemaPath,\n )?.fields\n }\n } else if (fieldSchemaMap.has(schemaPath)) {\n fieldSchema = fieldSchemaMap.get(schemaPath)\n }\n\n if (!fieldSchema) {\n return Response.json(\n {\n message: 'Could not find field schema for given path',\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n let docPreferences = reqData.docPreferences\n let data = reqData.data\n\n const promises: {\n data?: Promise<void>\n preferences?: Promise<void>\n } = {}\n\n // If the request does not include doc preferences,\n // we should fetch them. This is useful for DocumentInfoProvider\n // as it reduces the amount of client-side fetches necessary\n // when we fetch data for the Edit view\n if (!docPreferences) {\n let preferencesKey\n\n if (collectionSlug && id) {\n preferencesKey = `collection-${collectionSlug}-${id}`\n }\n\n if (globalSlug) {\n preferencesKey = `global-${globalSlug}`\n }\n\n if (preferencesKey) {\n const fetchPreferences = async () => {\n const preferencesResult = (await req.payload.find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n key: {\n equals: preferencesKey,\n },\n },\n })) as unknown as { docs: { value: DocumentPreferences }[] }\n\n if (preferencesResult?.docs?.[0]?.value) docPreferences = preferencesResult.docs[0].value\n }\n\n promises.preferences = fetchPreferences()\n }\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) data = reduceFieldsToValues(formState, true)\n\n // If we do not have data at this point,\n // we can fetch it. This is useful for DocumentInfoProvider\n // to reduce the amount of fetches required\n if (!data) {\n const fetchData = async () => {\n let resolvedData: TypeWithID\n\n if (collectionSlug && id) {\n resolvedData = await req.payload.findByID({\n id,\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n if (globalSlug && schemaPath === globalSlug) {\n resolvedData = await req.payload.findGlobal({\n slug: globalSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n data = resolvedData\n }\n\n promises.data = fetchData()\n }\n\n if (Object.keys(promises).length > 0) {\n await Promise.all(Object.values(promises))\n }\n\n const result = await buildStateFromSchema({\n id,\n data,\n fieldSchema,\n operation,\n preferences: docPreferences || { fields: {} },\n req,\n })\n\n // Maintain form state of file\n if (\n collectionSlug &&\n req.payload.collections[collectionSlug]?.config?.upload &&\n formState &&\n formState.file\n ) {\n result.file = formState.file\n }\n\n return Response.json(result, {\n headers,\n status: httpStatus.OK,\n })\n } catch (err) {\n return Response.json(\n {\n message: 'There was an error building form state',\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n}\n"],"names":["buildStateFromSchema","reduceFieldsToValues","httpStatus","buildFieldSchemaMap","headersWithCors","cached","global","_payload_fieldSchemaMap","getFieldSchemaMap","req","process","env","NODE_ENV","buildFormState","headers","Headers","reqData","data","collectionSlug","formState","globalSlug","locale","operation","schemaPath","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFunction","collections","access","canAccessAdmin","Response","json","status","UNAUTHORIZED","fieldSchemaMap","id","undefined","schemaPathSegments","split","fieldSchema","length","fields","globals","find","slug","has","get","message","BAD_REQUEST","docPreferences","promises","preferencesKey","fetchPreferences","preferencesResult","depth","limit","where","key","equals","docs","value","preferences","fetchData","resolvedData","findByID","draft","fallbackLocale","overrideAccess","findGlobal","Object","keys","Promise","all","values","result","upload","file","OK","err"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,oBAAoB,QAAQ,4CAA2C;AAChF,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,OAAOC,gBAAgB,cAAa;AAIpC,SAASC,mBAAmB,QAAQ,+CAA8C;AAClF,SAASC,eAAe,QAAQ,qCAAoC;AAEpE,IAAIC,SAASC,OAAOC,uBAAuB;AA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ACjD7D,aACAA,UAAU8D,IAAI,EACd;YACAF,OAAOE,IAAI,GAAG9D,UAAU8D,IAAI;QAC9B;QAEA,OAAO9C,SAASC,IAAI,CAAC2C,QAAQ;YAC3BjE;YACAuB,QAAQnC,WAAWgF,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZ,OAAOhD,SAASC,IAAI,CAClB;YACEgB,SAAS;QACX,GACA;YACEtC;YACAuB,QAAQnC,WAAWmD,WAAW;QAChC;IAEJ;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/count.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,KAAK,EAAE,sBAcnB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import httpStatus from 'http-status';
|
|
2
|
+
import { countOperation } from 'payload/operations';
|
|
3
|
+
export const count = async ({ collection, req })=>{
|
|
4
|
+
const { where } = req.query;
|
|
5
|
+
const result = await countOperation({
|
|
6
|
+
collection,
|
|
7
|
+
req,
|
|
8
|
+
where
|
|
9
|
+
});
|
|
10
|
+
return Response.json(result, {
|
|
11
|
+
status: httpStatus.OK
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=count.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/collections/count.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport httpStatus from 'http-status'\nimport { countOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const count: CollectionRouteHandler = async ({ collection, req }) => {\n const { where } = req.query as {\n where?: Where\n }\n\n const result = await countOperation({\n collection,\n req,\n where,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","countOperation","count","collection","req","where","query","result","Response","json","status","OK"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,cAAc,QAAQ,qBAAoB;AAInD,OAAO,MAAMC,QAAgC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrE,MAAM,EAAEC,KAAK,EAAE,GAAGD,IAAIE,KAAK;IAI3B,MAAMC,SAAS,MAAMN,eAAe;QAClCE;QACAC;QACAC;IACF;IAEA,OAAOG,SAASC,IAAI,CAACF,QAAQ;QAC3BG,QAAQV,WAAWW,EAAE;IACvB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBA8BpB,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { getTranslation } from '@payloadcms/translations';
|
|
|
2
2
|
import httpStatus from 'http-status';
|
|
3
3
|
import { createOperation } from 'payload/operations';
|
|
4
4
|
import { isNumber } from 'payload/utilities';
|
|
5
|
+
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
6
|
export const create = async ({ collection, req })=>{
|
|
6
7
|
const { searchParams } = req;
|
|
7
8
|
const autosave = searchParams.get('autosave') === 'true';
|
|
@@ -21,6 +22,10 @@ export const create = async ({ collection, req })=>{
|
|
|
21
22
|
label: getTranslation(collection.config.labels.singular, req.i18n)
|
|
22
23
|
})
|
|
23
24
|
}, {
|
|
25
|
+
headers: headersWithCors({
|
|
26
|
+
headers: new Headers(),
|
|
27
|
+
req
|
|
28
|
+
}),
|
|
24
29
|
status: httpStatus.CREATED
|
|
25
30
|
});
|
|
26
31
|
};
|