payload 3.19.0-canary.edf2c5e → 3.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/auth/endpoints/access.d.ts.map +1 -1
  2. package/dist/auth/endpoints/access.js +7 -0
  3. package/dist/auth/endpoints/access.js.map +1 -1
  4. package/dist/auth/endpoints/forgotPassword.d.ts.map +1 -1
  5. package/dist/auth/endpoints/forgotPassword.js +5 -0
  6. package/dist/auth/endpoints/forgotPassword.js.map +1 -1
  7. package/dist/auth/endpoints/init.d.ts.map +1 -1
  8. package/dist/auth/endpoints/init.js +6 -0
  9. package/dist/auth/endpoints/init.js.map +1 -1
  10. package/dist/auth/endpoints/login.d.ts.map +1 -1
  11. package/dist/auth/endpoints/login.js +6 -2
  12. package/dist/auth/endpoints/login.js.map +1 -1
  13. package/dist/auth/endpoints/logout.d.ts.map +1 -1
  14. package/dist/auth/endpoints/logout.js +7 -3
  15. package/dist/auth/endpoints/logout.js.map +1 -1
  16. package/dist/auth/endpoints/me.d.ts.map +1 -1
  17. package/dist/auth/endpoints/me.js +5 -0
  18. package/dist/auth/endpoints/me.js.map +1 -1
  19. package/dist/auth/endpoints/refresh.d.ts.map +1 -1
  20. package/dist/auth/endpoints/refresh.js +5 -1
  21. package/dist/auth/endpoints/refresh.js.map +1 -1
  22. package/dist/auth/endpoints/registerFirstUser.d.ts.map +1 -1
  23. package/dist/auth/endpoints/registerFirstUser.js +6 -2
  24. package/dist/auth/endpoints/registerFirstUser.js.map +1 -1
  25. package/dist/auth/endpoints/resetPassword.d.ts.map +1 -1
  26. package/dist/auth/endpoints/resetPassword.js +6 -2
  27. package/dist/auth/endpoints/resetPassword.js.map +1 -1
  28. package/dist/auth/endpoints/unlock.d.ts.map +1 -1
  29. package/dist/auth/endpoints/unlock.js +5 -0
  30. package/dist/auth/endpoints/unlock.js.map +1 -1
  31. package/dist/auth/endpoints/verifyEmail.d.ts.map +1 -1
  32. package/dist/auth/endpoints/verifyEmail.js +5 -0
  33. package/dist/auth/endpoints/verifyEmail.js.map +1 -1
  34. package/dist/collections/endpoints/create.d.ts.map +1 -1
  35. package/dist/collections/endpoints/create.js +5 -0
  36. package/dist/collections/endpoints/create.js.map +1 -1
  37. package/dist/collections/endpoints/delete.d.ts.map +1 -1
  38. package/dist/collections/endpoints/delete.js +7 -0
  39. package/dist/collections/endpoints/delete.js.map +1 -1
  40. package/dist/collections/endpoints/deleteByID.d.ts.map +1 -1
  41. package/dist/collections/endpoints/deleteByID.js +7 -0
  42. package/dist/collections/endpoints/deleteByID.js.map +1 -1
  43. package/dist/collections/endpoints/docAccess.d.ts.map +1 -1
  44. package/dist/collections/endpoints/docAccess.js +5 -0
  45. package/dist/collections/endpoints/docAccess.js.map +1 -1
  46. package/dist/collections/endpoints/duplicate.d.ts.map +1 -1
  47. package/dist/collections/endpoints/duplicate.js +5 -0
  48. package/dist/collections/endpoints/duplicate.js.map +1 -1
  49. package/dist/collections/endpoints/find.d.ts.map +1 -1
  50. package/dist/collections/endpoints/find.js +5 -0
  51. package/dist/collections/endpoints/find.js.map +1 -1
  52. package/dist/collections/endpoints/findByID.d.ts.map +1 -1
  53. package/dist/collections/endpoints/findByID.js +5 -0
  54. package/dist/collections/endpoints/findByID.js.map +1 -1
  55. package/dist/collections/endpoints/findVersionByID.d.ts.map +1 -1
  56. package/dist/collections/endpoints/findVersionByID.js +5 -0
  57. package/dist/collections/endpoints/findVersionByID.js.map +1 -1
  58. package/dist/collections/endpoints/findVersions.d.ts.map +1 -1
  59. package/dist/collections/endpoints/findVersions.js +5 -0
  60. package/dist/collections/endpoints/findVersions.js.map +1 -1
  61. package/dist/collections/endpoints/getFile.d.ts.map +1 -1
  62. package/dist/collections/endpoints/getFile.js +5 -1
  63. package/dist/collections/endpoints/getFile.js.map +1 -1
  64. package/dist/collections/endpoints/preview.d.ts.map +1 -1
  65. package/dist/collections/endpoints/preview.js +5 -0
  66. package/dist/collections/endpoints/preview.js.map +1 -1
  67. package/dist/collections/endpoints/restoreVersion.d.ts.map +1 -1
  68. package/dist/collections/endpoints/restoreVersion.js +5 -0
  69. package/dist/collections/endpoints/restoreVersion.js.map +1 -1
  70. package/dist/collections/endpoints/update.d.ts.map +1 -1
  71. package/dist/collections/endpoints/update.js +7 -0
  72. package/dist/collections/endpoints/update.js.map +1 -1
  73. package/dist/collections/endpoints/updateByID.d.ts.map +1 -1
  74. package/dist/collections/endpoints/updateByID.js +5 -0
  75. package/dist/collections/endpoints/updateByID.js.map +1 -1
  76. package/dist/fields/config/client.d.ts.map +1 -1
  77. package/dist/fields/config/client.js +22 -0
  78. package/dist/fields/config/client.js.map +1 -1
  79. package/dist/fields/config/types.d.ts +4 -0
  80. package/dist/fields/config/types.d.ts.map +1 -1
  81. package/dist/fields/config/types.js.map +1 -1
  82. package/dist/globals/endpoints/docAccess.d.ts.map +1 -1
  83. package/dist/globals/endpoints/docAccess.js +5 -0
  84. package/dist/globals/endpoints/docAccess.js.map +1 -1
  85. package/dist/globals/endpoints/findOne.d.ts.map +1 -1
  86. package/dist/globals/endpoints/findOne.js +5 -0
  87. package/dist/globals/endpoints/findOne.js.map +1 -1
  88. package/dist/globals/endpoints/findVersionByID.d.ts.map +1 -1
  89. package/dist/globals/endpoints/findVersionByID.js +5 -0
  90. package/dist/globals/endpoints/findVersionByID.js.map +1 -1
  91. package/dist/globals/endpoints/findVersions.d.ts.map +1 -1
  92. package/dist/globals/endpoints/findVersions.js +5 -0
  93. package/dist/globals/endpoints/findVersions.js.map +1 -1
  94. package/dist/globals/endpoints/preview.d.ts.map +1 -1
  95. package/dist/globals/endpoints/preview.js +5 -0
  96. package/dist/globals/endpoints/preview.js.map +1 -1
  97. package/dist/globals/endpoints/restoreVersion.d.ts.map +1 -1
  98. package/dist/globals/endpoints/restoreVersion.js +5 -0
  99. package/dist/globals/endpoints/restoreVersion.js.map +1 -1
  100. package/dist/globals/endpoints/update.d.ts.map +1 -1
  101. package/dist/globals/endpoints/update.js +5 -0
  102. package/dist/globals/endpoints/update.js.map +1 -1
  103. package/dist/index.d.ts +1 -1
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +1 -1
  106. package/dist/index.js.map +1 -1
  107. package/dist/utilities/handleEndpoints.d.ts +3 -1
  108. package/dist/utilities/handleEndpoints.d.ts.map +1 -1
  109. package/dist/utilities/handleEndpoints.js +20 -18
  110. package/dist/utilities/handleEndpoints.js.map +1 -1
  111. package/dist/utilities/headersWithCors.d.ts +0 -5
  112. package/dist/utilities/headersWithCors.d.ts.map +1 -1
  113. package/dist/utilities/headersWithCors.js +0 -4
  114. package/dist/utilities/headersWithCors.js.map +1 -1
  115. package/dist/utilities/routeError.d.ts.map +1 -1
  116. package/dist/utilities/routeError.js +7 -0
  117. package/dist/utilities/routeError.js.map +1 -1
  118. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/access.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,eAAO,MAAM,aAAa,EAAE,cAmB3B,CAAA"}
1
+ {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/access.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAK3D,eAAO,MAAM,aAAa,EAAE,cA0B3B,CAAA"}
@@ -1,17 +1,24 @@
1
1
  import { status as httpStatus } from 'http-status';
2
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
2
3
  import { accessOperation } from '../operations/access.js';
3
4
  export const accessHandler = async (req)=>{
5
+ const headers = headersWithCors({
6
+ headers: new Headers(),
7
+ req
8
+ });
4
9
  try {
5
10
  const results = await accessOperation({
6
11
  req
7
12
  });
8
13
  return Response.json(results, {
14
+ headers,
9
15
  status: httpStatus.OK
10
16
  });
11
17
  } catch (e) {
12
18
  return Response.json({
13
19
  error: e
14
20
  }, {
21
+ headers,
15
22
  status: httpStatus.INTERNAL_SERVER_ERROR
16
23
  });
17
24
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/access.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { accessOperation } from '../operations/access.js'\n\nexport const accessHandler: PayloadHandler = async (req) => {\n try {\n const results = await accessOperation({\n req,\n })\n\n return Response.json(results, {\n status: httpStatus.OK,\n })\n } catch (e: unknown) {\n return Response.json(\n {\n error: e,\n },\n {\n status: httpStatus.INTERNAL_SERVER_ERROR,\n },\n )\n }\n}\n"],"names":["status","httpStatus","accessOperation","accessHandler","req","results","Response","json","OK","e","error","INTERNAL_SERVER_ERROR"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,IAAI;QACF,MAAMC,UAAU,MAAMH,gBAAgB;YACpCE;QACF;QAEA,OAAOE,SAASC,IAAI,CAACF,SAAS;YAC5BL,QAAQC,WAAWO,EAAE;QACvB;IACF,EAAE,OAAOC,GAAY;QACnB,OAAOH,SAASC,IAAI,CAClB;YACEG,OAAOD;QACT,GACA;YACET,QAAQC,WAAWU,qBAAqB;QAC1C;IAEJ;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/access.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { accessOperation } from '../operations/access.js'\n\nexport const accessHandler: PayloadHandler = async (req) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const results = await accessOperation({\n req,\n })\n\n return Response.json(results, {\n headers,\n status: httpStatus.OK,\n })\n } catch (e: unknown) {\n return Response.json(\n {\n error: e,\n },\n {\n headers,\n status: httpStatus.INTERNAL_SERVER_ERROR,\n },\n )\n }\n}\n"],"names":["status","httpStatus","headersWithCors","accessOperation","accessHandler","req","headers","Headers","results","Response","json","OK","e","error","INTERNAL_SERVER_ERROR"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,UAAUJ,gBAAgB;QAC9BI,SAAS,IAAIC;QACbF;IACF;IAEA,IAAI;QACF,MAAMG,UAAU,MAAML,gBAAgB;YACpCE;QACF;QAEA,OAAOI,SAASC,IAAI,CAACF,SAAS;YAC5BF;YACAN,QAAQC,WAAWU,EAAE;QACvB;IACF,EAAE,OAAOC,GAAY;QACnB,OAAOH,SAASC,IAAI,CAClB;YACEG,OAAOD;QACT,GACA;YACEN;YACAN,QAAQC,WAAWa,qBAAqB;QAC1C;IAEJ;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/forgotPassword.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAK3D,eAAO,MAAM,qBAAqB,EAAE,cA8BnC,CAAA"}
1
+ {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/forgotPassword.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,qBAAqB,EAAE,cAkCnC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { status as httpStatus } from 'http-status';
2
2
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
3
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
3
4
  import { forgotPasswordOperation } from '../operations/forgotPassword.js';
4
5
  export const forgotPasswordHandler = async (req)=>{
5
6
  const { t } = req;
@@ -20,6 +21,10 @@ export const forgotPasswordHandler = async (req)=>{
20
21
  return Response.json({
21
22
  message: t('general:success')
22
23
  }, {
24
+ headers: headersWithCors({
25
+ headers: new Headers(),
26
+ req
27
+ }),
23
28
  status: httpStatus.OK
24
29
  });
25
30
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/forgotPassword.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { forgotPasswordOperation } from '../operations/forgotPassword.js'\n\nexport const forgotPasswordHandler: PayloadHandler = async (req) => {\n const { t } = req\n\n const collection = getRequestCollection(req)\n\n const authData = collection.config.auth?.loginWithUsername\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n }\n\n await forgotPasswordOperation({\n collection,\n data: authData,\n disableEmail: Boolean(req.data?.disableEmail),\n expiration: typeof req.data.expiration === 'number' ? req.data.expiration : undefined,\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollection","forgotPasswordOperation","forgotPasswordHandler","req","t","collection","authData","config","auth","loginWithUsername","email","data","username","disableEmail","Boolean","expiration","undefined","Response","json","message","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,uBAAuB,QAAQ,kCAAiC;AAEzE,OAAO,MAAMC,wBAAwC,OAAOC;IAC1D,MAAM,EAAEC,CAAC,EAAE,GAAGD;IAEd,MAAME,aAAaL,qBAAqBG;IAExC,MAAMG,WAAWD,WAAWE,MAAM,CAACC,IAAI,EAAEC,oBACrC;QACEC,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOT,IAAIQ,IAAI,EAAEC,aAAa,WAAWT,IAAIQ,IAAI,CAACC,QAAQ,GAAG;IACzE,IACA;QACEF,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;IAChE;IAEJ,MAAMT,wBAAwB;QAC5BI;QACAM,MAAML;QACNO,cAAcC,QAAQX,IAAIQ,IAAI,EAAEE;QAChCE,YAAY,OAAOZ,IAAIQ,IAAI,CAACI,UAAU,KAAK,WAAWZ,IAAIQ,IAAI,CAACI,UAAU,GAAGC;QAC5Eb;IACF;IAEA,OAAOc,SAASC,IAAI,CAClB;QACEC,SAASf,EAAE;IACb,GACA;QACEN,QAAQC,WAAWqB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/forgotPassword.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { forgotPasswordOperation } from '../operations/forgotPassword.js'\n\nexport const forgotPasswordHandler: PayloadHandler = async (req) => {\n const { t } = req\n\n const collection = getRequestCollection(req)\n\n const authData = collection.config.auth?.loginWithUsername\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n }\n\n await forgotPasswordOperation({\n collection,\n data: authData,\n disableEmail: Boolean(req.data?.disableEmail),\n expiration: typeof req.data.expiration === 'number' ? req.data.expiration : undefined,\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":["status","httpStatus","getRequestCollection","headersWithCors","forgotPasswordOperation","forgotPasswordHandler","req","t","collection","authData","config","auth","loginWithUsername","email","data","username","disableEmail","Boolean","expiration","undefined","Response","json","message","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,uBAAuB,QAAQ,kCAAiC;AAEzE,OAAO,MAAMC,wBAAwC,OAAOC;IAC1D,MAAM,EAAEC,CAAC,EAAE,GAAGD;IAEd,MAAME,aAAaN,qBAAqBI;IAExC,MAAMG,WAAWD,WAAWE,MAAM,CAACC,IAAI,EAAEC,oBACrC;QACEC,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOT,IAAIQ,IAAI,EAAEC,aAAa,WAAWT,IAAIQ,IAAI,CAACC,QAAQ,GAAG;IACzE,IACA;QACEF,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;IAChE;IAEJ,MAAMT,wBAAwB;QAC5BI;QACAM,MAAML;QACNO,cAAcC,QAAQX,IAAIQ,IAAI,EAAEE;QAChCE,YAAY,OAAOZ,IAAIQ,IAAI,CAACI,UAAU,KAAK,WAAWZ,IAAIQ,IAAI,CAACI,UAAU,GAAGC;QAC5Eb;IACF;IAEA,OAAOc,SAASC,IAAI,CAClB;QACEC,SAASf,EAAE;IACb,GACA;QACEgB,SAASpB,gBAAgB;YACvBoB,SAAS,IAAIC;YACblB;QACF;QACAN,QAAQC,WAAWwB,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAK3D,eAAO,MAAM,WAAW,EAAE,cAOzB,CAAA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,WAAW,EAAE,cAezB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
2
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
2
3
  import { initOperation } from '../operations/init.js';
3
4
  export const initHandler = async (req)=>{
4
5
  const initialized = await initOperation({
@@ -7,6 +8,11 @@ export const initHandler = async (req)=>{
7
8
  });
8
9
  return Response.json({
9
10
  initialized
11
+ }, {
12
+ headers: headersWithCors({
13
+ headers: new Headers(),
14
+ req
15
+ })
10
16
  });
11
17
  };
12
18
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/init.ts"],"sourcesContent":["import type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { initOperation } from '../operations/init.js'\n\nexport const initHandler: PayloadHandler = async (req) => {\n const initialized = await initOperation({\n collection: getRequestCollection(req).config.slug,\n req,\n })\n\n return Response.json({ initialized })\n}\n"],"names":["getRequestCollection","initOperation","initHandler","req","initialized","collection","config","slug","Response","json"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,aAAa,QAAQ,wBAAuB;AAErD,OAAO,MAAMC,cAA8B,OAAOC;IAChD,MAAMC,cAAc,MAAMH,cAAc;QACtCI,YAAYL,qBAAqBG,KAAKG,MAAM,CAACC,IAAI;QACjDJ;IACF;IAEA,OAAOK,SAASC,IAAI,CAAC;QAAEL;IAAY;AACrC,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/init.ts"],"sourcesContent":["import type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { initOperation } from '../operations/init.js'\n\nexport const initHandler: PayloadHandler = async (req) => {\n const initialized = await initOperation({\n collection: getRequestCollection(req).config.slug,\n req,\n })\n\n return Response.json(\n { initialized },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n },\n )\n}\n"],"names":["getRequestCollection","headersWithCors","initOperation","initHandler","req","initialized","collection","config","slug","Response","json","headers","Headers"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,wBAAuB;AAErD,OAAO,MAAMC,cAA8B,OAAOC;IAChD,MAAMC,cAAc,MAAMH,cAAc;QACtCI,YAAYN,qBAAqBI,KAAKG,MAAM,CAACC,IAAI;QACjDJ;IACF;IAEA,OAAOK,SAASC,IAAI,CAClB;QAAEL;IAAY,GACd;QACEM,SAASV,gBAAgB;YACvBU,SAAS,IAAIC;YACbR;QACF;IACF;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,YAAY,EAAE,cA6C1B,CAAA"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAQ3D,eAAO,MAAM,YAAY,EAAE,cAgD1B,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { status as httpStatus } from 'http-status';
2
2
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
3
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
3
4
  import { isNumber } from '../../utilities/isNumber.js';
4
5
  import { generatePayloadCookie } from '../cookies.js';
5
6
  import { loginOperation } from '../operations/login.js';
@@ -33,8 +34,11 @@ export const loginHandler = async (req)=>{
33
34
  message: t('authentication:passed'),
34
35
  ...result
35
36
  }, {
36
- headers: new Headers({
37
- 'Set-Cookie': cookie
37
+ headers: headersWithCors({
38
+ headers: new Headers({
39
+ 'Set-Cookie': cookie
40
+ }),
41
+ req
38
42
  }),
39
43
  status: httpStatus.OK
40
44
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/login.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { generatePayloadCookie } from '../cookies.js'\nimport { loginOperation } from '../operations/login.js'\n\nexport const loginHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n const authData =\n collection.config.auth?.loginWithUsername !== false\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n }\n\n const result = await loginOperation({\n collection,\n data: authData,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\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: new Headers({\n 'Set-Cookie': cookie,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollection","isNumber","generatePayloadCookie","loginOperation","loginHandler","req","collection","searchParams","t","depth","get","authData","config","auth","loginWithUsername","email","data","password","username","result","Number","undefined","cookie","collectionAuthConfig","cookiePrefix","payload","token","removeTokenFromResponses","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,KAAK;IACrB;IAEA,OAAOE,SAASC,IAAI,CAClB;QACEC,SAAStB,EAAE;QACX,GAAGW,MAAM;IACX,GACA;QACEY,SAAS,IAAIC,QAAQ;YACnB,cAAcV;QAChB;QACAxB,QAAQC,WAAWkC,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/login.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { generatePayloadCookie } from '../cookies.js'\nimport { loginOperation } from '../operations/login.js'\n\nexport const loginHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n const authData =\n collection.config.auth?.loginWithUsername !== false\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n }\n\n const result = await loginOperation({\n collection,\n data: authData,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\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":["status","httpStatus","getRequestCollection","headersWithCors","isNumber","generatePayloadCookie","loginOperation","loginHandler","req","collection","searchParams","t","depth","get","authData","config","auth","loginWithUsername","email","data","password","username","result","Number","undefined","cookie","collectionAuthConfig","cookiePrefix","payload","token","removeTokenFromResponses","Response","json","message","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,SAASC,cAAc,QAAQ,yBAAwB;AAEvD,OAAO,MAAMC,eAA+B,OAAOC;IACjD,MAAMC,aAAaP,qBAAqBM;IACxC,MAAM,EAAEE,YAAY,EAAEC,CAAC,EAAE,GAAGH;IAC5B,MAAMI,QAAQF,aAAaG,GAAG,CAAC;IAC/B,MAAMC,WACJL,WAAWM,MAAM,CAACC,IAAI,EAAEC,sBAAsB,QAC1C;QACEC,OAAO,OAAOV,IAAIW,IAAI,EAAED,UAAU,WAAWV,IAAIW,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOZ,IAAIW,IAAI,EAAEC,aAAa,WAAWZ,IAAIW,IAAI,CAACC,QAAQ,GAAG;QACvEC,UAAU,OAAOb,IAAIW,IAAI,EAAEE,aAAa,WAAWb,IAAIW,IAAI,CAACE,QAAQ,GAAG;IACzE,IACA;QACEH,OAAO,OAAOV,IAAIW,IAAI,EAAED,UAAU,WAAWV,IAAIW,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOZ,IAAIW,IAAI,EAAEC,aAAa,WAAWZ,IAAIW,IAAI,CAACC,QAAQ,GAAG;IACzE;IAEN,MAAME,SAAS,MAAMhB,eAAe;QAClCG;QACAU,MAAML;QACNF,OAAOR,SAASQ,SAASW,OAAOX,SAASY;QACzChB;IACF;IAEA,MAAMiB,SAASpB,sBAAsB;QACnCqB,sBAAsBjB,WAAWM,MAAM,CAACC,IAAI;QAC5CW,cAAcnB,IAAIoB,OAAO,CAACb,MAAM,CAACY,YAAY;QAC7CE,OAAOP,OAAOO,KAAK;IACrB;IAEA,IAAIpB,WAAWM,MAAM,CAACC,IAAI,CAACc,wBAAwB,EAAE;QACnD,OAAOR,OAAOO,KAAK;IACrB;IAEA,OAAOE,SAASC,IAAI,CAClB;QACEC,SAAStB,EAAE;QACX,GAAGW,MAAM;IACX,GACA;QACEY,SAAS/B,gBAAgB;YACvB+B,SAAS,IAAIC,QAAQ;gBACnB,cAAcV;YAChB;YACAjB;QACF;QACAR,QAAQC,WAAWmC,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,aAAa,EAAE,cAsC3B,CAAA"}
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,aAAa,EAAE,cA0C3B,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { status as httpStatus } from 'http-status';
2
2
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
3
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
3
4
  import { generateExpiredPayloadCookie } from '../cookies.js';
4
5
  import { logoutOperation } from '../operations/logout.js';
5
6
  export const logoutHandler = async (req)=>{
@@ -9,10 +10,15 @@ export const logoutHandler = async (req)=>{
9
10
  collection,
10
11
  req
11
12
  });
13
+ const headers = headersWithCors({
14
+ headers: new Headers(),
15
+ req
16
+ });
12
17
  if (!result) {
13
18
  return Response.json({
14
19
  message: t('error:logoutFailed')
15
20
  }, {
21
+ headers,
16
22
  status: httpStatus.BAD_REQUEST
17
23
  });
18
24
  }
@@ -21,9 +27,7 @@ export const logoutHandler = async (req)=>{
21
27
  config: req.payload.config,
22
28
  cookiePrefix: req.payload.config.cookiePrefix
23
29
  });
24
- const headers = new Headers({
25
- 'Set-Cookie': expiredCookie
26
- });
30
+ headers.set('Set-Cookie', expiredCookie);
27
31
  return Response.json({
28
32
  message: t('authentication:logoutSuccessful')
29
33
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/logout.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { generateExpiredPayloadCookie } from '../cookies.js'\nimport { logoutOperation } from '../operations/logout.js'\n\nexport const logoutHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { t } = req\n const result = await logoutOperation({\n collection,\n req,\n })\n\n if (!result) {\n return Response.json(\n {\n message: t('error:logoutFailed'),\n },\n {\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n const expiredCookie = generateExpiredPayloadCookie({\n collectionAuthConfig: collection.config.auth,\n config: req.payload.config,\n cookiePrefix: req.payload.config.cookiePrefix,\n })\n\n const headers = new Headers({\n 'Set-Cookie': expiredCookie,\n })\n\n return Response.json(\n {\n message: t('authentication:logoutSuccessful'),\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollection","generateExpiredPayloadCookie","logoutOperation","logoutHandler","req","collection","t","result","Response","json","message","BAD_REQUEST","expiredCookie","collectionAuthConfig","config","auth","payload","cookiePrefix","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,4BAA4B,QAAQ,gBAAe;AAC5D,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,aAAaL,qBAAqBI;IACxC,MAAM,EAAEE,CAAC,EAAE,GAAGF;IACd,MAAMG,SAAS,MAAML,gBAAgB;QACnCG;QACAD;IACF;IAEA,IAAI,CAACG,QAAQ;QACX,OAAOC,SAASC,IAAI,CAClB;YACEC,SAASJ,EAAE;QACb,GACA;YACER,QAAQC,WAAWY,WAAW;QAChC;IAEJ;IAEA,MAAMC,gBAAgBX,6BAA6B;QACjDY,sBAAsBR,WAAWS,MAAM,CAACC,IAAI;QAC5CD,QAAQV,IAAIY,OAAO,CAACF,MAAM;QAC1BG,cAAcb,IAAIY,OAAO,CAACF,MAAM,CAACG,YAAY;IAC/C;IAEA,MAAMC,UAAU,IAAIC,QAAQ;QAC1B,cAAcP;IAChB;IAEA,OAAOJ,SAASC,IAAI,CAClB;QACEC,SAASJ,EAAE;IACb,GACA;QACEY;QACApB,QAAQC,WAAWqB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/logout.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { generateExpiredPayloadCookie } from '../cookies.js'\nimport { logoutOperation } from '../operations/logout.js'\n\nexport const logoutHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(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 collectionAuthConfig: collection.config.auth,\n config: req.payload.config,\n cookiePrefix: req.payload.config.cookiePrefix,\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":["status","httpStatus","getRequestCollection","headersWithCors","generateExpiredPayloadCookie","logoutOperation","logoutHandler","req","collection","t","result","headers","Headers","Response","json","message","BAD_REQUEST","expiredCookie","collectionAuthConfig","config","auth","payload","cookiePrefix","set","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,4BAA4B,QAAQ,gBAAe;AAC5D,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,aAAaN,qBAAqBK;IACxC,MAAM,EAAEE,CAAC,EAAE,GAAGF;IACd,MAAMG,SAAS,MAAML,gBAAgB;QACnCG;QACAD;IACF;IAEA,MAAMI,UAAUR,gBAAgB;QAC9BQ,SAAS,IAAIC;QACbL;IACF;IAEA,IAAI,CAACG,QAAQ;QACX,OAAOG,SAASC,IAAI,CAClB;YACEC,SAASN,EAAE;QACb,GACA;YACEE;YACAX,QAAQC,WAAWe,WAAW;QAChC;IAEJ;IAEA,MAAMC,gBAAgBb,6BAA6B;QACjDc,sBAAsBV,WAAWW,MAAM,CAACC,IAAI;QAC5CD,QAAQZ,IAAIc,OAAO,CAACF,MAAM;QAC1BG,cAAcf,IAAIc,OAAO,CAACF,MAAM,CAACG,YAAY;IAC/C;IAEAX,QAAQY,GAAG,CAAC,cAAcN;IAE1B,OAAOJ,SAASC,IAAI,CAClB;QACEC,SAASN,EAAE;IACb,GACA;QACEE;QACAX,QAAQC,WAAWuB,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/me.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,SAAS,EAAE,cAuBvB,CAAA"}
1
+ {"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/me.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,SAAS,EAAE,cA2BvB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { status as httpStatus } from 'http-status';
2
2
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
3
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
3
4
  import { extractJWT } from '../extractJWT.js';
4
5
  import { meOperation } from '../operations/me.js';
5
6
  export const meHandler = async (req)=>{
@@ -17,6 +18,10 @@ export const meHandler = async (req)=>{
17
18
  ...result,
18
19
  message: req.t('authentication:account')
19
20
  }, {
21
+ headers: headersWithCors({
22
+ headers: new Headers(),
23
+ req
24
+ }),
20
25
  status: httpStatus.OK
21
26
  });
22
27
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/me.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { extractJWT } from '../extractJWT.js'\nimport { meOperation } from '../operations/me.js'\n\nexport const meHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(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":["status","httpStatus","getRequestCollection","extractJWT","meOperation","meHandler","req","collection","currentToken","result","config","auth","removeTokenFromResponses","token","Response","json","message","t","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,mBAAkB;AAC7C,SAASC,WAAW,QAAQ,sBAAqB;AAEjD,OAAO,MAAMC,YAA4B,OAAOC;IAC9C,MAAMC,aAAaL,qBAAqBI;IACxC,MAAME,eAAeL,WAAWG;IAEhC,MAAMG,SAAS,MAAML,YAAY;QAC/BG;QACAC;QACAF;IACF;IAEA,IAAIC,WAAWG,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOH,OAAOI,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACE,GAAGN,MAAM;QACTO,SAASV,IAAIW,CAAC,CAAC;IACjB,GACA;QACEjB,QAAQC,WAAWiB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/me.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { extractJWT } from '../extractJWT.js'\nimport { meOperation } from '../operations/me.js'\n\nexport const meHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(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":["status","httpStatus","getRequestCollection","headersWithCors","extractJWT","meOperation","meHandler","req","collection","currentToken","result","config","auth","removeTokenFromResponses","token","Response","json","message","t","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,UAAU,QAAQ,mBAAkB;AAC7C,SAASC,WAAW,QAAQ,sBAAqB;AAEjD,OAAO,MAAMC,YAA4B,OAAOC;IAC9C,MAAMC,aAAaN,qBAAqBK;IACxC,MAAME,eAAeL,WAAWG;IAEhC,MAAMG,SAAS,MAAML,YAAY;QAC/BG;QACAC;QACAF;IACF;IAEA,IAAIC,WAAWG,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOH,OAAOI,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACE,GAAGN,MAAM;QACTO,SAASV,IAAIW,CAAC,CAAC;IACjB,GACA;QACEC,SAAShB,gBAAgB;YACvBgB,SAAS,IAAIC;YACbb;QACF;QACAP,QAAQC,WAAWoB,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/refresh.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,cAAc,EAAE,cAmC5B,CAAA"}
1
+ {"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/refresh.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,cAAc,EAAE,cAsC5B,CAAA"}
@@ -1,11 +1,15 @@
1
1
  import { status as httpStatus } from 'http-status';
2
2
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
3
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
3
4
  import { generatePayloadCookie } from '../cookies.js';
4
5
  import { refreshOperation } from '../operations/refresh.js';
5
6
  export const refreshHandler = async (req)=>{
6
7
  const collection = getRequestCollection(req);
7
8
  const { t } = req;
8
- const headers = new Headers();
9
+ const headers = headersWithCors({
10
+ headers: new Headers(),
11
+ req
12
+ });
9
13
  const result = await refreshOperation({
10
14
  collection,
11
15
  req
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/refresh.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { generatePayloadCookie } from '../cookies.js'\nimport { refreshOperation } from '../operations/refresh.js'\n\nexport const refreshHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { t } = req\n\n const headers = new Headers()\n\n const result = await refreshOperation({\n collection,\n req,\n })\n\n if (result.setCookie) {\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\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\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":["status","httpStatus","getRequestCollection","generatePayloadCookie","refreshOperation","refreshHandler","req","collection","t","headers","Headers","result","setCookie","cookie","collectionAuthConfig","config","auth","cookiePrefix","payload","token","refreshedToken","removeTokenFromResponses","set","Response","json","message","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,SAASC,gBAAgB,QAAQ,2BAA0B;AAE3D,OAAO,MAAMC,iBAAiC,OAAOC;IACnD,MAAMC,aAAaL,qBAAqBI;IACxC,MAAM,EAAEE,CAAC,EAAE,GAAGF;IAEd,MAAMG,UAAU,IAAIC;IAEpB,MAAMC,SAAS,MAAMP,iBAAiB;QACpCG;QACAD;IACF;IAEA,IAAIK,OAAOC,SAAS,EAAE;QACpB,MAAMC,SAASV,sBAAsB;YACnCW,sBAAsBP,WAAWQ,MAAM,CAACC,IAAI;YAC5CC,cAAcX,IAAIY,OAAO,CAACH,MAAM,CAACE,YAAY;YAC7CE,OAAOR,OAAOS,cAAc;QAC9B;QAEA,IAAIb,WAAWQ,MAAM,CAACC,IAAI,CAACK,wBAAwB,EAAE;YACnD,OAAOV,OAAOS,cAAc;QAC9B;QAEAX,QAAQa,GAAG,CAAC,cAAcT;IAC5B;IAEA,OAAOU,SAASC,IAAI,CAClB;QACEC,SAASjB,EAAE;QACX,GAAGG,MAAM;IACX,GACA;QACEF;QACAT,QAAQC,WAAWyB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/refresh.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { generatePayloadCookie } from '../cookies.js'\nimport { refreshOperation } from '../operations/refresh.js'\n\nexport const refreshHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { t } = req\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n const result = await refreshOperation({\n collection,\n req,\n })\n\n if (result.setCookie) {\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\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\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":["status","httpStatus","getRequestCollection","headersWithCors","generatePayloadCookie","refreshOperation","refreshHandler","req","collection","t","headers","Headers","result","setCookie","cookie","collectionAuthConfig","config","auth","cookiePrefix","payload","token","refreshedToken","removeTokenFromResponses","set","Response","json","message","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,SAASC,gBAAgB,QAAQ,2BAA0B;AAE3D,OAAO,MAAMC,iBAAiC,OAAOC;IACnD,MAAMC,aAAaN,qBAAqBK;IACxC,MAAM,EAAEE,CAAC,EAAE,GAAGF;IAEd,MAAMG,UAAUP,gBAAgB;QAC9BO,SAAS,IAAIC;QACbJ;IACF;IAEA,MAAMK,SAAS,MAAMP,iBAAiB;QACpCG;QACAD;IACF;IAEA,IAAIK,OAAOC,SAAS,EAAE;QACpB,MAAMC,SAASV,sBAAsB;YACnCW,sBAAsBP,WAAWQ,MAAM,CAACC,IAAI;YAC5CC,cAAcX,IAAIY,OAAO,CAACH,MAAM,CAACE,YAAY;YAC7CE,OAAOR,OAAOS,cAAc;QAC9B;QAEA,IAAIb,WAAWQ,MAAM,CAACC,IAAI,CAACK,wBAAwB,EAAE;YACnD,OAAOV,OAAOS,cAAc;QAC9B;QAEAX,QAAQa,GAAG,CAAC,cAAcT;IAC5B;IAEA,OAAOU,SAASC,IAAI,CAClB;QACEC,SAASjB,EAAE;QACX,GAAGG,MAAM;IACX,GACA;QACEF;QACAV,QAAQC,WAAW0B,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"registerFirstUser.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/registerFirstUser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,wBAAwB,EAAE,cA2CtC,CAAA"}
1
+ {"version":3,"file":"registerFirstUser.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/registerFirstUser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,wBAAwB,EAAE,cA8CtC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { status as httpStatus } from 'http-status';
2
2
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
3
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
3
4
  import { generatePayloadCookie } from '../cookies.js';
4
5
  import { registerFirstUserOperation } from '../operations/registerFirstUser.js';
5
6
  export const registerFirstUserHandler = async (req)=>{
@@ -32,8 +33,11 @@ export const registerFirstUserHandler = async (req)=>{
32
33
  token: result.token,
33
34
  user: result.user
34
35
  }, {
35
- headers: new Headers({
36
- 'Set-Cookie': cookie
36
+ headers: headersWithCors({
37
+ headers: new Headers({
38
+ 'Set-Cookie': cookie
39
+ }),
40
+ req
37
41
  }),
38
42
  status: httpStatus.OK
39
43
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/registerFirstUser.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { generatePayloadCookie } from '../cookies.js'\nimport { registerFirstUserOperation } from '../operations/registerFirstUser.js'\n\nexport const registerFirstUserHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { data, t } = req\n const authData = collection.config.auth?.loginWithUsername\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n }\n\n const result = await registerFirstUserOperation({\n collection,\n data: {\n ...data,\n ...authData,\n },\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\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: new Headers({\n 'Set-Cookie': cookie,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollection","generatePayloadCookie","registerFirstUserOperation","registerFirstUserHandler","req","collection","data","t","authData","config","auth","loginWithUsername","email","password","username","result","cookie","collectionAuthConfig","cookiePrefix","payload","token","Response","json","exp","message","user","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,c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;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/registerFirstUser.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { generatePayloadCookie } from '../cookies.js'\nimport { registerFirstUserOperation } from '../operations/registerFirstUser.js'\n\nexport const registerFirstUserHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { data, t } = req\n const authData = collection.config.auth?.loginWithUsername\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n }\n\n const result = await registerFirstUserOperation({\n collection,\n data: {\n ...data,\n ...authData,\n },\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\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":["status","httpStatus","getRequestCollection","headersWithCors","generatePayloadCookie","registerFirstUserOperation","registerFirstUserHandler","req","collection","data","t","authData","config","auth","loginWithUsername","email","password","username","result","cookie","collectionAuthConfig","cookiePrefix","payload","token","Response","json","exp","message","user","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,SAASC,0BAA0B,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.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/resetPassword.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,oBAAoB,EAAE,cAqClC,CAAA"}
1
+ {"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/resetPassword.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,oBAAoB,EAAE,cAwClC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { status as httpStatus } from 'http-status';
2
2
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
3
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
3
4
  import { generatePayloadCookie } from '../cookies.js';
4
5
  import { resetPasswordOperation } from '../operations/resetPassword.js';
5
6
  export const resetPasswordHandler = async (req)=>{
@@ -27,8 +28,11 @@ export const resetPasswordHandler = async (req)=>{
27
28
  message: t('authentication:passwordResetSuccessfully'),
28
29
  ...result
29
30
  }, {
30
- headers: new Headers({
31
- 'Set-Cookie': cookie
31
+ headers: headersWithCors({
32
+ headers: new Headers({
33
+ 'Set-Cookie': cookie
34
+ }),
35
+ req
32
36
  }),
33
37
  status: httpStatus.OK
34
38
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/resetPassword.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { generatePayloadCookie } from '../cookies.js'\nimport { resetPasswordOperation } from '../operations/resetPassword.js'\n\nexport const resetPasswordHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(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 collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\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: new Headers({\n 'Set-Cookie': cookie,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollection","generatePayloadCookie","resetPasswordOperation","resetPasswordHandler","req","collection","searchParams","t","depth","get","result","data","password","token","Number","undefined","cookie","collectionAuthConfig","config","auth","cookiePrefix","payload","removeTokenFromResponses","Response","json","message","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,SAASC,sBAAsB,QAAQ,iCAAgC;AAEvE,OAAO,MAAMC,uBAAuC,OAAOC;IACzD,MAAMC,aAAaL,qBAAqBI;IACxC,MAAM,EAAEE,YAAY,EAAEC,CAAC,EAAE,GAAGH;IAC5B,MAAMI,QAAQF,aAAaG,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMR,uBAAuB;QAC1CG;QACAM,MAAM;YACJC,UAAU,OAAOR,IAAIO,IAAI,EAAEC,aAAa,WAAWR,IAAIO,IAAI,CAACC,QAAQ,GAAG;YACvEC,OAAO,OAAOT,IAAIO,IAAI,EAAEE,UAAU,WAAWT,IAAIO,IAAI,CAACE,KAAK,GAAG;QAChE;QACAL,OAAOA,QAAQM,OAAON,SAASO;QAC/BX;IACF;IAEA,MAAMY,SAASf,sBAAsB;QACnCgB,sBAAsBZ,WAAWa,MAAM,CAACC,IAAI;QAC5CC,cAAchB,IAAIiB,OAAO,CAACH,MAAM,CAACE,YAAY;QAC7CP,OAAOH,OAAOG,KAAK;IACrB;IAEA,IAAIR,WAAWa,MAAM,CAACC,IAAI,CAACG,wBAAwB,EAAE;QACnD,OAAOZ,OAAOG,KAAK;IACrB;IAEA,OAAOU,SAASC,IAAI,CAClB;QACEC,SAASlB,EAAE;QACX,GAAGG,MAAM;IACX,GACA;QACEgB,SAAS,IAAIC,QAAQ;YACnB,cAAcX;QAChB;QACAlB,QAAQC,WAAW6B,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/resetPassword.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { generatePayloadCookie } from '../cookies.js'\nimport { resetPasswordOperation } from '../operations/resetPassword.js'\n\nexport const resetPasswordHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(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 collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\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":["status","httpStatus","getRequestCollection","headersWithCors","generatePayloadCookie","resetPasswordOperation","resetPasswordHandler","req","collection","searchParams","t","depth","get","result","data","password","token","Number","undefined","cookie","collectionAuthConfig","config","auth","cookiePrefix","payload","removeTokenFromResponses","Response","json","message","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UA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AM,aAAa,EAAE,cA4B3B,CAAA"}
1
+ {"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/unlock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,aAAa,EAAE,cAgC3B,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { status as httpStatus } from 'http-status';
2
2
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
3
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
3
4
  import { unlockOperation } from '../operations/unlock.js';
4
5
  export const unlockHandler = async (req)=>{
5
6
  const collection = getRequestCollection(req);
@@ -18,6 +19,10 @@ export const unlockHandler = async (req)=>{
18
19
  return Response.json({
19
20
  message: t('general:success')
20
21
  }, {
22
+ headers: headersWithCors({
23
+ headers: new Headers(),
24
+ req
25
+ }),
21
26
  status: httpStatus.OK
22
27
  });
23
28
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/unlock.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { unlockOperation } from '../operations/unlock.js'\n\nexport const unlockHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { t } = req\n\n const authData =\n collection.config.auth?.loginWithUsername !== false\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n }\n\n await unlockOperation({\n collection,\n data: authData,\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollection","unlockOperation","unlockHandler","req","collection","t","authData","config","auth","loginWithUsername","email","data","username","Response","json","message","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,aAAaJ,qBAAqBG;IACxC,MAAM,EAAEE,CAAC,EAAE,GAAGF;IAEd,MAAMG,WACJF,WAAWG,MAAM,CAACC,IAAI,EAAEC,sBAAsB,QAC1C;QACEC,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOT,IAAIQ,IAAI,EAAEC,aAAa,WAAWT,IAAIQ,IAAI,CAACC,QAAQ,GAAG;IACzE,IACA;QACEF,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;IAChE;IAEN,MAAMT,gBAAgB;QACpBG;QACAO,MAAML;QACNH;IACF;IAEA,OAAOU,SAASC,IAAI,CAClB;QACEC,SAASV,EAAE;IACb,GACA;QACEP,QAAQC,WAAWiB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/unlock.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { unlockOperation } from '../operations/unlock.js'\n\nexport const unlockHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { t } = req\n\n const authData =\n collection.config.auth?.loginWithUsername !== false\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n }\n\n await unlockOperation({\n collection,\n data: authData,\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":["status","httpStatus","getRequestCollection","headersWithCors","unlockOperation","unlockHandler","req","collection","t","authData","config","auth","loginWithUsername","email","data","username","Response","json","message","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,aAAaL,qBAAqBI;IACxC,MAAM,EAAEE,CAAC,EAAE,GAAGF;IAEd,MAAMG,WACJF,WAAWG,MAAM,CAACC,IAAI,EAAEC,sBAAsB,QAC1C;QACEC,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOT,IAAIQ,IAAI,EAAEC,aAAa,WAAWT,IAAIQ,IAAI,CAACC,QAAQ,GAAG;IACzE,IACA;QACEF,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;IAChE;IAEN,MAAMT,gBAAgB;QACpBG;QACAO,MAAML;QACNH;IACF;IAEA,OAAOU,SAASC,IAAI,CAClB;QACEC,SAASV,EAAE;IACb,GACA;QACEW,SAAShB,gBAAgB;YACvBgB,SAAS,IAAIC;YACbd;QACF;QACAN,QAAQC,WAAWoB,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/verifyEmail.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAK3D,eAAO,MAAM,kBAAkB,EAAE,cAiBhC,CAAA"}
1
+ {"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/verifyEmail.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,kBAAkB,EAAE,cAqBhC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { status as httpStatus } from 'http-status';
2
2
  import { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js';
3
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
3
4
  import verifyEmailOperation from '../operations/verifyEmail.js';
4
5
  export const verifyEmailHandler = async (req)=>{
5
6
  const { id, collection } = getRequestCollectionWithID(req, {
@@ -14,6 +15,10 @@ export const verifyEmailHandler = async (req)=>{
14
15
  return Response.json({
15
16
  message: t('authentication:accountVerified')
16
17
  }, {
18
+ headers: headersWithCors({
19
+ headers: new Headers(),
20
+ req
21
+ }),
17
22
  status: httpStatus.OK
18
23
  });
19
24
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/verifyEmail.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport verifyEmailOperation from '../operations/verifyEmail.js'\n\nexport const verifyEmailHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req, { disableSanitize: true })\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:accountVerified'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollectionWithID","verifyEmailOperation","verifyEmailHandler","req","id","collection","disableSanitize","t","token","Response","json","message","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,OAAOC,0BAA0B,+BAA8B;AAE/D,OAAO,MAAMC,qBAAqC,OAAOC;IACvD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,GAAGL,2BAA2BG,KAAK;QAAEG,iBAAiB;IAAK;IACnF,MAAM,EAAEC,CAAC,EAAE,GAAGJ;IACd,MAAMF,qBAAqB;QACzBI;QACAF;QACAK,OAAOJ;IACT;IAEA,OAAOK,SAASC,IAAI,CAClB;QACEC,SAASJ,EAAE;IACb,GACA;QACET,QAAQC,WAAWa,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/verifyEmail.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport verifyEmailOperation from '../operations/verifyEmail.js'\n\nexport const verifyEmailHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req, { disableSanitize: true })\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:accountVerified'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollectionWithID","headersWithCors","verifyEmailOperation","verifyEmailHandler","req","id","collection","disableSanitize","t","token","Response","json","message","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,0BAA0B,+BAA8B;AAE/D,OAAO,MAAMC,qBAAqC,OAAOC;IACvD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,GAAGN,2BAA2BI,KAAK;QAAEG,iBAAiB;IAAK;IACnF,MAAM,EAAEC,CAAC,EAAE,GAAGJ;IACd,MAAMF,qBAAqB;QACzBI;QACAF;QACAK,OAAOJ;IACT;IAEA,OAAOK,SAASC,IAAI,CAClB;QACEC,SAASJ,EAAE;IACb,GACA;QACEK,SAASZ,gBAAgB;YACvBY,SAAS,IAAIC;YACbV;QACF;QACAN,QAAQC,WAAWgB,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAQ3D,eAAO,MAAM,aAAa,EAAE,cA6B3B,CAAA"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAS3D,eAAO,MAAM,aAAa,EAAE,cAiC3B,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { getTranslation } from '@payloadcms/translations';
2
2
  import { status as httpStatus } from 'http-status';
3
3
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
4
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
4
5
  import { isNumber } from '../../utilities/isNumber.js';
5
6
  import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
6
7
  import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js';
@@ -27,6 +28,10 @@ export const createHandler = async (req)=>{
27
28
  label: getTranslation(collection.config.labels.singular, req.i18n)
28
29
  })
29
30
  }, {
31
+ headers: headersWithCors({
32
+ headers: new Headers(),
33
+ req
34
+ }),
30
35
  status: httpStatus.CREATED
31
36
  });
32
37
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/endpoints/create.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { createOperation } from '../operations/create.js'\n\nexport const createHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { searchParams } = req\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n const depth = searchParams.get('depth')\n\n const doc = await createOperation({\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? depth : undefined,\n draft,\n populate: sanitizePopulateParam(req.query.populate),\n req,\n select: sanitizeSelectParam(req.query.select),\n })\n\n return Response.json(\n {\n doc,\n message: req.t('general:successfullyCreated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n }),\n },\n {\n status: httpStatus.CREATED,\n },\n )\n}\n"],"names":["getTranslation","status","httpStatus","getRequestCollection","isNumber","sanitizePopulateParam","sanitizeSelectParam","createOperation","createHandler","req","collection","searchParams","autosave","get","draft","depth","doc","data","undefined","populate","query","select","Response","json","message","t","label","config","labels","singular","i18n","CREATED"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,aAAaP,qBAAqBM;IACxC,MAAM,EAAEE,YAAY,EAAE,GAAGF;IACzB,MAAMG,WAAWD,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAC5C,MAAME,QAAQJ,aAAaE,GAAG,CAAC;IAE/B,MAAMG,MAAM,MAAMT,gBAAgB;QAChCK;QACAF;QACAO,MAAMR,IAAIQ,IAAI;QACdF,OAAOX,SAASW,SAASA,QAAQG;QACjCJ;QACAK,UAAUd,sBAAsBI,IAAIW,KAAK,CAACD,QAAQ;QAClDV;QACAY,QAAQf,oBAAoBG,IAAIW,KAAK,CAACC,MAAM;IAC9C;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEP;QACAQ,SAASf,IAAIgB,CAAC,CAAC,+BAA+B;YAC5CC,OAAO1B,eAAeU,WAAWiB,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEpB,IAAIqB,IAAI;QACnE;IACF,GACA;QACE7B,QAAQC,WAAW6B,OAAO;IAC5B;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/endpoints/create.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { createOperation } from '../operations/create.js'\n\nexport const createHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { searchParams } = req\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n const depth = searchParams.get('depth')\n\n const doc = await createOperation({\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? depth : undefined,\n draft,\n populate: sanitizePopulateParam(req.query.populate),\n req,\n select: sanitizeSelectParam(req.query.select),\n })\n\n return Response.json(\n {\n doc,\n message: req.t('general:successfullyCreated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n }),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.CREATED,\n },\n )\n}\n"],"names":["getTranslation","status","httpStatus","getRequestCollection","headersWithCors","isNumber","sanitizePopulateParam","sanitizeSelectParam","createOperation","createHandler","req","collection","searchParams","autosave","get","draft","depth","doc","data","undefined","populate","query","select","Response","json","message","t","label","config","labels","singular","i18n","headers","Headers","CREATED"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,aAAaR,qBAAqBO;IACxC,MAAM,EAAEE,YAAY,EAAE,GAAGF;IACzB,MAAMG,WAAWD,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAC5C,MAAME,QAAQJ,aAAaE,GAAG,CAAC;IAE/B,MAAMG,MAAM,MAAMT,gBAAgB;QAChCK;QACAF;QACAO,MAAMR,IAAIQ,IAAI;QACdF,OAAOX,SAASW,SAASA,QAAQG;QACjCJ;QACAK,UAAUd,sBAAsBI,IAAIW,KAAK,CAACD,QAAQ;QAClDV;QACAY,QAAQf,oBAAoBG,IAAIW,KAAK,CAACC,MAAM;IAC9C;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEP;QACAQ,SAASf,IAAIgB,CAAC,CAAC,+BAA+B;YAC5CC,OAAO3B,eAAeW,WAAWiB,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEpB,IAAIqB,IAAI;QACnE;IACF,GACA;QACEC,SAAS5B,gBAAgB;YACvB4B,SAAS,IAAIC;YACbvB;QACF;QACAT,QAAQC,WAAWgC,OAAO;IAC5B;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/delete.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAS3D,eAAO,MAAM,aAAa,EAAE,cAyD3B,CAAA"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/delete.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAU3D,eAAO,MAAM,aAAa,EAAE,cAgE3B,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { getTranslation } from '@payloadcms/translations';
2
2
  import { status as httpStatus } from 'http-status';
3
3
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
4
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
4
5
  import { isNumber } from '../../utilities/isNumber.js';
5
6
  import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
6
7
  import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js';
@@ -17,6 +18,10 @@ export const deleteHandler = async (req)=>{
17
18
  select: sanitizeSelectParam(select),
18
19
  where
19
20
  });
21
+ const headers = headersWithCors({
22
+ headers: new Headers(),
23
+ req
24
+ });
20
25
  if (result.errors.length === 0) {
21
26
  const message = req.t('general:deletedCountSuccessfully', {
22
27
  count: result.docs.length,
@@ -26,6 +31,7 @@ export const deleteHandler = async (req)=>{
26
31
  ...result,
27
32
  message
28
33
  }, {
34
+ headers,
29
35
  status: httpStatus.OK
30
36
  });
31
37
  }
@@ -39,6 +45,7 @@ export const deleteHandler = async (req)=>{
39
45
  ...result,
40
46
  message
41
47
  }, {
48
+ headers,
42
49
  status: httpStatus.BAD_REQUEST
43
50
  });
44
51
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/endpoints/delete.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { Where } from '../../types/index.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { deleteOperation } from '../operations/delete.js'\n\nexport const deleteHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { depth, overrideLock, populate, select, where } = req.query as {\n depth?: string\n overrideLock?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n where,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:deletedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length === 1 ? 'singular' : 'plural'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n\n const message = req.t('error:unableToDeleteCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total === 1 ? 'singular' : 'plural'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"names":["getTranslation","status","httpStatus","getRequestCollection","isNumber","sanitizePopulateParam","sanitizeSelectParam","deleteOperation","deleteHandler","req","collection","depth","overrideLock","populate","select","where","query","result","Number","undefined","Boolean","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","OK","total","BAD_REQUEST"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,aAAaP,qBAAqBM;IACxC,MAAM,EAAEE,KAAK,EAAEC,YAAY,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGN,IAAIO,KAAK;IAQlE,MAAMC,SAAS,MAAMV,gBAAgB;QACnCG;QACAC,OAAOP,SAASO,SAASO,OAAOP,SAASQ;QACzCP,cAAcQ,QAAQR,iBAAiB;QACvCC,UAAUR,sBAAsBQ;QAChCJ;QACAK,QAAQR,oBAAoBQ;QAC5BC;IACF;IAEA,IAAIE,OAAOI,MAAM,CAACC,MAAM,KAAK,GAAG;QAC9B,MAAMC,UAAUd,IAAIe,CAAC,CAAC,oCAAoC;YACxDC,OAAOR,OAAOS,IAAI,CAACJ,MAAM;YACzBK,OAAO3B,eACLU,WAAWkB,MAAM,CAACC,MAAM,CAACZ,OAAOS,IAAI,CAACJ,MAAM,KAAK,IAAI,aAAa,SAAS,EAC1Eb,IAAIqB,IAAI;QAEZ;QAEA,OAAOC,SAASC,IAAI,CAClB;YACE,GAAGf,MAAM;YACTM;QACF,GACA;YACEtB,QAAQC,WAAW+B,EAAE;QACvB;IAEJ;IAEA,MAAMC,QAAQjB,OAAOS,IAAI,CAACJ,MAAM,GAAGL,OAAOI,MAAM,CAACC,MAAM;IAEvD,MAAMC,UAAUd,IAAIe,CAAC,CAAC,6BAA6B;QACjDC,OAAOR,OAAOI,MAAM,CAACC,MAAM;QAC3BK,OAAO3B,eAAeU,WAAWkB,MAAM,CAACC,MAAM,CAACK,UAAU,IAAI,aAAa,SAAS,EAAEzB,IAAIqB,IAAI;QAC7FI;IACF;IAEA,OAAOH,SAASC,IAAI,CAClB;QACE,GAAGf,MAAM;QACTM;IACF,GACA;QACEtB,QAAQC,WAAWiC,WAAW;IAChC;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/endpoints/delete.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { Where } from '../../types/index.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { deleteOperation } from '../operations/delete.js'\n\nexport const deleteHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { depth, overrideLock, populate, select, where } = req.query as {\n depth?: string\n overrideLock?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:deletedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length === 1 ? 'singular' : 'plural'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n\n const message = req.t('error:unableToDeleteCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total === 1 ? 'singular' : 'plural'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"names":["getTranslation","status","httpStatus","getRequestCollection","headersWithCors","isNumber","sanitizePopulateParam","sanitizeSelectParam","deleteOperation","deleteHandler","req","collection","depth","overrideLock","populate","select","where","query","result","Number","undefined","Boolean","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","OK","total","BAD_REQUEST"],"mappings":"AAAA,SAASA,cAA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V,OAAOM,MAAM,CAACC,MAAM;QAC3BK,OAAO9B,eAAeW,WAAWoB,MAAM,CAACC,MAAM,CAACK,UAAU,IAAI,aAAa,SAAS,EAAE3B,IAAIuB,IAAI;QAC7FI;IACF;IAEA,OAAOH,SAASC,IAAI,CAClB;QACE,GAAGjB,MAAM;QACTQ;IACF,GACA;QACEJ;QACArB,QAAQC,WAAWoC,WAAW;IAChC;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deleteByID.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/deleteByID.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAQ3D,eAAO,MAAM,iBAAiB,EAAE,cAoC/B,CAAA"}
1
+ {"version":3,"file":"deleteByID.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/deleteByID.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAS3D,eAAO,MAAM,iBAAiB,EAAE,cA2C/B,CAAA"}