@redocly/framework 1.0.0-next.1 → 1.0.0-next.12
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/dist/bundler/build/dependency-pack.js +1 -1
- package/dist/bundler/build/output-metadata.js +1 -1
- package/dist/bundler/build/run.js +1 -1
- package/dist/bundler/build/theme-global-style-compiler.js +1 -0
- package/dist/bundler/build/theme-global-stylesheets.js +1 -0
- package/dist/bundler/build/vite-config.js +2 -2
- package/dist/bundler/dev/dev-content-build.js +1 -0
- package/dist/bundler/dev/dev-problems.js +1 -1
- package/dist/bundler/dev/dev-reporter.js +1 -1
- package/dist/bundler/dev/routes/dev-content-build-route.js +1 -0
- package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
- package/dist/bundler/dev/routes/source-sync-route.js +1 -1
- package/dist/bundler/dev/run.js +1 -1
- package/dist/bundler/dev/runtime-app.js +1 -1
- package/dist/bundler/dev/vite-chunk-url.js +1 -1
- package/dist/bundler/dev/vite-config.js +1 -1
- package/dist/bundler/node-bundle.js +1 -0
- package/dist/bundler/runtime-files.js +1 -1
- package/dist/bundler/user-markdoc-schema.js +1 -1
- package/dist/bundler/vite-config.base.js +12 -12
- package/dist/cli/api-docs-build-event.js +1 -0
- package/dist/cli/args.js +1 -1
- package/dist/cli/commands/build.js +1 -1
- package/dist/cli/commands/dev.js +1 -1
- package/dist/cli/commands/ingest.js +1 -1
- package/dist/cli/commands/translate.js +1 -1
- package/dist/cli/dev-console/{sweep.js → content-build.js} +1 -1
- package/dist/cli/dev-console/index.js +1 -1
- package/dist/cli/dev-console/lines.js +2 -2
- package/dist/cli/dev-console/plain.js +1 -1
- package/dist/cli/dev-console/tui.js +2 -2
- package/dist/cli/output.js +12 -12
- package/dist/cli/problems-output.js +3 -3
- package/dist/cli/validate-react-pages.js +1 -1
- package/dist/client/ApiAccess.js +3 -0
- package/dist/client/NavigationProgress.js +1 -1
- package/dist/client/ProductsProvider.js +1 -1
- package/dist/client/RouteErrorBoundary.js +1 -1
- package/dist/client/RuntimeLink.js +1 -0
- package/dist/client/ThemeGlobalStyle.js +1 -0
- package/dist/client/UnversionedVersionButton.js +1 -1
- package/dist/client/ai-search/citations.js +3 -3
- package/dist/client/ai-search/use-ai-search.js +1 -1
- package/dist/client/analytics-page-view.js +1 -1
- package/dist/client/app.js +2 -7
- package/dist/client/classic-webview-sync.js +1 -0
- package/dist/client/client-entry.js +1 -1
- package/dist/client/contexts.js +1 -1
- package/dist/client/dev-problems/ProblemsBar.js +75 -15
- package/dist/client/dev-problems/ProblemsModal.js +15 -15
- package/dist/client/dev-problems/build-segment.js +1 -0
- package/dist/client/dev-problems/index.js +1 -1
- package/dist/client/dev-problems/use-dev-problems.js +1 -1
- package/dist/client/experiments/runtime.js +1 -1
- package/dist/client/feedback.js +1 -1
- package/dist/client/history-mount.js +1 -0
- package/dist/client/l10n/ssr-l10n.js +1 -1
- package/dist/client/l10n/use-l10n-config.js +1 -1
- package/dist/client/l10n/use-l10n-href.js +1 -1
- package/dist/client/l10n/use-translate.js +1 -1
- package/dist/client/page-sync.js +1 -0
- package/dist/client/products.js +1 -1
- package/dist/client/review/ReviewBar.js +163 -69
- package/dist/client/review/login-url.js +1 -0
- package/dist/client/review/use-review.js +1 -1
- package/dist/client/revisions-history.js +1 -1
- package/dist/client/sidebar/PoweredByRedocly.js +2 -2
- package/dist/client/sidebar/SidebarDataProvider.js +1 -1
- package/dist/client/sidebar/drilldown.js +1 -1
- package/dist/client/ssr.js +1 -1
- package/dist/client/telemetry/config.js +1 -1
- package/dist/client/telemetry/report-preload-failure.js +1 -0
- package/dist/client/templates/dev-login.js +4 -4
- package/dist/client/templates/unauthorized.js +5 -5
- package/dist/client/theme-global-css.js +1 -0
- package/dist/client/theme-logo.js +1 -1
- package/dist/client/use-banner.js +1 -1
- package/dist/client/use-bar-position.js +1 -0
- package/dist/client/use-entity-revisions.js +1 -1
- package/dist/client/use-page-versions.js +1 -1
- package/dist/client/use-router-for-local-links.js +1 -1
- package/dist/client/use-search.js +1 -1
- package/dist/client/utils/routes/is-router-path.js +1 -0
- package/dist/client/webmcp/tools/shared.js +1 -1
- package/dist/client/webmcp/tools/site-tools.js +1 -1
- package/dist/client/webmcp/use-webmcp-tools.js +1 -1
- package/dist/content-layer/allowed-packages.js +1 -1
- package/dist/content-layer/api-outputs.js +1 -1
- package/dist/content-layer/config-schema.d.ts +12 -3
- package/dist/content-layer/config-schema.js +1 -1
- package/dist/content-layer/config.d.ts +30 -12
- package/dist/content-layer/config.js +1 -1
- package/dist/content-layer/context-state.js +1 -1
- package/dist/content-layer/context.d.ts +2 -0
- package/dist/content-layer/context.js +1 -1
- package/dist/content-layer/database/adapters/node-sqlite-client.js +1 -1
- package/dist/content-layer/database/assets.js +1 -1
- package/dist/content-layer/database/connection.js +1 -1
- package/dist/content-layer/database/entity-store.d.ts +24 -3
- package/dist/content-layer/database/entity-store.js +1 -1
- package/dist/content-layer/database/invalidation.d.ts +6 -0
- package/dist/content-layer/database/invalidation.js +26 -26
- package/dist/content-layer/database/origins.d.ts +2 -4
- package/dist/content-layer/database/origins.js +1 -1
- package/dist/content-layer/database/problems.d.ts +2 -0
- package/dist/content-layer/database/problems.js +1 -1
- package/dist/content-layer/database/reset.js +1 -1
- package/dist/content-layer/database/schema.d.ts +50 -0
- package/dist/content-layer/database/schema.js +1 -1
- package/dist/content-layer/database/site-config.d.ts +23 -0
- package/dist/content-layer/database/site-config.js +1 -1
- package/dist/content-layer/ingest/extract-all-phase.js +1 -1
- package/dist/content-layer/ingest/finalize-phase.js +1 -1
- package/dist/content-layer/ingest/git-last-modified.js +3 -3
- package/dist/content-layer/ingest/hash.js +1 -1
- package/dist/content-layer/ingest/hook-inputs.js +1 -1
- package/dist/content-layer/ingest/markdoc-schema-problem.js +1 -0
- package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
- package/dist/content-layer/ingest/rbac-teams.js +1 -1
- package/dist/content-layer/ingest/run.js +1 -1
- package/dist/content-layer/ingest/scan.d.ts +1 -1
- package/dist/content-layer/ingest/scan.js +1 -1
- package/dist/content-layer/ingest/search-sync.js +1 -1
- package/dist/content-layer/ingest/slugger/resolve-final-slugs.js +1 -1
- package/dist/content-layer/ingest/sync.js +1 -1
- package/dist/content-layer/link-checker/config-links.js +1 -1
- package/dist/content-layer/link-checker/delta.js +1 -1
- package/dist/content-layer/link-checker/fingerprint.js +1 -1
- package/dist/content-layer/link-checker/load-view.js +1 -1
- package/dist/content-layer/link-checker/node-ref.js +1 -1
- package/dist/content-layer/link-checker/run-build.js +1 -1
- package/dist/content-layer/link-checker/validate.js +1 -1
- package/dist/content-layer/link-checker/view.js +1 -1
- package/dist/content-layer/loaders/context.js +1 -1
- package/dist/content-layer/loaders/define.d.ts +3 -0
- package/dist/content-layer/markdown/client/JsonSchemaTag.js +1 -1
- package/dist/content-layer/markdown/client/OpenapiTagComponents.js +2 -2
- package/dist/content-layer/markdown/client/code-highlight-notation.js +3 -3
- package/dist/content-layer/markdown/client/dynamic-components.js +1 -1
- package/dist/content-layer/markdown/client/markdoc-components.js +2 -2
- package/dist/content-layer/markdown/client/markdown-text.js +1 -1
- package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
- package/dist/content-layer/markdown/constants/markdown-text-tag-set.js +1 -1
- package/dist/content-layer/markdown/constants/tag-sets.d.ts +20 -5
- package/dist/content-layer/markdown/constants/tag-sets.js +1 -1
- package/dist/content-layer/markdown/nodes/heading.js +1 -1
- package/dist/content-layer/markdown/nodes/table.js +1 -1
- package/dist/content-layer/markdown/resolve/ast.js +1 -1
- package/dist/content-layer/markdown/resolve/attribute-resolver-key.d.ts +8 -1
- package/dist/content-layer/markdown/resolve/attribute-resolver-key.js +1 -1
- package/dist/content-layer/markdown/resolve/audience-tag.d.ts +2 -6
- package/dist/content-layer/markdown/resolve/audience-tag.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/code-snippet.js +5 -4
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/code-walkthrough/filesets.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/diagram-file.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/file-reference.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.d.ts +2 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.d.ts +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/partial.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/svg-content.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc.d.ts +2 -1
- package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
- package/dist/content-layer/markdown/resolve/raw-partials.d.ts +2 -1
- package/dist/content-layer/markdown/resolve/raw-partials.js +1 -1
- package/dist/content-layer/markdown/resolve/references.d.ts +3 -1
- package/dist/content-layer/markdown/resolve/references.js +1 -1
- package/dist/content-layer/markdown/resolve/render-diagrams.d.ts +8 -1
- package/dist/content-layer/markdown/resolve/render-diagrams.js +1 -1
- package/dist/content-layer/markdown/search/to-sections.d.ts +8 -3
- package/dist/content-layer/markdown/search/to-sections.js +1 -1
- package/dist/content-layer/markdown/search/to-text.d.ts +4 -1
- package/dist/content-layer/markdown/search/to-text.js +5 -5
- package/dist/content-layer/markdown/server/render.d.ts +4 -2
- package/dist/content-layer/markdown/server/render.js +1 -1
- package/dist/content-layer/markdown/service.js +1 -1
- package/dist/content-layer/markdown/tags/html.d.ts +5 -2
- package/dist/content-layer/markdown/tags/html.js +1 -1
- package/dist/content-layer/markdown/tags/markdoc-error.d.ts +8 -0
- package/dist/content-layer/markdown/tags/markdoc-error.js +1 -1
- package/dist/content-layer/markdown/tags/openapi.d.ts +1 -1
- package/dist/content-layer/markdown/tags/openapi.js +1 -1
- package/dist/content-layer/markdown/tags/partial.d.ts +9 -3
- package/dist/content-layer/markdown/tags/partial.js +1 -1
- package/dist/content-layer/markdown/tags/variant.d.ts +6 -0
- package/dist/content-layer/markdown/tags/variant.js +1 -0
- package/dist/content-layer/markdown/types/service.d.ts +6 -0
- package/dist/content-layer/markdown/utils/collect-anchors.js +1 -1
- package/dist/content-layer/markdown/utils/collect-headings.d.ts +3 -1
- package/dist/content-layer/markdown/utils/collect-headings.js +1 -1
- package/dist/content-layer/markdown/utils/first-heading.js +1 -1
- package/dist/content-layer/markdown/utils/heading-slugger.d.ts +8 -0
- package/dist/content-layer/markdown/utils/heading-slugger.js +1 -1
- package/dist/content-layer/markdown/utils/node-source-range.d.ts +3 -3
- package/dist/content-layer/markdown/utils/node-source-range.js +1 -1
- package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
- package/dist/content-layer/markdown/utils/reparse-example-fences.d.ts +4 -1
- package/dist/content-layer/markdown/utils/reparse-example-fences.js +1 -1
- package/dist/content-layer/markdown/utils/substitute-variables.js +1 -1
- package/dist/content-layer/markdown/utils/walk-markdoc-ast.d.ts +2 -2
- package/dist/content-layer/markdown/utils/walk-markdoc-ast.js +1 -1
- package/dist/content-layer/materialization/asset-reconcile.js +1 -1
- package/dist/content-layer/materialization/entity.js +1 -1
- package/dist/content-layer/materialization/materializer.js +1 -0
- package/dist/content-layer/materialization/static-files.js +1 -1
- package/dist/content-layer/plan-gates.d.ts +3 -2
- package/dist/content-layer/plan-gates.js +1 -1
- package/dist/content-layer/plugins/execute.js +1 -1
- package/dist/content-layer/plugins/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/event-handlers.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/rebase-item-links.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/template.js +12 -4
- package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/build-definition.d.ts +28 -13
- package/dist/content-layer/plugins/internal/api-docs/server/build-definition.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/build-sidebar.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/declares-proto-service.d.ts +2 -0
- package/dist/content-layer/plugins/internal/api-docs/server/declares-proto-service.js +3 -0
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-copy.d.ts +14 -0
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-copy.js +23 -0
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-decorator.d.ts +1 -4
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-decorator.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/options.d.ts +4 -2
- package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/search-documents.d.ts +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/search-documents.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/spec-download.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/server/access.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/server/api-function-telemetry.js +1 -0
- package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/banner.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/index.d.ts +1 -1
- package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/logo.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/products.d.ts +2 -0
- package/dist/content-layer/plugins/internal/app-data/products.js +1 -1
- package/dist/content-layer/plugins/internal/assets/index.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/client/catalog-filtering.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/client/use-catalog-classic.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/resolve-items.d.ts +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/resolve-items.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/sidebars.d.ts +1 -1
- package/dist/content-layer/plugins/internal/index.js +1 -1
- package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/server/shared.d.ts +1 -1
- package/dist/content-layer/plugins/internal/mcp/app-data.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/constants.d.ts +20 -0
- package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/content-tools.d.ts +4 -1
- package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/ignored-routes.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/code-credentials.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/codemode/capabilities.js +6 -6
- package/dist/content-layer/plugins/internal/mcp/server/codemode/constants.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/discover.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/execute-schema.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/prompts.js +8 -8
- package/dist/content-layer/plugins/internal/mcp/server/config-gate.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/custom-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/allowed-http-methods.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/api-call-operations.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/call-api.js +2 -0
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-handler.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +10 -10
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/outcome-pages.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +6 -5
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/allowed-hosts.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-bridge.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-errors.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/ssrf-guard.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/upstream-detail.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
- package/dist/content-layer/plugins/internal/mcp/server/gateway/secret-store.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/tool-list.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +4 -4
- package/dist/content-layer/plugins/internal/mcp/server/gateway/upstream-auth-scheme.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/callback.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/error-reporting.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/register.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/token.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/rate-limit.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-info.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-catalog.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-catalog.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-document.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-refs.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/openapi.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/workflows/catalog.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/workflows/document-resolver.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/workflows/operations-subset.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/workflows/resolve-workflows.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/workflows/run-workflow.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/workflows/schemas.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/workflows/tools.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/workflows/types.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/workflows/workflow-references.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/setup-page.js +1 -1
- package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/react-page/index.d.ts +3 -2
- package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/client/Grid.js +11 -11
- package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardViews.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardWidgets.js +7 -7
- package/dist/content-layer/plugins/internal/scorecard-classic/client/template.js +2 -2
- package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/bundle.d.ts +18 -17
- package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/index.d.ts +5 -3
- package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
- package/dist/content-layer/plugins/internal/sidebar/subtree.js +1 -1
- package/dist/content-layer/plugins/internal/skills/index.js +1 -1
- package/dist/content-layer/plugins/internal/skills/server/routes.js +1 -1
- package/dist/content-layer/plugins/internal/versions/index.js +1 -1
- package/dist/content-layer/plugins/io.js +1 -1
- package/dist/content-layer/plugins/project/load.js +2 -2
- package/dist/content-layer/plugins/registry.js +1 -1
- package/dist/content-layer/plugins/request-context.d.ts +5 -0
- package/dist/content-layer/plugins/source-file.js +1 -1
- package/dist/content-layer/plugins/types/api-entity.d.ts +2 -6
- package/dist/content-layer/plugins/types/api-entity.js +1 -1
- package/dist/content-layer/plugins/types/markdoc.d.ts +2 -0
- package/dist/content-layer/plugins/types/plugin.d.ts +13 -0
- package/dist/content-layer/plugins/types/search.d.ts +14 -3
- package/dist/content-layer/plugins/utils/link-access.d.ts +2 -0
- package/dist/content-layer/plugins/utils/link-access.js +1 -1
- package/dist/content-layer/plugins/utils/route-index.d.ts +1 -1
- package/dist/content-layer/plugins/utils/route-index.js +1 -1
- package/dist/content-layer/plugins/utils/sidebar-label.d.ts +4 -1
- package/dist/content-layer/plugins/utils/sidebar-label.js +1 -1
- package/dist/content-layer/plugins/utils/version-path.js +1 -1
- package/dist/content-layer/plugins/work-time.js +1 -0
- package/dist/content-layer/problems/codes.d.ts +10 -0
- package/dist/content-layer/problems/codes.js +1 -1
- package/dist/content-layer/revisions/config.js +1 -1
- package/dist/content-layer/revisions/read.js +1 -1
- package/dist/content-layer/search/engine/core/content-parser.js +1 -1
- package/dist/content-layer/search/facet-rows.js +1 -1
- package/dist/content-layer/search/keywords.d.ts +18 -0
- package/dist/content-layer/search/keywords.js +1 -0
- package/dist/content-layer/search/postings/fragment-field.d.ts +2 -0
- package/dist/content-layer/search/postings/fragment-field.js +1 -1
- package/dist/content-layer/search/postings/postings-store.d.ts +14 -0
- package/dist/content-layer/search/postings/postings-store.js +1 -1
- package/dist/content-layer/search/store.d.ts +14 -1
- package/dist/content-layer/server/context.js +1 -1
- package/dist/content-layer/server/database.js +1 -1
- package/dist/content-layer/server/materialize.js +1 -1
- package/dist/content-layer/static/audience.js +1 -1
- package/dist/content-layer/static/registry.js +1 -1
- package/dist/content-layer/versions/group-info.d.ts +22 -0
- package/dist/content-layer/versions/group-info.js +1 -0
- package/dist/content-layer/versions/redirect.d.ts +24 -17
- package/dist/content-layer/versions/redirect.js +1 -1
- package/dist/content-layer/versions/resolve.d.ts +1 -21
- package/dist/content-layer/versions/resolve.js +1 -1
- package/dist/content-layer/versions/version-groups.d.ts +5 -1
- package/dist/content-layer/versions/version-groups.js +1 -1
- package/dist/plugin-api.d.ts +3 -0
- package/dist/plugin-api.js +1 -1
- package/dist/server/analytics-tags.js +1 -1
- package/dist/server/app.js +3 -3
- package/dist/server/ask-ai/feature-gate.js +1 -1
- package/dist/server/ask-ai/route.js +1 -1
- package/dist/server/auth/access-config.js +1 -1
- package/dist/server/auth/gate.js +1 -1
- package/dist/server/auth/middleware.js +1 -1
- package/dist/server/auth/oidc.js +1 -1
- package/dist/server/auth/request.js +1 -1
- package/dist/server/auth/routes.js +1 -1
- package/dist/server/auth/runtime.js +1 -1
- package/dist/server/content-assets/access.js +1 -1
- package/dist/server/content.js +15 -14
- package/dist/server/cors-proxy/handler.js +1 -1
- package/dist/server/feedback/route.js +1 -1
- package/dist/server/html-tags.js +2 -1
- package/dist/server/lambda-entry.js +1 -1
- package/dist/server/llms-txt.js +1 -1
- package/dist/server/manifest-assets.js +5 -5
- package/dist/server/metrics/request-metrics.js +1 -1
- package/dist/server/node-entry.js +1 -1
- package/dist/server/page-handlers.js +1 -1
- package/dist/server/plugin-context.js +1 -1
- package/dist/server/plugin-routes.js +1 -1
- package/dist/server/public-url.js +1 -0
- package/dist/server/rbac/content-asset-access.js +1 -1
- package/dist/server/redirects.js +1 -1
- package/dist/server/replay-oauth2/route.js +1 -1
- package/dist/server/review/route.js +1 -1
- package/dist/server/runtime-config.js +1 -1
- package/dist/server/search/cache.js +1 -0
- package/dist/server/search/route.js +1 -1
- package/dist/server/search/search-telemetry.js +1 -0
- package/dist/server/seo-tags.js +2 -2
- package/dist/server/sitemap.js +1 -1
- package/dist/server/ssrf/ssrf-blocklist.js +1 -1
- package/dist/server/static-files/serve.js +1 -1
- package/dist/server/subprocess/child-entry.js +1 -1
- package/dist/server/subprocess/runner.js +1 -1
- package/dist/server/telemetry/mock-server-events.js +1 -0
- package/dist/server/telemetry/redirect-event.js +1 -0
- package/dist/server/telemetry/route.js +1 -1
- package/dist/server/telemetry/sender.js +1 -1
- package/dist/server/telemetry/server-events.js +1 -1
- package/dist/server/template-ids.js +1 -1
- package/dist/server/wait-until.js +1 -0
- package/dist/shared/constants/api-spec-kinds.d.ts +7 -0
- package/dist/shared/constants/api-spec-kinds.js +1 -0
- package/dist/shared/constants/content-update.js +1 -1
- package/dist/shared/constants/dependency-pack.js +1 -1
- package/dist/shared/constants/dev-content-build.js +1 -0
- package/dist/shared/constants/dev-problems.js +1 -1
- package/dist/shared/constants/dev-source-sync.js +1 -1
- package/dist/shared/constants/l10n/langs/ar.js +1 -1
- package/dist/shared/constants/l10n/langs/de.js +1 -1
- package/dist/shared/constants/l10n/langs/en.js +1 -1
- package/dist/shared/constants/l10n/langs/es.js +1 -1
- package/dist/shared/constants/l10n/langs/fr.js +1 -1
- package/dist/shared/constants/l10n/langs/hi.js +1 -1
- package/dist/shared/constants/l10n/langs/it.js +1 -1
- package/dist/shared/constants/l10n/langs/ja.js +1 -1
- package/dist/shared/constants/l10n/langs/ko.js +1 -1
- package/dist/shared/constants/l10n/langs/pl.js +1 -1
- package/dist/shared/constants/l10n/langs/pt-br.js +1 -1
- package/dist/shared/constants/l10n/langs/pt.js +1 -1
- package/dist/shared/constants/l10n/langs/ru.js +1 -1
- package/dist/shared/constants/l10n/langs/uk.js +1 -1
- package/dist/shared/constants/l10n/langs/zh.js +1 -1
- package/dist/shared/constants/manifest-version.d.ts +3 -1
- package/dist/shared/constants/openapi-operation-methods.d.ts +2 -0
- package/dist/shared/constants/openapi-operation-methods.js +1 -0
- package/dist/shared/constants/review.d.ts +7 -0
- package/dist/shared/constants/review.js +1 -1
- package/dist/{server → shared}/constants/system-routes.d.ts +2 -2
- package/dist/shared/constants/system-routes.js +1 -0
- package/dist/shared/constants/versions.d.ts +2 -0
- package/dist/shared/constants/versions.js +1 -1
- package/dist/shared/experiments.js +1 -1
- package/dist/shared/load-dot-env.js +1 -1
- package/dist/shared/plan-gates.d.ts +9 -3
- package/dist/shared/plan-gates.js +1 -1
- package/dist/shared/products.js +1 -1
- package/dist/shared/project-env.d.ts +12 -0
- package/dist/shared/project-env.js +1 -0
- package/dist/shared/public-env.d.ts +9 -0
- package/dist/shared/public-env.js +1 -1
- package/dist/{server → shared}/rbac/api-docs.d.ts +3 -2
- package/dist/shared/rbac/api-docs.js +1 -0
- package/dist/{server → shared}/rbac/engine.d.ts +13 -10
- package/dist/shared/rbac/engine.js +0 -0
- package/dist/{server → shared}/rbac/filter.d.ts +2 -0
- package/dist/shared/rbac/filter.js +1 -0
- package/dist/{server → shared}/rbac/l10n-rules.d.ts +1 -1
- package/dist/shared/rbac/l10n-rules.js +1 -0
- package/dist/{server → shared}/rbac/route-scope.d.ts +1 -1
- package/dist/shared/rbac/route-scope.js +1 -0
- package/dist/{server → shared}/rbac/team-templates.d.ts +6 -2
- package/dist/shared/rbac/team-templates.js +1 -0
- package/dist/{server → shared}/rbac/teams.d.ts +1 -1
- package/dist/shared/rbac/types.js +1 -0
- package/dist/shared/search/facets.d.ts +5 -0
- package/dist/shared/search/facets.js +1 -1
- package/dist/shared/types/auth.d.ts +1 -0
- package/dist/shared/types/config.d.ts +5 -0
- package/dist/shared/types/search.d.ts +8 -2
- package/dist/shared/types/sidebar.d.ts +1 -0
- package/dist/shared/utils/redirect-match.js +1 -0
- package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
- package/dist/shared/utils/routes/markdown-copy-url.js +1 -0
- package/drizzle/20261103061150_site_config_effective_hash/migration.sql +1 -0
- package/drizzle/20261105151816_search_http_path_tokens/migration.sql +1 -0
- package/drizzle/20261111152552_page_markdown_rbac_scope/migration.sql +1 -0
- package/package.json +37 -13
- package/dist/bundler/dev/__tests__/reset-content-update-state.js +0 -1
- package/dist/bundler/dev/materialization-sweeper.js +0 -1
- package/dist/client/dev-problems/sweep-segment.js +0 -1
- package/dist/client/review/use-bar-position.js +0 -1
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.d.ts +0 -5
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.js +0 -26
- package/dist/content-layer/plugins/internal/mcp/server/gateway/__tests__/fake-kv.js +0 -1
- package/dist/content-layer/server/config.js +0 -1
- package/dist/server/__tests__/rbac-fixture.js +0 -1
- package/dist/server/__tests__/test-session.js +0 -1
- package/dist/server/constants/system-routes.js +0 -1
- package/dist/server/rbac/api-docs.js +0 -1
- package/dist/server/rbac/engine.js +0 -0
- package/dist/server/rbac/filter.js +0 -1
- package/dist/server/rbac/l10n-rules.js +0 -1
- package/dist/server/rbac/route-scope.js +0 -1
- package/dist/server/rbac/team-templates.js +0 -1
- package/dist/server/rbac/types.js +0 -1
- package/dist/shared/utils/routes/markdown-path.js +0 -1
- /package/dist/{server → shared}/rbac/entity-scope.js +0 -0
- /package/dist/{server → shared}/rbac/teams.js +0 -0
- /package/dist/{server → shared}/rbac/types.d.ts +0 -0
- /package/dist/{content-layer/markdown → shared}/utils/packed-ast.d.ts +0 -0
- /package/dist/{content-layer/markdown → shared}/utils/packed-ast.js +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
2
|
-
import type { NAV_ITEM_RBAC, RbacScope } from '../../../../
|
|
3
|
-
import type {
|
|
2
|
+
import type { NAV_ITEM_RBAC, RbacScope } from '../../../../shared/rbac/types.js';
|
|
3
|
+
import type { SidebarItemType } from '../../../../shared/types/sidebar.js';
|
|
4
4
|
import type { ProblemDraft } from '../../../problems/types.js';
|
|
5
5
|
import { type LinkRefDraft } from '../../../link-checker/classify.js';
|
|
6
6
|
import type { RouteIndex } from '../../utils/route-index.js';
|
|
7
|
+
import { type VersionGroups } from '../../../versions/version-groups.js';
|
|
7
8
|
export type SidebarBadge = {
|
|
8
9
|
name: string;
|
|
9
10
|
color?: string;
|
|
@@ -11,7 +12,7 @@ export type SidebarBadge = {
|
|
|
11
12
|
position?: 'before' | 'after';
|
|
12
13
|
};
|
|
13
14
|
export type BundledSidebarNode = {
|
|
14
|
-
type?:
|
|
15
|
+
type?: SidebarItemType;
|
|
15
16
|
label?: string;
|
|
16
17
|
/** The theme shows this key's translation, `label` when it has none. */
|
|
17
18
|
labelTranslationKey?: string;
|
|
@@ -51,6 +52,15 @@ export type BundledSidebarNode = {
|
|
|
51
52
|
httpVerb?: string;
|
|
52
53
|
deprecated?: boolean;
|
|
53
54
|
badges?: SidebarBadge[];
|
|
55
|
+
/**
|
|
56
|
+
* A page that is an item of another route's sidebar, such as an API operation under its API
|
|
57
|
+
* route: that route's slug and the page's stored slug. The item gives the label and access, and
|
|
58
|
+
* a page the route does not list loses the link.
|
|
59
|
+
*/
|
|
60
|
+
subtreeItem?: {
|
|
61
|
+
route: string;
|
|
62
|
+
link: string;
|
|
63
|
+
};
|
|
54
64
|
/** Server-only RBAC scope. */
|
|
55
65
|
[REDOCLY_TEAMS_RBAC]?: Record<string, string>;
|
|
56
66
|
/** Server-only scope from the entry's `rbac`. */
|
|
@@ -88,6 +98,8 @@ type BundleSidebarOptions = {
|
|
|
88
98
|
sidebarByDirectory?: ReadonlyMap<string, string>;
|
|
89
99
|
/** Route slugs a `directory` entry leaves out. */
|
|
90
100
|
skipRoutes?: ReadonlySet<string>;
|
|
101
|
+
/** The site's version groups; a `page:` path under a default version's route links through them. */
|
|
102
|
+
versionGroups?: VersionGroups;
|
|
91
103
|
};
|
|
92
104
|
export declare function bundleSidebar(options: BundleSidebarOptions & {
|
|
93
105
|
source: string;
|
|
@@ -98,19 +110,8 @@ export declare function bundleSidebarEntries(options: BundleSidebarOptions & {
|
|
|
98
110
|
}): Promise<BundleSidebarResult>;
|
|
99
111
|
/**
|
|
100
112
|
* Stamp `isDefaultVersion` and `versionLabel` on versioned leaves, from
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* later. Reads go through tracked io, so a change re-runs this finalize.
|
|
104
|
-
* Mutates `nodes`.
|
|
113
|
+
* `versionGroups`. Links keep their stored form here; `resolveSidebarNodes`
|
|
114
|
+
* rewrites default-version links later. Mutates `nodes`.
|
|
105
115
|
*/
|
|
106
|
-
export declare function stampDefaultVersions(
|
|
107
|
-
io: {
|
|
108
|
-
exists: (path: string) => Promise<boolean>;
|
|
109
|
-
readFile: (path: string) => Promise<string>;
|
|
110
|
-
};
|
|
111
|
-
routes: RouteIndex;
|
|
112
|
-
nodes: BundledSidebarNode[];
|
|
113
|
-
versionedDirectories: readonly string[];
|
|
114
|
-
logger?: Logger;
|
|
115
|
-
}): Promise<void>;
|
|
116
|
+
export declare function stampDefaultVersions(nodes: BundledSidebarNode[], versionGroups: VersionGroups): void;
|
|
116
117
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L10N_DIR as e}from"../../../../shared/constants/l10n/defaults.js";import{isObject as t}from"../../../../shared/utils/is-object.js";import"../../../../shared/utils/l10n.js";import{resolveContentPath as n}from"../../../../shared/utils/resolve-content-path.js";import{isLocalImagePath as r}from"../assets/extensions.js";import{splitUrlSuffix as i}from"../../../../shared/utils/routes/split-url-suffix.js";import{toNavItemRbacAnnotation as a}from"../../../../server/rbac/filter.js";import{resolvePageTarget as o}from"../../../../shared/utils/routes/resolve-page-target.js";import{collectVersionGroups as s,findVersionedDirectories as c}from"../../../versions/version-groups.js";import{joinSrcSet as l,parseSrcSet as u}from"../assets/srcset.js";import{classifyLinkTarget as d}from"../../../link-checker/classify.js";import{posix as f}from"node:path";import p from"js-yaml";function m(e){return typeof e.tab==`string`}function h(e,t,n){e.report?.({code:t,message:n,location:{filePath:e.file.path}})}function g(e,r){let i=p.load(e);if(!Array.isArray(i))return[];let a=[],o=e=>{if(t(e)){if(typeof e.$ref==`string`){let t=n(e.$ref,r);t!==null&&a.push(t)}if(Array.isArray(e.items))for(let t of e.items)o(t);if(m(e)&&Array.isArray(e.menu))for(let t of e.menu)o(t)}};for(let e of i)o(e);return a}async function _(e){let t=p.load(e.source);if(!Array.isArray(t))return[];let n=[];return await v({entries:t,ownerFilePath:e.filePath,currentFilePath:e.filePath,readFile:e.readFile,visitedRefs:/* @__PURE__ */ new Set([e.filePath]),refs:n}),n}async function v(e){let{ownerFilePath:t,currentFilePath:r,readFile:i,refs:a}=e;for(let o of e.entries){let s=W(o);if(s===void 0)continue;if(typeof s.$ref==`string`){let o=n(s.$ref,r);if(o===null||i===void 0||e.visitedRefs.has(o))continue;let c;try{c=await i(o)}catch{continue}let l=p.load(c);if(!Array.isArray(l))continue;let u=new Set(e.visitedRefs);u.add(o),await v({entries:l,ownerFilePath:t,currentFilePath:o,readFile:i,visitedRefs:u,refs:a});continue}let c=typeof s.page==`string`?s.page:s.href;typeof c==`string`&&y(a,c,r,t),Array.isArray(s.items)&&await v({...e,entries:s.items}),m(s)&&Array.isArray(s.menu)&&await v({...e,entries:s.menu})}}function y(e,t,n,r){let i=d(t,n);i!==null&&e.push({kind:`link`,raw:t,...i,...n===r?{}:{filePath:n}})}async function b(e){let t=p.load(e.source);if(!Array.isArray(t))throw Error(`Sidebar "${e.file.path}" must be a YAML sequence at the top level.`);return x({...e,entries:t})}async function x(e){let n=e.entries,r=n.filter(e=>t(e)&&m(e));if(r.length>0&&r.length!==n.length)throw Error(`Sidebar "${e.file.path}": when a sidebar uses navigation tabs, every top-level entry must be a tab (found ${n.length-r.length} other entries).`);let i={file:e.file,routes:e.routes,assignedRouteSlugs:/* @__PURE__ */ new Set,versionedDirectories:/* @__PURE__ */ new Set,report:e.report,readFile:e.readFile,skipRoutes:e.skipRoutes,exists:e.exists,sidebarByDirectory:e.sidebarByDirectory??/* @__PURE__ */ new Map,visitedRefs:/* @__PURE__ */ new Set([e.file.path])},a=[];if(r.length>0){for(let[e,t]of r.entries())a.push(await M({...i,entry:t,tabIndex:e}));F({file:e.file,tabs:a,routes:e.routes})}else for(let e of n)a.push(...await S({...i,entry:e}));return{assignedRouteSlugs:[...i.assignedRouteSlugs].sort(),versionedDirectories:[...i.versionedDirectories].sort(),nodes:a}}async function S(e){let n=await C(e),r=t(e.entry)?e.entry.rbac:void 0;if(r===void 0)return n;let i=P({...e,rbac:r});for(let e of n)Object.assign(e,i);return n}async function C(e){let t=W(e.entry);if(t===void 0)return h(e,`sidebar/invalid-entry`,`Sidebar entry ${U(e.entry)} is not a page reference or a group.`),[];if(m(t))throw Error(`Sidebar "${e.file.path}": "tab" is only allowed at the top level (found nested tab "${t.tab}").`);if(t.menu!==void 0)throw Error(`Sidebar "${e.file.path}": "menu" is only allowed directly on a tab.`);if(typeof t.$ref==`string`)return T({...e,ref:t.$ref});if(typeof t.directory==`string`&&K(t.group)!==void 0&&t.items===void 0)return C({...e,entry:{...t,directory:void 0,items:[{directory:t.directory,flatten:t.flatten}]}});if(typeof t.directory==`string`){let r=n(t.directory,e.file.path);if(r===null)return h(e,`sidebar/invalid-entry`,`Sidebar directory "${t.directory}" is outside the content root.`),[];let i=e.routes.inDirectory(r);i.length===0&&h(e,`sidebar/missing-target`,`Sidebar directory "${t.directory}" has no pages.`);let a=await L({...e,directoryPath:r,flatten:t.flatten===!0,pages:i.filter(t=>!e.skipRoutes?.has(t.slug))}),o=K(t.group)??K(t.label);return o===void 0?a:[{...J(t,e),menuStyle:Y(t),items:a.length>0?a:void 0,label:o,labelTranslationKey:w(t)}]}if(typeof t.separator==`string`)return[{type:`separator`,...J(t,e),label:t.separator,labelTranslationKey:K(t.separatorTranslationKey)}];let r=await z(t,e),i=r.route;if(i)for(let t of c([i]))e.versionedDirectories.add(t);let a;if(Array.isArray(t.items)){a=[];for(let n of t.items)a.push(...await S({...e,entry:n}))}let o=K(t.group)??K(t.label)??(i===void 0?K(t.href):void 0)??r.anchor,s=K(t.group)!==void 0;return[{...J(t,e),menuStyle:s?Y(t):void 0,external:t.external===!0||void 0,languageInsensitive:r.languageInsensitive?!0:void 0,items:a&&a.length>0?a:void 0,label:o,labelTranslationKey:w(t),link:r.link,isGroup:s?!0:void 0,version:K(t.version)??i?.version??void 0,versionGroup:i?.versionGroup??void 0}]}function w(e){return K(K(e.group)===void 0?e.labelTranslationKey:e.groupTranslationKey)}async function T(e){let{ref:t}=e,r=n(t,e.file.path);if(r===null)return h(e,`sidebar/invalid-entry`,`Sidebar $ref "${t}" is outside the content root.`),[];if(e.readFile===void 0)return h(e,`sidebar/invalid-entry`,`Sidebar $ref "${t}" is not supported here.`),[];if(e.visitedRefs.has(r))return h(e,`sidebar/invalid-entry`,`Sidebar $ref "${r}" includes itself.`),[];let i;try{i=await e.readFile(r)}catch{return h(e,`sidebar/missing-target`,`Sidebar $ref "${r}" could not be read.`),[]}let a=p.load(i);return Array.isArray(a)?E(e,r,a):(h(e,`sidebar/invalid-entry`,`Sidebar $ref "${r}" must be a YAML sequence.`),[])}async function E(e,t,n){let r=/* @__PURE__ */ new Set([...e.visitedRefs,t]),i=[];for(let a of n)i.push(...await S({...e,entry:a,file:{path:t},visitedRefs:r}));return i}async function D(e,t){if(e.readFile===void 0)return[];let n=p.load(await e.readFile(t));return Array.isArray(n)?E({...e,assignedRouteSlugs:/* @__PURE__ */ new Set,report:void 0},t,n.map(O)):[]}function O(e){if(!t(e)||!m(e))return e;let{tab:n,menu:r,...i}=e;return{...i,group:n,items:i.items??r}}function k(e,t){return`${e}-${t.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|(?<!-)-+$/g,``)||`tab`}`}function A(e){return/* @__PURE__ */ Error(`Sidebar "${e.file.path}": tab "${e.label}" ${e.message}.`)}function j(e){let{file:t,entry:n}=e,r=n.tab,i=n.menu!==void 0;if(i&&n.items!==void 0)throw A({file:t,label:r,message:`cannot have both "menu" and "items"`});if(i&&n.page!==void 0)throw A({file:t,label:r,message:`has "menu" and cannot also have "page"`});if(!i&&n.page===void 0)throw A({file:t,label:r,message:`needs "page" or "menu"`});if(typeof n.page==`string`&&n.page.includes(`#`))throw A({file:t,label:r,message:`page must not contain a heading anchor`});if(i&&!Array.isArray(n.menu))throw A({file:t,label:r,message:`"menu" must be a list of entries`});if(i&&Array.isArray(n.menu)&&n.menu.length===0)throw A({file:t,label:r,message:`has an empty "menu"`});if(n.$ref!==void 0||n.directory!==void 0||n.group!==void 0||n.href!==void 0)throw A({file:t,label:r,message:`accepts only "page", "items", "menu" and "icon"; move "$ref"/"directory"/"group"/"href" into "items"`})}async function M(e){let{entry:t}=e,n=t.tab;j({file:e.file,entry:t});let r=k(e.tabIndex,n);if(t.menu!==void 0){let i=Array.isArray(t.menu)?t.menu:[],a=[];for(let[t,n]of i.entries()){let i=await N({...e,tabId:r,index:t,raw:n});i!==void 0&&a.push(i)}return{tab:!0,tabId:r,label:n,menu:a,...X(t.icon,e),...P({...e,rbac:t.rbac})}}let[i]=await S({...e,entry:{page:t.page,label:n,items:t.items,rbac:t.rbac}}),a=i?.items??[];return{...i,tab:!0,tabId:r,...X(t.icon,e),items:a}}async function N(e){let{file:t,entry:n,tabId:r,index:i,raw:a}=e,o=n.tab,s=W(a);if(s===void 0||typeof s.page!=`string`)throw Error(`Sidebar "${t.path}": menu entry ${i+1} of tab "${o}" needs "page".`);if(s.page.includes(`#`))throw Error(`Sidebar "${t.path}": menu entry ${i+1} of tab "${o}" page must not contain a heading anchor.`);let c=`${r}/${i}`,[l]=await S({...e,entry:s});return l?.link===void 0?void 0:{...l,tabId:c,items:l.items??[]}}function P(e){return a(e.rbac,()=>h(e,`sidebar/invalid-entry`,`Sidebar entry has an invalid "rbac" value, so it is hidden.`))}function F(e){let t=/* @__PURE__ */ new Map,n=(n,r)=>{for(let i of r){let r=t.get(i);if(r!==void 0&&r.tabId!==n.tabId)throw Error(`Sidebar "${e.file.path}": route "${i}" is claimed by two navigation tabs, "${r.label}" and "${n.label}". A route can belong to one tab only.`);t.set(i,n)}};for(let t of e.tabs){if(t.menu!==void 0){for(let r of t.menu)r.tabId!==void 0&&n({tabId:r.tabId,label:`${t.label} > ${r.label??r.link}`},I({routes:e.routes,link:r.link,items:r.items}));continue}t.tabId!==void 0&&n({tabId:t.tabId,label:t.label??t.link??``},I({routes:e.routes,link:t.link,items:t.items}))}}function I(e){let t=[],n=n=>{if(n.link===void 0||n.languageInsensitive===!0)return;let r=e.routes.bySlug(n.link);r!==void 0&&r.originFilePath!==null&&t.push(r.slug)};n({link:e.link});let r=e=>{if(e!==void 0)for(let t of e)n(t),r(t.items)};return r(e.items),t}async function L(t){let n=t.directoryPath===``?``:`${t.directoryPath}/`,r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set,o=t.directoryPath.startsWith(`${e}/`),s=t.pages.filter(e=>o||e.locale===``).map(e=>({route:e,relativePath:e.originFilePath?.startsWith(n)?e.originFilePath.slice(n.length):null})).sort((e,t)=>R(e.relativePath??e.route.slug,t.relativePath??t.route.slug));for(let e of s){let n=e.relativePath?.split(`/`).slice(0,-1)??[],r=c(n);if(r!==void 0){if(!a.has(r.path)){a.add(r.path);let e=await D(t,r.path);e.length>0&&u(l(n,r.depth)).push(...e)}continue}V(e.route,t),e.route.version&&t.versionedDirectories.add(t.directoryPath),u(l(n,n.length)).push({link:e.route.slug,version:e.route.version??void 0,versionGroup:e.route.versionGroup??void 0})}return r;function c(e){for(let n=0;n<=e.length;n++){let r=f.join(t.directoryPath,...e.slice(0,n)),i=t.sidebarByDirectory.get(r);if(i!==void 0&&!t.visitedRefs.has(i))return{depth:n,path:i}}}function l(e,n){return t.flatten?[]:e.slice(0,n).filter(e=>!e.startsWith(`@`))}function u(e){let t=r,n=``;for(let r of e){n=n===``?r:`${n}/${r}`;let e=i.get(n);if(e){t=e;continue}let a=[];t.push({items:a,label:r}),i.set(n,a),t=a}return t}}function R(e,t){return e.startsWith(`index.`)?-1:t.startsWith(`index.`)?1:e.localeCompare(t,void 0,{numeric:!0})}async function z(e,t){if(typeof e.page==`string`){let{path:n,suffix:r,anchor:a}=i(e.page.trim()),o=await B(n,t);return o?(e.disconnect!==!0&&V(o,t),{link:`${o.slug}${r}`,anchor:a,route:o}):{}}if(typeof e.href==`string`){let n=e.href;if(n.startsWith(`/`)){let e=t.routes.bySlug(n);return e?{link:e.slug,route:e}:{link:n,languageInsensitive:!0}}return{link:n,languageInsensitive:!0}}return{}}async function B(e,t){let r=o(e,t.file.path,t.routes);if(r.kind===`escaped`){h(t,`sidebar/invalid-entry`,`Sidebar page "${e}" is outside the content root.`);return}if(r.kind===`missing`){let r=n(e,t.file.path);r!==null&&await t.exists?.(r)&&h(t,`sidebar/missing-target`,`Sidebar page "${e}" is a file that makes no page.`);return}return r.value}function V(e,t){t.assignedRouteSlugs.add(e.slug)}async function H(e){if(e.versionedDirectories.length===0)return;let t=await s({io:e.io,routes:e.routes,versionedDirectories:e.versionedDirectories}),n=e=>{for(let r of e){if(r.version!==void 0&&r.versionGroup!==void 0){let e=t.get(r.versionGroup),n=e?.labels.get(r.version);n&&(r.versionLabel=n),e?.defaultVersion===r.version&&(r.isDefaultVersion=!0)}r.items&&n(r.items),r.menu&&n(r.menu)}};n(e.nodes)}function U(e){let t=JSON.stringify(e)??String(e);return t.length>80?`${t.slice(0,79)}…`:t}function W(e){return typeof e==`string`?e.trim()===``?void 0:{page:e}:t(e)?e:void 0}function G(e){if(!Array.isArray(e))return;let n=[];for(let r of e){let e=t(r)?K(r.name):void 0;t(r)&&e!==void 0&&n.push({name:e,color:K(r.color),icon:K(r.icon),position:r.position===`before`||r.position===`after`?r.position:void 0})}return n.length>0?n:void 0}function K(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function q(e,t){return t.find(t=>t===e)}function J(e,t){return{badges:G(e.badges),...X(e.icon,t),expanded:e.expanded===!0?`true`:q(e.expanded,[`always`]),selectFirstItemOnExpand:e.selectFirstItemOnExpand===!0||void 0,separatorLine:e.separatorLine===!0||void 0,linePosition:q(e.linePosition,[`top`,`bottom`]),target:K(e.target),sublabel:K(e.sublabel)}}function Y(e){return q(e.menuStyle,[`drilldown`,`drilldown-header`])}function X(e,n){let r=t(e)?K(e.srcSet):void 0;if(r!==void 0){let e=u(r);if(e===null)return{srcSet:r};for(let t of e)t.src=Z(t.src,n);return{srcSet:l(e)}}let i=K(e);return i===void 0?{}:{icon:Z(i,n)}}function Z(e,t){if(!r(e))return e;let i=n(e,t.file.path);return i===null?(h(t,`sidebar/invalid-entry`,`Sidebar icon "${e}" is outside the content root.`),e):`/${i}`}export{b as bundleSidebar,x as bundleSidebarEntries,_ as collectSidebarLinkRefs,g as collectSidebarRefTargets,H as stampDefaultVersions};
|
|
1
|
+
import{L10N_DIR as e}from"../../../../shared/constants/l10n/defaults.js";import{isObject as t}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as n}from"../../../../shared/utils/routes/normalize-route-slug.js";import"../../../../shared/utils/l10n.js";import{splitUrlSuffix as r}from"../../../../shared/utils/routes/split-url-suffix.js";import{computePathPrefixes as i}from"../../../../shared/utils/routes/compute-path-prefixes.js";import{joinSrcSet as a,parseSrcSet as o}from"../assets/srcset.js";import{toNavItemRbacAnnotation as s}from"../../../../shared/rbac/filter.js";import{resolveContentPath as c}from"../../../../shared/utils/resolve-content-path.js";import{resolvePageTarget as l}from"../../../../shared/utils/routes/resolve-page-target.js";import{isLocalImagePath as u}from"../assets/extensions.js";import{classifyLinkTarget as d}from"../../../link-checker/classify.js";import{physicalVersionedSlug as f}from"../../utils/link-access.js";import{findVersionedDirectories as p}from"../../../versions/version-groups.js";import{posix as m}from"node:path";import h from"js-yaml";function g(e){return typeof e.tab==`string`}function _(e,t,n){e.report?.({code:t,message:n,location:{filePath:e.file.path}})}function v(e,n){let r=h.load(e);if(!Array.isArray(r))return[];let i=[],a=e=>{if(t(e)){if(typeof e.$ref==`string`){let t=c(e.$ref,n);t!==null&&i.push(t)}if(Array.isArray(e.items))for(let t of e.items)a(t);if(g(e)&&Array.isArray(e.menu))for(let t of e.menu)a(t)}};for(let e of r)a(e);return i}async function y(e){let t=h.load(e.source);if(!Array.isArray(t))return[];let n=[];return await b({entries:t,ownerFilePath:e.filePath,currentFilePath:e.filePath,readFile:e.readFile,visitedRefs:/* @__PURE__ */ new Set([e.filePath]),refs:n}),n}async function b(e){let{ownerFilePath:t,currentFilePath:n,readFile:r,refs:i}=e;for(let a of e.entries){let o=K(a);if(o===void 0)continue;if(typeof o.$ref==`string`){let a=c(o.$ref,n);if(a===null||r===void 0||e.visitedRefs.has(a))continue;let s;try{s=await r(a)}catch{continue}let l=h.load(s);if(!Array.isArray(l))continue;let u=new Set(e.visitedRefs);u.add(a),await b({entries:l,ownerFilePath:t,currentFilePath:a,readFile:r,visitedRefs:u,refs:i});continue}let s=typeof o.page==`string`?o.page:o.href;typeof s==`string`&&x(i,s,n,t),Array.isArray(o.items)&&await b({...e,entries:o.items}),g(o)&&Array.isArray(o.menu)&&await b({...e,entries:o.menu})}}function x(e,t,n,r){let i=d(t,n);i!==null&&e.push({kind:`link`,raw:t,...i,...n===r?{}:{filePath:n}})}async function S(e){let t=h.load(e.source);if(!Array.isArray(t))throw Error(`Sidebar "${e.file.path}" must be a YAML sequence at the top level.`);return C({...e,entries:t})}async function C(e){let n=e.entries,r=n.filter(e=>t(e)&&g(e));if(r.length>0&&r.length!==n.length)throw Error(`Sidebar "${e.file.path}": when a sidebar uses navigation tabs, every top-level entry must be a tab (found ${n.length-r.length} other entries).`);let i={file:e.file,routes:e.routes,versionGroups:e.versionGroups??/* @__PURE__ */ new Map,assignedRouteSlugs:/* @__PURE__ */ new Set,versionedDirectories:/* @__PURE__ */ new Set,report:e.report,readFile:e.readFile,skipRoutes:e.skipRoutes,exists:e.exists,sidebarByDirectory:e.sidebarByDirectory??/* @__PURE__ */ new Map,visitedRefs:/* @__PURE__ */ new Set([e.file.path])},a=[];if(r.length>0){for(let[e,t]of r.entries())a.push(await N({...i,entry:t,tabIndex:e}));I({file:e.file,tabs:a,routes:e.routes})}else for(let e of n)a.push(...await w({...i,entry:e}));return{assignedRouteSlugs:[...i.assignedRouteSlugs].sort(),versionedDirectories:[...i.versionedDirectories].sort(),nodes:a}}async function w(e){let n=await T(e),r=t(e.entry)?e.entry.rbac:void 0;if(r===void 0)return n;let i=F({...e,rbac:r});for(let e of n)Object.assign(e,i);return n}async function T(e){let t=K(e.entry);if(t===void 0)return _(e,`sidebar/invalid-entry`,`Sidebar entry ${G(e.entry)} is not a page reference or a group.`),[];if(g(t))throw Error(`Sidebar "${e.file.path}": "tab" is only allowed at the top level (found nested tab "${t.tab}").`);if(t.menu!==void 0)throw Error(`Sidebar "${e.file.path}": "menu" is only allowed directly on a tab.`);if(typeof t.$ref==`string`)return k({...e,ref:t.$ref});if(typeof t.directory==`string`&&O(t)&&t.items===void 0)return T({...e,entry:{...t,directory:void 0,items:[{directory:t.directory,flatten:t.flatten}]}});if(typeof t.directory==`string`){let n=c(t.directory,e.file.path);if(n===null)return _(e,`sidebar/invalid-entry`,`Sidebar directory "${t.directory}" is outside the content root.`),[];let r=e.routes.inDirectory(n);r.length===0&&_(e,`sidebar/missing-target`,`Sidebar directory "${t.directory}" has no pages.`);let i=await R({...e,directoryPath:n,flatten:t.flatten===!0,pages:r.filter(t=>!e.skipRoutes?.has(t.slug))}),a=J(t.group)??J(t.label);return a===void 0?i:[{type:`group`,...X(t,e),menuStyle:Z(t),items:i.length>0?i:void 0,label:a,labelTranslationKey:D(t)}]}if(typeof t.separator==`string`)return[{type:`separator`,...X(t,e),label:t.separator,labelTranslationKey:J(t.separatorTranslationKey)}];let n=await B(t,e),r=n.route;if(r)for(let t of p([r]))e.versionedDirectories.add(t);let i;if(Array.isArray(t.items)){i=[];for(let n of t.items)i.push(...await w({...e,entry:n}))}let a=J(t.group)??J(t.label)??(r===void 0?J(t.href):void 0)??n.anchor,o=O(t);return[{type:E(t,!!n.link,n.linksConnectedHeading===!0),...X(t,e),menuStyle:o?Z(t):void 0,external:t.external===!0||void 0,languageInsensitive:n.languageInsensitive?!0:void 0,items:i&&i.length>0?i:void 0,label:a,labelTranslationKey:D(t),link:n.link,isGroup:o?!0:void 0,version:J(t.version)??r?.version??void 0,versionGroup:r?.versionGroup??void 0,subtreeItem:n.subtreeItem}]}function E(e,t,n){if(O(e)&&!n)return`group`;if(t||e.label)return`link`}function D(e){return J(O(e)?e.groupTranslationKey:e.labelTranslationKey)}function O(e){return J(e.group)!==void 0}async function k(e){let{ref:t}=e,n=c(t,e.file.path);if(n===null)return _(e,`sidebar/invalid-entry`,`Sidebar $ref "${t}" is outside the content root.`),[];if(e.readFile===void 0)return _(e,`sidebar/invalid-entry`,`Sidebar $ref "${t}" is not supported here.`),[];if(e.visitedRefs.has(n))return _(e,`sidebar/invalid-entry`,`Sidebar $ref "${n}" includes itself.`),[];let r;try{r=await e.readFile(n)}catch{return _(e,`sidebar/missing-target`,`Sidebar $ref "${n}" could not be read.`),[]}let i=h.load(r);return Array.isArray(i)?A(e,n,i):(_(e,`sidebar/invalid-entry`,`Sidebar $ref "${n}" must be a YAML sequence.`),[])}async function A(e,t,n){let r=/* @__PURE__ */ new Set([...e.visitedRefs,t]),i=[];for(let a of n)i.push(...await w({...e,entry:a,file:{path:t},visitedRefs:r}));return i}async function ee(e,t){if(e.readFile===void 0)return[];let n=h.load(await e.readFile(t));return Array.isArray(n)?A({...e,assignedRouteSlugs:/* @__PURE__ */ new Set,report:void 0},t,n.map(te)):[]}function te(e){if(!t(e)||!g(e))return e;let{tab:n,menu:r,...i}=e;return{...i,group:n,items:i.items??r}}function ne(e,t){return`${e}-${t.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|(?<!-)-+$/g,``)||`tab`}`}function j(e){return/* @__PURE__ */ Error(`Sidebar "${e.file.path}": tab "${e.label}" ${e.message}.`)}function M(e){let{file:t,entry:n}=e,r=n.tab,i=n.menu!==void 0;if(i&&n.items!==void 0)throw j({file:t,label:r,message:`cannot have both "menu" and "items"`});if(i&&n.page!==void 0)throw j({file:t,label:r,message:`has "menu" and cannot also have "page"`});if(!i&&n.page===void 0)throw j({file:t,label:r,message:`needs "page" or "menu"`});if(typeof n.page==`string`&&n.page.includes(`#`))throw j({file:t,label:r,message:`page must not contain a heading anchor`});if(i&&!Array.isArray(n.menu))throw j({file:t,label:r,message:`"menu" must be a list of entries`});if(i&&Array.isArray(n.menu)&&n.menu.length===0)throw j({file:t,label:r,message:`has an empty "menu"`});if(n.$ref!==void 0||n.directory!==void 0||n.group!==void 0||n.href!==void 0)throw j({file:t,label:r,message:`accepts only "page", "items", "menu" and "icon"; move "$ref"/"directory"/"group"/"href" into "items"`})}async function N(e){let{entry:t}=e,n=t.tab;M({file:e.file,entry:t});let r=ne(e.tabIndex,n);if(t.menu!==void 0){let i=Array.isArray(t.menu)?t.menu:[],a=[];for(let[t,n]of i.entries()){let i=await P({...e,tabId:r,index:t,raw:n});i!==void 0&&a.push(i)}return{tab:!0,tabId:r,label:n,menu:a,...Q(t.icon,e),...F({...e,rbac:t.rbac})}}let[i]=await w({...e,entry:{page:t.page,label:n,items:t.items,rbac:t.rbac}}),a=i?.items??[];return{...i,tab:!0,tabId:r,...Q(t.icon,e),items:a}}async function P(e){let{file:t,entry:n,tabId:r,index:i,raw:a}=e,o=n.tab,s=K(a);if(s===void 0||typeof s.page!=`string`)throw Error(`Sidebar "${t.path}": menu entry ${i+1} of tab "${o}" needs "page".`);if(s.page.includes(`#`))throw Error(`Sidebar "${t.path}": menu entry ${i+1} of tab "${o}" page must not contain a heading anchor.`);let c=`${r}/${i}`,[l]=await w({...e,entry:s});return l?.link===void 0?void 0:{...l,tabId:c,items:l.items??[]}}function F(e){return s(e.rbac,()=>_(e,`sidebar/invalid-entry`,`Sidebar entry has an invalid "rbac" value, so it is hidden.`))}function I(e){let t=/* @__PURE__ */ new Map,n=(n,r)=>{for(let i of r){let r=t.get(i);if(r!==void 0&&r.tabId!==n.tabId)throw Error(`Sidebar "${e.file.path}": route "${i}" is claimed by two navigation tabs, "${r.label}" and "${n.label}". A route can belong to one tab only.`);t.set(i,n)}};for(let t of e.tabs){if(t.menu!==void 0){for(let r of t.menu)r.tabId!==void 0&&n({tabId:r.tabId,label:`${t.label} > ${r.label??r.link}`},L({routes:e.routes,link:r.link,items:r.items}));continue}t.tabId!==void 0&&n({tabId:t.tabId,label:t.label??t.link??``},L({routes:e.routes,link:t.link,items:t.items}))}}function L(e){let t=[],n=n=>{if(n.link===void 0||n.languageInsensitive===!0)return;let r=e.routes.bySlug(n.link);r!==void 0&&r.originFilePath!==null&&t.push(r.slug)};n({link:e.link});let r=e=>{if(e!==void 0)for(let t of e)n(t),r(t.items)};return r(e.items),t}async function R(t){let n=t.directoryPath===``?``:`${t.directoryPath}/`,r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set,o=t.directoryPath.startsWith(`${e}/`),s=t.pages.filter(e=>o||e.locale===``).map(e=>({route:e,relativePath:e.originFilePath?.startsWith(n)?e.originFilePath.slice(n.length):null})).sort((e,t)=>z(e.relativePath??e.route.slug,t.relativePath??t.route.slug));for(let e of s){let n=e.relativePath?.split(`/`).slice(0,-1)??[],r=c(n);if(r!==void 0){if(!a.has(r.path)){a.add(r.path);let e=await ee(t,r.path);e.length>0&&u(l(n,r.depth)).push(...e)}continue}U(e.route,t),e.route.version&&t.versionedDirectories.add(t.directoryPath),u(l(n,n.length)).push({type:`link`,link:e.route.slug,version:e.route.version??void 0,versionGroup:e.route.versionGroup??void 0})}return r;function c(e){for(let n=0;n<=e.length;n++){let r=m.join(t.directoryPath,...e.slice(0,n)),i=t.sidebarByDirectory.get(r);if(i!==void 0&&!t.visitedRefs.has(i))return{depth:n,path:i}}}function l(e,n){return t.flatten?[]:e.slice(0,n).filter(e=>!e.startsWith(`@`))}function u(e){let t=r,n=``;for(let r of e){n=n===``?r:`${n}/${r}`;let e=i.get(n);if(e){t=e;continue}let a=[];t.push({type:`group`,items:a,label:r}),i.set(n,a),t=a}return t}}function z(e,t){return e.startsWith(`index.`)?-1:t.startsWith(`index.`)?1:e.localeCompare(t,void 0,{numeric:!0})}async function B(e,t){if(typeof e.page==`string`){let{path:i,suffix:a,anchor:o}=r(e.page.trim()),s=await V(i,t);if(!s){let e=H(i,t);return e===void 0?{}:{link:`${n(i)}${a}`,anchor:o,subtreeItem:e}}let c=e.disconnect!==!0;return c&&U(s,t),{link:`${s.slug}${a}`,anchor:o,linksConnectedHeading:c&&o!==void 0,route:s}}if(typeof e.href==`string`){let n=e.href;if(n.startsWith(`/`)){let e=t.routes.bySlug(n);return e?{link:e.slug,route:e}:{link:n,languageInsensitive:!0}}return{link:n,languageInsensitive:!0}}return{}}async function V(e,t){let n=l(e,t.file.path,t.routes);if(n.kind===`escaped`){_(t,`sidebar/invalid-entry`,`Sidebar page "${e}" is outside the content root.`);return}if(n.kind===`missing`){let n=c(e,t.file.path);n!==null&&await t.exists?.(n)&&_(t,`sidebar/missing-target`,`Sidebar page "${e}" is a file that makes no page.`);return}return n.value}function H(e,t){if(!e.startsWith(`/`))return;let r=n(e),a=[r,f(r,t.versionGroups)].find(e=>e!==null&&t.routes.getAccess(e)!==void 0);if(a!=null)for(let e of i(a).slice(0,-1).reverse()){let n=t.routes.bySlug(e);if(n?.sidebarSubtreeEntityKey)return{route:n.slug,link:a}}}function U(e,t){t.assignedRouteSlugs.add(e.slug)}function W(e,t){let n=e=>{for(let r of e){if(r.version!==void 0&&r.versionGroup!==void 0){let e=t.get(r.versionGroup),n=e?.labels.get(r.version);n&&(r.versionLabel=n),e?.defaultVersion===r.version&&(r.isDefaultVersion=!0)}r.items&&n(r.items),r.menu&&n(r.menu)}};n(e)}function G(e){let t=JSON.stringify(e)??String(e);return t.length>80?`${t.slice(0,79)}…`:t}function K(e){return typeof e==`string`?e.trim()===``?void 0:{page:e}:t(e)?e:void 0}function q(e){if(!Array.isArray(e))return;let n=[];for(let r of e){if(!t(r))continue;let e=J(r.name),i=J(r.icon);(e!==void 0||i!==void 0)&&n.push({name:e??``,color:J(r.color),icon:i,position:r.position===`before`||r.position===`after`?r.position:void 0})}return n.length>0?n:void 0}function J(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function Y(e,t){return t.find(t=>t===e)}function X(e,t){return{badges:q(e.badges),...Q(e.icon,t),expanded:e.expanded===!0?`true`:Y(e.expanded,[`always`]),selectFirstItemOnExpand:e.selectFirstItemOnExpand===!0||void 0,separatorLine:e.separatorLine===!0||void 0,linePosition:Y(e.linePosition,[`top`,`bottom`]),target:J(e.target),sublabel:J(e.sublabel)}}function Z(e){return Y(e.menuStyle,[`drilldown`,`drilldown-header`])}function Q(e,n){let r=t(e)?J(e.srcSet):void 0;if(r!==void 0){let e=o(r);if(e===null)return{srcSet:r};for(let t of e)t.src=$(t.src,n);return{srcSet:a(e)}}let i=J(e);return i===void 0?{}:{icon:$(i,n)}}function $(e,t){if(!u(e))return e;let n=c(e,t.file.path);return n===null?(_(t,`sidebar/invalid-entry`,`Sidebar icon "${e}" is outside the content root.`),e):`/${n}`}export{S as bundleSidebar,C as bundleSidebarEntries,y as collectSidebarLinkRefs,v as collectSidebarRefTargets,W as stampDefaultVersions};
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
2
2
|
import { type BundledSidebarNode, type SidebarBadge } from './bundle.js';
|
|
3
3
|
import { type VersionStamp } from './subtree.js';
|
|
4
|
-
import { NAV_ITEM_RBAC, type RbacScope } from '../../../../
|
|
4
|
+
import { NAV_ITEM_RBAC, type RbacScope } from '../../../../shared/rbac/types.js';
|
|
5
|
+
import type { SidebarItemType } from '../../../../shared/types/sidebar.js';
|
|
5
6
|
import { SIDEBAR_ROUTE_DEP_KEY } from '../../../../shared/constants/route-deps.js';
|
|
6
7
|
export declare const SIDEBAR_PLUGIN_ID = "internal.sidebar";
|
|
7
8
|
export declare const SIDEBAR_AGGREGATOR_LOADER_ID: "internal.sidebar:aggregate";
|
|
8
9
|
export { SIDEBAR_ROUTE_DEP_KEY };
|
|
10
|
+
/** `sidebars.yaml`, or a file name that ends in `.sidebars.yaml`, `_sidebars.yaml` or `-sidebars.yaml`. */
|
|
9
11
|
export declare const SIDEBAR_FILENAME_REGEX: RegExp;
|
|
10
|
-
/** A folder's own sidebar; a named
|
|
12
|
+
/** A folder's own sidebar; a named `*sidebars.yaml` is not one. */
|
|
11
13
|
export declare const FOLDER_SIDEBAR_FILENAME_REGEX: RegExp;
|
|
12
14
|
export type ResolvedSidebarItem = {
|
|
13
|
-
type?:
|
|
15
|
+
type?: SidebarItemType;
|
|
14
16
|
label?: string;
|
|
15
17
|
labelTranslationKey?: string;
|
|
16
18
|
link?: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t,createInlineEntity as n}from"../../../loaders/define.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import"../../../../shared/constants/l10n/defaults.js";import{NAV_ITEM_RBAC as i}from"../../../../server/rbac/types.js";import{compareStrings as a}from"../../../../shared/utils/compare-strings.js";import{isObject as o}from"../../../../shared/utils/is-object.js";import{toLocaleSlug as s}from"../../../../shared/utils/l10n.js";import{resolveContentPath as c}from"../../../../shared/utils/resolve-content-path.js";import{isLocalImagePath as l}from"../assets/extensions.js";import{splitUrlSuffix as u}from"../../../../shared/utils/routes/split-url-suffix.js";import{resolvePageTarget as d}from"../../../../shared/utils/routes/resolve-page-target.js";import{toPublicVersionedSlug as f}from"../../../../shared/constants/versions.js";import{collectVersionGroups as p,findVersionedDirectories as ee}from"../../../versions/version-groups.js";import{publicLink as m}from"../../../versions/public-link.js";import{linkedPageAccess as h}from"../../utils/link-access.js";import{safeDecodeURI as g}from"../../../../shared/utils/safe-decode-uri.js";import{joinSrcSet as _,parseSrcSet as v}from"../assets/srcset.js";import{bundleSidebar as y,bundleSidebarEntries as te,collectSidebarLinkRefs as b,collectSidebarRefTargets as ne,stampDefaultVersions as x}from"./bundle.js";import{SIDEBAR_CONTRIBUTIONS_ENTITY_TYPE as S,sidebarStartEntityKey as re}from"./contributions.js";import{applySubtree as C}from"./subtree.js";import{collectSlugOverrides as w}from"../../utils/slug-overrides.js";import{SIDEBAR_BACK_LINK_ROUTE_DEP_KEY as ie,SIDEBAR_BREADCRUMBS_ROUTE_DEP_KEY as T,SIDEBAR_ROUTE_DEP_KEY as E,localizedSidebarDepKey as D}from"../../../../shared/constants/route-deps.js";import{SITE_START_ENTITY_KEY as ae}from"../../../../shared/constants/site-start.js";import{posix as O}from"node:path";import{REDOCLY_TEAMS_RBAC as k}from"@redocly/config";const A=`internal.sidebar`,j=r(A,`aggregate`),M=/(^|\/)(?:[^/]*\.)?sidebars\.ya?ml$/i,N=/(^|\/)sidebars\.ya?ml$/i,P=`sidebars.yaml`,F=`redocly.yaml`;function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Array.isArray(e.tabs)}function L(e){if(Array.isArray(e))return e.find(e=>R(e.label)!==void 0)?.label}function R(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function z(e){let t=((e??``).split(/[?#]/)[0]?.split(`/`).filter(Boolean).pop()??``).replace(/[-_]+/g,` `).trim();return t.charAt(0).toUpperCase()+t.slice(1)}async function B(e,t){let n=[];for(let r of e){let e=r.link?t.subtreeKeyOf(r.link):void 0,a=e?await t.loadEntity(e):void 0,o=r.tabId!==void 0,s=o?{...r,isGroup:!0,label:r.label??L(a)}:r,c=a===void 0?[s]:C(s,a);for(let e of c){let a=e[`redocly::nav-item-rbac`]??r[`redocly::nav-item-rbac`],s=e[k]??(a===void 0&&e.link!==void 0?t.accessOf(e.link)??void 0:void 0);n.push({type:e.type,expanded:e.expanded,selectFirstItemOnExpand:e.selectFirstItemOnExpand,external:e.external,target:e.target,languageInsensitive:e.languageInsensitive,icon:e.icon===void 0?void 0:await t.resolveAsset(e.icon),srcSet:e.srcSet===void 0?void 0:await V(e.srcSet,t),items:e.items?await B(e.items,t):void 0,tab:e.tab,tabId:e.tabId,menu:e.menu?await B(e.menu,t):void 0,label:o?e.label??z(e.link):e.label,labelTranslationKey:e.labelTranslationKey,link:e.link!==void 0&&e.versionGroup!==void 0&&e.version!==void 0?f(e.link,e.versionGroup,e.version,e.isDefaultVersion===!0):e.link,separatorLine:e.separatorLine,linePosition:e.linePosition,variant:e.variant,menuStyle:e.menuStyle,sublabel:e.sublabel,version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel,httpVerb:e.httpVerb,deprecated:e.deprecated,badges:e.badges,[k]:s,[i]:a})}}return n}async function V(e,t){let n=v(e);if(n===null)return e;let r=await Promise.all(n.map(async e=>Object.assign(e,{src:await t.resolveAsset(e.src)})));return _(r)}function H(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;return{async resolve(r){if(!l(r))return r;let i=await e.resolveImageReference(r,``),a=c(g(r),``);a!==null&&t.set(`file:${a}`,{kind:`file`,path:a});for(let e of i.entityDeps)t.set(e.kind===`file`?`file:${e.path}`:`entity:${e.key}`,e);for(let e of i.assetUsages)n.set(e.path,e);return i.result.kind===`assetRef`?i.result.url:r},collected(){return{entityDeps:[...t.values()],assetUsages:[...n.values()]}}}}function U(e){return e.tabId!==void 0}function W(e){return U(e)&&e.link!==void 0}function G(e){return{tabId:e.tabId,version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel,[k]:e[k],[i]:e[i]}}function K(e){return{...G(e),label:e.label,labelTranslationKey:e.labelTranslationKey,link:e.link,icon:e.icon,items:e.items??[]}}function q(e){return{...G(e),label:e.label,labelTranslationKey:e.labelTranslationKey,link:e.menu?void 0:e.link,icon:e.icon,items:e.menu?void 0:e.items??[],menu:e.menu?.filter(W).map(K)}}const J=t(j,async e=>{let t=H(e.markdown),{locale:n,slugOverrides:r={},versionedDirectories:i=[]}=e.args,a=t=>e.routes.bySlug(t)?.sidebarSubtreeEntityKey,o=i.length===0?/* @__PURE__ */ new Map:await p({io:e.io,routes:e.routes,versionedDirectories:i}),c=await B(e.args.nodes,{loadEntity:t=>e.entities.load(t),subtreeKeyOf:e=>(n===void 0?void 0:a(r[e]??s(e,n)))??a(e),accessOf:t=>h(t,e.routes,o),resolveAsset:t.resolve});return{value:e.args.nodes.some(e=>e.tab)?{tabs:c.filter(U).map(q)}:c,...t.collected()}});async function oe(e){let t=await e.loadEntity(e.subtreeKey);return B(C({link:e.routeSlug,...e.version},t),{loadEntity:e.loadEntity,subtreeKeyOf:()=>void 0,accessOf:()=>void 0,resolveAsset:async e=>e})}function se(e){let t=typeof e==`string`?e:o(e)?e.path:void 0;return typeof t==`string`&&t.trim()!==``?t.trim():null}function Y(e){return[e.originPluginId,e.originFilePath,e.routeId].join(`\0`)}async function X(e,t){let n=/* @__PURE__ */ new Map;for(let r of e.assignedRouteSlugs){let e=t.routes.bySlug(r),i=e?.originFilePath===null?e.sidebarSubtreeEntityKey:null;if(!i||await t.entities.get(i)===null)continue;let a=e=>{for(let i of e){let e=i.link===void 0?void 0:t.routes.bySlug(i.link);e!==void 0&&!n.has(e.slug)&&n.set(e.slug,r),i.items&&a(i.items)}};a(C({link:r},await t.entities.load(i)))}return n}function ce(e,t){for(let n of t)for(let[t,r]of n){let n=e.get(r);n!==void 0&&!e.has(t)&&e.set(t,n)}}async function le(e){let t=[];for(let n of await e.list({type:S}))t.push(...await e.load(n.key));return t}function ue(e,t=[]){let n=[];for(let[r,i]of e.entries()){if(t[r]?.link!==i.link)break;n.push(i)}return n}async function de(e,t,n,r,i){let a=await Promise.all(e.map(async e=>{let r=fe(e,t,n);return r===null?null:{item:e,link:r.link,label:await Z(e,r,i)}})),o=/* @__PURE__ */ new Map;for(let{item:e,link:t,label:n}of a.filter(e=>e!==null))for(let i of e.linkedSidebars??[]){let e=c(i,F),a=e===null?void 0:r.get(e);a!==void 0&&!o.has(a)&&o.set(a,{label:n,link:t})}return o}function fe(e,t,n){if(typeof e.href==`string`&&e.href.trim()!==``)return{link:e.href.trim()};if(typeof e.page!=`string`||e.page.trim()===``)return null;let{path:r,suffix:i,anchor:a}=u(e.page.trim()),o=d(r,F,t);if(o.kind!==`found`)return null;let s=o.value;return{link:`${m(s,n)}${i}`,anchor:a,route:s}}async function Z(e,t,n){let r=R(e.label)??R(e.group)??t.anchor;if(r!==void 0)return r;let i=t.route?.sidebarSubtreeEntityKey,a=i?await n(i):void 0;return(o(a)?R(a.label):void 0)??t.link}function Q(e,t){for(let n of e){if(!t(n))continue;if(n.link!==void 0&&n.languageInsensitive!==!0)return n;let e=Q([...n.items??[],...n.menu??[]],t);if(e!==null)return e}return null}function pe(e,t){return Q(e,e=>e.version===void 0||e.version===t)?.link??null}function $(e){let t=Q(e,e=>e.version===void 0||e.isDefaultVersion===!0);return t?.link===void 0?null:t.versionGroup!==void 0&&t.version!==void 0?f(t.link,t.versionGroup,t.version,!0):t.link}function me(e){let[t]=e;if(t===void 0)return null;let n=t.path.split(`/`).length;return(e.find(({path:e})=>e.split(`/`).length===n&&N.test(e))??t).link}function he(e){let t=null;for(let{slug:n,originFilePath:r,locale:i,versionGroup:o}of e)r!==null&&i===``&&o===null&&(t===null||n.length<t.length||n.length===t.length&&a(n,t)<0)&&(t=n);return t}const ge=e({id:A,version:`1.23.0`,content:{filter:{match:e=>M.test(e)},async extractFile(e,t){let n=await t.io.readFile(e.path);return{routes:[],linkRefs:await b({source:n,filePath:e.path,readFile:t.io.readFile})}}},async finalize(e){let t=[],r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=[],c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,d=[],f=await Promise.all(e.files.map(async t=>({path:t.path,source:await e.io.readFile(t.path)}))),m=e.routes.all(),g=w(m,e.localeContext),_=ee(m),v=_.length>0?_:void 0;f.sort((e,t)=>e.path.split(`/`).length-t.path.split(`/`).length);let b=new Map(f.map(({path:e,source:t})=>[e,t])),S=/* @__PURE__ */ new Map;for(let{path:e}of f)N.test(e)&&S.set(O.dirname(e),e);let C=/* @__PURE__ */ new Set;for(let{path:e,source:t}of f)for(let n of ne(t,e))C.add(n);let A={routes:e.routes,report:e=>r.push(e),readFile:async t=>b.get(t)??e.io.readFile(t),exists:t=>e.io.exists(t),sidebarByDirectory:S},j=async(n,r)=>{if(n.nodes.length===0)return;await x({io:e.io,routes:e.routes,logger:e.logger,nodes:n.nodes,versionedDirectories:_});let i=J.withArgs({nodes:n.nodes,versionedDirectories:v},r===void 0?void 0:{metadata:{sourcePath:r}});t.push(i),l.set(i,n.nodes);let a=/* @__PURE__ */ new Map;for(let r of e.localeContext.locales){let e=J.withArgs({nodes:n.nodes,locale:r,slugOverrides:g[r]??{},versionedDirectories:v});t.push(e),a.set(r,e)}return c.set(i,a),i};for(let{path:t,source:n}of f){if(C.has(t))continue;let c=await y({...A,file:{path:t},source:n}),l=await j(c,t);if(l===void 0)continue;a.set(t,l);let u=t.startsWith(`@l10n/`)?null:$(c.nodes);u!==null&&d.push({path:t,link:u}),s.push(await X(c,e));for(let e of c.assignedRouteSlugs){let n=o.get(e);n!==void 0&&r.push({code:`sidebar/route-conflict`,message:`Page "${e}" is in sidebars ${n} and ${t}; it shows ${t}.`,location:{filePath:t}}),i.set(e,l),o.set(e,t)}}ce(i,s);let M=new Map(m.map(e=>[e.slug,e]));for(let[t,n]of Object.entries(e.routes.metadata(`sidebar`))){let e=M.get(t);if(e===void 0||e.originFilePath===null)continue;let o=se(n);if(o===null)continue;let s=O.normalize(o.startsWith(`/`)?o.slice(1):O.join(O.dirname(e.originFilePath),o)),c=a.get(s);if(c===void 0){r.push({code:`sidebar/missing-target`,message:`Front matter sidebar "${o}" is not a sidebar file of this project.`,location:{filePath:e.originFilePath}});continue}i.set(e.slug,c)}let F=await le(e.entities),I=/* @__PURE__ */ new Set,L=/* @__PURE__ */ new Map,R=/* @__PURE__ */ new Map;for(let t of F){let n=i.get(t.route);if(n===void 0){let r=await te({...A,file:{path:P},entries:t.entries});if(n=await j(r),n===void 0)continue;let a=(await X(r,e)).keys();for(let e of[...r.assignedRouteSlugs,...a])i.has(e)||(i.set(e,n),I.add(e))}let r=L.get(n);L.set(n,r===void 0?t.backLink??null:r!==null&&r.link===t.backLink?.link?r:null);let a=R.get(n);R.set(n,a===void 0?t.breadcrumbs??[]:ue(a,t.breadcrumbs))}if(f.length===0&&m.length>0){let e=await y({...A,file:{path:P},source:`- directory: .
|
|
2
|
-
`,skipRoutes:
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t,createInlineEntity as n}from"../../../loaders/define.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import"../../../../shared/constants/l10n/defaults.js";import{compareStrings as i}from"../../../../shared/utils/compare-strings.js";import{isObject as a}from"../../../../shared/utils/is-object.js";import{toLocaleSlug as o}from"../../../../shared/utils/l10n.js";import{SIDEBAR_BACK_LINK_ROUTE_DEP_KEY as s,SIDEBAR_BREADCRUMBS_ROUTE_DEP_KEY as c,SIDEBAR_ROUTE_DEP_KEY as l,localizedSidebarDepKey as ee}from"../../../../shared/constants/route-deps.js";import{toPublicVersionedSlug as u}from"../../../../shared/constants/versions.js";import{splitUrlSuffix as d}from"../../../../shared/utils/routes/split-url-suffix.js";import{joinSrcSet as f,parseSrcSet as p}from"../assets/srcset.js";import{applySubtree as m}from"./subtree.js";import{NAV_ITEM_RBAC as h}from"../../../../shared/rbac/types.js";import{resolveContentPath as g}from"../../../../shared/utils/resolve-content-path.js";import{resolvePageTarget as _}from"../../../../shared/utils/routes/resolve-page-target.js";import{isLocalImagePath as v}from"../assets/extensions.js";import{safeDecodeURI as y}from"../../../../shared/utils/safe-decode-uri.js";import{linkedPageAccess as b}from"../../utils/link-access.js";import{collectVersionGroups as x,findVersionedDirectories as te}from"../../../versions/version-groups.js";import{bundleSidebar as S,bundleSidebarEntries as ne,collectSidebarLinkRefs as C,collectSidebarRefTargets as re,stampDefaultVersions as w}from"./bundle.js";import{SIDEBAR_CONTRIBUTIONS_ENTITY_TYPE as T,sidebarStartEntityKey as E}from"./contributions.js";import{collectSlugOverrides as ie}from"../../utils/slug-overrides.js";import{SITE_START_ENTITY_KEY as ae}from"../../../../shared/constants/site-start.js";import{publicLink as D}from"../../../versions/public-link.js";import{posix as O}from"node:path";import{REDOCLY_TEAMS_RBAC as k}from"@redocly/config";const A=`internal.sidebar`,j=r(A,`aggregate`),M=/(^|[/._-])sidebars\.ya?ml$/,N=/(^|\/)sidebars\.ya?ml$/,P=`sidebars.yaml`,F=`redocly.yaml`;function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Array.isArray(e.tabs)}function L(e){if(Array.isArray(e))return e.find(e=>R(e.label)!==void 0)?.label}function R(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function z(e){let t=((e??``).split(/[?#]/)[0]?.split(`/`).filter(Boolean).pop()??``).replace(/[-_]+/g,` `).trim();return t.charAt(0).toUpperCase()+t.slice(1)}async function B(e,{route:t,link:n},r){let i=r.subtreeKeyOf(t);if(!i)return{...e,link:void 0};let a=await r.loadEntity(i);if(a===void 0)return{...e,label:e.label??z(e.link)};let o=V(m({link:t},a),n.toLowerCase());return o===void 0?{...e,link:void 0}:{...e,label:e.label??o.label,[k]:o[k]}}function V(e,t){for(let n of e){if(n.link?.toLowerCase()===t)return n;let e=n.items===void 0?void 0:V(n.items,t);if(e!==void 0)return e}}async function H(e,t){let n=[];for(let r of e){let e=r.subtreeItem===void 0?r:await B(r,r.subtreeItem,t),i=e.link?t.subtreeKeyOf(e.link):void 0,a=i?await t.loadEntity(i):void 0,o=e.tabId!==void 0,s=o||!!i&&a===void 0,c=o?{...e,isGroup:!0,label:e.label??L(a)}:e,l=a===void 0?[c]:m(c,a);for(let r of l){let i=r[`redocly::nav-item-rbac`]??e[`redocly::nav-item-rbac`],a=r[k]??(i===void 0&&r.link!==void 0?t.accessOf(r.link)??void 0:void 0);n.push({type:r.type,expanded:r.expanded,selectFirstItemOnExpand:r.selectFirstItemOnExpand,external:r.external,target:r.target,languageInsensitive:r.languageInsensitive,icon:r.icon===void 0?void 0:await t.resolveAsset(r.icon),srcSet:r.srcSet===void 0?void 0:await U(r.srcSet,t),items:r.items?await H(r.items,t):void 0,tab:r.tab,tabId:r.tabId,menu:r.menu?await H(r.menu,t):void 0,label:s?r.label??z(r.link):r.label,labelTranslationKey:r.labelTranslationKey,link:r.link!==void 0&&r.versionGroup!==void 0&&r.version!==void 0?u(r.link,r.versionGroup,r.version,r.isDefaultVersion===!0):r.link,separatorLine:r.separatorLine,linePosition:r.linePosition,variant:r.variant,menuStyle:r.menuStyle,sublabel:r.sublabel,version:r.version,versionGroup:r.versionGroup,isDefaultVersion:r.isDefaultVersion,versionLabel:r.versionLabel,httpVerb:r.httpVerb,deprecated:r.deprecated,badges:r.badges,[k]:a,[h]:i})}}return n}async function U(e,t){let n=p(e);if(n===null)return e;let r=await Promise.all(n.map(async e=>Object.assign(e,{src:await t.resolveAsset(e.src)})));return f(r)}function W(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;return{async resolve(r){if(!v(r))return r;let i=await e.resolveImageReference(r,``),a=g(y(r),``);a!==null&&t.set(`file:${a}`,{kind:`file`,path:a});for(let e of i.entityDeps)t.set(e.kind===`file`?`file:${e.path}`:`entity:${e.key}`,e);for(let e of i.assetUsages)n.set(e.path,e);return i.result.kind===`assetRef`?i.result.url:r},collected(){return{entityDeps:[...t.values()],assetUsages:[...n.values()]}}}}function G(e){return e.tabId!==void 0}function K(e){return G(e)&&e.link!==void 0}function q(e){return{tabId:e.tabId,version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel,[k]:e[k],[h]:e[h]}}function oe(e){return{...q(e),label:e.label,labelTranslationKey:e.labelTranslationKey,link:e.link,icon:e.icon,items:e.items??[]}}function se(e){return{...q(e),label:e.label,labelTranslationKey:e.labelTranslationKey,link:e.menu?void 0:e.link,icon:e.icon,items:e.menu?void 0:e.items??[],menu:e.menu?.filter(K).map(oe)}}const J=t(j,async e=>{let t=W(e.markdown),{locale:n,slugOverrides:r={},versionedDirectories:i=[]}=e.args,a=t=>e.routes.bySlug(t)?.sidebarSubtreeEntityKey,s=i.length===0?/* @__PURE__ */ new Map:await x({io:e.io,routes:e.routes,versionedDirectories:i}),c=await H(e.args.nodes,{loadEntity:t=>e.entities.tryLoad(t),subtreeKeyOf:e=>(n===void 0?void 0:a(r[e]??o(e,n)))??a(e),accessOf:t=>b(t,e.routes,s),resolveAsset:t.resolve});return{value:e.args.nodes.some(e=>e.tab)?{tabs:c.filter(G).map(se)}:c,...t.collected()}});async function ce(e){let t=await e.loadEntity(e.subtreeKey);return H(m({link:e.routeSlug,...e.version},t),{loadEntity:e.loadEntity,subtreeKeyOf:()=>void 0,accessOf:()=>void 0,resolveAsset:async e=>e})}function le(e){let t=typeof e==`string`?e:a(e)?e.path:void 0;return typeof t==`string`&&t.trim()!==``?t.trim():null}function Y(e){return[e.originPluginId,e.originFilePath,e.routeId].join(`\0`)}async function X(e,t){let n=/* @__PURE__ */ new Map;for(let r of e.assignedRouteSlugs){let e=t.routes.bySlug(r),i=e?.originFilePath===null?e.sidebarSubtreeEntityKey:null;if(!i||await t.entities.get(i)===null)continue;let a=e=>{for(let i of e){let e=i.link===void 0?void 0:t.routes.bySlug(i.link);e!==void 0&&!n.has(e.slug)&&n.set(e.slug,r),i.items&&a(i.items)}};a(m({link:r},await t.entities.load(i)))}return n}function ue(e,t){for(let n of t)for(let[t,r]of n){let n=e.get(r);n!==void 0&&!e.has(t)&&e.set(t,n)}}async function Z(e){let t=[];for(let n of await e.list({type:T}))t.push(...await e.load(n.key));return t}function de(e,t=[]){let n=[];for(let[r,i]of e.entries()){if(t[r]?.link!==i.link)break;n.push(i)}return n}async function fe(e,t,n,r,i){let a=await Promise.all(e.map(async e=>{let r=pe(e,t,n);return r===null?null:{item:e,link:r.link,label:await me(e,r,i)}})),o=/* @__PURE__ */ new Map;for(let{item:e,link:t,label:n}of a.filter(e=>e!==null))for(let i of e.linkedSidebars??[]){let e=g(i,F),a=e===null?void 0:r.get(e);a!==void 0&&!o.has(a)&&o.set(a,{label:n,link:t})}return o}function pe(e,t,n){if(typeof e.href==`string`&&e.href.trim()!==``)return{link:e.href.trim()};if(typeof e.page!=`string`||e.page.trim()===``)return null;let{path:r,suffix:i,anchor:a}=d(e.page.trim()),o=_(r,F,t);if(o.kind!==`found`)return null;let s=o.value;return{link:`${D(s,n)}${i}`,anchor:a,route:s}}async function me(e,t,n){let r=R(e.label)??R(e.group)??t.anchor;if(r!==void 0)return r;let i=t.route?.sidebarSubtreeEntityKey,o=i?await n(i):void 0;return(a(o)?R(o.label):void 0)??t.link}function Q(e,t){for(let n of e){if(!t(n))continue;if(n.link!==void 0&&n.languageInsensitive!==!0)return n;let e=Q([...n.items??[],...n.menu??[]],t);if(e!==null)return e}return null}function he(e,t){return Q(e,e=>e.version===void 0||e.version===t)?.link??null}function $(e){let t=Q(e,e=>e.version===void 0||e.isDefaultVersion===!0);return t?.link===void 0?null:t.versionGroup!==void 0&&t.version!==void 0?u(t.link,t.versionGroup,t.version,!0):t.link}function ge(e){let[t]=e;if(t===void 0)return null;let n=t.path.split(`/`).length;return(e.find(({path:e})=>e.split(`/`).length===n&&N.test(e))??t).link}function _e(e){let t=null;for(let{slug:n,originFilePath:r,locale:a,versionGroup:o}of e)r!==null&&a===``&&o===null&&(t===null||n.length<t.length||n.length===t.length&&i(n,t)<0)&&(t=n);return t}const ve=e({id:A,version:`1.28.0`,content:{filter:{match:e=>M.test(e)},async extractFile(e,t){let n=await t.io.readFile(e.path);return{routes:[],linkRefs:await C({source:n,filePath:e.path,readFile:t.io.readFile})}}},async finalize(e){let t=[],r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,u=[],f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Map,m=[],h=await Promise.all(e.files.map(async t=>({path:t.path,source:await e.io.readFile(t.path)}))),g=e.routes.all(),_=ie(g,e.localeContext),v=te(g),y=v.length>0?v:void 0;h.sort((e,t)=>e.path.split(`/`).length-t.path.split(`/`).length);let C=new Map(h.map(({path:e,source:t})=>[e,t])),T=/* @__PURE__ */ new Map;for(let{path:e}of h)N.test(e)&&T.set(O.dirname(e),e);let D=/* @__PURE__ */ new Set;for(let{path:e,source:t}of h)for(let n of re(t,e))D.add(n);let A=await x({io:e.io,routes:e.routes,versionedDirectories:v}),j={routes:e.routes,versionGroups:A,report:e=>r.push(e),readFile:async t=>C.get(t)??e.io.readFile(t),exists:t=>e.io.exists(t),sidebarByDirectory:T},M=async(n,r)=>{if(n.nodes.length===0)return;w(n.nodes,A);let i=J.withArgs({nodes:n.nodes,versionedDirectories:y},r===void 0?void 0:{metadata:{sourcePath:r}});t.push(i),p.set(i,n.nodes);let a=/* @__PURE__ */ new Map;for(let r of e.localeContext.locales){let e=J.withArgs({nodes:n.nodes,locale:r,slugOverrides:_[r]??{},versionedDirectories:y});t.push(e),a.set(r,e)}return f.set(i,a),i};for(let{path:t,source:n}of h){if(D.has(t))continue;let s=await S({...j,file:{path:t},source:n}),c=await M(s,t);if(c===void 0)continue;a.set(t,c);let l=t.startsWith(`@l10n/`)?null:$(s.nodes);l!==null&&m.push({path:t,link:l}),u.push(await X(s,e));for(let e of s.assignedRouteSlugs){let n=o.get(e);n!==void 0&&r.push({code:`sidebar/route-conflict`,message:`Page "${e}" is in sidebars ${n} and ${t}; it shows ${t}.`,location:{filePath:t}}),i.set(e,c),o.set(e,t)}}ue(i,u);let F=new Map(g.map(e=>[e.slug,e]));for(let[t,n]of Object.entries(e.routes.metadata(`sidebar`))){let e=F.get(t);if(e===void 0||e.originFilePath===null)continue;let o=le(n);if(o===null)continue;let s=O.normalize(o.startsWith(`/`)?o.slice(1):O.join(O.dirname(e.originFilePath),o)),c=a.get(s);if(c===void 0){r.push({code:`sidebar/missing-target`,message:`Front matter sidebar "${o}" is not a sidebar file of this project.`,location:{filePath:e.originFilePath}});continue}i.set(e.slug,c)}let I=await Z(e.entities),L=/* @__PURE__ */ new Set,R=/* @__PURE__ */ new Map,z=/* @__PURE__ */ new Map;for(let t of I){let n=i.get(t.route);if(n===void 0){let r=await ne({...j,file:{path:P},entries:t.entries});if(n=await M(r),n===void 0)continue;let a=(await X(r,e)).keys();for(let e of[...r.assignedRouteSlugs,...a])i.has(e)||(i.set(e,n),L.add(e))}let r=R.get(n);R.set(n,r===void 0?t.backLink??null:r!==null&&r.link===t.backLink?.link?r:null);let a=z.get(n);z.set(n,a===void 0?t.breadcrumbs??[]:de(a,t.breadcrumbs))}if(h.length===0&&g.length>0){let e=await S({...j,file:{path:P},source:`- directory: .
|
|
2
|
+
`,skipRoutes:L}),t=await M(e);if(t!==void 0){for(let n of e.assignedRouteSlugs)i.has(n)||i.set(n,t);let n=$(e.nodes);n!==null&&m.push({path:P,link:n})}}let B=ge(m)??_e(g);if(B!==null){let{path:e}=d(B);t.push(n(e,{stableKey:ae}))}let V=/* @__PURE__ */ new Map;for(let e of g){if(e.originFilePath===null)continue;let t=Y(e);V.set(t,[...V.get(t)??[],e.slug])}for(let[e,t]of[...i]){let n=F.get(e);for(let e of(n&&V.get(Y(n)))??[])i.has(e)||i.set(e,t)}let H=/* @__PURE__ */ new Map,U=(e.config.navbar?.items??[]).filter(e=>e.linkedSidebars?.length),W=/* @__PURE__ */ new Map;for(let[t,n]of await fe(U,e.routes,A,a,t=>e.entities.tryLoad(t)))z.set(t,[n,...z.get(t)??[]]);let G=({label:t,link:n,icon:r})=>({label:t,link:n,icon:r,[k]:b(n,e.routes,A)??void 0});for(let[e,r]of R){if(r===null)continue;let i=n(G(r));t.push(i),H.set(e,i)}for(let[e,r]of z){if(r.length===0)continue;let i=n(r.map(G));t.push(i),W.set(e,i)}for(let r of new Set(I.map(e=>e.route))){let a=i.get(r),o=a===void 0?void 0:p.get(a),s=o===void 0?null:he(o,e.routes.bySlug(r)?.version??null);s!==null&&t.push(n(s,{stableKey:E(r)}))}return{entities:t,attach:[...i.entries()].map(([e,t])=>{let n={[l]:t},r=H.get(t);r!==void 0&&(n[s]=r);let i=W.get(t);if(i!==void 0&&(n[c]=i),F.get(e)?.locale===``)for(let[e,r]of f.get(t)??[])n[ee(e)]=r;return{slug:e,deps:n}}),problems:r}},loaders:[J]});export{N as FOLDER_SIDEBAR_FILENAME_REGEX,j as SIDEBAR_AGGREGATOR_LOADER_ID,M as SIDEBAR_FILENAME_REGEX,A as SIDEBAR_PLUGIN_ID,l as SIDEBAR_ROUTE_DEP_KEY,I as isTabbedSidebar,ce as resolveAutoSidebar,ve as sidebarContentPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,n){let r=e.version===void 0?void 0:{version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel};if(Array.isArray(n)){let i=e.isGroup===!0||Array.isArray(e.items)&&e.items.length>0,a=n.map(n=>t(n,e.link??``,r));if(i){let[t,...n]=a,r=t&&(t.link===void 0||t.link===e.link)?n:a;return[{...e,items:[...r,...e.items??[]]}]}return a}if(!n||typeof n!=`object`)return[e];let i={...e};for(let[t,r]of Object.entries(n)){if(t===`slugSuffix`&&typeof r==`string`){i.link=(e.link??``)+r;continue}i[t]===void 0&&r!==void 0&&(i[t]=r)}return e.slugSuffix&&!i.link&&(i.link=e.slugSuffix),[i]}function t(e,n,r){let i=r?{...e,...r}:{...e};return e.slugSuffix!==void 0&&(i.link=e.slugSuffix===``||e.slugSuffix===`/`?n:n+e.slugSuffix,delete i.slugSuffix),e.items&&(i.items=e.items.map(e=>t(e,n,r))),i}export{e as applySubtree};
|
|
1
|
+
function e(e,n){let r=e.version===void 0?void 0:{version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel};if(Array.isArray(n)){let i=e.isGroup===!0||Array.isArray(e.items)&&e.items.length>0,a=n.map(n=>t(n,e.link??``,r));if(i){let[t,...n]=a,r=t&&(t.link===void 0||t.link===e.link)?n:a;return[{...e,items:[...r,...e.items??[]]}]}for(let t of a)t.link===e.link&&(e.label!==void 0&&(t.label=e.label,t.labelTranslationKey=e.labelTranslationKey),(e.icon!==void 0||e.srcSet!==void 0)&&(t.icon=e.icon,t.srcSet=e.srcSet),e.badges!==void 0&&(t.badges=e.badges));return a}if(!n||typeof n!=`object`)return[e];let i={...e};for(let[t,r]of Object.entries(n)){if(t===`slugSuffix`&&typeof r==`string`){i.link=(e.link??``)+r;continue}i[t]===void 0&&r!==void 0&&(i[t]=r)}return e.slugSuffix&&!i.link&&(i.link=e.slugSuffix),[i]}function t(e,n,r){let i=r?{...e,...r}:{...e};return e.slugSuffix!==void 0&&(i.link=e.slugSuffix===``||e.slugSuffix===`/`?n:n+e.slugSuffix,delete i.slugSuffix),e.items&&(i.items=e.items.map(e=>t(e,n,r))),i}export{e as applySubtree};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{createInlineEntity as t}from"../../../loaders/define.js";import{
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{createInlineEntity as t}from"../../../loaders/define.js";import{isPlanFeatureGranted as n}from"../../../../shared/plan-gates.js";import{slugifySegment as r}from"../../../../shared/utils/routes/slugify-segment.js";import{AGENT_SKILLS_BASE as i,SKILLS_FOLDER as a,SKILLS_INDEX_SLUG as o,SKILL_FILENAME as s}from"../../utils/skill-paths.js";import{compileContentGlob as c}from"../../utils/glob.js";import{SKILL_ENTITY_TYPE as l,skillEntityKey as u}from"../../types/skill-entity.js";import{parseSkill as d}from"./parse-skill.js";const f=`internal.skills`,p=`${i}/:slug/${s}`,m=s.toLowerCase();function h(e){let t=e.split(`/`);return t.length===3&&t[0]===`@skills`&&t[2].toLowerCase()===m}function g(e,t){let n=/* @__PURE__ */ new Map;for(let t of e){if(!h(t.path))continue;let[,e,r]=t.path.split(`/`),i=n.get(e);i?i.push(r):n.set(e,[r])}let i=[],o=/* @__PURE__ */ new Map;for(let[e,c]of n){let n=c.includes(`SKILL.md`)?s:c[0];c.length>1&&t.warn(`Multiple skill files in "${a}/${e}" differ only by case; using "${n}".`);let l=r(e),u=o.get(l);if(u!==void 0){t.warn(`Skipping skill folder "${a}/${e}": its slug "${l}" collides with the folder "${u}" after slugification.`);continue}o.set(l,e),i.push({slug:l,sourcePath:`${a}/${e}/${n}`})}return i}const _=e({id:f,version:`1.3.0`,server:{routes:[{method:`GET`,path:o,handler:{filePath:`./server/routes.ts`,importer:import.meta.url,exportName:`skillsIndex`}},{method:`GET`,path:p,handler:{filePath:`./server/routes.ts`,importer:import.meta.url,exportName:`skillMarkdown`}}]},content:{filter:{match:e=>e===`SKILL.md`||h(e)},async extractAll(e){let r=[...e.config.mcp?.ignore??[],...e.config.skills?.excludeFiles??[]],i=r.length>0?c(r):()=>!1,a=process.env.PROJECT_SLUG||`project-docs`,o=g(e.files,e.logger);e.files.some(e=>e.path===`SKILL.md`)&&o.push({slug:a,sourcePath:s});let f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Map,m=n(e.config,`rbac`);for(let n of o){if(i(n.sourcePath))continue;let r=await e.io.readFile(n.sourcePath),a=d(n.sourcePath,r);if(`error`in a){e.logger.warn(a.error);continue}let o=p.get(n.slug);o!==void 0&&e.logger.warn(`Skill "${n.slug}" from "${o}" is replaced by "${n.sourcePath}".`);let s={slug:n.slug,title:a.title,description:a.description,sourcePath:n.sourcePath};`rbac`in a&&m&&(s.rbac=a.rbac);let c={content:r};p.set(n.slug,n.sourcePath),f.set(n.slug,t(c,{stableKey:u(n.slug),type:l,metadata:s}))}return{routes:[],entities:[...f.values()]}}}});export{f as SKILLS_PLUGIN_ID,p as SKILL_MARKDOWN_ROUTE_PATH,_ as skillsContentPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hashString as e}from"../../../../database/utils/json.js";import{withPathPrefix as t}from"../../../../../shared/path-prefix.js";import{SKILLS_INDEX_SCHEMA_URL as n,skillMarkdownPath as r}from"../../../utils/skill-paths.js";import{
|
|
1
|
+
import{hashString as e}from"../../../../database/utils/json.js";import{withPathPrefix as t}from"../../../../../shared/path-prefix.js";import{SKILLS_INDEX_SCHEMA_URL as n,skillMarkdownPath as r}from"../../../utils/skill-paths.js";import{isEntityScopeVisible as i}from"../../../../../shared/rbac/entity-scope.js";import{notFoundResponse as a}from"../../../../../server/plugin-context.js";import{publicOrigin as o}from"../../../utils/request-origin.js";import{SKILL_ENTITY_TYPE as s,skillEntityKey as c}from"../../../types/skill-entity.js";const l={"Cache-Control":`no-store`,"Access-Control-Allow-Origin":`*`};function u(e){return e.config.skills?.hide===!0}async function d(c,d){if(u(d))return a();let f=o(d.request),p=await d.entities.list({type:s}),m=await Promise.all(p.map(async n=>{let{slug:a,title:o,description:s}=n.metadata??{};if(typeof a!=`string`||!i(n,d.request.teams,e=>d.logger?.warn(e)))return[];let{content:c}=await d.entities.load(n.key);return[{name:o??a,type:`skill-md`,description:s??``,url:`${f}${t(r(a))}`,digest:`sha256:${e(c)}`}]}));return c.json({$schema:n,skills:m.flat()},200,l)}async function f(e,t){if(u(t))return a();let n=e.req.param(`slug`)??``,r=c(n),o=await t.entities.get(r);if(!o||!i(o,t.request.teams,e=>t.logger?.warn(e)))return a();let{content:s}=await t.entities.load(r);return e.body(s,200,{"Content-Type":`text/markdown; charset=utf-8`,...l})}export{f as skillMarkdown,d as skillsIndex};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{toJsonValue as t}from"../../../database/utils/json.js";import{createInlineEntityReference as n}from"../../../loaders/define.js";import{normalizeRouteSlug as r}from"../../../../shared/utils/routes/normalize-route-slug.js";import{slugifySegment as i}from"../../../../shared/utils/routes/slugify-segment.js";import{versionsConfigEntityKey as
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{toJsonValue as t}from"../../../database/utils/json.js";import{createInlineEntityReference as n}from"../../../loaders/define.js";import{normalizeRouteSlug as r}from"../../../../shared/utils/routes/normalize-route-slug.js";import{slugifySegment as i}from"../../../../shared/utils/routes/slugify-segment.js";import{versionDefaultEntityKey as a,versionsConfigEntityKey as o}from"../../../../shared/constants/versions.js";import{collectVersionGroups as s,findVersionedDirectories as c}from"../../../versions/version-groups.js";import{posix as l}from"node:path";import u from"js-yaml";const d=`internal.versions`,f=`versions.yaml`;function p(e){let t=l.dirname(e);return t===`.`?`/`:r(t.split(`/`).map(e=>i(e)).join(`/`))}const m=e({id:d,version:`1.3.0`,content:{filter:{match:e=>e===f||e.endsWith(`/${f}`)},async extractFile(e,r){let i=await r.io.readFile(e.path),a=u.load(i);return{routes:[],entities:[n(t(a??{}),{stableKey:o(p(e.path))})]}}},async finalize(e){return{entities:[...await s({io:e.io,routes:e.routes,versionedDirectories:c(e.routes.all())})].map(([e,t])=>n(t.defaultVersion,{stableKey:a(e)}))}}});export{d as VERSIONS_PLUGIN_ID,m as versionsContentPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isMissingError as e}from"../../shared/utils/is-missing-error.js";import{hashGlobMatches as t,matchGlob as n}from"./utils/glob.js";import{resolveContentPath as r}from"../../shared/utils/resolve-content-path.js";import{hashContentBytes as i}from"../../shared/utils/content-hash.js";import{resolve as a}from"node:path";function o(e){return{async exists(t){return e.exists(t)},async readBinaryFile(t){return e.readBinaryFile(t)},async readFile(t){return e.readFile(t)},async readdir(t){return(await e.readdir(t)).map(e=>({name:e.name,type:e.type===`file`?`file`:e.type===`directory`?`directory`:e.type===`symlink`?`symlink`:`other`})).sort((e,t)=>e.name.localeCompare(t.name))},async stat(t){let n=await e.stat(t);return n?{type:n.type,size:n.size,mtimeMs:n.mtimeMs}:null},async writeFile(t,n,r){return e.writeFile(t,n,r)},async mkdir(t,n){return e.mkdir(t,n)},async copyFile(t,n){return e.copyFile(t,n)},async rename(t,n){return e.rename(t,n)},async unlink(t){return e.rm(t,{force:!0})}}}function s(e,t){let n=r(t,``);if(n===null)throw Error(`Plugin IO path escapes the content root: "${t}"`);return a(e,n)}function c(e,t,r){return{async readFile(n){return e.readFile(s(t,n))},async readBinaryFile(n){return e.readBinaryFile(s(t,n))},async exists(n){return e.exists(s(t,n))},async glob(e){return n(r(),e)}}}function l(n,r,a,o,s){let l=c(n,r,a);function d(e){e.path!==s&&o({source:`file`,...e})}function f(t,n){throw e(n)&&d({accessType:`presence`,path:u(t),valueHash:`absent`}),n}return{async readFile(e){let t;try{t=await l.readBinaryFile(e)}catch(t){f(e,t)}let n=await i(t);return d({accessType:`value`,path:u(e),valueHash:n}),new TextDecoder().decode(t)},async readBinaryFile(e){let t;try{t=await l.readBinaryFile(e)}catch(t){f(e,t)}let n=await i(t);return d({accessType:`value`,path:u(e),valueHash:n}),t},async exists(e){let t=await l.exists(e);return d({accessType:`presence`,path:u(e),valueHash:t?`present`:`absent`}),t},async glob(e){let n=await l.glob(e);return o({source:`glob`,accessType:`value`,path:e,valueHash:t(n)}),n}}}function u(e){return r(e,``)??e}export{o as createContentPluginIO,c as createPluginIO,l as createRecordingPluginIO};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}function x(e){return/* @__PURE__ */ Error(`Failed to load project plugins:\n${b(e)}`)}function S(e){return(e.plugins??[]).map(e=>e.trim()).filter(e=>e!==``)}function C(e,t){let n=Object.keys(t).find(t=>e===t||e.startsWith(`${t}/`));return n===void 0?void 0:t[n]}function w(e){let t=Object.keys(c).find(t=>e===t||e===`${t}/plugin.js`);return t===void 0?void 0:c[t]}async function T(e,t,n){if(h(e)){if(await n.exists(e))return e;let r=_(t,e.replace(/^[/\\]+/,``));return await n.exists(r)?r:null}if(e.startsWith(`./`)||e.startsWith(`../`)){let r=_(t,e);return await n.exists(r)?r:null}if(e.includes(`/`)){let r=_(t,e);if(await n.exists(r))return r}return E(e,t)}function E(e,t){try{return d(import.meta.url).resolve(e,{paths:[t,m(f(import.meta.url))]})}catch{return null}}async function D(
|
|
1
|
+
import{isPlanFeatureGranted as e}from"../../../shared/plan-gates.js";import{isObject as t}from"../../../shared/utils/is-object.js";import{createNodePlatformFs as n}from"../../../platform/node/fs.js";import{hashContentBytes as r}from"../../../shared/utils/content-hash.js";import{loadRedoclyConfig as i}from"../../config.js";import{BUILT_IN_CLASSIC_PLUGINS as a,DEFAULT_PROJECT_PLUGIN_FILES as o,INTERNAL_PLUGIN_ID_PREFIX as s,PLAN_GATED_PLUGINS as c}from"./constants.js";import{setLoadedProjectPlugins as l}from"./loaded-set.js";import{createInternalContentPlugins as u}from"../internal/index.js";import{createRequire as d}from"node:module";import{fileURLToPath as f,pathToFileURL as p}from"node:url";import{dirname as m,isAbsolute as h,join as g,resolve as _}from"node:path";async function v(t,r={}){let s=_(t),c=r.fs??n(),{config:l}=await i(s,c),d=[],f=S(l),p=[];for(let e of f){let t=C(e,a);if(t!==void 0){r.logger?.warn(`Project plugin "${e}" is skipped: ${t} are built in. Remove it from \`plugins\` in redocly.yaml.`);continue}let n=w(e),i=n===void 0?await T(e,s,c):E(e,s);if(i===null){d.push({entry:e,message:`Cannot resolve the plugin module from the project root, its node_modules or the Realm Plus installation.`});continue}p.some(e=>e.path===i)||p.push({entry:e,path:i,feature:n??`customPlugins`})}for(let e of o){let t=g(s,e);if(await c.exists(t)){p.some(e=>e.path===t)||p.push({entry:e,path:t,feature:`customPlugins`});break}}let m=[],h=[],v=new Set(u().map(e=>e.id));for(let{entry:t,path:n,feature:i}of p){let a=await D({entry:t,path:n,contentDir:s,config:l,fs:c});if(`lintPlugin`in a&&h.push({entry:t,path:n,plugin:a.lintPlugin}),`message`in a){d.push({entry:a.entry,path:a.path,message:a.message});continue}if(`plugin`in a){if(!e(l,i)){r.logger?.warn(`Project plugin "${t}" is skipped: \`${i}\` is not in this project's plan.`);continue}if(v.has(a.plugin.id)){d.push({entry:t,path:n,message:`Plugin id "${a.plugin.id}" is already registered by another plugin.`});continue}v.add(a.plugin.id),m.push(a)}}for(let e of d)r.logger?.error(`Project plugin "${e.entry}": ${e.message}`);return{plugins:m,lintPlugins:h,paths:p.map(e=>e.path),entries:f,diagnostics:d}}async function y(e,t={}){let n=await v(e,t);return l(e,n),n}function b(e){return e.map(e=>`- ${e.entry}${e.path?` (${e.path})`:``}: ${e.message}`).join(`
|
|
2
|
+
`)}function x(e){return/* @__PURE__ */ Error(`Failed to load project plugins:\n${b(e)}`)}function S(e){return(e.plugins??[]).map(e=>e.trim()).filter(e=>e!==``)}function C(e,t){let n=Object.keys(t).find(t=>e===t||e.startsWith(`${t}/`));return n===void 0?void 0:t[n]}function w(e){let t=Object.keys(c).find(t=>e===t||e===`${t}/plugin.js`);return t===void 0?void 0:c[t]}async function T(e,t,n){if(h(e)){if(await n.exists(e))return e;let r=_(t,e.replace(/^[/\\]+/,``));return await n.exists(r)?r:null}if(e.startsWith(`./`)||e.startsWith(`../`)){let r=_(t,e);return await n.exists(r)?r:null}if(e.includes(`/`)){let r=_(t,e);if(await n.exists(r))return r}return E(e,t)}function E(e,t){try{return d(import.meta.url).resolve(e,{paths:[t,m(f(import.meta.url))]})}catch{return null}}async function D(e){let{entry:t,path:n}=e,i=await r(await e.fs.readBinaryFile(n)),a=p(n);a.searchParams.set(`v`,i),delete d(n).cache[n];let o;try{o=await import(a.href)}catch(e){return{entry:t,path:n,message:`Cannot import the plugin module: ${N(e)}`}}let s=O(o);if(s===void 0)return{entry:t,path:n,message:`The module has no default export.`};let c=s,l=i;if(typeof s==`function`){l+=`+${await r(new TextEncoder().encode(JSON.stringify(e.config)))}`;try{c=await s({engine:`realm-plus`,contentDir:e.contentDir,config:e.config})}catch(e){return{entry:t,path:n,message:`The plugin factory threw: ${N(e)}`}}}if(A(c))return{lintPlugin:c};let u=M(c);if(u!==null){let e=j(c);return{entry:t,path:n,message:u,...e&&{lintPlugin:e}}}let f=c;return{entry:t,path:n,plugin:{...f,version:`${f.version}+${l}`}}}function O(e){if(!t(e))return;let n=e.default;return t(n)&&!(`id`in n)&&`default`in n?n.default:n}const k=[`rules`,`preprocessors`,`decorators`,`configs`,`assertions`];function A(e){return t(e)&&typeof e.processContent!=`function`&&typeof e.afterRoutesCreated!=`function`&&e.version===void 0&&k.some(t=>t in e)}function j(e){if(!t(e)||typeof e.id!=`string`||typeof e.processContent!=`function`&&typeof e.afterRoutesCreated!=`function`)return;let n=[...k,`typeExtension`].filter(t=>t in e).map(t=>[t,e[t]]);return n.length>0?Object.fromEntries([[`id`,e.id],...n]):void 0}function M(e){return t(e)?typeof e.processContent==`function`||typeof e.afterRoutesCreated==`function`?`This is a legacy Realm lifecycle plugin (processContent/afterRoutesCreated). Realm Plus loads content plugins; see docs/guides/authoring-plugins.md.`:typeof e.id!=`string`||e.id.trim()===``?"The plugin needs a non-empty string `id`.":e.id.startsWith(`internal.`)?`The plugin id prefix "${s}" is reserved for built-in plugins.`:typeof e.version!=`string`||e.version.trim()===``?"The plugin needs a non-empty string `version`.":null:`The default export must be a plugin object or a factory that returns one.`}function N(e){return e instanceof Error?e.message:String(e)}export{x as createProjectPluginLoadError,b as formatProjectPluginDiagnostics,y as loadAndRegisterProjectPlugins,v as loadProjectPlugins,S as readPluginEntries,T as resolveProjectPluginPath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveRuntimeFilePath as e}from"./utils/runtime-file.js";import{resolveServerModuleReference as t}from"./server-fn.js";import{normalizeRouteSlug as n}from"../../shared/utils/routes/normalize-route-slug.js";import{ENGINE_ROUTE_PREFIXES as r,SYSTEM_ROUTES as i}from"../../
|
|
1
|
+
import{resolveRuntimeFilePath as e}from"./utils/runtime-file.js";import{resolveServerModuleReference as t}from"./server-fn.js";import{normalizeRouteSlug as n}from"../../shared/utils/routes/normalize-route-slug.js";import{ENGINE_ROUTE_PREFIXES as r,SYSTEM_ROUTES as i}from"../../shared/constants/system-routes.js";import{contentIgnoreMatcherOf as a}from"../ingest/scan.js";import{isStaticFolderPath as o}from"./internal/static-folder/index.js";import{collectEntityLoaders as s}from"../loaders/registry.js";import{resolve as c}from"node:path";const l=/^[a-zA-Z0-9_-]{1,64}$/;function u(e,t){let r=/* @__PURE__ */ new Map;for(let t of e){if(r.has(t.id))throw Error(`Duplicate content plugin id: ${t.id}`);r.set(t.id,t)}let i=f(r.values()),a=p(r.values()),o=m(r.values(),t),c=s(r.values()),l=_(r.values()),u=new Map(i.map(e=>[e.definition.id,e])),h=new Map(c.map(e=>[e.definition.id,e]));return{getById(e){return r.get(e)},getServerFnById(e){return u.get(e)},getEntityLoaderById(e){return h.get(e)},getEntityLoadersForPlugin(e){return c.filter(t=>t.pluginId===e)},list(){return[...r.values()]},listServerFns(){return[...i]},listServerRoutes(){return[...a]},listMcpTools(){return[...o.values()]},listReservedSlugs(){let e=/* @__PURE__ */ new Map;for(let t of a){if(/[:*]/.test(t.path))continue;let r=n(t.path);e.has(r)||e.set(r,t.plugin.id)}return e},listEntityLoaders(){return[...c]},listTemplates(){return[...l]},listFinalizePlugins(){return[...r.values()].filter(e=>e.finalize!==void 0)},listExtractAllPlugins(){return[...r.values()].filter(e=>e.content?.extractAll!==void 0)},listBuildMetadataPlugins(){return[...r.values()].filter(e=>e.buildMetadata!==void 0)},resolveAllForFile(e){return[...r.values()].filter(t=>d(t.content?.filter,e))}}}function d(e,t){return!e?.isStaticFolder&&o(t)?!1:e?.extensions?.some(e=>t.toLowerCase().endsWith(e.toLowerCase()))?!0:e?.match?.(t)??!1}function f(e){let t=[],n=/* @__PURE__ */ new Map;for(let r of e)for(let e of r.server?.functions??[]){let i=n.get(e.id);if(i!==void 0)throw Error(`Duplicate server function id "${e.id}" (plugins: ${i}, ${r.id})`);n.set(e.id,r.id),t.push({definition:e,pluginId:r.id})}return t}function p(e){let n=[],r=/* @__PURE__ */ new Map;for(let i of e)for(let e of i.server?.routes??[]){g(e,i.id);let a=r.get(e.path)??/* @__PURE__ */ new Set;for(let t of h(e.method)){if(a.has(t)||a.has(`ALL`)||t===`ALL`&&a.size>0)throw Error(`Plugin "${i.id}" server route ${t} ${e.path} is already declared by another plugin.`);a.add(t)}r.set(e.path,a),n.push({...e,handler:t(e.handler),plugin:{id:i.id,version:i.version}})}return n}function m(e,n){let r=/* @__PURE__ */ new Map;for(let i of e)for(let e of i.mcp?.tools??[]){if(!l.test(e.name))throw Error(`Plugin "${i.id}" declares an MCP tool with an invalid name "${e.name}". A name must match ${l.source}.`);let a=r.get(e.name);a&&n?.warn(`Plugin "${i.id}" MCP tool "${e.name}" overrides the one from "${a.plugin.id}".`),r.set(e.name,{declaration:e,handler:t(e.handler),plugin:{id:i.id,version:i.version}})}return r}function h(e){return e===void 0?[]:(typeof e==`string`?[e]:[...e]).map(e=>e.toUpperCase())}function g(e,t){let{path:a}=e,o=n(a);if(i.includes(o)||e.method!==void 0&&/^\/[:*]/.test(o)||r.some(e=>o===e||o.startsWith(`${e}/`)))throw Error(`Plugin "${t}" server route "${a}" collides with an engine-served path.`)}function _(e){let t=[],n=/* @__PURE__ */ new Set;for(let r of e){let e=r.templates??{};for(let[i,a]of Object.entries(e)){if(n.has(i))throw Error(`Duplicate template id "${i}" (plugin: ${r.id})`);n.add(i),t.push({filePath:v(a),pluginId:r.id,templateId:i})}}return t}function v(t){return y(t)?t.kind===`runtime`?e(t.filePath):c(t.filePath):e(t)}function y(e){return typeof e==`object`&&!(e instanceof URL)&&`kind`in e}function b(e,t){return a(e.config)(t)?[]:e.pluginRegistry.resolveAllForFile(t)}export{l as MCP_TOOL_NAME_PATTERN,u as createContentPluginRegistry,d as matchesContentPluginFilter,b as resolveContentPluginsForFile};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Context, Next } from 'hono';
|
|
2
|
+
import type { RbacRole } from '../../shared/rbac/types.js';
|
|
2
3
|
import type { RealmConfig } from '../../shared/types/config.js';
|
|
3
4
|
import type { Logger } from '../../shared/logger.js';
|
|
4
5
|
import type { Viewer } from '../../shared/types/auth.js';
|
|
@@ -69,6 +70,8 @@ export type ServerRouteContext = {
|
|
|
69
70
|
/** Whether a page is served at `slug`, including the versionless URL of a default version in any locale. */
|
|
70
71
|
hasRoute(slug: string): Promise<boolean>;
|
|
71
72
|
isSlugVisible(slug: string, options?: SlugVisibilityOptions): boolean;
|
|
73
|
+
/** The viewer's role on the page at `slug`: `none` for a hidden or missing page, `read` everywhere without `access.rbac`. */
|
|
74
|
+
roleForSlug(slug: string): RbacRole;
|
|
72
75
|
/** Runtime key-value store, namespaced to this plugin; shared by every request and process. */
|
|
73
76
|
kv: KvService;
|
|
74
77
|
logger?: Logger;
|
|
@@ -92,6 +95,8 @@ export type ServerRouteHandler = (c: Context, ctx: ServerRouteContext) => Respon
|
|
|
92
95
|
export type ServerMiddlewareHandler = (c: Context, next: Next, ctx: ServerRouteContext) => Promise<Response | void> | Response | void;
|
|
93
96
|
/** The plugin request context plus the host seams only built-in plugins read; not part of `framework/plugin`. */
|
|
94
97
|
export type BuiltinRouteContext = Omit<ServerRouteContext, 'withViewer'> & {
|
|
98
|
+
/** The host's auth key seed for the MCP gateway secret store; absent when the host has none. */
|
|
99
|
+
gatewaySecretSeed?: string;
|
|
95
100
|
loadContentModule?: (sourcePath: string) => Promise<Record<string, unknown>>;
|
|
96
101
|
mcpToolEntries?: readonly ContentPluginMcpToolEntry[];
|
|
97
102
|
withViewer(viewer: Viewer): Promise<BuiltinRouteContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{filePathToRouteSlug as e}from"../../shared/utils/routes/file-path-to-route-slug.js";import{toLowerExt as t}from"../../shared/utils/file-ext.js";import{basename as n}from"node:path";function r(r){let{path:i,hash:a,manifest:o}=r,s=t(i),c=n(i);return{path:i,ext:s,basename:s===``?c:c.slice(0,-s.length),pathSlug:e(i),hash:a,manifest:o}}export{r as createSourceFile};
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
+
import type { ApiSpecType } from '../../../shared/constants/api-spec-kinds.js';
|
|
1
2
|
import type { JsonObject, JsonValue } from '../../database/schema.js';
|
|
3
|
+
export { SPEC_KIND_ARAZZO, SPEC_KIND_ASYNCAPI, SPEC_KIND_GRAPHQL, SPEC_KIND_GRPC, SPEC_KIND_OPENAPI, type ApiSpecType, } from '../../../shared/constants/api-spec-kinds.js';
|
|
2
4
|
/**
|
|
3
5
|
* The well-known `api` entity: one per spec, value = the canonical bundled spec (blob when
|
|
4
6
|
* large; SDL for graphql). Every non-render consumer reads it, never the source filesystem.
|
|
5
7
|
*/
|
|
6
8
|
export declare const API_ENTITY_TYPE = "api";
|
|
7
|
-
export declare const SPEC_KIND_OPENAPI = "openapi";
|
|
8
|
-
export declare const SPEC_KIND_ASYNCAPI = "asyncapi";
|
|
9
|
-
export declare const SPEC_KIND_GRAPHQL = "graphql";
|
|
10
|
-
export declare const SPEC_KIND_ARAZZO = "arazzo";
|
|
11
|
-
/** An Arazzo description has no page: only `/_bundle` serves it. */
|
|
12
|
-
export type ApiSpecType = typeof SPEC_KIND_OPENAPI | typeof SPEC_KIND_ASYNCAPI | typeof SPEC_KIND_GRAPHQL | typeof SPEC_KIND_ARAZZO;
|
|
13
9
|
/** `/_mock<routeSlug>/*` serves an openapi api's stateless mock (`plugins/internal/mock`). */
|
|
14
10
|
export declare const MOCK_SERVER_ROUTE_PREFIX = "/_mock";
|
|
15
11
|
/** The `/_mock` path under which an api at `routeSlug` is mocked (`''` for a root-mounted spec). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{SPEC_KIND_ARAZZO as e,SPEC_KIND_ASYNCAPI as t,SPEC_KIND_GRAPHQL as n,SPEC_KIND_GRPC as r,SPEC_KIND_OPENAPI as i}from"../../../shared/constants/api-spec-kinds.js";const a=`/_mock`;function o(e){return e===`/`?``:e}export{a as MOCK_SERVER_ROUTE_PREFIX,e as SPEC_KIND_ARAZZO,t as SPEC_KIND_ASYNCAPI,n as SPEC_KIND_GRAPHQL,r as SPEC_KIND_GRPC,i as SPEC_KIND_OPENAPI,o as mockPathPrefix};
|
|
@@ -18,6 +18,8 @@ export type MarkdocAttributeResolverContext = ContentPluginBaseContext & {
|
|
|
18
18
|
partialChain?: readonly string[];
|
|
19
19
|
/** Lines of the Markdown source the AST was parsed from. */
|
|
20
20
|
readSourceLines: () => readonly string[];
|
|
21
|
+
/** True inside a `json-schema` tag's descriptions. */
|
|
22
|
+
inJsonSchemaDescription?: boolean;
|
|
21
23
|
};
|
|
22
24
|
export type MarkdocAttributeResolverResult = {
|
|
23
25
|
entityDeps?: readonly EntityInvalidationDep[];
|
|
@@ -13,6 +13,7 @@ import type { EntityStore } from '../../database/entity-store.js';
|
|
|
13
13
|
import type { SearchHandle } from '../../search/store.js';
|
|
14
14
|
import type { DataRefMarker } from '../../materialization/data-ref.js';
|
|
15
15
|
import type { ProblemDraft } from '../../problems/types.js';
|
|
16
|
+
import type { ConfigSchema } from '../../config-schema.js';
|
|
16
17
|
export type ContentPluginMetadata = {
|
|
17
18
|
id: string;
|
|
18
19
|
version: string;
|
|
@@ -95,6 +96,11 @@ export type FinalizeContext = {
|
|
|
95
96
|
};
|
|
96
97
|
export type FinalizeResult = {
|
|
97
98
|
entities?: readonly AnyRawEntityReference[];
|
|
99
|
+
/**
|
|
100
|
+
* Named dependencies for existing routes. `slug` can be a page's locale fallback
|
|
101
|
+
* (`localeContext.toL10nSlug(slug, locale)`): the fallback serves these in place of the
|
|
102
|
+
* page's dependencies of the same key.
|
|
103
|
+
*/
|
|
98
104
|
attach?: readonly {
|
|
99
105
|
slug: string;
|
|
100
106
|
deps: Record<string, ContentDependencyReference>;
|
|
@@ -155,6 +161,13 @@ export type ContentPluginMcp = {
|
|
|
155
161
|
export type ContentPlugin = {
|
|
156
162
|
id: string;
|
|
157
163
|
version: string;
|
|
164
|
+
/**
|
|
165
|
+
* The schema of the plugin's options, the `redocly.yaml` root key named by its `id`, checked
|
|
166
|
+
* with the rest of the config: a setting it rejects is removed and is a `configuration/invalid`
|
|
167
|
+
* error, and an unknown key stays and is a `configuration/ignored` warning. A built-in root
|
|
168
|
+
* key with the same name wins.
|
|
169
|
+
*/
|
|
170
|
+
configSchema?: ConfigSchema;
|
|
158
171
|
content?: ContentPluginContent;
|
|
159
172
|
/** Run after route slugs are final. */
|
|
160
173
|
finalize?(ctx: FinalizeContext): Promise<FinalizeResult> | FinalizeResult;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RbacScope } from '../../../
|
|
1
|
+
import type { RbacScope } from '../../../shared/rbac/types.js';
|
|
2
2
|
import type { ProblemDraft } from '../../problems/types.js';
|
|
3
3
|
/** A label rendered next to a hit (mirrors the theme's `ItemBadge`). */
|
|
4
4
|
export type SearchDocumentBadge = {
|
|
@@ -37,12 +37,22 @@ export type SearchFragmentUse = {
|
|
|
37
37
|
* string or a list of strings; a document matches a filter when any of its values is selected.
|
|
38
38
|
*/
|
|
39
39
|
export type SearchDocumentFacets = Record<string, string | string[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Search curation. A query that contains one of `includes` shows the document before the
|
|
42
|
+
* ranked hits; a query that contains one of `excludes` does not show the document. A query
|
|
43
|
+
* contains a keyword when it has the keyword's words next to each other, in the same order,
|
|
44
|
+
* in any case. `excludes` wins over `includes`. A keyword of more than 10 words is ignored.
|
|
45
|
+
*/
|
|
46
|
+
export type SearchDocumentKeywords = {
|
|
47
|
+
includes?: string[];
|
|
48
|
+
excludes?: string[];
|
|
49
|
+
};
|
|
40
50
|
/**
|
|
41
51
|
* One full-text search document an entity contributes; `docKey` is unique per entity.
|
|
42
52
|
* `groupKey` is the display label the search dialog groups hits under. `anchor` is the
|
|
43
53
|
* fragment a hit opens at (`routeSlug#anchor`), for documents that cover one page section.
|
|
44
|
-
* `facets` are the document's values for the facets configured in
|
|
45
|
-
* picked by the producer from its source's metadata. `rbacScope` (an operation's `x-rbac`)
|
|
54
|
+
* `facets` are the document's values for the default facets and the facets configured in
|
|
55
|
+
* `search.filters.facets`, picked by the producer from its source's metadata. `rbacScope` (an operation's `x-rbac`)
|
|
46
56
|
* narrows the route's audience to the viewers it also admits; it never widens it.
|
|
47
57
|
*/
|
|
48
58
|
export type SearchDocument = {
|
|
@@ -54,6 +64,7 @@ export type SearchDocument = {
|
|
|
54
64
|
groupKey?: string;
|
|
55
65
|
facets?: SearchDocumentFacets;
|
|
56
66
|
rbacScope?: RbacScope;
|
|
67
|
+
keywords?: SearchDocumentKeywords;
|
|
57
68
|
httpMethod?: string;
|
|
58
69
|
httpPath?: string;
|
|
59
70
|
deprecated?: boolean;
|
|
@@ -6,3 +6,5 @@ import type { RouteAccess, RouteIndex } from './route-index.js';
|
|
|
6
6
|
* `undefined` for a link that opens no page.
|
|
7
7
|
*/
|
|
8
8
|
export declare function linkedPageAccess(link: string, routes: Pick<RouteIndex, 'getAccess'>, versionGroups: VersionGroups): RouteAccess | undefined;
|
|
9
|
+
/** The stored slug behind a default version's public link; `null` when `link` is not one. */
|
|
10
|
+
export declare function physicalVersionedSlug(link: string, versionGroups: VersionGroups): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{toPhysicalVersionedSlug as e}from"../../../shared/constants/versions.js";import{splitUrlSuffix as t}from"../../../shared/utils/routes/split-url-suffix.js";function n(e,n,i){if(!e.startsWith(`/`))return;let{path:a}=t(e),o=n.getAccess(a);if(o!==void 0)return o;let s=r(a,i);return s===null?void 0:n.getAccess(s)}function r(t,n){let r=[...n].sort(([e],[t])=>t.length-e.length);for(let[n,i]of r){if(!i.defaultVersion)continue;let r=e(t,n,i.defaultVersion);if(r!==null&&r!==t)return r}return null}export{n as linkedPageAccess,r as physicalVersionedSlug};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RealmConfig } from '../../../shared/types/config.js';
|
|
2
|
-
import type { RbacScope } from '../../../
|
|
2
|
+
import type { RbacScope } from '../../../shared/rbac/types.js';
|
|
3
3
|
import type { JsonObject, JsonValue } from '../../database/schema.js';
|
|
4
4
|
import type { ContentStateView } from '../../database/types/content-state.js';
|
|
5
5
|
/** The identity facts of one route, as every route query returns them. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hashJsonValue as e,toStableJsonString as t}from"../../database/utils/json.js";import{
|
|
1
|
+
import{hashJsonValue as e,toStableJsonString as t}from"../../database/utils/json.js";import{compareStrings as n}from"../../../shared/utils/compare-strings.js";import{computePathPrefixes as r}from"../../../shared/utils/routes/compute-path-prefixes.js";import{normalizeRoutePath as i}from"../../../shared/utils/routes/normalize-route-path.js";import{compileRouteAccessMatcher as a}from"../../../shared/rbac/engine.js";import{resolveRouteScope as o}from"../../../shared/rbac/route-scope.js";import{hashEntityListMembership as s,hashEntityRead as c}from"../../database/entity-store.js";import{getRouteByFilePath as l,getRouteBySlug as u,getRoutesInDirectory as d}from"./state-lookup.js";function f(e,t){let f=a(t),m=e=>f===null?null:o(f,{hasRbacKey:`rbac`in e.metadata,rbacValue:e.metadata.rbac,slug:e.slug,sourcePath:e.originFilePath},()=>{}),h=e=>{let t=[];for(let n of e)t.push(v(n));return t.sort((e,t)=>n(e.slug,t.slug))};function*g(t){for(let n of e.routeBySlug.values())!n.isFallback&&(t===void 0||t(n))&&(yield n)}let y=e=>e!==void 0&&!e.isFallback?e:void 0,b=t=>{let n=i(t),a=y(u(e,n));if(a)return a;let o=r(n),s;for(let e of g(e=>e.wildcardPrefix&&o.includes(e.slug)))(s===void 0||e.slug.length>s.slug.length)&&(s=e);return s};function x(t,r){switch(t){case`byFilePath`:{let t=l(e,r);return _(t?v(t):void 0)}case`bySlug`:{let t=y(u(e,r));return _(t?v(t):void 0)}case`inDirectory`:return _(h(d(e,r)));case`all`:return _(h(g()));case`get`:{let t=y(u(e,r));return _(t?{...v(t),metadata:t.metadata,access:m(t)}:void 0)}case`getAccess`:{let e=b(r);return _(e?m(e):void 0)}case`list`:{let{sidebarKey:e}=JSON.parse(r);return _(h(g(t=>t.sidebarSubtreeEntityKey===e)))}case`metadata`:{let e={};for(let t of[...g()].sort((e,t)=>n(e.slug,t.slug)))Object.hasOwn(t.metadata,r)&&(e[t.slug]=t.metadata[r]);return _(e)}case`entity`:return{value:void 0,hash:c(e,r)};case`entity-type`:return{value:void 0,hash:s(e,r)};default:return{value:void 0,hash:``}}}return p(x)}function p(e){return{hash:(t,n)=>e(t,n).hash,index(n){let r=(t,r)=>{let i=e(t,r);return n?.({kind:t,argument:r,resultHash:i.hash}),i.value};return{byFilePath:e=>r(`byFilePath`,e),bySlug:e=>r(`bySlug`,e),inDirectory:e=>r(`inDirectory`,e),all:()=>r(`all`,``),get:e=>r(`get`,e),getAccess:e=>r(`getAccess`,e),list:e=>r(`list`,t({sidebarKey:e.sidebarKey})),metadata:e=>r(`metadata`,e)}},memoized(){let t=/* @__PURE__ */ new Map;return p((n,r)=>{if(n===`entity`||n===`entity-type`)return e(n,r);let i=`${n}\u0000${r}`,a=t.get(i);return a===void 0&&(a=e(n,r),t.set(i,a)),a})}}}function m(e,t,n){return f(e,t).index(n)}function h(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(`${n.kind}\u0000${n.argument}`,n);return[...t.values()].sort((e,t)=>n(e.kind,t.kind)||n(e.argument,t.argument))}function g(e,t){return e.hash(t.kind,t.argument)!==t.resultHash}function _(t){return{value:t,hash:e(t===void 0?`absent`:t)}}function v(e){return{slug:e.slug,routeId:e.routeId,originPluginId:e.originPluginId,originFilePath:e.originFilePath,versionGroup:e.versionGroup,version:e.version,sidebarSubtreeEntityKey:e.sidebarSubtreeEntityKey,template:e.template,locale:e.locale,canonicalSlug:e.canonicalSlug}}export{m as createRouteIndex,f as createRouteQueryEvaluator,h as dedupeRouteQueryDependencies,g as isRouteQueryStale};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { EntityStore } from '../../database/entity-store.js';
|
|
2
2
|
import type { RouteRow } from './route-index.js';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* The label of the route's sidebar item; undefined for a route in no sidebar, without a label,
|
|
5
|
+
* or whose sidebar item never loaded.
|
|
6
|
+
*/
|
|
4
7
|
export declare function loadSidebarSubtreeLabel(entities: EntityStore, route: Pick<RouteRow, 'sidebarSubtreeEntityKey'>): Promise<string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as e}from"../../../shared/utils/is-object.js";async function t(t,n){if(n.sidebarSubtreeEntityKey===null)return;let r=await t.
|
|
1
|
+
import{isObject as e}from"../../../shared/utils/is-object.js";async function t(t,n){if(n.sidebarSubtreeEntityKey===null)return;let r=await t.tryLoad(n.sidebarSubtreeEntityKey);return e(r)&&typeof r.label==`string`&&r.label.trim()!==``?r.label:void 0}export{t as loadSidebarSubtreeLabel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeRouteSlug as e}from"../../../shared/utils/routes/normalize-route-slug.js";import{slugifySegment as t}from"../../../shared/utils/routes/slugify-segment.js";import{delocalizeL10nPath as n}from"../../../shared/utils/l10n.js";import{posix as r}from"node:path";const i=/* @__PURE__ */ new Set([`@api`,`@theme`,`@l10n`,`@mcp`,`@skills`]);function a(e){let t=r.normalize(e.replaceAll(`\\`,`/`)),a=(n(t)??t).split(`/`).filter(Boolean).slice(0,-1),o=a.findIndex(e=>e.startsWith(`@`)&&e.length>1&&!i.has(e));return o===-1?null:{parent:a.slice(0,o).join(`/`),name:a[o].slice(1)}}function o(n){let r=a(n);if(!r)return null;let i=r.parent.split(`/`).filter(Boolean).map(t);return{versionGroup:e(i.join(`/`)),version:t(r.name)}}export{a as findVersionFolder,o as parseContentVersion};
|
|
1
|
+
import{normalizeRouteSlug as e}from"../../../shared/utils/routes/normalize-route-slug.js";import{slugifySegment as t}from"../../../shared/utils/routes/slugify-segment.js";import{delocalizeL10nPath as n}from"../../../shared/utils/l10n.js";import{posix as r}from"node:path";const i=/* @__PURE__ */ new Set([`@api`,`@theme`,`@l10n`,`@mcp`,`@skills`,`@sdk`]);function a(e){let t=r.normalize(e.replaceAll(`\\`,`/`)),a=(n(t)??t).split(`/`).filter(Boolean).slice(0,-1),o=a.findIndex(e=>e.startsWith(`@`)&&e.length>1&&!i.has(e));return o===-1?null:{parent:a.slice(0,o).join(`/`),name:a[o].slice(1)}}function o(n){let r=a(n);if(!r)return null;let i=r.parent.split(`/`).filter(Boolean).map(t);return{versionGroup:e(i.join(`/`)),version:t(r.name)}}export{a as findVersionFolder,o as parseContentVersion};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=/* @__PURE__ */ new Map;async function t(t,n,r){let i=performance.now();try{return await r()}finally{let r=e.get(t)??{ms:0,loaderCalls:0};r.ms+=performance.now()-i,n===`load`&&(r.loaderCalls+=1),e.set(t,r)}}function n(t){let n=e.get(t)??{ms:0,loaderCalls:0};return e.delete(t),n}export{n as takePluginWorkTime,t as timePluginWork};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Problem, ProblemCategory, ProblemDraft, ProblemSeverity } from './types.js';
|
|
2
|
+
type ProblemCodeDefaults = {
|
|
3
|
+
category: ProblemCategory;
|
|
4
|
+
severity: ProblemSeverity;
|
|
5
|
+
};
|
|
6
|
+
/** Problems a new load of the same input can clear; ingest marks their entities stale. */
|
|
7
|
+
export declare const RETRYABLE_PROBLEM_CODES: readonly string[];
|
|
8
|
+
export declare function resolveProblemDefaults(code: string): ProblemCodeDefaults;
|
|
9
|
+
export declare function createProblem(draft: ProblemDraft): Problem;
|
|
10
|
+
export {};
|