@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,218 @@
|
|
|
1
|
+
import { SEO_COLUMNS } from "../helpers/seo-fields.js";
|
|
2
|
+
import { getDb, query } from '@basicbenframework/core/db';
|
|
3
|
+
import { hooks, HOOKS } from '@basicbenframework/core/hooks';
|
|
4
|
+
import { renderContent } from '@basicbenframework/core/content';
|
|
5
|
+
import { getStorage } from '@basicbenframework/core/storage';
|
|
6
|
+
import { uniqueSlug } from "./derive.js";
|
|
7
|
+
/**
|
|
8
|
+
* Columns `update()` will write.
|
|
9
|
+
*
|
|
10
|
+
* The clause used to be built from whatever keys arrived, so a key that was not
|
|
11
|
+
* a column — or was a column nobody meant to expose — went into the SQL.
|
|
12
|
+
*/
|
|
13
|
+
const UPDATABLE = [
|
|
14
|
+
'title', 'slug', 'content', 'content_html', 'featured_image', 'template',
|
|
15
|
+
'published', 'parent_id', 'menu_order', 'meta_title', 'meta_description',
|
|
16
|
+
'updated_at', ...SEO_COLUMNS
|
|
17
|
+
];
|
|
18
|
+
export const Page = {
|
|
19
|
+
/**
|
|
20
|
+
* One page of pages, with the total so a caller can size the pager.
|
|
21
|
+
*
|
|
22
|
+
* Counted separately rather than with a window function: the drivers do not
|
|
23
|
+
* agree on those, and this runs on all of them.
|
|
24
|
+
*/
|
|
25
|
+
async paginate({ perPage, offset }) {
|
|
26
|
+
const db = await getDb();
|
|
27
|
+
// `id` breaks ties. `created_at` alone is not a total order — these rows
|
|
28
|
+
// are written in the same second all the time — and an unspecified order
|
|
29
|
+
// is merely untidy until you paginate it, at which point LIMIT/OFFSET can
|
|
30
|
+
// return a row on two pages and never return another. SQLite happens to be
|
|
31
|
+
// stable here; Postgres is under no obligation to be.
|
|
32
|
+
const pages = await db.all(`${SELECT_PAGE} ORDER BY pages.created_at DESC, pages.id DESC LIMIT ? OFFSET ?`, [perPage, offset]);
|
|
33
|
+
const counted = await db.get('SELECT COUNT(*) AS total FROM pages');
|
|
34
|
+
// Postgres returns bigint counts as strings rather than lose precision.
|
|
35
|
+
return { pages: await withFeaturedImages(pages), total: Number(counted?.total) || 0 };
|
|
36
|
+
},
|
|
37
|
+
async all() {
|
|
38
|
+
const db = await getDb();
|
|
39
|
+
return withFeaturedImages(await db.all(`${SELECT_PAGE} ORDER BY pages.menu_order ASC, pages.title ASC`));
|
|
40
|
+
},
|
|
41
|
+
async find(id) {
|
|
42
|
+
const db = await getDb();
|
|
43
|
+
return first(await db.get(`${SELECT_PAGE} WHERE pages.id = ?`, [id]));
|
|
44
|
+
},
|
|
45
|
+
async findBySlug(slug) {
|
|
46
|
+
const db = await getDb();
|
|
47
|
+
return first(await db.get(`${SELECT_PAGE} WHERE pages.slug = ?`, [slug]));
|
|
48
|
+
},
|
|
49
|
+
async findPublished() {
|
|
50
|
+
const db = await getDb();
|
|
51
|
+
return withFeaturedImages(await db.all(`
|
|
52
|
+
${SELECT_PAGE}
|
|
53
|
+
WHERE pages.published = 1
|
|
54
|
+
ORDER BY pages.menu_order ASC, pages.title ASC
|
|
55
|
+
`));
|
|
56
|
+
},
|
|
57
|
+
async findPublishedBySlug(slug) {
|
|
58
|
+
const db = await getDb();
|
|
59
|
+
return first(await db.get(`${SELECT_PAGE} WHERE pages.slug = ? AND pages.published = 1`, [slug]));
|
|
60
|
+
},
|
|
61
|
+
async tree() {
|
|
62
|
+
const pages = await this.all();
|
|
63
|
+
return buildTree(pages);
|
|
64
|
+
},
|
|
65
|
+
async create(data) {
|
|
66
|
+
const db = await getDb();
|
|
67
|
+
// Derived from the title when the author left it blank, and made unique
|
|
68
|
+
// either way: `pages.slug` is uniquely indexed, so a second "About" used to
|
|
69
|
+
// fail the save rather than become `about-2`.
|
|
70
|
+
const slug = await uniqueSlug('pages', data.slug || data.title, { fallback: 'page' });
|
|
71
|
+
const now = new Date().toISOString();
|
|
72
|
+
// Markdown stays canonical; the HTML beside it is a cache built on write.
|
|
73
|
+
const contentHtml = await renderContent(data.content || '', {
|
|
74
|
+
context: { table: 'pages', slug }
|
|
75
|
+
});
|
|
76
|
+
// The last point a listener can alter what is stored. Its return value has
|
|
77
|
+
// to be what gets written, or the filter is decoration.
|
|
78
|
+
const contentSaved = await hooks.filter(HOOKS.CONTENT_SAVE, contentHtml, { type: 'page', data });
|
|
79
|
+
// Through the query builder, which appends RETURNING id on Postgres. A raw
|
|
80
|
+
// INSERT there reports lastInsertRowid as null, so the row is written and
|
|
81
|
+
// the caller is handed an object with no id.
|
|
82
|
+
const result = await (await query('pages')).insert({
|
|
83
|
+
title: data.title,
|
|
84
|
+
slug,
|
|
85
|
+
content: data.content || null,
|
|
86
|
+
content_html: contentSaved,
|
|
87
|
+
featured_image: data.featured_image ?? null,
|
|
88
|
+
template: data.template || 'default',
|
|
89
|
+
published: data.published ? 1 : 0,
|
|
90
|
+
parent_id: data.parent_id || null,
|
|
91
|
+
menu_order: data.menu_order || 0,
|
|
92
|
+
meta_title: data.meta_title || null,
|
|
93
|
+
meta_description: data.meta_description || null,
|
|
94
|
+
...Object.fromEntries(SEO_COLUMNS.filter((key) => data[key] !== undefined)
|
|
95
|
+
.map((key) => [key, data[key]])),
|
|
96
|
+
created_at: now,
|
|
97
|
+
updated_at: now
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
id: result.lastInsertRowid,
|
|
101
|
+
title: data.title,
|
|
102
|
+
slug,
|
|
103
|
+
content: data.content,
|
|
104
|
+
content_html: contentSaved,
|
|
105
|
+
featured_image: data.featured_image ?? null,
|
|
106
|
+
template: data.template || 'default',
|
|
107
|
+
published: data.published || false,
|
|
108
|
+
parent_id: data.parent_id,
|
|
109
|
+
menu_order: data.menu_order || 0,
|
|
110
|
+
meta_title: data.meta_title,
|
|
111
|
+
meta_description: data.meta_description,
|
|
112
|
+
created_at: now,
|
|
113
|
+
updated_at: now
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
async update(id, data) {
|
|
117
|
+
const db = await getDb();
|
|
118
|
+
// A page keeps the slug it was published with. This used to re-derive it
|
|
119
|
+
// from the title on every save, so correcting a typo in a heading silently
|
|
120
|
+
// moved the page's URL and 404'd every link to it. Clearing the field is
|
|
121
|
+
// still a request for a new one, derived from the title.
|
|
122
|
+
// `undefined` means the caller said nothing about the slug — the controller
|
|
123
|
+
// destructures a fixed field list, so the key is always present. An empty
|
|
124
|
+
// string is a caller asking for a fresh one.
|
|
125
|
+
const wantsSlug = data.slug !== undefined;
|
|
126
|
+
const slug = wantsSlug
|
|
127
|
+
? await uniqueSlug('pages', (data.slug || '').trim() || data.title || '', {
|
|
128
|
+
excludeId: id,
|
|
129
|
+
fallback: 'page'
|
|
130
|
+
})
|
|
131
|
+
: undefined;
|
|
132
|
+
const updateData = {
|
|
133
|
+
...data,
|
|
134
|
+
...(wantsSlug ? { slug } : {}),
|
|
135
|
+
updated_at: new Date().toISOString()
|
|
136
|
+
};
|
|
137
|
+
// Only when the caller said something about it. The controller always
|
|
138
|
+
// passes the key, so `'published' in data` was true even for a request that
|
|
139
|
+
// never mentioned it — and a client sending just a title silently
|
|
140
|
+
// unpublished the page.
|
|
141
|
+
if (data.published !== undefined) {
|
|
142
|
+
updateData.published = data.published ? 1 : 0;
|
|
143
|
+
}
|
|
144
|
+
// Re-render whenever the source changes, so the two can never disagree.
|
|
145
|
+
if ('content' in data) {
|
|
146
|
+
updateData.content_html = await renderContent(data.content || '', {
|
|
147
|
+
context: { table: 'pages', id }
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// `undefined` means the caller said nothing about that column — the
|
|
151
|
+
// controller destructures a fixed list, so a client that sends only a title
|
|
152
|
+
// would otherwise blank the template, the parent and the menu order.
|
|
153
|
+
const writable = Object.entries(updateData).filter(([key, value]) => UPDATABLE.includes(key) && value !== undefined);
|
|
154
|
+
if (writable.length === 0)
|
|
155
|
+
return this.find(id);
|
|
156
|
+
const fields = writable.map(([key]) => `${key} = ?`).join(', ');
|
|
157
|
+
await db.run(`UPDATE pages SET ${fields} WHERE id = ?`, [...writable.map(([, value]) => value), id]);
|
|
158
|
+
return this.find(id);
|
|
159
|
+
},
|
|
160
|
+
async delete(id) {
|
|
161
|
+
const db = await getDb();
|
|
162
|
+
// Update children to remove parent
|
|
163
|
+
await db.run('UPDATE pages SET parent_id = NULL WHERE parent_id = ?', [id]);
|
|
164
|
+
// Delete page
|
|
165
|
+
await db.run('DELETE FROM pages WHERE id = ?', [id]);
|
|
166
|
+
},
|
|
167
|
+
async slugExists(slug, excludeId) {
|
|
168
|
+
const db = await getDb();
|
|
169
|
+
const query = excludeId
|
|
170
|
+
? 'SELECT id FROM pages WHERE slug = ? AND id != ?'
|
|
171
|
+
: 'SELECT id FROM pages WHERE slug = ?';
|
|
172
|
+
const params = excludeId ? [slug, excludeId] : [slug];
|
|
173
|
+
const result = await db.get(query, params);
|
|
174
|
+
return !!result;
|
|
175
|
+
},
|
|
176
|
+
async reorder(pages) {
|
|
177
|
+
const db = await getDb();
|
|
178
|
+
for (const { id, menu_order } of pages) {
|
|
179
|
+
await db.run('UPDATE pages SET menu_order = ? WHERE id = ?', [menu_order, id]);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Every page read joins its featured image.
|
|
185
|
+
*
|
|
186
|
+
* Written once so the eight read paths cannot disagree about whether a page has
|
|
187
|
+
* one — which is how `posts` ended up rendering `/uploads/3` for a while: the
|
|
188
|
+
* column holds a media id and the front end wants a URL.
|
|
189
|
+
*/
|
|
190
|
+
const SELECT_PAGE = `
|
|
191
|
+
SELECT pages.*, media.path AS featured_image_path
|
|
192
|
+
FROM pages
|
|
193
|
+
LEFT JOIN media ON media.id = pages.featured_image
|
|
194
|
+
`;
|
|
195
|
+
/** Resolve each featured image to a URL, in one adapter lookup for the batch. */
|
|
196
|
+
async function withFeaturedImages(rows) {
|
|
197
|
+
if (!rows.some((row) => row.featured_image_path))
|
|
198
|
+
return rows;
|
|
199
|
+
const storage = await getStorage();
|
|
200
|
+
return rows.map((row) => ({
|
|
201
|
+
...row,
|
|
202
|
+
featured_image_url: row.featured_image_path
|
|
203
|
+
? storage.publicUrl(row.featured_image_path)
|
|
204
|
+
: null
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
/** The same resolution for a single row, which is what `find` deals in. */
|
|
208
|
+
async function first(row) {
|
|
209
|
+
return row ? (await withFeaturedImages([row]))[0] : undefined;
|
|
210
|
+
}
|
|
211
|
+
function buildTree(pages, parentId = null) {
|
|
212
|
+
return pages
|
|
213
|
+
.filter(page => page.parent_id === parentId)
|
|
214
|
+
.map(page => ({
|
|
215
|
+
...page,
|
|
216
|
+
children: buildTree(pages, page.id)
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { Post as PostType } from '../types/index.ts';
|
|
2
|
+
interface CreatePostData {
|
|
3
|
+
user_id: number;
|
|
4
|
+
title: string;
|
|
5
|
+
content: string;
|
|
6
|
+
published: boolean;
|
|
7
|
+
slug?: string;
|
|
8
|
+
excerpt?: string;
|
|
9
|
+
featured_image?: number | null;
|
|
10
|
+
meta_title?: string | null;
|
|
11
|
+
meta_description?: string | null;
|
|
12
|
+
publish_at?: string | null;
|
|
13
|
+
status?: 'draft' | 'pending' | 'published';
|
|
14
|
+
live_notified?: number;
|
|
15
|
+
og_title?: string | null;
|
|
16
|
+
og_description?: string | null;
|
|
17
|
+
og_image?: number | null;
|
|
18
|
+
twitter_title?: string | null;
|
|
19
|
+
twitter_description?: string | null;
|
|
20
|
+
twitter_image?: number | null;
|
|
21
|
+
canonical_url?: string | null;
|
|
22
|
+
noindex?: number;
|
|
23
|
+
visibility?: string;
|
|
24
|
+
send_newsletter?: number;
|
|
25
|
+
/** Content type key (migration 038). Absent means `post`. */
|
|
26
|
+
post_type?: string;
|
|
27
|
+
/** Custom field values as stored: a JSON string, already validated. */
|
|
28
|
+
fields?: string | null;
|
|
29
|
+
}
|
|
30
|
+
interface UpdatePostData {
|
|
31
|
+
user_id?: number;
|
|
32
|
+
title?: string;
|
|
33
|
+
content?: string;
|
|
34
|
+
published?: number;
|
|
35
|
+
slug?: string;
|
|
36
|
+
excerpt?: string;
|
|
37
|
+
featured_image?: number | null;
|
|
38
|
+
meta_title?: string | null;
|
|
39
|
+
meta_description?: string | null;
|
|
40
|
+
publish_at?: string | null;
|
|
41
|
+
status?: 'draft' | 'pending' | 'published';
|
|
42
|
+
deleted_at?: string | null;
|
|
43
|
+
live_notified?: number;
|
|
44
|
+
og_title?: string | null;
|
|
45
|
+
og_description?: string | null;
|
|
46
|
+
og_image?: number | null;
|
|
47
|
+
twitter_title?: string | null;
|
|
48
|
+
twitter_description?: string | null;
|
|
49
|
+
twitter_image?: number | null;
|
|
50
|
+
canonical_url?: string | null;
|
|
51
|
+
noindex?: number;
|
|
52
|
+
visibility?: string;
|
|
53
|
+
send_newsletter?: number;
|
|
54
|
+
post_type?: string;
|
|
55
|
+
fields?: string | null;
|
|
56
|
+
}
|
|
57
|
+
/** The social and indexing fields, written on create exactly as given. */
|
|
58
|
+
export declare const SEO_FIELDS: readonly ["og_title", "og_description", "og_image", "twitter_title", "twitter_description", "twitter_image", "canonical_url", "noindex"];
|
|
59
|
+
/**
|
|
60
|
+
* The admin listing's filters, in the order the tabs show them.
|
|
61
|
+
*
|
|
62
|
+
* `scheduled` is not a stored status: it is a published post whose time has
|
|
63
|
+
* not come, which is exactly how the public site decides not to show it.
|
|
64
|
+
*/
|
|
65
|
+
export declare const LISTING_FILTERS: readonly ["all", "draft", "pending", "scheduled", "published", "trash"];
|
|
66
|
+
export type ListingFilter = (typeof LISTING_FILTERS)[number];
|
|
67
|
+
export declare const Post: {
|
|
68
|
+
all(): Promise<PostType[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Replace a post's categories.
|
|
71
|
+
*
|
|
72
|
+
* Rebuilt rather than merged, because the editor sends the complete set: a
|
|
73
|
+
* merge would make unchecking a box do nothing, which is the kind of bug
|
|
74
|
+
* people re-report for months.
|
|
75
|
+
*
|
|
76
|
+
* `posts.category_id` is kept in step as the *primary* category — the first
|
|
77
|
+
* of the set — so a breadcrumb or canonical URL still has one to name.
|
|
78
|
+
*/
|
|
79
|
+
syncCategories(postId: number, categoryIds: number[]): Promise<void>;
|
|
80
|
+
/** Replace a post's tags. Rebuilt, for the same reason as categories. */
|
|
81
|
+
syncTags(postId: number, tagIds: number[]): Promise<void>;
|
|
82
|
+
/** The ids of a post's categories and tags, for the editor to preselect. */
|
|
83
|
+
taxonomy(postId: number): Promise<{
|
|
84
|
+
categories: number[];
|
|
85
|
+
tags: number[];
|
|
86
|
+
}>;
|
|
87
|
+
find(id: number): Promise<PostType | undefined>;
|
|
88
|
+
findByUser(userId: number): Promise<PostType[]>;
|
|
89
|
+
/** How many posts sit in each listing tab, for the counts beside them. */
|
|
90
|
+
counts(userId?: number, type?: string): Promise<Record<ListingFilter, number>>;
|
|
91
|
+
/** Move to the trash. Hidden everywhere, restorable until emptied. */
|
|
92
|
+
trash(id: number): Promise<void>;
|
|
93
|
+
/** Take out of the trash, in whatever state it was in before. */
|
|
94
|
+
restore(id: number): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Scheduled posts whose time has come and that webhooks have not heard about.
|
|
97
|
+
*
|
|
98
|
+
* The public site needs nothing to make a scheduled post appear — the read
|
|
99
|
+
* filter does that — but a webhook consumer has to be told, and nothing
|
|
100
|
+
* happens at the moment the time passes. `publishDue()` asks this, tells
|
|
101
|
+
* the consumers, then marks each one with `markNotified`.
|
|
102
|
+
*/
|
|
103
|
+
dueForNotification(): Promise<PostType[]>;
|
|
104
|
+
markNotified(id: number): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* One page of posts, with the total so a caller can size the pager.
|
|
107
|
+
*
|
|
108
|
+
* `userId` narrows it to one author's work. Omitting it returns everyone's,
|
|
109
|
+
* which is what an editor or an admin should see — they can edit any post, so
|
|
110
|
+
* a listing that showed only their own hid the site from the people
|
|
111
|
+
* responsible for it.
|
|
112
|
+
*
|
|
113
|
+
* The count is a second query rather than a window function, because the
|
|
114
|
+
* three drivers do not agree on those and this has to run on all of them.
|
|
115
|
+
* It is cheap: an indexed count.
|
|
116
|
+
*/
|
|
117
|
+
paginate({ perPage, offset, userId, filter, search, type }: {
|
|
118
|
+
perPage: number;
|
|
119
|
+
offset: number;
|
|
120
|
+
userId?: number;
|
|
121
|
+
filter?: ListingFilter;
|
|
122
|
+
search?: string;
|
|
123
|
+
/** One content type's entries; omitted lists every type. */
|
|
124
|
+
type?: string;
|
|
125
|
+
}): Promise<{
|
|
126
|
+
posts: PostType[];
|
|
127
|
+
total: number;
|
|
128
|
+
}>;
|
|
129
|
+
findPublished(): Promise<PostType[]>;
|
|
130
|
+
findPublishedById(id: number): Promise<PostType | undefined>;
|
|
131
|
+
create(data: CreatePostData): Promise<PostType>;
|
|
132
|
+
update(id: number, data: UpdatePostData): Promise<PostType>;
|
|
133
|
+
/** Gone for good. Only ever called on a post already in the trash. */
|
|
134
|
+
delete(id: number): Promise<void>;
|
|
135
|
+
};
|
|
136
|
+
export {};
|