@redocly/revel 0.141.0-next.0 → 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.
Files changed (86) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/dist/cli/develop.js +1 -1
  3. package/dist/cli/utils/react-pages-check.d.ts +11 -0
  4. package/dist/cli/utils/react-pages-check.js +1 -0
  5. package/dist/client/App.js +1 -1
  6. package/dist/client/app/Sidebar/useSidebarItems.js +1 -1
  7. package/dist/client/app/hooks/useBanner.js +1 -1
  8. package/dist/client/app/hooks/useUserClaims.js +1 -1
  9. package/dist/client/app/webmcp/tools/shared.d.ts +2 -3
  10. package/dist/client/app/webmcp/tools/shared.js +1 -1
  11. package/dist/client/runtime/errors/page-async-component-error.d.ts +4 -0
  12. package/dist/client/runtime/errors/page-async-component-error.js +1 -0
  13. package/dist/client/runtime/loader.js +1 -1
  14. package/dist/constants/common.d.ts +2 -0
  15. package/dist/constants/common.js +1 -1
  16. package/dist/constants/l10n/langs/ar.js +1 -1
  17. package/dist/constants/l10n/langs/de.js +1 -1
  18. package/dist/constants/l10n/langs/en.js +1 -1
  19. package/dist/constants/l10n/langs/es.js +1 -1
  20. package/dist/constants/l10n/langs/fr.js +1 -1
  21. package/dist/constants/l10n/langs/hi.js +1 -1
  22. package/dist/constants/l10n/langs/it.js +1 -1
  23. package/dist/constants/l10n/langs/ja.js +1 -1
  24. package/dist/constants/l10n/langs/ko.js +1 -1
  25. package/dist/constants/l10n/langs/pl.js +1 -1
  26. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  27. package/dist/constants/l10n/langs/pt.js +1 -1
  28. package/dist/constants/l10n/langs/ru.js +1 -1
  29. package/dist/constants/l10n/langs/uk.js +1 -1
  30. package/dist/constants/l10n/langs/zh.js +1 -1
  31. package/dist/markdoc/nodes/table.js +1 -1
  32. package/dist/markdoc/tags/index.d.ts +6 -18
  33. package/dist/server/api-routes/run-api-routes-worker.js +1 -1
  34. package/dist/server/constants/entitlements.js +1 -1
  35. package/dist/server/entitlements/entitlements-provider.d.ts +4 -0
  36. package/dist/server/entitlements/entitlements-provider.js +1 -1
  37. package/dist/server/entitlements/plan-denied-markdoc-tags.d.ts +6 -0
  38. package/dist/server/entitlements/plan-denied-markdoc-tags.js +1 -0
  39. package/dist/server/fs/fast-mtime.js +3 -3
  40. package/dist/server/fs/fs.js +1 -1
  41. package/dist/server/plugins/api-docs/index.js +1 -1
  42. package/dist/server/plugins/api-docs/options.js +1 -1
  43. package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +64 -64
  44. package/dist/server/plugins/api-docs/spec-download.api.js +1 -1
  45. package/dist/server/plugins/config-parser/format-error.js +2 -2
  46. package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
  47. package/dist/server/plugins/markdown/attribute-resolvers/resolve-code-snippet-from-file.js +7 -6
  48. package/dist/server/plugins/markdown/compiler.d.ts +3 -3
  49. package/dist/server/plugins/markdown/compiler.js +1 -1
  50. package/dist/server/plugins/markdown/index.js +1 -1
  51. package/dist/server/plugins/markdown/markdoc/markdoc-options.d.ts +2 -0
  52. package/dist/server/plugins/markdown/markdoc/markdoc-options.js +1 -1
  53. package/dist/server/plugins/mcp/custom-tools/scan-custom-tools.d.ts +4 -1
  54. package/dist/server/plugins/mcp/custom-tools/scan-custom-tools.js +1 -1
  55. package/dist/server/plugins/mcp/index.js +1 -1
  56. package/dist/server/plugins/mcp/types.d.ts +1 -0
  57. package/dist/server/plugins/pages/index.js +1 -1
  58. package/dist/server/plugins/pages/validators/validate-react-pages.d.ts +8 -1
  59. package/dist/server/plugins/pages/validators/validate-react-pages.js +1 -1
  60. package/dist/server/plugins/search/ai-indexer/prepare-semantic-documents.js +1 -1
  61. package/dist/server/plugins/search/llmstxt/create-llms-txt-generator.js +1 -1
  62. package/dist/server/plugins/search/llmstxt/index.js +4 -4
  63. package/dist/server/ssr/server-side-props/get-default-static-props.d.ts +1 -0
  64. package/dist/server/ssr/utils.js +11 -9
  65. package/dist/server/store.d.ts +1 -0
  66. package/dist/server/store.js +1 -1
  67. package/dist/server/types/plugins/common.d.ts +13 -1
  68. package/dist/server/types/web-server.d.ts +5 -0
  69. package/dist/server/utils/errors.d.ts +2 -1
  70. package/dist/server/utils/errors.js +1 -1
  71. package/dist/server/utils/llmstxt/resolve-llms-txt-md.d.ts +5 -0
  72. package/dist/server/utils/llmstxt/resolve-llms-txt-md.js +1 -1
  73. package/dist/server/web-server/auth.js +3 -3
  74. package/dist/server/web-server/routes/dynamic-route.js +1 -1
  75. package/dist/server/web-server/routes/error.js +1 -1
  76. package/dist/server/web-server/routes/helpers/process-redirects.d.ts +6 -4
  77. package/dist/server/web-server/routes/helpers/process-redirects.js +1 -1
  78. package/dist/server/web-server/routes/index.js +1 -1
  79. package/dist/server/web-server/routes/page-data.d.ts +2 -1
  80. package/dist/server/web-server/routes/page-data.js +1 -1
  81. package/dist/server/web-server/utils.d.ts +1 -1
  82. package/dist/server/web-server/utils.js +1 -1
  83. package/dist/types/entitlements.d.ts +4 -0
  84. package/package.json +10 -10
  85. package/dist/server/utils/llmstxt/get-llms-txt-md-path-by-slug.d.ts +0 -19
  86. package/dist/server/utils/llmstxt/get-llms-txt-md-path-by-slug.js +0 -1
@@ -1,105 +1,105 @@
1
- import C from"node:path";import{REDOCLY_TEAMS_RBAC as T}from"@redocly/config";import{nodeTypes as y,contentType as b,isGraphqlFieldsNode as pn,resolveGraphqlItemFields as un}from"@redocly/api-docs";import{normalizeApiVersion as dn}from"../utils/normalize-api-version.js";import{replaceFileExtension as N}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as mn,canDownloadApiDefinition as hn,extractTeamsFromScopeItems as yn}from"../../../utils/rbac.js";import{getLlmsTxtMdPathBySlug as K}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{PUBLIC_API_DEFINITIONS_FOLDER as X}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as $n}from"../../../../constants/common.js";import{isPlainObject as $}from"../../../../utils/guards/is-plain-object.js";import{ANONYMOUS_AUTH_DETAILS as gn}from"../../../constants/rbac.js";import{toMarkdown as j}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as bn}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as In}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as An}from"../../../utils/l10n/get-build-translate-context.js";import{getPublicEnvVariables as Pn}from"../../../utils/envs/get-public-env-variables.js";import{llmsTxtLink as w}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as On}from"../../search/utils.js";import{extractDocumentSearchFacets as Sn}from"./search-facets.js";import{createApiDocsSearchIndexer as xn,createLlmDescriptionFormatter as Cn}from"./create-indexer.js";function P(e,s){return s==="openapi"&&"openapi"in e}function Z(e,s){return s==="asyncapi"&&"asyncapi"in e}function rt({getBuild:e,metadata:s,document:c,specType:o,excludeFromSearch:n,basePath:r,getSearchFacets:t,markdocTags:i}){return async(l,f,d,p)=>{if(n)return;const{items:a,store:m}=e(),h={...p.markdocOptions?.tags,...i},{locale:en,translate:on}=await An(l.slug,p.getGlobalData?.().l10n),O=bn(h,en,on,{env:Pn()}),L=p.getConfig(),D=In(l.fsPath),E=Cn(O),V=xn(r,E,m?.schemaStore,c,m?.exampleStore,m?.graphqlMeta),F=I=>{for(const u of I)V.addItem(u),u.items?.length&&F(u.items)};F(a);const rn=V.getResult(),_=new Map;for(const I of rn)_.set(I.url,I);const R=typeof s.title=="string"?s.title:void 0,q=dn(s.version),k=Sn(l.metadata||{},R,q,t),S=[],x=[],G=Tn(c,s),z=G?E(G):void 0,W=vn(s,z,c,o,E),B=Ln(o,s,l.fsPath,L),sn=Rn(a,L,O),cn=W+B+`
2
- `+sn,ln=W+B;x.push({title:R||"API Overview",description:z,content:cn,slug:r,fsPath:l.fsPath,includeInLLMsTxt:!0}),S.push({title:R||"API Overview",content:ln,url:r,fsPath:l.fsPath,locale:D,product:l.product?.name,facets:k});const fn=c&&P(c,o)?c.security:void 0,U=I=>{for(const u of I){if(!u.content||!u.link){u.items?.length&&U(u.items);continue}const an=_.get(u.link),J=u.content.contentType,Q=u[T],H=Q?yn(Q):void 0,Y=H?.length?H:void 0;if(J===b.ITEM){const g=kn(u,c,o)??nn(u,an,o,q,fn,O,m);if(g){const A=u.label||"";x.push({title:A,description:void 0,content:g,slug:u.link,fsPath:l.fsPath,includeInLLMsTxt:!1}),S.push({title:A,content:g,url:u.link,fsPath:l.fsPath,locale:D,product:l.product?.name,facets:k,rbacTeams:Y})}}else if(J===b.GROUP){const g=Un(u,L,o,O,m);if(g){const A=u.label||"";x.push({title:A,description:void 0,content:g.llmstxt,slug:u.link,fsPath:l.fsPath,includeInLLMsTxt:!1}),S.push({title:A,content:g.aiSearch,url:u.link,fsPath:l.fsPath,locale:D,product:l.product?.name,facets:k,rbacTeams:Y})}}u.items?.length&&U(u.items)}};return U(a),{async getLLMsTxts(){return x},async getSearchDocuments(){return S}}}}function Tn(e,s){const c=$(e?.info)?e.info:void 0,o=$(c?.["x-metadata"])?c["x-metadata"]:{},r=(typeof o.description=="string"?o.description:void 0)??c?.description??s.description;return typeof r=="string"?r||void 0:r&&typeof r=="object"?r:void 0}function vn(e,s,c,o,n){const r=typeof e.title=="string"?e.title:"",t=typeof e.summary=="string"?e.summary:"",i=typeof e.version=="string"?e.version:"";let l=r?`# ${r}
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
- `:"";if(l+=s?`${s}
4
+ `:"";if(i+=s?`${s}
5
5
 
6
- `:"",l+=t?`${t}
6
+ `:"",i+=e?`${e}
7
7
 
8
- `:"",l+=i?`Version: ${i}
9
- `:"",c){if(P(c,o)){const{info:f}=c;f?.license?.name&&(l+=`License: ${f.license.name}
10
- `);const d=f["x-metadata"],p=Object.entries($(d)?d:{}).filter(([m,h])=>m!=="description"||typeof h!="string"),a=On(Object.fromEntries(p));a&&(l+=`
8
+ `:"",i+=l?`Version: ${l}
9
+ `:"",r){if(O(r,c)){const{info:f}=r;f?.license?.name&&(i+=`License: ${f.license.name}
10
+ `);const m=f["x-metadata"],a=Object.entries($(m)?m:{}).filter(([u,h])=>u!=="description"||typeof h!="string"),d=xn(Object.fromEntries(a));d&&(i+=`
11
11
  Metadata:
12
- ${a}
13
- `)}else if(Z(c,o)){const{info:f}=c;f?.license?.name&&(l+=`License: ${f.license.name}
14
- `)}}return l+=`
15
- `,l+=Dn(c,o,n),l+=En(c,o,n),l}function Ln(e,s,c,o){if(!c)return"";let n,r,t;if(e==="openapi")n=C.posix.join(X,N(c,".yaml")),r="## Download OpenAPI description",t="OpenAPI definition";else if(e==="asyncapi")n=C.posix.join(X,N(c,".yaml")),r="## Download AsyncAPI description",t="AsyncAPI definition";else if(e==="graphql"){const f=C.posix.extname(c)||".graphql";n=C.posix.join($n,N(c,f)),r="## Download GraphQL schema",t="GraphQL schema"}else return"";if(!hn(n,o.access?.rbac??{},o.access?.requiresLogin??!1,gn))return"";const l=typeof s.title=="string"&&s.title||t;return`${r}
12
+ ${d}
13
+ `)}else if(X(r,c)){const{info:f}=r;f?.license?.name&&(i+=`License: ${f.license.name}
14
+ `)}}return i+=`
15
+ `,i+=En(r,c,n),i+=kn(r,c,n),i}function Dn(t,s,r,c){if(!r)return"";let n,o,e;if(t==="openapi")n=C.posix.join(Y,U(r,".yaml")),o="## Download OpenAPI description",e="OpenAPI definition";else if(t==="asyncapi")n=C.posix.join(Y,U(r,".yaml")),o="## Download AsyncAPI description",e="AsyncAPI definition";else if(t==="graphql"){const f=C.posix.extname(r)||".graphql";n=C.posix.join(bn,U(r,f)),o="## Download GraphQL schema",e="GraphQL schema"}else return"";if(!yn(n,c.access?.rbac??{},c.access?.requiresLogin??!1,An))return"";const i=typeof s.title=="string"&&s.title||e;return`${o}
16
16
 
17
- - ${w({title:l,description:void 0,slug:n,siteUrl:o.seo?.siteUrl})}`}function Dn(e,s,c){if(!e)return"";if(P(e,s)){const o=Array.isArray(e.servers)?e.servers.filter($):[];if(!o.length)return"";let n=`## Servers
17
+ - ${K({title:i,description:void 0,slug:n,siteUrl:c.seo?.siteUrl})}`}function En(t,s,r){if(!t)return"";if(O(t,s)){const c=Array.isArray(t.servers)?t.servers.filter($):[];if(!c.length)return"";let n=`## Servers
18
18
 
19
- `;for(const r of o){r.description&&(n+=`${c(r.description)}
19
+ `;for(const o of c){o.description&&(n+=`${r(o.description)}
20
20
  `),n+=`\`\`\`
21
- ${r.url}
21
+ ${o.url}
22
22
  \`\`\`
23
23
 
24
- `;const t=Object.entries($(r.variables)?r.variables:{}).filter(([,i])=>$(i));if(t.length){n+=`Variables:
25
- `;for(const[i,l]of t)n+=`- \`${i}\`${l.description?`: ${c(l.description).replace(/\s+/g," ")}`:""}
26
- `,l.default&&(n+=` Default: ${JSON.stringify(l.default)}
27
- `),Array.isArray(l.enum)&&(n+=` Enum: ${l.enum.map(f=>JSON.stringify(f)).join(", ")}
24
+ `;const e=Object.entries($(o.variables)?o.variables:{}).filter(([,l])=>$(l));if(e.length){n+=`Variables:
25
+ `;for(const[l,i]of e)n+=`- \`${l}\`${i.description?`: ${r(i.description).replace(/\s+/g," ")}`:""}
26
+ `,i.default&&(n+=` Default: ${JSON.stringify(i.default)}
27
+ `),Array.isArray(i.enum)&&(n+=` Enum: ${i.enum.map(f=>JSON.stringify(f)).join(", ")}
28
28
  `);n+=`
29
- `}}return n}if(Z(e,s)){const o=Object.entries($(e.servers)?e.servers:{}).filter(([,r])=>$(r));if(!o.length)return"";let n=`## Servers
29
+ `}}return n}if(X(t,s)){const c=Object.entries($(t.servers)?t.servers:{}).filter(([,o])=>$(o));if(!c.length)return"";let n=`## Servers
30
30
 
31
- `;for(const[r,t]of o)n+=`### ${r}
31
+ `;for(const[o,e]of c)n+=`### ${o}
32
32
 
33
- `,t.description&&(n+=`${c(t.description)}
34
- `),t.host&&(n+=`Host: ${t.host}
35
- `),t.protocol&&(n+=`Protocol: ${t.protocol}
36
- `),t.protocolVersion&&(n+=`Protocol Version: ${t.protocolVersion}
37
- `),t.pathname&&(n+=`Pathname: ${t.pathname}
33
+ `,e.description&&(n+=`${r(e.description)}
34
+ `),e.host&&(n+=`Host: ${e.host}
35
+ `),e.protocol&&(n+=`Protocol: ${e.protocol}
36
+ `),e.protocolVersion&&(n+=`Protocol Version: ${e.protocolVersion}
37
+ `),e.pathname&&(n+=`Pathname: ${e.pathname}
38
38
  `),n+=`
39
- `;return n}return""}function En(e,s,c){if(!e||!P(e,s))return"";const o=e.components?.securitySchemes;if(!o)return"";let n=`## Security
39
+ `;return n}return""}function kn(t,s,r){if(!t||!O(t,s))return"";const c=t.components?.securitySchemes;if(!c)return"";let n=`## Security
40
40
 
41
- `;for(const[r,t]of Object.entries(o)){if(!t||"$ref"in t)continue;const i=t;n+=`### ${r}
41
+ `;for(const[o,e]of Object.entries(c)){if(!e||"$ref"in e)continue;const l=e;n+=`### ${o}
42
42
 
43
- `,i.description&&(n+=`${c(i.description)}
43
+ `,l.description&&(n+=`${r(l.description)}
44
44
 
45
- `),i.type&&(n+=`Type: ${i.type}
46
- `),i.in&&(n+=`In: ${i.in}
47
- `),i.name&&(n+=`Name: ${i.name}
48
- `),i.scheme&&(n+=`Scheme: ${i.scheme}
49
- `),i.bearerFormat&&(n+=`Bearer Format: ${i.bearerFormat}
50
- `),i.openIdConnectUrl&&(n+=`OpenID Connect URL: ${i.openIdConnectUrl}
51
- `);const l=i.flows,f=l?.implicit||l?.password||l?.clientCredentials||l?.authorizationCode;if(f&&("authorizationUrl"in f&&f.authorizationUrl&&(n+=`Authorization URL: ${f.authorizationUrl}
45
+ `),l.type&&(n+=`Type: ${l.type}
46
+ `),l.in&&(n+=`In: ${l.in}
47
+ `),l.name&&(n+=`Name: ${l.name}
48
+ `),l.scheme&&(n+=`Scheme: ${l.scheme}
49
+ `),l.bearerFormat&&(n+=`Bearer Format: ${l.bearerFormat}
50
+ `),l.openIdConnectUrl&&(n+=`OpenID Connect URL: ${l.openIdConnectUrl}
51
+ `);const i=l.flows,f=i?.implicit||i?.password||i?.clientCredentials||i?.authorizationCode;if(f&&("authorizationUrl"in f&&f.authorizationUrl&&(n+=`Authorization URL: ${f.authorizationUrl}
52
52
  `),"tokenUrl"in f&&f.tokenUrl&&(n+=`Token URL: ${f.tokenUrl}
53
53
  `),f.scopes)){n+=`Scopes:
54
- `;for(const[d,p]of Object.entries(f.scopes))n+=`- \`${d}\`: ${p}
54
+ `;for(const[m,a]of Object.entries(f.scopes))n+=`- \`${m}\`: ${a}
55
55
  `}n+=`
56
- `}return n}function Rn(e,s,c){let o="";const n=(r,t)=>{for(const i of r)if(i.link){if(i.content?.contentType===b.GROUP)o+=`${t} ${i.label||""}
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&&n(i.items,t+"#");else if(i.content?.contentType===b.ITEM){if(!M(i,s))continue;const l=i,f=l.httpVerb,d=l.httpPath,p=f&&d?`${f.toUpperCase()} ${d}`:i.label||"",a=i.content?v(i.content.children,c):void 0;o+=` - ${w({title:p,description:a?a.slice(0,200):void 0,slug:K(i.link),siteUrl:s.seo?.siteUrl})}`}}};return n(e,"##"),o}function nn(e,s,c,o,n,r,t){if(!e.content)return;const i=e,l=e.label||"",f=v(e.content.children,r),d=e.content.meta?.deprecated;let p=`# ${l}${d?" (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
- `;if(f&&(p+=`${f}
60
+ `;if(f&&(a+=`${f}
61
61
 
62
- `),c==="openapi"||c==="asyncapi"){const a=i.httpVerb,m=i.httpPath;a&&m?p+=`Endpoint: ${a.toUpperCase()} ${m}
63
- `:a&&(p+=`Method: ${a.toUpperCase()}
64
- `),o&&(p+=`Version: ${o}
65
- `);const h=Nn(e.content.children,n);h&&(p+=`Security: ${h}
66
- `)}return s?.parameters?.length&&c!=="graphql"&&(p+=`
62
+ `),r==="openapi"||r==="asyncapi"){const d=l.httpVerb,u=l.httpPath;d&&u?a+=`Endpoint: ${d.toUpperCase()} ${u}
63
+ `:d&&(a+=`Method: ${d.toUpperCase()}
64
+ `),c&&(a+=`Version: ${c}
65
+ `);const h=Nn(t.content.children,n);h&&(a+=`Security: ${h}
66
+ `)}return s?.parameters?.length&&r!=="graphql"&&(a+=`
67
67
  `+jn(s.parameters)+`
68
- `),c==="graphql"&&(p+=wn(e.content.children,t,r)),p}function kn(e,s,c){if(e.httpVerb!=="tool"||!s||!P(s,c))return;const o=e.content?.meta?.name,n=o?s["x-mcp"]?.tools?.find(t=>t.name===o):void 0;if(!n)return;let r=`# ${e.label||n.name}
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}
69
69
 
70
- `;return typeof n.description=="string"&&n.description&&(r+=`${n.description}
70
+ `;return typeof n.description=="string"&&n.description&&(o+=`${n.description}
71
71
 
72
- `),r+=`## Input schema:
72
+ `),o+=`## Input schema:
73
73
 
74
- `,r+=`\`\`\`json
74
+ `,o+=`\`\`\`json
75
75
  ${JSON.stringify(n.inputSchema,null,2)}
76
76
  \`\`\`
77
77
 
78
- `,n.outputSchema&&(r+=`## Output schema:
78
+ `,n.outputSchema&&(o+=`## Output schema:
79
79
 
80
- `,r+=`\`\`\`json
80
+ `,o+=`\`\`\`json
81
81
  ${JSON.stringify(n.outputSchema,null,2)}
82
82
  \`\`\`
83
83
 
84
- `),r}function Un(e,s,c,o,n){if(!e.content)return;const r=e.label||"",t=v(e.content.children,o);let i=`# ${r}
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
- `;if(t&&(i+=`${t}
86
+ `;if(l&&(i+=`${l}
87
87
 
88
- `),c==="graphql"){let f="";const d=p=>{for(const a of p??[])if(!(!a.content||!M(a,s)))if(a.content.contentType===b.ITEM){const m=nn(a,void 0,c,void 0,void 0,o,n);m&&(f+=`${m}
88
+ `),r==="graphql"){let m="";const a=d=>{for(const u of d??[])if(!(!u.content||!tn(u,s)))if(u.content.contentType===A.ITEM){const h=nn(u,void 0,r,void 0,void 0,n,o);h&&(m+=`${h}
89
89
 
90
90
  ---
91
91
 
92
- `)}else a.content.contentType===b.GROUP&&d(a.items)};return d(e.items),{llmstxt:i+f,aiSearch:i}}let l="";if(e.items?.length)for(const f of e.items){if(!f.link||!f.content||f.content.contentType!==b.ITEM||!M(f,s))continue;const d=f,p=d.httpVerb,a=d.httpPath,m=p&&a?`${p.toUpperCase()} ${a}`:f.label||"",h=f.content?v(f.content.children,o):void 0;l+=` - ${w({title:m,description:h?h.slice(0,200):void 0,slug:K(f.link),siteUrl:s.seo?.siteUrl})}`}return{llmstxt:i+l,aiSearch:i}}function Nn(e,s){const c=[],o=n=>{for(const r of n)if(r.nodeType===y.SECURITY){const t=r;for(const i of t.requirements)for(const l of i.schemes)l[T]||l.name&&!c.includes(l.name)&&c.push(l.name)}else(r.nodeType===y.CONTAINER||r.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&o(r.children)};if(o(e),c.length)return c.join(", ");if(s?.length){const n=s.flatMap(r=>Object.keys(r));if(n.length)return[...new Set(n)].join(", ")}}function jn(e){const s={};for(const o of e){const n=`${o.place}${o.mediaType?` (${o.mediaType})`:""}`;s[n]||(s[n]=[]),s[n].push(o)}return Object.entries(s).map(([o,n])=>{const r=n.map(t=>{const i=[...t.path||[],t.name],l=Array.isArray(t.description)?t.description.join(" "):t.description;let f=` - \`${i.join(".")}\` (${t.type}${t.required?", required":""})
93
- `;return l&&(f+=` ${l.trim()}
94
- `),t.enum?f+=` Enum: ${t.enum.map(d=>JSON.stringify(d)).join(", ")}
95
- `:t.example&&(f+=` Example: ${t.example}
96
- `),f});return`## ${tn(o)}:
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
+ `;return i&&(f+=` ${i.trim()}
94
+ `),e.enum?f+=` Enum: ${e.enum.map(m=>JSON.stringify(m)).join(", ")}
95
+ `:e.example&&(f+=` Example: ${e.example}
96
+ `),f});return`## ${en(c)}:
97
97
 
98
- ${r.join(`
98
+ ${o.join(`
99
99
  `)}`}).join(`
100
- `)}function wn(e,s,c){let o="";const n=r=>{for(const t of r)if(t.nodeType===y.ITEM){const i=pn(t)?un(t,s??{}):void 0;i&&(o+=Mn(i,t.variant,c))}else(t.nodeType===y.CONTAINER||t.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&n(t.children)};return n(e),o}function Mn(e,s,c){let n=`
101
- ## ${tn(s==="return-type"?"Return type":s==="graphql-args"||s==="arguments"?"Arguments":s==="graphql-fields"?"Fields":s)}:
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
+ ## ${en(s==="return-type"?"Return type":s==="graphql-args"||s==="arguments"?"Arguments":s==="graphql-fields"?"Fields":s)}:
102
102
 
103
- `;const r=t=>{const i=t.description?j(Array.isArray(t.description)?t.description:[t.description],{renderTag:c}).trim():"";return` - \`${t.name}\` (${t.type.display})${i?`: ${i}`:""}
104
- `};if(e.type){const t=e.type.description?j(Array.isArray(e.type.description)?e.type.description:[e.type.description],{renderTag:c}).trim():"";n+=` Type: ${e.type.display}`,t&&(n+=` - ${t}`),n+=`
105
- `}else if(!e.fields.length)return"";for(const t of e.fields)n+=r(t);return n}function v(e,s){const c=[],o=r=>{for(const t of r)if(t.nodeType===y.MARKDOC){const i=t.content,l=Array.isArray(i)?i:[i],f=j(l,{renderTag:s}).trim();f&&c.push(f)}else(t.nodeType===y.CONTAINER||t.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&o(t.children)};return o(e),c.join(" ").trim()||void 0}function tn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function M(e,s){return s.access?.requiresLogin?!0:mn({slug:e.link||"",[T]:e[T]},s)}export{rt 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,4 +1,4 @@
1
- import{getLineColLocation as u,isAbsoluteUrl as g,getCodeframe as l}from"@redocly/openapi-core";import m from"node:path";import{gray as i}from"../../tools/notifiers/helpers/colors.js";function L(a,s){return`Config validation error:
1
+ import{getLineColLocation as u,isAbsoluteUrl as g,getCodeframe as l}from"@redocly/openapi-core";import m from"node:path";import{gray as i}from"../../tools/notifiers/helpers/colors.js";function v(a,s){return`Config validation ${a.severity==="warn"?"warning":"error"}:
2
2
 
3
3
  `+c(a);function c(o){const t=o.location[0];if(!t)return o.message;if(!t.source){const n=t.pointer??"";return`${o.message}${n?` at ${n}`:""}`}const e=t.source?.absoluteRef,r=e&&g(e)?e:e?m.relative(s,e):"config";try{if(typeof t.source.getAst!="function"){const $=t.pointer?i(`at ${t.pointer}`):"";return`${r} ${$}
4
4
 
@@ -14,4 +14,4 @@ ${o.message}
14
14
 
15
15
  ${o.message}
16
16
 
17
- `}}}export{L as formatConfigProblem};
17
+ `}}}export{v as formatConfigProblem};
@@ -1 +1 @@
1
- import R from"path";import{lintConfig as j,loadConfig as E,createConfigTypes as L}from"@redocly/openapi-core";import{findEmptyAgentSection as S,rbacConfigSchema as q,rootRedoclyConfigSchema as x,withPlatformSection as B}from"@redocly/config";import{deepMerge as k}from"../../../../../utils/object/deep-merge.js";import{isPlainObject as v}from"../../../../../utils/guards/is-plain-object.js";import{logger as p}from"../../../../tools/notifiers/logger.js";import{BRANCH_ENV_PREFIX as I}from"../../../../../constants/common.js";import{sanitizeBranchName as M}from"../../../../utils/envs/sanitize-branch-name.js";import{envConfig as C}from"../../../../config/env-config.js";import{ajv as N,safeParsePartial as _}from"../../safe-parse.js";import{formatConfigProblem as D}from"../../format-error.js";import{ExternalResolver as F}from"../../../../fs/utils/external-ref-resolver.js";import{resolveMutuallyExclusiveProps as G}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 z(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 V(e){return N.compile(x.properties.graphql.properties.servers.items.properties.url)(e)}function A(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"&&!V(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 Y(e,s){if(A(e.graphql,"graphql",s),!!v(e.apis))for(const[t,n]of Object.entries(e.apis))v(n)&&A(n.graphql,`apis.${t}.graphql`,s)}function H(e,s){const t=[["",e],...Object.entries(e.env??{}).map(([n,r])=>[`env.${n}.`,r])];for(const[n,r]of t){const a=S(r);a&&s(new Error(`Invalid ${n}${a}.agent: it must set at least one option.`))}}async function me(e,s,t,n){const a=s.getFileInfo(e)?.realRelativePath||e;async function c(){const f=new F(s),m=R.join(s.cwd,a),d=await E({configPath:m,externalRefResolver:f}),h=await n(d.resolvedConfig);if(h===void 0)return d.resolvedConfig;const g=d.document?.source,P=[...g?await j({config:d,externalConfigTypes:L(h,d)}):[],...g?G(d.resolvedConfig,g):[]];if(P.length>0)for(const U of P)t(new Error(D(U,s.cwd)));return d.resolvedConfig}const o=s.exists(e)?await c():{},l=Q(o),w=await n(o);y(o,"residency","Residency",t),y(o,"logoutReturnUrl","Logout return URL",t),z(o,t),Y(o,t),H(o,t);let u=w?_(w,o):o;u=W(u),u=J(u,t);const{env:b}=u;if(b){const f=C.REDOCLY_ENV,m=b[f]||{},d=C.PUBLIC_REDOCLY_BRANCH_NAME||"",h=d?M(d):"",g=h&&b[`${I}${h}`]||{};u=k(u,g,m)}const i=Z(u,l);if(i.imports&&i.imports.length>0){p.warn("The 'imports' property is deprecated. Please use 'plugins' property instead.");const f=new Set([...i.plugins||[],...i.imports.map(m=>R.posix.join(m,"plugin.js"))]);i.plugins=Array.from(f),delete i.imports}if(i.catalog&&(p.warn("The 'catalog' property is deprecated. Please use 'catalogClassic' property instead."),i.catalogClassic={...i.catalog},delete i.catalog),i.scorecard&&(p.warn("The 'scorecard' property is deprecated. Please use 'scorecardClassic' property instead."),i.scorecardClassic=i.scorecard,delete i.scorecard),i.search?.ai){p.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 K(i)}function K(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&&p.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 W(e){const s=Object.entries(e.env??{});[e,...s.map(([,r])=>r)].some(r=>r?.mcp?.docs)&&p.warn("The 'mcp.docs' property is deprecated. Please use the 'mcp' properties instead.");const t=e.mcp?{...e,mcp:$(e.mcp)}:e;if(!e.env)return t;const n=s.map(([r,a])=>[r,a?.mcp?{...a,mcp:$(a.mcp)}:a]);return{...t,env:Object.fromEntries(n)}}function $(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 X(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(q.properties,t))}function J(e,s){const t=Object.entries(e.env??{}),n=new Set;let r=!1;for(const o of[e,...t.map(([,l])=>l)])o?.reunite!==void 0&&n.add("The 'reunite' property is deprecated. Please use 'platform' property instead."),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(l=>l?.reunite!==void 0)&&n.add("The 'access.rbac.reunite' property is deprecated. Please use 'access.rbac.platform' property instead."),[o?.rbac,o?.access?.rbac].some(X)&&(r=!0);for(const o of n)p.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,l])=>[o,l&&T(l)]);return{...a,env:Object.fromEntries(c)}}function T(e){const s=B(e),t=e.rbac?{...s,rbac:O(e.rbac)}:s;return e.access?.rbac?{...t,access:{...e.access,rbac:O(e.access.rbac)}}:t}function O(e){const{reunite:s,...t}=e;return s===void 0?t:{...t,platform:e.platform??s}}function Q(e){if(!e.theme)return[];p.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):p.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 Z(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{K as ensureAccessBackwardsCompatibility,me as readAndValidateConfig};
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,7 @@
1
- import c from"node:path";import{slash as L}from"../../../../utils/path/slash.js";import{reporter as F}from"../../../tools/notifiers/reporter.js";import{getNodeAttribute as n}from"../../../../markdoc/helpers/get-node-attribute.js";import{MdResolveError as h}from"./md-resolve-error.js";async function V(i,w,b,{actions:{contentDir:m},context:u}){const o=n(i,w);if(!o)return;const r=o.startsWith("/")?o.slice(1):L(c.relative(m,c.resolve(m,c.dirname(b),o)));if(!u.fs.exists(r)){await F.panicOnBuildContentError(`Code snippet file ${r} does not exist`);return}let e=await u.fs.read(r);const d=n(i,"after"),p=n(i,"before"),y=n(i,"from"),C=n(i,"to"),v=n(i,"prefix")||"",s=y??d,f=C??p,g=d!==null,x=p!==null,E=(typeof s=="number"?Math.max(s||0,1):1)+(g?1:0);let a=(typeof f=="number"?f:1/0)-(x?1:0);if(typeof s=="string"){let t=e.indexOf(s);if(t===-1)throw new h(`Cannot find start text "${s}" in snippet file`,{rawLink:r});for(;e[t]!==`
2
- `&&t>0;)t--;typeof a=="number"&&(a-=e.slice(0,t-1).split(`
3
- `).length),e=e.slice(t+1)}if(typeof f=="string"){let t=e.indexOf(f);if(t===-1)throw new h(`Cannot find end text "${p}" in snippet file`,{rawLink:r});e[t-1]===`
4
- `&&t--,e=e.slice(0,t)}const l=e.split(`
5
- `);if(x)for(;l[l.length-1]==="";)l.pop();i.children=[],i.attributes.rawContent=v+l.slice(E-1,a).join(`
6
- `)}export{V as resolveCodeSnippetFromFile};
1
+ import m from"node:path";import{slash as O}from"../../../../utils/path/slash.js";import{reporter as F}from"../../../tools/notifiers/reporter.js";import{getNodeAttribute as i}from"../../../../markdoc/helpers/get-node-attribute.js";import{MdResolveError as w}from"./md-resolve-error.js";async function j(n,b,y,{actions:{contentDir:d},context:u}){const o=i(n,b);if(!o)return;const r=o.startsWith("/")?o.slice(1):O(m.relative(d,m.resolve(d,m.dirname(y),o)));if(!u.fs.exists(r)){await F.panicOnBuildContentError(`Code snippet file ${r} does not exist`);return}let e=await u.fs.read(r);const x=i(n,"after"),p=i(n,"before"),C=i(n,"from"),g=i(n,"to"),v=i(n,"prefix")||"",s=C??x,f=g??p,E=x!==null,a=p!==null,L=(typeof s=="number"?Math.max(s||0,1):1)+(E?1:0);let c=(typeof f=="number"?f:1/0)-(a?1:0);if(typeof s=="string"){let t=e.indexOf(s);if(t===-1)throw new w(`Cannot find start text "${s}" in snippet file`,{rawLink:r});for(;e[t]!==`
2
+ `&&t>0;)t--;typeof c=="number"&&(c-=e.slice(0,t-1).split(`
3
+ `).length),e=e.slice(t+1)}if(typeof f=="string"){let t=e.indexOf(f);if(t===-1)throw new w(`Cannot find end text "${p}" in snippet file`,{rawLink:r});if(a)e[t-1]===`
4
+ `&&t--;else{const h=e.indexOf(`
5
+ `,t);t=h===-1?e.length:h}e=e.slice(0,t)}const l=e.split(`
6
+ `);if(a)for(;l[l.length-1]==="";)l.pop();n.children=[],n.attributes.rawContent=v+l.slice(L-1,c).join(`
7
+ `)}export{j as resolveCodeSnippetFromFile};
@@ -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: Config | undefined, context: MarkdocResolveContext): Promise<MarkdocInfo>;
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: Config | undefined, rootContext: MarkdocResolveContext, resource?: string): Promise<import("../../types").LoadResult<{
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 N from"@redocly/markdoc";import{htmlTags as B}from"@redocly/markdoc/html";import*as M from"path";import{convertGithubAlertToAdmonition as H}from"@redocly/theme/markdoc/tags/admonition";import{GATED_MARKDOC_TAGS as F}from"../../constants/entitlements.js";import{logger as G}from"../../tools/notifiers/logger.js";import{reporter as K}from"../../tools/notifiers/reporter.js";import{sha1 as V}from"../../utils/crypto/sha1.js";import{formatMarkdocError as U}from"./errors.js";import{extractFirstHeading as q,SKIP as j,visit as $}from"./markdoc/plugins/utils.js";import{isPromptNode as z}from"../../../markdoc/helpers/guards/is-prompt-node.js";import{attributeResolvers as E}from"./attribute-resolvers/index.js";import{MdResolveError as J}from"./attribute-resolvers/md-resolve-error.js";import{normalizeHtmlHeadings as Q}from"./html/normalize-html-headings.js";import{resolveRawPartials as X}from"./markdoc/resolve-raw-partials.js";import{exampleContentTrees as Z,reparseExampleFences as tt}from"./markdoc/reparse-example-fences.js";import{EntitlementsProvider as at}from"../../entitlements/entitlements-provider.js";import{MARKDOC_PARTIALS_DEPS_KEY as rt}from"../../constants/common.js";import{getLinkOriginalAttrName as et}from"./attribute-resolvers/utils.js";import{createSourceLinesReader as ot}from"./create-source-lines-reader.js";const it="EMPTY";async function st(a,r,e){const f=at.instance(),{actions:n}=e,{relativePath:c,resolveErrors:S}=a,w={...e,readSourceLines:ot(a.rawContent)},g=new Set,u=new Set,l=new Set,b=new Set,s={},D=new Set,L={},_={};function P(t,o){const k=o||it;t[k]=(t[k]||0)+1}const T=[];a.resolveErrors.length=0;const A=Z(a.ast),I=t=>{H(t);const o=k();T.push(o.then(y=>{y?.sharedDataIds&&y.sharedDataIds.forEach(d=>g.add(d))}).catch(Y(t)));async function k(){const y=[];switch(t.type){case"fence":P(L,t.attributes.language);break;case"link":case"image":await E.nativeMdLink(t,t.type==="link"?"href":"src",c,w);break;case"tag":{if(!t.tag)break;const d=r?.tags?.[t.tag];if(!d){F[t.tag]&&!f.canAccessFeature(F[t.tag])&&(t.addError({level:"warning",id:"invalid-tag",message:`Undefined tag: ${t.tag}`}),t.tag="",t.type="error",t.attributes={});break}const v=t.tag==="html"?t.attributes.name:t.tag;if((t.tag==="html"?D:b).add(v),s[v]=(s[v]||0)+1,v==="code-snippet"&&P(L,t.attributes.language),d.attributes?.__idx&&(t.attributes.__idx=s[t.tag]),d.dynamicComponentLib&&u.add(d.dynamicComponentLib),!d.attributes)break;if(v==="partial"&&t.attributes?.file){const i=et("file"),m=t[i]||t.attributes.file,h=m.startsWith("/")?m.slice(1):M.posix.normalize(M.posix.join(M.posix.dirname(c),m));l.add(h);const p=(n.getGlobalConfig(rt)||{})[h];if(p?.dynamicComponents)for(const R of p.dynamicComponents)u.add(R);if(p?.sharedDataDeps)for(const R of p.sharedDataDeps)g.add(R)}for(const[i,m]of Object.entries(d.attributes)){const h=m.type;if(h&&(h.resolver||m.resolver)){const x=E[h.resolver||m.resolver],p=await x?.(t,i,c,w);p?.sharedDataId&&y.push(p.sharedDataId)}}if(v==="code-walkthrough")for(const i of t.attributes.resolvedFilesets||[])for(const m of i.files||[])P(_,m.language);const O=t.attributes?.attrs;if(O&&t.tag==="html")for(const i of Object.keys(O))i==="src"||i==="srcSet"?await E.htmlSourceAttribute(t,i,c,w):i==="href"&&await E.htmlHref(t,i,c,w);break}}return{sharedDataIds:y}}};function Y(t){return async o=>{if(!(o instanceof J)){await K.panicOnBuild(o.message);return}S.push(U({type:"resolve_link",meta:{...o.meta,link:o.meta.link??o.meta.rawLink},lines:t.location?[t.location.start.line,t.location.end.line]:[],location:t.location,error:{id:"",level:"error",message:o.message,location:t.location}},a.relativePath,a.rawContent))}}$(a.ast,t=>(I(t),z(t)?j:void 0));for(const t of A)$(t,o=>(H(o),o.type==="tag"&&I(o),z(o)?j:void 0));return await Promise.all(T),a.sharedDataDeps=g,a.dynamicMarkdocComponents=u,a.validatedAtRevision<n.buildRevision&&(a.markdocErrors=[a.ast,...A].flatMap(t=>N.validate(t,r)).map(t=>U(t,c,a.rawContent)),a.validatedAtRevision=n.buildRevision),{sharedDataDeps:a.sharedDataDeps,dynamicMarkdocComponents:Array.from(a.dynamicMarkdocComponents?.values()??[]),partials:Array.from(l),tagList:Array.from(b),htmlTagsList:Array.from(D),tagOccurrence:s,codeSnippetLanguages:L,codeWalkthroughLanguages:_}}const C="unclosed-html",nt={html:B({errorTag:C}),allowIndentation:!0,allowComments:!0};function W(a,r){const e=N.parse(a,{...nt,...r});return ct(e),Q(e),e}function ct(a){for(const r of a.walk())r.type!=="tag"||r.tag!==C||(r.type="error",r.errors.push({id:"parse-error",level:"critical",message:String(r.attributes.message),location:r.location}))}function lt(a,r){const e=W(r,{file:a,slots:!0});return tt(e,n=>W(n,{file:a})),{ast:e,rawContent:r,resolveErrors:[],markdocErrors:[],relativePath:a,sharedDataDeps:void 0,validatedAtRevision:-1}}async function Tt(a,r){const{data:e}=await r.cache.load(a,"markdown-ast");return q(e.ast)}async function At(a,r){K.clearMarkdocProblems();const e=a.getAllRoutes();let f=0;const n=G.isInteractive();for(const c of e)await a.resolveRouteStaticData(c,r,!0),f++,n&&f%100===0&&G.logInFooter("validate",` \u{1F50D} Status: validating markdoc (${f}/${e.length})`)}async function It(a,r,e,f){const n=a.content?V(a.content):"";return await e.context.cache.load(f||a.relativePath,{loader:S,name:"markdown-inline-parser"},[n,String(e.actions.buildRevision)]);async function S(w,g,u){let l;if(a.content){const s=await g.getConfig(),D=await X(a.content,a.relativePath,s.markdown?.partialsFolders,g);l=lt(a.relativePath,D)}else l=(await g.cache.load(a.relativePath,"markdown-ast")).data;let b={};if(e.actions.buildRevision!==0&&(b=await st(l,r,e)),!a.isVirtual){for(const s of l.markdocErrors)u(s);for(const s of l.resolveErrors)u(s)}return{ast:l.ast,info:b}}}export{Tt as extractMdFirstHeading,lt as getAst,It as parseAndResolveMarkdoc,st as resolveAndValidateMarkdoc,At as validateAllMarkdowns};
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};
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../constants/common.js";import{reporter as R}from"../../tools/notifiers/reporter.js";import{canAccessFeature as g}from"../../utils/entitlements/can-access-feature.js";import{extractMdFirstHeading as A,getAst as T}from"./compiler.js";import{getTemplatePath as w}from"./get-template-path.js";import{prepareMarkdocPartials as M}from"./markdoc/partials.js";import{searchResolver as C}from"./search/search-resolver.js";import{markdownStaticDataLoader as E}from"./markdown-static-data-loader.js";import{makeErrorRoute as I}from"../error-route.js";import{validateRbacConfig as O}from"../validate-rbac-config.js";import{findFrontmatterSlugs as _,getSidebarSharedDataId as G,resolveFrontmatterSlugs as L}from"../utils.js";import{isPartial as j}from"./is-partial.js";import{markdownFrontmatterLoader as B}from"./markdown-frontmatter-loader.js";import{resolveRawPartials as K}from"./markdoc/resolve-raw-partials.js";import{getAiDocumentsStore as N}from"./search/get-ai-search-documents.js";import{registerPageProps as Y}from"../register-page-props.js";import{resolveMarkdownTemplate as q}from"./utils/resolve-markdown-template.js";import{sanitizeMalformedMdContent as z}from"./utils/sanitize-malformed-md-content.js";import{telemetryTraceStep as H}from"../../../cli/telemetry/helpers/trace-step.js";async function ce(h){return{id:"markdoc",requiredEntitlements:["markdown"],loaders:{"markdown-frontmatter":B,"markdown-ast":async(e,t)=>{const i=await t.fs.read(e),m=await t.getConfig(),s=await K(i,e,m?.markdown?.partialsFolders,t),n=z(s);return T(e,n)}},processContent:async(e,t)=>{await H("com.redocly.build.plugin.markdown",async i=>{const{markdown:m}=await t.getConfig();i?.setAttribute("config",JSON.stringify(m||{}));const s=m?.partialsFolders??[],n=e.createTemplate("markdown","@redocly/theme/core/templates/Markdown"),S=e.registerServerPropsGetter("markdown",w("./get-server-props.js"));e.createTemplate("error",w("../../../client/app/Error/ErrorDetails.js"));for(const o of t.fs.scan(/\.md$/))if(!await t.isPathIgnored(o.relativePath)&&!j(o.relativePath,s))try{await k(o)}catch(a){e.addRoute(I(o.relativePath,a)),i?.error(a),await R.panicOnBuild("Failed to create route for markdown file: %s",a.message)}async function k(o){const{relativePath:a,realRelativePath:b}=o,{data:{frontmatter:r}}=await t.cache.load(a,"markdown-frontmatter"),P=r?.metadata||{},y=await _(a,"markdown-frontmatter",r,t),p=L(y,a);let d=null;r?.sidebar&&(d=await G(r.sidebar,a,t.fs));let u=n;const l=q({realRelativePath:b,frontmatter:r,markdown:m,contentDir:h.contentDir});l&&(u=e.createTemplate(l.templateRef,l.templatePath)),r?.rbac&&(g("rbac")?O({content:{[a]:r.rbac}}):r.rbac=void 0),g("banner")||(r.banner=void 0),Y(o,t.fs,e),(p.length?p.reverse():[void 0]).forEach(F=>{e.addRoute({excludeFromSearch:r?.excludeFromSearch||!1,slug:F,fsPath:a,templateId:u,sharedData:d?[{id:d,key:"sidebar"}]:void 0,redirectFrom:Object.entries(r.redirects||{}).map(([c,{type:f}])=>({type:f||301,from:c})),[v]:r?.rbac,getNavText:async()=>(r?.seo?.title||await A(a,t)||"").toString(),metadata:{type:"markdown",...P},async getStaticData(c,f){return E(o,c,t,r,f)},getSearchDocuments:C(r,a,e.getSearchFacets,e.setSearchFacets),getAiDocumentsStore:N(e.getSearchFacets,r),serverPropsGetterIds:[S]})})}})},afterRoutesCreated:async(e,t)=>{const i=await M(t,e);e.setGlobalConfig({[D]:i})}}}export{ce as markdownPlugin};
1
+ import{REDOCLY_TEAMS_RBAC as y}from"@redocly/config";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../constants/common.js";import{reporter as R}from"../../tools/notifiers/reporter.js";import{canAccessFeature as g}from"../../utils/entitlements/can-access-feature.js";import{extractMdFirstHeading as A,getAst as T}from"./compiler.js";import{getTemplatePath as w}from"./get-template-path.js";import{prepareMarkdocPartials as M}from"./markdoc/partials.js";import{searchResolver as C}from"./search/search-resolver.js";import{markdownStaticDataLoader as E}from"./markdown-static-data-loader.js";import{makeErrorRoute as I}from"../error-route.js";import{validateRbacConfig as O}from"../validate-rbac-config.js";import{findFrontmatterSlugs as _,getSidebarSharedDataId as G,resolveFrontmatterSlugs as L}from"../utils.js";import{isPartial as j}from"./is-partial.js";import{markdownFrontmatterLoader as B}from"./markdown-frontmatter-loader.js";import{resolveRawPartials as K}from"./markdoc/resolve-raw-partials.js";import{getAiDocumentsStore as N}from"./search/get-ai-search-documents.js";import{registerPageProps as Y}from"../register-page-props.js";import{resolveMarkdownTemplate as q}from"./utils/resolve-markdown-template.js";import{sanitizeMalformedMdContent as z}from"./utils/sanitize-malformed-md-content.js";import{telemetryTraceStep as H}from"../../../cli/telemetry/helpers/trace-step.js";async function ce(h){return{id:"markdoc",requiredEntitlements:["markdown"],loaders:{"markdown-frontmatter":B,"markdown-ast":async(e,t)=>{const i=await t.fs.read(e),m=await t.getConfig(),s=await K(i,e,m?.markdown?.partialsFolders,t),n=z(s);return T(e,n)}},processContent:async(e,t)=>{await H("com.redocly.build.plugin.markdown",async i=>{const{markdown:m}=await t.getConfig();i?.setAttribute("config",JSON.stringify(m||{}));const s=m?.partialsFolders??[],n=e.createTemplate("markdown","@redocly/theme/core/templates/Markdown"),S=e.registerServerPropsGetter("markdown",w("./get-server-props.js"));e.createTemplate("error",w("../../../client/app/Error/ErrorDetails.js"));for(const o of t.fs.scan(/\.md$/))if(!await t.isPathIgnored(o.relativePath)&&!j(o.relativePath,s))try{await k(o)}catch(a){e.addRoute(I(o.relativePath,a)),i?.error(a),await R.panicOnBuild("Failed to create route for markdown file: %s",a.message)}async function k(o){const{relativePath:a,realRelativePath:b}=o,{data:{frontmatter:r}}=await t.cache.load(a,"markdown-frontmatter"),P=r?.metadata||{},F=await _(a,"markdown-frontmatter",r,t),p=L(F,a);let d=null;r?.sidebar&&(d=await G(r.sidebar,a,t.fs));let u=n;const l=q({realRelativePath:b,frontmatter:r,markdown:m,contentDir:h.contentDir});l&&(u=e.createTemplate(l.templateRef,l.templatePath)),r?.rbac&&(g("rbac")?O({content:{[a]:r.rbac}}):r.rbac=void 0),g("banner")||(r.banner=void 0),Y(o,t.fs,e),(p.length?p.reverse():[void 0]).forEach(v=>{e.addRoute({excludeFromSearch:r?.excludeFromSearch||!1,slug:v,fsPath:a,templateId:u,sharedData:d?[{id:d,key:"sidebar"}]:void 0,redirectFrom:Object.entries(r.redirects||{}).map(([c,{type:f}])=>({type:f,from:c})),[y]:r?.rbac,getNavText:async()=>(r?.seo?.title||await A(a,t)||"").toString(),metadata:{type:"markdown",...P},async getStaticData(c,f){return E(o,c,t,r,f)},getSearchDocuments:C(r,a,e.getSearchFacets,e.setSearchFacets),getAiDocumentsStore:N(e.getSearchFacets,r),serverPropsGetterIds:[S]})})}})},afterRoutesCreated:async(e,t)=>{const i=await M(t,e);e.setGlobalConfig({[D]:i})}}}export{ce as markdownPlugin};
@@ -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 p from"@redocly/theme/markdoc/default";import{reporter as g}from"../../../tools/notifiers/reporter.js";import*as u from"../../../../markdoc/nodes/index.js";import d from"../../../../markdoc/tags/index.js";import{normalizeCustomTags as l}from"../../../../markdoc/helpers/normalize-custom-tags.js";import{includes as h}from"./functions/includes.js";import{importUserTags as O}from"./import-user-tags.js";import{concat as y}from"./functions/concat.js";const T=p.tags;function b(s){const{tags:c,functions:e={},...r}=s,n={...c,...r},a=Object.entries(n),o=[],t=[];for(const[i,m]of a)i in f.nodes?o.push([i,m]):t.push([i,m]);return{nodes:Object.fromEntries(o),tags:Object.fromEntries(t),functions:e}}async function _(s="../../../esbuild/cache/server/",c=""){let e;try{e=(await O(s)).schema}catch(t){throw t.code==="ERR_MODULE_NOT_FOUND"?(g.printErrors(),new Error("Please fix the errors above and try again.")):t}const{tags:r={},nodes:n={},functions:a={}}=b(e),o={tags:{schemaDefinition:{render:"SchemaDefinition",attributes:{schemaRef:{type:String},exampleRef:{type:String},showReadOnly:{type:Boolean},showWriteOnly:{type:Boolean}}}}};return{nodes:{...u,...n},tags:{...d,...T,...l(r),...o.tags},functions:{...f.functions,...a,includes:h,concat:y}}}export{_ as getMarkdocOptions};
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
- /** Registers every file in an `@mcp` folder as one MCP tool, named after the file. */
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 d,join as p}from"node:path";import{logger as f}from"../../../tools/notifiers/logger.js";import{reporter as s}from"../../../tools/notifiers/reporter.js";import{CODE_MODE_TOOL_NAMES as h}from"../codemode/constants.js";import{ALL_DEFAULT_TOOL_NAMES as O}from"../docs-mcp/tool-schemas.js";import{extractToolDefinition as T}from"./extract-tool-definition.js";const E=/(^|\/)@mcp\/.*\.(ts|js)$/,M=/^[a-zA-Z0-9_-]{1,64}$/,C=new Set([...h,...O]);async function g(o,a,n){_(o,n);const u=new Set(o.getMcpTools().map(r=>r.name)),l=new Map;for(const r of a.fs.scan(E)){if(r.isVirtual||r.relativePath.endsWith(".d.ts"))continue;const{relativePath:t}=r,e=d(t).replace(/\.(ts|js)$/,"");if(!M.test(e)){await s.panicOnBuildContentError(`Invalid MCP tool file "${t}": the tool name "${e}" 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(e);if(c){await s.panicOnBuildContentError(`Duplicate MCP tool name "${e}": defined by both "${c}" and "${t}". Tool names are file names, so each file name must be unique across @mcp folders.`);continue}if(C.has(e)||u.has(e)){await s.panicOnBuildContentError(`Invalid MCP tool file "${t}": the tool name "${e}" is already used by a built-in MCP tool. Rename the file.`);continue}l.set(e,t);const m=p(o.contentDir,t),i=await T({toolName:e,absoluteSourcePath:m,contentDir:o.contentDir,serverOutDir:o.serverOutDir});if(!i.ok){await s.panicOnBuildContentError(`Invalid MCP tool file "${t}": ${i.errors.join(" ")}`);continue}!i.schema.outputSchema&&!n.warnedNoOutputSchemaTools.has(e)&&(n.warnedNoOutputSchemaTools.add(e),f.warn(`MCP tool "${e}" in %rp declares no \`outputSchema\`. Add one that describes the returned value.`,t)),o.addMcpTools(m,[i.schema]),n.registeredToolNames.push(e)}return n.registeredToolNames.length}function _(o,a){o.removeMcpTools(a.registeredToolNames),a.registeredToolNames=[]}export{_ as resetCustomMcpTools,g as scanCustomMcpTools};
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 $,join as D}from"node:path";import{MCP_ROUTE as k,PUBLIC_MCP_ROUTE as M}from"@redocly/theme/core/constants/mcp";import{logger as p}from"../../tools/notifiers/logger.js";import{reporter as F}from"../../tools/notifiers/reporter.js";import{isDefined as B}from"../../../utils/guards/is-defined.js";import{MCP_CREDENTIALS_HANDLER_ID as A,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 P,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 _}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 S}from"./constants.js";const b=$(U(import.meta.url));async function de(){let i;const m={registeredToolNames:[],warnedNoOutputSchemaTools: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 F.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(P(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(P(O,v)),G=Object.values(t.products||{}).map(o=>o?.name).filter(B),I=t.l10n?.locales?.map(o=>o.code)??a.fs.localeFolders,N=oe({products:G,locales:I,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:_(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||S,publicEndpoint:_(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||S,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:k,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(A,l),i.addApiRoute({slug:V,requestHandlerId:A,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};
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 +1 @@
1
- import g from"node:path";import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{slash as S}from"../../../utils/path/slash.js";import{canAccessFeature as y}from"../../utils/entitlements/can-access-feature.js";import{staticDataLoader as b}from"./loaders/static-data-loader.js";import{findFrontmatterSlugs as F,getSidebarSharedDataId as P,resolveFrontmatterSlugs as v}from"../utils.js";import{reactFrontmatterLoader as w}from"./loaders/react-frontmatter-loader.js";import{registerPageProps as D}from"../register-page-props.js";import{telemetryTraceStep as R}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as E}from"./search/search-resolver.js";async function x(){return{loaders:{"react-frontmatter":w},id:"react-pages",requiredEntitlements:["reactPages"],processContent:async(r,a)=>{await R("com.redocly.build.plugin.pages",async()=>{const{fs:o,cache:f}=a;for(const n of o.scan(/\.page\.tsx?$/)){const{relativePath:e,realRelativePath:l}=n;if(await a.isPathIgnored(e))continue;const p=r.createTemplate(S(e),g.resolve(o.cwd,l));D(n,o,r);const{data:t}=await f.load(e,"react-frontmatter"),u=await F(e,"react-frontmatter",t,a),s=v(u,e);let c=null;t?.sidebar&&(c=await P(t.sidebar,e,a.fs)),(s.length?s.reverse():[void 0]).forEach(i=>{r.addRoute({excludeFromSearch:t?.excludeFromSearch||!1,slug:i,templateId:p,fsPath:e,sharedData:c?[{id:c,key:"sidebar"}]:void 0,[h]:y("rbac")?t?.rbac:void 0,getNavText:async()=>t?.seo?.title,getStaticData:async(m,d)=>({props:await b({frontmatter:t,relativePath:e},a,d)}),getSearchDocuments:E(t,e,r.getSearchFacets,r.setSearchFacets)})});for(const[i,{to:m,type:d}]of Object.entries(t?.redirects||{}))r.addRedirect(i,{to:m||s[0],type:d||301})}})}}}export{x as customPagesPlugin};
1
+ import g from"node:path";import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{slash as S}from"../../../utils/path/slash.js";import{canAccessFeature as b}from"../../utils/entitlements/can-access-feature.js";import{staticDataLoader as y}from"./loaders/static-data-loader.js";import{findFrontmatterSlugs as F,getSidebarSharedDataId as P,resolveFrontmatterSlugs as v}from"../utils.js";import{reactFrontmatterLoader as w}from"./loaders/react-frontmatter-loader.js";import{registerPageProps as D}from"../register-page-props.js";import{telemetryTraceStep as R}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as E}from"./search/search-resolver.js";async function x(){return{loaders:{"react-frontmatter":w},id:"react-pages",requiredEntitlements:["reactPages"],processContent:async(r,a)=>{await R("com.redocly.build.plugin.pages",async()=>{const{fs:o,cache:f}=a;for(const n of o.scan(/\.page\.tsx?$/)){const{relativePath:e,realRelativePath:l}=n;if(await a.isPathIgnored(e))continue;const u=r.createTemplate(S(e),g.resolve(o.cwd,l));D(n,o,r);const{data:t}=await f.load(e,"react-frontmatter"),p=await F(e,"react-frontmatter",t,a),s=v(p,e);let c=null;t?.sidebar&&(c=await P(t.sidebar,e,a.fs)),(s.length?s.reverse():[void 0]).forEach(i=>{r.addRoute({excludeFromSearch:t?.excludeFromSearch||!1,slug:i,templateId:u,fsPath:e,sharedData:c?[{id:c,key:"sidebar"}]:void 0,[h]:b("rbac")?t?.rbac:void 0,getNavText:async()=>t?.seo?.title,getStaticData:async(m,d)=>({props:await y({frontmatter:t,relativePath:e},a,d)}),getSearchDocuments:E(t,e,r.getSearchFacets,r.setSearchFacets)})});for(const[i,{to:m,type:d}]of Object.entries(t?.redirects||{}))r.addRedirect(i,{to:m||s[0],type:d})}})}}}export{x as customPagesPlugin};
@@ -1,4 +1,11 @@
1
1
  import type { Store } from '../../../store.js';
2
2
  import type { LifecycleContext } from '../../../types';
3
- export declare function validateReactPages(store: Store, lifecycleContext: LifecycleContext): Promise<void>;
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 u}from"node:url";import{slash as d}from"../../../../utils/path/slash.js";import{logger as o}from"../../../tools/notifiers/logger.js";import{reporter as n}from"../../../tools/notifiers/reporter.js";import{getServerProps as p}from"../../../ssr/server-side-props/get-server-props.js";import{telemetry as f}from"../../../../cli/telemetry/index.js";async function x(r,i){try{n.clearPageRenderProblems();const e=r.getAllRoutes().filter(t=>t.fsPath.match(/\.page\.tsx?$/));if(!e.length)return;const l=o.startTiming();o.info("Validating react pages");const g=await P(r.serverOutDir);for(const t of e){const c=await r.resolveRouteStaticData(t,i),m=await p(t,null,c,r);let a;try{a=(await g(t,m,null,r,f,!0)).error}catch(s){a=s}a&&n.reportPageRenderError({message:a.name==="PageMissingDefaultExportError"?a.message:`Runtime error: ${a.message}`,sourceFileRelativePath:t.fsPath})}o.infoTime(l,`Validated ${e.length} React pages`)}catch(e){await n.panicOnBuild(`Failed to validate react pages: ${e.message}`)}}async function P(r){const e=await import(u(`${d(r)}/index.mjs`)+"?only-exports=true");if(!e.renderPage)throw new Error("renderPage function not found in bundle");return e.renderPage}export{x as validateReactPages};
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};