@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,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The full-content export: everything a site is, in one JSON document.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the admin download (`GET /api/export`) and `basicben-cms export`,
|
|
5
|
+
* and read back by `basicben-cms import:json`. The format is documented in
|
|
6
|
+
* `docs/import-export.md`; bump `EXPORT_VERSION` for any change an older
|
|
7
|
+
* importer would misread, and teach the importer the old shape before doing so.
|
|
8
|
+
*
|
|
9
|
+
* ## Why this file imports (almost) nothing
|
|
10
|
+
*
|
|
11
|
+
* The scripts are plain Node, and loading this should not load the app with
|
|
12
|
+
* it. Taking the database handle as an argument, rather than calling
|
|
13
|
+
* `getDb()`, keeps this file loadable from both sides and lets the tests hand
|
|
14
|
+
* it an in-memory database.
|
|
15
|
+
*
|
|
16
|
+
* ## What is left out, and why it is an allowlist
|
|
17
|
+
*
|
|
18
|
+
* Tables are exported only if they are named below. A table added later is
|
|
19
|
+
* reported under `omitted.tables` rather than exported, because the tables
|
|
20
|
+
* that must never leave the database — hashed credentials, TOTP secrets,
|
|
21
|
+
* passkeys, rate-limiter state — are exactly the kind a blocklist forgets the
|
|
22
|
+
* day someone adds another one. An export is a file people email to each
|
|
23
|
+
* other; it should contain content, not ways in.
|
|
24
|
+
*/
|
|
25
|
+
/** Identifies the document, so an importer can refuse something else. */
|
|
26
|
+
export declare const EXPORT_FORMAT = "basicben-export";
|
|
27
|
+
/** Bumped for any change an older importer would misread. */
|
|
28
|
+
export declare const EXPORT_VERSION = 1;
|
|
29
|
+
/** The handle both the app's adapter and the scripts' adapter satisfy. */
|
|
30
|
+
export interface ExportDb {
|
|
31
|
+
driver?: string;
|
|
32
|
+
all: (sql: string, params?: unknown[]) => unknown;
|
|
33
|
+
get: (sql: string, params?: unknown[]) => unknown;
|
|
34
|
+
}
|
|
35
|
+
interface TableSpec {
|
|
36
|
+
name: string;
|
|
37
|
+
/** Columns never written out, whatever the table holds. */
|
|
38
|
+
omit?: string[];
|
|
39
|
+
/** Only exported when the caller asks for it. */
|
|
40
|
+
optional?: 'revisions';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Exported tables, in dependency order: a row only ever refers to rows in
|
|
44
|
+
* tables listed before it (or to its own table), so an importer reading
|
|
45
|
+
* top to bottom can remap every id as it goes.
|
|
46
|
+
*
|
|
47
|
+
* `menus`, `menu_items`, `redirects` and `snippets` belong to features that may not be
|
|
48
|
+
* installed; a table that does not exist is simply absent from the output.
|
|
49
|
+
*/
|
|
50
|
+
export declare const EXPORT_TABLES: TableSpec[];
|
|
51
|
+
/**
|
|
52
|
+
* Tables known to hold secrets or per-database state. Listed so the
|
|
53
|
+
* `omitted` report can say *why* they are missing rather than leaving an
|
|
54
|
+
* operator to wonder whether the export is incomplete.
|
|
55
|
+
*/
|
|
56
|
+
export declare const NEVER_EXPORTED: string[];
|
|
57
|
+
export declare function isSecretSetting(key: unknown): boolean;
|
|
58
|
+
/** Every table in the database, so the export can report what it left out. */
|
|
59
|
+
export declare function listTables(db: ExportDb): Promise<string[]>;
|
|
60
|
+
/**
|
|
61
|
+
* A table's columns, or an empty list if it does not exist.
|
|
62
|
+
*
|
|
63
|
+
* Asked of the catalogue rather than of a `SELECT *`, which returns no column
|
|
64
|
+
* names at all on an empty SQLite table.
|
|
65
|
+
*/
|
|
66
|
+
export declare function columnsOf(db: ExportDb, table: string): Promise<string[]>;
|
|
67
|
+
export interface ExportOptions {
|
|
68
|
+
/** Include `post_revisions`. Off by default. */
|
|
69
|
+
revisions?: boolean;
|
|
70
|
+
/** Rows read per query, so a large table is never held whole. */
|
|
71
|
+
pageSize?: number;
|
|
72
|
+
/** Stamped into the document; defaults to now. */
|
|
73
|
+
now?: Date;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The export as a sequence of JSON fragments.
|
|
77
|
+
*
|
|
78
|
+
* Yielded in pieces so the endpoint can stream a large site to the client
|
|
79
|
+
* without building the whole document in memory, and the script can write it
|
|
80
|
+
* to a file the same way. Joined, the fragments are one valid JSON document.
|
|
81
|
+
*/
|
|
82
|
+
export declare function exportChunks(db: ExportDb, options?: ExportOptions): AsyncGenerator<string>;
|
|
83
|
+
/** The whole export as a string. For tests and small sites. */
|
|
84
|
+
export declare function exportToString(db: ExportDb, options?: ExportOptions): Promise<string>;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The full-content export: everything a site is, in one JSON document.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the admin download (`GET /api/export`) and `basicben-cms export`,
|
|
5
|
+
* and read back by `basicben-cms import:json`. The format is documented in
|
|
6
|
+
* `docs/import-export.md`; bump `EXPORT_VERSION` for any change an older
|
|
7
|
+
* importer would misread, and teach the importer the old shape before doing so.
|
|
8
|
+
*
|
|
9
|
+
* ## Why this file imports (almost) nothing
|
|
10
|
+
*
|
|
11
|
+
* The scripts are plain Node, and loading this should not load the app with
|
|
12
|
+
* it. Taking the database handle as an argument, rather than calling
|
|
13
|
+
* `getDb()`, keeps this file loadable from both sides and lets the tests hand
|
|
14
|
+
* it an in-memory database.
|
|
15
|
+
*
|
|
16
|
+
* ## What is left out, and why it is an allowlist
|
|
17
|
+
*
|
|
18
|
+
* Tables are exported only if they are named below. A table added later is
|
|
19
|
+
* reported under `omitted.tables` rather than exported, because the tables
|
|
20
|
+
* that must never leave the database — hashed credentials, TOTP secrets,
|
|
21
|
+
* passkeys, rate-limiter state — are exactly the kind a blocklist forgets the
|
|
22
|
+
* day someone adds another one. An export is a file people email to each
|
|
23
|
+
* other; it should contain content, not ways in.
|
|
24
|
+
*/
|
|
25
|
+
// The one import: the features' manifests, which are static data and import
|
|
26
|
+
// nothing at runtime themselves, so plain Node still loads this file.
|
|
27
|
+
//
|
|
28
|
+
// Every feature's, not only the enabled ones: every site runs every feature's
|
|
29
|
+
// migrations, so the tables exist either way, and an export of a site that
|
|
30
|
+
// turned a feature off still carries what the feature left behind.
|
|
31
|
+
import manifests from "../features.manifest.js";
|
|
32
|
+
const features = Object.values(manifests);
|
|
33
|
+
/** Identifies the document, so an importer can refuse something else. */
|
|
34
|
+
export const EXPORT_FORMAT = 'basicben-export';
|
|
35
|
+
/** Bumped for any change an older importer would misread. */
|
|
36
|
+
export const EXPORT_VERSION = 1;
|
|
37
|
+
/**
|
|
38
|
+
* Exported tables, in dependency order: a row only ever refers to rows in
|
|
39
|
+
* tables listed before it (or to its own table), so an importer reading
|
|
40
|
+
* top to bottom can remap every id as it goes.
|
|
41
|
+
*
|
|
42
|
+
* `menus`, `menu_items`, `redirects` and `snippets` belong to features that may not be
|
|
43
|
+
* installed; a table that does not exist is simply absent from the output.
|
|
44
|
+
*/
|
|
45
|
+
export const EXPORT_TABLES = [
|
|
46
|
+
// The password hash is a credential, and `token_version` is session state
|
|
47
|
+
// that means nothing in another database. Imported users reset a password.
|
|
48
|
+
{ name: 'users', omit: ['password', 'token_version'] },
|
|
49
|
+
{ name: 'media' },
|
|
50
|
+
{ name: 'categories' },
|
|
51
|
+
{ name: 'tags' },
|
|
52
|
+
{ name: 'posts' },
|
|
53
|
+
{ name: 'post_categories' },
|
|
54
|
+
{ name: 'post_tags' },
|
|
55
|
+
// Revisions can be most of a database's size, and most moves do not need
|
|
56
|
+
// them, so they are opt-in.
|
|
57
|
+
{ name: 'post_revisions', optional: 'revisions' },
|
|
58
|
+
{ name: 'pages' },
|
|
59
|
+
// The commenter's address is a spam signal for this install, and personal
|
|
60
|
+
// data an export file has no business carrying around.
|
|
61
|
+
{ name: 'comments', omit: ['author_ip'] },
|
|
62
|
+
{ name: 'settings' },
|
|
63
|
+
{ name: 'menus' },
|
|
64
|
+
{ name: 'menu_items' },
|
|
65
|
+
{ name: 'redirects' },
|
|
66
|
+
{ name: 'snippets' },
|
|
67
|
+
// Each feature's own, from its manifest, after core's: a feature's rows may
|
|
68
|
+
// refer to core's, never the other way round.
|
|
69
|
+
...features.flatMap((feature) => feature.exportTables ?? [])
|
|
70
|
+
];
|
|
71
|
+
/**
|
|
72
|
+
* Tables known to hold secrets or per-database state. Listed so the
|
|
73
|
+
* `omitted` report can say *why* they are missing rather than leaving an
|
|
74
|
+
* operator to wonder whether the export is incomplete.
|
|
75
|
+
*/
|
|
76
|
+
export const NEVER_EXPORTED = [
|
|
77
|
+
'auth_tokens',
|
|
78
|
+
'user_two_factor',
|
|
79
|
+
'user_credentials',
|
|
80
|
+
'api_tokens',
|
|
81
|
+
'rate_limits',
|
|
82
|
+
// Who has a post open right now: meaningless anywhere else.
|
|
83
|
+
'post_locks',
|
|
84
|
+
// When background jobs last ran here. True of this database only.
|
|
85
|
+
'ops_heartbeats',
|
|
86
|
+
'_migrations',
|
|
87
|
+
'sqlite_sequence',
|
|
88
|
+
// Each feature's own, from its manifest.
|
|
89
|
+
...features.flatMap((feature) => feature.neverExported ?? [])
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* Setting keys that look like credentials.
|
|
93
|
+
*
|
|
94
|
+
* Settings are free-form key/value, so a plugin can store an API key there.
|
|
95
|
+
* Matching on the name is a heuristic, which is why matching keys are listed
|
|
96
|
+
* under `omitted.settings` — a false positive costs a setting re-entered by
|
|
97
|
+
* hand, a false negative would put a key in a file.
|
|
98
|
+
*/
|
|
99
|
+
const SECRET_SETTING = /(secret|password|passwd|token|api[_-]?key|private[_-]?key|credential|smtp_pass)/i;
|
|
100
|
+
export function isSecretSetting(key) {
|
|
101
|
+
return SECRET_SETTING.test(String(key ?? ''));
|
|
102
|
+
}
|
|
103
|
+
/** Identifiers are interpolated, so anything that is not a plain name is refused. */
|
|
104
|
+
function ident(name) {
|
|
105
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name))
|
|
106
|
+
throw new Error(`Refusing identifier: ${name}`);
|
|
107
|
+
return `"${name}"`;
|
|
108
|
+
}
|
|
109
|
+
const isPostgres = (db) => db.driver === 'postgres' || db.driver === 'pg';
|
|
110
|
+
/** Every table in the database, so the export can report what it left out. */
|
|
111
|
+
export async function listTables(db) {
|
|
112
|
+
const rows = (await db.all(isPostgres(db)
|
|
113
|
+
? 'SELECT table_name AS name FROM information_schema.tables WHERE table_schema = current_schema()'
|
|
114
|
+
: "SELECT name FROM sqlite_master WHERE type = 'table'"));
|
|
115
|
+
return rows.map((row) => String(row.name));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A table's columns, or an empty list if it does not exist.
|
|
119
|
+
*
|
|
120
|
+
* Asked of the catalogue rather than of a `SELECT *`, which returns no column
|
|
121
|
+
* names at all on an empty SQLite table.
|
|
122
|
+
*/
|
|
123
|
+
export async function columnsOf(db, table) {
|
|
124
|
+
ident(table);
|
|
125
|
+
const rows = (await db.all(isPostgres(db)
|
|
126
|
+
? 'SELECT column_name AS name FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = ? ORDER BY ordinal_position'
|
|
127
|
+
: `PRAGMA table_info(${ident(table)})`, isPostgres(db) ? [table] : []));
|
|
128
|
+
return rows.map((row) => String(row.name));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The export as a sequence of JSON fragments.
|
|
132
|
+
*
|
|
133
|
+
* Yielded in pieces so the endpoint can stream a large site to the client
|
|
134
|
+
* without building the whole document in memory, and the script can write it
|
|
135
|
+
* to a file the same way. Joined, the fragments are one valid JSON document.
|
|
136
|
+
*/
|
|
137
|
+
export async function* exportChunks(db, options = {}) {
|
|
138
|
+
const pageSize = options.pageSize ?? 500;
|
|
139
|
+
const present = new Set(await listTables(db));
|
|
140
|
+
const omittedColumns = {};
|
|
141
|
+
const omittedSettings = [];
|
|
142
|
+
const counts = {};
|
|
143
|
+
yield `{"format":${JSON.stringify(EXPORT_FORMAT)},"version":${EXPORT_VERSION}` +
|
|
144
|
+
`,"exported_at":${JSON.stringify((options.now ?? new Date()).toISOString())}` +
|
|
145
|
+
`,"driver":${JSON.stringify(db.driver ?? 'sqlite')}` +
|
|
146
|
+
`,"options":${JSON.stringify({ revisions: Boolean(options.revisions) })}` +
|
|
147
|
+
',"tables":{';
|
|
148
|
+
let firstTable = true;
|
|
149
|
+
for (const spec of EXPORT_TABLES) {
|
|
150
|
+
if (!present.has(spec.name))
|
|
151
|
+
continue;
|
|
152
|
+
if (spec.optional === 'revisions' && !options.revisions)
|
|
153
|
+
continue;
|
|
154
|
+
const columns = await columnsOf(db, spec.name);
|
|
155
|
+
const omit = new Set(spec.omit ?? []);
|
|
156
|
+
const kept = columns.filter((column) => !omit.has(column));
|
|
157
|
+
const dropped = columns.filter((column) => omit.has(column));
|
|
158
|
+
if (dropped.length)
|
|
159
|
+
omittedColumns[spec.name] = dropped;
|
|
160
|
+
// Paging needs a stable order, and join tables have no id: ordering by
|
|
161
|
+
// every column is stable for them because the row *is* its key.
|
|
162
|
+
const order = columns.includes('id') ? ident('id') : columns.map(ident).join(', ');
|
|
163
|
+
const select = kept.map(ident).join(', ');
|
|
164
|
+
yield `${firstTable ? '' : ','}${JSON.stringify(spec.name)}:[`;
|
|
165
|
+
firstTable = false;
|
|
166
|
+
let firstRow = true;
|
|
167
|
+
let count = 0;
|
|
168
|
+
for (let offset = 0;; offset += pageSize) {
|
|
169
|
+
const rows = (await db.all(`SELECT ${select} FROM ${ident(spec.name)} ORDER BY ${order} LIMIT ? OFFSET ?`, [pageSize, offset]));
|
|
170
|
+
for (const row of rows) {
|
|
171
|
+
if (spec.name === 'settings' && isSecretSetting(row.key)) {
|
|
172
|
+
omittedSettings.push(String(row.key));
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
yield `${firstRow ? '' : ','}${JSON.stringify(plain(row))}`;
|
|
176
|
+
firstRow = false;
|
|
177
|
+
count++;
|
|
178
|
+
}
|
|
179
|
+
if (rows.length < pageSize)
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
counts[spec.name] = count;
|
|
183
|
+
yield ']';
|
|
184
|
+
}
|
|
185
|
+
const exported = new Set(EXPORT_TABLES.map((spec) => spec.name));
|
|
186
|
+
const omittedTables = [...present]
|
|
187
|
+
.filter((name) => !exported.has(name) || (name === 'post_revisions' && !options.revisions))
|
|
188
|
+
.sort()
|
|
189
|
+
.map((name) => ({
|
|
190
|
+
name,
|
|
191
|
+
reason: NEVER_EXPORTED.includes(name)
|
|
192
|
+
? 'credentials or per-database state'
|
|
193
|
+
: name === 'post_revisions'
|
|
194
|
+
? 'revisions not requested'
|
|
195
|
+
: 'not a table this export knows; nothing in it was exported'
|
|
196
|
+
}));
|
|
197
|
+
yield '},"counts":' + JSON.stringify(counts) +
|
|
198
|
+
',"omitted":' + JSON.stringify({
|
|
199
|
+
tables: omittedTables,
|
|
200
|
+
columns: omittedColumns,
|
|
201
|
+
settings: omittedSettings
|
|
202
|
+
}) +
|
|
203
|
+
'}';
|
|
204
|
+
}
|
|
205
|
+
/** The whole export as a string. For tests and small sites. */
|
|
206
|
+
export async function exportToString(db, options = {}) {
|
|
207
|
+
let out = '';
|
|
208
|
+
for await (const chunk of exportChunks(db, options))
|
|
209
|
+
out += chunk;
|
|
210
|
+
return out;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* A row as plain JSON values.
|
|
214
|
+
*
|
|
215
|
+
* SQLite can hand back BigInt for large integers and Postgres hands back Date
|
|
216
|
+
* objects; neither survives `JSON.stringify` the way a reader expects.
|
|
217
|
+
*/
|
|
218
|
+
function plain(row) {
|
|
219
|
+
const out = {};
|
|
220
|
+
for (const [key, value] of Object.entries(row)) {
|
|
221
|
+
if (typeof value === 'bigint')
|
|
222
|
+
out[key] = Number(value);
|
|
223
|
+
else if (value instanceof Date)
|
|
224
|
+
out[key] = value.toISOString();
|
|
225
|
+
else
|
|
226
|
+
out[key] = value;
|
|
227
|
+
}
|
|
228
|
+
return out;
|
|
229
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restricted posts: which ones are gated, and what a reader without access
|
|
3
|
+
* gets instead of the body.
|
|
4
|
+
*
|
|
5
|
+
* The rule in one place, for the same reason `livePost` is in one place: the
|
|
6
|
+
* content API, the feeds and the built-in blog all serve post bodies, and a
|
|
7
|
+
* second copy of "is this gated?" is the copy that forgets a level. What a
|
|
8
|
+
* level means is the access policy's business (helpers/access.ts); what
|
|
9
|
+
* withholding removes is decided here.
|
|
10
|
+
*
|
|
11
|
+
* `viewer` below is what `viewerOf(req)` returned: null for an anonymous
|
|
12
|
+
* reader.
|
|
13
|
+
*
|
|
14
|
+
* No database access, so tests import it directly.
|
|
15
|
+
*/
|
|
16
|
+
import { visibilityOf } from './access.ts';
|
|
17
|
+
export { visibilityOf };
|
|
18
|
+
/** Does reading this post's body need more than an anonymous visit? */
|
|
19
|
+
export declare function isGated(visibility: unknown): boolean;
|
|
20
|
+
/** Whether *this reader* may have the body of a post with this visibility. */
|
|
21
|
+
export declare function mayReadBody(visibility: unknown, viewer: unknown): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* A post row with its body removed, for a reader who may not have it.
|
|
24
|
+
*
|
|
25
|
+
* Both columns, always: the Markdown source is the body just as much as the
|
|
26
|
+
* render is, and a surface that blanked one and forgot the other would leak
|
|
27
|
+
* the post in whichever format it forgot. Everything else — title, excerpt,
|
|
28
|
+
* image, dates — stays, because a listing of what members get is the point.
|
|
29
|
+
*/
|
|
30
|
+
export declare function withholdBody<T extends Record<string, unknown>>(row: T, viewer: unknown): T & {
|
|
31
|
+
gated: boolean;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The excerpt a reader who may not have the body is allowed to see.
|
|
35
|
+
*
|
|
36
|
+
* An automatic excerpt is the first 200 characters of the body, which on a
|
|
37
|
+
* short post *is* the body: withholding `content` and publishing the excerpt
|
|
38
|
+
* would gate nothing. So a gated post keeps its excerpt only when the excerpt
|
|
39
|
+
* is shorter than the body's text — a teaser, the way every membership site
|
|
40
|
+
* shows one. A typed excerpt that differs from the body is always kept.
|
|
41
|
+
*
|
|
42
|
+
* Whitespace is collapsed before comparing because the derived excerpt is.
|
|
43
|
+
*/
|
|
44
|
+
export declare function publicExcerpt(excerpt: string | null | undefined, bodyText: string | null | undefined, visibility: unknown, viewer: unknown): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* The body a feed item gets for a gated post: the excerpt and a pointer.
|
|
47
|
+
*
|
|
48
|
+
* Feeds are public documents, fetched by readers and aggregators that hold no
|
|
49
|
+
* session, so a gated post's feed entry can never carry the body. It still
|
|
50
|
+
* appears — a feed that silently skipped members-only posts would hide from
|
|
51
|
+
* subscribers that there was anything to sign in for.
|
|
52
|
+
*/
|
|
53
|
+
export declare function gatedFeedHtml(excerpt: string | null | undefined, link?: string): string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restricted posts: which ones are gated, and what a reader without access
|
|
3
|
+
* gets instead of the body.
|
|
4
|
+
*
|
|
5
|
+
* The rule in one place, for the same reason `livePost` is in one place: the
|
|
6
|
+
* content API, the feeds and the built-in blog all serve post bodies, and a
|
|
7
|
+
* second copy of "is this gated?" is the copy that forgets a level. What a
|
|
8
|
+
* level means is the access policy's business (helpers/access.ts); what
|
|
9
|
+
* withholding removes is decided here.
|
|
10
|
+
*
|
|
11
|
+
* `viewer` below is what `viewerOf(req)` returned: null for an anonymous
|
|
12
|
+
* reader.
|
|
13
|
+
*
|
|
14
|
+
* No database access, so tests import it directly.
|
|
15
|
+
*/
|
|
16
|
+
import { isRestricted, mayRead, visibilityOf } from "./access.js";
|
|
17
|
+
export { visibilityOf };
|
|
18
|
+
/** Does reading this post's body need more than an anonymous visit? */
|
|
19
|
+
export function isGated(visibility) {
|
|
20
|
+
return isRestricted(visibility);
|
|
21
|
+
}
|
|
22
|
+
/** Whether *this reader* may have the body of a post with this visibility. */
|
|
23
|
+
export function mayReadBody(visibility, viewer) {
|
|
24
|
+
return mayRead({ visibility }, viewer);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A post row with its body removed, for a reader who may not have it.
|
|
28
|
+
*
|
|
29
|
+
* Both columns, always: the Markdown source is the body just as much as the
|
|
30
|
+
* render is, and a surface that blanked one and forgot the other would leak
|
|
31
|
+
* the post in whichever format it forgot. Everything else — title, excerpt,
|
|
32
|
+
* image, dates — stays, because a listing of what members get is the point.
|
|
33
|
+
*/
|
|
34
|
+
export function withholdBody(row, viewer) {
|
|
35
|
+
if (mayRead(row, viewer))
|
|
36
|
+
return { ...row, gated: false };
|
|
37
|
+
// `content_html` is the render, so its text is the body's text. Stripped
|
|
38
|
+
// crudely here — this file stays free of imports — which only has to be
|
|
39
|
+
// good enough to tell a teaser from the whole post.
|
|
40
|
+
const html = String(row.content_html ?? row.content ?? '');
|
|
41
|
+
const text = html.replace(/<[^>]*>/g, ' ').replace(/ /g, ' ').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'");
|
|
42
|
+
const excerpt = publicExcerpt(row.excerpt, text, row.visibility, viewer);
|
|
43
|
+
return { ...row, ...('excerpt' in row ? { excerpt } : {}), content: null, content_html: null, gated: true };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The excerpt a reader who may not have the body is allowed to see.
|
|
47
|
+
*
|
|
48
|
+
* An automatic excerpt is the first 200 characters of the body, which on a
|
|
49
|
+
* short post *is* the body: withholding `content` and publishing the excerpt
|
|
50
|
+
* would gate nothing. So a gated post keeps its excerpt only when the excerpt
|
|
51
|
+
* is shorter than the body's text — a teaser, the way every membership site
|
|
52
|
+
* shows one. A typed excerpt that differs from the body is always kept.
|
|
53
|
+
*
|
|
54
|
+
* Whitespace is collapsed before comparing because the derived excerpt is.
|
|
55
|
+
*/
|
|
56
|
+
export function publicExcerpt(excerpt, bodyText, visibility, viewer) {
|
|
57
|
+
if (!excerpt)
|
|
58
|
+
return excerpt ?? null;
|
|
59
|
+
if (mayReadBody(visibility, viewer))
|
|
60
|
+
return excerpt;
|
|
61
|
+
const squash = (value) => value.replace(/\s+/g, ' ').trim().replace(/(\.\.\.|…)$/, '').trim();
|
|
62
|
+
const text = squash(bodyText ?? '');
|
|
63
|
+
const summary = squash(excerpt);
|
|
64
|
+
return summary.length >= text.length || text === summary ? null : excerpt;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The body a feed item gets for a gated post: the excerpt and a pointer.
|
|
68
|
+
*
|
|
69
|
+
* Feeds are public documents, fetched by readers and aggregators that hold no
|
|
70
|
+
* session, so a gated post's feed entry can never carry the body. It still
|
|
71
|
+
* appears — a feed that silently skipped members-only posts would hide from
|
|
72
|
+
* subscribers that there was anything to sign in for.
|
|
73
|
+
*/
|
|
74
|
+
export function gatedFeedHtml(excerpt, link) {
|
|
75
|
+
const escape = (value) => value
|
|
76
|
+
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
77
|
+
.replace(/"/g, '"').replace(/'/g, ''');
|
|
78
|
+
const summary = excerpt ? `<p>${escape(excerpt)}</p>` : '';
|
|
79
|
+
// The item's own link already points at the post; one in the body is a
|
|
80
|
+
// convenience for readers that hide it.
|
|
81
|
+
const notice = 'This post is for members. Sign in on the site to read it.';
|
|
82
|
+
return `${summary}<p>${link ? `<a href="${escape(link)}">${notice}</a>` : notice}</p>`;
|
|
83
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Site health: is this deployment configured the way production needs?
|
|
3
|
+
*
|
|
4
|
+
* Two halves. `gatherFacts` reads the database and the filesystem; the
|
|
5
|
+
* `evaluateHealth` half is a pure function from those facts (and the
|
|
6
|
+
* environment) to a list of checks, each pass / warn / fail with a fix. The
|
|
7
|
+
* split is what lets every rule be tested with a plain object, and keeps the
|
|
8
|
+
* one rule that matters most — **never echo a secret** — in a single place:
|
|
9
|
+
* secrets reach `evaluateHealth` only as the environment, and every check
|
|
10
|
+
* about one reports presence and length, never the value. Connection strings
|
|
11
|
+
* are summarised to a driver name for the same reason: a DATABASE_URL carries
|
|
12
|
+
* its password.
|
|
13
|
+
*
|
|
14
|
+
* Imports nothing outside `node:` so the tests (and a future CLI) can load it
|
|
15
|
+
* directly.
|
|
16
|
+
*/
|
|
17
|
+
export type HealthStatus = 'pass' | 'warn' | 'fail';
|
|
18
|
+
export interface HealthCheck {
|
|
19
|
+
id: string;
|
|
20
|
+
label: string;
|
|
21
|
+
status: HealthStatus;
|
|
22
|
+
/** What was found, for a person. Never a secret value. */
|
|
23
|
+
message: string;
|
|
24
|
+
/** What to do about it. Empty when nothing needs doing. */
|
|
25
|
+
hint: string;
|
|
26
|
+
}
|
|
27
|
+
export interface HealthFacts {
|
|
28
|
+
nodeVersion: string;
|
|
29
|
+
frameworkVersion: string | null;
|
|
30
|
+
dbDriver: string;
|
|
31
|
+
/** Migration files this deployment can see, or null when the directory is not shipped. */
|
|
32
|
+
migrationFiles: string[] | null;
|
|
33
|
+
/** Migrations recorded as run in `_migrations`. */
|
|
34
|
+
migrationsRan: string[];
|
|
35
|
+
storageDriver: string;
|
|
36
|
+
/** A transport name (`console`, `smtp`, `resend`, `http`), or `custom` for a function. */
|
|
37
|
+
mailTransport: string;
|
|
38
|
+
mailFrom: string | null;
|
|
39
|
+
settings: {
|
|
40
|
+
public_api?: string;
|
|
41
|
+
webhook_urls?: string;
|
|
42
|
+
};
|
|
43
|
+
heartbeats: Record<string, {
|
|
44
|
+
last_run_at: string;
|
|
45
|
+
detail: Record<string, unknown> | null;
|
|
46
|
+
}>;
|
|
47
|
+
/** Scheduled posts that are live but have not been announced. */
|
|
48
|
+
dueUnannounced: number;
|
|
49
|
+
rateLimitRows: number | null;
|
|
50
|
+
adminsTotal: number;
|
|
51
|
+
/** Active admin accounts with no TOTP second factor. */
|
|
52
|
+
adminsWithout2fa: number;
|
|
53
|
+
}
|
|
54
|
+
/** A serverless platform: read-only disk, no long-running process. */
|
|
55
|
+
export declare function isServerless(env: Record<string, string | undefined>): boolean;
|
|
56
|
+
export declare function check(id: string, label: string, status: HealthStatus, message: string, hint?: string): HealthCheck;
|
|
57
|
+
/** "3 minutes ago", for heartbeats. */
|
|
58
|
+
export declare function ago(iso: string, now: Date): string;
|
|
59
|
+
/** Pending migrations: files present that `_migrations` has no row for. */
|
|
60
|
+
export declare function pendingMigrations(files: string[], ran: string[]): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Every check, worst first is the caller's business; this returns them in a
|
|
63
|
+
* fixed order so the page does not shuffle between loads.
|
|
64
|
+
*/
|
|
65
|
+
export declare function evaluateHealth(env: Record<string, string | undefined>, facts: HealthFacts, now?: Date): HealthCheck[];
|
|
66
|
+
/** The worst status in a list: what the page's banner shows. */
|
|
67
|
+
export declare function overallStatus(checks: HealthCheck[]): HealthStatus;
|
|
68
|
+
/**
|
|
69
|
+
* Migration names in the migrator's directories, as it names them: the
|
|
70
|
+
* config's `migrations` list (defineSite sets the CMS's, then the site's), or
|
|
71
|
+
* one directory. Null when none can be read, which is a deployment that does
|
|
72
|
+
* not ship them; a missing site directory alongside the CMS's is just empty.
|
|
73
|
+
*/
|
|
74
|
+
export declare function migrationFilesIn(dirs: string | string[]): string[] | null;
|
|
75
|
+
interface FactsDb {
|
|
76
|
+
driver?: string;
|
|
77
|
+
get: (sql: string, params?: unknown[]) => any;
|
|
78
|
+
all: (sql: string, params?: unknown[]) => any;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The database-side facts. Every query tolerates a missing table — a health
|
|
82
|
+
* page that 500s on an unmigrated database is no help diagnosing one.
|
|
83
|
+
*/
|
|
84
|
+
export declare function databaseFacts(db: FactsDb, now?: Date): Promise<{
|
|
85
|
+
migrationsRan: string[];
|
|
86
|
+
settings: Record<string, string>;
|
|
87
|
+
rateLimitRows: number | null;
|
|
88
|
+
adminsTotal: number;
|
|
89
|
+
adminsWithout2fa: number;
|
|
90
|
+
}>;
|
|
91
|
+
export {};
|