@cossackframework/cms 0.0.0-stage → 0.9.1
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/LICENSE +21 -0
- package/README.md +147 -2
- package/agent-docs.json +259 -0
- package/app/README.md +78 -0
- package/app/cossack-recipe.json +43 -0
- package/app/src/auth-bot-check.ts +32 -0
- package/app/src/auth-bot-token.ts +11 -0
- package/app/src/auth-input.ts +35 -0
- package/app/src/auth-options.ts +18 -0
- package/app/src/auth-providers.ts +16 -0
- package/app/src/auth.ts +1082 -0
- package/app/src/brand.ts +68 -0
- package/app/src/cms/ai.ts +54 -0
- package/app/src/cms/analytics.ts +33 -0
- package/app/src/cms/block-errors.ts +55 -0
- package/app/src/cms/block-inserter.ts +111 -0
- package/app/src/cms/block-panel.ts +68 -0
- package/app/src/cms/block-rows.ts +44 -0
- package/app/src/cms/block-tree.ts +585 -0
- package/app/src/cms/blocks.css +708 -0
- package/app/src/cms/builder.ts +126 -0
- package/app/src/cms/cache.ts +44 -0
- package/app/src/cms/carousel.client.ts +52 -0
- package/app/src/cms/collab/presence.ts +69 -0
- package/app/src/cms/collab/rich-text-collab.client.ts +197 -0
- package/app/src/cms/collab/rich-text-notes.client.ts +138 -0
- package/app/src/cms/collab/room.ts +881 -0
- package/app/src/cms/compare.client.ts +47 -0
- package/app/src/cms/condition-control.ts +109 -0
- package/app/src/cms/content-api.ts +143 -0
- package/app/src/cms/content.ts +524 -0
- package/app/src/cms/countdown.client.ts +37 -0
- package/app/src/cms/editor-layout-editor.ts +260 -0
- package/app/src/cms/editor-layout-view.ts +37 -0
- package/app/src/cms/editor.ts +381 -0
- package/app/src/cms/entry.ts +26 -0
- package/app/src/cms/feeds.ts +145 -0
- package/app/src/cms/field-controls.ts +222 -0
- package/app/src/cms/field-group-editor.ts +105 -0
- package/app/src/cms/field-group-view.ts +211 -0
- package/app/src/cms/form-view.ts +203 -0
- package/app/src/cms/form.client.ts +203 -0
- package/app/src/cms/guards.ts +27 -0
- package/app/src/cms/handoff.ts +202 -0
- package/app/src/cms/headings.ts +51 -0
- package/app/src/cms/icons.ts +80 -0
- package/app/src/cms/import.client.ts +16 -0
- package/app/src/cms/index.ts +191 -0
- package/app/src/cms/lightbox.client.ts +109 -0
- package/app/src/cms/machine.ts +118 -0
- package/app/src/cms/maintenance.ts +97 -0
- package/app/src/cms/manage.ts +1236 -0
- package/app/src/cms/mcp-tools.ts +388 -0
- package/app/src/cms/mcp.ts +242 -0
- package/app/src/cms/media-chooser.ts +123 -0
- package/app/src/cms/media-usage.ts +57 -0
- package/app/src/cms/middleware.ts +199 -0
- package/app/src/cms/middlewares.ts +13 -0
- package/app/src/cms/network-ui.ts +36 -0
- package/app/src/cms/network-view.ts +38 -0
- package/app/src/cms/notes-announce.ts +65 -0
- package/app/src/cms/notes-rail.ts +207 -0
- package/app/src/cms/notification-rules.ts +66 -0
- package/app/src/cms/recovery.ts +82 -0
- package/app/src/cms/replace.ts +63 -0
- package/app/src/cms/reserved-paths.ts +19 -0
- package/app/src/cms/rich-text-field.ts +325 -0
- package/app/src/cms/rich-text-schema.ts +91 -0
- package/app/src/cms/rich-text.client.ts +255 -0
- package/app/src/cms/search.client.ts +116 -0
- package/app/src/cms/seo-head.ts +78 -0
- package/app/src/cms/seo.ts +241 -0
- package/app/src/cms/settings-draft.ts +218 -0
- package/app/src/cms/settings-file.ts +127 -0
- package/app/src/cms/settings-form.ts +180 -0
- package/app/src/cms/settings-languages.ts +125 -0
- package/app/src/cms/settings-nav.ts +102 -0
- package/app/src/cms/settings-network.ts +151 -0
- package/app/src/cms/settings-permalinks.ts +114 -0
- package/app/src/cms/settings-scroll.ts +10 -0
- package/app/src/cms/settings-search.ts +77 -0
- package/app/src/cms/settings-section.ts +38 -0
- package/app/src/cms/share.client.ts +27 -0
- package/app/src/cms/site-editing.ts +219 -0
- package/app/src/cms/site-editor.client.ts +1008 -0
- package/app/src/cms/site-editor.ts +99 -0
- package/app/src/cms/site-export.ts +60 -0
- package/app/src/cms/site-forms.ts +143 -0
- package/app/src/cms/site-import.ts +28 -0
- package/app/src/cms/site-session.ts +36 -0
- package/app/src/cms/site-taskbar.ts +77 -0
- package/app/src/cms/site-view.ts +1014 -0
- package/app/src/cms/site.ts +1322 -0
- package/app/src/cms/sitemaps.ts +131 -0
- package/app/src/cms/stat.client.ts +56 -0
- package/app/src/cms/style-controls.ts +252 -0
- package/app/src/cms/tabs.client.ts +36 -0
- package/app/src/cms/taskbar.ts +134 -0
- package/app/src/cms/term-icons.ts +10 -0
- package/app/src/cms/traffic.ts +26 -0
- package/app/src/cms/ui.ts +170 -0
- package/app/src/cms/updates.ts +124 -0
- package/app/src/cms/uploads.ts +26 -0
- package/app/src/cms/worker.ts +13 -0
- package/app/src/config/auth.ts +30 -0
- package/app/src/config/cms.ts +18 -0
- package/app/src/dashboard/access.ts +344 -0
- package/app/src/dashboard/agent-icons.ts +44 -0
- package/app/src/dashboard/app-passwords.ts +74 -0
- package/app/src/dashboard/avatar-field.ts +58 -0
- package/app/src/dashboard/bulk.ts +53 -0
- package/app/src/dashboard/head.ts +29 -0
- package/app/src/dashboard/icons.ts +15 -0
- package/app/src/dashboard/list-table.ts +120 -0
- package/app/src/dashboard/modules/roles.ts +15 -0
- package/app/src/dashboard/modules/sessions.ts +15 -0
- package/app/src/dashboard/modules/settings.ts +15 -0
- package/app/src/dashboard/modules/users.ts +18 -0
- package/app/src/dashboard/page.ts +67 -0
- package/app/src/dashboard/registry.ts +13 -0
- package/app/src/dashboard/session-list.ts +98 -0
- package/app/src/dashboard/tabs.ts +26 -0
- package/app/src/dashboard/time-ago.ts +16 -0
- package/app/src/dashboard/types.ts +40 -0
- package/app/src/dashboard/user-sections.ts +172 -0
- package/app/src/lib/permissions.ts +84 -0
- package/app/src/middlewares/auth.ts +117 -0
- package/app/src/pages/(site)/[...path]/index.ts +609 -0
- package/app/src/pages/(site)/feed/[...rest]/index.ts +13 -0
- package/app/src/pages/(site)/feed/index.ts +12 -0
- package/app/src/pages/(site)/index.ts +11 -0
- package/app/src/pages/(site)/indexnow/[file]/index.ts +18 -0
- package/app/src/pages/(site)/layout.ts +219 -0
- package/app/src/pages/(site)/llms.txt/index.ts +23 -0
- package/app/src/pages/(site)/manifest.webmanifest/index.ts +29 -0
- package/app/src/pages/(site)/media/[id]/[name]/index.ts +59 -0
- package/app/src/pages/(site)/preview/[collection]/[id]/index.ts +115 -0
- package/app/src/pages/(site)/robots.txt/index.ts +29 -0
- package/app/src/pages/(site)/search/index.ts +36 -0
- package/app/src/pages/(site)/sitemap.xml/index.ts +26 -0
- package/app/src/pages/(site)/sitemaps/[file]/index.ts +33 -0
- package/app/src/pages/api/auth/session.ts +48 -0
- package/app/src/pages/api/cms/appearance/areas/[name].ts +12 -0
- package/app/src/pages/api/cms/appearance/areas/index.ts +6 -0
- package/app/src/pages/api/cms/appearance/locations/[location].ts +6 -0
- package/app/src/pages/api/cms/appearance/locations/index.ts +6 -0
- package/app/src/pages/api/cms/appearance/menus/[id].ts +12 -0
- package/app/src/pages/api/cms/appearance/menus/index.ts +13 -0
- package/app/src/pages/api/cms/appearance/themes/[name]/activate.ts +6 -0
- package/app/src/pages/api/cms/appearance/themes/index.ts +6 -0
- package/app/src/pages/api/cms/cache/purge.ts +6 -0
- package/app/src/pages/api/cms/collections/index.ts +6 -0
- package/app/src/pages/api/cms/commands/[plugin]/[command].ts +26 -0
- package/app/src/pages/api/cms/comments/[id].ts +9 -0
- package/app/src/pages/api/cms/comments/index.ts +126 -0
- package/app/src/pages/api/cms/comments/queue.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/autosave.ts +27 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/blocks/[block].ts +16 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/notes.ts +18 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/publish.ts +11 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/index.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/restore.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/index.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/unpublish.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry].ts +42 -0
- package/app/src/pages/api/cms/content/[collection]/index.ts +24 -0
- package/app/src/pages/api/cms/export/[collection].ts +37 -0
- package/app/src/pages/api/cms/forms/[slug]/index.ts +173 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/[submission]/files/[file].ts +25 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/export.ts +34 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/index.ts +24 -0
- package/app/src/pages/api/cms/import/[collection].ts +23 -0
- package/app/src/pages/api/cms/mcp.ts +29 -0
- package/app/src/pages/api/cms/me/index.ts +6 -0
- package/app/src/pages/api/cms/me/recent-blocks.ts +37 -0
- package/app/src/pages/api/cms/me/tokens/[id].ts +6 -0
- package/app/src/pages/api/cms/me/tokens/index.ts +13 -0
- package/app/src/pages/api/cms/media/[id].ts +6 -0
- package/app/src/pages/api/cms/media.ts +26 -0
- package/app/src/pages/api/cms/menus/[location].ts +14 -0
- package/app/src/pages/api/cms/network/sites/[id]/export.ts +15 -0
- package/app/src/pages/api/cms/network/sites/[id]/index.ts +9 -0
- package/app/src/pages/api/cms/network/sites/index.ts +14 -0
- package/app/src/pages/api/cms/notes/[id].ts +13 -0
- package/app/src/pages/api/cms/notes/index.ts +6 -0
- package/app/src/pages/api/cms/payments/webhook.ts +28 -0
- package/app/src/pages/api/cms/plugins/[name]/grant.ts +6 -0
- package/app/src/pages/api/cms/plugins/[name]/revoke.ts +6 -0
- package/app/src/pages/api/cms/plugins/index.ts +6 -0
- package/app/src/pages/api/cms/recovery.ts +29 -0
- package/app/src/pages/api/cms/redirects/index.ts +9 -0
- package/app/src/pages/api/cms/roles/index.ts +6 -0
- package/app/src/pages/api/cms/schema/[collection].ts +13 -0
- package/app/src/pages/api/cms/search.ts +16 -0
- package/app/src/pages/api/cms/settings/[group].ts +9 -0
- package/app/src/pages/api/cms/settings/index.ts +9 -0
- package/app/src/pages/api/cms/site-export.ts +34 -0
- package/app/src/pages/api/cms/taxonomies/index.ts +6 -0
- package/app/src/pages/api/cms/terms/[taxonomy]/[id].ts +12 -0
- package/app/src/pages/api/cms/terms/[taxonomy]/index.ts +9 -0
- package/app/src/pages/api/cms/uploads/[id]/complete.ts +15 -0
- package/app/src/pages/api/cms/uploads/[id]/index.ts +15 -0
- package/app/src/pages/api/cms/uploads/index.ts +26 -0
- package/app/src/pages/api/cms/users/[id]/index.ts +12 -0
- package/app/src/pages/api/cms/users/[id]/meta.ts +40 -0
- package/app/src/pages/api/cms/users/index.ts +12 -0
- package/app/src/pages/api/cms/webhooks/[id].ts +6 -0
- package/app/src/pages/api/cms/webhooks/index.ts +9 -0
- package/app/src/pages/auth/[provider]/callback.ts +11 -0
- package/app/src/pages/auth/[provider]/redirect.ts +9 -0
- package/app/src/pages/auth/forgot-password/index.ts +75 -0
- package/app/src/pages/auth/layout.ts +32 -0
- package/app/src/pages/auth/login/index.ts +198 -0
- package/app/src/pages/auth/magic/index.ts +68 -0
- package/app/src/pages/auth/register/index.ts +117 -0
- package/app/src/pages/auth/reset-password/index.ts +65 -0
- package/app/src/pages/auth/setup/index.ts +194 -0
- package/app/src/pages/auth/two-factor/index.ts +67 -0
- package/app/src/pages/auth/verify/index.ts +62 -0
- package/app/src/pages/dashboard/(cms)/appearance/customize/index.ts +263 -0
- package/app/src/pages/dashboard/(cms)/appearance/dashboard-menu/index.ts +241 -0
- package/app/src/pages/dashboard/(cms)/appearance/index.ts +89 -0
- package/app/src/pages/dashboard/(cms)/appearance/menus/[id]/index.ts +697 -0
- package/app/src/pages/dashboard/(cms)/appearance/menus/index.ts +145 -0
- package/app/src/pages/dashboard/(cms)/appearance/widgets/index.ts +279 -0
- package/app/src/pages/dashboard/(cms)/blocks/index.ts +84 -0
- package/app/src/pages/dashboard/(cms)/calendar/index.ts +92 -0
- package/app/src/pages/dashboard/(cms)/collections/[name]/index.ts +525 -0
- package/app/src/pages/dashboard/(cms)/collections/index.ts +72 -0
- package/app/src/pages/dashboard/(cms)/collections/new/index.ts +66 -0
- package/app/src/pages/dashboard/(cms)/comments/index.ts +237 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/index.ts +2382 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/revisions/index.ts +126 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/index.ts +693 -0
- package/app/src/pages/dashboard/(cms)/field-groups/[id]/index.ts +193 -0
- package/app/src/pages/dashboard/(cms)/field-groups/index.ts +65 -0
- package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/[submission]/index.ts +279 -0
- package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/index.ts +170 -0
- package/app/src/pages/dashboard/(cms)/forms/index.ts +171 -0
- package/app/src/pages/dashboard/(cms)/media/[id]/index.ts +317 -0
- package/app/src/pages/dashboard/(cms)/media/index.ts +156 -0
- package/app/src/pages/dashboard/(cms)/media/new/index.ts +9 -0
- package/app/src/pages/dashboard/(cms)/media/summary/index.ts +74 -0
- package/app/src/pages/dashboard/(cms)/my-sites/index.ts +63 -0
- package/app/src/pages/dashboard/(cms)/network/index.ts +53 -0
- package/app/src/pages/dashboard/(cms)/network/plugins/index.ts +110 -0
- package/app/src/pages/dashboard/(cms)/network/sites/[id]/index.ts +243 -0
- package/app/src/pages/dashboard/(cms)/network/sites/index.ts +186 -0
- package/app/src/pages/dashboard/(cms)/network/sites/new/index.ts +77 -0
- package/app/src/pages/dashboard/(cms)/network/themes/index.ts +82 -0
- package/app/src/pages/dashboard/(cms)/network/updates/index.ts +48 -0
- package/app/src/pages/dashboard/(cms)/network/users/[id]/index.ts +176 -0
- package/app/src/pages/dashboard/(cms)/network/users/index.ts +174 -0
- package/app/src/pages/dashboard/(cms)/network/users/new/index.ts +66 -0
- package/app/src/pages/dashboard/(cms)/plugins/index.ts +172 -0
- package/app/src/pages/dashboard/(cms)/profile/public/index.ts +105 -0
- package/app/src/pages/dashboard/(cms)/registrations/index.ts +70 -0
- package/app/src/pages/dashboard/(cms)/settings/index.ts +359 -0
- package/app/src/pages/dashboard/(cms)/settings/json/index.ts +202 -0
- package/app/src/pages/dashboard/(cms)/settings/layout.ts +67 -0
- package/app/src/pages/dashboard/(cms)/taxonomies/[name]/index.ts +85 -0
- package/app/src/pages/dashboard/(cms)/taxonomies/index.ts +98 -0
- package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/[id]/index.ts +244 -0
- package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/index.ts +148 -0
- package/app/src/pages/dashboard/(cms)/tools/activity/index.ts +94 -0
- package/app/src/pages/dashboard/(cms)/tools/automations/index.ts +131 -0
- package/app/src/pages/dashboard/(cms)/tools/cache/index.ts +92 -0
- package/app/src/pages/dashboard/(cms)/tools/export/index.ts +99 -0
- package/app/src/pages/dashboard/(cms)/tools/health/index.ts +189 -0
- package/app/src/pages/dashboard/(cms)/tools/jobs/index.ts +93 -0
- package/app/src/pages/dashboard/(cms)/tools/links/index.ts +115 -0
- package/app/src/pages/dashboard/(cms)/tools/redirects/index.ts +161 -0
- package/app/src/pages/dashboard/(cms)/tools/replace/index.ts +124 -0
- package/app/src/pages/dashboard/(cms)/tools/schema/index.ts +54 -0
- package/app/src/pages/dashboard/(cms)/tools/seo/index.ts +156 -0
- package/app/src/pages/dashboard/(cms)/tools/updates/index.ts +114 -0
- package/app/src/pages/dashboard/(cms)/tools/webhooks/index.ts +182 -0
- package/app/src/pages/dashboard/index.ts +214 -0
- package/app/src/pages/dashboard/layout.ts +320 -0
- package/app/src/pages/dashboard/profile/index.ts +211 -0
- package/app/src/pages/dashboard/profile/security/index.ts +255 -0
- package/app/src/pages/dashboard/roles/[id]/index.ts +116 -0
- package/app/src/pages/dashboard/roles/index.ts +134 -0
- package/app/src/pages/dashboard/roles/new/index.ts +95 -0
- package/app/src/pages/dashboard/sessions/index.ts +105 -0
- package/app/src/pages/dashboard/users/[id]/index.ts +472 -0
- package/app/src/pages/dashboard/users/index.ts +299 -0
- package/app/src/pages/dashboard/users/new/index.ts +123 -0
- package/app/src/passkeys.client.ts +18 -0
- package/app/src/plugins/default-theme/assets/cover.svg +31 -0
- package/app/src/plugins/default-theme/assets/logo.svg +8 -0
- package/app/src/plugins/default-theme/parts/comments.ts +66 -0
- package/app/src/plugins/default-theme/parts/list.ts +38 -0
- package/app/src/plugins/default-theme/parts/media.ts +15 -0
- package/app/src/plugins/default-theme/parts/options.ts +45 -0
- package/app/src/plugins/default-theme/plugin.json +275 -0
- package/app/src/plugins/default-theme/templates/archive.ts +14 -0
- package/app/src/plugins/default-theme/templates/entry-blank.ts +13 -0
- package/app/src/plugins/default-theme/templates/entry.ts +27 -0
- package/app/src/plugins/default-theme/templates/home.ts +8 -0
- package/app/src/plugins/default-theme/templates/layout.ts +40 -0
- package/app/src/plugins/default-theme/templates/not-found.ts +10 -0
- package/app/src/plugins/default-theme/templates/search.ts +32 -0
- package/app/src/services/rbac.ts +65 -0
- package/app/src/services/roles.ts +89 -0
- package/app/src/services/users.ts +173 -0
- package/package.json +123 -3
- package/src/automations.ts +95 -0
- package/src/bindings.ts +138 -0
- package/src/block-references.ts +239 -0
- package/src/block-shape.ts +155 -0
- package/src/blocks.ts +1157 -0
- package/src/cache.ts +54 -0
- package/src/checks.ts +198 -0
- package/src/cloudflare-workers.d.ts +13 -0
- package/src/cloudflare.ts +61 -0
- package/src/collab.ts +372 -0
- package/src/collections.ts +421 -0
- package/src/comments.ts +46 -0
- package/src/cron.ts +95 -0
- package/src/dashboard-menu.ts +105 -0
- package/src/diff.ts +113 -0
- package/src/editor-layout.ts +316 -0
- package/src/errors.ts +50 -0
- package/src/field-groups.ts +498 -0
- package/src/fields.ts +411 -0
- package/src/form-builder.ts +1053 -0
- package/src/forms.ts +109 -0
- package/src/highlight.ts +134 -0
- package/src/hooks.ts +510 -0
- package/src/icon-catalog.ts +55 -0
- package/src/icons.ts +128 -0
- package/src/images.ts +149 -0
- package/src/index.ts +100 -0
- package/src/isolate-core.ts +245 -0
- package/src/isolate.ts +19 -0
- package/src/isolation.ts +69 -0
- package/src/mail.ts +182 -0
- package/src/manifest.ts +476 -0
- package/src/media.ts +193 -0
- package/src/menus.ts +287 -0
- package/src/module.ts +32 -0
- package/src/modules/content.ts +64 -0
- package/src/modules/forms.ts +35 -0
- package/src/node.ts +66 -0
- package/src/notes.ts +237 -0
- package/src/permissions.ts +139 -0
- package/src/plugin-settings.ts +114 -0
- package/src/records.ts +56 -0
- package/src/redirects.ts +59 -0
- package/src/resource.ts +245 -0
- package/src/richtext.ts +402 -0
- package/src/schema-json.ts +112 -0
- package/src/search.ts +89 -0
- package/src/seo.ts +477 -0
- package/src/server/accounts.ts +418 -0
- package/src/server/ai.ts +33 -0
- package/src/server/api-tokens.ts +91 -0
- package/src/server/areas.ts +116 -0
- package/src/server/audit.ts +94 -0
- package/src/server/auth.ts +89 -0
- package/src/server/automations.ts +190 -0
- package/src/server/autosaves.ts +69 -0
- package/src/server/brand-icons.ts +50 -0
- package/src/server/brands.ts +86 -0
- package/src/server/budget.ts +97 -0
- package/src/server/cache.ts +104 -0
- package/src/server/capabilities.ts +333 -0
- package/src/server/cloudflare.ts +92 -0
- package/src/server/comments.ts +237 -0
- package/src/server/drafts.ts +176 -0
- package/src/server/field-groups.ts +88 -0
- package/src/server/files.ts +780 -0
- package/src/server/forms.ts +726 -0
- package/src/server/handoffs.ts +107 -0
- package/src/server/host-schema.ts +312 -0
- package/src/server/host.ts +2892 -0
- package/src/server/images.ts +34 -0
- package/src/server/index.ts +59 -0
- package/src/server/indexnow.ts +91 -0
- package/src/server/isolation.ts +183 -0
- package/src/server/locked.ts +45 -0
- package/src/server/mail.ts +93 -0
- package/src/server/markdown.ts +24 -0
- package/src/server/menus.ts +286 -0
- package/src/server/network-policy.ts +60 -0
- package/src/server/network.ts +665 -0
- package/src/server/notes.ts +275 -0
- package/src/server/outbox.ts +213 -0
- package/src/server/path-moves.ts +33 -0
- package/src/server/payments.ts +59 -0
- package/src/server/previews.ts +62 -0
- package/src/server/purge.ts +140 -0
- package/src/server/reconcile.ts +38 -0
- package/src/server/redirects.ts +183 -0
- package/src/server/repository.ts +1107 -0
- package/src/server/schedules.ts +105 -0
- package/src/server/schema.ts +562 -0
- package/src/server/security.ts +391 -0
- package/src/server/seed.ts +52 -0
- package/src/server/shared-fields.ts +34 -0
- package/src/server/site-export.ts +151 -0
- package/src/server/site-import.ts +482 -0
- package/src/server/site-search.ts +289 -0
- package/src/server/site-settings.ts +286 -0
- package/src/server/sites.ts +243 -0
- package/src/server/stores.ts +314 -0
- package/src/server/stripe.ts +173 -0
- package/src/server/taxonomies.ts +415 -0
- package/src/server/tokens.ts +25 -0
- package/src/server/traffic.ts +118 -0
- package/src/server/users.ts +653 -0
- package/src/server/webhooks.ts +245 -0
- package/src/settings-controls.ts +54 -0
- package/src/settings-document.ts +111 -0
- package/src/settings.ts +426 -0
- package/src/storage/cloudflare.ts +94 -0
- package/src/storage/index.ts +30 -0
- package/src/storage/node.ts +114 -0
- package/src/taxonomy.ts +51 -0
- package/src/theme.ts +1135 -0
- package/src/to-markdown.ts +179 -0
- package/src/updates.ts +126 -0
- package/src/version.ts +2 -0
- package/src/vite.d.ts +25 -0
- package/src/vite.js +199 -0
- package/src/webhooks.ts +107 -0
package/src/settings.ts
ADDED
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Site settings, declared as groups of fields. Declarations are data and client-safe; the
|
|
3
|
+
* host stores one row per key and validates writes against these declarations.
|
|
4
|
+
*/
|
|
5
|
+
import { CACHE_HOLDS, type CacheHold } from './cache';
|
|
6
|
+
import { field, type FieldDeclaration, type FieldMediaKind } from './fields';
|
|
7
|
+
import { DEFAULT_ICON_STYLE, ICON_STYLE_LABELS, ICON_STYLES, type IconStyleName } from './icons';
|
|
8
|
+
import { SEO_TEMPLATE_DEFAULTS } from './seo';
|
|
9
|
+
|
|
10
|
+
/** Choices filled in by the host when a form renders, such as the list of roles. */
|
|
11
|
+
/** Where a setting's choices come from; `media` lists the library's images by their URL. */
|
|
12
|
+
export type SettingSource = 'roles' | 'pages' | 'categories' | 'timezones' | 'media';
|
|
13
|
+
/** String settings keep their scalar value while offering a richer editor. */
|
|
14
|
+
export type SettingControl = 'color' | 'file' | 'icon-style' | 'palette';
|
|
15
|
+
|
|
16
|
+
export interface SettingDeclaration extends FieldDeclaration {
|
|
17
|
+
readonly source?: SettingSource;
|
|
18
|
+
/** color: a hex color; file: an HTTP(S) or root-relative file URL; icon-style and palette: an enum shown with a preview. */
|
|
19
|
+
readonly control?: SettingControl;
|
|
20
|
+
/** file control: the kinds the media chooser lists first; other kinds remain available. */
|
|
21
|
+
readonly fileKinds?: readonly FieldMediaKind[];
|
|
22
|
+
/** Labels for enum values. */
|
|
23
|
+
readonly choices?: { readonly [value: string]: string };
|
|
24
|
+
/** Display section within a plugin's settings; it does not change the stored key. */
|
|
25
|
+
readonly section?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface SettingsSection {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
readonly label: string;
|
|
31
|
+
readonly description?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface SettingsGroup {
|
|
35
|
+
/** Lowercase name, such as `general`. Keys are `<group>.<field>`. */
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly label: string;
|
|
38
|
+
readonly description?: string;
|
|
39
|
+
readonly fields: { readonly [name: string]: SettingDeclaration };
|
|
40
|
+
/** Permission needed to change the group. Default `cms:settings`; Appearance groups use `cms:appearance`. */
|
|
41
|
+
readonly permission?: string;
|
|
42
|
+
/** Shown as a subpage of this group, such as Crawlers under SEO; keys keep the group's own ID. */
|
|
43
|
+
readonly parent?: string;
|
|
44
|
+
/** An icon of the dashboard's set beside its name in the Settings navigation. */
|
|
45
|
+
readonly icon?: string;
|
|
46
|
+
/** Opt into the shared scalar JSON editor and its validated save operation. */
|
|
47
|
+
readonly json?: boolean;
|
|
48
|
+
/** Plugin owner, assigned by the host, never by a plugin's declaration. */
|
|
49
|
+
readonly plugin?: string;
|
|
50
|
+
readonly sections?: readonly SettingsSection[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const DATE_FORMATS = Object.freeze({ long: 'October 16, 2026', medium: 'Oct 16, 2026', iso: '2026-10-16', us: '10/16/2026', eu: '16/10/2026' });
|
|
54
|
+
export const TIME_FORMATS = Object.freeze({ '12h': '3:45 pm', '24h': '15:45' });
|
|
55
|
+
|
|
56
|
+
/** General and Media settings belong to the host; content modules add Writing and Reading. */
|
|
57
|
+
export const general: SettingsGroup = {
|
|
58
|
+
id: 'general',
|
|
59
|
+
json: true,
|
|
60
|
+
icon: 'settings',
|
|
61
|
+
label: 'General',
|
|
62
|
+
fields: {
|
|
63
|
+
siteTitle: field.string({ required: true, max: 120, default: 'My Site', label: 'Site title' }),
|
|
64
|
+
tagline: field.string({ max: 200, default: 'Just another Cossack site', label: 'Tagline', description: 'In a few words, explain what this site is about.' }),
|
|
65
|
+
adminEmail: field.string({ max: 254, default: '', pattern: '(?:[^\\s@]+@[^\\s@]+)?', label: 'Administration email address', description: 'Used for administration notices.' }),
|
|
66
|
+
usersCanRegister: field.boolean({ default: false, label: 'Anyone can register' }),
|
|
67
|
+
approveRegistrations: field.boolean({ default: false, label: 'An administrator approves new accounts', description: 'New registrants cannot sign in until a user manager approves them under Users → Registrations.' }),
|
|
68
|
+
verifyEmail: field.boolean({ default: true, label: 'New registrants confirm their email address', description: 'The account is active once the link in the email is opened. Without an email sender, accounts are active at once.' }),
|
|
69
|
+
defaultRole: { ...field.string({ max: 80, default: 'subscriber', label: 'New user default role' }), source: 'roles' },
|
|
70
|
+
timezone: { ...field.string({ max: 64, default: 'UTC', label: 'Timezone' }), source: 'timezones' },
|
|
71
|
+
dateFormat: { ...field.enum(Object.keys(DATE_FORMATS), { default: 'long', label: 'Date format' }), choices: DATE_FORMATS },
|
|
72
|
+
timeFormat: { ...field.enum(Object.keys(TIME_FORMATS), { default: '12h', label: 'Time format' }), choices: TIME_FORMATS },
|
|
73
|
+
weekStartsOn: { ...field.enum(['sunday', 'monday', 'saturday'], { default: 'monday', label: 'Week starts on' }), choices: { sunday: 'Sunday', monday: 'Monday', saturday: 'Saturday' } },
|
|
74
|
+
maintenance: { ...field.enum(['off', 'maintenance', 'soon'], { default: 'off', label: 'Maintenance mode', description: 'Visitors see a holding page with status 503 while people who can use the dashboard see the site. Search engines keep the pages indexed.' }),
|
|
75
|
+
choices: { off: 'Off: the site is public', maintenance: 'Maintenance: back soon', soon: 'Coming soon: not launched yet' } },
|
|
76
|
+
maintenanceMessage: field.text({ max: 2000, default: '', label: 'Holding page message', description: 'Shown under the site title; empty uses a sentence for the mode.' }),
|
|
77
|
+
requireTwoFactor: field.boolean({ default: false, label: 'Require two-step sign-in for everyone who can use the dashboard', description: 'They add an authenticator app or a passkey before they can continue.' }),
|
|
78
|
+
favicon: { ...field.string({ max: 2000, default: '', pattern: '(?:https?://[^\\s]+|/[^\\s]*)?', label: 'Site icon', description: 'Shown in browser tabs and bookmarks: an SVG or a square PNG from the library.' }), source: 'media' },
|
|
79
|
+
appIcon: { ...field.string({ max: 2000, default: '', pattern: '(?:https?://[^\\s]+|/[^\\s]*)?', label: 'App icon', description: 'For home screens and the web app manifest: a square PNG of at least 512 pixels from the library; it is resized as needed.' }), source: 'media' },
|
|
80
|
+
logo: { ...field.string({ max: 2000, default: '', pattern: '(?:https?://[^\\s]+|/[^\\s]*)?', label: 'Logo', description: 'The site\'s logo in any shape, shown in the site header, on sign-in pages and in the dashboard. Search results use the square SEO logo.' }), source: 'media' },
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const media: SettingsGroup = {
|
|
85
|
+
id: 'media',
|
|
86
|
+
json: true,
|
|
87
|
+
icon: 'gallery',
|
|
88
|
+
label: 'Files',
|
|
89
|
+
fields: {
|
|
90
|
+
maxUploadMb: field.integer({ default: 100, min: 1, max: 1_000_000, label: 'Maximum upload size (MB)', description: 'Uploads go straight to the bucket, so the limit is yours to set.' }),
|
|
91
|
+
maxImageWidth: field.integer({ default: 0, min: 0, max: 10_000, label: 'Largest image width (pixels)', description: 'JPEG, PNG, WebP and AVIF images wider than this are scaled down when uploaded. 0 keeps them as they are.' }),
|
|
92
|
+
imageWidths: field.string({ default: '320, 640, 960, 1280, 1920, 2560', max: 80, pattern: '\\s*\\d{2,4}(\\s*,\\s*\\d{2,4}){0,11}\\s*', label: 'Image widths (pixels)', description: 'Resized copies are made in these widths, and pages offer them to browsers. Up to 12, separated by commas.' }),
|
|
93
|
+
imageQuality: field.integer({ default: 78, min: 30, max: 100, label: 'Image quality', description: 'For JPEG and WebP copies, 30 to 100; AVIF copies use a little less for the same look.' }),
|
|
94
|
+
placeholder: { ...field.enum(['blurred', 'none'], { default: 'blurred', label: 'While images load' }), choices: { blurred: 'Show a blurred preview', none: 'Show nothing' } },
|
|
95
|
+
sizes: field.string({ default: '(min-width: 768px) 768px, 100vw', max: 200, label: 'Image sizes', description: 'How wide content images show, so browsers choose the right copy: the sizes attribute.' }),
|
|
96
|
+
eagerFirstImage: field.boolean({ default: true, label: 'Load the first image of a page at once', description: 'It is often the largest thing on screen; other images load as they come into view.' }),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** The base palettes of `@cossackframework/ui/theme/palettes.css` the dashboard can use, and the accents. */
|
|
101
|
+
export const DASHBOARD_PALETTES = Object.freeze(['neutral', 'zinc', 'gray', 'slate', 'stone'] as const);
|
|
102
|
+
export const DASHBOARD_ACCENTS = Object.freeze(['neutral', 'blue', 'green', 'red'] as const);
|
|
103
|
+
export type DashboardPalette = typeof DASHBOARD_PALETTES[number];
|
|
104
|
+
export type DashboardAccent = typeof DASHBOARD_ACCENTS[number];
|
|
105
|
+
|
|
106
|
+
/** Site-wide look of the interface: the icon style everywhere, and the dashboard's colors. */
|
|
107
|
+
export const interfaceGroup: SettingsGroup = {
|
|
108
|
+
id: 'interface',
|
|
109
|
+
json: true,
|
|
110
|
+
icon: 'monitor',
|
|
111
|
+
label: 'Interface',
|
|
112
|
+
fields: {
|
|
113
|
+
/** The Solar style every icon is drawn in, on the site and in the dashboard. */
|
|
114
|
+
iconStyle: { ...field.enum(ICON_STYLES, { default: DEFAULT_ICON_STYLE, label: 'Icon style', description: 'How icons are drawn on the site and in the dashboard.' }), choices: ICON_STYLE_LABELS, control: 'icon-style' },
|
|
115
|
+
palette: { ...field.enum(DASHBOARD_PALETTES, { default: 'neutral', label: 'Dashboard colors', description: 'The dashboard\'s surfaces and text, in light and dark mode. The site keeps its theme\'s colors.' }),
|
|
116
|
+
choices: { neutral: 'Neutral', zinc: 'Zinc', gray: 'Gray', slate: 'Slate', stone: 'Stone' }, control: 'palette' },
|
|
117
|
+
accent: { ...field.enum(DASHBOARD_ACCENTS, { default: 'neutral', label: 'Dashboard accent', description: 'Buttons, links, the current menu item and charts.' }),
|
|
118
|
+
choices: { neutral: 'Neutral', blue: 'Blue', green: 'Green', red: 'Red' }, control: 'palette' },
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/** The active theme, a plugin name. Changed under Appearance → Themes. */
|
|
123
|
+
/** How administrators arrange the dashboard's navigation (Appearance → Dashboard menu); checked by `dashboardMenuProblems` on write. */
|
|
124
|
+
export const dashboard: SettingsGroup = {
|
|
125
|
+
id: 'dashboard',
|
|
126
|
+
icon: 'sidebar-minimalistic',
|
|
127
|
+
label: 'Dashboard menu',
|
|
128
|
+
permission: 'cms:appearance',
|
|
129
|
+
fields: {
|
|
130
|
+
menu: field.json({ label: 'Menu' }),
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const appearance: SettingsGroup = {
|
|
135
|
+
id: 'appearance',
|
|
136
|
+
icon: 'palette',
|
|
137
|
+
label: 'Appearance',
|
|
138
|
+
permission: 'cms:appearance',
|
|
139
|
+
fields: {
|
|
140
|
+
theme: field.string({ max: 64, default: '', pattern: '(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*)?', label: 'Theme' }),
|
|
141
|
+
/** The site's color changes and additions, by theme: `{ [theme]: { colors: { [slug]: value }, custom: Preset[] } }`. Checked by `presetOverridesProblem` on write. */
|
|
142
|
+
presets: field.json({ label: 'Colors' }),
|
|
143
|
+
/** Site-wide CSS added under Customize; `customCssProblem` keeps it to styling. */
|
|
144
|
+
customCss: field.text({ max: 20_000, default: '', label: 'Additional CSS' }),
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export const writing: SettingsGroup = {
|
|
149
|
+
id: 'writing',
|
|
150
|
+
json: true,
|
|
151
|
+
icon: 'pen',
|
|
152
|
+
label: 'Writing',
|
|
153
|
+
fields: {
|
|
154
|
+
defaultCategory: { ...field.string({ max: 80, default: '', label: 'Default post category', description: 'Posts saved without a category get this one.' }), source: 'categories' },
|
|
155
|
+
defaultStatus: { ...field.enum(['draft', 'published'], { default: 'draft', label: 'Default status of new posts' }), choices: { draft: 'Draft', published: 'Published' } },
|
|
156
|
+
requireResolvedNotes: field.boolean({ default: false, label: 'Open notes hold publishing', description: 'An entry with open notes cannot be published or scheduled until they are resolved. Off, open notes are a warning in the editor\'s checks.' }),
|
|
157
|
+
notesEmail: field.boolean({ default: true, label: 'Email people a note names', description: 'Someone mentioned in a note, or replied to, gets the note by email with a link to the entry. Sent only when the application can send mail.' }),
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const reading: SettingsGroup = {
|
|
162
|
+
id: 'reading',
|
|
163
|
+
json: true,
|
|
164
|
+
icon: 'eye',
|
|
165
|
+
label: 'Reading',
|
|
166
|
+
fields: {
|
|
167
|
+
showOnFront: { ...field.enum(['posts', 'page'], { default: 'posts', label: 'Your homepage displays' }), choices: { posts: 'Your latest posts', page: 'A static page' } },
|
|
168
|
+
pageOnFront: { ...field.string({ max: 80, default: '', label: 'Homepage' }), source: 'pages' },
|
|
169
|
+
pageForPosts: { ...field.string({ max: 80, default: '', label: 'Posts page', description: 'This page lists your latest posts, such as when the homepage is a static page or posts live at the site root.' }), source: 'pages' },
|
|
170
|
+
postsPerPage: field.integer({ default: 10, min: 1, max: 100, label: 'Blog pages show at most' }),
|
|
171
|
+
feedItems: field.integer({ default: 10, min: 1, max: 100, label: 'Syndication feeds show the most recent' }),
|
|
172
|
+
feedContent: { ...field.enum(['excerpt', 'full'], { default: 'excerpt', label: 'For each post in a feed, include' }), choices: { excerpt: 'Excerpt', full: 'Full text' } },
|
|
173
|
+
discourageSearchEngines: field.boolean({ default: false, label: 'Discourage search engines from indexing this site' }),
|
|
174
|
+
notFoundPage: { ...field.string({ max: 80, default: '', label: 'Page for missing addresses', description: 'A published page shown, with status 404, when an address has no page; empty shows the theme\'s own.' }), source: 'pages' },
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/** Comments: who can post, what is held for moderation, and who is told. */
|
|
179
|
+
export const discussion: SettingsGroup = {
|
|
180
|
+
id: 'discussion',
|
|
181
|
+
json: true,
|
|
182
|
+
icon: 'chat-round-line',
|
|
183
|
+
label: 'Discussion',
|
|
184
|
+
fields: {
|
|
185
|
+
enabled: field.boolean({ default: true, label: 'Allow discussions', description: 'Off hides comments and their forms everywhere and refuses new ones. Stored comments are kept and can still be moderated.' }),
|
|
186
|
+
defaultOpen: field.boolean({ default: true, label: 'Allow people to submit comments on new entries' }),
|
|
187
|
+
requireNameEmail: field.boolean({ default: true, label: 'Comment authors must fill out their name and email' }),
|
|
188
|
+
requireSignIn: field.boolean({ default: false, label: 'Users must be signed in to comment' }),
|
|
189
|
+
closeAfterDays: field.integer({ default: 0, min: 0, max: 3650, label: 'Close comments on entries older than (days)', description: '0 keeps comments open.' }),
|
|
190
|
+
threadDepth: field.integer({ default: 3, min: 1, max: 5, label: 'Nest replies up to this many levels' }),
|
|
191
|
+
moderation: { ...field.enum(['all', 'first', 'none'], { default: 'first', label: 'Before a comment appears' }),
|
|
192
|
+
choices: { all: 'It must be approved', first: 'Its author must be signed in and have an earlier approved comment', none: 'Nothing: comments appear at once' } },
|
|
193
|
+
maxLinks: field.integer({ default: 2, min: 0, max: 20, label: 'Hold a comment for moderation when it has at least this many links', description: '0 holds none for links.' }),
|
|
194
|
+
blockedWords: field.text({ max: 5000, default: '', label: 'Disallowed words', description: 'One per line. A comment containing one in its content, name, email or URL goes to spam.' }),
|
|
195
|
+
notifyPosted: field.boolean({ default: true, label: 'Email the administration address when anyone posts a comment' }),
|
|
196
|
+
notifyHeld: field.boolean({ default: true, label: 'Email the administration address when a comment is held for moderation' }),
|
|
197
|
+
notifyAuthor: field.boolean({ default: true, label: 'Email entry authors about comments on their entries' }),
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/** Separators between an entry's title and the site title in `<title>`. */
|
|
202
|
+
export const TITLE_SEPARATORS = Object.freeze({ dash: '–', pipe: '|', hyphen: '-', dot: '·', slash: '/', colon: ':' });
|
|
203
|
+
|
|
204
|
+
/** Site-wide search and sharing settings; entries override them in their SEO box. */
|
|
205
|
+
export const seo: SettingsGroup = {
|
|
206
|
+
id: 'seo',
|
|
207
|
+
json: true,
|
|
208
|
+
icon: 'graph',
|
|
209
|
+
label: 'SEO',
|
|
210
|
+
fields: {
|
|
211
|
+
titleSeparator: { ...field.enum(Object.keys(TITLE_SEPARATORS), { default: 'dash', label: 'Title separator', description: 'Between an entry\'s title and the site title.' }), choices: TITLE_SEPARATORS },
|
|
212
|
+
homeTitle: field.string({ max: 300, default: SEO_TEMPLATE_DEFAULTS.home, label: 'Home page title', description: 'Variables: %site%, %tagline%, %sep%.' }),
|
|
213
|
+
entryTitle: field.string({ max: 300, default: SEO_TEMPLATE_DEFAULTS.entry, label: 'Entry title', description: 'For entries without their own SEO title. Variables: %title%, %site%, %sep%, %tagline%, %author%, %collection%, %date%. A collection can set its own.' }),
|
|
214
|
+
entryDescription: field.string({ max: 300, default: SEO_TEMPLATE_DEFAULTS.description, label: 'Entry description', description: 'For entries without their own meta description. Variables: %excerpt%, %title%, %site%, %author%, %date%.' }),
|
|
215
|
+
archiveTitle: field.string({ max: 300, default: SEO_TEMPLATE_DEFAULTS.archive, label: 'Archive title', description: 'Collection archives. Variables: %title%, %site%, %sep%, %page%.' }),
|
|
216
|
+
termTitle: field.string({ max: 300, default: SEO_TEMPLATE_DEFAULTS.term, label: 'Term archive title', description: 'Category and tag archives. Variables: %term%, %taxonomy%, %site%, %sep%, %page%.' }),
|
|
217
|
+
authorTitle: field.string({ max: 300, default: SEO_TEMPLATE_DEFAULTS.author, label: 'Author page title', description: 'Variables: %author%, %site%, %sep%, %page%.' }),
|
|
218
|
+
defaultImage: field.string({ max: 2000, default: '', pattern: '(?:https?://[^\\s]+|/[^\\s]*)?', label: 'Default social image', description: 'Shown when a shared entry has no image: a URL from the media library or another site.' }),
|
|
219
|
+
twitter: field.string({ max: 60, default: '', pattern: '(?:@?[A-Za-z0-9_]{1,50})?', label: 'X (Twitter) account', description: 'The site\'s handle, for cards of shared links.' }),
|
|
220
|
+
representation: { ...field.enum(['organization', 'person'], { default: 'organization', label: 'The site represents', description: 'Who publishes the site, in structured data: an organization or a person.' }), choices: { organization: 'An organization', person: 'A person' } },
|
|
221
|
+
publisherName: field.string({ max: 200, default: '', label: 'Organization or person name', description: 'The site title when empty.' }),
|
|
222
|
+
logo: { ...field.string({ max: 2000, default: '', pattern: '(?:https?://[^\\s]+|/[^\\s]*)?', label: 'Logo', description: 'A square image of at least 112 pixels from the library; shown next to the site in search results and AI answers.' }), source: 'media' },
|
|
223
|
+
sameAs: field.text({ max: 3000, default: '', label: 'Profiles', description: 'The publisher\'s profiles elsewhere, one URL per line: social accounts, Wikipedia, Wikidata, Crunchbase. They tell engines which entity the site is.' }),
|
|
224
|
+
authorPages: field.boolean({ default: true, label: 'Author pages', description: 'Each author has a page at /author/<name> listing their entries, which their articles link to as the author.' }),
|
|
225
|
+
maxImagePreview: { ...field.enum(['none', 'standard', 'large'], { default: 'large', label: 'Image previews in results', description: 'How large an image engines may show for the site\'s pages. Large is what Discover and AI answers use.' }), choices: { none: 'None', standard: 'Standard', large: 'Large' } },
|
|
226
|
+
llmsTxt: field.boolean({ default: true, label: 'Serve /llms.txt', description: 'A plain-text map of the site for AI assistants: the site, its collections and their latest entries with summaries. No engine has committed to reading it; it costs nothing.' }),
|
|
227
|
+
llmsTxtNotes: field.text({ max: 5000, default: '', label: 'Additional llms.txt sections', description: 'Markdown appended to the generated file: an About section, links to documentation, what to cite.' }),
|
|
228
|
+
markdown: field.boolean({ default: true, label: 'Serve entries as Markdown', description: 'A request with Accept: text/markdown, or ?format=md, gets the entry as Markdown with front matter, the way agents read pages.' }),
|
|
229
|
+
robotsTxt: field.text({ max: 5000, default: '', label: 'Additional robots.txt rules', description: 'Appended to the generated robots.txt.' }),
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/** Which crawlers robots.txt lets in, by what they do with the pages. */
|
|
234
|
+
export const crawlers: SettingsGroup = {
|
|
235
|
+
id: 'crawlers',
|
|
236
|
+
json: true,
|
|
237
|
+
icon: 'bolt',
|
|
238
|
+
label: 'Crawlers',
|
|
239
|
+
parent: 'seo',
|
|
240
|
+
description: 'Crawlers by purpose. robots.txt asks; it does not enforce. Fetchers acting for a person (ChatGPT-User, Claude-User, Perplexity-User) ignore it, as browsers do.',
|
|
241
|
+
fields: {
|
|
242
|
+
allowSearch: field.boolean({ default: true, label: 'Search engines', description: 'Googlebot, Bingbot, Applebot, DuckDuckBot, Yandex, Baidu. Their indexes also feed AI Overviews, AI Mode and Copilot.' }),
|
|
243
|
+
allowAiSearch: field.boolean({ default: true, label: 'AI search and answers', description: 'OAI-SearchBot (ChatGPT search), Claude-SearchBot, PerplexityBot. They cite the pages they index.' }),
|
|
244
|
+
allowAiTraining: field.boolean({ default: true, label: 'AI training', description: 'GPTBot, ClaudeBot, Google-Extended, CCBot, Applebot-Extended, Bytespider, meta-externalagent, Amazonbot. Blocking keeps the site out of future models; Google-Extended also stops Gemini grounding.' }),
|
|
245
|
+
contentSignals: field.boolean({ default: false, label: 'Add a Content-Signal line', description: 'States the same preferences in Cloudflare\'s Content-Signal format (search, ai-input, ai-train). Google and Bing ignore it; Cloudflare reads it.' }),
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/** IndexNow: pings Bing, Yandex, Naver and Seznam when entries change. */
|
|
250
|
+
export const indexnow: SettingsGroup = {
|
|
251
|
+
id: 'indexnow',
|
|
252
|
+
json: true,
|
|
253
|
+
icon: 'rocket',
|
|
254
|
+
label: 'IndexNow',
|
|
255
|
+
parent: 'seo',
|
|
256
|
+
description: 'Tells Bing, Yandex, Naver and Seznam at once when a page is published, changed or removed, so their results and Copilot answers refresh within minutes. Google does not take part. Needs APP_URL.',
|
|
257
|
+
fields: {
|
|
258
|
+
enabled: field.boolean({ default: false, label: 'Ping IndexNow when entries change' }),
|
|
259
|
+
key: field.string({ max: 128, default: '', pattern: '(?:[A-Za-z0-9-]{8,128})?', label: 'Key', description: 'Made for you when pings are on; served at /indexnow/<key>.txt. Paste your own to keep one you already registered.' }),
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
/** Cache: how long the caches in front of the site may hold its pages. Purging is the host's `purge` service and Tools → Cache. */
|
|
264
|
+
export const cache: SettingsGroup = {
|
|
265
|
+
id: 'cache',
|
|
266
|
+
json: true,
|
|
267
|
+
icon: 'bolt',
|
|
268
|
+
label: 'Cache',
|
|
269
|
+
description: 'How long a cache in front of the site, such as Cloudflare with a cache-everything rule, may hold a page. Changes purge the pages they touch once a purger is set up (CLOUDFLARE_API_TOKEN); Tools → Cache shows purges and purges everything.',
|
|
270
|
+
fields: {
|
|
271
|
+
hold: { ...field.enum(CACHE_HOLDS, { default: 'auto', label: 'Hold pages' }),
|
|
272
|
+
choices: { auto: 'Automatic: five minutes, or a day once a purger is set up', none: 'Do not hold pages', minute: 'A minute', hour: 'An hour', day: 'A day', week: 'A week' } },
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/** How the emails the site sends look: each goes out as plain text with an HTML part laid out from it. */
|
|
277
|
+
export const email: SettingsGroup = {
|
|
278
|
+
id: 'email',
|
|
279
|
+
json: true,
|
|
280
|
+
icon: 'letter',
|
|
281
|
+
label: 'Email',
|
|
282
|
+
description: 'Every email the site sends (sign-up and sign-in links, password resets, invitations, comment, note and form notifications, automations, plugin mail) has an HTML part with the site title and logo above and a footer below, and the plain text alongside.',
|
|
283
|
+
fields: {
|
|
284
|
+
accentColor: { ...field.string({ max: 9, default: '#2563eb', label: 'Accent color', description: 'Of the button and the links.' }), control: 'color' },
|
|
285
|
+
logo: { ...field.string({ max: 2000, default: '', pattern: '(?:https?://[^\\s]+|/[^\\s]*)?', label: 'Logo', description: 'Shown before the site title: a PNG or JPEG, since many email apps do not show SVG. Empty uses the site logo or app icon when it is not an SVG.' }), source: 'media' },
|
|
286
|
+
footer: field.text({ max: 1000, default: '', label: 'Footer text', description: 'Under every message, above the site name and address: a postal address, or why people get these emails.' }),
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
/** The site's languages: others under `/<code>/`, the default one too when `urls` is `all`. */
|
|
291
|
+
/** Page views are counted by an outside service: a count here would be a database write per view, past the cache. */
|
|
292
|
+
export const analytics: SettingsGroup = {
|
|
293
|
+
id: 'analytics',
|
|
294
|
+
json: true,
|
|
295
|
+
icon: 'chart',
|
|
296
|
+
label: 'Analytics',
|
|
297
|
+
description: 'An outside service counts page views: the site adds its script and stores nothing. People signed in are left out.',
|
|
298
|
+
fields: {
|
|
299
|
+
cloudflareToken: field.string({ max: 80, default: '', pattern: '[A-Za-z0-9]*', label: 'Cloudflare Web Analytics token', description: 'Cloudflare Web Analytics uses no cookies. Leave empty for none.' }),
|
|
300
|
+
googleMeasurementId: field.string({ max: 22, default: '', pattern: '(?:G-[A-Z0-9]{4,20})?', label: 'Google Analytics measurement ID', description: 'Starts with G-. Google Analytics sets cookies, so many regions require a consent banner first. Browsers asking not to be tracked are left out. Leave empty for none.' }),
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
export const languages: SettingsGroup = {
|
|
305
|
+
id: 'languages',
|
|
306
|
+
icon: 'global',
|
|
307
|
+
label: 'Languages',
|
|
308
|
+
fields: {
|
|
309
|
+
default: field.string({ required: true, max: 16, default: 'en', pattern: '[a-z]{2,3}(?:-[a-z0-9]{2,8})?', label: 'Default language' }),
|
|
310
|
+
others: field.string({ max: 300, default: '', pattern: '(?:[a-z]{2,3}(?:-[a-z0-9]{2,8})?(?:,[a-z]{2,3}(?:-[a-z0-9]{2,8})?){0,19})?', label: 'Other languages', description: 'Codes separated by commas, such as fr,de,pt-br.' }),
|
|
311
|
+
urls: { ...field.enum(['hide-default', 'all'], { default: 'hide-default', label: 'Language in URLs' }),
|
|
312
|
+
choices: { 'hide-default': 'Hide the default language\'s code', all: 'Every language has its code' } },
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
/** Values of the built-in groups, with defaults applied. */
|
|
317
|
+
export interface SiteSettings {
|
|
318
|
+
'general.siteTitle': string;
|
|
319
|
+
'general.tagline': string;
|
|
320
|
+
'general.adminEmail': string;
|
|
321
|
+
'general.usersCanRegister': boolean;
|
|
322
|
+
'general.verifyEmail': boolean;
|
|
323
|
+
'general.approveRegistrations': boolean;
|
|
324
|
+
'general.defaultRole': string;
|
|
325
|
+
'general.timezone': string;
|
|
326
|
+
'general.dateFormat': keyof typeof DATE_FORMATS;
|
|
327
|
+
'general.timeFormat': keyof typeof TIME_FORMATS;
|
|
328
|
+
'general.weekStartsOn': 'sunday' | 'monday' | 'saturday';
|
|
329
|
+
'general.requireTwoFactor': boolean;
|
|
330
|
+
'general.maintenance': 'off' | 'maintenance' | 'soon';
|
|
331
|
+
'general.maintenanceMessage': string;
|
|
332
|
+
'general.favicon': string;
|
|
333
|
+
'general.appIcon': string;
|
|
334
|
+
'general.logo': string;
|
|
335
|
+
'media.maxUploadMb': number;
|
|
336
|
+
'media.maxImageWidth': number;
|
|
337
|
+
'media.imageWidths': string;
|
|
338
|
+
'media.imageQuality': number;
|
|
339
|
+
'media.placeholder': 'blurred' | 'none';
|
|
340
|
+
'media.sizes': string;
|
|
341
|
+
'media.eagerFirstImage': boolean;
|
|
342
|
+
'dashboard.menu': { readonly order?: readonly string[]; readonly hidden?: readonly string[]; readonly links?: readonly { id: string; label: string; href: string; icon?: string }[] } | null;
|
|
343
|
+
'appearance.theme': string;
|
|
344
|
+
'interface.iconStyle': IconStyleName;
|
|
345
|
+
'interface.palette': DashboardPalette;
|
|
346
|
+
'interface.accent': DashboardAccent;
|
|
347
|
+
'appearance.presets': { readonly [theme: string]: { readonly colors?: { readonly [slug: string]: string }; readonly custom?: readonly { slug: string; name: string; value: string }[]; readonly gradients?: { readonly [slug: string]: string }; readonly customGradients?: readonly { slug: string; name: string; value: string }[] } } | null;
|
|
348
|
+
'appearance.customCss': string;
|
|
349
|
+
'writing.defaultCategory': string;
|
|
350
|
+
'writing.defaultStatus': 'draft' | 'published';
|
|
351
|
+
'writing.requireResolvedNotes': boolean;
|
|
352
|
+
'writing.notesEmail': boolean;
|
|
353
|
+
'reading.showOnFront': 'posts' | 'page';
|
|
354
|
+
'reading.pageOnFront': string;
|
|
355
|
+
'reading.pageForPosts': string;
|
|
356
|
+
'reading.postsPerPage': number;
|
|
357
|
+
'reading.feedItems': number;
|
|
358
|
+
'reading.feedContent': 'excerpt' | 'full';
|
|
359
|
+
'reading.discourageSearchEngines': boolean;
|
|
360
|
+
'reading.notFoundPage': string;
|
|
361
|
+
'email.accentColor': string;
|
|
362
|
+
'email.logo': string;
|
|
363
|
+
'email.footer': string;
|
|
364
|
+
'analytics.cloudflareToken': string;
|
|
365
|
+
'analytics.googleMeasurementId': string;
|
|
366
|
+
'discussion.enabled': boolean;
|
|
367
|
+
'discussion.defaultOpen': boolean;
|
|
368
|
+
'discussion.requireNameEmail': boolean;
|
|
369
|
+
'discussion.requireSignIn': boolean;
|
|
370
|
+
'discussion.closeAfterDays': number;
|
|
371
|
+
'discussion.threadDepth': number;
|
|
372
|
+
'discussion.moderation': 'all' | 'first' | 'none';
|
|
373
|
+
'discussion.maxLinks': number;
|
|
374
|
+
'discussion.blockedWords': string;
|
|
375
|
+
'discussion.notifyPosted': boolean;
|
|
376
|
+
'discussion.notifyHeld': boolean;
|
|
377
|
+
'discussion.notifyAuthor': boolean;
|
|
378
|
+
'seo.titleSeparator': keyof typeof TITLE_SEPARATORS;
|
|
379
|
+
'seo.homeTitle': string;
|
|
380
|
+
'seo.entryTitle': string;
|
|
381
|
+
'seo.entryDescription': string;
|
|
382
|
+
'seo.archiveTitle': string;
|
|
383
|
+
'seo.termTitle': string;
|
|
384
|
+
'seo.authorTitle': string;
|
|
385
|
+
'seo.defaultImage': string;
|
|
386
|
+
'seo.twitter': string;
|
|
387
|
+
'seo.representation': 'organization' | 'person';
|
|
388
|
+
'seo.publisherName': string;
|
|
389
|
+
'seo.logo': string;
|
|
390
|
+
'seo.sameAs': string;
|
|
391
|
+
'seo.authorPages': boolean;
|
|
392
|
+
'seo.maxImagePreview': 'none' | 'standard' | 'large';
|
|
393
|
+
'seo.llmsTxt': boolean;
|
|
394
|
+
'seo.llmsTxtNotes': string;
|
|
395
|
+
'seo.markdown': boolean;
|
|
396
|
+
'seo.robotsTxt': string;
|
|
397
|
+
'crawlers.allowSearch': boolean;
|
|
398
|
+
'crawlers.allowAiSearch': boolean;
|
|
399
|
+
'crawlers.allowAiTraining': boolean;
|
|
400
|
+
'crawlers.contentSignals': boolean;
|
|
401
|
+
'indexnow.enabled': boolean;
|
|
402
|
+
'indexnow.key': string;
|
|
403
|
+
'cache.hold': CacheHold;
|
|
404
|
+
'languages.default': string;
|
|
405
|
+
'languages.others': string;
|
|
406
|
+
'languages.urls': 'hide-default' | 'all';
|
|
407
|
+
readonly [key: string]: unknown;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** Format a time in the site's timezone and date format. */
|
|
411
|
+
export function formatSiteDate(value: number, settings: Pick<SiteSettings, 'general.timezone' | 'general.dateFormat'>, options: { time?: false | keyof typeof TIME_FORMATS } = {}): string {
|
|
412
|
+
const timeZone = validTimeZone(settings['general.timezone']) ? settings['general.timezone'] : 'UTC';
|
|
413
|
+
const date = new Date(value);
|
|
414
|
+
const parts = Object.fromEntries(new Intl.DateTimeFormat('en-US', { timeZone, year: 'numeric', month: '2-digit', day: '2-digit' }).formatToParts(date).map(part => [part.type, part.value]));
|
|
415
|
+
const text = settings['general.dateFormat'] === 'iso' ? `${parts.year}-${parts.month}-${parts.day}`
|
|
416
|
+
: settings['general.dateFormat'] === 'us' ? `${parts.month}/${parts.day}/${parts.year}`
|
|
417
|
+
: settings['general.dateFormat'] === 'eu' ? `${parts.day}/${parts.month}/${parts.year}`
|
|
418
|
+
: new Intl.DateTimeFormat('en-US', { timeZone, dateStyle: settings['general.dateFormat'] === 'medium' ? 'medium' : 'long' }).format(date);
|
|
419
|
+
if (!options.time) return text;
|
|
420
|
+
const time = new Intl.DateTimeFormat('en-US', { timeZone, hour: 'numeric', minute: '2-digit', hour12: options.time === '12h' }).format(date);
|
|
421
|
+
return `${text} ${options.time === '12h' ? time.toLowerCase() : time}`;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export function validTimeZone(zone: string): boolean {
|
|
425
|
+
try { new Intl.DateTimeFormat('en-US', { timeZone: zone }); return true; } catch { return false; }
|
|
426
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { createR2StorageProvider, type R2StorageBucket } from '@cossackframework/framework/storage/r2';
|
|
2
|
+
import { organizationDatabases } from '@cossackframework/romedb';
|
|
3
|
+
import { DurableObjectPendingWriteStore, type DurableObjectNamespaceLike } from '@cossackframework/romedb/cloudflare';
|
|
4
|
+
import type { CmsStorage } from './index';
|
|
5
|
+
|
|
6
|
+
/** The part of the Cloudflare Images binding the CMS uses. */
|
|
7
|
+
interface ImagesBinding {
|
|
8
|
+
input(stream: ReadableStream<Uint8Array>): ImagesChain;
|
|
9
|
+
}
|
|
10
|
+
interface ImagesChain {
|
|
11
|
+
transform(options: Record<string, unknown>): ImagesChain;
|
|
12
|
+
output(options: { format: string; quality?: number }): Promise<{ response(): Response }>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The bindings {@link cloudflareStorage} reads. */
|
|
16
|
+
export interface CloudflareStorageBindings {
|
|
17
|
+
/**
|
|
18
|
+
* RomeDB database URL. Workers reach RomeDB over HTTP: a RomeDB Cloud database, or
|
|
19
|
+
* `romedb serve` in development (`pnpm dev` starts it for a loopback URL).
|
|
20
|
+
*/
|
|
21
|
+
ROMEDB_URL?: string;
|
|
22
|
+
/** Database grant (Cloud `query` scope) or the local service token. Server-only. */
|
|
23
|
+
ROMEDB_TOKEN?: string;
|
|
24
|
+
/** Where added sites keep their databases: a RomeDB Cloud organization URL, or `romedb serve --directory`. */
|
|
25
|
+
ROMEDB_SITES_URL?: string;
|
|
26
|
+
/** Organization key with the `manage` and `query` scopes, for ROMEDB_SITES_URL. Server-only. */
|
|
27
|
+
ROMEDB_SITES_TOKEN?: string;
|
|
28
|
+
/** Durable Object namespace for RomeDBPendingWrites (exported from src/index.ts). */
|
|
29
|
+
ROMEDB_PENDING?: DurableObjectNamespaceLike;
|
|
30
|
+
/** R2 bucket for uploaded media (r2_buckets in wrangler.jsonc). */
|
|
31
|
+
MEDIA?: R2StorageBucket;
|
|
32
|
+
/** Cloudflare Images (images in wrangler.jsonc): resized variants, crops and modern formats. */
|
|
33
|
+
IMAGES?: ImagesBinding;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The CMS's storage on Cloudflare Workers: RomeDB over HTTP, unconfirmed writes in a Durable
|
|
38
|
+
* Object, media in R2 and resized images through the Images binding.
|
|
39
|
+
*/
|
|
40
|
+
export const cloudflareStorage: CmsStorage<CloudflareStorageBindings> = {
|
|
41
|
+
databaseConnection(env) {
|
|
42
|
+
const url = env.ROMEDB_URL;
|
|
43
|
+
const token = env.ROMEDB_TOKEN;
|
|
44
|
+
if (!url || !token) throw new Error('The CMS needs ROMEDB_URL and ROMEDB_TOKEN: a RomeDB Cloud database, or a loopback URL that pnpm dev serves with romedb serve.');
|
|
45
|
+
return { url, token };
|
|
46
|
+
},
|
|
47
|
+
/** Null while sites cannot have their own database (no ROMEDB_SITES_URL). */
|
|
48
|
+
siteDatabase(env, database) {
|
|
49
|
+
const sites = env.ROMEDB_SITES_URL;
|
|
50
|
+
if (!sites) return null;
|
|
51
|
+
if (!env.ROMEDB_SITES_TOKEN) throw new Error('ROMEDB_SITES_URL needs ROMEDB_SITES_TOKEN, an organization key with the manage and query scopes.');
|
|
52
|
+
return { url: `${sites.replace(/\/$/, '')}/databases/${database}`, token: env.ROMEDB_SITES_TOKEN };
|
|
53
|
+
},
|
|
54
|
+
siteDirectory(env) {
|
|
55
|
+
return env.ROMEDB_SITES_URL && env.ROMEDB_SITES_TOKEN ? organizationDatabases({ url: env.ROMEDB_SITES_URL, token: env.ROMEDB_SITES_TOKEN }) : null;
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* Writes are saved in a Durable Object before dispatch, so an unconfirmed write survives the
|
|
59
|
+
* isolate. Each database has its own objects; the main site's keep their name.
|
|
60
|
+
*/
|
|
61
|
+
pendingWrites(env, database = 'main') {
|
|
62
|
+
if (!env.ROMEDB_PENDING) throw new Error('Bind the ROMEDB_PENDING Durable Object (class RomeDBPendingWrites) in wrangler.jsonc.');
|
|
63
|
+
return new DurableObjectPendingWriteStore(env.ROMEDB_PENDING, database === 'main' ? {} : { name: `romedb:${database}` });
|
|
64
|
+
},
|
|
65
|
+
/** Media bytes live in R2. Without the binding, uploads are unavailable. */
|
|
66
|
+
mediaStorage(env) {
|
|
67
|
+
return env.MEDIA ? createR2StorageProvider(env.MEDIA) : undefined;
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Resized images through the Images binding. Local development runs a low-fidelity version
|
|
71
|
+
* without crops; variants then keep the whole image.
|
|
72
|
+
*/
|
|
73
|
+
imageTransformer(env) {
|
|
74
|
+
const images = env.IMAGES;
|
|
75
|
+
if (!images) return undefined;
|
|
76
|
+
return {
|
|
77
|
+
async transform(input, request) {
|
|
78
|
+
const bytes = await new Response(input).arrayBuffer();
|
|
79
|
+
const { rect, source } = request;
|
|
80
|
+
const whole = rect.x === 0 && rect.y === 0 && rect.width === source.width && rect.height === source.height;
|
|
81
|
+
const run = async (trim: boolean) => {
|
|
82
|
+
let chain = images.input(new Response(bytes).body!);
|
|
83
|
+
if (trim) chain = chain.transform({ trim: { top: rect.y, left: rect.x, bottom: source.height - rect.y - rect.height, right: source.width - rect.x - rect.width } });
|
|
84
|
+
chain = chain.transform({ width: request.width, height: request.height, fit: 'cover' });
|
|
85
|
+
const output = await chain.output({ format: `image/${request.format}`, quality: request.quality });
|
|
86
|
+
return new Uint8Array(await output.response().arrayBuffer());
|
|
87
|
+
};
|
|
88
|
+
if (whole) return run(false);
|
|
89
|
+
try { return await run(true); } catch { return run(false); }
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
// Webhook deliveries use the Worker's own fetch, which cannot reach private networks.
|
|
94
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { StorageProvider } from '@cossackframework/core/storage';
|
|
2
|
+
import type { DatabaseDirectory, PendingWriteStore, RomeDBOptions } from '@cossackframework/romedb';
|
|
3
|
+
import type { ImageTransformer } from '../server/images';
|
|
4
|
+
|
|
5
|
+
/** How to reach one RomeDB database. */
|
|
6
|
+
export type DatabaseConnection = Pick<RomeDBOptions, 'url' | 'token' | 'connect'>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Where the CMS keeps its data on one runtime: the database, unconfirmed writes, media bytes
|
|
10
|
+
* and resized images. A project names one in `src/cms.config.ts` (`cloudflareStorage` from
|
|
11
|
+
* `@cossackframework/cms/storage/cloudflare`, `nodeStorage` from `@cossackframework/cms/storage/node`), and
|
|
12
|
+
* replaces a member to keep something elsewhere: `{ ...nodeStorage, mediaStorage: env => ... }`.
|
|
13
|
+
* `env` is the runtime's environment bindings.
|
|
14
|
+
*/
|
|
15
|
+
export interface CmsStorage<Env = never> {
|
|
16
|
+
/** How the CMS reaches its database. */
|
|
17
|
+
databaseConnection(env: Env): DatabaseConnection;
|
|
18
|
+
/** How the CMS reaches an added site's database, or null while sites cannot have their own. */
|
|
19
|
+
siteDatabase(env: Env, database: string): DatabaseConnection | null;
|
|
20
|
+
/** Creates and deletes added sites' databases, or null when sites cannot have their own. */
|
|
21
|
+
siteDirectory(env: Env): DatabaseDirectory | null;
|
|
22
|
+
/** Where unconfirmed writes wait. `database` is `main` or an added site's database. */
|
|
23
|
+
pendingWrites(env: Env, database?: string): PendingWriteStore;
|
|
24
|
+
/** Where media bytes live. Without one, uploads are unavailable. */
|
|
25
|
+
mediaStorage(env: Env): StorageProvider | undefined;
|
|
26
|
+
/** Resized variants, crops and modern formats. Without one, images keep their size. */
|
|
27
|
+
imageTransformer(env: Env): ImageTransformer | undefined;
|
|
28
|
+
/** The `fetch` of webhook deliveries; unset uses the runtime's own. */
|
|
29
|
+
readonly webhookFetch?: typeof fetch;
|
|
30
|
+
}
|