@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,15 @@
|
|
|
1
|
+
export * from "./application/usecases";
|
|
2
|
+
export {
|
|
3
|
+
navGenerated,
|
|
4
|
+
navRebuilt,
|
|
5
|
+
sidebarGroupBuilt,
|
|
6
|
+
} from "./domain/events";
|
|
7
|
+
export * from "./domain/operations";
|
|
8
|
+
export {
|
|
9
|
+
validateNavItem,
|
|
10
|
+
validateNavSection,
|
|
11
|
+
validateSidebarGroup,
|
|
12
|
+
validateSidebarItem,
|
|
13
|
+
} from "./domain/validators";
|
|
14
|
+
export type { ContentSource } from "./ports";
|
|
15
|
+
export * from "./types/public";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navigation module ports — interfaces to other modules (no I/O).
|
|
3
|
+
*/
|
|
4
|
+
import type { DocFile } from "@create-docs/modules/content";
|
|
5
|
+
|
|
6
|
+
/** Read access to the content module's scanned files. */
|
|
7
|
+
export interface ContentSource {
|
|
8
|
+
readonly allFiles: () => readonly DocFile[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Brand } from "@create-docs/shared/types";
|
|
2
|
+
|
|
3
|
+
export type NavItemHref = Brand<string, "NavItemHref">;
|
|
4
|
+
export const NavItemHref = (s: string): NavItemHref => s as NavItemHref;
|
|
5
|
+
|
|
6
|
+
export type BadgeVariant = "default" | "success" | "warning" | "danger";
|
|
7
|
+
|
|
8
|
+
export interface NavItem {
|
|
9
|
+
readonly label: string;
|
|
10
|
+
readonly href?: string;
|
|
11
|
+
readonly items?: readonly NavItem[];
|
|
12
|
+
readonly badge?: string;
|
|
13
|
+
readonly icon?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface NavSection {
|
|
17
|
+
readonly title: string;
|
|
18
|
+
readonly items: readonly NavItem[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SidebarItem {
|
|
22
|
+
readonly title: string;
|
|
23
|
+
readonly slug: string;
|
|
24
|
+
readonly badge?: string;
|
|
25
|
+
readonly badgeVariant?: BadgeVariant;
|
|
26
|
+
readonly items?: readonly SidebarItem[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface SidebarGroup {
|
|
30
|
+
readonly title: string;
|
|
31
|
+
readonly icon?: string;
|
|
32
|
+
readonly items: readonly SidebarItem[];
|
|
33
|
+
readonly collapsed?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface Sidebar {
|
|
37
|
+
readonly groups: readonly SidebarGroup[];
|
|
38
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swagger-parser adapter implementation.
|
|
3
|
+
* Provides OpenAPI 3 schema parsing and validation using js-yaml and native fetch.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { parseError } from "@create-docs/shared/errors";
|
|
7
|
+
import { JSON_SCHEMA, load } from "js-yaml";
|
|
8
|
+
import type { OpenApiParserPort } from "../ports/openapi-parser-port";
|
|
9
|
+
import type {
|
|
10
|
+
OpenApiEndpoint,
|
|
11
|
+
OpenApiMediaType,
|
|
12
|
+
OpenApiParameter,
|
|
13
|
+
OpenApiRequestBody,
|
|
14
|
+
OpenApiResponse,
|
|
15
|
+
} from "../types/openapi";
|
|
16
|
+
|
|
17
|
+
const loadRaw = async (source: string): Promise<string> => {
|
|
18
|
+
if (/^https?:\/\//i.test(source)) {
|
|
19
|
+
const response = await fetch(source);
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
22
|
+
}
|
|
23
|
+
return response.text();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (source.startsWith("file://")) {
|
|
27
|
+
return Bun.file(source.slice(7)).text();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (/\.(?:yaml|yml|json)$/i.test(source)) {
|
|
31
|
+
try {
|
|
32
|
+
return await Bun.file(source).text();
|
|
33
|
+
} catch {
|
|
34
|
+
// Fall through and treat the source as raw text.
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return source;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const parseText = (raw: string): unknown => {
|
|
42
|
+
const text = raw.trim();
|
|
43
|
+
if (text.startsWith("{") || text.startsWith("[")) {
|
|
44
|
+
return JSON.parse(text);
|
|
45
|
+
}
|
|
46
|
+
return load(text, { schema: JSON_SCHEMA });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const toParameter = (value: unknown): OpenApiParameter => {
|
|
50
|
+
const p = value as Record<string, unknown>;
|
|
51
|
+
return {
|
|
52
|
+
name: typeof p.name === "string" ? p.name : "",
|
|
53
|
+
in: (p.in as OpenApiParameter["in"]) ?? "query",
|
|
54
|
+
required: Boolean(p.required),
|
|
55
|
+
schema: p.schema,
|
|
56
|
+
description: typeof p.description === "string" ? p.description : undefined,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const toMediaTypes = (
|
|
61
|
+
value: unknown,
|
|
62
|
+
): Readonly<Record<string, OpenApiMediaType>> => {
|
|
63
|
+
if (!value || typeof value !== "object") return {};
|
|
64
|
+
const record: Record<string, OpenApiMediaType> = {};
|
|
65
|
+
for (const [key, media] of Object.entries(value as Record<string, unknown>)) {
|
|
66
|
+
const m = media as Record<string, unknown>;
|
|
67
|
+
record[key] = {
|
|
68
|
+
schema: m?.schema,
|
|
69
|
+
example: m?.example,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return record;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const toRequestBody = (value: unknown): OpenApiRequestBody => {
|
|
76
|
+
const body = value as Record<string, unknown>;
|
|
77
|
+
return {
|
|
78
|
+
description:
|
|
79
|
+
typeof body.description === "string" ? body.description : undefined,
|
|
80
|
+
required: Boolean(body.required),
|
|
81
|
+
content: toMediaTypes(body.content),
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const toResponses = (
|
|
86
|
+
value: unknown,
|
|
87
|
+
): Readonly<Record<string, OpenApiResponse>> => {
|
|
88
|
+
if (!value || typeof value !== "object") return {};
|
|
89
|
+
const record: Record<string, OpenApiResponse> = {};
|
|
90
|
+
for (const [code, response] of Object.entries(
|
|
91
|
+
value as Record<string, unknown>,
|
|
92
|
+
)) {
|
|
93
|
+
const r = response as Record<string, unknown>;
|
|
94
|
+
record[code] = {
|
|
95
|
+
description: typeof r.description === "string" ? r.description : "",
|
|
96
|
+
content: toMediaTypes(r.content),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return record;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const extractEndpoints = (
|
|
103
|
+
spec: Record<string, unknown>,
|
|
104
|
+
): readonly OpenApiEndpoint[] => {
|
|
105
|
+
const paths = spec.paths as Record<string, unknown> | undefined;
|
|
106
|
+
if (!paths || typeof paths !== "object") return [];
|
|
107
|
+
|
|
108
|
+
const endpoints: OpenApiEndpoint[] = [];
|
|
109
|
+
const methods = new Set(["GET", "POST", "PUT", "DELETE", "PATCH"]);
|
|
110
|
+
|
|
111
|
+
for (const [path, operations] of Object.entries(paths)) {
|
|
112
|
+
if (!operations || typeof operations !== "object") continue;
|
|
113
|
+
|
|
114
|
+
for (const [method, operation] of Object.entries(
|
|
115
|
+
operations as Record<string, unknown>,
|
|
116
|
+
)) {
|
|
117
|
+
const upperMethod = method.toUpperCase();
|
|
118
|
+
if (!methods.has(upperMethod)) continue;
|
|
119
|
+
|
|
120
|
+
const op = operation as Record<string, unknown> | undefined;
|
|
121
|
+
if (!op) continue;
|
|
122
|
+
|
|
123
|
+
const parameters = Array.isArray(op.parameters)
|
|
124
|
+
? op.parameters.map(toParameter)
|
|
125
|
+
: [];
|
|
126
|
+
|
|
127
|
+
endpoints.push({
|
|
128
|
+
method: upperMethod as OpenApiEndpoint["method"],
|
|
129
|
+
path,
|
|
130
|
+
summary: typeof op.summary === "string" ? op.summary : undefined,
|
|
131
|
+
description:
|
|
132
|
+
typeof op.description === "string" ? op.description : undefined,
|
|
133
|
+
parameters,
|
|
134
|
+
requestBody:
|
|
135
|
+
op.requestBody && typeof op.requestBody === "object"
|
|
136
|
+
? toRequestBody(op.requestBody)
|
|
137
|
+
: undefined,
|
|
138
|
+
responses: toResponses(op.responses),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return endpoints;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const createSwaggerParserAdapter = (): OpenApiParserPort => ({
|
|
147
|
+
parse: async (source: string) => {
|
|
148
|
+
try {
|
|
149
|
+
const raw = await loadRaw(source);
|
|
150
|
+
const parsed = parseText(raw) as Record<string, unknown>;
|
|
151
|
+
return extractEndpoints(parsed);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
throw parseError(source, "Failed to parse OpenAPI spec", error);
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
validate: async (schema: unknown) => {
|
|
158
|
+
if (Array.isArray(schema)) {
|
|
159
|
+
return schema.every(
|
|
160
|
+
(item) =>
|
|
161
|
+
item &&
|
|
162
|
+
typeof (item as Record<string, unknown>).method === "string" &&
|
|
163
|
+
typeof (item as Record<string, unknown>).path === "string",
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (typeof schema !== "object" || schema === null) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const s = schema as Record<string, unknown>;
|
|
172
|
+
return (
|
|
173
|
+
("openapi" in s || "swagger" in s) &&
|
|
174
|
+
typeof s.paths === "object" &&
|
|
175
|
+
s.paths !== null
|
|
176
|
+
);
|
|
177
|
+
},
|
|
178
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure OpenAPI parser 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 { OpenApiEndpoint } from "../../types/openapi";
|
|
9
|
+
|
|
10
|
+
export type OpenApiParseError = {
|
|
11
|
+
readonly kind: "openapi-parse-error";
|
|
12
|
+
readonly message: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Parse OpenAPI 3 schema to typed endpoints.
|
|
17
|
+
*/
|
|
18
|
+
export const parseOpenApiSchema = (
|
|
19
|
+
_schema: unknown,
|
|
20
|
+
): Result<readonly OpenApiEndpoint[], OpenApiParseError> => {
|
|
21
|
+
try {
|
|
22
|
+
// This will be implemented via adapter (swagger-parser)
|
|
23
|
+
// For now, return empty array
|
|
24
|
+
return ok([]);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
return err({
|
|
27
|
+
kind: "openapi-parse-error",
|
|
28
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Convert OpenAPI endpoint to internal ApiEndpoint format.
|
|
35
|
+
*/
|
|
36
|
+
export const openApiToApiEndpoint = (endpoint: OpenApiEndpoint): unknown => {
|
|
37
|
+
return {
|
|
38
|
+
method: endpoint.method,
|
|
39
|
+
path: endpoint.path,
|
|
40
|
+
summary: endpoint.summary,
|
|
41
|
+
description: endpoint.description,
|
|
42
|
+
parameters: endpoint.parameters,
|
|
43
|
+
requestBody: endpoint.requestBody,
|
|
44
|
+
responses: endpoint.responses,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API for the openapi module.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { createSwaggerParserAdapter } from "./application/swagger-parser-adapter";
|
|
6
|
+
export * from "./domain/operations/parse-openapi";
|
|
7
|
+
export * from "./ports/openapi-parser-port";
|
|
8
|
+
export * from "./types/openapi";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Port for OpenAPI parsing operations.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type OpenApiParserPort = {
|
|
6
|
+
/**
|
|
7
|
+
* Parse OpenAPI 3 schema from file or URL.
|
|
8
|
+
*/
|
|
9
|
+
readonly parse: (source: string) => Promise<unknown>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Validate OpenAPI 3 schema.
|
|
13
|
+
*/
|
|
14
|
+
readonly validate: (schema: unknown) => Promise<boolean>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI types for API documentation import.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type OpenApiEndpoint = {
|
|
6
|
+
readonly method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly summary?: string;
|
|
9
|
+
readonly description?: string;
|
|
10
|
+
readonly parameters?: readonly OpenApiParameter[];
|
|
11
|
+
readonly requestBody?: OpenApiRequestBody;
|
|
12
|
+
readonly responses?: Readonly<Record<string, OpenApiResponse>>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type OpenApiParameter = {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly in: "query" | "path" | "header" | "cookie";
|
|
18
|
+
readonly required: boolean;
|
|
19
|
+
readonly schema?: unknown;
|
|
20
|
+
readonly description?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type OpenApiRequestBody = {
|
|
24
|
+
readonly description?: string;
|
|
25
|
+
readonly required: boolean;
|
|
26
|
+
readonly content?: Readonly<Record<string, OpenApiMediaType>>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type OpenApiMediaType = {
|
|
30
|
+
readonly schema?: unknown;
|
|
31
|
+
readonly example?: unknown;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type OpenApiResponse = {
|
|
35
|
+
readonly description: string;
|
|
36
|
+
readonly content?: Readonly<Record<string, OpenApiMediaType>>;
|
|
37
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use case: build all virtual module source codes from a resolved config and pages.
|
|
3
|
+
* Returns a pure data structure (no Vite coupling).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ResolvedDocsConfig } from "@create-docs/modules/config";
|
|
7
|
+
import type { DocPage } from "@create-docs/modules/content";
|
|
8
|
+
import type { NavSection, SidebarGroup } from "@create-docs/modules/navigation";
|
|
9
|
+
import type { SearchIndex } from "@create-docs/modules/search";
|
|
10
|
+
import type { AppError } from "@create-docs/shared/errors";
|
|
11
|
+
import { ok, type Result } from "@create-docs/shared/types/result";
|
|
12
|
+
import {
|
|
13
|
+
buildConfigModule,
|
|
14
|
+
buildDocsDataModule,
|
|
15
|
+
buildNavModule,
|
|
16
|
+
buildSearchIndexModule,
|
|
17
|
+
buildSidebarModule,
|
|
18
|
+
} from "../../domain/operations/build-virtual";
|
|
19
|
+
|
|
20
|
+
export interface VirtualModuleSet {
|
|
21
|
+
readonly "virtual:docs/data": string;
|
|
22
|
+
readonly "virtual:docs/sidebar": string;
|
|
23
|
+
readonly "virtual:docs/nav": string;
|
|
24
|
+
readonly "virtual:docs/search-index": string;
|
|
25
|
+
readonly "virtual:docs/config": string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface BuildVirtualModulesInput {
|
|
29
|
+
readonly config: ResolvedDocsConfig;
|
|
30
|
+
readonly pages: readonly DocPage[];
|
|
31
|
+
readonly sidebar: readonly SidebarGroup[];
|
|
32
|
+
readonly nav: readonly NavSection[];
|
|
33
|
+
readonly searchIndex: SearchIndex;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type BuildVirtualModules = (
|
|
37
|
+
input: BuildVirtualModulesInput,
|
|
38
|
+
) => Result<VirtualModuleSet, AppError>;
|
|
39
|
+
|
|
40
|
+
export const buildVirtualModules: BuildVirtualModules = ({
|
|
41
|
+
config,
|
|
42
|
+
pages,
|
|
43
|
+
sidebar,
|
|
44
|
+
nav,
|
|
45
|
+
searchIndex,
|
|
46
|
+
}) =>
|
|
47
|
+
ok({
|
|
48
|
+
"virtual:docs/data": buildDocsDataModule(pages),
|
|
49
|
+
"virtual:docs/sidebar": buildSidebarModule(sidebar),
|
|
50
|
+
"virtual:docs/nav": buildNavModule(nav),
|
|
51
|
+
"virtual:docs/search-index": buildSearchIndexModule(searchIndex),
|
|
52
|
+
"virtual:docs/config": buildConfigModule(config),
|
|
53
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { buildVirtualModules } from "./build-virtual-modules";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use case: full docs build pipeline. Orchestrates:
|
|
3
|
+
* 1. scan docs dir → DocFile[]
|
|
4
|
+
* 2. load+parse each file → DocPage[]
|
|
5
|
+
* 3. build sidebar, nav, search index
|
|
6
|
+
* 4. produce virtual module source codes
|
|
7
|
+
*
|
|
8
|
+
* All I/O is delegated through ports; this function is fully testable with in-memory adapters.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { ResolvedDocsConfig } from "@create-docs/modules/config";
|
|
12
|
+
import { processDocsWorkflow } from "@create-docs/modules/content";
|
|
13
|
+
import { buildNav, buildSidebar } from "@create-docs/modules/navigation";
|
|
14
|
+
import { indexPages } from "@create-docs/modules/search";
|
|
15
|
+
import type { AppError } from "@create-docs/shared/errors";
|
|
16
|
+
import { ok, type Result } from "@create-docs/shared/types/result";
|
|
17
|
+
import type { DocsLoader } from "../../ports";
|
|
18
|
+
import {
|
|
19
|
+
buildVirtualModules,
|
|
20
|
+
type VirtualModuleSet,
|
|
21
|
+
} from "../usecases/build-virtual-modules";
|
|
22
|
+
|
|
23
|
+
export interface BuildDocsInput {
|
|
24
|
+
readonly config: ResolvedDocsConfig;
|
|
25
|
+
readonly loader: DocsLoader;
|
|
26
|
+
/** Optional page transformation hook. Invoked on each page after parsing. */
|
|
27
|
+
readonly transformPage?: (
|
|
28
|
+
page: import("@create-docs/modules/content").DocPage,
|
|
29
|
+
) =>
|
|
30
|
+
| import("@create-docs/modules/content").DocPage
|
|
31
|
+
| Promise<import("@create-docs/modules/content").DocPage>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type BuildDocs = (
|
|
35
|
+
input: BuildDocsInput,
|
|
36
|
+
) => Promise<Result<VirtualModuleSet, AppError>>;
|
|
37
|
+
|
|
38
|
+
export const buildDocs: BuildDocs = async ({
|
|
39
|
+
config,
|
|
40
|
+
loader,
|
|
41
|
+
transformPage,
|
|
42
|
+
}) => {
|
|
43
|
+
const loaded = await loader.loadAll(config);
|
|
44
|
+
if (!loaded.ok) return loaded;
|
|
45
|
+
let pages = loaded.value;
|
|
46
|
+
|
|
47
|
+
// Optional page transformation hook
|
|
48
|
+
if (transformPage) {
|
|
49
|
+
const next: import("@create-docs/modules/content").DocPage[] = [];
|
|
50
|
+
for (const p of pages) next.push(await transformPage(p));
|
|
51
|
+
pages = next;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Sidebar: prefer explicit config, otherwise auto-generate from pages
|
|
55
|
+
const sidebarResult = buildSidebar({
|
|
56
|
+
configured: config.sidebar,
|
|
57
|
+
pages,
|
|
58
|
+
});
|
|
59
|
+
if (!sidebarResult.ok) return sidebarResult;
|
|
60
|
+
const sidebar = sidebarResult.value;
|
|
61
|
+
|
|
62
|
+
// Nav from config
|
|
63
|
+
const navResult = buildNav(config.nav);
|
|
64
|
+
if (!navResult.ok) return navResult;
|
|
65
|
+
const nav = navResult.value;
|
|
66
|
+
|
|
67
|
+
// Search index
|
|
68
|
+
const searchResult = indexPages(pages);
|
|
69
|
+
if (!searchResult.ok) return searchResult;
|
|
70
|
+
const searchIndex = searchResult.value;
|
|
71
|
+
|
|
72
|
+
const vms = buildVirtualModules({ config, pages, sidebar, nav, searchIndex });
|
|
73
|
+
if (!vms.ok) return vms;
|
|
74
|
+
|
|
75
|
+
return ok(vms.value);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Re-export for backwards-compat with adapter layer
|
|
79
|
+
export { processDocsWorkflow };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../workflows/build-docs";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin module domain events.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ResolvedDocsConfig } from "@create-docs/modules/config";
|
|
6
|
+
|
|
7
|
+
export type PluginEvent =
|
|
8
|
+
| { readonly type: "plugin.initialized"; readonly config: ResolvedDocsConfig }
|
|
9
|
+
| {
|
|
10
|
+
readonly type: "plugin.config_resolved";
|
|
11
|
+
readonly docsDir: string;
|
|
12
|
+
readonly baseRoute: string;
|
|
13
|
+
}
|
|
14
|
+
| {
|
|
15
|
+
readonly type: "plugin.virtual_module_emitted";
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly bytes: number;
|
|
18
|
+
}
|
|
19
|
+
| { readonly type: "plugin.file_watched"; readonly path: string }
|
|
20
|
+
| { readonly type: "plugin.reloaded"; readonly pages: number }
|
|
21
|
+
| {
|
|
22
|
+
readonly type: "plugin.error";
|
|
23
|
+
readonly phase: "init" | "scan" | "transform" | "watch";
|
|
24
|
+
readonly message: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const pluginInitialized = (config: ResolvedDocsConfig): PluginEvent => ({
|
|
28
|
+
type: "plugin.initialized",
|
|
29
|
+
config,
|
|
30
|
+
});
|
|
31
|
+
export const pluginConfigResolved = (
|
|
32
|
+
docsDir: string,
|
|
33
|
+
baseRoute: string,
|
|
34
|
+
): PluginEvent => ({
|
|
35
|
+
type: "plugin.config_resolved",
|
|
36
|
+
docsDir,
|
|
37
|
+
baseRoute,
|
|
38
|
+
});
|
|
39
|
+
export const pluginVirtualModuleEmitted = (
|
|
40
|
+
id: string,
|
|
41
|
+
bytes: number,
|
|
42
|
+
): PluginEvent => ({
|
|
43
|
+
type: "plugin.virtual_module_emitted",
|
|
44
|
+
id,
|
|
45
|
+
bytes,
|
|
46
|
+
});
|
|
47
|
+
export const pluginFileWatched = (path: string): PluginEvent => ({
|
|
48
|
+
type: "plugin.file_watched",
|
|
49
|
+
path,
|
|
50
|
+
});
|
|
51
|
+
export const pluginReloaded = (pages: number): PluginEvent => ({
|
|
52
|
+
type: "plugin.reloaded",
|
|
53
|
+
pages,
|
|
54
|
+
});
|
|
55
|
+
export const pluginError = (
|
|
56
|
+
phase: "init" | "scan" | "transform" | "watch",
|
|
57
|
+
message: string,
|
|
58
|
+
): PluginEvent => ({
|
|
59
|
+
type: "plugin.error",
|
|
60
|
+
phase,
|
|
61
|
+
message,
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { PluginContext, PluginHooks } from "../../types";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure operations for generating virtual module source code (Vite-loadable ESM).
|
|
3
|
+
* No I/O, no exceptions. Returns strings ready to be emitted as virtual module code.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ResolvedDocsConfig } from "@create-docs/modules/config";
|
|
7
|
+
import type { DocPage, FilePath } from "@create-docs/modules/content";
|
|
8
|
+
import type { NavSection, SidebarGroup } from "@create-docs/modules/navigation";
|
|
9
|
+
import {
|
|
10
|
+
VIRTUAL_DATA,
|
|
11
|
+
VIRTUAL_NAV,
|
|
12
|
+
VIRTUAL_SEARCH_INDEX,
|
|
13
|
+
VIRTUAL_SIDEBAR,
|
|
14
|
+
} from "@create-docs/modules/plugin/types";
|
|
15
|
+
import type { SearchIndex } from "@create-docs/modules/search";
|
|
16
|
+
import { isString } from "@create-docs/shared/utils/object";
|
|
17
|
+
|
|
18
|
+
const serializeForESM = (value: unknown): string =>
|
|
19
|
+
JSON.stringify(value, replacer, 2);
|
|
20
|
+
|
|
21
|
+
const replacer = (_key: string, value: unknown): unknown => {
|
|
22
|
+
if (value === undefined) return undefined;
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const buildDocsDataModule = (pages: readonly DocPage[]): string => {
|
|
27
|
+
const exported = pages.map((p) => ({
|
|
28
|
+
id: String(p.id),
|
|
29
|
+
slug: String(p.slug),
|
|
30
|
+
title: p.title,
|
|
31
|
+
description: p.description,
|
|
32
|
+
frontmatter: p.frontmatter,
|
|
33
|
+
rawContent: p.rawContent,
|
|
34
|
+
content: p.content,
|
|
35
|
+
filePath: String(p.filePath),
|
|
36
|
+
}));
|
|
37
|
+
return `export const docsData = ${serializeForESM(exported)};`;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const buildSidebarModule = (groups: readonly SidebarGroup[]): string =>
|
|
41
|
+
`export const sidebar = ${serializeForESM(groups)};`;
|
|
42
|
+
|
|
43
|
+
export const buildNavModule = (sections: readonly NavSection[]): string =>
|
|
44
|
+
`export const nav = ${serializeForESM(sections)};`;
|
|
45
|
+
|
|
46
|
+
export const buildSearchIndexModule = (index: SearchIndex): string =>
|
|
47
|
+
`export const searchIndex = ${serializeForESM(index.entries)};`;
|
|
48
|
+
|
|
49
|
+
export const buildConfigModule = (
|
|
50
|
+
config: ResolvedDocsConfig,
|
|
51
|
+
): string => `export const docsConfig = ${serializeForESM(config)};
|
|
52
|
+
export const site = ${serializeForESM(config.site)};
|
|
53
|
+
export const nav = ${serializeForESM(config.nav)};
|
|
54
|
+
export const sidebar = ${serializeForESM(config.sidebar)};
|
|
55
|
+
export const api = ${serializeForESM(config.api)};
|
|
56
|
+
export const search = ${serializeForESM(config.search)};
|
|
57
|
+
export const editLink = ${serializeForESM(config.editLink)};
|
|
58
|
+
export const lastUpdated = ${serializeForESM(config.lastUpdated)};`;
|
|
59
|
+
|
|
60
|
+
export const resolveVirtualModule = (id: string): string | undefined => {
|
|
61
|
+
if (id === VIRTUAL_DATA) return "data";
|
|
62
|
+
if (id === VIRTUAL_SIDEBAR) return "sidebar";
|
|
63
|
+
if (id === VIRTUAL_NAV) return "nav";
|
|
64
|
+
if (id === VIRTUAL_SEARCH_INDEX) return "search-index";
|
|
65
|
+
return undefined;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const isVirtualDocsModule = (id: string): boolean =>
|
|
69
|
+
id.startsWith("virtual:docs/");
|
|
70
|
+
|
|
71
|
+
export const pathToFilePath = (p: string): FilePath => p as unknown as FilePath;
|
|
72
|
+
|
|
73
|
+
export const isMarkdownPath = (p: string): boolean => {
|
|
74
|
+
if (!isString(p)) return false;
|
|
75
|
+
return p.endsWith(".md") || p.endsWith(".mdoc");
|
|
76
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Plugin Domain Schemas - Arktype validation schemas
|
|
2
|
+
// Following /follow-arktype workflow for type-safe runtime validation
|
|
3
|
+
|
|
4
|
+
import type { ResolvedDocsConfig } from "@create-docs/modules/config";
|
|
5
|
+
import { pluginError } from "@create-docs/shared/errors";
|
|
6
|
+
import { err, ok, type Result } from "@create-docs/shared/types/result";
|
|
7
|
+
import { type Type, type } from "arktype";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Resolved Config Schema
|
|
11
|
+
*/
|
|
12
|
+
export const resolvedConfigSchema: Type = type({
|
|
13
|
+
docsDir: "string >= 1",
|
|
14
|
+
baseRoute: "string >= 1",
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type ResolvedConfigSchema = typeof resolvedConfigSchema.infer;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Validate resolved config using Arktype
|
|
21
|
+
*/
|
|
22
|
+
export const validateResolvedConfig = (
|
|
23
|
+
c: ResolvedDocsConfig,
|
|
24
|
+
): Result<ResolvedDocsConfig, ReturnType<typeof pluginError>> => {
|
|
25
|
+
const result = resolvedConfigSchema(c);
|
|
26
|
+
if (result instanceof type.errors) {
|
|
27
|
+
return err(pluginError(result.summary, { path: "docsDir" }));
|
|
28
|
+
}
|
|
29
|
+
return ok(c);
|
|
30
|
+
};
|