@payloadcms/next 3.0.0-canary.92e4997 → 3.0.0-canary.f1db24e
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.cjs +36 -10
- package/dist/cjs/withPayload.cjs.map +1 -1
- package/dist/elements/LeaveWithoutSaving/index.js +35 -15
- package/dist/elements/LeaveWithoutSaving/index.js.map +1 -1
- package/dist/exports/utilities.d.ts +0 -2
- package/dist/exports/utilities.d.ts.map +1 -1
- package/dist/exports/utilities.js +0 -2
- package/dist/exports/utilities.js.map +1 -1
- package/dist/exports/views.d.ts +2 -1
- package/dist/exports/views.d.ts.map +1 -1
- package/dist/exports/views.js +2 -1
- package/dist/exports/views.js.map +1 -1
- package/dist/fetchAPI-multipart/index.d.ts +2 -4
- package/dist/fetchAPI-multipart/index.d.ts.map +1 -1
- package/dist/fetchAPI-multipart/index.js +2 -4
- package/dist/fetchAPI-multipart/index.js.map +1 -1
- package/dist/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
- package/dist/fetchAPI-multipart/processMultipart.js +17 -11
- package/dist/fetchAPI-multipart/processMultipart.js.map +1 -1
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js +36 -21
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/prod/payload/payload-favicon-dark.png +0 -0
- package/dist/prod/payload/payload-favicon-light.png +0 -0
- package/dist/prod/styles.css +1 -1
- package/dist/routes/graphql/handler.d.ts.map +1 -1
- package/dist/routes/graphql/handler.js +3 -4
- package/dist/routes/graphql/handler.js.map +1 -1
- package/dist/routes/rest/auth/access.d.ts.map +1 -1
- package/dist/routes/rest/auth/access.js +17 -7
- package/dist/routes/rest/auth/access.js.map +1 -1
- package/dist/routes/rest/buildFormState.d.ts +0 -2
- package/dist/routes/rest/buildFormState.d.ts.map +1 -1
- package/dist/routes/rest/buildFormState.js +16 -166
- package/dist/routes/rest/buildFormState.js.map +1 -1
- package/dist/routes/rest/files/checkFileAccess.d.ts +2 -2
- package/dist/routes/rest/files/checkFileAccess.d.ts.map +1 -1
- package/dist/routes/rest/files/checkFileAccess.js +1 -0
- package/dist/routes/rest/files/checkFileAccess.js.map +1 -1
- package/dist/routes/rest/files/getFile.d.ts.map +1 -1
- package/dist/routes/rest/files/getFile.js +3 -1
- package/dist/routes/rest/files/getFile.js.map +1 -1
- package/dist/routes/rest/index.d.ts.map +1 -1
- package/dist/routes/rest/index.js +3 -1
- package/dist/routes/rest/index.js.map +1 -1
- package/dist/routes/rest/og/image.d.ts +9 -0
- package/dist/routes/rest/og/image.d.ts.map +1 -0
- package/dist/routes/rest/og/image.js +79 -0
- package/dist/routes/rest/og/image.js.map +1 -0
- package/dist/routes/rest/og/index.d.ts +11 -0
- package/dist/routes/rest/og/index.d.ts.map +1 -0
- package/dist/routes/rest/og/index.js +73 -0
- package/dist/routes/rest/og/index.js.map +1 -0
- package/dist/routes/rest/og/roboto-regular.woff +0 -0
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +12 -41
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/dist/utilities/addLocalesToRequest.js +4 -1
- package/dist/utilities/addLocalesToRequest.js.map +1 -1
- package/dist/utilities/getNextRequestI18n.d.ts +1 -1
- package/dist/utilities/getNextRequestI18n.js +1 -1
- package/dist/utilities/getNextRequestI18n.js.map +1 -1
- package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
- package/dist/utilities/getPayloadHMR.js +5 -3
- package/dist/utilities/getPayloadHMR.js.map +1 -1
- package/dist/utilities/getRequestLanguage.d.ts.map +1 -1
- package/dist/utilities/getRequestLanguage.js +1 -1
- package/dist/utilities/getRequestLanguage.js.map +1 -1
- package/dist/utilities/getRequestTheme.d.ts +11 -0
- package/dist/utilities/getRequestTheme.d.ts.map +1 -0
- package/dist/utilities/getRequestTheme.js +19 -0
- package/dist/utilities/getRequestTheme.js.map +1 -0
- package/dist/utilities/initPage/handleAdminPage.js +1 -1
- package/dist/utilities/initPage/handleAdminPage.js.map +1 -1
- package/dist/utilities/initPage/handleAuthRedirect.d.ts +2 -2
- package/dist/utilities/initPage/handleAuthRedirect.d.ts.map +1 -1
- package/dist/utilities/initPage/handleAuthRedirect.js +5 -4
- package/dist/utilities/initPage/handleAuthRedirect.js.map +1 -1
- package/dist/utilities/initPage/index.d.ts.map +1 -1
- package/dist/utilities/initPage/index.js +12 -1
- package/dist/utilities/initPage/index.js.map +1 -1
- package/dist/utilities/initPage/shared.d.ts +2 -2
- package/dist/utilities/initPage/shared.d.ts.map +1 -1
- package/dist/utilities/initPage/shared.js +10 -9
- package/dist/utilities/initPage/shared.js.map +1 -1
- package/dist/utilities/meta.d.ts +4 -8
- package/dist/utilities/meta.d.ts.map +1 -1
- package/dist/utilities/meta.js +64 -25
- package/dist/utilities/meta.js.map +1 -1
- package/dist/views/API/LocaleSelector/index.d.ts +9 -0
- package/dist/views/API/LocaleSelector/index.d.ts.map +1 -0
- package/dist/views/API/LocaleSelector/index.js +16 -0
- package/dist/views/API/LocaleSelector/index.js.map +1 -0
- package/dist/views/API/RenderJSON/index.js +100 -68
- package/dist/views/API/RenderJSON/index.js.map +1 -1
- package/dist/views/API/index.client.d.ts.map +1 -1
- package/dist/views/API/index.client.js +127 -93
- package/dist/views/API/index.client.js.map +1 -1
- package/dist/views/API/index.js +2 -1
- package/dist/views/API/index.js.map +1 -1
- package/dist/views/API/meta.d.ts.map +1 -1
- package/dist/views/API/meta.js +13 -6
- package/dist/views/API/meta.js.map +1 -1
- package/dist/views/Account/Settings/LanguageSelector.d.ts +6 -0
- package/dist/views/Account/Settings/LanguageSelector.d.ts.map +1 -0
- package/dist/views/Account/Settings/LanguageSelector.js +19 -0
- package/dist/views/Account/Settings/LanguageSelector.js.map +1 -0
- package/dist/views/Account/Settings/index.d.ts +4 -0
- package/dist/views/Account/Settings/index.d.ts.map +1 -1
- package/dist/views/Account/Settings/index.js +24 -20
- package/dist/views/Account/Settings/index.js.map +1 -1
- package/dist/views/Account/ToggleTheme/index.js +2 -1
- package/dist/views/Account/ToggleTheme/index.js.map +1 -1
- package/dist/views/Account/index.d.ts.map +1 -1
- package/dist/views/Account/index.js +66 -31
- package/dist/views/Account/index.js.map +1 -1
- package/dist/views/Account/meta.d.ts.map +1 -1
- package/dist/views/Account/meta.js +4 -5
- package/dist/views/Account/meta.js.map +1 -1
- package/dist/views/CreateFirstUser/index.client.js +29 -19
- package/dist/views/CreateFirstUser/index.client.js.map +1 -1
- package/dist/views/CreateFirstUser/index.js +16 -6
- package/dist/views/CreateFirstUser/index.js.map +1 -1
- package/dist/views/CreateFirstUser/meta.d.ts.map +1 -1
- package/dist/views/CreateFirstUser/meta.js +4 -5
- package/dist/views/CreateFirstUser/meta.js.map +1 -1
- package/dist/views/Dashboard/Default/index.d.ts +5 -3
- package/dist/views/Dashboard/Default/index.d.ts.map +1 -1
- package/dist/views/Dashboard/Default/index.js +118 -20
- package/dist/views/Dashboard/Default/index.js.map +1 -1
- package/dist/views/Dashboard/index.d.ts.map +1 -1
- package/dist/views/Dashboard/index.js +51 -11
- package/dist/views/Dashboard/index.js.map +1 -1
- package/dist/views/Dashboard/meta.d.ts.map +1 -1
- package/dist/views/Dashboard/meta.js +8 -5
- package/dist/views/Dashboard/meta.js.map +1 -1
- package/dist/views/Document/getCustomViewByKey.d.ts.map +1 -1
- package/dist/views/Document/getCustomViewByKey.js +2 -1
- package/dist/views/Document/getCustomViewByKey.js.map +1 -1
- package/dist/views/Document/getDocumentData.d.ts +9 -0
- package/dist/views/Document/getDocumentData.d.ts.map +1 -0
- package/dist/views/Document/getDocumentData.js +31 -0
- package/dist/views/Document/getDocumentData.js.map +1 -0
- package/dist/views/Document/getDocumentPermissions.d.ts +14 -0
- package/dist/views/Document/getDocumentPermissions.d.ts.map +1 -0
- package/dist/views/Document/getDocumentPermissions.js +83 -0
- package/dist/views/Document/getDocumentPermissions.js.map +1 -0
- package/dist/views/Document/getMetaBySegment.d.ts +0 -1
- package/dist/views/Document/getMetaBySegment.d.ts.map +1 -1
- package/dist/views/Document/getMetaBySegment.js +1 -1
- package/dist/views/Document/getMetaBySegment.js.map +1 -1
- package/dist/views/Document/getViewsFromConfig.d.ts.map +1 -1
- package/dist/views/Document/getViewsFromConfig.js +172 -171
- 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 +70 -47
- package/dist/views/Document/index.js.map +1 -1
- package/dist/views/Edit/Default/Auth/APIKey.js +42 -26
- package/dist/views/Edit/Default/Auth/APIKey.js.map +1 -1
- package/dist/views/Edit/Default/Auth/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/Auth/index.js +85 -51
- package/dist/views/Edit/Default/Auth/index.js.map +1 -1
- package/dist/views/Edit/Default/SetDocumentStepNav/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/SetDocumentStepNav/index.js +25 -22
- package/dist/views/Edit/Default/SetDocumentStepNav/index.js.map +1 -1
- package/dist/views/Edit/Default/index.d.ts.map +1 -1
- package/dist/views/Edit/Default/index.js +78 -68
- package/dist/views/Edit/Default/index.js.map +1 -1
- package/dist/views/Edit/index.client.d.ts.map +1 -1
- package/dist/views/Edit/index.client.js +11 -7
- package/dist/views/Edit/index.client.js.map +1 -1
- package/dist/views/Edit/index.js +2 -1
- package/dist/views/Edit/index.js.map +1 -1
- package/dist/views/Edit/meta.d.ts.map +1 -1
- package/dist/views/Edit/meta.js +17 -15
- package/dist/views/Edit/meta.js.map +1 -1
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +42 -20
- package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -1
- package/dist/views/ForgotPassword/index.d.ts.map +1 -1
- package/dist/views/ForgotPassword/index.js +38 -18
- package/dist/views/ForgotPassword/index.js.map +1 -1
- package/dist/views/ForgotPassword/meta.d.ts.map +1 -1
- package/dist/views/ForgotPassword/meta.js +4 -5
- package/dist/views/ForgotPassword/meta.js.map +1 -1
- package/dist/views/List/Default/index.d.ts.map +1 -1
- package/dist/views/List/Default/index.js +162 -87
- package/dist/views/List/Default/index.js.map +1 -1
- package/dist/views/List/index.d.ts.map +1 -1
- package/dist/views/List/index.js +56 -36
- package/dist/views/List/index.js.map +1 -1
- package/dist/views/List/meta.d.ts.map +1 -1
- package/dist/views/List/meta.js +4 -2
- package/dist/views/List/meta.js.map +1 -1
- package/dist/views/LivePreview/Context/context.d.ts +1 -1
- package/dist/views/LivePreview/Context/context.d.ts.map +1 -1
- package/dist/views/LivePreview/Context/context.js.map +1 -1
- package/dist/views/LivePreview/Context/index.js +9 -6
- package/dist/views/LivePreview/Context/index.js.map +1 -1
- package/dist/views/LivePreview/Device/index.js +5 -3
- package/dist/views/LivePreview/Device/index.js.map +1 -1
- package/dist/views/LivePreview/DeviceContainer/index.js +5 -3
- package/dist/views/LivePreview/DeviceContainer/index.js.map +1 -1
- package/dist/views/LivePreview/IFrame/index.js +2 -1
- package/dist/views/LivePreview/IFrame/index.js.map +1 -1
- package/dist/views/LivePreview/Preview/index.js +25 -14
- package/dist/views/LivePreview/Preview/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/Controls/index.js +105 -57
- package/dist/views/LivePreview/Toolbar/Controls/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/SizeInput/index.js +2 -1
- package/dist/views/LivePreview/Toolbar/SizeInput/index.js.map +1 -1
- package/dist/views/LivePreview/Toolbar/index.js +29 -14
- package/dist/views/LivePreview/Toolbar/index.js.map +1 -1
- package/dist/views/LivePreview/ToolbarArea/index.js +5 -3
- package/dist/views/LivePreview/ToolbarArea/index.js.map +1 -1
- package/dist/views/LivePreview/index.client.d.ts.map +1 -1
- package/dist/views/LivePreview/index.client.js +103 -80
- package/dist/views/LivePreview/index.client.js.map +1 -1
- package/dist/views/LivePreview/index.js +2 -1
- package/dist/views/LivePreview/index.js.map +1 -1
- package/dist/views/LivePreview/meta.d.ts.map +1 -1
- package/dist/views/LivePreview/meta.js +6 -22
- package/dist/views/LivePreview/meta.js.map +1 -1
- package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
- package/dist/views/Login/LoginForm/index.js +59 -50
- package/dist/views/Login/LoginForm/index.js.map +1 -1
- package/dist/views/Login/index.d.ts.map +1 -1
- package/dist/views/Login/index.js +50 -14
- package/dist/views/Login/index.js.map +1 -1
- package/dist/views/Login/meta.d.ts.map +1 -1
- package/dist/views/Login/meta.js +4 -5
- package/dist/views/Login/meta.js.map +1 -1
- package/dist/views/Logout/LogoutClient.js +21 -7
- package/dist/views/Logout/LogoutClient.js.map +1 -1
- package/dist/views/Logout/index.d.ts.map +1 -1
- package/dist/views/Logout/index.js +10 -11
- package/dist/views/Logout/index.js.map +1 -1
- package/dist/views/Logout/meta.d.ts.map +1 -1
- package/dist/views/Logout/meta.js +2 -4
- package/dist/views/Logout/meta.js.map +1 -1
- package/dist/views/NotFound/index.client.js +22 -10
- package/dist/views/NotFound/index.client.js.map +1 -1
- package/dist/views/NotFound/index.d.ts +1 -1
- package/dist/views/NotFound/index.d.ts.map +1 -1
- package/dist/views/NotFound/index.js +22 -9
- package/dist/views/NotFound/index.js.map +1 -1
- package/dist/views/NotFound/meta.d.ts.map +1 -1
- package/dist/views/NotFound/meta.js +2 -4
- package/dist/views/NotFound/meta.js.map +1 -1
- package/dist/views/ResetPassword/index.client.js +18 -11
- package/dist/views/ResetPassword/index.client.js.map +1 -1
- package/dist/views/ResetPassword/index.d.ts.map +1 -1
- package/dist/views/ResetPassword/index.js +47 -26
- package/dist/views/ResetPassword/index.js.map +1 -1
- package/dist/views/ResetPassword/meta.d.ts.map +1 -1
- package/dist/views/ResetPassword/meta.js +4 -5
- package/dist/views/ResetPassword/meta.js.map +1 -1
- package/dist/views/Root/getViewFromConfig.d.ts.map +1 -1
- package/dist/views/Root/getViewFromConfig.js +29 -12
- package/dist/views/Root/getViewFromConfig.js.map +1 -1
- package/dist/views/Root/index.d.ts +1 -0
- package/dist/views/Root/index.d.ts.map +1 -1
- package/dist/views/Root/index.js +41 -15
- package/dist/views/Root/index.js.map +1 -1
- package/dist/views/Root/meta.d.ts.map +1 -1
- package/dist/views/Root/meta.js +0 -19
- package/dist/views/Root/meta.js.map +1 -1
- package/dist/views/Unauthorized/index.d.ts.map +1 -1
- package/dist/views/Unauthorized/index.js +20 -9
- package/dist/views/Unauthorized/index.js.map +1 -1
- package/dist/views/Unauthorized/meta.d.ts.map +1 -1
- package/dist/views/Unauthorized/meta.js +4 -5
- package/dist/views/Unauthorized/meta.js.map +1 -1
- package/dist/views/Verify/index.d.ts.map +1 -1
- package/dist/views/Verify/index.js +23 -8
- package/dist/views/Verify/index.js.map +1 -1
- package/dist/views/Verify/meta.d.ts.map +1 -1
- package/dist/views/Verify/meta.js +4 -5
- package/dist/views/Verify/meta.js.map +1 -1
- package/dist/views/Version/Default/index.js +83 -57
- package/dist/views/Version/Default/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/Label/index.js +5 -3
- package/dist/views/Version/RenderFieldsToDiff/Label/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js +65 -50
- package/dist/views/Version/RenderFieldsToDiff/fields/Iterable/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js +30 -18
- package/dist/views/Version/RenderFieldsToDiff/fields/Nested/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js +23 -12
- package/dist/views/Version/RenderFieldsToDiff/fields/Relationship/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js +2 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/DiffViewer/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js +22 -11
- package/dist/views/Version/RenderFieldsToDiff/fields/Select/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js +31 -30
- package/dist/views/Version/RenderFieldsToDiff/fields/Tabs/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js +2 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/DiffViewer/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js +22 -11
- package/dist/views/Version/RenderFieldsToDiff/fields/Text/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts +0 -2
- package/dist/views/Version/RenderFieldsToDiff/fields/index.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts +2 -2
- package/dist/views/Version/RenderFieldsToDiff/fields/types.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/fields/types.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/index.js +90 -87
- package/dist/views/Version/RenderFieldsToDiff/index.js.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/types.d.ts +2 -2
- package/dist/views/Version/RenderFieldsToDiff/types.d.ts.map +1 -1
- package/dist/views/Version/RenderFieldsToDiff/types.js.map +1 -1
- package/dist/views/Version/Restore/index.js +38 -18
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Version/SelectComparison/index.js +32 -24
- package/dist/views/Version/SelectComparison/index.js.map +1 -1
- package/dist/views/Version/SelectLocales/index.d.ts.map +1 -1
- package/dist/views/Version/SelectLocales/index.js +18 -11
- package/dist/views/Version/SelectLocales/index.js.map +1 -1
- package/dist/views/Version/index.js +2 -1
- package/dist/views/Version/index.js.map +1 -1
- package/dist/views/Version/meta.d.ts.map +1 -1
- package/dist/views/Version/meta.js +5 -2
- package/dist/views/Version/meta.js.map +1 -1
- package/dist/views/Versions/buildColumns.js +7 -6
- package/dist/views/Versions/buildColumns.js.map +1 -1
- package/dist/views/Versions/cells/AutosaveCell/index.js +25 -3
- package/dist/views/Versions/cells/AutosaveCell/index.js.map +1 -1
- package/dist/views/Versions/cells/CreatedAt/index.js +9 -7
- package/dist/views/Versions/cells/CreatedAt/index.js.map +1 -1
- package/dist/views/Versions/cells/ID/index.js +4 -1
- package/dist/views/Versions/cells/ID/index.js.map +1 -1
- package/dist/views/Versions/index.client.js +61 -29
- package/dist/views/Versions/index.client.js.map +1 -1
- package/dist/views/Versions/index.js +31 -22
- package/dist/views/Versions/index.js.map +1 -1
- package/dist/views/Versions/meta.d.ts.map +1 -1
- package/dist/views/Versions/meta.js +8 -4
- package/dist/views/Versions/meta.js.map +1 -1
- package/dist/withPayload.d.ts.map +1 -1
- package/dist/withPayload.js +36 -10
- package/dist/withPayload.js.map +1 -1
- package/package.json +15 -11
- package/dist/utilities/buildFieldSchemaMap/index.d.ts +0 -4
- package/dist/utilities/buildFieldSchemaMap/index.d.ts.map +0 -1
- package/dist/utilities/buildFieldSchemaMap/index.js +0 -28
- package/dist/utilities/buildFieldSchemaMap/index.js.map +0 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts +0 -14
- package/dist/utilities/buildFieldSchemaMap/traverseFields.d.ts.map +0 -1
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js +0 -75
- package/dist/utilities/buildFieldSchemaMap/traverseFields.js.map +0 -1
- package/dist/utilities/buildFieldSchemaMap/types.d.ts +0 -3
- package/dist/utilities/buildFieldSchemaMap/types.d.ts.map +0 -1
- package/dist/utilities/buildFieldSchemaMap/types.js +0 -3
- package/dist/utilities/buildFieldSchemaMap/types.js.map +0 -1
- package/dist/utilities/getDataAndFile.d.ts +0 -12
- package/dist/utilities/getDataAndFile.d.ts.map +0 -1
- package/dist/utilities/getDataAndFile.js +0 -48
- package/dist/utilities/getDataAndFile.js.map +0 -1
- package/dist/views/Dashboard/Default/index.client.d.ts +0 -10
- package/dist/views/Dashboard/Default/index.client.d.ts.map +0 -1
- package/dist/views/Dashboard/Default/index.client.js +0 -103
- package/dist/views/Dashboard/Default/index.client.js.map +0 -1
- /package/dist/prod/payload/{favicon.svg → payload-favicon.svg} +0 -0
- /package/dist/prod/payload/{og-image.png → static-og-image.png} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,eAAe,CAAA;AAsDvF,eAAO,MAAM,UAAU,WAAkB,QAAQ,eAAe,CAAC,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/routes/graphql/handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqC,eAAe,EAAE,MAAM,eAAe,CAAA;AAsDvF,eAAO,MAAM,UAAU,WAAkB,QAAQ,eAAe,CAAC,GAAG,eAAe,iBAyBlF,CAAA;AAED,eAAO,MAAM,IAAI,WACN,QAAQ,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBAyD9E,CAAA"}
|
|
@@ -51,11 +51,10 @@ export const getGraphql = async (config)=>{
|
|
|
51
51
|
return cached.graphql;
|
|
52
52
|
}
|
|
53
53
|
if (!cached.promise) {
|
|
54
|
-
|
|
55
|
-
cached.promise = new Promise(
|
|
56
|
-
const resolvedConfig = await config;
|
|
54
|
+
const resolvedConfig = await config;
|
|
55
|
+
cached.promise = new Promise((resolve)=>{
|
|
57
56
|
const schema = configToSchema(resolvedConfig);
|
|
58
|
-
resolve(schema);
|
|
57
|
+
resolve(cached.graphql || schema);
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
60
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLError, GraphQLFormattedError } from 'graphql'\nimport type { CollectionAfterErrorHook, Payload, SanitizedConfig } from 'payload/types'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport httpStatus from 'http-status'\n\nimport { addDataAndFileToRequest } from '../../utilities/addDataAndFileToRequest.js'\nimport { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest.js'\nimport { createPayloadRequest } from '../../utilities/createPayloadRequest.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nconst handleError = async (\n payload: Payload,\n err: any,\n debug: boolean,\n afterErrorHook: CollectionAfterErrorHook,\n // eslint-disable-next-line @typescript-eslint/require-await\n): Promise<GraphQLFormattedError> => {\n const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR\n let errorMessage = err.message\n payload.logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: GraphQLFormattedError = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && err.originalError.data) || undefined,\n stack: debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n if (afterErrorHook) {\n ;({ response } = afterErrorHook(err, response, null, null) || { response })\n }\n\n return response\n}\n\nlet cached = global._payload_graphql\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/graphql/handler.ts"],"sourcesContent":["import type { GraphQLError, GraphQLFormattedError } from 'graphql'\nimport type { CollectionAfterErrorHook, Payload, SanitizedConfig } from 'payload/types'\n\nimport { configToSchema } from '@payloadcms/graphql'\nimport { createHandler } from 'graphql-http/lib/use/fetch'\nimport httpStatus from 'http-status'\n\nimport { addDataAndFileToRequest } from '../../utilities/addDataAndFileToRequest.js'\nimport { addLocalesToRequestFromData } from '../../utilities/addLocalesToRequest.js'\nimport { createPayloadRequest } from '../../utilities/createPayloadRequest.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nconst handleError = async (\n payload: Payload,\n err: any,\n debug: boolean,\n afterErrorHook: CollectionAfterErrorHook,\n // eslint-disable-next-line @typescript-eslint/require-await\n): Promise<GraphQLFormattedError> => {\n const status = err.originalError.status || httpStatus.INTERNAL_SERVER_ERROR\n let errorMessage = err.message\n payload.logger.error(err.stack)\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n errorMessage = 'Something went wrong.'\n }\n\n let response: GraphQLFormattedError = {\n extensions: {\n name: err?.originalError?.name || undefined,\n data: (err && err.originalError && err.originalError.data) || undefined,\n stack: debug ? err.stack : undefined,\n statusCode: status,\n },\n locations: err.locations,\n message: errorMessage,\n path: err.path,\n }\n\n if (afterErrorHook) {\n ;({ response } = afterErrorHook(err, response, null, null) || { response })\n }\n\n return response\n}\n\nlet cached = global._payload_graphql\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_graphql = { graphql: null, promise: null }\n}\n\nexport const getGraphql = async (config: Promise<SanitizedConfig> | SanitizedConfig) => {\n if (process.env.NODE_ENV === 'development') {\n cached = global._payload_graphql = { graphql: null, promise: null }\n }\n\n if (cached.graphql) {\n return cached.graphql\n }\n\n if (!cached.promise) {\n const resolvedConfig = await config\n cached.promise = new Promise((resolve) => {\n const schema = configToSchema(resolvedConfig)\n resolve(cached.graphql || schema)\n })\n }\n\n try {\n cached.graphql = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.graphql\n}\n\nexport const POST =\n (config: Promise<SanitizedConfig> | SanitizedConfig) => async (request: Request) => {\n const originalRequest = request.clone()\n const basePayloadRequest = await createPayloadRequest({\n config,\n request,\n })\n\n const reqWithData = await addDataAndFileToRequest({ request: basePayloadRequest })\n const payloadRequest = addLocalesToRequestFromData({ request: reqWithData })\n\n const { schema, validationRules } = await getGraphql(config)\n\n const { payload } = payloadRequest\n\n const afterErrorHook =\n typeof payload.config.hooks.afterError === 'function' ? payload.config.hooks.afterError : null\n\n const headers = {}\n const apiResponse = await createHandler({\n context: { headers, req: payloadRequest },\n onOperation: async (request, args, result) => {\n const response =\n typeof payload.extensions === 'function'\n ? await payload.extensions({\n args,\n req: request,\n result,\n })\n : result\n if (response.errors) {\n const errors = (await Promise.all(\n result.errors.map((error) => {\n return handleError(payload, error, payload.config.debug, afterErrorHook)\n }),\n )) as GraphQLError[]\n // errors type should be FormattedGraphQLError[] but onOperation has a return type of ExecutionResult instead of FormattedExecutionResult\n return { ...response, errors }\n }\n return response\n },\n schema,\n validationRules: (request, args, defaultRules) => defaultRules.concat(validationRules(args)),\n })(originalRequest)\n\n const resHeaders = headersWithCors({\n headers: new Headers(apiResponse.headers),\n req: payloadRequest,\n })\n\n for (const key in headers) {\n resHeaders.append(key, headers[key])\n }\n\n return new Response(apiResponse.body, {\n headers: resHeaders,\n status: apiResponse.status,\n })\n }\n"],"names":["configToSchema","createHandler","httpStatus","addDataAndFileToRequest","addLocalesToRequestFromData","createPayloadRequest","headersWithCors","handleError","payload","err","debug","afterErrorHook","status","originalError","INTERNAL_SERVER_ERROR","errorMessage","message","logger","error","stack","response","extensions","name","undefined","data","statusCode","locations","path","cached","global","_payload_graphql","graphql","promise","getGraphql","config","process","env","NODE_ENV","resolvedConfig","Promise","resolve","schema","e","POST","request","originalRequest","clone","basePayloadRequest","reqWithData","payloadRequest","validationRules","hooks","afterError","headers","apiResponse","context","req","onOperation","args","result","errors","all","map","defaultRules","concat","resHeaders","Headers","key","append","Response","body"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,cAAc,QAA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,EAAE;oBACnB,MAAMA,SAAU,MAAMrB,QAAQsB,GAAG,CAC/BF,OAAOC,MAAM,CAACE,GAAG,CAAC,CAAC5C;wBACjB,OAAOX,YAAYC,SAASU,OAAOV,QAAQ0B,MAAM,CAACxB,KAAK,EAAEC;oBAC3D;oBAEF,yIAAyI;oBACzI,OAAO;wBAAE,GAAGS,QAAQ;wBAAEwC;oBAAO;gBAC/B;gBACA,OAAOxC;YACT;YACAqB;YACAS,iBAAiB,CAACN,SAASc,MAAMK,eAAiBA,aAAaC,MAAM,CAACd,gBAAgBQ;QACxF,GAAGb;QAEH,MAAMoB,aAAa3D,gBAAgB;YACjC+C,SAAS,IAAIa,QAAQZ,YAAYD,OAAO;YACxCG,KAAKP;QACP;QAEA,IAAK,MAAMkB,OAAOd,QAAS;YACzBY,WAAWG,MAAM,CAACD,KAAKd,OAAO,CAACc,IAAI;QACrC;QAEA,OAAO,IAAIE,SAASf,YAAYgB,IAAI,EAAE;YACpCjB,SAASY;YACTrD,QAAQ0C,YAAY1C,MAAM;QAC5B;IACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/access.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAInD,eAAO,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/auth/access.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAInD,eAAO,MAAM,MAAM,EAAE,gBA0BpB,CAAA"}
|
|
@@ -2,16 +2,26 @@ import httpStatus from 'http-status';
|
|
|
2
2
|
import { accessOperation } from 'payload/operations';
|
|
3
3
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
4
4
|
export const access = async ({ req })=>{
|
|
5
|
-
const
|
|
5
|
+
const headers = headersWithCors({
|
|
6
|
+
headers: new Headers(),
|
|
6
7
|
req
|
|
7
8
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
headers: new Headers(),
|
|
9
|
+
try {
|
|
10
|
+
const results = await accessOperation({
|
|
11
11
|
req
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
});
|
|
13
|
+
return Response.json(results, {
|
|
14
|
+
headers,
|
|
15
|
+
status: httpStatus.OK
|
|
16
|
+
});
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return Response.json({
|
|
19
|
+
error: e
|
|
20
|
+
}, {
|
|
21
|
+
headers,
|
|
22
|
+
status: httpStatus.INTERNAL_SERVER_ERROR
|
|
23
|
+
});
|
|
24
|
+
}
|
|
15
25
|
};
|
|
16
26
|
|
|
17
27
|
//# sourceMappingURL=access.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/auth/access.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { accessOperation } from 'payload/operations'\n\nimport type { BaseRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const access: BaseRouteHandler = async ({ req }) => {\n const results = await accessOperation({\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/auth/access.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { accessOperation } from 'payload/operations'\n\nimport type { BaseRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const access: BaseRouteHandler = async ({ req }) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const results = await accessOperation({\n req,\n })\n\n return Response.json(results, {\n headers,\n status: httpStatus.OK,\n })\n } catch (e: unknown) {\n return Response.json(\n {\n error: e,\n },\n {\n headers,\n status: httpStatus.INTERNAL_SERVER_ERROR,\n },\n )\n }\n}\n"],"names":["httpStatus","accessOperation","headersWithCors","access","req","headers","Headers","results","Response","json","status","OK","e","error","INTERNAL_SERVER_ERROR"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AAIpD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAA2B,OAAO,EAAEC,GAAG,EAAE;IACpD,MAAMC,UAAUH,gBAAgB;QAC9BG,SAAS,IAAIC;QACbF;IACF;IAEA,IAAI;QACF,MAAMG,UAAU,MAAMN,gBAAgB;YACpCG;QACF;QAEA,OAAOI,SAASC,IAAI,CAACF,SAAS;YAC5BF;YACAK,QAAQV,WAAWW,EAAE;QACvB;IACF,EAAE,OAAOC,GAAY;QACnB,OAAOJ,SAASC,IAAI,CAClB;YACEI,OAAOD;QACT,GACA;YACEP;YACAK,QAAQV,WAAWc,qBAAqB;QAC1C;IAEJ;AACF,EAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { PayloadRequestWithData } from 'payload/types';
|
|
2
|
-
import type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.js';
|
|
3
|
-
export declare const getFieldSchemaMap: (req: PayloadRequestWithData) => FieldSchemaMap;
|
|
4
2
|
export declare const buildFormState: ({ req }: {
|
|
5
3
|
req: PayloadRequestWithData;
|
|
6
4
|
}) => Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/buildFormState.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildFormState.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/buildFormState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAQ3D,eAAO,MAAM,cAAc,YAAmB;IAAE,GAAG,EAAE,sBAAsB,CAAA;CAAE,sBAyC5E,CAAA"}
|
|
@@ -1,185 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues';
|
|
1
|
+
import { buildFormState as buildFormStateFn } from '@payloadcms/ui/utilities/buildFormState';
|
|
3
2
|
import httpStatus from 'http-status';
|
|
4
|
-
import { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js';
|
|
5
3
|
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
6
4
|
import { routeError } from './routeError.js';
|
|
7
|
-
let cached = global._payload_fieldSchemaMap;
|
|
8
|
-
if (!cached) {
|
|
9
|
-
// eslint-disable-next-line no-multi-assign
|
|
10
|
-
cached = global._payload_fieldSchemaMap = null;
|
|
11
|
-
}
|
|
12
|
-
export const getFieldSchemaMap = (req)=>{
|
|
13
|
-
if (cached && process.env.NODE_ENV !== 'development') {
|
|
14
|
-
return cached;
|
|
15
|
-
}
|
|
16
|
-
cached = buildFieldSchemaMap(req);
|
|
17
|
-
return cached;
|
|
18
|
-
};
|
|
19
5
|
export const buildFormState = async ({ req })=>{
|
|
20
6
|
const headers = headersWithCors({
|
|
21
7
|
headers: new Headers(),
|
|
22
8
|
req
|
|
23
9
|
});
|
|
24
10
|
try {
|
|
25
|
-
const
|
|
26
|
-
const { collectionSlug, formState, globalSlug, locale, operation, schemaPath } = reqData;
|
|
27
|
-
const incomingUserSlug = req.user?.collection;
|
|
28
|
-
const adminUserSlug = req.payload.config.admin.user;
|
|
29
|
-
// If we have a user slug, test it against the functions
|
|
30
|
-
if (incomingUserSlug) {
|
|
31
|
-
const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin;
|
|
32
|
-
// Run the admin access function from the config if it exists
|
|
33
|
-
if (adminAccessFunction) {
|
|
34
|
-
const canAccessAdmin = await adminAccessFunction({
|
|
35
|
-
req
|
|
36
|
-
});
|
|
37
|
-
if (!canAccessAdmin) {
|
|
38
|
-
return Response.json(null, {
|
|
39
|
-
headers,
|
|
40
|
-
status: httpStatus.UNAUTHORIZED
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
// Match the user collection to the global admin config
|
|
44
|
-
} else if (adminUserSlug !== incomingUserSlug) {
|
|
45
|
-
return Response.json(null, {
|
|
46
|
-
headers,
|
|
47
|
-
status: httpStatus.UNAUTHORIZED
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
const hasUsers = await req.payload.find({
|
|
52
|
-
collection: adminUserSlug,
|
|
53
|
-
depth: 0,
|
|
54
|
-
limit: 1,
|
|
55
|
-
pagination: false
|
|
56
|
-
});
|
|
57
|
-
// If there are users, we should not allow access because of /create-first-user
|
|
58
|
-
if (hasUsers.docs.length) {
|
|
59
|
-
return Response.json(null, {
|
|
60
|
-
headers,
|
|
61
|
-
status: httpStatus.UNAUTHORIZED
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const fieldSchemaMap = getFieldSchemaMap(req);
|
|
66
|
-
const id = collectionSlug ? reqData.id : undefined;
|
|
67
|
-
const schemaPathSegments = schemaPath.split('.');
|
|
68
|
-
let fieldSchema;
|
|
69
|
-
if (schemaPathSegments.length === 1) {
|
|
70
|
-
if (req.payload.collections[schemaPath]) {
|
|
71
|
-
fieldSchema = req.payload.collections[schemaPath].config.fields;
|
|
72
|
-
} else {
|
|
73
|
-
fieldSchema = req.payload.config.globals.find((global1)=>global1.slug === schemaPath)?.fields;
|
|
74
|
-
}
|
|
75
|
-
} else if (fieldSchemaMap.has(schemaPath)) {
|
|
76
|
-
fieldSchema = fieldSchemaMap.get(schemaPath);
|
|
77
|
-
}
|
|
78
|
-
if (!fieldSchema) {
|
|
79
|
-
return Response.json({
|
|
80
|
-
message: 'Could not find field schema for given path'
|
|
81
|
-
}, {
|
|
82
|
-
headers,
|
|
83
|
-
status: httpStatus.BAD_REQUEST
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
let docPreferences = reqData.docPreferences;
|
|
87
|
-
let data = reqData.data;
|
|
88
|
-
const promises = {};
|
|
89
|
-
// If the request does not include doc preferences,
|
|
90
|
-
// we should fetch them. This is useful for DocumentInfoProvider
|
|
91
|
-
// as it reduces the amount of client-side fetches necessary
|
|
92
|
-
// when we fetch data for the Edit view
|
|
93
|
-
if (!docPreferences) {
|
|
94
|
-
let preferencesKey;
|
|
95
|
-
if (collectionSlug && id) {
|
|
96
|
-
preferencesKey = `collection-${collectionSlug}-${id}`;
|
|
97
|
-
}
|
|
98
|
-
if (globalSlug) {
|
|
99
|
-
preferencesKey = `global-${globalSlug}`;
|
|
100
|
-
}
|
|
101
|
-
if (preferencesKey) {
|
|
102
|
-
const fetchPreferences = async ()=>{
|
|
103
|
-
const preferencesResult = await req.payload.find({
|
|
104
|
-
collection: 'payload-preferences',
|
|
105
|
-
depth: 0,
|
|
106
|
-
limit: 1,
|
|
107
|
-
where: {
|
|
108
|
-
key: {
|
|
109
|
-
equals: preferencesKey
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
if (preferencesResult?.docs?.[0]?.value) docPreferences = preferencesResult.docs[0].value;
|
|
114
|
-
};
|
|
115
|
-
promises.preferences = fetchPreferences();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// If there is a form state,
|
|
119
|
-
// then we can deduce data from that form state
|
|
120
|
-
if (formState) data = reduceFieldsToValues(formState, true);
|
|
121
|
-
// If we do not have data at this point,
|
|
122
|
-
// we can fetch it. This is useful for DocumentInfoProvider
|
|
123
|
-
// to reduce the amount of fetches required
|
|
124
|
-
if (!data) {
|
|
125
|
-
const fetchData = async ()=>{
|
|
126
|
-
let resolvedData;
|
|
127
|
-
if (collectionSlug && id) {
|
|
128
|
-
resolvedData = await req.payload.findByID({
|
|
129
|
-
id,
|
|
130
|
-
collection: collectionSlug,
|
|
131
|
-
depth: 0,
|
|
132
|
-
draft: true,
|
|
133
|
-
fallbackLocale: null,
|
|
134
|
-
locale,
|
|
135
|
-
overrideAccess: false,
|
|
136
|
-
user: req.user
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
if (globalSlug && schemaPath === globalSlug) {
|
|
140
|
-
resolvedData = await req.payload.findGlobal({
|
|
141
|
-
slug: globalSlug,
|
|
142
|
-
depth: 0,
|
|
143
|
-
draft: true,
|
|
144
|
-
fallbackLocale: null,
|
|
145
|
-
locale,
|
|
146
|
-
overrideAccess: false,
|
|
147
|
-
user: req.user
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
data = resolvedData;
|
|
151
|
-
};
|
|
152
|
-
promises.data = fetchData();
|
|
153
|
-
}
|
|
154
|
-
if (Object.keys(promises).length > 0) {
|
|
155
|
-
await Promise.all(Object.values(promises));
|
|
156
|
-
}
|
|
157
|
-
const result = await buildStateFromSchema({
|
|
158
|
-
id,
|
|
159
|
-
data,
|
|
160
|
-
fieldSchema,
|
|
161
|
-
operation,
|
|
162
|
-
preferences: docPreferences || {
|
|
163
|
-
fields: {}
|
|
164
|
-
},
|
|
11
|
+
const result = await buildFormStateFn({
|
|
165
12
|
req
|
|
166
13
|
});
|
|
167
|
-
// Maintain form state of auth / upload fields
|
|
168
|
-
if (collectionSlug && formState) {
|
|
169
|
-
if (req.payload.collections[collectionSlug]?.config?.upload && formState.file) {
|
|
170
|
-
result.file = formState.file;
|
|
171
|
-
}
|
|
172
|
-
if (req.payload.collections[collectionSlug]?.config?.auth && !req.payload.collections[collectionSlug].config.auth.disableLocalStrategy) {
|
|
173
|
-
if (formState.password) result.password = formState.password;
|
|
174
|
-
if (formState['confirm-password']) result['confirm-password'] = formState['confirm-password'];
|
|
175
|
-
if (formState.email) result.email = formState.email;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
14
|
return Response.json(result, {
|
|
179
15
|
headers,
|
|
180
16
|
status: httpStatus.OK
|
|
181
17
|
});
|
|
182
18
|
} catch (err) {
|
|
19
|
+
if (err.message === 'Could not find field schema for given path') {
|
|
20
|
+
return Response.json({
|
|
21
|
+
message: err.message
|
|
22
|
+
}, {
|
|
23
|
+
headers,
|
|
24
|
+
status: httpStatus.BAD_REQUEST
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (err.message === 'Unauthorized') {
|
|
28
|
+
return Response.json(null, {
|
|
29
|
+
headers,
|
|
30
|
+
status: httpStatus.UNAUTHORIZED
|
|
31
|
+
});
|
|
32
|
+
}
|
|
183
33
|
req.payload.logger.error({
|
|
184
34
|
err,
|
|
185
35
|
msg: `There was an error building form state`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/routes/rest/buildFormState.ts"],"sourcesContent":["import type { BuildFormStateArgs } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport type { DocumentPreferences, Field, PayloadRequestWithData, TypeWithID } from 'payload/types'\n\nimport { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\nimport { reduceFieldsToValues } from '@payloadcms/ui/utilities/reduceFieldsToValues'\nimport httpStatus from 'http-status'\n\nimport type { FieldSchemaMap } from '../../utilities/buildFieldSchemaMap/types.js'\n\nimport { buildFieldSchemaMap } from '../../utilities/buildFieldSchemaMap/index.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { routeError } from './routeError.js'\n\nlet cached = global._payload_fieldSchemaMap\n\nif (!cached) {\n // eslint-disable-next-line no-multi-assign\n cached = global._payload_fieldSchemaMap = null\n}\n\nexport const getFieldSchemaMap = (req: PayloadRequestWithData): FieldSchemaMap => {\n if (cached && process.env.NODE_ENV !== 'development') {\n return cached\n }\n\n cached = buildFieldSchemaMap(req)\n\n return cached\n}\n\nexport const buildFormState = async ({ req }: { req: PayloadRequestWithData }) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const reqData: BuildFormStateArgs = req.data as BuildFormStateArgs\n const { collectionSlug, formState, globalSlug, locale, operation, schemaPath } = reqData\n\n const incomingUserSlug = req.user?.collection\n const adminUserSlug = req.payload.config.admin.user\n\n // If we have a user slug, test it against the functions\n if (incomingUserSlug) {\n const adminAccessFunction = req.payload.collections[incomingUserSlug].config.access?.admin\n\n // Run the admin access function from the config if it exists\n if (adminAccessFunction) {\n const canAccessAdmin = await adminAccessFunction({ req })\n\n if (!canAccessAdmin) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n // Match the user collection to the global admin config\n } else if (adminUserSlug !== incomingUserSlug) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n } else {\n const hasUsers = await req.payload.find({\n collection: adminUserSlug,\n depth: 0,\n limit: 1,\n pagination: false,\n })\n // If there are users, we should not allow access because of /create-first-user\n if (hasUsers.docs.length) {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n }\n\n const fieldSchemaMap = getFieldSchemaMap(req)\n\n const id = collectionSlug ? reqData.id : undefined\n const schemaPathSegments = schemaPath.split('.')\n\n let fieldSchema: Field[]\n\n if (schemaPathSegments.length === 1) {\n if (req.payload.collections[schemaPath]) {\n fieldSchema = req.payload.collections[schemaPath].config.fields\n } else {\n fieldSchema = req.payload.config.globals.find(\n (global) => global.slug === schemaPath,\n )?.fields\n }\n } else if (fieldSchemaMap.has(schemaPath)) {\n fieldSchema = fieldSchemaMap.get(schemaPath)\n }\n\n if (!fieldSchema) {\n return Response.json(\n {\n message: 'Could not find field schema for given path',\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n let docPreferences = reqData.docPreferences\n let data = reqData.data\n\n const promises: {\n data?: Promise<void>\n preferences?: Promise<void>\n } = {}\n\n // If the request does not include doc preferences,\n // we should fetch them. This is useful for DocumentInfoProvider\n // as it reduces the amount of client-side fetches necessary\n // when we fetch data for the Edit view\n if (!docPreferences) {\n let preferencesKey\n\n if (collectionSlug && id) {\n preferencesKey = `collection-${collectionSlug}-${id}`\n }\n\n if (globalSlug) {\n preferencesKey = `global-${globalSlug}`\n }\n\n if (preferencesKey) {\n const fetchPreferences = async () => {\n const preferencesResult = (await req.payload.find({\n collection: 'payload-preferences',\n depth: 0,\n limit: 1,\n where: {\n key: {\n equals: preferencesKey,\n },\n },\n })) as unknown as { docs: { value: DocumentPreferences }[] }\n\n if (preferencesResult?.docs?.[0]?.value) docPreferences = preferencesResult.docs[0].value\n }\n\n promises.preferences = fetchPreferences()\n }\n }\n\n // If there is a form state,\n // then we can deduce data from that form state\n if (formState) data = reduceFieldsToValues(formState, true)\n\n // If we do not have data at this point,\n // we can fetch it. This is useful for DocumentInfoProvider\n // to reduce the amount of fetches required\n if (!data) {\n const fetchData = async () => {\n let resolvedData: TypeWithID\n\n if (collectionSlug && id) {\n resolvedData = await req.payload.findByID({\n id,\n collection: collectionSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n if (globalSlug && schemaPath === globalSlug) {\n resolvedData = await req.payload.findGlobal({\n slug: globalSlug,\n depth: 0,\n draft: true,\n fallbackLocale: null,\n locale,\n overrideAccess: false,\n user: req.user,\n })\n }\n\n data = resolvedData\n }\n\n promises.data = fetchData()\n }\n\n if (Object.keys(promises).length > 0) {\n await Promise.all(Object.values(promises))\n }\n\n const result = await buildStateFromSchema({\n id,\n data,\n fieldSchema,\n operation,\n preferences: docPreferences || { fields: {} },\n req,\n })\n\n // Maintain form state of auth / upload fields\n if (collectionSlug && formState) {\n if (req.payload.collections[collectionSlug]?.config?.upload && formState.file) {\n result.file = formState.file\n }\n\n if (\n req.payload.collections[collectionSlug]?.config?.auth &&\n !req.payload.collections[collectionSlug].config.auth.disableLocalStrategy\n ) {\n if (formState.password) result.password = formState.password\n if (formState['confirm-password'])\n result['confirm-password'] = formState['confirm-password']\n if (formState.email) result.email = formState.email\n }\n }\n\n return Response.json(result, {\n headers,\n status: httpStatus.OK,\n })\n } catch (err) {\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n return routeError({\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"names":["buildStateFromSchema","reduceFieldsToValues","httpStatus","buildFieldSchemaMap","headersWithCors","routeError","cached","global","_payload_fieldSchemaMap","getFieldSchemaMap","req","process","env","NODE_ENV","buildFormState","headers","Headers","reqData","data","collectionSlug","formState","globalSlug","locale","operation","schemaPath","incomingUserSlug","user","collection","adminUserSlug","payload","config","admin","adminAccessFunction","collections","access","canAccessAdmin","Response","json","status","UNAUTHORIZED","hasUsers","find","depth","limit","pagination","docs","length","fieldSchemaMap","id","undefined","schemaPathSegments","split","fieldSchema","fields","globals","slug","has","get","message","BAD_REQUEST","docPreferences","promises","preferencesKey","fetchPreferences","preferencesResult","where","key","equals","value","preferences","fetchData","resolvedData","findByID","draft","fallbackLocale","overrideAccess","findGlobal","Object","keys","Promise","all","values","result","upload","file","auth","disableLocalStrategy","password","email","OK","err","logger","error","msg"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,oBAAoB,QAAQ,4CAA2C;AAChF,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,OAAOC,gBAAgB,cAAa;AAIpC,SAASC,mBAAmB,QAAQ,+CAA8C;AAClF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,IAAIC,SAASC,OAAOC,uBAAuB;AAE3C,IAAI,CAACF,QAAQ;IACX,2CAA2C;IAC3CA,SAASC,OAAOC,uBAAuB,GAAG;AAC5C;AAEA,OAAO,MAAMC,oBAAoB,CAACC;IAChC,IAAIJ,UAAUK,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QACpD,OAAOP;IACT;IAEAA,SAASH,oBAAoBO;IAE7B,OAAOJ;AACT,EAAC;AAED,OAAO,MAAMQ,iBAAiB,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IAAI,GAAGhE,UAAUgE,IAAI;YAC9B;YAEA,IACE1E,IAAImB,OAAO,CAACI,WAAW,CAACd,eAAe,EAAEW,QAAQuD,QACjD,CAAC3E,IAAImB,OAAO,CAACI,WAAW,CAACd,eAAe,CAACW,MAAM,CAACuD,IAAI,CAACC,oBAAoB,EACzE;gBACA,IAAIlE,UAAUmE,QAAQ,EAAEL,OAAOK,QAAQ,GAAGnE,UAAUmE,QAAQ;gBAC5D,IAAInE,SAAS,CAAC,mBAAmB,EAC/B8D,MAAM,CAAC,mBAAmB,GAAG9D,SAAS,CAAC,mBAAmB;gBAC5D,IAAIA,UAAUoE,KAAK,EAAEN,OAAOM,KAAK,GAAGpE,UAAUoE,KAAK;YACrD;QACF;QAEA,OAAOpD,SAASC,IAAI,CAAC6C,QAAQ;YAC3BnE;YACAuB,QAAQpC,WAAWuF,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZhF,IAAImB,OAAO,CAAC8D,MAAM,CAACC,KAAK,CAAC;YAAEF;YAAKG,KAAK,CAAC,sCAAsC,CAAC;QAAC;QAE9E,OAAOxF,WAAW;YAChByB,QAAQpB,IAAImB,OAAO,CAACC,MAAM;YAC1B4D;YACAhF;QACF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/routes/rest/buildFormState.ts"],"sourcesContent":["import type { PayloadRequestWithData } from 'payload/types'\n\nimport { buildFormState as buildFormStateFn } from '@payloadcms/ui/utilities/buildFormState'\nimport httpStatus from 'http-status'\n\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { routeError } from './routeError.js'\n\nexport const buildFormState = async ({ req }: { req: PayloadRequestWithData }) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const result = await buildFormStateFn({ req })\n\n return Response.json(result, {\n headers,\n status: httpStatus.OK,\n })\n } catch (err) {\n if (err.message === 'Could not find field schema for given path') {\n return Response.json(\n {\n message: err.message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n if (err.message === 'Unauthorized') {\n return Response.json(null, {\n headers,\n status: httpStatus.UNAUTHORIZED,\n })\n }\n\n req.payload.logger.error({ err, msg: `There was an error building form state` })\n\n return routeError({\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"names":["buildFormState","buildFormStateFn","httpStatus","headersWithCors","routeError","req","headers","Headers","result","Response","json","status","OK","err","message","BAD_REQUEST","UNAUTHORIZED","payload","logger","error","msg","config"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,kBAAkBC,gBAAgB,QAAQ,0CAAyC;AAC5F,OAAOC,gBAAgB,cAAa;AAEpC,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,OAAO,MAAMJ,iBAAiB,OAAO,EAAEK,GAAG,EAAmC;IAC3E,MAAMC,UAAUH,gBAAgB;QAC9BG,SAAS,IAAIC;QACbF;IACF;IAEA,IAAI;QACF,MAAMG,SAAS,MAAMP,iBAAiB;YAAEI;QAAI;QAE5C,OAAOI,SAASC,IAAI,CAACF,QAAQ;YAC3BF;YACAK,QAAQT,WAAWU,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZ,IAAIA,IAAIC,OAAO,KAAK,8CAA8C;YAChE,OAAOL,SAASC,IAAI,CAClB;gBACEI,SAASD,IAAIC,OAAO;YACtB,GACA;gBACER;gBACAK,QAAQT,WAAWa,WAAW;YAChC;QAEJ;QAEA,IAAIF,IAAIC,OAAO,KAAK,gBAAgB;YAClC,OAAOL,SAASC,IAAI,CAAC,MAAM;gBACzBJ;gBACAK,QAAQT,WAAWc,YAAY;YACjC;QACF;QAEAX,IAAIY,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;YAAEN;YAAKO,KAAK,CAAC,sCAAsC,CAAC;QAAC;QAE9E,OAAOhB,WAAW;YAChBiB,QAAQhB,IAAIY,OAAO,CAACI,MAAM;YAC1BR;YACAR;QACF;IACF;AACF,EAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Collection, PayloadRequestWithData } from 'payload/types';
|
|
1
|
+
import type { Collection, PayloadRequestWithData, TypeWithID } from 'payload/types';
|
|
2
2
|
export declare function checkFileAccess({ collection, filename, req, }: {
|
|
3
3
|
collection: Collection;
|
|
4
4
|
filename: string;
|
|
5
5
|
req: PayloadRequestWithData;
|
|
6
|
-
}): Promise<Response>;
|
|
6
|
+
}): Promise<Response | TypeWithID>;
|
|
7
7
|
//# sourceMappingURL=checkFileAccess.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkFileAccess.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/files/checkFileAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAS,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"checkFileAccess.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/files/checkFileAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,EAAS,MAAM,eAAe,CAAA;AAO1F,wBAAsB,eAAe,CAAC,EACpC,UAAU,EACV,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,sBAAsB,CAAA;CAC5B,GAAG,OAAO,CAAC,QAAQ,GAAG,UAAU,CAAC,CA6CjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/files/checkFileAccess.ts"],"sourcesContent":["import type { Collection, PayloadRequestWithData, Where } from 'payload/types'\n\nimport { executeAccess } from 'payload/auth'\nimport { Forbidden } from 'payload/errors'\n\nimport { endpointsAreDisabled } from '../checkEndpoints.js'\n\nexport async function checkFileAccess({\n collection,\n filename,\n req,\n}: {\n collection: Collection\n filename: string\n req: PayloadRequestWithData\n}) {\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}\n"],"names":["executeAccess","Forbidden","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"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/files/checkFileAccess.ts"],"sourcesContent":["import type { Collection, PayloadRequestWithData, TypeWithID, Where } from 'payload/types'\n\nimport { executeAccess } from 'payload/auth'\nimport { Forbidden } from 'payload/errors'\n\nimport { endpointsAreDisabled } from '../checkEndpoints.js'\n\nexport async function checkFileAccess({\n collection,\n filename,\n req,\n}: {\n collection: Collection\n filename: string\n req: PayloadRequestWithData\n}): Promise<Response | TypeWithID> {\n const { config } = collection\n const disableEndpoints = endpointsAreDisabled({ endpoints: config.endpoints, request: req })\n if (disableEndpoints) return disableEndpoints\n\n const accessResult = await executeAccess({ isReadingStaticFile: true, req }, config.access.read)\n\n if (typeof accessResult === 'object') {\n const queryToBuild: Where = {\n and: [\n {\n or: [\n {\n filename: {\n equals: filename,\n },\n },\n ],\n },\n accessResult,\n ],\n }\n\n if (config.upload.imageSizes) {\n config.upload.imageSizes.forEach(({ name }) => {\n queryToBuild.and[0].or.push({\n [`sizes.${name}.filename`]: {\n equals: filename,\n },\n })\n })\n }\n\n const doc = await req.payload.db.findOne({\n collection: config.slug,\n req,\n where: queryToBuild,\n })\n\n if (!doc) {\n throw new Forbidden(req.t)\n }\n\n return doc\n }\n}\n"],"names":["executeAccess","Forbidden","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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,aAAa,QAAQ,eAAc;AAC5C,SAASC,SAAS,QAAQ,iBAAgB;AAE1C,SAASC,oBAAoB,QAAQ,uBAAsB;AAE3D,OAAO,eAAeC,gBAAgB,EACpCC,UAAU,EACVC,QAAQ,EACRC,GAAG,EAKJ;IACC,MAAM,EAAEC,MAAM,EAAE,GAAGH;IACnB,MAAMI,mBAAmBN,qBAAqB;QAAEO,WAAWF,OAAOE,SAAS;QAAEC,SAASJ;IAAI;IAC1F,IAAIE,kBAAkB,OAAOA;IAE7B,MAAMG,eAAe,MAAMX,cAAc;QAAEY,qBAAqB;QAAMN;IAAI,GAAGC,OAAOM,MAAM,CAACC,IAAI;IAE/F,IAAI,OAAOH,iBAAiB,UAAU;QACpC,MAAMI,eAAsB;YAC1BC,KAAK;gBACH;oBACEC,IAAI;wBACF;4BACEZ,UAAU;gCACRa,QAAQb;4BACV;wBACF;qBACD;gBACH;gBACAM;aACD;QACH;QAEA,IAAIJ,OAAOY,MAAM,CAACC,UAAU,EAAE;YAC5Bb,OAAOY,MAAM,CAACC,UAAU,CAACC,OAAO,CAAC,CAAC,EAAEC,IAAI,EAAE;gBACxCP,aAAaC,GAAG,CAAC,EAAE,CAACC,EAAE,CAACM,IAAI,CAAC;oBAC1B,CAAC,CAAC,MAAM,EAAED,KAAK,SAAS,CAAC,CAAC,EAAE;wBAC1BJ,QAAQb;oBACV;gBACF;YACF;QACF;QAEA,MAAMmB,MAAM,MAAMlB,IAAImB,OAAO,CAACC,EAAE,CAACC,OAAO,CAAC;YACvCvB,YAAYG,OAAOqB,IAAI;YACvBtB;YACAuB,OAAOd;QACT;QAEA,IAAI,CAACS,KAAK;YACR,MAAM,IAAIvB,UAAUK,IAAIwB,CAAC;QAC3B;QAEA,OAAON;IACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/files/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAevE,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,sBAAsB,CAAA;CAC5B,CAAA;AACD,eAAO,MAAM,OAAO,kCAAyC,IAAI,KAAG,QAAQ,QAAQ,
|
|
1
|
+
{"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/files/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAevE,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,sBAAsB,CAAA;CAC5B,CAAA;AACD,eAAO,MAAM,OAAO,kCAAyC,IAAI,KAAG,QAAQ,QAAQ,CA6DnF,CAAA"}
|
|
@@ -13,15 +13,17 @@ export const getFile = async ({ collection, filename, req })=>{
|
|
|
13
13
|
if (!collection.config.upload) {
|
|
14
14
|
throw new APIError(`This collection is not an upload collection: ${collection.config.slug}`, httpStatus.BAD_REQUEST);
|
|
15
15
|
}
|
|
16
|
-
await checkFileAccess({
|
|
16
|
+
const accessResult = await checkFileAccess({
|
|
17
17
|
collection,
|
|
18
18
|
filename,
|
|
19
19
|
req
|
|
20
20
|
});
|
|
21
|
+
if (accessResult instanceof Response) return accessResult;
|
|
21
22
|
let response = null;
|
|
22
23
|
if (collection.config.upload.handlers?.length) {
|
|
23
24
|
for (const handler of collection.config.upload.handlers){
|
|
24
25
|
response = await handler(req, {
|
|
26
|
+
doc: accessResult,
|
|
25
27
|
params: {
|
|
26
28
|
collection: collection.config.slug,
|
|
27
29
|
filename
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/routes/rest/files/getFile.ts"],"sourcesContent":["import type { Collection, PayloadRequestWithData } from 'payload/types'\n\nimport { fileTypeFromFile } from 'file-type'\nimport fsPromises from 'fs/promises'\nimport httpStatus from 'http-status'\nimport path from 'path'\nimport { APIError } from 'payload/errors'\n\nimport { streamFile } from '../../../fetchAPI-stream-file/index.js'\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\nimport { checkFileAccess } from './checkFileAccess.js'\nimport { getFileTypeFallback } from './getFileTypeFallback.js'\n\n// /:collectionSlug/file/:filename\ntype Args = {\n collection: Collection\n filename: string\n req: PayloadRequestWithData\n}\nexport const getFile = async ({ collection, filename, req }: Args): Promise<Response> => {\n try {\n if (!collection.config.upload) {\n throw new APIError(\n `This collection is not an upload collection: ${collection.config.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n await checkFileAccess({\n collection,\n filename,\n req,\n })\n\n let response: Response = null\n if (collection.config.upload.handlers?.length) {\n for (const handler of collection.config.upload.handlers) {\n response = await handler(req, {\n params: {\n collection: collection.config.slug,\n filename,\n },\n })\n }\n\n if (response instanceof Response) return response\n }\n\n const fileDir = collection.config.upload?.staticDir || collection.config.slug\n const filePath = path.resolve(`${fileDir}/${filename}`)\n\n const stats = await fsPromises.stat(filePath)\n\n const data = streamFile(filePath)\n\n const headers = new Headers({\n 'Content-Length': stats.size + '',\n })\n\n const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)\n headers.set('Content-Type', fileTypeResult.mime)\n\n return new Response(data, {\n headers: headersWithCors({\n headers,\n req,\n }),\n status: httpStatus.OK,\n })\n } catch (err) {\n return routeError({\n collection,\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"names":["fileTypeFromFile","fsPromises","httpStatus","path","APIError","streamFile","headersWithCors","routeError","checkFileAccess","getFileTypeFallback","getFile","collection","filename","req","config","upload","slug","BAD_REQUEST","response","handlers","length","handler","
|
|
1
|
+
{"version":3,"sources":["../../../../src/routes/rest/files/getFile.ts"],"sourcesContent":["import type { Collection, PayloadRequestWithData } from 'payload/types'\n\nimport { fileTypeFromFile } from 'file-type'\nimport fsPromises from 'fs/promises'\nimport httpStatus from 'http-status'\nimport path from 'path'\nimport { APIError } from 'payload/errors'\n\nimport { streamFile } from '../../../fetchAPI-stream-file/index.js'\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\nimport { checkFileAccess } from './checkFileAccess.js'\nimport { getFileTypeFallback } from './getFileTypeFallback.js'\n\n// /:collectionSlug/file/:filename\ntype Args = {\n collection: Collection\n filename: string\n req: PayloadRequestWithData\n}\nexport const getFile = async ({ collection, filename, req }: Args): Promise<Response> => {\n try {\n if (!collection.config.upload) {\n throw new APIError(\n `This collection is not an upload collection: ${collection.config.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n const accessResult = await checkFileAccess({\n collection,\n filename,\n req,\n })\n\n if (accessResult instanceof Response) return accessResult\n\n let response: Response = null\n if (collection.config.upload.handlers?.length) {\n for (const handler of collection.config.upload.handlers) {\n response = await handler(req, {\n doc: accessResult,\n params: {\n collection: collection.config.slug,\n filename,\n },\n })\n }\n\n if (response instanceof Response) return response\n }\n\n const fileDir = collection.config.upload?.staticDir || collection.config.slug\n const filePath = path.resolve(`${fileDir}/${filename}`)\n\n const stats = await fsPromises.stat(filePath)\n\n const data = streamFile(filePath)\n\n const headers = new Headers({\n 'Content-Length': stats.size + '',\n })\n\n const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)\n headers.set('Content-Type', fileTypeResult.mime)\n\n return new Response(data, {\n headers: headersWithCors({\n headers,\n req,\n }),\n status: httpStatus.OK,\n })\n } catch (err) {\n return routeError({\n collection,\n config: req.payload.config,\n err,\n req,\n })\n }\n}\n"],"names":["fileTypeFromFile","fsPromises","httpStatus","path","APIError","streamFile","headersWithCors","routeError","checkFileAccess","getFileTypeFallback","getFile","collection","filename","req","config","upload","slug","BAD_REQUEST","accessResult","Response","response","handlers","length","handler","doc","params","fileDir","staticDir","filePath","resolve","stats","stat","data","headers","Headers","size","fileTypeResult","set","mime","status","OK","err","payload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,gBAAgB,QAAQ,YAAW;AAC5C,OAAOC,gBAAgB,cAAa;AACpC,OAAOC,gBAAgB,cAAa;AACpC,OAAOC,UAAU,OAAM;AACvB,SAASC,QAAQ,QAAQ,iBAAgB;AAEzC,SAASC,UAAU,QAAQ,yCAAwC;AACnE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,UAAU,QAAQ,mBAAkB;AAC7C,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,mBAAmB,QAAQ,2BAA0B;AAQ9D,OAAO,MAAMC,UAAU,OAAO,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,GAAG,EAAQ;IAC/D,IAAI;QACF,IAAI,CAACF,WAAWG,MAAM,CAACC,MAAM,EAAE;YAC7B,MAAM,IAAIX,SACR,CAAC,6CAA6C,EAAEO,WAAWG,MAAM,CAACE,IAAI,CAAC,CAAC,EACxEd,WAAWe,WAAW;QAE1B;QAEA,MAAMC,eAAe,MAAMV,gBAAgB;YACzCG;YACAC;YACAC;QACF;QAEA,IAAIK,wBAAwBC,UAAU,OAAOD;QAE7C,IAAIE,WAAqB;QACzB,IAAIT,WAAWG,MAAM,CAACC,MAAM,CAACM,QAAQ,EAAEC,QAAQ;YAC7C,KAAK,MAAMC,WAAWZ,WAAWG,MAAM,CAACC,MAAM,CAACM,QAAQ,CAAE;gBACvDD,WAAW,MAAMG,QAAQV,KAAK;oBAC5BW,KAAKN;oBACLO,QAAQ;wBACNd,YAAYA,WAAWG,MAAM,CAACE,IAAI;wBAClCJ;oBACF;gBACF;YACF;YAEA,IAAIQ,oBAAoBD,UAAU,OAAOC;QAC3C;QAEA,MAAMM,UAAUf,WAAWG,MAAM,CAACC,MAAM,EAAEY,aAAahB,WAAWG,MAAM,CAACE,IAAI;QAC7E,MAAMY,WAAWzB,KAAK0B,OAAO,CAAC,CAAC,EAAEH,QAAQ,CAAC,EAAEd,SAAS,CAAC;QAEtD,MAAMkB,QAAQ,MAAM7B,WAAW8B,IAAI,CAACH;QAEpC,MAAMI,OAAO3B,WAAWuB;QAExB,MAAMK,UAAU,IAAIC,QAAQ;YAC1B,kBAAkBJ,MAAMK,IAAI,GAAG;QACjC;QAEA,MAAMC,iBAAiB,AAAC,MAAMpC,iBAAiB4B,aAAcnB,oBAAoBmB;QACjFK,QAAQI,GAAG,CAAC,gBAAgBD,eAAeE,IAAI;QAE/C,OAAO,IAAInB,SAASa,MAAM;YACxBC,SAAS3B,gBAAgB;gBACvB2B;gBACApB;YACF;YACA0B,QAAQrC,WAAWsC,EAAE;QACvB;IACF,EAAE,OAAOC,KAAK;QACZ,OAAOlC,WAAW;YAChBI;YACAG,QAAQD,IAAI6B,OAAO,CAAC5B,MAAM;YAC1B2B;YACA5B;QACF;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,eAAe,CAAA;AA2KtB,eAAO,MAAM,OAAO,WACT,QAAQ,eAAe,CAAC,GAAG,eAAe,eAAqB,OAAO,sBA0B9E,CAAA;AAEH,eAAO,MAAM,GAAG,WACL,QAAQ,eAAe,CAAC,GAAG,eAAe,eACnC,OAAO,wBAAwB;IAAE,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,sBA8K5E,CAAA;AAEH,eAAO,MAAM,IAAI,WACN,QAAQ,eAAe,CAAC,GAAG,eAAe,eACnC,OAAO,wBAAwB;IAAE,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,sBAgK5E,CAAA;AAEH,eAAO,MAAM,MAAM,WACR,QAAQ,eAAe,CAAC,GAAG,eAAe,eACnC,OAAO,wBAAwB;IAAE,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,sBA6E5E,CAAA;AAEH,eAAO,MAAM,KAAK,WACP,QAAQ,eAAe,CAAC,GAAG,eAAe,eACnC,OAAO,wBAAwB;IAAE,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,sBA8E5E,CAAA"}
|
|
@@ -39,6 +39,7 @@ import { findVersions as findVersionsGlobal } from './globals/findVersions.js';
|
|
|
39
39
|
import { preview as previewGlobal } from './globals/preview.js';
|
|
40
40
|
import { restoreVersion as restoreVersionGlobal } from './globals/restoreVersion.js';
|
|
41
41
|
import { update as updateGlobal } from './globals/update.js';
|
|
42
|
+
import { generateOGImage } from './og/index.js';
|
|
42
43
|
import { routeError } from './routeError.js';
|
|
43
44
|
const endpoints = {
|
|
44
45
|
collection: {
|
|
@@ -94,7 +95,8 @@ const endpoints = {
|
|
|
94
95
|
},
|
|
95
96
|
root: {
|
|
96
97
|
GET: {
|
|
97
|
-
access
|
|
98
|
+
access,
|
|
99
|
+
og: generateOGImage
|
|
98
100
|
},
|
|
99
101
|
POST: {
|
|
100
102
|
'form-state': buildFormState
|