@redocly/reef 0.140.0-next.1 → 0.140.0-next.13
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 +419 -199
- package/dist/api-schemas/mcp-fetch-count.d.ts +2 -18
- package/dist/api-schemas/otel-traces.d.ts +7 -1345
- package/dist/api-schemas/otel-traces.js +1 -1
- package/dist/api-schemas/search-facets.d.ts +3 -31
- package/dist/api-schemas/search.d.ts +6 -52
- package/dist/cli/build/index.js +1 -1
- package/dist/cli/eject/resolveEjectParams.js +1 -1
- package/dist/cli/generate/get-schema-template.js +1 -1
- package/dist/client/app/hooks/markdown/useMarkdocRenderer.js +1 -1
- package/dist/client/app/hooks/markdown/useMarkdownText.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.d.ts +2 -0
- package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.js +1 -1
- package/dist/client/app/markdoc/custom-components/openapi/use-markdown-adapter.d.ts +1 -33
- package/dist/client/app/useGlobalData.d.ts +1 -1
- package/dist/client/providers/post-message/use-post-message.d.ts +1 -1
- package/dist/client/templates/api-docs/helpers.js +3 -3
- package/dist/compiled/@redocly/pii/index.mjs +1 -0
- package/dist/compiled/@redocly/pii/package.json +1 -0
- package/dist/compiled/svgo/svgo-node.js +1 -1
- package/dist/constants/l10n/langs/ar.js +1 -1
- package/dist/constants/l10n/langs/de.js +1 -1
- package/dist/constants/l10n/langs/en.js +1 -1
- package/dist/constants/l10n/langs/es.js +1 -1
- package/dist/constants/l10n/langs/fr.js +1 -1
- package/dist/constants/l10n/langs/hi.js +1 -1
- package/dist/constants/l10n/langs/it.js +1 -1
- package/dist/constants/l10n/langs/ja.js +1 -1
- package/dist/constants/l10n/langs/ko.js +1 -1
- package/dist/constants/l10n/langs/pl.js +1 -1
- package/dist/constants/l10n/langs/pt-BR.js +1 -1
- package/dist/constants/l10n/langs/pt.js +1 -1
- package/dist/constants/l10n/langs/ru.js +1 -1
- package/dist/constants/l10n/langs/uk.js +1 -1
- package/dist/constants/l10n/langs/zh.js +1 -1
- package/dist/markdoc/attributes/definition-path.d.ts +1 -1
- package/dist/markdoc/attributes/json-example-ref.d.ts +1 -1
- package/dist/markdoc/attributes/json-schema-ref.d.ts +1 -1
- package/dist/markdoc/attributes/parsed-yaml.d.ts +1 -1
- package/dist/markdoc/attributes/raw-content.d.ts +1 -1
- package/dist/markdoc/attributes/sample-from-json-schema.d.ts +1 -1
- package/dist/markdoc/helpers/extract-rbac-from-condition-node.d.ts +1 -1
- package/dist/markdoc/helpers/get-inner-text.d.ts +1 -1
- package/dist/markdoc/helpers/get-node-attribute.d.ts +1 -1
- package/dist/markdoc/helpers/get-variable.d.ts +1 -1
- package/dist/markdoc/helpers/guards/is-conditional-node.d.ts +1 -1
- package/dist/markdoc/helpers/guards/is-function.d.ts +1 -1
- package/dist/markdoc/helpers/guards/is-node.d.ts +1 -1
- package/dist/markdoc/helpers/guards/is-prompt-node.d.ts +1 -1
- package/dist/markdoc/helpers/guards/is-tag.d.ts +1 -1
- package/dist/markdoc/helpers/guards/is-variable.d.ts +1 -1
- package/dist/markdoc/helpers/parse-partials.d.ts +1 -1
- package/dist/markdoc/helpers/parse-partials.js +1 -1
- package/dist/markdoc/helpers/remove-markdoc-tags.js +1 -1
- package/dist/markdoc/helpers/set-node-attribute-value.d.ts +1 -1
- package/dist/markdoc/nodes/fence/index.d.ts +1 -1
- package/dist/markdoc/nodes/fence/index.js +1 -1
- package/dist/markdoc/nodes/gfm-list-item.d.ts +1 -1
- package/dist/markdoc/nodes/gfm-list-item.js +1 -1
- package/dist/markdoc/nodes/heading.d.ts +1 -1
- package/dist/markdoc/nodes/heading.js +1 -1
- package/dist/markdoc/nodes/index.d.ts +6 -165
- package/dist/markdoc/nodes/index.js +1 -1
- package/dist/markdoc/nodes/table.d.ts +1 -1
- package/dist/markdoc/nodes/table.js +1 -1
- package/dist/markdoc/nodes/text.d.ts +1 -1
- package/dist/markdoc/tags/json-example.js +1 -1
- package/dist/markdoc/tags/openapi-code-sample.js +1 -1
- package/dist/server/api-routes/execute-api-route.js +1 -1
- package/dist/server/api-routes/run-api-routes-worker.js +1 -1
- package/dist/server/config/env-config.d.ts +26 -24
- package/dist/server/config/env-schema.d.ts +87 -326
- package/dist/server/config/env-schemas/api-urls.d.ts +2 -14
- package/dist/server/config/env-schemas/auth.d.ts +10 -32
- package/dist/server/config/env-schemas/catalog.d.ts +6 -9
- package/dist/server/config/env-schemas/database.d.ts +2 -8
- package/dist/server/config/env-schemas/environment-detection.d.ts +20 -18
- package/dist/server/config/env-schemas/feature-flags.d.ts +29 -33
- package/dist/server/config/env-schemas/feature-flags.js +1 -1
- package/dist/server/config/env-schemas/organization-project.d.ts +3 -21
- package/dist/server/config/env-schemas/scorecards.d.ts +2 -6
- package/dist/server/config/env-schemas/search.d.ts +9 -15
- package/dist/server/config/env-schemas/server-config.d.ts +6 -31
- package/dist/server/config/env-schemas/site.d.ts +1 -5
- package/dist/server/config/env-schemas/ssr.d.ts +7 -12
- package/dist/server/config/env-schemas/telemetry.d.ts +1 -7
- package/dist/server/constants/common.d.ts +3 -0
- package/dist/server/constants/common.js +1 -1
- package/dist/server/esbuild/plugins/dependency-resolver.js +1 -1
- package/dist/server/esbuild/plugins/styled-components-ssr.js +1 -1
- package/dist/server/esbuild/plugins/themes-resolver.js +3 -3
- package/dist/server/external-plugins/resolve-external-plugins.js +1 -1
- package/dist/server/node-bundle-entry.js +1 -1
- package/dist/server/plugins/analytics/amplitude/index.js +1 -1
- package/dist/server/plugins/analytics/ga/build-scripts.js +6 -6
- package/dist/server/plugins/api-docs/definition-access.d.ts +22 -0
- package/dist/server/plugins/api-docs/definition-access.js +1 -0
- package/dist/server/plugins/api-docs/index.js +1 -1
- package/dist/server/plugins/api-docs/loader.d.ts +1 -1
- package/dist/server/plugins/api-docs/options.js +1 -1
- package/dist/server/plugins/api-docs/search/get-ai-search-documents.js +23 -23
- package/dist/server/plugins/api-docs/spec-download.api.js +1 -1
- package/dist/server/plugins/config-parser/index.js +1 -1
- package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/code-walkthrough/filesets-resolver.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/helpers/load-openapi-bundle.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/index.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-code-snippet-from-file.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-diagram-from-file.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-html-href.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-html-source-attribute.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-image-gallery.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-image-src-set.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-image-src.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-json-example-ref.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-json-schema-ref.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-link.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-native-md-link.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-nav-links.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-open-api-ref.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.js +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-response-samples.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-parsed-yaml.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-raw-content.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-relative-or-cdn-icon.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-relative-path.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-sample-from-json-schema.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-svg-content.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-tag-raw-content.d.ts +1 -1
- package/dist/server/plugins/markdown/attribute-resolvers/resolve-tag-raw-content.js +2 -2
- package/dist/server/plugins/markdown/attribute-resolvers/utils.d.ts +1 -1
- package/dist/server/plugins/markdown/compiler.d.ts +1 -1
- package/dist/server/plugins/markdown/compiler.js +1 -1
- package/dist/server/plugins/markdown/errors.d.ts +1 -1
- package/dist/server/plugins/markdown/get-server-props.js +1 -1
- package/dist/server/plugins/markdown/html/normalize-html-headings.d.ts +1 -1
- package/dist/server/plugins/markdown/html/normalize-html-headings.js +1 -1
- package/dist/server/plugins/markdown/markdoc/functions/concat.d.ts +1 -1
- package/dist/server/plugins/markdown/markdoc/markdoc-options.d.ts +5 -165
- package/dist/server/plugins/markdown/markdoc/markdoc-options.js +1 -1
- package/dist/server/plugins/markdown/markdoc/partials.d.ts +1 -1
- package/dist/server/plugins/markdown/markdoc/plugins/headings.d.ts +1 -1
- package/dist/server/plugins/markdown/markdoc/plugins/utils.d.ts +1 -1
- package/dist/server/plugins/markdown/markdoc/reparse-example-fences.d.ts +1 -1
- package/dist/server/plugins/markdown/markdoc/reparse-example-fences.js +1 -1
- package/dist/server/plugins/markdown/runtime-transform.d.ts +2 -2
- package/dist/server/plugins/markdown/runtime-transform.js +1 -1
- package/dist/server/plugins/markdown/search/get-ai-search-documents.js +1 -1
- package/dist/server/plugins/markdown/search/nodes/section-node.d.ts +1 -1
- package/dist/server/plugins/markdown/search/search-resolver.js +1 -1
- package/dist/server/plugins/markdown/search/to-markdown.d.ts +1 -1
- package/dist/server/plugins/markdown/search/walk-sections.d.ts +1 -1
- package/dist/server/plugins/markdown/search/walk-sections.js +1 -1
- package/dist/server/plugins/markdown/utils/stringify-tag-children-objects.d.ts +1 -1
- package/dist/server/plugins/mcp/codemode/tools/describe-tools.d.ts +1 -1
- package/dist/server/plugins/mcp/codemode/tools/describe-tools.js +1 -3
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/get-graphql-type-list.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/list-graphql-apis.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/graphql/types.d.ts +4 -4
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/list-apis.js +1 -1
- package/dist/server/plugins/mcp/docs-mcp/tools/openapi/types.d.ts +2 -2
- package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
- package/dist/server/plugins/mcp/handlers/errors.d.ts +0 -5
- package/dist/server/plugins/mcp/handlers/errors.js +1 -1
- package/dist/server/plugins/mcp/handlers/handle-mcp-request.js +1 -1
- package/dist/server/plugins/mcp/handlers/mcp-credentials-handler.js +1 -1
- package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
- package/dist/server/plugins/mcp/servers/mcp-server.js +2 -2
- package/dist/server/plugins/mcp/types.d.ts +10 -0
- package/dist/server/plugins/mcp/utils/available-tools.d.ts +5 -0
- package/dist/server/plugins/mcp/utils/available-tools.js +1 -0
- package/dist/server/plugins/mcp/workers/worker-context.d.ts +4 -0
- package/dist/server/plugins/mcp/workers/worker-context.js +1 -0
- package/dist/server/plugins/scorecard-classic/compute-scorecard.d.ts +2 -2
- package/dist/server/plugins/scorecard-classic/compute-scorecard.js +1 -1
- package/dist/server/plugins/scorecard-classic/index.js +1 -1
- package/dist/server/plugins/scorecard-classic/shared-utils.js +1 -1
- package/dist/server/plugins/scorecard-classic/template/Grid/GridHeader.js +3 -3
- package/dist/server/plugins/scorecard-classic/template/views.js +1 -1
- package/dist/server/plugins/search/engines/typesense/index.js +1 -1
- package/dist/server/store-config.d.ts +33 -0
- package/dist/server/store-config.js +1 -0
- package/dist/server/store.d.ts +14 -16
- package/dist/server/store.js +1 -1
- package/dist/server/tools/notifiers/formatter.js +3 -3
- package/dist/server/tools/notifiers/helpers/colors.d.ts +1 -1
- package/dist/server/tools/notifiers/logger.d.ts +4 -0
- package/dist/server/tools/notifiers/reporter.js +1 -1
- package/dist/server/types/plugins/api-routes.d.ts +4 -1
- package/dist/server/types/plugins/common.d.ts +2 -1
- package/dist/server/utils/codeframes/codeframes.d.ts +1 -1
- package/dist/server/utils/codeframes/yaml-ast.d.ts +1 -1
- package/dist/server/utils/decode-request-path.d.ts +2 -0
- package/dist/server/utils/decode-request-path.js +1 -0
- package/dist/server/utils/envs/env-boolean-string.d.ts +9 -3
- package/dist/server/utils/envs/get-api-route-allowed-env-variables.d.ts +2 -0
- package/dist/server/utils/envs/get-api-route-allowed-env-variables.js +1 -1
- package/dist/server/utils/envs/interpolate-env-variables.d.ts +5 -1
- package/dist/server/utils/envs/interpolate-env-variables.js +1 -1
- package/dist/server/utils/envs/load-env-variables.js +1 -1
- package/dist/server/utils/envs/replace-env-variables-deep.d.ts +17 -9
- package/dist/server/utils/envs/replace-env-variables-deep.js +1 -1
- package/dist/server/utils/errors.d.ts +3 -0
- package/dist/server/utils/errors.js +1 -1
- package/dist/server/utils/globs.d.ts +12 -0
- package/dist/server/utils/globs.js +1 -1
- package/dist/server/utils/llmstxt/resolve-llms-txt-md.js +1 -1
- package/dist/server/utils/rbac-expand.js +1 -1
- package/dist/server/utils/rbac.d.ts +5 -1
- package/dist/server/utils/rbac.js +1 -1
- package/dist/server/utils/report-all-errors.js +1 -1
- package/dist/server/web-server/auth.d.ts +2 -0
- package/dist/server/web-server/auth.js +2 -2
- package/dist/server/web-server/middleware/jsonValidatorMiddleware.d.ts +5 -325
- package/dist/server/web-server/routes/auth.js +1 -1
- package/dist/server/web-server/routes/catalog/helpers/create-entity-schema.d.ts +1756 -1756
- package/dist/server/web-server/routes/catalog/helpers/create-entity-update-schema.d.ts +295 -295
- package/dist/server/web-server/routes/dynamic-route.js +1 -1
- package/dist/server/web-server/routes/error.js +1 -1
- package/dist/server/web-server/routes/helpers/process-redirects.js +1 -1
- package/dist/server/web-server/routes/mcp-routes/mcp-consent-page.d.ts +2 -2
- package/dist/server/web-server/routes/mcp-routes/mcp-consent-page.js +18 -18
- package/dist/server/web-server/routes/mcp-routes/mcp-oauth.js +1 -1
- package/dist/server/web-server/utils/ssrf-safe-lookup.d.ts +2 -1
- package/dist/server/web-server/utils/ssrf-safe-lookup.js +1 -1
- package/dist/server/workers/mcp-tool-worker-methods.d.ts +7 -0
- package/dist/server/workers/mcp-tool-worker-methods.js +1 -0
- package/dist/server/workers/mcp-tool-worker-pool.d.ts +0 -1
- package/dist/server/workers/mcp-tool-worker-pool.js +1 -1
- package/dist/server/workers/mcp-tool-worker.js +1 -1
- package/dist/server/workers/types.d.ts +4 -8
- package/dist/server/workers/worker-config.d.ts +33 -0
- package/dist/server/workers/worker-config.js +1 -0
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/markdoc.d.ts +1 -1
- package/package.json +12 -12
- package/dist/server/plugins/markdown/html/html-jsx-attribute-mapping.d.ts +0 -6
- package/dist/server/plugins/markdown/html/html-jsx-attribute-mapping.js +0 -1
- package/dist/server/plugins/markdown/html/process-html-tokens.d.ts +0 -2
- package/dist/server/plugins/markdown/html/process-html-tokens.js +0 -1
- package/dist/server/plugins/markdown/source.d.ts +0 -4
- package/dist/server/plugins/markdown/source.js +0 -1
- package/dist/server/plugins/mcp/utils/available-sandbox-tools.d.ts +0 -4
- package/dist/server/plugins/mcp/utils/available-sandbox-tools.js +0 -1
- package/dist/server/tools/notifiers/helpers/privacy/mask-email.d.ts +0 -25
- package/dist/server/tools/notifiers/helpers/privacy/mask-email.js +0 -1
- package/dist/server/tools/notifiers/helpers/privacy/mask-subject.d.ts +0 -13
- package/dist/server/tools/notifiers/helpers/privacy/mask-subject.js +0 -1
- package/dist/server/tools/notifiers/helpers/privacy/remove-pii-from-url.d.ts +0 -25
- package/dist/server/tools/notifiers/helpers/privacy/remove-pii-from-url.js +0 -1
- package/dist/server/tools/notifiers/helpers/privacy/remove-pii.d.ts +0 -36
- package/dist/server/tools/notifiers/helpers/privacy/remove-pii.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node, Tag } from '@
|
|
1
|
+
import type { Node, Tag } from '@redocly/markdoc';
|
|
2
2
|
export declare function getLinkOriginalAttrName(attributeName: string): `redocly:::linkOriginal:${string}`;
|
|
3
3
|
export declare function getOptionalAttribute<T>(node: Node | Tag, attrName: string): T | undefined;
|
|
4
4
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config, Node, ValidationType } from '@
|
|
1
|
+
import type { Config, Node, ValidationType } from '@redocly/markdoc';
|
|
2
2
|
import type { Store } from '../../store.js';
|
|
3
3
|
import type { LifecycleContext, MarkdownParseInput, MarkdocResolveContext } from '../../types';
|
|
4
4
|
import type { MarkdocError } from '../../../types/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import N from"@redocly/markdoc";import{htmlTags as B}from"@redocly/markdoc/html";import*as M from"path";import{convertGithubAlertToAdmonition as H}from"@redocly/theme/markdoc/tags/admonition";import{GATED_MARKDOC_TAGS as F}from"../../constants/entitlements.js";import{logger as G}from"../../tools/notifiers/logger.js";import{reporter as K}from"../../tools/notifiers/reporter.js";import{sha1 as V}from"../../utils/crypto/sha1.js";import{formatMarkdocError as U}from"./errors.js";import{extractFirstHeading as q,SKIP as j,visit as $}from"./markdoc/plugins/utils.js";import{isPromptNode as z}from"../../../markdoc/helpers/guards/is-prompt-node.js";import{attributeResolvers as E}from"./attribute-resolvers/index.js";import{MdResolveError as J}from"./attribute-resolvers/md-resolve-error.js";import{normalizeHtmlHeadings as Q}from"./html/normalize-html-headings.js";import{resolveRawPartials as X}from"./markdoc/resolve-raw-partials.js";import{exampleContentTrees as Z,reparseExampleFences as tt}from"./markdoc/reparse-example-fences.js";import{EntitlementsProvider as at}from"../../entitlements/entitlements-provider.js";import{MARKDOC_PARTIALS_DEPS_KEY as rt}from"../../constants/common.js";import{getLinkOriginalAttrName as et}from"./attribute-resolvers/utils.js";import{createSourceLinesReader as ot}from"./create-source-lines-reader.js";const it="EMPTY";async function st(a,r,e){const f=at.instance(),{actions:n}=e,{relativePath:c,resolveErrors:S}=a,w={...e,readSourceLines:ot(a.rawContent)},g=new Set,u=new Set,l=new Set,b=new Set,s={},D=new Set,L={},_={};function P(t,o){const k=o||it;t[k]=(t[k]||0)+1}const T=[];a.resolveErrors.length=0;const A=Z(a.ast),I=t=>{H(t);const o=k();T.push(o.then(y=>{y?.sharedDataIds&&y.sharedDataIds.forEach(d=>g.add(d))}).catch(Y(t)));async function k(){const y=[];switch(t.type){case"fence":P(L,t.attributes.language);break;case"link":case"image":await E.nativeMdLink(t,t.type==="link"?"href":"src",c,w);break;case"tag":{if(!t.tag)break;const d=r?.tags?.[t.tag];if(!d){F[t.tag]&&!f.canAccessFeature(F[t.tag])&&(t.addError({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"?D:b).add(v),s[v]=(s[v]||0)+1,v==="code-snippet"&&P(L,t.attributes.language),d.attributes?.__idx&&(t.attributes.__idx=s[t.tag]),d.dynamicComponentLib&&u.add(d.dynamicComponentLib),!d.attributes)break;if(v==="partial"&&t.attributes?.file){const i=et("file"),m=t[i]||t.attributes.file,h=m.startsWith("/")?m.slice(1):M.posix.normalize(M.posix.join(M.posix.dirname(c),m));l.add(h);const p=(n.getGlobalConfig(rt)||{})[h];if(p?.dynamicComponents)for(const R of p.dynamicComponents)u.add(R);if(p?.sharedDataDeps)for(const R of p.sharedDataDeps)g.add(R)}for(const[i,m]of Object.entries(d.attributes)){const h=m.type;if(h&&(h.resolver||m.resolver)){const x=E[h.resolver||m.resolver],p=await x?.(t,i,c,w);p?.sharedDataId&&y.push(p.sharedDataId)}}if(v==="code-walkthrough")for(const i of t.attributes.resolvedFilesets||[])for(const m of i.files||[])P(_,m.language);const O=t.attributes?.attrs;if(O&&t.tag==="html")for(const i of Object.keys(O))i==="src"||i==="srcSet"?await E.htmlSourceAttribute(t,i,c,w):i==="href"&&await E.htmlHref(t,i,c,w);break}}return{sharedDataIds:y}}};function Y(t){return async o=>{if(!(o instanceof J)){await K.panicOnBuild(o.message);return}S.push(U({type:"resolve_link",meta:{...o.meta,link:o.meta.link??o.meta.rawLink},lines:t.location?[t.location.start.line,t.location.end.line]:[],location:t.location,error:{id:"",level:"error",message:o.message,location:t.location}},a.relativePath,a.rawContent))}}$(a.ast,t=>(I(t),z(t)?j:void 0));for(const t of A)$(t,o=>(H(o),o.type==="tag"&&I(o),z(o)?j:void 0));return await Promise.all(T),a.sharedDataDeps=g,a.dynamicMarkdocComponents=u,a.validatedAtRevision<n.buildRevision&&(a.markdocErrors=[a.ast,...A].flatMap(t=>N.validate(t,r)).map(t=>U(t,c,a.rawContent)),a.validatedAtRevision=n.buildRevision),{sharedDataDeps:a.sharedDataDeps,dynamicMarkdocComponents:Array.from(a.dynamicMarkdocComponents?.values()??[]),partials:Array.from(l),tagList:Array.from(b),htmlTagsList:Array.from(D),tagOccurrence:s,codeSnippetLanguages:L,codeWalkthroughLanguages:_}}const C="unclosed-html",nt={html:B({errorTag:C}),allowIndentation:!0,allowComments:!0};function W(a,r){const e=N.parse(a,{...nt,...r});return ct(e),Q(e),e}function ct(a){for(const r of a.walk())r.type!=="tag"||r.tag!==C||(r.type="error",r.errors.push({id:"parse-error",level:"critical",message:String(r.attributes.message),location:r.location}))}function lt(a,r){const e=W(r,{file:a,slots:!0});return tt(e,n=>W(n,{file:a})),{ast:e,rawContent:r,resolveErrors:[],markdocErrors:[],relativePath:a,sharedDataDeps:void 0,validatedAtRevision:-1}}async function Tt(a,r){const{data:e}=await r.cache.load(a,"markdown-ast");return q(e.ast)}async function At(a,r){K.clearMarkdocProblems();const e=a.getAllRoutes();let f=0;const n=G.isInteractive();for(const c of e)await a.resolveRouteStaticData(c,r,!0),f++,n&&f%100===0&&G.logInFooter("validate",` \u{1F50D} Status: validating markdoc (${f}/${e.length})`)}async function It(a,r,e,f){const n=a.content?V(a.content):"";return await e.context.cache.load(f||a.relativePath,{loader:S,name:"markdown-inline-parser"},[n,String(e.actions.buildRevision)]);async function S(w,g,u){let l;if(a.content){const s=await g.getConfig(),D=await X(a.content,a.relativePath,s.markdown?.partialsFolders,g);l=lt(a.relativePath,D)}else l=(await g.cache.load(a.relativePath,"markdown-ast")).data;let b={};if(e.actions.buildRevision!==0&&(b=await st(l,r,e)),!a.isVirtual){for(const s of l.markdocErrors)u(s);for(const s of l.resolveErrors)u(s)}return{ast:l.ast,info:b}}}export{Tt as extractMdFirstHeading,lt as getAst,It as parseAndResolveMarkdoc,st as resolveAndValidateMarkdoc,At as validateAllMarkdowns};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NormalizedProblem } from '@redocly/openapi-core';
|
|
2
|
-
import type { ValidateError, LocationEdge } from '@
|
|
2
|
+
import type { ValidateError, LocationEdge } from '@redocly/markdoc';
|
|
3
3
|
import type { MarkdocError, BrokenLinkType } from '../../../types/index.js';
|
|
4
4
|
export type ValidateErrorWithMeta = ValidateError & {
|
|
5
5
|
meta?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@
|
|
1
|
+
import e from"@redocly/markdoc";import{getPublicEnvVariables as u}from"../../utils/envs/get-public-env-variables.js";import{transformMdAst as i}from"./runtime-transform";const v=async(A,o,t,s)=>{const{ast:l,frontmatter:r,props:n,editPage:f,lastModified:m,isTranslationFallback:b}=o,{headings:d,renderableAst:p}=await i(e.Ast.fromJSON(l),{partials:t.partials,variables:{frontmatter:r,...t.variables,env:u()}},s.serverOutDir);return Array.isArray(r.banner)&&(r.banner=await Promise.all(r.banner.map(async a=>{if(a.ast){const{renderableAst:c}=await i(e.Ast.fromJSON(a.ast),{partials:{},variables:{}},s.serverOutDir);return{...a,ast:c}}return a}))),{...n,ast:p,headings:d,frontmatter:r,editPage:f,lastModified:m,...b?{isTranslationFallback:!0}:{}}};var k=v;export{k as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node } from '@
|
|
1
|
+
import type { Node } from '@redocly/markdoc';
|
|
2
2
|
/**
|
|
3
3
|
* Rewrites block-level raw HTML `<h1>`…`<h6>` elements into Markdoc `heading` nodes,
|
|
4
4
|
* so they get an anchor id, a TOC entry and a search section like Markdown headings.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import l from"@redocly/markdoc";const s=/^h([1-6])$/;function u(t){r(t,!1)}function r(t,i){const n=i||t.type==="inline";t.children=t.children.map(e=>{const o=(n?void 0:a(e))??e;return r(o,n),o});for(const e of Object.values(t.slots))r(e,n)}function a(t){if(t.type!=="tag"||t.tag!=="html")return;const i=s.exec(t.attributes.name)?.[1];if(!i)return;const n=t.attributes.attrs?.id,e=new l.Ast.Node("heading",{level:Number(i),...typeof n=="string"&&{id:n}},[new l.Ast.Node("inline",{},t.children)]);return e.location=t.location,e}export{u as normalizeHtmlHeadings};
|
|
@@ -7,171 +7,11 @@ export declare function getMarkdocOptions(serverOutDir?: string, _templateId?: s
|
|
|
7
7
|
td: import("@markdoc/markdoc").Schema;
|
|
8
8
|
th: import("@markdoc/markdoc").Schema;
|
|
9
9
|
text: import("@markdoc/markdoc").Schema;
|
|
10
|
-
strong:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
inline?: boolean;
|
|
16
|
-
transform?(node: import("@markdoc/markdoc").Node, config: Readonly<Partial<{
|
|
17
|
-
nodes: Partial<Record<import("@markdoc/markdoc").NodeType, import("@markdoc/markdoc").Schema<Partial</*elided*/ any>, string>>>;
|
|
18
|
-
tags: Record<string, import("@markdoc/markdoc").Schema>;
|
|
19
|
-
variables: Record<string, any>;
|
|
20
|
-
functions: Record<string, import("@markdoc/markdoc").ConfigFunction>;
|
|
21
|
-
partials: Record<string, any>;
|
|
22
|
-
validation?: {
|
|
23
|
-
parents?: import("@markdoc/markdoc").Node[];
|
|
24
|
-
validateFunctions?: boolean;
|
|
25
|
-
environment?: string;
|
|
26
|
-
};
|
|
27
|
-
}>>): import("@markdoc/markdoc").MaybePromise<import("@markdoc/markdoc").RenderableTreeNodes>;
|
|
28
|
-
validate?(node: import("@markdoc/markdoc").Node, config: Readonly<Partial<{
|
|
29
|
-
nodes: Partial<Record<import("@markdoc/markdoc").NodeType, import("@markdoc/markdoc").Schema<Partial<any>, string>>>;
|
|
30
|
-
tags: Record<string, import("@markdoc/markdoc").Schema>;
|
|
31
|
-
variables: Record<string, any>;
|
|
32
|
-
functions: Record<string, import("@markdoc/markdoc").ConfigFunction>;
|
|
33
|
-
partials: Record<string, any>;
|
|
34
|
-
validation?: {
|
|
35
|
-
parents?: import("@markdoc/markdoc").Node[];
|
|
36
|
-
validateFunctions?: boolean;
|
|
37
|
-
environment?: string;
|
|
38
|
-
};
|
|
39
|
-
}>>): import("@markdoc/markdoc").MaybePromise<import("@markdoc/markdoc").ValidationError[]>;
|
|
40
|
-
description?: string;
|
|
41
|
-
children: string[];
|
|
42
|
-
};
|
|
43
|
-
em: {
|
|
44
|
-
render?: string | undefined;
|
|
45
|
-
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute>;
|
|
46
|
-
slots?: Record<string, import("@markdoc/markdoc").SchemaSlot>;
|
|
47
|
-
selfClosing?: boolean;
|
|
48
|
-
inline?: boolean;
|
|
49
|
-
transform?(node: import("@markdoc/markdoc").Node, config: Readonly<Partial<{
|
|
50
|
-
nodes: Partial<Record<import("@markdoc/markdoc").NodeType, import("@markdoc/markdoc").Schema<Partial<any>, string>>>;
|
|
51
|
-
tags: Record<string, import("@markdoc/markdoc").Schema>;
|
|
52
|
-
variables: Record<string, any>;
|
|
53
|
-
functions: Record<string, import("@markdoc/markdoc").ConfigFunction>;
|
|
54
|
-
partials: Record<string, any>;
|
|
55
|
-
validation?: {
|
|
56
|
-
parents?: import("@markdoc/markdoc").Node[];
|
|
57
|
-
validateFunctions?: boolean;
|
|
58
|
-
environment?: string;
|
|
59
|
-
};
|
|
60
|
-
}>>): import("@markdoc/markdoc").MaybePromise<import("@markdoc/markdoc").RenderableTreeNodes>;
|
|
61
|
-
validate?(node: import("@markdoc/markdoc").Node, config: Readonly<Partial<{
|
|
62
|
-
nodes: Partial<Record<import("@markdoc/markdoc").NodeType, import("@markdoc/markdoc").Schema<Partial<any>, string>>>;
|
|
63
|
-
tags: Record<string, import("@markdoc/markdoc").Schema>;
|
|
64
|
-
variables: Record<string, any>;
|
|
65
|
-
functions: Record<string, import("@markdoc/markdoc").ConfigFunction>;
|
|
66
|
-
partials: Record<string, any>;
|
|
67
|
-
validation?: {
|
|
68
|
-
parents?: import("@markdoc/markdoc").Node[];
|
|
69
|
-
validateFunctions?: boolean;
|
|
70
|
-
environment?: string;
|
|
71
|
-
};
|
|
72
|
-
}>>): import("@markdoc/markdoc").MaybePromise<import("@markdoc/markdoc").ValidationError[]>;
|
|
73
|
-
description?: string;
|
|
74
|
-
children: string[];
|
|
75
|
-
};
|
|
76
|
-
s: {
|
|
77
|
-
render?: string | undefined;
|
|
78
|
-
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute>;
|
|
79
|
-
slots?: Record<string, import("@markdoc/markdoc").SchemaSlot>;
|
|
80
|
-
selfClosing?: boolean;
|
|
81
|
-
inline?: boolean;
|
|
82
|
-
transform?(node: import("@markdoc/markdoc").Node, config: Readonly<Partial<{
|
|
83
|
-
nodes: Partial<Record<import("@markdoc/markdoc").NodeType, import("@markdoc/markdoc").Schema<Partial<any>, string>>>;
|
|
84
|
-
tags: Record<string, import("@markdoc/markdoc").Schema>;
|
|
85
|
-
variables: Record<string, any>;
|
|
86
|
-
functions: Record<string, import("@markdoc/markdoc").ConfigFunction>;
|
|
87
|
-
partials: Record<string, any>;
|
|
88
|
-
validation?: {
|
|
89
|
-
parents?: import("@markdoc/markdoc").Node[];
|
|
90
|
-
validateFunctions?: boolean;
|
|
91
|
-
environment?: string;
|
|
92
|
-
};
|
|
93
|
-
}>>): import("@markdoc/markdoc").MaybePromise<import("@markdoc/markdoc").RenderableTreeNodes>;
|
|
94
|
-
validate?(node: import("@markdoc/markdoc").Node, config: Readonly<Partial<{
|
|
95
|
-
nodes: Partial<Record<import("@markdoc/markdoc").NodeType, import("@markdoc/markdoc").Schema<Partial<any>, string>>>;
|
|
96
|
-
tags: Record<string, import("@markdoc/markdoc").Schema>;
|
|
97
|
-
variables: Record<string, any>;
|
|
98
|
-
functions: Record<string, import("@markdoc/markdoc").ConfigFunction>;
|
|
99
|
-
partials: Record<string, any>;
|
|
100
|
-
validation?: {
|
|
101
|
-
parents?: import("@markdoc/markdoc").Node[];
|
|
102
|
-
validateFunctions?: boolean;
|
|
103
|
-
environment?: string;
|
|
104
|
-
};
|
|
105
|
-
}>>): import("@markdoc/markdoc").MaybePromise<import("@markdoc/markdoc").ValidationError[]>;
|
|
106
|
-
description?: string;
|
|
107
|
-
children: string[];
|
|
108
|
-
};
|
|
109
|
-
link: {
|
|
110
|
-
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute>;
|
|
111
|
-
slots?: Record<string, import("@markdoc/markdoc").SchemaSlot>;
|
|
112
|
-
selfClosing?: boolean;
|
|
113
|
-
inline?: boolean;
|
|
114
|
-
transform?(node: import("@markdoc/markdoc").Node, config: Readonly<Partial<{
|
|
115
|
-
nodes: Partial<Record<import("@markdoc/markdoc").NodeType, import("@markdoc/markdoc").Schema<Partial<any>, string>>>;
|
|
116
|
-
tags: Record<string, import("@markdoc/markdoc").Schema>;
|
|
117
|
-
variables: Record<string, any>;
|
|
118
|
-
functions: Record<string, import("@markdoc/markdoc").ConfigFunction>;
|
|
119
|
-
partials: Record<string, any>;
|
|
120
|
-
validation?: {
|
|
121
|
-
parents?: import("@markdoc/markdoc").Node[];
|
|
122
|
-
validateFunctions?: boolean;
|
|
123
|
-
environment?: string;
|
|
124
|
-
};
|
|
125
|
-
}>>): import("@markdoc/markdoc").MaybePromise<import("@markdoc/markdoc").RenderableTreeNodes>;
|
|
126
|
-
validate?(node: import("@markdoc/markdoc").Node, config: Readonly<Partial<{
|
|
127
|
-
nodes: Partial<Record<import("@markdoc/markdoc").NodeType, import("@markdoc/markdoc").Schema<Partial<any>, string>>>;
|
|
128
|
-
tags: Record<string, import("@markdoc/markdoc").Schema>;
|
|
129
|
-
variables: Record<string, any>;
|
|
130
|
-
functions: Record<string, import("@markdoc/markdoc").ConfigFunction>;
|
|
131
|
-
partials: Record<string, any>;
|
|
132
|
-
validation?: {
|
|
133
|
-
parents?: import("@markdoc/markdoc").Node[];
|
|
134
|
-
validateFunctions?: boolean;
|
|
135
|
-
environment?: string;
|
|
136
|
-
};
|
|
137
|
-
}>>): import("@markdoc/markdoc").MaybePromise<import("@markdoc/markdoc").ValidationError[]>;
|
|
138
|
-
description?: string;
|
|
139
|
-
render: string;
|
|
140
|
-
children: string[];
|
|
141
|
-
};
|
|
142
|
-
document: {
|
|
143
|
-
render?: string | undefined;
|
|
144
|
-
attributes?: Record<string, import("@markdoc/markdoc").SchemaAttribute>;
|
|
145
|
-
slots?: Record<string, import("@markdoc/markdoc").SchemaSlot>;
|
|
146
|
-
selfClosing?: boolean;
|
|
147
|
-
inline?: boolean;
|
|
148
|
-
transform?(node: import("@markdoc/markdoc").Node, config: Readonly<Partial<{
|
|
149
|
-
nodes: Partial<Record<import("@markdoc/markdoc").NodeType, import("@markdoc/markdoc").Schema<Partial<any>, string>>>;
|
|
150
|
-
tags: Record<string, import("@markdoc/markdoc").Schema>;
|
|
151
|
-
variables: Record<string, any>;
|
|
152
|
-
functions: Record<string, import("@markdoc/markdoc").ConfigFunction>;
|
|
153
|
-
partials: Record<string, any>;
|
|
154
|
-
validation?: {
|
|
155
|
-
parents?: import("@markdoc/markdoc").Node[];
|
|
156
|
-
validateFunctions?: boolean;
|
|
157
|
-
environment?: string;
|
|
158
|
-
};
|
|
159
|
-
}>>): import("@markdoc/markdoc").MaybePromise<import("@markdoc/markdoc").RenderableTreeNodes>;
|
|
160
|
-
validate?(node: import("@markdoc/markdoc").Node, config: Readonly<Partial<{
|
|
161
|
-
nodes: Partial<Record<import("@markdoc/markdoc").NodeType, import("@markdoc/markdoc").Schema<Partial<any>, string>>>;
|
|
162
|
-
tags: Record<string, import("@markdoc/markdoc").Schema>;
|
|
163
|
-
variables: Record<string, any>;
|
|
164
|
-
functions: Record<string, import("@markdoc/markdoc").ConfigFunction>;
|
|
165
|
-
partials: Record<string, any>;
|
|
166
|
-
validation?: {
|
|
167
|
-
parents?: import("@markdoc/markdoc").Node[];
|
|
168
|
-
validateFunctions?: boolean;
|
|
169
|
-
environment?: string;
|
|
170
|
-
};
|
|
171
|
-
}>>): import("@markdoc/markdoc").MaybePromise<import("@markdoc/markdoc").ValidationError[]>;
|
|
172
|
-
description?: string;
|
|
173
|
-
children: string[];
|
|
174
|
-
};
|
|
10
|
+
strong: import("@markdoc/markdoc").Schema;
|
|
11
|
+
em: import("@markdoc/markdoc").Schema;
|
|
12
|
+
s: import("@markdoc/markdoc").Schema;
|
|
13
|
+
link: import("@markdoc/markdoc").Schema;
|
|
14
|
+
document: import("@markdoc/markdoc").Schema;
|
|
175
15
|
};
|
|
176
16
|
tags: {
|
|
177
17
|
schemaDefinition: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import f from"@
|
|
1
|
+
import f from"@redocly/markdoc";import*as p from"@redocly/theme/markdoc/default";import{reporter as g}from"../../../tools/notifiers/reporter.js";import*as u from"../../../../markdoc/nodes/index.js";import d from"../../../../markdoc/tags/index.js";import{normalizeCustomTags as l}from"../../../../markdoc/helpers/normalize-custom-tags.js";import{includes as h}from"./functions/includes.js";import{importUserTags as O}from"./import-user-tags.js";import{concat as y}from"./functions/concat.js";const T=p.tags;function b(s){const{tags:c,functions:e={},...r}=s,n={...c,...r},a=Object.entries(n),o=[],t=[];for(const[i,m]of a)i in f.nodes?o.push([i,m]):t.push([i,m]);return{nodes:Object.fromEntries(o),tags:Object.fromEntries(t),functions:e}}async function _(s="../../../esbuild/cache/server/",c=""){let e;try{e=(await O(s)).schema}catch(t){throw t.code==="ERR_MODULE_NOT_FOUND"?(g.printErrors(),new Error("Please fix the errors above and try again.")):t}const{tags:r={},nodes:n={},functions:a={}}=b(e),o={tags:{schemaDefinition:{render:"SchemaDefinition",attributes:{schemaRef:{type:String},exampleRef:{type:String},showReadOnly:{type:Boolean},showWriteOnly:{type:Boolean}}}}};return{nodes:{...u,...n},tags:{...d,...T,...l(r),...o.tags},functions:{...f.functions,...a,includes:h,concat:y}}}export{_ as getMarkdocOptions};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node } from '@
|
|
1
|
+
import type { Node } from '@redocly/markdoc';
|
|
2
2
|
import type { LifecycleContext, AfterRoutesCreatedActions } from '../../../types';
|
|
3
3
|
export declare function prepareMarkdocPartials(context: LifecycleContext, actions: AfterRoutesCreatedActions): Promise<Record<string, Node>>;
|
|
4
4
|
//# sourceMappingURL=partials.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node } from '@
|
|
1
|
+
import type { Node } from '@redocly/markdoc';
|
|
2
2
|
type ParseMarkdownFn = (content: string) => Node;
|
|
3
3
|
/** Parse each `{% markdoc-example %}` fence body onto the fence, out of the page tree. */
|
|
4
4
|
export declare function reparseExampleFences(ast: Node, parseMarkdown: ParseMarkdownFn): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EXAMPLE_CONTENT_ATTRIBUTE as
|
|
1
|
+
import{EXAMPLE_CONTENT_ATTRIBUTE as c}from"@redocly/theme/core/constants";import{isExampleNode as l}from"../../../../markdoc/helpers/guards/is-example-node.js";import{isFenceNode as a}from"../../../../markdoc/helpers/guards/is-fence-node.js";const u="no-inline-annotations";function d(o,t){for(const e of s(o)){if(!e.children.length)continue;const{content:n}=e.attributes;if(typeof n!="string")continue;const i=t(n),f=(e.location?.start.line??0)+1;for(const r of i.children)m(r,f);e.children=[],e.slots={},e.errors=e.errors.filter(r=>r.id!==u),e.attributes[c]=i,d(i,t)}}function p(o){const t=[];for(const e of s(o)){const n=e.attributes[c];n&&t.push(n,...p(n))}return t}function*s(o){for(const t of o.walk()){if(!l(t))continue;const[e]=t.children;a(e)&&(yield e)}}function m(o,t){for(const e of[o,...o.walk()]){const{location:n}=e;n&&(typeof n.start?.line=="number"&&(n.start.line+=t),typeof n.end?.line=="number"&&(n.end.line+=t))}}export{p as exampleContentTrees,d as reparseExampleFences};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node } from '@
|
|
1
|
+
import type { Node } from '@redocly/markdoc';
|
|
2
2
|
import type { MdOptions } from '@redocly/config';
|
|
3
3
|
export declare function transformMdAst(ast: Node, config: MdOptions, serverOutDir: string): Promise<{
|
|
4
4
|
headings: {
|
|
@@ -6,7 +6,7 @@ export declare function transformMdAst(ast: Node, config: MdOptions, serverOutDi
|
|
|
6
6
|
id: string;
|
|
7
7
|
depth: number;
|
|
8
8
|
}[];
|
|
9
|
-
renderableAst: import("@markdoc/markdoc").
|
|
9
|
+
renderableAst: import("@markdoc/markdoc").RenderableTreeNodes;
|
|
10
10
|
pageProps: any;
|
|
11
11
|
}>;
|
|
12
12
|
//# sourceMappingURL=runtime-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"@
|
|
1
|
+
import c from"@redocly/markdoc";import{isTag as b}from"../../../markdoc/helpers/guards/is-tag.js";import{slugger as f}from"../../utils/index.js";import{getMarkdocOptions as l}from"./markdoc/markdoc-options.js";import{visit as h,getHeadingData as k,getNumberedItemHeadingData as D}from"./markdoc/plugins/utils.js";import{renderDiagramsWithVariants as H}from"./markdoc/plugins/render-diagrams.js";import{deepStringify as v}from"./markdoc/utils/deep-stringify.js";import{stringifyTagChildrenObjects as y}from"./utils/stringify-tag-children-objects.js";async function S(d,e,p){const g=await l(p),i=[],a=[],o=v(e.variables?.pageProps),{headers:T,...u}=e.variables||{};f.reset();const m=c.transform(d,{...g,...e,variables:{...u,pageProps:o}});let n=0;h(m,r=>{if(b(r)){switch(r.name){case"Heading":{r.attributes.__idx=n,n++;const t=k(r);t&&i.push(t);break}case"NumberedItem":{const t=D(r);t&&i.push(t);break}case"Diagram":a.push({tag:r,input:{type:r.attributes.diagramType,source:r.attributes.diagramSource}});break}y(r)}});const s=await H(a.map(r=>r.input));for(let r=0;r<a.length;r++)a[r].tag.attributes.diagramError=s[r].error,a[r].tag.attributes.diagramHtml=s[r].light,a[r].tag.attributes.diagramHtmlDark=s[r].dark;return{headings:i,renderableAst:m,pageProps:o}}export{S as transformMdAst};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import M from"@
|
|
1
|
+
import M from"@redocly/markdoc";import D from"node:path";import{AI_SEARCH_CHUNK_SIZE as R,AI_SEARCH_DOCUMENT_CHUNK_SIZE as v}from"../../../constants/plugins/search.js";import{slugger as I}from"../../../../utils/slugger.js";import{joinSectionContent as N}from"./join-section-content.js";import{toMarkdown as P}from"./to-markdown.js";import{AstToSearchNodeTransformer as w}from"./walk-sections.js";import{createRenderTagFn as x}from"./create-render-tag-fn.js";import{getBuildTranslateContext as K}from"../../../utils/l10n/get-build-translate-context.js";import{getLocaleFromRelativePath as L}from"../../../fs/utils/get-locale-from-relative-path.js";import{HeadingNode as b}from"./nodes/heading-node.js";import{extractDocumentSearchFacets as U}from"./search-facets.js";import{formatDocumentMetadata as y}from"../../search/utils.js";import{TagNode as H}from"./nodes/tag-node.js";import{MARKDOC_PARTIALS_DATA_KEY as O}from"../../../constants/common.js";const j=Symbol(),at=(n,o)=>async(e,r,i,c)=>{if(o?.excludeFromSearch)return;I.reset();const l=await e.getNavText?.()||D.basename(e.fsPath),f=M.Ast.fromJSON(r.ast),{locale:g,translate:A}=await K(e.slug,c.getGlobalData?.().l10n),s=new w({partials:c.getGlobalConfig(O)||{},renderTag:x(c.markdocOptions.tags,g,A),getInnerContent:P,ast:f,skipConditionals:!0}),d=Array.from(s.transform());return{async getLLMsTxts(){const u=o?.seo,t=u&&typeof u=="object"&&"description"in u?String(u.description):void 0,a=N(d);return[{title:l,description:t,slug:e.slug,fsPath:e.fsPath,content:a,includeInLLMsTxt:!0}]},async getSearchDocuments(){return F(e,d,n,l)}}};function F(n,o,e,r){const i=n.slug,c=new Map,l=n.metadata||{},f=U(l,e),g=y(l),A=g?`Metadata:
|
|
2
2
|
${g}
|
|
3
3
|
`:"",s=[];for(const t of o)if(t instanceof b){s.splice(t.attributes.level-1,6);const a=t.attributes.level>2,m=s[s.length-1]?.title,T=s[s.length-1]?.url,C=a&&m?m:W(r,t),S=a&&T?T:t.getUrl(i),p={title:C,content:"",url:S,level:t.attributes.level,toc:s.map(E=>h(E.section)).join(`
|
|
4
4
|
`)};(t.attributes.level>1||h(t)!==r)&&(p.content+=p.content?`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import d from"@
|
|
1
|
+
import d from"@redocly/markdoc";import{REDOCLY_ROUTE_RBAC as l,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{getInnerText as T}from"../../../../markdoc/helpers/get-inner-text.js";import{skipAgentsOnlyContent as h}from"@redocly/theme/markdoc/tags/visibility";import{getSearchDocuments as g}from"./get-search-documents.js";import{AstToSearchNodeTransformer as C}from"./walk-sections.js";import{setDocumentSearchFacets as R,extractDocumentSearchFacets as S}from"./search-facets.js";import{MARKDOC_PARTIALS_DATA_KEY as D}from"../../../constants/common.js";import{normalizeFrontmatterKeywords as _}from"../../helpers/normalize-frontmatter-keywords.js";function Y(e,m,o,c){return async(t,r,a)=>{if(e?.excludeFromSearch)return[];const i=d.Ast.fromJSON(r.ast),f=new C({ast:i,getInnerContent:T,partials:a.getGlobalConfig(D)||{},renderTag:h,indexPromptTitles:!0}),p=t.metadata||{},n=S(p,o);R(n,o,c);const u=e?.seo?.title||m,{result:s}=_(e?.keywords);return g(f,t.slug,u,r[A],r[l],n,s||void 0)}}export{Y as searchResolver};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Function, Node, RenderableTreeNode, Variable } from '@
|
|
1
|
+
import type { Function, Node, RenderableTreeNode, Variable } from '@redocly/markdoc';
|
|
2
2
|
import type { GetInnerContentFnOptions } from '../../../../types/index.js';
|
|
3
3
|
export declare function toMarkdown(children: (RenderableTreeNode | Node | Variable | Function)[], options?: GetInnerContentFnOptions): string;
|
|
4
4
|
//# sourceMappingURL=to-markdown.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node } from '@
|
|
1
|
+
import type { Node } from '@redocly/markdoc';
|
|
2
2
|
import type { GetInnerContentFn } from '../../../../types/index.js';
|
|
3
3
|
import type { SearchNode } from './nodes/types.js';
|
|
4
4
|
import type { RenderTagFn } from '../../../types/plugins/markdown.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{PROMPT_TAG as a}from"@redocly/theme/core/constants";import{logger as w}from"../../../tools/notifiers/logger.js";import{isNode as p}from"../../../../markdoc/helpers/guards/is-node.js";import{isConditionalNode as N}from"../../../../markdoc/helpers/guards/is-conditional-node.js";import{isContentNode as m}from"../../../../markdoc/helpers/guards/is-content-node.js";import{getNodeAttribute as f}from"../../../../markdoc/helpers/get-node-attribute.js";import{extractRbacFromCondition as b}from"../../../../markdoc/helpers/extract-rbac-from-condition-node.js";import{TextNode as n}from"./nodes/text-node.js";import{TAG_TITLE_ATTRIBUTES as g,TagNode as u}from"./nodes/tag-node.js";import{HeadingNode as y}from"./nodes/heading-node.js";import{joinSectionContent as d}from"./join-section-content.js";class G{#r;#e;#o;#s;#c;#n;constructor({ast:i,partials:t,skipConditionals:s=!1,getInnerContent:r,renderTag:e,indexPromptTitles:o=!1}){if(this.#r=i,this.#e=t,this.#o=s,this.#s=r,this.#c=e,this.#n=o,!this.#r||!p(this.#r))throw new Error("ast is not a valid Markdoc Node.")}#i(i={}){return{skipConditionals:this.#o,renderTag:this.#c,...i}}*transform(){yield*this.#l(this.#r,{parentNode:null})}*#l(i,t,s=this.#s){if(!(!i||!p(i))){if(N(i)){if(this.#o)return;const r=b(i);r&&r.length>0&&(yield*this.#t(i,{...t,rbacTeams:r},s));return}if(m(i)){yield new n({node:i,content:s([i],this.#i()),...t});return}if(i.type==="heading"){yield new y({node:i,content:s([i],this.#i()),rbacTeams:t?.rbacTeams});return}if(i.type==="tag"){yield*this.#h(i,t,s);return}yield*this.#t(i,t,s)}}*#h(i,t,s=this.#s){switch(i.tag){case"partial":{const r=i.attributes.file,e=i.attributes.variables??{};if(r&&this.#e[r]){yield*this.#l(this.#e[r],t,(o,h)=>s(o,{...h,variables:e}));return}w.warn(`Could not create search indexes for partial \u201C${r}\u201D: file not found`);return}case"html":case"cards":case"tabs":case"code-walkthrough":{yield*this.#t(i,t,s);return}case a:{const r=f(i,"title");this.#n&&r&&(yield new u({node:i,content:r,...t}));return}case"markdoc-example":{const r=s([i],this.#i());yield new n({node:i,content:r,...t});return}case"code-snippet":{const r=f(i,"title"),e=s([i],this.#i());if(r){const o=new u({node:i,content:r,...t});t={...t,parentNode:o},yield o}e&&(yield new n({node:i,content:e,...t}));return}default:{const r=this.#f(i,t,s);if(r!==void 0){yield new n({node:i,content:k(r),...t});return}const e=g.find(l=>l in i.attributes),o=(e&&f(i,e))??"",h=typeof o=="string"?o:s([o]);if(h){const l=new u({node:i,content:h,...t});t={...t,parentNode:l},yield l}if(T(i))yield*this.#t(i,t,s);else{const l=s([i],this.#i());l&&(yield new n({node:i,content:l,...t}))}return}}}#f(i,t,s){const r=()=>T(i)?d([...this.#t(i,t,s)]):"";return this.#c?.(i,{getBody:r})}*#t(i,t,s=this.#s){for(const r of[...Object.values(i.slots),...i.children])for(const e of this.#l(r,t,s))e instanceof y&&(t={...t,parentNode:e}),yield e}}function T(c){return c.children.length>0||Object.keys(c.slots).length>0}function k(c){return c.endsWith(`
|
|
1
|
+
import{PROMPT_TAG as a}from"@redocly/theme/core/constants";import{logger as w}from"../../../tools/notifiers/logger.js";import{isNode as p}from"../../../../markdoc/helpers/guards/is-node.js";import{isConditionalNode as N}from"../../../../markdoc/helpers/guards/is-conditional-node.js";import{isContentNode as m}from"../../../../markdoc/helpers/guards/is-content-node.js";import{getNodeAttribute as f}from"../../../../markdoc/helpers/get-node-attribute.js";import{extractRbacFromCondition as b}from"../../../../markdoc/helpers/extract-rbac-from-condition-node.js";import{TextNode as n}from"./nodes/text-node.js";import{TAG_TITLE_ATTRIBUTES as g,TagNode as u}from"./nodes/tag-node.js";import{HeadingNode as y}from"./nodes/heading-node.js";import{joinSectionContent as d}from"./join-section-content.js";class G{#r;#e;#o;#s;#c;#n;constructor({ast:i,partials:t,skipConditionals:s=!1,getInnerContent:r,renderTag:e,indexPromptTitles:o=!1}){if(this.#r=i,this.#e=t,this.#o=s,this.#s=r,this.#c=e,this.#n=o,!this.#r||!p(this.#r))throw new Error("ast is not a valid Markdoc Node.")}#i(i={}){return{skipConditionals:this.#o,renderTag:this.#c,...i}}*transform(){yield*this.#l(this.#r,{parentNode:null})}*#l(i,t,s=this.#s){if(!(!i||!p(i))){if(N(i)){if(this.#o)return;const r=b(i);r&&r.length>0&&(yield*this.#t(i,{...t,rbacTeams:r},s));return}if(m(i)){yield new n({node:i,content:s([i],this.#i()),...t});return}if(i.type==="heading"){yield new y({node:i,content:s([i],this.#i()),rbacTeams:t?.rbacTeams});return}if(i.type==="tag"){yield*this.#h(i,t,s);return}yield*this.#t(i,t,s)}}*#h(i,t,s=this.#s){switch(i.tag){case"partial":{const r=i.attributes.file,e=i.attributes.variables??{};if(r&&this.#e[r]){yield*this.#l(this.#e[r],t,(o,h)=>s(o,{...h,variables:e}));return}w.warn(`Could not create search indexes for partial \u201C${r}\u201D: file not found`);return}case"html":case"cards":case"tabs":case"code-walkthrough":{yield*this.#t(i,t,s);return}case a:{const r=f(i,"title");this.#n&&r&&(yield new u({node:i,content:r,...t}));return}case"markdoc-example":{const r=s([i],this.#i());yield new n({node:i,content:r,...t});return}case"code-snippet":{const r=f(i,"title"),e=s([i],this.#i());if(r){const o=new u({node:i,content:r,...t});t={...t,parentNode:o},yield o}e&&(yield new n({node:i,content:e,...t}));return}default:{const r=this.#f(i,t,s);if(r!==void 0){yield new n({node:i,content:k(r),...t});return}const e=g.find(l=>l in i.attributes),o=(e&&f(i,e))??"",h=typeof o=="string"?o:s([o]);if(h){const l=new u({node:i,content:h,...t});t={...t,parentNode:l},yield l}if(T(i))yield*this.#t(i,t,s);else{const l=s([i],this.#i());l&&(yield new n({node:i,content:l,...t}))}return}}}#f(i,t,s){const r=()=>T(i)?d([...this.#t(i,t,s)]):"";return this.#c?.(i,{getBody:r})}*#t(i,t,s=this.#s){for(const r of[...Object.values(i.slots??{}),...i.children])for(const e of this.#l(r,t,s))e instanceof y&&(t={...t,parentNode:e}),yield e}}function T(c){return c.children.length>0||Object.keys(c.slots??{}).length>0}function k(c){return c.endsWith(`
|
|
2
2
|
`)?c:`${c}
|
|
3
3
|
`}export{G as AstToSearchNodeTransformer};
|
|
@@ -2,5 +2,5 @@ import type { McpToolSchema } from '../../../../types';
|
|
|
2
2
|
import type { McpToolCallback, McpToolContext } from '../../types.js';
|
|
3
3
|
import { type SandboxCapability } from '../capabilities/index.js';
|
|
4
4
|
export declare function describeToolsSchema(tools: McpToolSchema[], capabilities: SandboxCapability[]): McpToolSchema;
|
|
5
|
-
export declare function describeTools(tools: McpToolSchema[],
|
|
5
|
+
export declare function describeTools(tools: McpToolSchema[], capabilities: SandboxCapability[], context: McpToolContext): McpToolCallback;
|
|
6
6
|
//# sourceMappingURL=describe-tools.d.ts.map
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
import{renderDescribeToolsOutput as
|
|
2
|
-
|
|
3
|
-
`);return E({tool:l,mode:m,serverType:u.Docs,args:t,result:h,...d}),k({tool:l,mode:m,serverType:u.Docs,durationMs:Math.round(performance.now()-b),outputLength:h.length,...d}),{content:[{type:"text",text:h}]}}catch(e){const i=e instanceof O,a=i?"tool_error":"server_error";throw E({tool:l,mode:m,serverType:u.Docs,args:t,errorClass:a,...d}),C({tool:l,mode:m,serverType:u.Docs,durationMs:Math.round(performance.now()-b),message:e instanceof Error?e.message:String(e),stack:!i&&e instanceof Error&&e.stack||"",errorClass:a,...d}),e}}}export{z as describeTools,B as describeToolsSchema};
|
|
1
|
+
import{renderDescribeToolsOutput as E}from"../capabilities/index.js";import{McpServerType as u,READ_ONLY_ANNOTATIONS as O}from"../../constants.js";import{logMcpToolCallAudit as h,reportMcpToolCalled as S,reportMcpToolError as b}from"../../workers/mcp-tool-telemetry.js";import{DESCRIBE_TOOLS_TOOL_NAME as l}from"../constants.js";import{DESCRIBE_TOOLS_DESCRIPTION as v}from"../prompts.js";import{sanitizeToolName as s}from"../build-tool-type-declarations.js";import{UnknownToolError as w}from"./tool-errors.js";import{callAttribution as D}from"../../utils/telemetry-attributes.js";function R(p,i){const n=[...new Set([...p.map(r=>s(r.name)),...i.map(r=>s(r.id))])];return{name:l,title:"Get docs function signatures",description:v,annotations:O,schema:{type:"object",required:[],additionalProperties:!1,properties:{tools:{type:"array",description:`Tool names to describe: ${n.join(", ")}. Omit to describe everything.`,items:n.length>0?{type:"string",enum:n}:{type:"string"},nullable:!0}}}}}function U(p,i,n){const r=new Map(p.map(t=>[s(t.name),t])),T=new Map(i.map(t=>[s(t.id),t]));return async t=>{const y=performance.now(),m=n.mcpMode??"code",d=D(n);try{const o=[...new Set((t.tools??[]).map(s))],a=o.length===0,c=o.filter(e=>!r.has(e)&&!T.has(e));if(c.length>0){const e=[...r.keys(),...T.keys()];throw new w(`Unknown tool(s): ${c.join(", ")}. Valid tools: ${e.join(", ")}.`)}const M=a?i:i.filter(e=>o.includes(s(e.id))),g=a?p:o.filter(e=>r.has(e)).map(e=>r.get(e)),f=E(g,M,n);return h({tool:l,mode:m,serverType:u.Docs,args:t,result:f,...d}),S({tool:l,mode:m,serverType:u.Docs,durationMs:Math.round(performance.now()-y),outputLength:f.length,...d}),{content:[{type:"text",text:f}]}}catch(o){const a=o instanceof w,c=a?"tool_error":"server_error";throw h({tool:l,mode:m,serverType:u.Docs,args:t,errorClass:c,...d}),b({tool:l,mode:m,serverType:u.Docs,durationMs:Math.round(performance.now()-y),message:o instanceof Error?o.message:String(o),stack:!a&&o instanceof Error&&o.stack||"",errorClass:c,...d}),o}}}export{U as describeTools,R as describeToolsSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FIELD_SCOPE_KINDS as n,GRAPHQL_TYPE_KINDS as u}from"./constants.js";import{respondWithGraphqlSchema as g,paginate as d}from"./tool-helpers.js";import{groupSchemaTypes as h,fieldMembers as y,filterMembersReferencingType as S,matchesFilter as b}from"./utils.js";function T(r,p,t){if(p==="fields"){if(t&&!n.some(e=>e===t))throw new Error(`scope "fields" lists the fields of object, interface, and input types; kind must be ${n.map(e=>`"${e}"`).join(", ")}, or omitted.`);return y(r,t)}const o=h(r);return(t?[t]:u).flatMap(e=>o[e].map(s=>({kind:e,...s})))}const E=(r,p)=>g(r.name,p,({name:t,schema:o})=>{const{kind:e,scope:s="members",filter:f,referencesType:l,page:m
|
|
1
|
+
import{FIELD_SCOPE_KINDS as n,GRAPHQL_TYPE_KINDS as u}from"./constants.js";import{respondWithGraphqlSchema as g,paginate as d}from"./tool-helpers.js";import{groupSchemaTypes as h,fieldMembers as y,filterMembersReferencingType as S,matchesFilter as b}from"./utils.js";function T(r,p,t){if(p==="fields"){if(t&&!n.some(e=>e===t))throw new Error(`scope "fields" lists the fields of object, interface, and input types; kind must be ${n.map(e=>`"${e}"`).join(", ")}, or omitted.`);return y(r,t)}const o=h(r);return(t?[t]:u).flatMap(e=>o[e].map(s=>({kind:e,...s})))}const E=(r,p)=>g(r.name,p,({name:t,schema:o})=>{const{kind:e,scope:s="members",filter:f,referencesType:l,page:m,limit:a}=r;let i=T(o,s,e);return l&&(i=S(o,i,l)),f&&(i=i.filter(c=>b(c,f))),JSON.stringify({name:t,...d(i,m??1,a??300)},null,2)});var D={"get-graphql-type-list":E};export{D as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{paginate as p,textResult as m}from"./tool-helpers.js";const c=async(r,l)=>{const{filter:i,page:o
|
|
1
|
+
import{paginate as p,textResult as m}from"./tool-helpers.js";const c=async(r,l)=>{const{filter:i,page:o,limit:n}=r;let t=l.graphqlDescriptions;if(i){const e=i.toLowerCase();t=t.filter(s=>s.name.toLowerCase().includes(e))}const a=p(t,o??1,n??300);return m(JSON.stringify({...a,items:a.items.map(({name:e,description:s})=>({name:e,description:s}))}))};var g={"list-graphql-apis":c};export{g as default};
|
|
@@ -14,8 +14,8 @@ export type SchemaMemberWithKind = SchemaMember & {
|
|
|
14
14
|
export type GroupedSchemaTypes = Record<GraphqlTypeKind, SchemaMember[]>;
|
|
15
15
|
export type ListGraphqlApisArgs = {
|
|
16
16
|
filter?: string;
|
|
17
|
-
page?: number;
|
|
18
|
-
limit?: number;
|
|
17
|
+
page?: number | null;
|
|
18
|
+
limit?: number | null;
|
|
19
19
|
};
|
|
20
20
|
export type GetGraphqlTypeListArgs = {
|
|
21
21
|
name: string;
|
|
@@ -23,8 +23,8 @@ export type GetGraphqlTypeListArgs = {
|
|
|
23
23
|
scope?: GraphqlListScope;
|
|
24
24
|
filter?: string;
|
|
25
25
|
referencesType?: string;
|
|
26
|
-
page?: number;
|
|
27
|
-
limit?: number;
|
|
26
|
+
page?: number | null;
|
|
27
|
+
limit?: number | null;
|
|
28
28
|
};
|
|
29
29
|
export type GetGraphqlTypeArgs = {
|
|
30
30
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCallableApis as b}from"../../../gateway-mcp/callable-apis.js";import{filterApiDescriptionsByName as d}from"../../utils/api-name-matching.js";import{apiTitleKey as y,countApiTitles as A,orderSharedTitles as T}from"../../utils/api-titles.js";const x=async(
|
|
1
|
+
import{getCallableApis as b}from"../../../gateway-mcp/callable-apis.js";import{filterApiDescriptionsByName as d}from"../../utils/api-name-matching.js";import{apiTitleKey as y,countApiTitles as A,orderSharedTitles as T}from"../../utils/api-titles.js";const x=async(l,s)=>{const{filter:a}=l,n=l.page??1,e=l.limit??300,o=new Set(b(s).map(i=>i.relativePath)),m=o.size>0,c=T(Object.values(s.apiDescriptionsMap)),f=A(c);let t=c;a&&(t=d(t,a));const p=(n-1)*e,u=p+e,g=Math.ceil(t.length/e),h=t.length;return t=t.slice(p,u),{content:[{type:"text",text:JSON.stringify({items:t.map(({relativePath:i,fetchEligible:D,...r})=>({filePath:i,...r,...(f.get(y(r.name))??0)>1?{ambiguousTitle:!0}:{},...m?{callable:o.has(i)}:{}})),limit:e,total:h,page:n,totalPages:g})}]}};var I={"list-apis":x};export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger as A}from"../../../tools/notifiers/logger.js";import{getFeedbackClientIp as
|
|
1
|
+
import{logger as A}from"../../../tools/notifiers/logger.js";import{getFeedbackClientIp as v}from"../../../web-server/utils/feedback-ip.js";import{getForwardedOrigin as M,getInternalOrigin as N}from"../../../web-server/utils/get-request-origin.js";import{GATEWAY_FETCH_LIMIT_DEFAULTS as L,DEFAULT_ANONYMOUS_VISITOR_TEAM as B,RbacFeatures as H}from"../../../../constants/common.js";import{isObject as j}from"../../../../utils/guards/is-object.js";import{getAccessibleSkills as V}from"../../../utils/skills/get-accessible-skills.js";import{getSkillUrl as $}from"../../../utils/skills/get-skill-url.js";import{createMcpHandler as Y}from"@modelcontextprotocol/server";import{createDocsMcpServer as G}from"../servers/docs-server.js";import{filterApiDescriptionsByRbac as J,filterGraphqlDescriptionsByRbac as K}from"../utils.js";import{userSubject as z}from"../gateway-mcp/subject.js";import{ipRateLimitKey as X}from"../gateway-mcp/rate-limit/utils/ip-key.js";import{createMethodNotAllowedError as Q,withErrorHandling as W}from"./errors.js";import{constructForbiddenResponse as Z,constructInvalidTokenResponse as q,constructUnauthorizedResponse as x,handleMcpAuth as ee}from"../auth/auth-handlers.js";import{isAssistantAnonymousToken as oe}from"../auth/assistant-anonymous-token.js";import{shouldHandleMcpAuth as re}from"../../../utils/rbac/should-handle-mcp-auth.js";import{extractTokenFromAuthHeader as se}from"../utils/jwt.js";import{resolveMcpClient as ie}from"../utils/mcp-client.js";import{randomUUID as ne}from"../../../utils/crypto/random-uuid.js";import{getPublicMcpEndpointStatus as te}from"../utils/public-endpoint.js";import{narrowMcpConfigForCaller as ce}from"../gateway-mcp/caller-api-calls.js";import{DEFAULT_DOCS_MCP_SERVER_NAME as ae,SSE_KEEPALIVE_INTERVAL_MS as pe}from"../constants.js";import{withPathPrefix as de}from"@redocly/theme/core/utils";import{PUBLIC_MCP_ROUTE as le}from"@redocly/theme/core/constants/mcp";import{canAccessFeature as me}from"../../../utils/rbac.js";import{ANONYMOUS_AUTH_DETAILS as fe}from"../../../constants/rbac.js";const E="X-Redocly-AI-Metadata",ue=1024*1024;function ge(o){if(o)try{const e=JSON.parse(o);if(j(e))return e;A.warn(`Ignoring ${E} header: not a JSON object.`)}catch{A.warn(`Ignoring ${E} header: invalid JSON.`)}}function he(o,e){return new URL(o).searchParams.get("mode")==="tools"?"tools":e}function b(){return{...fe,email:"",idpAccessToken:void 0,idpId:void 0}}const Ae=async(o,e,n)=>{const t=!!e?.config?.access?.requiresLogin,c=e?.config?.access?.rbac||{},I=n?.props?.config?.mcpMode??"tools",p=he(o.url,I),U=n?.props?.config?.gatewayFetchBudgetPerExec??L.budgetPerExec,R=n?.props?.config?.searchIgnoredRoutes??[],r=n,C=!!r?.props?.config?.isPublicEndpoint;let u;const T=o.headers.get("Authorization");if(C)e.user=b();else if(re(t,c)){const{isAuthenticated:i,isTokenValid:d,isFirstPartyAnonymous:g,currentUser:l,accessToken:h}=await ee(o,e);if(g)e.user=b();else if(i)l&&(e.user=l),u=h;else{const a=M(o),m=te(e.config)==="served"?`${a}${de(le)}`:void 0;return d===!1?q(a,m):x(a,m)}}else if(T){const i=se(T)??void 0;u=(i?await oe(i):!1)?void 0:i}const _={isAuthenticated:!!e.user?.isAuthenticated,teams:e.user?.teams||[B],claims:e.user?.claims??{}};return me(H.MCP,_,c,t)?await W(async()=>{const i=p==="code"&&(n?.props?.config?.elicitationEnabled??!1);if(o.method==="GET")return new Response(JSON.stringify({error:"Method Not Allowed",message:`In order to use this MCP server, you need to register it in your MCP client (VS Code, Cursor, Claude Code, etc.) using this URL: ${o.url}`}),{status:405,headers:{"Content-Type":"application/json"}});if(o.method!=="POST")return Q();const d=r?.props?.config?.apiDescriptionsMap||{},g=r?.props?.config?.graphqlDescriptions||[],l=r?.props?.config?.mcpDocsServerName||ae,{config:{mcp:h={}}}=e,a=J(d,e.user,c,t),m=K(g,e.user,c,t),y=e.config.products?Object.values(e.config.products).map(s=>s?.name):[],D=h.docs?.name||l,f=ge(o.headers.get(E)),P=r?.props?.tools||[],O=r?.props?.skillsBaseUrl||M(o),w=V(r?.props?.skills||[],e.user,c,t).map(s=>({slug:s.slug,name:s.name,description:s.description,content:s.content,uri:$(O,s.slug)})),S=r?.props?.fetchCountSecret,F={name:D,tools:P,skills:w,context:{...e,config:{...e.config,mcp:ce(e.config.mcp,f)},configFile:r?.props?.configFile,accessToken:u,outdir:e.outdir||"",baseUrl:e.baseUrl||M(o),internalBaseUrl:N(o),apiDescriptionsMap:a,graphqlDescriptions:m,products:y,metadata:f,mcpMode:p,elicitationEnabled:i,gatewayFetchBudgetPerExec:U,fetchCountRequest:p==="code"&&S?{caller:{subject:z(e.user),ip:X(o)},secret:S}:void 0,searchIgnoredRoutes:R,clientIp:v(o),...ie(o),requestId:ne(),messageId:typeof f?.messageId=="string"?f.messageId:void 0}},k=await G({...F,getKv:e.getKv});return await Y(async()=>k,{keepAliveMs:pe,maxRequestBodySize:ue,onerror:s=>A.warn(`MCP handler: ${s.message}`)}).fetch(o)},p):Z()};var Je=Ae;export{Je as default};
|
|
@@ -12,11 +12,6 @@ export declare class McpError extends Error {
|
|
|
12
12
|
constructor(code: McpErrorCodeTypes, message: string, data?: unknown, requestId?: string | number | null);
|
|
13
13
|
createErrorResponse(): Response;
|
|
14
14
|
}
|
|
15
|
-
export declare class McpClientInputError extends Error {
|
|
16
|
-
constructor(message: string, options?: {
|
|
17
|
-
cause?: unknown;
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
15
|
export declare function createMethodNotAllowedError(requestId?: string | number | null): Response;
|
|
21
16
|
export declare function createInternalServerError(error: Error | string, requestId?: string | number | null): Response;
|
|
22
17
|
export declare function withErrorHandling<T>(operation: () => Promise<T>, mode?: McpMode): Promise<T | Response>;
|
|
@@ -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 d}from"../constants.js";import{serverAttributes as i}from"../utils/telemetry-attributes.js";class n extends Error{code;data;requestId;constructor(t,e,s,a){super(e),this.name="McpError",this.code=t,this.data=s,this.requestId=a}createErrorResponse(){const t={jsonrpc:"2.0",error:{code:this.code,message:this.message,...this.data?{data:this.data}:{}},id:this.requestId??null},e=p(this.code);return new Response(JSON.stringify(t),{status:e,headers:{"Content-Type":"application/json"}})}}function p(r){switch(r){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(r){return new n(o.ServerError,"Method not allowed",void 0,r).createErrorResponse()}function u(r,t){const e=r instanceof Error?r.message:String(r);return new n(o.InternalError,"Internal server error mcp",e,t).createErrorResponse()}async function f(r,t="tools"){try{return await r()}catch(e){return c.sendMcpErrorMessage([{...i(d.Docs),message:e?.message||"",stack:e?.stack||"",error_class:"server_error",mode:t}]),u(e)}}export{n as McpError,u as createInternalServerError,h as createMethodNotAllowedError,f as withErrorHandling};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{withPathPrefix as g}from"@redocly/theme/core/utils";import{importApiRoutesHandler as h}from"../../../api-routes/import-api-routes-handlers.js";import{enhanceContext as D}from"../../../api-routes/helpers/enhance-context.js";import{telemetry as A}from"../../../telemetry/index.js";import{KvService as E}from"../../../persistence/kv/services/kv-service.js";import{envConfig as l}from"../../../config/env-config.js";import{acceptsHtml as R}from"../../../utils/ai-agent-detection.js";import{handleErrorPageRender as T}from"../../../web-server/utils.js";import{MCP_DOCS_SERVER_HANDLER_ID as _,MCP_NOT_ALLOWED_TEMPLATE_ID as w}from"../../../constants/mcp.js";import{resolvePublicBaseUrl as S}from"../../../web-server/utils/resolve-public-base-url.js";import{getForwardedOrigin as q}from"../../../web-server/utils/get-request-origin.js";import{applyEdgeRateLimit as C}from"../gateway-mcp/rate-limit/request-limiter/apply-edge-rate-limit.js";import{fetchCountSecret as O}from"../gateway-mcp/rate-limit/fetch-limiter/fetch-count-secret.js";async function
|
|
1
|
+
import{withPathPrefix as g}from"@redocly/theme/core/utils";import{importApiRoutesHandler as h}from"../../../api-routes/import-api-routes-handlers.js";import{enhanceContext as D}from"../../../api-routes/helpers/enhance-context.js";import{telemetry as A}from"../../../telemetry/index.js";import{KvService as E}from"../../../persistence/kv/services/kv-service.js";import{envConfig as l}from"../../../config/env-config.js";import{acceptsHtml as R}from"../../../utils/ai-agent-detection.js";import{handleErrorPageRender as T}from"../../../web-server/utils.js";import{MCP_DOCS_SERVER_HANDLER_ID as _,MCP_NOT_ALLOWED_TEMPLATE_ID as w}from"../../../constants/mcp.js";import{resolvePublicBaseUrl as S}from"../../../web-server/utils/resolve-public-base-url.js";import{getForwardedOrigin as q}from"../../../web-server/utils/get-request-origin.js";import{applyEdgeRateLimit as C}from"../gateway-mcp/rate-limit/request-limiter/apply-edge-rate-limit.js";import{fetchCountSecret as O}from"../gateway-mcp/rate-limit/fetch-limiter/fetch-count-secret.js";async function K(i,t,e){const n=t.req.raw;if(i.requestHandlerId===_&&n.method==="GET"&&R(n.headers.get("accept"))&&e.globalData.mcpData?.docs?.enabled)return T(t,e,{slug:i.slug},405,w);const r=t.get("auth"),o=await C(n,e);if(o)return o;const s=await e.resolveRouteStaticData(i)||{},c=g(i.slug),{requestHandlers:m}=await h(e.serverOutDir),p=m[i.requestHandlerId],d=(await p()).default,u=async()=>await E.getInstance({baseDbDir:e.serverOutDir,sqldRemoteDatabaseUrl:l.SQLD_REMOTE_DATABASE_URL,sqldRemoteDatabaseAuthToken:l.SQLD_REMOTE_DATABASE_AUTH_TOKEN}),f=D({honoCtx:t,ctx:{user:{teams:r.teams,email:r.claims.email,claims:r.claims,idpAccessToken:r.idpAccessToken,idpId:r.claims.idpId,isAuthenticated:r.isAuthenticated},config:e.config,outdir:e.outdir,baseUrl:q(t.req.raw)},telemetry:A,getKv:u}),a=await d(t.req.raw,f,{...s,props:{...s.props,routeSlug:c,outdir:e.outdir,fetchCountSecret:O(),skills:e.config.skills?.hide===!0?[]:e.getSkills(),skillsBaseUrl:S(e,t),configFile:e.configFile}});return a instanceof Response?a:typeof a=="string"?new Response(a,{headers:{"Content-Type":"text/plain"}}):new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"}})}export{K as handleMcpRequest};
|