@basicbenframework/cms 0.0.0-stage → 0.6.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 +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,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Long-lived API tokens, for programs rather than people.
|
|
3
|
+
*
|
|
4
|
+
* Only a hash of the token is stored, so a copy of this table does not let
|
|
5
|
+
* anyone read the site's content API.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** @typedef {{ exec: (sql: string) => Promise<void> }} MigrationDb */
|
|
9
|
+
/** @typedef {{ autoIncrementPrimaryKey: () => string, timestampType: () => string, dropTable: (table: string) => string }} Grammar */
|
|
10
|
+
|
|
11
|
+
/** @param {MigrationDb} db @param {Grammar} grammar */
|
|
12
|
+
export const up = async (db, grammar) => {
|
|
13
|
+
await db.exec(`
|
|
14
|
+
CREATE TABLE api_tokens (
|
|
15
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
16
|
+
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
17
|
+
name TEXT NOT NULL,
|
|
18
|
+
token_hash TEXT NOT NULL UNIQUE,
|
|
19
|
+
scopes TEXT NOT NULL,
|
|
20
|
+
last_used_at ${grammar.timestampType()},
|
|
21
|
+
expires_at ${grammar.timestampType()},
|
|
22
|
+
created_at ${grammar.timestampType()} NOT NULL
|
|
23
|
+
)
|
|
24
|
+
`)
|
|
25
|
+
|
|
26
|
+
// Every authenticated request looks a token up by its hash. The column is
|
|
27
|
+
// already UNIQUE, which indexes it on both drivers, so the lookup is covered.
|
|
28
|
+
await db.exec('CREATE INDEX idx_api_tokens_user ON api_tokens (user_id)')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @param {MigrationDb} db @param {Grammar} grammar */
|
|
32
|
+
export const down = async (db, grammar) => {
|
|
33
|
+
await db.exec(grammar.dropTable('api_tokens'))
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Categories become many-to-many, as they are in every CMS people arrive from.
|
|
3
|
+
*
|
|
4
|
+
* `posts.category_id` allowed exactly one, which is fine until you import from
|
|
5
|
+
* somewhere that allows several: 59 of 70 posts in the first real migration had
|
|
6
|
+
* more than one category, so 67 of 83 were demoted to tags to avoid dropping
|
|
7
|
+
* them outright. They survived, but as the wrong kind of thing.
|
|
8
|
+
*
|
|
9
|
+
* `posts.category_id` stays, and stays meaningful: it is the *primary*
|
|
10
|
+
* category — the one a breadcrumb or a canonical URL would use. Every category
|
|
11
|
+
* a post has, including that one, is a row here.
|
|
12
|
+
*
|
|
13
|
+
* Existing rows are backfilled, so nothing has to be re-imported to keep what
|
|
14
|
+
* it already had.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const up = async (db) => {
|
|
18
|
+
await db.exec(`
|
|
19
|
+
CREATE TABLE post_categories (
|
|
20
|
+
post_id INTEGER NOT NULL REFERENCES posts(id) ON DELETE CASCADE,
|
|
21
|
+
category_id INTEGER NOT NULL REFERENCES categories(id) ON DELETE CASCADE,
|
|
22
|
+
PRIMARY KEY (post_id, category_id)
|
|
23
|
+
)
|
|
24
|
+
`)
|
|
25
|
+
|
|
26
|
+
await db.exec('CREATE INDEX idx_post_categories_post ON post_categories(post_id)')
|
|
27
|
+
await db.exec('CREATE INDEX idx_post_categories_category ON post_categories(category_id)')
|
|
28
|
+
|
|
29
|
+
// Whatever each post already had becomes its first row here, so the join
|
|
30
|
+
// table is authoritative from the moment it exists rather than after a
|
|
31
|
+
// re-import.
|
|
32
|
+
await db.exec(`
|
|
33
|
+
INSERT INTO post_categories (post_id, category_id)
|
|
34
|
+
SELECT id, category_id FROM posts WHERE category_id IS NOT NULL
|
|
35
|
+
`)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const down = async (db, grammar) => {
|
|
39
|
+
await db.exec(grammar.dropTable('post_categories'))
|
|
40
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every user gets an author profile.
|
|
3
|
+
*
|
|
4
|
+
* A post has always carried a `user_id`, and every byline the site renders came
|
|
5
|
+
* from `users.name` — the whole of what a reader could learn about whoever
|
|
6
|
+
* wrote it. There was nowhere to put a biography, a link, or a face, so a
|
|
7
|
+
* multi-author site had authors in the database and none on the page.
|
|
8
|
+
*
|
|
9
|
+
* `name` stays the display name rather than gaining a `display_name` beside it.
|
|
10
|
+
* Two columns that both mean "what goes on the byline" is the kind of pair that
|
|
11
|
+
* disagrees within a week, and every existing byline already reads `name`.
|
|
12
|
+
*
|
|
13
|
+
* `slug` is the author archive segment — `/author/jane-doe`, and `?author=` on
|
|
14
|
+
* the content API. Backfilled here so every account that already exists is
|
|
15
|
+
* addressable the moment this runs, deduplicated because two people called Jane
|
|
16
|
+
* Doe is a fact about the world rather than an error.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { slugify } from '@basicbenframework/core/content'
|
|
20
|
+
|
|
21
|
+
export const up = async (db) => {
|
|
22
|
+
await db.exec('ALTER TABLE users ADD COLUMN slug TEXT')
|
|
23
|
+
await db.exec('ALTER TABLE users ADD COLUMN bio TEXT')
|
|
24
|
+
await db.exec('ALTER TABLE users ADD COLUMN website TEXT')
|
|
25
|
+
await db.exec('ALTER TABLE users ADD COLUMN avatar_id INTEGER REFERENCES media(id)')
|
|
26
|
+
|
|
27
|
+
const users = await db.all('SELECT id, name FROM users ORDER BY id ASC')
|
|
28
|
+
const taken = new Set()
|
|
29
|
+
|
|
30
|
+
for (const user of users) {
|
|
31
|
+
// A name that slugifies to nothing — one written entirely in a script the
|
|
32
|
+
// slugifier drops — still needs a URL, so it falls back to the id.
|
|
33
|
+
const base = slugify(user.name || '') || `author-${user.id}`
|
|
34
|
+
|
|
35
|
+
let slug = base
|
|
36
|
+
let suffix = 2
|
|
37
|
+
|
|
38
|
+
while (taken.has(slug)) slug = `${base}-${suffix++}`
|
|
39
|
+
|
|
40
|
+
taken.add(slug)
|
|
41
|
+
|
|
42
|
+
await db.run('UPDATE users SET slug = ? WHERE id = ?', [slug, user.id])
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Unique rather than merely indexed: the slug is a URL, and two authors
|
|
46
|
+
// answering at one address is a bug you find in production. Rows written
|
|
47
|
+
// before this migration are all filled in above, and the model fills in
|
|
48
|
+
// every one written after.
|
|
49
|
+
await db.exec('CREATE UNIQUE INDEX idx_users_slug ON users(slug)')
|
|
50
|
+
await db.exec('CREATE INDEX idx_users_avatar ON users(avatar_id)')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const down = async (db) => {
|
|
54
|
+
await db.exec('DROP INDEX IF EXISTS idx_users_slug')
|
|
55
|
+
await db.exec('DROP INDEX IF EXISTS idx_users_avatar')
|
|
56
|
+
await db.exec('ALTER TABLE users DROP COLUMN avatar_id')
|
|
57
|
+
await db.exec('ALTER TABLE users DROP COLUMN website')
|
|
58
|
+
await db.exec('ALTER TABLE users DROP COLUMN bio')
|
|
59
|
+
await db.exec('ALTER TABLE users DROP COLUMN slug')
|
|
60
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pages get a featured image, the way posts already had one.
|
|
3
|
+
*
|
|
4
|
+
* `posts.featured_image` arrived with migration 009 and pages were left out,
|
|
5
|
+
* so a landing page built here could carry a hero image only by writing the
|
|
6
|
+
* Markdown for it inside the body — which puts it in the middle of the content
|
|
7
|
+
* rather than beside it, where a template, an Open Graph tag or a card listing
|
|
8
|
+
* could find it.
|
|
9
|
+
*
|
|
10
|
+
* A foreign key into `media`, not a URL, for the same reason posts store one:
|
|
11
|
+
* moving buckets or putting a CDN in front of one should not mean rewriting
|
|
12
|
+
* every row.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const up = async (db) => {
|
|
16
|
+
await db.exec('ALTER TABLE pages ADD COLUMN featured_image INTEGER REFERENCES media(id)')
|
|
17
|
+
await db.exec('CREATE INDEX idx_pages_featured_image ON pages(featured_image)')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const down = async (db) => {
|
|
21
|
+
await db.exec('DROP INDEX IF EXISTS idx_pages_featured_image')
|
|
22
|
+
await db.exec('ALTER TABLE pages DROP COLUMN featured_image')
|
|
23
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fill in the slugs and excerpts nothing ever wrote.
|
|
3
|
+
*
|
|
4
|
+
* `posts.slug` and `posts.excerpt` arrived with migration 009 and the editor
|
|
5
|
+
* has shown both fields ever since, but `store` and `update` read only title,
|
|
6
|
+
* content and published — the same fault the taxonomy had. So both columns are
|
|
7
|
+
* null on every post this CMS has written, which is why the content API
|
|
8
|
+
* documents a slug as "null on posts written before slugs existed": in practice
|
|
9
|
+
* that was all of them, and a consumer building URLs had to fall back to ids.
|
|
10
|
+
*
|
|
11
|
+
* The controller derives both from now on. This is the catch-up for what is
|
|
12
|
+
* already in the table, so nothing has to be opened and re-saved to get a URL.
|
|
13
|
+
*
|
|
14
|
+
* Only null columns are touched. An imported post that already has a slug keeps
|
|
15
|
+
* it — changing a published URL is not a migration's business.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { slugify, excerpt } from '@basicbenframework/core/content'
|
|
19
|
+
|
|
20
|
+
export const up = async (db) => {
|
|
21
|
+
const posts = await db.all(
|
|
22
|
+
'SELECT id, title, content, slug, excerpt FROM posts ORDER BY id ASC'
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// Seeded with what the table already holds, so a generated slug cannot
|
|
26
|
+
// collide with one an import wrote. `posts.slug` is uniquely indexed, and a
|
|
27
|
+
// collision here would fail the whole migration.
|
|
28
|
+
const taken = new Set(posts.map((post) => post.slug).filter(Boolean))
|
|
29
|
+
|
|
30
|
+
for (const post of posts) {
|
|
31
|
+
if (!post.slug) {
|
|
32
|
+
const base = slugify(post.title || '') || `post-${post.id}`
|
|
33
|
+
|
|
34
|
+
let slug = base
|
|
35
|
+
let suffix = 2
|
|
36
|
+
|
|
37
|
+
while (taken.has(slug)) slug = `${base}-${suffix++}`
|
|
38
|
+
|
|
39
|
+
taken.add(slug)
|
|
40
|
+
|
|
41
|
+
await db.run('UPDATE posts SET slug = ? WHERE id = ?', [slug, post.id])
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!post.excerpt && post.content) {
|
|
45
|
+
await db.run('UPDATE posts SET excerpt = ? WHERE id = ?', [
|
|
46
|
+
excerpt(post.content),
|
|
47
|
+
post.id
|
|
48
|
+
])
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const down = async () => {
|
|
54
|
+
// Deliberately empty. The columns existed before this ran; the values it
|
|
55
|
+
// wrote are indistinguishable from ones an author typed, and blanking every
|
|
56
|
+
// slug on a rollback would break every URL the site had just published.
|
|
57
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sessions that can be ended, and accounts that can be switched off.
|
|
3
|
+
*
|
|
4
|
+
* A session is a stateless JWT, so until now nothing could revoke one: signing
|
|
5
|
+
* out discarded the token on one device and left every copy of it valid for
|
|
6
|
+
* the rest of its seven days, and demoting an editor did nothing until their
|
|
7
|
+
* token happened to expire.
|
|
8
|
+
*
|
|
9
|
+
* `token_version` is carried in every token and compared on every request.
|
|
10
|
+
* Bumping it ends every session the account has, which is what signing out,
|
|
11
|
+
* changing a password, and changing a role each need.
|
|
12
|
+
*
|
|
13
|
+
* `disabled_at` turns an account off without deleting it, so the posts it
|
|
14
|
+
* wrote keep their author.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const up = async (db) => {
|
|
18
|
+
await db.exec('ALTER TABLE users ADD COLUMN token_version INTEGER NOT NULL DEFAULT 0')
|
|
19
|
+
await db.exec('ALTER TABLE users ADD COLUMN disabled_at TEXT')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const down = async (db) => {
|
|
23
|
+
await db.exec('ALTER TABLE users DROP COLUMN disabled_at')
|
|
24
|
+
await db.exec('ALTER TABLE users DROP COLUMN token_version')
|
|
25
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scheduling that schedules, review that can be asked for, and a trash.
|
|
3
|
+
*
|
|
4
|
+
* `publish_at` has existed since migration 009 and nothing read it: a post
|
|
5
|
+
* given a future date went live the moment it was published. From here a post
|
|
6
|
+
* is on the site when it is published, not in the trash, and its `publish_at`
|
|
7
|
+
* has arrived — one rule, kept in `src/models/visibility.ts`, that every public
|
|
8
|
+
* read goes through.
|
|
9
|
+
*
|
|
10
|
+
* `status` is the editorial state the admin shows: `draft`, `pending` (a
|
|
11
|
+
* contributor asking for review) or `published`. `published` stays the flag
|
|
12
|
+
* every query already filters on and is kept in step with it, so nothing that
|
|
13
|
+
* reads the flag needs to learn the new column.
|
|
14
|
+
*
|
|
15
|
+
* `deleted_at` is the trash. A deleted post is hidden everywhere and can be
|
|
16
|
+
* restored until it is emptied.
|
|
17
|
+
*
|
|
18
|
+
* `live_notified` records whether webhooks have been told a post is live. A
|
|
19
|
+
* post published now is told at once; a scheduled one is told by the
|
|
20
|
+
* publish-due tick when its time comes, which then sets this.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
export const up = async (db, grammar) => {
|
|
24
|
+
await db.exec("ALTER TABLE posts ADD COLUMN status TEXT NOT NULL DEFAULT 'draft'")
|
|
25
|
+
await db.exec(`ALTER TABLE posts ADD COLUMN deleted_at ${grammar.timestampType()}`)
|
|
26
|
+
await db.exec('ALTER TABLE posts ADD COLUMN live_notified INTEGER NOT NULL DEFAULT 1')
|
|
27
|
+
|
|
28
|
+
await db.exec("UPDATE posts SET status = 'published' WHERE published = 1")
|
|
29
|
+
|
|
30
|
+
// Everything already live stays live. A published post's publish_at was
|
|
31
|
+
// ignored until now, so a future value there was never a schedule anyone
|
|
32
|
+
// saw take effect; honouring it would make live posts vanish on deploy.
|
|
33
|
+
await db.exec('UPDATE posts SET publish_at = created_at WHERE published = 1')
|
|
34
|
+
|
|
35
|
+
await db.exec('CREATE INDEX idx_posts_status ON posts(status)')
|
|
36
|
+
await db.exec('CREATE INDEX idx_posts_deleted_at ON posts(deleted_at)')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const down = async (db) => {
|
|
40
|
+
await db.exec('DROP INDEX IF EXISTS idx_posts_deleted_at')
|
|
41
|
+
await db.exec('DROP INDEX IF EXISTS idx_posts_status')
|
|
42
|
+
await db.exec('ALTER TABLE posts DROP COLUMN live_notified')
|
|
43
|
+
await db.exec('ALTER TABLE posts DROP COLUMN deleted_at')
|
|
44
|
+
await db.exec('ALTER TABLE posts DROP COLUMN status')
|
|
45
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a post or page looks like when it is shared, and whether it is indexed.
|
|
3
|
+
*
|
|
4
|
+
* `meta_title` and `meta_description` cover the search result. A link shared
|
|
5
|
+
* to a social network reads Open Graph and Twitter card tags instead, and
|
|
6
|
+
* Ghost lets an editor set those separately for the same reason: the headline
|
|
7
|
+
* that works in a search result is rarely the one that works in a feed.
|
|
8
|
+
* Absent values fall back — og to meta to the title — in the content API, so
|
|
9
|
+
* nobody has to fill in six fields to get a card.
|
|
10
|
+
*
|
|
11
|
+
* `canonical_url` is for a post first published somewhere else. `noindex`
|
|
12
|
+
* keeps a post out of the sitemap and tells the front end to emit a robots
|
|
13
|
+
* meta tag.
|
|
14
|
+
*
|
|
15
|
+
* Images are foreign keys into `media`, as `featured_image` is.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const TABLES = ['posts', 'pages']
|
|
19
|
+
|
|
20
|
+
export const up = async (db) => {
|
|
21
|
+
for (const table of TABLES) {
|
|
22
|
+
await db.exec(`ALTER TABLE ${table} ADD COLUMN og_title TEXT`)
|
|
23
|
+
await db.exec(`ALTER TABLE ${table} ADD COLUMN og_description TEXT`)
|
|
24
|
+
await db.exec(`ALTER TABLE ${table} ADD COLUMN og_image INTEGER REFERENCES media(id)`)
|
|
25
|
+
await db.exec(`ALTER TABLE ${table} ADD COLUMN twitter_title TEXT`)
|
|
26
|
+
await db.exec(`ALTER TABLE ${table} ADD COLUMN twitter_description TEXT`)
|
|
27
|
+
await db.exec(`ALTER TABLE ${table} ADD COLUMN twitter_image INTEGER REFERENCES media(id)`)
|
|
28
|
+
await db.exec(`ALTER TABLE ${table} ADD COLUMN canonical_url TEXT`)
|
|
29
|
+
await db.exec(`ALTER TABLE ${table} ADD COLUMN noindex INTEGER NOT NULL DEFAULT 0`)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const down = async (db) => {
|
|
34
|
+
for (const table of TABLES) {
|
|
35
|
+
for (const column of ['noindex', 'canonical_url', 'twitter_image', 'twitter_description',
|
|
36
|
+
'twitter_title', 'og_image', 'og_description', 'og_title']) {
|
|
37
|
+
await db.exec(`ALTER TABLE ${table} DROP COLUMN ${column}`)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Revisions: what a post said before each save.
|
|
3
|
+
*
|
|
4
|
+
* Written on every update that changes the title, the body or the excerpt, so
|
|
5
|
+
* an editor can see what changed and put an older version back. `autosave`
|
|
6
|
+
* marks the rolling copy the editor writes while someone is typing — one per
|
|
7
|
+
* post and author, replaced each time, so autosaving does not bury the real
|
|
8
|
+
* history under a revision every thirty seconds.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const up = async (db, grammar) => {
|
|
12
|
+
await db.exec(`
|
|
13
|
+
CREATE TABLE post_revisions (
|
|
14
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
15
|
+
post_id INTEGER NOT NULL REFERENCES posts(id) ON DELETE CASCADE,
|
|
16
|
+
user_id INTEGER REFERENCES users(id) ON DELETE SET NULL,
|
|
17
|
+
title TEXT NOT NULL,
|
|
18
|
+
content TEXT NOT NULL,
|
|
19
|
+
excerpt TEXT,
|
|
20
|
+
autosave INTEGER NOT NULL DEFAULT 0,
|
|
21
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
22
|
+
)
|
|
23
|
+
`)
|
|
24
|
+
await db.exec('CREATE INDEX idx_post_revisions_post ON post_revisions(post_id, created_at)')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const down = async (db) => {
|
|
28
|
+
await db.exec('DROP TABLE IF EXISTS post_revisions')
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image dimensions.
|
|
3
|
+
*
|
|
4
|
+
* Without them a front end cannot reserve space for an image before it loads
|
|
5
|
+
* (the page jumps as it arrives), cannot emit `width`/`height` attributes, and
|
|
6
|
+
* cannot build a `srcset` without guessing which sizes are worth asking a CDN
|
|
7
|
+
* for. Read from the file's own header at upload; null for anything that is
|
|
8
|
+
* not an image, or was uploaded before this.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const up = async (db) => {
|
|
12
|
+
await db.exec('ALTER TABLE media ADD COLUMN width INTEGER')
|
|
13
|
+
await db.exec('ALTER TABLE media ADD COLUMN height INTEGER')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const down = async (db) => {
|
|
17
|
+
await db.exec('ALTER TABLE media DROP COLUMN height')
|
|
18
|
+
await db.exec('ALTER TABLE media DROP COLUMN width')
|
|
19
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navigation menus, edited in the admin rather than hard-coded in a theme.
|
|
3
|
+
*
|
|
4
|
+
* A menu is identified by its `location` — where the front end renders it:
|
|
5
|
+
* `primary` (the header), `secondary` and `footer` are created here so a front
|
|
6
|
+
* end can rely on them existing; an admin may add more. One menu per location,
|
|
7
|
+
* which is what makes `/api/v1/navigation` a lookup rather than a query.
|
|
8
|
+
*
|
|
9
|
+
* An item is either a URL or a link to a post, page or category by id
|
|
10
|
+
* (`target_type` + `target_id`). Linking by id is the point: rename the page
|
|
11
|
+
* and the menu follows it, unpublish it and the menu stops pointing at a 404.
|
|
12
|
+
* The public API resolves the id to the target's current path at read time.
|
|
13
|
+
*
|
|
14
|
+
* `parent_id` allows one level of nesting — a dropdown. Deeper trees are
|
|
15
|
+
* refused by the controller rather than the schema; most front ends cannot
|
|
16
|
+
* render a third level usefully.
|
|
17
|
+
*
|
|
18
|
+
* Booleans are INTEGER 0/1, as everywhere else here, so the same SQL runs on
|
|
19
|
+
* SQLite, libSQL and Postgres.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export const up = async (db, grammar) => {
|
|
23
|
+
await db.exec(`
|
|
24
|
+
CREATE TABLE menus (
|
|
25
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
26
|
+
location TEXT UNIQUE NOT NULL,
|
|
27
|
+
name TEXT NOT NULL,
|
|
28
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP,
|
|
29
|
+
updated_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
30
|
+
)
|
|
31
|
+
`)
|
|
32
|
+
|
|
33
|
+
await db.exec(`
|
|
34
|
+
CREATE TABLE menu_items (
|
|
35
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
36
|
+
menu_id INTEGER NOT NULL REFERENCES menus(id) ON DELETE CASCADE,
|
|
37
|
+
parent_id INTEGER REFERENCES menu_items(id) ON DELETE CASCADE,
|
|
38
|
+
label TEXT NOT NULL,
|
|
39
|
+
url TEXT,
|
|
40
|
+
target_type TEXT,
|
|
41
|
+
target_id INTEGER,
|
|
42
|
+
open_in_new_tab INTEGER NOT NULL DEFAULT 0,
|
|
43
|
+
sort_order INTEGER NOT NULL DEFAULT 0,
|
|
44
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP,
|
|
45
|
+
updated_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
46
|
+
)
|
|
47
|
+
`)
|
|
48
|
+
|
|
49
|
+
await db.exec('CREATE INDEX idx_menu_items_menu ON menu_items(menu_id, sort_order)')
|
|
50
|
+
await db.exec('CREATE INDEX idx_menu_items_parent ON menu_items(parent_id)')
|
|
51
|
+
// Finding the items that point at a piece of content.
|
|
52
|
+
await db.exec('CREATE INDEX idx_menu_items_target ON menu_items(target_type, target_id)')
|
|
53
|
+
|
|
54
|
+
await db.run(`
|
|
55
|
+
INSERT INTO menus (location, name) VALUES
|
|
56
|
+
('primary', 'Primary'),
|
|
57
|
+
('secondary', 'Secondary'),
|
|
58
|
+
('footer', 'Footer')
|
|
59
|
+
`)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const down = async (db, grammar) => {
|
|
63
|
+
await db.exec(grammar.dropTable('menu_items'))
|
|
64
|
+
await db.exec(grammar.dropTable('menus'))
|
|
65
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redirects: old URLs that should keep working.
|
|
3
|
+
*
|
|
4
|
+
* The CMS is headless, so it does not answer requests for `/blog/old-slug` —
|
|
5
|
+
* the front end does. What the CMS can do is keep the list: `/api/v1/redirects`
|
|
6
|
+
* hands it to the front end, which applies it (a build step writing a
|
|
7
|
+
* `_redirects` file, or edge middleware).
|
|
8
|
+
*
|
|
9
|
+
* Rows come from two places, told apart by `source`: an admin typing one in
|
|
10
|
+
* (`manual`), or a published post or page changing its slug (`post`, `page`),
|
|
11
|
+
* which records a 301 from the old path so links and search results already
|
|
12
|
+
* out in the world do not 404.
|
|
13
|
+
*
|
|
14
|
+
* `from_path` is stored normalised — leading slash, no trailing slash, no query
|
|
15
|
+
* — and is unique, so a path has exactly one destination. `hits` counts
|
|
16
|
+
* lookups made through `?path=`; a front end that applies the whole list
|
|
17
|
+
* itself cannot report back, so treat it as a lower bound.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export const up = async (db, grammar) => {
|
|
21
|
+
await db.exec(`
|
|
22
|
+
CREATE TABLE redirects (
|
|
23
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
24
|
+
from_path TEXT UNIQUE NOT NULL,
|
|
25
|
+
to_path TEXT NOT NULL,
|
|
26
|
+
status INTEGER NOT NULL DEFAULT 301,
|
|
27
|
+
source TEXT NOT NULL DEFAULT 'manual',
|
|
28
|
+
hits INTEGER NOT NULL DEFAULT 0,
|
|
29
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP,
|
|
30
|
+
updated_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
31
|
+
)
|
|
32
|
+
`)
|
|
33
|
+
|
|
34
|
+
// Chain collapsing looks rows up by destination.
|
|
35
|
+
await db.exec('CREATE INDEX idx_redirects_to_path ON redirects(to_path)')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const down = async (db, grammar) => {
|
|
39
|
+
await db.exec(grammar.dropTable('redirects'))
|
|
40
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comment moderation that can say "spam", and replies people can follow.
|
|
3
|
+
*
|
|
4
|
+
* `status` is the moderation state: `pending`, `approved`, `spam` or `trash`.
|
|
5
|
+
* One flag could only say approved or not, so spam sat in the same queue as
|
|
6
|
+
* the comments worth reading and deleting was the only way to clear it. The
|
|
7
|
+
* `approved` flag stays and is kept in step with it (`approved = 1` exactly
|
|
8
|
+
* when `status = 'approved'`), so anything already reading the flag still
|
|
9
|
+
* reads the truth — the same arrangement as posts' `published` and `status`.
|
|
10
|
+
*
|
|
11
|
+
* `held_reason` records why a check held a comment or called it spam
|
|
12
|
+
* ("honeypot", "links: 5"), so a moderator can tell a false positive from a
|
|
13
|
+
* bot at a glance, and tune the blocklist that caused it.
|
|
14
|
+
*
|
|
15
|
+
* `author_ip` is the commenter's address as the rate limiter sees it — IPv4,
|
|
16
|
+
* or an IPv6 /64 — for blocklisting a persistent spammer. Moderators only; it
|
|
17
|
+
* is never part of a public read.
|
|
18
|
+
*
|
|
19
|
+
* `notify_replies` is the commenter's opt-in to an email when someone replies.
|
|
20
|
+
* Off for every existing comment: nobody agreed to mail they never asked for.
|
|
21
|
+
*
|
|
22
|
+
* `reply_notified` is set on a reply once its parent's author has been told
|
|
23
|
+
* about it, so approving, unapproving and approving again sends one email.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export const up = async (db) => {
|
|
27
|
+
await db.exec("ALTER TABLE comments ADD COLUMN status TEXT NOT NULL DEFAULT 'pending'")
|
|
28
|
+
await db.exec('ALTER TABLE comments ADD COLUMN held_reason TEXT')
|
|
29
|
+
await db.exec('ALTER TABLE comments ADD COLUMN author_ip TEXT')
|
|
30
|
+
await db.exec('ALTER TABLE comments ADD COLUMN notify_replies INTEGER NOT NULL DEFAULT 0')
|
|
31
|
+
await db.exec('ALTER TABLE comments ADD COLUMN reply_notified INTEGER NOT NULL DEFAULT 0')
|
|
32
|
+
|
|
33
|
+
// Every approved comment stays approved; everything else was waiting for a
|
|
34
|
+
// moderator, which is what `pending` means.
|
|
35
|
+
await db.exec("UPDATE comments SET status = 'approved' WHERE approved = 1")
|
|
36
|
+
|
|
37
|
+
// Existing replies predate opt-in, so there is nobody to tell about them;
|
|
38
|
+
// marking them told keeps a later re-approval from mailing anyone.
|
|
39
|
+
await db.exec('UPDATE comments SET reply_notified = 1 WHERE parent_id IS NOT NULL')
|
|
40
|
+
|
|
41
|
+
await db.exec('CREATE INDEX idx_comments_status ON comments(status)')
|
|
42
|
+
await db.exec('CREATE INDEX idx_comments_post_status ON comments(post_id, status)')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const down = async (db) => {
|
|
46
|
+
await db.exec('DROP INDEX IF EXISTS idx_comments_post_status')
|
|
47
|
+
await db.exec('DROP INDEX IF EXISTS idx_comments_status')
|
|
48
|
+
await db.exec('ALTER TABLE comments DROP COLUMN reply_notified')
|
|
49
|
+
await db.exec('ALTER TABLE comments DROP COLUMN notify_replies')
|
|
50
|
+
await db.exec('ALTER TABLE comments DROP COLUMN author_ip')
|
|
51
|
+
await db.exec('ALTER TABLE comments DROP COLUMN held_reason')
|
|
52
|
+
await db.exec('ALTER TABLE comments DROP COLUMN status')
|
|
53
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit locks: who has a post open in the editor right now.
|
|
3
|
+
*
|
|
4
|
+
* A soft lock in the WordPress sense. Two people editing the same post used to
|
|
5
|
+
* mean the second save silently replaced the first; now the editor holds a
|
|
6
|
+
* lock while it is open, refreshes it on a heartbeat, and anyone else who opens
|
|
7
|
+
* the post is told who is in it and offered the chance to take over.
|
|
8
|
+
*
|
|
9
|
+
* A table of its own rather than two columns on `posts`:
|
|
10
|
+
*
|
|
11
|
+
* - A heartbeat every thirty seconds is a write, and on `posts` it would be a
|
|
12
|
+
* write to the row every public read and every listing reads, on a table
|
|
13
|
+
* other migrations keep altering. Here it is one narrow row.
|
|
14
|
+
* - `SELECT posts.*` is how several reads build a post. Lock columns there
|
|
15
|
+
* would ride along into every one of them, the public feed included, and
|
|
16
|
+
* hand out which account is editing what.
|
|
17
|
+
* - One row per post, keyed on the post, makes "take the lock if it is free
|
|
18
|
+
* or stale" a single conditional upsert rather than a read then a write.
|
|
19
|
+
*
|
|
20
|
+
* `locked_at` is the last heartbeat. A lock older than the expiry (two
|
|
21
|
+
* minutes, in src/models/PostLock.ts) is free for the taking — a closed laptop
|
|
22
|
+
* does not hold a post hostage. Expired rows are not cleaned up: there is at
|
|
23
|
+
* most one per post, and the next person to open it overwrites it.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export const up = async (db, grammar) => {
|
|
27
|
+
await db.exec(`
|
|
28
|
+
CREATE TABLE post_locks (
|
|
29
|
+
post_id INTEGER PRIMARY KEY REFERENCES posts(id) ON DELETE CASCADE,
|
|
30
|
+
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
31
|
+
locked_at ${grammar.timestampType()} NOT NULL
|
|
32
|
+
)
|
|
33
|
+
`)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const down = async (db) => {
|
|
37
|
+
await db.exec('DROP TABLE IF EXISTS post_locks')
|
|
38
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snippets: reusable pieces of Markdown.
|
|
3
|
+
*
|
|
4
|
+
* The newsletter sign-up line, the affiliate disclosure, the "this post is part
|
|
5
|
+
* of a series" box — text that gets pasted into post after post and then
|
|
6
|
+
* drifts, because each copy was edited by hand. A snippet is inserted into the
|
|
7
|
+
* post as text, not referenced: changing a snippet later does not rewrite the
|
|
8
|
+
* posts that already used it, which is what you want from a published archive.
|
|
9
|
+
*
|
|
10
|
+
* `created_by` is the owner, for the rule that anyone who writes may use every
|
|
11
|
+
* snippet but only an editor may change someone else's. Nullable and SET NULL
|
|
12
|
+
* so deleting an account keeps the snippets it wrote for everyone else.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const up = async (db, grammar) => {
|
|
16
|
+
await db.exec(`
|
|
17
|
+
CREATE TABLE snippets (
|
|
18
|
+
id ${grammar.autoIncrementPrimaryKey()},
|
|
19
|
+
name TEXT NOT NULL,
|
|
20
|
+
content TEXT NOT NULL,
|
|
21
|
+
created_by INTEGER REFERENCES users(id) ON DELETE SET NULL,
|
|
22
|
+
created_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP,
|
|
23
|
+
updated_at ${grammar.timestampType()} DEFAULT CURRENT_TIMESTAMP
|
|
24
|
+
)
|
|
25
|
+
`)
|
|
26
|
+
await db.exec('CREATE INDEX idx_snippets_name ON snippets(name)')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const down = async (db) => {
|
|
30
|
+
await db.exec('DROP TABLE IF EXISTS snippets')
|
|
31
|
+
}
|