@redocly/redoc-revel 0.141.0-next.2 → 0.141.0-next.21

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 (183) hide show
  1. package/CHANGELOG.md +357 -0
  2. package/dist/cli/develop.js +1 -1
  3. package/dist/cli/utils/react-pages-check.d.ts +11 -0
  4. package/dist/cli/utils/react-pages-check.js +1 -0
  5. package/dist/client/App.js +1 -1
  6. package/dist/client/app/Sidebar/useSidebarItems.js +1 -1
  7. package/dist/client/app/hooks/products/useProducts.d.ts +2 -0
  8. package/dist/client/app/hooks/useBanner.js +1 -1
  9. package/dist/client/app/hooks/useUserClaims.js +1 -1
  10. package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.d.ts +2 -1
  11. package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.js +1 -1
  12. package/dist/client/app/markdoc/custom-components/openapi/openapi-example.d.ts +1 -1
  13. package/dist/client/app/markdoc/custom-components/openapi/openapi-example.js +1 -1
  14. package/dist/client/app/markdoc/custom-components/openapi/openapi-response-sample.d.ts +2 -1
  15. package/dist/client/app/markdoc/custom-components/openapi/openapi-response-sample.js +1 -1
  16. package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.d.ts +2 -1
  17. package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.js +1 -1
  18. package/dist/client/app/markdoc/hooks/use-store.d.ts +12 -0
  19. package/dist/client/app/markdoc/hooks/use-store.js +1 -1
  20. package/dist/client/app/webmcp/tools/shared.d.ts +2 -3
  21. package/dist/client/app/webmcp/tools/shared.js +1 -1
  22. package/dist/client/providers/post-message/PostMessageConnection.d.ts +2 -2
  23. package/dist/client/providers/post-message/PostMessageProvider.d.ts +2 -2
  24. package/dist/client/providers/post-message/use-post-message.d.ts +1 -1
  25. package/dist/client/runtime/errors/page-async-component-error.d.ts +4 -0
  26. package/dist/client/runtime/errors/page-async-component-error.js +1 -0
  27. package/dist/client/runtime/loader.js +1 -1
  28. package/dist/client/types/index.d.ts +0 -1
  29. package/dist/compiled/@redocly/platform-utils/pii/index.mjs +1 -0
  30. package/dist/compiled/@redocly/platform-utils/pii/package.json +1 -0
  31. package/dist/constants/l10n/langs/ar.js +1 -1
  32. package/dist/constants/l10n/langs/de.js +1 -1
  33. package/dist/constants/l10n/langs/en.js +1 -1
  34. package/dist/constants/l10n/langs/es.js +1 -1
  35. package/dist/constants/l10n/langs/fr.js +1 -1
  36. package/dist/constants/l10n/langs/hi.js +1 -1
  37. package/dist/constants/l10n/langs/it.js +1 -1
  38. package/dist/constants/l10n/langs/ja.js +1 -1
  39. package/dist/constants/l10n/langs/ko.js +1 -1
  40. package/dist/constants/l10n/langs/pl.js +1 -1
  41. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  42. package/dist/constants/l10n/langs/pt.js +1 -1
  43. package/dist/constants/l10n/langs/ru.js +1 -1
  44. package/dist/constants/l10n/langs/uk.js +1 -1
  45. package/dist/constants/l10n/langs/zh.js +1 -1
  46. package/dist/markdoc/helpers/get-resolved-sample-code-block.js +4 -4
  47. package/dist/markdoc/nodes/fence/index.js +1 -1
  48. package/dist/markdoc/nodes/table.js +1 -1
  49. package/dist/markdoc/tags/index.d.ts +6 -18
  50. package/dist/markdoc/tags/openapi-code-sample.js +1 -1
  51. package/dist/markdoc/tags/openapi-response-sample.js +1 -1
  52. package/dist/markdoc/tags/replay-openapi.js +1 -1
  53. package/dist/server/api-routes/run-api-routes-worker.js +1 -1
  54. package/dist/server/config/env-config.d.ts +0 -2
  55. package/dist/server/config/env-schema.d.ts +0 -1
  56. package/dist/server/config/env-schemas/feature-flags.d.ts +0 -1
  57. package/dist/server/config/env-schemas/feature-flags.js +1 -1
  58. package/dist/server/constants/assets.d.ts +3 -0
  59. package/dist/server/constants/assets.js +1 -0
  60. package/dist/server/constants/common.d.ts +0 -3
  61. package/dist/server/constants/common.js +1 -1
  62. package/dist/server/constants/config-schema.d.ts +12 -0
  63. package/dist/server/constants/config-schema.js +1 -0
  64. package/dist/server/constants/plugins/search.d.ts +0 -1
  65. package/dist/server/constants/plugins/search.js +1 -1
  66. package/dist/server/constants/project-plugins.d.ts +2 -0
  67. package/dist/server/constants/project-plugins.js +1 -0
  68. package/dist/server/constants/versions.d.ts +3 -0
  69. package/dist/server/constants/versions.js +1 -0
  70. package/dist/server/esbuild/esbuild.js +2 -2
  71. package/dist/server/esbuild/plugins/assets-resolver.js +1 -1
  72. package/dist/server/esbuild/plugins/dependency-resolver.js +1 -1
  73. package/dist/server/external-plugins/resolve-external-plugins.js +1 -1
  74. package/dist/server/fs/fs.js +1 -1
  75. package/dist/server/plugins/api-docs/index.js +1 -1
  76. package/dist/server/plugins/api-docs/options.js +1 -1
  77. package/dist/server/plugins/api-docs/search/create-indexer.d.ts +1 -4
  78. package/dist/server/plugins/api-docs/search/create-indexer.js +1 -1
  79. package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +22 -22
  80. package/dist/server/plugins/api-docs/search/search-resolver.js +1 -1
  81. package/dist/server/plugins/api-docs/spec-download.api.js +1 -1
  82. package/dist/server/plugins/api-docs/utils/is-api-doc.js +1 -1
  83. package/dist/server/plugins/api-docs/utils/relative-path-to-base-slug.js +1 -1
  84. package/dist/server/plugins/config-parser/loaders/content-slugs-loader.d.ts +1 -10
  85. package/dist/server/plugins/config-parser/loaders/content-slugs-loader.js +1 -1
  86. package/dist/server/plugins/config-parser/loaders/index.d.ts +1 -1
  87. package/dist/server/plugins/config-parser/loaders/redocly-config-loader.js +1 -1
  88. package/dist/server/plugins/config-parser/loaders/utils/calculate-content-slugs.d.ts +32 -0
  89. package/dist/server/plugins/config-parser/loaders/utils/calculate-content-slugs.js +1 -0
  90. package/dist/server/plugins/config-parser/loaders/versions-config-loader.d.ts +0 -2
  91. package/dist/server/plugins/config-parser/loaders/versions-config-loader.js +1 -1
  92. package/dist/server/plugins/create-slugify.d.ts +1 -1
  93. package/dist/server/plugins/create-slugify.js +1 -1
  94. package/dist/server/plugins/default-theme/resolve-products-config.d.ts +1 -0
  95. package/dist/server/plugins/default-theme/resolve-products-config.js +1 -1
  96. package/dist/server/plugins/get-reserved-routes.js +1 -1
  97. package/dist/server/plugins/lifecycle.js +1 -1
  98. package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.d.ts +1 -0
  99. package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.js +1 -1
  100. package/dist/server/plugins/markdown/attribute-resolvers/index.js +1 -1
  101. package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.js +1 -1
  102. package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.js +1 -1
  103. package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-operation.d.ts +10 -0
  104. package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-operation.js +1 -0
  105. package/dist/server/plugins/markdown/compiler.js +1 -1
  106. package/dist/server/plugins/markdown/markdoc/markdoc-options.d.ts +1 -1
  107. package/dist/server/plugins/markdown/markdoc/markdoc-options.js +1 -1
  108. package/dist/server/plugins/markdown/runtime-transform.js +1 -1
  109. package/dist/server/plugins/markdown/utils/resolve-markdown-template.js +1 -1
  110. package/dist/server/plugins/mcp/codemode/tools/execute-schema.js +1 -1
  111. package/dist/server/plugins/mcp/codemode/tools/manage-credentials.js +2 -2
  112. package/dist/server/plugins/mcp/constants.d.ts +2 -2
  113. package/dist/server/plugins/mcp/constants.js +1 -1
  114. package/dist/server/plugins/mcp/docs-mcp/tools/core/create-anonymous-session.d.ts +1 -1
  115. package/dist/server/plugins/mcp/docs-mcp/tools/core/search.js +2 -2
  116. package/dist/server/plugins/mcp/docs-mcp/tools/index.d.ts +1 -1
  117. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/utils.d.ts +2 -2
  118. package/dist/server/plugins/mcp/gateway-mcp/subject.d.ts +2 -2
  119. package/dist/server/plugins/mcp/gateway-mcp/subject.js +1 -1
  120. package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
  121. package/dist/server/plugins/mcp/utils/route-reservation.d.ts +9 -0
  122. package/dist/server/plugins/mcp/utils/route-reservation.js +1 -0
  123. package/dist/server/plugins/nav-utils.js +1 -1
  124. package/dist/server/plugins/pages/validators/validate-react-pages.d.ts +8 -1
  125. package/dist/server/plugins/pages/validators/validate-react-pages.js +1 -1
  126. package/dist/server/plugins/search/ai-indexer/prepare-semantic-documents.js +1 -1
  127. package/dist/server/plugins/search/engines/flexsearch/search-index.js +1 -1
  128. package/dist/server/plugins/search/engines/typesense/index.js +1 -1
  129. package/dist/server/plugins/search/llmstxt/create-llms-txt-generator.js +1 -1
  130. package/dist/server/plugins/search/llmstxt/index.js +4 -4
  131. package/dist/server/plugins/utils.d.ts +0 -4
  132. package/dist/server/plugins/utils.js +1 -1
  133. package/dist/server/ssr/index.js +1 -1
  134. package/dist/server/ssr/server-side-props/get-default-static-props.d.ts +1 -0
  135. package/dist/server/ssr/utils.js +11 -9
  136. package/dist/server/store.d.ts +2 -1
  137. package/dist/server/store.js +1 -1
  138. package/dist/server/tools/notifiers/formatter.js +1 -1
  139. package/dist/server/types/plugins/common.d.ts +2 -0
  140. package/dist/server/types/web-server.d.ts +5 -0
  141. package/dist/server/utils/content/parse-base-name.d.ts +15 -0
  142. package/dist/server/utils/content/parse-base-name.js +1 -0
  143. package/dist/server/utils/crypto/sha-dir-path-short.js +1 -1
  144. package/dist/server/utils/errors.d.ts +2 -1
  145. package/dist/server/utils/errors.js +1 -1
  146. package/dist/server/utils/llmstxt/resolve-llms-txt-md.d.ts +5 -0
  147. package/dist/server/utils/llmstxt/resolve-llms-txt-md.js +1 -1
  148. package/dist/server/utils/product.d.ts +1 -0
  149. package/dist/server/utils/rbac/can-access-feature.d.ts +5 -0
  150. package/dist/server/utils/rbac/can-access-feature.js +1 -0
  151. package/dist/server/utils/rbac/can-anonymous-access-mcp-feature.js +1 -1
  152. package/dist/server/utils/rbac/has-scope-access.d.ts +3 -0
  153. package/dist/server/utils/rbac/has-scope-access.js +1 -0
  154. package/dist/server/utils/rbac.d.ts +19 -11
  155. package/dist/server/utils/rbac.js +1 -1
  156. package/dist/server/web-server/auth.js +3 -3
  157. package/dist/server/web-server/routes/ask-ai.js +1 -1
  158. package/dist/server/web-server/routes/dynamic-route.js +1 -1
  159. package/dist/server/web-server/routes/error.js +1 -1
  160. package/dist/server/web-server/routes/index.js +1 -1
  161. package/dist/server/web-server/routes/mcp-routes/mcp-client-metadata.js +1 -1
  162. package/dist/server/web-server/routes/mcp-routes/mcp-oauth.d.ts +0 -1
  163. package/dist/server/web-server/routes/mcp-routes/mcp-oauth.js +1 -1
  164. package/dist/server/web-server/routes/page-data.d.ts +2 -1
  165. package/dist/server/web-server/routes/page-data.js +1 -1
  166. package/dist/server/web-server/routes/semantic-search.js +1 -1
  167. package/dist/server/web-server/utils.d.ts +1 -1
  168. package/dist/server/web-server/utils.js +1 -1
  169. package/dist/server/workers/worker-config.js +1 -1
  170. package/dist/utils/l10n/build-i18n-config.js +1 -1
  171. package/package.json +13 -11
  172. package/dist/client/app/ReviewComments/ReviewComments.d.ts +0 -4
  173. package/dist/client/app/ReviewComments/ReviewComments.js +0 -7
  174. package/dist/client/types/post-message.d.ts +0 -68
  175. package/dist/client/types/post-message.js +0 -0
  176. package/dist/compiled/@redocly/pii/index.mjs +0 -1
  177. package/dist/compiled/@redocly/pii/package.json +0 -1
  178. package/dist/server/utils/llmstxt/get-llms-txt-md-path-by-slug.d.ts +0 -19
  179. package/dist/server/utils/llmstxt/get-llms-txt-md-path-by-slug.js +0 -1
  180. package/dist/server/utils/search/highlight-text-for-search.d.ts +0 -3
  181. package/dist/server/utils/search/highlight-text-for-search.js +0 -1
  182. package/dist/server/utils/search/text-match.d.ts +0 -6
  183. package/dist/server/utils/search/text-match.js +0 -1
@@ -1 +1 @@
1
- import{existsSync as m,readFileSync as F}from"node:fs";import{createRequire as k}from"node:module";import s from"node:path";import{resolvePlugins as A}from"@redocly/openapi-core";import{DEFAULT_PROJECT_PLUGIN_PATHS as d,DEFAULT_THEME_PLUGIN_PATH as c,STYLES_FILE as S}from"../constants/common.js";import{GATED_PLUGINS as v}from"../constants/entitlements.js";import{DEFAULT_THEME_NAME as h}from"../../constants/common.js";import{isDefined as _}from"../../utils/guards/is-defined.js";import{isPlainObject as g}from"../../utils/guards/is-plain-object.js";import{logger as C}from"../tools/notifiers/logger.js";import{reporter as L}from"../tools/notifiers/reporter.js";import{sha as w}from"../utils/crypto/sha.js";import{resolveModule as P}from"./resolve-module.js";import{EntitlementsProvider as I}from"../entitlements/entitlements-provider.js";const f={sha:"",value:Promise.resolve({resolvedPlugins:[],errors:[]})};async function ee(e,r=[]){const n=w(JSON.stringify(r));if(f.sha!==n){f.sha=n;const o=M(e),a=N(e,r,o),p=await A(a,e)||[];if(!a.some(i=>d.includes(i))){const i=d[0],l=s.join(e,i);p.push({id:"",absolutePath:l,path:i})}f.value=Promise.all(p.map(i=>b(i,i.path===o?c:i.path))).then(i=>{const l=i.filter(_),j=l.filter(u=>u?.type&&["error","warning"].includes(u.type)),D=l.filter(u=>u.type==="resolvedPlugin");return{errors:j,resolvedPlugins:D}})}const t=await f.value;if(t.errors.length)for(let o=0;o<t.errors.length;o++)await L.panicOnBuildContentError(t.errors[o].error);return t.resolvedPlugins}function M(e){const r=s.resolve(e,"package.json");if(!y(s.dirname(r)))return P(c)??c;const n=E(o=>k(r).resolve(o)),t=E(P);return n&&t&&n!==t&&C.warn("The project declares %s %s, and Realm uses it instead of the %s it was built with.",h,n,t),c}function y(e){const r=T(s.join(e,"package.json")),n=[r?.dependencies,r?.devDependencies].some(o=>g(o)&&h in o),t=s.dirname(e);return n||t!==e&&y(t)}function E(e){try{const r=e(`${h}/package.json`),n=r&&T(r)?.version;return typeof n=="string"?n:void 0}catch{return}}function T(e){try{const r=JSON.parse(F(e,"utf8"));return g(r)?r:void 0}catch{return}}function N(e,r=[],n){const t=[...r];for(const o of d)!t.includes(o)&&m(s.join(e,o))&&t.push(o);return t.includes(c)||t.unshift(n),t}async function b(e,r){if(!e.absolutePath||!r)return{type:"error",error:`Plugin with path "${e}" not found`};const n=s.dirname(e.absolutePath),{lifecyclePlugin:t,config:o}=R(e,r);return{name:s.dirname(r),type:"resolvedPlugin",isNpmPackage:O(r),pluginDirAbsolutePath:n,lifecyclePlugin:t,config:o,stylesFile:s.resolve(n,S),markdoc:U(n)}}function O(e){const r=s.dirname(e);return P(s.join(r,"package.json"))!=null}function R(e,r){const n=I.instance(),t=!n.canAccessFeature("customPlugins")&&!v.includes(r),o=e.requiredEntitlements&&v.includes(r)&&!e.requiredEntitlements.every(a=>n.canAccessFeature(a));return t||o?{lifecyclePlugin:{id:e.id},config:{}}:{lifecyclePlugin:{id:e.id,processContent:e.processContent,afterRoutesCreated:e.afterRoutesCreated,loaders:e.loaders,requiredEntitlements:e.requiredEntitlements},config:{schema:e.redoclyConfigSchema,ejectIgnore:e.ejectIgnore}}}function U(e){const r=s.resolve(e,"markdoc"),n=s.join(r,"schema.ts");if(!m(n))return null;const t=s.join(r,"components.tsx");return{schemaFile:n,componentsFile:m(t)?t:void 0}}export{ee as resolveExternalPlugins};
1
+ import{existsSync as m,readFileSync as F}from"node:fs";import{createRequire as k}from"node:module";import s from"node:path";import{resolvePlugins as A}from"@redocly/openapi-core";import{DEFAULT_THEME_PLUGIN_PATH as c,STYLES_FILE as S}from"../constants/common.js";import{DEFAULT_PROJECT_PLUGIN_PATHS as d}from"../constants/project-plugins.js";import{GATED_PLUGINS as v}from"../constants/entitlements.js";import{DEFAULT_THEME_NAME as h}from"../../constants/common.js";import{isDefined as _}from"../../utils/guards/is-defined.js";import{isPlainObject as g}from"../../utils/guards/is-plain-object.js";import{logger as C}from"../tools/notifiers/logger.js";import{reporter as L}from"../tools/notifiers/reporter.js";import{sha as w}from"../utils/crypto/sha.js";import{resolveModule as P}from"./resolve-module.js";import{EntitlementsProvider as I}from"../entitlements/entitlements-provider.js";const f={sha:"",value:Promise.resolve({resolvedPlugins:[],errors:[]})};async function re(e,r=[]){const n=w(JSON.stringify(r));if(f.sha!==n){f.sha=n;const o=M(e),a=N(e,r,o),p=await A(a,e)||[];if(!a.some(i=>d.includes(i))){const i=d[0],l=s.join(e,i);p.push({id:"",absolutePath:l,path:i})}f.value=Promise.all(p.map(i=>b(i,i.path===o?c:i.path))).then(i=>{const l=i.filter(_),j=l.filter(u=>u?.type&&["error","warning"].includes(u.type)),D=l.filter(u=>u.type==="resolvedPlugin");return{errors:j,resolvedPlugins:D}})}const t=await f.value;if(t.errors.length)for(let o=0;o<t.errors.length;o++)await L.panicOnBuildContentError(t.errors[o].error);return t.resolvedPlugins}function M(e){const r=s.resolve(e,"package.json");if(!y(s.dirname(r)))return P(c)??c;const n=E(o=>k(r).resolve(o)),t=E(P);return n&&t&&n!==t&&C.warn("The project declares %s %s, and Realm uses it instead of the %s it was built with.",h,n,t),c}function y(e){const r=T(s.join(e,"package.json")),n=[r?.dependencies,r?.devDependencies].some(o=>g(o)&&h in o),t=s.dirname(e);return n||t!==e&&y(t)}function E(e){try{const r=e(`${h}/package.json`),n=r&&T(r)?.version;return typeof n=="string"?n:void 0}catch{return}}function T(e){try{const r=JSON.parse(F(e,"utf8"));return g(r)?r:void 0}catch{return}}function N(e,r=[],n){const t=[...r];for(const o of d)!t.includes(o)&&m(s.join(e,o))&&t.push(o);return t.includes(c)||t.unshift(n),t}async function b(e,r){if(!e.absolutePath||!r)return{type:"error",error:`Plugin with path "${e}" not found`};const n=s.dirname(e.absolutePath),{lifecyclePlugin:t,config:o}=R(e,r);return{name:s.dirname(r),type:"resolvedPlugin",isNpmPackage:O(r),pluginDirAbsolutePath:n,lifecyclePlugin:t,config:o,stylesFile:s.resolve(n,S),markdoc:U(n)}}function O(e){const r=s.dirname(e);return P(s.join(r,"package.json"))!=null}function R(e,r){const n=I.instance(),t=!n.canAccessFeature("customPlugins")&&!v.includes(r),o=e.requiredEntitlements&&v.includes(r)&&!e.requiredEntitlements.every(a=>n.canAccessFeature(a));return t||o?{lifecyclePlugin:{id:e.id},config:{}}:{lifecyclePlugin:{id:e.id,processContent:e.processContent,afterRoutesCreated:e.afterRoutesCreated,loaders:e.loaders,requiredEntitlements:e.requiredEntitlements},config:{schema:e.redoclyConfigSchema,ejectIgnore:e.ejectIgnore}}}function U(e){const r=s.resolve(e,"markdoc"),n=s.join(r,"schema.ts");if(!m(n))return null;const t=s.join(r,"components.tsx");return{schemaFile:n,componentsFile:m(t)?t:void 0}}export{re as resolveExternalPlugins};
@@ -1 +1 @@
1
- import*as f from"chokidar";import h from"path";import*as p from"node:fs/promises";import{createHash as l}from"node:crypto";import{slash as o}from"../../utils/path/slash.js";import{logger as c}from"../tools/notifiers/logger.js";import{sha1 as m}from"../utils/crypto/sha1.js";import{USER_THEME_ALIAS as u,USER_SKILLS_ALIAS as g,USER_SKILL_FILENAME as w}from"../../constants/common.js";import{debouncedEmit as L}from"./utils/debounced-emit.js";import{trackAccessStore as r}from"./utils/async-storage.js";import{removeBom as S}from"./utils/string-utils.js";const E=`${g}(/.*)?`,y=w.replace(".","\\."),v=new RegExp(`^(${E}|${y})$`);class j{cwd;ignored;filesList=new Map;watcher;#t=new Map;#e=[];constructor(t,e=[]){this.cwd=t,this.ignored=e,this.watcher=this.#i()}get ready(){return this.watcher.then(()=>!0)}getFileInfo(t){return this.filesList.get(t)}watch(t){this.#e.push(t)}async dispose(){(await this.watcher).close()}exists(t){const e=this.filesList.has(t);return r.getStore()?.push({type:"exists",path:t,hash:e?"t":"f"}),e}async read(t,e="utf-8"){try{let s=await p.readFile(h.join(this.cwd,t),e);s=S(s);const i=m(s);r.getStore()?.push({type:"read",path:t,hash:i});const a=this.filesList.get(t);return a&&(a.hash=i),s}catch(s){throw r.getStore()?.push({type:"read",path:t,hash:"error"}),s}}scan(t){const e=[],s=l("sha1");this.filesList.forEach(a=>{(!t||t.test(a.relativePath))&&(e.push(a),s.update(a.relativePath))});const i=s.digest("base64");return this.#t.set(t,i),r.getStore()?.push({type:"scan",hash:i,pattern:t}),e}emitCodeUpdated(){this.emit({event:"code-updated"})}addVirtualFile(t,e){this.filesList.set(t,{relativePath:t,realRelativePath:e.realRelativePath,hash:e.hash,isVirtual:!0}),r.getStore()?.push({type:"read",path:t,hash:e.hash??""})}getPatternScanHash(t){return this.#t.get(t)}#s(t){return v.test(t)}emit=L(async t=>{for(const e of t)if(!("path"in e&&this.#s(e.path)))switch(e.event){case"add":this.filesList.set(e.path,{relativePath:e.path,realRelativePath:e.path,hash:void 0,isVirtual:!1});for(const s of this.#t.keys())s&&s.test(e.path)&&this.#t.set(s,void 0),s||this.#t.set(s,void 0);break;case"change":{const s=this.filesList.get(e.path);s&&(s.hash=void 0);break}case"unlink":this.filesList.delete(e.path);for(const s of this.#t.keys())s&&s.test(e.path)&&this.#t.delete(s),s||this.#t.delete(s);break}for(const e of this.#e)await e(t)});async#i(){return c.startTiming("init-fs"),new Promise((t,e)=>{const s=f.watch(this.cwd,{usePolling:!1,ignoreInitial:!0,ignored:[new RegExp(`(/.git/|/node_modules/|${u})`),h.join(this.cwd,"public"),h.join(this.cwd,"README.md"),...this.ignored]});s.on("ready",()=>{this.filesList=this.#a(s.getWatched()),t(s),c.infoTime("init-fs","File system scan completed")}).on("error",e).on("add",(i,a)=>{this.emit({event:"add",path:o(h.relative(this.cwd,i)),stats:a})}).on("change",(i,a)=>{this.emit({event:"change",path:o(h.relative(this.cwd,i)),stats:a})}).on("unlink",i=>{this.emit({event:"unlink",path:o(h.relative(this.cwd,i))})})})}#a(t){const e=new Map;for(const s of Object.keys(t))for(const i of t[s]){const a=h.join(s,i);if(t[a])continue;const d=o(h.dirname(h.relative(this.cwd,a))),n=h.posix.join(d,i);this.#s(n)||e.set(n,{relativePath:n,realRelativePath:n,isVirtual:!1,hash:void 0})}return e}}export{j as Fs};
1
+ import*as f from"chokidar";import h from"path";import*as p from"node:fs/promises";import{createHash as l}from"node:crypto";import{slash as o}from"../../utils/path/slash.js";import{logger as c}from"../tools/notifiers/logger.js";import{sha1 as m}from"../utils/crypto/sha1.js";import{USER_THEME_ALIAS as u,USER_SKILLS_ALIAS as g,USER_SKILL_FILENAME as w}from"../../constants/common.js";import{debouncedEmit as L}from"./utils/debounced-emit.js";import{trackAccessStore as r}from"./utils/async-storage.js";import{removeBom as S}from"./utils/string-utils.js";const E=`${g}(/.*)?`,y=w.replace(".","\\."),v=new RegExp(`^(${E}|${y})$`);class j{cwd;ignored;filesList=new Map;watcher;#t=new Map;#e=[];constructor(t,e=[]){this.cwd=t,this.ignored=e,this.watcher=this.#i()}get ready(){return this.watcher.then(()=>!0)}getFileInfo(t){return this.filesList.get(t)}watch(t){this.#e.push(t)}async dispose(){(await this.watcher).close()}exists(t){const e=this.filesList.has(t);return r.getStore()?.push({type:"exists",path:t,hash:e?"t":"f"}),e}async read(t,e="utf-8"){try{let s=await p.readFile(h.join(this.cwd,t),e);s=S(s);const i=m(s);r.getStore()?.push({type:"read",path:t,hash:i});const a=this.filesList.get(t);return a&&(a.hash=i),s}catch(s){throw r.getStore()?.push({type:"read",path:t,hash:"error"}),s}}scan(t){const e=[],s=l("sha1");this.filesList.forEach(a=>{(!t||t.test(a.relativePath))&&(e.push(a),s.update(a.relativePath))});const i=s.digest("base64");return this.#t.set(t,i),r.getStore()?.push({type:"scan",hash:i,pattern:t}),e}emitCodeUpdated(){this.emit({event:"code-updated"})}addVirtualFile(t,e){this.filesList.set(t,{relativePath:t,realRelativePath:e.realRelativePath,hash:e.hash,isVirtual:!0}),r.getStore()?.push({type:"read",path:t,hash:e.hash??""})}getPatternScanHash(t){return this.#t.get(t)}#s(t){return v.test(t)}emit=L(async t=>{for(const e of t)if(!("path"in e&&this.#s(e.path)))switch(e.event){case"add":this.filesList.set(e.path,{relativePath:e.path,realRelativePath:e.path,hash:void 0,isVirtual:!1});for(const s of this.#t.keys())s&&s.test(e.path)&&this.#t.set(s,void 0),s||this.#t.set(s,void 0);break;case"change":{const s=this.filesList.get(e.path);s&&(s.hash=void 0);break}case"unlink":this.filesList.delete(e.path);for(const s of this.#t.keys())s&&s.test(e.path)&&this.#t.delete(s),s||this.#t.delete(s);break}for(const e of this.#e)await e(t)});async#i(){return c.startTiming("init-fs"),new Promise((t,e)=>{const s=f.watch(this.cwd,{usePolling:!1,ignoreInitial:!0,ignored:[new RegExp(`(/.git/|/node_modules/|${u}|/@sdk(/|$))`),h.join(this.cwd,"public"),h.join(this.cwd,"README.md"),...this.ignored]});s.on("ready",()=>{this.filesList=this.#a(s.getWatched()),t(s),c.infoTime("init-fs","File system scan completed")}).on("error",e).on("add",(i,a)=>{this.emit({event:"add",path:o(h.relative(this.cwd,i)),stats:a})}).on("change",(i,a)=>{this.emit({event:"change",path:o(h.relative(this.cwd,i)),stats:a})}).on("unlink",i=>{this.emit({event:"unlink",path:o(h.relative(this.cwd,i))})})})}#a(t){const e=new Map;for(const s of Object.keys(t))for(const i of t[s]){const a=h.join(s,i);if(t[a])continue;const d=o(h.dirname(h.relative(this.cwd,a))),n=h.posix.join(d,i);this.#s(n)||e.set(n,{relativePath:n,realRelativePath:n,isVirtual:!1,hash:void 0})}return e}}export{j as Fs};
@@ -1 +1 @@
1
- import{REDOCLY_ROUTE_RBAC as w,REDOCLY_TEAMS_RBAC as I}from"@redocly/config";import{mcpTagSchemas as ae,schemaDefinitionTag as ie,markdocParser as U,collectPreviousRouteSlugs as se}from"@redocly/api-docs";import{withPathPrefix as $}from"@redocly/theme/core/utils";import{API_DOCS_TEMPLATE_ID as j,GRAPHQL_SPEC_SLUG as ne,PUBLIC_RBAC_SCOPE_ITEM as N}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ce,PUBLIC_API_DEFINITIONS_FOLDER as pe}from"../../constants/common.js";import{API_DOCS_SHARED_DATA_PREFIX as O}from"../../constants/plugins/api-docs.js";import{fromCurrentDir as ue}from"../../utils/paths.js";import{normalizeRouteSlug as le}from"../../../utils/path/normalize-route-slug.js";import{removeTrailingSlash as de}from"../../../utils/url/remove-trailing-slash.js";import{isTranslationFallback as me}from"../../fs/utils/is-translation-fallback.js";import{createSlugify as fe}from"../create-slugify.js";import{apiDocLoader as ge,apiDocsLoader as he}from"./loader.js";import{getTemplatePath as V}from"./get-template-path.js";import{storeDefinitionBundles as Se}from"./store-definition-bundles.js";import{definitionAccessKey as De,describeDefinitionAccess as Pe}from"./definition-access.js";import{telemetryTraceStep as ye}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as ve}from"./search/search-resolver.js";import{getAiDocumentsStore as Ae}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as Ie}from"../get-api-config.js";import{getRouteSlugsForPath as Re}from"../utils.js";import{collectItemRoutes as be}from"./utils/collect-item-routes.js";import{isChunkCurrent as _e}from"./utils/decorators.js";import{applyNavItemToRoot as Ce}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as we}from"./utils/build-routes-mapping.js";import{buildItemPositions as Te}from"./utils/build-item-positions.js";import{resolveApiDocTitle as ke}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as K}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as Ee}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as Oe}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as W}from"./import-api-docs-builder.js";import{envConfig as G}from"../../config/env-config.js";import{logger as Fe}from"../../tools/notifiers/logger.js";const F="openapi-spec-download",Me={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function Dt(){let t=[],r=new Map;const a=new WeakMap;let i=new Set,g={},v={};function X(o,D,R){const A=a.get(o)??new Map;a.set(o,A);const P=D??"";return A.get(P)===R?!1:(A.set(P,R),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":ge,"api-docs":he},processContent:async(o,D)=>{await ye("com.redocly.build.plugin.apiDocs",async()=>{o.createRequestHandler(F,ue(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:pe+"/*",requestHandlerId:F,httpMethod:"all",[I]:N,getStaticData:async()=>({props:{definitionAccess:v}})}),o.addApiRoute({slug:ce+"/*",requestHandlerId:F,httpMethod:"all",[I]:N,getStaticData:async()=>({props:{definitionAccess:v}})}),o.addApiRoute({slug:ne+"/*",requestHandlerId:F,httpMethod:"all",[I]:N,getStaticData:async()=>({props:{definitionAccess:v}})});const R=o.createTemplate(j,V("../../../client/templates/api-docs/template.js")),A=o.registerServerPropsGetter(j,V("./get-server-props.js")),P=await D.getConfig();r=new Map,g={};const y=await o.loadApiDocuments(D);Se(y,o.outdir),v={};const T=!!P.plugins?.some(e=>typeof e=="string"&&e.startsWith("@redocly/portal-plugin-async-api/"));T&&y.some(e=>e.type==="asyncapi")&&Fe.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=T?y.filter(e=>e.type!=="asyncapi"):y;t=c.map(({markdocChunks:e,relativePath:u,isVirtual:p,customOutputRelativeFile:s,realRelativePath:S})=>({chunks:e??[],relativePath:u,realRelativePath:S,isVirtual:s!=null||p}));const{buildItems:n}=await W(o.serverOutDir),m=(await D.cache.load("content-slugs","content-slugs")).data,h=fe(m),k=e=>le(h(e));for(const e of y){const u=De(e);if(u===void 0)continue;const p=k(e.customOutputRelativeFile||e.relativePath);v[u]=Pe(e,p)}for(const e of c){const u=e.customOutputRelativeFile||e.relativePath,p=k(u);qe(e,p);const{items:s,store:S}=await n({type:e.type,document:e.document,options:e.options,basePath:p,markdownParser:U}),b=`${O}${e.relativePath}`,M=G.isDevelopMode?e.relativePath:void 0,l=$e(e.document),_=l?.["x-metadata"],C=e.isVirtual?void 0:_?.apiId,B={document:e,basePath:p,sourcePath:M,apiId:C,build:{items:s,store:S}};await o.createSharedData(b,z(B,s,S));const J=K(e.config),L=!!e.options.excludeFromSearch,Z=e.type==="openapi",ee=be(s,J),te=me(e),f=ee.map(d=>{const x=d.metadata?.seo,E={fsPath:u,templateId:R,sharedData:[{key:"apiDocsStore",id:b}],serverPropsGetterIds:[A],excludeFromSearch:L,getStaticData:Le(d.label,x,te),[I]:d[I]};return Object.assign(E,xe(d.link,p)),Z&&d.httpVerb&&(E.httpVerb=d.httpVerb,E.metadata={subType:"openapi-operation"}),E});if(!f.length)continue;const H=ke(l,e.type,s),oe=Oe(l?.version),q={type:e.type,title:H,version:oe,description:typeof l?.description=="string"?l.description:void 0,summary:typeof l?.summary=="string"?l.summary:void 0,...l?.["x-metadata"]&&typeof l["x-metadata"]=="object"?l["x-metadata"]:{}};f[0]={...f[0],metadata:q,hasClientRoutes:!0,getSidebar:(d,x)=>Ce(Y(s),p,x),getNavText:()=>H??Me[e.type]??"API Docs",getSearchDocuments:ve(s,q,o.getSearchFacets,o.setSearchFacets,L,S,e.document),getAiDocumentsStore:Ae({getBuild:()=>B.build,metadata:q,document:e.document,specType:e.type,excludeFromSearch:L,basePath:p,getSearchFacets:o.getSearchFacets,markdocTags:{...ae,schemaDefinition:ie}})};const re=f[0];f[0]=f[f.length-1],f[f.length-1]=re;for(const d of f)o.addRoute(d);if(C){const d=Ie(e.config?.apis,e.realRelativePath);g[C]={[I]:d.rbac,[w]:{fsPath:u}}}r.set(b,B)}})},afterRoutesCreated:async(o,D)=>{const{buildItems:R,simplifyAstStructure:A}=await W(o.serverOutDir);for(const c of r.values())Q(o,c.build.items);const P=new Set,y=new Set;for(const{chunks:c,relativePath:n,isVirtual:m}of t){const h=`${O}${n}`,k=Re(o.getAllRoutes(),n);for(const{node:e,markdown:u,pointer:p,key:s,relativePath:S}of c){const{ast:b,compoundHash:M}=await o.parseMarkdoc({input:{content:u,relativePath:S,isVirtual:m},resource:p,context:D,deps:{sharedDataIds:[`${O}${S}`],routeSlugs:k}});if(P.add(p),!(s==="graphql-docs"?e?.description?.value!==void 0:!!s&&_e(e,s,u))||!X(e,s,M))continue;y.add(h);const _=A(b);if(s==="graphql-docs"){e.description&&(e.description.value=_);const C=`${O}${S}`;Be(r.get(C),_)}else s&&(e[s]=_)}}const T=i.difference(P);for(const c of T)D.cache.delete(c);i=P,Object.entries(g).forEach(([c,n])=>{const m=n[w]?.fsPath;if(!m)return;const h=o.getRouteByFsPath(m)?.baseSlug;g[c]={...n,[w]:{...n[w],slug:h},slug:h}}),o.setGlobalData({apiProducts:g});for(const[c,n]of r){if(!y.has(c))continue;const{items:m,store:h}=await R({type:n.document.type,document:n.document.document,options:n.document.options,basePath:n.basePath,markdownParser:U});n.build={items:m,store:h},Q(o,m),await o.createSharedData(c,z(n,m,h))}}}}function Q(t,r){for(const{from:a,to:i}of se(r))t.getConfig().redirects?.[a]||t.getRouteBySlug(a,{followRedirect:!1})||(t.addRouteAlias(a,i),t.addRedirect(a,{to:i},{trackOriginalSource:!1}))}function z({document:t,basePath:r,sourcePath:a,apiId:i},g,v){return{[I]:K(t.config),[w]:{slug:de(r),fsPath:t.customOutputRelativeFile||t.relativePath},items:g,store:v,options:t.options,baseSlug:r,routesMapping:G.isDevelopMode?we(g,r):{},graphqlPositions:G.isDevelopMode&&t.type==="graphql"?Te(g,r):void 0,sourcePath:a,apiId:i}}function Be(t,r){t?.document.type!=="graphql"||!t.document.options||(t.document.options.info={...t.document.options.info||{},description:r})}function Le(t,r,a){return async function(i){return{...a?{isTranslationFallback:!0}:{},props:{settings:{baseUrlPath:$(i.baseSlug)},disableAutoScroll:!0,seo:{title:t,...r}}}}}function qe(t,r){const a=t.options?.mockServer,i=$(`/_mock${Ee(t.relativePath)}`);a?.url===i&&(t.options={...t.options,mockServer:{...a,url:$(`/_mock${r}`)}})}function xe(t,r){if(t===r)return{};const a=r==="/"?"/":`${r}/`;if(t.startsWith(a)){const i=t.slice(a.length);return i?{slugSuffix:i}:{}}return{slug:t}}function $e(t){if(t&&typeof t=="object"&&"info"in t)return t.info}function Y(t){return t.map(({content:r,items:a,...i})=>({...i,...a&&{items:Y(a)}}))}export{Dt as apiDocsPlugin,xe as toRouteSlugFields};
1
+ import{REDOCLY_ROUTE_RBAC as T,REDOCLY_TEAMS_RBAC as I}from"@redocly/config";import{mcpTagSchemas as ae,schemaDefinitionTag as ie,markdocParser as j,collectPreviousRouteSlugs as ne}from"@redocly/api-docs";import{withPathPrefix as N}from"@redocly/theme/core/utils";import{API_DOCS_TEMPLATE_ID as V,GRAPHQL_SPEC_SLUG as ce,PUBLIC_RBAC_SCOPE_ITEM as $}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as pe,PUBLIC_API_DEFINITIONS_FOLDER as ue}from"../../constants/common.js";import{API_DOCS_SHARED_DATA_PREFIX as O}from"../../constants/plugins/api-docs.js";import{fromCurrentDir as le}from"../../utils/paths.js";import{normalizeRouteSlug as de}from"../../../utils/path/normalize-route-slug.js";import{removeTrailingSlash as me}from"../../../utils/url/remove-trailing-slash.js";import{isTranslationFallback as fe}from"../../fs/utils/is-translation-fallback.js";import{createSlugify as ge}from"../create-slugify.js";import{apiDocLoader as he,apiDocsLoader as Se}from"./loader.js";import{getTemplatePath as W}from"./get-template-path.js";import{storeDefinitionBundles as De}from"./store-definition-bundles.js";import{definitionAccessKey as Pe,describeDefinitionAccess as ye}from"./definition-access.js";import{telemetryTraceStep as Ae}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as ve}from"./search/search-resolver.js";import{getAiDocumentsStore as Ie}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as Re}from"../get-api-config.js";import{getRouteSlugsForPath as be}from"../utils.js";import{collectItemRoutes as _e}from"./utils/collect-item-routes.js";import{isChunkCurrent as Ce}from"./utils/decorators.js";import{applyNavItemToRoot as Te}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as we}from"./utils/build-routes-mapping.js";import{buildItemPositions as Ee}from"./utils/build-item-positions.js";import{resolveApiDocTitle as ke}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as K}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as Oe}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as Fe}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as z}from"./import-api-docs-builder.js";import{envConfig as G}from"../../config/env-config.js";import{logger as Me}from"../../tools/notifiers/logger.js";const F="openapi-spec-download",H={timeoutMs:15e3,maxResponseSizeMB:20},Le={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function Pt(){let t=[],r=new Map;const s=new WeakMap;let a=new Set,g={},A={};function J(o,D,R){const v=s.get(o)??new Map;s.set(o,v);const P=D??"";return v.get(P)===R?!1:(v.set(P,R),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":he,"api-docs":Se},processContent:async(o,D)=>{await Ae("com.redocly.build.plugin.apiDocs",async()=>{o.createRequestHandler(F,le(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:ue+"/*",requestHandlerId:F,httpMethod:"all",...H,[I]:$,getStaticData:async()=>({props:{definitionAccess:A}})}),o.addApiRoute({slug:pe+"/*",requestHandlerId:F,httpMethod:"all",...H,[I]:$,getStaticData:async()=>({props:{definitionAccess:A}})}),o.addApiRoute({slug:ce+"/*",requestHandlerId:F,httpMethod:"all",...H,[I]:$,getStaticData:async()=>({props:{definitionAccess:A}})});const R=o.createTemplate(V,W("../../../client/templates/api-docs/template.js")),v=o.registerServerPropsGetter(V,W("./get-server-props.js")),P=await D.getConfig();r=new Map,g={};const y=await o.loadApiDocuments(D);De(y,o.outdir),A={};const w=!!P.plugins?.some(e=>typeof e=="string"&&e.startsWith("@redocly/portal-plugin-async-api/"));w&&y.some(e=>e.type==="asyncapi")&&Me.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=w?y.filter(e=>e.type!=="asyncapi"):y;t=c.map(({markdocChunks:e,relativePath:u,isVirtual:p,customOutputRelativeFile:i,realRelativePath:S})=>({chunks:e??[],relativePath:u,realRelativePath:S,isVirtual:i!=null||p}));const{buildItems:n}=await z(o.serverOutDir),m=(await D.cache.load("content-slugs","content-slugs")).data,h=ge(m),E=e=>de(h(e));for(const e of y){const u=Pe(e);if(u===void 0)continue;const p=E(e.customOutputRelativeFile||e.relativePath);A[u]=ye(e,p)}for(const e of c){const u=e.customOutputRelativeFile||e.relativePath,p=E(u);xe(e,p);const{items:i,store:S}=await n({type:e.type,document:e.document,options:e.options,basePath:p,markdownParser:j}),b=`${O}${e.relativePath}`,M=G.isDevelopMode?e.relativePath:void 0,l=$e(e.document),_=l?.["x-metadata"],C=e.isVirtual?void 0:_?.apiId,L={document:e,basePath:p,sourcePath:M,apiId:C,build:{items:i,store:S}};await o.createSharedData(b,Y(L,i,S));const Z=K(e.config),B=!!e.options.excludeFromSearch,ee=e.type==="openapi",te=_e(i,Z),oe=fe(e),f=te.map(d=>{const x=d.metadata?.seo,k={fsPath:u,templateId:R,sharedData:[{key:"apiDocsStore",id:b}],serverPropsGetterIds:[v],excludeFromSearch:B,getStaticData:qe(d.label,x,oe),[I]:d[I]};return Object.assign(k,Ne(d.link,p)),ee&&d.httpVerb&&(k.httpVerb=d.httpVerb,k.metadata={subType:"openapi-operation"}),k});if(!f.length)continue;const U=ke(l,e.type,i),re=Fe(l?.version),q={type:e.type,title:U,version:re,description:typeof l?.description=="string"?l.description:void 0,summary:typeof l?.summary=="string"?l.summary:void 0,...l?.["x-metadata"]&&typeof l["x-metadata"]=="object"?l["x-metadata"]:{}};f[0]={...f[0],metadata:q,hasClientRoutes:!0,getSidebar:(d,x)=>Te(X(i),p,x),getNavText:()=>U??Le[e.type]??"API Docs",getSearchDocuments:ve(i,q,o.getSearchFacets,o.setSearchFacets,B,S,e.document),getAiDocumentsStore:Ie({getBuild:()=>L.build,metadata:q,document:e.document,specType:e.type,excludeFromSearch:B,basePath:p,getSearchFacets:o.getSearchFacets,markdocTags:{...ae,schemaDefinition:ie}})};const se=f[0];f[0]=f[f.length-1],f[f.length-1]=se;for(const d of f)o.addRoute(d);if(C){const d=Re(e.config?.apis,e.realRelativePath);g[C]={[I]:d.rbac,[T]:{fsPath:u}}}r.set(b,L)}})},afterRoutesCreated:async(o,D)=>{const{buildItems:R,simplifyAstStructure:v}=await z(o.serverOutDir);for(const c of r.values())Q(o,c.build.items);const P=new Set,y=new Set;for(const{chunks:c,relativePath:n,isVirtual:m}of t){const h=`${O}${n}`,E=be(o.getAllRoutes(),n);for(const{node:e,markdown:u,pointer:p,key:i,relativePath:S}of c){const{ast:b,compoundHash:M}=await o.parseMarkdoc({input:{content:u,relativePath:S,isVirtual:m},resource:p,context:D,deps:{sharedDataIds:[`${O}${S}`],routeSlugs:E}});if(P.add(p),!(i==="graphql-docs"?e?.description?.value!==void 0:!!i&&Ce(e,i,u))||!J(e,i,M))continue;y.add(h);const _=v(b);if(i==="graphql-docs"){e.description&&(e.description.value=_);const C=`${O}${S}`;Be(r.get(C),_)}else i&&(e[i]=_)}}const w=a.difference(P);for(const c of w)D.cache.delete(c);a=P,Object.entries(g).forEach(([c,n])=>{const m=n[T]?.fsPath;if(!m)return;const h=o.getRouteByFsPath(m)?.baseSlug;g[c]={...n,[T]:{...n[T],slug:h},slug:h}}),o.setGlobalData({apiProducts:g});for(const[c,n]of r){if(!y.has(c))continue;const{items:m,store:h}=await R({type:n.document.type,document:n.document.document,options:n.document.options,basePath:n.basePath,markdownParser:j});n.build={items:m,store:h},Q(o,m),await o.createSharedData(c,Y(n,m,h))}}}}function Q(t,r){for(const{from:s,to:a}of ne(r))t.getConfig().redirects?.[s]||t.getRouteBySlug(s,{followRedirect:!1})||(t.addRouteAlias(s,a),t.addRedirect(s,{to:a},{trackOriginalSource:!1}))}function Y({document:t,basePath:r,sourcePath:s,apiId:a},g,A){return{[I]:K(t.config),[T]:{slug:me(r),fsPath:t.customOutputRelativeFile||t.relativePath},items:g,store:A,options:t.options,baseSlug:r,routesMapping:G.isDevelopMode?we(g,r):{},graphqlPositions:G.isDevelopMode&&t.type==="graphql"?Ee(g,r):void 0,sourcePath:s,apiId:a}}function Be(t,r){t?.document.type!=="graphql"||!t.document.options||(t.document.options.info={...t.document.options.info||{},description:r})}function qe(t,r,s){return async function(a){return{...s?{isTranslationFallback:!0}:{},props:{settings:{baseUrlPath:N(a.baseSlug)},disableAutoScroll:!0,seo:{title:t,...r}}}}}function xe(t,r){const s=t.options?.mockServer,a=N(`/_mock${Oe(t.relativePath)}`);s?.url===a&&(t.options={...t.options,mockServer:{...s,url:N(`/_mock${r}`)}})}function Ne(t,r){if(t===r)return{};const s=r==="/"?"/":`${r}/`;if(t.startsWith(s)){const a=t.slice(s.length);return a?{slugSuffix:a}:{}}return{slug:t}}function $e(t){if(t&&typeof t=="object"&&"info"in t)return t.info}function X(t){return t.map(({content:r,items:s,...a})=>({...a,...s&&{items:X(s)}}))}export{Pt as apiDocsPlugin,Ne as toRouteSlugFields};
@@ -1 +1 @@
1
- import*as O from"node:path";import{findFirstBinding as A,markdocParser as F}from"@redocly/api-docs";import{combineUrls as i}from"@redocly/theme/core/openapi";import{withPathPrefix as k}from"@redocly/theme/core/utils";import{GRAPHQL_SPEC_SLUG as L}from"../../../constants/common.js";import{PUBLIC_API_DEFINITIONS_FOLDER as f}from"../../constants/common.js";import{envConfig as E}from"../../config/env-config.js";import{deepMerge as w}from"../../../utils/object/deep-merge.js";import{normalizeFeedbackOptions as B}from"./utils/normalize-feedback-options.js";import{replaceFileExtension as p}from"./utils/replace-file-extension.js";import{relativePathToBaseSlug as M}from"./utils/relative-path-to-base-slug.js";const R={tags:{},nodes:{},components:{}};function D(o,r){if(!(o?.off!==!0))return o;const a=M(r);return{url:k(`/_mock${a}`),position:"first",description:"Mock server",...o}}function I(o,r){return(r==="graphql"?[i(L,`${p(o,O.posix.extname(o))}?download`)]:[i(f,`${p(o,".json")}?download`),i(f,`${p(o,".yaml")}?download`)]).map(a=>({url:k(a)}))}function X(o,r,m){const{rootConfig:a,config:s,apiConfig:c,mergedConfig:e,relativePath:l}=m,n=w(a?.[o]||{},s[o]||{},c[o]||c.theme?.[o]||{}),S=r["x-feedback"]||n.feedback||s.feedback,b=!!e[o]?.excludeFromSearch||!!e.theme?.[o]?.excludeFromSearch||!!a?.[o]?.excludeFromSearch||!!a?.theme?.[o]?.excludeFromSearch,_=e.rbac||c.rbac,g=B(S),u=s.metadata,x={...g&&{feedback:g},mockServer:D(e?.mockServer||a?.mockServer,l),disableRouter:!0,downloadUrls:n.downloadUrls||I(l,o),excludeFromSearch:b,rbac:_,markdownParser:F,replayFeatures:{graphql:E.REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED??!1,asyncapi:E.REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED??!1}};let d;if(o==="graphql"){const t=n;d={title:t.info?.title,...u,...t.metadata??{}}}else{const t=r.info,P=t?.["x-metadata"];d={title:t?.title,description:t?.description,...o==="openapi"&&{summary:t?.summary},...u,...P}}o==="openapi"&&n.showSchemaCatalogLinks&&(r["x-schema-catalog-link"]=i(f,l));const C=n.markdocOptions??R,h={...n,...x,specType:o,markdocOptions:C,metadata:d};return o==="asyncapi"&&(h.protocol=A(r)??void 0),h}export{I as buildDownloadUrls,X as createOptions};
1
+ import*as L from"node:path";import{descriptionOptions as x,markdocParser as A}from"@redocly/api-docs";import{combineUrls as i}from"@redocly/theme/core/openapi";import{withPathPrefix as E}from"@redocly/theme/core/utils";import{GRAPHQL_SPEC_SLUG as D}from"../../../constants/common.js";import{PUBLIC_API_DEFINITIONS_FOLDER as f,PUBLIC_STATIC_FOLDER as F}from"../../constants/common.js";import{envConfig as S}from"../../config/env-config.js";import{deepMerge as w}from"../../../utils/object/deep-merge.js";import{normalizeFeedbackOptions as R}from"./utils/normalize-feedback-options.js";import{replaceFileExtension as p}from"./utils/replace-file-extension.js";import{relativePathToBaseSlug as B}from"./utils/relative-path-to-base-slug.js";const I={tags:{},nodes:{},components:{}};function U(o,r){if(!(o?.off!==!0))return o;const e=B(r);return{url:E(`/_mock${e}`),position:"first",description:"Mock server",...o}}function M(o,r){return(r==="graphql"?[i(D,`${p(o,L.posix.extname(o))}?download`)]:[i(f,`${p(o,".json")}?download`),i(f,`${p(o,".yaml")}?download`)]).map(e=>({url:E(e)}))}function j(o,r,l){const{rootConfig:e,config:s,apiConfig:c,mergedConfig:t,relativePath:a}=l,n=w(e?.[o]||{},s[o]||{},c[o]||c.theme?.[o]||{}),_=r["x-feedback"]||n.feedback||s.feedback,b=!!t[o]?.excludeFromSearch||!!t.theme?.[o]?.excludeFromSearch||!!e?.[o]?.excludeFromSearch||!!e?.theme?.[o]?.excludeFromSearch,C=t.rbac||c.rbac,g=R(_),h=s.metadata,u=M(a,o),O={...g&&{feedback:g},mockServer:U(t?.mockServer||e?.mockServer,a),disableRouter:!0,downloadUrls:n.downloadUrls||u,replayDefinitionUrl:o!=="graphql"&&a.startsWith(`${F}/`)?void 0:u[0]?.url,excludeFromSearch:b,rbac:C,markdownParser:A,replayFeatures:{graphql:S.REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED??!1,asyncapi:S.REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED??!1}},k=x(o,r,h);let m;if(o==="graphql"){const d=n;m={title:d.info?.title,...h,...d.metadata??{}}}else m={description:r.info?.description,...k.metadata};o==="openapi"&&n.showSchemaCatalogLinks&&(r["x-schema-catalog-link"]=i(f,a));const P=n.markdocOptions??I;return{...n,...O,...k,markdocOptions:P,metadata:m}}export{M as buildDownloadUrls,j as createOptions};
@@ -1,5 +1,4 @@
1
- import { ApiDocsSearchIndexer } from '@redocly/api-docs';
2
- import type { ExampleEntry, GraphqlStoreMeta, SchemaEntry, SearchIndexerOptions } from '@redocly/api-docs';
1
+ import type { SearchIndexerOptions } from '@redocly/api-docs';
3
2
  import type { RenderTagFn } from '../../../../types/index.js';
4
3
  export type DescriptionFormatter = NonNullable<SearchIndexerOptions['formatDescription']>;
5
4
  /**
@@ -7,6 +6,4 @@ export type DescriptionFormatter = NonNullable<SearchIndexerOptions['formatDescr
7
6
  * llms.txt. Tags render through `renderTag` (their `renderForLlms`).
8
7
  */
9
8
  export declare function createLlmDescriptionFormatter(renderTag?: RenderTagFn): DescriptionFormatter;
10
- /** The shared api-docs indexer with Markdown descriptions — AI search documents and llms.txt need Markdown. */
11
- export declare function createApiDocsSearchIndexer(basePath: string, formatDescription: DescriptionFormatter, schemaStore?: Record<string, SchemaEntry>, document?: Record<string, unknown>, exampleStore?: Record<string, ExampleEntry>, graphqlMeta?: GraphqlStoreMeta): ApiDocsSearchIndexer;
12
9
  //# sourceMappingURL=create-indexer.d.ts.map
@@ -1 +1 @@
1
- import{ApiDocsSearchIndexer as a,markdocParser as f,parseMarkdown as p}from"@redocly/api-docs";import{toMarkdown as s}from"../../markdown/search/to-markdown.js";function u(i){const n=new Map;return r=>{if(typeof r=="string"&&!r.includes("{%"))return r;const e=typeof r=="string"?n.get(r):void 0;if(e!==void 0)return e;const t=p(r,{markdownParser:f}),o=!t||typeof t=="string"?t??"":s(Array.isArray(t)?t:[t],{renderTag:i}).trim();return typeof r=="string"&&n.set(r,o),o}}function d(i,n,r,e,t,o){return new a(i,r,e,{formatDescription:n,exampleStore:t,graphqlMeta:o})}export{d as createApiDocsSearchIndexer,u as createLlmDescriptionFormatter};
1
+ import{markdocParser as a,parseMarkdown as f}from"@redocly/api-docs";import{toMarkdown as m}from"../../markdown/search/to-markdown.js";function u(i){const n=new Map;return r=>{if(typeof r=="string"&&!r.includes("{%"))return r;const o=typeof r=="string"?n.get(r):void 0;if(o!==void 0)return o;const t=f(r,{markdownParser:a}),e=!t||typeof t=="string"?t??"":m(Array.isArray(t)?t:[t],{renderTag:i}).trim();return typeof r=="string"&&n.set(r,e),e}}export{u as createLlmDescriptionFormatter};
@@ -1,20 +1,20 @@
1
- import C from"node:path";import{REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{nodeTypes as y,contentType as A,isGraphqlFieldsNode as un,resolveGraphqlItemFields as dn}from"@redocly/api-docs";import{normalizeApiVersion as mn}from"../utils/normalize-api-version.js";import{replaceFileExtension as U}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as hn,canDownloadApiDefinition as yn,extractTeamsFromScopeItems as $n}from"../../../utils/rbac.js";import{getLlmsTxtMdPathBySlug as gn}from"../../../utils/llmstxt/get-llms-txt-md-path-by-slug.js";import{PUBLIC_API_DEFINITIONS_FOLDER as Y}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as bn}from"../../../../constants/common.js";import{isPlainObject as $}from"../../../../utils/guards/is-plain-object.js";import{ANONYMOUS_AUTH_DETAILS as An}from"../../../constants/rbac.js";import{toMarkdown as N}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as In}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as On}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as Pn}from"../../../utils/l10n/get-build-translate-context.js";import{getPublicEnvVariables as Sn}from"../../../utils/envs/get-public-env-variables.js";import{llmsTxtLink as K}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as xn}from"../../search/utils.js";import{extractDocumentSearchFacets as Cn}from"./search-facets.js";import{createApiDocsSearchIndexer as vn,createLlmDescriptionFormatter as Ln}from"./create-indexer.js";function O(t,s){return s==="openapi"&&"openapi"in t}function X(t,s){return s==="asyncapi"&&"asyncapi"in t}function se({getBuild:t,metadata:s,document:r,specType:c,excludeFromSearch:n,basePath:o,getSearchFacets:e,markdocTags:l}){return async(i,f,m,a)=>{if(n)return;const{items:d,store:u}=t(),h={...a.markdocOptions?.tags,...l},{locale:on,translate:rn}=await Pn(i.slug,a.getGlobalData?.().l10n),P=In(h,on,rn,{env:Sn()}),L=a.getConfig(),T=On(i.fsPath),R=Ln(P),j=vn(o,R,u?.schemaStore,r,u?.exampleStore,u?.graphqlMeta),M=b=>{for(const p of b)j.addItem(p),p.items?.length&&M(p.items)};M(d);const sn=j.getResult(),V=new Map;for(const b of sn)V.set(b.url,b);const D=typeof s.title=="string"?s.title:void 0,F=mn(s.version),E=Cn(i.metadata||{},D,F,e),S=[],x=[],_=Tn(r,s),q=_?R(_):void 0,G=Rn(s,q,r,c,R),z=Dn(c,s,i.fsPath,L),W=new Map,cn=Z(d,L,W,P),ln=G+z+`
2
- `+cn,fn=G+z;x.push({title:D||"API Overview",description:q,content:ln,slug:o,fsPath:i.fsPath,includeInLLMsTxt:!0}),S.push({title:D||"API Overview",content:fn,url:o,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:E});const an=r&&O(r,c)?r.security:void 0,k=b=>{for(const p of b){if(!p.content||!p.link){p.items?.length&&k(p.items);continue}const pn=V.get(p.link),B=p.content.contentType,J=p[v],Q=J?$n(J):void 0,H=Q?.length?Q:void 0;if(B===A.ITEM){const g=Un(p,r,c)??nn(p,pn,c,F,an,P,u);if(g){const I=p.label||"";x.push({title:I,description:void 0,content:g,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),S.push({title:I,content:g,url:p.link,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:E,rbacTeams:H})}}else if(B===A.GROUP){const g=Nn(p,L,c,W,P,u);if(g){const I=p.label||"";x.push({title:I,description:void 0,content:g.llmstxt,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),S.push({title:I,content:g.aiSearch,url:p.link,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:E,rbacTeams:H})}}p.items?.length&&k(p.items)}};return k(d),{async getLLMsTxts(){return x},async getSearchDocuments(){return S}}}}function Tn(t,s){const r=$(t?.info)?t.info:void 0,c=$(r?.["x-metadata"])?r["x-metadata"]:{},o=(typeof c.description=="string"?c.description:void 0)??r?.description??s.description;return typeof o=="string"?o||void 0:o&&typeof o=="object"?o:void 0}function Rn(t,s,r,c,n){const o=typeof t.title=="string"?t.title:"",e=typeof t.summary=="string"?t.summary:"",l=typeof t.version=="string"?t.version:"";let i=o?`# ${o}
1
+ import C from"node:path";import{REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{ApiDocsSearchIndexer as an,nodeTypes as y,contentType as b,isGraphqlFieldsNode as pn,resolveGraphqlItemFields as un}from"@redocly/api-docs";import{normalizeApiVersion as dn}from"../utils/normalize-api-version.js";import{replaceFileExtension as w}from"../utils/replace-file-extension.js";import{isResourcePubliclyAccessible as mn,canDownloadApiDefinition as hn,extractTeamsFromScopeItems as yn}from"../../../utils/rbac.js";import{getMarkdownCopyPath as $n}from"@redocly/theme/core/utils";import{PUBLIC_API_DEFINITIONS_FOLDER as B}from"../../../constants/common.js";import{GRAPHQL_SPEC_SLUG as gn}from"../../../../constants/common.js";import{isPlainObject as $}from"../../../../utils/guards/is-plain-object.js";import{ANONYMOUS_AUTH_DETAILS as bn}from"../../../constants/rbac.js";import{toMarkdown as U}from"../../markdown/search/to-markdown.js";import{createRenderTagFn as An}from"../../markdown/search/create-render-tag-fn.js";import{getLocaleFromRelativePath as In}from"../../../fs/utils/get-locale-from-relative-path.js";import{getBuildTranslateContext as On}from"../../../utils/l10n/get-build-translate-context.js";import{getPublicEnvVariables as Pn}from"../../../utils/envs/get-public-env-variables.js";import{llmsTxtLink as H}from"../../search/llmstxt/index.js";import{formatDocumentMetadata as Sn}from"../../search/utils.js";import{extractDocumentSearchFacets as xn}from"./search-facets.js";import{createLlmDescriptionFormatter as Cn}from"./create-indexer.js";function I(t,s){return s==="openapi"&&"openapi"in t}function Y(t,s){return s==="asyncapi"&&"asyncapi"in t}function re({getBuild:t,metadata:s,document:r,specType:c,excludeFromSearch:n,basePath:o,getSearchFacets:e,markdocTags:l}){return async(i,f,m,a)=>{if(n)return;const{items:d,store:u}=t(),h={...a.markdocOptions?.tags,...l},{locale:en,translate:tn}=await On(i.slug,a.getGlobalData?.().l10n),O=An(h,en,tn,{env:Pn()}),L=a.getConfig(),T=In(i.fsPath),D=Cn(O),on=new an({basePath:o,store:u,document:r,formatDescription:D}).documents(d),j=new Map;for(const x of on)j.set(x.url,x);const E=typeof s.title=="string"?s.title:void 0,M=dn(s.version),R=xn(i.metadata||{},E,M,e),P=[],S=[],V=vn(r,s),F=V?D(V):void 0,_=Ln(s,F,r,c,D),q=Tn(c,s,i.fsPath,L),G=new Map,rn=K(d,L,G,O),sn=_+q+`
2
+ `+rn,cn=_+q;S.push({title:E||"API Overview",description:F,content:sn,slug:o,fsPath:i.fsPath,includeInLLMsTxt:!0}),P.push({title:E||"API Overview",content:cn,url:o,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:R});const ln=r&&I(r,c)?r.security:void 0,k=x=>{for(const p of x){if(!p.content||!p.link){p.items?.length&&k(p.items);continue}const fn=j.get(p.link),z=p.content.contentType,W=p[v],J=W?yn(W):void 0,Q=J?.length?J:void 0;if(z===b.ITEM){const g=Rn(p,r,c)??X(p,fn,c,M,ln,O,u);if(g){const A=p.label||"";S.push({title:A,description:void 0,content:g,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),P.push({title:A,content:g,url:p.link,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:R,rbacTeams:Q})}}else if(z===b.GROUP){const g=kn(p,L,c,G,O,u);if(g){const A=p.label||"";S.push({title:A,description:void 0,content:g.llmstxt,slug:p.link,fsPath:i.fsPath,includeInLLMsTxt:!1}),P.push({title:A,content:g.aiSearch,url:p.link,fsPath:i.fsPath,locale:T,product:i.product?.name,facets:R,rbacTeams:Q})}}p.items?.length&&k(p.items)}};return k(d),{async getLLMsTxts(){return S},async getSearchDocuments(){return P}}}}function vn(t,s){const r=$(t?.info)?t.info:void 0,c=$(r?.["x-metadata"])?r["x-metadata"]:{},o=(typeof c.description=="string"?c.description:void 0)??r?.description??s.description;return typeof o=="string"?o||void 0:o&&typeof o=="object"?o:void 0}function Ln(t,s,r,c,n){const o=typeof t.title=="string"?t.title:"",e=typeof t.summary=="string"?t.summary:"",l=typeof t.version=="string"?t.version:"";let i=o?`# ${o}
3
3
 
4
4
  `:"";if(i+=s?`${s}
5
5
 
6
6
  `:"",i+=e?`${e}
7
7
 
8
8
  `:"",i+=l?`Version: ${l}
9
- `:"",r){if(O(r,c)){const{info:f}=r;f?.license?.name&&(i+=`License: ${f.license.name}
10
- `);const m=f["x-metadata"],a=Object.entries($(m)?m:{}).filter(([u,h])=>u!=="description"||typeof h!="string"),d=xn(Object.fromEntries(a));d&&(i+=`
9
+ `:"",r){if(I(r,c)){const{info:f}=r;f?.license?.name&&(i+=`License: ${f.license.name}
10
+ `);const m=f["x-metadata"],a=Object.entries($(m)?m:{}).filter(([u,h])=>u!=="description"||typeof h!="string"),d=Sn(Object.fromEntries(a));d&&(i+=`
11
11
  Metadata:
12
12
  ${d}
13
- `)}else if(X(r,c)){const{info:f}=r;f?.license?.name&&(i+=`License: ${f.license.name}
13
+ `)}else if(Y(r,c)){const{info:f}=r;f?.license?.name&&(i+=`License: ${f.license.name}
14
14
  `)}}return i+=`
15
- `,i+=En(r,c,n),i+=kn(r,c,n),i}function Dn(t,s,r,c){if(!r)return"";let n,o,e;if(t==="openapi")n=C.posix.join(Y,U(r,".yaml")),o="## Download OpenAPI description",e="OpenAPI definition";else if(t==="asyncapi")n=C.posix.join(Y,U(r,".yaml")),o="## Download AsyncAPI description",e="AsyncAPI definition";else if(t==="graphql"){const f=C.posix.extname(r)||".graphql";n=C.posix.join(bn,U(r,f)),o="## Download GraphQL schema",e="GraphQL schema"}else return"";if(!yn(n,c.access?.rbac??{},c.access?.requiresLogin??!1,An))return"";const i=typeof s.title=="string"&&s.title||e;return`${o}
15
+ `,i+=Dn(r,c,n),i+=En(r,c,n),i}function Tn(t,s,r,c){if(!r)return"";let n,o,e;if(t==="openapi")n=C.posix.join(B,w(r,".yaml")),o="## Download OpenAPI description",e="OpenAPI definition";else if(t==="asyncapi")n=C.posix.join(B,w(r,".yaml")),o="## Download AsyncAPI description",e="AsyncAPI definition";else if(t==="graphql"){const f=C.posix.extname(r)||".graphql";n=C.posix.join(gn,w(r,f)),o="## Download GraphQL schema",e="GraphQL schema"}else return"";if(!hn(n,c.access?.rbac??{},c.access?.requiresLogin??!1,bn))return"";const i=typeof s.title=="string"&&s.title||e;return`${o}
16
16
 
17
- - ${K({title:i,description:void 0,slug:n,siteUrl:c.seo?.siteUrl})}`}function En(t,s,r){if(!t)return"";if(O(t,s)){const c=Array.isArray(t.servers)?t.servers.filter($):[];if(!c.length)return"";let n=`## Servers
17
+ - ${H({title:i,description:void 0,slug:n,siteUrl:c.seo?.siteUrl})}`}function Dn(t,s,r){if(!t)return"";if(I(t,s)){const c=Array.isArray(t.servers)?t.servers.filter($):[];if(!c.length)return"";let n=`## Servers
18
18
 
19
19
  `;for(const o of c){o.description&&(n+=`${r(o.description)}
20
20
  `),n+=`\`\`\`
@@ -26,7 +26,7 @@ ${o.url}
26
26
  `,i.default&&(n+=` Default: ${JSON.stringify(i.default)}
27
27
  `),Array.isArray(i.enum)&&(n+=` Enum: ${i.enum.map(f=>JSON.stringify(f)).join(", ")}
28
28
  `);n+=`
29
- `}}return n}if(X(t,s)){const c=Object.entries($(t.servers)?t.servers:{}).filter(([,o])=>$(o));if(!c.length)return"";let n=`## Servers
29
+ `}}return n}if(Y(t,s)){const c=Object.entries($(t.servers)?t.servers:{}).filter(([,o])=>$(o));if(!c.length)return"";let n=`## Servers
30
30
 
31
31
  `;for(const[o,e]of c)n+=`### ${o}
32
32
 
@@ -36,7 +36,7 @@ ${o.url}
36
36
  `),e.protocolVersion&&(n+=`Protocol Version: ${e.protocolVersion}
37
37
  `),e.pathname&&(n+=`Pathname: ${e.pathname}
38
38
  `),n+=`
39
- `;return n}return""}function kn(t,s,r){if(!t||!O(t,s))return"";const c=t.components?.securitySchemes;if(!c)return"";let n=`## Security
39
+ `;return n}return""}function En(t,s,r){if(!t||!I(t,s))return"";const c=t.components?.securitySchemes;if(!c)return"";let n=`## Security
40
40
 
41
41
  `;for(const[o,e]of Object.entries(c)){if(!e||"$ref"in e)continue;const l=e;n+=`### ${o}
42
42
 
@@ -53,9 +53,9 @@ ${o.url}
53
53
  `),f.scopes)){n+=`Scopes:
54
54
  `;for(const[m,a]of Object.entries(f.scopes))n+=`- \`${m}\`: ${a}
55
55
  `}n+=`
56
- `}return n}function Z(t,s,r,c){let n="";const o=(e,l)=>{for(const i of e)if(!(!i.link||!tn(i,s))){if(i.content?.contentType===A.GROUP)n+=`${l} ${i.label||""}
56
+ `}return n}function K(t,s,r,c){let n="";const o=(e,l)=>{for(const i of e)if(!(!i.link||!nn(i,s))){if(i.content?.contentType===b.GROUP)n+=`${l} ${i.label||""}
57
57
 
58
- `,i.items?.length&&o(i.items,l+"#");else if(i.content?.contentType===A.ITEM){let f=r.get(i.link);if(f===void 0){const m=i,a=m.httpVerb,d=m.httpPath,u=a&&d?`${a.toUpperCase()} ${d}`:i.label||"",h=w(i.content.children,c);f=` - ${K({title:u,description:h?h.slice(0,200):void 0,slug:gn(i.link),siteUrl:s.seo?.siteUrl})}`,r.set(i.link,f)}n+=f}}};return o(t,"##"),n}function nn(t,s,r,c,n,o,e){if(!t.content)return;const l=t,i=t.label||"",f=w(t.content.children,o),m=t.content.meta?.deprecated;let a=`# ${i}${m?" (deprecated)":""}
58
+ `,i.items?.length&&o(i.items,l+"#");else if(i.content?.contentType===b.ITEM){let f=r.get(i.link);if(f===void 0){const m=i,a=m.httpVerb,d=m.httpPath,u=a&&d?`${a.toUpperCase()} ${d}`:i.label||"",h=N(i.content.children,c);f=` - ${H({title:u,description:h?h.slice(0,200):void 0,slug:$n(i.link),siteUrl:s.seo?.siteUrl})}`,r.set(i.link,f)}n+=f}}};return o(t,"##"),n}function X(t,s,r,c,n,o,e){if(!t.content)return;const l=t,i=t.label||"",f=N(t.content.children,o),m=t.content.meta?.deprecated;let a=`# ${i}${m?" (deprecated)":""}
59
59
 
60
60
  `;if(f&&(a+=`${f}
61
61
 
@@ -64,8 +64,8 @@ ${o.url}
64
64
  `),c&&(a+=`Version: ${c}
65
65
  `);const h=wn(t.content.children,n);h&&(a+=`Security: ${h}
66
66
  `)}return s?.parameters?.length&&r!=="graphql"&&(a+=`
67
- `+jn(s.parameters)+`
68
- `),r==="graphql"&&(a+=Mn(t.content.children,e,o)),a}function Un(t,s,r){if(t.httpVerb!=="tool"||!s||!O(s,r))return;const c=t.content?.meta?.name,n=c?s["x-mcp"]?.tools?.find(e=>e.name===c):void 0;if(!n)return;let o=`# ${t.label||n.name}
67
+ `+Un(s.parameters)+`
68
+ `),r==="graphql"&&(a+=Nn(t.content.children,e,o)),a}function Rn(t,s,r){if(t.httpVerb!=="tool"||!s||!I(s,r))return;const c=t.content?.meta?.name,n=c?s["x-mcp"]?.tools?.find(e=>e.name===c):void 0;if(!n)return;let o=`# ${t.label||n.name}
69
69
 
70
70
  `;return typeof n.description=="string"&&n.description&&(o+=`${n.description}
71
71
 
@@ -81,25 +81,25 @@ ${JSON.stringify(n.inputSchema,null,2)}
81
81
  ${JSON.stringify(n.outputSchema,null,2)}
82
82
  \`\`\`
83
83
 
84
- `),o}function Nn(t,s,r,c,n,o){if(!t.content)return;const e=t.label||"",l=w(t.content.children,n);let i=`# ${e}
84
+ `),o}function kn(t,s,r,c,n,o){if(!t.content)return;const e=t.label||"",l=N(t.content.children,n);let i=`# ${e}
85
85
 
86
86
  `;if(l&&(i+=`${l}
87
87
 
88
- `),r==="graphql"){let m="";const a=d=>{for(const u of d??[])if(!(!u.content||!tn(u,s)))if(u.content.contentType===A.ITEM){const h=nn(u,void 0,r,void 0,void 0,n,o);h&&(m+=`${h}
88
+ `),r==="graphql"){let m="";const a=d=>{for(const u of d??[])if(!(!u.content||!nn(u,s)))if(u.content.contentType===b.ITEM){const h=X(u,void 0,r,void 0,void 0,n,o);h&&(m+=`${h}
89
89
 
90
90
  ---
91
91
 
92
- `)}else u.content.contentType===A.GROUP&&a(u.items)};return a(t.items),{llmstxt:i+m,aiSearch:i}}const f=Z(t.items??[],s,c,n);return{llmstxt:i+f,aiSearch:i}}function wn(t,s){const r=[],c=n=>{for(const o of n)if(o.nodeType===y.SECURITY){const e=o;for(const l of e.requirements)for(const i of l.schemes)i[v]||i.name&&!r.includes(i.name)&&r.push(i.name)}else(o.nodeType===y.CONTAINER||o.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(o.children)};if(c(t),r.length)return r.join(", ");if(s?.length){const n=s.flatMap(o=>Object.keys(o));if(n.length)return[...new Set(n)].join(", ")}}function jn(t){const s={};for(const c of t){const n=`${c.place}${c.mediaType?` (${c.mediaType})`:""}`;s[n]||(s[n]=[]),s[n].push(c)}return Object.entries(s).map(([c,n])=>{const o=n.map(e=>{const l=[...e.path||[],e.name],i=Array.isArray(e.description)?e.description.join(" "):e.description;let f=` - \`${l.join(".")}\` (${e.type}${e.required?", required":""})
92
+ `)}else u.content.contentType===b.GROUP&&a(u.items)};return a(t.items),{llmstxt:i+m,aiSearch:i}}const f=K(t.items??[],s,c,n);return{llmstxt:i+f,aiSearch:i}}function wn(t,s){const r=[],c=n=>{for(const o of n)if(o.nodeType===y.SECURITY){const e=o;for(const l of e.requirements)for(const i of l.schemes)i[v]||i.name&&!r.includes(i.name)&&r.push(i.name)}else(o.nodeType===y.CONTAINER||o.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(o.children)};if(c(t),r.length)return r.join(", ");if(s?.length){const n=s.flatMap(o=>Object.keys(o));if(n.length)return[...new Set(n)].join(", ")}}function Un(t){const s={};for(const c of t){const n=`${c.place}${c.mediaType?` (${c.mediaType})`:""}`;s[n]||(s[n]=[]),s[n].push(c)}return Object.entries(s).map(([c,n])=>{const o=n.map(e=>{const l=[...e.path||[],e.name],i=Array.isArray(e.description)?e.description.join(" "):e.description;let f=` - \`${l.join(".")}\` (${e.type}${e.required?", required":""})
93
93
  `;return i&&(f+=` ${i.trim()}
94
94
  `),e.enum?f+=` Enum: ${e.enum.map(m=>JSON.stringify(m)).join(", ")}
95
95
  `:e.example&&(f+=` Example: ${e.example}
96
- `),f});return`## ${en(c)}:
96
+ `),f});return`## ${Z(c)}:
97
97
 
98
98
  ${o.join(`
99
99
  `)}`}).join(`
100
- `)}function Mn(t,s,r){let c="";const n=o=>{for(const e of o)if(e.nodeType===y.ITEM){const l=un(e)?dn(e,s??{}):void 0;l&&(c+=Vn(l,e.variant,r))}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&n(e.children)};return n(t),c}function Vn(t,s,r){let n=`
101
- ## ${en(s==="return-type"?"Return type":s==="graphql-args"||s==="arguments"?"Arguments":s==="graphql-fields"?"Fields":s)}:
100
+ `)}function Nn(t,s,r){let c="";const n=o=>{for(const e of o)if(e.nodeType===y.ITEM){const l=pn(e)?un(e,s??{}):void 0;l&&(c+=jn(l,e.variant,r))}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&n(e.children)};return n(t),c}function jn(t,s,r){let n=`
101
+ ## ${Z(s==="return-type"?"Return type":s==="graphql-args"||s==="arguments"?"Arguments":s==="graphql-fields"?"Fields":s)}:
102
102
 
103
- `;const o=e=>{const l=e.description?N(Array.isArray(e.description)?e.description:[e.description],{renderTag:r}).trim():"";return` - \`${e.name}\` (${e.type.display})${l?`: ${l}`:""}
104
- `};if(t.type){const e=t.type.description?N(Array.isArray(t.type.description)?t.type.description:[t.type.description],{renderTag:r}).trim():"";n+=` Type: ${t.type.display}`,e&&(n+=` - ${e}`),n+=`
105
- `}else if(!t.fields.length)return"";for(const e of t.fields)n+=o(e);return n}function w(t,s){const r=[],c=o=>{for(const e of o)if(e.nodeType===y.MARKDOC){const l=e.content,i=Array.isArray(l)?l:[l],f=N(i,{renderTag:s}).trim();f&&r.push(f)}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(e.children)};return c(t),r.join(" ").trim()||void 0}function en(t){return t.charAt(0).toUpperCase()+t.slice(1)}function tn(t,s){return s.access?.requiresLogin?!0:hn({slug:t.link||"",[v]:t[v]},s)}export{se as getAiDocumentsStore};
103
+ `;const o=e=>{const l=e.description?U(Array.isArray(e.description)?e.description:[e.description],{renderTag:r}).trim():"";return` - \`${e.name}\` (${e.type.display})${l?`: ${l}`:""}
104
+ `};if(t.type){const e=t.type.description?U(Array.isArray(t.type.description)?t.type.description:[t.type.description],{renderTag:r}).trim():"";n+=` Type: ${t.type.display}`,e&&(n+=` - ${e}`),n+=`
105
+ `}else if(!t.fields.length)return"";for(const e of t.fields)n+=o(e);return n}function N(t,s){const r=[],c=o=>{for(const e of o)if(e.nodeType===y.MARKDOC){const l=e.content,i=Array.isArray(l)?l:[l],f=U(i,{renderTag:s}).trim();f&&r.push(f)}else(e.nodeType===y.CONTAINER||e.nodeType===y.OVERVIEW_SECTION_WRAPPER)&&c(e.children)};return c(t),r.join(" ").trim()||void 0}function Z(t){return t.charAt(0).toUpperCase()+t.slice(1)}function nn(t,s){return s.access?.requiresLogin?!0:mn({slug:t.link||"",[v]:t[v]},s)}export{re as getAiDocumentsStore};
@@ -1 +1 @@
1
- import{REDOCLY_ROUTE_RBAC as h,REDOCLY_TEAMS_RBAC as o}from"@redocly/config";import{extractDocumentSearchFacets as x,setDocumentSearchFacets as A}from"./search-facets.js";import{ApiDocsSearchIndexer as D}from"@redocly/api-docs";import{normalizeApiVersion as d}from"../utils/normalize-api-version.js";function M(g,i,c,u,S,n,R){return async e=>{if(S)return[];const m=e.baseSlug||e.slug,l=new D(m,n?.schemaStore,R,{exampleStore:n?.exampleStore,graphqlMeta:n?.graphqlMeta}),p=t=>{for(const a of t)l.addItem(a),a.items?.length&&p(a.items)};p(g);const s=typeof i.title=="string"?i.title:void 0,r=d(i.version),f=x(e.metadata||{},s,r,c);return A(f,c,u),l.getResult().map(t=>({...t,...t.url===m&&s&&{title:r?`${s} (${r})`:s},[o]:t[o]??e[o],[h]:e[h]??{slug:e.slug,fsPath:e.fsPath},facets:f}))}}export{M as searchResolver};
1
+ import{REDOCLY_ROUTE_RBAC as m,REDOCLY_TEAMS_RBAC as c}from"@redocly/config";import{extractDocumentSearchFacets as g,setDocumentSearchFacets as A}from"./search-facets.js";import{ApiDocsSearchIndexer as D}from"@redocly/api-docs";import{normalizeApiVersion as S}from"../utils/normalize-api-version.js";function _(p,s,r,l,u,h,d){return async t=>{if(u)return[];const i=t.baseSlug||t.slug,R=new D({basePath:i,store:h,document:d}),e=typeof s.title=="string"?s.title:void 0,n=S(s.version),a=g(t.metadata||{},e,n,r);A(a,r,l);const f=[];for(const o of R.documents(p))f.push(Object.assign(o,{path:[],...o.url===i&&e&&{title:n?`${e} (${n})`:e},[c]:o[c]??t[c],[m]:t[m]??{slug:t.slug,fsPath:t.fsPath},facets:a}));return f}}export{_ as searchResolver};
@@ -1 +1 @@
1
- import e from"node:path";import{existsSync as u}from"node:fs";import{readFile as I}from"node:fs/promises";import L from"js-yaml";import{withoutPathPrefix as j}from"@redocly/theme/core/utils";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as g,PUBLIC_API_DEFINITIONS_FOLDER as w}from"../../constants/common.js";import{GRAPHQL_SPEC_SLUG as T}from"../../../constants/common.js";import{requestDefinitionAccessKey as C}from"./definition-access.js";import{canDownloadApiDefinition as U,filterDataByAccessDeep as B}from"../../utils/rbac.js";import{API_DOWNLOAD_PREFIXES as G}from"../../utils/is-api-download-link.js";import{decodeRequestPath as W}from"../../utils/decode-request-path.js";import{replaceFileExtension as X}from"./utils/replace-file-extension.js";const v=[".json",".yaml",".yml"],H=[".graphql",".gql"];function F(r,o){const t=e.parse(r);return e.join(t.dir,t.name+o)}const J=async(r,o,t)=>{const{isAuthenticated:a,teams:m,claims:{email:d}}=o.user,S=new URL(r.url),n=W(j(S.pathname));if(n===void 0||n.endsWith("/"))return new Response("Bad Request",{status:400});const c=G.find(i=>n.startsWith(`${i}/`));if(c===void 0)return new Response("Not found",{status:404});const p=c===T,s=n.slice(c.length),l=e.extname(s);if(!(p?H:v).includes(l))return new Response("Not found",{status:404});const{rbac:h={},requiresLogin:P=!1}=o.config.access||{},y=(t.props?.definitionAccess??{})[C(p,X(s.slice(1),""))];if(!U(n,h,P,{isAuthenticated:a,email:d,teams:m},y))return new Response("Unauthorized",{status:a?403:401});const f=t.props?.outdir||"";if(p){const i=e.join(f,w,s);if(!u(i))return new Response("Not found",{status:404});const q=await I(i,"utf-8");return new Response(q,{headers:{"Content-Type":"application/graphql"}})}const E=e.join(f,w,F(s,".json")),R=e.join(f,g,F(s,".json")),A=u(E),D=u(R);if(!A&&!D)return new Response("Not found",{status:404});const _=await I(A?E:R,"utf-8"),x=JSON.parse(_),N=B(x,{isAuthenticated:a,email:d,teams:m},h,P),O=l===".yaml"?L.dump(N):JSON.stringify(N,null,2);return new Response(O,{headers:{"Content-Type":l===".yaml"?"application/yaml":"application/json"}})};var ie=J;export{ie as default};
1
+ import e from"node:path";import{existsSync as u}from"node:fs";import{readFile as I}from"node:fs/promises";import L from"js-yaml";import{withoutPathPrefix as j}from"@redocly/theme/core/utils";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as g,PUBLIC_API_DEFINITIONS_FOLDER as w}from"../../constants/common.js";import{GRAPHQL_SPEC_SLUG as T}from"../../../constants/common.js";import{requestDefinitionAccessKey as C}from"./definition-access.js";import{canDownloadApiDefinition as U,filterDataByAccessDeep as B}from"../../utils/rbac.js";import{API_DOWNLOAD_PREFIXES as G}from"../../utils/is-api-download-link.js";import{decodeRequestPath as W}from"../../utils/decode-request-path.js";import{replaceFileExtension as X}from"./utils/replace-file-extension.js";const v=[".json",".yaml",".yml"],H=[".graphql",".gql"];function F(r,o){const t=e.parse(r);return e.join(t.dir,t.name+o)}const J=async(r,o,t)=>{const{isAuthenticated:a,teams:m,claims:{email:d}}=o.user,S=new URL(r.url),n=W(j(S.pathname));if(n===void 0||n.endsWith("/"))return new Response("Bad Request",{status:400});const c=G.find(i=>n.startsWith(`${i}/`));if(c===void 0)return new Response("Not found",{status:404});const p=c===T,s=n.slice(c.length),f=e.extname(s);if(!(p?H:v).includes(f))return new Response("Not found",{status:404});const{rbac:h={},requiresLogin:P=!1}=o.config.access||{},y=(t.props?.definitionAccess??{})[C(p,X(s.slice(1),""))];if(!U(n,h,P,{isAuthenticated:a,email:d,teams:m},y))return new Response("Unauthorized",{status:a?403:401});const l=t.props?.outdir||"";if(p){const i=e.join(l,w,s);if(!u(i))return new Response("Not found",{status:404});const q=await I(i,"utf-8");return new Response(q,{headers:{"Content-Type":"application/graphql"}})}const E=e.join(l,w,F(s,".json")),R=e.join(l,g,F(s,".json")),A=u(E),D=u(R);if(!A&&!D)return new Response("Not found",{status:404});const _=await I(A?E:R,"utf-8"),x=JSON.parse(_),N=B(x,{isAuthenticated:a,email:d,teams:m},h,P),O=f===".yaml"?L.dump(N,{noRefs:!0}):JSON.stringify(N,null,2);return new Response(O,{headers:{"Content-Type":f===".yaml"?"application/yaml":"application/json"}})};var ie=J;export{ie as default};
@@ -1 +1 @@
1
- import c from"node:path";import{CONFIG_FILE_NAME as O}from"../../../../constants/common.js";import{normalizeRouteSlug as l}from"../../../../utils/path/normalize-route-slug.js";import{removeLeadingSlash as x}from"../../../../utils/url/remove-leading-slash.js";import{parseBaseName as w}from"../../utils.js";const m=async(t,e)=>{if(!t.match(/(\.ya?ml|\.json)$/)||c.posix.basename(t)===O||await e.isPathIgnored(t))return null;const s=e.fs.getFileInfo(t);if(!s)return null;try{const{data:o}=await e.cache.load(s.realRelativePath,"yaml");return o??null}catch{return null}},L=async(t,e)=>{const s=await m(t,e);return!!(s?.openapi||s?.swagger)},j=async(t,e)=>!!(await m(t,e))?.asyncapi,F=t=>!!t.match(/(\.gql|\.graphql)$/),U=async(t,e,s,o)=>{const{getRouteBySlug:d,getRouteByFsPath:f}=s,i={isOpenapiDetected:!1,isOpenapiValid:!1},g={isOpenapiDetected:!0,isOpenapiValid:!1},h={isOpenapiDetected:!0,isOpenapiValid:!0};let r=t.toLowerCase();if(t.startsWith("/"))r=l(t);else if(t.startsWith("./")||t.startsWith("../")){const n=f(e)?.slug;if(!n)return i;const{isIndexFile:a}=w(e);r=a?l(c.posix.join(n,t)):l(c.posix.join(n,"../",t))}else return i;const p=r.toLowerCase().split("/");for(let n=p.length;n>=0;n--){const a=p.slice(0,n).join("/"),y=p.slice(n).join("/"),u=d(a)||f(x(a));if(u)return await L(u.fsPath,o)?y?g:h:i}return i};export{j as isAsyncapiDoc,F as isGraphqlDoc,U as isOpenApiURL,L as isOpenapiDoc};
1
+ import c from"node:path";import{CONFIG_FILE_NAME as O}from"../../../../constants/common.js";import{normalizeRouteSlug as l}from"../../../../utils/path/normalize-route-slug.js";import{removeLeadingSlash as x}from"../../../../utils/url/remove-leading-slash.js";import{parseBaseName as w}from"../../../utils/content/parse-base-name.js";const m=async(t,e)=>{if(!t.match(/(\.ya?ml|\.json)$/)||c.posix.basename(t)===O||await e.isPathIgnored(t))return null;const s=e.fs.getFileInfo(t);if(!s)return null;try{const{data:o}=await e.cache.load(s.realRelativePath,"yaml");return o??null}catch{return null}},L=async(t,e)=>{const s=await m(t,e);return!!(s?.openapi||s?.swagger)},j=async(t,e)=>!!(await m(t,e))?.asyncapi,F=t=>!!t.match(/(\.gql|\.graphql)$/),U=async(t,e,s,o)=>{const{getRouteBySlug:d,getRouteByFsPath:f}=s,i={isOpenapiDetected:!1,isOpenapiValid:!1},g={isOpenapiDetected:!0,isOpenapiValid:!1},h={isOpenapiDetected:!0,isOpenapiValid:!0};let r=t.toLowerCase();if(t.startsWith("/"))r=l(t);else if(t.startsWith("./")||t.startsWith("../")){const n=f(e)?.slug;if(!n)return i;const{isIndexFile:a}=w(e);r=a?l(c.posix.join(n,t)):l(c.posix.join(n,"../",t))}else return i;const p=r.toLowerCase().split("/");for(let n=p.length;n>=0;n--){const a=p.slice(0,n).join("/"),y=p.slice(n).join("/"),u=d(a)||f(x(a));if(u)return await L(u.fsPath,o)?y?g:h:i}return i};export{j as isAsyncapiDoc,F as isGraphqlDoc,U as isOpenApiURL,L as isOpenapiDoc};
@@ -1 +1 @@
1
- import i from"node:path";import{isL10nPath as m}from"../../../fs/utils/is-l10n-path.js";import{getLocaleFromRelativePath as n}from"../../../fs/utils/get-locale-from-relative-path.js";import{removeL10nPrefix as s}from"../../../fs/utils/remove-l10n-prefix.js";import{parseBaseName as p}from"../../utils.js";function h(r){const{baseName:t,isIndexFile:a}=p(r),e=i.posix.dirname(r),o=a?e==="."?"":e:e==="."?t:i.posix.join(e,t);return m(o)?("/"+n(o).toLowerCase()+"/"+s(o)).replace(/\/{2,}/g,"/"):("/"+o).replace(/\/{2,}/g,"/")}export{h as relativePathToBaseSlug};
1
+ import i from"node:path";import{isL10nPath as m}from"../../../fs/utils/is-l10n-path.js";import{getLocaleFromRelativePath as n}from"../../../fs/utils/get-locale-from-relative-path.js";import{removeL10nPrefix as s}from"../../../fs/utils/remove-l10n-prefix.js";import{parseBaseName as p}from"../../../utils/content/parse-base-name.js";function h(r){const{baseName:t,isIndexFile:a}=p(r),e=i.posix.dirname(r),o=a?e==="."?"":e:e==="."?t:i.posix.join(e,t);return m(o)?("/"+n(o).toLowerCase()+"/"+s(o)).replace(/\/{2,}/g,"/"):("/"+o).replace(/\/{2,}/g,"/")}export{h as relativePathToBaseSlug};
@@ -1,13 +1,4 @@
1
1
  import type { LoaderFn } from '../../../types';
2
- export type SlugCollisions = {
3
- pageVsPage: number;
4
- dirVsDir: number;
5
- };
6
- export type ContentSlugs = {
7
- fileSlugs: Map<string, string>;
8
- dirSlugs: Map<string, string>;
9
- collisions: SlugCollisions;
10
- };
11
- export declare const IGNORED_EXTS: Set<string>;
2
+ import type { ContentSlugs } from './utils/calculate-content-slugs.js';
12
3
  export declare const contentSlugsLoader: LoaderFn<ContentSlugs>;
13
4
  //# sourceMappingURL=content-slugs-loader.d.ts.map
@@ -1 +1 @@
1
- import f from"path";import{combineUrls as S}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as b}from"../../../constants/common.js";import{removeTrailingSlash as v}from"../../../../utils/url/remove-trailing-slash.js";import{slash as E}from"../../../../utils/path/slash.js";import{logger as m}from"../../../tools/notifiers/logger.js";import{getDefaultVersionByPath as I}from"./versions-config-loader.js";import{GithubSlugger as N,slug as h}from"../../../utils/index.js";import{isPartial as z}from"../../markdown/is-partial.js";import{parseBaseName as T}from"../../utils.js";const j=new Set([".jpg",".jpeg",".png",".gif",".webp",".svg",".ico",".avif",".mp3",".wav",".ogg",".m4a",".mp4",".avi",".mov",".webm",".pdf",".doc",".docx",".zip",".rar",".gz",".ttf",".woff",".woff2"]),U=async(i,{fs:s,cache:r,getConfig:l})=>{const t=m.startTiming(),g=(await r.load("versions-config","versions-config")).data,{markdown:u}=await l(),o=u?.partialsFolders??[],e=new Map,n=new Map,c=new Set,d={pageVsPage:0,dirVsDir:0},D=new N;n.set(".","/"),n.set("/","/");const w=s.scan().sort((a,p)=>p.relativePath.localeCompare(a.relativePath));for(const{relativePath:a}of w){if(j.has(f.posix.extname(a)))continue;const{data:p}=await r.load(a,"is-ignored");if(p||f.posix.extname(a)===".md"&&z(a,o))continue;const F=E(a).replace(new RegExp("^(@i18n|@l10n)\\/"),""),V=I(a,g);y(F,{defaultVersion:V,fileSlugs:e,dirSlugs:n,allFileSlugsList:c,githubSlugger:D,collisions:d})}return m.verboseTime(t,"Calculated slugs. Number of file paths processed: "+w.length),{fileSlugs:e,dirSlugs:n,collisions:d}};function y(i,s){const r=s.fileSlugs.get(i);if(r)return r;const l=f.posix.dirname(i),t=L(l,s)||"",{baseName:g,isIndexFile:u}=T(i),o=s.dirSlugs.has(f.posix.join(l,g));let e;if(!u&&o){const n=h(S(t,g));s.allFileSlugsList.has(n)||(e=n)}if(!e){const n=u?s.dirSlugs.get(l):void 0;if(n)e=n;else{const c=S(t,g),d=h(c);e=s.githubSlugger.slug(c),e!==d&&(s.collisions.pageVsPage++,m.verbose("File slug collision: %s wanted %s, assigned %s",i,d,e))}}e=v(e),s.fileSlugs.set(i,e),s.allFileSlugsList.add(e)}function L(i,s){if(s.dirSlugs.has(i))return s.dirSlugs.get(i);const r=v(f.posix.normalize(i)).split("/");let l="/",t="";for(const g of r){t=f.posix.join(t,g);const u=P(g,s.defaultVersion);let o=s.dirSlugs.get(t);if(!o){const e=S("/",l,u),n=h(e);o=s.githubSlugger.slug(e),o!==n&&(s.collisions.dirVsDir++,m.verbose("Directory slug collision: %s wanted %s, assigned %s",t,n,o))}o.endsWith("/")||(o=o+"/"),s.dirSlugs.set(t,o),l=o}return s.dirSlugs.get(i)}function P(i,s){if(!i.startsWith(b))return i;const r=i.substring(b.length);return r===s?"":r}export{j as IGNORED_EXTS,U as contentSlugsLoader};
1
+ import{logger as o}from"../../../tools/notifiers/logger.js";import{calculateContentSlugs as p}from"./utils/calculate-content-slugs.js";const f={pageVsPage:"File slug collision: %s wanted %s, assigned %s",dirVsDir:"Directory slug collision: %s wanted %s, assigned %s"},C=async(w,{fs:t,cache:a,getConfig:n})=>{const i=o.startTiming(),r=(await a.load("versions-config","versions-config")).data,{markdown:l}=await n(),c=l?.partialsFolders??[],e=t.scan().map(({relativePath:s})=>s),g=await p(e,{isIgnored:async s=>(await a.load(s,"is-ignored")).data,partialsFolders:c,versionsConfig:r,onCollision:({kind:s,relativePath:d,desiredSlug:m,assignedSlug:u})=>o.verbose(f[s],d,m,u)});return o.verboseTime(i,"Calculated slugs. Number of file paths processed: "+e.length),g};export{C as contentSlugsLoader};
@@ -3,7 +3,7 @@ export declare const DEFAULT_LOADERS: {
3
3
  'redocly-config': import("../../../types/fs.js").LoaderFn;
4
4
  'product-config': import("../../../types/fs.js").LoaderFn;
5
5
  'versions-config': import("../../../types/fs.js").LoaderFn;
6
- 'content-slugs': import("../../../types/fs.js").LoaderFn<import("./content-slugs-loader.js").ContentSlugs>;
6
+ 'content-slugs': import("../../../types/fs.js").LoaderFn<import("./utils/calculate-content-slugs.js").ContentSlugs>;
7
7
  'is-ignored': import("../../../types/fs.js").LoaderFn<boolean>;
8
8
  yaml: import("../../../types/fs.js").LoaderFn;
9
9
  };
@@ -1 +1 @@
1
- import{DEFAULT_SEARCH_ENGINE as p,redocConfigSchema as A,rootRedoclyConfigSchema as i}from"@redocly/config";import F from"is-glob";import{I18N_DIR_NAME as u,L10N_DIR_NAME as l}from"../../../constants/common.js";import{CONFIG_FILE_NAME as f}from"../../../../constants/common.js";import{deepMerge as C}from"../../../../utils/object/deep-merge.js";import{logger as o}from"../../../tools/notifiers/logger.js";import{EntitlementsProvider as b}from"../../../entitlements/entitlements-provider.js";import{readAndValidateConfig as h}from"./utils/read-and-validate-config.js";import{resolveExternalPlugins as y}from"../../../external-plugins/resolve-external-plugins.js";import{getPathForAllLocales as m}from"../../../fs/utils/get-path-for-all-locales.js";import{parseRbacConfig as E}from"../../../utils/rbac.js";import{RbacConfigLocation as S,validateRbacConfig as v}from"../../validate-rbac-config.js";const R=["**/_partials/**"],$=async(e,{fs:n},s)=>{const r=await h(e,n,s,async t=>e===f?L(n.cwd,t?.plugins||[]):void 0);if(r?.access?.rbac){const t=await E(r.access.rbac);r.access.rbac=t,v(t,e===f?S.RootRedoclyYaml:void 0)}(r?.l10n||r?.i18n)&&(r.l10n=w(r),r.i18n=void 0);const c=C(r||{},{markdown:{partialsFolders:(r?.markdown?.partialsFolders||R).flatMap(t=>m(t,n))}});return _({...c,configPath:e,ignore:g(r?.ignore,n)})};async function L(e,n){const s=await y(e,n),r=s.map(a=>a.config.schema?a.lifecyclePlugin.id:""),c={};for(const a of s){const d=a.lifecyclePlugin?.id;a.config.schema&&d&&i.properties&&(c[d]=a.config.schema)}return{...i,properties:{...c,...i.properties,openapi:A},$id:i.$id+r.join("")}}function _(e){const n=b.instance();if(n.canAccessFeature("apiFunctions")||(e.apiFunctions=void 0),n.canAccessFeature("products")||(e.products=void 0),n.canAccessFeature("breadcrumbs")||(e.breadcrumbs={hide:!0}),n.canAccessFeature("seo")||(e.seo={llmstxt:{hide:!0}}),n.canAccessFeature("redirects")||(e.redirects={}),n.canAccessFeature("l10n")||(e.l10n=void 0),n.canAccessFeature("rbac")||e.access&&(e.access.rbac=void 0),n.canAccessFeature("sso")||e.access&&(e.access.sso=void 0),n.canAccessFeature("ssoDirect")||(e.ssoDirect=void 0),n.canAccessFeature("catalogClassic")||(e.catalog=void 0,e.catalogClassic=void 0),n.canAccessFeature("scorecard")||(e.scorecard=void 0,e.scorecardClassic=void 0),n.canAccessFeature("scorecards")||(e.scorecards=void 0),n.canAccessFeature("devOnboarding")||(e.developerOnboarding=void 0),n.canAccessFeature("analytics")||(e.analytics=void 0),n.canAccessFeature("removeAttribution")||(e.removeAttribution=void 0),n.canAccessFeature("mockServer")||(e.mockServer={off:!0}),n.canAccessFeature("advancedSearch")||e.search&&(e.search.engine=p),n.canAccessFeature("banner")||(e.banner=void 0),e.consent){const s=n.entitlements;s&&!Object.prototype.hasOwnProperty.call(s,"cookieConsent")?o.warn("The plan gates token has no cookieConsent entry. The consent option stays on."):n.canAccessFeature("cookieConsent")||(o.error("The consent option requires the Enterprise+ plan. It is ignored, and analytics loads without consent."),e.consent=void 0)}return e}function g(e=[],n){return["static",...e].flatMap(s=>F(s)&&(s.startsWith("*")||s.startsWith(l)||s.startsWith("/"+l)||s.startsWith(u)||s.startsWith("/"+u))?s:m(s,n))}function w(e){return e.i18n&&o.warn("The `i18n` configuration is deprecated. Please use `l10n` instead."),e.l10n||e.i18n||{}}export{$ as redoclyConfigLoader};
1
+ import{DEFAULT_SEARCH_ENGINE as A,rootRedoclyConfigSchema as d}from"@redocly/config";import F from"is-glob";import{I18N_DIR_NAME as u,L10N_DIR_NAME as l}from"../../../constants/common.js";import{ROOT_CONFIG_SCHEMA as f}from"../../../constants/config-schema.js";import{CONFIG_FILE_NAME as m}from"../../../../constants/common.js";import{deepMerge as C}from"../../../../utils/object/deep-merge.js";import{logger as i}from"../../../tools/notifiers/logger.js";import{EntitlementsProvider as b}from"../../../entitlements/entitlements-provider.js";import{readAndValidateConfig as h}from"./utils/read-and-validate-config.js";import{resolveExternalPlugins as y}from"../../../external-plugins/resolve-external-plugins.js";import{getPathForAllLocales as p}from"../../../fs/utils/get-path-for-all-locales.js";import{parseRbacConfig as E}from"../../../utils/rbac.js";import{RbacConfigLocation as R,validateRbacConfig as S}from"../../validate-rbac-config.js";const _=["**/_partials/**"],$=async(e,{fs:n},s)=>{const r=await h(e,n,s,async t=>e===m?v(n.cwd,t?.plugins||[]):void 0);if(r?.access?.rbac){const t=await E(r.access.rbac);r.access.rbac=t,S(t,e===m?R.RootRedoclyYaml:void 0)}(r?.l10n||r?.i18n)&&(r.l10n=w(r),r.i18n=void 0);const c=C(r||{},{markdown:{partialsFolders:(r?.markdown?.partialsFolders||_).flatMap(t=>p(t,n))}});return I({...c,configPath:e,ignore:L(r?.ignore,n)})};async function v(e,n){const s=await y(e,n),r=s.map(a=>a.config.schema?a.lifecyclePlugin.id:""),c={};for(const a of s){const o=a.lifecyclePlugin?.id;a.config.schema&&o&&d.properties&&(c[o]=a.config.schema)}return{...f,properties:{...c,...f.properties},$id:d.$id+r.join("")}}function I(e){const n=b.instance();if(n.canAccessFeature("apiFunctions")||(e.apiFunctions=void 0),n.canAccessFeature("products")||(e.products=void 0),n.canAccessFeature("breadcrumbs")||(e.breadcrumbs={hide:!0}),n.canAccessFeature("seo")||(e.seo={llmstxt:{hide:!0}}),n.canAccessFeature("redirects")||(e.redirects={}),n.canAccessFeature("l10n")||(e.l10n=void 0),n.canAccessFeature("rbac")||e.access&&(e.access.rbac=void 0),n.canAccessFeature("sso")||e.access&&(e.access.sso=void 0),n.canAccessFeature("ssoDirect")||(e.ssoDirect=void 0),n.canAccessFeature("catalogClassic")||(e.catalog=void 0,e.catalogClassic=void 0),n.canAccessFeature("scorecard")||(e.scorecard=void 0,e.scorecardClassic=void 0),n.canAccessFeature("scorecards")||(e.scorecards=void 0),n.canAccessFeature("devOnboarding")||(e.developerOnboarding=void 0),n.canAccessFeature("analytics")||(e.analytics=void 0),n.canAccessFeature("removeAttribution")||(e.removeAttribution=void 0),n.canAccessFeature("mockServer")||(e.mockServer={off:!0}),n.canAccessFeature("advancedSearch")||e.search&&(e.search.engine=A),n.canAccessFeature("banner")||(e.banner=void 0),e.consent){const s=n.entitlements;s&&!Object.prototype.hasOwnProperty.call(s,"cookieConsent")?i.warn("The plan gates token has no cookieConsent entry. The consent option stays on."):n.canAccessFeature("cookieConsent")||(i.error("The consent option requires the Enterprise+ plan. It is ignored, and analytics loads without consent."),e.consent=void 0)}return e}function L(e=[],n){return["static",...e].flatMap(s=>F(s)&&(s.startsWith("*")||s.startsWith(l)||s.startsWith("/"+l)||s.startsWith(u)||s.startsWith("/"+u))?s:p(s,n))}function w(e){return e.i18n&&i.warn("The `i18n` configuration is deprecated. Please use `l10n` instead."),e.l10n||e.i18n||{}}export{$ as redoclyConfigLoader};
@@ -0,0 +1,32 @@
1
+ import type { VersionedFolderConfig } from '@redocly/config';
2
+ export type SlugCollisions = {
3
+ pageVsPage: number;
4
+ dirVsDir: number;
5
+ };
6
+ export type ContentSlugs = {
7
+ fileSlugs: Map<string, string>;
8
+ dirSlugs: Map<string, string>;
9
+ collisions: SlugCollisions;
10
+ };
11
+ export type SlugCollision = {
12
+ kind: keyof SlugCollisions;
13
+ relativePath: string;
14
+ desiredSlug: string;
15
+ assignedSlug: string;
16
+ };
17
+ export type ContentSlugsOptions = {
18
+ isIgnored: (relativePath: string) => boolean | Promise<boolean>;
19
+ partialsFolders: string[];
20
+ versionsConfig: Map<string, VersionedFolderConfig>;
21
+ onCollision?: (collision: SlugCollision) => void;
22
+ };
23
+ export declare const IGNORED_EXTS: Set<string>;
24
+ /**
25
+ * Assigns a route slug to each content file and folder. A file with an `IGNORED_EXTS` extension,
26
+ * an ignored file and a Markdown partial get none; a slug already held gets a numbered suffix.
27
+ *
28
+ * @param relativePaths - Paths relative to the content root, in any order; not modified.
29
+ * @returns The slug of each file and folder, and how many slugs got a numbered suffix.
30
+ */
31
+ export declare function calculateContentSlugs(relativePaths: readonly string[], { isIgnored, partialsFolders, versionsConfig, onCollision }: ContentSlugsOptions): Promise<ContentSlugs>;
32
+ //# sourceMappingURL=calculate-content-slugs.d.ts.map
@@ -0,0 +1 @@
1
+ import f from"path";import{combineUrls as m}from"@redocly/theme/core/utils/urls";import{VERSION_SEPARATOR as c}from"../../../../constants/versions.js";import{removeTrailingSlash as h}from"../../../../../utils/url/remove-trailing-slash.js";import{slash as w}from"../../../../../utils/path/slash.js";import{parsePathVersions as b}from"../../../../../utils/path/parse-path-versions.js";import{GithubSlugger as D,slug as p}from"../../../../../utils/slugger.js";import{parseBaseName as P}from"../../../../utils/content/parse-base-name.js";import{isPartial as E}from"../../../markdown/is-partial.js";const F=new Set([".jpg",".jpeg",".png",".gif",".webp",".svg",".ico",".avif",".mp3",".wav",".ogg",".m4a",".mp4",".avi",".mov",".webm",".pdf",".doc",".docx",".zip",".rar",".gz",".ttf",".woff",".woff2"]);async function A(e,{isIgnored:i,partialsFolders:o,versionsConfig:a,onCollision:l}){const g=new Map,u=new Map,n=new Set,s={pageVsPage:0,dirVsDir:0},t=new D;u.set(".","/"),u.set("/","/");const d=[...e].sort((r,S)=>S.localeCompare(r));for(const r of d){if(F.has(f.posix.extname(r))||await i(r)||f.posix.extname(r)===".md"&&E(r,o))continue;const S=w(r).replace(new RegExp("^(@i18n|@l10n)\\/"),""),V=z(r,a);I(S,{defaultVersion:V,fileSlugs:g,dirSlugs:u,allFileSlugsList:n,githubSlugger:t,collisions:s,onCollision:l})}return{fileSlugs:g,dirSlugs:u,collisions:s}}function z(e,i){const o=b(e);return o==null?null:i.get(o.versionFolderPath)?.defaultVersion}function I(e,i){const o=i.fileSlugs.get(e);if(o)return o;const a=f.posix.dirname(e),l=N(a,i)||"",{baseName:g,isIndexFile:u}=P(e),n=i.dirSlugs.has(f.posix.join(a,g));let s;if(!u&&n){const t=p(m(l,g));i.allFileSlugsList.has(t)||(s=t)}if(!s){const t=u?i.dirSlugs.get(a):void 0;if(t)s=t;else{const d=m(l,g),r=p(d);s=i.githubSlugger.slug(d),s!==r&&(i.collisions.pageVsPage++,i.onCollision?.({kind:"pageVsPage",relativePath:e,desiredSlug:r,assignedSlug:s}))}}s=h(s),i.fileSlugs.set(e,s),i.allFileSlugsList.add(s)}function N(e,i){if(i.dirSlugs.has(e))return i.dirSlugs.get(e);const o=h(f.posix.normalize(e)).split("/");let a="/",l="";for(const g of o){l=f.posix.join(l,g);const u=j(g,i.defaultVersion);let n=i.dirSlugs.get(l);if(!n){const s=m("/",a,u),t=p(s);n=i.githubSlugger.slug(s),n!==t&&(i.collisions.dirVsDir++,i.onCollision?.({kind:"dirVsDir",relativePath:l,desiredSlug:t,assignedSlug:n}))}n.endsWith("/")||(n=n+"/"),i.dirSlugs.set(l,n),a=n}return i.dirSlugs.get(e)}function j(e,i){if(!e.startsWith(c))return e;const o=e.substring(c.length);return o===i?"":o}export{F as IGNORED_EXTS,A as calculateContentSlugs};
@@ -1,5 +1,3 @@
1
- import type { VersionedFolderConfig } from '@redocly/config';
2
1
  import type { LoaderFn } from '../../../types';
3
2
  export declare const versionsConfigLoader: LoaderFn;
4
- export declare function getDefaultVersionByPath(path: string, versionsConfig: Map<string, VersionedFolderConfig>): string | null | undefined;
5
3
  //# sourceMappingURL=versions-config-loader.d.ts.map
@@ -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(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
+ import d from"path";import{I18N_DIR_NAME as v,L10N_DIR_NAME as c,RESERVED_DIR_NAMES as p}from"../../../constants/common.js";import{VERSION_SEPARATOR as V,VERSIONED_FOLDER_REGEXP_MATCH as P}from"../../../constants/versions.js";import{parsePathVersions as h}from"../../../../utils/path/parse-path-versions.js";import{compareVersions as g}from"../../../../utils/version/compare-versions.js";import{reporter as u}from"../../../tools/notifiers/reporter.js";import{logger as y}from"../../../tools/notifiers/logger.js";const S=async(i,{cache:r,fs:n})=>{const e=new Map,a=n.scan();await E(a);for(const{relativePath:s}of a){if(d.posix.basename(s)==="versions.yaml"){await F(s,e,r);continue}const o=h(s);if(o==null||p.includes(V+o.versionName))continue;const t=e.get(o.versionFolderPath)||{versionedFiles:new Map,versions:[]},l=t.versionedFiles.get(o.filePathInVersion)||new Set,f={version:o.versionName};l.add(f.version),!t.hasVersionsConfig&&t.versions.findIndex(m=>m.version===o.versionName)===-1&&t.versions.push(f),t.versionedFiles.set(o.filePathInVersion,l),e.set(o.versionFolderPath,t)}return I(e)};async function F(i,r,n){let e=d.posix.dirname(i);e==="."?e="/":e=e.endsWith("/")?e:e+"/",e.startsWith(v+"/")&&(e=e.slice(v.length+1)),e.startsWith(c+"/")&&(e=e.slice(c.length+1));const s=(await n.load(i,"yaml")).data;s.versions&&!Array.isArray(s.versions)?(await u.panicOnBuild(`Property 'versions' must be an array at %rp. Got '${typeof s.versions}'.`,i),s.versions=[]):(!s.versions||s.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=s.versions||[],s.default&&(o.defaultVersion=s.default),r.set(e,o)}async function E(i){const r=new Set;for(const{relativePath:n}of i){const e=h(n);if(!(e?.versionFolderPath&&p.includes(e?.versionFolderPath))){if(e?.versionFolderPath==null){(n.match(P)?.length||0)>1&&await u.panicOnBuild(`Nested versions are not supported. Detected nested versions in path: "${n}".`);continue}r.has(e.versionFolderPath)||r.add(e.versionFolderPath)}}}function I(i){for(const[r,n]of i){const e=n.hasVersionsConfig?n.versions:n.versions.sort((o,t)=>g(t.version,o.version)),a=n.hasVersionsConfig?e[e.length-1]:e[0],s=n.defaultVersion||a?.version;i.set(r,{...n,versions:e,defaultVersion:s})}return i}export{S as versionsConfigLoader};
@@ -1,4 +1,4 @@
1
- import type { ContentSlugs } from './config-parser/loaders/content-slugs-loader.js';
1
+ import type { ContentSlugs } from './config-parser/loaders/utils/calculate-content-slugs.js';
2
2
  /**
3
3
  * Creates the canonical fsPath -> route slug function backed by the
4
4
  * precalculated `content-slugs` cache. The cache is the single place where
@@ -1 +1 @@
1
- import s from"path";import{combineUrls as n}from"@redocly/theme/core/utils";import{removeTrailingSlash as a}from"../../utils/url/remove-trailing-slash.js";import{slash as p}from"../../utils/path/slash.js";import{slug as f}from"../utils/index.js";import{parseBaseName as u}from"./utils.js";function b(i){return function(r){const o=p(r).replace(new RegExp("^(@i18n|@l10n)\\/"),""),l=i?.fileSlugs.get(o)||i?.dirSlugs.get(a(o));if(l)return l;const{baseName:t,isIndexFile:m}=u(r);let e=s.dirname(r.replace(new RegExp("^(@i18n|@l10n)\\/"),""));return e=e==="."?"/":e,n("/",f(m?e:n(e,t)),"/")}}export{b as createSlugify};
1
+ import s from"path";import{combineUrls as n}from"@redocly/theme/core/utils";import{removeTrailingSlash as a}from"../../utils/url/remove-trailing-slash.js";import{slash as p}from"../../utils/path/slash.js";import{slug as f}from"../utils/index.js";import{parseBaseName as u}from"../utils/content/parse-base-name.js";function b(i){return function(r){const o=p(r).replace(new RegExp("^(@i18n|@l10n)\\/"),""),l=i?.fileSlugs.get(o)||i?.dirSlugs.get(a(o));if(l)return l;const{baseName:t,isIndexFile:m}=u(r);let e=s.dirname(r.replace(new RegExp("^(@i18n|@l10n)\\/"),""));return e=e==="."?"/":e,n("/",f(m?e:n(e,t)),"/")}}export{b as createSlugify};
@@ -5,6 +5,7 @@ export declare const resolveProductsConfig: (productsConfig: Record<string, Prod
5
5
  folder: string;
6
6
  icon?: string | undefined;
7
7
  name: string;
8
+ nameTranslationKey?: string | undefined;
8
9
  };
9
10
  } & {
10
11
  [key: string]: import("@redocly/config").ProductUiConfig;
@@ -1 +1 @@
1
- import a from"path";import{productConfigOverrideSchema as R,REDOCLY_TEAMS_RBAC as w,REDOCLY_ROUTE_RBAC as O}from"@redocly/config";import{CONFIG_FILE_NAME as b}from"../../../constants/common.js";import{findDeepFirst as A}from"../../../utils/tree/find-deep-first.js";import{removeTrailingSlash as B}from"../../../utils/url/remove-trailing-slash.js";import{addTrailingSlash as D}from"../../../utils/url/add-trailing-slash.js";import{reporter as k}from"../../tools/notifiers/reporter.js";import{logger as F}from"../../tools/notifiers/logger.js";import{FileNotFoundError as E,resolveAssetPath as I}from"../../utils/index.js";import{safeParsePartial as _}from"../config-parser/safe-parse.js";import{resolveLinksFromConfig as v,resolveItems as S}from"../nav-utils.js";import{resolveLogoConfig as j}from"./resolve-logo.js";import{pickUiAccessibleConfig as z}from"./index.js";import{getExcludedFromLinkCheckerPatterns as N}from"../sidebars/utils.js";const re=async(o,e,r)=>{if(!o)return;const s={};for(const t of Object.keys(o)){let d;const m=o[t].icon;if(m)try{d=await I(m,r.fs,{fromFileRelativePath:b,contentDir:e.contentDir,outdir:e.outdir})}catch(L){L instanceof E?await k.panicOnBuildContentError(`Could not resolve icon for product "${t}": file ${m} does not exist`):await k.panicOnBuild(`Could not resolve icon for product "${t}": ${L.message}`)}const{name:C,folder:n}=o[t],l=a.posix.join(n,"redocly.yaml"),f=r.fs.exists(l)?await r.cache.load(l,"product-config"):void 0,c=f?.data&&_(R,f.data),p=await T(n,r,e);if(!p){await k.panicOnBuild(`Could not resolve first link for product "${t}"`);continue}const u=e.getRouteBySlug(p),g=a.join(e.contentDir,n),i=c&&z(c),P=Object.keys(i?.logo||{}).length>0?await j(i?.logo,l,e.outdir,r.fs):void 0,h=N(e.getConfig()),y={navFile:l,excludedFromLinkCheckerPatterns:h};s[t]={name:C,folder:n,icon:d,slug:r.slugify(a.normalize(n)),link:p,configOverride:i&&{logo:Object.keys(P||{}).length>0?P:void 0,navbar:await v(i.navbar,g,e,r,y),footer:await v(i.footer,g,e,r,y),feedback:i.feedback,sidebar:i.sidebar,search:i.search&&{...i.search,suggestedPages:await v(i.search?.suggestedPages,g,e,r,{navFile:b,excludedFromLinkCheckerPatterns:h})},codeSnippet:i.codeSnippet,breadcrumbs:i.breadcrumbs&&{...i.breadcrumbs,prefixItems:await v(i.breadcrumbs?.prefixItems||[],g,e,r,{navFile:b,excludedFromLinkCheckerPatterns:h})},palette:i.palette,analytics:i.analytics,mockServer:i.mockServer},[w]:u?.[w],[O]:u?.[O]},F.verbose(`Resolved config for product "${t}"`)}return s};async function T(o,e,r){const s=D(a.posix.normalize(o)),t=B(e.slugify(a.normalize(o))),d=r.getRouteBySlug(t);if(d&&d.fsPath.startsWith(s))return d.slug;const m=e.fs.scan(/sidebars\.yaml$/).filter(c=>c.relativePath.startsWith(s)),n=W(m)[0]?.relativePath;if(n){const c=await e.cache.load(n,"yaml"),p=await S(c.data,a.dirname(n),r,e,{navFile:n}),u=$(p);if(u)return F.verbose(`Found product first link "${u}" in sidebar "${n}"`),u}const l=await S([{directory:`${s}`}],a.dirname("sidebars.yaml"),r,e,{navFile:"sidebars.yaml"}),f=$(l);return f&&F.verbose(`Found product first link "${f}" in product folder "${s}"`),f}function $(o){return(o?A(o,r=>!!r.link):void 0)?.link}function W(o){return o.sort((e,r)=>{const s=e.relativePath.split("/").length,t=r.relativePath.split("/").length;return s!==t?s-t:e.relativePath.localeCompare(r.relativePath,void 0,{numeric:!0})})}export{T as getProductFirstLink,re as resolveProductsConfig};
1
+ import f from"path";import{productConfigOverrideSchema as A,REDOCLY_TEAMS_RBAC as O,REDOCLY_ROUTE_RBAC as S}from"@redocly/config";import{CONFIG_FILE_NAME as b}from"../../../constants/common.js";import{findDeepFirst as B}from"../../../utils/tree/find-deep-first.js";import{removeTrailingSlash as D}from"../../../utils/url/remove-trailing-slash.js";import{addTrailingSlash as E}from"../../../utils/url/add-trailing-slash.js";import{reporter as k}from"../../tools/notifiers/reporter.js";import{logger as F}from"../../tools/notifiers/logger.js";import{FileNotFoundError as I,resolveAssetPath as _}from"../../utils/index.js";import{safeParsePartial as j}from"../config-parser/safe-parse.js";import{resolveLinksFromConfig as v,resolveItems as $}from"../nav-utils.js";import{resolveLogoConfig as T}from"./resolve-logo.js";import{pickUiAccessibleConfig as z}from"./index.js";import{getExcludedFromLinkCheckerPatterns as N}from"../sidebars/utils.js";const ie=async(o,e,r)=>{if(!o)return;const n={};for(const t of Object.keys(o)){let c;const m=o[t].icon;if(m)try{c=await _(m,r.fs,{fromFileRelativePath:b,contentDir:e.contentDir,outdir:e.outdir})}catch(w){w instanceof I?await k.panicOnBuildContentError(`Could not resolve icon for product "${t}": file ${m} does not exist`):await k.panicOnBuild(`Could not resolve icon for product "${t}": ${w.message}`)}const{name:C,nameTranslationKey:a,folder:d}=o[t],s=f.posix.join(d,"redocly.yaml"),u=r.fs.exists(s)?await r.cache.load(s,"product-config"):void 0,p=u?.data&&j(A,u.data),l=await W(d,r,e);if(!l){await k.panicOnBuild(`Could not resolve first link for product "${t}"`);continue}const P=e.getRouteBySlug(l),g=f.join(e.contentDir,d),i=p&&z(p),y=Object.keys(i?.logo||{}).length>0?await T(i?.logo,s,e.outdir,r.fs):void 0,h=N(e.getConfig()),L={navFile:s,excludedFromLinkCheckerPatterns:h};n[t]={name:C,nameTranslationKey:a,folder:d,icon:c,slug:r.slugify(f.normalize(d)),link:l,configOverride:i&&{logo:Object.keys(y||{}).length>0?y:void 0,navbar:await v(i.navbar,g,e,r,L),footer:await v(i.footer,g,e,r,L),feedback:i.feedback,sidebar:i.sidebar,search:i.search&&{...i.search,suggestedPages:await v(i.search?.suggestedPages,g,e,r,{navFile:b,excludedFromLinkCheckerPatterns:h})},codeSnippet:i.codeSnippet,breadcrumbs:i.breadcrumbs&&{...i.breadcrumbs,prefixItems:await v(i.breadcrumbs?.prefixItems||[],g,e,r,{navFile:b,excludedFromLinkCheckerPatterns:h})},palette:i.palette,analytics:i.analytics,mockServer:i.mockServer},[O]:P?.[O],[S]:P?.[S]},F.verbose(`Resolved config for product "${t}"`)}return n};async function W(o,e,r){const n=E(f.posix.normalize(o)),t=D(e.slugify(f.normalize(o))),c=r.getRouteBySlug(t);if(c&&c.fsPath.startsWith(n))return c.slug;const m=e.fs.scan(/sidebars\.yaml$/).filter(u=>u.relativePath.startsWith(n)),a=U(m)[0]?.relativePath;if(a){const u=await e.cache.load(a,"yaml"),p=await $(u.data,f.dirname(a),r,e,{navFile:a}),l=R(p);if(l)return F.verbose(`Found product first link "${l}" in sidebar "${a}"`),l}const d=await $([{directory:`${n}`}],f.dirname("sidebars.yaml"),r,e,{navFile:"sidebars.yaml"}),s=R(d);return s&&F.verbose(`Found product first link "${s}" in product folder "${n}"`),s}function R(o){return(o?B(o,r=>!!r.link):void 0)?.link}function U(o){return o.sort((e,r)=>{const n=e.relativePath.split("/").length,t=r.relativePath.split("/").length;return n!==t?n-t:e.relativePath.localeCompare(r.relativePath,void 0,{numeric:!0})})}export{W as getProductFirstLink,ie as resolveProductsConfig};
@@ -1 +1 @@
1
- import{MCP_ROUTE as i,PUBLIC_MCP_ROUTE as r}from"@redocly/theme/core/constants/mcp";import{EntitlementsProvider as m}from"../entitlements/entitlements-provider.js";import{getPublicMcpEndpointStatus as p}from"./mcp/utils/public-endpoint.js";const t={mcp:i,mcpPublic:r};function s(){return!!m.instance().canAccessFeature("mcp")}const E=[{slug:t.mcp,isEnabled:e=>!e?.mcp?.hide&&!e?.mcp?.docs?.hide&&s()},{slug:t.mcpPublic,isEnabled:e=>s()&&p(e)==="served"}];function l(e,n,o=[]){return[...E,...o].some(c=>c.slug===e&&c.isEnabled(n))}export{t as RESERVED_ROUTES,l as isRouteReserved};
1
+ import{MCP_ROUTE as t,PUBLIC_MCP_ROUTE as r}from"@redocly/theme/core/constants/mcp";import{EntitlementsProvider as E}from"../entitlements/entitlements-provider.js";import{isMcpRouteServedByConfig as m,isPublicMcpRouteServedByConfig as p}from"./mcp/utils/route-reservation.js";const o={mcp:t,mcpPublic:r};function n(){return!!E.instance().canAccessFeature("mcp")}const u=[{slug:o.mcp,isEnabled:e=>m(e)&&n()},{slug:o.mcpPublic,isEnabled:e=>n()&&p(e)}];function d(e,i,s=[]){return[...u,...s].some(c=>c.slug===e&&c.isEnabled(i))}export{o as RESERVED_ROUTES,d as isRouteReserved};
@@ -1,2 +1,2 @@
1
- import B from"@redocly/portal-plugin-mock-server";import{REDOCLY_ROUTE_RBAC as x}from"@redocly/config";import{combineUrls as E,withPathPrefix as L}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as k}from"../constants/common.js";import{removeTrailingSlash as N}from"../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as j}from"../../utils/url/remove-leading-slash.js";import{isTruthy as $}from"../../utils/guards/is-truthy.js";import{normalizeRouteSlug as D}from"../../utils/path/normalize-route-slug.js";import{parsePathVersions as V}from"../../utils/path/parse-path-versions.js";import{reporter as v}from"../tools/notifiers/reporter.js";import{logger as P}from"../tools/notifiers/logger.js";import{envConfig as S}from"../config/env-config.js";import{shaDirPathShort as M}from"../utils/crypto/sha-dir-path-short.js";import{writeServerRebuildTrigger as _,generateBrowserPluginsModule as q,generateClientRoutes as z,generateTemplatesModule as H}from"../esbuild/generate.js";import{customPagesPlugin as U}from"../../server/plugins/pages/index.js";import{apiDocsPlugin as G}from"../../server/plugins/api-docs/index.js";import{configParserPlugin as I}from"./config-parser/index.js";import{createSlugify as W}from"./create-slugify.js";import{markdownPlugin as K}from"./markdown/index.js";import{searchPlugin as Y}from"./search/index.js";import{skillsPlugin as J}from"./skills/index.js";import{defaultThemePlugin as Q}from"./default-theme/index.js";import{apiKeyMgmtPlugin as X}from"./dev-onboarding/index.js";import{apiFunctionsPlugin as Z}from"./api-functions/index.js";import{scorecardClassicPlugin as ee}from"./scorecard-classic/index.js";import{lintPlugin as te}from"./lint/index.js";import{resolveExternalPlugins as oe}from"../external-plugins/resolve-external-plugins.js";import{sidebarsPlugin as ie}from"./sidebars/index.js";import{l10nPlugin as re}from"./l10n/index.js";import{validateRedirects as ne}from"../utils/redirects/validate-redirects.js";import{analyticsPlugins as se}from"./analytics/index.js";import{consentPlugin as ae}from"./consent/index.js";import{sitemapPlugin as le}from"./sitemap/index.js";import{entitlementsPlugin as ce}from"./entitlements/index.js";import{getBilledPagesCount as ue}from"../utils/index.js";import{telemetry as fe}from"../../cli/telemetry/index.js";import{telemetryTraceStep as b}from"../../cli/telemetry/helpers/trace-step.js";import{EntitlementsProvider as A}from"../entitlements/entitlements-provider.js";import{enforceLoginPlugin as me}from"./enforce-login/index.js";import{ssoPlugin as de}from"./sso/index.js";import{Cache as ge}from"../fs/cache.js";import{ContentFs as pe}from"../fs/content-fs.js";import{findProductBySlug as Pe}from"../utils/product.js";import{isRouteReserved as ye}from"./get-reserved-routes.js";import{catalogClassicPlugin as he}from"./catalog-classic/index.js";import{arazzoDocsPlugin as Re}from"./arazzo-docs/index.js";const Ce=[I,me,de,Q,re,K,G,Re,ee,te,Z,U,X,he,{importPath:"./catalog-entities/plugin.js",loadCondition:()=>S.NEW_CATALOG_ENABLED??!1},{importPath:"./scorecards/plugin.js",loadCondition:()=>S.NEW_SCORECARDS_ENABLED??!1},{importPath:"./mcp/index.js",loadCondition:()=>A.instance().canAccessFeature("mcp")},ie,le,ce,Y,J,B,ae,...se];async function Pt(t,e=Ce){return await b("com.redocly.build.pluginsInit",async()=>{const r=[],R=A.instance(),y={};for(const s of e){let u;if("loadCondition"in s){if(!s.loadCondition())continue;const i=await import(s.importPath);if(!i.default||typeof i.default!="function"){await v.panicOnBuild(`Dynamic plugin ${s.importPath} does not export a default export or it is not a function`);continue}u=i.default}else u=s;const h=await u(t);for(const[i,f]of Object.entries(h.loaders||{}))y[i]&&await v.panicOnBuild(`Duplicate loader with name ${i}`),y[i]=f;(!h.requiredEntitlements||h.requiredEntitlements?.every(i=>R.canAccessFeature(i)))&&r.push(h)}const l=new pe(t.contentDir);await l.ready;const c=new ge(l);return c.setLoaders(y),P.verbose("All plugins instantiated"),{pluginInstances:r,lifecycleContext:be(l,c)}})}function O(t){P.verbose("Generating templates"),b("com.redocly.build.writeClientEntries",()=>{H(t),q(t),z(t)})}async function ve(t){const e=t.getAllRoutes();ue(e)||await v.panicOnBuild("No routes created by plugins. Please check your project configuration.")}async function yt(t,e,r,R={}){const y=A.instance();try{await b("com.redocly.build.pluginsRun",async()=>{e.startPluginsRun();const l=S.isDevelopMode&&e.buildRevision>0,c=l?F(e):"";let s=[];await b("com.redocly.build.pluginsProcessContent",async i=>{for(const o of t){const a=P.startTiming();await o.processContent?.(e,r),P.verboseTime(a,`processContent for ${o.id}`)}s=(await oe(e.contentDir,e.config.plugins)).map(o=>o.lifecyclePlugin).filter(o=>$(o)&&(!o.requiredEntitlements||o.requiredEntitlements?.every(a=>y.canAccessFeature(a)))),r.cache.setLoaders(Object.fromEntries(s.flatMap(o=>Object.entries(o.loaders||{}))));for(const o of s){const a=P.startTiming();await o.processContent?.(e,r),P.verboseTime(a,`processContent for ${o.id}`)}i?.setAttribute("externalPluginsProcessed",s.length.toString())});const u=await we(e,r),h=[...t,...s];O(e),S.isDevelopMode?await e.userCodeReady:e.buildRevision++,await b("com.redocly.build.pluginsAfterRoutesCreated",async()=>{for(const i of h){const f=P.startTiming();await i.afterRoutesCreated?.(e,u),P.verboseTime(f,`afterRoutesCreated for ${i.id}`)}}),ne(e),await e.reportUnsetEnvVars(),await ve(e),O(e),l&&c!==F(e)&&(e.markRequestHandlersEntryOutdated(),_(e.serverOutDir))})}catch(l){const c="Unhandled error in plugin. "+l.message+`
1
+ import B from"@redocly/portal-plugin-mock-server";import{REDOCLY_ROUTE_RBAC as x}from"@redocly/config";import{combineUrls as E,withPathPrefix as L}from"@redocly/theme/core/utils";import{VERSION_SEPARATOR as k}from"../constants/versions.js";import{removeTrailingSlash as N}from"../../utils/url/remove-trailing-slash.js";import{removeLeadingSlash as j}from"../../utils/url/remove-leading-slash.js";import{isTruthy as $}from"../../utils/guards/is-truthy.js";import{normalizeRouteSlug as D}from"../../utils/path/normalize-route-slug.js";import{parsePathVersions as V}from"../../utils/path/parse-path-versions.js";import{reporter as v}from"../tools/notifiers/reporter.js";import{logger as P}from"../tools/notifiers/logger.js";import{envConfig as S}from"../config/env-config.js";import{shaDirPathShort as M}from"../utils/crypto/sha-dir-path-short.js";import{writeServerRebuildTrigger as _,generateBrowserPluginsModule as q,generateClientRoutes as z,generateTemplatesModule as H}from"../esbuild/generate.js";import{customPagesPlugin as U}from"../../server/plugins/pages/index.js";import{apiDocsPlugin as G}from"../../server/plugins/api-docs/index.js";import{configParserPlugin as I}from"./config-parser/index.js";import{createSlugify as W}from"./create-slugify.js";import{markdownPlugin as K}from"./markdown/index.js";import{searchPlugin as Y}from"./search/index.js";import{skillsPlugin as J}from"./skills/index.js";import{defaultThemePlugin as Q}from"./default-theme/index.js";import{apiKeyMgmtPlugin as X}from"./dev-onboarding/index.js";import{apiFunctionsPlugin as Z}from"./api-functions/index.js";import{scorecardClassicPlugin as ee}from"./scorecard-classic/index.js";import{lintPlugin as te}from"./lint/index.js";import{resolveExternalPlugins as oe}from"../external-plugins/resolve-external-plugins.js";import{sidebarsPlugin as ie}from"./sidebars/index.js";import{l10nPlugin as re}from"./l10n/index.js";import{validateRedirects as ne}from"../utils/redirects/validate-redirects.js";import{analyticsPlugins as se}from"./analytics/index.js";import{consentPlugin as ae}from"./consent/index.js";import{sitemapPlugin as le}from"./sitemap/index.js";import{entitlementsPlugin as ce}from"./entitlements/index.js";import{getBilledPagesCount as ue}from"../utils/index.js";import{telemetry as fe}from"../../cli/telemetry/index.js";import{telemetryTraceStep as b}from"../../cli/telemetry/helpers/trace-step.js";import{EntitlementsProvider as A}from"../entitlements/entitlements-provider.js";import{enforceLoginPlugin as me}from"./enforce-login/index.js";import{ssoPlugin as de}from"./sso/index.js";import{Cache as ge}from"../fs/cache.js";import{ContentFs as pe}from"../fs/content-fs.js";import{findProductBySlug as Pe}from"../utils/product.js";import{isRouteReserved as ye}from"./get-reserved-routes.js";import{catalogClassicPlugin as he}from"./catalog-classic/index.js";import{arazzoDocsPlugin as Re}from"./arazzo-docs/index.js";const Ce=[I,me,de,Q,re,K,G,Re,ee,te,Z,U,X,he,{importPath:"./catalog-entities/plugin.js",loadCondition:()=>S.NEW_CATALOG_ENABLED??!1},{importPath:"./scorecards/plugin.js",loadCondition:()=>S.NEW_SCORECARDS_ENABLED??!1},{importPath:"./mcp/index.js",loadCondition:()=>A.instance().canAccessFeature("mcp")},ie,le,ce,Y,J,B,ae,...se];async function Pt(t,e=Ce){return await b("com.redocly.build.pluginsInit",async()=>{const r=[],R=A.instance(),y={};for(const s of e){let u;if("loadCondition"in s){if(!s.loadCondition())continue;const i=await import(s.importPath);if(!i.default||typeof i.default!="function"){await v.panicOnBuild(`Dynamic plugin ${s.importPath} does not export a default export or it is not a function`);continue}u=i.default}else u=s;const h=await u(t);for(const[i,f]of Object.entries(h.loaders||{}))y[i]&&await v.panicOnBuild(`Duplicate loader with name ${i}`),y[i]=f;(!h.requiredEntitlements||h.requiredEntitlements?.every(i=>R.canAccessFeature(i)))&&r.push(h)}const l=new pe(t.contentDir);await l.ready;const c=new ge(l);return c.setLoaders(y),P.verbose("All plugins instantiated"),{pluginInstances:r,lifecycleContext:be(l,c)}})}function O(t){P.verbose("Generating templates"),b("com.redocly.build.writeClientEntries",()=>{H(t),q(t),z(t)})}async function ve(t){const e=t.getAllRoutes();ue(e)||await v.panicOnBuild("No routes created by plugins. Please check your project configuration.")}async function yt(t,e,r,R={}){const y=A.instance();try{await b("com.redocly.build.pluginsRun",async()=>{e.startPluginsRun();const l=S.isDevelopMode&&e.buildRevision>0,c=l?F(e):"";let s=[];await b("com.redocly.build.pluginsProcessContent",async i=>{for(const o of t){const a=P.startTiming();await o.processContent?.(e,r),P.verboseTime(a,`processContent for ${o.id}`)}s=(await oe(e.contentDir,e.config.plugins)).map(o=>o.lifecyclePlugin).filter(o=>$(o)&&(!o.requiredEntitlements||o.requiredEntitlements?.every(a=>y.canAccessFeature(a)))),r.cache.setLoaders(Object.fromEntries(s.flatMap(o=>Object.entries(o.loaders||{}))));for(const o of s){const a=P.startTiming();await o.processContent?.(e,r),P.verboseTime(a,`processContent for ${o.id}`)}i?.setAttribute("externalPluginsProcessed",s.length.toString())});const u=await we(e,r),h=[...t,...s];O(e),S.isDevelopMode?await e.userCodeReady:e.buildRevision++,await b("com.redocly.build.pluginsAfterRoutesCreated",async()=>{for(const i of h){const f=P.startTiming();await i.afterRoutesCreated?.(e,u),P.verboseTime(f,`afterRoutesCreated for ${i.id}`)}}),ne(e),await e.reportUnsetEnvVars(),await ve(e),O(e),l&&c!==F(e)&&(e.markRequestHandlersEntryOutdated(),_(e.serverOutDir))})}catch(l){const c="Unhandled error in plugin. "+l.message+`
2
2
  `+l.stack;fe.sendCliErrorCaughtMessage([{id:"cli",object:"error",uri:"urn:redocly:realm:cli:error:cli",message:c}]),R.failFast?await v.panic(c):await v.panicOnBuild(c)}finally{e.finishPluginsRun()}}async function we(t,e){const{cache:r,fs:R}=e,y=await e.getConfig(),l=Object.values(y.products||{}),c=(await r.load("versions-config","versions-config")).data,s=(await r.load("content-slugs","content-slugs")).data,u=W(s);for(const{duplicateInAllLocales:i,slugSuffix:f,sharedData:o=[],redirectFrom:a=[],...d}of t.newRoutes){const w=D(d.slug?d.slug:u(d.fsPath)),g=N(f?E(w,f):w),n={...d,[x]:{slug:g,fsPath:d.fsPath},slug:g,baseSlug:w,versions:h(d.fsPath,f),product:Pe(l,g,u)};ye(g,y)&&await v.panicOnBuildContentError(`Route "${g}" is reserved and cannot be used. Please choose a different slug for "${d.fsPath}".`),t.routesByFsPath.set(n.fsPath,n.slug),t.routesBySlug.set(n.slug,n);for(const{key:p,id:m}of o)t.addRouteSharedData(n.slug,p,m);for(const p of a)t.addRedirect(p.from,{type:p.type,to:n.slug});if(i)for(const p of R.localeFolders){const m={...n,slug:"/"+p.toLowerCase()+n.slug};t.routesByFsPath.set(m.fsPath,m.slug),t.routesBySlug.set(m.slug,m);for(const{key:C,id:T}of o)t.addRouteSharedData(m.slug,C,T);for(const C of a){const T=E(R.localizationFolder,p,C.from);t.addRedirect(T,{type:C.type,to:m.slug},{trackOriginalSource:!1})}}}return t.newRoutes=[],{...e,slugify:u};function h(i,f=""){const o=V(i);if(!o?.versionName)return;const{versionFolderPath:a,filePathInVersion:d,versionName:w}=o,g=c.get(a);if(g)return g.versions.map(n=>{const p=g.defaultVersion===n.version,m=j(E(a,k+n.version,d)),C=u(m);return{version:n.version,label:n.name||n.version,link:D(E(C,f)),default:p,active:w===n.version,folderId:M(`${a}`)}})}}function be(t,e){return{fs:t,cache:e,getConfig:async(r=".")=>(await e.load(r,"nearest-redocly-config",t.localeFolders)).data,isPathIgnored:async r=>(await e.load(r,"is-ignored")).data,withPathPrefix:L,logger:P}}function F(t){return[...t.apiRoutesRequestHandlers.keys(),...t.getMcpTools().map(e=>`${e.name}:${e.importPath}`)].sort().join(",")}export{Ce as INTERNAL_PLUGINS,be as createLifecycleContext,Pt as initPlugins,yt as runPlugins,O as writeClientEntries};
@@ -6,4 +6,5 @@ export type OpenapiBundle = {
6
6
  rawOptions: RawApiDocsOptions;
7
7
  };
8
8
  export declare function loadOpenapiBundle(node: Node, context: LifecycleContext): Promise<OpenapiBundle | undefined>;
9
+ export declare function loadFullOpenapiBundle(node: Node, context: LifecycleContext): Promise<OpenapiBundle | undefined>;
9
10
  //# sourceMappingURL=load-openapi-bundle.d.ts.map