@redocly/revel 0.141.0-next.1 → 0.141.0-next.10
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 +149 -0
- package/dist/cli/develop.js +1 -1
- package/dist/cli/utils/react-pages-check.d.ts +11 -0
- package/dist/cli/utils/react-pages-check.js +1 -0
- package/dist/client/App.js +1 -1
- package/dist/client/app/Sidebar/useSidebarItems.js +1 -1
- package/dist/client/app/hooks/useBanner.js +1 -1
- package/dist/client/app/hooks/useUserClaims.js +1 -1
- package/dist/client/app/webmcp/tools/shared.d.ts +2 -3
- package/dist/client/app/webmcp/tools/shared.js +1 -1
- package/dist/client/runtime/errors/page-async-component-error.d.ts +4 -0
- package/dist/client/runtime/errors/page-async-component-error.js +1 -0
- package/dist/client/runtime/loader.js +1 -1
- package/dist/constants/common.d.ts +2 -0
- package/dist/constants/common.js +1 -1
- package/dist/constants/l10n/langs/ar.js +1 -1
- package/dist/constants/l10n/langs/de.js +1 -1
- package/dist/constants/l10n/langs/en.js +1 -1
- package/dist/constants/l10n/langs/es.js +1 -1
- package/dist/constants/l10n/langs/fr.js +1 -1
- package/dist/constants/l10n/langs/hi.js +1 -1
- package/dist/constants/l10n/langs/it.js +1 -1
- package/dist/constants/l10n/langs/ja.js +1 -1
- package/dist/constants/l10n/langs/ko.js +1 -1
- package/dist/constants/l10n/langs/pl.js +1 -1
- package/dist/constants/l10n/langs/pt-BR.js +1 -1
- package/dist/constants/l10n/langs/pt.js +1 -1
- package/dist/constants/l10n/langs/ru.js +1 -1
- package/dist/constants/l10n/langs/uk.js +1 -1
- package/dist/constants/l10n/langs/zh.js +1 -1
- package/dist/markdoc/tags/index.d.ts +6 -18
- package/dist/server/api-routes/run-api-routes-worker.js +1 -1
- package/dist/server/constants/entitlements.js +1 -1
- package/dist/server/entitlements/entitlements-provider.d.ts +4 -0
- package/dist/server/entitlements/entitlements-provider.js +1 -1
- package/dist/server/entitlements/plan-denied-markdoc-tags.d.ts +6 -0
- package/dist/server/entitlements/plan-denied-markdoc-tags.js +1 -0
- package/dist/server/fs/fast-mtime.js +3 -3
- package/dist/server/fs/fs.js +1 -1
- package/dist/server/plugins/api-docs/index.js +1 -1
- package/dist/server/plugins/api-docs/options.js +1 -1
- package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +9 -9
- package/dist/server/plugins/api-docs/spec-download.api.js +1 -1
- package/dist/server/plugins/config-parser/format-error.js +2 -2
- package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
- package/dist/server/plugins/markdown/compiler.d.ts +3 -3
- package/dist/server/plugins/markdown/compiler.js +1 -1
- package/dist/server/plugins/markdown/markdoc/markdoc-options.d.ts +2 -0
- package/dist/server/plugins/markdown/markdoc/markdoc-options.js +1 -1
- package/dist/server/plugins/mcp/custom-tools/scan-custom-tools.d.ts +4 -1
- package/dist/server/plugins/mcp/custom-tools/scan-custom-tools.js +1 -1
- package/dist/server/plugins/mcp/index.js +1 -1
- package/dist/server/plugins/mcp/types.d.ts +1 -0
- package/dist/server/plugins/pages/validators/validate-react-pages.d.ts +8 -1
- package/dist/server/plugins/pages/validators/validate-react-pages.js +1 -1
- package/dist/server/plugins/search/ai-indexer/prepare-semantic-documents.js +1 -1
- package/dist/server/plugins/search/llmstxt/create-llms-txt-generator.js +1 -1
- package/dist/server/plugins/search/llmstxt/index.js +4 -4
- package/dist/server/ssr/server-side-props/get-default-static-props.d.ts +1 -0
- package/dist/server/ssr/utils.js +11 -9
- package/dist/server/store.js +1 -1
- package/dist/server/types/plugins/common.d.ts +4 -0
- package/dist/server/types/web-server.d.ts +5 -0
- package/dist/server/utils/errors.d.ts +2 -1
- package/dist/server/utils/errors.js +1 -1
- package/dist/server/utils/llmstxt/resolve-llms-txt-md.d.ts +5 -0
- package/dist/server/utils/llmstxt/resolve-llms-txt-md.js +1 -1
- package/dist/server/web-server/auth.js +3 -3
- package/dist/server/web-server/routes/dynamic-route.js +1 -1
- package/dist/server/web-server/routes/error.js +1 -1
- package/dist/server/web-server/routes/index.js +1 -1
- package/dist/server/web-server/routes/page-data.d.ts +2 -1
- package/dist/server/web-server/routes/page-data.js +1 -1
- package/dist/server/web-server/utils.d.ts +1 -1
- package/dist/server/web-server/utils.js +1 -1
- package/dist/types/entitlements.d.ts +4 -0
- package/package.json +10 -10
- package/dist/server/utils/llmstxt/get-llms-txt-md-path-by-slug.d.ts +0 -19
- package/dist/server/utils/llmstxt/get-llms-txt-md-path-by-slug.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import C from"path";import{lintConfig as E,loadConfig as L,createConfigTypes as S}from"@redocly/openapi-core";import{findEmptyAgentSection as q,rbacConfigSchema as x,rootRedoclyConfigSchema as B,withPlatformSection as k}from"@redocly/config";import{deepMerge as I}from"../../../../../utils/object/deep-merge.js";import{isPlainObject as v}from"../../../../../utils/guards/is-plain-object.js";import{logger as d}from"../../../../tools/notifiers/logger.js";import{BRANCH_ENV_PREFIX as M}from"../../../../../constants/common.js";import{sanitizeBranchName as N}from"../../../../utils/envs/sanitize-branch-name.js";import{envConfig as A}from"../../../../config/env-config.js";import{ajv as _,safeParsePartial as D}from"../../safe-parse.js";import{formatConfigProblem as F}from"../../format-error.js";import{ExternalResolver as G}from"../../../../fs/utils/external-ref-resolver.js";import{resolveMutuallyExclusiveProps as z}from"../../resolve-mutual-exclusion.js";function y(e,s,t,n){s in e&&e[s]&&typeof e[s]=="string"&&(/^https?:\/\/.*/.test(e[s])||n(new Error(`Invalid ${t} URL: "${e[s]}". ${t} must start with "http://" or "https://".`)))}function V(e,s){if("access"in e&&e.access&&typeof e.access=="object"){const t=e.access;y(t,"logoutReturnUrl","access.logoutReturnUrl",s),y(t,"residency","access.residency",s);const n=["requiresLogin","logoutReturnUrl","residency","sso","rbac"];for(const r of n)r in t&&t[r]!==void 0&&r in e&&e[r]!==void 0&&s(new Error(`Property '${r}' is defined both at root level and in 'access' object. Please use 'access.${r}' to define this configuration.`))}}function Y(e){return _.compile(B.properties.graphql.properties.servers.items.properties.url)(e)}function $(e,s,t){if(v(e)&&Array.isArray(e.servers))for(const n of e.servers){const r=v(n)?n.url:void 0;if(typeof r=="string"&&!Y(r)){const a=e.servers.indexOf(n),c=`${s}.servers[${a}].url`;t(new Error(`Invalid ${c}: "${r}". It must be an absolute http:// or https:// URL.`))}}}function H(e,s){if($(e.graphql,"graphql",s),!!v(e.apis))for(const[t,n]of Object.entries(e.apis))v(n)&&$(n.graphql,`apis.${t}.graphql`,s)}function K(e,s){const t=[["",e],...Object.entries(e.env??{}).map(([n,r])=>[`env.${n}.`,r])];for(const[n,r]of t){const a=q(r);a&&s(new Error(`Invalid ${n}${a}.agent: it must set at least one option.`))}}async function he(e,s,t,n){const a=s.getFileInfo(e)?.realRelativePath||e;async function c(){const f=new G(s),m=C.join(s.cwd,a),l=await L({configPath:m,externalRefResolver:f}),h=await n(l.resolvedConfig);if(h===void 0)return l.resolvedConfig;const g=l.document?.source,j=[...g?await E({config:l,externalConfigTypes:S(h,l)}):[],...g?z(l.resolvedConfig,g):[]];for(const P of j){const R=F(P,s.cwd);P.severity==="warn"?d.warn(R):t(new Error(R))}return l.resolvedConfig}const o=s.exists(e)?await c():{},u=Z(o),w=await n(o);y(o,"residency","Residency",t),y(o,"logoutReturnUrl","Logout return URL",t),V(o,t),H(o,t),K(o,t);let p=w?D(w,o):o;p=X(p),p=Q(p,t);const{env:b}=p;if(b){const f=A.REDOCLY_ENV,m=b[f]||{},l=A.PUBLIC_REDOCLY_BRANCH_NAME||"",h=l?N(l):"",g=h&&b[`${M}${h}`]||{};p=I(p,g,m)}const i=ee(p,u);if(i.imports&&i.imports.length>0){d.warn("The 'imports' property is deprecated. Please use 'plugins' property instead.");const f=new Set([...i.plugins||[],...i.imports.map(m=>C.posix.join(m,"plugin.js"))]);i.plugins=Array.from(f),delete i.imports}if(i.catalog&&(d.warn("The 'catalog' property is deprecated. Please use 'catalogClassic' property instead."),i.catalogClassic={...i.catalog},delete i.catalog),i.scorecard&&(d.warn("The 'scorecard' property is deprecated. Please use 'scorecardClassic' property instead."),i.scorecardClassic=i.scorecard,delete i.scorecard),i.search?.ai){d.warn("The 'search.ai' property is deprecated. Please use 'aiAssistant' property instead.");const f={...i.search?.ai,...i.aiAssistant,suggestions:i.aiAssistant?.suggestions?.length?i.aiAssistant.suggestions:i.search?.ai.suggestions||[]};i.aiAssistant=f,delete i.search.ai}return W(i)}function W(e){const s={...e},n={..."access"in e&&e.access&&typeof e.access=="object"?e.access:{}},r=["requiresLogin","logoutReturnUrl","residency","sso","idps","rbac"],a=[];for(const c of r){const o=s[c];o!==void 0&&(a.push(c),c==="requiresLogin"&&n.requiresLogin===void 0&&(n.requiresLogin=o),c==="logoutReturnUrl"&&n.logoutReturnUrl===void 0&&(n.logoutReturnUrl=o),c==="residency"&&n.residency===void 0&&(n.residency=o),c==="sso"&&n.sso===void 0&&(n.sso=o),c==="idps"&&n.idps===void 0&&(n.idps=o),c==="rbac"&&n.rbac===void 0&&(n.rbac=o),delete s[c])}return a.length>0&&d.warn(`The following properties at root level are deprecated: ${a.join(", ")}. Please move them to the 'access' object.`),Object.keys(n).length>0&&(s.access=n),s}function X(e){const s=Object.entries(e.env??{});[e,...s.map(([,r])=>r)].some(r=>r?.mcp?.docs)&&d.warn("The 'mcp.docs' property is deprecated. Please use the 'mcp' properties instead.");const t=e.mcp?{...e,mcp:O(e.mcp)}:e;if(!e.env)return t;const n=s.map(([r,a])=>[r,a?.mcp?{...a,mcp:O(a.mcp)}:a]);return{...t,env:Object.fromEntries(n)}}function O(e){const s=e.docs??{},t={};(e.hide??s.hide)!==void 0&&(t.hide=e.hide===!0||s.hide===!0);const n=e.name??s.name;n!==void 0&&(t.name=n);const r=e.ignore??s.ignore;r!==void 0&&(t.ignore=r);const a=e.publicEndpoint??s.publicEndpoint;return a!==void 0&&(t.publicEndpoint=a),{...e,...t,docs:{...s,...t}}}function J(e){if(!v(e)||e.platform===void 0)return!1;const s=Object.keys(e).filter(t=>t!=="platform");return s.length>0&&s.every(t=>!Object.hasOwn(x.properties,t))}function Q(e,s){const t=Object.entries(e.env??{}),n=new Set;let r=!1;for(const o of[e,...t.map(([,u])=>u)])o?.reunite!==void 0&&o?.platform!==void 0&&n.add("Both 'platform' and 'reunite' are set. 'reunite' is ignored, so remove it."),[o?.rbac,o?.access?.rbac].some(J)&&(r=!0);for(const o of n)d.warn(o);r&&s(new Error("You are using an incorrect format of 'rbac:' configuration. See: https://redocly.com/docs/realm/access"));const a=T(e);if(!e.env)return a;const c=t.map(([o,u])=>[o,u&&T(u)]);return{...a,env:Object.fromEntries(c)}}function T(e){const s=k(e),t=e.rbac?{...s,rbac:U(e.rbac)}:s;return e.access?.rbac?{...t,access:{...e.access,rbac:U(e.access.rbac)}}:t}function U(e){const{reunite:s,...t}=e;return s===void 0?t:{...t,platform:e.platform??s}}function Z(e){if(!e.theme)return[];d.warn("The 'theme' property in redocly.yaml is deprecated. Please move all of the properties from 'theme' to the root of the config.");const s=[];for(const t of Object.keys(e.theme))e[t]==null?s.push(t):d.warn(`Detected both '${t}' and 'theme.${t}' properties in redocly.yaml. The 'theme.${t}' property will be ignored and needs to be removed or merged into the '${t}'.`);return s}function ee(e,s){if(!e.theme||s.length===0)return e;const t={...e};for(const n of s)t[n]=e.theme[n];return delete t.theme,t}export{W as ensureAccessBackwardsCompatibility,he as readAndValidateConfig};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config, Node, ValidationType } from '@redocly/markdoc';
|
|
2
2
|
import type { Store } from '../../store.js';
|
|
3
|
-
import type { LifecycleContext, MarkdownParseInput, MarkdocResolveContext } from '../../types';
|
|
3
|
+
import type { LifecycleContext, MarkdownParseInput, MarkdocOptions, MarkdocResolveContext } from '../../types';
|
|
4
4
|
import type { MarkdocError } from '../../../types/index.js';
|
|
5
5
|
export type ResolvableType = ValidationType & {
|
|
6
6
|
resolver?: string;
|
|
@@ -31,11 +31,11 @@ type MarkdocInfo = {
|
|
|
31
31
|
codeSnippetLanguages?: Record<string, number>;
|
|
32
32
|
codeWalkthroughLanguages?: Record<string, number>;
|
|
33
33
|
};
|
|
34
|
-
export declare function resolveAndValidateMarkdoc(parsedAstChunk: ParsedAstChunk, markdocOpts:
|
|
34
|
+
export declare function resolveAndValidateMarkdoc(parsedAstChunk: ParsedAstChunk, markdocOpts: MarkdocOptions | undefined, context: MarkdocResolveContext): Promise<MarkdocInfo>;
|
|
35
35
|
export declare function getAst(relativePath: string, rawContent: string): ParsedAstChunk;
|
|
36
36
|
export declare function extractMdFirstHeading(relativePath: string, context: LifecycleContext): Promise<string | undefined>;
|
|
37
37
|
export declare function validateAllMarkdowns(store: Store, context?: LifecycleContext): Promise<void>;
|
|
38
|
-
export declare function parseAndResolveMarkdoc(input: MarkdownParseInput, markdocOpts:
|
|
38
|
+
export declare function parseAndResolveMarkdoc(input: MarkdownParseInput, markdocOpts: MarkdocOptions | undefined, rootContext: MarkdocResolveContext, resource?: string): Promise<import("../../types").LoadResult<{
|
|
39
39
|
ast: Node;
|
|
40
40
|
info: MarkdocInfo;
|
|
41
41
|
}>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import A from"@redocly/markdoc";import{htmlTags as Y}from"@redocly/markdoc/html";import*as P from"path";import{convertGithubAlertToAdmonition as H}from"@redocly/theme/markdoc/tags/admonition";import{logger as M}from"../../tools/notifiers/logger.js";import{reporter as F}from"../../tools/notifiers/reporter.js";import{sha1 as B}from"../../utils/crypto/sha1.js";import{formatMarkdocError as $}from"./errors.js";import{extractFirstHeading as V,SKIP as G,visit as j}from"./markdoc/plugins/utils.js";import{isPromptNode as K}from"../../../markdoc/helpers/guards/is-prompt-node.js";import{attributeResolvers as L}from"./attribute-resolvers/index.js";import{MdResolveError as q}from"./attribute-resolvers/md-resolve-error.js";import{normalizeHtmlHeadings as C}from"./html/normalize-html-headings.js";import{resolveRawPartials as J}from"./markdoc/resolve-raw-partials.js";import{exampleContentTrees as Q,reparseExampleFences as X}from"./markdoc/reparse-example-fences.js";import{MARKDOC_PARTIALS_DEPS_KEY as Z}from"../../constants/common.js";import{getLinkOriginalAttrName as tt}from"./attribute-resolvers/utils.js";import{createSourceLinesReader as rt}from"./create-source-lines-reader.js";const et="EMPTY";async function at(r,e,o){const{actions:n}=o,{relativePath:s,resolveErrors:k}=r,h={...o,readSourceLines:rt(r.rawContent)},E=new Set,d=new Set,y=new Set,c=new Set,g={},f=new Set,D={},_={};function S(t,a){const u=a||et;t[u]=(t[u]||0)+1}const T=[];r.resolveErrors.length=0;const I=Q(r.ast),x=t=>{H(t);const a=u();T.push(a.then(p=>{p?.sharedDataIds&&p.sharedDataIds.forEach(m=>E.add(m))}).catch(W(t)));async function u(){const p=[];switch(t.type){case"fence":S(D,t.attributes.language);break;case"link":case"image":await L.nativeMdLink(t,t.type==="link"?"href":"src",s,h);break;case"tag":{if(!t.tag)break;const m=e?.tags?.[t.tag];if(!m){const i=e?.planDeniedTags?.[t.tag];i&&(t.addError({level:"error",id:"invalid-tag",message:i}),t.tag="",t.type="error",t.attributes={});break}const w=t.tag==="html"?t.attributes.name:t.tag;if((t.tag==="html"?f:c).add(w),g[w]=(g[w]||0)+1,w==="code-snippet"&&S(D,t.attributes.language),m.attributes?.__idx&&(t.attributes.__idx=g[t.tag]),m.dynamicComponentLib&&d.add(m.dynamicComponentLib),!m.attributes)break;if(w==="partial"&&t.attributes?.file){const i=tt("file"),l=t[i]||t.attributes.file,b=l.startsWith("/")?l.slice(1):P.posix.normalize(P.posix.join(P.posix.dirname(s),l));y.add(b);const v=(n.getGlobalConfig(Z)||{})[b];if(v?.dynamicComponents)for(const R of v.dynamicComponents)d.add(R);if(v?.sharedDataDeps)for(const R of v.sharedDataDeps)E.add(R)}for(const[i,l]of Object.entries(m.attributes)){const b=l.type;if(b&&(b.resolver||l.resolver)){const N=L[b.resolver||l.resolver],v=await N?.(t,i,s,h);v?.sharedDataId&&p.push(v.sharedDataId)}}if(w==="code-walkthrough")for(const i of t.attributes.resolvedFilesets||[])for(const l of i.files||[])S(_,l.language);const O=t.attributes?.attrs;if(O&&t.tag==="html")for(const i of Object.keys(O))i==="src"||i==="srcSet"?await L.htmlSourceAttribute(t,i,s,h):i==="href"&&await L.htmlHref(t,i,s,h);break}}return{sharedDataIds:p}}};function W(t){return async a=>{if(!(a instanceof q)){await F.panicOnBuild(a.message);return}k.push($({type:"resolve_link",meta:{...a.meta,link:a.meta.link??a.meta.rawLink},lines:t.location?[t.location.start.line,t.location.end.line]:[],location:t.location,error:{id:"",level:"error",message:a.message,location:t.location}},r.relativePath,r.rawContent))}}j(r.ast,t=>(x(t),K(t)?G:void 0));for(const t of I)j(t,a=>(H(a),a.type==="tag"&&x(a),K(a)?G:void 0));if(await Promise.all(T),r.sharedDataDeps=E,r.dynamicMarkdocComponents=d,r.validatedAtRevision<n.buildRevision){r.markdocErrors=[];for(const t of[r.ast,...I])for(const a of A.validate(t,e)){if(a.error.level!=="error"&&a.error.level!=="critical"){const u=a.location?.start.line,p=u===void 0?"":`:${u+1}`;M.warn(`${a.error.message} at ./${s}${p}`);continue}r.markdocErrors.push($(a,s,r.rawContent))}r.validatedAtRevision=n.buildRevision}return{sharedDataDeps:r.sharedDataDeps,dynamicMarkdocComponents:Array.from(r.dynamicMarkdocComponents?.values()??[]),partials:Array.from(y),tagList:Array.from(c),htmlTagsList:Array.from(f),tagOccurrence:g,codeSnippetLanguages:D,codeWalkthroughLanguages:_}}const U="unclosed-html",ot={html:Y({errorTag:U}),allowIndentation:!0,allowComments:!0};function z(r,e){const o=A.parse(r,{...ot,...e});return it(o),C(o),o}function it(r){for(const e of r.walk())e.type!=="tag"||e.tag!==U||(e.type="error",e.errors.push({id:"parse-error",level:"critical",message:String(e.attributes.message),location:e.location}))}function st(r,e){const o=z(e,{file:r,slots:!0});return X(o,s=>z(s,{file:r})),{ast:o,rawContent:e,resolveErrors:[],markdocErrors:[],relativePath:r,sharedDataDeps:void 0,validatedAtRevision:-1}}async function St(r,e){const{data:o}=await e.cache.load(r,"markdown-ast");return V(o.ast)}async function Rt(r,e){F.clearMarkdocProblems();const o=r.getAllRoutes();let n=0;const s=M.isInteractive();for(const k of o)await r.resolveRouteStaticData(k,e,!0),n++,s&&n%100===0&&M.logInFooter("validate",` \u{1F50D} Status: validating markdoc (${n}/${o.length})`)}async function Pt(r,e,o,n){const s=r.content?B(r.content):"";return await o.context.cache.load(n||r.relativePath,{loader:h,name:"markdown-inline-parser"},[s,String(o.actions.buildRevision)]);async function h(E,d,y){let c;if(r.content){const f=await d.getConfig(),D=await J(r.content,r.relativePath,f.markdown?.partialsFolders,d);c=st(r.relativePath,D)}else c=(await d.cache.load(r.relativePath,"markdown-ast")).data;let g={};if(o.actions.buildRevision!==0&&(g=await at(c,e,o)),!r.isVirtual){for(const f of c.markdocErrors)y(f);for(const f of c.resolveErrors)y(f)}return{ast:c.ast,info:g}}}export{St as extractMdFirstHeading,st as getAst,Pt as parseAndResolveMarkdoc,at as resolveAndValidateMarkdoc,Rt as validateAllMarkdowns};
|
|
@@ -50,5 +50,7 @@ export declare function getMarkdocOptions(serverOutDir?: string, _templateId?: s
|
|
|
50
50
|
}): string;
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
+
/** The tags only the project schema defines, under the names pages use them by. */
|
|
54
|
+
userTagNames: string[];
|
|
53
55
|
}>;
|
|
54
56
|
//# sourceMappingURL=markdoc-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import f from"@redocly/markdoc";import*as
|
|
1
|
+
import f from"@redocly/markdoc";import*as g from"@redocly/theme/markdoc/default";import{EntitlementsProvider as p}from"../../../entitlements/entitlements-provider.js";import{reporter as u}from"../../../tools/notifiers/reporter.js";import*as d from"../../../../markdoc/nodes/index.js";import l from"../../../../markdoc/tags/index.js";import{normalizeCustomTags as h}from"../../../../markdoc/helpers/normalize-custom-tags.js";import{includes as O}from"./functions/includes.js";import{importUserTags as T}from"./import-user-tags.js";import{concat as y}from"./functions/concat.js";const b=g.tags;function E(n){const{tags:m,functions:s={},...a}=n,i={...m,...a},c=Object.entries(i),o=[],r=[];for(const[t,e]of c)t in f.nodes?o.push([t,e]):r.push([t,e]);return{nodes:Object.fromEntries(o),tags:Object.fromEntries(r),functions:s}}async function S(n="../../../esbuild/cache/server/",m=""){let s;try{s=(await T(n)).schema}catch(e){throw e.code==="ERR_MODULE_NOT_FOUND"?(u.printErrors(),new Error("Please fix the errors above and try again.")):e}const{tags:a={},nodes:i={},functions:c={}}=E(s),o=h(a),r={tags:{schemaDefinition:{render:"SchemaDefinition",attributes:{schemaRef:{type:String},exampleRef:{type:String},showReadOnly:{type:Boolean},showWriteOnly:{type:Boolean}}}}},t={...l,...b};return{nodes:{...d,...i},tags:{...t,...p.instance().canUseCustomMarkdocTags()?o:{},...r.tags},functions:{...f.functions,...c,includes:O,concat:y},userTagNames:Object.keys(o).filter(e=>!(e in t))}}export{S as getMarkdocOptions};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { LifecycleContext, ProcessContentActions } from '../../../types';
|
|
2
2
|
import type { CustomMcpToolsState } from '../types.js';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Registers every file in an `@mcp` folder as one MCP tool, named after the file. Without custom
|
|
5
|
+
* MCP tools in the plan, each file is a warning and no tool.
|
|
6
|
+
*/
|
|
4
7
|
export declare function scanCustomMcpTools(actions: ProcessContentActions, context: LifecycleContext, state: CustomMcpToolsState): Promise<number>;
|
|
5
8
|
export declare function resetCustomMcpTools(actions: Pick<ProcessContentActions, 'removeMcpTools'>, state: CustomMcpToolsState): void;
|
|
6
9
|
//# sourceMappingURL=scan-custom-tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{basename as
|
|
1
|
+
import{basename as p,join as f}from"node:path";import{logger as d}from"../../../tools/notifiers/logger.js";import{reporter as i}from"../../../tools/notifiers/reporter.js";import{EntitlementsProvider as h}from"../../../entitlements/entitlements-provider.js";import{CODE_MODE_TOOL_NAMES as T}from"../codemode/constants.js";import{ALL_DEFAULT_TOOL_NAMES as M}from"../docs-mcp/tool-schemas.js";import{extractToolDefinition as O}from"./extract-tool-definition.js";const E=/(^|\/)@mcp\/.*\.(ts|js)$/,C=/^[a-zA-Z0-9_-]{1,64}$/,P=new Set([...T,...M]);async function b(t,r,n){_(t,n);const s=r.fs.scan(E).filter(e=>!e.isVirtual&&!e.relativePath.endsWith(".d.ts")).map(e=>e.relativePath);if(!h.instance().canUseCustomMcpTools()){for(const e of s)n.warnedPlanIgnoredFiles.has(e)||(n.warnedPlanIgnoredFiles.add(e),d.warn("Custom MCP tools are not in this project's plan, so %rp is ignored.",e));return 0}const u=new Set(t.getMcpTools().map(e=>e.name)),l=new Map;for(const e of s){const o=p(e).replace(/\.(ts|js)$/,"");if(!C.test(o)){await i.panicOnBuildContentError(`Invalid MCP tool file "${e}": the tool name "${o}" is derived from the file name and may only contain letters, numbers, hyphens, and underscores (max 64 characters). Rename the file.`);continue}const c=l.get(o);if(c){await i.panicOnBuildContentError(`Duplicate MCP tool name "${o}": defined by both "${c}" and "${e}". Tool names are file names, so each file name must be unique across @mcp folders.`);continue}if(P.has(o)||u.has(o)){await i.panicOnBuildContentError(`Invalid MCP tool file "${e}": the tool name "${o}" is already used by a built-in MCP tool. Rename the file.`);continue}l.set(o,e);const m=f(t.contentDir,e),a=await O({toolName:o,absoluteSourcePath:m,contentDir:t.contentDir,serverOutDir:t.serverOutDir});if(!a.ok){await i.panicOnBuildContentError(`Invalid MCP tool file "${e}": ${a.errors.join(" ")}`);continue}!a.schema.outputSchema&&!n.warnedNoOutputSchemaTools.has(o)&&(n.warnedNoOutputSchemaTools.add(o),d.warn(`MCP tool "${o}" in %rp declares no \`outputSchema\`. Add one that describes the returned value.`,e)),t.addMcpTools(m,[a.schema]),n.registeredToolNames.push(o)}return n.registeredToolNames.length}function _(t,r){t.removeMcpTools(r.registeredToolNames),r.registeredToolNames=[]}export{_ as resetCustomMcpTools,b as scanCustomMcpTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileURLToPath as U}from"node:url";import{dirname as
|
|
1
|
+
import{fileURLToPath as U}from"node:url";import{dirname as F,join as D}from"node:path";import{MCP_ROUTE as $,PUBLIC_MCP_ROUTE as M}from"@redocly/theme/core/constants/mcp";import{logger as p}from"../../tools/notifiers/logger.js";import{reporter as k}from"../../tools/notifiers/reporter.js";import{isDefined as B}from"../../../utils/guards/is-defined.js";import{MCP_CREDENTIALS_HANDLER_ID as P,MCP_CREDENTIALS_ROUTE as V,MCP_DOCS_SERVER_HANDLER_ID as T,MCP_NOT_ALLOWED_TEMPLATE_ID as x}from"../../constants/mcp.js";import{bundledOpenApiDocumentsToMcpOpenApi as J,bundledGraphqlDocumentsToMcpOpenApi as W,buildGraphqlDescriptions as X,collectIgnoredRoutes as z,filterIgnoredApiDescriptions as A,getCleanedUpApiDescriptions as K,isMcpInRedirects as Q}from"./utils.js";import{getMcpMode as R,isMcpElicitationEnabled as Y,isMcpGatewayEnabled as Z}from"./utils/mode.js";import{getPublicMcpEndpointStatus as S}from"./utils/public-endpoint.js";import{findGatedToolNames as ee}from"./utils/find-gated-tool-names.js";import{getDefaultToolSchemas as oe}from"./docs-mcp/tool-schemas.js";import{EXECUTE_TOOL_SCHEMA as te}from"./codemode/tools/execute-schema.js";import{isGatewayCapabilityEnabled as ie,isGatewayEligible as re}from"./gateway-mcp/eligibility.js";import{resolveGatewayFetchLimits as se}from"./gateway-mcp/rate-limit/fetch-limiter/fetch-limits.js";import{resetCustomMcpTools as ne,scanCustomMcpTools as ae}from"./custom-tools/scan-custom-tools.js";import{resolveSiteBranding as ce}from"./handlers/credentials-page/site-branding.js";import{telemetryTraceStep as pe}from"../../../cli/telemetry/helpers/trace-step.js";import{DEFAULT_DOCS_MCP_SERVER_NAME as _}from"./constants.js";const b=F(U(import.meta.url));async function de(){let i;const m={registeredToolNames:[],warnedNoOutputSchemaTools:new Set,warnedPlanIgnoredFiles:new Set};let u=0,f=!1;return{id:"mcp",async processContent(e,a){await pe("com.redocly.build.plugin.mcp",async s=>{const t=await a.getConfig(),{mcp:r,redirects:g}=t;if(s?.setAttribute("config",JSON.stringify(r||{})),s?.setAttribute("mcpMode",R()),s?.setAttribute("mcpGateway",String(Z())),r?.hide||r?.docs?.hide){ne(e,m);return}Q(g)&&await k.panicOnBuildContentError('The reserved route "/mcp" cannot be used in redirect configuration. Please remove any redirects involving "/mcp" from your redocly.yaml config.'),e.createTemplate(x,"@redocly/theme/layouts/McpNotAllowed");const l=!!t?.access?.requiresLogin,C=t?.access?.rbac||{},d=R(),c=Y(),{budgetPerExec:h}=se();if(!i){p.info("Configuring MCP servers...");const w=J(await e.loadApiDocuments(a)),O=W(await e.loadApiDocuments(a)),v=r?.docs?.ignore||[],L=K(A(w,v)),q=ie(r),E=new Map;for(const o of L){const H=o.definition.info?.title||"",j=o.definition.info?.version||"";E.set(o.relativePath,{name:H,description:typeof o.definition.info?.description=="string"?o.definition.info.description:"",version:j,servers:o.definition.servers||[],relativePath:o.relativePath,...q&&re(o.definition.info)?{fetchEligible:!0}:{}})}const y=X(A(O,v)),I=Object.values(t.products||{}).map(o=>o?.name).filter(B),G=t.l10n?.locales?.map(o=>o.code)??a.fs.localeFolders,N=oe({products:I,locales:G,requiresLogin:l,rbac:C,hasGraphqlApis:y.length>0,elicitationEnabled:c,hasCallableApis:E.values().some(o=>o.fetchEligible),feedbackHidden:t.feedback?.hide===!0});e.addMcpTools(D(b,"./docs-mcp/tools/index.js"),N),d==="code"&&e.addMcpTools(D(b,"./codemode/tools/execute.js"),[te]),i={apiDescriptionsMap:Object.fromEntries(E),graphqlDescriptions:y}}const n=await ae(e,a,m);s?.setAttribute("customToolsCount",String(n)),n!==u&&(u=n,n>0&&p.info(`Registered ${n} custom MCP tool${n===1?"":"s"} from @mcp folders`)),await le({actions:e,handlerPath:D(b,"./handlers/docs-mcp-handler.js"),apiDescriptionsMap:i.apiDescriptionsMap,graphqlDescriptions:i.graphqlDescriptions,mcpConfig:r,mcpMode:d,elicitationEnabled:c,gatewayFetchBudgetPerExec:h,publicEndpointStatus:S(t)}),f||(p.info("Registered Docs MCP Server endpoint at /mcp"),f=!0)})},async afterRoutesCreated(e,a){const s=await a.getConfig(),{mcp:t}=s,r=!t?.hide&&!t?.docs?.hide;e.markGatedMcpTools(await ee(e.getMcpTools())),e.setGlobalData({mcpData:{docs:{enabled:r,name:t?.docs?.name||_,publicEndpoint:S(s)==="served"}}})}}}var Oe=de;async function le({actions:i,handlerPath:m,apiDescriptionsMap:u,graphqlDescriptions:f,mcpConfig:e,mcpMode:a,elicitationEnabled:s,gatewayFetchBudgetPerExec:t,publicEndpointStatus:r}){i.createRequestHandler(T,m);const g=l=>async(C,d)=>{const c=z(d.getAllRoutes(),e?.docs?.ignore||[]);return c.length>0&&p.verbose(`mcp.docs.ignore: hiding ${c.length} page routes from MCP search`),{props:{config:{apiDescriptionsMap:u,graphqlDescriptions:f,mcpDocsServerName:e?.docs?.name||_,mcpMode:a,elicitationEnabled:s,gatewayFetchBudgetPerExec:t,searchIgnoredRoutes:c,...l?{isPublicEndpoint:l}:{}},serverOutDir:i.serverOutDir,tools:i.getMcpTools().map(({importPath:h,...n})=>n)}}};if(i.addApiRoute({slug:$,requestHandlerId:T,httpMethod:"all",getStaticData:g(!1)}),r==="no-protected-content"?p.info(`mcp.docs.publicEndpoint is enabled, but the project has no protected content - /mcp already serves anonymous users, skipping ${M}.`):r==="anonymous-denied"?p.info(`mcp.docs.publicEndpoint is enabled, but anonymous users are denied the MCP feature (rbac.features.mcp or requiresLogin) - skipping ${M}.`):r==="served"&&(i.addApiRoute({slug:M,requestHandlerId:T,httpMethod:"all",getStaticData:g(!0)}),p.verbose(`Registered public Docs MCP Server endpoint at ${M}`)),s){const l=D(b,"./handlers/mcp-credentials-handler.js");i.createRequestHandler(P,l),i.addApiRoute({slug:V,requestHandlerId:P,httpMethod:"all",getStaticData:async(C,d)=>{const{seo:c,colorMode:h}=d.getConfig(),{logo:n}=d.getGlobalData();return{props:{branding:ce({seo:c,logo:n,colorMode:h})}}}}),p.verbose("Registered MCP credentials endpoint at /mcp/credentials")}}export{Oe as default,de as mcpServerPlugin};
|
|
@@ -143,6 +143,7 @@ export type McpToolWorkerParams = Omit<McpToolExecutionParams, 'context'> & {
|
|
|
143
143
|
export type CustomMcpToolsState = {
|
|
144
144
|
registeredToolNames: string[];
|
|
145
145
|
warnedNoOutputSchemaTools: Set<string>;
|
|
146
|
+
warnedPlanIgnoredFiles: Set<string>;
|
|
146
147
|
};
|
|
147
148
|
export type ToolDefinitionValidationResult = {
|
|
148
149
|
ok: true;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { Store } from '../../../store.js';
|
|
2
2
|
import type { LifecycleContext } from '../../../types';
|
|
3
|
-
|
|
3
|
+
import type { renderPage as renderPageFn } from '../../../ssr/index.js';
|
|
4
|
+
type RenderPage = typeof renderPageFn;
|
|
5
|
+
/**
|
|
6
|
+
* `renderPage` defaults to the one from the built server bundle, which preview does not have.
|
|
7
|
+
* When `isOutdated` returns true the store has changed under the run: it stops and reports nothing.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateReactPages(store: Store, lifecycleContext: LifecycleContext, renderPage?: RenderPage, isOutdated?: () => boolean): Promise<void>;
|
|
10
|
+
export {};
|
|
4
11
|
//# sourceMappingURL=validate-react-pages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pathToFileURL as
|
|
1
|
+
import{pathToFileURL as d}from"node:url";import{slash as P}from"../../../../utils/path/slash.js";import{logger as s}from"../../../tools/notifiers/logger.js";import{reporter as n}from"../../../tools/notifiers/reporter.js";import{getServerProps as h}from"../../../ssr/server-side-props/get-server-props.js";import{isVirtualFile as R}from"../../../fs/utils/isVirtualFile.js";import{telemetry as E}from"../../../../cli/telemetry/index.js";const w=["PageMissingDefaultExportError","PageAsyncComponentError"];async function A(r,i,o,l){try{const a=r.getAllRoutes().filter(e=>e.fsPath.match(/\.page\.tsx?$/)&&!R(e.fsPath,i.fs));if(!a.length){n.clearPageRenderProblems();return}const m=s.startTiming();s.info("Validating react pages");const u=o??await b(r.serverOutDir),c=[];for(const e of a){const f=await r.resolveRouteStaticData(e,i),p=await h(e,null,f,r);let t;try{t=(await u(e,p,null,r,E,!0)).error}catch(g){t=g}if(l?.())return;t&&c.push({message:w.includes(t.name)?t.message:`Runtime error: ${t.message}`,sourceFileRelativePath:e.fsPath})}n.clearPageRenderProblems(),c.forEach(e=>n.reportPageRenderError(e)),s.infoTime(m,`Validated ${a.length} React pages`)}catch(a){if(l?.())return;await n.panicOnBuild(`Failed to validate react pages: ${a.message}`)}}async function b(r){const o=await import(d(`${P(r)}/index.mjs`)+"?only-exports=true");if(!o.renderPage)throw new Error("renderPage function not found in bundle");return o.renderPage}export{A as validateReactPages};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
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
|
|
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
|
|
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){
|
|
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:
|
|
12
|
-
`)}),t.join("")}function M({title:e,description:i,slug:n,siteUrl:r}){const l=`${
|
|
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};
|
|
@@ -5,6 +5,7 @@ export declare function getDefaultStaticProps({ staticData, variables, }: {
|
|
|
5
5
|
}): {
|
|
6
6
|
metadata?: Record<string, unknown>;
|
|
7
7
|
seo?: import("@redocly/config").SeoConfig;
|
|
8
|
+
markdownUrl?: string;
|
|
8
9
|
sharedDataIds?: Record<string, string>;
|
|
9
10
|
frontmatter?: Omit<import("@redocly/config").PageProps, 'frontmatter'> & {
|
|
10
11
|
settings?: any;
|
package/dist/server/ssr/utils.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import{pathToFileURL as u}from"url";import{removeTrailingSlash as p}from"../../utils/url/remove-trailing-slash.js";import{slash as f}from"../../utils/path/slash.js";import{getClientPageDataUrl as h}from"../../utils/url/get-client-page-data-url.js";import{getSharedDataFetchUrl as g}from"../../utils/url/get-shared-data-fetch-url.js";import{DEFAULT_COLOR_MODES as l}from"@redocly/theme/core/constants";import{envConfig as m}from"../config/env-config.js";function q(t){const o=t?.colorMode,{modes:e=[l.LIGHT,l.DARK],hide:r,ignoreDetection:
|
|
1
|
+
import{pathToFileURL as u}from"url";import{removeTrailingSlash as p}from"../../utils/url/remove-trailing-slash.js";import{slash as f}from"../../utils/path/slash.js";import{getClientPageDataUrl as h}from"../../utils/url/get-client-page-data-url.js";import{getSharedDataFetchUrl as g}from"../../utils/url/get-shared-data-fetch-url.js";import{DEFAULT_COLOR_MODES as l}from"@redocly/theme/core/constants";import{envConfig as m}from"../config/env-config.js";function q(t){const o=t?.colorMode,{modes:e=[l.LIGHT,l.DARK],hide:r,ignoreDetection:n}=o||{},a=e&&`'${e[0]}'`,s=e?.[0],d=e?.some(i=>i===s)?`'${s}'`:void 0;return r||!a?"":`
|
|
2
2
|
<script>
|
|
3
3
|
if(window&&document.documentElement)
|
|
4
4
|
{
|
|
5
5
|
const q=new URLSearchParams(window.location.search).get("colorSchema");
|
|
6
|
-
|
|
6
|
+
let s;
|
|
7
|
+
try { s=window.localStorage.getItem("colorSchema"); } catch(_) {}
|
|
8
|
+
const e=q || s;
|
|
7
9
|
if(e) {
|
|
8
|
-
const modeToSet = [${e.map(
|
|
9
|
-
${
|
|
10
|
+
const modeToSet = [${e.map(i=>`'${i}'`)}].some((mode) => mode === e) ? e : 'light';
|
|
11
|
+
${c("modeToSet",e)}
|
|
10
12
|
} else {
|
|
11
13
|
if (window.matchMedia) {
|
|
12
|
-
${S(
|
|
14
|
+
${S(n,d,a,e)}
|
|
13
15
|
} else {
|
|
14
|
-
${
|
|
16
|
+
${c(a,e)}
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
|
-
</script>`}function S(t,o,e,r=["light","dark"]){return t?o?
|
|
20
|
+
</script>`}function S(t,o,e,r=["light","dark"]){return t?o?c(o,r):e?c(e,r):"return":$(o,r)}function c(t=`'${l.LIGHT}'`,o=["light","dark"]){return`(function() {
|
|
19
21
|
var root = document.documentElement;
|
|
20
22
|
var modes = [${o.map(r=>`'${r}'`).join(", ")}];
|
|
21
23
|
var value = ${t};
|
|
@@ -23,7 +25,7 @@ import{pathToFileURL as u}from"url";import{removeTrailingSlash as p}from"../../u
|
|
|
23
25
|
root.classList.remove(className);
|
|
24
26
|
});
|
|
25
27
|
root.classList.add(value);
|
|
26
|
-
})();`}function $(t,o=["light","dark"]){const e=o.map(
|
|
28
|
+
})();`}function $(t,o=["light","dark"]){const e=o.map(n=>`'${n}'`).join(", "),r=t?`root.classList.add(${t});`:"";return`(function() {
|
|
27
29
|
var root = document.documentElement;
|
|
28
30
|
var modes = [${e}];
|
|
29
31
|
modes.forEach(function(className) {
|
|
@@ -36,4 +38,4 @@ import{pathToFileURL as u}from"url";import{removeTrailingSlash as p}from"../../u
|
|
|
36
38
|
}${r?` else {
|
|
37
39
|
${r}
|
|
38
40
|
}`:""}
|
|
39
|
-
})();`}async function T(t){try{return m.isRuntimeMode?await import("@portal/server-props"):await import(u(`${f(t)}/server-props-entry.js`)+"?"+new Date)}catch{return{}}}function
|
|
41
|
+
})();`}async function T(t){try{return m.isRuntimeMode?await import("@portal/server-props"):await import(u(`${f(t)}/server-props-entry.js`)+"?"+new Date)}catch{return{}}}function y(t){const o=t.split("/").map(encodeURIComponent).join("/"),e=o==="/"?o:p(o);return`<link rel="preload" as="fetch" crossorigin="anonymous" href="${h(e)}" />`}function j(t={}){const o=new Set;for(const e of Object.values(t))e&&o.add(g(e,m.isDevelopMode));return[...o].map(e=>`<link rel="preload" as="fetch" crossorigin="anonymous" href="${w(e)}" />`)}function w(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}const x=(t,o)=>{if(!o)return{params:[],queries:{}};const e=t.slug||"",n=o.req.path.split(e.endsWith("/")?e:`${e}/`)[1]||"",a=o.req.query(),s=n.replace("data.json","");return!s||s==="/"?{params:[],queries:a}:{params:s.split("/").filter(Boolean),queries:a}};export{q as detectColorSchemaScript,y as generatePreloadPageData,j as generatePreloadSharedData,x as getPathParams,T as importServerProps};
|
package/dist/server/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import k from"@redocly/markdoc";import{writeFileSync as D}from"node:fs";import{readFile as R}from"node:fs/promises";import{join as g}from"node:path";import{parseAndResolveMarkdoc as F}from"./plugins/markdown/compiler.js";import{getPathnameForLocale as L}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as m}from"../constants/common.js";import{DEFAULT_TITLE as H,MARKDOC_PARTIALS_DATA_KEY as y,MARKDOC_PARTIALS_DEPS_KEY as G}from"./constants/common.js";import{GATED_MARKDOC_TAGS as S}from"./constants/entitlements.js";import{isObject as _}from"../utils/guards/is-object.js";import{mapObject as N}from"../utils/object/map-object.js";import{getValueDeep as v}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as B}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as d}from"../utils/path/normalize-route-slug.js";import{isLocalLink as E}from"../utils/path/is-local-link.js";import{reporter as C}from"./tools/notifiers/reporter.js";import{logger as u}from"./tools/notifiers/logger.js";import{sha1 as I}from"./utils/crypto/sha1.js";import{FileNotFoundError as j}from"./utils/fs.js";import{resolveAssetPath as V}from"./utils/resolve-asset-path.js";import{envConfig as q,setEnv as J}from"./config/env-config.js";import{KvService as U}from"./persistence/kv/services/kv-service.js";import{SandboxContext as x}from"./utils/sandbox-context.js";import{isAllowedEnv as K}from"./utils/envs/get-api-route-allowed-env-variables.js";import{ensureDir as $,writeSharedData as W}from"./utils/index.js";import{renderComponents as z}from"./ssr/render.js";import{readStaticData as Y,writeStaticData as Z}from"./utils/static-data.js";import{getMarkdocOptions as Q}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as P}from"./entitlements/entitlements-provider.js";import{isRouteReserved as X}from"./plugins/get-reserved-routes.js";import{isL10nPath as ee}from"./fs/utils/is-l10n-path.js";import{resolveGlobMapValue as te}from"./utils/globs.js";import{createDefaultStoreConfig as se,resolveConfigEntries as re,resolveStoreConfig as oe}from"./store-config.js";import{findRedirect as ae}from"./utils/redirects/find-redirect.js";import{followRedirectChain as ie}from"./utils/redirects/follow-redirect-chain.js";import{addWildcardRedirectToTree as ne}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as ce}from"../cli/telemetry/helpers/trace-step.js";const A={routesBySlug:"map",staticFilePaths:"object",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",ssr:"object",searchFacets:"map",routesPartials:"map",mcpToolHandlers:"map",skills:"map",devLogin:"object"},b="store.json",O="store-config.json",T="PLAN_GATES",le=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORGANIZATION_SLUG","ORGANIZATION_ID","ORG_ID"],We="userDefinedApiFunctions";class w{routesBySlug=new Map;routeAliases=new Map;staticFilePaths={};replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#t={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;routesPartials=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;mcpToolHandlers=new Map;skills=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};devLogin=!1;#a=void 0;config=se();configFile;#i;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#n;userCodeReady;#s=Promise.resolve();#c;#l=Promise.resolve();#d;#h=Promise.resolve();#u;#e=!1;#r=0;#f=0;#o=new Map;constructor({outdir:e,contentDir:t,serverMode:s=!1,serverOutDir:r}){this.#i=t,this.outdir=e,this.serverMode=s,this.serverOutDir=r,x.register({serverOutDir:r,readRoots:[e,process.cwd()]}),this.userCodeReady=new Promise(o=>{this.#n=o})}on(e,t){const s=this.listeners.get(e);s?s.add(t):this.listeners.set(e,new Set([t]))}queueEvent=(e,t,...s)=>{this.#o.set(e+String(t),[e,t,...s])};runListeners=(e,t,...s)=>{for(const r of this.listeners.get(e)||new Set)t?r(t,...s):r(...s)};startPluginsRun(){this.clear(),this.#s=new Promise(e=>{this.#c=e})}waitForPluginsLifecycle(){return Promise.all([this.#s,this.#l,this.#h])}waitForPluginsRun(){return this.#s}finishPluginsRun(){this.#c?.();for(const e of this.#o.values())this.runListeners(...e);this.#o.clear()}startEsbuildRun(){this.#l=new Promise(e=>{this.#d=e})}finishEsbuildRun(){this.#d?.()}markRequestHandlersEntryOutdated(){this.#r++,!this.#e&&(this.#e=!0,this.#h=new Promise(e=>{this.#u=e}))}noteRequestHandlersEntryBuildStart(){this.#f=this.#r}markRequestHandlersEntryUpdated(){this.#e&&(this.#r>this.#f||(this.#e=!1,this.#u?.()))}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#i}markUserCodeReady(){this.#n?.(!0)}async reloadMarkdocOptions(){await ce("com.redocly.build.reloadMarkdocOptions",async()=>{const e=P.instance(),t=await Q(this.serverOutDir),s=Object.fromEntries(Object.entries(t.tags).filter(([r])=>S[r]!=null?e.canAccessFeature(S[r]):!0));this.#a={...t,tags:s}})}get markdocOptions(){return{...this.#a,partials:this.getGlobalConfig(y),themeConfig:this.config.markdown}}setGlobalData=e=>{const t=this.globalData,s={...this.globalData,...e};this.globalData=s,JSON.stringify(s)!==JSON.stringify(t)&&this.queueEvent("global-data-updated",void 0,s)};getGlobalData=()=>this.globalData;getKv=async()=>U.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async({input:e,context:t,deps:s,resource:r})=>{const{data:{info:o,ast:a},compoundHash:c}=await F(e,this.markdocOptions,{actions:this,context:t},r);for(const i of o.sharedDataDeps||[]){for(const n of s?.routeSlugs||[])this.addRouteSharedData(n,i,i);for(const n of s?.sharedDataIds||[]){const l=this.sharedDataDeps.get(n)||new Set;l.add(i),this.sharedDataDeps.set(n,l)}}for(const i of o.dynamicMarkdocComponents||[]){for(const n of s?.routeSlugs||[]){const l=this.routesDynamicComponents.get(n)||new Set;l.add(i),this.routesDynamicComponents.set(n,l)}for(const n of s?.sharedDataIds||[]){const l=this.sharedDataMarkdocComponents.get(n)||new Set;l.add(i),this.sharedDataMarkdocComponents.set(n,l)}}if(s?.routeSlugs&&o.partials?.length)for(const i of s.routeSlugs){const n=this.routesPartials.get(i)||[];for(const l of o.partials)n.includes(l)||n.push(l);this.routesPartials.set(i,n)}return{info:o,ast:a,compoundHash:c}};async loadApiDocuments(e){return(await e.cache.load(".","api-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setStaticFilePaths=e=>{this.staticFilePaths=e};setGlobalConfig=e=>{const t=Object.keys(e);for(const a of t)for(const c in this.replacedEnvVars)if(c===a||c.startsWith(`${a}:`)){const i=c.split(":"),{error:n,value:l}=v(e,i);(n||l!==this.replacedEnvVars[c].replaced)&&delete this.replacedEnvVars[c]}const{config:s,unsetEnvVars:r,replacedValues:o}=re(e);for(const a of r)this.unsetEnvVars.add(a);Object.assign(this.replacedEnvVars,o),Object.assign(this.config,s)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,t,s={})=>{if(!P.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const a=d(e).toLowerCase();this.config.redirects[a]=t;const{trackOriginalSource:c=!0}=s,i=this.getGlobalConfig("originalRedirectSources");c&&Array.isArray(i)&&!i.includes(a)&&i.push(a),a.endsWith("*")&&ne(this.config.wildcardRedirectsTree,a)};getRedirect=e=>{const t=d(e).toLowerCase(),s=ae(t,this.config.redirects,this.config.wildcardRedirectsTree,this.staticFilePaths);if(!s)return null;if(E(s.to)){const r=d(s.to).toLowerCase();if(!r.endsWith("*")&&ie(r,[t],this.config.redirects,this.config.wildcardRedirectsTree).type==="cycle")return null}return{to:s.to,type:s.type}};createSharedData=async(e,t,s)=>{if(s&&this.#t[e]===s)return e;const r=JSON.stringify(t),o=s??I(r);return this.#t[e]===o||(this.#t[e]=o,await W(e,r,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,t,s)=>{const r=B(e),o=this.routesSharedData.get(r)||{};o[t]=s,this.routesSharedData.set(r,o),u.verbose(`Adding shared data to ${e}, ${t}, ${s}`)};getRouteSharedDataByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.routesSharedData.get(t)||{}:{}};getPartialsForRoute=e=>{const t=this.getGlobalConfig(y)||{},s=this.routesPartials.get(e);if(!s||s.length===0)return{};const r=this.getGlobalConfig(G)||{},o=new Set(s),a=Array.from(s);for(let i=0;i<a.length;i++){const n=a[i],l=r[n]?.partials??[];for(const h of l)o.has(h)||(o.add(h),a.push(h))}const c={};for(const i of o)t[i]&&(c[i]=t[i]);return c};addRoute=e=>{const s={...te(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:s}),u.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,t,s)=>{const r=[m,...this.lifecycleContext?.fs.localeFolders||[]].map(o=>({code:o,name:o}));for(const o of r){const a=L(e,m,o.code,r);this.addRouteSharedData(a,t,s)}};addApiRoute=e=>{this.apiRoutes.push(e),u.verbose("Created API route %s",e.slug)};addMcpTools=(e,t)=>{for(const s of t){const r=this.mcpToolHandlers.get(s.name);r&&r.importPath!==e&&u.warn('MCP tool "%s" from %s overwrites the tool registered from %s',s.name,e,r.importPath);const o=s.hasAvailabilityGate??(r?.importPath===e?r.hasAvailabilityGate:void 0);this.mcpToolHandlers.set(s.name,{...s,importPath:e,hasAvailabilityGate:o}),u.verbose("Created MCP tool %s",s.name)}};getMcpTools=()=>Array.from(this.mcpToolHandlers.values());markGatedMcpTools=e=>{for(const t of e){const s=this.mcpToolHandlers.get(t);s&&this.mcpToolHandlers.set(t,{...s,hasAvailabilityGate:!0})}};addSkills=e=>{for(const t of e)this.skills.set(t.slug,t),u.verbose("Discovered skill %s",t.slug)};getSkills=()=>Array.from(this.skills.values());removeMcpTools=e=>{for(const t of e)this.mcpToolHandlers.delete(t)};addMiddleware=e=>{this.middleware.push(e),u.verbose("Created middleware %s",e.id)};setResourceResponseHeaders=(e,t)=>{this.config.responseHeaders||(this.config.responseHeaders={});const s=new Set(t.map(a=>a.name.toLowerCase())),o=[...(this.config.responseHeaders[e]??[]).filter(a=>!s.has(a.name.toLowerCase())),...t];this.config.responseHeaders[e]=o};getRouteByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.getRouteBySlug(t):void 0};getRouteBySlug=(e,t={})=>{const{followRedirect:s=!0}=t,r=this.getRedirect(e);if(s&&r)return this.routesBySlug.get(d(r.to));const o=s?this.routeAliases.get(d(e).toLowerCase()):void 0;return this.routesBySlug.get(o??e)};addRouteAlias=(e,t)=>{this.routeAliases.set(d(e).toLowerCase(),d(t))};hasRouteOrRedirectBySlug=e=>{if(this.routesBySlug.has(e)||this.routeAliases.has(d(e).toLowerCase())||X(e,this.getConfig()))return!0;const t=this.getRedirect(e);if(!t)return!1;if(!E(t.to))return!0;const s=d(t.to);return this.routesBySlug.has(s)};getRoutesByTemplateId=e=>this.newRoutes.filter(t=>t.templateId===e);getAllRoutesForLocale=(e=m)=>{const t=Array.from(this.routesBySlug.values()),s=e.toLowerCase();return t.filter(r=>e===m?!ee(r.fsPath):r.slug.startsWith(`/${s}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,t)=>(this.templates.set(e,t),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};copyAsset=async(e,t)=>{const s=this.lifecycleContext?.fs;if(!s)throw new Error(`Cannot copy asset ${e}: the content file system is not ready`);try{const r=await V(e,s,{fromFileRelativePath:t,contentDir:this.contentDir,outdir:this.outdir});if(!r)throw new Error(`Cannot copy asset ${e}`);return r}catch(r){if(r instanceof j)return null;throw r}};createRequestHandler=(e,t)=>(this.apiRoutesRequestHandlers.set(e,t),e);clearRequestHandlersByPrefix=e=>{for(const t of this.apiRoutesRequestHandlers.keys())t.startsWith(e)&&this.apiRoutesRequestHandlers.delete(t)};registerServerPropsGetter=(e,t)=>(this.serverPropsGetters.set(e,t),e);registerPagePropsGetter=(e,t)=>{this.pagePropsGetters.set(e,t)};async writeRouteStaticData(e,t){const s=await this.resolveRouteStaticData(e,t,!1);s&&Z(e.slug,s,this.outdir)}async resolveRouteStaticData(e,t,s){if(this.serverMode)return Y(e.slug,this.outdir);const r={...this,contentDir:this.contentDir,parseMarkdoc:({input:l,context:h,resource:f})=>this.parseMarkdoc({input:l,context:h,deps:{routeSlugs:[e.slug]},resource:f})},o=await e.getStaticData?.(e,r)||{},a=new Set(this.routesDynamicComponents.get(e.slug)),c=this.routesSharedData.get(e.slug)||{};for(const l of Object.values(c)){const h=this.sharedDataMarkdocComponents.get(l);h&&h.forEach(p=>a.add(p));const f=this.sharedDataDeps.get(l);f&&f.forEach(p=>this.addRouteSharedData(e.slug,p,p))}const i=this.getGlobalConfig("seo"),n=o?.frontmatter||{};return{...o,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await e.getNavText?.()}},props:{...o.props,dynamicMarkdocComponents:Array.from(a),metadata:{...o?.props?.metadata,...e.metadata},seo:{title:H,...i,...o.props?.seo,siteUrl:i?.siteUrl},compilationErrors:this.compilationErrors},lastModified:s||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,t){if(!e?.length)return;const s=typeof e[0]=="string"?e.join(""):z(e);s&&(t==="head"?this.ssr.headTags.push(s):t==="preBody"?this.ssr.preBodyTags.push(s):this.ssr.postBodyTags.push(s))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.routeAliases.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.skills.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};#p(){const e=[];for(const[s,r]of Object.entries(A))switch(r){case"map":{const o=Array.from(this[s].entries());e.push([s,o]);break}case"object":e.push([s,this[s]]);break;default:throw new Error("Invalid format")}const t=Object.fromEntries(e);return t[T]=q.PLAN_GATES,t}static#g(e,t){const s=new w(t);for(const[o,a]of Object.entries(A))switch(a){case"map":s[o]=new Map(e[o]);break;case"object":s[o]=e[o];break;default:throw new Error("Invalid format")}const r=e[T];return r&&J("PLAN_GATES",r),s}async writeServerFiles(){$(this.serverOutDir),D(g(this.serverOutDir,b),JSON.stringify(this.#p())),D(g(this.serverOutDir,O),JSON.stringify(await this.getConfigWithEnvPlaceholders()))}static async fromServerFiles(e){const t=g(e.serverOutDir,O),{config:s,env:r}=oe(JSON.parse(await R(t,"utf8")));s[y]=de(s[y]);const o=JSON.parse(await R(g(e.serverOutDir,b),"utf8")),a=w.#g(o,e);a.config=s;const c=Object.fromEntries(Object.entries(r).filter(([i])=>K(i)));return a.configFile={path:t,env:c,config:{...s}},a}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const t in this.replacedEnvVars){const{original:s}=this.replacedEnvVars[t],r=t.split(":"),o=r.pop(),{error:a,value:c}=v(e,r);if(a||!_(c)&&!Array.isArray(c)){await C.panicOnBuild(`Failed to replace env var with env name for ${t}`);continue}c[o]=s}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(s=>!le.includes(s));if(e.length===0)return;const t=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await C.panicOnBuildContentError(t)}}function de(M){return N(M,e=>k.Ast.fromJSON(JSON.stringify(e)))}export{w as Store,We as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
|
|
1
|
+
import T from"@redocly/markdoc";import{writeFileSync as w}from"node:fs";import{readFile as R}from"node:fs/promises";import{join as g}from"node:path";import{parseAndResolveMarkdoc as M}from"./plugins/markdown/compiler.js";import{getPathnameForLocale as k}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as m}from"../constants/common.js";import{DEFAULT_TITLE as F,MARKDOC_PARTIALS_DATA_KEY as y,MARKDOC_PARTIALS_DEPS_KEY as L}from"./constants/common.js";import{isObject as H}from"../utils/guards/is-object.js";import{mapObject as N}from"../utils/object/map-object.js";import{getValueDeep as S}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as G}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as d}from"../utils/path/normalize-route-slug.js";import{isLocalLink as v}from"../utils/path/is-local-link.js";import{reporter as E}from"./tools/notifiers/reporter.js";import{logger as u}from"./tools/notifiers/logger.js";import{sha1 as _}from"./utils/crypto/sha1.js";import{FileNotFoundError as B}from"./utils/fs.js";import{resolveAssetPath as I}from"./utils/resolve-asset-path.js";import{envConfig as j,setEnv as V}from"./config/env-config.js";import{KvService as q}from"./persistence/kv/services/kv-service.js";import{SandboxContext as J}from"./utils/sandbox-context.js";import{isAllowedEnv as U}from"./utils/envs/get-api-route-allowed-env-variables.js";import{ensureDir as x,writeSharedData as K}from"./utils/index.js";import{renderComponents as $}from"./ssr/render.js";import{readStaticData as W,writeStaticData as z}from"./utils/static-data.js";import{getMarkdocOptions as Y}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as Z}from"./entitlements/entitlements-provider.js";import{getPlanDeniedMarkdocTags as Q}from"./entitlements/plan-denied-markdoc-tags.js";import{isRouteReserved as X}from"./plugins/get-reserved-routes.js";import{isL10nPath as ee}from"./fs/utils/is-l10n-path.js";import{resolveGlobMapValue as te}from"./utils/globs.js";import{createDefaultStoreConfig as se,resolveConfigEntries as re,resolveStoreConfig as oe}from"./store-config.js";import{findRedirect as ae}from"./utils/redirects/find-redirect.js";import{followRedirectChain as ie}from"./utils/redirects/follow-redirect-chain.js";import{addWildcardRedirectToTree as ne}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as le}from"../cli/telemetry/helpers/trace-step.js";const P={routesBySlug:"map",staticFilePaths:"object",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",ssr:"object",searchFacets:"map",routesPartials:"map",mcpToolHandlers:"map",skills:"map",devLogin:"object"},C="store.json",A="store-config.json",b="PLAN_GATES",ce=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORGANIZATION_SLUG","ORGANIZATION_ID","ORG_ID"],We="userDefinedApiFunctions";class D{routesBySlug=new Map;routeAliases=new Map;staticFilePaths={};replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#t={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;routesPartials=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;mcpToolHandlers=new Map;skills=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};devLogin=!1;#a=void 0;#i={};config=se();configFile;#n;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#l;userCodeReady;#s=Promise.resolve();#c;#d=Promise.resolve();#h;#u=Promise.resolve();#f;#e=!1;#r=0;#p=0;#o=new Map;constructor({outdir:e,contentDir:t,serverMode:s=!1,serverOutDir:r}){this.#n=t,this.outdir=e,this.serverMode=s,this.serverOutDir=r,J.register({serverOutDir:r,readRoots:[e,process.cwd()]}),this.userCodeReady=new Promise(o=>{this.#l=o})}on(e,t){const s=this.listeners.get(e);s?s.add(t):this.listeners.set(e,new Set([t]))}queueEvent=(e,t,...s)=>{this.#o.set(e+String(t),[e,t,...s])};runListeners=(e,t,...s)=>{for(const r of this.listeners.get(e)||new Set)t?r(t,...s):r(...s)};startPluginsRun(){this.clear(),this.#s=new Promise(e=>{this.#c=e})}waitForPluginsLifecycle(){return Promise.all([this.#s,this.#d,this.#u])}waitForPluginsRun(){return this.#s}finishPluginsRun(){this.#c?.();for(const e of this.#o.values())this.runListeners(...e);this.#o.clear()}startEsbuildRun(){this.#d=new Promise(e=>{this.#h=e})}finishEsbuildRun(){this.#h?.()}markRequestHandlersEntryOutdated(){this.#r++,!this.#e&&(this.#e=!0,this.#u=new Promise(e=>{this.#f=e}))}noteRequestHandlersEntryBuildStart(){this.#p=this.#r}markRequestHandlersEntryUpdated(){this.#e&&(this.#r>this.#p||(this.#e=!1,this.#f?.()))}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#n}markUserCodeReady(){this.#l?.(!0)}async reloadMarkdocOptions(){await le("com.redocly.build.reloadMarkdocOptions",async()=>{const{userTagNames:e,...t}=await Y(this.serverOutDir),s=Q(e),r=Object.fromEntries(Object.entries(t.tags).filter(([o])=>!(o in s)));this.#a={...t,tags:r},this.#i=s})}get markdocOptions(){return{...this.#a,partials:this.getGlobalConfig(y),themeConfig:this.config.markdown,planDeniedTags:this.#i}}setGlobalData=e=>{const t=this.globalData,s={...this.globalData,...e};this.globalData=s,JSON.stringify(s)!==JSON.stringify(t)&&this.queueEvent("global-data-updated",void 0,s)};getGlobalData=()=>this.globalData;getKv=async()=>q.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async({input:e,context:t,deps:s,resource:r})=>{const{data:{info:o,ast:a},compoundHash:l}=await M(e,this.markdocOptions,{actions:this,context:t},r);for(const i of o.sharedDataDeps||[]){for(const n of s?.routeSlugs||[])this.addRouteSharedData(n,i,i);for(const n of s?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(i),this.sharedDataDeps.set(n,c)}}for(const i of o.dynamicMarkdocComponents||[]){for(const n of s?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(i),this.routesDynamicComponents.set(n,c)}for(const n of s?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(i),this.sharedDataMarkdocComponents.set(n,c)}}if(s?.routeSlugs&&o.partials?.length)for(const i of s.routeSlugs){const n=this.routesPartials.get(i)||[];for(const c of o.partials)n.includes(c)||n.push(c);this.routesPartials.set(i,n)}return{info:o,ast:a,compoundHash:l}};async loadApiDocuments(e){return(await e.cache.load(".","api-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setStaticFilePaths=e=>{this.staticFilePaths=e};setGlobalConfig=e=>{const t=Object.keys(e);for(const a of t)for(const l in this.replacedEnvVars)if(l===a||l.startsWith(`${a}:`)){const i=l.split(":"),{error:n,value:c}=S(e,i);(n||c!==this.replacedEnvVars[l].replaced)&&delete this.replacedEnvVars[l]}const{config:s,unsetEnvVars:r,replacedValues:o}=re(e);for(const a of r)this.unsetEnvVars.add(a);Object.assign(this.replacedEnvVars,o),Object.assign(this.config,s)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,t,s={})=>{if(!Z.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const a=d(e).toLowerCase();this.config.redirects[a]=t;const{trackOriginalSource:l=!0}=s,i=this.getGlobalConfig("originalRedirectSources");l&&Array.isArray(i)&&!i.includes(a)&&i.push(a),a.endsWith("*")&&ne(this.config.wildcardRedirectsTree,a)};getRedirect=e=>{const t=d(e).toLowerCase(),s=ae(t,this.config.redirects,this.config.wildcardRedirectsTree,this.staticFilePaths);if(!s)return null;if(v(s.to)){const r=d(s.to).toLowerCase();if(!r.endsWith("*")&&ie(r,[t],this.config.redirects,this.config.wildcardRedirectsTree).type==="cycle")return null}return{to:s.to,type:s.type}};createSharedData=async(e,t,s)=>{if(s&&this.#t[e]===s)return e;const r=JSON.stringify(t),o=s??_(r);return this.#t[e]===o||(this.#t[e]=o,await K(e,r,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,t,s)=>{const r=G(e),o=this.routesSharedData.get(r)||{};o[t]=s,this.routesSharedData.set(r,o),u.verbose(`Adding shared data to ${e}, ${t}, ${s}`)};getRouteSharedDataByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.routesSharedData.get(t)||{}:{}};getPartialsForRoute=e=>{const t=this.getGlobalConfig(y)||{},s=this.routesPartials.get(e);if(!s||s.length===0)return{};const r=this.getGlobalConfig(L)||{},o=new Set(s),a=Array.from(s);for(let i=0;i<a.length;i++){const n=a[i],c=r[n]?.partials??[];for(const h of c)o.has(h)||(o.add(h),a.push(h))}const l={};for(const i of o)t[i]&&(l[i]=t[i]);return l};addRoute=e=>{const s={...te(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:s}),u.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,t,s)=>{const r=[m,...this.lifecycleContext?.fs.localeFolders||[]].map(o=>({code:o,name:o}));for(const o of r){const a=k(e,m,o.code,r);this.addRouteSharedData(a,t,s)}};addApiRoute=e=>{this.apiRoutes.push(e),u.verbose("Created API route %s",e.slug)};addMcpTools=(e,t)=>{for(const s of t){const r=this.mcpToolHandlers.get(s.name);r&&r.importPath!==e&&u.warn('MCP tool "%s" from %s overwrites the tool registered from %s',s.name,e,r.importPath);const o=s.hasAvailabilityGate??(r?.importPath===e?r.hasAvailabilityGate:void 0);this.mcpToolHandlers.set(s.name,{...s,importPath:e,hasAvailabilityGate:o}),u.verbose("Created MCP tool %s",s.name)}};getMcpTools=()=>Array.from(this.mcpToolHandlers.values());markGatedMcpTools=e=>{for(const t of e){const s=this.mcpToolHandlers.get(t);s&&this.mcpToolHandlers.set(t,{...s,hasAvailabilityGate:!0})}};addSkills=e=>{for(const t of e)this.skills.set(t.slug,t),u.verbose("Discovered skill %s",t.slug)};getSkills=()=>Array.from(this.skills.values());removeMcpTools=e=>{for(const t of e)this.mcpToolHandlers.delete(t)};addMiddleware=e=>{this.middleware.push(e),u.verbose("Created middleware %s",e.id)};setResourceResponseHeaders=(e,t)=>{this.config.responseHeaders||(this.config.responseHeaders={});const s=new Set(t.map(a=>a.name.toLowerCase())),o=[...(this.config.responseHeaders[e]??[]).filter(a=>!s.has(a.name.toLowerCase())),...t];this.config.responseHeaders[e]=o};getRouteByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.getRouteBySlug(t):void 0};getRouteBySlug=(e,t={})=>{const{followRedirect:s=!0}=t,r=this.getRedirect(e);if(s&&r)return this.routesBySlug.get(d(r.to));const o=s?this.routeAliases.get(d(e).toLowerCase()):void 0;return this.routesBySlug.get(o??e)};addRouteAlias=(e,t)=>{this.routeAliases.set(d(e).toLowerCase(),d(t))};hasRouteOrRedirectBySlug=e=>{if(this.routesBySlug.has(e)||this.routeAliases.has(d(e).toLowerCase())||X(e,this.getConfig()))return!0;const t=this.getRedirect(e);if(!t)return!1;if(!v(t.to))return!0;const s=d(t.to);return this.routesBySlug.has(s)};getRoutesByTemplateId=e=>this.newRoutes.filter(t=>t.templateId===e);getAllRoutesForLocale=(e=m)=>{const t=Array.from(this.routesBySlug.values()),s=e.toLowerCase();return t.filter(r=>e===m?!ee(r.fsPath):r.slug.startsWith(`/${s}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,t)=>(this.templates.set(e,t),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};copyAsset=async(e,t)=>{const s=this.lifecycleContext?.fs;if(!s)throw new Error(`Cannot copy asset ${e}: the content file system is not ready`);try{const r=await I(e,s,{fromFileRelativePath:t,contentDir:this.contentDir,outdir:this.outdir});if(!r)throw new Error(`Cannot copy asset ${e}`);return r}catch(r){if(r instanceof B)return null;throw r}};createRequestHandler=(e,t)=>(this.apiRoutesRequestHandlers.set(e,t),e);clearRequestHandlersByPrefix=e=>{for(const t of this.apiRoutesRequestHandlers.keys())t.startsWith(e)&&this.apiRoutesRequestHandlers.delete(t)};registerServerPropsGetter=(e,t)=>(this.serverPropsGetters.set(e,t),e);registerPagePropsGetter=(e,t)=>{this.pagePropsGetters.set(e,t)};async writeRouteStaticData(e,t){const s=await this.resolveRouteStaticData(e,t,!1);s&&z(e.slug,s,this.outdir)}async resolveRouteStaticData(e,t,s){if(this.serverMode)return W(e.slug,this.outdir);const r={...this,contentDir:this.contentDir,parseMarkdoc:({input:c,context:h,resource:f})=>this.parseMarkdoc({input:c,context:h,deps:{routeSlugs:[e.slug]},resource:f})},o=await e.getStaticData?.(e,r)||{},a=new Set(this.routesDynamicComponents.get(e.slug)),l=this.routesSharedData.get(e.slug)||{};for(const c of Object.values(l)){const h=this.sharedDataMarkdocComponents.get(c);h&&h.forEach(p=>a.add(p));const f=this.sharedDataDeps.get(c);f&&f.forEach(p=>this.addRouteSharedData(e.slug,p,p))}const i=this.getGlobalConfig("seo"),n=o?.frontmatter||{};return{...o,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await e.getNavText?.()}},props:{...o.props,dynamicMarkdocComponents:Array.from(a),metadata:{...o?.props?.metadata,...e.metadata},seo:{title:F,...i,...o.props?.seo,siteUrl:i?.siteUrl},compilationErrors:this.compilationErrors},lastModified:s||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,t){if(!e?.length)return;const s=typeof e[0]=="string"?e.join(""):$(e);s&&(t==="head"?this.ssr.headTags.push(s):t==="preBody"?this.ssr.preBodyTags.push(s):this.ssr.postBodyTags.push(s))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.routeAliases.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.skills.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};#g(){const e=[];for(const[s,r]of Object.entries(P))switch(r){case"map":{const o=Array.from(this[s].entries());e.push([s,o]);break}case"object":e.push([s,this[s]]);break;default:throw new Error("Invalid format")}const t=Object.fromEntries(e);return t[b]=j.PLAN_GATES,t}static#m(e,t){const s=new D(t);for(const[o,a]of Object.entries(P))switch(a){case"map":s[o]=new Map(e[o]);break;case"object":s[o]=e[o];break;default:throw new Error("Invalid format")}const r=e[b];return r&&V("PLAN_GATES",r),s}async writeServerFiles(){x(this.serverOutDir),w(g(this.serverOutDir,C),JSON.stringify(this.#g())),w(g(this.serverOutDir,A),JSON.stringify(await this.getConfigWithEnvPlaceholders()))}static async fromServerFiles(e){const t=g(e.serverOutDir,A),{config:s,env:r}=oe(JSON.parse(await R(t,"utf8")));s[y]=de(s[y]);const o=JSON.parse(await R(g(e.serverOutDir,C),"utf8")),a=D.#m(o,e);a.config=s;const l=Object.fromEntries(Object.entries(r).filter(([i])=>U(i)));return a.configFile={path:t,env:l,config:{...s}},a}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const t in this.replacedEnvVars){const{original:s}=this.replacedEnvVars[t],r=t.split(":"),o=r.pop(),{error:a,value:l}=S(e,r);if(a||!H(l)&&!Array.isArray(l)){await E.panicOnBuild(`Failed to replace env var with env name for ${t}`);continue}l[o]=s}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(s=>!ce.includes(s));if(e.length===0)return;const t=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await E.panicOnBuildContentError(t)}}function de(O){return N(O,e=>T.Ast.fromJSON(JSON.stringify(e)))}export{D as Store,We as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
|
|
@@ -31,6 +31,8 @@ export type ResolveItemsOptions = {
|
|
|
31
31
|
};
|
|
32
32
|
export type MarkdocOptions = Partial<Omit<MarkdocConfigProps, 'relativePath'>> & {
|
|
33
33
|
themeConfig?: RedoclyConfig['markdown'];
|
|
34
|
+
/** The tags the project's plan lacks, each with the message a page shows in place of the tag. */
|
|
35
|
+
planDeniedTags?: Record<string, string>;
|
|
34
36
|
};
|
|
35
37
|
export type GetStaticDataContext = {
|
|
36
38
|
getRouteByFsPath: (relativePath: string) => PageRouteDetails<PageStaticData, PageProps> | undefined;
|
|
@@ -119,6 +121,8 @@ export type ApiRouteMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'all'
|
|
|
119
121
|
export type ApiRoute = RouteDetails & {
|
|
120
122
|
httpMethod: ApiRouteMethod;
|
|
121
123
|
requestHandlerId: string;
|
|
124
|
+
timeoutMs?: number;
|
|
125
|
+
maxResponseSizeMB?: number;
|
|
122
126
|
};
|
|
123
127
|
export type McpToolSchema = {
|
|
124
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;
|
|
@@ -3,6 +3,7 @@ export declare class HttpError extends Error {
|
|
|
3
3
|
constructor(status: number, message: string);
|
|
4
4
|
}
|
|
5
5
|
export declare class OidcDiscoveryError extends Error {
|
|
6
|
-
|
|
6
|
+
/** `reason` completes the sentence "<host> ...", e.g. "answered HTTP 503 (text/html)". */
|
|
7
|
+
constructor(url: string, reason: string);
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
class s extends Error{status;constructor(t,r){super(r),this.status=t,Object.setPrototypeOf(this,s.prototype)}}class e extends Error{constructor(t,r){super(`OIDC discovery failed: ${new URL(t).host} ${r}`),this.name="OidcDiscoveryError",Object.setPrototypeOf(this,e.prototype)}}export{s as HttpError,e as OidcDiscoveryError};
|
|
@@ -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
|
|
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};
|