@redocly/redoc-reef 0.139.0-next.7 → 0.139.0

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 (111) hide show
  1. package/CHANGELOG.md +253 -0
  2. package/dist/cli/develop.js +1 -1
  3. package/dist/cli/eject/resolveEjectParams.js +1 -1
  4. package/dist/client/app/Sidebar/PoweredByRedocly.d.ts +14 -0
  5. package/dist/client/app/Sidebar/PoweredByRedocly.js +40 -0
  6. package/dist/client/app/Sidebar/Sidebar.js +3 -3
  7. package/dist/client/app/hooks/useL10nConfig.d.ts +1 -0
  8. package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.js +1 -1
  9. package/dist/client/app/utils/programmatic-scroll.js +1 -1
  10. package/dist/client/app/webmcp/tools/api-tools.js +1 -1
  11. package/dist/client/app/webmcp/tools/site-tools.js +2 -2
  12. package/dist/client/app/webmcp/useWebMcpTools.js +1 -1
  13. package/dist/client/browser-entry.js +2 -2
  14. package/dist/client/templates/api-docs/template.js +5 -3
  15. package/dist/constants/common.d.ts +2 -0
  16. package/dist/constants/common.js +1 -1
  17. package/dist/constants/l10n/langs/ar.js +1 -1
  18. package/dist/constants/l10n/langs/de.js +1 -1
  19. package/dist/constants/l10n/langs/en.js +1 -1
  20. package/dist/constants/l10n/langs/es.js +1 -1
  21. package/dist/constants/l10n/langs/fr.js +1 -1
  22. package/dist/constants/l10n/langs/hi.js +1 -1
  23. package/dist/constants/l10n/langs/it.js +1 -1
  24. package/dist/constants/l10n/langs/ja.js +1 -1
  25. package/dist/constants/l10n/langs/ko.js +1 -1
  26. package/dist/constants/l10n/langs/pl.js +1 -1
  27. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  28. package/dist/constants/l10n/langs/pt.js +1 -1
  29. package/dist/constants/l10n/langs/ru.js +1 -1
  30. package/dist/constants/l10n/langs/uk.js +1 -1
  31. package/dist/constants/l10n/langs/zh.js +1 -1
  32. package/dist/markdoc/helpers/get-inner-text.d.ts +2 -0
  33. package/dist/markdoc/helpers/get-inner-text.js +2 -2
  34. package/dist/markdoc/helpers/remove-markdoc-tags.js +1 -1
  35. package/dist/server/constants/entitlements.d.ts +2 -2
  36. package/dist/server/constants/entitlements.js +1 -1
  37. package/dist/server/entitlements/entitlements-provider.d.ts +8 -2
  38. package/dist/server/entitlements/entitlements-provider.js +1 -1
  39. package/dist/server/entitlements/is-valid-plan.d.ts +2 -2
  40. package/dist/server/entitlements/is-valid-plan.js +1 -1
  41. package/dist/server/fs/content-fs.js +1 -1
  42. package/dist/server/fs/utils/external-ref-resolver.js +2 -2
  43. package/dist/server/fs/utils/is-translation-fallback.d.ts +9 -0
  44. package/dist/server/fs/utils/is-translation-fallback.js +1 -0
  45. package/dist/server/node-bundle-entry.js +1 -1
  46. package/dist/server/plugins/api-docs/get-server-props.js +1 -1
  47. package/dist/server/plugins/api-docs/index.js +1 -1
  48. package/dist/server/plugins/api-docs/loader.js +3 -3
  49. package/dist/server/plugins/api-docs/search/get-ai-search-documents.d.ts +6 -3
  50. package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +69 -69
  51. package/dist/server/plugins/api-docs/utils/inject-metadata.d.ts +19 -0
  52. package/dist/server/plugins/api-docs/utils/inject-metadata.js +1 -0
  53. package/dist/server/plugins/arazzo-docs/arazzo-doc-loader.js +2 -2
  54. package/dist/server/plugins/arazzo-docs/index.js +1 -1
  55. package/dist/server/plugins/catalog-entities/extensions/extractors/api-description/openapi-entities-extractor.js +1 -1
  56. package/dist/server/plugins/catalog-entities/template/index.js +1 -1
  57. package/dist/server/plugins/config-parser/index.js +1 -1
  58. package/dist/server/plugins/config-parser/loaders/versions-config-loader.js +1 -1
  59. package/dist/server/plugins/default-theme/resolve-logo.js +1 -1
  60. package/dist/server/plugins/dev-onboarding/api/routes/products.js +1 -1
  61. package/dist/server/plugins/l10n/index.js +1 -1
  62. package/dist/server/plugins/markdown/attribute-resolvers/resolve-json-example-ref.js +1 -1
  63. package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.js +1 -1
  64. package/dist/server/plugins/markdown/get-server-props.js +1 -1
  65. package/dist/server/plugins/markdown/index.js +1 -1
  66. package/dist/server/plugins/markdown/markdoc/plugins/utils.js +1 -1
  67. package/dist/server/plugins/markdown/markdoc/resolve-raw-partials.js +1 -1
  68. package/dist/server/plugins/markdown/markdown-static-data-loader.js +1 -1
  69. package/dist/server/plugins/markdown/read-file-content.js +1 -1
  70. package/dist/server/plugins/markdown/search/search-resolver.js +1 -1
  71. package/dist/server/plugins/mcp/gateway-mcp/allowed-http-methods.d.ts +0 -5
  72. package/dist/server/plugins/mcp/gateway-mcp/allowed-http-methods.js +1 -1
  73. package/dist/server/plugins/mcp/gateway-mcp/caller-api-calls.d.ts +3 -4
  74. package/dist/server/plugins/mcp/gateway-mcp/caller-api-calls.js +1 -1
  75. package/dist/server/plugins/nav-utils.js +1 -1
  76. package/dist/server/plugins/pages/index.js +1 -1
  77. package/dist/server/plugins/register-page-props.d.ts +1 -1
  78. package/dist/server/plugins/register-page-props.js +1 -1
  79. package/dist/server/plugins/sidebars/index.js +1 -1
  80. package/dist/server/plugins/sidebars/utils.js +1 -1
  81. package/dist/server/providers/database/has-project-database.js +1 -1
  82. package/dist/server/store.d.ts +3 -1
  83. package/dist/server/store.js +1 -1
  84. package/dist/server/types/index.d.ts +1 -0
  85. package/dist/server/types/plugins/markdown.d.ts +1 -0
  86. package/dist/server/types/static-files.d.ts +6 -0
  87. package/dist/server/types/static-files.js +0 -0
  88. package/dist/server/utils/content/build-static-file-paths.d.ts +15 -0
  89. package/dist/server/utils/content/build-static-file-paths.js +1 -0
  90. package/dist/server/utils/find-disallowed-packages.d.ts +16 -0
  91. package/dist/server/utils/find-disallowed-packages.js +1 -0
  92. package/dist/server/utils/is-realm-or-reef.js +1 -1
  93. package/dist/server/utils/lifecycle-hooks.js +1 -1
  94. package/dist/server/utils/rbac-expand.d.ts +4 -0
  95. package/dist/server/utils/rbac-expand.js +1 -1
  96. package/dist/server/utils/rbac.js +1 -1
  97. package/dist/server/utils/redirects/find-redirect.d.ts +4 -3
  98. package/dist/server/utils/redirects/find-redirect.js +1 -1
  99. package/dist/server/utils/resolve-asset-path.js +1 -1
  100. package/dist/server/utils/validate-allowed-packages.d.ts +7 -0
  101. package/dist/server/utils/validate-allowed-packages.js +2 -0
  102. package/dist/server/web-server/auth.d.ts +2 -0
  103. package/dist/server/web-server/auth.js +3 -3
  104. package/dist/server/web-server/jwt/jwt.js +1 -1
  105. package/dist/server/web-server/middleware/catalogAuthMiddleware.js +1 -1
  106. package/dist/server/web-server/routes/mcp-routes/mcp-client-metadata.d.ts +3 -3
  107. package/dist/server/web-server/routes/mcp-routes/mcp-client-metadata.js +1 -1
  108. package/dist/server/web-server/routes/mcp-routes/mcp-oauth.js +1 -1
  109. package/dist/types/entitlements.d.ts +10 -1
  110. package/dist/types/global-data.d.ts +4 -0
  111. package/package.json +8 -8
@@ -1 +1 @@
1
- import{simplifyAstStructure as h}from"@redocly/api-docs";import{storeDefinitionBundles as p}from"./store-definition-bundles.js";import{arazzoDocLoader as y,arazzoDocsLoader as D}from"./arazzo-doc-loader.js";import{telemetryTraceStep as P}from"../../../cli/telemetry/helpers/trace-step.js";const u="arazzo-docs-";async function $(k){let l=[];return{id:"arazzo",loaders:{"arazzo-doc":y,"arazzo-docs":D},processContent:async(e,o)=>{await P("com.redocly.build.plugin.arazzoDocs",async()=>{for(const t of await o.fs.scan(/(\.ya?ml|\.json)$/))if(!await o.isPathIgnored(t.relativePath))try{const{data:a,compoundHash:n}=await o.cache.load(t.realRelativePath,"arazzo-doc");if(!a?.length)continue;l=a.map(({markdocChunks:r,relativePath:c,isVirtual:i,customOutputRelativeFile:s,realRelativePath:d})=>({chunks:r,relativePath:c,realRelativePath:d,isVirtual:s!=null||t.isVirtual||i})),p(a,e.outdir,n);for(const r of a){const c=`${u}${r.relativePath}`;await e.createSharedData(c,{document:r.document})}}catch(a){console.error(a)}})},afterRoutesCreated:async(e,o)=>{for(const{chunks:t,relativePath:a,isVirtual:n,realRelativePath:r}of l)await o.cache.load(a,{loader:async function(){await o.cache.load(r,"arazzo-doc");for(const{node:i,markdown:s,pointer:d,key:z,relativePath:m}of t){const{ast:f}=await e.parseMarkdoc({input:{content:s,relativePath:d,isVirtual:n},context:o,deps:{sharedDataIds:[`${u}${m}`]}});i[`x-parsed-md-${z}`]={result:h(f)}}},name:"arazzo-markdoc-inline-parser"})}}}export{$ as arazzoDocsPlugin};
1
+ import{simplifyAstStructure as h}from"@redocly/api-docs";import{storeDefinitionBundles as p}from"./store-definition-bundles.js";import{arazzoDocLoader as y,arazzoDocsLoader as D}from"./arazzo-doc-loader.js";import{telemetryTraceStep as P}from"../../../cli/telemetry/helpers/trace-step.js";const u="arazzo-docs-";async function $(k){let l=[];return{id:"arazzo",loaders:{"arazzo-doc":y,"arazzo-docs":D},processContent:async(e,o)=>{await P("com.redocly.build.plugin.arazzoDocs",async()=>{for(const t of o.fs.scan(/(\.ya?ml|\.json)$/))if(!await o.isPathIgnored(t.relativePath))try{const{data:a,compoundHash:n}=await o.cache.load(t.realRelativePath,"arazzo-doc");if(!a?.length)continue;l=a.map(({markdocChunks:r,relativePath:c,isVirtual:s,customOutputRelativeFile:i,realRelativePath:d})=>({chunks:r,relativePath:c,realRelativePath:d,isVirtual:i!=null||t.isVirtual||s})),p(a,e.outdir,n);for(const r of a){const c=`${u}${r.relativePath}`;await e.createSharedData(c,{document:r.document})}}catch(a){console.error(a)}})},afterRoutesCreated:async(e,o)=>{for(const{chunks:t,relativePath:a,isVirtual:n,realRelativePath:r}of l)await o.cache.load(a,{loader:async function(){await o.cache.load(r,"arazzo-doc");for(const{node:s,markdown:i,pointer:d,key:z,relativePath:m}of t){const{ast:f}=await e.parseMarkdoc({input:{content:i,relativePath:d,isVirtual:n},context:o,deps:{sharedDataIds:[`${u}${m}`]}});s[`x-parsed-md-${z}`]={result:h(f)}}},name:"arazzo-markdoc-inline-parser"})}}}export{$ as arazzoDocsPlugin};
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as R}from"@redocly/config";import{removeLeadingSlash as O}from"@redocly/theme/core/utils";import{toKebabCase as y}from"../../../../../../utils/string/to-kebab-case.js";import{promiseMapLimit as E}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as x}from"../../../../../utils/async/promise-map-limit-with-status.js";import{extractTeamsFromScopeItems as $}from"../../../../../utils/rbac.js";import{removeMarkdocTags as S}from"../../../../../../markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as b}from"./base.js";import{OpenapiSchemaResolver as w}from"../../../utils/openapi-schema-resolver.js";import{extractPartsFromComponentsRef as N}from"../../../utils/extract-parts-from-components-ref.js";import{isValidTagName as d}from"../../../utils/is-valid-tag-name.js";const A=["get","post","put","delete","patch"],T=15,v=15;class V extends b{#e;constructor(e){super("openapi",e),this.#e=e.context.logger}async loadApiDescriptions(){return(await this.actions.loadApiDocuments(this.context)).filter(o=>o.type==="openapi").map(o=>({...o,isVirtual:o.isVirtual??!1}))}mapApiDescriptionToEntity(e,o){const n=O(e.realRelativePath),s=e.document.info.title,t=this.resolveEntityKey({realRelativePath:e.realRelativePath,customKey:e.document["x-redocly-catalog-key"]});return{type:this.type,key:t,title:s,summary:S(typeof e.document.info.description=="string"?e.document.info.description:void 0),tags:e.document.tags?.filter(a=>a.name&&d(a.name)).map(a=>a.name),metadata:{specType:this.specType,descriptionFile:n},version:o}}async processApiDescription(e,o,n,s){if(w.clearSchemaCache(),!e?.document)throw new Error("OpenAPI definition is missing a bundled document");const t=this.getRbacTeamsForDefinition(e.relativePath),a=this.mapApiDescriptionToEntity(e,n);await this.catalogEntitiesService.createEntity({entity:a,sourceFile:e.realRelativePath,fileHash:e.hash,source:"file",isRootEntity:!0,rbacTeams:t,revision:o}),s.delete(`${a.key}:${n}`),await this.#o(e,a.key,a.version,n,o,s,t);const r=this.#n(e.document.paths);if(r.length!==0){const i=(await x(r,T,async({operation:m,path:h,method:f})=>{if(!m.operationId)return;const l=await this.#c(m,h,f,e,a.key,a.version,o,t);s.delete(`${l}:${n}`)},this.#e)).count.failed;i>0&&this.#e.warn(`Extraction completed with ${i} failures out of ${r.length} operations for ${a.key}`)}}#n(e){return Object.entries(e??{}).flatMap(([o,n])=>A.filter(s=>n[s]).map(s=>{const t=n[s];if(!t)throw new Error(`Operation not found for method ${s} on path ${o}`);return{operation:t,path:o,method:s.toUpperCase()}}))}async#o(e,o,n,s,t,a,r){const c=e.document.components?.schemas;if(!c)return;const i=Object.entries(c);i.length!==0&&await E(i,v,async([m,h])=>{const f=`${o}-${y(m)}`,l=await this.#r({schemaName:m,schema:h,description:e,parentKey:o,parentVersion:n,parentRevision:t,rbacTeams:r});a.delete(`${f}:${s}`),l&&await this.catalogEntitiesService.createEntityRelation({sourceKey:o,sourceVersion:n,sourceRevision:t,type:"uses",targetKey:l.key,targetVersion:n,targetRevision:t,sourceFile:e.realRelativePath,fileHash:e.hash})})}async#r({schemaName:e,schema:o,description:n,parentKey:s,parentVersion:t,parentRevision:a,rbacTeams:r}){const c=w.resolveSchemaRefs(o,n.document),i=JSON.stringify(c),m=c[R]?$(c[R]):r,h=$(c["x-rbac"]),f={type:"data-schema",key:`${s}-${y(e)}`,title:e,summary:(typeof c.description=="string"?c.description:c.title)??null,tags:[],metadata:{specType:this.specType,schema:i},version:t};try{return await this.catalogEntitiesService.createEntity({entity:f,sourceFile:n.realRelativePath,fileHash:n.hash,rbacTeams:h.length?h:m,source:"file",revision:a})}catch(l){return this.#e.error(`Failed to create data schema entity for ${e}: ${l instanceof Error?l.message:"Unknown error"}`),null}}async#c(e,o,n,s,t,a,r,c){const i=`${t}-${y(`${e.operationId}`)}`,m=await Promise.all([this.#h(e.requestBody??null,s),this.#l(e.responses??{},s)]),h=m[0].schemaNames,f=m[1].schemaNames;m[0].errors.length>0&&this.#e.warn(`Schema extraction errors for operation ${e.operationId}: ${m[0].errors.join(", ")}`),m[1].errors.length>0&&this.#e.warn(`Response schema extraction errors for operation ${e.operationId}: ${m[1].errors.join(", ")}`);const l=h.map(p=>`${t}-${y(p)}`),u=f.map(p=>`${t}-${y(p)}`),g=await this.#p({path:o,method:n,operation:e,requestBodySchemasKeys:l,responseSchemasKeys:u,description:s,parentKey:t,parentVersion:a,parentRevision:r,rbacTeams:c});return g&&await Promise.all([this.#i(h,e.operationId??"",s.realRelativePath,s.hash,t,a,r),this.#m(f,e.operationId??"",s.realRelativePath,s.hash,t,a,r),this.#y({apiOperationKey:g.key,operationRelations:e["x-catalogRelations"],descriptionUniqueKey:t,description:s,parentVersion:a,parentRevision:r})]),i}async#i(e,o,n,s,t,a,r){return e.length===0||!o?[]:await this.#s(e,o,n,s,t,a,r)}async#m(e,o,n,s,t,a,r){return e.length===0||!o?[]:await this.#s(e,o,n,s,t,a,r)}#h(e,o){const n=[],s=[];try{if(e&&"content"in e&&e.content)for(const t of Object.values(e.content)){const a=this.#a(t,o);if(!a)continue;const r=this.#t(a);r?.componentType==="schemas"&&r.componentName&&n.push(r.componentName)}if(e&&e.$ref){const t=this.#t(e.$ref);if(t?.componentType==="requestBodies"&&t.componentName){const a=o.document.components?.requestBodies?.[t.componentName];if(a&&"content"in a)for(const r of Object.values(a.content??{})){const c=this.#a(r,o);if(!c)continue;const i=this.#t(c);i?.componentType==="schemas"&&i.componentName&&n.push(i.componentName)}}}}catch(t){s.push(`Failed to extract request body schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(n)],errors:s}}#l(e,o){const n=[],s=[];try{for(const t of Object.values(e)){if(t&&"content"in t&&t.content)for(const a of Object.values(t.content)){const r=this.#a(a,o);if(!r)continue;const c=this.#t(r);c?.componentType==="schemas"&&c.componentName&&n.push(c.componentName)}if(t&&t.$ref){const a=this.#t(t.$ref);if(a?.componentType==="responses"&&a.componentName){const r=o.document.components?.responses?.[a.componentName];if(r&&"content"in r)for(const c of Object.values(r.content??{})){const i=this.#a(c,o);if(!i)continue;const m=this.#t(i);m?.componentType==="schemas"&&m.componentName&&n.push(m.componentName)}}}}}catch(t){s.push(`Failed to extract response schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(n)],errors:s}}#a(e,o){const n=new Set;let s=e;for(;s&&"$ref"in s;){const t=this.#t(s.$ref),a=t?.componentName;if(t?.componentType!=="mediaTypes"||!a||n.has(a))return;n.add(a),s=o.document.components?.mediaTypes?.[a]}return s?.schema?.$ref}#t(e){try{return N(e)}catch{return{componentType:"",componentName:null}}}async#s(e,o,n,s,t,a,r){return e.length===0?[]:await E(e,v,async c=>await this.#f({operationId:o,schemaName:c,descriptionSourceFile:n,descriptionHash:s,parentKey:t,parentVersion:a,parentRevision:r}))}async#f({operationId:e,schemaName:o,descriptionSourceFile:n,descriptionHash:s,parentKey:t,parentVersion:a,parentRevision:r}){const c=`${t}-${y(o)}`;try{return await this.catalogEntitiesService.createEntityRelation({sourceKey:`${t}-${y(e)}`,type:"uses",targetKey:c,sourceFile:n,fileHash:s,sourceVersion:a,targetVersion:a,sourceRevision:r,targetRevision:r}),c}catch(i){throw this.#e.error(`Failed to create relation between operation ${e} and schema ${o}: ${i instanceof Error?i.message:"Unknown error"}`),i}}async#p({path:e,method:o,operation:n,requestBodySchemasKeys:s,responseSchemasKeys:t,description:a,parentKey:r,parentVersion:c,parentRevision:i,rbacTeams:m}){const h=`${n.operationId}`,f=`${r}-${y(h)}`,l=n[R]?$(n[R]):m,u=$(n["x-rbac"]),g={type:"api-operation",key:f,title:h,summary:S(n.summary),tags:n.tags?.filter(p=>d(p)),metadata:{path:e,method:o,payload:s,responses:t},version:c};try{return await this.catalogEntitiesService.createEntity({entity:g,sourceFile:a.realRelativePath,fileHash:a.hash,rbacTeams:u.length>0?u:l,source:"file",revision:i})}catch(p){return this.#e.error(`Failed to create API operation entity for ${h}: ${p instanceof Error?p.message:"Unknown error"}`),null}}async#y({apiOperationKey:e,operationRelations:o,descriptionUniqueKey:n,description:s,parentVersion:t,parentRevision:a}){try{await this.catalogEntitiesService.createEntityRelation({sourceKey:e,type:"partOf",targetKey:n,sourceFile:s.realRelativePath,fileHash:s.hash,sourceVersion:t,targetVersion:t,sourceRevision:a,targetRevision:a}),await this.#u(e,s,o,t,a)}catch(r){this.#e.error(`Failed to create API operation relations for ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}async#u(e,o,n,s,t){n?.length&&await E(n,T,async a=>{try{this.validateEntityRelationFileSchema(a),await this.catalogEntitiesService.createEntityRelation({sourceKey:e,type:a.type,targetKey:a.key,sourceFile:o.realRelativePath,fileHash:o.hash,sourceVersion:s,targetVersion:"",sourceRevision:t,targetRevision:""})}catch(r){this.context.logger.warn(`Error creating entity relation for operation ${e} based on custom property: ${r instanceof Error?r.message:"Unknown error"}`)}})}}export{V as OpenApiEntitiesExtractor};
1
+ import{REDOCLY_TEAMS_RBAC as g}from"@redocly/config";import{removeLeadingSlash as x}from"@redocly/theme/core/utils";import{toKebabCase as p}from"../../../../../../utils/string/to-kebab-case.js";import{promiseMapLimit as S}from"../../../../../utils/async/promise-map-limit.js";import{promiseMapLimitWithStatus as b}from"../../../../../utils/async/promise-map-limit-with-status.js";import{extractTeamsFromScopeItems as R}from"../../../../../utils/rbac.js";import{removeMarkdocTags as w}from"../../../../../../markdoc/helpers/remove-markdoc-tags.js";import{BaseApiEntitiesExtractor as N}from"./base.js";import{OpenapiSchemaResolver as d}from"../../../utils/openapi-schema-resolver.js";import{extractPartsFromComponentsRef as A}from"../../../utils/extract-parts-from-components-ref.js";import{isValidTagName as T}from"../../../utils/is-valid-tag-name.js";const k=["get","post","put","delete","patch"],v=15,O=15;class _ extends N{#e;constructor(e){super("openapi",e),this.#e=e.context.logger}async loadApiDescriptions(){return(await this.actions.loadApiDocuments(this.context)).filter(o=>o.type==="openapi").map(o=>({...o,isVirtual:o.isVirtual??!1}))}mapApiDescriptionToEntity(e,o){const n=x(e.realRelativePath),s=e.document.info.title,t=this.resolveEntityKey({realRelativePath:e.realRelativePath,customKey:e.document["x-redocly-catalog-key"]});return{type:this.type,key:t,title:s,summary:w(typeof e.document.info.description=="string"?e.document.info.description:void 0),tags:e.document.tags?.filter(a=>a.name&&T(a.name)).map(a=>a.name),metadata:{specType:this.specType,descriptionFile:n},version:o}}async processApiDescription(e,o,n,s){if(d.clearSchemaCache(),!e?.document)throw new Error("OpenAPI definition is missing a bundled document");const t=this.getRbacTeamsForDefinition(e.relativePath),a=this.mapApiDescriptionToEntity(e,n);await this.catalogEntitiesService.createEntity({entity:a,sourceFile:e.realRelativePath,fileHash:e.hash,source:"file",isRootEntity:!0,rbacTeams:t,revision:o}),s.delete(`${a.key}:${n}`),await this.#o(e,a.key,a.version,n,o,s,t);const r=this.#n(e.document.paths);if(r.length!==0){const i=(await b(r,v,async({operation:m,path:h,method:f})=>{if(!m.operationId)return;const l=await this.#c(m,h,f,e,a.key,a.version,o,t);s.delete(`${l}:${n}`)},this.#e)).count.failed;i>0&&this.#e.warn(`Extraction completed with ${i} failures out of ${r.length} operations for ${a.key}`)}}#n(e){return Object.entries(e??{}).flatMap(([o,n])=>k.filter(s=>n[s]).map(s=>{const t=n[s];if(!t)throw new Error(`Operation not found for method ${s} on path ${o}`);return{operation:t,path:o,method:s.toUpperCase()}}))}async#o(e,o,n,s,t,a,r){const c=e.document.components?.schemas;if(!c)return;const i=Object.entries(c);i.length!==0&&await S(i,O,async([m,h])=>{const f=`${o}-${p(m)}`,l=await this.#r({schemaName:m,schema:h,description:e,parentKey:o,parentVersion:n,parentRevision:t,rbacTeams:r});a.delete(`${f}:${s}`),l&&await this.catalogEntitiesService.createEntityRelation({sourceKey:o,sourceVersion:n,sourceRevision:t,type:"uses",targetKey:l.key,targetVersion:n,targetRevision:t,sourceFile:e.realRelativePath,fileHash:e.hash})})}async#r({schemaName:e,schema:o,description:n,parentKey:s,parentVersion:t,parentRevision:a,rbacTeams:r}){const c=d.resolveSchemaRefs(o,n.document),i=JSON.stringify(c),m=c[g]?R(c[g]):r,h=R(c["x-rbac"]),f={type:"data-schema",key:`${s}-${p(e)}`,title:e,summary:(typeof c.description=="string"?c.description:c.title)??null,tags:[],metadata:{specType:this.specType,schema:i},version:t};try{return await this.catalogEntitiesService.createEntity({entity:f,sourceFile:n.realRelativePath,fileHash:n.hash,rbacTeams:h.length?h:m,source:"file",revision:a})}catch(l){return this.#e.error(`Failed to create data schema entity for ${e}: ${l instanceof Error?l.message:"Unknown error"}`),null}}async#c(e,o,n,s,t,a,r,c){const i=`${t}-${p(`${e.operationId}`)}`,m=this.#h(e.requestBody??null,s),h=this.#l(e.responses??{},s),f=m.schemaNames,l=h.schemaNames;m.errors.length>0&&this.#e.warn(`Schema extraction errors for operation ${e.operationId}: ${m.errors.join(", ")}`),h.errors.length>0&&this.#e.warn(`Response schema extraction errors for operation ${e.operationId}: ${h.errors.join(", ")}`);const u=f.map(E=>`${t}-${p(E)}`),$=l.map(E=>`${t}-${p(E)}`),y=await this.#p({path:o,method:n,operation:e,requestBodySchemasKeys:u,responseSchemasKeys:$,description:s,parentKey:t,parentVersion:a,parentRevision:r,rbacTeams:c});return y&&await Promise.all([this.#i(f,e.operationId??"",s.realRelativePath,s.hash,t,a,r),this.#m(l,e.operationId??"",s.realRelativePath,s.hash,t,a,r),this.#y({apiOperationKey:y.key,operationRelations:e["x-catalogRelations"],descriptionUniqueKey:t,description:s,parentVersion:a,parentRevision:r})]),i}async#i(e,o,n,s,t,a,r){return e.length===0||!o?[]:await this.#s(e,o,n,s,t,a,r)}async#m(e,o,n,s,t,a,r){return e.length===0||!o?[]:await this.#s(e,o,n,s,t,a,r)}#h(e,o){const n=[],s=[];try{if(e&&"content"in e&&e.content)for(const t of Object.values(e.content)){const a=this.#a(t,o);if(!a)continue;const r=this.#t(a);r?.componentType==="schemas"&&r.componentName&&n.push(r.componentName)}if(e&&e.$ref){const t=this.#t(e.$ref);if(t?.componentType==="requestBodies"&&t.componentName){const a=o.document.components?.requestBodies?.[t.componentName];if(a&&"content"in a)for(const r of Object.values(a.content??{})){const c=this.#a(r,o);if(!c)continue;const i=this.#t(c);i?.componentType==="schemas"&&i.componentName&&n.push(i.componentName)}}}}catch(t){s.push(`Failed to extract request body schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(n)],errors:s}}#l(e,o){const n=[],s=[];try{for(const t of Object.values(e)){if(t&&"content"in t&&t.content)for(const a of Object.values(t.content)){const r=this.#a(a,o);if(!r)continue;const c=this.#t(r);c?.componentType==="schemas"&&c.componentName&&n.push(c.componentName)}if(t&&t.$ref){const a=this.#t(t.$ref);if(a?.componentType==="responses"&&a.componentName){const r=o.document.components?.responses?.[a.componentName];if(r&&"content"in r)for(const c of Object.values(r.content??{})){const i=this.#a(c,o);if(!i)continue;const m=this.#t(i);m?.componentType==="schemas"&&m.componentName&&n.push(m.componentName)}}}}}catch(t){s.push(`Failed to extract response schemas: ${t instanceof Error?t.message:"Unknown error"}`)}return{schemaNames:[...new Set(n)],errors:s}}#a(e,o){const n=new Set;let s=e;for(;s&&"$ref"in s;){const t=this.#t(s.$ref),a=t?.componentName;if(t?.componentType!=="mediaTypes"||!a||n.has(a))return;n.add(a),s=o.document.components?.mediaTypes?.[a]}return s?.schema?.$ref}#t(e){try{return A(e)}catch{return{componentType:"",componentName:null}}}async#s(e,o,n,s,t,a,r){return e.length===0?[]:await S(e,O,async c=>await this.#f({operationId:o,schemaName:c,descriptionSourceFile:n,descriptionHash:s,parentKey:t,parentVersion:a,parentRevision:r}))}async#f({operationId:e,schemaName:o,descriptionSourceFile:n,descriptionHash:s,parentKey:t,parentVersion:a,parentRevision:r}){const c=`${t}-${p(o)}`;try{return await this.catalogEntitiesService.createEntityRelation({sourceKey:`${t}-${p(e)}`,type:"uses",targetKey:c,sourceFile:n,fileHash:s,sourceVersion:a,targetVersion:a,sourceRevision:r,targetRevision:r}),c}catch(i){throw this.#e.error(`Failed to create relation between operation ${e} and schema ${o}: ${i instanceof Error?i.message:"Unknown error"}`),i}}async#p({path:e,method:o,operation:n,requestBodySchemasKeys:s,responseSchemasKeys:t,description:a,parentKey:r,parentVersion:c,parentRevision:i,rbacTeams:m}){const h=`${n.operationId}`,f=`${r}-${p(h)}`,l=n[g]?R(n[g]):m,u=R(n["x-rbac"]),$={type:"api-operation",key:f,title:h,summary:w(n.summary),tags:n.tags?.filter(y=>T(y)),metadata:{path:e,method:o,payload:s,responses:t},version:c};try{return await this.catalogEntitiesService.createEntity({entity:$,sourceFile:a.realRelativePath,fileHash:a.hash,rbacTeams:u.length>0?u:l,source:"file",revision:i})}catch(y){return this.#e.error(`Failed to create API operation entity for ${h}: ${y instanceof Error?y.message:"Unknown error"}`),null}}async#y({apiOperationKey:e,operationRelations:o,descriptionUniqueKey:n,description:s,parentVersion:t,parentRevision:a}){try{await this.catalogEntitiesService.createEntityRelation({sourceKey:e,type:"partOf",targetKey:n,sourceFile:s.realRelativePath,fileHash:s.hash,sourceVersion:t,targetVersion:t,sourceRevision:a,targetRevision:a}),await this.#u(e,s,o,t,a)}catch(r){this.#e.error(`Failed to create API operation relations for ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}async#u(e,o,n,s,t){n?.length&&await S(n,v,async a=>{try{this.validateEntityRelationFileSchema(a),await this.catalogEntitiesService.createEntityRelation({sourceKey:e,type:a.type,targetKey:a.key,sourceFile:o.realRelativePath,fileHash:o.hash,sourceVersion:s,targetVersion:"",sourceRevision:t,targetRevision:""})}catch(r){this.context.logger.warn(`Error creating entity relation for operation ${e} based on custom property: ${r instanceof Error?r.message:"Unknown error"}`)}})}}export{_ as OpenApiEntitiesExtractor};
@@ -1 +1 @@
1
- import*as t from"react";import{useMemo as l}from"react";import{QueryClientProvider as c,QueryClient as m}from"@tanstack/react-query";import{RedocSchema as u,StoreProvider as i,GraphQLTypeViewByName as d,MarkdownAdapterProvider as n,createMarkdocAdapter as f,buildGraphqlStoreFromSdl as s}from"@redocly/api-docs";import{Catalog as y}from"@redocly/theme/components/Catalog/Catalog";import{CatalogEntity as p}from"@redocly/theme/components/Catalog/CatalogEntity/CatalogEntity";import{NotFound as h}from"@redocly/theme/layouts/NotFound";const E=new m({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),o=f();function S({sdl:e,typeName:a}){const r=l(()=>{try{return s(e)}catch{return null}},[e]);return r?t.createElement(i,{apiStore:r,options:{specType:"graphql"}},t.createElement(n,{value:o},t.createElement(d,{typeName:a,fieldExpandLevel:0}))):null}function w({pageProps:e}){return e.status==="notFound"?t.createElement(h,null):t.createElement(c,{client:E},"entities"in e&&t.createElement(y,{entitiesTypes:e.entitiesTypes,catalogConfig:e.catalogConfig,filters:e.filters,initialEntitiesList:e.entities,catalogSwitcherItems:e.catalogSwitcherItems,initialViewMode:e.initialViewMode}),"entity"in e&&t.createElement(n,{value:o},t.createElement(p,{RedocSchema:u,StoreProvider:i,GraphqlTypeRenderer:S})))}export{w as default};
1
+ import*as t from"react";import{useMemo as l}from"react";import{QueryClientProvider as m,QueryClient as c}from"@tanstack/react-query";import{RedocSchema as u,StoreProvider as i,GraphQLTypeViewByName as d,MarkdownAdapterProvider as n,createMarkdocAdapter as f}from"@redocly/api-docs";import{buildGraphqlStoreFromSdl as s}from"@redocly/api-docs/lib/adapters/graphql/buildStoreFromSdl.js";import{Catalog as p}from"@redocly/theme/components/Catalog/Catalog";import{CatalogEntity as y}from"@redocly/theme/components/Catalog/CatalogEntity/CatalogEntity";import{NotFound as h}from"@redocly/theme/layouts/NotFound";const E=new c({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),o=f();function S({sdl:e,typeName:a}){const r=l(()=>{try{return s(e)}catch{return null}},[e]);return r?t.createElement(i,{apiStore:r,options:{specType:"graphql"}},t.createElement(n,{value:o},t.createElement(d,{typeName:a,fieldExpandLevel:0}))):null}function w({pageProps:e}){return e.status==="notFound"?t.createElement(h,null):t.createElement(m,{client:E},"entities"in e&&t.createElement(p,{entitiesTypes:e.entitiesTypes,catalogConfig:e.catalogConfig,filters:e.filters,initialEntitiesList:e.entities,catalogSwitcherItems:e.catalogSwitcherItems,initialViewMode:e.initialViewMode}),"entity"in e&&t.createElement(n,{value:o},t.createElement(y,{RedocSchema:u,StoreProvider:i,GraphqlTypeRenderer:S})))}export{w as default};
@@ -1 +1 @@
1
- import A from"path";import{REDOCLY_ROUTE_RBAC as b,REDOCLY_TEAMS_RBAC as g}from"@redocly/config";import{deepMerge as S}from"../../../utils/object/deep-merge.js";import{parsePathVersions as v}from"../../../utils/path/parse-path-versions.js";import{buildWildcardRedirectsTree as D}from"../../utils/redirects/build-wildcard-redirects-tree.js";import{shaHexShort as T}from"../../utils/crypto/sha-hex-short.js";import{formatCustomScripts as u,formatCustomLinks as w}from"./format-custom-tags.js";import{applyL10nToRbacConfig as L,resolveDirectoryHashes as O}from"../../utils/rbac.js";import{isConsentEnabled as E}from"../consent/is-consent-enabled.js";import{copySeoAssets as k}from"./copy-seo-assets.js";import{normalizeRedirectSources as G}from"./normalize-redirect-sources.js";import{applyL10nToRedirects as B}from"./apply-l10n-to-redirects.js";import{DEFAULT_LOADERS as _}from"./loaders/index.js";import{resolveSearchFacets as j}from"./resolve-search-facets.js";import{telemetryTraceStep as x}from"../../../cli/telemetry/helpers/trace-step.js";import{transformMdAst as F}from"../markdown/runtime-transform.js";async function er(){return{id:"Config Parser",loaders:_,async processContent(e,{getConfig:n,fs:t}){await x("com.redocly.build.plugin.configParser",async o=>{const{contentDir:l,setGlobalConfig:s,setGlobalData:a}=e,r=await n(),i=r.access||{},d=L(t,i.rbac||{}),f={outdir:e.outdir,contentDir:l,consentEnabled:E(r.consent)},y=await u(r.scripts?.head,f),h=await w(r.links,f),R=await u(r.scripts?.body,f),m=S(r,{headScriptTags:y,linkTags:h,postBodyScriptTags:R});o?.setAttribute("config",JSON.stringify(m));const p=r.redirects?G(r.redirects):{},C=Object.keys(p),P=m.banner?.map(c=>typeof c=="object"&&c!==null&&c.rbac?{...c,[g]:c.rbac}:c);s({...m,banner:P,access:{...i,requiresLogin:!!i.requiresLogin,rbac:d},directoryPaths:await O(t,i.rbac),seo:r.seo&&await k(r.seo,f.contentDir,f.outdir),redirects:B(p,r.l10n),wildcardRedirectsTree:D(p),originalRedirectSources:C}),j(r.search?.filters?.facets||[],e.getSearchFacets,e.setSearchFacets),a({removeAttribution:!!r.removeAttribution})})},async afterRoutesCreated(e,n){M(e);const t=e.getGlobalConfig("banner");if(Array.isArray(t)){const o=await Promise.all(t.map(async(l,s)=>{const{content:a,...r}=l,{ast:i}=await e.parseMarkdoc({input:{content:a,relativePath:"redocly.yaml"},context:n,resource:`redocly.yaml#banner${s}`}),{renderableAst:d}=await F(i,{variables:{},partials:{}},e.serverOutDir);return{...r,ast:d,hash:T(a)}}));e.setGlobalConfig({banner:o})}}}}function M(e){const n=e.getGlobalConfig("access")?.rbac,t=e.getGlobalConfig("directoryPaths");if(!(!n||Object.keys(n).length===0))for(const o of e.getAllRoutes()){if(o.versions&&t){const l=v(o.fsPath)?.filePathInVersion||"index.md";for(const s of o.versions){const a=t[s.folderId],i=a==="."||a==="/"?"":a;s[b]={slug:s.link,fsPath:A.posix.join(i,"@"+s.version,l)}}}o[b]||o[g]||(o[b]={slug:o.slug,fsPath:o.fsPath})}}export{er as configParserPlugin};
1
+ import S from"path";import{REDOCLY_ROUTE_RBAC as u,REDOCLY_TEAMS_RBAC as y}from"@redocly/config";import{deepMerge as T}from"../../../utils/object/deep-merge.js";import{parsePathVersions as D}from"../../../utils/path/parse-path-versions.js";import{buildWildcardRedirectsTree as w}from"../../utils/redirects/build-wildcard-redirects-tree.js";import{shaHexShort as E}from"../../utils/crypto/sha-hex-short.js";import{formatCustomScripts as h,formatCustomLinks as L}from"./format-custom-tags.js";import{applyL10nToRbacConfig as O,resolveDirectoryHashes as k}from"../../utils/rbac.js";import{isConsentEnabled as G}from"../consent/is-consent-enabled.js";import{copySeoAssets as B}from"./copy-seo-assets.js";import{normalizeRedirectSources as F}from"./normalize-redirect-sources.js";import{applyL10nToRedirects as _}from"./apply-l10n-to-redirects.js";import{DEFAULT_LOADERS as j}from"./loaders/index.js";import{resolveSearchFacets as x}from"./resolve-search-facets.js";import{telemetryTraceStep as M}from"../../../cli/telemetry/helpers/trace-step.js";import{transformMdAst as z}from"../markdown/runtime-transform.js";import{EntitlementsProvider as I}from"../../entitlements/entitlements-provider.js";async function ir(){return{id:"Config Parser",loaders:j,async processContent(e,{getConfig:a,fs:o}){await M("com.redocly.build.plugin.configParser",async t=>{const{contentDir:l,setGlobalConfig:s,setGlobalData:i}=e,r=await a(),n=r.access||{},m=O(o,n.rbac||{}),f={outdir:e.outdir,contentDir:l,consentEnabled:G(r.consent)},C=await h(r.scripts?.head,f),P=await L(r.links,f),R=await h(r.scripts?.body,f),d=T(r,{headScriptTags:C,linkTags:P,postBodyScriptTags:R});t?.setAttribute("config",JSON.stringify(d));const p=r.redirects?F(r.redirects):{},v=Object.keys(p),A=d.banner?.map(c=>typeof c=="object"&&c!==null&&c.rbac?{...c,[y]:c.rbac}:c);s({...d,banner:A,access:{...n,requiresLogin:!!n.requiresLogin,rbac:m},directoryPaths:await k(o,n.rbac),seo:r.seo&&await B(r.seo,f.contentDir,f.outdir),redirects:_(p,r.l10n),wildcardRedirectsTree:w(p),originalRedirectSources:v}),x(r.search?.filters?.facets||[],e.getSearchFacets,e.setSearchFacets);const b=I.instance(),g=!!b.canAccessFeature("removeAttribution");i({removeAttribution:b.pricingTier?g:!0,removeConsoleAttribution:g&&r.removeAttribution===!0})})},async afterRoutesCreated(e,a){V(e);const o=e.getGlobalConfig("banner");if(Array.isArray(o)){const t=await Promise.all(o.map(async(l,s)=>{const{content:i,...r}=l,{ast:n}=await e.parseMarkdoc({input:{content:i,relativePath:"redocly.yaml"},context:a,resource:`redocly.yaml#banner${s}`}),{renderableAst:m}=await z(n,{variables:{},partials:{}},e.serverOutDir);return{...r,ast:m,hash:E(i)}}));e.setGlobalConfig({banner:t})}}}}function V(e){const a=e.getGlobalConfig("access")?.rbac,o=e.getGlobalConfig("directoryPaths");if(!(!a||Object.keys(a).length===0))for(const t of e.getAllRoutes()){if(t.versions&&o){const l=D(t.fsPath)?.filePathInVersion||"index.md";for(const s of t.versions){const i=o[s.folderId],n=i==="."||i==="/"?"":i;s[u]={slug:s.link,fsPath:S.posix.join(n,"@"+s.version,l)}}}t[u]||t[y]||(t[u]={slug:t.slug,fsPath:t.fsPath})}}export{ir as configParserPlugin};
@@ -1 +1 @@
1
- import v from"path";import{I18N_DIR_NAME as c,L10N_DIR_NAME as p,RESERVED_DIR_NAMES as u,VERSION_SEPARATOR as V,VERSIONED_FOLDER_REGEXP_MATCH as P}from"../../../constants/common.js";import{parsePathVersions as l}from"../../../../utils/path/parse-path-versions.js";import{compareVersions as g}from"../../../../utils/version/compare-versions.js";import{reporter as h}from"../../../tools/notifiers/reporter.js";import{logger as y}from"../../../tools/notifiers/logger.js";const A=async(i,{cache:r,fs:s})=>{const e=new Map,a=await s.scan();await E(a);for(const{relativePath:n}of a){if(v.posix.basename(n)==="versions.yaml"){await F(n,e,r);continue}const o=l(n);if(o==null||u.includes(V+o.versionName))continue;const t=e.get(o.versionFolderPath)||{versionedFiles:new Map,versions:[]},f=t.versionedFiles.get(o.filePathInVersion)||new Set,d={version:o.versionName};f.add(d.version),!t.hasVersionsConfig&&t.versions.findIndex(m=>m.version===o.versionName)===-1&&t.versions.push(d),t.versionedFiles.set(o.filePathInVersion,f),e.set(o.versionFolderPath,t)}return w(e)};async function F(i,r,s){let e=v.posix.dirname(i);e==="."?e="/":e=e.endsWith("/")?e:e+"/",e.startsWith(c+"/")&&(e=e.slice(c.length+1)),e.startsWith(p+"/")&&(e=e.slice(p.length+1));const n=(await s.load(i,"yaml")).data;n.versions&&!Array.isArray(n.versions)?(await h.panicOnBuild(`Property 'versions' must be an array at %rp. Got '${typeof n.versions}'.`,i),n.versions=[]):(!n.versions||n.versions.length===0)&&y.warn("Property 'versions' is empty at %rp. This is likely a mistake.",i);const o=r.get(e)||{versionedFiles:new Map,versions:[]};o.hasVersionsConfig=!0,o.versions=n.versions||[],n.default&&(o.defaultVersion=n.default),r.set(e,o)}async function E(i){const r=new Set;for(const{relativePath:s}of i){const e=l(s);if(!(e?.versionFolderPath&&u.includes(e?.versionFolderPath))){if(e?.versionFolderPath==null){(s.match(P)?.length||0)>1&&await h.panicOnBuild(`Nested versions are not supported. Detected nested versions in path: "${s}".`);continue}r.has(e.versionFolderPath)||r.add(e.versionFolderPath)}}}function w(i){for(const[r,s]of i){const e=s.hasVersionsConfig?s.versions:s.versions.sort((o,t)=>g(t.version,o.version)),a=s.hasVersionsConfig?e[e.length-1]:e[0],n=s.defaultVersion||a?.version;i.set(r,{...s,versions:e,defaultVersion:n})}return i}function S(i,r){const s=l(i);return s==null?null:r.get(s.versionFolderPath)?.defaultVersion}export{S as getDefaultVersionByPath,A as versionsConfigLoader};
1
+ import v from"path";import{I18N_DIR_NAME as c,L10N_DIR_NAME as p,RESERVED_DIR_NAMES as u,VERSION_SEPARATOR as V,VERSIONED_FOLDER_REGEXP_MATCH as P}from"../../../constants/common.js";import{parsePathVersions as l}from"../../../../utils/path/parse-path-versions.js";import{compareVersions as g}from"../../../../utils/version/compare-versions.js";import{reporter as h}from"../../../tools/notifiers/reporter.js";import{logger as y}from"../../../tools/notifiers/logger.js";const A=async(r,{cache:i,fs:s})=>{const e=new Map,a=s.scan();await E(a);for(const{relativePath:n}of a){if(v.posix.basename(n)==="versions.yaml"){await F(n,e,i);continue}const o=l(n);if(o==null||u.includes(V+o.versionName))continue;const t=e.get(o.versionFolderPath)||{versionedFiles:new Map,versions:[]},f=t.versionedFiles.get(o.filePathInVersion)||new Set,d={version:o.versionName};f.add(d.version),!t.hasVersionsConfig&&t.versions.findIndex(m=>m.version===o.versionName)===-1&&t.versions.push(d),t.versionedFiles.set(o.filePathInVersion,f),e.set(o.versionFolderPath,t)}return I(e)};async function F(r,i,s){let e=v.posix.dirname(r);e==="."?e="/":e=e.endsWith("/")?e:e+"/",e.startsWith(c+"/")&&(e=e.slice(c.length+1)),e.startsWith(p+"/")&&(e=e.slice(p.length+1));const n=(await s.load(r,"yaml")).data;n.versions&&!Array.isArray(n.versions)?(await h.panicOnBuild(`Property 'versions' must be an array at %rp. Got '${typeof n.versions}'.`,r),n.versions=[]):(!n.versions||n.versions.length===0)&&y.warn("Property 'versions' is empty at %rp. This is likely a mistake.",r);const o=i.get(e)||{versionedFiles:new Map,versions:[]};o.hasVersionsConfig=!0,o.versions=n.versions||[],n.default&&(o.defaultVersion=n.default),i.set(e,o)}async function E(r){const i=new Set;for(const{relativePath:s}of r){const e=l(s);if(!(e?.versionFolderPath&&u.includes(e?.versionFolderPath))){if(e?.versionFolderPath==null){(s.match(P)?.length||0)>1&&await h.panicOnBuild(`Nested versions are not supported. Detected nested versions in path: "${s}".`);continue}i.has(e.versionFolderPath)||i.add(e.versionFolderPath)}}}function I(r){for(const[i,s]of r){const e=s.hasVersionsConfig?s.versions:s.versions.sort((o,t)=>g(t.version,o.version)),a=s.hasVersionsConfig?e[e.length-1]:e[0],n=s.defaultVersion||a?.version;r.set(i,{...s,versions:e,defaultVersion:n})}return r}function S(r,i){const s=l(r);return s==null?null:i.get(s.versionFolderPath)?.defaultVersion}export{S as getDefaultVersionByPath,A as versionsConfigLoader};
@@ -1 +1 @@
1
- import{CONFIG_FILE_NAME as s}from"../../../constants/common.js";import{slash as m}from"../../../utils/path/slash.js";import{reporter as r}from"../../tools/notifiers/reporter.js";import{copyStaticFile as v,FileNotFoundError as c}from"../../utils/fs.js";import{resolveSrcSet as l}from"../../utils/resolve-src-set.js";import{resolveAssetPath as f}from"../../utils/resolve-asset-path.js";const p=["png","svg","ico"];async function u(e={},o,n,a){const t={...e};if(e.image)try{t.image=await f(e.image,a,{fromFileRelativePath:o,contentDir:a.cwd,outdir:n})}catch(i){i instanceof c?await r.panicOnBuildContentError('Cannot resolve "logo.image": %rp',e.image):await r.panicOnBuild(`Cannot resolve "logo.image": %rp: ${i.message}`,e.image)}if(e.srcSet)try{t.srcSet=await l(e.srcSet,a,{fromFileRelativePath:s,contentDir:a.cwd,outdir:n})}catch(i){i instanceof c?await r.panicOnBuildContentError(`Cannot resolve "logo.srcSet" "${e.srcSet}"`):await r.panicOnBuild(`Cannot resolve "logo.srcSet" "${e.srcSet}": ${i.message}`)}if(e.favicon)try{t.favicon=await f(e.favicon,a,{fromFileRelativePath:s,contentDir:a.cwd,outdir:n})}catch(i){i instanceof c?await r.panicOnBuildContentError('Cannot resolve "logo.favicon": %rp',e.favicon):await r.panicOnBuild(`Cannot resolve "logo.favicon": %rp: ${i.message}`,e.favicon)}return t.favicon||(t.favicon=await w(n,a)),t}async function w(e,o){for(const n of p){const a=`favicon.${n}`,t=m(a);if(await o.exists(t))return v(o.cwd,a,e)}}export{u as resolveLogoConfig};
1
+ import{CONFIG_FILE_NAME as s}from"../../../constants/common.js";import{slash as m}from"../../../utils/path/slash.js";import{reporter as r}from"../../tools/notifiers/reporter.js";import{copyStaticFile as v,FileNotFoundError as c}from"../../utils/fs.js";import{resolveSrcSet as l}from"../../utils/resolve-src-set.js";import{resolveAssetPath as f}from"../../utils/resolve-asset-path.js";const p=["png","svg","ico"];async function u(e={},o,n,t){const a={...e};if(e.image)try{a.image=await f(e.image,t,{fromFileRelativePath:o,contentDir:t.cwd,outdir:n})}catch(i){i instanceof c?await r.panicOnBuildContentError('Cannot resolve "logo.image": %rp',e.image):await r.panicOnBuild(`Cannot resolve "logo.image": %rp: ${i.message}`,e.image)}if(e.srcSet)try{a.srcSet=await l(e.srcSet,t,{fromFileRelativePath:s,contentDir:t.cwd,outdir:n})}catch(i){i instanceof c?await r.panicOnBuildContentError(`Cannot resolve "logo.srcSet" "${e.srcSet}"`):await r.panicOnBuild(`Cannot resolve "logo.srcSet" "${e.srcSet}": ${i.message}`)}if(e.favicon)try{a.favicon=await f(e.favicon,t,{fromFileRelativePath:s,contentDir:t.cwd,outdir:n})}catch(i){i instanceof c?await r.panicOnBuildContentError('Cannot resolve "logo.favicon": %rp',e.favicon):await r.panicOnBuild(`Cannot resolve "logo.favicon": %rp: ${i.message}`,e.favicon)}return a.favicon||(a.favicon=await w(n,t)),a}async function w(e,o){for(const n of p){const t=`favicon.${n}`,a=m(t);if(o.exists(a))return v(o.cwd,t,e)}}export{u as resolveLogoConfig};
@@ -1 +1 @@
1
- function s(t){return async e=>{const o=e.get("devOnboardingAdapter"),{data:n,total:a}=await o.getApiProducts();return e.json(n,200,{"X-Pagination-Total":a.toString(),"Cache-Control":"no-store"})}}function d(){return async t=>{const e=await t.req.param("id"),o=!!t.req.query("expand");if(!e)return t.json({error:"Not found"},404);const n=decodeURI(e),r=await t.get("devOnboardingAdapter").getApiAccessStatus(n,o);return t.json(r,200,{"Cache-Control":"no-store"})}}export{d as getApiAccessStatus,s as listApiProducts};
1
+ function s(t){return async e=>{const o=e.get("devOnboardingAdapter"),{data:n,total:r}=await o.getApiProducts();return e.json(n,200,{"X-Pagination-Total":r.toString(),"Cache-Control":"no-store"})}}function d(){return async t=>{const e=t.req.param("id"),o=!!t.req.query("expand");if(!e)return t.json({error:"Not found"},404);const n=decodeURI(e),a=await t.get("devOnboardingAdapter").getApiAccessStatus(n,o);return t.json(a,200,{"Cache-Control":"no-store"})}}export{d as getApiAccessStatus,s as listApiProducts};
@@ -1 +1 @@
1
- import g from"path";import{DEFAULT_LOCALE_PLACEHOLDER as d,TRANSLATIONS_FILE_NAME as h}from"../../../constants/common.js";import{I18N_DIR_NAME as y,L10N_DIR_NAME as A}from"../../constants/common.js";import{logger as m}from"../../tools/notifiers/logger.js";import{reporter as w}from"../../tools/notifiers/reporter.js";import{EntitlementsProvider as O}from"../../entitlements/entitlements-provider.js";import{isL10nPath as E}from"../../fs/utils/is-l10n-path.js";import{isOpenapiDoc as I}from"../api-docs/utils/is-api-doc.js";import{telemetryTraceStep as N}from"../../../cli/telemetry/helpers/trace-step.js";async function $(){return{id:"l10n",async processContent(n,i){await N("com.redocly.build.plugin.l10n",async a=>{const{fs:t,cache:c,getConfig:r}=i,e={},p=O.instance(),l=await r();a?.setAttribute("config",JSON.stringify(l.l10n||{}));const s=l.l10n?.defaultLocale||d;if(p.canAccessFeature("l10n")){await F(i);for(const{relativePath:o}of t.scan(/(?:^|[/\\])translations\.yaml$/)){const u=await c.load(o,"yaml"),L=P(o)||s;e[L]={translation:u.data||{}}}}e[s]={translation:{...e[s]?.translation||{}}};const f=l.l10n?.locales||[d,...t.localeFolders].map(o=>({code:o.toLowerCase(),name:o}));a?.setAttribute("locales",JSON.stringify(f)),n.setGlobalData({l10n:{translations:e,defaultLocale:s,locales:f.map(o=>({code:o.code,name:o.name||o.code}))}})})}}}function P(n){return n.indexOf("/")>0?n.split("/")[1]:void 0}async function F(n){const i=n.fs.scan();for(const{isVirtual:a,realRelativePath:t}of i){if(a)continue;if(E(t)&&t.endsWith(".page.tsx")&&await w.panicOnBuild(`The file %rp is not allowed in ${A} or ${y} folders`,t),g.posix.basename(t)===h){const r=/^(?:@(i18n|l10n)[/\\][^/\\]+[/\\])?translations\.yaml$/.test(t),e=await I(t,n);!r&&!e&&m.warn("The file %rp is in the wrong location. Make sure it is located in the root directory or in the locale root directory.",t),r&&e&&m.warn("It looks like the file %rp might be an OpenAPI definition and is located in a location reserved for translation files. Please rename it or move to another directory if it is not a translations file",t)}}}export{$ as l10nPlugin};
1
+ import g from"path";import{DEFAULT_LOCALE_PLACEHOLDER as d,TRANSLATIONS_FILE_NAME as h}from"../../../constants/common.js";import{I18N_DIR_NAME as y,L10N_DIR_NAME as w}from"../../constants/common.js";import{logger as m}from"../../tools/notifiers/logger.js";import{reporter as A}from"../../tools/notifiers/reporter.js";import{EntitlementsProvider as N}from"../../entitlements/entitlements-provider.js";import{isL10nPath as O}from"../../fs/utils/is-l10n-path.js";import{isOpenapiDoc as E}from"../api-docs/utils/is-api-doc.js";import{telemetryTraceStep as I}from"../../../cli/telemetry/helpers/trace-step.js";async function $(){return{id:"l10n",async processContent(n,e){await I("com.redocly.build.plugin.l10n",async a=>{const{fs:t,cache:c,getConfig:r}=e,i={},p=N.instance(),l=await r();a?.setAttribute("config",JSON.stringify(l.l10n||{}));const s=l.l10n?.defaultLocale||d;if(p.canAccessFeature("l10n")){await F(e);for(const{relativePath:o}of t.scan(/(?:^|[/\\])translations\.yaml$/)){const u=await c.load(o,"yaml"),L=P(o)||s;i[L]={translation:u.data||{}}}}i[s]={translation:{...i[s]?.translation||{}}};const f=l.l10n?.locales||[d,...t.localeFolders].map(o=>({code:o.toLowerCase(),name:o}));a?.setAttribute("locales",JSON.stringify(f)),n.setGlobalData({l10n:{translations:i,defaultLocale:s,locales:f.map(o=>({code:o.code,name:o.name||o.code,showMissingTranslationNotice:o.showMissingTranslationNotice}))}})})}}}function P(n){return n.indexOf("/")>0?n.split("/")[1]:void 0}async function F(n){const e=n.fs.scan();for(const{isVirtual:a,realRelativePath:t}of e){if(a)continue;if(O(t)&&t.endsWith(".page.tsx")&&await A.panicOnBuild(`The file %rp is not allowed in ${w} or ${y} folders`,t),g.posix.basename(t)===h){const r=/^(?:@(i18n|l10n)[/\\][^/\\]+[/\\])?translations\.yaml$/.test(t),i=await E(t,n);!r&&!i&&m.warn("The file %rp is in the wrong location. Make sure it is located in the root directory or in the locale root directory.",t),r&&i&&m.warn("It looks like the file %rp might be an OpenAPI definition and is located in a location reserved for translation files. Please rename it or move to another directory if it is not a translations file",t)}}}export{$ as l10nPlugin};
@@ -1 +1 @@
1
- import{JsonPointer as w}from"@redocly/api-docs";import{isObject as d}from"../../../../utils/guards/is-object.js";import{getNodeAttribute as u}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as s}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{MdResolveError as p}from"./md-resolve-error.js";import{resolvePathInMarkdown as $}from"../resolve-path-in-markdown.js";async function b(e,o,m,{context:n,actions:h}){const r=u(e,o);try{if(!d(r)||typeof r.$ref!="string"){try{JSON.stringify(r)}catch(i){throw new Error(`Invalid JSON value: ${i.message}`)}s(e,o+"Resolved",r);return}const[t,f]=r.$ref.split("#");if(!t)throw new Error(`Invalid $ref. Path to file is required: ${r.$ref}`);const l=$(t,m,h.contentDir),c=await n.fs.getFileInfo(l);if(!c)throw new Error(`Invalid $ref. No such file: ${l}`);let a;try{a=(await n.cache.load(c.realRelativePath,"yaml")).data}catch(i){throw new Error(`Invalid file format. File must be valid json or yaml: ${l} ${i?.message||""}`)}if(!f){s(e,o+"Resolved",a);return}const v=w.get(a,f);s(e,o+"Resolved",v)}catch(t){throw s(e,o+"ResolvedErrors",[t.message]),new p(t.message,{rawLink:""})}}export{b as resolveJsonExampleRef};
1
+ import{JsonPointer as d}from"@redocly/api-docs";import{isObject as u}from"../../../../utils/guards/is-object.js";import{getNodeAttribute as w}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as s}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{MdResolveError as p}from"./md-resolve-error.js";import{resolvePathInMarkdown as $}from"../resolve-path-in-markdown.js";async function b(e,o,m,{context:n,actions:h}){const r=w(e,o);try{if(!u(r)||typeof r.$ref!="string"){try{JSON.stringify(r)}catch(i){throw new Error(`Invalid JSON value: ${i.message}`)}s(e,o+"Resolved",r);return}const[t,f]=r.$ref.split("#");if(!t)throw new Error(`Invalid $ref. Path to file is required: ${r.$ref}`);const l=$(t,m,h.contentDir),c=n.fs.getFileInfo(l);if(!c)throw new Error(`Invalid $ref. No such file: ${l}`);let a;try{a=(await n.cache.load(c.realRelativePath,"yaml")).data}catch(i){throw new Error(`Invalid file format. File must be valid json or yaml: ${l} ${i?.message||""}`)}if(!f){s(e,o+"Resolved",a);return}const v=d.get(a,f);s(e,o+"Resolved",v)}catch(t){throw s(e,o+"ResolvedErrors",[t.message]),new p(t.message,{rawLink:""})}}export{b as resolveJsonExampleRef};
@@ -1 +1 @@
1
- import n from"node:path";import{API_DOCS_TEMPLATE_ID as y,ASYNC_API_DOCS_TEMPLATE_ID as F,GRAPHQL_TEMPLATE_ID as M,OPENAPI_DOCS_TEMPLATE_ID as U}from"../../../../constants/common.js";import{isLocalLink as C}from"../../../../utils/path/is-local-link.js";import{normalizeRouteSlug as P}from"../../../../utils/path/normalize-route-slug.js";import{removeFragment as B}from"../../../../utils/path/remove-fragment.js";import{getInnerText as W}from"../../../../markdoc/helpers/get-inner-text.js";import{getNodeAttribute as j}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as c}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{isAuthRoutePath as $}from"../../../../utils/auth/is-auth-route-path.js";import{isApiDownloadLink as V}from"../../../utils/is-api-download-link.js";import{MdResolveError as A}from"./md-resolve-error.js";import{getLinkOriginalAttrName as b}from"./utils.js";import{isOpenApiURL as z}from"../../api-docs/utils/is-api-doc.js";import{parseBaseName as G}from"../../utils.js";import{isMarkdownPage as N}from"../is-markdown-page.js";import{copyStaticFile as q}from"../../../utils/fs.js";async function pt(i,r,p,{actions:w,context:u}){const{contentDir:D,outdir:T,getRouteByFsPath:x,getRouteBySlug:I,hasRouteOrRedirectBySlug:d}=w,k=b(r),o=i[k]||j(i,r);if(i[k]=o,!C(o)||V(o)||$(o))return;const[H,t="",R,L]=/^([^?#]+)?([^#]+)?(.+)?/.exec(o)||[],f=i.type==="image"?"IMAGE":"LINK",g=String(i.attributes.title||i.attributes.alt||W([i])||""),a=B(p);if(i.type!=="image"){const{isOpenapiDetected:e,isOpenapiValid:s}=await z(t,a,w,u);if(e&&!s)throw new A(`OpenAPI route ${o} does not exist`,{rawLink:o,link:t,title:g,brokenLinkType:f})}if(n.extname(t)===""){if(t.startsWith("/")){const e=P(t),s=d(e)?t:_(e,I);if(!s)throw new A(`Route ${t} does not exist`,{rawLink:o,link:t,title:g,brokenLinkType:f});c(i,r,s+(R||"")+(L||""))}if(!o.startsWith("#")&&!t.startsWith("/")&&N(a)){const e=x(a)?.slug;if(!e)return;const{isIndexFile:s}=G(a),h=s?P(n.posix.join(e,t)):P(n.posix.join(e,"../",t)),E=d(P(h))?h:_(h,I);if(!E)throw new A(`Route ${t} does not exist`,{rawLink:o,link:h,title:g,brokenLinkType:f});c(i,r,E+(R||"")+(L||""))}return}const l=t.startsWith("/")?t.substring(1):n.posix.join(n.posix.dirname(a),decodeURI(t)),v=t.startsWith("/")?n.posix.join("static",t.substring(1)):"",S=u.fs.exists(l),O=u.fs.exists(v),m=x(l);if(!S&&!m&&!O)throw c(i,r,"#"),new A(`File ${l} does not exist`,{rawLink:o,link:l,title:g,brokenLinkType:f});if(m){const e=[U,M,F].includes(m.templateId);c(i,r,(e?m.baseSlug:m.slug)+(L||""))}else if(S){const e=u.fs.getFileInfo(l);if(!e||e.isVirtual)return;const s=await q(D,e.realRelativePath,T);c(i,r,s)}}function _(i,r){const p=r(i.toLowerCase());return p?.templateId===y?p.slug:void 0}export{pt as resolveLink};
1
+ import l from"node:path";import{API_DOCS_TEMPLATE_ID as O,ASYNC_API_DOCS_TEMPLATE_ID as y,GRAPHQL_TEMPLATE_ID as M,OPENAPI_DOCS_TEMPLATE_ID as U}from"../../../../constants/common.js";import{isLocalLink as C}from"../../../../utils/path/is-local-link.js";import{normalizeRouteSlug as P}from"../../../../utils/path/normalize-route-slug.js";import{removeFragment as B}from"../../../../utils/path/remove-fragment.js";import{getInnerText as W}from"../../../../markdoc/helpers/get-inner-text.js";import{getNodeAttribute as j}from"../../../../markdoc/helpers/get-node-attribute.js";import{setNodeAttributeValue as p}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{isAuthRoutePath as $}from"../../../../utils/auth/is-auth-route-path.js";import{isApiDownloadLink as b}from"../../../utils/is-api-download-link.js";import{isTranslationFallback as V}from"../../../fs/utils/is-translation-fallback.js";import{removeL10nPrefix as z}from"../../../fs/utils/remove-l10n-prefix.js";import{MdResolveError as A}from"./md-resolve-error.js";import{getLinkOriginalAttrName as G}from"./utils.js";import{isOpenApiURL as N}from"../../api-docs/utils/is-api-doc.js";import{parseBaseName as q}from"../../utils.js";import{isMarkdownPage as H}from"../is-markdown-page.js";import{copyStaticFile as K}from"../../../utils/fs.js";async function ht(i,s,u,{actions:I,context:m}){const{contentDir:T,outdir:v,getRouteByFsPath:d,getRouteBySlug:k,hasRouteOrRedirectBySlug:w}=I,x=G(s),o=i[x]||j(i,s);if(i[x]=o,!C(o)||b(o)||$(o))return;const[Q,t="",R,L]=/^([^?#]+)?([^#]+)?(.+)?/.exec(o)||[],g=i.type==="image"?"IMAGE":"LINK",h=String(i.attributes.title||i.attributes.alt||W([i])||""),c=B(u);if(i.type!=="image"){const{isOpenapiDetected:e,isOpenapiValid:r}=await N(t,c,I,m);if(e&&!r)throw new A(`OpenAPI route ${o} does not exist`,{rawLink:o,link:t,title:h,brokenLinkType:g})}if(l.extname(t)===""){if(t.startsWith("/")){const e=P(t),r=w(e)?t:_(e,k);if(!r)throw new A(`Route ${t} does not exist`,{rawLink:o,link:t,title:h,brokenLinkType:g});p(i,s,r+(R||"")+(L||""))}if(!o.startsWith("#")&&!t.startsWith("/")&&H(c)){const e=d(c)?.slug;if(!e)return;const{isIndexFile:r}=q(c),a=r?P(l.posix.join(e,t)):P(l.posix.join(e,"../",t)),E=w(P(a))?a:_(a,k);if(!E)throw new A(`Route ${t} does not exist`,{rawLink:o,link:a,title:h,brokenLinkType:g});p(i,s,E+(R||"")+(L||""))}return}const n=t.startsWith("/")?t.substring(1):l.posix.join(l.posix.dirname(c),decodeURI(t)),D=t.startsWith("/")?l.posix.join("static",t.substring(1)):"",S=m.fs.exists(n),F=m.fs.exists(D),f=d(n);if(!S&&!f&&!F)throw p(i,s,"#"),new A(`File ${n} does not exist`,{rawLink:o,link:n,title:h,brokenLinkType:g});if(f){const e=[U,M,y].includes(f.templateId);p(i,s,(e?f.baseSlug:f.slug)+(L||""))}else if(S){const e=m.fs.getFileInfo(n),r=V(e)?m.fs.getFileInfo(z(n)):e;if(!r||r.isVirtual)return;const a=await K(T,r.realRelativePath,v);p(i,s,a)}}function _(i,s){const u=s(i.toLowerCase());return u?.templateId===O?u.slug:void 0}export{ht as resolveLink};
@@ -1 +1 @@
1
- import s from"@markdoc/markdoc";import{getPublicEnvVariables as u}from"../../utils/envs/get-public-env-variables.js";import{transformMdAst as i}from"./runtime-transform";const v=async(A,o,t,e)=>{const{ast:n,frontmatter:r,props:l,editPage:f,lastModified:m}=o,{headings:d,renderableAst:p}=await i(s.Ast.fromJSON(n),{partials:t.partials,variables:{frontmatter:r,...t.variables,env:u()}},e.serverOutDir);return Array.isArray(r.banner)&&(r.banner=await Promise.all(r.banner.map(async a=>{if(a.ast){const{renderableAst:b}=await i(s.Ast.fromJSON(a.ast),{partials:{},variables:{}},e.serverOutDir);return{...a,ast:b}}return a}))),{...l,ast:p,headings:d,frontmatter:r,editPage:f,lastModified:m}};var P=v;export{P as default};
1
+ import e from"@markdoc/markdoc";import{getPublicEnvVariables as u}from"../../utils/envs/get-public-env-variables.js";import{transformMdAst as i}from"./runtime-transform";const v=async(A,o,t,s)=>{const{ast:l,frontmatter:r,props:n,editPage:f,lastModified:m,isTranslationFallback:b}=o,{headings:d,renderableAst:p}=await i(e.Ast.fromJSON(l),{partials:t.partials,variables:{frontmatter:r,...t.variables,env:u()}},s.serverOutDir);return Array.isArray(r.banner)&&(r.banner=await Promise.all(r.banner.map(async a=>{if(a.ast){const{renderableAst:c}=await i(e.Ast.fromJSON(a.ast),{partials:{},variables:{}},s.serverOutDir);return{...a,ast:c}}return a}))),{...n,ast:p,headings:d,frontmatter:r,editPage:f,lastModified:m,...b?{isTranslationFallback:!0}:{}}};var k=v;export{k as default};
@@ -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),await 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 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 +1 @@
1
- import{isNode as p}from"../../../../../markdoc/helpers/guards/is-node.js";import{isStringNode as u}from"../../../../../markdoc/helpers/guards/is-string-node.js";import{getNodeAttribute as o}from"../../../../../markdoc/helpers/get-node-attribute.js";import{getInnerText as a}from"../../../../../markdoc/helpers/get-inner-text.js";import{isPromptNode as m}from"../../../../../markdoc/helpers/guards/is-prompt-node.js";function d(t){const r=o(t,"level");if(r)return{value:a(t.children),id:o(t,"id"),depth:r}}function y(t){const r=o(t,"headlineLevel"),e=o(t,"anchorId"),s=o(t,"headline");if(!(!r||!e||!Array.isArray(s)))return{value:a(s),id:e,depth:r}}function I(t){let r;return f(t,e=>{if(p(e)){if(m(e))return l;if(e.type==="heading")return r=d(e)?.value,c}}),r}const c=Symbol("Exit visitor"),l=Symbol("Skip children");function f(t,r){if(!t)return;const e=r(t);if(e===c)return e;if(e===l)return;for(const i of t.children){if(!i||u(i))continue;const n=f(i,r);if(n===c)return n}const s=t.slots||{};for(const i of Object.values(s)){if(!i||u(i))continue;const n=f(i,r);if(n===c)return n}}export{c as EXIT,l as SKIP,I as extractFirstHeading,d as getHeadingData,y as getNumberedItemHeadingData,f as visit};
1
+ import{isForAgentsOnly as m}from"@redocly/theme/markdoc/tags/visibility";import{isNode as p}from"../../../../../markdoc/helpers/guards/is-node.js";import{isStringNode as u}from"../../../../../markdoc/helpers/guards/is-string-node.js";import{getNodeAttribute as o}from"../../../../../markdoc/helpers/get-node-attribute.js";import{getInnerText as l}from"../../../../../markdoc/helpers/get-inner-text.js";import{isPromptNode as d}from"../../../../../markdoc/helpers/guards/is-prompt-node.js";function h(t){const r=o(t,"level");if(r)return{value:l(t.children),id:o(t,"id"),depth:r}}function N(t){const r=o(t,"headlineLevel"),e=o(t,"anchorId"),s=o(t,"headline");if(!(!r||!e||!Array.isArray(s)))return{value:l(s),id:e,depth:r}}function S(t){let r;return c(t,e=>{if(p(e)){if(d(e)||m(e))return a;if(e.type==="heading")return r=h(e)?.value,f}}),r}const f=Symbol("Exit visitor"),a=Symbol("Skip children");function c(t,r){if(!t)return;const e=r(t);if(e===f)return e;if(e===a)return;for(const i of t.children){if(!i||u(i))continue;const n=c(i,r);if(n===f)return n}const s=t.slots||{};for(const i of Object.values(s)){if(!i||u(i))continue;const n=c(i,r);if(n===f)return n}}export{f as EXIT,a as SKIP,S as extractFirstHeading,h as getHeadingData,N as getNumberedItemHeadingData,c as visit};
@@ -1,2 +1,2 @@
1
- import p from"node:path";import _ from"is-glob";import{slash as $}from"../../../../utils/path/slash.js";import{reporter as d}from"../../../tools/notifiers/reporter.js";import{convertGlobToRegex as h}from"../../../utils/index.js";import{formatMarkdocError as k}from"../errors.js";import{isPartial as E}from"../is-partial.js";const b=/\{% ?raw-partial file="([^"]+)" ?\/?%\}/gm,y=async(t,a,i=[],o,l=[a])=>{for(const s of i){const r=_(s)?h(s):new RegExp(`^${s}/`);await o.fs.scan(r)}const n=[],f=t.replace(b,(s,r)=>(n.push(u(s,r)),"_$redocly$"+(n.length-1)+"$")),w=await Promise.all(n);return f.replace(/_\$redocly\$(\d+)\$/g,(s,r)=>w[+r]);async function u(s,r){const e=r.startsWith("/")?r.slice(1):$(p.relative(o.fs.cwd,p.resolve(o.fs.cwd,p.dirname(a),r)));if(l.includes(e)){const c=[...l,e];return await d.panicOnBuildContentError(`Circular reference chain detected when processing raw partials: ${c.map(()=>"%rp").join(" -> ")}`,...c),""}const m=!o.fs.exists(e),g=!e.endsWith(".md")||await o.isPathIgnored(e)||!E(e,i);if(m||g){const R={type:"resolve_link",lines:[1,t.split(`
1
+ import p from"node:path";import _ from"is-glob";import{slash as $}from"../../../../utils/path/slash.js";import{reporter as d}from"../../../tools/notifiers/reporter.js";import{convertGlobToRegex as h}from"../../../utils/index.js";import{formatMarkdocError as k}from"../errors.js";import{isPartial as E}from"../is-partial.js";const b=/\{% ?raw-partial file="([^"]+)" ?\/?%\}/gm,y=async(t,a,i=[],o,l=[a])=>{for(const s of i){const r=_(s)?h(s):new RegExp(`^${s}/`);o.fs.scan(r)}const n=[],f=t.replace(b,(s,r)=>(n.push(u(s,r)),"_$redocly$"+(n.length-1)+"$")),w=await Promise.all(n);return f.replace(/_\$redocly\$(\d+)\$/g,(s,r)=>w[+r]);async function u(s,r){const e=r.startsWith("/")?r.slice(1):$(p.relative(o.fs.cwd,p.resolve(o.fs.cwd,p.dirname(a),r)));if(l.includes(e)){const c=[...l,e];return await d.panicOnBuildContentError(`Circular reference chain detected when processing raw partials: ${c.map(()=>"%rp").join(" -> ")}`,...c),""}const m=!o.fs.exists(e),g=!e.endsWith(".md")||await o.isPathIgnored(e)||!E(e,i);if(m||g){const R={type:"resolve_link",lines:[1,t.split(`
2
2
  `).length],meta:{rawLink:r,link:e},error:{id:"error",level:"error",message:m?"Raw partial file does not exist":"Could not resolve raw partial. Starting with 0.73.0 version all partials should be placed in partials folders"}};return d.reportMarkdocProblem(k(R,a,t)),""}const v=await o.fs.read(e);return await y(v,e,i,o,[...l,e])}};export{y as resolveRawPartials};
@@ -1 +1 @@
1
- import D from"path";import{REDOCLY_TEAMS_RBAC as v,REDOCLY_ROUTE_RBAC as A}from"@redocly/config";import{removeTrailingSlash as M}from"../../../utils/url/remove-trailing-slash.js";import{addLeadingSlash as N}from"../../../utils/url/add-leading-slash.js";import{shaHexShort as E}from"../../utils/crypto/sha-hex-short.js";import{isDefined as I}from"../../../utils/guards/is-defined.js";import{resolveFrontmatterKeys as L}from"../resolve-frontmatter-keys.js";import{resolveItem as _}from"../nav-utils.js";const R=new WeakMap;async function j(o,i,s,e,a){const d=await s.getConfig(),{ast:r,compoundHash:n,info:g}=await a.parseMarkdoc({input:o,context:s}),l={...d.markdown?.editPage,...e.markdown?.editPage},t=i.fsPath!=null?s.fs.getFileInfo(i.fsPath):null,f=!l?.hide&&l?.baseUrl?{to:M(l.baseUrl)+N(t?.realRelativePath||i.fsPath||"")}:void 0,w={...d.feedback,...e.feedback},m=e.feedback?{type:w.type||"sentiment",settings:w.settings||{},hide:e.feedback?.hide}:void 0;let h;Array.isArray(e.banner)&&(h=(await Promise.all(e.banner.map(async(B,O)=>{const{content:k,...b}=B;if(!k)return;const{ast:T}=await a.parseMarkdoc({input:{content:k,relativePath:o.relativePath,isVirtual:o.isVirtual},context:s,resource:`${o.relativePath}#banner${O}`});return{...b,...b.rbac?{[v]:b.rbac}:{},ast:JSON.stringify(T),hash:E(k)}}))).filter(I));const y=R.get(r);let c=y?.ast;(!c||y?.compoundHash!==n)&&(c=JSON.stringify(r),R.set(r,{ast:c,compoundHash:n}));let p;e.navigation&&(p={...e.navigation,nextButton:await S(e.navigation.nextButton,i,a,s),previousButton:await S(e.navigation.previousButton,i,a,s)});const u=e?.seo?await L(e.seo,["image"],i.fsPath||"",a,s):void 0,P=g.tagList;Array.isArray(P)&&P.includes("code-walkthrough")&&(e.markdown=e.markdown||{},e.markdown.toc={hide:!0},e.footer=e.footer||{},e.footer={hide:!0});const C=e?.seo?.title||await i.getNavText?.();return{ast:c,frontmatter:await L({...e,...m!==void 0?{feedback:m}:{},...u!==void 0?{seo:u}:{},...p!==void 0?{navigation:p}:{},...h!==void 0?{banner:h}:{}},d.markdown?.frontMatterKeysToResolve||["image","links"],i.fsPath||"",a,s),editPage:f,props:{metadata:{markdoc:{tagList:g.tagList}},seo:{...u,...C?{title:C}:{}}},[v]:i[v],[A]:i[A]}}async function S(o,i,s,e){if(!o||typeof o!="object")return;let a=o,d,r;if("page"in a&&typeof a.page=="string"){const{page:t,...f}=a;a=f,d=t}if("label"in a&&typeof a.label=="string"){const{label:t,...f}=a;a=f,r=t}let n;if(d){const t=await _({page:d},i.fsPath?D.dirname(i.fsPath):".",s,e,{navFile:i.fsPath||""});n=Array.isArray(t)?t[0]:t,n=n?.type!=="error"?n:void 0}const g=n?.routeSlug,l=r??n?.label;return{...a,label:l,link:g}}export{j as markdownStaticDataLoader};
1
+ import D from"path";import{REDOCLY_TEAMS_RBAC as m,REDOCLY_ROUTE_RBAC as A}from"@redocly/config";import{removeTrailingSlash as F}from"../../../utils/url/remove-trailing-slash.js";import{addLeadingSlash as M}from"../../../utils/url/add-leading-slash.js";import{shaHexShort as N}from"../../utils/crypto/sha-hex-short.js";import{isDefined as E}from"../../../utils/guards/is-defined.js";import{isTranslationFallback as I}from"../../fs/utils/is-translation-fallback.js";import{resolveFrontmatterKeys as L}from"../resolve-frontmatter-keys.js";import{resolveItem as _}from"../nav-utils.js";const R=new WeakMap;async function z(n,i,s,e,a){const l=await s.getConfig(),{ast:d,compoundHash:t,info:g}=await a.parseMarkdoc({input:n,context:s}),r={...l.markdown?.editPage,...e.markdown?.editPage},o=i.fsPath!=null?s.fs.getFileInfo(i.fsPath):null,f=!r?.hide&&r?.baseUrl?{to:F(r.baseUrl)+M(o?.realRelativePath||i.fsPath||"")}:void 0,v={...l.feedback,...e.feedback},w=e.feedback?{type:v.type||"sentiment",settings:v.settings||{},hide:e.feedback?.hide}:void 0;let h;Array.isArray(e.banner)&&(h=(await Promise.all(e.banner.map(async(T,B)=>{const{content:k,...b}=T;if(!k)return;const{ast:O}=await a.parseMarkdoc({input:{content:k,relativePath:n.relativePath,isVirtual:n.isVirtual},context:s,resource:`${n.relativePath}#banner${B}`});return{...b,...b.rbac?{[m]:b.rbac}:{},ast:JSON.stringify(O),hash:N(k)}}))).filter(E));const y=R.get(d);let c=y?.ast;(!c||y?.compoundHash!==t)&&(c=JSON.stringify(d),R.set(d,{ast:c,compoundHash:t}));let p;e.navigation&&(p={...e.navigation,nextButton:await S(e.navigation.nextButton,i,a,s),previousButton:await S(e.navigation.previousButton,i,a,s)});const u=e?.seo?await L(e.seo,["image"],i.fsPath||"",a,s):void 0,P=g.tagList;Array.isArray(P)&&P.includes("code-walkthrough")&&(e.markdown=e.markdown||{},e.markdown.toc={hide:!0},e.footer=e.footer||{},e.footer={hide:!0});const C=e?.seo?.title||await i.getNavText?.();return{ast:c,frontmatter:await L({...e,...w!==void 0?{feedback:w}:{},...u!==void 0?{seo:u}:{},...p!==void 0?{navigation:p}:{},...h!==void 0?{banner:h}:{}},l.markdown?.frontMatterKeysToResolve||["image","links"],i.fsPath||"",a,s),editPage:f,...I(n)?{isTranslationFallback:!0}:{},props:{metadata:{markdoc:{tagList:g.tagList}},seo:{...u,...C?{title:C}:{}}},[m]:i[m],[A]:i[A]}}async function S(n,i,s,e){if(!n||typeof n!="object")return;let a=n,l,d;if("page"in a&&typeof a.page=="string"){const{page:o,...f}=a;a=f,l=o}if("label"in a&&typeof a.label=="string"){const{label:o,...f}=a;a=f,d=o}let t;if(l){const o=await _({page:l},i.fsPath?D.dirname(i.fsPath):".",s,e,{navFile:i.fsPath||""});t=Array.isArray(o)?o[0]:o,t=t?.type!=="error"?t:void 0}const g=t?.routeSlug,r=d??t?.label;return{...a,label:r,link:g}}export{z as markdownStaticDataLoader};
@@ -1 +1 @@
1
- import{reporter as t}from"../../tools/notifiers/reporter.js";async function o(r,n){return await n.exists(r)?n.read(r):(await t.panicOnBuildContentError(`File ${r} does not exist`),null)}export{o as readFileContent};
1
+ import{reporter as e}from"../../tools/notifiers/reporter.js";async function o(r,n){return n.exists(r)?n.read(r):(await e.panicOnBuildContentError(`File ${r} does not exist`),null)}export{o as readFileContent};
@@ -1 +1 @@
1
- import p from"@markdoc/markdoc";import{REDOCLY_ROUTE_RBAC as l,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{getInnerText as T}from"../../../../markdoc/helpers/get-inner-text.js";import{getSearchDocuments as h}from"./get-search-documents.js";import{AstToSearchNodeTransformer as R}from"./walk-sections.js";import{setDocumentSearchFacets as S,extractDocumentSearchFacets as C}from"./search-facets.js";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../../constants/common.js";import{normalizeFrontmatterKeywords as _}from"../../helpers/normalize-frontmatter-keywords.js";function K(e,m,o,c){return async(t,r,a)=>{if(e?.excludeFromSearch)return[];const i=p.Ast.fromJSON(r.ast),u=new R({ast:i,getInnerContent:T,partials:a.getGlobalConfig(D)||{},indexPromptTitles:!0}),f=t.metadata||{},n=C(f,o);S(n,o,c);const d=e?.seo?.title||m,{result:s}=_(e?.keywords);return h(u,t.slug,d,r[A],r[l],n,s||void 0)}}export{K as searchResolver};
1
+ import d from"@markdoc/markdoc";import{REDOCLY_ROUTE_RBAC as l,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{getInnerText as T}from"../../../../markdoc/helpers/get-inner-text.js";import{skipAgentsOnlyContent as h}from"@redocly/theme/markdoc/tags/visibility";import{getSearchDocuments as g}from"./get-search-documents.js";import{AstToSearchNodeTransformer as C}from"./walk-sections.js";import{setDocumentSearchFacets as R,extractDocumentSearchFacets as S}from"./search-facets.js";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../../constants/common.js";import{normalizeFrontmatterKeywords as _}from"../../helpers/normalize-frontmatter-keywords.js";function Y(e,m,o,c){return async(t,r,a)=>{if(e?.excludeFromSearch)return[];const i=d.Ast.fromJSON(r.ast),f=new C({ast:i,getInnerContent:T,partials:a.getGlobalConfig(D)||{},renderTag:h,indexPromptTitles:!0}),p=t.metadata||{},n=S(p,o);R(n,o,c);const u=e?.seo?.title||m,{result:s}=_(e?.keywords);return g(f,t.slug,u,r[A],r[l],n,s||void 0)}}export{Y as searchResolver};
@@ -1,11 +1,6 @@
1
1
  import type { RedoclyConfig } from '@redocly/config';
2
- export type ApiCallsConfig = NonNullable<NonNullable<RedoclyConfig['mcp']>['apiCalls']>;
3
- type ApiCallsHttpMethod = NonNullable<ApiCallsConfig['allowedHttpMethods']>[number];
4
- /** The methods agents may send when `mcp.apiCalls.allowedHttpMethods` is not set. */
5
- export declare const DEFAULT_ALLOWED_HTTP_METHODS: readonly ApiCallsHttpMethod[];
6
2
  /** Upper-case HTTP methods agents may send; read-only unless `redocly.yaml` allows more. */
7
3
  export declare function getAllowedHttpMethods(mcp: RedoclyConfig['mcp'] | undefined): string[];
8
4
  /** Whether every allowed method is safe by HTTP semantics (`GET`, `HEAD`, `OPTIONS`). */
9
5
  export declare function allowsOnlySafeHttpMethods(mcp: RedoclyConfig['mcp'] | undefined): boolean;
10
- export {};
11
6
  //# sourceMappingURL=allowed-http-methods.d.ts.map
@@ -1 +1 @@
1
- const o=["GET","HEAD","OPTIONS"],r={GET:!0,HEAD:!0,OPTIONS:!0};function T(t){return(t?.apiCalls?.allowedHttpMethods??o).map(e=>e.toUpperCase())}function p(t){return T(t).every(e=>r[e])}export{o as DEFAULT_ALLOWED_HTTP_METHODS,p as allowsOnlySafeHttpMethods,T as getAllowedHttpMethods};
1
+ const o=["GET","HEAD","OPTIONS"],r={GET:!0,HEAD:!0,OPTIONS:!0};function T(t){return(t?.apiCalls?.allowedHttpMethods??o).map(e=>e.toUpperCase())}function l(t){return T(t).every(e=>r[e])}export{l as allowsOnlySafeHttpMethods,T as getAllowedHttpMethods};
@@ -1,9 +1,8 @@
1
1
  import type { RedoclyConfig } from '@redocly/config';
2
2
  /**
3
- * `mcp` with `apiCalls` narrowed by the caller's `metadata.apiCalls` (`hide`, `allowedHttpMethods`),
4
- * which the AI Assistant fills from `aiAssistant.mcp.apiCalls`. The caller can only take API calls
5
- * or methods away: a value of another shape changes nothing, and a method list that keeps none of
6
- * the project's methods turns API calls off.
3
+ * `mcp` with API calls turned off when the caller's `metadata.apiCalls.hide` is `true`: the AI
4
+ * Assistant sends it when the host page of its web component runs the API calls itself. The caller
5
+ * can only take API calls away; a value of another shape changes nothing.
7
6
  */
8
7
  export declare function narrowMcpConfigForCaller(mcp: RedoclyConfig['mcp'], metadata: Record<string, unknown> | undefined): RedoclyConfig['mcp'];
9
8
  //# sourceMappingURL=caller-api-calls.d.ts.map
@@ -1 +1 @@
1
- import{DEFAULT_ALLOWED_HTTP_METHODS as d}from"./allowed-http-methods.js";function h(e,a){const o=a?.apiCalls;if(!o||typeof o!="object")return e;const{hide:i,allowedHttpMethods:s}=o,t={...e?.apiCalls};if(i===!0&&(t.hide=!0),Array.isArray(s)){const n=new Set(s.map(r=>String(r).toUpperCase())),l=(e?.apiCalls?.allowedHttpMethods??d).filter(r=>n.has(r));l.length===0?t.hide=!0:t.allowedHttpMethods=l}return{...e,apiCalls:t}}export{h as narrowMcpConfigForCaller};
1
+ function i(e,t){const r=t?.apiCalls;return!r||typeof r!="object"||r.hide!==!0?e:{...e,apiCalls:{...e?.apiCalls,hide:!0}}}export{i as narrowMcpConfigForCaller};
@@ -1 +1 @@
1
- import*as v from"path";import{REDOCLY_ROUTE_RBAC as b,REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{VERSION_SEPARATOR as M}from"../constants/common.js";import{DEFAULT_LOCALE_PLACEHOLDER as _}from"../../constants/common.js";import{removeTrailingSlash as j}from"../../utils/url/remove-trailing-slash.js";import{isPrimitive as W}from"../../utils/guards/is-primitive.js";import{slash as w}from"../../utils/path/slash.js";import{isAbsoluteUrl as z}from"../../utils/url/is-absolute-url.js";import{normalizeRouteSlug as J}from"../../utils/path/normalize-route-slug.js";import{parsePathVersions as C}from"../../utils/path/parse-path-versions.js";import{logger as A}from"../tools/notifiers/logger.js";import{reporter as S}from"../tools/notifiers/reporter.js";import{shaDirPathShort as R}from"../utils/crypto/sha-dir-path-short.js";import{copyStaticFile as U,FileNotFoundError as E}from"../utils/fs.js";import{isIconPath as H,resolveAssetPath as Y}from"../utils/index.js";import{resolveSrcSet as G}from"../utils/resolve-src-set.js";import{isL10nPath as B}from"../fs/utils/is-l10n-path.js";import{getLocaleFromRelativePath as q}from"../fs/utils/get-locale-from-relative-path.js";async function N(e,i,n,t,a){if(!e)return;const f={...a,ignoreCustomSidebar:!0};if(W(e)){if(typeof e=="string"){const r=F(n.contentDir,i,a,e,t.fs);if(t.fs.exists(r)){if(n.getRouteByFsPath(r))return K({page:e},i,n,t,f);{const g=t.fs.getFileInfo(r);return g?U(n.contentDir,g.realRelativePath,n.outdir):void 0}}}return e}return Array.isArray(e)?I(D(e),i,n,t,f):Object.fromEntries(await Promise.all(Object.entries(e).map(async([r,l])=>[r,await N(l,i,n,t,a)])))}function D(e){return e.map(i=>({...i,items:i.items?D(i.items):void 0}))}async function I(e,i,n,t,a){if(Array.isArray(e))return(await Promise.all(e.map(f=>K(f,i,n,t,a)))).flatMap(f=>f)}async function y(e,i,n,t){let a,f;if(typeof e.icon=="object"){if("srcSet"in e.icon)try{a=await G(e.icon.srcSet,n.fs,{fromFileRelativePath:t.navFile,contentDir:i.contentDir,outdir:i.outdir})}catch(d){d instanceof E?await S.panicOnBuildContentError(`Cannot resolve "item.icon.srcSet" from ${t.navFile}: ${d.message}`):await S.panicOnBuild(`Cannot resolve "item.icon.srcSet" from ${t.navFile}: ${d.message}`)}}else if(typeof e.icon=="string")if(z(e.icon)||H(e.icon))try{f=await Y(e.icon,n.fs,{fromFileRelativePath:t.navFile,contentDir:i.contentDir,outdir:i.outdir})}catch(d){d instanceof E?await S.panicOnBuildContentError(`Cannot resolve "item.icon" from ${t.navFile}: file ${f} does not exist`):await S.panicOnBuild(`Cannot resolve "item.icon" from ${t.navFile}: ${d.message}`)}else f=e.icon;return{icon:f,srcSet:a}}function Q(e){return i=>{if(i.type==="link"||i.type==="group"){const n=i.metadata;return n?Object.entries(e).every(([t,a])=>Array.isArray(a)?a.some(f=>n[t]===f):n[t]===a):!1}return!0}}async function K(e,i,n,t,a){if(e?.tab!==void 0||e?.menu!==void 0){const s=`Navigation tabs ("tab"/"menu") are only allowed at the top level of a sidebars.yaml file: ${JSON.stringify(e)}`;return await S.panicOnBuildContentError(`Invalid nav item in %rp. ${s}`,a.navFile),{type:"error",label:s}}if(e?.directory&&e.items?.length)return{type:"error",label:`Can't have both "directory" and "items" in the nav item: ${JSON.stringify(e)}`};e?.directory&&e?.group&&(e={...e,directory:void 0,items:[{directory:e.directory}]});const f=e?.directory?F(n.contentDir,i,a,e.directory,t.fs):void 0;if(f!==void 0){const s=f===""?"":f+"/",{locale:u,ignoredRoutes:o}=a,p=n.getAllRoutesForLocale(u).filter(c=>!o?.has(c.baseSlug||"")&&c.fsPath.startsWith(s)&&!c.excludeFromSidebar).sort((c,P)=>c.fsPath===P.fsPath?0:c.baseSlug.localeCompare(P.baseSlug,void 0,{numeric:!0})),m=e.includeByMetadata?Q(e.includeByMetadata):Boolean;if(!p.length)return[];const T=(await Promise.all(p.map(async c=>{const P=c.versions?.find(x=>x.active),L=P&&{version:P.version,isDefault:P.default,versionFolderId:P.folderId},V=ee(v.posix.relative(f,c.fsPath)),O=c.getSidebar?.(c);return!a.ignoreCustomSidebar&&O?.length?{type:"group",fsPath:c.fsPath,metadata:c.metadata,link:c.slug,routeSlug:c.slug,label:await c.getNavText?.()||c.slug,[h]:c[h],[b]:c[b],sidebarItems:k(O,L,c[h],c[b]),...L,relativePathFromDirectory:v.relative(f,c.fsPath).replace(/@(?<!@[^/]*?@)[^/]+\//,"")}:{type:"link",fsPath:c.fsPath,metadata:c.metadata,[h]:c[h],[b]:c[b],label:await c.getNavText?.()||c.slug,link:c.slug,routeSlug:c.slug,...L,relativePathFromDirectory:V}}))).filter(m);return e.flatten?$(T,a):Z(T,a)}let d=typeof e=="string"?e:e?.page,r,l;if(d){if(d.includes("#")){const[s,u]=d.split("#");u?l=u:A.warn(`Invalid heading anchor format in sidebar: "${u}". Heading anchors should contain only alphanumeric characters, hyphens, and underscores.`),d=s}if(d=j(d),a.locale&&a.locale!==_){const s=J(v.join(a.locale.toLowerCase(),d));r=n.getRouteBySlug(s)}r||(r=n.getRouteBySlug(d)),r||(r=n.getRouteByFsPath(F(n.contentDir,i,a,d,t.fs)))}const g=r?.metadata;if(e?.$ref){let s=F(n.contentDir,i,a,e.$ref,t.fs);if(a.ref!==void 0&&(s=v.posix.join(a.ref,e.$ref)),!t.fs.exists(s))return await S.panicOnBuildContentError(`Failed to load ${s} file. Make sure sidebar $ref path is correct.`),[];const u=await t.cache.load(s,"yaml"),o=v.dirname(s);return await I(u.data,i,n,t,{...a,navFile:s,ref:o})||[]}if(!r){const s=a.excludedFromLinkCheckerPatterns?.catalog.some(o=>o.test(d||"")),u=a.excludedFromLinkCheckerPatterns?.apiFunctions.some(o=>o.test(d||e.href||""));(u||s)&&(e={...e,href:d||e.href,page:void 0,target:e.target??(u?"_blank":void 0)}),await X(e,a,t,i)}if(r&&!e.disconnect&&!a.ignoreCustomSidebar&&(l||r?.getSidebar)){const s=r.versions?.find(o=>o.active),u=s&&{version:s.version,isDefault:s.default,versionFolderId:s.folderId};if(l){let o=[];if(r.getSidebar&&(o=r.getSidebar(r,{...e,...await y(e,n,t,a)}),o&&o.length>0)){const p=o[0];p&&p.link&&(p.link=`${p.link}#${l}`)}if(!o||o.length===0){const p=e.group||e.label||l;o=[{type:"link",fsPath:r.fsPath,metadata:r.metadata,link:`${r.slug}#${l}`,routeSlug:r.slug,label:p,labelTranslationKey:e.labelTranslationKey,...await y(e,n,t,a),[h]:r[h],[b]:{slug:r.slug,fsPath:r.fsPath},...u}]}return k(o,u,r[h],r[b])}if(r?.getSidebar){const o=r.getSidebar(r,{...e,...await y(e,n,t,a)}),p=e.group&&o?.[0]?.routeSlug===r.slug?o.slice(1):o;return k(a.groupCustomSidebars||e.group?[{type:"group",fsPath:r.fsPath,link:r.slug,routeSlug:r.slug,label:e.group||e.label||await r.getNavText?.()||r.slug,items:p,labelTranslationKey:e.labelTranslationKey,metadata:g,badges:e.badges,...await y(e,n,t,a)}]:o,u,r[h],r[b])}}if(r&&!e.group){const s=l?`${r.slug}#${l}`:r.slug;let u=e.label||l||"";u||(u=await r.getNavText?.()||r.slug);const o=r.versions?.find(m=>m.active),p=o&&{version:o.version,isDefault:o.default,versionFolderId:o.folderId};return{type:"link",fsPath:r.fsPath,linkedSidebars:e.linkedSidebars,metadata:g,[h]:e?.rbac||r[h],[b]:{slug:r.slug,fsPath:r.fsPath},label:u,labelTranslationKey:e.labelTranslationKey,link:s,items:await I(e.items,i,n,t,a),separatorLine:e.separatorLine,linePosition:e.linePosition,routeSlug:e.disconnect?void 0:s,external:e.external,target:e.target,badges:e.badges,...await y(e,n,t,a),...p,additionalProps:e.additionalProps}}else if(e?.group){const s=r?.versions?.find(o=>o.active),u=C(a?.navFile);return{type:"group",fsPath:r?.fsPath,linkedSidebars:e.linkedSidebars,metadata:g,version:s?.version||u?.versionName,versionFolderId:s?.folderId||(u?.versionFolderPath?R(u.versionFolderPath):void 0),label:e.group,link:r?.slug,routeSlug:r?.slug,badges:e.badges,labelTranslationKey:e.groupTranslationKey,items:await I(e.items,i,n,t,a),expanded:e.expanded?e.expanded.toString():void 0,selectFirstItemOnExpand:e.selectFirstItemOnExpand,menuStyle:e.menuStyle,separatorLine:e.separatorLine,linePosition:e.linePosition,...await y(e,n,t,a),[h]:e?.rbac,[b]:{slug:r?.slug||"",fsPath:r?.fsPath||""},additionalProps:e.additionalProps}}else{if(e?.href||e?.label)return{type:"link",metadata:g,link:e.href||"",label:e?.label||e?.href||"",labelTranslationKey:e.labelTranslationKey,external:e.external,target:e.target,separatorLine:e.separatorLine,linePosition:e.linePosition,badges:e.badges,...await y(e,n,t,a),[h]:e?.rbac,additionalProps:e.additionalProps};if(e?.separator!=null||e?.separatorLine!=null){const s=C(a?.navFile);return{type:"separator",metadata:g,version:s?.versionName,versionFolderId:s?.versionFolderPath?R(s.versionFolderPath):void 0,label:e.separator,labelTranslationKey:e.separatorTranslationKey,separatorLine:e.separatorLine,linePosition:e.linePosition,...await y(e,n,t,a),[h]:e?.rbac,additionalProps:e.additionalProps}}else{const s=C(a?.navFile);return{type:"error",label:`Can't resolve page: ${JSON.stringify(e)}`,version:s?.versionName,versionFolderId:s?.versionFolderPath?R(s.versionFolderPath):void 0}}}}async function X(e,i,n,t){const{href:a,page:f}=e;if(a||!f)return;const d=F(n.fs.cwd,t,i,f,n.fs),r=n.fs.exists(d),l=await n.isPathIgnored(d),g=(r?"The page is ignored: ":"Can't resolve page: ")+f;(!r||l)&&S.reportBrokenLink({type:"BROKEN_LINK",brokenLinkType:"LINK",title:e.label||e.group||"",link:d,rawLink:f,message:g,sourceFileRelativePath:i.navFile,sourceFileLocation:{line:0}})}function F(e,i,n,t="",a){if(n.ref!==void 0)return w(v.relative(e,v.resolve(e,v.join(n.ref,t))));if(t.startsWith("/")){const f=B(i)?q(i):void 0,d=f?`${a.localizationFolder}/${f}/`:"",r=t.slice(1);return B(r)?r:d+w(r)}return w(v.relative(e,v.resolve(e,i,t)))}function Z(e,i){const n={};for(const r of e){const l=v.dirname(r.relativePathFromDirectory),g=r.version?M+r.version:"",s=v.basename(r.relativePathFromDirectory)+g;d(l,r,s)}const t=f(a(n));return $(t,i);function a(r){const l=[];for(const g of Object.keys(r)){const s=r[g];l.push({...s,items:s.items?a(s.items):void 0})}return l}function f(r){return r.sort((l,g)=>{const s=typeof l=="string"?l.toLowerCase():l.relativePathFromDirectory||l.label||"",u=typeof g=="string"?g.toLowerCase():g.relativePathFromDirectory||g.label||"";return s.startsWith("index.")?-1:u.startsWith("index.")?1:s.localeCompare(u,void 0,{numeric:!0})})}function d(r,l,g){r==="."&&(r="");const s=r.split("/").filter(Boolean);let u=n;for(const o of s){const p=o+(l?.version||"");u[p]||(u[p]={type:"group",version:l?.version,label:o,isDefault:l?.isDefault,versionFolderId:l.versionFolderId,items:{}}),u=u[p].items}u[g]=l}}function $(e,i){return e.flatMap(n=>n?.sidebarItems?i.groupCustomSidebars?{...n,items:n.sidebarItems,sidebarItems:void 0,relativePathFromDirectory:void 0}:n.sidebarItems:{...n,items:n.items?$(n.items,i):void 0})}function k(e,i,n,t){return e.map(a=>({...a,...i,[h]:a[h]||n,[b]:a[b]||t,items:a.type==="group"&&a.items?k(a.items,i,n):a.items}))}function ee(e){return e.replace(/@(?<!@[^/]*?@)[^/]+\//,"")}async function ye(e,i,n,t){const a=(e?.items||[]).filter(r=>r.linkedSidebars?.length).map(r=>({...r,items:void 0})),f=await N(a,i.contentDir,i,n,t),d=new Map;for(const r of f)if(r.linkedSidebars?.length)for(const l of r.linkedSidebars){if(d.has(l)){A.warn(`Only one navbar item can belong to sidebar. "${l}" on 'linkedSidebars' property on "${r.label}" will be ignored.`);continue}d.set(l,{label:r.label,link:r.link})}return d}export{ye as collectItemsLinkedToSidebars,D as normalizeItems,K as resolveItem,I as resolveItems,N as resolveLinksFromConfig};
1
+ import*as h from"path";import{REDOCLY_ROUTE_RBAC as b,REDOCLY_TEAMS_RBAC as p}from"@redocly/config";import{VERSION_SEPARATOR as x}from"../constants/common.js";import{DEFAULT_LOCALE_PLACEHOLDER as M}from"../../constants/common.js";import{removeTrailingSlash as j}from"../../utils/url/remove-trailing-slash.js";import{isPrimitive as W}from"../../utils/guards/is-primitive.js";import{slash as w}from"../../utils/path/slash.js";import{isAbsoluteUrl as z}from"../../utils/url/is-absolute-url.js";import{normalizeRouteSlug as J}from"../../utils/path/normalize-route-slug.js";import{parsePathVersions as C}from"../../utils/path/parse-path-versions.js";import{logger as A}from"../tools/notifiers/logger.js";import{reporter as F}from"../tools/notifiers/reporter.js";import{shaDirPathShort as R}from"../utils/crypto/sha-dir-path-short.js";import{copyStaticFile as U,FileNotFoundError as D}from"../utils/fs.js";import{isIconPath as H,resolveAssetPath as Y}from"../utils/index.js";import{resolveSrcSet as G}from"../utils/resolve-src-set.js";import{isL10nPath as E}from"../fs/utils/is-l10n-path.js";import{getLocaleFromRelativePath as q}from"../fs/utils/get-locale-from-relative-path.js";async function B(e,i,n,s,a){if(!e)return;const f={...a,ignoreCustomSidebar:!0};if(W(e)){if(typeof e=="string"){const r=I(n.contentDir,i,a,e,s.fs);if(s.fs.exists(r)){if(n.getRouteByFsPath(r))return K({page:e},i,n,s,f);{const g=s.fs.getFileInfo(r);return g?U(n.contentDir,g.realRelativePath,n.outdir):void 0}}}return e}return Array.isArray(e)?k(N(e),i,n,s,f):Object.fromEntries(await Promise.all(Object.entries(e).map(async([r,l])=>[r,await B(l,i,n,s,a)])))}function N(e){return e.map(i=>({...i,items:i.items?N(i.items):void 0}))}async function k(e,i,n,s,a){if(Array.isArray(e))return(await Promise.all(e.map(f=>K(f,i,n,s,a)))).flatMap(f=>f)}async function y(e,i,n,s){let a,f;if(typeof e.icon=="object"){if("srcSet"in e.icon)try{a=await G(e.icon.srcSet,n.fs,{fromFileRelativePath:s.navFile,contentDir:i.contentDir,outdir:i.outdir})}catch(d){d instanceof D?await F.panicOnBuildContentError(`Cannot resolve "item.icon.srcSet" from ${s.navFile}: ${d.message}`):await F.panicOnBuild(`Cannot resolve "item.icon.srcSet" from ${s.navFile}: ${d.message}`)}}else if(typeof e.icon=="string")if(z(e.icon)||H(e.icon))try{f=await Y(e.icon,n.fs,{fromFileRelativePath:s.navFile,contentDir:i.contentDir,outdir:i.outdir})}catch(d){d instanceof D?await F.panicOnBuildContentError(`Cannot resolve "item.icon" from ${s.navFile}: file ${f} does not exist`):await F.panicOnBuild(`Cannot resolve "item.icon" from ${s.navFile}: ${d.message}`)}else f=e.icon;return{icon:f,srcSet:a}}function Q(e){return i=>{if(i.type==="link"||i.type==="group"){const n=i.metadata;return n?Object.entries(e).every(([s,a])=>Array.isArray(a)?a.some(f=>n[s]===f):n[s]===a):!1}return!0}}async function K(e,i,n,s,a){if(e?.tab!==void 0||e?.menu!==void 0){const t=`Navigation tabs ("tab"/"menu") are only allowed at the top level of a sidebars.yaml file: ${JSON.stringify(e)}`;return await F.panicOnBuildContentError(`Invalid nav item in %rp. ${t}`,a.navFile),{type:"error",label:t}}if(e?.directory&&e.items?.length)return{type:"error",label:`Can't have both "directory" and "items" in the nav item: ${JSON.stringify(e)}`};e?.directory&&e?.group&&(e={...e,directory:void 0,items:[{directory:e.directory}]});const f=e?.directory?I(n.contentDir,i,a,e.directory,s.fs):void 0;if(f!==void 0){const t=f===""?"":f+"/",{locale:u,ignoredRoutes:o}=a,v=n.getAllRoutesForLocale(u).filter(c=>!o?.has(c.baseSlug||"")&&c.fsPath.startsWith(t)&&!c.excludeFromSidebar).sort((c,P)=>c.fsPath===P.fsPath?0:c.baseSlug.localeCompare(P.baseSlug,void 0,{numeric:!0})),L=e.includeByMetadata?Q(e.includeByMetadata):Boolean;if(!v.length)return[];const T=(await Promise.all(v.map(async c=>{const P=c.versions?.find(_=>_.active),S=P&&{version:P.version,isDefault:P.default,versionFolderId:P.folderId},V=ee(h.posix.relative(f,c.fsPath)),O=c.getSidebar?.(c);return!a.ignoreCustomSidebar&&O?.length?{type:"group",fsPath:c.fsPath,metadata:c.metadata,link:c.slug,routeSlug:c.slug,label:await c.getNavText?.()||c.slug,[p]:c[p],[b]:c[b],sidebarItems:m(O,S,c[p],c[b]),version:S?.version,isDefault:S?.isDefault,versionFolderId:S?.versionFolderId,relativePathFromDirectory:h.relative(f,c.fsPath).replace(/@(?<!@[^/]*?@)[^/]+\//,"")}:{type:"link",fsPath:c.fsPath,metadata:c.metadata,[p]:c[p],[b]:c[b],label:await c.getNavText?.()||c.slug,link:c.slug,routeSlug:c.slug,version:S?.version,isDefault:S?.isDefault,versionFolderId:S?.versionFolderId,relativePathFromDirectory:V}}))).filter(L);return e.flatten?$(T,a):Z(T,a)}let d=typeof e=="string"?e:e?.page,r,l;if(d){if(d.includes("#")){const[t,u]=d.split("#");u?l=u:A.warn(`Invalid heading anchor format in sidebar: "${u}". Heading anchors should contain only alphanumeric characters, hyphens, and underscores.`),d=t}if(d=j(d),a.locale&&a.locale!==M){const t=J(h.join(a.locale.toLowerCase(),d));r=n.getRouteBySlug(t)}r||(r=n.getRouteBySlug(d)),r||(r=n.getRouteByFsPath(I(n.contentDir,i,a,d,s.fs)))}const g=r?.metadata;if(e?.$ref){let t=I(n.contentDir,i,a,e.$ref,s.fs);if(a.ref!==void 0&&(t=h.posix.join(a.ref,e.$ref)),!s.fs.exists(t))return await F.panicOnBuildContentError(`Failed to load ${t} file. Make sure sidebar $ref path is correct.`),[];const u=await s.cache.load(t,"yaml"),o=h.dirname(t);return await k(u.data,i,n,s,{...a,navFile:t,ref:o})||[]}if(!r){const t=a.excludedFromLinkCheckerPatterns?.catalog.some(o=>o.test(d||"")),u=a.excludedFromLinkCheckerPatterns?.apiFunctions.some(o=>o.test(d||e.href||""));(u||t)&&(e={...e,href:d||e.href,page:void 0,target:e.target??(u?"_blank":void 0)}),await X(e,a,s,i)}if(r&&!e.disconnect&&!a.ignoreCustomSidebar&&(l||r?.getSidebar)){const t=r.versions?.find(o=>o.active),u=t&&{version:t.version,isDefault:t.default,versionFolderId:t.folderId};if(l){let o=[];if(r.getSidebar&&(o=r.getSidebar(r,{...e,...await y(e,n,s,a)}),o&&o.length>0)){const v=o[0];v&&v.link&&(v.link=`${v.link}#${l}`)}if(!o||o.length===0){const v=e.group||e.label||l;o=[{type:"link",fsPath:r.fsPath,metadata:r.metadata,link:`${r.slug}#${l}`,routeSlug:r.slug,label:v,labelTranslationKey:e.labelTranslationKey,...await y(e,n,s,a),[p]:r[p],[b]:{slug:r.slug,fsPath:r.fsPath},...u}]}return m(o,u,r[p],r[b])}if(r?.getSidebar){const o=r.getSidebar(r,{...e,...await y(e,n,s,a)}),v=e.group&&o?.[0]?.routeSlug===r.slug?o.slice(1):o;return m(a.groupCustomSidebars||e.group?[{type:"group",fsPath:r.fsPath,link:r.slug,routeSlug:r.slug,label:e.group||e.label||await r.getNavText?.()||r.slug,items:v,labelTranslationKey:e.labelTranslationKey,metadata:g,badges:e.badges,...await y(e,n,s,a)}]:o,u,r[p],r[b])}}if(r&&!e.group){const t=l?`${r.slug}#${l}`:r.slug;let u=e.label||l||"";u||(u=await r.getNavText?.()||r.slug);const o=r.versions?.find(L=>L.active),v=o&&{version:o.version,isDefault:o.default,versionFolderId:o.folderId};return{type:"link",fsPath:r.fsPath,linkedSidebars:e.linkedSidebars,metadata:g,[p]:e?.rbac||r[p],[b]:{slug:r.slug,fsPath:r.fsPath},label:u,labelTranslationKey:e.labelTranslationKey,link:t,items:await k(e.items,i,n,s,a),separatorLine:e.separatorLine,linePosition:e.linePosition,routeSlug:e.disconnect?void 0:t,external:e.external,target:e.target,badges:e.badges,...await y(e,n,s,a),...v,additionalProps:e.additionalProps}}else if(e?.group){const t=r?.versions?.find(o=>o.active),u=C(a?.navFile);return{type:"group",fsPath:r?.fsPath,linkedSidebars:e.linkedSidebars,metadata:g,version:t?.version||u?.versionName,versionFolderId:t?.folderId||(u?.versionFolderPath?R(u.versionFolderPath):void 0),label:e.group,link:r?.slug,routeSlug:r?.slug,badges:e.badges,labelTranslationKey:e.groupTranslationKey,items:await k(e.items,i,n,s,a),expanded:e.expanded?e.expanded.toString():void 0,selectFirstItemOnExpand:e.selectFirstItemOnExpand,menuStyle:e.menuStyle,separatorLine:e.separatorLine,linePosition:e.linePosition,...await y(e,n,s,a),[p]:e?.rbac,[b]:{slug:r?.slug||"",fsPath:r?.fsPath||""},additionalProps:e.additionalProps}}else{if(e?.href||e?.label)return{type:"link",metadata:g,link:e.href||"",label:e?.label||e?.href||"",labelTranslationKey:e.labelTranslationKey,external:e.external,target:e.target,separatorLine:e.separatorLine,linePosition:e.linePosition,badges:e.badges,...await y(e,n,s,a),[p]:e?.rbac,additionalProps:e.additionalProps};if(e?.separator!=null||e?.separatorLine!=null){const t=C(a?.navFile);return{type:"separator",metadata:g,version:t?.versionName,versionFolderId:t?.versionFolderPath?R(t.versionFolderPath):void 0,label:e.separator,labelTranslationKey:e.separatorTranslationKey,separatorLine:e.separatorLine,linePosition:e.linePosition,...await y(e,n,s,a),[p]:e?.rbac,additionalProps:e.additionalProps}}else{const t=C(a?.navFile);return{type:"error",label:`Can't resolve page: ${JSON.stringify(e)}`,version:t?.versionName,versionFolderId:t?.versionFolderPath?R(t.versionFolderPath):void 0}}}}async function X(e,i,n,s){const{href:a,page:f}=e;if(a||!f)return;const d=I(n.fs.cwd,s,i,f,n.fs),r=n.fs.exists(d),l=await n.isPathIgnored(d),g=(r?"The page is ignored: ":"Can't resolve page: ")+f;(!r||l)&&F.reportBrokenLink({type:"BROKEN_LINK",brokenLinkType:"LINK",title:e.label||e.group||"",link:d,rawLink:f,message:g,sourceFileRelativePath:i.navFile,sourceFileLocation:{line:0}})}function I(e,i,n,s="",a){if(n.ref!==void 0)return w(h.relative(e,h.resolve(e,h.join(n.ref,s))));if(s.startsWith("/")){const f=E(i)?q(i):void 0,d=f?`${a.localizationFolder}/${f}/`:"",r=s.slice(1);return E(r)?r:d+w(r)}return w(h.relative(e,h.resolve(e,i,s)))}function Z(e,i){const n={};for(const r of e){const l=h.dirname(r.relativePathFromDirectory),g=r.version?x+r.version:"",t=h.basename(r.relativePathFromDirectory)+g;d(l,r,t)}const s=f(a(n));return $(s,i);function a(r){const l=[];for(const g of Object.keys(r)){const t=r[g];l.push({...t,items:t.items?a(t.items):void 0})}return l}function f(r){return r.sort((l,g)=>{const t=typeof l=="string"?l.toLowerCase():l.relativePathFromDirectory||l.label||"",u=typeof g=="string"?g.toLowerCase():g.relativePathFromDirectory||g.label||"";return t.startsWith("index.")?-1:u.startsWith("index.")?1:t.localeCompare(u,void 0,{numeric:!0})})}function d(r,l,g){r==="."&&(r="");const t=r.split("/").filter(Boolean);let u=n;for(const o of t){const v=o+(l?.version||"");u[v]||(u[v]={type:"group",version:l?.version,label:o,isDefault:l?.isDefault,versionFolderId:l.versionFolderId,items:{}}),u=u[v].items}u[g]=l}}function $(e,i){return e.flatMap(n=>n?.sidebarItems?i.groupCustomSidebars?{...n,items:n.sidebarItems,sidebarItems:void 0,relativePathFromDirectory:void 0}:n.sidebarItems:{...n,items:n.items?$(n.items,i):void 0})}function m(e,i,n,s){return e.map(a=>({...a,...i,[p]:a[p]||n,[b]:a[b]||s,items:a.type==="group"&&a.items?m(a.items,i,n):a.items}))}function ee(e){return e.replace(/@(?<!@[^/]*?@)[^/]+\//,"")}async function ye(e,i,n,s){const a=(e?.items||[]).filter(r=>r.linkedSidebars?.length).map(({items:r,...l})=>l),f=await B(a,i.contentDir,i,n,s),d=new Map;for(const r of f)if(r.linkedSidebars?.length)for(const l of r.linkedSidebars){if(d.has(l)){A.warn(`Only one navbar item can belong to sidebar. "${l}" on 'linkedSidebars' property on "${r.label}" will be ignored.`);continue}d.set(l,{label:r.label,link:r.link})}return d}export{ye as collectItemsLinkedToSidebars,N as normalizeItems,K as resolveItem,k as resolveItems,B as resolveLinksFromConfig};
@@ -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 w}from"../utils.js";import{reactFrontmatterLoader as v}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":v},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));await D(n,o,r);const{data:t}=await f.load(e,"react-frontmatter"),u=await F(e,"react-frontmatter",t,a),s=w(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 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,4 +1,4 @@
1
1
  import type { ContentFs } from '../fs/content-fs.js';
2
2
  import type { FileInfo, ProcessContentActions } from '../types';
3
- export declare function registerPageProps(file: FileInfo, fs: ContentFs, actions: ProcessContentActions): Promise<void>;
3
+ export declare function registerPageProps(file: FileInfo, fs: ContentFs, actions: ProcessContentActions): void;
4
4
  //# sourceMappingURL=register-page-props.d.ts.map
@@ -1 +1 @@
1
- import o from"path";async function l(e,t,a){const{realRelativePath:s,relativePath:i}=e;let r;s.match(/\.md$/)&&(r=s.replace(/\.md$/,".props.ts")),s.match(/\.page\.tsx?$/)&&(r=s.replace(/\.page\.tsx?$/,".props.ts"));const p=r?await n(r,t):void 0;p&&a.registerPagePropsGetter(i,p)}async function n(e,t){return await t.exists(e)?o.resolve(t.cwd,e):void 0}export{l as registerPageProps};
1
+ import a from"path";function l(e,t,p){const{realRelativePath:r,relativePath:o}=e;let s;r.match(/\.md$/)&&(s=r.replace(/\.md$/,".props.ts")),r.match(/\.page\.tsx?$/)&&(s=r.replace(/\.page\.tsx?$/,".props.ts"));const i=s?n(s,t):void 0;i&&p.registerPagePropsGetter(o,i)}function n(e,t){return t.exists(e)?a.resolve(t.cwd,e):void 0}export{l as registerPageProps};
@@ -4,4 +4,4 @@ import{writeFileSync as at}from"node:fs";import*as g from"path";import{removeMar
4
4
  - ${y.join(`
5
5
  - `)}`,m);return}const{fromDir:k,resolveOptions:n}=V(m,f,p);return Ft(l,k,a,c,n)}))).flat().filter(M),e=vt(r),s=It(e);if(s.length){await I.panicOnBuildContentError(`Navigation tabs conflict in %rp. A route can belong to one tab only:
6
6
  - ${s.map(({routeSlug:l,owners:f})=>`${l} is claimed by ${f.map(m=>`"${m}"`).join(" and ")}`).join(`
7
- - `)}`,i);return}return{routeOwners:e,sharedData:{items:[],tabs:r},navItems:Ct(r)}}function V(t,i,o){return{fromDir:g.dirname(g.join(u,t)),resolveOptions:{locale:i,ignoredRoutes:o,navFile:t,excludedFromLinkCheckerPatterns:T}}}async function rt(t,{routeOwners:i,sharedData:o,navItems:r}){const e=Q(t),s=new Set;for(const{routeSlug:f,items:m}of i){const p=a.getRouteBySlug(f)?.fsPath??"",y=x[p];y&&(Array.from(s).find(n=>n.key===y.key&&n.version===y.version)||s.add(y)),a.addRouteSharedData(f,"sidebar",e),F.set(J(f),m)}const l=s.size===1?Array.from(s)[0]:void 0;return await a.createSharedData(e,{relatedNavbarItem:tt?.get(t),...o,catalogEntity:l?{key:l.key,version:l.version}:void 0}),{firstLink:B(r,f=>!!f.link),resolved:r}}async function K(t,i,o,r=!1){const e=structuredClone(i);o&&o!==E&&e.items.forEach(n=>{n.directory=g.posix.join(d.localizationFolder||"",o,n.directory||"")});const s=await q(e.items,u,a,c,{groupCustomSidebars:!0,locale:o,navFile:Y,excludedFromLinkCheckerPatterns:T});if(!s){await I.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}Bt(s);const l=o===E?"":"/"+o.toLowerCase(),f=o===E?"":`-${o}`,m=J(g.posix.join(l,e.slug));if(r)for(const n of s){const S=B(n.items||[],v=>!!v.routeSlug);if(!S?.routeSlug)continue;const b=F.get(S.routeSlug);if(!b)continue;const O=N(b,"routeSlug"),R="current-catalog-info-"+n.routeSlug+f,P={catalog:{label:e.title,titleTranslationKey:e.titleTranslationKey,link:m,icon:e?.icon},item:{label:n.metadata?.title,link:n.link,icon:n.icon}};await a.createSharedData(R,P);for(const v of O)a.addRouteSharedData(v,"current-catalog-info",R),C.add(v);const X=B(b,v=>!!v.link&&!v.external&&ut(v.link)&&(!n.version||v.version===n.version));X&&(n.sidebar=[{...X,items:void 0}])}const p={},y=new Set;for(const n of s){if(!(n.routeSlug||n.sidebar?.[0]?.routeSlug)||!n.fsPath||y.has(n.fsPath))continue;y.add(n.fsPath);const b=g.dirname(n.fsPath);p[b]=(p[b]||0)+1}if(r){const n=await a.createSharedData(pt(t,f),s.flatMap(S=>{const b=g.dirname(S.fsPath??""),O=p[b]===1,R=P=>({...P,fsPath:O?b:P.fsPath??""});return S.type==="group"&&S.items?.every(P=>P.type==="group")?(S.items||[]).map(R):R(S)}));a.addRouteSharedData(m,"catalog",n),Ot(o,s,j,p)}const k=N(s,"routeSlug");for(const n of k)C.add(n)}})}}}function Ot(u,a,c,h){if(u===E)for(const d of a){const D=d.routeSlug||d.sidebar?.[0]?.routeSlug;if(!D||!d.fsPath)continue;const F=g.dirname(d.fsPath),C=h[F]===1;c.set(D,{rootFileFsPath:d.fsPath,fsPath:C?F:d.fsPath,metadata:d.metadata||{},title:d.metadata?.title||d.label||"Untitled",version:d.version||"latest"})}}function Bt(u){const a=c=>{typeof c.metadata?.description=="string"&&(c.metadata={...c.metadata,description:nt(c.metadata.description)})};for(const c of u)if(c.routeSlug)a(c);else for(const h of c.items||[])a(h)}function Q(u){return st+dt(u)}async function fe(u,a,c){const h=g.posix.join(g.dirname(u),a);return await c.exists(h)?Q(h):(await I.panicOnBuildContentErrorForRealFile("File %rp: Failed to create relative path for sidebars.yaml using %s",u,c,u,a),null)}function Mt(u){const a=u.replaceAll("/","_");if(a.length>Lt){const c=a.slice(0,Tt),h=gt(u).slice(0,_t).replaceAll("/","_");return c+h}else return a}export{fe as resolveSidebarId,ce as sidebarsPlugin,Bt as stripMarkdocFromDescriptions};
7
+ - `)}`,i);return}return{routeOwners:e,sharedData:{items:[],tabs:r},navItems:Ct(r)}}function V(t,i,o){return{fromDir:g.dirname(g.join(u,t)),resolveOptions:{locale:i,ignoredRoutes:o,navFile:t,excludedFromLinkCheckerPatterns:T}}}async function rt(t,{routeOwners:i,sharedData:o,navItems:r}){const e=Q(t),s=new Set;for(const{routeSlug:f,items:m}of i){const p=a.getRouteBySlug(f)?.fsPath??"",y=x[p];y&&(Array.from(s).find(n=>n.key===y.key&&n.version===y.version)||s.add(y)),a.addRouteSharedData(f,"sidebar",e),F.set(J(f),m)}const l=s.size===1?Array.from(s)[0]:void 0;return await a.createSharedData(e,{relatedNavbarItem:tt?.get(t),...o,catalogEntity:l?{key:l.key,version:l.version}:void 0}),{firstLink:B(r,f=>!!f.link),resolved:r}}async function K(t,i,o,r=!1){const e=structuredClone(i);o&&o!==E&&e.items.forEach(n=>{n.directory=g.posix.join(d.localizationFolder||"",o,n.directory||"")});const s=await q(e.items,u,a,c,{groupCustomSidebars:!0,locale:o,navFile:Y,excludedFromLinkCheckerPatterns:T});if(!s){await I.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}Bt(s);const l=o===E?"":"/"+o.toLowerCase(),f=o===E?"":`-${o}`,m=J(g.posix.join(l,e.slug));if(r)for(const n of s){const S=B(n.items||[],v=>!!v.routeSlug);if(!S?.routeSlug)continue;const b=F.get(S.routeSlug);if(!b)continue;const O=N(b,"routeSlug"),R="current-catalog-info-"+n.routeSlug+f,P={catalog:{label:e.title,titleTranslationKey:e.titleTranslationKey,link:m,icon:e?.icon},item:{label:n.metadata?.title,link:n.link,icon:n.icon}};await a.createSharedData(R,P);for(const v of O)a.addRouteSharedData(v,"current-catalog-info",R),C.add(v);const X=B(b,v=>!!v.link&&!v.external&&ut(v.link)&&(!n.version||v.version===n.version));X&&(n.sidebar=[{...X,items:void 0}])}const p={},y=new Set;for(const n of s){if(!(n.routeSlug||n.sidebar?.[0]?.routeSlug)||!n.fsPath||y.has(n.fsPath))continue;y.add(n.fsPath);const b=g.dirname(n.fsPath);p[b]=(p[b]||0)+1}if(r){const n=await a.createSharedData(pt(t,f),s.flatMap(S=>{const b=g.dirname(S.fsPath??""),O=p[b]===1,R=P=>({...P,fsPath:O?b:P.fsPath??""});return S.type==="group"&&S.items?.every(P=>P.type==="group")?(S.items||[]).map(R):R(S)}));a.addRouteSharedData(m,"catalog",n),Ot(o,s,j,p)}const k=N(s,"routeSlug");for(const n of k)C.add(n)}})}}}function Ot(u,a,c,h){if(u===E)for(const d of a){const D=d.routeSlug||d.sidebar?.[0]?.routeSlug;if(!D||!d.fsPath)continue;const F=g.dirname(d.fsPath),C=h[F]===1;c.set(D,{rootFileFsPath:d.fsPath,fsPath:C?F:d.fsPath,metadata:d.metadata||{},title:d.metadata?.title||d.label||"Untitled",version:d.version||"latest"})}}function Bt(u){const a=c=>{typeof c.metadata?.description=="string"&&(c.metadata={...c.metadata,description:nt(c.metadata.description)})};for(const c of u)if(c.routeSlug)a(c);else for(const h of c.items||[])a(h)}function Q(u){return st+dt(u)}async function fe(u,a,c){const h=g.posix.join(g.dirname(u),a);return c.exists(h)?Q(h):(await I.panicOnBuildContentErrorForRealFile("File %rp: Failed to create relative path for sidebars.yaml using %s",u,c,u,a),null)}function Mt(u){const a=u.replaceAll("/","_");if(a.length>Lt){const c=a.slice(0,Tt),h=gt(u).slice(0,_t).replaceAll("/","_");return c+h}else return a}export{fe as resolveSidebarId,ce as sidebarsPlugin,Bt as stripMarkdocFromDescriptions};
@@ -1 +1 @@
1
- import s from"path";import{collectPropValueDeep as g}from"../../../utils/tree/collect-prop-value-deep.js";import{removeTrailingSlash as f}from"../../../utils/url/remove-trailing-slash.js";import{slash as C}from"../../../utils/path/slash.js";import{removeLeadingSlash as u}from"../../../utils/url/remove-leading-slash.js";import{reporter as p}from"../../tools/notifiers/reporter.js";import{getCompleteCatalogConfig as h}from"../catalog-entities/get-complete-catalog-config.js";async function k({fs:r,cache:i},e,n){const a=new Map;for(const t of n){if(!await r.exists(t))continue;const o=s.dirname(s.join(e,t)),m=(await i.load(t,"yaml")).data;try{const c=g(m,"$ref");for(const d of c){const l=C(s.relative(e,s.join(o,d)));a.has(l)&&await p.panicOnBuildContentError(`Sidebar reference '${l}' was used multiple times.`),a.set(l,t)}}catch(c){if(c.message.includes("not iterable")){await p.panicOnBuildContentErrorForRealFile('Invalid sidebar format at %rp, "items" should be an array',t,r,t);continue}throw c}}return a}function v(r){function i(e,n){if(n.includes(e))return[...n,e];const a=r.get(e);if(a){const t=i(a,[...n,e]);if(t)return t}return!1}for(const e of r.keys()){const n=i(e,[]);if(n)return n}return!1}function P(r){const i=r.apiFunctions?.folders?.map(o=>new RegExp(`^/?(${u(f(o))})(/|$)`))||[],e=[new RegExp("^/?(api)(/|$)")],n=h(r.entitiesCatalog),t=Object.values(n?.catalogs||{}).map(o=>o?.slug?new RegExp(`^/?(catalogs\\/${u(f(o?.slug||""))})(/|$)`):null).filter(o=>o!==null);return{apiFunctions:[...i,...e],catalog:t}}export{P as getExcludedFromLinkCheckerPatterns,k as getSidebarReferences,v as hasCircularDependency};
1
+ import s from"path";import{collectPropValueDeep as g}from"../../../utils/tree/collect-prop-value-deep.js";import{removeTrailingSlash as f}from"../../../utils/url/remove-trailing-slash.js";import{slash as C}from"../../../utils/path/slash.js";import{removeLeadingSlash as u}from"../../../utils/url/remove-leading-slash.js";import{reporter as p}from"../../tools/notifiers/reporter.js";import{getCompleteCatalogConfig as h}from"../catalog-entities/get-complete-catalog-config.js";async function k({fs:r,cache:i},e,n){const a=new Map;for(const t of n){if(!r.exists(t))continue;const o=s.dirname(s.join(e,t)),m=(await i.load(t,"yaml")).data;try{const c=g(m,"$ref");for(const d of c){const l=C(s.relative(e,s.join(o,d)));a.has(l)&&await p.panicOnBuildContentError(`Sidebar reference '${l}' was used multiple times.`),a.set(l,t)}}catch(c){if(c.message.includes("not iterable")){await p.panicOnBuildContentErrorForRealFile('Invalid sidebar format at %rp, "items" should be an array',t,r,t);continue}throw c}}return a}function v(r){function i(e,n){if(n.includes(e))return[...n,e];const a=r.get(e);if(a){const t=i(a,[...n,e]);if(t)return t}return!1}for(const e of r.keys()){const n=i(e,[]);if(n)return n}return!1}function P(r){const i=r.apiFunctions?.folders?.map(o=>new RegExp(`^/?(${u(f(o))})(/|$)`))||[],e=[new RegExp("^/?(api)(/|$)")],n=h(r.entitiesCatalog),t=Object.values(n?.catalogs||{}).map(o=>o?.slug?new RegExp(`^/?(catalogs\\/${u(f(o?.slug||""))})(/|$)`):null).filter(o=>o!==null);return{apiFunctions:[...i,...e],catalog:t}}export{P as getExcludedFromLinkCheckerPatterns,k as getSidebarReferences,v as hasCircularDependency};
@@ -1 +1 @@
1
- import{PACKAGE_NAME as e}from"../../../config/product-gates.js";const r=["@redocly/realm","@redocly/reef","@redocly/redoc-reef","@redocly/revel-reef"];function c(){return r.includes(e)}export{c as hasProjectDatabase};
1
+ import{PACKAGE_NAME as e}from"../../../config/product-gates.js";const r=["@redocly/realm","@redocly/framework","@redocly/reef","@redocly/redoc-reef","@redocly/revel-reef"];function c(){return r.includes(e)}export{c as hasProjectDatabase};
@@ -1,7 +1,7 @@
1
1
  import { type Node } from '@markdoc/markdoc';
2
2
  import type { JSX } from 'react';
3
3
  import type { CommonError, GlobalData } from '../types/index.js';
4
- import type { MiddlewareDetails, PageRouteInit, PageRouteDetails, RouteDetails, LifecycleContext, ApiRoute, ParseMarkdocOpts, WildcardRedirectsTree, RedirectOptions, McpToolRegistration, McpToolSchema, MarkdocOptions } from './types';
4
+ import type { MiddlewareDetails, PageRouteInit, PageRouteDetails, RouteDetails, LifecycleContext, ApiRoute, ParseMarkdocOpts, WildcardRedirectsTree, StaticFilePaths, RedirectOptions, McpToolRegistration, McpToolSchema, MarkdocOptions } from './types';
5
5
  import type { Skill } from './types/plugins/skills.js';
6
6
  import type { RedoclyConfig, RedirectConfig, CompilationError, PageStaticData } from '@redocly/config';
7
7
  import type { SearchFacet } from '@redocly/theme/core/types';
@@ -28,6 +28,7 @@ export type ComputedRedoclyConfig = {
28
28
  export declare class Store {
29
29
  #private;
30
30
  routesBySlug: Map<string, PageRouteDetails>;
31
+ staticFilePaths: StaticFilePaths;
31
32
  replacedEnvVars: Record<string, {
32
33
  original: string;
33
34
  replaced: string;
@@ -112,6 +113,7 @@ export declare class Store {
112
113
  loadApiDocuments(context: LifecycleContext): Promise<BundledApiDefinition[]>;
113
114
  setSearchEngine(engine: SearchEngine): void;
114
115
  setSearchFacets: (searchFacets: Map<string, SearchFacet>) => void;
116
+ setStaticFilePaths: (staticFilePaths: StaticFilePaths) => void;
115
117
  setGlobalConfig: (data: Partial<RedoclyConfig>) => void;
116
118
  getConfig: () => RedoclyConfig;
117
119
  getGlobalConfig: <T = unknown>(key: string) => T;
@@ -1 +1 @@
1
- import A from"@markdoc/markdoc";import{parseAndResolveMarkdoc as T}from"./plugins/markdown/compiler.js";import{getPathnameForLocale as M}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as g}from"../constants/common.js";import{DEFAULT_TITLE as O,MARKDOC_PARTIALS_DATA_KEY as m,MARKDOC_PARTIALS_DEPS_KEY as k}from"./constants/common.js";import{GATED_MARKDOC_TAGS as R}from"./constants/entitlements.js";import{isObject as L}from"../utils/guards/is-object.js";import{mapObject as H}from"../utils/object/map-object.js";import{getValueDeep as y}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as D}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as h}from"../utils/path/normalize-route-slug.js";import{isLocalLink as S}from"../utils/path/is-local-link.js";import{reporter as w}from"./tools/notifiers/reporter.js";import{logger as u}from"./tools/notifiers/logger.js";import{sha1 as G}from"./utils/crypto/sha1.js";import{envConfig as _,setEnv as B}from"./config/env-config.js";import{KvService as F}from"./persistence/kv/services/kv-service.js";import{SandboxContext as I}from"./utils/sandbox-context.js";import{writeSharedData as N}from"./utils/index.js";import{renderComponents as V}from"./ssr/render.js";import{readStaticData as q,writeStaticData as U}from"./utils/static-data.js";import{getMarkdocOptions as j}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as v}from"./entitlements/entitlements-provider.js";import{isRouteReserved as x}from"./plugins/get-reserved-routes.js";import{isL10nPath as K}from"./fs/utils/is-l10n-path.js";import{resolveGlobMapValue as J}from"./utils/globs.js";import{replaceEnvVariablesDeep as W}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as $}from"./utils/redirects/find-redirect.js";import{followRedirectChain as z}from"./utils/redirects/follow-redirect-chain.js";import{addWildcardRedirectToTree as Y}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as Z}from"../cli/telemetry/helpers/trace-step.js";const E={routesBySlug:"map",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",config:"object",ssr:"object",searchFacets:"map",routesPartials:"map",mcpToolHandlers:"map",skills:"map",devLogin:"object"},P="PLAN_GATES",Q=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORGANIZATION_SLUG","ORGANIZATION_ID","ORG_ID"],ke="userDefinedApiFunctions";class b{routesBySlug=new Map;replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#t={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;routesPartials=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;mcpToolHandlers=new Map;skills=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};devLogin=!1;#a=void 0;config={configFilePath:"",redirects:{},wildcardRedirectsTree:{},access:{rbac:{},requiresLogin:!1},directoryPermissions:{},devLogin:!1,ssoDirect:{}};#i;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#n;userCodeReady;#s=Promise.resolve();#c;#l=Promise.resolve();#d;#u=Promise.resolve();#h;#e=!1;#r=0;#f=0;#o=new Map;constructor({outdir:e,contentDir:s,serverMode:t=!1,serverOutDir:r}){this.#i=s,this.outdir=e,this.serverMode=t,this.serverOutDir=r,I.register({serverOutDir:r,readRoots:[e,process.cwd()]}),this.userCodeReady=new Promise(o=>{this.#n=o})}on(e,s){const t=this.listeners.get(e);t?t.add(s):this.listeners.set(e,new Set([s]))}queueEvent=(e,s,...t)=>{this.#o.set(e+String(s),[e,s,...t])};runListeners=(e,s,...t)=>{for(const r of this.listeners.get(e)||new Set)s?r(s,...t):r(...t)};startPluginsRun(){this.clear(),this.#s=new Promise(e=>{this.#c=e})}waitForPluginsLifecycle(){return Promise.all([this.#s,this.#l,this.#u])}waitForPluginsRun(){return this.#s}finishPluginsRun(){this.#c?.();for(const e of this.#o.values())this.runListeners(...e);this.#o.clear()}startEsbuildRun(){this.#l=new Promise(e=>{this.#d=e})}finishEsbuildRun(){this.#d?.()}markRequestHandlersEntryOutdated(){this.#r++,!this.#e&&(this.#e=!0,this.#u=new Promise(e=>{this.#h=e}))}noteRequestHandlersEntryBuildStart(){this.#f=this.#r}markRequestHandlersEntryUpdated(){this.#e&&(this.#r>this.#f||(this.#e=!1,this.#h?.()))}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#i}markUserCodeReady(){this.#n?.(!0)}async reloadMarkdocOptions(){await Z("com.redocly.build.reloadMarkdocOptions",async()=>{const e=v.instance(),s=await j(this.serverOutDir),t=Object.fromEntries(Object.entries(s.tags).filter(([r])=>R[r]!=null?e.canAccessFeature(R[r]):!0));this.#a={...s,tags:t}})}get markdocOptions(){return{...this.#a,partials:this.getGlobalConfig(m),themeConfig:this.config.markdown}}setGlobalData=e=>{const s=this.globalData,t={...this.globalData,...e};this.globalData=t,JSON.stringify(t)!==JSON.stringify(s)&&this.queueEvent("global-data-updated",void 0,t)};getGlobalData=()=>this.globalData;getKv=async()=>F.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async({input:e,context:s,deps:t,resource:r})=>{const{data:{info:o,ast:i},compoundHash:l}=await T(e,this.markdocOptions,{actions:this,context:s},r);for(const a of o.sharedDataDeps||[]){for(const n of t?.routeSlugs||[])this.addRouteSharedData(n,a,a);for(const n of t?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(a),this.sharedDataDeps.set(n,c)}}for(const a of o.dynamicMarkdocComponents||[]){for(const n of t?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(a),this.routesDynamicComponents.set(n,c)}for(const n of t?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(a),this.sharedDataMarkdocComponents.set(n,c)}}if(t?.routeSlugs&&o.partials?.length)for(const a of t.routeSlugs){const n=this.routesPartials.get(a)||[];for(const c of o.partials)n.includes(c)||n.push(c);this.routesPartials.set(a,n)}return{info:o,ast:i,compoundHash:l}};async loadApiDocuments(e){return(await e.cache.load(".","api-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setGlobalConfig=e=>{const s=Object.keys(e);for(const l of s)for(const a in this.replacedEnvVars)if(a===l||a.startsWith(`${l}:`)){const n=a.split(":"),{error:c,value:d}=y(e,n);(c||d!==this.replacedEnvVars[a].replaced)&&delete this.replacedEnvVars[a]}const{resolvedObj:t,unsetEnvVars:r,replacedValues:o}=W(e);for(const l of r)this.unsetEnvVars.add(l);Object.assign(this.replacedEnvVars,o);const i=t.seo?.siteUrl?.trim();i&&(t.seo={...t.seo,siteUrl:URL.canParse(i)?new URL(i).origin:D(i)}),Object.assign(this.config,t)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,s,t={})=>{if(!v.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const i=h(e).toLowerCase();this.config.redirects[i]=s;const{trackOriginalSource:l=!0}=t,a=this.getGlobalConfig("originalRedirectSources");l&&Array.isArray(a)&&!a.includes(i)&&a.push(i),i.endsWith("*")&&Y(this.config.wildcardRedirectsTree,i)};getRedirect=e=>{const s=h(e).toLowerCase(),t=$(s,this.config.redirects,this.config.wildcardRedirectsTree);if(!t)return null;if(S(t.to)){const r=h(t.to).toLowerCase();if(!r.endsWith("*")&&z(r,[s],this.config.redirects,this.config.wildcardRedirectsTree).type==="cycle")return null}return{to:t.to,type:t.type}};createSharedData=async(e,s,t)=>{if(t&&this.#t[e]===t)return e;const r=JSON.stringify(s),o=t??G(r);return this.#t[e]===o||(this.#t[e]=o,await N(e,r,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,s,t)=>{const r=D(e),o=this.routesSharedData.get(r)||{};o[s]=t,this.routesSharedData.set(r,o),u.verbose(`Adding shared data to ${e}, ${s}, ${t}`)};getRouteSharedDataByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.routesSharedData.get(s)||{}:{}};getPartialsForRoute=e=>{const s=this.getGlobalConfig(m)||{},t=this.routesPartials.get(e);if(!t||t.length===0)return{};const r=this.getGlobalConfig(k)||{},o=new Set(t),i=Array.from(t);for(let a=0;a<i.length;a++){const n=i[a],c=r[n]?.partials??[];for(const d of c)o.has(d)||(o.add(d),i.push(d))}const l={};for(const a of o)s[a]&&(l[a]=s[a]);return l};addRoute=e=>{const t={...J(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:t}),u.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,s,t)=>{const r=[g,...this.lifecycleContext?.fs.localeFolders||[]].map(o=>({code:o,name:o}));for(const o of r){const i=M(e,g,o.code,r);this.addRouteSharedData(i,s,t)}};addApiRoute=e=>{this.apiRoutes.push(e),u.verbose("Created API route %s",e.slug)};addMcpTools=(e,s)=>{for(const t of s){const r=this.mcpToolHandlers.get(t.name);r&&r.importPath!==e&&u.warn('MCP tool "%s" from %s overwrites the tool registered from %s',t.name,e,r.importPath),this.mcpToolHandlers.set(t.name,{...t,importPath:e}),u.verbose("Created MCP tool %s",t.name)}};getMcpTools=()=>Array.from(this.mcpToolHandlers.values());markGatedMcpTools=e=>{for(const s of e){const t=this.mcpToolHandlers.get(s);t&&this.mcpToolHandlers.set(s,{...t,hasAvailabilityGate:!0})}};addSkills=e=>{for(const s of e)this.skills.set(s.slug,s),u.verbose("Discovered skill %s",s.slug)};getSkills=()=>Array.from(this.skills.values());removeMcpTools=e=>{for(const s of e)this.mcpToolHandlers.delete(s)};addMiddleware=e=>{this.middleware.push(e),u.verbose("Created middleware %s",e.id)};setResourceResponseHeaders=(e,s)=>{this.config.responseHeaders||(this.config.responseHeaders={});const t=new Set(s.map(i=>i.name.toLowerCase())),o=[...(this.config.responseHeaders[e]??[]).filter(i=>!t.has(i.name.toLowerCase())),...s];this.config.responseHeaders[e]=o};getRouteByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.getRouteBySlug(s):void 0};getRouteBySlug=(e,s={})=>{const{followRedirect:t=!0}=s,r=this.getRedirect(e);return t&&r?this.routesBySlug.get(h(r.to)):this.routesBySlug.get(e)};hasRouteOrRedirectBySlug=e=>{if(this.routesBySlug.has(e)||x(e,this.getConfig()))return!0;const s=this.getRedirect(e);if(!s)return!1;if(!S(s.to))return!0;const t=h(s.to);return this.routesBySlug.has(t)};getRoutesByTemplateId=e=>this.newRoutes.filter(s=>s.templateId===e);getAllRoutesForLocale=(e=g)=>{const s=Array.from(this.routesBySlug.values()),t=e.toLowerCase();return s.filter(r=>e===g?!K(r.fsPath):r.slug.startsWith(`/${t}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,s)=>(this.templates.set(e,s),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};createRequestHandler=(e,s)=>(this.apiRoutesRequestHandlers.set(e,s),e);clearRequestHandlersByPrefix=e=>{for(const s of this.apiRoutesRequestHandlers.keys())s.startsWith(e)&&this.apiRoutesRequestHandlers.delete(s)};registerServerPropsGetter=(e,s)=>(this.serverPropsGetters.set(e,s),e);registerPagePropsGetter=(e,s)=>{this.pagePropsGetters.set(e,s)};async writeRouteStaticData(e,s){const t=await this.resolveRouteStaticData(e,s,!1);t&&U(e.slug,t,this.outdir)}async resolveRouteStaticData(e,s,t){if(this.serverMode)return q(e.slug,this.outdir);const r={...this,contentDir:this.contentDir,parseMarkdoc:({input:c,context:d,resource:f})=>this.parseMarkdoc({input:c,context:d,deps:{routeSlugs:[e.slug]},resource:f})},o=await e.getStaticData?.(e,r)||{},i=new Set(this.routesDynamicComponents.get(e.slug)),l=this.routesSharedData.get(e.slug)||{};for(const c of Object.values(l)){const d=this.sharedDataMarkdocComponents.get(c);d&&d.forEach(p=>i.add(p));const f=this.sharedDataDeps.get(c);f&&f.forEach(p=>this.addRouteSharedData(e.slug,p,p))}const a=this.getGlobalConfig("seo"),n=o?.frontmatter||{};return{...o,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await e.getNavText?.()}},props:{...o.props,dynamicMarkdocComponents:Array.from(i),metadata:{...o?.props?.metadata,...e.metadata},seo:{title:O,...a,...o.props?.seo,siteUrl:a?.siteUrl},compilationErrors:this.compilationErrors},lastModified:t||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,s){if(!e?.length)return;const t=typeof e[0]=="string"?e.join(""):V(e);t&&(s==="head"?this.ssr.headTags.push(t):s==="preBody"?this.ssr.preBodyTags.push(t):this.ssr.postBodyTags.push(t))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.skills.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const e=[];for(const[t,r]of Object.entries(E))switch(r){case"map":{const o=Array.from(this[t].entries());e.push([t,o]);break}case"object":if(t==="config"){e.push([t,await this.getConfigWithEnvPlaceholders()]);break}e.push([t,this[t]]);break;default:throw new Error("Invalid format")}const s=Object.fromEntries(e);return s[P]=_.PLAN_GATES,s}static fromJson(e,s){const t=new b(s);for(const[o,i]of Object.entries(E))switch(i){case"map":t[o]=new Map(e[o]);break;case"object":if(o==="config"){t.setGlobalConfig(e[o]);break}t[o]=e[o];break;default:throw new Error("Invalid format")}t.config[m]=X(t.config[m]||{});const r=e[P];return r&&B("PLAN_GATES",r),t}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const s in this.replacedEnvVars){const{original:t}=this.replacedEnvVars[s],r=s.split(":"),o=r.pop(),{error:i,value:l}=y(e,r);if(i||!L(l)&&!Array.isArray(l)){await w.panicOnBuild(`Failed to replace env var with env name for ${s}`);continue}l[o]=t}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(t=>!Q.includes(t));if(e.length===0)return;const s=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await w.panicOnBuildContentError(s)}}function X(C){return H(C,e=>A.Ast.fromJSON(JSON.stringify(e)))}export{b as Store,ke as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
1
+ import A from"@markdoc/markdoc";import{parseAndResolveMarkdoc as T}from"./plugins/markdown/compiler.js";import{getPathnameForLocale as M}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as g}from"../constants/common.js";import{DEFAULT_TITLE as O,MARKDOC_PARTIALS_DATA_KEY as m,MARKDOC_PARTIALS_DEPS_KEY as k}from"./constants/common.js";import{GATED_MARKDOC_TAGS as R}from"./constants/entitlements.js";import{isObject as L}from"../utils/guards/is-object.js";import{mapObject as H}from"../utils/object/map-object.js";import{getValueDeep as y}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as D}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as u}from"../utils/path/normalize-route-slug.js";import{isLocalLink as S}from"../utils/path/is-local-link.js";import{reporter as w}from"./tools/notifiers/reporter.js";import{logger as h}from"./tools/notifiers/logger.js";import{sha1 as F}from"./utils/crypto/sha1.js";import{envConfig as G,setEnv as _}from"./config/env-config.js";import{KvService as B}from"./persistence/kv/services/kv-service.js";import{SandboxContext as I}from"./utils/sandbox-context.js";import{writeSharedData as N}from"./utils/index.js";import{renderComponents as V}from"./ssr/render.js";import{readStaticData as q,writeStaticData as j}from"./utils/static-data.js";import{getMarkdocOptions as U}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as v}from"./entitlements/entitlements-provider.js";import{isRouteReserved as x}from"./plugins/get-reserved-routes.js";import{isL10nPath as K}from"./fs/utils/is-l10n-path.js";import{resolveGlobMapValue as J}from"./utils/globs.js";import{replaceEnvVariablesDeep as W}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as $}from"./utils/redirects/find-redirect.js";import{followRedirectChain as z}from"./utils/redirects/follow-redirect-chain.js";import{addWildcardRedirectToTree as Y}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as Z}from"../cli/telemetry/helpers/trace-step.js";const E={routesBySlug:"map",staticFilePaths:"object",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",config:"object",ssr:"object",searchFacets:"map",routesPartials:"map",mcpToolHandlers:"map",skills:"map",devLogin:"object"},P="PLAN_GATES",Q=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORGANIZATION_SLUG","ORGANIZATION_ID","ORG_ID"],ke="userDefinedApiFunctions";class b{routesBySlug=new Map;staticFilePaths={};replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#t={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;routesPartials=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;mcpToolHandlers=new Map;skills=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};devLogin=!1;#o=void 0;config={configFilePath:"",redirects:{},wildcardRedirectsTree:{},access:{rbac:{},requiresLogin:!1},directoryPermissions:{},devLogin:!1,ssoDirect:{}};#i;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#n;userCodeReady;#s=Promise.resolve();#c;#l=Promise.resolve();#d;#h=Promise.resolve();#u;#e=!1;#r=0;#f=0;#a=new Map;constructor({outdir:e,contentDir:s,serverMode:t=!1,serverOutDir:r}){this.#i=s,this.outdir=e,this.serverMode=t,this.serverOutDir=r,I.register({serverOutDir:r,readRoots:[e,process.cwd()]}),this.userCodeReady=new Promise(a=>{this.#n=a})}on(e,s){const t=this.listeners.get(e);t?t.add(s):this.listeners.set(e,new Set([s]))}queueEvent=(e,s,...t)=>{this.#a.set(e+String(s),[e,s,...t])};runListeners=(e,s,...t)=>{for(const r of this.listeners.get(e)||new Set)s?r(s,...t):r(...t)};startPluginsRun(){this.clear(),this.#s=new Promise(e=>{this.#c=e})}waitForPluginsLifecycle(){return Promise.all([this.#s,this.#l,this.#h])}waitForPluginsRun(){return this.#s}finishPluginsRun(){this.#c?.();for(const e of this.#a.values())this.runListeners(...e);this.#a.clear()}startEsbuildRun(){this.#l=new Promise(e=>{this.#d=e})}finishEsbuildRun(){this.#d?.()}markRequestHandlersEntryOutdated(){this.#r++,!this.#e&&(this.#e=!0,this.#h=new Promise(e=>{this.#u=e}))}noteRequestHandlersEntryBuildStart(){this.#f=this.#r}markRequestHandlersEntryUpdated(){this.#e&&(this.#r>this.#f||(this.#e=!1,this.#u?.()))}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#i}markUserCodeReady(){this.#n?.(!0)}async reloadMarkdocOptions(){await Z("com.redocly.build.reloadMarkdocOptions",async()=>{const e=v.instance(),s=await U(this.serverOutDir),t=Object.fromEntries(Object.entries(s.tags).filter(([r])=>R[r]!=null?e.canAccessFeature(R[r]):!0));this.#o={...s,tags:t}})}get markdocOptions(){return{...this.#o,partials:this.getGlobalConfig(m),themeConfig:this.config.markdown}}setGlobalData=e=>{const s=this.globalData,t={...this.globalData,...e};this.globalData=t,JSON.stringify(t)!==JSON.stringify(s)&&this.queueEvent("global-data-updated",void 0,t)};getGlobalData=()=>this.globalData;getKv=async()=>B.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async({input:e,context:s,deps:t,resource:r})=>{const{data:{info:a,ast:i},compoundHash:l}=await T(e,this.markdocOptions,{actions:this,context:s},r);for(const o of a.sharedDataDeps||[]){for(const n of t?.routeSlugs||[])this.addRouteSharedData(n,o,o);for(const n of t?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(o),this.sharedDataDeps.set(n,c)}}for(const o of a.dynamicMarkdocComponents||[]){for(const n of t?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(o),this.routesDynamicComponents.set(n,c)}for(const n of t?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(o),this.sharedDataMarkdocComponents.set(n,c)}}if(t?.routeSlugs&&a.partials?.length)for(const o of t.routeSlugs){const n=this.routesPartials.get(o)||[];for(const c of a.partials)n.includes(c)||n.push(c);this.routesPartials.set(o,n)}return{info:a,ast:i,compoundHash:l}};async loadApiDocuments(e){return(await e.cache.load(".","api-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setStaticFilePaths=e=>{this.staticFilePaths=e};setGlobalConfig=e=>{const s=Object.keys(e);for(const l of s)for(const o in this.replacedEnvVars)if(o===l||o.startsWith(`${l}:`)){const n=o.split(":"),{error:c,value:d}=y(e,n);(c||d!==this.replacedEnvVars[o].replaced)&&delete this.replacedEnvVars[o]}const{resolvedObj:t,unsetEnvVars:r,replacedValues:a}=W(e);for(const l of r)this.unsetEnvVars.add(l);Object.assign(this.replacedEnvVars,a);const i=t.seo?.siteUrl?.trim();i&&(t.seo={...t.seo,siteUrl:URL.canParse(i)?new URL(i).origin:D(i)}),Object.assign(this.config,t)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,s,t={})=>{if(!v.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const i=u(e).toLowerCase();this.config.redirects[i]=s;const{trackOriginalSource:l=!0}=t,o=this.getGlobalConfig("originalRedirectSources");l&&Array.isArray(o)&&!o.includes(i)&&o.push(i),i.endsWith("*")&&Y(this.config.wildcardRedirectsTree,i)};getRedirect=e=>{const s=u(e).toLowerCase(),t=$(s,this.config.redirects,this.config.wildcardRedirectsTree,this.staticFilePaths);if(!t)return null;if(S(t.to)){const r=u(t.to).toLowerCase();if(!r.endsWith("*")&&z(r,[s],this.config.redirects,this.config.wildcardRedirectsTree).type==="cycle")return null}return{to:t.to,type:t.type}};createSharedData=async(e,s,t)=>{if(t&&this.#t[e]===t)return e;const r=JSON.stringify(s),a=t??F(r);return this.#t[e]===a||(this.#t[e]=a,await N(e,r,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,s,t)=>{const r=D(e),a=this.routesSharedData.get(r)||{};a[s]=t,this.routesSharedData.set(r,a),h.verbose(`Adding shared data to ${e}, ${s}, ${t}`)};getRouteSharedDataByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.routesSharedData.get(s)||{}:{}};getPartialsForRoute=e=>{const s=this.getGlobalConfig(m)||{},t=this.routesPartials.get(e);if(!t||t.length===0)return{};const r=this.getGlobalConfig(k)||{},a=new Set(t),i=Array.from(t);for(let o=0;o<i.length;o++){const n=i[o],c=r[n]?.partials??[];for(const d of c)a.has(d)||(a.add(d),i.push(d))}const l={};for(const o of a)s[o]&&(l[o]=s[o]);return l};addRoute=e=>{const t={...J(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:t}),h.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,s,t)=>{const r=[g,...this.lifecycleContext?.fs.localeFolders||[]].map(a=>({code:a,name:a}));for(const a of r){const i=M(e,g,a.code,r);this.addRouteSharedData(i,s,t)}};addApiRoute=e=>{this.apiRoutes.push(e),h.verbose("Created API route %s",e.slug)};addMcpTools=(e,s)=>{for(const t of s){const r=this.mcpToolHandlers.get(t.name);r&&r.importPath!==e&&h.warn('MCP tool "%s" from %s overwrites the tool registered from %s',t.name,e,r.importPath),this.mcpToolHandlers.set(t.name,{...t,importPath:e}),h.verbose("Created MCP tool %s",t.name)}};getMcpTools=()=>Array.from(this.mcpToolHandlers.values());markGatedMcpTools=e=>{for(const s of e){const t=this.mcpToolHandlers.get(s);t&&this.mcpToolHandlers.set(s,{...t,hasAvailabilityGate:!0})}};addSkills=e=>{for(const s of e)this.skills.set(s.slug,s),h.verbose("Discovered skill %s",s.slug)};getSkills=()=>Array.from(this.skills.values());removeMcpTools=e=>{for(const s of e)this.mcpToolHandlers.delete(s)};addMiddleware=e=>{this.middleware.push(e),h.verbose("Created middleware %s",e.id)};setResourceResponseHeaders=(e,s)=>{this.config.responseHeaders||(this.config.responseHeaders={});const t=new Set(s.map(i=>i.name.toLowerCase())),a=[...(this.config.responseHeaders[e]??[]).filter(i=>!t.has(i.name.toLowerCase())),...s];this.config.responseHeaders[e]=a};getRouteByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.getRouteBySlug(s):void 0};getRouteBySlug=(e,s={})=>{const{followRedirect:t=!0}=s,r=this.getRedirect(e);return t&&r?this.routesBySlug.get(u(r.to)):this.routesBySlug.get(e)};hasRouteOrRedirectBySlug=e=>{if(this.routesBySlug.has(e)||x(e,this.getConfig()))return!0;const s=this.getRedirect(e);if(!s)return!1;if(!S(s.to))return!0;const t=u(s.to);return this.routesBySlug.has(t)};getRoutesByTemplateId=e=>this.newRoutes.filter(s=>s.templateId===e);getAllRoutesForLocale=(e=g)=>{const s=Array.from(this.routesBySlug.values()),t=e.toLowerCase();return s.filter(r=>e===g?!K(r.fsPath):r.slug.startsWith(`/${t}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,s)=>(this.templates.set(e,s),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};createRequestHandler=(e,s)=>(this.apiRoutesRequestHandlers.set(e,s),e);clearRequestHandlersByPrefix=e=>{for(const s of this.apiRoutesRequestHandlers.keys())s.startsWith(e)&&this.apiRoutesRequestHandlers.delete(s)};registerServerPropsGetter=(e,s)=>(this.serverPropsGetters.set(e,s),e);registerPagePropsGetter=(e,s)=>{this.pagePropsGetters.set(e,s)};async writeRouteStaticData(e,s){const t=await this.resolveRouteStaticData(e,s,!1);t&&j(e.slug,t,this.outdir)}async resolveRouteStaticData(e,s,t){if(this.serverMode)return q(e.slug,this.outdir);const r={...this,contentDir:this.contentDir,parseMarkdoc:({input:c,context:d,resource:f})=>this.parseMarkdoc({input:c,context:d,deps:{routeSlugs:[e.slug]},resource:f})},a=await e.getStaticData?.(e,r)||{},i=new Set(this.routesDynamicComponents.get(e.slug)),l=this.routesSharedData.get(e.slug)||{};for(const c of Object.values(l)){const d=this.sharedDataMarkdocComponents.get(c);d&&d.forEach(p=>i.add(p));const f=this.sharedDataDeps.get(c);f&&f.forEach(p=>this.addRouteSharedData(e.slug,p,p))}const o=this.getGlobalConfig("seo"),n=a?.frontmatter||{};return{...a,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await e.getNavText?.()}},props:{...a.props,dynamicMarkdocComponents:Array.from(i),metadata:{...a?.props?.metadata,...e.metadata},seo:{title:O,...o,...a.props?.seo,siteUrl:o?.siteUrl},compilationErrors:this.compilationErrors},lastModified:t||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,s){if(!e?.length)return;const t=typeof e[0]=="string"?e.join(""):V(e);t&&(s==="head"?this.ssr.headTags.push(t):s==="preBody"?this.ssr.preBodyTags.push(t):this.ssr.postBodyTags.push(t))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.skills.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const e=[];for(const[t,r]of Object.entries(E))switch(r){case"map":{const a=Array.from(this[t].entries());e.push([t,a]);break}case"object":if(t==="config"){e.push([t,await this.getConfigWithEnvPlaceholders()]);break}e.push([t,this[t]]);break;default:throw new Error("Invalid format")}const s=Object.fromEntries(e);return s[P]=G.PLAN_GATES,s}static fromJson(e,s){const t=new b(s);for(const[a,i]of Object.entries(E))switch(i){case"map":t[a]=new Map(e[a]);break;case"object":if(a==="config"){t.setGlobalConfig(e[a]);break}t[a]=e[a];break;default:throw new Error("Invalid format")}t.config[m]=X(t.config[m]||{});const r=e[P];return r&&_("PLAN_GATES",r),t}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const s in this.replacedEnvVars){const{original:t}=this.replacedEnvVars[s],r=s.split(":"),a=r.pop(),{error:i,value:l}=y(e,r);if(i||!L(l)&&!Array.isArray(l)){await w.panicOnBuild(`Failed to replace env var with env name for ${s}`);continue}l[a]=t}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(t=>!Q.includes(t));if(e.length===0)return;const s=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await w.panicOnBuildContentError(s)}}function X(C){return H(C,e=>A.Ast.fromJSON(JSON.stringify(e)))}export{b as Store,ke as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
@@ -3,5 +3,6 @@ export type * from './plugin-hooks';
3
3
  export type * from './plugins';
4
4
  export type * from './web-server';
5
5
  export type * from './redirects';
6
+ export type * from './static-files';
6
7
  export type * from './tools';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -27,6 +27,7 @@ export type MdPageStaticData = {
27
27
  editPage?: {
28
28
  to: string;
29
29
  };
30
+ isTranslationFallback?: boolean;
30
31
  [REDOCLY_TEAMS_RBAC]?: RbacScopeItems;
31
32
  [REDOCLY_ROUTE_RBAC]?: {
32
33
  slug?: string;