@payloadcms/next 3.68.0-internal-debug.654e4ad → 3.68.0-internal.10bf491

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 (398) hide show
  1. package/dist/auth/login.js +58 -52
  2. package/dist/auth/login.js.map +1 -1
  3. package/dist/auth/logout.js +44 -39
  4. package/dist/auth/logout.js.map +1 -1
  5. package/dist/auth/refresh.js +47 -45
  6. package/dist/auth/refresh.js.map +1 -1
  7. package/dist/cjs/withPayload.cjs +41 -65
  8. package/dist/cjs/withPayload.cjs.map +1 -1
  9. package/dist/config.js +0 -1
  10. package/dist/config.js.map +1 -1
  11. package/dist/elements/DocumentHeader/Tabs/ShouldRenderTabs.js +15 -9
  12. package/dist/elements/DocumentHeader/Tabs/ShouldRenderTabs.js.map +1 -1
  13. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js +71 -40
  14. package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js.map +1 -1
  15. package/dist/elements/DocumentHeader/Tabs/Tab/index.js +59 -65
  16. package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
  17. package/dist/elements/DocumentHeader/Tabs/index.js +70 -80
  18. package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
  19. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js +23 -16
  20. package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js.map +1 -1
  21. package/dist/elements/DocumentHeader/Tabs/tabs/index.js +69 -61
  22. package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +1 -1
  23. package/dist/elements/DocumentHeader/index.js +28 -48
  24. package/dist/elements/DocumentHeader/index.js.map +1 -1
  25. package/dist/elements/FormHeader/index.js +16 -30
  26. package/dist/elements/FormHeader/index.js.map +1 -1
  27. package/dist/elements/Logo/index.js +34 -19
  28. package/dist/elements/Logo/index.js.map +1 -1
  29. package/dist/elements/Nav/NavHamburger/index.js +44 -23
  30. package/dist/elements/Nav/NavHamburger/index.js.map +1 -1
  31. package/dist/elements/Nav/NavWrapper/index.js +54 -28
  32. package/dist/elements/Nav/NavWrapper/index.js.map +1 -1
  33. package/dist/elements/Nav/SettingsMenuButton/index.js +39 -33
  34. package/dist/elements/Nav/SettingsMenuButton/index.js.map +1 -1
  35. package/dist/elements/Nav/getNavPrefs.js +22 -27
  36. package/dist/elements/Nav/getNavPrefs.js.map +1 -1
  37. package/dist/elements/Nav/index.client.js +118 -97
  38. package/dist/elements/Nav/index.client.js.map +1 -1
  39. package/dist/elements/Nav/index.js +127 -148
  40. package/dist/elements/Nav/index.js.map +1 -1
  41. package/dist/exports/auth.js +0 -1
  42. package/dist/exports/auth.js.map +1 -1
  43. package/dist/exports/client.js +1 -1
  44. package/dist/exports/client.js.map +1 -1
  45. package/dist/exports/layouts.js +0 -1
  46. package/dist/exports/layouts.js.map +1 -1
  47. package/dist/exports/routes.js +0 -1
  48. package/dist/exports/routes.js.map +1 -1
  49. package/dist/exports/rsc.js +0 -1
  50. package/dist/exports/rsc.js.map +1 -1
  51. package/dist/exports/templates.js +0 -1
  52. package/dist/exports/templates.js.map +1 -1
  53. package/dist/exports/utilities.js +12 -7
  54. package/dist/exports/utilities.js.map +1 -1
  55. package/dist/exports/views.js +0 -1
  56. package/dist/exports/views.js.map +1 -1
  57. package/dist/index.js +0 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/layouts/Root/NestProviders.js +20 -21
  60. package/dist/layouts/Root/NestProviders.js.map +1 -1
  61. package/dist/layouts/Root/checkDependencies.js +41 -49
  62. package/dist/layouts/Root/checkDependencies.js.map +1 -1
  63. package/dist/layouts/Root/index.js +103 -128
  64. package/dist/layouts/Root/index.js.map +1 -1
  65. package/dist/prod/styles.css +1 -5
  66. package/dist/routes/graphql/handler.js +122 -114
  67. package/dist/routes/graphql/handler.js.map +1 -1
  68. package/dist/routes/graphql/index.js +0 -1
  69. package/dist/routes/graphql/index.js.map +1 -1
  70. package/dist/routes/graphql/playground.js +23 -24
  71. package/dist/routes/graphql/playground.js.map +1 -1
  72. package/dist/routes/index.js +0 -1
  73. package/dist/routes/index.js.map +1 -1
  74. package/dist/routes/rest/index.js +19 -20
  75. package/dist/routes/rest/index.js.map +1 -1
  76. package/dist/routes/rest/og/image.js +79 -103
  77. package/dist/routes/rest/og/image.js.map +1 -1
  78. package/dist/routes/rest/og/index.js +54 -59
  79. package/dist/routes/rest/og/index.js.map +1 -1
  80. package/dist/templates/Default/NavHamburger/index.js +20 -12
  81. package/dist/templates/Default/NavHamburger/index.js.map +1 -1
  82. package/dist/templates/Default/Wrapper/index.js +44 -20
  83. package/dist/templates/Default/Wrapper/index.js.map +1 -1
  84. package/dist/templates/Default/index.js +133 -183
  85. package/dist/templates/Default/index.js.map +1 -1
  86. package/dist/templates/Minimal/index.js +17 -26
  87. package/dist/templates/Minimal/index.js.map +1 -1
  88. package/dist/utilities/getExistingAuthToken.js +2 -3
  89. package/dist/utilities/getExistingAuthToken.js.map +1 -1
  90. package/dist/utilities/getNextRequestI18n.js +13 -12
  91. package/dist/utilities/getNextRequestI18n.js.map +1 -1
  92. package/dist/utilities/getPayloadHMR.js +5 -5
  93. package/dist/utilities/getPayloadHMR.js.map +1 -1
  94. package/dist/utilities/getPreferences.js +22 -27
  95. package/dist/utilities/getPreferences.js.map +1 -1
  96. package/dist/utilities/getRequestLocale.js +14 -13
  97. package/dist/utilities/getRequestLocale.js.map +1 -1
  98. package/dist/utilities/getRequestTheme.js +19 -19
  99. package/dist/utilities/getRequestTheme.js.map +1 -1
  100. package/dist/utilities/getRouteWithoutAdmin.js +5 -3
  101. package/dist/utilities/getRouteWithoutAdmin.js.map +1 -1
  102. package/dist/utilities/getVisibleEntities.js +23 -12
  103. package/dist/utilities/getVisibleEntities.js.map +1 -1
  104. package/dist/utilities/handleAuthRedirect.js +36 -22
  105. package/dist/utilities/handleAuthRedirect.js.map +1 -1
  106. package/dist/utilities/handleServerFunctions.js +39 -32
  107. package/dist/utilities/handleServerFunctions.js.map +1 -1
  108. package/dist/utilities/initReq.js +96 -78
  109. package/dist/utilities/initReq.js.map +1 -1
  110. package/dist/utilities/isCustomAdminView.js +26 -22
  111. package/dist/utilities/isCustomAdminView.js.map +1 -1
  112. package/dist/utilities/isPublicAdminRoute.js +20 -26
  113. package/dist/utilities/isPublicAdminRoute.js.map +1 -1
  114. package/dist/utilities/meta.js +63 -68
  115. package/dist/utilities/meta.js.map +1 -1
  116. package/dist/utilities/selectiveCache.js +26 -25
  117. package/dist/utilities/selectiveCache.js.map +1 -1
  118. package/dist/utilities/setPayloadAuthCookie.js +22 -19
  119. package/dist/utilities/setPayloadAuthCookie.js.map +1 -1
  120. package/dist/utilities/slugify.js +33 -24
  121. package/dist/utilities/slugify.js.map +1 -1
  122. package/dist/utilities/timestamp.js +6 -7
  123. package/dist/utilities/timestamp.js.map +1 -1
  124. package/dist/views/API/LocaleSelector/index.js +39 -17
  125. package/dist/views/API/LocaleSelector/index.js.map +1 -1
  126. package/dist/views/API/RenderJSON/index.js +126 -171
  127. package/dist/views/API/RenderJSON/index.js.map +1 -1
  128. package/dist/views/API/index.client.js +195 -287
  129. package/dist/views/API/index.client.js.map +1 -1
  130. package/dist/views/API/index.js +2 -7
  131. package/dist/views/API/index.js.map +1 -1
  132. package/dist/views/API/metadata.js +23 -18
  133. package/dist/views/API/metadata.js.map +1 -1
  134. package/dist/views/Account/ResetPreferences/index.js +91 -74
  135. package/dist/views/Account/ResetPreferences/index.js.map +1 -1
  136. package/dist/views/Account/Settings/LanguageSelector.js +47 -18
  137. package/dist/views/Account/Settings/LanguageSelector.js.map +1 -1
  138. package/dist/views/Account/Settings/index.js +28 -62
  139. package/dist/views/Account/Settings/index.js.map +1 -1
  140. package/dist/views/Account/ToggleTheme/index.js +55 -38
  141. package/dist/views/Account/ToggleTheme/index.js.map +1 -1
  142. package/dist/views/Account/index.client.js +32 -16
  143. package/dist/views/Account/index.client.js.map +1 -1
  144. package/dist/views/Account/index.js +155 -144
  145. package/dist/views/Account/index.js.map +1 -1
  146. package/dist/views/Account/metadata.js +12 -8
  147. package/dist/views/Account/metadata.js.map +1 -1
  148. package/dist/views/BrowseByFolder/buildView.js +158 -139
  149. package/dist/views/BrowseByFolder/buildView.js.map +1 -1
  150. package/dist/views/BrowseByFolder/index.js +16 -16
  151. package/dist/views/BrowseByFolder/index.js.map +1 -1
  152. package/dist/views/BrowseByFolder/metadata.js +15 -13
  153. package/dist/views/BrowseByFolder/metadata.js.map +1 -1
  154. package/dist/views/CollectionFolders/buildView.js +143 -123
  155. package/dist/views/CollectionFolders/buildView.js.map +1 -1
  156. package/dist/views/CollectionFolders/index.js +16 -16
  157. package/dist/views/CollectionFolders/index.js.map +1 -1
  158. package/dist/views/CollectionFolders/metadata.js +21 -18
  159. package/dist/views/CollectionFolders/metadata.js.map +1 -1
  160. package/dist/views/CollectionFolders/renderFolderViewSlots.js +61 -58
  161. package/dist/views/CollectionFolders/renderFolderViewSlots.js.map +1 -1
  162. package/dist/views/CollectionTrash/index.js +17 -17
  163. package/dist/views/CollectionTrash/index.js.map +1 -1
  164. package/dist/views/CollectionTrash/metadata.js +21 -18
  165. package/dist/views/CollectionTrash/metadata.js.map +1 -1
  166. package/dist/views/CreateFirstUser/index.client.js +101 -114
  167. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  168. package/dist/views/CreateFirstUser/index.js +81 -87
  169. package/dist/views/CreateFirstUser/index.js.map +1 -1
  170. package/dist/views/CreateFirstUser/metadata.js +12 -8
  171. package/dist/views/CreateFirstUser/metadata.js.map +1 -1
  172. package/dist/views/Dashboard/Default/index.js +152 -176
  173. package/dist/views/Dashboard/Default/index.js.map +1 -1
  174. package/dist/views/Dashboard/index.js +90 -97
  175. package/dist/views/Dashboard/index.js.map +1 -1
  176. package/dist/views/Dashboard/metadata.js +14 -10
  177. package/dist/views/Dashboard/metadata.js.map +1 -1
  178. package/dist/views/Document/getCustomDocumentViewByKey.js +2 -3
  179. package/dist/views/Document/getCustomDocumentViewByKey.js.map +1 -1
  180. package/dist/views/Document/getCustomViewByRoute.js +30 -27
  181. package/dist/views/Document/getCustomViewByRoute.js.map +1 -1
  182. package/dist/views/Document/getDocPreferences.js +41 -40
  183. package/dist/views/Document/getDocPreferences.js.map +1 -1
  184. package/dist/views/Document/getDocumentData.js +55 -44
  185. package/dist/views/Document/getDocumentData.js.map +1 -1
  186. package/dist/views/Document/getDocumentPermissions.js +80 -77
  187. package/dist/views/Document/getDocumentPermissions.js.map +1 -1
  188. package/dist/views/Document/getDocumentView.js +283 -313
  189. package/dist/views/Document/getDocumentView.js.map +1 -1
  190. package/dist/views/Document/getIsLocked.js +66 -66
  191. package/dist/views/Document/getIsLocked.js.map +1 -1
  192. package/dist/views/Document/getMetaBySegment.js +136 -130
  193. package/dist/views/Document/getMetaBySegment.js.map +1 -1
  194. package/dist/views/Document/getVersions.js +194 -204
  195. package/dist/views/Document/getVersions.js.map +1 -1
  196. package/dist/views/Document/handleServerFunction.js +128 -103
  197. package/dist/views/Document/handleServerFunction.js.map +1 -1
  198. package/dist/views/Document/index.js +354 -315
  199. package/dist/views/Document/index.js.map +1 -1
  200. package/dist/views/Document/metadata.js +1 -2
  201. package/dist/views/Document/metadata.js.map +1 -1
  202. package/dist/views/Document/renderDocumentSlots.js +132 -121
  203. package/dist/views/Document/renderDocumentSlots.js.map +1 -1
  204. package/dist/views/Edit/index.js +6 -10
  205. package/dist/views/Edit/index.js.map +1 -1
  206. package/dist/views/Edit/metadata.js +46 -36
  207. package/dist/views/Edit/metadata.js.map +1 -1
  208. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +164 -130
  209. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
  210. package/dist/views/ForgotPassword/index.js +62 -79
  211. package/dist/views/ForgotPassword/index.js.map +1 -1
  212. package/dist/views/ForgotPassword/metadata.js +12 -8
  213. package/dist/views/ForgotPassword/metadata.js.map +1 -1
  214. package/dist/views/List/createSerializableValue.js +11 -12
  215. package/dist/views/List/createSerializableValue.js.map +1 -1
  216. package/dist/views/List/enrichDocsWithVersionStatus.js +86 -86
  217. package/dist/views/List/enrichDocsWithVersionStatus.js.map +1 -1
  218. package/dist/views/List/extractRelationshipDisplayValue.js +14 -15
  219. package/dist/views/List/extractRelationshipDisplayValue.js.map +1 -1
  220. package/dist/views/List/extractValueOrRelationshipID.js +15 -16
  221. package/dist/views/List/extractValueOrRelationshipID.js.map +1 -1
  222. package/dist/views/List/handleGroupBy.js +150 -133
  223. package/dist/views/List/handleGroupBy.js.map +1 -1
  224. package/dist/views/List/handleServerFunction.js +119 -96
  225. package/dist/views/List/handleServerFunction.js.map +1 -1
  226. package/dist/views/List/index.js +323 -305
  227. package/dist/views/List/index.js.map +1 -1
  228. package/dist/views/List/metadata.js +20 -17
  229. package/dist/views/List/metadata.js.map +1 -1
  230. package/dist/views/List/renderListViewSlots.js +75 -82
  231. package/dist/views/List/renderListViewSlots.js.map +1 -1
  232. package/dist/views/List/resolveAllFilterOptions.js +45 -43
  233. package/dist/views/List/resolveAllFilterOptions.js.map +1 -1
  234. package/dist/views/List/transformColumnsToSelect.js +8 -9
  235. package/dist/views/List/transformColumnsToSelect.js.map +1 -1
  236. package/dist/views/Login/LoginField/index.js +89 -57
  237. package/dist/views/Login/LoginField/index.js.map +1 -1
  238. package/dist/views/Login/LoginForm/index.js +157 -104
  239. package/dist/views/Login/LoginForm/index.js.map +1 -1
  240. package/dist/views/Login/index.js +85 -82
  241. package/dist/views/Login/index.js.map +1 -1
  242. package/dist/views/Login/metadata.js +12 -8
  243. package/dist/views/Login/metadata.js.map +1 -1
  244. package/dist/views/Logout/LogoutClient.js +119 -83
  245. package/dist/views/Logout/LogoutClient.js.map +1 -1
  246. package/dist/views/Logout/index.js +29 -29
  247. package/dist/views/Logout/index.js.map +1 -1
  248. package/dist/views/Logout/metadata.js +11 -7
  249. package/dist/views/Logout/metadata.js.map +1 -1
  250. package/dist/views/NotFound/index.client.js +82 -71
  251. package/dist/views/NotFound/index.client.js.map +1 -1
  252. package/dist/views/NotFound/index.js +72 -71
  253. package/dist/views/NotFound/index.js.map +1 -1
  254. package/dist/views/NotFound/metadata.js +9 -7
  255. package/dist/views/NotFound/metadata.js.map +1 -1
  256. package/dist/views/ResetPassword/ResetPasswordForm/index.js +107 -94
  257. package/dist/views/ResetPassword/ResetPasswordForm/index.js.map +1 -1
  258. package/dist/views/ResetPassword/index.js +73 -93
  259. package/dist/views/ResetPassword/index.js.map +1 -1
  260. package/dist/views/ResetPassword/metadata.js +12 -8
  261. package/dist/views/ResetPassword/metadata.js.map +1 -1
  262. package/dist/views/Root/attachViewActions.js +23 -18
  263. package/dist/views/Root/attachViewActions.js.map +1 -1
  264. package/dist/views/Root/generateCustomViewMetadata.js +21 -19
  265. package/dist/views/Root/generateCustomViewMetadata.js.map +1 -1
  266. package/dist/views/Root/getCustomViewByKey.js +14 -12
  267. package/dist/views/Root/getCustomViewByKey.js.map +1 -1
  268. package/dist/views/Root/getCustomViewByRoute.js +42 -31
  269. package/dist/views/Root/getCustomViewByRoute.js.map +1 -1
  270. package/dist/views/Root/getDocumentViewInfo.js +23 -24
  271. package/dist/views/Root/getDocumentViewInfo.js.map +1 -1
  272. package/dist/views/Root/getRouteData.js +325 -333
  273. package/dist/views/Root/getRouteData.js.map +1 -1
  274. package/dist/views/Root/index.js +269 -247
  275. package/dist/views/Root/index.js.map +1 -1
  276. package/dist/views/Root/isPathMatchingRoute.js +26 -21
  277. package/dist/views/Root/isPathMatchingRoute.js.map +1 -1
  278. package/dist/views/Root/metadata.js +181 -176
  279. package/dist/views/Root/metadata.js.map +1 -1
  280. package/dist/views/Unauthorized/index.js +46 -54
  281. package/dist/views/Unauthorized/index.js.map +1 -1
  282. package/dist/views/Unauthorized/metadata.js +12 -8
  283. package/dist/views/Unauthorized/metadata.js.map +1 -1
  284. package/dist/views/Verify/index.client.js +43 -25
  285. package/dist/views/Verify/index.client.js.map +1 -1
  286. package/dist/views/Verify/index.js +62 -68
  287. package/dist/views/Verify/index.js.map +1 -1
  288. package/dist/views/Verify/metadata.js +12 -8
  289. package/dist/views/Verify/metadata.js.map +1 -1
  290. package/dist/views/Version/Default/SelectedLocalesContext.js +4 -4
  291. package/dist/views/Version/Default/SelectedLocalesContext.js.map +1 -1
  292. package/dist/views/Version/Default/SetStepNav.js +127 -86
  293. package/dist/views/Version/Default/SetStepNav.js.map +1 -1
  294. package/dist/views/Version/Default/index.js +236 -380
  295. package/dist/views/Version/Default/index.js.map +1 -1
  296. package/dist/views/Version/Default/types.js +1 -2
  297. package/dist/views/Version/Default/types.js.map +1 -1
  298. package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js +119 -102
  299. package/dist/views/Version/RenderFieldsToDiff/DiffCollapser/index.js.map +1 -1
  300. package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js +73 -78
  301. package/dist/views/Version/RenderFieldsToDiff/RenderVersionFieldsToDiff.js.map +1 -1
  302. package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js +408 -363
  303. package/dist/views/Version/RenderFieldsToDiff/buildVersionFields.js.map +1 -1
  304. package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js +51 -40
  305. package/dist/views/Version/RenderFieldsToDiff/fields/Collapsible/index.js.map +1 -1
  306. package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.js +67 -35
  307. package/dist/views/Version/RenderFieldsToDiff/fields/Date/index.js.map +1 -1
  308. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js +56 -59
  309. package/dist/views/Version/RenderFieldsToDiff/fields/Group/index.js.map +1 -1
  310. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +117 -139
  311. package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
  312. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js +41 -36
  313. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/generateLabelFromValue.js.map +1 -1
  314. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +178 -192
  315. package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
  316. package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.js +11 -17
  317. package/dist/views/Version/RenderFieldsToDiff/fields/Row/index.js.map +1 -1
  318. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +73 -48
  319. package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
  320. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +143 -132
  321. package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
  322. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +81 -56
  323. package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
  324. package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.js +210 -251
  325. package/dist/views/Version/RenderFieldsToDiff/fields/Upload/index.js.map +1 -1
  326. package/dist/views/Version/RenderFieldsToDiff/fields/index.js +22 -23
  327. package/dist/views/Version/RenderFieldsToDiff/fields/index.js.map +1 -1
  328. package/dist/views/Version/RenderFieldsToDiff/index.js +9 -12
  329. package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
  330. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js +228 -213
  331. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.js.map +1 -1
  332. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js +826 -1005
  333. package/dist/views/Version/RenderFieldsToDiff/utilities/countChangedFields.spec.js.map +1 -1
  334. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.js +1 -2
  335. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.js.map +1 -1
  336. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js +43 -44
  337. package/dist/views/Version/RenderFieldsToDiff/utilities/fieldHasChanges.spec.js.map +1 -1
  338. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.js +22 -25
  339. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldPathsModified.js.map +1 -1
  340. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js +36 -32
  341. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.js.map +1 -1
  342. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js +129 -145
  343. package/dist/views/Version/RenderFieldsToDiff/utilities/getFieldsForRowComparison.spec.js.map +1 -1
  344. package/dist/views/Version/Restore/index.js +91 -116
  345. package/dist/views/Version/Restore/index.js.map +1 -1
  346. package/dist/views/Version/SelectComparison/VersionDrawer/CreatedAtCell.js +50 -33
  347. package/dist/views/Version/SelectComparison/VersionDrawer/CreatedAtCell.js.map +1 -1
  348. package/dist/views/Version/SelectComparison/VersionDrawer/index.js +226 -170
  349. package/dist/views/Version/SelectComparison/VersionDrawer/index.js.map +1 -1
  350. package/dist/views/Version/SelectComparison/index.js +50 -73
  351. package/dist/views/Version/SelectComparison/index.js.map +1 -1
  352. package/dist/views/Version/SelectComparison/types.js +1 -2
  353. package/dist/views/Version/SelectComparison/types.js.map +1 -1
  354. package/dist/views/Version/SelectLocales/index.js +32 -34
  355. package/dist/views/Version/SelectLocales/index.js.map +1 -1
  356. package/dist/views/Version/VersionPillLabel/VersionPillLabel.js +95 -104
  357. package/dist/views/Version/VersionPillLabel/VersionPillLabel.js.map +1 -1
  358. package/dist/views/Version/VersionPillLabel/getVersionLabel.js +27 -23
  359. package/dist/views/Version/VersionPillLabel/getVersionLabel.js.map +1 -1
  360. package/dist/views/Version/fetchVersions.js +138 -113
  361. package/dist/views/Version/fetchVersions.js.map +1 -1
  362. package/dist/views/Version/index.js +323 -325
  363. package/dist/views/Version/index.js.map +1 -1
  364. package/dist/views/Version/metadata.js +50 -43
  365. package/dist/views/Version/metadata.js.map +1 -1
  366. package/dist/views/Versions/buildColumns.js +79 -95
  367. package/dist/views/Versions/buildColumns.js.map +1 -1
  368. package/dist/views/Versions/cells/AutosaveCell/index.js +38 -34
  369. package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
  370. package/dist/views/Versions/cells/CreatedAt/index.js +53 -32
  371. package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
  372. package/dist/views/Versions/cells/ID/index.js +8 -10
  373. package/dist/views/Versions/cells/ID/index.js.map +1 -1
  374. package/dist/views/Versions/index.client.js +83 -106
  375. package/dist/views/Versions/index.client.js.map +1 -1
  376. package/dist/views/Versions/index.js +140 -140
  377. package/dist/views/Versions/index.js.map +1 -1
  378. package/dist/views/Versions/metadata.js +44 -37
  379. package/dist/views/Versions/metadata.js.map +1 -1
  380. package/dist/views/Versions/types.js +1 -2
  381. package/dist/views/Versions/types.js.map +1 -1
  382. package/dist/withPayload.d.ts +8 -2
  383. package/dist/withPayload.d.ts.map +1 -1
  384. package/dist/withPayload.js +145 -219
  385. package/dist/withPayload.js.map +1 -1
  386. package/dist/withPayload.utils.d.ts +58 -0
  387. package/dist/withPayload.utils.d.ts.map +1 -0
  388. package/dist/withPayload.utils.js +101 -0
  389. package/dist/withPayload.utils.js.map +1 -0
  390. package/dist/withPayloadLegacy.d.ts +6 -0
  391. package/dist/withPayloadLegacy.d.ts.map +1 -0
  392. package/dist/withPayloadLegacy.js +44 -0
  393. package/dist/withPayloadLegacy.js.map +1 -0
  394. package/package.json +15 -17
  395. package/dist/esbuildEntry.d.ts +0 -5
  396. package/dist/esbuildEntry.d.ts.map +0 -1
  397. package/dist/esbuildEntry.js +0 -6
  398. package/dist/esbuildEntry.js.map +0 -1
@@ -1,61 +1,67 @@
1
1
  'use server';
2
+
2
3
  import { getPayload } from 'payload';
3
4
  import { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js';
4
- export async function login({ collection, config, email, password, username }) {
5
- const payload = await getPayload({
6
- config,
7
- cron: true
8
- });
9
- const authConfig = payload.collections[collection]?.config.auth;
10
- if (!authConfig) {
11
- throw new Error(`No auth config found for collection: ${collection}`);
12
- }
13
- const loginWithUsername = authConfig?.loginWithUsername ?? false;
14
- if (loginWithUsername) {
15
- if (loginWithUsername.allowEmailLogin) {
16
- if (!email && !username) {
17
- throw new Error('Email or username is required.');
18
- }
19
- } else {
20
- if (!username) {
21
- throw new Error('Username is required.');
22
- }
23
- }
5
+ export async function login({
6
+ collection,
7
+ config,
8
+ email,
9
+ password,
10
+ username
11
+ }) {
12
+ const payload = await getPayload({
13
+ config,
14
+ cron: true
15
+ });
16
+ const authConfig = payload.collections[collection]?.config.auth;
17
+ if (!authConfig) {
18
+ throw new Error(`No auth config found for collection: ${collection}`);
19
+ }
20
+ const loginWithUsername = authConfig?.loginWithUsername ?? false;
21
+ if (loginWithUsername) {
22
+ if (loginWithUsername.allowEmailLogin) {
23
+ if (!email && !username) {
24
+ throw new Error('Email or username is required.');
25
+ }
24
26
  } else {
25
- if (!email) {
26
- throw new Error('Email is required.');
27
- }
27
+ if (!username) {
28
+ throw new Error('Username is required.');
29
+ }
28
30
  }
29
- let loginData;
30
- if (loginWithUsername) {
31
- loginData = username ? {
32
- password,
33
- username
34
- } : {
35
- email,
36
- password
37
- };
38
- } else {
39
- loginData = {
40
- email,
41
- password
42
- };
31
+ } else {
32
+ if (!email) {
33
+ throw new Error('Email is required.');
43
34
  }
44
- const result = await payload.login({
45
- collection,
46
- data: loginData
35
+ }
36
+ let loginData;
37
+ if (loginWithUsername) {
38
+ loginData = username ? {
39
+ password,
40
+ username
41
+ } : {
42
+ email,
43
+ password
44
+ };
45
+ } else {
46
+ loginData = {
47
+ email,
48
+ password
49
+ };
50
+ }
51
+ const result = await payload.login({
52
+ collection,
53
+ data: loginData
54
+ });
55
+ if (result.token) {
56
+ await setPayloadAuthCookie({
57
+ authConfig,
58
+ cookiePrefix: payload.config.cookiePrefix,
59
+ token: result.token
47
60
  });
48
- if (result.token) {
49
- await setPayloadAuthCookie({
50
- authConfig,
51
- cookiePrefix: payload.config.cookiePrefix,
52
- token: result.token
53
- });
54
- }
55
- if ('removeTokenFromResponses' in config && config.removeTokenFromResponses) {
56
- delete result.token;
57
- }
58
- return result;
61
+ }
62
+ if ('removeTokenFromResponses' in config && config.removeTokenFromResponses) {
63
+ delete result.token;
64
+ }
65
+ return result;
59
66
  }
60
-
61
67
  //# sourceMappingURL=login.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport { getPayload } from 'payload'\n\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\ntype LoginWithEmail = {\n collection: CollectionSlug\n config: any\n email: string\n password: string\n username?: never\n}\n\ntype LoginWithUsername = {\n collection: CollectionSlug\n config: any\n email?: never\n password: string\n username: string\n}\ntype LoginArgs = LoginWithEmail | LoginWithUsername\n\nexport async function login({ collection, config, email, password, username }: LoginArgs): Promise<{\n token?: string\n user: any\n}> {\n const payload = await getPayload({ config, cron: true })\n\n const authConfig = payload.collections[collection]?.config.auth\n\n if (!authConfig) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const loginWithUsername = authConfig?.loginWithUsername ?? false\n\n if (loginWithUsername) {\n if (loginWithUsername.allowEmailLogin) {\n if (!email && !username) {\n throw new Error('Email or username is required.')\n }\n } else {\n if (!username) {\n throw new Error('Username is required.')\n }\n }\n } else {\n if (!email) {\n throw new Error('Email is required.')\n }\n }\n\n let loginData\n\n if (loginWithUsername) {\n loginData = username ? { password, username } : { email, password }\n } else {\n loginData = { email, password }\n }\n\n const result = await payload.login({\n collection,\n data: loginData,\n })\n\n if (result.token) {\n await setPayloadAuthCookie({\n authConfig,\n cookiePrefix: payload.config.cookiePrefix,\n token: result.token,\n })\n }\n\n if ('removeTokenFromResponses' in config && config.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n"],"names":["getPayload","setPayloadAuthCookie","login","collection","config","email","password","username","payload","cron","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","result","data","token","cookiePrefix","removeTokenFromResponses"],"mappings":"AAAA;AAIA,SAASA,UAAU,QAAQ,UAAS;AAEpC,SAASC,oBAAoB,QAAQ,uCAAsC;AAmB3E,OAAO,eAAeC,MAAM,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAa;IAItF,MAAMC,UAAU,MAAMR,WAAW;QAAEI;QAAQK,MAAM;IAAK;IAEtD,MAAMC,aAAaF,QAAQG,WAAW,CAACR,WAAW,EAAEC,OAAOQ;IAE3D,IAAI,CAACF,YAAY;QACf,MAAM,IAAIG,MAAM,CAAC,qCAAqC,EAAEV,YAAY;IACtE;IAEA,MAAMW,oBAAoBJ,YAAYI,qBAAqB;IAE3D,IAAIA,mBAAmB;QACrB,IAAIA,kBAAkBC,eAAe,EAAE;YACrC,IAAI,CAACV,SAAS,CAACE,UAAU;gBACvB,MAAM,IAAIM,MAAM;YAClB;QACF,OAAO;YACL,IAAI,CAACN,UAAU;gBACb,MAAM,IAAIM,MAAM;YAClB;QACF;IACF,OAAO;QACL,IAAI,CAACR,OAAO;YACV,MAAM,IAAIQ,MAAM;QAClB;IACF;IAEA,IAAIG;IAEJ,IAAIF,mBAAmB;QACrBE,YAAYT,WAAW;YAAED;YAAUC;QAAS,IAAI;YAAEF;YAAOC;QAAS;IACpE,OAAO;QACLU,YAAY;YAAEX;YAAOC;QAAS;IAChC;IAEA,MAAMW,SAAS,MAAMT,QAAQN,KAAK,CAAC;QACjCC;QACAe,MAAMF;IACR;IAEA,IAAIC,OAAOE,KAAK,EAAE;QAChB,MAAMlB,qBAAqB;YACzBS;YACAU,cAAcZ,QAAQJ,MAAM,CAACgB,YAAY;YACzCD,OAAOF,OAAOE,KAAK;QACrB;IACF;IAEA,IAAI,8BAA8Bf,UAAUA,OAAOiB,wBAAwB,EAAE;QAC3E,OAAOJ,OAAOE,KAAK;IACrB;IAEA,OAAOF;AACT"}
1
+ {"version":3,"file":"login.js","names":["getPayload","setPayloadAuthCookie","login","collection","config","email","password","username","payload","cron","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","result","data","token","cookiePrefix","removeTokenFromResponses"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport { getPayload } from 'payload'\n\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\ntype LoginWithEmail = {\n collection: CollectionSlug\n config: any\n email: string\n password: string\n username?: never\n}\n\ntype LoginWithUsername = {\n collection: CollectionSlug\n config: any\n email?: never\n password: string\n username: string\n}\ntype LoginArgs = LoginWithEmail | LoginWithUsername\n\nexport async function login({ collection, config, email, password, username }: LoginArgs): Promise<{\n token?: string\n user: any\n}> {\n const payload = await getPayload({ config, cron: true })\n\n const authConfig = payload.collections[collection]?.config.auth\n\n if (!authConfig) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const loginWithUsername = authConfig?.loginWithUsername ?? false\n\n if (loginWithUsername) {\n if (loginWithUsername.allowEmailLogin) {\n if (!email && !username) {\n throw new Error('Email or username is required.')\n }\n } else {\n if (!username) {\n throw new Error('Username is required.')\n }\n }\n } else {\n if (!email) {\n throw new Error('Email is required.')\n }\n }\n\n let loginData\n\n if (loginWithUsername) {\n loginData = username ? { password, username } : { email, password }\n } else {\n loginData = { email, password }\n }\n\n const result = await payload.login({\n collection,\n data: loginData,\n })\n\n if (result.token) {\n await setPayloadAuthCookie({\n authConfig,\n cookiePrefix: payload.config.cookiePrefix,\n token: result.token,\n })\n }\n\n if ('removeTokenFromResponses' in config && config.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n"],"mappings":"AAAA;;AAIA,SAASA,UAAU,QAAQ;AAE3B,SAASC,oBAAoB,QAAQ;AAmBrC,OAAO,eAAeC,MAAM;EAAEC,UAAU;EAAEC,MAAM;EAAEC,KAAK;EAAEC,QAAQ;EAAEC;AAAQ,CAAa;EAItF,MAAMC,OAAA,GAAU,MAAMR,UAAA,CAAW;IAAEI,MAAA;IAAQK,IAAA,EAAM;EAAK;EAEtD,MAAMC,UAAA,GAAaF,OAAA,CAAQG,WAAW,CAACR,UAAA,CAAW,EAAEC,MAAA,CAAOQ,IAAA;EAE3D,IAAI,CAACF,UAAA,EAAY;IACf,MAAM,IAAIG,KAAA,CAAM,wCAAwCV,UAAA,EAAY;EACtE;EAEA,MAAMW,iBAAA,GAAoBJ,UAAA,EAAYI,iBAAA,IAAqB;EAE3D,IAAIA,iBAAA,EAAmB;IACrB,IAAIA,iBAAA,CAAkBC,eAAe,EAAE;MACrC,IAAI,CAACV,KAAA,IAAS,CAACE,QAAA,EAAU;QACvB,MAAM,IAAIM,KAAA,CAAM;MAClB;IACF,OAAO;MACL,IAAI,CAACN,QAAA,EAAU;QACb,MAAM,IAAIM,KAAA,CAAM;MAClB;IACF;EACF,OAAO;IACL,IAAI,CAACR,KAAA,EAAO;MACV,MAAM,IAAIQ,KAAA,CAAM;IAClB;EACF;EAEA,IAAIG,SAAA;EAEJ,IAAIF,iBAAA,EAAmB;IACrBE,SAAA,GAAYT,QAAA,GAAW;MAAED,QAAA;MAAUC;IAAS,IAAI;MAAEF,KAAA;MAAOC;IAAS;EACpE,OAAO;IACLU,SAAA,GAAY;MAAEX,KAAA;MAAOC;IAAS;EAChC;EAEA,MAAMW,MAAA,GAAS,MAAMT,OAAA,CAAQN,KAAK,CAAC;IACjCC,UAAA;IACAe,IAAA,EAAMF;EACR;EAEA,IAAIC,MAAA,CAAOE,KAAK,EAAE;IAChB,MAAMlB,oBAAA,CAAqB;MACzBS,UAAA;MACAU,YAAA,EAAcZ,OAAA,CAAQJ,MAAM,CAACgB,YAAY;MACzCD,KAAA,EAAOF,MAAA,CAAOE;IAChB;EACF;EAEA,IAAI,8BAA8Bf,MAAA,IAAUA,MAAA,CAAOiB,wBAAwB,EAAE;IAC3E,OAAOJ,MAAA,CAAOE,KAAK;EACrB;EAEA,OAAOF,MAAA;AACT","ignoreList":[]}
@@ -1,47 +1,52 @@
1
1
  'use server';
2
+
2
3
  import { cookies as getCookies, headers as nextHeaders } from 'next/headers.js';
3
4
  import { createLocalReq, getPayload, logoutOperation } from 'payload';
4
5
  import { getExistingAuthToken } from '../utilities/getExistingAuthToken.js';
5
- export async function logout({ allSessions = false, config }) {
6
- const payload = await getPayload({
7
- config,
8
- cron: true
9
- });
10
- const headers = await nextHeaders();
11
- const authResult = await payload.auth({
12
- headers
13
- });
14
- if (!authResult.user) {
15
- return {
16
- message: 'User already logged out',
17
- success: true
18
- };
19
- }
20
- const { user } = authResult;
21
- const req = await createLocalReq({
22
- user
23
- }, payload);
24
- const collection = payload.collections[user.collection];
25
- const logoutResult = await logoutOperation({
26
- allSessions,
27
- collection,
28
- req
29
- });
30
- if (!logoutResult) {
31
- return {
32
- message: 'Logout failed',
33
- success: false
34
- };
35
- }
36
- const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix);
37
- if (existingCookie) {
38
- const cookies = await getCookies();
39
- cookies.delete(existingCookie.name);
40
- }
6
+ export async function logout({
7
+ allSessions = false,
8
+ config
9
+ }) {
10
+ const payload = await getPayload({
11
+ config,
12
+ cron: true
13
+ });
14
+ const headers = await nextHeaders();
15
+ const authResult = await payload.auth({
16
+ headers
17
+ });
18
+ if (!authResult.user) {
19
+ return {
20
+ message: 'User already logged out',
21
+ success: true
22
+ };
23
+ }
24
+ const {
25
+ user
26
+ } = authResult;
27
+ const req = await createLocalReq({
28
+ user
29
+ }, payload);
30
+ const collection = payload.collections[user.collection];
31
+ const logoutResult = await logoutOperation({
32
+ allSessions,
33
+ collection,
34
+ req
35
+ });
36
+ if (!logoutResult) {
41
37
  return {
42
- message: 'User logged out successfully',
43
- success: true
38
+ message: 'Logout failed',
39
+ success: false
44
40
  };
41
+ }
42
+ const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix);
43
+ if (existingCookie) {
44
+ const cookies = await getCookies();
45
+ cookies.delete(existingCookie.name);
46
+ }
47
+ return {
48
+ message: 'User logged out successfully',
49
+ success: true
50
+ };
45
51
  }
46
-
47
52
  //# sourceMappingURL=logout.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type { SanitizedConfig } from 'payload'\n\nimport { cookies as getCookies, headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, logoutOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\n\nexport async function logout({\n allSessions = false,\n config,\n}: {\n allSessions?: boolean\n config: Promise<SanitizedConfig> | SanitizedConfig\n}) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const authResult = await payload.auth({ headers })\n\n if (!authResult.user) {\n return { message: 'User already logged out', success: true }\n }\n\n const { user } = authResult\n const req = await createLocalReq({ user }, payload)\n const collection = payload.collections[user.collection]\n\n const logoutResult = await logoutOperation({\n allSessions,\n collection,\n req,\n })\n\n if (!logoutResult) {\n return { message: 'Logout failed', success: false }\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (existingCookie) {\n const cookies = await getCookies()\n cookies.delete(existingCookie.name)\n }\n\n return { message: 'User logged out successfully', success: true }\n}\n"],"names":["cookies","getCookies","headers","nextHeaders","createLocalReq","getPayload","logoutOperation","getExistingAuthToken","logout","allSessions","config","payload","cron","authResult","auth","user","message","success","req","collection","collections","logoutResult","existingCookie","cookiePrefix","delete","name"],"mappings":"AAAA;AAIA,SAASA,WAAWC,UAAU,EAAEC,WAAWC,WAAW,QAAQ,kBAAiB;AAC/E,SAASC,cAAc,EAAEC,UAAU,EAAEC,eAAe,QAAQ,UAAS;AAErE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,eAAeC,OAAO,EAC3BC,cAAc,KAAK,EACnBC,MAAM,EAIP;IACC,MAAMC,UAAU,MAAMN,WAAW;QAAEK;QAAQE,MAAM;IAAK;IACtD,MAAMV,UAAU,MAAMC;IACtB,MAAMU,aAAa,MAAMF,QAAQG,IAAI,CAAC;QAAEZ;IAAQ;IAEhD,IAAI,CAACW,WAAWE,IAAI,EAAE;QACpB,OAAO;YAAEC,SAAS;YAA2BC,SAAS;QAAK;IAC7D;IAEA,MAAM,EAAEF,IAAI,EAAE,GAAGF;IACjB,MAAMK,MAAM,MAAMd,eAAe;QAAEW;IAAK,GAAGJ;IAC3C,MAAMQ,aAAaR,QAAQS,WAAW,CAACL,KAAKI,UAAU,CAAC;IAEvD,MAAME,eAAe,MAAMf,gBAAgB;QACzCG;QACAU;QACAD;IACF;IAEA,IAAI,CAACG,cAAc;QACjB,OAAO;YAAEL,SAAS;YAAiBC,SAAS;QAAM;IACpD;IAEA,MAAMK,iBAAiB,MAAMf,qBAAqBI,QAAQD,MAAM,CAACa,YAAY;IAC7E,IAAID,gBAAgB;QAClB,MAAMtB,UAAU,MAAMC;QACtBD,QAAQwB,MAAM,CAACF,eAAeG,IAAI;IACpC;IAEA,OAAO;QAAET,SAAS;QAAgCC,SAAS;IAAK;AAClE"}
1
+ {"version":3,"file":"logout.js","names":["cookies","getCookies","headers","nextHeaders","createLocalReq","getPayload","logoutOperation","getExistingAuthToken","logout","allSessions","config","payload","cron","authResult","auth","user","message","success","req","collection","collections","logoutResult","existingCookie","cookiePrefix","delete","name"],"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type { SanitizedConfig } from 'payload'\n\nimport { cookies as getCookies, headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, logoutOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\n\nexport async function logout({\n allSessions = false,\n config,\n}: {\n allSessions?: boolean\n config: Promise<SanitizedConfig> | SanitizedConfig\n}) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const authResult = await payload.auth({ headers })\n\n if (!authResult.user) {\n return { message: 'User already logged out', success: true }\n }\n\n const { user } = authResult\n const req = await createLocalReq({ user }, payload)\n const collection = payload.collections[user.collection]\n\n const logoutResult = await logoutOperation({\n allSessions,\n collection,\n req,\n })\n\n if (!logoutResult) {\n return { message: 'Logout failed', success: false }\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (existingCookie) {\n const cookies = await getCookies()\n cookies.delete(existingCookie.name)\n }\n\n return { message: 'User logged out successfully', success: true }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,UAAU,EAAEC,OAAA,IAAWC,WAAW,QAAQ;AAC9D,SAASC,cAAc,EAAEC,UAAU,EAAEC,eAAe,QAAQ;AAE5D,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,OAAO;EAC3BC,WAAA,GAAc,KAAK;EACnBC;AAAM,CAIP;EACC,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;IAAEK,MAAA;IAAQE,IAAA,EAAM;EAAK;EACtD,MAAMV,OAAA,GAAU,MAAMC,WAAA;EACtB,MAAMU,UAAA,GAAa,MAAMF,OAAA,CAAQG,IAAI,CAAC;IAAEZ;EAAQ;EAEhD,IAAI,CAACW,UAAA,CAAWE,IAAI,EAAE;IACpB,OAAO;MAAEC,OAAA,EAAS;MAA2BC,OAAA,EAAS;IAAK;EAC7D;EAEA,MAAM;IAAEF;EAAI,CAAE,GAAGF,UAAA;EACjB,MAAMK,GAAA,GAAM,MAAMd,cAAA,CAAe;IAAEW;EAAK,GAAGJ,OAAA;EAC3C,MAAMQ,UAAA,GAAaR,OAAA,CAAQS,WAAW,CAACL,IAAA,CAAKI,UAAU,CAAC;EAEvD,MAAME,YAAA,GAAe,MAAMf,eAAA,CAAgB;IACzCG,WAAA;IACAU,UAAA;IACAD;EACF;EAEA,IAAI,CAACG,YAAA,EAAc;IACjB,OAAO;MAAEL,OAAA,EAAS;MAAiBC,OAAA,EAAS;IAAM;EACpD;EAEA,MAAMK,cAAA,GAAiB,MAAMf,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACa,YAAY;EAC7E,IAAID,cAAA,EAAgB;IAClB,MAAMtB,OAAA,GAAU,MAAMC,UAAA;IACtBD,OAAA,CAAQwB,MAAM,CAACF,cAAA,CAAeG,IAAI;EACpC;EAEA,OAAO;IAAET,OAAA,EAAS;IAAgCC,OAAA,EAAS;EAAK;AAClE","ignoreList":[]}
@@ -1,54 +1,56 @@
1
1
  'use server';
2
+
2
3
  import { headers as nextHeaders } from 'next/headers.js';
3
4
  import { createLocalReq, getPayload, refreshOperation } from 'payload';
4
5
  import { getExistingAuthToken } from '../utilities/getExistingAuthToken.js';
5
6
  import { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js';
6
- export async function refresh({ config }) {
7
- const payload = await getPayload({
8
- config,
9
- cron: true
10
- });
11
- const headers = await nextHeaders();
12
- const result = await payload.auth({
13
- headers
14
- });
15
- if (!result.user) {
16
- throw new Error('Cannot refresh token: user not authenticated');
17
- }
18
- const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix);
19
- if (!existingCookie) {
20
- return {
21
- message: 'No valid token found to refresh',
22
- success: false
23
- };
24
- }
25
- const collection = result.user.collection;
26
- const collectionConfig = payload.collections[collection];
27
- if (!collectionConfig?.config.auth) {
28
- throw new Error(`No auth config found for collection: ${collection}`);
29
- }
30
- const req = await createLocalReq({
31
- user: result.user
32
- }, payload);
33
- const refreshResult = await refreshOperation({
34
- collection: collectionConfig,
35
- req
36
- });
37
- if (!refreshResult) {
38
- return {
39
- message: 'Token refresh failed',
40
- success: false
41
- };
42
- }
43
- await setPayloadAuthCookie({
44
- authConfig: collectionConfig.config.auth,
45
- cookiePrefix: payload.config.cookiePrefix,
46
- token: refreshResult.refreshedToken
47
- });
7
+ export async function refresh({
8
+ config
9
+ }) {
10
+ const payload = await getPayload({
11
+ config,
12
+ cron: true
13
+ });
14
+ const headers = await nextHeaders();
15
+ const result = await payload.auth({
16
+ headers
17
+ });
18
+ if (!result.user) {
19
+ throw new Error('Cannot refresh token: user not authenticated');
20
+ }
21
+ const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix);
22
+ if (!existingCookie) {
23
+ return {
24
+ message: 'No valid token found to refresh',
25
+ success: false
26
+ };
27
+ }
28
+ const collection = result.user.collection;
29
+ const collectionConfig = payload.collections[collection];
30
+ if (!collectionConfig?.config.auth) {
31
+ throw new Error(`No auth config found for collection: ${collection}`);
32
+ }
33
+ const req = await createLocalReq({
34
+ user: result.user
35
+ }, payload);
36
+ const refreshResult = await refreshOperation({
37
+ collection: collectionConfig,
38
+ req
39
+ });
40
+ if (!refreshResult) {
48
41
  return {
49
- message: 'Token refreshed successfully',
50
- success: true
42
+ message: 'Token refresh failed',
43
+ success: false
51
44
  };
45
+ }
46
+ await setPayloadAuthCookie({
47
+ authConfig: collectionConfig.config.auth,
48
+ cookiePrefix: payload.config.cookiePrefix,
49
+ token: refreshResult.refreshedToken
50
+ });
51
+ return {
52
+ message: 'Token refreshed successfully',
53
+ success: true
54
+ };
52
55
  }
53
-
54
56
  //# sourceMappingURL=refresh.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport { headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, refreshOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\nexport async function refresh({ config }: { config: any }) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const result = await payload.auth({ headers })\n\n if (!result.user) {\n throw new Error('Cannot refresh token: user not authenticated')\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (!existingCookie) {\n return { message: 'No valid token found to refresh', success: false }\n }\n\n const collection: CollectionSlug | undefined = result.user.collection\n const collectionConfig = payload.collections[collection]\n\n if (!collectionConfig?.config.auth) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const req = await createLocalReq({ user: result.user }, payload)\n\n const refreshResult = await refreshOperation({\n collection: collectionConfig,\n req,\n })\n\n if (!refreshResult) {\n return { message: 'Token refresh failed', success: false }\n }\n\n await setPayloadAuthCookie({\n authConfig: collectionConfig.config.auth,\n cookiePrefix: payload.config.cookiePrefix,\n token: refreshResult.refreshedToken,\n })\n\n return { message: 'Token refreshed successfully', success: true }\n}\n"],"names":["headers","nextHeaders","createLocalReq","getPayload","refreshOperation","getExistingAuthToken","setPayloadAuthCookie","refresh","config","payload","cron","result","auth","user","Error","existingCookie","cookiePrefix","message","success","collection","collectionConfig","collections","req","refreshResult","authConfig","token","refreshedToken"],"mappings":"AAAA;AAIA,SAASA,WAAWC,WAAW,QAAQ,kBAAiB;AACxD,SAASC,cAAc,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ,UAAS;AAEtE,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,eAAeC,QAAQ,EAAEC,MAAM,EAAmB;IACvD,MAAMC,UAAU,MAAMN,WAAW;QAAEK;QAAQE,MAAM;IAAK;IACtD,MAAMV,UAAU,MAAMC;IACtB,MAAMU,SAAS,MAAMF,QAAQG,IAAI,CAAC;QAAEZ;IAAQ;IAE5C,IAAI,CAACW,OAAOE,IAAI,EAAE;QAChB,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,iBAAiB,MAAMV,qBAAqBI,QAAQD,MAAM,CAACQ,YAAY;IAC7E,IAAI,CAACD,gBAAgB;QACnB,OAAO;YAAEE,SAAS;YAAmCC,SAAS;QAAM;IACtE;IAEA,MAAMC,aAAyCR,OAAOE,IAAI,CAACM,UAAU;IACrE,MAAMC,mBAAmBX,QAAQY,WAAW,CAACF,WAAW;IAExD,IAAI,CAACC,kBAAkBZ,OAAOI,MAAM;QAClC,MAAM,IAAIE,MAAM,CAAC,qCAAqC,EAAEK,YAAY;IACtE;IAEA,MAAMG,MAAM,MAAMpB,eAAe;QAAEW,MAAMF,OAAOE,IAAI;IAAC,GAAGJ;IAExD,MAAMc,gBAAgB,MAAMnB,iBAAiB;QAC3Ce,YAAYC;QACZE;IACF;IAEA,IAAI,CAACC,eAAe;QAClB,OAAO;YAAEN,SAAS;YAAwBC,SAAS;QAAM;IAC3D;IAEA,MAAMZ,qBAAqB;QACzBkB,YAAYJ,iBAAiBZ,MAAM,CAACI,IAAI;QACxCI,cAAcP,QAAQD,MAAM,CAACQ,YAAY;QACzCS,OAAOF,cAAcG,cAAc;IACrC;IAEA,OAAO;QAAET,SAAS;QAAgCC,SAAS;IAAK;AAClE"}
1
+ {"version":3,"file":"refresh.js","names":["headers","nextHeaders","createLocalReq","getPayload","refreshOperation","getExistingAuthToken","setPayloadAuthCookie","refresh","config","payload","cron","result","auth","user","Error","existingCookie","cookiePrefix","message","success","collection","collectionConfig","collections","req","refreshResult","authConfig","token","refreshedToken"],"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport { headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, refreshOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\nexport async function refresh({ config }: { config: any }) {\n const payload = await getPayload({ config, cron: true })\n const headers = await nextHeaders()\n const result = await payload.auth({ headers })\n\n if (!result.user) {\n throw new Error('Cannot refresh token: user not authenticated')\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (!existingCookie) {\n return { message: 'No valid token found to refresh', success: false }\n }\n\n const collection: CollectionSlug | undefined = result.user.collection\n const collectionConfig = payload.collections[collection]\n\n if (!collectionConfig?.config.auth) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const req = await createLocalReq({ user: result.user }, payload)\n\n const refreshResult = await refreshOperation({\n collection: collectionConfig,\n req,\n })\n\n if (!refreshResult) {\n return { message: 'Token refresh failed', success: false }\n }\n\n await setPayloadAuthCookie({\n authConfig: collectionConfig.config.auth,\n cookiePrefix: payload.config.cookiePrefix,\n token: refreshResult.refreshedToken,\n })\n\n return { message: 'Token refreshed successfully', success: true }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,WAAW,QAAQ;AACvC,SAASC,cAAc,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ;AAE7D,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,QAAQ;EAAEC;AAAM,CAAmB;EACvD,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;IAAEK,MAAA;IAAQE,IAAA,EAAM;EAAK;EACtD,MAAMV,OAAA,GAAU,MAAMC,WAAA;EACtB,MAAMU,MAAA,GAAS,MAAMF,OAAA,CAAQG,IAAI,CAAC;IAAEZ;EAAQ;EAE5C,IAAI,CAACW,MAAA,CAAOE,IAAI,EAAE;IAChB,MAAM,IAAIC,KAAA,CAAM;EAClB;EAEA,MAAMC,cAAA,GAAiB,MAAMV,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACQ,YAAY;EAC7E,IAAI,CAACD,cAAA,EAAgB;IACnB,OAAO;MAAEE,OAAA,EAAS;MAAmCC,OAAA,EAAS;IAAM;EACtE;EAEA,MAAMC,UAAA,GAAyCR,MAAA,CAAOE,IAAI,CAACM,UAAU;EACrE,MAAMC,gBAAA,GAAmBX,OAAA,CAAQY,WAAW,CAACF,UAAA,CAAW;EAExD,IAAI,CAACC,gBAAA,EAAkBZ,MAAA,CAAOI,IAAA,EAAM;IAClC,MAAM,IAAIE,KAAA,CAAM,wCAAwCK,UAAA,EAAY;EACtE;EAEA,MAAMG,GAAA,GAAM,MAAMpB,cAAA,CAAe;IAAEW,IAAA,EAAMF,MAAA,CAAOE;EAAK,GAAGJ,OAAA;EAExD,MAAMc,aAAA,GAAgB,MAAMnB,gBAAA,CAAiB;IAC3Ce,UAAA,EAAYC,gBAAA;IACZE;EACF;EAEA,IAAI,CAACC,aAAA,EAAe;IAClB,OAAO;MAAEN,OAAA,EAAS;MAAwBC,OAAA,EAAS;IAAM;EAC3D;EAEA,MAAMZ,oBAAA,CAAqB;IACzBkB,UAAA,EAAYJ,gBAAA,CAAiBZ,MAAM,CAACI,IAAI;IACxCI,YAAA,EAAcP,OAAA,CAAQD,MAAM,CAACQ,YAAY;IACzCS,KAAA,EAAOF,aAAA,CAAcG;EACvB;EAEA,OAAO;IAAET,OAAA,EAAS;IAAgCC,OAAA,EAAS;EAAK;AAClE","ignoreList":[]}
@@ -1,10 +1,4 @@
1
- /**
2
- * @param {import('next').NextConfig} nextConfig
3
- * @param {Object} [options] - Optional configuration options
4
- * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false
5
- *
6
- * @returns {import('next').NextConfig}
7
- * */ "use strict";
1
+ /* eslint-disable no-console */ /* eslint-disable no-restricted-exports */ "use strict";
8
2
  Object.defineProperty(exports, "__esModule", {
9
3
  value: true
10
4
  });
@@ -22,53 +16,23 @@ _export(exports, {
22
16
  return withPayload;
23
17
  }
24
18
  });
19
+ const _withPayloadutils = require("./withPayload.utils.js");
20
+ const _withPayloadLegacy = require("./withPayloadLegacy.js");
21
+ const poweredByHeader = {
22
+ key: 'X-Powered-By',
23
+ value: 'Next.js, Payload'
24
+ };
25
25
  const withPayload = (nextConfig = {}, options = {})=>{
26
+ const nextjsVersion = (0, _withPayloadutils.getNextjsVersion)();
27
+ const supportsTurbopackBuild = (0, _withPayloadutils.supportsTurbopackExternalizeTransitiveDependencies)(nextjsVersion);
26
28
  const env = nextConfig.env || {};
27
29
  if (nextConfig.experimental?.staleTimes?.dynamic) {
28
30
  console.warn('Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.');
29
31
  env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true';
30
32
  }
31
- if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') {
32
- // TODO: This warning is thrown because we cannot externalize the entry-point package for client-s3, so we patch the warning to not show it.
33
- // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991
34
- const turbopackWarningText = 'Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.\nTry to install it into the project directory by running';
35
- // TODO 4.0: Remove this once we drop support for Next.js 15.2.x
36
- const turbopackConfigWarningText = "Unrecognized key(s) in object: 'turbopack'";
37
- const consoleWarn = console.warn;
38
- console.warn = (...args)=>{
39
- // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805
40
- if (typeof args[1] === 'string' && args[1].includes(turbopackWarningText) || typeof args[0] === 'string' && args[0].includes(turbopackWarningText)) {
41
- return;
42
- }
43
- // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower.
44
- // TODO 4.0: Remove this once we drop support for Next.js 15.2.x
45
- const hasTurbopackConfigWarning = typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText) || typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText);
46
- if (hasTurbopackConfigWarning) {
47
- consoleWarn(...args);
48
- consoleWarn('Payload: You can safely ignore the "Invalid next.config" warning above. This only occurs on Next.js 15.2.x or lower. We recommend upgrading to Next.js 15.4.7 to resolve this warning.');
49
- return;
50
- }
51
- consoleWarn(...args);
52
- };
53
- }
54
- const isBuild = process.env.NODE_ENV === 'production';
55
- const isTurbopackNextjs15 = process.env.TURBOPACK === '1';
56
- const isTurbopackNextjs16 = process.env.TURBOPACK === 'auto';
57
- if (isBuild && (isTurbopackNextjs15 || isTurbopackNextjs16)) {
58
- throw new Error('Payload does not support using Turbopack for production builds. If you are using Next.js 16, please use `next build --webpack` instead.');
59
- }
60
- const poweredByHeader = {
61
- key: 'X-Powered-By',
62
- value: 'Next.js, Payload'
63
- };
64
- /**
65
- * @type {import('next').NextConfig}
66
- */ const toReturn = {
33
+ const baseConfig = {
67
34
  ...nextConfig,
68
35
  env,
69
- turbopack: {
70
- ...nextConfig.turbopack || {}
71
- },
72
36
  outputFileTracingExcludes: {
73
37
  ...nextConfig.outputFileTracingExcludes || {},
74
38
  '**/*': [
@@ -84,6 +48,9 @@ const withPayload = (nextConfig = {}, options = {})=>{
84
48
  '@libsql/client'
85
49
  ]
86
50
  },
51
+ turbopack: {
52
+ ...nextConfig.turbopack || {}
53
+ },
87
54
  // We disable the poweredByHeader here because we add it manually in the headers function below
88
55
  ...nextConfig.poweredByHeader !== false ? {
89
56
  poweredByHeader: false
@@ -93,7 +60,6 @@ const withPayload = (nextConfig = {}, options = {})=>{
93
60
  return [
94
61
  ...headersFromConfig || [],
95
62
  {
96
- source: '/:path*',
97
63
  headers: [
98
64
  {
99
65
  key: 'Accept-CH',
@@ -110,21 +76,15 @@ const withPayload = (nextConfig = {}, options = {})=>{
110
76
  ...nextConfig.poweredByHeader !== false ? [
111
77
  poweredByHeader
112
78
  ] : []
113
- ]
79
+ ],
80
+ source: '/:path*'
114
81
  }
115
82
  ];
116
83
  },
117
84
  serverExternalPackages: [
118
- // serverExternalPackages = webpack.externals, but with turbopack support and an additional check
119
- // for whether the package is resolvable from the project root
120
- ...nextConfig.serverExternalPackages || [],
121
- // Can be externalized, because we require users to install graphql themselves - we only rely on it as a peer dependency => resolvable from the project root.
122
- //
123
85
  // WHY: without externalizing graphql, a graphql version error will be thrown
124
86
  // during runtime ("Ensure that there is only one instance of \"graphql\" in the node_modules\ndirectory.")
125
87
  'graphql',
126
- // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.
127
- '@sentry/nextjs',
128
88
  ...process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true ? /**
129
89
  * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we
130
90
  * do not bundle server-only packages during dev for two reasons:
@@ -188,6 +148,13 @@ const withPayload = (nextConfig = {}, options = {})=>{
188
148
  'libsql',
189
149
  'require-in-the-middle'
190
150
  ],
151
+ plugins: [
152
+ ...incomingWebpackConfig?.plugins || [],
153
+ // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177
154
+ new webpackOptions.webpack.IgnorePlugin({
155
+ resourceRegExp: /^pg-native$|^cloudflare:sockets$/
156
+ })
157
+ ],
191
158
  resolve: {
192
159
  ...incomingWebpackConfig?.resolve || {},
193
160
  alias: {
@@ -215,21 +182,30 @@ const withPayload = (nextConfig = {}, options = {})=>{
215
182
  *
216
183
  **/ aws4: false
217
184
  }
218
- },
219
- plugins: [
220
- ...incomingWebpackConfig?.plugins || [],
221
- // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177
222
- new webpackOptions.webpack.IgnorePlugin({
223
- resourceRegExp: /^pg-native$|^cloudflare:sockets$/
224
- })
225
- ]
185
+ }
226
186
  };
227
187
  }
228
188
  };
229
189
  if (nextConfig.basePath) {
230
- toReturn.env.NEXT_BASE_PATH = nextConfig.basePath;
190
+ baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath;
191
+ }
192
+ if (!supportsTurbopackBuild) {
193
+ return (0, _withPayloadLegacy.withPayloadLegacy)(baseConfig);
194
+ } else {
195
+ return {
196
+ ...baseConfig,
197
+ serverExternalPackages: [
198
+ ...baseConfig.serverExternalPackages || [],
199
+ 'drizzle-kit',
200
+ 'drizzle-kit/api',
201
+ 'sharp',
202
+ 'libsql',
203
+ 'require-in-the-middle',
204
+ // Prevents turbopack build errors by the thread-stream package which is installed by pino
205
+ 'pino'
206
+ ]
207
+ };
231
208
  }
232
- return toReturn;
233
209
  };
234
210
  const _default = withPayload;
235
211
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/withPayload.js"],"names":["withPayload","nextConfig","options","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","process","PAYLOAD_PATCH_TURBOPACK_WARNINGS","turbopackWarningText","turbopackConfigWarningText","consoleWarn","args","includes","hasTurbopackConfigWarning","isBuild","NODE_ENV","isTurbopackNextjs15","TURBOPACK","isTurbopackNextjs16","Error","poweredByHeader","key","value","toReturn","turbopack","outputFileTracingExcludes","outputFileTracingIncludes","headers","headersFromConfig","source","serverExternalPackages","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","resolve","alias","fallback","aws4","plugins","IgnorePlugin","resourceRegExp","basePath","NEXT_BASE_PATH"],"mappings":"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","file":"withPayload.cjs","sourcesContent":["/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n *\n * @returns {import('next').NextConfig}\n * */\nexport const withPayload = (nextConfig = {}, options = {}) => {\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n if (process.env.PAYLOAD_PATCH_TURBOPACK_WARNINGS !== 'false') {\n // TODO: This warning is thrown because we cannot externalize the entry-point package for client-s3, so we patch the warning to not show it.\n // We can remove this once Next.js implements https://github.com/vercel/next.js/discussions/76991\n const turbopackWarningText =\n 'Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.\\nTry to install it into the project directory by running'\n\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const turbopackConfigWarningText = \"Unrecognized key(s) in object: 'turbopack'\"\n\n const consoleWarn = console.warn\n console.warn = (...args) => {\n // Force to disable serverExternalPackages warnings: https://github.com/vercel/next.js/issues/68805\n if (\n (typeof args[1] === 'string' && args[1].includes(turbopackWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackWarningText))\n ) {\n return\n }\n\n // Add Payload-specific message after turbopack config warning in Next.js 15.2.x or lower.\n // TODO 4.0: Remove this once we drop support for Next.js 15.2.x\n const hasTurbopackConfigWarning =\n (typeof args[1] === 'string' && args[1].includes(turbopackConfigWarningText)) ||\n (typeof args[0] === 'string' && args[0].includes(turbopackConfigWarningText))\n\n if (hasTurbopackConfigWarning) {\n consoleWarn(...args)\n consoleWarn(\n 'Payload: You can safely ignore the \"Invalid next.config\" warning above. This only occurs on Next.js 15.2.x or lower. We recommend upgrading to Next.js 15.4.7 to resolve this warning.',\n )\n return\n }\n\n consoleWarn(...args)\n }\n }\n\n const isBuild = process.env.NODE_ENV === 'production'\n const isTurbopackNextjs15 = process.env.TURBOPACK === '1'\n const isTurbopackNextjs16 = process.env.TURBOPACK === 'auto'\n\n if (isBuild && (isTurbopackNextjs15 || isTurbopackNextjs16)) {\n throw new Error(\n 'Payload does not support using Turbopack for production builds. If you are using Next.js 16, please use `next build --webpack` instead.',\n )\n }\n\n const poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n }\n\n /**\n * @type {import('next').NextConfig}\n */\n const toReturn = {\n ...nextConfig,\n env,\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n source: '/:path*',\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n },\n ]\n },\n serverExternalPackages: [\n // serverExternalPackages = webpack.externals, but with turbopack support and an additional check\n // for whether the package is resolvable from the project root\n ...(nextConfig.serverExternalPackages || []),\n // Can be externalized, because we require users to install graphql themselves - we only rely on it as a peer dependency => resolvable from the project root.\n //\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n // External, because it installs import-in-the-middle and require-in-the-middle - both in the default serverExternalPackages list.\n '@sentry/nextjs',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n }\n },\n }\n\n if (nextConfig.basePath) {\n toReturn.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n return toReturn\n}\n\nexport default withPayload\n"]}
1
+ {"version":3,"sources":["../../src/withPayload.ts"],"names":["withPayload","poweredByHeader","key","value","nextConfig","options","nextjsVersion","getNextjsVersion","supportsTurbopackBuild","supportsTurbopackExternalizeTransitiveDependencies","env","experimental","staleTimes","dynamic","console","warn","NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH","baseConfig","outputFileTracingExcludes","outputFileTracingIncludes","turbopack","headers","headersFromConfig","source","serverExternalPackages","process","NODE_ENV","devBundleServerPackages","webpack","webpackConfig","webpackOptions","incomingWebpackConfig","externals","plugins","IgnorePlugin","resourceRegExp","resolve","alias","fallback","aws4","basePath","NEXT_BASE_PATH","withPayloadLegacy"],"mappings":"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","file":"withPayload.cjs","sourcesContent":["/* eslint-disable no-console */\n/* eslint-disable no-restricted-exports */\nimport type { NextConfig } from 'next'\n\nimport {\n getNextjsVersion,\n supportsTurbopackExternalizeTransitiveDependencies,\n} from './withPayload.utils.js'\nimport { withPayloadLegacy } from './withPayloadLegacy.js'\n\nconst poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n}\n\n/**\n * @param {import('next').NextConfig} nextConfig\n * @param {Object} [options] - Optional configuration options\n * @param {boolean} [options.devBundleServerPackages] - Whether to bundle server packages in development mode. @default false\n * */\nexport const withPayload = (\n nextConfig: NextConfig = {},\n options: { devBundleServerPackages?: boolean } = {},\n): NextConfig => {\n const nextjsVersion = getNextjsVersion()\n\n const supportsTurbopackBuild = supportsTurbopackExternalizeTransitiveDependencies(nextjsVersion)\n\n const env = nextConfig.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n const baseConfig: NextConfig = {\n ...nextConfig,\n env,\n outputFileTracingExcludes: {\n ...(nextConfig.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n turbopack: {\n ...(nextConfig.turbopack || {}),\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n source: '/:path*',\n },\n ]\n },\n serverExternalPackages: [\n // WHY: without externalizing graphql, a graphql version error will be thrown\n // during runtime (\"Ensure that there is only one instance of \\\"graphql\\\" in the node_modules\\ndirectory.\")\n 'graphql',\n ...(process.env.NODE_ENV === 'development' && options.devBundleServerPackages !== true\n ? /**\n * Unless explicitly disabled by the user, by passing `devBundleServerPackages: true` to withPayload, we\n * do not bundle server-only packages during dev for two reasons:\n *\n * 1. Performance: Fewer files to compile means faster compilation speeds.\n * 2. Turbopack support: Webpack's externals are not supported by Turbopack.\n *\n * Regarding Turbopack support: Unlike webpack.externals, we cannot use serverExternalPackages to\n * externalized packages that are not resolvable from the project root. So including a package like\n * \"drizzle-kit\" in here would do nothing - Next.js will ignore the rule and still bundle the package -\n * because it detects that the package is not resolvable from the project root (= not directly installed\n * by the user in their own package.json).\n *\n * Instead, we can use serverExternalPackages for the entry-point packages that *are* installed directly\n * by the user (e.g. db-postgres, which then installs drizzle-kit as a dependency).\n *\n *\n *\n * We should only do this during development, not build, because externalizing these packages can hurt\n * the bundle size. Not only does it disable tree-shaking, it also risks installing duplicate copies of the\n * same package.\n *\n * Example:\n * - @payloadcms/richtext-lexical (in bundle) -> installs qs-esm (bundled because of importer)\n * - payload (not in bundle, external) -> installs qs-esm (external because of importer)\n * Result: we have two copies of qs-esm installed - one in the bundle, and one in node_modules.\n *\n * During development, these bundle size difference do not matter much, and development speed /\n * turbopack support are more important.\n */\n [\n 'payload',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/db-sqlite',\n '@payloadcms/db-vercel-postgres',\n '@payloadcms/db-d1-sqlite',\n '@payloadcms/drizzle',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/graphql',\n '@payloadcms/payload-cloud',\n '@payloadcms/plugin-redirects',\n // TODO: Add the following packages, excluding their /client subpath exports, once Next.js supports it\n // see: https://github.com/vercel/next.js/discussions/76991\n //'@payloadcms/plugin-cloud-storage',\n //'@payloadcms/plugin-sentry',\n //'@payloadcms/plugin-stripe',\n // @payloadcms/richtext-lexical\n //'@payloadcms/storage-azure',\n //'@payloadcms/storage-gcs',\n //'@payloadcms/storage-s3',\n //'@payloadcms/storage-uploadthing',\n //'@payloadcms/storage-vercel-blob',\n ]\n : []),\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n /**\n * See the explanation in the serverExternalPackages section above.\n * We need to force Webpack to emit require() calls for these packages, even though they are not\n * resolvable from the project root. You would expect this to error during runtime, but Next.js seems to be able to require these just fine.\n *\n * This is the only way to get Webpack Build to work, without the bundle size caveats of externalizing the\n * entry point packages, as explained in the serverExternalPackages section above.\n */\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n ],\n plugins: [\n ...(incomingWebpackConfig?.plugins || []),\n // Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177\n new webpackOptions.webpack.IgnorePlugin({\n resourceRegExp: /^pg-native$|^cloudflare:sockets$/,\n }),\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n /*\n * This fixes the following warning when running next build with webpack (tested on Next.js 16.0.3 with Payload 3.64.0):\n *\n * ⚠ Compiled with warnings in 8.7s\n *\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * Module not found: Can't resolve 'aws4' in '/Users/alessio/Documents/temp/next16p/node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib'\n *\n * Import trace for requested module:\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/deps.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/client-side-encryption/client_encryption.js\n * ./node_modules/.pnpm/mongodb@6.16.0/node_modules/mongodb/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/lib/index.js\n * ./node_modules/.pnpm/mongoose@8.15.1/node_modules/mongoose/index.js\n * ./node_modules/.pnpm/@payloadcms+db-mongodb@3.64.0_payload@3.64.0_graphql@16.12.0_typescript@5.7.3_/node_modules/@payloadcms/db-mongodb/dist/index.js\n * ./src/payload.config.ts\n * ./src/app/my-route/route.ts\n *\n **/\n aws4: false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n baseConfig.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n if (!supportsTurbopackBuild) {\n return withPayloadLegacy(baseConfig)\n } else {\n return {\n ...baseConfig,\n serverExternalPackages: [\n ...(baseConfig.serverExternalPackages || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n 'require-in-the-middle',\n // Prevents turbopack build errors by the thread-stream package which is installed by pino\n 'pino',\n ],\n }\n }\n}\n\nexport default withPayload\n"]}
package/dist/config.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export default {};
2
-
3
2
  //# sourceMappingURL=config.js.map