@basicbenframework/cms 0.0.0-stage → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +206 -2
- package/db/migrations/001_create_users.js +15 -0
- package/db/migrations/002_create_posts.js +18 -0
- package/db/migrations/003_create_categories.js +19 -0
- package/db/migrations/004_create_tags.js +16 -0
- package/db/migrations/005_create_post_tags.js +16 -0
- package/db/migrations/006_create_pages.js +26 -0
- package/db/migrations/007_create_comments.js +24 -0
- package/db/migrations/008_create_media.js +22 -0
- package/db/migrations/009_update_posts_blogging.js +27 -0
- package/db/migrations/010_create_settings.js +29 -0
- package/db/migrations/011_add_user_roles.js +23 -0
- package/db/migrations/012_create_auth_tokens.js +30 -0
- package/db/migrations/013_add_email_verified.js +24 -0
- package/db/migrations/014_create_user_two_factor.js +30 -0
- package/db/migrations/015_create_user_credentials.js +35 -0
- package/db/migrations/016_create_rate_limits.js +31 -0
- package/db/migrations/017_add_content_html.js +38 -0
- package/db/migrations/018_create_api_tokens.js +34 -0
- package/db/migrations/019_create_post_categories.js +40 -0
- package/db/migrations/020_add_author_profiles.js +60 -0
- package/db/migrations/021_add_page_featured_image.js +23 -0
- package/db/migrations/022_backfill_post_slugs_and_excerpts.js +57 -0
- package/db/migrations/023_add_user_session_controls.js +25 -0
- package/db/migrations/024_add_post_status_and_trash.js +45 -0
- package/db/migrations/025_add_social_and_indexing_fields.js +40 -0
- package/db/migrations/026_create_post_revisions.js +29 -0
- package/db/migrations/027_add_media_dimensions.js +19 -0
- package/db/migrations/028_create_navigation_menus.js +65 -0
- package/db/migrations/029_create_redirects.js +40 -0
- package/db/migrations/030_add_comment_status_and_notifications.js +53 -0
- package/db/migrations/031_create_post_locks.js +38 -0
- package/db/migrations/032_create_snippets.js +31 -0
- package/db/migrations/033_create_members.js +70 -0
- package/db/migrations/034_add_post_visibility.js +28 -0
- package/db/migrations/035_create_newsletters.js +72 -0
- package/db/migrations/036_create_analytics.js +89 -0
- package/db/migrations/037_create_ops_heartbeats.js +30 -0
- package/db/migrations/038_create_content_types.js +84 -0
- package/db/migrations/039_create_content_type_fields.js +47 -0
- package/db/migrations/040_create_taxonomies.js +80 -0
- package/db/migrations/041_add_newsletter_handoff.js +28 -0
- package/db/migrations/042_create_mysendbox_contacts.js +63 -0
- package/lib/cli/backup.d.mts +2 -0
- package/lib/cli/backup.mjs +124 -0
- package/lib/cli/export.d.mts +2 -0
- package/lib/cli/export.mjs +54 -0
- package/lib/cli/import-ghost.d.mts +2 -0
- package/lib/cli/import-ghost.mjs +50 -0
- package/lib/cli/import-json.d.mts +2 -0
- package/lib/cli/import-json.mjs +61 -0
- package/lib/cli/import-wordpress.d.mts +2 -0
- package/lib/cli/import-wordpress.mjs +169 -0
- package/lib/cli/import-wxr.d.mts +2 -0
- package/lib/cli/import-wxr.mjs +55 -0
- package/lib/cli/index.d.mts +2 -0
- package/lib/cli/index.mjs +53 -0
- package/lib/cli/lib/backup.d.mts +112 -0
- package/lib/cli/lib/backup.mjs +297 -0
- package/lib/cli/lib/ghost.d.mts +30 -0
- package/lib/cli/lib/ghost.mjs +201 -0
- package/lib/cli/lib/html-to-markdown.d.mts +61 -0
- package/lib/cli/lib/html-to-markdown.mjs +523 -0
- package/lib/cli/lib/import-common.d.mts +100 -0
- package/lib/cli/lib/import-common.mjs +252 -0
- package/lib/cli/lib/json-import.d.mts +22 -0
- package/lib/cli/lib/json-import.mjs +422 -0
- package/lib/cli/lib/site-import.d.mts +32 -0
- package/lib/cli/lib/site-import.mjs +456 -0
- package/lib/cli/lib/wordpress-rest.d.mts +25 -0
- package/lib/cli/lib/wordpress-rest.mjs +177 -0
- package/lib/cli/lib/wxr.d.mts +18 -0
- package/lib/cli/lib/wxr.mjs +307 -0
- package/lib/cli/lib/xml.d.mts +33 -0
- package/lib/cli/lib/xml.mjs +186 -0
- package/lib/cli/restore.d.mts +2 -0
- package/lib/cli/restore.mjs +98 -0
- package/lib/client/components/Alert.d.ts +7 -0
- package/lib/client/components/Alert.js +8 -0
- package/lib/client/components/Avatar.d.ts +15 -0
- package/lib/client/components/Avatar.js +10 -0
- package/lib/client/components/BackLink.d.ts +7 -0
- package/lib/client/components/BackLink.js +6 -0
- package/lib/client/components/Button.d.ts +7 -0
- package/lib/client/components/Button.js +12 -0
- package/lib/client/components/Card.d.ts +7 -0
- package/lib/client/components/Card.js +6 -0
- package/lib/client/components/CommentThread.d.ts +15 -0
- package/lib/client/components/CommentThread.js +101 -0
- package/lib/client/components/Empty.d.ts +6 -0
- package/lib/client/components/Empty.js +6 -0
- package/lib/client/components/Input.d.ts +6 -0
- package/lib/client/components/Input.js +6 -0
- package/lib/client/components/Link.d.ts +31 -0
- package/lib/client/components/Link.js +49 -0
- package/lib/client/components/Loading.d.ts +1 -0
- package/lib/client/components/Loading.js +6 -0
- package/lib/client/components/Logo.d.ts +5 -0
- package/lib/client/components/Logo.js +4 -0
- package/lib/client/components/MarkdownEditor.d.ts +41 -0
- package/lib/client/components/MarkdownEditor.js +156 -0
- package/lib/client/components/Nav/DarkModeToggle.d.ts +6 -0
- package/lib/client/components/Nav/DarkModeToggle.js +6 -0
- package/lib/client/components/Nav/DesktopNav.d.ts +8 -0
- package/lib/client/components/Nav/DesktopNav.js +9 -0
- package/lib/client/components/Nav/MobileNav.d.ts +9 -0
- package/lib/client/components/Nav/MobileNav.js +15 -0
- package/lib/client/components/NavLink.d.ts +8 -0
- package/lib/client/components/NavLink.js +6 -0
- package/lib/client/components/PageHeader.d.ts +8 -0
- package/lib/client/components/PageHeader.js +6 -0
- package/lib/client/components/PostCard.d.ts +8 -0
- package/lib/client/components/PostCard.js +7 -0
- package/lib/client/components/Textarea.d.ts +6 -0
- package/lib/client/components/Textarea.js +6 -0
- package/lib/client/components/ThemeContext.d.ts +18 -0
- package/lib/client/components/ThemeContext.js +8 -0
- package/lib/client/components/admin/AdminIcons.d.ts +13 -0
- package/lib/client/components/admin/AdminIcons.js +66 -0
- package/lib/client/components/admin/ContentModelPanels.d.ts +22 -0
- package/lib/client/components/admin/ContentModelPanels.js +93 -0
- package/lib/client/components/admin/FeaturedImageBox.d.ts +21 -0
- package/lib/client/components/admin/FeaturedImageBox.js +24 -0
- package/lib/client/components/admin/MediaGrid.d.ts +23 -0
- package/lib/client/components/admin/MediaGrid.js +69 -0
- package/lib/client/components/admin/MediaPicker.d.ts +17 -0
- package/lib/client/components/admin/MediaPicker.js +61 -0
- package/lib/client/components/admin/Pagination.d.ts +27 -0
- package/lib/client/components/admin/Pagination.js +29 -0
- package/lib/client/components/admin/SnippetPicker.d.ts +27 -0
- package/lib/client/components/admin/SnippetPicker.js +65 -0
- package/lib/client/components/admin/TermPicker.d.ts +52 -0
- package/lib/client/components/admin/TermPicker.js +58 -0
- package/lib/client/contexts/ToastContext.d.ts +12 -0
- package/lib/client/contexts/ToastContext.js +49 -0
- package/lib/client/features.d.ts +11 -0
- package/lib/client/features.js +7 -0
- package/lib/client/hooks/useContentTypes.d.ts +48 -0
- package/lib/client/hooks/useContentTypes.js +48 -0
- package/lib/client/hooks/useMediaLibrary.d.ts +46 -0
- package/lib/client/hooks/useMediaLibrary.js +189 -0
- package/lib/client/hooks/usePostLock.d.ts +32 -0
- package/lib/client/hooks/usePostLock.js +107 -0
- package/lib/client/host/index.d.ts +71 -0
- package/lib/client/host/index.js +58 -0
- package/lib/client/i18n/index.d.ts +79 -0
- package/lib/client/i18n/index.js +177 -0
- package/lib/client/i18n/locales/es/content.d.ts +4 -0
- package/lib/client/i18n/locales/es/content.js +220 -0
- package/lib/client/i18n/locales/es/editor.d.ts +9 -0
- package/lib/client/i18n/locales/es/editor.js +144 -0
- package/lib/client/i18n/locales/es/index.d.ts +8 -0
- package/lib/client/i18n/locales/es/index.js +7 -0
- package/lib/client/i18n/locales/es/layout.d.ts +4 -0
- package/lib/client/i18n/locales/es/layout.js +35 -0
- package/lib/client/i18n/locales/es/people.d.ts +4 -0
- package/lib/client/i18n/locales/es/people.js +187 -0
- package/lib/client/i18n/locales/es/site.d.ts +4 -0
- package/lib/client/i18n/locales/es/site.js +208 -0
- package/lib/client/layouts/AdminLayout.d.ts +7 -0
- package/lib/client/layouts/AdminLayout.js +1046 -0
- package/lib/client/layouts/AppLayout.d.ts +6 -0
- package/lib/client/layouts/AppLayout.js +19 -0
- package/lib/client/layouts/AuthLayout.d.ts +6 -0
- package/lib/client/layouts/AuthLayout.js +14 -0
- package/lib/client/layouts/DocsLayout.d.ts +6 -0
- package/lib/client/layouts/DocsLayout.js +28 -0
- package/lib/client/layouts/RootLayout.d.ts +6 -0
- package/lib/client/layouts/RootLayout.js +11 -0
- package/lib/client/pages/AcceptInvite.d.ts +8 -0
- package/lib/client/pages/AcceptInvite.js +60 -0
- package/lib/client/pages/Auth.d.ts +1 -0
- package/lib/client/pages/Auth.js +40 -0
- package/lib/client/pages/Authentication.d.ts +1 -0
- package/lib/client/pages/Authentication.js +230 -0
- package/lib/client/pages/Content.d.ts +1 -0
- package/lib/client/pages/Content.js +21 -0
- package/lib/client/pages/Database.d.ts +1 -0
- package/lib/client/pages/Database.js +264 -0
- package/lib/client/pages/Extending.d.ts +1 -0
- package/lib/client/pages/Extending.js +28 -0
- package/lib/client/pages/Feed.d.ts +1 -0
- package/lib/client/pages/Feed.js +19 -0
- package/lib/client/pages/FeedPost.d.ts +1 -0
- package/lib/client/pages/FeedPost.js +31 -0
- package/lib/client/pages/ForgotPassword.d.ts +8 -0
- package/lib/client/pages/ForgotPassword.js +38 -0
- package/lib/client/pages/GettingStarted.d.ts +1 -0
- package/lib/client/pages/GettingStarted.js +84 -0
- package/lib/client/pages/Headless.d.ts +1 -0
- package/lib/client/pages/Headless.js +49 -0
- package/lib/client/pages/Home.d.ts +1 -0
- package/lib/client/pages/Home.js +67 -0
- package/lib/client/pages/PostForm.d.ts +1 -0
- package/lib/client/pages/PostForm.js +55 -0
- package/lib/client/pages/Posts.d.ts +1 -0
- package/lib/client/pages/Posts.js +35 -0
- package/lib/client/pages/Profile.d.ts +1 -0
- package/lib/client/pages/Profile.js +153 -0
- package/lib/client/pages/ResetPassword.d.ts +8 -0
- package/lib/client/pages/ResetPassword.js +52 -0
- package/lib/client/pages/Routing.d.ts +1 -0
- package/lib/client/pages/Routing.js +192 -0
- package/lib/client/pages/Storage.d.ts +1 -0
- package/lib/client/pages/Storage.js +54 -0
- package/lib/client/pages/Testing.d.ts +1 -0
- package/lib/client/pages/Testing.js +141 -0
- package/lib/client/pages/Validation.d.ts +1 -0
- package/lib/client/pages/Validation.js +123 -0
- package/lib/client/pages/admin/Categories.d.ts +2 -0
- package/lib/client/pages/admin/Categories.js +75 -0
- package/lib/client/pages/admin/Comments.d.ts +11 -0
- package/lib/client/pages/admin/Comments.js +247 -0
- package/lib/client/pages/admin/ContentTypes.d.ts +2 -0
- package/lib/client/pages/admin/ContentTypes.js +163 -0
- package/lib/client/pages/admin/Dashboard.d.ts +2 -0
- package/lib/client/pages/admin/Dashboard.js +66 -0
- package/lib/client/pages/admin/Health.d.ts +12 -0
- package/lib/client/pages/admin/Health.js +148 -0
- package/lib/client/pages/admin/Media.d.ts +2 -0
- package/lib/client/pages/admin/Media.js +101 -0
- package/lib/client/pages/admin/Navigation.d.ts +9 -0
- package/lib/client/pages/admin/Navigation.js +230 -0
- package/lib/client/pages/admin/Pages.d.ts +2 -0
- package/lib/client/pages/admin/Pages.js +53 -0
- package/lib/client/pages/admin/PostEditor.d.ts +17 -0
- package/lib/client/pages/admin/PostEditor.js +532 -0
- package/lib/client/pages/admin/Posts.d.ts +2 -0
- package/lib/client/pages/admin/Posts.js +152 -0
- package/lib/client/pages/admin/Redirects.d.ts +10 -0
- package/lib/client/pages/admin/Redirects.js +87 -0
- package/lib/client/pages/admin/Settings.d.ts +2 -0
- package/lib/client/pages/admin/Settings.js +111 -0
- package/lib/client/pages/admin/Snippets.d.ts +14 -0
- package/lib/client/pages/admin/Snippets.js +85 -0
- package/lib/client/pages/admin/Tags.d.ts +2 -0
- package/lib/client/pages/admin/Tags.js +74 -0
- package/lib/client/pages/admin/Taxonomies.d.ts +2 -0
- package/lib/client/pages/admin/Taxonomies.js +130 -0
- package/lib/client/pages/admin/Tokens.d.ts +9 -0
- package/lib/client/pages/admin/Tokens.js +260 -0
- package/lib/client/pages/admin/Tools.d.ts +12 -0
- package/lib/client/pages/admin/Tools.js +111 -0
- package/lib/client/pages/admin/Users.d.ts +13 -0
- package/lib/client/pages/admin/Users.js +313 -0
- package/lib/client/pages/api-reference.d.ts +33 -0
- package/lib/client/pages/api-reference.js +198 -0
- package/lib/client/styles.css +37 -0
- package/lib/config.d.ts +24 -0
- package/lib/config.js +39 -0
- package/lib/controllers/AdminController.d.ts +46 -0
- package/lib/controllers/AdminController.js +134 -0
- package/lib/controllers/AuthController.d.ts +15 -0
- package/lib/controllers/AuthController.js +194 -0
- package/lib/controllers/AuthorController.d.ts +17 -0
- package/lib/controllers/AuthorController.js +19 -0
- package/lib/controllers/CategoryController.d.ts +10 -0
- package/lib/controllers/CategoryController.js +88 -0
- package/lib/controllers/CommentController.d.ts +68 -0
- package/lib/controllers/CommentController.js +438 -0
- package/lib/controllers/ContentTypeController.d.ts +24 -0
- package/lib/controllers/ContentTypeController.js +91 -0
- package/lib/controllers/EmailVerificationController.d.ts +33 -0
- package/lib/controllers/EmailVerificationController.js +116 -0
- package/lib/controllers/ExportController.d.ts +15 -0
- package/lib/controllers/ExportController.js +41 -0
- package/lib/controllers/FeedController.d.ts +14 -0
- package/lib/controllers/FeedController.js +246 -0
- package/lib/controllers/HealthController.d.ts +21 -0
- package/lib/controllers/HealthController.js +176 -0
- package/lib/controllers/HomeController.d.ts +12 -0
- package/lib/controllers/HomeController.js +16 -0
- package/lib/controllers/MediaController.d.ts +24 -0
- package/lib/controllers/MediaController.js +189 -0
- package/lib/controllers/NavigationController.d.ts +22 -0
- package/lib/controllers/NavigationController.js +176 -0
- package/lib/controllers/PageController.d.ts +13 -0
- package/lib/controllers/PageController.js +172 -0
- package/lib/controllers/PasskeyController.d.ts +36 -0
- package/lib/controllers/PasskeyController.js +201 -0
- package/lib/controllers/PasswordResetController.d.ts +44 -0
- package/lib/controllers/PasswordResetController.js +160 -0
- package/lib/controllers/PostController.d.ts +51 -0
- package/lib/controllers/PostController.js +538 -0
- package/lib/controllers/PostLockController.d.ts +62 -0
- package/lib/controllers/PostLockController.js +101 -0
- package/lib/controllers/ProfileController.d.ts +13 -0
- package/lib/controllers/ProfileController.js +160 -0
- package/lib/controllers/PublicApiController.d.ts +23 -0
- package/lib/controllers/PublicApiController.js +100 -0
- package/lib/controllers/RedirectController.d.ts +32 -0
- package/lib/controllers/RedirectController.js +95 -0
- package/lib/controllers/SettingsController.d.ts +28 -0
- package/lib/controllers/SettingsController.js +105 -0
- package/lib/controllers/SnippetController.d.ts +27 -0
- package/lib/controllers/SnippetController.js +123 -0
- package/lib/controllers/TagController.d.ts +9 -0
- package/lib/controllers/TagController.js +70 -0
- package/lib/controllers/TaxonomyController.d.ts +24 -0
- package/lib/controllers/TaxonomyController.js +149 -0
- package/lib/controllers/TokenController.d.ts +27 -0
- package/lib/controllers/TokenController.js +83 -0
- package/lib/controllers/TwoFactorController.d.ts +31 -0
- package/lib/controllers/TwoFactorController.js +213 -0
- package/lib/controllers/UserController.d.ts +110 -0
- package/lib/controllers/UserController.js +504 -0
- package/lib/features/analytics/AnalyticsPage.d.ts +11 -0
- package/lib/features/analytics/AnalyticsPage.js +123 -0
- package/lib/features/analytics/admin.d.ts +3 -0
- package/lib/features/analytics/admin.js +9 -0
- package/lib/features/analytics/controller.d.ts +19 -0
- package/lib/features/analytics/controller.js +79 -0
- package/lib/features/analytics/helpers.d.ts +84 -0
- package/lib/features/analytics/helpers.js +181 -0
- package/lib/features/analytics/i18n/es.d.ts +4 -0
- package/lib/features/analytics/i18n/es.js +31 -0
- package/lib/features/analytics/index.d.ts +28 -0
- package/lib/features/analytics/index.js +91 -0
- package/lib/features/analytics/manifest.d.ts +8 -0
- package/lib/features/analytics/manifest.js +18 -0
- package/lib/features/analytics/model.d.ts +130 -0
- package/lib/features/analytics/model.js +206 -0
- package/lib/features/members/Member.d.ts +93 -0
- package/lib/features/members/Member.js +194 -0
- package/lib/features/members/MemberAdminController.d.ts +60 -0
- package/lib/features/members/MemberAdminController.js +262 -0
- package/lib/features/members/MemberController.d.ts +88 -0
- package/lib/features/members/MemberController.js +250 -0
- package/lib/features/members/MembersPage.d.ts +10 -0
- package/lib/features/members/MembersPage.js +216 -0
- package/lib/features/members/PostAccessBox.d.ts +15 -0
- package/lib/features/members/PostAccessBox.js +70 -0
- package/lib/features/members/admin.d.ts +3 -0
- package/lib/features/members/admin.js +12 -0
- package/lib/features/members/csv.d.ts +21 -0
- package/lib/features/members/csv.js +74 -0
- package/lib/features/members/events.d.ts +34 -0
- package/lib/features/members/events.js +34 -0
- package/lib/features/members/i18n/es.d.ts +4 -0
- package/lib/features/members/i18n/es.js +106 -0
- package/lib/features/members/index.d.ts +44 -0
- package/lib/features/members/index.js +106 -0
- package/lib/features/members/manifest.d.ts +8 -0
- package/lib/features/members/manifest.js +18 -0
- package/lib/features/members/middleware.d.ts +42 -0
- package/lib/features/members/middleware.js +74 -0
- package/lib/features/members/newsletter.d.ts +177 -0
- package/lib/features/members/newsletter.js +439 -0
- package/lib/features/members/rate-limits.d.ts +34 -0
- package/lib/features/members/rate-limits.js +50 -0
- package/lib/features/members/request.d.ts +13 -0
- package/lib/features/members/request.js +6 -0
- package/lib/features/members/routes.d.ts +15 -0
- package/lib/features/members/routes.js +59 -0
- package/lib/features/members/session.d.ts +102 -0
- package/lib/features/members/session.js +158 -0
- package/lib/features/members/settings.d.ts +14 -0
- package/lib/features/members/settings.js +23 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.d.ts +7 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.js +48 -0
- package/lib/features/mysendbox/admin.d.ts +3 -0
- package/lib/features/mysendbox/admin.js +9 -0
- package/lib/features/mysendbox/broadcasts.d.ts +61 -0
- package/lib/features/mysendbox/broadcasts.js +124 -0
- package/lib/features/mysendbox/client.d.ts +95 -0
- package/lib/features/mysendbox/client.js +61 -0
- package/lib/features/mysendbox/config.d.ts +27 -0
- package/lib/features/mysendbox/config.js +74 -0
- package/lib/features/mysendbox/contacts.d.ts +121 -0
- package/lib/features/mysendbox/contacts.js +378 -0
- package/lib/features/mysendbox/controller.d.ts +11 -0
- package/lib/features/mysendbox/controller.js +47 -0
- package/lib/features/mysendbox/i18n/es.d.ts +4 -0
- package/lib/features/mysendbox/i18n/es.js +28 -0
- package/lib/features/mysendbox/index.d.ts +18 -0
- package/lib/features/mysendbox/index.js +71 -0
- package/lib/features/mysendbox/manifest.d.ts +7 -0
- package/lib/features/mysendbox/manifest.js +6 -0
- package/lib/features/mysendbox/routes.d.ts +6 -0
- package/lib/features/mysendbox/routes.js +14 -0
- package/lib/features/mysendbox/webhook.d.ts +23 -0
- package/lib/features/mysendbox/webhook.js +104 -0
- package/lib/features/theme/OEmbedController.d.ts +31 -0
- package/lib/features/theme/OEmbedController.js +128 -0
- package/lib/features/theme/ThemeController.d.ts +20 -0
- package/lib/features/theme/ThemeController.js +256 -0
- package/lib/features/theme/ThemeSettingsCard.d.ts +7 -0
- package/lib/features/theme/ThemeSettingsCard.js +12 -0
- package/lib/features/theme/admin.d.ts +3 -0
- package/lib/features/theme/admin.js +9 -0
- package/lib/features/theme/html.d.ts +48 -0
- package/lib/features/theme/html.js +97 -0
- package/lib/features/theme/i18n/es.d.ts +4 -0
- package/lib/features/theme/i18n/es.js +9 -0
- package/lib/features/theme/index.d.ts +11 -0
- package/lib/features/theme/index.js +23 -0
- package/lib/features/theme/manifest.d.ts +7 -0
- package/lib/features/theme/manifest.js +6 -0
- package/lib/features/theme/oembed.d.ts +36 -0
- package/lib/features/theme/oembed.js +58 -0
- package/lib/features/theme/routes.d.ts +17 -0
- package/lib/features/theme/routes.js +54 -0
- package/lib/features/theme/templates.d.ts +103 -0
- package/lib/features/theme/templates.js +283 -0
- package/lib/features.d.ts +15 -0
- package/lib/features.js +6 -0
- package/lib/features.manifest.d.ts +10 -0
- package/lib/features.manifest.js +6 -0
- package/lib/helpers/access.d.ts +62 -0
- package/lib/helpers/access.js +92 -0
- package/lib/helpers/api.d.ts +20 -0
- package/lib/helpers/api.js +44 -0
- package/lib/helpers/comment-guard.d.ts +145 -0
- package/lib/helpers/comment-guard.js +253 -0
- package/lib/helpers/comment-mail.d.ts +53 -0
- package/lib/helpers/comment-mail.js +188 -0
- package/lib/helpers/content-model.d.ts +50 -0
- package/lib/helpers/content-model.js +84 -0
- package/lib/helpers/content-paths.d.ts +107 -0
- package/lib/helpers/content-paths.js +200 -0
- package/lib/helpers/export-data.d.ts +85 -0
- package/lib/helpers/export-data.js +229 -0
- package/lib/helpers/gating.d.ts +53 -0
- package/lib/helpers/gating.js +83 -0
- package/lib/helpers/health.d.ts +91 -0
- package/lib/helpers/health.js +279 -0
- package/lib/helpers/heartbeat.d.ts +35 -0
- package/lib/helpers/heartbeat.js +55 -0
- package/lib/helpers/image-size.d.ts +18 -0
- package/lib/helpers/image-size.js +83 -0
- package/lib/helpers/images.d.ts +29 -0
- package/lib/helpers/images.js +41 -0
- package/lib/helpers/mail-templates.d.ts +11 -0
- package/lib/helpers/mail-templates.js +42 -0
- package/lib/helpers/publish-due.d.ts +28 -0
- package/lib/helpers/publish-due.js +67 -0
- package/lib/helpers/redirects.d.ts +43 -0
- package/lib/helpers/redirects.js +80 -0
- package/lib/helpers/seo-fields.d.ts +13 -0
- package/lib/helpers/seo-fields.js +52 -0
- package/lib/helpers/session.d.ts +30 -0
- package/lib/helpers/session.js +27 -0
- package/lib/helpers/site-settings.d.ts +98 -0
- package/lib/helpers/site-settings.js +232 -0
- package/lib/helpers/site.d.ts +14 -0
- package/lib/helpers/site.js +23 -0
- package/lib/helpers/write-hooks.d.ts +33 -0
- package/lib/helpers/write-hooks.js +37 -0
- package/lib/hooks.d.ts +17 -0
- package/lib/hooks.js +101 -0
- package/lib/host/core-tasks.d.ts +4 -0
- package/lib/host/core-tasks.js +26 -0
- package/lib/host/cron.d.ts +39 -0
- package/lib/host/cron.js +85 -0
- package/lib/host/enabled.d.ts +4 -0
- package/lib/host/enabled.js +40 -0
- package/lib/host/index.d.ts +81 -0
- package/lib/host/index.js +87 -0
- package/lib/host/manifest.d.ts +34 -0
- package/lib/host/manifest.js +7 -0
- package/lib/host/menu.d.ts +18 -0
- package/lib/host/menu.js +15 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +24 -0
- package/lib/middleware/api-auth.d.ts +59 -0
- package/lib/middleware/api-auth.js +164 -0
- package/lib/middleware/auth.d.ts +49 -0
- package/lib/middleware/auth.js +112 -0
- package/lib/middleware/cache.d.ts +17 -0
- package/lib/middleware/cache.js +52 -0
- package/lib/middleware/rate-limits.d.ts +199 -0
- package/lib/middleware/rate-limits.js +276 -0
- package/lib/middleware/viewer.d.ts +13 -0
- package/lib/middleware/viewer.js +16 -0
- package/lib/models/Category.d.ts +24 -0
- package/lib/models/Category.js +102 -0
- package/lib/models/Comment.d.ts +120 -0
- package/lib/models/Comment.js +283 -0
- package/lib/models/ContentType.d.ts +142 -0
- package/lib/models/ContentType.js +462 -0
- package/lib/models/Credential.d.ts +21 -0
- package/lib/models/Credential.js +31 -0
- package/lib/models/Media.d.ts +53 -0
- package/lib/models/Media.js +132 -0
- package/lib/models/Menu.d.ts +131 -0
- package/lib/models/Menu.js +312 -0
- package/lib/models/Page.d.ts +55 -0
- package/lib/models/Page.js +218 -0
- package/lib/models/Post.d.ts +136 -0
- package/lib/models/Post.js +406 -0
- package/lib/models/PostLock.d.ts +67 -0
- package/lib/models/PostLock.js +112 -0
- package/lib/models/PostRevision.d.ts +45 -0
- package/lib/models/PostRevision.js +82 -0
- package/lib/models/PublicContent.d.ts +283 -0
- package/lib/models/PublicContent.js +577 -0
- package/lib/models/Redirect.d.ts +123 -0
- package/lib/models/Redirect.js +225 -0
- package/lib/models/Settings.d.ts +61 -0
- package/lib/models/Settings.js +128 -0
- package/lib/models/Snippet.d.ts +36 -0
- package/lib/models/Snippet.js +64 -0
- package/lib/models/Tag.d.ts +23 -0
- package/lib/models/Tag.js +117 -0
- package/lib/models/Taxonomy.d.ts +127 -0
- package/lib/models/Taxonomy.js +321 -0
- package/lib/models/TwoFactor.d.ts +26 -0
- package/lib/models/TwoFactor.js +60 -0
- package/lib/models/User.d.ts +49 -0
- package/lib/models/User.js +128 -0
- package/lib/models/derive.d.ts +69 -0
- package/lib/models/derive.js +81 -0
- package/lib/models/pagination.d.ts +30 -0
- package/lib/models/pagination.js +36 -0
- package/lib/models/visibility.d.ts +31 -0
- package/lib/models/visibility.js +47 -0
- package/lib/routes/App.d.ts +2 -0
- package/lib/routes/App.js +146 -0
- package/lib/routes/api/admin.d.ts +6 -0
- package/lib/routes/api/admin.js +11 -0
- package/lib/routes/api/auth.d.ts +6 -0
- package/lib/routes/api/auth.js +24 -0
- package/lib/routes/api/authors.d.ts +5 -0
- package/lib/routes/api/authors.js +8 -0
- package/lib/routes/api/categories.d.ts +8 -0
- package/lib/routes/api/categories.js +15 -0
- package/lib/routes/api/comments.d.ts +8 -0
- package/lib/routes/api/comments.js +35 -0
- package/lib/routes/api/content-model.d.ts +17 -0
- package/lib/routes/api/content-model.js +67 -0
- package/lib/routes/api/cron.d.ts +6 -0
- package/lib/routes/api/cron.js +9 -0
- package/lib/routes/api/export.d.ts +5 -0
- package/lib/routes/api/export.js +11 -0
- package/lib/routes/api/feed.d.ts +5 -0
- package/lib/routes/api/feed.js +16 -0
- package/lib/routes/api/media.d.ts +8 -0
- package/lib/routes/api/media.js +25 -0
- package/lib/routes/api/navigation.d.ts +12 -0
- package/lib/routes/api/navigation.js +17 -0
- package/lib/routes/api/ops.d.ts +9 -0
- package/lib/routes/api/ops.js +19 -0
- package/lib/routes/api/pages.d.ts +8 -0
- package/lib/routes/api/pages.js +21 -0
- package/lib/routes/api/passkeys.d.ts +7 -0
- package/lib/routes/api/passkeys.js +13 -0
- package/lib/routes/api/posts.d.ts +8 -0
- package/lib/routes/api/posts.js +39 -0
- package/lib/routes/api/profile.d.ts +6 -0
- package/lib/routes/api/profile.js +8 -0
- package/lib/routes/api/redirects.d.ts +12 -0
- package/lib/routes/api/redirects.js +13 -0
- package/lib/routes/api/settings.d.ts +8 -0
- package/lib/routes/api/settings.js +15 -0
- package/lib/routes/api/snippets.d.ts +15 -0
- package/lib/routes/api/snippets.js +16 -0
- package/lib/routes/api/tags.d.ts +8 -0
- package/lib/routes/api/tags.js +14 -0
- package/lib/routes/api/tokens.d.ts +7 -0
- package/lib/routes/api/tokens.js +15 -0
- package/lib/routes/api/two-factor.d.ts +7 -0
- package/lib/routes/api/two-factor.js +15 -0
- package/lib/routes/api/users.d.ts +8 -0
- package/lib/routes/api/users.js +25 -0
- package/lib/routes/api/v1.d.ts +12 -0
- package/lib/routes/api/v1.js +55 -0
- package/lib/routes/api/verification.d.ts +6 -0
- package/lib/routes/api/verification.js +11 -0
- package/lib/server/index.d.ts +24 -0
- package/lib/server/index.js +110 -0
- package/lib/types/index.d.ts +298 -0
- package/lib/types/index.js +1 -0
- package/lib/vite.d.ts +2 -0
- package/lib/vite.js +101 -0
- package/mail/comment-moderation.html +27 -0
- package/mail/comment-moderation.txt +13 -0
- package/mail/comment-reply.html +28 -0
- package/mail/comment-reply.txt +14 -0
- package/mail/invitation.html +25 -0
- package/mail/invitation.txt +11 -0
- package/mail/member-magic-link.html +23 -0
- package/mail/member-magic-link.txt +10 -0
- package/mail/newsletter.html +26 -0
- package/mail/newsletter.txt +13 -0
- package/mail/password-reset.html +26 -0
- package/mail/password-reset.txt +10 -0
- package/mail/verify-email.html +25 -0
- package/mail/verify-email.txt +8 -0
- package/package.json +85 -4
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useAuth } from '@basicbenframework/core/client';
|
|
4
|
+
import { api } from "../../../helpers/api.js";
|
|
5
|
+
import AdminLayout from "../../layouts/AdminLayout.js";
|
|
6
|
+
import { Pagination } from "../../components/admin/Pagination.js";
|
|
7
|
+
import { useT } from "../../i18n/index.js";
|
|
8
|
+
const FALLBACK_ROLES = ['admin', 'editor', 'author', 'contributor', 'subscriber'];
|
|
9
|
+
/**
|
|
10
|
+
* Who can sign in, and what they may do.
|
|
11
|
+
*
|
|
12
|
+
* Every control here is also enforced on the server — the last-admin and
|
|
13
|
+
* not-yourself rules especially, since the client cannot see a concurrent
|
|
14
|
+
* change by another admin. The UI disables the obvious cases so they are not
|
|
15
|
+
* offered, and shows the server's refusal for the rest.
|
|
16
|
+
*
|
|
17
|
+
* Deleting someone who has written posts asks where the posts should go
|
|
18
|
+
* first, because the server will not orphan them.
|
|
19
|
+
*/
|
|
20
|
+
export default function AdminUsers() {
|
|
21
|
+
const { user: me } = useAuth();
|
|
22
|
+
const { t, tn, locale } = useT();
|
|
23
|
+
/** What each role can do, in a phrase — the select alone says nothing. */
|
|
24
|
+
const ROLE_HINTS = {
|
|
25
|
+
admin: t('Everything, including users and settings'),
|
|
26
|
+
editor: t('Publish and manage everyone’s content'),
|
|
27
|
+
author: t('Write and publish their own posts'),
|
|
28
|
+
contributor: t('Write drafts for review'),
|
|
29
|
+
subscriber: t('Comment and keep a profile')
|
|
30
|
+
};
|
|
31
|
+
// The built-in roles by name; a role the server adds later shows as it is.
|
|
32
|
+
const ROLE_LABELS = {
|
|
33
|
+
admin: t('Admin'),
|
|
34
|
+
editor: t('Editor'),
|
|
35
|
+
author: t('Author'),
|
|
36
|
+
contributor: t('Contributor'),
|
|
37
|
+
subscriber: t('Subscriber')
|
|
38
|
+
};
|
|
39
|
+
const roleLabel = (role) => ROLE_LABELS[role] ?? capitalise(role);
|
|
40
|
+
// The role as it reads after "Make Jane …" / "Jane is now …".
|
|
41
|
+
const ROLE_ARTICLED = {
|
|
42
|
+
admin: t('an admin'),
|
|
43
|
+
editor: t('an editor'),
|
|
44
|
+
author: t('an author'),
|
|
45
|
+
contributor: t('a contributor'),
|
|
46
|
+
subscriber: t('a subscriber')
|
|
47
|
+
};
|
|
48
|
+
const roleArticled = (role) => ROLE_ARTICLED[role] ?? articled(role);
|
|
49
|
+
const [users, setUsers] = useState([]);
|
|
50
|
+
const [roles, setRoles] = useState(FALLBACK_ROLES);
|
|
51
|
+
const [meta, setMeta] = useState(null);
|
|
52
|
+
const [page, setPage] = useState(1);
|
|
53
|
+
const [search, setSearch] = useState('');
|
|
54
|
+
const [query, setQuery] = useState('');
|
|
55
|
+
const [roleFilter, setRoleFilter] = useState('');
|
|
56
|
+
const [loading, setLoading] = useState(true);
|
|
57
|
+
const [notice, setNotice] = useState(null);
|
|
58
|
+
const [invitations, setInvitations] = useState([]);
|
|
59
|
+
const [invite, setInvite] = useState({ email: '', name: '', role: 'author' });
|
|
60
|
+
const [inviting, setInviting] = useState(false);
|
|
61
|
+
// The user being deleted, and — when they have posts — who receives them.
|
|
62
|
+
const [deleting, setDeleting] = useState(null);
|
|
63
|
+
const [candidates, setCandidates] = useState([]);
|
|
64
|
+
const [reassignTo, setReassignTo] = useState('');
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
loadUsers();
|
|
67
|
+
}, [page, query, roleFilter]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
loadInvitations();
|
|
70
|
+
}, []);
|
|
71
|
+
const loadUsers = async () => {
|
|
72
|
+
try {
|
|
73
|
+
const params = new URLSearchParams({ page: String(page) });
|
|
74
|
+
if (query)
|
|
75
|
+
params.set('search', query);
|
|
76
|
+
if (roleFilter)
|
|
77
|
+
params.set('role', roleFilter);
|
|
78
|
+
const res = await api.get(`/api/users?${params}`);
|
|
79
|
+
setUsers(res?.users || []);
|
|
80
|
+
if (res?.roles?.length)
|
|
81
|
+
setRoles(res.roles);
|
|
82
|
+
setMeta(res?.meta ?? null);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
setNotice({ tone: 'error', text: error.message || t('Could not load users.') });
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
setLoading(false);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const loadInvitations = async () => {
|
|
92
|
+
try {
|
|
93
|
+
const res = await api.get('/api/invitations');
|
|
94
|
+
setInvitations(res?.invitations || []);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// The users table is the important half; a failed side list is not
|
|
98
|
+
// worth replacing the page's notice for.
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
/** Run a change, show the server's verdict, and reload the window. */
|
|
102
|
+
const act = async (work, success) => {
|
|
103
|
+
setNotice(null);
|
|
104
|
+
try {
|
|
105
|
+
await work();
|
|
106
|
+
setNotice({ tone: 'ok', text: success });
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
setNotice({ tone: 'error', text: error.message || t('That did not work.') });
|
|
110
|
+
}
|
|
111
|
+
// Reloaded on failure too: a refusal often means someone else changed the
|
|
112
|
+
// row, and what is on screen is now out of date.
|
|
113
|
+
await loadUsers();
|
|
114
|
+
};
|
|
115
|
+
const changeRole = (target, role) => {
|
|
116
|
+
if (role === target.role)
|
|
117
|
+
return;
|
|
118
|
+
if (!confirm(t('Make {name} {role}? They will be signed out and sign in again with the new role.', { name: target.name, role: roleArticled(role) })))
|
|
119
|
+
return;
|
|
120
|
+
act(() => api.put(`/api/users/${target.id}`, { role }), t('{name} is now {role}.', { name: target.name, role: roleArticled(role) }));
|
|
121
|
+
};
|
|
122
|
+
const toggleDisabled = (target) => {
|
|
123
|
+
if (target.disabled_at) {
|
|
124
|
+
act(() => api.post(`/api/users/${target.id}/enable`), t('{name} can sign in again.', { name: target.name }));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (!confirm(t('Disable {name}? They are signed out everywhere and cannot sign in until enabled. Their posts stay up.', { name: target.name })))
|
|
128
|
+
return;
|
|
129
|
+
act(() => api.post(`/api/users/${target.id}/disable`), t('{name} has been disabled.', { name: target.name }));
|
|
130
|
+
};
|
|
131
|
+
const startDelete = async (target) => {
|
|
132
|
+
setNotice(null);
|
|
133
|
+
if (target.post_count === 0) {
|
|
134
|
+
if (!confirm(t('Delete {name}? This cannot be undone.', { name: target.name })))
|
|
135
|
+
return;
|
|
136
|
+
act(() => api.delete(`/api/users/${target.id}`), t('{name} was deleted.', { name: target.name }));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
// Everyone, not just this page: the person receiving the posts is rarely
|
|
140
|
+
// on the same page of the table as the person leaving.
|
|
141
|
+
setDeleting(target);
|
|
142
|
+
setReassignTo('');
|
|
143
|
+
try {
|
|
144
|
+
const res = await api.get('/api/users?per_page=100');
|
|
145
|
+
setCandidates((res?.users || []).filter(u => u.id !== target.id));
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
setCandidates(users.filter(u => u.id !== target.id));
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const confirmDelete = async (event) => {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
if (!deleting || !reassignTo)
|
|
154
|
+
return;
|
|
155
|
+
const target = deleting;
|
|
156
|
+
const receiver = candidates.find(u => String(u.id) === reassignTo);
|
|
157
|
+
setDeleting(null);
|
|
158
|
+
await act(() => api.delete(`/api/users/${target.id}?reassign=${encodeURIComponent(reassignTo)}`), t('{name} was deleted. Their posts now belong to {receiver}.', { name: target.name, receiver: receiver?.name ?? t('the user you chose') }));
|
|
159
|
+
};
|
|
160
|
+
const handleSearch = (event) => {
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
setPage(1);
|
|
163
|
+
setQuery(search.trim());
|
|
164
|
+
};
|
|
165
|
+
const handleInvite = async (event) => {
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
setInviting(true);
|
|
168
|
+
setNotice(null);
|
|
169
|
+
try {
|
|
170
|
+
const res = await api.post('/api/users/invite', {
|
|
171
|
+
email: invite.email,
|
|
172
|
+
name: invite.name || undefined,
|
|
173
|
+
role: invite.role
|
|
174
|
+
});
|
|
175
|
+
setNotice({ tone: 'ok', text: res.message });
|
|
176
|
+
setInvite({ email: '', name: '', role: invite.role });
|
|
177
|
+
await loadInvitations();
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
setNotice({ tone: 'error', text: error.message || t('Could not send the invitation.') });
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
setInviting(false);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
const revokeInvitation = async (invitation) => {
|
|
187
|
+
if (!confirm(t('Revoke the invitation to {email}? The link they were sent stops working.', { email: invitation.email })))
|
|
188
|
+
return;
|
|
189
|
+
try {
|
|
190
|
+
await api.delete(`/api/invitations/${invitation.id}`);
|
|
191
|
+
setNotice({ tone: 'ok', text: t('Invitation to {email} revoked.', { email: invitation.email }) });
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
setNotice({ tone: 'error', text: error.message || t('Could not revoke the invitation.') });
|
|
195
|
+
}
|
|
196
|
+
await loadInvitations();
|
|
197
|
+
};
|
|
198
|
+
if (loading) {
|
|
199
|
+
return (_jsx(AdminLayout, { title: t('Users'), children: _jsx("div", { className: "admin-loading", children: t('Loading…') }) }));
|
|
200
|
+
}
|
|
201
|
+
return (_jsxs(AdminLayout, { title: t('Users'), children: [_jsx("style", { children: userStyles }), notice && (_jsx("div", { className: `users-notice users-notice-${notice.tone}`, role: "status", children: notice.text })), deleting && (_jsxs("form", { className: "users-reassign", onSubmit: confirmDelete, children: [_jsx("p", { className: "users-reassign-title", children: t('Delete {name}?', { name: deleting.name }) }), _jsxs("p", { className: "users-hint", children: [tn('They have written {count} post.', 'They have written {count} posts.', deleting.post_count), ' ', t('Choose who they should belong to — nothing is deleted with the account. This cannot be undone.')] }), _jsxs("div", { className: "users-row", children: [_jsxs("select", { className: "admin-select", value: reassignTo, onChange: e => setReassignTo(e.target.value), required: true, "aria-label": t('Reassign posts to'), children: [_jsx("option", { value: "", children: t('Reassign posts to…') }), candidates.map(candidate => (_jsxs("option", { value: candidate.id, children: [candidate.name, " (", candidate.email, ")"] }, candidate.id)))] }), _jsx("button", { type: "submit", className: "admin-btn admin-btn-danger", disabled: !reassignTo, children: t('Reassign and delete') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => setDeleting(null), children: t('Cancel') })] })] })), _jsxs("div", { className: "admin-card", children: [_jsxs("div", { className: "admin-card-header", children: [_jsx("h2", { className: "admin-card-title", children: t('Users') }), meta && _jsx("span", { className: "users-count", children: meta.total })] }), _jsxs("form", { className: "users-row users-filters", onSubmit: handleSearch, children: [_jsx("input", { className: "admin-input", type: "search", value: search, onChange: e => setSearch(e.target.value), placeholder: t('Search by name or email'), "aria-label": t('Search users') }), _jsxs("select", { className: "admin-select", value: roleFilter, onChange: e => { setPage(1); setRoleFilter(e.target.value); }, "aria-label": t('Filter by role'), children: [_jsx("option", { value: "", children: t('All roles') }), roles.map(role => _jsx("option", { value: role, children: roleLabel(role) }, role))] }), _jsx("button", { type: "submit", className: "admin-btn admin-btn-secondary", children: t('Search') })] }), users.length === 0 ? (_jsx("div", { className: "users-empty", children: _jsx("p", { children: query || roleFilter ? t('Nobody matches that search.') : t('No users yet.') }) })) : (_jsxs("table", { className: "admin-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('Name') }), _jsx("th", { children: t('Role') }), _jsx("th", { children: t('Posts') }), _jsx("th", { children: t('Status') }), _jsx("th", { children: t('Joined') }), _jsx("th", { children: t('Actions') })] }) }), _jsx("tbody", { children: users.map(row => {
|
|
202
|
+
// Your own role, status and account are off limits here — the
|
|
203
|
+
// server refuses them, so offering them would only invite an
|
|
204
|
+
// error. Another admin can make those changes for you.
|
|
205
|
+
const isMe = me?.id === row.id;
|
|
206
|
+
return (_jsxs("tr", { children: [_jsxs("td", { children: [_jsx("strong", { children: row.name }), isMe && _jsxs("span", { className: "users-muted", children: [" ", t('(you)')] }), _jsx("div", { className: "users-muted", children: row.email })] }), _jsx("td", { children: _jsx("select", { className: "admin-select", value: row.role, disabled: isMe, onChange: e => changeRole(row, e.target.value), "aria-label": t('Role for {name}', { name: row.name }), title: isMe ? t('You cannot change your own role') : ROLE_HINTS[row.role], children: roles.map(role => _jsx("option", { value: role, children: roleLabel(role) }, role)) }) }), _jsx("td", { children: row.post_count }), _jsx("td", { children: row.disabled_at ? (_jsx("span", { className: "admin-badge admin-badge-danger", children: t('Disabled') })) : row.email_verified ? (_jsx("span", { className: "admin-badge admin-badge-success", children: t('Active') })) : (_jsx("span", { className: "admin-badge admin-badge-warning", children: t('Unverified') })) }), _jsx("td", { className: "users-muted", children: new Date(row.created_at).toLocaleDateString(locale) }), _jsx("td", { children: _jsxs("div", { className: "users-row", children: [_jsx("button", { onClick: () => toggleDisabled(row), className: "admin-btn admin-btn-secondary", disabled: isMe, children: row.disabled_at ? t('Enable') : t('Disable') }), _jsx("button", { onClick: () => startDelete(row), className: "admin-btn admin-btn-danger", disabled: isMe, children: t('Delete') })] }) })] }, row.id));
|
|
207
|
+
}) })] })), meta && _jsx(Pagination, { meta: meta, onChange: setPage, noun: t('users') })] }), _jsxs("div", { className: "admin-card", children: [_jsx("div", { className: "admin-card-header", children: _jsx("h2", { className: "admin-card-title", children: t('Invite someone') }) }), _jsxs("form", { onSubmit: handleInvite, className: "users-form", children: [_jsxs("label", { className: "users-field", children: [_jsx("span", { className: "users-label", children: t('Email') }), _jsx("input", { className: "admin-input", type: "email", value: invite.email, onChange: e => setInvite({ ...invite, email: e.target.value }), placeholder: 'jane@example.com', required: true })] }), _jsxs("label", { className: "users-field", children: [_jsx("span", { className: "users-label", children: t('Name (optional)') }), _jsx("input", { className: "admin-input", value: invite.name, onChange: e => setInvite({ ...invite, name: e.target.value }), placeholder: t('Filled in on their sign-up form; they can change it') })] }), _jsxs("label", { className: "users-field", children: [_jsx("span", { className: "users-label", children: t('Role') }), _jsx("select", { className: "admin-select", value: invite.role, onChange: e => setInvite({ ...invite, role: e.target.value }), children: roles.map(role => _jsx("option", { value: role, children: roleLabel(role) }, role)) }), _jsx("span", { className: "users-hint", children: ROLE_HINTS[invite.role] ?? '' })] }), _jsx("div", { children: _jsx("button", { type: "submit", className: "admin-btn admin-btn-primary", disabled: inviting, children: inviting ? t('Sending…') : t('Send invitation') }) }), _jsx("span", { className: "users-hint", children: t('They get an email with a link that works once, for 7 days — even while sign-ups are closed.') })] })] }), _jsxs("div", { className: "admin-card", children: [_jsxs("div", { className: "admin-card-header", children: [_jsx("h2", { className: "admin-card-title", children: t('Pending invitations') }), _jsx("span", { className: "users-count", children: invitations.length })] }), invitations.length === 0 ? (_jsx("div", { className: "users-empty", children: _jsx("p", { children: t('No pending invitations.') }) })) : (_jsxs("table", { className: "admin-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('Email') }), _jsx("th", { children: t('Role') }), _jsx("th", { children: t('Invited by') }), _jsx("th", { children: t('Expires') }), _jsx("th", {})] }) }), _jsx("tbody", { children: invitations.map(invitation => (_jsxs("tr", { children: [_jsxs("td", { children: [_jsx("strong", { children: invitation.email }), invitation.name && _jsx("div", { className: "users-muted", children: invitation.name })] }), _jsx("td", { children: roleLabel(invitation.role) }), _jsx("td", { className: "users-muted", children: invitation.invited_by ?? '—' }), _jsx("td", { className: "users-muted", children: new Date(invitation.expires_at).toLocaleDateString(locale) }), _jsx("td", { children: _jsx("button", { onClick: () => revokeInvitation(invitation), className: "admin-btn admin-btn-secondary", children: t('Revoke') }) })] }, invitation.id))) })] }))] })] }));
|
|
208
|
+
}
|
|
209
|
+
function capitalise(value) {
|
|
210
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
211
|
+
}
|
|
212
|
+
function articled(role) {
|
|
213
|
+
return /^[aeiou]/i.test(role) ? `an ${role}` : `a ${role}`;
|
|
214
|
+
}
|
|
215
|
+
const userStyles = `
|
|
216
|
+
.users-notice {
|
|
217
|
+
padding: 12px 16px;
|
|
218
|
+
border-radius: 8px;
|
|
219
|
+
border: 1px solid var(--border);
|
|
220
|
+
margin-bottom: 16px;
|
|
221
|
+
font-size: 14px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.users-notice-ok {
|
|
225
|
+
background: var(--tint-success);
|
|
226
|
+
border-color: var(--success);
|
|
227
|
+
color: var(--success);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.users-notice-error {
|
|
231
|
+
background: var(--tint-danger);
|
|
232
|
+
border-color: var(--danger);
|
|
233
|
+
color: var(--danger);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.users-reassign {
|
|
237
|
+
padding: 16px;
|
|
238
|
+
border-radius: 8px;
|
|
239
|
+
border: 1px solid var(--danger);
|
|
240
|
+
background: var(--tint-danger);
|
|
241
|
+
margin-bottom: 16px;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.users-reassign-title {
|
|
245
|
+
margin: 0 0 4px;
|
|
246
|
+
font-weight: 600;
|
|
247
|
+
color: var(--fg);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.users-reassign .users-hint {
|
|
251
|
+
display: block;
|
|
252
|
+
margin: 0 0 12px;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.users-row {
|
|
256
|
+
display: flex;
|
|
257
|
+
gap: 8px;
|
|
258
|
+
align-items: center;
|
|
259
|
+
flex-wrap: wrap;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.users-filters {
|
|
263
|
+
margin-bottom: 16px;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.users-filters .admin-input {
|
|
267
|
+
flex: 1;
|
|
268
|
+
min-width: 200px;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.users-form {
|
|
272
|
+
display: flex;
|
|
273
|
+
flex-direction: column;
|
|
274
|
+
gap: 20px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.users-field {
|
|
278
|
+
display: flex;
|
|
279
|
+
flex-direction: column;
|
|
280
|
+
gap: 6px;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.users-label {
|
|
284
|
+
font-size: 13px;
|
|
285
|
+
font-weight: 600;
|
|
286
|
+
color: var(--fg);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.users-hint {
|
|
290
|
+
font-size: 12px;
|
|
291
|
+
color: var(--fg-muted);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.users-muted {
|
|
295
|
+
color: var(--fg-muted);
|
|
296
|
+
font-size: 13px;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.users-count {
|
|
300
|
+
font-size: 13px;
|
|
301
|
+
color: var(--fg-muted);
|
|
302
|
+
background: var(--surface-hover);
|
|
303
|
+
border-radius: 999px;
|
|
304
|
+
padding: 2px 10px;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.users-empty {
|
|
308
|
+
padding: 40px 20px;
|
|
309
|
+
text-align: center;
|
|
310
|
+
color: var(--fg-muted);
|
|
311
|
+
font-size: 14px;
|
|
312
|
+
}
|
|
313
|
+
`;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by scripts/generate-api-reference.js — do not edit.
|
|
3
|
+
*
|
|
4
|
+
* The field tables come from the interfaces in src/models/PublicContent.ts and
|
|
5
|
+
* the endpoint list from src/routes/api/v1.ts. Change those and re-run the
|
|
6
|
+
* generator; a test fails when this file stops matching them.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ENDPOINTS: {
|
|
9
|
+
method: string;
|
|
10
|
+
path: string;
|
|
11
|
+
scope: string;
|
|
12
|
+
shape: string;
|
|
13
|
+
collection: boolean;
|
|
14
|
+
summary: string;
|
|
15
|
+
}[];
|
|
16
|
+
export declare const QUERY_PARAMS: {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
}[];
|
|
20
|
+
export declare const SHAPES: {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
fields: {
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
}[];
|
|
28
|
+
}[];
|
|
29
|
+
export declare const ENVELOPE: {
|
|
30
|
+
item: string;
|
|
31
|
+
collection: string;
|
|
32
|
+
error: string;
|
|
33
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by scripts/generate-api-reference.js — do not edit.
|
|
3
|
+
*
|
|
4
|
+
* The field tables come from the interfaces in src/models/PublicContent.ts and
|
|
5
|
+
* the endpoint list from src/routes/api/v1.ts. Change those and re-run the
|
|
6
|
+
* generator; a test fails when this file stops matching them.
|
|
7
|
+
*/
|
|
8
|
+
export const ENDPOINTS = [
|
|
9
|
+
{
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/api/v1/posts',
|
|
12
|
+
scope: 'content:read',
|
|
13
|
+
shape: 'PublicPost',
|
|
14
|
+
collection: true,
|
|
15
|
+
summary: 'Published posts, newest first.'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
method: 'GET',
|
|
19
|
+
path: '/api/v1/posts/:slug',
|
|
20
|
+
scope: 'content:read',
|
|
21
|
+
shape: 'PublicPost',
|
|
22
|
+
collection: false,
|
|
23
|
+
summary: 'One published post, by slug or id.'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
method: 'GET',
|
|
27
|
+
path: '/api/v1/pages',
|
|
28
|
+
scope: 'content:read',
|
|
29
|
+
shape: 'PublicPage',
|
|
30
|
+
collection: true,
|
|
31
|
+
summary: 'Published pages, newest first.'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
method: 'GET',
|
|
35
|
+
path: '/api/v1/pages/:slug',
|
|
36
|
+
scope: 'content:read',
|
|
37
|
+
shape: 'PublicPage',
|
|
38
|
+
collection: false,
|
|
39
|
+
summary: 'One published page, by slug or id.'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
method: 'GET',
|
|
43
|
+
path: '/api/v1/authors',
|
|
44
|
+
scope: 'content:read',
|
|
45
|
+
shape: 'PublicAuthor',
|
|
46
|
+
collection: false,
|
|
47
|
+
summary: 'Every author with something published.'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
method: 'GET',
|
|
51
|
+
path: '/api/v1/authors/:slug',
|
|
52
|
+
scope: 'content:read',
|
|
53
|
+
shape: 'PublicAuthor',
|
|
54
|
+
collection: false,
|
|
55
|
+
summary: 'One author, by slug or id.'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
method: 'GET',
|
|
59
|
+
path: '/api/v1/categories',
|
|
60
|
+
scope: 'content:read',
|
|
61
|
+
shape: 'PublicCategory',
|
|
62
|
+
collection: false,
|
|
63
|
+
summary: 'Every category, with post counts.'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
method: 'GET',
|
|
67
|
+
path: '/api/v1/tags',
|
|
68
|
+
scope: 'content:read',
|
|
69
|
+
shape: 'PublicTag',
|
|
70
|
+
collection: false,
|
|
71
|
+
summary: 'Every tag, with post counts.'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
method: 'GET',
|
|
75
|
+
path: '/api/v1/media/:id',
|
|
76
|
+
scope: 'media:read',
|
|
77
|
+
shape: 'PublicMedia',
|
|
78
|
+
collection: false,
|
|
79
|
+
summary: 'One media item, by id.'
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
export const QUERY_PARAMS = [
|
|
83
|
+
{ name: 'author', description: 'Filter posts by author slug or id — an author archive.' },
|
|
84
|
+
{ name: 'category', description: 'Filter posts by category slug or id.' },
|
|
85
|
+
{ name: 'format', description: '`markdown` returns the source. Anything else returns rendered HTML.' },
|
|
86
|
+
{ name: 'page', description: 'Which page of results. Defaults to 1.' },
|
|
87
|
+
{ name: 'per_page', description: 'Results per page. Defaults to 10, clamped to 100.' },
|
|
88
|
+
{ name: 'search', description: 'Filter posts whose title or excerpt contains this text.' },
|
|
89
|
+
{ name: 'tag', description: 'Filter posts by tag slug or id.' },
|
|
90
|
+
{ name: 'tax', description: 'Filter posts by custom taxonomy term: `taxonomy:slug`, comma-separated to require several. `taxonomy[key]=slug` works too.' },
|
|
91
|
+
{ name: 'type', description: 'Content type key (see `/api/v1/types`). Defaults to `post`; `any` means every public type. Applies to the list and to a single post.' }
|
|
92
|
+
];
|
|
93
|
+
export const SHAPES = [
|
|
94
|
+
{
|
|
95
|
+
name: 'PublicPost',
|
|
96
|
+
description: 'A post as the content API returns it.',
|
|
97
|
+
fields: [
|
|
98
|
+
{ name: 'id', type: 'number', description: 'Stable identifier. Accepted anywhere a slug is.' },
|
|
99
|
+
{ name: 'slug', type: 'string | null', description: 'URL segment. Null on posts written before slugs existed.' },
|
|
100
|
+
{ name: 'title', type: 'string', description: 'Plain text, never markup.' },
|
|
101
|
+
{ name: 'excerpt', type: 'string | null', description: 'Short summary, if the author wrote one.' },
|
|
102
|
+
{ name: 'content', type: 'string | null', description: 'The body, in whichever `format` this item reports. Null when `gated`: the site\'s access policy did not let this request read it (with the members feature, send a member session as `X-Member-Token`).' },
|
|
103
|
+
{ name: 'format', type: '\'html\' | \'markdown\'', description: 'What `content` actually is — not what you asked for. See `?format=`.' },
|
|
104
|
+
{ name: 'visibility', type: 'string', description: 'Who may read the body: `public`, or a level the site\'s access policy defines (the members feature: `members`, `paid`).' },
|
|
105
|
+
{ name: 'gated', type: 'boolean', description: 'True when this response withholds the body because the request may not read it.' },
|
|
106
|
+
{ name: 'featured_image_url', type: 'string | null', description: 'Absolute URL of the featured image, or null.' },
|
|
107
|
+
{ name: 'author', type: 'string | null', description: 'The author\'s display name. Never their address.' },
|
|
108
|
+
{ name: 'author_profile', type: '{ id: number; name: string; slug: string | null; bio: string | null; website: string | null; avatar_url: string | null } | null', description: 'The author\'s profile — biography, link and avatar. Null if the account is gone.' },
|
|
109
|
+
{ name: 'categories', type: 'Array<{ id: number; name: string; slug: string }>', description: 'Every category on the post. Empty when uncategorised.' },
|
|
110
|
+
{ name: 'tags', type: 'Array<{ id: number; name: string; slug: string }>', description: 'Every tag on the post. Empty when untagged.' },
|
|
111
|
+
{ name: 'type', type: 'string', description: 'Content type key: `post` for a blog post, or a custom type such as `recipe`. See `?type=` and `/api/v1/types`.' },
|
|
112
|
+
{ name: 'fields', type: 'Record<string, unknown> | null', description: 'Custom field values keyed by field key, typed as the content type declares them. Empty when it has none; null when `gated`, like `content`.' },
|
|
113
|
+
{ name: 'terms', type: 'Record<string, Array<{ id: number; name: string; slug: string }>>', description: 'Custom taxonomy terms keyed by taxonomy key. Categories and tags stay in their own fields.' },
|
|
114
|
+
{ name: 'meta_title', type: 'string | null', description: 'SEO title override, if set.' },
|
|
115
|
+
{ name: 'meta_description', type: 'string | null', description: 'SEO description override, if set.' },
|
|
116
|
+
{ name: 'featured_image', type: 'ResponsiveImage | null', description: 'The featured image with its dimensions, alt text and a srcset when IMAGE_TRANSFORM_URL is set.' },
|
|
117
|
+
{ name: 'og', type: 'SocialCard', description: 'Open Graph card: title, description and image, each falling back to the SEO fields, the excerpt and the featured image.' },
|
|
118
|
+
{ name: 'twitter', type: 'SocialCard', description: 'Twitter card, falling back to the Open Graph card.' },
|
|
119
|
+
{ name: 'canonical_url', type: 'string | null', description: 'Where this was first published, if somewhere else. Emit as rel=canonical.' },
|
|
120
|
+
{ name: 'noindex', type: 'boolean', description: 'True when the author asked search engines not to index this. Emit a robots noindex meta tag.' },
|
|
121
|
+
{ name: 'structured_data', type: 'Record<string, unknown>', description: 'schema.org BlogPosting, ready to embed as application/ld+json.' },
|
|
122
|
+
{ name: 'published_at', type: 'string', description: 'When it went live, ISO 8601. Posts are ordered by this, newest first.' },
|
|
123
|
+
{ name: 'updated_at', type: 'string', description: 'When it last changed, ISO 8601.' }
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'PublicPage',
|
|
128
|
+
description: 'A page as the content API returns it. A post without the blog machinery.',
|
|
129
|
+
fields: [
|
|
130
|
+
{ name: 'id', type: 'number', description: 'Stable identifier. Accepted anywhere a slug is.' },
|
|
131
|
+
{ name: 'slug', type: 'string', description: 'URL segment. Required on pages, unlike posts.' },
|
|
132
|
+
{ name: 'title', type: 'string', description: 'Plain text, never markup.' },
|
|
133
|
+
{ name: 'content', type: 'string', description: 'The body, in whichever `format` this item reports.' },
|
|
134
|
+
{ name: 'format', type: '\'html\' | \'markdown\'', description: 'What `content` actually is — not what you asked for. See `?format=`.' },
|
|
135
|
+
{ name: 'featured_image_url', type: 'string | null', description: 'Absolute URL of the featured image, or null.' },
|
|
136
|
+
{ name: 'meta_title', type: 'string | null', description: 'SEO title override, if set.' },
|
|
137
|
+
{ name: 'meta_description', type: 'string | null', description: 'SEO description override, if set.' },
|
|
138
|
+
{ name: 'featured_image', type: 'ResponsiveImage | null', description: 'The featured image with its dimensions, alt text and a srcset when IMAGE_TRANSFORM_URL is set.' },
|
|
139
|
+
{ name: 'og', type: 'SocialCard', description: 'Open Graph card: title, description and image, each falling back to the SEO fields and the featured image.' },
|
|
140
|
+
{ name: 'twitter', type: 'SocialCard', description: 'Twitter card, falling back to the Open Graph card.' },
|
|
141
|
+
{ name: 'canonical_url', type: 'string | null', description: 'Where this was first published, if somewhere else. Emit as rel=canonical.' },
|
|
142
|
+
{ name: 'noindex', type: 'boolean', description: 'True when the author asked search engines not to index this. Emit a robots noindex meta tag.' },
|
|
143
|
+
{ name: 'published_at', type: 'string', description: 'When it was created, ISO 8601.' },
|
|
144
|
+
{ name: 'updated_at', type: 'string', description: 'When it last changed, ISO 8601.' }
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'PublicAuthor',
|
|
149
|
+
description: 'An author, as a byline and an archive page need them.',
|
|
150
|
+
fields: [
|
|
151
|
+
{ name: 'id', type: 'number', description: 'Stable identifier. Accepted anywhere a slug is.' },
|
|
152
|
+
{ name: 'name', type: 'string', description: 'Display name, as it appears on a byline.' },
|
|
153
|
+
{ name: 'slug', type: 'string | null', description: 'URL segment for the author\'s archive. Accepted by `?author=`.' },
|
|
154
|
+
{ name: 'bio', type: 'string | null', description: 'The biography they wrote, if any.' },
|
|
155
|
+
{ name: 'website', type: 'string | null', description: 'Their own site, if they gave one.' },
|
|
156
|
+
{ name: 'avatar_url', type: 'string | null', description: 'Absolute URL of their avatar, or null.' },
|
|
157
|
+
{ name: 'post_count', type: 'number', description: 'How many published posts they have. Never zero — unpublished authors are not listed.' }
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'PublicCategory',
|
|
162
|
+
description: 'A category, with how many published posts sit in it.',
|
|
163
|
+
fields: [
|
|
164
|
+
{ name: 'id', type: 'number', description: 'Stable identifier.' },
|
|
165
|
+
{ name: 'name', type: 'string', description: 'Display name.' },
|
|
166
|
+
{ name: 'slug', type: 'string', description: 'URL segment. Accepted by `?category=`.' },
|
|
167
|
+
{ name: 'description', type: 'string | null', description: 'Longer description, if one was written.' },
|
|
168
|
+
{ name: 'post_count', type: 'number', description: 'Published posts in this category. Zero is returned, not omitted.' }
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'PublicTag',
|
|
173
|
+
description: 'A tag, with how many published posts carry it.',
|
|
174
|
+
fields: [
|
|
175
|
+
{ name: 'id', type: 'number', description: 'Stable identifier.' },
|
|
176
|
+
{ name: 'name', type: 'string', description: 'Display name.' },
|
|
177
|
+
{ name: 'slug', type: 'string', description: 'URL segment. Accepted by `?tag=`.' },
|
|
178
|
+
{ name: 'post_count', type: 'number', description: 'Published posts carrying this tag.' }
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: 'PublicMedia',
|
|
183
|
+
description: 'A media item.',
|
|
184
|
+
fields: [
|
|
185
|
+
{ name: 'id', type: 'number', description: 'Stable identifier.' },
|
|
186
|
+
{ name: 'url', type: 'string', description: 'Absolute URL of the file.' },
|
|
187
|
+
{ name: 'mime_type', type: 'string', description: 'MIME type as recorded at upload.' },
|
|
188
|
+
{ name: 'size', type: 'number', description: 'Size in bytes.' },
|
|
189
|
+
{ name: 'alt_text', type: 'string | null', description: 'Alt text, if an editor supplied one.' },
|
|
190
|
+
{ name: 'created_at', type: 'string', description: 'When it was uploaded, ISO 8601.' }
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
];
|
|
194
|
+
export const ENVELOPE = {
|
|
195
|
+
item: '{ "data": <object> }',
|
|
196
|
+
collection: '{ "data": [<object>], "meta": { "page", "per_page", "total", "total_pages" } }',
|
|
197
|
+
error: '{ "error": "Not found" }'
|
|
198
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tailwind, compiled at build time.
|
|
3
|
+
*
|
|
4
|
+
* This used to be `<script src="https://cdn.tailwindcss.com">` in index.html,
|
|
5
|
+
* which survived into the production build — so a deployed site downloaded a
|
|
6
|
+
* compiler and generated its CSS in the browser on every visit, and lost all
|
|
7
|
+
* styling whenever the CDN was unreachable. Tailwind documents that build as
|
|
8
|
+
* being for development only.
|
|
9
|
+
*
|
|
10
|
+
* Tailwind 4 configures itself from CSS rather than a JavaScript object, so the
|
|
11
|
+
* theme extensions that used to sit inline in a <script> live here.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
@import 'tailwindcss';
|
|
15
|
+
|
|
16
|
+
@theme {
|
|
17
|
+
/* Used by the page shell in index.html. */
|
|
18
|
+
--color-dark-900: #0f0f0f;
|
|
19
|
+
--color-dark-800: #1a1a1a;
|
|
20
|
+
--color-dark-700: #222222;
|
|
21
|
+
--color-dark-600: #333333;
|
|
22
|
+
|
|
23
|
+
/* Toasts slide in. The matching slide-out and the two fades were configured
|
|
24
|
+
and never used, so they are not carried over. */
|
|
25
|
+
--animate-slide-in: slideIn 0.3s ease-out;
|
|
26
|
+
|
|
27
|
+
@keyframes slideIn {
|
|
28
|
+
0% {
|
|
29
|
+
transform: translateX(100%);
|
|
30
|
+
opacity: 0;
|
|
31
|
+
}
|
|
32
|
+
100% {
|
|
33
|
+
transform: translateX(0);
|
|
34
|
+
opacity: 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CMS's own migrations, all of them, for every site: a feature list
|
|
3
|
+
* switches behaviour, not the schema. Found beside src/ in the repository and
|
|
4
|
+
* beside lib/ in the package. The server entry imports this module too, so
|
|
5
|
+
* Vercel's tracer follows this URL into the function.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CMS_MIGRATIONS: string;
|
|
8
|
+
/** The site's own migrations, from `basicben make:migration`, run after the CMS's. */
|
|
9
|
+
export declare const SITE_MIGRATIONS = "db/migrations";
|
|
10
|
+
export interface SiteConfig {
|
|
11
|
+
/**
|
|
12
|
+
* The CMS features this site runs, by name: analytics, members, mysendbox,
|
|
13
|
+
* theme. Order is the order their routes mount in; theme goes last. []
|
|
14
|
+
* is the bare core. Left out, it is the bare core with a warning.
|
|
15
|
+
*/
|
|
16
|
+
features?: string[];
|
|
17
|
+
/** Everything else is the framework's config: cors, mail, storage, db, port… */
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface ResolvedSiteConfig extends SiteConfig {
|
|
21
|
+
features: string[];
|
|
22
|
+
migrations: string[];
|
|
23
|
+
}
|
|
24
|
+
export declare function defineSite(site?: SiteConfig): ResolvedSiteConfig;
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@basicbenframework/cms/config`: what a site's basicben.config.js calls.
|
|
3
|
+
*
|
|
4
|
+
* import { defineSite } from '@basicbenframework/cms/config'
|
|
5
|
+
* export default defineSite({ features: ['analytics', 'members', 'theme'], cors, mail, storage })
|
|
6
|
+
*
|
|
7
|
+
* Every process loads that file: the server, the CLI, the migrator, the
|
|
8
|
+
* admin build. So the feature list is checked here, once, and a misspelt name
|
|
9
|
+
* stops all of them instead of quietly leaving a feature off.
|
|
10
|
+
*
|
|
11
|
+
* Synchronous, and it must stay so: core's loadConfig takes the default
|
|
12
|
+
* export as it finds it. It imports only the manifests, which are data.
|
|
13
|
+
*/
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
import { enabledFeatureNames } from "./host/enabled.js";
|
|
16
|
+
/**
|
|
17
|
+
* The CMS's own migrations, all of them, for every site: a feature list
|
|
18
|
+
* switches behaviour, not the schema. Found beside src/ in the repository and
|
|
19
|
+
* beside lib/ in the package. The server entry imports this module too, so
|
|
20
|
+
* Vercel's tracer follows this URL into the function.
|
|
21
|
+
*/
|
|
22
|
+
export const CMS_MIGRATIONS = fileURLToPath(new URL('../db/migrations/', import.meta.url));
|
|
23
|
+
/** The site's own migrations, from `basicben make:migration`, run after the CMS's. */
|
|
24
|
+
export const SITE_MIGRATIONS = 'db/migrations';
|
|
25
|
+
export function defineSite(site = {}) {
|
|
26
|
+
if (site === null || typeof site !== 'object' || Array.isArray(site)) {
|
|
27
|
+
throw new Error('defineSite takes the site\'s config, an object');
|
|
28
|
+
}
|
|
29
|
+
for (const name of Array.isArray(site.features) ? site.features : []) {
|
|
30
|
+
if (typeof name === 'string' && /[/\\.@]/.test(name)) {
|
|
31
|
+
throw new Error(`Feature "${name}" in basicben.config.js looks like a path or a package. Only the CMS's own features can be listed for now (phase 4c will open this up).`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if ('migrations' in site) {
|
|
35
|
+
throw new Error('`migrations` is set by defineSite: the CMS\'s, then the site\'s db/migrations. ' +
|
|
36
|
+
'Put the site\'s own migrations in db/migrations (basicben make:migration does) and remove the key.');
|
|
37
|
+
}
|
|
38
|
+
return { ...site, features: enabledFeatureNames(site.features), migrations: [CMS_MIGRATIONS, SITE_MIGRATIONS] };
|
|
39
|
+
}
|