studiocms 0.1.0-beta.7 → 0.1.0-beta.8
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/CHANGELOG.md +473 -0
- package/LICENSE +1 -1
- package/README.md +17 -10
- package/auth.d.ts +405 -0
- package/core.d.ts +225 -0
- package/custom-renderers/index.ts +4 -0
- package/custom-renderers/markdocRenderers/markdocReact-components/MarkDocReactRenderer.tsx +8 -0
- package/custom-renderers/markdocRenderers/markdocReact-components/MarkDocReactWrapper.astro +13 -0
- package/custom-renderers/markdocRenderers/markdocReact.ts +56 -0
- package/dist/cli/cmds/get-turso.d.ts +1 -0
- package/dist/cli/cmds/get-turso.js +10 -0
- package/dist/cli/cmds/init/index.d.ts +4 -0
- package/dist/cli/cmds/init/index.js +52 -0
- package/dist/cli/cmds/init/steps/data/studiocmsEnv.d.ts +3 -0
- package/dist/cli/cmds/init/steps/data/studiocmsEnv.js +71 -0
- package/dist/cli/cmds/init/steps/envBuilder.d.ts +21 -0
- package/dist/cli/cmds/init/steps/envBuilder.js +368 -0
- package/dist/cli/cmds/init/steps/nextSteps.d.ts +2 -0
- package/dist/cli/cmds/init/steps/nextSteps.js +38 -0
- package/dist/cli/cmds/init.d.ts +1 -0
- package/dist/cli/cmds/init.js +4 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +9 -0
- package/dist/cli/lib/commander.d.ts +39 -0
- package/dist/cli/lib/commander.js +87 -0
- package/dist/cli/lib/context.d.ts +28 -0
- package/dist/cli/lib/context.js +55 -0
- package/dist/cli/lib/pathUtil.d.ts +5 -0
- package/dist/cli/lib/pathUtil.js +14 -0
- package/dist/cli/lib/runExternal.d.ts +20 -0
- package/dist/cli/lib/runExternal.js +40 -0
- package/dist/cli/lib/seasonal.d.ts +5 -0
- package/dist/cli/lib/seasonal.js +88 -0
- package/dist/cli/lib/utils.d.ts +55 -0
- package/dist/cli/lib/utils.js +310 -0
- package/dist/cli/shared/intro.d.ts +2 -0
- package/dist/cli/shared/intro.js +24 -0
- package/dist/components/DefaultEditor.astro +138 -0
- package/dist/components/FormattedDate.astro +12 -0
- package/dist/components/Generator.astro +7 -0
- package/dist/components/Renderer.astro +13 -0
- package/dist/components/auth/OAuthButton.astro +21 -0
- package/dist/components/auth/OAuthButtonStack.astro +19 -0
- package/dist/components/auth/StaticAuthCheck.astro +20 -0
- package/dist/components/auth/StudioCMSLogoSVG.astro +13 -0
- package/dist/components/auth/oAuthButtonProviders.d.ts +8 -0
- package/dist/components/auth/oAuthButtonProviders.js +35 -0
- package/dist/components/dashboard/AstroCodeDiffsScript.astro +25 -0
- package/dist/components/dashboard/BaseHead.astro +41 -0
- package/dist/components/dashboard/Code.astro +23 -0
- package/dist/components/dashboard/DashboardPageHeader.astro +60 -0
- package/dist/components/dashboard/DoubleSidebar.astro +26 -0
- package/dist/components/dashboard/Footer.astro +16 -0
- package/dist/components/dashboard/MainSidebarContent.astro +124 -0
- package/dist/components/dashboard/PageHeader.astro +52 -0
- package/dist/components/dashboard/SidebarLink.astro +61 -0
- package/dist/components/dashboard/SidebarModals.astro +6 -0
- package/dist/components/dashboard/SidebarPluginLink.astro +45 -0
- package/dist/components/dashboard/SingleSidebar.astro +23 -0
- package/dist/components/dashboard/StudioCMSLogo.astro +12 -0
- package/dist/components/dashboard/ThemeManager.astro +53 -0
- package/dist/components/dashboard/component-scripts/TinyMDE.astro +6 -0
- package/dist/components/dashboard/component-scripts/dateTimeListener.d.ts +1 -0
- package/dist/components/dashboard/component-scripts/dateTimeListener.js +14 -0
- package/dist/components/dashboard/component-scripts/dateWithTimeAndZone.d.ts +1 -0
- package/dist/components/dashboard/component-scripts/dateWithTimeAndZone.js +12 -0
- package/dist/components/dashboard/component-scripts/makeClientRoutable.d.ts +1 -0
- package/dist/components/dashboard/component-scripts/makeClientRoutable.js +9 -0
- package/dist/components/dashboard/component-scripts/timeAgo.d.ts +1 -0
- package/dist/components/dashboard/component-scripts/timeAgo.js +21 -0
- package/dist/components/dashboard/islands/LoginChecker.astro +52 -0
- package/dist/components/dashboard/islands/configuration/ConfigForm.astro +272 -0
- package/dist/components/dashboard/islands/configuration/LightVsDark.astro +67 -0
- package/dist/components/dashboard/islands/content-mgmt/CreateFolder.astro +91 -0
- package/dist/components/dashboard/islands/content-mgmt/CreatePage.astro +332 -0
- package/dist/components/dashboard/islands/content-mgmt/EditFolder.astro +112 -0
- package/dist/components/dashboard/islands/content-mgmt/EditPage.astro +388 -0
- package/dist/components/dashboard/islands/content-mgmt/InnerSidebarElement.astro +230 -0
- package/dist/components/dashboard/islands/content-mgmt/PageHeader.astro +387 -0
- package/dist/components/dashboard/islands/content-mgmt/PageList.astro +49 -0
- package/dist/components/dashboard/islands/content-mgmt/PluginFields.astro +29 -0
- package/dist/components/dashboard/islands/content-mgmt/TreeRenderer.astro +75 -0
- package/dist/components/dashboard/islands/content-mgmt/TreeSidebarFolder.astro +53 -0
- package/dist/components/dashboard/islands/content-mgmt/TreeSidebarLink.astro +51 -0
- package/dist/components/dashboard/islands/content-mgmt/runtime.d.ts +10 -0
- package/dist/components/dashboard/islands/content-mgmt/runtime.js +33 -0
- package/dist/components/dashboard/islands/content-mgmt/shared.d.ts +27 -0
- package/dist/components/dashboard/islands/content-mgmt/shared.js +31 -0
- package/dist/components/dashboard/islands/dashboard/DashboardGrid.astro +39 -0
- package/dist/components/dashboard/islands/dashboard/DashboardGridItem.astro +34 -0
- package/dist/components/dashboard/islands/dashboard/Test.astro +5 -0
- package/dist/components/dashboard/islands/dashboard/UserName.astro +6 -0
- package/dist/components/dashboard/islands/dashboard/shared.d.ts +2 -0
- package/dist/components/dashboard/islands/dashboard/shared.js +0 -0
- package/dist/components/dashboard/islands/plugins/SettingsRenderer.astro +29 -0
- package/dist/components/dashboard/islands/profile/APITokens.astro +267 -0
- package/dist/components/dashboard/islands/profile/BasicInfo.astro +107 -0
- package/dist/components/dashboard/islands/profile/BasicInfoFallback.astro +43 -0
- package/dist/components/dashboard/islands/profile/SocialSignin.astro +151 -0
- package/dist/components/dashboard/islands/profile/SocialSigninFallback.astro +83 -0
- package/dist/components/dashboard/islands/profile/UpdatePassword.astro +137 -0
- package/dist/components/dashboard/islands/profile/UpdatePasswordFallback.astro +47 -0
- package/dist/components/dashboard/islands/profile/oAuthButtonProviders.d.ts +8 -0
- package/dist/components/dashboard/islands/profile/oAuthButtonProviders.js +35 -0
- package/dist/components/dashboard/islands/sidebar/Admin.astro +103 -0
- package/dist/components/dashboard/islands/sidebar/Editor.astro +18 -0
- package/dist/components/dashboard/islands/sidebar/UserAccount.astro +23 -0
- package/dist/components/dashboard/islands/sidebar/VersionCheck.astro +127 -0
- package/dist/components/dashboard/islands/sidebar/VersionCheckChangelog.astro +107 -0
- package/dist/components/dashboard/islands/user-mgmt/InnerSidebarElement.astro +298 -0
- package/dist/components/dashboard/islands/user-mgmt/RankCheck.astro +49 -0
- package/dist/components/dashboard/islands/user-mgmt/SocialSignin.astro +88 -0
- package/dist/components/dashboard/islands/user-mgmt/UserListItem.astro +60 -0
- package/dist/components/dashboard/sidebar-modals/UserManagementModals.astro +103 -0
- package/dist/components/dashboard/sidebar-modals/VersionModal.astro +267 -0
- package/dist/components/dashboard/sidebarConfig.d.ts +31 -0
- package/dist/components/dashboard/sidebarConfig.js +90 -0
- package/dist/components/default-grid-items/Recently-created-pages.astro +91 -0
- package/dist/components/default-grid-items/Recently-signed-up.astro +71 -0
- package/dist/components/default-grid-items/Recently-updated-pages.astro +96 -0
- package/dist/components/default-grid-items/Totals.astro +107 -0
- package/dist/components/default-grid-items/utils.d.ts +17 -0
- package/dist/components/default-grid-items/utils.js +26 -0
- package/dist/components/image/CustomImage.astro +90 -0
- package/dist/components/user-quick-tools.d.ts +42 -0
- package/dist/components/user-quick-tools.js +312 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +4 -0
- package/dist/consts.d.ts +61 -0
- package/dist/consts.js +39 -0
- package/dist/db/config.d.ts +4 -0
- package/dist/db/config.js +6 -0
- package/dist/db/tables.js +168 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +11 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +1177 -0
- package/dist/layouts/auth/AuthLayout.astro +74 -0
- package/dist/layouts/auth/FallbackCanvas.astro +123 -0
- package/dist/layouts/auth/ThemeManager.astro +53 -0
- package/dist/layouts/auth/ThreeCanvasLoader.astro +18 -0
- package/dist/layouts/dashboard/Layout.astro +64 -0
- package/dist/lib/auth/encryption.d.ts +30 -0
- package/dist/lib/auth/encryption.js +39 -0
- package/dist/lib/auth/password.d.ts +27 -0
- package/dist/lib/auth/password.js +42 -0
- package/dist/lib/auth/rate-limit.d.ts +136 -0
- package/dist/lib/auth/rate-limit.js +214 -0
- package/dist/lib/auth/session.d.ts +85 -0
- package/dist/lib/auth/session.js +93 -0
- package/dist/lib/auth/types.d.ts +83 -0
- package/dist/lib/auth/types.js +0 -0
- package/dist/lib/auth/user.d.ts +148 -0
- package/dist/lib/auth/user.js +133 -0
- package/dist/lib/dashboardGrid.d.ts +119 -0
- package/dist/lib/dashboardGrid.js +0 -0
- package/dist/lib/dynamic-sitemap/index.d.ts +42 -0
- package/dist/lib/dynamic-sitemap/index.js +45 -0
- package/dist/lib/dynamic-sitemap/sitemap-index.xml.d.ts +8 -0
- package/dist/lib/dynamic-sitemap/sitemap-index.xml.js +20 -0
- package/dist/lib/dynamic-sitemap/sitemap-index.xml.ts +45 -0
- package/dist/lib/head.d.ts +9 -0
- package/dist/lib/head.js +65 -0
- package/dist/lib/headDefaults.d.ts +18 -0
- package/dist/lib/headDefaults.js +75 -0
- package/dist/lib/i18n/LanguageSelector.astro +103 -0
- package/dist/lib/i18n/config.d.ts +16 -0
- package/dist/lib/i18n/config.js +8 -0
- package/dist/lib/i18n/index.d.ts +228 -0
- package/dist/lib/i18n/index.js +63 -0
- package/dist/lib/i18n/translations/de.json +43 -0
- package/dist/lib/i18n/translations/en-us.json +63 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/index.js +7 -0
- package/dist/lib/jsonUtils.d.ts +2 -0
- package/dist/lib/jsonUtils.js +11 -0
- package/dist/lib/makeAPIRoute.d.ts +45 -0
- package/dist/lib/makeAPIRoute.js +16 -0
- package/dist/lib/makePublicRoute.d.ts +7 -0
- package/dist/lib/makePublicRoute.js +6 -0
- package/dist/lib/pathGenerators.d.ts +20 -0
- package/dist/lib/pathGenerators.js +66 -0
- package/dist/lib/plugins/dashboard-pages.d.ts +71 -0
- package/dist/lib/plugins/dashboard-pages.js +11 -0
- package/dist/lib/plugins/frontend-navigation.d.ts +18 -0
- package/dist/lib/plugins/frontend-navigation.js +39 -0
- package/dist/lib/plugins/index.d.ts +2 -0
- package/dist/lib/plugins/index.js +2 -0
- package/dist/lib/removeLeadingTrailingSlashes.d.ts +7 -0
- package/dist/lib/removeLeadingTrailingSlashes.js +13 -0
- package/dist/lib/renderer/astro-remark.d.ts +13 -0
- package/dist/lib/renderer/astro-remark.js +11 -0
- package/dist/lib/renderer/contentRenderer.d.ts +13 -0
- package/dist/lib/renderer/contentRenderer.js +31 -0
- package/dist/lib/renderer/errors.d.ts +5 -0
- package/dist/lib/renderer/errors.js +25 -0
- package/dist/lib/renderer/markdoc-renderers/markdocHTML.d.ts +3 -0
- package/dist/lib/renderer/markdoc-renderers/markdocHTML.js +14 -0
- package/dist/lib/renderer/markdoc-renderers/markdocReactStatic.d.ts +3 -0
- package/dist/lib/renderer/markdoc-renderers/markdocReactStatic.js +14 -0
- package/dist/lib/renderer/markdoc.d.ts +11 -0
- package/dist/lib/renderer/markdoc.js +28 -0
- package/dist/lib/renderer/mdx.d.ts +10 -0
- package/dist/lib/renderer/mdx.js +37 -0
- package/dist/lib/renderer/runtime.d.ts +8 -0
- package/dist/lib/renderer/runtime.js +30 -0
- package/dist/lib/renderer/shared.d.ts +15 -0
- package/dist/lib/renderer/shared.js +13 -0
- package/dist/lib/renderer/studiocms.d.ts +11 -0
- package/dist/lib/renderer/studiocms.js +22 -0
- package/dist/lib/renderer/types.d.ts +12 -0
- package/dist/lib/renderer/types.js +0 -0
- package/dist/lib/robots/core.d.ts +24 -0
- package/dist/lib/robots/core.js +187 -0
- package/dist/lib/robots/index.d.ts +11 -0
- package/dist/lib/robots/index.js +47 -0
- package/dist/lib/robots/types.d.ts +185 -0
- package/dist/lib/robots/types.js +0 -0
- package/dist/lib/robots/utils.d.ts +22 -0
- package/dist/lib/robots/utils.js +22 -0
- package/dist/lib/routeMap.d.ts +257 -0
- package/dist/lib/routeMap.js +249 -0
- package/dist/lib/urlGen.d.ts +11 -0
- package/dist/lib/urlGen.js +26 -0
- package/dist/lib/webVitals/checkForWebVitalsPlugin.d.ts +18 -0
- package/dist/lib/webVitals/checkForWebVitalsPlugin.js +82 -0
- package/dist/lib/webVitals/consts.d.ts +240 -0
- package/dist/lib/webVitals/consts.js +40 -0
- package/dist/lib/webVitals/dashboard-grid-items/CoreVitals.astro +66 -0
- package/dist/lib/webVitals/dashboard-grid-items/MetricCard.astro +24 -0
- package/dist/lib/webVitals/dashboard-grid-items/SummaryCard.astro +56 -0
- package/dist/lib/webVitals/dashboard-grid-items/metric.css +103 -0
- package/dist/lib/webVitals/dashboard-grid-items/shared.d.ts +29 -0
- package/dist/lib/webVitals/dashboard-grid-items/shared.js +35 -0
- package/dist/lib/webVitals/pages/analytics/body.astro +186 -0
- package/dist/lib/webVitals/pages/analytics/header.astro +42 -0
- package/dist/lib/webVitals/schemas.d.ts +78 -0
- package/dist/lib/webVitals/schemas.js +37 -0
- package/dist/lib/webVitals/types.d.ts +156 -0
- package/dist/lib/webVitals/types.js +0 -0
- package/dist/lib/webVitals/utils/buildDataObject.d.ts +8 -0
- package/dist/lib/webVitals/utils/buildDataObject.js +28 -0
- package/dist/lib/webVitals/utils/buildPageRouteDataObject.d.ts +15 -0
- package/dist/lib/webVitals/utils/buildPageRouteDataObject.js +70 -0
- package/dist/lib/webVitals/utils/buildPerPageDataObject.d.ts +23 -0
- package/dist/lib/webVitals/utils/buildPerPageDataObject.js +209 -0
- package/dist/lib/webVitals/utils/checkDate.d.ts +5 -0
- package/dist/lib/webVitals/utils/checkDate.js +19 -0
- package/dist/lib/webVitals/utils/webVitalsUtils.d.ts +24 -0
- package/dist/lib/webVitals/utils/webVitalsUtils.js +234 -0
- package/dist/lib/webVitals/webVital.d.ts +20 -0
- package/dist/lib/webVitals/webVital.js +40 -0
- package/dist/lib/webVitals/webVitalsRouteSummary.d.ts +19 -0
- package/dist/lib/webVitals/webVitalsRouteSummary.js +59 -0
- package/dist/lib/webVitals/webVitalsSummary.d.ts +19 -0
- package/dist/lib/webVitals/webVitalsSummary.js +49 -0
- package/dist/plugins.d.ts +2 -0
- package/dist/plugins.js +6 -0
- package/dist/routes/api/render.astro +25 -0
- package/dist/routes/auth/api/auth0/callback.d.ts +4 -0
- package/dist/routes/auth/api/auth0/callback.js +117 -0
- package/dist/routes/auth/api/auth0/index.d.ts +4 -0
- package/dist/routes/auth/api/auth0/index.js +36 -0
- package/dist/routes/auth/api/auth0/shared.d.ts +13 -0
- package/dist/routes/auth/api/auth0/shared.js +24 -0
- package/dist/routes/auth/api/discord/callback.d.ts +4 -0
- package/dist/routes/auth/api/discord/callback.js +112 -0
- package/dist/routes/auth/api/discord/index.d.ts +4 -0
- package/dist/routes/auth/api/discord/index.js +36 -0
- package/dist/routes/auth/api/discord/shared.d.ts +12 -0
- package/dist/routes/auth/api/discord/shared.js +17 -0
- package/dist/routes/auth/api/github/callback.d.ts +4 -0
- package/dist/routes/auth/api/github/callback.js +112 -0
- package/dist/routes/auth/api/github/index.d.ts +4 -0
- package/dist/routes/auth/api/github/index.js +36 -0
- package/dist/routes/auth/api/github/shared.d.ts +13 -0
- package/dist/routes/auth/api/github/shared.js +14 -0
- package/dist/routes/auth/api/google/callback.d.ts +4 -0
- package/dist/routes/auth/api/google/callback.js +115 -0
- package/dist/routes/auth/api/google/index.d.ts +4 -0
- package/dist/routes/auth/api/google/index.js +38 -0
- package/dist/routes/auth/api/google/shared.d.ts +12 -0
- package/dist/routes/auth/api/google/shared.js +19 -0
- package/dist/routes/auth/api/login.d.ts +4 -0
- package/dist/routes/auth/api/login.js +46 -0
- package/dist/routes/auth/api/logout.d.ts +5 -0
- package/dist/routes/auth/api/logout.js +55 -0
- package/dist/routes/auth/api/register.d.ts +4 -0
- package/dist/routes/auth/api/register.js +64 -0
- package/dist/routes/auth/api/shared.d.ts +2 -0
- package/dist/routes/auth/api/shared.js +21 -0
- package/dist/routes/auth/login.astro +67 -0
- package/dist/routes/auth/logout.astro +28 -0
- package/dist/routes/auth/signup.astro +70 -0
- package/dist/routes/dashboard/[...pluginPage].astro +88 -0
- package/dist/routes/dashboard/configuration.astro +27 -0
- package/dist/routes/dashboard/content-management/createfolder.astro +56 -0
- package/dist/routes/dashboard/content-management/createpage.astro +59 -0
- package/dist/routes/dashboard/content-management/diff.astro +100 -0
- package/dist/routes/dashboard/content-management/editfolder.astro +40 -0
- package/dist/routes/dashboard/content-management/editpage.astro +44 -0
- package/dist/routes/dashboard/content-management/index.astro +57 -0
- package/dist/routes/dashboard/index.astro +24 -0
- package/dist/routes/dashboard/password-reset.astro +169 -0
- package/dist/routes/dashboard/plugins/[plugin].astro +60 -0
- package/dist/routes/dashboard/profile.astro +57 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/api-tokens.d.ts +5 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/api-tokens.js +90 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/config.d.ts +4 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/config.js +63 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/content/folder.d.ts +6 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/content/folder.js +121 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/content/page.d.ts +6 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/content/page.js +257 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/create-reset-link.d.ts +4 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/create-reset-link.js +59 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/create-user-invite.d.ts +4 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/create-user-invite.js +105 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/create-user.d.ts +4 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/create-user.js +100 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/partials/Editor.astro +61 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/partials/LiveRender.astro +30 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/partials/UserListItems.astro +39 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/plugins/[plugin].d.ts +2 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/plugins/[plugin].js +32 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/profile.d.ts +4 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/profile.js +130 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/reset-password.d.ts +4 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/reset-password.js +105 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/search-list.d.ts +4 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/search-list.js +55 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/users.d.ts +5 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/users.js +92 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/verify-session.d.ts +2 -0
- package/dist/routes/dashboard/studiocms_api/dashboard/verify-session.js +72 -0
- package/dist/routes/dashboard/user-management/edit.astro +593 -0
- package/dist/routes/dashboard/user-management/index.astro +67 -0
- package/dist/routes/error-pages/404.astro +35 -0
- package/dist/routes/firstTimeSetupRoutes/1-start.astro +253 -0
- package/dist/routes/firstTimeSetupRoutes/2-next.astro +208 -0
- package/dist/routes/firstTimeSetupRoutes/3-done.astro +95 -0
- package/dist/routes/firstTimeSetupRoutes/api/step-1.d.ts +2 -0
- package/dist/routes/firstTimeSetupRoutes/api/step-1.js +126 -0
- package/dist/routes/firstTimeSetupRoutes/api/step-2.d.ts +2 -0
- package/dist/routes/firstTimeSetupRoutes/api/step-2.js +110 -0
- package/dist/routes/firstTimeSetupRoutes/components/Layout.astro +41 -0
- package/dist/routes/firstTimeSetupRoutes/components/PageHeader.astro +60 -0
- package/dist/routes/firstTimeSetupRoutes/components/TabItem.astro +44 -0
- package/dist/routes/firstTimeSetupRoutes/components/Tabs.astro +170 -0
- package/dist/routes/firstTimeSetupRoutes/snippets/opt1-astro.config.diff +14 -0
- package/dist/routes/firstTimeSetupRoutes/snippets/opt2-astro.config.diff +9 -0
- package/dist/routes/firstTimeSetupRoutes/snippets/opt2-studiocms.config.diff +5 -0
- package/dist/routes/rest/utils/auth-token.d.ts +17 -0
- package/dist/routes/rest/utils/auth-token.js +31 -0
- package/dist/routes/rest/v1/folders/[id].d.ts +6 -0
- package/dist/routes/rest/v1/folders/[id].js +106 -0
- package/dist/routes/rest/v1/folders/index.d.ts +5 -0
- package/dist/routes/rest/v1/folders/index.js +88 -0
- package/dist/routes/rest/v1/pages/[id]/history/[diffid].d.ts +4 -0
- package/dist/routes/rest/v1/pages/[id]/history/[diffid].js +55 -0
- package/dist/routes/rest/v1/pages/[id]/history/index.d.ts +4 -0
- package/dist/routes/rest/v1/pages/[id]/history/index.js +61 -0
- package/dist/routes/rest/v1/pages/[id]/index.d.ts +6 -0
- package/dist/routes/rest/v1/pages/[id]/index.js +165 -0
- package/dist/routes/rest/v1/pages/index.d.ts +5 -0
- package/dist/routes/rest/v1/pages/index.js +113 -0
- package/dist/routes/rest/v1/public/folders/[id].d.ts +4 -0
- package/dist/routes/rest/v1/public/folders/[id].js +43 -0
- package/dist/routes/rest/v1/public/folders/index.d.ts +4 -0
- package/dist/routes/rest/v1/public/folders/index.js +49 -0
- package/dist/routes/rest/v1/public/pages/[id].d.ts +4 -0
- package/dist/routes/rest/v1/public/pages/[id].js +46 -0
- package/dist/routes/rest/v1/public/pages/index.d.ts +4 -0
- package/dist/routes/rest/v1/public/pages/index.js +61 -0
- package/dist/routes/rest/v1/settings/index.d.ts +5 -0
- package/dist/routes/rest/v1/settings/index.js +75 -0
- package/dist/routes/rest/v1/users/[id].d.ts +6 -0
- package/dist/routes/rest/v1/users/[id].js +212 -0
- package/dist/routes/rest/v1/users/index.d.ts +5 -0
- package/dist/routes/rest/v1/users/index.js +138 -0
- package/dist/routes/sdk/fallback-list-pages.json.d.ts +2 -0
- package/dist/routes/sdk/fallback-list-pages.json.js +19 -0
- package/dist/routes/sdk/fallback-list-pages.json.ts +22 -0
- package/dist/routes/sdk/full-changelog.json.d.ts +16 -0
- package/dist/routes/sdk/full-changelog.json.js +170 -0
- package/dist/routes/sdk/full-changelog.json.ts +224 -0
- package/dist/routes/sdk/list-pages.d.ts +4 -0
- package/dist/routes/sdk/list-pages.js +34 -0
- package/dist/routes/sdk/update-latest-version-cache.d.ts +4 -0
- package/dist/routes/sdk/update-latest-version-cache.js +41 -0
- package/dist/runtime/AstroComponentProxy.d.ts +29 -0
- package/dist/runtime/AstroComponentProxy.js +47 -0
- package/dist/runtime/decoder/decode-codepoint.d.ts +18 -0
- package/dist/runtime/decoder/decode-codepoint.js +58 -0
- package/dist/runtime/decoder/decode-data-html.d.ts +1 -0
- package/dist/runtime/decoder/decode-data-html.js +7 -0
- package/dist/runtime/decoder/decode-data-xml.d.ts +1 -0
- package/dist/runtime/decoder/decode-data-xml.js +7 -0
- package/dist/runtime/decoder/index.d.ts +34 -0
- package/dist/runtime/decoder/index.js +18 -0
- package/dist/runtime/decoder/util.d.ts +208 -0
- package/dist/runtime/decoder/util.js +415 -0
- package/dist/schemas/config/auth.d.ts +175 -0
- package/dist/schemas/config/auth.js +65 -0
- package/dist/schemas/config/componentoverrides.d.ts +17 -0
- package/dist/schemas/config/componentoverrides.js +14 -0
- package/dist/schemas/config/dashboard.d.ts +154 -0
- package/dist/schemas/config/dashboard.js +59 -0
- package/dist/schemas/config/defaultFrontend.d.ts +125 -0
- package/dist/schemas/config/defaultFrontend.js +57 -0
- package/dist/schemas/config/developer.d.ts +15 -0
- package/dist/schemas/config/developer.js +14 -0
- package/dist/schemas/config/imageService.d.ts +13 -0
- package/dist/schemas/config/imageService.js +12 -0
- package/dist/schemas/config/index.d.ts +1153 -0
- package/dist/schemas/config/index.js +95 -0
- package/dist/schemas/config/integrations.d.ts +14 -0
- package/dist/schemas/config/integrations.js +12 -0
- package/dist/schemas/config/markdoc.d.ts +172 -0
- package/dist/schemas/config/markdoc.js +68 -0
- package/dist/schemas/config/mdx.d.ts +455 -0
- package/dist/schemas/config/mdx.js +71 -0
- package/dist/schemas/config/rendererConfig.d.ts +659 -0
- package/dist/schemas/config/rendererConfig.js +51 -0
- package/dist/schemas/config/sdk.d.ts +167 -0
- package/dist/schemas/config/sdk.js +85 -0
- package/dist/schemas/config/studiocms-markdown-remark.d.ts +292 -0
- package/dist/schemas/config/studiocms-markdown-remark.js +63 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/plugins/index.d.ts +7373 -0
- package/dist/schemas/plugins/index.js +192 -0
- package/dist/schemas/plugins/shared.d.ts +1752 -0
- package/dist/schemas/plugins/shared.js +221 -0
- package/dist/scripts/formListener.d.ts +16 -0
- package/dist/scripts/formListener.js +46 -0
- package/dist/scripts/three.d.ts +1 -0
- package/dist/scripts/three.js +277 -0
- package/dist/scripts/utils/fitModelToViewport.d.ts +8 -0
- package/dist/scripts/utils/fitModelToViewport.js +19 -0
- package/dist/sdk/StudioCMSVirtualCache.d.ts +283 -0
- package/dist/sdk/StudioCMSVirtualCache.js +685 -0
- package/dist/sdk/cache.d.ts +11 -0
- package/dist/sdk/cache.js +12 -0
- package/dist/sdk/core.d.ts +865 -0
- package/dist/sdk/core.js +1966 -0
- package/dist/sdk/errors.d.ts +21 -0
- package/dist/sdk/errors.js +11 -0
- package/dist/sdk/index.d.ts +371 -0
- package/dist/sdk/index.js +8 -0
- package/dist/sdk/lib/foldertree.d.ts +50 -0
- package/dist/sdk/lib/foldertree.js +123 -0
- package/dist/sdk/lib/generators.d.ts +30 -0
- package/dist/sdk/lib/generators.js +25 -0
- package/dist/sdk/lib/packages.d.ts +8 -0
- package/dist/sdk/lib/packages.js +14 -0
- package/dist/sdk/lib/parsers.d.ts +14 -0
- package/dist/sdk/lib/parsers.js +10 -0
- package/dist/sdk/lib/users.d.ts +19 -0
- package/dist/sdk/lib/users.js +26 -0
- package/dist/sdk/tables.d.ts +1198 -0
- package/dist/sdk/tables.js +55 -0
- package/dist/sdk/types/index.d.ts +175 -0
- package/dist/sdk/types/index.js +0 -0
- package/dist/sdk/types/tableDefs.d.ts +75 -0
- package/dist/sdk/types/tableDefs.js +0 -0
- package/dist/sdk/types/tsAlias.d.ts +155 -0
- package/dist/sdk/types/tsAlias.js +0 -0
- package/dist/sdk/utils/db.d.ts +5 -0
- package/dist/sdk/utils/db.js +15 -0
- package/dist/stubs/auth-lib.d.ts +2 -0
- package/dist/stubs/auth-lib.js +519 -0
- package/dist/stubs/auth-scripts.d.ts +2 -0
- package/dist/stubs/auth-scripts.js +29 -0
- package/dist/stubs/auth-utils.d.ts +2 -0
- package/dist/stubs/auth-utils.js +36 -0
- package/dist/stubs/changelog.d.ts +2 -0
- package/dist/stubs/changelog.js +16 -0
- package/dist/stubs/components.d.ts +2 -0
- package/dist/stubs/components.js +67 -0
- package/dist/stubs/core.d.ts +2 -0
- package/dist/stubs/core.js +49 -0
- package/dist/stubs/i18n-dts.d.ts +2 -0
- package/dist/stubs/i18n-dts.js +117 -0
- package/dist/stubs/images.d.ts +1 -0
- package/dist/stubs/images.js +30 -0
- package/dist/stubs/index.d.ts +1 -0
- package/dist/stubs/index.js +40 -0
- package/dist/stubs/lib.d.ts +2 -0
- package/dist/stubs/lib.js +123 -0
- package/dist/stubs/plugins.d.ts +2 -0
- package/dist/stubs/plugins.js +60 -0
- package/dist/stubs/proxy.d.ts +2 -0
- package/dist/stubs/proxy.js +40 -0
- package/dist/stubs/renderer-config.d.ts +2 -0
- package/dist/stubs/renderer-config.js +18 -0
- package/dist/stubs/renderer-markdownConfig.d.ts +2 -0
- package/dist/stubs/renderer-markdownConfig.js +17 -0
- package/dist/stubs/renderer.d.ts +2 -0
- package/dist/stubs/renderer.js +44 -0
- package/dist/stubs/sdk.d.ts +2 -0
- package/dist/stubs/sdk.js +202 -0
- package/dist/stubs/webVitals.d.ts +2 -0
- package/dist/stubs/webVitals.js +40 -0
- package/dist/styles/404.css +47 -0
- package/dist/styles/SyntaxFont.woff2 +0 -0
- package/dist/styles/authlayout.css +138 -0
- package/dist/styles/dashboard-base.css +493 -0
- package/dist/styles/dashboard-code.css +33 -0
- package/dist/styles/dashboard-diff.css +389 -0
- package/dist/styles/dashboard-tiny-mde.css +224 -0
- package/dist/styles/md-remark-callouts/github.css +56 -0
- package/dist/styles/md-remark-callouts/obsidian.css +66 -0
- package/dist/styles/md-remark-callouts/vitepress.css +58 -0
- package/dist/styles/md-remark-headings.css +48 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.js +0 -0
- package/dist/utils/addAPIRoutes.d.ts +9 -0
- package/dist/utils/addAPIRoutes.js +33 -0
- package/dist/utils/addIntegrationArray.d.ts +24 -0
- package/dist/utils/addIntegrationArray.js +11 -0
- package/dist/utils/addIntegrationArrayWithCheck.d.ts +11 -0
- package/dist/utils/addIntegrationArrayWithCheck.js +24 -0
- package/dist/utils/astroConfigCheck.d.ts +8 -0
- package/dist/utils/astroConfigCheck.js +31 -0
- package/dist/utils/astroEnvConfig.d.ts +45 -0
- package/dist/utils/astroEnvConfig.js +9 -0
- package/dist/utils/authEnvCheck.d.ts +38 -0
- package/dist/utils/authEnvCheck.js +82 -0
- package/dist/utils/changelog.d.ts +1 -0
- package/dist/utils/changelog.js +53 -0
- package/dist/utils/changelogLoader.d.ts +15 -0
- package/dist/utils/changelogLoader.js +104 -0
- package/dist/utils/checkENV.d.ts +27 -0
- package/dist/utils/checkENV.js +115 -0
- package/dist/utils/configManager.d.ts +22 -0
- package/dist/utils/configManager.js +98 -0
- package/dist/utils/configResolver.d.ts +283 -0
- package/dist/utils/configResolver.js +105 -0
- package/dist/utils/defineStudioCMSConfig.d.ts +165 -0
- package/dist/utils/defineStudioCMSConfig.js +6 -0
- package/dist/utils/getLabelForPermissionLevel.d.ts +2 -0
- package/dist/utils/getLabelForPermissionLevel.js +17 -0
- package/dist/utils/injectRouteArray.d.ts +19 -0
- package/dist/utils/injectRouteArray.js +75 -0
- package/dist/utils/integrationLogger.d.ts +7 -0
- package/dist/utils/integrationLogger.js +18 -0
- package/dist/utils/integrations.d.ts +4 -0
- package/dist/utils/integrations.js +32 -0
- package/dist/utils/isDashboardRoute.d.ts +7 -0
- package/dist/utils/isDashboardRoute.js +10 -0
- package/dist/utils/loginBackgrounds/studiocms-blobs-dark.png +0 -0
- package/dist/utils/loginBackgrounds/studiocms-blobs-light.png +0 -0
- package/dist/utils/loginBackgrounds/studiocms-blocks-dark.png +0 -0
- package/dist/utils/loginBackgrounds/studiocms-blocks-light.png +0 -0
- package/dist/utils/loginBackgrounds/studiocms-curves-dark.png +0 -0
- package/dist/utils/loginBackgrounds/studiocms-curves-light.png +0 -0
- package/dist/utils/makePageTitle.d.ts +3 -0
- package/dist/utils/makePageTitle.js +7 -0
- package/dist/utils/pageListPackageLabel.d.ts +4 -0
- package/dist/utils/pageListPackageLabel.js +12 -0
- package/dist/utils/readJson.d.ts +1 -0
- package/dist/utils/readJson.js +7 -0
- package/dist/utils/routeBuilder.d.ts +18 -0
- package/dist/utils/routeBuilder.js +96 -0
- package/dist/utils/safeString.d.ts +1 -0
- package/dist/utils/safeString.js +6 -0
- package/dist/utils/simpleResponse.d.ts +1 -0
- package/dist/utils/simpleResponse.js +29 -0
- package/dist/utils/validImages.d.ts +13 -0
- package/dist/utils/validImages.js +39 -0
- package/dist/virtual.d.js +0 -0
- package/dist/virtual.d.ts +5 -0
- package/package.json +180 -59
- package/renderer.d.ts +25 -0
- package/static/studiocms-resources/auth/studiocms-logo.glb +0 -0
- package/static/studiocms-resources/core/favicon-dark.png +0 -0
- package/static/studiocms-resources/core/favicon-light.png +0 -0
- package/static/studiocms-resources/core/favicon.svg +15 -0
- package/studiocms-cli.mjs +13 -0
- package/ui.d.ts +291 -0
- package/src/blog/index.ts +0 -35
- package/src/index.ts +0 -25
- package/src/integration.ts +0 -130
- package/src/updateCheck.ts +0 -51
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { getUserData, verifyUserPermissionLevel } from "studiocms:auth/lib/user";
|
|
2
|
+
import { developerConfig } from "studiocms:config";
|
|
3
|
+
import studioCMS_SDK from "studiocms:sdk";
|
|
4
|
+
import studioCMS_SDK_Cache from "studiocms:sdk/cache";
|
|
5
|
+
import { simpleResponse } from "../../../../../utils/simpleResponse.js";
|
|
6
|
+
const { testingAndDemoMode } = developerConfig;
|
|
7
|
+
const POST = async (context) => {
|
|
8
|
+
if (testingAndDemoMode) {
|
|
9
|
+
return simpleResponse(400, "Testing and demo mode is enabled, this action is disabled.");
|
|
10
|
+
}
|
|
11
|
+
const userData = await getUserData(context);
|
|
12
|
+
if (!userData.isLoggedIn) {
|
|
13
|
+
return simpleResponse(403, "Unauthorized");
|
|
14
|
+
}
|
|
15
|
+
const isAuthorized = await verifyUserPermissionLevel(userData, "editor");
|
|
16
|
+
if (!isAuthorized) {
|
|
17
|
+
return simpleResponse(403, "Unauthorized");
|
|
18
|
+
}
|
|
19
|
+
const jsonData = await context.request.json();
|
|
20
|
+
const { folderName, parentFolder } = jsonData;
|
|
21
|
+
if (!folderName) {
|
|
22
|
+
return simpleResponse(400, "Invalid form data, folderName is required");
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
await studioCMS_SDK.POST.databaseEntry.folder({
|
|
26
|
+
name: folderName,
|
|
27
|
+
parent: parentFolder || null,
|
|
28
|
+
id: crypto.randomUUID()
|
|
29
|
+
});
|
|
30
|
+
await studioCMS_SDK_Cache.UPDATE.folderList();
|
|
31
|
+
await studioCMS_SDK_Cache.UPDATE.folderTree();
|
|
32
|
+
return simpleResponse(200, "Folder created successfully");
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return simpleResponse(500, "Failed to create folder");
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const PATCH = async (context) => {
|
|
38
|
+
if (testingAndDemoMode) {
|
|
39
|
+
return simpleResponse(400, "Testing and demo mode is enabled, this action is disabled.");
|
|
40
|
+
}
|
|
41
|
+
const userData = await getUserData(context);
|
|
42
|
+
if (!userData.isLoggedIn) {
|
|
43
|
+
return simpleResponse(403, "Unauthorized");
|
|
44
|
+
}
|
|
45
|
+
const isAuthorized = await verifyUserPermissionLevel(userData, "editor");
|
|
46
|
+
if (!isAuthorized) {
|
|
47
|
+
return simpleResponse(403, "Unauthorized");
|
|
48
|
+
}
|
|
49
|
+
const jsonData = await context.request.json();
|
|
50
|
+
const { id, folderName, parentFolder } = jsonData;
|
|
51
|
+
if (!id) {
|
|
52
|
+
return simpleResponse(400, "Invalid form data, id is required");
|
|
53
|
+
}
|
|
54
|
+
if (!folderName) {
|
|
55
|
+
return simpleResponse(400, "Invalid form data, folderName is required");
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
await studioCMS_SDK_Cache.UPDATE.folder({
|
|
59
|
+
id,
|
|
60
|
+
name: folderName,
|
|
61
|
+
parent: parentFolder || null
|
|
62
|
+
});
|
|
63
|
+
return simpleResponse(200, "Folder updated successfully");
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return simpleResponse(500, "Failed to update folder");
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const DELETE = async (context) => {
|
|
69
|
+
if (testingAndDemoMode) {
|
|
70
|
+
return simpleResponse(400, "Testing and demo mode is enabled, this action is disabled.");
|
|
71
|
+
}
|
|
72
|
+
const userData = await getUserData(context);
|
|
73
|
+
if (!userData.isLoggedIn) {
|
|
74
|
+
return simpleResponse(403, "Unauthorized");
|
|
75
|
+
}
|
|
76
|
+
const isAuthorized = await verifyUserPermissionLevel(userData, "admin");
|
|
77
|
+
if (!isAuthorized) {
|
|
78
|
+
return simpleResponse(403, "Unauthorized");
|
|
79
|
+
}
|
|
80
|
+
const jsonData = await context.request.json();
|
|
81
|
+
const { id } = jsonData;
|
|
82
|
+
if (!id) {
|
|
83
|
+
return simpleResponse(400, "Invalid form data, id is required");
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
await studioCMS_SDK.DELETE.folder(id);
|
|
87
|
+
await studioCMS_SDK_Cache.UPDATE.folderList();
|
|
88
|
+
await studioCMS_SDK_Cache.UPDATE.folderTree();
|
|
89
|
+
return simpleResponse(200, "Folder deleted successfully");
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return simpleResponse(500, "Failed to delete folder");
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const OPTIONS = async () => {
|
|
95
|
+
return new Response(null, {
|
|
96
|
+
status: 204,
|
|
97
|
+
statusText: "No Content",
|
|
98
|
+
headers: {
|
|
99
|
+
Allow: "OPTIONS, POST, DELETE, PATCH",
|
|
100
|
+
"ALLOW-ACCESS-CONTROL-ORIGIN": "*",
|
|
101
|
+
"Cache-Control": "public, max-age=604800, immutable",
|
|
102
|
+
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const ALL = async () => {
|
|
107
|
+
return new Response(null, {
|
|
108
|
+
status: 405,
|
|
109
|
+
statusText: "Method Not Allowed",
|
|
110
|
+
headers: {
|
|
111
|
+
"ACCESS-CONTROL-ALLOW-ORIGIN": "*"
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
export {
|
|
116
|
+
ALL,
|
|
117
|
+
DELETE,
|
|
118
|
+
OPTIONS,
|
|
119
|
+
PATCH,
|
|
120
|
+
POST
|
|
121
|
+
};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { getUserData, verifyUserPermissionLevel } from "studiocms:auth/lib/user";
|
|
2
|
+
import { developerConfig } from "studiocms:config";
|
|
3
|
+
import plugins from "studiocms:plugins";
|
|
4
|
+
import studioCMS_SDK from "studiocms:sdk";
|
|
5
|
+
import studioCMS_SDK_Cache from "studiocms:sdk/cache";
|
|
6
|
+
import { simpleResponse } from "../../../../../utils/simpleResponse.js";
|
|
7
|
+
const pageTypeOptions = plugins.flatMap(({ pageTypes }) => {
|
|
8
|
+
const pageTypeOutput = [];
|
|
9
|
+
if (!pageTypes) {
|
|
10
|
+
return pageTypeOutput;
|
|
11
|
+
}
|
|
12
|
+
for (const pageType of pageTypes) {
|
|
13
|
+
pageTypeOutput.push(pageType);
|
|
14
|
+
}
|
|
15
|
+
return pageTypeOutput;
|
|
16
|
+
});
|
|
17
|
+
function getPageTypeEndpoints(pkg, type) {
|
|
18
|
+
const currentPageType = pageTypeOptions.find((pageType) => pageType.identifier === pkg);
|
|
19
|
+
if (!currentPageType) {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
return currentPageType.apiEndpoints?.[type];
|
|
23
|
+
}
|
|
24
|
+
const { testingAndDemoMode } = developerConfig;
|
|
25
|
+
function getParentFolderValue(value) {
|
|
26
|
+
if (value === "null") return null;
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
const POST = async (context) => {
|
|
30
|
+
if (testingAndDemoMode) {
|
|
31
|
+
return simpleResponse(400, "Testing and demo mode is enabled, this action is disabled.");
|
|
32
|
+
}
|
|
33
|
+
const userData = await getUserData(context);
|
|
34
|
+
if (!userData.isLoggedIn) {
|
|
35
|
+
return simpleResponse(403, "Unauthorized");
|
|
36
|
+
}
|
|
37
|
+
const isAuthorized = await verifyUserPermissionLevel(userData, "editor");
|
|
38
|
+
if (!isAuthorized) {
|
|
39
|
+
return simpleResponse(403, "Unauthorized");
|
|
40
|
+
}
|
|
41
|
+
const formData = await context.request.formData();
|
|
42
|
+
const data = {
|
|
43
|
+
title: formData.get("page-title")?.toString(),
|
|
44
|
+
slug: formData.get("page-slug")?.toString(),
|
|
45
|
+
description: formData.get("page-description")?.toString(),
|
|
46
|
+
package: formData.get("page-type")?.toString(),
|
|
47
|
+
showOnNav: formData.get("show-in-nav")?.toString() === "true",
|
|
48
|
+
heroImage: formData.get("page-hero-image")?.toString(),
|
|
49
|
+
parentFolder: getParentFolderValue(formData.get("parent-folder")?.toString()),
|
|
50
|
+
showAuthor: formData.get("show-author")?.toString() === "true",
|
|
51
|
+
showContributors: formData.get("show-contributors")?.toString() === "true",
|
|
52
|
+
categories: [],
|
|
53
|
+
tags: [],
|
|
54
|
+
draft: true
|
|
55
|
+
};
|
|
56
|
+
const content = {
|
|
57
|
+
id: crypto.randomUUID(),
|
|
58
|
+
content: formData.get("page-content")?.toString() ?? ""
|
|
59
|
+
};
|
|
60
|
+
if (!data) {
|
|
61
|
+
return simpleResponse(400, "Invalid form data, data is required");
|
|
62
|
+
}
|
|
63
|
+
if (!content) {
|
|
64
|
+
return simpleResponse(400, "Invalid form data, content is required");
|
|
65
|
+
}
|
|
66
|
+
const dataId = crypto.randomUUID();
|
|
67
|
+
const contentId = crypto.randomUUID();
|
|
68
|
+
if (!data.title) {
|
|
69
|
+
return simpleResponse(400, "Invalid form data, title is required");
|
|
70
|
+
}
|
|
71
|
+
const apiRoute = getPageTypeEndpoints(data.package, "onCreate");
|
|
72
|
+
try {
|
|
73
|
+
await studioCMS_SDK.POST.databaseEntry.pages(
|
|
74
|
+
{
|
|
75
|
+
id: dataId,
|
|
76
|
+
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
77
|
+
title: data.title,
|
|
78
|
+
slug: data.slug || data.title.toLowerCase().replace(/\s/g, "-"),
|
|
79
|
+
description: data.description || "",
|
|
80
|
+
authorId: userData.user?.id || null,
|
|
81
|
+
...data
|
|
82
|
+
},
|
|
83
|
+
{ id: contentId, ...content }
|
|
84
|
+
);
|
|
85
|
+
if (apiRoute) {
|
|
86
|
+
await apiRoute(context);
|
|
87
|
+
}
|
|
88
|
+
return simpleResponse(200, "Page created successfully");
|
|
89
|
+
} catch (error) {
|
|
90
|
+
return simpleResponse(500, "Failed to create page");
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const PATCH = async (context) => {
|
|
94
|
+
if (testingAndDemoMode) {
|
|
95
|
+
return simpleResponse(400, "Testing and demo mode is enabled, this action is disabled.");
|
|
96
|
+
}
|
|
97
|
+
const userData = await getUserData(context);
|
|
98
|
+
if (!userData.isLoggedIn) {
|
|
99
|
+
return simpleResponse(403, "Unauthorized");
|
|
100
|
+
}
|
|
101
|
+
const isAuthorized = await verifyUserPermissionLevel(userData, "editor");
|
|
102
|
+
if (!isAuthorized) {
|
|
103
|
+
return simpleResponse(403, "Unauthorized");
|
|
104
|
+
}
|
|
105
|
+
const formData = await context.request.formData();
|
|
106
|
+
const data = {
|
|
107
|
+
title: formData.get("page-title")?.toString(),
|
|
108
|
+
slug: formData.get("page-slug")?.toString(),
|
|
109
|
+
description: formData.get("page-description")?.toString(),
|
|
110
|
+
package: formData.get("page-type")?.toString(),
|
|
111
|
+
showOnNav: formData.get("show-in-nav") === "true",
|
|
112
|
+
heroImage: formData.get("page-hero-image")?.toString(),
|
|
113
|
+
parentFolder: getParentFolderValue(formData.get("parent-folder")?.toString()),
|
|
114
|
+
showAuthor: formData.get("show-author") === "true",
|
|
115
|
+
showContributors: formData.get("show-contributors")?.toString() === "true",
|
|
116
|
+
categories: [],
|
|
117
|
+
tags: [],
|
|
118
|
+
id: formData.get("page-id")?.toString(),
|
|
119
|
+
draft: formData.get("draft")?.toString() === "true"
|
|
120
|
+
};
|
|
121
|
+
const content = {
|
|
122
|
+
id: formData.get("page-content-id")?.toString(),
|
|
123
|
+
content: formData.get("page-content")?.toString()
|
|
124
|
+
};
|
|
125
|
+
if (!data) {
|
|
126
|
+
return simpleResponse(400, "Invalid form data, data is required");
|
|
127
|
+
}
|
|
128
|
+
if (!content) {
|
|
129
|
+
return simpleResponse(400, "Invalid form data, content is required");
|
|
130
|
+
}
|
|
131
|
+
if (!data.id) {
|
|
132
|
+
return simpleResponse(400, "Invalid form data, id is required");
|
|
133
|
+
}
|
|
134
|
+
if (!content.id) {
|
|
135
|
+
return simpleResponse(400, "Invalid form data, id is required");
|
|
136
|
+
}
|
|
137
|
+
const currentPageData = await studioCMS_SDK_Cache.GET.page.byId(data.id);
|
|
138
|
+
if (!currentPageData.data) {
|
|
139
|
+
return simpleResponse(404, "Page not found");
|
|
140
|
+
}
|
|
141
|
+
const { authorId, contributorIds } = currentPageData.data;
|
|
142
|
+
let AuthorId = authorId;
|
|
143
|
+
if (!authorId) {
|
|
144
|
+
AuthorId = userData.user?.id || null;
|
|
145
|
+
}
|
|
146
|
+
const ContributorIds = contributorIds || [];
|
|
147
|
+
if (!ContributorIds.includes(userData.user.id)) {
|
|
148
|
+
ContributorIds.push(userData.user.id);
|
|
149
|
+
}
|
|
150
|
+
data.authorId = AuthorId;
|
|
151
|
+
data.contributorIds = JSON.stringify(ContributorIds);
|
|
152
|
+
data.updatedAt = /* @__PURE__ */ new Date();
|
|
153
|
+
const startMetaData = (await studioCMS_SDK.GET.databaseTable.pageData()).find(
|
|
154
|
+
(metaData) => metaData.id === data.id
|
|
155
|
+
);
|
|
156
|
+
const {
|
|
157
|
+
data: { defaultContent }
|
|
158
|
+
} = await studioCMS_SDK_Cache.GET.page.byId(data.id);
|
|
159
|
+
const apiRoute = getPageTypeEndpoints(data.package, "onEdit");
|
|
160
|
+
try {
|
|
161
|
+
await studioCMS_SDK_Cache.UPDATE.page.byId(data.id, {
|
|
162
|
+
pageData: data,
|
|
163
|
+
pageContent: content
|
|
164
|
+
});
|
|
165
|
+
const updatedMetaData = (await studioCMS_SDK.GET.databaseTable.pageData()).find(
|
|
166
|
+
(metaData) => metaData.id === data.id
|
|
167
|
+
);
|
|
168
|
+
const { enableDiffs, diffPerPage } = (await studioCMS_SDK_Cache.GET.siteConfig()).data;
|
|
169
|
+
if (enableDiffs) {
|
|
170
|
+
await studioCMS_SDK.diffTracking.insert(
|
|
171
|
+
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
172
|
+
userData.user.id,
|
|
173
|
+
data.id,
|
|
174
|
+
{
|
|
175
|
+
content: {
|
|
176
|
+
start: defaultContent?.content || "",
|
|
177
|
+
end: content.content || ""
|
|
178
|
+
},
|
|
179
|
+
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
180
|
+
metaData: { start: startMetaData, end: updatedMetaData }
|
|
181
|
+
},
|
|
182
|
+
diffPerPage
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
if (apiRoute) {
|
|
186
|
+
await apiRoute(context);
|
|
187
|
+
}
|
|
188
|
+
return simpleResponse(200, "Page updated successfully");
|
|
189
|
+
} catch (error) {
|
|
190
|
+
return simpleResponse(500, "Failed to update page");
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const DELETE = async (context) => {
|
|
194
|
+
if (testingAndDemoMode) {
|
|
195
|
+
return simpleResponse(400, "Testing and demo mode is enabled, this action is disabled.");
|
|
196
|
+
}
|
|
197
|
+
const userData = await getUserData(context);
|
|
198
|
+
if (!userData.isLoggedIn) {
|
|
199
|
+
return simpleResponse(403, "Unauthorized");
|
|
200
|
+
}
|
|
201
|
+
const isAuthorized = await verifyUserPermissionLevel(userData, "admin");
|
|
202
|
+
if (!isAuthorized) {
|
|
203
|
+
return simpleResponse(403, "Unauthorized");
|
|
204
|
+
}
|
|
205
|
+
const jsonData = await context.request.json();
|
|
206
|
+
const { id, slug } = jsonData;
|
|
207
|
+
if (!id) {
|
|
208
|
+
return simpleResponse(400, "Invalid request");
|
|
209
|
+
}
|
|
210
|
+
if (!slug) {
|
|
211
|
+
return simpleResponse(400, "Invalid request");
|
|
212
|
+
}
|
|
213
|
+
const isHomePage = await studioCMS_SDK_Cache.GET.page.bySlug("index");
|
|
214
|
+
if (isHomePage.data && isHomePage.data.id === id) {
|
|
215
|
+
return simpleResponse(400, "Cannot delete home page");
|
|
216
|
+
}
|
|
217
|
+
const pageToDelete = await studioCMS_SDK_Cache.GET.page.byId(id);
|
|
218
|
+
const apiRoute = getPageTypeEndpoints(pageToDelete.data.package, "onCreate");
|
|
219
|
+
try {
|
|
220
|
+
await studioCMS_SDK.DELETE.page(id);
|
|
221
|
+
studioCMS_SDK_Cache.CLEAR.page.byId(id);
|
|
222
|
+
if (apiRoute) {
|
|
223
|
+
await apiRoute(context);
|
|
224
|
+
}
|
|
225
|
+
return simpleResponse(200, "Page deleted successfully");
|
|
226
|
+
} catch (error) {
|
|
227
|
+
return simpleResponse(500, "Failed to delete page");
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
const OPTIONS = async () => {
|
|
231
|
+
return new Response(null, {
|
|
232
|
+
status: 204,
|
|
233
|
+
statusText: "No Content",
|
|
234
|
+
headers: {
|
|
235
|
+
Allow: "OPTIONS, POST, DELETE, PATCH",
|
|
236
|
+
"ALLOW-ACCESS-CONTROL-ORIGIN": "*",
|
|
237
|
+
"Cache-Control": "public, max-age=604800, immutable",
|
|
238
|
+
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
const ALL = async () => {
|
|
243
|
+
return new Response(null, {
|
|
244
|
+
status: 405,
|
|
245
|
+
statusText: "Method Not Allowed",
|
|
246
|
+
headers: {
|
|
247
|
+
"ACCESS-CONTROL-ALLOW-ORIGIN": "*"
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
export {
|
|
252
|
+
ALL,
|
|
253
|
+
DELETE,
|
|
254
|
+
OPTIONS,
|
|
255
|
+
PATCH,
|
|
256
|
+
POST
|
|
257
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getUserData, verifyUserPermissionLevel } from "studiocms:auth/lib/user";
|
|
2
|
+
import { developerConfig } from "studiocms:config";
|
|
3
|
+
import studioCMS_SDK from "studiocms:sdk";
|
|
4
|
+
import { simpleResponse } from "../../../../utils/simpleResponse.js";
|
|
5
|
+
const { testingAndDemoMode } = developerConfig;
|
|
6
|
+
const POST = async (ctx) => {
|
|
7
|
+
if (testingAndDemoMode) {
|
|
8
|
+
return simpleResponse(400, "Testing and demo mode is enabled, this action is disabled.");
|
|
9
|
+
}
|
|
10
|
+
const userData = await getUserData(ctx);
|
|
11
|
+
if (!userData.isLoggedIn) {
|
|
12
|
+
return simpleResponse(403, "Unauthorized");
|
|
13
|
+
}
|
|
14
|
+
const isAuthorized = await verifyUserPermissionLevel(userData, "admin");
|
|
15
|
+
if (!isAuthorized) {
|
|
16
|
+
return simpleResponse(403, "Unauthorized");
|
|
17
|
+
}
|
|
18
|
+
const jsonData = await ctx.request.json();
|
|
19
|
+
const { userId } = jsonData;
|
|
20
|
+
if (!userId) {
|
|
21
|
+
return simpleResponse(400, "Invalid form data, userId is required");
|
|
22
|
+
}
|
|
23
|
+
const token = await studioCMS_SDK.resetTokenBucket.new(userId);
|
|
24
|
+
if (!token) {
|
|
25
|
+
return simpleResponse(500, "Failed to create reset link");
|
|
26
|
+
}
|
|
27
|
+
return new Response(JSON.stringify(token), {
|
|
28
|
+
headers: {
|
|
29
|
+
"content-type": "application/json"
|
|
30
|
+
},
|
|
31
|
+
status: 200
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const OPTIONS = async () => {
|
|
35
|
+
return new Response(null, {
|
|
36
|
+
status: 204,
|
|
37
|
+
statusText: "No Content",
|
|
38
|
+
headers: {
|
|
39
|
+
Allow: "OPTIONS, POST",
|
|
40
|
+
"ALLOW-ACCESS-CONTROL-ORIGIN": "*",
|
|
41
|
+
"Cache-Control": "public, max-age=604800, immutable",
|
|
42
|
+
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const ALL = async () => {
|
|
47
|
+
return new Response(null, {
|
|
48
|
+
status: 405,
|
|
49
|
+
statusText: "Method Not Allowed",
|
|
50
|
+
headers: {
|
|
51
|
+
"ACCESS-CONTROL-ALLOW-ORIGIN": "*"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
ALL,
|
|
57
|
+
OPTIONS,
|
|
58
|
+
POST
|
|
59
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getUserData,
|
|
3
|
+
verifyUserPermissionLevel,
|
|
4
|
+
verifyUsernameInput
|
|
5
|
+
} from "studiocms:auth/lib/user";
|
|
6
|
+
import { developerConfig } from "studiocms:config";
|
|
7
|
+
import { StudioCMSRoutes, removeLeadingTrailingSlashes } from "studiocms:lib";
|
|
8
|
+
import studioCMS_SDK from "studiocms:sdk";
|
|
9
|
+
import { z } from "astro/zod";
|
|
10
|
+
import { simpleResponse } from "../../../../utils/simpleResponse.js";
|
|
11
|
+
const { testingAndDemoMode } = developerConfig;
|
|
12
|
+
const POST = async (ctx) => {
|
|
13
|
+
if (testingAndDemoMode) {
|
|
14
|
+
return simpleResponse(400, "Testing and demo mode is enabled, this action is disabled.");
|
|
15
|
+
}
|
|
16
|
+
const userData = await getUserData(ctx);
|
|
17
|
+
if (!userData.isLoggedIn) {
|
|
18
|
+
return simpleResponse(403, "Unauthorized");
|
|
19
|
+
}
|
|
20
|
+
const isAuthorized = await verifyUserPermissionLevel(userData, "admin");
|
|
21
|
+
if (!isAuthorized) {
|
|
22
|
+
return simpleResponse(403, "Unauthorized");
|
|
23
|
+
}
|
|
24
|
+
const jsonData = await ctx.request.json();
|
|
25
|
+
const { username, email, displayname, rank, originalUrl } = jsonData;
|
|
26
|
+
if (!username) {
|
|
27
|
+
return simpleResponse(400, "Missing field: Username is required");
|
|
28
|
+
}
|
|
29
|
+
if (!email) {
|
|
30
|
+
return simpleResponse(400, "Missing field: Email is required");
|
|
31
|
+
}
|
|
32
|
+
if (!displayname) {
|
|
33
|
+
return simpleResponse(400, "Missing field: Display name is required");
|
|
34
|
+
}
|
|
35
|
+
if (!rank) {
|
|
36
|
+
return simpleResponse(400, "Missing field: Rank is required");
|
|
37
|
+
}
|
|
38
|
+
if (verifyUsernameInput(username) !== true) {
|
|
39
|
+
return simpleResponse(
|
|
40
|
+
400,
|
|
41
|
+
"Invalid username: Username must be between 3 and 20 characters, only contain lowercase letters, numbers, -, and _ as well as not be a commonly used username (admin, root, etc.)"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const checkEmail = z.coerce.string().email({ message: "Email address is invalid" }).safeParse(email);
|
|
45
|
+
if (!checkEmail.success) {
|
|
46
|
+
return simpleResponse(400, `Invalid email: ${checkEmail.error.message}`);
|
|
47
|
+
}
|
|
48
|
+
const { usernameSearch, emailSearch } = await studioCMS_SDK.AUTH.user.searchUsersForUsernameOrEmail(username, checkEmail.data);
|
|
49
|
+
if (usernameSearch.length > 0) {
|
|
50
|
+
return simpleResponse(400, "Invalid username: Username is already in use");
|
|
51
|
+
}
|
|
52
|
+
if (emailSearch.length > 0) {
|
|
53
|
+
return simpleResponse(400, "Invalid email: Email is already in use");
|
|
54
|
+
}
|
|
55
|
+
function generateResetLink(token2) {
|
|
56
|
+
return `${originalUrl}${StudioCMSRoutes.mainLinks.dashboardIndex}/reset-password?userid=${token2.userId}&token=${token2.token}&id=${token2.id}`;
|
|
57
|
+
}
|
|
58
|
+
const newUser = await studioCMS_SDK.AUTH.user.create(
|
|
59
|
+
{
|
|
60
|
+
username,
|
|
61
|
+
email: checkEmail.data,
|
|
62
|
+
name: displayname,
|
|
63
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
64
|
+
id: crypto.randomUUID()
|
|
65
|
+
},
|
|
66
|
+
rank
|
|
67
|
+
);
|
|
68
|
+
const token = await studioCMS_SDK.resetTokenBucket.new(newUser.id);
|
|
69
|
+
if (!token) {
|
|
70
|
+
return simpleResponse(500, "Failed to create reset token");
|
|
71
|
+
}
|
|
72
|
+
const resetLink = generateResetLink(token);
|
|
73
|
+
return new Response(JSON.stringify({ link: resetLink }), {
|
|
74
|
+
headers: {
|
|
75
|
+
"content-type": "application/json"
|
|
76
|
+
},
|
|
77
|
+
status: 200
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const OPTIONS = async () => {
|
|
81
|
+
return new Response(null, {
|
|
82
|
+
status: 204,
|
|
83
|
+
statusText: "No Content",
|
|
84
|
+
headers: {
|
|
85
|
+
Allow: "OPTIONS, POST",
|
|
86
|
+
"ALLOW-ACCESS-CONTROL-ORIGIN": "*",
|
|
87
|
+
"Cache-Control": "public, max-age=604800, immutable",
|
|
88
|
+
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const ALL = async () => {
|
|
93
|
+
return new Response(null, {
|
|
94
|
+
status: 405,
|
|
95
|
+
statusText: "Method Not Allowed",
|
|
96
|
+
headers: {
|
|
97
|
+
"ACCESS-CONTROL-ALLOW-ORIGIN": "*"
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
export {
|
|
102
|
+
ALL,
|
|
103
|
+
OPTIONS,
|
|
104
|
+
POST
|
|
105
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { verifyPasswordStrength } from "studiocms:auth/lib/password";
|
|
2
|
+
import {
|
|
3
|
+
createLocalUser,
|
|
4
|
+
getUserData,
|
|
5
|
+
verifyUserPermissionLevel,
|
|
6
|
+
verifyUsernameInput
|
|
7
|
+
} from "studiocms:auth/lib/user";
|
|
8
|
+
import { developerConfig } from "studiocms:config";
|
|
9
|
+
import studioCMS_SDK from "studiocms:sdk";
|
|
10
|
+
import { z } from "astro/zod";
|
|
11
|
+
import { simpleResponse } from "../../../../utils/simpleResponse.js";
|
|
12
|
+
const { testingAndDemoMode } = developerConfig;
|
|
13
|
+
const POST = async (ctx) => {
|
|
14
|
+
if (testingAndDemoMode) {
|
|
15
|
+
return simpleResponse(400, "Testing and demo mode is enabled, this action is disabled.");
|
|
16
|
+
}
|
|
17
|
+
const userData = await getUserData(ctx);
|
|
18
|
+
if (!userData.isLoggedIn) {
|
|
19
|
+
return simpleResponse(403, "Unauthorized");
|
|
20
|
+
}
|
|
21
|
+
const isAuthorized = await verifyUserPermissionLevel(userData, "admin");
|
|
22
|
+
if (!isAuthorized) {
|
|
23
|
+
return simpleResponse(403, "Unauthorized");
|
|
24
|
+
}
|
|
25
|
+
const jsonData = await ctx.request.json();
|
|
26
|
+
let { username, password, email, displayname, rank } = jsonData;
|
|
27
|
+
if (!username) {
|
|
28
|
+
return simpleResponse(400, "Missing field: Username is required");
|
|
29
|
+
}
|
|
30
|
+
if (!password) {
|
|
31
|
+
password = studioCMS_SDK.generateRandomPassword(12);
|
|
32
|
+
}
|
|
33
|
+
if (!email) {
|
|
34
|
+
return simpleResponse(400, "Missing field: Email is required");
|
|
35
|
+
}
|
|
36
|
+
if (!displayname) {
|
|
37
|
+
return simpleResponse(400, "Missing field: Display name is required");
|
|
38
|
+
}
|
|
39
|
+
if (!rank) {
|
|
40
|
+
return simpleResponse(400, "Missing field: Rank is required");
|
|
41
|
+
}
|
|
42
|
+
if (verifyUsernameInput(username) !== true) {
|
|
43
|
+
return simpleResponse(
|
|
44
|
+
400,
|
|
45
|
+
"Invalid username: Username must be between 3 and 20 characters, only contain lowercase letters, numbers, -, and _ as well as not be a commonly used username (admin, root, etc.)"
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (await verifyPasswordStrength(password) !== true) {
|
|
49
|
+
return simpleResponse(
|
|
50
|
+
400,
|
|
51
|
+
'Invalid password: Password must be between 6 and 255 characters, and not be in the <a href="https://haveibeenpwned.com/Passwords" target="_blank">pwned password database</a>.'
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const checkEmail = z.coerce.string().email({ message: "Email address is invalid" }).safeParse(email);
|
|
55
|
+
if (!checkEmail.success) {
|
|
56
|
+
return simpleResponse(400, `Invalid email: ${checkEmail.error.message}`);
|
|
57
|
+
}
|
|
58
|
+
const { usernameSearch, emailSearch } = await studioCMS_SDK.AUTH.user.searchUsersForUsernameOrEmail(username, checkEmail.data);
|
|
59
|
+
if (usernameSearch.length > 0) {
|
|
60
|
+
return simpleResponse(400, "Invalid username: Username is already in use");
|
|
61
|
+
}
|
|
62
|
+
if (emailSearch.length > 0) {
|
|
63
|
+
return simpleResponse(400, "Invalid email: Email is already in use");
|
|
64
|
+
}
|
|
65
|
+
const newUser = await createLocalUser(displayname, username, email, password);
|
|
66
|
+
const updateRank = await studioCMS_SDK.UPDATE.permissions({
|
|
67
|
+
user: newUser.id,
|
|
68
|
+
rank
|
|
69
|
+
});
|
|
70
|
+
return simpleResponse(
|
|
71
|
+
200,
|
|
72
|
+
JSON.stringify({ username, email, displayname, rank: updateRank.rank, password })
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
const OPTIONS = async () => {
|
|
76
|
+
return new Response(null, {
|
|
77
|
+
status: 204,
|
|
78
|
+
statusText: "No Content",
|
|
79
|
+
headers: {
|
|
80
|
+
Allow: "OPTIONS, POST",
|
|
81
|
+
"ALLOW-ACCESS-CONTROL-ORIGIN": "*",
|
|
82
|
+
"Cache-Control": "public, max-age=604800, immutable",
|
|
83
|
+
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const ALL = async () => {
|
|
88
|
+
return new Response(null, {
|
|
89
|
+
status: 405,
|
|
90
|
+
statusText: "Method Not Allowed",
|
|
91
|
+
headers: {
|
|
92
|
+
"ACCESS-CONTROL-ALLOW-ORIGIN": "*"
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
export {
|
|
97
|
+
ALL,
|
|
98
|
+
OPTIONS,
|
|
99
|
+
POST
|
|
100
|
+
};
|