@redocly/framework 1.0.0-next.2 → 1.0.0-next.4
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/vite-config.js +2 -2
- package/dist/bundler/dev/materialization-sweeper.js +1 -1
- 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/user-markdoc-schema.js +1 -1
- package/dist/bundler/vite-config.base.js +8 -8
- package/dist/cli/args.js +1 -1
- package/dist/cli/commands/build.js +1 -1
- package/dist/cli/commands/dev.js +1 -1
- package/dist/cli/commands/ingest.js +1 -1
- package/dist/cli/commands/translate.js +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/RuntimeLink.js +1 -0
- 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 +1 -1
- package/dist/client/experiments/runtime.js +1 -1
- package/dist/client/feedback.js +1 -1
- package/dist/client/l10n/use-l10n-config.js +1 -1
- package/dist/client/products.js +1 -1
- package/dist/client/review/ReviewBar.js +50 -50
- package/dist/client/review/use-review.js +1 -1
- 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/use-entity-revisions.js +1 -1
- package/dist/client/use-page-versions.js +1 -1
- package/dist/client/use-router-for-local-links.js +1 -1
- package/dist/client/use-search.js +1 -1
- package/dist/client/utils/routes/is-router-path.js +1 -0
- package/dist/client/webmcp/tools/shared.js +1 -1
- package/dist/client/webmcp/tools/site-tools.js +1 -1
- package/dist/client/webmcp/use-webmcp-tools.js +1 -1
- package/dist/content-layer/config.js +1 -1
- package/dist/content-layer/database/files.js +1 -1
- package/dist/content-layer/database/finalize.js +1 -1
- package/dist/content-layer/database/invalidation.js +26 -26
- package/dist/content-layer/database/origins.js +1 -1
- package/dist/content-layer/ingest/finalize-phase.js +1 -1
- package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
- package/dist/content-layer/ingest/run.js +1 -1
- package/dist/content-layer/ingest/search-sync.js +1 -1
- package/dist/content-layer/ingest/sync.js +1 -1
- package/dist/content-layer/link-checker/delta.js +1 -1
- package/dist/content-layer/link-checker/load-view.js +1 -1
- package/dist/content-layer/link-checker/run-build.js +1 -1
- package/dist/content-layer/link-checker/validate.js +1 -1
- package/dist/content-layer/loaders/context.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/heading.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.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
- package/dist/content-layer/markdown/resolve/raw-partials.d.ts +2 -1
- package/dist/content-layer/markdown/resolve/raw-partials.js +1 -1
- package/dist/content-layer/markdown/resolve/references.js +1 -1
- package/dist/content-layer/markdown/search/to-sections.js +1 -1
- package/dist/content-layer/markdown/search/to-text.d.ts +4 -1
- package/dist/content-layer/markdown/search/to-text.js +5 -5
- package/dist/content-layer/markdown/server/render.js +1 -1
- package/dist/content-layer/markdown/tags/variant.d.ts +6 -0
- package/dist/content-layer/markdown/tags/variant.js +1 -0
- package/dist/content-layer/markdown/utils/collect-anchors.js +1 -1
- package/dist/content-layer/markdown/utils/collect-headings.d.ts +3 -1
- package/dist/content-layer/markdown/utils/collect-headings.js +1 -1
- package/dist/content-layer/markdown/utils/first-heading.js +1 -1
- package/dist/content-layer/markdown/utils/heading-slugger.d.ts +8 -0
- package/dist/content-layer/markdown/utils/heading-slugger.js +1 -1
- package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
- package/dist/content-layer/materialization/entity.js +1 -1
- package/dist/content-layer/materialization/static-files.js +1 -1
- package/dist/content-layer/plugins/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/rebase-item-links.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/template.js +2 -2
- package/dist/content-layer/plugins/internal/api-docs/index.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.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/server/api-function-telemetry.js +1 -0
- package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/banner.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/index.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/markdoc/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/constants.d.ts +0 -6
- 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/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/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/sandbox.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/tool-list.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/api-call-operations.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +6 -5
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/allowed-hosts.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-bridge.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-errors.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/ssrf-guard.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
- 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/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-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.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +3 -3
- 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.d.ts +3 -2
- package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/bundle.js +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/types/plugin.d.ts +5 -0
- package/dist/content-layer/plugins/utils/link-access.js +1 -1
- package/dist/content-layer/plugins/utils/route-index.js +1 -1
- package/dist/content-layer/search/postings/postings-store.js +1 -1
- package/dist/content-layer/search/store.d.ts +11 -0
- package/dist/content-layer/server/database.js +1 -1
- package/dist/content-layer/static/registry.js +1 -1
- package/dist/content-layer/versions/redirect.js +1 -1
- package/dist/content-layer/versions/resolve.js +1 -1
- package/dist/server/__tests__/rbac-fixture.js +1 -1
- package/dist/server/app.js +3 -3
- package/dist/server/ask-ai/route.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/constants/system-routes.js +1 -1
- package/dist/server/content.js +15 -14
- package/dist/server/cors-proxy/handler.js +1 -1
- package/dist/server/feedback/route.js +1 -1
- package/dist/server/html-tags.js +2 -1
- package/dist/server/lambda-entry.js +1 -1
- package/dist/server/llms-txt.js +1 -1
- package/dist/server/manifest-assets.js +4 -4
- package/dist/server/node-entry.js +1 -1
- package/dist/server/page-handlers.js +2 -2
- package/dist/server/plugin-context.js +1 -1
- package/dist/server/public-url.js +1 -0
- package/dist/server/rbac/l10n-rules.js +1 -1
- package/dist/server/rbac/team-templates.js +1 -1
- package/dist/server/search/cache.js +1 -0
- package/dist/server/search/route.js +1 -1
- package/dist/server/search/search-telemetry.js +1 -0
- package/dist/server/seo-tags.js +2 -2
- package/dist/server/ssrf/ssrf-blocklist.js +1 -1
- package/dist/server/static-files/serve.js +1 -1
- package/dist/server/subprocess/child-entry.js +1 -1
- package/dist/server/subprocess/host.js +1 -1
- package/dist/shared/constants/l10n/langs/ar.js +1 -1
- package/dist/shared/constants/l10n/langs/de.js +1 -1
- package/dist/shared/constants/l10n/langs/en.js +1 -1
- package/dist/shared/constants/l10n/langs/es.js +1 -1
- package/dist/shared/constants/l10n/langs/fr.js +1 -1
- package/dist/shared/constants/l10n/langs/hi.js +1 -1
- package/dist/shared/constants/l10n/langs/it.js +1 -1
- package/dist/shared/constants/l10n/langs/ja.js +1 -1
- package/dist/shared/constants/l10n/langs/ko.js +1 -1
- package/dist/shared/constants/l10n/langs/pl.js +1 -1
- package/dist/shared/constants/l10n/langs/pt-br.js +1 -1
- package/dist/shared/constants/l10n/langs/pt.js +1 -1
- package/dist/shared/constants/l10n/langs/ru.js +1 -1
- package/dist/shared/constants/l10n/langs/uk.js +1 -1
- package/dist/shared/constants/l10n/langs/zh.js +1 -1
- package/dist/shared/experiments.js +1 -1
- package/dist/shared/load-dot-env.js +1 -1
- package/dist/shared/public-env.d.ts +9 -0
- package/dist/shared/public-env.js +1 -1
- package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
- package/dist/shared/utils/routes/markdown-copy-url.js +1 -0
- package/package.json +9 -6
- package/dist/content-layer/plugins/internal/mcp/server/codemode/execution-budget.js +0 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/read-result.js +0 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/return-last-expression.js +0 -6
- package/dist/content-layer/plugins/internal/mcp/server/codemode/returns-from-top-level.js +0 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/tool-declarations.js +0 -4
- package/dist/content-layer/plugins/internal/mcp/server/codemode/unknown-tool-hint.js +0 -3
- package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-constants.js +0 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages-constants.js +0 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +0 -1
- package/dist/shared/utils/routes/markdown-path.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{withPathPrefix as e}from"../../shared/path-prefix.js";import{REVIEW_ROUTE_PATH as t}from"../../shared/constants/review.js";import{useCallback as n,useEffect as r,useState as i}from"react";function a(e,t){let n=t?.error;return typeof n==`string`?n:`Request failed with ${e.status}.`}function o(){let[o,s]=i(null),[c,l]=i(null),[u,d]=i(!1);r(()=>{let n=!1,r=()=>void fetch(e(t),{headers:{accept:`application/json`}}).then(async e=>{let t=await e.json().catch(()=>null);n||(t&&`signedIn`in t?s(t):l(a(e,t)))}).catch(()=>{n||l(`Could not load the review.`)});return r(),window.addEventListener(`focus`,r),()=>{n=!0,window.removeEventListener(`focus`,r)}},[]);let f=n(async(t,n)=>{d(!0),l(null);try{let r=await fetch(e(t),n),i=await r.json().catch(()=>null);return i&&`signedIn`in i?(s(i),i.signedIn):(l(a(r,i)),!1)}catch{return l(`Could not reach the server.`),!1}finally{d(!1)}},[]);return{state:o,error:c,submitting:u,addComment:n(e=>f(t,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),[f]),deleteComment:n(e=>f(`${t}/comments/${encodeURIComponent(e)}`,{method:`DELETE`}),[f])}}export{o as useReview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{EMPTY_SIDEBAR_DATA as e,PageContext as t,SidebarDataContext as n}from"../contexts.js";import{useL10nHref as r}from"../l10n/use-l10n-href.js";import{SIDEBAR_BACK_LINK_ROUTE_DEP_KEY as i,SIDEBAR_BREADCRUMBS_ROUTE_DEP_KEY as a}from"../../shared/constants/route-deps.js";import{localizeSidebar as o}from"./localize.js";import{resolveSidebarData as s}from"./resolve-sidebar-data.js";import c,{useContext as l}from"react";import{useLocation as u}from"react-router";import{jsx as d}from"react/jsx-runtime";function f({loaderData:f,children:m}){let h=f.__sidebar,g=f[i],_=f[a],v=l(t),{pathname:y}=u(),b=r(),x=c.useMemo(()=>o(h,b),[h,b]),S=c.useMemo(()=>g?{...g,link:b(g.link)}:void 0,[g,b]),C=c.useMemo(()=>_?.map(e=>({...e,link:b(e.link)})),[_,b]),w=c.useMemo(()=>({...s({sidebar:x,page:v,pathname:y}),backLink:S,breadcrumbs:C}),[x,v,y,S,C]),T=p(w),E=c.useRef(e);return E.current.key!==T&&(E.current={key:T,...w}),/* @__PURE__ */ d(n.Provider,{value:E.current,children:m})}function p(e){return JSON.stringify([e.items??null,e.backLink??null,e.breadcrumbs??null,e.tabs?.map(e=>[e.tabId,e.label,e.link,e.menu?.map(e=>[e.tabId,e.label,e.link])])??null,e.activeTab?.tabId??null,e.activeMenuEntry?.tabId??null])}export{f as SidebarDataProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getMenuItemType as e}from"@redocly/theme/core/utils";import{MenuItemType as t}from"@redocly/theme/core/constants";function n(e,t,n){return{active:e.link===n&&!e.external,hasActiveSubItem:t.some(e=>e.active||e.hasActiveSubItem)}}function r(e,t){return e.map(e=>{let i=r(e.items,t);return{...e,items:i,...n(e,i,t)}})}function i(e,t){let{item:n}=e;return r([...n.link?[{...n,items:[],menuStyle:void 0,separatorLine:!1}]:[],...n.items],t)}function a(n,r=[]){for(let i of n)if(i.active||i.hasActiveSubItem){if(e(i)===t.DrillDown&&r.push({item:i}),i.hasActiveSubItem)return a(i.items,r);if(i.active)return r}return r}export{i as getDrilldownPanelItems,a as getInitialDrilldownStack,n as resolveActiveState,r as withActiveState};
|
package/dist/client/ssr.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{productClassName as e}from"../shared/products.js";import{routableLocales as t}from"../shared/utils/l10n/routable-locales.js";import{DEFAULT_LOCALE_PLACEHOLDER as n}from"../shared/constants/l10n/defaults.js";import"../shared/utils/l10n.js";import{getL10nAppData as r}from"./l10n/use-l10n-config.js";import{stripPathPrefix as i}from"../shared/path-prefix.js";import{findPageProduct as a}from"./products.js";import{L10nContext as o}from"./l10n/l10n-context.js";import{translationPackChunk as s}from"../shared/constants/l10n/default-translations.js";import{translationPackCode as c}from"../shared/utils/l10n/build-i18n-config.js";import{htmlLang as l}from"./l10n/html-lang.js";import{createServerApp as u,loadPageDependencies as d}from"./app.js";import{streamPage as f}from"./ssr-stream.js";import{createSsrL10nContext as p}from"./l10n/ssr-l10n.js";import{jsx as m}from"react/jsx-runtime";import{getLocaleFromPathname as h}from"@redocly/theme/core/utils";import"virtual:realm-markdoc-schema";import"virtual:realm-server-fns";import{serverRoutes as g}from"virtual:realm-server-routes";import{serverModules as _}from"virtual:realm-server-modules";import{mcpTools as v}from"virtual:realm-mcp-tools";async function y(g,_,v,y){let{Template:b,loaderData:x}=await d(g,{resolvedLoaderData:_,ssr:!0}),S=r(x),C=new URL(v,`http://localhost`).pathname,w=S?.defaultLocale||n,T=h(C,w,t(S)),E=a(x,i(C)??C),D=E?e(E.name):void 0,O=null;try{O=await p(S,T)}catch(e){console.error(`Realm: translations failed to load; rendering untranslated chrome.`,e)}let k=l(T),A=c(S,T),j=A===void 0?void 0:s(A);return{...await f(async e=>{let t=await u({page:g,loaderData:x,Template:e,url:v});return globalThis.SSR_HOSTNAME=y??``,/* @__PURE__ */ m(o.Provider,{value:O,children:t})},b),lang:k,translationPack:j,htmlClass:D}}export{v as mcpTools,y as render,_ as serverModules,g as serverRoutes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{withPathPrefix as e}from"../../shared/path-prefix.js";import{telemetryServiceVersion as t}from"../../shared/telemetry-service-version.js";import{OTEL_TRACES_ROUTE_PATH as n}from"../../shared/constants/telemetry.js";const r=process.env.REDOCLY_TELEMETRY===`on`;function i(){return new URL(e(n),window.location.origin).toString()}function a(){if(typeof window<`u`)return{collectorUrl:i(),disabled:!r,serviceVersion:t()}}export{r as CLIENT_TELEMETRY_ENABLED,a as apiDocsTelemetryConfig,i as clientTelemetryCollectorUrl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{LoaderDataContext as e}from"./contexts.js";import{REVISIONS_ROUTE_DEP_KEY as t}from"../shared/constants/revisions.js";import{useContext as n}from"react";const r={entityKey:null,items:[]};function i(e){let n=e[t];return!n||!Array.isArray(n.items)?r:{entityKey:typeof n.entityKey==`string`?n.entityKey:null,items:n.items}}function a(e){let{entityKey:t,items:n}=i(e);return!!t&&n.length>0}function o(t){let{items:r}=i(n(e));return{query:{data:void 0,isLoading:!1,isError:!1},items:r}}export{a as hasEntityRevisions,i as selectEntityRevisions,o as useFetchCatalogEntityRevisions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{PageContext as e,SidebarDataContext as t}from"./contexts.js";import{compareVersions as n,toPhysicalVersionedSlug as r,toPublicVersionedSlug as i,versionRoutePrefix as a}from"../shared/constants/versions.js";import{useContext as o,useMemo as s}from"react";const c=[];function l(e){return{name:typeof e?.version==`string`?e.version:void 0,group:typeof e?.versionGroup==`string`?e.versionGroup:void 0}}function u(e,t){let{name:o,group:s}=l(t);if(s===void 0||o===void 0)return c;let u=/* @__PURE__ */ new Map,d=e=>{for(let t of e){if(typeof t!=`object`||!t)continue;let e=t;if(e.versionGroup===s&&typeof e.version==`string`&&typeof e.link==`string`){let t=u.get(e.version);t||(t={firstLink:e.link,isDefault:!1,links:/* @__PURE__ */ new Set},u.set(e.version,t)),t.links.add(e.link),e.isDefaultVersion===!0&&(t.isDefault=!0),t.label===void 0&&typeof e.versionLabel==`string`&&(t.label=e.versionLabel)}Array.isArray(e.items)&&d(e.items)}};if(d(e??[]),u.size===0)return c;let f=t?.slug??``,p=r(f,s,o),m=p===null?null:p.slice(a(s,o).length),h=(e,t)=>{if(m===null)return t.firstLink;let n=i(`${a(s,e)}${m}`,s,e,t.isDefault);return t.links.has(n)?n:t.firstLink};return[...u.entries()].sort(([e],[t])=>n(t,e)).map(([e,t])=>({version:e,label:t.label??e,link:e===o?f:h(e,t),default:t.isDefault,active:e===o,folderId:e}))}function d(){let n=o(t),r=o(e);return{versions:s(()=>u(n.allItems??n.items,r),[n,r])}}export{l as selectActiveVersion,u as selectPageVersions,d as usePageVersionsImpl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{stripPathPrefix as e}from"../shared/path-prefix.js";import{isRouterPath as t}from"./utils/routes/is-router-path.js";import{useEffect as n}from"react";import{useNavigate as r}from"react-router";const i=[`mouseover`,`pointerdown`,`focusin`],a=e=>e;function o(e,t=a){let o=r();n(()=>{let n=e=>{if(e.defaultPrevented||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let n=c(s(e.target));n!==null&&(e.preventDefault(),o(t(n)))},r=null,a=n=>{let i=c(s(n.target));i!==null&&i!==r&&(r=i,e(t(i)))};document.addEventListener(`click`,n);for(let e of i)document.addEventListener(e,a);return()=>{document.removeEventListener(`click`,n);for(let e of i)document.removeEventListener(e,a)}},[o,e,t])}function s(e){let t=e instanceof Element?e.closest(`a`):null;return t instanceof HTMLAnchorElement?t:null}function c(n){if(!n||n.hasAttribute(`download`)||n.target!==``&&n.target!==`_self`||n.origin!==location.origin||n.protocol!==location.protocol||n.pathname===location.pathname&&n.search===location.search&&n.href.includes(`#`))return null;let r=e(n.pathname);return r===null||!t(r)?null:`${r}${n.search}${n.hash}`}export{o as useRouterForLocalLinks};
|
|
@@ -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{LoaderDataContext as n,PageContext as r}from"./contexts.js";import{APP_DATA_LOADER_KEY as i}from"../shared/constants/app-data.js";import{readAppData as a}from"../shared/utils/app-data.js";import{useL10nConfig as o}from"./l10n/use-l10n-config.js";import{withPathPrefix as s}from"../shared/path-prefix.js";import{telemetry as c}from"./telemetry/telemetry.js";import{selectActiveVersion as l}from"./use-page-versions.js";import{SEARCH_FACETS_ROUTE_PATH as u,SEARCH_ROUTE_PATH as d}from"../shared/constants/search.js";import{useCallback as f,useContext as p,useEffect as m,useMemo as h,useRef as g,useState as _}from"react";import{getBaseDataAttributes as v}from"@redocly/theme/core/utils";import{SEARCH_DEBOUNCE_TIME_MS as y}from"@redocly/theme/core/constants";import{SearchSessionContext as ee}from"@redocly/theme/core/contexts";async function b(e,t,n){let r=await fetch(s(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 x(e,t){return b(d,e,t)}function S(e){return Object.fromEntries(e.map(e=>[e.field,e.values]))}function C(e,t){return b(u,e,t)}function w(e){return a(e).theme?.aiAssistant?.hide===!1}function T(){let e=p(n),t=p(r);return{askAi:w(e)&&t?.aiAvailable===!0}}function E(e){return e.filter(e=>e.values.length>0).map(({field:e,values:t})=>({field:e,values:[...t]}))}function D(){let e=p(r),{currentLocale:t,defaultLocale:n}=o(),i=t===n?void 0:t,{name:a,group:s}=l(e);return h(()=>({locale:i,version:s!==void 0&&a!==void 0?{group:s,version:a}:void 0}),[i,s,a])}const O=(e,t)=>e.map(e=>({...e,isCounterVisible:t}));function k(r,a){let o=a===!1,{askAi:s}=T(),l=p(n),u=p(ee)?.searchSessionId,d=D(),b=h(()=>t(l[i]),[l]),[w,k]=_(``),[A,j]=_([]),[M,N]=_({}),[P,F]=_({}),[I,L]=_({}),[R,z]=_({}),[B,V]=_(!1),[H,U]=_(null),[W,G]=_(!1),K=g(null),q=g(null),J=g(!1),Y=h(()=>E(A),[A]),X=Y.length>0,Z=f(()=>{q.current=null,N({}),F({}),z({})},[]),Q=f((e,t,n)=>{K.current?.abort();let r=new AbortController;return K.current=r,V(!0),U(null),x(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)})},[]),$=f(async e=>{let t=e.trim();if(t===``&&!X){K.current?.abort(),J.current=!1,Z(),G(!1),U(null),V(!1);return}let n={query:t,...d,filter:Y,product:r};J.current=!0,await Q(n,i=>{J.current=!1,q.current=n,N(i.documents),F(i.facets??{}),z(i.groupCounts??{}),G(!0),t.length>1&&c.sendSearchQueryMessage([{...v(`searchQuery`,`search`),query:e,resultCount:Object.values(i.documents).reduce((e,t)=>e+t.length,0).toString(),...u?{searchSessionId:u}:{},...r?{product:r}:{}}])},()=>{J.current=!1,Z()})},[d,Y,X,Q,Z,r,u]),te=f(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]);m(()=>{if(a)return;(w.trim()!==``||X)&&V(!0);let e=setTimeout(()=>{$(w)},y);return()=>clearTimeout(e)},[w,a,X,$]),m(()=>{if(!b.advanced||!o)return;let e=new AbortController;return C({...d,product:r},e.signal).then(e=>L(S(e))).catch(()=>{e.signal.aborted||L({})}),()=>e.abort()},[b.advanced,o,d,r]),m(()=>()=>K.current?.abort(),[]);let ne=f(async()=>{await $(w)},[w,$]),re=h(()=>b.facets.map(e=>({...e,values:W?O(P[e.field]??[],!0):O(I[e.field]??[],!1)})),[b.facets,W,P,I]);return{advancedSearch:b.advanced,askAi:s,facets:re,filter:A,groupCounts:R,groupField:e,isSearchLoading:B,items:M,query:w,searchError:H,setFilter:j,setLoadMore:te,setQuery:k,retrySearch:ne}}function A(e){let r=D(),a=p(n),o=h(()=>t(a[i]).facets.find(t=>t.field===e),[a,e]),[s,c]=_(null),[l,u]=_(null);return m(()=>{if(l===null){c(null);return}let t=new AbortController;return C({...r,field:e,query:l.query,filter:E(l.filter),facetQuery:l.facetQuery},t.signal).then(t=>{c(o?{...o,values:O(S(t)[e]??[],!0)}:null)}).catch(()=>{t.signal.aborted||c(null)}),()=>t.abort()},[e,r,l,o]),{searchFacet:s,setSearchFacet:c,setSearchFacetQuery:u}}export{x as fetchSearch,C as fetchSearchFacets,A as useFacetQuery,k as useSearch,T as useSearchFeatures,D as useSearchScope};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CONTENT_ASSETS_URL_PREFIX as e}from"../../../shared/constants/content-assets.js";const t=[`${e}/`,`/_assets/`,`/_auth/`],n=[`/login`,`/logout`,`/post-logout`],r=/\.(?:avif|csv|docx?|gif|gz|ico|jpe?g|json|md|mp[34]|pdf|png|pptx?|svg|tar|tgz|ttf|txt|webm|webp|woff2?|xlsx?|xml|ya?ml|zip)$/i;function i(e){let i=e.split(/[?#]/)[0];return!r.test(i)&&!n.includes(i)&&!t.some(e=>i.startsWith(e))}export{i as isRouterPath};
|
|
@@ -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{stripPathPrefix as t}from"../../../shared/path-prefix.js";import{markdownCopyUrl as n}from"../../../shared/utils/routes/markdown-copy-url.js";import{splitUrlSuffix as r}from"../../../shared/utils/routes/split-url-suffix.js";function i(i){let{path:a}=r(i);return n(e(t(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{clampLimit as r,fetchText as i,markdownPathForRoute as a,toSitePath as o}from"./shared.js";import{SKILLS_INDEX_SLUG as s}from"../../../content-layer/plugins/utils/skill-paths.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 i=typeof t.query==`string`?t.query.trim():``;if(!i)return c(`Provide a query to search for.`);let a=r(t.limit,10,50),o={query:i,...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:i,resultCount:f.length,results:f}):u(`No documentation pages matched "${i}".`)}async function h(e,t){let n=typeof t.url==`string`&&t.url.trim()?t.url.trim():e.pathname,r=o(n);if(!r)return c(`Provide a site-relative path that starts with "/".`);let s=await i(e.routeUrl(a(r)));return s?u(s):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 i(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 r=await fetch(t.sitePathUrl(s),{headers:{accept:`application/json`}});if(!r.ok)return c(`This site does not publish agent skills.`);let a=await r.json(),o=e(a)&&Array.isArray(a.skills)?a.skills:[],d=typeof n.name==`string`?n.name.trim():``;if(!d)return l({skills:o.map(e=>({name:e.name,description:e.description}))});let f=o.find(e=>e.name.toLowerCase()===d.toLowerCase());if(!f){let e=o.map(e=>e.name).join(`, `);return c(`No skill named "${d}". Available skills: ${e||`none`}.`)}let p=await i(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,s=o(a);if(!s)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(s),comment:i?`${r}\n\n${i}`:r,agent:`webmcp-browser-agent`,origin:`mcp`})});return l.ok?u(`Thanks. The feedback about ${s} reached the documentation team.`):c(l.status===403||l.status===404?`Feedback cannot be left for ${s}.`:`Feedback could not be sent, status ${l.status}.`)}async function x(e,t){let n=typeof t.url==`string`?o(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{LoaderDataContext as e,PageContext as t,SidebarDataContext as n}from"../contexts.js";import{useL10nConfig as r}from"../l10n/use-l10n-config.js";import{stripPathPrefix as i,withPathPrefix as a}from"../../shared/path-prefix.js";import{useCurrentProduct as o}from"../ProductsProvider.js";import{telemetry as s}from"../telemetry/telemetry.js";import{API_DOCS_RENDER_DEP_KEY as c}from"../../content-layer/plugins/internal/api-docs/server/shared.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 s=_(),d=v(),{currentLocale:S}=r(),w=u(),{versions:E}=l(),D=m(n).items,O=o(),k=m(t),A=m(e)[c],j=k?.slug.toLowerCase(),M=y().feedback?.hide===!0,N=k?.metadata?.seo,P={pathname:a(s.pathname),pageTitle:N?.title,locale:S,searchScope:w,product:O?.name??O?.slug,versions:E,sidebarItems:D??[],feedbackHidden:M,navigate:async e=>{let{pathname:t,search:n,hash:r}=new URL(e,window.location.origin);await d({pathname:i(t)??t,search:n,hash:r})},withPrefix:a,routeUrl:e=>new URL(e,window.location.origin).toString(),sitePathUrl:e=>new URL(a(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=>s.sendAgentToolsRegisteredMessage([{...w,toolCount:t,scope:e}]),called:(e,t)=>s.sendAgentToolCalledMessage([{...w,toolName:e,outcome:t}])}}export{S as useWebMcpTools};
|
|
@@ -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{listL10nDirs as n,resolveLocaleContext as r}from"../shared/utils/l10n.js";import{hashContentBytes as i}from"../shared/utils/content-hash.js";import{isClosedToAnonymous as a,parseRbacConfigData as o}from"../server/rbac/engine.js";import{readProjectEnv as s}from"../server/project-env.js";import{expandConfigRbacForL10n as c}from"../server/rbac/l10n-rules.js";import{expandConfigRbacTeamTemplates as l,listTeamDirs as u,teamTemplatePrefixes as d}from"../server/rbac/team-templates.js";import{getProcessEnv as f,getPublicEnv as p,resolveRedoclyEnvironment as m,sanitizeBranchName as h}from"../shared/public-env.js";import{resolveContentPath as g}from"../shared/utils/resolve-content-path.js";import{resolveConfigRedirects as _}from"./config-redirects.js";import{NESTED_CONFIG_SCHEMA as v,REALM_CONFIG_SCHEMA as y,sanitizeConfig as b}from"./config-schema.js";import{hashEffectiveConfig as x,resolveSiteConfig as S}from"./database/site-config.js";import{applyEnforcedAccess as C}from"./enforced-access.js";import{applyPlanGates as w}from"./plan-gates.js";import{resolve as T}from"node:path";import{interpolateEnvVariables as E}from"@redocly/config";import D from"js-yaml";const O=[`redocly.yaml`,`redocly.yml`],k=`redocly.yaml`;async function A(e,t){let r=await re(e,t),a=f();if(!r){let e=[],t=C(w($(),a,t=>e.push({code:`configuration/ignored`,message:t})),a);return{absolutePath:null,config:t,siteConfig:t,path:null,hash:null,refs:[],problems:e}}let o=await t.readBinaryFile(r.absolutePath),c=[],l=[],p=[],m=F(new TextDecoder().decode(o),r.path),h=[],g=s(a),_={contentDir:e,fs:t,env:g,refs:p,warnings:c,errors:l},v=Q(await te(await R(await I(m,{..._,deprecations:h}),``,_),_)),y={filePath:r.path},b=[],x=U(v.access)?v.access.rbac:void 0,T=K(v,{dirLocales:await n(e,t),teamDirs:await u(e,t,d(U(x)?x:{})),env:g,report:e=>b.push({...e,location:y})}),E=C(w(T,a,e=>b.push({code:`configuration/ignored`,message:e,location:y})),a),{config:D,unsetVars:O}=S(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})),...l.map(e=>({code:`configuration/invalid`,severity:`error`,message:e,location:y})),...b];return{...r,config:D,siteConfig:E,hash:await i(o),refs:p,problems:k}}function j(e,t){return x(e)!==t}async function ee(e){if(e.context.configLoaded&&e.force!==!0)return{absolutePath:e.context.configFilePath?T(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=await A(e.context.contentDir,e.context.platform.fs);return e.context.config=t.config,e.context.siteConfig=t.siteConfig,e.context.configFilePath=t.path,e.context.configHash=t.hash,e.context.configRefs=t.refs,e.context.configLoaded=!0,t}function M(e,t){let n=E(F(e,t),s(f())).value,{value:r,problems:i}=b(v,n);for(let e of i)e.location={filePath:t};return{config:r,problems:i}}function N(e){return e.endsWith(`/${k}`)}async function P(e){let t=[];for(let n of e.paths)try{let r=await e.fs.readFile(T(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 F(t,n){let r=D.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 I(e,t){let{env:n,...r}=e;if(!U(n))return e;let i=t.env.PUBLIC_REDOCLY_BRANCH_NAME,a=[...i?[`branch.${h(i)}`]:[],m(t.env.REDOCLY_ENV)],o=e=>t.deprecations.push(e),s=J(r,o);for(let e of a){let r=await L(n[e],e,t);r&&(s=H(s,J(r,o)))}return s}async function L(e,t,n){if(!U(e))return null;if(typeof e.$ref!=`string`)return e;let{$ref:r,...i}=e,a=`env.${t}`,o=z(await B(r,a,n),i,a,n);return U(o)?o:null}async function R(e,t,n){if(Array.isArray(e))return Promise.all(e.map((e,r)=>R(e,`${t}[${r}]`,n)));if(!U(e))return e;if(typeof e.$ref==`string`){let{$ref:r,...i}=e;return z(await B(r,t,n),await R(i,t,n),t,n)}let r={};for(let[i,a]of Object.entries(e))r[i]=await R(a,t===``?i:`${t}.${i}`,n);return r}function z(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 B(e,n,r){return V(e,`${n} $ref`,r,e=>t(D.load(e)))}async function V(e,t,n,r,a=`warning`){let o=a===`error`?n.errors:n.warnings,s=g(e,O[0]);if(s===null)return o.push(`${t} "${e}" escapes the content root.`),null;try{let e=await n.fs.readBinaryFile(T(n.contentDir,s));return n.refs.push({path:s,hash:await i(e)}),r(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 te(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 V(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??(()=>{}),i=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=b(y,a,{env:t.env});for(let e of o.problems)n(e);let{redirects:s,access:u,...d}=c(l(q(o.value,t.env),t.teamDirs??{},n),i),f={...d,publicEnv:p()};u&&(f.access=ne(u,n));let m=_(s,r(d.l10n,i));return m&&(f.redirects=m),f}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?o(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:a(n)}):e}async function re(e,t){for(let n of O){let r=T(e,n);if(await t.exists(r))return{absolutePath:r,path:n}}return null}function $(){return K({})}export{k as NESTED_CONFIG_FILENAME,O as REDOCLY_CONFIG_FILENAMES,$ as createEmptyRealmConfig,H as deepMergeConfig,j as isConfigChanged,N as isNestedConfigPath,ee as loadContentLayerConfig,A as loadRedoclyConfig,K as normalizeRedoclyConfig,M as parseNestedConfig,P as readNestedConfigProblems};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{entities as e,entityDeps as t,filePlugins as n,files as r,originDeps as i,routeDeps as a,routes as o,searchDocuments as s}from"./schema.js";import{batchValues as c,normalizeBatchSize as l,runWithSqliteBusyRetry as u}from"./connection.js";import{
|
|
1
|
+
import{entities as e,entityDeps as t,filePlugins as n,files as r,originDeps as i,routeDeps as a,routes as o,searchDocuments as s}from"./schema.js";import{batchValues as c,normalizeBatchSize as l,runWithSqliteBusyRetry as u}from"./connection.js";import{garbageCollectOrphanedEntitiesInTransaction as d}from"./invalidation.js";import{deleteProblemsForFilesTx as f}from"./problems.js";import{deleteLinkRowsForFilesTx as p}from"./link-refs.js";import{and as m,eq as h,inArray as g,sql as _}from"drizzle-orm";async function v(e){return e.db.select({hash:r.hash,id:r.id,lastModifiedAt:r.lastModifiedAt,manifestVersion:r.manifestVersion,path:r.path}).from(r).orderBy(r.path)}async function y(e,t){let n=/* @__PURE__ */ new Map;for(let i of c(t,500)){let t=await e.db.select({manifest:r.manifest,path:r.path}).from(r).where(g(r.path,i));for(let e of t)n.set(e.path,JSON.parse(e.manifest))}return n}async function b(e){let t=await e.db.select({fileId:n.fileId,filePath:r.path,pluginId:n.pluginId,pluginVersion:n.pluginVersion}).from(n).innerJoin(r,h(n.fileId,r.id)).orderBy(r.path,n.pluginId),i=/* @__PURE__ */ new Map;for(let e of t){let t=i.get(e.filePath)??[];t.push({fileId:e.fileId,pluginId:e.pluginId,pluginVersion:e.pluginVersion}),i.set(e.filePath,t)}return i}async function x(e){let[t,n,i,a]=await Promise.all([v(e),e.db.select({metadata:o.metadata,originFileId:o.sourceId,originFilePath:r.path,originPluginId:o.pluginId,routeId:o.routeId,sidebarSubtreeEntityKey:o.sidebarSubtreeEntityKey,wildcardPrefix:o.wildcardPrefix,slug:o.slug,requestedSlug:o.requestedSlug,slugType:o.slugType,template:o.template,versionGroup:o.versionGroup,version:o.version,locale:o.locale,isFallback:o.isFallback,canonicalSlug:o.canonicalSlug}).from(o).leftJoin(r,h(o.sourceId,r.id)).orderBy(r.path,o.pluginId,o.routeId),S(e),b(e)]);return{entities:i,filePluginsByPath:a,files:t,routes:n}}async function S(t,n){return t.db.select({id:e.id,isSystem:e.isSystem,key:e.key,kind:e.kind,type:e.type,metadata:e.metadata,dataHash:e.dataHash,loaderArgs:e.loaderArgs,loaderId:e.loaderId,pluginId:e.pluginId,status:e.status}).from(e).where(n===void 0?h(e.isCurrent,1):m(g(e.key,[...n]),h(e.isCurrent,1))).orderBy(e.key)}async function C(e,s){let m=l(s.batchSize);return s.upserts.length===0&&s.removedPaths.length===0?[]:u(()=>e.db.transaction(async e=>{let l=[];for(let t of c(s.upserts,m)){let n=await e.insert(r).values(t).onConflictDoUpdate({target:r.path,set:{hash:_.raw(`excluded.hash`),manifest:_.raw(`excluded.manifest`),manifestVersion:_.raw(`excluded.manifest_v`),lastModifiedAt:_.raw(`excluded.last_modified_at`)}}).returning({id:r.id,path:r.path,hash:r.hash,lastModifiedAt:r.lastModifiedAt,manifestVersion:r.manifestVersion});l.push(...n)}if(s.removedPaths.length>0){let l=(await e.select({id:r.id}).from(r).where(g(r.path,s.removedPaths))).map(e=>e.id);if(l.length>0){for(let r of c(l,m))await e.delete(t).where(g(t.originFileId,r)),await e.delete(i).where(g(i.originFileId,r)),await e.delete(a).where(g(a.originFileId,r)),await e.delete(o).where(g(o.sourceId,r)),await e.delete(n).where(g(n.fileId,r)),await f(e,r,m),await p(e,r,m);for(let t of c(l,m))await e.delete(r).where(g(r.id,t));await d(e)}}return l}),{logger:s.logger,operation:`persist content file state`})}async function w(e,t,n){t.length!==0&&await u(()=>e.db.transaction(async e=>{for(let n of t)await e.update(r).set({lastModifiedAt:n.lastModifiedAt}).where(h(r.path,n.path))}),{logger:n,operation:`refresh file last-modified`})}async function T(e){let[t,n]=await Promise.all([e.db.select({filePath:r.path,slug:o.slug,metadata:o.metadata}).from(o).innerJoin(r,h(o.sourceId,r.id)),e.db.select({slug:s.routeSlug,title:s.title}).from(s).where(g(s.docKey,[`page`,`overview`]))]),i=new Map(n.map(e=>[e.slug,e.title])),a=/* @__PURE__ */ new Map;for(let{filePath:e,slug:n,metadata:r}of t){let t=a.get(e);if(t!==void 0&&t.slug.length<=n.length)continue;let o=i.get(n)||r.title;a.set(e,typeof o==`string`&&o?{slug:n,title:o}:{slug:n})}return a}export{T as listRoutePagesByFile,y as loadFileManifestsByPaths,S as loadPersistedContentStateEntities,x as loadPersistedContentStateSummary,v as loadStoredContentFiles,C as persistContentFileState,w as refreshFileLastModified};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isJsonObject as e,toJsonObject as t,toStableJsonString as n}from"./utils/json.js";import{compareStrings as r}from"../../shared/utils/compare-strings.js";import{entities as i,entityDeps as a,originDeps as o,pluginHookState as s,routeDeps as c,routeQueryDeps as l,routes as u,staticFiles as d}from"./schema.js";import{batchValues as f,normalizeBatchSize as p,runWithSqliteBusyRetry as m}from"./connection.js";import{
|
|
1
|
+
import{isJsonObject as e,toJsonObject as t,toStableJsonString as n}from"./utils/json.js";import{compareStrings as r}from"../../shared/utils/compare-strings.js";import{entities as i,entityDeps as a,originDeps as o,pluginHookState as s,routeDeps as c,routeQueryDeps as l,routes as u,staticFiles as d}from"./schema.js";import{batchValues as f,normalizeBatchSize as p,runWithSqliteBusyRetry as m}from"./connection.js";import{generateEntityId as h}from"./entities.js";import{deleteProblemsForPluginHookTx as g,insertProblemsTx as _,replaceGlobalProblemsForKeysTx as v}from"./problems.js";import{writePluginHookState as y}from"./plugin-hook-state.js";import{replaceRouteQueryDepsTx as b}from"./route-query-deps.js";import{upsertEntityDescriptors as x}from"./origins.js";import{inArray as S,notInArray as C,sql as w}from"drizzle-orm";async function T(e,t,n){t.length!==0&&await m(()=>e.db.transaction(async e=>{for(let n of t)await E(e,n)}),{logger:n?.logger,operation:`register system entities`})}async function E(e,t){let[r]=await e.select({id:i.id,kind:i.kind,pluginId:i.pluginId,loaderId:i.loaderId,loaderArgs:i.loaderArgs}).from(i).where(w`${i.key} = ${t.key} and ${i.isCurrent} = 1`).limit(1),a=t.fragmentUpdates?D(r?.loaderArgs??null,t.loaderArgs,t.fragmentUpdates):t.loaderArgs,o=!r||r.kind!==t.kind||r.pluginId!==t.pluginId||r.loaderId!==t.loaderId||n(r.loaderArgs??null)!==n(a??null);await e.insert(i).values({id:r?.id??h(),key:t.key,kind:t.kind,type:t.type,metadata:t.metadata,pluginId:t.pluginId,loaderId:t.loaderId,loaderArgs:a,status:`stale`,data:null,markdoc:null,isSystem:1}).onConflictDoUpdate({target:i.id,set:{kind:w.raw(`excluded.kind`),pluginId:w.raw(`excluded.plugin_id`),loaderId:w.raw(`excluded.loader_id`),loaderArgs:w.raw(`excluded.loader_args`),isSystem:w.raw(`excluded.is_system`)}}),(t.shouldInvalidateValue||o)&&await e.update(i).set({status:`stale`,invalidationSeq:w`${i.invalidationSeq} + 1`}).where(w`${i.key} = ${t.key} and ${i.isCurrent} = 1`)}function D(n,i,a){let o=e(n)&&e(n.fragments)?n.fragments:{},s={};for(let[t,n]of Object.entries(o))e(n)&&typeof n.owner==`string`&&!a.has(n.owner)&&(s[t]=n);for(let[e,t]of a)for(let[n,r]of Object.entries(t??{}))s[n]={owner:e,value:r};let c=t(Object.fromEntries(Object.keys(s).sort(r).map(e=>[e,s[e]])));return{...e(i)?i:{},fragments:c}}function O(t){let n=/* @__PURE__ */ new Set,r=e(t)&&e(t.fragments)?t.fragments:{};for(let t of Object.values(r))e(t)&&typeof t.owner==`string`&&`value`in t&&n.add(t.owner);return n}async function k(e,t){let n=p(t.batchSize);await m(()=>e.db.transaction(async e=>{await e.delete(o).where(w`${o.originPluginId} = ${t.originPluginId} and ${o.originFileId} is null and ${o.hook} = 'finalize'`);for(let r of f(t.dependencies,n))r.length!==0&&await e.insert(o).values(r.map(e=>({accessType:e.accessType,originFileId:null,originPluginId:t.originPluginId,hook:`finalize`,source:e.source,path:e.path,valueHash:e.valueHash})));await b(e,{originPluginId:t.originPluginId,hook:`finalize`,entityId:null,dependencies:t.routeQueries}),await y(e,{pluginId:t.originPluginId,hook:`finalize`,fingerprint:t.fingerprint})}),{logger:t.logger,operation:`replace finalize reads`})}async function A(e,t,n){let r=t.map(e=>`${e.hook}:${e.pluginId}`),i=e=>t.filter(t=>t.hook===e).map(e=>e.pluginId),f=i(`extractAll`),p=i(`finalize`),h=(e,t)=>C(w`${t} || ':' || ${e}`,r),g=e=>w`${e.originFileId} is null and ${e.hook} in ('extractAll', 'finalize') and ${h(e.originPluginId,e.hook)}`;return m(()=>e.db.transaction(async e=>[await e.delete(o).where(g(o)).returning({id:o.id}),await e.delete(a).where(g(a)).returning({id:a.id}),await e.delete(c).where(g(c)).returning({id:c.id}),await e.delete(l).where(w`${l.entityId} is null and ${l.hook} in ('extractAll', 'finalize') and ${h(l.originPluginId,l.hook)}`).returning({id:l.id}),await e.delete(u).where(w`${u.sourceId} is null and ${u.isFallback} = 0 and ${C(u.pluginId,f)}`).returning({id:u.id}),await e.delete(d).where(C(d.ownerPluginId,p)).returning({id:d.path}),await e.delete(s).where(h(s.pluginId,s.hook)).returning({id:s.pluginId})].some(e=>e.length>0)),{logger:n?.logger,operation:`reconcile plugin-scoped rows`})}async function j(e,t){let n=[...t],r=w`${c.originFileId} is null`;return e.db.select({routeSlug:c.routeSlug,key:c.key,originPluginId:c.originPluginId}).from(c).where(n.length===0?r:w`${r} and not (${c.hook} = 'finalize' and ${S(c.originPluginId,n)})`)}async function M(e,t){let n=p(t.batchSize);await m(()=>e.db.transaction(async e=>{await P(e,t.originPluginId),await F(e,t,n)}),{logger:t.logger,operation:`replace finalize artifacts`})}async function N(e,t){await m(()=>e.db.transaction(async e=>{await g(e,t.pluginIds,`finalize`),await _(e,t.pluginProblems),await v(e,`finalize`,t.globalKeys,t.globalProblems)}),{logger:t.logger,operation:`replace finalize problems`})}async function P(e,t){await e.delete(c).where(w`${c.originFileId} is null and ${c.originPluginId} = ${t} and ${c.hook} = 'finalize'`),await e.delete(a).where(w`${a.originFileId} is null and ${a.originPluginId} = ${t} and ${a.hook} = 'finalize'`)}async function F(e,t,n){let r=await x(e,t.entities,n);for(let r of f(t.routeDependencies,n))r.length!==0&&await e.insert(c).values(r.map(e=>({args:e.args,dependencyType:e.dependencyType,key:e.key,originFileId:null,originPluginId:t.originPluginId,hook:`finalize`,routeSlug:e.routeSlug,target:e.target}))).onConflictDoNothing();if(t.entities.length!==0)for(let n of t.entities){let i=r.get(n.key);if(!i)throw Error(`Missing entity row for key "${n.key}".`);await e.insert(a).values({dependencyRef:t.originPluginId,dependencyType:`origin`,entityId:i,originFileId:null,originPluginId:t.originPluginId,hook:`finalize`}).onConflictDoNothing()}}export{O as collectAppDataFragmentOwnerIds,j as loadPluginScopedRouteDepOwners,A as reconcilePluginScopedRows,T as registerSystemEntities,M as replaceFinalizeArtifacts,N as replaceFinalizeProblems,k as replaceFinalizeReads};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{APP_DATA_ENTITY_KEY as e}from"../../shared/constants/app-data.js";import{delocalizeL10nPath as t}from"../../shared/utils/l10n.js";import{assetRefs as n,entities as r,entityDeps as i,files as a,linkRefs as o,loaderConfigDeps as s,originDeps as c,pageMarkdown as l,problems as u,searchDocuments as d,searchFragmentParents as f,searchFragmentPostings as p,searchFragmentUsages as m,searchFragments as h,searchPostings as g}from"./schema.js";import{compileGlob as _,hashGlobMatches as v,matchGlob as y}from"../plugins/utils/glob.js";import{hashContentConfigDependency as b}from"../config-deps.js";import{runWithSqliteBusyRetry as x}from"./connection.js";import{createRouteQueryEvaluator as S,isRouteQueryStale as C}from"../plugins/utils/route-index.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:c.accessType,originFileId:c.originFileId,originFilePath:a.path,originPluginId:c.originPluginId,hook:c.hook,path:c.path,source:c.source,valueHash:c.valueHash}).from(c).leftJoin(a,k(c.originFileId,a.id)).orderBy(a.path,c.originPluginId,c.path,c.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(y(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=b(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 n=await e.db.select({accessType:s.accessType,path:s.path,key:r.key,valueHash:s.valueHash}).from(s).innerJoin(r,k(s.entityId,r.id)).orderBy(r.key,s.path,s.accessType),i=/* @__PURE__ */ new Set;for(let e of n)b(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 n=await e.db.selectDistinct({key:r.key}).from(u).innerJoin(r,k(u.entityId,r.id)).where(O(k(u.scope,`entity`),A(u.code,[...D]),k(r.isCurrent,1)));return U(e,{logger:t.logger,reason:`retryable problem invalidation`,keys:n.map(e=>e.key)})}async function V(e,t){let n=S(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)||C(n,e)&&i.add(e.entityId);if(i.size===0)return{invalidatedKeys:[]};let a=await e.db.select({key:r.key}).from(r).where(A(r.id,[...i]));return U(e,{logger:t.logger,reason:`route query invalidation`,keys:a.map(e=>e.key)})}async function H(e,a){if(a.changedFilePaths.length===0)return{invalidatedKeys:[]};let o=/* @__PURE__ */ new Set,s=await e.db.select({key:r.key}).from(r).innerJoin(i,k(i.entityId,r.id)).where(j`${i.dependencyType} in ('file','origin') and ${i.dependencyRef} in ${a.changedFilePaths}`);for(let e of s)o.has(e.key)||o.add(e.key);let c=[...new Set(a.changedFilePaths.map(t).filter(e=>e!==void 0))];if(c.length>0){let t=await e.db.select({key:r.key}).from(r).innerJoin(n,k(n.entityId,r.id)).where(A(n.path,c));for(let e of t)o.add(e.key)}let l=a.membershipChangedPaths??[];if(l.length>0){let t=await e.db.select({key:r.key,pattern:i.dependencyRef}).from(r).innerJoin(i,k(i.entityId,r.id)).where(k(i.dependencyType,`glob`));for(let e of t){let t=_(e.pattern);l.some(t)&&o.add(e.key)}}let u=await U(e,{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 n=new Set(t.keys),a=new Set(n),o=[...n];for(;o.length>0;){let t=o;o=[];let n=await e.db.select({key:r.key}).from(r).innerJoin(i,k(i.entityId,r.id)).where(j`${i.dependencyType} = 'entity' and ${i.dependencyRef} in ${t}`);for(let e of n)a.has(e.key)||(a.add(e.key),o.push(e.key))}let s=t.markKeys===!1?[...a].filter(e=>!n.has(e)):[...a];return s.length===0?{invalidatedKeys:[]}:(await x(()=>e.db.update(r).set({status:`stale`,invalidationSeq:j`${r.invalidationSeq} + 1`}).where(O(A(r.key,s),k(r.isCurrent,1))),{logger:t.logger,operation:t.reason}),{invalidatedKeys:s})}async function W(e,t){return x(()=>e.db.transaction(e=>G(e)),{logger:t,operation:`garbage collect orphaned entities`})}async function G(t){let n=j`(${r.isSystem} = 0 or ${r.key} <> ${e}) and ${r.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 ${i}
|
|
4
|
+
where ${i.entityId} = ${r.id}
|
|
5
|
+
and ${i.dependencyType} = 'origin'
|
|
6
|
+
)`,[a]=await t.select({id:r.id}).from(r).where(n).limit(1);return a!==void 0&&await K(t,n),await t.delete(r).where(j`${r.isCurrent} = 0 and not exists (
|
|
7
|
+
select 1 from ${r} as live
|
|
8
|
+
where live.key = ${r.key} and live.is_current = 1
|
|
9
|
+
)`),{removedOrphans:a!==void 0}}async function K(e,t){await e.delete(s).where(j`${s.entityId} in (
|
|
10
|
+
select ${r.id} from ${r} where ${t}
|
|
11
|
+
)`);let n=j`select ${d.id} from ${d}
|
|
12
|
+
where ${d.entityKey} in (
|
|
13
|
+
select ${r.key} from ${r} where ${t}
|
|
14
|
+
)`,i=j`select ${h.id} from ${h}
|
|
15
|
+
where ${h.entityKey} in (
|
|
16
|
+
select ${r.key} from ${r} where ${t}
|
|
17
|
+
)`,a=[...await T(e,n),...await E(e,i)];await e.delete(g).where(j`${g.docId} in (${n})`),await e.delete(p).where(j`${p.fragmentId} in (${i})`),await e.delete(f).where(j`${f.docId} in (${n})`),await e.delete(m).where(j`${m.fragmentId} in (${i})`),await e.delete(h).where(j`${h.id} in (${i})`),await w(e,a),await e.delete(d).where(j`${d.entityKey} in (
|
|
18
|
+
select ${r.key} from ${r} where ${t}
|
|
19
|
+
)`),await e.delete(l).where(j`${l.entityKey} in (
|
|
20
|
+
select ${r.key} from ${r} where ${t}
|
|
21
|
+
)`),await e.delete(u).where(j`${u.scope} = 'entity' and ${u.entityId} in (
|
|
22
|
+
select ${r.id} from ${r} where ${t}
|
|
23
|
+
)`);let c=j`${o.entityId} in (
|
|
24
|
+
select ${r.id} from ${r} where ${t}
|
|
25
|
+
)`;await e.delete(u).where(j`${u.scope} = 'link' and ${u.linkRefId} in (
|
|
26
|
+
select ${o.id} from ${o} where ${c}
|
|
27
|
+
)`),await e.delete(o).where(c),await e.delete(r).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};
|
|
@@ -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{
|
|
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?.capture&&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{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
|
|
1
|
+
import{hashJsonValue as e,isJsonObject as t,toJsonObject as n}from"../database/utils/json.js";import"../../shared/constants/app-data.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{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{loadPluginScopedRouteDepOwners as v,registerSystemEntities as y,replaceFinalizeArtifacts as b,replaceFinalizeProblems as x,replaceFinalizeReads as S}from"../database/finalize.js";import{appDataNamespaceConflictProblem as C,attachConflictProblem as w,finalizeFailedProblem as T,keysBlamingPlugins as E}from"../problems/producers.js";import{buildHookSourceFiles as D,createHookEntityStore as O,finalizeHookInputs as k,resolvePluginHookTriggers as A}from"./hook-inputs.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=A(`finalize`,e.context,e.workingState,e.pluginScopedOriginRows,e.routeQueryRows,e.hookState,k(e.localeContext)),n=e.context.pluginRegistry.listFinalizePlugins().filter(t.shouldRun).map(e=>({plugin:e,inputsHash:t.fingerprintOf(e)})),r=n.map(({plugin:e})=>e.id),i=await L(e.database,r),a=/* @__PURE__ */ new Map,o=R(e.workingState,e.context),s=/* @__PURE__ */ new Map,c=[],l=[],u=[],d=[];for(let{plugin:r,inputsHash:f}of n){let n=await I({plugin:r,context:e.context,database:e.database,localeContext:e.localeContext,workingState:e.workingState,processedFiles:e.files,matchedPaths:t.matchedPathsOf(r),routeQueries:t.evaluator,attachOwnerByKey:i,staticFilesByPlugin:a,namespaceOwners:o,fragmentUpdates:s,pendingTrackedDependencyWrites:c,inputsHash:f,logger:e.logger,collectEntities:e.collectEntities,conflicts:u,staticProblems:d});for(let e of n.problems)l.push({pluginId:r.id,problem:e})}s.size>0&&await q(e.database,e.context,s);let f=new Set(e.context.pluginRegistry.listFinalizePlugins().map(e=>e.id));if(await W(e,a,d,f),r.length>0){let t=await p(e.database,`finalize`),n=U(t,new Set(r),f);await x(e.database,{pluginIds:r,pluginProblems:l.map(({pluginId:e,problem:t})=>m(t,{scope:`origin`,originFileId:null,originPluginId:e,hook:`finalize`})),globalKeys:[.../* @__PURE__ */ new Set([...u.map(e=>e.key),...E(t,n)])],globalProblems:u.map(e=>m(e.problem,{scope:`global`,source:`finalize`,key:e.key})),logger:e.logger})}for(let t of c)await V(e.database,t);return{ranPluginIds:r}}async function I(e){let t=e.logger.child(`content-layer:plugin:${e.plugin.id}`),r=await D(e.matchedPaths,e.processedFiles,{database:e.database,workingState:e.workingState}),o=a(e.context.config),c=[],l=i(e.context.platform.fs,e.context.contentDir,()=>e.workingState.filesByPath.keys(),e=>c.push(e)),u=[],f=e=>u.push(e),p=await s(e.plugin,{files:r,routes:e.routeQueries.index(f),io:l,config:o.config,localeContext:e.localeContext,entities:O(e.context,e.database,e.workingState,f),search:_(e.database),logger:t});if(!p.ok)return{problems:[T({pluginId:e.plugin.id,message:p.error.message})]};let m=p.value??{};return e.fragmentUpdates.set(e.plugin.id,m.appData===void 0?B(e.plugin.id,e.namespaceOwners):z({pluginId:e.plugin.id,appData:n(m.appData),namespaceOwners:e.namespaceOwners,conflicts:e.conflicts})),e.staticFilesByPlugin.set(e.plugin.id,await H({plugin:e.plugin,result:m,workingState:e.workingState,context:e.context,database:e.database,attachOwnerByKey:e.attachOwnerByKey,recordFileDependency:e=>c.push(e),conflicts:e.conflicts,staticProblems:e.staticProblems,logger:t,collectEntities:e.collectEntities})),e.pendingTrackedDependencyWrites.push({pluginId:e.plugin.id,inputsHash:e.inputsHash,configDependencies:o.collectDependencies(),fileDependencies:c,routeQueryDependencies:u,logger:t}),{problems:(m.problems??[]).map(d)}}async function L(e,t){let n=await v(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(C({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 S(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 b(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),...E(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(w({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 y(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,toJsonObject as t,toJsonValue as n}from"../database/utils/json.js";import{isEntityLoaderReference as r,isInlineEntityReference as i,isRawEntityReference as a}from"../loaders/define.js";import{createStoredEntityReference as o,isServerFnReference as s}from"../plugins/server-fn.js";import{compareStrings as c}from"../../shared/utils/compare-strings.js";import{isObject as l}from"../../shared/utils/is-object.js";import{
|
|
1
|
+
import{hashJsonValue as e,toJsonObject as t,toJsonValue as n}from"../database/utils/json.js";import{isEntityLoaderReference as r,isInlineEntityReference as i,isRawEntityReference as a}from"../loaders/define.js";import{createStoredEntityReference as o,isServerFnReference as s}from"../plugins/server-fn.js";import{compareStrings as c}from"../../shared/utils/compare-strings.js";import{isObject as l}from"../../shared/utils/is-object.js";import{isCoreRouteDepKey as u}from"../../shared/constants/route-deps.js";import{LIST_REVISIONS_SERVER_FN_ID as d,REVISIONS_ROUTE_DEP_KEY as f}from"../../shared/constants/revisions.js";import{matchContentPathMap as p}from"../plugins/utils/glob.js";import{parseContentVersion as m}from"../plugins/utils/version-path.js";import{deriveLocalizedRequestedSlug as h,deriveRequestedSlug as g}from"./slugger/derive-requested-slug.js";function _(e){let n=v(e);if(n===`skip`)return{routeDependencies:[],routes:[],entities:[]};let r=e.filePath===null?null:m(e.filePath),i=b(e.context,e.pluginId,r?.version??null),a=/* @__PURE__ */ new Map,o=[],s=[];for(let t of e.standaloneEntities){let e=i(t);a.set(e.key,e)}let _=/* @__PURE__ */ new Set,x=e.filePath===null?void 0:p(e.filePath,e.context.config.metadataGlobs);for(let c of e.routeDrafts){let{requestedSlug:p,slugType:m,canonicalSlug:v}=n?h({route:c,locale:n.locale,canonicalPath:n.canonicalPath,localeContext:n.localeContext,resolveCanonicalRoute:e.resolveCanonicalRoute}):{...g(c,e.filePath??``),canonicalSlug:``},b=`${c.routeId}\u0000${p}`;if(_.has(b))continue;_.add(b);let{rbac:S,excludeFromSearch:C,...w}=l(c.metadata?.metadata)?c.metadata.metadata:{},T=t({...x,...c.metadata,...w}),E=null;if(c.sidebarSubtree){let e=i(c.sidebarSubtree);a.set(e.key,e),E=e.key}for(let[t,n]of Object.entries(c.deps??{})){let r=y({dependency:n,describeEntity:i,key:t,registerEntity:e=>{a.set(e.key,e)},routeSlug:p,sourcePath:e.filePath??void 0});o.push({...r,routeId:c.routeId})}if(e.filePath!==null&&e.revisions?.isTracked(e.filePath)||r){let e=[...new Set(o.filter(e=>e.routeSlug===p&&e.dependencyType===`entity`&&!u(e.key)).map(e=>e.target))];o.push({args:{entityKeys:e,routeSlug:p},dependencyType:`serverFn`,key:f,routeId:c.routeId,routeSlug:p,target:d}),T.revisionsEnabled=!0}s.push({metadata:T,pluginId:e.pluginId,routeId:c.routeId,sidebarSubtreeEntityKey:E,wildcardPrefix:c.wildcardPrefix===!0,slug:p,requestedSlug:p,slugType:m,template:c.template?.trim()||``,versionGroup:r?.versionGroup??null,version:r?.version??null,locale:n?n.locale:``,isFallback:!1,canonicalSlug:v})}return{routeDependencies:o,routes:s,entities:[...a.values()].sort((e,t)=>c(e.key,t.key))}}function v(e){let{filePath:t,localeContext:n}=e;if(t===null||n===void 0||!n.isL10nPath(t))return null;if(!n.enabled)return`skip`;let{locale:r,canonicalPath:i}=n.splitLocaleFromPath(t);return i===``||!n.isLocale(r)?`skip`:{locale:r,canonicalPath:i,localeContext:n}}function y(e){let{dependency:t,key:n,routeSlug:r}=e;if(s(t))return{args:S(t.args,t=>{let n=e.describeEntity(t);return e.registerEntity(n),n.key}),dependencyType:`serverFn`,key:n,routeSlug:r,target:t.id};if(!a(t)){let t=e.sourcePath?` on "${e.sourcePath}"`:``;throw Error(`Unsupported route dependency "${n}"${t}.`)}let i=e.describeEntity(t);return e.registerEntity(i),{args:null,dependencyType:`entity`,key:n,routeSlug:r,target:i.key}}function b(e,t,n=null){let r=/* @__PURE__ */ new Map;return i=>{let a=r.get(i);return a===void 0&&(a=x(e,t,i,n),r.set(i,a)),a}}function x(t,n,a,s=null){if(i(a)){let t=a.key?.trim()||null;return{loaderArgs:null,kind:`inline`,type:a.type??null,metadata:a.metadata??null,loaderId:null,pluginId:n,shouldInvalidateValue:!1,key:t??`inline:${e(a.value)}`,value:a.value,isSystem:!1,version:s,searchable:a.searchable}}if(!r(a))throw Error(`Unsupported entity reference.`);let c=a.key?.trim()||null,l=S(a.args,e=>o(x(t,n,e,s).key)),u=t.pluginRegistry.getEntityLoaderById(a.id);if(!u)throw Error(`Entity loader "${a.id}" is not registered.`);return{loaderArgs:l,kind:`loader`,type:a.type??null,metadata:a.metadata??null,loaderId:a.id,pluginId:u.pluginId,shouldInvalidateValue:!0,key:c??`${a.id}:${e(l)}`,value:null,isSystem:!1,version:s}}function S(e,t){if(a(e))return t(e);if(Array.isArray(e))return e.map(e=>S(e,t));if(e&&typeof e==`object`){let r=Object.entries(e).map(([e,n])=>[e,S(n,t)]);return n(Object.fromEntries(r))}return n(e)}export{b as createEntityDescriber,x as createEntityDescriptor,_ as normalizePluginArtifacts,y as normalizeRouteDependency};
|