studiocms 0.2.0 → 0.4.0
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 +122 -0
- package/dist/cli/add/index.d.ts +2 -2
- package/dist/cli/add/index.js +4 -3
- package/dist/cli/add/npm-utils.d.ts +6 -6
- package/dist/cli/add/tryToInstallPlugins.d.ts +1 -1
- package/dist/cli/add/tryToInstallPlugins.js +6 -5
- package/dist/cli/add/updateStudioCMSConfig.d.ts +1 -1
- package/dist/cli/add/updateStudioCMSConfig.js +3 -4
- package/dist/cli/add/validatePlugins.d.ts +1 -2
- package/dist/cli/add/validatePlugins.js +15 -9
- package/dist/cli/crypto/genJWT/index.d.ts +1 -1
- package/dist/cli/crypto/genJWT/index.js +8 -9
- package/dist/cli/crypto/index.d.ts +1 -1
- package/dist/cli/init/steps/env.js +14 -4
- package/dist/cli/init/steps/next.d.ts +1 -1
- package/dist/cli/init/steps/next.js +6 -5
- package/dist/cli/migrator/index.d.ts +1 -1
- package/dist/cli/migrator/index.js +2 -2
- package/dist/cli/users/index.d.ts +1 -1
- package/dist/cli/users/shared.js +2 -2
- package/dist/cli/users/steps/createUsers.js +7 -7
- package/dist/cli/users/steps/modifyUsers.js +2 -2
- package/dist/cli/users/steps/next.d.ts +1 -1
- package/dist/cli/utils/checkRequiredEnvVars.js +2 -2
- package/dist/cli/utils/context.d.ts +2 -4
- package/dist/cli/utils/context.js +1 -3
- package/dist/cli/utils/getCliDbClient.d.ts +1 -1
- package/dist/cli/utils/intro.d.ts +1 -1
- package/dist/cli/utils/loadConfig.d.ts +54 -49
- package/dist/cli/utils/loadConfig.js +5 -8
- package/dist/cli/utils/logger.js +3 -3
- package/dist/cli/utils/user-utils.d.ts +1 -1
- package/dist/cli/utils/user-utils.js +4 -3
- package/dist/client/apiClient.d.ts +4923 -0
- package/dist/client/apiClient.js +72 -0
- package/dist/config.d.ts +1734 -1
- package/dist/consts.d.ts +5 -5
- package/dist/consts.js +3 -2
- package/dist/db/plugins.d.ts +1 -1
- package/dist/db/plugins.js +5 -8
- package/dist/handlers/frontend/routes.d.ts +4 -18
- package/dist/handlers/frontend/routes.js +13 -152
- package/dist/handlers/frontend/types.d.ts +1 -1
- package/dist/handlers/frontend/utils.js +0 -18
- package/dist/handlers/pluginHandler.d.ts +34 -257
- package/dist/handlers/pluginHandler.js +92 -46
- package/dist/handlers/routeHandler.js +32 -11
- package/dist/handlers/setupDbStudio.d.ts +3 -1
- package/dist/handlers/setupDbStudio.js +19 -10
- package/dist/handlers/storage-manager/core/effectify-astro-context.d.ts +25 -0
- package/dist/handlers/storage-manager/core/effectify-astro-context.js +78 -0
- package/dist/handlers/storage-manager/no-op.d.ts +2 -2
- package/dist/handlers/storage-manager/no-op.js +2 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +10 -20
- package/dist/integrations/robots/index.d.ts +2 -2
- package/dist/integrations/robots/index.js +1 -3
- package/dist/integrations/robots/schema.d.ts +102 -273
- package/dist/integrations/robots/schema.js +220 -209
- package/dist/plugins/analytics/assets/schemas.d.ts +14 -9
- package/dist/plugins/analytics/assets/schemas.js +25 -17
- package/dist/plugins/analytics/db-client.d.ts +1 -1
- package/dist/plugins/analytics/index.d.ts +823 -3
- package/dist/plugins/analytics/index.js +4 -5
- package/dist/plugins/analytics/schemas.d.ts +54 -62
- package/dist/plugins/analytics/schemas.js +64 -13
- package/dist/plugins/analytics/table.d.ts +1 -1
- package/dist/plugins.d.ts +0 -1
- package/dist/schemas/config/api.d.ts +17 -0
- package/dist/schemas/config/api.js +14 -0
- package/dist/schemas/config/auth.d.ts +55 -59
- package/dist/schemas/config/auth.js +34 -11
- package/dist/schemas/config/dashboard.d.ts +43 -79
- package/dist/schemas/config/dashboard.js +43 -12
- package/dist/schemas/config/db.d.ts +15 -17
- package/dist/schemas/config/db.js +13 -5
- package/dist/schemas/config/developer.d.ts +33 -45
- package/dist/schemas/config/developer.js +22 -5
- package/dist/schemas/config/index.d.ts +398 -521
- package/dist/schemas/config/index.js +115 -57
- package/dist/schemas/config/sdk.d.ts +50 -196
- package/dist/schemas/config/sdk.js +61 -73
- package/dist/schemas/custom.d.ts +40 -0
- package/dist/schemas/custom.js +41 -0
- package/dist/schemas/external-schemas.d.ts +171 -0
- package/dist/schemas/external-schemas.js +179 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/plugins/i18n.d.ts +59 -39
- package/dist/schemas/plugins/i18n.js +42 -5
- package/dist/schemas/plugins/index.d.ts +7126 -10296
- package/dist/schemas/plugins/index.js +260 -276
- package/dist/schemas/plugins/shared.d.ts +1293 -3718
- package/dist/schemas/plugins/shared.js +320 -329
- package/dist/test-utils.d.ts +15 -4
- package/dist/test-utils.js +27 -11
- package/dist/toolbar/db-viewer/db-shared-types.d.ts +6 -6
- package/dist/toolbar/db-viewer/studio/connection.d.ts +8 -4
- package/dist/toolbar/db-viewer/studio/connection.js +2 -28
- package/dist/toolbar/db-viewer/studio/env/libsql.d.ts +7 -0
- package/dist/toolbar/db-viewer/studio/env/libsql.js +17 -0
- package/dist/toolbar/db-viewer/studio/env/mysql.d.ts +7 -0
- package/dist/toolbar/db-viewer/studio/env/mysql.js +23 -0
- package/dist/toolbar/db-viewer/studio/env/postgres.d.ts +7 -0
- package/dist/toolbar/db-viewer/studio/env/postgres.js +23 -0
- package/dist/toolbar/db-viewer/studio/index.js +20 -56
- package/dist/toolbar/db-viewer/studio/type.d.ts +1 -2
- package/dist/toolbar/db-viewer/studio/virtual-connection/libsql.d.ts +3 -0
- package/dist/toolbar/db-viewer/studio/virtual-connection/libsql.js +24 -0
- package/dist/toolbar/db-viewer/studio/virtual-connection/mysql.d.ts +3 -0
- package/dist/toolbar/db-viewer/studio/virtual-connection/mysql.js +9 -0
- package/dist/toolbar/db-viewer/studio/virtual-connection/postgres.d.ts +3 -0
- package/dist/toolbar/db-viewer/studio/virtual-connection/postgres.js +9 -0
- package/dist/toolbar/db-viewer/viewer.js +20 -21
- package/dist/types.d.ts +30 -0
- package/dist/utils/effects/smtp.d.ts +1 -1
- package/dist/utils/lang-helper.d.ts +10 -2
- package/dist/virtual.d.ts +35 -28
- package/dist/virtuals/auth/core.d.ts +5 -5
- package/dist/virtuals/auth/verify-email.d.ts +6 -6
- package/dist/virtuals/components/Generator.astro +2 -2
- package/dist/virtuals/components/Renderer.astro +9 -1
- package/dist/virtuals/components/renderFn.d.ts +3 -1
- package/dist/virtuals/components/renderFn.js +18 -0
- package/dist/virtuals/lib/headDefaults.d.ts +4 -2
- package/dist/virtuals/lib/headDefaults.js +0 -2
- package/dist/virtuals/lib/routeMap.d.ts +0 -12
- package/dist/virtuals/lib/routeMap.js +2 -14
- package/dist/virtuals/mailer/index.d.ts +3 -3
- package/dist/virtuals/notifier/index.d.ts +5 -5
- package/dist/virtuals/plugins/dashboard-pages.d.ts +2 -64
- package/dist/virtuals/scripts/StorageFileBrowser.d.ts +1 -172
- package/dist/virtuals/scripts/StorageFileBrowser.js +216 -119
- package/dist/virtuals/template-engine/index.d.ts +4 -4
- package/frontend/components/dashboard/configuration/ConfigForm.astro +218 -110
- package/frontend/components/dashboard/content-mgmt/ContentSearch.astro +21 -22
- package/frontend/components/dashboard/content-mgmt/CreateFolder.astro +66 -54
- package/frontend/components/dashboard/content-mgmt/CreatePage.astro +58 -104
- package/frontend/components/dashboard/content-mgmt/EditFolder.astro +65 -67
- package/frontend/components/dashboard/content-mgmt/EditPage.astro +86 -134
- package/frontend/components/dashboard/content-mgmt/InnerSidebarElement.astro +0 -1
- package/frontend/components/dashboard/content-mgmt/PageHeader.astro +33 -52
- package/frontend/components/dashboard/content-mgmt/PageTypeHandler.astro +2 -2
- package/frontend/components/dashboard/profile/APITokens.astro +219 -158
- package/frontend/components/dashboard/profile/BasicInfo.astro +165 -106
- package/frontend/components/dashboard/profile/Notifications.astro +27 -18
- package/frontend/components/dashboard/profile/UpdatePassword.astro +134 -94
- package/frontend/components/dashboard/sidebar/VersionCheck.astro +31 -16
- package/frontend/components/dashboard/sidebar/VersionCheckChangelog.astro +18 -11
- package/frontend/components/dashboard/sidebar-modals/VersionModal.astro +2 -2
- package/frontend/components/dashboard/smtp-config/TemplateEditor.astro +14 -14
- package/frontend/components/dashboard/taxonomy/InnerSidebarElement.astro +0 -1
- package/frontend/components/dashboard/taxonomy/MetaContainer.astro +0 -2
- package/frontend/components/dashboard/taxonomy/PageHeader.astro +16 -24
- package/frontend/components/dashboard/taxonomy/TaxonomySearch.astro +23 -27
- package/frontend/components/dashboard/user-mgmt/InnerSidebarElement.astro +111 -104
- package/frontend/components/dashboard/user-mgmt/UserListItem.astro +9 -22
- package/frontend/components/dashboard/user-mgmt/UserListItems.astro +18 -0
- package/frontend/components/first-time-setup/snippets/{opt2-studiocms.config.diff → studiocms.config.diff} +1 -0
- package/frontend/components/shared/Code.astro +1 -4
- package/frontend/components/shared/DynamicSettingsRenderer.astro +1 -1
- package/frontend/components/shared/SSRUser.astro +2 -4
- package/frontend/components/shared/foldertree/FolderTreeNode.astro +0 -6
- package/frontend/components/shared/storage-manager/StorageCopyOutput.astro +0 -1
- package/frontend/components/shared/taxonomy/TaxonomyTreeNode.astro +0 -6
- package/frontend/layouts/DashboardLayout.astro +1 -10
- package/frontend/layouts/TaxonomyLayout.astro +0 -1
- package/frontend/middleware/index.ts +102 -61
- package/frontend/pages/404.astro +5 -9
- package/frontend/pages/[dashboard]/[...pluginPage].astro +10 -1
- package/frontend/pages/[dashboard]/configuration.astro +10 -1
- package/frontend/pages/[dashboard]/content-management/createfolder.astro +10 -1
- package/frontend/pages/[dashboard]/content-management/createpage.astro +10 -1
- package/frontend/pages/[dashboard]/content-management/diff.astro +39 -14
- package/frontend/pages/[dashboard]/content-management/editfolder.astro +10 -1
- package/frontend/pages/[dashboard]/content-management/editpage.astro +10 -1
- package/frontend/pages/[dashboard]/content-management/index.astro +10 -1
- package/frontend/pages/[dashboard]/index.astro +10 -1
- package/frontend/pages/[dashboard]/login.astro +86 -25
- package/frontend/pages/[dashboard]/password-reset.astro +22 -16
- package/frontend/pages/[dashboard]/plugins/[plugin].astro +10 -1
- package/frontend/pages/[dashboard]/profile.astro +10 -1
- package/frontend/pages/[dashboard]/signup.astro +153 -52
- package/frontend/pages/[dashboard]/smtp-configuration.astro +77 -75
- package/frontend/pages/[dashboard]/system-management.astro +10 -1
- package/frontend/pages/[dashboard]/taxonomy/categories.astro +30 -41
- package/frontend/pages/[dashboard]/taxonomy/index.astro +10 -0
- package/frontend/pages/[dashboard]/taxonomy/tags.astro +33 -43
- package/frontend/pages/[dashboard]/unverified-email.astro +29 -21
- package/frontend/pages/[dashboard]/user-management/edit.astro +170 -90
- package/frontend/pages/[dashboard]/user-management/index.astro +10 -1
- package/frontend/pages/studiocms_api/[...all].ts +106 -0
- package/frontend/pages/studiocms_api/_handlers/_utils/auth.ts +26 -0
- package/frontend/pages/studiocms_api/_handlers/_utils/changelog.ts +147 -0
- package/frontend/pages/studiocms_api/_handlers/_utils/db-studio-driver.ts +46 -0
- package/frontend/pages/studiocms_api/_handlers/_utils/parseLogLevel.ts +27 -0
- package/frontend/pages/studiocms_api/_handlers/auth/auth.ts +459 -0
- package/frontend/pages/studiocms_api/_handlers/auth/index.ts +17 -0
- package/frontend/pages/studiocms_api/_handlers/auth/oauth.ts +91 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/_shared.ts +57 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/apiTokens.ts +134 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/config.ts +64 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/content.ts +741 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/create.ts +480 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/emailNotifications.ts +49 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/index.ts +45 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/mailer.ts +136 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/plugins.ts +80 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/profile.ts +275 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/resetPassword.ts +140 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/search.ts +63 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/taxonomy.ts +285 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/templates.ts +75 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/users.ts +312 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/verifyEndpoints.ts +307 -0
- package/frontend/pages/studiocms_api/_handlers/integration/dbStudio.ts +98 -0
- package/frontend/pages/studiocms_api/_handlers/integration/index.ts +17 -0
- package/frontend/pages/studiocms_api/_handlers/integration/storageManager.ts +107 -0
- package/frontend/pages/studiocms_api/_handlers/rest-api/index.ts +8 -0
- package/frontend/pages/studiocms_api/_handlers/rest-api/v1/_shared.ts +41 -0
- package/frontend/pages/studiocms_api/_handlers/rest-api/v1/index.ts +17 -0
- package/frontend/pages/studiocms_api/_handlers/rest-api/v1/public.ts +195 -0
- package/frontend/pages/studiocms_api/_handlers/rest-api/v1/secure.ts +1726 -0
- package/frontend/pages/studiocms_api/_handlers/sdk.ts +129 -0
- package/frontend/pages/studiocms_api/_middleware/astroLocals.ts +36 -0
- package/frontend/pages/studiocms_api/_middleware/restApi.ts +56 -0
- package/frontend/pages/studiocms_api/integrations/[...all].ts +8 -0
- package/frontend/scripts/formdata.ts +219 -0
- package/frontend/setup-pages/3-done.astro +4 -20
- package/frontend/setup-pages/studiocms_api/dashboard/step-2.ts +3 -6
- package/frontend/styles/dashboard-base.css +0 -1
- package/frontend/web-vitals/endpoint.ts +2 -1
- package/package.json +35 -31
- package/dist/global.d.ts +0 -9
- package/frontend/components/dashboard/LoginChecker.astro +0 -68
- package/frontend/components/dashboard/user-mgmt/RankCheck.astro +0 -57
- package/frontend/components/first-time-setup/snippets/opt1-astro.config.diff +0 -14
- package/frontend/components/first-time-setup/snippets/opt2-astro.config.diff +0 -9
- package/frontend/middleware/_authmap.ts +0 -63
- package/frontend/pages/studiocms_api/auth/[path].ts +0 -390
- package/frontend/pages/studiocms_api/auth/[provider]/[...id].ts +0 -64
- package/frontend/pages/studiocms_api/auth/[provider]/_effects/index.ts +0 -101
- package/frontend/pages/studiocms_api/auth/_shared.ts +0 -52
- package/frontend/pages/studiocms_api/dashboard/api-tokens.ts +0 -115
- package/frontend/pages/studiocms_api/dashboard/config.ts +0 -74
- package/frontend/pages/studiocms_api/dashboard/content/diff.ts +0 -73
- package/frontend/pages/studiocms_api/dashboard/content/folder.ts +0 -220
- package/frontend/pages/studiocms_api/dashboard/content/page.ts +0 -359
- package/frontend/pages/studiocms_api/dashboard/create-reset-link.ts +0 -77
- package/frontend/pages/studiocms_api/dashboard/create-user-invite.ts +0 -231
- package/frontend/pages/studiocms_api/dashboard/create-user.ts +0 -186
- package/frontend/pages/studiocms_api/dashboard/email-notification-settings-site.ts +0 -74
- package/frontend/pages/studiocms_api/dashboard/mailer/check-email.ts +0 -75
- package/frontend/pages/studiocms_api/dashboard/mailer/config.ts +0 -136
- package/frontend/pages/studiocms_api/dashboard/plugins/[plugin].ts +0 -80
- package/frontend/pages/studiocms_api/dashboard/profile.ts +0 -245
- package/frontend/pages/studiocms_api/dashboard/resend-verify-email.ts +0 -77
- package/frontend/pages/studiocms_api/dashboard/reset-password.ts +0 -124
- package/frontend/pages/studiocms_api/dashboard/search-list.ts +0 -59
- package/frontend/pages/studiocms_api/dashboard/taxonomy-search.ts +0 -47
- package/frontend/pages/studiocms_api/dashboard/taxonomy.ts +0 -230
- package/frontend/pages/studiocms_api/dashboard/templates.ts +0 -74
- package/frontend/pages/studiocms_api/dashboard/update-user-notifications.ts +0 -86
- package/frontend/pages/studiocms_api/dashboard/users.ts +0 -236
- package/frontend/pages/studiocms_api/dashboard/verify-email.ts +0 -83
- package/frontend/pages/studiocms_api/dashboard/verify-session.ts +0 -187
- package/frontend/pages/studiocms_api/integrations/[type]/[...id].ts +0 -15
- package/frontend/pages/studiocms_api/integrations/[type]/_routes/db-studio.ts +0 -173
- package/frontend/pages/studiocms_api/integrations/[type]/_routes/storage.ts +0 -88
- package/frontend/pages/studiocms_api/partials/editor.astro +0 -74
- package/frontend/pages/studiocms_api/partials/render.astro +0 -39
- package/frontend/pages/studiocms_api/partials/user-list-items.astro +0 -43
- package/frontend/pages/studiocms_api/rest/utils/auth-token.ts +0 -59
- package/frontend/pages/studiocms_api/rest/v1/[type]/[...id].ts +0 -23
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/categories.ts +0 -267
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/folders.ts +0 -283
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/pages.ts +0 -505
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/settings.ts +0 -100
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/tags.ts +0 -229
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/users.ts +0 -553
- package/frontend/pages/studiocms_api/rest/v1/public/[type]/[...id].ts +0 -19
- package/frontend/pages/studiocms_api/rest/v1/public/[type]/_routes/categories.ts +0 -74
- package/frontend/pages/studiocms_api/rest/v1/public/[type]/_routes/folders.ts +0 -85
- package/frontend/pages/studiocms_api/rest/v1/public/[type]/_routes/pages.ts +0 -103
- package/frontend/pages/studiocms_api/rest/v1/public/[type]/_routes/tags.ts +0 -67
- package/frontend/pages/studiocms_api/sdk/[...path].ts +0 -97
- package/frontend/pages/studiocms_api/sdk/utils/changelog.ts +0 -119
- package/frontend/scripts/auth/formListener.ts +0 -81
- package/frontend/scripts/formdata-utils.ts +0 -116
- package/frontend/utils/build-partial-schema.ts +0 -46
- package/frontend/utils/errors.ts +0 -6
- package/frontend/utils/param-extractor.ts +0 -83
- package/frontend/utils/rest-router.ts +0 -444
|
@@ -1,17 +1,38 @@
|
|
|
1
|
-
import { Effect
|
|
2
|
-
import { defineUtility } from "astro-integration-kit";
|
|
3
|
-
import {
|
|
1
|
+
import { Effect } from "@withstudiocms/effect";
|
|
2
|
+
import { addVirtualImports, defineUtility } from "astro-integration-kit";
|
|
3
|
+
import {
|
|
4
|
+
getAstroProject,
|
|
5
|
+
getRouteConfig,
|
|
6
|
+
StudioCMSRouteConfig
|
|
7
|
+
} from "./frontend/routes.js";
|
|
4
8
|
const routeHandler = defineUtility("astro:config:setup")(
|
|
5
9
|
async (params, options) => {
|
|
6
10
|
const { injectRoute, addMiddleware } = params;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const _injectRoutes = (route) => Effect.sync(() => injectRoute(route));
|
|
12
|
+
const _addMiddleware = (mw) => Effect.sync(() => addMiddleware(mw));
|
|
13
|
+
const sharedConfig = StudioCMSRouteConfig.Live(options);
|
|
14
|
+
await Effect.all([
|
|
15
|
+
// Retrieve the processed route configuration and add it as a virtual import for use in other parts of the application
|
|
16
|
+
getRouteConfig.pipe(
|
|
17
|
+
Effect.map((config) => {
|
|
18
|
+
addVirtualImports(params, {
|
|
19
|
+
name: "studiocms:routeHandler",
|
|
20
|
+
imports: {
|
|
21
|
+
"virtual:studiocms/route-config": `export const routeConfig = ${JSON.stringify(config)}; export default routeConfig;`
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
})
|
|
25
|
+
),
|
|
26
|
+
// Retrieve the Astro project configuration, which includes the routes and middleware to be injected, and process them by injecting routes and adding middleware
|
|
27
|
+
getAstroProject.pipe(
|
|
28
|
+
Effect.flatMap(
|
|
29
|
+
({ middleware, routes }) => Effect.all([
|
|
30
|
+
Effect.forEach(routes, _injectRoutes),
|
|
31
|
+
Effect.forEach(middleware, _addMiddleware)
|
|
32
|
+
])
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
]).pipe(Effect.provide(sharedConfig), Effect.runPromise);
|
|
15
36
|
}
|
|
16
37
|
);
|
|
17
38
|
export {
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export declare const setupDbStudio: import("astro-integration-kit").HookUtility<"astro:config:setup", [
|
|
1
|
+
export declare const setupDbStudio: import("astro-integration-kit").HookUtility<"astro:config:setup", [opts: {
|
|
2
|
+
readonly dialect: "libsql" | "postgres" | "mysql";
|
|
3
|
+
}], Promise<void>>;
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import createPathResolver from "@withstudiocms/internal_helpers/pathResolver";
|
|
2
|
-
import { defineUtility } from "astro-integration-kit";
|
|
2
|
+
import { addVirtualImports, defineUtility } from "astro-integration-kit";
|
|
3
3
|
const { resolve } = createPathResolver(import.meta.url);
|
|
4
|
-
const setupDbStudio = defineUtility("astro:config:setup")(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
4
|
+
const setupDbStudio = defineUtility("astro:config:setup")(
|
|
5
|
+
async (params, opts) => {
|
|
6
|
+
const { addDevToolbarApp } = params;
|
|
7
|
+
const { dialect } = opts;
|
|
8
|
+
addVirtualImports(params, {
|
|
9
|
+
name: "studiocms:db-studio",
|
|
10
|
+
imports: {
|
|
11
|
+
"virtual:studiocms/db-studio/connection": `export { createConnectionFromConfig } from '${resolve(`../toolbar/db-viewer/studio/virtual-connection/${dialect}.js`)}';`
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
addDevToolbarApp({
|
|
15
|
+
id: "studiocms-db-viewer",
|
|
16
|
+
entrypoint: resolve("../toolbar/db-viewer/index.js"),
|
|
17
|
+
name: "Database Viewer",
|
|
18
|
+
icon: '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"><path stroke-linecap="round" stroke-linejoin="round" d="M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375m16.5 0v3.75m-16.5-3.75v3.75m16.5 0v3.75C20.25 16.153 16.556 18 12 18s-8.25-1.847-8.25-4.125v-3.75m16.5 0c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125" /></svg>'
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
);
|
|
13
22
|
export {
|
|
14
23
|
setupDbStudio
|
|
15
24
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HttpServerResponse } from '@effect/platform';
|
|
2
|
+
import type { HttpBodyError } from '@effect/platform/HttpBody';
|
|
3
|
+
import type { APIContext } from 'astro';
|
|
4
|
+
import type { Effect } from 'effect';
|
|
5
|
+
import type { ContextDriverDefinition, ContextHandler, ContextHandlerFn, ParsedContext } from '../definitions';
|
|
6
|
+
/**
|
|
7
|
+
* Astro Context Driver implementation.
|
|
8
|
+
*
|
|
9
|
+
* This class implements the ContextDriverDefinition interface for Astro,
|
|
10
|
+
* providing methods to parse the context, build responses, and handle endpoints.
|
|
11
|
+
*/
|
|
12
|
+
export default class EffectifyAstroContextDriver implements ContextDriverDefinition<APIContext, Effect.Effect<HttpServerResponse.HttpServerResponse, HttpBodyError>> {
|
|
13
|
+
parseContext({ request, locals }: APIContext): ParsedContext;
|
|
14
|
+
buildResponse<Data>(opts: {
|
|
15
|
+
data: Data;
|
|
16
|
+
status: number;
|
|
17
|
+
}): Effect.Effect<HttpServerResponse.HttpServerResponse, HttpBodyError>;
|
|
18
|
+
buildErrorResponse(error: unknown): {
|
|
19
|
+
data: {
|
|
20
|
+
error: string;
|
|
21
|
+
};
|
|
22
|
+
status: number;
|
|
23
|
+
};
|
|
24
|
+
handleEndpoint(contextHandler: ContextHandler): ContextHandlerFn<APIContext, Effect.Effect<HttpServerResponse.HttpServerResponse, HttpBodyError>>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { runSDK, SDKCoreJs } from "studiocms:sdk";
|
|
2
|
+
import { HttpServerResponse } from "@effect/platform";
|
|
3
|
+
import { UserPermissionLevel } from "@withstudiocms/auth-kit/types";
|
|
4
|
+
class EffectifyAstroContextDriver {
|
|
5
|
+
parseContext({ request, locals }) {
|
|
6
|
+
return {
|
|
7
|
+
getJson: () => request.json(),
|
|
8
|
+
getArrayBuffer: () => request.arrayBuffer(),
|
|
9
|
+
getHeader: (name) => request.headers.get(name),
|
|
10
|
+
isAuthorized: async (type) => {
|
|
11
|
+
switch (type) {
|
|
12
|
+
case "headers": {
|
|
13
|
+
const authTokenData = request.headers.get("Authorization");
|
|
14
|
+
if (!authTokenData) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const parts = authTokenData.split(" ");
|
|
18
|
+
if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer") {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const token = parts[1];
|
|
22
|
+
const user = await runSDK(SDKCoreJs.REST_API.tokens.verify(token));
|
|
23
|
+
if (!user) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
let level;
|
|
27
|
+
switch (user.rank) {
|
|
28
|
+
case "owner":
|
|
29
|
+
level = UserPermissionLevel.owner;
|
|
30
|
+
break;
|
|
31
|
+
case "admin":
|
|
32
|
+
level = UserPermissionLevel.admin;
|
|
33
|
+
break;
|
|
34
|
+
case "editor":
|
|
35
|
+
level = UserPermissionLevel.editor;
|
|
36
|
+
break;
|
|
37
|
+
case "visitor":
|
|
38
|
+
level = UserPermissionLevel.visitor;
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
level = UserPermissionLevel.unknown;
|
|
42
|
+
}
|
|
43
|
+
const isEditor = level >= UserPermissionLevel.editor;
|
|
44
|
+
if (!isEditor) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
default: {
|
|
50
|
+
const isEditor = locals.StudioCMS.security?.userPermissionLevel.isEditor || false;
|
|
51
|
+
return isEditor;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
buildResponse(opts) {
|
|
58
|
+
return HttpServerResponse.json(opts.data, { status: opts.status });
|
|
59
|
+
}
|
|
60
|
+
buildErrorResponse(error) {
|
|
61
|
+
return { data: { error: error.message }, status: 500 };
|
|
62
|
+
}
|
|
63
|
+
handleEndpoint(contextHandler) {
|
|
64
|
+
return async (rawContext) => {
|
|
65
|
+
try {
|
|
66
|
+
const context = this.parseContext(rawContext);
|
|
67
|
+
const opts = await contextHandler(context);
|
|
68
|
+
return this.buildResponse(opts);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
const errorResponse = this.buildErrorResponse(error);
|
|
71
|
+
return this.buildResponse(errorResponse);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
EffectifyAstroContextDriver as default
|
|
78
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type StudioCMSStorageManagerDef } from '../../schemas/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Defines a No-Op Storage Manager plugin for StudioCMS.
|
|
4
4
|
*
|
|
@@ -7,4 +7,4 @@ import { type StudioCMSStorageManager } from '../../schemas/index.js';
|
|
|
7
7
|
* @param version - The minimum StudioCMS version required for this storage manager.
|
|
8
8
|
* @returns A StudioCMSStorageManager plugin definition.
|
|
9
9
|
*/
|
|
10
|
-
export declare const NoOpStorageManager: (
|
|
10
|
+
export declare const NoOpStorageManager: () => StudioCMSStorageManagerDef;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import createPathResolver from "@withstudiocms/internal_helpers/pathResolver";
|
|
2
2
|
import { defineStorageManager } from "../../schemas/index.js";
|
|
3
3
|
const { resolve } = createPathResolver(import.meta.url);
|
|
4
|
-
const NoOpStorageManager = (
|
|
4
|
+
const NoOpStorageManager = () => defineStorageManager({
|
|
5
5
|
identifier: "studiocms",
|
|
6
6
|
name: "Core No-Op Storage (built-in)",
|
|
7
|
-
studiocmsMinimumVersion: version,
|
|
8
7
|
hooks: {
|
|
9
|
-
"studiocms:storage-manager": ({ setStorageManager, logger }) => {
|
|
8
|
+
"studiocms:storage-manager": async ({ setStorageManager, logger }) => {
|
|
10
9
|
logger.info("No-Op Storage initialized.");
|
|
11
10
|
setStorageManager({
|
|
12
11
|
managerPath: resolve("./core/no-op-storage-manager.js")
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* directives must be first at the top of the file and can only be preceded by this comment.
|
|
5
5
|
*/
|
|
6
6
|
/// <reference types="@studiocms/ui/v/types" preserve="true" />
|
|
7
|
-
/// <reference types="./global.d.ts" preserve="true" />
|
|
8
7
|
/// <reference types="./virtual.d.ts" preserve="true" />
|
|
9
8
|
/// <reference types="./theme.d.ts" preserve="true" />
|
|
10
9
|
import type { AstroIntegration } from 'astro';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,11 @@ import { promises as fsP, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { runtimeLogger } from "@inox-tools/runtime-logger";
|
|
3
3
|
import studiocmsUi from "@studiocms/ui";
|
|
4
4
|
import { componentRegistryHandler } from "@withstudiocms/component-registry";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
configResolverBuilderEffect,
|
|
7
|
+
exists,
|
|
8
|
+
watchConfigFileBuilder
|
|
9
|
+
} from "@withstudiocms/config-utils";
|
|
6
10
|
import { Effect, runEffect } from "@withstudiocms/effect";
|
|
7
11
|
import {
|
|
8
12
|
addIntegrationArray,
|
|
@@ -19,7 +23,6 @@ import { envField } from "astro/config";
|
|
|
19
23
|
import { addVirtualImports } from "astro-integration-kit";
|
|
20
24
|
import dotenv from "dotenv";
|
|
21
25
|
import { compare as semCompare } from "semver";
|
|
22
|
-
import { loadEnv } from "vite";
|
|
23
26
|
import {
|
|
24
27
|
AstroConfigImageSettings,
|
|
25
28
|
AstroConfigViteSettings,
|
|
@@ -48,7 +51,6 @@ const { name: pkgName, version: pkgVersion } = readJson(
|
|
|
48
51
|
resolve("../package.json")
|
|
49
52
|
);
|
|
50
53
|
dotenv.config({ quiet: true });
|
|
51
|
-
const env = loadEnv("", process.cwd(), "");
|
|
52
54
|
const StudioCMSRendererComponentPath = "./virtuals/components/Renderer.astro";
|
|
53
55
|
const CustomImageComponentPath = "./virtuals/components/CustomImage.astro";
|
|
54
56
|
const builtInComponents = {
|
|
@@ -60,10 +62,10 @@ const studiocms = () => {
|
|
|
60
62
|
const watchConfigFile = watchConfigFileBuilder({
|
|
61
63
|
configPaths
|
|
62
64
|
});
|
|
63
|
-
const configResolver =
|
|
65
|
+
const configResolver = configResolverBuilderEffect({
|
|
64
66
|
configPaths,
|
|
65
67
|
label: name,
|
|
66
|
-
|
|
68
|
+
effectSchema: StudioCMSOptionsSchema
|
|
67
69
|
});
|
|
68
70
|
const messages = [];
|
|
69
71
|
let cacheJsonFile;
|
|
@@ -135,7 +137,6 @@ const studiocms = () => {
|
|
|
135
137
|
dashboardRoute,
|
|
136
138
|
dbStartPage,
|
|
137
139
|
name,
|
|
138
|
-
pkgVersion,
|
|
139
140
|
plugins,
|
|
140
141
|
robotsTXTConfig,
|
|
141
142
|
verbose,
|
|
@@ -167,7 +168,6 @@ const studiocms = () => {
|
|
|
167
168
|
dynamicWithAstroVirtual,
|
|
168
169
|
buildDefaultOnlyVirtual,
|
|
169
170
|
buildLoggerVirtual,
|
|
170
|
-
buildNamedMultiExportVirtual,
|
|
171
171
|
buildVirtualConfig
|
|
172
172
|
} = VirtualModuleBuilder(resolve);
|
|
173
173
|
const debugProvider = new DebugInfoProvider({
|
|
@@ -183,11 +183,6 @@ const studiocms = () => {
|
|
|
183
183
|
"studiocms:plugins": buildDefaultOnlyVirtual(safePluginList),
|
|
184
184
|
"studiocms:version": buildDefaultOnlyVirtual(pkgVersion),
|
|
185
185
|
"studiocms:logger": buildLoggerVirtual(verbose),
|
|
186
|
-
"virtual:studiocms/sdk/env": buildNamedMultiExportVirtual({
|
|
187
|
-
dbUrl: env.ASTRO_DB_REMOTE_URL,
|
|
188
|
-
dbSecret: env.ASTRO_DB_APP_TOKEN,
|
|
189
|
-
cmsEncryptionKey: env.CMS_ENCRYPTION_KEY
|
|
190
|
-
}),
|
|
191
186
|
"studiocms:lib": dynamicVirtual([
|
|
192
187
|
"./virtuals/lib/head.js",
|
|
193
188
|
"./virtuals/lib/headDefaults.js",
|
|
@@ -222,9 +217,6 @@ const studiocms = () => {
|
|
|
222
217
|
"studiocms:auth/utils/validImages": dynamicVirtual([
|
|
223
218
|
"./virtuals/auth/validImages/index.js"
|
|
224
219
|
]),
|
|
225
|
-
"studiocms:auth/utils/getLabelForPermissionLevel": dynamicVirtual([
|
|
226
|
-
"./virtuals/auth/getLabelForPermissionLevel.js"
|
|
227
|
-
]),
|
|
228
220
|
"studiocms:auth/scripts/three": ambientScripts(["./virtuals/auth/scripts/three.js"]),
|
|
229
221
|
"studiocms:i18n/config": `export default ${JSON.stringify({ ...options.locale.i18n })}`,
|
|
230
222
|
"studiocms:i18n/virtual": `
|
|
@@ -250,16 +242,14 @@ const studiocms = () => {
|
|
|
250
242
|
"studiocms:i18n/plugins": dynamicVirtual(["./virtuals/i18n/plugin.js"]),
|
|
251
243
|
"studiocms:sdk": dynamicVirtual(["./virtuals/sdk/index.js"]),
|
|
252
244
|
"studiocms:sdk/types": dynamicVirtual(["./virtuals/sdk/types.js"]),
|
|
253
|
-
"studiocms:astro-config/adapter": `export const adapter = ${JSON.stringify(
|
|
254
|
-
config.adapter?.name || "unknown"
|
|
255
|
-
)}`,
|
|
256
245
|
"studiocms:debug-info": `export const debugInfo = ${JSON.stringify(debugOutput)};export default debugInfo;`,
|
|
257
246
|
"studiocms:client-scripts/StorageFileBrowser": ambientScripts([
|
|
258
247
|
"./virtuals/scripts/StorageFileBrowser.js"
|
|
259
|
-
])
|
|
248
|
+
]),
|
|
249
|
+
"studiocms:client/apiClients": dynamicVirtual(["./client/apiClient.js"])
|
|
260
250
|
}
|
|
261
251
|
});
|
|
262
|
-
await setupDbStudio(params);
|
|
252
|
+
await setupDbStudio(params, options.db);
|
|
263
253
|
integrationLogger(
|
|
264
254
|
logInfo,
|
|
265
255
|
"Updating Astro Config with StudioCMS Resources and settings..."
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AstroIntegration } from 'astro';
|
|
2
|
-
import {
|
|
2
|
+
import type { RobotsConfig } from './schema.js';
|
|
3
3
|
/**
|
|
4
4
|
* **Robots.txt Integration**
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@ import { type RobotsConfig } from './schema.js';
|
|
|
8
8
|
* @param astroConfig Robots Configuration
|
|
9
9
|
* @returns AstroIntegration
|
|
10
10
|
*/
|
|
11
|
-
export default function createRobotsIntegration(
|
|
11
|
+
export default function createRobotsIntegration(config: RobotsConfig): AstroIntegration;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { generateContent, printInfo } from "./core.js";
|
|
4
|
-
import { RobotsTXTConfigSchema } from "./schema.js";
|
|
5
4
|
import { getFileSizeInKilobytes, measureExecutionTime } from "./utils.js";
|
|
6
|
-
function createRobotsIntegration(
|
|
5
|
+
function createRobotsIntegration(config) {
|
|
7
6
|
let astroConfig;
|
|
8
7
|
let finalSiteMapHref;
|
|
9
8
|
let executionTime;
|
|
10
|
-
const config = RobotsTXTConfigSchema.parse(options);
|
|
11
9
|
return {
|
|
12
10
|
name: "studiocms/robotstxt",
|
|
13
11
|
hooks: {
|