@payloadcms/next 3.0.0-canary.a5aaf21 → 3.0.0-canary.a6e7305

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 (301) hide show
  1. package/dist/cjs/withPayload.cjs +156 -0
  2. package/dist/cjs/withPayload.cjs.map +1 -0
  3. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.d.ts.map +1 -1
  4. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js +1 -0
  5. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js.map +1 -1
  6. package/dist/elements/DocumentHeader/Tabs/Tab/index.scss +70 -68
  7. package/dist/elements/DocumentHeader/Tabs/index.scss +41 -39
  8. package/dist/elements/DocumentHeader/index.scss +44 -42
  9. package/dist/elements/DocumentLocked/index.d.ts +1 -1
  10. package/dist/elements/DocumentLocked/index.d.ts.map +1 -1
  11. package/dist/elements/DocumentLocked/index.js +24 -14
  12. package/dist/elements/DocumentLocked/index.js.map +1 -1
  13. package/dist/elements/DocumentLocked/index.scss +29 -26
  14. package/dist/elements/DocumentTakeOver/index.scss +28 -26
  15. package/dist/elements/FormHeader/index.d.ts +9 -0
  16. package/dist/elements/FormHeader/index.d.ts.map +1 -0
  17. package/dist/elements/FormHeader/index.js +20 -0
  18. package/dist/elements/FormHeader/index.js.map +1 -0
  19. package/dist/elements/FormHeader/index.scss +8 -0
  20. package/dist/elements/LeaveWithoutSaving/index.scss +28 -26
  21. package/dist/elements/Nav/NavWrapper/index.scss +20 -18
  22. package/dist/elements/Nav/index.client.d.ts.map +1 -1
  23. package/dist/elements/Nav/index.client.js +1 -0
  24. package/dist/elements/Nav/index.client.js.map +1 -1
  25. package/dist/elements/Nav/index.scss +127 -125
  26. package/dist/exports/routes.d.ts +1 -1
  27. package/dist/exports/routes.d.ts.map +1 -1
  28. package/dist/exports/routes.js +1 -1
  29. package/dist/exports/routes.js.map +1 -1
  30. package/dist/exports/utilities.d.ts +1 -0
  31. package/dist/exports/utilities.d.ts.map +1 -1
  32. package/dist/exports/utilities.js +1 -0
  33. package/dist/exports/utilities.js.map +1 -1
  34. package/dist/layouts/Root/index.js +6 -6
  35. package/dist/layouts/Root/index.js.map +1 -1
  36. package/dist/prod/styles.css +1 -1
  37. package/dist/routes/graphql/handler.d.ts.map +1 -1
  38. package/dist/routes/graphql/handler.js +23 -11
  39. package/dist/routes/graphql/handler.js.map +1 -1
  40. package/dist/routes/rest/auth/login.js +2 -2
  41. package/dist/routes/rest/auth/login.js.map +1 -1
  42. package/dist/routes/rest/auth/logout.d.ts.map +1 -1
  43. package/dist/routes/rest/auth/logout.js +3 -2
  44. package/dist/routes/rest/auth/logout.js.map +1 -1
  45. package/dist/routes/rest/auth/refresh.js +2 -2
  46. package/dist/routes/rest/auth/refresh.js.map +1 -1
  47. package/dist/routes/rest/auth/registerFirstUser.js +2 -2
  48. package/dist/routes/rest/auth/registerFirstUser.js.map +1 -1
  49. package/dist/routes/rest/auth/resetPassword.js +2 -2
  50. package/dist/routes/rest/auth/resetPassword.js.map +1 -1
  51. package/dist/routes/rest/collections/create.d.ts.map +1 -1
  52. package/dist/routes/rest/collections/create.js +5 -1
  53. package/dist/routes/rest/collections/create.js.map +1 -1
  54. package/dist/routes/rest/collections/delete.d.ts.map +1 -1
  55. package/dist/routes/rest/collections/delete.js +8 -0
  56. package/dist/routes/rest/collections/delete.js.map +1 -1
  57. package/dist/routes/rest/collections/deleteByID.d.ts.map +1 -1
  58. package/dist/routes/rest/collections/deleteByID.js +7 -1
  59. package/dist/routes/rest/collections/deleteByID.js.map +1 -1
  60. package/dist/routes/rest/collections/duplicate.d.ts.map +1 -1
  61. package/dist/routes/rest/collections/duplicate.js +5 -1
  62. package/dist/routes/rest/collections/duplicate.js.map +1 -1
  63. package/dist/routes/rest/collections/find.d.ts.map +1 -1
  64. package/dist/routes/rest/collections/find.js +7 -1
  65. package/dist/routes/rest/collections/find.js.map +1 -1
  66. package/dist/routes/rest/collections/findByID.d.ts.map +1 -1
  67. package/dist/routes/rest/collections/findByID.js +5 -1
  68. package/dist/routes/rest/collections/findByID.js.map +1 -1
  69. package/dist/routes/rest/collections/findVersionByID.d.ts.map +1 -1
  70. package/dist/routes/rest/collections/findVersionByID.js +5 -1
  71. package/dist/routes/rest/collections/findVersionByID.js.map +1 -1
  72. package/dist/routes/rest/collections/findVersions.d.ts.map +1 -1
  73. package/dist/routes/rest/collections/findVersions.js +7 -1
  74. package/dist/routes/rest/collections/findVersions.js.map +1 -1
  75. package/dist/routes/rest/collections/restoreVersion.d.ts.map +1 -1
  76. package/dist/routes/rest/collections/restoreVersion.js +2 -0
  77. package/dist/routes/rest/collections/restoreVersion.js.map +1 -1
  78. package/dist/routes/rest/collections/update.d.ts.map +1 -1
  79. package/dist/routes/rest/collections/update.js +10 -0
  80. package/dist/routes/rest/collections/update.js.map +1 -1
  81. package/dist/routes/rest/collections/updateByID.d.ts.map +1 -1
  82. package/dist/routes/rest/collections/updateByID.js +7 -1
  83. package/dist/routes/rest/collections/updateByID.js.map +1 -1
  84. package/dist/routes/rest/globals/findOne.d.ts.map +1 -1
  85. package/dist/routes/rest/globals/findOne.js +5 -1
  86. package/dist/routes/rest/globals/findOne.js.map +1 -1
  87. package/dist/routes/rest/globals/findVersionByID.d.ts.map +1 -1
  88. package/dist/routes/rest/globals/findVersionByID.js +5 -1
  89. package/dist/routes/rest/globals/findVersionByID.js.map +1 -1
  90. package/dist/routes/rest/globals/findVersions.d.ts.map +1 -1
  91. package/dist/routes/rest/globals/findVersions.js +7 -1
  92. package/dist/routes/rest/globals/findVersions.js.map +1 -1
  93. package/dist/routes/rest/globals/restoreVersion.d.ts.map +1 -1
  94. package/dist/routes/rest/globals/restoreVersion.js +2 -0
  95. package/dist/routes/rest/globals/restoreVersion.js.map +1 -1
  96. package/dist/routes/rest/globals/update.d.ts.map +1 -1
  97. package/dist/routes/rest/globals/update.js +5 -1
  98. package/dist/routes/rest/globals/update.js.map +1 -1
  99. package/dist/routes/rest/index.d.ts +17 -12
  100. package/dist/routes/rest/index.d.ts.map +1 -1
  101. package/dist/routes/rest/index.js +90 -15
  102. package/dist/routes/rest/index.js.map +1 -1
  103. package/dist/routes/rest/og/index.js +2 -4
  104. package/dist/routes/rest/og/index.js.map +1 -1
  105. package/dist/routes/rest/routeError.d.ts +2 -7
  106. package/dist/routes/rest/routeError.d.ts.map +1 -1
  107. package/dist/routes/rest/routeError.js +33 -19
  108. package/dist/routes/rest/routeError.js.map +1 -1
  109. package/dist/routes/rest/utilities/sanitizeJoinParams.d.ts +1 -1
  110. package/dist/routes/rest/utilities/sanitizeJoinParams.d.ts.map +1 -1
  111. package/dist/routes/rest/utilities/sanitizeJoinParams.js +9 -5
  112. package/dist/routes/rest/utilities/sanitizeJoinParams.js.map +1 -1
  113. package/dist/routes/rest/utilities/sanitizePopulate.d.ts +3 -0
  114. package/dist/routes/rest/utilities/sanitizePopulate.d.ts.map +1 -0
  115. package/dist/routes/rest/utilities/sanitizePopulate.js +11 -0
  116. package/dist/routes/rest/utilities/sanitizePopulate.js.map +1 -0
  117. package/dist/routes/rest/utilities/sanitizeSelect.d.ts +6 -0
  118. package/dist/routes/rest/utilities/sanitizeSelect.d.ts.map +1 -0
  119. package/dist/routes/rest/utilities/sanitizeSelect.js +17 -0
  120. package/dist/routes/rest/utilities/sanitizeSelect.js.map +1 -0
  121. package/dist/scss/app.scss +166 -162
  122. package/dist/scss/colors.scss +256 -254
  123. package/dist/scss/resets.scss +9 -7
  124. package/dist/scss/toastify.scss +42 -40
  125. package/dist/scss/toasts.scss +105 -103
  126. package/dist/scss/type.scss +80 -79
  127. package/dist/templates/Default/Wrapper/index.scss +38 -36
  128. package/dist/templates/Default/index.scss +60 -58
  129. package/dist/templates/Minimal/index.scss +22 -20
  130. package/dist/utilities/getNextRequestI18n.js +2 -2
  131. package/dist/utilities/getNextRequestI18n.js.map +1 -1
  132. package/dist/utilities/getRequestTheme.d.ts.map +1 -1
  133. package/dist/utilities/getRequestTheme.js +3 -0
  134. package/dist/utilities/getRequestTheme.js.map +1 -1
  135. package/dist/utilities/initPage/handleAdminPage.d.ts +12 -11
  136. package/dist/utilities/initPage/handleAdminPage.d.ts.map +1 -1
  137. package/dist/utilities/initPage/handleAdminPage.js +9 -21
  138. package/dist/utilities/initPage/handleAdminPage.js.map +1 -1
  139. package/dist/utilities/initPage/handleAuthRedirect.d.ts +6 -3
  140. package/dist/utilities/initPage/handleAuthRedirect.d.ts.map +1 -1
  141. package/dist/utilities/initPage/handleAuthRedirect.js +23 -36
  142. package/dist/utilities/initPage/handleAuthRedirect.js.map +1 -1
  143. package/dist/utilities/initPage/index.d.ts +1 -1
  144. package/dist/utilities/initPage/index.d.ts.map +1 -1
  145. package/dist/utilities/initPage/index.js +27 -10
  146. package/dist/utilities/initPage/index.js.map +1 -1
  147. package/dist/utilities/initPage/isCustomAdminView.d.ts +10 -0
  148. package/dist/utilities/initPage/isCustomAdminView.d.ts.map +1 -0
  149. package/dist/utilities/initPage/isCustomAdminView.js +31 -0
  150. package/dist/utilities/initPage/isCustomAdminView.js.map +1 -0
  151. package/dist/utilities/initPage/shared.d.ts +2 -2
  152. package/dist/utilities/initPage/shared.d.ts.map +1 -1
  153. package/dist/utilities/initPage/shared.js +19 -13
  154. package/dist/utilities/initPage/shared.js.map +1 -1
  155. package/dist/utilities/initReq.js +1 -1
  156. package/dist/utilities/initReq.js.map +1 -1
  157. package/dist/views/API/RenderJSON/index.scss +68 -66
  158. package/dist/views/API/index.scss +98 -96
  159. package/dist/views/Account/Settings/index.d.ts +2 -1
  160. package/dist/views/Account/Settings/index.d.ts.map +1 -1
  161. package/dist/views/Account/Settings/index.js +3 -2
  162. package/dist/views/Account/Settings/index.js.map +1 -1
  163. package/dist/views/Account/Settings/index.scss +37 -35
  164. package/dist/views/Account/ToggleTheme/index.d.ts.map +1 -1
  165. package/dist/views/Account/ToggleTheme/index.js +1 -0
  166. package/dist/views/Account/ToggleTheme/index.js.map +1 -1
  167. package/dist/views/Account/index.d.ts.map +1 -1
  168. package/dist/views/Account/index.js +4 -2
  169. package/dist/views/Account/index.js.map +1 -1
  170. package/dist/views/CreateFirstUser/index.client.d.ts.map +1 -1
  171. package/dist/views/CreateFirstUser/index.client.js +31 -15
  172. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  173. package/dist/views/CreateFirstUser/index.scss +13 -11
  174. package/dist/views/Dashboard/Default/index.d.ts +3 -1
  175. package/dist/views/Dashboard/Default/index.d.ts.map +1 -1
  176. package/dist/views/Dashboard/Default/index.js +12 -3
  177. package/dist/views/Dashboard/Default/index.js.map +1 -1
  178. package/dist/views/Dashboard/Default/index.scss +51 -49
  179. package/dist/views/Dashboard/index.d.ts.map +1 -1
  180. package/dist/views/Dashboard/index.js +31 -13
  181. package/dist/views/Dashboard/index.js.map +1 -1
  182. package/dist/views/Document/getDocumentData.js +4 -2
  183. package/dist/views/Document/getDocumentData.js.map +1 -1
  184. package/dist/views/Document/getDocumentPermissions.d.ts.map +1 -1
  185. package/dist/views/Document/getDocumentPermissions.js +6 -5
  186. package/dist/views/Document/getDocumentPermissions.js.map +1 -1
  187. package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -1
  188. package/dist/views/Document/getViewsFromConfig.js +6 -0
  189. package/dist/views/Document/getViewsFromConfig.js.map +1 -1
  190. package/dist/views/Edit/Default/Auth/APIKey.d.ts.map +1 -1
  191. package/dist/views/Edit/Default/Auth/APIKey.js +2 -8
  192. package/dist/views/Edit/Default/Auth/APIKey.js.map +1 -1
  193. package/dist/views/Edit/Default/Auth/index.d.ts.map +1 -1
  194. package/dist/views/Edit/Default/Auth/index.js +37 -26
  195. package/dist/views/Edit/Default/Auth/index.js.map +1 -1
  196. package/dist/views/Edit/Default/Auth/index.scss +56 -54
  197. package/dist/views/Edit/Default/index.d.ts.map +1 -1
  198. package/dist/views/Edit/Default/index.js +45 -73
  199. package/dist/views/Edit/Default/index.js.map +1 -1
  200. package/dist/views/Edit/Default/index.scss +15 -13
  201. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -1
  202. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +9 -11
  203. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
  204. package/dist/views/ForgotPassword/index.d.ts.map +1 -1
  205. package/dist/views/ForgotPassword/index.js +10 -8
  206. package/dist/views/ForgotPassword/index.js.map +1 -1
  207. package/dist/views/List/Default/index.scss +136 -134
  208. package/dist/views/List/index.d.ts.map +1 -1
  209. package/dist/views/List/index.js +1 -1
  210. package/dist/views/List/index.js.map +1 -1
  211. package/dist/views/LivePreview/IFrame/index.scss +8 -6
  212. package/dist/views/LivePreview/Preview/index.scss +32 -30
  213. package/dist/views/LivePreview/Toolbar/Controls/index.scss +49 -47
  214. package/dist/views/LivePreview/Toolbar/SizeInput/index.scss +11 -9
  215. package/dist/views/LivePreview/Toolbar/index.scss +33 -31
  216. package/dist/views/LivePreview/ToolbarArea/index.scss +5 -3
  217. package/dist/views/LivePreview/index.client.d.ts.map +1 -1
  218. package/dist/views/LivePreview/index.client.js +221 -203
  219. package/dist/views/LivePreview/index.client.js.map +1 -1
  220. package/dist/views/LivePreview/index.scss +48 -46
  221. package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
  222. package/dist/views/Login/LoginForm/index.js +2 -1
  223. package/dist/views/Login/LoginForm/index.js.map +1 -1
  224. package/dist/views/Login/LoginForm/index.scss +8 -6
  225. package/dist/views/Login/index.scss +8 -6
  226. package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
  227. package/dist/views/Logout/LogoutClient.js +77 -55
  228. package/dist/views/Logout/LogoutClient.js.map +1 -1
  229. package/dist/views/Logout/index.scss +17 -15
  230. package/dist/views/NotFound/index.d.ts +5 -5
  231. package/dist/views/NotFound/index.d.ts.map +1 -1
  232. package/dist/views/NotFound/index.js +7 -2
  233. package/dist/views/NotFound/index.js.map +1 -1
  234. package/dist/views/NotFound/index.scss +38 -36
  235. package/dist/views/ResetPassword/ResetPasswordForm/index.d.ts +7 -0
  236. package/dist/views/ResetPassword/ResetPasswordForm/index.d.ts.map +1 -0
  237. package/dist/views/ResetPassword/{index.client.js → ResetPasswordForm/index.js} +16 -19
  238. package/dist/views/ResetPassword/ResetPasswordForm/index.js.map +1 -0
  239. package/dist/views/ResetPassword/index.d.ts.map +1 -1
  240. package/dist/views/ResetPassword/index.js +19 -10
  241. package/dist/views/ResetPassword/index.js.map +1 -1
  242. package/dist/views/ResetPassword/index.scss +6 -26
  243. package/dist/views/Root/getViewFromConfig.d.ts.map +1 -1
  244. package/dist/views/Root/getViewFromConfig.js +1 -7
  245. package/dist/views/Root/getViewFromConfig.js.map +1 -1
  246. package/dist/views/Root/index.d.ts +5 -5
  247. package/dist/views/Root/index.d.ts.map +1 -1
  248. package/dist/views/Root/index.js +23 -10
  249. package/dist/views/Root/index.js.map +1 -1
  250. package/dist/views/Root/meta.d.ts +5 -5
  251. package/dist/views/Root/meta.d.ts.map +1 -1
  252. package/dist/views/Root/meta.js +3 -2
  253. package/dist/views/Root/meta.js.map +1 -1
  254. package/dist/views/Unauthorized/index.d.ts.map +1 -1
  255. package/dist/views/Unauthorized/index.js +14 -7
  256. package/dist/views/Unauthorized/index.js.map +1 -1
  257. package/dist/views/Unauthorized/index.scss +4 -31
  258. package/dist/views/Verify/index.client.d.ts +7 -0
  259. package/dist/views/Verify/index.client.d.ts.map +1 -0
  260. package/dist/views/Verify/index.client.js +46 -0
  261. package/dist/views/Verify/index.client.js.map +1 -0
  262. package/dist/views/Verify/index.d.ts.map +1 -1
  263. package/dist/views/Verify/index.js +12 -11
  264. package/dist/views/Verify/index.js.map +1 -1
  265. package/dist/views/Verify/index.scss +13 -11
  266. package/dist/views/Version/Default/index.scss +52 -50
  267. package/dist/views/Version/RenderFieldsToDiff/Label/index.scss +5 -3
  268. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.scss +29 -27
  269. package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.scss +11 -9
  270. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.scss +12 -10
  271. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.scss +12 -10
  272. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.scss +12 -10
  273. package/dist/views/Version/RenderFieldsToDiff/index.scss +12 -10
  274. package/dist/views/Version/Restore/index.d.ts.map +1 -1
  275. package/dist/views/Version/Restore/index.js +8 -14
  276. package/dist/views/Version/Restore/index.js.map +1 -1
  277. package/dist/views/Version/Restore/index.scss +57 -55
  278. package/dist/views/Version/SelectComparison/index.scss +12 -10
  279. package/dist/views/Version/SelectLocales/index.scss +6 -4
  280. package/dist/views/Version/index.d.ts.map +1 -1
  281. package/dist/views/Version/index.js +2 -0
  282. package/dist/views/Version/index.js.map +1 -1
  283. package/dist/views/Versions/cells/CreatedAt/index.js +1 -0
  284. package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
  285. package/dist/views/Versions/getLatestVersion.d.ts +1 -0
  286. package/dist/views/Versions/getLatestVersion.d.ts.map +1 -1
  287. package/dist/views/Versions/getLatestVersion.js +15 -4
  288. package/dist/views/Versions/getLatestVersion.js.map +1 -1
  289. package/dist/views/Versions/index.d.ts.map +1 -1
  290. package/dist/views/Versions/index.js +4 -4
  291. package/dist/views/Versions/index.js.map +1 -1
  292. package/dist/views/Versions/index.scss +78 -76
  293. package/dist/withPayload.d.ts.map +1 -1
  294. package/dist/withPayload.js +9 -1
  295. package/dist/withPayload.js.map +1 -1
  296. package/package.json +10 -10
  297. package/dist/cjs/withPayload.js +0 -111
  298. package/dist/cjs/withPayload.js.map +0 -1
  299. package/dist/views/ResetPassword/index.client.d.ts +0 -7
  300. package/dist/views/ResetPassword/index.client.d.ts.map +0 -1
  301. package/dist/views/ResetPassword/index.client.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,SAAS,CAAA;AAsDjF,eAAO,MAAM,UAAU,WAAkB,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,iBAyBlF,CAAA;AAED,eAAO,MAAM,IAAI,WACN,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBAyD9E,CAAA"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,SAAS,CAAA;AAmEjF,eAAO,MAAM,UAAU,WAAkB,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,iBAyBlF,CAAA;AAED,eAAO,MAAM,IAAI,WACN,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBAsD9E,CAAA"}
@@ -6,33 +6,42 @@ import { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest
6
6
  import { createPayloadRequest } from '../../utilities/createPayloadRequest.js';
7
7
  import { headersWithCors } from '../../utilities/headersWithCors.js';
8
8
  import { mergeHeaders } from '../../utilities/mergeHeaders.js';
9
- const handleError = async (payload, err, debug, afterErrorHook) => {
9
+ const handleError = async ({
10
+ err,
11
+ payload,
12
+ req
13
+ }) => {
10
14
  const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR;
11
15
  let errorMessage = err.message;
12
16
  payload.logger.error(err.stack);
13
17
  // Internal server errors can contain anything, including potentially sensitive data.
14
18
  // Therefore, error details will be hidden from the response unless `config.debug` is `true`
15
- if (!debug && status === httpStatus.INTERNAL_SERVER_ERROR) {
19
+ if (!payload.config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {
16
20
  errorMessage = 'Something went wrong.';
17
21
  }
18
22
  let response = {
19
23
  extensions: {
20
24
  name: err?.originalError?.name || undefined,
21
25
  data: err && err.originalError && err.originalError.data || undefined,
22
- stack: debug ? err.stack : undefined,
26
+ stack: payload.config.debug ? err.stack : undefined,
23
27
  statusCode: status
24
28
  },
25
29
  locations: err.locations,
26
30
  message: errorMessage,
27
31
  path: err.path
28
32
  };
29
- if (afterErrorHook) {
30
- ({
31
- response
32
- } = afterErrorHook(err, response, null, null) || {
33
- response
33
+ await payload.config.hooks.afterError?.reduce(async (promise, hook) => {
34
+ await promise;
35
+ const result = await hook({
36
+ context: req.context,
37
+ error: err,
38
+ graphqlResult: response,
39
+ req
34
40
  });
35
- }
41
+ if (result) {
42
+ response = result.graphqlResult || response;
43
+ }
44
+ }, Promise.resolve());
36
45
  return response;
37
46
  };
38
47
  let cached = global._payload_graphql;
@@ -82,7 +91,6 @@ export const POST = config => async request => {
82
91
  const {
83
92
  payload
84
93
  } = req;
85
- const afterErrorHook = typeof payload.config.hooks.afterError === 'function' ? payload.config.hooks.afterError : null;
86
94
  const headers = {};
87
95
  const apiResponse = await createHandler({
88
96
  context: {
@@ -97,7 +105,11 @@ export const POST = config => async request => {
97
105
  }) : result;
98
106
  if (response.errors) {
99
107
  const errors = await Promise.all(result.errors.map(error => {
100
- return handleError(payload, error, payload.config.debug, afterErrorHook);
108
+ return handleError({
109
+ err: error,
110
+ payload,
111
+ req
112
+ });
101
113
  }));
102
114
  // errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult
103
115
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","names":["configToSchema","createHandler","httpStatus","addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequest","headersWithCors","mergeHeaders","handleError","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","req","validationRules","hooks","afterError","headers","apiResponse","context","onOperation","args","result","errors","all","map","_","defaultRules","concat","resHeaders","Headers","key","append","Response","body","responseHeaders"],"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLError, GraphQLFormattedError } from 'graphql'\nimport type { CollectionAfterErrorHook, Payload, SanitizedConfig } from 'payload'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport httpStatus from 'http-status'\n\nimport { addDataAndFileToRequest } from '../../utilities/addDataAndFileToRequest.js'\nimport { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest.js'\nimport { createPayloadRequest } from '../../utilities/createPayloadRequest.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { mergeHeaders } from '../../utilities/mergeHeaders.js'\n\nconst handleError = async (\n 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 cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\nexport const POST =\n (config: Promise<SanitizedConfig> | SanitizedConfig) => async (request: Request) => {\n const originalRequest = request.clone()\n const req = await createPayloadRequest({\n config,\n request,\n })\n\n await addDataAndFileToRequest(req)\n addLocalesToRequestFromData(req)\n\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = req\n\n const 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: (_, args, defaultRules) => defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req,\n })\n\n for (const key in headers) {\n resHeaders.append(key, headers[key])\n }\n\n return new Response(apiResponse.body, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, resHeaders) : resHeaders,\n status: apiResponse.status,\n })\n }\n"],"mappings":"AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAC9B,OAAOC,UAAA,MAAgB;AAEvB,SAASC,uBAAuB,QAAQ;AACxC,SAASC,2BAA2B,QAAQ;AAC5C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAE7B,MAAMC,WAAA,GAAc,MAAAA,CAClBC,OAAA,EACAC,GAAA,EACAC,KAAA,EACAC,cAAA;EAGA,MAAMC,MAAA,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,EAAMC,MAAA;MACjC,MAAMpC,QAAA,GACJ,OAAOZ,OAAA,CAAQa,UAAU,KAAK,aAC1B,MAAMb,OAAA,CAAQa,UAAU,CAAC;QACvBkC,IAAA;QACAR,GAAA,EAAKH,OAAA;QACLY;MACF,KACAA,MAAA;MACN,IAAIpC,QAAA,CAASqC,MAAM,EAAE;QACnB,MAAMA,MAAA,GAAU,MAAMlB,OAAA,CAAQmB,GAAG,CAC/BF,MAAA,CAAOC,MAAM,CAACE,GAAG,CAAEzC,KAAA;UACjB,OAAOX,WAAA,CAAYC,OAAA,EAASU,KAAA,EAAOV,OAAA,CAAQ0B,MAAM,CAACxB,KAAK,EAAEC,cAAA;QAC3D;QAEF;QACA,OAAO;UAAE,GAAGS,QAAQ;UAAEqC;QAAO;MAC/B;MACA,OAAOrC,QAAA;IACT;IACAqB,MAAA;IACAO,eAAA,EAAiBA,CAACY,CAAA,EAAGL,IAAA,EAAMM,YAAA,KAAiBA,YAAA,CAAaC,MAAM,CAACd,eAAA,CAAgBO,IAAA;EAClF,GAAGV,eAAA;EAEH,MAAMkB,UAAA,GAAa1D,eAAA,CAAgB;IACjC8C,OAAA,EAAS,IAAIa,OAAA,CAAQZ,WAAA,CAAYD,OAAO;IACxCJ;EACF;EAEA,KAAK,MAAMkB,GAAA,IAAOd,OAAA,EAAS;IACzBY,UAAA,CAAWG,MAAM,CAACD,GAAA,EAAKd,OAAO,CAACc,GAAA,CAAI;EACrC;EAEA,OAAO,IAAIE,QAAA,CAASf,WAAA,CAAYgB,IAAI,EAAE;IACpCjB,OAAA,EAASJ,GAAA,CAAIsB,eAAe,GAAG/D,YAAA,CAAayC,GAAA,CAAIsB,eAAe,EAAEN,UAAA,IAAcA,UAAA;IAC/EnD,MAAA,EAAQwC,WAAA,CAAYxC;EACtB;AACF","ignoreList":[]}
1
+ {"version":3,"file":"handler.js","names":["configToSchema","createHandler","httpStatus","addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequest","headersWithCors","mergeHeaders","handleError","err","payload","req","status","originalError","INTERNAL_SERVER_ERROR","errorMessage","message","logger","error","stack","config","debug","response","extensions","name","undefined","data","statusCode","locations","path","hooks","afterError","reduce","promise","hook","result","context","graphqlResult","Promise","resolve","cached","global","_payload_graphql","graphql","getGraphql","process","env","NODE_ENV","resolvedConfig","schema","e","POST","request","originalRequest","clone","validationRules","headers","apiResponse","onOperation","args","errors","all","map","_","defaultRules","concat","resHeaders","Headers","key","append","Response","body","responseHeaders"],"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLError, GraphQLFormattedError } from 'graphql'\nimport type { APIError, Payload, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport httpStatus from 'http-status'\n\nimport { addDataAndFileToRequest } from '../../utilities/addDataAndFileToRequest.js'\nimport { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest.js'\nimport { createPayloadRequest } from '../../utilities/createPayloadRequest.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { mergeHeaders } from '../../utilities/mergeHeaders.js'\n\nconst handleError = async ({\n err,\n payload,\n req,\n}: {\n err: GraphQLError\n payload: Payload\n req: PayloadRequest\n}): Promise<GraphQLFormattedError> => {\n const status = (err.originalError as APIError).status || httpStatus.INTERNAL_SERVER_ERROR\n let errorMessage = err.message\n payload.logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!payload.config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: GraphQLFormattedError = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && (err.originalError as APIError).data) || undefined,\n stack: payload.config.debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n await payload.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n context: req.context,\n error: err,\n graphqlResult: response,\n req,\n })\n\n if (result) {\n response = result.graphqlResult || response\n }\n }, Promise.resolve())\n\n return response\n}\n\nlet cached = global._payload_graphql\n\nif (!cached) {\n cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\nexport const POST =\n (config: Promise<SanitizedConfig> | SanitizedConfig) => async (request: Request) => {\n const originalRequest = request.clone()\n const req = await createPayloadRequest({\n config,\n request,\n })\n\n await addDataAndFileToRequest(req)\n addLocalesToRequestFromData(req)\n\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = req\n\n const headers = {}\n const apiResponse = await createHandler({\n context: { headers, req },\n onOperation: async (request, args, result) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: request,\n result,\n })\n : result\n if (response.errors) {\n const errors = (await Promise.all(\n result.errors.map((error) => {\n return handleError({ err: error, payload, req })\n }),\n )) as GraphQLError[]\n // errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (_, args, defaultRules) => defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req,\n })\n\n for (const key in headers) {\n resHeaders.append(key, headers[key])\n }\n\n return new Response(apiResponse.body, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, resHeaders) : resHeaders,\n status: apiRes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CAAQV,WAAA,CAAYD,OAAO;IACxC7C;EACF;EAEA,KAAK,MAAMyD,GAAA,IAAOZ,OAAA,EAAS;IACzBU,UAAA,CAAWG,MAAM,CAACD,GAAA,EAAKZ,OAAO,CAACY,GAAA,CAAI;EACrC;EAEA,OAAO,IAAIE,QAAA,CAASb,WAAA,CAAYc,IAAI,EAAE;IACpCf,OAAA,EAAS7C,GAAA,CAAI6D,eAAe,GAAGjE,YAAA,CAAaI,GAAA,CAAI6D,eAAe,EAAEN,UAAA,IAAcA,UAAA;IAC/EtD,MAAA,EAAQ6C,WAAA,CAAY7C;EACtB;AACF","ignoreList":[]}
@@ -26,8 +26,8 @@ export const login = async ({
26
26
  req
27
27
  });
28
28
  const cookie = generatePayloadCookie({
29
- collectionConfig: collection.config,
30
- payload: req.payload,
29
+ collectionAuthConfig: collection.config.auth,
30
+ cookiePrefix: req.payload.config.cookiePrefix,
31
31
  token: result.token
32
32
  });
33
33
  if (collection.config.auth.removeTokenFromResponses) {
@@ -1 +1 @@
1
- {"version":3,"file":"login.js","names":["httpStatus","generatePayloadCookie","loginOperation","isNumber","headersWithCors","login","collection","req","searchParams","t","depth","get","authData","config","auth","loginWithUsername","email","data","password","username","result","Number","undefined","cookie","collectionConfig","payload","token","removeTokenFromResponses","Response","json","message","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/auth/login.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie, loginOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\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 const authData =\n collection.config.auth?.loginWithUsername !== false\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n }\n\n const result = await loginOperation({\n collection,\n data: authData,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n 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"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,qBAAqB,EAAEC,cAAc,QAAQ;AACtD,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,KAAA,GAAgC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACrE,MAAM;IAAEC,YAAY;IAAEC;EAAC,CAAE,GAAGF,GAAA;EAC5B,MAAMG,KAAA,GAAQF,YAAA,CAAaG,GAAG,CAAC;EAC/B,MAAMC,QAAA,GACJN,UAAA,CAAWO,MAAM,CAACC,IAAI,EAAEC,iBAAA,KAAsB,QAC1C;IACEC,KAAA,EAAO,OAAOT,GAAA,CAAIU,IAAI,EAAED,KAAA,KAAU,WAAWT,GAAA,CAAIU,IAAI,CAACD,KAAK,GAAG;IAC9DE,QAAA,EAAU,OAAOX,GAAA,CAAIU,IAAI,EAAEC,QAAA,KAAa,WAAWX,GAAA,CAAIU,IAAI,CAACC,QAAQ,GAAG;IACvEC,QAAA,EAAU,OAAOZ,GAAA,CAAIU,IAAI,EAAEE,QAAA,KAAa,WAAWZ,GAAA,CAAIU,IAAI,CAACE,QAAQ,GAAG;EACzE,IACA;IACEH,KAAA,EAAO,OAAOT,GAAA,CAAIU,IAAI,EAAED,KAAA,KAAU,WAAWT,GAAA,CAAIU,IAAI,CAACD,KAAK,GAAG;IAC9DE,QAAA,EAAU,OAAOX,GAAA,CAAIU,IAAI,EAAEC,QAAA,KAAa,WAAWX,GAAA,CAAIU,IAAI,CAACC,QAAQ,GAAG;EACzE;EAEN,MAAME,MAAA,GAAS,MAAMlB,cAAA,CAAe;IAClCI,UAAA;IACAW,IAAA,EAAML,QAAA;IACNF,KAAA,EAAOP,QAAA,CAASO,KAAA,IAASW,MAAA,CAAOX,KAAA,IAASY,SAAA;IACzCf;EACF;EAEA,MAAMgB,MAAA,GAAStB,qBAAA,CAAsB;IACnCuB,gBAAA,EAAkBlB,UAAA,CAAWO,MAAM;IACnCY,OAAA,EAASlB,GAAA,CAAIkB,OAAO;IACpBC,KAAA,EAAON,MAAA,CAAOM;EAChB;EAEA,IAAIpB,UAAA,CAAWO,MAAM,CAACC,IAAI,CAACa,wBAAwB,EAAE;IACnD,OAAOP,MAAA,CAAOM,KAAK;EACrB;EAEA,OAAOE,QAAA,CAASC,IAAI,CAClB;IACEC,OAAA,EAASrB,CAAA,CAAE;IACX,GAAGW;EACL,GACA;IACEW,OAAA,EAAS3B,eAAA,CAAgB;MACvB2B,OAAA,EAAS,IAAIC,OAAA,CAAQ;QACnB,cAAcT;MAChB;MACAhB;IACF;IACA0B,MAAA,EAAQjC,UAAA,CAAWkC;EACrB;AAEJ","ignoreList":[]}
1
+ {"version":3,"file":"login.js","names":["httpStatus","generatePayloadCookie","loginOperation","isNumber","headersWithCors","login","collection","req","searchParams","t","depth","get","authData","config","auth","loginWithUsername","email","data","password","username","result","Number","undefined","cookie","collectionAuthConfig","cookiePrefix","payload","token","removeTokenFromResponses","Response","json","message","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/auth/login.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie, loginOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\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 const authData =\n collection.config.auth?.loginWithUsername !== false\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n }\n\n const result = await loginOperation({\n collection,\n data: authData,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n message: t('authentication:passed'),\n ...result,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,qBAAqB,EAAEC,cAAc,QAAQ;AACtD,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,KAAA,GAAgC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACrE,MAAM;IAAEC,YAAY;IAAEC;EAAC,CAAE,GAAGF,GAAA;EAC5B,MAAMG,KAAA,GAAQF,YAAA,CAAaG,GAAG,CAAC;EAC/B,MAAMC,QAAA,GACJN,UAAA,CAAWO,MAAM,CAACC,IAAI,EAAEC,iBAAA,KAAsB,QAC1C;IACEC,KAAA,EAAO,OAAOT,GAAA,CAAIU,IAAI,EAAED,KAAA,KAAU,WAAWT,GAAA,CAAIU,IAAI,CAACD,KAAK,GAAG;IAC9DE,QAAA,EAAU,OAAOX,GAAA,CAAIU,IAAI,EAAEC,QAAA,KAAa,WAAWX,GAAA,CAAIU,IAAI,CAACC,QAAQ,GAAG;IACvEC,QAAA,EAAU,OAAOZ,GAAA,CAAIU,IAAI,EAAEE,QAAA,KAAa,WAAWZ,GAAA,CAAIU,IAAI,CAACE,QAAQ,GAAG;EACzE,IACA;IACEH,KAAA,EAAO,OAAOT,GAAA,CAAIU,IAAI,EAAED,KAAA,KAAU,WAAWT,GAAA,CAAIU,IAAI,CAACD,KAAK,GAAG;IAC9DE,QAAA,EAAU,OAAOX,GAAA,CAAIU,IAAI,EAAEC,QAAA,KAAa,WAAWX,GAAA,CAAIU,IAAI,CAACC,QAAQ,GAAG;EACzE;EAEN,MAAME,MAAA,GAAS,MAAMlB,cAAA,CAAe;IAClCI,UAAA;IACAW,IAAA,EAAML,QAAA;IACNF,KAAA,EAAOP,QAAA,CAASO,KAAA,IAASW,MAAA,CAAOX,KAAA,IAASY,SAAA;IACzCf;EACF;EAEA,MAAMgB,MAAA,GAAStB,qBAAA,CAAsB;IACnCuB,oBAAA,EAAsBlB,UAAA,CAAWO,MAAM,CAACC,IAAI;IAC5CW,YAAA,EAAclB,GAAA,CAAImB,OAAO,CAACb,MAAM,CAACY,YAAY;IAC7CE,KAAA,EAAOP,MAAA,CAAOO;EAChB;EAEA,IAAIrB,UAAA,CAAWO,MAAM,CAACC,IAAI,CAACc,wBAAwB,EAAE;IACnD,OAAOR,MAAA,CAAOO,KAAK;EACrB;EAEA,OAAOE,QAAA,CAASC,IAAI,CAClB;IACEC,OAAA,EAAStB,CAAA,CAAE;IACX,GAAGW;EACL,GACA;IACEY,OAAA,EAAS5B,eAAA,CAAgB;MACvB4B,OAAA,EAAS,IAAIC,OAAA,CAAQ;QACnB,cAAcV;MAChB;MACAhB;IACF;IACA2B,MAAA,EAAQlC,UAAA,CAAWmC;EACrB;AAEJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/logout.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBAwCpB,CAAA"}
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/logout.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBAyCpB,CAAA"}
@@ -25,8 +25,9 @@ export const logout = async ({
25
25
  });
26
26
  }
27
27
  const expiredCookie = generateExpiredPayloadCookie({
28
- collectionConfig: collection.config,
29
- payload: req.payload
28
+ collectionAuthConfig: collection.config.auth,
29
+ config: req.payload.config,
30
+ cookiePrefix: req.payload.config.cookiePrefix
30
31
  });
31
32
  headers.set('Set-Cookie', expiredCookie);
32
33
  return Response.json({
@@ -1 +1 @@
1
- {"version":3,"file":"logout.js","names":["httpStatus","generateExpiredPayloadCookie","logoutOperation","headersWithCors","logout","collection","req","t","result","headers","Headers","Response","json","message","status","BAD_REQUEST","expiredCookie","collectionConfig","config","payload","set","OK"],"sources":["../../../../src/routes/rest/auth/logout.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generateExpiredPayloadCookie, logoutOperation } from 'payload'\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"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,4BAA4B,EAAEC,eAAe,QAAQ;AAI9D,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,MAAA,GAAiC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACtE,MAAM;IAAEC;EAAC,CAAE,GAAGD,GAAA;EACd,MAAME,MAAA,GAAS,MAAMN,eAAA,CAAgB;IACnCG,UAAA;IACAC;EACF;EAEA,MAAMG,OAAA,GAAUN,eAAA,CAAgB;IAC9BM,OAAA,EAAS,IAAIC,OAAA;IACbJ;EACF;EAEA,IAAI,CAACE,MAAA,EAAQ;IACX,OAAOG,QAAA,CAASC,IAAI,CAClB;MACEC,OAAA,EAASN,CAAA,CAAE;IACb,GACA;MACEE,OAAA;MACAK,MAAA,EAAQd,UAAA,CAAWe;IACrB;EAEJ;EAEA,MAAMC,aAAA,GAAgBf,4BAAA,CAA6B;IACjDgB,gBAAA,EAAkBZ,UAAA,CAAWa,MAAM;IACnCC,OAAA,EAASb,GAAA,CAAIa;EACf;EAEAV,OAAA,CAAQW,GAAG,CAAC,cAAcJ,aAAA;EAE1B,OAAOL,QAAA,CAASC,IAAI,CAClB;IACEC,OAAA,EAASN,CAAA,CAAE;EACb,GACA;IACEE,OAAA;IACAK,MAAA,EAAQd,UAAA,CAAWqB;EACrB;AAEJ","ignoreList":[]}
1
+ {"version":3,"file":"logout.js","names":["httpStatus","generateExpiredPayloadCookie","logoutOperation","headersWithCors","logout","collection","req","t","result","headers","Headers","Response","json","message","status","BAD_REQUEST","expiredCookie","collectionAuthConfig","config","auth","payload","cookiePrefix","set","OK"],"sources":["../../../../src/routes/rest/auth/logout.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generateExpiredPayloadCookie, logoutOperation } from 'payload'\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 collectionAuthConfig: collection.config.auth,\n config: req.payload.config,\n cookiePrefix: req.payload.config.cookiePrefix,\n })\n\n headers.set('Set-Cookie', expiredCookie)\n\n return Response.json(\n {\n message: t('authentication:logoutSuccessful'),\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,4BAA4B,EAAEC,eAAe,QAAQ;AAI9D,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,MAAA,GAAiC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACtE,MAAM;IAAEC;EAAC,CAAE,GAAGD,GAAA;EACd,MAAME,MAAA,GAAS,MAAMN,eAAA,CAAgB;IACnCG,UAAA;IACAC;EACF;EAEA,MAAMG,OAAA,GAAUN,eAAA,CAAgB;IAC9BM,OAAA,EAAS,IAAIC,OAAA;IACbJ;EACF;EAEA,IAAI,CAACE,MAAA,EAAQ;IACX,OAAOG,QAAA,CAASC,IAAI,CAClB;MACEC,OAAA,EAASN,CAAA,CAAE;IACb,GACA;MACEE,OAAA;MACAK,MAAA,EAAQd,UAAA,CAAWe;IACrB;EAEJ;EAEA,MAAMC,aAAA,GAAgBf,4BAAA,CAA6B;IACjDgB,oBAAA,EAAsBZ,UAAA,CAAWa,MAAM,CAACC,IAAI;IAC5CD,MAAA,EAAQZ,GAAA,CAAIc,OAAO,CAACF,MAAM;IAC1BG,YAAA,EAAcf,GAAA,CAAIc,OAAO,CAACF,MAAM,CAACG;EACnC;EAEAZ,OAAA,CAAQa,GAAG,CAAC,cAAcN,aAAA;EAE1B,OAAOL,QAAA,CAASC,IAAI,CAClB;IACEC,OAAA,EAASN,CAAA,CAAE;EACb,GACA;IACEE,OAAA;IACAK,MAAA,EAAQd,UAAA,CAAWuB;EACrB;AAEJ","ignoreList":[]}
@@ -18,8 +18,8 @@ export const refresh = async ({
18
18
  });
19
19
  if (result.setCookie) {
20
20
  const cookie = generatePayloadCookie({
21
- collectionConfig: collection.config,
22
- payload: req.payload,
21
+ collectionAuthConfig: collection.config.auth,
22
+ cookiePrefix: req.payload.config.cookiePrefix,
23
23
  token: result.refreshedToken
24
24
  });
25
25
  if (collection.config.auth.removeTokenFromResponses) {
@@ -1 +1 @@
1
- {"version":3,"file":"refresh.js","names":["httpStatus","generatePayloadCookie","refreshOperation","headersWithCors","refresh","collection","req","t","headers","Headers","result","setCookie","cookie","collectionConfig","config","payload","token","refreshedToken","auth","removeTokenFromResponses","set","Response","json","message","status","OK"],"sources":["../../../../src/routes/rest/auth/refresh.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie, refreshOperation } from 'payload'\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\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n const result = await refreshOperation({\n collection,\n req,\n })\n\n if (result.setCookie) {\n const cookie = generatePayloadCookie({\n 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\n return Response.json(\n {\n message: t('authentication:tokenRefreshSuccessful'),\n ...result,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,qBAAqB,EAAEC,gBAAgB,QAAQ;AAIxD,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,OAAA,GAAkC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACvE,MAAM;IAAEC;EAAC,CAAE,GAAGD,GAAA;EAEd,MAAME,OAAA,GAAUL,eAAA,CAAgB;IAC9BK,OAAA,EAAS,IAAIC,OAAA;IACbH;EACF;EAEA,MAAMI,MAAA,GAAS,MAAMR,gBAAA,CAAiB;IACpCG,UAAA;IACAC;EACF;EAEA,IAAII,MAAA,CAAOC,SAAS,EAAE;IACpB,MAAMC,MAAA,GAASX,qBAAA,CAAsB;MACnCY,gBAAA,EAAkBR,UAAA,CAAWS,MAAM;MACnCC,OAAA,EAAST,GAAA,CAAIS,OAAO;MACpBC,KAAA,EAAON,MAAA,CAAOO;IAChB;IAEA,IAAIZ,UAAA,CAAWS,MAAM,CAACI,IAAI,CAACC,wBAAwB,EAAE;MACnD,OAAOT,MAAA,CAAOO,cAAc;IAC9B;IAEAT,OAAA,CAAQY,GAAG,CAAC,cAAcR,MAAA;EAC5B;EAEA,OAAOS,QAAA,CAASC,IAAI,CAClB;IACEC,OAAA,EAAShB,CAAA,CAAE;IACX,GAAGG;EACL,GACA;IACEF,OAAA;IACAgB,MAAA,EAAQxB,UAAA,CAAWyB;EACrB;AAEJ","ignoreList":[]}
1
+ {"version":3,"file":"refresh.js","names":["httpStatus","generatePayloadCookie","refreshOperation","headersWithCors","refresh","collection","req","t","headers","Headers","result","setCookie","cookie","collectionAuthConfig","config","auth","cookiePrefix","payload","token","refreshedToken","removeTokenFromResponses","set","Response","json","message","status","OK"],"sources":["../../../../src/routes/rest/auth/refresh.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie, refreshOperation } from 'payload'\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\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n const result = await refreshOperation({\n collection,\n req,\n })\n\n if (result.setCookie) {\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\n token: result.refreshedToken,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.refreshedToken\n }\n\n headers.set('Set-Cookie', cookie)\n }\n\n return Response.json(\n {\n message: t('authentication:tokenRefreshSuccessful'),\n ...result,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,qBAAqB,EAAEC,gBAAgB,QAAQ;AAIxD,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,OAAA,GAAkC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACvE,MAAM;IAAEC;EAAC,CAAE,GAAGD,GAAA;EAEd,MAAME,OAAA,GAAUL,eAAA,CAAgB;IAC9BK,OAAA,EAAS,IAAIC,OAAA;IACbH;EACF;EAEA,MAAMI,MAAA,GAAS,MAAMR,gBAAA,CAAiB;IACpCG,UAAA;IACAC;EACF;EAEA,IAAII,MAAA,CAAOC,SAAS,EAAE;IACpB,MAAMC,MAAA,GAASX,qBAAA,CAAsB;MACnCY,oBAAA,EAAsBR,UAAA,CAAWS,MAAM,CAACC,IAAI;MAC5CC,YAAA,EAAcV,GAAA,CAAIW,OAAO,CAACH,MAAM,CAACE,YAAY;MAC7CE,KAAA,EAAOR,MAAA,CAAOS;IAChB;IAEA,IAAId,UAAA,CAAWS,MAAM,CAACC,IAAI,CAACK,wBAAwB,EAAE;MACnD,OAAOV,MAAA,CAAOS,cAAc;IAC9B;IAEAX,OAAA,CAAQa,GAAG,CAAC,cAAcT,MAAA;EAC5B;EAEA,OAAOU,QAAA,CAASC,IAAI,CAClB;IACEC,OAAA,EAASjB,CAAA,CAAE;IACX,GAAGG;EACL,GACA;IACEF,OAAA;IACAiB,MAAA,EAAQzB,UAAA,CAAW0B;EACrB;AAEJ","ignoreList":[]}
@@ -26,8 +26,8 @@ export const registerFirstUser = async ({
26
26
  req
27
27
  });
28
28
  const cookie = generatePayloadCookie({
29
- collectionConfig: collection.config,
30
- payload: req.payload,
29
+ collectionAuthConfig: collection.config.auth,
30
+ cookiePrefix: req.payload.config.cookiePrefix,
31
31
  token: result.token
32
32
  });
33
33
  return Response.json({
@@ -1 +1 @@
1
- {"version":3,"file":"registerFirstUser.js","names":["httpStatus","generatePayloadCookie","registerFirstUserOperation","headersWithCors","registerFirstUser","collection","req","data","t","authData","config","auth","loginWithUsername","email","password","username","result","cookie","collectionConfig","payload","token","Response","json","exp","message","user","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie, registerFirstUserOperation } from 'payload'\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 const authData = collection.config.auth?.loginWithUsername\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n }\n\n const result = await registerFirstUserOperation({\n collection,\n data: {\n ...data,\n ...authData,\n },\n req,\n })\n\n const cookie = generatePayloadCookie({\n 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"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ;AAIlE,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,iBAAA,GAA4C,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE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AA,EAAS,IAAIC,OAAA,CAAQ;QACnB,cAAcV;MAChB;MACAX;IACF;IACAsB,MAAA,EAAQ5B,UAAA,CAAW6B;EACrB;AAEJ","ignoreList":[]}
1
+ {"version":3,"file":"registerFirstUser.js","names":["httpStatus","generatePayloadCookie","registerFirstUserOperation","headersWithCors","registerFirstUser","collection","req","data","t","authData","config","auth","loginWithUsername","email","password","username","result","cookie","collectionAuthConfig","cookiePrefix","payload","token","Response","json","exp","message","user","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie, registerFirstUserOperation } from 'payload'\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 const authData = collection.config.auth?.loginWithUsername\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n }\n\n const result = await registerFirstUserOperation({\n collection,\n data: {\n ...data,\n ...authData,\n },\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\n token: result.token,\n })\n\n return Response.json(\n {\n exp: result.exp,\n message: t('authentication:successfullyRegisteredFirstUser'),\n token: result.token,\n user: result.user,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ;AAIlE,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,iBAAA,GAA4C,MAAAA,CAAO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AAMV,MAAA,CAAOU;EACf,GACA;IACEC,OAAA,EAASxB,eAAA,CAAgB;MACvBwB,OAAA,EAAS,IAAIC,OAAA,CAAQ;QACnB,cAAcX;MAChB;MACAX;IACF;IACAuB,MAAA,EAAQ7B,UAAA,CAAW8B;EACrB;AAEJ","ignoreList":[]}
@@ -20,8 +20,8 @@ export const resetPassword = async ({
20
20
  req
21
21
  });
22
22
  const cookie = generatePayloadCookie({
23
- collectionConfig: collection.config,
24
- payload: req.payload,
23
+ collectionAuthConfig: collection.config.auth,
24
+ cookiePrefix: req.payload.config.cookiePrefix,
25
25
  token: result.token
26
26
  });
27
27
  if (collection.config.auth.removeTokenFromResponses) {
@@ -1 +1 @@
1
- {"version":3,"file":"resetPassword.js","names":["httpStatus","generatePayloadCookie","resetPasswordOperation","headersWithCors","resetPassword","collection","req","searchParams","t","depth","get","result","data","password","token","Number","undefined","cookie","collectionConfig","config","payload","auth","removeTokenFromResponses","Response","json","message","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/auth/resetPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie, resetPasswordOperation } from 'payload'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const resetPassword: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n\n const result = await resetPasswordOperation({\n collection,\n data: {\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n token: typeof req.data?.token === 'string' ? req.data.token : '',\n },\n depth: depth ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n message: t('authentication:passwordResetSuccessfully'),\n ...result,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus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file":"resetPassword.js","names":["httpStatus","generatePayloadCookie","resetPasswordOperation","headersWithCors","resetPassword","collection","req","searchParams","t","depth","get","result","data","password","token","Number","undefined","cookie","collectionAuthConfig","config","auth","cookiePrefix","payload","removeTokenFromResponses","Response","json","message","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/auth/resetPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { generatePayloadCookie, resetPasswordOperation } from 'payload'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const resetPassword: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n\n const result = await resetPasswordOperation({\n collection,\n data: {\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n token: typeof req.data?.token === 'string' ? req.data.token : '',\n },\n depth: depth ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n message: t('authentication:passwordResetSuccessfully'),\n ...result,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,qBAAqB,EAAEC,sBAAsB,QAAQ;AAI9D,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,aAAA,GAAwC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EAC7E,MAAM;IAAEC,YAAY;IAAEC;EAAC,CAAE,GAAGF,GAAA;EAC5B,MAAMG,KAAA,GAAQF,YAAA,CAAaG,GAAG,CAAC;EAE/B,MAAMC,MAAA,GAAS,MAAMT,sBAAA,CAAuB;IAC1CG,UAAA;IACAO,IAAA,EAAM;MACJC,QAAA,EAAU,OAAOP,GAAA,CAAIM,IAAI,EAAEC,QAAA,KAAa,WAAWP,GAAA,CAAIM,IAAI,CAACC,QAAQ,GAAG;MACvEC,KAAA,EAAO,OAAOR,GAAA,CAAIM,IAAI,EAAEE,KAAA,KAAU,WAAWR,GAAA,CAAIM,IAAI,CAACE,KAAK,GAAG;IAChE;IACAL,KAAA,EAAOA,KAAA,GAAQM,MAAA,CAAON,KAAA,IAASO,SAAA;IAC/BV;EACF;EAEA,MAAMW,MAAA,GAAShB,qBAAA,CAAsB;IACnCiB,oBAAA,EAAsBb,UAAA,CAAWc,MAAM,CAACC,IAAI;IAC5CC,YAAA,EAAcf,GAAA,CAAIgB,OAAO,CAACH,MAAM,CAACE,YAAY;IAC7CP,KAAA,EAAOH,MAAA,CAAOG;EAChB;EAEA,IAAIT,UAAA,CAAWc,MAAM,CAACC,IAAI,CAACG,wBAAwB,EAAE;IACnD,OAAOZ,MAAA,CAAOG,KAAK;EACrB;EAEA,OAAOU,QAAA,CAASC,IAAI,CAClB;IACEC,OAAA,EAASlB,CAAA,CAAE;IACX,GAAGG;EACL,GACA;IACEgB,OAAA,EAASxB,eAAA,CAAgB;MACvBwB,OAAA,EAAS,IAAIC,OAAA,CAAQ;QACnB,cAAcX;MAChB;MACAX;IACF;IACAuB,MAAA,EAAQ7B,UAAA,CAAW8B;EACrB;AAEJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBA8BpB,CAAA"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAMzD,eAAO,MAAM,MAAM,EAAE,sBAgCpB,CAAA"}
@@ -3,6 +3,8 @@ import httpStatus from 'http-status';
3
3
  import { createOperation } from 'payload';
4
4
  import { isNumber } from 'payload/shared';
5
5
  import { headersWithCors } from '../../../utilities/headersWithCors.js';
6
+ import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
7
+ import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
6
8
  export const create = async ({
7
9
  collection,
8
10
  req
@@ -19,7 +21,9 @@ export const create = async ({
19
21
  data: req.data,
20
22
  depth: isNumber(depth) ? depth : undefined,
21
23
  draft,
22
- req
24
+ populate: sanitizePopulate(req.query.populate),
25
+ req,
26
+ select: sanitizeSelect(req.query.select)
23
27
  });
24
28
  return Response.json({
25
29
  doc,
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","names":["getTranslation","httpStatus","createOperation","isNumber","headersWithCors","create","collection","req","searchParams","autosave","get","draft","depth","doc","data","undefined","Response","json","message","t","label","config","labels","singular","i18n","headers","Headers","status","CREATED"],"sources":["../../../../src/routes/rest/collections/create.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { createOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const create: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams } = req\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n const depth = searchParams.get('depth')\n\n const doc = await createOperation({\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? depth : undefined,\n draft,\n req,\n })\n\n return Response.json(\n {\n doc,\n message: req.t('general:successfullyCreated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n }),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.CREATED,\n },\n )\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,MAAA,GAAiC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACtE,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,QAAA,GAAWD,YAAA,CAAaE,GAAG,CAAC,gBAAgB;EAClD,MAAMC,KAAA,GAAQH,YAAA,CAAaE,GAAG,CAAC,aAAa;EAC5C,MAAME,KAAA,GAAQJ,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMG,GAAA,GAAM,MAAMX,eAAA,CAAgB;IAChCO,QAAA;IACAH,UAAA;IACAQ,IAAA,EAAMP,GAAA,CAAIO,IAAI;IACdF,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASA,KAAA,GAAQG,SAAA;IACjCJ,KAAA;IACAJ;EACF;EAEA,OAAOS,QAAA,CAASC,IAAI,CAClB;IACEJ,GAAA;IACAK,OAAA,EAASX,GAAA,CAAIY,CAAC,CAAC,+BAA+B;MAC5CC,KAAA,EAAOpB,cAAA,CAAeM,UAAA,CAAWe,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEhB,GAAA,CAAIiB,IAAI;IACnE;EACF,GACA;IACEC,OAAA,EAASrB,eAAA,CAAgB;MACvBqB,OAAA,EAAS,IAAIC,OAAA;MACbnB;IACF;IACAoB,MAAA,EAAQ1B,UAAA,CAAW2B;EACrB;AAEJ","ignoreList":[]}
1
+ {"version":3,"file":"create.js","names":["getTranslation","httpStatus","createOperation","isNumber","headersWithCors","sanitizePopulate","sanitizeSelect","create","collection","req","searchParams","autosave","get","draft","depth","doc","data","undefined","populate","query","select","Response","json","message","t","label","config","labels","singular","i18n","headers","Headers","status","CREATED"],"sources":["../../../../src/routes/rest/collections/create.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { createOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.js'\n\nexport const create: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams } = req\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n const depth = searchParams.get('depth')\n\n const doc = await createOperation({\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? depth : undefined,\n draft,\n populate: sanitizePopulate(req.query.populate),\n req,\n select: sanitizeSelect(req.query.select),\n })\n\n return Response.json(\n {\n doc,\n message: req.t('general:successfullyCreated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n }),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.CREATED,\n },\n )\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,MAAA,GAAiC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACtE,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,QAAA,GAAWD,YAAA,CAAaE,GAAG,CAAC,gBAAgB;EAClD,MAAMC,KAAA,GAAQH,YAAA,CAAaE,GAAG,CAAC,aAAa;EAC5C,MAAME,KAAA,GAAQJ,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMG,GAAA,GAAM,MAAMb,eAAA,CAAgB;IAChCS,QAAA;IACAH,UAAA;IACAQ,IAAA,EAAMP,GAAA,CAAIO,IAAI;IACdF,KAAA,EAAOX,QAAA,CAASW,KAAA,IAASA,KAAA,GAAQG,SAAA;IACjCJ,KAAA;IACAK,QAAA,EAAUb,gBAAA,CAAiBI,GAAA,CAAIU,KAAK,CAACD,QAAQ;IAC7CT,GAAA;IACAW,MAAA,EAAQd,cAAA,CAAeG,GAAA,CAAIU,KAAK,CAACC,MAAM;EACzC;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEP,GAAA;IACAQ,OAAA,EAASd,GAAA,CAAIe,CAAC,CAAC,+BAA+B;MAC5CC,KAAA,EAAOzB,cAAA,CAAeQ,UAAA,CAAWkB,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEnB,GAAA,CAAIoB,IAAI;IACnE;EACF,GACA;IACEC,OAAA,EAAS1B,eAAA,CAAgB;MACvB0B,OAAA,EAAS,IAAIC,OAAA;MACbtB;IACF;IACAuB,MAAA,EAAQ/B,UAAA,CAAWgC;EACrB;AAEJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/delete.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,SAAS,EAAE,sBAyDvB,CAAA"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/delete.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAMzD,eAAO,MAAM,SAAS,EAAE,sBA+DvB,CAAA"}
@@ -3,18 +3,26 @@ import httpStatus from 'http-status';
3
3
  import { deleteOperation } from 'payload';
4
4
  import { isNumber } from 'payload/shared';
5
5
  import { headersWithCors } from '../../../utilities/headersWithCors.js';
6
+ import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
7
+ import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
6
8
  export const deleteDoc = async ({
7
9
  collection,
8
10
  req
9
11
  }) => {
10
12
  const {
11
13
  depth,
14
+ overrideLock,
15
+ populate,
16
+ select,
12
17
  where
13
18
  } = req.query;
14
19
  const result = await deleteOperation({
15
20
  collection,
16
21
  depth: isNumber(depth) ? Number(depth) : undefined,
22
+ overrideLock: Boolean(overrideLock === 'true'),
23
+ populate: sanitizePopulate(populate),
17
24
  req,
25
+ select: sanitizeSelect(select),
18
26
  where
19
27
  });
20
28
  const headers = headersWithCors({
@@ -1 +1 @@
1
- {"version":3,"file":"delete.js","names":["getTranslation","httpStatus","deleteOperation","isNumber","headersWithCors","deleteDoc","collection","req","depth","where","query","result","Number","undefined","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"sources":["../../../../src/routes/rest/collections/delete.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { deleteOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const deleteDoc: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, where } = req.query as {\n depth?: string\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:deletedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n\n const message = req.t('error:unableToDeleteCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"mappings":"AAEA,SAASA,cAAc,QA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iB,MAAM,CAACC,MAAM,CAACM,KAAA,GAAQ,IAAI,WAAW,WAAW,EAAEvB,GAAA,CAAIkB,IAAI;IAC3FK;EACF;EAEA,OAAOJ,QAAA,CAASC,IAAI,CAClB;IACE,GAAGhB,MAAM;IACTO;EACF,GACA;IACEJ,OAAA;IACAc,MAAA,EAAQ3B,UAAA,CAAW8B;EACrB;AAEJ","ignoreList":[]}
1
+ {"version":3,"file":"delete.js","names":["getTranslation","httpStatus","deleteOperation","isNumber","headersWithCors","sanitizePopulate","sanitizeSelect","deleteDoc","collection","req","depth","overrideLock","populate","select","where","query","result","Number","undefined","Boolean","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"sources":["../../../../src/routes/rest/collections/delete.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { deleteOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.js'\n\nexport const deleteDoc: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, overrideLock, populate, select, where } = req.query as {\n depth?: string\n overrideLock?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulate(populate),\n req,\n select: sanitizeSelect(select),\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:deletedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n\n const message = req.t('error:unableToDeleteCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,SAAA,GAAoC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACzE,MAAM;IAAEC,KAAK;IAAEC,YAAY;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EAAK,CAAE,GAAGL,GAAA,CAAIM,KAAK;EAQlE,MAAMC,MAAA,GAAS,MAAMd,eAAA,CAAgB;IACnCM,UAAA;IACAE,KAAA,EAAOP,QAAA,CAASO,KAAA,IAASO,MAAA,CAAOP,KAAA,IAASQ,SAAA;IACzCP,YAAA,EAAcQ,OAAA,CAAQR,YAAA,KAAiB;IACvCC,QAAA,EAAUP,gBAAA,CAAiBO,QAAA;IAC3BH,GAAA;IACAI,MAAA,EAAQP,cAAA,CAAeO,MAAA;IACvBC;EACF;EAEA,MAAMM,OAAA,GAAUhB,eAAA,CAAgB;IAC9BgB,OAAA,EAAS,IAAIC,OAAA;IACbZ;EACF;EAEA,IAAIO,MAAA,CAAOM,MAAM,CAACC,MAAM,KAAK,GAAG;IAC9B,MAAMC,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC,oCAAoC;MACxDC,KAAA,EAAOV,MAAA,CAAOW,IAAI,CAACJ,MAAM;MACzBK,KAAA,EAAO5B,cAAA,CACLQ,UAAA,CAAWqB,MAAM,CAACC,MAAM,CAACd,MAAA,CAAOW,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxEd,GAAA,CAAIsB,IAAI;IAEZ;IAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;MACE,GAAGjB,MAAM;MACTQ;IACF,GACA;MACEJ,OAAA;MACAc,MAAA,EAAQjC,UAAA,CAAWkC;IACrB;EAEJ;EAEA,MAAMC,KAAA,GAAQpB,MAAA,CAAOW,IAAI,CAACJ,MAAM,GAAGP,MAAA,CAAOM,MAAM,CAACC,MAAM;EAEvD,MAAMC,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC,6BAA6B;IACjDC,KAAA,EAAOV,MAAA,CAAOM,MAAM,CAACC,MAAM;IAC3BK,KAAA,EAAO5B,cAAA,CAAeQ,UAAA,CAAWqB,MAAM,CAACC,MAAM,CAACM,KAAA,GAAQ,IAAI,WAAW,WAAW,EAAE3B,GAAA,CAAIsB,IAAI;IAC3FK;EACF;EAEA,OAAOJ,QAAA,CAASC,IAAI,CAClB;IACE,GAAGjB,MAAM;IACTQ;EACF,GACA;IACEJ,OAAA;IACAc,MAAA,EAAQjC,UAAA,CAAWoC;EACrB;AAEJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"deleteByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,UAAU,EAAE,4BAgDxB,CAAA"}
1
+ {"version":3,"file":"deleteByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAO/D,eAAO,MAAM,UAAU,EAAE,4BAoDxB,CAAA"}
@@ -3,6 +3,8 @@ import { deleteByIDOperation } from 'payload';
3
3
  import { isNumber } from 'payload/shared';
4
4
  import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
5
  import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
6
+ import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
7
+ import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
6
8
  export const deleteByID = async ({
7
9
  id: incomingID,
8
10
  collection,
@@ -12,6 +14,7 @@ export const deleteByID = async ({
12
14
  searchParams
13
15
  } = req;
14
16
  const depth = searchParams.get('depth');
17
+ const overrideLock = searchParams.get('overrideLock');
15
18
  const id = sanitizeCollectionID({
16
19
  id: incomingID,
17
20
  collectionSlug: collection.config.slug,
@@ -21,7 +24,10 @@ export const deleteByID = async ({
21
24
  id,
22
25
  collection,
23
26
  depth: isNumber(depth) ? depth : undefined,
24
- req
27
+ overrideLock: Boolean(overrideLock === 'true'),
28
+ populate: sanitizePopulate(req.query.populate),
29
+ req,
30
+ select: sanitizeSelect(req.query.select)
25
31
  });
26
32
  const headers = headersWithCors({
27
33
  headers: new Headers(),
@@ -1 +1 @@
1
- {"version":3,"file":"deleteByID.js","names":["httpStatus","deleteByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","deleteByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","doc","undefined","headers","Headers","Response","json","message","t","status","NOT_FOUND","OK"],"sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { deleteByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const deleteByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await deleteByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? depth : undefined,\n req,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (!doc) {\n return Response.json(\n {\n message: req.t('general:notFound'),\n },\n {\n headers,\n status: httpStatus.NOT_FOUND,\n },\n )\n }\n\n return Response.json(\n {\n doc,\n message: req.t('general:deletedSuccessfully'),\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,mBAAmB,QAAQ;AACpC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,UAAA,GAA2C,MAAAA,CAAO;EAC7DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMN,EAAA,GAAKF,oBAAA,CAAqB;IAC9BE,EAAA,EAAIC,UAAA;IACJM,cAAA,EAAgBL,UAAA,CAAWM,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASP,GAAA,CAAIO;EACf;EAEA,MAAMC,GAAA,GAAM,MAAMhB,mBAAA,CAAoB;IACpCK,EAAA;IACAE,UAAA;IACAG,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASA,KAAA,GAAQO,SAAA;IACjCT;EACF;EAEA,MAAMU,OAAA,GAAUhB,eAAA,CAAgB;IAC9BgB,OAAA,EAAS,IAAIC,OAAA;IACbX;EACF;EAEA,IAAI,CAACQ,GAAA,EAAK;IACR,OAAOI,QAAA,CAASC,IAAI,CAClB;MACEC,OAAA,EAASd,GAAA,CAAIe,CAAC,CAAC;IACjB,GACA;MACEL,OAAA;MACAM,MAAA,EAAQzB,UAAA,CAAW0B;IACrB;EAEJ;EAEA,OAAOL,QAAA,CAASC,IAAI,CAClB;IACEL,GAAA;IACAM,OAAA,EAASd,GAAA,CAAIe,CAAC,CAAC;EACjB,GACA;IACEL,OAAA;IACAM,MAAA,EAAQzB,UAAA,CAAW2B;EACrB;AAEJ","ignoreList":[]}
1
+ {"version":3,"file":"deleteByID.js","names":["httpStatus","deleteByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizePopulate","sanitizeSelect","deleteByID","id","incomingID","collection","req","searchParams","depth","get","overrideLock","collectionSlug","config","slug","payload","doc","undefined","Boolean","populate","query","select","headers","Headers","Response","json","message","t","status","NOT_FOUND","OK"],"sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { deleteByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.js'\n\nexport const deleteByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const overrideLock = searchParams.get('overrideLock')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await deleteByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? depth : undefined,\n overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulate(req.query.populate),\n req,\n select: sanitizeSelect(req.query.select),\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (!doc) {\n return Response.json(\n {\n message: req.t('general:notFound'),\n },\n {\n headers,\n status: httpStatus.NOT_FOUND,\n },\n )\n }\n\n return Response.json(\n {\n doc,\n message: req.t('general:deletedSuccessfully'),\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,U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AClB;IACET,GAAA;IACAU,OAAA,EAASnB,GAAA,CAAIoB,CAAC,CAAC;EACjB,GACA;IACEL,OAAA;IACAM,MAAA,EAAQhC,UAAA,CAAWkC;EACrB;AAEJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/duplicate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,SAAS,EAAE,4BAyCvB,CAAA"}
1
+ {"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/duplicate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAO/D,eAAO,MAAM,SAAS,EAAE,4BA2CvB,CAAA"}
@@ -4,6 +4,8 @@ import { duplicateOperation } from 'payload';
4
4
  import { isNumber } from 'payload/shared';
5
5
  import { headersWithCors } from '../../../utilities/headersWithCors.js';
6
6
  import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
7
+ import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
8
+ import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
7
9
  export const duplicate = async ({
8
10
  id: incomingID,
9
11
  collection,
@@ -25,7 +27,9 @@ export const duplicate = async ({
25
27
  collection,
26
28
  depth: isNumber(depth) ? Number(depth) : undefined,
27
29
  draft,
28
- req
30
+ populate: sanitizePopulate(req.query.populate),
31
+ req,
32
+ select: sanitizeSelect(req.query.select)
29
33
  });
30
34
  const message = req.t('general:successfullyDuplicated', {
31
35
  label: getTranslation(collection.config.labels.singular, req.i18n)
@@ -1 +1 @@
1
- {"version":3,"file":"duplicate.js","names":["getTranslation","httpStatus","duplicateOperation","isNumber","headersWithCors","sanitizeCollectionID","duplicate","id","incomingID","collection","req","searchParams","depth","get","draft","collectionSlug","config","slug","payload","doc","Number","undefined","message","t","label","labels","singular","i18n","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/duplicate.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { duplicateOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const duplicate: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n // draft defaults to true, unless explicitly set requested as false to prevent the newly duplicated document from being published\n const draft = searchParams.get('draft') !== 'false'\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await duplicateOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n req,\n })\n\n const message = req.t('general:successfullyDuplicated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n })\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,kBAAkB,QAAQ;AACnC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,SAAA,GAA0C,MAAAA,CAAO;EAC5DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B;EACA,MAAMC,KAAA,GAAQH,YAAA,CAAaE,GAAG,CAAC,aAAa;EAE5C,MAAMN,EAAA,GAAKF,oBAAA,CAAqB;IAC9BE,EAAA,EAAIC,UAAA;IACJO,cAAA,EAAgBN,UAAA,CAAWO,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASR,GAAA,CAAIQ;EACf;EAEA,MAAMC,GAAA,GAAM,MAAMjB,kBAAA,CAAmB;IACnCK,EAAA;IACAE,UAAA;IACAG,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCP,KAAA;IACAJ;EACF;EAEA,MAAMY,OAAA,GAAUZ,GAAA,CAAIa,CAAC,CAAC,kCAAkC;IACtDC,KAAA,EAAOxB,cAAA,CAAeS,UAAA,CAAWO,MAAM,CAACS,MAAM,CAACC,QAAQ,EAAEhB,GAAA,CAAIiB,IAAI;EACnE;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEV,GAAA;IACAG;EACF,GACA;IACEQ,OAAA,EAAS1B,eAAA,CAAgB;MACvB0B,OAAA,EAAS,IAAIC,OAAA;MACbrB;IACF;IACAsB,MAAA,EAAQ/B,UAAA,CAAWgC;EACrB;AAEJ","ignoreList":[]}
1
+ {"version":3,"file":"duplicate.js","names":["getTranslation","httpStatus","duplicateOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizePopulate","sanitizeSelect","duplicate","id","incomingID","collection","req","searchParams","depth","get","draft","collectionSlug","config","slug","payload","doc","Number","undefined","populate","query","select","message","t","label","labels","singular","i18n","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/duplicate.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { duplicateOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.js'\n\nexport const duplicate: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n // draft defaults to true, unless explicitly set requested as false to prevent the newly duplicated document from being published\n const draft = searchParams.get('draft') !== 'false'\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await duplicateOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n populate: sanitizePopulate(req.query.populate),\n req,\n select: sanitizeSelect(req.query.select),\n })\n\n const message = req.t('general:successfullyDuplicated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n })\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,kBAAkB,QAAQ;AACnC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,SAAA,GAA0C,MAAAA,CAAO;EAC5DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B;EACA,MAAMC,KAAA,GAAQH,YAAA,CAAaE,GAAG,CAAC,aAAa;EAE5C,MAAMN,EAAA,GAAKJ,oBAAA,CAAqB;IAC9BI,EAAA,EAAIC,UAAA;IACJO,cAAA,EAAgBN,UAAA,CAAWO,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASR,GAAA,CAAIQ;EACf;EAEA,MAAMC,GAAA,GAAM,MAAMnB,kBAAA,CAAmB;IACnCO,EAAA;IACAE,UAAA;IACAG,KAAA,EAAOX,QAAA,CAASW,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCP,KAAA;IACAQ,QAAA,EAAUlB,gBAAA,CAAiBM,GAAA,CAAIa,KAAK,CAACD,QAAQ;IAC7CZ,GAAA;IACAc,MAAA,EAAQnB,cAAA,CAAeK,GAAA,CAAIa,KAAK,CAACC,MAAM;EACzC;EAEA,MAAMC,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC,kCAAkC;IACtDC,KAAA,EAAO7B,cAAA,CAAeW,UAAA,CAAWO,MAAM,CAACY,MAAM,CAACC,QAAQ,EAAEnB,GAAA,CAAIoB,IAAI;EACnE;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEb,GAAA;IACAM;EACF,GACA;IACEQ,OAAA,EAAS/B,eAAA,CAAgB;MACvB+B,OAAA,EAAS,IAAIC,OAAA;MACbxB;IACF;IACAyB,MAAA,EAAQpC,UAAA,CAAWqC;EACrB;AAEJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/find.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAKzD,eAAO,MAAM,IAAI,EAAE,sBA8BlB,CAAA"}
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/find.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAOzD,eAAO,MAAM,IAAI,EAAE,sBAkClB,CAAA"}
@@ -3,6 +3,8 @@ import { findOperation } from 'payload';
3
3
  import { isNumber } from 'payload/shared';
4
4
  import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
5
  import { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js';
6
+ import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
7
+ import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
6
8
  export const find = async ({
7
9
  collection,
8
10
  req
@@ -13,6 +15,8 @@ export const find = async ({
13
15
  joins,
14
16
  limit,
15
17
  page,
18
+ populate,
19
+ select,
16
20
  sort,
17
21
  where
18
22
  } = req.query;
@@ -23,8 +27,10 @@ export const find = async ({
23
27
  joins: sanitizeJoinParams(joins),
24
28
  limit: isNumber(limit) ? Number(limit) : undefined,
25
29
  page: isNumber(page) ? Number(page) : undefined,
30
+ populate: sanitizePopulate(populate),
26
31
  req,
27
- sort,
32
+ select: sanitizeSelect(select),
33
+ sort: typeof sort === 'string' ? sort.split(',') : undefined,
28
34
  where
29
35
  });
30
36
  return Response.json(result, {
@@ -1 +1 @@
1
- {"version":3,"file":"find.js","names":["httpStatus","findOperation","isNumber","headersWithCors","sanitizeJoinParams","find","collection","req","depth","draft","joins","limit","page","sort","where","query","result","Number","undefined","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/find.ts"],"sourcesContent":["import type { JoinQuery, Where } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { findOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js'\n\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, joins, limit, page, sort, where } = req.query as {\n depth?: string\n draft?: string\n joins?: JoinQuery\n limit?: string\n page?: string\n sort?: string\n where?: Where\n }\n\n const result = await findOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n joins: sanitizeJoinParams(joins),\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n req,\n sort,\n where,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AACvB,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,IAAA,GAA+B,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACpE,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,IAAI;IAAEC,IAAI;IAAEC;EAAK,CAAE,GAAGP,GAAA,CAAIQ,KAAK;EAUnE,MAAMC,MAAA,GAAS,MAAMf,aAAA,CAAc;IACjCK,UAAA;IACAE,KAAA,EAAON,QAAA,CAASM,KAAA,IAASS,MAAA,CAAOT,KAAA,IAASU,SAAA;IACzCT,KAAA,EAAOA,KAAA,KAAU;IACjBC,KAAA,EAAON,kBAAA,CAAmBM,KAAA;IAC1BC,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASM,MAAA,CAAON,KAAA,IAASO,SAAA;IACzCN,IAAA,EAAMV,QAAA,CAASU,IAAA,IAAQK,MAAA,CAAOL,IAAA,IAAQM,SAAA;IACtCX,GAAA;IACAM,IAAA;IACAC;EACF;EAEA,OAAOK,QAAA,CAASC,IAAI,CAACJ,MAAA,EAAQ;IAC3BK,OAAA,EAASlB,eAAA,CAAgB;MACvBkB,OAAA,EAAS,IAAIC,OAAA;MACbf;IACF;IACAgB,MAAA,EAAQvB,UAAA,CAAWwB;EACrB;AACF","ignoreList":[]}
1
+ {"version":3,"file":"find.js","names":["httpStatus","findOperation","isNumber","headersWithCors","sanitizeJoinParams","sanitizePopulate","sanitizeSelect","find","collection","req","depth","draft","joins","limit","page","populate","select","sort","where","query","result","Number","undefined","split","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/find.ts"],"sourcesContent":["import type { JoinQuery, Where } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { findOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.js'\n\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, joins, limit, page, populate, select, sort, where } = req.query as {\n depth?: string\n draft?: string\n joins?: JoinQuery\n limit?: string\n page?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n sort?: string\n where?: Where\n }\n\n const result = await findOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n joins: sanitizeJoinParams(joins),\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n populate: sanitizePopulate(populate),\n req,\n select: sanitizeSelect(select),\n sort: typeof sort === 'string' ? sort.split(',') : undefined,\n where,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AACvB,SAASC,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,IAAA,GAA+B,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACpE,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,IAAI;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAK,CAAE,GAAGT,GAAA,CAAIU,KAAK;EAYrF,MAAMC,MAAA,GAAS,MAAMnB,aAAA,CAAc;IACjCO,UAAA;IACAE,KAAA,EAAOR,QAAA,CAASQ,KAAA,IAASW,MAAA,CAAOX,KAAA,IAASY,SAAA;IACzCX,KAAA,EAAOA,KAAA,KAAU;IACjBC,KAAA,EAAOR,kBAAA,CAAmBQ,KAAA;IAC1BC,KAAA,EAAOX,QAAA,CAASW,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCR,IAAA,EAAMZ,QAAA,CAASY,IAAA,IAAQO,MAAA,CAAOP,IAAA,IAAQQ,SAAA;IACtCP,QAAA,EAAUV,gBAAA,CAAiBU,QAAA;IAC3BN,GAAA;IACAO,MAAA,EAAQV,cAAA,CAAeU,MAAA;IACvBC,IAAA,EAAM,OAAOA,IAAA,KAAS,WAAWA,IAAA,CAAKM,KAAK,CAAC,OAAOD,SAAA;IACnDJ;EACF;EAEA,OAAOM,QAAA,CAASC,IAAI,CAACL,MAAA,EAAQ;IAC3BM,OAAA,EAASvB,eAAA,CAAgB;MACvBuB,OAAA,EAAS,IAAIC,OAAA;MACblB;IACF;IACAmB,MAAA,EAAQ5B,UAAA,CAAW6B;EACrB;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAM/D,eAAO,MAAM,QAAQ,EAAE,4BA8BtB,CAAA"}
1
+ {"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAQ/D,eAAO,MAAM,QAAQ,EAAE,4BAgCtB,CAAA"}
@@ -4,6 +4,8 @@ import { isNumber } from 'payload/shared';
4
4
  import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
5
  import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
6
6
  import { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js';
7
+ import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
8
+ import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
7
9
  export const findByID = async ({
8
10
  id: incomingID,
9
11
  collection,
@@ -24,7 +26,9 @@ export const findByID = async ({
24
26
  depth: isNumber(depth) ? Number(depth) : undefined,
25
27
  draft: searchParams.get('draft') === 'true',
26
28
  joins: sanitizeJoinParams(req.query.joins),
27
- req
29
+ populate: sanitizePopulate(req.query.populate),
30
+ req,
31
+ select: sanitizeSelect(req.query.select)
28
32
  });
29
33
  return Response.json(result, {
30
34
  headers: headersWithCors({