@payloadcms/next 3.15.2-canary.64ffcd8 → 3.15.2-canary.de7619e

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 (270) hide show
  1. package/dist/exports/utilities.d.ts +65 -5
  2. package/dist/exports/utilities.d.ts.map +1 -1
  3. package/dist/exports/utilities.js +49 -5
  4. package/dist/exports/utilities.js.map +1 -1
  5. package/dist/layouts/Root/index.d.ts.map +1 -1
  6. package/dist/layouts/Root/index.js +5 -2
  7. package/dist/layouts/Root/index.js.map +1 -1
  8. package/dist/layouts/Root/initJobAutoRun.d.ts +5 -0
  9. package/dist/layouts/Root/initJobAutoRun.d.ts.map +1 -0
  10. package/dist/layouts/Root/initJobAutoRun.js +23 -0
  11. package/dist/layouts/Root/initJobAutoRun.js.map +1 -0
  12. package/dist/routes/graphql/handler.d.ts.map +1 -1
  13. package/dist/routes/graphql/handler.js +1 -6
  14. package/dist/routes/graphql/handler.js.map +1 -1
  15. package/dist/routes/graphql/playground.d.ts +1 -1
  16. package/dist/routes/graphql/playground.d.ts.map +1 -1
  17. package/dist/routes/graphql/playground.js +1 -1
  18. package/dist/routes/graphql/playground.js.map +1 -1
  19. package/dist/routes/rest/index.d.ts +6 -26
  20. package/dist/routes/rest/index.d.ts.map +1 -1
  21. package/dist/routes/rest/index.js +25 -820
  22. package/dist/routes/rest/index.js.map +1 -1
  23. package/dist/routes/rest/og/index.d.ts +2 -8
  24. package/dist/routes/rest/og/index.d.ts.map +1 -1
  25. package/dist/routes/rest/og/index.js +3 -6
  26. package/dist/routes/rest/og/index.js.map +1 -1
  27. package/dist/templates/Default/index.d.ts +0 -4
  28. package/dist/templates/Default/index.d.ts.map +1 -1
  29. package/dist/templates/Default/index.js +1 -9
  30. package/dist/templates/Default/index.js.map +1 -1
  31. package/dist/utilities/getNextRequestI18n.d.ts +1 -1
  32. package/dist/utilities/getNextRequestI18n.d.ts.map +1 -1
  33. package/dist/utilities/getNextRequestI18n.js +1 -1
  34. package/dist/utilities/getNextRequestI18n.js.map +1 -1
  35. package/dist/utilities/getPayloadHMR.d.ts +8 -0
  36. package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
  37. package/dist/utilities/getPayloadHMR.js +8 -0
  38. package/dist/utilities/getPayloadHMR.js.map +1 -1
  39. package/dist/utilities/initReq.d.ts.map +1 -1
  40. package/dist/utilities/initReq.js +1 -2
  41. package/dist/utilities/initReq.js.map +1 -1
  42. package/dist/views/List/handleServerFunction.d.ts +1 -2
  43. package/dist/views/List/handleServerFunction.d.ts.map +1 -1
  44. package/dist/views/List/handleServerFunction.js.map +1 -1
  45. package/dist/views/List/index.d.ts.map +1 -1
  46. package/dist/views/List/index.js.map +1 -1
  47. package/dist/views/Root/getViewFromConfig.d.ts +0 -1
  48. package/dist/views/Root/getViewFromConfig.d.ts.map +1 -1
  49. package/dist/views/Root/getViewFromConfig.js +0 -2
  50. package/dist/views/Root/getViewFromConfig.js.map +1 -1
  51. package/dist/views/Root/index.d.ts.map +1 -1
  52. package/dist/views/Root/index.js +0 -5
  53. package/dist/views/Root/index.js.map +1 -1
  54. package/package.json +8 -7
  55. package/dist/fetchAPI-multipart/fileFactory.d.ts +0 -16
  56. package/dist/fetchAPI-multipart/fileFactory.d.ts.map +0 -1
  57. package/dist/fetchAPI-multipart/fileFactory.js +0 -44
  58. package/dist/fetchAPI-multipart/fileFactory.js.map +0 -1
  59. package/dist/fetchAPI-multipart/handlers.d.ts +0 -14
  60. package/dist/fetchAPI-multipart/handlers.d.ts.map +0 -1
  61. package/dist/fetchAPI-multipart/handlers.js +0 -87
  62. package/dist/fetchAPI-multipart/handlers.js.map +0 -1
  63. package/dist/fetchAPI-multipart/index.d.ts +0 -32
  64. package/dist/fetchAPI-multipart/index.d.ts.map +0 -1
  65. package/dist/fetchAPI-multipart/index.js +0 -43
  66. package/dist/fetchAPI-multipart/index.js.map +0 -1
  67. package/dist/fetchAPI-multipart/isEligibleRequest.d.ts +0 -2
  68. package/dist/fetchAPI-multipart/isEligibleRequest.d.ts.map +0 -1
  69. package/dist/fetchAPI-multipart/isEligibleRequest.js +0 -18
  70. package/dist/fetchAPI-multipart/isEligibleRequest.js.map +0 -1
  71. package/dist/fetchAPI-multipart/processMultipart.d.ts +0 -9
  72. package/dist/fetchAPI-multipart/processMultipart.d.ts.map +0 -1
  73. package/dist/fetchAPI-multipart/processMultipart.js +0 -178
  74. package/dist/fetchAPI-multipart/processMultipart.js.map +0 -1
  75. package/dist/fetchAPI-multipart/processNested.d.ts +0 -2
  76. package/dist/fetchAPI-multipart/processNested.d.ts.map +0 -1
  77. package/dist/fetchAPI-multipart/processNested.js +0 -31
  78. package/dist/fetchAPI-multipart/processNested.js.map +0 -1
  79. package/dist/fetchAPI-multipart/uploadTimer.d.ts +0 -7
  80. package/dist/fetchAPI-multipart/uploadTimer.d.ts.map +0 -1
  81. package/dist/fetchAPI-multipart/uploadTimer.js +0 -20
  82. package/dist/fetchAPI-multipart/uploadTimer.js.map +0 -1
  83. package/dist/fetchAPI-multipart/utilities.d.ts +0 -65
  84. package/dist/fetchAPI-multipart/utilities.d.ts.map +0 -1
  85. package/dist/fetchAPI-multipart/utilities.js +0 -227
  86. package/dist/fetchAPI-multipart/utilities.js.map +0 -1
  87. package/dist/fetchAPI-stream-file/index.d.ts +0 -5
  88. package/dist/fetchAPI-stream-file/index.d.ts.map +0 -1
  89. package/dist/fetchAPI-stream-file/index.js +0 -27
  90. package/dist/fetchAPI-stream-file/index.js.map +0 -1
  91. package/dist/routes/rest/auth/access.d.ts +0 -3
  92. package/dist/routes/rest/auth/access.d.ts.map +0 -1
  93. package/dist/routes/rest/auth/access.js +0 -28
  94. package/dist/routes/rest/auth/access.js.map +0 -1
  95. package/dist/routes/rest/auth/forgotPassword.d.ts +0 -3
  96. package/dist/routes/rest/auth/forgotPassword.d.ts.map +0 -1
  97. package/dist/routes/rest/auth/forgotPassword.js +0 -34
  98. package/dist/routes/rest/auth/forgotPassword.js.map +0 -1
  99. package/dist/routes/rest/auth/init.d.ts +0 -3
  100. package/dist/routes/rest/auth/init.d.ts.map +0 -1
  101. package/dist/routes/rest/auth/init.js +0 -20
  102. package/dist/routes/rest/auth/init.js.map +0 -1
  103. package/dist/routes/rest/auth/login.d.ts +0 -3
  104. package/dist/routes/rest/auth/login.d.ts.map +0 -1
  105. package/dist/routes/rest/auth/login.js +0 -49
  106. package/dist/routes/rest/auth/login.js.map +0 -1
  107. package/dist/routes/rest/auth/logout.d.ts +0 -3
  108. package/dist/routes/rest/auth/logout.d.ts.map +0 -1
  109. package/dist/routes/rest/auth/logout.js +0 -40
  110. package/dist/routes/rest/auth/logout.js.map +0 -1
  111. package/dist/routes/rest/auth/me.d.ts +0 -3
  112. package/dist/routes/rest/auth/me.d.ts.map +0 -1
  113. package/dist/routes/rest/auth/me.js +0 -28
  114. package/dist/routes/rest/auth/me.js.map +0 -1
  115. package/dist/routes/rest/auth/refresh.d.ts +0 -3
  116. package/dist/routes/rest/auth/refresh.d.ts.map +0 -1
  117. package/dist/routes/rest/auth/refresh.js +0 -38
  118. package/dist/routes/rest/auth/refresh.js.map +0 -1
  119. package/dist/routes/rest/auth/registerFirstUser.d.ts +0 -3
  120. package/dist/routes/rest/auth/registerFirstUser.d.ts.map +0 -1
  121. package/dist/routes/rest/auth/registerFirstUser.js +0 -48
  122. package/dist/routes/rest/auth/registerFirstUser.js.map +0 -1
  123. package/dist/routes/rest/auth/resetPassword.d.ts +0 -3
  124. package/dist/routes/rest/auth/resetPassword.d.ts.map +0 -1
  125. package/dist/routes/rest/auth/resetPassword.js +0 -43
  126. package/dist/routes/rest/auth/resetPassword.js.map +0 -1
  127. package/dist/routes/rest/auth/unlock.d.ts +0 -3
  128. package/dist/routes/rest/auth/unlock.d.ts.map +0 -1
  129. package/dist/routes/rest/auth/unlock.js +0 -32
  130. package/dist/routes/rest/auth/unlock.js.map +0 -1
  131. package/dist/routes/rest/auth/verifyEmail.d.ts +0 -3
  132. package/dist/routes/rest/auth/verifyEmail.d.ts.map +0 -1
  133. package/dist/routes/rest/auth/verifyEmail.js +0 -27
  134. package/dist/routes/rest/auth/verifyEmail.js.map +0 -1
  135. package/dist/routes/rest/checkEndpoints.d.ts +0 -5
  136. package/dist/routes/rest/checkEndpoints.d.ts.map +0 -1
  137. package/dist/routes/rest/checkEndpoints.js +0 -14
  138. package/dist/routes/rest/checkEndpoints.js.map +0 -1
  139. package/dist/routes/rest/collections/count.d.ts +0 -3
  140. package/dist/routes/rest/collections/count.d.ts.map +0 -1
  141. package/dist/routes/rest/collections/count.js +0 -19
  142. package/dist/routes/rest/collections/count.js.map +0 -1
  143. package/dist/routes/rest/collections/create.d.ts +0 -3
  144. package/dist/routes/rest/collections/create.d.ts.map +0 -1
  145. package/dist/routes/rest/collections/create.js +0 -39
  146. package/dist/routes/rest/collections/create.js.map +0 -1
  147. package/dist/routes/rest/collections/delete.d.ts +0 -3
  148. package/dist/routes/rest/collections/delete.d.ts.map +0 -1
  149. package/dist/routes/rest/collections/delete.js +0 -57
  150. package/dist/routes/rest/collections/delete.js.map +0 -1
  151. package/dist/routes/rest/collections/deleteByID.d.ts +0 -3
  152. package/dist/routes/rest/collections/deleteByID.d.ts.map +0 -1
  153. package/dist/routes/rest/collections/deleteByID.js +0 -50
  154. package/dist/routes/rest/collections/deleteByID.js.map +0 -1
  155. package/dist/routes/rest/collections/docAccess.d.ts +0 -3
  156. package/dist/routes/rest/collections/docAccess.d.ts.map +0 -1
  157. package/dist/routes/rest/collections/docAccess.js +0 -22
  158. package/dist/routes/rest/collections/docAccess.js.map +0 -1
  159. package/dist/routes/rest/collections/duplicate.d.ts +0 -3
  160. package/dist/routes/rest/collections/duplicate.d.ts.map +0 -1
  161. package/dist/routes/rest/collections/duplicate.js +0 -47
  162. package/dist/routes/rest/collections/duplicate.js.map +0 -1
  163. package/dist/routes/rest/collections/find.d.ts +0 -3
  164. package/dist/routes/rest/collections/find.d.ts.map +0 -1
  165. package/dist/routes/rest/collections/find.js +0 -43
  166. package/dist/routes/rest/collections/find.js.map +0 -1
  167. package/dist/routes/rest/collections/findByID.d.ts +0 -3
  168. package/dist/routes/rest/collections/findByID.d.ts.map +0 -1
  169. package/dist/routes/rest/collections/findByID.js +0 -38
  170. package/dist/routes/rest/collections/findByID.js.map +0 -1
  171. package/dist/routes/rest/collections/findVersionByID.d.ts +0 -3
  172. package/dist/routes/rest/collections/findVersionByID.d.ts.map +0 -1
  173. package/dist/routes/rest/collections/findVersionByID.js +0 -36
  174. package/dist/routes/rest/collections/findVersionByID.js.map +0 -1
  175. package/dist/routes/rest/collections/findVersions.d.ts +0 -3
  176. package/dist/routes/rest/collections/findVersions.d.ts.map +0 -1
  177. package/dist/routes/rest/collections/findVersions.js +0 -39
  178. package/dist/routes/rest/collections/findVersions.js.map +0 -1
  179. package/dist/routes/rest/collections/preview.d.ts +0 -3
  180. package/dist/routes/rest/collections/preview.d.ts.map +0 -1
  181. package/dist/routes/rest/collections/preview.js +0 -49
  182. package/dist/routes/rest/collections/preview.js.map +0 -1
  183. package/dist/routes/rest/collections/restoreVersion.d.ts +0 -3
  184. package/dist/routes/rest/collections/restoreVersion.d.ts.map +0 -1
  185. package/dist/routes/rest/collections/restoreVersion.js +0 -40
  186. package/dist/routes/rest/collections/restoreVersion.js.map +0 -1
  187. package/dist/routes/rest/collections/update.d.ts +0 -3
  188. package/dist/routes/rest/collections/update.d.ts.map +0 -1
  189. package/dist/routes/rest/collections/update.js +0 -62
  190. package/dist/routes/rest/collections/update.js.map +0 -1
  191. package/dist/routes/rest/collections/updateByID.d.ts +0 -3
  192. package/dist/routes/rest/collections/updateByID.d.ts.map +0 -1
  193. package/dist/routes/rest/collections/updateByID.js +0 -55
  194. package/dist/routes/rest/collections/updateByID.js.map +0 -1
  195. package/dist/routes/rest/files/checkFileAccess.d.ts +0 -7
  196. package/dist/routes/rest/files/checkFileAccess.d.ts.map +0 -1
  197. package/dist/routes/rest/files/checkFileAccess.js +0 -57
  198. package/dist/routes/rest/files/checkFileAccess.js.map +0 -1
  199. package/dist/routes/rest/files/getFile.d.ts +0 -9
  200. package/dist/routes/rest/files/getFile.d.ts.map +0 -1
  201. package/dist/routes/rest/files/getFile.js +0 -70
  202. package/dist/routes/rest/files/getFile.js.map +0 -1
  203. package/dist/routes/rest/files/getFileTypeFallback.d.ts +0 -7
  204. package/dist/routes/rest/files/getFileTypeFallback.d.ts.map +0 -1
  205. package/dist/routes/rest/files/getFileTypeFallback.js +0 -20
  206. package/dist/routes/rest/files/getFileTypeFallback.js.map +0 -1
  207. package/dist/routes/rest/globals/docAccess.d.ts +0 -3
  208. package/dist/routes/rest/globals/docAccess.d.ts.map +0 -1
  209. package/dist/routes/rest/globals/docAccess.js +0 -20
  210. package/dist/routes/rest/globals/docAccess.js.map +0 -1
  211. package/dist/routes/rest/globals/findOne.d.ts +0 -3
  212. package/dist/routes/rest/globals/findOne.d.ts.map +0 -1
  213. package/dist/routes/rest/globals/findOne.js +0 -30
  214. package/dist/routes/rest/globals/findOne.js.map +0 -1
  215. package/dist/routes/rest/globals/findVersionByID.d.ts +0 -3
  216. package/dist/routes/rest/globals/findVersionByID.d.ts.map +0 -1
  217. package/dist/routes/rest/globals/findVersionByID.js +0 -30
  218. package/dist/routes/rest/globals/findVersionByID.js.map +0 -1
  219. package/dist/routes/rest/globals/findVersions.d.ts +0 -3
  220. package/dist/routes/rest/globals/findVersions.d.ts.map +0 -1
  221. package/dist/routes/rest/globals/findVersions.js +0 -39
  222. package/dist/routes/rest/globals/findVersions.js.map +0 -1
  223. package/dist/routes/rest/globals/preview.d.ts +0 -3
  224. package/dist/routes/rest/globals/preview.d.ts.map +0 -1
  225. package/dist/routes/rest/globals/preview.js +0 -47
  226. package/dist/routes/rest/globals/preview.js.map +0 -1
  227. package/dist/routes/rest/globals/restoreVersion.d.ts +0 -3
  228. package/dist/routes/rest/globals/restoreVersion.d.ts.map +0 -1
  229. package/dist/routes/rest/globals/restoreVersion.js +0 -34
  230. package/dist/routes/rest/globals/restoreVersion.js.map +0 -1
  231. package/dist/routes/rest/globals/update.d.ts +0 -3
  232. package/dist/routes/rest/globals/update.d.ts.map +0 -1
  233. package/dist/routes/rest/globals/update.js +0 -46
  234. package/dist/routes/rest/globals/update.js.map +0 -1
  235. package/dist/routes/rest/routeError.d.ts +0 -9
  236. package/dist/routes/rest/routeError.d.ts.map +0 -1
  237. package/dist/routes/rest/routeError.js +0 -83
  238. package/dist/routes/rest/routeError.js.map +0 -1
  239. package/dist/routes/rest/types.d.ts +0 -23
  240. package/dist/routes/rest/types.d.ts.map +0 -1
  241. package/dist/routes/rest/types.js +0 -2
  242. package/dist/routes/rest/types.js.map +0 -1
  243. package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts +0 -9
  244. package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts.map +0 -1
  245. package/dist/routes/rest/utilities/sanitizeCollectionID.js +0 -20
  246. package/dist/routes/rest/utilities/sanitizeCollectionID.js.map +0 -1
  247. package/dist/utilities/addDataAndFileToRequest.d.ts +0 -8
  248. package/dist/utilities/addDataAndFileToRequest.d.ts.map +0 -1
  249. package/dist/utilities/addDataAndFileToRequest.js +0 -47
  250. package/dist/utilities/addDataAndFileToRequest.js.map +0 -1
  251. package/dist/utilities/addLocalesToRequest.d.ts +0 -17
  252. package/dist/utilities/addLocalesToRequest.d.ts.map +0 -1
  253. package/dist/utilities/addLocalesToRequest.js +0 -65
  254. package/dist/utilities/addLocalesToRequest.js.map +0 -1
  255. package/dist/utilities/createPayloadRequest.d.ts +0 -11
  256. package/dist/utilities/createPayloadRequest.d.ts.map +0 -1
  257. package/dist/utilities/createPayloadRequest.js +0 -103
  258. package/dist/utilities/createPayloadRequest.js.map +0 -1
  259. package/dist/utilities/getRequestLanguage.d.ts +0 -12
  260. package/dist/utilities/getRequestLanguage.d.ts.map +0 -1
  261. package/dist/utilities/getRequestLanguage.js +0 -19
  262. package/dist/utilities/getRequestLanguage.js.map +0 -1
  263. package/dist/utilities/headersWithCors.d.ts +0 -8
  264. package/dist/utilities/headersWithCors.d.ts.map +0 -1
  265. package/dist/utilities/headersWithCors.js +0 -24
  266. package/dist/utilities/headersWithCors.js.map +0 -1
  267. package/dist/utilities/mergeHeaders.d.ts +0 -2
  268. package/dist/utilities/mergeHeaders.d.ts.map +0 -1
  269. package/dist/utilities/mergeHeaders.js +0 -10
  270. package/dist/utilities/mergeHeaders.js.map +0 -1
@@ -142,7 +142,6 @@ export const getViewFromConfig = ({
142
142
  };
143
143
  templateClassName = `${segmentTwo}-list`;
144
144
  templateType = 'default';
145
- serverProps.viewType = 'list';
146
145
  serverProps.viewActions = serverProps.viewActions.concat(matchedCollection.admin.components?.views?.list?.actions);
147
146
  } else if (isGlobal && matchedGlobal) {
148
147
  // --> /globals/:globalSlug
@@ -179,7 +178,6 @@ export const getViewFromConfig = ({
179
178
  };
180
179
  templateClassName = `collection-default-edit`;
181
180
  templateType = 'default';
182
- serverProps.viewType = 'edit';
183
181
  // Adds view actions to the current collection view
184
182
  if (matchedCollection.admin?.components?.views?.edit) {
185
183
  if ('root' in matchedCollection.admin.components.views.edit) {
@@ -1 +1 @@
1
- {"version":3,"file":"getViewFromConfig.js","names":["formatAdminURL","Account","CreateFirstUserView","Dashboard","Document","DocumentView","forgotPasswordBaseClass","ForgotPasswordView","ListView","loginBaseClass","LoginView","LogoutInactivity","LogoutView","ResetPassword","resetPasswordBaseClass","UnauthorizedView","Verify","verifyBaseClass","getCustomViewByRoute","isPathMatchingRoute","baseClasses","account","forgot","login","reset","verify","oneSegmentViews","createFirstUser","inactivity","logout","unauthorized","getViewActions","editConfig","viewKey","actions","undefined","getViewFromConfig","adminRoute","config","currentRoute","importMap","searchParams","segments","ViewToRender","templateClassName","templateType","initPageOptions","route","segmentOne","segmentTwo","segmentThree","segmentFour","segmentFive","isGlobal","isCollection","matchedCollection","matchedGlobal","serverProps","viewActions","admin","components","collections","find","slug","collectionConfig","globals","globalConfig","length","Component","routes","matchedRoute","Object","entries","exact","path","viewType","concat","views","list","edit","view","reverse","DefaultView"],"sources":["../../../src/views/Root/getViewFromConfig.ts"],"sourcesContent":["import type {\n AdminViewComponent,\n AdminViewProps,\n CustomComponent,\n EditConfig,\n ImportMap,\n SanitizedConfig,\n} from 'payload'\nimport type React from 'react'\n\nimport { formatAdminURL } from '@payloadcms/ui/shared'\n\nimport type { initPage } from '../../utilities/initPage/index.js'\n\nimport { Account } from '../Account/index.js'\nimport { CreateFirstUserView } from '../CreateFirstUser/index.js'\nimport { Dashboard } from '../Dashboard/index.js'\nimport { Document as DocumentView } from '../Document/index.js'\nimport { forgotPasswordBaseClass, ForgotPasswordView } from '../ForgotPassword/index.js'\nimport { ListView } from '../List/index.js'\nimport { loginBaseClass, LoginView } from '../Login/index.js'\nimport { LogoutInactivity, LogoutView } from '../Logout/index.js'\nimport { ResetPassword, resetPasswordBaseClass } from '../ResetPassword/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { Verify, verifyBaseClass } from '../Verify/index.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\nconst baseClasses = {\n account: 'account',\n forgot: forgotPasswordBaseClass,\n login: loginBaseClass,\n reset: resetPasswordBaseClass,\n verify: verifyBaseClass,\n}\n\ntype OneSegmentViews = {\n [K in Exclude<keyof SanitizedConfig['admin']['routes'], 'reset'>]: React.FC<AdminViewProps>\n}\n\nexport type ViewFromConfig = {\n Component?: React.FC<AdminViewProps>\n payloadComponent?: AdminViewComponent\n}\n\nconst oneSegmentViews: OneSegmentViews = {\n account: Account,\n createFirstUser: CreateFirstUserView,\n forgot: ForgotPasswordView,\n inactivity: LogoutInactivity,\n login: LoginView,\n logout: LogoutView,\n unauthorized: UnauthorizedView,\n}\n\nfunction getViewActions({\n editConfig,\n viewKey,\n}: {\n editConfig: EditConfig\n viewKey: keyof EditConfig\n}): CustomComponent[] | undefined {\n if (editConfig && viewKey in editConfig && 'actions' in editConfig[viewKey]) {\n return editConfig[viewKey].actions\n }\n\n return undefined\n}\n\ntype ServerPropsFromView = {\n collectionConfig?: SanitizedConfig['collections'][number]\n globalConfig?: SanitizedConfig['globals'][number]\n viewActions: CustomComponent[]\n viewType?: 'edit' | 'list'\n}\n\ntype GetViewFromConfigArgs = {\n adminRoute: string\n config: SanitizedConfig\n currentRoute: string\n importMap: ImportMap\n searchParams: {\n [key: string]: string | string[]\n }\n segments: string[]\n}\n\ntype GetViewFromConfigResult = {\n DefaultView: ViewFromConfig\n initPageOptions: Parameters<typeof initPage>[0]\n serverProps: ServerPropsFromView\n templateClassName: string\n templateType: 'default' | 'minimal'\n}\n\nexport const getViewFromConfig = ({\n adminRoute,\n config,\n currentRoute,\n importMap,\n searchParams,\n segments,\n}: GetViewFromConfigArgs): GetViewFromConfigResult => {\n let ViewToRender: ViewFromConfig = null\n let templateClassName: string\n let templateType: 'default' | 'minimal' | undefined\n\n const initPageOptions: Parameters<typeof initPage>[0] = {\n config,\n importMap,\n route: currentRoute,\n searchParams,\n }\n\n const [segmentOne, segmentTwo, segmentThree, segmentFour, segmentFive] = segments\n\n const isGlobal = segmentOne === 'globals'\n const isCollection = segmentOne === 'collections'\n let matchedCollection: SanitizedConfig['collections'][number] = undefined\n let matchedGlobal: SanitizedConfig['globals'][number] = undefined\n\n const serverProps: ServerPropsFromView = {\n viewActions: config?.admin?.components?.actions || [],\n }\n\n if (isCollection) {\n matchedCollection = config.collections.find(({ slug }) => slug === segmentTwo)\n serverProps.collectionConfig = matchedCollection\n }\n\n if (isGlobal) {\n matchedGlobal = config.globals.find(({ slug }) => slug === segmentTwo)\n serverProps.globalConfig = matchedGlobal\n }\n\n switch (segments.length) {\n case 0: {\n if (currentRoute === adminRoute) {\n ViewToRender = {\n Component: Dashboard,\n }\n templateClassName = 'dashboard'\n templateType = 'default'\n }\n break\n }\n case 1: {\n // users can override the default routes via `admin.routes` config\n // i.e.{ admin: { routes: { logout: '/sign-out', inactivity: '/idle' }}}\n let viewKey: keyof typeof oneSegmentViews\n\n if (config.admin.routes) {\n const matchedRoute = Object.entries(config.admin.routes).find(([, route]) => {\n return isPathMatchingRoute({\n currentRoute,\n exact: true,\n path: formatAdminURL({ adminRoute, path: route }),\n })\n })\n\n if (matchedRoute) {\n viewKey = matchedRoute[0] as keyof typeof oneSegmentViews\n }\n }\n\n if (oneSegmentViews[viewKey]) {\n // --> /account\n // --> /create-first-user\n // --> /forgot\n // --> /login\n // --> /logout\n // --> /logout-inactivity\n // --> /unauthorized\n\n ViewToRender = {\n Component: oneSegmentViews[viewKey],\n }\n\n templateClassName = baseClasses[viewKey]\n templateType = 'minimal'\n\n if (viewKey === 'account') {\n templateType = 'default'\n }\n }\n break\n }\n case 2: {\n if (`/${segmentOne}` === config.admin.routes.reset) {\n // --> /reset/:token\n ViewToRender = {\n Component: ResetPassword,\n }\n templateClassName = baseClasses[segmentTwo]\n templateType = 'minimal'\n }\n\n if (isCollection && matchedCollection) {\n // --> /collections/:collectionSlug\n\n ViewToRender = {\n Component: ListView,\n }\n\n templateClassName = `${segmentTwo}-list`\n templateType = 'default'\n serverProps.viewType = 'list'\n serverProps.viewActions = serverProps.viewActions.concat(\n matchedCollection.admin.components?.views?.list?.actions,\n )\n } else if (isGlobal && matchedGlobal) {\n // --> /globals/:globalSlug\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = 'global-edit'\n templateType = 'default'\n\n // add default view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin?.components?.views?.edit,\n viewKey: 'default',\n }),\n )\n }\n break\n }\n default:\n if (segmentTwo === 'verify') {\n // --> /:collectionSlug/verify/:token\n ViewToRender = {\n Component: Verify,\n }\n\n templateClassName = 'verify'\n templateType = 'minimal'\n } else if (isCollection && matchedCollection) {\n // Custom Views\n // --> /collections/:collectionSlug/:id\n // --> /collections/:collectionSlug/:id/api\n // --> /collections/:collectionSlug/:id/preview\n // --> /collections/:collectionSlug/:id/versions\n // --> /collections/:collectionSlug/:id/versions/:versionID\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = `collection-default-edit`\n templateType = 'default'\n serverProps.viewType = 'edit'\n\n // Adds view actions to the current collection view\n if (matchedCollection.admin?.components?.views?.edit) {\n if ('root' in matchedCollection.admin.components.views.edit) {\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views?.edit,\n viewKey: 'root',\n }),\n )\n } else {\n if (segmentFive) {\n if (segmentFour === 'versions') {\n // add version view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views?.edit,\n viewKey: 'version',\n }),\n )\n }\n } else if (segmentFour) {\n if (segmentFour === 'versions') {\n // add versions view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views.edit,\n viewKey: 'versions',\n }),\n )\n } else if (segmentFour === 'preview') {\n // add livePreview view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views.edit,\n viewKey: 'livePreview',\n }),\n )\n } else if (segmentFour === 'api') {\n // add api view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views.edit,\n viewKey: 'api',\n }),\n )\n }\n } else if (segmentThree) {\n // add default view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views.edit,\n viewKey: 'default',\n }),\n )\n }\n }\n }\n } else if (isGlobal && matchedGlobal) {\n // Custom Views\n // --> /globals/:globalSlug/versions\n // --> /globals/:globalSlug/preview\n // --> /globals/:globalSlug/versions/:versionID\n // --> /globals/:globalSlug/api\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = `global-edit`\n templateType = 'default'\n\n // Adds view actions to the current global view\n if (matchedGlobal.admin?.components?.views?.edit) {\n if ('root' in matchedGlobal.admin.components.views.edit) {\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin.components?.views?.edit,\n viewKey: 'root',\n }),\n )\n } else {\n if (segmentFour) {\n if (segmentThree === 'versions') {\n // add version view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin?.components?.views?.edit,\n viewKey: 'version',\n }),\n )\n }\n } else if (segmentThree) {\n if (segmentThree === 'versions') {\n // add versions view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin?.components?.views?.edit,\n viewKey: 'versions',\n }),\n )\n } else if (segmentThree === 'preview') {\n // add livePreview view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin?.components?.views?.edit,\n viewKey: 'livePreview',\n }),\n )\n } else if (segmentThree === 'api') {\n // add api view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin?.components?.views?.edit,\n viewKey: 'api',\n }),\n )\n }\n }\n }\n }\n }\n break\n }\n\n if (!ViewToRender) {\n ViewToRender = getCustomViewByRoute({ config, currentRoute })?.view\n }\n\n serverProps.viewActions.reverse()\n\n return {\n DefaultView: ViewToRender,\n initPageOptions,\n serverProps,\n templateClassName,\n templateType,\n }\n}\n"],"mappings":"AAUA,SAASA,cAAc,QAAQ;AAI/B,SAASC,OAAO,QAAQ;AACxB,SAASC,mBAAmB,QAAQ;AACpC,SAASC,SAAS,QAAQ;AAC1B,SAASC,QAAA,IAAYC,YAAY,QAAQ;AACzC,SAASC,uBAAuB,EAAEC,kBAAkB,QAAQ;AAC5D,SAASC,QAAQ,QAAQ;AACzB,SAASC,cAAc,EAAEC,SAAS,QAAQ;AAC1C,SAASC,gBAAgB,EAAEC,UAAU,QAAQ;AAC7C,SAASC,aAAa,EAAEC,sBAAsB,QAAQ;AACtD,SAASC,gBAAgB,QAAQ;AACjC,SAASC,MAAM,EAAEC,eAAe,QAAQ;AACxC,SAASC,oBAAoB,QAAQ;AACrC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","names":["formatAdminURL","Account","CreateFirstUserView","Dashboard","Document","DocumentView","forgotPasswordBaseClass","ForgotPasswordView","ListView","loginBaseClass","LoginView","LogoutInactivity","LogoutView","ResetPassword","resetPasswordBaseClass","UnauthorizedView","Verify","verifyBaseClass","getCustomViewByRoute","isPathMatchingRoute","baseClasses","account","forgot","login","reset","verify","oneSegmentViews","createFirstUser","inactivity","logout","unauthorized","getViewActions","editConfig","viewKey","actions","undefined","getViewFromConfig","adminRoute","config","currentRoute","importMap","searchParams","segments","ViewToRender","templateClassName","templateType","initPageOptions","route","segmentOne","segmentTwo","segmentThree","segmentFour","segmentFive","isGlobal","isCollection","matchedCollection","matchedGlobal","serverProps","viewActions","admin","components","collections","find","slug","collectionConfig","globals","globalConfig","length","Component","routes","matchedRoute","Object","entries","exact","path","concat","views","list","edit","view","reverse","DefaultView"],"sources":["../../../src/views/Root/getViewFromConfig.ts"],"sourcesContent":["import type {\n AdminViewComponent,\n AdminViewProps,\n CustomComponent,\n EditConfig,\n ImportMap,\n SanitizedConfig,\n} from 'payload'\nimport type React from 'react'\n\nimport { formatAdminURL } from '@payloadcms/ui/shared'\n\nimport type { initPage } from '../../utilities/initPage/index.js'\n\nimport { Account } from '../Account/index.js'\nimport { CreateFirstUserView } from '../CreateFirstUser/index.js'\nimport { Dashboard } from '../Dashboard/index.js'\nimport { Document as DocumentView } from '../Document/index.js'\nimport { forgotPasswordBaseClass, ForgotPasswordView } from '../ForgotPassword/index.js'\nimport { ListView } from '../List/index.js'\nimport { loginBaseClass, LoginView } from '../Login/index.js'\nimport { LogoutInactivity, LogoutView } from '../Logout/index.js'\nimport { ResetPassword, resetPasswordBaseClass } from '../ResetPassword/index.js'\nimport { UnauthorizedView } from '../Unauthorized/index.js'\nimport { Verify, verifyBaseClass } from '../Verify/index.js'\nimport { getCustomViewByRoute } from './getCustomViewByRoute.js'\nimport { isPathMatchingRoute } from './isPathMatchingRoute.js'\n\nconst baseClasses = {\n account: 'account',\n forgot: forgotPasswordBaseClass,\n login: loginBaseClass,\n reset: resetPasswordBaseClass,\n verify: verifyBaseClass,\n}\n\ntype OneSegmentViews = {\n [K in Exclude<keyof SanitizedConfig['admin']['routes'], 'reset'>]: React.FC<AdminViewProps>\n}\n\nexport type ViewFromConfig = {\n Component?: React.FC<AdminViewProps>\n payloadComponent?: AdminViewComponent\n}\n\nconst oneSegmentViews: OneSegmentViews = {\n account: Account,\n createFirstUser: CreateFirstUserView,\n forgot: ForgotPasswordView,\n inactivity: LogoutInactivity,\n login: LoginView,\n logout: LogoutView,\n unauthorized: UnauthorizedView,\n}\n\nfunction getViewActions({\n editConfig,\n viewKey,\n}: {\n editConfig: EditConfig\n viewKey: keyof EditConfig\n}): CustomComponent[] | undefined {\n if (editConfig && viewKey in editConfig && 'actions' in editConfig[viewKey]) {\n return editConfig[viewKey].actions\n }\n\n return undefined\n}\n\ntype ServerPropsFromView = {\n collectionConfig?: SanitizedConfig['collections'][number]\n globalConfig?: SanitizedConfig['globals'][number]\n viewActions: CustomComponent[]\n}\n\ntype GetViewFromConfigArgs = {\n adminRoute: string\n config: SanitizedConfig\n currentRoute: string\n importMap: ImportMap\n searchParams: {\n [key: string]: string | string[]\n }\n segments: string[]\n}\n\ntype GetViewFromConfigResult = {\n DefaultView: ViewFromConfig\n initPageOptions: Parameters<typeof initPage>[0]\n serverProps: ServerPropsFromView\n templateClassName: string\n templateType: 'default' | 'minimal'\n}\n\nexport const getViewFromConfig = ({\n adminRoute,\n config,\n currentRoute,\n importMap,\n searchParams,\n segments,\n}: GetViewFromConfigArgs): GetViewFromConfigResult => {\n let ViewToRender: ViewFromConfig = null\n let templateClassName: string\n let templateType: 'default' | 'minimal' | undefined\n\n const initPageOptions: Parameters<typeof initPage>[0] = {\n config,\n importMap,\n route: currentRoute,\n searchParams,\n }\n\n const [segmentOne, segmentTwo, segmentThree, segmentFour, segmentFive] = segments\n\n const isGlobal = segmentOne === 'globals'\n const isCollection = segmentOne === 'collections'\n let matchedCollection: SanitizedConfig['collections'][number] = undefined\n let matchedGlobal: SanitizedConfig['globals'][number] = undefined\n\n const serverProps: ServerPropsFromView = {\n viewActions: config?.admin?.components?.actions || [],\n }\n\n if (isCollection) {\n matchedCollection = config.collections.find(({ slug }) => slug === segmentTwo)\n serverProps.collectionConfig = matchedCollection\n }\n\n if (isGlobal) {\n matchedGlobal = config.globals.find(({ slug }) => slug === segmentTwo)\n serverProps.globalConfig = matchedGlobal\n }\n\n switch (segments.length) {\n case 0: {\n if (currentRoute === adminRoute) {\n ViewToRender = {\n Component: Dashboard,\n }\n templateClassName = 'dashboard'\n templateType = 'default'\n }\n break\n }\n case 1: {\n // users can override the default routes via `admin.routes` config\n // i.e.{ admin: { routes: { logout: '/sign-out', inactivity: '/idle' }}}\n let viewKey: keyof typeof oneSegmentViews\n\n if (config.admin.routes) {\n const matchedRoute = Object.entries(config.admin.routes).find(([, route]) => {\n return isPathMatchingRoute({\n currentRoute,\n exact: true,\n path: formatAdminURL({ adminRoute, path: route }),\n })\n })\n\n if (matchedRoute) {\n viewKey = matchedRoute[0] as keyof typeof oneSegmentViews\n }\n }\n\n if (oneSegmentViews[viewKey]) {\n // --> /account\n // --> /create-first-user\n // --> /forgot\n // --> /login\n // --> /logout\n // --> /logout-inactivity\n // --> /unauthorized\n\n ViewToRender = {\n Component: oneSegmentViews[viewKey],\n }\n\n templateClassName = baseClasses[viewKey]\n templateType = 'minimal'\n\n if (viewKey === 'account') {\n templateType = 'default'\n }\n }\n break\n }\n case 2: {\n if (`/${segmentOne}` === config.admin.routes.reset) {\n // --> /reset/:token\n ViewToRender = {\n Component: ResetPassword,\n }\n templateClassName = baseClasses[segmentTwo]\n templateType = 'minimal'\n }\n\n if (isCollection && matchedCollection) {\n // --> /collections/:collectionSlug\n\n ViewToRender = {\n Component: ListView,\n }\n\n templateClassName = `${segmentTwo}-list`\n templateType = 'default'\n serverProps.viewActions = serverProps.viewActions.concat(\n matchedCollection.admin.components?.views?.list?.actions,\n )\n } else if (isGlobal && matchedGlobal) {\n // --> /globals/:globalSlug\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = 'global-edit'\n templateType = 'default'\n\n // add default view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin?.components?.views?.edit,\n viewKey: 'default',\n }),\n )\n }\n break\n }\n default:\n if (segmentTwo === 'verify') {\n // --> /:collectionSlug/verify/:token\n ViewToRender = {\n Component: Verify,\n }\n\n templateClassName = 'verify'\n templateType = 'minimal'\n } else if (isCollection && matchedCollection) {\n // Custom Views\n // --> /collections/:collectionSlug/:id\n // --> /collections/:collectionSlug/:id/api\n // --> /collections/:collectionSlug/:id/preview\n // --> /collections/:collectionSlug/:id/versions\n // --> /collections/:collectionSlug/:id/versions/:versionID\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = `collection-default-edit`\n templateType = 'default'\n\n // Adds view actions to the current collection view\n if (matchedCollection.admin?.components?.views?.edit) {\n if ('root' in matchedCollection.admin.components.views.edit) {\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views?.edit,\n viewKey: 'root',\n }),\n )\n } else {\n if (segmentFive) {\n if (segmentFour === 'versions') {\n // add version view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views?.edit,\n viewKey: 'version',\n }),\n )\n }\n } else if (segmentFour) {\n if (segmentFour === 'versions') {\n // add versions view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views.edit,\n viewKey: 'versions',\n }),\n )\n } else if (segmentFour === 'preview') {\n // add livePreview view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views.edit,\n viewKey: 'livePreview',\n }),\n )\n } else if (segmentFour === 'api') {\n // add api view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views.edit,\n viewKey: 'api',\n }),\n )\n }\n } else if (segmentThree) {\n // add default view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedCollection.admin?.components?.views.edit,\n viewKey: 'default',\n }),\n )\n }\n }\n }\n } else if (isGlobal && matchedGlobal) {\n // Custom Views\n // --> /globals/:globalSlug/versions\n // --> /globals/:globalSlug/preview\n // --> /globals/:globalSlug/versions/:versionID\n // --> /globals/:globalSlug/api\n\n ViewToRender = {\n Component: DocumentView,\n }\n\n templateClassName = `global-edit`\n templateType = 'default'\n\n // Adds view actions to the current global view\n if (matchedGlobal.admin?.components?.views?.edit) {\n if ('root' in matchedGlobal.admin.components.views.edit) {\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin.components?.views?.edit,\n viewKey: 'root',\n }),\n )\n } else {\n if (segmentFour) {\n if (segmentThree === 'versions') {\n // add version view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin?.components?.views?.edit,\n viewKey: 'version',\n }),\n )\n }\n } else if (segmentThree) {\n if (segmentThree === 'versions') {\n // add versions view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin?.components?.views?.edit,\n viewKey: 'versions',\n }),\n )\n } else if (segmentThree === 'preview') {\n // add livePreview view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin?.components?.views?.edit,\n viewKey: 'livePreview',\n }),\n )\n } else if (segmentThree === 'api') {\n // add api view actions\n serverProps.viewActions = serverProps.viewActions.concat(\n getViewActions({\n editConfig: matchedGlobal.admin?.components?.views?.edit,\n viewKey: 'api',\n }),\n )\n }\n }\n }\n }\n }\n break\n }\n\n if (!ViewToRender) {\n ViewToRender = getCustomViewByRoute({ config, currentRoute })?.view\n }\n\n serverProps.viewActions.reverse()\n\n return {\n DefaultView: ViewToRender,\n initPageOptions,\n serverProps,\n templateClassName,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
  serverProps: {
102
102
  ...serverProps,
103
103
  clientConfig,
104
- docID: initPageResult?.docID,
105
104
  i18n: initPageResult?.req.i18n,
106
105
  importMap,
107
106
  initPageResult,
@@ -117,9 +116,6 @@ export const RootPage = async ({
117
116
  className: templateClassName,
118
117
  children: RenderedView
119
118
  }), templateType === 'default' && /*#__PURE__*/_jsx(DefaultTemplate, {
120
- collectionSlug: initPageResult?.collectionConfig?.slug,
121
- docID: initPageResult?.docID,
122
- globalSlug: initPageResult?.globalConfig?.slug,
123
119
  i18n: initPageResult?.req.i18n,
124
120
  locale: initPageResult?.locale,
125
121
  params: params,
@@ -128,7 +124,6 @@ export const RootPage = async ({
128
124
  searchParams: searchParams,
129
125
  user: initPageResult?.req.user,
130
126
  viewActions: serverProps.viewActions,
131
- viewType: serverProps.viewType,
132
127
  visibleEntities: {
133
128
  // The reason we are not passing in initPageResult.visibleEntities directly is due to a "Cannot assign to read only property of object '#<Object>" error introduced in React 19
134
129
  // which this caused as soon as initPageResult.visibleEntities is passed in
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["RenderServerComponent","formatAdminURL","getClientConfig","notFound","redirect","React","Fragment","DefaultTemplate","MinimalTemplate","initPage","getViewFromConfig","generatePageMetadata","RootPage","config","configPromise","importMap","params","paramsPromise","searchParams","searchParamsPromise","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","currentRoute","path","Array","isArray","segments","join","DefaultView","initPageOptions","serverProps","templateClassName","templateType","initPageResult","dbHasUser","req","payload","db","findOne","collection","then","doc","Component","payloadComponent","redirectTo","createFirstUserRoute","collectionConfig","collections","find","slug","disableLocalStrategy","auth","clientConfig","i18n","RenderedView","clientProps","Fallback","docID","_jsxs","_jsx","className","collectionSlug","globalSlug","globalConfig","locale","permissions","viewActions","viewType","visibleEntities","globals"],"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { ImportMap, SanitizedConfig } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { initPage } from '../../utilities/initPage/index.js'\nimport { getViewFromConfig } from './getViewFromConfig.js'\n\nexport { generatePageMetadata } from './meta.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n importMap,\n params: paramsPromise,\n searchParams: searchParamsPromise,\n}: {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const params = await paramsPromise\n\n const currentRoute = formatAdminURL({\n adminRoute,\n path: `${Array.isArray(params.segments) ? `/${params.segments.join('/')}` : ''}`,\n })\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n\n const searchParams = await searchParamsPromise\n\n const { DefaultView, initPageOptions, serverProps, templateClassName, templateType } =\n getViewFromConfig({\n adminRoute,\n config,\n currentRoute,\n importMap,\n searchParams,\n segments,\n })\n\n const initPageResult = await initPage(initPageOptions)\n\n const dbHasUser =\n initPageResult.req.user ||\n (await initPageResult?.req.payload.db\n .findOne({\n collection: userSlug,\n req: initPageResult?.req,\n })\n ?.then((doc) => !!doc))\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent) {\n if (initPageResult?.req?.user) {\n notFound()\n }\n\n if (dbHasUser) {\n redirect(adminRoute)\n }\n }\n\n if (typeof initPageResult?.redirectTo === 'string') {\n redirect(initPageResult.redirectTo)\n }\n\n if (initPageResult) {\n const createFirstUserRoute = formatAdminURL({ adminRoute, path: _createFirstUserRoute })\n\n const collectionConfig = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = collectionConfig?.auth?.disableLocalStrategy\n\n if (disableLocalStrategy && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n }\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {\n redirect(adminRoute)\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n: initPageResult?.req.i18n,\n importMap,\n })\n\n const RenderedView = RenderServerComponent({\n clientProps: { clientConfig },\n Component: DefaultView.payloadComponent,\n Fallback: DefaultView.Component,\n importMap,\n serverProps: {\n ...serverProps,\n clientConfig,\n docID: initPageResult?.docID,\n i18n: initPageResult?.req.i18n,\n importMap,\n initPageResult,\n params,\n payload: initPageResult?.req.payload,\n searchParams,\n },\n })\n\n return (\n <Fragment>\n {!templateType && <Fragment>{RenderedView}</Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n collectionSlug={initPageResult?.collectionConfig?.slug}\n docID={initPageResult?.docID}\n globalSlug={initPageResult?.globalConfig?.slug}\n i18n={initPageResult?.req.i18n}\n locale={initPageResult?.locale}\n params={params}\n payload={initPageResult?.req.payload}\n permissions={initPageResult?.permissions}\n searchParams={searchParams}\n user={initPageResult?.req.user}\n viewActions={serverProps.viewActions}\n viewType={serverProps.viewType}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: initPageResult?.visibleEntities?.collections,\n globals: initPageResult?.visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </Fragment>\n )\n}\n"],"mappings":";AAIA,SAASA,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,EAAEC,QAAQ,QAAQ;AACnC,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AACzB,SAASC,iBAAiB,QAAQ;AAElC,SAASC,oBAAoB,QAAQ;AASrC,OAAO,MAAMC,QAAA,GAAW,MAAAA,CAAO;EAC7BC,MAAA,EAAQC,aAAa;EACrBC,SAAS;EACTC,MAAA,EAAQC,aAAa;EACrBC,YAAA,EAAcC;AAAmB,CAUlC;EACC,MAAMN,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAM;IACJM,KAAA,EAAO;MACLC,MAAA,EAAQ;QAAEC,eAAA,EAAiBC;MAAqB,CAAE;MAClDC,IAAA,EAAMC;IAAQ,CACf;IACDJ,MAAA,EAAQ;MAAED,KAAA,EAAOM;IAAU;EAAE,CAC9B,GAAGb,MAAA;EAEJ,MAAMG,MAAA,GAAS,MAAMC,aAAA;EAErB,MAAMU,YAAA,GAAe1B,cAAA,CAAe;IAClCyB,UAAA;IACAE,IAAA,EAAM,GAAGC,KAAA,CAAMC,OAAO,CAACd,MAAA,CAAOe,QAAQ,IAAI,IAAIf,MAAA,CAAOe,QAAQ,CAACC,IAAI,CAAC,MAAM,GAAG;EAC9E;EAEA,MAAMD,QAAA,GAAWF,KAAA,CAAMC,OAAO,CAACd,MAAA,CAAOe,QAAQ,IAAIf,MAAA,CAAOe,QAAQ,GAAG,EAAE;EAEtE,MAAMb,YAAA,GAAe,MAAMC,mBAAA;EAE3B,MAAM;IAAEc,WAAW;IAAEC,eA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IAAA;MAC1CI,IAAA,EAAMpB,cAAA,EAAgBE,GAAA,CAAIkB,IAAA;MAC1BW,MAAA,EAAQ/B,cAAA,EAAgB+B,MAAA;MACxBrD,MAAA,EAAQA,MAAA;MACRyB,OAAA,EAASH,cAAA,EAAgBE,GAAA,CAAIC,OAAA;MAC7B6B,WAAA,EAAahC,cAAA,EAAgBgC,WAAA;MAC7BpD,YAAA,EAAcA,YAAA;MACdM,IAAA,EAAMc,cAAA,EAAgBE,GAAA,CAAIhB,IAAA;MAC1B+C,WAAA,EAAapC,WAAA,CAAYoC,WAAW;MACpCC,QAAA,EAAUrC,WAAA,CAAYqC,QAAQ;MAC9BC,eAAA,EAAiB;QACf;QACA;QACArB,WAAA,EAAad,cAAA,EAAgBmC,eAAA,EAAiBrB,WAAA;QAC9CsB,OAAA,EAASpC,cAAA,EAAgBmC,eAAA,EAAiBC;MAC5C;gBAECf;;;AAKX","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["RenderServerComponent","formatAdminURL","getClientConfig","notFound","redirect","React","Fragment","DefaultTemplate","MinimalTemplate","initPage","getViewFromConfig","generatePageMetadata","RootPage","config","configPromise","importMap","params","paramsPromise","searchParams","searchParamsPromise","admin","routes","createFirstUser","_createFirstUserRoute","user","userSlug","adminRoute","currentRoute","path","Array","isArray","segments","join","DefaultView","initPageOptions","serverProps","templateClassName","templateType","initPageResult","dbHasUser","req","payload","db","findOne","collection","then","doc","Component","payloadComponent","redirectTo","createFirstUserRoute","collectionConfig","collections","find","slug","disableLocalStrategy","auth","clientConfig","i18n","RenderedView","clientProps","Fallback","_jsxs","_jsx","className","locale","permissions","viewActions","visibleEntities","globals"],"sources":["../../../src/views/Root/index.tsx"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { Metadata } from 'next'\nimport type { ImportMap, SanitizedConfig } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { formatAdminURL } from '@payloadcms/ui/shared'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { notFound, redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { DefaultTemplate } from '../../templates/Default/index.js'\nimport { MinimalTemplate } from '../../templates/Minimal/index.js'\nimport { initPage } from '../../utilities/initPage/index.js'\nimport { getViewFromConfig } from './getViewFromConfig.js'\n\nexport { generatePageMetadata } from './meta.js'\n\nexport type GenerateViewMetadata = (args: {\n config: SanitizedConfig\n i18n: I18nClient\n isEditing?: boolean\n params?: { [key: string]: string | string[] }\n}) => Promise<Metadata>\n\nexport const RootPage = async ({\n config: configPromise,\n importMap,\n params: paramsPromise,\n searchParams: searchParamsPromise,\n}: {\n readonly config: Promise<SanitizedConfig>\n readonly importMap: ImportMap\n readonly params: Promise<{\n segments: string[]\n }>\n readonly searchParams: Promise<{\n [key: string]: string | string[]\n }>\n}) => {\n const config = await configPromise\n\n const {\n admin: {\n routes: { createFirstUser: _createFirstUserRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute },\n } = config\n\n const params = await paramsPromise\n\n const currentRoute = formatAdminURL({\n adminRoute,\n path: `${Array.isArray(params.segments) ? `/${params.segments.join('/')}` : ''}`,\n })\n\n const segments = Array.isArray(params.segments) ? params.segments : []\n\n const searchParams = await searchParamsPromise\n\n const { DefaultView, initPageOptions, serverProps, templateClassName, templateType } =\n getViewFromConfig({\n adminRoute,\n config,\n currentRoute,\n importMap,\n searchParams,\n segments,\n })\n\n const initPageResult = await initPage(initPageOptions)\n\n const dbHasUser =\n initPageResult.req.user ||\n (await initPageResult?.req.payload.db\n .findOne({\n collection: userSlug,\n req: initPageResult?.req,\n })\n ?.then((doc) => !!doc))\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent) {\n if (initPageResult?.req?.user) {\n notFound()\n }\n\n if (dbHasUser) {\n redirect(adminRoute)\n }\n }\n\n if (typeof initPageResult?.redirectTo === 'string') {\n redirect(initPageResult.redirectTo)\n }\n\n if (initPageResult) {\n const createFirstUserRoute = formatAdminURL({ adminRoute, path: _createFirstUserRoute })\n\n const collectionConfig = config.collections.find(({ slug }) => slug === userSlug)\n const disableLocalStrategy = collectionConfig?.auth?.disableLocalStrategy\n\n if (disableLocalStrategy && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n\n if (!dbHasUser && currentRoute !== createFirstUserRoute && !disableLocalStrategy) {\n redirect(createFirstUserRoute)\n }\n\n if (dbHasUser && currentRoute === createFirstUserRoute) {\n redirect(adminRoute)\n }\n }\n\n if (!DefaultView?.Component && !DefaultView?.payloadComponent && !dbHasUser) {\n redirect(adminRoute)\n }\n\n const clientConfig = getClientConfig({\n config,\n i18n: initPageResult?.req.i18n,\n importMap,\n })\n\n const RenderedView = RenderServerComponent({\n clientProps: { clientConfig },\n Component: DefaultView.payloadComponent,\n Fallback: DefaultView.Component,\n importMap,\n serverProps: {\n ...serverProps,\n clientConfig,\n i18n: initPageResult?.req.i18n,\n importMap,\n initPageResult,\n params,\n payload: initPageResult?.req.payload,\n searchParams,\n },\n })\n\n return (\n <Fragment>\n {!templateType && <Fragment>{RenderedView}</Fragment>}\n {templateType === 'minimal' && (\n <MinimalTemplate className={templateClassName}>{RenderedView}</MinimalTemplate>\n )}\n {templateType === 'default' && (\n <DefaultTemplate\n i18n={initPageResult?.req.i18n}\n locale={initPageResult?.locale}\n params={params}\n payload={initPageResult?.req.payload}\n permissions={initPageResult?.permissions}\n searchParams={searchParams}\n user={initPageResult?.req.user}\n viewActions={serverProps.viewActions}\n visibleEntities={{\n // The reason we are not passing in initPageResult.visibleEntities directly is due to a \"Cannot assign to read only property of object '#<Object>\" error introduced in React 19\n // which this caused as soon as initPageResult.visibleEntities is passed in\n collections: initPageResult?.visibleEntities?.collections,\n globals: initPageResult?.visibleEntities?.globals,\n }}\n >\n {RenderedView}\n </DefaultTemplate>\n )}\n </Fragment>\n )\n}\n"],"mappings":";AAIA,SAASA,qBAAqB,QAAQ;AACtC,SAASC,cAAc,QAAQ;AAC/B,SAASC,eAAe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AAgB8B,eAAA,EAAiBhB,WAAA;QAC9CiB,OAAA,EAAS/B,cAAA,EAAgB8B,eAAA,EAAiBC;MAC5C;gBAECV;;;AAKX","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/next",
3
- "version": "3.15.2-canary.64ffcd8",
3
+ "version": "3.15.2-canary.de7619e",
4
4
  "homepage": "https://payloadcms.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -69,6 +69,7 @@
69
69
  "dependencies": {
70
70
  "@dnd-kit/core": "6.0.8",
71
71
  "busboy": "^1.6.0",
72
+ "croner": "9.0.0",
72
73
  "file-type": "19.3.0",
73
74
  "graphql-http": "^1.22.0",
74
75
  "graphql-playground-html": "1.6.30",
@@ -79,9 +80,9 @@
79
80
  "sass": "1.77.4",
80
81
  "sonner": "^1.7.0",
81
82
  "uuid": "10.0.0",
82
- "@payloadcms/graphql": "3.15.2-canary.64ffcd8",
83
- "@payloadcms/translations": "3.15.2-canary.64ffcd8",
84
- "@payloadcms/ui": "3.15.2-canary.64ffcd8"
83
+ "@payloadcms/graphql": "3.15.2-canary.de7619e",
84
+ "@payloadcms/ui": "3.15.2-canary.de7619e",
85
+ "@payloadcms/translations": "3.15.2-canary.de7619e"
85
86
  },
86
87
  "devDependencies": {
87
88
  "@babel/cli": "7.25.9",
@@ -99,13 +100,13 @@
99
100
  "esbuild-sass-plugin": "3.3.1",
100
101
  "eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
101
102
  "swc-plugin-transform-remove-imports": "2.0.0",
102
- "@payloadcms/eslint-config": "3.9.0",
103
- "payload": "3.15.2-canary.64ffcd8"
103
+ "payload": "3.15.2-canary.de7619e",
104
+ "@payloadcms/eslint-config": "3.9.0"
104
105
  },
105
106
  "peerDependencies": {
106
107
  "graphql": "^16.8.1",
107
108
  "next": "^15.0.0",
108
- "payload": "3.15.2-canary.64ffcd8"
109
+ "payload": "3.15.2-canary.de7619e"
109
110
  },
110
111
  "engines": {
111
112
  "node": "^18.20.2 || >=20.9.0"
@@ -1,16 +0,0 @@
1
- import type { FetchAPIFileUploadOptions } from 'payload';
2
- import type { FileShape } from './index.js';
3
- type FileFactoryOptions = {
4
- buffer: Buffer;
5
- encoding: string;
6
- hash: Buffer | string;
7
- mimetype: string;
8
- name: string;
9
- size: number;
10
- tempFilePath: string;
11
- truncated: boolean;
12
- };
13
- type FileFactory = (options: FileFactoryOptions, fileUploadOptions: FetchAPIFileUploadOptions) => FileShape;
14
- export declare const fileFactory: FileFactory;
15
- export {};
16
- //# sourceMappingURL=fileFactory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileFactory.d.ts","sourceRoot":"","sources":["../../src/fetchAPI-multipart/fileFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAmC3C,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AACD,KAAK,WAAW,GAAG,CACjB,OAAO,EAAE,kBAAkB,EAC3B,iBAAiB,EAAE,yBAAyB,KACzC,SAAS,CAAA;AACd,eAAO,MAAM,WAAW,EAAE,WA4BzB,CAAA"}
@@ -1,44 +0,0 @@
1
- import { checkAndMakeDir, debugLog, isFunc, moveFile, promiseCallback, saveBufferToFile } from './utilities.js';
2
- /**
3
- * Returns Local function that moves the file to a different location on the filesystem
4
- * which takes two function arguments to make it compatible w/ Promise or Callback APIs
5
- */
6
- const moveFromTemp = (filePath, options, fileUploadOptions) => (resolve, reject) => {
7
- debugLog(fileUploadOptions, `Moving temporary file ${options.tempFilePath} to ${filePath}`);
8
- moveFile(options.tempFilePath, filePath, promiseCallback(resolve, reject));
9
- };
10
- /**
11
- * Returns Local function that moves the file from buffer to a different location on the filesystem
12
- * which takes two function arguments to make it compatible w/ Promise or Callback APIs
13
- */
14
- const moveFromBuffer = (filePath, options, fileUploadOptions) => (resolve, reject) => {
15
- debugLog(fileUploadOptions, `Moving uploaded buffer to ${filePath}`);
16
- saveBufferToFile(options.buffer, filePath, promiseCallback(resolve, reject));
17
- };
18
- export const fileFactory = (options, fileUploadOptions) => {
19
- // see: https://github.com/richardgirges/express-fileupload/issues/14
20
- // firefox uploads empty file in case of cache miss when f5ing page.
21
- // resulting in unexpected behavior. if there is no file data, the file is invalid.
22
- // if (!fileUploadOptions.useTempFiles && !options.buffer.length) return;
23
- // Create and return file object.
24
- return {
25
- name: options.name,
26
- data: options.buffer,
27
- encoding: options.encoding,
28
- md5: options.hash,
29
- mimetype: options.mimetype,
30
- mv: (filePath, callback) => {
31
- // Define a proper move function.
32
- const moveFunc = fileUploadOptions.useTempFiles ? moveFromTemp(filePath, options, fileUploadOptions) : moveFromBuffer(filePath, options, fileUploadOptions);
33
- // Create a folder for a file.
34
- checkAndMakeDir(fileUploadOptions, filePath);
35
- // If callback is passed in, use the callback API, otherwise return a promise.
36
- const defaultReject = () => undefined;
37
- return isFunc(callback) ? moveFunc(callback, defaultReject) : new Promise(moveFunc);
38
- },
39
- size: options.size,
40
- tempFilePath: options.tempFilePath,
41
- truncated: options.truncated
42
- };
43
- };
44
- //# sourceMappingURL=fileFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileFactory.js","names":["checkAndMakeDir","debugLog","isFunc","moveFile","promiseCallback","saveBufferToFile","moveFromTemp","filePath","options","fileUploadOptions","resolve","reject","tempFilePath","moveFromBuffer","buffer","fileFactory","name","data","encoding","md5","hash","mimetype","mv","callback","moveFunc","useTempFiles","defaultReject","undefined","Promise","size","truncated"],"sources":["../../src/fetchAPI-multipart/fileFactory.ts"],"sourcesContent":["import type { FetchAPIFileUploadOptions } from 'payload'\n\nimport type { FileShape } from './index.js'\n\nimport {\n checkAndMakeDir,\n debugLog,\n isFunc,\n moveFile,\n promiseCallback,\n saveBufferToFile,\n} from './utilities.js'\n\ntype MoveFile = (\n filePath: string,\n options: FileFactoryOptions,\n fileUploadOptions: FetchAPIFileUploadOptions,\n) => (resolve: () => void, reject: () => void) => void\n\n/**\n * Returns Local function that moves the file to a different location on the filesystem\n * which takes two function arguments to make it compatible w/ Promise or Callback APIs\n */\nconst moveFromTemp: MoveFile = (filePath, options, fileUploadOptions) => (resolve, reject) => {\n debugLog(fileUploadOptions, `Moving temporary file ${options.tempFilePath} to ${filePath}`)\n moveFile(options.tempFilePath, filePath, promiseCallback(resolve, reject))\n}\n\n/**\n * Returns Local function that moves the file from buffer to a different location on the filesystem\n * which takes two function arguments to make it compatible w/ Promise or Callback APIs\n */\nconst moveFromBuffer: MoveFile = (filePath, options, fileUploadOptions) => (resolve, reject) => {\n debugLog(fileUploadOptions, `Moving uploaded buffer to ${filePath}`)\n saveBufferToFile(options.buffer, filePath, promiseCallback(resolve, reject))\n}\n\ntype FileFactoryOptions = {\n buffer: Buffer\n encoding: string\n hash: Buffer | string\n mimetype: string\n name: string\n size: number\n tempFilePath: string\n truncated: boolean\n}\ntype FileFactory = (\n options: FileFactoryOptions,\n fileUploadOptions: FetchAPIFileUploadOptions,\n) => FileShape\nexport const fileFactory: FileFactory = (options, fileUploadOptions) => {\n // see: https://github.com/richardgirges/express-fileupload/issues/14\n // firefox uploads empty file in case of cache miss when f5ing page.\n // resulting in unexpected behavior. if there is no file data, the file is invalid.\n // if (!fileUploadOptions.useTempFiles && !options.buffer.length) return;\n\n // Create and return file object.\n return {\n name: options.name,\n data: options.buffer,\n encoding: options.encoding,\n md5: options.hash,\n mimetype: options.mimetype,\n mv: (filePath: string, callback) => {\n // Define a proper move function.\n const moveFunc = fileUploadOptions.useTempFiles\n ? moveFromTemp(filePath, options, fileUploadOptions)\n : moveFromBuffer(filePath, options, fileUploadOptions)\n // Create a folder for a file.\n checkAndMakeDir(fileUploadOptions, filePath)\n // If callback is passed in, use the callback API, otherwise return a promise.\n const defaultReject = () => undefined\n return isFunc(callback) ? moveFunc(callback, defaultReject) : new Promise(moveFunc)\n },\n size: options.size,\n tempFilePath: options.tempFilePath,\n truncated: options.truncated,\n }\n}\n"],"mappings":"AAIA,SACEA,eAAe,EACfC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,eAAe,EACfC,gBAAgB,QACX;AAQP;;;;AAIA,MAAMC,YAAA,GAAyBA,CAACC,QAAA,EAAUC,OAAA,EAASC,iBAAA,KAAsB,CAACC,OAAA,EAASC,MAAA;EACjFV,QAAA,CAASQ,iBAAA,EAAmB,yBAAyBD,OAAA,CAAQI,YAAY,OAAOL,QAAA,EAAU;EAC1FJ,QAAA,CAASK,OAAA,CAAQI,YAAY,EAAEL,QAAA,EAAUH,eAAA,CAAgBM,OAAA,EAASC,MAAA;AACpE;AAEA;;;;AAIA,MAAME,cAAA,GAA2BA,CAACN,QAAA,EAAUC,OAAA,EAASC,iBAAA,KAAsB,CAACC,OAAA,EAASC,MAAA;EACnFV,QAAA,CAASQ,iBAAA,EAAmB,6BAA6BF,QAAA,EAAU;EACnEF,gBAAA,CAAiBG,OAAA,CAAQM,MAAM,EAAEP,QAAA,EAAUH,eAAA,CAAgBM,OAAA,EAASC,MAAA;AACtE;AAgBA,OAAO,MAAMI,WAAA,GAA2BA,CAACP,OAAA,EAASC,iBAAA;EAChD;EACA;EACA;EACA;EAEA;EACA,OAAO;IACLO,IAAA,EAAMR,OAAA,CAAQQ,IAAI;IAClBC,IAAA,EAAMT,OAAA,CAAQM,MAAM;IACpBI,QAAA,EAAUV,OAAA,CAAQU,QAAQ;IAC1BC,GAAA,EAAKX,OAAA,CAAQY,IAAI;IACjBC,QAAA,EAAUb,OAAA,CAAQa,QAAQ;IAC1BC,EAAA,EAAIA,CAACf,QAAA,EAAkBgB,QAAA;MACrB;MACA,MAAMC,QAAA,GAAWf,iBAAA,CAAkBgB,YAAY,GAC3CnB,YAAA,CAAaC,QAAA,EAAUC,OAAA,EAASC,iBAAA,IAChCI,cAAA,CAAeN,QAAA,EAAUC,OAAA,EAASC,iBAAA;MACtC;MACAT,eAAA,CAAgBS,iBAAA,EAAmBF,QAAA;MACnC;MACA,MAAMmB,aAAA,GAAgBA,CAAA,KAAMC,SAAA;MAC5B,OAAOzB,MAAA,CAAOqB,QAAA,IAAYC,QAAA,CAASD,QAAA,EAAUG,aAAA,IAAiB,IAAIE,OAAA,CAAQJ,QAAA;IAC5E;IACAK,IAAA,EAAMrB,OAAA,CAAQqB,IAAI;IAClBjB,YAAA,EAAcJ,OAAA,CAAQI,YAAY;IAClCkB,SAAA,EAAWtB,OAAA,CAAQsB;EACrB;AACF","ignoreList":[]}
@@ -1,14 +0,0 @@
1
- import type { FetchAPIFileUploadOptions } from 'payload';
2
- type Handler = (options: FetchAPIFileUploadOptions, fieldname: string, filename: string) => {
3
- cleanup: () => void;
4
- complete: () => Buffer;
5
- dataHandler: (data: Buffer) => void;
6
- getFilePath: () => string;
7
- getFileSize: () => number;
8
- getHash: () => string;
9
- getWritePromise: () => Promise<boolean>;
10
- };
11
- export declare const tempFileHandler: Handler;
12
- export declare const memHandler: Handler;
13
- export {};
14
- //# sourceMappingURL=handlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/fetchAPI-multipart/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAQxD,KAAK,OAAO,GAAG,CACb,OAAO,EAAE,yBAAyB,EAClC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,KACb;IACH,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,QAAQ,EAAE,MAAM,MAAM,CAAA;IACtB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,WAAW,EAAE,MAAM,MAAM,CAAA;IACzB,WAAW,EAAE,MAAM,MAAM,CAAA;IACzB,OAAO,EAAE,MAAM,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CACxC,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,OAwD7B,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,OAgCxB,CAAA"}
@@ -1,87 +0,0 @@
1
- import crypto from 'crypto';
2
- import fs, { WriteStream } from 'fs';
3
- import path from 'path';
4
- import { checkAndMakeDir, debugLog, deleteFile, getTempFilename } from './utilities.js';
5
- export const tempFileHandler = (options, fieldname, filename) => {
6
- const dir = path.normalize(options.tempFileDir);
7
- const tempFilePath = path.join(process.cwd(), dir, getTempFilename());
8
- checkAndMakeDir({
9
- createParentPath: true
10
- }, tempFilePath);
11
- debugLog(options, `Temporary file path is ${tempFilePath}`);
12
- const hash = crypto.createHash('md5');
13
- let fileSize = 0;
14
- let completed = false;
15
- debugLog(options, `Opening write stream for ${fieldname}->${filename}...`);
16
- const writeStream = fs.createWriteStream(tempFilePath);
17
- const writePromise = new Promise((resolve, reject) => {
18
- writeStream.on('finish', () => resolve(true));
19
- writeStream.on('error', err => {
20
- debugLog(options, `Error write temp file: ${err}`);
21
- reject(err);
22
- });
23
- });
24
- return {
25
- cleanup: () => {
26
- completed = true;
27
- debugLog(options, `Cleaning up temporary file ${tempFilePath}...`);
28
- writeStream.end();
29
- deleteFile(tempFilePath, err => err ? debugLog(options, `Cleaning up temporary file ${tempFilePath} failed: ${err}`) : debugLog(options, `Cleaning up temporary file ${tempFilePath} done.`));
30
- },
31
- complete: () => {
32
- completed = true;
33
- debugLog(options, `Upload ${fieldname}->${filename} completed, bytes:${fileSize}.`);
34
- if (writeStream instanceof WriteStream) {
35
- writeStream.end();
36
- }
37
- // Return empty buff since data was uploaded into a temp file.
38
- return Buffer.concat([]);
39
- },
40
- dataHandler: data => {
41
- if (completed === true) {
42
- debugLog(options, `Error: got ${fieldname}->${filename} data chunk for completed upload!`);
43
- return;
44
- }
45
- writeStream.write(data);
46
- hash.update(data);
47
- fileSize += data.length;
48
- debugLog(options, `Uploading ${fieldname}->${filename}, bytes:${fileSize}...`);
49
- },
50
- getFilePath: () => tempFilePath,
51
- getFileSize: () => fileSize,
52
- getHash: () => hash.digest('hex'),
53
- getWritePromise: () => writePromise
54
- };
55
- };
56
- export const memHandler = (options, fieldname, filename) => {
57
- const buffers = [];
58
- const hash = crypto.createHash('md5');
59
- let fileSize = 0;
60
- let completed = false;
61
- const getBuffer = () => Buffer.concat(buffers, fileSize);
62
- return {
63
- cleanup: () => {
64
- completed = true;
65
- },
66
- complete: () => {
67
- debugLog(options, `Upload ${fieldname}->${filename} completed, bytes:${fileSize}.`);
68
- completed = true;
69
- return getBuffer();
70
- },
71
- dataHandler: data => {
72
- if (completed === true) {
73
- debugLog(options, `Error: got ${fieldname}->${filename} data chunk for completed upload!`);
74
- return;
75
- }
76
- buffers.push(data);
77
- hash.update(data);
78
- fileSize += data.length;
79
- debugLog(options, `Uploading ${fieldname}->${filename}, bytes:${fileSize}...`);
80
- },
81
- getFilePath: () => '',
82
- getFileSize: () => fileSize,
83
- getHash: () => hash.digest('hex'),
84
- getWritePromise: () => Promise.resolve(true)
85
- };
86
- };
87
- //# sourceMappingURL=handlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlers.js","names":["crypto","fs","WriteStream","path","checkAndMakeDir","debugLog","deleteFile","getTempFilename","tempFileHandler","options","fieldname","filename","dir","normalize","tempFileDir","tempFilePath","join","process","cwd","createParentPath","hash","createHash","fileSize","completed","writeStream","createWriteStream","writePromise","Promise","resolve","reject","on","err","cleanup","end","complete","Buffer","concat","dataHandler","data","write","update","length","getFilePath","getFileSize","getHash","digest","getWritePromise","memHandler","buffers","getBuffer","push"],"sources":["../../src/fetchAPI-multipart/handlers.ts"],"sourcesContent":["import type { FetchAPIFileUploadOptions } from 'payload'\n\nimport crypto from 'crypto'\nimport fs, { WriteStream } from 'fs'\nimport path from 'path'\n\nimport { checkAndMakeDir, debugLog, deleteFile, getTempFilename } from './utilities.js'\n\ntype Handler = (\n options: FetchAPIFileUploadOptions,\n fieldname: string,\n filename: string,\n) => {\n cleanup: () => void\n complete: () => Buffer\n dataHandler: (data: Buffer) => void\n getFilePath: () => string\n getFileSize: () => number\n getHash: () => string\n getWritePromise: () => Promise<boolean>\n}\n\nexport const tempFileHandler: Handler = (options, fieldname, filename) => {\n const dir = path.normalize(options.tempFileDir)\n const tempFilePath = path.join(process.cwd(), dir, getTempFilename())\n checkAndMakeDir({ createParentPath: true }, tempFilePath)\n\n debugLog(options, `Temporary file path is ${tempFilePath}`)\n\n const hash = crypto.createHash('md5')\n let fileSize = 0\n let completed = false\n\n debugLog(options, `Opening write stream for ${fieldname}->${filename}...`)\n const writeStream = fs.createWriteStream(tempFilePath)\n const writePromise = new Promise<boolean>((resolve, reject) => {\n writeStream.on('finish', () => resolve(true))\n writeStream.on('error', (err) => {\n debugLog(options, `Error write temp file: ${err}`)\n reject(err)\n })\n })\n\n return {\n cleanup: () => {\n completed = true\n debugLog(options, `Cleaning up temporary file ${tempFilePath}...`)\n writeStream.end()\n deleteFile(tempFilePath, (err) =>\n err\n ? debugLog(options, `Cleaning up temporary file ${tempFilePath} failed: ${err}`)\n : debugLog(options, `Cleaning up temporary file ${tempFilePath} done.`),\n )\n },\n complete: () => {\n completed = true\n debugLog(options, `Upload ${fieldname}->${filename} completed, bytes:${fileSize}.`)\n if (writeStream instanceof WriteStream) {\n writeStream.end()\n }\n // Return empty buff since data was uploaded into a temp file.\n return Buffer.concat([])\n },\n dataHandler: (data) => {\n if (completed === true) {\n debugLog(options, `Error: got ${fieldname}->${filename} data chunk for completed upload!`)\n return\n }\n writeStream.write(data)\n hash.update(data)\n fileSize += data.length\n debugLog(options, `Uploading ${fieldname}->${filename}, bytes:${fileSize}...`)\n },\n getFilePath: () => tempFilePath,\n getFileSize: () => fileSize,\n getHash: () => hash.digest('hex'),\n getWritePromise: () => writePromise,\n }\n}\n\nexport const memHandler: Handler = (options, fieldname, filename) => {\n const buffers: Buffer[] = []\n const hash = crypto.createHash('md5')\n let fileSize = 0\n let completed = false\n\n const getBuffer = () => Buffer.concat(buffers, fileSize)\n\n return {\n cleanup: () => {\n completed = true\n },\n complete: () => {\n debugLog(options, `Upload ${fieldname}->${filename} completed, bytes:${fileSize}.`)\n completed = true\n return getBuffer()\n },\n dataHandler: (data) => {\n if (completed === true) {\n debugLog(options, `Error: got ${fieldname}->${filename} data chunk for completed upload!`)\n return\n }\n buffers.push(data)\n hash.update(data)\n fileSize += data.length\n debugLog(options, `Uploading ${fieldname}->${filename}, bytes:${fileSize}...`)\n },\n getFilePath: () => '',\n getFileSize: () => fileSize,\n getHash: () => hash.digest('hex'),\n getWritePromise: () => Promise.resolve(true),\n }\n}\n"],"mappings":"AAEA,OAAOA,MAAA,MAAY;AACnB,OAAOC,EAAA,IAAMC,WAAW,QAAQ;AAChC,OAAOC,IAAA,MAAU;AAEjB,SAASC,eAAe,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,eAAe,QAAQ;AAgBvE,OAAO,MAAMC,eAAA,GAA2BA,CAACC,OAAA,EAASC,SAAA,EAAWC,QAAA;EAC3D,MAAMC,GAAA,GAAMT,IAAA,CAAKU,SAAS,CAACJ,OAAA,CAAQK,WAAW;EAC9C,MAAMC,YAAA,GAAeZ,IAAA,CAAKa,IAAI,CAACC,OAAA,CAAQC,GAAG,IAAIN,GAAA,EAAKL,eAAA;EACnDH,eAAA,CAAgB;IAAEe,gBAAA,EAAkB;EAAK,GAAGJ,YAAA;EAE5CV,QAAA,CAASI,OAAA,EAAS,0BAA0BM,YAAA,EAAc;EAE1D,MAAMK,IAAA,GAAOpB,MAAA,CAAOqB,UAAU,CAAC;EAC/B,IAAIC,QAAA,GAAW;EACf,IAAIC,SAAA,GAAY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,IAAA,CAAKyB,MAAM,CAAC;IAC3BC,eAAA,EAAiBA,CAAA,KAAMnB,OAAA,CAAQC,OAAO,CAAC;EACzC;AACF","ignoreList":[]}
@@ -1,32 +0,0 @@
1
- import type { FetchAPIFileUploadOptions } from 'payload';
2
- import { APIError } from 'payload';
3
- export type FileShape = {
4
- data: Buffer;
5
- encoding: string;
6
- md5: Buffer | string;
7
- mimetype: string;
8
- mv: (filePath: string, callback: () => void) => Promise<void> | void;
9
- name: string;
10
- size: number;
11
- tempFilePath: string;
12
- truncated: boolean;
13
- };
14
- type FetchAPIFileUploadResponseFile = {
15
- data: Buffer;
16
- mimetype: string;
17
- name: string;
18
- size: number;
19
- tempFilePath?: string;
20
- };
21
- export type FetchAPIFileUploadResponse = {
22
- error?: APIError;
23
- fields: Record<string, string>;
24
- files: Record<string, FetchAPIFileUploadResponseFile>;
25
- };
26
- type FetchAPIFileUpload = (args: {
27
- options?: FetchAPIFileUploadOptions;
28
- request: Request;
29
- }) => Promise<FetchAPIFileUploadResponse>;
30
- export declare const fetchAPIFileUpload: FetchAPIFileUpload;
31
- export {};
32
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetchAPI-multipart/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAGxD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAsBlC,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,EAAE,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACpE,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,KAAK,8BAA8B,GAAG;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAA;CACtD,CAAA;AAED,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE;IAC/B,OAAO,CAAC,EAAE,yBAAyB,CAAA;IACnC,OAAO,EAAE,OAAO,CAAA;CACjB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAA;AACzC,eAAO,MAAM,kBAAkB,EAAE,kBAYhC,CAAA"}
@@ -1,43 +0,0 @@
1
- import path from 'path';
2
- import { APIError } from 'payload';
3
- import { isEligibleRequest } from './isEligibleRequest.js';
4
- import { processMultipart } from './processMultipart.js';
5
- import { debugLog } from './utilities.js';
6
- const DEFAULT_OPTIONS = {
7
- abortOnLimit: false,
8
- createParentPath: false,
9
- debug: false,
10
- defParamCharset: 'utf8',
11
- limitHandler: false,
12
- parseNested: false,
13
- preserveExtension: false,
14
- responseOnLimit: 'File size limit has been reached',
15
- safeFileNames: false,
16
- tempFileDir: path.join(process.cwd(), 'tmp'),
17
- uploadTimeout: 60000,
18
- uriDecodeFileNames: false,
19
- useTempFiles: false
20
- };
21
- export const fetchAPIFileUpload = async ({
22
- options,
23
- request
24
- }) => {
25
- const uploadOptions = {
26
- ...DEFAULT_OPTIONS,
27
- ...options
28
- };
29
- if (!isEligibleRequest(request)) {
30
- debugLog(uploadOptions, 'Request is not eligible for file upload!');
31
- return {
32
- error: new APIError('Request is not eligible for file upload', 500),
33
- fields: undefined,
34
- files: undefined
35
- };
36
- } else {
37
- return processMultipart({
38
- options: uploadOptions,
39
- request
40
- });
41
- }
42
- };
43
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["path","APIError","isEligibleRequest","processMultipart","debugLog","DEFAULT_OPTIONS","abortOnLimit","createParentPath","debug","defParamCharset","limitHandler","parseNested","preserveExtension","responseOnLimit","safeFileNames","tempFileDir","join","process","cwd","uploadTimeout","uriDecodeFileNames","useTempFiles","fetchAPIFileUpload","options","request","uploadOptions","error","fields","undefined","files"],"sources":["../../src/fetchAPI-multipart/index.ts"],"sourcesContent":["import type { FetchAPIFileUploadOptions } from 'payload'\n\nimport path from 'path'\nimport { APIError } from 'payload'\n\nimport { isEligibleRequest } from './isEligibleRequest.js'\nimport { processMultipart } from './processMultipart.js'\nimport { debugLog } from './utilities.js'\n\nconst DEFAULT_OPTIONS: FetchAPIFileUploadOptions = {\n abortOnLimit: false,\n createParentPath: false,\n debug: false,\n defParamCharset: 'utf8',\n limitHandler: false,\n parseNested: false,\n preserveExtension: false,\n responseOnLimit: 'File size limit has been reached',\n safeFileNames: false,\n tempFileDir: path.join(process.cwd(), 'tmp'),\n uploadTimeout: 60000,\n uriDecodeFileNames: false,\n useTempFiles: false,\n}\n\nexport type FileShape = {\n data: Buffer\n encoding: string\n md5: Buffer | string\n mimetype: string\n mv: (filePath: string, callback: () => void) => Promise<void> | void\n name: string\n size: number\n tempFilePath: string\n truncated: boolean\n}\n\ntype FetchAPIFileUploadResponseFile = {\n data: Buffer\n mimetype: string\n name: string\n size: number\n tempFilePath?: string\n}\n\nexport type FetchAPIFileUploadResponse = {\n error?: APIError\n fields: Record<string, string>\n files: Record<string, FetchAPIFileUploadResponseFile>\n}\n\ntype FetchAPIFileUpload = (args: {\n options?: FetchAPIFileUploadOptions\n request: Request\n}) => Promise<FetchAPIFileUploadResponse>\nexport const fetchAPIFileUpload: FetchAPIFileUpload = async ({ options, request }) => {\n const uploadOptions: FetchAPIFileUploadOptions = { ...DEFAULT_OPTIONS, ...options }\n if (!isEligibleRequest(request)) {\n debugLog(uploadOptions, 'Request is not eligible for file upload!')\n return {\n error: new APIError('Request is not eligible for file upload', 500),\n fields: undefined,\n files: undefined,\n }\n } else {\n return processMultipart({ options: uploadOptions, request })\n }\n}\n"],"mappings":"AAEA,OAAOA,IAAA,MAAU;AACjB,SAASC,QAAQ,QAAQ;AAEzB,SAASC,iBAAiB,QAAQ;AAClC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,QAAQ,QAAQ;AAEzB,MAAMC,eAAA,GAA6C;EACjDC,YAAA,EAAc;EACdC,gBAAA,EAAkB;EAClBC,KAAA,EAAO;EACPC,eAAA,EAAiB;EACjBC,YAAA,EAAc;EACdC,WAAA,EAAa;EACbC,iBAAA,EAAmB;EACnBC,eAAA,EAAiB;EACjBC,aAAA,EAAe;EACfC,WAAA,EAAaf,IAAA,CAAKgB,IAAI,CAACC,OAAA,CAAQC,GAAG,IAAI;EACtCC,aAAA,EAAe;EACfC,kBAAA,EAAoB;EACpBC,YAAA,EAAc;AAChB;AAgCA,OAAO,MAAMC,kBAAA,GAAyC,MAAAA,CAAO;EAAEC,OAAO;EAAEC;AAAO,CAAE;EAC/E,MAAMC,aAAA,GAA2C;IAAE,GAAGpB,eAAe;IAAE,GAAGkB;EAAQ;EAClF,IAAI,CAACrB,iBAAA,CAAkBsB,OAAA,GAAU;IAC/BpB,QAAA,CAASqB,aAAA,EAAe;IACxB,OAAO;MACLC,KAAA,EAAO,IAAIzB,QAAA,CAAS,2CAA2C;MAC/D0B,MAAA,EAAQC,SAAA;MACRC,KAAA,EAAOD;IACT;EACF,OAAO;IACL,OAAOzB,gBAAA,CAAiB;MAAEoB,OAAA,EAASE,aAAA;MAAeD;IAAQ;EAC5D;AACF","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export declare const isEligibleRequest: (req: Request) => boolean;
2
- //# sourceMappingURL=isEligibleRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isEligibleRequest.d.ts","sourceRoot":"","sources":["../../src/fetchAPI-multipart/isEligibleRequest.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,iBAAiB,QAAS,OAAO,KAAG,OAMhD,CAAA"}
@@ -1,18 +0,0 @@
1
- const ACCEPTABLE_CONTENT_TYPE = /multipart\/['"()+-_]+(?:; ?['"()+-_]*)+$/i;
2
- const UNACCEPTABLE_METHODS = new Set(['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'TRACE']);
3
- const hasBody = req => {
4
- return Boolean(req.headers.get('transfer-encoding') || req.headers.get('content-length') && req.headers.get('content-length') !== '0');
5
- };
6
- const hasAcceptableMethod = req => !UNACCEPTABLE_METHODS.has(req.method);
7
- const hasAcceptableContentType = req => {
8
- const contType = req.headers.get('content-type');
9
- return contType.includes('boundary=') && ACCEPTABLE_CONTENT_TYPE.test(contType);
10
- };
11
- export const isEligibleRequest = req => {
12
- try {
13
- return hasBody(req) && hasAcceptableMethod(req) && hasAcceptableContentType(req);
14
- } catch (e) {
15
- return false;
16
- }
17
- };
18
- //# sourceMappingURL=isEligibleRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isEligibleRequest.js","names":["ACCEPTABLE_CONTENT_TYPE","UNACCEPTABLE_METHODS","Set","hasBody","req","Boolean","headers","get","hasAcceptableMethod","has","method","hasAcceptableContentType","contType","includes","test","isEligibleRequest","e"],"sources":["../../src/fetchAPI-multipart/isEligibleRequest.ts"],"sourcesContent":["const ACCEPTABLE_CONTENT_TYPE = /multipart\\/['\"()+-_]+(?:; ?['\"()+-_]*)+$/i\nconst UNACCEPTABLE_METHODS = new Set(['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'TRACE'])\n\nconst hasBody = (req: Request): boolean => {\n return Boolean(\n req.headers.get('transfer-encoding') ||\n (req.headers.get('content-length') && req.headers.get('content-length') !== '0'),\n )\n}\n\nconst hasAcceptableMethod = (req: Request): boolean => !UNACCEPTABLE_METHODS.has(req.method)\n\nconst hasAcceptableContentType = (req: Request): boolean => {\n const contType = req.headers.get('content-type')\n return contType.includes('boundary=') && ACCEPTABLE_CONTENT_TYPE.test(contType)\n}\n\nexport const isEligibleRequest = (req: Request): boolean => {\n try {\n return hasBody(req) && hasAcceptableMethod(req) && hasAcceptableContentType(req)\n } catch (e) {\n return false\n }\n}\n"],"mappings":"AAAA,MAAMA,uBAAA,GAA0B;AAChC,MAAMC,oBAAA,GAAuB,IAAIC,GAAA,CAAI,CAAC,WAAW,UAAU,OAAO,QAAQ,WAAW,QAAQ;AAE7F,MAAMC,OAAA,GAAWC,GAAA;EACf,OAAOC,OAAA,CACLD,GAAA,CAAIE,OAAO,CAACC,GAAG,CAAC,wBACbH,GAAA,CAAIE,OAAO,CAACC,GAAG,CAAC,qBAAqBH,GAAA,CAAIE,OAAO,CAACC,GAAG,CAAC,sBAAsB;AAElF;AAEA,MAAMC,mBAAA,GAAuBJ,GAAA,IAA0B,CAACH,oBAAA,CAAqBQ,GAAG,CAACL,GAAA,CAAIM,MAAM;AAE3F,MAAMC,wBAAA,GAA4BP,GAAA;EAChC,MAAMQ,QAAA,GAAWR,GAAA,CAAIE,OAAO,CAACC,GAAG,CAAC;EACjC,OAAOK,QAAA,CAASC,QAAQ,CAAC,gBAAgBb,uBAAA,CAAwBc,IAAI,CAACF,QAAA;AACxE;AAEA,OAAO,MAAMG,iBAAA,GAAqBX,GAAA;EAChC,IAAI;IACF,OAAOD,OAAA,CAAQC,GAAA,KAAQI,mBAAA,CAAoBJ,GAAA,KAAQO,wBAAA,CAAyBP,GAAA;EAC9E,EAAE,OAAOY,CAAA,EAAG;IACV,OAAO;EACT;AACF","ignoreList":[]}
@@ -1,9 +0,0 @@
1
- import type { FetchAPIFileUploadOptions } from 'payload';
2
- import type { FetchAPIFileUploadResponse } from './index.js';
3
- type ProcessMultipart = (args: {
4
- options: FetchAPIFileUploadOptions;
5
- request: Request;
6
- }) => Promise<FetchAPIFileUploadResponse>;
7
- export declare const processMultipart: ProcessMultipart;
8
- export {};
9
- //# sourceMappingURL=processMultipart.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"processMultipart.d.ts","sourceRoot":"","sources":["../../src/fetchAPI-multipart/processMultipart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAOxD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAU5D,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE;IAC7B,OAAO,EAAE,yBAAyB,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;CACjB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAA;AACzC,eAAO,MAAM,gBAAgB,EAAE,gBAmM9B,CAAA"}