@payloadcms/next 3.0.0-canary.294ea5c → 3.0.0-canary.2d0dd26

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 (615) hide show
  1. package/dist/cjs/withPayload.cjs +166 -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.d.ts +1 -1
  7. package/dist/elements/DocumentHeader/Tabs/Tab/index.d.ts.map +1 -1
  8. package/dist/elements/DocumentHeader/Tabs/Tab/index.js +16 -18
  9. package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
  10. package/dist/elements/DocumentHeader/Tabs/Tab/index.scss +70 -68
  11. package/dist/elements/DocumentHeader/Tabs/index.d.ts +2 -2
  12. package/dist/elements/DocumentHeader/Tabs/index.d.ts.map +1 -1
  13. package/dist/elements/DocumentHeader/Tabs/index.js +18 -17
  14. package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
  15. package/dist/elements/DocumentHeader/Tabs/index.scss +41 -39
  16. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.d.ts.map +1 -1
  17. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js +16 -27
  18. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js.map +1 -1
  19. package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts +1 -1
  20. package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts.map +1 -1
  21. package/dist/elements/DocumentHeader/Tabs/tabs/index.js +3 -3
  22. package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +1 -1
  23. package/dist/elements/DocumentHeader/index.d.ts +2 -3
  24. package/dist/elements/DocumentHeader/index.d.ts.map +1 -1
  25. package/dist/elements/DocumentHeader/index.js +9 -12
  26. package/dist/elements/DocumentHeader/index.js.map +1 -1
  27. package/dist/elements/DocumentHeader/index.scss +44 -42
  28. package/dist/elements/FormHeader/index.d.ts +9 -0
  29. package/dist/elements/FormHeader/index.d.ts.map +1 -0
  30. package/dist/elements/FormHeader/index.js +20 -0
  31. package/dist/elements/FormHeader/index.js.map +1 -0
  32. package/dist/elements/FormHeader/index.scss +8 -0
  33. package/dist/elements/Logo/index.d.ts.map +1 -1
  34. package/dist/elements/Logo/index.js +5 -6
  35. package/dist/elements/Logo/index.js.map +1 -1
  36. package/dist/elements/Nav/NavWrapper/index.scss +21 -14
  37. package/dist/elements/Nav/getNavPrefs.d.ts +6 -0
  38. package/dist/elements/Nav/getNavPrefs.d.ts.map +1 -0
  39. package/dist/elements/Nav/getNavPrefs.js +26 -0
  40. package/dist/elements/Nav/getNavPrefs.js.map +1 -0
  41. package/dist/elements/Nav/index.client.d.ts +6 -1
  42. package/dist/elements/Nav/index.client.d.ts.map +1 -1
  43. package/dist/elements/Nav/index.client.js +45 -95
  44. package/dist/elements/Nav/index.client.js.map +1 -1
  45. package/dist/elements/Nav/index.d.ts.map +1 -1
  46. package/dist/elements/Nav/index.js +66 -23
  47. package/dist/elements/Nav/index.js.map +1 -1
  48. package/dist/elements/Nav/index.scss +127 -121
  49. package/dist/exports/layouts.d.ts +2 -1
  50. package/dist/exports/layouts.d.ts.map +1 -1
  51. package/dist/exports/layouts.js +2 -1
  52. package/dist/exports/layouts.js.map +1 -1
  53. package/dist/exports/routes.d.ts +1 -1
  54. package/dist/exports/routes.d.ts.map +1 -1
  55. package/dist/exports/routes.js +1 -1
  56. package/dist/exports/routes.js.map +1 -1
  57. package/dist/exports/utilities.d.ts +2 -1
  58. package/dist/exports/utilities.d.ts.map +1 -1
  59. package/dist/exports/utilities.js +3 -1
  60. package/dist/exports/utilities.js.map +1 -1
  61. package/dist/exports/views.d.ts +1 -3
  62. package/dist/exports/views.d.ts.map +1 -1
  63. package/dist/exports/views.js +1 -3
  64. package/dist/exports/views.js.map +1 -1
  65. package/dist/fetchAPI-multipart/fileFactory.d.ts +2 -1
  66. package/dist/fetchAPI-multipart/fileFactory.d.ts.map +1 -1
  67. package/dist/fetchAPI-multipart/fileFactory.js.map +1 -1
  68. package/dist/fetchAPI-multipart/handlers.d.ts +1 -1
  69. package/dist/fetchAPI-multipart/handlers.d.ts.map +1 -1
  70. package/dist/fetchAPI-multipart/handlers.js +3 -1
  71. package/dist/fetchAPI-multipart/handlers.js.map +1 -1
  72. package/dist/fetchAPI-multipart/index.d.ts +1 -101
  73. package/dist/fetchAPI-multipart/index.d.ts.map +1 -1
  74. package/dist/fetchAPI-multipart/index.js +1 -1
  75. package/dist/fetchAPI-multipart/index.js.map +1 -1
  76. package/dist/fetchAPI-multipart/isEligibleRequest.js +1 -1
  77. package/dist/fetchAPI-multipart/isEligibleRequest.js.map +1 -1
  78. package/dist/fetchAPI-multipart/processMultipart.d.ts +2 -1
  79. package/dist/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
  80. package/dist/fetchAPI-multipart/processMultipart.js +9 -10
  81. package/dist/fetchAPI-multipart/processMultipart.js.map +1 -1
  82. package/dist/fetchAPI-multipart/processNested.d.ts.map +1 -1
  83. package/dist/fetchAPI-multipart/processNested.js +8 -4
  84. package/dist/fetchAPI-multipart/processNested.js.map +1 -1
  85. package/dist/fetchAPI-multipart/uploadTimer.d.ts.map +1 -1
  86. package/dist/fetchAPI-multipart/uploadTimer.js +3 -1
  87. package/dist/fetchAPI-multipart/uploadTimer.js.map +1 -1
  88. package/dist/fetchAPI-multipart/utilities.d.ts +1 -1
  89. package/dist/fetchAPI-multipart/utilities.d.ts.map +1 -1
  90. package/dist/fetchAPI-multipart/utilities.js +32 -12
  91. package/dist/fetchAPI-multipart/utilities.js.map +1 -1
  92. package/dist/layouts/Root/NestProviders.d.ts +11 -0
  93. package/dist/layouts/Root/NestProviders.d.ts.map +1 -0
  94. package/dist/layouts/Root/NestProviders.js +21 -0
  95. package/dist/layouts/Root/NestProviders.js.map +1 -0
  96. package/dist/layouts/Root/checkDependencies.d.ts +2 -0
  97. package/dist/layouts/Root/checkDependencies.d.ts.map +1 -0
  98. package/dist/layouts/Root/checkDependencies.js +49 -0
  99. package/dist/layouts/Root/checkDependencies.js.map +1 -0
  100. package/dist/layouts/Root/index.d.ts +4 -3
  101. package/dist/layouts/Root/index.d.ts.map +1 -1
  102. package/dist/layouts/Root/index.js +42 -71
  103. package/dist/layouts/Root/index.js.map +1 -1
  104. package/dist/prod/styles.css +1 -1
  105. package/dist/routes/graphql/handler.d.ts.map +1 -1
  106. package/dist/routes/graphql/handler.js +23 -11
  107. package/dist/routes/graphql/handler.js.map +1 -1
  108. package/dist/routes/rest/auth/login.js +2 -2
  109. package/dist/routes/rest/auth/login.js.map +1 -1
  110. package/dist/routes/rest/auth/logout.d.ts.map +1 -1
  111. package/dist/routes/rest/auth/logout.js +3 -2
  112. package/dist/routes/rest/auth/logout.js.map +1 -1
  113. package/dist/routes/rest/auth/refresh.js +2 -2
  114. package/dist/routes/rest/auth/refresh.js.map +1 -1
  115. package/dist/routes/rest/auth/registerFirstUser.js +2 -2
  116. package/dist/routes/rest/auth/registerFirstUser.js.map +1 -1
  117. package/dist/routes/rest/auth/resetPassword.js +2 -2
  118. package/dist/routes/rest/auth/resetPassword.js.map +1 -1
  119. package/dist/routes/rest/collections/create.d.ts.map +1 -1
  120. package/dist/routes/rest/collections/create.js +5 -1
  121. package/dist/routes/rest/collections/create.js.map +1 -1
  122. package/dist/routes/rest/collections/delete.d.ts.map +1 -1
  123. package/dist/routes/rest/collections/delete.js +8 -0
  124. package/dist/routes/rest/collections/delete.js.map +1 -1
  125. package/dist/routes/rest/collections/deleteByID.d.ts.map +1 -1
  126. package/dist/routes/rest/collections/deleteByID.js +7 -1
  127. package/dist/routes/rest/collections/deleteByID.js.map +1 -1
  128. package/dist/routes/rest/collections/duplicate.d.ts.map +1 -1
  129. package/dist/routes/rest/collections/duplicate.js +5 -1
  130. package/dist/routes/rest/collections/duplicate.js.map +1 -1
  131. package/dist/routes/rest/collections/find.d.ts.map +1 -1
  132. package/dist/routes/rest/collections/find.js +10 -1
  133. package/dist/routes/rest/collections/find.js.map +1 -1
  134. package/dist/routes/rest/collections/findByID.d.ts.map +1 -1
  135. package/dist/routes/rest/collections/findByID.js +7 -1
  136. package/dist/routes/rest/collections/findByID.js.map +1 -1
  137. package/dist/routes/rest/collections/findVersionByID.d.ts.map +1 -1
  138. package/dist/routes/rest/collections/findVersionByID.js +5 -1
  139. package/dist/routes/rest/collections/findVersionByID.js.map +1 -1
  140. package/dist/routes/rest/collections/findVersions.d.ts.map +1 -1
  141. package/dist/routes/rest/collections/findVersions.js +7 -1
  142. package/dist/routes/rest/collections/findVersions.js.map +1 -1
  143. package/dist/routes/rest/collections/restoreVersion.d.ts.map +1 -1
  144. package/dist/routes/rest/collections/restoreVersion.js +2 -0
  145. package/dist/routes/rest/collections/restoreVersion.js.map +1 -1
  146. package/dist/routes/rest/collections/update.d.ts.map +1 -1
  147. package/dist/routes/rest/collections/update.js +10 -0
  148. package/dist/routes/rest/collections/update.js.map +1 -1
  149. package/dist/routes/rest/collections/updateByID.d.ts.map +1 -1
  150. package/dist/routes/rest/collections/updateByID.js +15 -3
  151. package/dist/routes/rest/collections/updateByID.js.map +1 -1
  152. package/dist/routes/rest/files/checkFileAccess.d.ts.map +1 -1
  153. package/dist/routes/rest/files/checkFileAccess.js +7 -2
  154. package/dist/routes/rest/files/checkFileAccess.js.map +1 -1
  155. package/dist/routes/rest/files/getFile.d.ts.map +1 -1
  156. package/dist/routes/rest/files/getFile.js +6 -2
  157. package/dist/routes/rest/files/getFile.js.map +1 -1
  158. package/dist/routes/rest/globals/findOne.d.ts.map +1 -1
  159. package/dist/routes/rest/globals/findOne.js +5 -1
  160. package/dist/routes/rest/globals/findOne.js.map +1 -1
  161. package/dist/routes/rest/globals/findVersionByID.d.ts.map +1 -1
  162. package/dist/routes/rest/globals/findVersionByID.js +5 -1
  163. package/dist/routes/rest/globals/findVersionByID.js.map +1 -1
  164. package/dist/routes/rest/globals/findVersions.d.ts.map +1 -1
  165. package/dist/routes/rest/globals/findVersions.js +7 -1
  166. package/dist/routes/rest/globals/findVersions.js.map +1 -1
  167. package/dist/routes/rest/globals/restoreVersion.d.ts.map +1 -1
  168. package/dist/routes/rest/globals/restoreVersion.js +2 -0
  169. package/dist/routes/rest/globals/restoreVersion.js.map +1 -1
  170. package/dist/routes/rest/globals/update.d.ts.map +1 -1
  171. package/dist/routes/rest/globals/update.js +13 -3
  172. package/dist/routes/rest/globals/update.js.map +1 -1
  173. package/dist/routes/rest/index.d.ts +17 -12
  174. package/dist/routes/rest/index.d.ts.map +1 -1
  175. package/dist/routes/rest/index.js +132 -39
  176. package/dist/routes/rest/index.js.map +1 -1
  177. package/dist/routes/rest/og/image.d.ts +4 -2
  178. package/dist/routes/rest/og/image.d.ts.map +1 -1
  179. package/dist/routes/rest/og/image.js +14 -10
  180. package/dist/routes/rest/og/image.js.map +1 -1
  181. package/dist/routes/rest/og/index.d.ts.map +1 -1
  182. package/dist/routes/rest/og/index.js +7 -12
  183. package/dist/routes/rest/og/index.js.map +1 -1
  184. package/dist/routes/rest/routeError.d.ts +2 -7
  185. package/dist/routes/rest/routeError.d.ts.map +1 -1
  186. package/dist/routes/rest/routeError.js +43 -69
  187. package/dist/routes/rest/routeError.js.map +1 -1
  188. package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts.map +1 -1
  189. package/dist/routes/rest/utilities/sanitizeCollectionID.js +6 -2
  190. package/dist/routes/rest/utilities/sanitizeCollectionID.js.map +1 -1
  191. package/dist/routes/rest/utilities/sanitizeJoinParams.d.ts +13 -0
  192. package/dist/routes/rest/utilities/sanitizeJoinParams.d.ts.map +1 -0
  193. package/dist/routes/rest/utilities/sanitizeJoinParams.js +21 -0
  194. package/dist/routes/rest/utilities/sanitizeJoinParams.js.map +1 -0
  195. package/dist/routes/rest/utilities/sanitizePopulate.d.ts +3 -0
  196. package/dist/routes/rest/utilities/sanitizePopulate.d.ts.map +1 -0
  197. package/dist/routes/rest/utilities/sanitizePopulate.js +11 -0
  198. package/dist/routes/rest/utilities/sanitizePopulate.js.map +1 -0
  199. package/dist/routes/rest/utilities/sanitizeSelect.d.ts +6 -0
  200. package/dist/routes/rest/utilities/sanitizeSelect.d.ts.map +1 -0
  201. package/dist/routes/rest/utilities/sanitizeSelect.js +17 -0
  202. package/dist/routes/rest/utilities/sanitizeSelect.js.map +1 -0
  203. package/dist/scss/app.scss +166 -162
  204. package/dist/scss/colors.scss +256 -254
  205. package/dist/scss/resets.scss +9 -7
  206. package/dist/scss/toastify.scss +42 -40
  207. package/dist/scss/toasts.scss +105 -103
  208. package/dist/scss/type.scss +80 -79
  209. package/dist/templates/Default/Wrapper/index.scss +37 -36
  210. package/dist/templates/Default/index.d.ts +2 -1
  211. package/dist/templates/Default/index.d.ts.map +1 -1
  212. package/dist/templates/Default/index.js +101 -31
  213. package/dist/templates/Default/index.js.map +1 -1
  214. package/dist/templates/Default/index.scss +62 -50
  215. package/dist/templates/Minimal/index.scss +22 -20
  216. package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
  217. package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
  218. package/dist/utilities/addLocalesToRequest.d.ts.map +1 -1
  219. package/dist/utilities/addLocalesToRequest.js +24 -10
  220. package/dist/utilities/addLocalesToRequest.js.map +1 -1
  221. package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
  222. package/dist/utilities/createPayloadRequest.js +21 -13
  223. package/dist/utilities/createPayloadRequest.js.map +1 -1
  224. package/dist/utilities/getClientConfig.d.ts +8 -0
  225. package/dist/utilities/getClientConfig.d.ts.map +1 -0
  226. package/dist/utilities/getClientConfig.js +16 -0
  227. package/dist/utilities/getClientConfig.js.map +1 -0
  228. package/dist/utilities/getNextRequestI18n.d.ts.map +1 -1
  229. package/dist/utilities/getNextRequestI18n.js +2 -2
  230. package/dist/utilities/getNextRequestI18n.js.map +1 -1
  231. package/dist/utilities/getPayloadHMR.d.ts +1 -2
  232. package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
  233. package/dist/utilities/getPayloadHMR.js +4 -102
  234. package/dist/utilities/getPayloadHMR.js.map +1 -1
  235. package/dist/utilities/getRequestLocales.d.ts.map +1 -1
  236. package/dist/utilities/getRequestLocales.js +10 -6
  237. package/dist/utilities/getRequestLocales.js.map +1 -1
  238. package/dist/utilities/getRequestTheme.d.ts.map +1 -1
  239. package/dist/utilities/getRequestTheme.js +3 -0
  240. package/dist/utilities/getRequestTheme.js.map +1 -1
  241. package/dist/utilities/handleServerFunctions.d.ts +3 -0
  242. package/dist/utilities/handleServerFunctions.d.ts.map +1 -0
  243. package/dist/utilities/handleServerFunctions.js +35 -0
  244. package/dist/utilities/handleServerFunctions.js.map +1 -0
  245. package/dist/utilities/headersWithCors.d.ts.map +1 -1
  246. package/dist/utilities/headersWithCors.js.map +1 -1
  247. package/dist/utilities/initPage/handleAdminPage.d.ts +13 -11
  248. package/dist/utilities/initPage/handleAdminPage.d.ts.map +1 -1
  249. package/dist/utilities/initPage/handleAdminPage.js +16 -20
  250. package/dist/utilities/initPage/handleAdminPage.js.map +1 -1
  251. package/dist/utilities/initPage/handleAuthRedirect.d.ts +6 -3
  252. package/dist/utilities/initPage/handleAuthRedirect.d.ts.map +1 -1
  253. package/dist/utilities/initPage/handleAuthRedirect.js +23 -34
  254. package/dist/utilities/initPage/handleAuthRedirect.js.map +1 -1
  255. package/dist/utilities/initPage/index.d.ts +1 -1
  256. package/dist/utilities/initPage/index.d.ts.map +1 -1
  257. package/dist/utilities/initPage/index.js +57 -48
  258. package/dist/utilities/initPage/index.js.map +1 -1
  259. package/dist/utilities/initPage/isCustomAdminView.d.ts +10 -0
  260. package/dist/utilities/initPage/isCustomAdminView.d.ts.map +1 -0
  261. package/dist/utilities/initPage/isCustomAdminView.js +31 -0
  262. package/dist/utilities/initPage/isCustomAdminView.js.map +1 -0
  263. package/dist/utilities/initPage/shared.d.ts +2 -2
  264. package/dist/utilities/initPage/shared.d.ts.map +1 -1
  265. package/dist/utilities/initPage/shared.js +19 -13
  266. package/dist/utilities/initPage/shared.js.map +1 -1
  267. package/dist/utilities/initReq.d.ts +11 -0
  268. package/dist/utilities/initReq.d.ts.map +1 -0
  269. package/dist/utilities/initReq.js +45 -0
  270. package/dist/utilities/initReq.js.map +1 -0
  271. package/dist/utilities/timestamp.d.ts.map +1 -1
  272. package/dist/utilities/timestamp.js +3 -1
  273. package/dist/utilities/timestamp.js.map +1 -1
  274. package/dist/views/API/LocaleSelector/index.js +2 -2
  275. package/dist/views/API/LocaleSelector/index.js.map +1 -1
  276. package/dist/views/API/RenderJSON/index.d.ts +1 -1
  277. package/dist/views/API/RenderJSON/index.d.ts.map +1 -1
  278. package/dist/views/API/RenderJSON/index.js.map +1 -1
  279. package/dist/views/API/RenderJSON/index.scss +68 -66
  280. package/dist/views/API/index.client.d.ts.map +1 -1
  281. package/dist/views/API/index.client.js +16 -16
  282. package/dist/views/API/index.client.js.map +1 -1
  283. package/dist/views/API/index.scss +98 -96
  284. package/dist/views/Account/Settings/index.d.ts +2 -1
  285. package/dist/views/Account/Settings/index.d.ts.map +1 -1
  286. package/dist/views/Account/Settings/index.js +3 -3
  287. package/dist/views/Account/Settings/index.js.map +1 -1
  288. package/dist/views/Account/Settings/index.scss +37 -35
  289. package/dist/views/Account/ToggleTheme/index.d.ts.map +1 -1
  290. package/dist/views/Account/ToggleTheme/index.js +2 -0
  291. package/dist/views/Account/ToggleTheme/index.js.map +1 -1
  292. package/dist/views/Account/index.d.ts.map +1 -1
  293. package/dist/views/Account/index.js +86 -31
  294. package/dist/views/Account/index.js.map +1 -1
  295. package/dist/views/CreateFirstUser/index.client.d.ts +4 -2
  296. package/dist/views/CreateFirstUser/index.client.d.ts.map +1 -1
  297. package/dist/views/CreateFirstUser/index.client.js +86 -92
  298. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  299. package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
  300. package/dist/views/CreateFirstUser/index.js +36 -4
  301. package/dist/views/CreateFirstUser/index.js.map +1 -1
  302. package/dist/views/CreateFirstUser/index.scss +18 -6
  303. package/dist/views/Dashboard/Default/index.d.ts +11 -2
  304. package/dist/views/Dashboard/Default/index.d.ts.map +1 -1
  305. package/dist/views/Dashboard/Default/index.js +70 -47
  306. package/dist/views/Dashboard/Default/index.js.map +1 -1
  307. package/dist/views/Dashboard/Default/index.scss +53 -46
  308. package/dist/views/Dashboard/index.d.ts.map +1 -1
  309. package/dist/views/Dashboard/index.js +57 -24
  310. package/dist/views/Dashboard/index.js.map +1 -1
  311. package/dist/views/Document/getDocPreferences.d.ts +11 -0
  312. package/dist/views/Document/getDocPreferences.d.ts.map +1 -0
  313. package/dist/views/Document/getDocPreferences.js +44 -0
  314. package/dist/views/Document/getDocPreferences.js.map +1 -0
  315. package/dist/views/Document/getDocumentData.d.ts +10 -8
  316. package/dist/views/Document/getDocumentData.d.ts.map +1 -1
  317. package/dist/views/Document/getDocumentData.js +35 -34
  318. package/dist/views/Document/getDocumentData.js.map +1 -1
  319. package/dist/views/Document/getDocumentPermissions.d.ts +2 -2
  320. package/dist/views/Document/getDocumentPermissions.d.ts.map +1 -1
  321. package/dist/views/Document/getDocumentPermissions.js +14 -8
  322. package/dist/views/Document/getDocumentPermissions.js.map +1 -1
  323. package/dist/views/Document/getIsLocked.d.ts +16 -0
  324. package/dist/views/Document/getIsLocked.d.ts.map +1 -0
  325. package/dist/views/Document/getIsLocked.js +55 -0
  326. package/dist/views/Document/getIsLocked.js.map +1 -0
  327. package/dist/views/Document/getMetaBySegment.d.ts +2 -2
  328. package/dist/views/Document/getMetaBySegment.d.ts.map +1 -1
  329. package/dist/views/Document/getMetaBySegment.js.map +1 -1
  330. package/dist/views/Document/getVersions.d.ts +19 -0
  331. package/dist/views/Document/getVersions.d.ts.map +1 -0
  332. package/dist/views/Document/getVersions.js +181 -0
  333. package/dist/views/Document/getVersions.js.map +1 -0
  334. package/dist/views/Document/getViewsFromConfig.d.ts +3 -3
  335. package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -1
  336. package/dist/views/Document/getViewsFromConfig.js +30 -25
  337. package/dist/views/Document/getViewsFromConfig.js.map +1 -1
  338. package/dist/views/Document/handleServerFunction.d.ts +25 -0
  339. package/dist/views/Document/handleServerFunction.d.ts.map +1 -0
  340. package/dist/views/Document/handleServerFunction.js +159 -0
  341. package/dist/views/Document/handleServerFunction.js.map +1 -0
  342. package/dist/views/Document/index.d.ts +5 -1
  343. package/dist/views/Document/index.d.ts.map +1 -1
  344. package/dist/views/Document/index.js +184 -73
  345. package/dist/views/Document/index.js.map +1 -1
  346. package/dist/views/Document/renderDocumentSlots.d.ts +12 -0
  347. package/dist/views/Document/renderDocumentSlots.d.ts.map +1 -0
  348. package/dist/views/Document/renderDocumentSlots.js +92 -0
  349. package/dist/views/Document/renderDocumentSlots.js.map +1 -0
  350. package/dist/views/Edit/index.d.ts +3 -2
  351. package/dist/views/Edit/index.d.ts.map +1 -1
  352. package/dist/views/Edit/index.js +7 -3
  353. package/dist/views/Edit/index.js.map +1 -1
  354. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -1
  355. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +17 -12
  356. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
  357. package/dist/views/ForgotPassword/index.d.ts.map +1 -1
  358. package/dist/views/ForgotPassword/index.js +11 -9
  359. package/dist/views/ForgotPassword/index.js.map +1 -1
  360. package/dist/views/List/handleServerFunction.d.ts +27 -0
  361. package/dist/views/List/handleServerFunction.d.ts.map +1 -0
  362. package/dist/views/List/handleServerFunction.js +158 -0
  363. package/dist/views/List/handleServerFunction.js.map +1 -0
  364. package/dist/views/List/index.d.ts +12 -2
  365. package/dist/views/List/index.d.ts.map +1 -1
  366. package/dist/views/List/index.js +146 -85
  367. package/dist/views/List/index.js.map +1 -1
  368. package/dist/views/List/renderListViewSlots.d.ts +12 -0
  369. package/dist/views/List/renderListViewSlots.d.ts.map +1 -0
  370. package/dist/views/List/renderListViewSlots.js +56 -0
  371. package/dist/views/List/renderListViewSlots.js.map +1 -0
  372. package/dist/views/LivePreview/Context/context.d.ts +1 -1
  373. package/dist/views/LivePreview/Context/context.d.ts.map +1 -1
  374. package/dist/views/LivePreview/Context/context.js.map +1 -1
  375. package/dist/views/LivePreview/Context/index.d.ts.map +1 -1
  376. package/dist/views/LivePreview/Context/index.js +3 -1
  377. package/dist/views/LivePreview/Context/index.js.map +1 -1
  378. package/dist/views/LivePreview/Context/sizeReducer.d.ts +1 -1
  379. package/dist/views/LivePreview/Context/sizeReducer.d.ts.map +1 -1
  380. package/dist/views/LivePreview/Context/sizeReducer.js +4 -4
  381. package/dist/views/LivePreview/Context/sizeReducer.js.map +1 -1
  382. package/dist/views/LivePreview/Device/index.d.ts.map +1 -1
  383. package/dist/views/LivePreview/Device/index.js +5 -1
  384. package/dist/views/LivePreview/Device/index.js.map +1 -1
  385. package/dist/views/LivePreview/IFrame/index.scss +8 -6
  386. package/dist/views/LivePreview/Preview/index.scss +32 -30
  387. package/dist/views/LivePreview/Toolbar/Controls/index.js +1 -1
  388. package/dist/views/LivePreview/Toolbar/Controls/index.js.map +1 -1
  389. package/dist/views/LivePreview/Toolbar/Controls/index.scss +49 -47
  390. package/dist/views/LivePreview/Toolbar/SizeInput/index.d.ts.map +1 -1
  391. package/dist/views/LivePreview/Toolbar/SizeInput/index.js.map +1 -1
  392. package/dist/views/LivePreview/Toolbar/SizeInput/index.scss +11 -9
  393. package/dist/views/LivePreview/Toolbar/index.scss +33 -31
  394. package/dist/views/LivePreview/ToolbarArea/index.scss +5 -3
  395. package/dist/views/LivePreview/index.client.d.ts.map +1 -1
  396. package/dist/views/LivePreview/index.client.js +234 -210
  397. package/dist/views/LivePreview/index.client.js.map +1 -1
  398. package/dist/views/LivePreview/index.d.ts.map +1 -1
  399. package/dist/views/LivePreview/index.js +5 -36
  400. package/dist/views/LivePreview/index.js.map +1 -1
  401. package/dist/views/LivePreview/index.scss +48 -46
  402. package/dist/views/LivePreview/usePopupWindow.d.ts +1 -1
  403. package/dist/views/LivePreview/usePopupWindow.d.ts.map +1 -1
  404. package/dist/views/LivePreview/usePopupWindow.js +119 -74
  405. package/dist/views/LivePreview/usePopupWindow.js.map +1 -1
  406. package/dist/views/Login/LoginField/index.d.ts.map +1 -1
  407. package/dist/views/Login/LoginField/index.js +6 -1
  408. package/dist/views/Login/LoginField/index.js.map +1 -1
  409. package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
  410. package/dist/views/Login/LoginForm/index.js +31 -13
  411. package/dist/views/Login/LoginForm/index.js.map +1 -1
  412. package/dist/views/Login/LoginForm/index.scss +8 -6
  413. package/dist/views/Login/index.d.ts.map +1 -1
  414. package/dist/views/Login/index.js +26 -20
  415. package/dist/views/Login/index.js.map +1 -1
  416. package/dist/views/Login/index.scss +8 -6
  417. package/dist/views/Logout/LogoutClient.d.ts +1 -0
  418. package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
  419. package/dist/views/Logout/LogoutClient.js +82 -57
  420. package/dist/views/Logout/LogoutClient.js.map +1 -1
  421. package/dist/views/Logout/index.d.ts.map +1 -1
  422. package/dist/views/Logout/index.js +1 -1
  423. package/dist/views/Logout/index.js.map +1 -1
  424. package/dist/views/Logout/index.scss +19 -14
  425. package/dist/views/NotFound/index.client.d.ts.map +1 -1
  426. package/dist/views/NotFound/index.client.js +8 -5
  427. package/dist/views/NotFound/index.client.js.map +1 -1
  428. package/dist/views/NotFound/index.d.ts +5 -5
  429. package/dist/views/NotFound/index.d.ts.map +1 -1
  430. package/dist/views/NotFound/index.js +7 -2
  431. package/dist/views/NotFound/index.js.map +1 -1
  432. package/dist/views/NotFound/index.scss +41 -21
  433. package/dist/views/ResetPassword/ResetPasswordForm/index.d.ts +7 -0
  434. package/dist/views/ResetPassword/ResetPasswordForm/index.d.ts.map +1 -0
  435. package/dist/views/ResetPassword/{index.client.js → ResetPasswordForm/index.js} +26 -25
  436. package/dist/views/ResetPassword/ResetPasswordForm/index.js.map +1 -0
  437. package/dist/views/ResetPassword/index.d.ts.map +1 -1
  438. package/dist/views/ResetPassword/index.js +48 -45
  439. package/dist/views/ResetPassword/index.js.map +1 -1
  440. package/dist/views/ResetPassword/index.scss +9 -3
  441. package/dist/views/Root/getViewFromConfig.d.ts +3 -1
  442. package/dist/views/Root/getViewFromConfig.d.ts.map +1 -1
  443. package/dist/views/Root/getViewFromConfig.js +131 -16
  444. package/dist/views/Root/getViewFromConfig.js.map +1 -1
  445. package/dist/views/Root/index.d.ts +5 -5
  446. package/dist/views/Root/index.d.ts.map +1 -1
  447. package/dist/views/Root/index.js +44 -19
  448. package/dist/views/Root/index.js.map +1 -1
  449. package/dist/views/Root/isPathMatchingRoute.d.ts.map +1 -1
  450. package/dist/views/Root/isPathMatchingRoute.js +6 -2
  451. package/dist/views/Root/isPathMatchingRoute.js.map +1 -1
  452. package/dist/views/Root/meta.d.ts +5 -5
  453. package/dist/views/Root/meta.d.ts.map +1 -1
  454. package/dist/views/Root/meta.js +3 -2
  455. package/dist/views/Root/meta.js.map +1 -1
  456. package/dist/views/Unauthorized/index.d.ts.map +1 -1
  457. package/dist/views/Unauthorized/index.js +15 -8
  458. package/dist/views/Unauthorized/index.js.map +1 -1
  459. package/dist/views/Unauthorized/index.scss +4 -31
  460. package/dist/views/Verify/index.client.d.ts +7 -0
  461. package/dist/views/Verify/index.client.d.ts.map +1 -0
  462. package/dist/views/Verify/index.client.js +46 -0
  463. package/dist/views/Verify/index.client.js.map +1 -0
  464. package/dist/views/Verify/index.d.ts.map +1 -1
  465. package/dist/views/Verify/index.js +13 -11
  466. package/dist/views/Verify/index.js.map +1 -1
  467. package/dist/views/Verify/index.scss +13 -11
  468. package/dist/views/Version/Default/index.d.ts.map +1 -1
  469. package/dist/views/Version/Default/index.js +5 -5
  470. package/dist/views/Version/Default/index.js.map +1 -1
  471. package/dist/views/Version/Default/index.scss +52 -50
  472. package/dist/views/Version/Default/types.d.ts +2 -2
  473. package/dist/views/Version/Default/types.d.ts.map +1 -1
  474. package/dist/views/Version/Default/types.js.map +1 -1
  475. package/dist/views/Version/RenderFieldsToDiff/Label/index.scss +5 -3
  476. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts.map +1 -1
  477. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +4 -2
  478. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
  479. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.scss +29 -27
  480. package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js +1 -1
  481. package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js.map +1 -1
  482. package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.scss +11 -9
  483. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.scss +12 -10
  484. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts.map +1 -1
  485. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +3 -1
  486. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
  487. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.scss +12 -10
  488. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.d.ts.map +1 -1
  489. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +9 -3
  490. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
  491. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.scss +12 -10
  492. package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts +4 -2
  493. package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts.map +1 -1
  494. package/dist/views/Version/RenderFieldsToDiff/fields/types.js.map +1 -1
  495. package/dist/views/Version/RenderFieldsToDiff/index.d.ts.map +1 -1
  496. package/dist/views/Version/RenderFieldsToDiff/index.js +10 -6
  497. package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
  498. package/dist/views/Version/RenderFieldsToDiff/index.scss +12 -10
  499. package/dist/views/Version/RenderFieldsToDiff/types.d.ts +4 -2
  500. package/dist/views/Version/RenderFieldsToDiff/types.d.ts.map +1 -1
  501. package/dist/views/Version/RenderFieldsToDiff/types.js.map +1 -1
  502. package/dist/views/Version/Restore/index.d.ts.map +1 -1
  503. package/dist/views/Version/Restore/index.js +32 -30
  504. package/dist/views/Version/Restore/index.js.map +1 -1
  505. package/dist/views/Version/Restore/index.scss +60 -42
  506. package/dist/views/Version/SelectComparison/index.d.ts.map +1 -1
  507. package/dist/views/Version/SelectComparison/index.js +27 -4
  508. package/dist/views/Version/SelectComparison/index.js.map +1 -1
  509. package/dist/views/Version/SelectComparison/index.scss +12 -10
  510. package/dist/views/Version/SelectComparison/types.d.ts +1 -0
  511. package/dist/views/Version/SelectComparison/types.d.ts.map +1 -1
  512. package/dist/views/Version/SelectComparison/types.js.map +1 -1
  513. package/dist/views/Version/SelectLocales/index.d.ts.map +1 -1
  514. package/dist/views/Version/SelectLocales/index.js.map +1 -1
  515. package/dist/views/Version/SelectLocales/index.scss +6 -4
  516. package/dist/views/Version/index.d.ts.map +1 -1
  517. package/dist/views/Version/index.js +2 -0
  518. package/dist/views/Version/index.js.map +1 -1
  519. package/dist/views/Versions/buildColumns.d.ts +3 -2
  520. package/dist/views/Versions/buildColumns.d.ts.map +1 -1
  521. package/dist/views/Versions/buildColumns.js +47 -60
  522. package/dist/views/Versions/buildColumns.js.map +1 -1
  523. package/dist/views/Versions/cells/AutosaveCell/index.d.ts +7 -0
  524. package/dist/views/Versions/cells/AutosaveCell/index.d.ts.map +1 -1
  525. package/dist/views/Versions/cells/AutosaveCell/index.js +66 -27
  526. package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
  527. package/dist/views/Versions/cells/CreatedAt/index.d.ts +4 -0
  528. package/dist/views/Versions/cells/CreatedAt/index.d.ts.map +1 -1
  529. package/dist/views/Versions/cells/CreatedAt/index.js +43 -44
  530. package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
  531. package/dist/views/Versions/cells/ID/index.d.ts +3 -1
  532. package/dist/views/Versions/cells/ID/index.d.ts.map +1 -1
  533. package/dist/views/Versions/cells/ID/index.js +7 -19
  534. package/dist/views/Versions/cells/ID/index.js.map +1 -1
  535. package/dist/views/Versions/getLatestVersion.d.ts +1 -0
  536. package/dist/views/Versions/getLatestVersion.d.ts.map +1 -1
  537. package/dist/views/Versions/getLatestVersion.js +15 -4
  538. package/dist/views/Versions/getLatestVersion.js.map +1 -1
  539. package/dist/views/Versions/index.client.d.ts.map +1 -1
  540. package/dist/views/Versions/index.client.js +53 -51
  541. package/dist/views/Versions/index.client.js.map +1 -1
  542. package/dist/views/Versions/index.d.ts.map +1 -1
  543. package/dist/views/Versions/index.js +35 -13
  544. package/dist/views/Versions/index.js.map +1 -1
  545. package/dist/views/Versions/index.scss +78 -76
  546. package/dist/withPayload.d.ts.map +1 -1
  547. package/dist/withPayload.js +23 -5
  548. package/dist/withPayload.js.map +1 -1
  549. package/license.md +22 -0
  550. package/package.json +37 -22
  551. package/dist/cjs/withPayload.js +0 -111
  552. package/dist/cjs/withPayload.js.map +0 -1
  553. package/dist/elements/EmailAndUsername/index.d.ts +0 -14
  554. package/dist/elements/EmailAndUsername/index.d.ts.map +0 -1
  555. package/dist/elements/EmailAndUsername/index.js +0 -121
  556. package/dist/elements/EmailAndUsername/index.js.map +0 -1
  557. package/dist/elements/LeaveWithoutSaving/index.d.ts +0 -4
  558. package/dist/elements/LeaveWithoutSaving/index.d.ts.map +0 -1
  559. package/dist/elements/LeaveWithoutSaving/index.js +0 -162
  560. package/dist/elements/LeaveWithoutSaving/index.js.map +0 -1
  561. package/dist/elements/LeaveWithoutSaving/index.scss +0 -37
  562. package/dist/elements/LeaveWithoutSaving/usePreventLeave.d.ts +0 -9
  563. package/dist/elements/LeaveWithoutSaving/usePreventLeave.d.ts.map +0 -1
  564. package/dist/elements/LeaveWithoutSaving/usePreventLeave.js +0 -134
  565. package/dist/elements/LeaveWithoutSaving/usePreventLeave.js.map +0 -1
  566. package/dist/routes/rest/buildFormState.d.ts +0 -5
  567. package/dist/routes/rest/buildFormState.d.ts.map +0 -1
  568. package/dist/routes/rest/buildFormState.js +0 -46
  569. package/dist/routes/rest/buildFormState.js.map +0 -1
  570. package/dist/views/Edit/Default/Auth/APIKey.d.ts +0 -6
  571. package/dist/views/Edit/Default/Auth/APIKey.d.ts.map +0 -1
  572. package/dist/views/Edit/Default/Auth/APIKey.js +0 -131
  573. package/dist/views/Edit/Default/Auth/APIKey.js.map +0 -1
  574. package/dist/views/Edit/Default/Auth/index.d.ts +0 -5
  575. package/dist/views/Edit/Default/Auth/index.d.ts.map +0 -1
  576. package/dist/views/Edit/Default/Auth/index.js +0 -307
  577. package/dist/views/Edit/Default/Auth/index.js.map +0 -1
  578. package/dist/views/Edit/Default/Auth/index.scss +0 -76
  579. package/dist/views/Edit/Default/Auth/types.d.ts +0 -17
  580. package/dist/views/Edit/Default/Auth/types.d.ts.map +0 -1
  581. package/dist/views/Edit/Default/Auth/types.js +0 -2
  582. package/dist/views/Edit/Default/Auth/types.js.map +0 -1
  583. package/dist/views/Edit/Default/SetDocumentStepNav/index.d.ts +0 -11
  584. package/dist/views/Edit/Default/SetDocumentStepNav/index.d.ts.map +0 -1
  585. package/dist/views/Edit/Default/SetDocumentStepNav/index.js +0 -130
  586. package/dist/views/Edit/Default/SetDocumentStepNav/index.js.map +0 -1
  587. package/dist/views/Edit/Default/SetDocumentTitle/index.d.ts +0 -8
  588. package/dist/views/Edit/Default/SetDocumentTitle/index.d.ts.map +0 -1
  589. package/dist/views/Edit/Default/SetDocumentTitle/index.js +0 -81
  590. package/dist/views/Edit/Default/SetDocumentTitle/index.js.map +0 -1
  591. package/dist/views/Edit/Default/index.d.ts +0 -4
  592. package/dist/views/Edit/Default/index.d.ts.map +0 -1
  593. package/dist/views/Edit/Default/index.js +0 -212
  594. package/dist/views/Edit/Default/index.js.map +0 -1
  595. package/dist/views/Edit/Default/index.scss +0 -21
  596. package/dist/views/Edit/Default/types.d.ts +0 -6
  597. package/dist/views/Edit/Default/types.d.ts.map +0 -1
  598. package/dist/views/Edit/Default/types.js +0 -2
  599. package/dist/views/Edit/Default/types.js.map +0 -1
  600. package/dist/views/Edit/index.client.d.ts +0 -3
  601. package/dist/views/Edit/index.client.d.ts.map +0 -1
  602. package/dist/views/Edit/index.client.js +0 -54
  603. package/dist/views/Edit/index.client.js.map +0 -1
  604. package/dist/views/List/Default/index.d.ts +0 -4
  605. package/dist/views/List/Default/index.d.ts.map +0 -1
  606. package/dist/views/List/Default/index.js +0 -363
  607. package/dist/views/List/Default/index.js.map +0 -1
  608. package/dist/views/List/Default/index.scss +0 -177
  609. package/dist/views/List/Default/types.d.ts +0 -15
  610. package/dist/views/List/Default/types.d.ts.map +0 -1
  611. package/dist/views/List/Default/types.js +0 -2
  612. package/dist/views/List/Default/types.js.map +0 -1
  613. package/dist/views/ResetPassword/index.client.d.ts +0 -7
  614. package/dist/views/ResetPassword/index.client.d.ts.map +0 -1
  615. 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":"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","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: apiResponse.status,\n })\n }\n"],"mappings":"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","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;EACjF,MAAM;IAAEC,IAAI;IAAEC;EAAC,CAAE,GAAGF,GAAA;EACpB,MAAMG,QAAA,GAAWJ,UAAA,CAAWK,MAAM,CAACC,IAAI,EAAEC,iBAAA,GACrC;IACEC,KAAA,EAAO,OAAOP,GAAA,CAAIC,IAAI,EAAEM,KAAA,KAAU,WAAWP,GAAA,CAAIC,IAAI,CAACM,KAAK,GAAG;IAC9DC,QAAA,EAAU,OAAOR,GAAA,CAAIC,IAAI,EAAEO,QAAA,KAAa,WAAWR,GAAA,CAAIC,IAAI,CAACO,QAAQ,GAAG;IACvEC,QAAA,EAAU,OAAOT,GAAA,CAAIC,IAAI,EAAEQ,QAAA,KAAa,WAAWT,GAAA,CAAIC,IAAI,CAACQ,QAAQ,GAAG;EACzE,IACA;IACEF,KAAA,EAAO,OAAOP,GAAA,CAAIC,IAAI,EAAEM,KAAA,KAAU,WAAWP,GAAA,CAAIC,IAAI,CAACM,KAAK,GAAG;IAC9DC,QAAA,EAAU,OAAOR,GAAA,CAAIC,IAAI,EAAEO,QAAA,KAAa,WAAWR,GAAA,CAAIC,IAAI,CAACO,QAAQ,GAAG;EACzE;EAEJ,MAAME,MAAA,GAAS,MAAMd,0BAAA,CAA2B;IAC9CG,UAAA;IACAE,IAAA,EAAM;MACJ,GAAGA,IAAI;MACP,GAAGE;IACL;IACAH;EACF;EAEA,MAAMW,MAAA,GAAShB,qBAAA,CAAsB;IACnCiB,gBAAA,EAAkBb,UAAA,CAAWK,MAAM;IACnCS,OAAA,EAASb,GAAA,CAAIa,OAAO;IACpBC,KAAA,EAAOJ,MAAA,CAAOI;EAChB;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEC,GAAA,EAAKP,MAAA,CAAOO,GAAG;IACfC,OAAA,EAAShB,CAAA,CAAE;IACXY,KAAA,EAAOJ,MAAA,CAAOI,KAAK;IACnBK,IAAA,EAAMT,MAAA,CAAOS;EACf,GACA;IACEC,OAAA,EAASvB,eAAA,CAAgB;MACvBuB,OAAA,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;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACjF,MAAM;IAAEC,IAAI;IAAEC;EAAC,CAAE,GAAGF,GAAA;EACpB,MAAMG,QAAA,GAAWJ,UAAA,CAAWK,MAAM,CAACC,IAAI,EAAEC,iBAAA,GACrC;IACEC,KAAA,EAAO,OAAOP,GAAA,CAAIC,IAAI,EAAEM,KAAA,KAAU,WAAWP,GAAA,CAAIC,IAAI,CAACM,KAAK,GAAG;IAC9DC,QAAA,EAAU,OAAOR,GAAA,CAAIC,IAAI,EAAEO,QAAA,KAAa,WAAWR,GAAA,CAAIC,IAAI,CAACO,QAAQ,GAAG;IACvEC,QAAA,EAAU,OAAOT,GAAA,CAAIC,IAAI,EAAEQ,QAAA,KAAa,WAAWT,GAAA,CAAIC,IAAI,CAACQ,QAAQ,GAAG;EACzE,IACA;IACEF,KAAA,EAAO,OAAOP,GAAA,CAAIC,IAAI,EAAEM,KAAA,KAAU,WAAWP,GAAA,CAAIC,IAAI,CAACM,KAAK,GAAG;IAC9DC,QAAA,EAAU,OAAOR,GAAA,CAAIC,IAAI,EAAEO,QAAA,KAAa,WAAWR,GAAA,CAAIC,IAAI,CAACO,QAAQ,GAAG;EACzE;EAEJ,MAAME,MAAA,GAAS,MAAMd,0BAAA,CAA2B;IAC9CG,UAAA;IACAE,IAAA,EAAM;MACJ,GAAGA,IAAI;MACP,GAAGE;IACL;IACAH;EACF;EAEA,MAAMW,MAAA,GAAShB,qBAAA,CAAsB;IACnCiB,oBAAA,EAAsBb,UAAA,CAAWK,MAAM,CAACC,IAAI;IAC5CQ,YAAA,EAAcb,GAAA,CAAIc,OAAO,CAACV,MAAM,CAACS,YAAY;IAC7CE,KAAA,EAAOL,MAAA,CAAOK;EAChB;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEC,GAAA,EAAKR,MAAA,CAAOQ,GAAG;IACfC,OAAA,EAASjB,CAAA,CAAE;IACXa,KAAA,EAAOL,MAAA,CAAOK,KAAK;IACnBK,IAAA,EAAMV,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.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,gBAAA,EAAkBb,UAAA,CAAWc,MAAM;IACnCC,OAAA,EAASd,GAAA,CAAIc,OAAO;IACpBN,KAAA,EAAOH,MAAA,CAAOG;EAChB;EAEA,IAAIT,UAAA,CAAWc,MAAM,CAACE,IAAI,CAACC,wBAAwB,EAAE;IACnD,OAAOX,MAAA,CAAOG,KAAK;EACrB;EAEA,OAAOS,QAAA,CAASC,IAAI,CAClB;IACEC,OAAA,EAASjB,CAAA,CAAE;IACX,GAAGG;EACL,GACA;IACEe,OAAA,EAASvB,eAAA,CAAgB;MACvBuB,OAAA,EAAS,IAAIC,OAAA,CAAQ;QACnB,cAAcV;MAChB;MACAX;IACF;IACAsB,MAAA,EAAQ5B,UAAA,CAAW6B;EACrB;AAEJ","ignoreList":[]}
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","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,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,SAAA,GAAoC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACzE,MAAM;IAAEC,KAAK;IAAEC;EAAK,CAAE,GAAGF,GAAA,CAAIG,KAAK;EAKlC,MAAMC,MAAA,GAAS,MAAMT,eAAA,CAAgB;IACnCI,UAAA;IACAE,KAAA,EAAOL,QAAA,CAASK,KAAA,IAASI,MAAA,CAAOJ,KAAA,IAASK,SAAA;IACzCN,GAAA;IACAE;EACF;EAEA,MAAMK,OAAA,GAAUV,eAAA,CAAgB;IAC9BU,OAAA,EAAS,IAAIC,OAAA;IACbR;EACF;EAEA,IAAII,MAAA,CAAOK,MAAM,CAACC,MAAM,KAAK,GAAG;IAC9B,MAAMC,OAAA,GAAUX,GAAA,CAAIY,CAAC,CAAC,oCAAoC;MACxDC,KAAA,EAAOT,MAAA,CAAOU,IAAI,CAACJ,MAAM;MACzBK,KAAA,EAAOtB,cAAA,CACLM,UAAA,CAAWiB,MAAM,CAACC,MAAM,CAACb,MAAA,CAAOU,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxEV,GAAA,CAAIkB,IAAI;IAEZ;IAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;MACE,GAAGhB,MAAM;MACTO;IACF,GACA;MACEJ,OAAA;MACAc,MAAA,EAAQ3B,UAAA,CAAW4B;IACrB;EAEJ;EAEA,MAAMC,KAAA,GAAQnB,MAAA,CAAOU,IAAI,CAACJ,MAAM,GAAGN,MAAA,CAAOK,MAAM,CAACC,MAAM;EAEvD,MAAMC,OAAA,GAAUX,GAAA,CAAIY,CAAC,CAAC,6BAA6B;IACjDC,KAAA,EAAOT,MAAA,CAAOK,MAAM,CAACC,MAAM;IAC3BK,KAAA,EAAOtB,cAAA,CAAeM,UAAA,CAAWiB,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,UAAA,MAAgB;AACvB,SAASC,mBAAmB,QAAQ;AACpC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,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;EAC/B,MAAMC,YAAA,GAAeH,YAAA,CAAaE,GAAG,CAAC;EAEtC,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,mBAAA,CAAoB;IACpCO,EAAA;IACAE,UAAA;IACAG,KAAA,EAAOX,QAAA,CAASW,KAAA,IAASA,KAAA,GAAQQ,SAAA;IACjCN,YAAA,EAAcO,OAAA,CAAQP,YAAA,KAAiB;IACvCQ,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,GAAUvB,eAAA,CAAgB;IAC9BuB,OAAA,EAAS,IAAIC,OAAA;IACbhB;EACF;EAEA,IAAI,CAACS,GAAA,EAAK;IACR,OAAOQ,QAAA,CAASC,IAAI,CAClB;MACEC,OAAA,EAASnB,GAAA,CAAIoB,CAAC,CAAC;IACjB,GACA;MACEL,OAAA;MACAM,MAAA,EAAQhC,UAAA,CAAWiC;IACrB;EAEJ;EAEA,OAAOL,QAAA,CAASC,IAAI,CAClB;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;AAIzD,eAAO,MAAM,IAAI,EAAE,sBA4BlB,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"}
@@ -2,6 +2,9 @@ import httpStatus from 'http-status';
2
2
  import { findOperation } from 'payload';
3
3
  import { isNumber } from 'payload/shared';
4
4
  import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
+ import { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js';
6
+ import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
7
+ import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
5
8
  export const find = async ({
6
9
  collection,
7
10
  req
@@ -9,8 +12,11 @@ export const find = async ({
9
12
  const {
10
13
  depth,
11
14
  draft,
15
+ joins,
12
16
  limit,
13
17
  page,
18
+ populate,
19
+ select,
14
20
  sort,
15
21
  where
16
22
  } = req.query;
@@ -18,10 +24,13 @@ export const find = async ({
18
24
  collection,
19
25
  depth: isNumber(depth) ? Number(depth) : undefined,
20
26
  draft: draft === 'true',
27
+ joins: sanitizeJoinParams(joins),
21
28
  limit: isNumber(limit) ? Number(limit) : undefined,
22
29
  page: isNumber(page) ? Number(page) : undefined,
30
+ populate: sanitizePopulate(populate),
23
31
  req,
24
- sort,
32
+ select: sanitizeSelect(select),
33
+ sort: typeof sort === 'string' ? sort.split(',') : undefined,
25
34
  where
26
35
  });
27
36
  return Response.json(result, {
@@ -1 +1 @@
1
- {"version":3,"file":"find.js","names":["httpStatus","findOperation","isNumber","headersWithCors","find","collection","req","depth","draft","limit","page","sort","where","query","result","Number","undefined","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/find.ts"],"sourcesContent":["import type { 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'\n\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, limit, page, sort, where } = req.query as {\n depth?: string\n draft?: string\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 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;AAEhC,OAAO,MAAMC,IAAA,GAA+B,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACpE,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,IAAI;IAAEC,IAAI;IAAEC;EAAK,CAAE,GAAGN,GAAA,CAAIO,KAAK;EAS5D,MAAMC,MAAA,GAAS,MAAMb,aAAA,CAAc;IACjCI,UAAA;IACAE,KAAA,EAAOL,QAAA,CAASK,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCR,KAAA,EAAOA,KAAA,KAAU;IACjBC,KAAA,EAAOP,QAAA,CAASO,KAAA,IAASM,MAAA,CAAON,KAAA,IAASO,SAAA;IACzCN,IAAA,EAAMR,QAAA,CAASQ,IAAA,IAAQK,MAAA,CAAOL,IAAA,IAAQM,SAAA;IACtCV,GAAA;IACAK,IAAA;IACAC;EACF;EAEA,OAAOK,QAAA,CAASC,IAAI,CAACJ,MAAA,EAAQ;IAC3BK,OAAA,EAAShB,eAAA,CAAgB;MACvBgB,OAAA,EAAS,IAAIC,OAAA;MACbd;IACF;IACAe,MAAA,EAAQrB,UAAA,CAAWsB;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":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,QAAQ,EAAE,4BA6BtB,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"}
@@ -3,6 +3,9 @@ import { findByIDOperation } 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 { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js';
7
+ import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
8
+ import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
6
9
  export const findByID = async ({
7
10
  id: incomingID,
8
11
  collection,
@@ -22,7 +25,10 @@ export const findByID = async ({
22
25
  collection,
23
26
  depth: isNumber(depth) ? Number(depth) : undefined,
24
27
  draft: searchParams.get('draft') === 'true',
25
- req
28
+ joins: sanitizeJoinParams(req.query.joins),
29
+ populate: sanitizePopulate(req.query.populate),
30
+ req,
31
+ select: sanitizeSelect(req.query.select)
26
32
  });
27
33
  return Response.json(result, {
28
34
  headers: headersWithCors({