@redocly/framework 1.0.0-next.1 → 1.0.0-next.11
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/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/run.js +1 -1
- package/dist/bundler/dev/runtime-app.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/commands/build.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/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/app.js +2 -7
- package/dist/client/client-entry.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/history-mount.js +1 -0
- 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/products.js +1 -1
- package/dist/client/review/ReviewBar.js +163 -69
- package/dist/client/review/login-url.js +1 -0
- package/dist/client/revisions-history.js +1 -1
- package/dist/client/sidebar/PoweredByRedocly.js +2 -2
- package/dist/client/ssr.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/use-banner.js +1 -1
- package/dist/client/use-bar-position.js +1 -0
- 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/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.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/blobs.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/files.js +1 -1
- package/dist/content-layer/database/finalize.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/link-refs.js +1 -1
- 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/route-query-deps.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/search-vocab.js +2 -2
- 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/database/static-files.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/l10n-warnings.js +1 -1
- package/dist/content-layer/ingest/markdoc-schema-problem.js +1 -0
- 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/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/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/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/fence.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-markdown.js +2 -2
- 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/products.d.ts +2 -0
- package/dist/content-layer/plugins/internal/app-data/products.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/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/l10n/translations-loader.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/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/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-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.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +7 -6
- 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/discovery.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/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/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/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/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/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/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/delete.js +1 -1
- package/dist/content-layer/search/engine/core/content-parser.js +1 -1
- package/dist/content-layer/search/engine/core/search-engine.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/templates/template-set.js +1 -1
- package/dist/content-layer/versions/group-info.d.ts +21 -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 +14 -13
- 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 +2 -2
- 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/ssrf/ssrf-blocklist.js +1 -1
- package/dist/server/static-files/serve.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/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 +5 -0
- package/dist/shared/constants/review.js +1 -1
- package/dist/{server → shared}/constants/system-routes.d.ts +1 -1
- 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/l10n.js +1 -1
- package/dist/shared/utils/redirect-match.js +1 -0
- 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 +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{SKILL_ENTITY_TYPE as i,skillEntityKey as a}from"../../../types/skill-entity.js";import{isEntityScopeVisible as o}from"../../../../../
|
|
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{SKILL_ENTITY_TYPE as i,skillEntityKey as a}from"../../../types/skill-entity.js";import{isEntityScopeVisible as o}from"../../../../../shared/rbac/entity-scope.js";import{notFoundResponse as s}from"../../../../../server/plugin-context.js";import{publicOrigin as c}from"../../../utils/request-origin.js";const l={"Cache-Control":`no-store`,"Access-Control-Allow-Origin":`*`};function u(e){return e.config.skills?.hide===!0}async function d(a,d){if(u(d))return s();let f=c(d.request),p=await d.entities.list({type:i}),m=await Promise.all(p.map(async n=>{let{slug:i,title:a,description:s}=n.metadata??{};if(typeof i!=`string`||!o(n,d.request.teams,e=>d.logger?.warn(e)))return[];let{content:c}=await d.entities.load(n.key);return[{name:a??i,type:`skill-md`,description:s??``,url:`${f}${t(r(i))}`,digest:`sha256:${e(c)}`}]}));return a.json({$schema:n,skills:m.flat()},200,l)}async function f(e,t){if(u(t))return s();let n=e.req.param(`slug`)??``,r=a(n),i=await t.entities.get(r);if(!i||!o(i,t.request.teams,e=>t.logger?.warn(e)))return s();let{content:c}=await t.entities.load(r);return e.body(c,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.2.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,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{hashContentBytes as t}from"../../../shared/utils/content-hash.js";import{isObject as n}from"../../../shared/utils/is-object.js";import{createNodePlatformFs as r}from"../../../platform/node/fs.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,n={}){let s=_(t),c=n.fs??r(),{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){n.logger?.warn(`Project plugin "${e}" is skipped: ${t} are built in. Remove it from \`plugins\` in redocly.yaml.`);continue}let r=w(e),i=r===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:r??`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:r,feature:i}of p){let a=await D({entry:t,path:r,contentDir:s,config:l,fs:c});if(`lintPlugin`in a&&h.push({entry:t,path:r,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)){n.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:r,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)n.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:n,path:r}=e,i=await t(await e.fs.readBinaryFile(r)),a=p(r);a.searchParams.set(`v`,i),delete d(r).cache[r];let o;try{o=await import(a.href)}catch(e){return{entry:n,path:r,message:`Cannot import the plugin module: ${N(e)}`}}let s=O(o);if(s===void 0)return{entry:n,path:r,message:`The module has no default export.`};let c=s,l=i;if(typeof s==`function`){l+=`+${await t(new TextEncoder().encode(JSON.stringify(e.config)))}`;try{c=await s({engine:`realm-plus`,contentDir:e.contentDir,config:e.config})}catch(e){return{entry:n,path:r,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:n,path:r,message:u,...e&&{lintPlugin:e}}}let f=c;return{entry:n,path:r,plugin:{...f,version:`${f.version}+${l}`}}}function O(e){if(!n(e))return;let t=e.default;return n(t)&&!(`id`in t)&&`default`in t?t.default:t}const k=[`rules`,`preprocessors`,`decorators`,`configs`,`assertions`];function A(e){return n(e)&&typeof e.processContent!=`function`&&typeof e.afterRoutesCreated!=`function`&&e.version===void 0&&k.some(t=>t in e)}function j(e){if(!n(e)||typeof e.id!=`string`||typeof e.processContent!=`function`&&typeof e.afterRoutesCreated!=`function`)return;let t=[...k,`typeExtension`].filter(t=>t in e).map(t=>[t,e[t]]);return t.length>0?Object.fromEntries([[`id`,e.id],...t]):void 0}function M(e){return n(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,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{splitUrlSuffix as e}from"../../../shared/utils/routes/split-url-suffix.js";import{toPhysicalVersionedSlug as t}from"../../../shared/constants/versions.js";
|
|
1
|
+
import{splitUrlSuffix as e}from"../../../shared/utils/routes/split-url-suffix.js";import{toPhysicalVersionedSlug as t}from"../../../shared/constants/versions.js";function n(t,n,i){if(!t.startsWith(`/`))return;let{path:a}=e(t),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(e,n){let r=[...n].sort(([e],[t])=>t.length-e.length);for(let[n,i]of r){if(!i.defaultVersion)continue;let r=t(e,n,i.defaultVersion);if(r!==null&&r!==e)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{compileRouteAccessMatcher as r}from"../../../shared/rbac/engine.js";import{computePathPrefixes as i}from"../../../shared/utils/routes/compute-path-prefixes.js";import{normalizeRoutePath as a}from"../../../shared/utils/routes/normalize-route-path.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=r(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=a(t),r=y(u(e,n));if(r)return r;let o=i(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 {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={"link/missing-target":{category:`links`,severity:`error`},"link/missing-anchor":{category:`links`,severity:`
|
|
1
|
+
const e={"link/missing-target":{category:`links`,severity:`error`},"link/missing-anchor":{category:`links`,severity:`warning`},"markdoc/parse-error":{category:`markdown`,severity:`error`},"markdoc/validation-error":{category:`markdown`,severity:`error`},"markdoc/diagram-service-failed":{category:`markdown`,severity:`warning`},"markdown/frontmatter-parse":{category:`markdown`,severity:`warning`},"search/facet-invalid":{category:`search`,severity:`warning`},"spec/parse-failed":{category:`spec`,severity:`error`},"spec/bundle-error":{category:`spec`,severity:`error`},"routing/slug-collision":{category:`routing`,severity:`error`},"routing/reserved-slug":{category:`routing`,severity:`error`},"routing/wildcard-shadowing":{category:`routing`,severity:`warning`},"plugin/extract-failed":{category:`plugin`,severity:`error`},"plugin/extract-all-failed":{category:`plugin`,severity:`error`},"plugin/finalize-failed":{category:`plugin`,severity:`error`},"plugin/loader-failed":{category:`plugin`,severity:`error`},"plugin/searchable-failed":{category:`plugin`,severity:`error`},"plugin/static-file-invalid":{category:`plugin`,severity:`error`},"plugin/static-file-conflict":{category:`plugin`,severity:`error`},"configuration/invalid":{category:`configuration`,severity:`error`},"configuration/ignored":{category:`configuration`,severity:`warning`},"configuration/deprecated":{category:`configuration`,severity:`warning`},"configuration/l10n-invalid":{category:`configuration`,severity:`error`},"configuration/l10n-layout":{category:`configuration`,severity:`warning`},"configuration/l10n-translations-invalid":{category:`configuration`,severity:`warning`},"configuration/app-data-namespace-conflict":{category:`configuration`,severity:`error`},"configuration/attach-conflict":{category:`configuration`,severity:`error`},"configuration/package-not-allowed":{category:`configuration`,severity:`error`},"configuration/markdoc-schema-failed":{category:`configuration`,severity:`error`},"sidebar/missing-target":{category:`configuration`,severity:`warning`},"sidebar/invalid-entry":{category:`configuration`,severity:`warning`},"sidebar/route-conflict":{category:`configuration`,severity:`warning`},"scorecard/lint-failed":{category:`spec`,severity:`warning`},"react-page/render-failed":{category:`page`,severity:`error`},"system/ingest-failed":{category:`system`,severity:`error`}},t=[`markdoc/diagram-service-failed`,`spec/bundle-error`],n={category:`plugin`,severity:`error`};function r(t){return e[t]??n}function i(e){let t=r(e.code);return{code:e.code,category:t.category,severity:e.severity??t.severity,message:e.message,location:e.location,data:e.data}}export{t as RETRYABLE_PROBLEM_CODES,i as createProblem,r as resolveProblemDefaults};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"picomatch";function t(t){let n=t.revisions?.include??[];if(n.length===0)return null;let r=e(n,{dot:!1});return{max:t.revisions?.max??20,isTracked:e=>r(e.replaceAll(`\\`,`/`))}}export{t as resolveRevisionsConfig};
|
|
1
|
+
import e from"picomatch";function t(e,t){let r=t?n(e):null;return r?{...r,capture:!0}:null}function n(t){let n=t.revisions?.include??[];if(n.length===0)return null;let r=e(n,{dot:!1});return{max:t.revisions?.max??20,isTracked:e=>r(e.replaceAll(`\\`,`/`))}}export{t as resolveRevisionCapture,n as resolveRevisionsConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{entities as e}from"../database/schema.js";import{runWithSqliteBusyRetry as t}from"../database/connection.js";import{and as n,eq as r}from"drizzle-orm";async function i(i,a){let[o]=await i.db.select({id:e.id,isCurrent:e.isCurrent}).from(e).where(n(r(e.key,a.key),r(e.revisionCreatedAt,a.revisionCreatedAt))).limit(1);return o?o.isCurrent===1?`refused-current`:(await t(()=>i.db.delete(e).where(r(e.id,o.id)),{operation:`delete entity revision`}),`deleted`):`not-found`}export{i as deleteEntityRevision};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=class{statistic;segmenter=new Intl.Segmenter(`en`,{granularity:`word`});constructor(e){this.statistic=e}documentProcessing(e,t){return this.statistic.documents.set(e,0),this.parseTokens(e,t)}parseTokens(e,t){if(!t)return[];let n=/* @__PURE__ */ new Map,r=0;for(let e of this.segmenter.segment(t)){if(!e.isWordLike)continue;let t=e.segment.toLowerCase(),i=n.get(t);i?i.push(e.index):n.set(t,[e.index]),r++}return this.statistic.documents.set(e,r),Array.from(n,([t,n])=>({documentId:e,value:t,offsets:n}))}getQueryTokens(e){let t=[];for(let n of this.segmenter.segment(e))n.isWordLike&&t.push(n.segment.toLowerCase());return t}};export{e as ContentParser};
|
|
1
|
+
var e=class{statistic;segmenter=new Intl.Segmenter(`en`,{granularity:`word`});constructor(e){this.statistic=e}documentProcessing(e,t){return this.statistic.documents.set(e,0),this.parseTokens(e,t)}parseTokens(e,t){if(!t)return[];let n=/* @__PURE__ */ new Map,r=0;for(let e of this.segmenter.segment(t)){if(!e.isWordLike)continue;let t=e.segment.toLowerCase(),i=n.get(t);i?i.push(e.index):n.set(t,[e.index]);let a=e.segment;for(let t of/[._:]/.test(a)?a.matchAll(/(?<=[._:])[^._:]+/g):[]){let r=t[0].toLowerCase(),i=n.get(r)??[];i.push(e.index+t.index),n.set(r,i)}r++}return this.statistic.documents.set(e,r),Array.from(n,([t,n])=>({documentId:e,value:t,offsets:n}))}getQueryTokens(e){let t=[];for(let n of this.segmenter.segment(e))n.isWordLike&&t.push(n.segment.toLowerCase());return t}};export{e as ContentParser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ContentParser as e}from"./content-parser.js";import{
|
|
1
|
+
import{ContentParser as e}from"./content-parser.js";import{Statistic as t}from"./radix-tree/statistic.js";import{DocumentField as n}from"./field.js";var r=class{fields=[];limit;parser=new e(new t);constructor(e){this.limit=e.limit;for(let t of e.fields)this.fields.push(new n(t))}search(e,t={}){let n=a(this.parser.getQueryTokens(e));if(n.length===0)return[];let r=e=>t.terms?.get(e)??/* @__PURE__ */ new Set([e]),o=this.fields.map(e=>({field:e,matches:e.match(n,r)})),s=t.documentFrequencies===void 0?i(o.filter(({field:e})=>e.countsTowardFrequency).map(({matches:e})=>e),n):new Map(n.map(e=>[e,t.documentFrequencies?.get(e)??0])),c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map;for(let{field:e,matches:t}of o){let r=e.rank(t,n,s);for(let[t,{rank:n,offsets:i,tokens:a}]of Object.entries(r)){let r=Number(t),o=c.get(r);o?(o.rank+=n*e.weight,o.fields.push({name:e.name,offsets:i,tokens:a})):c.set(r,{id:r,rank:n*e.weight,fields:[{name:e.name,offsets:i,tokens:a}]});let s=l.get(r);s||l.set(r,s=/* @__PURE__ */ new Set);for(let e of a)s.add(e)}}let u=n.filter(e=>!t.optional?.has(e)),d=u.length>0?u:n;for(let e of c.values()){let t=l.get(e.id),n=d.filter(e=>t?.has(e)).length;e.rank*=n/d.length}return Array.from(c.values()).sort((e,t)=>t.rank-e.rank).slice(0,this.limit)}};function i(e,t){let n=/* @__PURE__ */ new Map;for(let r of t){let t=/* @__PURE__ */ new Set;for(let n of e)for(let[e,i]of n)i[r]?.length&&t.add(e);n.set(r,t.size)}return n}function a(e){return[...new Set([...e].reverse())].reverse()}export{r as SearchEngine};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SEARCH_GROUP_FACET_FIELD as e,SEARCH_PRODUCT_FACET_FIELD as t,SEARCH_TEAMS_FACET_FIELD as n,SEARCH_VERSION_FACET_FIELD as r,isReservedSearchFacetField as i,searchVersionFacetValue as a}from"../../shared/search/facets.js";import{normalizeFacetValue as o}from"./facet-values.js";function
|
|
1
|
+
import{SEARCH_GROUP_FACET_FIELD as e,SEARCH_PRODUCT_FACET_FIELD as t,SEARCH_TEAMS_FACET_FIELD as n,SEARCH_VERSION_FACET_FIELD as r,isReservedSearchFacetField as i,searchVersionFacetValue as a}from"../../shared/search/facets.js";import{normalizeFacetValue as o}from"./facet-values.js";import{SEARCH_HIDE_FACET_FIELD as s,SEARCH_PIN_FACET_FIELD as c,curationPhrase as l}from"./keywords.js";function u(u){let d={},{facets:f,onDropped:p}=u;if(f!==void 0){if(typeof f!=`object`||!f||Array.isArray(f))p?.(`facets`,`not-an-object`);else for(let[e,t]of Object.entries(f)){if(i(e)){p?.(e,`reserved`);continue}if(!u.configuredFields.has(e))continue;let n=o(t);if(n===null){p?.(e,`invalid`);continue}let r=n.filter(e=>e.length<=500);r.length<n.length&&p?.(e,`too-long`),r.length>0&&(d[e]=r)}}if(d[e]=[u.groupKey||`Results`],u.teams.length>0&&(d[n]=[...new Set(u.teams)]),u.version!==null){let{group:e,version:t}=u.version;d[r]=[a(e,t)]}u.product!==null&&(d[t]=[u.product]);let m=e=>{let t=/* @__PURE__ */ new Set;for(let n of(e??[]).map(l))n!==``&&(n.length>500?p?.(`keywords`,`too-long`):n.split(` `).length>10?p?.(`keywords`,`too-many-words`):t.add(n));return t},h=m(u.keywords?.excludes),g=[...m(u.keywords?.includes)].filter(e=>!h.has(e));return g.length>0&&(d[c]=g),h.size>0&&(d[s]=[...h]),d}export{u as buildDocumentFacets};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SearchDocumentKeywords } from '../plugins/types/search.js';
|
|
2
|
+
/** Curation: the query phrases that show the document before the ranked hits. */
|
|
3
|
+
export declare const SEARCH_PIN_FACET_FIELD = "redocly_pin";
|
|
4
|
+
/** Curation: the query phrases that hide the document. */
|
|
5
|
+
export declare const SEARCH_HIDE_FACET_FIELD = "redocly_hide";
|
|
6
|
+
/** The most words a curation keyword has; a longer keyword is not stored. */
|
|
7
|
+
export declare const CURATION_MAX_KEYWORD_WORDS = 10;
|
|
8
|
+
/**
|
|
9
|
+
* The front matter `keywords` object (`{ includes, excludes }`) as curation keywords;
|
|
10
|
+
* undefined for another shape or when both lists are empty. A number or boolean item
|
|
11
|
+
* becomes its string, as in the classic engine; other items are dropped.
|
|
12
|
+
*/
|
|
13
|
+
export declare function curationKeywordsOf(value: unknown): SearchDocumentKeywords | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* A keyword or a query as the curation compares them: its query tokens joined by one space.
|
|
16
|
+
* A query contains a keyword when ` <query> ` contains ` <keyword> `.
|
|
17
|
+
*/
|
|
18
|
+
export declare function curationPhrase(text: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject as e}from"../../shared/utils/is-object.js";import{tokenizeSearchQuery as t}from"./tokenize.js";const n=`redocly_pin`,r=`redocly_hide`;function i(t){if(!e(t))return;let n=e=>Array.isArray(e)?e.filter(e=>[`string`,`number`,`boolean`].includes(typeof e)).map(e=>String(e)):[],r=n(t.includes),i=n(t.excludes);if(r.length!==0||i.length!==0)return{...r.length>0?{includes:r}:{},...i.length>0?{excludes:i}:{}}}function a(e){return t(e).join(` `)}export{r as SEARCH_HIDE_FACET_FIELD,n as SEARCH_PIN_FACET_FIELD,i as curationKeywordsOf,a as curationPhrase};
|
|
@@ -2,6 +2,8 @@ import type { SearchFragment } from '../../plugins/types/search.js';
|
|
|
2
2
|
import type { SearchParameterHighlight } from '../store.js';
|
|
3
3
|
/** The text the `parameters` field indexes for one fragment: its parts joined by one space. */
|
|
4
4
|
export declare function indexedFragmentText(fragment: SearchFragment): string;
|
|
5
|
+
/** The `offsets` into a fragment's indexed text that lie in its name, which the text starts with. */
|
|
6
|
+
export declare function nameOffsets(name: string, offsets: readonly number[]): number[];
|
|
5
7
|
/**
|
|
6
8
|
* An anchor split where the fields under one parent share it: the part up to the field's
|
|
7
9
|
* own segment of the `path=` value, and that segment. An anchor without a `path=` is all
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return[e.name,e.description??``,e.example??``,e.enum&&e.enum.length>0?e.enum.join(` `):``].filter(e=>e!==``)}function t(t){return e(t).join(` `)}function n(e){let t=e.indexOf(`path=`);if(t===-1)return{prefix:e,tail:``};let n=e.lastIndexOf(`/`),r=n>t?n+1:t+5;return{prefix:e.slice(0,r),tail:e.slice(r)}}function
|
|
1
|
+
function e(e){return[e.name,e.description??``,e.example??``,e.enum&&e.enum.length>0?e.enum.join(` `):``].filter(e=>e!==``)}function t(t){return e(t).join(` `)}function n(e,t){return t.filter(t=>t<e.length)}function r(e){let t=e.indexOf(`path=`);if(t===-1)return{prefix:e,tail:``};let n=e.lastIndexOf(`/`),r=n>t?n+1:t+5;return{prefix:e.slice(0,r),tail:e.slice(r)}}function i(e,t){let n=e.description??``;if(n===``)return[];let r=e.name.length+1,i=r+n.length;return t.flatMap(([e=0,...t])=>{let n=t.filter(t=>t>=r&&t+e<=i);return n.length===0?[]:[[e,...n.map(e=>e-r)]]})}function a(e){let t=[];for(let[n,...r]of e)for(let e of r)t.push({start:e,end:e+(n??0)});return t.sort((e,t)=>e.start-t.start||t.end-e.end)}function o(e,t,n){let r=t+e.length,i=``,a=0;for(let o of n){if(o.start<t||o.end>r)continue;let n=o.start-t,s=o.end-t;n<a||(i+=`${e.slice(a,n)}<mark>${e.slice(n,s)}</mark>`,a=s)}return i+e.slice(a)}function s(e,t,n){let r=n?a(n):[],i=0,s=e=>{if(e===``)return e;let t=o(e,i,r);return i+=e.length+1,t},c={place:t.place,path:[...t.path],name:s(e.name),description:s(e.description??``)};return e.example&&(c.example=s(e.example)),e.enum&&e.enum.length>0&&(c.enum=s(e.enum.join(` `))),c}export{i as descriptionOffsetGroups,s as highlightFragment,t as indexedFragmentText,n as nameOffsets,r as splitAnchor};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { type ContentLayerDatabase } from '../../database/connection.js';
|
|
2
|
+
import { SearchEngine } from '../engine/core/search-engine.js';
|
|
2
3
|
import { type SearchStore } from '../store.js';
|
|
4
|
+
/**
|
|
5
|
+
* How the store indexes a document's fields. Change it with `FIELDS` or a field's text, so
|
|
6
|
+
* the sync re-runs every producer and no stored row keeps the old index.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SEARCH_INDEX_FORMAT = 3;
|
|
3
9
|
/** Characters a text snippet shows around the densest passage of matches. */
|
|
4
10
|
export declare const SNIPPET_LENGTH = 200;
|
|
5
11
|
/** The whole `content` with every match wrapped in `<mark>`. */
|
|
@@ -16,6 +22,13 @@ export declare function highlightPath(path: readonly string[] | undefined, title
|
|
|
16
22
|
* at word boundaries and marked with `…` on the sides that were trimmed.
|
|
17
23
|
*/
|
|
18
24
|
export declare function highlightSnippet(content: string, offsetGroups?: number[][], length?: number): string | undefined;
|
|
25
|
+
type RankedMatch = ReturnType<SearchEngine['search']>[number];
|
|
26
|
+
/**
|
|
27
|
+
* `ranked` with the `pinned` documents first: the ranked ones in rank order, then the
|
|
28
|
+
* others, which do not hold the words, in id order. Each pinned match ranks above every
|
|
29
|
+
* other match.
|
|
30
|
+
*/
|
|
31
|
+
export declare function pinFirst(ranked: readonly RankedMatch[], pinned: readonly number[]): RankedMatch[];
|
|
19
32
|
/**
|
|
20
33
|
* The SQL postings search store: documents, a term dictionary and per-field postings live
|
|
21
34
|
* in plain tables; queries pull the postings of the documents holding every query word and
|
|
@@ -26,3 +39,4 @@ export declare function highlightSnippet(content: string, offsetGroups?: number[
|
|
|
26
39
|
* terms, before the postings are read.
|
|
27
40
|
*/
|
|
28
41
|
export declare function createPostingsSearchStore(database: ContentLayerDatabase): SearchStore;
|
|
42
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SEARCH_GROUP_FACET_FIELD as e,SEARCH_TEAMS_FACET_FIELD as t,SEARCH_VERSION_FACET_FIELD as n}from"../../../shared/search/facets.js";import{batchValues as r,normalizeBatchSize as i}from"../../database/connection.js";import{searchDocuments as a,searchFacets as o,searchFragmentParents as s,searchFragmentPostings as c,searchFragmentUsages as l,searchFragments as u,searchPostings as d,searchVocab as f}from"../../database/schema.js";import{teamBlockSectionKey as p}from"../../markdown/search/to-sections.js";import{refreshTermDocCounts as m,selectTermIdsOfDocuments as h,selectTermIdsOfFragments as g}from"../../database/search-vocab.js";import{SearchEngine as _}from"../engine/core/search-engine.js";import{PATH_SEGMENT_SEPARATOR as v,indexedPathSegments as y,indexedPathText as b,splitIndexedPath as x}from"./path-field.js";import{descriptionOffsetGroups as S,highlightFragment as C,indexedFragmentText as w,splitAnchor as T}from"./fragment-field.js";import{createPostingsTermLookup as E,wordOffsets as D}from"./term-lookup.js";import{optionalTokens as O}from"../stopwords.js";import{tokenizeSearchContent as k,tokenizeSearchQuery as ee}from"../tokenize.js";import{maxEditsForToken as A,pickCorrection as j}from"./typo-correction.js";import"../store.js";import{and as M,asc as N,between as P,desc as F,eq as I,exists as L,gte as R,inArray as z,lt as B,lte as V,ne as H,notExists as te,notInArray as ne,or as re,sql as U}from"drizzle-orm";import{alias as ie,unionAll as W}from"drizzle-orm/sqlite-core";const ae=/* @__PURE__ */ new Set([e]),G=[{name:`title`,weight:2},{name:`text`,weight:1},{name:`path`,weight:1}],oe={name:`parameters`,weight:1};function se(e,t,n,r){let i=k(t.title),a=k(t.text),o=k(b(t.path,t.title)),s=t.path||t.badges||t.product||t.version||t.isAdditionalOperation?{path:t.path,badges:t.badges,product:t.product,version:t.version,isAdditionalOperation:t.isAdditionalOperation}:null;return{fields:{title:i,text:a,path:o},facets:t.facets??{},row:{entityKey:e,docKey:t.docKey,routeSlug:t.routeSlug,locale:t.locale??``,anchor:t.anchor??null,title:t.title,text:t.text,titleTokens:i.length,textTokens:a.length,pathTokens:o.length,sourceHash:n,pluginVersion:r,groupKey:t.groupKey||null,httpMethod:t.httpMethod??null,httpPath:t.httpPath??null,deprecated:+!!t.deprecated,extra:s}}}function ce(e){let t=new Map(e.docs.map(e=>[e.docKey,e.locale??``])),n=(e.uses??[]).filter(e=>t.has(e.docKey)),r=/* @__PURE__ */ new Map;for(let e of n)r.has(e.fragmentKey)||r.set(e.fragmentKey,t.get(e.docKey)??``);let i=[],a=/* @__PURE__ */ new Set;for(let t of e.fragments??[]){let e=r.get(t.fragmentKey);e===void 0||a.has(t.fragmentKey)||(a.add(t.fragmentKey),i.push({fragment:t,locale:e,tokens:k(w(t))}))}let o=/* @__PURE__ */ new Map;for(let e of n){if(!a.has(e.fragmentKey))continue;let t=JSON.stringify([e.docKey,e.fragmentKey]);o.has(t)||o.set(t,e)}let s=/* @__PURE__ */ new Map;for(let e of o.values()){let t=e.path??[],{prefix:n,tail:r}=T(e.anchor),i=JSON.stringify([e.docKey,e.place,t,n]),a=s.get(i);a||(a={docKey:e.docKey,place:e.place,path:t,anchorPrefix:n,uses:[]},s.set(i,a)),a.uses.push({fragmentKey:e.fragmentKey,anchorTail:r})}return{entityKey:e.entityKey,docs:e.docs.map(t=>se(e.entityKey,t,e.sourceHash,e.pluginVersion)),fragments:i,parents:[...s.values()]}}function le(e){let t={fragmentKey:e.fragmentKey,name:e.name,description:e.description};return e.example&&(t.example=e.example),e.enumValues&&e.enumValues.length>0&&(t.enum=e.enumValues),t}const K=(e,t)=>JSON.stringify([e,t]),q=(e,t)=>JSON.stringify([e,t]);async function ue(e,t){let n=e.select({id:a.id}).from(a).where(z(a.entityKey,[...t])),r=e.select({id:u.id}).from(u).where(z(u.entityKey,[...t])),i=[...await h(e,n.getSQL()),...await g(e,r.getSQL())];return await e.delete(d).where(z(d.docId,n)),await e.delete(o).where(z(o.docId,n)),await e.delete(c).where(z(c.fragmentId,r)),await e.delete(s).where(z(s.docId,n)),await e.delete(l).where(z(l.fragmentId,r)),await e.delete(u).where(z(u.entityKey,[...t])),i}function de(e,t){if(e.length<=t)return e;let n=e.lastIndexOf(` `,t);return`${e.slice(0,n>0?n:t)}…`}function J(e){let t=[];return e.forEach(([e,...n],r)=>{for(let i of n)t.push({start:i,end:i+(e??0),word:r})}),t.sort((e,t)=>e.start-t.start||t.end-e.end)}function Y(e,t,n,r){let i=``,a=n;for(let{start:n,end:o}of t)n<a||o>r||(i+=`${e.slice(a,n)}<mark>${e.slice(n,o)}</mark>`,a=o);return i+e.slice(a,r)}function X(e,t){if(t?.length)return Y(e,J(t),0,e.length)}function fe(e,t,n,r){if(e===void 0||e.length<2)return;let i=y(e,t),a=i.length<e.length,o=X(i.join(v),n),s=a?r:void 0;if(o===void 0&&s===void 0)return;let c=o===void 0?[...i]:x(o);return a?[...c,s??t]:c}function Z(e,t,n=200){if(!t?.length)return;let r=J(t);if(r.length===0||e.length<=n)return Y(e,r,0,e.length);let i={first:0,last:0,words:0,matches:0};for(let e=0;e<r.length;e++){let t=r[e].start+n,a=/* @__PURE__ */ new Set,o=e;for(let n=e;n<r.length&&r[n].end<=t;n++)a.add(r[n].word),o=n;let s=o-e+1;(a.size>i.words||a.size===i.words&&s>i.matches)&&(i={first:e,last:o,words:a.size,matches:s})}let a=r[i.first].start,o=r[i.last].end,s=Math.max(0,Math.min(a-Math.floor((n-(o-a))/2),e.length-n)),c=Math.min(e.length,s+n);if(s>0){let t=e.lastIndexOf(` `,s);s=t===-1?0:Math.min(t+1,a)}if(c<e.length){let t=e.indexOf(` `,c);c=t===-1?e.length:Math.max(t,o)}let l=Y(e,r,s,c);return`${s>0?`…`:``}${l}${c<e.length?`…`:``}`}async function pe(e,t,n){let[r]=await e.select({max:U`max(${n})`}).from(t);return Number(r?.max??0)}function me(h){let g=i(void 0);async function v(e,t){let n=t.map(e=>e.entityKey),i=[];for(let t of r(n,g)){for(let n of await ue(e,t))i.push(n);await e.delete(a).where(z(a.entityKey,t))}let p=t.flatMap(e=>e.docs);if(p.length===0){await m(e,i);return}for(let t of r(p,g))await e.insert(a).values(t.map(e=>e.row));let h=/* @__PURE__ */ new Map;for(let t of r(n,g)){let n=await e.select({id:a.id,entityKey:a.entityKey,docKey:a.docKey}).from(a).where(z(a.entityKey,t));for(let e of n)h.set(K(e.entityKey,e.docKey),e.id)}let _=/* @__PURE__ */ new Map,v=(e,t)=>JSON.stringify([e,t]),y=await pe(e,u,u.id)+1,b=[];for(let e of t)for(let{fragment:t,locale:n}of e.fragments){let r=y++;_.set(v(e.entityKey,t.fragmentKey),r),b.push({id:r,entityKey:e.entityKey,fragmentKey:t.fragmentKey,locale:n,name:t.name,description:t.description??``,example:t.example??null,enumValues:t.enum??null})}let x=await pe(e,s,s.id)+1,S=[],C=[];for(let e of t)for(let t of e.parents){let n=h.get(K(e.entityKey,t.docKey));if(n===void 0)continue;let r=x++;S.push({id:r,docId:n,place:t.place,path:t.path,anchorPrefix:t.anchorPrefix});for(let i of t.uses){let t=_.get(v(e.entityKey,i.fragmentKey));t!==void 0&&C.push({fragmentId:t,docId:n,parentId:r,anchorTail:i.anchorTail})}}for(let t of r(b,g))await e.insert(u).values(t);for(let t of r(S,g))await e.insert(s).values(t);for(let t of r(C,g))await e.insert(l).values(t);let w=/* @__PURE__ */ new Map,T=e=>{let t=w.get(e);return t||(t=/* @__PURE__ */ new Set,w.set(e,t)),t};for(let e of p){let t=T(e.row.locale??``);for(let n of G)for(let r of e.fields[n.name].tokens)t.add(r.value)}for(let e of t)for(let{locale:t,tokens:n}of e.fragments){let e=T(t);for(let t of n.tokens)e.add(t.value)}let E=/* @__PURE__ */ new Map;for(let[t,n]of w)for(let i of r([...n],g)){await e.insert(f).values(i.map(e=>({term:e,locale:t}))).onConflictDoNothing();let n=await e.select({id:f.id,term:f.term}).from(f).where(M(I(f.locale,t),z(f.term,i)));for(let e of n)E.set(q(t,e.term),e.id)}let D=[];for(let e of p){let t=h.get(K(e.row.entityKey,e.row.docKey));if(t!==void 0)for(let n of G)for(let r of e.fields[n.name].tokens){let i=E.get(q(e.row.locale??``,r.value));i!==void 0&&D.push({termId:i,field:n.name,docId:t,offsets:JSON.stringify(r.offsets)})}}for(let t of r(D,g))await e.insert(d).values(t);let O=[];for(let e of t)for(let{fragment:t,locale:n,tokens:r}of e.fragments){let i=_.get(v(e.entityKey,t.fragmentKey));if(i!==void 0)for(let e of r.tokens){let t=E.get(q(n,e.value));t!==void 0&&O.push({termId:t,fragmentId:i,offsets:JSON.stringify(e.offsets)})}}for(let t of r(O,g))await e.insert(c).values(t);let k=[];for(let e of p){let t=h.get(K(e.row.entityKey,e.row.docKey));if(t!==void 0)for(let[n,r]of Object.entries(e.facets))for(let e of r)k.push({docId:t,field:n,value:e})}for(let t of r(k,g))await e.insert(o).values(t);await m(e,[...i,...E.values()])}let y=e=>e===void 0?void 0:z(f.locale,[...e]);function b(e,t){return h.db.select({id:f.id,term:f.term}).from(f).where(M(e,y(t))).orderBy(F(f.docCount),N(f.term)).limit(50)}let x=(e,t)=>b(M(R(f.term,e),V(f.term,`${e}\uffff`)),t);async function w(e,t){let n=A(e),r=e.codePointAt(0);if(n===0||r===void 0||r>=1114111)return[];let i=[...e].length,a=await h.db.select({id:f.id,term:f.term,docCount:f.docCount}).from(f).where(M(y(t),R(f.term,String.fromCodePoint(r)),B(f.term,String.fromCodePoint(r+1)),P(U`length(${f.term})`,i-n,i+n))).orderBy(F(f.docCount),N(f.term)).limit(2e3),o=/* @__PURE__ */ new Map;for(let{id:e,term:t,docCount:n}of a){let r=o.get(t);r?(r.docCount+=n,r.ids.push(e)):o.set(t,{term:t,docCount:n,ids:[e]})}let s=j(e,[...o.values()]);return s===null?[]:(o.get(s)?.ids??[]).map(e=>({id:e,term:s}))}async function T(e,t,n){let r=e.length-1,i=(e,n)=>t.has(e)&&n!==r,a=(e,t)=>t===r||t>r-3&&e.length>=3,[o,s]=await Promise.all([h.db.select({id:f.id,term:f.term}).from(f).where(M(z(f.term,e),y(n))),Promise.all(e.map(async(e,t)=>!i(e,t)&&a(e,t)?x(e,n):[]))]);return Promise.all(e.map(async(e,t)=>{let c=o.filter(t=>t.term===e);if(i(e,t))return k(e,c,!0);let l=[...c,...s[t]??[]];if(l.length>0)return k(e,l);let u=await w(e,n),d=u[0]?.term;if(d!==void 0){let e=a(d,t)?await x(d,n):[];return k(d,[...u,...e])}let p=t===r&&e.length>=3?await b(U`instr(${f.term}, ${e}) > 0`,n):[];return k(e,p)}))}let k=(e,t,n=!1)=>({word:e,ids:[...new Set(t.map(e=>e.id))],terms:new Set(t.map(e=>e.term)),optional:n});function se(e){let t=/* @__PURE__ */ new Set,n=[];for(let r of[...e].reverse())t.has(r.word)||(t.add(r.word),n.push(r));return n.reverse()}let J=()=>({hits:[],facetCounts:{}});function Y(e,t){let n=Math.max(0,Math.trunc(e.offset??0));return{offset:n,end:Math.min(n+t,500)}}function me(e){let t=e?.trim().toLowerCase();if(t)return e=>e.toLowerCase().startsWith(t)}let he=e=>(e.filter??[]).filter(e=>e.values.length>0),Q=ie(o,`carried`),$=(e,t)=>t.length===0?U`0`:L(h.db.select({one:U`1`}).from(Q).where(M(I(Q.docId,a.id),I(Q.field,e),z(Q.value,[...t]))));function ge(e,r){let i=[];e.locales!==void 0&&i.push(z(a.locale,[...e.locales]));let{candidates:o}=e;if(o!==void 0&&(r===void 0||o.lifted!==r)&&i.push(z(a.id,o.ids)),e.teams!==void 0&&i.push($(t,[...new Set(e.teams.map(e=>e.toLowerCase()))])),e.versions!==void 0){let t=te(h.db.select({one:U`1`}).from(Q).where(M(I(Q.docId,a.id),I(Q.field,n)))),r=[...new Set(e.versions)];i.push(r.length===0?t:re(t,$(n,r)))}for(let t of e.selections)t.field!==r&&i.push($(t.field,t.values));return i}async function _e(e){let t=await h.db.select({id:a.id,titleTokens:a.titleTokens,textTokens:a.textTokens,pathTokens:a.pathTokens,groupKey:a.groupKey,entityKey:a.entityKey,docKey:a.docKey}).from(a).where(M(...ge(e)));return new Map(t.map(({id:e,...t})=>[e,t]))}async function ve(e,t,n){return h.db.select({field:o.field,value:o.value,count:U`count(*)`}).from(a).crossJoin(o).where(M(I(o.docId,a.id),z(o.field,[...t]),...ge(e,n))).groupBy(o.field,o.value)}let ye=(e,t)=>h.db.select({docId:o.docId}).from(o).where(M(I(o.field,e),z(o.value,[...t])));function be(e,r){let i=o.docId,s=[];if(e.locales!==void 0&&s.push(z(i,h.db.select({id:a.id}).from(a).where(z(a.locale,[...e.locales])))),e.teams!==void 0){let n=[...new Set(e.teams.map(e=>e.toLowerCase()))];s.push(n.length===0?U`0`:z(i,ye(t,n)))}if(e.versions!==void 0){let t=ne(i,h.db.select({docId:o.docId}).from(o).where(I(o.field,n))),r=[...new Set(e.versions)];s.push(r.length===0?t:re(t,z(i,ye(n,r))))}for(let t of e.selections)t.field!==r&&s.push(z(i,ye(t.field,t.values)));return s}async function xe(e,t,n){return h.db.select({field:o.field,value:o.value,count:U`count(*)`}).from(o).where(M(z(o.field,[...t]),...be(e,n))).groupBy(o.field,o.value)}async function Se(e,t,n){let r=[...new Set(t)],i=r.filter(t=>e.candidates!==void 0&&e.candidates.lifted!==t),a=r.filter(e=>!i.includes(e)),o=new Set(e.selections.map(e=>e.field)),s=e=>{let t=e.filter(e=>!o.has(e));return[...t.length>0?[{fields:t,lift:void 0}]:[],...e.filter(e=>o.has(e)).map(e=>({fields:[e],lift:e}))]},c=(await Promise.all([...s(i).map(t=>ve(e,t.fields,t.lift)),...s(a).map(t=>xe(e,t.fields,t.lift))])).flat(),l=me(n),u={};for(let e of r)u[e]=c.filter(t=>t.field===e&&(l===void 0||l(t.value))).map(e=>({value:e.value,count:Number(e.count)})).sort((e,t)=>t.count-e.count||(e.value<t.value?-1:1)).slice(0,ae.has(e)?void 0:25);return u}async function Ce(e){let t=/* @__PURE__ */ new Map;for(let n of r(e,g)){let e=await h.db.select().from(a).where(z(a.id,n));for(let n of e)t.set(n.id,n)}return t}async function we(e,t){let n=[];for(let i of r(e,g)){let e=await h.db.select({field:d.field,term:f.term,docId:d.docId,offsets:d.offsets}).from(d).innerJoin(f,I(f.id,d.termId)).where(M(z(d.termId,i),t===void 0?void 0:z(d.docId,t)));for(let t of e)n.push(t)}return n}function Te(e,t){let n=h.db.select({docId:d.docId,termId:d.termId}).from(d).where(M(z(d.termId,e),H(d.field,`path`))),r=h.db.select({docId:l.docId,termId:c.termId}).from(c).innerJoin(l,I(l.fragmentId,c.fragmentId)).where(z(c.termId,e)),i=W(n,r).as(`occurrences`),a=h.db.select({docId:i.docId}).from(i);if(t===void 0)return a;let o=U.join(t.map(e=>U`max(case when ${z(i.termId,[...e])} then 1 else 0 end)`),U` + `);return a.groupBy(i.docId).having(U`${o} = ${t.length}`)}async function Ee(e){let t=(e,t)=>{let n=h.db.select({docId:d.docId}).from(d).where(M(z(d.termId,[...t]),H(d.field,`path`))),r=h.db.select({docId:l.docId}).from(c).innerJoin(l,I(l.fragmentId,c.fragmentId)).where(z(c.termId,[...t])),i=W(n,r).as(`reached`);return h.db.select({word:U`${e}`.as(`word`),count:U`count(distinct ${i.docId})`.as(`count`)}).from(i)},n=e.flatMap((e,n)=>e.length===0?[]:[t(n,e)]),r=e.map(()=>0);if(n.length===0)return r;let i=n.length===1?await n[0]:await W(...n);for(let e of i)r[Number(e.word)]=Number(e.count);return r}async function De(e,t){let n=[];for(let i of r(e,g)){let e=await h.db.select({term:f.term,fragmentId:c.fragmentId,offsets:c.offsets,docId:l.docId}).from(c).innerJoin(f,I(f.id,c.termId)).innerJoin(l,I(l.fragmentId,c.fragmentId)).where(M(z(c.termId,i),t===void 0?void 0:z(U`+${l.docId}`,t)));for(let t of e)n.push(t)}return n}function Oe(e){let t=/* @__PURE__ */ new Map;return e.map(e=>{let n=`${e.docId}\u0000${e.fragmentId}`,r=t.get(n);r===void 0&&t.set(n,r=t.size);let i=r*1e6,a=JSON.parse(e.offsets).map(e=>i+e);return{term:e.term,docId:e.docId,offsets:JSON.stringify(a)}})}function ke(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){let e=n.get(r.docId);e||n.set(r.docId,e=/* @__PURE__ */ new Map);let i=e.get(r.fragmentId);i||(i={fragmentId:r.fragmentId,score:0,offsetGroups:[]},e.set(r.fragmentId,i));let a=JSON.parse(r.offsets);i.score+=a.length;for(let{word:e,terms:n}of t)n.has(r.term)&&i.offsetGroups.push([e.length,...D(e,r.term,a)])}let r=/* @__PURE__ */ new Map;for(let[e,t]of n){let n;for(let e of t.values())(n===void 0||e.score>n.score)&&(n=e);n&&r.set(e,{fragmentId:n.fragmentId,offsetGroups:n.offsetGroups})}return r}async function Ae(e){let t=/* @__PURE__ */ new Map;for(let n of r([...new Set(e)],g)){let e=await h.db.select().from(u).where(z(u.id,n));for(let n of e)t.set(n.id,le(n))}return t}async function je(e){let t=/* @__PURE__ */ new Map;if(e.size===0)return t;let n=await h.db.select({docId:l.docId,fragmentId:l.fragmentId,anchorTail:l.anchorTail,place:s.place,path:s.path,anchorPrefix:s.anchorPrefix}).from(l).innerJoin(s,I(s.id,l.parentId)).where(M(z(l.docId,[...e.keys()]),z(l.fragmentId,[...new Set([...e.values()].map(e=>e.fragmentId))])));for(let r of n)e.get(r.docId)?.fragmentId===r.fragmentId&&t.set(r.docId,{place:r.place,path:r.path,anchor:r.anchorPrefix+r.anchorTail});return t}async function Me(e){let[t]=await h.db.select({total:U`count(*)`,averageTitle:U`avg(${a.titleTokens})`,averageText:U`avg(${a.textTokens})`,averagePath:U`avg(nullif(${a.pathTokens}, 0))`}).from(a).where(e===void 0?void 0:z(a.locale,[...e]));return t}async function Ne(t,n,r){let{locales:i}=n,a=se(t),o=a.filter(e=>!e.optional).map(e=>e.ids).filter(e=>e.length>0),s=[...new Set(o.flat())];if(s.length===0)return J();let c=a.filter(e=>e.optional).flatMap(e=>e.ids),l=[.../* @__PURE__ */ new Set([...s,...c])],u=a.map(e=>e.word),d=new Set(a.filter(e=>e.optional).map(e=>e.word)),f=e=>({locales:i,candidates:{ids:e},teams:n.teams,versions:n.versions,selections:he(n)}),m=Te(s,o),h=Te(s),g=e=>Se(e,n.countFields??[],n.countValuePrefix);if(n.countOnly){let e=await g(f(m));return{hits:[],facetCounts:Object.values(e).every(e=>e.length===0)&&o.length>1?await g(f(h)):e}}let v=Promise.all([Me(i),Ee(a.map(e=>e.ids))]),y=(e,t)=>Promise.all([g(f(e)),_e(f(e)),we(l,t?e:void 0),De(s,t?e:void 0)]),[b,x,w,T]=await y(m,!0);x.size===0&&o.length>1&&([b,x,w,T]=await y(h,c.length>0));let[D,O]=await v;if(x.size===0||w.length===0&&T.length===0)return{hits:[],facetCounts:b};let k=new Map(a.map((e,t)=>[e.word,O[t]??0])),ee=new Set([...w,...T].map(e=>e.docId)),A=Y(n,r),j=(e,t)=>({totalDocuments:D?.total??0,averageDocumentLength:t??0,getDocumentLength:t=>x.get(t)?.[e]??0}),M=new _({limit:ee.size,fields:[{name:`title`,weight:G[0].weight,lookup:E(w.filter(e=>e.field===`title`)),corpusStats:j(`titleTokens`,D?.averageTitle??null)},{name:`text`,weight:G[1].weight,lookup:E(w.filter(e=>e.field===`text`)),corpusStats:j(`textTokens`,D?.averageText??null)},{name:`path`,weight:G[2].weight,lookup:E(w.filter(e=>e.field===`path`)),corpusStats:j(`pathTokens`,D?.averagePath??null),countsTowardFrequency:!1},{name:oe.name,weight:oe.weight,lookup:E(Oe(T)),corpusStats:{totalDocuments:D?.total??0,averageDocumentLength:1,getDocumentLength:()=>1}}]}),N=/* @__PURE__ */ new Set,P=/* @__PURE__ */ new Map,F=M.search(u.join(` `),{optional:d,documentFrequencies:k,terms:new Map(a.map(e=>[e.word,e.terms]))}).filter(e=>{let t=x.get(e.id);if(t===void 0)return!1;let n=K(t.entityKey,p(t.docKey));return N.has(n)?(t.groupKey!==null&&P.set(t.groupKey,(P.get(t.groupKey)??0)+1),!1):(N.add(n),!0)}),I=b[e];I!==void 0&&P.size>0&&(b[e]=I.map(({value:e,count:t})=>({value:e,count:t-(P.get(e)??0)})).filter(({count:e})=>e>0));let L=n.perGroup,R=/* @__PURE__ */ new Map,z=L===void 0?F.slice(A.offset,A.end):F.filter(e=>{let t=x.get(e.id)?.groupKey??null,n=R.get(t)??0;return R.set(t,n+1),n<L}),B=new Set(z.map(e=>e.id)),V=ke(T.filter(e=>B.has(e.docId)),a),[H,te,ne]=await Promise.all([Ce([...B]),Ae([...V.values()].map(e=>e.fragmentId)),je(V)]);return{hits:z.flatMap(e=>{let t=H.get(e.id);if(!t)return[];let n=t=>e.fields.find(e=>e.name===t),r=e=>n(e)?.offsets,i={},a=X(t.title,r(`title`)),o=Z(t.text,r(`text`)),s=fe(t.extra?.path,t.title,r(`path`),a);a!==void 0&&(i.title=a),o!==void 0&&(i.text=o),s!==void 0&&(i.path=s);let c=V.get(e.id),l=c?te.get(c.fragmentId):void 0,u=ne.get(e.id),f={...t,rank:e.rank,highlight:i};if(c===void 0||l===void 0||u===void 0)return[f];let p=C(l,u,c.offsetGroups),m=l.description??``;return p.description=Z(m,S(l,c.offsetGroups))??de(m,200),i.parameters=[p],[n(`title`)?.tokens.some(e=>!d.has(e))?f:{...f,parameterAnchor:u.anchor}]}),facetCounts:b}}async function Pe(e,t){let n=he(e),[r]=n,i={locales:e.locales,candidates:r&&{ids:h.db.select({docId:o.docId}).from(o).where(M(I(o.field,r.field),z(o.value,[...r.values]))),lifted:r.field},teams:e.teams,versions:e.versions,selections:n},s=await Se(i,e.countFields??[],e.countValuePrefix),c=Y(e,t);return e.countOnly||i.selections.length===0||c.end<=c.offset?{hits:[],facetCounts:s}:{hits:(await h.db.select().from(a).where(M(...ge(i))).orderBy(N(a.routeSlug),N(a.docKey)).limit(c.end-c.offset).offset(c.offset)).map(e=>Object.assign(e,{rank:0,highlight:{}})),facetCounts:s}}return{async replaceSourceDocuments(e,t){if(e.length===0)return;let n=e.map(ce);t?await v(t,n):await h.db.transaction(e=>v(e,n))},async removeSource(e){await h.db.transaction(async t=>{let n=await ue(t,[e]);await t.delete(a).where(I(a.entityKey,e)),await m(t,n)})},async query(e){let t=Math.min(Math.max(1,Math.trunc(e.limit)),500),n=ee(e.q);return n.length===0?Pe(e,t):Ne(await T(n,O(n,e.stopwords),e.locales),e,t)},async readDocuments(e={}){let t=[e.routeSlug===void 0?void 0:I(a.routeSlug,e.routeSlug),e.entityKey===void 0?void 0:I(a.entityKey,e.entityKey)].filter(e=>e!==void 0);return h.db.select().from(a).where(t.length>0?M(...t):void 0).orderBy(N(a.entityKey),N(a.docKey))}}}export{me as createPostingsSearchStore,X as highlightOffsets,fe as highlightPath,Z as highlightSnippet};
|
|
1
|
+
import{SEARCH_GROUP_FACET_FIELD as e,SEARCH_TEAMS_FACET_FIELD as t,SEARCH_VERSION_FACET_FIELD as n}from"../../../shared/search/facets.js";import{routes as r,searchDocuments as i,searchFacets as a,searchFragmentParents as o,searchFragmentPostings as s,searchFragmentUsages as c,searchFragments as l,searchPostings as u,searchVocab as d}from"../../database/schema.js";import{batchValues as f,normalizeBatchSize as p}from"../../database/connection.js";import{TEAM_BLOCK_KEY_MARKER as m,isTeamBlockKey as h}from"../../markdown/search/to-sections.js";import{tokenizeSearchContent as g,tokenizeSearchQuery as _}from"../tokenize.js";import{SEARCH_HIDE_FACET_FIELD as v,SEARCH_PIN_FACET_FIELD as y}from"../keywords.js";import{refreshTermDocCounts as b,selectTermIdsOfDocuments as x,selectTermIdsOfFragments as S}from"../../database/search-vocab.js";import{SearchEngine as ee}from"../engine/core/search-engine.js";import{PATH_SEGMENT_SEPARATOR as C,indexedPathSegments as w,indexedPathText as T,splitIndexedPath as E}from"./path-field.js";import{descriptionOffsetGroups as te,highlightFragment as ne,indexedFragmentText as D,nameOffsets as O,splitAnchor as k}from"./fragment-field.js";import{createPostingsTermLookup as A,wordOffsets as re}from"./term-lookup.js";import{optionalTokens as ie}from"../stopwords.js";import{maxEditsForToken as ae,pickCorrection as oe}from"./typo-correction.js";import"../store.js";import{and as j,asc as M,between as N,desc as P,eq as F,exists as se,gte as I,inArray as L,lt as ce,lte as le,ne as R,notExists as z,notInArray as B,or as V,sql as H}from"drizzle-orm";import{alias as U,unionAll as W}from"drizzle-orm/sqlite-core";const ue=/* @__PURE__ */ new Set([e]),G=[{name:`title`,weight:2},{name:`text`,weight:1},{name:`path`,weight:1},{name:`httpPath`,weight:1}],de={name:`parameters`,weight:.5},fe={name:`parameterNames`,weight:1},K=Object.fromEntries(G.map(e=>[e.name,e.weight])),pe=/* @__PURE__ */ new Set([`get`,`put`,`post`,`delete`,`options`,`head`,`patch`,`trace`,`query`]),q=/[_.:']/g;function me(e,t){if(!e)return g(``);let n=t?.toLowerCase(),r=n&&pe.has(n)?`${C}${n}`:``,i=g(`${e}${r}`),a=g(`${e.replace(q,` `)}${r}`),o=/* @__PURE__ */ new Map;for(let e of[...i.tokens,...a.tokens]){let t=o.get(e.value)??/* @__PURE__ */ new Set;for(let n of e.offsets)t.add(n);o.set(e.value,t)}return{tokens:[...o].map(([e,t])=>({documentId:0,value:e,offsets:[...t].sort((e,t)=>e-t)})),length:a.length}}function he(e,t,n,r){let i=g(t.title),a=g(t.text),o=g(T(t.path,t.title)),s=me(t.httpPath,t.httpMethod),c=t.path||t.badges||t.product||t.version||t.isAdditionalOperation?{path:t.path,badges:t.badges,product:t.product,version:t.version,isAdditionalOperation:t.isAdditionalOperation}:null;return{fields:{title:i,text:a,path:o,httpPath:s},facets:t.facets??{},row:{entityKey:e,docKey:t.docKey,routeSlug:t.routeSlug,locale:t.locale??``,anchor:t.anchor??null,title:t.title,text:t.text,titleTokens:i.length,textTokens:a.length,pathTokens:o.length,httpPathTokens:s.length,sourceHash:n,pluginVersion:r,groupKey:t.groupKey||null,httpMethod:t.httpMethod??null,httpPath:t.httpPath??null,deprecated:+!!t.deprecated,extra:c}}}function ge(e){let t=new Map(e.docs.map(e=>[e.docKey,e.locale??``])),n=(e.uses??[]).filter(e=>t.has(e.docKey)),r=/* @__PURE__ */ new Map;for(let e of n)r.has(e.fragmentKey)||r.set(e.fragmentKey,t.get(e.docKey)??``);let i=[],a=/* @__PURE__ */ new Set;for(let t of e.fragments??[]){let e=r.get(t.fragmentKey);e===void 0||a.has(t.fragmentKey)||(a.add(t.fragmentKey),i.push({fragment:t,locale:e,tokens:g(D(t))}))}let o=/* @__PURE__ */ new Map;for(let e of n){if(!a.has(e.fragmentKey))continue;let t=JSON.stringify([e.docKey,e.fragmentKey]);o.has(t)||o.set(t,e)}let s=/* @__PURE__ */ new Map;for(let e of o.values()){let t=e.path??[],{prefix:n,tail:r}=k(e.anchor),i=JSON.stringify([e.docKey,e.place,t,n]),a=s.get(i);a||(a={docKey:e.docKey,place:e.place,path:t,anchorPrefix:n,uses:[]},s.set(i,a)),a.uses.push({fragmentKey:e.fragmentKey,anchorTail:r})}return{entityKey:e.entityKey,docs:e.docs.map(t=>he(e.entityKey,t,e.sourceHash,e.pluginVersion)),fragments:i,parents:[...s.values()]}}function _e(e){let t={fragmentKey:e.fragmentKey,name:e.name,description:e.description};return e.example&&(t.example=e.example),e.enumValues&&e.enumValues.length>0&&(t.enum=e.enumValues),t}const J=(e,t)=>JSON.stringify([e,t]),ve=(e,t)=>JSON.stringify([e,t]),ye=[8,16],be=e=>ye[e.length-1]??50;async function xe(e,t){let n=e.select({id:i.id}).from(i).where(L(i.entityKey,[...t])),r=e.select({id:l.id}).from(l).where(L(l.entityKey,[...t])),d=[...await x(e,n.getSQL()),...await S(e,r.getSQL())];return await e.delete(u).where(L(u.docId,n)),await e.delete(a).where(L(a.docId,n)),await e.delete(s).where(L(s.fragmentId,r)),await e.delete(o).where(L(o.docId,n)),await e.delete(c).where(L(c.fragmentId,r)),await e.delete(l).where(L(l.entityKey,[...t])),d}function Se(e,t){if(e.length<=t)return e;let n=e.lastIndexOf(` `,t);return`${e.slice(0,n>0?n:t)}…`}function Y(e){let t=[];return e.forEach(([e,...n],r)=>{for(let i of n)t.push({start:i,end:i+(e??0),word:r})}),t.sort((e,t)=>e.start-t.start||t.end-e.end)}function X(e,t,n,r){let i=``,a=n;for(let{start:n,end:o}of t)n<a||o>r||(i+=`${e.slice(a,n)}<mark>${e.slice(n,o)}</mark>`,a=o);return i+e.slice(a,r)}function Z(e,t){if(t?.length)return X(e,Y(t),0,e.length)}function Ce(e,t,n,r){if(e===void 0||e.length<2)return;let i=w(e,t),a=i.length<e.length,o=Z(i.join(C),n),s=a?r:void 0;if(o===void 0&&s===void 0)return;let c=o===void 0?[...i]:E(o);return a?[...c,s??t]:c}function we(e,t,n=200){if(!t?.length)return;let r=Y(t);if(r.length===0||e.length<=n)return X(e,r,0,e.length);let i={first:0,last:0,words:0,matches:0};for(let e=0;e<r.length;e++){let t=r[e].start+n,a=/* @__PURE__ */ new Set,o=e;for(let n=e;n<r.length&&r[n].end<=t;n++)a.add(r[n].word),o=n;let s=o-e+1;(a.size>i.words||a.size===i.words&&s>i.matches)&&(i={first:e,last:o,words:a.size,matches:s})}let a=r[i.first].start,o=r[i.last].end,s=Math.max(0,Math.min(a-Math.floor((n-(o-a))/2),e.length-n)),c=Math.min(e.length,s+n);if(s>0){let t=e.lastIndexOf(` `,s);s=t===-1?0:Math.min(t+1,a)}if(c<e.length){let t=e.indexOf(` `,c);c=t===-1?e.length:Math.max(t,o)}let l=X(e,r,s,c);return`${s>0?`…`:``}${l}${c<e.length?`…`:``}`}async function Te(e,t,n){let[r]=await e.select({max:H`max(${n})`}).from(t);return Number(r?.max??0)}function Ee(e,t){if(t.length===0)return[...e];let n=new Set(t),r=e.filter(e=>n.has(e.id)),i=new Set(r.map(e=>e.id)),a=t.filter(e=>!i.has(e)).sort((e,t)=>e-t).map(e=>({id:e,rank:0,fields:[]})),o=e[0]?.rank??0,s=[...r,...a];return[...s.map((e,t)=>Object.assign(e,{rank:o+s.length-t})),...e.filter(e=>!n.has(e.id))]}function De(g){let x=p(void 0);async function S(e,t){let n=t.map(e=>e.entityKey),r=[];for(let t of f(n,x)){for(let n of await xe(e,t))r.push(n);await e.delete(i).where(L(i.entityKey,t))}let p=t.flatMap(e=>e.docs);if(p.length===0){await b(e,r);return}for(let t of f(p,x))await e.insert(i).values(t.map(e=>e.row));let m=/* @__PURE__ */ new Map;for(let t of f(n,x)){let n=await e.select({id:i.id,entityKey:i.entityKey,docKey:i.docKey}).from(i).where(L(i.entityKey,t));for(let e of n)m.set(J(e.entityKey,e.docKey),e.id)}let h=/* @__PURE__ */ new Map,g=(e,t)=>JSON.stringify([e,t]),_=await Te(e,l,l.id)+1,v=[];for(let e of t)for(let{fragment:t,locale:n}of e.fragments){let r=_++;h.set(g(e.entityKey,t.fragmentKey),r),v.push({id:r,entityKey:e.entityKey,fragmentKey:t.fragmentKey,locale:n,name:t.name,description:t.description??``,example:t.example??null,enumValues:t.enum??null})}let y=await Te(e,o,o.id)+1,S=[],ee=[];for(let e of t)for(let t of e.parents){let n=m.get(J(e.entityKey,t.docKey));if(n===void 0)continue;let r=y++;S.push({id:r,docId:n,place:t.place,path:t.path,anchorPrefix:t.anchorPrefix});for(let i of t.uses){let t=h.get(g(e.entityKey,i.fragmentKey));t!==void 0&&ee.push({fragmentId:t,docId:n,parentId:r,anchorTail:i.anchorTail})}}for(let t of f(v,x))await e.insert(l).values(t);for(let t of f(S,x))await e.insert(o).values(t);for(let t of f(ee,x))await e.insert(c).values(t);let C=/* @__PURE__ */ new Map,w=e=>{let t=C.get(e);return t||(t=/* @__PURE__ */ new Set,C.set(e,t)),t};for(let e of p){let t=w(e.row.locale??``);for(let n of G)for(let r of e.fields[n.name].tokens)t.add(r.value)}for(let e of t)for(let{locale:t,tokens:n}of e.fragments){let e=w(t);for(let t of n.tokens)e.add(t.value)}let T=/* @__PURE__ */ new Map;for(let[t,n]of C)for(let r of f([...n],x)){await e.insert(d).values(r.map(e=>({term:e,locale:t}))).onConflictDoNothing();let n=await e.select({id:d.id,term:d.term}).from(d).where(j(F(d.locale,t),L(d.term,r)));for(let e of n)T.set(ve(t,e.term),e.id)}let E=[];for(let e of p){let t=m.get(J(e.row.entityKey,e.row.docKey));if(t!==void 0)for(let n of G)for(let r of e.fields[n.name].tokens){let i=T.get(ve(e.row.locale??``,r.value));i!==void 0&&E.push({termId:i,field:n.name,docId:t,offsets:JSON.stringify(r.offsets)})}}for(let t of f(E,x))await e.insert(u).values(t);let te=[];for(let e of t)for(let{fragment:t,locale:n,tokens:r}of e.fragments){let i=h.get(g(e.entityKey,t.fragmentKey));if(i!==void 0)for(let e of r.tokens){let t=T.get(ve(n,e.value));t!==void 0&&te.push({termId:t,fragmentId:i,offsets:JSON.stringify(e.offsets)})}}for(let t of f(te,x))await e.insert(s).values(t);let ne=[];for(let e of p){let t=m.get(J(e.row.entityKey,e.row.docKey));if(t!==void 0)for(let[n,r]of Object.entries(e.facets))for(let e of r)ne.push({docId:t,field:n,value:e})}for(let t of f(ne,x))await e.insert(a).values(t);await b(e,[...r,...T.values()])}let C=e=>e===void 0?void 0:L(d.locale,[...e]);function w(e,t,n=50){return g.db.select({id:d.id,term:d.term}).from(d).where(j(e,C(t))).orderBy(P(d.docCount),M(d.term)).limit(n)}let T=(e,t)=>w(j(I(d.term,e),le(d.term,`${e}\uffff`)),t,be(e));async function E(e,t){let n=ae(e),r=e.codePointAt(0);if(n===0||r===void 0||r>=1114111)return[];let i=[...e].length,a=await g.db.select({id:d.id,term:d.term,docCount:d.docCount}).from(d).where(j(C(t),I(d.term,String.fromCodePoint(r)),ce(d.term,String.fromCodePoint(r+1)),N(H`length(${d.term})`,i-n,i+n))).orderBy(P(d.docCount),M(d.term)).limit(2e3),o=/* @__PURE__ */ new Map;for(let{id:e,term:t,docCount:n}of a){let r=o.get(t);r?(r.docCount+=n,r.ids.push(e)):o.set(t,{term:t,docCount:n,ids:[e]})}let s=oe(e,[...o.values()]);return s===null?[]:(o.get(s)?.ids??[]).map(e=>({id:e,term:s}))}async function D(e,t,n){let r=e.length-1,i=(e,n)=>t.has(e)&&n!==r,a=(e,t)=>t===r||t>r-3&&e.length>=3,[o,s]=await Promise.all([g.db.select({id:d.id,term:d.term}).from(d).where(j(L(d.term,e),C(n))),Promise.all(e.map(async(e,t)=>!i(e,t)&&a(e,t)?T(e,n):[]))]);return Promise.all(e.map(async(e,t)=>{let c=o.filter(t=>t.term===e);if(i(e,t))return k(e,c,!0);let l=[...c,...s[t]??[]];if(l.length>0)return k(e,l);let u=await E(e,n),f=u[0]?.term;if(f!==void 0){let e=a(f,t)?await T(f,n):[];return k(f,[...u,...e])}let p=t===r&&e.length>=3?await w(H`instr(${d.term}, ${e}) > 0`,n):[];return k(e,p)}))}let k=(e,t,n=!1)=>({word:e,ids:[...new Set(t.map(e=>e.id))],terms:new Set(t.map(e=>e.term)),optional:n});function pe(e){let t=/* @__PURE__ */ new Set,n=[];for(let r of[...e].reverse())t.has(r.word)||(t.add(r.word),n.push(r));return n.reverse()}let q=()=>({hits:[],facetCounts:{}});function me(e,t){let n=Math.max(0,Math.trunc(e.offset??0));return{offset:n,end:Math.min(n+t,500)}}function he(e){let t=e?.trim().toLowerCase();if(t)return e=>e.toLowerCase().startsWith(t)}let ye=e=>(e.filter??[]).filter(e=>e.values.length>0),Y=U(a,`carried`),X=(e,t)=>t.length===0?H`0`:se(g.db.select({one:H`1`}).from(Y).where(j(F(Y.docId,i.id),F(Y.field,e),L(Y.value,[...t]))));function De(e){if(e.locales===void 0)return;let t=L(i.locale,[...e.locales]),n=e.canonicalFallback;if(n===void 0)return t;let a=z(g.db.select({one:H`1`}).from(r).where(j(F(r.locale,n.locale),F(r.isFallback,!1),F(r.canonicalSlug,i.routeSlug)))),o=n.translatedPrefixes.length===0?void 0:V(se(g.db.select({one:H`1`}).from(r).where(F(r.slug,i.routeSlug))),j(...n.translatedPrefixes.map(e=>H`substr(${i.routeSlug}, 1, ${e.length+1}) <> ${`${e}/`}`)));return j(t,V(R(i.locale,``),j(a,o)))}function Q(e,r){let a=[De(e)],{candidates:o}=e;if(o!==void 0&&(r===void 0||o.lifted!==r)&&a.push(L(i.id,o.ids)),e.hidden!==void 0&&a.push(B(i.id,e.hidden)),e.teams!==void 0&&a.push(X(t,[...new Set(e.teams.map(e=>e.toLowerCase()))])),e.versions!==void 0){let t=z(g.db.select({one:H`1`}).from(Y).where(j(F(Y.docId,i.id),F(Y.field,n)))),r=[...new Set(e.versions)];a.push(r.length===0?t:V(t,X(n,r)))}for(let t of e.selections)t.field!==r&&a.push(X(t.field,t.values));return a}let $=U(i,`section`);async function Oe(e,t){let n=H`instr(${i.docKey}, ${m})`,r=g.db.select({id:$.id}).from($).where(j(F($.entityKey,i.entityKey),F($.docKey,H`substr(${i.docKey}, 1, ${n} - 1)`))),a=await g.db.select({id:i.id,titleTokens:i.titleTokens,textTokens:i.textTokens,pathTokens:i.pathTokens,httpPathTokens:i.httpPathTokens,groupKey:i.groupKey,markedKey:H`case when ${n} > 0 then ${i.docKey} end`.as(`marked_key`),sectionId:H`case when ${n} > 0 then ${r} end`.as(`section_id`),...t&&{pinned:H`${L(i.id,t)}`.as(`pinned`)}}).from(i).where(j(...Q(e)));return new Map(a.map(({id:e,pinned:t,markedKey:n,sectionId:r,...i})=>[e,{...i,sectionId:n!==null&&r!==null&&h(n)?Number(r):e,pinned:Number(t)===1}]))}async function ke(e,t,n){return g.db.select({field:a.field,value:a.value,count:H`count(*)`}).from(i).crossJoin(a).where(j(F(a.docId,i.id),L(a.field,[...t]),...Q(e,n))).groupBy(a.field,a.value)}let Ae=(e,t)=>g.db.select({docId:a.docId}).from(a).where(j(F(a.field,e),L(a.value,[...t])));function je(e,r){let o=a.docId,s=[];if(e.locales!==void 0&&s.push(L(o,g.db.select({id:i.id}).from(i).where(De(e)))),e.teams!==void 0){let n=[...new Set(e.teams.map(e=>e.toLowerCase()))];s.push(n.length===0?H`0`:L(o,Ae(t,n)))}if(e.versions!==void 0){let t=B(o,g.db.select({docId:a.docId}).from(a).where(F(a.field,n))),r=[...new Set(e.versions)];s.push(r.length===0?t:V(t,L(o,Ae(n,r))))}for(let t of e.selections)t.field!==r&&s.push(L(o,Ae(t.field,t.values)));return s}async function Me(e,t,n){return g.db.select({field:a.field,value:a.value,count:H`count(*)`}).from(a).where(j(L(a.field,[...t]),...je(e,n))).groupBy(a.field,a.value)}async function Ne(e,t,n){let r=[...new Set(t)],i=r.filter(t=>e.candidates!==void 0&&e.candidates.lifted!==t),a=r.filter(e=>!i.includes(e)),o=new Set(e.selections.map(e=>e.field)),s=e=>{let t=e.filter(e=>!o.has(e));return[...t.length>0?[{fields:t,lift:void 0}]:[],...e.filter(e=>o.has(e)).map(e=>({fields:[e],lift:e}))]},c=(await Promise.all([...s(i).map(t=>ke(e,t.fields,t.lift)),...s(a).map(t=>Me(e,t.fields,t.lift))])).flat(),l=he(n),u={};for(let e of r)u[e]=c.filter(t=>t.field===e&&(l===void 0||l(t.value))).map(e=>({value:e.value,count:Number(e.count)})).sort((e,t)=>t.count-e.count||(e.value<t.value?-1:1)).slice(0,ue.has(e)?void 0:25);return u}async function Pe(e){let t=/* @__PURE__ */ new Map;for(let n of f(e,x)){let e=await g.db.select().from(i).where(L(i.id,n));for(let n of e)t.set(n.id,n)}return t}async function Fe(e,t){let n=[];for(let r of f(e,x)){let e=await g.db.select({field:u.field,term:d.term,docId:u.docId,offsets:u.offsets}).from(u).innerJoin(d,F(d.id,u.termId)).where(j(L(u.termId,r),t===void 0?void 0:L(u.docId,t)));for(let t of e)n.push(t)}return n}function Ie(e,t){let n=g.db.select({docId:u.docId,termId:u.termId}).from(u).where(j(L(u.termId,e),R(u.field,`path`))),r=g.db.select({docId:c.docId,termId:s.termId}).from(s).innerJoin(c,F(c.fragmentId,s.fragmentId)).where(L(s.termId,e)),i=W(n,r).as(`occurrences`),a=g.db.select({docId:i.docId}).from(i);if(t===void 0)return a;let o=H.join(t.map(e=>H`max(case when ${L(i.termId,[...e])} then 1 else 0 end)`),H` + `);return a.groupBy(i.docId).having(H`${o} = ${t.length}`)}async function Le(e){let t=(e,t)=>{let n=g.db.select({docId:u.docId}).from(u).where(j(L(u.termId,[...t]),R(u.field,`path`))),r=g.db.select({docId:c.docId}).from(s).innerJoin(c,F(c.fragmentId,s.fragmentId)).where(L(s.termId,[...t])),i=W(n,r).as(`reached`);return g.db.select({word:H`${e}`.as(`word`),count:H`count(distinct ${i.docId})`.as(`count`)}).from(i)},n=e.flatMap((e,n)=>e.length===0?[]:[t(n,e)]),r=e.map(()=>0);if(n.length===0)return r;let i=n.length===1?await n[0]:await W(...n);for(let e of i)r[Number(e.word)]=Number(e.count);return r}async function Re(e,t){let n=[];for(let r of f(e,x)){let e=await g.db.select({term:d.term,fragmentId:s.fragmentId,offsets:s.offsets,docId:c.docId,fragmentName:l.name}).from(s).innerJoin(d,F(d.id,s.termId)).innerJoin(l,F(l.id,s.fragmentId)).innerJoin(c,F(c.fragmentId,s.fragmentId)).where(j(L(s.termId,r),t===void 0?void 0:L(H`+${c.docId}`,t)));for(let t of e)n.push(t)}return n}function ze(e){let t=/* @__PURE__ */ new Map,n=[],r=[];for(let i of e){let e=`${i.docId}\u0000${i.fragmentId}`,a=t.get(e);a===void 0&&t.set(e,a=t.size);let o=a*1e6,s=JSON.parse(i.offsets),c=O(i.fragmentName,s),[l,u]=c.length>0?[n,c]:[r,s];l.push({term:i.term,docId:i.docId,offsets:JSON.stringify(u.map(e=>o+e))})}return{names:n,rest:r}}function Be(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){let e=n.get(r.docId);e||n.set(r.docId,e=/* @__PURE__ */ new Map);let i=e.get(r.fragmentId);i||(i={fragmentId:r.fragmentId,words:/* @__PURE__ */ new Set,nameWords:/* @__PURE__ */ new Set,score:0,offsetGroups:[]},e.set(r.fragmentId,i));let a=JSON.parse(r.offsets),o=O(r.fragmentName,a).length>0;i.score+=a.length;for(let e of t)e.terms.has(r.term)&&(i.words.add(e),o&&i.nameWords.add(e),i.offsetGroups.push([e.word.length,...re(e.word,r.term,a)]))}let r=/* @__PURE__ */ new Map;for(let[e,t]of n){let n;for(let e of t.values())(n===void 0||(e.words.size-n.words.size||e.nameWords.size-n.nameWords.size||e.score-n.score)>0)&&(n=e);n&&r.set(e,{fragmentId:n.fragmentId,offsetGroups:n.offsetGroups})}return r}async function Ve(e){let t=/* @__PURE__ */ new Map;for(let n of f([...new Set(e)],x)){let e=await g.db.select().from(l).where(L(l.id,n));for(let n of e)t.set(n.id,_e(n))}return t}async function He(e){let t=/* @__PURE__ */ new Map;if(e.size===0)return t;let n=await g.db.select({docId:c.docId,fragmentId:c.fragmentId,anchorTail:c.anchorTail,place:o.place,path:o.path,anchorPrefix:o.anchorPrefix}).from(c).innerJoin(o,F(o.id,c.parentId)).where(j(L(c.docId,[...e.keys()]),L(c.fragmentId,[...new Set([...e.values()].map(e=>e.fragmentId))])));for(let r of n)e.get(r.docId)?.fragmentId===r.fragmentId&&t.set(r.docId,{place:r.place,path:r.path,anchor:r.anchorPrefix+r.anchorTail});return t}async function Ue(e){let[t]=await g.db.select({total:H`count(*)`,averageTitle:H`avg(${i.titleTokens})`,averageText:H`avg(${i.textTokens})`,averagePath:H`avg(nullif(${i.pathTokens}, 0))`,averageHttpPath:H`avg(nullif(${i.httpPathTokens}, 0))`}).from(i).where(e===void 0?void 0:L(i.locale,[...e]));return t}async function We(e){let t=/* @__PURE__ */ new Set;for(let n=0;n<e.length;n++){let r=Math.min(e.length,n+10);for(let i=n+1;i<=r;i++)t.add(e.slice(n,i).join(` `))}let n=[...t],r=await g.db.selectDistinct({field:a.field}).from(a).where(j(L(a.field,[y,v]),L(a.value,n))),i=e=>r.some(t=>t.field===e),o=i(`redocly_hide`)?Ae(v,n):void 0;if(!i(`redocly_pin`))return o?{hidden:o}:{};let s=g.db.select({docId:a.docId}).from(a).where(j(F(a.field,y),L(a.value,n)));return o?{pinned:s,hidden:o}:{pinned:s}}async function Ge(e){return(await g.db.select({id:i.id}).from(i).where(j(...Q(e))).limit(1)).length>0}async function Ke(t,n,r,i){let{locales:a}=r,o=pe(t),s=o.filter(e=>!e.optional).map(e=>e.ids).filter(e=>e.length>0),c=[...new Set(s.flat())];if(c.length===0&&n.pinned===void 0)return q();let l=o.filter(e=>e.optional).flatMap(e=>e.ids),u=[.../* @__PURE__ */ new Set([...c,...l])],d=o.map(e=>e.word),f=new Set(o.filter(e=>e.optional).map(e=>e.word)),{pinned:p}=n,m=e=>p===void 0?e:H`(select doc_id from ${e} union select doc_id from ${p})`,h=e=>({locales:a,canonicalFallback:r.canonicalFallback,candidates:{ids:e},hidden:n.hidden,teams:r.teams,versions:r.versions,selections:ye(r)}),g=Ie(c,s.length>0?s:void 0),_=Ie(c),v=e=>Ne(e,r.countFields??[],r.countValuePrefix),y=p!==void 0&&s.length>1?Ge(h(g)):void 0;if(r.countOnly){let[e,t]=await Promise.all([v(h(m(g))),y]),n=Object.values(e).every(e=>e.length===0);return c.length===0&&n?q():{hits:[],facetCounts:s.length>1&&!(t??!n)?await v(h(m(_))):e}}let b=Promise.all([Ue(a),Le(o.map(e=>e.ids))]),x=(e,t)=>{let n=m(e);return Promise.all([v(h(n)),Oe(h(n),p),Fe(u,t?n:void 0),Re(c,t?n:void 0)])},[S,C]=await Promise.all([x(g,!0),y]),[w,T,E,D]=S;!(C??T.size>0)&&s.length>1&&([w,T,E,D]=await x(_,l.length>0));let[O,k]=await b,re=[...T].filter(([,e])=>e.pinned).map(([e])=>e);if(re.length===0&&(T.size===0||E.length===0&&D.length===0))return c.length===0?q():{hits:[],facetCounts:w};let ie=new Map(o.map((e,t)=>[e.word,k[t]??0])),ae=new Set([...E,...D].map(e=>e.docId)),oe=me(r,i),j=(e,t)=>({totalDocuments:O?.total??0,averageDocumentLength:t??0,getDocumentLength:t=>T.get(t)?.[e]??0}),M=/* @__PURE__ */ new Map;for(let e of E){let t=M.get(e.field);t?t.push(e):M.set(e.field,[e])}let N=e=>M.get(e)??[],P=ze(D),F={totalDocuments:O?.total??0,averageDocumentLength:1,getDocumentLength:()=>1},se=new ee({limit:ae.size,fields:[{name:`title`,weight:K.title,lookup:A(N(`title`)),corpusStats:j(`titleTokens`,O?.averageTitle??null)},{name:`text`,weight:K.text,lookup:A(N(`text`)),corpusStats:j(`textTokens`,O?.averageText??null)},{name:`path`,weight:K.path,lookup:A(N(`path`)),corpusStats:j(`pathTokens`,O?.averagePath??null),countsTowardFrequency:!1},{name:`httpPath`,weight:K.httpPath,lookup:A(N(`httpPath`)),corpusStats:j(`httpPathTokens`,O?.averageHttpPath??null)},{name:fe.name,weight:fe.weight,lookup:A(P.names),corpusStats:F},{name:de.name,weight:de.weight,lookup:A(P.rest),corpusStats:F}]}),I=/* @__PURE__ */ new Set,L=/* @__PURE__ */ new Map,ce=Ee(se.search(d.join(` `),{optional:f,documentFrequencies:ie,terms:new Map(o.map(e=>[e.word,e.terms]))}),re).filter(e=>{let t=T.get(e.id);return t===void 0?!1:I.has(t.sectionId)?(t.groupKey!==null&&L.set(t.groupKey,(L.get(t.groupKey)??0)+1),!1):(I.add(t.sectionId),!0)}),le=w[e];le!==void 0&&L.size>0&&(w[e]=le.map(({value:e,count:t})=>({value:e,count:t-(L.get(e)??0)})).filter(({count:e})=>e>0));let R=r.perGroup,z=/* @__PURE__ */ new Map,B=R===void 0?ce.slice(oe.offset,oe.end):ce.filter(e=>{let t=T.get(e.id)?.groupKey??null,n=z.get(t)??0;return z.set(t,n+1),n<R}),V=new Set(B.map(e=>e.id)),U=Be(D.filter(e=>V.has(e.docId)),o),[W,ue,G]=await Promise.all([Pe([...V]),Ve([...U.values()].map(e=>e.fragmentId)),He(U)]);return{hits:B.flatMap(e=>{let t=W.get(e.id);if(!t)return[];let n=t=>e.fields.find(e=>e.name===t),r=e=>n(e)?.offsets,i={},a=Z(t.title,r(`title`)),o=we(t.text,r(`text`)),s=Ce(t.extra?.path,t.title,r(`path`),a);a!==void 0&&(i.title=a),o!==void 0&&(i.text=o),s!==void 0&&(i.path=s);let c=Z(t.httpPath??``,r(`httpPath`));c?.includes(`<mark>`)&&(i.httpPath=c);let l=U.get(e.id),u=l?ue.get(l.fragmentId):void 0,d=G.get(e.id),p={...t,rank:e.rank,highlight:i};if(l===void 0||u===void 0||d===void 0)return[p];let m=ne(u,d,l.offsetGroups),h=u.description??``;return m.description=we(h,te(u,l.offsetGroups))??Se(h,200),i.parameters=[m],[n(`title`)?.tokens.some(e=>!f.has(e))?p:{...p,parameterAnchor:d.anchor}]}),facetCounts:w}}async function qe(e,t){let n=ye(e),[r]=n,o={locales:e.locales,canonicalFallback:e.canonicalFallback,candidates:r&&{ids:g.db.select({docId:a.docId}).from(a).where(j(F(a.field,r.field),L(a.value,[...r.values]))),lifted:r.field},teams:e.teams,versions:e.versions,selections:n},s=await Ne(o,e.countFields??[],e.countValuePrefix),c=me(e,t);return e.countOnly||o.selections.length===0||c.end<=c.offset?{hits:[],facetCounts:s}:{hits:(await g.db.select().from(i).where(j(...Q(o))).orderBy(M(i.routeSlug),M(i.docKey)).limit(c.end-c.offset).offset(c.offset)).map(e=>Object.assign(e,{rank:0,highlight:{}})),facetCounts:s}}return{async replaceSourceDocuments(e,t){if(e.length===0)return;let n=e.map(ge);t?await S(t,n):await g.db.transaction(e=>S(e,n))},async removeSource(e){await g.db.transaction(async t=>{let n=await xe(t,[e]);await t.delete(i).where(F(i.entityKey,e)),await b(t,n)})},async query(e){let t=Math.min(Math.max(1,Math.trunc(e.limit)),500),n=_(e.q);if(n.length===0)return qe(e,t);let r=ie(n,e.stopwords),[i,a]=await Promise.all([D(n,r,e.locales),We(n)]);return Ke(i,a,e,t)},async readDocuments(e={}){let t=[e.routeSlug===void 0?void 0:F(i.routeSlug,e.routeSlug),e.entityKey===void 0?void 0:F(i.entityKey,e.entityKey)].filter(e=>e!==void 0);return g.db.select().from(i).where(t.length>0?j(...t):void 0).orderBy(M(i.entityKey),M(i.docKey))}}}export{De as createPostingsSearchStore,Z as highlightOffsets,Ce as highlightPath,we as highlightSnippet,Ee as pinFirst};
|
|
@@ -7,7 +7,7 @@ import type { SearchFilterInput } from '../../shared/types/search.js';
|
|
|
7
7
|
* facet rows. `facets` is the validated `field -> distinct values` map, reserved fields
|
|
8
8
|
* included (the route's teams among them), and becomes one `search_facets` row per value.
|
|
9
9
|
*/
|
|
10
|
-
export type SearchSourceDocument = Omit<SearchDocument, 'facets'> & {
|
|
10
|
+
export type SearchSourceDocument = Omit<SearchDocument, 'facets' | 'keywords'> & {
|
|
11
11
|
/** The locale of the document's route; `''` for canonical content. */
|
|
12
12
|
locale?: string;
|
|
13
13
|
/** The product whose pages include the document's route. */
|
|
@@ -57,6 +57,17 @@ export type SearchQuery = {
|
|
|
57
57
|
* absent. Each locale is its own partition: its words, completions and corrections.
|
|
58
58
|
*/
|
|
59
59
|
locales?: readonly string[];
|
|
60
|
+
/**
|
|
61
|
+
* For a search of `locale` that also covers the canonical (`''`) documents: a canonical
|
|
62
|
+
* document counts only when `locale` has no translation of its page, which the site then
|
|
63
|
+
* serves under the locale's prefix. A translated route's slug drops the canonical document
|
|
64
|
+
* of the same slug; a slug in `translatedPrefixes` (a translated route that serves its
|
|
65
|
+
* sub-paths, such as an API description) also drops those under it that have no route.
|
|
66
|
+
*/
|
|
67
|
+
canonicalFallback?: {
|
|
68
|
+
locale: string;
|
|
69
|
+
translatedPrefixes: readonly string[];
|
|
70
|
+
};
|
|
60
71
|
/**
|
|
61
72
|
* Words dropped from the query before it is resolved — not required, not loaded, not
|
|
62
73
|
* highlighted — unless the query is made of them alone. None when absent.
|
|
@@ -92,6 +103,8 @@ export type SearchHighlight = {
|
|
|
92
103
|
title?: string;
|
|
93
104
|
text?: string;
|
|
94
105
|
path?: string[];
|
|
106
|
+
/** The stored HTTP path, present when it matched. */
|
|
107
|
+
httpPath?: string;
|
|
95
108
|
/** The one indexed field of the document that matched best (the theme's `ParameterHighlight`). */
|
|
96
109
|
parameters?: SearchParameterHighlight[];
|
|
97
110
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContentLayerContext as e}from"../context.js";
|
|
1
|
+
import{createContentLayerContext as e}from"../context.js";export{e as createContentLayerContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{loadSiteConfig as e,resolveSiteConfig as t}from"../database/site-config.js";import{isRemoteDatabaseUrl as n}from"../database/utils/is-remote-database-url.js";import{openContentLayerDatabase as r,resolveLocalDatabasePath as i}from"../database/connection.js";import{garbageCollectOrphanBlobs as a,getBlob as o}from"../database/blobs.js";import{createEntityStore as s,loadCurrentEntityMetadata as c}from"../database/entity-store.js";import{listAssetSourcePaths as l}from"../database/assets.js";import{loadEntityRecordByKey as u}from"../database/entities.js";import{listProblemsForEntity as d}from"../database/problems.js";import{listRoutePagesByFile as f}from"../database/files.js";import{listStaticFileRecords as p}from"../database/static-files.js";import{createKvStore as m}from"../database/kv.js";export{s as createEntityStore,m as createKvStore,a as garbageCollectOrphanBlobs,o as getBlob,n as isRemoteDatabaseUrl,l as listAssetSourcePaths,d as listProblemsForEntity,f as listRoutePagesByFile,p as listStaticFileRecords,c as loadCurrentEntityMetadata,u as loadEntityRecordByKey,e as loadSiteConfig,r as openContentLayerDatabase,i as resolveLocalDatabasePath,t as resolveSiteConfig};
|