@redocly/reef 0.137.0-next.6 → 0.137.0-next.8

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 (213) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.js +1 -1
  3. package/dist/client/templates/api-docs/helpers.d.ts +4 -1
  4. package/dist/client/templates/api-docs/helpers.js +5 -1
  5. package/dist/client/templates/api-docs/template.js +1 -1
  6. package/dist/constants/l10n/langs/ar.js +1 -1
  7. package/dist/constants/l10n/langs/de.js +1 -1
  8. package/dist/constants/l10n/langs/en.js +1 -1
  9. package/dist/constants/l10n/langs/es.js +1 -1
  10. package/dist/constants/l10n/langs/fr.js +1 -1
  11. package/dist/constants/l10n/langs/hi.js +1 -1
  12. package/dist/constants/l10n/langs/it.js +1 -1
  13. package/dist/constants/l10n/langs/ja.js +1 -1
  14. package/dist/constants/l10n/langs/ko.js +1 -1
  15. package/dist/constants/l10n/langs/pl.js +1 -1
  16. package/dist/constants/l10n/langs/pt-BR.js +1 -1
  17. package/dist/constants/l10n/langs/pt.js +1 -1
  18. package/dist/constants/l10n/langs/ru.js +1 -1
  19. package/dist/constants/l10n/langs/uk.js +1 -1
  20. package/dist/constants/l10n/langs/zh.js +1 -1
  21. package/dist/server/config/env-config.d.ts +2 -0
  22. package/dist/server/config/env-schema.d.ts +5 -0
  23. package/dist/server/config/env-schemas/feature-flags.d.ts +4 -0
  24. package/dist/server/config/env-schemas/feature-flags.js +1 -1
  25. package/dist/server/esbuild/esbuild.js +3 -3
  26. package/dist/server/esbuild/plugins/mcp-tool-handlers-resolver.js +1 -1
  27. package/dist/server/plugins/api-docs/options.js +1 -1
  28. package/dist/server/plugins/{openapi-docs/is-openapi-doc.d.ts → api-docs/utils/is-api-doc.d.ts} +4 -2
  29. package/dist/server/plugins/api-docs/utils/is-api-doc.js +1 -0
  30. package/dist/server/plugins/arazzo-docs/arazzo-doc-loader.d.ts +1 -1
  31. package/dist/server/plugins/arazzo-docs/arazzo-doc-loader.js +1 -1
  32. package/dist/server/plugins/entitlements/index.js +1 -1
  33. package/dist/server/plugins/l10n/index.js +1 -1
  34. package/dist/server/plugins/lifecycle.js +2 -2
  35. package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.js +1 -1
  36. package/dist/server/plugins/markdown/attribute-resolvers/resolve-open-api-ref.js +1 -1
  37. package/dist/server/plugins/mcp/codemode/capabilities/fetch/index.js +4 -4
  38. package/dist/server/plugins/mcp/codemode/code-execution-telemetry.d.ts +3 -1
  39. package/dist/server/plugins/mcp/codemode/code-execution-telemetry.js +1 -1
  40. package/dist/server/plugins/mcp/codemode/invoke-tool.js +1 -1
  41. package/dist/server/plugins/mcp/codemode/prompts.js +1 -1
  42. package/dist/server/plugins/mcp/codemode/sandbox/polyfills/fetch-shim.d.ts +1 -1
  43. package/dist/server/plugins/mcp/codemode/sandbox/polyfills/fetch-shim.js +9 -3
  44. package/dist/server/plugins/mcp/codemode/tools/execute.js +1 -1
  45. package/dist/server/plugins/mcp/codemode/tools/manage-credentials.js +1 -1
  46. package/dist/server/plugins/mcp/codemode/types.d.ts +1 -0
  47. package/dist/server/plugins/mcp/constants.d.ts +1 -0
  48. package/dist/server/plugins/mcp/constants.js +1 -1
  49. package/dist/server/plugins/mcp/custom-tools/extract-tool-definition.d.ts +13 -0
  50. package/dist/server/plugins/mcp/custom-tools/extract-tool-definition.js +1 -0
  51. package/dist/server/plugins/mcp/custom-tools/scan-custom-tools.d.ts +6 -0
  52. package/dist/server/plugins/mcp/custom-tools/scan-custom-tools.js +1 -0
  53. package/dist/server/plugins/mcp/custom-tools/validate-tool-definition.d.ts +3 -0
  54. package/dist/server/plugins/mcp/custom-tools/validate-tool-definition.js +1 -0
  55. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.d.ts +2 -0
  56. package/dist/server/plugins/mcp/docs-mcp/tool-schemas.js +1 -1
  57. package/dist/server/plugins/mcp/docs-mcp/tools/core/search.js +2 -2
  58. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoints.js +1 -1
  59. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/list-apis.js +1 -1
  60. package/dist/server/plugins/mcp/docs-mcp/tools/openapi/utils.js +1 -1
  61. package/dist/server/plugins/mcp/gateway-mcp/callable-apis.d.ts +10 -0
  62. package/dist/server/plugins/mcp/gateway-mcp/callable-apis.js +1 -0
  63. package/dist/server/plugins/mcp/gateway-mcp/fetch/fetch-bridge.js +1 -1
  64. package/dist/server/plugins/mcp/gateway-mcp/fetch-capability.d.ts +1 -9
  65. package/dist/server/plugins/mcp/gateway-mcp/fetch-capability.js +1 -1
  66. package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
  67. package/dist/server/plugins/mcp/handlers/errors.d.ts +7 -2
  68. package/dist/server/plugins/mcp/handlers/errors.js +1 -1
  69. package/dist/server/plugins/mcp/index.js +1 -1
  70. package/dist/server/plugins/mcp/servers/docs-server.d.ts +2 -2
  71. package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
  72. package/dist/server/plugins/mcp/servers/mcp-server.d.ts +2 -11
  73. package/dist/server/plugins/mcp/servers/mcp-server.js +3 -3
  74. package/dist/server/plugins/mcp/types.d.ts +29 -3
  75. package/dist/server/plugins/mcp/utils/available-sandbox-tools.d.ts +4 -0
  76. package/dist/server/plugins/mcp/utils/available-sandbox-tools.js +1 -0
  77. package/dist/server/plugins/mcp/utils/find-gated-tool-names.d.ts +2 -3
  78. package/dist/server/plugins/mcp/utils/find-gated-tool-names.js +1 -1
  79. package/dist/server/plugins/mcp/utils/mcp-client.d.ts +13 -0
  80. package/dist/server/plugins/mcp/utils/mcp-client.js +1 -0
  81. package/dist/server/plugins/mcp/workers/execute-mcp-tool.d.ts +6 -1
  82. package/dist/server/plugins/mcp/workers/execute-mcp-tool.js +1 -1
  83. package/dist/server/plugins/mcp/workers/import-mcp-tool-handlers.d.ts +5 -0
  84. package/dist/server/plugins/mcp/workers/import-mcp-tool-handlers.js +1 -0
  85. package/dist/server/plugins/mcp/workers/mcp-tool-telemetry.d.ts +6 -11
  86. package/dist/server/plugins/mcp/workers/mcp-tool-telemetry.js +1 -1
  87. package/dist/server/plugins/mcp/workers/tool-file-system.d.ts +6 -0
  88. package/dist/server/plugins/mcp/workers/tool-file-system.js +1 -0
  89. package/dist/server/sandbox/sandbox.js +2 -2
  90. package/dist/server/sandbox/utils/returns-from-top-level.d.ts +4 -0
  91. package/dist/server/sandbox/utils/returns-from-top-level.js +1 -0
  92. package/dist/server/store.d.ts +1 -0
  93. package/dist/server/store.js +1 -1
  94. package/dist/server/types/plugins/common.d.ts +2 -1
  95. package/dist/server/web-server/routes/resolve-route.js +1 -1
  96. package/dist/server/web-server/utils/get-request-origin.d.ts +2 -0
  97. package/dist/server/web-server/utils/get-request-origin.js +1 -1
  98. package/dist/server/workers/mcp-tool-worker-pool.d.ts +1 -0
  99. package/dist/server/workers/mcp-tool-worker-pool.js +1 -1
  100. package/dist/server/workers/mcp-tool-worker.js +1 -1
  101. package/dist/server/workers/types.d.ts +9 -2
  102. package/dist/server/workers/worker-pool.d.ts +1 -0
  103. package/dist/server/workers/worker-pool.js +1 -1
  104. package/dist/utils/guards/is-plain-object.d.ts +19 -0
  105. package/dist/utils/guards/is-plain-object.js +1 -0
  106. package/package.json +8 -11
  107. package/dist/client/templates/asyncapi-docs/helpers.d.ts +0 -12
  108. package/dist/client/templates/asyncapi-docs/helpers.js +0 -1
  109. package/dist/client/templates/asyncapi-docs/template.d.ts +0 -15
  110. package/dist/client/templates/asyncapi-docs/template.js +0 -9
  111. package/dist/client/templates/openapi-docs/helpers.d.ts +0 -18
  112. package/dist/client/templates/openapi-docs/helpers.js +0 -5
  113. package/dist/client/templates/openapi-docs/template.d.ts +0 -6
  114. package/dist/client/templates/openapi-docs/template.js +0 -14
  115. package/dist/server/esbuild/plugins/api-docs-module-replacer/empty-check.d.ts +0 -9
  116. package/dist/server/esbuild/plugins/api-docs-module-replacer/empty-check.js +0 -1
  117. package/dist/server/esbuild/plugins/api-docs-module-replacer/empty-overlay.d.ts +0 -2
  118. package/dist/server/esbuild/plugins/api-docs-module-replacer/empty-overlay.js +0 -1
  119. package/dist/server/esbuild/plugins/api-docs-module-replacer/index.d.ts +0 -6
  120. package/dist/server/esbuild/plugins/api-docs-module-replacer/index.js +0 -1
  121. package/dist/server/esbuild/plugins/openapi-docs-module-replacer/empty-check.d.ts +0 -8
  122. package/dist/server/esbuild/plugins/openapi-docs-module-replacer/empty-check.js +0 -1
  123. package/dist/server/esbuild/plugins/openapi-docs-module-replacer/empty-overlay.d.ts +0 -2
  124. package/dist/server/esbuild/plugins/openapi-docs-module-replacer/empty-overlay.js +0 -1
  125. package/dist/server/esbuild/plugins/openapi-docs-module-replacer/empty-use-license-key.d.ts +0 -5
  126. package/dist/server/esbuild/plugins/openapi-docs-module-replacer/empty-use-license-key.js +0 -1
  127. package/dist/server/esbuild/plugins/openapi-docs-module-replacer/index.d.ts +0 -6
  128. package/dist/server/esbuild/plugins/openapi-docs-module-replacer/index.js +0 -1
  129. package/dist/server/esbuild/plugins/openapi-docs-module-replacer/loadAndBundleSpec.mock.d.ts +0 -3
  130. package/dist/server/esbuild/plugins/openapi-docs-module-replacer/loadAndBundleSpec.mock.js +0 -1
  131. package/dist/server/plugins/asyncapi-docs/asyncapi-doc-loader.d.ts +0 -18
  132. package/dist/server/plugins/asyncapi-docs/asyncapi-doc-loader.js +0 -5
  133. package/dist/server/plugins/asyncapi-docs/get-server-props.d.ts +0 -4
  134. package/dist/server/plugins/asyncapi-docs/get-server-props.js +0 -1
  135. package/dist/server/plugins/asyncapi-docs/get-template-path.d.ts +0 -2
  136. package/dist/server/plugins/asyncapi-docs/get-template-path.js +0 -1
  137. package/dist/server/plugins/asyncapi-docs/index.d.ts +0 -3
  138. package/dist/server/plugins/asyncapi-docs/index.js +0 -1
  139. package/dist/server/plugins/asyncapi-docs/is-asyncapi-doc.d.ts +0 -3
  140. package/dist/server/plugins/asyncapi-docs/is-asyncapi-doc.js +0 -1
  141. package/dist/server/plugins/asyncapi-docs/search/get-ai-search-documents.d.ts +0 -9
  142. package/dist/server/plugins/asyncapi-docs/search/get-ai-search-documents.js +0 -56
  143. package/dist/server/plugins/asyncapi-docs/search/schema-processor.d.ts +0 -8
  144. package/dist/server/plugins/asyncapi-docs/search/schema-processor.js +0 -1
  145. package/dist/server/plugins/asyncapi-docs/search/search-facets.d.ts +0 -8
  146. package/dist/server/plugins/asyncapi-docs/search/search-facets.js +0 -1
  147. package/dist/server/plugins/asyncapi-docs/search/search-resolver.d.ts +0 -5
  148. package/dist/server/plugins/asyncapi-docs/search/search-resolver.js +0 -1
  149. package/dist/server/plugins/asyncapi-docs/store-definition-bundles.d.ts +0 -4
  150. package/dist/server/plugins/asyncapi-docs/store-definition-bundles.js +0 -1
  151. package/dist/server/plugins/graphql-docs/constants.d.ts +0 -2
  152. package/dist/server/plugins/graphql-docs/constants.js +0 -1
  153. package/dist/server/plugins/graphql-docs/get-template-path.d.ts +0 -2
  154. package/dist/server/plugins/graphql-docs/get-template-path.js +0 -1
  155. package/dist/server/plugins/graphql-docs/graphql-doc-loader.d.ts +0 -17
  156. package/dist/server/plugins/graphql-docs/graphql-doc-loader.js +0 -1
  157. package/dist/server/plugins/graphql-docs/index.d.ts +0 -4
  158. package/dist/server/plugins/graphql-docs/index.js +0 -1
  159. package/dist/server/plugins/graphql-docs/is-graphql-doc.d.ts +0 -2
  160. package/dist/server/plugins/graphql-docs/is-graphql-doc.js +0 -1
  161. package/dist/server/plugins/graphql-docs/search/ai/get-ai-search-document.d.ts +0 -17
  162. package/dist/server/plugins/graphql-docs/search/ai/get-ai-search-document.js +0 -4
  163. package/dist/server/plugins/graphql-docs/search/ai/utils.d.ts +0 -14
  164. package/dist/server/plugins/graphql-docs/search/ai/utils.js +0 -36
  165. package/dist/server/plugins/graphql-docs/search/search-facets.d.ts +0 -8
  166. package/dist/server/plugins/graphql-docs/search/search-facets.js +0 -1
  167. package/dist/server/plugins/graphql-docs/search/search-resolver.d.ts +0 -5
  168. package/dist/server/plugins/graphql-docs/search/search-resolver.js +0 -1
  169. package/dist/server/plugins/graphql-docs/spec-download.api.d.ts +0 -3
  170. package/dist/server/plugins/graphql-docs/spec-download.api.js +0 -1
  171. package/dist/server/plugins/graphql-docs/template/GraphQLDocs.d.ts +0 -5
  172. package/dist/server/plugins/graphql-docs/template/GraphQLDocs.js +0 -4
  173. package/dist/server/plugins/graphql-docs/types.d.ts +0 -40
  174. package/dist/server/plugins/graphql-docs/types.js +0 -0
  175. package/dist/server/plugins/openapi-docs/ai-search-indexer.d.ts +0 -14
  176. package/dist/server/plugins/openapi-docs/ai-search-indexer.js +0 -1
  177. package/dist/server/plugins/openapi-docs/decorators.d.ts +0 -25
  178. package/dist/server/plugins/openapi-docs/decorators.js +0 -1
  179. package/dist/server/plugins/openapi-docs/format-bundle-error.d.ts +0 -6
  180. package/dist/server/plugins/openapi-docs/format-bundle-error.js +0 -5
  181. package/dist/server/plugins/openapi-docs/get-server-props.d.ts +0 -4
  182. package/dist/server/plugins/openapi-docs/get-server-props.js +0 -1
  183. package/dist/server/plugins/openapi-docs/get-template-path.d.ts +0 -2
  184. package/dist/server/plugins/openapi-docs/get-template-path.js +0 -1
  185. package/dist/server/plugins/openapi-docs/index.d.ts +0 -3
  186. package/dist/server/plugins/openapi-docs/index.js +0 -1
  187. package/dist/server/plugins/openapi-docs/is-openapi-doc.js +0 -1
  188. package/dist/server/plugins/openapi-docs/load-definition.d.ts +0 -31
  189. package/dist/server/plugins/openapi-docs/load-definition.js +0 -3
  190. package/dist/server/plugins/openapi-docs/openapi-search-builder.d.ts +0 -24
  191. package/dist/server/plugins/openapi-docs/openapi-search-builder.js +0 -1
  192. package/dist/server/plugins/openapi-docs/search/get-ai-search-documents.d.ts +0 -18
  193. package/dist/server/plugins/openapi-docs/search/get-ai-search-documents.js +0 -94
  194. package/dist/server/plugins/openapi-docs/search/search-facets.d.ts +0 -11
  195. package/dist/server/plugins/openapi-docs/search/search-facets.js +0 -1
  196. package/dist/server/plugins/openapi-docs/search/search-resolver.d.ts +0 -5
  197. package/dist/server/plugins/openapi-docs/search/search-resolver.js +0 -1
  198. package/dist/server/plugins/openapi-docs/search-indexer.d.ts +0 -17
  199. package/dist/server/plugins/openapi-docs/search-indexer.js +0 -1
  200. package/dist/server/plugins/openapi-docs/spec-download.api.d.ts +0 -4
  201. package/dist/server/plugins/openapi-docs/spec-download.api.js +0 -1
  202. package/dist/server/plugins/openapi-docs/store-definition-bundles.d.ts +0 -4
  203. package/dist/server/plugins/openapi-docs/store-definition-bundles.js +0 -1
  204. package/dist/server/plugins/openapi-docs/types.d.ts +0 -17
  205. package/dist/server/plugins/openapi-docs/types.js +0 -0
  206. package/dist/server/plugins/openapi-docs/utils.d.ts +0 -25
  207. package/dist/server/plugins/openapi-docs/utils.js +0 -1
  208. /package/dist/client/templates/{openapi-docs → api-docs}/mock-server-config.d.ts +0 -0
  209. /package/dist/client/templates/{openapi-docs → api-docs}/mock-server-config.js +0 -0
  210. /package/dist/{server/plugins → markdoc}/helpers/parse-partials.d.ts +0 -0
  211. /package/dist/{server/plugins → markdoc}/helpers/parse-partials.js +0 -0
  212. /package/dist/server/plugins/{openapi-docs → api-docs/utils}/ast-utils.d.ts +0 -0
  213. /package/dist/server/plugins/{openapi-docs → api-docs/utils}/ast-utils.js +0 -0
@@ -1 +1 @@
1
- import C 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 R}from"./constants/entitlements.js";import{MARKDOC_PARTIALS_DATA_KEY as m,MARKDOC_PARTIALS_DEPS_KEY as O}from"./constants/common.js";import{isObject as M}from"../utils/guards/is-object.js";import{mapObject as k}from"../utils/object/map-object.js";import{getValueDeep as y}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 D}from"../utils/path/is-local-link.js";import{reporter as S}from"./tools/notifiers/reporter.js";import{logger as u}from"./tools/notifiers/logger.js";import{sha1 as H}from"./utils/crypto/sha1.js";import{envConfig as G,setEnv as _}from"./config/env-config.js";import{KvService as B}from"./persistence/kv/services/kv-service.js";import{SandboxContext as F}from"./utils/sandbox-context.js";import{writeSharedData as I}from"./utils/index.js";import{renderComponents as N}from"./ssr/render.js";import{readStaticData as V,writeStaticData as q}from"./utils/static-data.js";import{parseAndResolveMarkdoc as j}from"./plugins/markdown/compiler.js";import{getMarkdocOptions as U}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as w}from"./entitlements/entitlements-provider.js";import{isL10nPath as K}from"./fs/utils/is-l10n-path.js";import{resolveGlobMapValue as x}from"./utils/globs.js";import{replaceEnvVariablesDeep as J}from"./utils/envs/replace-env-variables-deep.js";import{findRedirect as W}from"./utils/redirects/find-redirect.js";import{followRedirectChain as $}from"./utils/redirects/follow-redirect-chain.js";import{addWildcardRedirectToTree as z}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as Y}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",skills:"map"},E="PLAN_GATES",Z=["OAUTH_CLIENT_ID","OAUTH_CLIENT_SECRET","ORGANIZATION_SLUG","ORGANIZATION_ID","ORG_ID"],Me="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;skills=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:t,serverMode:s=!1,serverOutDir:a}){this.#i=t,this.outdir=e,this.serverMode=s,this.serverOutDir=a,F.register({serverOutDir:a,readRoots:[e,process.cwd()]}),this.userCodeReady=new Promise(r=>{this.#n=r})}on(e,t){const s=this.listeners.get(e);s?s.add(t):this.listeners.set(e,new Set([t]))}queueEvent=(e,t,...s)=>{this.#a.set(e+String(t),[e,t,...s])};runListeners=(e,t,...s)=>{for(const a of this.listeners.get(e)||new Set)t?a(t,...s):a(...s)};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 Y("com.redocly.build.reloadMarkdocOptions",async()=>{const e=w.instance(),t=await U(this.serverOutDir),s=Object.fromEntries(Object.entries(t.tags).filter(([a])=>R[a]!=null?e.canAccessFeature(R[a]):!0));this.#o={...t,tags:s}})}get markdocOptions(){return{...this.#o,partials:this.getGlobalConfig(m),themeConfig:this.config.markdown}}setGlobalData=e=>{const t=this.globalData,s={...this.globalData,...e};this.globalData=s,JSON.stringify(s)!==JSON.stringify(t)&&this.queueEvent("global-data-updated",void 0,s)};getGlobalData=()=>this.globalData;getKv=async()=>B.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async({input:e,context:t,deps:s,resource:a})=>{const{data:{info:r,ast:o},compoundHash:l}=await j(e,this.markdocOptions,{actions:this,context:t},a);for(const i of r.sharedDataDeps||[]){for(const n of s?.routeSlugs||[])this.addRouteSharedData(n,i,i);for(const n of s?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(i),this.sharedDataDeps.set(n,c)}}for(const i of r.dynamicMarkdocComponents||[]){for(const n of s?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(i),this.routesDynamicComponents.set(n,c)}for(const n of s?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(i),this.sharedDataMarkdocComponents.set(n,c)}}if(s?.routeSlugs&&r.partials?.length)for(const i of s.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 loadApiDocuments(e){return(await e.cache.load(".","api-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setGlobalConfig=e=>{const t=Object.keys(e);for(const o of t)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:s,unsetEnvVars:a,replacedValues:r}=J(e);for(const o of a)this.unsetEnvVars.add(o);Object.assign(this.replacedEnvVars,r),Object.assign(this.config,s)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,t,s={})=>{if(!w.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const o=h(e).toLowerCase();this.config.redirects[o]=t;const{trackOriginalSource:l=!0}=s,i=this.getGlobalConfig("originalRedirectSources");l&&Array.isArray(i)&&!i.includes(o)&&i.push(o),o.endsWith("*")&&z(this.config.wildcardRedirectsTree,o)};getRedirect=e=>{const t=h(e).toLowerCase(),s=W(t,this.config.redirects,this.config.wildcardRedirectsTree);if(!s)return null;if(D(s.to)){const a=h(s.to).toLowerCase();if(!a.endsWith("*")&&$(a,[t],this.config.redirects,this.config.wildcardRedirectsTree).type==="cycle")return null}return{to:s.to,type:s.type}};createSharedData=async(e,t,s)=>{if(s&&this.#t[e]===s)return e;const a=JSON.stringify(t),r=s??H(a);return this.#t[e]===r||(this.#t[e]=r,await I(e,a,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,t,s)=>{const a=L(e),r=this.routesSharedData.get(a)||{};r[t]=s,this.routesSharedData.set(a,r),u.verbose(`Adding shared data to ${e}, ${t}, ${s}`)};getRouteSharedDataByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.routesSharedData.get(t)||{}:{}};getPartialsForRoute=e=>{const t=this.getGlobalConfig(m)||{},s=this.routesPartials.get(e);if(!s||s.length===0)return{};const a=this.getGlobalConfig(O)||{},r=new Set(s),o=Array.from(s);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)t[i]&&(l[i]=t[i]);return l};addRoute=e=>{const s={...x(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:s}),u.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,t,s)=>{const 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,t,s)}};addApiRoute=e=>{this.apiRoutes.push(e),u.verbose("Created API route %s",e.slug)};addMcpTools=(e,t)=>{for(const s of t)this.mcpToolHandlers.set(s.name,{...s,importPath:e}),u.verbose("Created MCP tool %s",s.name)};getMcpTools=()=>Array.from(this.mcpToolHandlers.values());markGatedMcpTools=e=>{for(const t of e){const s=this.mcpToolHandlers.get(t);s&&this.mcpToolHandlers.set(t,{...s,hasAvailabilityGate:!0})}};addSkills=e=>{for(const t of e)this.skills.set(t.slug,t),u.verbose("Discovered skill %s",t.slug)};getSkills=()=>Array.from(this.skills.values());addMiddleware=e=>{this.middleware.push(e),u.verbose("Created middleware %s",e.id)};setResourceResponseHeaders=(e,t)=>{this.config.responseHeaders||(this.config.responseHeaders={});const s=new Set(t.map(o=>o.name.toLowerCase())),r=[...(this.config.responseHeaders[e]??[]).filter(o=>!s.has(o.name.toLowerCase())),...t];this.config.responseHeaders[e]=r};getRouteByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.getRouteBySlug(t):void 0};getRouteBySlug=(e,t={})=>{const{followRedirect:s=!0}=t,a=this.getRedirect(e);return s&&a?this.routesBySlug.get(h(a.to)):this.routesBySlug.get(e)};hasRouteOrRedirectBySlug=e=>{if(this.routesBySlug.has(e))return!0;const t=this.getRedirect(e);if(!t)return!1;if(!D(t.to))return!0;const s=h(t.to);return this.routesBySlug.has(s)};getRoutesByTemplateId=e=>this.newRoutes.filter(t=>t.templateId===e);getAllRoutesForLocale=(e=g)=>{const t=Array.from(this.routesBySlug.values()),s=e.toLowerCase();return t.filter(a=>e===g?!K(a.fsPath):a.slug.startsWith(`/${s}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,t)=>(this.templates.set(e,t),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};createRequestHandler=(e,t)=>(this.apiRoutesRequestHandlers.set(e,t),e);clearRequestHandlersByPrefix=e=>{for(const t of this.apiRoutesRequestHandlers.keys())t.startsWith(e)&&this.apiRoutesRequestHandlers.delete(t)};registerServerPropsGetter=(e,t)=>(this.serverPropsGetters.set(e,t),e);registerPagePropsGetter=(e,t)=>{this.pagePropsGetters.set(e,t)};async writeRouteStaticData(e,t){const s=await this.resolveRouteStaticData(e,t,!1);s&&q(e.slug,s,this.outdir)}async resolveRouteStaticData(e,t,s){if(this.serverMode)return V(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:s||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,t){if(!e?.length)return;const s=typeof e[0]=="string"?e.join(""):N(e);s&&(t==="head"?this.ssr.headTags.push(s):t==="preBody"?this.ssr.preBodyTags.push(s):this.ssr.postBodyTags.push(s))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.skills.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const e=[];for(const[s,a]of Object.entries(v))switch(a){case"map":const r=Array.from(this[s].entries());e.push([s,r]);break;case"object":s==="config"&&e.push([s,await this.getConfigWithEnvPlaceholders()]),e.push([s,this[s]]);break;default:throw new Error("Invalid format")}const t=Object.fromEntries(e);return t[E]=G.PLAN_GATES,t}static fromJson(e,t){const s=new P(t);for(const[r,o]of Object.entries(v))switch(o){case"map":s[r]=new Map(e[r]);break;case"object":if(r==="config"){s.setGlobalConfig(e[r]);break}s[r]=e[r];break;default:throw new Error("Invalid format")}s.config[m]=Q(s.config[m]||{});const a=e[E];return a&&_("PLAN_GATES",a),s}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const t in this.replacedEnvVars){const{original:s}=this.replacedEnvVars[t],a=t.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 ${t}`);continue}l[r]=s}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(s=>!Z.includes(s));if(e.length===0)return;const t=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await S.panicOnBuildContentError(t)}}function Q(b){return k(b,e=>C.Ast.fromJSON(JSON.stringify(e)))}export{P as Store,Me as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
1
+ import C 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 R}from"./constants/entitlements.js";import{MARKDOC_PARTIALS_DATA_KEY as m,MARKDOC_PARTIALS_DEPS_KEY as M}from"./constants/common.js";import{isObject as O}from"../utils/guards/is-object.js";import{mapObject as k}from"../utils/object/map-object.js";import{getValueDeep as y}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 D}from"../utils/path/is-local-link.js";import{reporter as S}from"./tools/notifiers/reporter.js";import{logger as u}from"./tools/notifiers/logger.js";import{sha1 as H}from"./utils/crypto/sha1.js";import{envConfig as G,setEnv as _}from"./config/env-config.js";import{KvService as B}from"./persistence/kv/services/kv-service.js";import{SandboxContext as F}from"./utils/sandbox-context.js";import{writeSharedData as I}from"./utils/index.js";import{renderComponents as N}from"./ssr/render.js";import{readStaticData as V,writeStaticData as q}from"./utils/static-data.js";import{parseAndResolveMarkdoc as j}from"./plugins/markdown/compiler.js";import{getMarkdocOptions as U}from"./plugins/markdown/markdoc/markdoc-options.js";import{EntitlementsProvider as w}from"./entitlements/entitlements-provider.js";import{isL10nPath as x}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 W}from"./utils/redirects/find-redirect.js";import{followRedirectChain as $}from"./utils/redirects/follow-redirect-chain.js";import{addWildcardRedirectToTree as z}from"./utils/redirects/add-wildcard-redirect-to-tree.js";import{telemetryTraceStep as Y}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",skills:"map"},E="PLAN_GATES",Z=["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;skills=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:t,serverMode:s=!1,serverOutDir:r}){this.#i=t,this.outdir=e,this.serverMode=s,this.serverOutDir=r,F.register({serverOutDir:r,readRoots:[e,process.cwd()]}),this.userCodeReady=new Promise(a=>{this.#n=a})}on(e,t){const s=this.listeners.get(e);s?s.add(t):this.listeners.set(e,new Set([t]))}queueEvent=(e,t,...s)=>{this.#a.set(e+String(t),[e,t,...s])};runListeners=(e,t,...s)=>{for(const r of this.listeners.get(e)||new Set)t?r(t,...s):r(...s)};startPluginsRun(){this.clear(),this.#s=new Promise(e=>{this.#c=e})}waitForPluginsLifecycle(){return Promise.all([this.#s,this.#l,this.#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 Y("com.redocly.build.reloadMarkdocOptions",async()=>{const e=w.instance(),t=await U(this.serverOutDir),s=Object.fromEntries(Object.entries(t.tags).filter(([r])=>R[r]!=null?e.canAccessFeature(R[r]):!0));this.#o={...t,tags:s}})}get markdocOptions(){return{...this.#o,partials:this.getGlobalConfig(m),themeConfig:this.config.markdown}}setGlobalData=e=>{const t=this.globalData,s={...this.globalData,...e};this.globalData=s,JSON.stringify(s)!==JSON.stringify(t)&&this.queueEvent("global-data-updated",void 0,s)};getGlobalData=()=>this.globalData;getKv=async()=>B.getInstance({baseDbDir:this.serverOutDir});parseMarkdoc=async({input:e,context:t,deps:s,resource:r})=>{const{data:{info:a,ast:o},compoundHash:l}=await j(e,this.markdocOptions,{actions:this,context:t},r);for(const i of a.sharedDataDeps||[]){for(const n of s?.routeSlugs||[])this.addRouteSharedData(n,i,i);for(const n of s?.sharedDataIds||[]){const c=this.sharedDataDeps.get(n)||new Set;c.add(i),this.sharedDataDeps.set(n,c)}}for(const i of a.dynamicMarkdocComponents||[]){for(const n of s?.routeSlugs||[]){const c=this.routesDynamicComponents.get(n)||new Set;c.add(i),this.routesDynamicComponents.set(n,c)}for(const n of s?.sharedDataIds||[]){const c=this.sharedDataMarkdocComponents.get(n)||new Set;c.add(i),this.sharedDataMarkdocComponents.set(n,c)}}if(s?.routeSlugs&&a.partials?.length)for(const i of s.routeSlugs){const n=this.routesPartials.get(i)||[];for(const c of a.partials)n.includes(c)||n.push(c);this.routesPartials.set(i,n)}return{info:a,ast:o,compoundHash:l}};async loadApiDocuments(e){return(await e.cache.load(".","api-docs")).data}setSearchEngine(e){this.searchEngine=e}setSearchFacets=e=>{this.searchFacets=e};setGlobalConfig=e=>{const t=Object.keys(e);for(const o of t)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:s,unsetEnvVars:r,replacedValues:a}=J(e);for(const o of r)this.unsetEnvVars.add(o);Object.assign(this.replacedEnvVars,a),Object.assign(this.config,s)};getConfig=()=>this.config;getGlobalConfig=e=>this.config[e];getSearchFacets=()=>this.searchFacets;addRedirect=(e,t,s={})=>{if(!w.instance().canAccessFeature("redirects")&&e!=="/")return;this.config.redirects||(this.config.redirects={});const o=h(e).toLowerCase();this.config.redirects[o]=t;const{trackOriginalSource:l=!0}=s,i=this.getGlobalConfig("originalRedirectSources");l&&Array.isArray(i)&&!i.includes(o)&&i.push(o),o.endsWith("*")&&z(this.config.wildcardRedirectsTree,o)};getRedirect=e=>{const t=h(e).toLowerCase(),s=W(t,this.config.redirects,this.config.wildcardRedirectsTree);if(!s)return null;if(D(s.to)){const r=h(s.to).toLowerCase();if(!r.endsWith("*")&&$(r,[t],this.config.redirects,this.config.wildcardRedirectsTree).type==="cycle")return null}return{to:s.to,type:s.type}};createSharedData=async(e,t,s)=>{if(s&&this.#t[e]===s)return e;const r=JSON.stringify(t),a=s??H(r);return this.#t[e]===a||(this.#t[e]=a,await I(e,r,this.outdir),this.queueEvent("shared-data-updated",e)),e};addRouteSharedData=(e,t,s)=>{const r=L(e),a=this.routesSharedData.get(r)||{};a[t]=s,this.routesSharedData.set(r,a),u.verbose(`Adding shared data to ${e}, ${t}, ${s}`)};getRouteSharedDataByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.routesSharedData.get(t)||{}:{}};getPartialsForRoute=e=>{const t=this.getGlobalConfig(m)||{},s=this.routesPartials.get(e);if(!s||s.length===0)return{};const r=this.getGlobalConfig(M)||{},a=new Set(s),o=Array.from(s);for(let i=0;i<o.length;i++){const n=o[i],c=r[n]?.partials??[];for(const d of c)a.has(d)||(a.add(d),o.push(d))}const l={};for(const i of a)t[i]&&(l[i]=t[i]);return l};addRoute=e=>{const s={...K(e.fsPath,this.config.metadataGlobs),...e.metadata||{}};this.newRoutes.push({...e,metadata:s}),u.verbose("Created route %s",e.slug)};addRouteSharedDataToAllLocales=(e,t,s)=>{const r=[g,...this.lifecycleContext?.fs.localeFolders||[]].map(a=>({code:a,name:a}));for(const a of r){const o=A(e,g,a.code,r);this.addRouteSharedData(o,t,s)}};addApiRoute=e=>{this.apiRoutes.push(e),u.verbose("Created API route %s",e.slug)};addMcpTools=(e,t)=>{for(const s of t){const r=this.mcpToolHandlers.get(s.name);r&&r.importPath!==e&&u.warn('MCP tool "%s" from %s overwrites the tool registered from %s',s.name,e,r.importPath),this.mcpToolHandlers.set(s.name,{...s,importPath:e}),u.verbose("Created MCP tool %s",s.name)}};getMcpTools=()=>Array.from(this.mcpToolHandlers.values());markGatedMcpTools=e=>{for(const t of e){const s=this.mcpToolHandlers.get(t);s&&this.mcpToolHandlers.set(t,{...s,hasAvailabilityGate:!0})}};addSkills=e=>{for(const t of e)this.skills.set(t.slug,t),u.verbose("Discovered skill %s",t.slug)};getSkills=()=>Array.from(this.skills.values());removeMcpTools=e=>{for(const t of e)this.mcpToolHandlers.delete(t)};addMiddleware=e=>{this.middleware.push(e),u.verbose("Created middleware %s",e.id)};setResourceResponseHeaders=(e,t)=>{this.config.responseHeaders||(this.config.responseHeaders={});const s=new Set(t.map(o=>o.name.toLowerCase())),a=[...(this.config.responseHeaders[e]??[]).filter(o=>!s.has(o.name.toLowerCase())),...t];this.config.responseHeaders[e]=a};getRouteByFsPath=e=>{const t=this.routesByFsPath.get(e);return t?this.getRouteBySlug(t):void 0};getRouteBySlug=(e,t={})=>{const{followRedirect:s=!0}=t,r=this.getRedirect(e);return s&&r?this.routesBySlug.get(h(r.to)):this.routesBySlug.get(e)};hasRouteOrRedirectBySlug=e=>{if(this.routesBySlug.has(e))return!0;const t=this.getRedirect(e);if(!t)return!1;if(!D(t.to))return!0;const s=h(t.to);return this.routesBySlug.has(s)};getRoutesByTemplateId=e=>this.newRoutes.filter(t=>t.templateId===e);getAllRoutesForLocale=(e=g)=>{const t=Array.from(this.routesBySlug.values()),s=e.toLowerCase();return t.filter(r=>e===g?!x(r.fsPath):r.slug.startsWith(`/${s}`))};getAllRoutes=()=>Array.from(this.routesBySlug.values());getAllApiRoutes=()=>this.apiRoutes;getAllMiddleware=()=>this.middleware;getTemplate=e=>this.templates.get(e);getRequestHandler=e=>this.apiRoutesRequestHandlers.get(e);createTemplate=(e,t)=>(this.templates.set(e,t),e);addBrowserPlugin=e=>{this.browserPlugins.add(e)};createRequestHandler=(e,t)=>(this.apiRoutesRequestHandlers.set(e,t),e);clearRequestHandlersByPrefix=e=>{for(const t of this.apiRoutesRequestHandlers.keys())t.startsWith(e)&&this.apiRoutesRequestHandlers.delete(t)};registerServerPropsGetter=(e,t)=>(this.serverPropsGetters.set(e,t),e);registerPagePropsGetter=(e,t)=>{this.pagePropsGetters.set(e,t)};async writeRouteStaticData(e,t){const s=await this.resolveRouteStaticData(e,t,!1);s&&q(e.slug,s,this.outdir)}async resolveRouteStaticData(e,t,s){if(this.serverMode)return V(e.slug,this.outdir);const r={...this,contentDir:this.contentDir,parseMarkdoc:({input:c,context:d,resource:f})=>this.parseMarkdoc({input:c,context:d,deps:{routeSlugs:[e.slug]},resource:f})},a=await e.getStaticData?.(e,r)||{},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=a?.frontmatter||{};return{...a,frontmatter:{...n,seo:{...n?.seo,title:n?.seo?.title||await e.getNavText?.()}},props:{...a.props,dynamicMarkdocComponents:Array.from(o),metadata:{...a?.props?.metadata,...e.metadata},seo:{title:T,...i,...a.props?.seo},compilationErrors:this.compilationErrors},lastModified:s||!e.fsPath?null:await this.lifecycleContext?.fs.getLastModified(e.fsPath)}}addSsrComponents(e,t){if(!e?.length)return;const s=typeof e[0]=="string"?e.join(""):N(e);s&&(t==="head"?this.ssr.headTags.push(s):t==="preBody"?this.ssr.preBodyTags.push(s):this.ssr.postBodyTags.push(s))}clear=()=>{this.routesByFsPath.clear(),this.templates.clear(),this.newRoutes=[],this.routesBySlug.clear(),this.apiRoutes=[],this.middleware=[],this.routesSharedData.clear(),this.sharedDataDeps.clear(),this.sharedDataMarkdocComponents.clear(),this.routesDynamicComponents.clear(),this.routesPartials.clear(),this.skills.clear(),this.config.redirects={},this.config.wildcardRedirectsTree={},this.config.directoryPermissions={},this.ssr={preBodyTags:[],postBodyTags:[],headTags:[]}};async toJson(){const e=[];for(const[s,r]of Object.entries(v))switch(r){case"map":const a=Array.from(this[s].entries());e.push([s,a]);break;case"object":s==="config"&&e.push([s,await this.getConfigWithEnvPlaceholders()]),e.push([s,this[s]]);break;default:throw new Error("Invalid format")}const t=Object.fromEntries(e);return t[E]=G.PLAN_GATES,t}static fromJson(e,t){const s=new P(t);for(const[a,o]of Object.entries(v))switch(o){case"map":s[a]=new Map(e[a]);break;case"object":if(a==="config"){s.setGlobalConfig(e[a]);break}s[a]=e[a];break;default:throw new Error("Invalid format")}s.config[m]=Q(s.config[m]||{});const r=e[E];return r&&_("PLAN_GATES",r),s}async getConfigWithEnvPlaceholders(){const e=JSON.parse(JSON.stringify(this.config));for(const t in this.replacedEnvVars){const{original:s}=this.replacedEnvVars[t],r=t.split(":"),a=r.pop(),{error:o,value:l}=y(e,r);if(o||!O(l)&&!Array.isArray(l)){await S.panicOnBuild(`Failed to replace env var with env name for ${t}`);continue}l[a]=s}return e}async reportUnsetEnvVars(){if(this.unsetEnvVars.size===0)return;const e=Array.from(this.unsetEnvVars).filter(s=>!Z.includes(s));if(e.length===0)return;const t=`Failed to resolve config. The following environment variables are not set: ${e.join(", ")}`;await S.panicOnBuildContentError(t)}}function Q(b){return k(b,e=>C.Ast.fromJSON(JSON.stringify(e)))}export{P as Store,Oe as USER_DEFINED_API_FUNCTIONS_COUNTER_KEY};
@@ -128,10 +128,10 @@ export type McpToolSchema = {
128
128
  schema: Record<string, unknown>;
129
129
  outputSchema?: Record<string, unknown>;
130
130
  annotations?: ToolAnnotations;
131
+ hasAvailabilityGate?: boolean;
131
132
  };
132
133
  export type McpToolRegistration = McpToolSchema & {
133
134
  importPath: string;
134
- hasAvailabilityGate?: boolean;
135
135
  };
136
136
  export type MiddlewareDetails = {
137
137
  id: string;
@@ -164,6 +164,7 @@ export type ProcessContentActions = {
164
164
  addApiRoute: (route: ApiRoute) => void;
165
165
  addMcpTools: (importPath: string, tools: McpToolSchema[]) => void;
166
166
  getMcpTools: () => McpToolRegistration[];
167
+ removeMcpTools: (names: string[]) => void;
167
168
  createRequestHandler: (id: string, importPath: string) => void;
168
169
  clearRequestHandlersByPrefix: (prefix: string) => void;
169
170
  addRedirect: (from: string, to: RedirectConfig, options?: RedirectOptions) => void;
@@ -1 +1 @@
1
- import{Source as P}from"@redocly/openapi-core";import y from"node:fs/promises";import S from"node:path";import{withPathPrefix as j,getPathPrefix as h,combineUrls as w}from"@redocly/theme/core/utils";import{API_DOCS_SHARED_DATA_PREFIX as d}from"../../constants/plugins/api-docs.js";import{CATALOG_BASE_SLUG as b,CATALOG_SLUGS as $}from"../../../constants/catalog-entities.js";import{CATALOG_ENTITIES_FILES_REGEX as I}from"../../constants/plugins/catalog-entities.js";import{removeTrailingSlash as E}from"../../../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as N}from"../../../utils/path/normalize-route-slug.js";import{promiseMapLimit as T}from"../../utils/async/promise-map-limit.js";import{getRoutesByLines as L,getPointerPosition as U}from"../../plugins/openapi-docs/ast-utils.js";import{readSharedData as m}from"../../utils/index.js";const q=new Set(["openapi","asyncapi"]);function K(n){return async t=>{const i=await t.req.json(),r=decodeURI(E(i.split("?")[0])),[o]=r.split("#"),g=h(),f=N(o.slice(g.length)),u=f.startsWith(b)?b:f,e=n.getRouteBySlug(u);if(e){const p=n.getRouteByFsPath(e.fsPath);if(p?.metadata?.type&&q.has(p.metadata.type)){const a=await m(`${d}${e.fsPath}`,n.outdir);if(!a?.routesMapping)return t.json({route:e},200);const s=Object.keys(a.routesMapping).find(c=>w(e.baseSlug,a.routesMapping[c])===r);if(!a.sourcePath)return t.json({route:e},200);let l;if(s){const c=S.join(n.contentDir,e.fsPath),R=await y.readFile(c,"utf-8"),_=new P(c,R);l=U(s,_)}return t.json({route:{fsPath:e.fsPath,pointer:s,position:l}},200)}if(p?.metadata?.type==="graphql"){const a=await m(`${d}${e.fsPath}`,n.outdir);if(!a?.graphqlPositions)return t.json({route:e},200);const s=Object.keys(a.graphqlPositions).find(c=>w(e.baseSlug,c)===r),l=s?a.graphqlPositions[s].position:void 0;return t.json({route:{fsPath:e.fsPath,position:l}},200)}}return t.json({route:e},200)}}function X(n){return async t=>{const i=await t.req.json(),r=await T(i,5,async o=>A(o,n));return t.json({routes:r},200)}}function Y(n){return async t=>{const i=await t.req.json(),r=await A(i,n);return t.json(r,200)}}function J(n){return async t=>{const i=(t.req.query("lines")||"").split(",").map(f=>parseInt(f)),r=t.req.query("file");if(!r)return t.json("No data",400);const o=await m(`${d}${r}`,n.outdir),g=S.join(n.contentDir,r);try{const f=await y.readFile(g,"utf-8");if(!o)return t.json("No data",400);const u=new P(g,f),e=L(i,u,o.routesMapping,o.baseSlug);return t.json(e,200)}catch{return t.json("No data",400)}}}async function A(n,t){const[i,r]=n.split(":");if(I.test(i))return{route:{slug:`${b}/${$.ALL}`}};let o=t.getRouteByFsPath(i);if(o?.metadata?.type&&q.has(o.metadata.type)){const u=await m(`${d}${i}`,t.outdir);if(u?.sourcePath){const e=S.join(t.contentDir,o.fsPath),p=await y.readFile(e,"utf-8"),a=new P(e,p),s=L([parseInt(r,10)],a,u.routesMapping,o.baseSlug);if(s.length)return{route:{slug:h()?j(s[0]):s[0],filePath:n}}}}if(o?.metadata?.type==="graphql"){const u=await m(`${d}${i}`,t.outdir),e=parseInt(r,10);if(u?.sourcePath&&u.graphqlPositions&&!Number.isNaN(e)){let p,a=1/0;for(const[s,{startLine:l,endLine:c}]of Object.entries(u.graphqlPositions))l<=e&&e<=c&&c-l<a&&(a=c-l,p=s);if(p){const s=w(o.baseSlug,p);return{route:{slug:h()?j(s):s,filePath:n}}}}}const g=o?.slug?h()?j(o?.slug):o?.slug:"";return{route:{...o,pageName:o?await o?.getNavText?.():"",slug:g,filePath:n}}}export{J as getRoutesByLineHandler,Y as resolvePathHandler,X as resolvePathsHandler,K as resolveSlugHandler};
1
+ import{Source as P}from"@redocly/openapi-core";import y from"node:fs/promises";import S from"node:path";import{withPathPrefix as j,getPathPrefix as h,combineUrls as w}from"@redocly/theme/core/utils";import{API_DOCS_SHARED_DATA_PREFIX as d}from"../../constants/plugins/api-docs.js";import{CATALOG_BASE_SLUG as b,CATALOG_SLUGS as $}from"../../../constants/catalog-entities.js";import{CATALOG_ENTITIES_FILES_REGEX as I}from"../../constants/plugins/catalog-entities.js";import{removeTrailingSlash as E}from"../../../utils/url/remove-trailing-slash.js";import{normalizeRouteSlug as N}from"../../../utils/path/normalize-route-slug.js";import{promiseMapLimit as T}from"../../utils/async/promise-map-limit.js";import{getRoutesByLines as L,getPointerPosition as U}from"../../plugins/api-docs/utils/ast-utils.js";import{readSharedData as m}from"../../utils/index.js";const q=new Set(["openapi","asyncapi"]);function K(n){return async t=>{const i=await t.req.json(),r=decodeURI(E(i.split("?")[0])),[o]=r.split("#"),g=h(),f=N(o.slice(g.length)),u=f.startsWith(b)?b:f,e=n.getRouteBySlug(u);if(e){const p=n.getRouteByFsPath(e.fsPath);if(p?.metadata?.type&&q.has(p.metadata.type)){const a=await m(`${d}${e.fsPath}`,n.outdir);if(!a?.routesMapping)return t.json({route:e},200);const s=Object.keys(a.routesMapping).find(c=>w(e.baseSlug,a.routesMapping[c])===r);if(!a.sourcePath)return t.json({route:e},200);let l;if(s){const c=S.join(n.contentDir,e.fsPath),R=await y.readFile(c,"utf-8"),_=new P(c,R);l=U(s,_)}return t.json({route:{fsPath:e.fsPath,pointer:s,position:l}},200)}if(p?.metadata?.type==="graphql"){const a=await m(`${d}${e.fsPath}`,n.outdir);if(!a?.graphqlPositions)return t.json({route:e},200);const s=Object.keys(a.graphqlPositions).find(c=>w(e.baseSlug,c)===r),l=s?a.graphqlPositions[s].position:void 0;return t.json({route:{fsPath:e.fsPath,position:l}},200)}}return t.json({route:e},200)}}function X(n){return async t=>{const i=await t.req.json(),r=await T(i,5,async o=>A(o,n));return t.json({routes:r},200)}}function Y(n){return async t=>{const i=await t.req.json(),r=await A(i,n);return t.json(r,200)}}function J(n){return async t=>{const i=(t.req.query("lines")||"").split(",").map(f=>parseInt(f)),r=t.req.query("file");if(!r)return t.json("No data",400);const o=await m(`${d}${r}`,n.outdir),g=S.join(n.contentDir,r);try{const f=await y.readFile(g,"utf-8");if(!o)return t.json("No data",400);const u=new P(g,f),e=L(i,u,o.routesMapping,o.baseSlug);return t.json(e,200)}catch{return t.json("No data",400)}}}async function A(n,t){const[i,r]=n.split(":");if(I.test(i))return{route:{slug:`${b}/${$.ALL}`}};let o=t.getRouteByFsPath(i);if(o?.metadata?.type&&q.has(o.metadata.type)){const u=await m(`${d}${i}`,t.outdir);if(u?.sourcePath){const e=S.join(t.contentDir,o.fsPath),p=await y.readFile(e,"utf-8"),a=new P(e,p),s=L([parseInt(r,10)],a,u.routesMapping,o.baseSlug);if(s.length)return{route:{slug:h()?j(s[0]):s[0],filePath:n}}}}if(o?.metadata?.type==="graphql"){const u=await m(`${d}${i}`,t.outdir),e=parseInt(r,10);if(u?.sourcePath&&u.graphqlPositions&&!Number.isNaN(e)){let p,a=1/0;for(const[s,{startLine:l,endLine:c}]of Object.entries(u.graphqlPositions))l<=e&&e<=c&&c-l<a&&(a=c-l,p=s);if(p){const s=w(o.baseSlug,p);return{route:{slug:h()?j(s):s,filePath:n}}}}}const g=o?.slug?h()?j(o?.slug):o?.slug:"";return{route:{...o,pageName:o?await o?.getNavText?.():"",slug:g,filePath:n}}}export{J as getRoutesByLineHandler,Y as resolvePathHandler,X as resolvePathsHandler,K as resolveSlugHandler};
@@ -1,4 +1,6 @@
1
1
  import type { Context } from 'hono';
2
2
  export declare function getRequestOrigin(ctx: Context): string;
3
+ /** Request-based counterpart of `getRequestOrigin`; the same trust caveat applies. */
3
4
  export declare function getForwardedOrigin(request: Request): string;
5
+ export declare function getInternalOrigin(request: Request): string | undefined;
4
6
  //# sourceMappingURL=get-request-origin.d.ts.map
@@ -1 +1 @@
1
- const s=["localhost","127.0.0.1","::1","[::1]"];function n(o){return o?.split(",")[0].trim()||void 0}function d(o){const t=o.replace(/:\d+$/,"");return s.includes(t)||t.endsWith(".localhost")}function a(o){const t=new URL(o.req.url),r=o.req.header("x-forwarded-proto")||t.protocol.slice(0,-1)||"https",e=o.req.header("x-forwarded-host")||t.host;return`${r}://${e}`}function c(o){const t=new URL(o.url),r=n(o.headers.get("x-forwarded-host"))||t.host;return`${n(o.headers.get("x-forwarded-proto"))||(d(r)?"http":"https")}://${r}`}export{c as getForwardedOrigin,a as getRequestOrigin};
1
+ import{envConfig as i}from"../../config/env-config.js";const c=["localhost","127.0.0.1","::1","[::1]"];function n(o){return o?.split(",")[0].trim()||void 0}const a=/^(?:[A-Za-z0-9._-]+|\[[0-9A-Fa-f:.]+\])(?::\d{1,5})?$/;function s(o){const t=n(o);return t&&a.test(t)?t:void 0}function d(o){const t=n(o)?.toLowerCase();return t==="http"||t==="https"?t:void 0}function p(o){const t=o.replace(/:\d+$/,"");return c.includes(t)||t.endsWith(".localhost")}function h(o){const t=new URL(o.req.url),r=d(o.req.header("x-forwarded-proto"))||t.protocol.slice(0,-1)||"https",e=s(o.req.header("x-forwarded-host"))||t.host;return`${r}://${e}`}function u(o){const t=new URL(o.url),r=s(o.headers.get("x-forwarded-host"))||t.host;return`${d(o.headers.get("x-forwarded-proto"))||(p(r)?"http":"https")}://${r}`}function l(o){const t=o.context?.remoteAddr?.port??i.PORT;return t?`http://127.0.0.1:${t}`:void 0}export{u as getForwardedOrigin,l as getInternalOrigin,h as getRequestOrigin};
@@ -1,5 +1,6 @@
1
1
  import { WorkerPool } from './worker-pool.js';
2
2
  export declare const MCP_TOOL_WORKER_KEY = "executeMcpTool";
3
3
  export declare const MCP_TOOL_IS_AVAILABLE_KEY = "isMcpToolAvailable";
4
+ export declare const MCP_TOOL_AVAILABILITY_KEY = "mcpToolAvailability";
4
5
  export declare const mcpToolWorkers: WorkerPool;
5
6
  //# sourceMappingURL=mcp-tool-worker-pool.d.ts.map
@@ -1 +1 @@
1
- import{getAllowedEnvs as o}from"../utils/envs/get-api-route-allowed-env-variables.js";import{WorkerPool as r}from"./worker-pool.js";const p="executeMcpTool",c="isMcpToolAvailable",e=5,l=new r({workerScript:"./mcp-tool-worker",minWorkers:1,maxWorkers:e,workerType:"process",forkOpts:{stdio:"inherit"},resolveForkEnv:o,lazy:!0,sandbox:!0});export{c as MCP_TOOL_IS_AVAILABLE_KEY,p as MCP_TOOL_WORKER_KEY,l as mcpToolWorkers};
1
+ import{getAllowedEnvs as o}from"../utils/envs/get-api-route-allowed-env-variables.js";import{WorkerPool as r}from"./worker-pool.js";const p="executeMcpTool",l="isMcpToolAvailable",c="mcpToolAvailability",e=5,i=new r({workerScript:"./mcp-tool-worker",minWorkers:1,maxWorkers:e,workerType:"process",forkOpts:{stdio:"inherit"},resolveForkEnv:o,lazy:!0,sandbox:!0});export{c as MCP_TOOL_AVAILABILITY_KEY,l as MCP_TOOL_IS_AVAILABLE_KEY,p as MCP_TOOL_WORKER_KEY,i as mcpToolWorkers};
@@ -1 +1 @@
1
- import o from"workerpool";import{executeMcpTool as r,isMcpToolAvailable as _}from"../plugins/mcp/workers/execute-mcp-tool.js";import{MCP_TOOL_IS_AVAILABLE_KEY as e,MCP_TOOL_WORKER_KEY as m}from"./mcp-tool-worker-pool.js";o.worker({[m]:r,[e]:_});
1
+ import o from"workerpool";import{executeMcpTool as r,isMcpToolAvailable as _,mcpToolAvailability as i}from"../plugins/mcp/workers/execute-mcp-tool.js";import{MCP_TOOL_AVAILABILITY_KEY as l,MCP_TOOL_IS_AVAILABLE_KEY as A,MCP_TOOL_WORKER_KEY as m}from"./mcp-tool-worker-pool.js";o.worker({[m]:r,[A]:_,[l]:i});
@@ -1,11 +1,11 @@
1
1
  import type { ApiRoutesWorkerParams, ApiRoutesWorkerResponse } from '../types/plugins/api-routes.js';
2
2
  import type { RenderPayload } from '../../types/ssr.js';
3
3
  import type { ScorecardsWorkerParams, ScorecardsWorkerResponse } from '../types/plugins/scorecards.js';
4
- import type { McpToolExecutionParams, McpToolWorkerResponse } from '../plugins/mcp/types.js';
4
+ import type { McpToolContext, McpToolExecutionParams, McpToolWorkerResponse } from '../plugins/mcp/types.js';
5
5
  import type { SCORECARDS_WORKER_KEY } from './scorecards-worker-pool.js';
6
6
  import type { API_ROUTES_WORKER_KEY } from './api-routes-worker-pool.js';
7
7
  import type { SSR_WORKER_KEY } from './ssr-worker-pool.js';
8
- import type { MCP_TOOL_IS_AVAILABLE_KEY, MCP_TOOL_WORKER_KEY } from './mcp-tool-worker-pool.js';
8
+ import type { MCP_TOOL_AVAILABILITY_KEY, MCP_TOOL_IS_AVAILABLE_KEY, MCP_TOOL_WORKER_KEY } from './mcp-tool-worker-pool.js';
9
9
  export type SsrWorkerResponse = {
10
10
  html: string;
11
11
  statusCode: 200 | 500;
@@ -32,6 +32,13 @@ export type WorkerTypeMapping = {
32
32
  params: [Omit<McpToolExecutionParams, 'args' | 'extra'>];
33
33
  response: boolean;
34
34
  };
35
+ [MCP_TOOL_AVAILABILITY_KEY]: {
36
+ params: [{
37
+ toolNames: string[];
38
+ context: McpToolContext;
39
+ }];
40
+ response: Record<string, boolean>;
41
+ };
35
42
  };
36
43
  export type WorkerParams<T extends keyof WorkerTypeMapping> = WorkerTypeMapping[T]['params'];
37
44
  export type WorkerResponse<T extends keyof WorkerTypeMapping> = WorkerTypeMapping[T]['response'];
@@ -7,6 +7,7 @@ export type WorkerPoolConfig = {
7
7
  resolveForkEnv?: () => Record<string, string | undefined>;
8
8
  } & WorkerPoolOptions;
9
9
  type RegisteredWorkers = keyof WorkerTypeMapping;
10
+ export declare const workerBaseDir: string;
10
11
  export declare class WorkerPool {
11
12
  #private;
12
13
  constructor(config: WorkerPoolConfig);
@@ -1 +1 @@
1
- import l from"workerpool";import{mkdirSync as m}from"node:fs";import{basename as u,dirname as c,resolve as f}from"node:path";import{fileURLToPath as p}from"node:url";import{envConfig as n}from"../config/env-config.js";import{SandboxContext as v}from"../utils/sandbox-context.js";const h=(()=>{const o=c(p(import.meta.url));return u(o)==="chunks"?c(o):o})();class P{#t=null;#r;constructor(r){this.#r=r,this.#r.lazy||(this.#t=this.#e())}#e(){const{workerScript:r,lazy:t,sandbox:i,resolveForkEnv:s,...e}=this.#r,a=this.#s(r);return s&&e.forkOpts&&(e.forkOpts={...e.forkOpts,env:s()}),this.#o(i)?l.pool(a,{...e,forkOpts:this.#i(e.forkOpts)}):l.pool(a,{...e})}#o(r){return!!r&&n.isReunite&&n.REDOCLY_DISABLE_API_FUNCTION_SANDBOX!==!0}#i(r){const t=v.resolve(h);try{m(t.tmpDir,{recursive:!0})}catch{}return{...r,cwd:t.serverOutDir,execArgv:[...t.execArgv,...r?.execArgv??[]],env:{...r?.env,...t.env}}}#s(r){let t=r;return!t.endsWith(".js")&&!t.endsWith(".mjs")&&(t=`${t}.${n.isDevelopMode?"js":"mjs"}`),t.startsWith(".")?f(h,t):t}#n(){return this.#t||(this.#t=this.#e()),this.#t}async exec(r,t,i){let e=this.#n().exec(r,t);return i?.timeout&&(e=e.timeout(i.timeout)),await e}async terminate(){this.#t&&(await this.#t.terminate(),this.#t=null)}}export{P as WorkerPool};
1
+ import l from"workerpool";import{mkdirSync as m}from"node:fs";import{basename as u,dirname as c,resolve as p}from"node:path";import{fileURLToPath as f}from"node:url";import{envConfig as n}from"../config/env-config.js";import{SandboxContext as v}from"../utils/sandbox-context.js";const h=(()=>{const o=c(f(import.meta.url));return u(o)==="chunks"?c(o):o})();class P{#t=null;#r;constructor(r){this.#r=r,this.#r.lazy||(this.#t=this.#e())}#e(){const{workerScript:r,lazy:t,sandbox:i,resolveForkEnv:s,...e}=this.#r,a=this.#s(r);return s&&e.forkOpts&&(e.forkOpts={...e.forkOpts,env:s()}),this.#o(i)?l.pool(a,{...e,forkOpts:this.#i(e.forkOpts)}):l.pool(a,{...e})}#o(r){return!!r&&n.isReunite&&n.REDOCLY_DISABLE_API_FUNCTION_SANDBOX!==!0}#i(r){const t=v.resolve(h);try{m(t.tmpDir,{recursive:!0})}catch{}return{...r,cwd:t.serverOutDir,execArgv:[...t.execArgv,...r?.execArgv??[]],env:{...r?.env,...t.env}}}#s(r){let t=r;return!t.endsWith(".js")&&!t.endsWith(".mjs")&&(t=`${t}.${n.isDevelopMode?"js":"mjs"}`),t.startsWith(".")?p(h,t):t}#n(){return this.#t||(this.#t=this.#e()),this.#t}async exec(r,t,i){let e=this.#n().exec(r,t);return i?.timeout&&(e=e.timeout(i.timeout)),await e}async terminate(){this.#t&&(await this.#t.terminate(),this.#t=null)}}export{P as WorkerPool,h as workerBaseDir};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Determines whether a value is a non-null, non-array object.
3
+ *
4
+ * Unlike `isObject`, class instances pass: the check guards shape
5
+ * (keyed properties), not prototype purity.
6
+ *
7
+ * @param value - The value to check.
8
+ * @returns True if the value is a non-null, non-array object.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * isPlainObject({}); // true
13
+ * isPlainObject(new Date()); // true
14
+ * isPlainObject([]); // false
15
+ * isPlainObject(null); // false
16
+ * ```
17
+ */
18
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
19
+ //# sourceMappingURL=is-plain-object.d.ts.map
@@ -0,0 +1 @@
1
+ function t(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}export{t as isPlainObject};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/reef",
3
- "version": "0.137.0-next.6",
3
+ "version": "0.137.0-next.8",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,7 +33,13 @@
33
33
  "@opentelemetry/sdk-trace-web": "2.8.0",
34
34
  "@opentelemetry/semantic-conventions": "1.40.0",
35
35
  "@redocly/ajv": "8.18.0",
36
+ "@redocly/api-docs": "0.2.0-next.8",
37
+ "@redocly/config": "0.55.0",
36
38
  "@redocly/openapi-core": "2.47.0",
39
+ "@redocly/portal-legacy-ui": "0.19.0",
40
+ "@redocly/portal-plugin-mock-server": "0.22.0-next.6",
41
+ "@redocly/realm-asyncapi-sdk": "0.15.0-next.3",
42
+ "@redocly/theme": "0.69.0-next.7",
37
43
  "@shikijs/transformers": "3.21.0",
38
44
  "@tanstack/react-query": "5.62.3",
39
45
  "@tanstack/react-table": "8.21.3",
@@ -92,16 +98,7 @@
92
98
  "xml-crypto": "6.1.0",
93
99
  "xpath": "0.0.34",
94
100
  "yaml-ast-parser": "0.0.43",
95
- "zod": "^3.25.76",
96
- "@redocly/api-docs": "0.2.0-next.6",
97
- "@redocly/asyncapi-docs": "1.14.0-next.6",
98
- "@redocly/config": "0.54.0",
99
- "@redocly/graphql-docs": "1.14.0-next.6",
100
- "@redocly/openapi-docs": "3.25.0-next.6",
101
- "@redocly/portal-legacy-ui": "0.19.0",
102
- "@redocly/portal-plugin-mock-server": "0.22.0-next.6",
103
- "@redocly/realm-asyncapi-sdk": "0.15.0-next.3",
104
- "@redocly/theme": "0.69.0-next.6"
101
+ "zod": "^3.25.76"
105
102
  },
106
103
  "peerDependencies": {
107
104
  "react": "^19.2.7",
@@ -1,12 +0,0 @@
1
- import type { PageProps } from '@redocly/config';
2
- export declare function useCollectMarkdocOptions({ markdown }: PageProps): {
3
- variables?: Record<string, any>;
4
- tags: {
5
- [x: string]: any;
6
- };
7
- nodes: any;
8
- functions: any;
9
- components: any;
10
- partials: Record<string, import("@markdoc/markdoc").Node[] | import("@markdoc/markdoc").Node> | undefined;
11
- };
12
- //# sourceMappingURL=helpers.d.ts.map
@@ -1 +0,0 @@
1
- import{useMemo as t}from"react";import{components as m}from"@redocly-markdoc/components";import{schema as s}from"@redocly-markdoc/schema";import{tags as r,components as n}from"@redocly/theme/markdoc/default";import*as a from"../../app/markdoc/custom-components/index.js";import*as e from"../../../markdoc/nodes/index.js";import p from"../../../markdoc/tags/index.js";import{normalizeCustomTags as i}from"../../../markdoc/helpers/normalize-custom-tags.js";import{parsePartials as c}from"../../templates/openapi-docs/helpers.js";function O({markdown:o}){return t(()=>({tags:{...p,...r,...i(s?.tags??{})},nodes:{...e,...s?.nodes??{}},functions:{...s?.functions??{}},components:{...a,...n,...m,...globalThis.__LOADER.markdocComponents},...o,partials:c(o?.partials)}),[o])}export{O as useCollectMarkdocOptions};
@@ -1,15 +0,0 @@
1
- import * as React from 'react';
2
- import type { LayoutVariant } from '@redocly/theme/components/SidebarActions/SidebarActions';
3
- type TemplateProps = {
4
- pageProps: {
5
- apiOptions: {
6
- layout: LayoutVariant;
7
- };
8
- settings: {
9
- baseUrlPath: string;
10
- };
11
- };
12
- };
13
- export default function AsyncApiDocs({ pageProps }: TemplateProps): React.JSX.Element;
14
- export {};
15
- //# sourceMappingURL=template.d.ts.map
@@ -1,9 +0,0 @@
1
- import m from"styled-components";import*as t from"react";import{RedoclyAsyncAPIDocs as d}from"@redocly/asyncapi-docs";import{withPathPrefix as r}from"@redocly/theme/core/utils";import{ServerRoutes as p}from"../../../constants/api.js";import{CLIENT_TELEMETRY_ENABLED as f}from"../../constants/common.js";import{PACKAGE_NAME as E}from"../../../config/product-gates";import{usePageSharedData as A}from"../../providers/page-data/hooks";import{useCollectMarkdocOptions as h}from"./helpers.js";function u({pageProps:o}){const e=A("AsyncApiDefinition"),{document:i,apiItems:a,protocol:n,downloadUrls:s}=e,c=r(o?.settings?.baseUrlPath),l=h(o);return t.createElement(g,null,t.createElement(d,{pageProps:o,document:i,apiItems:a,routingBasePath:c,protocol:n,downloadUrls:s,markdocOptions:l,telemetryConfig:{collectorUrl:new URL(r(p.OTEL_TRACES),location.origin).toString(),disabled:!f,serviceVersion:`${E}@${process.env.REDOCLY_PORTAL_VERSION}`}}))}const g=m.div`
2
- a[id],
3
- a[data-section-id],
4
- div[data-section-id] {
5
- scroll-margin-top: calc(var(--navbar-height) + var(--banner-height) + var(--panel-gap-vertical));
6
- }
7
-
8
- --sidebar-width: 0px;
9
- `;export{u as default};
@@ -1,18 +0,0 @@
1
- import { type Node } from '@markdoc/markdoc';
2
- import type { AsyncApiRealmUI } from '@redocly/realm-asyncapi-sdk';
3
- import type { OpenAPIDefinition } from '@redocly/openapi-docs';
4
- import type { EventType } from '@redocly/openapi-docs/src/events/types';
5
- import type { RedocConfig, PageProps } from '@redocly/config';
6
- type EventFunctionInput = string | ((event: EventType) => void) | undefined;
7
- type OpenAPIDocsStore = {
8
- definition: OpenAPIDefinition;
9
- options: RedocConfig;
10
- basePath?: string;
11
- };
12
- export declare function joinWithSeparator(base?: string, path?: string, sep?: string): string;
13
- export declare function parsePartials(partials?: Record<string, any>): Record<string, Node[] | Node> | undefined;
14
- export declare function usePatchedStore(storeJs: OpenAPIDocsStore, { markdown, baseSlug }: PageProps): OpenAPIDocsStore;
15
- export declare function safeParseFunction(fnInput: EventFunctionInput): ((event: EventType) => void) | null;
16
- export declare function mergeEvents(userFunction: ((event: EventType) => void) | null, telemetryEvent?: AsyncApiRealmUI.GetEventData<'com.redocly.openapiDocs.interacted'>[0]['eventType']): (event: EventType) => void;
17
- export {};
18
- //# sourceMappingURL=helpers.d.ts.map
@@ -1,5 +0,0 @@
1
- import{useMemo as f}from"react";import{components as g}from"@redocly-markdoc/components";import{schema as c}from"@redocly-markdoc/schema";import{Ast as d}from"@markdoc/markdoc";import{PageNavigation as h}from"@redocly/theme/components/PageNavigation/PageNavigation";import{tags as _,components as y}from"@redocly/theme/markdoc/default";import{Breadcrumbs as P}from"@redocly/theme/components/Breadcrumbs/Breadcrumbs";import{withPathPrefix as m,getBaseDataAttributes as w}from"@redocly/theme/core/utils";import{ServerRoutes as u}from"../../../constants/api.js";import{OPENAPI_DOCS_TEMPLATE_ID as S}from"../../../constants/common.js";import{isBrowser as O}from"../../../utils/env/is-browser.js";import*as v from"../../../markdoc/nodes/index.js";import C from"../../../markdoc/tags/index.js";import{normalizeCustomTags as T}from"../../../markdoc/helpers/normalize-custom-tags.js";import*as A from"../../app/markdoc/custom-components/index.js";import{usePageData as x,useSidebarSiblingsData as D}from"../../providers/page-data/hooks";import{telemetry as E}from"../../app/telemetry/index.js";import{getMockServerDocsConfig as R}from"./mock-server-config.js";function Z(o="",r="",t="/"){return o.endsWith(t)&&(o=o.slice(0,-t.length)),r.startsWith(t)&&(r=r.slice(t.length)),!o||!r?o+r:o+t+r}function b(o){if(o)return Object.entries(o).reduce((r,[t,n])=>(r[t]=d.fromJSON(JSON.stringify(n)),r),{})}function G(o,{markdown:r,baseSlug:t}){return f(()=>{const i=O();if(o.options.oAuth2RedirectURI=i?`${window.location.origin}${m(u.REPLAY_OAUTH2_CALLBACK)}`:void 0,o.options.routingBasePath=m(t),o.options.mockServer=R(o.options.mockServer,t),o.options.corsProxyUrl===void 0){const e=m(`${u.CORS_PROXY}/`);o.options.corsProxyUrl=i?new URL(e,window.location.origin).toString():e}o.options.scrollYOffset=i?parseInt(getComputedStyle(document.documentElement).getPropertyValue("--navbar-height"),10):0,o.options.markdocOptions={tags:{...C,..._,...T(c?.tags??{})},nodes:{...v,...c?.nodes??{}},functions:{...c?.functions??{}},components:{...A,...y,...g,...globalThis.__LOADER.markdocComponents},...r,partials:b(r?.partials)},o.options.unstable_hooks={...o.options.unstable_hooks,MiddlePanelFooter:()=>{const{templateId:e}=x()||{},{nextPage:s,prevPage:a}=D()||{};return e===S?null:h({nextPage:s,prevPage:a})},MiddlePanelHeader:()=>P({})};const l={codeSamplesLanguageSwitch:"samples_language_switch",codeSamplesCopy:"code_samples_copy",panelToggle:"panel_toggle",targetServerSwitch:"target_server_switch",tryItOpen:"try_it_toggle",tryItSent:"try_it_sent"},p={};for(const[e,s]of Object.entries(l)){const a=I(o.options.events?.[e]);p[e]=U(a,s)}return o.options.events=p,o},[o,r,t])}function I(o){if(typeof window>"u")return null;if(typeof o=="function")return o;if(typeof o!="string")return null;try{const r=o.trim();if(!r.match(/^(\([^)]*\)\s*=>\s*.+|[a-zA-Z_$][\w$]*\s*=>\s*.+)$/))throw new Error("Invalid function format. Only arrow functions allowed.");if(["eval","Function","constructor","prototype","__proto__","import","require","process","global","window","document"].some(i=>r.includes(i)))throw new Error("Function contains prohibited keywords");return new Function("event",`
2
- 'use strict';
3
- const userFn = ${r};
4
- return userFn(event);
5
- `)}catch(r){return console.error("Function parsing error:",r),null}}function U(o,r){return t=>{if(o)try{o(t)}catch(n){console.error("User event handler error:",n)}if(r)try{E.sendOpenapiDocsMessage([{...w("openapiDocsInteraction","openapiDocs"),eventType:r,operationHttpVerb:t.operationHttpVerb,operationPath:t.operationPath,lang:"lang"in t?t.lang:void 0,action:t.action,state:"state"in t?t.state:void 0,serverUrl:"serverUrl"in t?t.serverUrl:void 0}])}catch{}}}export{Z as joinWithSeparator,U as mergeEvents,b as parsePartials,I as safeParseFunction,G as usePatchedStore};
@@ -1,6 +0,0 @@
1
- import * as React from 'react';
2
- import { type PageProps } from '@redocly/config';
3
- export default function OpenAPIDocs({ pageProps }: {
4
- pageProps: PageProps;
5
- }): "Something went wrong" | React.JSX.Element;
6
- //# sourceMappingURL=template.d.ts.map
@@ -1,14 +0,0 @@
1
- import*as o from"react";import i from"styled-components";import{RedoclyOpenAPIDocs as m}from"@redocly/openapi-docs";import{LayoutVariant as c}from"@redocly/config";import{CLIENT_TELEMETRY_ENABLED as s}from"../../constants/common.js";import{ThreePanelLayout as p}from"@redocly/theme/layouts/ThreePanelLayout";import{CatalogClassicInfoBlock as f}from"@redocly/theme/components/CatalogClassic/CatalogClassicInfoBlock";import{withPathPrefix as h}from"@redocly/theme/core/utils";import{useUserClaims as d}from"../../app/hooks";import{ServerRoutes as u}from"../../../constants/api.js";import{PACKAGE_NAME as E}from"../../../config/product-gates";import{usePageSharedData as v}from"../../providers/page-data/hooks";import{usePatchedStore as g}from"./helpers.js";function y({pageProps:t}){const r=d(),e=v("openAPIDocsStore"),n=o.useMemo(()=>({layout:t.apiOptions?.layout,userClaims:r}),[t.apiOptions?.layout,r]),a=g(e,t);if(!e)return"Something went wrong";const l=t.apiOptions?.layout;return o.createElement(A,null,o.createElement(S,{layout:l},o.createElement(f,{metadata:t.metadata})),o.createElement(m,{store:{options:a.options,definition:a.definition,withState:n},telemetryConfig:{collectorUrl:new URL(h(u.OTEL_TRACES),location.origin).toString(),disabled:!s,serviceVersion:`${E}@${process.env.REDOCLY_PORTAL_VERSION}`}}))}const S=i(p)`
2
- && {
3
- padding-right: ${({layout:t})=>t===c.THREE_PANEL?"calc(var(--panel-gap-horizontal) * 2)":"var(--panel-gap-horizontal)"};
4
- }
5
- `,A=i.div`
6
- div[id] {
7
- scroll-margin-top: calc(var(--navbar-height) + var(--banner-height) - var(--panel-gap-vertical));
8
- }
9
- a[id] {
10
- scroll-margin-top: calc(var(--navbar-height) + var(--banner-height) + var(--panel-gap-vertical));
11
- }
12
-
13
- --sidebar-width: 0px;
14
- `;export{y as default};
@@ -1,9 +0,0 @@
1
- export declare function useLicense(): {
2
- licenseInfo: {
3
- allowed: boolean;
4
- valid: boolean;
5
- };
6
- isValid: boolean;
7
- isPending: boolean;
8
- };
9
- //# sourceMappingURL=empty-check.d.ts.map
@@ -1 +0,0 @@
1
- function e(){return{licenseInfo:{allowed:!0,valid:!0},isValid:!0,isPending:!1}}export{e as useLicense};
@@ -1,2 +0,0 @@
1
- export declare function LicenseOverlay(): null;
2
- //# sourceMappingURL=empty-overlay.d.ts.map
@@ -1 +0,0 @@
1
- function e(){return null}export{e as LicenseOverlay};
@@ -1,6 +0,0 @@
1
- import type { PluginBuild } from 'esbuild';
2
- export declare const ApiDocsModuleReplacer: () => {
3
- name: string;
4
- setup: (build: PluginBuild) => void;
5
- };
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- import{createRequire as o}from"module";const s=o(import.meta.url),t=()=>({name:"esbuild-redocly-api-docs-module-replacer",setup:r=>{r.onResolve({filter:/\/hooks\/useLicense\.js$/},async e=>{if(e.resolveDir.endsWith("/api-docs/lib"))return{path:s.resolve("./empty-check.js")}}),r.onResolve({filter:/\/components\/LicenseOverlay\.js$/},async e=>{if(e.resolveDir.endsWith("/api-docs/lib"))return{path:s.resolve("./empty-overlay.js")}})}});export{t as ApiDocsModuleReplacer};
@@ -1,8 +0,0 @@
1
- export declare function useLicense(): {
2
- licenseInfo: {
3
- allowed: boolean;
4
- valid: boolean;
5
- };
6
- isValid: boolean;
7
- };
8
- //# sourceMappingURL=empty-check.d.ts.map
@@ -1 +0,0 @@
1
- function e(){return{licenseInfo:{allowed:!0,valid:!0},isValid:!0}}export{e as useLicense};
@@ -1,2 +0,0 @@
1
- export declare const Overlay: () => null;
2
- //# sourceMappingURL=empty-overlay.d.ts.map
@@ -1 +0,0 @@
1
- const n=function(){return null};export{n as Overlay};
@@ -1,5 +0,0 @@
1
- export declare function useLicenseKey(): {
2
- isValid: boolean;
3
- loading: boolean;
4
- };
5
- //# sourceMappingURL=empty-use-license-key.d.ts.map
@@ -1 +0,0 @@
1
- function e(){return{isValid:!0,loading:!1}}export{e as useLicenseKey};
@@ -1,6 +0,0 @@
1
- import type { PluginBuild } from 'esbuild';
2
- export declare const OpenapiDocsModuleReplacer: () => {
3
- name: string;
4
- setup: (build: PluginBuild) => void;
5
- };
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- import{createRequire as r}from"module";const o=r(import.meta.url),c=()=>({name:"esbuild-redocly-openapi-docs-module-replacer",setup:e=>{e.onResolve({filter:/\.[\/\\]Overlay.js$/},async s=>{if(s.resolveDir.endsWith("openapi-docs/lib/components/RedoclyOpenAPIDocs"))return{path:o.resolve("./empty-overlay.js")}}),e.onResolve({filter:/(.*)\/hooks\/useLicense.js$/},async s=>{if(s.resolveDir.endsWith("openapi-docs/lib/components/RedoclyOpenAPIDocs"))return{path:o.resolve("./empty-check.js")}}),e.onResolve({filter:/shared\/license\/use-license-key/},async()=>({path:o.resolve("./empty-use-license-key.js")}))}});export{c as OpenapiDocsModuleReplacer};
@@ -1,3 +0,0 @@
1
- export declare function loadAndBundleDefinition(): void;
2
- export declare function convertSwagger2OpenAPI(): void;
3
- //# sourceMappingURL=loadAndBundleSpec.mock.d.ts.map
@@ -1 +0,0 @@
1
- function n(){}function e(){}export{e as convertSwagger2OpenAPI,n as loadAndBundleDefinition};
@@ -1,18 +0,0 @@
1
- import type { AsyncApiDefinition, AsyncApiDefinitionReferenced } from '@redocly/asyncapi-docs';
2
- import type { MarkdocChunk } from '../openapi-docs/load-definition.js';
3
- import type { RedoclyConfig } from '@redocly/config';
4
- import type { LifecycleContext } from '../../types';
5
- export type BundledDefinition = {
6
- document: AsyncApiDefinition;
7
- documentWithReferences: AsyncApiDefinitionReferenced;
8
- config: Partial<RedoclyConfig & NonNullable<RedoclyConfig['apis']>[string]>;
9
- customOutputRelativeFile: string | undefined;
10
- markdocChunks: MarkdocChunk[];
11
- realRelativePath: string;
12
- relativePath: string;
13
- isVirtual: boolean;
14
- hash: string;
15
- };
16
- export declare function asyncapiDocLoader(relativePath: string, { fs, logger, cache, getConfig, isPathIgnored }: LifecycleContext): Promise<Omit<BundledDefinition, 'hash'>[]>;
17
- export declare function asyncapiDocsLoader(_: string, context: LifecycleContext): Promise<BundledDefinition[]>;
18
- //# sourceMappingURL=asyncapi-doc-loader.d.ts.map
@@ -1,5 +0,0 @@
1
- import s from"node:path";import{bundle as R,createConfig as B,getTotals as J}from"@redocly/openapi-core";import{CONFIG_FILE_NAME as L}from"../../../constants/common.js";import{deepMerge as M}from"../../../utils/object/deep-merge.js";import{pluralize as $}from"../../../utils/string/pluralize.js";import{getAllApiConfigsByPath as W}from"../get-api-config.js";import{injectDecoratorIntoConfig as _}from"../openapi-docs/decorators.js";import{ExternalResolver as T}from"../../fs/utils/external-ref-resolver.js";async function Z(n,{fs:o,logger:f,cache:u,getConfig:p,isPathIgnored:d}){let a;try{a=(await u.load(n,"yaml")).data}catch{return[]}if(!a?.asyncapi)return f.verbose(`${n} file is not AsyncAPI document. Skipping`),[];const l=[],e=o.getFileInfo(n),t=await p(s.posix.dirname(n)),A=W(t?.apis,n,t.configPath),D=await d(n);for(const c of A){if(!c.output&&D)continue;const O=t.configPath?s.posix.dirname(t.configPath):".",r=c.output?s.posix.join(O,c.output):n;if(await d(r))continue;e&&c.output&&!await o.exists(r)&&o.addVirtualFile(r,e);const m=M(t,{rbac:void 0},c),k=s.resolve(o.cwd,t.realConfigPath||L),w=new T(o),v=await B(_(m,r,o.cwd),{configPath:k,externalRefResolver:w}),h=s.resolve(o.cwd,n),g={config:v,base:s.dirname(h),doc:{source:{absoluteRef:h},parsed:JSON.parse(JSON.stringify(a))}},{bundle:{parsed:I},problems:y,visitorsData:N}=await R({...g,dereference:!0,externalRefResolver:w}),{bundle:{parsed:P}}=await R({...g,doc:{...g.doc,parsed:JSON.parse(JSON.stringify(a))}}),S=N["markdown/markdown"]?.markdocChunks??[],i=J(y);let b=[i.errors&&`${i.errors} ${$(i.errors,"error","errors")}`,i.warnings&&`${i.warnings} ${$(i.warnings,"warning","warnings")}`,i.ignored&&`${i.ignored} ignored`].filter(Boolean).join(", ");if(i.errors){const C=y.find(F=>F.severity==="error");throw new Error(`${b} while bundling ${r} definition.
2
-
3
- ${C?.message} at ${C?.location?.[0].pointer}
4
-
5
- `)}i.warnings&&f.warn(`${b} while bundling %rp definition`,r);const V=x(I,t.metadata),j=x(P,t.metadata),E={document:V,documentWithReferences:j,config:m,relativePath:r,realRelativePath:e?.realRelativePath||r,customOutputRelativeFile:c.output&&r,markdocChunks:S,isVirtual:e?.isVirtual??!1};l.push(E)}return l}async function nn(n,o){const{fs:f,cache:u,getConfig:p}=o,d=[];for(const a of await f.scan(/(\.ya?ml|\.json)$/)){if(!await p(s.posix.dirname(a.relativePath)))continue;let e;try{e=await u.load(a.relativePath,"asyncapi-doc")}catch{continue}e.data?.length&&d.push(...e.data.map(t=>({...t,isVirtual:a.isVirtual||t.isVirtual,hash:e.compoundHash})))}return d}function x(n,o){return o?{...n,info:{...n.info,"x-metadata":{...n.info["x-metadata"],...o}}}:n}export{Z as asyncapiDocLoader,nn as asyncapiDocsLoader};
@@ -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{getPublicEnvVariables as n}from"../../utils/envs/get-public-env-variables.js";const l=async({fsPath:r,slug:e},t,{partials:a,variables:i},o)=>{const s=o.getPartialsForRoute?.(e)||a;return{definitionId:r,...t.props,markdown:{partials:s,variables:{...i,env:n()}}}};var d=l;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,3 +0,0 @@
1
- import type { LifecyclePluginInstance, PluginOptions } from '../../types';
2
- export declare function asyncAPIDocsPlugin(_pluginOptions: PluginOptions): Promise<LifecyclePluginInstance>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- import A from"path";import{simplifyAstStructure as E}from"@redocly/openapi-docs/lib/utils/simplifyAstStructure.js";import{buildMenuItems as $}from"@redocly/asyncapi-docs/lib/utils/build-menu-items.js";import{findFirstBinding as T}from"@redocly/asyncapi-docs/lib/utils/find-first-binding.js";import{ASYNC_API_DOCS_TEMPLATE_ID as v}from"../../../constants/common.js";import{combineUrls as D}from"@redocly/theme/core/utils";import{PUBLIC_API_DEFINITIONS_FOLDER as R}from"../../constants/common.js";import{logger as x}from"../../tools/notifiers/logger.js";import{getRouteSlugsForPath as F}from"../utils.js";import{getTemplatePath as b}from"./get-template-path.js";import{storeDefinitionBundles as O}from"./store-definition-bundles.js";import{asyncapiDocLoader as N,asyncapiDocsLoader as j}from"./asyncapi-doc-loader.js";import{searchResolver as L}from"./search/search-resolver.js";import{getAiDocumentsStore as G}from"./search/get-ai-search-documents.js";import{telemetryTraceStep as M}from"../../../cli/telemetry/helpers/trace-step.js";const _="asyncapi-docs-";async function ot(d){let p=[],u=new Set;return{id:"asyncapi",requiredEntitlements:["asyncapi"],loaders:{"asyncapi-doc":N,"asyncapi-docs":j},processContent:async(e,o)=>{await M("com.redocly.build.plugin.asyncapiDocs",async()=>{if((await o.getConfig()).plugins?.some(l=>l.startsWith("@redocly/portal-plugin-async-api/"))){x.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");return}const c=e.createTemplate(v,b("../../../client/templates/asyncapi-docs/template.js")),g=e.registerServerPropsGetter(v,b("./get-server-props.js"));for(const l of await o.fs.scan(/(\.ya?ml|\.json)$/))if(!await o.isPathIgnored(l.relativePath))try{const{data:r,compoundHash:w}=await o.cache.load(l.realRelativePath,"asyncapi-doc");if(!r?.length)continue;p=r.map(({markdocChunks:t,relativePath:s,isVirtual:m,customOutputRelativeFile:f,realRelativePath:y})=>({chunks:t,relativePath:s,realRelativePath:y,isVirtual:f!=null||l.isVirtual||m})),O(r,e.outdir,w);for(const t of r){const s=`${_}${t.relativePath}`,m=T(t.document),{navItems:f,apiItems:y}=$({asyncApiDoc:t.document,protocol:m||""}),I=[{url:D(R,`${C(t.relativePath,".json")}?download`)},{url:D(R,`${C(t.relativePath,".yaml")}?download`)}];await e.createSharedData(s,{document:t.document,apiItems:y,protocol:m,downloadUrls:I}),f.forEach(i=>{const n={fsPath:t.relativePath,slugSuffix:`/${i.link}`,templateId:c,sharedData:[{key:"AsyncApiDefinition",id:s}],getStaticData:S(o.withPathPrefix,i.label),serverPropsGetterIds:[g]};e.addRoute(n),i.items&&i.items.forEach(a=>{e.addRoute({...n,slugSuffix:`/${a.link}`,getStaticData:S(o.withPathPrefix,a.label)}),a.items&&a.items.forEach(h=>{e.addRoute({...n,slugSuffix:`/${h.link}`,getStaticData:S(o.withPathPrefix,a.label)})})})}),e.addRoute({fsPath:t.customOutputRelativeFile||t.relativePath,templateId:c,hasClientRoutes:!0,getSidebar:i=>{const n=a=>{const h={...a};return a.link&&(h.routeSlug=D(i.slug,a.link),h.link=D(i.slug,a.link)),a.items&&(h.items=a.items.map(n)),h};return[{type:"link",label:t.document.info?.title??"AsyncAPI Overview",routeSlug:i.slug,link:i.slug},...f.map(n)]},getSearchDocuments:L(e,t.document),getStaticData:S(o.withPathPrefix,t.document.info?.title??"AsyncAPI Docs"),getAiDocumentsStore:G({actions:e,document:t.document,metadata:{type:"asyncapi",title:t.document.info?.title??"AsyncAPI Docs",description:t.document.info?.description??"",...t.document.info?.["x-metadata"]??{}}}),metadata:{type:"asyncapi",title:t.document.info?.title??"AsyncAPI Docs",description:t.document.info?.description??"",...t.document.info?.["x-metadata"]??{}},sharedData:[{key:"AsyncApiDefinition",id:s}]})}}catch(r){console.error(r)}})},afterRoutesCreated:async(e,o)=>{const P=new Set;for(const{chunks:c,relativePath:g,isVirtual:l,realRelativePath:r}of p){const w=F(e.getAllRoutes(),g),t=(await o.cache.load(r,"asyncapi-doc")).compoundHash;await o.cache.load(g,{loader:async function(){for(const{node:m,markdown:f,pointer:y,key:I,relativePath:i}of c){const{ast:n}=await e.parseMarkdoc({input:{content:f,relativePath:y,isVirtual:l},context:o,deps:{sharedDataIds:[`${_}${i}`],routeSlugs:w}});m[`x-parsed-md-${I}`]={result:E(n)}}},name:"asyncapi-markdoc-inline-parser"},[t]);for(const{pointer:s}of c)P.add(s)}const k=u.difference(P);for(const c of k)o.cache.delete(c);u=P}}}function S(d,p){return async function(u,e){return{props:{settings:{baseUrlPath:d(u.baseSlug)},disableAutoScroll:!0,seo:{title:p}}}}}function C(d,p){const u=A.posix.dirname(d),e=A.posix.basename(d,A.posix.extname(d))+p;return A.posix.join(u,e)}export{ot as asyncAPIDocsPlugin};
@@ -1,3 +0,0 @@
1
- import type { LifecycleContext } from '../../types';
2
- export declare const isAsyncapiDoc: (relativePath: string, context: LifecycleContext) => Promise<boolean>;
3
- //# sourceMappingURL=is-asyncapi-doc.d.ts.map
@@ -1 +0,0 @@
1
- import f from"node:path";import{CONFIG_FILE_NAME as n}from"../../../constants/common.js";const o=async(a,r)=>{if(!a.match(/(\.ya?ml|\.json)$/)||f.posix.basename(a)===n||await r.isPathIgnored(a))return!1;const s=r.fs.getFileInfo(a);if(!s)return!1;try{const{data:e}=await r.cache.load(s.realRelativePath,"yaml");return!!e?.asyncapi}catch{return!1}};export{o as isAsyncapiDoc};
@@ -1,9 +0,0 @@
1
- import type { AsyncApiDefinition } from '@redocly/asyncapi-docs';
2
- import type { PageRouteDetails, ProcessContentActions, AfterRoutesCreatedLifecycleContext } from '../../../types';
3
- import type { AiDocumentsStore } from '../../../plugins/search/types.js';
4
- export declare const getAiDocumentsStore: ({ actions, document, metadata, }: {
5
- actions: ProcessContentActions;
6
- document: AsyncApiDefinition;
7
- metadata: Record<string, unknown>;
8
- }) => (route: PageRouteDetails, _staticData: unknown, context: AfterRoutesCreatedLifecycleContext) => Promise<AiDocumentsStore | undefined>;
9
- //# sourceMappingURL=get-ai-search-documents.d.ts.map