@payloadcms/next 3.0.0-beta.4 → 3.0.0-beta.41

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 (586) hide show
  1. package/dist/cjs/withPayload.cjs +46 -10
  2. package/dist/cjs/withPayload.cjs.map +1 -1
  3. package/dist/elements/LeaveWithoutSaving/index.js +35 -15
  4. package/dist/elements/LeaveWithoutSaving/index.js.map +1 -1
  5. package/dist/exports/routes.d.ts +1 -1
  6. package/dist/exports/routes.d.ts.map +1 -1
  7. package/dist/exports/routes.js +1 -1
  8. package/dist/exports/routes.js.map +1 -1
  9. package/dist/exports/utilities.d.ts +5 -1
  10. package/dist/exports/utilities.d.ts.map +1 -1
  11. package/dist/exports/utilities.js +5 -1
  12. package/dist/exports/utilities.js.map +1 -1
  13. package/dist/exports/views.d.ts +2 -1
  14. package/dist/exports/views.d.ts.map +1 -1
  15. package/dist/exports/views.js +2 -1
  16. package/dist/exports/views.js.map +1 -1
  17. package/dist/{next-fileupload → fetchAPI-multipart}/fileFactory.d.ts +2 -2
  18. package/dist/fetchAPI-multipart/fileFactory.d.ts.map +1 -0
  19. package/dist/fetchAPI-multipart/fileFactory.js.map +1 -0
  20. package/dist/{next-fileupload → fetchAPI-multipart}/handlers.d.ts +2 -2
  21. package/dist/fetchAPI-multipart/handlers.d.ts.map +1 -0
  22. package/dist/fetchAPI-multipart/handlers.js.map +1 -0
  23. package/dist/{next-fileupload → fetchAPI-multipart}/index.d.ts +10 -12
  24. package/dist/fetchAPI-multipart/index.d.ts.map +1 -0
  25. package/dist/{next-fileupload → fetchAPI-multipart}/index.js +3 -5
  26. package/dist/fetchAPI-multipart/index.js.map +1 -0
  27. package/dist/fetchAPI-multipart/isEligibleRequest.d.ts.map +1 -0
  28. package/dist/{next-fileupload → fetchAPI-multipart}/isEligibleRequest.js +1 -1
  29. package/dist/fetchAPI-multipart/isEligibleRequest.js.map +1 -0
  30. package/dist/fetchAPI-multipart/processMultipart.d.ts +8 -0
  31. package/dist/fetchAPI-multipart/processMultipart.d.ts.map +1 -0
  32. package/dist/{next-fileupload → fetchAPI-multipart}/processMultipart.js +43 -14
  33. package/dist/fetchAPI-multipart/processMultipart.js.map +1 -0
  34. package/dist/fetchAPI-multipart/processNested.d.ts.map +1 -0
  35. package/dist/{next-fileupload → fetchAPI-multipart}/processNested.js +2 -1
  36. package/dist/fetchAPI-multipart/processNested.js.map +1 -0
  37. package/dist/fetchAPI-multipart/uploadTimer.d.ts.map +1 -0
  38. package/dist/fetchAPI-multipart/uploadTimer.js.map +1 -0
  39. package/dist/{next-fileupload → fetchAPI-multipart}/utilities.d.ts +4 -4
  40. package/dist/fetchAPI-multipart/utilities.d.ts.map +1 -0
  41. package/dist/{next-fileupload → fetchAPI-multipart}/utilities.js +4 -4
  42. package/dist/fetchAPI-multipart/utilities.js.map +1 -0
  43. package/dist/fetchAPI-stream-file/index.d.ts.map +1 -0
  44. package/dist/fetchAPI-stream-file/index.js.map +1 -0
  45. package/dist/layouts/Root/index.d.ts.map +1 -1
  46. package/dist/layouts/Root/index.js +48 -16
  47. package/dist/layouts/Root/index.js.map +1 -1
  48. package/dist/prod/payload/payload-favicon-dark.png +0 -0
  49. package/dist/prod/payload/payload-favicon-light.png +0 -0
  50. package/dist/prod/styles.css +1 -1
  51. package/dist/routes/graphql/handler.d.ts.map +1 -1
  52. package/dist/routes/graphql/handler.js +22 -10
  53. package/dist/routes/graphql/handler.js.map +1 -1
  54. package/dist/routes/index.d.ts +1 -1
  55. package/dist/routes/index.d.ts.map +1 -1
  56. package/dist/routes/index.js +1 -1
  57. package/dist/routes/index.js.map +1 -1
  58. package/dist/routes/rest/auth/access.d.ts.map +1 -1
  59. package/dist/routes/rest/auth/access.js +19 -4
  60. package/dist/routes/rest/auth/access.js.map +1 -1
  61. package/dist/routes/rest/auth/forgotPassword.d.ts.map +1 -1
  62. package/dist/routes/rest/auth/forgotPassword.js +7 -2
  63. package/dist/routes/rest/auth/forgotPassword.js.map +1 -1
  64. package/dist/routes/rest/auth/init.d.ts.map +1 -1
  65. package/dist/routes/rest/auth/init.js +6 -0
  66. package/dist/routes/rest/auth/init.js.map +1 -1
  67. package/dist/routes/rest/auth/login.d.ts.map +1 -1
  68. package/dist/routes/rest/auth/login.js +8 -5
  69. package/dist/routes/rest/auth/login.js.map +1 -1
  70. package/dist/routes/rest/auth/logout.d.ts.map +1 -1
  71. package/dist/routes/rest/auth/logout.js +12 -7
  72. package/dist/routes/rest/auth/logout.js.map +1 -1
  73. package/dist/routes/rest/auth/me.d.ts.map +1 -1
  74. package/dist/routes/rest/auth/me.js +5 -0
  75. package/dist/routes/rest/auth/me.js.map +1 -1
  76. package/dist/routes/rest/auth/refresh.d.ts.map +1 -1
  77. package/dist/routes/rest/auth/refresh.js +11 -7
  78. package/dist/routes/rest/auth/refresh.js.map +1 -1
  79. package/dist/routes/rest/auth/registerFirstUser.d.ts.map +1 -1
  80. package/dist/routes/rest/auth/registerFirstUser.js +8 -5
  81. package/dist/routes/rest/auth/registerFirstUser.js.map +1 -1
  82. package/dist/routes/rest/auth/resetPassword.d.ts.map +1 -1
  83. package/dist/routes/rest/auth/resetPassword.js +8 -5
  84. package/dist/routes/rest/auth/resetPassword.js.map +1 -1
  85. package/dist/routes/rest/auth/unlock.d.ts.map +1 -1
  86. package/dist/routes/rest/auth/unlock.js +7 -2
  87. package/dist/routes/rest/auth/unlock.js.map +1 -1
  88. package/dist/routes/rest/auth/verifyEmail.d.ts.map +1 -1
  89. package/dist/routes/rest/auth/verifyEmail.js +7 -2
  90. package/dist/routes/rest/auth/verifyEmail.js.map +1 -1
  91. package/dist/routes/rest/buildFormState.d.ts +2 -4
  92. package/dist/routes/rest/buildFormState.d.ts.map +1 -1
  93. package/dist/routes/rest/buildFormState.js +30 -145
  94. package/dist/routes/rest/buildFormState.js.map +1 -1
  95. package/dist/routes/rest/collections/count.d.ts +3 -0
  96. package/dist/routes/rest/collections/count.d.ts.map +1 -0
  97. package/dist/routes/rest/collections/count.js +15 -0
  98. package/dist/routes/rest/collections/count.js.map +1 -0
  99. package/dist/routes/rest/collections/create.d.ts.map +1 -1
  100. package/dist/routes/rest/collections/create.js +5 -0
  101. package/dist/routes/rest/collections/create.js.map +1 -1
  102. package/dist/routes/rest/collections/delete.d.ts.map +1 -1
  103. package/dist/routes/rest/collections/delete.js +7 -0
  104. package/dist/routes/rest/collections/delete.js.map +1 -1
  105. package/dist/routes/rest/collections/deleteByID.d.ts.map +1 -1
  106. package/dist/routes/rest/collections/deleteByID.js +7 -0
  107. package/dist/routes/rest/collections/deleteByID.js.map +1 -1
  108. package/dist/routes/rest/collections/docAccess.d.ts.map +1 -1
  109. package/dist/routes/rest/collections/docAccess.js +5 -0
  110. package/dist/routes/rest/collections/docAccess.js.map +1 -1
  111. package/dist/routes/rest/collections/duplicate.d.ts.map +1 -1
  112. package/dist/routes/rest/collections/duplicate.js +5 -0
  113. package/dist/routes/rest/collections/duplicate.js.map +1 -1
  114. package/dist/routes/rest/collections/find.d.ts.map +1 -1
  115. package/dist/routes/rest/collections/find.js +5 -0
  116. package/dist/routes/rest/collections/find.js.map +1 -1
  117. package/dist/routes/rest/collections/findByID.d.ts.map +1 -1
  118. package/dist/routes/rest/collections/findByID.js +5 -0
  119. package/dist/routes/rest/collections/findByID.js.map +1 -1
  120. package/dist/routes/rest/collections/findVersionByID.d.ts.map +1 -1
  121. package/dist/routes/rest/collections/findVersionByID.js +5 -0
  122. package/dist/routes/rest/collections/findVersionByID.js.map +1 -1
  123. package/dist/routes/rest/collections/findVersions.d.ts.map +1 -1
  124. package/dist/routes/rest/collections/findVersions.js +5 -0
  125. package/dist/routes/rest/collections/findVersions.js.map +1 -1
  126. package/dist/routes/rest/collections/preview.d.ts.map +1 -1
  127. package/dist/routes/rest/collections/preview.js +7 -1
  128. package/dist/routes/rest/collections/preview.js.map +1 -1
  129. package/dist/routes/rest/collections/restoreVersion.d.ts.map +1 -1
  130. package/dist/routes/rest/collections/restoreVersion.js +5 -0
  131. package/dist/routes/rest/collections/restoreVersion.js.map +1 -1
  132. package/dist/routes/rest/collections/update.d.ts.map +1 -1
  133. package/dist/routes/rest/collections/update.js +7 -0
  134. package/dist/routes/rest/collections/update.js.map +1 -1
  135. package/dist/routes/rest/collections/updateByID.d.ts.map +1 -1
  136. package/dist/routes/rest/collections/updateByID.js +5 -0
  137. package/dist/routes/rest/collections/updateByID.js.map +1 -1
  138. package/dist/routes/rest/files/checkFileAccess.d.ts +3 -3
  139. package/dist/routes/rest/files/checkFileAccess.d.ts.map +1 -1
  140. package/dist/routes/rest/files/checkFileAccess.js +1 -0
  141. package/dist/routes/rest/files/checkFileAccess.js.map +1 -1
  142. package/dist/routes/rest/files/getFile.d.ts +2 -2
  143. package/dist/routes/rest/files/getFile.d.ts.map +1 -1
  144. package/dist/routes/rest/files/getFile.js +19 -10
  145. package/dist/routes/rest/files/getFile.js.map +1 -1
  146. package/dist/routes/rest/files/getFileTypeFallback.d.ts +7 -0
  147. package/dist/routes/rest/files/getFileTypeFallback.d.ts.map +1 -0
  148. package/dist/routes/rest/files/getFileTypeFallback.js +21 -0
  149. package/dist/routes/rest/files/getFileTypeFallback.js.map +1 -0
  150. package/dist/routes/rest/globals/docAccess.d.ts.map +1 -1
  151. package/dist/routes/rest/globals/docAccess.js +5 -0
  152. package/dist/routes/rest/globals/docAccess.js.map +1 -1
  153. package/dist/routes/rest/globals/findOne.d.ts.map +1 -1
  154. package/dist/routes/rest/globals/findOne.js +5 -0
  155. package/dist/routes/rest/globals/findOne.js.map +1 -1
  156. package/dist/routes/rest/globals/findVersionByID.d.ts.map +1 -1
  157. package/dist/routes/rest/globals/findVersionByID.js +5 -0
  158. package/dist/routes/rest/globals/findVersionByID.js.map +1 -1
  159. package/dist/routes/rest/globals/findVersions.d.ts.map +1 -1
  160. package/dist/routes/rest/globals/findVersions.js +5 -0
  161. package/dist/routes/rest/globals/findVersions.js.map +1 -1
  162. package/dist/routes/rest/globals/preview.d.ts.map +1 -1
  163. package/dist/routes/rest/globals/preview.js +7 -1
  164. package/dist/routes/rest/globals/preview.js.map +1 -1
  165. package/dist/routes/rest/globals/restoreVersion.d.ts.map +1 -1
  166. package/dist/routes/rest/globals/restoreVersion.js +5 -0
  167. package/dist/routes/rest/globals/restoreVersion.js.map +1 -1
  168. package/dist/routes/rest/globals/update.d.ts.map +1 -1
  169. package/dist/routes/rest/globals/update.js +5 -0
  170. package/dist/routes/rest/globals/update.js.map +1 -1
  171. package/dist/routes/rest/index.d.ts +1 -0
  172. package/dist/routes/rest/index.d.ts.map +1 -1
  173. package/dist/routes/rest/index.js +338 -215
  174. package/dist/routes/rest/index.js.map +1 -1
  175. package/dist/routes/rest/og/image.d.ts +9 -0
  176. package/dist/routes/rest/og/image.d.ts.map +1 -0
  177. package/dist/routes/rest/og/image.js +79 -0
  178. package/dist/routes/rest/og/image.js.map +1 -0
  179. package/dist/routes/rest/og/index.d.ts +11 -0
  180. package/dist/routes/rest/og/index.d.ts.map +1 -0
  181. package/dist/routes/rest/og/index.js +73 -0
  182. package/dist/routes/rest/og/index.js.map +1 -0
  183. package/dist/routes/rest/og/roboto-regular.woff +0 -0
  184. package/dist/routes/rest/routeError.d.ts +5 -4
  185. package/dist/routes/rest/routeError.d.ts.map +1 -1
  186. package/dist/routes/rest/routeError.js +25 -11
  187. package/dist/routes/rest/routeError.js.map +1 -1
  188. package/dist/routes/rest/types.d.ts +7 -7
  189. package/dist/routes/rest/types.d.ts.map +1 -1
  190. package/dist/routes/rest/types.js.map +1 -1
  191. package/dist/scss/app.scss +2 -3
  192. package/dist/scss/vars.scss +0 -7
  193. package/dist/utilities/addDataAndFileToRequest.d.ts +11 -0
  194. package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -0
  195. package/dist/utilities/addDataAndFileToRequest.js +45 -0
  196. package/dist/utilities/addDataAndFileToRequest.js.map +1 -0
  197. package/dist/utilities/addLocalesToRequest.d.ts +20 -0
  198. package/dist/utilities/addLocalesToRequest.d.ts.map +1 -0
  199. package/dist/utilities/addLocalesToRequest.js +44 -0
  200. package/dist/utilities/addLocalesToRequest.js.map +1 -0
  201. package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
  202. package/dist/utilities/createPayloadRequest.js +15 -28
  203. package/dist/utilities/createPayloadRequest.js.map +1 -1
  204. package/dist/utilities/getNextRequestI18n.d.ts +1 -1
  205. package/dist/utilities/getNextRequestI18n.js +1 -1
  206. package/dist/utilities/getNextRequestI18n.js.map +1 -1
  207. package/dist/utilities/getPayloadHMR.d.ts +2 -1
  208. package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
  209. package/dist/utilities/getPayloadHMR.js +25 -20
  210. package/dist/utilities/getPayloadHMR.js.map +1 -1
  211. package/dist/utilities/getRequestLanguage.d.ts +1 -1
  212. package/dist/utilities/getRequestLanguage.d.ts.map +1 -1
  213. package/dist/utilities/getRequestLanguage.js +4 -5
  214. package/dist/utilities/getRequestLanguage.js.map +1 -1
  215. package/dist/utilities/getRequestTheme.d.ts +11 -0
  216. package/dist/utilities/getRequestTheme.d.ts.map +1 -0
  217. package/dist/utilities/getRequestTheme.js +19 -0
  218. package/dist/utilities/getRequestTheme.js.map +1 -0
  219. package/dist/utilities/headersWithCors.d.ts +8 -0
  220. package/dist/utilities/headersWithCors.d.ts.map +1 -0
  221. package/dist/utilities/headersWithCors.js +17 -0
  222. package/dist/utilities/headersWithCors.js.map +1 -0
  223. package/dist/utilities/initPage/handleAdminPage.d.ts +13 -0
  224. package/dist/utilities/initPage/handleAdminPage.d.ts.map +1 -0
  225. package/dist/utilities/initPage/handleAdminPage.js +35 -0
  226. package/dist/utilities/initPage/handleAdminPage.js.map +1 -0
  227. package/dist/utilities/initPage/handleAuthRedirect.d.ts +9 -0
  228. package/dist/utilities/initPage/handleAuthRedirect.d.ts.map +1 -0
  229. package/dist/utilities/initPage/handleAuthRedirect.js +27 -0
  230. package/dist/utilities/initPage/handleAuthRedirect.js.map +1 -0
  231. package/dist/utilities/initPage/index.d.ts +4 -0
  232. package/dist/utilities/initPage/index.d.ts.map +1 -0
  233. package/dist/utilities/{initPage.js → initPage/index.js} +33 -31
  234. package/dist/utilities/initPage/index.js.map +1 -0
  235. package/dist/utilities/initPage/shared.d.ts +4 -0
  236. package/dist/utilities/initPage/shared.d.ts.map +1 -0
  237. package/dist/utilities/initPage/shared.js +18 -0
  238. package/dist/utilities/initPage/shared.js.map +1 -0
  239. package/dist/utilities/initPage/types.d.ts +24 -0
  240. package/dist/utilities/initPage/types.d.ts.map +1 -0
  241. package/dist/utilities/initPage/types.js.map +1 -0
  242. package/dist/utilities/meta.d.ts +4 -8
  243. package/dist/utilities/meta.d.ts.map +1 -1
  244. package/dist/utilities/meta.js +64 -25
  245. package/dist/utilities/meta.js.map +1 -1
  246. package/dist/views/API/LocaleSelector/index.d.ts +9 -0
  247. package/dist/views/API/LocaleSelector/index.d.ts.map +1 -0
  248. package/dist/views/API/LocaleSelector/index.js +16 -0
  249. package/dist/views/API/LocaleSelector/index.js.map +1 -0
  250. package/dist/views/API/RenderJSON/index.js +100 -68
  251. package/dist/views/API/RenderJSON/index.js.map +1 -1
  252. package/dist/views/API/index.client.d.ts.map +1 -1
  253. package/dist/views/API/index.client.js +128 -94
  254. package/dist/views/API/index.client.js.map +1 -1
  255. package/dist/views/API/index.js +2 -1
  256. package/dist/views/API/index.js.map +1 -1
  257. package/dist/views/API/meta.d.ts.map +1 -1
  258. package/dist/views/API/meta.js +13 -6
  259. package/dist/views/API/meta.js.map +1 -1
  260. package/dist/views/Account/Settings/LanguageSelector.d.ts +6 -0
  261. package/dist/views/Account/Settings/LanguageSelector.d.ts.map +1 -0
  262. package/dist/views/Account/Settings/LanguageSelector.js +19 -0
  263. package/dist/views/Account/Settings/LanguageSelector.js.map +1 -0
  264. package/dist/views/Account/Settings/index.d.ts +4 -0
  265. package/dist/views/Account/Settings/index.d.ts.map +1 -1
  266. package/dist/views/Account/Settings/index.js +24 -20
  267. package/dist/views/Account/Settings/index.js.map +1 -1
  268. package/dist/views/Account/ToggleTheme/index.js +2 -1
  269. package/dist/views/Account/ToggleTheme/index.js.map +1 -1
  270. package/dist/views/Account/index.d.ts.map +1 -1
  271. package/dist/views/Account/index.js +66 -30
  272. package/dist/views/Account/index.js.map +1 -1
  273. package/dist/views/Account/meta.d.ts.map +1 -1
  274. package/dist/views/Account/meta.js +4 -5
  275. package/dist/views/Account/meta.js.map +1 -1
  276. package/dist/views/CreateFirstUser/index.client.d.ts +3 -3
  277. package/dist/views/CreateFirstUser/index.client.d.ts.map +1 -1
  278. package/dist/views/CreateFirstUser/index.client.js +61 -9
  279. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  280. package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
  281. package/dist/views/CreateFirstUser/index.js +21 -31
  282. package/dist/views/CreateFirstUser/index.js.map +1 -1
  283. package/dist/views/CreateFirstUser/index.scss +2 -12
  284. package/dist/views/CreateFirstUser/meta.d.ts.map +1 -1
  285. package/dist/views/CreateFirstUser/meta.js +4 -5
  286. package/dist/views/CreateFirstUser/meta.js.map +1 -1
  287. package/dist/views/Dashboard/Default/index.d.ts +5 -3
  288. package/dist/views/Dashboard/Default/index.d.ts.map +1 -1
  289. package/dist/views/Dashboard/Default/index.js +118 -20
  290. package/dist/views/Dashboard/Default/index.js.map +1 -1
  291. package/dist/views/Dashboard/index.d.ts.map +1 -1
  292. package/dist/views/Dashboard/index.js +51 -11
  293. package/dist/views/Dashboard/index.js.map +1 -1
  294. package/dist/views/Dashboard/meta.d.ts.map +1 -1
  295. package/dist/views/Dashboard/meta.js +8 -5
  296. package/dist/views/Dashboard/meta.js.map +1 -1
  297. package/dist/views/Document/getCustomViewByKey.d.ts.map +1 -1
  298. package/dist/views/Document/getCustomViewByKey.js +2 -1
  299. package/dist/views/Document/getCustomViewByKey.js.map +1 -1
  300. package/dist/views/Document/getDocumentData.d.ts +10 -0
  301. package/dist/views/Document/getDocumentData.d.ts.map +1 -0
  302. package/dist/views/Document/getDocumentData.js +31 -0
  303. package/dist/views/Document/getDocumentData.js.map +1 -0
  304. package/dist/views/Document/getDocumentPermissions.d.ts +14 -0
  305. package/dist/views/Document/getDocumentPermissions.d.ts.map +1 -0
  306. package/dist/views/Document/getDocumentPermissions.js +83 -0
  307. package/dist/views/Document/getDocumentPermissions.js.map +1 -0
  308. package/dist/views/Document/getMetaBySegment.d.ts +0 -1
  309. package/dist/views/Document/getMetaBySegment.d.ts.map +1 -1
  310. package/dist/views/Document/getMetaBySegment.js +1 -1
  311. package/dist/views/Document/getMetaBySegment.js.map +1 -1
  312. package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -1
  313. package/dist/views/Document/getViewsFromConfig.js +172 -171
  314. package/dist/views/Document/getViewsFromConfig.js.map +1 -1
  315. package/dist/views/Document/index.d.ts.map +1 -1
  316. package/dist/views/Document/index.js +70 -46
  317. package/dist/views/Document/index.js.map +1 -1
  318. package/dist/views/Edit/Default/Auth/APIKey.d.ts +1 -0
  319. package/dist/views/Edit/Default/Auth/APIKey.d.ts.map +1 -1
  320. package/dist/views/Edit/Default/Auth/APIKey.js +55 -32
  321. package/dist/views/Edit/Default/Auth/APIKey.js.map +1 -1
  322. package/dist/views/Edit/Default/Auth/index.d.ts.map +1 -1
  323. package/dist/views/Edit/Default/Auth/index.js +85 -50
  324. package/dist/views/Edit/Default/Auth/index.js.map +1 -1
  325. package/dist/views/Edit/Default/{SetStepNav → SetDocumentStepNav}/index.d.ts +1 -1
  326. package/dist/views/Edit/Default/SetDocumentStepNav/index.d.ts.map +1 -0
  327. package/dist/views/Edit/Default/SetDocumentStepNav/index.js +74 -0
  328. package/dist/views/Edit/Default/SetDocumentStepNav/index.js.map +1 -0
  329. package/dist/views/Edit/Default/index.d.ts.map +1 -1
  330. package/dist/views/Edit/Default/index.js +80 -69
  331. package/dist/views/Edit/Default/index.js.map +1 -1
  332. package/dist/views/Edit/index.client.d.ts.map +1 -1
  333. package/dist/views/Edit/index.client.js +11 -7
  334. package/dist/views/Edit/index.client.js.map +1 -1
  335. package/dist/views/Edit/index.js +2 -1
  336. package/dist/views/Edit/index.js.map +1 -1
  337. package/dist/views/Edit/meta.d.ts.map +1 -1
  338. package/dist/views/Edit/meta.js +17 -15
  339. package/dist/views/Edit/meta.js.map +1 -1
  340. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts +3 -0
  341. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -0
  342. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +80 -0
  343. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -0
  344. package/dist/views/ForgotPassword/index.d.ts.map +1 -1
  345. package/dist/views/ForgotPassword/index.js +39 -55
  346. package/dist/views/ForgotPassword/index.js.map +1 -1
  347. package/dist/views/ForgotPassword/meta.d.ts.map +1 -1
  348. package/dist/views/ForgotPassword/meta.js +4 -5
  349. package/dist/views/ForgotPassword/meta.js.map +1 -1
  350. package/dist/views/List/Default/index.d.ts.map +1 -1
  351. package/dist/views/List/Default/index.js +162 -87
  352. package/dist/views/List/Default/index.js.map +1 -1
  353. package/dist/views/List/index.d.ts.map +1 -1
  354. package/dist/views/List/index.js +58 -38
  355. package/dist/views/List/index.js.map +1 -1
  356. package/dist/views/List/meta.d.ts.map +1 -1
  357. package/dist/views/List/meta.js +4 -2
  358. package/dist/views/List/meta.js.map +1 -1
  359. package/dist/views/LivePreview/Context/context.d.ts +1 -1
  360. package/dist/views/LivePreview/Context/context.d.ts.map +1 -1
  361. package/dist/views/LivePreview/Context/context.js.map +1 -1
  362. package/dist/views/LivePreview/Context/index.js +9 -6
  363. package/dist/views/LivePreview/Context/index.js.map +1 -1
  364. package/dist/views/LivePreview/Device/index.js +5 -3
  365. package/dist/views/LivePreview/Device/index.js.map +1 -1
  366. package/dist/views/LivePreview/DeviceContainer/index.js +5 -3
  367. package/dist/views/LivePreview/DeviceContainer/index.js.map +1 -1
  368. package/dist/views/LivePreview/IFrame/index.js +2 -1
  369. package/dist/views/LivePreview/IFrame/index.js.map +1 -1
  370. package/dist/views/LivePreview/Preview/index.d.ts.map +1 -1
  371. package/dist/views/LivePreview/Preview/index.js +48 -14
  372. package/dist/views/LivePreview/Preview/index.js.map +1 -1
  373. package/dist/views/LivePreview/Toolbar/Controls/index.d.ts.map +1 -1
  374. package/dist/views/LivePreview/Toolbar/Controls/index.js +111 -61
  375. package/dist/views/LivePreview/Toolbar/Controls/index.js.map +1 -1
  376. package/dist/views/LivePreview/Toolbar/SizeInput/index.js +2 -1
  377. package/dist/views/LivePreview/Toolbar/SizeInput/index.js.map +1 -1
  378. package/dist/views/LivePreview/Toolbar/index.js +29 -14
  379. package/dist/views/LivePreview/Toolbar/index.js.map +1 -1
  380. package/dist/views/LivePreview/ToolbarArea/index.js +5 -3
  381. package/dist/views/LivePreview/ToolbarArea/index.js.map +1 -1
  382. package/dist/views/LivePreview/index.client.d.ts.map +1 -1
  383. package/dist/views/LivePreview/index.client.js +125 -90
  384. package/dist/views/LivePreview/index.client.js.map +1 -1
  385. package/dist/views/LivePreview/index.js +2 -1
  386. package/dist/views/LivePreview/index.js.map +1 -1
  387. package/dist/views/LivePreview/meta.d.ts.map +1 -1
  388. package/dist/views/LivePreview/meta.js +6 -22
  389. package/dist/views/LivePreview/meta.js.map +1 -1
  390. package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
  391. package/dist/views/Login/LoginForm/index.js +61 -22
  392. package/dist/views/Login/LoginForm/index.js.map +1 -1
  393. package/dist/views/Login/index.d.ts.map +1 -1
  394. package/dist/views/Login/index.js +50 -14
  395. package/dist/views/Login/index.js.map +1 -1
  396. package/dist/views/Login/meta.d.ts.map +1 -1
  397. package/dist/views/Login/meta.js +4 -5
  398. package/dist/views/Login/meta.js.map +1 -1
  399. package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
  400. package/dist/views/Logout/LogoutClient.js +21 -8
  401. package/dist/views/Logout/LogoutClient.js.map +1 -1
  402. package/dist/views/Logout/index.d.ts.map +1 -1
  403. package/dist/views/Logout/index.js +10 -11
  404. package/dist/views/Logout/index.js.map +1 -1
  405. package/dist/views/Logout/meta.d.ts.map +1 -1
  406. package/dist/views/Logout/meta.js +2 -4
  407. package/dist/views/Logout/meta.js.map +1 -1
  408. package/dist/views/NotFound/index.client.js +22 -10
  409. package/dist/views/NotFound/index.client.js.map +1 -1
  410. package/dist/views/NotFound/index.d.ts +1 -1
  411. package/dist/views/NotFound/index.d.ts.map +1 -1
  412. package/dist/views/NotFound/index.js +27 -12
  413. package/dist/views/NotFound/index.js.map +1 -1
  414. package/dist/views/NotFound/meta.d.ts.map +1 -1
  415. package/dist/views/NotFound/meta.js +2 -4
  416. package/dist/views/NotFound/meta.js.map +1 -1
  417. package/dist/views/ResetPassword/index.client.d.ts +7 -0
  418. package/dist/views/ResetPassword/index.client.d.ts.map +1 -0
  419. package/dist/views/ResetPassword/index.client.js +90 -0
  420. package/dist/views/ResetPassword/index.client.js.map +1 -0
  421. package/dist/views/ResetPassword/index.d.ts.map +1 -1
  422. package/dist/views/ResetPassword/index.js +49 -53
  423. package/dist/views/ResetPassword/index.js.map +1 -1
  424. package/dist/views/ResetPassword/index.scss +2 -12
  425. package/dist/views/ResetPassword/meta.d.ts.map +1 -1
  426. package/dist/views/ResetPassword/meta.js +4 -5
  427. package/dist/views/ResetPassword/meta.js.map +1 -1
  428. package/dist/views/Root/getViewFromConfig.d.ts +1 -1
  429. package/dist/views/Root/getViewFromConfig.d.ts.map +1 -1
  430. package/dist/views/Root/getViewFromConfig.js +29 -12
  431. package/dist/views/Root/getViewFromConfig.js.map +1 -1
  432. package/dist/views/Root/index.d.ts +1 -0
  433. package/dist/views/Root/index.d.ts.map +1 -1
  434. package/dist/views/Root/index.js +42 -16
  435. package/dist/views/Root/index.js.map +1 -1
  436. package/dist/views/Root/meta.d.ts.map +1 -1
  437. package/dist/views/Root/meta.js +0 -19
  438. package/dist/views/Root/meta.js.map +1 -1
  439. package/dist/views/Unauthorized/index.d.ts.map +1 -1
  440. package/dist/views/Unauthorized/index.js +20 -9
  441. package/dist/views/Unauthorized/index.js.map +1 -1
  442. package/dist/views/Unauthorized/meta.d.ts.map +1 -1
  443. package/dist/views/Unauthorized/meta.js +4 -5
  444. package/dist/views/Unauthorized/meta.js.map +1 -1
  445. package/dist/views/Verify/index.d.ts.map +1 -1
  446. package/dist/views/Verify/index.js +23 -8
  447. package/dist/views/Verify/index.js.map +1 -1
  448. package/dist/views/Verify/meta.d.ts.map +1 -1
  449. package/dist/views/Verify/meta.js +4 -5
  450. package/dist/views/Verify/meta.js.map +1 -1
  451. package/dist/views/Version/Default/index.js +83 -57
  452. package/dist/views/Version/Default/index.js.map +1 -1
  453. package/dist/views/Version/RenderFieldsToDiff/Label/index.js +5 -3
  454. package/dist/views/Version/RenderFieldsToDiff/Label/index.js.map +1 -1
  455. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +65 -50
  456. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
  457. package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js +30 -18
  458. package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js.map +1 -1
  459. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +23 -12
  460. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
  461. package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js +2 -1
  462. package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js.map +1 -1
  463. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +22 -11
  464. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
  465. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +31 -30
  466. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
  467. package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js +2 -1
  468. package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js.map +1 -1
  469. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +22 -11
  470. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
  471. package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts +0 -2
  472. package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts.map +1 -1
  473. package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts +2 -2
  474. package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts.map +1 -1
  475. package/dist/views/Version/RenderFieldsToDiff/fields/types.js.map +1 -1
  476. package/dist/views/Version/RenderFieldsToDiff/index.js +90 -87
  477. package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
  478. package/dist/views/Version/RenderFieldsToDiff/types.d.ts +2 -2
  479. package/dist/views/Version/RenderFieldsToDiff/types.d.ts.map +1 -1
  480. package/dist/views/Version/RenderFieldsToDiff/types.js.map +1 -1
  481. package/dist/views/Version/Restore/index.d.ts.map +1 -1
  482. package/dist/views/Version/Restore/index.js +49 -26
  483. package/dist/views/Version/Restore/index.js.map +1 -1
  484. package/dist/views/Version/Restore/index.scss +4 -2
  485. package/dist/views/Version/SelectComparison/index.js +32 -24
  486. package/dist/views/Version/SelectComparison/index.js.map +1 -1
  487. package/dist/views/Version/SelectLocales/index.d.ts.map +1 -1
  488. package/dist/views/Version/SelectLocales/index.js +18 -11
  489. package/dist/views/Version/SelectLocales/index.js.map +1 -1
  490. package/dist/views/Version/index.js +2 -1
  491. package/dist/views/Version/index.js.map +1 -1
  492. package/dist/views/Version/meta.d.ts.map +1 -1
  493. package/dist/views/Version/meta.js +5 -2
  494. package/dist/views/Version/meta.js.map +1 -1
  495. package/dist/views/Versions/buildColumns.js +7 -6
  496. package/dist/views/Versions/buildColumns.js.map +1 -1
  497. package/dist/views/Versions/cells/AutosaveCell/index.js +25 -3
  498. package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
  499. package/dist/views/Versions/cells/CreatedAt/index.js +9 -7
  500. package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
  501. package/dist/views/Versions/cells/ID/index.js +4 -1
  502. package/dist/views/Versions/cells/ID/index.js.map +1 -1
  503. package/dist/views/Versions/index.client.js +61 -29
  504. package/dist/views/Versions/index.client.js.map +1 -1
  505. package/dist/views/Versions/index.js +32 -23
  506. package/dist/views/Versions/index.js.map +1 -1
  507. package/dist/views/Versions/meta.d.ts.map +1 -1
  508. package/dist/views/Versions/meta.js +8 -4
  509. package/dist/views/Versions/meta.js.map +1 -1
  510. package/dist/withPayload.d.ts.map +1 -1
  511. package/dist/withPayload.js +46 -10
  512. package/dist/withPayload.js.map +1 -1
  513. package/package.json +41 -37
  514. package/dist/next-fileupload/fileFactory.d.ts.map +0 -1
  515. package/dist/next-fileupload/fileFactory.js.map +0 -1
  516. package/dist/next-fileupload/handlers.d.ts.map +0 -1
  517. package/dist/next-fileupload/handlers.js.map +0 -1
  518. package/dist/next-fileupload/index.d.ts.map +0 -1
  519. package/dist/next-fileupload/index.js.map +0 -1
  520. package/dist/next-fileupload/isEligibleRequest.d.ts.map +0 -1
  521. package/dist/next-fileupload/isEligibleRequest.js.map +0 -1
  522. package/dist/next-fileupload/processMultipart.d.ts +0 -8
  523. package/dist/next-fileupload/processMultipart.d.ts.map +0 -1
  524. package/dist/next-fileupload/processMultipart.js.map +0 -1
  525. package/dist/next-fileupload/processNested.d.ts.map +0 -1
  526. package/dist/next-fileupload/processNested.js.map +0 -1
  527. package/dist/next-fileupload/uploadTimer.d.ts.map +0 -1
  528. package/dist/next-fileupload/uploadTimer.js.map +0 -1
  529. package/dist/next-fileupload/utilities.d.ts.map +0 -1
  530. package/dist/next-fileupload/utilities.js.map +0 -1
  531. package/dist/next-stream-file/index.d.ts.map +0 -1
  532. package/dist/next-stream-file/index.js.map +0 -1
  533. package/dist/prod/payload/SuisseIntl-Bold.woff +0 -0
  534. package/dist/prod/payload/SuisseIntl-Bold.woff2 +0 -0
  535. package/dist/prod/payload/SuisseIntl-Medium.woff +0 -0
  536. package/dist/prod/payload/SuisseIntl-Medium.woff2 +0 -0
  537. package/dist/prod/payload/SuisseIntl-SemiBold.woff +0 -0
  538. package/dist/prod/payload/SuisseIntl-SemiBold.woff2 +0 -0
  539. package/dist/prod/payload/SuisseIntl.woff +0 -0
  540. package/dist/prod/payload/SuisseIntl.woff2 +0 -0
  541. package/dist/prod/payload/merriweather-v30-latin-900.woff +0 -0
  542. package/dist/prod/payload/merriweather-v30-latin-900.woff2 +0 -0
  543. package/dist/prod/payload/merriweather-v30-latin-900italic.woff +0 -0
  544. package/dist/prod/payload/merriweather-v30-latin-900italic.woff2 +0 -0
  545. package/dist/prod/payload/merriweather-v30-latin-italic.woff +0 -0
  546. package/dist/prod/payload/merriweather-v30-latin-italic.woff2 +0 -0
  547. package/dist/prod/payload/merriweather-v30-latin-regular.woff +0 -0
  548. package/dist/prod/payload/merriweather-v30-latin-regular.woff2 +0 -0
  549. package/dist/scss/fonts.scss +0 -75
  550. package/dist/utilities/buildFieldSchemaMap/index.d.ts +0 -4
  551. package/dist/utilities/buildFieldSchemaMap/index.d.ts.map +0 -1
  552. package/dist/utilities/buildFieldSchemaMap/index.js +0 -28
  553. package/dist/utilities/buildFieldSchemaMap/index.js.map +0 -1
  554. package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts +0 -14
  555. package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts.map +0 -1
  556. package/dist/utilities/buildFieldSchemaMap/traverseFields.js +0 -72
  557. package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +0 -1
  558. package/dist/utilities/buildFieldSchemaMap/types.d.ts +0 -3
  559. package/dist/utilities/buildFieldSchemaMap/types.d.ts.map +0 -1
  560. package/dist/utilities/buildFieldSchemaMap/types.js.map +0 -1
  561. package/dist/utilities/getDataAndFile.d.ts +0 -12
  562. package/dist/utilities/getDataAndFile.d.ts.map +0 -1
  563. package/dist/utilities/getDataAndFile.js +0 -64
  564. package/dist/utilities/getDataAndFile.js.map +0 -1
  565. package/dist/utilities/initPage.d.ts +0 -12
  566. package/dist/utilities/initPage.d.ts.map +0 -1
  567. package/dist/utilities/initPage.js.map +0 -1
  568. package/dist/views/Dashboard/Default/index.client.d.ts +0 -10
  569. package/dist/views/Dashboard/Default/index.client.d.ts.map +0 -1
  570. package/dist/views/Dashboard/Default/index.client.js +0 -103
  571. package/dist/views/Dashboard/Default/index.client.js.map +0 -1
  572. package/dist/views/Edit/Default/SetStepNav/index.d.ts.map +0 -1
  573. package/dist/views/Edit/Default/SetStepNav/index.js +0 -64
  574. package/dist/views/Edit/Default/SetStepNav/index.js.map +0 -1
  575. package/src/index.js +0 -1
  576. /package/dist/{next-fileupload → fetchAPI-multipart}/fileFactory.js +0 -0
  577. /package/dist/{next-fileupload → fetchAPI-multipart}/handlers.js +0 -0
  578. /package/dist/{next-fileupload → fetchAPI-multipart}/isEligibleRequest.d.ts +0 -0
  579. /package/dist/{next-fileupload → fetchAPI-multipart}/processNested.d.ts +0 -0
  580. /package/dist/{next-fileupload → fetchAPI-multipart}/uploadTimer.d.ts +0 -0
  581. /package/dist/{next-fileupload → fetchAPI-multipart}/uploadTimer.js +0 -0
  582. /package/dist/{next-stream-file → fetchAPI-stream-file}/index.d.ts +0 -0
  583. /package/dist/{next-stream-file → fetchAPI-stream-file}/index.js +0 -0
  584. /package/dist/prod/payload/{favicon.svg → payload-favicon.svg} +0 -0
  585. /package/dist/prod/payload/{og-image.png → static-og-image.png} +0 -0
  586. /package/dist/utilities/{buildFieldSchemaMap → initPage}/types.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,eAAe,CAAA;AAkDvF,eAAO,MAAM,UAAU,WAAkB,QAAQ,eAAe,CAAC,GAAG,eAAe,iBAyBlF,CAAA;AAED,eAAO,MAAM,IAAI,WACN,QAAQ,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBAiD9E,CAAA"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,eAAe,CAAA;AAsDvF,eAAO,MAAM,UAAU,WAAkB,QAAQ,eAAe,CAAC,GAAG,eAAe,iBAyBlF,CAAA;AAED,eAAO,MAAM,IAAI,WACN,QAAQ,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBAyD9E,CAAA"}
@@ -1,7 +1,10 @@
1
1
  import { configToSchema } from '@payloadcms/graphql';
2
2
  import { createHandler } from 'graphql-http/lib/use/fetch';
3
3
  import httpStatus from 'http-status';
4
+ import { addDataAndFileToRequest } from '../../utilities/addDataAndFileToRequest.js';
5
+ import { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest.js';
4
6
  import { createPayloadRequest } from '../../utilities/createPayloadRequest.js';
7
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
5
8
  const handleError = async (payload, err, debug, afterErrorHook)=>{
6
9
  const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR;
7
10
  let errorMessage = err.message;
@@ -23,7 +26,7 @@ const handleError = async (payload, err, debug, afterErrorHook)=>{
23
26
  path: err.path
24
27
  };
25
28
  if (afterErrorHook) {
26
- ({ response } = await afterErrorHook(err, response, null, null) || {
29
+ ({ response } = afterErrorHook(err, response, null, null) || {
27
30
  response
28
31
  });
29
32
  }
@@ -48,10 +51,10 @@ export const getGraphql = async (config)=>{
48
51
  return cached.graphql;
49
52
  }
50
53
  if (!cached.promise) {
51
- cached.promise = new Promise(async (resolve)=>{
52
- const resolvedConfig = await config;
53
- const schema = await configToSchema(resolvedConfig);
54
- resolve(schema);
54
+ const resolvedConfig = await config;
55
+ cached.promise = new Promise((resolve)=>{
56
+ const schema = configToSchema(resolvedConfig);
57
+ resolve(cached.graphql || schema);
55
58
  });
56
59
  }
57
60
  try {
@@ -64,18 +67,24 @@ export const getGraphql = async (config)=>{
64
67
  };
65
68
  export const POST = (config)=>async (request)=>{
66
69
  const originalRequest = request.clone();
67
- const req = await createPayloadRequest({
70
+ const basePayloadRequest = await createPayloadRequest({
68
71
  config,
69
72
  request
70
73
  });
74
+ const reqWithData = await addDataAndFileToRequest({
75
+ request: basePayloadRequest
76
+ });
77
+ const payloadRequest = addLocalesToRequestFromData({
78
+ request: reqWithData
79
+ });
71
80
  const { schema, validationRules } = await getGraphql(config);
72
- const { payload } = req;
81
+ const { payload } = payloadRequest;
73
82
  const afterErrorHook = typeof payload.config.hooks.afterError === 'function' ? payload.config.hooks.afterError : null;
74
83
  const headers = {};
75
84
  const apiResponse = await createHandler({
76
85
  context: {
77
86
  headers,
78
- req
87
+ req: payloadRequest
79
88
  },
80
89
  onOperation: async (request, args, result)=>{
81
90
  const response = typeof payload.extensions === 'function' ? await payload.extensions({
@@ -98,12 +107,15 @@ export const POST = (config)=>async (request)=>{
98
107
  schema,
99
108
  validationRules: (request, args, defaultRules)=>defaultRules.concat(validationRules(args))
100
109
  })(originalRequest);
101
- const resHeaders = new Headers(apiResponse.headers);
110
+ const resHeaders = headersWithCors({
111
+ headers: new Headers(apiResponse.headers),
112
+ req: payloadRequest
113
+ });
102
114
  for(const key in headers){
103
115
  resHeaders.append(key, headers[key]);
104
116
  }
105
117
  return new Response(apiResponse.body, {
106
- headers: new Headers(resHeaders),
118
+ headers: resHeaders,
107
119
  status: apiResponse.status
108
120
  });
109
121
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLFormattedError } from 'graphql'\nimport type { GraphQLError } from 'graphql'\nimport type { CollectionAfterErrorHook, Payload, SanitizedConfig } from 'payload/types'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport httpStatus from 'http-status'\n\nimport { createPayloadRequest } from '../../utilities/createPayloadRequest.js'\n\nconst handleError = async (\n payload: Payload,\n err: any,\n debug: boolean,\n afterErrorHook: CollectionAfterErrorHook,\n): Promise<GraphQLFormattedError> => {\n const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR\n let errorMessage = err.message\n payload.logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: GraphQLFormattedError = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && err.originalError.data) || undefined,\n stack: debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n if (afterErrorHook) {\n ;({ response } = (await afterErrorHook(err, response, null, null)) || { response })\n }\n\n return response\n}\n\nlet cached = global._payload_graphql\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n cached.promise = new Promise(async (resolve) => {\n const resolvedConfig = await config\n const schema = await configToSchema(resolvedConfig)\n resolve(schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\nexport const POST =\n (config: Promise<SanitizedConfig> | SanitizedConfig) => async (request: Request) => {\n const originalRequest = request.clone()\n const req = await createPayloadRequest({\n config,\n request,\n })\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = req\n\n const afterErrorHook =\n typeof payload.config.hooks.afterError === 'function' ? payload.config.hooks.afterError : null\n\n const headers = {}\n const apiResponse = await createHandler({\n context: { headers, req },\n onOperation: async (request, args, result) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: request,\n result,\n })\n : result\n if (response.errors) {\n const errors = (await Promise.all(\n result.errors.map((error) => {\n return handleError(payload, error, payload.config.debug, afterErrorHook)\n }),\n )) as GraphQLError[]\n // errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (request, args, defaultRules) => defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = new Headers(apiResponse.headers)\n for (const key in headers) {\n resHeaders.append(key, headers[key])\n }\n\n return new Response(apiResponse.body, {\n headers: new Headers(resHeaders),\n status: apiResponse.status,\n })\n }\n"],"names":["configToSchema","createHandler","httpStatus","createPayloadRequest","handleError","payload","err","debug","afterErrorHook","status","originalError","INTERNAL_SERVER_ERROR","errorMessage","message","logger","error","stack","response","extensions","name","undefined","data","statusCode","locations","path","cached","global","_payload_graphql","graphql","promise","getGraphql","config","process","env","NODE_ENV","Promise","resolve","resolvedConfig","schema","e","POST","request","originalRequest","clone","req","validationRules","hooks","afterError","headers","apiResponse","context","onOperation","args","result","errors","all","map","defaultRules","concat","resHeaders","Headers","key","append","Response","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
1
+ {"version":3,"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLError, GraphQLFormattedError } from 'graphql'\nimport type { CollectionAfterErrorHook, Payload, SanitizedConfig } from 'payload/types'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport httpStatus from 'http-status'\n\nimport { addDataAndFileToRequest } from '../../utilities/addDataAndFileToRequest.js'\nimport { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest.js'\nimport { createPayloadRequest } from '../../utilities/createPayloadRequest.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nconst handleError = async (\n payload: Payload,\n err: any,\n debug: boolean,\n afterErrorHook: CollectionAfterErrorHook,\n // eslint-disable-next-line @typescript-eslint/require-await\n): Promise<GraphQLFormattedError> => {\n const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR\n let errorMessage = err.message\n payload.logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: GraphQLFormattedError = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && err.originalError.data) || undefined,\n stack: debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n if (afterErrorHook) {\n ;({ response } = afterErrorHook(err, response, null, null) || { response })\n }\n\n return response\n}\n\nlet cached = global._payload_graphql\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\nexport const POST =\n (config: Promise<SanitizedConfig> | SanitizedConfig) => async (request: Request) => {\n const originalRequest = request.clone()\n const basePayloadRequest = await createPayloadRequest({\n config,\n request,\n })\n\n const reqWithData = await addDataAndFileToRequest({ request: basePayloadRequest })\n const payloadRequest = addLocalesToRequestFromData({ request: reqWithData })\n\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = payloadRequest\n\n const afterErrorHook =\n typeof payload.config.hooks.afterError === 'function' ? payload.config.hooks.afterError : null\n\n const headers = {}\n const apiResponse = await createHandler({\n context: { headers, req: payloadRequest },\n onOperation: async (request, args, result) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: request,\n result,\n })\n : result\n if (response.errors) {\n const errors = (await Promise.all(\n result.errors.map((error) => {\n return handleError(payload, error, payload.config.debug, afterErrorHook)\n }),\n )) as GraphQLError[]\n // errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (request, args, defaultRules) => defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req: payloadRequest,\n })\n\n for (const key in headers) {\n resHeaders.append(key, headers[key])\n }\n\n return new Response(apiResponse.body, {\n headers: resHeaders,\n status: apiResponse.status,\n })\n }\n"],"names":["configToSchema","createHandler","httpStatus","addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequest","headersWithCors","handleError","payload","err","debug","afterErrorHook","status","originalError","INTERNAL_SERVER_ERROR","errorMessage","message","logger","error","stack","response","extensions","name","undefined","data","statusCode","locations","path","cached","global","_payload_graphql","graphql","promise","getGraphql","config","process","env","NODE_ENV","resolvedConfig","Promise","resolve","schema","e","POST","request","originalRequest","clone","basePayloadRequest","reqWithData","payloadRequest","validationRules","hooks","afterError","headers","apiResponse","context","req","onOperation","args","result","errors","all","map","defaultRules","concat","resHeaders","Headers","key","append","Response","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,cAAc,QAAQ,sBAAqB;AACpD,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,OAAOC,gBAAgB,cAAa;AAEpC,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,2BAA2B,QAAQ,yCAAwC;AACpF,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,eAAe,QAAQ,qCAAoC;AAEpE,MAAMC,cAAc,OAClBC,SACAC,KACAC,OACAC;IAGA,MAAMC,SAASH,IAAII,aAAa,CAACD,MAAM,IAAIV,WAAWY,qBAAqB;IAC3E,IAAIC,eAAeN,IAAIO,OAAO;IAC9BR,QAAQS,MAAM,CAACC,KAAK,CAACT,IAAIU,KAAK;IAE9B,qFAAqF;IACrF,4FAA4F;IAC5F,IAAI,CAACT,SAASE,WAAWV,WAAWY,qBAAqB,EAAE;QACzDC,eAAe;IACjB;IAEA,IAAIK,WAAkC;QACpCC,YAAY;YACVC,MAAMb,KAAKI,eAAeS,QAAQC;YAClCC,MAAM,AAACf,OAAOA,IAAII,aAAa,IAAIJ,IAAII,aAAa,CAACW,IAAI,IAAKD;YAC9DJ,OAAOT,QAAQD,IAAIU,KAAK,GAAGI;YAC3BE,YAAYb;QACd;QACAc,WAAWjB,IAAIiB,SAAS;QACxBV,SAASD;QACTY,MAAMlB,IAAIkB,IAAI;IAChB;IAEA,IAAIhB,gBAAgB;QAChB,CAAA,EAAES,QAAQ,EAAE,GAAGT,eAAeF,KAAKW,UAAU,MAAM,SAAS;YAAEA;QAAS,CAAA;IAC3E;IAEA,OAAOA;AACT;AAEA,IAAIQ,SAASC,OAAOC,gBAAgB;AAEpC,IAAI,CAACF,QAAQ;IACX,2CAA2C;IAC3CA,SAASC,OAAOC,gBAAgB,GAAG;QAAEC,SAAS;QAAMC,SAAS;IAAK;AACpE;AAEA,OAAO,MAAMC,aAAa,OAAOC;IAC/B,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1CT,SAASC,OAAOC,gBAAgB,GAAG;YAAEC,SAAS;YAAMC,SAAS;QAAK;IACpE;IAEA,IAAIJ,OAAOG,OAAO,EAAE;QAClB,OAAOH,OAAOG,OAAO;IACvB;IAEA,IAAI,CAACH,OAAOI,OAAO,EAAE;QACnB,MAAMM,iBAAiB,MAAMJ;QAC7BN,OAAOI,OAAO,GAAG,IAAIO,QAAQ,CAACC;YAC5B,MAAMC,SAASzC,eAAesC;YAC9BE,QAAQZ,OAAOG,OAAO,IAAIU;QAC5B;IACF;IAEA,IAAI;QACFb,OAAOG,OAAO,GAAG,MAAMH,OAAOI,OAAO;IACvC,EAAE,OAAOU,GAAG;QACVd,OAAOI,OAAO,GAAG;QACjB,MAAMU;IACR;IAEA,OAAOd,OAAOG,OAAO;AACvB,EAAC;AAED,OAAO,MAAMY,OACX,CAACT,SAAuD,OAAOU;QAC7D,MAAMC,kBAAkBD,QAAQE,KAAK;QACrC,MAAMC,qBAAqB,MAAM1C,qBAAqB;YACpD6B;YACAU;QACF;QAEA,MAAMI,cAAc,MAAM7C,wBAAwB;YAAEyC,SAASG;QAAmB;QAChF,MAAME,iBAAiB7C,4BAA4B;YAAEwC,SAASI;QAAY;QAE1E,MAAM,EAAEP,MAAM,EAAES,eAAe,EAAE,GAAG,MAAMjB,WAAWC;QAErD,MAAM,EAAE1B,OAAO,EAAE,GAAGyC;QAEpB,MAAMtC,iBACJ,OAAOH,QAAQ0B,MAAM,CAACiB,KAAK,CAACC,UAAU,KAAK,aAAa5C,QAAQ0B,MAAM,CAACiB,KAAK,CAACC,UAAU,GAAG;QAE5F,MAAMC,UAAU,CAAC;QACjB,MAAMC,cAAc,MAAMrD,cAAc;YACtCsD,SAAS;gBAAEF;gBAASG,KAAKP;YAAe;YACxCQ,aAAa,OAAOb,SAASc,MAAMC;gBACjC,MAAMvC,WACJ,OAAOZ,QAAQa,UAAU,KAAK,aAC1B,MAAMb,QAAQa,UAAU,CAAC;oBACvBqC;oBACAF,KAAKZ;oBACLe;gBACF,KACAA;gBACN,IAAIvC,SAASwC,MAAM,EAAE;oBACnB,MAAMA,SAAU,MAAMrB,QAAQsB,GAAG,CAC/BF,OAAOC,MAAM,CAACE,GAAG,CAAC,CAAC5C;wBACjB,OAAOX,YAAYC,SAASU,OAAOV,QAAQ0B,MAAM,CAACxB,KAAK,EAAEC;oBAC3D;oBAEF,yIAAyI;oBACzI,OAAO;wBAAE,GAAGS,QAAQ;wBAAEwC;oBAAO;gBAC/B;gBACA,OAAOxC;YACT;YACAqB;YACAS,iBAAiB,CAACN,SAASc,MAAMK,eAAiBA,aAAaC,MAAM,CAACd,gBAAgBQ;QACxF,GAAGb;QAEH,MAAMoB,aAAa3D,gBAAgB;YACjC+C,SAAS,IAAIa,QAAQZ,YAAYD,OAAO;YACxCG,KAAKP;QACP;QAEA,IAAK,MAAMkB,OAAOd,QAAS;YACzBY,WAAWG,MAAM,CAACD,KAAKd,OAAO,CAACc,IAAI;QACrC;QAEA,OAAO,IAAIE,SAASf,YAAYgB,IAAI,EAAE;YACpCjB,SAASY;YACTrD,QAAQ0C,YAAY1C,MAAM;QAC5B;IACF,EAAC"}
@@ -1,3 +1,3 @@
1
1
  export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from './graphql/index.js';
2
- export { DELETE as REST_DELETE, GET as REST_GET, PATCH as REST_PATCH, POST as REST_POST, } from './rest/index.js';
2
+ export { DELETE as REST_DELETE, GET as REST_GET, OPTIONS as REST_OPTIONS, PATCH as REST_PATCH, POST as REST_POST, } from './rest/index.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEzE,OAAO,EACL,MAAM,IAAI,WAAW,EACrB,GAAG,IAAI,QAAQ,EACf,KAAK,IAAI,UAAU,EACnB,IAAI,IAAI,SAAS,GAClB,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEzE,OAAO,EACL,MAAM,IAAI,WAAW,EACrB,GAAG,IAAI,QAAQ,EACf,OAAO,IAAI,YAAY,EACvB,KAAK,IAAI,UAAU,EACnB,IAAI,IAAI,SAAS,GAClB,MAAM,iBAAiB,CAAA"}
@@ -1,4 +1,4 @@
1
1
  export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from './graphql/index.js';
2
- export { DELETE as REST_DELETE, GET as REST_GET, PATCH as REST_PATCH, POST as REST_POST } from './rest/index.js';
2
+ export { DELETE as REST_DELETE, GET as REST_GET, OPTIONS as REST_OPTIONS, PATCH as REST_PATCH, POST as REST_POST } from './rest/index.js';
3
3
 
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/routes/index.ts"],"sourcesContent":["export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from './graphql/index.js'\n\nexport {\n DELETE as REST_DELETE,\n GET as REST_GET,\n PATCH as REST_PATCH,\n POST as REST_POST,\n} from './rest/index.js'\n"],"names":["GRAPHQL_PLAYGROUND_GET","GRAPHQL_POST","DELETE","REST_DELETE","GET","REST_GET","PATCH","REST_PATCH","POST","REST_POST"],"rangeMappings":";","mappings":"AAAA,SAASA,sBAAsB,EAAEC,YAAY,QAAQ,qBAAoB;AAEzE,SACEC,UAAUC,WAAW,EACrBC,OAAOC,QAAQ,EACfC,SAASC,UAAU,EACnBC,QAAQC,SAAS,QACZ,kBAAiB"}
1
+ {"version":3,"sources":["../../src/routes/index.ts"],"sourcesContent":["export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from './graphql/index.js'\n\nexport {\n DELETE as REST_DELETE,\n GET as REST_GET,\n OPTIONS as REST_OPTIONS,\n PATCH as REST_PATCH,\n POST as REST_POST,\n} from './rest/index.js'\n"],"names":["GRAPHQL_PLAYGROUND_GET","GRAPHQL_POST","DELETE","REST_DELETE","GET","REST_GET","OPTIONS","REST_OPTIONS","PATCH","REST_PATCH","POST","REST_POST"],"rangeMappings":";","mappings":"AAAA,SAASA,sBAAsB,EAAEC,YAAY,QAAQ,qBAAoB;AAEzE,SACEC,UAAUC,WAAW,EACrBC,OAAOC,QAAQ,EACfC,WAAWC,YAAY,EACvBC,SAASC,UAAU,EACnBC,QAAQC,SAAS,QACZ,kBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/access.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,eAAO,MAAM,MAAM,EAAE,gBAQpB,CAAA"}
1
+ {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/access.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAInD,eAAO,MAAM,MAAM,EAAE,gBA0BpB,CAAA"}
@@ -1,12 +1,27 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { accessOperation } from 'payload/operations';
3
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
3
4
  export const access = async ({ req })=>{
4
- const results = await accessOperation({
5
+ const headers = headersWithCors({
6
+ headers: new Headers(),
5
7
  req
6
8
  });
7
- return Response.json(results, {
8
- status: httpStatus.OK
9
- });
9
+ try {
10
+ const results = await accessOperation({
11
+ req
12
+ });
13
+ return Response.json(results, {
14
+ headers,
15
+ status: httpStatus.OK
16
+ });
17
+ } catch (e) {
18
+ return Response.json({
19
+ error: e
20
+ }, {
21
+ headers,
22
+ status: httpStatus.INTERNAL_SERVER_ERROR
23
+ });
24
+ }
10
25
  };
11
26
 
12
27
  //# sourceMappingURL=access.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/auth/access.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { accessOperation } from 'payload/operations'\n\nimport type { BaseRouteHandler } from '../types.js'\n\nexport const access: BaseRouteHandler = async ({ req }) => {\n const results = await accessOperation({\n req,\n })\n\n return Response.json(results, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","accessOperation","access","req","results","Response","json","status","OK"],"rangeMappings":";;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,OAAO,MAAMC,SAA2B,OAAO,EAAEC,GAAG,EAAE;IACpD,MAAMC,UAAU,MAAMH,gBAAgB;QACpCE;IACF;IAEA,OAAOE,SAASC,IAAI,CAACF,SAAS;QAC5BG,QAAQP,WAAWQ,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/auth/access.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { accessOperation } from 'payload/operations'\n\nimport type { BaseRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const access: BaseRouteHandler = 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":["httpStatus","accessOperation","headersWithCors","access","req","headers","Headers","results","Response","json","status","OK","e","error","INTERNAL_SERVER_ERROR"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAA2B,OAAO,EAAEC,GAAG,EAAE;IACpD,MAAMC,UAAUH,gBAAgB;QAC9BG,SAAS,IAAIC;QACbF;IACF;IAEA,IAAI;QACF,MAAMG,UAAU,MAAMN,gBAAgB;YACpCG;QACF;QAEA,OAAOI,SAASC,IAAI,CAACF,SAAS;YAC5BF;YACAK,QAAQV,WAAWW,EAAE;QACvB;IACF,EAAE,OAAOC,GAAY;QACnB,OAAOJ,SAASC,IAAI,CAClB;YACEI,OAAOD;QACT,GACA;YACEP;YACAK,QAAQV,WAAWc,qBAAqB;QAC1C;IAEJ;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,cAAc,EAAE,sBAoB5B,CAAA"}
1
+ {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,cAAc,EAAE,sBAwB5B,CAAA"}
@@ -1,6 +1,8 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { forgotPasswordOperation } from 'payload/operations';
3
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
3
4
  export const forgotPassword = async ({ collection, req })=>{
5
+ const { t } = req;
4
6
  await forgotPasswordOperation({
5
7
  collection,
6
8
  data: {
@@ -11,9 +13,12 @@ export const forgotPassword = async ({ collection, req })=>{
11
13
  req
12
14
  });
13
15
  return Response.json({
14
- // TODO(translate)
15
- message: 'Success'
16
+ message: t('general:success')
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/routes/rest/auth/forgotPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { forgotPasswordOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const forgotPassword: CollectionRouteHandler = async ({ collection, req }) => {\n await forgotPasswordOperation({\n collection,\n data: {\n email: req.data.email as string,\n },\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 // TODO(translate)\n message: 'Success',\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","forgotPasswordOperation","forgotPassword","collection","req","data","email","disableEmail","Boolean","expiration","undefined","Response","json","message","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,uBAAuB,QAAQ,qBAAoB;AAI5D,OAAO,MAAMC,iBAAyC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAC9E,MAAMH,wBAAwB;QAC5BE;QACAE,MAAM;YACJC,OAAOF,IAAIC,IAAI,CAACC,KAAK;QACvB;QACAC,cAAcC,QAAQJ,IAAIC,IAAI,EAAEE;QAChCE,YAAY,OAAOL,IAAIC,IAAI,CAACI,UAAU,KAAK,WAAWL,IAAIC,IAAI,CAACI,UAAU,GAAGC;QAC5EN;IACF;IAEA,OAAOO,SAASC,IAAI,CAClB;QACE,kBAAkB;QAClBC,SAAS;IACX,GACA;QACEC,QAAQd,WAAWe,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { forgotPasswordOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const forgotPassword: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n await forgotPasswordOperation({\n collection,\n data: {\n email: req.data.email as string,\n },\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":["httpStatus","forgotPasswordOperation","headersWithCors","forgotPassword","collection","req","t","data","email","disableEmail","Boolean","expiration","undefined","Response","json","message","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,uBAAuB,QAAQ,qBAAoB;AAI5D,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,iBAAyC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAC9E,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAMJ,wBAAwB;QAC5BG;QACAG,MAAM;YACJC,OAAOH,IAAIE,IAAI,CAACC,KAAK;QACvB;QACAC,cAAcC,QAAQL,IAAIE,IAAI,EAAEE;QAChCE,YAAY,OAAON,IAAIE,IAAI,CAACI,UAAU,KAAK,WAAWN,IAAIE,IAAI,CAACI,UAAU,GAAGC;QAC5EP;IACF;IAEA,OAAOQ,SAASC,IAAI,CAClB;QACEC,SAAST,EAAE;IACb,GACA;QACEU,SAASd,gBAAgB;YACvBc,SAAS,IAAIC;YACbZ;QACF;QACAa,QAAQlB,WAAWmB,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,IAAI,EAAE,sBAOlB,CAAA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,IAAI,EAAE,sBAelB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { initOperation } from 'payload/operations';
2
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
2
3
  export const init = async ({ collection, req })=>{
3
4
  const initialized = await initOperation({
4
5
  collection: collection.config.slug,
@@ -6,6 +7,11 @@ export const init = async ({ collection, req })=>{
6
7
  });
7
8
  return Response.json({
8
9
  initialized
10
+ }, {
11
+ headers: headersWithCors({
12
+ headers: new Headers(),
13
+ req
14
+ })
9
15
  });
10
16
  };
11
17
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/auth/init.ts"],"sourcesContent":["import { initOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const init: CollectionRouteHandler = async ({ collection, req }) => {\n const initialized = await initOperation({\n collection: collection.config.slug,\n req,\n })\n\n return Response.json({ initialized })\n}\n"],"names":["initOperation","init","collection","req","initialized","config","slug","Response","json"],"rangeMappings":";;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAoB;AAIlD,OAAO,MAAMC,OAA+B,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACpE,MAAMC,cAAc,MAAMJ,cAAc;QACtCE,YAAYA,WAAWG,MAAM,CAACC,IAAI;QAClCH;IACF;IAEA,OAAOI,SAASC,IAAI,CAAC;QAAEJ;IAAY;AACrC,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/auth/init.ts"],"sourcesContent":["import { initOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const init: CollectionRouteHandler = async ({ collection, req }) => {\n const initialized = await initOperation({\n collection: collection.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":["initOperation","headersWithCors","init","collection","req","initialized","config","slug","Response","json","headers","Headers"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAoB;AAIlD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,OAA+B,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACpE,MAAMC,cAAc,MAAML,cAAc;QACtCG,YAAYA,WAAWG,MAAM,CAACC,IAAI;QAClCH;IACF;IAEA,OAAOI,SAASC,IAAI,CAClB;QAAEJ;IAAY,GACd;QACEK,SAAST,gBAAgB;YACvBS,SAAS,IAAIC;YACbP;QACF;IACF;AAEJ,EAAC"}
@@ -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;AAEzD,eAAO,MAAM,KAAK,EAAE,sBAqCnB,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
- // TODO(translate)
27
- message: 'Auth Passed',
27
+ message: t('authentication:passed'),
28
28
  ...result
29
29
  }, {
30
- headers: new Headers({
31
- 'Set-Cookie': cookie
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 // TODO(translate)\n message: 'Auth Passed',\n ...result,\n },\n {\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generatePayloadCookie","loginOperation","isNumber","login","collection","req","searchParams","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,OAAO,MAAMC,QAAgC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrE,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMR,eAAe;QAClCG;QACAM,MAAM;YACJC,OAAO,OAAON,IAAIK,IAAI,EAAEC,UAAU,WAAWN,IAAIK,IAAI,CAACC,KAAK,GAAG;YAC9DC,UAAU,OAAOP,IAAIK,IAAI,EAAEE,aAAa,WAAWP,IAAIK,IAAI,CAACE,QAAQ,GAAG;QACzE;QACAL,OAAOL,SAASK,SAASM,OAAON,SAASO;QACzCT;IACF;IAEA,MAAMU,SAASf,sBAAsB;QACnCgB,kBAAkBZ,WAAWa,MAAM;QACnCC,SAASb,IAAIa,OAAO;QACpBC,OAAOV,OAAOU,KAAK;IACrB;IAEA,IAAIf,WAAWa,MAAM,CAACG,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOZ,OAAOU,KAAK;IACrB;IAEA,OAAOG,SAASC,IAAI,CAClB;QACE,kBAAkB;QAClBC,SAAS;QACT,GAAGf,MAAM;IACX,GACA;QACEgB,SAAS,IAAIC,QAAQ;YACnB,cAAcX;QAChB;QACAY,QAAQ5B,WAAW6B,EAAE;IACvB;AAEJ,EAAC"}
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;AAEzD,eAAO,MAAM,MAAM,EAAE,sBAkCpB,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 })=>{
5
- const result = logoutOperation({
6
+ const { t } = req;
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: 'Logout failed.'
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
- // TODO(translate)
22
- message: 'Logout successful.'
29
+ message: t('authentication:logoutSuccessful')
23
30
  }, {
24
- headers: new 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 = logoutOperation({\n collection,\n req,\n })\n\n if (!result) {\n return Response.json(\n {\n message: 'Logout failed.',\n },\n {\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n const expiredCookie = generateExpiredPayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n })\n\n return Response.json(\n {\n // TODO(translate)\n message: 'Logout successful.',\n },\n {\n headers: new Headers({\n 'Set-Cookie': expiredCookie,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generateExpiredPayloadCookie","logoutOperation","logout","collection","req","result","Response","json","message","status","BAD_REQUEST","expiredCookie","collectionConfig","config","payload","headers","Headers","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,4BAA4B,QAAQ,eAAc;AAC3D,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAMC,SAASJ,gBAAgB;QAC7BE;QACAC;IACF;IAEA,IAAI,CAACC,QAAQ;QACX,OAAOC,SAASC,IAAI,CAClB;YACEC,SAAS;QACX,GACA;YACEC,QAAQV,WAAWW,WAAW;QAChC;IAEJ;IAEA,MAAMC,gBAAgBX,6BAA6B;QACjDY,kBAAkBT,WAAWU,MAAM;QACnCC,SAASV,IAAIU,OAAO;IACtB;IAEA,OAAOR,SAASC,IAAI,CAClB;QACE,kBAAkB;QAClBC,SAAS;IACX,GACA;QACEO,SAAS,IAAIC,QAAQ;YACnB,cAAcL;QAChB;QACAF,QAAQV,WAAWkB,EAAE;IACvB;AAEJ,EAAC"}
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;AAEzD,eAAO,MAAM,EAAE,EAAE,sBAsBhB,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":";;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,UAAU,QAAQ,eAAc;AACzC,SAASC,WAAW,QAAQ,qBAAoB;AAIhD,OAAO,MAAMC,KAA6B,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAClE,MAAMC,eAAeL,WAAWI;IAEhC,MAAME,SAAS,MAAML,YAAY;QAC/BE;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,QAAQhB,WAAWiB,EAAE;IACvB;AAEJ,EAAC"}
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;AAEzD,eAAO,MAAM,OAAO,EAAE,sBA4CrB,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
- // TODO(translate)
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
- // TODO(translate)
30
- message: 'Token refresh successful',
36
+ message: t('authentication:tokenRefreshSuccessful'),
31
37
  ...result
32
38
  }, {
33
- headers: new 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 // TODO(translate)\n message: 'Token not provided.',\n },\n {\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 return Response.json(\n {\n // TODO(translate)\n message: 'Token refresh successful',\n ...result,\n },\n {\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","extractJWT","generatePayloadCookie","refreshOperation","refresh","collection","req","token","data","Response","json","message","status","UNAUTHORIZED","result","cookie","collectionConfig","config","payload","refreshedToken","auth","removeTokenFromResponses","headers","Headers","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,UAAU,QAAQ,eAAc;AACzC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,gBAAgB,QAAQ,qBAAoB;AAIrD,OAAO,MAAMC,UAAkC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACvE,MAAMC,QAAQ,OAAOD,IAAIE,IAAI,EAAED,UAAU,WAAWD,IAAIE,IAAI,CAACD,KAAK,GAAGN,WAAWK;IAEhF,IAAI,CAACC,OAAO;QACV,OAAOE,SAASC,IAAI,CAClB;YACE,kBAAkB;YAClBC,SAAS;QACX,GACA;YACEC,QAAQZ,WAAWa,YAAY;QACjC;IAEJ;IAEA,MAAMC,SAAS,MAAMX,iBAAiB;QACpCE;QACAC;QACAC;IACF;IAEA,MAAMQ,SAASb,sBAAsB;QACnCc,kBAAkBX,WAAWY,MAAM;QACnCC,SAASZ,IAAIY,OAAO;QACpBX,OAAOO,OAAOK,cAAc;IAC9B;IAEA,IAAId,WAAWY,MAAM,CAACG,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOP,OAAOK,cAAc;IAC9B;IAEA,OAAOV,SAASC,IAAI,CAClB;QACE,kBAAkB;QAClBC,SAAS;QACT,GAAGG,MAAM;IACX,GACA;QACEQ,SAAS,IAAIC,QAAQ;YACnB,cAAcR;QAChB;QACAH,QAAQZ,WAAWwB,EAAE;IACvB;AAEJ,EAAC"}
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":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,iBAAiB,EAAE,sBAkC/B,CAAA"}
1
+ {"version":3,"file":"registerFirstUser.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,iBAAiB,EAAE,sBAoC/B,CAAA"}
@@ -1,8 +1,9 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { generatePayloadCookie } from 'payload/auth';
3
3
  import { registerFirstUserOperation } from 'payload/operations';
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
5
  export const registerFirstUser = async ({ collection, req })=>{
5
- const data = req.data;
6
+ const { data, t } = req;
6
7
  const result = await registerFirstUserOperation({
7
8
  collection,
8
9
  data: {
@@ -19,13 +20,15 @@ export const registerFirstUser = async ({ collection, req })=>{
19
20
  });
20
21
  return Response.json({
21
22
  exp: result.exp,
22
- // TODO(translate)
23
- message: 'Successfully registered first user.',
23
+ message: t('authentication:successfullyRegisteredFirstUser'),
24
24
  token: result.token,
25
25
  user: result.user
26
26
  }, {
27
- headers: new Headers({
28
- 'Set-Cookie': cookie
27
+ headers: headersWithCors({
28
+ headers: new Headers({
29
+ 'Set-Cookie': cookie
30
+ }),
31
+ req
29
32
  }),
30
33
  status: httpStatus.OK
31
34
  });
@@ -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.data\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 // TODO(translate)\n message: 'Successfully registered first user.',\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":["httpStatus","generatePayloadCookie","registerFirstUserOperation","registerFirstUser","collection","req","data","result","email","password","cookie","collectionConfig","config","payload","token","Response","json","exp","message","user","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,SAASC,0BAA0B,QAAQ,qBAAoB;AAI/D,OAAO,MAAMC,oBAA4C,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACjF,MAAMC,OAAOD,IAAIC,IAAI;IAErB,MAAMC,SAAS,MAAML,2BAA2B;QAC9CE;QACAE,MAAM;YACJ,GAAGA,IAAI;YACPE,OAAO,OAAOF,MAAME,UAAU,WAAWF,KAAKE,KAAK,GAAG;YACtDC,UAAU,OAAOH,MAAMG,aAAa,WAAWH,KAAKG,QAAQ,GAAG;QACjE;QACAJ;IACF;IAEA,MAAMK,SAAST,sBAAsB;QACnCU,kBAAkBP,WAAWQ,MAAM;QACnCC,SAASR,IAAIQ,OAAO;QACpBC,OAAOP,OAAOO,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEC,KAAKV,OAAOU,GAAG;QACf,kBAAkB;QAClBC,SAAS;QACTJ,OAAOP,OAAOO,KAAK;QACnBK,MAAMZ,OAAOY,IAAI;IACnB,GACA;QACEC,SAAS,IAAIC,QAAQ;YACnB,cAAcX;QAChB;QACAY,QAAQtB,WAAWuB,EAAE;IACvB;AAEJ,EAAC"}
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\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const registerFirstUser: CollectionRouteHandler = async ({ collection, req }) => {\n const { data, t } = req\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","registerFirstUserOperation","headersWithCors","registerFirstUser","collection","req","data","t","result","email","password","cookie","collectionConfig","config","payload","token","Response","json","exp","message","user","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,QAAQ,eAAc;AACpD,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,MAAMG,SAAS,MAAMP,2BAA2B;QAC9CG;QACAE,MAAM;YACJ,GAAGA,IAAI;YACPG,OAAO,OAAOH,MAAMG,UAAU,WAAWH,KAAKG,KAAK,GAAG;YACtDC,UAAU,OAAOJ,MAAMI,aAAa,WAAWJ,KAAKI,QAAQ,GAAG;QACjE;QACAL;IACF;IAEA,MAAMM,SAASX,sBAAsB;QACnCY,kBAAkBR,WAAWS,MAAM;QACnCC,SAAST,IAAIS,OAAO;QACpBC,OAAOP,OAAOO,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEC,KAAKV,OAAOU,GAAG;QACfC,SAASZ,EAAE;QACXQ,OAAOP,OAAOO,KAAK;QACnBK,MAAMZ,OAAOY,IAAI;IACnB,GACA;QACEC,SAASnB,gBAAgB;YACvBmB,SAAS,IAAIC,QAAQ;gBACnB,cAAcX;YAChB;YACAN;QACF;QACAkB,QAAQxB,WAAWyB,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;AAEzD,eAAO,MAAM,aAAa,EAAE,sBAqC3B,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
- // TODO(translate)
26
- message: 'Password reset successfully.',
26
+ message: t('authentication:passwordResetSuccessfully'),
27
27
  ...result
28
28
  }, {
29
- headers: new Headers({
30
- 'Set-Cookie': cookie
29
+ headers: headersWithCors({
30
+ headers: new Headers({
31
+ 'Set-Cookie': cookie
32
+ }),
33
+ req
31
34
  }),
32
35
  status: httpStatus.OK
33
36
  });