@redocly/framework 1.0.0-next.12 → 1.0.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/dist/bundler/build/dependency-pack.js +1 -1
- package/dist/bundler/build/output-metadata.js +1 -1
- package/dist/bundler/build/run.js +1 -1
- package/dist/bundler/build/theme-global-stylesheets.js +1 -1
- package/dist/bundler/build/vite-config.js +2 -2
- package/dist/bundler/dev/dev-content-build.js +1 -1
- package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
- package/dist/bundler/dev/routes/source-sync-route.js +1 -1
- package/dist/bundler/dev/run.js +1 -1
- package/dist/bundler/dev/runtime-app.js +1 -1
- package/dist/bundler/dev/vite-chunk-url.js +1 -1
- package/dist/bundler/user-markdoc-schema.js +1 -1
- package/dist/bundler/vite-config.base.js +5 -5
- package/dist/cli/api-docs-build-event.js +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/commands/build.js +1 -1
- package/dist/cli/commands/dev.js +1 -1
- package/dist/cli/commands/ingest.js +1 -1
- package/dist/cli/commands/translate.js +1 -1
- package/dist/cli/problems-output.js +3 -3
- package/dist/cli/validate-react-pages.js +1 -1
- package/dist/client/UnversionedVersionButton.js +1 -1
- package/dist/client/VersionPicker.js +343 -0
- package/dist/client/ai-search/use-ai-search.js +1 -1
- package/dist/client/analytics-page-view.js +1 -1
- package/dist/client/app.js +2 -2
- package/dist/client/classic-webview-sync.js +1 -1
- package/dist/client/client-entry.js +1 -1
- package/dist/client/contexts.js +1 -1
- package/dist/client/feedback.js +1 -1
- package/dist/client/history-mount.js +6 -5
- package/dist/client/l10n/ssr-l10n.js +1 -1
- package/dist/client/l10n/use-l10n-config.js +1 -1
- package/dist/client/products.js +1 -1
- package/dist/client/review/ReviewBar.js +31 -31
- package/dist/client/review/login-url.js +1 -1
- package/dist/client/review/use-review.js +1 -1
- package/dist/client/revisions-history.js +1 -1
- package/dist/client/sidebar/SidebarDataProvider.js +1 -1
- package/dist/client/sidebar/drilldown.js +1 -1
- package/dist/client/ssr.js +1 -1
- package/dist/client/telemetry/config.js +1 -1
- package/dist/client/theme-logo.js +1 -1
- package/dist/client/use-entity-revisions.js +1 -1
- package/dist/client/use-page-versions.js +1 -1
- package/dist/client/use-search.js +1 -1
- package/dist/client/webmcp/tools/shared.js +1 -1
- package/dist/client/webmcp/tools/site-tools.js +1 -1
- package/dist/client/webmcp/use-webmcp-tools.js +1 -1
- package/dist/content-layer/config-schema.js +1 -1
- package/dist/content-layer/config.d.ts +8 -0
- package/dist/content-layer/config.js +1 -1
- package/dist/content-layer/context-state.js +1 -1
- package/dist/content-layer/context.d.ts +6 -0
- package/dist/content-layer/context.js +1 -1
- package/dist/content-layer/database/assets.js +1 -1
- package/dist/content-layer/database/blobs.js +1 -1
- package/dist/content-layer/database/entities.d.ts +2 -0
- package/dist/content-layer/database/entities.js +1 -1
- package/dist/content-layer/database/entity-store.js +1 -1
- package/dist/content-layer/database/files.js +1 -1
- package/dist/content-layer/database/finalize.js +1 -1
- package/dist/content-layer/database/invalidation.js +26 -26
- package/dist/content-layer/database/link-refs.js +1 -1
- package/dist/content-layer/database/origins.d.ts +2 -1
- package/dist/content-layer/database/origins.js +1 -1
- package/dist/content-layer/database/problems.js +1 -1
- package/dist/content-layer/database/reset.js +1 -1
- package/dist/content-layer/database/route-query-deps.d.ts +19 -3
- package/dist/content-layer/database/route-query-deps.js +1 -1
- package/dist/content-layer/database/search-vocab.js +2 -2
- package/dist/content-layer/database/static-files.js +1 -1
- package/dist/content-layer/ingest/extract-all-phase.js +1 -1
- package/dist/content-layer/ingest/finalize-phase.js +1 -1
- package/dist/content-layer/ingest/git-last-modified.d.ts +20 -0
- package/dist/content-layer/ingest/git-last-modified.js +5 -4
- package/dist/content-layer/ingest/hash.js +1 -1
- package/dist/content-layer/ingest/hook-inputs.js +1 -1
- package/dist/content-layer/ingest/l10n-warnings.js +1 -1
- package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
- package/dist/content-layer/ingest/run.js +1 -1
- package/dist/content-layer/ingest/scan.js +1 -1
- package/dist/content-layer/ingest/search-sync.js +1 -1
- package/dist/content-layer/ingest/sync.js +1 -1
- package/dist/content-layer/link-checker/config-links.js +1 -1
- package/dist/content-layer/link-checker/delta.js +1 -1
- package/dist/content-layer/link-checker/fingerprint.js +1 -1
- package/dist/content-layer/link-checker/load-view.js +1 -1
- package/dist/content-layer/link-checker/node-ref.js +1 -1
- package/dist/content-layer/link-checker/run-build.js +1 -1
- package/dist/content-layer/link-checker/validate.js +1 -1
- package/dist/content-layer/loaders/context.js +1 -1
- package/dist/content-layer/markdown/client/JsonSchemaTag.js +1 -1
- package/dist/content-layer/markdown/client/markdown-text.js +1 -1
- package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
- package/dist/content-layer/markdown/nodes/fence.js +1 -1
- package/dist/content-layer/markdown/nodes/heading.js +1 -1
- package/dist/content-layer/markdown/nodes/table.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/file-reference.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/partial.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc-resolvers/svg-content.js +1 -1
- package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
- package/dist/content-layer/markdown/resolve/references.js +1 -1
- package/dist/content-layer/markdown/search/to-markdown.js +2 -2
- package/dist/content-layer/markdown/search/to-sections.js +1 -1
- package/dist/content-layer/markdown/search/to-text.js +5 -5
- package/dist/content-layer/markdown/server/render.js +1 -1
- package/dist/content-layer/markdown/service.js +1 -1
- package/dist/content-layer/markdown/tags/variant.js +1 -1
- package/dist/content-layer/markdown/utils/collect-anchors.js +1 -1
- package/dist/content-layer/markdown/utils/first-heading.js +1 -1
- package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
- package/dist/content-layer/materialization/asset-reconcile.js +1 -1
- package/dist/content-layer/materialization/entity.js +1 -1
- package/dist/content-layer/materialization/materializer.js +1 -1
- package/dist/content-layer/materialization/static-files.js +1 -1
- package/dist/content-layer/plugins/execute.js +1 -1
- package/dist/content-layer/plugins/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/client/template.js +2 -2
- package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/build-definition.d.ts +2 -0
- package/dist/content-layer/plugins/internal/api-docs/server/build-definition.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/markdown-copy.js +12 -10
- package/dist/content-layer/plugins/internal/api-docs/server/options.d.ts +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/search-documents.js +1 -1
- package/dist/content-layer/plugins/internal/api-docs/server/spec-download.js +1 -1
- package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/logo.js +1 -1
- package/dist/content-layer/plugins/internal/app-data/products.js +1 -1
- package/dist/content-layer/plugins/internal/assets/index.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/client/use-catalog-classic.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/catalog-classic/resolve-items.js +1 -1
- package/dist/content-layer/plugins/internal/index.js +1 -1
- package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
- package/dist/content-layer/plugins/internal/l10n/translations-loader.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/app-data.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/constants.d.ts +4 -3
- package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/ignored-routes.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/constants.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/execute-schema.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/codemode/prompts.js +8 -8
- package/dist/content-layer/plugins/internal/mcp/server/config-gate.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/custom-tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/call-api.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-handler.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +6 -6
- package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
- package/dist/content-layer/plugins/internal/mcp/server/gateway/subject.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/tool-list.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +4 -4
- package/dist/content-layer/plugins/internal/mcp/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/callback.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/register.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/oauth/token.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/server-info.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +2 -2
- package/dist/content-layer/plugins/internal/mcp/server/workflows/resolve-workflows.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/server/workflows/schemas.js +2 -1
- package/dist/content-layer/plugins/internal/mcp/server/workflows/tools.js +1 -1
- package/dist/content-layer/plugins/internal/mcp/setup-page.js +1 -1
- package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
- package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/client/template.js +1 -1
- package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
- package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
- package/dist/content-layer/plugins/internal/skills/index.js +1 -1
- package/dist/content-layer/plugins/internal/skills/server/routes.js +1 -1
- package/dist/content-layer/plugins/io.js +1 -1
- package/dist/content-layer/plugins/project/load.js +2 -2
- package/dist/content-layer/plugins/source-file.js +1 -1
- package/dist/content-layer/plugins/utils/link-access.js +1 -1
- package/dist/content-layer/plugins/utils/route-index.js +1 -1
- package/dist/content-layer/revisions/delete.js +1 -1
- package/dist/content-layer/revisions/read.js +1 -1
- package/dist/content-layer/search/engine/core/search-engine.js +1 -1
- package/dist/content-layer/search/postings/postings-store.js +1 -1
- package/dist/content-layer/server/database.js +1 -1
- package/dist/content-layer/static/registry.js +1 -1
- package/dist/content-layer/templates/template-set.js +1 -1
- package/dist/content-layer/versions/redirect.js +1 -1
- package/dist/content-layer/versions/resolve.js +1 -1
- package/dist/server/app.js +3 -3
- package/dist/server/ask-ai/route.js +1 -1
- package/dist/server/auth/middleware.js +1 -1
- package/dist/server/auth/request.js +1 -1
- package/dist/server/auth/routes.js +1 -1
- package/dist/server/content.js +12 -12
- package/dist/server/cors-proxy/handler.js +1 -1
- package/dist/server/feedback/route.js +1 -1
- package/dist/server/lambda-entry.js +1 -1
- package/dist/server/manifest-assets.js +4 -4
- package/dist/server/node-entry.js +1 -1
- package/dist/server/plugin-context.js +1 -1
- package/dist/server/rbac/content-asset-access.js +1 -1
- package/dist/server/runtime-config.js +1 -1
- package/dist/server/search/route.js +1 -1
- package/dist/server/seo-tags.js +2 -2
- package/dist/server/sitemap.js +1 -1
- package/dist/server/static-files/serve.js +1 -1
- package/dist/server/subprocess/child-entry.js +1 -1
- package/dist/server/template-ids.js +1 -1
- package/dist/shared/constants/system-routes.js +1 -1
- package/dist/shared/rbac/engine.js +0 -0
- package/dist/shared/rbac/l10n-rules.js +1 -1
- package/dist/shared/rbac/route-scope.js +1 -1
- package/dist/shared/rbac/team-templates.js +1 -1
- package/dist/shared/types/config.d.ts +2 -1
- package/dist/shared/utils/l10n.js +1 -1
- package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{MCP_CALLBACK_ROUTE as e}from"../../constants.js";import{SystemRoute as t}from"../../../../../../shared/constants/system-routes.js";import{withPathPrefix as n}from"../../../../../../shared/path-prefix.js";import{isMcpContentProtected as r,isMcpHidden as i,resolveMcpAccess as a}from"../config-gate.js";import{getSessionIssuer as o}from"../../../../../../server/auth/middleware.js";import{notFoundResponse as s}from"../../../../../../server/plugin-context.js";import{SUPPORTED_CODE_CHALLENGE_METHODS as c}from"./constants.js";import"../auth.js";import{sendMcpAuthorizationStarted as l}from"../mcp-telemetry.js";import{applyMcpRateLimit as u}from"../rate-limit.js";import{parseRedirectUri as d}from"./redirect-uri.js";import{fetchClientMetadataDocument as f,isClientMetadataDocumentUrl as p,isRedirectUriRegistered as m}from"./client-metadata.js";import{readMcpClient as h}from"./client-registry.js";import{reportMcpAuthorizationFailure as g,withMcpFailureReporting as _}from"./error-reporting.js";import{isSupportedCodeChallengeMethod as v,signMcpArtifact as y}from"./tokens.js";import{ulid as b}from"ulid";function x(e,t){return e.json({error:`invalid_request`,error_description:t},400)}async function S(e,t,n){if(p(t)){let r;try{r=await f(t)}catch(t){let n=`Unable to resolve client metadata document: ${t instanceof Error?t.message:String(t)}`;return await g(e,n),{ok:!1,error:n}}return{ok:!0,allowed:m(n,r.redirect_uris),clientName:r.client_name??null}}let r=(await h(e.kv,t))?.redirect_uris??[];return{ok:!0,allowed:r.length===0||m(n,r),clientName:null}}const C=_(w,e=>e.json({error:`server_error`,error_description:`The server could not complete the request`},500));async function w(f,p){if(i(p.config)||!r(a(p.config)))return s();let m=o(f);if(!m)return s();let h=await u({kv:p.kv,ip:p.request.ip,bucket:`oauth`,logger:p.logger});if(h)return h;let g=new URL(f.req.url).searchParams,_=g.get(`redirect_uri`),C=g.get(`client_id`),w=g.get(`code_challenge`),T=g.get(`code_challenge_method`);if(!_||!d(_))return x(f,`redirect_uri must be an https URL, a loopback http URL, or a private-use scheme`);if(!C)return x(f,`client_id is required`);if(!w)return x(f,`code_challenge is required`);if(!T||!v(T))return x(f,`Unsupported code_challenge_method. Supported: ${c.join(`, `)}`);let E=await S(p,C,_);if(!E.ok)return f.json({error:`invalid_client`,error_description:E.error},400);if(!E.allowed)return x(f,`redirect_uri is not registered for this client`);let D=b(),O=await y({type:`mcp_context`,sessionId:D,redirectUri:_,clientId:C,clientName:E.clientName,state:g.get(`state`),codeChallenge:w,codeChallengeMethod:T},m.artifactSecret,Math.floor(Date.now()/1e3)+600);l(D,_,{logger:p.logger});let k=new URLSearchParams({redirectTo:`${e}/${O}`});return f.redirect(`${n(t.AuthIdpLogin)}?${k.toString()}`,302)}export{C as mcpAuthorize};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isMcpHidden as e}from"../config-gate.js";import{REALM_SESSION_COOKIE as t}from"../../../../../../server/auth/constants.js";import{getBearerVerifier as n,getSessionIssuer as r}from"../../../../../../server/auth/middleware.js";import{notFoundResponse as i}from"../../../../../../server/plugin-context.js";import{MCP_REFRESH_SESSION_LIFETIME_SEC as a,SUPPORTED_MCP_SCOPES as o}from"./constants.js";import{auditInput as s}from"../audit.js";import{sendMcpAuthorizationCompleted as c}from"../mcp-telemetry.js";import{loadPageSite as l}from"../gateway/credentials-page/site-branding.js";import{isLoopbackRedirect as u,parseRedirectUri as d}from"./redirect-uri.js";import{isClientMetadataDocumentUrl as f}from"./client-metadata.js";import{reportMcpAuthorizationFailure as p,withMcpFailureReporting as m}from"./error-reporting.js";import{sessionClaimsFromSession as h,sha256Base64Url as g,signMcpArtifact as _,verifyMcpArtifact as v}from"./tokens.js";import{CONSENT_PAGE_HEADERS as y,consentInvalidPage as b,consentPage as x}from"./consent-page.js";import{hasConsent as S,saveConsent as C}from"./store.js";import{getCookie as w}from"hono/cookie";const T={"Cache-Control":`no-store`},E=`Missing context token`;function D(e){let t=e.searchParams.get(`context`);if(t)return t;let n=e.pathname.split(`/`).filter(Boolean).pop();return n&&n!==`callback`?n:null}async function O(e,r){let i=new URL(e.req.url),a=w(e,t),o=a?await n(e)?.(a):null;return{method:e.req.method,path:`${i.pathname}${i.search}`,referer:e.req.header(`referer`)??null,user_agent:r.request.userAgent,has_session_cookie:a!==void 0,has_user_session:!!o&&o?.claims.tokenUse!==`mcp_access_token`}}function k(a){return async(o,c)=>{if(e(c.config))return i();let l=r(o);if(!l)return i();let u=D(new URL(o.req.url));if(!u){let e=await O(o,c);return await p(c,E,{details:s(JSON.stringify(e)),logFields:e}),o.text(E,400,T)}let f,m,h;try{if(f=await v(u,l.artifactSecret,`mcp_context`),h=f.sessionId,o.set(`realmMcpSessionId`,h),m=d(f.redirectUri),!m)throw Error(`Invalid MCP context`)}catch(e){let t=await p(c,e,{sessionId:h,errorClass:`client_error`,logMessage:`MCP callback failed`});return o.text(`Invalid MCP callback: ${t}`,400,T)}let g=w(o,t),_=g?await n(o)?.(g):null;return!g||!_||_.claims.tokenUse===`mcp_access_token`?(await p(c,`Authentication required`,{sessionId:h}),o.text(`Authentication required`,401,T)):a(o,c,{issuer:l,contextToken:u,mcpContext:f,redirectUrl:m,sessionToken:g,session:_})}}async function A(e,t,{issuer:n,mcpContext:r,redirectUrl:i,session:o}){let s=Math.floor(Date.now()/1e3),l=await _({type:`mcp_auth_code`,sessionId:r.sessionId,clientId:r.clientId,redirectUri:r.redirectUri,claims:h(o),sessionExp:s+a,codeChallenge:r.codeChallenge,codeChallengeMethod:r.codeChallengeMethod},n.artifactSecret,s+600),u=new URL(i);return u.searchParams.set(`code`,l),r.state&&u.searchParams.set(`state`,r.state),c(r.sessionId,r.redirectUri,{logger:t.logger}),e.header(`Cache-Control`,`no-store`),e.redirect(u.toString(),302)}async function j(e,t,{mcpContext:n,redirectUrl:r}){let i=new URL(r);return i.searchParams.set(`error`,`access_denied`),n.state&&i.searchParams.set(`state`,n.state),await p(t,`access_denied`,{sessionId:n.sessionId}),e.header(`Cache-Control`,`no-store`),e.redirect(i.toString(),302)}function M({mcpContext:e,session:t}){return{idpId:t.claims.idpId,subject:t.viewer.sub,clientId:e.clientId,redirectUri:e.redirectUri}}function N({issuer:e,sessionToken:t,contextToken:n}){return _({type:`mcp_consent`,sessionHash:g(t),contextHash:g(n)},e.artifactSecret,Math.floor(Date.now()/1e3)+300)}async function P(e,{issuer:t,sessionToken:n,contextToken:r}){try{let i=await v(e,t.artifactSecret,`mcp_consent`);return i.sessionHash===g(n)&&i.contextHash===g(r)}catch{return!1}}const F=e=>e.text(`MCP authorization could not be completed`,500,T),I=m(k(async(e,t,n)=>{if(u(n.redirectUrl)||await S(t.kv,M(n)))return A(e,t,n);let{clientId:r,clientName:i}=n.mcpContext,{viewer:s}=n.session,c=x({site:await l(t),user:s.email||s.name||s.sub,clientName:i??void 0,clientIdHost:f(r)?new URL(r).host:void 0,redirectUrl:n.redirectUrl,scopes:o,accessLifetimeHours:a/3600,rememberDays:30,consentToken:await N(n)});return e.set(`realmCacheControlOwned`,!0),new Response(c,{status:200,headers:y})}),F),L=m(k(async(e,t,n)=>{let r=await e.req.formData().catch(()=>null),i=r?.get(`consent`);return typeof i!=`string`||!await P(i,n)?new Response(b(await l(t)),{status:403,headers:y}):r?.get(`decision`)===`allow`?(await C(t.kv,M(n)),A(e,t,n)):j(e,t,n)}),F);export{I as mcpCallback,L as mcpConsent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{MCP_AUTHORIZATION_SERVER_ROUTE as e,MCP_AUTHORIZE_ROUTE as t,MCP_REGISTER_ROUTE as n,MCP_ROUTE as r,MCP_TOKEN_ROUTE as i}from"../../constants.js";import{withPathPrefix as a}from"../../../../../../shared/path-prefix.js";import{isMcpContentProtected as o,isMcpHidden as s,resolveMcpAccess as c}from"../config-gate.js";import{notFoundResponse as l}from"../../../../../../server/plugin-context.js";import{publicOrigin as u}from"../../../../utils/request-origin.js";import{CORS_ANY_ORIGIN as d,SUPPORTED_MCP_GRANT_TYPES as f,SUPPORTED_MCP_SCOPES as p}from"./constants.js";import"../auth.js";function m(e){return!s(e.config)&&o(c(e.config))}function h(t,n){if(!m(n))return l();let i=u(n.request);return t.json({resource:`${i}${a(r)}`,authorization_servers:[i],bearer_methods_supported:[`header`],resource_documentation:`${i}${a(e)}`,scopes_supported:[...p],bearer_token_types_supported:[`Bearer`]},200,{...d})}function g(e,r){if(!m(r))return l();let o=u(r.request);return e.json({issuer:o,authorization_endpoint:`${o}${a(t)}`,token_endpoint:`${o}${a(i)}`,scopes_supported:[...p],registration_endpoint:`${o}${a(n)}`,response_types_supported:[`code`],grant_types_supported:[...f],subject_types_supported:[`public`],id_token_signing_alg_values_supported:[`RS256`],code_challenge_methods_supported:[`S256`],token_endpoint_auth_methods_supported:[`none`],client_id_metadata_document_supported:!0},200,{...d})}export{g as oauthAuthorizationServer,h as oauthProtectedResource};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isMcpContentProtected as e,isMcpHidden as t,resolveMcpAccess as n}from"../config-gate.js";import{notFoundResponse as r}from"../../../../../../server/plugin-context.js";import{CORS_ANY_ORIGIN as i,SUPPORTED_MCP_GRANT_TYPES as a,SUPPORTED_MCP_SCOPES as o}from"./constants.js";import"../auth.js";import{applyMcpRateLimit as s}from"../rate-limit.js";import{writeMcpClient as c}from"./client-registry.js";import{withMcpFailureReporting as l}from"./error-reporting.js";import{ulid as u}from"ulid";function d(e){let t=e.client_name;if(typeof t==`string`&&Buffer.byteLength(t,`utf8`)>256)return{ok:!1,error:`client_name exceeds 256 bytes`};let n=e.redirect_uris;if(n!==void 0&&!Array.isArray(n))return{ok:!1,error:`redirect_uris must be an array`};if(Array.isArray(n)&&n.length>20)return{ok:!1,error:`redirect_uris must hold at most 20 entries`};let r=[];for(let e of Array.isArray(n)?n:[])if(typeof e==`string`&&e!==``){if(Buffer.byteLength(e,`utf8`)>512)return{ok:!1,error:`a redirect_uri exceeds 512 bytes`};r.push(e)}return{ok:!0,clientName:typeof t==`string`&&t?t:`MCP Client`,redirectUris:r}}const f=l(p,e=>e.json({error:`server_error`,error_description:`Unable to register client`},500,{...i}));async function p(l,f){if(t(f.config)||!e(n(f.config)))return r();let p=await s({kv:f.kv,ip:f.request.ip,bucket:`oauth`,logger:f.logger});if(p)return p;let m=await l.req.json().catch(()=>null);if(m!==null&&(typeof m!=`object`||Array.isArray(m)))return l.json({error:`invalid_request`,error_description:`Client metadata must be a JSON object`},400,{...i});let h=d(m??{});if(!h.ok)return l.json({error:`invalid_request`,error_description:h.error},400,{...i});let g=(/* @__PURE__ */ new Date()).toISOString(),_={client_id:`mcp_${u()}`,client_name:h.clientName,redirect_uris:h.redirectUris,grant_types:[...a],response_types:[`code`],scope:o.join(` `),subject_type:`public`,token_endpoint_auth_method:`none`,created_at:g,updated_at:g};return await c(f.kv,_),l.json(_,201,{...i})}export{f as mcpRegister};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isMcpHidden as e}from"../config-gate.js";import{MCP_ACCESS_TOKEN_USE as t}from"../../../../../../server/auth/constants.js";import{getSessionIssuer as n}from"../../../../../../server/auth/middleware.js";import{notFoundResponse as r}from"../../../../../../server/plugin-context.js";import{MCP_ACCESS_TOKEN_TTL_SEC as i,SUPPORTED_MCP_GRANT_TYPES as a,SUPPORTED_MCP_SCOPES as o,TOKEN_RESPONSE_HEADERS as s}from"./constants.js";import{refuseMcpOAuth as c,withMcpFailureReporting as l}from"./error-reporting.js";import{signMcpArtifact as u,verifyMcpArtifact as d,verifyPkce as f}from"./tokens.js";import{redeemAuthorizationCode as p,redeemRefreshToken as m}from"./store.js";async function h(e,n,r,a){e.set(`realmCacheControlOwned`,!0);let l=Math.floor(Date.now()/1e3);if(l>=a.sessionExp)return c(e,n,`invalid_grant`,`Session has expired`);let d=Math.min(i,a.sessionExp-l),[f,p]=await Promise.all([r.mint({...a.claims,tokenUse:t},l+d),u({type:`mcp_refresh_token`,sessionId:a.sessionId,clientId:a.clientId,claims:a.claims,sessionExp:a.sessionExp},r.artifactSecret,a.sessionExp)]);return e.json({access_token:f,token_type:`Bearer`,expires_in:d,refresh_token:p,scope:o.join(` `)},200,{...s})}const g=l(_,e=>e.json({error:`server_error`,error_description:`The server could not complete the request`},500,{...s}));async function _(t,i){if(e(i.config))return r();let o=n(t);if(!o)return r();let s;try{s=await t.req.formData()}catch{return c(t,i,`invalid_request`,`Expected an application/x-www-form-urlencoded body`)}let l=s.get(`grant_type`);return typeof l!=`string`||!a.includes(l)?c(t,i,`invalid_request`,`Invalid grant type`):l===`refresh_token`?y(t,i,o,s):v(t,i,o,s)}async function v(e,t,n,r){let i=r.get(`code`);if(typeof i!=`string`||i===``)return c(e,t,`invalid_request`,`Missing authorization code`);let a;try{a=await d(i,n.artifactSecret,`mcp_auth_code`),e.set(`realmMcpSessionId`,a.sessionId)}catch{return c(e,t,`invalid_grant`,`Invalid authorization code`,`MCP token exchange failed`)}let o=r.get(`redirect_uri`);if(typeof o!=`string`||o!==a.redirectUri)return c(e,t,`invalid_grant`,`redirect_uri mismatch`);let s=r.get(`client_id`);if(typeof s!=`string`||s!==a.clientId)return c(e,t,`invalid_grant`,`Client mismatch`);let l=r.get(`code_verifier`);return typeof l!=`string`||l===``?c(e,t,`invalid_grant`,`code_verifier required`):f(a.codeChallenge,a.codeChallengeMethod,l)?await p(t.kv,i,a.exp)?h(e,t,n,{sessionId:a.sessionId,clientId:a.clientId,claims:a.claims,sessionExp:a.sessionExp}):c(e,t,`invalid_grant`,`Authorization code already used`):c(e,t,`invalid_grant`,`code_verifier mismatch`)}async function y(e,t,n,r){let i=r.get(`refresh_token`);if(typeof i!=`string`||i===``)return c(e,t,`invalid_request`,`refresh_token is required`);let a;try{a=await d(i,n.artifactSecret,`mcp_refresh_token`),e.set(`realmMcpSessionId`,a.sessionId)}catch{return c(e,t,`invalid_grant`,`Invalid refresh token`,`MCP refresh token rejected`)}let o=r.get(`client_id`);return typeof o!=`string`||o!==a.clientId?c(e,t,`invalid_grant`,`Client mismatch`):await m(t.kv,i,a.exp)?h(e,t,n,{sessionId:a.sessionId,clientId:a.clientId,claims:a.claims,sessionExp:a.sessionExp}):c(e,t,`invalid_grant`,`Refresh token already used`,`MCP refresh rejected: the refresh token was already used`)}export{g as mcpToken};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{MCP_ROUTE as e}from"../constants.js";import{withPathPrefix as t}from"../../../../../shared/path-prefix.js";import{ANONYMOUS_VIEWER as n}from"../../../../../shared/types/auth.js";import{isMcpContentProtected as r,isMcpHidden as i,resolveMcpAccess as a}from"./config-gate.js";import{notFoundResponse as o}from"../../../../../server/plugin-context.js";import{publicBaseUrl as s,publicOrigin as c}from"../../../utils/request-origin.js";import{formatError as l}from"./tool-errors.js";import{CORS_ANY_ORIGIN as u,MCP_AUTH_SCHEMES as d}from"./oauth/constants.js";import"./auth.js";import{EXECUTE_DEADLINE_MS as f}from"./codemode/constants.js";import{resolveMcpMode as p}from"./mode.js";import{sendMcpServerCardServed as m}from"./mcp-telemetry.js";import{applyMcpRateLimit as h}from"./rate-limit.js";import{createServedMcpRequestHandler as g}from"./handler.js";import{docsServerInfo as _}from"./server-info.js";import{CLIENT_CAPABILITIES_META_KEY as v,CLIENT_INFO_META_KEY as y,LATEST_PROTOCOL_VERSION as b,PROTOCOL_VERSION_META_KEY as x}from"@modelcontextprotocol/server";const S=`2026-07-28`,C=[`dynamic`],w={capabilities:{},tools:C};async function T(e,t,n){let r=await e(new Request(t,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json, text/event-stream`,"mcp-protocol-version":S,"mcp-method":n},body:JSON.stringify({jsonrpc:`2.0`,id:1,method:n,params:{_meta:{[x]:S,[y]:{name:`server-card`,version:`1.0`},[v]:{}}}})}));if(r.ok)return(await r.json()).result}function E(e,t){e.logger?.warn(`MCP server card lists dynamic tools: ${l(t)}`)}async function D(r,i){let a=await r.withViewer(n),o=await g(a,{isProtected:i},Date.now()+f,{onError:e=>E(r,e)}),s=new URL(t(e),c(r.request)).href,[l,u]=await Promise.all([T(o,s,`server/discover`),i?void 0:T(o,s,`tools/list`)]);if(!l)return;if(i)return{capabilities:l.capabilities,tools:C};if(!u)return;let d=u.tools.map(({name:e,title:t,description:n,inputSchema:r,annotations:i,_meta:a})=>({name:e,title:t,description:n,inputSchema:r,annotations:i,_meta:a}));return{capabilities:l.capabilities,instructions:l.instructions,tools:d.length>0?d:C}}async function O(n,c){if(i(c.config))return o();n.set(`realmCacheControlOwned`,!0);let l=await h({kv:c.kv,ip:c.request.ip,bucket:`card`,headers:u,logger:c.logger});if(l)return l;let f=_(c.config,c.request),g=r(a(c.config)),v=await D(c,g).catch(e=>{E(c,e)}),{capabilities:y,instructions:x,tools:S}=v??w;return m({mode:p(),toolsCount:S===C?0:S.length,authRequired:g},{logger:c.logger}),n.json({$schema:`https://static.modelcontextprotocol.io/schemas/mcp-server-card/v1.json`,version:`1.0`,protocolVersion:b,serverInfo:{...f,title:f.name},description:f.description,documentationUrl:s(c.config,c.request),transport:{type:`streamable-http`,endpoint:t(e)},capabilities:y,authentication:g?{required:!0,schemes:[...d]}:void 0,instructions:x,tools:S},200,{...u,"Cache-Control":v?`public, max-age=3600`:`no-store`})}export{O as mcpServerCard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{PLACEHOLDER_MCP_SERVER_NAMES as e}from"../constants.js";import{realmPlusVersion as t}from"../../../../../shared/realm-plus-version.js";import{publicOrigin as n}from"../../../utils/request-origin.js";import{resolveDocsSiteUrl as r}from"./docs-site-url.js";import{docsSiteSentence as i}from"./codemode/prompts.js";function a(t){let n=t.mcp?.name?.trim();return n&&!e.includes(n)?n:void 0}function o(e,o){let s=r(e.seo?.siteUrl,n(o));return{name:a(e)||new URL(s).host,version:t(),description:i(s),websiteUrl:s}}export{o as docsServerInfo};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{withPathPrefix as e}from"../../../../../shared/path-prefix.js";import{skillMarkdownPath as t}from"../../../utils/skill-paths.js";import{
|
|
1
|
+
import{withPathPrefix as e}from"../../../../../shared/path-prefix.js";import{skillMarkdownPath as t}from"../../../utils/skill-paths.js";import{SKILL_ENTITY_TYPE as n}from"../../../types/skill-entity.js";import{isEntityScopeVisible as r}from"../../../../../shared/rbac/entity-scope.js";import{publicOrigin as i}from"../../../utils/request-origin.js";async function a(a){if(a.config.skills?.hide===!0)return[];let o=await a.entities.list({type:n}),s=i(a.request),c=e=>r(e,a.request.teams,e=>a.logger?.warn(e));return o.flatMap(n=>{let{slug:r,title:i,description:o}=n.metadata??{};return typeof r!=`string`||!c(n)?[]:[{slug:r,title:i??r,description:o??``,uri:`${s}${e(t(r))}`,read:async()=>(await a.entities.load(n.key)).content}]})}export{a as loadSkillResources};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{normalizeRouteSlug as e}from"../../../../../../shared/utils/routes/normalize-route-slug.js";import{normalizeRoutePath as t}from"../../../../../../shared/utils/routes/normalize-route-path.js";import"../../../../../../shared/constants/app-data.js";import{filterRbacAnnotatedValue as n}from"../../../../../../shared/rbac/filter.js";import{stripPathPrefix as r,withPathPrefix as i}from"../../../../../../shared/path-prefix.js";import{FOLDER_SIDEBAR_FILENAME_REGEX as a,SIDEBAR_AGGREGATOR_LOADER_ID as o,SIDEBAR_PLUGIN_ID as s,isTabbedSidebar as c}from"../../../sidebar/index.js";import{readIgnoredRouteSlugs as l}from"../../ignored-routes.js";import{toAppData as u}from"../../../../../../shared/utils/app-data.js";import{posix as d}from"node:path";const f=/* @__PURE__ */ new Set,p=/(?:\/index(?:\.html\.md|\.html|\.md)|\.md|\.html)$/;async function m(e){let[t,n]=await Promise.all([l(e.entities),e.pageMarkdown.listPages()]);return{pages:n.filter(e=>!t.has(e.slug)),isVisible:n=>!t.has(n)&&e.isSlugVisible(n)}}async function h(t){let[{pages:r,isVisible:i},a,o]=await Promise.all([m(t),w(t),T(t)]),s=o.filter(t=>typeof t.link==`string`&&t.external!==!0&&i(e(t.link))),c=new Map(r.map(e=>[e.slug,e.title])),l=/* @__PURE__ */ new Set,u=[],d=g(a.map(({path:e})=>e)),p=a.map(({path:e,value:t},n)=>({path:e,value:t,id:d[n],links:M(k(t))})),h=D(p.flatMap(({links:e})=>e.slice(0,1)));for(let{path:e,value:r,id:a,links:o}of p){for(let e of o)l.add(e);let d=N(k(n(r,t.request.teams)),e=>i(e)&&c.has(e));if(d.length===0)continue;let p=a===`/`,m=p?t.config.seo?.title||`Documentation`:a,g=O(e,d,s,c,p?f:h)||m;u.push({id:a,title:g,nodes:d})}u.sort((e,t)=>Number(t.id===`/`)-Number(e.id===`/`));let _=r.filter(e=>!l.has(e.slug)).map(e=>({type:`page`,label:e.title,link:e.slug,items:[]}));return _.length>0&&u.push({id:`other-pages`,title:`Other pages`,nodes:_}),{sections:u,pages:r}}function g(e){let t=e.map(e=>{let t=d.dirname(e);return t===`.`?`/`:t}),n=/* @__PURE__ */ new Map;for(let e of t)n.set(e,(n.get(e)??0)+1);return e.map((e,r)=>{let i=t[r],o=!a.test(e),s=(n.get(i)??0)>1;return o&&s?e:i})}function _(e){let t=(e,n)=>n.flatMap(n=>{if(n.type!==`section`)return[];let r=v(e,n.label);return[{id:r,title:n.label,link:n.link,nodes:n.items},...t(r,n.items)]});return e.flatMap(e=>[e,...t(e.id,e.nodes)])}function v(e,t){return`${e} > ${t}`}function y(e,t,n){let r=_(e),i=t.trim().toLowerCase(),a=r.find(e=>e.id.toLowerCase()===i);if(a)return a;let o=C(t,n),s=r.find(e=>e.link!==void 0&&e.link===o);if(s)return s;let c=r.filter(e=>e.title.toLowerCase()===i);return c.find(e=>c.every(t=>t===e||t.id.startsWith(`${e.id} > `)))}function b(e){return e.flatMap(e=>[...e.link?[e.link]:[],...b(e.items)])}function x(e){return e.reduce((e,t)=>e+(t.type===`page`?1:x(t.items)),0)}function S(e,t){return`${t}${i(e)}`}function C(e,n){let i;try{i=new URL(e.trim(),n).pathname}catch{return null}let a=r(i)??i;return t(a.replace(p,``))}async function w(e){let t=(await e.entities.list({pluginId:s})).flatMap(e=>{let t=e.metadata?.sourcePath;return e.loaderId===o&&typeof t==`string`?[{path:t,key:e.key}]:[]});return t.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path)),Promise.all(t.map(async({path:t,key:n})=>({path:t,value:await e.entities.load(n)})))}async function T(e){if(!await e.entities.get(`app-data`))return[];let t=u(await e.entities.load(`app-data`)).theme?.navbar?.items??[];return E(n(t,e.request.teams)??[])}function E(e){return e.flatMap(e=>[e,...E(e.items??[])])}function D(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return new Set([...t].filter(([,e])=>e>1).map(([e])=>e))}function O(e,t,n,r,i){let a=n.find(t=>Array.isArray(t.linkedSidebars)&&t.linkedSidebars.includes(e));if(typeof a?.label==`string`&&a.label!==``)return a.label;let o=t.find(e=>!e.link||!i.has(e.link));if(o)return o.link?r.get(o.link):o.label}function k(e){return e===null?[]:c(e)?e.tabs.map(A):e}function A(e){return{label:e.label,link:e.link,items:e.menu??e.items??[]}}function j(e){return e.link!==void 0&&e.external!==!0}function M(t){return t.flatMap(t=>[...j(t)&&t.link?[e(t.link)]:[],...M(t.items??[])])}function N(t,n){return t.flatMap(t=>{let r=j(t)&&t.link?e(t.link):void 0,i=r!==void 0&&n(r)?r:void 0;if(t.items){let e=N(t.items,n);return e.length===0&&!i?[]:[{type:`section`,label:t.label??``,...i?{link:i}:{},items:e}]}return i?[{type:`page`,label:t.label??i,link:i,items:[]}]:[]})}export{b as collectNodeLinks,x as countPages,y as findSection,_ as flattenSections,h as loadPageNavigation,m as loadVisiblePages,C as toPageSlug,S as toPublicUrl,v as toSectionId};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}}},S={schema:i,schemaFor:e=>o(e.mcpMode),async execute(
|
|
1
|
+
import{readIgnoredRouteSlugs as e}from"../../ignored-routes.js";import{publicOrigin as t}from"../../../../utils/request-origin.js";import{MAX_PAGE_LINES as n}from"./pages-constants.js";import{GET_PAGE_SCHEMA as r,GREP_PAGES_SCHEMA as i,LIST_PAGES_SCHEMA as a,grepPagesToolSchema as o,listPagesToolSchema as s}from"./schemas.js";import{recoveryToolNames as c}from"./openapi-document.js";import{collectNodeLinks as l,countPages as u,findSection as d,flattenSections as f,loadPageNavigation as p,loadVisiblePages as m,toPageSlug as h,toPublicUrl as g,toSectionId as _}from"./pages-navigation.js";const v=/^(#{1,3}) +(\S.*)$/,y=/^\s*(```|~~~)/,b={schema:a,schemaFor:e=>s(e.mcpMode),async execute(e,n){let{section:r}=e??{},{sections:i}=await p(n),a=t(n.request);if(!r)return{sections:i.map(e=>({id:e.id,title:e.title,items:w(e.id,e.nodes,a)}))};let o=d(i,r,a);if(!o){let e=f(i).slice(0,50).map(({id:e})=>e);throw Error(`No section "${r}". Pass one of these section ids: ${e.join(`; `)}.`)}return{section:{id:o.id,title:o.title},items:w(o.id,o.nodes,a)}}},x={schema:r,async execute(e,r){let{url:i,startLine:a,lines:o}=e??{};if(typeof i!=`string`||i.trim()===``)throw Error(`The "url" parameter is required: a page URL or path.`);let s=t(r.request),l=h(i,s),u=l===null?null:await C(l,r);if(l===null||u===null)throw Error(`No page you can read is at "${i}": it does not exist, or your access does not include it. Do not describe it from other pages. Call ${c(r.mcpMode).listPages} to see the pages you can read.`);let d=D(u.text),f=Math.max(1,Math.floor(a??1));if(f>d.length)throw Error(`Line ${f} is past the end of "${u.title??l}", which has ${d.length} lines.`);let p=T(o,200,n),m=Math.min(d.length,f+p-1);return{url:g(l,s),title:u.title??l,totalLines:d.length,startLine:f,endLine:m,...m<d.length?{nextStartLine:m+1}:{},outline:O(d),content:d.slice(f-1,m).join(`
|
|
2
|
+
`)}}},S={schema:i,schemaFor:e=>o(e.mcpMode),async execute(e,n){let{query:r,section:i,maxMatches:a}=e??{};if(typeof r!=`string`||r===``)throw Error(`The "query" parameter is required: a text to find.`);let o=t(n.request),s,u;if(i){let{sections:e,pages:t}=await p(n),r=d(e,i,o);if(!r)throw Error(`No section "${i}". Call ${c(n.mcpMode).listPages} to see the sections.`);let a=new Set(l(r.nodes));r.link&&a.add(r.link),s=t.filter(e=>a.has(e.slug)),u=r.title}else s=(await m(n)).pages;let f=T(a,20,100),h=r.toLowerCase(),_=s.length,v=[];for(let e=0;e<s.length;e+=100){let t=s.slice(e,e+100),r=await Promise.all(t.map(async e=>(await n.pageMarkdown.readPage(e.slug))?.text??``));for(let[e,n]of t.entries()){let t=r[e];if(t.toLowerCase().includes(h))for(let[e,r]of D(t).entries()){let t=r.toLowerCase().indexOf(h);if(t!==-1){if(v.length===f)return{matches:v,searchedPages:_,truncated:!0};v.push({url:g(n.slug,o),title:n.title,line:e+1,text:E(r,t)})}}}}return v.length>0?{matches:v,searchedPages:_,truncated:!1}:{matches:v,searchedPages:_,truncated:!1,note:`No page you can read ${u?`in "${u}" contains "${r}". All ${_} pages there were searched.`:`contains "${r}". All ${_} pages were searched. API references are not searched: use ${c(n.mcpMode).listApis} for them.`}`}}};async function C(t,n){return(await e(n.entities)).has(t)?null:n.pageMarkdown.readPage(t)}function w(e,t,n){return t.map(t=>t.type===`page`?{type:`page`,title:t.label,url:g(t.link??``,n)}:{type:`section`,id:_(e,t.label),title:t.label,...t.link?{url:g(t.link,n)}:{},pageCount:u(t.items)})}function T(e,t,n){return Math.min(Math.max(1,Math.floor(e??t)),n)}function E(e,t){let n=Math.max(0,Math.min(t-80,e.length-200));return e.slice(n,n+200).trim()}function D(e){return(e.endsWith(`
|
|
3
3
|
`)?e.slice(0,-1):e).split(`
|
|
4
4
|
`)}function O(e){let t=[],n=!1;return e.forEach((e,r)=>{if(y.test(e)){n=!n;return}let i=n?null:v.exec(e);i&&t.push({line:r+1,level:i[1].length,heading:i[2].trim()})}),t}const k=[b,x,S];export{k as pageTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{OPERATION_METHODS as e}from"../../../../../../shared/constants/openapi-operation-methods.js";import{READ_ONLY_ANNOTATIONS as t,SUBMIT_FEEDBACK_TOOL_NAME as n}from"../../constants.js";import{toolNameForMode as r}from"../codemode/tool-declarations.js";import{GRAPHQL_LIST_SCOPES as i,GRAPHQL_TYPE_KINDS as a}from"./graphql-constants.js";import{MAX_PAGE_LINES as o}from"./pages-constants.js";const s={type:`string`,nullable:!0},c={limit:{type:`number`},total:{type:`number`},page:{type:`number`},totalPages:{type:`number`}},l={codemodeType:`OpenApiServer[]`},u={codemodeType:`OpenApiSecurityRequirement[]`},d={codemodeType:`Record<string, OpenApiSecurityScheme>`},f={codemodeType:`OpenApiDocument`},p={codemodeType:`OpenApiOperation & { path: string; method: string }`},m={codemodeType:`OpenApiComponents`,description:"Components the endpoint references. A `$ref` in `endpoint` resolves against the root of the result."},h={filePath:{type:`string`,description:`API definition file path`},otherMatches:{type:`array`,description:"Other API definitions the lookup also matched. Present only when several matched; pass `filePath` to pick another one",items:{type:`object`,required:[`filePath`],properties:{version:{type:`string`},filePath:{type:`string`}}}}},g="When several definitions match the name, the highest version or the shortest file path is used and the rest are listed in `otherMatches`; tell the user which version or file the answer is based on.";function _(e,n){let r={query:{type:`string`,description:`What to find, as a few words or a short question.`,minLength:1}};return e.length>0&&(r.product={type:`string`,description:`Optional product name to filter search results by specific product.`,enum:[...e,null],nullable:!0}),n.length>0&&(r.locale={type:`string`,description:`Optional locale code to filter search results by documentation language (e.g. 'en', 'ja'). Use the locale matching the language of the user's request. Defaults to the site's default locale.`,enum:[...n,null],nullable:!0}),{name:`search`,title:`Search documentation`,description:`Search the documentation. Returns Markdown text: one section per matching page, with its title and URL as a link.`,summary:`Search the documentation.`,schema:{type:`object`,required:[`query`],additionalProperties:!1,properties:r},annotations:t,outputSchema:{type:`string`}}}const v=_([],[]),y={name:`whoami`,title:`Who am I`,description:`Get information about the currently authenticated user`,summary:`Get the signed-in user.`,schema:{type:`object`,required:[],additionalProperties:!1,properties:{}},annotations:t,outputSchema:{type:`object`,required:[`authenticated`],properties:{authenticated:{type:`boolean`},email:{type:`string`},name:{type:`string`},subject:{type:`string`},clientId:{type:`string`},scope:{type:`string`},issuedAt:{type:`string`},expiresAt:{type:`string`}}}},b={name:n,title:`Submit feedback`,description:`Report a documentation page that is wrong or incomplete. Use it when the user reports a problem with a page on this site, or agrees to report a problem that you found. Do not use it for product bugs or support questions.`,schema:{type:`object`,required:[`path`,`summary`],additionalProperties:!1,properties:{path:{type:`string`,description:`Path or URL of the documentation page the feedback is about (e.g. /guides/auth)`,minLength:1,maxLength:1e3},summary:{type:`string`,description:`One sentence that names what is wrong with the page`,minLength:1,maxLength:500},details:{type:`string`,description:`Expected versus actual behavior, missing steps, or the snippet that failed`,maxLength:4e3,nullable:!0},targetFeature:{type:`string`,description:`The API or feature the page documents`,maxLength:500,nullable:!0}}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},outputSchema:{type:`object`,required:[`status`,`page`,`message`],properties:{status:{type:`string`},page:{type:`string`},message:{type:`string`}}}},x={type:`object`,additionalProperties:!1,required:[],properties:{filter:{type:`string`,description:`Matches part of an API name, or of a description when no name matches`,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}}};function S(e){return{type:`string`,description:`API definition file path, as returned by \`${r(`list-apis`,e)}\``,nullable:!0}}function C(e){return{type:`object`,required:[],additionalProperties:!1,properties:{name:{type:`string`,description:"API name, or a unique part of it. Required when the project documents more than one API, unless `filePath` is given.",minLength:1,nullable:!0},version:{type:`string`,description:`API version. When omitted and several versions exist, the highest one is used`,nullable:!0},filePath:S(e)}}}function w(t){let{name:n,version:r,filePath:i}=C(t).properties;return{type:`object`,required:[`path`,`method`],additionalProperties:!1,properties:{name:n,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:[...e.map(e=>e.toUpperCase()),...e],minLength:1},version:r,filePath:i}}}function T(e){let n={name:{type:`string`},description:{type:`string`},version:{type:`string`},servers:l,filePath:{type:`string`,description:`API definition file path`},ambiguousTitle:{type:`boolean`,description:"true = another API shares this title; a lookup picks the highest version, or the shortest file path at the same version, and lists the rest in `otherMatches`. Pass `filePath` to pick another one"}};return e&&(n.callable={type:`boolean`,description:"true = the documented hosts of this API are reachable via `fetch`; false = documentation only"}),{name:`list-apis`,title:`List APIs`,description:`Lists the APIs documented on this site`,summary:`List the available APIs.`,schema:x,annotations:t,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`,`description`,`version`,`servers`,`filePath`],properties:n}},...c}}}}const E=T(!1),D=T(!0);function O(e){return{name:`get-endpoints`,title:`Get endpoints`,description:`Get all endpoints for a specific API. ${g}`,summary:`Get all endpoints for an API.`,schema:C(e),annotations:t,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoints`],properties:{api:{type:`string`},version:{type:`string`},...h,servers:l,endpoints:{type:`array`,items:{type:`object`,required:[`path`,`method`],properties:{path:{type:`string`},method:{type:`string`},summary:s,description:s,security:u}}}}}}}const k=O(`tools`);function A(e){return{name:`get-endpoint-info`,title:`Get endpoint info`,description:`Get comprehensive information about specific endpoint including parameters, security, and examples. A \`$ref\` in \`endpoint\` points into the \`components\` key at the root of the result: read \`#/components/<section>/<name>\` there. ${g}`,summary:`Get the details of an endpoint.`,schema:w(e),annotations:t,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoint`,`globalSecurity`,`securitySchemes`],properties:{api:{type:`string`},version:{type:`string`},...h,servers:l,endpoint:p,globalSecurity:u,securitySchemes:d,components:m}}}}const j=A(`tools`);function M(e){return{name:`get-security-schemes`,title:`Get security schemes`,description:`Get the security schemes for a specific API. ${g}`,summary:`Get the security schemes for an API.`,schema:C(e),annotations:t,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`securitySchemes`,`security`],properties:{api:{type:`string`},version:{type:`string`},...h,securitySchemes:d,security:u}}}}const N=M(`tools`);function P(e){return{name:`get-full-api-description`,title:`Get full API description`,description:`Get the complete OpenAPI description. ${g}`,summary:`Get the complete OpenAPI description.`,schema:C(e),annotations:t,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`definition`],properties:{api:{type:`string`},version:{type:`string`},...h,definition:f}}}}const F=P(`tools`),I={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}}},L={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. With scope "fields", restricts to the fields of that parent category ("objects", "interfaces", or "inputs" only).`,enum:[...a,null],nullable:!0},scope:{type:`string`,description:'Optional: what each list item is. "members" (default) lists top-level types and operations. "fields" flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions — combine with `filter` to search nested fields anywhere in the schema.',enum:[...i,null],nullable:!0},filter:{type:`string`,description:`Optional: only members whose name or description contains this substring, case-insensitive (e.g. "custom tags")`,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 — 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}}},R={type:`object`,required:[`name`],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,nullable:!0},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}}},z={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1}}},B={name:`list-graphql-apis`,title:`List GraphQL APIs`,description:`Lists available GraphQL schemas with their context and purpose`,summary:`List the available GraphQL schemas.`,schema:I,annotations:t,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`],properties:{name:{type:`string`},description:s}}},...c}}},V={name:`get-graphql-type-list`,title:`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, …) and carries a one-line description; operations also include their return type and argument signature — use it to decide which members to fetch in detail. Narrow the result with `kind` (one category), `filter` (case-insensitive substring of the member name or description, e.g. "book"), or `referencesType` (only members that use a given type, directly or transitively) to explore a domain cheaply instead of pulling the full schema. To search nested fields — not just type names — set scope "fields": it flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions, so `filter` finds things like an input field whose docstring mentions your keyword.',summary:`List the operations and types in a GraphQL schema.`,schema:L,annotations:t,outputSchema:{type:`object`,required:[`name`,`items`,`limit`,`total`,`page`,`totalPages`],properties:{name:{type:`string`},items:{type:`array`,items:{type:`object`,required:[`kind`,`name`],properties:{kind:{type:`string`,enum:[...a]},name:{type:`string`},description:s,type:{type:`string`},args:{type:`string`},directives:{type:`string`}}}},...c}}};function H(e){return{name:`get-graphql-type`,title:`Get GraphQL type`,description:`Get the SDL for a single GraphQL type, operation (query/mutation/subscription field), or directive. Without includeReferencedTypes, the SDL is followed by a one-level manifest of every directly referenced type's field names (e.g. "input ActionOperationInput { addTags, removeTags }"), so you can see what nested types contain before fetching them. Set includeReferencedTypes to instead pull in the full SDL of every type it references transitively — the whole structural subgraph in one call, ideal for complete exploration of an entity (e.g. Book and all the types it touches). That traversal only follows what the target depends on; to go the other direction and find the members that use a type, call ${r(`get-graphql-type-list`,e)} with \`referencesType\`.`,summary:`Get the SDL of one GraphQL type or operation.`,schema:R,annotations:t,outputSchema:{type:`string`}}}const U=H(`tools`);function W(e){return{name:`get-graphql-schema`,title:`Get GraphQL schema`,description:`Get the complete GraphQL schema as SDL — the whole type graph in one call. Returns everything, so it can be very large and token-expensive for big schemas; prefer ${r(`get-graphql-type-list`,e)} (filter/paginate) plus targeted ${r(`get-graphql-type`,e)} calls, and reach for this only for small schemas or when you truly need the full SDL.`,summary:`Get the complete GraphQL schema.`,schema:z,annotations:t,outputSchema:{type:`string`}}}const G=W(`tools`);function K(e){return`Section id from ${r(`list-pages`,e)} (for example "products/ledger > Integration"), a section title, or a section URL`}function q(e){return{type:`object`,required:[`type`,`title`],properties:{type:{type:`string`,enum:[`page`,`section`]},id:{type:`string`,description:`Section id to pass to ${r(`list-pages`,e)} or ${r(`grep-pages`,e)}`},title:{type:`string`},url:{type:`string`},pageCount:{type:`number`,description:`Pages inside the section`}}}}function J(e){let n=q(e);return{name:`list-pages`,title:`List pages`,description:`Lists the docs navigation, one level per call`,summary:`List the docs navigation, one level per call.`,schema:{type:`object`,additionalProperties:!1,required:[],properties:{section:{type:`string`,nullable:!0,description:`${K(e)}. Omit it to list the top level`}}},annotations:t,outputSchema:{type:`object`,properties:{sections:{type:`array`,description:`Top level, when no section is given`,items:{type:`object`,required:[`id`,`title`,`items`],properties:{id:{type:`string`},title:{type:`string`},items:{type:`array`,items:n}}}},section:{type:`object`,properties:{id:{type:`string`},title:{type:`string`}}},items:{type:`array`,items:n}}}}}const Y=J(`tools`),X={name:`get-page`,title:`Get page`,description:`Reads a docs page as Markdown, in line windows`,summary:`Read a docs page as Markdown, in line windows.`,schema:{type:`object`,additionalProperties:!1,required:[`url`],properties:{url:{type:`string`,minLength:1,description:`Page URL or path, for example "/guides/auth"`},startLine:{type:`integer`,nullable:!0,minimum:1,description:`First line to return (default 1)`},lines:{type:`integer`,nullable:!0,minimum:1,maximum:o,description:`Number of lines to return (default 200)`}}},annotations:t,outputSchema:{type:`object`,required:[`url`,`title`,`totalLines`,`startLine`,`endLine`,`outline`,`content`],properties:{url:{type:`string`},title:{type:`string`},totalLines:{type:`number`},startLine:{type:`number`},endLine:{type:`number`},nextStartLine:{type:`number`,description:`Pass as startLine to read on; absent at the end`},outline:{type:`array`,description:`Headings (levels 1-3) with their line numbers`,items:{type:`object`,required:[`line`,`level`,`heading`],properties:{line:{type:`number`},level:{type:`number`},heading:{type:`string`}}}},content:{type:`string`}}}};function Z(e){return{name:`grep-pages`,title:`Grep pages`,description:`Finds the docs lines that contain a text`,summary:`Find the docs lines that contain a text.`,schema:{type:`object`,additionalProperties:!1,required:[`query`],properties:{query:{type:`string`,minLength:1,description:`Text to find, case-insensitive. Not a regular expression`},section:{type:`string`,nullable:!0,description:`${K(e)}. Omit it to search every page`},maxMatches:{type:`integer`,nullable:!0,minimum:1,maximum:100,description:`Maximum matching lines to return (default 20)`}}},annotations:t,outputSchema:{type:`object`,required:[`matches`,`searchedPages`,`truncated`],properties:{matches:{type:`array`,items:{type:`object`,required:[`url`,`title`,`line`,`text`],properties:{url:{type:`string`},title:{type:`string`},line:{type:`number`},text:{type:`string`}}}},searchedPages:{type:`number`,description:`Pages searched: every page you can read, or every page in the section`},truncated:{type:`boolean`,description:`true = more matches exist; narrow the query or the section`},note:{type:`string`,description:`Present when nothing matches: the docs you can read do not contain the text`}}}}}const Q=Z(`tools`);export{k as GET_ENDPOINTS_SCHEMA,j as GET_ENDPOINT_INFO_SCHEMA,F as GET_FULL_API_DESCRIPTION_SCHEMA,G as GET_GRAPHQL_SCHEMA_SCHEMA,V as GET_GRAPHQL_TYPE_LIST_SCHEMA,U as GET_GRAPHQL_TYPE_SCHEMA,X as GET_PAGE_SCHEMA,N as GET_SECURITY_SCHEMES_SCHEMA,Q as GREP_PAGES_SCHEMA,D as LIST_APIS_CALLABLE_SCHEMA,E as LIST_APIS_SCHEMA,B as LIST_GRAPHQL_APIS_SCHEMA,Y as LIST_PAGES_SCHEMA,v as SEARCH_SCHEMA,b as SUBMIT_FEEDBACK_SCHEMA,y as WHOAMI_SCHEMA,A as getEndpointInfoToolSchema,O as getEndpointsToolSchema,P as getFullApiDescriptionToolSchema,W as getGraphqlSchemaToolSchema,H as getGraphqlTypeToolSchema,M as getSecuritySchemesToolSchema,Z as grepPagesToolSchema,J as listPagesToolSchema,_ as searchSchema};
|
|
1
|
+
import{READ_ONLY_ANNOTATIONS as e,SUBMIT_FEEDBACK_TOOL_NAME as t}from"../../constants.js";import{OPERATION_METHODS as n}from"../../../../../../shared/constants/openapi-operation-methods.js";import{toolNameForMode as r}from"../codemode/tool-declarations.js";import{GRAPHQL_LIST_SCOPES as i,GRAPHQL_TYPE_KINDS as a}from"./graphql-constants.js";import{MAX_PAGE_LINES as o}from"./pages-constants.js";const s={type:`string`,nullable:!0},c={limit:{type:`number`},total:{type:`number`},page:{type:`number`},totalPages:{type:`number`}},l={codemodeType:`OpenApiServer[]`},u={codemodeType:`OpenApiSecurityRequirement[]`},d={codemodeType:`Record<string, OpenApiSecurityScheme>`},f={codemodeType:`OpenApiDocument`},p={codemodeType:`OpenApiOperation & { path: string; method: string }`},m={codemodeType:`OpenApiComponents`,description:"Components the endpoint references. A `$ref` in `endpoint` resolves against the root of the result."},h={filePath:{type:`string`,description:`API definition file path`},otherMatches:{type:`array`,description:"Other API definitions the lookup also matched. Present only when several matched; pass `filePath` to pick another one",items:{type:`object`,required:[`filePath`],properties:{version:{type:`string`},filePath:{type:`string`}}}}},g="When several definitions match the name, the highest version or the shortest file path is used and the rest are listed in `otherMatches`; tell the user which version or file the answer is based on.";function _(t,n){let r={query:{type:`string`,description:`What to find, as a few words or a short question.`,minLength:1}};return t.length>0&&(r.product={type:`string`,description:`Optional product name to filter search results by specific product.`,enum:[...t,null],nullable:!0}),n.length>0&&(r.locale={type:`string`,description:`Optional locale code to filter search results by documentation language (e.g. 'en', 'ja'). Use the locale matching the language of the user's request. Defaults to the site's default locale.`,enum:[...n,null],nullable:!0}),{name:`search`,title:`Search documentation`,description:`Search the documentation. Returns Markdown text: one section per matching page, with its title and URL as a link.`,summary:`Search the documentation.`,schema:{type:`object`,required:[`query`],additionalProperties:!1,properties:r},annotations:e,outputSchema:{type:`string`}}}const v=_([],[]),y={name:`whoami`,title:`Who am I`,description:`Get information about the currently authenticated user`,summary:`Get the signed-in user.`,schema:{type:`object`,required:[],additionalProperties:!1,properties:{}},annotations:e,outputSchema:{type:`object`,required:[`authenticated`],properties:{authenticated:{type:`boolean`},email:{type:`string`},name:{type:`string`},subject:{type:`string`},clientId:{type:`string`},scope:{type:`string`},issuedAt:{type:`string`},expiresAt:{type:`string`}}}},b={name:t,title:`Submit feedback`,description:`Report a documentation page that is wrong or incomplete. Use it when the user reports a problem with a page on this site, or agrees to report a problem that you found. Do not use it for product bugs or support questions.`,schema:{type:`object`,required:[`path`,`summary`],additionalProperties:!1,properties:{path:{type:`string`,description:`Path or URL of the documentation page the feedback is about (e.g. /guides/auth)`,minLength:1,maxLength:1e3},summary:{type:`string`,description:`One sentence that names what is wrong with the page`,minLength:1,maxLength:500},details:{type:`string`,description:`Expected versus actual behavior, missing steps, or the snippet that failed`,maxLength:4e3,nullable:!0},targetFeature:{type:`string`,description:`The API or feature the page documents`,maxLength:500,nullable:!0}}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},outputSchema:{type:`object`,required:[`status`,`page`,`message`],properties:{status:{type:`string`},page:{type:`string`},message:{type:`string`}}}},x={type:`object`,additionalProperties:!1,required:[],properties:{filter:{type:`string`,description:`Matches part of an API name, or of a description when no name matches`,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}}};function S(e){return{type:`string`,description:`API definition file path, as returned by \`${r(`list-apis`,e)}\``,nullable:!0}}function C(e){return{type:`object`,required:[],additionalProperties:!1,properties:{name:{type:`string`,description:"API name, or a unique part of it. Required when the project documents more than one API, unless `filePath` is given.",minLength:1,nullable:!0},version:{type:`string`,description:`API version. When omitted and several versions exist, the highest one is used`,nullable:!0},filePath:S(e)}}}function w(e){let{name:t,version:r,filePath:i}=C(e).properties;return{type:`object`,required:[`path`,`method`],additionalProperties:!1,properties:{name:t,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:[...n.map(e=>e.toUpperCase()),...n],minLength:1},version:r,filePath:i}}}function T(t){let n={name:{type:`string`},description:{type:`string`},version:{type:`string`},servers:l,filePath:{type:`string`,description:`API definition file path`},ambiguousTitle:{type:`boolean`,description:"true = another API shares this title; a lookup picks the highest version, or the shortest file path at the same version, and lists the rest in `otherMatches`. Pass `filePath` to pick another one"}};return t&&(n.callable={type:`boolean`,description:"true = the documented hosts of this API are reachable via `fetch`; false = documentation only"}),{name:`list-apis`,title:`List APIs`,description:`Lists the APIs documented on this site`,summary:`List the available APIs.`,schema:x,annotations:e,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`,`description`,`version`,`servers`,`filePath`],properties:n}},...c}}}}const E=T(!1),D=T(!0);function O(t){return{name:`get-endpoints`,title:`Get endpoints`,description:`Get all endpoints for a specific API. ${g}`,summary:`Get all endpoints for an API.`,schema:C(t),annotations:e,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoints`],properties:{api:{type:`string`},version:{type:`string`},...h,servers:l,endpoints:{type:`array`,items:{type:`object`,required:[`path`,`method`],properties:{path:{type:`string`},method:{type:`string`},summary:s,description:s,security:u}}}}}}}const k=O(`tools`);function A(t){return{name:`get-endpoint-info`,title:`Get endpoint info`,description:`Get comprehensive information about specific endpoint including parameters, security, and examples. A \`$ref\` in \`endpoint\` points into the \`components\` key at the root of the result: read \`#/components/<section>/<name>\` there. ${g}`,summary:`Get the details of an endpoint.`,schema:w(t),annotations:e,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoint`,`globalSecurity`,`securitySchemes`],properties:{api:{type:`string`},version:{type:`string`},...h,servers:l,endpoint:p,globalSecurity:u,securitySchemes:d,components:m}}}}const j=A(`tools`);function M(t){return{name:`get-security-schemes`,title:`Get security schemes`,description:`Get the security schemes for a specific API. ${g}`,summary:`Get the security schemes for an API.`,schema:C(t),annotations:e,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`securitySchemes`,`security`],properties:{api:{type:`string`},version:{type:`string`},...h,securitySchemes:d,security:u}}}}const N=M(`tools`);function P(t){return{name:`get-full-api-description`,title:`Get full API description`,description:`Get the complete OpenAPI description. ${g}`,summary:`Get the complete OpenAPI description.`,schema:C(t),annotations:e,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`definition`],properties:{api:{type:`string`},version:{type:`string`},...h,definition:f}}}}const F=P(`tools`),I={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}}},L={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. With scope "fields", restricts to the fields of that parent category ("objects", "interfaces", or "inputs" only).`,enum:[...a,null],nullable:!0},scope:{type:`string`,description:'Optional: what each list item is. "members" (default) lists top-level types and operations. "fields" flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions — combine with `filter` to search nested fields anywhere in the schema.',enum:[...i,null],nullable:!0},filter:{type:`string`,description:`Optional: only members whose name or description contains this substring, case-insensitive (e.g. "custom tags")`,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 — 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}}},R={type:`object`,required:[`name`],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,nullable:!0},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}}},z={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1}}},B={name:`list-graphql-apis`,title:`List GraphQL APIs`,description:`Lists available GraphQL schemas with their context and purpose`,summary:`List the available GraphQL schemas.`,schema:I,annotations:e,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`],properties:{name:{type:`string`},description:s}}},...c}}},V={name:`get-graphql-type-list`,title:`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, …) and carries a one-line description; operations also include their return type and argument signature — use it to decide which members to fetch in detail. Narrow the result with `kind` (one category), `filter` (case-insensitive substring of the member name or description, e.g. "book"), or `referencesType` (only members that use a given type, directly or transitively) to explore a domain cheaply instead of pulling the full schema. To search nested fields — not just type names — set scope "fields": it flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions, so `filter` finds things like an input field whose docstring mentions your keyword.',summary:`List the operations and types in a GraphQL schema.`,schema:L,annotations:e,outputSchema:{type:`object`,required:[`name`,`items`,`limit`,`total`,`page`,`totalPages`],properties:{name:{type:`string`},items:{type:`array`,items:{type:`object`,required:[`kind`,`name`],properties:{kind:{type:`string`,enum:[...a]},name:{type:`string`},description:s,type:{type:`string`},args:{type:`string`},directives:{type:`string`}}}},...c}}};function H(t){return{name:`get-graphql-type`,title:`Get GraphQL type`,description:`Get the SDL for a single GraphQL type, operation (query/mutation/subscription field), or directive. Without includeReferencedTypes, the SDL is followed by a one-level manifest of every directly referenced type's field names (e.g. "input ActionOperationInput { addTags, removeTags }"), so you can see what nested types contain before fetching them. Set includeReferencedTypes to instead pull in the full SDL of every type it references transitively — the whole structural subgraph in one call, ideal for complete exploration of an entity (e.g. Book and all the types it touches). That traversal only follows what the target depends on; to go the other direction and find the members that use a type, call ${r(`get-graphql-type-list`,t)} with \`referencesType\`.`,summary:`Get the SDL of one GraphQL type or operation.`,schema:R,annotations:e,outputSchema:{type:`string`}}}const U=H(`tools`);function W(t){return{name:`get-graphql-schema`,title:`Get GraphQL schema`,description:`Get the complete GraphQL schema as SDL — the whole type graph in one call. Returns everything, so it can be very large and token-expensive for big schemas; prefer ${r(`get-graphql-type-list`,t)} (filter/paginate) plus targeted ${r(`get-graphql-type`,t)} calls, and reach for this only for small schemas or when you truly need the full SDL.`,summary:`Get the complete GraphQL schema.`,schema:z,annotations:e,outputSchema:{type:`string`}}}const G=W(`tools`);function K(e){return`Section id from ${r(`list-pages`,e)} (for example "products/ledger > Integration"), a section title, or a section URL`}function q(e){return{type:`object`,required:[`type`,`title`],properties:{type:{type:`string`,enum:[`page`,`section`]},id:{type:`string`,description:`Section id to pass to ${r(`list-pages`,e)} or ${r(`grep-pages`,e)}`},title:{type:`string`},url:{type:`string`},pageCount:{type:`number`,description:`Pages inside the section`}}}}function J(t){let n=q(t);return{name:`list-pages`,title:`List pages`,description:`Lists the docs navigation, one level per call`,summary:`List the docs navigation, one level per call.`,schema:{type:`object`,additionalProperties:!1,required:[],properties:{section:{type:`string`,nullable:!0,description:`${K(t)}. Omit it to list the top level`}}},annotations:e,outputSchema:{type:`object`,properties:{sections:{type:`array`,description:`Top level, when no section is given`,items:{type:`object`,required:[`id`,`title`,`items`],properties:{id:{type:`string`},title:{type:`string`},items:{type:`array`,items:n}}}},section:{type:`object`,properties:{id:{type:`string`},title:{type:`string`}}},items:{type:`array`,items:n}}}}}const Y=J(`tools`),X={name:`get-page`,title:`Get page`,description:`Reads a docs page as Markdown, in line windows`,summary:`Read a docs page as Markdown, in line windows.`,schema:{type:`object`,additionalProperties:!1,required:[`url`],properties:{url:{type:`string`,minLength:1,description:`Page URL or path, for example "/guides/auth"`},startLine:{type:`integer`,nullable:!0,minimum:1,description:`First line to return (default 1)`},lines:{type:`integer`,nullable:!0,minimum:1,maximum:o,description:`Number of lines to return (default 200)`}}},annotations:e,outputSchema:{type:`object`,required:[`url`,`title`,`totalLines`,`startLine`,`endLine`,`outline`,`content`],properties:{url:{type:`string`},title:{type:`string`},totalLines:{type:`number`},startLine:{type:`number`},endLine:{type:`number`},nextStartLine:{type:`number`,description:`Pass as startLine to read on; absent at the end`},outline:{type:`array`,description:`Headings (levels 1-3) with their line numbers`,items:{type:`object`,required:[`line`,`level`,`heading`],properties:{line:{type:`number`},level:{type:`number`},heading:{type:`string`}}}},content:{type:`string`}}}};function Z(t){return{name:`grep-pages`,title:`Grep pages`,description:`Finds the docs lines that contain a text`,summary:`Find the docs lines that contain a text.`,schema:{type:`object`,additionalProperties:!1,required:[`query`],properties:{query:{type:`string`,minLength:1,description:`Text to find, case-insensitive. Not a regular expression`},section:{type:`string`,nullable:!0,description:`${K(t)}. Omit it to search every page`},maxMatches:{type:`integer`,nullable:!0,minimum:1,maximum:100,description:`Maximum matching lines to return (default 20)`}}},annotations:e,outputSchema:{type:`object`,required:[`matches`,`searchedPages`,`truncated`],properties:{matches:{type:`array`,items:{type:`object`,required:[`url`,`title`,`line`,`text`],properties:{url:{type:`string`},title:{type:`string`},line:{type:`number`},text:{type:`string`}}}},searchedPages:{type:`number`,description:`Pages searched: every page you can read, or every page in the section`},truncated:{type:`boolean`,description:`true = more matches exist; narrow the query or the section`},note:{type:`string`,description:`Present when nothing matches: the docs you can read do not contain the text`}}}}}const Q=Z(`tools`);export{k as GET_ENDPOINTS_SCHEMA,j as GET_ENDPOINT_INFO_SCHEMA,F as GET_FULL_API_DESCRIPTION_SCHEMA,G as GET_GRAPHQL_SCHEMA_SCHEMA,V as GET_GRAPHQL_TYPE_LIST_SCHEMA,U as GET_GRAPHQL_TYPE_SCHEMA,X as GET_PAGE_SCHEMA,N as GET_SECURITY_SCHEMES_SCHEMA,Q as GREP_PAGES_SCHEMA,D as LIST_APIS_CALLABLE_SCHEMA,E as LIST_APIS_SCHEMA,B as LIST_GRAPHQL_APIS_SCHEMA,Y as LIST_PAGES_SCHEMA,v as SEARCH_SCHEMA,b as SUBMIT_FEEDBACK_SCHEMA,y as WHOAMI_SCHEMA,A as getEndpointInfoToolSchema,O as getEndpointsToolSchema,P as getFullApiDescriptionToolSchema,W as getGraphqlSchemaToolSchema,H as getGraphqlTypeToolSchema,M as getSecuritySchemesToolSchema,Z as grepPagesToolSchema,J as listPagesToolSchema,_ as searchSchema};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{normalizeL10nConfig as e}from"../../../../../../shared/utils/l10n.js";import{withPathPrefix as t}from"../../../../../../shared/path-prefix.js";import{readIgnoredRouteSlugs as n}from"../../ignored-routes.js";import{publicOrigin as r}from"../../../../utils/request-origin.js";import{resolveSemanticSearchUpstreamUrl as i}from"../../../../../../shared/ask-ai/upstream.js";import{SemanticSearchError as a,fetchSemanticSearchDocuments as o,filterSemanticSearchDocuments as s}from"../semantic-search.js";import{SEARCH_SCHEMA as c,searchSchema as l}from"./schemas.js";const u=`No results found.`;function d(e,n){let r=e=>{try{return new URL(t(e),n).toString()}catch{return e}};return e.map(e=>`### [${e.title}](${r(e.url)})\n\n${e.content}\n`).join(`
|
|
2
2
|
|
|
3
|
-
`).trim()}const f=[{schema:c,schemaFor:
|
|
3
|
+
`).trim()}const f=[{schema:c,schemaFor:t=>l(Object.values(t.config.products??{}).map(e=>e.name),e(t.config.l10n).locales?.map(e=>e.code)??[]),isAvailable:()=>i()!==``,async execute(t,i){let{query:c,product:l,locale:f}=t??{},p;try{p=await o({query:c,product:l||void 0,locale:f||e(i.config.l10n).defaultLocale})}catch(e){throw e instanceof a?(i.logger?.warn(`MCP search: ${e.message} ${e.detail}`),Error(`The search service failed. Try the call again later.`)):e}let m=await n(i.entities),h=await s(p,async e=>!m.has(e)&&i.isSlugVisible(e)&&await i.hasRoute(e));return h.length===0?u:d(h,r(i.request))||u}}];export{f as searchTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{OPERATION_METHODS as t}from"../../../../../../shared/constants/openapi-operation-methods.js";import{withoutTrailingSlashes as n}from"../tools/openapi-document.js";import{operationHttpMethod as r,pathTemplateKey as i}from"../gateway/route-pattern.js";import{findUnresolvedPlaceholders as a}from"../gateway/fetch/url-placeholders.js";import{SOURCE_REFERENCE as o,UnsupportedWorkflowError as s,failureActionsOf as c,localWorkflowId as l,referencedWorkflowIds as u,successActionsOf as d}from"./workflow-references.js";import{definitionForOperations as f}from"./operations-subset.js";import{stepKey as p}from"./types.js";import{posix as m}from"node:path";import{replaceServerVariables as h}from"@redocly/api-docs/lib/services/code-samples/server-variables.js";import{resolveRef as g}from"@redocly/api-docs/lib/utils/inline-openapi-refs.js";const _=/^\{\$sourceDescriptions\.([\w.-]+)\.url\}#(\/.+)$/,v=/^([\w-]+)\.(.+)$/,y=/^[a-z][a-z0-9+.-]*:/i,b=/^https?:\/\//i,x=/\$components\.(\w+)\.([\w.-]+)/g,S=/\b(?:match|search)\s*\(/,C=[`multipart/form-data`,`application/octet-stream`],w=new Set(t);function T(e){let{filePath:t,document:n}=e,r=E(e),i=new Map((n.workflows??[]).map(e=>[e.workflowId,e])),a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map;for(let t of i.values())try{if(R(t,n.components))throw new s(`it generates test data with $faker`);for(let n of t.steps??[]){let i=A(n,t,r,e);i&&a.set(p(t.workflowId,n.stepId),i)}for(let e of u(t,n.components))V(e,r)}catch(e){if(!(e instanceof s))throw e;o.set(t.workflowId,e.message)}H(i,o),G(i,n.components,o);let c=/* @__PURE__ */ new Map;for(let e of i.values())o.has(e.workflowId)||c.set(e.workflowId,{workflow:e,inputs:K(e,i),methods:q(e,i,n.components,a)});return{filePath:t,title:n.info?.title??m.basename(t),document:n,sources:D(n,r,[...a.values()]),operations:a,runnable:c,unsupported:o}}function E({filePath:e,document:t,apis:n}){let r=/* @__PURE__ */ new Map;for(let i of t.sourceDescriptions??[]){let t=k(e,i.url);if(t){if(i.type===`arazzo`&&t===e)r.set(i.name,{kind:`self`});else if(i.type===`openapi`&&!i[`x-serverUrl`]){let e=n.find(e=>e.relativePath===t);e&&r.set(i.name,{kind:`api`,api:e})}}}return r}function D(e,t,n){let r=/* @__PURE__ */ new Map;for(let{name:i,type:a}of e.sourceDescriptions??[]){let e=t.get(i);if(e?.kind!==`self`){if(e?.kind===`api`){let{definition:t,servers:a}=e.api,o=n.filter(e=>e.sourceName===i);r.set(i,{...f(t,o),servers:[...a]})}else r.set(i,O(a,i))}}return r}function O(e,t){let n={title:t,version:`0`};return e===`arazzo`?{arazzo:`1.0.1`,info:n,sourceDescriptions:[],workflows:[]}:{openapi:`3.1.0`,info:n,paths:{}}}function k(e,t){if(!(y.test(t)||t.startsWith(`/`)))return m.normalize(m.join(m.dirname(e),t))}function A(e,t,n,a){if(L(e,t,a.document.components),c(e,t,a.document.components).some(B))throw new s(`step "${e.stepId}" waits more than 5 seconds before a retry`);if(e.workflowId)return;let o=j(e,n);if(!o)throw new s(`step "${e.stepId}" calls no operation of a callable API`);let{sourceName:l,api:u,path:d,method:f,operation:p}=o,m=r(f),h=i(d),g=u.operations.find(e=>e.method===m&&i(e.path)===h);if(!g?.callable||!g.visible)throw new s(`step "${e.stepId}" calls ${m} ${d}, which agents cannot call`);if(!a.allowedHttpMethods.includes(m))throw new s(`step "${e.stepId}" sends ${m}, which this project does not allow`);let _=e.requestBody?.contentType??F(p,u.definition);if(e.requestBody&&_&&C.some(e=>_.includes(e)))throw new s(`step "${e.stepId}" sends ${_}, which workflows cannot send`);if(!I(u))throw new s(`step "${e.stepId}" calls an API without an absolute server URL`);return{sourceName:l,method:m,operationKey:f,path:d}}function j(e,t){if(e.operationPath)return M(e.operationPath,t);if(!e.operationId)return;let n=o.exec(e.operationId)??v.exec(e.operationId),r=n?[[n[1],t.get(n[1])]]:[...t],i=n?n[2]:e.operationId,a=r.flatMap(([e,t])=>t?.kind===`api`?N(e,t.api,i):[]);return a.length===1?a[0]:void 0}function M(e,t){let n=_.exec(e),r=n&&t.get(n[1]);if(!n||r?.kind!==`api`)return;let i=n[2].slice(1).split(`/`).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`));if(i.length!==3||i[0]!==`paths`)return;let[,a,o]=i,s=P(r.api,a,o);return s&&{sourceName:n[1],api:r.api,path:a,method:o,operation:s}}function N(t,n,r){return Object.entries(n.definition.paths??{}).flatMap(([i,a])=>Object.keys(e(a)?a:{}).flatMap(e=>{let a=P(n,i,e);return a?.operationId===r?[{sourceName:t,api:n,path:i,method:e,operation:a}]:[]}))}function P(t,n,r){if(!w.has(r.toLowerCase()))return;let i=t.definition.paths?.[n],a=e(i)?i[r]:void 0;return e(a)?a:void 0}function F(t,n){let r=t.requestBody,i=r&&`$ref`in r&&r.$ref?g(r.$ref,n):r,a=e(i)?i.content:void 0;return e(a)?Object.keys(a)[0]:void 0}function I(e){let[t]=e.servers;if(!t)return!1;let r=n(h(t));return b.test(r)&&a(r).length===0}function L(e,t,n){let r=[...d(e,t,n),...c(e,t,n)],i=[...e.successCriteria??[],...r.flatMap(e=>e.criteria??[])];for(let{type:t,condition:n}of i){let r=typeof t==`object`?t.type:t;if(r===`xpath`)throw new s(`step "${e.stepId}" checks an XPath criterion, which workflows cannot evaluate`);if(r===`regex`||r===`jsonpath`&&S.test(n))throw new s(`step "${e.stepId}" checks a regex, which workflows cannot evaluate safely`)}}function R(e,t){let n=JSON.stringify(e);return[n,...[...n.matchAll(x)].map(([,e=``,n=``])=>JSON.stringify(z(t,e,n))??``)].some(e=>e.includes(`$faker`))}function z(t,n,r){let i=t,a=e(i)?i[n]:void 0;return e(a)?a[r]:void 0}function B(e){return e.type===`retry`&&(e.retryAfter??0)>5}function V(e,t){let n=o.exec(e);if(n&&t.get(n[1])?.kind!==`self`)throw new s(`it uses workflow "${e}" of another file`)}function H(e,t){for(let n of e.values()){let r=U(n,e);r&&!t.has(n.workflowId)&&t.set(n.workflowId,`it calls itself through workflow "${r}"`)}}function U(e,t){for(let n of W(e)){let r=/* @__PURE__ */ new Set,i=[n];for(;i.length>0;){let a=i.pop();if(a===e.workflowId)return n;if(r.has(a))continue;r.add(a);let o=t.get(a);o&&i.push(...W(o))}}}function W(e){let t=(e.steps??[]).flatMap(e=>e.workflowId?[l(e.workflowId)]:[]);return[...(e.dependsOn??[]).map(l),...t]}function G(e,t,n){let r=!0;for(;r;){r=!1;for(let i of e.values()){if(n.has(i.workflowId))continue;let a=u(i,t).map(l).find(t=>!e.has(t)||n.has(t));a!==void 0&&(n.set(i.workflowId,`it uses workflow "${a}", which cannot run`),r=!0)}}}function K(e,t){let n={},r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=e=>{if(!i.has(e.workflowId)){i.add(e.workflowId);for(let[t,r]of Object.entries(e.inputs?.properties??{}))t in n||(n[t]=r);for(let t of e.inputs?.required??[])r.add(t);for(let n of e.dependsOn??[]){let e=t.get(l(n));e&&a(e)}}};return a(e),r.size>0?{type:`object`,properties:n,required:[...r]}:{type:`object`,properties:n}}function q(e,t,n,r){let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=[e];for(;o.length>0;){let e=o.pop();if(!a.has(e.workflowId)){a.add(e.workflowId);for(let t of e.steps??[]){let n=r.get(p(e.workflowId,t.stepId))?.method;n&&i.add(n)}for(let r of u(e,n)){let e=t.get(l(r));e&&o.push(e)}}}return[...i].sort()}export{T as resolveArazzoFile,k as sourceDescriptionPath};
|
|
1
|
+
import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{OPERATION_METHODS as t}from"../../../../../../shared/constants/openapi-operation-methods.js";import{withoutTrailingSlashes as n}from"../tools/openapi-document.js";import{operationHttpMethod as r,pathTemplateKey as i}from"../gateway/route-pattern.js";import{findUnresolvedPlaceholders as a}from"../gateway/fetch/url-placeholders.js";import{SOURCE_REFERENCE as o,UnsupportedWorkflowError as s,failureActionsOf as c,localWorkflowId as l,referencedWorkflowIds as u,successActionsOf as d}from"./workflow-references.js";import{definitionForOperations as f}from"./operations-subset.js";import{stepKey as p}from"./types.js";import{posix as m}from"node:path";import{replaceServerVariables as h}from"@redocly/api-docs/lib/services/code-samples/server-variables.js";import{resolveRef as g}from"@redocly/api-docs/lib/utils/inline-openapi-refs.js";const _=/^\{\$sourceDescriptions\.([\w.-]+)\.url\}#(\/.+)$/,v=/^([\w-]+)\.(.+)$/,y=/^[a-z][a-z0-9+.-]*:/i,b=/^https?:\/\//i,x=/\$components\.(\w+)\.([\w.-]+)/g,S=/\b(?:match|search)\s*\(/,C=[`multipart/form-data`,`application/octet-stream`],w=new Set(t);function T(e){let{filePath:t,document:n}=e,r=E(e),i=new Map((n.workflows??[]).map(e=>[e.workflowId,e])),a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map;for(let t of i.values())try{if(R(t,n.components))throw new s(`it generates test data with $faker`);for(let n of t.steps??[]){let i=A(n,t,r,e);i&&a.set(p(t.workflowId,n.stepId),i)}for(let e of u(t,n.components))V(e,r)}catch(e){if(!(e instanceof s))throw e;o.set(t.workflowId,e.message)}H(i,o),G(i,n.components,o);let c=/* @__PURE__ */ new Map;for(let e of i.values())o.has(e.workflowId)||c.set(e.workflowId,{workflow:e,inputs:K(e,i),methods:q(e,i,n.components,a)});return{filePath:t,title:n.info?.title??m.basename(t),document:n,sources:D(n,r,[...a.values()]),operations:a,runnable:c,unsupported:o}}function E({filePath:e,document:t,apis:n}){let r=/* @__PURE__ */ new Map;for(let i of t.sourceDescriptions??[]){let t=k(e,i.url);if(t){if(i.type===`arazzo`&&t===e)r.set(i.name,{kind:`self`});else if(i.type===`openapi`&&!i[`x-serverUrl`]){let e=n.find(e=>e.relativePath===t);e&&r.set(i.name,{kind:`api`,api:e})}}}return r}function D(e,t,n){let r=/* @__PURE__ */ new Map;for(let{name:i,type:a}of e.sourceDescriptions??[]){let e=t.get(i);if(e?.kind!==`self`){if(e?.kind===`api`){let{definition:t,servers:a}=e.api,o=n.filter(e=>e.sourceName===i);r.set(i,{...f(t,o),servers:[...a]})}else r.set(i,O(a,i))}}return r}function O(e,t){let n={title:t,version:`0`};return e===`arazzo`?{arazzo:`1.0.1`,info:n,sourceDescriptions:[],workflows:[]}:{openapi:`3.1.0`,info:n,paths:{}}}function k(e,t){if(!(y.test(t)||t.startsWith(`/`)))return m.normalize(m.join(m.dirname(e),t))}function A(e,t,n,a){if(L(e,t,a.document.components),c(e,t,a.document.components).some(B))throw new s(`step "${e.stepId}" waits more than 5 seconds before a retry`);if(e.workflowId)return;if(e[`x-operation`])throw new s(`step "${e.stepId}" calls an x-operation URL, not a documented operation`);let o=j(e,n);if(!o)throw new s(`step "${e.stepId}" calls no operation of a callable API`);let{sourceName:l,api:u,path:d,method:f,operation:p}=o,m=r(f),h=i(d),g=u.operations.find(e=>e.method===m&&i(e.path)===h);if(!g?.callable||!g.visible)throw new s(`step "${e.stepId}" calls ${m} ${d}, which agents cannot call`);if(!a.allowedHttpMethods.includes(m))throw new s(`step "${e.stepId}" sends ${m}, which this project does not allow`);let _=e.requestBody?.contentType??F(p,u.definition);if(e.requestBody&&_&&C.some(e=>_.includes(e)))throw new s(`step "${e.stepId}" sends ${_}, which workflows cannot send`);if(!I(u))throw new s(`step "${e.stepId}" calls an API without an absolute server URL`);return{sourceName:l,method:m,operationKey:f,path:d}}function j(e,t){if(e.operationPath)return M(e.operationPath,t);if(!e.operationId)return;let n=o.exec(e.operationId)??v.exec(e.operationId),r=n?[[n[1],t.get(n[1])]]:[...t],i=n?n[2]:e.operationId,a=r.flatMap(([e,t])=>t?.kind===`api`?N(e,t.api,i):[]);return a.length===1?a[0]:void 0}function M(e,t){let n=_.exec(e),r=n&&t.get(n[1]);if(!n||r?.kind!==`api`)return;let i=n[2].slice(1).split(`/`).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`));if(i.length!==3||i[0]!==`paths`)return;let[,a,o]=i,s=P(r.api,a,o);return s&&{sourceName:n[1],api:r.api,path:a,method:o,operation:s}}function N(t,n,r){return Object.entries(n.definition.paths??{}).flatMap(([i,a])=>Object.keys(e(a)?a:{}).flatMap(e=>{let a=P(n,i,e);return a?.operationId===r?[{sourceName:t,api:n,path:i,method:e,operation:a}]:[]}))}function P(t,n,r){if(!w.has(r.toLowerCase()))return;let i=t.definition.paths?.[n],a=e(i)?i[r]:void 0;return e(a)?a:void 0}function F(t,n){let r=t.requestBody,i=r&&`$ref`in r&&r.$ref?g(r.$ref,n):r,a=e(i)?i.content:void 0;return e(a)?Object.keys(a)[0]:void 0}function I(e){let[t]=e.servers;if(!t)return!1;let r=n(h(t));return b.test(r)&&a(r).length===0}function L(e,t,n){let r=[...d(e,t,n),...c(e,t,n)],i=[...e.successCriteria??[],...r.flatMap(e=>e.criteria??[])];for(let{type:t,condition:n}of i){let r=typeof t==`object`?t.type:t;if(r===`xpath`)throw new s(`step "${e.stepId}" checks an XPath criterion, which workflows cannot evaluate`);if(r===`regex`||r===`jsonpath`&&S.test(n))throw new s(`step "${e.stepId}" checks a regex, which workflows cannot evaluate safely`)}}function R(e,t){let n=JSON.stringify(e);return[n,...[...n.matchAll(x)].map(([,e=``,n=``])=>JSON.stringify(z(t,e,n))??``)].some(e=>e.includes(`$faker`))}function z(t,n,r){let i=t,a=e(i)?i[n]:void 0;return e(a)?a[r]:void 0}function B(e){return e.type===`retry`&&(e.retryAfter??0)>5}function V(e,t){let n=o.exec(e);if(n&&t.get(n[1])?.kind!==`self`)throw new s(`it uses workflow "${e}" of another file`)}function H(e,t){for(let n of e.values()){let r=U(n,e);r&&!t.has(n.workflowId)&&t.set(n.workflowId,`it calls itself through workflow "${r}"`)}}function U(e,t){for(let n of W(e)){let r=/* @__PURE__ */ new Set,i=[n];for(;i.length>0;){let a=i.pop();if(a===e.workflowId)return n;if(r.has(a))continue;r.add(a);let o=t.get(a);o&&i.push(...W(o))}}}function W(e){let t=(e.steps??[]).flatMap(e=>e.workflowId?[l(e.workflowId)]:[]);return[...(e.dependsOn??[]).map(l),...t]}function G(e,t,n){let r=!0;for(;r;){r=!1;for(let i of e.values()){if(n.has(i.workflowId))continue;let a=u(i,t).map(l).find(t=>!e.has(t)||n.has(t));a!==void 0&&(n.set(i.workflowId,`it uses workflow "${a}", which cannot run`),r=!0)}}}function K(e,t){let n={},r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=e=>{if(!i.has(e.workflowId)){i.add(e.workflowId);for(let[t,r]of Object.entries(e.inputs?.properties??{}))t in n||(n[t]=r);for(let t of e.inputs?.required??[])r.add(t);for(let n of e.dependsOn??[]){let e=t.get(l(n));e&&a(e)}}};return a(e),r.size>0?{type:`object`,properties:n,required:[...r]}:{type:`object`,properties:n}}function q(e,t,n,r){let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=[e];for(;o.length>0;){let e=o.pop();if(!a.has(e.workflowId)){a.add(e.workflowId);for(let t of e.steps??[]){let n=r.get(p(e.workflowId,t.stepId))?.method;n&&i.add(n)}for(let r of u(e,n)){let e=t.get(l(r));e&&o.push(e)}}}return[...i].sort()}export{T as resolveArazzoFile,k as sourceDescriptionPath};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{GET_WORKFLOW_TOOL_NAME as e,LIST_WORKFLOWS_TOOL_NAME as t,READ_ONLY_ANNOTATIONS as n,RUN_WORKFLOW_TOOL_NAME as
|
|
1
|
+
import{GET_WORKFLOW_TOOL_NAME as e,LIST_WORKFLOWS_TOOL_NAME as t,READ_ONLY_ANNOTATIONS as n,REQUIRES_USER_INTERACTION_META as r,RUN_WORKFLOW_TOOL_NAME as i,RUN_WORKFLOW_WRITE_TOOL_NAME as a,WRITE_TOOL_ANNOTATIONS as o}from"../../constants.js";import{SESSION_HANDLE_PROPERTY as s}from"../gateway/tools.js";const c={type:`string`,nullable:!0},l={workflowId:{type:`string`,description:"The `workflowId` from `listWorkflows`."},filePath:{...c,description:"The `filePath` from `listWorkflows`. Needed only when several files declare the workflow ID."}},u={workflowId:{type:`string`},filePath:{type:`string`,description:`The Arazzo description that declares the workflow.`},summary:c,description:c,writes:{type:`boolean`,description:`True when a step can change data. Such a workflow does not run inside \`execute\`; it runs through the \`${a}\` tool.`},inputs:{type:`object`,description:"The JSON Schema of the `inputs` that `runWorkflow` takes."}},d={name:t,title:`List API workflows`,description:'Lists the workflows that `runWorkflow` can run. Each workflow is a ready-made multi-step API action that the docs authors wrote, such as "log in, then place an order". When a workflow matches the task, run it instead of chaining `fetch` calls: it already knows the order of the calls and how data passes between them.',summary:`List the multi-step API workflows you can run.`,annotations:n,schema:{type:`object`,required:[],additionalProperties:!1,properties:{filter:{...c,description:`Case-insensitive text to find in the workflow ID, summary, or description.`}}},outputSchema:{type:`object`,required:[`items`],properties:{items:{type:`array`,items:{type:`object`,required:[`workflowId`,`filePath`,`writes`,`inputs`],properties:u}}}}},f={name:e,title:`Get an API workflow`,description:"Gets one workflow from `listWorkflows`: its inputs, outputs, and the request or sub-workflow of each step. Use it to explain a workflow to the user before you run it. For a workflow that cannot run, the error says why.",summary:`Get the inputs, steps, and outputs of one workflow.`,annotations:n,schema:{type:`object`,required:[`workflowId`],additionalProperties:!1,properties:l},outputSchema:{type:`object`,required:[`workflowId`,`filePath`,`writes`,`inputs`,`outputs`,`steps`],properties:{...u,outputs:{type:`array`,items:{type:`string`},description:"The names of the `outputs` a successful run returns."},steps:{type:`array`,items:{type:`object`,required:[`stepId`],properties:{stepId:{type:`string`},description:c,request:{...c,description:"The method and the path, such as `POST /orders`."},workflowId:{...c,description:`The sub-workflow the step runs.`}}}}}}},p={...l,inputs:{type:`object`,nullable:!0,description:"The workflow inputs; their JSON Schema is `inputs` in `listWorkflows`."}},m={type:`object`,required:[`workflowId`,`status`,`steps`],properties:{workflowId:{type:`string`},status:{type:`string`,enum:[`succeeded`,`failed`]},outputs:{type:`object`,nullable:!0},steps:{type:`array`,items:{type:`object`,required:[`stepId`,`ms`],properties:{stepId:{type:`string`},workflowId:{...c,description:`Set for a step of a sub-workflow or a dependency.`},request:c,status:{type:`number`,nullable:!0},ms:{type:`number`},error:{...c,description:`Why the request did not reach the API.`}}}},failure:{type:`object`,nullable:!0,required:[`workflowId`,`reason`],properties:{workflowId:{type:`string`},stepId:c,reason:{type:`string`},response:{type:`object`,nullable:!0,required:[`status`,`body`],properties:{status:{type:`number`},body:{type:`string`}}}}}}},h={name:i,title:`Run an API workflow`,description:`Runs one workflow from \`listWorkflows\` that does not write (\`writes: false\`) with its \`inputs\`, and returns its \`outputs\` and one \`steps\` entry per request. Each request goes through \`fetch\`: the same documented operations, hosts, stored credentials, and limits. A run that fails returns \`status: "failed"\` with the failed step and its response. Run a workflow with \`writes: true\` with the \`${a}\` tool.`,summary:`Run a read-only multi-step API workflow with its inputs.`,annotations:{...n,openWorldHint:!0},schema:{type:`object`,required:[`workflowId`],additionalProperties:!1,properties:p},outputSchema:m},g={name:a,title:`Run a workflow that writes`,description:["Runs one workflow from `listWorkflows` that has at least one write step (`writes: true`), with its `inputs`.","Read the workflow with `getWorkflow` in `execute` first.",`Run it only when the user asked for the action. A question about what is possible is not a request to run it.`,"It returns the `outputs` and one `steps` entry per request. Do not run it again after a failure without asking the user."].join(`
|
|
2
|
+
`),annotations:o,_meta:r,schema:{type:`object`,required:[`workflowId`],additionalProperties:!1,properties:{...p,sessionHandle:s}},outputSchema:m};export{f as GET_WORKFLOW_SCHEMA,d as LIST_WORKFLOWS_SCHEMA,h as RUN_WORKFLOW_SCHEMA,g as RUN_WORKFLOW_WRITE_SCHEMA};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{RUN_WORKFLOW_WRITE_TOOL_NAME as e}from"../../constants.js";import{isToolDisabledByCaller as t}from"../disabled-tools.js";import{formatCandidates as n}from"../tools/openapi-document.js";import{getAllowedHttpMethods as r,isSafeHttpMethod as i}from"../gateway/allowed-http-methods.js";import{runExecuteWithGateway as a}from"../gateway/index.js";import{stepKey as o}from"./types.js";import{hasRunnableWorkflows as s,loadWorkflowCatalog as c}from"./catalog.js";import{runWorkflow as l}from"./run-workflow.js";import{GET_WORKFLOW_SCHEMA as u,LIST_WORKFLOWS_SCHEMA as d,RUN_WORKFLOW_SCHEMA as f,RUN_WORKFLOW_WRITE_SCHEMA as p}from"./schemas.js";import{Ajv as m,AjvJsonSchemaValidator as h}from"@modelcontextprotocol/server/validators/ajv";const g=new h(new m({allErrors:!0,strict:!1,validateFormats:!1}));function _({methods:e}){return e.some(e=>!i(e))}function v({file:e,runnable:t}){let{workflowId:n,summary:r,description:i}=t.workflow;return{workflowId:n,filePath:e.filePath,summary:r,description:i,writes:_(t),inputs:t.inputs}}function y(e){return e.flatMap(e=>Array.from(e.runnable.values(),t=>({file:e,runnable:t})))}function b({workflowId:e,filePath:t},r){let i=t?r.filter(e=>e.filePath===t):r,a=i.flatMap(t=>{let n=t.runnable.get(e);return n?[{file:t,runnable:n}]:[]});if(a.length===1)return a[0];if(a.length>1)throw Error(`Workflow "${e}" is in several files: ${n(a.map(({file:e})=>`"${e.filePath}"`))}. Pass \`filePath\`.`);let o=i.find(t=>t.unsupported.has(e));if(o)throw Error(`Workflow "${e}" in ${o.filePath} cannot run: ${o.unsupported.get(e)}.`);let s=y(r).map(({runnable:e})=>`"${e.workflow.workflowId}"`);throw Error(`No workflow "${e}"`+(t?` in ${t}`:``)+(s.length>0?`. Available workflows: ${n(s)}.`:`.`))}const x={schema:d,isAvailable:s,async execute(e,t){let n=(e??{}).filter?.trim().toLowerCase(),r=y(await c(t)).map(v);return{items:n?r.filter(e=>[e.workflowId,e.summary,e.description].some(e=>e?.toLowerCase().includes(n))):r}}},S={schema:u,isAvailable:s,async execute(e,t){let n=b(e,await c(t)),{workflow:r}=n.runnable;return{...v(n),outputs:Object.keys(r.outputs??{}),steps:(r.steps??[]).map(e=>{let t=n.file.operations.get(o(r.workflowId,e.stepId));return{stepId:e.stepId,description:e.description,request:t&&`${t.method} ${t.path}`,workflowId:e.workflowId}})}}};async function C(e,t){let n=b(e,await c(t)),r=e.inputs??{},i=g.getValidator(n.runnable.inputs)(r);if(!i.valid)throw Error(`The inputs of workflow "${e.workflowId}" are not valid: ${i.errorMessage}`);return{...n,inputs:r}}const w={schema:f,isAvailable:s,async execute(n,r,i){let a=n,o=await C(a,r);if(_(o.runnable)){let n=t(`run-workflow_write`,r.metadata)?`Explain the workflow to the user instead of running it.`:`Use the \`${e}\` tool.`;throw Error(`Workflow "${a.workflowId}" was not run. This workflow writes. ${n}`)}let s=i?.gatewayFetch;if(!s)throw Error("`runWorkflow` runs only inside an `execute` script.");return l({file:o.file,workflowId:a.workflowId,inputs:o.inputs,fetch:s,deadline:r.executeDeadline})}},T={schema:p,isAvailable:async e=>y(await c(e)).some(({runnable:e})=>_(e)),async execute(t,n,i){let o=t,s=i?.serverContext;if(!s)throw Error(`\`${e}\` runs only as a top-level tool call.`);let c=await C(o,n);if(!_(c.runnable))throw Error(`Workflow "${o.workflowId}" does not write. Run it with \`site.runWorkflow\` inside \`execute\`.`);return a({ctx:n,sessionHandle:o.sessionHandle,serverContext:s,allowedHttpMethods:r(n.config.mcp),run:async e=>{let t=await l({file:c.file,workflowId:o.workflowId,inputs:c.inputs,fetch:e,deadline:n.executeDeadline});return{content:[{type:`text`,text:JSON.stringify(t)}],structuredContent:t,isError:t.status===`failed`}}})}};function E(){return[x,S,w]}export{T as runWorkflowWriteTool,E as workflowTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{MCP_ROUTE as e,MCP_SETUP_TEMPLATE_ID as t,PUBLIC_MCP_ROUTE as n}from"./constants.js";import{isMcpHidden as r,isPublicEndpointServedFromConfig as i}from"./server/config-gate.js";const a={title:`Connect to the MCP server`,rbac:{"*":`read`},excludeFromSearch:!0};function o(o){return r(o)?[]:[{routeId:`mcp-setup`,slug:e,template:t,metadata:a},...i(o)?[{routeId:`mcp-public-setup`,slug:n,template:t,metadata:a}]:[]]}export{o as buildMcpSetupPageRoutes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isPlanFeatureGranted as e}from"../../../../../shared/plan-gates.js";import{
|
|
1
|
+
import{isPlanFeatureGranted as e}from"../../../../../shared/plan-gates.js";import{isObject as t}from"../../../../../shared/utils/is-object.js";import{filePathToRouteSlug as n}from"../../../../../shared/utils/routes/file-path-to-route-slug.js";import"../../../../../shared/constants/api-spec-kinds.js";import{mockPathPrefix as r}from"../../../types/api-entity.js";import{parseContentVersion as i}from"../../../utils/version-path.js";import{toPublicVersionedSlug as a}from"../../../../../shared/constants/versions.js";import{stripPathPrefix as o}from"../../../../../shared/path-prefix.js";import{notFoundResponse as s}from"../../../../../server/plugin-context.js";import{MOCK_SERVER_HANDLER_ID as c,withMockServerEvent as l}from"../../../../../server/telemetry/mock-server-events.js";const u={"Cache-Control":`no-store`},d=/* @__PURE__ */ new Map;function f(e,n){let r=n.metadata?.mockServer;return{...e,...t(r)?r:{}}}function p(e,t){let{specType:n,routeSlug:i}=e.metadata??{};return n!==`openapi`||typeof i!=`string`||f(t,e).off===!0?null:r(i)}function m(e,t,n=void 0){let r=null,i=-1;for(let a of e){let e=p(a,n);e===null||e.length<=i||h(e,t)&&(r={api:a,path:t.slice(e.length)||`/`},i=e.length)}return r}function h(e,t){return t===e||t.startsWith(`${e}/`)}async function g(e,t,n){let o=null,s=-1;for(let c of t){let t=p(c,e.config.mockServer),l=i(String(c.metadata?.sourcePath));if(t===null||l===null)continue;let u=String(c.metadata?.routeSlug),d=r(a(u,l.versionGroup,l.version,!0));d===t||d.length<=s||!h(d,n)||(await e.versions.counterparts(u))?.group.defaultVersion===l.version&&(o={api:c,path:n.slice(d.length)||`/`},s=d.length)}return o}function _(e,t,{createMockServer:n}){let r=d.get(t.key);if(r&&r.dataHash===t.dataHash)return r.handler;let{strictExamples:i,errorIfForcedExampleNotFound:a}=f(e.config.mockServer,t),o=e.entities.load(t.key).then(e=>n(structuredClone(e),{strictExamples:i,errorIfForcedExampleNotFound:a}));return d.set(t.key,{dataHash:t.dataHash,handler:o}),o.catch(()=>d.delete(t.key)),o}async function v(e,t){let o=await e.entities.list({type:`api`}),s=o.filter(({metadata:e})=>{if(e?.specType!==`openapi`||e.routeSlug!==void 0)return!1;let o=String(e.sourcePath),s=n(o),c=i(o);return(c?[s,a(s,c.versionGroup,c.version,!0)]:[s]).some(e=>h(r(e),t))});return s.length===0?o:(await Promise.all(s.map(t=>e.entities.load(t.key))),e.entities.list({type:`api`}))}function y(e,t){let n=(e.req.header(`x-http-method-override`)??e.req.method).toUpperCase(),{search:r}=new URL(e.req.url),i;return{path:t,method:n,query:r===``?void 0:r,headers:Object.fromEntries(e.req.raw.headers),getBody:()=>i??=e.req.arrayBuffer().then(e=>e.byteLength>0?Buffer.from(e):void 0)}}function b(e){return(o(new URL(e.req.url).pathname)??``).slice(6)||`/`}async function x(t,n){if(!e(n.config,`mockServer`))return s();let r=b(t),i=await v(n,r),a=m(i,r,n.config.mockServer)??await g(n,i,r);if(!a||!n.isSlugVisible(String(a.api.metadata?.routeSlug)))return s();let o;try{o=await import(`@redocly/mock-server`)}catch{return new Response(`Mock server is not available on this host`,{status:501})}return l({handler:c,request:t.req.raw,logger:n.logger},async()=>{let e=await(await _(n,a.api,o))(y(t,a.path));return new Response(e.body?new Uint8Array(e.body):null,{status:e.statusCode,headers:{...e.headers,...u}})})}export{m as matchMockApi,x as mock,y as toMockRequest};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t,createInlineEntity as n}from"../../../loaders/define.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import{SEARCH_GROUP_FACET_FIELD as i}from"../../../../shared/search/facets.js";import{configuredFacetFields as a,extractFacetsFromFrontmatter as o,invalidFacetValueProblems as s,searchCategoryOf as c}from"../../../search/facet-values.js";import{isPlanFeatureGranted as l}from"../../../../shared/plan-gates.js";import{
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t,createInlineEntity as n}from"../../../loaders/define.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import{SEARCH_GROUP_FACET_FIELD as i}from"../../../../shared/search/facets.js";import{configuredFacetFields as a,extractFacetsFromFrontmatter as o,invalidFacetValueProblems as s,searchCategoryOf as c}from"../../../search/facet-values.js";import{isPlanFeatureGranted as l}from"../../../../shared/plan-gates.js";import{SOURCE_TEMPLATE_PREFIX as u}from"../../../../shared/constants/template-ids.js";import{isObject as d}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as f}from"../../../../shared/utils/routes/normalize-route-slug.js";import{notInPlanProblem as p}from"../../../plan-gates.js";import{filePathToRouteSlug as m}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{isInternalPagePath as h}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as g}from"../../utils/explicit-slugs.js";import{curationKeywordsOf as _}from"../../../search/keywords.js";import{readPageFrontmatter as v}from"./frontmatter.js";const y=[`.page.tsx`,`.page.ts`],b=`internal.react-page`,x=`search`,S=t(r(b,`search`),async e=>({value:e.args}),{searchable(e,t){if(t.route===void 0||t.route.metadata.excludeFromSearch===!0)return{docs:[]};let{category:n,isInvalid:r}=c(t.route.metadata),{facets:l,invalidFields:u}=o(t.route.metadata,a(t.config)),d={docKey:`page`,routeSlug:t.route.slug,title:e.title,text:e.text,groupKey:n??`Documentation`,facets:l};return e.keywords!==void 0&&(d.keywords=e.keywords),{docs:[d],problems:s([...u,...r?[i]:[]],t.route.originFilePath)}}});function C(e){if(e.excludeFromSearch===!0)return;let t=d(e.search)?e.search:{},n=d(e.seo)?e.seo:{},r=e=>typeof e==`string`?e.trim():``,i=r(t.title)||r(n.title)||r(e.title),a=r(t.description)||r(n.description)||r(e.description);if(i===``&&a===``)return;let o={title:i,text:[a,...Array.isArray(t.keywords)?t.keywords.filter(e=>typeof e==`string`):[]].filter(e=>e!==``).join(` `)},s=_(t.keywords);return s!==void 0&&(o.keywords=s),o}const w=t(r(b,`seo`),async e=>{let{result:t,entityDeps:n,assetUsages:r}=await e.markdown.resolveImageReference(e.args.image,e.file.path);return t.kind===`assetRef`?{value:{image:t.url},entityDeps:n,assetUsages:r}:{value:{image:e.args.image},entityDeps:n}}),T=e({id:b,version:`1.13.0`,loaders:[w,S],content:{filter:{extensions:y},async extractFile(e,t){if(h(e.path))return{routes:[]};if(!l(t.config,`reactPages`))return{routes:[],problems:[p(`React pages`)]};let{frontmatter:r,error:i}=v(await t.io.readFile(e.path));i!==void 0&&t.logger.warn(`Ignoring the frontmatter export of a page component`,{path:e.path,error:i});let a=g(r?.slug),o=d(r?.seo)&&typeof r.seo.image==`string`?r.seo.image:void 0,s=r===null?void 0:C(r),c={};o!==void 0&&(c.seo=w.withArgs({filePath:e.path,image:o})),s!==void 0&&(c[x]=S.withArgs(s,{stableKey:`react-page:search:${e.path}`}));let _=Object.keys(c).length===0?void 0:c,y=`${u}${e.path}`,b=d(r?.seo)?r.seo.title:void 0,T=typeof b==`string`&&b.trim()!==``?n({label:b}):void 0;return{routes:a.length>0?a.map(e=>({routeId:`page`,slug:f(e),template:y,metadata:r??void 0,deps:_,sidebarSubtree:T})):[{routeId:`page`,slugHint:m(e.path,E(e.path)),template:y,metadata:r??void 0,deps:_,sidebarSubtree:T}]}}}});function E(e){return e.toLowerCase().endsWith(`.page.ts`)?`.page.ts`:`.page.tsx`}export{x as REACT_PAGE_SEARCH_LOADER_KEY,T as reactPageContentPlugin};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{CATALOG_CLASSIC_DEP_KEY as e}from"../../catalog-classic/client/contract.js";import"./contract.js";import{AppPageWrapper as t,CardRow as n,CardValue as r,CardsWrapper as i,ContentWithDotWrap as a,LevelComplianceCardTitle as o,LinkButton as s,ModeSwitcherTab as c,ModeSwitcherTabs as l,PageDescription as u,ProblemsByStatusCardBody as d,ScoreCardStatusCardBody as f,ScorecardCard as p,ScorecardCardTitle as m,TableWrap as h}from"./styles.js";import{ApiLevel as g,Gauge as _,GaugeValue as v,InstanceStatus as y,LevelStatus as b,StatusByLevelWidget as x,StatusDistribution as S}from"./ScorecardWidgets.js";import{useApiScorecard as C,useScorecard as w}from"./use-scorecard.js";import{ApiListView as T,ApiProblemsView as E,RuleApisView as D,RulesView as ee,TeamsView as O}from"./ScorecardViews.js";import*as k from"react";import A from"styled-components";import{Button as j}from"@redocly/theme/components/Button/Button";import{useLocation as M}from"react-router";import{breakpoints as N,getScorecardColorVariable as P}from"@redocly/theme/core/utils";import{Fragment as F,jsx as I,jsxs as L}from"react/jsx-runtime";import{useModalScrollLock as R}from"@redocly/theme/core/hooks";import{
|
|
1
|
+
import{CATALOG_CLASSIC_DEP_KEY as e}from"../../catalog-classic/client/contract.js";import"./contract.js";import{AppPageWrapper as t,CardRow as n,CardValue as r,CardsWrapper as i,ContentWithDotWrap as a,LevelComplianceCardTitle as o,LinkButton as s,ModeSwitcherTab as c,ModeSwitcherTabs as l,PageDescription as u,ProblemsByStatusCardBody as d,ScoreCardStatusCardBody as f,ScorecardCard as p,ScorecardCardTitle as m,TableWrap as h}from"./styles.js";import{ApiLevel as g,Gauge as _,GaugeValue as v,InstanceStatus as y,LevelStatus as b,StatusByLevelWidget as x,StatusDistribution as S}from"./ScorecardWidgets.js";import{useApiScorecard as C,useScorecard as w}from"./use-scorecard.js";import{ApiListView as T,ApiProblemsView as E,RuleApisView as D,RulesView as ee,TeamsView as O}from"./ScorecardViews.js";import*as k from"react";import A from"styled-components";import{Button as j}from"@redocly/theme/components/Button/Button";import{useLocation as M}from"react-router";import{breakpoints as N,getScorecardColorVariable as P}from"@redocly/theme/core/utils";import{Fragment as F,jsx as I,jsxs as L}from"react/jsx-runtime";import{useModalScrollLock as R}from"@redocly/theme/core/hooks";import{Link as z}from"@redocly/theme/components/Link/Link";import{ArrowLeftIcon as B}from"@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon";import{Sidebar as V}from"@redocly/theme/components/Sidebar/Sidebar";import{useLoaderData as H}from"virtual:realm-runtime";import{CatalogDescription as U,CatalogPageContent as W,CatalogPageDescriptionWrapper as G,CatalogPageWrapper as K,CatalogTitle as q}from"@redocly/theme/components/CatalogClassic/CatalogClassic";import{FilterContent as J}from"@redocly/theme/components/Filter/FilterContent";import{FilterPopover as Y}from"@redocly/theme/components/Filter/FilterPopover";import{HighlightContext as X}from"@redocly/theme/components/CatalogClassic/CatalogClassicHighlight";import{CatalogClassicActions as Z}from"@redocly/theme/components/CatalogClassic/CatalogClassicActions";function Q({page:t}){let n=H(e),{pathname:r}=M();if(!n)return null;let i=t.slug.replace(/\/$/,``),[a,o]=r.slice(i.length).split(`/`).filter(Boolean),s=o===void 0?void 0:decodeURIComponent(o);return/* @__PURE__ */ I(te,{base:i,data:n,view:a===`apis`&&s!==void 0?{kind:`api`,link:`/${s}`}:a===`rules`&&s!==void 0?{kind:`rule`,ruleId:s}:{kind:`dashboard`}})}function te({base:e,data:n,view:r}){let i=w(n);if(r.kind===`api`){let a=i.apis.find(e=>e.link===r.link);return a?/* @__PURE__ */ I(re,{base:e,api:a,scorecard:i,rulesPerLevel:n.scorecard.rulesPerLevel}):/* @__PURE__ */ I(t,{children:`API not found`})}if(r.kind===`rule`){let n=i.problemsByRule.find(e=>e.ruleId===r.ruleId);return n?/* @__PURE__ */ I(ie,{base:e,rule:n,scorecard:i}):/* @__PURE__ */ I(t,{children:`Rule not found`})}return/* @__PURE__ */ I(ne,{base:e,levelNames:n.scorecard.levelNames,scorecard:i})}function ne({base:e,levelNames:t,scorecard:o}){let{summary:u,filters:_,filterTerm:v,setFilterTerm:y,hasTeam:b,teamLabel:x,catalogConfig:C}=o,w={apis:`APIs`,rules:`Rules`};b&&(w.teams=x);let[E,D]=k.useState(!1),[A,j]=k.useState(`apis`),M=k.useCallback(()=>j(`apis`),[]);R(E);let N=o.teams.filter(e=>(e.apis[`Non-conformant`]??0)>0).sort((e,t)=>(t.apis[`Non-conformant`]??0)-(e.apis[`Non-conformant`]??0));return/* @__PURE__ */ I(X.Provider,{value:[v],children:/* @__PURE__ */ L(K,{"data-component-name":`Scorecard/Dashboard`,children:[/* @__PURE__ */ I(ae,{menu:/* @__PURE__ */ I(J,{setFilterTerm:y,filters:_,filterTerm:v,filterValuesCasing:C.filterValuesCasing})}),E&&/* @__PURE__ */ I(Y,{onClose:()=>D(!1),setFilterTerm:y,filterTerm:v,filters:_,filterValuesCasing:C.filterValuesCasing}),/* @__PURE__ */ I(Z,{onOpenFilter:()=>D(!0),filters:_,filterTerm:v}),/* @__PURE__ */ L(W,{children:[/* @__PURE__ */ L(G,{children:[/* @__PURE__ */ I(q,{children:`API design scorecard`}),/* @__PURE__ */ I(U,{children:`See the health of your API designs.`})]}),/* @__PURE__ */ L(i,{children:[/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:`Scorecard status`}),/* @__PURE__ */ L(f,{children:[/* @__PURE__ */ L(`div`,{children:[/* @__PURE__ */ I(r,{children:u.total}),/* @__PURE__ */ I(`br`,{}),`APIs`]}),/* @__PURE__ */ I(`div`,{children:Object.entries(u.levels).map(([e,t],n)=>/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(r,{style:{width:`40px`,textAlign:`right`},children:t}),/* @__PURE__ */ I(g,{level:e,colorVariable:P(n,Object.values(u.levels).length)})]},e))})]}),/* @__PURE__ */ I(S,{summary:u})]}),b&&/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:`Non-conformant APIs by ${x}`}),/* @__PURE__ */ L(d,{children:[N.slice(0,4).map(e=>/* @__PURE__ */ L(n,{children:[/* @__PURE__ */ I(`span`,{style:{flex:1,textAlign:`left`},children:e.team}),/* @__PURE__ */ I(r,{children:e.apis[`Non-conformant`]})]},e.team)),o.teams.length>4&&/* @__PURE__ */ L(s,{onClick:()=>j(`teams`),children:[`See all (`,o.teams.length,`)`]})]})]})]}),/* @__PURE__ */ I(l,{"data-component-name":`Scorecard/ModeSwitcherTabs`,children:Object.entries(w).map(([e,t])=>/* @__PURE__ */ I(c,{"data-component-name":`Scorecard/ModeSwitcherTab`,$isActive:A===e,onClick:()=>j(e),children:t},e))}),/* @__PURE__ */ I(h,{$isActive:A===`apis`,children:/* @__PURE__ */ I(T,{base:e,apis:o.apis,levelNames:t,hasTeam:b,hasPublishedAt:o.hasPublishedAt,teamLabel:x})}),/* @__PURE__ */ I(h,{$isActive:A===`rules`,children:/* @__PURE__ */ I(ee,{base:e,rules:o.problemsByRule})}),b&&/* @__PURE__ */ I(h,{$isActive:A===`teams`,children:/* @__PURE__ */ I(O,{teams:o.teams,levelNames:t,filters:_,teamLabel:x,teamProperty:o.teamProperty,onSelectTeam:M})})]})]})})}function $({base:e}){return/* @__PURE__ */ I(j,{icon:/* @__PURE__ */ I(B,{}),iconPosition:`left`,variant:`ghost`,size:`large`,to:e,children:`Back to dashboard`})}function re({base:e,api:n,scorecard:s,rulesPerLevel:d}){let _=C(n.scorecard.relativePath),v=_?.levels??{},y=Object.keys(v),[S,w]=k.useState(),T=S??y[0];return _===void 0?/* @__PURE__ */ I(t,{children:`Loading…`}):_===null?/* @__PURE__ */ I(t,{children:`Scorecard not found`}):/* @__PURE__ */ L(t,{"data-component-name":`Scorecard/ApiPage`,children:[/* @__PURE__ */ I($,{base:e}),/* @__PURE__ */ I(`h1`,{children:n.title}),/* @__PURE__ */ L(u,{children:[n.publishedAt&&/* @__PURE__ */ L(F,{children:[`Published at: `,new Date(n.publishedAt).toLocaleDateString(),/* @__PURE__ */ I(`br`,{})]}),/* @__PURE__ */ I(z,{to:n.link,external:!0,children:`Documentation`})]}),/* @__PURE__ */ L(i,{children:[/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ L(o,{children:[/* @__PURE__ */ I(`span`,{children:`Scorecard level`}),/* @__PURE__ */ I(g,{level:_.scorecardLevel,colorVariable:P(_.scorecardLevelIdx,y.length+1)})]}),/* @__PURE__ */ L(f,{children:[/* @__PURE__ */ I(`div`,{children:`Compliance by level`}),/* @__PURE__ */ I(`div`,{children:Object.entries(v).map(([e,t])=>/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(r,{style:{width:`100px`,textAlign:`right`},children:e}),/* @__PURE__ */ I(b,{errors:t.errors,warnings:t.warnings})]},e))})]})]}),/* @__PURE__ */ I(x,{title:`Rules compliance`,levels:Object.entries(v).map(([e,t])=>({name:e,errors:t.uniqueErrors,warnings:t.uniqueWarnings,total:d[e]?.length??0}))}),/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:s.teamLabel}),/* @__PURE__ */ I(r,{style:{fontWeight:`normal`},children:n.team})]})]}),/* @__PURE__ */ I(l,{"data-component-name":`Scorecard/ModeSwitcherTabs`,children:y.map(e=>/* @__PURE__ */ I(c,{"data-component-name":`Scorecard/ModeSwitcherTab`,$isActive:T===e,onClick:()=>w(e),children:/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(`span`,{children:e}),/* @__PURE__ */ I(b,{errors:v[e].errors,warnings:v[e].warnings})]})},e))}),y.map(e=>/* @__PURE__ */ I(h,{$isActive:T===e,children:/* @__PURE__ */ I(E,{level:e,problems:v[e].problems})},e))]})}function ie({base:e,rule:o,scorecard:s}){let c=Object.entries(o.teams).sort((e,t)=>t[1]-e[1]),l=o.apis.length;return/* @__PURE__ */ L(t,{"data-component-name":`Scorecard/RulePage`,children:[/* @__PURE__ */ I($,{base:e}),/* @__PURE__ */ L(`h1`,{children:[`Rule `,o.ruleId]}),/* @__PURE__ */ L(i,{children:[/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:`Rule status`}),/* @__PURE__ */ L(f,{children:[/* @__PURE__ */ L(`div`,{children:[/* @__PURE__ */ I(r,{children:l}),/* @__PURE__ */ I(`br`,{}),`APIs`]}),/* @__PURE__ */ L(`div`,{children:[/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(r,{children:l-o.warningApisCount-o.errorApisCount}),/* @__PURE__ */ I(y,{severity:`Pass`})]}),/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(r,{children:o.warningApisCount}),/* @__PURE__ */ I(y,{severity:`Warn`})]}),/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(r,{children:o.errorApisCount}),/* @__PURE__ */ I(y,{severity:`Error`})]})]})]})]}),/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:`Problems by level`}),/* @__PURE__ */ I(d,{children:Object.entries(o.levels).map(([e,t])=>/* @__PURE__ */ L(n,{children:[/* @__PURE__ */ I(`span`,{children:e}),/* @__PURE__ */ I(_,{chunks:[{share:t.errors/o.count*100,colorVariable:`--scorecard-color-error`},{share:t.warnings/o.count*100,colorVariable:`--scorecard-color-warning`}]}),/* @__PURE__ */ I(v,{children:t.errors+t.warnings})]},e))})]}),/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:`Problems by ${s.teamLabel}`}),/* @__PURE__ */ I(d,{children:c.slice(0,4).map(([e,t])=>/* @__PURE__ */ L(n,{children:[/* @__PURE__ */ I(`span`,{style:{flex:1,textAlign:`left`},children:e}),/* @__PURE__ */ I(r,{children:t})]},e))})]})]}),/* @__PURE__ */ I(D,{ruleId:o.ruleId,apis:o.apis,hasPublishedAt:s.hasPublishedAt,hasTeam:s.hasTeam,teamLabel:s.teamLabel})]})}const ae=A(V)`
|
|
2
2
|
display: none;
|
|
3
3
|
|
|
4
4
|
@media screen and (min-width: ${N.medium}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineContentPlugin as e}from"../../define.js";import{toJsonValue as t}from"../../../database/utils/json.js";import{createEntityLoader as n}from"../../../loaders/define.js";import{runtimeFile as r}from"../../utils/runtime-file.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{runtimeTemplate as a}from"../../templates.js";import{
|
|
1
|
+
import{defineContentPlugin as e}from"../../define.js";import{toJsonValue as t}from"../../../database/utils/json.js";import{createEntityLoader as n}from"../../../loaders/define.js";import{runtimeFile as r}from"../../utils/runtime-file.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{runtimeTemplate as a}from"../../templates.js";import{toPosixPath as o}from"../../../../shared/utils/to-posix-path.js";import{isObject as s}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as c}from"../../../../shared/utils/routes/normalize-route-slug.js";import{publicLink as l}from"../../../versions/public-link.js";import{createApiEntityKey as u}from"../../utils/api-entity-key.js";import{API_DOCS_INFO_BLOCK_DEP_KEY as d}from"../api-docs/server/shared.js";import{getLoadedProjectPlugins as f}from"../../project/loaded-set.js";import{API_OUTPUT_MANIFEST_KEY as p}from"../../../api-outputs.js";import{CATALOG_CLASSIC_DEP_KEY as m}from"../catalog-classic/client/contract.js";import{catalogEntityKey as h}from"../catalog-classic/entity-key.js";import{CATALOG_CARD_METADATA_ENTITY_TYPE as g}from"../catalog-classic/card-metadata.js";import{loadVersionGroups as _}from"../catalog-classic/resolve-items.js";import{NON_CONFORMANT as ee,apiPagePath as v,scorecardDetailsFile as y}from"./client/contract.js";import{findTarget as b,readScorecardSettings as x}from"./config.js";import{API_SCORECARD_ENTITY_TYPE as S,RULES_ENTITY_KEY as C,apiScorecardEntityKey as w,isScoredApi as T,scorecardPageEntityKey as E}from"./entities.js";import{collectRuleNames as te,lintApi as ne,resolveLevelConfigs as D,summarizeRules as O}from"./lint.js";import{gzip as k}from"../../../../shared/utils/gzip.js";import{join as A,posix as j,relative as M}from"node:path";import re from"picomatch";const N=`internal.scorecard-classic`,P=`scorecard-classic`,ie=i(N,`api`),ae=i(N,`rules`),oe=i(N,`page`),se=i(N,`card-metadata`),ce=i(N,`badge`),F=n(ie,async e=>{let t=e.file.path,n=e.args.source??t,r=e.routes.byFilePath(t),i=r&&e.routes.get(r.slug);if(!i)return{value:null,metadata:{sourcePath:t}};let a=async t=>({body:await e.createBlobRef(await k(new TextEncoder().encode(JSON.stringify(t))),{format:`binary`}),contentType:`application/gzip`}),o=x(e.config),s=J(e.contentDir),c=b(o.targets,i.metadata),l=b(o.targets.filter(e=>e.rules!==void 0),i.metadata),u=s.paths,d;try{let t=await D({contentDir:e.contentDir,settings:o,plugins:s.plugins,readFile:e.io.readFile});u=[...t.files,...s.paths];let r=l===void 0?void 0:t.targets[o.targets.indexOf(l)];d=await ne({contentDir:e.contentDir,filePath:n,source:await e.io.readFile(A(e.contentDir,n)),configs:Object.fromEntries(o.levels.map(e=>[e.name,r?.[e.name]??t.levels[e.name]]))})}catch(e){return{value:await a(null),metadata:{sourcePath:t},problems:[{code:`scorecard/lint-failed`,message:`The scorecard could not lint this API: ${e instanceof Error?e.message:String(e)}`,location:{filePath:t}}],entityDeps:Y([n,...u])}}let f={...L(o,d.levels,c?.minimumLevel),title:await I(e.entities,t)??j.basename(n),relativePath:t,levels:d.levels};i.version!==null&&(f.version=i.version);let{levels:p,...m}=f,h={...m,levels:Object.fromEntries(Object.entries(p).map(([e,{problems:t,...n}])=>[e,n])),rules:O(p),sourcePath:t,route:i.slug};return{value:await a(f),metadata:h,entityDeps:Y([n,...d.files,...u])}});async function I(e,t){let n=await e.load(u(t)).catch(()=>void 0),r=s(n)&&s(n.info)?n.info:{};return typeof r.title==`string`?r.title:void 0}function L(e,t,n){let r=e.levels.map(e=>e.name),i=r.findIndex(e=>t[e].errors>0),a=i===-1?r.length:i,o=n??r[0],s=r.indexOf(o),c=`HIGHEST`;return a-1<s?c=`BELOW_MINIMUM`:s<r.length-1&&(c=`MINIMUM`),{scorecardLevel:a===0?ee:r[a-1],scorecardLevelIdx:a,targetLevel:o,status:c}}async function R(e,t){let n=await e.get(t);return n!==null&&(n.status!==`ready`||!T(n.metadata))&&(await e.load(t).catch(()=>void 0),n=await e.get(t)),n!==null&&T(n.metadata)?n.metadata:null}async function z(e){let t=[];for(let n of await e.list({type:S})){let r=await R(e,n.key);r!==null&&t.push(r)}return t}function B({sourcePath:e,route:t,...n}){return n}const V=n(ae,async e=>{let t=x(e.config),{perLevel:n,all:r}=await D({contentDir:e.contentDir,settings:t,plugins:J(e.contentDir).plugins,readFile:e.io.readFile}).then(e=>te(e.levels),()=>({perLevel:{},all:[]}));return{value:{levelNames:t.levels.map(e=>e.name),rules:r,rulesPerLevel:n}}}),H=n(oe,async e=>{let t=await e.entities.load(h(e.args.catalogId)),n=await e.entities.load(C),r=(await z(e.entities)).flatMap(t=>{let n=e.routes.get(t.route);return n?[{route:n,api:t}]:[]}),{versionGroups:i,entityDeps:a}=await _(r,e),o=new Map(r.map(({route:e,api:t})=>[l(e,i),B(t)])),s=[];for(let e of t.items){let t=o.get(e.link);t!==void 0&&s.push({...e,metadata:{...e.metadata,scorecard:t,scorecardLevel:t.scorecardLevel}})}let c={...t,items:s,scorecard:{...n,teamMetadataProperty:x(e.config).teamMetadataProperty}},u=JSON.stringify(c);return{value:u.length>65536?await e.createBlobRef(u,{format:`json`}):c,entityDeps:a}}),U=n(se,async e=>({value:(await z(e.entities)).map(e=>({route:e.route,metadata:{scorecardStatus:e.status,scorecardLevel:e.scorecardLevel,scorecardLevelIdx:e.scorecardLevelIdx,scorecardLevels:G(e)}}))})),W=n(ce,async e=>{let t=await R(e.entities,w(e.args.file)),n=t&&e.routes.get(t.route);if(!t||!n)return{value:null};let{versionGroups:r,entityDeps:i}=await _([{route:n}],e),a=l(n,r),o=q(e.config);if(o.length===0)return{value:null};let s=o[0].slug;if(o.length>1){for(let{catalogId:t,slug:n}of o)if((await e.entities.load(h(t))).items.some(e=>e.link===a)){s=n;break}}return{value:{scorecardLevel:t.scorecardLevel,scorecardLevelIdx:t.scorecardLevelIdx,scorecardLevels:G(t),scoreCardSlug:v(K(s),a)},entityDeps:i}});function G(e){return Object.fromEntries(Object.entries(e.levels).map(([e,t])=>[e,{uniqueErrors:t.uniqueErrors,uniqueWarnings:t.uniqueWarnings}]))}function K(e){return j.join(c(e),`scorecard`)}function q(e){return Object.entries(e.catalogClassic??e.catalog??{}).map(([e,t])=>({catalogId:e,slug:String(t.slug)}))}function J(e){let t=f(e)?.lintPlugins??[];return{plugins:t,paths:t.map(t=>o(M(e,t.path))).filter(e=>e!==``&&!e.startsWith(`../`))}}function Y(e){return[...new Set(e)].map(e=>({kind:`file`,path:e}))}function X(e){let t=e=>typeof e==`string`||typeof e==`number`;return t(e.manifest.openapi)||t(e.manifest.swagger)}function Z(e){let t=e.manifest[p];return s(t)&&typeof t.root==`string`?t.root:e.path}function Q(e){let t=Z(e);return F.withArgs(t===e.path?{}:{source:t},{stableKey:w(e.path),type:S,metadata:{sourcePath:e.path}})}function $(e,t){if(!X(e))return!1;let n=(t.scorecardClassic??t.scorecard)?.ignore??[];return n.length===0||!re([...n])(Z(e))}function le(e,t){let n=e.filter(e=>e.status===`BELOW_MINIMUM`).map(e=>e.relativePath);if(n.length===0)return;let r=n.slice(0,15).map(e=>`\n - ${e}`),i=n.length-r.length,a=`Detected OpenAPI definitions with score below minimum level:${r.join(``)}${i>0?`\n ... and ${i} more`:``}`;t.config.platform?.ignoreLint??(t.config.scorecardClassic??t.config.scorecard)?.ignoreNonCompliant?t.logger.warn(a):t.logger.error(a)}const ue=e({id:N,version:`2.3.0`,content:{filter:{extensions:[`.yaml`,`.yml`,`.json`]},extractFile(e,t){return $(e,t.config)?{routes:[],entities:[Q(e)]}:null},extractAll(e){let t=e.config.catalogClassic??e.config.catalog??{};if(!e.files.some(X)&&Object.keys(t).length===0)return{routes:[]};let n=x(e.config),r=[V.withArgs({},{stableKey:C})];n.isDefault||r.push(U.withArgs({},{stableKey:`scorecard-classic:card-metadata`,type:g}));let i=[];for(let[e,n]of Object.entries(t)){let t=K(String(n.slug)),a=H.withArgs({catalogId:e},{stableKey:E(e),metadata:{sourcePath:t}});r.push(a),i.push({deps:{[m]:a},metadata:{title:typeof n.title==`string`?n.title:`API design scorecard`},routeId:e,slug:t,template:P,wildcardPrefix:!0})}return{entities:r,routes:i}}},finalize(e){let t=q(e.config).length>0&&!x(e.config).isDefault,n=[],r=[],i=[];for(let a of e.files){let o=$(a,e.config)?e.routes.byFilePath(a.path):void 0;if(o===void 0||(n.push({path:y(a.path),producer:Q(a),audience:{routeSlug:o.slug}}),!t))continue;let s=W.withArgs({file:a.path},{stableKey:`scorecard-classic:badge:${o.slug}`});r.push(s),i.push({slug:o.slug,deps:{[d]:s}})}return{entities:r,attach:i,staticFiles:n}},async buildMetadata(e){if(await e.entities.get(`scorecard-classic:rules`)===null)return;let n=await e.entities.load(C),r=await z(e.entities),i={};for(let e of r){let{rules:t,...n}=B(e);i[e.relativePath]=n}return le(r,e),{scorecardData:i,...n,reuniteIgnoreLint:t(e.config.platform?.ignoreLint)}},loaders:[F,V,H,U,W],templates:{[P]:a(r(`./client/template.tsx`,import.meta.url))}});export{N as SCORECARD_CLASSIC_PLUGIN_ID,P as SCORECARD_CLASSIC_TEMPLATE_ID,ue as scorecardClassicContentPlugin};
|