@basicbenframework/cms 0.0.0-stage → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +206 -2
- package/db/migrations/001_create_users.js +15 -0
- package/db/migrations/002_create_posts.js +18 -0
- package/db/migrations/003_create_categories.js +19 -0
- package/db/migrations/004_create_tags.js +16 -0
- package/db/migrations/005_create_post_tags.js +16 -0
- package/db/migrations/006_create_pages.js +26 -0
- package/db/migrations/007_create_comments.js +24 -0
- package/db/migrations/008_create_media.js +22 -0
- package/db/migrations/009_update_posts_blogging.js +27 -0
- package/db/migrations/010_create_settings.js +29 -0
- package/db/migrations/011_add_user_roles.js +23 -0
- package/db/migrations/012_create_auth_tokens.js +30 -0
- package/db/migrations/013_add_email_verified.js +24 -0
- package/db/migrations/014_create_user_two_factor.js +30 -0
- package/db/migrations/015_create_user_credentials.js +35 -0
- package/db/migrations/016_create_rate_limits.js +31 -0
- package/db/migrations/017_add_content_html.js +38 -0
- package/db/migrations/018_create_api_tokens.js +34 -0
- package/db/migrations/019_create_post_categories.js +40 -0
- package/db/migrations/020_add_author_profiles.js +60 -0
- package/db/migrations/021_add_page_featured_image.js +23 -0
- package/db/migrations/022_backfill_post_slugs_and_excerpts.js +57 -0
- package/db/migrations/023_add_user_session_controls.js +25 -0
- package/db/migrations/024_add_post_status_and_trash.js +45 -0
- package/db/migrations/025_add_social_and_indexing_fields.js +40 -0
- package/db/migrations/026_create_post_revisions.js +29 -0
- package/db/migrations/027_add_media_dimensions.js +19 -0
- package/db/migrations/028_create_navigation_menus.js +65 -0
- package/db/migrations/029_create_redirects.js +40 -0
- package/db/migrations/030_add_comment_status_and_notifications.js +53 -0
- package/db/migrations/031_create_post_locks.js +38 -0
- package/db/migrations/032_create_snippets.js +31 -0
- package/db/migrations/033_create_members.js +70 -0
- package/db/migrations/034_add_post_visibility.js +28 -0
- package/db/migrations/035_create_newsletters.js +72 -0
- package/db/migrations/036_create_analytics.js +89 -0
- package/db/migrations/037_create_ops_heartbeats.js +30 -0
- package/db/migrations/038_create_content_types.js +84 -0
- package/db/migrations/039_create_content_type_fields.js +47 -0
- package/db/migrations/040_create_taxonomies.js +80 -0
- package/db/migrations/041_add_newsletter_handoff.js +28 -0
- package/db/migrations/042_create_mysendbox_contacts.js +63 -0
- package/lib/cli/backup.d.mts +2 -0
- package/lib/cli/backup.mjs +124 -0
- package/lib/cli/export.d.mts +2 -0
- package/lib/cli/export.mjs +54 -0
- package/lib/cli/import-ghost.d.mts +2 -0
- package/lib/cli/import-ghost.mjs +50 -0
- package/lib/cli/import-json.d.mts +2 -0
- package/lib/cli/import-json.mjs +61 -0
- package/lib/cli/import-wordpress.d.mts +2 -0
- package/lib/cli/import-wordpress.mjs +169 -0
- package/lib/cli/import-wxr.d.mts +2 -0
- package/lib/cli/import-wxr.mjs +55 -0
- package/lib/cli/index.d.mts +2 -0
- package/lib/cli/index.mjs +53 -0
- package/lib/cli/lib/backup.d.mts +112 -0
- package/lib/cli/lib/backup.mjs +297 -0
- package/lib/cli/lib/ghost.d.mts +30 -0
- package/lib/cli/lib/ghost.mjs +201 -0
- package/lib/cli/lib/html-to-markdown.d.mts +61 -0
- package/lib/cli/lib/html-to-markdown.mjs +523 -0
- package/lib/cli/lib/import-common.d.mts +100 -0
- package/lib/cli/lib/import-common.mjs +252 -0
- package/lib/cli/lib/json-import.d.mts +22 -0
- package/lib/cli/lib/json-import.mjs +422 -0
- package/lib/cli/lib/site-import.d.mts +32 -0
- package/lib/cli/lib/site-import.mjs +456 -0
- package/lib/cli/lib/wordpress-rest.d.mts +25 -0
- package/lib/cli/lib/wordpress-rest.mjs +177 -0
- package/lib/cli/lib/wxr.d.mts +18 -0
- package/lib/cli/lib/wxr.mjs +307 -0
- package/lib/cli/lib/xml.d.mts +33 -0
- package/lib/cli/lib/xml.mjs +186 -0
- package/lib/cli/restore.d.mts +2 -0
- package/lib/cli/restore.mjs +98 -0
- package/lib/client/components/Alert.d.ts +7 -0
- package/lib/client/components/Alert.js +8 -0
- package/lib/client/components/Avatar.d.ts +15 -0
- package/lib/client/components/Avatar.js +10 -0
- package/lib/client/components/BackLink.d.ts +7 -0
- package/lib/client/components/BackLink.js +6 -0
- package/lib/client/components/Button.d.ts +7 -0
- package/lib/client/components/Button.js +12 -0
- package/lib/client/components/Card.d.ts +7 -0
- package/lib/client/components/Card.js +6 -0
- package/lib/client/components/CommentThread.d.ts +15 -0
- package/lib/client/components/CommentThread.js +101 -0
- package/lib/client/components/Empty.d.ts +6 -0
- package/lib/client/components/Empty.js +6 -0
- package/lib/client/components/Input.d.ts +6 -0
- package/lib/client/components/Input.js +6 -0
- package/lib/client/components/Link.d.ts +31 -0
- package/lib/client/components/Link.js +49 -0
- package/lib/client/components/Loading.d.ts +1 -0
- package/lib/client/components/Loading.js +6 -0
- package/lib/client/components/Logo.d.ts +5 -0
- package/lib/client/components/Logo.js +4 -0
- package/lib/client/components/MarkdownEditor.d.ts +41 -0
- package/lib/client/components/MarkdownEditor.js +156 -0
- package/lib/client/components/Nav/DarkModeToggle.d.ts +6 -0
- package/lib/client/components/Nav/DarkModeToggle.js +6 -0
- package/lib/client/components/Nav/DesktopNav.d.ts +8 -0
- package/lib/client/components/Nav/DesktopNav.js +9 -0
- package/lib/client/components/Nav/MobileNav.d.ts +9 -0
- package/lib/client/components/Nav/MobileNav.js +15 -0
- package/lib/client/components/NavLink.d.ts +8 -0
- package/lib/client/components/NavLink.js +6 -0
- package/lib/client/components/PageHeader.d.ts +8 -0
- package/lib/client/components/PageHeader.js +6 -0
- package/lib/client/components/PostCard.d.ts +8 -0
- package/lib/client/components/PostCard.js +7 -0
- package/lib/client/components/Textarea.d.ts +6 -0
- package/lib/client/components/Textarea.js +6 -0
- package/lib/client/components/ThemeContext.d.ts +18 -0
- package/lib/client/components/ThemeContext.js +8 -0
- package/lib/client/components/admin/AdminIcons.d.ts +13 -0
- package/lib/client/components/admin/AdminIcons.js +66 -0
- package/lib/client/components/admin/ContentModelPanels.d.ts +22 -0
- package/lib/client/components/admin/ContentModelPanels.js +93 -0
- package/lib/client/components/admin/FeaturedImageBox.d.ts +21 -0
- package/lib/client/components/admin/FeaturedImageBox.js +24 -0
- package/lib/client/components/admin/MediaGrid.d.ts +23 -0
- package/lib/client/components/admin/MediaGrid.js +69 -0
- package/lib/client/components/admin/MediaPicker.d.ts +17 -0
- package/lib/client/components/admin/MediaPicker.js +61 -0
- package/lib/client/components/admin/Pagination.d.ts +27 -0
- package/lib/client/components/admin/Pagination.js +29 -0
- package/lib/client/components/admin/SnippetPicker.d.ts +27 -0
- package/lib/client/components/admin/SnippetPicker.js +65 -0
- package/lib/client/components/admin/TermPicker.d.ts +52 -0
- package/lib/client/components/admin/TermPicker.js +58 -0
- package/lib/client/contexts/ToastContext.d.ts +12 -0
- package/lib/client/contexts/ToastContext.js +49 -0
- package/lib/client/features.d.ts +11 -0
- package/lib/client/features.js +7 -0
- package/lib/client/hooks/useContentTypes.d.ts +48 -0
- package/lib/client/hooks/useContentTypes.js +48 -0
- package/lib/client/hooks/useMediaLibrary.d.ts +46 -0
- package/lib/client/hooks/useMediaLibrary.js +189 -0
- package/lib/client/hooks/usePostLock.d.ts +32 -0
- package/lib/client/hooks/usePostLock.js +107 -0
- package/lib/client/host/index.d.ts +71 -0
- package/lib/client/host/index.js +58 -0
- package/lib/client/i18n/index.d.ts +79 -0
- package/lib/client/i18n/index.js +177 -0
- package/lib/client/i18n/locales/es/content.d.ts +4 -0
- package/lib/client/i18n/locales/es/content.js +220 -0
- package/lib/client/i18n/locales/es/editor.d.ts +9 -0
- package/lib/client/i18n/locales/es/editor.js +144 -0
- package/lib/client/i18n/locales/es/index.d.ts +8 -0
- package/lib/client/i18n/locales/es/index.js +7 -0
- package/lib/client/i18n/locales/es/layout.d.ts +4 -0
- package/lib/client/i18n/locales/es/layout.js +35 -0
- package/lib/client/i18n/locales/es/people.d.ts +4 -0
- package/lib/client/i18n/locales/es/people.js +187 -0
- package/lib/client/i18n/locales/es/site.d.ts +4 -0
- package/lib/client/i18n/locales/es/site.js +208 -0
- package/lib/client/layouts/AdminLayout.d.ts +7 -0
- package/lib/client/layouts/AdminLayout.js +1046 -0
- package/lib/client/layouts/AppLayout.d.ts +6 -0
- package/lib/client/layouts/AppLayout.js +19 -0
- package/lib/client/layouts/AuthLayout.d.ts +6 -0
- package/lib/client/layouts/AuthLayout.js +14 -0
- package/lib/client/layouts/DocsLayout.d.ts +6 -0
- package/lib/client/layouts/DocsLayout.js +28 -0
- package/lib/client/layouts/RootLayout.d.ts +6 -0
- package/lib/client/layouts/RootLayout.js +11 -0
- package/lib/client/pages/AcceptInvite.d.ts +8 -0
- package/lib/client/pages/AcceptInvite.js +60 -0
- package/lib/client/pages/Auth.d.ts +1 -0
- package/lib/client/pages/Auth.js +40 -0
- package/lib/client/pages/Authentication.d.ts +1 -0
- package/lib/client/pages/Authentication.js +230 -0
- package/lib/client/pages/Content.d.ts +1 -0
- package/lib/client/pages/Content.js +21 -0
- package/lib/client/pages/Database.d.ts +1 -0
- package/lib/client/pages/Database.js +264 -0
- package/lib/client/pages/Extending.d.ts +1 -0
- package/lib/client/pages/Extending.js +28 -0
- package/lib/client/pages/Feed.d.ts +1 -0
- package/lib/client/pages/Feed.js +19 -0
- package/lib/client/pages/FeedPost.d.ts +1 -0
- package/lib/client/pages/FeedPost.js +31 -0
- package/lib/client/pages/ForgotPassword.d.ts +8 -0
- package/lib/client/pages/ForgotPassword.js +38 -0
- package/lib/client/pages/GettingStarted.d.ts +1 -0
- package/lib/client/pages/GettingStarted.js +84 -0
- package/lib/client/pages/Headless.d.ts +1 -0
- package/lib/client/pages/Headless.js +49 -0
- package/lib/client/pages/Home.d.ts +1 -0
- package/lib/client/pages/Home.js +67 -0
- package/lib/client/pages/PostForm.d.ts +1 -0
- package/lib/client/pages/PostForm.js +55 -0
- package/lib/client/pages/Posts.d.ts +1 -0
- package/lib/client/pages/Posts.js +35 -0
- package/lib/client/pages/Profile.d.ts +1 -0
- package/lib/client/pages/Profile.js +153 -0
- package/lib/client/pages/ResetPassword.d.ts +8 -0
- package/lib/client/pages/ResetPassword.js +52 -0
- package/lib/client/pages/Routing.d.ts +1 -0
- package/lib/client/pages/Routing.js +192 -0
- package/lib/client/pages/Storage.d.ts +1 -0
- package/lib/client/pages/Storage.js +54 -0
- package/lib/client/pages/Testing.d.ts +1 -0
- package/lib/client/pages/Testing.js +141 -0
- package/lib/client/pages/Validation.d.ts +1 -0
- package/lib/client/pages/Validation.js +123 -0
- package/lib/client/pages/admin/Categories.d.ts +2 -0
- package/lib/client/pages/admin/Categories.js +75 -0
- package/lib/client/pages/admin/Comments.d.ts +11 -0
- package/lib/client/pages/admin/Comments.js +247 -0
- package/lib/client/pages/admin/ContentTypes.d.ts +2 -0
- package/lib/client/pages/admin/ContentTypes.js +163 -0
- package/lib/client/pages/admin/Dashboard.d.ts +2 -0
- package/lib/client/pages/admin/Dashboard.js +66 -0
- package/lib/client/pages/admin/Health.d.ts +12 -0
- package/lib/client/pages/admin/Health.js +148 -0
- package/lib/client/pages/admin/Media.d.ts +2 -0
- package/lib/client/pages/admin/Media.js +101 -0
- package/lib/client/pages/admin/Navigation.d.ts +9 -0
- package/lib/client/pages/admin/Navigation.js +230 -0
- package/lib/client/pages/admin/Pages.d.ts +2 -0
- package/lib/client/pages/admin/Pages.js +53 -0
- package/lib/client/pages/admin/PostEditor.d.ts +17 -0
- package/lib/client/pages/admin/PostEditor.js +532 -0
- package/lib/client/pages/admin/Posts.d.ts +2 -0
- package/lib/client/pages/admin/Posts.js +152 -0
- package/lib/client/pages/admin/Redirects.d.ts +10 -0
- package/lib/client/pages/admin/Redirects.js +87 -0
- package/lib/client/pages/admin/Settings.d.ts +2 -0
- package/lib/client/pages/admin/Settings.js +111 -0
- package/lib/client/pages/admin/Snippets.d.ts +14 -0
- package/lib/client/pages/admin/Snippets.js +85 -0
- package/lib/client/pages/admin/Tags.d.ts +2 -0
- package/lib/client/pages/admin/Tags.js +74 -0
- package/lib/client/pages/admin/Taxonomies.d.ts +2 -0
- package/lib/client/pages/admin/Taxonomies.js +130 -0
- package/lib/client/pages/admin/Tokens.d.ts +9 -0
- package/lib/client/pages/admin/Tokens.js +260 -0
- package/lib/client/pages/admin/Tools.d.ts +12 -0
- package/lib/client/pages/admin/Tools.js +111 -0
- package/lib/client/pages/admin/Users.d.ts +13 -0
- package/lib/client/pages/admin/Users.js +313 -0
- package/lib/client/pages/api-reference.d.ts +33 -0
- package/lib/client/pages/api-reference.js +198 -0
- package/lib/client/styles.css +37 -0
- package/lib/config.d.ts +24 -0
- package/lib/config.js +39 -0
- package/lib/controllers/AdminController.d.ts +46 -0
- package/lib/controllers/AdminController.js +134 -0
- package/lib/controllers/AuthController.d.ts +15 -0
- package/lib/controllers/AuthController.js +194 -0
- package/lib/controllers/AuthorController.d.ts +17 -0
- package/lib/controllers/AuthorController.js +19 -0
- package/lib/controllers/CategoryController.d.ts +10 -0
- package/lib/controllers/CategoryController.js +88 -0
- package/lib/controllers/CommentController.d.ts +68 -0
- package/lib/controllers/CommentController.js +438 -0
- package/lib/controllers/ContentTypeController.d.ts +24 -0
- package/lib/controllers/ContentTypeController.js +91 -0
- package/lib/controllers/EmailVerificationController.d.ts +33 -0
- package/lib/controllers/EmailVerificationController.js +116 -0
- package/lib/controllers/ExportController.d.ts +15 -0
- package/lib/controllers/ExportController.js +41 -0
- package/lib/controllers/FeedController.d.ts +14 -0
- package/lib/controllers/FeedController.js +246 -0
- package/lib/controllers/HealthController.d.ts +21 -0
- package/lib/controllers/HealthController.js +176 -0
- package/lib/controllers/HomeController.d.ts +12 -0
- package/lib/controllers/HomeController.js +16 -0
- package/lib/controllers/MediaController.d.ts +24 -0
- package/lib/controllers/MediaController.js +189 -0
- package/lib/controllers/NavigationController.d.ts +22 -0
- package/lib/controllers/NavigationController.js +176 -0
- package/lib/controllers/PageController.d.ts +13 -0
- package/lib/controllers/PageController.js +172 -0
- package/lib/controllers/PasskeyController.d.ts +36 -0
- package/lib/controllers/PasskeyController.js +201 -0
- package/lib/controllers/PasswordResetController.d.ts +44 -0
- package/lib/controllers/PasswordResetController.js +160 -0
- package/lib/controllers/PostController.d.ts +51 -0
- package/lib/controllers/PostController.js +538 -0
- package/lib/controllers/PostLockController.d.ts +62 -0
- package/lib/controllers/PostLockController.js +101 -0
- package/lib/controllers/ProfileController.d.ts +13 -0
- package/lib/controllers/ProfileController.js +160 -0
- package/lib/controllers/PublicApiController.d.ts +23 -0
- package/lib/controllers/PublicApiController.js +100 -0
- package/lib/controllers/RedirectController.d.ts +32 -0
- package/lib/controllers/RedirectController.js +95 -0
- package/lib/controllers/SettingsController.d.ts +28 -0
- package/lib/controllers/SettingsController.js +105 -0
- package/lib/controllers/SnippetController.d.ts +27 -0
- package/lib/controllers/SnippetController.js +123 -0
- package/lib/controllers/TagController.d.ts +9 -0
- package/lib/controllers/TagController.js +70 -0
- package/lib/controllers/TaxonomyController.d.ts +24 -0
- package/lib/controllers/TaxonomyController.js +149 -0
- package/lib/controllers/TokenController.d.ts +27 -0
- package/lib/controllers/TokenController.js +83 -0
- package/lib/controllers/TwoFactorController.d.ts +31 -0
- package/lib/controllers/TwoFactorController.js +213 -0
- package/lib/controllers/UserController.d.ts +110 -0
- package/lib/controllers/UserController.js +504 -0
- package/lib/features/analytics/AnalyticsPage.d.ts +11 -0
- package/lib/features/analytics/AnalyticsPage.js +123 -0
- package/lib/features/analytics/admin.d.ts +3 -0
- package/lib/features/analytics/admin.js +9 -0
- package/lib/features/analytics/controller.d.ts +19 -0
- package/lib/features/analytics/controller.js +79 -0
- package/lib/features/analytics/helpers.d.ts +84 -0
- package/lib/features/analytics/helpers.js +181 -0
- package/lib/features/analytics/i18n/es.d.ts +4 -0
- package/lib/features/analytics/i18n/es.js +31 -0
- package/lib/features/analytics/index.d.ts +28 -0
- package/lib/features/analytics/index.js +91 -0
- package/lib/features/analytics/manifest.d.ts +8 -0
- package/lib/features/analytics/manifest.js +18 -0
- package/lib/features/analytics/model.d.ts +130 -0
- package/lib/features/analytics/model.js +206 -0
- package/lib/features/members/Member.d.ts +93 -0
- package/lib/features/members/Member.js +194 -0
- package/lib/features/members/MemberAdminController.d.ts +60 -0
- package/lib/features/members/MemberAdminController.js +262 -0
- package/lib/features/members/MemberController.d.ts +88 -0
- package/lib/features/members/MemberController.js +250 -0
- package/lib/features/members/MembersPage.d.ts +10 -0
- package/lib/features/members/MembersPage.js +216 -0
- package/lib/features/members/PostAccessBox.d.ts +15 -0
- package/lib/features/members/PostAccessBox.js +70 -0
- package/lib/features/members/admin.d.ts +3 -0
- package/lib/features/members/admin.js +12 -0
- package/lib/features/members/csv.d.ts +21 -0
- package/lib/features/members/csv.js +74 -0
- package/lib/features/members/events.d.ts +34 -0
- package/lib/features/members/events.js +34 -0
- package/lib/features/members/i18n/es.d.ts +4 -0
- package/lib/features/members/i18n/es.js +106 -0
- package/lib/features/members/index.d.ts +44 -0
- package/lib/features/members/index.js +106 -0
- package/lib/features/members/manifest.d.ts +8 -0
- package/lib/features/members/manifest.js +18 -0
- package/lib/features/members/middleware.d.ts +42 -0
- package/lib/features/members/middleware.js +74 -0
- package/lib/features/members/newsletter.d.ts +177 -0
- package/lib/features/members/newsletter.js +439 -0
- package/lib/features/members/rate-limits.d.ts +34 -0
- package/lib/features/members/rate-limits.js +50 -0
- package/lib/features/members/request.d.ts +13 -0
- package/lib/features/members/request.js +6 -0
- package/lib/features/members/routes.d.ts +15 -0
- package/lib/features/members/routes.js +59 -0
- package/lib/features/members/session.d.ts +102 -0
- package/lib/features/members/session.js +158 -0
- package/lib/features/members/settings.d.ts +14 -0
- package/lib/features/members/settings.js +23 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.d.ts +7 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.js +48 -0
- package/lib/features/mysendbox/admin.d.ts +3 -0
- package/lib/features/mysendbox/admin.js +9 -0
- package/lib/features/mysendbox/broadcasts.d.ts +61 -0
- package/lib/features/mysendbox/broadcasts.js +124 -0
- package/lib/features/mysendbox/client.d.ts +95 -0
- package/lib/features/mysendbox/client.js +61 -0
- package/lib/features/mysendbox/config.d.ts +27 -0
- package/lib/features/mysendbox/config.js +74 -0
- package/lib/features/mysendbox/contacts.d.ts +121 -0
- package/lib/features/mysendbox/contacts.js +378 -0
- package/lib/features/mysendbox/controller.d.ts +11 -0
- package/lib/features/mysendbox/controller.js +47 -0
- package/lib/features/mysendbox/i18n/es.d.ts +4 -0
- package/lib/features/mysendbox/i18n/es.js +28 -0
- package/lib/features/mysendbox/index.d.ts +18 -0
- package/lib/features/mysendbox/index.js +71 -0
- package/lib/features/mysendbox/manifest.d.ts +7 -0
- package/lib/features/mysendbox/manifest.js +6 -0
- package/lib/features/mysendbox/routes.d.ts +6 -0
- package/lib/features/mysendbox/routes.js +14 -0
- package/lib/features/mysendbox/webhook.d.ts +23 -0
- package/lib/features/mysendbox/webhook.js +104 -0
- package/lib/features/theme/OEmbedController.d.ts +31 -0
- package/lib/features/theme/OEmbedController.js +128 -0
- package/lib/features/theme/ThemeController.d.ts +20 -0
- package/lib/features/theme/ThemeController.js +256 -0
- package/lib/features/theme/ThemeSettingsCard.d.ts +7 -0
- package/lib/features/theme/ThemeSettingsCard.js +12 -0
- package/lib/features/theme/admin.d.ts +3 -0
- package/lib/features/theme/admin.js +9 -0
- package/lib/features/theme/html.d.ts +48 -0
- package/lib/features/theme/html.js +97 -0
- package/lib/features/theme/i18n/es.d.ts +4 -0
- package/lib/features/theme/i18n/es.js +9 -0
- package/lib/features/theme/index.d.ts +11 -0
- package/lib/features/theme/index.js +23 -0
- package/lib/features/theme/manifest.d.ts +7 -0
- package/lib/features/theme/manifest.js +6 -0
- package/lib/features/theme/oembed.d.ts +36 -0
- package/lib/features/theme/oembed.js +58 -0
- package/lib/features/theme/routes.d.ts +17 -0
- package/lib/features/theme/routes.js +54 -0
- package/lib/features/theme/templates.d.ts +103 -0
- package/lib/features/theme/templates.js +283 -0
- package/lib/features.d.ts +15 -0
- package/lib/features.js +6 -0
- package/lib/features.manifest.d.ts +10 -0
- package/lib/features.manifest.js +6 -0
- package/lib/helpers/access.d.ts +62 -0
- package/lib/helpers/access.js +92 -0
- package/lib/helpers/api.d.ts +20 -0
- package/lib/helpers/api.js +44 -0
- package/lib/helpers/comment-guard.d.ts +145 -0
- package/lib/helpers/comment-guard.js +253 -0
- package/lib/helpers/comment-mail.d.ts +53 -0
- package/lib/helpers/comment-mail.js +188 -0
- package/lib/helpers/content-model.d.ts +50 -0
- package/lib/helpers/content-model.js +84 -0
- package/lib/helpers/content-paths.d.ts +107 -0
- package/lib/helpers/content-paths.js +200 -0
- package/lib/helpers/export-data.d.ts +85 -0
- package/lib/helpers/export-data.js +229 -0
- package/lib/helpers/gating.d.ts +53 -0
- package/lib/helpers/gating.js +83 -0
- package/lib/helpers/health.d.ts +91 -0
- package/lib/helpers/health.js +279 -0
- package/lib/helpers/heartbeat.d.ts +35 -0
- package/lib/helpers/heartbeat.js +55 -0
- package/lib/helpers/image-size.d.ts +18 -0
- package/lib/helpers/image-size.js +83 -0
- package/lib/helpers/images.d.ts +29 -0
- package/lib/helpers/images.js +41 -0
- package/lib/helpers/mail-templates.d.ts +11 -0
- package/lib/helpers/mail-templates.js +42 -0
- package/lib/helpers/publish-due.d.ts +28 -0
- package/lib/helpers/publish-due.js +67 -0
- package/lib/helpers/redirects.d.ts +43 -0
- package/lib/helpers/redirects.js +80 -0
- package/lib/helpers/seo-fields.d.ts +13 -0
- package/lib/helpers/seo-fields.js +52 -0
- package/lib/helpers/session.d.ts +30 -0
- package/lib/helpers/session.js +27 -0
- package/lib/helpers/site-settings.d.ts +98 -0
- package/lib/helpers/site-settings.js +232 -0
- package/lib/helpers/site.d.ts +14 -0
- package/lib/helpers/site.js +23 -0
- package/lib/helpers/write-hooks.d.ts +33 -0
- package/lib/helpers/write-hooks.js +37 -0
- package/lib/hooks.d.ts +17 -0
- package/lib/hooks.js +101 -0
- package/lib/host/core-tasks.d.ts +4 -0
- package/lib/host/core-tasks.js +26 -0
- package/lib/host/cron.d.ts +39 -0
- package/lib/host/cron.js +85 -0
- package/lib/host/enabled.d.ts +4 -0
- package/lib/host/enabled.js +40 -0
- package/lib/host/index.d.ts +81 -0
- package/lib/host/index.js +87 -0
- package/lib/host/manifest.d.ts +34 -0
- package/lib/host/manifest.js +7 -0
- package/lib/host/menu.d.ts +18 -0
- package/lib/host/menu.js +15 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +24 -0
- package/lib/middleware/api-auth.d.ts +59 -0
- package/lib/middleware/api-auth.js +164 -0
- package/lib/middleware/auth.d.ts +49 -0
- package/lib/middleware/auth.js +112 -0
- package/lib/middleware/cache.d.ts +17 -0
- package/lib/middleware/cache.js +52 -0
- package/lib/middleware/rate-limits.d.ts +199 -0
- package/lib/middleware/rate-limits.js +276 -0
- package/lib/middleware/viewer.d.ts +13 -0
- package/lib/middleware/viewer.js +16 -0
- package/lib/models/Category.d.ts +24 -0
- package/lib/models/Category.js +102 -0
- package/lib/models/Comment.d.ts +120 -0
- package/lib/models/Comment.js +283 -0
- package/lib/models/ContentType.d.ts +142 -0
- package/lib/models/ContentType.js +462 -0
- package/lib/models/Credential.d.ts +21 -0
- package/lib/models/Credential.js +31 -0
- package/lib/models/Media.d.ts +53 -0
- package/lib/models/Media.js +132 -0
- package/lib/models/Menu.d.ts +131 -0
- package/lib/models/Menu.js +312 -0
- package/lib/models/Page.d.ts +55 -0
- package/lib/models/Page.js +218 -0
- package/lib/models/Post.d.ts +136 -0
- package/lib/models/Post.js +406 -0
- package/lib/models/PostLock.d.ts +67 -0
- package/lib/models/PostLock.js +112 -0
- package/lib/models/PostRevision.d.ts +45 -0
- package/lib/models/PostRevision.js +82 -0
- package/lib/models/PublicContent.d.ts +283 -0
- package/lib/models/PublicContent.js +577 -0
- package/lib/models/Redirect.d.ts +123 -0
- package/lib/models/Redirect.js +225 -0
- package/lib/models/Settings.d.ts +61 -0
- package/lib/models/Settings.js +128 -0
- package/lib/models/Snippet.d.ts +36 -0
- package/lib/models/Snippet.js +64 -0
- package/lib/models/Tag.d.ts +23 -0
- package/lib/models/Tag.js +117 -0
- package/lib/models/Taxonomy.d.ts +127 -0
- package/lib/models/Taxonomy.js +321 -0
- package/lib/models/TwoFactor.d.ts +26 -0
- package/lib/models/TwoFactor.js +60 -0
- package/lib/models/User.d.ts +49 -0
- package/lib/models/User.js +128 -0
- package/lib/models/derive.d.ts +69 -0
- package/lib/models/derive.js +81 -0
- package/lib/models/pagination.d.ts +30 -0
- package/lib/models/pagination.js +36 -0
- package/lib/models/visibility.d.ts +31 -0
- package/lib/models/visibility.js +47 -0
- package/lib/routes/App.d.ts +2 -0
- package/lib/routes/App.js +146 -0
- package/lib/routes/api/admin.d.ts +6 -0
- package/lib/routes/api/admin.js +11 -0
- package/lib/routes/api/auth.d.ts +6 -0
- package/lib/routes/api/auth.js +24 -0
- package/lib/routes/api/authors.d.ts +5 -0
- package/lib/routes/api/authors.js +8 -0
- package/lib/routes/api/categories.d.ts +8 -0
- package/lib/routes/api/categories.js +15 -0
- package/lib/routes/api/comments.d.ts +8 -0
- package/lib/routes/api/comments.js +35 -0
- package/lib/routes/api/content-model.d.ts +17 -0
- package/lib/routes/api/content-model.js +67 -0
- package/lib/routes/api/cron.d.ts +6 -0
- package/lib/routes/api/cron.js +9 -0
- package/lib/routes/api/export.d.ts +5 -0
- package/lib/routes/api/export.js +11 -0
- package/lib/routes/api/feed.d.ts +5 -0
- package/lib/routes/api/feed.js +16 -0
- package/lib/routes/api/media.d.ts +8 -0
- package/lib/routes/api/media.js +25 -0
- package/lib/routes/api/navigation.d.ts +12 -0
- package/lib/routes/api/navigation.js +17 -0
- package/lib/routes/api/ops.d.ts +9 -0
- package/lib/routes/api/ops.js +19 -0
- package/lib/routes/api/pages.d.ts +8 -0
- package/lib/routes/api/pages.js +21 -0
- package/lib/routes/api/passkeys.d.ts +7 -0
- package/lib/routes/api/passkeys.js +13 -0
- package/lib/routes/api/posts.d.ts +8 -0
- package/lib/routes/api/posts.js +39 -0
- package/lib/routes/api/profile.d.ts +6 -0
- package/lib/routes/api/profile.js +8 -0
- package/lib/routes/api/redirects.d.ts +12 -0
- package/lib/routes/api/redirects.js +13 -0
- package/lib/routes/api/settings.d.ts +8 -0
- package/lib/routes/api/settings.js +15 -0
- package/lib/routes/api/snippets.d.ts +15 -0
- package/lib/routes/api/snippets.js +16 -0
- package/lib/routes/api/tags.d.ts +8 -0
- package/lib/routes/api/tags.js +14 -0
- package/lib/routes/api/tokens.d.ts +7 -0
- package/lib/routes/api/tokens.js +15 -0
- package/lib/routes/api/two-factor.d.ts +7 -0
- package/lib/routes/api/two-factor.js +15 -0
- package/lib/routes/api/users.d.ts +8 -0
- package/lib/routes/api/users.js +25 -0
- package/lib/routes/api/v1.d.ts +12 -0
- package/lib/routes/api/v1.js +55 -0
- package/lib/routes/api/verification.d.ts +6 -0
- package/lib/routes/api/verification.js +11 -0
- package/lib/server/index.d.ts +24 -0
- package/lib/server/index.js +110 -0
- package/lib/types/index.d.ts +298 -0
- package/lib/types/index.js +1 -0
- package/lib/vite.d.ts +2 -0
- package/lib/vite.js +101 -0
- package/mail/comment-moderation.html +27 -0
- package/mail/comment-moderation.txt +13 -0
- package/mail/comment-reply.html +28 -0
- package/mail/comment-reply.txt +14 -0
- package/mail/invitation.html +25 -0
- package/mail/invitation.txt +11 -0
- package/mail/member-magic-link.html +23 -0
- package/mail/member-magic-link.txt +10 -0
- package/mail/newsletter.html +26 -0
- package/mail/newsletter.txt +13 -0
- package/mail/password-reset.html +26 -0
- package/mail/password-reset.txt +10 -0
- package/mail/verify-email.html +25 -0
- package/mail/verify-email.txt +8 -0
- package/package.json +85 -4
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse an HTML fragment into `{ name, attrs, children }` elements and string
|
|
3
|
+
* text nodes. Entities are decoded in text and attribute values.
|
|
4
|
+
*/
|
|
5
|
+
export function parseHtml(html: any): {
|
|
6
|
+
name: string;
|
|
7
|
+
attrs: {};
|
|
8
|
+
children: never[];
|
|
9
|
+
};
|
|
10
|
+
/** The plain text of a node. */
|
|
11
|
+
export function textContent(node: any): any;
|
|
12
|
+
/**
|
|
13
|
+
* Convert HTML to Markdown.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} html
|
|
16
|
+
* @returns {string}
|
|
17
|
+
*/
|
|
18
|
+
export function htmlToMarkdown(html: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* WordPress's `wpautop`, roughly: turn the blank-line-separated text that
|
|
21
|
+
* classic-editor posts are stored as into paragraphs.
|
|
22
|
+
*
|
|
23
|
+
* A WXR file holds `post_content` as the author saved it, not as the site
|
|
24
|
+
* rendered it — WordPress adds the `<p>` tags at display time. Without this a
|
|
25
|
+
* classic post's paragraphs all run together. Block-editor content is already
|
|
26
|
+
* real HTML (every paragraph is a `<p>` between `<!-- wp:` comments), so it is
|
|
27
|
+
* left alone.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} content
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
export function autop(content: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Unwrap the shortcodes that carry content, leaving the rest as text.
|
|
35
|
+
*
|
|
36
|
+
* `[caption]` wraps nearly every captioned image a classic WordPress post
|
|
37
|
+
* has; left alone it prints as literal brackets around the picture. It
|
|
38
|
+
* becomes a figure, so the caption survives. `[embed]` becomes a link. Other
|
|
39
|
+
* shortcodes belong to plugins that will not exist here, and are left visible
|
|
40
|
+
* so an editor can see something needs replacing rather than having it
|
|
41
|
+
* silently vanish.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} content
|
|
44
|
+
* @returns {string}
|
|
45
|
+
*/
|
|
46
|
+
export function expandShortcodes(content: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* The plain-text summary for an excerpt field: tags stripped, entities
|
|
49
|
+
* decoded, whitespace collapsed, WordPress's `[…]` read as "...".
|
|
50
|
+
*/
|
|
51
|
+
export function plainText(html: any): string;
|
|
52
|
+
/**
|
|
53
|
+
* A comment as the plain text this CMS stores comments as.
|
|
54
|
+
*
|
|
55
|
+
* Comments are not Markdown here — they are shown as text — so Markdown
|
|
56
|
+
* escaping would put backslashes in front of every asterisk a reader typed.
|
|
57
|
+
* Paragraph and line breaks are kept; every tag is dropped.
|
|
58
|
+
*/
|
|
59
|
+
export function commentText(html: any): string;
|
|
60
|
+
export { decodeEntities };
|
|
61
|
+
import { decodeEntities } from '@basicbenframework/core/content';
|
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML to Markdown, for imported blog content.
|
|
3
|
+
*
|
|
4
|
+
* This CMS edits Markdown, so everything an importer brings in — WordPress's
|
|
5
|
+
* rendered HTML, a WXR file's raw post content, Ghost's `html` field — has to
|
|
6
|
+
* become Markdown on the way in, or the editor shows raw tags and
|
|
7
|
+
* `?format=markdown` is a lie. It replaces Turndown (and `he`) so the importers
|
|
8
|
+
* stop needing either.
|
|
9
|
+
*
|
|
10
|
+
* ## Scope
|
|
11
|
+
*
|
|
12
|
+
* Good enough for what blogs contain: paragraphs, headings, emphasis, links,
|
|
13
|
+
* images, lists (nested), quotes, code, tables, figures with captions, and
|
|
14
|
+
* embeds. It is not a general HTML parser — it does not build the spec's DOM,
|
|
15
|
+
* only a tree tolerant enough for the markup CMSes emit (unclosed `<p>` and
|
|
16
|
+
* `<li>`, stray closing tags).
|
|
17
|
+
*
|
|
18
|
+
* ## What happens to markup Markdown cannot say
|
|
19
|
+
*
|
|
20
|
+
* This project's Markdown renderer shows raw HTML as text rather than passing
|
|
21
|
+
* it through, so "keep the tag" — Turndown's answer for figures, iframes and
|
|
22
|
+
* tables — would print the tags on the page the first time a post was saved.
|
|
23
|
+
* Instead: tables become GFM tables, figures become their image plus an
|
|
24
|
+
* italic caption, and an embed becomes a link to what it embedded, so a video
|
|
25
|
+
* degrades to a link rather than vanishing. Scripts and styles are dropped
|
|
26
|
+
* whole; any other tag is unwrapped and its text kept.
|
|
27
|
+
*/
|
|
28
|
+
import { decodeEntities } from '@basicbenframework/core/content';
|
|
29
|
+
export { decodeEntities };
|
|
30
|
+
const VOID = new Set([
|
|
31
|
+
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta',
|
|
32
|
+
'param', 'source', 'track', 'wbr'
|
|
33
|
+
]);
|
|
34
|
+
/** Removed with everything inside them: their content is not prose. */
|
|
35
|
+
const DROP = new Set(['script', 'style', 'noscript', 'template', 'title', 'textarea', 'svg', 'math', 'head', 'button', 'select']);
|
|
36
|
+
/** Content of these is raw text up to the closing tag. */
|
|
37
|
+
const RAW_TEXT = new Set(['script', 'style', 'textarea', 'title']);
|
|
38
|
+
const BLOCK = new Set([
|
|
39
|
+
'address', 'article', 'aside', 'blockquote', 'body', 'center', 'dd', 'details',
|
|
40
|
+
'dialog', 'div', 'dl', 'dt', 'fieldset', 'figcaption', 'figure', 'footer',
|
|
41
|
+
'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'html',
|
|
42
|
+
'li', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'summary', 'table', 'tbody',
|
|
43
|
+
'td', 'tfoot', 'th', 'thead', 'tr', 'ul', 'iframe', 'video', 'audio', 'object',
|
|
44
|
+
'embed', 'caption'
|
|
45
|
+
]);
|
|
46
|
+
/** Opening one of these closes an open `<p>`, as browsers do. */
|
|
47
|
+
const CLOSES_P = new Set([...BLOCK].filter((t) => !['li', 'dd', 'dt', 'td', 'th', 'tr', 'tbody', 'thead', 'tfoot', 'caption', 'figcaption', 'summary', 'iframe', 'video', 'audio', 'object', 'embed'].includes(t)));
|
|
48
|
+
const EMBEDS = new Set(['iframe', 'video', 'audio', 'object', 'embed']);
|
|
49
|
+
/** Hard line break, held as a sentinel until whitespace has been collapsed. */
|
|
50
|
+
const BR = '\u0001';
|
|
51
|
+
/**
|
|
52
|
+
* Parse an HTML fragment into `{ name, attrs, children }` elements and string
|
|
53
|
+
* text nodes. Entities are decoded in text and attribute values.
|
|
54
|
+
*/
|
|
55
|
+
export function parseHtml(html) {
|
|
56
|
+
const src = String(html ?? '').replace(/\0/g, '');
|
|
57
|
+
const root = { name: '#root', attrs: {}, children: [] };
|
|
58
|
+
const stack = [root];
|
|
59
|
+
let i = 0;
|
|
60
|
+
const top = () => stack[stack.length - 1];
|
|
61
|
+
const text = (value) => {
|
|
62
|
+
if (!value)
|
|
63
|
+
return;
|
|
64
|
+
const kids = top().children;
|
|
65
|
+
if (typeof kids[kids.length - 1] === 'string')
|
|
66
|
+
kids[kids.length - 1] += value;
|
|
67
|
+
else
|
|
68
|
+
kids.push(value);
|
|
69
|
+
};
|
|
70
|
+
const closeUntil = (name) => {
|
|
71
|
+
for (let d = stack.length - 1; d > 0; d--) {
|
|
72
|
+
if (stack[d].name === name) {
|
|
73
|
+
stack.length = d;
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
};
|
|
79
|
+
while (i < src.length) {
|
|
80
|
+
const lt = src.indexOf('<', i);
|
|
81
|
+
if (lt === -1) {
|
|
82
|
+
text(decodeEntities(src.slice(i)));
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if (lt > i)
|
|
86
|
+
text(decodeEntities(src.slice(i, lt)));
|
|
87
|
+
if (src.startsWith('<!--', lt)) {
|
|
88
|
+
const end = src.indexOf('-->', lt + 4);
|
|
89
|
+
i = end === -1 ? src.length : end + 3;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (src[lt + 1] === '!' || src[lt + 1] === '?') {
|
|
93
|
+
const end = src.indexOf('>', lt);
|
|
94
|
+
i = end === -1 ? src.length : end + 1;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const closing = src[lt + 1] === '/';
|
|
98
|
+
const match = /^<\/?([A-Za-z][A-Za-z0-9:-]*)((?:\s+[^\s"'>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*)\s*(\/?)>/.exec(src.slice(lt, lt + 8192));
|
|
99
|
+
if (!match) {
|
|
100
|
+
// A lone `<` in prose ("a < b"), not a tag.
|
|
101
|
+
text('<');
|
|
102
|
+
i = lt + 1;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const name = match[1].toLowerCase();
|
|
106
|
+
i = lt + match[0].length;
|
|
107
|
+
if (closing) {
|
|
108
|
+
if (name === 'p' && !stack.some((el) => el.name === 'p')) {
|
|
109
|
+
// `</p>` with nothing open is an empty paragraph to a browser.
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
closeUntil(name);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const attrs = {};
|
|
116
|
+
for (const a of match[2].matchAll(/([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)) {
|
|
117
|
+
attrs[a[1].toLowerCase()] = decodeEntities(a[2] ?? a[3] ?? a[4] ?? '');
|
|
118
|
+
}
|
|
119
|
+
// The implied end tags real markup relies on.
|
|
120
|
+
if (CLOSES_P.has(name) && top().name === 'p')
|
|
121
|
+
stack.pop();
|
|
122
|
+
if (name === 'li')
|
|
123
|
+
closeSibling(stack, 'li', ['ul', 'ol']);
|
|
124
|
+
if (name === 'dt' || name === 'dd')
|
|
125
|
+
closeSibling(stack, ['dt', 'dd'], ['dl']);
|
|
126
|
+
if (name === 'tr')
|
|
127
|
+
closeSibling(stack, 'tr', ['table', 'thead', 'tbody', 'tfoot']);
|
|
128
|
+
if (name === 'td' || name === 'th')
|
|
129
|
+
closeSibling(stack, ['td', 'th'], ['tr', 'table']);
|
|
130
|
+
if (name === 'p' && top().name === 'p')
|
|
131
|
+
stack.pop();
|
|
132
|
+
const element = { name, attrs, children: [] };
|
|
133
|
+
top().children.push(element);
|
|
134
|
+
if (RAW_TEXT.has(name)) {
|
|
135
|
+
const end = src.toLowerCase().indexOf(`</${name}`, i);
|
|
136
|
+
const stop = end === -1 ? src.length : end;
|
|
137
|
+
element.children.push(src.slice(i, stop));
|
|
138
|
+
const gt = src.indexOf('>', stop);
|
|
139
|
+
i = gt === -1 ? src.length : gt + 1;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (!VOID.has(name) && !match[3])
|
|
143
|
+
stack.push(element);
|
|
144
|
+
}
|
|
145
|
+
return root;
|
|
146
|
+
}
|
|
147
|
+
/** Close an open `names` element, but not past its container. */
|
|
148
|
+
function closeSibling(stack, names, containers) {
|
|
149
|
+
const wanted = Array.isArray(names) ? names : [names];
|
|
150
|
+
for (let d = stack.length - 1; d > 0; d--) {
|
|
151
|
+
if (containers.includes(stack[d].name))
|
|
152
|
+
return;
|
|
153
|
+
if (wanted.includes(stack[d].name)) {
|
|
154
|
+
stack.length = d;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/** The plain text of a node. */
|
|
160
|
+
export function textContent(node) {
|
|
161
|
+
if (typeof node === 'string')
|
|
162
|
+
return node;
|
|
163
|
+
if (DROP.has(node.name))
|
|
164
|
+
return '';
|
|
165
|
+
if (node.name === 'br')
|
|
166
|
+
return '\n';
|
|
167
|
+
return node.children.map(textContent).join('');
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Convert HTML to Markdown.
|
|
171
|
+
*
|
|
172
|
+
* @param {string} html
|
|
173
|
+
* @returns {string}
|
|
174
|
+
*/
|
|
175
|
+
export function htmlToMarkdown(html) {
|
|
176
|
+
const tree = parseHtml(html);
|
|
177
|
+
return blocks(tree.children)
|
|
178
|
+
.join('\n\n')
|
|
179
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
180
|
+
.trim();
|
|
181
|
+
}
|
|
182
|
+
/** Render children as a list of Markdown blocks. */
|
|
183
|
+
function blocks(children) {
|
|
184
|
+
const out = [];
|
|
185
|
+
let run = [];
|
|
186
|
+
const flush = () => {
|
|
187
|
+
const paragraph = escapeLineStart(inlines(run));
|
|
188
|
+
if (paragraph)
|
|
189
|
+
out.push(paragraph);
|
|
190
|
+
run = [];
|
|
191
|
+
};
|
|
192
|
+
for (const node of children) {
|
|
193
|
+
if (typeof node === 'string' || !BLOCK.has(node.name)) {
|
|
194
|
+
run.push(node);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
flush();
|
|
198
|
+
out.push(...block(node));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
flush();
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
function block(el) {
|
|
205
|
+
const { name } = el;
|
|
206
|
+
if (DROP.has(name))
|
|
207
|
+
return [];
|
|
208
|
+
if (/^h[1-6]$/.test(name)) {
|
|
209
|
+
const text = inlines(el.children).replace(new RegExp(BR, 'g'), ' ').replace(/\\\n/g, ' ').trim();
|
|
210
|
+
return text ? [`${'#'.repeat(Number(name[1]))} ${text}`] : [];
|
|
211
|
+
}
|
|
212
|
+
switch (name) {
|
|
213
|
+
case 'hr':
|
|
214
|
+
return ['---'];
|
|
215
|
+
case 'pre':
|
|
216
|
+
return [codeBlock(el)];
|
|
217
|
+
case 'blockquote': {
|
|
218
|
+
const inner = blocks(el.children).join('\n\n');
|
|
219
|
+
if (!inner)
|
|
220
|
+
return [];
|
|
221
|
+
return [inner.split('\n').map((line) => (line ? `> ${line}` : '>')).join('\n')];
|
|
222
|
+
}
|
|
223
|
+
case 'ul':
|
|
224
|
+
case 'ol':
|
|
225
|
+
return [list(el)].filter(Boolean);
|
|
226
|
+
case 'table':
|
|
227
|
+
return table(el);
|
|
228
|
+
case 'figcaption': {
|
|
229
|
+
const caption = inlines(el.children);
|
|
230
|
+
return caption ? [`*${caption}*`] : [];
|
|
231
|
+
}
|
|
232
|
+
case 'dt': {
|
|
233
|
+
const term = inlines(el.children);
|
|
234
|
+
return term ? [`**${term}**`] : [];
|
|
235
|
+
}
|
|
236
|
+
case 'iframe':
|
|
237
|
+
case 'video':
|
|
238
|
+
case 'audio':
|
|
239
|
+
case 'object':
|
|
240
|
+
case 'embed':
|
|
241
|
+
return [embed(el)].filter(Boolean);
|
|
242
|
+
default:
|
|
243
|
+
return blocks(el.children);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function codeBlock(el) {
|
|
247
|
+
const code = el.children.find((c) => typeof c !== 'string' && c.name === 'code');
|
|
248
|
+
const className = `${el.attrs.class ?? ''} ${code?.attrs.class ?? ''}`;
|
|
249
|
+
const language = /(?:^|\s)(?:language|lang)-([\w+#.-]+)/.exec(className)?.[1] ?? '';
|
|
250
|
+
const text = textContent(el).replace(/^\n/, '').replace(/\s+$/, '');
|
|
251
|
+
// A fence longer than any run of backticks inside, so the code cannot close it.
|
|
252
|
+
const longest = Math.max(2, ...[...text.matchAll(/`+/g)].map((m) => m[0].length));
|
|
253
|
+
const fence = '`'.repeat(longest + 1);
|
|
254
|
+
return `${fence}${language}\n${text}\n${fence}`;
|
|
255
|
+
}
|
|
256
|
+
function list(el) {
|
|
257
|
+
const ordered = el.name === 'ol';
|
|
258
|
+
let n = Number.parseInt(el.attrs.start ?? '1', 10);
|
|
259
|
+
if (!Number.isFinite(n))
|
|
260
|
+
n = 1;
|
|
261
|
+
const items = [];
|
|
262
|
+
for (const node of el.children) {
|
|
263
|
+
if (typeof node === 'string') {
|
|
264
|
+
if (node.trim())
|
|
265
|
+
items.push(escapeLineStart(inlines([node])));
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
const content = joinItemBlocks(node.name === 'li' ? blocks(node.children) : block(node));
|
|
269
|
+
const marker = ordered ? `${n++}. ` : '- ';
|
|
270
|
+
const indent = ' '.repeat(marker.length);
|
|
271
|
+
const [first = '', ...rest] = content.split('\n');
|
|
272
|
+
items.push(marker + first + rest.map((line) => `\n${line ? indent + line : ''}`).join(''));
|
|
273
|
+
}
|
|
274
|
+
return items.join('\n');
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Blocks inside one list item. A nested list follows its parent's text on
|
|
278
|
+
* the next line, so `- two` and its sub-list stay one tight item; anything
|
|
279
|
+
* else is separated by a blank line, as Markdown needs for a second paragraph.
|
|
280
|
+
*/
|
|
281
|
+
function joinItemBlocks(parts) {
|
|
282
|
+
return parts.reduce((out, part) => {
|
|
283
|
+
if (!out)
|
|
284
|
+
return part;
|
|
285
|
+
return out + (/^(?:[-+*]|\d+[.)]) /.test(part) ? '\n' : '\n\n') + part;
|
|
286
|
+
}, '');
|
|
287
|
+
}
|
|
288
|
+
/** A GFM table, or the cells as paragraphs if it has no recognisable rows. */
|
|
289
|
+
function table(el) {
|
|
290
|
+
const rows = [];
|
|
291
|
+
const walk = (node, inHead) => {
|
|
292
|
+
for (const c of node.children) {
|
|
293
|
+
if (typeof c === 'string')
|
|
294
|
+
continue;
|
|
295
|
+
if (c.name === 'tr')
|
|
296
|
+
rows.push({ head: inHead || c.children.some((x) => typeof x !== 'string' && x.name === 'th') && rows.length === 0, cells: c.children.filter((x) => typeof x !== 'string' && (x.name === 'td' || x.name === 'th')) });
|
|
297
|
+
else if (c.name === 'thead')
|
|
298
|
+
walk(c, true);
|
|
299
|
+
else if (c.name === 'tbody' || c.name === 'tfoot')
|
|
300
|
+
walk(c, false);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
walk(el, false);
|
|
304
|
+
if (rows.length === 0)
|
|
305
|
+
return blocks(el.children);
|
|
306
|
+
const cell = (c) => inlines(c.children).replace(new RegExp(BR, 'g'), ' ').replace(/\\\n/g, ' ').trim();
|
|
307
|
+
const width = Math.max(...rows.map((r) => r.cells.length));
|
|
308
|
+
const line = (cells) => `| ${Array.from({ length: width }, (_, k) => cells[k] ?? '').join(' | ')} |`;
|
|
309
|
+
const header = rows[0].head ? rows.shift().cells.map(cell) : Array.from({ length: width }, () => '');
|
|
310
|
+
const caption = el.children.find((c) => typeof c !== 'string' && c.name === 'caption');
|
|
311
|
+
const out = [
|
|
312
|
+
line(header),
|
|
313
|
+
`| ${Array.from({ length: width }, () => '---').join(' | ')} |`,
|
|
314
|
+
...rows.map((r) => line(r.cells.map(cell)))
|
|
315
|
+
].join('\n');
|
|
316
|
+
return caption ? [`*${inlines(caption.children)}*`, out] : [out];
|
|
317
|
+
}
|
|
318
|
+
function embed(el) {
|
|
319
|
+
const source = el.children.find((c) => typeof c !== 'string' && c.name === 'source');
|
|
320
|
+
const src = el.attrs.src || el.attrs.data || source?.attrs.src;
|
|
321
|
+
if (!src || !safeUrl(src))
|
|
322
|
+
return '';
|
|
323
|
+
const label = el.attrs.title || (el.name === 'video' ? 'Video' : el.name === 'audio' ? 'Audio' : 'Embedded content');
|
|
324
|
+
return `[${escapeText(label)}](${destination(src)})`;
|
|
325
|
+
}
|
|
326
|
+
/** Render inline nodes to one paragraph of Markdown. */
|
|
327
|
+
function inlines(nodes) {
|
|
328
|
+
return nodes
|
|
329
|
+
.map(inline)
|
|
330
|
+
.join('')
|
|
331
|
+
.replace(/[ \t\n\r\f]+/g, ' ')
|
|
332
|
+
.replace(new RegExp(` ?${BR} ?`, 'g'), BR)
|
|
333
|
+
.trim()
|
|
334
|
+
.replace(new RegExp(`^${BR}+|${BR}+$`, 'g'), '')
|
|
335
|
+
.replace(new RegExp(BR, 'g'), '\\\n');
|
|
336
|
+
}
|
|
337
|
+
function inline(node) {
|
|
338
|
+
if (typeof node === 'string')
|
|
339
|
+
return escapeText(node);
|
|
340
|
+
const { name, attrs, children } = node;
|
|
341
|
+
if (DROP.has(name))
|
|
342
|
+
return '';
|
|
343
|
+
switch (name) {
|
|
344
|
+
case 'br':
|
|
345
|
+
return BR;
|
|
346
|
+
case 'strong':
|
|
347
|
+
case 'b':
|
|
348
|
+
return wrap(children, '**');
|
|
349
|
+
case 'em':
|
|
350
|
+
case 'i':
|
|
351
|
+
case 'cite':
|
|
352
|
+
return wrap(children, '*');
|
|
353
|
+
case 'del':
|
|
354
|
+
case 's':
|
|
355
|
+
case 'strike':
|
|
356
|
+
return wrap(children, '~~');
|
|
357
|
+
case 'code':
|
|
358
|
+
case 'kbd':
|
|
359
|
+
case 'samp':
|
|
360
|
+
case 'tt': {
|
|
361
|
+
const text = textContent(node).replace(/\s+/g, ' ');
|
|
362
|
+
if (!text.trim())
|
|
363
|
+
return text;
|
|
364
|
+
const longest = Math.max(0, ...[...text.matchAll(/`+/g)].map((m) => m[0].length));
|
|
365
|
+
const ticks = '`'.repeat(longest + 1);
|
|
366
|
+
const pad = text.startsWith('`') || text.endsWith('`') ? ' ' : '';
|
|
367
|
+
return `${ticks}${pad}${text}${pad}${ticks}`;
|
|
368
|
+
}
|
|
369
|
+
case 'a': {
|
|
370
|
+
const content = children.map(inline).join('');
|
|
371
|
+
const href = attrs.href?.trim();
|
|
372
|
+
if (!href || href.startsWith('#') && content.trim() === '' || !safeUrl(href))
|
|
373
|
+
return content;
|
|
374
|
+
if (!content.trim())
|
|
375
|
+
return '';
|
|
376
|
+
const title = attrs.title ? ` "${attrs.title.replace(/"/g, '\\"')}"` : '';
|
|
377
|
+
return `[${content.trim()}](${destination(href)}${title})`;
|
|
378
|
+
}
|
|
379
|
+
case 'img': {
|
|
380
|
+
const src = attrs.src?.trim();
|
|
381
|
+
if (!src || !safeUrl(src))
|
|
382
|
+
return '';
|
|
383
|
+
const alt = (attrs.alt ?? '').replace(/[[\]\\]/g, '\\$&');
|
|
384
|
+
const title = attrs.title ? ` "${attrs.title.replace(/"/g, '\\"')}"` : '';
|
|
385
|
+
return `}${title})`;
|
|
386
|
+
}
|
|
387
|
+
case 'input':
|
|
388
|
+
return attrs.type === 'checkbox' ? ('checked' in attrs ? '[x] ' : '[ ] ') : '';
|
|
389
|
+
default:
|
|
390
|
+
if (EMBEDS.has(name))
|
|
391
|
+
return ` ${embed(node)} `;
|
|
392
|
+
// A block element reached inside inline content (a <div> in a link,
|
|
393
|
+
// say) cannot be a block here; its content stays inline.
|
|
394
|
+
return children.map(inline).join('');
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
/** Emphasis around content, with surrounding whitespace moved outside. */
|
|
398
|
+
function wrap(children, delimiter) {
|
|
399
|
+
const content = children.map(inline).join('');
|
|
400
|
+
if (!content.trim())
|
|
401
|
+
return content;
|
|
402
|
+
const lead = /^\s*/.exec(content)[0];
|
|
403
|
+
const trail = /\s*$/.exec(content)[0];
|
|
404
|
+
return `${lead}${delimiter}${content.trim()}${delimiter}${trail}`;
|
|
405
|
+
}
|
|
406
|
+
/** Escape characters that would otherwise become Markdown syntax. */
|
|
407
|
+
function escapeText(text) {
|
|
408
|
+
return text
|
|
409
|
+
.replace(/[\\`*_[\]<>~|]/g, '\\$&')
|
|
410
|
+
// An entity-shaped run would be decoded by the renderer; the text meant it literally.
|
|
411
|
+
.replace(/&(?=#?[A-Za-z0-9]+;)/g, '\\&');
|
|
412
|
+
}
|
|
413
|
+
/** Text that starts a line looking like a heading, list item or quote. */
|
|
414
|
+
function escapeLineStart(paragraph) {
|
|
415
|
+
return paragraph
|
|
416
|
+
.split('\n')
|
|
417
|
+
.map((line) => line
|
|
418
|
+
.replace(/^(#{1,6})(\s|$)/, '\\$1$2')
|
|
419
|
+
.replace(/^([-+])(\s)/, '\\$1$2')
|
|
420
|
+
.replace(/^(\d+)([.)])(\s)/, '$1\\$2$3')
|
|
421
|
+
.replace(/^(=+|-+)$/, '\\$1'))
|
|
422
|
+
.join('\n');
|
|
423
|
+
}
|
|
424
|
+
function destination(url) {
|
|
425
|
+
return url.replace(/ /g, '%20').replace(/\(/g, '%28').replace(/\)/g, '%29');
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Drop `javascript:` and friends. The sanitizer would remove them from the
|
|
429
|
+
* rendered HTML anyway; leaving them out of the Markdown means the source
|
|
430
|
+
* never carries one either.
|
|
431
|
+
*/
|
|
432
|
+
function safeUrl(url) {
|
|
433
|
+
const cleaned = String(url).replace(/[\u0000- \u007f]/g, '').toLowerCase();
|
|
434
|
+
const scheme = /^([a-z][a-z0-9+.-]*):/.exec(cleaned)?.[1];
|
|
435
|
+
return !scheme || ['http', 'https', 'mailto', 'tel', 'ftp'].includes(scheme);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* WordPress's `wpautop`, roughly: turn the blank-line-separated text that
|
|
439
|
+
* classic-editor posts are stored as into paragraphs.
|
|
440
|
+
*
|
|
441
|
+
* A WXR file holds `post_content` as the author saved it, not as the site
|
|
442
|
+
* rendered it — WordPress adds the `<p>` tags at display time. Without this a
|
|
443
|
+
* classic post's paragraphs all run together. Block-editor content is already
|
|
444
|
+
* real HTML (every paragraph is a `<p>` between `<!-- wp:` comments), so it is
|
|
445
|
+
* left alone.
|
|
446
|
+
*
|
|
447
|
+
* @param {string} content
|
|
448
|
+
* @returns {string}
|
|
449
|
+
*/
|
|
450
|
+
export function autop(content) {
|
|
451
|
+
const text = String(content ?? '').replace(/\r\n?/g, '\n');
|
|
452
|
+
if (!text.trim() || /<!--\s*wp:/.test(text))
|
|
453
|
+
return text;
|
|
454
|
+
// Preformatted blocks keep their newlines.
|
|
455
|
+
const preserved = [];
|
|
456
|
+
const protectedText = text.replace(/<pre[\s>][\s\S]*?<\/pre>/gi, (m) => {
|
|
457
|
+
preserved.push(m);
|
|
458
|
+
return `\u0002${preserved.length - 1}\u0002`;
|
|
459
|
+
});
|
|
460
|
+
const blockStart = /^\s*(<\/?(?:p|div|h[1-6]|ul|ol|li|blockquote|pre|table|thead|tbody|tr|td|th|figure|figcaption|hr|section|article|aside|header|footer|iframe|dl|dt|dd|form|address|video|audio)\b|\u0002)/i;
|
|
461
|
+
return protectedText
|
|
462
|
+
.split(/\n\s*\n/)
|
|
463
|
+
.map((chunk) => chunk.trim())
|
|
464
|
+
.filter(Boolean)
|
|
465
|
+
.map((chunk) => (blockStart.test(chunk) ? chunk : `<p>${chunk.replace(/\n/g, '<br />\n')}</p>`))
|
|
466
|
+
.join('\n')
|
|
467
|
+
.replace(/\u0002(\d+)\u0002/g, (_, k) => preserved[Number(k)]);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Unwrap the shortcodes that carry content, leaving the rest as text.
|
|
471
|
+
*
|
|
472
|
+
* `[caption]` wraps nearly every captioned image a classic WordPress post
|
|
473
|
+
* has; left alone it prints as literal brackets around the picture. It
|
|
474
|
+
* becomes a figure, so the caption survives. `[embed]` becomes a link. Other
|
|
475
|
+
* shortcodes belong to plugins that will not exist here, and are left visible
|
|
476
|
+
* so an editor can see something needs replacing rather than having it
|
|
477
|
+
* silently vanish.
|
|
478
|
+
*
|
|
479
|
+
* @param {string} content
|
|
480
|
+
* @returns {string}
|
|
481
|
+
*/
|
|
482
|
+
export function expandShortcodes(content) {
|
|
483
|
+
return String(content ?? '')
|
|
484
|
+
.replace(/\[caption[^\]]*\]([\s\S]*?)\[\/caption\]/gi, (_, inner) => {
|
|
485
|
+
const m = /^(\s*(?:<a\b[^>]*>\s*)?<img\b[^>]*>(?:\s*<\/a>)?)([\s\S]*)$/i.exec(inner);
|
|
486
|
+
return m ? `<figure>${m[1]}<figcaption>${m[2].trim()}</figcaption></figure>` : inner;
|
|
487
|
+
})
|
|
488
|
+
.replace(/\[embed[^\]]*\]\s*(https?:\/\/[^\s[]+)\s*\[\/embed\]/gi, '<p><a href="$1">$1</a></p>');
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* The plain-text summary for an excerpt field: tags stripped, entities
|
|
492
|
+
* decoded, whitespace collapsed, WordPress's `[…]` read as "...".
|
|
493
|
+
*/
|
|
494
|
+
export function plainText(html) {
|
|
495
|
+
return decodeEntities(String(html ?? '')
|
|
496
|
+
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/gi, ' ')
|
|
497
|
+
// Block boundaries separate words; inline tags (`<em>`) must not, or
|
|
498
|
+
// "a <em>soup</em>." reads "a soup ."
|
|
499
|
+
.replace(/<\/?(p|div|br|li|h[1-6]|blockquote|tr|td|th)\b[^>]*>/gi, ' ')
|
|
500
|
+
.replace(/<[^>]+>/g, '')
|
|
501
|
+
.replace(/\[…\]|\[…\]/g, '...'))
|
|
502
|
+
.replace(/\s+/g, ' ')
|
|
503
|
+
.trim();
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* A comment as the plain text this CMS stores comments as.
|
|
507
|
+
*
|
|
508
|
+
* Comments are not Markdown here — they are shown as text — so Markdown
|
|
509
|
+
* escaping would put backslashes in front of every asterisk a reader typed.
|
|
510
|
+
* Paragraph and line breaks are kept; every tag is dropped.
|
|
511
|
+
*/
|
|
512
|
+
export function commentText(html) {
|
|
513
|
+
return decodeEntities(autop(String(html ?? ''))
|
|
514
|
+
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/gi, '')
|
|
515
|
+
.replace(/<br\s*\/?>\s*/gi, '\n')
|
|
516
|
+
.replace(/<\/(p|div|blockquote|li|h[1-6])>/gi, '\n\n')
|
|
517
|
+
.replace(/<[^>]+>/g, ''))
|
|
518
|
+
.split('\n')
|
|
519
|
+
.map((line) => line.replace(/[ \t]+/g, ' ').trim())
|
|
520
|
+
.join('\n')
|
|
521
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
522
|
+
.trim();
|
|
523
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse `--flag` and `--option value` arguments.
|
|
3
|
+
*
|
|
4
|
+
* @param {string[]} argv
|
|
5
|
+
* @param {{ flags?: string[], options?: string[] }} spec
|
|
6
|
+
* @returns {{ flags: Record<string, boolean>, options: Record<string, string>, positional: string[] }}
|
|
7
|
+
*/
|
|
8
|
+
export function parseArgs(argv: string[], spec?: {
|
|
9
|
+
flags?: string[];
|
|
10
|
+
options?: string[];
|
|
11
|
+
}): {
|
|
12
|
+
flags: Record<string, boolean>;
|
|
13
|
+
options: Record<string, string>;
|
|
14
|
+
positional: string[];
|
|
15
|
+
};
|
|
16
|
+
/** The target table's columns, asked once per table per connection. */
|
|
17
|
+
export function tableColumns(db: any, table: any): Promise<any>;
|
|
18
|
+
/** Forget cached columns — for tests that migrate between runs. */
|
|
19
|
+
export function clearColumnCache(db: any): void;
|
|
20
|
+
/**
|
|
21
|
+
* Insert a row and return its id.
|
|
22
|
+
*
|
|
23
|
+
* `RETURNING id` on Postgres, because its adapter only learns the new id from
|
|
24
|
+
* a returned row — a bare INSERT there writes the row and reports null, and
|
|
25
|
+
* the failure surfaces later as a foreign key pointing at nothing.
|
|
26
|
+
*/
|
|
27
|
+
export function insertRow(db: any, table: any, row: any): Promise<number | null>;
|
|
28
|
+
/** Update a row by id with whichever of `row`'s columns the table has. */
|
|
29
|
+
export function updateRow(db: any, table: any, id: any, row: any): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* A stored timestamp, as the app writes them: ISO-8601 UTC with a `Z`.
|
|
32
|
+
*
|
|
33
|
+
* Accepts what the sources produce — ISO strings, WordPress's zone-less
|
|
34
|
+
* `YYYY-MM-DD HH:MM:SS` (read as UTC, so pass the `_gmt` field), Ghost's
|
|
35
|
+
* millisecond ISO — and returns null for nothing or nonsense, including
|
|
36
|
+
* WordPress's `0000-00-00 00:00:00` for "never".
|
|
37
|
+
*/
|
|
38
|
+
export function toTimestamp(value: any): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* The object key behind a media URL.
|
|
41
|
+
*
|
|
42
|
+
* `https://cdn.example.com/2025/11/x.jpeg` is stored as `2025/11/x.jpeg`,
|
|
43
|
+
* because `publicUrl()` prepends the configured domain. Storing the absolute
|
|
44
|
+
* URL instead would produce `/uploads/https%3A%2F%2F...` on any driver.
|
|
45
|
+
*/
|
|
46
|
+
export function objectKey(url: any): string | null;
|
|
47
|
+
/** A MIME type from a file name, for sources that do not say. */
|
|
48
|
+
export function mimeFromName(name: any): any;
|
|
49
|
+
/**
|
|
50
|
+
* A password hash no password can match.
|
|
51
|
+
*
|
|
52
|
+
* Imported authors get an account so their posts keep a byline, but nobody
|
|
53
|
+
* chose a password for it, and inventing one would mean an account anyone
|
|
54
|
+
* holding the importer's output could sign in to. A stored hash has six
|
|
55
|
+
* colon-separated parts; this has two, so `verifyPassword` rejects it before
|
|
56
|
+
* doing any work. The owner signs in by resetting the password, which proves
|
|
57
|
+
* they control the address.
|
|
58
|
+
*/
|
|
59
|
+
export function unusablePassword(): string;
|
|
60
|
+
/**
|
|
61
|
+
* A slug not yet used in `table`, built from `base`.
|
|
62
|
+
*
|
|
63
|
+
* Numbered the way the CMS numbers its own (`jane`, `jane-2`), and checked
|
|
64
|
+
* against the table rather than a local set so it holds across runs.
|
|
65
|
+
*/
|
|
66
|
+
export function uniqueSlug(db: any, table: any, base: any, fallback?: string): Promise<any>;
|
|
67
|
+
/**
|
|
68
|
+
* Run `fn`, writing nothing if `dryRun` is set.
|
|
69
|
+
*
|
|
70
|
+
* A dry run executes the real import inside a transaction and rolls it back,
|
|
71
|
+
* rather than following a separate "pretend" code path. Two paths drift — the
|
|
72
|
+
* pretend one forgets a dedupe rule and reports creates the real one would
|
|
73
|
+
* have skipped — so this reports exactly what a real run would do, because it
|
|
74
|
+
* *is* a real run, undone.
|
|
75
|
+
*/
|
|
76
|
+
export function withDryRun(db: any, dryRun: any, fn: any): Promise<any>;
|
|
77
|
+
/**
|
|
78
|
+
* The account imported content falls back to: the first admin.
|
|
79
|
+
*
|
|
80
|
+
* Required, not optional — a post must have an author, and making one up is
|
|
81
|
+
* not this script's business.
|
|
82
|
+
*/
|
|
83
|
+
export function defaultAuthor(db: any): Promise<any>;
|
|
84
|
+
/**
|
|
85
|
+
* Counts of what happened to each kind of thing, plus notes worth reading.
|
|
86
|
+
*
|
|
87
|
+
* Every importer prints the same shape, so a dry run of a WXR file and of a
|
|
88
|
+
* Ghost export can be compared line for line.
|
|
89
|
+
*/
|
|
90
|
+
export class Report {
|
|
91
|
+
counts: {};
|
|
92
|
+
notes: any[];
|
|
93
|
+
noteCounts: Map<any, any>;
|
|
94
|
+
count(entity: any, outcome: any, n?: number): void;
|
|
95
|
+
/** A note, collapsed by text so one gap does not print a thousand times. */
|
|
96
|
+
note(text: any): void;
|
|
97
|
+
get(entity: any, outcome: any): any;
|
|
98
|
+
toString(): string;
|
|
99
|
+
}
|
|
100
|
+
export const NO_ADMIN_MESSAGE: string;
|