studiocms 0.1.0-beta.25 → 0.1.0-beta.26
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 +91 -0
- package/dist/cli/users/steps/libsqlCreateUsers.js +1 -3
- package/dist/cli/users/steps/libsqlModifyUsers.js +1 -3
- package/dist/components/auth/OAuthButton.astro +1 -1
- package/dist/components/auth/OAuthButtonStack.astro +1 -1
- package/dist/components/auth/component-scripts/formListener.js +1 -1
- package/dist/components/dashboard/BaseHead.astro +6 -17
- package/dist/components/dashboard/DashboardGrid.astro +2 -2
- package/dist/components/dashboard/DashboardGridItem.astro +2 -1
- package/dist/components/dashboard/DashboardPageHeader.astro +8 -4
- package/dist/components/dashboard/DoubleSidebar.astro +2 -2
- package/dist/components/dashboard/LoginChecker.astro +3 -2
- package/dist/components/dashboard/MainSidebarContent.astro +16 -12
- package/dist/components/dashboard/PageHeader.astro +3 -2
- package/dist/components/dashboard/SidebarLink.astro +5 -5
- package/dist/components/dashboard/SidebarPluginLink.astro +3 -3
- package/dist/components/dashboard/SingleSidebar.astro +2 -2
- package/dist/components/dashboard/configuration/ConfigForm.astro +49 -47
- package/dist/components/dashboard/configuration/LoginPreview.astro +6 -4
- package/dist/components/dashboard/content-mgmt/CreateFolder.astro +3 -2
- package/dist/components/dashboard/content-mgmt/CreatePage.astro +8 -5
- package/dist/components/dashboard/content-mgmt/EditFolder.astro +3 -2
- package/dist/components/dashboard/content-mgmt/EditPage.astro +25 -13
- package/dist/components/dashboard/content-mgmt/InnerSidebarElement.astro +23 -15
- package/dist/components/dashboard/content-mgmt/PageHeader.astro +23 -14
- package/dist/components/dashboard/content-mgmt/PluginFields.astro +6 -1
- package/dist/components/dashboard/content-mgmt/TreeRenderer.astro +6 -6
- package/dist/components/dashboard/content-mgmt/TreeSidebarFolder.astro +4 -4
- package/dist/components/dashboard/content-mgmt/TreeSidebarLink.astro +4 -4
- package/dist/components/dashboard/plugins/SettingsRenderer.astro +6 -1
- package/dist/components/dashboard/profile/APITokens.astro +14 -8
- package/dist/components/dashboard/profile/BasicInfo.astro +8 -4
- package/dist/components/dashboard/profile/Notifications.astro +7 -4
- package/dist/components/dashboard/profile/SocialSignin.astro +8 -5
- package/dist/components/dashboard/profile/UpdatePassword.astro +6 -3
- package/dist/components/dashboard/sidebar/UserAccount.astro +1 -2
- package/dist/components/dashboard/sidebar/VersionCheck.astro +7 -7
- package/dist/components/dashboard/sidebar/VersionCheckChangelog.astro +28 -6
- package/dist/components/dashboard/sidebar-modals/UserManagementModals.astro +8 -3
- package/dist/components/dashboard/sidebar-modals/VersionModal.astro +16 -15
- package/dist/components/dashboard/sidebarConfig.d.ts +2 -2
- package/dist/components/dashboard/sidebarConfig.js +6 -6
- package/dist/components/dashboard/user-mgmt/InnerSidebarElement.astro +16 -9
- package/dist/components/dashboard/user-mgmt/RankCheck.astro +6 -8
- package/dist/components/dashboard/user-mgmt/SocialSignin.astro +9 -10
- package/dist/components/dashboard/user-mgmt/UserListItem.astro +8 -6
- package/dist/components/default-grid-items/Recently-created-pages.astro +11 -9
- package/dist/components/default-grid-items/Recently-signed-up.astro +8 -8
- package/dist/components/default-grid-items/Recently-updated-pages.astro +11 -9
- package/dist/components/default-grid-items/Totals.astro +7 -6
- package/dist/components/first-time-setup/PageHeader.astro +4 -3
- package/dist/components/shared/SSRUser.astro +200 -0
- package/dist/components/shared/head/Favicons.astro +6 -0
- package/dist/components/shared/head/Global.astro +4 -0
- package/dist/components/shared/head/TitleTags.astro +14 -0
- package/dist/config.d.ts +1 -4
- package/dist/consts.d.ts +34 -1
- package/dist/consts.js +42 -1
- package/dist/db/config.d.ts +22 -37
- package/dist/db/config.js +14 -2
- package/dist/handlers/astroConfigCheck.js +1 -1
- package/dist/handlers/changelog.d.ts +1 -0
- package/dist/handlers/changelog.js +54 -0
- package/dist/handlers/index.d.ts +1 -2
- package/dist/handlers/index.js +2 -4
- package/dist/handlers/pluginHandler.d.ts +2 -1
- package/dist/handlers/pluginHandler.js +14 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.js +115 -107
- package/dist/integrations/dynamic-sitemap/index.js +1 -1
- package/dist/integrations/webVitals/checkForWebVitalsPlugin.js +3 -3
- package/dist/integrations/webVitals/dashboard-grid-items/CoreVitals.astro +1 -1
- package/dist/integrations/webVitals/dashboard-grid-items/MetricCard.astro +3 -2
- package/dist/integrations/webVitals/dashboard-grid-items/SummaryCard.astro +2 -2
- package/dist/integrations/webVitals/dashboard-grid-items/metric.css +17 -17
- package/dist/integrations/webVitals/dashboard-grid-items/shared.d.ts +4 -4
- package/dist/integrations/webVitals/dashboard-grid-items/shared.js +3 -3
- package/dist/integrations/webVitals/pages/analytics/body.astro +10 -9
- package/dist/integrations/webVitals/utils/webVitalsUtils.d.ts +9 -9
- package/dist/layouts/AuthLayout.astro +7 -18
- package/dist/layouts/DashboardLayout.astro +3 -2
- package/dist/layouts/FirstTimeSetupLayout.astro +7 -18
- package/dist/middleware/index.js +3 -13
- package/dist/middleware/utils.d.ts +1 -1
- package/dist/middleware/utils.js +8 -5
- package/dist/routes/api/auth/login.js +1 -6
- package/dist/routes/api/auth/logout.js +3 -2
- package/dist/routes/api/auth/register.js +1 -7
- package/dist/routes/api/dashboard/content/page.js +5 -5
- package/dist/routes/api/dashboard/create-user-invite.js +1 -1
- package/dist/routes/api/dashboard/create-user.d.ts +0 -7
- package/dist/routes/api/dashboard/create-user.js +18 -23
- package/dist/routes/api/dashboard/email-notification-settings-site.js +10 -0
- package/dist/routes/api/dashboard/profile.js +1 -1
- package/dist/routes/api/dashboard/reset-password.js +1 -1
- package/dist/routes/api/dashboard/users.js +27 -10
- package/dist/routes/api/dashboard/verify-email.js +5 -2
- package/dist/routes/api/dashboard/verify-session.js +3 -2
- package/dist/routes/api/rest/utils/auth-token.d.ts +1 -1
- package/dist/routes/api/rest/v1/pages/[id]/index.js +3 -10
- package/dist/routes/api/rest/v1/users/[id].js +24 -23
- package/dist/routes/api/rest/v1/users/index.js +1 -1
- package/dist/routes/api/sdk/utils/changelog.d.ts +0 -15
- package/dist/routes/api/sdk/utils/changelog.js +9 -112
- package/dist/routes/auth/login.astro +16 -9
- package/dist/routes/auth/signup.astro +2 -1
- package/dist/routes/dashboard/configuration.astro +3 -2
- package/dist/routes/dashboard/content-management/createfolder.astro +1 -1
- package/dist/routes/dashboard/content-management/createpage.astro +1 -1
- package/dist/routes/dashboard/content-management/diff.astro +8 -5
- package/dist/routes/dashboard/content-management/index.astro +1 -1
- package/dist/routes/dashboard/password-reset.astro +8 -5
- package/dist/routes/dashboard/plugins/[plugin].astro +4 -3
- package/dist/routes/dashboard/smtp-configuration.astro +21 -10
- package/dist/routes/dashboard/unverified-email.astro +2 -4
- package/dist/routes/dashboard/user-management/edit.astro +30 -22
- package/dist/routes/dashboard/user-management/index.astro +2 -2
- package/dist/routes/error-pages/404.astro +1 -1
- package/dist/routes/firstTimeSetupRoutes/1-start.astro +15 -14
- package/dist/routes/firstTimeSetupRoutes/2-next.astro +14 -11
- package/dist/routes/firstTimeSetupRoutes/3-done.astro +3 -2
- package/dist/routes/firstTimeSetupRoutes/api/step-2.js +1 -1
- package/dist/schemas/plugins/index.d.ts +64 -64
- package/dist/schemas/plugins/shared.d.ts +84 -84
- package/dist/schemas/plugins/shared.js +10 -16
- package/dist/styles/404.css +1 -1
- package/dist/styles/code-component.css +8 -8
- package/dist/styles/dashboard-base.css +29 -29
- package/dist/styles/dashboard-diff.css +31 -31
- package/dist/types.d.ts +2 -22
- package/dist/utils/effects/smtp.d.ts +2 -3
- package/dist/utils/effects/smtp.js +5 -1
- package/dist/utils/safeString.d.ts +1 -1
- package/dist/utils/safeString.js +1 -3
- package/dist/utils/stripIconify.d.ts +13 -0
- package/dist/utils/stripIconify.js +11 -0
- package/dist/utils/tinyMDParser.js +5 -5
- package/dist/virtual.d.ts +17 -60
- package/dist/virtuals/auth/core.d.ts +91 -0
- package/dist/virtuals/auth/core.js +45 -0
- package/dist/virtuals/auth/index.d.ts +1 -4
- package/dist/virtuals/auth/index.js +1 -4
- package/dist/virtuals/auth/verify-email.d.ts +3 -3
- package/dist/virtuals/i18n/LanguageSelector.astro +1 -1
- package/dist/virtuals/i18n/client.d.ts +100 -4
- package/dist/virtuals/i18n/client.js +11 -10
- package/dist/virtuals/i18n/config.d.ts +417 -3
- package/dist/virtuals/i18n/config.js +22 -1
- package/dist/virtuals/i18n/server.d.ts +116 -0
- package/dist/virtuals/i18n/{index.js → server.js} +6 -19
- package/dist/virtuals/i18n/v-files.d.ts +30 -0
- package/dist/virtuals/i18n/v-files.js +46 -0
- package/dist/virtuals/lib/head.d.ts +1 -25
- package/dist/virtuals/lib/head.js +1 -73
- package/dist/virtuals/lib/headDefaults.d.ts +2 -2
- package/dist/virtuals/lib/pathGenerators.d.ts +1 -20
- package/dist/virtuals/lib/pathGenerators.js +1 -66
- package/dist/virtuals/lib/urlGen.d.ts +2 -1
- package/dist/virtuals/lib/urlGen.js +4 -24
- package/dist/virtuals/mailer/index.d.ts +4 -34
- package/dist/virtuals/mailer/index.js +3 -16
- package/dist/virtuals/plugins/dashboard-pages.d.ts +8 -8
- package/dist/virtuals/scripts/user-quick-tools.d.ts +3 -2
- package/dist/virtuals/scripts/user-quick-tools.js +135 -53
- package/dist/virtuals/sdk/effect/collectors.d.ts +1 -1
- package/dist/virtuals/sdk/effect/foldertree.d.ts +1 -1
- package/dist/virtuals/sdk/effect/parsers.js +1 -1
- package/dist/virtuals/sdk/index.d.ts +2 -1
- package/dist/virtuals/sdk/modules/auth.d.ts +6 -5
- package/dist/virtuals/sdk/modules/config.d.ts +272 -0
- package/dist/virtuals/sdk/modules/config.js +205 -0
- package/dist/virtuals/sdk/modules/get.d.ts +10 -23
- package/dist/virtuals/sdk/modules/get.js +27 -40
- package/dist/virtuals/sdk/modules/init.d.ts +4 -18
- package/dist/virtuals/sdk/modules/init.js +7 -8
- package/dist/virtuals/sdk/modules/notificationSettings.d.ts +5 -22
- package/dist/virtuals/sdk/modules/notificationSettings.js +7 -29
- package/dist/virtuals/sdk/modules/post.d.ts +5 -5
- package/dist/virtuals/sdk/modules/post.js +14 -9
- package/dist/virtuals/sdk/modules/rest_api.d.ts +3 -3
- package/dist/virtuals/sdk/modules/update.d.ts +19 -19
- package/dist/virtuals/sdk/modules/update.js +28 -25
- package/dist/virtuals/sdk/sdkCore.d.ts +5 -3
- package/dist/virtuals/sdk/sdkCore.js +9 -4
- package/dist/virtuals/sdk/types/index.d.ts +4 -3
- package/dist/virtuals/sdk/types/tableDefs.d.ts +5 -4
- package/dist/virtuals/sdk/types/tsAlias.d.ts +4 -0
- package/dist/virtuals/sdk/utils.d.ts +3 -2
- package/dist/virtuals/utils.d.ts +21 -17
- package/dist/virtuals/utils.js +10 -6
- package/package.json +15 -20
- package/src/cli/users/steps/libsqlCreateUsers.ts +2 -4
- package/src/cli/users/steps/libsqlModifyUsers.ts +2 -4
- package/src/components/auth/OAuthButton.astro +1 -1
- package/src/components/auth/OAuthButtonStack.astro +1 -1
- package/src/components/auth/component-scripts/formListener.ts +1 -1
- package/src/components/dashboard/BaseHead.astro +6 -17
- package/src/components/dashboard/DashboardGrid.astro +2 -2
- package/src/components/dashboard/DashboardGridItem.astro +2 -1
- package/src/components/dashboard/DashboardPageHeader.astro +8 -4
- package/src/components/dashboard/DoubleSidebar.astro +2 -2
- package/src/components/dashboard/LoginChecker.astro +3 -2
- package/src/components/dashboard/MainSidebarContent.astro +16 -12
- package/src/components/dashboard/PageHeader.astro +3 -2
- package/src/components/dashboard/SidebarLink.astro +5 -5
- package/src/components/dashboard/SidebarPluginLink.astro +3 -3
- package/src/components/dashboard/SingleSidebar.astro +2 -2
- package/src/components/dashboard/configuration/ConfigForm.astro +49 -47
- package/src/components/dashboard/configuration/LoginPreview.astro +6 -4
- package/src/components/dashboard/content-mgmt/CreateFolder.astro +3 -2
- package/src/components/dashboard/content-mgmt/CreatePage.astro +8 -5
- package/src/components/dashboard/content-mgmt/EditFolder.astro +3 -2
- package/src/components/dashboard/content-mgmt/EditPage.astro +25 -13
- package/src/components/dashboard/content-mgmt/InnerSidebarElement.astro +23 -15
- package/src/components/dashboard/content-mgmt/PageHeader.astro +23 -14
- package/src/components/dashboard/content-mgmt/PluginFields.astro +6 -1
- package/src/components/dashboard/content-mgmt/TreeRenderer.astro +6 -6
- package/src/components/dashboard/content-mgmt/TreeSidebarFolder.astro +4 -4
- package/src/components/dashboard/content-mgmt/TreeSidebarLink.astro +4 -4
- package/src/components/dashboard/plugins/SettingsRenderer.astro +6 -1
- package/src/components/dashboard/profile/APITokens.astro +14 -8
- package/src/components/dashboard/profile/BasicInfo.astro +8 -4
- package/src/components/dashboard/profile/Notifications.astro +7 -4
- package/src/components/dashboard/profile/SocialSignin.astro +8 -5
- package/src/components/dashboard/profile/UpdatePassword.astro +6 -3
- package/src/components/dashboard/sidebar/UserAccount.astro +1 -2
- package/src/components/dashboard/sidebar/VersionCheck.astro +7 -7
- package/src/components/dashboard/sidebar/VersionCheckChangelog.astro +28 -6
- package/src/components/dashboard/sidebar-modals/UserManagementModals.astro +8 -3
- package/src/components/dashboard/sidebar-modals/VersionModal.astro +16 -15
- package/src/components/dashboard/sidebarConfig.ts +8 -8
- package/src/components/dashboard/user-mgmt/InnerSidebarElement.astro +16 -9
- package/src/components/dashboard/user-mgmt/RankCheck.astro +6 -8
- package/src/components/dashboard/user-mgmt/SocialSignin.astro +9 -10
- package/src/components/dashboard/user-mgmt/UserListItem.astro +8 -6
- package/src/components/default-grid-items/Recently-created-pages.astro +11 -9
- package/src/components/default-grid-items/Recently-signed-up.astro +8 -8
- package/src/components/default-grid-items/Recently-updated-pages.astro +11 -9
- package/src/components/default-grid-items/Totals.astro +7 -6
- package/src/components/first-time-setup/PageHeader.astro +4 -3
- package/src/components/shared/SSRUser.astro +200 -0
- package/src/components/shared/head/Favicons.astro +6 -0
- package/src/components/shared/head/Global.astro +4 -0
- package/src/components/shared/head/TitleTags.astro +14 -0
- package/src/config.ts +1 -4
- package/src/consts.ts +67 -1
- package/src/db/config.ts +43 -2
- package/src/handlers/astroConfigCheck.ts +1 -1
- package/src/handlers/changelog.ts +67 -0
- package/src/handlers/index.ts +1 -2
- package/src/handlers/pluginHandler.ts +16 -9
- package/src/index.ts +142 -121
- package/src/integrations/dynamic-sitemap/index.ts +1 -1
- package/src/integrations/webVitals/checkForWebVitalsPlugin.ts +3 -3
- package/src/integrations/webVitals/dashboard-grid-items/CoreVitals.astro +1 -1
- package/src/integrations/webVitals/dashboard-grid-items/MetricCard.astro +3 -2
- package/src/integrations/webVitals/dashboard-grid-items/SummaryCard.astro +2 -2
- package/src/integrations/webVitals/dashboard-grid-items/metric.css +17 -17
- package/src/integrations/webVitals/dashboard-grid-items/shared.ts +7 -7
- package/src/integrations/webVitals/pages/analytics/body.astro +10 -9
- package/src/layouts/AuthLayout.astro +7 -18
- package/src/layouts/DashboardLayout.astro +3 -2
- package/src/layouts/FirstTimeSetupLayout.astro +7 -18
- package/src/middleware/index.ts +3 -19
- package/src/middleware/utils.ts +7 -4
- package/src/routes/api/auth/login.ts +1 -6
- package/src/routes/api/auth/logout.ts +3 -2
- package/src/routes/api/auth/register.ts +1 -7
- package/src/routes/api/dashboard/config.ts +3 -2
- package/src/routes/api/dashboard/content/page.ts +6 -6
- package/src/routes/api/dashboard/create-user-invite.ts +3 -2
- package/src/routes/api/dashboard/create-user.ts +21 -23
- package/src/routes/api/dashboard/email-notification-settings-site.ts +27 -2
- package/src/routes/api/dashboard/profile.ts +1 -1
- package/src/routes/api/dashboard/reset-password.ts +1 -1
- package/src/routes/api/dashboard/users.ts +33 -15
- package/src/routes/api/dashboard/verify-email.ts +5 -2
- package/src/routes/api/dashboard/verify-session.ts +3 -2
- package/src/routes/api/rest/v1/pages/[id]/index.ts +3 -13
- package/src/routes/api/rest/v1/users/[id].ts +24 -23
- package/src/routes/api/rest/v1/users/index.ts +1 -1
- package/src/routes/api/sdk/utils/changelog.ts +2 -143
- package/src/routes/auth/login.astro +16 -9
- package/src/routes/auth/signup.astro +2 -1
- package/src/routes/dashboard/configuration.astro +3 -2
- package/src/routes/dashboard/content-management/createfolder.astro +1 -1
- package/src/routes/dashboard/content-management/createpage.astro +1 -1
- package/src/routes/dashboard/content-management/diff.astro +8 -5
- package/src/routes/dashboard/content-management/index.astro +1 -1
- package/src/routes/dashboard/password-reset.astro +8 -5
- package/src/routes/dashboard/plugins/[plugin].astro +4 -3
- package/src/routes/dashboard/smtp-configuration.astro +21 -10
- package/src/routes/dashboard/unverified-email.astro +2 -4
- package/src/routes/dashboard/user-management/edit.astro +30 -22
- package/src/routes/dashboard/user-management/index.astro +2 -2
- package/src/routes/error-pages/404.astro +1 -1
- package/src/routes/firstTimeSetupRoutes/1-start.astro +15 -14
- package/src/routes/firstTimeSetupRoutes/2-next.astro +14 -11
- package/src/routes/firstTimeSetupRoutes/3-done.astro +3 -2
- package/src/routes/firstTimeSetupRoutes/api/step-2.ts +1 -1
- package/src/schemas/plugins/shared.ts +13 -25
- package/src/styles/404.css +1 -1
- package/src/styles/code-component.css +8 -8
- package/src/styles/dashboard-base.css +29 -29
- package/src/styles/dashboard-diff.css +31 -31
- package/src/types.ts +3 -20
- package/src/utils/effects/smtp.ts +8 -4
- package/src/utils/safeString.ts +1 -6
- package/src/utils/stripIconify.ts +20 -0
- package/src/utils/tinyMDParser.ts +7 -7
- package/src/virtual.d.ts +17 -60
- package/src/virtuals/auth/core.ts +82 -0
- package/src/virtuals/auth/index.ts +1 -4
- package/src/virtuals/i18n/LanguageSelector.astro +1 -1
- package/src/virtuals/i18n/client.ts +115 -11
- package/src/virtuals/i18n/config.ts +154 -3
- package/src/virtuals/i18n/{index.ts → server.ts} +42 -46
- package/src/virtuals/i18n/v-files.ts +122 -0
- package/src/virtuals/lib/head.ts +1 -114
- package/src/virtuals/lib/pathGenerators.ts +1 -72
- package/src/virtuals/lib/urlGen.ts +4 -29
- package/src/virtuals/mailer/index.ts +7 -34
- package/src/virtuals/scripts/user-quick-tools.ts +151 -59
- package/src/virtuals/sdk/effect/parsers.ts +1 -1
- package/src/virtuals/sdk/modules/auth.ts +2 -1
- package/src/virtuals/sdk/modules/config.ts +602 -0
- package/src/virtuals/sdk/modules/get.ts +32 -48
- package/src/virtuals/sdk/modules/init.ts +18 -26
- package/src/virtuals/sdk/modules/notificationSettings.ts +8 -44
- package/src/virtuals/sdk/modules/post.ts +17 -18
- package/src/virtuals/sdk/modules/update.ts +31 -29
- package/src/virtuals/sdk/sdkCore.ts +5 -0
- package/src/virtuals/sdk/types/index.ts +4 -8
- package/src/virtuals/sdk/types/tableDefs.ts +4 -4
- package/src/virtuals/sdk/types/tsAlias.ts +4 -0
- package/src/virtuals/sdk/utils.ts +2 -2
- package/src/virtuals/utils.ts +29 -25
- package/ui.d.ts +1301 -274
- package/dist/components/first-time-setup/TabItem.astro +0 -44
- package/dist/components/first-time-setup/Tabs.astro +0 -170
- package/dist/handlers/changelog/changelogLoader.d.ts +0 -15
- package/dist/handlers/changelog/changelogLoader.js +0 -104
- package/dist/handlers/changelog/index.d.ts +0 -1
- package/dist/handlers/changelog/index.js +0 -53
- package/dist/handlers/scriptHandler.d.ts +0 -30
- package/dist/handlers/scriptHandler.js +0 -25
- package/dist/utils/addIntegrationArray.d.ts +0 -24
- package/dist/utils/addIntegrationArray.js +0 -11
- package/dist/utils/getLatestVersion.d.ts +0 -12
- package/dist/utils/getLatestVersion.js +0 -36
- package/dist/utils/integrationLogger.d.ts +0 -8
- package/dist/utils/integrationLogger.js +0 -23
- package/dist/utils/jsonUtils.d.ts +0 -13
- package/dist/utils/jsonUtils.js +0 -11
- package/dist/utils/pageTypeFilter.d.ts +0 -2
- package/dist/utils/pageTypeFilter.js +0 -16
- package/dist/virtuals/auth/encryption.d.ts +0 -46
- package/dist/virtuals/auth/encryption.js +0 -82
- package/dist/virtuals/auth/password.d.ts +0 -47
- package/dist/virtuals/auth/password.js +0 -147
- package/dist/virtuals/auth/session.d.ts +0 -77
- package/dist/virtuals/auth/session.js +0 -146
- package/dist/virtuals/auth/user.d.ts +0 -155
- package/dist/virtuals/auth/user.js +0 -251
- package/dist/virtuals/auth/utils/lists/passwords.d.ts +0 -2
- package/dist/virtuals/auth/utils/lists/passwords.js +0 -10006
- package/dist/virtuals/auth/utils/lists/usernames.d.ts +0 -2
- package/dist/virtuals/auth/utils/lists/usernames.js +0 -547
- package/dist/virtuals/auth/utils/scrypt.d.ts +0 -17
- package/dist/virtuals/auth/utils/scrypt.js +0 -30
- package/dist/virtuals/auth/utils/unsafeCheck.d.ts +0 -34
- package/dist/virtuals/auth/utils/unsafeCheck.js +0 -39
- package/dist/virtuals/i18n/index.d.ts +0 -2471
- package/dist/virtuals/lib/jsonUtils.d.ts +0 -2
- package/dist/virtuals/lib/jsonUtils.js +0 -14
- package/dist/virtuals/lib/removeLeadingTrailingSlashes.d.ts +0 -10
- package/dist/virtuals/lib/removeLeadingTrailingSlashes.js +0 -5
- package/src/components/first-time-setup/TabItem.astro +0 -44
- package/src/components/first-time-setup/Tabs.astro +0 -170
- package/src/handlers/changelog/changelogLoader.ts +0 -138
- package/src/handlers/changelog/index.ts +0 -67
- package/src/handlers/scriptHandler.ts +0 -86
- package/src/utils/addIntegrationArray.ts +0 -35
- package/src/utils/getLatestVersion.ts +0 -67
- package/src/utils/integrationLogger.ts +0 -29
- package/src/utils/jsonUtils.ts +0 -20
- package/src/utils/pageTypeFilter.ts +0 -13
- package/src/virtuals/auth/encryption.ts +0 -148
- package/src/virtuals/auth/password.ts +0 -279
- package/src/virtuals/auth/session.ts +0 -290
- package/src/virtuals/auth/user.ts +0 -501
- package/src/virtuals/auth/utils/lists/passwords.ts +0 -10004
- package/src/virtuals/auth/utils/lists/usernames.ts +0 -546
- package/src/virtuals/auth/utils/scrypt.ts +0 -42
- package/src/virtuals/auth/utils/unsafeCheck.ts +0 -72
- package/src/virtuals/lib/jsonUtils.ts +0 -11
- package/src/virtuals/lib/removeLeadingTrailingSlashes.ts +0 -11
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
import { eq } from 'astro:db';
|
|
2
|
+
import {
|
|
3
|
+
CMSMailerConfigId,
|
|
4
|
+
CMSNotificationSettingsId,
|
|
5
|
+
CMSSiteConfigId,
|
|
6
|
+
Next_MailerConfigId,
|
|
7
|
+
Next_NotificationSettingsId,
|
|
8
|
+
Next_SiteConfigId,
|
|
9
|
+
} from '../../../consts.js';
|
|
10
|
+
import { Deepmerge, Effect } from '../../../effect.js';
|
|
11
|
+
import { AstroDB, type LibSQLDatabaseError } from '../effect/db.js';
|
|
12
|
+
import {
|
|
13
|
+
tsDynamicConfigSettings,
|
|
14
|
+
tsMailerConfig,
|
|
15
|
+
tsNotificationSettings,
|
|
16
|
+
tsSiteConfig,
|
|
17
|
+
} from '../tables.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Represents the inferred selection type for dynamic configuration settings.
|
|
21
|
+
*
|
|
22
|
+
* This type is derived from the `$inferSelect` property of `tsDynamicConfigSettings`,
|
|
23
|
+
* and is typically used to describe the shape of a dynamic configuration entry
|
|
24
|
+
* as it would be selected from the database or configuration source.
|
|
25
|
+
*/
|
|
26
|
+
export type RawDynamicConfigEntry = typeof tsDynamicConfigSettings.$inferSelect;
|
|
27
|
+
export type RawDynamicConfigInsert = typeof tsDynamicConfigSettings.$inferInsert;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Represents a dynamic configuration entry with a unique identifier and associated data.
|
|
31
|
+
*
|
|
32
|
+
* @template T - The type of the data stored in the configuration entry.
|
|
33
|
+
* @property id - A unique string identifier for the configuration entry.
|
|
34
|
+
* @property data - The configuration data of type T.
|
|
35
|
+
*/
|
|
36
|
+
export type DynamicConfigEntry<T> = {
|
|
37
|
+
id: string;
|
|
38
|
+
data: T;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Represents the legacy site configuration type, inferred from the shape of `tsSiteConfig`.
|
|
43
|
+
*
|
|
44
|
+
* This type is useful for maintaining compatibility with older site configuration structures.
|
|
45
|
+
*
|
|
46
|
+
* @see tsSiteConfig
|
|
47
|
+
*/
|
|
48
|
+
export type LegacySiteConfig = typeof tsSiteConfig;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Represents the type of the legacy mailer configuration object.
|
|
52
|
+
*
|
|
53
|
+
* This type is inferred from the shape of `tsMailerConfig`, allowing for strong typing
|
|
54
|
+
* and IntelliSense support wherever the legacy mailer configuration is used.
|
|
55
|
+
*
|
|
56
|
+
* @see tsMailerConfig
|
|
57
|
+
*/
|
|
58
|
+
export type LegacyMailerConfig = typeof tsMailerConfig;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Represents the type of the legacy notification settings object.
|
|
62
|
+
*
|
|
63
|
+
* This type is inferred from the shape of `tsNotificationSettings`.
|
|
64
|
+
* It is used to ensure compatibility with legacy notification settings
|
|
65
|
+
* throughout the codebase.
|
|
66
|
+
*
|
|
67
|
+
* @see tsNotificationSettings
|
|
68
|
+
*/
|
|
69
|
+
export type LegacyNotificationSettings = typeof tsNotificationSettings;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Represents the union of legacy configuration table types.
|
|
73
|
+
*
|
|
74
|
+
* @remarks
|
|
75
|
+
* This type is used to refer to any of the legacy configuration tables
|
|
76
|
+
* that may be present in the system, including site configuration,
|
|
77
|
+
* mailer configuration, and notification settings.
|
|
78
|
+
*
|
|
79
|
+
* @see LegacySiteConfig
|
|
80
|
+
* @see LegacyMailerConfig
|
|
81
|
+
* @see LegacyNotificationSettings
|
|
82
|
+
*/
|
|
83
|
+
export type LegacyTables = LegacySiteConfig | LegacyMailerConfig | LegacyNotificationSettings;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Base interface for dynamic configuration objects in StudioCMS.
|
|
87
|
+
*
|
|
88
|
+
* @property _config_version - The version identifier for the configuration schema.
|
|
89
|
+
*/
|
|
90
|
+
export interface StudioCMSDynamicConfigBase {
|
|
91
|
+
_config_version: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type ConfigFinal<T extends StudioCMSDynamicConfigBase> = Omit<T, '_config_version'>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Represents the configuration options for a StudioCMS site.
|
|
98
|
+
*
|
|
99
|
+
* @extends StudioCMSDynamicConfigBase
|
|
100
|
+
*
|
|
101
|
+
* @property {string} description - A brief description of the site.
|
|
102
|
+
* @property {string} title - The title of the site.
|
|
103
|
+
* @property {string | null | undefined} [defaultOgImage] - The default Open Graph image URL for social sharing.
|
|
104
|
+
* @property {string | null | undefined} [siteIcon] - The URL or path to the site's icon.
|
|
105
|
+
* @property {string | undefined} [loginPageBackground] - The background image or color for the login page.
|
|
106
|
+
* @property {string | null | undefined} [loginPageCustomImage] - A custom image for the login page.
|
|
107
|
+
* @property {boolean | undefined} [enableDiffs] - Whether to enable content diffs.
|
|
108
|
+
* @property {number | undefined} [diffPerPage] - The number of diffs to display per page.
|
|
109
|
+
* @property {string[]} [gridItems] - List of grid item identifiers for the site layout.
|
|
110
|
+
* @property {boolean | undefined} [enableMailer] - Whether to enable the mailer functionality.
|
|
111
|
+
* @property {boolean | undefined} [hideDefaultIndex] - Whether to hide the default index page.
|
|
112
|
+
*/
|
|
113
|
+
export interface StudioCMSSiteConfig extends StudioCMSDynamicConfigBase {
|
|
114
|
+
description: string;
|
|
115
|
+
title: string;
|
|
116
|
+
defaultOgImage?: string | null | undefined;
|
|
117
|
+
siteIcon?: string | null | undefined;
|
|
118
|
+
loginPageBackground?: string | undefined;
|
|
119
|
+
loginPageCustomImage?: string | null | undefined;
|
|
120
|
+
enableDiffs?: boolean | undefined;
|
|
121
|
+
diffPerPage?: number | undefined;
|
|
122
|
+
gridItems?: string[];
|
|
123
|
+
enableMailer?: boolean | undefined;
|
|
124
|
+
hideDefaultIndex?: boolean | undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Configuration options for the StudioCMS mailer module.
|
|
129
|
+
*
|
|
130
|
+
* @extends StudioCMSDynamicConfigBase
|
|
131
|
+
*
|
|
132
|
+
* @property host - The hostname or IP address of the mail server.
|
|
133
|
+
* @property port - The port number to connect to the mail server.
|
|
134
|
+
* @property secure - Whether to use a secure connection (TLS/SSL).
|
|
135
|
+
* @property proxy - Optional. Proxy server URL to use for outgoing mail connections.
|
|
136
|
+
* @property auth_user - Optional. Username for mail server authentication.
|
|
137
|
+
* @property auth_pass - Optional. Password for mail server authentication.
|
|
138
|
+
* @property tls_rejectUnauthorized - Optional. Whether to reject unauthorized TLS certificates.
|
|
139
|
+
* @property tls_servername - Optional. Server name for TLS verification.
|
|
140
|
+
* @property default_sender - The default email address to use as the sender.
|
|
141
|
+
*/
|
|
142
|
+
export interface StudioCMSMailerConfig extends StudioCMSDynamicConfigBase {
|
|
143
|
+
host: string;
|
|
144
|
+
port: number;
|
|
145
|
+
secure: boolean;
|
|
146
|
+
proxy?: string | null | undefined;
|
|
147
|
+
auth_user?: string | null | undefined;
|
|
148
|
+
auth_pass?: string | null | undefined;
|
|
149
|
+
tls_rejectUnauthorized?: boolean | null | undefined;
|
|
150
|
+
tls_servername?: string | null | undefined;
|
|
151
|
+
default_sender: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Represents the notification settings configuration for StudioCMS.
|
|
156
|
+
* Extends the base dynamic configuration interface.
|
|
157
|
+
*
|
|
158
|
+
* @property emailVerification - Optional. If true, enables email verification for users.
|
|
159
|
+
* @property requireAdminVerification - Optional. If true, requires admin verification for certain actions.
|
|
160
|
+
* @property requireEditorVerification - Optional. If true, requires editor verification for certain actions.
|
|
161
|
+
* @property oAuthBypassVerification - Optional. If true, allows OAuth users to bypass verification.
|
|
162
|
+
*/
|
|
163
|
+
export interface StudioCMSNotificationSettings extends StudioCMSDynamicConfigBase {
|
|
164
|
+
emailVerification?: boolean | undefined;
|
|
165
|
+
requireAdminVerification?: boolean | undefined;
|
|
166
|
+
requireEditorVerification?: boolean | undefined;
|
|
167
|
+
oAuthBypassVerification?: boolean | undefined;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Casts the `data` property of a `RawDynamicConfigEntry` to the specified generic type `T`
|
|
172
|
+
* and returns a new `DynamicConfigEntry<T>` object.
|
|
173
|
+
*
|
|
174
|
+
* @typeParam T - The type to cast the `data` property to.
|
|
175
|
+
* @param param0 - An object containing the `data` to cast and its associated `id`.
|
|
176
|
+
* @param param0.data - The raw data to be cast to type `T`.
|
|
177
|
+
* @param param0.id - The identifier for the config entry.
|
|
178
|
+
* @returns A `DynamicConfigEntry<T>` object with the `data` property cast to type `T`.
|
|
179
|
+
*/
|
|
180
|
+
export const castType = <T>({ data, id }: RawDynamicConfigEntry): DynamicConfigEntry<T> => ({
|
|
181
|
+
id,
|
|
182
|
+
data: data as T,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The current version of the configuration schema used by the SDK.
|
|
187
|
+
*
|
|
188
|
+
* This constant should be updated whenever breaking changes are made to the configuration format.
|
|
189
|
+
*
|
|
190
|
+
* @remarks
|
|
191
|
+
* Used to ensure compatibility between different versions of configuration files and the SDK.
|
|
192
|
+
*
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
export const CURRENT_CONFIG_VERSION = '1.0.0';
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Migrates a legacy site configuration object to the latest `StudioCMSSiteConfig` format.
|
|
199
|
+
*
|
|
200
|
+
* @param params - The legacy site configuration object, destructured to extract `id`, `gridItems`, and the rest of the config.
|
|
201
|
+
* @param params.id - The unique identifier of the site (legacy, not used in the new config).
|
|
202
|
+
* @param params.gridItems - The grid items from the legacy config, which will be cast to a string array.
|
|
203
|
+
* @param params.legacyConfig - The remaining properties of the legacy config.
|
|
204
|
+
* @returns The migrated site configuration object with the latest config version and normalized `gridItems`.
|
|
205
|
+
*/
|
|
206
|
+
export const migrateLegacySiteConfig = ({
|
|
207
|
+
id,
|
|
208
|
+
gridItems,
|
|
209
|
+
...legacyConfig
|
|
210
|
+
}: typeof tsSiteConfig.$inferSelect): StudioCMSSiteConfig => ({
|
|
211
|
+
...legacyConfig,
|
|
212
|
+
gridItems: (gridItems ?? []) as string[],
|
|
213
|
+
_config_version: CURRENT_CONFIG_VERSION,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Migrates a legacy mailer configuration object to the current configuration version.
|
|
218
|
+
*
|
|
219
|
+
* @param param0 - The legacy mailer configuration object, destructured to extract the `id` and the rest of the configuration.
|
|
220
|
+
* @returns The updated mailer configuration object with the current configuration version applied.
|
|
221
|
+
*/
|
|
222
|
+
export const migrateLegacyMailerConfig = ({
|
|
223
|
+
id,
|
|
224
|
+
...legacyConfig
|
|
225
|
+
}: typeof tsMailerConfig.$inferSelect): StudioCMSMailerConfig => ({
|
|
226
|
+
...legacyConfig,
|
|
227
|
+
_config_version: CURRENT_CONFIG_VERSION,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Migrates legacy notification settings to the current configuration version.
|
|
232
|
+
*
|
|
233
|
+
* @param param0 - An object containing the legacy notification settings, including an `id` and other configuration properties.
|
|
234
|
+
* @returns The migrated notification settings object with the updated `_config_version`.
|
|
235
|
+
*/
|
|
236
|
+
export const migrateLegacyNotificationSettings = ({
|
|
237
|
+
id,
|
|
238
|
+
...legacyConfig
|
|
239
|
+
}: typeof tsNotificationSettings.$inferSelect): StudioCMSNotificationSettings => ({
|
|
240
|
+
...legacyConfig,
|
|
241
|
+
_config_version: CURRENT_CONFIG_VERSION,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Provides configuration management services for StudioCMS using an effect-based service pattern.
|
|
246
|
+
*
|
|
247
|
+
* This service handles CRUD operations for dynamic configuration entries, supports migration from legacy tables,
|
|
248
|
+
* and exposes specialized interfaces for site, mailer, and notification configuration management.
|
|
249
|
+
*
|
|
250
|
+
* @remarks
|
|
251
|
+
* - Uses dependency injection for database and deep merge utilities.
|
|
252
|
+
* - Supports versioned dynamic configs and automatic migration from legacy schemas.
|
|
253
|
+
* - Exposes effect-based methods for creating, retrieving, updating, and migrating configuration entries.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const configService = Effect.service(SDKCore_CONFIG);
|
|
258
|
+
* const siteConfig = yield* configService.siteConfig.get();
|
|
259
|
+
* yield* configService.siteConfig.update({ ...siteConfig, someField: 'newValue' });
|
|
260
|
+
* ```
|
|
261
|
+
*
|
|
262
|
+
* @service
|
|
263
|
+
* @module studiocms/sdk/modules/SDKCore_CONFIG
|
|
264
|
+
*/
|
|
265
|
+
export class SDKCore_CONFIG extends Effect.Service<SDKCore_CONFIG>()(
|
|
266
|
+
'studiocms/sdk/modules/SDKCore_CONFIG',
|
|
267
|
+
{
|
|
268
|
+
dependencies: [AstroDB.Default, Deepmerge.Default],
|
|
269
|
+
effect: Effect.gen(function* () {
|
|
270
|
+
const [dbService, { merge }] = yield* Effect.all([AstroDB, Deepmerge]);
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Inserts a new dynamic configuration entry into the database.
|
|
274
|
+
*
|
|
275
|
+
* @param entry - The raw dynamic configuration entry to insert.
|
|
276
|
+
* @returns A promise that resolves to the inserted entry.
|
|
277
|
+
*
|
|
278
|
+
* @remarks
|
|
279
|
+
* This function uses the `dbService.makeQuery` utility to perform the insertion
|
|
280
|
+
* and returns the newly inserted record from the `tsDynamicConfigSettings` table.
|
|
281
|
+
*/
|
|
282
|
+
const _insert = dbService.makeQuery((ex, entry: RawDynamicConfigInsert) =>
|
|
283
|
+
ex((db) => db.insert(tsDynamicConfigSettings).values(entry).returning().get())
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Creates a query function to select a dynamic configuration setting by its ID.
|
|
288
|
+
*
|
|
289
|
+
* @param ex - The database executor function.
|
|
290
|
+
* @param id - The unique identifier of the dynamic configuration setting.
|
|
291
|
+
* @returns A promise that resolves to the configuration setting matching the provided ID.
|
|
292
|
+
*/
|
|
293
|
+
const _select = dbService.makeQuery((ex, id: string) =>
|
|
294
|
+
ex((db) =>
|
|
295
|
+
db.select().from(tsDynamicConfigSettings).where(eq(tsDynamicConfigSettings.id, id)).get()
|
|
296
|
+
)
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Updates a dynamic configuration entry in the database.
|
|
301
|
+
*
|
|
302
|
+
* @param entry - The `RawDynamicConfigEntry` object containing the updated configuration data.
|
|
303
|
+
* @returns A promise that resolves to the updated entry from the database.
|
|
304
|
+
*
|
|
305
|
+
* @remarks
|
|
306
|
+
* This function uses the `dbService.makeQuery` utility to perform an update operation
|
|
307
|
+
* on the `tsDynamicConfigSettings` table, setting the fields based on the provided `entry`
|
|
308
|
+
* where the `id` matches. The updated entry is returned after the operation.
|
|
309
|
+
*/
|
|
310
|
+
const _update = dbService.makeQuery((ex, entry: RawDynamicConfigEntry) =>
|
|
311
|
+
ex((db) =>
|
|
312
|
+
db
|
|
313
|
+
.update(tsDynamicConfigSettings)
|
|
314
|
+
.set(entry)
|
|
315
|
+
.where(eq(tsDynamicConfigSettings.id, entry.id))
|
|
316
|
+
.returning()
|
|
317
|
+
.get()
|
|
318
|
+
)
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Creates a new entry with the specified `id` and associated `data`.
|
|
323
|
+
*
|
|
324
|
+
* @template DataType - The type of the data to associate with the entry.
|
|
325
|
+
* @param id - The unique identifier for the entry.
|
|
326
|
+
* @param data - The data to be stored in the entry.
|
|
327
|
+
* @returns An Effect that, when executed, inserts the entry and yields the result.
|
|
328
|
+
*/
|
|
329
|
+
const create = Effect.fn(function* <DataType>(id: string, data: DataType) {
|
|
330
|
+
const entry = castType<DataType>({ id, data });
|
|
331
|
+
return yield* _insert(entry) as Effect.Effect<
|
|
332
|
+
DynamicConfigEntry<DataType>,
|
|
333
|
+
LibSQLDatabaseError
|
|
334
|
+
>;
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Retrieves an entry by its ID and casts it to the specified data type.
|
|
339
|
+
*
|
|
340
|
+
* @template DataType - The expected type of the returned entry.
|
|
341
|
+
* @param id - The unique identifier of the entry to retrieve.
|
|
342
|
+
* @returns The entry cast to the specified type, or `undefined` if not found.
|
|
343
|
+
*/
|
|
344
|
+
const get = Effect.fn(function* <DataType>(id: string) {
|
|
345
|
+
const entry = yield* _select(id);
|
|
346
|
+
if (!entry) return undefined;
|
|
347
|
+
return castType<DataType>(entry);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Updates an entry with the specified `id` and `data`.
|
|
352
|
+
*
|
|
353
|
+
* @template DataType - The type of the data to update.
|
|
354
|
+
* @param id - The unique identifier of the entry to update.
|
|
355
|
+
* @param data - The new data to associate with the entry.
|
|
356
|
+
* @returns An Effect yielding the result of the update operation.
|
|
357
|
+
*/
|
|
358
|
+
const update = Effect.fn(function* <DataType>(id: string, data: DataType) {
|
|
359
|
+
const entry = castType<DataType>({ id, data });
|
|
360
|
+
return yield* _update(entry) as Effect.Effect<
|
|
361
|
+
DynamicConfigEntry<DataType>,
|
|
362
|
+
LibSQLDatabaseError
|
|
363
|
+
>;
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Runs a migration for a legacy configuration table entry to a new configuration format.
|
|
368
|
+
*
|
|
369
|
+
* This function retrieves a legacy configuration entry from the specified table using the provided legacy ID,
|
|
370
|
+
* applies a migration function to transform it into the new configuration format, and then creates a new entry
|
|
371
|
+
* with the specified new ID.
|
|
372
|
+
*
|
|
373
|
+
* @typeParam Table - The legacy table type to migrate from.
|
|
374
|
+
* @typeParam LegacyConfig - The inferred select type of the legacy table.
|
|
375
|
+
* @typeParam Config - The new configuration type to migrate to.
|
|
376
|
+
* @param opts - The migration options.
|
|
377
|
+
* @param opts.table - The legacy table to migrate from.
|
|
378
|
+
* @param opts.legacyId - The ID of the legacy configuration entry.
|
|
379
|
+
* @param opts.migrate - The migration function that transforms the legacy configuration to the new format.
|
|
380
|
+
* @param opts.newId - The ID for the new configuration entry.
|
|
381
|
+
* @returns The result of the creation operation, or `undefined` if the legacy configuration was not found.
|
|
382
|
+
*/
|
|
383
|
+
const runMigration = Effect.fn(function* <
|
|
384
|
+
Table extends LegacyTables,
|
|
385
|
+
LegacyConfig extends Table extends LegacySiteConfig
|
|
386
|
+
? LegacySiteConfig['$inferSelect']
|
|
387
|
+
: Table extends LegacyMailerConfig
|
|
388
|
+
? LegacyMailerConfig['$inferSelect']
|
|
389
|
+
: Table extends LegacyNotificationSettings
|
|
390
|
+
? LegacyNotificationSettings['$inferSelect']
|
|
391
|
+
: never,
|
|
392
|
+
Config extends Table extends LegacySiteConfig
|
|
393
|
+
? StudioCMSSiteConfig
|
|
394
|
+
: Table extends LegacyMailerConfig
|
|
395
|
+
? StudioCMSMailerConfig
|
|
396
|
+
: Table extends LegacyNotificationSettings
|
|
397
|
+
? StudioCMSNotificationSettings
|
|
398
|
+
: never,
|
|
399
|
+
>(opts: {
|
|
400
|
+
table: Table;
|
|
401
|
+
legacyId: string | number;
|
|
402
|
+
migrate: (legacyConfig: LegacyConfig) => Config;
|
|
403
|
+
newId: string;
|
|
404
|
+
}) {
|
|
405
|
+
const { table, legacyId, migrate, newId } = opts;
|
|
406
|
+
|
|
407
|
+
const legacyConfig = (yield* dbService.execute((db) =>
|
|
408
|
+
db.select().from(table).where(eq(table.id, legacyId)).get()
|
|
409
|
+
)) as LegacyConfig | undefined;
|
|
410
|
+
|
|
411
|
+
if (!legacyConfig) return;
|
|
412
|
+
|
|
413
|
+
const newConfig = migrate(legacyConfig);
|
|
414
|
+
return yield* create(newId, newConfig);
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Retrieves a dynamic configuration entry by its ID. If the entry does not exist
|
|
419
|
+
* or its configuration version does not match the current version, runs a migration
|
|
420
|
+
* using the provided migration options and returns the migrated entry.
|
|
421
|
+
*
|
|
422
|
+
* @template DataType - The type of the dynamic configuration data.
|
|
423
|
+
* @param id - The unique identifier of the configuration entry to retrieve.
|
|
424
|
+
* @param migrationOpts - Options for migrating legacy configuration entries.
|
|
425
|
+
* @param migrationOpts.table - The legacy table to use for migration.
|
|
426
|
+
* @param migrationOpts.legacyId - The identifier of the legacy configuration entry.
|
|
427
|
+
* @param migrationOpts.migrate - A function that transforms the legacy configuration into the new format.
|
|
428
|
+
* @param migrationOpts.newId - The new identifier to assign to the migrated configuration entry.
|
|
429
|
+
* @returns The configuration entry of type `DataType`, either retrieved or migrated.
|
|
430
|
+
*/
|
|
431
|
+
const dynamicGet = Effect.fn(function* <DataType extends StudioCMSDynamicConfigBase>(
|
|
432
|
+
id: string,
|
|
433
|
+
migrationOpts: {
|
|
434
|
+
table: LegacyTables;
|
|
435
|
+
legacyId: string | number;
|
|
436
|
+
// biome-ignore lint/suspicious/noExplicitAny: the actual type is too complex
|
|
437
|
+
migrate: (legacyConfig: any) => DataType;
|
|
438
|
+
newId: string;
|
|
439
|
+
}
|
|
440
|
+
) {
|
|
441
|
+
const entry = yield* get<DataType>(id);
|
|
442
|
+
// If missing, migrate from legacy (first-time population)
|
|
443
|
+
if (!entry) {
|
|
444
|
+
return yield* runMigration(migrationOpts) as Effect.Effect<
|
|
445
|
+
DynamicConfigEntry<DataType> | undefined,
|
|
446
|
+
LibSQLDatabaseError
|
|
447
|
+
>;
|
|
448
|
+
}
|
|
449
|
+
// If present but outdated, bump in-place to avoid UNIQUE conflicts and preserve user data
|
|
450
|
+
if (entry.data._config_version !== CURRENT_CONFIG_VERSION) {
|
|
451
|
+
return yield* update<DataType>(id, {
|
|
452
|
+
...entry.data,
|
|
453
|
+
_config_version: CURRENT_CONFIG_VERSION,
|
|
454
|
+
} as DataType);
|
|
455
|
+
}
|
|
456
|
+
return entry;
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Updates a dynamic configuration entry by merging new data into the existing entry.
|
|
461
|
+
*
|
|
462
|
+
* @template DataType - The type of the dynamic configuration data.
|
|
463
|
+
* @param id - The unique identifier of the configuration entry to update.
|
|
464
|
+
* @param data - The new data to merge into the existing configuration entry.
|
|
465
|
+
* @returns The updated configuration entry if it exists, otherwise `undefined`.
|
|
466
|
+
*
|
|
467
|
+
* @remarks
|
|
468
|
+
* This function retrieves the existing configuration entry by its ID, merges the provided data into it,
|
|
469
|
+
* and then updates the entry in the data store. If the entry does not exist, it returns `undefined`.
|
|
470
|
+
*/
|
|
471
|
+
const dynamicUpdate = Effect.fn(function* <DataType extends StudioCMSDynamicConfigBase>(
|
|
472
|
+
id: string,
|
|
473
|
+
data: DataType
|
|
474
|
+
) {
|
|
475
|
+
const entry = yield* get<DataType>(id);
|
|
476
|
+
if (!entry) return undefined;
|
|
477
|
+
const updatedEntry = (yield* merge((m) => m(entry.data, data))) as DataType;
|
|
478
|
+
return yield* update<DataType>(id, updatedEntry) as Effect.Effect<
|
|
479
|
+
DynamicConfigEntry<DataType>,
|
|
480
|
+
LibSQLDatabaseError,
|
|
481
|
+
never
|
|
482
|
+
>;
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Provides methods to interact with the site configuration.
|
|
487
|
+
*/
|
|
488
|
+
const siteConfig = {
|
|
489
|
+
/**
|
|
490
|
+
* Retrieves the current site configuration.
|
|
491
|
+
*/
|
|
492
|
+
get: () =>
|
|
493
|
+
dynamicGet<StudioCMSSiteConfig>(Next_SiteConfigId, {
|
|
494
|
+
table: tsSiteConfig,
|
|
495
|
+
legacyId: CMSSiteConfigId,
|
|
496
|
+
migrate: migrateLegacySiteConfig,
|
|
497
|
+
newId: Next_SiteConfigId,
|
|
498
|
+
}),
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Updates the site configuration with the provided data.
|
|
502
|
+
* @param data The new configuration data, excluding the internal version field.
|
|
503
|
+
* @returns The updated site configuration.
|
|
504
|
+
*/
|
|
505
|
+
update: (data: ConfigFinal<StudioCMSSiteConfig>) =>
|
|
506
|
+
dynamicUpdate<StudioCMSSiteConfig>(Next_SiteConfigId, {
|
|
507
|
+
...data,
|
|
508
|
+
_config_version: CURRENT_CONFIG_VERSION,
|
|
509
|
+
}),
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Initializes the site configuration with the provided data.
|
|
513
|
+
* @param data The initial configuration data, excluding the internal version field.
|
|
514
|
+
* @returns The created site configuration.
|
|
515
|
+
*/
|
|
516
|
+
init: (data: ConfigFinal<StudioCMSSiteConfig>) =>
|
|
517
|
+
create<StudioCMSSiteConfig>(Next_SiteConfigId, {
|
|
518
|
+
...data,
|
|
519
|
+
_config_version: CURRENT_CONFIG_VERSION,
|
|
520
|
+
}),
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Provides methods to interact with the StudioCMS mailer configuration.
|
|
525
|
+
*/
|
|
526
|
+
const mailerConfig = {
|
|
527
|
+
/**
|
|
528
|
+
* Retrieves the current mailer configuration.
|
|
529
|
+
*/
|
|
530
|
+
get: () =>
|
|
531
|
+
dynamicGet<StudioCMSMailerConfig>(Next_MailerConfigId, {
|
|
532
|
+
table: tsMailerConfig,
|
|
533
|
+
legacyId: CMSMailerConfigId,
|
|
534
|
+
migrate: migrateLegacyMailerConfig,
|
|
535
|
+
newId: Next_MailerConfigId,
|
|
536
|
+
}),
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Updates the mailer configuration with the provided data.
|
|
540
|
+
* @param data The new configuration data, excluding the internal version field.
|
|
541
|
+
* @returns The updated mailer configuration.
|
|
542
|
+
*/
|
|
543
|
+
update: (data: ConfigFinal<StudioCMSMailerConfig>) =>
|
|
544
|
+
dynamicUpdate<StudioCMSMailerConfig>(Next_MailerConfigId, {
|
|
545
|
+
...data,
|
|
546
|
+
_config_version: CURRENT_CONFIG_VERSION,
|
|
547
|
+
}),
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Initializes the mailer configuration with the provided data.
|
|
551
|
+
* @param data The initial configuration data, excluding the internal version field.
|
|
552
|
+
* @returns The created mailer configuration.
|
|
553
|
+
*/
|
|
554
|
+
init: (data: ConfigFinal<StudioCMSMailerConfig>) =>
|
|
555
|
+
create<StudioCMSMailerConfig>(Next_MailerConfigId, {
|
|
556
|
+
...data,
|
|
557
|
+
_config_version: CURRENT_CONFIG_VERSION,
|
|
558
|
+
}),
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Provides methods to interact with the notification settings configuration.
|
|
563
|
+
*/
|
|
564
|
+
const notificationConfig = {
|
|
565
|
+
/**
|
|
566
|
+
* Retrieves the current notification settings.
|
|
567
|
+
*/
|
|
568
|
+
get: () =>
|
|
569
|
+
dynamicGet<StudioCMSNotificationSettings>(Next_NotificationSettingsId, {
|
|
570
|
+
table: tsNotificationSettings,
|
|
571
|
+
legacyId: CMSNotificationSettingsId,
|
|
572
|
+
migrate: migrateLegacyNotificationSettings,
|
|
573
|
+
newId: Next_NotificationSettingsId,
|
|
574
|
+
}),
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Updates the notification settings with the provided data.
|
|
578
|
+
* @param data The new notification settings, excluding the `_config_version` property.
|
|
579
|
+
* @returns A promise resolving to the updated `StudioCMSNotificationSettings`.
|
|
580
|
+
*/
|
|
581
|
+
update: (data: ConfigFinal<StudioCMSNotificationSettings>) =>
|
|
582
|
+
dynamicUpdate<StudioCMSNotificationSettings>(Next_NotificationSettingsId, {
|
|
583
|
+
...data,
|
|
584
|
+
_config_version: CURRENT_CONFIG_VERSION,
|
|
585
|
+
}),
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Initializes the notification settings with the provided data.
|
|
589
|
+
* @param data The initial configuration data, excluding the internal version field.
|
|
590
|
+
* @returns The created notification settings.
|
|
591
|
+
*/
|
|
592
|
+
init: (data: ConfigFinal<StudioCMSNotificationSettings>) =>
|
|
593
|
+
create<StudioCMSNotificationSettings>(Next_NotificationSettingsId, {
|
|
594
|
+
...data,
|
|
595
|
+
_config_version: CURRENT_CONFIG_VERSION,
|
|
596
|
+
}),
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
return { siteConfig, mailerConfig, notificationConfig } as const;
|
|
600
|
+
}),
|
|
601
|
+
}
|
|
602
|
+
) {}
|