@cossackframework/cms 0.0.0 → 0.9.2
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 +145 -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 +21 -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 +709 -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 +114 -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 +62 -0
- package/app/src/dashboard/avatar-field.ts +58 -0
- package/app/src/dashboard/bulk.ts +22 -0
- package/app/src/dashboard/head.ts +29 -0
- package/app/src/dashboard/icons.ts +15 -0
- package/app/src/dashboard/list-table.ts +28 -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 +18 -0
- package/app/src/dashboard/session-list.ts +98 -0
- package/app/src/dashboard/tabs.ts +2 -0
- package/app/src/dashboard/time-ago.ts +16 -0
- package/app/src/dashboard/types.ts +43 -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 +82 -0
- package/app/src/pages/auth/layout.ts +32 -0
- package/app/src/pages/auth/login/index.ts +205 -0
- package/app/src/pages/auth/magic/index.ts +68 -0
- package/app/src/pages/auth/register/index.ts +124 -0
- package/app/src/pages/auth/reset-password/index.ts +74 -0
- package/app/src/pages/auth/setup/index.ts +194 -0
- package/app/src/pages/auth/two-factor/index.ts +69 -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 +183 -0
- package/app/src/pages/dashboard/index.ts +214 -0
- package/app/src/pages/dashboard/layout.ts +227 -0
- package/app/src/pages/dashboard/profile/index.ts +211 -0
- package/app/src/pages/dashboard/profile/security/index.ts +249 -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 +114 -2
- 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
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Cossack, Page, State, Server, Client, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { input } from '@cossackframework/core/input';
|
|
3
|
+
import { Button, Card, CardBody, CardHeader, Checkbox, Field, Input, NativeSelect } from '@cossackframework/ui';
|
|
4
|
+
import { html, component } from '@cossackframework/renderer';
|
|
5
|
+
import { isCmsError, PERMISSIONS, recordTitle, type Block, type RichTextDoc } from '@cossackframework/cms';
|
|
6
|
+
import { replaceableFields, replaceInBlocks, replaceInDoc, replaceInText } from '#app/cms/replace';
|
|
7
|
+
import { requireAny } from '#app/cms/guards';
|
|
8
|
+
import { notice, pageHeader } from '#app/cms/ui';
|
|
9
|
+
|
|
10
|
+
interface Match { id: string; title: string; href: string; fields: string[]; count: number }
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Tools → Find and replace: a word or phrase across a collection's titles, excerpts, summaries,
|
|
14
|
+
* Markdown and rich text, previewed before it is applied. Each changed entry gets a revision,
|
|
15
|
+
* so a replacement can be undone entry by entry.
|
|
16
|
+
*/
|
|
17
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageSettings)] })
|
|
18
|
+
export default class ReplacePage extends Cossack {
|
|
19
|
+
@State() collections: { name: string; label: string }[] = [];
|
|
20
|
+
@State() collection = 'posts';
|
|
21
|
+
@State() find = '';
|
|
22
|
+
@State() replace = '';
|
|
23
|
+
@State() matchCase = false;
|
|
24
|
+
@State() matches: Match[] = [];
|
|
25
|
+
@State() scanned = 0;
|
|
26
|
+
@State() previewed = false;
|
|
27
|
+
@State() message = '';
|
|
28
|
+
@State() error = '';
|
|
29
|
+
|
|
30
|
+
head(): HeadValue {
|
|
31
|
+
return { title: 'Find and replace' };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async init() {
|
|
35
|
+
this.collections = this.c.get('cms').collections().filter(collection => !collection.managed).map(collection => ({ name: collection.name, label: collection.label }));
|
|
36
|
+
if (!this.collections.some(collection => collection.name === this.collection)) this.collection = this.collections[0]?.name ?? '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Client()
|
|
40
|
+
async submit(event: Event, apply: boolean) {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
if (apply) await this.run(this.collection, this.find, this.replace, this.matchCase, true);
|
|
43
|
+
else await this.run(this.collection, this.find, this.replace, this.matchCase, false);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Scan up to a thousand entries; with `apply`, write the replacement to every matching entry. */
|
|
47
|
+
@Server({ input: input.args(input.string({ maxLength: 2000 }), input.string({ maxLength: 2000 }), input.string({ maxLength: 2000 }), input.boolean(), input.boolean()) })
|
|
48
|
+
async run(collection: string, find: string, replace: string, matchCase: boolean, apply: boolean) {
|
|
49
|
+
this.error = '';
|
|
50
|
+
this.message = '';
|
|
51
|
+
this.collection = collection;
|
|
52
|
+
this.find = find.slice(0, 200);
|
|
53
|
+
this.replace = replace.slice(0, 2000);
|
|
54
|
+
this.matchCase = matchCase;
|
|
55
|
+
this.matches = [];
|
|
56
|
+
this.scanned = 0;
|
|
57
|
+
this.previewed = false;
|
|
58
|
+
if (!this.find) { this.error = __('Enter the text to find.'); return; }
|
|
59
|
+
const cms = this.c.get('cms');
|
|
60
|
+
const principal = this.c.get('principal');
|
|
61
|
+
const definition = cms.collections().find(entry => entry.name === collection);
|
|
62
|
+
if (!definition) { this.error = __('Choose a collection.'); return; }
|
|
63
|
+
const resource = cms.resource(`cms/${collection}`);
|
|
64
|
+
const fields = replaceableFields(cms.resourceById(`cms/${collection}`).fields);
|
|
65
|
+
const pattern = new RegExp(this.find.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), matchCase ? 'g' : 'gi');
|
|
66
|
+
try {
|
|
67
|
+
for (let offset = 0; offset < 1000; offset += 100) {
|
|
68
|
+
const page = await resource.list({ limit: 100, offset, order: { field: 'updatedAt', direction: 'desc' } }, { principal });
|
|
69
|
+
for (const record of page.records) {
|
|
70
|
+
// Only entries this user may change are searched: a count over one they may not would
|
|
71
|
+
// tell what a protected or members-only entry says.
|
|
72
|
+
if (!resource.canUpdate(record, principal)) continue;
|
|
73
|
+
this.scanned++;
|
|
74
|
+
const changed: Record<string, unknown> = {};
|
|
75
|
+
const touched: string[] = [];
|
|
76
|
+
let count = 0;
|
|
77
|
+
for (const [name, declaration] of fields) {
|
|
78
|
+
const value = record[name];
|
|
79
|
+
const result = declaration.kind === 'richtext' ? replaceInDoc(value as RichTextDoc | null, pattern, this.replace)
|
|
80
|
+
: declaration.kind === 'blocks' ? replaceInBlocks(value as Block[] | null, cms.blockTypes, pattern, this.replace)
|
|
81
|
+
: typeof value === 'string' ? replaceInText(value, pattern, this.replace) : null;
|
|
82
|
+
if (!result || !result.count) continue;
|
|
83
|
+
changed[name] = result.value;
|
|
84
|
+
touched.push(declaration.label ?? name);
|
|
85
|
+
count += result.count;
|
|
86
|
+
}
|
|
87
|
+
if (!count) continue;
|
|
88
|
+
if (apply) await resource.update(record.id, changed, { principal, expectedRevision: record.rev as number });
|
|
89
|
+
this.matches.push({ id: record.id, title: recordTitle(record, 'title'), href: `/dashboard/content/${collection}/${record.id}`, fields: touched, count });
|
|
90
|
+
}
|
|
91
|
+
if (page.records.length < 100) break;
|
|
92
|
+
}
|
|
93
|
+
this.previewed = !apply;
|
|
94
|
+
const total = this.matches.reduce((sum, match) => sum + match.count, 0);
|
|
95
|
+
if (apply) this.message = this.matches.length ? `${__('Replaced')} ${total} ${__('occurrence(s) in')} ${this.matches.length} ${__('entry(ies)')}.` : __('Nothing matched, so nothing changed.');
|
|
96
|
+
} catch (error) {
|
|
97
|
+
this.error = isCmsError(error) ? error.message : __('The scan failed.');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
render() {
|
|
102
|
+
const total = this.matches.reduce((sum, match) => sum + match.count, 0);
|
|
103
|
+
return html`<div class="space-y-6">
|
|
104
|
+
${pageHeader(__('Find and replace'), { description: __('Change a word or phrase across a collection. Preview first; every changed entry keeps a revision.') })}
|
|
105
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
106
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
107
|
+
${component(Card, {}, component(CardBody, {}, html`<form class="grid gap-4 md:grid-cols-[12rem_1fr_1fr]" @submit=${(event: Event) => this.submit(event, false)}>
|
|
108
|
+
${component(Field, { label: __('Collection'), for: 'replace-collection', control: attributes => component(NativeSelect, { ...attributes, '@change': (event: Event) => { this.collection = (event.target as HTMLSelectElement).value; } }, html`
|
|
109
|
+
${this.collections.map(collection => html`<option value=${collection.name} ?selected=${collection.name === this.collection}>${collection.label}</option>`)}`) })}
|
|
110
|
+
${component(Field, { label: __('Find'), for: 'replace-find', control: attributes => component(Input, { ...attributes, required: true, maxlength: 200, '.value': this.find, '@input': (event: Event) => { this.find = (event.target as HTMLInputElement).value; } }) })}
|
|
111
|
+
${component(Field, { label: __('Replace with'), for: 'replace-with', control: attributes => component(Input, { ...attributes, maxlength: 2000, '.value': this.replace, '@input': (event: Event) => { this.replace = (event.target as HTMLInputElement).value; } }) })}
|
|
112
|
+
<div class="md:col-span-3">${component(Checkbox, { label: __('Match case'), checked: this.matchCase, '@change': (event: Event) => { this.matchCase = (event.target as HTMLInputElement).checked; } })}</div>
|
|
113
|
+
<div class="flex flex-wrap gap-2 md:col-span-3">
|
|
114
|
+
${component(Button, { type: 'submit', variant: 'outline' }, __('Preview'))}
|
|
115
|
+
${component(Button, { type: 'button', variant: 'destructive', disabled: !this.previewed || !this.matches.length, '@click': (event: Event) => this.submit(event, true) }, __('Replace in every matching entry'))}
|
|
116
|
+
</div>
|
|
117
|
+
</form>`))}
|
|
118
|
+
${this.previewed || this.message ? component(Card, {}, html`${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${this.previewed ? __('Would change') : __('Changed')} ${this.matches.length} ${__('of')} ${this.scanned} ${__('entries')} · ${total} ${__('occurrence(s)')}</h2>`)}
|
|
119
|
+
${component(CardBody, { class: 'p-0' }, this.matches.length ? html`<ul class="divide-y divide-border" data-testid="replace-matches">${this.matches.map(match => html`<li class="flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-sm">
|
|
120
|
+
<a href=${match.href} class="font-medium text-foreground hover:underline">${match.title}</a><span class="text-xs text-muted-foreground">${match.count} × ${__('in')} ${match.fields.join(', ')}</span></li>`)}</ul>`
|
|
121
|
+
: html`<p class="px-4 py-6 text-sm text-muted-foreground">${__('No entry contains the text.')}</p>`)}`) : null}
|
|
122
|
+
</div>`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Cossack, Page, State, flash, flashed, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Card, CardBody, Button } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { isSameOriginPost, PERMISSIONS } from '@cossackframework/cms';
|
|
5
|
+
import { requireAny } from '#app/cms/guards';
|
|
6
|
+
import { notice, pageHeader } from '#app/cms/ui';
|
|
7
|
+
|
|
8
|
+
interface StepView { id: string; description: string; rql: string[] }
|
|
9
|
+
|
|
10
|
+
/** The schema plan: additive DDL and explicit steps, applied one atomic batch at a time. */
|
|
11
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageSchema)] })
|
|
12
|
+
export default class SchemaPage extends Cossack {
|
|
13
|
+
@State() steps: StepView[] = [];
|
|
14
|
+
@State() blocked: string[] = [];
|
|
15
|
+
@State() warnings: string[] = [];
|
|
16
|
+
@State() engine = '';
|
|
17
|
+
@State() message = '';
|
|
18
|
+
|
|
19
|
+
head(): HeadValue {
|
|
20
|
+
return { title: 'Schema' };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async init() {
|
|
24
|
+
const plan = await this.c.get('cms').plan();
|
|
25
|
+
this.engine = plan.engineVersion;
|
|
26
|
+
this.steps = plan.steps.map(step => ({ id: step.id, description: step.description, rql: step.statements.map(statement => statement.rql) }));
|
|
27
|
+
this.blocked = plan.blocked.map(problem => `${problem.resource}: ${problem.message}`);
|
|
28
|
+
this.warnings = plan.warnings.map(problem => `${problem.resource}: ${problem.message}`);
|
|
29
|
+
this.message = flashed<string>('cms.message') ?? '';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async post() {
|
|
33
|
+
if (!isSameOriginPost(this.c.req.raw)) return this.c.text('Forbidden', 403);
|
|
34
|
+
const report = await this.c.get('cms').migrate();
|
|
35
|
+
flash('cms.message', report.failed
|
|
36
|
+
? `Step "${report.failed.step.description}" failed and was rolled back: ${report.failed.message}`
|
|
37
|
+
: `Applied ${report.applied.length} step(s).`);
|
|
38
|
+
return this.redirect('/dashboard/tools/schema');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
render() {
|
|
42
|
+
return html`<div class="max-w-4xl space-y-6">
|
|
43
|
+
${pageHeader(__('Schema'), { description: `RomeDB engine ${this.engine}. ${__('Collections apply their own changes when saved; code-declared resources and plugins migrate here.')}` })}
|
|
44
|
+
${this.message ? notice(this.message) : null}
|
|
45
|
+
${this.blocked.map(problem => notice(problem, 'error'))}
|
|
46
|
+
${this.warnings.map(problem => notice(problem))}
|
|
47
|
+
${this.steps.length ? html`<ol class="space-y-3">${this.steps.map(step => html`<li>${component(Card, {}, component(CardBody, { class: 'space-y-2' }, html`
|
|
48
|
+
<p class="text-sm font-medium text-foreground">${step.description}</p>
|
|
49
|
+
<pre class="overflow-x-auto rounded-md bg-muted p-3 text-xs">${step.rql.join(';\n')}</pre>`))}</li>`)}</ol>
|
|
50
|
+
<form method="post">${component(Button, { type: 'submit' }, __('Apply the plan'))}</form>`
|
|
51
|
+
: notice(__('The database matches every declaration.'))}
|
|
52
|
+
</div>`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Cossack, Page, State, Server, Client, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Button, Card, CardBody, Input, NativeSelect, Textarea } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { isCmsError, PERMISSIONS, recordTitle, renderSeoTemplate, TITLE_SEPARATORS, type FieldFilter } from '@cossackframework/cms';
|
|
5
|
+
import { requireAny } from '#app/cms/guards';
|
|
6
|
+
import { notice, pageHeader } from '#app/cms/ui';
|
|
7
|
+
|
|
8
|
+
interface SeoRow { id: string; title: string; url: string | null; status: string; seoTitle: string; description: string; summary: string; rev: number; saved: boolean }
|
|
9
|
+
|
|
10
|
+
const PAGE_SIZE = 25;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* SEO titles, meta descriptions and summaries of a collection's entries in one table, to fill
|
|
14
|
+
* in or fix many at once. Each row saves on its own, with a revision check so a concurrent
|
|
15
|
+
* edit in the entry editor is not overwritten.
|
|
16
|
+
*/
|
|
17
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageSettings)] })
|
|
18
|
+
export default class SeoEditorPage extends Cossack {
|
|
19
|
+
@State() collections: { name: string; label: string; summary: boolean }[] = [];
|
|
20
|
+
@State() collection = '';
|
|
21
|
+
@State() rows: SeoRow[] = [];
|
|
22
|
+
@State() total = 0;
|
|
23
|
+
@State() page = 1;
|
|
24
|
+
@State() filter: 'all' | 'missing' = 'all';
|
|
25
|
+
@State() template = { title: '%title% %sep% %site%', sep: '–', site: '' };
|
|
26
|
+
@State() error = '';
|
|
27
|
+
/** What the last row save did. */
|
|
28
|
+
@State() message = '';
|
|
29
|
+
|
|
30
|
+
head(): HeadValue {
|
|
31
|
+
return { title: __('SEO editor') };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async init() {
|
|
35
|
+
const cms = this.c.get('cms');
|
|
36
|
+
this.collections = cms.collections().filter(collection => typeof collection.path === 'string' && !collection.managed).map(collection => ({ name: collection.name, label: collection.label, summary: Boolean(cms.resourceById(`cms/${collection.name}`).fields.summary) }));
|
|
37
|
+
this.collection = this.collections.find(entry => entry.name === this.c.req.query('collection'))?.name ?? this.collections[0]?.name ?? '';
|
|
38
|
+
this.filter = this.c.req.query('filter') === 'missing' ? 'missing' : 'all';
|
|
39
|
+
const page = Number(this.c.req.query('page'));
|
|
40
|
+
this.page = Number.isSafeInteger(page) && page > 0 ? page : 1;
|
|
41
|
+
await this.load();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Server()
|
|
45
|
+
async load() {
|
|
46
|
+
const cms = this.c.get('cms');
|
|
47
|
+
if (!this.collection) return;
|
|
48
|
+
const collection = cms.collection(this.collection);
|
|
49
|
+
const settings = await cms.settings.all();
|
|
50
|
+
this.template = { title: collection.seoTemplates?.title || settings['seo.entryTitle'], sep: TITLE_SEPARATORS[settings['seo.titleSeparator']] ?? '–', site: settings['general.siteTitle'] };
|
|
51
|
+
const where: { [field: string]: FieldFilter } = collection.publishable === false ? {} : { status: 'published' };
|
|
52
|
+
const repository = cms.resource(`cms/${collection.name}`);
|
|
53
|
+
const principal = this.c.get('principal');
|
|
54
|
+
// The missing filter reads up to 500 entries and keeps those without a description or summary.
|
|
55
|
+
const limit = this.filter === 'missing' ? 100 : PAGE_SIZE;
|
|
56
|
+
const records = [];
|
|
57
|
+
let total = 0;
|
|
58
|
+
if (this.filter === 'missing') {
|
|
59
|
+
for (let offset = 0; offset < 500; offset += 100) {
|
|
60
|
+
const page = await repository.list({ where, limit: 100, offset, order: { field: 'updatedAt', direction: 'desc' } }, { principal });
|
|
61
|
+
records.push(...page.records.filter(record => !(record.seo as { description?: string } | null)?.description || !(typeof record.summary === 'string' && record.summary)));
|
|
62
|
+
if (page.records.length < 100) break;
|
|
63
|
+
}
|
|
64
|
+
total = records.length;
|
|
65
|
+
} else {
|
|
66
|
+
const page = await repository.list({ where, limit, offset: (this.page - 1) * PAGE_SIZE, order: { field: 'updatedAt', direction: 'desc' } }, { principal });
|
|
67
|
+
records.push(...page.records);
|
|
68
|
+
total = await repository.count({ where }, { principal });
|
|
69
|
+
}
|
|
70
|
+
const slice = this.filter === 'missing' ? records.slice((this.page - 1) * PAGE_SIZE, this.page * PAGE_SIZE) : records;
|
|
71
|
+
const urls = await cms.entryUrls(collection, slice);
|
|
72
|
+
this.total = total;
|
|
73
|
+
// A locked entry's summary is written from its content: only its editors see it.
|
|
74
|
+
this.rows = slice.map(stored => repository.readerView(stored, principal)).map(record => {
|
|
75
|
+
const seo = (record.seo ?? {}) as { title?: string; description?: string };
|
|
76
|
+
return { id: record.id, title: recordTitle(record, 'title'), url: urls.get(record.id) ?? null, status: String(record.status ?? ''), seoTitle: seo.title ?? '', description: seo.description ?? '', summary: typeof record.summary === 'string' ? record.summary : '', rev: record.rev, saved: false };
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Client()
|
|
81
|
+
set(id: string, key: 'seoTitle' | 'description' | 'summary', value: string) {
|
|
82
|
+
this.rows = this.rows.map(row => row.id === id ? { ...row, [key]: value, saved: false } : row);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Client()
|
|
86
|
+
async save(id: string) {
|
|
87
|
+
const row = this.rows.find(entry => entry.id === id);
|
|
88
|
+
if (!row) return;
|
|
89
|
+
this.message = '';
|
|
90
|
+
await this.store(row);
|
|
91
|
+
if (!this.error) this.message = __('Saved.');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@Server()
|
|
95
|
+
async store(row: SeoRow) {
|
|
96
|
+
this.error = '';
|
|
97
|
+
const cms = this.c.get('cms');
|
|
98
|
+
try {
|
|
99
|
+
// The collection and its fields as the host has them: the client's list only names one.
|
|
100
|
+
const collection = cms.collections().find(entry => entry.name === this.collection && typeof entry.path === 'string' && !entry.managed);
|
|
101
|
+
if (!collection) { this.error = __('The entry no longer exists.'); return; }
|
|
102
|
+
const repository = cms.resource(`cms/${collection.name}`);
|
|
103
|
+
const current = await repository.get(row.id, { principal: this.c.get('principal') });
|
|
104
|
+
if (!current) { this.error = __('The entry no longer exists.'); return; }
|
|
105
|
+
const seo = { ...((current.seo as Record<string, unknown> | null) ?? {}), title: row.seoTitle.trim(), description: row.description.trim() };
|
|
106
|
+
const summary = Boolean(cms.resourceById(`cms/${collection.name}`).fields.summary);
|
|
107
|
+
const saved = await repository.update(row.id, { seo, ...(summary ? { summary: row.summary.trim() } : {}) }, { principal: this.c.get('principal'), expectedRevision: row.rev });
|
|
108
|
+
this.rows = this.rows.map(entry => entry.id === row.id ? { ...entry, rev: saved.rev, saved: true } : entry);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
this.error = isCmsError(error) ? (error.code === 'CMS_CONFLICT' ? __('Someone changed this entry meanwhile; reload the page.') : error.message) : __('The entry could not be saved.');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
render() {
|
|
115
|
+
const pages = Math.max(1, Math.ceil(this.total / PAGE_SIZE));
|
|
116
|
+
const href = (query: { collection?: string; filter?: string; page?: number }) => `/dashboard/tools/seo?collection=${encodeURIComponent(query.collection ?? this.collection)}&filter=${query.filter ?? this.filter}&page=${query.page ?? 1}`;
|
|
117
|
+
const counter = (text: string, ideal: number) => html`<span class=${`text-xs ${[...text].length > ideal ? 'text-amber-600' : 'text-muted-foreground'}`}>${[...text].length}/${ideal}</span>`;
|
|
118
|
+
const summary = this.collections.find(entry => entry.name === this.collection)?.summary ?? false;
|
|
119
|
+
return html`<div class="space-y-6">
|
|
120
|
+
${pageHeader(__('SEO editor'), { description: __('Titles, descriptions and summaries of many entries at once. Empty titles and descriptions use the templates in Settings → SEO.') })}
|
|
121
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
122
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
123
|
+
<form method="get" action="/dashboard/tools/seo" class="flex flex-wrap items-end gap-3">
|
|
124
|
+
<label class="text-sm text-foreground">${__('Collection')}<br>${component(NativeSelect, { name: 'collection', '@change': (event: Event) => { window.location.href = href({ collection: (event.target as HTMLSelectElement).value }); } }, html`
|
|
125
|
+
${this.collections.map(entry => html`<option value=${entry.name} ?selected=${entry.name === this.collection}>${entry.label}</option>`)}`)}</label>
|
|
126
|
+
<nav class="flex gap-3 text-sm">
|
|
127
|
+
<a href=${href({ filter: 'all' })} class=${this.filter === 'all' ? 'font-semibold text-foreground no-underline' : 'text-primary hover:underline'}>${__('All published')}</a>
|
|
128
|
+
<a href=${href({ filter: 'missing' })} class=${this.filter === 'missing' ? 'font-semibold text-foreground no-underline' : 'text-primary hover:underline'}>${__('Missing a description or summary')}</a>
|
|
129
|
+
</nav>
|
|
130
|
+
</form>
|
|
131
|
+
${component(Card, {}, component(CardBody, {}, this.rows.length ? html`<div class="space-y-5">${this.rows.map(row => html`<div class="grid gap-3 border-b border-border pb-5 last:border-0 last:pb-0 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto]">
|
|
132
|
+
<div class="min-w-0 space-y-1">
|
|
133
|
+
<a href=${`/dashboard/content/${this.collection}/${row.id}`} class="block truncate font-medium text-foreground hover:text-primary" title=${row.title}>${row.title}</a>
|
|
134
|
+
${row.url ? html`<p class="truncate text-xs text-muted-foreground">${row.url}</p>` : null}
|
|
135
|
+
<p class="truncate text-xs text-blue-700 dark:text-blue-400" title=${__('Title in results')}>${renderSeoTemplate(this.template.title, { title: row.seoTitle || row.title, sep: this.template.sep, site: this.template.site })}</p>
|
|
136
|
+
<div class="flex items-center justify-between"><label for=${`seo-title-${row.id}`} class="text-xs font-medium text-foreground">${__('SEO title')}</label>${counter(row.seoTitle, 60)}</div>
|
|
137
|
+
${component(Input, { id: `seo-title-${row.id}`, size: 'sm', placeholder: row.title, '.value': row.seoTitle, '@input': (event: Event) => this.set(row.id, 'seoTitle', (event.target as HTMLInputElement).value) })}
|
|
138
|
+
</div>
|
|
139
|
+
<div class="min-w-0 space-y-1">
|
|
140
|
+
<div class="flex items-center justify-between"><label for=${`seo-description-${row.id}`} class="text-xs font-medium text-foreground">${__('Meta description')}</label>${counter(row.description, 155)}</div>
|
|
141
|
+
${component(Textarea, { id: `seo-description-${row.id}`, rows: 3, '.value': row.description, '@input': (event: Event) => this.set(row.id, 'description', (event.target as HTMLTextAreaElement).value) })}
|
|
142
|
+
</div>
|
|
143
|
+
<div class="min-w-0 space-y-1">
|
|
144
|
+
${summary ? html`<div class="flex items-center justify-between"><label for=${`seo-summary-${row.id}`} class="text-xs font-medium text-foreground">${__('Summary')}</label>${counter(row.summary, 300)}</div>
|
|
145
|
+
${component(Textarea, { id: `seo-summary-${row.id}`, rows: 3, '.value': row.summary, '@input': (event: Event) => this.set(row.id, 'summary', (event.target as HTMLTextAreaElement).value) })}` : null}
|
|
146
|
+
</div>
|
|
147
|
+
<div class="flex items-end">${component(Button, { type: 'button', size: 'sm', variant: row.saved ? 'outline' : 'default', '@click': () => this.save(row.id) }, row.saved ? __('Saved') : __('Save'))}</div>
|
|
148
|
+
</div>`)}</div>` : html`<p class="text-sm text-muted-foreground">${this.filter === 'missing' ? __('Every entry has a description or a summary.') : __('No published entries.')}</p>`))}
|
|
149
|
+
${pages > 1 ? html`<nav aria-label=${__('Pages')} class="flex items-center justify-between text-sm">
|
|
150
|
+
${this.page > 1 ? html`<a href=${href({ page: this.page - 1 })} class="text-primary hover:underline">← ${__('Previous')}</a>` : html`<span></span>`}
|
|
151
|
+
<span class="text-muted-foreground">${__('Page')} ${this.page} ${__('of')} ${pages}</span>
|
|
152
|
+
${this.page < pages ? html`<a href=${href({ page: this.page + 1 })} class="text-primary hover:underline">${__('Next')} →</a>` : html`<span></span>`}
|
|
153
|
+
</nav>` : null}
|
|
154
|
+
</div>`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Cossack, Page, State, flash, flashed, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Badge, Button, Card, CardBody, CardHeader } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { ANONYMOUS, isSameOriginPost, type Principal } from '@cossackframework/cms';
|
|
5
|
+
import { defineServerMiddleware } from '@cossackframework/core';
|
|
6
|
+
import { networkFor, updateSettings, type CmsBindings } from '#app/cms/index';
|
|
7
|
+
import { clearRequest, requestUpdate, updateHook, updateStatus, type UpdateStatus } from '#app/cms/updates';
|
|
8
|
+
import { managesUpdates } from '#app/dashboard/access';
|
|
9
|
+
import { notice, pageHeader, shortDate } from '#app/cms/ui';
|
|
10
|
+
|
|
11
|
+
/** Holders of the updates permission on the main site; in a network, its administrators. */
|
|
12
|
+
const requireUpdates = defineServerMiddleware(async (c, next) => {
|
|
13
|
+
if (await managesUpdates(c, c.get('principal') ?? ANONYMOUS)) { await next(); return; }
|
|
14
|
+
return c.redirect('/dashboard');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const EMPTY: UpdateStatus = { installed: '', checking: true, checkedAt: null, available: null, error: '', request: null, hook: false, progressUrl: null };
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Tools → Updates: the installed version, the latest one the update server named, and a button
|
|
21
|
+
* that asks the project's pipeline to update the site. A running site cannot change its own
|
|
22
|
+
* code: the pipeline runs `cossack upgrade`, and the project's deploy ships the result.
|
|
23
|
+
*/
|
|
24
|
+
@Page({ transport: 'http', middlewares: [requireUpdates] })
|
|
25
|
+
export default class UpdatesPage extends Cossack {
|
|
26
|
+
@State() status: UpdateStatus = EMPTY;
|
|
27
|
+
@State() message = '';
|
|
28
|
+
@State() error = '';
|
|
29
|
+
|
|
30
|
+
head(): HeadValue {
|
|
31
|
+
return { title: 'Updates' };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async init() {
|
|
35
|
+
const env = this.c.env as CmsBindings;
|
|
36
|
+
this.status = await updateStatus(networkFor(env), updateSettings(env), updateHook(env));
|
|
37
|
+
this.message = flashed<string>('updates.message') ?? '';
|
|
38
|
+
this.error = flashed<string>('updates.error') ?? '';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async post() {
|
|
42
|
+
if (!isSameOriginPost(this.c.req.raw)) return this.c.text('Forbidden', 403);
|
|
43
|
+
const form = await this.c.req.formData();
|
|
44
|
+
const action = String(form.get('action') ?? '');
|
|
45
|
+
const env = this.c.env as CmsBindings;
|
|
46
|
+
const network = networkFor(env);
|
|
47
|
+
const principal: Principal = this.c.get('principal') ?? ANONYMOUS;
|
|
48
|
+
const by = principal.kind === 'user' ? principal.id : 'system';
|
|
49
|
+
try {
|
|
50
|
+
if (action === 'update') {
|
|
51
|
+
// An older build cannot open the database after the update: the person confirms a backup first.
|
|
52
|
+
if (form.get('backup') !== 'yes') throw new Error(__('Confirm that you have a backup first.'));
|
|
53
|
+
const request = await requestUpdate(network, updateSettings(env), updateHook(env), by);
|
|
54
|
+
await this.c.get('cms').audit.record({ actor: by, action: 'request-update', resource: 'cms/updates', recordId: request.version }).catch(() => undefined);
|
|
55
|
+
flash('updates.message', `${__('Update requested: version')} ${request.version}.`);
|
|
56
|
+
} else if (action === 'clear') {
|
|
57
|
+
await clearRequest(network);
|
|
58
|
+
flash('updates.message', __('The request was cleared. You can ask again.'));
|
|
59
|
+
} else throw new Error(__('Unknown action.'));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
flash('updates.error', error instanceof Error ? error.message : __('The update could not be requested.'));
|
|
62
|
+
}
|
|
63
|
+
return this.redirect('/dashboard/tools/updates');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
render() {
|
|
67
|
+
const { status } = this;
|
|
68
|
+
const available = status.available;
|
|
69
|
+
return html`<div class="space-y-6">
|
|
70
|
+
${pageHeader(__('Updates'), { description: __('The version this site runs, and the latest one.') })}
|
|
71
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
72
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
73
|
+
<div class="grid gap-6 xl:grid-cols-[minmax(0,1fr)_24rem]">
|
|
74
|
+
<div class="space-y-6">
|
|
75
|
+
${component(Card, {}, html`${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Versions')}</h2>`)}
|
|
76
|
+
${component(CardBody, { class: 'space-y-3 text-sm' }, html`
|
|
77
|
+
<p data-testid="installed-version">${__('Installed')}: <strong>${status.installed}</strong></p>
|
|
78
|
+
${available ? html`<p data-testid="latest-version">${__('Latest')}: <strong>${available.latest}</strong>
|
|
79
|
+
${available.security ? component(Badge, { variant: 'destructive' }, __('Security fix')) : component(Badge, { variant: 'secondary' }, __('Update available'))}
|
|
80
|
+
${available.published ? html`<span class="text-muted-foreground"> · ${shortDate(available.published)}</span>` : null}</p>
|
|
81
|
+
${available.notes ? html`<p><a class="text-primary underline" href=${available.notes} rel="noreferrer noopener" target="_blank">${__('Release notes')}</a></p>` : null}
|
|
82
|
+
${available.hostTemplate ? html`<p class="text-muted-foreground">${__('This update also changes files in the project. cossack upgrade merges them with your edits.')}</p>` : null}`
|
|
83
|
+
: html`<p class="text-muted-foreground" data-testid="latest-version">${!status.checking ? __('This site does not ask for new versions (updates.check is off in src/cms.config.ts).')
|
|
84
|
+
: status.checkedAt ? __('This is the latest version.') : __('No answer from the update server yet. The site asks once a day.')}</p>`}
|
|
85
|
+
${status.checkedAt ? html`<p class="text-xs text-muted-foreground">${__('Last checked')} ${shortDate(status.checkedAt)}${status.error ? html` · ${status.error}` : null}</p>` : null}`)}`)}
|
|
86
|
+
${available ? component(Card, {}, html`${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Update this site')}</h2>`)}
|
|
87
|
+
${component(CardBody, { class: 'space-y-3 text-sm' }, status.request ? html`
|
|
88
|
+
<p data-testid="update-requested">${__('Update requested: version')} <strong>${status.request.version}</strong> · ${shortDate(status.request.requestedAt)}</p>
|
|
89
|
+
<p class="text-muted-foreground">${__('The project\'s pipeline runs cossack upgrade, and the site shows the new version after its next deploy.')}
|
|
90
|
+
${status.progressUrl ? html` <a class="text-primary underline" href=${status.progressUrl} rel="noreferrer noopener" target="_blank">${__('See its progress')}</a>.` : null}</p>
|
|
91
|
+
<form method="post"><input type="hidden" name="action" value="clear">${component(Button, { type: 'submit', size: 'sm', variant: 'outline' }, __('Request again'))}</form>`
|
|
92
|
+
: status.hook ? html`
|
|
93
|
+
<p class="text-muted-foreground">${__('The button asks the project\'s pipeline to run cossack upgrade. The pipeline tests the result and opens a pull request, or deploys it, as the project set it up.')}</p>
|
|
94
|
+
<p class="text-muted-foreground">${__('Take a backup first. The update may change the database, and an older build cannot open it afterwards: going back means restoring the backup together with the older code.')}
|
|
95
|
+
<a class="text-primary underline" href="/dashboard/tools/export">${__('Tools → Export')}</a></p>
|
|
96
|
+
<form method="post" class="space-y-3">
|
|
97
|
+
<input type="hidden" name="action" value="update">
|
|
98
|
+
<label class="flex items-start gap-2"><input type="checkbox" name="backup" value="yes" required class="mt-1"><span>${__('I have a backup of this site\'s content.')}</span></label>
|
|
99
|
+
${component(Button, { type: 'submit' }, `${__('Update to')} ${available.latest}`)}
|
|
100
|
+
</form>`
|
|
101
|
+
: html`
|
|
102
|
+
<p>${__('Run this in the project, then deploy:')}</p>
|
|
103
|
+
<pre class="rounded-md bg-muted px-3 py-2 text-xs"><code>pnpm cossack upgrade</code></pre>
|
|
104
|
+
<p class="text-muted-foreground">${__('To update from this page, give the site an update hook: CMS_UPDATE_HOOK_URL and CMS_UPDATE_HOOK_TOKEN in its environment. See docs/cms/updates.md.')}</p>`)}`) : null}
|
|
105
|
+
</div>
|
|
106
|
+
<aside class="space-y-4">
|
|
107
|
+
${component(Card, {}, component(CardBody, { class: 'space-y-3' }, html`<h2 class="text-base font-semibold text-foreground">${__('How it works')}</h2>
|
|
108
|
+
<p class="text-xs text-muted-foreground">${__('Once a day the site asks the update server which version is the latest. It sends its own version and channel, and nothing about the site.')}</p>
|
|
109
|
+
<p class="text-xs text-muted-foreground">${__('The CMS is a package of the project. An update changes the project\'s dependencies, so it goes through the project\'s own pipeline, never around it.')}</p>`))}
|
|
110
|
+
</aside>
|
|
111
|
+
</div>
|
|
112
|
+
</div>`;
|
|
113
|
+
}
|
|
114
|
+
}
|