@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
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Cossack, Page, State, Server, Client, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { input } from '@cossackframework/core/input';
|
|
3
|
+
import { AlertDialog, Badge, Button, Card, CardBody, CardHeader, Checkbox, Field, Input } from '@cossackframework/ui';
|
|
4
|
+
import { html, component } from '@cossackframework/renderer';
|
|
5
|
+
import { isCmsError, PERMISSIONS, WEBHOOK_EVENTS, type Webhook, type WebhookDelivery, type WebhookEvent } from '@cossackframework/cms';
|
|
6
|
+
import { requireAny } from '#app/cms/guards';
|
|
7
|
+
import { notice, pageHeader, shortDate } from '#app/cms/ui';
|
|
8
|
+
|
|
9
|
+
const EVENT_LABELS: Record<WebhookEvent, string> = {
|
|
10
|
+
'entry.created': 'An entry is created', 'entry.updated': 'An entry changes', 'entry.published': 'An entry is published',
|
|
11
|
+
'entry.unpublished': 'An entry is unpublished', 'entry.deleted': 'An entry is deleted', 'form.submitted': 'A form is submitted',
|
|
12
|
+
'note.created': 'A note is left on an entry', 'note.resolved': 'A note is resolved', 'payment.completed': 'A payment is completed',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
interface Form { id: string; name: string; url: string; events: string[]; collections: string[]; active: boolean }
|
|
16
|
+
const EMPTY: Form = { id: '', name: '', url: '', events: ['entry.published', 'entry.unpublished'], collections: [], active: true };
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Webhooks post entry events to other services, such as a static site's build hook. Each
|
|
20
|
+
* delivery is signed with the webhook's secret and retried with backoff when it fails.
|
|
21
|
+
*/
|
|
22
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageWebhooks)] })
|
|
23
|
+
export default class WebhooksPage extends Cossack {
|
|
24
|
+
@State() hooks: Webhook[] = [];
|
|
25
|
+
@State() collections: { name: string; label: string }[] = [];
|
|
26
|
+
@State() form: Form = { ...EMPTY, events: [...EMPTY.events] };
|
|
27
|
+
@State() deliveries: WebhookDelivery[] = [];
|
|
28
|
+
@State() selected = '';
|
|
29
|
+
/** The selected webhook's secret, once shown: lists carry only its first characters. */
|
|
30
|
+
@State() revealed = '';
|
|
31
|
+
@State() error = '';
|
|
32
|
+
/** What the last save or test did. */
|
|
33
|
+
@State() message = '';
|
|
34
|
+
@State() pendingDelete: Webhook | null = null;
|
|
35
|
+
|
|
36
|
+
head(): HeadValue {
|
|
37
|
+
return { title: __('Webhooks') };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async init() {
|
|
41
|
+
this.collections = this.c.get('cms').collections().map(collection => ({ name: collection.name, label: collection.label }));
|
|
42
|
+
await this.load(this.c.req.query('id') ?? '');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Server()
|
|
46
|
+
async load(id: string) {
|
|
47
|
+
const cms = this.c.get('cms');
|
|
48
|
+
this.hooks = await cms.webhooks.list();
|
|
49
|
+
const hook = this.hooks.find(entry => entry.id === id);
|
|
50
|
+
this.selected = hook?.id ?? '';
|
|
51
|
+
this.revealed = '';
|
|
52
|
+
this.form = hook ? { id: hook.id, name: hook.name, url: hook.url, events: [...hook.events], collections: [...hook.collections], active: hook.active } : { ...EMPTY, events: [...EMPTY.events] };
|
|
53
|
+
this.deliveries = hook ? await cms.webhooks.deliveries(hook.id, 20) : [];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Read the selected webhook's secret, for whoever manages webhooks here. */
|
|
57
|
+
@Server()
|
|
58
|
+
async reveal() {
|
|
59
|
+
// The client names the webhook: only one of this site's, read again here.
|
|
60
|
+
const cms = this.c.get('cms');
|
|
61
|
+
const hook = (await cms.webhooks.list()).find(entry => entry.id === this.selected);
|
|
62
|
+
this.revealed = hook ? await cms.webhooks.secret(hook.id) ?? '' : '';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Client()
|
|
66
|
+
toggle(key: 'events' | 'collections', value: string, checked: boolean) {
|
|
67
|
+
this.form = { ...this.form, [key]: checked ? [...new Set([...this.form[key], value])] : this.form[key].filter(entry => entry !== value) };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@Client()
|
|
71
|
+
async submit(event: Event) {
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
const editing = Boolean(this.form.id);
|
|
74
|
+
this.message = '';
|
|
75
|
+
await this.save(this.form);
|
|
76
|
+
if (!this.error) this.message = editing ? __('Webhook updated.') : __('Webhook added. Copy its secret to verify deliveries.');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Server()
|
|
80
|
+
async save(form: Form) {
|
|
81
|
+
this.error = '';
|
|
82
|
+
const cms = this.c.get('cms');
|
|
83
|
+
try {
|
|
84
|
+
const principal = this.c.get('principal');
|
|
85
|
+
const hook = await cms.webhooks.save({ name: form.name, url: form.url, events: form.events, collections: form.collections, active: form.active },
|
|
86
|
+
{ ...(form.id ? { id: form.id } : {}), by: principal.kind === 'user' ? principal.id : null, collections: cms.collections().map(collection => collection.name) });
|
|
87
|
+
await this.load(hook.id);
|
|
88
|
+
if (hook.secret) this.revealed = hook.secret;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
this.error = isCmsError(error) ? error.message : __('The webhook could not be saved.');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@Client()
|
|
95
|
+
async test() {
|
|
96
|
+
this.message = '';
|
|
97
|
+
this.error = '';
|
|
98
|
+
const result = await this.ping(this.selected);
|
|
99
|
+
if (result.ok) this.message = `${__('The receiver answered')} ${result.status}.`;
|
|
100
|
+
else this.error = result.error ?? __('The test failed.');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@Server({ input: input.args(input.string({ minLength: 1, maxLength: 200 })) })
|
|
104
|
+
async ping(id: string) {
|
|
105
|
+
return this.c.get('cms').webhooks.ping(id);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@Server({ input: input.args(input.string({ minLength: 1, maxLength: 200 })) })
|
|
109
|
+
async redeliver(deliveryId: string) {
|
|
110
|
+
const cms = this.c.get('cms');
|
|
111
|
+
await cms.webhooks.redeliver(deliveryId);
|
|
112
|
+
await cms.webhooks.dispatch({ limit: 5 });
|
|
113
|
+
const hook = (await cms.webhooks.list()).find(entry => entry.id === this.selected);
|
|
114
|
+
this.deliveries = hook ? await cms.webhooks.deliveries(hook.id, 20) : [];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Server({ input: input.args(input.string({ minLength: 1, maxLength: 200 })) })
|
|
118
|
+
async remove(id: string) {
|
|
119
|
+
this.message = '';
|
|
120
|
+
await this.c.get('cms').webhooks.delete(id);
|
|
121
|
+
await this.load('');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
render() {
|
|
125
|
+
const hook = this.hooks.find(entry => entry.id === this.selected);
|
|
126
|
+
return html`<div class="space-y-6">
|
|
127
|
+
${pageHeader(__('Webhooks'), { description: __('Tell other services when entries change, such as to rebuild a static site.'),
|
|
128
|
+
actions: this.selected ? html`<a href="/dashboard/tools/webhooks" class="text-sm text-primary hover:underline">+ ${__('Add webhook')}</a>` : null })}
|
|
129
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
130
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
131
|
+
<div class="grid gap-6 xl:grid-cols-[minmax(0,1fr)_24rem]">
|
|
132
|
+
<div class="space-y-6">
|
|
133
|
+
${component(Card, {}, html`${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${this.selected ? `${__('Edit')} ${hook?.name ?? ''}` : __('Add webhook')}</h2>`)}
|
|
134
|
+
${component(CardBody, {}, html`<form class="space-y-4" @submit=${(event: Event) => this.submit(event)}>
|
|
135
|
+
${component(Field, { label: __('Name'), for: 'hook-name', control: attributes => component(Input, { ...attributes, required: true, maxlength: 80, placeholder: __('Rebuild the site'),
|
|
136
|
+
'.value': this.form.name, '@input': (event: Event) => { this.form = { ...this.form, name: (event.target as HTMLInputElement).value }; } }) })}
|
|
137
|
+
${component(Field, { label: __('URL'), for: 'hook-url', hint: __('HTTPS, or http://localhost while developing.'), control: attributes => component(Input, { ...attributes, type: 'url', required: true,
|
|
138
|
+
placeholder: 'https://api.example.com/hooks/cms', '.value': this.form.url, '@input': (event: Event) => { this.form = { ...this.form, url: (event.target as HTMLInputElement).value }; } }) })}
|
|
139
|
+
<fieldset class="space-y-2"><legend class="mb-1 text-sm font-medium text-foreground">${__('Events')}</legend>
|
|
140
|
+
${WEBHOOK_EVENTS.map(event => html`<div>${component(Checkbox, { checked: this.form.events.includes(event), '@change': (change: Event) => this.toggle('events', event, (change.target as HTMLInputElement).checked) },
|
|
141
|
+
html`${__(EVENT_LABELS[event])} <code class="text-xs text-muted-foreground">${event}</code>`)}</div>`)}</fieldset>
|
|
142
|
+
<fieldset class="space-y-2"><legend class="mb-1 text-sm font-medium text-foreground">${__('Collections')}</legend>
|
|
143
|
+
<p class="text-xs text-muted-foreground">${__('None checked sends events of every collection.')}</p>
|
|
144
|
+
<div class="grid gap-2 sm:grid-cols-3">${this.collections.map(collection => html`<div>${component(Checkbox, { label: collection.label, checked: this.form.collections.includes(collection.name), '@change': (change: Event) => this.toggle('collections', collection.name, (change.target as HTMLInputElement).checked) })}</div>`)}</div></fieldset>
|
|
145
|
+
${component(Checkbox, { label: __('Active'), checked: this.form.active, '@change': (change: Event) => { this.form = { ...this.form, active: (change.target as HTMLInputElement).checked }; } })}
|
|
146
|
+
<div class="flex flex-wrap gap-2">
|
|
147
|
+
${component(Button, { type: 'submit' }, this.selected ? __('Save webhook') : __('Add webhook'))}
|
|
148
|
+
${this.selected ? component(Button, { type: 'button', variant: 'outline', '@click': () => this.test() }, __('Send a test')) : null}
|
|
149
|
+
${hook ? component(Button, { type: 'button', variant: 'ghost', class: 'text-destructive', '@click': () => { this.pendingDelete = hook; } }, __('Delete')) : null}
|
|
150
|
+
</div>
|
|
151
|
+
</form>`)}`)}
|
|
152
|
+
${hook ? component(Card, {}, html`${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Recent deliveries')}</h2>`)}
|
|
153
|
+
${component(CardBody, { class: 'p-0' }, this.deliveries.length ? html`<ul class="divide-y divide-border">${this.deliveries.map(delivery => html`<li class="flex flex-wrap items-center justify-between gap-2 px-4 py-3 text-sm">
|
|
154
|
+
<span><code>${delivery.event}</code> <span class="text-muted-foreground">· ${shortDate(delivery.createdAt)} · ${__('attempts')}: ${delivery.attempts}</span>
|
|
155
|
+
${delivery.error ? html`<span class="block text-xs text-destructive">${delivery.error}</span>` : null}</span>
|
|
156
|
+
<span class="flex items-center gap-2">${component(Badge, { variant: delivery.status === 'delivered' ? 'success' : delivery.status === 'failed' ? 'destructive' : 'secondary' },
|
|
157
|
+
delivery.status === 'delivered' ? `${__('Delivered')} ${delivery.responseStatus ?? ''}` : delivery.status === 'failed' ? __('Failed') : __('Pending'))}
|
|
158
|
+
${delivery.status !== 'pending' ? html`<button type="button" class="text-xs text-primary hover:underline bg-transparent border-none p-0 cursor-pointer" @click=${() => this.redeliver(delivery.id)}>${__('Send again')}</button>` : null}</span>
|
|
159
|
+
</li>`)}</ul>` : html`<p class="px-4 py-6 text-sm text-muted-foreground">${__('No deliveries yet.')}</p>`)}`) : null}
|
|
160
|
+
</div>
|
|
161
|
+
<aside class="space-y-4">
|
|
162
|
+
${component(Card, {}, component(CardBody, { class: 'space-y-3' }, html`<h2 class="text-base font-semibold text-foreground">${__('Webhooks')}</h2>
|
|
163
|
+
${this.hooks.length ? html`<ul class="space-y-2">${this.hooks.map(entry => html`<li><a href=${`/dashboard/tools/webhooks?id=${entry.id}`}
|
|
164
|
+
class=${`block rounded-md border px-3 py-2 no-underline ${entry.id === this.selected ? 'border-primary' : 'border-border hover:bg-muted'}`}>
|
|
165
|
+
<span class="flex items-center justify-between gap-2"><span class="truncate text-sm font-medium text-foreground">${entry.name}</span>
|
|
166
|
+
${component(Badge, { variant: entry.active ? 'success' : 'secondary' }, entry.active ? __('Active') : __('Off'))}</span>
|
|
167
|
+
<span class="block truncate text-xs text-muted-foreground">${entry.url}</span></a></li>`)}</ul>` : html`<p class="text-sm text-muted-foreground">${__('No webhooks yet.')}</p>`}`))}
|
|
168
|
+
${hook ? component(Card, {}, component(CardBody, { class: 'space-y-2' }, html`<h2 class="text-base font-semibold text-foreground">${__('Signing secret')}</h2>
|
|
169
|
+
<code class="block break-all rounded bg-muted px-2 py-1 text-xs">${this.revealed || `${hook.secretHint}${'•'.repeat(16)}`}</code>
|
|
170
|
+
${this.revealed ? null : html`<button type="button" class="text-xs text-primary hover:underline bg-transparent border-none p-0 cursor-pointer" @click=${() => this.reveal()}>${__('Show')}</button>`}
|
|
171
|
+
<p class="text-xs text-muted-foreground">${__('Each delivery has X-Cossack-Signature: sha256= the HMAC-SHA256 of “timestamp.body” with this secret, and the timestamp in X-Cossack-Timestamp.')}</p>`)) : null}
|
|
172
|
+
</aside>
|
|
173
|
+
</div>
|
|
174
|
+
${component(AlertDialog, {
|
|
175
|
+
id: 'delete-webhook-dialog', open: this.pendingDelete !== null, title: __('Delete this webhook?'),
|
|
176
|
+
description: this.pendingDelete ? `${this.pendingDelete.name} ${__('stops receiving events, and its delivery history is deleted.')}` : '',
|
|
177
|
+
cancelLabel: __('Cancel'), actionLabel: __('Delete'), actionVariant: 'destructive',
|
|
178
|
+
onAction: () => { const item = this.pendingDelete; this.pendingDelete = null; if (item) void this.remove(item.id); }, onOpenChange: () => { this.pendingDelete = null; },
|
|
179
|
+
})}
|
|
180
|
+
</div>`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { Cossack, Page, State, Server, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Avatar, Badge, Icon } from '@cossackframework/ui';
|
|
3
|
+
import { html, component, type TemplateResult } from '@cossackframework/renderer';
|
|
4
|
+
import { plugins } from '@cossackframework/framework/plugins';
|
|
5
|
+
import { evaluateRule, hasPermission, PERMISSIONS, recordTitle } from '@cossackframework/cms';
|
|
6
|
+
import { icon } from '#app/cms/icons';
|
|
7
|
+
import { box, notice, screenHelp, shortDate } from '#app/cms/ui';
|
|
8
|
+
import { agentIcon, browserIcon, osIcon } from '#app/dashboard/agent-icons';
|
|
9
|
+
import { parseUserAgent } from '#app/dashboard/session-list';
|
|
10
|
+
|
|
11
|
+
/** Components active plugins export as `slots['dashboard.overview']` from their ui.ts. */
|
|
12
|
+
function overviewWidgets(active: readonly string[]): TemplateResult[] {
|
|
13
|
+
return plugins.filter(plugin => active.includes(plugin.name)).flatMap(plugin => {
|
|
14
|
+
const slots = (plugin.ui as { slots?: Record<string, unknown[]> } | null)?.slots;
|
|
15
|
+
return (slots?.['dashboard.overview'] ?? []).map(widget => component(widget as never, {}));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Glance { label: string; href: string; icon: string; published: number; drafts: number }
|
|
20
|
+
interface Item { title: string; href: string; at: number; meta?: string; /** The author, for an avatar before the title. */ author?: { name: string; avatar: string | null } }
|
|
21
|
+
/** A sign-in: the account and the device, from the session's user agent; browser and OS are empty when unknown. */
|
|
22
|
+
interface SignIn { name: string; avatar: string | null; href: string; at: number; browser: string; os: string; ip: string }
|
|
23
|
+
|
|
24
|
+
/** The dashboard home: at a glance, recent activity and what needs attention, in collapsible boxes. */
|
|
25
|
+
@Page({ transport: 'http' })
|
|
26
|
+
export default class DashboardPage extends Cossack {
|
|
27
|
+
@State() userName = '';
|
|
28
|
+
@State() userAvatar: string | null = null;
|
|
29
|
+
@State() glance: Glance[] = [];
|
|
30
|
+
@State() media = -1;
|
|
31
|
+
@State() users = -1;
|
|
32
|
+
@State() published: Item[] = [];
|
|
33
|
+
/** Entries waiting for review, across collections, for editors. */
|
|
34
|
+
@State() pending: Item[] = [];
|
|
35
|
+
@State() pendingTotal = 0;
|
|
36
|
+
/** Open note threads the user started or is named in, newest activity first. */
|
|
37
|
+
@State() notesForMe: Item[] = [];
|
|
38
|
+
/** Who signed in lately, for user managers. */
|
|
39
|
+
@State() signIns: SignIn[] = [];
|
|
40
|
+
@State() canSeeSignIns = false;
|
|
41
|
+
@State() attention: { text: string; href: string }[] = [];
|
|
42
|
+
@State() outbox = 0;
|
|
43
|
+
@State() unconfirmed = 0;
|
|
44
|
+
@State() canMigrate = false;
|
|
45
|
+
@State() widgets: string[] = [];
|
|
46
|
+
|
|
47
|
+
head(): HeadValue {
|
|
48
|
+
return { title: 'Dashboard' };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async init() {
|
|
52
|
+
const user = this.user;
|
|
53
|
+
this.userName = user?.name ?? '';
|
|
54
|
+
this.userAvatar = user?.avatar ?? null;
|
|
55
|
+
await this.load();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@Server()
|
|
59
|
+
async load() {
|
|
60
|
+
const cms = this.c.get('cms');
|
|
61
|
+
const principal = this.c.get('principal');
|
|
62
|
+
const context = { principal };
|
|
63
|
+
const glance: Glance[] = [];
|
|
64
|
+
for (const collection of cms.collections()) {
|
|
65
|
+
const resource = cms.resourceById(`cms/${collection.name}`);
|
|
66
|
+
if (evaluateRule(resource.access.create, principal) === 'deny' && !hasPermission(principal, `cms/${collection.name}:read`)) continue;
|
|
67
|
+
const repository = cms.resource(resource.id);
|
|
68
|
+
const counts = collection.publishable === false
|
|
69
|
+
? [await repository.count({}, context).catch(() => 0), 0]
|
|
70
|
+
: await repository.countMany([{ where: { status: 'published' } }, { where: { status: 'draft' } }], context).catch(() => [0, 0]);
|
|
71
|
+
glance.push({ label: collection.label, href: `/dashboard/content/${collection.name}`, icon: collection.icon ?? 'document-text', published: counts[0]!, drafts: counts[1]! });
|
|
72
|
+
}
|
|
73
|
+
this.glance = glance;
|
|
74
|
+
if (cms.files && (hasPermission(principal, PERMISSIONS.upload) || hasPermission(principal, PERMISSIONS.manageMedia))) this.media = (await cms.files.list({ limit: 1 })).total;
|
|
75
|
+
if (hasPermission(principal, PERMISSIONS.manageUsers)) this.users = (await cms.users.list({ limit: 1 })).total;
|
|
76
|
+
// The newest published entries of every publishable collection, together, with their authors.
|
|
77
|
+
const recent: (Item & { owner: string })[] = [];
|
|
78
|
+
for (const collection of cms.collections()) {
|
|
79
|
+
if (collection.publishable === false || collection.name === 'forms') continue;
|
|
80
|
+
const page = await cms.resource(`cms/${collection.name}`).list({ where: { status: 'published' }, order: { field: 'publishedAt', direction: 'desc' }, limit: 5 }, context).catch(() => ({ records: [] }));
|
|
81
|
+
recent.push(...page.records.map(record => ({ title: recordTitle(record, 'title'), href: `/dashboard/content/${collection.name}/${record.id}`, at: Number(record.publishedAt), meta: collection.singular, owner: record.owner ?? '' })));
|
|
82
|
+
}
|
|
83
|
+
const newest = recent.sort((a, b) => b.at - a.at).slice(0, 8);
|
|
84
|
+
const authors = await cms.users.getMany([...new Set(newest.map(item => item.owner).filter(Boolean))]);
|
|
85
|
+
this.published = newest.map(({ owner, ...item }) => {
|
|
86
|
+
const author = owner ? authors.get(owner) : undefined;
|
|
87
|
+
return author ? { ...item, author: { name: author.name || author.email, avatar: author.avatar ?? null } } : item;
|
|
88
|
+
});
|
|
89
|
+
const status = await cms.status();
|
|
90
|
+
this.canMigrate = hasPermission(principal, PERMISSIONS.manageSchema);
|
|
91
|
+
// Comments and reviews waiting for someone.
|
|
92
|
+
const waiting: { text: string; href: string }[] = [];
|
|
93
|
+
if (hasPermission(principal, PERMISSIONS.moderateComments)) {
|
|
94
|
+
const pending = await cms.comments.counts().then(counts => counts.pending).catch(() => 0);
|
|
95
|
+
if (pending) waiting.push({ text: `${pending} ${pending === 1 ? __('comment is waiting for moderation.') : __('comments are waiting for moderation.')}`, href: '/dashboard/comments?status=pending' });
|
|
96
|
+
}
|
|
97
|
+
// Entries waiting for review get their own card; the notice stays for the count.
|
|
98
|
+
const pending: Item[] = [];
|
|
99
|
+
let pendingTotal = 0;
|
|
100
|
+
for (const collection of cms.collections()) {
|
|
101
|
+
if (collection.publishable === false || !hasPermission(principal, `cms/${collection.name}:update`)) continue;
|
|
102
|
+
const repository = cms.resource(`cms/${collection.name}`);
|
|
103
|
+
const count = await repository.count({ where: { status: 'pending' } }, context).catch(() => 0);
|
|
104
|
+
if (!count) continue;
|
|
105
|
+
pendingTotal += count;
|
|
106
|
+
const page = await repository.list({ where: { status: 'pending' }, order: { field: 'updatedAt', direction: 'desc' }, limit: 5 }, context).catch(() => ({ records: [] }));
|
|
107
|
+
const owners = await cms.users.getMany(page.records.map(record => record.owner).filter((owner): owner is string => !!owner));
|
|
108
|
+
pending.push(...page.records.map(record => ({ title: recordTitle(record, 'title'), href: `/dashboard/content/${collection.name}/${record.id}`, at: record.updatedAt,
|
|
109
|
+
meta: [collection.singular, record.owner ? owners.get(record.owner)?.name : ''].filter(Boolean).join(' · ') })));
|
|
110
|
+
}
|
|
111
|
+
this.pending = pending.sort((a, b) => b.at - a.at).slice(0, 8);
|
|
112
|
+
this.pendingTotal = pendingTotal;
|
|
113
|
+
if (pendingTotal) waiting.push({ text: `${pendingTotal} ${pendingTotal === 1 ? __('entry is pending review.') : __('entries are pending review.')}`, href: '#pending-review' });
|
|
114
|
+
// Notes for you: open threads you started or were mentioned in, with the entry and the words they quote.
|
|
115
|
+
if (principal.kind === 'user') {
|
|
116
|
+
const threads = await cms.notes.forUser(principal.id, 8).catch(() => []);
|
|
117
|
+
const authors = await cms.users.getMany([...new Set(threads.map(note => note.userId))]);
|
|
118
|
+
const items: Item[] = [];
|
|
119
|
+
for (const note of threads) {
|
|
120
|
+
const [owner, name] = note.resource.split('/');
|
|
121
|
+
const record = await cms.resource(note.resource).get(note.recordId, context).catch(() => null);
|
|
122
|
+
if (!record || !cms.resource(note.resource).canUpdate(record, principal)) continue;
|
|
123
|
+
const author = authors.get(note.userId);
|
|
124
|
+
const excerpt = note.quote ? `“${note.quote.slice(0, 80)}”` : note.body.replace(/@\[([^\]]+)\]\([^)]+\)/g, '@$1').slice(0, 80);
|
|
125
|
+
items.push({ title: recordTitle(record, cms.resourceById(note.resource).titleField), href: `/dashboard/content/${owner === 'cms' ? name : `${owner}.${name}`}/${record.id}?notes=open`, at: note.updatedAt, meta: excerpt,
|
|
126
|
+
...(author ? { author: { name: author.name || author.email, avatar: author.avatar } } : {}) });
|
|
127
|
+
}
|
|
128
|
+
this.notesForMe = items;
|
|
129
|
+
}
|
|
130
|
+
// Who signed in lately: sessions end at sign-out, so these are the accounts signed in now.
|
|
131
|
+
this.canSeeSignIns = hasPermission(principal, PERMISSIONS.manageUsers);
|
|
132
|
+
if (this.canSeeSignIns) {
|
|
133
|
+
const sessions = await cms.authSessions.listRecent(Date.now(), 8).catch(() => []);
|
|
134
|
+
const users = await cms.users.getMany([...new Set(sessions.map(session => session.userId))]);
|
|
135
|
+
this.signIns = sessions.map(session => {
|
|
136
|
+
const user = users.get(session.userId);
|
|
137
|
+
const agent = parseUserAgent(session.userAgent);
|
|
138
|
+
return { name: user?.name || user?.email || __('Deleted user'), avatar: user?.avatar ?? null, href: user ? `/dashboard/users/${user.id}?tab=sessions` : '/dashboard/users',
|
|
139
|
+
at: session.createdAt, browser: session.userAgent ? agent.browser : '', os: session.userAgent ? agent.os : '', ip: session.ip ?? '' };
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
this.attention = [
|
|
143
|
+
...waiting,
|
|
144
|
+
...status.resources.filter(resource => !resource.active).map(resource => ({ text: `${resource.id} ${__('is waiting for a schema migration.')}`, href: '/dashboard/tools/schema' })),
|
|
145
|
+
...status.plugins.filter(plugin => !plugin.active && plugin.missing.length).map(plugin => ({ text: `${plugin.name}: ${plugin.reason ?? __('not enabled.')}`, href: '/dashboard/plugins' })),
|
|
146
|
+
];
|
|
147
|
+
if (this.canMigrate) {
|
|
148
|
+
this.outbox = (await cms.outbox.pending({ limit: 100 }).catch(() => [])).length;
|
|
149
|
+
this.unconfirmed = (await cms.db.pending.list({ limit: 100 })).length;
|
|
150
|
+
}
|
|
151
|
+
this.widgets = status.plugins.filter(plugin => plugin.active).map(plugin => plugin.name);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
render() {
|
|
155
|
+
const widgets = overviewWidgets(this.widgets);
|
|
156
|
+
const list = (items: Item[], empty: string) => items.length
|
|
157
|
+
? html`<ul class="space-y-2">${items.map(item => html`<li class="flex items-center justify-between gap-3 text-sm">
|
|
158
|
+
<span class="flex min-w-0 items-center gap-2">
|
|
159
|
+
${item.author ? html`<span class="inline-flex shrink-0" title=${item.author.name}>${component(Avatar, { src: item.author.avatar ?? undefined, alt: item.author.name, size: 24 })}</span>` : null}
|
|
160
|
+
<span class="min-w-0 truncate"><a href=${item.href} class="text-primary hover:underline">${item.title}</a>${item.meta ? html`<span class="ml-2 text-xs text-muted-foreground">${item.meta}</span>` : null}</span>
|
|
161
|
+
</span>
|
|
162
|
+
<span class="shrink-0 text-xs text-muted-foreground">${shortDate(item.at)}</span></li>`)}</ul>`
|
|
163
|
+
: html`<p class="text-sm text-muted-foreground">${empty}</p>`;
|
|
164
|
+
const glance = [...this.glance.map(entry => ({ ...entry, note: entry.drafts ? `${entry.drafts} ${entry.drafts === 1 ? __('draft') : __('drafts')}` : '' })),
|
|
165
|
+
...(this.media >= 0 ? [{ label: __('Media'), href: '/dashboard/media', icon: 'gallery', published: this.media, note: '' }] : []),
|
|
166
|
+
...(this.users >= 0 ? [{ label: __('Users'), href: '/dashboard/users', icon: 'users-group-rounded', published: this.users, note: '' }] : [])];
|
|
167
|
+
const signIns = this.signIns.length ? html`<ul class="divide-y divide-border">${this.signIns.map(entry => html`<li class="flex items-center gap-3 py-2 text-sm first:pt-0 last:pb-0">
|
|
168
|
+
${component(Avatar, { src: entry.avatar ?? undefined, alt: entry.name, size: 28 })}
|
|
169
|
+
<span class="min-w-0 flex-1"><a href=${entry.href} class="block truncate font-medium text-foreground no-underline hover:text-primary">${entry.name}</a>
|
|
170
|
+
<span class="flex items-center gap-1.5 text-xs text-muted-foreground">
|
|
171
|
+
${entry.browser || entry.os ? html`${agentIcon(browserIcon(entry.browser), entry.browser || __('Unknown browser'), 14)}${agentIcon(osIcon(entry.os), entry.os || __('Unknown system'), 14)}` : html`<span>${__('Unknown device')}</span>`}
|
|
172
|
+
${entry.ip ? html`<span class="truncate">${entry.ip}</span>` : null}
|
|
173
|
+
</span></span>
|
|
174
|
+
<span class="shrink-0 text-xs text-muted-foreground">${shortDate(entry.at)}</span></li>`)}</ul>`
|
|
175
|
+
: html`<p class="text-sm text-muted-foreground">${__('No one is signed in.')}</p>`;
|
|
176
|
+
return html`<div class="space-y-6">
|
|
177
|
+
${screenHelp(html`<p>${__('At a glance counts the published entries of each collection, with drafts beside them; Recently published lists the newest entries with their authors.')}</p>
|
|
178
|
+
<p>${__('Notices at the top, and the taskbar below, show what waits for someone: comments to moderate, entries pending review, schema migrations and plugins waiting for a grant.')}</p>
|
|
179
|
+
<p>${__('Each box collapses from its title; plugins add their own boxes. Delivery counts the events and writes the site has not confirmed yet.')}</p>`)}
|
|
180
|
+
<div class="flex items-center gap-4">
|
|
181
|
+
${component(Avatar, { src: this.userAvatar ?? undefined, alt: this.userName, size: 48 })}
|
|
182
|
+
<div>
|
|
183
|
+
<h1 class="text-2xl font-bold text-foreground">${__('Dashboard')}</h1>
|
|
184
|
+
<p class="text-sm text-muted-foreground">${__('Welcome back')}, ${this.userName}.</p>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
${this.attention.map(item => html`<a href=${item.href} class="block no-underline">${notice(item.text, 'error')}</a>`)}
|
|
188
|
+
<div class="grid gap-6 xl:grid-cols-3">
|
|
189
|
+
<div class="space-y-6 xl:col-span-2">
|
|
190
|
+
${box(__('At a glance'), html`<dl class="grid grid-cols-2 gap-3 sm:grid-cols-3">
|
|
191
|
+
${glance.map(entry => html`<a href=${entry.href} class="group rounded-lg border border-border p-3 no-underline transition-colors hover:border-primary/50 hover:bg-muted/40">
|
|
192
|
+
<dt class="flex items-center gap-2 text-sm text-muted-foreground group-hover:text-foreground"><span class="inline-flex [&_svg]:size-4">${component(Icon, { entry: icon(entry.icon), size: 16 })}</span>${entry.label}</dt>
|
|
193
|
+
<dd class="mt-1 text-2xl font-semibold text-foreground">${entry.published}</dd>
|
|
194
|
+
${entry.note ? html`<dd class="text-xs text-muted-foreground">${entry.note}</dd>` : null}
|
|
195
|
+
</a>`)}
|
|
196
|
+
</dl>`, { id: 'box-glance' })}
|
|
197
|
+
${this.notesForMe.length ? html`<div id="notes-for-you">${box(__('Notes for you'), list(this.notesForMe, ''), { id: 'box-notes', extra: component(Badge, { variant: 'warning' }, String(this.notesForMe.length)) })}</div>` : null}
|
|
198
|
+
${this.pendingTotal ? html`<div id="pending-review">${box(__('Waiting for review'), html`${list(this.pending, '')}
|
|
199
|
+
${this.pendingTotal > this.pending.length ? html`<p class="mt-3 text-xs"><a href="/dashboard/content/posts?status=pending" class="text-primary hover:underline">${__('Show everything pending')}</a></p>` : null}`,
|
|
200
|
+
{ id: 'box-pending', extra: component(Badge, { variant: 'warning' }, String(this.pendingTotal)) })}</div>` : null}
|
|
201
|
+
${box(__('Recently published'), list(this.published, __('Nothing published yet.')), { id: 'box-published' })}
|
|
202
|
+
${widgets.length ? html`<section class="grid gap-4 sm:grid-cols-2">${widgets}</section>` : null}
|
|
203
|
+
</div>
|
|
204
|
+
<div class="space-y-6">
|
|
205
|
+
${this.canSeeSignIns ? box(__('Recent sign-ins'), signIns, { id: 'box-sign-ins', extra: html`<a href="/dashboard/users" class="text-xs font-normal text-primary hover:underline">${__('All users')}</a>` }) : null}
|
|
206
|
+
${this.canMigrate ? box(__('Delivery'), html`<dl class="grid gap-3 sm:grid-cols-2 xl:grid-cols-1">
|
|
207
|
+
<div class="rounded-lg border border-border p-3"><dt class="text-sm text-muted-foreground">${__('Events waiting for delivery')}</dt><dd class="text-2xl font-semibold text-foreground" data-testid="outbox">${this.outbox}</dd></div>
|
|
208
|
+
<div class="rounded-lg border border-border p-3"><dt class="text-sm text-muted-foreground">${__('Writes waiting for confirmation')}</dt><dd class="text-2xl font-semibold text-foreground">${this.unconfirmed}</dd></div>
|
|
209
|
+
</dl>`, { id: 'box-delivery' }) : null}
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
</div>`;
|
|
213
|
+
}
|
|
214
|
+
}
|