@redocly/redoc-reef 0.135.0-next.5 → 0.135.0-next.7

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 (126) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/dist/cli/build/analytics/collect-analytics.js +1 -1
  3. package/dist/cli/build/analytics/collectors/get-nested-configs-usage.js +1 -1
  4. package/dist/cli/develop.js +1 -1
  5. package/dist/cli/telemetry/get-portal-config-stats.js +1 -1
  6. package/dist/cli/telemetry/index.js +1 -1
  7. package/dist/client/app/Sidebar/RequestAccessButton.js +2 -2
  8. package/dist/client/app/Sidebar/Sidebar.js +3 -3
  9. package/dist/client/app/hooks/catalog/useCatalogClassic.js +1 -1
  10. package/dist/client/app/hooks/catalog/useCatalogFilter.js +1 -1
  11. package/dist/client/app/hooks/useRouteChangeTracker.js +1 -1
  12. package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.js +1 -1
  13. package/dist/client/app/markdoc/custom-components/openapi/openapi-response-sample.js +1 -1
  14. package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.js +1 -1
  15. package/dist/client/app/pages/DevLogin/DevLogin.js +1 -1
  16. package/dist/client/app/search/useSearch.js +1 -1
  17. package/dist/client/templates/openapi-docs/helpers.js +1 -1
  18. package/dist/constants/l10n/langs/ar.js +1 -1
  19. package/dist/constants/l10n/langs/de.js +1 -1
  20. package/dist/constants/l10n/langs/en.js +1 -1
  21. package/dist/constants/l10n/langs/es.js +1 -1
  22. package/dist/constants/l10n/langs/fr.js +1 -1
  23. package/dist/constants/l10n/langs/hi.js +1 -1
  24. package/dist/constants/l10n/langs/it.js +1 -1
  25. package/dist/constants/l10n/langs/ja.js +1 -1
  26. package/dist/constants/l10n/langs/ko.js +1 -1
  27. package/dist/constants/l10n/langs/pl.js +1 -1
  28. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  29. package/dist/constants/l10n/langs/pt.js +1 -1
  30. package/dist/constants/l10n/langs/ru.js +1 -1
  31. package/dist/constants/l10n/langs/uk.js +1 -1
  32. package/dist/constants/l10n/langs/zh.js +1 -1
  33. package/dist/markdoc/helpers/get-operation/get-operation.js +1 -0
  34. package/dist/markdoc/helpers/get-operation/index.d.ts +4 -0
  35. package/dist/markdoc/helpers/get-operation/index.js +1 -0
  36. package/dist/markdoc/helpers/get-resolved-sample-code-block.d.ts +3 -0
  37. package/dist/markdoc/helpers/get-resolved-sample-code-block.js +5 -0
  38. package/dist/markdoc/tags/openapi-code-sample.js +1 -1
  39. package/dist/markdoc/tags/openapi-response-sample.js +1 -1
  40. package/dist/server/api-routes/execute-api-route.js +1 -1
  41. package/dist/server/api-routes/import-api-routes-handlers.js +1 -1
  42. package/dist/server/constants/common.d.ts +2 -2
  43. package/dist/server/constants/common.js +1 -1
  44. package/dist/server/constants/plugins/openapi-docs.d.ts +0 -1
  45. package/dist/server/constants/plugins/openapi-docs.js +1 -1
  46. package/dist/server/esbuild/plugins/api-request-handlers-resolver.js +1 -1
  47. package/dist/server/esbuild/plugins/on-rebuild.d.ts +4 -4
  48. package/dist/server/plugins/api-functions/index.js +1 -1
  49. package/dist/server/plugins/catalog-classic/index.d.ts +0 -1
  50. package/dist/server/plugins/catalog-classic/index.js +1 -1
  51. package/dist/server/plugins/config-parser/loaders/redocly-config-loader.js +1 -1
  52. package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
  53. package/dist/server/plugins/lifecycle.js +2 -2
  54. package/dist/server/plugins/markdown/attribute-resolvers/helpers/get-media-content-samples.d.ts +4 -0
  55. package/dist/server/plugins/markdown/attribute-resolvers/helpers/get-media-content-samples.js +1 -0
  56. package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.d.ts +7 -0
  57. package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.js +1 -0
  58. package/dist/server/plugins/markdown/attribute-resolvers/index.js +1 -1
  59. package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.d.ts +4 -0
  60. package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.js +1 -0
  61. package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-response-samples.d.ts +4 -0
  62. package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-response-samples.js +1 -0
  63. package/dist/server/plugins/markdown/attribute-resolvers/utils.d.ts +2 -0
  64. package/dist/server/plugins/markdown/attribute-resolvers/utils.js +1 -1
  65. package/dist/server/plugins/markdown/compiler.js +1 -1
  66. package/dist/server/plugins/markdown/index.js +1 -1
  67. package/dist/server/plugins/markdown/markdoc/partials.js +1 -1
  68. package/dist/server/plugins/markdown/search/get-ai-search-documents.js +1 -1
  69. package/dist/server/plugins/markdown/search/search-resolver.js +1 -1
  70. package/dist/server/plugins/markdown/search/walk-sections.js +3 -1
  71. package/dist/server/plugins/mcp/constants.d.ts +1 -0
  72. package/dist/server/plugins/mcp/constants.js +1 -1
  73. package/dist/server/plugins/mcp/docs-mcp/codemode/build-tool-type-declarations.d.ts +4 -0
  74. package/dist/server/plugins/mcp/docs-mcp/codemode/build-tool-type-declarations.js +8 -0
  75. package/dist/server/plugins/mcp/docs-mcp/codemode/prompts.d.ts +5 -0
  76. package/dist/server/plugins/mcp/docs-mcp/codemode/prompts.js +4 -0
  77. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.d.ts +3 -0
  78. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.js +1 -1
  79. package/dist/server/plugins/mcp/docs-mcp/tools/core/search.js +2 -2
  80. package/dist/server/plugins/mcp/docs-mcp/tools/core/types.d.ts +1 -0
  81. package/dist/server/plugins/mcp/docs-mcp/tools/execute.js +1 -1
  82. package/dist/server/plugins/mcp/docs-mcp/tools/graphql/list-graphql-apis.js +1 -1
  83. package/dist/server/plugins/mcp/handlers/handle-mcp-request.js +1 -1
  84. package/dist/server/plugins/mcp/index.js +1 -1
  85. package/dist/server/plugins/mcp/servers/docs-server.js +3 -1
  86. package/dist/server/plugins/openapi-docs/index.js +1 -1
  87. package/dist/server/plugins/scorecard-classic/get-scorecard-config.d.ts +16 -0
  88. package/dist/server/plugins/scorecard-classic/index.js +1 -1
  89. package/dist/server/plugins/search/engines/typesense/index.js +1 -1
  90. package/dist/server/plugins/search/index.js +1 -1
  91. package/dist/server/plugins/sso/index.js +1 -1
  92. package/dist/server/ssr/server-side-props/get-server-props-from-system-handlers.js +1 -1
  93. package/dist/server/store.d.ts +5 -3
  94. package/dist/server/store.js +1 -1
  95. package/dist/server/telemetry/index.js +1 -1
  96. package/dist/server/utils/ai-agent-detection.d.ts +6 -0
  97. package/dist/server/utils/ai-agent-detection.js +1 -1
  98. package/dist/server/web-server/routes/otel/otel.js +1 -1
  99. package/dist/server/web-server/routes/page-data.js +1 -1
  100. package/dist/server/web-server/utils.js +1 -1
  101. package/dist/types/markdoc.d.ts +5 -0
  102. package/package.json +9 -9
  103. package/dist/client/app/markdoc/custom-components/openapi/get-operation/get-operation.js +0 -1
  104. package/dist/client/app/markdoc/custom-components/openapi/get-operation/index.d.ts +0 -4
  105. package/dist/client/app/markdoc/custom-components/openapi/get-operation/index.js +0 -1
  106. package/dist/server/plugins/catalog-classic/get-server-props.d.ts +0 -4
  107. package/dist/server/plugins/catalog-classic/get-server-props.js +0 -1
  108. package/dist/server/plugins/catalog-classic/get-template-path.d.ts +0 -2
  109. package/dist/server/plugins/catalog-classic/get-template-path.js +0 -1
  110. package/dist/server/plugins/mcp/docs-mcp/codemode/build-execute-tool-description.d.ts +0 -4
  111. package/dist/server/plugins/mcp/docs-mcp/codemode/build-execute-tool-description.js +0 -4
  112. package/dist/server/plugins/openapi-docs/get-server-props-custom-fields.d.ts +0 -11
  113. package/dist/server/plugins/openapi-docs/get-server-props-custom-fields.js +0 -1
  114. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-id.d.ts +0 -0
  115. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-id.js +0 -0
  116. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-pointer.d.ts +0 -0
  117. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-pointer.js +0 -0
  118. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation.d.ts +0 -0
  119. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/index.d.ts +0 -0
  120. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/index.js +0 -0
  121. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-identifier.d.ts +0 -0
  122. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-identifier.js +0 -0
  123. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-info.d.ts +0 -0
  124. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-info.js +0 -0
  125. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-parameters.d.ts +0 -0
  126. /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-parameters.js +0 -0
@@ -1 +1 @@
1
- import b from"@markdoc/markdoc";import{getPathnameForLocale as A}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as g}from"../constants/common.js";import{DEFAULT_TITLE as T}from"./constants/common.js";import{GATED_MARKDOC_TAGS as D}from"./constants/entitlements.js";import{isObject as O}from"../utils/guards/is-object.js";import{mapObject as M}from"../utils/object/map-object.js";import{getValueDeep as R}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as L}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as h}from"../utils/path/normalize-route-slug.js";import{isLocalLink as y}from"../utils/path/is-local-link.js";import{reporter as w}from"./tools/notifiers/reporter.js";import{logger as u}from"./tools/notifiers/logger.js";import{sha1 as k}from"./utils/crypto/sha1.js";import{envConfig as _,setEnv as G}from"./config/env-config.js";import{KvService as F}from"./persistence/kv/services/kv-service.js";import{writeSharedData as B}from"./utils/index.js";import{renderComponents as I}from"./ssr/render.js";import{readStaticData as H,writeStaticData as N}from"./utils/static-data.js";import{parseAndResolveMarkdoc as V}from"./plugins/markdown/compiler.js";import{getMarkdocOptions as j}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as S}from"./entitlements/entitlements-provider.js";import{isL10nPath as q}from"./fs/utils/is-l10n-path.js";import{resolveGlobMapValue as K}from"./utils/globs.js";import{replaceEnvVariablesDeep as U}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as x}from"./utils/redirects/find-redirect.js";import{followRedirectChain as J}from"./utils/redirects/follow-redirect-chain.js";import{addWildcardRedirectToTree as W}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as $}from"../cli/telemetry/helpers/trace-step.js";const v={routesBySlug:"map",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",config:"object",ssr:"object",searchFacets:"map",routesPartials:"map",mcpToolHandlers:"map"},m="markdown/partials",z="markdown/partials-deps",E="PLAN_GATES",Y=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORGANIZATION_SLUG","ORGANIZATION_ID","ORG_ID"],Ae="userDefinedApiFunctions";class P{routesBySlug=new Map;replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#e={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;routesPartials=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;mcpToolHandlers=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};#s=void 0;config={configFilePath:"",redirects:{},wildcardRedirectsTree:{},access:{rbac:{},requiresLogin:!1},directoryPermissions:{},devLogin:!1,ssoDirect:{}};#r;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#a;userCodeReady;#o=Promise.resolve();#i;#n=Promise.resolve();#c;#t=new Map;constructor({outdir:e,contentDir:s,serverMode:t=!1,serverOutDir:a}){this.#r=s,this.outdir=e,this.serverMode=t,this.serverOutDir=a,this.userCodeReady=new Promise(r=>{this.#a=r})}on(e,s){const t=this.listeners.get(e);t?t.add(s):this.listeners.set(e,new Set([s]))}queueEvent=(e,s,...t)=>{this.#t.set(e+String(s),[e,s,...t])};runListeners=(e,s,...t)=>{for(const a of this.listeners.get(e)||new Set)s?a(s,...t):a(...t)};startPluginsRun(){this.clear(),this.#o=new Promise(e=>{this.#i=e})}waitForPluginsLifecycle(){return Promise.all([this.#o,this.#n])}finishPluginsRun(){this.#i?.();for(const e of this.#t.values())this.runListeners(...e);this.#t.clear()}startEsbuildRun(){this.#n=new Promise(e=>{this.#c=e})}finishEsbuildRun(){this.#c?.()}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#r}markUserCodeReady(){this.#a?.(!0)}async reloadMarkdocOptions(){await $("build.reload_markdoc_options",async()=>{const e=S.instance(),s=await j(this.serverOutDir),t=Object.fromEntries(Object.entries(s.tags).filter(([a])=>D[a]!=null?e.canAccessFeature(D[a]):!0));this.#s={...s,tags:t}})}get markdocOptions(){return{...this.#s,partials:this.getGlobalConfig(m),themeConfig:this.config.markdown}}setGlobalData=e=>{const s=this.globalData,t={...this.globalData,...e};this.globalData=t,JSON.stringify(t)!==JSON.stringify(s)&&this.queueEvent("global-data-updated",void 0,t)};getGlobalData=()=>this.globalData;getKv=async()=>F.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async({input:e,context:s,deps:t,resource:a})=>{const{data:{info:r,ast:o},compoundHash:l}=await V(e,this.markdocOptions,{actions:this,context:s},a);for(const i of r.sharedDataDeps||[]){for(const n of t?.routeSlugs||[])this.addRouteSharedData(n,i,i);for(const n of t?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(i),this.sharedDataDeps.set(n,c)}}for(const i of r.dynamicMarkdocComponents||[]){for(const n of t?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(i),this.routesDynamicComponents.set(n,c)}for(const n of t?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(i),this.sharedDataMarkdocComponents.set(n,c)}}if(t?.routeSlugs&&r.partials?.length)for(const i of t.routeSlugs){const n=this.routesPartials.get(i)||[];for(const c of r.partials)n.includes(c)||n.push(c);this.routesPartials.set(i,n)}return{info:r,ast:o,compoundHash:l}};async loadOpenApiDefinitions(e){return(await e.cache.load(".","load-oas-docs")).data}async loadAsyncApiDefinitions(e){return(await e.cache.load(".","asyncapi-docs")).data}async loadGraphqlDefinitions(e){return(await e.cache.load(".","load-graphql-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setGlobalConfig=e=>{const s=Object.keys(e);for(const o of s)for(const l in this.replacedEnvVars)if(l===o||l.startsWith(`${o}:`)){const i=l.split(":"),{error:n,value:c}=R(e,i);(n||c!==this.replacedEnvVars[l].replaced)&&delete this.replacedEnvVars[l]}const{resolvedObj:t,unsetEnvVars:a,replacedValues:r}=U(e);for(const o of a)this.unsetEnvVars.add(o);Object.assign(this.replacedEnvVars,r),Object.assign(this.config,t)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,s,t={})=>{if(!S.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const o=h(e).toLowerCase();this.config.redirects[o]=s;const{trackOriginalSource:l=!0}=t,i=this.getGlobalConfig("originalRedirectSources");l&&Array.isArray(i)&&!i.includes(o)&&i.push(o),o.endsWith("*")&&W(this.config.wildcardRedirectsTree,o)};getRedirect=e=>{const s=h(e).toLowerCase(),t=x(s,this.config.redirects,this.config.wildcardRedirectsTree);if(!t)return null;if(y(t.to)){const a=h(t.to).toLowerCase();if(!a.endsWith("*")&&J(a,[s],this.config.redirects,this.config.wildcardRedirectsTree).type==="cycle")return null}return{to:t.to,type:t.type}};createSharedData=async(e,s,t)=>{if(t&&this.#e[e]===t)return e;const a=JSON.stringify(s),r=t??k(a);return this.#e[e]===r||(this.#e[e]=r,await B(e,a,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,s,t)=>{const a=L(e),r=this.routesSharedData.get(a)||{};r[s]=t,this.routesSharedData.set(a,r),u.verbose(`Adding shared data to ${e}, ${s}, ${t}`)};getRouteSharedDataByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.routesSharedData.get(s)||{}:{}};getPartialsForRoute=e=>{const s=this.getGlobalConfig(m)||{},t=this.routesPartials.get(e);if(!t||t.length===0)return{};const a=this.getGlobalConfig(z)||{},r=new Set(t),o=Array.from(t);for(let i=0;i<o.length;i++){const n=o[i],c=a[n]?.partials??[];for(const d of c)r.has(d)||(r.add(d),o.push(d))}const l={};for(const i of r)s[i]&&(l[i]=s[i]);return l};addRoute=e=>{const t={...K(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:t}),u.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,s,t)=>{const a=[g,...this.lifecycleContext?.fs.localeFolders||[]].map(r=>({code:r,name:r}));for(const r of a){const o=A(e,g,r.code,a);this.addRouteSharedData(o,s,t)}};addApiRoute=e=>{this.apiRoutes.push(e),u.verbose("Created API route %s",e.slug)};addMcpTools=(e,s)=>{for(const t of s)this.mcpToolHandlers.set(t.name,{...t,importPath:e}),u.verbose("Created MCP tool %s",t.name)};getMcpTools=()=>Array.from(this.mcpToolHandlers.values());addMiddleware=e=>{this.middleware.push(e),u.verbose("Created middleware %s",e.id)};setResourceResponseHeaders=(e,s)=>{this.config.responseHeaders||(this.config.responseHeaders={});const t=new Set(s.map(o=>o.name.toLowerCase())),r=[...(this.config.responseHeaders[e]??[]).filter(o=>!t.has(o.name.toLowerCase())),...s];this.config.responseHeaders[e]=r};getRouteByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.getRouteBySlug(s):void 0};getRouteBySlug=(e,s={})=>{const{followRedirect:t=!0}=s,a=this.getRedirect(e);return t&&a?this.routesBySlug.get(h(a.to)):this.routesBySlug.get(e)};hasRouteOrRedirectBySlug=e=>{if(this.routesBySlug.has(e))return!0;const s=this.getRedirect(e);if(!s)return!1;if(!y(s.to))return!0;const t=h(s.to);return this.routesBySlug.has(t)};getRoutesByTemplateId=e=>this.newRoutes.filter(s=>s.templateId===e);getAllRoutesForLocale=(e=g)=>{const s=Array.from(this.routesBySlug.values()),t=e.toLowerCase();return s.filter(a=>e===g?!q(a.fsPath):a.slug.startsWith(`/${t}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,s)=>(this.templates.set(e,s),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};createRequestHandler=(e,s)=>(this.apiRoutesRequestHandlers.set(e,s),e);clearRequestHandlersByPrefix=e=>{for(const s of this.apiRoutesRequestHandlers.keys())s.startsWith(e)&&this.apiRoutesRequestHandlers.delete(s)};registerServerPropsGetter=(e,s)=>(this.serverPropsGetters.set(e,s),e);registerPagePropsGetter=(e,s)=>{this.pagePropsGetters.set(e,s)};async writeRouteStaticData(e,s){const t=await this.resolveRouteStaticData(e,s,!1);t&&N(e.slug,t,this.outdir)}async resolveRouteStaticData(e,s,t){if(this.serverMode)return H(e.slug,this.outdir);const a={...this,contentDir:this.contentDir,parseMarkdoc:({input:c,context:d,resource:f})=>this.parseMarkdoc({input:c,context:d,deps:{routeSlugs:[e.slug]},resource:f})},r=await e.getStaticData?.(e,a)||{},o=new Set(this.routesDynamicComponents.get(e.slug)),l=this.routesSharedData.get(e.slug)||{};for(const c of Object.values(l)){const d=this.sharedDataMarkdocComponents.get(c);d&&d.forEach(p=>o.add(p));const f=this.sharedDataDeps.get(c);f&&f.forEach(p=>this.addRouteSharedData(e.slug,p,p))}const i=this.getGlobalConfig("seo"),n=r?.frontmatter||{};return{...r,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await e.getNavText?.()}},props:{...r.props,dynamicMarkdocComponents:Array.from(o),metadata:{...r?.props?.metadata,...e.metadata},seo:{title:T,...i,...r.props?.seo},compilationErrors:this.compilationErrors},lastModified:t||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,s){if(!e?.length)return;const t=typeof e[0]=="string"?e.join(""):I(e);t&&(s==="head"?this.ssr.headTags.push(t):s==="preBody"?this.ssr.preBodyTags.push(t):this.ssr.postBodyTags.push(t))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const e=[];for(const[t,a]of Object.entries(v))switch(a){case"map":const r=Array.from(this[t].entries());e.push([t,r]);break;case"object":t==="config"&&e.push([t,await this.getConfigWithEnvPlaceholders()]),e.push([t,this[t]]);break;default:throw new Error("Invalid format")}const s=Object.fromEntries(e);return s[E]=_.PLAN_GATES,s}static fromJson(e,s){const t=new P(s);for(const[r,o]of Object.entries(v))switch(o){case"map":t[r]=new Map(e[r]);break;case"object":if(r==="config"){t.setGlobalConfig(e[r]);break}t[r]=e[r];break;default:throw new Error("Invalid format")}t.config[m]=Z(t.config[m]||{});const a=e[E];return a&&G("PLAN_GATES",a),t}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const s in this.replacedEnvVars){const{original:t}=this.replacedEnvVars[s],a=s.split(":"),r=a.pop(),{error:o,value:l}=R(e,a);if(o||!O(l)&&!Array.isArray(l)){await w.panicOnBuild(`Failed to replace env var with env name for ${s}`);continue}l[r]=t}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(t=>!Y.includes(t));if(e.length===0)return;const s=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await w.panicOnBuildContentError(s)}}function Z(C){return M(C,e=>b.Ast.fromJSON(JSON.stringify(e)))}export{m as MARKDOC_PARTIALS_DATA_KEY,z as MARKDOC_PARTIALS_DEPS_KEY,P as Store,Ae as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
1
+ import b from"@markdoc/markdoc";import{getPathnameForLocale as A}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as g}from"../constants/common.js";import{DEFAULT_TITLE as O}from"./constants/common.js";import{GATED_MARKDOC_TAGS as D}from"./constants/entitlements.js";import{MARKDOC_PARTIALS_DATA_KEY as m,MARKDOC_PARTIALS_DEPS_KEY as T}from"./constants/common.js";import{isObject as M}from"../utils/guards/is-object.js";import{mapObject as L}from"../utils/object/map-object.js";import{getValueDeep as y}from"../utils/object/get-value-deep.js";import{removeTrailingSlash as k}from"../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as u}from"../utils/path/normalize-route-slug.js";import{isLocalLink as R}from"../utils/path/is-local-link.js";import{reporter as S}from"./tools/notifiers/reporter.js";import{logger as h}from"./tools/notifiers/logger.js";import{sha1 as H}from"./utils/crypto/sha1.js";import{envConfig as _,setEnv as G}from"./config/env-config.js";import{KvService as B}from"./persistence/kv/services/kv-service.js";import{writeSharedData as F}from"./utils/index.js";import{renderComponents as I}from"./ssr/render.js";import{readStaticData as N,writeStaticData as q}from"./utils/static-data.js";import{parseAndResolveMarkdoc as V}from"./plugins/markdown/compiler.js";import{getMarkdocOptions as j}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as w}from"./entitlements/entitlements-provider.js";import{isL10nPath as U}from"./fs/utils/is-l10n-path.js";import{resolveGlobMapValue as K}from"./utils/globs.js";import{replaceEnvVariablesDeep as J}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as x}from"./utils/redirects/find-redirect.js";import{followRedirectChain as W}from"./utils/redirects/follow-redirect-chain.js";import{addWildcardRedirectToTree as $}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as z}from"../cli/telemetry/helpers/trace-step.js";const v={routesBySlug:"map",apiRoutes:"object",middleware:"object",routesByFsPath:"map",routesSharedData:"map",globalData:"object",config:"object",ssr:"object",searchFacets:"map",routesPartials:"map",mcpToolHandlers:"map"},E="PLAN_GATES",Y=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORGANIZATION_SLUG","ORGANIZATION_ID","ORG_ID"],Oe="userDefinedApiFunctions";class P{routesBySlug=new Map;replacedEnvVars={};unsetEnvVars=new Set;lifecycleContext;newRoutes=[];#t={};routesByFsPath=new Map;apiRoutes=[];middleware=[];routesSharedData=new Map;sharedDataDeps=new Map;sharedDataMarkdocComponents=new Map;routesDynamicComponents=new Map;routesPartials=new Map;ssr={preBodyTags:[],postBodyTags:[],headTags:[]};searchFacets=new Map;searchEngine;templates=new Map;browserPlugins=new Set;apiRoutesRequestHandlers=new Map;mcpToolHandlers=new Map;serverPropsGetters=new Map;pagePropsGetters=new Map;listeners=new Map;globalData={};#o=void 0;config={configFilePath:"",redirects:{},wildcardRedirectsTree:{},access:{rbac:{},requiresLogin:!1},directoryPermissions:{},devLogin:!1,ssoDirect:{}};#i;serverMode;serverOutDir;outdir;buildRevision=0;hasSitemap=!1;compilationErrors=[];#n;userCodeReady;#s=Promise.resolve();#c;#l=Promise.resolve();#d;#u=Promise.resolve();#h;#e=!1;#r=0;#f=0;#a=new Map;constructor({outdir:e,contentDir:s,serverMode:t=!1,serverOutDir:a}){this.#i=s,this.outdir=e,this.serverMode=t,this.serverOutDir=a,this.userCodeReady=new Promise(r=>{this.#n=r})}on(e,s){const t=this.listeners.get(e);t?t.add(s):this.listeners.set(e,new Set([s]))}queueEvent=(e,s,...t)=>{this.#a.set(e+String(s),[e,s,...t])};runListeners=(e,s,...t)=>{for(const a of this.listeners.get(e)||new Set)s?a(s,...t):a(...t)};startPluginsRun(){this.clear(),this.#s=new Promise(e=>{this.#c=e})}waitForPluginsLifecycle(){return Promise.all([this.#s,this.#l,this.#u])}waitForPluginsRun(){return this.#s}finishPluginsRun(){this.#c?.();for(const e of this.#a.values())this.runListeners(...e);this.#a.clear()}startEsbuildRun(){this.#l=new Promise(e=>{this.#d=e})}finishEsbuildRun(){this.#d?.()}markRequestHandlersEntryOutdated(){this.#r++,!this.#e&&(this.#e=!0,this.#u=new Promise(e=>{this.#h=e}))}noteRequestHandlersEntryBuildStart(){this.#f=this.#r}markRequestHandlersEntryUpdated(){this.#e&&(this.#r>this.#f||(this.#e=!1,this.#h?.()))}get contentDir(){if(this.serverMode)throw new Error("contentDir should not be used in server mode");return this.#i}markUserCodeReady(){this.#n?.(!0)}async reloadMarkdocOptions(){await z("build.reload_markdoc_options",async()=>{const e=w.instance(),s=await j(this.serverOutDir),t=Object.fromEntries(Object.entries(s.tags).filter(([a])=>D[a]!=null?e.canAccessFeature(D[a]):!0));this.#o={...s,tags:t}})}get markdocOptions(){return{...this.#o,partials:this.getGlobalConfig(m),themeConfig:this.config.markdown}}setGlobalData=e=>{const s=this.globalData,t={...this.globalData,...e};this.globalData=t,JSON.stringify(t)!==JSON.stringify(s)&&this.queueEvent("global-data-updated",void 0,t)};getGlobalData=()=>this.globalData;getKv=async()=>B.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async({input:e,context:s,deps:t,resource:a})=>{const{data:{info:r,ast:o},compoundHash:l}=await V(e,this.markdocOptions,{actions:this,context:s},a);for(const i of r.sharedDataDeps||[]){for(const n of t?.routeSlugs||[])this.addRouteSharedData(n,i,i);for(const n of t?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(i),this.sharedDataDeps.set(n,c)}}for(const i of r.dynamicMarkdocComponents||[]){for(const n of t?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(i),this.routesDynamicComponents.set(n,c)}for(const n of t?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(i),this.sharedDataMarkdocComponents.set(n,c)}}if(t?.routeSlugs&&r.partials?.length)for(const i of t.routeSlugs){const n=this.routesPartials.get(i)||[];for(const c of r.partials)n.includes(c)||n.push(c);this.routesPartials.set(i,n)}return{info:r,ast:o,compoundHash:l}};async loadOpenApiDefinitions(e){return(await e.cache.load(".","load-oas-docs")).data}async loadAsyncApiDefinitions(e){return(await e.cache.load(".","asyncapi-docs")).data}async loadGraphqlDefinitions(e){return(await e.cache.load(".","load-graphql-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setGlobalConfig=e=>{const s=Object.keys(e);for(const o of s)for(const l in this.replacedEnvVars)if(l===o||l.startsWith(`${o}:`)){const i=l.split(":"),{error:n,value:c}=y(e,i);(n||c!==this.replacedEnvVars[l].replaced)&&delete this.replacedEnvVars[l]}const{resolvedObj:t,unsetEnvVars:a,replacedValues:r}=J(e);for(const o of a)this.unsetEnvVars.add(o);Object.assign(this.replacedEnvVars,r),Object.assign(this.config,t)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,s,t={})=>{if(!w.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const o=u(e).toLowerCase();this.config.redirects[o]=s;const{trackOriginalSource:l=!0}=t,i=this.getGlobalConfig("originalRedirectSources");l&&Array.isArray(i)&&!i.includes(o)&&i.push(o),o.endsWith("*")&&$(this.config.wildcardRedirectsTree,o)};getRedirect=e=>{const s=u(e).toLowerCase(),t=x(s,this.config.redirects,this.config.wildcardRedirectsTree);if(!t)return null;if(R(t.to)){const a=u(t.to).toLowerCase();if(!a.endsWith("*")&&W(a,[s],this.config.redirects,this.config.wildcardRedirectsTree).type==="cycle")return null}return{to:t.to,type:t.type}};createSharedData=async(e,s,t)=>{if(t&&this.#t[e]===t)return e;const a=JSON.stringify(s),r=t??H(a);return this.#t[e]===r||(this.#t[e]=r,await F(e,a,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,s,t)=>{const a=k(e),r=this.routesSharedData.get(a)||{};r[s]=t,this.routesSharedData.set(a,r),h.verbose(`Adding shared data to ${e}, ${s}, ${t}`)};getRouteSharedDataByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.routesSharedData.get(s)||{}:{}};getPartialsForRoute=e=>{const s=this.getGlobalConfig(m)||{},t=this.routesPartials.get(e);if(!t||t.length===0)return{};const a=this.getGlobalConfig(T)||{},r=new Set(t),o=Array.from(t);for(let i=0;i<o.length;i++){const n=o[i],c=a[n]?.partials??[];for(const d of c)r.has(d)||(r.add(d),o.push(d))}const l={};for(const i of r)s[i]&&(l[i]=s[i]);return l};addRoute=e=>{const t={...K(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:t}),h.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,s,t)=>{const a=[g,...this.lifecycleContext?.fs.localeFolders||[]].map(r=>({code:r,name:r}));for(const r of a){const o=A(e,g,r.code,a);this.addRouteSharedData(o,s,t)}};addApiRoute=e=>{this.apiRoutes.push(e),h.verbose("Created API route %s",e.slug)};addMcpTools=(e,s)=>{for(const t of s)this.mcpToolHandlers.set(t.name,{...t,importPath:e}),h.verbose("Created MCP tool %s",t.name)};getMcpTools=()=>Array.from(this.mcpToolHandlers.values());addMiddleware=e=>{this.middleware.push(e),h.verbose("Created middleware %s",e.id)};setResourceResponseHeaders=(e,s)=>{this.config.responseHeaders||(this.config.responseHeaders={});const t=new Set(s.map(o=>o.name.toLowerCase())),r=[...(this.config.responseHeaders[e]??[]).filter(o=>!t.has(o.name.toLowerCase())),...s];this.config.responseHeaders[e]=r};getRouteByFsPath=e=>{const s=this.routesByFsPath.get(e);return s?this.getRouteBySlug(s):void 0};getRouteBySlug=(e,s={})=>{const{followRedirect:t=!0}=s,a=this.getRedirect(e);return t&&a?this.routesBySlug.get(u(a.to)):this.routesBySlug.get(e)};hasRouteOrRedirectBySlug=e=>{if(this.routesBySlug.has(e))return!0;const s=this.getRedirect(e);if(!s)return!1;if(!R(s.to))return!0;const t=u(s.to);return this.routesBySlug.has(t)};getRoutesByTemplateId=e=>this.newRoutes.filter(s=>s.templateId===e);getAllRoutesForLocale=(e=g)=>{const s=Array.from(this.routesBySlug.values()),t=e.toLowerCase();return s.filter(a=>e===g?!U(a.fsPath):a.slug.startsWith(`/${t}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,s)=>(this.templates.set(e,s),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};createRequestHandler=(e,s)=>(this.apiRoutesRequestHandlers.set(e,s),e);clearRequestHandlersByPrefix=e=>{for(const s of this.apiRoutesRequestHandlers.keys())s.startsWith(e)&&this.apiRoutesRequestHandlers.delete(s)};registerServerPropsGetter=(e,s)=>(this.serverPropsGetters.set(e,s),e);registerPagePropsGetter=(e,s)=>{this.pagePropsGetters.set(e,s)};async writeRouteStaticData(e,s){const t=await this.resolveRouteStaticData(e,s,!1);t&&q(e.slug,t,this.outdir)}async resolveRouteStaticData(e,s,t){if(this.serverMode)return N(e.slug,this.outdir);const a={...this,contentDir:this.contentDir,parseMarkdoc:({input:c,context:d,resource:f})=>this.parseMarkdoc({input:c,context:d,deps:{routeSlugs:[e.slug]},resource:f})},r=await e.getStaticData?.(e,a)||{},o=new Set(this.routesDynamicComponents.get(e.slug)),l=this.routesSharedData.get(e.slug)||{};for(const c of Object.values(l)){const d=this.sharedDataMarkdocComponents.get(c);d&&d.forEach(p=>o.add(p));const f=this.sharedDataDeps.get(c);f&&f.forEach(p=>this.addRouteSharedData(e.slug,p,p))}const i=this.getGlobalConfig("seo"),n=r?.frontmatter||{};return{...r,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await e.getNavText?.()}},props:{...r.props,dynamicMarkdocComponents:Array.from(o),metadata:{...r?.props?.metadata,...e.metadata},seo:{title:O,...i,...r.props?.seo},compilationErrors:this.compilationErrors},lastModified:t||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,s){if(!e?.length)return;const t=typeof e[0]=="string"?e.join(""):I(e);t&&(s==="head"?this.ssr.headTags.push(t):s==="preBody"?this.ssr.preBodyTags.push(t):this.ssr.postBodyTags.push(t))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const e=[];for(const[t,a]of Object.entries(v))switch(a){case"map":const r=Array.from(this[t].entries());e.push([t,r]);break;case"object":t==="config"&&e.push([t,await this.getConfigWithEnvPlaceholders()]),e.push([t,this[t]]);break;default:throw new Error("Invalid format")}const s=Object.fromEntries(e);return s[E]=_.PLAN_GATES,s}static fromJson(e,s){const t=new P(s);for(const[r,o]of Object.entries(v))switch(o){case"map":t[r]=new Map(e[r]);break;case"object":if(r==="config"){t.setGlobalConfig(e[r]);break}t[r]=e[r];break;default:throw new Error("Invalid format")}t.config[m]=Z(t.config[m]||{});const a=e[E];return a&&G("PLAN_GATES",a),t}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const s in this.replacedEnvVars){const{original:t}=this.replacedEnvVars[s],a=s.split(":"),r=a.pop(),{error:o,value:l}=y(e,a);if(o||!M(l)&&!Array.isArray(l)){await S.panicOnBuild(`Failed to replace env var with env name for ${s}`);continue}l[r]=t}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(t=>!Y.includes(t));if(e.length===0)return;const s=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await S.panicOnBuildContentError(s)}}function Z(C){return L(C,e=>b.Ast.fromJSON(JSON.stringify(e)))}export{P as Store,Oe as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
@@ -1 +1 @@
1
- import{AsyncApiRealmAPI as o}from"@redocly/realm-asyncapi-sdk";import{envConfig as e}from"../config/env-config.js";import{PACKAGE_NAME as t}from"../../config/product-gates.js";import{OTEL_TRACES_DEV_URL as i,TELEMETRY_ENABLED as s}from"../constants/common.js";class E extends o.Telemetry{constructor(){super(),this.updateCloudEventData(()=>({organizationId:e.ORGANIZATION_ID||"",organizationSlug:e.ORGANIZATION_SLUG||"",projectId:e.PROJECT_ID||"",projectSlug:e.PROJECT_SLUG||"",origin:"realmApi",actor:{id:"Anonymous",object:"user",uri:""},source:"server",env:e.REDOCLY_ENV}))}initialize(r=!1){this.init({otel:{serviceName:"realm-server",serviceVersion:`${t}@${e.REDOCLY_PORTAL_VERSION||""}`,collectorTraceUrl:r?i:e.OTEL_TRACES_URL||"https://otel.cloud.redocly.com/v1/traces",isProd:e.isProductionEnv,version:"1.0",tracerName:"server-telemetry",delayMillis:100},disabled:r?!e.TELEMETRY_DEV_DEBUG:!s})}}const A=new E;export{A as telemetry};
1
+ import{AsyncApiRealmAPI as o}from"@redocly/realm-asyncapi-sdk";import{envConfig as e}from"../config/env-config.js";import{PACKAGE_NAME as t}from"../../config/product-gates.js";import{OTEL_TRACES_DEV_URL as i,TELEMETRY_ENABLED as l}from"../constants/common.js";class s extends o.Telemetry{constructor(){super(),this.updateCloudEventData(()=>({organizationId:e.ORGANIZATION_ID||"",organizationSlug:e.ORGANIZATION_SLUG||"",projectId:e.PROJECT_ID||"",projectSlug:e.PROJECT_SLUG||"",origin:"realmApi",actor:{id:"Anonymous",object:"user",uri:""},source:"urn:redocly:realm:api",env:e.REDOCLY_ENV}))}initialize(r=!1){this.init({otel:{serviceName:"realm-server",serviceVersion:`${t}@${e.REDOCLY_PORTAL_VERSION||""}`,collectorTraceUrl:r?i:e.OTEL_TRACES_URL||"https://otel.cloud.redocly.com/v1/traces",isProd:e.isProductionEnv,version:"1.0",tracerName:"server-telemetry",delayMillis:100},disabled:r?!e.TELEMETRY_DEV_DEBUG:!l})}}const A=new s;export{A as telemetry};
@@ -5,6 +5,12 @@ export type AiAgentRequestHeaders = {
5
5
  signatureInput?: string;
6
6
  userAgent?: string;
7
7
  };
8
+ /**
9
+ * Returns true if the Accept header explicitly lists text/html with a non-zero
10
+ * quality value. The catch-all wildcard does not count, so non-browser
11
+ * clients (curl, MCP clients) are not treated as browsers.
12
+ */
13
+ export declare function acceptsHtml(acceptHeader: string | null | undefined): boolean;
8
14
  /**
9
15
  * Returns true if the request appears to be from an AI agent or a client that
10
16
  * should receive the markdown representation when llms.txt is enabled.
@@ -1 +1 @@
1
- const u=new Set(["https://chatgpt.com","https://anthropic.com","https://gemini.google.com","https://perplexity.ai"]),p=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","anthropic-ai","Google-Extended","Gemini-Deep-Research","Google-CloudVertexBot","PerplexityBot","Perplexity-User","Meta-ExternalAgent","Meta-ExternalFetcher","meta-webindexer","CrawlBot","CCBot","Bytespider","DuckAssistBot","Cursor"];function l(t,e,n){return Math.min(n,Math.max(e,t))}function m(t){if(!t?.trim())return[];const e=[],n=t.split(",").map(o=>o.trim());for(const o of n){if(!o)continue;const[r,...s]=o.split(";").map(a=>a.trim().toLowerCase());if(!r.includes("/"))continue;let i=1;for(const a of s)if(a.startsWith("q=")){const c=parseFloat(a.slice(2));i=Number.isFinite(c)?l(c,0,1):1;break}e.push({type:r,q:i})}return e}function f(t){const e=m(t),n=Math.max(0,...e.filter(r=>r.type==="text/html").map(r=>r.q)),o=Math.max(0,...e.filter(r=>r.type==="text/markdown").map(r=>r.q));return o>=n&&o>0}function h(t){if(!t||!t.trim().length)return!1;const e=t.trim().toLowerCase().replace(/\/$/,"");return u.has(e)}function d(t){if(!t)return!1;const e=t.toLowerCase();return p.some(n=>e.includes(n.toLowerCase()))}function g(t){const{accept:e,signatureAgent:n,signature:o,signatureInput:r,userAgent:s}=t;return!!(f(e??"")||h(n)&&(o!==void 0||r!==void 0)||d(s))}export{g as isAiAgentRequest};
1
+ const p=new Set(["https://chatgpt.com","https://anthropic.com","https://gemini.google.com","https://perplexity.ai"]),l=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","anthropic-ai","Google-Extended","Gemini-Deep-Research","Google-CloudVertexBot","PerplexityBot","Perplexity-User","Meta-ExternalAgent","Meta-ExternalFetcher","meta-webindexer","CrawlBot","CCBot","Bytespider","DuckAssistBot","Cursor"];function m(t,e,r){return Math.min(r,Math.max(e,t))}function u(t){if(!t?.trim())return[];const e=[],r=t.split(",").map(o=>o.trim());for(const o of r){if(!o)continue;const[n,...a]=o.split(";").map(s=>s.trim().toLowerCase());if(!n.includes("/"))continue;let i=1;for(const s of a)if(s.startsWith("q=")){const c=parseFloat(s.slice(2));i=Number.isFinite(c)?m(c,0,1):1;break}e.push({type:n,q:i})}return e}function f(t){const e=u(t),r=Math.max(0,...e.filter(n=>n.type==="text/html").map(n=>n.q)),o=Math.max(0,...e.filter(n=>n.type==="text/markdown").map(n=>n.q));return o>=r&&o>0}function x(t){return u(t??"").some(r=>r.type==="text/html"&&r.q>0)}function h(t){if(!t||!t.trim().length)return!1;const e=t.trim().toLowerCase().replace(/\/$/,"");return p.has(e)}function d(t){if(!t)return!1;const e=t.toLowerCase();return l.some(r=>e.includes(r.toLowerCase()))}function g(t){const{accept:e,signatureAgent:r,signature:o,signatureInput:n,userAgent:a}=t;return!!(f(e??"")||h(r)&&(o!==void 0||n!==void 0)||d(a))}export{x as acceptsHtml,g as isAiAgentRequest};
@@ -1 +1 @@
1
- import{AsyncApiRealmAPI as T}from"@redocly/realm-asyncapi-sdk";import{envConfig as o}from"../../../config/env-config.js";import{getClientIp as R}from"../../utils/get-client-ip.js";import{getAttributesStringValue as v,mergeAttributes as S}from"./otlp.js";const C=o.OTEL_TRACES_URL||"https://otel.cloud.redocly.com/v1/traces";class O extends T.OtelClient{initTracer(){}}let a=null;function h(){return a||(a=new O,a.init({collectorTraceUrl:void 0,serviceName:"realm-ui",serviceVersion:"1.0",isProd:o.isProductionEnv,version:"1.0",tracerName:"attribute-processor"})),a}async function D(e){const n=await e.req.json();return n.resourceSpans?.length&&(w(n,P(e)),await fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})),e.newResponse(null,200)}function w(e,n){for(const r of e.resourceSpans){const c=r.resource.attributes.find(i=>i.key==="session_id");if(!c)continue;const d=v(c);if(!d)continue;const l=j(n.userId,d),A=new Date,_={organizationId:o.ORGANIZATION_ID||"",organizationSlug:o.ORGANIZATION_SLUG||"",projectId:o.PROJECT_ID||"",projectSlug:o.PROJECT_SLUG||"",env:o.REDOCLY_ENV||"",source:"urn:redocly:realm:ui",actor:{id:l.id,object:l.object,uri:l.uri},clientIp:n.clientIp,userAgent:n.userAgent,sessionId:d},s=(i,t)=>{const u=i.attributes.find(p=>p.key===t);return u?v(u):""};for(const i of r.scopeSpans)for(const t of i.spans){if(!t.name.startsWith("event.")||t.name==="event.undefined")continue;const u=s(t,"cloudevents.event_spec_version"),p=s(t,"cloudevents.event_object"),g=s(t,"cloudevents.event_data_content_type"),I=s(t,"cloudevents.event_origin"),m=s(t,"cloudevents.event_time"),f=m?new Date(m):A,b={..._,id:s(t,"cloudevents.event_id"),specversion:u,type:t.name.slice(6),object:p,datacontenttype:g,time:f,origin:I},y=h().processAttributes(b,f);S(t,y,{overwrite:!0})}}}function P(e){const n=e.get("auth")?.claims?.id||e.get("auth")?.claims?.sub,r=R(e.req.raw)||e.req.raw.context?.remoteAddr?.hostname,c=e.req.raw.headers.get("user-agent");return{userId:n,clientIp:r??void 0,userAgent:c??void 0}}function j(e,n){if(e)return{id:e,object:"user",uri:`${o.MAIN_API_URL}/users/${e}`};const r=n.replace("ses_","ann_");return{id:r,object:"anonymous",uri:`${o.MAIN_API_URL}/anonymous/${r}`}}export{D as otelTracesHandler,j as toActor};
1
+ import{AsyncApiRealmAPI as y}from"@redocly/realm-asyncapi-sdk";import{envConfig as o}from"../../../config/env-config.js";import{getClientIp as R}from"../../utils/get-client-ip.js";import{getAttributesStringValue as I,mergeAttributes as h,toAttribute as O}from"./otlp.js";const C=o.OTEL_TRACES_URL||"https://otel.cloud.redocly.com/v1/traces",A="cloudevents.event_session_id";class w extends y.OtelClient{initTracer(){}}let d=null;function E(){return d||(d=new w,d.init({collectorTraceUrl:void 0,serviceName:"realm-ui",serviceVersion:"1.0",isProd:o.isProductionEnv,version:"1.0",tracerName:"attribute-processor"})),d}async function $(e){const t=await e.req.json();return t.resourceSpans?.length&&(N(t,j(e)),await fetch(C,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})),e.newResponse(null,200)}function N(e,t){for(const s of e.resourceSpans){const r=s.resource.attributes.find(u=>u.key==="session_id");if(!r)continue;const i=I(r);if(!i)continue;const l=L(t.userId,i),_=new Date,v={organizationId:o.ORGANIZATION_ID||"",organizationSlug:o.ORGANIZATION_SLUG||"",projectId:o.PROJECT_ID||"",projectSlug:o.PROJECT_SLUG||"",env:o.REDOCLY_ENV||"",source:"urn:redocly:realm:ui",actor:{id:l.id,object:l.object,uri:l.uri},clientIp:t.clientIp,userAgent:t.userAgent},c=(u,n)=>{const a=u.attributes.find(f=>f.key===n);return a?I(a):""};for(const u of s.scopeSpans)for(const n of u.spans){if(!n.name.startsWith("event.")||n.name==="event.undefined")continue;const a=c(n,"cloudevents.event_spec_version"),f=c(n,"cloudevents.event_object"),g=c(n,"cloudevents.event_data_content_type"),b=c(n,"cloudevents.event_origin"),p=c(n,"cloudevents.event_time"),m=p?new Date(p):_,S={...v,id:c(n,"cloudevents.event_id"),specversion:a,type:n.name.slice(6),object:f,datacontenttype:g,time:m,origin:b},T=E().processAttributes(S,m);h(n,T,{overwrite:!0}),P(n,t.sessionId)}}}function P(e,t){const s=e.attributes.findIndex(i=>i.key===A),r=O(A,t);r?s===-1?e.attributes.push(r):e.attributes[s]=r:s!==-1&&e.attributes.splice(s,1)}function j(e){const t=e.get("auth")?.claims?.id||e.get("auth")?.claims?.sub,s=e.get("auth")?.claims?.sessionId,r=R(e.req.raw)||e.req.raw.context?.remoteAddr?.hostname,i=e.req.raw.headers.get("user-agent");return{userId:t,sessionId:s||void 0,clientIp:r??void 0,userAgent:i??void 0}}function L(e,t){if(e)return{id:e,object:"user",uri:`${o.MAIN_API_URL}/users/${e}`};const s=t.replace("ses_","ann_");return{id:s,object:"anonymous",uri:`${o.MAIN_API_URL}/anonymous/${s}`}}export{$ as otelTracesHandler,L as toActor};
@@ -1 +1 @@
1
- import{ServerRoutes as O}from"../../../constants/api.js";import{DEV_LOGIN_SLUG as U}from"../../../constants/common.js";import{CACHE_CONTROL_NO_STORE_HEADER_VALUE as a,DEFAULT_TITLE as $}from"../../constants/common.js";import{findInIterable as F}from"../../../utils/collection/find-in-iterable.js";import{removeTrailingSlash as N}from"../../../utils/url/remove-trailing-slash.js";import{envConfig as S}from"../../config/env-config.js";import{canAccessResource as q,filterDataByAccessDeep as b,isResourcePubliclyAccessible as B}from"../../utils/rbac.js";import{getServerProps as H}from"../../ssr/index.js";import{readSharedData as G}from"../../utils/index.js";import{getRedirectLoginUrl as M}from"../utils/get-redirect-login-url.js";import{processRedirects as V}from"./helpers/process-redirects.js";import{removeErrorDetails as k}from"../utils/remove-error-details.js";import{telemetry as K}from"../../telemetry/index.js";function se(e,s){return async(t,p)=>{const l=t.get("logger"),{req:u}=t,{pathname:d}=new URL(u.url),{seo:f,ssoDirect:h}=e.getConfig(),i=f?.title||$;if(e?.compilationErrors?.length&&S.isDevelopMode)return t.json({templateId:"compilation-error",props:{compilationErrors:e?.compilationErrors},sharedDataIds:{}},500,{"Cache-Control":a});const m=d.match(/page-data(.*)data.json$/);if(!m)return p();const c=decodeURI(m[1]),n=c==="/index/"?"/":N(c),o=e.getRouteBySlug(n,{followRedirect:!1})||F(e.routesBySlug.values(),r=>r.hasClientRoutes&&c.startsWith(r.slug+"/"));if(c===O.OIDC_CALLBACK+"/")return t.json({templateId:"403OIDC",sharedDataIds:{},props:{seo:{title:`${i} - Forbidden`}}},200,{"Cache-Control":a});const{isAuthenticated:C,teams:D,claims:{name:j,picture:v,email:I}}=t.get("auth"),R={isAuthenticated:C,email:I,teams:D},g={isAuthenticated:C,name:j,picture:v,email:I,teams:D},L=e.getRedirect(n);if(L){const r=V({redirect:L}).location;return K.sendRedirectMessage([{object:"redirect",from:n,templateId:"404"}]),t.json({templateId:"404",redirectTo:r,sharedDataIds:{},props:{}},301,{"Cache-Control":a})}if(!o){const r=e.getRouteBySlug(n,{followRedirect:!0});return l.error(`Page not found: ${d}`),t.json({templateId:"404",redirectTo:r?.slug,sharedDataIds:{},props:{seo:{title:`${i} - Not Found`}},userData:g},404,{"Cache-Control":a})}if(l.verbose(`Page viewed: ${o.slug}`),!q(o,R,e.config.access?.rbac,e.config.access?.requiresLogin)&&o.slug!==U){if(C)return t.json({templateId:"403",sharedDataIds:{},props:{seo:{title:`${i} - Forbidden`}},userData:g},403,{"Cache-Control":a});const r=Object.keys(h||{}).length>0;return t.json({templateId:"404",sharedDataIds:{},props:{seo:{title:`${i} - Not Found`}},userData:g,...r?{redirectTo:M(e,o.slug)}:{}},r?401:404,{"Cache-Control":a})}const A=b(o.versions,R,e.config.access?.rbac,e.config.access?.requiresLogin),T=e.routesSharedData.get(o.slug)||{},P=await s(o),y=await H(o,t,P,e),{sharedDataIds:_,...E}=y,w={templateId:o.templateId,versions:A,sharedDataIds:{...T,..._||{}},props:S.isProductionEnv?k(E):E,slug:o.slug,userData:g,isPublic:B(o,e.config)};return t.json(w,200,{"Cache-Control":a})}}function ne(e){return async(s,t)=>{const p=s.get("logger"),{req:l}=s,{pathname:u}=new URL(l.url),d=u.match(/\/page-data\/shared\/(.*)\.json/);if(!d)return t();const f=decodeURIComponent(d[1]),h=await G(f,e.outdir),{isAuthenticated:i,teams:m,claims:{email:c}}=s.get("auth"),n=b(h,{isAuthenticated:i,email:c,teams:m},e.config.access?.rbac,e.config.access?.requiresLogin);return n?s.json(n,200,{"Cache-Control":a}):(p.error(`Shared data not found: ${u}`),s.text("Not Found",404,{"Cache-Control":a}))}}export{se as pageDataHandler,ne as sharedPageDataHandler};
1
+ import{ServerRoutes as U}from"../../../constants/api.js";import{DEV_LOGIN_SLUG as $}from"../../../constants/common.js";import{CACHE_CONTROL_NO_STORE_HEADER_VALUE as r,DEFAULT_TITLE as F}from"../../constants/common.js";import{findInIterable as N}from"../../../utils/collection/find-in-iterable.js";import{removeTrailingSlash as q}from"../../../utils/url/remove-trailing-slash.js";import{envConfig as T}from"../../config/env-config.js";import{canAccessResource as B,filterDataByAccessDeep as j,isResourcePubliclyAccessible as H}from"../../utils/rbac.js";import{getServerProps as M}from"../../ssr/index.js";import{readSharedData as G}from"../../utils/index.js";import{getRedirectLoginUrl as V}from"../utils/get-redirect-login-url.js";import{processRedirects as W}from"./helpers/process-redirects.js";import{removeErrorDetails as k}from"../utils/remove-error-details.js";import{telemetry as K}from"../../telemetry/index.js";import{MCP_NOT_ALLOWED_TEMPLATE_ID as A}from"../../plugins/mcp/constants.js";function ie(e,n){return async(t,g)=>{const m=t.get("logger"),{req:p}=t,{pathname:d}=new URL(p.url),{seo:f,ssoDirect:h}=e.getConfig(),i=f?.title||F;if(e?.compilationErrors?.length&&T.isDevelopMode)return t.json({templateId:"compilation-error",props:{compilationErrors:e?.compilationErrors},sharedDataIds:{}},500,{"Cache-Control":r});const u=d.match(/page-data(.*)data.json$/);if(!u)return g();const c=decodeURI(u[1]),s=c==="/index/"?"/":q(c),o=e.getRouteBySlug(s,{followRedirect:!1})||N(e.routesBySlug.values(),a=>a.hasClientRoutes&&c.startsWith(a.slug+"/"));if(c===U.OIDC_CALLBACK+"/")return t.json({templateId:"403OIDC",sharedDataIds:{},props:{seo:{title:`${i} - Forbidden`}}},200,{"Cache-Control":r});const{isAuthenticated:C,teams:D,claims:{name:S,picture:_,email:I}}=t.get("auth"),R={isAuthenticated:C,email:I,teams:D},l={isAuthenticated:C,name:S,picture:_,email:I,teams:D};if(s==="/mcp"&&e.templates.has(A))return t.json({templateId:A,sharedDataIds:{},props:{},userData:l},405,{"Cache-Control":r});const L=e.getRedirect(s);if(L){const a=W({redirect:L}).location;return K.sendRedirectMessage([{object:"redirect",from:s,templateId:"404"}]),t.json({templateId:"404",redirectTo:a,sharedDataIds:{},props:{}},301,{"Cache-Control":r})}if(!o){const a=e.getRouteBySlug(s,{followRedirect:!0});return m.error(`Page not found: ${d}`),t.json({templateId:"404",redirectTo:a?.slug,sharedDataIds:{},props:{seo:{title:`${i} - Not Found`}},userData:l},404,{"Cache-Control":r})}if(m.verbose(`Page viewed: ${o.slug}`),!B(o,R,e.config.access?.rbac,e.config.access?.requiresLogin)&&o.slug!==$){if(C)return t.json({templateId:"403",sharedDataIds:{},props:{seo:{title:`${i} - Forbidden`}},userData:l},403,{"Cache-Control":r});const a=Object.keys(h||{}).length>0;return t.json({templateId:"404",sharedDataIds:{},props:{seo:{title:`${i} - Not Found`}},userData:l,...a?{redirectTo:V(e,o.slug)}:{}},a?401:404,{"Cache-Control":r})}const b=j(o.versions,R,e.config.access?.rbac,e.config.access?.requiresLogin),v=e.routesSharedData.get(o.slug)||{},P=await n(o),O=await M(o,t,P,e),{sharedDataIds:y,...E}=O,w={templateId:o.templateId,versions:b,sharedDataIds:{...v,...y||{}},props:T.isProductionEnv?k(E):E,slug:o.slug,userData:l,isPublic:H(o,e.config)};return t.json(w,200,{"Cache-Control":r})}}function ce(e){return async(n,t)=>{const g=n.get("logger"),{req:m}=n,{pathname:p}=new URL(m.url),d=p.match(/\/page-data\/shared\/(.*)\.json/);if(!d)return t();const f=decodeURIComponent(d[1]),h=await G(f,e.outdir),{isAuthenticated:i,teams:u,claims:{email:c}}=n.get("auth"),s=j(h,{isAuthenticated:i,email:c,teams:u},e.config.access?.rbac,e.config.access?.requiresLogin);return s?n.json(s,200,{"Cache-Control":r}):(g.error(`Shared data not found: ${p}`),n.text("Not Found",404,{"Cache-Control":r}))}}export{ie as pageDataHandler,ce as sharedPageDataHandler};
@@ -1 +1 @@
1
- import{setCookie as E}from"hono/cookie";import{withPathPrefix as l}from"@redocly/theme/core/utils";import{DEV_LOGIN_SLUG as b}from"../../constants/common.js";import{CACHE_CONTROL_NO_STORE_HEADER_VALUE as A}from"../constants/common.js";import{getAuthProviderLoginParams as y,buildLoginUrl as C}from"./auth.js";import{renderPage as O}from"../ssr/index.js";import{telemetry as R}from"../../cli/telemetry/index.js";async function T(r,t,o,n){const{isAuthenticated:a}=r.get("auth"),e=r.req.raw.headers.get("x-forwarded-host"),i=r.req.raw.headers.get("x-forwarded-proto"),U=e?`${i==="http"||i==="https"?i:"https"}://${e}`:new URL(r.req.url).origin,u=t.getConfig().ssoDirect,p=Object.keys(u||{}),s=n||p[0],g=u?.[s];if(a)return _(r,t,{slug:o},403);const d=s&&g?await y(s,g):void 0,m=d?{...d,extraParams:{...d.extraParams,prompt:"login"}}:void 0,{loginUrl:w,cookies:h={}}=m&&C(m,U,l(o))||{},f=t.globalData.auth?.devLogin||p.length>1?v(o):w;return Object.keys(h).forEach(c=>{E(r,c,h[c].value,h[c].options)}),f?r.newResponse(null,302,{Location:f}):r.text("Unauthorized",401)}const L={};async function _(r,t,o,n,a){let e=L[n];if(!e){const i={templateId:String(a||n),fsPath:"/",...o,baseSlug:o.slug};e=(await O(i,{},r,t,R)).html,L[n]=e}return r.html(e,n,{"Cache-Control":A})}function v(r){const t=new URLSearchParams({redirectTo:l(r)});return`${l(b)}?${t}`}async function j(r){return r.text("Forbidden",P(r))}function k(r){return r.json({message:"Forbidden"},P(r))}function P(r){const{isAuthenticated:t}=r.get("auth");return t?403:401}function G(r){const t=r?.match(/(?:^|:)(\d{1,3}(?:\.\d{1,3}){3})$/);return t?t[1]:r}export{v as getLoginUrlWithRedirect,_ as handleErrorPageRender,T as handleUnauthorized,k as handleUnauthorizedApiRequest,j as handleUnauthorizedAsset,G as normalizeIpAddress};
1
+ import{setCookie as b}from"hono/cookie";import{withPathPrefix as l}from"@redocly/theme/core/utils";import{DEV_LOGIN_SLUG as A}from"../../constants/common.js";import{CACHE_CONTROL_NO_STORE_HEADER_VALUE as y}from"../constants/common.js";import{getAuthProviderLoginParams as C,buildLoginUrl as O}from"./auth.js";import{renderPage as R}from"../ssr/index.js";import{telemetry as _}from"../../cli/telemetry/index.js";async function T(r,t,o,n){const{isAuthenticated:a}=r.get("auth"),i=r.req.raw.headers.get("x-forwarded-host"),e=r.req.raw.headers.get("x-forwarded-proto"),w=i?`${e==="http"||e==="https"?e:"https"}://${i}`:new URL(r.req.url).origin,g=t.getConfig().ssoDirect,p=Object.keys(g||{}),s=n||p[0],m=g?.[s];if(a)return v(r,t,{slug:o},403);const d=s&&m?await C(s,m):void 0,f=d?{...d,extraParams:{...d.extraParams,prompt:"login"}}:void 0,{loginUrl:E,cookies:h={}}=f&&O(f,w,l(o))||{},L=t.globalData.auth?.devLogin||p.length>1?z(o):E;return Object.keys(h).forEach(c=>{b(r,c,h[c].value,h[c].options)}),L?r.newResponse(null,302,{Location:L}):r.text("Unauthorized",401)}const P={};async function v(r,t,o,n,a){const i=a||String(n);let e=P[i];if(!e){const u={templateId:String(a||n),fsPath:"/",...o,baseSlug:o.slug};e=(await R(u,{},r,t,_)).html,P[i]=e}return r.html(e,n,{"Cache-Control":y})}function z(r){const t=new URLSearchParams({redirectTo:l(r)});return`${l(A)}?${t}`}async function j(r){return r.text("Forbidden",U(r))}function k(r){return r.json({message:"Forbidden"},U(r))}function U(r){const{isAuthenticated:t}=r.get("auth");return t?403:401}function G(r){const t=r?.match(/(?:^|:)(\d{1,3}(?:\.\d{1,3}){3})$/);return t?t[1]:r}export{z as getLoginUrlWithRedirect,v as handleErrorPageRender,T as handleUnauthorized,k as handleUnauthorizedApiRequest,j as handleUnauthorizedAsset,G as normalizeIpAddress};
@@ -8,4 +8,9 @@ export type GetInnerContentFnOptions = {
8
8
  renderTag?: RenderTagFn;
9
9
  };
10
10
  export type GetInnerContentFn = (children: (RenderableTreeNode | Node | Variable | Function)[], options?: GetInnerContentFnOptions) => string;
11
+ export type ResolvedSampleBlock = {
12
+ lang?: string;
13
+ title?: string;
14
+ source: string;
15
+ };
11
16
  //# sourceMappingURL=markdoc.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/redoc-reef",
3
- "version": "0.135.0-next.5",
3
+ "version": "0.135.0-next.7",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,7 +33,7 @@
33
33
  "@opentelemetry/semantic-conventions": "1.40.0",
34
34
  "@redocly/ajv": "8.18.0",
35
35
  "@redocly/mcp-typescript-sdk": "1.18.1",
36
- "@redocly/openapi-core": "2.34.0",
36
+ "@redocly/openapi-core": "2.37.0",
37
37
  "@shikijs/transformers": "3.21.0",
38
38
  "@tanstack/react-query": "5.62.3",
39
39
  "@tanstack/react-table": "8.21.3",
@@ -93,14 +93,14 @@
93
93
  "xpath": "0.0.34",
94
94
  "yaml-ast-parser": "0.0.43",
95
95
  "zod": "^3.25.76",
96
- "@redocly/asyncapi-docs": "1.12.0-next.5",
97
- "@redocly/config": "0.49.0",
98
- "@redocly/graphql-docs": "1.12.0-next.5",
99
- "@redocly/openapi-docs": "3.23.0-next.5",
96
+ "@redocly/asyncapi-docs": "1.12.0-next.7",
97
+ "@redocly/config": "0.50.1",
98
+ "@redocly/graphql-docs": "1.12.0-next.7",
99
+ "@redocly/openapi-docs": "3.23.0-next.7",
100
100
  "@redocly/portal-legacy-ui": "0.18.0-next.0",
101
- "@redocly/portal-plugin-mock-server": "0.20.0-next.5",
102
- "@redocly/realm-asyncapi-sdk": "0.13.0-next.3",
103
- "@redocly/theme": "0.67.0-next.4"
101
+ "@redocly/portal-plugin-mock-server": "0.20.0-next.7",
102
+ "@redocly/realm-asyncapi-sdk": "0.13.0-next.4",
103
+ "@redocly/theme": "0.67.0-next.6"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^19.2.4",
@@ -1 +0,0 @@
1
- import{getOperation as E,getServerEnvName as l,normalizeOptions as x,OpenAPIParser as h,getTagOrGroup as q}from"@redocly/openapi-docs";import{getOperationInfoById as v}from"./get-operation-info-by-id";import{getOperationInfoByPointer as y}from"./get-operation-info-by-pointer";function M(s,{operationId:i,pointer:f},m,{exampleKey:r,mimeType:a,environments:p,environment:d,requestBody:g}){let o;if(i?o=v(s.definition,i):f&&(o=y(s.definition,f)),!o)return;const O=new h(s.definition,void 0,x(s.options)),u=o.tags?.[0],B=u?q("group",{name:u},void 0):void 0,n=E(O,o,B,m,"");if(a&&n.requestBody?.content?.mediaTypes&&(n.requestBody.content.mediaTypes=n.requestBody?.content?.mediaTypes.filter(e=>e.name===a)),r&&(n.requestBody?.content?.mediaTypes.forEach(e=>{if(!e.examples)return;const t=e.examples[r];e.examples=t?{[r]:t}:{}}),n.responses?.forEach(e=>{e.content?.mediaTypes?.forEach(t=>{if(!t.examples)return;const c=t.examples[r];t.examples=c?{[r]:c}:{}})})),g&&n.requestBody?.content?.mediaTypes.forEach(e=>{e.examples={}}),p&&(n.servers=n.servers.map(e=>{const t=p?.[l(e)];return t?{...e,url:t.server||e.url}:e})),d){const e=n.servers.filter(t=>d===l(t));n.servers=e.length?e:n.servers}return n}export{M as getOperation};
@@ -1,4 +0,0 @@
1
- export * from './get-operation-info-by-id';
2
- export * from './get-operation-info-by-pointer';
3
- export * from './get-operation';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- export*from"./get-operation-info-by-id";export*from"./get-operation-info-by-pointer";export*from"./get-operation";
@@ -1,4 +0,0 @@
1
- import type { GetServerPropsFn } from '../../types';
2
- declare const getServerProps: GetServerPropsFn;
3
- export default getServerProps;
4
- //# sourceMappingURL=get-server-props.d.ts.map
@@ -1 +0,0 @@
1
- import{REGISTRY_APIS_API_URL as t}from"../../constants/common.js";import{logger as o}from"../../tools/notifiers/logger.js";const a=async(p,e,r)=>{if(!r.variables?.idpAccessToken)return o.warnProd("Cannot fetch custom fields: access token not found"),e.props||{};if(!t)return o.warnProd("Cannot fetch custom fields: API URL not found in env"),e.props||{};const n={};try{const s=await fetch(t+"?limit=2000",{headers:{Cookie:`accessToken=${r.variables.idpAccessToken}`}});if(s.status!==200)return o.warnProd(`Failed to fetch custom fields. API response status: ${s.status}. Request URL: ${t}`),e.props||{};const i=await s.json();for(const c of i.items)n[c.contentPath]=c.customFields||{}}catch(s){o.warnProd("Failed to fetch custom fields: "+s.message)}return{...e.props,customFields:n}};var d=a;export{d as default};
@@ -1,2 +0,0 @@
1
- export declare function getTemplatePath(relativePath: string): string;
2
- //# sourceMappingURL=get-template-path.d.ts.map
@@ -1 +0,0 @@
1
- import{fromCurrentDir as t}from"../../utils/paths.js";function m(r){return t(import.meta.url,r)}export{m as getTemplatePath};
@@ -1,4 +0,0 @@
1
- import type { McpToolSchema } from '../../../../types';
2
- export declare function sanitizeToolName(name: string): string;
3
- export declare function buildExecuteToolDescription(tools: McpToolSchema[]): string;
4
- //# sourceMappingURL=build-execute-tool-description.d.ts.map
@@ -1,4 +0,0 @@
1
- const c=/^[A-Za-z_$][\w$]*$/;function p(e){const n=e.split(/[^A-Za-z0-9]+/).filter(Boolean).map((o,r)=>r===0?o:o[0].toUpperCase()+o.slice(1)).join("");return c.test(n)?n:`_${n}`}function y(e){return["Execute JavaScript in a sandbox to call the documentation tools below.","","Each tool is an async function on the global `tools` object.","","Do everything one request needs in a SINGLE execution: call as many tools as you need,","pass one call's output into the next, and branch or loop on intermediate results, then","`return` the final value. Each `execute` call is a full round-trip, so one script that","gathers everything is far cheaper and faster than several sequential calls. Only make","another `execute` call when you must react to something you genuinely could not","anticipate, and never repeat discovery you have already done.","","Example \u2014 one call that lists APIs, then drills into an endpoint:","","```ts","const { items } = await tools.listApis({ filter: 'billing' });","const { endpoints } = await tools.getEndpoints({ name: items[0].name });","return tools.getEndpointInfo({"," name: items[0].name,"," path: endpoints[0].path,"," method: endpoints[0].method,","});","```","","Available tools:","","Types named `OpenApi\u2026` are the standard OpenAPI Specification objects.","","```ts","declare const tools: {",e.map(n=>{const o=n.schema,r=s(o),u=n.outputSchema?s(n.outputSchema):"unknown",a=o.required?.length?"input":"input?";return` /** ${n.description} */
2
- ${p(n.name)}(${a}: ${r}): Promise<${u}>;`}).join(`
3
- `),"};","```"].join(`
4
- `)}function s(e){if(!e||typeof e!="object")return"unknown";const t=e.nullable?" | null":"";if(typeof e.codemodeType=="string")return e.codemodeType+t;if(Array.isArray(e.enum))return e.enum.map(d).join(" | ")+t;switch(e.type){case"string":return"string"+t;case"number":case"integer":return"number"+t;case"boolean":return"boolean"+t;case"array":return`Array<${s(e.items)}>`+t;case"object":return f(e)+t;default:return"unknown"}}function d(e){return typeof e=="string"?`'${e}'`:String(e)}function f(e){const t=e.properties??{},n=Object.keys(t),o=e.additionalProperties,r=o?o===!0?"unknown":s(o):void 0;if(n.length===0)return o===!1?"{}":`Record<string, ${r??"unknown"}>`;const u=new Set(e.required??[]),a=n.map(i=>{const l=u.has(i)?"":"?";return`${c.test(i)?i:JSON.stringify(i)}${l}: ${s(t[i])}`});return r&&a.push(`[key: string]: ${r}`),`{ ${a.join("; ")} }`}export{y as buildExecuteToolDescription,p as sanitizeToolName};
@@ -1,11 +0,0 @@
1
- import type { PageRouteDetails } from '../../types';
2
- import type { MdOptions } from '@redocly/config';
3
- /** Load API catalog entry custom fields from the API registry */
4
- export default function getServerProps(props: PageRouteDetails, _data: any, { variables }: MdOptions & {
5
- variables: {
6
- idpAccessToken?: string;
7
- };
8
- }): Promise<{
9
- customFields: Record<string, unknown>;
10
- }>;
11
- //# sourceMappingURL=get-server-props-custom-fields.d.ts.map
@@ -1 +0,0 @@
1
- import i from"path";import{REGISTRY_APIS_PATHS_API_URL as a}from"../../constants/common.js";import{logger as n}from"../../tools/notifiers/logger.js";async function p(r,d,{variables:o}){const c=i.posix.dirname(r.fsPath);let t={};if(o.idpAccessToken&&a)try{const s=a+"/"+encodeURIComponent(c),e=await fetch(s,{headers:{Cookie:`accessToken=${o.idpAccessToken}`}});e.status!==200?n.warnProd(`Failed to fetch custom fields. API response status: ${e.status}. Request URL: ${s}`):t=(await e.json()).customFields||{}}catch(s){n.warnProd("Failed to fetch custom fields: "+s.message)}return{customFields:t}}export{p as default};