@redocly/realm 0.135.0-next.4 → 0.135.0-next.6
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.
- package/CHANGELOG.md +70 -0
- package/dist/cli/build/analytics/collect-analytics.js +1 -1
- package/dist/cli/build/analytics/collectors/get-nested-configs-usage.js +1 -1
- package/dist/cli/telemetry/get-portal-config-stats.js +1 -1
- package/dist/cli/telemetry/index.js +1 -1
- package/dist/client/app/Sidebar/RequestAccessButton.js +2 -2
- package/dist/client/app/Sidebar/Sidebar.js +3 -3
- package/dist/client/app/Sidebar/helpers/filter-out-versioned-items.d.ts +5 -2
- package/dist/client/app/Sidebar/helpers/filter-out-versioned-items.js +1 -1
- package/dist/client/app/hooks/catalog/useCatalogClassic.js +1 -1
- package/dist/client/app/hooks/catalog/useCatalogFilter.js +1 -1
- package/dist/client/app/hooks/useRouteChangeTracker.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/openapi-response-sample.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/replay-openapi.js +1 -1
- package/dist/client/app/pages/DevLogin/DevLogin.js +1 -1
- package/dist/client/app/search/useSearch.js +1 -1
- package/dist/client/providers/theme/ThemeDataProvider.js +1 -1
- package/dist/markdoc/helpers/get-operation/get-operation.js +1 -0
- package/dist/markdoc/helpers/get-operation/index.d.ts +4 -0
- package/dist/markdoc/helpers/get-operation/index.js +1 -0
- package/dist/markdoc/helpers/get-resolved-sample-code-block.d.ts +3 -0
- package/dist/markdoc/helpers/get-resolved-sample-code-block.js +5 -0
- package/dist/markdoc/tags/openapi-code-sample.js +1 -1
- package/dist/markdoc/tags/openapi-response-sample.js +1 -1
- package/dist/server/config/env-config.d.ts +2 -0
- package/dist/server/config/env-schema.d.ts +5 -0
- package/dist/server/config/env-schemas/feature-flags.d.ts +4 -0
- package/dist/server/config/env-schemas/feature-flags.js +1 -1
- package/dist/server/constants/common.d.ts +2 -0
- package/dist/server/constants/common.js +1 -1
- package/dist/server/constants/plugins/search.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/get-media-content-samples.d.ts +4 -0
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/get-media-content-samples.js +1 -0
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.d.ts +7 -0
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.js +1 -0
- package/dist/server/plugins/markdown/attribute-resolvers/index.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.d.ts +4 -0
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.js +1 -0
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-response-samples.d.ts +4 -0
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-response-samples.js +1 -0
- package/dist/server/plugins/markdown/attribute-resolvers/utils.d.ts +2 -0
- package/dist/server/plugins/markdown/attribute-resolvers/utils.js +1 -1
- package/dist/server/plugins/markdown/compiler.js +1 -1
- package/dist/server/plugins/markdown/extract-frontmatter.d.ts +6 -0
- package/dist/server/plugins/markdown/extract-frontmatter.js +1 -0
- package/dist/server/plugins/markdown/index.js +1 -1
- package/dist/server/plugins/markdown/markdoc/partials.js +1 -1
- package/dist/server/plugins/markdown/markdown-frontmatter-loader.js +1 -1
- package/dist/server/plugins/markdown/search/get-ai-search-documents.js +1 -1
- package/dist/server/plugins/markdown/search/search-resolver.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/codemode/build-execute-tool-description.d.ts +4 -0
- package/dist/server/plugins/mcp/docs-mcp/codemode/build-execute-tool-description.js +4 -0
- package/dist/server/plugins/mcp/docs-mcp/codemode/sandbox.d.ts +3 -0
- package/dist/server/plugins/mcp/docs-mcp/codemode/sandbox.js +7 -0
- package/dist/server/plugins/mcp/docs-mcp/codemode/types.d.ts +9 -0
- package/dist/server/plugins/mcp/docs-mcp/codemode/types.js +0 -0
- package/dist/server/plugins/mcp/docs-mcp/tool-schemas.d.ts +2 -0
- package/dist/server/plugins/mcp/docs-mcp/tool-schemas.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/core/search.d.ts +2 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/core/types.d.ts +6 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/core/types.js +0 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/core/whoami.d.ts +2 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/execute.d.ts +9 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/execute.js +1 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-schema.d.ts +2 -3
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-type-list.d.ts +2 -9
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-type.d.ts +2 -5
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/list-graphql-apis.d.ts +2 -5
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/types.d.ts +21 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/index.d.ts +11 -46
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoint-info.d.ts +2 -6
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-endpoints.d.ts +2 -4
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-full-api-description.d.ts +2 -4
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/get-security-schemes.d.ts +2 -4
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/list-apis.d.ts +2 -5
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/types.d.ts +16 -0
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/types.js +0 -0
- package/dist/server/plugins/mcp/handlers/errors.js +1 -1
- package/dist/server/plugins/mcp/index.js +1 -1
- package/dist/server/plugins/mcp/mode.d.ts +9 -0
- package/dist/server/plugins/mcp/mode.js +1 -0
- package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
- package/dist/server/plugins/mcp/types.d.ts +1 -0
- package/dist/server/plugins/mcp/workers/execute-mcp-tool.js +1 -1
- package/dist/server/plugins/mcp/workers/mcp-tool-telemetry.d.ts +4 -0
- package/dist/server/plugins/mcp/workers/mcp-tool-telemetry.js +1 -0
- package/dist/server/plugins/scorecard-classic/get-scorecard-config.d.ts +11 -0
- package/dist/server/plugins/search/engines/typesense/index.js +1 -1
- package/dist/server/ssr/server-side-props/get-server-props-from-system-handlers.js +1 -1
- package/dist/server/store.d.ts +0 -2
- package/dist/server/store.js +1 -1
- package/dist/server/telemetry/index.js +1 -1
- package/dist/server/types/plugins/common.d.ts +3 -0
- package/dist/types/markdoc.d.ts +5 -0
- package/package.json +12 -11
- package/dist/client/app/markdoc/custom-components/openapi/get-operation/get-operation.js +0 -1
- package/dist/client/app/markdoc/custom-components/openapi/get-operation/index.d.ts +0 -4
- package/dist/client/app/markdoc/custom-components/openapi/get-operation/index.js +0 -1
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-id.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-id.js +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-pointer.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation-info-by-pointer.js +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/get-operation.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/index.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/index.js +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-identifier.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-identifier.js +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-info.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-info.js +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-parameters.d.ts +0 -0
- /package/dist/{client/app/markdoc/custom-components/openapi → markdoc/helpers}/get-operation/types/operation-parameters.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{normalizeOptions as s}from"@redocly/openapi-docs";import{getOperation as l}from"../../../../markdoc/helpers/get-operation/index.js";import{setNodeAttributeValue as f}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{getMediaContentSamples as c}from"./helpers/get-media-content-samples.js";import{loadOpenapiBundle as u}from"./helpers/load-openapi-bundle.js";import{getOptionalAttribute as o}from"./utils.js";async function h(t,a,O,{context:m}){const e=await u(t,m);if(!e)return;const i=o(t,"exampleKey"),n=l({definition:e.definition,options:e.rawOptions},{operationId:o(t,"operationId"),pointer:o(t,"pointer")},s(e.rawOptions),{exampleKey:i});if(!n)return;const r=(n.responses??[]).flatMap(p=>c(p.content,i,`${p.code}`));r.length&&f(t,a,r)}export{h as resolveOpenapiResponseSamples};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { Node, Tag } from '@markdoc/markdoc';
|
|
1
2
|
export declare function getLinkOriginalAttrName(attributeName: string): `redocly:::linkOriginal:${string}`;
|
|
3
|
+
export declare function getOptionalAttribute<T>(node: Node | Tag, attrName: string): T | undefined;
|
|
2
4
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LINK_ORIGINAL_ATTR_NAME as
|
|
1
|
+
import{LINK_ORIGINAL_ATTR_NAME as e}from"../../../constants/common.js";import{getNodeAttribute as i}from"../../../../markdoc/helpers/get-node-attribute.js";function u(t){return`${e}:${t}`}function A(t,r){return i(t,r)??void 0}export{u as getLinkOriginalAttrName,A as getOptionalAttribute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import M from"@markdoc/markdoc";import*as S from"path";import{GATED_MARKDOC_TAGS as O}from"../../constants/entitlements.js";import{logger as F}from"../../tools/notifiers/logger.js";import{reporter as N}from"../../tools/notifiers/reporter.js";import{sha1 as G}from"../../utils/crypto/sha1.js";import{formatMarkdocError as H}from"./errors.js";import{extractFirstHeading as j,visit as K}from"./markdoc/plugins/utils.js";import{attributeResolvers as y}from"./attribute-resolvers/index.js";import{MdResolveError as $}from"./attribute-resolvers/md-resolve-error.js";import{processHtmlTokens as U}from"./html/process-html-tokens.js";import{resolveRawPartials as W}from"./markdoc/resolve-raw-partials.js";import{EntitlementsProvider as Y}from"../../entitlements/entitlements-provider.js";import{MARKDOC_PARTIALS_DEPS_KEY as B}from"../../
|
|
1
|
+
import M from"@markdoc/markdoc";import*as S from"path";import{GATED_MARKDOC_TAGS as O}from"../../constants/entitlements.js";import{logger as F}from"../../tools/notifiers/logger.js";import{reporter as N}from"../../tools/notifiers/reporter.js";import{sha1 as G}from"../../utils/crypto/sha1.js";import{formatMarkdocError as H}from"./errors.js";import{extractFirstHeading as j,visit as K}from"./markdoc/plugins/utils.js";import{attributeResolvers as y}from"./attribute-resolvers/index.js";import{MdResolveError as $}from"./attribute-resolvers/md-resolve-error.js";import{processHtmlTokens as U}from"./html/process-html-tokens.js";import{resolveRawPartials as W}from"./markdoc/resolve-raw-partials.js";import{EntitlementsProvider as Y}from"../../entitlements/entitlements-provider.js";import{MARKDOC_PARTIALS_DEPS_KEY as B}from"../../constants/common.js";import{getLinkOriginalAttrName as V}from"./attribute-resolvers/utils.js";const q="EMPTY";async function C(a,s,e){const n=Y.instance(),{actions:m}=e,{relativePath:i,resolveErrors:E}=a,k=new Set,g=new Set,b=new Set,c=new Set,u={},f=new Set,w={},_={};function R(t,P){const D=P||q;t[D]=(t[D]||0)+1}const A=[];return a.resolveErrors.length=0,K(a.ast,t=>{const P=D();A.push(P.then(r=>{r?.sharedDataIds&&r.sharedDataIds.forEach(d=>k.add(d))}).catch(z));async function D(){const r=[];switch(t.type){case"fence":R(w,t.attributes.language);break;case"link":case"image":await y.nativeMdLink(t,t.type==="link"?"href":"src",i,e);break;case"tag":if(!t.tag)break;const d=s?.tags?.[t.tag];if(!d){O[t.tag]&&!n.canAccessFeature(O[t.tag])&&(t.errors.push({level:"warning",id:"invalid-tag",message:`Undefined tag: ${t.tag}`}),t.tag="",t.type="error",t.attributes={});break}const v=t.tag==="html"?t.attributes.name:t.tag;if((t.tag==="html"?f:c).add(v),u[v]=(u[v]||0)+1,v==="code-snippet"&&R(w,t.attributes.language),d.attributes?.__idx&&(t.attributes.__idx=u[t.tag]),d.dynamicComponentLib&&g.add(d.dynamicComponentLib),!d.attributes)break;if(v==="partial"&&t.attributes?.file){const o=V("file"),l=t[o]||t.attributes.file,h=l.startsWith("/")?l.slice(1):S.posix.normalize(S.posix.join(S.posix.dirname(i),l));b.add(h);const p=(m.getGlobalConfig(B)||{})[h];if(p?.dynamicComponents)for(const L of p.dynamicComponents)g.add(L);if(p?.sharedDataDeps)for(const L of p.sharedDataDeps)k.add(L)}for(const[o,l]of Object.entries(d.attributes)){const h=l.type;if(h&&(h.resolver||l.resolver)){const T=y[h.resolver||l.resolver],p=await T?.(t,o,i,e);p?.sharedDataId&&r.push(p.sharedDataId)}}if(v==="code-walkthrough")for(const o of t.attributes.resolvedFilesets||[])for(const l of o.files||[])R(_,l.language);const I=t.attributes?.attrs;if(I&&t.tag==="html")for(const o of Object.keys(I))o==="src"||o==="srcSet"?await y.htmlSourceAttribute(t,o,i,e):o==="href"&&await y.htmlHref(t,o,i,e);break}return{sharedDataIds:r}}async function z(r){if(!(r instanceof $)){await N.panicOnBuild(r.message);return}E.push(H({type:"resolve_link",meta:{...r.meta,link:r.meta.link??r.meta.rawLink},lines:t.lines,location:t.location,error:{id:"",level:"error",message:r.message,location:t.location}},a.relativePath,a.rawContent))}}),await Promise.all(A),a.sharedDataDeps=k,a.dynamicMarkdocComponents=g,a.validatedAtRevision<m.buildRevision&&(a.markdocErrors=M.validate(a.ast,s).map(t=>H(t,i,a.rawContent)),a.validatedAtRevision=m.buildRevision),{sharedDataDeps:a.sharedDataDeps,dynamicMarkdocComponents:Array.from(a.dynamicMarkdocComponents?.values()??[]),partials:Array.from(b),tagList:Array.from(c),htmlTagsList:Array.from(f),tagOccurrence:u,codeSnippetLanguages:w,codeWalkthroughLanguages:_}}const x=new M.Tokenizer({html:!0,allowIndentation:!0,allowComments:!0});x.parser.block.ruler.getRules("reference").length=0;function J(a,s){const e=x.tokenize(s),n=U(e);return{ast:M.parse(n,{file:a,slots:!0}),rawContent:s,resolveErrors:[],markdocErrors:[],relativePath:a,sharedDataDeps:void 0,validatedAtRevision:-1}}async function dt(a,s){const{data:e}=await s.cache.load(a,"markdown-ast");return j(e.ast)}async function gt(a,s){N.clearMarkdocProblems();const e=a.getAllRoutes();let n=0;const m=F.isInteractive();for(const i of e)await a.resolveRouteStaticData(i,s,!0),n++,m&&n%100===0&&F.logInFooter("validate",` \u{1F50D} Status: validating markdoc (${n}/${e.length})`)}async function ut(a,s,e,n){const m=a.content?G(a.content):"";return await e.context.cache.load(n||a.relativePath,{loader:E,name:"markdown-inline-parser"},[m,String(e.actions.buildRevision)]);async function E(k,g,b){let c;if(a.content){const f=await g.getConfig(),w=await W(a.content,a.relativePath,f.markdown?.partialsFolders,g);c=J(a.relativePath,w)}else c=(await g.cache.load(a.relativePath,"markdown-ast")).data;let u={};if(e.actions.buildRevision!==0&&(u=await C(c,s,e)),!a.isVirtual){for(const f of c.markdocErrors)b(f);for(const f of c.resolveErrors)b(f)}return{ast:c.ast,info:u}}}export{dt as extractMdFirstHeading,J as getAst,ut as parseAndResolveMarkdoc,C as resolveAndValidateMarkdoc,gt as validateAllMarkdowns};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import a from"js-yaml";const c=/^---\r?\n(?:([\s\S]*?)\r?\n)?---\r?\n?/;function m(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function f(t){const n=t.match(c);if(!n)return{frontmatter:{}};const o=n[1]??"";try{const r=a.load(o);return{frontmatter:m(r)?r:{}}}catch(r){const e=r instanceof Error?r.message:String(r);return{frontmatter:{},frontmatterError:e}}}export{f as extractFrontmatter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as y}from"@redocly/config";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as y}from"@redocly/config";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../constants/common.js";import{reporter as R}from"../../tools/notifiers/reporter.js";import{canAccessFeature as g}from"../../utils/entitlements/can-access-feature.js";import{extractMdFirstHeading as A,getAst as T}from"./compiler.js";import{getTemplatePath as w}from"./get-template-path.js";import{prepareMarkdocPartials as M}from"./markdoc/partials.js";import{searchResolver as C}from"./search/search-resolver.js";import{markdownStaticDataLoader as E}from"./markdown-static-data-loader.js";import{makeErrorRoute as I}from"../error-route.js";import{validateRbacConfig as O}from"../validate-rbac-config.js";import{findFrontmatterSlugs as _,getSidebarSharedDataId as G,resolveFrontmatterSlugs as L}from"../utils.js";import{isPartial as j}from"./is-partial.js";import{markdownFrontmatterLoader as B}from"./markdown-frontmatter-loader.js";import{resolveRawPartials as K}from"./markdoc/resolve-raw-partials.js";import{getAiDocumentsStore as N}from"./search/get-ai-search-documents.js";import{registerPageProps as Y}from"../register-page-props.js";import{resolveMarkdownTemplate as q}from"./utils/resolve-markdown-template.js";import{sanitizeMalformedMdContent as z}from"./utils/sanitize-malformed-md-content.js";import{telemetryTraceStep as H}from"../../../cli/telemetry/helpers/trace-step.js";async function le(h){return{id:"markdoc",requiredEntitlements:["markdown"],loaders:{"markdown-frontmatter":B,"markdown-ast":async(e,t)=>{const i=await t.fs.read(e),m=await t.getConfig(),s=await K(i,e,m?.markdown?.partialsFolders,t),n=z(s);return T(e,n)}},processContent:async(e,t)=>{await H("build.plugin.markdown",async i=>{const{markdown:m}=await t.getConfig();i?.setAttribute("config",JSON.stringify(m||{}));const s=m?.partialsFolders??[],n=e.createTemplate("markdown","@redocly/theme/core/templates/Markdown"),S=e.registerServerPropsGetter("markdown",w("./get-server-props.js"));e.createTemplate("error",w("../../../client/app/Error/ErrorDetails.js"));for(const o of t.fs.scan(/\.md$/))if(!await t.isPathIgnored(o.relativePath)&&!j(o.relativePath,s))try{await k(o)}catch(a){e.addRoute(I(o.relativePath,a)),i?.error(a),await R.panicOnBuild("Failed to create route for markdown file: %s",a.message)}async function k(o){const{relativePath:a,realRelativePath:b}=o,{data:{frontmatter:r}}=await t.cache.load(a,"markdown-frontmatter"),P=r?.metadata||{},F=await _(a,"markdown-frontmatter",r,t),p=L(F,a);let d=null;r?.sidebar&&(d=await G(r.sidebar,a,t.fs));let u=n;const f=q({realRelativePath:b,frontmatter:r,markdown:m,contentDir:h.contentDir});f&&(u=e.createTemplate(f.templateRef,f.templatePath)),r?.rbac&&(g("rbac")?O({content:{[a]:r.rbac}}):r.rbac=void 0),g("banner")||(r.banner=void 0),await Y(o,t.fs,e),(p.length?p.reverse():[void 0]).forEach(v=>{e.addRoute({excludeFromSearch:r?.excludeFromSearch||!1,slug:v,fsPath:a,templateId:u,sharedData:d?[{id:d,key:"sidebar"}]:void 0,redirectFrom:Object.entries(r.redirects||{}).map(([l,{type:c}])=>({type:c||301,from:l})),[y]:r?.rbac,getNavText:async()=>(r?.seo?.title||await A(a,t)||"").toString(),metadata:{type:"markdown",...P},async getStaticData(l,c){return E(o,l,t,r,c)},getSearchDocuments:C(r,a,e.getSearchFacets,e.setSearchFacets),getAiDocumentsStore:N(e.getSearchFacets,r),serverPropsGetterIds:[S]})})}})},afterRoutesCreated:async(e,t)=>{const i=await M(t,e);e.setGlobalConfig({[D]:i})}}}export{le as markdownPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as f from"path";import{MARKDOC_PARTIALS_DATA_KEY as D,MARKDOC_PARTIALS_DEPS_KEY as A}from"../../../
|
|
1
|
+
import*as f from"path";import{MARKDOC_PARTIALS_DATA_KEY as D,MARKDOC_PARTIALS_DEPS_KEY as A}from"../../../constants/common.js";import{isPartial as y}from"../is-partial.js";function h(t,s){return Promise.all(t.map(s)).then(i=>t.filter((o,n)=>i[n]))}async function b(t,s){const{markdown:i}=await t.getConfig(),o=i?.partialsFolders??[],n=await h(t.fs.scan(/\.md$/),async a=>!(!f.posix.basename(a.relativePath).endsWith(".md")||await t.isPathIgnored(a.relativePath)||!y(a.relativePath,o)));s.setGlobalConfig({[D]:Object.fromEntries(n.map(a=>[a.relativePath,{}]))});const p={},m={};for(const a of n){const{ast:e,info:r}=await s.parseMarkdoc({input:a,context:t});p[a.relativePath]=e;const l=Array.isArray(r.dynamicMarkdocComponents)?r.dynamicMarkdocComponents:[],c=r.sharedDataDeps instanceof Set?Array.from(r.sharedDataDeps):Array.isArray(r.sharedDataDeps)?r.sharedDataDeps:[],d=Array.isArray(r.partials)?r.partials:[];m[a.relativePath]={dynamicComponents:new Set(l),sharedDataDeps:new Set(c),partials:new Set(d)}}return s.setGlobalConfig({[A]:Object.fromEntries(Object.entries(m).map(([a,e])=>[a,{dynamicComponents:Array.from(e.dynamicComponents),sharedDataDeps:Array.from(e.sharedDataDeps),partials:Array.from(e.partials)}]))}),p}export{b as prepareMarkdocPartials};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{extractFrontmatter as m}from"./extract-frontmatter.js";import{ensureFrontmatterThemeCompatibility as f}from"../ensure-frontmatter-theme-compatibility.js";const w=async(r,t,a)=>{const n=await t.fs.read(r),{frontmatter:e,frontmatterError:o}=m(n);return o&&a(new Error(o)),{frontmatter:await f(e,r,t.fs)}};export{w as markdownFrontmatterLoader};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _ from"@markdoc/markdoc";import D from"node:path";import{AI_SEARCH_CHUNK_SIZE as E,AI_SEARCH_DOCUMENT_CHUNK_SIZE as M}from"../../../constants/plugins/search.js";import{slugger as P}from"../../../../utils/slugger.js";import{joinSectionContent as U}from"./join-section-content.js";import{toMarkdown as b}from"./to-markdown.js";import{AstToSearchNodeTransformer as I}from"./walk-sections.js";import{createRenderTagFn as x}from"./create-render-tag-fn.js";import{getLocaleFromRelativePath as y}from"../../../fs/utils/get-locale-from-relative-path.js";import{HeadingNode as L}from"./nodes/heading-node.js";import{extractDocumentSearchFacets as H}from"./search-facets.js";import{formatDocumentMetadata as K}from"../../search/utils.js";import{TagNode as N}from"./nodes/tag-node.js";import{MARKDOC_PARTIALS_DATA_KEY as R}from"../../../
|
|
1
|
+
import _ from"@markdoc/markdoc";import D from"node:path";import{AI_SEARCH_CHUNK_SIZE as E,AI_SEARCH_DOCUMENT_CHUNK_SIZE as M}from"../../../constants/plugins/search.js";import{slugger as P}from"../../../../utils/slugger.js";import{joinSectionContent as U}from"./join-section-content.js";import{toMarkdown as b}from"./to-markdown.js";import{AstToSearchNodeTransformer as I}from"./walk-sections.js";import{createRenderTagFn as x}from"./create-render-tag-fn.js";import{getLocaleFromRelativePath as y}from"../../../fs/utils/get-locale-from-relative-path.js";import{HeadingNode as L}from"./nodes/heading-node.js";import{extractDocumentSearchFacets as H}from"./search-facets.js";import{formatDocumentMetadata as K}from"../../search/utils.js";import{TagNode as N}from"./nodes/tag-node.js";import{MARKDOC_PARTIALS_DATA_KEY as R}from"../../../constants/common.js";const j=Symbol(),et=(n,r)=>async(e,c,i,s)=>{if(r?.excludeFromSearch)return;P.reset();const a=await e.getNavText?.()||D.basename(e.fsPath),u=_.Ast.fromJSON(c.ast),f=new I({partials:s.getGlobalConfig(R)||{},renderTag:x(s.markdocOptions.tags),getInnerContent:b,ast:u,skipConditionals:!0}),d=Array.from(f.transform());return{async getLLMsTxts(){const o=r?.seo,g=o&&typeof o=="object"&&"description"in o?String(o.description):void 0,C=U(d);return[{title:a,description:g,slug:e.slug,fsPath:e.fsPath,content:C,includeInLLMsTxt:!0}]},async getSearchDocuments(){return F(e,d,n,a)}}};function F(n,r,e,c){const i=n.slug,s=new Map,a=n.metadata||{},u=H(a,e),f=K(a),d=f?`Metadata:
|
|
2
2
|
${f}
|
|
3
3
|
`:"";let o=[];for(const t of r)if(t instanceof L){o.splice(t.attributes.level-1,6);const l=t.attributes.level>2,m=o[o.length-1]?.title,S=o[o.length-1]?.url,T=l&&m?m:O(c,t),A=l&&S?S:t.getUrl(i),h={title:T,content:"",url:A,level:t.attributes.level,toc:o.map(v=>p(v.section)).join(`
|
|
4
4
|
`)};(t.attributes.level>1||p(t)!==c)&&(h.content+=h.content?`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import p from"@markdoc/markdoc";import{REDOCLY_ROUTE_RBAC as l,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{getInnerText as h}from"../../../../markdoc/helpers/get-inner-text.js";import{getSearchDocuments as T}from"./get-search-documents.js";import{AstToSearchNodeTransformer as R}from"./walk-sections.js";import{setDocumentSearchFacets as S,extractDocumentSearchFacets as C}from"./search-facets.js";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../../
|
|
1
|
+
import p from"@markdoc/markdoc";import{REDOCLY_ROUTE_RBAC as l,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{getInnerText as h}from"../../../../markdoc/helpers/get-inner-text.js";import{getSearchDocuments as T}from"./get-search-documents.js";import{AstToSearchNodeTransformer as R}from"./walk-sections.js";import{setDocumentSearchFacets as S,extractDocumentSearchFacets as C}from"./search-facets.js";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../../constants/common.js";import{normalizeFrontmatterKeywords as _}from"../../helpers/normalize-frontmatter-keywords.js";function K(e,m,o,c){return async(t,r,a)=>{if(e?.excludeFromSearch)return[];const i=p.Ast.fromJSON(r.ast),f=new R({ast:i,getInnerContent:h,partials:a.getGlobalConfig(D)||{}}),u=t.metadata||{},n=C(u,o);S(n,o,c);const d=e?.seo?.title||m,{result:s}=_(e?.keywords);return T(f,t.slug,d,r[A],r[l],n,s||void 0)}}export{K as searchResolver};
|
|
@@ -0,0 +1,4 @@
|
|
|
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};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import J from"@jitl/quickjs-singlefile-mjs-release-sync";import{newQuickJSWASMModuleFromVariant as A,shouldInterruptAfterDeadline as I}from"quickjs-emscripten-core";const $=1e4,C=64*1024*1024,L=256*1024,w=100,N=1024*1024,R=1024*1024;let O;function x(){return O??=A(J)}function Y(t){return`(() => {
|
|
2
|
+
const invoke = globalThis.__invoke;
|
|
3
|
+
delete globalThis.__invoke;
|
|
4
|
+
globalThis.tools = Object.freeze({ ${t.map(r=>`${JSON.stringify(r)}: (input) => invoke(${JSON.stringify(r)}, JSON.stringify(input ?? {})).then(JSON.parse)`).join(", ")} });
|
|
5
|
+
})();`}async function F(t,n,r={}){const{timeoutMs:s=$}=r,m=new Set;let M=0,f=0;const e=(await x()).newContext();let l,g=()=>{};const y=new Promise((o,c)=>{g=()=>c(new Error(`Execution timed out after ${s}ms`))}),S=()=>e.runtime.setInterruptHandler(I(Date.now()+s)),p=()=>{clearTimeout(l),l=setTimeout(g,s)};let u;try{e.runtime.setMemoryLimit(C),e.runtime.setMaxStackSize(L),S(),p(),B(e,"__invoke",(E,b)=>{const P=e.getString(E),j=JSON.parse(e.getString(b)),i=e.newPromise();return m.add(i),f++,clearTimeout(l),(++M>w?Promise.reject(new Error(`Exceeded the limit of ${w} tool calls`)):Promise.resolve().then(()=>n[P](j))).then(a=>{if(!e.alive)return;const d=JSON.stringify(a??null);if(d.length>N){const k=`Tool output is too large (${d.length} bytes); request narrower data instead`;e.newError(k).consume(i.reject)}else e.newString(d).consume(i.resolve)},a=>{e.alive&&e.newError(h(a)).consume(i.reject)}),i.settled.then(()=>{e.alive&&(S(),--f===0&&p(),e.runtime.executePendingJobs())}),i.handle}),U(e,Y(Object.keys(n))),u=e.unwrapResult(e.evalCode(`(async () => {
|
|
6
|
+
${t}
|
|
7
|
+
})()`));const o=e.resolvePromise(u);e.runtime.executePendingJobs();const c=await Promise.race([o,y]),T=e.unwrapResult(c),_=e.dump(T);T.dispose();const v=JSON.stringify(_??null).length;return v>R?{error:`Result is too large (${v} bytes); return less data`}:{result:_}}catch(o){return{error:h(o)}}finally{clearTimeout(l),u?.dispose();for(const o of m)o.alive&&o.dispose();try{e.dispose()}catch{O=void 0}}}function B(t,n,r){t.newFunction(n,r).consume(s=>t.setProp(t.global,n,s))}function U(t,n){t.unwrapResult(t.evalCode(n)).dispose()}function h(t){return t instanceof Error?t.message:String(t)}export{F as runInSandbox};
|
|
File without changes
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { McpToolSchema } from '../../../types';
|
|
2
|
+
export declare const EXECUTE_TOOL_NAME = "execute";
|
|
3
|
+
export declare const EXECUTE_TOOL_SCHEMA: McpToolSchema;
|
|
2
4
|
export declare function getDefaultToolSchemas(config: {
|
|
3
5
|
products?: string[];
|
|
4
6
|
requiresLogin: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{shouldHandleMcpAuth as
|
|
1
|
+
import{shouldHandleMcpAuth as p}from"../auth/auth-handlers.js";import{GRAPHQL_TYPE_KINDS as l}from"./tools/graphql/types.js";const s=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD","TRACE"],t={type:"string",nullable:!0},n={codemodeType:"OpenApiServer[]"},r={codemodeType:"OpenApiSecurityRequirement[]"},o={codemodeType:"Record<string, OpenApiSecurityScheme>"},c={codemodeType:"OpenApiDocument"},u={codemodeType:"OpenApiOperation & { path: string; method: string }"},m="execute",P={name:m,description:"Run JavaScript in a sandbox to orchestrate multiple documentation tools in one call.",schema:{type:"object",required:["code","description"],additionalProperties:!1,properties:{code:{type:"string",description:"JavaScript to run in the sandbox. Return a value to receive it as the result.",minLength:1},description:{type:"string",description:"A short, human-readable summary of what this code does (shown to users in place of the raw call).",minLength:1}}}},d={type:"object",additionalProperties:!1,required:[],properties:{filter:{type:"string",description:"API name (or part of it)",minLength:1,nullable:!0},page:{type:"number",description:"Page number",minimum:1,default:1,nullable:!0},limit:{type:"number",description:"Number of APIs per page. Default is 300",minimum:1,default:300,nullable:!0}}},a={type:"object",required:["name"],additionalProperties:!1,properties:{name:{type:"string",description:"API name",minLength:1},version:{type:"string",description:"API version (required when multiple APIs share the same name but differ by version)",nullable:!0}}},h={type:"object",required:["name","path","method"],additionalProperties:!1,properties:{name:{type:"string",description:"API name",minLength:1},path:{type:"string",description:"Endpoint path (e.g. /api/v1/users)",minLength:1},method:{type:"string",description:"HTTP method (GET, POST, PUT, DELETE, etc.)",enum:[...s,...s.map(e=>e.toLowerCase())],minLength:1},version:{type:"string",description:"API version (required when multiple APIs share the same name but differ by version)",nullable:!0}}},y={type:"object",required:[],additionalProperties:!1,properties:{}};function q(e){const i=[{name:"list-apis",description:"Lists available APIs with their context and purpose",schema:d,annotations:{title:"List APIs",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{name:{type:"string"},description:t,version:t,servers:n}}},limit:{type:"number"},total:{type:"number"},page:{type:"number"},totalPages:{type:"number"}}}},{name:"get-endpoints",description:"Get all endpoints for a specific API",schema:a,annotations:{title:"Get Endpoints",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{api:{type:"string"},version:{type:"string"},servers:n,endpoints:{type:"array",items:{type:"object",properties:{path:{type:"string"},method:{type:"string"},summary:t,description:t,security:r}}}}}},{name:"get-endpoint-info",description:"Get comprehensive information about specific endpoint including parameters, security, and examples",schema:h,annotations:{title:"Get Endpoint Info",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{api:{type:"string"},version:{type:"string"},servers:n,endpoint:u,globalSecurity:r,securitySchemes:o}}},{name:"get-security-schemes",description:"Get the security schemes for a specific API",schema:a,annotations:{title:"Get Security Schemes",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{name:t,version:t,securitySchemes:o,security:r}}},{name:"get-full-api-description",description:"Get the complete OpenAPI description",schema:a,annotations:{title:"Get Full API Description",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{api:{type:"string"},version:{type:"string"},definition:c}}},v(e.products)];return p(e.requiresLogin,e.rbac)&&i.push({name:"whoami",description:"Get information about the currently authenticated user",schema:y,annotations:{title:"Who Am I",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},outputSchema:{type:"object",properties:{email:{type:"string"},name:{type:"string"},subject:{type:"string"},clientId:{type:"string"},scope:{type:"string"},issuedAt:{type:"string"},expiresAt:{type:"string"}}}}),e.hasGraphqlApis&&i.push(...H()),i}const g={type:"object",required:[],additionalProperties:!1,properties:{filter:{type:"string",description:"GraphQL schema name (or part of it)",minLength:1,nullable:!0},page:{type:"number",description:"Page number",minimum:1,default:1,nullable:!0},limit:{type:"number",description:"Number of results per page. Default is 300",minimum:1,default:300,nullable:!0}}},f={type:"object",required:["name"],additionalProperties:!1,properties:{name:{type:"string",description:"GraphQL schema name",minLength:1},kind:{type:"string",description:"Optional: return only a single category of schema members",enum:[...l],nullable:!0},filter:{type:"string",description:'Optional: only members whose name contains this substring (e.g. "book")',minLength:1,nullable:!0},referencesType:{type:"string",description:'Optional: only members that reference this type directly or transitively (via return, field, argument, union-member or input-field types). Finds cross-cutting members that never name it \u2014 e.g. referencesType "Book" surfaces a search query returning a union that includes Book.',minLength:1,nullable:!0},page:{type:"number",description:"Page number",minimum:1,default:1,nullable:!0},limit:{type:"number",description:"Number of results per page. Default is 300",minimum:1,default:300,nullable:!0}}},b={type:"object",required:["name","type"],additionalProperties:!1,properties:{name:{type:"string",description:"GraphQL schema name",minLength:1},type:{type:"string",description:"Name of the type, operation, or directive",minLength:1},includeReferencedTypes:{type:"boolean",description:"Also include the SDL of every type referenced transitively. Gives the whole subgraph at once, but can be large for highly-connected types.",default:!1,nullable:!0}}},S={type:"object",required:["name"],additionalProperties:!1,properties:{name:{type:"string",description:"GraphQL schema name",minLength:1}}};function H(){return[{name:"list-graphql-apis",description:"Lists available GraphQL schemas with their context and purpose",schema:g,annotations:{title:"List GraphQL APIs",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},{name:"get-graphql-type-list",description:'List all operations and types in a GraphQL schema as a flat, paginated list. Each item is tagged with its kind (query, object, enum, \u2026) and carries a one-line description; operations also include their return type and argument signature \u2014 use it to decide which members to fetch in detail. Narrow the result with `kind` (one category) and/or `filter` (member-name substring, e.g. "book") to explore a domain cheaply instead of pulling the full schema.',schema:f,annotations:{title:"Get GraphQL Type List",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},{name:"get-graphql-type",description:"Get the SDL for a single GraphQL type, operation (query/mutation/subscription field), or directive. Set includeReferencedTypes to also pull in every type it references transitively \u2014 the full structural subgraph in one call, ideal for complete exploration of an entity (e.g. Book and all the types it touches).",schema:b,annotations:{title:"Get GraphQL Type",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},{name:"get-graphql-schema",description:"Get the complete GraphQL schema as SDL \u2014 the whole type graph in one call. Returns everything, so it can be very large and token-expensive for big schemas; prefer get-graphql-type-list (filter/paginate) plus targeted get-graphql-type calls, and reach for this only for small schemas or when you truly need the full SDL.",schema:S,annotations:{title:"Get GraphQL Schema",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}]}function v(e){return{name:"search",description:"Search across the documentation to fetch relevant content for a given query",schema:e&&e.length>0?{type:"object",required:["query"],additionalProperties:!1,properties:{query:{type:"string",description:"Search query. Should be a single word or that phrase that is presented in a documentation.",minLength:1},product:{type:"string",description:"Optional product name to filter search results by specific product.",enum:e,nullable:!0}}}:{type:"object",required:["query"],additionalProperties:!1,properties:{query:{type:"string",description:"Search query. Should be a single word or that phrase that is presented in a documentation.",minLength:1}}},annotations:{title:"Search Documentation",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},outputSchema:{type:"string"}}}export{m as EXECUTE_TOOL_NAME,P as EXECUTE_TOOL_SCHEMA,q as getDefaultToolSchemas};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
+
import type { SearchArgs } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
|
-
search: McpToolHandler
|
|
4
|
+
search: McpToolHandler<SearchArgs>;
|
|
4
5
|
};
|
|
5
6
|
export default _default;
|
|
6
7
|
//# sourceMappingURL=search.d.ts.map
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
+
import type { WhoamiArgs } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
|
-
whoami: McpToolHandler
|
|
4
|
+
whoami: McpToolHandler<WhoamiArgs>;
|
|
4
5
|
};
|
|
5
6
|
export default _default;
|
|
6
7
|
//# sourceMappingURL=whoami.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mcpToolHandlers as s}from"../../../../../client/mcp-tool-handlers-entry.js";import{EXECUTE_TOOL_NAME as c}from"../tool-schemas.js";import{sanitizeToolName as u}from"../codemode/build-execute-tool-description.js";import{runInSandbox as f}from"../codemode/sandbox.js";import{executeMcpTool as l,isMcpToolAvailable as m}from"../../workers/execute-mcp-tool.js";const p=async(t,r,n)=>{const o=await y(r,n),{result:i,error:e}=await f(t.code,o);return{content:[{type:"text",text:JSON.stringify({result:i,error:e})}],isError:e!==void 0}};async function y(t,r){const n={};for(const o of Object.keys(s))o!==c&&await d(o,t)&&(n[u(o)]=async i=>{const e=await l({toolName:o,args:i,context:t,extra:r}),a=x(e);if(e.isError)throw new Error(a);return T(a)});return n}async function d(t,r){try{return await m({toolName:t,context:r})}catch{return!1}}function x(t){return t.content.filter(r=>r.type==="text").map(r=>r.text).join("")}function T(t){try{return JSON.parse(t)}catch{return t}}var g={[c]:p};export{g as default};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
+
import type { GetGraphqlSchemaArgs } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
|
-
'get-graphql-schema': McpToolHandler<
|
|
4
|
-
name: string;
|
|
5
|
-
}>;
|
|
4
|
+
'get-graphql-schema': McpToolHandler<GetGraphqlSchemaArgs>;
|
|
6
5
|
};
|
|
7
6
|
export default _default;
|
|
8
7
|
//# sourceMappingURL=get-graphql-schema.d.ts.map
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GetGraphqlTypeListArgs } from './types.js';
|
|
3
3
|
declare const _default: {
|
|
4
|
-
'get-graphql-type-list': McpToolHandler<
|
|
5
|
-
name: string;
|
|
6
|
-
kind?: GraphqlTypeKind;
|
|
7
|
-
filter?: string;
|
|
8
|
-
referencesType?: string;
|
|
9
|
-
page?: number;
|
|
10
|
-
limit?: number;
|
|
11
|
-
}>;
|
|
4
|
+
'get-graphql-type-list': McpToolHandler<GetGraphqlTypeListArgs>;
|
|
12
5
|
};
|
|
13
6
|
export default _default;
|
|
14
7
|
//# sourceMappingURL=get-graphql-type-list.d.ts.map
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
+
import type { GetGraphqlTypeArgs } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
|
-
'get-graphql-type': McpToolHandler<
|
|
4
|
-
name: string;
|
|
5
|
-
type: string;
|
|
6
|
-
includeReferencedTypes?: boolean;
|
|
7
|
-
}>;
|
|
4
|
+
'get-graphql-type': McpToolHandler<GetGraphqlTypeArgs>;
|
|
8
5
|
};
|
|
9
6
|
export default _default;
|
|
10
7
|
//# sourceMappingURL=get-graphql-type.d.ts.map
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
+
import type { ListGraphqlApisArgs } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
|
-
'list-graphql-apis': McpToolHandler<
|
|
4
|
-
filter?: string;
|
|
5
|
-
page?: number;
|
|
6
|
-
limit?: number;
|
|
7
|
-
}>;
|
|
4
|
+
'list-graphql-apis': McpToolHandler<ListGraphqlApisArgs>;
|
|
8
5
|
};
|
|
9
6
|
export default _default;
|
|
10
7
|
//# sourceMappingURL=list-graphql-apis.d.ts.map
|
|
@@ -7,4 +7,25 @@ export type SchemaMember = {
|
|
|
7
7
|
args?: string;
|
|
8
8
|
};
|
|
9
9
|
export type GroupedSchemaTypes = Record<GraphqlTypeKind, SchemaMember[]>;
|
|
10
|
+
export type ListGraphqlApisArgs = {
|
|
11
|
+
filter?: string;
|
|
12
|
+
page?: number;
|
|
13
|
+
limit?: number;
|
|
14
|
+
};
|
|
15
|
+
export type GetGraphqlTypeListArgs = {
|
|
16
|
+
name: string;
|
|
17
|
+
kind?: GraphqlTypeKind;
|
|
18
|
+
filter?: string;
|
|
19
|
+
referencesType?: string;
|
|
20
|
+
page?: number;
|
|
21
|
+
limit?: number;
|
|
22
|
+
};
|
|
23
|
+
export type GetGraphqlTypeArgs = {
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
includeReferencedTypes?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type GetGraphqlSchemaArgs = {
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
10
31
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,50 +1,15 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
'list-apis': import("../../types.js").McpToolHandler<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'get-
|
|
12
|
-
|
|
13
|
-
path: string;
|
|
14
|
-
method: string;
|
|
15
|
-
version?: string;
|
|
16
|
-
}>;
|
|
17
|
-
'get-security-schemes': import("../../types.js").McpToolHandler<{
|
|
18
|
-
name: string;
|
|
19
|
-
version?: string;
|
|
20
|
-
}>;
|
|
21
|
-
'get-full-api-description': import("../../types.js").McpToolHandler<{
|
|
22
|
-
name: string;
|
|
23
|
-
version?: string;
|
|
24
|
-
}>;
|
|
25
|
-
search: import("../../types.js").McpToolHandler;
|
|
26
|
-
whoami: import("../../types.js").McpToolHandler;
|
|
27
|
-
'list-graphql-apis': import("../../types.js").McpToolHandler<{
|
|
28
|
-
filter?: string;
|
|
29
|
-
page?: number;
|
|
30
|
-
limit?: number;
|
|
31
|
-
}>;
|
|
32
|
-
'get-graphql-type-list': import("../../types.js").McpToolHandler<{
|
|
33
|
-
name: string;
|
|
34
|
-
kind?: import("./graphql/types.js").GraphqlTypeKind;
|
|
35
|
-
filter?: string;
|
|
36
|
-
referencesType?: string;
|
|
37
|
-
page?: number;
|
|
38
|
-
limit?: number;
|
|
39
|
-
}>;
|
|
40
|
-
'get-graphql-type': import("../../types.js").McpToolHandler<{
|
|
41
|
-
name: string;
|
|
42
|
-
type: string;
|
|
43
|
-
includeReferencedTypes?: boolean;
|
|
44
|
-
}>;
|
|
45
|
-
'get-graphql-schema': import("../../types.js").McpToolHandler<{
|
|
46
|
-
name: string;
|
|
47
|
-
}>;
|
|
2
|
+
'list-apis': import("../../types.js").McpToolHandler<import("./openapi/types.js").ListApisArgs>;
|
|
3
|
+
'get-endpoints': import("../../types.js").McpToolHandler<import("./openapi/types.js").ApiNameVersionArgs>;
|
|
4
|
+
'get-endpoint-info': import("../../types.js").McpToolHandler<import("./openapi/types.js").GetEndpointInfoArgs>;
|
|
5
|
+
'get-security-schemes': import("../../types.js").McpToolHandler<import("./openapi/types.js").ApiNameVersionArgs>;
|
|
6
|
+
'get-full-api-description': import("../../types.js").McpToolHandler<import("./openapi/types.js").ApiNameVersionArgs>;
|
|
7
|
+
search: import("../../types.js").McpToolHandler<import("./core/types.js").SearchArgs>;
|
|
8
|
+
whoami: import("../../types.js").McpToolHandler<import("./core/types.js").WhoamiArgs>;
|
|
9
|
+
'list-graphql-apis': import("../../types.js").McpToolHandler<import("./graphql/types.js").ListGraphqlApisArgs>;
|
|
10
|
+
'get-graphql-type-list': import("../../types.js").McpToolHandler<import("./graphql/types.js").GetGraphqlTypeListArgs>;
|
|
11
|
+
'get-graphql-type': import("../../types.js").McpToolHandler<import("./graphql/types.js").GetGraphqlTypeArgs>;
|
|
12
|
+
'get-graphql-schema': import("../../types.js").McpToolHandler<import("./graphql/types.js").GetGraphqlSchemaArgs>;
|
|
48
13
|
};
|
|
49
14
|
export default _default;
|
|
50
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
+
import type { GetEndpointInfoArgs } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
|
-
'get-endpoint-info': McpToolHandler<
|
|
4
|
-
name: string;
|
|
5
|
-
path: string;
|
|
6
|
-
method: string;
|
|
7
|
-
version?: string;
|
|
8
|
-
}>;
|
|
4
|
+
'get-endpoint-info': McpToolHandler<GetEndpointInfoArgs>;
|
|
9
5
|
};
|
|
10
6
|
export default _default;
|
|
11
7
|
//# sourceMappingURL=get-endpoint-info.d.ts.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
+
import type { ApiNameVersionArgs } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
|
-
'get-endpoints': McpToolHandler<
|
|
4
|
-
name: string;
|
|
5
|
-
version?: string;
|
|
6
|
-
}>;
|
|
4
|
+
'get-endpoints': McpToolHandler<ApiNameVersionArgs>;
|
|
7
5
|
};
|
|
8
6
|
export default _default;
|
|
9
7
|
//# sourceMappingURL=get-endpoints.d.ts.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
+
import type { ApiNameVersionArgs } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
|
-
'get-full-api-description': McpToolHandler<
|
|
4
|
-
name: string;
|
|
5
|
-
version?: string;
|
|
6
|
-
}>;
|
|
4
|
+
'get-full-api-description': McpToolHandler<ApiNameVersionArgs>;
|
|
7
5
|
};
|
|
8
6
|
export default _default;
|
|
9
7
|
//# sourceMappingURL=get-full-api-description.d.ts.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
+
import type { ApiNameVersionArgs } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
|
-
'get-security-schemes': McpToolHandler<
|
|
4
|
-
name: string;
|
|
5
|
-
version?: string;
|
|
6
|
-
}>;
|
|
4
|
+
'get-security-schemes': McpToolHandler<ApiNameVersionArgs>;
|
|
7
5
|
};
|
|
8
6
|
export default _default;
|
|
9
7
|
//# sourceMappingURL=get-security-schemes.d.ts.map
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { McpToolHandler } from '../../../types.js';
|
|
2
|
+
import type { ListApisArgs } from './types.js';
|
|
2
3
|
declare const _default: {
|
|
3
|
-
'list-apis': McpToolHandler<
|
|
4
|
-
filter?: string;
|
|
5
|
-
page?: number;
|
|
6
|
-
limit?: number;
|
|
7
|
-
}>;
|
|
4
|
+
'list-apis': McpToolHandler<ListApisArgs>;
|
|
8
5
|
};
|
|
9
6
|
export default _default;
|
|
10
7
|
//# sourceMappingURL=list-apis.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type ListApisArgs = {
|
|
2
|
+
filter?: string;
|
|
3
|
+
page?: number;
|
|
4
|
+
limit?: number;
|
|
5
|
+
};
|
|
6
|
+
export type ApiNameVersionArgs = {
|
|
7
|
+
name: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
};
|
|
10
|
+
export type GetEndpointInfoArgs = {
|
|
11
|
+
name: string;
|
|
12
|
+
path: string;
|
|
13
|
+
method: string;
|
|
14
|
+
version?: string;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=types.d.ts.map
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{telemetry as c}from"../../../telemetry/index.js";import{McpErrorCodes as o,McpServerType as
|
|
1
|
+
import{telemetry as c}from"../../../telemetry/index.js";import{McpErrorCodes as o,McpServerType as i}from"../constants.js";import{getMcpMode as d}from"../mode.js";class n extends Error{code;data;requestId;constructor(r,t,s,a){super(t),this.name="McpError",this.code=r,this.data=s,this.requestId=a}createErrorResponse(){const r={jsonrpc:"2.0",error:{code:this.code,message:this.message,...this.data?{data:this.data}:{}},id:this.requestId??null},t=u(this.code);return new Response(JSON.stringify(r),{status:t,headers:{"Content-Type":"application/json"}})}}function u(e){switch(e){case o.InvalidRequest:case o.InvalidParams:return 400;case o.MethodNotFound:return 404;case o.ServerError:return 405;case o.InternalError:default:return 500}}function h(e){return new n(o.ServerError,"Method not allowed",void 0,e).createErrorResponse()}function p(e,r=i.Docs,t){const s=e instanceof Error?e.message:String(e),a=e instanceof Error?e.stack:void 0;return c.sendMcpErrorMessage([{id:r,object:"mcpServer",uri:`urn:redocly:realm:mcp:server:${r}`,server_type:r,message:s,stack:a||"",mode:d()}]),new n(o.InternalError,"Internal server error mcp",s,t).createErrorResponse()}function v(e="Invalid request",r){return new n(o.InvalidRequest,e,void 0,r).createErrorResponse()}function I(e="Invalid parameters",r){return new n(o.InvalidParams,e,void 0,r).createErrorResponse()}async function M(e,r,t){try{return await e()}catch(s){return c.sendMcpErrorMessage([{id:r,object:"mcpServer",uri:`urn:redocly:realm:mcp:server:${r}`,server_type:r,message:s?.message||"",stack:s?.stack||"",mode:d()}]),t&&t(),p(s,r)}}export{n as McpError,p as createInternalServerError,I as createInvalidParamsError,v as createInvalidRequestError,h as createMethodNotAllowedError,M as withErrorHandling};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileURLToPath as
|
|
1
|
+
import{fileURLToPath as E}from"node:url";import{dirname as O,join as a}from"node:path";import{logger as u}from"../../tools/notifiers/logger.js";import{reporter as R}from"../../tools/notifiers/reporter.js";import{isDefined as q}from"../../../utils/guards/is-defined.js";import{buildGraphqlDescriptions as w,filterIgnoredApiDescriptions as h,getCleanedUpApiDescriptions as A,isMcpInRedirects as T}from"./utils.js";import{isMcpCodeModeEnabled as _}from"./mode.js";import{getDefaultToolSchemas as j,EXECUTE_TOOL_SCHEMA as L}from"./docs-mcp/tool-schemas.js";import{telemetryTraceStep as G}from"../../../cli/telemetry/helpers/trace-step.js";const D="mcp-docs-server-handler",p=O(E(import.meta.url));async function H(){let o=!1;return{id:"mcp",async processContent(e,i){o||await G("build.plugin.mcp",async c=>{const r=await e.loadOpenApiDefinitions(i),d=await e.loadGraphqlDefinitions(i),n=await i.getConfig(),{mcp:t,redirects:v}=n;if(c?.setAttribute("config",JSON.stringify(t||{})),!(t?.hide||t?.docs?.hide)&&(T(v)&&await R.panicOnBuildContentError('The reserved route "/mcp" cannot be used in redirect configuration. Please remove any redirects involving "/mcp" from your redocly.yaml config.'),!t?.docs?.hide)){u.info("Configuring MCP servers...");const C=a(p,"./handlers/docs-mcp-handler.js"),M=A(h(r,t?.docs?.ignore||[])),l=new Map;for(const s of M){const f=s.definition.info?.title||"",g=s.definition.info?.version||"";l.set(`${f.toLowerCase()}@${g}`,{name:f,description:s.definition.info?.description||"",version:g,servers:s.definition.servers||[],relativePath:s.relativePath})}const m=w(h(d,t?.docs?.ignore||[])),P=Object.values(n.products||{}).map(s=>s?.name).filter(q),S=!!n?.access?.requiresLogin,b=n?.access?.rbac||{},y=j({products:P,requiresLogin:S,rbac:b,hasGraphqlApis:m.length>0});e.addMcpTools(a(p,"./docs-mcp/tools/index.js"),y),_()&&e.addMcpTools(a(p,"./docs-mcp/tools/execute.js"),[L]),await I({actions:e,handlerPath:C,apiDescriptionsMap:Object.fromEntries(l),graphqlDescriptions:m,mcpConfig:t}),o=!0}})},async afterRoutesCreated(e,i){const c=await i.getConfig(),{mcp:r}=c;e.setGlobalData({mcpData:{docs:{enabled:!r?.hide&&!r?.docs?.hide,name:r?.docs?.name}}})}}}var z=H;async function I({actions:o,handlerPath:e,apiDescriptionsMap:i,graphqlDescriptions:c,mcpConfig:r}){o.createRequestHandler(D,e),o.addApiRoute({slug:"/mcp",requestHandlerId:D,httpMethod:"all",getStaticData:async()=>({props:{config:{apiDescriptionsMap:i,graphqlDescriptions:c,mcpDocsServerName:r?.docs?.name||"Docs MCP Server"},serverOutDir:o.serverOutDir,tools:o.getMcpTools().map(({importPath:d,...n})=>n)}})}),u.info("Registered Docs MCP Server endpoint at /mcp")}export{D as MCP_DOCS_SERVER_HANDLER_ID,z as default,H as mcpServerPlugin};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { McpMode } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Codemode (a single `execute` tool) is gated by a feature flag, not client config, so
|
|
4
|
+
* only we control the rollout. Kept in its own module so the worker / telemetry path
|
|
5
|
+
* does not pull in the heavier `utils.js` dependencies.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isMcpCodeModeEnabled(): boolean;
|
|
8
|
+
export declare function getMcpMode(): McpMode;
|
|
9
|
+
//# sourceMappingURL=mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{envConfig as o}from"../../config/env-config.js";function e(){return o.REDOCLY_EXP_MCP_CODE_MODE_ENABLED??!1}function t(){return e()?"code":"tools"}export{t as getMcpMode,e as isMcpCodeModeEnabled};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{McpServer as
|
|
1
|
+
import{McpServer as T}from"@redocly/mcp-typescript-sdk/server/mcp.js";import{StreamableHTTPServerTransport as b}from"@redocly/mcp-typescript-sdk/server/streamableHttp.js";import{logger as m}from"../../../tools/notifiers/logger.js";import{mcpToolWorkers as u,MCP_TOOL_WORKER_KEY as _,MCP_TOOL_IS_AVAILABLE_KEY as g}from"../../../workers/mcp-tool-worker-pool.js";import{EXECUTE_TOOL_NAME as i,EXECUTE_TOOL_SCHEMA as I}from"../docs-mcp/tool-schemas.js";import{buildExecuteToolDescription as M}from"../docs-mcp/codemode/build-execute-tool-description.js";import{isMcpCodeModeEnabled as S}from"../mode.js";async function A({name:e,tools:f,context:d}){const a=new T({name:e,version:new Date().toISOString().slice(0,10)},{capabilities:{logging:{}}}),s=new b({sessionIdGenerator:void 0}),n=C(d),c=o=>async(r,t)=>{m.info(`MCP tool called: ${o}`);const E={toolName:o,args:r,context:n,extra:h(t)};return await u.exec(_,[E],{timeout:6e4})},l=async o=>{try{return await u.exec(g,[{toolName:o,context:n}],{timeout:1e4})}catch(r){return m.error(`Failed to check MCP tool availability for "${o}": ${r instanceof Error?r.message:String(r)}`),!1}},p=f.filter(o=>o.name!==i);if(S()){const o=[];for(const r of p)await l(r.name)&&o.push(r);a.tool(i,M(o),I.schema,c(i))}else for(const o of p){const r=o.annotations||{title:o.name},t=a.tool(o.name,o.description,o.schema,r,c(o.name));await l(o.name)||t.disable()}return await a.connect(s),{server:a,transport:s,cleanup:async()=>{s.close()}}}function h(e){return{sessionId:e.sessionId,authInfo:e.authInfo,requestId:e.requestId,requestInfo:e.requestInfo,_meta:e._meta}}function C(e){return{user:e.user,config:e.config,outdir:e.outdir,baseUrl:e.baseUrl,params:e.params,query:e.query,cookies:e.cookies,apiDescriptionsMap:e.apiDescriptionsMap,graphqlDescriptions:e.graphqlDescriptions,products:e.products,accessToken:e.accessToken,metadata:e.metadata}}export{A as createDocsMcpServer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{telemetry as
|
|
1
|
+
import{telemetry as u}from"../../../telemetry/index.js";import{mcpToolHandlers as p}from"../../../../client/mcp-tool-handlers-entry.js";import{getMcpMode as m}from"../mode.js";import{reportMcpToolCalled as w,reportMcpToolError as f}from"./mcp-tool-telemetry.js";async function b(n){u.initialize();const{toolName:t,args:c,context:o,extra:l}=n,r=m();try{const e=p[t];if(!e)throw new Error(`Unknown MCP tool: ${t}`);const{default:d}=await e(),i=d[t];if(!i)throw new Error(`MCP tool module does not export a handler for "${t}". Expected \`export default { '${t}': handler }\`.`);const a=await(typeof i=="function"?i:i.execute)(c,o,l);if(!x(a))throw new Error(`MCP tool "${t}" returned an invalid result.`);if(a.isError)f(t,a.content.map(({text:s})=>s).join(" "),r);else{const s=a.content.map(({text:h})=>h).join("").length;w(t,r,s)}return a}catch(e){throw f(t,e instanceof Error?e.message:String(e),r,e instanceof Error&&e.stack||""),e}}function x(n){return!n||typeof n!="object"?!1:Array.isArray(n.content)}async function T(n){u.initialize();const{toolName:t,context:c}=n;try{const o=p[t];if(!o)return!1;const{default:l}=await o(),r=l[t];return r?typeof r=="object"&&typeof r.isAvailable=="function"?await r.isAvailable(c):!0:!1}catch(o){throw f(t,"Failed to check if MCP tool is available: "+(o instanceof Error?o.message:String(o)),m(),o instanceof Error&&o.stack||""),o}}export{b as executeMcpTool,T as isMcpToolAvailable};
|