@redocly/framework 1.0.0-next.4 → 1.0.0-next.6
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/routes/dev-problems-route.js +1 -1
- package/dist/bundler/dev/routes/source-sync-route.js +1 -1
- package/dist/bundler/dev/run.js +1 -1
- package/dist/bundler/dev/runtime-app.js +1 -1
- package/dist/bundler/dev/vite-chunk-url.js +1 -1
- package/dist/bundler/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/commands/build.js +1 -1
- package/dist/cli/commands/dev.js +1 -1
- package/dist/cli/commands/ingest.js +1 -1
- package/dist/cli/commands/translate.js +2 -2
- package/dist/cli/dev-console/index.js +1 -1
- package/dist/cli/log-output/index.js +1 -1
- 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 -1
- package/dist/client/ThemeGlobalStyle.js +1 -0
- package/dist/client/UnversionedVersionButton.js +1 -1
- package/dist/client/ai-search/use-ai-search.js +1 -1
- package/dist/client/analytics-page-view.js +1 -1
- package/dist/client/app.js +3 -3
- package/dist/client/client-entry.js +1 -1
- package/dist/client/contexts.js +1 -1
- package/dist/client/dev-problems/ProblemsBar.js +6 -6
- package/dist/client/dev-problems/ProblemsModal.js +15 -15
- package/dist/client/feedback.js +1 -1
- package/dist/client/l10n/use-l10n-config.js +1 -1
- package/dist/client/l10n/use-l10n-href.js +1 -1
- package/dist/client/l10n/use-translate.js +1 -1
- package/dist/client/products.js +1 -1
- package/dist/client/review/ReviewBar.js +61 -61
- package/dist/client/review/use-review.js +1 -1
- package/dist/client/sidebar/PoweredByRedocly.js +2 -2
- package/dist/client/sidebar/SidebarDataProvider.js +1 -1
- package/dist/client/sidebar/drilldown.js +1 -1
- package/dist/client/ssr.js +1 -1
- package/dist/client/telemetry/config.js +1 -1
- package/dist/client/telemetry/report-preload-failure.js +1 -0
- package/dist/client/templates/dev-login.js +4 -4
- package/dist/client/templates/unauthorized.js +5 -5
- package/dist/client/theme-global-css.js +1 -0
- package/dist/client/use-banner.js +1 -1
- package/dist/client/use-entity-revisions.js +1 -1
- package/dist/client/use-page-versions.js +1 -1
- package/dist/client/use-search.js +1 -1
- package/dist/client/webmcp/tools/shared.js +1 -1
- package/dist/client/webmcp/tools/site-tools.js +1 -1
- package/dist/client/webmcp/use-webmcp-tools.js +1 -1
- package/dist/content-layer/allowed-packages.js +1 -1
- package/dist/content-layer/config-schema.d.ts +5 -1
- package/dist/content-layer/config-schema.js +1 -1
- package/dist/content-layer/config.d.ts +6 -2
- package/dist/content-layer/config.js +1 -1
- package/dist/content-layer/database/adapters/node-sqlite-client.js +1 -1
- package/dist/content-layer/database/connection.js +1 -1
- package/dist/content-layer/database/entity-store.d.ts +9 -1
- package/dist/content-layer/database/entity-store.js +1 -1
- package/dist/content-layer/database/invalidation.js +26 -26
- package/dist/content-layer/database/origins.d.ts +2 -4
- package/dist/content-layer/database/origins.js +1 -1
- package/dist/content-layer/ingest/extract-all-phase.js +1 -1
- package/dist/content-layer/ingest/finalize-phase.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/normalize-artifacts.js +1 -1
- package/dist/content-layer/ingest/rbac-teams.js +1 -1
- package/dist/content-layer/ingest/run.js +1 -1
- package/dist/content-layer/ingest/scan.d.ts +1 -1
- package/dist/content-layer/ingest/scan.js +1 -1
- package/dist/content-layer/ingest/search-sync.js +1 -1
- package/dist/content-layer/ingest/slugger/resolve-final-slugs.js +1 -1
- package/dist/content-layer/ingest/sync.js +1 -1
- package/dist/content-layer/link-checker/load-view.js +1 -1
- package/dist/content-layer/link-checker/validate.js +1 -1
- package/dist/content-layer/loaders/context.js +1 -1
- package/dist/content-layer/markdown/client/OpenapiTagComponents.js +2 -2
- package/dist/content-layer/markdown/client/dynamic-components.js +1 -1
- package/dist/content-layer/markdown/client/markdoc-components.js +2 -2
- package/dist/content-layer/markdown/client/markdown-text.js +1 -1
- package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
- package/dist/content-layer/markdown/constants/markdown-text-tag-set.js +1 -1
- package/dist/content-layer/markdown/constants/tag-sets.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/audience-tag.d.ts +1 -1
- package/dist/content-layer/markdown/resolve/audience-tag.js +1 -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.js +1 -1
- package/dist/content-layer/markdown/resolve/references.js +1 -1
- package/dist/content-layer/markdown/search/to-markdown.js +2 -2
- package/dist/content-layer/markdown/search/to-sections.js +1 -1
- 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 +4 -1
- package/dist/content-layer/markdown/tags/html.js +1 -1
- package/dist/content-layer/markdown/tags/partial.d.ts +7 -2
- package/dist/content-layer/markdown/tags/partial.js +1 -1
- package/dist/content-layer/markdown/tags/variant.js +1 -1
- package/dist/content-layer/markdown/types/service.d.ts +4 -0
- 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/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/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/template.js +4 -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 +2 -2
- 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/markdown-docs.js +13 -13
- 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.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/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.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/use-catalog-classic.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/index.js +1 -1
- package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/server/shared.d.ts +1 -1
- package/dist/content-layer/plugins/internal/mcp/constants.d.ts +6 -0
- package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/ignored-routes.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/capabilities.js +3 -3
- 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/execution-budget.js +1 -0
- 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/codemode/read-result.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/codemode/return-last-expression.js +6 -0
- package/dist/content-layer/plugins/internal/mcp/server/codemode/returns-from-top-level.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/codemode/sandbox.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/tool-declarations.js +4 -0
- package/dist/content-layer/plugins/internal/mcp/server/codemode/tool-list.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/unknown-tool-hint.js +3 -0
- 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/__tests__/secret-store-fixture.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/gateway/api-call-operations.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +7 -7
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-bridge.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/subject.js +1 -1
- 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/server-info.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-catalog.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-constants.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-document.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/graphql.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-constants.js +1 -0
- 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 +3 -3
- package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -0
- package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/submit-feedback.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/whoami.js +1 -1
- package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/client/Grid.js +11 -11
- package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardViews.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardWidgets.js +7 -7
- package/dist/content-layer/plugins/internal/scorecard-classic/client/template.js +2 -2
- package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/bundle.d.ts +1 -1
- package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/index.d.ts +1 -1
- package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
- 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/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/plugin.d.ts +8 -0
- package/dist/content-layer/plugins/types/search.d.ts +1 -1
- 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/version-path.js +1 -1
- package/dist/content-layer/revisions/config.js +1 -1
- package/dist/content-layer/server/context.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/redirect.d.ts +11 -6
- package/dist/content-layer/versions/redirect.js +1 -1
- package/dist/content-layer/versions/resolve.js +1 -1
- package/dist/plugin-api.d.ts +3 -0
- package/dist/plugin-api.js +1 -1
- package/dist/server/__tests__/rbac-fixture.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/gate.js +1 -1
- package/dist/server/auth/middleware.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 +12 -12
- package/dist/server/cors-proxy/handler.js +1 -1
- package/dist/server/feedback/route.js +1 -1
- package/dist/server/lambda-entry.js +1 -1
- package/dist/server/manifest-assets.js +4 -4
- package/dist/server/metrics/request-metrics.js +1 -1
- package/dist/server/node-entry.js +1 -1
- package/dist/server/plugin-context.js +1 -1
- package/dist/server/plugin-routes.js +1 -1
- package/dist/server/rbac/content-asset-access.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/route.js +1 -1
- package/dist/server/seo-tags.js +2 -2
- package/dist/server/static-files/serve.js +1 -1
- package/dist/server/subprocess/runner.js +1 -1
- package/dist/server/telemetry/route.js +1 -1
- package/dist/server/template-ids.js +1 -1
- package/dist/shared/constants/api-spec-kinds.d.ts +6 -0
- package/dist/shared/constants/api-spec-kinds.js +1 -0
- 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/{server → shared}/constants/system-routes.d.ts +1 -1
- package/dist/shared/constants/system-routes.js +1 -0
- package/dist/shared/plan-gates.d.ts +6 -1
- package/dist/shared/plan-gates.js +1 -1
- package/dist/shared/products.js +1 -1
- package/dist/{server → shared}/project-env.d.ts +1 -1
- package/dist/{server → shared}/rbac/api-docs.d.ts +1 -1
- package/dist/{server → shared}/rbac/engine.d.ts +1 -1
- package/dist/shared/rbac/engine.js +0 -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/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/types/config.d.ts +2 -0
- package/dist/shared/utils/l10n.js +1 -1
- package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
- package/package.json +8 -10
- package/dist/content-layer/server/config.js +0 -1
- package/dist/server/constants/system-routes.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/{server → shared}/project-env.js +0 -0
- /package/dist/{server → shared}/rbac/api-docs.js +0 -0
- /package/dist/{server → shared}/rbac/entity-scope.js +0 -0
- /package/dist/{server → shared}/rbac/filter.d.ts +0 -0
- /package/dist/{server → shared}/rbac/route-scope.d.ts +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{SEARCH_GROUP_FACET_FIELD as e,readSearchAppData as t}from"../shared/search/facets.js";import{
|
|
1
|
+
import{SEARCH_GROUP_FACET_FIELD as e,readSearchAppData as t}from"../shared/search/facets.js";import{SEARCH_FACETS_ROUTE_PATH as n,SEARCH_ROUTE_PATH as r}from"../shared/constants/search.js";import{APP_DATA_LOADER_KEY as i}from"../shared/constants/app-data.js";import{withPathPrefix as a}from"../shared/path-prefix.js";import{readAppData as o}from"../shared/utils/app-data.js";import{LoaderDataContext as s,PageContext as c}from"./contexts.js";import{useL10nConfig as l}from"./l10n/use-l10n-config.js";import{telemetry as u}from"./telemetry/telemetry.js";import{selectActiveVersion as d}from"./use-page-versions.js";import{SEARCH_DEBOUNCE_TIME_MS as f}from"@redocly/theme/core/constants";import{useCallback as p,useContext as m,useEffect as h,useMemo as g,useRef as _,useState as v}from"react";import{getBaseDataAttributes as y}from"@redocly/theme/core/utils";import{SearchSessionContext as b}from"@redocly/theme/core/contexts";async function x(e,t,n){let r=await fetch(a(e),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t),signal:n});if(!r.ok)throw Error(r.statusText||`Search request failed (${r.status})`);return await r.json()}function S(e,t){return x(r,e,t)}function C(e){return Object.fromEntries(e.map(e=>[e.field,e.values]))}function w(e,t){return x(n,e,t)}function T(e){return o(e).theme?.aiAssistant?.hide===!1}function E(){let e=m(s),t=m(c);return{askAi:T(e)&&t?.aiAvailable===!0}}function D(e){return e.filter(e=>e.values.length>0).map(({field:e,values:t})=>({field:e,values:[...t]}))}function O(){let e=m(c),{currentLocale:t,defaultLocale:n}=l(),r=t===n?void 0:t,{name:i,group:a}=d(e);return g(()=>({locale:r,version:a!==void 0&&i!==void 0?{group:a,version:i}:void 0}),[r,a,i])}const k=(e,t)=>e.map(e=>({...e,isCounterVisible:t}));function A(n,r){let a=r===!1,{askAi:o}=E(),c=m(s),l=m(b)?.searchSessionId,d=O(),x=g(()=>t(c[i]),[c]),[T,A]=v(``),[j,M]=v([]),[ee,N]=v({}),[P,F]=v({}),[I,L]=v({}),[R,z]=v({}),[B,V]=v(!1),[H,U]=v(null),[W,G]=v(!1),K=_(null),q=_(null),J=_(!1),Y=g(()=>D(j),[j]),X=Y.length>0,Z=p(()=>{q.current=null,N({}),F({}),z({})},[]),Q=p((e,t,n)=>{K.current?.abort();let r=new AbortController;return K.current=r,V(!0),U(null),S(e,r.signal).then(e=>{r.signal.aborted||t(e)}).catch(e=>{r.signal.aborted||(U(e instanceof Error?e.message:`Search request failed`),n())}).finally(()=>{r.signal.aborted||V(!1)})},[]),$=p(async e=>{let t=e.trim();if(t===``&&!X){K.current?.abort(),J.current=!1,Z(),G(!1),U(null),V(!1);return}let r={query:t,...d,filter:Y,product:n};J.current=!0,await Q(r,i=>{J.current=!1,q.current=r,N(i.documents),F(i.facets??{}),z(i.groupCounts??{}),G(!0),t.length>1&&u.sendSearchQueryMessage([{...y(`searchQuery`,`search`),query:e,resultCount:Object.values(i.documents).reduce((e,t)=>e+t.length,0).toString(),...l?{searchSessionId:l}:{},...n?{product:n}:{}}])},()=>{J.current=!1,Z()})},[d,Y,X,Q,Z,n,l]),te=p(e=>{let t=typeof e==`function`?e(void 0):e,n=q.current;t&&n&&!J.current&&Q({...n,loadMore:t},e=>{let n=e.documents[t.groupKey]??[];N(e=>({...e,[t.groupKey]:[...e[t.groupKey]??[],...n]})),z(t=>({...t,...e.groupCounts}))},()=>{})},[Q]);h(()=>{if(r)return;(T.trim()!==``||X)&&V(!0);let e=setTimeout(()=>{$(T)},f);return()=>clearTimeout(e)},[T,r,X,$]),h(()=>{if(!x.advanced||!a)return;let e=new AbortController;return w({...d,product:n},e.signal).then(e=>L(C(e))).catch(()=>{e.signal.aborted||L({})}),()=>e.abort()},[x.advanced,a,d,n]),h(()=>()=>K.current?.abort(),[]);let ne=p(async()=>{await $(T)},[T,$]),re=g(()=>x.facets.map(e=>({...e,values:W?k(P[e.field]??[],!0):k(I[e.field]??[],!1)})),[x.facets,W,P,I]);return{advancedSearch:x.advanced,askAi:o,facets:re,filter:j,groupCounts:R,groupField:e,isSearchLoading:B,items:ee,query:T,searchError:H,setFilter:M,setLoadMore:te,setQuery:A,retrySearch:ne}}function j(e){let n=O(),r=m(s),a=g(()=>t(r[i]).facets.find(t=>t.field===e),[r,e]),[o,c]=v(null),[l,u]=v(null);return h(()=>{if(l===null){c(null);return}let t=new AbortController;return w({...n,field:e,query:l.query,filter:D(l.filter),facetQuery:l.facetQuery},t.signal).then(t=>{c(a?{...a,values:k(C(t)[e]??[],!0)}:null)}).catch(()=>{t.signal.aborted||c(null)}),()=>t.abort()},[e,n,l,a]),{searchFacet:o,setSearchFacet:c,setSearchFacetQuery:u}}export{S as fetchSearch,w as fetchSearchFacets,j as useFacetQuery,A as useSearch,E as useSearchFeatures,O as useSearchScope};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeRouteSlug as e}from"../../../shared/utils/routes/normalize-route-slug.js";import{
|
|
1
|
+
import{normalizeRouteSlug as e}from"../../../shared/utils/routes/normalize-route-slug.js";import{splitUrlSuffix as t}from"../../../shared/utils/routes/split-url-suffix.js";import{stripPathPrefix as n}from"../../../shared/path-prefix.js";import{markdownCopyUrl as r}from"../../../shared/utils/routes/markdown-copy-url.js";function i(i){let{path:a}=t(i);return r(e(n(a)??a))}const a=`https://site.invalid`;function o(e){let t=e.trim();if(!t.startsWith(`/`))return;let n=URL.parse(t,a);if(n?.origin===a)return`${n.pathname}${n.search}${n.hash}`}async function s(e){let t=await fetch(e,{headers:{accept:`text/plain`}});if(t.ok&&!t.headers.get(`content-type`)?.startsWith(`text/html`))return await t.text()}function c(e,t,n){let r=typeof e==`number`?e:Number(e);return!Number.isFinite(r)||r<=0?t:Math.min(Math.floor(r),n)}export{c as clampLimit,s as fetchText,i as markdownPathForRoute,o as toSitePath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as e}from"../../../shared/utils/is-object.js";import{FEEDBACK_ROUTE_PATH as t}from"../../../shared/constants/feedback.js";import{SEARCH_ROUTE_PATH as n}from"../../../shared/constants/search.js";import{
|
|
1
|
+
import{isObject as e}from"../../../shared/utils/is-object.js";import{FEEDBACK_ROUTE_PATH as t}from"../../../shared/constants/feedback.js";import{SEARCH_ROUTE_PATH as n}from"../../../shared/constants/search.js";import{SKILLS_INDEX_SLUG as r}from"../../../content-layer/plugins/utils/skill-paths.js";import{clampLimit as i,fetchText as a,markdownPathForRoute as o,toSitePath as s}from"./shared.js";import{agentErrorResult as c,agentJsonResult as l,agentTextResult as u,collectOperations as d}from"@redocly/api-docs/lib/services/agent-tools/index.js";function f(e){return[...e.feedbackHidden?[]:[y(e)],{name:`get_current_page`,title:`Get current page`,description:`Report which documentation page the user is looking at right now, including the product and version in scope and whether it is an API reference page. Call this first so an answer matches what is on screen.`,inputSchema:{type:`object`,properties:{},additionalProperties:!1},annotations:{readOnlyHint:!0},execute:async()=>p(e)},{name:`search_docs`,title:`Search documentation`,description:`Search this documentation site and return matching pages with their titles and URLs. Use it to find the page that answers a question before reading it.`,inputSchema:{type:`object`,properties:{query:{type:`string`,description:`What to search for`},limit:{type:`integer`,description:`Maximum number of results, 10 by default`}},required:[`query`],additionalProperties:!1},annotations:{readOnlyHint:!0,untrustedContentHint:!0},execute:async t=>m(e,t)},{name:`read_page`,title:`Read a page`,description:`Return the full Markdown source of a documentation page. Omit the url to read the page the user is currently on.`,inputSchema:{type:`object`,properties:{url:{type:`string`,description:`Site-relative page path, for example /guides/quickstart`}},additionalProperties:!1},annotations:{readOnlyHint:!0,untrustedContentHint:!0},execute:async t=>h(e,t)},{name:`get_site_overview`,title:`Get site overview`,description:`Return the outline of this documentation site: its sections and the pages inside them, limited to what the current user may see. Use it to orient before searching.`,inputSchema:{type:`object`,properties:{},additionalProperties:!1},annotations:{readOnlyHint:!0,untrustedContentHint:!0},execute:async()=>g(e)},{name:`read_skill`,title:`Read an agent skill`,description:`List the agent skills this site publishes, or read one by name. A skill explains how to carry out a task against the documented product.`,inputSchema:{type:`object`,properties:{name:{type:`string`,description:`Skill name; omit to list every skill`}},additionalProperties:!1},annotations:{readOnlyHint:!0,untrustedContentHint:!0},execute:async t=>v(e,t)},{name:`navigate_page`,title:`Open a page`,description:`Move the browser tab to another page of this documentation site, so the user sees what an answer is based on. Accepts site-relative paths only.`,inputSchema:{type:`object`,properties:{url:{type:`string`,description:`Site-relative page path, optionally with a #section anchor`}},required:[`url`],additionalProperties:!1},annotations:{readOnlyHint:!1},execute:async t=>x(e,t)}]}async function p(e){let t=e.versions.find(e=>e.active);return l({url:e.pathname,title:e.pageTitle??document.title,locale:e.locale,product:e.product,version:t?.label??t?.version,isApiReference:!!e.apiDocs,...e.apiDocs?{apiBasePath:e.withPrefix(e.apiDocs.baseSlug),apiSpecType:e.apiDocs.store.specType,operationCount:d(e.apiDocs.items).length}:{}})}async function m(e,t){let r=typeof t.query==`string`?t.query.trim():``;if(!r)return c(`Provide a query to search for.`);let a=i(t.limit,10,50),o={query:r,...e.searchScope},s=await fetch(e.sitePathUrl(n),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(o)});if(!s.ok)return c(`Search failed with status ${s.status}.`);let{documents:d}=await s.json(),f=Object.entries(d).flatMap(([e,t])=>t.map(({document:t})=>({section:e,document:t}))).slice(0,a).map(({section:t,document:n})=>({title:n.title,url:e.withPrefix(n.url),section:t,method:n.httpMethod?.toUpperCase(),path:n.httpMethod?n.httpPath:void 0,deprecated:n.deprecated?!0:void 0,snippet:n.text.slice(0,300)}));return f.length?l({query:r,resultCount:f.length,results:f}):u(`No documentation pages matched "${r}".`)}async function h(e,t){let n=typeof t.url==`string`&&t.url.trim()?t.url.trim():e.pathname,r=s(n);if(!r)return c(`Provide a site-relative path that starts with "/".`);let i=await a(e.routeUrl(o(r)));return i?u(i):c(`${r} has no Markdown version. Either the path is wrong, or the page is built from code rather than Markdown. Use search_docs to find a documentation page.`)}async function g(e){let t=_(e.sidebarItems,e.withPrefix,0);if(t.length)return l({product:e.product,pages:t});let n=await a(e.sitePathUrl(`/llms.txt`));return n?u(n):c(`This site publishes no navigation tree.`)}function _(t,n,r){if(r>=3)return[];let i=[];for(let a of t){if(!e(a))continue;let t=typeof a.label==`string`?a.label:``,o=typeof a.link==`string`?a.link:void 0;if(!t&&!o)continue;let s=Array.isArray(a.items)?_(a.items,n,r+1):[];i.push({title:t,...o?{url:n(o)}:{},...s.length?{pages:s}:{}})}return i}async function v(t,n){let i=await fetch(t.sitePathUrl(r),{headers:{accept:`application/json`}});if(!i.ok)return c(`This site does not publish agent skills.`);let o=await i.json(),s=e(o)&&Array.isArray(o.skills)?o.skills:[],d=typeof n.name==`string`?n.name.trim():``;if(!d)return l({skills:s.map(e=>({name:e.name,description:e.description}))});let f=s.find(e=>e.name.toLowerCase()===d.toLowerCase());if(!f){let e=s.map(e=>e.name).join(`, `);return c(`No skill named "${d}". Available skills: ${e||`none`}.`)}let p=await a(t.routeUrl(f.url));return p?u(p):c(`The "${f.name}" skill could not be read.`)}function y(e){return{name:`leave_feedback`,title:`Leave feedback on a page`,description:`Report that a documentation page is wrong, outdated, confusing or incomplete. Use it only when the user agrees, and summarize the problem in their words. Reports reach the team that owns the page.`,inputSchema:{type:`object`,properties:{summary:{type:`string`,description:`One sentence naming the problem`},details:{type:`string`,description:`What is wrong and what the page should say`},url:{type:`string`,description:`Site-relative path of the page; the current page by default`}},required:[`summary`],additionalProperties:!1},annotations:{readOnlyHint:!1,consequentialHint:!0},execute:async t=>b(e,t)}}async function b(e,n){let r=typeof n.summary==`string`?n.summary.trim():``;if(!r)return c(`Describe the problem in one sentence.`);let i=typeof n.details==`string`?n.details.trim():``,a=typeof n.url==`string`&&n.url.trim()?n.url.trim():e.pathname,o=s(a);if(!o)return c(`Provide a site-relative path that starts with "/".`);let l=await fetch(e.sitePathUrl(t),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({component:`comment`,path:e.routeUrl(o),comment:i?`${r}\n\n${i}`:r,agent:`webmcp-browser-agent`,origin:`mcp`})});return l.ok?u(`Thanks. The feedback about ${o} reached the documentation team.`):c(l.status===403||l.status===404?`Feedback cannot be left for ${o}.`:`Feedback could not be sent, status ${l.status}.`)}async function x(e,t){let n=typeof t.url==`string`?s(t.url):void 0;return n?(await e.navigate(n),u(`Opened ${n}.`)):c(`Provide a site-relative path that starts with "/". This tool cannot leave the documentation site.`)}export{f as buildSiteTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{stripPathPrefix as e,withPathPrefix as t}from"../../shared/path-prefix.js";import{API_DOCS_RENDER_DEP_KEY as n}from"../../content-layer/plugins/internal/api-docs/server/shared.js";import{LoaderDataContext as r,PageContext as i,SidebarDataContext as a}from"../contexts.js";import{useL10nConfig as o}from"../l10n/use-l10n-config.js";import{useCurrentProduct as s}from"../ProductsProvider.js";import{telemetry as c}from"../telemetry/telemetry.js";import{usePageVersionsImpl as l}from"../use-page-versions.js";import{useSearchScope as u}from"../use-search.js";import{rebaseItemLinks as d}from"../../content-layer/plugins/internal/api-docs/client/rebase-item-links.js";import{buildApiTools as f}from"./tools/api-tools.js";import{buildSiteTools as p}from"./tools/site-tools.js";import{useContext as m,useEffect as h,useRef as g}from"react";import{useLocation as _,useNavigate as v}from"react-router";import{useThemeConfig as y}from"@redocly/theme/core/hooks";import{registerAgentTools as b}from"@redocly/api-docs/lib/services/agent-tools/index.js";import{getModelContext as x}from"@redocly/api-docs/lib/services/agent-tools/webmcp.js";function S(){let c=_(),d=v(),{currentLocale:S}=o(),w=u(),{versions:E}=l(),D=m(a).items,O=s(),k=m(i),A=m(r)[n],j=k?.slug.toLowerCase(),M=y().feedback?.hide===!0,N=k?.metadata?.seo,P={pathname:t(c.pathname),pageTitle:N?.title,locale:S,searchScope:w,product:O?.name??O?.slug,versions:E,sidebarItems:D??[],feedbackHidden:M,navigate:async t=>{let{pathname:n,search:r,hash:i}=new URL(t,window.location.origin);await d({pathname:e(n)??n,search:r,hash:i})},withPrefix:t,routeUrl:e=>new URL(e,window.location.origin).toString(),sitePathUrl:e=>new URL(t(e),window.location.origin).toString()},F=g(P);Object.assign(F.current,P),h(()=>{let e=new AbortController;return b(p(F.current),e.signal,T(`site`)),()=>e.abort()},[M]),h(()=>{if(!x())return;let e=F.current,t=C(A,j);if(e.apiDocs=t,!t)return;let n=new AbortController;return b(f(e,t),n.signal,T(`apiReference`)),()=>{n.abort(),e.apiDocs=void 0}},[A,j])}function C(e,t){if(Array.isArray(e?.items)&&t!==void 0)return{items:e.basePath===t?e.items:d(e.items,e.basePath,t),store:e.store,baseSlug:t}}const w={id:`agentTools`,object:`feature`,uri:`urn:redocly:realm:ui:feature:agentTools`};function T(e){return{registered:t=>c.sendAgentToolsRegisteredMessage([{...w,toolCount:t,scope:e}]),called:(e,t)=>c.sendAgentToolCalledMessage([{...w,toolName:e,outcome:t}])}}export{S as useWebMcpTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isPlanFeatureGranted as e}from"../shared/plan-gates.js";import{toPosixPath as t}from"../shared/utils/to-posix-path.js";import{describePackageViolation as n,findDisallowedPackages as r}from"./find-disallowed-packages.js";import{posix as i}from"node:path";async function a(t,i,a){if(e(t,`customPackages`))return[];let s=await o(i,a);if(!s)return[];let l;try{l=c(await a.readFile(s.absolutePath))}catch(e){return[{code:`configuration/invalid`,message:`This plan allows only approved npm packages, but package.json cannot be checked: ${e.message}`,location:{filePath:s.path}}]}return r(l,t.allowedPackages??[]).map(e=>({code:`configuration/package-not-allowed`,message:n(e),location:{filePath:s.path}}))}async function o(e,n){for(let r=t(e),a=0;;r=i.dirname(r),a++){let e=i.join(r,`package.json`);if(await n.exists(e))return{absolutePath:e,path:`${`../`.repeat(a)}package.json`};if(s(r))return null}}function s(e){let t=i.dirname(e);return t===e||t===`.`}function c(e){return JSON.parse(e.replace(/^\uFEFF/,``))}export{a as checkAllowedPackages};
|
|
@@ -26,7 +26,11 @@ export type ConfigSchema = boolean | {
|
|
|
26
26
|
};
|
|
27
27
|
not?: ConfigSchema;
|
|
28
28
|
};
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* The root `redocly.yaml`, with each plugin's schema for the root key named by its plugin id; a
|
|
31
|
+
* built-in key wins over a plugin id. Unknown top-level keys stay: project plugins read their own.
|
|
32
|
+
*/
|
|
33
|
+
export declare function realmConfigSchema(pluginSchemas: Readonly<Record<string, ConfigSchema>>): ConfigSchema;
|
|
30
34
|
export declare const REALM_CONFIG_SCHEMA: ConfigSchema;
|
|
31
35
|
/** A nested `redocly.yaml`: the product override sections, `apis`, and the API kind blocks. */
|
|
32
36
|
export declare const NESTED_CONFIG_SCHEMA: ConfigSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as e}from"../shared/utils/is-object.js";import{interpolateEnvVariables as t,productConfigOverrideSchema as n,rootRedoclyConfigSchema as r}from"@redocly/config";const i=r.properties,a={type:`string`,pattern:`\\S`},o={...i.apis.additionalProperties,required:[`root`]},s={...i.scripts.properties.head.items,required:[`src`]},c=i.redirects.additionalProperties,l=i.theme.properties.asyncapi,u={type:`object`,additionalProperties:o},d={...i.scripts,properties:{head:{type:`array`,items:s},body:{type:`array`,items:s}}},f={...i.redirects,propertyNames:a,additionalProperties:{...c,properties:{...c.properties,to:a},required:[`to`]}},p={type:`object`,properties:{include:{type:`array`,items:{type:`string`,minLength:1}},max:{type:`integer`,minimum:1}},additionalProperties:!1},m={type:`object`,properties:{anchors:{type:`object`,properties:{hide:{type:`boolean`}},additionalProperties:!1}},additionalProperties:!1}
|
|
1
|
+
import{isObject as e}from"../shared/utils/is-object.js";import{interpolateEnvVariables as t,productConfigOverrideSchema as n,rootRedoclyConfigSchema as r}from"@redocly/config";const i=r.properties,a={type:`string`,pattern:`\\S`},o={...i.apis.additionalProperties,required:[`root`]},s={...i.scripts.properties.head.items,required:[`src`]},c=i.redirects.additionalProperties,l=i.theme.properties.asyncapi,u={type:`object`,additionalProperties:o},d={...i.scripts,properties:{head:{type:`array`,items:s},body:{type:`array`,items:s}}},f={...i.redirects,propertyNames:a,additionalProperties:{...c,properties:{...c.properties,to:a},required:[`to`]}},p={type:`object`,properties:{include:{type:`array`,items:{type:`string`,minLength:1}},max:{type:`integer`,minimum:1}},additionalProperties:!1},m={type:`object`,properties:{anchors:{type:`object`,properties:{hide:{type:`boolean`}},additionalProperties:!1}},additionalProperties:!1};function h(e){return{...r,properties:{...e,...i,apis:u,asyncapi:l,linkChecker:m,redirects:f,revisions:p,scripts:d},additionalProperties:!0}}h({});const g={...n,properties:{...n.properties,apis:u,asyncapi:l,graphql:i.graphql}},_={type:`object`,properties:{banner:i.banner}},v=Symbol(`drop`);function y(n,r,i={}){let{env:a}=i,o={problems:[],resolve:a?e=>t(e,a).value:e=>e},s=b(n,structuredClone(r),``,o);return{value:e(s)?s:{},problems:o.problems}}function b(t,n,r,i){if(t===!0)return n;if(t===!1)return j(i,r,`is not allowed`);let a=S(t,x(n,i));if(a!==void 0)return j(i,r,a);let o=n;return e(n)?o=C(t,n,r,i):Array.isArray(n)&&(o=T(t,n,r,i)),o!==v&&t.oneOf&&(o=E(t.oneOf,t.discriminator,n,o,r,i)),o!==v&&t.not!==void 0&&D(t.not,o,i)&&i.problems.push({code:`configuration/invalid`,message:`${M(r)} ${A(t.not)}.`}),o}function x(e,t){return typeof e==`string`?t.resolve(e):e}function S(e,t){if(e.type!==void 0&&!O(t,e.type))return`must be ${e.type}`;if(e.enum&&!e.enum.some(e=>k(e,t)))return`must be one of: ${e.enum.join(`, `)}`;if(e.const!==void 0&&!k(e.const,t))return`must be ${JSON.stringify(e.const)}`;if(typeof t==`string`){if(e.minLength!==void 0&&t.length<e.minLength)return e.minLength===1?`must not be empty`:`must have at least ${e.minLength} characters`;if(e.pattern!==void 0&&!new RegExp(e.pattern,`u`).test(t))return e.pattern===`\\S`?`must not be empty`:`must match the pattern ${e.pattern}`}if(typeof t==`number`&&e.minimum!==void 0&&t<e.minimum)return`must be at least ${e.minimum}`}function C(e,t,n,r){let i=[];for(let[a,o]of Object.entries(t)){let t=N(n,a);if(e.propertyNames!==void 0&&!D(e.propertyNames,a,r)){j(r,t,`has an invalid name`);continue}let s=w(e,a);if(s===void 0){r.problems.push({code:`configuration/ignored`,message:`\`${t}\` is not a known option and is ignored.`}),i.push([a,o]);continue}let c=b(s,o,t,r);c!==v&&i.push([a,c])}let a=Object.fromEntries(i),o=e.required??[],s=o.find(e=>!Object.hasOwn(t,e));if(s!==void 0)return j(r,n,`must have required property '${s}'`);if(e.minProperties!==void 0){if(Object.keys(t).length<e.minProperties)return j(r,n,e.minProperties===1?`must not be empty`:`must have at least ${e.minProperties} properties`);if(Object.keys(a).length<e.minProperties)return v}return o.every(e=>Object.hasOwn(a,e))?a:v}function w(e,t){if(e.properties&&Object.hasOwn(e.properties,t))return e.properties[t];for(let[n,r]of Object.entries(e.patternProperties??{}))if(new RegExp(n,`u`).test(t))return r;return e.additionalProperties===!1?void 0:e.additionalProperties??!0}function T(e,t,n,r){let{items:i}=e,a=i===void 0?t:t.flatMap((e,t)=>{let a=b(i,e,N(n,t),r);return a===v?[]:[a]});if(e.minItems!==void 0){if(t.length<e.minItems)return j(r,n,e.minItems===1?`must not be empty`:`must have at least ${e.minItems} items`);if(a.length<e.minItems)return v}return e.uniqueItems&&new Set(t.map(e=>JSON.stringify(e))).size<t.length?j(r,n,`must not have duplicate items`):a}function E(t,n,r,i,a,o){if(n){let r=n.propertyName,s=e(i)?x(i[r],o):void 0,c=t.find(e=>{let t=typeof e==`object`?e.properties?.[r]:void 0;return s!==void 0&&typeof t==`object`&&t.const===s});return c===void 0?j(o,a,`has an invalid value`):b(c,i,a,o)}let s=e=>t.filter(t=>D(t,e,o)).length;return s(r)===1?s(i)===1?i:v:j(o,a,`has an invalid value`)}function D(e,t,n){let r={problems:[],resolve:n.resolve};return b(e,t,``,r),r.problems.length===0}function O(t,n){switch(n){case`object`:return e(t);case`array`:return Array.isArray(t);case`integer`:return Number.isInteger(t);case`number`:return typeof t==`number`&&Number.isFinite(t);default:return typeof t===n}}function k(e,t){return JSON.stringify(e)===JSON.stringify(t)}function A(e){let t=typeof e==`object`?e.required:void 0;return t?`must not set both ${t.map(e=>`\`${e}\``).join(` and `)}`:`has a value that is not allowed`}function j(e,t,n){return e.problems.push({code:`configuration/invalid`,message:`${M(t)} ${n} and is ignored.`}),v}function M(e){return e===``?`The config`:`\`${e}\``}function N(e,t){return typeof t==`number`?`${e}[${t}]`:e===``?t:/^[A-Za-z_$][\w$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}export{g as NESTED_CONFIG_SCHEMA,_ as PAGE_BANNER_SCHEMA,h as realmConfigSchema,y as sanitizeConfig};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { PlatformFs } from '../platform/types/fs.js';
|
|
2
|
-
import { type TeamDirs } from '../
|
|
2
|
+
import { type TeamDirs } from '../shared/rbac/team-templates.js';
|
|
3
3
|
import { type ProcessEnv } from '../shared/public-env.js';
|
|
4
4
|
import type { NestedConfig, RealmConfig } from '../shared/types/config.js';
|
|
5
|
+
import { type ConfigSchema } from './config-schema.js';
|
|
5
6
|
import type { ContentLayerContext } from './context.js';
|
|
6
7
|
import type { ProblemDraft } from './problems/types.js';
|
|
7
8
|
export type { RealmConfig } from '../shared/types/config.js';
|
|
@@ -37,8 +38,9 @@ type ConfigObject = Record<string, unknown>;
|
|
|
37
38
|
* `REDOCLY_ENFORCE_LOGIN` and `REDOCLY_ENFORCE_RESIDENCY` enforce applied. `siteConfig`
|
|
38
39
|
* keeps the `{{ process.env.X }}` references, judged by their values in the environment;
|
|
39
40
|
* `config` has them replaced. A reference reads the view a host gives it (`readProjectEnv`).
|
|
41
|
+
* `pluginSchemas` checks the root key of each plugin id it names.
|
|
40
42
|
*/
|
|
41
|
-
export declare function loadRedoclyConfig(contentDir: string, fs: PlatformFs): Promise<LoadedRedoclyConfig>;
|
|
43
|
+
export declare function loadRedoclyConfig(contentDir: string, fs: PlatformFs, pluginSchemas?: Readonly<Record<string, ConfigSchema>>): Promise<LoadedRedoclyConfig>;
|
|
42
44
|
/**
|
|
43
45
|
* Whether the effective config differs from the one whose digest the last ingest stored;
|
|
44
46
|
* `null` (no ingest yet, or a row an older ingest wrote) counts as changed. The effective config
|
|
@@ -80,11 +82,13 @@ export declare function deepMergeConfig(base: ConfigObject, override: ConfigObje
|
|
|
80
82
|
* `access.rbac.content` and `redirects` cover every content locale, `access.requiresLogin`
|
|
81
83
|
* follows the rbac rules when `access.rbac` is set, and the `PUBLIC_*` environment is
|
|
82
84
|
* attached. `report` receives one problem per removed, ignored, or deprecated setting.
|
|
85
|
+
* `pluginSchemas` checks the root key of each plugin id it names.
|
|
83
86
|
*/
|
|
84
87
|
export declare function normalizeRedoclyConfig(config: Record<string, unknown>, options?: {
|
|
85
88
|
dirLocales?: readonly string[];
|
|
86
89
|
teamDirs?: TeamDirs;
|
|
87
90
|
env?: ProcessEnv;
|
|
91
|
+
pluginSchemas?: Readonly<Record<string, ConfigSchema>>;
|
|
88
92
|
report?: (problem: ProblemDraft) => void;
|
|
89
93
|
}): RealmConfig;
|
|
90
94
|
export declare function createEmptyRealmConfig(): RealmConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toJsonObject as e,toJsonValue as t}from"./database/utils/json.js";import{
|
|
1
|
+
import{toJsonObject as e,toJsonValue as t}from"./database/utils/json.js";import{hashContentBytes as n}from"../shared/utils/content-hash.js";import{getProcessEnv as r,getPublicEnv as i,resolveRedoclyEnvironment as a,sanitizeBranchName as o}from"../shared/public-env.js";import{isClosedToAnonymous as s,parseRbacConfigData as c}from"../shared/rbac/engine.js";import{readProjectEnv as l}from"../shared/project-env.js";import{listL10nDirs as u,resolveLocaleContext as d}from"../shared/utils/l10n.js";import{expandConfigRbacForL10n as f}from"../shared/rbac/l10n-rules.js";import{expandConfigRbacTeamTemplates as p,listTeamDirs as m,teamTemplatePrefixes as ee}from"../shared/rbac/team-templates.js";import{resolveContentPath as h}from"../shared/utils/resolve-content-path.js";import{resolveConfigRedirects as g}from"./config-redirects.js";import{NESTED_CONFIG_SCHEMA as _,realmConfigSchema as v,sanitizeConfig as y}from"./config-schema.js";import{hashEffectiveConfig as b,resolveSiteConfig as x}from"./database/site-config.js";import{applyEnforcedAccess as S}from"./enforced-access.js";import{applyPlanGates as C}from"./plan-gates.js";import{resolve as w}from"node:path";import T from"js-yaml";import{interpolateEnvVariables as E}from"@redocly/config";const D=[`redocly.yaml`,`redocly.yml`],O=`redocly.yaml`;async function k(e,t,i={}){let a=await re(e,t),o=r();if(!a){let e=[],t=S(C($(),o,t=>e.push({code:`configuration/ignored`,message:t})),o);return{absolutePath:null,config:t,siteConfig:t,path:null,hash:null,refs:[],problems:e}}let s=await t.readBinaryFile(a.absolutePath),c=[],d=[],f=[],p=P(new TextDecoder().decode(s),a.path),h=[],g=l(o),_={contentDir:e,fs:t,env:g,refs:f,warnings:c,errors:d},v=Q(await V(await L(await F(p,{..._,deprecations:h}),``,_),_)),y={filePath:a.path},b=[],w=U(v.access)?v.access.rbac:void 0,T=K(v,{dirLocales:await u(e,t),teamDirs:await m(e,t,ee(U(w)?w:{})),env:g,pluginSchemas:i,report:e=>b.push({...e,location:y})}),E=S(C(T,o,e=>b.push({code:`configuration/ignored`,message:e,location:y})),o),{config:D,unsetVars:O}=x(E,g);for(let e of O)c.push(`The config references process.env.${e}, which is not set.`);let k=[...c.map(e=>({code:`configuration/ignored`,message:e,location:y})),...[...new Set(h)].map(e=>({code:`configuration/deprecated`,message:e,location:y})),...d.map(e=>({code:`configuration/invalid`,severity:`error`,message:e,location:y})),...b];return{...a,config:D,siteConfig:E,hash:await n(s),refs:f,problems:k}}function A(e,t){return b(e)!==t}async function j(e){if(e.context.configLoaded&&e.force!==!0)return{absolutePath:e.context.configFilePath?w(e.context.contentDir,e.context.configFilePath):null,config:e.context.config,siteConfig:e.context.siteConfig,path:e.context.configFilePath,hash:e.context.configHash,refs:e.context.configRefs,problems:[]};let t=Object.fromEntries(e.context.pluginRegistry.list().flatMap(e=>e.configSchema?[[e.id,e.configSchema]]:[])),n=await k(e.context.contentDir,e.context.platform.fs,t);return e.context.config=n.config,e.context.siteConfig=n.siteConfig,e.context.configFilePath=n.path,e.context.configHash=n.hash,e.context.configRefs=n.refs,e.context.configLoaded=!0,n}function M(e,t){let n=E(P(e,t),l(r())).value,{value:i,problems:a}=y(_,n);for(let e of a)e.location={filePath:t};return{config:i,problems:a}}function te(e){return e.endsWith(`/${O}`)}async function N(e){let t=[];for(let n of e.paths)try{let r=await e.fs.readFile(w(e.contentDir,n));t.push(...M(r,n).problems)}catch(e){let r=e instanceof Error?e.message:String(e);t.push({code:`configuration/invalid`,message:`The config cannot be read: ${r}`,location:{filePath:n}})}return t}function P(t,n){let r=T.load(t);if(r==null)return{};try{return e(r)}catch(e){throw Error(`Expected ${n} to contain a YAML object.`,{cause:e})}}async function F(e,t){let{env:n,...r}=e;if(!U(n))return e;let i=t.env.PUBLIC_REDOCLY_BRANCH_NAME,s=[...i?[`branch.${o(i)}`]:[],a(t.env.REDOCLY_ENV)],c=e=>t.deprecations.push(e),l=J(r,c);for(let e of s){let r=await I(n[e],e,t);r&&(l=H(l,J(r,c)))}return l}async function I(e,t,n){if(!U(e))return null;if(typeof e.$ref!=`string`)return e;let{$ref:r,...i}=e,a=`env.${t}`,o=R(await z(r,a,n),i,a,n);return U(o)?o:null}async function L(e,t,n){if(Array.isArray(e))return Promise.all(e.map((e,r)=>L(e,`${t}[${r}]`,n)));if(!U(e))return e;if(typeof e.$ref==`string`){let{$ref:r,...i}=e;return R(await z(r,t,n),await L(i,t,n),t,n)}let r={};for(let[i,a]of Object.entries(e))r[i]=await L(a,t===``?i:`${t}.${i}`,n);return r}function R(e,t,n,r){if(Object.keys(t).length===0)return e;if(U(e))return{...e,...t};if(e==null)return t;let i=Array.isArray(e)?`list`:`scalar`;return r.warnings.push(`${n===``?`The config`:n} has keys next to a $ref to a ${i}; only the referenced file applies.`),e}function z(e,n,r){return B(e,`${n} $ref`,r,e=>t(T.load(e)))}async function B(e,t,r,i,a=`warning`){let o=a===`error`?r.errors:r.warnings,s=h(e,D[0]);if(s===null)return o.push(`${t} "${e}" escapes the content root.`),null;try{let e=await r.fs.readBinaryFile(w(r.contentDir,s));return r.refs.push({path:s,hash:await n(e)}),i(new TextDecoder().decode(e))}catch(n){let r=n instanceof Error?n.message:String(n);return o.push(`Cannot read ${t} "${e}": ${r}`),null}}async function V(e,t){let{seo:n}=e;if(!U(n)||!U(n.llmstxt)||!U(n.llmstxt.details))return e;let{path:r,...i}=n.llmstxt.details;if(typeof r!=`string`)return e;let a=null;i.content===void 0?a=await B(E(r,t.env).value,`seo.llmstxt.details.path`,t,e=>e,`error`):t.errors.push(`seo.llmstxt.details.path and seo.llmstxt.details.content are mutually exclusive; the path is ignored.`);let o={...n.llmstxt,details:a===null?i:{...i,path:r,content:a}};return{...e,seo:{...n,llmstxt:o}}}function H(e,t){let n={...e};for(let[e,r]of Object.entries(t)){if(e===`__proto__`||e===`constructor`||e===`prototype`)continue;let t=n[e];n[e]=U(t)&&U(r)?H(t,r):r}return n}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const W=[`hide`,`name`,`ignore`,`publicEndpoint`],G=[`requiresLogin`,`rbac`,`sso`,`idps`,`logoutReturnUrl`,`residency`];function K(e,t={}){let n=t.report??(()=>{}),r=t.dirLocales??[],a=J(e,e=>n({code:`configuration/deprecated`,message:e}));U(a.mcp)&&a.mcp.docs!==void 0&&n({code:`configuration/deprecated`,message:`The 'mcp.docs' property is deprecated. Use the 'mcp' properties instead.`});let o=y(v(t.pluginSchemas??{}),a,{env:t.env});for(let e of o.problems)n(e);let{redirects:s,access:c,...l}=f(p(q(o.value,t.env),t.teamDirs??{},n),r),u={...l,publicEnv:i()};c&&(u.access=ne(c,n));let m=g(s,d(l.l10n,r));return m&&(u.redirects=m),u}function q(e,t){if(!t)return e;let n={...e};for(let r of[`access`,`l10n`,`redirects`])r in e&&(n[r]=E(e[r],t).value);return n}function J(e,t){return Z(Y(Q(e),t))}function Y(e,t){let n=e;e.reunite!==void 0&&(t(`The 'reunite' property is deprecated. Use 'platform' instead.`),e.platform!==void 0&&e.platform!==null&&t(`Both 'platform' and 'reunite' are set. 'reunite' is ignored, so remove it.`),n=X(e));let{access:r}=n;return U(r)&&U(r.rbac)&&r.rbac.reunite!==void 0&&(t(`The 'access.rbac.reunite' property is deprecated. Use 'access.rbac.platform' instead.`),n={...n,access:{...r,rbac:X(r.rbac)}}),n}function X(e){let{reunite:t,...n}=e;return{...n,platform:e.platform??t}}function Z(e){let{mcp:t}=e;if(!U(t))return e;let{docs:n,...r}=t;if(!U(n))return e;let i={...n};for(let e of W){let t=n[e];delete i[e],t!==void 0&&(r[e]===void 0||r[e]===null||e===`hide`&&t===!0)&&(r[e]=t)}return{...e,mcp:{...r,docs:i}}}function Q(e){let t=G.map(t=>[t,e[t]]).filter(([,e])=>e!==void 0);if(t.length===0)return e;let n={...e},r=U(e.access)?{...e.access}:{};for(let[e,i]of t)delete n[e],(r[e]===void 0||r[e]===null)&&(r[e]=i);return{...n,access:r}}function ne(e,t){let n=e.rbac?c(e.rbac,e=>t({code:`configuration/invalid`,message:e})):null;return n?(e.requiresLogin===!0&&t({code:`configuration/ignored`,message:`access.requiresLogin is ignored because access.rbac is also configured — the two are mutually exclusive. Remove one.`}),{...e,requiresLogin:s(n)}):e}async function re(e,t){for(let n of D){let r=w(e,n);if(await t.exists(r))return{absolutePath:r,path:n}}return null}function $(){return K({})}export{O as NESTED_CONFIG_FILENAME,D as REDOCLY_CONFIG_FILENAMES,$ as createEmptyRealmConfig,H as deepMergeConfig,A as isConfigChanged,te as isNestedConfigPath,j as loadContentLayerConfig,k as loadRedoclyConfig,K as normalizeRedoclyConfig,M as parseNestedConfig,N as readNestedConfigProblems};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createSqliteDatabaseClient as e}from"@redocly/realm-db-client";import{DatabaseSync as t}from"node:sqlite";function n(n){let i=new t(n,{timeout:5e3}),o=/* @__PURE__ */ new Map;function s(e){let t=o.get(e);if(t)return o.delete(e),o.set(e,t),t;let n=i.prepare(e);return n.setReturnArrays(!0),n.setReadBigInts(!0),o.size>=256&&o.delete(o.keys().next().value),o.set(e,n),n}return e({exec:e=>i.exec(e),run({sql:e,args:t}){let n=s(e),i=r(t);if(n.columns().length===0){let e=n.run(...i);return{columns:[],rows:[],rowsAffected:Number(e.changes),lastInsertRowid:BigInt(e.lastInsertRowid)}}let o=n.all(...i),c=n.columns();return{columns:c.map(e=>e.name),columnTypes:c.map(e=>(e.type??``).toUpperCase()),rows:o.map(e=>e.map(a))}},close(){o.clear(),i.close()}})}function r(e){if(e===void 0)return[];if(Array.isArray(e))return e.map(i);let t={};for(let[n,r]of Object.entries(e))t[n]=i(r);return[t]}function i(e){return typeof e==`boolean`?+!!e:e}function a(e){return typeof e==`bigint`&&e>=BigInt(-(2**53-1))&&e<=BigInt(2**53-1)?Number(e):e}export{n as createNodeSqliteClient};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getRealmDir as e}from"../../shared/constants/runtime-layout.js";import{createNodePlatformFs as t}from"../../platform/node/fs.js";import{createCloudDatabaseConnection as n}from"./adapters/cloud.js";import{createLocalDatabaseConnection as r}from"./adapters/local.js";import{isRemoteDatabaseUrl as i}from"./utils/is-remote-database-url.js";import{fileURLToPath as a,pathToFileURL as o}from"node:url";import{dirname as s,join as c}from"node:path";import{sql as l}from"drizzle-orm";const u=`content-layer.db`,d=5e3,f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Map;function m(e){let t=/^[a-z][a-z0-9+.-]*:/i.exec(e);return t?p.get(t[0].toLowerCase()):void 0}const h=a(new URL(`../../../drizzle`,import.meta.url));async function g(e){let a=e.migrationsDir??h,o=e.databaseUrl??_(e),c=e.logger,l=e.platform?.fs??t(),u,d=m(o);if(d)u=await d(o);else if(i(o))u=await n({url:o,authToken:e.authToken,instrumentation:e.instrumentation});else{let e=v(o);await l.exists(s(e))||await l.mkdir(s(e),{recursive:!0}),u=await r({path:e}),await E(u.db,c)}return e.runMigrations!==!1&&await x(u.db,{databaseUrl:o,migrationsDir:a,logger:c,operation:`run content-layer migrations`}),{db:u.db,url:o,close:async()=>{u.close()}}}function _(t){if(!t.contentDir)throw Error(`contentDir is required when databaseUrl is not provided.`);return o(c(e(t.contentDir),u)).href}function v(e){if(e.startsWith(`file:///`))return a(e);if(e.startsWith(`file:`))return e.slice(5);if(!y(e))return e;throw Error(`Unsupported content-layer database URL "${e}". Expected a file path, a file: URL, an http(s) URL, or a scheme registered with registerDatabaseUrlSchemeAdapter.`)}function y(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)}async function b(e,t){let{migrate:n}=await import(`drizzle-orm/libsql/migrator`);await S(e,t),await n(e,{migrationsFolder:t})}async function x(e,t){await T({databaseUrl:t.databaseUrl,migrationsDir:t.migrationsDir,run:()=>D(()=>b(e,t.migrationsDir),{logger:t.logger,operation:t.operation})})}async function S(e,t){let{readMigrationFiles:n}=await import(`drizzle-orm/migrator`);if((await e.all(l`select 1 from sqlite_master where name = '__drizzle_migrations'`)).length===0)return;let r=new Map(n({migrationsFolder:t}).map(e=>[e.name,e.hash]));if(!(await e.all(l`select name, hash from __drizzle_migrations`)).some(e=>!r.has(e.name)||r.get(e.name)!==e.hash))return;let i=await e.all(l`select name from sqlite_master where type = 'table'
|
|
2
2
|
and name not like 'sqlite\\_%' escape '\\'
|
|
3
3
|
and name not like '\\_\\_realm\\_db\\_%' escape '\\'`);await e.run(l.raw(`PRAGMA foreign_keys = OFF`));for(let t of i)await e.run(l`drop table ${l.identifier(t.name)}`);await e.run(l.raw(`PRAGMA foreign_keys = ON`))}function C(e){if(e===void 0)return 500;if(!Number.isInteger(e)||e<=0)throw Error(`Invalid batch size: ${e}`);return e}function*w(e,t){for(let n=0;n<e.length;n+=t)yield e.slice(n,n+t)}async function T(e){let t=`${e.databaseUrl}::${e.migrationsDir}`,n=f.get(t);if(n){await n;return}let r=e.run().finally(()=>{f.delete(t)});f.set(t,r),await r}async function E(e,t){await e.run(l.raw(`PRAGMA busy_timeout = ${d}`)),await D(async()=>{await e.run(l.raw(`PRAGMA foreign_keys = ON`)),await e.run(l.raw(`PRAGMA journal_mode = WAL`)),await e.run(l.raw(`PRAGMA synchronous = NORMAL`))},{logger:t,operation:`configure local SQLite pragmas`})}async function D(e,t){let n=t.maxAttempts??4,r=t.retryDelayMs??50;for(let i=1;i<=n;i+=1)try{return await e()}catch(e){if(!O(e)||i===n)throw e;let a=r*i;t.logger?.warn(`SQLite database is busy; retrying ${t.operation} (attempt ${i}/${n}, ${a}ms backoff)`),await k(a)}throw Error(`Failed to ${t.operation}.`)}function O(e){return e instanceof Error?`code`in e&&e.code===`SQLITE_BUSY`||`errcode`in e&&e.errcode===5||e.message.includes(`SQLITE_BUSY`)||e.message.includes(`database is locked`)?!0:`cause`in e&&O(e.cause):!1}function k(e){return new Promise(t=>{setTimeout(t,e)})}export{u as CONTENT_LAYER_DB_FILENAME,d as DEFAULT_SQLITE_BUSY_TIMEOUT_MS,w as batchValues,C as normalizeBatchSize,g as openContentLayerDatabase,v as resolveLocalDatabasePath,D as runWithSqliteBusyRetry};
|
|
@@ -41,7 +41,10 @@ export type EntityStoreOptions = {
|
|
|
41
41
|
* rows never materialize. Null/absent = current rows (the hot path).
|
|
42
42
|
*/
|
|
43
43
|
revisionAsOf?: number | null;
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Produces a missing or stale value and patches its row in `state`; absent = stored values
|
|
46
|
+
* only (production runtime).
|
|
47
|
+
*/
|
|
45
48
|
materialize?: (key: string) => Promise<JsonValue>;
|
|
46
49
|
/** Called with every key `get`/`load` touched, once the read is known — the reader's entity deps. */
|
|
47
50
|
onEntityRead?: (key: string) => void;
|
|
@@ -49,6 +52,11 @@ export type EntityStoreOptions = {
|
|
|
49
52
|
record?: RouteQueryRecorder;
|
|
50
53
|
};
|
|
51
54
|
export declare function createEntityStore(options: EntityStoreOptions): EntityStore;
|
|
55
|
+
/**
|
|
56
|
+
* Makes the state entry of `key` match its stored row after a materialization: in place, so
|
|
57
|
+
* every store over this state, and a `get` after a `load`, sees the loader's metadata.
|
|
58
|
+
*/
|
|
59
|
+
export declare function refreshStateEntity(database: ContentLayerDatabase, state: ContentStateView, key: string): Promise<void>;
|
|
52
60
|
/** The hash a hook's `entity` read records: identity, type, metadata, and value hash, or absence. */
|
|
53
61
|
export declare function hashEntityRead(state: ContentStateView, key: string): string;
|
|
54
62
|
/** Re-runs a stored `entity-type` query against `state`; the hash `list` recorded. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hashJsonValue as e,toStableJsonString as t}from"./utils/json.js";import{compareStrings as n}from"../../shared/utils/compare-strings.js";import{entities as r}from"./schema.js";import{replaceDataRefMarkers as i}from"../materialization/data-ref.js";import{resolveDataRef as a}from"./blobs.js";import{listEntityRevisions as o}from"../revisions/list.js";import{selectEntityRowForRead as s}from"../revisions/read.js";import{and as c,eq as l,inArray as u}from"drizzle-orm";function d(e){let{database:t,state:u}=e,d=typeof e.revisionAsOf==`number`?e.revisionAsOf:null;return{get:async n=>{if(e.onEntityRead?.(n),d!==null){let e=await s(t.db,n,d);return e?x(e):null}let i=u?.entitiesByKey.get(n);if(i)return x(i);if(u)return null;let[a]=await t.db.select(b()).from(r).where(c(l(r.key,n),l(r.isCurrent,1))).limit(1);return a?x(a):null},async listRevisions(n){for(let t of n)e.onEntityRead?.(t);return o(t.db,n)},async list(i={}){let a=(u?[...u.entitiesByKey.values()].filter(e=>v(e,i)):await t.db.select(b()).from(r).where(c(l(r.isCurrent,1),i.type===void 0?void 0:l(r.type,i.type),i.pluginId===void 0?void 0:l(r.pluginId,i.pluginId)))).map(x).sort((e,t)=>n(e.key,t.key));return e.record?.({kind:`entity-type`,argument:m(i),resultHash:_(a.map(e=>e.key))}),a},async load(n){let o=u?.entitiesByKey.get(n),[
|
|
1
|
+
import{hashJsonValue as e,toStableJsonString as t}from"./utils/json.js";import{compareStrings as n}from"../../shared/utils/compare-strings.js";import{entities as r}from"./schema.js";import{replaceDataRefMarkers as i}from"../materialization/data-ref.js";import{resolveDataRef as a}from"./blobs.js";import{listEntityRevisions as o}from"../revisions/list.js";import{selectEntityRowForRead as s}from"../revisions/read.js";import{and as c,eq as l,inArray as u}from"drizzle-orm";function d(e){let{database:t,state:u}=e,d=typeof e.revisionAsOf==`number`?e.revisionAsOf:null;return{get:async n=>{if(e.onEntityRead?.(n),d!==null){let e=await s(t.db,n,d);return e?x(e):null}let i=u?.entitiesByKey.get(n);if(i)return x(i);if(u)return null;let[a]=await t.db.select(b()).from(r).where(c(l(r.key,n),l(r.isCurrent,1))).limit(1);return a?x(a):null},async listRevisions(n){for(let t of n)e.onEntityRead?.(t);return o(t.db,n)},async list(i={}){let a=(u?[...u.entitiesByKey.values()].filter(e=>v(e,i)):await t.db.select(b()).from(r).where(c(l(r.isCurrent,1),i.type===void 0?void 0:l(r.type,i.type),i.pluginId===void 0?void 0:l(r.pluginId,i.pluginId)))).map(x).sort((e,t)=>n(e.key,t.key));return e.record?.({kind:`entity-type`,argument:m(i),resultHash:_(a.map(e=>e.key))}),a},async load(n){let o=u?.entitiesByKey.get(n),[f]=d===null?u&&!o?[]:await t.db.select({status:r.status,data:r.data,dataHash:r.dataHash,type:r.type,metadata:r.metadata,isCurrent:r.isCurrent}).from(r).where(c(l(r.key,n),l(r.isCurrent,1))).limit(1):[await s(t.db,n,d)??void 0];if(!f)throw e.onEntityRead?.(n),Error(`Entity "${n}" is not registered.`);let m;if(f.status===`ready`&&f.data!==null||f.isCurrent!==1)m=f.data,u&&f.isCurrent===1&&d===null&&p(u,n,f);else if(e.materialize)m=await e.materialize(n);else throw Error(`Missing precomputed entity data for "${n}". Rebuild the content entity data before starting the production runtime.`);return e.onEntityRead?.(n),await i(m,e=>a(t,e))}}}async function f(e,t,n){let[i]=await e.db.select({status:r.status,dataHash:r.dataHash,type:r.type,metadata:r.metadata}).from(r).where(c(l(r.key,n),l(r.isCurrent,1))).limit(1);i&&p(t,n,i)}function p(e,t,n){let r=e.entitiesByKey.get(t);r&&Object.assign(r,{status:n.status,dataHash:n.dataHash,type:n.type,metadata:n.metadata})}function m(e){return t({...e.type===void 0?{}:{type:e.type},...e.pluginId===void 0?{}:{pluginId:e.pluginId}})}function h(t,n){let r=t.entitiesByKey.get(n);return e(r?[r.id,r.kind,r.type,r.metadata,r.dataHash,r.status]:`absent`)}function g(e,t){let r=JSON.parse(t),i=[];for(let t of e.entitiesByKey.values())v(t,r)&&i.push(t.key);return _(i.sort(n))}function _(t){return e([...t])}function v(e,t){return(t.type===void 0||e.type===t.type)&&(t.pluginId===void 0||e.pluginId===t.pluginId)}async function y(e,t){return t.length===0?[]:e.db.select({key:r.key,metadata:r.metadata}).from(r).where(c(u(r.key,[...t]),l(r.isCurrent,1)))}function b(){return{id:r.id,key:r.key,kind:r.kind,type:r.type,metadata:r.metadata,pluginId:r.pluginId,loaderId:r.loaderId,loaderArgs:r.loaderArgs,status:r.status,dataHash:r.dataHash,isSystem:r.isSystem}}function x(e){return{id:e.id,key:e.key,kind:e.kind,type:e.type,metadata:e.metadata,pluginId:e.pluginId,loaderId:e.loaderId,loaderArgs:e.loaderArgs,status:e.status,dataHash:e.dataHash,isSystem:e.isSystem===!0||e.isSystem===1}}export{d as createEntityStore,g as hashEntityListMembership,h as hashEntityRead,y as loadCurrentEntityMetadata,f as refreshStateEntity};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{delocalizeL10nPath as e}from"../../shared/utils/l10n.js";import{assetRefs as t,entities as n,entityDeps as r,files as i,linkRefs as a,loaderConfigDeps as o,originDeps as s,pageMarkdown as c,problems as l,searchDocuments as u,searchFragmentParents as d,searchFragmentPostings as f,searchFragmentUsages as p,searchFragments as m,searchPostings as h}from"./schema.js";import{compileGlob as g,hashGlobMatches as _,matchGlob as v}from"../plugins/utils/glob.js";import{hashContentConfigDependency as y}from"../config-deps.js";import{runWithSqliteBusyRetry as b}from"./connection.js";import{createRouteQueryEvaluator as x,isRouteQueryStale as S}from"../plugins/utils/route-index.js";import{APP_DATA_ENTITY_KEY as C}from"../../shared/constants/app-data.js";import{refreshTermDocCounts as w,selectTermIdsOfDocuments as T,selectTermIdsOfFragments as E}from"./search-vocab.js";import{RETRYABLE_PROBLEM_CODES as D}from"../problems/codes.js";import{and as O,eq as k,inArray as A,sql as j}from"drizzle-orm";async function M(e){return await e.db.select({accessType:s.accessType,originFileId:s.originFileId,originFilePath:i.path,originPluginId:s.originPluginId,hook:s.hook,path:s.path,source:s.source,valueHash:s.valueHash}).from(s).leftJoin(i,k(s.originFileId,i.id)).orderBy(i.path,s.originPluginId,s.path,s.accessType)}function N(e,t){let n=/* @__PURE__ */ new Map,r=L(t);for(let t of e){if(t.source!==`config`||t.originFileId===null||t.originFilePath===null||r(t)===t.valueHash)continue;let e=`${t.originPluginId}:${t.originFilePath}`;n.has(e)||n.set(e,t)}return R([...n.values()])}function P(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){if(r.source===`config`||r.originFileId===null||r.originFilePath===null||F(r,t)===r.valueHash)continue;let e=`${r.originPluginId}:${r.originFilePath}`;n.has(e)||n.set(e,r)}return R([...n.values()])}function F(e,t){if(e.source===`glob`)return _(v(t.filesByPath.keys(),e.path));let n=t.filesByPath.get(e.path)??t.ignoredFilesByPath?.get(e.path);return e.accessType===`presence`?n?`present`:`absent`:n?.hash??null}function I(e,t,n){let r=/* @__PURE__ */ new Set,i=L(n.config);for(let a of e)a.originFileId!==null||a.hook!==t||r.has(a.originPluginId)||(a.source===`config`?i(a):F(a,n))!==a.valueHash&&r.add(a.originPluginId);return r}function L(e){let t=/* @__PURE__ */ new Map;return n=>{let r=`${n.accessType}\u0000${n.path}`,i=t.get(r);return i===void 0&&(i=y(e,n),t.set(r,i)),i}}function R(e){return e.sort((e,t)=>{let n=e.originFilePath.localeCompare(t.originFilePath);return n===0?e.originPluginId.localeCompare(t.originPluginId):n})}async function z(e,t){let r=await e.db.select({accessType:o.accessType,path:o.path,key:n.key,valueHash:o.valueHash}).from(o).innerJoin(n,k(o.entityId,n.id)).orderBy(n.key,o.path,o.accessType),i=/* @__PURE__ */ new Set;for(let e of r)y(t.config,e)!==e.valueHash&&i.add(e.key);let a=await U(e,{logger:t.logger,reason:`config dependency invalidation`,keys:[...i]});return a.invalidatedKeys.length>0&&t.logger?.debug(`Propagated config dependency invalidation`,{invalidatedKeys:a.invalidatedKeys.length}),a}async function B(e,t={}){let r=await e.db.selectDistinct({key:n.key}).from(l).innerJoin(n,k(l.entityId,n.id)).where(O(k(l.scope,`entity`),A(l.code,[...D]),k(n.isCurrent,1)));return U(e,{logger:t.logger,reason:`retryable problem invalidation`,keys:r.map(e=>e.key)})}async function V(e,t){let r=x(t.state,t.config).memoized(),i=/* @__PURE__ */ new Set;for(let e of t.rows)e.entityId===null||e.hook===`searchable`||i.has(e.entityId)||S(r,e)&&i.add(e.entityId);if(i.size===0)return{invalidatedKeys:[]};let a=await e.db.select({key:n.key}).from(n).where(A(n.id,[...i]));return U(e,{logger:t.logger,reason:`route query invalidation`,keys:a.map(e=>e.key)})}async function H(i,a){if(a.changedFilePaths.length===0)return{invalidatedKeys:[]};let o=/* @__PURE__ */ new Set,s=await i.db.select({key:n.key}).from(n).innerJoin(r,k(r.entityId,n.id)).where(j`${r.dependencyType} in ('file','origin') and ${r.dependencyRef} in ${a.changedFilePaths}`);for(let e of s)o.has(e.key)||o.add(e.key);let c=[...new Set(a.changedFilePaths.map(e).filter(e=>e!==void 0))];if(c.length>0){let e=await i.db.select({key:n.key}).from(n).innerJoin(t,k(t.entityId,n.id)).where(A(t.path,c));for(let t of e)o.add(t.key)}let l=a.membershipChangedPaths??[];if(l.length>0){let e=await i.db.select({key:n.key,pattern:r.dependencyRef}).from(n).innerJoin(r,k(r.entityId,n.id)).where(k(r.dependencyType,`glob`));for(let t of e){let e=g(t.pattern);l.some(e)&&o.add(t.key)}}let u=await U(i,{logger:a.logger,reason:`file dependency invalidation`,keys:[...o]});return u.invalidatedKeys.length>0&&a.logger?.debug(`Propagated entity invalidation`,{changedFilePaths:a.changedFilePaths.length,invalidatedKeys:u.invalidatedKeys.length}),u}async function U(e,t){let i=new Set(t.keys),a=new Set(i),o=[...i];for(;o.length>0;){let t=o;o=[];let i=await e.db.select({key:n.key}).from(n).innerJoin(r,k(r.entityId,n.id)).where(j`${r.dependencyType} = 'entity' and ${r.dependencyRef} in ${t}`);for(let e of i)a.has(e.key)||(a.add(e.key),o.push(e.key))}let s=t.markKeys===!1?[...a].filter(e=>!i.has(e)):[...a];return s.length===0?{invalidatedKeys:[]}:(await b(()=>e.db.update(n).set({status:`stale`,invalidationSeq:j`${n.invalidationSeq} + 1`}).where(O(A(n.key,s),k(n.isCurrent,1))),{logger:t.logger,operation:t.reason}),{invalidatedKeys:s})}async function W(e,t){return b(()=>e.db.transaction(e=>G(e)),{logger:t,operation:`garbage collect orphaned entities`})}async function G(e){let t=j`(${n.isSystem} = 0 or ${n.key} <> ${C}) and ${n.isCurrent} = 1 and not exists (
|
|
2
2
|
select 1
|
|
3
|
-
from ${
|
|
4
|
-
where ${
|
|
5
|
-
and ${
|
|
6
|
-
)`,[
|
|
7
|
-
select 1 from ${
|
|
8
|
-
where live.key = ${
|
|
9
|
-
)`),{removedOrphans:
|
|
10
|
-
select ${
|
|
11
|
-
)`);let
|
|
12
|
-
where ${
|
|
13
|
-
select ${
|
|
14
|
-
)`,i=j`select ${
|
|
15
|
-
where ${
|
|
16
|
-
select ${
|
|
17
|
-
)`,
|
|
18
|
-
select ${
|
|
19
|
-
)`),await e.delete(
|
|
20
|
-
select ${
|
|
21
|
-
)`),await e.delete(
|
|
22
|
-
select ${
|
|
23
|
-
)`);let
|
|
24
|
-
select ${
|
|
25
|
-
)`;await e.delete(
|
|
26
|
-
select ${
|
|
27
|
-
)`),await e.delete(
|
|
3
|
+
from ${r}
|
|
4
|
+
where ${r.entityId} = ${n.id}
|
|
5
|
+
and ${r.dependencyType} = 'origin'
|
|
6
|
+
)`,[i]=await e.select({id:n.id}).from(n).where(t).limit(1);return i!==void 0&&await K(e,t),await e.delete(n).where(j`${n.isCurrent} = 0 and not exists (
|
|
7
|
+
select 1 from ${n} as live
|
|
8
|
+
where live.key = ${n.key} and live.is_current = 1
|
|
9
|
+
)`),{removedOrphans:i!==void 0}}async function K(e,t){await e.delete(o).where(j`${o.entityId} in (
|
|
10
|
+
select ${n.id} from ${n} where ${t}
|
|
11
|
+
)`);let r=j`select ${u.id} from ${u}
|
|
12
|
+
where ${u.entityKey} in (
|
|
13
|
+
select ${n.key} from ${n} where ${t}
|
|
14
|
+
)`,i=j`select ${m.id} from ${m}
|
|
15
|
+
where ${m.entityKey} in (
|
|
16
|
+
select ${n.key} from ${n} where ${t}
|
|
17
|
+
)`,s=[...await T(e,r),...await E(e,i)];await e.delete(h).where(j`${h.docId} in (${r})`),await e.delete(f).where(j`${f.fragmentId} in (${i})`),await e.delete(d).where(j`${d.docId} in (${r})`),await e.delete(p).where(j`${p.fragmentId} in (${i})`),await e.delete(m).where(j`${m.id} in (${i})`),await w(e,s),await e.delete(u).where(j`${u.entityKey} in (
|
|
18
|
+
select ${n.key} from ${n} where ${t}
|
|
19
|
+
)`),await e.delete(c).where(j`${c.entityKey} in (
|
|
20
|
+
select ${n.key} from ${n} where ${t}
|
|
21
|
+
)`),await e.delete(l).where(j`${l.scope} = 'entity' and ${l.entityId} in (
|
|
22
|
+
select ${n.id} from ${n} where ${t}
|
|
23
|
+
)`);let g=j`${a.entityId} in (
|
|
24
|
+
select ${n.id} from ${n} where ${t}
|
|
25
|
+
)`;await e.delete(l).where(j`${l.scope} = 'link' and ${l.linkRefId} in (
|
|
26
|
+
select ${a.id} from ${a} where ${g}
|
|
27
|
+
)`),await e.delete(a).where(g),await e.delete(n).where(t)}export{N as computeDirtyConfigOrigins,P as computeDirtyFileOrigins,I as computeDirtyPluginScopedOrigins,W as garbageCollectOrphanedEntities,G as garbageCollectOrphanedEntitiesInTransaction,M as loadOriginDependencyRows,z as propagateConfigDependencyInvalidation,H as propagateEntityInvalidation,U as propagateEntityInvalidationFromKeys,B as propagateRetryableProblemInvalidation,V as propagateRouteQueryInvalidation};
|
|
@@ -60,14 +60,12 @@ export declare function bulkSyncOrigins(database: ContentLayerDatabase, items: r
|
|
|
60
60
|
fallbackRoutes?: BulkSyncFallbackRoutes;
|
|
61
61
|
}): Promise<void>;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
* files match the revisions include globs
|
|
65
|
-
* (build/CLI on, dev watch off).
|
|
63
|
+
* The revision snapshots a capturing run cuts: `trackedKeys` holds the entity keys whose
|
|
64
|
+
* files match the revisions include globs. Absent when the run captures none.
|
|
66
65
|
*/
|
|
67
66
|
export type EntityUpsertRevisionsOptions = {
|
|
68
67
|
max: number;
|
|
69
68
|
trackedKeys: ReadonlySet<string>;
|
|
70
|
-
capture: boolean;
|
|
71
69
|
};
|
|
72
70
|
/**
|
|
73
71
|
* Upserts entity descriptors (deduped by key, last-wins), generating ids for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hashJsonValue as e}from"./utils/json.js";import{entities as t,entityDeps as n,filePlugins as r,linkRefs as i,originDeps as a,routeDeps as o,routes as s}from"./schema.js";import{batchValues as c,normalizeBatchSize as l,runWithSqliteBusyRetry as u}from"./connection.js";import{generateEntityId as d}from"./entities.js";import{garbageCollectOrphanedEntitiesInTransaction as f}from"./invalidation.js";import{deleteProblemsForFilesTx as p,deleteProblemsForPluginHookTx as m,insertProblemsTx as h,problemRow as g,replaceGlobalProblemsForKeysTx as _}from"./problems.js";import{deleteOriginLinkRefsForFilesTx as v}from"./link-refs.js";import{detectMarkdocPayloadFlag as y}from"../markdown/server/render.js";import{cutEntityRevisionTx as b}from"../revisions/cut.js";import{writePluginHookState as x}from"./plugin-hook-state.js";import{replaceRouteQueryDepsTx as S}from"./route-query-deps.js";import{and as C,eq as w,inArray as T,sql as E}from"drizzle-orm";async function D(e,t){let[r]=await e.select({originFileId:n.originFileId}).from(n).where(E`${n.entityId} = ${t.entityId} and ${n.dependencyType} = 'origin'`).limit(1);if(await e.delete(n).where(E`${n.entityId} = ${t.entityId} and ${n.dependencyType} in ('file','entity','glob')`),t.deps.length===0)return;if(!r&&!t.isSystem)throw Error(`replaceEntityRuntimeDeps: entity ${t.entityId} has no origin dep row.`);let i=/* @__PURE__ */ new Set,a=[];for(let e of t.deps){let n=e.kind===`file`?e.path:e.kind===`glob`?e.pattern:e.key,o=`${e.kind} ${n}`;i.has(o)||(i.add(o),a.push({entityId:t.entityId,originFileId:r?.originFileId??null,originPluginId:t.originPluginId,hook:`loader`,dependencyType:e.kind,dependencyRef:n}))}for(let t of c(a,500))await e.insert(n).values(t)}async function O(e,t,c){let d=c?.extractAllOrigins??[],p=c?.extractAllFailures??[],m=c?.globalProblems,v=c?.fallbackRoutes,y=(v?.removedSlugs.length??0)+(v?.added.length??0);if(t.length===0&&d.length===0&&p.length===0&&m===void 0&&y===0)return;let b=l(c?.batchSize);await u(()=>e.db.transaction(async e=>{await k(e,{fileIds:t.map(e=>e.fileId),extractAllOrigins:d,extractAllFailures:p,fallbackRoutes:v,batchSize:b}),await F(A(t),b,t=>e.insert(r).values(t));let l=j(t,d,v);await F(l.routes,b,t=>e.insert(s).values(t)),await F(l.routeDeps,b,t=>e.insert(o).values(t));let u=await I(e,l.entityDescriptors,b,c?.revisions);await F(l.originDeps,b,t=>e.insert(a).values(t)),await F(l.linkRefs,b,t=>e.insert(i).values(t));let y=[...l.problems,...p.map(e=>g(e.problem,{scope:`origin`,originFileId:null,originPluginId:e.pluginId,hook:`extractAll`}))];await h(e,y,b),m&&await _(e,m.source,m.keys,m.newProblems),l.entityDescriptors.length>0&&await F(P(l.entityOrigins,u),b,t=>e.insert(n).values(t));for(let t of d)await S(e,{originPluginId:t.originPluginId,hook:`extractAll`,entityId:null,dependencies:t.routeQueries}),await x(e,{pluginId:t.originPluginId,hook:`extractAll`,fingerprint:t.fingerprint});await f(e)}),{logger:c?.logger,operation:`bulk sync origins`})}async function k(e,t){for(let i of c(t.fileIds,t.batchSize))await e.delete(r).where(T(r.fileId,i)),await e.delete(o).where(T(o.originFileId,i)),await e.delete(s).where(T(s.sourceId,i)),await e.delete(n).where(T(n.originFileId,i)),await e.delete(a).where(T(a.originFileId,i));await p(e,t.fileIds,t.batchSize),await v(e,t.fileIds,t.batchSize),await m(e,[...t.extractAllOrigins.map(e=>e.originPluginId),...t.extractAllFailures.map(e=>e.pluginId)],`extractAll`);let i=t.extractAllOrigins.map(e=>e.originPluginId);for(let r of c(i,t.batchSize))await e.delete(o).where(E`${o.originFileId} is null and ${o.hook} = 'extractAll' and ${T(o.originPluginId,r)}`),await e.delete(s).where(E`${s.sourceId} is null and ${T(s.pluginId,r)}`),await e.delete(n).where(E`${n.originFileId} is null and ${n.hook} = 'extractAll' and ${T(n.originPluginId,r)}`),await e.delete(a).where(E`${a.originFileId} is null and ${a.hook} = 'extractAll' and ${T(a.originPluginId,r)}`);if(t.fallbackRoutes){let{pluginId:n,removedSlugs:r,added:i}=t.fallbackRoutes,a=[.../* @__PURE__ */ new Set([...r,...i.map(e=>e.slug)])];for(let r of c(a,t.batchSize))await e.delete(s).where(E`${s.sourceId} is null and ${s.pluginId} = ${n} and ${T(s.slug,r)}`)}}function A(e){let t=[];for(let n of e)for(let e of n.plugins)t.push({fileId:n.fileId,pluginId:e.id,pluginVersion:e.version});return t}function j(e,t,n){let r={routes:[],routeDeps:[],originDeps:[],entityDescriptors:[],entityOrigins:[],problems:[],linkRefs:[]};for(let t of e)for(let e of t.origins)N(e,r);for(let e of t)N(e,r);for(let e of n?.added??[])r.routes.push(M(e,null));return r}function M(e,t){return{metadata:e.metadata,pluginId:e.pluginId,routeId:e.routeId,sidebarSubtreeEntityKey:e.sidebarSubtreeEntityKey,wildcardPrefix:e.wildcardPrefix??!1,slug:e.slug,requestedSlug:e.requestedSlug,slugType:e.slugType,sourceId:t,template:e.template,versionGroup:e.versionGroup,version:e.version,locale:e.locale,isFallback:e.isFallback,canonicalSlug:e.canonicalSlug}}function N(e,t){for(let n of e.routes)t.routes.push(M(n,e.originFileId));for(let n of e.routeDependencies)t.routeDeps.push({args:n.args,dependencyType:n.dependencyType,key:n.key,originFileId:e.originFileId,originPluginId:e.originPluginId,hook:e.hook,routeSlug:n.routeSlug,target:n.target});for(let n of e.originDependencies)t.originDeps.push({accessType:n.accessType,originFileId:e.originFileId,originPluginId:e.originPluginId,hook:e.hook,source:n.source,path:n.path,valueHash:n.valueHash});for(let n of e.problems)t.problems.push(g(n,{scope:`origin`,originFileId:e.originFileId,originPluginId:e.originPluginId,hook:e.hook}));e.entities.length>0&&(t.entityDescriptors.push(...e.entities),t.entityOrigins.push({originFileId:e.originFileId,originFilePath:e.originFilePath,originPluginId:e.originPluginId,hook:e.hook,descriptors:e.entities}));for(let n of e.linkRefs??[]){let r=n.filePath??e.originFilePath;r!==null&&t.linkRefs.push({entityId:null,originFileId:e.originFileId,originPluginId:e.originPluginId,filePath:r,kind:n.kind,raw:n.raw,targetKind:n.targetKind,target:n.target,fragment:n.fragment,title:n.title??null,range:n.range??null})}}function P(e,t){let n=[];for(let r of e)for(let e of r.descriptors){let i=t.get(e.key);if(!i)throw Error(`bulkSyncOrigins: missing entity id for key "${e.key}" after upsert.`);n.push({dependencyRef:r.originFilePath??r.originPluginId,dependencyType:`origin`,entityId:i,originFileId:r.originFileId,originPluginId:r.originPluginId,hook:r.hook})}return n}async function F(e,t,n){for(let r of c(e,t))r.length>0&&await n(r)}async function I(n,r,i=500,a){if(r.length===0)return/* @__PURE__ */ new Map;let o=/* @__PURE__ */ new Map;for(let e of r)o.set(e.key,e);let s=[...o.keys()],l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map;for(let e of c(s,i)){let r=await n.select({id:t.id,key:t.key,kind:t.kind,type:t.type,metadata:t.metadata,pluginId:t.pluginId,loaderId:t.loaderId,loaderArgs:t.loaderArgs,data:t.data,markdoc:t.markdoc,dataHash:t.dataHash,version:t.version,revisionCreatedAt:t.revisionCreatedAt}).from(t).where(C(T(t.key,e),w(t.isCurrent,1)));for(let e of r)l.set(e.key,e.id),u.set(e.key,e)}let f=Date.now(),p=[];for(let t of o.values()){let r=u.get(t.key),i=r?.id??d();l.set(t.key,i);let o=t.kind===`inline`?`ready`:t.shouldInvalidateValue||!r?`stale`:`ready`,s=t.kind===`inline`?t.value:null,c=s===null?null:e(s),m=r?.revisionCreatedAt??f;t.kind===`inline`&&r&&(r.dataHash??null)!==c&&(a?.
|
|
1
|
+
import{hashJsonValue as e}from"./utils/json.js";import{entities as t,entityDeps as n,filePlugins as r,linkRefs as i,originDeps as a,routeDeps as o,routes as s}from"./schema.js";import{batchValues as c,normalizeBatchSize as l,runWithSqliteBusyRetry as u}from"./connection.js";import{generateEntityId as d}from"./entities.js";import{garbageCollectOrphanedEntitiesInTransaction as f}from"./invalidation.js";import{deleteProblemsForFilesTx as p,deleteProblemsForPluginHookTx as m,insertProblemsTx as h,problemRow as g,replaceGlobalProblemsForKeysTx as _}from"./problems.js";import{deleteOriginLinkRefsForFilesTx as v}from"./link-refs.js";import{detectMarkdocPayloadFlag as y}from"../markdown/server/render.js";import{cutEntityRevisionTx as b}from"../revisions/cut.js";import{writePluginHookState as x}from"./plugin-hook-state.js";import{replaceRouteQueryDepsTx as S}from"./route-query-deps.js";import{and as C,eq as w,inArray as T,sql as E}from"drizzle-orm";async function D(e,t){let[r]=await e.select({originFileId:n.originFileId}).from(n).where(E`${n.entityId} = ${t.entityId} and ${n.dependencyType} = 'origin'`).limit(1);if(await e.delete(n).where(E`${n.entityId} = ${t.entityId} and ${n.dependencyType} in ('file','entity','glob')`),t.deps.length===0)return;if(!r&&!t.isSystem)throw Error(`replaceEntityRuntimeDeps: entity ${t.entityId} has no origin dep row.`);let i=/* @__PURE__ */ new Set,a=[];for(let e of t.deps){let n=e.kind===`file`?e.path:e.kind===`glob`?e.pattern:e.key,o=`${e.kind} ${n}`;i.has(o)||(i.add(o),a.push({entityId:t.entityId,originFileId:r?.originFileId??null,originPluginId:t.originPluginId,hook:`loader`,dependencyType:e.kind,dependencyRef:n}))}for(let t of c(a,500))await e.insert(n).values(t)}async function O(e,t,c){let d=c?.extractAllOrigins??[],p=c?.extractAllFailures??[],m=c?.globalProblems,v=c?.fallbackRoutes,y=(v?.removedSlugs.length??0)+(v?.added.length??0);if(t.length===0&&d.length===0&&p.length===0&&m===void 0&&y===0)return;let b=l(c?.batchSize);await u(()=>e.db.transaction(async e=>{await k(e,{fileIds:t.map(e=>e.fileId),extractAllOrigins:d,extractAllFailures:p,fallbackRoutes:v,batchSize:b}),await F(A(t),b,t=>e.insert(r).values(t));let l=j(t,d,v);await F(l.routes,b,t=>e.insert(s).values(t)),await F(l.routeDeps,b,t=>e.insert(o).values(t));let u=await I(e,l.entityDescriptors,b,c?.revisions);await F(l.originDeps,b,t=>e.insert(a).values(t)),await F(l.linkRefs,b,t=>e.insert(i).values(t));let y=[...l.problems,...p.map(e=>g(e.problem,{scope:`origin`,originFileId:null,originPluginId:e.pluginId,hook:`extractAll`}))];await h(e,y,b),m&&await _(e,m.source,m.keys,m.newProblems),l.entityDescriptors.length>0&&await F(P(l.entityOrigins,u),b,t=>e.insert(n).values(t));for(let t of d)await S(e,{originPluginId:t.originPluginId,hook:`extractAll`,entityId:null,dependencies:t.routeQueries}),await x(e,{pluginId:t.originPluginId,hook:`extractAll`,fingerprint:t.fingerprint});await f(e)}),{logger:c?.logger,operation:`bulk sync origins`})}async function k(e,t){for(let i of c(t.fileIds,t.batchSize))await e.delete(r).where(T(r.fileId,i)),await e.delete(o).where(T(o.originFileId,i)),await e.delete(s).where(T(s.sourceId,i)),await e.delete(n).where(T(n.originFileId,i)),await e.delete(a).where(T(a.originFileId,i));await p(e,t.fileIds,t.batchSize),await v(e,t.fileIds,t.batchSize),await m(e,[...t.extractAllOrigins.map(e=>e.originPluginId),...t.extractAllFailures.map(e=>e.pluginId)],`extractAll`);let i=t.extractAllOrigins.map(e=>e.originPluginId);for(let r of c(i,t.batchSize))await e.delete(o).where(E`${o.originFileId} is null and ${o.hook} = 'extractAll' and ${T(o.originPluginId,r)}`),await e.delete(s).where(E`${s.sourceId} is null and ${T(s.pluginId,r)}`),await e.delete(n).where(E`${n.originFileId} is null and ${n.hook} = 'extractAll' and ${T(n.originPluginId,r)}`),await e.delete(a).where(E`${a.originFileId} is null and ${a.hook} = 'extractAll' and ${T(a.originPluginId,r)}`);if(t.fallbackRoutes){let{pluginId:n,removedSlugs:r,added:i}=t.fallbackRoutes,a=[.../* @__PURE__ */ new Set([...r,...i.map(e=>e.slug)])];for(let r of c(a,t.batchSize))await e.delete(s).where(E`${s.sourceId} is null and ${s.pluginId} = ${n} and ${T(s.slug,r)}`)}}function A(e){let t=[];for(let n of e)for(let e of n.plugins)t.push({fileId:n.fileId,pluginId:e.id,pluginVersion:e.version});return t}function j(e,t,n){let r={routes:[],routeDeps:[],originDeps:[],entityDescriptors:[],entityOrigins:[],problems:[],linkRefs:[]};for(let t of e)for(let e of t.origins)N(e,r);for(let e of t)N(e,r);for(let e of n?.added??[])r.routes.push(M(e,null));return r}function M(e,t){return{metadata:e.metadata,pluginId:e.pluginId,routeId:e.routeId,sidebarSubtreeEntityKey:e.sidebarSubtreeEntityKey,wildcardPrefix:e.wildcardPrefix??!1,slug:e.slug,requestedSlug:e.requestedSlug,slugType:e.slugType,sourceId:t,template:e.template,versionGroup:e.versionGroup,version:e.version,locale:e.locale,isFallback:e.isFallback,canonicalSlug:e.canonicalSlug}}function N(e,t){for(let n of e.routes)t.routes.push(M(n,e.originFileId));for(let n of e.routeDependencies)t.routeDeps.push({args:n.args,dependencyType:n.dependencyType,key:n.key,originFileId:e.originFileId,originPluginId:e.originPluginId,hook:e.hook,routeSlug:n.routeSlug,target:n.target});for(let n of e.originDependencies)t.originDeps.push({accessType:n.accessType,originFileId:e.originFileId,originPluginId:e.originPluginId,hook:e.hook,source:n.source,path:n.path,valueHash:n.valueHash});for(let n of e.problems)t.problems.push(g(n,{scope:`origin`,originFileId:e.originFileId,originPluginId:e.originPluginId,hook:e.hook}));e.entities.length>0&&(t.entityDescriptors.push(...e.entities),t.entityOrigins.push({originFileId:e.originFileId,originFilePath:e.originFilePath,originPluginId:e.originPluginId,hook:e.hook,descriptors:e.entities}));for(let n of e.linkRefs??[]){let r=n.filePath??e.originFilePath;r!==null&&t.linkRefs.push({entityId:null,originFileId:e.originFileId,originPluginId:e.originPluginId,filePath:r,kind:n.kind,raw:n.raw,targetKind:n.targetKind,target:n.target,fragment:n.fragment,title:n.title??null,range:n.range??null})}}function P(e,t){let n=[];for(let r of e)for(let e of r.descriptors){let i=t.get(e.key);if(!i)throw Error(`bulkSyncOrigins: missing entity id for key "${e.key}" after upsert.`);n.push({dependencyRef:r.originFilePath??r.originPluginId,dependencyType:`origin`,entityId:i,originFileId:r.originFileId,originPluginId:r.originPluginId,hook:r.hook})}return n}async function F(e,t,n){for(let r of c(e,t))r.length>0&&await n(r)}async function I(n,r,i=500,a){if(r.length===0)return/* @__PURE__ */ new Map;let o=/* @__PURE__ */ new Map;for(let e of r)o.set(e.key,e);let s=[...o.keys()],l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map;for(let e of c(s,i)){let r=await n.select({id:t.id,key:t.key,kind:t.kind,type:t.type,metadata:t.metadata,pluginId:t.pluginId,loaderId:t.loaderId,loaderArgs:t.loaderArgs,data:t.data,markdoc:t.markdoc,dataHash:t.dataHash,version:t.version,revisionCreatedAt:t.revisionCreatedAt}).from(t).where(C(T(t.key,e),w(t.isCurrent,1)));for(let e of r)l.set(e.key,e.id),u.set(e.key,e)}let f=Date.now(),p=[];for(let t of o.values()){let r=u.get(t.key),i=r?.id??d();l.set(t.key,i);let o=t.kind===`inline`?`ready`:t.shouldInvalidateValue||!r?`stale`:`ready`,s=t.kind===`inline`?t.value:null,c=s===null?null:e(s),m=r?.revisionCreatedAt??f;t.kind===`inline`&&r&&(r.dataHash??null)!==c&&(a?.trackedKeys.has(t.key)&&await b(n,{current:r,max:a.max}),m=Math.max(f,r.revisionCreatedAt+1)),p.push({id:i,key:t.key,kind:t.kind,type:t.type,metadata:t.metadata,pluginId:t.pluginId,loaderId:t.loaderId,loaderArgs:t.loaderArgs,status:o,data:s,markdoc:s===null?null:y(JSON.stringify(s)),dataHash:c,isSystem:+!!t.isSystem,version:t.version,isCurrent:1,revisionCreatedAt:m})}for(let e of c(p,i))e.length!==0&&await n.insert(t).values(e).onConflictDoUpdate({target:t.id,set:{kind:E.raw(`excluded.kind`),type:E.raw(`excluded.type`),metadata:E.raw(`CASE WHEN excluded.kind = 'inline' OR excluded.status = 'stale' THEN excluded.metadata ELSE entities.metadata END`),pluginId:E.raw(`excluded.plugin_id`),loaderId:E.raw(`excluded.loader_id`),loaderArgs:E.raw(`excluded.loader_args`),status:E.raw(`CASE WHEN excluded.kind = 'inline' OR excluded.status = 'stale' THEN excluded.status ELSE entities.status END`),data:E.raw(`CASE WHEN excluded.kind = 'inline' THEN excluded.data ELSE entities.data END`),markdoc:E.raw(`CASE WHEN excluded.kind = 'inline' THEN excluded.markdoc ELSE entities.markdoc END`),dataHash:E.raw(`CASE WHEN excluded.kind = 'inline' THEN excluded.data_hash ELSE entities.data_hash END`),isSystem:E.raw(`excluded.is_system`),version:E.raw(`excluded.version`),revisionCreatedAt:E.raw(`excluded.revision_created_at`),invalidationSeq:E`case when excluded.status = 'stale' then ${t.invalidationSeq} + 1 else ${t.invalidationSeq} end`}});return l}export{O as bulkSyncOrigins,D as replaceEntityRuntimeDeps,I as upsertEntityDescriptors};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRecordingPluginIO as e}from"../plugins/io.js";import{createTrackedRedoclyConfig as t}from"../config-deps.js";import{dedupeFileDependencies as n}from"../plugins/execute.js";import{dedupeRouteQueryDependencies as r}from"../plugins/utils/route-index.js";import"../plugins/index.js";import{extractAllFailedProblem as i}from"../problems/producers.js";import{buildHookSourceFiles as a,createHookEntityStore as o,resolvePluginHookTriggers as s}from"./hook-inputs.js";import{routeKeepsSlug as c}from"./slugger/drop-colliding-routes.js";import{normalizePluginArtifacts as l}from"./normalize-artifacts.js";import{applyOriginRoutesToWorkingState as u,removeOriginFromWorkingState as d}from"./working-state.js";async function f(c){let f=[],p=[],m=c.context.pluginRegistry.listExtractAllPlugins();if(
|
|
1
|
+
import{createRecordingPluginIO as e}from"../plugins/io.js";import{createTrackedRedoclyConfig as t}from"../config-deps.js";import{dedupeFileDependencies as n}from"../plugins/execute.js";import{dedupeRouteQueryDependencies as r}from"../plugins/utils/route-index.js";import"../plugins/index.js";import{extractAllFailedProblem as i}from"../problems/producers.js";import{buildHookSourceFiles as a,createHookEntityStore as o,resolvePluginHookTriggers as s}from"./hook-inputs.js";import{routeKeepsSlug as c}from"./slugger/drop-colliding-routes.js";import{normalizePluginArtifacts as l}from"./normalize-artifacts.js";import{applyOriginRoutesToWorkingState as u,removeOriginFromWorkingState as d}from"./working-state.js";async function f(c){let f=[],p=[],m=c.materializer.state,h=c.context.pluginRegistry.listExtractAllPlugins();if(h.length===0)return{pending:f,failures:p};let g=s(`extractAll`,c.context,m,c.originRows,c.routeQueryRows,c.hookState),_=c.context.pluginRegistry.list().map(e=>e.id);for(let s of h){if(!g.shouldRun(s)||!s.content?.extractAll)continue;let h=c.logger.child(`content-layer:plugin:${s.id}`),v=t(c.context.config),y=[],b=[],x=e=>b.push(e),S=await a(g.matchedPathsOf(s),c.files,{database:c.database,workingState:m}),C;try{C=await s.content.extractAll({files:S,io:e(c.context.platform.fs,c.context.contentDir,()=>m.filesByPath.keys(),e=>y.push(e)),config:v.config,entities:o(c.database,c.materializer,x),logger:h})}catch(e){let t=e instanceof Error?e:Error(String(e));h.warn(`Content plugin extractAll failed`,{plugin:s.id,error:t.message}),p.push({pluginId:s.id,problem:i({pluginId:s.id,message:t.message})});continue}let w=l({context:c.context,filePath:null,pluginId:s.id,routeDrafts:C?.routes??[],standaloneEntities:C?.entities??[]});d(m,_,s.id,null),u(m,_,s.id,null,w.routes),f.push({pluginId:s.id,inputsHash:g.fingerprintOf(s),routes:w.routes,routeDependencies:w.routeDependencies,entities:w.entities,originDependencies:[...v.collectDependencies().map(e=>Object.assign(e,{source:`config`})),...n(y)],routeQueries:r(b)})}return{pending:f,failures:p}}function p(e,t){if(t.size!==0)for(let n of e){n.routes=n.routes.filter(e=>c(t,n.pluginId,null,e));let e=new Set(n.routes.map(e=>`${e.routeId}\u0000${e.requestedSlug}`));n.routeDependencies=n.routeDependencies.filter(t=>e.has(`${t.routeId}\u0000${t.routeSlug}`))}}export{p as dropCollidingExtractAllRoutes,f as runExtractAllPhase};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hashJsonValue as e,isJsonObject as t,toJsonObject as n}from"../database/utils/json.js";import
|
|
1
|
+
import{hashJsonValue as e,isJsonObject as t,toJsonObject as n}from"../database/utils/json.js";import{compareStrings as r}from"../../shared/utils/compare-strings.js";import{createRecordingPluginIO as i}from"../plugins/io.js";import{createTrackedRedoclyConfig as a}from"../config-deps.js";import{dedupeFileDependencies as o,runContentPluginFinalize as s}from"../plugins/execute.js";import{dedupeRouteQueryDependencies as c}from"../plugins/utils/route-index.js";import"../../shared/constants/app-data.js";import{appDataSystemEntityDescriptor as l,isAppDataFragment as u}from"../plugins/internal/app-data/index.js";import"../plugins/index.js";import{createProblem as d}from"../problems/codes.js";import{propagateEntityInvalidationFromKeys as f}from"../database/invalidation.js";import{listGlobalProblems as p,problemRow as m}from"../database/problems.js";import{listStaticFileRecords as h,replaceStaticFileRows as g}from"../database/static-files.js";import{createSearchHandle as _}from"../search/store.js";import{appDataNamespaceConflictProblem as v,attachConflictProblem as y,finalizeFailedProblem as b,keysBlamingPlugins as x}from"../problems/producers.js";import{buildHookSourceFiles as S,createHookEntityStore as C,finalizeHookInputs as w,resolvePluginHookTriggers as T}from"./hook-inputs.js";import{loadPluginScopedRouteDepOwners as E,registerSystemEntities as D,replaceFinalizeArtifacts as O,replaceFinalizeProblems as k,replaceFinalizeReads as A}from"../database/finalize.js";import{createEntityDescriber as j,normalizeRouteDependency as M}from"./normalize-artifacts.js";import{collectStaticFileRows as N,settleStaticFileClaims as P}from"../static/registry.js";async function F(e){let t=e.materializer.state,n=T(`finalize`,e.context,t,e.pluginScopedOriginRows,e.routeQueryRows,e.hookState,w(e.localeContext)),r=e.context.pluginRegistry.listFinalizePlugins().filter(n.shouldRun).map(e=>({plugin:e,inputsHash:n.fingerprintOf(e)})),i=r.map(({plugin:e})=>e.id),a=await L(e.database,i),o=/* @__PURE__ */ new Map,s=R(t,e.context),c=/* @__PURE__ */ new Map,l=[],u=[],d=[],f=[];for(let{plugin:t,inputsHash:i}of r){let r=await I({plugin:t,context:e.context,database:e.database,localeContext:e.localeContext,materializer:e.materializer,processedFiles:e.files,matchedPaths:n.matchedPathsOf(t),routeQueries:n.evaluator,attachOwnerByKey:a,staticFilesByPlugin:o,namespaceOwners:s,fragmentUpdates:c,pendingTrackedDependencyWrites:l,inputsHash:i,logger:e.logger,collectEntities:e.collectEntities,conflicts:d,staticProblems:f});for(let e of r.problems)u.push({pluginId:t.id,problem:e})}c.size>0&&await q(e.database,e.context,c);let h=new Set(e.context.pluginRegistry.listFinalizePlugins().map(e=>e.id));if(await W({context:e.context,database:e.database,workingState:t},o,f,h),i.length>0){let t=await p(e.database,`finalize`),n=U(t,new Set(i),h);await k(e.database,{pluginIds:i,pluginProblems:u.map(({pluginId:e,problem:t})=>m(t,{scope:`origin`,originFileId:null,originPluginId:e,hook:`finalize`})),globalKeys:[.../* @__PURE__ */ new Set([...d.map(e=>e.key),...x(t,n)])],globalProblems:d.map(e=>m(e.problem,{scope:`global`,source:`finalize`,key:e.key})),logger:e.logger})}for(let t of l)await V(e.database,t);return{ranPluginIds:i}}async function I(e){let t=e.logger.child(`content-layer:plugin:${e.plugin.id}`),r=e.materializer.state,o=await S(e.matchedPaths,e.processedFiles,{database:e.database,workingState:r}),c=a(e.context.config),l=[],u=i(e.context.platform.fs,e.context.contentDir,()=>r.filesByPath.keys(),e=>l.push(e)),f=[],p=e=>f.push(e),m=await s(e.plugin,{files:o,routes:e.routeQueries.index(p),io:u,config:c.config,localeContext:e.localeContext,entities:C(e.database,e.materializer,p),search:_(e.database),logger:t});if(!m.ok)return{problems:[b({pluginId:e.plugin.id,message:m.error.message})]};let h=m.value??{};return e.fragmentUpdates.set(e.plugin.id,h.appData===void 0?B(e.plugin.id,e.namespaceOwners):z({pluginId:e.plugin.id,appData:n(h.appData),namespaceOwners:e.namespaceOwners,conflicts:e.conflicts})),e.staticFilesByPlugin.set(e.plugin.id,await H({plugin:e.plugin,result:h,workingState:r,context:e.context,database:e.database,attachOwnerByKey:e.attachOwnerByKey,recordFileDependency:e=>l.push(e),conflicts:e.conflicts,staticProblems:e.staticProblems,logger:t,collectEntities:e.collectEntities})),e.pendingTrackedDependencyWrites.push({pluginId:e.plugin.id,inputsHash:e.inputsHash,configDependencies:c.collectDependencies(),fileDependencies:l,routeQueryDependencies:f,logger:t}),{problems:(h.problems??[]).map(d)}}async function L(e,t){let n=await E(e,t);return new Map(n.map(e=>[`${e.routeSlug}\u0000${e.key}`,e.originPluginId]))}function R(e,n){let r=/* @__PURE__ */ new Map,i=e.entitiesByKey.get(`app-data`)?.loaderArgs??null,a=t(i)&&t(i.fragments)?i.fragments:{},o=new Set(n.pluginRegistry.listFinalizePlugins().map(e=>e.id));for(let[e,t]of Object.entries(a))u(t)&&o.has(t.owner)&&r.set(e,t.owner);return r}function z(e){B(e.pluginId,e.namespaceOwners);let t={};for(let[n,r]of Object.entries(e.appData)){let i=e.namespaceOwners.get(n);if(i!==void 0&&i!==e.pluginId){e.conflicts.push(v({namespace:n,ownerPluginId:i,pluginId:e.pluginId}));continue}e.namespaceOwners.set(n,e.pluginId),t[n]=r}return t}function B(e,t){for(let[n,r]of t)r===e&&t.delete(n);return null}async function V(e,t){let n=[...t.configDependencies.map(e=>({...e,source:`config`})),...o(t.fileDependencies)];await A(e,{originPluginId:t.pluginId,fingerprint:t.inputsHash,dependencies:n,routeQueries:c(t.routeQueryDependencies),logger:t.logger})}async function H(t){let n=G({context:t.context,pluginId:t.plugin.id,result:t.result,state:t.workingState,attachOwnerByKey:t.attachOwnerByKey,recordFileDependency:t.recordFileDependency,conflicts:t.conflicts,staticProblems:t.staticProblems,logger:t.logger});await O(t.database,{originPluginId:t.plugin.id,routeDependencies:n.routeDependencies,entities:n.entities,logger:t.logger}),t.collectEntities?.(n.entities);let r=n.entities.flatMap(({key:n,kind:r,value:i})=>r===`inline`&&t.workingState.entitiesByKey.get(n)?.dataHash!==(i===null?null:e(i))?[n]:[]);if(r.length>0){let{invalidatedKeys:e}=await f(t.database,{keys:r,reason:`invalidate finalize entity readers`,markKeys:!1,logger:t.logger});for(let n of e){let e=t.workingState.entitiesByKey.get(n);e&&(e.status=`stale`)}}return n.staticFiles}function U(e,t,n){let r=new Set(t);for(let t of e){let e=t.data===null?void 0:t.data.pluginId;typeof e==`string`&&!n.has(e)&&r.add(e)}return r}async function W(e,t,n,r){let i=await h(e.database),a=await p(e.database,`static`),o=i.filter(e=>!t.has(e.ownerPluginId)),s=P({kept:o,collected:[...t],routeBySlug:e.workingState.routeBySlug,reservedSlugs:e.context.pluginRegistry.listReservedSlugs(),problems:n}),c=U(a,new Set(t.keys()),r),l=/* @__PURE__ */ new Set([...n.map(e=>e.key),...o.map(e=>e.path),...x(a,c)]);await g(e.database,{ownerPluginIds:[...s.keys()],rows:[...s].flatMap(([e,t])=>t.map(t=>({...t,ownerPluginId:e}))),problems:{keys:[...l],newProblems:n.map(e=>m(e.problem,{scope:`global`,source:`static`,key:e.key}))}})}function G(e){let t=/* @__PURE__ */ new Map,n=[],i=j(e.context,e.pluginId),a=e=>{t.set(e.key,e)};for(let t of e.result.entities??[])a(i(t));for(let t of e.result.attach??[])K({attachment:t,describeEntity:i,pluginId:e.pluginId,state:e.state,attachOwnerByKey:e.attachOwnerByKey,conflicts:e.conflicts,registerEntity:a,routeDependencies:n});let o=N({pluginId:e.pluginId,declarations:e.result.staticFiles??[],filesByPath:e.state.filesByPath,registerProducer:e=>{let t={...i(e.producer),shouldInvalidateValue:!1};return a(t),t.key},recordFileDependency:e.recordFileDependency,problems:e.staticProblems});return{routeDependencies:n,entities:[...t.values()].sort((e,t)=>r(e.key,t.key)),staticFiles:o}}function K(e){let{attachment:t}=e;if(e.state.routeBySlug.get(t.slug))for(let[n,r]of Object.entries(t.deps)){let i=`${t.slug}\u0000${n}`,a=e.attachOwnerByKey.get(i);if(a!==void 0){a!==e.pluginId&&e.conflicts.push(y({slug:t.slug,key:n,ownerPluginId:a,pluginId:e.pluginId}));continue}e.attachOwnerByKey.set(i,e.pluginId),e.routeDependencies.push(M({dependency:r,describeEntity:e.describeEntity,key:n,registerEntity:e.registerEntity,routeSlug:t.slug}))}}async function q(e,t,n){await D(e,[l({fragmentUpdates:n})],{logger:t.logger.child(`content-layer:db`)})}export{U as claimantsToReplace,F as runFinalizePhase};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hashJsonValue as e}from"../database/utils/json.js";import{compareStrings as t}from"../../shared/utils/compare-strings.js";import{matchesContentPluginFilter as n}from"../plugins/registry.js";import{createSourceFile as r}from"../plugins/source-file.js";import{createEntityStore as i,hashEntityRead as a}from"../database/entity-store.js";import{createRouteQueryEvaluator as o,isRouteQueryStale as s}from"../plugins/utils/route-index.js";import"../plugins/index.js";import{computeDirtyPluginScopedOrigins as c}from"../database/invalidation.js";import{loadFileManifestsByPaths as l}from"../database/files.js";
|
|
1
|
+
import{hashJsonValue as e}from"../database/utils/json.js";import{compareStrings as t}from"../../shared/utils/compare-strings.js";import{matchesContentPluginFilter as n}from"../plugins/registry.js";import{createSourceFile as r}from"../plugins/source-file.js";import{createEntityStore as i,hashEntityRead as a}from"../database/entity-store.js";import{createRouteQueryEvaluator as o,isRouteQueryStale as s}from"../plugins/utils/route-index.js";import"../plugins/index.js";import{computeDirtyPluginScopedOrigins as c}from"../database/invalidation.js";import{loadFileManifestsByPaths as l}from"../database/files.js";function u(e){return[e.defaultLocale,[...e.locales]]}function d(t,n,r,i,a,l,u){let d=new Set(c(i,t,{config:n.config,filesByPath:r.filesByPath,ignoredFilesByPath:r.ignoredFilesByPath})),f=o(r,n.config),m=f.memoized();for(let e of a)e.hook===t&&e.entityId===null&&!d.has(e.originPluginId)&&s(m,e)&&d.add(e.originPluginId);let h=/* @__PURE__ */ new Map,g=e=>{let t=h.get(e.id);return t||(t=p(e,r.filesByPath),h.set(e.id,t)),t},_=t=>e(u===void 0?[t.version,g(t)]:[t.version,g(t),u]);return{evaluator:f,fingerprintOf:_,matchedPathsOf:e=>g(e).map(([e])=>e),shouldRun:e=>d.has(e.id)||l[t].get(e.id)!==_(e)}}function f(e,t,n,r,i,a,o){let s=d(e,t,n,r,i,a,o);return(e===`extractAll`?t.pluginRegistry.listExtractAllPlugins():t.pluginRegistry.listFinalizePlugins()).some(s.shouldRun)}function p(e,r){let i=[];for(let[t,a]of r)n(e.content?.filter,t)&&i.push([t,a.hash]);return i.sort((e,n)=>t(e[0],n[0]))}async function m(e,t,n){let i=new Map(t.map(e=>[e.path,e])),a=e.filter(e=>i.get(e)?.manifest===void 0),o=a.length>0?await l(n.database,a):/* @__PURE__ */ new Map,s=[];for(let t of e){let e=n.workingState.filesByPath.get(t);if(!e)continue;let a=i.get(t)?.manifest??o.get(t)??{};s.push(r({path:t,hash:e.hash,manifest:a}))}return s}function h(e,t,n){let{state:r}=t;return i({database:e,state:r,materialize:t.materialize,onEntityRead:e=>n({kind:`entity`,argument:e,resultHash:a(r,e)}),record:n})}export{m as buildHookSourceFiles,h as createHookEntityStore,u as finalizeHookInputs,f as hasAnyPluginHookTrigger,d as resolvePluginHookTriggers};
|