@payloadcms/next 3.0.0-alpha.60 → 3.0.0-alpha.62

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 (376) hide show
  1. package/dist/cjs/withPayload.cjs +95 -0
  2. package/dist/cjs/withPayload.cjs.map +1 -0
  3. package/dist/config.js.map +1 -1
  4. package/dist/elements/LeaveWithoutSaving/index.js.map +1 -1
  5. package/dist/elements/LeaveWithoutSaving/usePreventLeave.js.map +1 -1
  6. package/dist/exports/layouts.js.map +1 -1
  7. package/dist/exports/routes.d.ts +1 -1
  8. package/dist/exports/routes.d.ts.map +1 -1
  9. package/dist/exports/routes.js +1 -1
  10. package/dist/exports/routes.js.map +1 -1
  11. package/dist/exports/utilities.d.ts +4 -1
  12. package/dist/exports/utilities.d.ts.map +1 -1
  13. package/dist/exports/utilities.js +4 -1
  14. package/dist/exports/utilities.js.map +1 -1
  15. package/dist/exports/views.js.map +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/layouts/Root/index.d.ts.map +1 -1
  18. package/dist/layouts/Root/index.js +51 -28
  19. package/dist/layouts/Root/index.js.map +1 -1
  20. package/dist/next-fileupload/fileFactory.js.map +1 -1
  21. package/dist/next-fileupload/handlers.js.map +1 -1
  22. package/dist/next-fileupload/index.js.map +1 -1
  23. package/dist/next-fileupload/isEligibleRequest.js +1 -1
  24. package/dist/next-fileupload/isEligibleRequest.js.map +1 -1
  25. package/dist/next-fileupload/processMultipart.d.ts.map +1 -1
  26. package/dist/next-fileupload/processMultipart.js +29 -6
  27. package/dist/next-fileupload/processMultipart.js.map +1 -1
  28. package/dist/next-fileupload/processNested.js.map +1 -1
  29. package/dist/next-fileupload/uploadTimer.js.map +1 -1
  30. package/dist/next-fileupload/utilities.d.ts.map +1 -1
  31. package/dist/next-fileupload/utilities.js +4 -4
  32. package/dist/next-fileupload/utilities.js.map +1 -1
  33. package/dist/next-stream-file/index.js.map +1 -1
  34. package/dist/prod/styles.css +1 -1
  35. package/dist/routes/graphql/handler.d.ts.map +1 -1
  36. package/dist/routes/graphql/handler.js +8 -3
  37. package/dist/routes/graphql/handler.js.map +1 -1
  38. package/dist/routes/graphql/index.js.map +1 -1
  39. package/dist/routes/graphql/playground.js.map +1 -1
  40. package/dist/routes/index.js.map +1 -1
  41. package/dist/routes/rest/auth/access.d.ts.map +1 -1
  42. package/dist/routes/rest/auth/access.js +5 -0
  43. package/dist/routes/rest/auth/access.js.map +1 -1
  44. package/dist/routes/rest/auth/forgotPassword.d.ts.map +1 -1
  45. package/dist/routes/rest/auth/forgotPassword.js +7 -2
  46. package/dist/routes/rest/auth/forgotPassword.js.map +1 -1
  47. package/dist/routes/rest/auth/init.d.ts.map +1 -1
  48. package/dist/routes/rest/auth/init.js +6 -0
  49. package/dist/routes/rest/auth/init.js.map +1 -1
  50. package/dist/routes/rest/auth/login.d.ts.map +1 -1
  51. package/dist/routes/rest/auth/login.js +8 -5
  52. package/dist/routes/rest/auth/login.js.map +1 -1
  53. package/dist/routes/rest/auth/logout.d.ts.map +1 -1
  54. package/dist/routes/rest/auth/logout.js +12 -7
  55. package/dist/routes/rest/auth/logout.js.map +1 -1
  56. package/dist/routes/rest/auth/me.d.ts.map +1 -1
  57. package/dist/routes/rest/auth/me.js +5 -0
  58. package/dist/routes/rest/auth/me.js.map +1 -1
  59. package/dist/routes/rest/auth/refresh.d.ts.map +1 -1
  60. package/dist/routes/rest/auth/refresh.js +11 -7
  61. package/dist/routes/rest/auth/refresh.js.map +1 -1
  62. package/dist/routes/rest/auth/registerFirstUser.d.ts.map +1 -1
  63. package/dist/routes/rest/auth/registerFirstUser.js +17 -5
  64. package/dist/routes/rest/auth/registerFirstUser.js.map +1 -1
  65. package/dist/routes/rest/auth/resetPassword.d.ts.map +1 -1
  66. package/dist/routes/rest/auth/resetPassword.js +8 -5
  67. package/dist/routes/rest/auth/resetPassword.js.map +1 -1
  68. package/dist/routes/rest/auth/unlock.d.ts.map +1 -1
  69. package/dist/routes/rest/auth/unlock.js +7 -2
  70. package/dist/routes/rest/auth/unlock.js.map +1 -1
  71. package/dist/routes/rest/auth/verifyEmail.d.ts.map +1 -1
  72. package/dist/routes/rest/auth/verifyEmail.js +7 -2
  73. package/dist/routes/rest/auth/verifyEmail.js.map +1 -1
  74. package/dist/routes/rest/buildFormState.d.ts +2 -2
  75. package/dist/routes/rest/buildFormState.d.ts.map +1 -1
  76. package/dist/routes/rest/buildFormState.js +19 -4
  77. package/dist/routes/rest/buildFormState.js.map +1 -1
  78. package/dist/routes/rest/checkEndpoints.js.map +1 -1
  79. package/dist/routes/rest/collections/count.d.ts +3 -0
  80. package/dist/routes/rest/collections/count.d.ts.map +1 -0
  81. package/dist/routes/rest/collections/count.js +15 -0
  82. package/dist/routes/rest/collections/count.js.map +1 -0
  83. package/dist/routes/rest/collections/create.d.ts.map +1 -1
  84. package/dist/routes/rest/collections/create.js +5 -0
  85. package/dist/routes/rest/collections/create.js.map +1 -1
  86. package/dist/routes/rest/collections/delete.d.ts.map +1 -1
  87. package/dist/routes/rest/collections/delete.js +7 -0
  88. package/dist/routes/rest/collections/delete.js.map +1 -1
  89. package/dist/routes/rest/collections/deleteByID.d.ts.map +1 -1
  90. package/dist/routes/rest/collections/deleteByID.js +14 -1
  91. package/dist/routes/rest/collections/deleteByID.js.map +1 -1
  92. package/dist/routes/rest/collections/docAccess.d.ts.map +1 -1
  93. package/dist/routes/rest/collections/docAccess.js +5 -0
  94. package/dist/routes/rest/collections/docAccess.js.map +1 -1
  95. package/dist/routes/rest/collections/duplicate.d.ts.map +1 -1
  96. package/dist/routes/rest/collections/duplicate.js +12 -1
  97. package/dist/routes/rest/collections/duplicate.js.map +1 -1
  98. package/dist/routes/rest/collections/find.d.ts.map +1 -1
  99. package/dist/routes/rest/collections/find.js +5 -0
  100. package/dist/routes/rest/collections/find.js.map +1 -1
  101. package/dist/routes/rest/collections/findByID.d.ts.map +1 -1
  102. package/dist/routes/rest/collections/findByID.js +12 -1
  103. package/dist/routes/rest/collections/findByID.js.map +1 -1
  104. package/dist/routes/rest/collections/findVersionByID.d.ts.map +1 -1
  105. package/dist/routes/rest/collections/findVersionByID.js +12 -1
  106. package/dist/routes/rest/collections/findVersionByID.js.map +1 -1
  107. package/dist/routes/rest/collections/findVersions.d.ts.map +1 -1
  108. package/dist/routes/rest/collections/findVersions.js +5 -0
  109. package/dist/routes/rest/collections/findVersions.js.map +1 -1
  110. package/dist/routes/rest/collections/preview.d.ts.map +1 -1
  111. package/dist/routes/rest/collections/preview.js +11 -2
  112. package/dist/routes/rest/collections/preview.js.map +1 -1
  113. package/dist/routes/rest/collections/restoreVersion.d.ts.map +1 -1
  114. package/dist/routes/rest/collections/restoreVersion.js +12 -1
  115. package/dist/routes/rest/collections/restoreVersion.js.map +1 -1
  116. package/dist/routes/rest/collections/update.d.ts.map +1 -1
  117. package/dist/routes/rest/collections/update.js +7 -0
  118. package/dist/routes/rest/collections/update.js.map +1 -1
  119. package/dist/routes/rest/collections/updateByID.d.ts.map +1 -1
  120. package/dist/routes/rest/collections/updateByID.js +12 -1
  121. package/dist/routes/rest/collections/updateByID.js.map +1 -1
  122. package/dist/routes/rest/files/checkFileAccess.js.map +1 -1
  123. package/dist/routes/rest/files/getFile.d.ts.map +1 -1
  124. package/dist/routes/rest/files/getFile.js +15 -8
  125. package/dist/routes/rest/files/getFile.js.map +1 -1
  126. package/dist/routes/rest/files/getFileTypeFallback.d.ts +7 -0
  127. package/dist/routes/rest/files/getFileTypeFallback.d.ts.map +1 -0
  128. package/dist/routes/rest/files/getFileTypeFallback.js +21 -0
  129. package/dist/routes/rest/files/getFileTypeFallback.js.map +1 -0
  130. package/dist/routes/rest/globals/docAccess.d.ts.map +1 -1
  131. package/dist/routes/rest/globals/docAccess.js +5 -0
  132. package/dist/routes/rest/globals/docAccess.js.map +1 -1
  133. package/dist/routes/rest/globals/findOne.d.ts.map +1 -1
  134. package/dist/routes/rest/globals/findOne.js +5 -0
  135. package/dist/routes/rest/globals/findOne.js.map +1 -1
  136. package/dist/routes/rest/globals/findVersionByID.d.ts.map +1 -1
  137. package/dist/routes/rest/globals/findVersionByID.js +5 -0
  138. package/dist/routes/rest/globals/findVersionByID.js.map +1 -1
  139. package/dist/routes/rest/globals/findVersions.d.ts.map +1 -1
  140. package/dist/routes/rest/globals/findVersions.js +5 -0
  141. package/dist/routes/rest/globals/findVersions.js.map +1 -1
  142. package/dist/routes/rest/globals/preview.d.ts.map +1 -1
  143. package/dist/routes/rest/globals/preview.js +11 -2
  144. package/dist/routes/rest/globals/preview.js.map +1 -1
  145. package/dist/routes/rest/globals/restoreVersion.d.ts.map +1 -1
  146. package/dist/routes/rest/globals/restoreVersion.js +5 -0
  147. package/dist/routes/rest/globals/restoreVersion.js.map +1 -1
  148. package/dist/routes/rest/globals/update.d.ts.map +1 -1
  149. package/dist/routes/rest/globals/update.js +5 -0
  150. package/dist/routes/rest/globals/update.js.map +1 -1
  151. package/dist/routes/rest/index.d.ts +1 -0
  152. package/dist/routes/rest/index.d.ts.map +1 -1
  153. package/dist/routes/rest/index.js +51 -5
  154. package/dist/routes/rest/index.js.map +1 -1
  155. package/dist/routes/rest/routeError.d.ts +4 -3
  156. package/dist/routes/rest/routeError.d.ts.map +1 -1
  157. package/dist/routes/rest/routeError.js +23 -9
  158. package/dist/routes/rest/routeError.js.map +1 -1
  159. package/dist/routes/rest/types.js.map +1 -1
  160. package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts +9 -0
  161. package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts.map +1 -0
  162. package/dist/routes/rest/utilities/sanitizeCollectionID.js +13 -0
  163. package/dist/routes/rest/utilities/sanitizeCollectionID.js.map +1 -0
  164. package/dist/scss/app.scss +2 -3
  165. package/dist/scss/vars.scss +0 -7
  166. package/dist/utilities/buildFieldSchemaMap/index.d.ts +2 -2
  167. package/dist/utilities/buildFieldSchemaMap/index.d.ts.map +1 -1
  168. package/dist/utilities/buildFieldSchemaMap/index.js +3 -1
  169. package/dist/utilities/buildFieldSchemaMap/index.js.map +1 -1
  170. package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts +3 -1
  171. package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts.map +1 -1
  172. package/dist/utilities/buildFieldSchemaMap/traverseFields.js +6 -1
  173. package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +1 -1
  174. package/dist/utilities/buildFieldSchemaMap/types.js.map +1 -1
  175. package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
  176. package/dist/utilities/createPayloadRequest.js +2 -4
  177. package/dist/utilities/createPayloadRequest.js.map +1 -1
  178. package/dist/utilities/getDataAndFile.d.ts.map +1 -1
  179. package/dist/utilities/getDataAndFile.js +26 -42
  180. package/dist/utilities/getDataAndFile.js.map +1 -1
  181. package/dist/utilities/getNextRequestI18n.d.ts +11 -0
  182. package/dist/utilities/getNextRequestI18n.d.ts.map +1 -0
  183. package/dist/utilities/getNextRequestI18n.js +18 -0
  184. package/dist/utilities/getNextRequestI18n.js.map +1 -0
  185. package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
  186. package/dist/utilities/getPayloadHMR.js +2 -1
  187. package/dist/utilities/getPayloadHMR.js.map +1 -1
  188. package/dist/utilities/getRequestLanguage.d.ts +3 -2
  189. package/dist/utilities/getRequestLanguage.d.ts.map +1 -1
  190. package/dist/utilities/getRequestLanguage.js +13 -5
  191. package/dist/utilities/getRequestLanguage.js.map +1 -1
  192. package/dist/utilities/getRequestLocales.js.map +1 -1
  193. package/dist/utilities/headersWithCors.d.ts +8 -0
  194. package/dist/utilities/headersWithCors.d.ts.map +1 -0
  195. package/dist/utilities/headersWithCors.js +17 -0
  196. package/dist/utilities/headersWithCors.js.map +1 -0
  197. package/dist/utilities/initPage.d.ts.map +1 -1
  198. package/dist/utilities/initPage.js +18 -7
  199. package/dist/utilities/initPage.js.map +1 -1
  200. package/dist/utilities/meta.js.map +1 -1
  201. package/dist/utilities/timestamp.js.map +1 -1
  202. package/dist/views/API/RenderJSON/index.js.map +1 -1
  203. package/dist/views/API/index.client.js +2 -2
  204. package/dist/views/API/index.client.js.map +1 -1
  205. package/dist/views/API/index.js.map +1 -1
  206. package/dist/views/API/meta.js.map +1 -1
  207. package/dist/views/Account/Settings/index.js.map +1 -1
  208. package/dist/views/Account/ToggleTheme/index.js.map +1 -1
  209. package/dist/views/Account/index.js.map +1 -1
  210. package/dist/views/Account/meta.js.map +1 -1
  211. package/dist/views/CreateFirstUser/index.client.js +2 -2
  212. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  213. package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
  214. package/dist/views/CreateFirstUser/index.js +28 -1
  215. package/dist/views/CreateFirstUser/index.js.map +1 -1
  216. package/dist/views/CreateFirstUser/meta.js.map +1 -1
  217. package/dist/views/Dashboard/Default/index.client.js.map +1 -1
  218. package/dist/views/Dashboard/Default/index.js.map +1 -1
  219. package/dist/views/Dashboard/index.js.map +1 -1
  220. package/dist/views/Dashboard/meta.js.map +1 -1
  221. package/dist/views/Document/getCustomViewByKey.js.map +1 -1
  222. package/dist/views/Document/getCustomViewByRoute.js.map +1 -1
  223. package/dist/views/Document/getMetaBySegment.js +2 -2
  224. package/dist/views/Document/getMetaBySegment.js.map +1 -1
  225. package/dist/views/Document/getViewsFromConfig.js.map +1 -1
  226. package/dist/views/Document/index.js.map +1 -1
  227. package/dist/views/Document/meta.js.map +1 -1
  228. package/dist/views/Edit/Default/Auth/APIKey.js.map +1 -1
  229. package/dist/views/Edit/Default/Auth/index.js.map +1 -1
  230. package/dist/views/Edit/Default/Auth/types.js.map +1 -1
  231. package/dist/views/Edit/Default/{SetStepNav → SetDocumentStepNav}/index.d.ts +1 -1
  232. package/dist/views/Edit/Default/SetDocumentStepNav/index.d.ts.map +1 -0
  233. package/dist/views/Edit/Default/{SetStepNav → SetDocumentStepNav}/index.js +12 -5
  234. package/dist/views/Edit/Default/SetDocumentStepNav/index.js.map +1 -0
  235. package/dist/views/Edit/Default/SetDocumentTitle/index.js.map +1 -1
  236. package/dist/views/Edit/Default/index.d.ts.map +1 -1
  237. package/dist/views/Edit/Default/index.js +5 -4
  238. package/dist/views/Edit/Default/index.js.map +1 -1
  239. package/dist/views/Edit/Default/types.js.map +1 -1
  240. package/dist/views/Edit/index.client.js.map +1 -1
  241. package/dist/views/Edit/index.js.map +1 -1
  242. package/dist/views/Edit/meta.js.map +1 -1
  243. package/dist/views/Edit/sanitizeEditViewProps.js.map +1 -1
  244. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts +3 -0
  245. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -0
  246. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +55 -0
  247. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -0
  248. package/dist/views/ForgotPassword/index.d.ts.map +1 -1
  249. package/dist/views/ForgotPassword/index.js +3 -39
  250. package/dist/views/ForgotPassword/index.js.map +1 -1
  251. package/dist/views/ForgotPassword/meta.js.map +1 -1
  252. package/dist/views/List/Default/index.js.map +1 -1
  253. package/dist/views/List/Default/types.js.map +1 -1
  254. package/dist/views/List/index.d.ts.map +1 -1
  255. package/dist/views/List/index.js +6 -3
  256. package/dist/views/List/index.js.map +1 -1
  257. package/dist/views/List/meta.js.map +1 -1
  258. package/dist/views/LivePreview/Context/collisionDetection.js.map +1 -1
  259. package/dist/views/LivePreview/Context/context.js.map +1 -1
  260. package/dist/views/LivePreview/Context/index.js.map +1 -1
  261. package/dist/views/LivePreview/Context/sizeReducer.js.map +1 -1
  262. package/dist/views/LivePreview/Device/index.js.map +1 -1
  263. package/dist/views/LivePreview/DeviceContainer/index.js.map +1 -1
  264. package/dist/views/LivePreview/IFrame/index.js.map +1 -1
  265. package/dist/views/LivePreview/Preview/index.js.map +1 -1
  266. package/dist/views/LivePreview/Toolbar/Controls/index.d.ts.map +1 -1
  267. package/dist/views/LivePreview/Toolbar/Controls/index.js +6 -4
  268. package/dist/views/LivePreview/Toolbar/Controls/index.js.map +1 -1
  269. package/dist/views/LivePreview/Toolbar/SizeInput/index.js.map +1 -1
  270. package/dist/views/LivePreview/Toolbar/index.js.map +1 -1
  271. package/dist/views/LivePreview/ToolbarArea/index.js.map +1 -1
  272. package/dist/views/LivePreview/index.client.js +2 -2
  273. package/dist/views/LivePreview/index.client.js.map +1 -1
  274. package/dist/views/LivePreview/index.js.map +1 -1
  275. package/dist/views/LivePreview/meta.js.map +1 -1
  276. package/dist/views/LivePreview/usePopupWindow.js.map +1 -1
  277. package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
  278. package/dist/views/Login/LoginForm/index.js +26 -2
  279. package/dist/views/Login/LoginForm/index.js.map +1 -1
  280. package/dist/views/Login/index.js.map +1 -1
  281. package/dist/views/Login/meta.js.map +1 -1
  282. package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
  283. package/dist/views/Logout/LogoutClient.js +1 -2
  284. package/dist/views/Logout/LogoutClient.js.map +1 -1
  285. package/dist/views/Logout/index.js.map +1 -1
  286. package/dist/views/Logout/meta.js.map +1 -1
  287. package/dist/views/NotFound/index.client.js.map +1 -1
  288. package/dist/views/NotFound/index.d.ts.map +1 -1
  289. package/dist/views/NotFound/index.js +2 -2
  290. package/dist/views/NotFound/index.js.map +1 -1
  291. package/dist/views/NotFound/meta.js.map +1 -1
  292. package/dist/views/ResetPassword/index.js.map +1 -1
  293. package/dist/views/ResetPassword/meta.js.map +1 -1
  294. package/dist/views/Root/getCustomViewByRoute.js.map +1 -1
  295. package/dist/views/Root/getViewFromConfig.js.map +1 -1
  296. package/dist/views/Root/index.js.map +1 -1
  297. package/dist/views/Root/isPathMatchingRoute.js.map +1 -1
  298. package/dist/views/Root/meta.js +2 -2
  299. package/dist/views/Root/meta.js.map +1 -1
  300. package/dist/views/Unauthorized/index.js.map +1 -1
  301. package/dist/views/Unauthorized/meta.js.map +1 -1
  302. package/dist/views/Verify/index.js.map +1 -1
  303. package/dist/views/Verify/meta.js.map +1 -1
  304. package/dist/views/Version/Default/SetStepNav.d.ts.map +1 -1
  305. package/dist/views/Version/Default/SetStepNav.js +10 -2
  306. package/dist/views/Version/Default/SetStepNav.js.map +1 -1
  307. package/dist/views/Version/Default/index.js +5 -1
  308. package/dist/views/Version/Default/index.js.map +1 -1
  309. package/dist/views/Version/Default/types.js.map +1 -1
  310. package/dist/views/Version/RenderFieldsToDiff/Label/index.js.map +1 -1
  311. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
  312. package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js.map +1 -1
  313. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
  314. package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js.map +1 -1
  315. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
  316. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
  317. package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js.map +1 -1
  318. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
  319. package/dist/views/Version/RenderFieldsToDiff/fields/diffMethods.js.map +1 -1
  320. package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts +2 -2
  321. package/dist/views/Version/RenderFieldsToDiff/fields/index.js.map +1 -1
  322. package/dist/views/Version/RenderFieldsToDiff/fields/styles.js.map +1 -1
  323. package/dist/views/Version/RenderFieldsToDiff/fields/types.js.map +1 -1
  324. package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
  325. package/dist/views/Version/RenderFieldsToDiff/types.js.map +1 -1
  326. package/dist/views/Version/Restore/index.js.map +1 -1
  327. package/dist/views/Version/Restore/types.js.map +1 -1
  328. package/dist/views/Version/SelectComparison/index.js +5 -1
  329. package/dist/views/Version/SelectComparison/index.js.map +1 -1
  330. package/dist/views/Version/SelectComparison/types.js.map +1 -1
  331. package/dist/views/Version/SelectLocales/index.js.map +1 -1
  332. package/dist/views/Version/SelectLocales/types.js.map +1 -1
  333. package/dist/views/Version/index.js.map +1 -1
  334. package/dist/views/Version/meta.js +5 -1
  335. package/dist/views/Version/meta.js.map +1 -1
  336. package/dist/views/Version/shared.js.map +1 -1
  337. package/dist/views/Versions/buildColumns.js.map +1 -1
  338. package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
  339. package/dist/views/Versions/cells/CreatedAt/index.d.ts.map +1 -1
  340. package/dist/views/Versions/cells/CreatedAt/index.js +5 -1
  341. package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
  342. package/dist/views/Versions/cells/ID/index.js.map +1 -1
  343. package/dist/views/Versions/index.client.js.map +1 -1
  344. package/dist/views/Versions/index.js +3 -3
  345. package/dist/views/Versions/index.js.map +1 -1
  346. package/dist/views/Versions/meta.js.map +1 -1
  347. package/dist/views/Versions/types.js.map +1 -1
  348. package/dist/webpackEntry.js.map +1 -1
  349. package/dist/withPayload.d.ts +1 -2
  350. package/dist/withPayload.d.ts.map +1 -1
  351. package/dist/withPayload.js +5 -1
  352. package/dist/withPayload.js.map +1 -1
  353. package/package.json +16 -13
  354. package/dist/prod/payload/SuisseIntl-Bold.woff +0 -0
  355. package/dist/prod/payload/SuisseIntl-Bold.woff2 +0 -0
  356. package/dist/prod/payload/SuisseIntl-Medium.woff +0 -0
  357. package/dist/prod/payload/SuisseIntl-Medium.woff2 +0 -0
  358. package/dist/prod/payload/SuisseIntl-SemiBold.woff +0 -0
  359. package/dist/prod/payload/SuisseIntl-SemiBold.woff2 +0 -0
  360. package/dist/prod/payload/SuisseIntl.woff +0 -0
  361. package/dist/prod/payload/SuisseIntl.woff2 +0 -0
  362. package/dist/prod/payload/merriweather-v30-latin-900.woff +0 -0
  363. package/dist/prod/payload/merriweather-v30-latin-900.woff2 +0 -0
  364. package/dist/prod/payload/merriweather-v30-latin-900italic.woff +0 -0
  365. package/dist/prod/payload/merriweather-v30-latin-900italic.woff2 +0 -0
  366. package/dist/prod/payload/merriweather-v30-latin-italic.woff +0 -0
  367. package/dist/prod/payload/merriweather-v30-latin-italic.woff2 +0 -0
  368. package/dist/prod/payload/merriweather-v30-latin-regular.woff +0 -0
  369. package/dist/prod/payload/merriweather-v30-latin-regular.woff2 +0 -0
  370. package/dist/scss/fonts.scss +0 -75
  371. package/dist/utilities/getNextI18n.d.ts +0 -7
  372. package/dist/utilities/getNextI18n.d.ts.map +0 -1
  373. package/dist/utilities/getNextI18n.js +0 -16
  374. package/dist/utilities/getNextI18n.js.map +0 -1
  375. package/dist/views/Edit/Default/SetStepNav/index.d.ts.map +0 -1
  376. package/dist/views/Edit/Default/SetStepNav/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/auth/unlock.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { unlockOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const unlock: CollectionRouteHandler = async ({ collection, req }) => {\n await unlockOperation({\n collection,\n data: { email: req.data.email as string },\n req,\n })\n\n return Response.json(\n {\n // TODO(translate)\n message: 'Success',\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","unlockOperation","unlock","collection","req","data","email","Response","json","message","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAMH,gBAAgB;QACpBE;QACAE,MAAM;YAAEC,OAAOF,IAAIC,IAAI,CAACC,KAAK;QAAW;QACxCF;IACF;IAEA,OAAOG,SAASC,IAAI,CAClB;QACE,kBAAkB;QAClBC,SAAS;IACX,GACA;QACEC,QAAQV,WAAWW,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/auth/unlock.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { unlockOperation } from 'payload/operations'\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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,CAAC,EAAE,GAAGD;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 +1 @@
1
- {"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAE/D,eAAO,MAAM,WAAW,EAAE,4BAgBzB,CAAA"}
1
+ {"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,WAAW,EAAE,4BAoBzB,CAAA"}
@@ -1,15 +1,20 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { verifyEmailOperation } from 'payload/operations';
3
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
3
4
  export const verifyEmail = async ({ id, collection, req })=>{
5
+ const { t } = req;
4
6
  await verifyEmailOperation({
5
7
  collection,
6
8
  req,
7
9
  token: id
8
10
  });
9
11
  return Response.json({
10
- // TODO(translate)
11
- message: 'Email verified successfully.'
12
+ message: t('authentication:emailVerified')
12
13
  }, {
14
+ headers: headersWithCors({
15
+ headers: new Headers(),
16
+ req
17
+ }),
13
18
  status: httpStatus.OK
14
19
  });
15
20
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { verifyEmailOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nexport const verifyEmail: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n await verifyEmailOperation({\n collection,\n req,\n token: id,\n })\n\n return Response.json(\n {\n // TODO(translate)\n message: 'Email verified successfully.',\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","verifyEmailOperation","verifyEmail","id","collection","req","token","Response","json","message","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,oBAAoB,QAAQ,qBAAoB;AAIzD,OAAO,MAAMC,cAA4C,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrF,MAAMJ,qBAAqB;QACzBG;QACAC;QACAC,OAAOH;IACT;IAEA,OAAOI,SAASC,IAAI,CAClB;QACE,kBAAkB;QAClBC,SAAS;IACX,GACA;QACEC,QAAQV,WAAWW,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/auth/verifyEmail.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { verifyEmailOperation } from 'payload/operations'\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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,oBAAoB,QAAQ,qBAAoB;AAIzD,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,6 +1,6 @@
1
- import type { PayloadRequest, SanitizedConfig } from 'payload/types';
1
+ import type { PayloadRequest } from 'payload/types';
2
2
  import type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.js';
3
- export declare const getFieldSchemaMap: (config: SanitizedConfig) => FieldSchemaMap;
3
+ export declare const getFieldSchemaMap: (req: PayloadRequest) => FieldSchemaMap;
4
4
  export declare const buildFormState: ({ req }: {
5
5
  req: PayloadRequest;
6
6
  }) => Promise<Response>;
@@ -1 +1 @@
1
- {"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/buildFormState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,cAAc,EACd,eAAe,EAEhB,MAAM,eAAe,CAAA;AAMtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAA;AAWlF,eAAO,MAAM,iBAAiB,WAAY,eAAe,mBAQxD,CAAA;AAED,eAAO,MAAM,cAAc,YAAmB;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,sBA8KpE,CAAA"}
1
+ {"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/buildFormState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA8B,cAAc,EAAc,MAAM,eAAe,CAAA;AAM3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAA;AAYlF,eAAO,MAAM,iBAAiB,QAAS,cAAc,mBAQpD,CAAA;AAED,eAAO,MAAM,cAAc,YAAmB;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,sBAmMpE,CAAA"}
@@ -2,19 +2,24 @@ import { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'
2
2
  import { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues';
3
3
  import httpStatus from 'http-status';
4
4
  import { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js';
5
+ import { headersWithCors } from '../../utilities/headersWithCors.js';
5
6
  let cached = global._payload_fieldSchemaMap;
6
7
  if (!cached) {
7
8
  // eslint-disable-next-line no-multi-assign
8
9
  cached = global._payload_fieldSchemaMap = null;
9
10
  }
10
- export const getFieldSchemaMap = (config)=>{
11
+ export const getFieldSchemaMap = (req)=>{
11
12
  if (cached && process.env.NODE_ENV !== 'development') {
12
13
  return cached;
13
14
  }
14
- cached = buildFieldSchemaMap(config);
15
+ cached = buildFieldSchemaMap(req);
15
16
  return cached;
16
17
  };
17
18
  export const buildFormState = async ({ req })=>{
19
+ const headers = headersWithCors({
20
+ headers: new Headers(),
21
+ req
22
+ });
18
23
  try {
19
24
  const reqData = req.data;
20
25
  const { collectionSlug, formState, globalSlug, locale, operation, schemaPath } = reqData;
@@ -30,21 +35,24 @@ export const buildFormState = async ({ req })=>{
30
35
  });
31
36
  if (!canAccessAdmin) {
32
37
  return Response.json(null, {
38
+ headers,
33
39
  status: httpStatus.UNAUTHORIZED
34
40
  });
35
41
  }
36
42
  // Match the user collection to the global admin config
37
43
  } else if (adminUserSlug !== incomingUserSlug) {
38
44
  return Response.json(null, {
45
+ headers,
39
46
  status: httpStatus.UNAUTHORIZED
40
47
  });
41
48
  }
42
49
  } else {
43
50
  return Response.json(null, {
51
+ headers,
44
52
  status: httpStatus.UNAUTHORIZED
45
53
  });
46
54
  }
47
- const fieldSchemaMap = getFieldSchemaMap(req.payload.config);
55
+ const fieldSchemaMap = getFieldSchemaMap(req);
48
56
  const id = collectionSlug ? reqData.id : undefined;
49
57
  const schemaPathSegments = schemaPath.split('.');
50
58
  let fieldSchema;
@@ -61,6 +69,7 @@ export const buildFormState = async ({ req })=>{
61
69
  return Response.json({
62
70
  message: 'Could not find field schema for given path'
63
71
  }, {
72
+ headers,
64
73
  status: httpStatus.BAD_REQUEST
65
74
  });
66
75
  }
@@ -117,7 +126,7 @@ export const buildFormState = async ({ req })=>{
117
126
  user: req.user
118
127
  });
119
128
  }
120
- if (globalSlug) {
129
+ if (globalSlug && schemaPath === globalSlug) {
121
130
  resolvedData = await req.payload.findGlobal({
122
131
  slug: globalSlug,
123
132
  depth: 0,
@@ -145,13 +154,19 @@ export const buildFormState = async ({ req })=>{
145
154
  },
146
155
  req
147
156
  });
157
+ // Maintain form state of file
158
+ if (collectionSlug && req.payload.collections[collectionSlug]?.config?.upload && formState && formState.file) {
159
+ result.file = formState.file;
160
+ }
148
161
  return Response.json(result, {
162
+ headers,
149
163
  status: httpStatus.OK
150
164
  });
151
165
  } catch (err) {
152
166
  return Response.json({
153
167
  message: 'There was an error building form state'
154
168
  }, {
169
+ headers,
155
170
  status: httpStatus.BAD_REQUEST
156
171
  });
157
172
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/routes/rest/buildFormState.ts"],"sourcesContent":["import type { BuildFormStateArgs } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport type {\n DocumentPreferences,\n Field,\n PayloadRequest,\n SanitizedConfig,\n TypeWithID,\n} from 'payload/types'\n\nimport { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues'\nimport httpStatus from 'http-status'\n\nimport type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.js'\n\nimport { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js'\n\nlet cached = global._payload_fieldSchemaMap\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_fieldSchemaMap = null\n}\n\nexport const getFieldSchemaMap = (config: SanitizedConfig): FieldSchemaMap => {\n if (cached && process.env.NODE_ENV !== 'development') {\n return cached\n }\n\n cached = buildFieldSchemaMap(config)\n\n return cached\n}\n\nexport const buildFormState = async ({ req }: { req: PayloadRequest }) => {\n try {\n const reqData: BuildFormStateArgs = req.data as BuildFormStateArgs\n const { collectionSlug, formState, globalSlug, locale, operation, schemaPath } = reqData\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n return Response.json(null, {\n status: httpStatus.UNAUTHORIZED,\n })\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n return Response.json(null, {\n status: httpStatus.UNAUTHORIZED,\n })\n }\n } else {\n return Response.json(null, {\n status: httpStatus.UNAUTHORIZED,\n })\n }\n\n const fieldSchemaMap = getFieldSchemaMap(req.payload.config)\n\n const id = collectionSlug ? reqData.id : undefined\n const schemaPathSegments = schemaPath.split('.')\n\n let fieldSchema: Field[]\n\n if (schemaPathSegments.length === 1) {\n if (req.payload.collections[schemaPath]) {\n fieldSchema = req.payload.collections[schemaPath].config.fields\n } else {\n fieldSchema = req.payload.config.globals.find(\n (global) => global.slug === schemaPath,\n )?.fields\n }\n } else if (fieldSchemaMap.has(schemaPath)) {\n fieldSchema = fieldSchemaMap.get(schemaPath)\n }\n\n if (!fieldSchema) {\n return Response.json(\n {\n message: 'Could not find field schema for given path',\n },\n {\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n let docPreferences = reqData.docPreferences\n let data = reqData.data\n\n const promises: {\n data?: Promise<void>\n preferences?: Promise<void>\n } = {}\n\n // If the request does not include doc preferences,\n // we should fetch them. This is useful for DocumentInfoProvider\n // as it reduces the amount of client-side fetches necessary\n // when we fetch data for the Edit view\n if (!docPreferences) {\n let preferencesKey\n\n if (collectionSlug && id) {\n preferencesKey = `collection-${collectionSlug}-${id}`\n }\n\n if (globalSlug) {\n preferencesKey = `global-${globalSlug}`\n }\n\n if (preferencesKey) {\n const fetchPreferences = async () => {\n const preferencesResult = (await req.payload.find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n key: {\n equals: preferencesKey,\n },\n },\n })) as unknown as { docs: { value: DocumentPreferences }[] }\n\n if (preferencesResult?.docs?.[0]?.value) docPreferences = preferencesResult.docs[0].value\n }\n\n promises.preferences = fetchPreferences()\n }\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) data = reduceFieldsToValues(formState, true)\n\n // If we do not have data at this point,\n // we can fetch it. This is useful for DocumentInfoProvider\n // to reduce the amount of fetches required\n if (!data) {\n const fetchData = async () => {\n let resolvedData: TypeWithID\n\n if (collectionSlug && id) {\n resolvedData = await req.payload.findByID({\n id,\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n if (globalSlug) {\n resolvedData = await req.payload.findGlobal({\n slug: globalSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n data = resolvedData\n }\n\n promises.data = fetchData()\n }\n\n if (Object.keys(promises).length > 0) {\n await Promise.all(Object.values(promises))\n }\n\n const result = await buildStateFromSchema({\n id,\n data,\n fieldSchema,\n operation,\n preferences: docPreferences || { fields: {} },\n req,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n } catch (err) {\n return Response.json(\n {\n message: 'There was an error building form state',\n },\n {\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n}\n"],"names":["buildStateFromSchema","reduceFieldsToValues","httpStatus","buildFieldSchemaMap","cached","global","_payload_fieldSchemaMap","getFieldSchemaMap","config","process","env","NODE_ENV","buildFormState","req","reqData","data","collectionSlug","formState","globalSlug","locale","operation","schemaPath","incomingUserSlug","user","collection","adminUserSlug","payload","admin","adminAccessFunction","collections","access","canAccessAdmin","Response","json","status","UNAUTHORIZED","fieldSchemaMap","id","undefined","schemaPathSegments","split","fieldSchema","length","fields","globals","find","slug","has","get","message","BAD_REQUEST","docPreferences","promises","preferencesKey","fetchPreferences","preferencesResult","depth","limit","where","key","equals","docs","value","preferences","fetchData","resolvedData","findByID","draft","fallbackLocale","overrideAccess","findGlobal","Object","keys","Promise","all","values","result","OK","err"],"mappings":"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"}
1
+ {"version":3,"sources":["../../../src/routes/rest/buildFormState.ts"],"sourcesContent":["import type { BuildFormStateArgs } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport type { DocumentPreferences, Field, PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues'\nimport httpStatus from 'http-status'\n\nimport type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.js'\n\nimport { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nlet cached = global._payload_fieldSchemaMap\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_fieldSchemaMap = null\n}\n\nexport const getFieldSchemaMap = (req: PayloadRequest): FieldSchemaMap => {\n if (cached && process.env.NODE_ENV !== 'development') {\n return cached\n }\n\n cached = buildFieldSchemaMap(req)\n\n return cached\n}\n\nexport const buildFormState = async ({ req }: { req: PayloadRequest }) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const reqData: BuildFormStateArgs = req.data as BuildFormStateArgs\n const { collectionSlug, formState, globalSlug, locale, operation, schemaPath } = reqData\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n } else {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n\n const fieldSchemaMap = getFieldSchemaMap(req)\n\n const id = collectionSlug ? reqData.id : undefined\n const schemaPathSegments = schemaPath.split('.')\n\n let fieldSchema: Field[]\n\n if (schemaPathSegments.length === 1) {\n if (req.payload.collections[schemaPath]) {\n fieldSchema = req.payload.collections[schemaPath].config.fields\n } else {\n fieldSchema = req.payload.config.globals.find(\n (global) => global.slug === schemaPath,\n )?.fields\n }\n } else if (fieldSchemaMap.has(schemaPath)) {\n fieldSchema = fieldSchemaMap.get(schemaPath)\n }\n\n if (!fieldSchema) {\n return Response.json(\n {\n message: 'Could not find field schema for given path',\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n let docPreferences = reqData.docPreferences\n let data = reqData.data\n\n const promises: {\n data?: Promise<void>\n preferences?: Promise<void>\n } = {}\n\n // If the request does not include doc preferences,\n // we should fetch them. This is useful for DocumentInfoProvider\n // as it reduces the amount of client-side fetches necessary\n // when we fetch data for the Edit view\n if (!docPreferences) {\n let preferencesKey\n\n if (collectionSlug && id) {\n preferencesKey = `collection-${collectionSlug}-${id}`\n }\n\n if (globalSlug) {\n preferencesKey = `global-${globalSlug}`\n }\n\n if (preferencesKey) {\n const fetchPreferences = async () => {\n const preferencesResult = (await req.payload.find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n key: {\n equals: preferencesKey,\n },\n },\n })) as unknown as { docs: { value: DocumentPreferences }[] }\n\n if (preferencesResult?.docs?.[0]?.value) docPreferences = preferencesResult.docs[0].value\n }\n\n promises.preferences = fetchPreferences()\n }\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) data = reduceFieldsToValues(formState, true)\n\n // If we do not have data at this point,\n // we can fetch it. This is useful for DocumentInfoProvider\n // to reduce the amount of fetches required\n if (!data) {\n const fetchData = async () => {\n let resolvedData: TypeWithID\n\n if (collectionSlug && id) {\n resolvedData = await req.payload.findByID({\n id,\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n if (globalSlug && schemaPath === globalSlug) {\n resolvedData = await req.payload.findGlobal({\n slug: globalSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n data = resolvedData\n }\n\n promises.data = fetchData()\n }\n\n if (Object.keys(promises).length > 0) {\n await Promise.all(Object.values(promises))\n }\n\n const result = await buildStateFromSchema({\n id,\n data,\n fieldSchema,\n operation,\n preferences: docPreferences || { fields: {} },\n req,\n })\n\n // Maintain form state of file\n if (\n collectionSlug &&\n req.payload.collections[collectionSlug]?.config?.upload &&\n formState &&\n formState.file\n ) {\n result.file = formState.file\n }\n\n return Response.json(result, {\n headers,\n status: httpStatus.OK,\n })\n } catch (err) {\n return Response.json(\n {\n message: 'There was an error building form state',\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n}\n"],"names":["buildStateFromSchema","reduceFieldsToValues","httpStatus","buildFieldSchemaMap","headersWithCors","cached","global","_payload_fieldSchemaMap","getFieldSchemaMap","req","process","env","NODE_ENV","buildFormState","headers","Headers","reqData","data","collectionSlug","formState","globalSlug","locale","operation","schemaPath","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFunction","collections","access","canAccessAdmin","Response","json","status","UNAUTHORIZED","fieldSchemaMap","id","undefined","schemaPathSegments","split","fieldSchema","length","fields","globals","find","slug","has","get","message","BAD_REQUEST","docPreferences","promises","preferencesKey","fetchPreferences","preferencesResult","depth","limit","where","key","equals","docs","value","preferences","fetchData","resolvedData","findByID","draft","fallbackLocale","overrideAccess","findGlobal","Object","keys","Promise","all","values","result","upload","file","OK","err"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/routes/rest/checkEndpoints.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nexport const endpointsAreDisabled = ({\n endpoints,\n request,\n}: {\n endpoints: false | unknown[]\n request: Partial<Request>\n}) => {\n if (!endpoints) {\n return Response.json(\n {\n message: `Cannot ${request.method.toUpperCase()} ${request.url}`,\n },\n {\n status: httpStatus.NOT_IMPLEMENTED,\n },\n )\n }\n}\n"],"names":["httpStatus","endpointsAreDisabled","endpoints","request","Response","json","message","method","toUpperCase","url","status","NOT_IMPLEMENTED"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAEpC,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,SAAS,EACTC,OAAO,EAIR;IACC,IAAI,CAACD,WAAW;QACd,OAAOE,SAASC,IAAI,CAClB;YACEC,SAAS,CAAC,OAAO,EAAEH,QAAQI,MAAM,CAACC,WAAW,GAAG,CAAC,EAAEL,QAAQM,GAAG,CAAC,CAAC;QAClE,GACA;YACEC,QAAQV,WAAWW,eAAe;QACpC;IAEJ;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/routes/rest/checkEndpoints.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nexport const endpointsAreDisabled = ({\n endpoints,\n request,\n}: {\n endpoints: false | unknown[]\n request: Partial<Request>\n}) => {\n if (!endpoints) {\n return Response.json(\n {\n message: `Cannot ${request.method.toUpperCase()} ${request.url}`,\n },\n {\n status: httpStatus.NOT_IMPLEMENTED,\n },\n )\n }\n}\n"],"names":["httpStatus","endpointsAreDisabled","endpoints","request","Response","json","message","method","toUpperCase","url","status","NOT_IMPLEMENTED"],"rangeMappings":";;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAEpC,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,SAAS,EACTC,OAAO,EAIR;IACC,IAAI,CAACD,WAAW;QACd,OAAOE,SAASC,IAAI,CAClB;YACEC,SAAS,CAAC,OAAO,EAAEH,QAAQI,MAAM,CAACC,WAAW,GAAG,CAAC,EAAEL,QAAQM,GAAG,CAAC,CAAC;QAClE,GACA;YACEC,QAAQV,WAAWW,eAAe;QACpC;IAEJ;AACF,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CollectionRouteHandler } from '../types.js';
2
+ export declare const count: CollectionRouteHandler;
3
+ //# sourceMappingURL=count.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/count.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,KAAK,EAAE,sBAcnB,CAAA"}
@@ -0,0 +1,15 @@
1
+ import httpStatus from 'http-status';
2
+ import { countOperation } from 'payload/operations';
3
+ export const count = async ({ collection, req })=>{
4
+ const { where } = req.query;
5
+ const result = await countOperation({
6
+ collection,
7
+ req,
8
+ where
9
+ });
10
+ return Response.json(result, {
11
+ status: httpStatus.OK
12
+ });
13
+ };
14
+
15
+ //# sourceMappingURL=count.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/count.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport httpStatus from 'http-status'\nimport { countOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const count: CollectionRouteHandler = async ({ collection, req }) => {\n const { where } = req.query as {\n where?: Where\n }\n\n const result = await countOperation({\n collection,\n req,\n where,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","countOperation","count","collection","req","where","query","result","Response","json","status","OK"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,cAAc,QAAQ,qBAAoB;AAInD,OAAO,MAAMC,QAAgC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACrE,MAAM,EAAEC,KAAK,EAAE,GAAGD,IAAIE,KAAK;IAI3B,MAAMC,SAAS,MAAMN,eAAe;QAClCE;QACAC;QACAC;IACF;IAEA,OAAOG,SAASC,IAAI,CAACF,QAAQ;QAC3BG,QAAQV,WAAWW,EAAE;IACvB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,MAAM,EAAE,sBA0BpB,CAAA"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBA8BpB,CAAA"}
@@ -2,6 +2,7 @@ import { getTranslation } from '@payloadcms/translations';
2
2
  import httpStatus from 'http-status';
3
3
  import { createOperation } from 'payload/operations';
4
4
  import { isNumber } from 'payload/utilities';
5
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
6
  export const create = async ({ collection, req })=>{
6
7
  const { searchParams } = req;
7
8
  const autosave = searchParams.get('autosave') === 'true';
@@ -21,6 +22,10 @@ export const create = async ({ collection, req })=>{
21
22
  label: getTranslation(collection.config.labels.singular, req.i18n)
22
23
  })
23
24
  }, {
25
+ headers: headersWithCors({
26
+ headers: new Headers(),
27
+ req
28
+ }),
24
29
  status: httpStatus.CREATED
25
30
  });
26
31
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/create.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { createOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const create: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams } = req\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n const depth = searchParams.get('depth')\n\n const doc = await createOperation({\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? depth : undefined,\n draft,\n req,\n })\n\n return Response.json(\n {\n doc,\n message: req.t('general:successfullyCreated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n }),\n },\n {\n status: httpStatus.CREATED,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","createOperation","isNumber","create","collection","req","searchParams","autosave","get","draft","depth","doc","data","undefined","Response","json","message","t","label","config","labels","singular","i18n","status","CREATED"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,WAAWD,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAC5C,MAAME,QAAQJ,aAAaE,GAAG,CAAC;IAE/B,MAAMG,MAAM,MAAMV,gBAAgB;QAChCM;QACAH;QACAQ,MAAMP,IAAIO,IAAI;QACdF,OAAOR,SAASQ,SAASA,QAAQG;QACjCJ;QACAJ;IACF;IAEA,OAAOS,SAASC,IAAI,CAClB;QACEJ;QACAK,SAASX,IAAIY,CAAC,CAAC,+BAA+B;YAC5CC,OAAOnB,eAAeK,WAAWe,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEhB,IAAIiB,IAAI;QACnE;IACF,GACA;QACEC,QAAQvB,WAAWwB,OAAO;IAC5B;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/create.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { createOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const create: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams } = req\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n const depth = searchParams.get('depth')\n\n const doc = await createOperation({\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? depth : undefined,\n draft,\n req,\n })\n\n return Response.json(\n {\n doc,\n message: req.t('general:successfullyCreated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n }),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.CREATED,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","createOperation","isNumber","headersWithCors","create","collection","req","searchParams","autosave","get","draft","depth","doc","data","undefined","Response","json","message","t","label","config","labels","singular","i18n","headers","Headers","status","CREATED"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,WAAWD,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAC5C,MAAME,QAAQJ,aAAaE,GAAG,CAAC;IAE/B,MAAMG,MAAM,MAAMX,gBAAgB;QAChCO;QACAH;QACAQ,MAAMP,IAAIO,IAAI;QACdF,OAAOT,SAASS,SAASA,QAAQG;QACjCJ;QACAJ;IACF;IAEA,OAAOS,SAASC,IAAI,CAClB;QACEJ;QACAK,SAASX,IAAIY,CAAC,CAAC,+BAA+B;YAC5CC,OAAOpB,eAAeM,WAAWe,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEhB,IAAIiB,IAAI;QACnE;IACF,GACA;QACEC,SAASrB,gBAAgB;YACvBqB,SAAS,IAAIC;YACbnB;QACF;QACAoB,QAAQ1B,WAAW2B,OAAO;IAC5B;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/delete.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,SAAS,EAAE,sBAkDvB,CAAA"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/delete.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,SAAS,EAAE,sBAyDvB,CAAA"}
@@ -2,6 +2,7 @@ import { getTranslation } from '@payloadcms/translations';
2
2
  import httpStatus from 'http-status';
3
3
  import { deleteOperation } from 'payload/operations';
4
4
  import { isNumber } from 'payload/utilities';
5
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
6
  export const deleteDoc = async ({ collection, req })=>{
6
7
  const { depth, where } = req.query;
7
8
  const result = await deleteOperation({
@@ -10,6 +11,10 @@ export const deleteDoc = async ({ collection, req })=>{
10
11
  req,
11
12
  where
12
13
  });
14
+ const headers = headersWithCors({
15
+ headers: new Headers(),
16
+ req
17
+ });
13
18
  if (result.errors.length === 0) {
14
19
  const message = req.t('general:deletedCountSuccessfully', {
15
20
  count: result.docs.length,
@@ -19,6 +24,7 @@ export const deleteDoc = async ({ collection, req })=>{
19
24
  ...result,
20
25
  message
21
26
  }, {
27
+ headers,
22
28
  status: httpStatus.OK
23
29
  });
24
30
  }
@@ -32,6 +38,7 @@ export const deleteDoc = async ({ collection, req })=>{
32
38
  ...result,
33
39
  message
34
40
  }, {
41
+ headers,
35
42
  status: httpStatus.BAD_REQUEST
36
43
  });
37
44
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/delete.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { deleteOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const deleteDoc: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, where } = req.query as {\n depth?: string\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n where,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:deletedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n\n const message = req.t('error:unableToDeleteCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","deleteOperation","isNumber","deleteDoc","collection","req","depth","where","query","result","Number","undefined","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"mappings":"AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,YAAoC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACzE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF,IAAIG,KAAK;IAKlC,MAAMC,SAAS,MAAMR,gBAAgB;QACnCG;QACAE,OAAOJ,SAASI,SAASI,OAAOJ,SAASK;QACzCN;QACAE;IACF;IAEA,IAAIE,OAAOG,MAAM,CAACC,MAAM,KAAK,GAAG;QAC9B,MAAMC,UAAUT,IAAIU,CAAC,CAAC,oCAAoC;YACxDC,OAAOP,OAAOQ,IAAI,CAACJ,MAAM;YACzBK,OAAOnB,eACLK,WAAWe,MAAM,CAACC,MAAM,CAACX,OAAOQ,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxER,IAAIgB,IAAI;QAEZ;QAEA,OAAOC,SAASC,IAAI,CAClB;YACE,GAAGd,MAAM;YACTK;QACF,GACA;YACEU,QAAQxB,WAAWyB,EAAE;QACvB;IAEJ;IAEA,MAAMC,QAAQjB,OAAOQ,IAAI,CAACJ,MAAM,GAAGJ,OAAOG,MAAM,CAACC,MAAM;IAEvD,MAAMC,UAAUT,IAAIU,CAAC,CAAC,6BAA6B;QACjDC,OAAOP,OAAOG,MAAM,CAACC,MAAM;QAC3BK,OAAOnB,eAAeK,WAAWe,MAAM,CAACC,MAAM,CAACM,QAAQ,IAAI,WAAW,WAAW,EAAErB,IAAIgB,IAAI;QAC3FK;IACF;IAEA,OAAOJ,SAASC,IAAI,CAClB;QACE,GAAGd,MAAM;QACTK;IACF,GACA;QACEU,QAAQxB,WAAW2B,WAAW;IAChC;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/delete.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { deleteOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const deleteDoc: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, where } = req.query as {\n depth?: string\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:deletedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n\n const message = req.t('error:unableToDeleteCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","deleteOperation","isNumber","headersWithCors","deleteDoc","collection","req","depth","where","query","result","Number","undefined","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,YAAoC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACzE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF,IAAIG,KAAK;IAKlC,MAAMC,SAAS,MAAMT,gBAAgB;QACnCI;QACAE,OAAOL,SAASK,SAASI,OAAOJ,SAASK;QACzCN;QACAE;IACF;IAEA,MAAMK,UAAUV,gBAAgB;QAC9BU,SAAS,IAAIC;QACbR;IACF;IAEA,IAAII,OAAOK,MAAM,CAACC,MAAM,KAAK,GAAG;QAC9B,MAAMC,UAAUX,IAAIY,CAAC,CAAC,oCAAoC;YACxDC,OAAOT,OAAOU,IAAI,CAACJ,MAAM;YACzBK,OAAOtB,eACLM,WAAWiB,MAAM,CAACC,MAAM,CAACb,OAAOU,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxEV,IAAIkB,IAAI;QAEZ;QAEA,OAAOC,SAASC,IAAI,CAClB;YACE,GAAGhB,MAAM;YACTO;QACF,GACA;YACEJ;YACAc,QAAQ3B,WAAW4B,EAAE;QACvB;IAEJ;IAEA,MAAMC,QAAQnB,OAAOU,IAAI,CAACJ,MAAM,GAAGN,OAAOK,MAAM,CAACC,MAAM;IAEvD,MAAMC,UAAUX,IAAIY,CAAC,CAAC,6BAA6B;QACjDC,OAAOT,OAAOK,MAAM,CAACC,MAAM;QAC3BK,OAAOtB,eAAeM,WAAWiB,MAAM,CAACC,MAAM,CAACM,QAAQ,IAAI,WAAW,WAAW,EAAEvB,IAAIkB,IAAI;QAC3FK;IACF;IAEA,OAAOJ,SAASC,IAAI,CAClB;QACE,GAAGhB,MAAM;QACTO;IACF,GACA;QACEJ;QACAc,QAAQ3B,WAAW8B,WAAW;IAChC;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deleteByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAE/D,eAAO,MAAM,UAAU,EAAE,4BA8BxB,CAAA"}
1
+ {"version":3,"file":"deleteByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,UAAU,EAAE,4BAgDxB,CAAA"}
@@ -1,19 +1,31 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { deleteByIDOperation } from 'payload/operations';
3
3
  import { isNumber } from 'payload/utilities';
4
- export const deleteByID = async ({ id, collection, req })=>{
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
+ import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
6
+ export const deleteByID = async ({ id: incomingID, collection, req })=>{
5
7
  const { searchParams } = req;
6
8
  const depth = searchParams.get('depth');
9
+ const id = sanitizeCollectionID({
10
+ id: incomingID,
11
+ collectionSlug: collection.config.slug,
12
+ payload: req.payload
13
+ });
7
14
  const doc = await deleteByIDOperation({
8
15
  id,
9
16
  collection,
10
17
  depth: isNumber(depth) ? depth : undefined,
11
18
  req
12
19
  });
20
+ const headers = headersWithCors({
21
+ headers: new Headers(),
22
+ req
23
+ });
13
24
  if (!doc) {
14
25
  return Response.json({
15
26
  message: req.t('general:notFound')
16
27
  }, {
28
+ headers,
17
29
  status: httpStatus.NOT_FOUND
18
30
  });
19
31
  }
@@ -21,6 +33,7 @@ export const deleteByID = async ({ id, collection, req })=>{
21
33
  doc,
22
34
  message: req.t('general:deletedSuccessfully')
23
35
  }, {
36
+ headers,
24
37
  status: httpStatus.OK
25
38
  });
26
39
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { deleteByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nexport const deleteByID: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const doc = await deleteByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? depth : undefined,\n req,\n })\n\n if (!doc) {\n return Response.json(\n {\n message: req.t('general:notFound'),\n },\n {\n status: httpStatus.NOT_FOUND,\n },\n )\n }\n\n return Response.json(\n {\n doc,\n message: req.t('general:deletedSuccessfully'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","deleteByIDOperation","isNumber","deleteByID","id","collection","req","searchParams","depth","get","doc","undefined","Response","json","message","t","status","NOT_FOUND","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,mBAAmB,QAAQ,qBAAoB;AACxD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,aAA2C,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACpF,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAC/B,MAAMC,MAAM,MAAMT,oBAAoB;QACpCG;QACAC;QACAG,OAAON,SAASM,SAASA,QAAQG;QACjCL;IACF;IAEA,IAAI,CAACI,KAAK;QACR,OAAOE,SAASC,IAAI,CAClB;YACEC,SAASR,IAAIS,CAAC,CAAC;QACjB,GACA;YACEC,QAAQhB,WAAWiB,SAAS;QAC9B;IAEJ;IAEA,OAAOL,SAASC,IAAI,CAClB;QACEH;QACAI,SAASR,IAAIS,CAAC,CAAC;IACjB,GACA;QACEC,QAAQhB,WAAWkB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { deleteByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const deleteByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await deleteByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? depth : undefined,\n req,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (!doc) {\n return Response.json(\n {\n message: req.t('general:notFound'),\n },\n {\n headers,\n status: httpStatus.NOT_FOUND,\n },\n )\n }\n\n return Response.json(\n {\n doc,\n message: req.t('general:deletedSuccessfully'),\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","deleteByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","deleteByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","doc","undefined","headers","Headers","Response","json","message","t","status","NOT_FOUND","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,mBAAmB,QAAQ,qBAAoB;AACxD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,aAA2C,OAAO,EAC7DC,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,MAAM,MAAMhB,oBAAoB;QACpCK;QACAE;QACAG,OAAOT,SAASS,SAASA,QAAQO;QACjCT;IACF;IAEA,MAAMU,UAAUhB,gBAAgB;QAC9BgB,SAAS,IAAIC;QACbX;IACF;IAEA,IAAI,CAACQ,KAAK;QACR,OAAOI,SAASC,IAAI,CAClB;YACEC,SAASd,IAAIe,CAAC,CAAC;QACjB,GACA;YACEL;YACAM,QAAQzB,WAAW0B,SAAS;QAC9B;IAEJ;IAEA,OAAOL,SAASC,IAAI,CAClB;QACEL;QACAM,SAASd,IAAIe,CAAC,CAAC;IACjB,GACA;QACEL;QACAM,QAAQzB,WAAW2B,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"docAccess.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/docAccess.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAE/D,eAAO,MAAM,SAAS,EAAE,4BAUvB,CAAA"}
1
+ {"version":3,"file":"docAccess.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/docAccess.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,SAAS,EAAE,4BAcvB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { docAccessOperation } from 'payload/operations';
3
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
3
4
  export const docAccess = async ({ id, collection, req })=>{
4
5
  const result = await docAccessOperation({
5
6
  id,
@@ -7,6 +8,10 @@ export const docAccess = async ({ id, collection, req })=>{
7
8
  req
8
9
  });
9
10
  return Response.json(result, {
11
+ headers: headersWithCors({
12
+ headers: new Headers(),
13
+ req
14
+ }),
10
15
  status: httpStatus.OK
11
16
  });
12
17
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/docAccess.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { docAccessOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nexport const docAccess: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const result = await docAccessOperation({\n id,\n collection,\n req,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","docAccessOperation","docAccess","id","collection","req","result","Response","json","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,kBAAkB,QAAQ,qBAAoB;AAIvD,OAAO,MAAMC,YAA0C,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACnF,MAAMC,SAAS,MAAML,mBAAmB;QACtCE;QACAC;QACAC;IACF;IAEA,OAAOE,SAASC,IAAI,CAACF,QAAQ;QAC3BG,QAAQT,WAAWU,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/docAccess.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { docAccessOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const docAccess: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const result = await docAccessOperation({\n id,\n collection,\n req,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","docAccessOperation","headersWithCors","docAccess","id","collection","req","result","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,kBAAkB,QAAQ,qBAAoB;AAIvD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,YAA0C,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACnF,MAAMC,SAAS,MAAMN,mBAAmB;QACtCG;QACAC;QACAC;IACF;IAEA,OAAOE,SAASC,IAAI,CAACF,QAAQ;QAC3BG,SAASR,gBAAgB;YACvBQ,SAAS,IAAIC;YACbL;QACF;QACAM,QAAQZ,WAAWa,EAAE;IACvB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/duplicate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAE/D,eAAO,MAAM,SAAS,EAAE,4BA2BvB,CAAA"}
1
+ {"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/duplicate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,SAAS,EAAE,4BAyCvB,CAAA"}
@@ -2,11 +2,18 @@ import { getTranslation } from '@payloadcms/translations';
2
2
  import httpStatus from 'http-status';
3
3
  import { duplicateOperation } from 'payload/operations';
4
4
  import { isNumber } from 'payload/utilities';
5
- export const duplicate = async ({ id, collection, req })=>{
5
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
6
+ import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
7
+ export const duplicate = async ({ id: incomingID, collection, req })=>{
6
8
  const { searchParams } = req;
7
9
  const depth = searchParams.get('depth');
8
10
  // draft defaults to true, unless explicitly set requested as false to prevent the newly duplicated document from being published
9
11
  const draft = searchParams.get('draft') !== 'false';
12
+ const id = sanitizeCollectionID({
13
+ id: incomingID,
14
+ collectionSlug: collection.config.slug,
15
+ payload: req.payload
16
+ });
10
17
  const doc = await duplicateOperation({
11
18
  id,
12
19
  collection,
@@ -21,6 +28,10 @@ export const duplicate = async ({ id, collection, req })=>{
21
28
  doc,
22
29
  message
23
30
  }, {
31
+ headers: headersWithCors({
32
+ headers: new Headers(),
33
+ req
34
+ }),
24
35
  status: httpStatus.OK
25
36
  });
26
37
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/duplicate.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { duplicateOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nexport const duplicate: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n // draft defaults to true, unless explicitly set requested as false to prevent the newly duplicated document from being published\n const draft = searchParams.get('draft') !== 'false'\n\n const doc = await duplicateOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n req,\n })\n\n const message = req.t('general:successfullyDuplicated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n })\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","duplicateOperation","isNumber","duplicate","id","collection","req","searchParams","depth","get","draft","doc","Number","undefined","message","t","label","config","labels","singular","i18n","Response","json","status","OK"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,YAA0C,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACnF,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAC/B,iIAAiI;IACjI,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAE5C,MAAME,MAAM,MAAMV,mBAAmB;QACnCG;QACAC;QACAG,OAAON,SAASM,SAASI,OAAOJ,SAASK;QACzCH;QACAJ;IACF;IAEA,MAAMQ,UAAUR,IAAIS,CAAC,CAAC,kCAAkC;QACtDC,OAAOjB,eAAeM,WAAWY,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEb,IAAIc,IAAI;IACnE;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEX;QACAG;IACF,GACA;QACES,QAAQvB,WAAWwB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/duplicate.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { duplicateOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const duplicate: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n // draft defaults to true, unless explicitly set requested as false to prevent the newly duplicated document from being published\n const draft = searchParams.get('draft') !== 'false'\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await duplicateOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n req,\n })\n\n const message = req.t('general:successfullyDuplicated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n })\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","duplicateOperation","isNumber","headersWithCors","sanitizeCollectionID","duplicate","id","incomingID","collection","req","searchParams","depth","get","draft","collectionSlug","config","slug","payload","doc","Number","undefined","message","t","label","labels","singular","i18n","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,YAA0C,OAAO,EAC5DC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAC/B,iIAAiI;IACjI,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAE5C,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJO,gBAAgBN,WAAWO,MAAM,CAACC,IAAI;QACtCC,SAASR,IAAIQ,OAAO;IACtB;IAEA,MAAMC,MAAM,MAAMjB,mBAAmB;QACnCK;QACAE;QACAG,OAAOT,SAASS,SAASQ,OAAOR,SAASS;QACzCP;QACAJ;IACF;IAEA,MAAMY,UAAUZ,IAAIa,CAAC,CAAC,kCAAkC;QACtDC,OAAOxB,eAAeS,WAAWO,MAAM,CAACS,MAAM,CAACC,QAAQ,EAAEhB,IAAIiB,IAAI;IACnE;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEV;QACAG;IACF,GACA;QACEQ,SAAS1B,gBAAgB;YACvB0B,SAAS,IAAIC;YACbrB;QACF;QACAsB,QAAQ/B,WAAWgC,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/find.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,IAAI,EAAE,sBAwBlB,CAAA"}
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/find.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,IAAI,EAAE,sBA4BlB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { findOperation } from 'payload/operations';
3
3
  import { isNumber } from 'payload/utilities';
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
5
  export const find = async ({ collection, req })=>{
5
6
  const { depth, draft, limit, page, sort, where } = req.query;
6
7
  const result = await findOperation({
@@ -14,6 +15,10 @@ export const find = async ({ collection, req })=>{
14
15
  where
15
16
  });
16
17
  return Response.json(result, {
18
+ headers: headersWithCors({
19
+ headers: new Headers(),
20
+ req
21
+ }),
17
22
  status: httpStatus.OK
18
23
  });
19
24
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/find.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport httpStatus from 'http-status'\nimport { findOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, limit, page, sort, where } = req.query as {\n depth?: string\n draft?: string\n limit?: string\n page?: string\n sort?: string\n where?: Where\n }\n\n const result = await findOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n req,\n sort,\n where,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","findOperation","isNumber","find","collection","req","depth","draft","limit","page","sort","where","query","result","Number","undefined","Response","json","status","OK"],"mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,OAA+B,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACpE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGN,IAAIO,KAAK;IAS5D,MAAMC,SAAS,MAAMZ,cAAc;QACjCG;QACAE,OAAOJ,SAASI,SAASQ,OAAOR,SAASS;QACzCR,OAAOA,UAAU;QACjBC,OAAON,SAASM,SAASM,OAAON,SAASO;QACzCN,MAAMP,SAASO,QAAQK,OAAOL,QAAQM;QACtCV;QACAK;QACAC;IACF;IAEA,OAAOK,SAASC,IAAI,CAACJ,QAAQ;QAC3BK,QAAQlB,WAAWmB,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/find.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport httpStatus from 'http-status'\nimport { findOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, limit, page, sort, where } = req.query as {\n depth?: string\n draft?: string\n limit?: string\n page?: string\n sort?: string\n where?: Where\n }\n\n const result = await findOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n req,\n sort,\n where,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","findOperation","isNumber","headersWithCors","find","collection","req","depth","draft","limit","page","sort","where","query","result","Number","undefined","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,OAA+B,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACpE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGN,IAAIO,KAAK;IAS5D,MAAMC,SAAS,MAAMb,cAAc;QACjCI;QACAE,OAAOL,SAASK,SAASQ,OAAOR,SAASS;QACzCR,OAAOA,UAAU;QACjBC,OAAOP,SAASO,SAASM,OAAON,SAASO;QACzCN,MAAMR,SAASQ,QAAQK,OAAOL,QAAQM;QACtCV;QACAK;QACAC;IACF;IAEA,OAAOK,SAASC,IAAI,CAACJ,QAAQ;QAC3BK,SAAShB,gBAAgB;YACvBgB,SAAS,IAAIC;YACbd;QACF;QACAe,QAAQrB,WAAWsB,EAAE;IACvB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAE/D,eAAO,MAAM,QAAQ,EAAE,4BAetB,CAAA"}
1
+ {"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,QAAQ,EAAE,4BA6BtB,CAAA"}
@@ -1,9 +1,16 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { findByIDOperation } from 'payload/operations';
3
3
  import { isNumber } from 'payload/utilities';
4
- export const findByID = async ({ id, collection, req })=>{
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
+ import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
6
+ export const findByID = async ({ id: incomingID, collection, req })=>{
5
7
  const { searchParams } = req;
6
8
  const depth = searchParams.get('depth');
9
+ const id = sanitizeCollectionID({
10
+ id: incomingID,
11
+ collectionSlug: collection.config.slug,
12
+ payload: req.payload
13
+ });
7
14
  const result = await findByIDOperation({
8
15
  id,
9
16
  collection,
@@ -12,6 +19,10 @@ export const findByID = async ({ id, collection, req })=>{
12
19
  req
13
20
  });
14
21
  return Response.json(result, {
22
+ headers: headersWithCors({
23
+ headers: new Headers(),
24
+ req
25
+ }),
15
26
  status: httpStatus.OK
16
27
  });
17
28
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/findByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { findByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nexport const findByID: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const result = await findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n req,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","findByIDOperation","isNumber","findByID","id","collection","req","searchParams","depth","get","result","Number","undefined","draft","Response","json","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,WAAyC,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAClF,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMT,kBAAkB;QACrCG;QACAC;QACAG,OAAON,SAASM,SAASG,OAAOH,SAASI;QACzCC,OAAON,aAAaE,GAAG,CAAC,aAAa;QACrCH;IACF;IAEA,OAAOQ,SAASC,IAAI,CAACL,QAAQ;QAC3BM,QAAQhB,WAAWiB,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/findByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { findByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const findByID: 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 findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n req,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","findByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","findByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","draft","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,WAAyC,OAAO,EAC3DC,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,kBAAkB;QACrCK;QACAE;QACAG,OAAOT,SAASS,SAASO,OAAOP,SAASQ;QACzCC,OAAOV,aAAaE,GAAG,CAAC,aAAa;QACrCH;IACF;IAEA,OAAOY,SAASC,IAAI,CAACL,QAAQ;QAC3BM,SAASpB,gBAAgB;YACvBoB,SAAS,IAAIC;YACbf;QACF;QACAgB,QAAQzB,WAAW0B,EAAE;IACvB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findVersionByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAE/D,eAAO,MAAM,eAAe,EAAE,4BAc7B,CAAA"}
1
+ {"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findVersionByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,eAAe,EAAE,4BA4B7B,CAAA"}