@redocly/revel 0.141.0-next.5 → 0.141.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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @redocly/revel
2
2
 
3
+ ## 0.141.0-next.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 4fe1a869003: Fixed an issue where the cookie consent banner moved with animated page content in customized layouts.
8
+ - 4fe1a869003: Fixed an issue where the local preview floating bar moved with animated page content in customized layouts.
9
+ - Updated dependencies [79920583248]
10
+ - @redocly/api-docs@0.6.0-next.6
11
+
3
12
  ## 0.141.0-next.5
4
13
 
5
14
  ### Patch Changes
@@ -1 +1 @@
1
- import*as o from"react";import{Outlet as g,useLocation as h,useNavigate as P}from"react-router";import{useEffect as i,useMemo as c,useState as S,Suspense as D}from"react";import{withoutPathPrefix as T}from"@redocly/theme/core/utils";import{useThemeConfig as v}from"@redocly/theme/core/hooks";import{InternalServerErrorLayout as L}from"@redocly/theme/layouts/InternalServerErrorLayout";import{RootLayout as C}from"@redocly/theme/layouts/RootLayout";import{Consent as y}from"@redocly/theme/components/Consent/Consent";import{LoadProgressBar as R}from"@redocly/theme/components/LoadProgressBar/LoadProgressBar";import{PageLayout as _}from"@redocly/theme/layouts/PageLayout";import{components as I}from"@redocly/theme/markdoc/default";import{Sidebar as N}from"./app/Sidebar/Sidebar";import{loadAndNavigate as O}from"./app/utils/loadAndNavigate";import{useActions as A}from"./app/Sidebar/useActions";import{useScrollTracker as b}from"./app/hooks/useScrollTracker";import{useAutoScroll as k}from"./app/hooks/useAutoScroll";import{API_DOCS_TEMPLATE_ID as u}from"../constants/common";import{removeTrailingSlash as M}from"../utils/url/remove-trailing-slash";import{removeLeadingSlash as x}from"../utils/url/remove-leading-slash";import*as B from"./app/markdoc/custom-components/index";import{DefaultStyles as G}from"./styling/default-styles";import{ThemeDataProvider as V}from"./providers/theme/ThemeDataProvider";import{PageDataContext as F}from"./providers/page-data/PageDataContext";import{SeoTags as w}from"./app/seo/SeoTags";import{useRouterForLocalLinks as U,useRunningEnvironmentCheck as W}from"./providers/hooks";import{usePageData as j,usePageDataLoader as q}from"./providers/page-data/hooks";import{ErrorBoundary as z}from"./ErrorBoundary";import{ErrorDetails as f,Loader as H}from"./server-entry";import"@styles";import{useRouteChangeTracker as J}from"./app/hooks/useRouteChangeTracker";import{useWebMcpTools as K}from"./app/webmcp";import{isInIframe as Q}from"./utils";import{useL10n as X}from"./app/l10n";import{PostMessageProvider as Y}from"./providers/post-message/PostMessageProvider";import{ScriptLoader as Z}from"./ScriptLoader";import{clientRoutes as $}from"./runtime/generated/routes.js";import{DevModeFloatingBar as ee}from"./app/DevModeFloatingBar";import{usePageTimeTracker as oe}from"./app/hooks/usePageTimeTracker";import{useMarkdocRenderer as re}from"./app/hooks/markdown/useMarkdocRenderer";globalThis.__LOADER.markdocComponents={...B,...I};function te(){const{palette:e}=v();return o.createElement(G,{palette:e})}function je(){const e=q(),[t,n]=S(e),r=h(),m=P();X(),i(()=>{e?n(e):O({navigate:m,to:r.pathname+r.search+r.hash}).then(()=>n(H.loadSync(r.pathname)))},[r,m]),U();const a=W();return a?(console.log(a),o.createElement(f,{error:{message:a,name:""}})):t?o.createElement(z,null,o.createElement(F.Provider,{value:e||t},o.createElement(V,null,o.createElement(te,null),o.createElement(R,null),o.createElement(Y,{enabled:process.env.NODE_ENV==="development"||Q()},o.createElement(g,null))))):null}function ne(){return k(),null}function E(){J(),oe(),b(),K();const e=j(),t=A(),{layout:n}=t,r=c(()=>({layout:n}),[n]),m=process.env.NODE_ENV!=="production",a=globalThis.SSR_OMIT_SUSPENSE,s=re(e?.props?.ast),d=M(e?.slug||"");i(()=>{document.documentElement.classList.add("ready")},[]);const l=c(()=>[u].includes(e?.templateId??"")?{...e?.props,apiOptions:r}:e?.props,[e?.props,e?.templateId,r]);if(e?.props.pagePropGetterError?.message)return m?o.createElement(f,{error:{...e?.props?.pagePropGetterError}}):o.createElement(L,null);if(!!e?.props?.compilationErrors?.length)return e?.Template?o.createElement(e.Template,{pageProps:e?.props,children:s}):null;const p=()=>o.createElement(C,null,e?.templateId!==u&&o.createElement(ne,null),o.createElement(_,{sidebar:o.createElement(N,{layoutControls:t})},o.createElement(w,{seo:e?.props.seo,slug:d}),e?.Template&&l?o.createElement(e.Template,{pageProps:l,children:s}):null),process.env.NODE_ENV!=="production"&&o.createElement(ee,null),o.createElement(Z,null),o.createElement(y,null));return a?p():o.createElement(D,null,p())}const qe=[...$.map(e=>({Component:E,path:x(T(e).substring(1)+"/*")})),{Component:E,path:"*"}];export{je as App,E as Page,qe as routes};
1
+ import*as t from"react";import{Outlet as d,useLocation as h,useNavigate as P}from"react-router";import{useEffect as i,useMemo as c,useState as S,Suspense as D}from"react";import{withoutPathPrefix as T}from"@redocly/theme/core/utils";import{useThemeConfig as v}from"@redocly/theme/core/hooks";import{InternalServerErrorLayout as L}from"@redocly/theme/layouts/InternalServerErrorLayout";import{RootLayout as C}from"@redocly/theme/layouts/RootLayout";import{Consent as y}from"@redocly/theme/components/Consent/Consent";import{LoadProgressBar as R}from"@redocly/theme/components/LoadProgressBar/LoadProgressBar";import{PageLayout as _}from"@redocly/theme/layouts/PageLayout";import{components as I}from"@redocly/theme/markdoc/default";import{Sidebar as N}from"./app/Sidebar/Sidebar";import{loadAndNavigate as O}from"./app/utils/loadAndNavigate";import{useActions as A}from"./app/Sidebar/useActions";import{useScrollTracker as b}from"./app/hooks/useScrollTracker";import{useAutoScroll as k}from"./app/hooks/useAutoScroll";import{API_DOCS_TEMPLATE_ID as u}from"../constants/common";import{removeTrailingSlash as M}from"../utils/url/remove-trailing-slash";import{removeLeadingSlash as x}from"../utils/url/remove-leading-slash";import*as B from"./app/markdoc/custom-components/index";import{DefaultStyles as F}from"./styling/default-styles";import{ThemeDataProvider as G}from"./providers/theme/ThemeDataProvider";import{PageDataContext as V}from"./providers/page-data/PageDataContext";import{SeoTags as w}from"./app/seo/SeoTags";import{useRouterForLocalLinks as U,useRunningEnvironmentCheck as W}from"./providers/hooks";import{usePageData as j,usePageDataLoader as q}from"./providers/page-data/hooks";import{ErrorBoundary as z}from"./ErrorBoundary";import{ErrorDetails as f,Loader as H}from"./server-entry";import"@styles";import{useRouteChangeTracker as J}from"./app/hooks/useRouteChangeTracker";import{useWebMcpTools as K}from"./app/webmcp";import{isInIframe as Q}from"./utils";import{useL10n as X}from"./app/l10n";import{PostMessageProvider as Y}from"./providers/post-message/PostMessageProvider";import{ScriptLoader as Z}from"./ScriptLoader";import{clientRoutes as $}from"./runtime/generated/routes.js";import{DevModeFloatingBar as ee}from"./app/DevModeFloatingBar";import{usePageTimeTracker as te}from"./app/hooks/usePageTimeTracker";import{useMarkdocRenderer as oe}from"./app/hooks/markdown/useMarkdocRenderer";globalThis.__LOADER.markdocComponents={...B,...I};function re(){const{palette:e}=v();return t.createElement(F,{palette:e})}function je(){const e=q(),[r,n]=S(e),o=h(),m=P();X(),i(()=>{e?n(e):O({navigate:m,to:o.pathname+o.search+o.hash}).then(()=>n(H.loadSync(o.pathname)))},[o,m]),U();const a=W();return a?(console.log(a),t.createElement(f,{error:{message:a,name:""}})):r?t.createElement(z,null,t.createElement(V.Provider,{value:e||r},t.createElement(G,null,t.createElement(re,null),t.createElement(R,null),t.createElement(Y,{enabled:process.env.NODE_ENV==="development"||Q()},t.createElement(d,null))))):null}function ne(){return k(),null}function E(){J(),te(),b(),K();const e=j(),r=A(),{layout:n}=r,o=c(()=>({layout:n}),[n]),m=process.env.NODE_ENV!=="production",a=globalThis.SSR_OMIT_SUSPENSE,l=oe(e?.props?.ast),g=M(e?.slug||"");i(()=>{document.documentElement.classList.add("ready")},[]);const s=c(()=>[u].includes(e?.templateId??"")?{...e?.props,apiOptions:o}:e?.props,[e?.props,e?.templateId,o]);if(e?.props.pagePropGetterError?.message)return m?t.createElement(f,{error:{...e?.props?.pagePropGetterError}}):t.createElement(L,null);if(!!e?.props?.compilationErrors?.length)return e?.Template?t.createElement(e.Template,{pageProps:e?.props,children:l}):null;const p=()=>t.createElement(t.Fragment,null,t.createElement(C,null,e?.templateId!==u&&t.createElement(ne,null),t.createElement(_,{sidebar:t.createElement(N,{layoutControls:r})},t.createElement(w,{seo:e?.props.seo,slug:g}),e?.Template&&s?t.createElement(e.Template,{pageProps:s,children:l}):null),t.createElement(Z,null)),t.createElement(y,null),process.env.NODE_ENV!=="production"&&t.createElement(ee,null));return a?p():t.createElement(D,null,p())}const qe=[...$.map(e=>({Component:E,path:x(T(e).substring(1)+"/*")})),{Component:E,path:"*"}];export{je as App,E as Page,qe as routes};
@@ -1,8 +1,7 @@
1
1
  export declare function isRecord(value: unknown): value is Record<string, unknown>;
2
2
  /**
3
- * Markdown mirror of a prefixed route, mirroring `getLlmsTxtMdPathBySlug` on the server. The site
4
- * root resolves to `index.html.md`; every other route gains a `.md` suffix. The query and the
5
- * fragment are dropped, so the suffix always lands on the pathname and can never select another route.
3
+ * The Markdown copy of a prefixed route. The query and the fragment are dropped, so the `.md`
4
+ * suffix always lands on the pathname and can never select another route.
6
5
  */
7
6
  export declare function markdownPathForRoute(pathname: string): string;
8
7
  /** Returns the normalized path only when it stays on this site, so a tool can never navigate off-origin. */
@@ -1 +1 @@
1
- import{withPathPrefix as s,withoutPathPrefix as c}from"@redocly/theme/core/utils";function a(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function f(t){const[r=t]=t.split("#"),[n=r]=r.split("?"),e=c(n),i=e.length>1?e.replace(/\/$/,""):"/";return s(`${i}${i==="/"?"index.html.md":".md"}`)}const o="https://site.invalid";function p(t){const r=t.trim();if(!r.startsWith("/"))return;const n=URL.parse(r,o);if(n?.origin===o)return`${n.pathname}${n.search}${n.hash}`}async function h(t){const r=await fetch(t,{headers:{accept:"text/plain"}});if(r.ok)return await r.text()}function d(t,r,n){const e=typeof t=="number"?t:Number(t);return!Number.isFinite(e)||e<=0?r:Math.min(Math.floor(e),n)}function m(t){return Array.isArray(t)?t.join(" "):t??""}export{d as clampLimit,h as fetchText,a as isRecord,m as joinField,f as markdownPathForRoute,p as toSitePath};
1
+ import{getMarkdownCopyPath as s,withPathPrefix as a,withoutPathPrefix as c}from"@redocly/theme/core/utils";function f(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function p(t){const[r=t]=t.split("#"),[n=r]=r.split("?"),e=c(n),o=e.length>1?e.replace(/\/$/,""):"/";return a(s(o))}const i="https://site.invalid";function h(t){const r=t.trim();if(!r.startsWith("/"))return;const n=URL.parse(r,i);if(n?.origin===i)return`${n.pathname}${n.search}${n.hash}`}async function d(t){const r=await fetch(t,{headers:{accept:"text/plain"}});if(r.ok)return await r.text()}function m(t,r,n){const e=typeof t=="number"?t:Number(t);return!Number.isFinite(e)||e<=0?r:Math.min(Math.floor(e),n)}function x(t){return Array.isArray(t)?t.join(" "):t??""}export{m as clampLimit,d as fetchText,f as isRecord,x as joinField,p as markdownPathForRoute,h as toSitePath};
@@ -1 +1 @@
1
- import*as p from"workerpool";import{withPathPrefix as f}from"@redocly/theme/core/utils";import{envConfig as u}from"../config/env-config.js";import{telemetry as a}from"../telemetry/index.js";import{TimeoutExceededError as g}from"./errors/timeout-exceeded.js";import{serializeRequest as E}from"./helpers/serialize-request.js";import{apiRoutesWorkers as A,API_ROUTES_WORKER_KEY as T}from"../workers/api-routes-worker-pool.js";import{API_FUNCTIONS_REQUEST_HANDLER_ID as m}from"../plugins/api-functions/index.js";import{toWorkerConfig as h}from"../workers/worker-config.js";const S=1e4,R=15;async function U(e,r,i){a.initialize();const o=r.get("auth"),s=await i.resolveRouteStaticData(e)||{},n=f(e.slug);try{const{status:t,headers:l,body:c}=await A.exec(T,[{serverOutDir:i.serverOutDir,slug:n,requestHandlerId:e.requestHandlerId,maxResponseSizeMB:R,ctxData:{user:{teams:o.teams,email:o.claims.email,claims:o.claims,idpAccessToken:o.idpAccessToken,idpId:o.claims.idpId,isAuthenticated:o.isAuthenticated},config:h(i.config,i.configFile),outdir:i.outdir,baseUrl:new URL(r.req.url).origin},staticData:{...s,props:{...s.props,routeSlug:n,outdir:i.outdir}},req:await E(r.req.raw),sqldRemoteDatabaseUrl:u.SQLD_REMOTE_DATABASE_URL,sqldRemoteDatabaseAuthToken:u.SQLD_REMOTE_DATABASE_AUTH_TOKEN}],{timeout:S});_({requestHandlerId:e.requestHandlerId,status:t,ctx:r});const d=c.data?Buffer.from(c.data):null;return new Response(d,{status:t,headers:l})}catch(t){throw M({requestHandlerId:e.requestHandlerId,error:t}),t instanceof p.Promise.TimeoutError?new g("Timeout exceeded"):t}}function _({requestHandlerId:e,status:r,ctx:i}){e.startsWith(m)?a.sendApiFunctionCalledMessage([{id:"apiFunctionId",object:"apiFunction",uri:"urn:redocly:realm:api:apiFunction:apiFunctionId",handler:e,status:r,message:null}]):a.sendMockServerCalledMessage([{id:e,object:"mockServer",uri:`urn:redocly:realm:api:mockServer:${e}`,error:null,handler:e,headers:{"user-agent":i.req.header("user-agent")??null},status:r}])}function M({requestHandlerId:e,error:r}){e.startsWith(m)?a.sendApiFunctionErrorMessage([{id:"apiFunctionId",object:"apiFunction",uri:"urn:redocly:realm:api:apiFunction:apiFunctionId",status:500,handler:e,message:r.message}]):a.sendMockServerErrorMessage([{id:e,object:"mockServer",uri:`urn:redocly:realm:api:mockServer:${e}`,handler:e,message:r.message}])}export{U as runApiRoutesWorker,M as sendTelemetryErrorMessage};
1
+ import*as p from"workerpool";import{withPathPrefix as f}from"@redocly/theme/core/utils";import{envConfig as m}from"../config/env-config.js";import{telemetry as a}from"../telemetry/index.js";import{TimeoutExceededError as g}from"./errors/timeout-exceeded.js";import{serializeRequest as E}from"./helpers/serialize-request.js";import{apiRoutesWorkers as A,API_ROUTES_WORKER_KEY as S}from"../workers/api-routes-worker-pool.js";import{API_FUNCTIONS_REQUEST_HANDLER_ID as u}from"../plugins/api-functions/index.js";import{toWorkerConfig as T}from"../workers/worker-config.js";const h=1e4,R=15;async function U(e,r,i){a.initialize();const o=r.get("auth"),s=await i.resolveRouteStaticData(e)||{},n=f(e.slug);try{const{status:t,headers:l,body:c}=await A.exec(S,[{serverOutDir:i.serverOutDir,slug:n,requestHandlerId:e.requestHandlerId,maxResponseSizeMB:e.maxResponseSizeMB??R,ctxData:{user:{teams:o.teams,email:o.claims.email,claims:o.claims,idpAccessToken:o.idpAccessToken,idpId:o.claims.idpId,isAuthenticated:o.isAuthenticated},config:T(i.config,i.configFile),outdir:i.outdir,baseUrl:new URL(r.req.url).origin},staticData:{...s,props:{...s.props,routeSlug:n,outdir:i.outdir}},req:await E(r.req.raw),sqldRemoteDatabaseUrl:m.SQLD_REMOTE_DATABASE_URL,sqldRemoteDatabaseAuthToken:m.SQLD_REMOTE_DATABASE_AUTH_TOKEN}],{timeout:e.timeoutMs??h});_({requestHandlerId:e.requestHandlerId,status:t,ctx:r});const d=c.data?Buffer.from(c.data):null;return new Response(d,{status:t,headers:l})}catch(t){throw M({requestHandlerId:e.requestHandlerId,error:t}),t instanceof p.Promise.TimeoutError?new g("Timeout exceeded"):t}}function _({requestHandlerId:e,status:r,ctx:i}){e.startsWith(u)?a.sendApiFunctionCalledMessage([{id:"apiFunctionId",object:"apiFunction",uri:"urn:redocly:realm:api:apiFunction:apiFunctionId",handler:e,status:r,message:null}]):a.sendMockServerCalledMessage([{id:e,object:"mockServer",uri:`urn:redocly:realm:api:mockServer:${e}`,error:null,handler:e,headers:{"user-agent":i.req.header("user-agent")??null},status:r}])}function M({requestHandlerId:e,error:r}){e.startsWith(u)?a.sendApiFunctionErrorMessage([{id:"apiFunctionId",object:"apiFunction",uri:"urn:redocly:realm:api:apiFunction:apiFunctionId",status:500,handler:e,message:r.message}]):a.sendMockServerErrorMessage([{id:e,object:"mockServer",uri:`urn:redocly:realm:api:mockServer:${e}`,handler:e,message:r.message}])}export{U as runApiRoutesWorker,M as sendTelemetryErrorMessage};
@@ -1 +1 @@
1
- import{REDOCLY_ROUTE_RBAC as w,REDOCLY_TEAMS_RBAC as I}from"@redocly/config";import{mcpTagSchemas as ae,schemaDefinitionTag as ie,markdocParser as U,collectPreviousRouteSlugs as se}from"@redocly/api-docs";import{withPathPrefix as $}from"@redocly/theme/core/utils";import{API_DOCS_TEMPLATE_ID as j,GRAPHQL_SPEC_SLUG as ne,PUBLIC_RBAC_SCOPE_ITEM as N}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ce,PUBLIC_API_DEFINITIONS_FOLDER as pe}from"../../constants/common.js";import{API_DOCS_SHARED_DATA_PREFIX as O}from"../../constants/plugins/api-docs.js";import{fromCurrentDir as ue}from"../../utils/paths.js";import{normalizeRouteSlug as le}from"../../../utils/path/normalize-route-slug.js";import{removeTrailingSlash as de}from"../../../utils/url/remove-trailing-slash.js";import{isTranslationFallback as me}from"../../fs/utils/is-translation-fallback.js";import{createSlugify as fe}from"../create-slugify.js";import{apiDocLoader as ge,apiDocsLoader as he}from"./loader.js";import{getTemplatePath as V}from"./get-template-path.js";import{storeDefinitionBundles as Se}from"./store-definition-bundles.js";import{definitionAccessKey as De,describeDefinitionAccess as Pe}from"./definition-access.js";import{telemetryTraceStep as ye}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as ve}from"./search/search-resolver.js";import{getAiDocumentsStore as Ae}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as Ie}from"../get-api-config.js";import{getRouteSlugsForPath as Re}from"../utils.js";import{collectItemRoutes as be}from"./utils/collect-item-routes.js";import{isChunkCurrent as _e}from"./utils/decorators.js";import{applyNavItemToRoot as Ce}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as we}from"./utils/build-routes-mapping.js";import{buildItemPositions as Te}from"./utils/build-item-positions.js";import{resolveApiDocTitle as ke}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as K}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as Ee}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as Oe}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as W}from"./import-api-docs-builder.js";import{envConfig as G}from"../../config/env-config.js";import{logger as Fe}from"../../tools/notifiers/logger.js";const F="openapi-spec-download",Me={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function Dt(){let t=[],r=new Map;const a=new WeakMap;let i=new Set,g={},v={};function X(o,D,R){const A=a.get(o)??new Map;a.set(o,A);const P=D??"";return A.get(P)===R?!1:(A.set(P,R),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":ge,"api-docs":he},processContent:async(o,D)=>{await ye("com.redocly.build.plugin.apiDocs",async()=>{o.createRequestHandler(F,ue(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:pe+"/*",requestHandlerId:F,httpMethod:"all",[I]:N,getStaticData:async()=>({props:{definitionAccess:v}})}),o.addApiRoute({slug:ce+"/*",requestHandlerId:F,httpMethod:"all",[I]:N,getStaticData:async()=>({props:{definitionAccess:v}})}),o.addApiRoute({slug:ne+"/*",requestHandlerId:F,httpMethod:"all",[I]:N,getStaticData:async()=>({props:{definitionAccess:v}})});const R=o.createTemplate(j,V("../../../client/templates/api-docs/template.js")),A=o.registerServerPropsGetter(j,V("./get-server-props.js")),P=await D.getConfig();r=new Map,g={};const y=await o.loadApiDocuments(D);Se(y,o.outdir),v={};const T=!!P.plugins?.some(e=>typeof e=="string"&&e.startsWith("@redocly/portal-plugin-async-api/"));T&&y.some(e=>e.type==="asyncapi")&&Fe.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=T?y.filter(e=>e.type!=="asyncapi"):y;t=c.map(({markdocChunks:e,relativePath:u,isVirtual:p,customOutputRelativeFile:s,realRelativePath:S})=>({chunks:e??[],relativePath:u,realRelativePath:S,isVirtual:s!=null||p}));const{buildItems:n}=await W(o.serverOutDir),m=(await D.cache.load("content-slugs","content-slugs")).data,h=fe(m),k=e=>le(h(e));for(const e of y){const u=De(e);if(u===void 0)continue;const p=k(e.customOutputRelativeFile||e.relativePath);v[u]=Pe(e,p)}for(const e of c){const u=e.customOutputRelativeFile||e.relativePath,p=k(u);qe(e,p);const{items:s,store:S}=await n({type:e.type,document:e.document,options:e.options,basePath:p,markdownParser:U}),b=`${O}${e.relativePath}`,M=G.isDevelopMode?e.relativePath:void 0,l=$e(e.document),_=l?.["x-metadata"],C=e.isVirtual?void 0:_?.apiId,B={document:e,basePath:p,sourcePath:M,apiId:C,build:{items:s,store:S}};await o.createSharedData(b,z(B,s,S));const J=K(e.config),L=!!e.options.excludeFromSearch,Z=e.type==="openapi",ee=be(s,J),te=me(e),f=ee.map(d=>{const x=d.metadata?.seo,E={fsPath:u,templateId:R,sharedData:[{key:"apiDocsStore",id:b}],serverPropsGetterIds:[A],excludeFromSearch:L,getStaticData:Le(d.label,x,te),[I]:d[I]};return Object.assign(E,xe(d.link,p)),Z&&d.httpVerb&&(E.httpVerb=d.httpVerb,E.metadata={subType:"openapi-operation"}),E});if(!f.length)continue;const H=ke(l,e.type,s),oe=Oe(l?.version),q={type:e.type,title:H,version:oe,description:typeof l?.description=="string"?l.description:void 0,summary:typeof l?.summary=="string"?l.summary:void 0,...l?.["x-metadata"]&&typeof l["x-metadata"]=="object"?l["x-metadata"]:{}};f[0]={...f[0],metadata:q,hasClientRoutes:!0,getSidebar:(d,x)=>Ce(Y(s),p,x),getNavText:()=>H??Me[e.type]??"API Docs",getSearchDocuments:ve(s,q,o.getSearchFacets,o.setSearchFacets,L,S,e.document),getAiDocumentsStore:Ae({getBuild:()=>B.build,metadata:q,document:e.document,specType:e.type,excludeFromSearch:L,basePath:p,getSearchFacets:o.getSearchFacets,markdocTags:{...ae,schemaDefinition:ie}})};const re=f[0];f[0]=f[f.length-1],f[f.length-1]=re;for(const d of f)o.addRoute(d);if(C){const d=Ie(e.config?.apis,e.realRelativePath);g[C]={[I]:d.rbac,[w]:{fsPath:u}}}r.set(b,B)}})},afterRoutesCreated:async(o,D)=>{const{buildItems:R,simplifyAstStructure:A}=await W(o.serverOutDir);for(const c of r.values())Q(o,c.build.items);const P=new Set,y=new Set;for(const{chunks:c,relativePath:n,isVirtual:m}of t){const h=`${O}${n}`,k=Re(o.getAllRoutes(),n);for(const{node:e,markdown:u,pointer:p,key:s,relativePath:S}of c){const{ast:b,compoundHash:M}=await o.parseMarkdoc({input:{content:u,relativePath:S,isVirtual:m},resource:p,context:D,deps:{sharedDataIds:[`${O}${S}`],routeSlugs:k}});if(P.add(p),!(s==="graphql-docs"?e?.description?.value!==void 0:!!s&&_e(e,s,u))||!X(e,s,M))continue;y.add(h);const _=A(b);if(s==="graphql-docs"){e.description&&(e.description.value=_);const C=`${O}${S}`;Be(r.get(C),_)}else s&&(e[s]=_)}}const T=i.difference(P);for(const c of T)D.cache.delete(c);i=P,Object.entries(g).forEach(([c,n])=>{const m=n[w]?.fsPath;if(!m)return;const h=o.getRouteByFsPath(m)?.baseSlug;g[c]={...n,[w]:{...n[w],slug:h},slug:h}}),o.setGlobalData({apiProducts:g});for(const[c,n]of r){if(!y.has(c))continue;const{items:m,store:h}=await R({type:n.document.type,document:n.document.document,options:n.document.options,basePath:n.basePath,markdownParser:U});n.build={items:m,store:h},Q(o,m),await o.createSharedData(c,z(n,m,h))}}}}function Q(t,r){for(const{from:a,to:i}of se(r))t.getConfig().redirects?.[a]||t.getRouteBySlug(a,{followRedirect:!1})||(t.addRouteAlias(a,i),t.addRedirect(a,{to:i},{trackOriginalSource:!1}))}function z({document:t,basePath:r,sourcePath:a,apiId:i},g,v){return{[I]:K(t.config),[w]:{slug:de(r),fsPath:t.customOutputRelativeFile||t.relativePath},items:g,store:v,options:t.options,baseSlug:r,routesMapping:G.isDevelopMode?we(g,r):{},graphqlPositions:G.isDevelopMode&&t.type==="graphql"?Te(g,r):void 0,sourcePath:a,apiId:i}}function Be(t,r){t?.document.type!=="graphql"||!t.document.options||(t.document.options.info={...t.document.options.info||{},description:r})}function Le(t,r,a){return async function(i){return{...a?{isTranslationFallback:!0}:{},props:{settings:{baseUrlPath:$(i.baseSlug)},disableAutoScroll:!0,seo:{title:t,...r}}}}}function qe(t,r){const a=t.options?.mockServer,i=$(`/_mock${Ee(t.relativePath)}`);a?.url===i&&(t.options={...t.options,mockServer:{...a,url:$(`/_mock${r}`)}})}function xe(t,r){if(t===r)return{};const a=r==="/"?"/":`${r}/`;if(t.startsWith(a)){const i=t.slice(a.length);return i?{slugSuffix:i}:{}}return{slug:t}}function $e(t){if(t&&typeof t=="object"&&"info"in t)return t.info}function Y(t){return t.map(({content:r,items:a,...i})=>({...i,...a&&{items:Y(a)}}))}export{Dt as apiDocsPlugin,xe as toRouteSlugFields};
1
+ import{REDOCLY_ROUTE_RBAC as T,REDOCLY_TEAMS_RBAC as I}from"@redocly/config";import{mcpTagSchemas as ae,schemaDefinitionTag as ie,markdocParser as j,collectPreviousRouteSlugs as ne}from"@redocly/api-docs";import{withPathPrefix as N}from"@redocly/theme/core/utils";import{API_DOCS_TEMPLATE_ID as V,GRAPHQL_SPEC_SLUG as ce,PUBLIC_RBAC_SCOPE_ITEM as $}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as pe,PUBLIC_API_DEFINITIONS_FOLDER as ue}from"../../constants/common.js";import{API_DOCS_SHARED_DATA_PREFIX as O}from"../../constants/plugins/api-docs.js";import{fromCurrentDir as le}from"../../utils/paths.js";import{normalizeRouteSlug as de}from"../../../utils/path/normalize-route-slug.js";import{removeTrailingSlash as me}from"../../../utils/url/remove-trailing-slash.js";import{isTranslationFallback as fe}from"../../fs/utils/is-translation-fallback.js";import{createSlugify as ge}from"../create-slugify.js";import{apiDocLoader as he,apiDocsLoader as Se}from"./loader.js";import{getTemplatePath as W}from"./get-template-path.js";import{storeDefinitionBundles as De}from"./store-definition-bundles.js";import{definitionAccessKey as Pe,describeDefinitionAccess as ye}from"./definition-access.js";import{telemetryTraceStep as Ae}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as ve}from"./search/search-resolver.js";import{getAiDocumentsStore as Ie}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as Re}from"../get-api-config.js";import{getRouteSlugsForPath as be}from"../utils.js";import{collectItemRoutes as _e}from"./utils/collect-item-routes.js";import{isChunkCurrent as Ce}from"./utils/decorators.js";import{applyNavItemToRoot as Te}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as we}from"./utils/build-routes-mapping.js";import{buildItemPositions as Ee}from"./utils/build-item-positions.js";import{resolveApiDocTitle as ke}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as K}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as Oe}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as Fe}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as z}from"./import-api-docs-builder.js";import{envConfig as G}from"../../config/env-config.js";import{logger as Me}from"../../tools/notifiers/logger.js";const F="openapi-spec-download",H={timeoutMs:15e3,maxResponseSizeMB:20},Le={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function Pt(){let t=[],r=new Map;const s=new WeakMap;let a=new Set,g={},A={};function J(o,D,R){const v=s.get(o)??new Map;s.set(o,v);const P=D??"";return v.get(P)===R?!1:(v.set(P,R),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":he,"api-docs":Se},processContent:async(o,D)=>{await Ae("com.redocly.build.plugin.apiDocs",async()=>{o.createRequestHandler(F,le(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:ue+"/*",requestHandlerId:F,httpMethod:"all",...H,[I]:$,getStaticData:async()=>({props:{definitionAccess:A}})}),o.addApiRoute({slug:pe+"/*",requestHandlerId:F,httpMethod:"all",...H,[I]:$,getStaticData:async()=>({props:{definitionAccess:A}})}),o.addApiRoute({slug:ce+"/*",requestHandlerId:F,httpMethod:"all",...H,[I]:$,getStaticData:async()=>({props:{definitionAccess:A}})});const R=o.createTemplate(V,W("../../../client/templates/api-docs/template.js")),v=o.registerServerPropsGetter(V,W("./get-server-props.js")),P=await D.getConfig();r=new Map,g={};const y=await o.loadApiDocuments(D);De(y,o.outdir),A={};const w=!!P.plugins?.some(e=>typeof e=="string"&&e.startsWith("@redocly/portal-plugin-async-api/"));w&&y.some(e=>e.type==="asyncapi")&&Me.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=w?y.filter(e=>e.type!=="asyncapi"):y;t=c.map(({markdocChunks:e,relativePath:u,isVirtual:p,customOutputRelativeFile:i,realRelativePath:S})=>({chunks:e??[],relativePath:u,realRelativePath:S,isVirtual:i!=null||p}));const{buildItems:n}=await z(o.serverOutDir),m=(await D.cache.load("content-slugs","content-slugs")).data,h=ge(m),E=e=>de(h(e));for(const e of y){const u=Pe(e);if(u===void 0)continue;const p=E(e.customOutputRelativeFile||e.relativePath);A[u]=ye(e,p)}for(const e of c){const u=e.customOutputRelativeFile||e.relativePath,p=E(u);xe(e,p);const{items:i,store:S}=await n({type:e.type,document:e.document,options:e.options,basePath:p,markdownParser:j}),b=`${O}${e.relativePath}`,M=G.isDevelopMode?e.relativePath:void 0,l=$e(e.document),_=l?.["x-metadata"],C=e.isVirtual?void 0:_?.apiId,L={document:e,basePath:p,sourcePath:M,apiId:C,build:{items:i,store:S}};await o.createSharedData(b,Y(L,i,S));const Z=K(e.config),B=!!e.options.excludeFromSearch,ee=e.type==="openapi",te=_e(i,Z),oe=fe(e),f=te.map(d=>{const x=d.metadata?.seo,k={fsPath:u,templateId:R,sharedData:[{key:"apiDocsStore",id:b}],serverPropsGetterIds:[v],excludeFromSearch:B,getStaticData:qe(d.label,x,oe),[I]:d[I]};return Object.assign(k,Ne(d.link,p)),ee&&d.httpVerb&&(k.httpVerb=d.httpVerb,k.metadata={subType:"openapi-operation"}),k});if(!f.length)continue;const U=ke(l,e.type,i),re=Fe(l?.version),q={type:e.type,title:U,version:re,description:typeof l?.description=="string"?l.description:void 0,summary:typeof l?.summary=="string"?l.summary:void 0,...l?.["x-metadata"]&&typeof l["x-metadata"]=="object"?l["x-metadata"]:{}};f[0]={...f[0],metadata:q,hasClientRoutes:!0,getSidebar:(d,x)=>Te(X(i),p,x),getNavText:()=>U??Le[e.type]??"API Docs",getSearchDocuments:ve(i,q,o.getSearchFacets,o.setSearchFacets,B,S,e.document),getAiDocumentsStore:Ie({getBuild:()=>L.build,metadata:q,document:e.document,specType:e.type,excludeFromSearch:B,basePath:p,getSearchFacets:o.getSearchFacets,markdocTags:{...ae,schemaDefinition:ie}})};const se=f[0];f[0]=f[f.length-1],f[f.length-1]=se;for(const d of f)o.addRoute(d);if(C){const d=Re(e.config?.apis,e.realRelativePath);g[C]={[I]:d.rbac,[T]:{fsPath:u}}}r.set(b,L)}})},afterRoutesCreated:async(o,D)=>{const{buildItems:R,simplifyAstStructure:v}=await z(o.serverOutDir);for(const c of r.values())Q(o,c.build.items);const P=new Set,y=new Set;for(const{chunks:c,relativePath:n,isVirtual:m}of t){const h=`${O}${n}`,E=be(o.getAllRoutes(),n);for(const{node:e,markdown:u,pointer:p,key:i,relativePath:S}of c){const{ast:b,compoundHash:M}=await o.parseMarkdoc({input:{content:u,relativePath:S,isVirtual:m},resource:p,context:D,deps:{sharedDataIds:[`${O}${S}`],routeSlugs:E}});if(P.add(p),!(i==="graphql-docs"?e?.description?.value!==void 0:!!i&&Ce(e,i,u))||!J(e,i,M))continue;y.add(h);const _=v(b);if(i==="graphql-docs"){e.description&&(e.description.value=_);const C=`${O}${S}`;Be(r.get(C),_)}else i&&(e[i]=_)}}const w=a.difference(P);for(const c of w)D.cache.delete(c);a=P,Object.entries(g).forEach(([c,n])=>{const m=n[T]?.fsPath;if(!m)return;const h=o.getRouteByFsPath(m)?.baseSlug;g[c]={...n,[T]:{...n[T],slug:h},slug:h}}),o.setGlobalData({apiProducts:g});for(const[c,n]of r){if(!y.has(c))continue;const{items:m,store:h}=await R({type:n.document.type,document:n.document.document,options:n.document.options,basePath:n.basePath,markdownParser:j});n.build={items:m,store:h},Q(o,m),await o.createSharedData(c,Y(n,m,h))}}}}function Q(t,r){for(const{from:s,to:a}of ne(r))t.getConfig().redirects?.[s]||t.getRouteBySlug(s,{followRedirect:!1})||(t.addRouteAlias(s,a),t.addRedirect(s,{to:a},{trackOriginalSource:!1}))}function Y({document:t,basePath:r,sourcePath:s,apiId:a},g,A){return{[I]:K(t.config),[T]:{slug:me(r),fsPath:t.customOutputRelativeFile||t.relativePath},items:g,store:A,options:t.options,baseSlug:r,routesMapping:G.isDevelopMode?we(g,r):{},graphqlPositions:G.isDevelopMode&&t.type==="graphql"?Ee(g,r):void 0,sourcePath:s,apiId:a}}function Be(t,r){t?.document.type!=="graphql"||!t.document.options||(t.document.options.info={...t.document.options.info||{},description:r})}function qe(t,r,s){return async function(a){return{...s?{isTranslationFallback:!0}:{},props:{settings:{baseUrlPath:N(a.baseSlug)},disableAutoScroll:!0,seo:{title:t,...r}}}}}function xe(t,r){const s=t.options?.mockServer,a=N(`/_mock${Oe(t.relativePath)}`);s?.url===a&&(t.options={...t.options,mockServer:{...s,url:N(`/_mock${r}`)}})}function Ne(t,r){if(t===r)return{};const s=r==="/"?"/":`${r}/`;if(t.startsWith(s)){const a=t.slice(s.length);return a?{slugSuffix:a}:{}}return{slug:t}}function $e(t){if(t&&typeof t=="object"&&"info"in t)return t.info}function X(t){return t.map(({content:r,items:s,...a})=>({...a,...s&&{items:X(s)}}))}export{Pt as apiDocsPlugin,Ne as toRouteSlugFields};
@@ -1,5 +1,5 @@
1
- import C from"node:path";import{REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{nodeTypes as y,contentType as A,isGraphqlFieldsNode as un,resolveGraphqlItemFields as dn}from"@redocly/api-docs";import{normalizeApiVersion as mn}from"../utils/normalize-api-version.js";import{replaceFileExtension as U}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as hn,canDownloadApiDefinition as yn,extractTeamsFromScopeItems as $n}from"../../../utils/rbac.js";import{getLlmsTxtMdPathBySlug as gn}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{PUBLIC_API_DEFINITIONS_FOLDER as Y}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as bn}from"../../../../constants/common.js";import{isPlainObject as $}from"../../../../utils/guards/is-plain-object.js";import{ANONYMOUS_AUTH_DETAILS as An}from"../../../constants/rbac.js";import{toMarkdown as N}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as In}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as On}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as Pn}from"../../../utils/l10n/get-build-translate-context.js";import{getPublicEnvVariables as Sn}from"../../../utils/envs/get-public-env-variables.js";import{llmsTxtLink as K}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as xn}from"../../search/utils.js";import{extractDocumentSearchFacets as Cn}from"./search-facets.js";import{createApiDocsSearchIndexer as vn,createLlmDescriptionFormatter as Ln}from"./create-indexer.js";function O(t,s){return s==="openapi"&&"openapi"in t}function X(t,s){return s==="asyncapi"&&"asyncapi"in t}function se({getBuild:t,metadata:s,document:r,specType:c,excludeFromSearch:n,basePath:o,getSearchFacets:e,markdocTags:l}){return async(i,f,m,a)=>{if(n)return;const{items:d,store:u}=t(),h={...a.markdocOptions?.tags,...l},{locale:on,translate:rn}=await Pn(i.slug,a.getGlobalData?.().l10n),P=In(h,on,rn,{env:Sn()}),L=a.getConfig(),T=On(i.fsPath),R=Ln(P),j=vn(o,R,u?.schemaStore,r,u?.exampleStore,u?.graphqlMeta),M=b=>{for(const p of b)j.addItem(p),p.items?.length&&M(p.items)};M(d);const sn=j.getResult(),V=new Map;for(const b of sn)V.set(b.url,b);const D=typeof s.title=="string"?s.title:void 0,F=mn(s.version),E=Cn(i.metadata||{},D,F,e),S=[],x=[],_=Tn(r,s),q=_?R(_):void 0,G=Rn(s,q,r,c,R),z=Dn(c,s,i.fsPath,L),W=new Map,cn=Z(d,L,W,P),ln=G+z+`
2
- `+cn,fn=G+z;x.push({title:D||"API Overview",description:q,content:ln,slug:o,fsPath:i.fsPath,includeInLLMsTxt:!0}),S.push({title:D||"API Overview",content:fn,url:o,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:E});const an=r&&O(r,c)?r.security:void 0,k=b=>{for(const p of b){if(!p.content||!p.link){p.items?.length&&k(p.items);continue}const pn=V.get(p.link),B=p.content.contentType,J=p[v],Q=J?$n(J):void 0,H=Q?.length?Q:void 0;if(B===A.ITEM){const g=Un(p,r,c)??nn(p,pn,c,F,an,P,u);if(g){const I=p.label||"";x.push({title:I,description:void 0,content:g,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),S.push({title:I,content:g,url:p.link,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:E,rbacTeams:H})}}else if(B===A.GROUP){const g=Nn(p,L,c,W,P,u);if(g){const I=p.label||"";x.push({title:I,description:void 0,content:g.llmstxt,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),S.push({title:I,content:g.aiSearch,url:p.link,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:E,rbacTeams:H})}}p.items?.length&&k(p.items)}};return k(d),{async getLLMsTxts(){return x},async getSearchDocuments(){return S}}}}function Tn(t,s){const r=$(t?.info)?t.info:void 0,c=$(r?.["x-metadata"])?r["x-metadata"]:{},o=(typeof c.description=="string"?c.description:void 0)??r?.description??s.description;return typeof o=="string"?o||void 0:o&&typeof o=="object"?o:void 0}function Rn(t,s,r,c,n){const o=typeof t.title=="string"?t.title:"",e=typeof t.summary=="string"?t.summary:"",l=typeof t.version=="string"?t.version:"";let i=o?`# ${o}
1
+ import C from"node:path";import{REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{nodeTypes as y,contentType as A,isGraphqlFieldsNode as un,resolveGraphqlItemFields as dn}from"@redocly/api-docs";import{normalizeApiVersion as mn}from"../utils/normalize-api-version.js";import{replaceFileExtension as U}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as hn,canDownloadApiDefinition as yn,extractTeamsFromScopeItems as $n}from"../../../utils/rbac.js";import{getMarkdownCopyPath as gn}from"@redocly/theme/core/utils";import{PUBLIC_API_DEFINITIONS_FOLDER as Y}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as bn}from"../../../../constants/common.js";import{isPlainObject as $}from"../../../../utils/guards/is-plain-object.js";import{ANONYMOUS_AUTH_DETAILS as An}from"../../../constants/rbac.js";import{toMarkdown as w}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as In}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as On}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as Pn}from"../../../utils/l10n/get-build-translate-context.js";import{getPublicEnvVariables as Sn}from"../../../utils/envs/get-public-env-variables.js";import{llmsTxtLink as K}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as xn}from"../../search/utils.js";import{extractDocumentSearchFacets as Cn}from"./search-facets.js";import{createApiDocsSearchIndexer as vn,createLlmDescriptionFormatter as Ln}from"./create-indexer.js";function O(t,s){return s==="openapi"&&"openapi"in t}function X(t,s){return s==="asyncapi"&&"asyncapi"in t}function se({getBuild:t,metadata:s,document:r,specType:c,excludeFromSearch:n,basePath:o,getSearchFacets:e,markdocTags:l}){return async(i,f,m,a)=>{if(n)return;const{items:d,store:u}=t(),h={...a.markdocOptions?.tags,...l},{locale:on,translate:rn}=await Pn(i.slug,a.getGlobalData?.().l10n),P=In(h,on,rn,{env:Sn()}),L=a.getConfig(),R=On(i.fsPath),T=Ln(P),j=vn(o,T,u?.schemaStore,r,u?.exampleStore,u?.graphqlMeta),M=b=>{for(const p of b)j.addItem(p),p.items?.length&&M(p.items)};M(d);const sn=j.getResult(),V=new Map;for(const b of sn)V.set(b.url,b);const D=typeof s.title=="string"?s.title:void 0,F=mn(s.version),E=Cn(i.metadata||{},D,F,e),S=[],x=[],_=Rn(r,s),q=_?T(_):void 0,G=Tn(s,q,r,c,T),z=Dn(c,s,i.fsPath,L),W=new Map,cn=Z(d,L,W,P),ln=G+z+`
2
+ `+cn,fn=G+z;x.push({title:D||"API Overview",description:q,content:ln,slug:o,fsPath:i.fsPath,includeInLLMsTxt:!0}),S.push({title:D||"API Overview",content:fn,url:o,fsPath:i.fsPath,locale:R,product:i.product?.name,facets:E});const an=r&&O(r,c)?r.security:void 0,k=b=>{for(const p of b){if(!p.content||!p.link){p.items?.length&&k(p.items);continue}const pn=V.get(p.link),J=p.content.contentType,Q=p[v],B=Q?$n(Q):void 0,H=B?.length?B:void 0;if(J===A.ITEM){const g=Un(p,r,c)??nn(p,pn,c,F,an,P,u);if(g){const I=p.label||"";x.push({title:I,description:void 0,content:g,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),S.push({title:I,content:g,url:p.link,fsPath:i.fsPath,locale:R,product:i.product?.name,facets:E,rbacTeams:H})}}else if(J===A.GROUP){const g=wn(p,L,c,W,P,u);if(g){const I=p.label||"";x.push({title:I,description:void 0,content:g.llmstxt,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),S.push({title:I,content:g.aiSearch,url:p.link,fsPath:i.fsPath,locale:R,product:i.product?.name,facets:E,rbacTeams:H})}}p.items?.length&&k(p.items)}};return k(d),{async getLLMsTxts(){return x},async getSearchDocuments(){return S}}}}function Rn(t,s){const r=$(t?.info)?t.info:void 0,c=$(r?.["x-metadata"])?r["x-metadata"]:{},o=(typeof c.description=="string"?c.description:void 0)??r?.description??s.description;return typeof o=="string"?o||void 0:o&&typeof o=="object"?o:void 0}function Tn(t,s,r,c,n){const o=typeof t.title=="string"?t.title:"",e=typeof t.summary=="string"?t.summary:"",l=typeof t.version=="string"?t.version:"";let i=o?`# ${o}
3
3
 
4
4
  `:"";if(i+=s?`${s}
5
5
 
@@ -55,14 +55,14 @@ ${o.url}
55
55
  `}n+=`
56
56
  `}return n}function Z(t,s,r,c){let n="";const o=(e,l)=>{for(const i of e)if(!(!i.link||!tn(i,s))){if(i.content?.contentType===A.GROUP)n+=`${l} ${i.label||""}
57
57
 
58
- `,i.items?.length&&o(i.items,l+"#");else if(i.content?.contentType===A.ITEM){let f=r.get(i.link);if(f===void 0){const m=i,a=m.httpVerb,d=m.httpPath,u=a&&d?`${a.toUpperCase()} ${d}`:i.label||"",h=w(i.content.children,c);f=` - ${K({title:u,description:h?h.slice(0,200):void 0,slug:gn(i.link),siteUrl:s.seo?.siteUrl})}`,r.set(i.link,f)}n+=f}}};return o(t,"##"),n}function nn(t,s,r,c,n,o,e){if(!t.content)return;const l=t,i=t.label||"",f=w(t.content.children,o),m=t.content.meta?.deprecated;let a=`# ${i}${m?" (deprecated)":""}
58
+ `,i.items?.length&&o(i.items,l+"#");else if(i.content?.contentType===A.ITEM){let f=r.get(i.link);if(f===void 0){const m=i,a=m.httpVerb,d=m.httpPath,u=a&&d?`${a.toUpperCase()} ${d}`:i.label||"",h=N(i.content.children,c);f=` - ${K({title:u,description:h?h.slice(0,200):void 0,slug:gn(i.link),siteUrl:s.seo?.siteUrl})}`,r.set(i.link,f)}n+=f}}};return o(t,"##"),n}function nn(t,s,r,c,n,o,e){if(!t.content)return;const l=t,i=t.label||"",f=N(t.content.children,o),m=t.content.meta?.deprecated;let a=`# ${i}${m?" (deprecated)":""}
59
59
 
60
60
  `;if(f&&(a+=`${f}
61
61
 
62
62
  `),r==="openapi"||r==="asyncapi"){const d=l.httpVerb,u=l.httpPath;d&&u?a+=`Endpoint: ${d.toUpperCase()} ${u}
63
63
  `:d&&(a+=`Method: ${d.toUpperCase()}
64
64
  `),c&&(a+=`Version: ${c}
65
- `);const h=wn(t.content.children,n);h&&(a+=`Security: ${h}
65
+ `);const h=Nn(t.content.children,n);h&&(a+=`Security: ${h}
66
66
  `)}return s?.parameters?.length&&r!=="graphql"&&(a+=`
67
67
  `+jn(s.parameters)+`
68
68
  `),r==="graphql"&&(a+=Mn(t.content.children,e,o)),a}function Un(t,s,r){if(t.httpVerb!=="tool"||!s||!O(s,r))return;const c=t.content?.meta?.name,n=c?s["x-mcp"]?.tools?.find(e=>e.name===c):void 0;if(!n)return;let o=`# ${t.label||n.name}
@@ -81,7 +81,7 @@ ${JSON.stringify(n.inputSchema,null,2)}
81
81
  ${JSON.stringify(n.outputSchema,null,2)}
82
82
  \`\`\`
83
83
 
84
- `),o}function Nn(t,s,r,c,n,o){if(!t.content)return;const e=t.label||"",l=w(t.content.children,n);let i=`# ${e}
84
+ `),o}function wn(t,s,r,c,n,o){if(!t.content)return;const e=t.label||"",l=N(t.content.children,n);let i=`# ${e}
85
85
 
86
86
  `;if(l&&(i+=`${l}
87
87
 
@@ -89,7 +89,7 @@ ${JSON.stringify(n.outputSchema,null,2)}
89
89
 
90
90
  ---
91
91
 
92
- `)}else u.content.contentType===A.GROUP&&a(u.items)};return a(t.items),{llmstxt:i+m,aiSearch:i}}const f=Z(t.items??[],s,c,n);return{llmstxt:i+f,aiSearch:i}}function wn(t,s){const r=[],c=n=>{for(const o of n)if(o.nodeType===y.SECURITY){const e=o;for(const l of e.requirements)for(const i of l.schemes)i[v]||i.name&&!r.includes(i.name)&&r.push(i.name)}else(o.nodeType===y.CONTAINER||o.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(o.children)};if(c(t),r.length)return r.join(", ");if(s?.length){const n=s.flatMap(o=>Object.keys(o));if(n.length)return[...new Set(n)].join(", ")}}function jn(t){const s={};for(const c of t){const n=`${c.place}${c.mediaType?` (${c.mediaType})`:""}`;s[n]||(s[n]=[]),s[n].push(c)}return Object.entries(s).map(([c,n])=>{const o=n.map(e=>{const l=[...e.path||[],e.name],i=Array.isArray(e.description)?e.description.join(" "):e.description;let f=` - \`${l.join(".")}\` (${e.type}${e.required?", required":""})
92
+ `)}else u.content.contentType===A.GROUP&&a(u.items)};return a(t.items),{llmstxt:i+m,aiSearch:i}}const f=Z(t.items??[],s,c,n);return{llmstxt:i+f,aiSearch:i}}function Nn(t,s){const r=[],c=n=>{for(const o of n)if(o.nodeType===y.SECURITY){const e=o;for(const l of e.requirements)for(const i of l.schemes)i[v]||i.name&&!r.includes(i.name)&&r.push(i.name)}else(o.nodeType===y.CONTAINER||o.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(o.children)};if(c(t),r.length)return r.join(", ");if(s?.length){const n=s.flatMap(o=>Object.keys(o));if(n.length)return[...new Set(n)].join(", ")}}function jn(t){const s={};for(const c of t){const n=`${c.place}${c.mediaType?` (${c.mediaType})`:""}`;s[n]||(s[n]=[]),s[n].push(c)}return Object.entries(s).map(([c,n])=>{const o=n.map(e=>{const l=[...e.path||[],e.name],i=Array.isArray(e.description)?e.description.join(" "):e.description;let f=` - \`${l.join(".")}\` (${e.type}${e.required?", required":""})
93
93
  `;return i&&(f+=` ${i.trim()}
94
94
  `),e.enum?f+=` Enum: ${e.enum.map(m=>JSON.stringify(m)).join(", ")}
95
95
  `:e.example&&(f+=` Example: ${e.example}
@@ -100,6 +100,6 @@ ${o.join(`
100
100
  `)}function Mn(t,s,r){let c="";const n=o=>{for(const e of o)if(e.nodeType===y.ITEM){const l=un(e)?dn(e,s??{}):void 0;l&&(c+=Vn(l,e.variant,r))}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&n(e.children)};return n(t),c}function Vn(t,s,r){let n=`
101
101
  ## ${en(s==="return-type"?"Return type":s==="graphql-args"||s==="arguments"?"Arguments":s==="graphql-fields"?"Fields":s)}:
102
102
 
103
- `;const o=e=>{const l=e.description?N(Array.isArray(e.description)?e.description:[e.description],{renderTag:r}).trim():"";return` - \`${e.name}\` (${e.type.display})${l?`: ${l}`:""}
104
- `};if(t.type){const e=t.type.description?N(Array.isArray(t.type.description)?t.type.description:[t.type.description],{renderTag:r}).trim():"";n+=` Type: ${t.type.display}`,e&&(n+=` - ${e}`),n+=`
105
- `}else if(!t.fields.length)return"";for(const e of t.fields)n+=o(e);return n}function w(t,s){const r=[],c=o=>{for(const e of o)if(e.nodeType===y.MARKDOC){const l=e.content,i=Array.isArray(l)?l:[l],f=N(i,{renderTag:s}).trim();f&&r.push(f)}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(e.children)};return c(t),r.join(" ").trim()||void 0}function en(t){return t.charAt(0).toUpperCase()+t.slice(1)}function tn(t,s){return s.access?.requiresLogin?!0:hn({slug:t.link||"",[v]:t[v]},s)}export{se as getAiDocumentsStore};
103
+ `;const o=e=>{const l=e.description?w(Array.isArray(e.description)?e.description:[e.description],{renderTag:r}).trim():"";return` - \`${e.name}\` (${e.type.display})${l?`: ${l}`:""}
104
+ `};if(t.type){const e=t.type.description?w(Array.isArray(t.type.description)?t.type.description:[t.type.description],{renderTag:r}).trim():"";n+=` Type: ${t.type.display}`,e&&(n+=` - ${e}`),n+=`
105
+ `}else if(!t.fields.length)return"";for(const e of t.fields)n+=o(e);return n}function N(t,s){const r=[],c=o=>{for(const e of o)if(e.nodeType===y.MARKDOC){const l=e.content,i=Array.isArray(l)?l:[l],f=w(i,{renderTag:s}).trim();f&&r.push(f)}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(e.children)};return c(t),r.join(" ").trim()||void 0}function en(t){return t.charAt(0).toUpperCase()+t.slice(1)}function tn(t,s){return s.access?.requiresLogin?!0:hn({slug:t.link||"",[v]:t[v]},s)}export{se as getAiDocumentsStore};
@@ -1 +1 @@
1
- import e from"node:path";import{existsSync as u}from"node:fs";import{readFile as I}from"node:fs/promises";import L from"js-yaml";import{withoutPathPrefix as j}from"@redocly/theme/core/utils";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as g,PUBLIC_API_DEFINITIONS_FOLDER as w}from"../../constants/common.js";import{GRAPHQL_SPEC_SLUG as T}from"../../../constants/common.js";import{requestDefinitionAccessKey as C}from"./definition-access.js";import{canDownloadApiDefinition as U,filterDataByAccessDeep as B}from"../../utils/rbac.js";import{API_DOWNLOAD_PREFIXES as G}from"../../utils/is-api-download-link.js";import{decodeRequestPath as W}from"../../utils/decode-request-path.js";import{replaceFileExtension as X}from"./utils/replace-file-extension.js";const v=[".json",".yaml",".yml"],H=[".graphql",".gql"];function F(r,o){const t=e.parse(r);return e.join(t.dir,t.name+o)}const J=async(r,o,t)=>{const{isAuthenticated:a,teams:m,claims:{email:d}}=o.user,S=new URL(r.url),n=W(j(S.pathname));if(n===void 0||n.endsWith("/"))return new Response("Bad Request",{status:400});const c=G.find(i=>n.startsWith(`${i}/`));if(c===void 0)return new Response("Not found",{status:404});const p=c===T,s=n.slice(c.length),l=e.extname(s);if(!(p?H:v).includes(l))return new Response("Not found",{status:404});const{rbac:h={},requiresLogin:P=!1}=o.config.access||{},y=(t.props?.definitionAccess??{})[C(p,X(s.slice(1),""))];if(!U(n,h,P,{isAuthenticated:a,email:d,teams:m},y))return new Response("Unauthorized",{status:a?403:401});const f=t.props?.outdir||"";if(p){const i=e.join(f,w,s);if(!u(i))return new Response("Not found",{status:404});const q=await I(i,"utf-8");return new Response(q,{headers:{"Content-Type":"application/graphql"}})}const E=e.join(f,w,F(s,".json")),R=e.join(f,g,F(s,".json")),A=u(E),D=u(R);if(!A&&!D)return new Response("Not found",{status:404});const _=await I(A?E:R,"utf-8"),x=JSON.parse(_),N=B(x,{isAuthenticated:a,email:d,teams:m},h,P),O=l===".yaml"?L.dump(N):JSON.stringify(N,null,2);return new Response(O,{headers:{"Content-Type":l===".yaml"?"application/yaml":"application/json"}})};var ie=J;export{ie as default};
1
+ import e from"node:path";import{existsSync as u}from"node:fs";import{readFile as I}from"node:fs/promises";import L from"js-yaml";import{withoutPathPrefix as j}from"@redocly/theme/core/utils";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as g,PUBLIC_API_DEFINITIONS_FOLDER as w}from"../../constants/common.js";import{GRAPHQL_SPEC_SLUG as T}from"../../../constants/common.js";import{requestDefinitionAccessKey as C}from"./definition-access.js";import{canDownloadApiDefinition as U,filterDataByAccessDeep as B}from"../../utils/rbac.js";import{API_DOWNLOAD_PREFIXES as G}from"../../utils/is-api-download-link.js";import{decodeRequestPath as W}from"../../utils/decode-request-path.js";import{replaceFileExtension as X}from"./utils/replace-file-extension.js";const v=[".json",".yaml",".yml"],H=[".graphql",".gql"];function F(r,o){const t=e.parse(r);return e.join(t.dir,t.name+o)}const J=async(r,o,t)=>{const{isAuthenticated:a,teams:m,claims:{email:d}}=o.user,S=new URL(r.url),n=W(j(S.pathname));if(n===void 0||n.endsWith("/"))return new Response("Bad Request",{status:400});const c=G.find(i=>n.startsWith(`${i}/`));if(c===void 0)return new Response("Not found",{status:404});const p=c===T,s=n.slice(c.length),f=e.extname(s);if(!(p?H:v).includes(f))return new Response("Not found",{status:404});const{rbac:h={},requiresLogin:P=!1}=o.config.access||{},y=(t.props?.definitionAccess??{})[C(p,X(s.slice(1),""))];if(!U(n,h,P,{isAuthenticated:a,email:d,teams:m},y))return new Response("Unauthorized",{status:a?403:401});const l=t.props?.outdir||"";if(p){const i=e.join(l,w,s);if(!u(i))return new Response("Not found",{status:404});const q=await I(i,"utf-8");return new Response(q,{headers:{"Content-Type":"application/graphql"}})}const E=e.join(l,w,F(s,".json")),R=e.join(l,g,F(s,".json")),A=u(E),D=u(R);if(!A&&!D)return new Response("Not found",{status:404});const _=await I(A?E:R,"utf-8"),x=JSON.parse(_),N=B(x,{isAuthenticated:a,email:d,teams:m},h,P),O=f===".yaml"?L.dump(N,{noRefs:!0}):JSON.stringify(N,null,2);return new Response(O,{headers:{"Content-Type":f===".yaml"?"application/yaml":"application/json"}})};var ie=J;export{ie as default};
@@ -1 +1 @@
1
- import p from"node:path";import{existsSync as O}from"node:fs";import{writeFile as h,access as y,rm as v,constants as b}from"fs/promises";import{REDOCLY_TEAMS_RBAC as N}from"@redocly/config";import{DEFAULT_LOCALE_PLACEHOLDER as P}from"../../../../constants/common.js";import{AI_INDEX_EXPORT_FOLDER as X}from"../../../constants/plugins/search.js";import{LLMS_TXT_FILE_NAME as $}from"../../../constants/common.js";import{envConfig as j}from"../../../config/env-config.js";import{logger as n}from"../../../tools/notifiers/logger.js";import{shaHexShort as B}from"../../../utils/crypto/sha-hex-short.js";import{promiseMapLimit as D}from"../../../utils/async/promise-map-limit.js";import{getLlmsTxtMdPathBySlug as G}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{validateLLMsTxtConfig as U,generateLLMsTxt as H}from"../llmstxt/index.js";import{buildPageLlmsTxtMd as k}from"../llmstxt/build-page-llms-txt-md.js";import{getLlmsTxtExcludeMatcher as J}from"../llmstxt/get-llms-txt-exclude-matcher.js";import{isIncludedInLlmsTxt as K}from"../llmstxt/is-included-in-llms-txt.js";import{getRouteStaticData as V}from"../../../utils/get-route-static-data.js";import{getRouteAiDocumentsStore as W}from"../../../utils/get-route-ai-documents-store.js";import{ensureDir as R}from"../../../utils/fs.js";import{extractTeamsFromScopeItems as Y,getRbacTeamsListForResource as q}from"../../../utils/rbac.js";const _=20,S="llms.txt:";async function ht(t,m,{embeddingsEnabled:e,writeLlmstxtFiles:l}){const c=p.join(t.outdir,$);if(!l){try{await y(c,b.W_OK),await v(c)}catch{}if(!e)return}e&&n.info("Preparing semantic documents..."),l&&n.info(`${S} Generating llms.txt files...`);const g=n.startTiming(),s=n.startTiming(),i=t.getGlobalConfig("seo"),f=i?.llmstxt,T=p.resolve(t.outdir,X),u=t.getConfig(),A=u.access?.rbac??{},M=t.getAllRoutes(),C=u?.l10n?.defaultLocale||u?.i18n?.defaultLocale||P,E=J(i),L=[];if(await D(M,_,async o=>{if(o.excludeFromSearch)return;const w=await V(o,t),x=await W(o,w,m,t);if(x){if(l)for(const r of await x.getLLMsTxts()){if(E(r.fsPath))continue;const d=G(r.slug),a=p.join(t.outdir,d);R(a),await h(a,k(r,i)),K(r,o,u)&&L.push(r)}if(e&&j.isBuildMode){const r=await x.getSearchDocuments();if(!r.length)return;const d=z(o,A),a=o.versions?.find(({active:F})=>F),I=a&&{folder:a.folderId,label:a.label,default:a.default};await Q(r,o.fsPath,d,T,C,I)}}}),e&&n.infoTime(s,"Semantic search documents prepared"),L.length)try{U(f);const o=await H(L,f,{title:i?.title,description:i?.description,siteUrl:i?.siteUrl},m);R(c),await h(c,o),n.infoTime(g,`${S} files generated`)}catch(o){n.error(`${S} Failed to generate llms.txt file. ${o.message}`)}}function z(t,m){const e=Y(t?.[N]);return e?.length?e:q(t,m)}async function Q(t,m,e,l,c,g){await D(t,_,async s=>{const i=`${B(m+s.content)}.json`,f=R(p.join(l,i)),T=s.locale===P?c:s.locale;O(f)||await h(f,JSON.stringify({...s,rbacTeams:s.rbacTeams??e??[],version:g,locale:T}),"utf-8")})}export{ht as prepareSemanticDocuments};
1
+ import u from"node:path";import{existsSync as O}from"node:fs";import{writeFile as h,access as y,rm as v,constants as b}from"fs/promises";import{REDOCLY_TEAMS_RBAC as N}from"@redocly/config";import{DEFAULT_LOCALE_PLACEHOLDER as S}from"../../../../constants/common.js";import{AI_INDEX_EXPORT_FOLDER as X}from"../../../constants/plugins/search.js";import{LLMS_TXT_FILE_NAME as $}from"../../../constants/common.js";import{envConfig as j}from"../../../config/env-config.js";import{logger as n}from"../../../tools/notifiers/logger.js";import{shaHexShort as G}from"../../../utils/crypto/sha-hex-short.js";import{promiseMapLimit as D}from"../../../utils/async/promise-map-limit.js";import{getMarkdownCopyPath as U}from"@redocly/theme/core/utils";import{validateLLMsTxtConfig as k,generateLLMsTxt as B}from"../llmstxt/index.js";import{buildPageLlmsTxtMd as H}from"../llmstxt/build-page-llms-txt-md.js";import{getLlmsTxtExcludeMatcher as J}from"../llmstxt/get-llms-txt-exclude-matcher.js";import{isIncludedInLlmsTxt as K}from"../llmstxt/is-included-in-llms-txt.js";import{getRouteStaticData as V}from"../../../utils/get-route-static-data.js";import{getRouteAiDocumentsStore as W}from"../../../utils/get-route-ai-documents-store.js";import{ensureDir as R}from"../../../utils/fs.js";import{extractTeamsFromScopeItems as Y,getRbacTeamsListForResource as q}from"../../../utils/rbac.js";const _=20,P="llms.txt:";async function ht(t,c,{embeddingsEnabled:e,writeLlmstxtFiles:l}){const m=u.join(t.outdir,$);if(!l){try{await y(m,b.W_OK),await v(m)}catch{}if(!e)return}e&&n.info("Preparing semantic documents..."),l&&n.info(`${P} Generating llms.txt files...`);const g=n.startTiming(),s=n.startTiming(),i=t.getGlobalConfig("seo"),f=i?.llmstxt,T=u.resolve(t.outdir,X),p=t.getConfig(),A=p.access?.rbac??{},C=t.getAllRoutes(),M=p?.l10n?.defaultLocale||p?.i18n?.defaultLocale||S,w=J(i),L=[];if(await D(C,_,async o=>{if(o.excludeFromSearch)return;const E=await V(o,t),x=await W(o,E,c,t);if(x){if(l)for(const r of await x.getLLMsTxts()){if(w(r.fsPath))continue;const d=U(r.slug),a=u.join(t.outdir,d);R(a),await h(a,H(r,i)),K(r,o,p)&&L.push(r)}if(e&&j.isBuildMode){const r=await x.getSearchDocuments();if(!r.length)return;const d=z(o,A),a=o.versions?.find(({active:F})=>F),I=a&&{folder:a.folderId,label:a.label,default:a.default};await Q(r,o.fsPath,d,T,M,I)}}}),e&&n.infoTime(s,"Semantic search documents prepared"),L.length)try{k(f);const o=await B(L,f,{title:i?.title,description:i?.description,siteUrl:i?.siteUrl},c);R(m),await h(m,o),n.infoTime(g,`${P} files generated`)}catch(o){n.error(`${P} Failed to generate llms.txt file. ${o.message}`)}}function z(t,c){const e=Y(t?.[N]);return e?.length?e:q(t,c)}async function Q(t,c,e,l,m,g){await D(t,_,async s=>{const i=`${G(c+s.content)}.json`,f=R(u.join(l,i)),T=s.locale===S?m:s.locale;O(f)||await h(f,JSON.stringify({...s,rbacTeams:s.rbacTeams??e??[],version:g,locale:T}),"utf-8")})}export{ht as prepareSemanticDocuments};
@@ -1 +1 @@
1
- import p from"node:path";import{logger as f}from"../../../tools/notifiers/logger.js";import{promiseMapLimit as x}from"../../../utils/async/promise-map-limit.js";import{getLlmsTxtMdPathBySlug as L}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{getRouteStaticData as T}from"../../../utils/get-route-static-data.js";import{getRouteAiDocumentsStore as w}from"../../../utils/get-route-ai-documents-store.js";import{generateLLMsTxt as h,validateLLMsTxtConfig as M}from"./index.js";import{buildPageLlmsTxtMd as S}from"./build-page-llms-txt-md.js";import{getLlmsTxtExcludeMatcher as m}from"./get-llms-txt-exclude-matcher.js";import{isIncludedInLlmsTxt as R}from"./is-included-in-llms-txt.js";import{EntitlementsProvider as C}from"../../../entitlements/entitlements-provider.js";const A=20;function v(i,c){const a=new WeakMap,l=()=>{const t=i.getGlobalConfig("seo");return C.instance().canAccessFeature("seo")===!0&&t?.llmstxt?.hide!==!0},d=async t=>{if(t.excludeFromSearch)return[];const e=i,n=await T(t,e);return await(await w(t,n,c,e))?.getLLMsTxts()??[]},u=t=>{const e=a.get(t);if(e)return e;const n=d(t).catch(o=>(a.delete(t),f.warn(`Failed to generate Markdown for LLMs of "${t.slug}". ${o}`),[]));return a.set(t,n),n},g=t=>{const e=t==="/index.html.md"?"/":t.replace(/\.md$/,"");for(let n=e;n.startsWith("/");){const o=i.getRouteBySlug(n,{followRedirect:!1});if(o?.getAiDocumentsStore)return o;const r=p.posix.dirname(n);if(r===n)return;n=r}};return{async getPageMarkdown(t){if(!l())return;const e=g(t);if(!e)return;const n=i.getGlobalConfig("seo"),o=m(n),r=(await u(e)).find(s=>L(s.slug)===t&&!o(s.fsPath));if(r)return{route:e,content:S(r,n)}},async getLlmsTxt(){if(!l())return;const t=i.getConfig(),e=i.getGlobalConfig("seo"),n=m(e),o=[];if(await x(i.getAllRoutes(),A,async r=>{for(const s of await u(r))!n(s.fsPath)&&R(s,r,t)&&o.push(s)}),!!o.length)try{return M(e?.llmstxt),await h(o,e?.llmstxt,{title:e?.title,description:e?.description,siteUrl:e?.siteUrl},c)}catch(r){f.error(`Failed to generate llms.txt. ${r}`);return}}}}export{v as createLlmsTxtGenerator};
1
+ import m from"node:path";import{logger as p}from"../../../tools/notifiers/logger.js";import{promiseMapLimit as w}from"../../../utils/async/promise-map-limit.js";import{getMarkdownCopyPath as R,getSlugFromMarkdownCopyPath as x}from"@redocly/theme/core/utils";import{getRouteStaticData as S}from"../../../utils/get-route-static-data.js";import{getRouteAiDocumentsStore as T}from"../../../utils/get-route-ai-documents-store.js";import{generateLLMsTxt as C,validateLLMsTxtConfig as M}from"./index.js";import{buildPageLlmsTxtMd as P}from"./build-page-llms-txt-md.js";import{getLlmsTxtExcludeMatcher as a}from"./get-llms-txt-exclude-matcher.js";import{isIncludedInLlmsTxt as y}from"./is-included-in-llms-txt.js";import{EntitlementsProvider as A}from"../../../entitlements/entitlements-provider.js";const E=20;function W(r,c){const u=new WeakMap,l=()=>{const e=r.getGlobalConfig("seo");return A.instance().canAccessFeature("seo")===!0&&r.getConfig().search?.hide!==!0&&e?.llmstxt?.hide!==!0},L=async e=>{if(e.excludeFromSearch)return[];const t=r,n=await S(e,t);return await(await T(e,n,c,t))?.getLLMsTxts()??[]},d=e=>{const t=u.get(e);if(t)return t;const n=L(e).catch(o=>(u.delete(e),p.warn(`Failed to generate Markdown for LLMs of "${e.slug}". ${o}`),[]));return u.set(e,n),n},h=e=>{const t=x(e);if(t===null||R(t)!==e)return;const n=r.getRouteBySlug(t,{followRedirect:!1});if(n?.getAiDocumentsStore)return n;for(let o=m.posix.dirname(t);o.startsWith("/");){const i=r.getRouteBySlug(o,{followRedirect:!1});if(i?.hasClientRoutes&&i.getAiDocumentsStore)return i;const s=m.posix.dirname(o);if(s===o)return;o=s}},f=e=>{if(!l())return;const t=h(e);if(!t||t.excludeFromSearch)return;const n=a(r.getGlobalConfig("seo"));return t.fsPath!==void 0&&n(t.fsPath)?void 0:t};return{hasPageMarkdown(e){return f(e)!==void 0},async getPageMarkdown(e){const t=f(e);if(!t)return;const n=r.getGlobalConfig("seo"),o=a(n),i=x(e),s=(await d(t)).find(g=>g.slug===i&&!o(g.fsPath));if(s)return{route:t,content:P(s,n)}},async getLlmsTxt(){if(!l())return;const e=r.getConfig(),t=r.getGlobalConfig("seo"),n=a(t),o=[];if(await w(r.getAllRoutes(),E,async i=>{for(const s of await d(i))!n(s.fsPath)&&y(s,i,e)&&o.push(s)}),!!o.length)try{return M(t?.llmstxt),await C(o,t?.llmstxt,{title:t?.title,description:t?.description,siteUrl:t?.siteUrl},c)}catch(i){p.error(`Failed to generate llms.txt. ${i}`);return}}}}export{W as createLlmsTxtGenerator};
@@ -1,13 +1,13 @@
1
- import d from"picomatch";import{dirname as T,resolve as $}from"node:path";import{access as x,readFile as E,constants as F}from"fs/promises";import{removeTrailingSlash as w}from"../../../../utils/url/remove-trailing-slash.js";import{logger as g}from"../../../tools/notifiers/logger.js";import{withPathPrefix as U}from"@redocly/theme/core/utils";import{envConfig as y}from"../../../config/env-config.js";import{getLlmsTxtMdPathBySlug as I}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";const a="llms.txt",u="Table of contents";async function v(e,i,n={title:a,description:void 0},r){if(!i)return{title:n.title||a,description:n.description,details:void 0,sections:[{title:u,description:void 0,llmstxts:e}]};const s=i.title||n.title||a,l=i.description||n.description,t=await D(i,r),o=i.sections?.map(c=>{const{title:f,description:h,excludeFiles:m,includeFiles:L}=c,P=p(e,{excludeFiles:m,includeFiles:L});return{title:f,description:h,llmstxts:P}});return{title:s,description:l,details:t,sections:o||[{title:u,description:void 0,llmstxts:p(e,{includeFiles:["**/*"],excludeFiles:[]})}]}}async function D(e,i){const n=await i.getConfig();if(e?.details?.path&&n.configPath)try{const r=i.fs.getFileInfo(n.configPath);if(!r)throw new Error(`Config file ${n.configPath} not found`);const s=$(i.fs.cwd,T(r.relativePath),e.details.path);return await x(s,F.R_OK),E(s,"utf-8")}catch{throw new Error(`${e.details.path} is not accessible`)}if(e?.details?.content)return e.details.content}function p(e,i){const{excludeFiles:n,includeFiles:r}=i,s=n?.map(t=>d(t)),l=r?.map(t=>d(t));return e.filter(t=>s?.some(c=>c(t.fsPath))?!1:l?.some(c=>c(t.fsPath)))}async function b(e,i,n={title:a,description:void 0,siteUrl:void 0},r){const s=await v(e,i,n,r),l=n.siteUrl,t=[`# ${s.title}
1
+ import d from"picomatch";import{dirname as T,resolve as $}from"node:path";import{access as w,readFile as x,constants as E}from"fs/promises";import{removeTrailingSlash as F}from"../../../../utils/url/remove-trailing-slash.js";import{logger as U}from"../../../tools/notifiers/logger.js";import{getMarkdownCopyPath as g,withPathPrefix as y}from"@redocly/theme/core/utils";import{envConfig as I}from"../../../config/env-config.js";const a="llms.txt",u="Table of contents";async function v(e,i,n={title:a,description:void 0},r){if(!i)return{title:n.title||a,description:n.description,details:void 0,sections:[{title:u,description:void 0,llmstxts:e}]};const s=i.title||n.title||a,l=i.description||n.description,t=await D(i,r),o=i.sections?.map(c=>{const{title:f,description:h,excludeFiles:m,includeFiles:L}=c,P=p(e,{excludeFiles:m,includeFiles:L});return{title:f,description:h,llmstxts:P}});return{title:s,description:l,details:t,sections:o||[{title:u,description:void 0,llmstxts:p(e,{includeFiles:["**/*"],excludeFiles:[]})}]}}async function D(e,i){const n=await i.getConfig();if(e?.details?.path&&n.configPath)try{const r=i.fs.getFileInfo(n.configPath);if(!r)throw new Error(`Config file ${n.configPath} not found`);const s=$(i.fs.cwd,T(r.relativePath),e.details.path);return await w(s,E.R_OK),x(s,"utf-8")}catch{throw new Error(`${e.details.path} is not accessible`)}if(e?.details?.content)return e.details.content}function p(e,i){const{excludeFiles:n,includeFiles:r}=i,s=n?.map(t=>d(t)),l=r?.map(t=>d(t));return e.filter(t=>s?.some(c=>c(t.fsPath))?!1:l?.some(c=>c(t.fsPath)))}async function b(e,i,n={title:a,description:void 0,siteUrl:void 0},r){const s=await v(e,i,n,r),l=n.siteUrl,t=[`# ${s.title}
2
2
 
3
3
  `];return s.description&&t.push(`> ${s.description}
4
4
 
5
5
  `),s.details&&t.push(`${s.details}
6
6
 
7
- `),s.sections.forEach(o=>{if(!o.llmstxts.length){g.warn(`llms.txt: No links found for section "${o.title}". Please check the includeFiles/excludeFiles patterns.`);return}t.push(`## ${o.title}
7
+ `),s.sections.forEach(o=>{if(!o.llmstxts.length){U.warn(`llms.txt: No links found for section "${o.title}". Please check the includeFiles/excludeFiles patterns.`);return}t.push(`## ${o.title}
8
8
  `),o.description?t.push(`${o.description.replace(/(?<!\n)\n+$/,"")}
9
9
 
10
10
  `):t.push(`
11
- `),o.llmstxts.forEach(c=>{t.push(` - ${M({title:c.title,description:c.description,slug:I(c.slug),siteUrl:l})}`)}),t.push(`
12
- `)}),t.join("")}function M({title:e,description:i,slug:n,siteUrl:r}){const l=`${w(r?.trim()||y.REDOCLY_PUBLIC_URL||"")}${encodeURI(U(n))}`,t=i?.replace(/\s+/g," ").trim();return`[${e}](${l})${t?`: ${t}`:""}
11
+ `),o.llmstxts.forEach(c=>{t.push(` - ${M({title:c.title,description:c.description,slug:g(c.slug),siteUrl:l})}`)}),t.push(`
12
+ `)}),t.join("")}function M({title:e,description:i,slug:n,siteUrl:r}){const l=`${F(r?.trim()||I.REDOCLY_PUBLIC_URL||"")}${encodeURI(y(n))}`,t=i?.replace(/\s+/g," ").trim();return`[${e}](${l})${t?`: ${t}`:""}
13
13
  `}function j(e){if(e?.details?.path&&e?.details?.content)throw new Error('"details.path" and "details.content" are mutually exclusive. Please use only one of them.')}export{b as generateLLMsTxt,M as llmsTxtLink,j as validateLLMsTxtConfig};
@@ -121,6 +121,8 @@ export type ApiRouteMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'all'
121
121
  export type ApiRoute = RouteDetails & {
122
122
  httpMethod: ApiRouteMethod;
123
123
  requestHandlerId: string;
124
+ timeoutMs?: number;
125
+ maxResponseSizeMB?: number;
124
126
  };
125
127
  export type McpToolSchema = {
126
128
  name: string;
@@ -60,6 +60,11 @@ declare module 'hono' {
60
60
  }
61
61
  }
62
62
  export type LlmsTxtGenerator = {
63
+ /**
64
+ * Whether `getPageMarkdown` would answer for this path, without rendering anything. A sub-path
65
+ * of a route with client routes answers for the owner route.
66
+ */
67
+ hasPageMarkdown(mdPathname: string): boolean;
63
68
  getPageMarkdown(mdPathname: string): Promise<{
64
69
  route: PageRouteDetails;
65
70
  content: string;
@@ -6,5 +6,10 @@ type ResolvedLlmsTxtMd = {
6
6
  route: PageRouteDetails | undefined;
7
7
  };
8
8
  export declare function resolveLlmsTxtMd(mdPathname: string, store: Store, generator?: LlmsTxtGenerator): Promise<ResolvedLlmsTxtMd>;
9
+ /**
10
+ * The prefixed URL of the Markdown copy of the page at `slug`, or `undefined` when the site
11
+ * has no copy of it: the build wrote none, or develop mode generates none.
12
+ */
13
+ export declare function resolvePageMarkdownUrl(slug: string, store: Store, generator?: LlmsTxtGenerator): Promise<string | undefined>;
9
14
  export {};
10
15
  //# sourceMappingURL=resolve-llms-txt-md.d.ts.map
@@ -1 +1 @@
1
- import n from"path";import{removeLeadingSlash as s}from"../../../utils/url/remove-leading-slash.js";import{fileExistsAsync as l}from"../index.js";async function f(e,o,r){if(r){const t=await r.getPageMarkdown(e);return{exists:t!==void 0,content:t?.content,route:t?.route}}const i=e==="/index.html.md"?"/":e.replace(/\.md$/i,"");return{exists:await l(n.resolve(o.outdir,s(e))),content:void 0,route:o.getRouteBySlug(i,{followRedirect:!1})}}export{f as resolveLlmsTxtMd};
1
+ import s from"path";import{getMarkdownCopyPath as a,getSlugFromMarkdownCopyPath as d,withPathPrefix as u}from"@redocly/theme/core/utils";import{isPathInFolder as f}from"../../../utils/path/is-path-in-folder.js";import{removeLeadingSlash as l}from"../../../utils/url/remove-leading-slash.js";import{fileExistsAsync as c}from"../index.js";async function y(t,o,e){if(e){const r=await e.getPageMarkdown(t);return{exists:r!==void 0,content:r?.content,route:r?.route}}const n=d(t);return{exists:await i(t,o),content:void 0,route:n===null?void 0:o.getRouteBySlug(n,{followRedirect:!1})}}async function M(t,o,e){const n=a(t);return(e?e.hasPageMarkdown(n):await i(n,o))?encodeURI(u(n)):void 0}async function i(t,o){if(/[\\\0]/.test(t))return!1;const e=s.resolve(o.outdir,l(t));return f(e,o.outdir)&&c(e)}export{y as resolveLlmsTxtMd,M as resolvePageMarkdownUrl};
@@ -1 +1 @@
1
- import m from"path";import{realpath as G}from"fs/promises";import{REDOCLY_ROUTE_RBAC as z,REDOCLY_TEAMS_RBAC as j}from"@redocly/config";import{combineUrls as V,withoutPathPrefix as ie,withPathPrefix as R}from"@redocly/theme/core/utils";import{CACHE_CONTROL_NO_STORE_HEADER_VALUE as W,CACHE_CONTROL_PUBLIC_HTML as ae,DEFAULT_IMMUTABLE_CACHE_MAX_AGE as se,DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ce,PAGE_DATA_FOLDER as le,PUBLIC_API_DEFINITIONS_FOLDER as me,PUBLIC_ASSETS_FOLDER as ue,STATIC_DATA_FOLDER as de,X_REDOCLY_CACHE_CONTROL_HEADER as fe,X_REDOCLY_CACHE_CONTROL_PUBLIC_HTML as ge}from"../../constants/common.js";import{removeTrailingSlash as Z}from"../../../utils/url/remove-trailing-slash.js";import{findInIterable as pe}from"../../../utils/collection/find-in-iterable.js";import{sanitizeRedirectPathname as he}from"../../../utils/url/sanitize-redirect-pathname.js";import{envConfig as Re}from"../../config/env-config.js";import{addLeadingSlash as Ae}from"../../../utils/url/add-leading-slash.js";import{isPathInFolder as D}from"../../../utils/path/is-path-in-folder.js";import{getLlmsTxtMdPathBySlug as Ee}from"../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{resolveLlmsTxtMd as J}from"../../utils/llmstxt/resolve-llms-txt-md.js";import{removeLeadingSlash as I}from"../../../utils/url/remove-leading-slash.js";import{decodeRequestPath as Ce}from"../../utils/decode-request-path.js";import{AI_INDEX_EXPORT_FOLDER as _e,SEARCH_DATA_EXPORT_FOLDER as Le}from"../../constants/plugins/search.js";import{processRedirects as Te}from"./helpers/process-redirects.js";import{renderPage as Pe,getServerProps as Oe}from"../../ssr/index.js";import{canAccessAsset as we,canAccessResource as K}from"../../utils/rbac.js";import{handleErrorPageRender as A,handleUnauthorized as Q,handleUnauthorizedAsset as x}from"../utils.js";import{DEFAULT_MAX_AGE_FOR_MIME_TYPE as De,MIME_TYPES as Ie}from"../mime-types.js";import{fileExistsAsync as Se}from"../../utils/index.js";import{isAiAgentRequest as ye}from"../../utils/ai-agent-detection.js";import{getRedirectRoute as Ue}from"../utils/legacy-openapi-redirects.js";import{getContentTypeHeaderValue as ee}from"../utils/content-type.js";import{telemetry as be}from"../../../cli/telemetry/index.js";import{telemetry as Me}from"../../telemetry/index.js";const Fe=[Le,_e,de,I(me),I(ce),le];async function qe(e,E){try{const[C,u]=await Promise.all([G(e),G(E)]);return Fe.some(t=>D(C,m.join(u,t)))}catch{return!1}}function mt(e,E,C,u){return async t=>{const S=t.get("logger"),i=t.req,c=new URL(i.url),_=c.pathname.replace(/\/{2,}/g,"/"),y=Ce(_);if(y===void 0)return t.text("Bad Request",400);const d=Re.isProductionEnv?301:302;if(_!==c.pathname)return t.newResponse(null,d,{Location:_+c.search});const r=ie(y),U=m.parse(r).ext.toLowerCase()===".md",b=ye({accept:i.header("accept"),signatureAgent:i.header("signature-agent"),signature:i.header("signature"),signatureInput:i.header("signature-input"),userAgent:i.header("user-agent")}),a=Ae(Z(r)),o=(i.method==="GET"||i.method==="HEAD")&&!U?e.getRouteBySlug(a,{followRedirect:!1})||pe(e.routesBySlug?.values(),n=>n.hasClientRoutes&&(r===n.slug||r.startsWith(n.slug+"/"))):void 0,M=e.getRedirect(a);if(M){const n=Te({redirect:M,reqUrlSearch:c.search});return Me.sendRedirectMessage([{id:a,object:"redirect",uri:`urn:redocly:realm:api:redirect:${a}`,from:a,templateId:n.type.toString()}]),t.newResponse(null,n.type,{Location:n.location})}if(o?.metadata?.type==="openapi"){const n=Ue(c.pathname);if(n)return S.info("Legacy OpenAPI docs redirect from "+c.pathname),t.newResponse(null,d,{Location:encodeURI(n)});if(r.match(/[A-Z]/))return S.warn("Redirect to lowercase route to avoid 404 error"),t.newResponse(null,d,{Location:encodeURI(R(r.toLowerCase()))})}if(r.endsWith("/")&&r!=="/"){const n=he(new URL(a||"/",t.req.url).pathname);return t.newResponse(null,d,{Location:R((n==="/"?"/":Z(n))+c.search)})}const{isAuthenticated:f,teams:L,claims:{email:T}}=t.get("auth");if(o&&!K(o,{isAuthenticated:f,email:T,teams:L},e.config.access?.rbac,e.config.access?.requiresLogin))return f?A(t,e,{slug:o.slug,[j]:o[j],[z]:o[z]},403):Q(t,e,o.slug);const g=o&&b?Ee(o.slug):void 0,F=g?await J(g,e,u):void 0,P=F?.exists??!1;if(o&&(!b||!P)){const n=await E(o),N=await Oe(o,t,n,e),{html:ne,statusCode:X,error:oe}=await Pe(o,N,t,e,be),Y=e.config.access?.rbac,$=!e.config.access?.requiresLogin&&(!Y||!Object.keys(Y).length),k=X>=400||!!oe||!!e.compilationErrors?.length,re=$&&!k;let h;return k?h=W:$?h=ae:h="private",t.html(ne,X,{"Cache-Control":h,...re&&{[fe]:ge}})}const p=g&&P?g:r,te=I(p),s=m.resolve(e.outdir,te);if(!D(s,e.outdir))return x(t);const q=U?await J(r,e,u):void 0,l=q?.route;if(l&&!K(l,{isAuthenticated:f,email:T,teams:L},e.config.access?.rbac,e.config.access?.requiresLogin))return Q(t,e,r);if(!P&&!l){if(await qe(s,e.outdir))return A(t,e,{slug:a},404);const n=e.getGlobalConfig("access");if(!we(p,n?.rbac||{},n?.requiresLogin||!1,e.getGlobalConfig("directoryPaths"),{isAuthenticated:f,email:T,teams:L}))return D(p,ue)?x(t):A(t,e,{slug:a},404)}const O=Ie[m.extname(s)]||"text/plain",w=s.match(/assets\/.*\.[a-f0-9]{8,}\..+/)||s.match(/runtime\/chunks\/.*/)?se:De[O],H=w?{"Cache-Control":`public, max-age=${w}, immutable`,Expires:new Date(Date.now()+w*1e3).toUTCString()}:{"Cache-Control":W},B=i.query("download")!=null,v=F?.content??q?.content;if(v!==void 0)return t.newResponse(v,200,{"Content-Type":ee(O),"Access-Control-Allow-Origin":"*",...H,...l&&{"X-Robots-Tag":"noindex, follow",...e.config.seo?.siteUrl&&{Link:`<${V(e.config.seo.siteUrl,R(l.slug))}>; rel="canonical"`}},...B&&{"Content-Disposition":`attachment; filename="${m.basename(p)}"`}});if(await Se(s)){const n=await C(s);return t.newResponse(n,200,{"Content-Type":ee(O),"Access-Control-Allow-Origin":"*",...H,...l&&{"X-Robots-Tag":"noindex, follow",...e.config.seo?.siteUrl&&{Link:`<${V(e.config.seo.siteUrl,R(l.slug))}>; rel="canonical"`}},...B&&{"Content-Disposition":`attachment; filename="${m.basename(s)}"`}})}else return A(t,e,{slug:a},404)}}export{mt as dynamicRouteHandler};
1
+ import m from"path";import{realpath as z}from"fs/promises";import{REDOCLY_ROUTE_RBAC as G,REDOCLY_TEAMS_RBAC as j}from"@redocly/config";import{combineUrls as V,getMarkdownCopyPath as ae,withoutPathPrefix as se,withPathPrefix as R}from"@redocly/theme/core/utils";import{CACHE_CONTROL_NO_STORE_HEADER_VALUE as W,CACHE_CONTROL_PUBLIC_HTML as ce,DEFAULT_IMMUTABLE_CACHE_MAX_AGE as le,DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as me,PAGE_DATA_FOLDER as ue,PUBLIC_API_DEFINITIONS_FOLDER as de,PUBLIC_ASSETS_FOLDER as fe,STATIC_DATA_FOLDER as ge,X_REDOCLY_CACHE_CONTROL_HEADER as pe,X_REDOCLY_CACHE_CONTROL_PUBLIC_HTML as he}from"../../constants/common.js";import{removeTrailingSlash as Z}from"../../../utils/url/remove-trailing-slash.js";import{findInIterable as Re}from"../../../utils/collection/find-in-iterable.js";import{sanitizeRedirectPathname as Ae}from"../../../utils/url/sanitize-redirect-pathname.js";import{envConfig as Ee}from"../../config/env-config.js";import{addLeadingSlash as Ce}from"../../../utils/url/add-leading-slash.js";import{isPathInFolder as I}from"../../../utils/path/is-path-in-folder.js";import{resolveLlmsTxtMd as J,resolvePageMarkdownUrl as _e}from"../../utils/llmstxt/resolve-llms-txt-md.js";import{removeLeadingSlash as U}from"../../../utils/url/remove-leading-slash.js";import{decodeRequestPath as Le}from"../../utils/decode-request-path.js";import{AI_INDEX_EXPORT_FOLDER as we,SEARCH_DATA_EXPORT_FOLDER as Pe}from"../../constants/plugins/search.js";import{processRedirects as Te}from"./helpers/process-redirects.js";import{renderPage as Oe,getServerProps as De}from"../../ssr/index.js";import{canAccessAsset as Ie,canAccessResource as K}from"../../utils/rbac.js";import{handleErrorPageRender as A,handleUnauthorized as Q,handleUnauthorizedAsset as x}from"../utils.js";import{DEFAULT_MAX_AGE_FOR_MIME_TYPE as Ue,MIME_TYPES as Se}from"../mime-types.js";import{fileExistsAsync as ye}from"../../utils/index.js";import{isAiAgentRequest as Me}from"../../utils/ai-agent-detection.js";import{getRedirectRoute as be}from"../utils/legacy-openapi-redirects.js";import{getContentTypeHeaderValue as ee}from"../utils/content-type.js";import{telemetry as Fe}from"../../../cli/telemetry/index.js";import{telemetry as qe}from"../../telemetry/index.js";const He=[Pe,we,ge,U(de),U(me),ue];async function ve(e,E){try{const[C,u]=await Promise.all([z(e),z(E)]);return He.some(n=>I(C,m.join(u,n)))}catch{return!1}}function dn(e,E,C,u){return async n=>{const S=n.get("logger"),a=n.req,c=new URL(a.url),_=c.pathname.replace(/\/{2,}/g,"/"),y=Le(_);if(y===void 0)return n.text("Bad Request",400);const d=Ee.isProductionEnv?301:302;if(_!==c.pathname)return n.newResponse(null,d,{Location:_+c.search});const r=se(y),M=m.parse(r).ext.toLowerCase()===".md",b=Me({accept:a.header("accept"),signatureAgent:a.header("signature-agent"),signature:a.header("signature"),signatureInput:a.header("signature-input"),userAgent:a.header("user-agent")}),i=Ce(Z(r)),o=(a.method==="GET"||a.method==="HEAD")&&!M?e.getRouteBySlug(i,{followRedirect:!1})||Re(e.routesBySlug?.values(),t=>t.hasClientRoutes&&(r===t.slug||r.startsWith(t.slug+"/"))):void 0,F=e.getRedirect(i);if(F){const t=Te({redirect:F,reqUrlSearch:c.search});return qe.sendRedirectMessage([{id:i,object:"redirect",uri:`urn:redocly:realm:api:redirect:${i}`,from:i,templateId:t.type.toString()}]),n.newResponse(null,t.type,{Location:t.location})}if(o?.metadata?.type==="openapi"){const t=be(c.pathname);if(t)return S.info("Legacy OpenAPI docs redirect from "+c.pathname),n.newResponse(null,d,{Location:encodeURI(t)});if(r.match(/[A-Z]/))return S.warn("Redirect to lowercase route to avoid 404 error"),n.newResponse(null,d,{Location:encodeURI(R(r.toLowerCase()))})}if(r.endsWith("/")&&r!=="/"){const t=Ae(new URL(i||"/",n.req.url).pathname);return n.newResponse(null,d,{Location:R((t==="/"?"/":Z(t))+c.search)})}const{isAuthenticated:f,teams:L,claims:{email:w}}=n.get("auth");if(o&&!K(o,{isAuthenticated:f,email:w,teams:L},e.config.access?.rbac,e.config.access?.requiresLogin))return f?A(n,e,{slug:o.slug,[j]:o[j],[G]:o[G]},403):Q(n,e,o.slug);const g=o&&b?ae(i):void 0,q=g?await J(g,e,u):void 0,P=q?.exists??!1;if(o&&(!b||!P)){const t=await E(o),D=await _e(i,e,u),te={...await De(o,n,t,e),...D?{markdownUrl:D}:{}},{html:oe,statusCode:X,error:re}=await Oe(o,te,n,e,Fe),k=e.config.access?.rbac,Y=!e.config.access?.requiresLogin&&(!k||!Object.keys(k).length),$=X>=400||!!re||!!e.compilationErrors?.length,ie=Y&&!$;let h;return $?h=W:Y?h=ce:h="private",n.html(oe,X,{"Cache-Control":h,...ie&&{[pe]:he}})}const p=g&&P?g:r,ne=U(p),s=m.resolve(e.outdir,ne);if(!I(s,e.outdir))return x(n);const H=M?await J(r,e,u):void 0,l=H?.route;if(l&&!K(l,{isAuthenticated:f,email:w,teams:L},e.config.access?.rbac,e.config.access?.requiresLogin))return Q(n,e,r);if(!P&&!l){if(await ve(s,e.outdir))return A(n,e,{slug:i},404);const t=e.getGlobalConfig("access");if(!Ie(p,t?.rbac||{},t?.requiresLogin||!1,e.getGlobalConfig("directoryPaths"),{isAuthenticated:f,email:w,teams:L}))return I(p,fe)?x(n):A(n,e,{slug:i},404)}const T=Se[m.extname(s)]||"text/plain",O=s.match(/assets\/.*\.[a-f0-9]{8,}\..+/)||s.match(/runtime\/chunks\/.*/)?le:Ue[T],v=O?{"Cache-Control":`public, max-age=${O}, immutable`,Expires:new Date(Date.now()+O*1e3).toUTCString()}:{"Cache-Control":W},B=a.query("download")!=null,N=q?.content??H?.content;if(N!==void 0)return n.newResponse(N,200,{"Content-Type":ee(T),"Access-Control-Allow-Origin":"*",...v,...l&&{"X-Robots-Tag":"noindex, follow",...e.config.seo?.siteUrl&&{Link:`<${V(e.config.seo.siteUrl,R(l.slug))}>; rel="canonical"`}},...B&&{"Content-Disposition":`attachment; filename="${m.basename(p)}"`}});if(await ye(s)){const t=await C(s);return n.newResponse(t,200,{"Content-Type":ee(T),"Access-Control-Allow-Origin":"*",...v,...l&&{"X-Robots-Tag":"noindex, follow",...e.config.seo?.siteUrl&&{Link:`<${V(e.config.seo.siteUrl,R(l.slug))}>; rel="canonical"`}},...B&&{"Content-Disposition":`attachment; filename="${m.basename(s)}"`}})}else return A(n,e,{slug:i},404)}}export{dn as dynamicRouteHandler};
@@ -1 +1 @@
1
- import{serveStatic as c}from"hono/serve-static";import{withPathPrefix as i,withoutPathPrefix as H}from"@redocly/theme/core/utils";import{ServerRoutes as l}from"../../../constants/api.js";import{LLMS_TXT_FILE_NAME as L,PUBLIC_STATIC_FOLDER as C}from"../../constants/common.js";import{envConfig as I}from"../../config/env-config.js";import{authMiddleware as g}from"../middleware/authMiddleware.js";import{ensureSearchData as h}from"../middleware/ensureSearchData.js";import{dynamicMiddleware as D}from"../middleware/dynamic-middleware/dynamic-middleware.js";import{installRoutes as P}from"../../plugins/dev-onboarding/api/routes/index.js";import{installSkillsRoutes as N}from"./skills/skills-routes.js";import{llmsTxtHandler as M}from"./llms-txt.js";import{authorizeHandler as w,oidcCallbackHandler as B,logoutHandler as E,postLogoutHandler as v,idpLoginHandler as F,redoclyLoginCallbackHandler as G,samlCallbackHandler as U,redoclyTokenLoginHandler as Y,inviteHandler as y}from"./auth.js";import{appDataHandler as K}from"./app-data.js";import{searchFacetsHandler as k,searchHandler as x}from"./search.js";import{dynamicRouteHandler as b}from"./dynamic-route.js";import{pageDataHandler as V,sharedPageDataHandler as q}from"./page-data.js";import{pathPrefixRedirectHandler as X}from"./path-prefix-redirect.js";import{getRoutesByLineHandler as _,resolvePathHandler as S,resolvePathsHandler as $,resolveSlugHandler as f}from"./resolve-route.js";import{feedbackHandler as j}from"./feedback.js";import{loggerMiddleware as z}from"../middleware/loggerMiddleware.js";import{responseHeadersMiddleware as W}from"../middleware/responseHeadersMiddleware.js";import{idleTimeoutMiddleware as Z}from"../middleware/idleTimeoutMiddleware.js";import{otelTracesHandler as u}from"./otel/otel.js";import{healthCheckHandler as J}from"./health.js";import{askAiHandler as Q,aiAssistantEscalationsHandler as aa,aiAssistantFeedbackHandler as ea,AI_ASSISTANT_IDENTITY_STATUS_HEADER as ia}from"./ask-ai.js";import{semanticSearchHandler as la}from"./semantic-search.js";import{replayOauth2RedirectCallbackHandler as ta}from"./replay-oauth2-redirect.js";import{corsProxyHandler as r}from"./cors-proxy.js";import{corsMiddleware as m}from"../middleware/corsMiddleware.js";import{installApiRoutes as ma}from"./api-routes/api-routes.js";import{cookieMiddleware as oa}from"../middleware/cookieMiddleware.js";import{staticContentHandler as da}from"../routes/static-content.js";import{infoHandler as O}from"./info.js";import{catalogHandler as Aa}from"./catalog/catalog.js";import{catalogRelationsHandler as na}from"./catalog/catalog-relations.js";import{bffCatalogHandler as sa}from"./catalog/bff-catalog.js";import{bffCatalogRevisionsHandler as pa}from"./catalog/bff-catalog-revisions.js";import{bffCatalogRelatedEntitiesHandler as Ta}from"./catalog/bff-catalog-related-entities.js";import{catalogAuthMiddleware as o}from"../middleware/catalogAuthMiddleware.js";import{telemetryMiddleware as Ea}from"../middleware/telemetry-middleware.js";import{errorHandler as _a}from"./error.js";import{installMcpRoutes as Sa}from"./mcp-routes/mcp-routes.js";import{jsonValidatorMiddleware as n}from"../middleware/jsonValidatorMiddleware.js";import{otelTracesRequestSchema as fa}from"../../../api-schemas/otel-traces.js";import{searchFacetsRequestSchema as ra}from"../../../api-schemas/search-facets.js";import{searchRequestSchema as Oa}from"../../../api-schemas/search.js";function Te(a,e,d){const{resolveRouteData:s,readStaticAsset:p,llmsTxtGenerator:A}=d;a.use("*",Z()),a.use("*",oa()),a.use("*",D(e)),a.use("*",g(e)),a.use("*",z()),a.use("*",W(e)),a.use("*",Ea()),a.use(i("*"),c({root:`./${C}`,getContent:(t,R)=>da(t,R,e,p),rewriteRequestPath:t=>H(t)})),a.use(i(l.FEEDBACK),m({allowMethods:["POST"]})),a.use(i(l.ASK_AI),m({allowMethods:["POST"],exposeHeaders:[ia]})),a.use(i(l.AI_ASSISTANT_ESCALATIONS),m({allowMethods:["POST"]})),a.use(i(l.AI_ASSISTANT_FEEDBACK),m({allowMethods:["POST"]})),a.use(i(l.SEMANTIC_SEARCH),m({allowMethods:["POST"]})),a.use("*",Ra(e));const T=h(e);a.use(i(l.INFO),O()),I.NEW_CATALOG_ENABLED&&(a.use(i(l.CATALOG_ENTITIES),o({serverOutDir:e.serverOutDir}),Aa(e)),a.use(i(l.CATALOG_ENTITIES_RELATIONS),o({serverOutDir:e.serverOutDir}),na(e)),a.get(i(l.BFF_CATALOG_ENTITIES),o({serverOutDir:e.serverOutDir,protectReadMethods:!1}),sa(e)),a.get(i(l.BFF_CATALOG_RELATED_ENTITIES),o({serverOutDir:e.serverOutDir,protectReadMethods:!1}),Ta(e)),a.get(i(l.BFF_CATALOG_REVISIONS),o({serverOutDir:e.serverOutDir,protectReadMethods:!1}),pa(e))),a.get(i(l.SHARED_PAGE_DATA),q(e)),a.get(i(l.PAGE_DATA),V(e,s)),a.get(i(l.APP_DATA),K(e)),a.post(i(l.SEARCH),T,n(Oa),x(e)),a.post(i(l.SEARCH_FACETS),T,n(ra),k(e)),a.post(i(l.AUTHORIZATION),t=>w(t,e)),a.post(i(l.LOGOUT),E(e)),a.get(i(l.LOGOUT),E(e)),a.get(i(l.POST_LOGOUT),v(e)),a.get(i(l.OIDC_CALLBACK),B(e)),a.get(i(l.REDOCLY_TOKEN_LOGIN),Y(e)),a.get(i(l.REDOCLY_LOGIN_CALLBACK),G()),a.get(i(l.IDP_LOGIN),F(e)),a.post(i(l.SAML_CALLBACK),U(e)),a.get(i(l.INVITE),y(e)),a.get(i(l.HEALTH),J),Sa(a,e),P(a,e),N(a,e),a.all(i(l.CORS_PROXY),r(e)),a.all(i(`${l.CORS_PROXY}/*`),r(e)),ma(a,e),a.post(i(l.FEEDBACK),j(e)),a.post(i(l.RESOLVE_ROUTE_BY_PATH),S(e)),a.post(i(l.RESOLVE_ROUTES_BY_PATHS),$(e)),a.post(i(l.RESOLVE_ROUTE_BY_SLUG),f(e)),a.post(i(l.ASK_AI),Q(e)),a.post(i(l.AI_ASSISTANT_ESCALATIONS),aa(e)),a.post(i(l.AI_ASSISTANT_FEEDBACK),ea(e)),a.post(i(l.SEMANTIC_SEARCH),la(e)),a.get(i(l.GET_ROUTES_BY_LINE),_(e)),a.post(i(l.OTEL_TRACES),n(fa),u),a.get(i(l.REPLAY_OAUTH2_CALLBACK),ta),A&&a.get(i(`/${L}`),M(A)),a.all(i("/*"),b(e,s,p,A)),a.get("*",X),a.onError(_a)}function Ra(a){return async(e,d)=>{await a.waitForPluginsLifecycle(),await d()}}function Ee(a,e){a.get(i(l.INFO),O()),a.post(i(l.RESOLVE_ROUTE_BY_PATH),S(e)),a.post(i(l.RESOLVE_ROUTE_BY_SLUG),f(e)),a.get(i(l.GET_ROUTES_BY_LINE),_(e))}export{Ee as installDevRoutes,Te as installProdRoutes,Ra as waitForPluginsLifecycle};
1
+ import{serveStatic as c}from"hono/serve-static";import{withPathPrefix as i,withoutPathPrefix as H}from"@redocly/theme/core/utils";import{ServerRoutes as l}from"../../../constants/api.js";import{LLMS_TXT_FILE_NAME as L,PUBLIC_STATIC_FOLDER as C}from"../../constants/common.js";import{envConfig as I}from"../../config/env-config.js";import{authMiddleware as g}from"../middleware/authMiddleware.js";import{ensureSearchData as h}from"../middleware/ensureSearchData.js";import{dynamicMiddleware as D}from"../middleware/dynamic-middleware/dynamic-middleware.js";import{installRoutes as P}from"../../plugins/dev-onboarding/api/routes/index.js";import{installSkillsRoutes as N}from"./skills/skills-routes.js";import{llmsTxtHandler as M}from"./llms-txt.js";import{authorizeHandler as w,oidcCallbackHandler as B,logoutHandler as E,postLogoutHandler as v,idpLoginHandler as F,redoclyLoginCallbackHandler as G,samlCallbackHandler as U,redoclyTokenLoginHandler as Y,inviteHandler as y}from"./auth.js";import{appDataHandler as K}from"./app-data.js";import{searchFacetsHandler as k,searchHandler as x}from"./search.js";import{dynamicRouteHandler as b}from"./dynamic-route.js";import{pageDataHandler as V,sharedPageDataHandler as q}from"./page-data.js";import{pathPrefixRedirectHandler as X}from"./path-prefix-redirect.js";import{getRoutesByLineHandler as _,resolvePathHandler as S,resolvePathsHandler as $,resolveSlugHandler as f}from"./resolve-route.js";import{feedbackHandler as j}from"./feedback.js";import{loggerMiddleware as z}from"../middleware/loggerMiddleware.js";import{responseHeadersMiddleware as W}from"../middleware/responseHeadersMiddleware.js";import{idleTimeoutMiddleware as Z}from"../middleware/idleTimeoutMiddleware.js";import{otelTracesHandler as u}from"./otel/otel.js";import{healthCheckHandler as J}from"./health.js";import{askAiHandler as Q,aiAssistantEscalationsHandler as aa,aiAssistantFeedbackHandler as ea,AI_ASSISTANT_IDENTITY_STATUS_HEADER as ia}from"./ask-ai.js";import{semanticSearchHandler as la}from"./semantic-search.js";import{replayOauth2RedirectCallbackHandler as ta}from"./replay-oauth2-redirect.js";import{corsProxyHandler as r}from"./cors-proxy.js";import{corsMiddleware as m}from"../middleware/corsMiddleware.js";import{installApiRoutes as ma}from"./api-routes/api-routes.js";import{cookieMiddleware as oa}from"../middleware/cookieMiddleware.js";import{staticContentHandler as da}from"../routes/static-content.js";import{infoHandler as O}from"./info.js";import{catalogHandler as Aa}from"./catalog/catalog.js";import{catalogRelationsHandler as na}from"./catalog/catalog-relations.js";import{bffCatalogHandler as sa}from"./catalog/bff-catalog.js";import{bffCatalogRevisionsHandler as pa}from"./catalog/bff-catalog-revisions.js";import{bffCatalogRelatedEntitiesHandler as Ta}from"./catalog/bff-catalog-related-entities.js";import{catalogAuthMiddleware as o}from"../middleware/catalogAuthMiddleware.js";import{telemetryMiddleware as Ea}from"../middleware/telemetry-middleware.js";import{errorHandler as _a}from"./error.js";import{installMcpRoutes as Sa}from"./mcp-routes/mcp-routes.js";import{jsonValidatorMiddleware as n}from"../middleware/jsonValidatorMiddleware.js";import{otelTracesRequestSchema as fa}from"../../../api-schemas/otel-traces.js";import{searchFacetsRequestSchema as ra}from"../../../api-schemas/search-facets.js";import{searchRequestSchema as Oa}from"../../../api-schemas/search.js";function Te(a,e,A){const{resolveRouteData:s,readStaticAsset:p,llmsTxtGenerator:d}=A;a.use("*",Z()),a.use("*",oa()),a.use("*",D(e)),a.use("*",g(e)),a.use("*",z()),a.use("*",W(e)),a.use("*",Ea()),a.use(i("*"),c({root:`./${C}`,getContent:(t,R)=>da(t,R,e,p),rewriteRequestPath:t=>H(t)})),a.use(i(l.FEEDBACK),m({allowMethods:["POST"]})),a.use(i(l.ASK_AI),m({allowMethods:["POST"],exposeHeaders:[ia]})),a.use(i(l.AI_ASSISTANT_ESCALATIONS),m({allowMethods:["POST"]})),a.use(i(l.AI_ASSISTANT_FEEDBACK),m({allowMethods:["POST"]})),a.use(i(l.SEMANTIC_SEARCH),m({allowMethods:["POST"]})),a.use("*",Ra(e));const T=h(e);a.use(i(l.INFO),O()),I.NEW_CATALOG_ENABLED&&(a.use(i(l.CATALOG_ENTITIES),o({serverOutDir:e.serverOutDir}),Aa(e)),a.use(i(l.CATALOG_ENTITIES_RELATIONS),o({serverOutDir:e.serverOutDir}),na(e)),a.get(i(l.BFF_CATALOG_ENTITIES),o({serverOutDir:e.serverOutDir,protectReadMethods:!1}),sa(e)),a.get(i(l.BFF_CATALOG_RELATED_ENTITIES),o({serverOutDir:e.serverOutDir,protectReadMethods:!1}),Ta(e)),a.get(i(l.BFF_CATALOG_REVISIONS),o({serverOutDir:e.serverOutDir,protectReadMethods:!1}),pa(e))),a.get(i(l.SHARED_PAGE_DATA),q(e)),a.get(i(l.PAGE_DATA),V(e,s,d)),a.get(i(l.APP_DATA),K(e)),a.post(i(l.SEARCH),T,n(Oa),x(e)),a.post(i(l.SEARCH_FACETS),T,n(ra),k(e)),a.post(i(l.AUTHORIZATION),t=>w(t,e)),a.post(i(l.LOGOUT),E(e)),a.get(i(l.LOGOUT),E(e)),a.get(i(l.POST_LOGOUT),v(e)),a.get(i(l.OIDC_CALLBACK),B(e)),a.get(i(l.REDOCLY_TOKEN_LOGIN),Y(e)),a.get(i(l.REDOCLY_LOGIN_CALLBACK),G()),a.get(i(l.IDP_LOGIN),F(e)),a.post(i(l.SAML_CALLBACK),U(e)),a.get(i(l.INVITE),y(e)),a.get(i(l.HEALTH),J),Sa(a,e),P(a,e),N(a,e),a.all(i(l.CORS_PROXY),r(e)),a.all(i(`${l.CORS_PROXY}/*`),r(e)),ma(a,e),a.post(i(l.FEEDBACK),j(e)),a.post(i(l.RESOLVE_ROUTE_BY_PATH),S(e)),a.post(i(l.RESOLVE_ROUTES_BY_PATHS),$(e)),a.post(i(l.RESOLVE_ROUTE_BY_SLUG),f(e)),a.post(i(l.ASK_AI),Q(e)),a.post(i(l.AI_ASSISTANT_ESCALATIONS),aa(e)),a.post(i(l.AI_ASSISTANT_FEEDBACK),ea(e)),a.post(i(l.SEMANTIC_SEARCH),la(e)),a.get(i(l.GET_ROUTES_BY_LINE),_(e)),a.post(i(l.OTEL_TRACES),n(fa),u),a.get(i(l.REPLAY_OAUTH2_CALLBACK),ta),d&&a.get(i(`/${L}`),M(d)),a.all(i("/*"),b(e,s,p,d)),a.get("*",X),a.onError(_a)}function Ra(a){return async(e,A)=>{await a.waitForPluginsLifecycle(),await A()}}function Ee(a,e){a.get(i(l.INFO),O()),a.post(i(l.RESOLVE_ROUTE_BY_PATH),S(e)),a.post(i(l.RESOLVE_ROUTE_BY_SLUG),f(e)),a.get(i(l.GET_ROUTES_BY_LINE),_(e))}export{Ee as installDevRoutes,Te as installProdRoutes,Ra as waitForPluginsLifecycle};
@@ -1,6 +1,7 @@
1
1
  import type { Handler } from 'hono';
2
2
  import type { Store } from '../../store';
3
3
  import type { RouteDataResolver } from './index';
4
- export declare function pageDataHandler(store: Store, resolveRouteData: RouteDataResolver): Handler;
4
+ import type { LlmsTxtGenerator } from '../../types';
5
+ export declare function pageDataHandler(store: Store, resolveRouteData: RouteDataResolver, llmsTxtGenerator?: LlmsTxtGenerator): Handler;
5
6
  export declare function sharedPageDataHandler(store: Store): Handler;
6
7
  //# sourceMappingURL=page-data.d.ts.map
@@ -1 +1 @@
1
- import{MCP_ROUTE as $,PUBLIC_MCP_ROUTE as w}from"@redocly/theme/core/constants/mcp";import{ServerRoutes as M}from"../../../constants/api.js";import{DEV_LOGIN_SLUG as F}from"../../../constants/common.js";import{CACHE_CONTROL_NO_STORE_HEADER_VALUE as a,DEFAULT_TITLE as N}from"../../constants/common.js";import{findInIterable as B}from"../../../utils/collection/find-in-iterable.js";import{removeTrailingSlash as q}from"../../../utils/url/remove-trailing-slash.js";import{envConfig as b}from"../../config/env-config.js";import{canAccessResource as H,filterDataByAccessDeep as T,isResourcePubliclyAccessible as G}from"../../utils/rbac.js";import{getServerProps as V}from"../../ssr/index.js";import{readSharedData as W}from"../../utils/index.js";import{getRedirectLoginUrl as k}from"../utils/get-redirect-login-url.js";import{processRedirects as K}from"./helpers/process-redirects.js";import{removeErrorDetails as z}from"../utils/remove-error-details.js";import{telemetry as J}from"../../telemetry/index.js";import{MCP_NOT_ALLOWED_TEMPLATE_ID as Q}from"../../constants/mcp.js";function ue(e,n){return async(t,g)=>{const p=t.get("logger"),{req:u}=t,{pathname:d}=new URL(u.url),{seo:f,ssoDirect:h}=e.getConfig(),i=f?.title||N;if(e?.compilationErrors?.length&&b.isDevelopMode)return t.json({templateId:"compilation-error",props:{compilationErrors:e?.compilationErrors},sharedDataIds:{}},500,{"Cache-Control":a});const m=d.match(/page-data(.*)data.json$/);if(!m)return g();const c=decodeURI(m[1]),r=c==="/index/"?"/":q(c),o=e.getRouteBySlug(r,{followRedirect:!1})||B(e.routesBySlug.values(),s=>s.hasClientRoutes&&c.startsWith(s.slug+"/"));if(c===M.OIDC_CALLBACK+"/")return t.json({templateId:"403OIDC",sharedDataIds:{},props:{seo:{title:`${i} - Forbidden`}}},200,{"Cache-Control":a});const{isAuthenticated:C,teams:D,claims:{name:_,picture:P,email:I}}=t.get("auth"),R={isAuthenticated:C,email:I,teams:D},l={isAuthenticated:C,name:_,picture:P,email:I,teams:D};if((r===$||r===w&&!!e.globalData.mcpData?.docs?.publicEndpoint)&&e.globalData.mcpData?.docs?.enabled)return t.json({templateId:Q,sharedDataIds:{},props:{},userData:l},405,{"Cache-Control":a});const E=e.getRedirect(r);if(E){const{location:s,type:U}=K({redirect:E});return J.sendRedirectMessage([{id:r,object:"redirect",uri:`urn:redocly:realm:api:redirect:${r}`,from:r,templateId:"404"}]),t.json({templateId:"404",redirectTo:s,sharedDataIds:{},props:{}},U,{"Cache-Control":a})}if(!o){const s=e.getRouteBySlug(r,{followRedirect:!0});return p.error(`Page not found: ${d}`),t.json({templateId:"404",redirectTo:s?.slug,sharedDataIds:{},props:{seo:{title:`${i} - Not Found`}},userData:l},404,{"Cache-Control":a})}if(p.verbose(`Page viewed: ${o.slug}`),!H(o,R,e.config.access?.rbac,e.config.access?.requiresLogin)&&o.slug!==F){if(C)return t.json({templateId:"403",sharedDataIds:{},props:{seo:{title:`${i} - Forbidden`}},userData:l},403,{"Cache-Control":a});const s=Object.keys(h||{}).length>0;return t.json({templateId:"404",sharedDataIds:{},props:{seo:{title:`${i} - Not Found`}},userData:l,...s?{redirectTo:k(e,o.slug)}:{}},s?401:404,{"Cache-Control":a})}const S=T(o.versions,R,e.config.access?.rbac,e.config.access?.requiresLogin),j=e.routesSharedData.get(o.slug)||{},A=await n(o),v=await V(o,t,A,e),{sharedDataIds:O,...L}=v,y={templateId:o.templateId,versions:S,sharedDataIds:{...j,...O||{}},props:b.isProductionEnv?z(L):L,slug:o.slug,userData:l,isPublic:G(o,e.config)};return t.json(y,200,{"Cache-Control":a})}}function me(e){return async(n,t)=>{const g=n.get("logger"),{req:p}=n,{pathname:u}=new URL(p.url),d=u.match(/\/page-data\/shared\/(.*)\.json/);if(!d)return t();const f=decodeURIComponent(d[1]),h=await W(f,e.outdir),{isAuthenticated:i,teams:m,claims:{email:c}}=n.get("auth"),r=T(h,{isAuthenticated:i,email:c,teams:m},e.config.access?.rbac,e.config.access?.requiresLogin);return r?n.json(r,200,{"Cache-Control":a}):(g.error(`Shared data not found: ${u}`),n.text("Not Found",404,{"Cache-Control":a}))}}export{ue as pageDataHandler,me as sharedPageDataHandler};
1
+ import{MCP_ROUTE as $,PUBLIC_MCP_ROUTE as F}from"@redocly/theme/core/constants/mcp";import{ServerRoutes as N}from"../../../constants/api.js";import{DEV_LOGIN_SLUG as B}from"../../../constants/common.js";import{CACHE_CONTROL_NO_STORE_HEADER_VALUE as r,DEFAULT_TITLE as q}from"../../constants/common.js";import{findInIterable as H}from"../../../utils/collection/find-in-iterable.js";import{removeTrailingSlash as k}from"../../../utils/url/remove-trailing-slash.js";import{envConfig as T}from"../../config/env-config.js";import{canAccessResource as G,filterDataByAccessDeep as _,isResourcePubliclyAccessible as V}from"../../utils/rbac.js";import{getServerProps as W}from"../../ssr/index.js";import{readSharedData as K}from"../../utils/index.js";import{getRedirectLoginUrl as z}from"../utils/get-redirect-login-url.js";import{processRedirects as J}from"./helpers/process-redirects.js";import{removeErrorDetails as Q}from"../utils/remove-error-details.js";import{resolvePageMarkdownUrl as X}from"../../utils/llmstxt/resolve-llms-txt-md.js";import{telemetry as Y}from"../../telemetry/index.js";import{MCP_NOT_ALLOWED_TEMPLATE_ID as Z}from"../../constants/mcp.js";function he(e,n,g){return async(t,f)=>{const d=t.get("logger"),{req:p}=t,{pathname:m}=new URL(p.url),{seo:h,ssoDirect:C}=e.getConfig(),c=h?.title||q;if(e?.compilationErrors?.length&&T.isDevelopMode)return t.json({templateId:"compilation-error",props:{compilationErrors:e?.compilationErrors},sharedDataIds:{}},500,{"Cache-Control":r});const u=m.match(/page-data(.*)data.json$/);if(!u)return f();const i=decodeURI(u[1]),a=i==="/index/"?"/":k(i),o=e.getRouteBySlug(a,{followRedirect:!1})||H(e.routesBySlug.values(),s=>s.hasClientRoutes&&i.startsWith(s.slug+"/"));if(i===N.OIDC_CALLBACK+"/")return t.json({templateId:"403OIDC",sharedDataIds:{},props:{seo:{title:`${c} - Forbidden`}}},200,{"Cache-Control":r});const{isAuthenticated:D,teams:I,claims:{name:S,picture:j,email:R}}=t.get("auth"),E={isAuthenticated:D,email:R,teams:I},l={isAuthenticated:D,name:S,picture:j,email:R,teams:I};if((a===$||a===F&&!!e.globalData.mcpData?.docs?.publicEndpoint)&&e.globalData.mcpData?.docs?.enabled)return t.json({templateId:Z,sharedDataIds:{},props:{},userData:l},405,{"Cache-Control":r});const L=e.getRedirect(a);if(L){const{location:s,type:M}=J({redirect:L});return Y.sendRedirectMessage([{id:a,object:"redirect",uri:`urn:redocly:realm:api:redirect:${a}`,from:a,templateId:"404"}]),t.json({templateId:"404",redirectTo:s,sharedDataIds:{},props:{}},M,{"Cache-Control":r})}if(!o){const s=e.getRouteBySlug(a,{followRedirect:!0});return d.error(`Page not found: ${m}`),t.json({templateId:"404",redirectTo:s?.slug,sharedDataIds:{},props:{seo:{title:`${c} - Not Found`}},userData:l},404,{"Cache-Control":r})}if(d.verbose(`Page viewed: ${o.slug}`),!G(o,E,e.config.access?.rbac,e.config.access?.requiresLogin)&&o.slug!==B){if(D)return t.json({templateId:"403",sharedDataIds:{},props:{seo:{title:`${c} - Forbidden`}},userData:l},403,{"Cache-Control":r});const s=Object.keys(C||{}).length>0;return t.json({templateId:"404",sharedDataIds:{},props:{seo:{title:`${c} - Not Found`}},userData:l,...s?{redirectTo:z(e,o.slug)}:{}},s?401:404,{"Cache-Control":r})}const v=_(o.versions,E,e.config.access?.rbac,e.config.access?.requiresLogin),A=e.routesSharedData.get(o.slug)||{},U=await n(o),O=await W(o,t,U,e),b=await X(a,e,g),{sharedDataIds:w,...P}={...O,...b?{markdownUrl:b}:{}},y={templateId:o.templateId,versions:v,sharedDataIds:{...A,...w||{}},props:T.isProductionEnv?Q(P):P,slug:o.slug,userData:l,isPublic:V(o,e.config)};return t.json(y,200,{"Cache-Control":r})}}function Ce(e){return async(n,g)=>{const t=n.get("logger"),{req:f}=n,{pathname:d}=new URL(f.url),p=d.match(/\/page-data\/shared\/(.*)\.json/);if(!p)return g();const m=decodeURIComponent(p[1]),h=await K(m,e.outdir),{isAuthenticated:C,teams:c,claims:{email:u}}=n.get("auth"),i=_(h,{isAuthenticated:C,email:u,teams:c},e.config.access?.rbac,e.config.access?.requiresLogin);return i?n.json(i,200,{"Cache-Control":r}):(t.error(`Shared data not found: ${d}`),n.text("Not Found",404,{"Cache-Control":r}))}}export{he as pageDataHandler,Ce as sharedPageDataHandler};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/revel",
3
- "version": "0.141.0-next.5",
3
+ "version": "0.141.0-next.6",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,7 +33,7 @@
33
33
  "@opentelemetry/sdk-trace-web": "2.8.0",
34
34
  "@opentelemetry/semantic-conventions": "1.40.0",
35
35
  "@redocly/ajv": "8.18.0",
36
- "@redocly/api-docs": "0.6.0-next.5",
36
+ "@redocly/api-docs": "0.6.0-next.6",
37
37
  "@redocly/config": "0.74.0",
38
38
  "@redocly/markdoc": "0.7.0-beta.2",
39
39
  "@redocly/openapi-core": "2.77.0",
@@ -1,19 +0,0 @@
1
- /**
2
- * Builds the markdown asset path used for `llms.txt` / AI agent flows from a route slug.
3
- *
4
- * The site root slug (`/`) maps to `index.html.md` so the home page resolves like other HTML routes;
5
- * every other slug gets a `.md` suffix on the same path.
6
- *
7
- * @param routeSlug - URL path segment for the page (e.g. `/`, `/docs`, `/reference/petstore`)
8
- * @returns Path to the corresponding markdown file (e.g. `/index.html.md`, `/docs.md`)
9
- *
10
- * @example
11
- * getLlmsTxtMdPathBySlug('/');
12
- * // returns '/index.html.md'
13
- *
14
- * @example
15
- * getLlmsTxtMdPathBySlug('/guides/getting-started');
16
- * // returns '/guides/getting-started.md'
17
- */
18
- export declare function getLlmsTxtMdPathBySlug(routeSlug: string): string;
19
- //# sourceMappingURL=get-llms-txt-md-path-by-slug.d.ts.map
@@ -1 +0,0 @@
1
- function d(t){return`${t}${t==="/"?"index.html.md":".md"}`}export{d as getLlmsTxtMdPathBySlug};