@wrikka/create-docs 0.1.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/README.md +137 -0
- package/bin/cli.js +408 -0
- package/dist/index.cjs +20 -0
- package/dist/index.d.cts +475 -0
- package/dist/index.d.ts +475 -0
- package/dist/index.js +20 -0
- package/docs/_dir.yml +2 -0
- package/docs/config.md +75 -0
- package/docs/data-sources.md +88 -0
- package/docs/deploy.md +38 -0
- package/docs/features.md +51 -0
- package/docs/getting-started.md +42 -0
- package/docs/index.md +34 -0
- package/docs/markdown.md +154 -0
- package/docs/theming.md +53 -0
- package/package.json +142 -0
- package/scripts/generate-docs-index.ts +111 -0
- package/scripts/github-pull.ts +124 -0
- package/src/adapters/config/index.ts +1 -0
- package/src/adapters/config/node-config-loader.ts +36 -0
- package/src/adapters/fs/fs-docs-loader.ts +31 -0
- package/src/adapters/fs/index.ts +12 -0
- package/src/adapters/fs/memory-fs.ts +60 -0
- package/src/adapters/fs/node-fs.ts +116 -0
- package/src/adapters/git/index.ts +164 -0
- package/src/adapters/github/github-pull.ts +340 -0
- package/src/adapters/index.ts +6 -0
- package/src/adapters/velite.ts +112 -0
- package/src/adapters/vite/docs-watcher.ts +36 -0
- package/src/adapters/vite/index.ts +2 -0
- package/src/adapters/vite/polling-watcher.ts +89 -0
- package/src/code-block-enhancements/index.ts +3 -0
- package/src/config/index.ts +15 -0
- package/src/content/index.ts +11 -0
- package/src/content-validation/index.ts +5 -0
- package/src/index.ts +174 -0
- package/src/live-editor/index.ts +7 -0
- package/src/modules/analytics/application/plausible-adapter.ts +103 -0
- package/src/modules/analytics/application/umami-adapter.ts +109 -0
- package/src/modules/analytics/domain/events/index.ts +37 -0
- package/src/modules/analytics/domain/models/index.ts +35 -0
- package/src/modules/analytics/domain/operations/analytics-operations.ts +67 -0
- package/src/modules/analytics/domain/validators/index.ts +50 -0
- package/src/modules/analytics/index.ts +9 -0
- package/src/modules/analytics/ports/analytics-port.ts +17 -0
- package/src/modules/analytics/types/analytics.ts +16 -0
- package/src/modules/api-docs/application/type-docs-adapter.ts +34 -0
- package/src/modules/api-docs/domain/events/index.ts +42 -0
- package/src/modules/api-docs/domain/models/index.ts +40 -0
- package/src/modules/api-docs/domain/operations/api-docs-operations.ts +59 -0
- package/src/modules/api-docs/domain/validators/index.ts +56 -0
- package/src/modules/api-docs/index.ts +8 -0
- package/src/modules/api-docs/ports/api-docs-port.ts +21 -0
- package/src/modules/api-docs/types/api-docs.ts +15 -0
- package/src/modules/api-reference/openapi.ts +166 -0
- package/src/modules/api-reference/orpc.ts +94 -0
- package/src/modules/code-block-enhancements/application/usecases/index.ts +39 -0
- package/src/modules/code-block-enhancements/domain/code-operations.ts +72 -0
- package/src/modules/code-block-enhancements/domain/events/index.ts +58 -0
- package/src/modules/code-block-enhancements/domain/index.ts +11 -0
- package/src/modules/code-block-enhancements/domain/models/index.ts +36 -0
- package/src/modules/code-block-enhancements/domain/validators/index.ts +50 -0
- package/src/modules/code-block-enhancements/index.ts +10 -0
- package/src/modules/code-block-enhancements/ports/index.ts +18 -0
- package/src/modules/code-block-enhancements/types/index.ts +37 -0
- package/src/modules/code-execution/application/sandbox-adapter.ts +44 -0
- package/src/modules/code-execution/domain/events/index.ts +58 -0
- package/src/modules/code-execution/domain/models/index.ts +33 -0
- package/src/modules/code-execution/domain/operations/execution-operations.ts +60 -0
- package/src/modules/code-execution/domain/validators/index.ts +50 -0
- package/src/modules/code-execution/index.ts +8 -0
- package/src/modules/code-execution/ports/execution-port.ts +15 -0
- package/src/modules/code-execution/types/execution.ts +15 -0
- package/src/modules/comments/application/giscus-adapter.ts +55 -0
- package/src/modules/comments/domain/events/index.ts +55 -0
- package/src/modules/comments/domain/models/index.ts +30 -0
- package/src/modules/comments/domain/operations/comment-operations.ts +46 -0
- package/src/modules/comments/domain/validators/index.ts +50 -0
- package/src/modules/comments/index.ts +8 -0
- package/src/modules/comments/ports/comment-port.ts +18 -0
- package/src/modules/comments/types/comments.ts +19 -0
- package/src/modules/config/application/usecases/index.ts +1 -0
- package/src/modules/config/application/usecases/loadConfig.ts +38 -0
- package/src/modules/config/application/workflows/index.ts +1 -0
- package/src/modules/config/application/workflows/validateConfig.ts +14 -0
- package/src/modules/config/domain/events/index.ts +50 -0
- package/src/modules/config/domain/models/index.ts +9 -0
- package/src/modules/config/domain/operations/defaults.ts +74 -0
- package/src/modules/config/domain/operations/index.ts +2 -0
- package/src/modules/config/domain/operations/resolve.ts +40 -0
- package/src/modules/config/domain/validators/index.ts +152 -0
- package/src/modules/config/index.ts +23 -0
- package/src/modules/config/ports/index.ts +15 -0
- package/src/modules/config/types/index.ts +113 -0
- package/src/modules/config/types/public.ts +19 -0
- package/src/modules/content/application/cache/index.ts +6 -0
- package/src/modules/content/application/cache/parse-cache.ts +6 -0
- package/src/modules/content/application/cache/parseCache.ts +56 -0
- package/src/modules/content/application/usecases/index.ts +2 -0
- package/src/modules/content/application/usecases/load-doc-page.ts +1 -0
- package/src/modules/content/application/usecases/loadDocPage.ts +111 -0
- package/src/modules/content/application/usecases/scanDocsDir.ts +105 -0
- package/src/modules/content/application/workflows/index.ts +1 -0
- package/src/modules/content/application/workflows/processDocs.ts +51 -0
- package/src/modules/content/domain/events/index.ts +61 -0
- package/src/modules/content/domain/models/index.ts +13 -0
- package/src/modules/content/domain/operations/build-page.ts +146 -0
- package/src/modules/content/domain/operations/buildPage.ts +93 -0
- package/src/modules/content/domain/operations/index.ts +17 -0
- package/src/modules/content/domain/operations/parse.ts +241 -0
- package/src/modules/content/domain/validators/frontmatter.ts +82 -0
- package/src/modules/content/domain/validators/index.ts +6 -0
- package/src/modules/content/index.ts +27 -0
- package/src/modules/content/ports/index.ts +45 -0
- package/src/modules/content/ports/velite.ts +134 -0
- package/src/modules/content/types/index.ts +76 -0
- package/src/modules/content/types/public.ts +1 -0
- package/src/modules/content-linting/application/builtin-linting-adapter.ts +82 -0
- package/src/modules/content-linting/domain/events/index.ts +58 -0
- package/src/modules/content-linting/domain/models/index.ts +46 -0
- package/src/modules/content-linting/domain/operations/linting-operations.ts +82 -0
- package/src/modules/content-linting/domain/validators/index.ts +50 -0
- package/src/modules/content-linting/index.ts +8 -0
- package/src/modules/content-linting/ports/linting-port.ts +21 -0
- package/src/modules/content-linting/types/linting.ts +18 -0
- package/src/modules/content-validation/application/usecases/index.ts +18 -0
- package/src/modules/content-validation/domain/events/index.ts +7 -0
- package/src/modules/content-validation/domain/index.ts +16 -0
- package/src/modules/content-validation/domain/models/index.ts +33 -0
- package/src/modules/content-validation/domain/operations/index.ts +157 -0
- package/src/modules/content-validation/domain/types/index.ts +17 -0
- package/src/modules/content-validation/domain/validators/index.ts +8 -0
- package/src/modules/content-validation/index.ts +9 -0
- package/src/modules/content-validation/ports/index.ts +15 -0
- package/src/modules/content-validation/types/index.ts +5 -0
- package/src/modules/export/application/puppeteer-export-adapter.ts +63 -0
- package/src/modules/export/domain/events/index.ts +55 -0
- package/src/modules/export/domain/models/index.ts +38 -0
- package/src/modules/export/domain/operations/export-operations.ts +56 -0
- package/src/modules/export/domain/validators/index.ts +52 -0
- package/src/modules/export/index.ts +8 -0
- package/src/modules/export/ports/export-port.ts +15 -0
- package/src/modules/export/types/export.ts +15 -0
- package/src/modules/external-search/application/algolia-adapter.ts +182 -0
- package/src/modules/external-search/application/meilisearch-adapter.ts +161 -0
- package/src/modules/external-search/domain/events/index.ts +42 -0
- package/src/modules/external-search/domain/models/index.ts +42 -0
- package/src/modules/external-search/domain/operations/search-operations.ts +53 -0
- package/src/modules/external-search/domain/validators/index.ts +55 -0
- package/src/modules/external-search/index.ts +9 -0
- package/src/modules/external-search/ports/external-search-port.ts +23 -0
- package/src/modules/external-search/types/search.ts +19 -0
- package/src/modules/git-history/application/simple-git-adapter.ts +46 -0
- package/src/modules/git-history/domain/events/index.ts +34 -0
- package/src/modules/git-history/domain/models/index.ts +25 -0
- package/src/modules/git-history/domain/operations/git-history-operations.ts +56 -0
- package/src/modules/git-history/domain/validators/index.ts +52 -0
- package/src/modules/git-history/index.ts +8 -0
- package/src/modules/git-history/ports/git-history-port.ts +21 -0
- package/src/modules/git-history/types/git-history.ts +15 -0
- package/src/modules/i18n/application/fs-locale-loader.ts +39 -0
- package/src/modules/i18n/domain/events/index.ts +34 -0
- package/src/modules/i18n/domain/models/index.ts +34 -0
- package/src/modules/i18n/domain/operations/locale-operations.ts +74 -0
- package/src/modules/i18n/domain/validators/index.ts +52 -0
- package/src/modules/i18n/index.ts +8 -0
- package/src/modules/i18n/ports/locale-loader-port.ts +18 -0
- package/src/modules/i18n/types/locale.ts +17 -0
- package/src/modules/image-optimization/application/sharp-adapter.ts +58 -0
- package/src/modules/image-optimization/domain/events/index.ts +39 -0
- package/src/modules/image-optimization/domain/models/index.ts +27 -0
- package/src/modules/image-optimization/domain/operations/image-operations.ts +65 -0
- package/src/modules/image-optimization/domain/validators/index.ts +52 -0
- package/src/modules/image-optimization/index.ts +8 -0
- package/src/modules/image-optimization/ports/image-optimizer-port.ts +15 -0
- package/src/modules/image-optimization/types/image.ts +17 -0
- package/src/modules/live-editor/application/usecases/index.ts +60 -0
- package/src/modules/live-editor/domain/events/index.ts +37 -0
- package/src/modules/live-editor/domain/gitOperations.ts +110 -0
- package/src/modules/live-editor/domain/index.ts +15 -0
- package/src/modules/live-editor/domain/models/index.ts +21 -0
- package/src/modules/live-editor/domain/validators/index.ts +55 -0
- package/src/modules/live-editor/index.ts +14 -0
- package/src/modules/live-editor/ports/index.ts +49 -0
- package/src/modules/live-editor/types/index.ts +80 -0
- package/src/modules/live-preview/application/vite-preview-adapter.ts +20 -0
- package/src/modules/live-preview/domain/operations/preview-operations.ts +56 -0
- package/src/modules/live-preview/index.ts +8 -0
- package/src/modules/live-preview/ports/preview-port.ts +20 -0
- package/src/modules/live-preview/types/preview.ts +16 -0
- package/src/modules/mdx/application/mdx-js-adapter.ts +38 -0
- package/src/modules/mdx/domain/operations/parse-mdx.ts +43 -0
- package/src/modules/mdx/index.ts +8 -0
- package/src/modules/mdx/ports/mdx-parser-port.ts +15 -0
- package/src/modules/mdx/types/mdx.ts +14 -0
- package/src/modules/navigation/application/usecases/buildNav.ts +15 -0
- package/src/modules/navigation/application/usecases/buildSidebar.ts +45 -0
- package/src/modules/navigation/application/usecases/index.ts +2 -0
- package/src/modules/navigation/domain/events/index.ts +30 -0
- package/src/modules/navigation/domain/models/index.ts +7 -0
- package/src/modules/navigation/domain/operations/group.ts +79 -0
- package/src/modules/navigation/domain/operations/index.ts +10 -0
- package/src/modules/navigation/domain/operations/sort.ts +27 -0
- package/src/modules/navigation/domain/shared/utils/array.ts +39 -0
- package/src/modules/navigation/domain/validators/index.ts +88 -0
- package/src/modules/navigation/index.ts +15 -0
- package/src/modules/navigation/ports/index.ts +9 -0
- package/src/modules/navigation/types/index.ts +38 -0
- package/src/modules/navigation/types/public.ts +9 -0
- package/src/modules/openapi/application/swagger-parser-adapter.ts +178 -0
- package/src/modules/openapi/domain/operations/parse-openapi.ts +46 -0
- package/src/modules/openapi/index.ts +8 -0
- package/src/modules/openapi/ports/openapi-parser-port.ts +15 -0
- package/src/modules/openapi/types/openapi.ts +37 -0
- package/src/modules/plugin/application/usecases/build-virtual-modules.ts +53 -0
- package/src/modules/plugin/application/usecases/index.ts +1 -0
- package/src/modules/plugin/application/workflows/build-docs.ts +79 -0
- package/src/modules/plugin/application/workflows/index.ts +1 -0
- package/src/modules/plugin/domain/events/index.ts +62 -0
- package/src/modules/plugin/domain/models/index.ts +1 -0
- package/src/modules/plugin/domain/operations/build-virtual.ts +76 -0
- package/src/modules/plugin/domain/operations/index.ts +11 -0
- package/src/modules/plugin/domain/validators/index.ts +30 -0
- package/src/modules/plugin/index.ts +14 -0
- package/src/modules/plugin/ports/index.ts +21 -0
- package/src/modules/plugin/types/index.ts +27 -0
- package/src/modules/plugin/types/public.ts +1 -0
- package/src/modules/search/application/usecases/index.ts +1 -0
- package/src/modules/search/application/usecases/indexPages.ts +15 -0
- package/src/modules/search/domain/events/index.ts +32 -0
- package/src/modules/search/domain/models/index.ts +1 -0
- package/src/modules/search/domain/operations/build-index.ts +6 -0
- package/src/modules/search/domain/operations/buildIndex.ts +70 -0
- package/src/modules/search/domain/operations/index.ts +7 -0
- package/src/modules/search/domain/operations/query.ts +186 -0
- package/src/modules/search/domain/validators/index.ts +32 -0
- package/src/modules/search/index.ts +9 -0
- package/src/modules/search/types/index.ts +22 -0
- package/src/modules/search/types/public.ts +1 -0
- package/src/modules/search-analytics/application/local-storage-adapter.ts +68 -0
- package/src/modules/search-analytics/domain/operations/search-analytics-operations.ts +74 -0
- package/src/modules/search-analytics/index.ts +8 -0
- package/src/modules/search-analytics/ports/search-analytics-port.ts +20 -0
- package/src/modules/search-analytics/types/search-analytics.ts +16 -0
- package/src/modules/search-highlighting/application/dom-highlighting-adapter.ts +36 -0
- package/src/modules/search-highlighting/domain/operations/highlighting-operations.ts +72 -0
- package/src/modules/search-highlighting/index.ts +8 -0
- package/src/modules/search-highlighting/ports/highlighting-port.ts +14 -0
- package/src/modules/search-highlighting/types/highlighting.ts +15 -0
- package/src/modules/seo-optimization/application/usecases/index.ts +18 -0
- package/src/modules/seo-optimization/domain/index.ts +12 -0
- package/src/modules/seo-optimization/domain/seoOperations.ts +92 -0
- package/src/modules/seo-optimization/index.ts +8 -0
- package/src/modules/seo-optimization/ports/index.ts +18 -0
- package/src/modules/seo-optimization/types/index.ts +41 -0
- package/src/modules/theme/application/css-theme-adapter.ts +50 -0
- package/src/modules/theme/domain/operations/theme-operations.ts +68 -0
- package/src/modules/theme/index.ts +8 -0
- package/src/modules/theme/ports/theme-port.ts +8 -0
- package/src/modules/theme/types/theme.ts +12 -0
- package/src/modules/toc/application/markdown-toc-adapter.ts +106 -0
- package/src/modules/toc/domain/operations/toc-operations.ts +92 -0
- package/src/modules/toc/index.ts +8 -0
- package/src/modules/toc/ports/toc-port.ts +21 -0
- package/src/modules/toc/types/toc.ts +17 -0
- package/src/modules/toc-generator/application/usecases/index.ts +30 -0
- package/src/modules/toc-generator/domain/index.ts +12 -0
- package/src/modules/toc-generator/domain/tocOperations.ts +104 -0
- package/src/modules/toc-generator/index.ts +9 -0
- package/src/modules/toc-generator/ports/index.ts +20 -0
- package/src/modules/toc-generator/types/index.ts +50 -0
- package/src/modules/version-control/domain/events/index.ts +39 -0
- package/src/modules/version-control/domain/models/index.ts +25 -0
- package/src/modules/version-control/domain/validators/index.ts +50 -0
- package/src/modules/versioning/application/fs-version-loader.ts +44 -0
- package/src/modules/versioning/domain/operations/versioning-operations.ts +80 -0
- package/src/modules/versioning/index.ts +8 -0
- package/src/modules/versioning/ports/version-loader-port.ts +18 -0
- package/src/modules/versioning/types/versioning.ts +17 -0
- package/src/modules/workflow/domain/events/index.ts +55 -0
- package/src/modules/workflow/domain/models/index.ts +40 -0
- package/src/modules/workflow/domain/validators/index.ts +50 -0
- package/src/modules/yaml-parser/application/js-yaml-adapter.ts +34 -0
- package/src/modules/yaml-parser/domain/operations/parse-yaml.ts +58 -0
- package/src/modules/yaml-parser/index.ts +7 -0
- package/src/modules/yaml-parser/ports/yaml-parser-port.ts +18 -0
- package/src/navigation/index.ts +9 -0
- package/src/plugin/index.ts +4 -0
- package/src/presentation/index.ts +1 -0
- package/src/presentation/live-editor/index.ts +22 -0
- package/src/presentation/live-editor/live-editor-component.ts +219 -0
- package/src/presentation/live-editor/virtual-module.ts +16 -0
- package/src/presentation/solid/CodeBlock.tsx +120 -0
- package/src/presentation/solid/Toc.tsx +58 -0
- package/src/presentation/solid/index.ts +11 -0
- package/src/presentation/vite-plugin/docs-plugin.ts +212 -0
- package/src/presentation/vite-plugin/index.ts +9 -0
- package/src/presentation/vite-plugin/transform-markdown.ts +26 -0
- package/src/runtime/analytics.ts +59 -0
- package/src/runtime/api-diff.ts +115 -0
- package/src/runtime/app.tsx +32 -0
- package/src/runtime/components/AccentPicker.tsx +114 -0
- package/src/runtime/components/ApiPlayground.tsx +332 -0
- package/src/runtime/components/AskAiDialog.tsx +127 -0
- package/src/runtime/components/BackToTop.tsx +38 -0
- package/src/runtime/components/Banner.tsx +75 -0
- package/src/runtime/components/Breadcrumbs.tsx +42 -0
- package/src/runtime/components/CollectionDropdown.tsx +85 -0
- package/src/runtime/components/CustomizeDrawer.tsx +195 -0
- package/src/runtime/components/DocMarkdown.tsx +579 -0
- package/src/runtime/components/DocPrevNext.tsx +54 -0
- package/src/runtime/components/DocToc.tsx +147 -0
- package/src/runtime/components/DocsDropdown.tsx +184 -0
- package/src/runtime/components/Footer.tsx +52 -0
- package/src/runtime/components/GitHubAuth.tsx +82 -0
- package/src/runtime/components/GitHubStats.tsx +73 -0
- package/src/runtime/components/Head.tsx +225 -0
- package/src/runtime/components/LocaleDropdown.tsx +75 -0
- package/src/runtime/components/MobileBottomNav.tsx +111 -0
- package/src/runtime/components/NotFound.tsx +139 -0
- package/src/runtime/components/PageActions.tsx +144 -0
- package/src/runtime/components/RelatedDocs.tsx +50 -0
- package/src/runtime/components/ScrollProgress.tsx +32 -0
- package/src/runtime/components/SearchPalette.tsx +333 -0
- package/src/runtime/components/ShowcaseCard.tsx +87 -0
- package/src/runtime/components/SidebarNav.tsx +237 -0
- package/src/runtime/components/Skeleton.tsx +39 -0
- package/src/runtime/components/ThemeToggle.tsx +26 -0
- package/src/runtime/components/TopNav.tsx +270 -0
- package/src/runtime/components/VersionDropdown.tsx +189 -0
- package/src/runtime/components/markdown/components.ts +280 -0
- package/src/runtime/config.ts +225 -0
- package/src/runtime/content.ts +451 -0
- package/src/runtime/context.tsx +30 -0
- package/src/runtime/data.ts +93 -0
- package/src/runtime/github.ts +226 -0
- package/src/runtime/icons.ts +32 -0
- package/src/runtime/index.ts +153 -0
- package/src/runtime/layouts/DocsLayout.tsx +144 -0
- package/src/runtime/markdown-content.css +996 -0
- package/src/runtime/pages/AbTestPage.tsx +88 -0
- package/src/runtime/pages/AnalyticsPage.tsx +90 -0
- package/src/runtime/pages/ApiDiffPage.tsx +86 -0
- package/src/runtime/pages/ApiEndpointPage.tsx +248 -0
- package/src/runtime/pages/BuilderPage.tsx +150 -0
- package/src/runtime/pages/ChangelogPage.tsx +210 -0
- package/src/runtime/pages/CollectionPage.tsx +140 -0
- package/src/runtime/pages/CommunityPage.tsx +384 -0
- package/src/runtime/pages/CreatePage.tsx +448 -0
- package/src/runtime/pages/DocPage.tsx +193 -0
- package/src/runtime/pages/EditPage.tsx +201 -0
- package/src/runtime/pages/HomePage.tsx +187 -0
- package/src/runtime/pages/IssuesPage.tsx +140 -0
- package/src/runtime/pages/OAuthCallbackPage.tsx +80 -0
- package/src/runtime/pages/PluginsPage.tsx +249 -0
- package/src/runtime/pages/ShowcasePage.tsx +202 -0
- package/src/runtime/pwa.ts +39 -0
- package/src/runtime/router.tsx +192 -0
- package/src/runtime/seo.ts +192 -0
- package/src/runtime/theme.css +175 -0
- package/src/runtime/theme.ts +224 -0
- package/src/runtime/types.ts +217 -0
- package/src/search/index.ts +6 -0
- package/src/seo-optimization/index.ts +4 -0
- package/src/shared/constants/index.ts +26 -0
- package/src/shared/errors/index.ts +195 -0
- package/src/shared/index.ts +27 -0
- package/src/shared/types/brand.ts +14 -0
- package/src/shared/types/client.d.ts +45 -0
- package/src/shared/types/either.ts +38 -0
- package/src/shared/types/index.ts +42 -0
- package/src/shared/types/option.ts +52 -0
- package/src/shared/types/result.ts +81 -0
- package/src/shared/utils/array.ts +97 -0
- package/src/shared/utils/index.ts +46 -0
- package/src/shared/utils/object.ts +47 -0
- package/src/shared/utils/string.ts +74 -0
- package/src/toc-generator/index.ts +1 -0
- package/src/types/js-yaml.d.ts +42 -0
- package/src/worker.ts +462 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain events for content linting
|
|
3
|
+
*/
|
|
4
|
+
export interface LintingStartedEvent {
|
|
5
|
+
readonly type: "LINTING_STARTED";
|
|
6
|
+
readonly timestamp: number;
|
|
7
|
+
readonly filePath: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface LintingCompletedEvent {
|
|
11
|
+
readonly type: "LINTING_COMPLETED";
|
|
12
|
+
readonly timestamp: number;
|
|
13
|
+
readonly filePath: string;
|
|
14
|
+
readonly issueCount: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface IssueFoundEvent {
|
|
18
|
+
readonly type: "ISSUE_FOUND";
|
|
19
|
+
readonly timestamp: number;
|
|
20
|
+
readonly ruleId: string;
|
|
21
|
+
readonly message: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type ContentLintingDomainEvent =
|
|
25
|
+
| LintingStartedEvent
|
|
26
|
+
| LintingCompletedEvent
|
|
27
|
+
| IssueFoundEvent;
|
|
28
|
+
|
|
29
|
+
export const createLintingStartedEvent = (
|
|
30
|
+
filePath: string,
|
|
31
|
+
now: number = Date.now(),
|
|
32
|
+
): LintingStartedEvent => ({
|
|
33
|
+
type: "LINTING_STARTED",
|
|
34
|
+
timestamp: now,
|
|
35
|
+
filePath,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const createLintingCompletedEvent = (
|
|
39
|
+
filePath: string,
|
|
40
|
+
issueCount: number,
|
|
41
|
+
now: number = Date.now(),
|
|
42
|
+
): LintingCompletedEvent => ({
|
|
43
|
+
type: "LINTING_COMPLETED",
|
|
44
|
+
timestamp: now,
|
|
45
|
+
filePath,
|
|
46
|
+
issueCount,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const createIssueFoundEvent = (
|
|
50
|
+
ruleId: string,
|
|
51
|
+
message: string,
|
|
52
|
+
now: number = Date.now(),
|
|
53
|
+
): IssueFoundEvent => ({
|
|
54
|
+
type: "ISSUE_FOUND",
|
|
55
|
+
timestamp: now,
|
|
56
|
+
ruleId,
|
|
57
|
+
message,
|
|
58
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain models for content linting
|
|
3
|
+
*/
|
|
4
|
+
export interface LintRule {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly description: string;
|
|
8
|
+
readonly severity: "error" | "warning" | "info";
|
|
9
|
+
readonly enabled: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface LintIssue {
|
|
13
|
+
readonly ruleId: string;
|
|
14
|
+
readonly message: string;
|
|
15
|
+
readonly line: number;
|
|
16
|
+
readonly column: number;
|
|
17
|
+
readonly severity: "error" | "warning" | "info";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const createLintRule = (
|
|
21
|
+
id: string,
|
|
22
|
+
name: string,
|
|
23
|
+
description: string,
|
|
24
|
+
severity: LintRule["severity"],
|
|
25
|
+
enabled: boolean = true,
|
|
26
|
+
): LintRule => ({
|
|
27
|
+
id,
|
|
28
|
+
name,
|
|
29
|
+
description,
|
|
30
|
+
severity,
|
|
31
|
+
enabled,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const createLintIssue = (
|
|
35
|
+
ruleId: string,
|
|
36
|
+
message: string,
|
|
37
|
+
line: number,
|
|
38
|
+
column: number,
|
|
39
|
+
severity: LintIssue["severity"],
|
|
40
|
+
): LintIssue => ({
|
|
41
|
+
ruleId,
|
|
42
|
+
message,
|
|
43
|
+
line,
|
|
44
|
+
column,
|
|
45
|
+
severity,
|
|
46
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure content linting operations.
|
|
3
|
+
* No I/O. No exceptions thrown. Returns Result types.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Result } from "@create-docs/shared/types";
|
|
7
|
+
import { err, ok } from "@create-docs/shared/types";
|
|
8
|
+
import type { LintResult, LintRule } from "../../types/linting";
|
|
9
|
+
|
|
10
|
+
export type LintingError = {
|
|
11
|
+
readonly kind: "linting-error";
|
|
12
|
+
readonly message: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Check for missing title in frontmatter.
|
|
17
|
+
*/
|
|
18
|
+
export const checkMissingTitle = (frontmatter: unknown): LintResult | null => {
|
|
19
|
+
if (!frontmatter || typeof frontmatter !== "object") return null;
|
|
20
|
+
const fm = frontmatter as Record<string, unknown>;
|
|
21
|
+
if (!fm.title) {
|
|
22
|
+
return {
|
|
23
|
+
ruleId: "missing-title",
|
|
24
|
+
message: "Document is missing a title",
|
|
25
|
+
line: 1,
|
|
26
|
+
column: 1,
|
|
27
|
+
severity: "error",
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Check for missing description in frontmatter.
|
|
35
|
+
*/
|
|
36
|
+
export const checkMissingDescription = (
|
|
37
|
+
frontmatter: unknown,
|
|
38
|
+
): LintResult | null => {
|
|
39
|
+
if (!frontmatter || typeof frontmatter !== "object") return null;
|
|
40
|
+
const fm = frontmatter as Record<string, unknown>;
|
|
41
|
+
if (!fm.description) {
|
|
42
|
+
return {
|
|
43
|
+
ruleId: "missing-description",
|
|
44
|
+
message: "Document is missing a description",
|
|
45
|
+
line: 1,
|
|
46
|
+
column: 1,
|
|
47
|
+
severity: "warning",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Run all lint rules on content.
|
|
55
|
+
*/
|
|
56
|
+
export const runLintRules = (
|
|
57
|
+
_content: string,
|
|
58
|
+
frontmatter: unknown,
|
|
59
|
+
rules: readonly LintRule[],
|
|
60
|
+
): Result<readonly LintResult[], LintingError> => {
|
|
61
|
+
try {
|
|
62
|
+
const results: LintResult[] = [];
|
|
63
|
+
|
|
64
|
+
for (const rule of rules) {
|
|
65
|
+
if (rule.id === "missing-title") {
|
|
66
|
+
const result = checkMissingTitle(frontmatter);
|
|
67
|
+
if (result) results.push(result);
|
|
68
|
+
}
|
|
69
|
+
if (rule.id === "missing-description") {
|
|
70
|
+
const result = checkMissingDescription(frontmatter);
|
|
71
|
+
if (result) results.push(result);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return ok(results);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
return err({
|
|
78
|
+
kind: "linting-error",
|
|
79
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Content Linting Domain Schemas - Arktype validation schemas
|
|
2
|
+
// Following /follow-arktype workflow for type-safe runtime validation
|
|
3
|
+
|
|
4
|
+
import { type Type, type } from "arktype";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Rule Name Schema
|
|
8
|
+
*/
|
|
9
|
+
export const ruleNameSchema: Type = type("string >= 1");
|
|
10
|
+
|
|
11
|
+
export type RuleName = typeof ruleNameSchema.infer;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Severity Schema
|
|
15
|
+
*/
|
|
16
|
+
export const severitySchema: Type = type("'error' | 'warning' | 'info'");
|
|
17
|
+
|
|
18
|
+
export type Severity = typeof severitySchema.infer;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Validation errors
|
|
22
|
+
*/
|
|
23
|
+
export class ValidationError extends Error {
|
|
24
|
+
constructor(message: string) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "ValidationError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Validate rule name using Arktype
|
|
32
|
+
*/
|
|
33
|
+
export const validateRuleName = (name: unknown): RuleName => {
|
|
34
|
+
const result = ruleNameSchema(name);
|
|
35
|
+
if (result instanceof type.errors) {
|
|
36
|
+
throw new ValidationError("Rule name must be a non-empty string");
|
|
37
|
+
}
|
|
38
|
+
return result as RuleName;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Validate severity using Arktype
|
|
43
|
+
*/
|
|
44
|
+
export const validateSeverity = (severity: unknown): Severity => {
|
|
45
|
+
const result = severitySchema(severity);
|
|
46
|
+
if (result instanceof type.errors) {
|
|
47
|
+
throw new ValidationError("Invalid severity level");
|
|
48
|
+
}
|
|
49
|
+
return result as Severity;
|
|
50
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API for the content-linting module.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { createBuiltinLintingAdapter } from "./application/builtin-linting-adapter";
|
|
6
|
+
export * from "./domain/operations/linting-operations";
|
|
7
|
+
export * from "./ports/linting-port";
|
|
8
|
+
export * from "./types/linting";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Port for content linting operations.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type LintingPort = {
|
|
6
|
+
/**
|
|
7
|
+
* Lint content file.
|
|
8
|
+
*/
|
|
9
|
+
readonly lint: (
|
|
10
|
+
filePath: string,
|
|
11
|
+
rules: readonly unknown[],
|
|
12
|
+
) => Promise<readonly unknown[]>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Fix lint issues.
|
|
16
|
+
*/
|
|
17
|
+
readonly fix: (
|
|
18
|
+
filePath: string,
|
|
19
|
+
results: readonly unknown[],
|
|
20
|
+
) => Promise<void>;
|
|
21
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content linting types for validating documentation content.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type LintRule = {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly description: string;
|
|
9
|
+
readonly severity: "error" | "warning" | "info";
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type LintResult = {
|
|
13
|
+
readonly ruleId: string;
|
|
14
|
+
readonly message: string;
|
|
15
|
+
readonly line: number;
|
|
16
|
+
readonly column: number;
|
|
17
|
+
readonly severity: "error" | "warning" | "info";
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Validation Use Cases
|
|
3
|
+
*
|
|
4
|
+
* Orchestration layer for content validation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { validateContent } from "../../domain";
|
|
8
|
+
import type { ValidationOptions, ValidationResult } from "../../types";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Validate content
|
|
12
|
+
*/
|
|
13
|
+
export const validate = (
|
|
14
|
+
content: string,
|
|
15
|
+
options: ValidationOptions = {},
|
|
16
|
+
): ValidationResult => {
|
|
17
|
+
return validateContent(content, options);
|
|
18
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Validation Domain
|
|
3
|
+
*
|
|
4
|
+
* Pure business logic for content validation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export * from "./events";
|
|
8
|
+
export * from "./models";
|
|
9
|
+
export {
|
|
10
|
+
validateCodeBlocks,
|
|
11
|
+
validateContent,
|
|
12
|
+
validateHeadings,
|
|
13
|
+
validateImages,
|
|
14
|
+
validateLinks,
|
|
15
|
+
} from "./operations";
|
|
16
|
+
export * from "./validators";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Validation Domain Models
|
|
3
|
+
*
|
|
4
|
+
* Readonly data models for content validation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Validation error model
|
|
9
|
+
*/
|
|
10
|
+
export interface ValidationError {
|
|
11
|
+
readonly message: string;
|
|
12
|
+
readonly line?: number;
|
|
13
|
+
readonly column?: number;
|
|
14
|
+
readonly severity: "error" | "warning" | "info";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Validation result model
|
|
19
|
+
*/
|
|
20
|
+
export interface ValidationResult {
|
|
21
|
+
readonly valid: boolean;
|
|
22
|
+
readonly errors: readonly ValidationError[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Validation options model
|
|
27
|
+
*/
|
|
28
|
+
export interface ValidationOptions {
|
|
29
|
+
readonly checkHeadings?: boolean;
|
|
30
|
+
readonly checkLinks?: boolean;
|
|
31
|
+
readonly checkImages?: boolean;
|
|
32
|
+
readonly checkCodeBlocks?: boolean;
|
|
33
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Validation Operations
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for content validation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
ValidationError,
|
|
9
|
+
ValidationOptions,
|
|
10
|
+
ValidationResult,
|
|
11
|
+
} from "../types";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Validate heading hierarchy
|
|
15
|
+
*/
|
|
16
|
+
export const validateHeadings = (content: string): ValidationError[] => {
|
|
17
|
+
const errors: ValidationError[] = [];
|
|
18
|
+
const lines = content.split("\n");
|
|
19
|
+
let lastLevel = 0;
|
|
20
|
+
|
|
21
|
+
for (const line of lines) {
|
|
22
|
+
const match = line.match(/^(#{1,6})\s+(.+)$/);
|
|
23
|
+
if (match) {
|
|
24
|
+
const level = match[1].length;
|
|
25
|
+
const lineNum = lines.indexOf(line) + 1;
|
|
26
|
+
|
|
27
|
+
if (level > lastLevel + 1) {
|
|
28
|
+
errors.push({
|
|
29
|
+
message: `Heading level ${level} should not be more than one level deeper than ${lastLevel}`,
|
|
30
|
+
line: lineNum,
|
|
31
|
+
severity: "warning",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
lastLevel = level;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return errors;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Validate links
|
|
44
|
+
*/
|
|
45
|
+
export const validateLinks = (content: string): ValidationError[] => {
|
|
46
|
+
const errors: ValidationError[] = [];
|
|
47
|
+
const lines = content.split("\n");
|
|
48
|
+
|
|
49
|
+
for (const line of lines) {
|
|
50
|
+
const linkMatch = line.match(/\[([^\]]+)\]\(([^)]+)\)/);
|
|
51
|
+
if (linkMatch) {
|
|
52
|
+
const url = linkMatch[2];
|
|
53
|
+
const lineNum = lines.indexOf(line) + 1;
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
!url.startsWith("http") &&
|
|
57
|
+
!url.startsWith("#") &&
|
|
58
|
+
!url.startsWith("/")
|
|
59
|
+
) {
|
|
60
|
+
errors.push({
|
|
61
|
+
message: `Link "${url}" should be absolute or start with # or /`,
|
|
62
|
+
line: lineNum,
|
|
63
|
+
severity: "warning",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return errors;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Validate images
|
|
74
|
+
*/
|
|
75
|
+
export const validateImages = (content: string): ValidationError[] => {
|
|
76
|
+
const errors: ValidationError[] = [];
|
|
77
|
+
const lines = content.split("\n");
|
|
78
|
+
|
|
79
|
+
for (const line of lines) {
|
|
80
|
+
const imageMatch = line.match(/!\[([^\]]*)\]\(([^)]+)\)/);
|
|
81
|
+
if (imageMatch) {
|
|
82
|
+
const alt = imageMatch[1];
|
|
83
|
+
const lineNum = lines.indexOf(line) + 1;
|
|
84
|
+
|
|
85
|
+
if (!alt) {
|
|
86
|
+
errors.push({
|
|
87
|
+
message: "Image should have alt text",
|
|
88
|
+
line: lineNum,
|
|
89
|
+
severity: "error",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return errors;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Validate code blocks
|
|
100
|
+
*/
|
|
101
|
+
export const validateCodeBlocks = (content: string): ValidationError[] => {
|
|
102
|
+
const errors: ValidationError[] = [];
|
|
103
|
+
const lines = content.split("\n");
|
|
104
|
+
let inCodeBlock = false;
|
|
105
|
+
let codeBlockStart = 0;
|
|
106
|
+
|
|
107
|
+
for (const line of lines) {
|
|
108
|
+
const codeMatch = line.match(/^```(\w+)?$/);
|
|
109
|
+
if (codeMatch && !inCodeBlock) {
|
|
110
|
+
inCodeBlock = true;
|
|
111
|
+
codeBlockStart = lines.indexOf(line) + 1;
|
|
112
|
+
} else if (line === "```" && inCodeBlock) {
|
|
113
|
+
inCodeBlock = false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (inCodeBlock) {
|
|
118
|
+
errors.push({
|
|
119
|
+
message: "Unclosed code block",
|
|
120
|
+
line: codeBlockStart,
|
|
121
|
+
severity: "error",
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return errors;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Validate content
|
|
130
|
+
*/
|
|
131
|
+
export const validateContent = (
|
|
132
|
+
content: string,
|
|
133
|
+
options: ValidationOptions = {},
|
|
134
|
+
): ValidationResult => {
|
|
135
|
+
const errors: ValidationError[] = [];
|
|
136
|
+
|
|
137
|
+
if (options.checkHeadings !== false) {
|
|
138
|
+
errors.push(...validateHeadings(content));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (options.checkLinks !== false) {
|
|
142
|
+
errors.push(...validateLinks(content));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (options.checkImages !== false) {
|
|
146
|
+
errors.push(...validateImages(content));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (options.checkCodeBlocks !== false) {
|
|
150
|
+
errors.push(...validateCodeBlocks(content));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
valid: errors.filter((e) => e.severity === "error").length === 0,
|
|
155
|
+
errors,
|
|
156
|
+
};
|
|
157
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type ValidationError = Readonly<{
|
|
2
|
+
message: string;
|
|
3
|
+
line?: number;
|
|
4
|
+
severity: "error" | "warning";
|
|
5
|
+
}>;
|
|
6
|
+
|
|
7
|
+
export type ValidationOptions = Readonly<{
|
|
8
|
+
checkHeadings?: boolean;
|
|
9
|
+
checkLinks?: boolean;
|
|
10
|
+
checkImages?: boolean;
|
|
11
|
+
checkCodeBlocks?: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
|
|
14
|
+
export type ValidationResult = Readonly<{
|
|
15
|
+
valid: boolean;
|
|
16
|
+
errors: readonly ValidationError[];
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Validation Ports
|
|
3
|
+
*
|
|
4
|
+
* Module-specific interfaces for content validation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ValidationOptions, ValidationResult } from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Content validator interface
|
|
11
|
+
*/
|
|
12
|
+
export interface ContentValidator {
|
|
13
|
+
/** Validate content */
|
|
14
|
+
validate(content: string, options?: ValidationOptions): ValidationResult;
|
|
15
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Puppeteer export adapter implementation.
|
|
3
|
+
* Provides PDF/EPUB export using Puppeteer.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { processExportResult } from "../domain/operations/export-operations";
|
|
7
|
+
import type { ExportPort } from "../ports/export-port";
|
|
8
|
+
import type { ExportConfig } from "../types/export";
|
|
9
|
+
|
|
10
|
+
const PUPPETEER_MISSING_ERROR =
|
|
11
|
+
"Puppeteer is not installed. PDF/EPUB export requires the puppeteer package and a Chromium binary.";
|
|
12
|
+
|
|
13
|
+
export const createPuppeteerExportAdapter = (): ExportPort => ({
|
|
14
|
+
exportToPdf: async (_content: string, config?: unknown) => {
|
|
15
|
+
try {
|
|
16
|
+
if (typeof window !== "undefined") {
|
|
17
|
+
return processExportResult(
|
|
18
|
+
false,
|
|
19
|
+
"",
|
|
20
|
+
"PDF export is only supported in a Node.js build environment with Puppeteer.",
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const exportConfig = config as ExportConfig;
|
|
25
|
+
if (!exportConfig?.outputDir) {
|
|
26
|
+
return processExportResult(false, "", "Output directory not specified");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return processExportResult(false, "", PUPPETEER_MISSING_ERROR);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return processExportResult(
|
|
32
|
+
false,
|
|
33
|
+
"",
|
|
34
|
+
error instanceof Error ? error.message : "Unknown error",
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
exportToEpub: async (_content: string, config?: unknown) => {
|
|
40
|
+
try {
|
|
41
|
+
if (typeof window !== "undefined") {
|
|
42
|
+
return processExportResult(
|
|
43
|
+
false,
|
|
44
|
+
"",
|
|
45
|
+
"EPUB export is only supported in a Node.js build environment with Puppeteer.",
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const exportConfig = config as ExportConfig;
|
|
50
|
+
if (!exportConfig?.outputDir) {
|
|
51
|
+
return processExportResult(false, "", "Output directory not specified");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return processExportResult(false, "", PUPPETEER_MISSING_ERROR);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return processExportResult(
|
|
57
|
+
false,
|
|
58
|
+
"",
|
|
59
|
+
error instanceof Error ? error.message : "Unknown error",
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
});
|