@payloadcms/next 3.0.0-beta.90 → 3.0.0-beta.92
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.
- package/dist/cjs/withPayload.js +111 -0
- package/dist/cjs/withPayload.js.map +1 -0
- package/dist/config.js +0 -1
- package/dist/config.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/ShouldRenderTabs.js +15 -9
- package/dist/elements/DocumentHeader/Tabs/ShouldRenderTabs.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js +100 -35
- package/dist/elements/DocumentHeader/Tabs/Tab/TabLink.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js +74 -63
- package/dist/elements/DocumentHeader/Tabs/Tab/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/getCustomViews.js +31 -35
- package/dist/elements/DocumentHeader/Tabs/getCustomViews.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/getViewConfig.js +15 -12
- package/dist/elements/DocumentHeader/Tabs/getViewConfig.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/index.js +86 -79
- package/dist/elements/DocumentHeader/Tabs/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js +32 -13
- package/dist/elements/DocumentHeader/Tabs/tabs/VersionsPill/index.js.map +1 -1
- package/dist/elements/DocumentHeader/Tabs/tabs/index.js +60 -52
- package/dist/elements/DocumentHeader/Tabs/tabs/index.js.map +1 -1
- package/dist/elements/DocumentHeader/index.js +24 -23
- package/dist/elements/DocumentHeader/index.js.map +1 -1
- package/dist/elements/EmailAndUsername/index.js +107 -75
- package/dist/elements/EmailAndUsername/index.js.map +1 -1
- package/dist/elements/LeaveWithoutSaving/index.js +150 -83
- package/dist/elements/LeaveWithoutSaving/index.js.map +1 -1
- package/dist/elements/LeaveWithoutSaving/usePreventLeave.d.ts.map +1 -1
- package/dist/elements/LeaveWithoutSaving/usePreventLeave.js +119 -101
- package/dist/elements/LeaveWithoutSaving/usePreventLeave.js.map +1 -1
- package/dist/elements/Logo/index.js +36 -21
- package/dist/elements/Logo/index.js.map +1 -1
- package/dist/elements/Nav/NavHamburger/index.js +41 -13
- package/dist/elements/Nav/NavHamburger/index.js.map +1 -1
- package/dist/elements/Nav/NavWrapper/index.js +48 -16
- package/dist/elements/Nav/NavWrapper/index.js.map +1 -1
- package/dist/elements/Nav/index.client.js +149 -76
- package/dist/elements/Nav/index.client.js.map +1 -1
- package/dist/elements/Nav/index.js +56 -50
- package/dist/elements/Nav/index.js.map +1 -1
- package/dist/exports/layouts.js +0 -1
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/routes.js +0 -1
- package/dist/exports/routes.js.map +1 -1
- package/dist/exports/templates.js +0 -1
- package/dist/exports/templates.js.map +1 -1
- package/dist/exports/utilities.js +0 -1
- package/dist/exports/utilities.js.map +1 -1
- package/dist/exports/views.js +0 -1
- package/dist/exports/views.js.map +1 -1
- package/dist/fetchAPI-multipart/fileFactory.js +35 -34
- package/dist/fetchAPI-multipart/fileFactory.js.map +1 -1
- package/dist/fetchAPI-multipart/handlers.js +77 -78
- package/dist/fetchAPI-multipart/handlers.js.map +1 -1
- package/dist/fetchAPI-multipart/index.js +33 -31
- package/dist/fetchAPI-multipart/index.js.map +1 -1
- package/dist/fetchAPI-multipart/isEligibleRequest.js +13 -21
- package/dist/fetchAPI-multipart/isEligibleRequest.js.map +1 -1
- package/dist/fetchAPI-multipart/processMultipart.js +158 -141
- package/dist/fetchAPI-multipart/processMultipart.js.map +1 -1
- package/dist/fetchAPI-multipart/processNested.js +23 -21
- package/dist/fetchAPI-multipart/processNested.js.map +1 -1
- package/dist/fetchAPI-multipart/uploadTimer.js +16 -17
- package/dist/fetchAPI-multipart/uploadTimer.js.map +1 -1
- package/dist/fetchAPI-multipart/utilities.js +166 -166
- package/dist/fetchAPI-multipart/utilities.js.map +1 -1
- package/dist/fetchAPI-stream-file/index.js +19 -17
- package/dist/fetchAPI-stream-file/index.js.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/layouts/Root/index.js +118 -115
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/prod/styles.css +1 -1
- package/dist/routes/graphql/handler.js +109 -103
- package/dist/routes/graphql/handler.js.map +1 -1
- package/dist/routes/graphql/index.js +0 -1
- package/dist/routes/graphql/index.js.map +1 -1
- package/dist/routes/graphql/playground.js +23 -24
- package/dist/routes/graphql/playground.js.map +1 -1
- package/dist/routes/index.js +0 -1
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/rest/auth/access.js +22 -21
- package/dist/routes/rest/auth/access.js.map +1 -1
- package/dist/routes/rest/auth/forgotPassword.js +29 -25
- package/dist/routes/rest/auth/forgotPassword.js.map +1 -1
- package/dist/routes/rest/auth/init.js +16 -14
- package/dist/routes/rest/auth/init.js.map +1 -1
- package/dist/routes/rest/auth/login.js +43 -38
- package/dist/routes/rest/auth/login.js.map +1 -1
- package/dist/routes/rest/auth/logout.js +31 -27
- package/dist/routes/rest/auth/logout.js.map +1 -1
- package/dist/routes/rest/auth/me.js +23 -21
- package/dist/routes/rest/auth/me.js.map +1 -1
- package/dist/routes/rest/auth/refresh.js +31 -27
- package/dist/routes/rest/auth/refresh.js.map +1 -1
- package/dist/routes/rest/auth/registerFirstUser.js +43 -38
- package/dist/routes/rest/auth/registerFirstUser.js.map +1 -1
- package/dist/routes/rest/auth/resetPassword.js +38 -33
- package/dist/routes/rest/auth/resetPassword.js.map +1 -1
- package/dist/routes/rest/auth/unlock.js +27 -23
- package/dist/routes/rest/auth/unlock.js.map +1 -1
- package/dist/routes/rest/auth/verifyEmail.js +22 -17
- package/dist/routes/rest/auth/verifyEmail.js.map +1 -1
- package/dist/routes/rest/buildFormState.js +38 -37
- package/dist/routes/rest/buildFormState.js.map +1 -1
- package/dist/routes/rest/checkEndpoints.js +11 -9
- package/dist/routes/rest/checkEndpoints.js.map +1 -1
- package/dist/routes/rest/collections/count.js +15 -11
- package/dist/routes/rest/collections/count.js.map +1 -1
- package/dist/routes/rest/collections/create.js +30 -26
- package/dist/routes/rest/collections/create.js.map +1 -1
- package/dist/routes/rest/collections/delete.js +40 -35
- package/dist/routes/rest/collections/delete.js.map +1 -1
- package/dist/routes/rest/collections/deleteByID.js +36 -31
- package/dist/routes/rest/collections/deleteByID.js.map +1 -1
- package/dist/routes/rest/collections/docAccess.js +17 -14
- package/dist/routes/rest/collections/docAccess.js.map +1 -1
- package/dist/routes/rest/collections/duplicate.js +36 -31
- package/dist/routes/rest/collections/duplicate.js.map +1 -1
- package/dist/routes/rest/collections/find.js +29 -20
- package/dist/routes/rest/collections/find.js.map +1 -1
- package/dist/routes/rest/collections/findByID.js +28 -23
- package/dist/routes/rest/collections/findByID.js.map +1 -1
- package/dist/routes/rest/collections/findVersionByID.js +27 -22
- package/dist/routes/rest/collections/findVersionByID.js.map +1 -1
- package/dist/routes/rest/collections/findVersions.js +27 -19
- package/dist/routes/rest/collections/findVersions.js.map +1 -1
- package/dist/routes/rest/collections/preview.js +39 -34
- package/dist/routes/rest/collections/preview.js.map +1 -1
- package/dist/routes/rest/collections/restoreVersion.js +32 -27
- package/dist/routes/rest/collections/restoreVersion.js.map +1 -1
- package/dist/routes/rest/collections/update.js +43 -37
- package/dist/routes/rest/collections/update.js.map +1 -1
- package/dist/routes/rest/collections/updateByID.js +38 -33
- package/dist/routes/rest/collections/updateByID.js.map +1 -1
- package/dist/routes/rest/files/checkFileAccess.js +46 -44
- package/dist/routes/rest/files/checkFileAccess.js.map +1 -1
- package/dist/routes/rest/files/getFile.js +52 -49
- package/dist/routes/rest/files/getFile.js.map +1 -1
- package/dist/routes/rest/files/getFileTypeFallback.js +16 -17
- package/dist/routes/rest/files/getFileTypeFallback.js.map +1 -1
- package/dist/routes/rest/globals/docAccess.js +15 -13
- package/dist/routes/rest/globals/docAccess.js.map +1 -1
- package/dist/routes/rest/globals/findOne.js +22 -18
- package/dist/routes/rest/globals/findOne.js.map +1 -1
- package/dist/routes/rest/globals/findVersionByID.js +22 -17
- package/dist/routes/rest/globals/findVersionByID.js.map +1 -1
- package/dist/routes/rest/globals/findVersions.js +27 -19
- package/dist/routes/rest/globals/findVersions.js.map +1 -1
- package/dist/routes/rest/globals/preview.js +38 -34
- package/dist/routes/rest/globals/preview.js.map +1 -1
- package/dist/routes/rest/globals/restoreVersion.js +27 -22
- package/dist/routes/rest/globals/restoreVersion.js.map +1 -1
- package/dist/routes/rest/globals/update.js +32 -28
- package/dist/routes/rest/globals/update.js.map +1 -1
- package/dist/routes/rest/index.js +651 -626
- package/dist/routes/rest/index.js.map +1 -1
- package/dist/routes/rest/og/image.js +74 -76
- package/dist/routes/rest/og/image.js.map +1 -1
- package/dist/routes/rest/og/index.js +60 -59
- package/dist/routes/rest/og/index.js.map +1 -1
- package/dist/routes/rest/routeError.js +102 -95
- package/dist/routes/rest/routeError.js.map +1 -1
- package/dist/routes/rest/types.js +1 -2
- package/dist/routes/rest/types.js.map +1 -1
- package/dist/routes/rest/utilities/sanitizeCollectionID.js +14 -11
- package/dist/routes/rest/utilities/sanitizeCollectionID.js.map +1 -1
- package/dist/scss/app.scss +4 -4
- package/dist/scss/type.scss +4 -4
- package/dist/templates/Default/NavHamburger/index.js +18 -6
- package/dist/templates/Default/NavHamburger/index.js.map +1 -1
- package/dist/templates/Default/Wrapper/index.js +42 -13
- package/dist/templates/Default/Wrapper/index.js.map +1 -1
- package/dist/templates/Default/index.js +54 -47
- package/dist/templates/Default/index.js.map +1 -1
- package/dist/templates/Minimal/index.js +16 -16
- package/dist/templates/Minimal/index.js.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +40 -35
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/dist/utilities/addLocalesToRequest.js +44 -36
- package/dist/utilities/addLocalesToRequest.js.map +1 -1
- package/dist/utilities/createPayloadRequest.js +85 -74
- package/dist/utilities/createPayloadRequest.js.map +1 -1
- package/dist/utilities/getNextRequestI18n.js +13 -11
- package/dist/utilities/getNextRequestI18n.js.map +1 -1
- package/dist/utilities/getPayloadHMR.d.ts +1 -1
- package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
- package/dist/utilities/getPayloadHMR.js +91 -94
- package/dist/utilities/getPayloadHMR.js.map +1 -1
- package/dist/utilities/getRequestLanguage.js +16 -13
- package/dist/utilities/getRequestLanguage.js.map +1 -1
- package/dist/utilities/getRequestLocales.js +27 -24
- package/dist/utilities/getRequestLocales.js.map +1 -1
- package/dist/utilities/getRequestTheme.js +16 -16
- package/dist/utilities/getRequestTheme.js.map +1 -1
- package/dist/utilities/headersWithCors.js +21 -30
- package/dist/utilities/headersWithCors.js.map +1 -1
- package/dist/utilities/initPage/handleAdminPage.js +46 -42
- package/dist/utilities/initPage/handleAdminPage.js.map +1 -1
- package/dist/utilities/initPage/handleAuthRedirect.js +45 -32
- package/dist/utilities/initPage/handleAuthRedirect.js.map +1 -1
- package/dist/utilities/initPage/index.js +146 -120
- package/dist/utilities/initPage/index.js.map +1 -1
- package/dist/utilities/initPage/shared.js +26 -25
- package/dist/utilities/initPage/shared.js.map +1 -1
- package/dist/utilities/initPage/types.js +1 -2
- package/dist/utilities/initPage/types.js.map +1 -1
- package/dist/utilities/mergeHeaders.js +8 -9
- package/dist/utilities/mergeHeaders.js.map +1 -1
- package/dist/utilities/meta.js +66 -68
- package/dist/utilities/meta.js.map +1 -1
- package/dist/utilities/timestamp.js +4 -5
- package/dist/utilities/timestamp.js.map +1 -1
- package/dist/views/API/LocaleSelector/index.d.ts.map +1 -1
- package/dist/views/API/LocaleSelector/index.js +38 -11
- package/dist/views/API/LocaleSelector/index.js.map +1 -1
- package/dist/views/API/RenderJSON/index.js +124 -112
- package/dist/views/API/RenderJSON/index.js.map +1 -1
- package/dist/views/API/index.client.js +190 -202
- package/dist/views/API/index.client.js.map +1 -1
- package/dist/views/API/index.js +2 -3
- package/dist/views/API/index.js.map +1 -1
- package/dist/views/API/meta.js +22 -18
- package/dist/views/API/meta.js.map +1 -1
- package/dist/views/Account/Settings/LanguageSelector.js +45 -12
- package/dist/views/Account/Settings/LanguageSelector.js.map +1 -1
- package/dist/views/Account/Settings/index.js +21 -28
- package/dist/views/Account/Settings/index.js.map +1 -1
- package/dist/views/Account/ToggleTheme/index.js +51 -30
- package/dist/views/Account/ToggleTheme/index.js.map +1 -1
- package/dist/views/Account/index.client.js +32 -16
- package/dist/views/Account/index.client.js.map +1 -1
- package/dist/views/Account/index.js +99 -68
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/Account/meta.js +12 -8
- package/dist/views/Account/meta.js.map +1 -1
- package/dist/views/CreateFirstUser/index.client.js +95 -57
- package/dist/views/CreateFirstUser/index.client.js.map +1 -1
- package/dist/views/CreateFirstUser/index.js +42 -28
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/CreateFirstUser/meta.js +12 -8
- package/dist/views/CreateFirstUser/meta.js.map +1 -1
- package/dist/views/Dashboard/Default/index.js +132 -115
- package/dist/views/Dashboard/Default/index.js.map +1 -1
- package/dist/views/Dashboard/index.js +61 -52
- package/dist/views/Dashboard/index.js.map +1 -1
- package/dist/views/Dashboard/meta.js +16 -12
- package/dist/views/Dashboard/meta.js.map +1 -1
- package/dist/views/Document/getCustomViewByKey.js +2 -3
- package/dist/views/Document/getCustomViewByKey.js.map +1 -1
- package/dist/views/Document/getCustomViewByRoute.js +30 -27
- package/dist/views/Document/getCustomViewByRoute.js.map +1 -1
- package/dist/views/Document/getDocumentData.js +34 -28
- package/dist/views/Document/getDocumentData.js.map +1 -1
- package/dist/views/Document/getDocumentPermissions.js +83 -74
- package/dist/views/Document/getDocumentPermissions.js.map +1 -1
- package/dist/views/Document/getMetaBySegment.js +113 -107
- package/dist/views/Document/getMetaBySegment.js.map +1 -1
- package/dist/views/Document/getViewsFromConfig.js +309 -331
- package/dist/views/Document/getViewsFromConfig.js.map +1 -1
- package/dist/views/Document/index.d.ts.map +1 -1
- package/dist/views/Document/index.js +193 -159
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Document/meta.js +1 -2
- package/dist/views/Document/meta.js.map +1 -1
- package/dist/views/Edit/Default/Auth/APIKey.js +118 -132
- package/dist/views/Edit/Default/Auth/APIKey.js.map +1 -1
- package/dist/views/Edit/Default/Auth/index.js +293 -196
- package/dist/views/Edit/Default/Auth/index.js.map +1 -1
- package/dist/views/Edit/Default/Auth/types.js +1 -2
- package/dist/views/Edit/Default/Auth/types.js.map +1 -1
- package/dist/views/Edit/Default/SetDocumentStepNav/index.js +121 -70
- package/dist/views/Edit/Default/SetDocumentStepNav/index.js.map +1 -1
- package/dist/views/Edit/Default/SetDocumentTitle/index.js +74 -29
- package/dist/views/Edit/Default/SetDocumentTitle/index.js.map +1 -1
- package/dist/views/Edit/Default/index.js +190 -187
- package/dist/views/Edit/Default/index.js.map +1 -1
- package/dist/views/Edit/Default/types.js +1 -2
- package/dist/views/Edit/Default/types.js.map +1 -1
- package/dist/views/Edit/index.client.js +45 -21
- package/dist/views/Edit/index.client.js.map +1 -1
- package/dist/views/Edit/index.js +2 -3
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/views/Edit/meta.js +43 -35
- package/dist/views/Edit/meta.js.map +1 -1
- package/dist/views/Edit/sanitizeEditViewProps.js +8 -9
- package/dist/views/Edit/sanitizeEditViewProps.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +151 -94
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
- package/dist/views/ForgotPassword/index.js +59 -46
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/ForgotPassword/meta.js +12 -8
- package/dist/views/ForgotPassword/meta.js.map +1 -1
- package/dist/views/List/Default/index.js +348 -208
- package/dist/views/List/Default/index.js.map +1 -1
- package/dist/views/List/Default/types.js +1 -2
- package/dist/views/List/Default/types.js.map +1 -1
- package/dist/views/List/index.js +153 -137
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/List/meta.js +20 -17
- package/dist/views/List/meta.js.map +1 -1
- package/dist/views/LivePreview/Context/collisionDetection.js +24 -21
- package/dist/views/LivePreview/Context/collisionDetection.js.map +1 -1
- package/dist/views/LivePreview/Context/context.d.ts +2 -1
- package/dist/views/LivePreview/Context/context.d.ts.map +1 -1
- package/dist/views/LivePreview/Context/context.js +39 -36
- package/dist/views/LivePreview/Context/context.js.map +1 -1
- package/dist/views/LivePreview/Context/index.js +134 -142
- package/dist/views/LivePreview/Context/index.js.map +1 -1
- package/dist/views/LivePreview/Context/sizeReducer.js +18 -19
- package/dist/views/LivePreview/Context/sizeReducer.js.map +1 -1
- package/dist/views/LivePreview/Device/index.d.ts.map +1 -1
- package/dist/views/LivePreview/Device/index.js +78 -71
- package/dist/views/LivePreview/Device/index.js.map +1 -1
- package/dist/views/LivePreview/DeviceContainer/index.js +47 -23
- package/dist/views/LivePreview/DeviceContainer/index.js.map +1 -1
- package/dist/views/LivePreview/IFrame/index.js +21 -16
- package/dist/views/LivePreview/IFrame/index.js.map +1 -1
- package/dist/views/LivePreview/Preview/index.js +145 -92
- package/dist/views/LivePreview/Preview/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/Controls/index.js +136 -115
- package/dist/views/LivePreview/Toolbar/Controls/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/SizeInput/index.js +89 -51
- package/dist/views/LivePreview/Toolbar/SizeInput/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/index.js +82 -50
- package/dist/views/LivePreview/Toolbar/index.js.map +1 -1
- package/dist/views/LivePreview/ToolbarArea/index.js +32 -10
- package/dist/views/LivePreview/ToolbarArea/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.js +316 -160
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/LivePreview/index.js +67 -55
- package/dist/views/LivePreview/index.js.map +1 -1
- package/dist/views/LivePreview/meta.js +14 -9
- package/dist/views/LivePreview/meta.js.map +1 -1
- package/dist/views/LivePreview/usePopupWindow.js +91 -94
- package/dist/views/LivePreview/usePopupWindow.js.map +1 -1
- package/dist/views/Login/LoginField/index.js +83 -39
- package/dist/views/Login/LoginField/index.js.map +1 -1
- package/dist/views/Login/LoginForm/index.js +130 -66
- package/dist/views/Login/LoginForm/index.js.map +1 -1
- package/dist/views/Login/index.js +77 -54
- package/dist/views/Login/index.js.map +1 -1
- package/dist/views/Login/meta.js +12 -8
- package/dist/views/Login/meta.js.map +1 -1
- package/dist/views/Logout/LogoutClient.js +84 -39
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/Logout/index.js +29 -16
- package/dist/views/Logout/index.js.map +1 -1
- package/dist/views/Logout/meta.js +11 -7
- package/dist/views/Logout/meta.js.map +1 -1
- package/dist/views/NotFound/index.client.js +78 -40
- package/dist/views/NotFound/index.client.js.map +1 -1
- package/dist/views/NotFound/index.js +47 -37
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/NotFound/meta.js +9 -7
- package/dist/views/NotFound/meta.js.map +1 -1
- package/dist/views/ResetPassword/index.client.js +97 -59
- package/dist/views/ResetPassword/index.client.js.map +1 -1
- package/dist/views/ResetPassword/index.js +68 -53
- package/dist/views/ResetPassword/index.js.map +1 -1
- package/dist/views/ResetPassword/meta.js +12 -8
- package/dist/views/ResetPassword/meta.js.map +1 -1
- package/dist/views/Root/generateCustomViewMetadata.js +21 -19
- package/dist/views/Root/generateCustomViewMetadata.js.map +1 -1
- package/dist/views/Root/getCustomViewByRoute.js +42 -31
- package/dist/views/Root/getCustomViewByRoute.js.map +1 -1
- package/dist/views/Root/getViewFromConfig.js +162 -156
- package/dist/views/Root/getViewFromConfig.js.map +1 -1
- package/dist/views/Root/index.js +99 -82
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Root/isPathMatchingRoute.js +18 -13
- package/dist/views/Root/isPathMatchingRoute.js.map +1 -1
- package/dist/views/Root/meta.js +141 -136
- package/dist/views/Root/meta.js.map +1 -1
- package/dist/views/Unauthorized/index.js +32 -22
- package/dist/views/Unauthorized/index.js.map +1 -1
- package/dist/views/Unauthorized/meta.js +12 -8
- package/dist/views/Unauthorized/meta.js.map +1 -1
- package/dist/views/Verify/index.js +58 -43
- package/dist/views/Verify/index.js.map +1 -1
- package/dist/views/Verify/meta.js +12 -8
- package/dist/views/Verify/meta.js.map +1 -1
- package/dist/views/Version/Default/SetStepNav.d.ts.map +1 -1
- package/dist/views/Version/Default/SetStepNav.js +147 -103
- package/dist/views/Version/Default/SetStepNav.js.map +1 -1
- package/dist/views/Version/Default/index.js +198 -114
- package/dist/views/Version/Default/index.js.map +1 -1
- package/dist/views/Version/Default/types.js +1 -2
- package/dist/views/Version/Default/types.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/Label/index.js +6 -5
- package/dist/views/Version/RenderFieldsToDiff/Label/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +65 -69
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js +34 -31
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +108 -78
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js +17 -11
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +40 -38
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +42 -32
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js +17 -11
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +34 -31
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/diffMethods.js +4 -5
- package/dist/views/Version/RenderFieldsToDiff/fields/diffMethods.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/index.js +20 -21
- package/dist/views/Version/RenderFieldsToDiff/fields/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/styles.js +23 -24
- package/dist/views/Version/RenderFieldsToDiff/fields/styles.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/types.js +1 -2
- package/dist/views/Version/RenderFieldsToDiff/fields/types.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/index.js +102 -97
- package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/types.js +1 -2
- package/dist/views/Version/RenderFieldsToDiff/types.js.map +1 -1
- package/dist/views/Version/Restore/index.js +107 -110
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Version/Restore/types.js +1 -2
- package/dist/views/Version/Restore/types.js.map +1 -1
- package/dist/views/Version/SelectComparison/index.js +130 -138
- package/dist/views/Version/SelectComparison/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/types.js +1 -2
- package/dist/views/Version/SelectComparison/types.js.map +1 -1
- package/dist/views/Version/SelectLocales/index.js +58 -30
- package/dist/views/Version/SelectLocales/index.js.map +1 -1
- package/dist/views/Version/SelectLocales/types.js +1 -2
- package/dist/views/Version/SelectLocales/types.js.map +1 -1
- package/dist/views/Version/index.js +126 -105
- package/dist/views/Version/index.js.map +1 -1
- package/dist/views/Version/meta.js +49 -43
- package/dist/views/Version/meta.js.map +1 -1
- package/dist/views/Versions/buildColumns.js +87 -82
- package/dist/views/Versions/buildColumns.js.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.js +69 -42
- package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
- package/dist/views/Versions/cells/CreatedAt/index.js +70 -17
- package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
- package/dist/views/Versions/cells/ID/index.js +17 -5
- package/dist/views/Versions/cells/ID/index.js.map +1 -1
- package/dist/views/Versions/getLatestVersion.js +33 -29
- package/dist/views/Versions/getLatestVersion.js.map +1 -1
- package/dist/views/Versions/index.client.js +80 -77
- package/dist/views/Versions/index.client.js.map +1 -1
- package/dist/views/Versions/index.js +148 -127
- package/dist/views/Versions/index.js.map +1 -1
- package/dist/views/Versions/meta.js +43 -37
- package/dist/views/Versions/meta.js.map +1 -1
- package/dist/views/Versions/types.js +1 -2
- package/dist/views/Versions/types.js.map +1 -1
- package/dist/withPayload.js +83 -117
- package/dist/withPayload.js.map +1 -1
- package/package.json +20 -10
- package/dist/cjs/withPayload.cjs +0 -145
- package/dist/cjs/withPayload.cjs.map +0 -1
|
@@ -3,46 +3,52 @@ import httpStatus from 'http-status';
|
|
|
3
3
|
import { updateOperation } from 'payload';
|
|
4
4
|
import { isNumber } from 'payload/shared';
|
|
5
5
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
6
|
-
export const update = async ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
const total = result.docs.length + result.errors.length;
|
|
34
|
-
const message = req.t('error:unableToUpdateCount', {
|
|
35
|
-
count: result.errors.length,
|
|
36
|
-
label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),
|
|
37
|
-
total
|
|
6
|
+
export const update = async ({
|
|
7
|
+
collection,
|
|
8
|
+
req
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
depth,
|
|
12
|
+
draft,
|
|
13
|
+
where
|
|
14
|
+
} = req.query;
|
|
15
|
+
const result = await updateOperation({
|
|
16
|
+
collection,
|
|
17
|
+
data: req.data,
|
|
18
|
+
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
19
|
+
draft: draft === 'true',
|
|
20
|
+
req,
|
|
21
|
+
where
|
|
22
|
+
});
|
|
23
|
+
const headers = headersWithCors({
|
|
24
|
+
headers: new Headers(),
|
|
25
|
+
req
|
|
26
|
+
});
|
|
27
|
+
if (result.errors.length === 0) {
|
|
28
|
+
const message = req.t('general:updatedCountSuccessfully', {
|
|
29
|
+
count: result.docs.length,
|
|
30
|
+
label: getTranslation(collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'], req.i18n)
|
|
38
31
|
});
|
|
39
32
|
return Response.json({
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
...result,
|
|
34
|
+
message
|
|
42
35
|
}, {
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
headers,
|
|
37
|
+
status: httpStatus.OK
|
|
45
38
|
});
|
|
39
|
+
}
|
|
40
|
+
const total = result.docs.length + result.errors.length;
|
|
41
|
+
const message = req.t('error:unableToUpdateCount', {
|
|
42
|
+
count: result.errors.length,
|
|
43
|
+
label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),
|
|
44
|
+
total
|
|
45
|
+
});
|
|
46
|
+
return Response.json({
|
|
47
|
+
...result,
|
|
48
|
+
message
|
|
49
|
+
}, {
|
|
50
|
+
headers,
|
|
51
|
+
status: httpStatus.BAD_REQUEST
|
|
52
|
+
});
|
|
46
53
|
};
|
|
47
|
-
|
|
48
54
|
//# sourceMappingURL=update.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/collections/update.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { updateOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const update: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, where } = req.query as {\n depth?: string\n draft?: string\n where?: Where\n }\n\n const result = await updateOperation({\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n req,\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:updatedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n const message = req.t('error:unableToUpdateCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"
|
|
1
|
+
{"version":3,"file":"update.js","names":["getTranslation","httpStatus","updateOperation","isNumber","headersWithCors","update","collection","req","depth","draft","where","query","result","data","Number","undefined","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"sources":["../../../../src/routes/rest/collections/update.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { updateOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const update: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, where } = req.query as {\n depth?: string\n draft?: string\n where?: Where\n }\n\n const result = await updateOperation({\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n req,\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:updatedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n const message = req.t('error:unableToUpdateCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,eAAe,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,MAAA,GAAiC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACtE,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAK,CAAE,GAAGH,GAAA,CAAII,KAAK;EAMzC,MAAMC,MAAA,GAAS,MAAMV,eAAA,CAAgB;IACnCI,UAAA;IACAO,IAAA,EAAMN,GAAA,CAAIM,IAAI;IACdL,KAAA,EAAOL,QAAA,CAASK,KAAA,IAASM,MAAA,CAAON,KAAA,IAASO,SAAA;IACzCN,KAAA,EAAOA,KAAA,KAAU;IACjBF,GAAA;IACAG;EACF;EAEA,MAAMM,OAAA,GAAUZ,eAAA,CAAgB;IAC9BY,OAAA,EAAS,IAAIC,OAAA;IACbV;EACF;EAEA,IAAIK,MAAA,CAAOM,MAAM,CAACC,MAAM,KAAK,GAAG;IAC9B,MAAMC,OAAA,GAAUb,GAAA,CAAIc,CAAC,CAAC,oCAAoC;MACxDC,KAAA,EAAOV,MAAA,CAAOW,IAAI,CAACJ,MAAM;MACzBK,KAAA,EAAOxB,cAAA,CACLM,UAAA,CAAWmB,MAAM,CAACC,MAAM,CAACd,MAAA,CAAOW,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxEZ,GAAA,CAAIoB,IAAI;IAEZ;IAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;MACE,GAAGjB,MAAM;MACTQ;IACF,GACA;MACEJ,OAAA;MACAc,MAAA,EAAQ7B,UAAA,CAAW8B;IACrB;EAEJ;EAEA,MAAMC,KAAA,GAAQpB,MAAA,CAAOW,IAAI,CAACJ,MAAM,GAAGP,MAAA,CAAOM,MAAM,CAACC,MAAM;EACvD,MAAMC,OAAA,GAAUb,GAAA,CAAIc,CAAC,CAAC,6BAA6B;IACjDC,KAAA,EAAOV,MAAA,CAAOM,MAAM,CAACC,MAAM;IAC3BK,KAAA,EAAOxB,cAAA,CAAeM,UAAA,CAAWmB,MAAM,CAACC,MAAM,CAACM,KAAA,GAAQ,IAAI,WAAW,WAAW,EAAEzB,GAAA,CAAIoB,IAAI;IAC3FK;EACF;EAEA,OAAOJ,QAAA,CAASC,IAAI,CAClB;IACE,GAAGjB,MAAM;IACTQ;EACF,GACA;IACEJ,OAAA;IACAc,MAAA,EAAQ7B,UAAA,CAAWgC;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -3,38 +3,43 @@ import { updateByIDOperation } from 'payload';
|
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
5
|
import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
|
|
6
|
-
export const updateByID = async ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
6
|
+
export const updateByID = async ({
|
|
7
|
+
id: incomingID,
|
|
8
|
+
collection,
|
|
9
|
+
req
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
searchParams
|
|
13
|
+
} = req;
|
|
14
|
+
const depth = searchParams.get('depth');
|
|
15
|
+
const autosave = searchParams.get('autosave') === 'true';
|
|
16
|
+
const draft = searchParams.get('draft') === 'true';
|
|
17
|
+
const id = sanitizeCollectionID({
|
|
18
|
+
id: incomingID,
|
|
19
|
+
collectionSlug: collection.config.slug,
|
|
20
|
+
payload: req.payload
|
|
21
|
+
});
|
|
22
|
+
const doc = await updateByIDOperation({
|
|
23
|
+
id,
|
|
24
|
+
autosave,
|
|
25
|
+
collection,
|
|
26
|
+
data: req.data,
|
|
27
|
+
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
28
|
+
draft,
|
|
29
|
+
req
|
|
30
|
+
});
|
|
31
|
+
let message = req.t('general:updatedSuccessfully');
|
|
32
|
+
if (draft) message = req.t('version:draftSavedSuccessfully');
|
|
33
|
+
if (autosave) message = req.t('version:autosavedSuccessfully');
|
|
34
|
+
return Response.json({
|
|
35
|
+
doc,
|
|
36
|
+
message
|
|
37
|
+
}, {
|
|
38
|
+
headers: headersWithCors({
|
|
39
|
+
headers: new Headers(),
|
|
40
|
+
req
|
|
41
|
+
}),
|
|
42
|
+
status: httpStatus.OK
|
|
43
|
+
});
|
|
38
44
|
};
|
|
39
|
-
|
|
40
45
|
//# sourceMappingURL=updateByID.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/collections/updateByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { updateByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const updateByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await updateByIDOperation({\n id,\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n req,\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) message = req.t('version:draftSavedSuccessfully')\n if (autosave) message = req.t('version:autosavedSuccessfully')\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"
|
|
1
|
+
{"version":3,"file":"updateByID.js","names":["httpStatus","updateByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","updateByID","id","incomingID","collection","req","searchParams","depth","get","autosave","draft","collectionSlug","config","slug","payload","doc","data","Number","undefined","message","t","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/updateByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { updateByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const updateByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await updateByIDOperation({\n id,\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n req,\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) message = req.t('version:draftSavedSuccessfully')\n if (autosave) message = req.t('version:autosavedSuccessfully')\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,mBAAmB,QAAQ;AACpC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,UAAA,GAA2C,MAAAA,CAAO;EAC7DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B,MAAMC,QAAA,GAAWH,YAAA,CAAaE,GAAG,CAAC,gBAAgB;EAClD,MAAME,KAAA,GAAQJ,YAAA,CAAaE,GAAG,CAAC,aAAa;EAE5C,MAAMN,EAAA,GAAKF,oBAAA,CAAqB;IAC9BE,EAAA,EAAIC,UAAA;IACJQ,cAAA,EAAgBP,UAAA,CAAWQ,MAAM,CAACC,IAAI;IACtCC,OAAA,EAAST,GAAA,CAAIS;EACf;EAEA,MAAMC,GAAA,GAAM,MAAMlB,mBAAA,CAAoB;IACpCK,EAAA;IACAO,QAAA;IACAL,UAAA;IACAY,IAAA,EAAMX,GAAA,CAAIW,IAAI;IACdT,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASU,MAAA,CAAOV,KAAA,IAASW,SAAA;IACzCR,KAAA;IACAL;EACF;EAEA,IAAIc,OAAA,GAAUd,GAAA,CAAIe,CAAC,CAAC;EAEpB,IAAIV,KAAA,EAAOS,OAAA,GAAUd,GAAA,CAAIe,CAAC,CAAC;EAC3B,IAAIX,QAAA,EAAUU,OAAA,GAAUd,GAAA,CAAIe,CAAC,CAAC;EAE9B,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEP,GAAA;IACAI;EACF,GACA;IACEI,OAAA,EAASxB,eAAA,CAAgB;MACvBwB,OAAA,EAAS,IAAIC,OAAA;MACbnB;IACF;IACAoB,MAAA,EAAQ7B,UAAA,CAAW8B;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -1,50 +1,52 @@
|
|
|
1
1
|
import { Forbidden, executeAccess } from 'payload';
|
|
2
2
|
import { endpointsAreDisabled } from '../checkEndpoints.js';
|
|
3
|
-
export async function checkFileAccess({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const doc = await req.payload.db.findOne({
|
|
39
|
-
collection: config.slug,
|
|
40
|
-
req,
|
|
41
|
-
where: queryToBuild
|
|
3
|
+
export async function checkFileAccess({
|
|
4
|
+
collection,
|
|
5
|
+
filename,
|
|
6
|
+
req
|
|
7
|
+
}) {
|
|
8
|
+
const {
|
|
9
|
+
config
|
|
10
|
+
} = collection;
|
|
11
|
+
const disableEndpoints = endpointsAreDisabled({
|
|
12
|
+
endpoints: config.endpoints,
|
|
13
|
+
request: req
|
|
14
|
+
});
|
|
15
|
+
if (disableEndpoints) return disableEndpoints;
|
|
16
|
+
const accessResult = await executeAccess({
|
|
17
|
+
isReadingStaticFile: true,
|
|
18
|
+
req
|
|
19
|
+
}, config.access.read);
|
|
20
|
+
if (typeof accessResult === 'object') {
|
|
21
|
+
const queryToBuild = {
|
|
22
|
+
and: [{
|
|
23
|
+
or: [{
|
|
24
|
+
filename: {
|
|
25
|
+
equals: filename
|
|
26
|
+
}
|
|
27
|
+
}]
|
|
28
|
+
}, accessResult]
|
|
29
|
+
};
|
|
30
|
+
if (config.upload.imageSizes) {
|
|
31
|
+
config.upload.imageSizes.forEach(({
|
|
32
|
+
name
|
|
33
|
+
}) => {
|
|
34
|
+
queryToBuild.and[0].or.push({
|
|
35
|
+
[`sizes.${name}.filename`]: {
|
|
36
|
+
equals: filename
|
|
37
|
+
}
|
|
42
38
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const doc = await req.payload.db.findOne({
|
|
42
|
+
collection: config.slug,
|
|
43
|
+
req,
|
|
44
|
+
where: queryToBuild
|
|
45
|
+
});
|
|
46
|
+
if (!doc) {
|
|
47
|
+
throw new Forbidden(req.t);
|
|
47
48
|
}
|
|
49
|
+
return doc;
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
|
-
|
|
50
52
|
//# sourceMappingURL=checkFileAccess.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/files/checkFileAccess.ts"],"sourcesContent":["import type { Collection, PayloadRequest, TypeWithID, Where } from 'payload'\n\nimport { Forbidden, executeAccess } from 'payload'\n\nimport { endpointsAreDisabled } from '../checkEndpoints.js'\n\nexport async function checkFileAccess({\n collection,\n filename,\n req,\n}: {\n collection: Collection\n filename: string\n req: PayloadRequest\n}): Promise<Response | TypeWithID> {\n const { config } = collection\n const disableEndpoints = endpointsAreDisabled({ endpoints: config.endpoints, request: req })\n if (disableEndpoints) return disableEndpoints\n\n const accessResult = await executeAccess({ isReadingStaticFile: true, req }, config.access.read)\n\n if (typeof accessResult === 'object') {\n const queryToBuild: Where = {\n and: [\n {\n or: [\n {\n filename: {\n equals: filename,\n },\n },\n ],\n },\n accessResult,\n ],\n }\n\n if (config.upload.imageSizes) {\n config.upload.imageSizes.forEach(({ name }) => {\n queryToBuild.and[0].or.push({\n [`sizes.${name}.filename`]: {\n equals: filename,\n },\n })\n })\n }\n\n const doc = await req.payload.db.findOne({\n collection: config.slug,\n req,\n where: queryToBuild,\n })\n\n if (!doc) {\n throw new Forbidden(req.t)\n }\n\n return doc\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"checkFileAccess.js","names":["Forbidden","executeAccess","endpointsAreDisabled","checkFileAccess","collection","filename","req","config","disableEndpoints","endpoints","request","accessResult","isReadingStaticFile","access","read","queryToBuild","and","or","equals","upload","imageSizes","forEach","name","push","doc","payload","db","findOne","slug","where","t"],"sources":["../../../../src/routes/rest/files/checkFileAccess.ts"],"sourcesContent":["import type { Collection, PayloadRequest, TypeWithID, Where } from 'payload'\n\nimport { Forbidden, executeAccess } from 'payload'\n\nimport { endpointsAreDisabled } from '../checkEndpoints.js'\n\nexport async function checkFileAccess({\n collection,\n filename,\n req,\n}: {\n collection: Collection\n filename: string\n req: PayloadRequest\n}): Promise<Response | TypeWithID> {\n const { config } = collection\n const disableEndpoints = endpointsAreDisabled({ endpoints: config.endpoints, request: req })\n if (disableEndpoints) return disableEndpoints\n\n const accessResult = await executeAccess({ isReadingStaticFile: true, req }, config.access.read)\n\n if (typeof accessResult === 'object') {\n const queryToBuild: Where = {\n and: [\n {\n or: [\n {\n filename: {\n equals: filename,\n },\n },\n ],\n },\n accessResult,\n ],\n }\n\n if (config.upload.imageSizes) {\n config.upload.imageSizes.forEach(({ name }) => {\n queryToBuild.and[0].or.push({\n [`sizes.${name}.filename`]: {\n equals: filename,\n },\n })\n })\n }\n\n const doc = await req.payload.db.findOne({\n collection: config.slug,\n req,\n where: queryToBuild,\n })\n\n if (!doc) {\n throw new Forbidden(req.t)\n }\n\n return doc\n }\n}\n"],"mappings":"AAEA,SAASA,SAAS,EAAEC,aAAa,QAAQ;AAEzC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,gBAAgB;EACpCC,UAAU;EACVC,QAAQ;EACRC;AAAG,CAKJ;EACC,MAAM;IAAEC;EAAM,CAAE,GAAGH,UAAA;EACnB,MAAMI,gBAAA,GAAmBN,oBAAA,CAAqB;IAAEO,SAAA,EAAWF,MAAA,CAAOE,SAAS;IAAEC,OAAA,EAASJ;EAAI;EAC1F,IAAIE,gBAAA,EAAkB,OAAOA,gBAAA;EAE7B,MAAMG,YAAA,GAAe,MAAMV,aAAA,CAAc;IAAEW,mBAAA,EAAqB;IAAMN;EAAI,GAAGC,MAAA,CAAOM,MAAM,CAACC,IAAI;EAE/F,IAAI,OAAOH,YAAA,KAAiB,UAAU;IACpC,MAAMI,YAAA,GAAsB;MAC1BC,GAAA,EAAK,CACH;QACEC,EAAA,EAAI,CACF;UACEZ,QAAA,EAAU;YACRa,MAAA,EAAQb;UACV;QACF;MAEJ,GACAM,YAAA;IAEJ;IAEA,IAAIJ,MAAA,CAAOY,MAAM,CAACC,UAAU,EAAE;MAC5Bb,MAAA,CAAOY,MAAM,CAACC,UAAU,CAACC,OAAO,CAAC,CAAC;QAAEC;MAAI,CAAE;QACxCP,YAAA,CAAaC,GAAG,CAAC,EAAE,CAACC,EAAE,CAACM,IAAI,CAAC;UAC1B,CAAC,SAASD,IAAA,WAAe,GAAG;YAC1BJ,MAAA,EAAQb;UACV;QACF;MACF;IACF;IAEA,MAAMmB,GAAA,GAAM,MAAMlB,GAAA,CAAImB,OAAO,CAACC,EAAE,CAACC,OAAO,CAAC;MACvCvB,UAAA,EAAYG,MAAA,CAAOqB,IAAI;MACvBtB,GAAA;MACAuB,KAAA,EAAOd;IACT;IAEA,IAAI,CAACS,GAAA,EAAK;MACR,MAAM,IAAIxB,SAAA,CAAUM,GAAA,CAAIwB,CAAC;IAC3B;IAEA,OAAON,GAAA;EACT;AACF","ignoreList":[]}
|
|
@@ -8,56 +8,59 @@ import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
|
8
8
|
import { routeError } from '../routeError.js';
|
|
9
9
|
import { checkFileAccess } from './checkFileAccess.js';
|
|
10
10
|
import { getFileTypeFallback } from './getFileTypeFallback.js';
|
|
11
|
-
export const getFile = async ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const fileDir = collection.config.upload?.staticDir || collection.config.slug;
|
|
36
|
-
const filePath = path.resolve(`${fileDir}/${filename}`);
|
|
37
|
-
const stats = await fsPromises.stat(filePath);
|
|
38
|
-
const data = streamFile(filePath);
|
|
39
|
-
const fileTypeResult = await fileTypeFromFile(filePath) || getFileTypeFallback(filePath);
|
|
40
|
-
let headers = new Headers();
|
|
41
|
-
headers.set('Content-Type', fileTypeResult.mime);
|
|
42
|
-
headers.set('Content-Length', stats.size + '');
|
|
43
|
-
headers = collection.config.upload?.modifyResponseHeaders ? collection.config.upload.modifyResponseHeaders({
|
|
44
|
-
headers
|
|
45
|
-
}) : headers;
|
|
46
|
-
return new Response(data, {
|
|
47
|
-
headers: headersWithCors({
|
|
48
|
-
headers,
|
|
49
|
-
req
|
|
50
|
-
}),
|
|
51
|
-
status: httpStatus.OK
|
|
52
|
-
});
|
|
53
|
-
} catch (err) {
|
|
54
|
-
return routeError({
|
|
55
|
-
collection,
|
|
56
|
-
config: req.payload.config,
|
|
57
|
-
err,
|
|
58
|
-
req
|
|
11
|
+
export const getFile = async ({
|
|
12
|
+
collection,
|
|
13
|
+
filename,
|
|
14
|
+
req
|
|
15
|
+
}) => {
|
|
16
|
+
try {
|
|
17
|
+
if (!collection.config.upload) {
|
|
18
|
+
throw new APIError(`This collection is not an upload collection: ${collection.config.slug}`, httpStatus.BAD_REQUEST);
|
|
19
|
+
}
|
|
20
|
+
const accessResult = await checkFileAccess({
|
|
21
|
+
collection,
|
|
22
|
+
filename,
|
|
23
|
+
req
|
|
24
|
+
});
|
|
25
|
+
if (accessResult instanceof Response) return accessResult;
|
|
26
|
+
if (collection.config.upload.handlers?.length) {
|
|
27
|
+
let customResponse = null;
|
|
28
|
+
for (const handler of collection.config.upload.handlers) {
|
|
29
|
+
customResponse = await handler(req, {
|
|
30
|
+
doc: accessResult,
|
|
31
|
+
params: {
|
|
32
|
+
collection: collection.config.slug,
|
|
33
|
+
filename
|
|
34
|
+
}
|
|
59
35
|
});
|
|
36
|
+
}
|
|
37
|
+
if (customResponse instanceof Response) return customResponse;
|
|
60
38
|
}
|
|
39
|
+
const fileDir = collection.config.upload?.staticDir || collection.config.slug;
|
|
40
|
+
const filePath = path.resolve(`${fileDir}/${filename}`);
|
|
41
|
+
const stats = await fsPromises.stat(filePath);
|
|
42
|
+
const data = streamFile(filePath);
|
|
43
|
+
const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath);
|
|
44
|
+
let headers = new Headers();
|
|
45
|
+
headers.set('Content-Type', fileTypeResult.mime);
|
|
46
|
+
headers.set('Content-Length', stats.size + '');
|
|
47
|
+
headers = collection.config.upload?.modifyResponseHeaders ? collection.config.upload.modifyResponseHeaders({
|
|
48
|
+
headers
|
|
49
|
+
}) : headers;
|
|
50
|
+
return new Response(data, {
|
|
51
|
+
headers: headersWithCors({
|
|
52
|
+
headers,
|
|
53
|
+
req
|
|
54
|
+
}),
|
|
55
|
+
status: httpStatus.OK
|
|
56
|
+
});
|
|
57
|
+
} catch (err) {
|
|
58
|
+
return routeError({
|
|
59
|
+
collection,
|
|
60
|
+
config: req.payload.config,
|
|
61
|
+
err,
|
|
62
|
+
req
|
|
63
|
+
});
|
|
64
|
+
}
|
|
61
65
|
};
|
|
62
|
-
|
|
63
66
|
//# sourceMappingURL=getFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/files/getFile.ts"],"sourcesContent":["import type { Collection, PayloadRequest } from 'payload'\n\nimport { fileTypeFromFile } from 'file-type'\nimport fsPromises from 'fs/promises'\nimport httpStatus from 'http-status'\nimport path from 'path'\nimport { APIError } from 'payload'\n\nimport { streamFile } from '../../../fetchAPI-stream-file/index.js'\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\nimport { checkFileAccess } from './checkFileAccess.js'\nimport { getFileTypeFallback } from './getFileTypeFallback.js'\n\n// /:collectionSlug/file/:filename\ntype Args = {\n collection: Collection\n filename: string\n req: PayloadRequest\n}\nexport const getFile = async ({ collection, filename, req }: Args): Promise<Response> => {\n try {\n if (!collection.config.upload) {\n throw new APIError(\n `This collection is not an upload collection: ${collection.config.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n const accessResult = await checkFileAccess({\n collection,\n filename,\n req,\n })\n\n if (accessResult instanceof Response) return accessResult\n\n if (collection.config.upload.handlers?.length) {\n let customResponse = null\n for (const handler of collection.config.upload.handlers) {\n customResponse = await handler(req, {\n doc: accessResult,\n params: {\n collection: collection.config.slug,\n filename,\n },\n })\n }\n\n if (customResponse instanceof Response) return customResponse\n }\n\n const fileDir = collection.config.upload?.staticDir || collection.config.slug\n const filePath = path.resolve(`${fileDir}/${filename}`)\n const stats = await fsPromises.stat(filePath)\n const data = streamFile(filePath)\n const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)\n\n let headers = new Headers()\n headers.set('Content-Type', fileTypeResult.mime)\n headers.set('Content-Length', stats.size + '')\n headers = collection.config.upload?.modifyResponseHeaders\n ? collection.config.upload.modifyResponseHeaders({ headers })\n : headers\n\n return new Response(data, {\n headers: headersWithCors({\n headers,\n req,\n }),\n status: httpStatus.OK,\n })\n } catch (err) {\n return routeError({\n collection,\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"getFile.js","names":["fileTypeFromFile","fsPromises","httpStatus","path","APIError","streamFile","headersWithCors","routeError","checkFileAccess","getFileTypeFallback","getFile","collection","filename","req","config","upload","slug","BAD_REQUEST","accessResult","Response","handlers","length","customResponse","handler","doc","params","fileDir","staticDir","filePath","resolve","stats","stat","data","fileTypeResult","headers","Headers","set","mime","size","modifyResponseHeaders","status","OK","err","payload"],"sources":["../../../../src/routes/rest/files/getFile.ts"],"sourcesContent":["import type { Collection, PayloadRequest } from 'payload'\n\nimport { fileTypeFromFile } from 'file-type'\nimport fsPromises from 'fs/promises'\nimport httpStatus from 'http-status'\nimport path from 'path'\nimport { APIError } from 'payload'\n\nimport { streamFile } from '../../../fetchAPI-stream-file/index.js'\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\nimport { checkFileAccess } from './checkFileAccess.js'\nimport { getFileTypeFallback } from './getFileTypeFallback.js'\n\n// /:collectionSlug/file/:filename\ntype Args = {\n collection: Collection\n filename: string\n req: PayloadRequest\n}\nexport const getFile = async ({ collection, filename, req }: Args): Promise<Response> => {\n try {\n if (!collection.config.upload) {\n throw new APIError(\n `This collection is not an upload collection: ${collection.config.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n const accessResult = await checkFileAccess({\n collection,\n filename,\n req,\n })\n\n if (accessResult instanceof Response) return accessResult\n\n if (collection.config.upload.handlers?.length) {\n let customResponse = null\n for (const handler of collection.config.upload.handlers) {\n customResponse = await handler(req, {\n doc: accessResult,\n params: {\n collection: collection.config.slug,\n filename,\n },\n })\n }\n\n if (customResponse instanceof Response) return customResponse\n }\n\n const fileDir = collection.config.upload?.staticDir || collection.config.slug\n const filePath = path.resolve(`${fileDir}/${filename}`)\n const stats = await fsPromises.stat(filePath)\n const data = streamFile(filePath)\n const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)\n\n let headers = new Headers()\n headers.set('Content-Type', fileTypeResult.mime)\n headers.set('Content-Length', stats.size + '')\n headers = collection.config.upload?.modifyResponseHeaders\n ? collection.config.upload.modifyResponseHeaders({ headers })\n : headers\n\n return new Response(data, {\n headers: headersWithCors({\n headers,\n req,\n }),\n status: httpStatus.OK,\n })\n } catch (err) {\n return routeError({\n collection,\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ;AACjC,OAAOC,UAAA,MAAgB;AACvB,OAAOC,UAAA,MAAgB;AACvB,OAAOC,IAAA,MAAU;AACjB,SAASC,QAAQ,QAAQ;AAEzB,SAASC,UAAU,QAAQ;AAC3B,SAASC,eAAe,QAAQ;AAChC,SAASC,UAAU,QAAQ;AAC3B,SAASC,eAAe,QAAQ;AAChC,SAASC,mBAAmB,QAAQ;AAQpC,OAAO,MAAMC,OAAA,GAAU,MAAAA,CAAO;EAAEC,UAAU;EAAEC,QAAQ;EAAEC;AAAG,CAAQ;EAC/D,IAAI;IACF,IAAI,CAACF,UAAA,CAAWG,MAAM,CAACC,MAAM,EAAE;MAC7B,MAAM,IAAIX,QAAA,CACR,gDAAgDO,UAAA,CAAWG,MAAM,CAACE,IAAI,EAAE,EACxEd,UAAA,CAAWe,WAAW;IAE1B;IAEA,MAAMC,YAAA,GAAe,MAAMV,eAAA,CAAgB;MACzCG,UAAA;MACAC,QAAA;MACAC;IACF;IAEA,IAAIK,YAAA,YAAwBC,QAAA,EAAU,OAAOD,YAAA;IAE7C,IAAIP,UAAA,CAAWG,MAAM,CAACC,MAAM,CAACK,QAAQ,EAAEC,MAAA,EAAQ;MAC7C,IAAIC,cAAA,GAAiB;MACrB,KAAK,MAAMC,OAAA,IAAWZ,UAAA,CAAWG,MAAM,CAACC,MAAM,CAACK,QAAQ,EAAE;QACvDE,cAAA,GAAiB,MAAMC,OAAA,CAAQV,GAAA,EAAK;UAClCW,GAAA,EAAKN,YAAA;UACLO,MAAA,EAAQ;YACNd,UAAA,EAAYA,UAAA,CAAWG,MAAM,CAACE,IAAI;YAClCJ;UACF;QACF;MACF;MAEA,IAAIU,cAAA,YAA0BH,QAAA,EAAU,OAAOG,cAAA;IACjD;IAEA,MAAMI,OAAA,GAAUf,UAAA,CAAWG,MAAM,CAACC,MAAM,EAAEY,SAAA,IAAahB,UAAA,CAAWG,MAAM,CAACE,IAAI;IAC7E,MAAMY,QAAA,GAAWzB,IAAA,CAAK0B,OAAO,CAAC,GAAGH,OAAA,IAAWd,QAAA,EAAU;IACtD,MAAMkB,KAAA,GAAQ,MAAM7B,UAAA,CAAW8B,IAAI,CAACH,QAAA;IACpC,MAAMI,IAAA,GAAO3B,UAAA,CAAWuB,QAAA;IACxB,MAAMK,cAAA,GAAiB,OAAOjC,gBAAA,CAAiB4B,QAAA,MAAcnB,mBAAA,CAAoBmB,QAAA;IAEjF,IAAIM,OAAA,GAAU,IAAIC,OAAA;IAClBD,OAAA,CAAQE,GAAG,CAAC,gBAAgBH,cAAA,CAAeI,IAAI;IAC/CH,OAAA,CAAQE,GAAG,CAAC,kBAAkBN,KAAA,CAAMQ,IAAI,GAAG;IAC3CJ,OAAA,GAAUvB,UAAA,CAAWG,MAAM,CAACC,MAAM,EAAEwB,qBAAA,GAChC5B,UAAA,CAAWG,MAAM,CAACC,MAAM,CAACwB,qBAAqB,CAAC;MAAEL;IAAQ,KACzDA,OAAA;IAEJ,OAAO,IAAIf,QAAA,CAASa,IAAA,EAAM;MACxBE,OAAA,EAAS5B,eAAA,CAAgB;QACvB4B,OAAA;QACArB;MACF;MACA2B,MAAA,EAAQtC,UAAA,CAAWuC;IACrB;EACF,EAAE,OAAOC,GAAA,EAAK;IACZ,OAAOnC,UAAA,CAAW;MAChBI,UAAA;MACAG,MAAA,EAAQD,GAAA,CAAI8B,OAAO,CAAC7B,MAAM;MAC1B4B,GAAA;MACA7B;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
const extensionMap = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
css: 'text/css',
|
|
3
|
+
csv: 'text/csv',
|
|
4
|
+
htm: 'text/html',
|
|
5
|
+
html: 'text/html',
|
|
6
|
+
js: 'application/javascript',
|
|
7
|
+
json: 'application/json',
|
|
8
|
+
md: 'text/markdown',
|
|
9
|
+
svg: 'image/svg+xml',
|
|
10
|
+
xml: 'application/xml',
|
|
11
|
+
yml: 'application/x-yaml'
|
|
12
12
|
};
|
|
13
|
-
export const getFileTypeFallback =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
export const getFileTypeFallback = path => {
|
|
14
|
+
const ext = path.split('.').pop() || 'txt';
|
|
15
|
+
return {
|
|
16
|
+
ext,
|
|
17
|
+
mime: extensionMap[ext] || 'text/plain'
|
|
18
|
+
};
|
|
19
19
|
};
|
|
20
|
-
|
|
21
20
|
//# sourceMappingURL=getFileTypeFallback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/files/getFileTypeFallback.ts"],"sourcesContent":["type ReturnType = {\n ext: string\n mime: string\n}\n\nconst extensionMap: {\n [ext: string]: string\n} = {\n css: 'text/css',\n csv: 'text/csv',\n htm: 'text/html',\n html: 'text/html',\n js: 'application/javascript',\n json: 'application/json',\n md: 'text/markdown',\n svg: 'image/svg+xml',\n xml: 'application/xml',\n yml: 'application/x-yaml',\n}\n\nexport const getFileTypeFallback = (path: string): ReturnType => {\n const ext = path.split('.').pop() || 'txt'\n\n return {\n ext,\n mime: extensionMap[ext] || 'text/plain',\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"getFileTypeFallback.js","names":["extensionMap","css","csv","htm","html","js","json","md","svg","xml","yml","getFileTypeFallback","path","ext","split","pop","mime"],"sources":["../../../../src/routes/rest/files/getFileTypeFallback.ts"],"sourcesContent":["type ReturnType = {\n ext: string\n mime: string\n}\n\nconst extensionMap: {\n [ext: string]: string\n} = {\n css: 'text/css',\n csv: 'text/csv',\n htm: 'text/html',\n html: 'text/html',\n js: 'application/javascript',\n json: 'application/json',\n md: 'text/markdown',\n svg: 'image/svg+xml',\n xml: 'application/xml',\n yml: 'application/x-yaml',\n}\n\nexport const getFileTypeFallback = (path: string): ReturnType => {\n const ext = path.split('.').pop() || 'txt'\n\n return {\n ext,\n mime: extensionMap[ext] || 'text/plain',\n }\n}\n"],"mappings":"AAKA,MAAMA,YAAA,GAEF;EACFC,GAAA,EAAK;EACLC,GAAA,EAAK;EACLC,GAAA,EAAK;EACLC,IAAA,EAAM;EACNC,EAAA,EAAI;EACJC,IAAA,EAAM;EACNC,EAAA,EAAI;EACJC,GAAA,EAAK;EACLC,GAAA,EAAK;EACLC,GAAA,EAAK;AACP;AAEA,OAAO,MAAMC,mBAAA,GAAuBC,IAAA;EAClC,MAAMC,GAAA,GAAMD,IAAA,CAAKE,KAAK,CAAC,KAAKC,GAAG,MAAM;EAErC,OAAO;IACLF,GAAA;IACAG,IAAA,EAAMhB,YAAY,CAACa,GAAA,CAAI,IAAI;EAC7B;AACF","ignoreList":[]}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
2
|
import { docAccessOperationGlobal } from 'payload';
|
|
3
3
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
4
|
-
export const docAccess = async ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
export const docAccess = async ({
|
|
5
|
+
globalConfig,
|
|
6
|
+
req
|
|
7
|
+
}) => {
|
|
8
|
+
const result = await docAccessOperationGlobal({
|
|
9
|
+
globalConfig,
|
|
10
|
+
req
|
|
11
|
+
});
|
|
12
|
+
return Response.json(result, {
|
|
13
|
+
headers: headersWithCors({
|
|
14
|
+
headers: new Headers(),
|
|
15
|
+
req
|
|
16
|
+
}),
|
|
17
|
+
status: httpStatus.OK
|
|
18
|
+
});
|
|
16
19
|
};
|
|
17
|
-
|
|
18
20
|
//# sourceMappingURL=docAccess.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/globals/docAccess.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { docAccessOperationGlobal } from 'payload'\n\nimport type { GlobalRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const docAccess: GlobalRouteHandler = async ({ globalConfig, req }) => {\n const result = await docAccessOperationGlobal({\n globalConfig,\n req,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"
|
|
1
|
+
{"version":3,"file":"docAccess.js","names":["httpStatus","docAccessOperationGlobal","headersWithCors","docAccess","globalConfig","req","result","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/globals/docAccess.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { docAccessOperationGlobal } from 'payload'\n\nimport type { GlobalRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const docAccess: GlobalRouteHandler = async ({ globalConfig, req }) => {\n const result = await docAccessOperationGlobal({\n globalConfig,\n req,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,wBAAwB,QAAQ;AAIzC,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,SAAA,GAAgC,MAAAA,CAAO;EAAEC,YAAY;EAAEC;AAAG,CAAE;EACvE,MAAMC,MAAA,GAAS,MAAML,wBAAA,CAAyB;IAC5CG,YAAA;IACAC;EACF;EAEA,OAAOE,QAAA,CAASC,IAAI,CAACF,MAAA,EAAQ;IAC3BG,OAAA,EAASP,eAAA,CAAgB;MACvBO,OAAA,EAAS,IAAIC,OAAA;MACbL;IACF;IACAM,MAAA,EAAQX,UAAA,CAAWY;EACrB;AACF","ignoreList":[]}
|
|
@@ -2,23 +2,27 @@ import httpStatus from 'http-status';
|
|
|
2
2
|
import { findOneOperation } from 'payload';
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
|
-
export const findOne = async ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
export const findOne = async ({
|
|
6
|
+
globalConfig,
|
|
7
|
+
req
|
|
8
|
+
}) => {
|
|
9
|
+
const {
|
|
10
|
+
searchParams
|
|
11
|
+
} = req;
|
|
12
|
+
const depth = searchParams.get('depth');
|
|
13
|
+
const result = await findOneOperation({
|
|
14
|
+
slug: globalConfig.slug,
|
|
15
|
+
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
16
|
+
draft: searchParams.get('draft') === 'true',
|
|
17
|
+
globalConfig,
|
|
18
|
+
req
|
|
19
|
+
});
|
|
20
|
+
return Response.json(result, {
|
|
21
|
+
headers: headersWithCors({
|
|
22
|
+
headers: new Headers(),
|
|
23
|
+
req
|
|
24
|
+
}),
|
|
25
|
+
status: httpStatus.OK
|
|
26
|
+
});
|
|
22
27
|
};
|
|
23
|
-
|
|
24
28
|
//# sourceMappingURL=findOne.js.map
|