@payloadcms/next 3.0.0-canary.f83d96a → 3.0.0-canary.fb81f02

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 (339) hide show
  1. package/dist/cjs/withPayload.cjs +18 -11
  2. package/dist/cjs/withPayload.cjs.map +1 -1
  3. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.d.ts.map +1 -1
  4. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js +5 -1
  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.map +1 -1
  9. package/dist/elements/DocumentHeader/Tabs/Tab/index.scss +7 -5
  10. package/dist/elements/DocumentHeader/Tabs/index.scss +0 -1
  11. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.d.ts.map +1 -1
  12. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js +3 -5
  13. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js.map +1 -1
  14. package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts +2 -2
  15. package/dist/elements/DocumentHeader/Tabs/tabs/index.d.ts.map +1 -1
  16. package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +1 -1
  17. package/dist/elements/DocumentHeader/index.scss +0 -2
  18. package/dist/elements/EmailAndUsername/index.d.ts +14 -0
  19. package/dist/elements/EmailAndUsername/index.d.ts.map +1 -0
  20. package/dist/elements/EmailAndUsername/index.js +85 -0
  21. package/dist/elements/EmailAndUsername/index.js.map +1 -0
  22. package/dist/elements/LeaveWithoutSaving/index.d.ts.map +1 -1
  23. package/dist/elements/LeaveWithoutSaving/index.js +2 -0
  24. package/dist/elements/LeaveWithoutSaving/index.js.map +1 -1
  25. package/dist/elements/LeaveWithoutSaving/index.scss +1 -0
  26. package/dist/elements/Nav/index.client.d.ts.map +1 -1
  27. package/dist/elements/Nav/index.client.js +20 -11
  28. package/dist/elements/Nav/index.client.js.map +1 -1
  29. package/dist/elements/Nav/index.scss +17 -14
  30. package/dist/layouts/Root/index.d.ts.map +1 -1
  31. package/dist/layouts/Root/index.js +16 -19
  32. package/dist/layouts/Root/index.js.map +1 -1
  33. package/dist/prod/styles.css +1 -1
  34. package/dist/routes/graphql/handler.d.ts.map +1 -1
  35. package/dist/routes/graphql/handler.js +7 -15
  36. package/dist/routes/graphql/handler.js.map +1 -1
  37. package/dist/routes/rest/auth/forgotPassword.d.ts.map +1 -1
  38. package/dist/routes/rest/auth/forgotPassword.js +7 -3
  39. package/dist/routes/rest/auth/forgotPassword.js.map +1 -1
  40. package/dist/routes/rest/auth/login.d.ts.map +1 -1
  41. package/dist/routes/rest/auth/login.js +9 -4
  42. package/dist/routes/rest/auth/login.js.map +1 -1
  43. package/dist/routes/rest/auth/registerFirstUser.d.ts.map +1 -1
  44. package/dist/routes/rest/auth/registerFirstUser.js +9 -2
  45. package/dist/routes/rest/auth/registerFirstUser.js.map +1 -1
  46. package/dist/routes/rest/auth/unlock.d.ts.map +1 -1
  47. package/dist/routes/rest/auth/unlock.js +7 -3
  48. package/dist/routes/rest/auth/unlock.js.map +1 -1
  49. package/dist/routes/rest/auth/verifyEmail.js +1 -1
  50. package/dist/routes/rest/auth/verifyEmail.js.map +1 -1
  51. package/dist/routes/rest/buildFormState.d.ts +2 -2
  52. package/dist/routes/rest/buildFormState.d.ts.map +1 -1
  53. package/dist/routes/rest/buildFormState.js.map +1 -1
  54. package/dist/routes/rest/collections/restoreVersion.d.ts.map +1 -1
  55. package/dist/routes/rest/collections/restoreVersion.js +2 -0
  56. package/dist/routes/rest/collections/restoreVersion.js.map +1 -1
  57. package/dist/routes/rest/files/checkFileAccess.d.ts +2 -2
  58. package/dist/routes/rest/files/checkFileAccess.d.ts.map +1 -1
  59. package/dist/routes/rest/files/checkFileAccess.js.map +1 -1
  60. package/dist/routes/rest/files/getFile.d.ts +2 -2
  61. package/dist/routes/rest/files/getFile.d.ts.map +1 -1
  62. package/dist/routes/rest/files/getFile.js.map +1 -1
  63. package/dist/routes/rest/globals/restoreVersion.d.ts.map +1 -1
  64. package/dist/routes/rest/globals/restoreVersion.js +2 -0
  65. package/dist/routes/rest/globals/restoreVersion.js.map +1 -1
  66. package/dist/routes/rest/index.d.ts.map +1 -1
  67. package/dist/routes/rest/index.js +88 -95
  68. package/dist/routes/rest/index.js.map +1 -1
  69. package/dist/routes/rest/og/index.d.ts +2 -2
  70. package/dist/routes/rest/og/index.d.ts.map +1 -1
  71. package/dist/routes/rest/og/index.js.map +1 -1
  72. package/dist/routes/rest/routeError.d.ts +2 -2
  73. package/dist/routes/rest/routeError.d.ts.map +1 -1
  74. package/dist/routes/rest/routeError.js +3 -3
  75. package/dist/routes/rest/routeError.js.map +1 -1
  76. package/dist/routes/rest/types.d.ts +7 -7
  77. package/dist/routes/rest/types.d.ts.map +1 -1
  78. package/dist/routes/rest/types.js.map +1 -1
  79. package/dist/scss/app.scss +10 -15
  80. package/dist/scss/colors.scss +76 -76
  81. package/dist/scss/toastify.scss +59 -0
  82. package/dist/scss/toasts.scss +75 -45
  83. package/dist/scss/type.scss +15 -23
  84. package/dist/scss/vars.scss +26 -47
  85. package/dist/templates/Default/index.d.ts +2 -2
  86. package/dist/templates/Default/index.d.ts.map +1 -1
  87. package/dist/templates/Default/index.js.map +1 -1
  88. package/dist/utilities/addDataAndFileToRequest.d.ts +3 -6
  89. package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
  90. package/dist/utilities/addDataAndFileToRequest.js +15 -18
  91. package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
  92. package/dist/utilities/addLocalesToRequest.d.ts +2 -5
  93. package/dist/utilities/addLocalesToRequest.d.ts.map +1 -1
  94. package/dist/utilities/addLocalesToRequest.js +8 -9
  95. package/dist/utilities/addLocalesToRequest.js.map +1 -1
  96. package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
  97. package/dist/utilities/createPayloadRequest.js +11 -8
  98. package/dist/utilities/createPayloadRequest.js.map +1 -1
  99. package/dist/utilities/getNextRequestI18n.d.ts +3 -3
  100. package/dist/utilities/getNextRequestI18n.d.ts.map +1 -1
  101. package/dist/utilities/getNextRequestI18n.js +3 -1
  102. package/dist/utilities/getNextRequestI18n.js.map +1 -1
  103. package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
  104. package/dist/utilities/getPayloadHMR.js +11 -8
  105. package/dist/utilities/getPayloadHMR.js.map +1 -1
  106. package/dist/utilities/headersWithCors.d.ts +2 -2
  107. package/dist/utilities/headersWithCors.d.ts.map +1 -1
  108. package/dist/utilities/headersWithCors.js +19 -3
  109. package/dist/utilities/headersWithCors.js.map +1 -1
  110. package/dist/utilities/initPage/handleAdminPage.d.ts +4 -0
  111. package/dist/utilities/initPage/handleAdminPage.d.ts.map +1 -1
  112. package/dist/utilities/initPage/handleAdminPage.js +17 -4
  113. package/dist/utilities/initPage/handleAdminPage.js.map +1 -1
  114. package/dist/utilities/initPage/handleAuthRedirect.d.ts.map +1 -1
  115. package/dist/utilities/initPage/handleAuthRedirect.js +16 -4
  116. package/dist/utilities/initPage/handleAuthRedirect.js.map +1 -1
  117. package/dist/utilities/initPage/index.d.ts.map +1 -1
  118. package/dist/utilities/initPage/index.js +2 -1
  119. package/dist/utilities/initPage/index.js.map +1 -1
  120. package/dist/utilities/initPage/shared.d.ts +14 -2
  121. package/dist/utilities/initPage/shared.d.ts.map +1 -1
  122. package/dist/utilities/initPage/shared.js +14 -4
  123. package/dist/utilities/initPage/shared.js.map +1 -1
  124. package/dist/utilities/mergeHeaders.d.ts +1 -1
  125. package/dist/utilities/mergeHeaders.d.ts.map +1 -1
  126. package/dist/utilities/mergeHeaders.js +7 -33
  127. package/dist/utilities/mergeHeaders.js.map +1 -1
  128. package/dist/utilities/meta.d.ts +2 -2
  129. package/dist/utilities/meta.d.ts.map +1 -1
  130. package/dist/utilities/meta.js +3 -5
  131. package/dist/utilities/meta.js.map +1 -1
  132. package/dist/views/API/index.scss +1 -2
  133. package/dist/views/Account/index.client.d.ts +3 -0
  134. package/dist/views/Account/index.client.d.ts.map +1 -0
  135. package/dist/views/Account/index.client.js +21 -0
  136. package/dist/views/Account/index.client.js.map +1 -0
  137. package/dist/views/Account/index.d.ts.map +1 -1
  138. package/dist/views/Account/index.js +21 -26
  139. package/dist/views/Account/index.js.map +1 -1
  140. package/dist/views/CreateFirstUser/index.client.d.ts +2 -1
  141. package/dist/views/CreateFirstUser/index.client.d.ts.map +1 -1
  142. package/dist/views/CreateFirstUser/index.client.js +14 -12
  143. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  144. package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
  145. package/dist/views/CreateFirstUser/index.js +11 -29
  146. package/dist/views/CreateFirstUser/index.js.map +1 -1
  147. package/dist/views/CreateFirstUser/index.scss +4 -0
  148. package/dist/views/Dashboard/Default/index.d.ts +2 -2
  149. package/dist/views/Dashboard/Default/index.d.ts.map +1 -1
  150. package/dist/views/Dashboard/Default/index.js +13 -4
  151. package/dist/views/Dashboard/Default/index.js.map +1 -1
  152. package/dist/views/Dashboard/Default/index.scss +11 -7
  153. package/dist/views/Dashboard/index.js +3 -4
  154. package/dist/views/Dashboard/index.js.map +1 -1
  155. package/dist/views/Document/getDocumentData.d.ts +3 -2
  156. package/dist/views/Document/getDocumentData.d.ts.map +1 -1
  157. package/dist/views/Document/getDocumentData.js +4 -3
  158. package/dist/views/Document/getDocumentData.js.map +1 -1
  159. package/dist/views/Document/getMetaBySegment.d.ts +2 -2
  160. package/dist/views/Document/getMetaBySegment.d.ts.map +1 -1
  161. package/dist/views/Document/getMetaBySegment.js.map +1 -1
  162. package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -1
  163. package/dist/views/Document/getViewsFromConfig.js +19 -5
  164. package/dist/views/Document/getViewsFromConfig.js.map +1 -1
  165. package/dist/views/Document/index.d.ts.map +1 -1
  166. package/dist/views/Document/index.js +26 -40
  167. package/dist/views/Document/index.js.map +1 -1
  168. package/dist/views/Edit/Default/Auth/APIKey.d.ts +2 -2
  169. package/dist/views/Edit/Default/Auth/APIKey.d.ts.map +1 -1
  170. package/dist/views/Edit/Default/Auth/APIKey.js +36 -8
  171. package/dist/views/Edit/Default/Auth/APIKey.js.map +1 -1
  172. package/dist/views/Edit/Default/Auth/index.d.ts.map +1 -1
  173. package/dist/views/Edit/Default/Auth/index.js +69 -26
  174. package/dist/views/Edit/Default/Auth/index.js.map +1 -1
  175. package/dist/views/Edit/Default/Auth/index.scss +17 -2
  176. package/dist/views/Edit/Default/Auth/types.d.ts +4 -0
  177. package/dist/views/Edit/Default/Auth/types.d.ts.map +1 -1
  178. package/dist/views/Edit/Default/Auth/types.js.map +1 -1
  179. package/dist/views/Edit/Default/SetDocumentStepNav/index.d.ts.map +1 -1
  180. package/dist/views/Edit/Default/SetDocumentStepNav/index.js +15 -5
  181. package/dist/views/Edit/Default/SetDocumentStepNav/index.js.map +1 -1
  182. package/dist/views/Edit/Default/index.d.ts.map +1 -1
  183. package/dist/views/Edit/Default/index.js +34 -25
  184. package/dist/views/Edit/Default/index.js.map +1 -1
  185. package/dist/views/Edit/Default/index.scss +2 -2
  186. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -1
  187. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +34 -6
  188. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
  189. package/dist/views/ForgotPassword/index.d.ts.map +1 -1
  190. package/dist/views/ForgotPassword/index.js +12 -4
  191. package/dist/views/ForgotPassword/index.js.map +1 -1
  192. package/dist/views/List/Default/index.d.ts.map +1 -1
  193. package/dist/views/List/Default/index.js +28 -30
  194. package/dist/views/List/Default/index.js.map +1 -1
  195. package/dist/views/List/Default/index.scss +7 -17
  196. package/dist/views/List/index.d.ts.map +1 -1
  197. package/dist/views/List/index.js +33 -12
  198. package/dist/views/List/index.js.map +1 -1
  199. package/dist/views/List/meta.d.ts +2 -2
  200. package/dist/views/List/meta.d.ts.map +1 -1
  201. package/dist/views/List/meta.js.map +1 -1
  202. package/dist/views/LivePreview/Preview/index.js +1 -1
  203. package/dist/views/LivePreview/Preview/index.js.map +1 -1
  204. package/dist/views/LivePreview/Toolbar/index.d.ts +2 -2
  205. package/dist/views/LivePreview/Toolbar/index.d.ts.map +1 -1
  206. package/dist/views/LivePreview/Toolbar/index.js.map +1 -1
  207. package/dist/views/LivePreview/index.client.d.ts.map +1 -1
  208. package/dist/views/LivePreview/index.client.js.map +1 -1
  209. package/dist/views/LivePreview/usePopupWindow.js.map +1 -1
  210. package/dist/views/Login/LoginField/index.d.ts +9 -0
  211. package/dist/views/Login/LoginField/index.d.ts.map +1 -0
  212. package/dist/views/Login/LoginField/index.js +46 -0
  213. package/dist/views/Login/LoginField/index.js.map +1 -0
  214. package/dist/views/Login/LoginForm/index.d.ts +3 -0
  215. package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
  216. package/dist/views/Login/LoginForm/index.js +40 -51
  217. package/dist/views/Login/LoginForm/index.js.map +1 -1
  218. package/dist/views/Login/index.d.ts.map +1 -1
  219. package/dist/views/Login/index.js +7 -0
  220. package/dist/views/Login/index.js.map +1 -1
  221. package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
  222. package/dist/views/Logout/LogoutClient.js +7 -2
  223. package/dist/views/Logout/LogoutClient.js.map +1 -1
  224. package/dist/views/Logout/index.d.ts +2 -2
  225. package/dist/views/Logout/index.d.ts.map +1 -1
  226. package/dist/views/Logout/index.js +2 -2
  227. package/dist/views/Logout/index.js.map +1 -1
  228. package/dist/views/NotFound/index.client.d.ts.map +1 -1
  229. package/dist/views/NotFound/index.client.js +3 -2
  230. package/dist/views/NotFound/index.client.js.map +1 -1
  231. package/dist/views/NotFound/index.d.ts.map +1 -1
  232. package/dist/views/NotFound/index.js +17 -22
  233. package/dist/views/NotFound/index.js.map +1 -1
  234. package/dist/views/NotFound/meta.d.ts +2 -2
  235. package/dist/views/NotFound/meta.d.ts.map +1 -1
  236. package/dist/views/NotFound/meta.js.map +1 -1
  237. package/dist/views/ResetPassword/index.client.d.ts.map +1 -1
  238. package/dist/views/ResetPassword/index.client.js +19 -31
  239. package/dist/views/ResetPassword/index.client.js.map +1 -1
  240. package/dist/views/ResetPassword/index.d.ts.map +1 -1
  241. package/dist/views/ResetPassword/index.js +7 -3
  242. package/dist/views/ResetPassword/index.js.map +1 -1
  243. package/dist/views/Root/getViewFromConfig.d.ts.map +1 -1
  244. package/dist/views/Root/getViewFromConfig.js +5 -1
  245. package/dist/views/Root/getViewFromConfig.js.map +1 -1
  246. package/dist/views/Root/index.d.ts +2 -2
  247. package/dist/views/Root/index.d.ts.map +1 -1
  248. package/dist/views/Root/index.js +14 -8
  249. package/dist/views/Root/index.js.map +1 -1
  250. package/dist/views/Unauthorized/index.d.ts.map +1 -1
  251. package/dist/views/Unauthorized/index.js +1 -0
  252. package/dist/views/Unauthorized/index.js.map +1 -1
  253. package/dist/views/Verify/index.d.ts.map +1 -1
  254. package/dist/views/Verify/index.js +9 -2
  255. package/dist/views/Verify/index.js.map +1 -1
  256. package/dist/views/Version/Default/SetStepNav.d.ts +1 -3
  257. package/dist/views/Version/Default/SetStepNav.d.ts.map +1 -1
  258. package/dist/views/Version/Default/SetStepNav.js +28 -13
  259. package/dist/views/Version/Default/SetStepNav.js.map +1 -1
  260. package/dist/views/Version/Default/index.d.ts.map +1 -1
  261. package/dist/views/Version/Default/index.js +15 -15
  262. package/dist/views/Version/Default/index.js.map +1 -1
  263. package/dist/views/Version/Default/types.d.ts +3 -3
  264. package/dist/views/Version/Default/types.d.ts.map +1 -1
  265. package/dist/views/Version/Default/types.js.map +1 -1
  266. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
  267. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.d.ts.map +1 -1
  268. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +41 -21
  269. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
  270. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts +3 -4
  271. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts.map +1 -1
  272. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
  273. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts +3 -3
  274. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts.map +1 -1
  275. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
  276. package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts +11 -11
  277. package/dist/views/Version/RenderFieldsToDiff/fields/index.js +3 -2
  278. package/dist/views/Version/RenderFieldsToDiff/fields/index.js.map +1 -1
  279. package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts +1 -2
  280. package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts.map +1 -1
  281. package/dist/views/Version/RenderFieldsToDiff/fields/types.js.map +1 -1
  282. package/dist/views/Version/RenderFieldsToDiff/types.d.ts +3 -4
  283. package/dist/views/Version/RenderFieldsToDiff/types.d.ts.map +1 -1
  284. package/dist/views/Version/RenderFieldsToDiff/types.js.map +1 -1
  285. package/dist/views/Version/Restore/index.d.ts.map +1 -1
  286. package/dist/views/Version/Restore/index.js +46 -13
  287. package/dist/views/Version/Restore/index.js.map +1 -1
  288. package/dist/views/Version/Restore/index.scss +31 -0
  289. package/dist/views/Version/Restore/types.d.ts +1 -0
  290. package/dist/views/Version/Restore/types.d.ts.map +1 -1
  291. package/dist/views/Version/Restore/types.js.map +1 -1
  292. package/dist/views/Version/SelectComparison/index.d.ts.map +1 -1
  293. package/dist/views/Version/SelectComparison/index.js +49 -28
  294. package/dist/views/Version/SelectComparison/index.js.map +1 -1
  295. package/dist/views/Version/SelectComparison/index.scss +1 -1
  296. package/dist/views/Version/SelectComparison/types.d.ts +2 -1
  297. package/dist/views/Version/SelectComparison/types.d.ts.map +1 -1
  298. package/dist/views/Version/SelectComparison/types.js.map +1 -1
  299. package/dist/views/Version/index.d.ts +1 -1
  300. package/dist/views/Version/index.d.ts.map +1 -1
  301. package/dist/views/Version/index.js +55 -43
  302. package/dist/views/Version/index.js.map +1 -1
  303. package/dist/views/Versions/buildColumns.d.ts +3 -1
  304. package/dist/views/Versions/buildColumns.d.ts.map +1 -1
  305. package/dist/views/Versions/buildColumns.js +7 -4
  306. package/dist/views/Versions/buildColumns.js.map +1 -1
  307. package/dist/views/Versions/cells/AutosaveCell/index.d.ts +7 -1
  308. package/dist/views/Versions/cells/AutosaveCell/index.d.ts.map +1 -1
  309. package/dist/views/Versions/cells/AutosaveCell/index.js +31 -13
  310. package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
  311. package/dist/views/Versions/cells/CreatedAt/index.d.ts.map +1 -1
  312. package/dist/views/Versions/cells/CreatedAt/index.js +10 -4
  313. package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
  314. package/dist/views/Versions/getLatestVersion.d.ts +14 -0
  315. package/dist/views/Versions/getLatestVersion.d.ts.map +1 -0
  316. package/dist/views/Versions/getLatestVersion.js +34 -0
  317. package/dist/views/Versions/getLatestVersion.js.map +1 -0
  318. package/dist/views/Versions/index.client.d.ts.map +1 -1
  319. package/dist/views/Versions/index.client.js +3 -2
  320. package/dist/views/Versions/index.client.js.map +1 -1
  321. package/dist/views/Versions/index.d.ts.map +1 -1
  322. package/dist/views/Versions/index.js +45 -3
  323. package/dist/views/Versions/index.js.map +1 -1
  324. package/dist/withPayload.d.ts.map +1 -1
  325. package/dist/withPayload.js +18 -11
  326. package/dist/withPayload.js.map +1 -1
  327. package/package.json +20 -26
  328. package/dist/prod/index.js +0 -62
  329. package/dist/prod/payload/payload-favicon-dark.png +0 -0
  330. package/dist/prod/payload/payload-favicon-light.png +0 -0
  331. package/dist/prod/payload/static-og-image.png +0 -0
  332. package/dist/views/Version/shared.d.ts +0 -9
  333. package/dist/views/Version/shared.d.ts.map +0 -1
  334. package/dist/views/Version/shared.js +0 -10
  335. package/dist/views/Version/shared.js.map +0 -1
  336. package/dist/webpackEntry.d.ts +0 -5
  337. package/dist/webpackEntry.d.ts.map +0 -1
  338. package/dist/webpackEntry.js +0 -6
  339. package/dist/webpackEntry.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;AAuDjF,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,sBA6D9E,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;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"}
@@ -35,7 +35,6 @@ const handleError = async (payload, err, debug, afterErrorHook)=>{
35
35
  };
36
36
  let cached = global._payload_graphql;
37
37
  if (!cached) {
38
- // eslint-disable-next-line no-multi-assign
39
38
  cached = global._payload_graphql = {
40
39
  graphql: null,
41
40
  promise: null
@@ -68,24 +67,20 @@ export const getGraphql = async (config)=>{
68
67
  };
69
68
  export const POST = (config)=>async (request)=>{
70
69
  const originalRequest = request.clone();
71
- const basePayloadRequest = await createPayloadRequest({
70
+ const req = await createPayloadRequest({
72
71
  config,
73
72
  request
74
73
  });
75
- const reqWithData = await addDataAndFileToRequest({
76
- request: basePayloadRequest
77
- });
78
- const payloadRequest = addLocalesToRequestFromData({
79
- request: reqWithData
80
- });
74
+ await addDataAndFileToRequest(req);
75
+ addLocalesToRequestFromData(req);
81
76
  const { schema, validationRules } = await getGraphql(config);
82
- const { payload } = payloadRequest;
77
+ const { payload } = req;
83
78
  const afterErrorHook = typeof payload.config.hooks.afterError === 'function' ? payload.config.hooks.afterError : null;
84
79
  const headers = {};
85
80
  const apiResponse = await createHandler({
86
81
  context: {
87
82
  headers,
88
- req: payloadRequest
83
+ req
89
84
  },
90
85
  onOperation: async (request, args, result)=>{
91
86
  const response = typeof payload.extensions === 'function' ? await payload.extensions({
@@ -110,16 +105,13 @@ export const POST = (config)=>async (request)=>{
110
105
  })(originalRequest);
111
106
  const resHeaders = headersWithCors({
112
107
  headers: new Headers(apiResponse.headers),
113
- req: payloadRequest
108
+ req
114
109
  });
115
110
  for(const key in headers){
116
111
  resHeaders.append(key, headers[key]);
117
112
  }
118
- if (basePayloadRequest.responseHeaders) {
119
- mergeHeaders(basePayloadRequest.responseHeaders, resHeaders);
120
- }
121
113
  return new Response(apiResponse.body, {
122
- headers: resHeaders,
114
+ headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, resHeaders) : resHeaders,
123
115
  status: apiResponse.status
124
116
  });
125
117
  };
@@ -1 +1 @@
1
- {"version":3,"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 // eslint-disable-next-line no-multi-assign\n cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\nexport const POST =\n (config: Promise<SanitizedConfig> | SanitizedConfig) => async (request: Request) => {\n const originalRequest = request.clone()\n const basePayloadRequest = await createPayloadRequest({\n config,\n request,\n })\n\n const reqWithData = await addDataAndFileToRequest({ request: basePayloadRequest })\n const payloadRequest = addLocalesToRequestFromData({ request: reqWithData })\n\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = payloadRequest\n\n const afterErrorHook =\n typeof payload.config.hooks.afterError === 'function' ? payload.config.hooks.afterError : null\n\n const headers = {}\n const apiResponse = await createHandler({\n context: { headers, req: payloadRequest },\n onOperation: async (request, args, result) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: request,\n result,\n })\n : result\n if (response.errors) {\n const errors = (await Promise.all(\n result.errors.map((error) => {\n return handleError(payload, error, payload.config.debug, afterErrorHook)\n }),\n )) as GraphQLError[]\n // errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (_, args, defaultRules) => defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req: payloadRequest,\n })\n\n for (const key in headers) {\n resHeaders.append(key, headers[key])\n }\n\n if (basePayloadRequest.responseHeaders) {\n mergeHeaders(basePayloadRequest.responseHeaders, resHeaders)\n }\n\n return new Response(apiResponse.body, {\n headers: resHeaders,\n status: apiResponse.status,\n })\n }\n"],"names":["configToSchema","createHandler","httpStatus","addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequest","headersWithCors","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","basePayloadRequest","reqWithData","payloadRequest","validationRules","hooks","afterError","headers","apiResponse","context","req","onOperation","args","result","errors","all","map","_","defaultRules","concat","resHeaders","Headers","key","append","responseHeaders","Response","body"],"mappings":"AAGA,SAASA,cAAc,QAAQ,sBAAqB;AACpD,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,OAAOC,gBAAgB,cAAa;AAEpC,SAASC,uBAAuB,QAAQ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MAAM,CAACE,GAAG,CAAC,CAAC5C;wBACjB,OAAOX,YAAYC,SAASU,OAAOV,QAAQ0B,MAAM,CAACxB,KAAK,EAAEC;oBAC3D;oBAEF,yIAAyI;oBACzI,OAAO;wBAAE,GAAGS,QAAQ;wBAAEwC;oBAAO;gBAC/B;gBACA,OAAOxC;YACT;YACAqB;YACAS,iBAAiB,CAACa,GAAGL,MAAMM,eAAiBA,aAAaC,MAAM,CAACf,gBAAgBQ;QAClF,GAAGb;QAEH,MAAMqB,aAAa7D,gBAAgB;YACjCgD,SAAS,IAAIc,QAAQb,YAAYD,OAAO;YACxCG,KAAKP;QACP;QAEA,IAAK,MAAMmB,OAAOf,QAAS;YACzBa,WAAWG,MAAM,CAACD,KAAKf,OAAO,CAACe,IAAI;QACrC;QAEA,IAAIrB,mBAAmBuB,eAAe,EAAE;YACtChE,aAAayC,mBAAmBuB,eAAe,EAAEJ;QACnD;QAEA,OAAO,IAAIK,SAASjB,YAAYkB,IAAI,EAAE;YACpCnB,SAASa;YACTtD,QAAQ0C,YAAY1C,MAAM;QAC5B;IACF,EAAC"}
1
+ {"version":3,"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"],"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"],"mappings":"AAGA,SAASA,cAAc,QAAQ,sBAAqB;AACpD,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,OAAOC,gBAAgB,cAAa;AAEpC,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,2BAA2B,QAAQ,yCAAwC;AACpF,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,YAAY,QAAQ,kCAAiC;AAE9D,MAAMC,cAAc,OAClBC,SACAC,KACAC,OACAC;IAGA,MAAMC,SAASH,IAAII,aAAa,CAACD,MAAM,IAAIX,WAAWa,qBAAqB;IAC3E,IAAIC,eAAeN,IAAIO,OAAO;IAC9BR,QAAQS,MAAM,CA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QAAS;YACzBY,WAAWG,MAAM,CAACD,KAAKd,OAAO,CAACc,IAAI;QACrC;QAEA,OAAO,IAAIE,SAASf,YAAYgB,IAAI,EAAE;YACpCjB,SAASJ,IAAIsB,eAAe,GAAG/D,aAAayC,IAAIsB,eAAe,EAAEN,cAAcA;YAC/EnD,QAAQwC,YAAYxC,MAAM;QAC5B;IACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,cAAc,EAAE,sBAwB5B,CAAA"}
1
+ {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,cAAc,EAAE,sBA+B5B,CAAA"}
@@ -3,11 +3,15 @@ import { forgotPasswordOperation } from 'payload';
3
3
  import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
4
  export const forgotPassword = async ({ collection, req })=>{
5
5
  const { t } = req;
6
+ const authData = collection.config.auth?.loginWithUsername ? {
7
+ email: typeof req.data?.email === 'string' ? req.data.email : '',
8
+ username: typeof req.data?.username === 'string' ? req.data.username : ''
9
+ } : {
10
+ email: typeof req.data?.email === 'string' ? req.data.email : ''
11
+ };
6
12
  await forgotPasswordOperation({
7
13
  collection,
8
- data: {
9
- email: req.data.email
10
- },
14
+ data: authData,
11
15
  disableEmail: Boolean(req.data?.disableEmail),
12
16
  expiration: typeof req.data.expiration === 'number' ? req.data.expiration : undefined,
13
17
  req
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { forgotPasswordOperation } from 'payload'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const forgotPassword: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n await forgotPasswordOperation({\n collection,\n data: {\n email: req.data.email as string,\n },\n disableEmail: Boolean(req.data?.disableEmail),\n expiration: typeof req.data.expiration === 'number' ? req.data.expiration : undefined,\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","forgotPasswordOperation","headersWithCors","forgotPassword","collection","req","t","data","email","disableEmail","Boolean","expiration","undefined","Response","json","message","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,uBAAuB,QAAQ,UAAS;AAIjD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,iBAAyC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAC9E,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAMJ,wBAAwB;QAC5BG;QACAG,MAAM;YACJC,OAAOH,IAAIE,IAAI,CAACC,KAAK;QACvB;QACAC,cAAcC,QAAQL,IAAIE,IAAI,EAAEE;QAChCE,YAAY,OAAON,IAAIE,IAAI,CAACI,UAAU,KAAK,WAAWN,IAAIE,IAAI,CAACI,UAAU,GAAGC;QAC5EP;IACF;IAEA,OAAOQ,SAASC,IAAI,CAClB;QACEC,SAAST,EAAE;IACb,GACA;QACEU,SAASd,gBAAgB;YACvBc,SAAS,IAAIC;YACbZ;QACF;QACAa,QAAQlB,WAAWmB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/auth/forgotPassword.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { forgotPasswordOperation } from 'payload'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const forgotPassword: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n const authData = collection.config.auth?.loginWithUsername\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n }\n\n await forgotPasswordOperation({\n collection,\n data: authData,\n disableEmail: Boolean(req.data?.disableEmail),\n expiration: typeof req.data.expiration === 'number' ? req.data.expiration : undefined,\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","forgotPasswordOperation","headersWithCors","forgotPassword","collection","req","t","authData","config","auth","loginWithUsername","email","data","username","disableEmail","Boolean","expiration","undefined","Response","json","message","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,uBAAuB,QAAQ,UAAS;AAIjD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,iBAAyC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAC9E,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAME,WAAWH,WAAWI,MAAM,CAACC,IAAI,EAAEC,oBACrC;QACEC,OAAO,OAAON,IAAIO,IAAI,EAAED,UAAU,WAAWN,IAAIO,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOR,IAAIO,IAAI,EAAEC,aAAa,WAAWR,IAAIO,IAAI,CAACC,QAAQ,GAAG;IACzE,IACA;QACEF,OAAO,OAAON,IAAIO,IAAI,EAAED,UAAU,WAAWN,IAAIO,IAAI,CAACD,KAAK,GAAG;IAChE;IAEJ,MAAMV,wBAAwB;QAC5BG;QACAQ,MAAML;QACNO,cAAcC,QAAQV,IAAIO,IAAI,EAAEE;QAChCE,YAAY,OAAOX,IAAIO,IAAI,CAACI,UAAU,KAAK,WAAWX,IAAIO,IAAI,CAACI,UAAU,GAAGC;QAC5EZ;IACF;IAEA,OAAOa,SAASC,IAAI,CAClB;QACEC,SAASd,EAAE;IACb,GACA;QACEe,SAASnB,gBAAgB;YACvBmB,SAAS,IAAIC;YACbjB;QACF;QACAkB,QAAQvB,WAAWwB,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/login.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,KAAK,EAAE,sBAuCnB,CAAA"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/login.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,KAAK,EAAE,sBA+CnB,CAAA"}
@@ -5,12 +5,17 @@ import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
5
  export const login = async ({ collection, req })=>{
6
6
  const { searchParams, t } = req;
7
7
  const depth = searchParams.get('depth');
8
+ const authData = collection.config.auth?.loginWithUsername !== false ? {
9
+ email: typeof req.data?.email === 'string' ? req.data.email : '',
10
+ password: typeof req.data?.password === 'string' ? req.data.password : '',
11
+ username: typeof req.data?.username === 'string' ? req.data.username : ''
12
+ } : {
13
+ email: typeof req.data?.email === 'string' ? req.data.email : '',
14
+ password: typeof req.data?.password === 'string' ? req.data.password : ''
15
+ };
8
16
  const result = await loginOperation({
9
17
  collection,
10
- data: {
11
- email: typeof req.data?.email === 'string' ? req.data.email : '',
12
- password: typeof req.data?.password === 'string' ? req.data.password : ''
13
- },
18
+ data: authData,
14
19
  depth: isNumber(depth) ? Number(depth) : undefined,
15
20
  req
16
21
  });
@@ -1 +1 @@
1
- {"version":3,"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\n const result = await loginOperation({\n collection,\n data: {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n },\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n message: t('authentication:passed'),\n ...result,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generatePayloadCookie","loginOperation","isNumber","headersWithCors","login","collection","req","searchParams","t","depth","get","result","data","email","password","Number","undefined","cookie","collectionConfig","config","payload","token","auth","removeTokenFromResponses","Response","json","message","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,EAAEC,cAAc,QAAQ,UAAS;AAC/D,SAASC,QAAQ,QAAQ,iBAAgB;AAIzC,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,QAAgC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrE,MAAM,EAAEC,YAAY,EAAEC,CAAC,EAAE,GAAGF;IAC5B,MAAMG,QAAQF,aAAaG,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMV,eAAe;QAClCI;QACAO,MAAM;YACJC,OAAO,OAAOP,IAAIM,IAAI,EAAEC,UAAU,WAAWP,IAAIM,IAAI,CAACC,KAAK,GAAG;YAC9DC,UAAU,OAAOR,IAAIM,IAAI,EAAEE,aAAa,WAAWR,IAAIM,IAAI,CAACE,QAAQ,GAAG;QACzE;QACAL,OAAOP,SAASO,SAASM,OAAON,SAASO;QACzCV;IACF;IAEA,MAAMW,SAASjB,sBAAsB;QACnCkB,kBAAkBb,WAAWc,MAAM;QACnCC,SAASd,IAAIc,OAAO;QACpBC,OAAOV,OAAOU,KAAK;IACrB;IAEA,IAAIhB,WAAWc,MAAM,CAACG,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOZ,OAAOU,KAAK;IACrB;IAEA,OAAOG,SAASC,IAAI,CAClB;QACEC,SAASlB,EAAE;QACX,GAAGG,MAAM;IACX,GACA;QACEgB,SAASxB,gBAAgB;YACvBwB,SAAS,IAAIC,QAAQ;gBACnB,cAAcX;YAChB;YACAX;QACF;QACAuB,QAAQ9B,WAAW+B,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"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"],"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"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,EAAEC,cAAc,QAAQ,UAAS;AAC/D,SAASC,QAAQ,QAAQ,iBAAgB;AAIzC,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,QAAgC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrE,MAAM,EAAEC,YAAY,EAAEC,CAAC,EAAE,GAAGF;IAC5B,MAAMG,QAAQF,aAAaG,GAAG,CAAC;IAC/B,MAAMC,WACJN,WAAWO,MAAM,CAACC,IAAI,EAAEC,sBAAsB,QAC1C;QACEC,OAAO,OAAOT,IAAIU,IAAI,EAAED,UAAU,WAAWT,IAAIU,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOX,IAAIU,IAAI,EAAEC,aAAa,WAAWX,IAAIU,IAAI,CAACC,QAAQ,GAAG;QACvEC,UAAU,OAAOZ,IAAIU,IAAI,EAAEE,aAAa,WAAWZ,IAAIU,IAAI,CAACE,QAAQ,GAAG;IACzE,IACA;QACEH,OAAO,OAAOT,IAAIU,IAAI,EAAED,UAAU,WAAWT,IAAIU,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOX,IAAIU,IAAI,EAAEC,aAAa,WAAWX,IAAIU,IAAI,CAACC,QAAQ,GAAG;IACzE;IAEN,MAAME,SAAS,MAAMlB,eAAe;QAClCI;QACAW,MAAML;QACNF,OAAOP,SAASO,SAASW,OAAOX,SAASY;QACzCf;IACF;IAEA,MAAMgB,SAAStB,sBAAsB;QACnCuB,kBAAkBlB,WAAWO,MAAM;QACnCY,SAASlB,IAAIkB,OAAO;QACpBC,OAAON,OAAOM,KAAK;IACrB;IAEA,IAAIpB,WAAWO,MAAM,CAACC,IAAI,CAACa,wBAAwB,EAAE;QACnD,OAAOP,OAAOM,KAAK;IACrB;IAEA,OAAOE,SAASC,IAAI,CAClB;QACEC,SAASrB,EAAE;QACX,GAAGW,MAAM;IACX,GACA;QACEW,SAAS3B,gBAAgB;YACvB2B,SAAS,IAAIC,QAAQ;gBACnB,cAAcT;YAChB;YACAhB;QACF;QACA0B,QAAQjC,WAAWkC,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"registerFirstUser.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,iBAAiB,EAAE,sBAoC/B,CAAA"}
1
+ {"version":3,"file":"registerFirstUser.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/registerFirstUser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,iBAAiB,EAAE,sBA6C/B,CAAA"}
@@ -3,12 +3,19 @@ import { generatePayloadCookie, registerFirstUserOperation } from 'payload';
3
3
  import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
4
  export const registerFirstUser = async ({ collection, req })=>{
5
5
  const { data, t } = req;
6
+ const authData = collection.config.auth?.loginWithUsername ? {
7
+ email: typeof req.data?.email === 'string' ? req.data.email : '',
8
+ password: typeof req.data?.password === 'string' ? req.data.password : '',
9
+ username: typeof req.data?.username === 'string' ? req.data.username : ''
10
+ } : {
11
+ email: typeof req.data?.email === 'string' ? req.data.email : '',
12
+ password: typeof req.data?.password === 'string' ? req.data.password : ''
13
+ };
6
14
  const result = await registerFirstUserOperation({
7
15
  collection,
8
16
  data: {
9
17
  ...data,
10
- email: typeof data?.email === 'string' ? data.email : '',
11
- password: typeof data?.password === 'string' ? data.password : ''
18
+ ...authData
12
19
  },
13
20
  req
14
21
  });
@@ -1 +1 @@
1
- {"version":3,"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\n const result = await registerFirstUserOperation({\n collection,\n data: {\n ...data,\n email: typeof data?.email === 'string' ? data.email : '',\n password: typeof data?.password === 'string' ? data.password : '',\n },\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionConfig: collection.config,\n payload: req.payload,\n token: result.token,\n })\n\n return Response.json(\n {\n exp: result.exp,\n message: t('authentication:successfullyRegisteredFirstUser'),\n token: result.token,\n user: result.user,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","generatePayloadCookie","registerFirstUserOperation","headersWithCors","registerFirstUser","collection","req","data","t","result","email","password","cookie","collectionConfig","config","payload","token","Response","json","exp","message","user","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ,UAAS;AAI3E,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,oBAA4C,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACjF,MAAM,EAAEC,IAAI,EAAEC,CAAC,EAAE,GAAGF;IAEpB,MAAMG,SAAS,MAAMP,2BAA2B;QAC9CG;QACAE,MAAM;YACJ,GAAGA,IAAI;YACPG,OAAO,OAAOH,MAAMG,UAAU,WAAWH,KAAKG,KAAK,GAAG;YACtDC,UAAU,OAAOJ,MAAMI,aAAa,WAAWJ,KAAKI,QAAQ,GAAG;QACjE;QACAL;IACF;IAEA,MAAMM,SAASX,sBAAsB;QACnCY,kBAAkBR,WAAWS,MAAM;QACnCC,SAAST,IAAIS,OAAO;QACpBC,OAAOP,OAAOO,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEC,KAAKV,OAAOU,GAAG;QACfC,SAASZ,EAAE;QACXQ,OAAOP,OAAOO,KAAK;QACnBK,MAAMZ,OAAOY,IAAI;IACnB,GACA;QACEC,SAASnB,gBAAgB;YACvBmB,SAAS,IAAIC,QAAQ;gBACnB,cAAcX;YAChB;YACAN;QACF;QACAkB,QAAQxB,WAAWyB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"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"],"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"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ,UAAS;AAI3E,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,oBAA4C,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACjF,MAAM,EAAEC,IAAI,EAAEC,CAAC,EAAE,GAAGF;IACpB,MAAMG,WAAWJ,WAAWK,MAAM,CAACC,IAAI,EAAEC,oBACrC;QACEC,OAAO,OAAOP,IAAIC,IAAI,EAAEM,UAAU,WAAWP,IAAIC,IAAI,CAACM,KAAK,GAAG;QAC9DC,UAAU,OAAOR,IAAIC,IAAI,EAAEO,aAAa,WAAWR,IAAIC,IAAI,CAACO,QAAQ,GAAG;QACvEC,UAAU,OAAOT,IAAIC,IAAI,EAAEQ,aAAa,WAAWT,IAAIC,IAAI,CAACQ,QAAQ,GAAG;IACzE,IACA;QACEF,OAAO,OAAOP,IAAIC,IAAI,EAAEM,UAAU,WAAWP,IAAIC,IAAI,CAACM,KAAK,GAAG;QAC9DC,UAAU,OAAOR,IAAIC,IAAI,EAAEO,aAAa,WAAWR,IAAIC,IAAI,CAACO,QAAQ,GAAG;IACzE;IAEJ,MAAME,SAAS,MAAMd,2BAA2B;QAC9CG;QACAE,MAAM;YACJ,GAAGA,IAAI;YACP,GAAGE,QAAQ;QACb;QACAH;IACF;IAEA,MAAMW,SAAShB,sBAAsB;QACnCiB,kBAAkBb,WAAWK,MAAM;QACnCS,SAASb,IAAIa,OAAO;QACpBC,OAAOJ,OAAOI,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEC,KAAKP,OAAOO,GAAG;QACfC,SAAShB,EAAE;QACXY,OAAOJ,OAAOI,KAAK;QACnBK,MAAMT,OAAOS,IAAI;IACnB,GACA;QACEC,SAASvB,gBAAgB;YACvBuB,SAAS,IAAIC,QAAQ;gBACnB,cAAcV;YAChB;YACAX;QACF;QACAsB,QAAQ5B,WAAW6B,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/unlock.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBAqBpB,CAAA"}
1
+ {"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/unlock.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBA+BpB,CAAA"}
@@ -3,11 +3,15 @@ import { unlockOperation } from 'payload';
3
3
  import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
4
  export const unlock = async ({ collection, req })=>{
5
5
  const { t } = req;
6
+ const authData = collection.config.auth?.loginWithUsername !== false ? {
7
+ email: typeof req.data?.email === 'string' ? req.data.email : '',
8
+ username: typeof req.data?.username === 'string' ? req.data.username : ''
9
+ } : {
10
+ email: typeof req.data?.email === 'string' ? req.data.email : ''
11
+ };
6
12
  await unlockOperation({
7
13
  collection,
8
- data: {
9
- email: req.data.email
10
- },
14
+ data: authData,
11
15
  req
12
16
  });
13
17
  return Response.json({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/auth/unlock.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { unlockOperation } from 'payload'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const unlock: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n\n await unlockOperation({\n collection,\n data: { email: req.data.email as string },\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","unlockOperation","headersWithCors","unlock","collection","req","t","data","email","Response","json","message","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,UAAS;AAIzC,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,CAAC,EAAE,GAAGD;IAEd,MAAMJ,gBAAgB;QACpBG;QACAG,MAAM;YAAEC,OAAOH,IAAIE,IAAI,CAACC,KAAK;QAAW;QACxCH;IACF;IAEA,OAAOI,SAASC,IAAI,CAClB;QACEC,SAASL,EAAE;IACb,GACA;QACEM,SAASV,gBAAgB;YACvBU,SAAS,IAAIC;YACbR;QACF;QACAS,QAAQd,WAAWe,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/auth/unlock.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { unlockOperation } from 'payload'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const unlock: CollectionRouteHandler = async ({ collection, req }) => {\n const { t } = req\n\n const authData =\n collection.config.auth?.loginWithUsername !== false\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n }\n\n await unlockOperation({\n collection,\n data: authData,\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","unlockOperation","headersWithCors","unlock","collection","req","t","authData","config","auth","loginWithUsername","email","data","username","Response","json","message","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,UAAS;AAIzC,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,CAAC,EAAE,GAAGD;IAEd,MAAME,WACJH,WAAWI,MAAM,CAACC,IAAI,EAAEC,sBAAsB,QAC1C;QACEC,OAAO,OAAON,IAAIO,IAAI,EAAED,UAAU,WAAWN,IAAIO,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOR,IAAIO,IAAI,EAAEC,aAAa,WAAWR,IAAIO,IAAI,CAACC,QAAQ,GAAG;IACzE,IACA;QACEF,OAAO,OAAON,IAAIO,IAAI,EAAED,UAAU,WAAWN,IAAIO,IAAI,CAACD,KAAK,GAAG;IAChE;IAEN,MAAMV,gBAAgB;QACpBG;QACAQ,MAAML;QACNF;IACF;IAEA,OAAOS,SAASC,IAAI,CAClB;QACEC,SAASV,EAAE;IACb,GACA;QACEW,SAASf,gBAAgB;YACvBe,SAAS,IAAIC;YACbb;QACF;QACAc,QAAQnB,WAAWoB,EAAE;IACvB;AAEJ,EAAC"}
@@ -9,7 +9,7 @@ export const verifyEmail = async ({ id, collection, req })=>{
9
9
  token: id
10
10
  });
11
11
  return Response.json({
12
- message: t('authentication:emailVerified')
12
+ message: t('authentication:accountVerified')
13
13
  }, {
14
14
  headers: headersWithCors({
15
15
  headers: new Headers(),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { verifyEmailOperation } from 'payload'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const verifyEmail: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { t } = req\n await verifyEmailOperation({\n collection,\n req,\n token: id,\n })\n\n return Response.json(\n {\n message: t('authentication:emailVerified'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","verifyEmailOperation","headersWithCors","verifyEmail","id","collection","req","t","token","Response","json","message","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,oBAAoB,QAAQ,UAAS;AAI9C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,cAA4C,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrF,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAML,qBAAqB;QACzBI;QACAC;QACAE,OAAOJ;IACT;IAEA,OAAOK,SAASC,IAAI,CAClB;QACEC,SAASJ,EAAE;IACb,GACA;QACEK,SAASV,gBAAgB;YACvBU,SAAS,IAAIC;YACbP;QACF;QACAQ,QAAQd,WAAWe,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { verifyEmailOperation } from 'payload'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const verifyEmail: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { t } = req\n await verifyEmailOperation({\n collection,\n req,\n token: id,\n })\n\n return Response.json(\n {\n message: t('authentication:accountVerified'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","verifyEmailOperation","headersWithCors","verifyEmail","id","collection","req","t","token","Response","json","message","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,oBAAoB,QAAQ,UAAS;AAI9C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,cAA4C,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrF,MAAM,EAAEC,CAAC,EAAE,GAAGD;IACd,MAAML,qBAAqB;QACzBI;QACAC;QACAE,OAAOJ;IACT;IAEA,OAAOK,SAASC,IAAI,CAClB;QACEC,SAASJ,EAAE;IACb,GACA;QACEK,SAASV,gBAAgB;YACvBU,SAAS,IAAIC;YACbP;QACF;QACAQ,QAAQd,WAAWe,EAAE;IACvB;AAEJ,EAAC"}
@@ -1,5 +1,5 @@
1
- import type { PayloadRequestWithData } from 'payload';
1
+ import type { PayloadRequest } from 'payload';
2
2
  export declare const buildFormState: ({ req }: {
3
- req: PayloadRequestWithData;
3
+ req: PayloadRequest;
4
4
  }) => Promise<Response>;
5
5
  //# sourceMappingURL=buildFormState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/buildFormState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAQrD,eAAO,MAAM,cAAc,YAAmB;IAAE,GAAG,EAAE,sBAAsB,CAAA;CAAE,sBAyC5E,CAAA"}
1
+ {"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/buildFormState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAQ7C,eAAO,MAAM,cAAc,YAAmB;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,sBAyCpE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/routes/rest/buildFormState.ts"],"sourcesContent":["import type { PayloadRequestWithData } from 'payload'\n\nimport { buildFormState as buildFormStateFn } from '@payloadcms/ui/utilities/buildFormState'\nimport httpStatus from 'http-status'\n\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { routeError } from './routeError.js'\n\nexport const buildFormState = async ({ req }: { req: PayloadRequestWithData }) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const result = await buildFormStateFn({ req })\n\n return Response.json(result, {\n headers,\n status: httpStatus.OK,\n })\n } catch (err) {\n if (err.message === 'Could not find field schema for given path') {\n return Response.json(\n {\n message: err.message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n if (err.message === 'Unauthorized') {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n return routeError({\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"names":["buildFormState","buildFormStateFn","httpStatus","headersWithCors","routeError","req","headers","Headers","result","Response","json","status","OK","err","message","BAD_REQUEST","UNAUTHORIZED","payload","logger","error","msg","config"],"mappings":"AAEA,SAASA,kBAAkBC,gBAAgB,QAAQ,0CAAyC;AAC5F,OAAOC,gBAAgB,cAAa;AAEpC,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,OAAO,MAAMJ,iBAAiB,OAAO,EAAEK,GAAG,EAAmC;IAC3E,MAAMC,UAAUH,gBAAgB;QAC9BG,SAAS,IAAIC;QACbF;IACF;IAEA,IAAI;QACF,MAAMG,SAAS,MAAMP,iBAAiB;YAAEI;QAAI;QAE5C,OAAOI,SAASC,IAAI,CAACF,QAAQ;YAC3BF;YACAK,QAAQT,WAAWU,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZ,IAAIA,IAAIC,OAAO,KAAK,8CAA8C;YAChE,OAAOL,SAASC,IAAI,CAClB;gBACEI,SAASD,IAAIC,OAAO;YACtB,GACA;gBACER;gBACAK,QAAQT,WAAWa,WAAW;YAChC;QAEJ;QAEA,IAAIF,IAAIC,OAAO,KAAK,gBAAgB;YAClC,OAAOL,SAASC,IAAI,CAAC,MAAM;gBACzBJ;gBACAK,QAAQT,WAAWc,YAAY;YACjC;QACF;QAEAX,IAAIY,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;YAAEN;YAAKO,KAAK,CAAC,sCAAsC,CAAC;QAAC;QAE9E,OAAOhB,WAAW;YAChBiB,QAAQhB,IAAIY,OAAO,CAACI,MAAM;YAC1BR;YACAR;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/routes/rest/buildFormState.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { buildFormState as buildFormStateFn } from '@payloadcms/ui/utilities/buildFormState'\nimport httpStatus from 'http-status'\n\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { routeError } from './routeError.js'\n\nexport const buildFormState = async ({ req }: { req: PayloadRequest }) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const result = await buildFormStateFn({ req })\n\n return Response.json(result, {\n headers,\n status: httpStatus.OK,\n })\n } catch (err) {\n if (err.message === 'Could not find field schema for given path') {\n return Response.json(\n {\n message: err.message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n if (err.message === 'Unauthorized') {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n return routeError({\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"names":["buildFormState","buildFormStateFn","httpStatus","headersWithCors","routeError","req","headers","Headers","result","Response","json","status","OK","err","message","BAD_REQUEST","UNAUTHORIZED","payload","logger","error","msg","config"],"mappings":"AAEA,SAASA,kBAAkBC,gBAAgB,QAAQ,0CAAyC;AAC5F,OAAOC,gBAAgB,cAAa;AAEpC,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,OAAO,MAAMJ,iBAAiB,OAAO,EAAEK,GAAG,EAA2B;IACnE,MAAMC,UAAUH,gBAAgB;QAC9BG,SAAS,IAAIC;QACbF;IACF;IAEA,IAAI;QACF,MAAMG,SAAS,MAAMP,iBAAiB;YAAEI;QAAI;QAE5C,OAAOI,SAASC,IAAI,CAACF,QAAQ;YAC3BF;YACAK,QAAQT,WAAWU,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZ,IAAIA,IAAIC,OAAO,KAAK,8CAA8C;YAChE,OAAOL,SAASC,IAAI,CAClB;gBACEI,SAASD,IAAIC,OAAO;YACtB,GACA;gBACER;gBACAK,QAAQT,WAAWa,WAAW;YAChC;QAEJ;QAEA,IAAIF,IAAIC,OAAO,KAAK,gBAAgB;YAClC,OAAOL,SAASC,IAAI,CAAC,MAAM;gBACzBJ;gBACAK,QAAQT,WAAWc,YAAY;YACjC;QACF;QAEAX,IAAIY,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;YAAEN;YAAKO,KAAK,CAAC,sCAAsC,CAAC;QAAC;QAE9E,OAAOhB,WAAW;YAChBiB,QAAQhB,IAAIY,OAAO,CAACI,MAAM;YAC1BR;YACAR;QACF;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/restoreVersion.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,cAAc,EAAE,4BAkC5B,CAAA"}
1
+ {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/restoreVersion.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,cAAc,EAAE,4BAoC5B,CAAA"}
@@ -6,6 +6,7 @@ import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
6
6
  export const restoreVersion = async ({ id: incomingID, collection, req })=>{
7
7
  const { searchParams } = req;
8
8
  const depth = searchParams.get('depth');
9
+ const draft = searchParams.get('draft');
9
10
  const id = sanitizeCollectionID({
10
11
  id: incomingID,
11
12
  collectionSlug: collection.config.slug,
@@ -15,6 +16,7 @@ export const restoreVersion = async ({ id: incomingID, collection, req })=>{
15
16
  id,
16
17
  collection,
17
18
  depth: isNumber(depth) ? Number(depth) : undefined,
19
+ draft: draft === 'true' ? true : undefined,
18
20
  req
19
21
  });
20
22
  return Response.json({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { restoreVersionOperation } 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 restoreVersion: 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 result = await restoreVersionOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n return Response.json(\n {\n ...result,\n message: req.t('version:restoredSuccessfully'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","restoreVersionOperation","isNumber","headersWithCors","sanitizeCollectionID","restoreVersion","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","Response","json","message","t","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,uBAAuB,QAAQ,UAAS;AACjD,SAASC,QAAQ,QAAQ,iBAAgB;AAIzC,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,iBAA+C,OAAO,EACjEC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJM,gBAAgBL,WAAWM,MAAM,CAACC,IAAI;QACtCC,SAASP,IAAIO,OAAO;IACtB;IAEA,MAAMC,SAAS,MAAMhB,wBAAwB;QAC3CK;QACAE;QACAG,OAAOT,SAASS,SAASO,OAAOP,SAASQ;QACzCV;IACF;IAEA,OAAOW,SAASC,IAAI,CAClB;QACE,GAAGJ,MAAM;QACTK,SAASb,IAAIc,CAAC,CAAC;IACjB,GACA;QACEC,SAASrB,gBAAgB;YACvBqB,SAAS,IAAIC;YACbhB;QACF;QACAiB,QAAQ1B,WAAW2B,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { restoreVersionOperation } 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 restoreVersion: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const draft = searchParams.get('draft')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const result = await restoreVersionOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true' ? true : undefined,\n req,\n })\n\n return Response.json(\n {\n ...result,\n message: req.t('version:restoredSuccessfully'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","restoreVersionOperation","isNumber","headersWithCors","sanitizeCollectionID","restoreVersion","id","incomingID","collection","req","searchParams","depth","get","draft","collectionSlug","config","slug","payload","result","Number","undefined","Response","json","message","t","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,uBAAuB,QAAQ,UAAS;AACjD,SAASC,QAAQ,QAAQ,iBAAgB;AAIzC,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,iBAA+C,OAAO,EACjEC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAC/B,MAAMC,QAAQH,aAAaE,GAAG,CAAC;IAE/B,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJO,gBAAgBN,WAAWO,MAAM,CAACC,IAAI;QACtCC,SAASR,IAAIQ,OAAO;IACtB;IAEA,MAAMC,SAAS,MAAMjB,wBAAwB;QAC3CK;QACAE;QACAG,OAAOT,SAASS,SAASQ,OAAOR,SAASS;QACzCP,OAAOA,UAAU,SAAS,OAAOO;QACjCX;IACF;IAEA,OAAOY,SAASC,IAAI,CAClB;QACE,GAAGJ,MAAM;QACTK,SAASd,IAAIe,CAAC,CAAC;IACjB,GACA;QACEC,SAAStB,gBAAgB;YACvBsB,SAAS,IAAIC;YACbjB;QACF;QACAkB,QAAQ3B,WAAW4B,EAAE;IACvB;AAEJ,EAAC"}
@@ -1,7 +1,7 @@
1
- import type { Collection, PayloadRequestWithData, TypeWithID } from 'payload';
1
+ import type { Collection, PayloadRequest, TypeWithID } from 'payload';
2
2
  export declare function checkFileAccess({ collection, filename, req, }: {
3
3
  collection: Collection;
4
4
  filename: string;
5
- req: PayloadRequestWithData;
5
+ req: PayloadRequest;
6
6
  }): Promise<Response | TypeWithID>;
7
7
  //# sourceMappingURL=checkFileAccess.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkFileAccess.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/files/checkFileAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,EAAS,MAAM,SAAS,CAAA;AAMpF,wBAAsB,eAAe,CAAC,EACpC,UAAU,EACV,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,sBAAsB,CAAA;CAC5B,GAAG,OAAO,CAAC,QAAQ,GAAG,UAAU,CAAC,CA6CjC"}
1
+ {"version":3,"file":"checkFileAccess.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/files/checkFileAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAS,MAAM,SAAS,CAAA;AAM5E,wBAAsB,eAAe,CAAC,EACpC,UAAU,EACV,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,OAAO,CAAC,QAAQ,GAAG,UAAU,CAAC,CA6CjC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/files/checkFileAccess.ts"],"sourcesContent":["import type { Collection, PayloadRequestWithData, TypeWithID, Where } from 'payload'\n\nimport { Forbidden, executeAccess } from 'payload'\n\nimport { endpointsAreDisabled } from '../checkEndpoints.js'\n\nexport async function checkFileAccess({\n collection,\n filename,\n req,\n}: {\n collection: Collection\n filename: string\n req: PayloadRequestWithData\n}): Promise<Response | TypeWithID> {\n const { config } = collection\n const disableEndpoints = endpointsAreDisabled({ endpoints: config.endpoints, request: req })\n if (disableEndpoints) return disableEndpoints\n\n const accessResult = await executeAccess({ isReadingStaticFile: true, req }, config.access.read)\n\n if (typeof accessResult === 'object') {\n const queryToBuild: Where = {\n and: [\n {\n or: [\n {\n filename: {\n equals: filename,\n },\n },\n ],\n },\n accessResult,\n ],\n }\n\n if (config.upload.imageSizes) {\n config.upload.imageSizes.forEach(({ name }) => {\n queryToBuild.and[0].or.push({\n [`sizes.${name}.filename`]: {\n equals: filename,\n },\n })\n })\n }\n\n const doc = await req.payload.db.findOne({\n collection: config.slug,\n req,\n where: queryToBuild,\n })\n\n if (!doc) {\n throw new Forbidden(req.t)\n }\n\n return doc\n }\n}\n"],"names":["Forbidden","executeAccess","endpointsAreDisabled","checkFileAccess","collection","filename","req","config","disableEndpoints","endpoints","request","accessResult","isReadingStaticFile","access","read","queryToBuild","and","or","equals","upload","imageSizes","forEach","name","push","doc","payload","db","findOne","slug","where","t"],"mappings":"AAEA,SAASA,SAAS,EAAEC,aAAa,QAAQ,UAAS;AAElD,SAASC,oBAAoB,QAAQ,uBAAsB;AAE3D,OAAO,eAAeC,gBAAgB,EACpCC,UAAU,EACVC,QAAQ,EACRC,GAAG,EAKJ;IACC,MAAM,EAAEC,MAAM,EAAE,GAAGH;IACnB,MAAMI,mBAAmBN,qBAAqB;QAAEO,WAAWF,OAAOE,SAAS;QAAEC,SAASJ;IAAI;IAC1F,IAAIE,kBAAkB,OAAOA;IAE7B,MAAMG,eAAe,MAAMV,cAAc;QAAEW,qBAAqB;QAAMN;IAAI,GAAGC,OAAOM,MAAM,CAACC,IAAI;IAE/F,IAAI,OAAOH,iBAAiB,UAAU;QACpC,MAAMI,eAAsB;YAC1BC,KAAK;gBACH;oBACEC,IAAI;wBACF;4BACEZ,UAAU;gCACRa,QAAQb;4BACV;wBACF;qBACD;gBACH;gBACAM;aACD;QACH;QAEA,IAAIJ,OAAOY,MAAM,CAACC,UAAU,EAAE;YAC5Bb,OAAOY,MAAM,CAACC,UAAU,CAACC,OAAO,CAAC,CAAC,EAAEC,IAAI,EAAE;gBACxCP,aAAaC,GAAG,CAAC,EAAE,CAACC,EAAE,CAACM,IAAI,CAAC;oBAC1B,CAAC,CAAC,MAAM,EAAED,KAAK,SAAS,CAAC,CAAC,EAAE;wBAC1BJ,QAAQb;oBACV;gBACF;YACF;QACF;QAEA,MAAMmB,MAAM,MAAMlB,IAAImB,OAAO,CAACC,EAAE,CAACC,OAAO,CAAC;YACvCvB,YAAYG,OAAOqB,IAAI;YACvBtB;YACAuB,OAAOd;QACT;QAEA,IAAI,CAACS,KAAK;YACR,MAAM,IAAIxB,UAAUM,IAAIwB,CAAC;QAC3B;QAEA,OAAON;IACT;AACF"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/files/checkFileAccess.ts"],"sourcesContent":["import type { Collection, PayloadRequest, TypeWithID, Where } from 'payload'\n\nimport { Forbidden, executeAccess } from 'payload'\n\nimport { endpointsAreDisabled } from '../checkEndpoints.js'\n\nexport async function checkFileAccess({\n collection,\n filename,\n req,\n}: {\n collection: Collection\n filename: string\n req: PayloadRequest\n}): Promise<Response | TypeWithID> {\n const { config } = collection\n const disableEndpoints = endpointsAreDisabled({ endpoints: config.endpoints, request: req })\n if (disableEndpoints) return disableEndpoints\n\n const accessResult = await executeAccess({ isReadingStaticFile: true, req }, config.access.read)\n\n if (typeof accessResult === 'object') {\n const queryToBuild: Where = {\n and: [\n {\n or: [\n {\n filename: {\n equals: filename,\n },\n },\n ],\n },\n accessResult,\n ],\n }\n\n if (config.upload.imageSizes) {\n config.upload.imageSizes.forEach(({ name }) => {\n queryToBuild.and[0].or.push({\n [`sizes.${name}.filename`]: {\n equals: filename,\n },\n })\n })\n }\n\n const doc = await req.payload.db.findOne({\n collection: config.slug,\n req,\n where: queryToBuild,\n })\n\n if (!doc) {\n throw new Forbidden(req.t)\n }\n\n return doc\n }\n}\n"],"names":["Forbidden","executeAccess","endpointsAreDisabled","checkFileAccess","collection","filename","req","config","disableEndpoints","endpoints","request","accessResult","isReadingStaticFile","access","read","queryToBuild","and","or","equals","upload","imageSizes","forEach","name","push","doc","payload","db","findOne","slug","where","t"],"mappings":"AAEA,SAASA,SAAS,EAAEC,aAAa,QAAQ,UAAS;AAElD,SAASC,oBAAoB,QAAQ,uBAAsB;AAE3D,OAAO,eAAeC,gBAAgB,EACpCC,UAAU,EACVC,QAAQ,EACRC,GAAG,EAKJ;IACC,MAAM,EAAEC,MAAM,EAAE,GAAGH;IACnB,MAAMI,mBAAmBN,qBAAqB;QAAEO,WAAWF,OAAOE,SAAS;QAAEC,SAASJ;IAAI;IAC1F,IAAIE,kBAAkB,OAAOA;IAE7B,MAAMG,eAAe,MAAMV,cAAc;QAAEW,qBAAqB;QAAMN;IAAI,GAAGC,OAAOM,MAAM,CAACC,IAAI;IAE/F,IAAI,OAAOH,iBAAiB,UAAU;QACpC,MAAMI,eAAsB;YAC1BC,KAAK;gBACH;oBACEC,IAAI;wBACF;4BACEZ,UAAU;gCACRa,QAAQb;4BACV;wBACF;qBACD;gBACH;gBACAM;aACD;QACH;QAEA,IAAIJ,OAAOY,MAAM,CAACC,UAAU,EAAE;YAC5Bb,OAAOY,MAAM,CAACC,UAAU,CAACC,OAAO,CAAC,CAAC,EAAEC,IAAI,EAAE;gBACxCP,aAAaC,GAAG,CAAC,EAAE,CAACC,EAAE,CAACM,IAAI,CAAC;oBAC1B,CAAC,CAAC,MAAM,EAAED,KAAK,SAAS,CAAC,CAAC,EAAE;wBAC1BJ,QAAQb;oBACV;gBACF;YACF;QACF;QAEA,MAAMmB,MAAM,MAAMlB,IAAImB,OAAO,CAACC,EAAE,CAACC,OAAO,CAAC;YACvCvB,YAAYG,OAAOqB,IAAI;YACvBtB;YACAuB,OAAOd;QACT;QAEA,IAAI,CAACS,KAAK;YACR,MAAM,IAAIxB,UAAUM,IAAIwB,CAAC;QAC3B;QAEA,OAAON;IACT;AACF"}
@@ -1,8 +1,8 @@
1
- import type { Collection, PayloadRequestWithData } from 'payload';
1
+ import type { Collection, PayloadRequest } from 'payload';
2
2
  type Args = {
3
3
  collection: Collection;
4
4
  filename: string;
5
- req: PayloadRequestWithData;
5
+ req: PayloadRequest;
6
6
  };
7
7
  export declare const getFile: ({ collection, filename, req }: Args) => Promise<Response>;
8
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/files/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAejE,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,sBAAsB,CAAA;CAC5B,CAAA;AACD,eAAO,MAAM,OAAO,kCAAyC,IAAI,KAAG,OAAO,CAAC,QAAQ,CA4DnF,CAAA"}
1
+ {"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/files/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAezD,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AACD,eAAO,MAAM,OAAO,kCAAyC,IAAI,KAAG,OAAO,CAAC,QAAQ,CA4DnF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/files/getFile.ts"],"sourcesContent":["import type { Collection, PayloadRequestWithData } from 'payload'\n\nimport { fileTypeFromFile } from 'file-type'\nimport fsPromises from 'fs/promises'\nimport httpStatus from 'http-status'\nimport path from 'path'\nimport { APIError } from 'payload'\n\nimport { streamFile } from '../../../fetchAPI-stream-file/index.js'\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\nimport { checkFileAccess } from './checkFileAccess.js'\nimport { getFileTypeFallback } from './getFileTypeFallback.js'\n\n// /:collectionSlug/file/:filename\ntype Args = {\n collection: Collection\n filename: string\n req: PayloadRequestWithData\n}\nexport const getFile = async ({ collection, filename, req }: Args): Promise<Response> => {\n try {\n if (!collection.config.upload) {\n throw new APIError(\n `This collection is not an upload collection: ${collection.config.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n const accessResult = await checkFileAccess({\n collection,\n filename,\n req,\n })\n\n if (accessResult instanceof Response) return accessResult\n\n if (collection.config.upload.handlers?.length) {\n let customResponse = null\n for (const handler of collection.config.upload.handlers) {\n customResponse = await handler(req, {\n doc: accessResult,\n params: {\n collection: collection.config.slug,\n filename,\n },\n })\n }\n\n if (customResponse instanceof Response) return customResponse\n }\n\n const fileDir = collection.config.upload?.staticDir || collection.config.slug\n const filePath = path.resolve(`${fileDir}/${filename}`)\n const stats = await fsPromises.stat(filePath)\n const data = streamFile(filePath)\n const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)\n\n let headers = new Headers()\n headers.set('Content-Type', fileTypeResult.mime)\n headers.set('Content-Length', stats.size + '')\n headers = collection.config.upload?.modifyResponseHeaders\n ? collection.config.upload.modifyResponseHeaders({ headers })\n : headers\n\n return new Response(data, {\n headers: headersWithCors({\n headers,\n req,\n }),\n status: httpStatus.OK,\n })\n } catch (err) {\n return routeError({\n collection,\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"names":["fileTypeFromFile","fsPromises","httpStatus","path","APIError","streamFile","headersWithCors","routeError","checkFileAccess","getFileTypeFallback","getFile","collection","filename","req","config","upload","slug","BAD_REQUEST","accessResult","Response","handlers","length","customResponse","handler","doc","params","fileDir","staticDir","filePath","resolve","stats","stat","data","fileTypeResult","headers","Headers","set","mime","size","modifyResponseHeaders","status","OK","err","payload"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,YAAW;AAC5C,OAAOC,gBAAgB,cAAa;AACpC,OAAOC,gBAAgB,cAAa;AACpC,OAAOC,UAAU,OAAM;AACvB,SAASC,QAAQ,QAAQ,UAAS;AAElC,SAASC,UAAU,QAAQ,yCAAwC;AACnE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,UAAU,QAAQ,mBAAkB;AAC7C,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,mBAAmB,QAAQ,2BAA0B;AAQ9D,OAAO,MAAMC,UAAU,OAAO,EAAEC,UAAU,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,OAAO,IAAIf,SAASa,MAAM;YACxBE,SAAS5B,gBAAgB;gBACvB4B;gBACArB;YACF;YACA2B,QAAQtC,WAAWuC,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZ,OAAOnC,WAAW;YAChBI;YACAG,QAAQD,IAAI8B,OAAO,CAAC7B,MAAM;YAC1B4B;YACA7B;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/files/getFile.ts"],"sourcesContent":["import type { Collection, PayloadRequest } from 'payload'\n\nimport { fileTypeFromFile } from 'file-type'\nimport fsPromises from 'fs/promises'\nimport httpStatus from 'http-status'\nimport path from 'path'\nimport { APIError } from 'payload'\n\nimport { streamFile } from '../../../fetchAPI-stream-file/index.js'\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\nimport { checkFileAccess } from './checkFileAccess.js'\nimport { getFileTypeFallback } from './getFileTypeFallback.js'\n\n// /:collectionSlug/file/:filename\ntype Args = {\n collection: Collection\n filename: string\n req: PayloadRequest\n}\nexport const getFile = async ({ collection, filename, req }: Args): Promise<Response> => {\n try {\n if (!collection.config.upload) {\n throw new APIError(\n `This collection is not an upload collection: ${collection.config.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n const accessResult = await checkFileAccess({\n collection,\n filename,\n req,\n })\n\n if (accessResult instanceof Response) return accessResult\n\n if (collection.config.upload.handlers?.length) {\n let customResponse = null\n for (const handler of collection.config.upload.handlers) {\n customResponse = await handler(req, {\n doc: accessResult,\n params: {\n collection: collection.config.slug,\n filename,\n },\n })\n }\n\n if (customResponse instanceof Response) return customResponse\n }\n\n const fileDir = collection.config.upload?.staticDir || collection.config.slug\n const filePath = path.resolve(`${fileDir}/${filename}`)\n const stats = await fsPromises.stat(filePath)\n const data = streamFile(filePath)\n const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)\n\n let headers = new Headers()\n headers.set('Content-Type', fileTypeResult.mime)\n headers.set('Content-Length', stats.size + '')\n headers = collection.config.upload?.modifyResponseHeaders\n ? collection.config.upload.modifyResponseHeaders({ headers })\n : headers\n\n return new Response(data, {\n headers: headersWithCors({\n headers,\n req,\n }),\n status: httpStatus.OK,\n })\n } catch (err) {\n return routeError({\n collection,\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"names":["fileTypeFromFile","fsPromises","httpStatus","path","APIError","streamFile","headersWithCors","routeError","checkFileAccess","getFileTypeFallback","getFile","collection","filename","req","config","upload","slug","BAD_REQUEST","accessResult","Response","handlers","length","customResponse","handler","doc","params","fileDir","staticDir","filePath","resolve","stats","stat","data","fileTypeResult","headers","Headers","set","mime","size","modifyResponseHeaders","status","OK","err","payload"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,YAAW;AAC5C,OAAOC,gBAAgB,cAAa;AACpC,OAAOC,gBAAgB,cAAa;AACpC,OAAOC,UAAU,OAAM;AACvB,SAASC,QAAQ,QAAQ,UAAS;AAElC,SAASC,UAAU,QAAQ,yCAAwC;AACnE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,UAAU,QAAQ,mBAAkB;AAC7C,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,mBAAmB,QAAQ,2BAA0B;AAQ9D,OAAO,MAAMC,UAAU,OAAO,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,GAAG,EAAQ;IAC/D,IAAI;QACF,IAAI,CAACF,WAAWG,MAAM,CAACC,MAAM,EAAE;YAC7B,MAAM,IAAIX,SACR,CAAC,6CAA6C,EAAEO,WAAWG,MAAM,CAACE,IAAI,CAAC,CAAC,EACxEd,WAAWe,WAAW;QAE1B;QAEA,MAAMC,eAAe,MAAMV,gBAAgB;YACzCG;YACAC;YACAC;QACF;QAEA,IAAIK,wBAAwBC,UAAU,OAAOD;QAE7C,IAAIP,WAAWG,MAAM,CAACC,MAAM,CAACK,QAAQ,EAAEC,QAAQ;YAC7C,IAAIC,iBAAiB;YACrB,KAAK,MAAMC,WAAWZ,WAAWG,MAAM,CAACC,MAAM,CAACK,QAAQ,CAAE;gBACvDE,iBAAiB,MAAMC,QAAQV,KAAK;oBAClCW,KAAKN;oBACLO,QAAQ;wBACNd,YAAYA,WAAWG,MAAM,CAACE,IAAI;wBAClCJ;oBACF;gBACF;YACF;YAEA,IAAIU,0BAA0BH,UAAU,OAAOG;QACjD;QAEA,MAAMI,UAAUf,WAAWG,MAAM,CAACC,MAAM,EAAEY,aAAahB,WAAWG,MAAM,CAACE,IAAI;QAC7E,MAAMY,WAAWzB,KAAK0B,OAAO,CAAC,CAAC,EAAEH,QAAQ,CAAC,EAAEd,SAAS,CAAC;QACtD,MAAMkB,QAAQ,MAAM7B,WAAW8B,IAAI,CAACH;QACpC,MAAMI,OAAO3B,WAAWuB;QACxB,MAAMK,iBAAiB,AAAC,MAAMjC,iBAAiB4B,aAAcnB,oBAAoBmB;QAEjF,IAAIM,UAAU,IAAIC;QAClBD,QAAQE,GAAG,CAAC,gBAAgBH,eAAeI,IAAI;QAC/CH,QAAQE,GAAG,CAAC,kBAAkBN,MAAMQ,IAAI,GAAG;QAC3CJ,UAAUvB,WAAWG,MAAM,CAACC,MAAM,EAAEwB,wBAChC5B,WAAWG,MAAM,CAACC,MAAM,CAACwB,qBAAqB,CAAC;YAAEL;QAAQ,KACzDA;QAEJ,OAAO,IAAIf,SAASa,MAAM;YACxBE,SAAS5B,gBAAgB;gBACvB4B;gBACArB;YACF;YACA2B,QAAQtC,WAAWuC,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZ,OAAOnC,WAAW;YAChBI;YACAG,QAAQD,IAAI8B,OAAO,CAAC7B,MAAM;YAC1B4B;YACA7B;QACF;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/globals/restoreVersion.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAI3D,eAAO,MAAM,cAAc,EAAE,wBAwB5B,CAAA"}
1
+ {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/globals/restoreVersion.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAI3D,eAAO,MAAM,cAAc,EAAE,wBA0B5B,CAAA"}
@@ -5,9 +5,11 @@ import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
5
  export const restoreVersion = async ({ id, globalConfig, req })=>{
6
6
  const { searchParams } = req;
7
7
  const depth = searchParams.get('depth');
8
+ const draft = searchParams.get('draft');
8
9
  const doc = await restoreVersionOperationGlobal({
9
10
  id,
10
11
  depth: isNumber(depth) ? Number(depth) : undefined,
12
+ draft: draft === 'true' ? true : undefined,
11
13
  globalConfig,
12
14
  req
13
15
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/globals/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { restoreVersionOperationGlobal } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { GlobalRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const restoreVersion: GlobalRouteHandlerWithID = async ({ id, globalConfig, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const doc = await restoreVersionOperationGlobal({\n id,\n depth: isNumber(depth) ? Number(depth) : undefined,\n globalConfig,\n req,\n })\n\n return Response.json(\n {\n doc,\n message: req.t('version:restoredSuccessfully'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","restoreVersionOperationGlobal","isNumber","headersWithCors","restoreVersion","id","globalConfig","req","searchParams","depth","get","doc","Number","undefined","Response","json","message","t","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,6BAA6B,QAAQ,UAAS;AACvD,SAASC,QAAQ,QAAQ,iBAAgB;AAIzC,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,iBAA2C,OAAO,EAAEC,EAAE,EAAEC,YAAY,EAAEC,GAAG,EAAE;IACtF,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMC,MAAM,MAAMV,8BAA8B;QAC9CI;QACAI,OAAOP,SAASO,SAASG,OAAOH,SAASI;QACzCP;QACAC;IACF;IAEA,OAAOO,SAASC,IAAI,CAClB;QACEJ;QACAK,SAAST,IAAIU,CAAC,CAAC;IACjB,GACA;QACEC,SAASf,gBAAgB;YACvBe,SAAS,IAAIC;YACbZ;QACF;QACAa,QAAQpB,WAAWqB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/globals/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { restoreVersionOperationGlobal } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { GlobalRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const restoreVersion: GlobalRouteHandlerWithID = async ({ id, globalConfig, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const draft = searchParams.get('draft')\n\n const doc = await restoreVersionOperationGlobal({\n id,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true' ? true : undefined,\n globalConfig,\n req,\n })\n\n return Response.json(\n {\n doc,\n message: req.t('version:restoredSuccessfully'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","restoreVersionOperationGlobal","isNumber","headersWithCors","restoreVersion","id","globalConfig","req","searchParams","depth","get","draft","doc","Number","undefined","Response","json","message","t","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,6BAA6B,QAAQ,UAAS;AACvD,S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