@redocly/framework 1.0.0-next.6 → 1.0.0-next.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/dist/bundler/build/output-metadata.js +1 -1
  2. package/dist/bundler/build/run.js +1 -1
  3. package/dist/bundler/dev/dev-content-build.js +1 -0
  4. package/dist/bundler/dev/dev-problems.js +1 -1
  5. package/dist/bundler/dev/dev-reporter.js +1 -1
  6. package/dist/bundler/dev/routes/dev-content-build-route.js +1 -0
  7. package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
  8. package/dist/bundler/dev/run.js +1 -1
  9. package/dist/bundler/dev/runtime-app.js +1 -1
  10. package/dist/cli/args.js +1 -1
  11. package/dist/cli/commands/build.js +1 -1
  12. package/dist/cli/commands/ingest.js +1 -1
  13. package/dist/cli/commands/translate.js +1 -1
  14. package/dist/cli/dev-console/{sweep.js → content-build.js} +1 -1
  15. package/dist/cli/dev-console/index.js +1 -1
  16. package/dist/cli/dev-console/lines.js +2 -2
  17. package/dist/cli/dev-console/plain.js +1 -1
  18. package/dist/cli/dev-console/tui.js +2 -2
  19. package/dist/cli/validate-react-pages.js +1 -1
  20. package/dist/client/app.js +2 -7
  21. package/dist/client/client-entry.js +1 -1
  22. package/dist/client/dev-problems/ProblemsBar.js +75 -15
  23. package/dist/client/dev-problems/build-segment.js +1 -0
  24. package/dist/client/dev-problems/index.js +1 -1
  25. package/dist/client/dev-problems/use-dev-problems.js +1 -1
  26. package/dist/client/review/ReviewBar.js +163 -69
  27. package/dist/client/review/login-url.js +1 -0
  28. package/dist/client/use-bar-position.js +1 -0
  29. package/dist/client/use-page-versions.js +1 -1
  30. package/dist/client/use-search.js +1 -1
  31. package/dist/content-layer/api-outputs.js +1 -1
  32. package/dist/content-layer/config-schema.js +1 -1
  33. package/dist/content-layer/config.d.ts +2 -1
  34. package/dist/content-layer/config.js +1 -1
  35. package/dist/content-layer/database/files.js +1 -1
  36. package/dist/content-layer/database/finalize.js +1 -1
  37. package/dist/content-layer/database/origins.js +1 -1
  38. package/dist/content-layer/database/problems.d.ts +2 -0
  39. package/dist/content-layer/database/problems.js +1 -1
  40. package/dist/content-layer/database/reset.js +1 -1
  41. package/dist/content-layer/database/schema.d.ts +17 -0
  42. package/dist/content-layer/database/schema.js +1 -1
  43. package/dist/content-layer/ingest/finalize-phase.js +1 -1
  44. package/dist/content-layer/ingest/git-last-modified.js +3 -3
  45. package/dist/content-layer/ingest/hash.js +1 -1
  46. package/dist/content-layer/ingest/run.js +1 -1
  47. package/dist/content-layer/ingest/search-sync.js +1 -1
  48. package/dist/content-layer/ingest/sync.js +1 -1
  49. package/dist/content-layer/link-checker/delta.js +1 -1
  50. package/dist/content-layer/link-checker/fingerprint.js +1 -1
  51. package/dist/content-layer/link-checker/load-view.js +1 -1
  52. package/dist/content-layer/link-checker/run-build.js +1 -1
  53. package/dist/content-layer/link-checker/validate.js +1 -1
  54. package/dist/content-layer/link-checker/view.js +1 -1
  55. package/dist/content-layer/loaders/context.js +1 -1
  56. package/dist/content-layer/loaders/define.d.ts +3 -0
  57. package/dist/content-layer/markdown/client/JsonSchemaTag.js +1 -1
  58. package/dist/content-layer/markdown/client/code-highlight-notation.js +3 -3
  59. package/dist/content-layer/markdown/client/markdoc-components.js +2 -2
  60. package/dist/content-layer/markdown/resolve/audience-tag.d.ts +1 -5
  61. package/dist/content-layer/markdown/resolve/audience-tag.js +1 -1
  62. package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.js +1 -1
  63. package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
  64. package/dist/content-layer/markdown/resolve/references.js +1 -1
  65. package/dist/content-layer/markdown/search/to-sections.d.ts +1 -1
  66. package/dist/content-layer/markdown/search/to-sections.js +1 -1
  67. package/dist/content-layer/markdown/tags/html.d.ts +2 -2
  68. package/dist/content-layer/markdown/tags/html.js +1 -1
  69. package/dist/content-layer/markdown/tags/openapi.js +1 -1
  70. package/dist/content-layer/materialization/entity.js +1 -1
  71. package/dist/content-layer/materialization/static-files.js +1 -1
  72. package/dist/content-layer/plugins/internal/api-docs/client/event-handlers.js +1 -1
  73. package/dist/content-layer/plugins/internal/api-docs/client/template.js +11 -3
  74. package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
  75. package/dist/content-layer/plugins/internal/api-docs/server/build-definition.d.ts +21 -11
  76. package/dist/content-layer/plugins/internal/api-docs/server/build-definition.js +1 -1
  77. package/dist/content-layer/plugins/internal/api-docs/server/build-sidebar.js +1 -1
  78. package/dist/content-layer/plugins/internal/api-docs/server/markdown-decorator.d.ts +1 -4
  79. package/dist/content-layer/plugins/internal/api-docs/server/markdown-decorator.js +1 -1
  80. package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.js +14 -14
  81. package/dist/content-layer/plugins/internal/api-docs/server/spec-download.js +1 -1
  82. package/dist/content-layer/plugins/internal/api-functions/server/access.js +1 -1
  83. package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
  84. package/dist/content-layer/plugins/internal/app-data/index.d.ts +1 -1
  85. package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
  86. package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
  87. package/dist/content-layer/plugins/internal/mcp/constants.d.ts +17 -0
  88. package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
  89. package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
  90. package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
  91. package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
  92. package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
  93. package/dist/content-layer/plugins/internal/mcp/server/codemode/capabilities.js +6 -6
  94. package/dist/content-layer/plugins/internal/mcp/server/codemode/constants.js +1 -1
  95. package/dist/content-layer/plugins/internal/mcp/server/codemode/discover.js +1 -1
  96. package/dist/content-layer/plugins/internal/mcp/server/codemode/prompts.js +8 -8
  97. package/dist/content-layer/plugins/internal/mcp/server/custom-tools.js +1 -1
  98. package/dist/content-layer/plugins/internal/mcp/server/gateway/allowed-http-methods.js +1 -1
  99. package/dist/content-layer/plugins/internal/mcp/server/gateway/api-call-operations.js +1 -1
  100. package/dist/content-layer/plugins/internal/mcp/server/gateway/call-api.js +2 -0
  101. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +10 -10
  102. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/outcome-pages.js +1 -1
  103. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
  104. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-bridge.js +1 -1
  105. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/ssrf-guard.js +1 -1
  106. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/upstream-detail.js +1 -1
  107. package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
  108. package/dist/content-layer/plugins/internal/mcp/server/gateway/tool-list.js +1 -0
  109. package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +4 -4
  110. package/dist/content-layer/plugins/internal/mcp/server/gateway/upstream-auth-scheme.js +1 -1
  111. package/dist/content-layer/plugins/internal/mcp/server/handler.js +1 -1
  112. package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
  113. package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.js +1 -1
  114. package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
  115. package/dist/content-layer/plugins/internal/mcp/server/oauth/callback.js +1 -1
  116. package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
  117. package/dist/content-layer/plugins/internal/mcp/server/oauth/token.js +1 -1
  118. package/dist/content-layer/plugins/internal/mcp/server/oauth/tokens.js +1 -1
  119. package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
  120. package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
  121. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-catalog.js +1 -1
  122. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-document.js +1 -1
  123. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi.js +1 -1
  124. package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +2 -2
  125. package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -1
  126. package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
  127. package/dist/content-layer/plugins/internal/sidebar/index.d.ts +2 -1
  128. package/dist/content-layer/plugins/internal/sidebar/index.js +1 -1
  129. package/dist/content-layer/plugins/internal/sidebar/subtree.js +1 -1
  130. package/dist/content-layer/plugins/internal/skills/server/routes.js +1 -1
  131. package/dist/content-layer/plugins/types/markdoc.d.ts +2 -0
  132. package/dist/content-layer/plugins/utils/route-index.js +1 -1
  133. package/dist/content-layer/problems/codes.js +1 -1
  134. package/dist/content-layer/search/postings/fragment-field.d.ts +2 -0
  135. package/dist/content-layer/search/postings/fragment-field.js +1 -1
  136. package/dist/content-layer/search/postings/postings-store.js +1 -1
  137. package/dist/content-layer/server/database.js +1 -1
  138. package/dist/content-layer/static/registry.js +1 -1
  139. package/dist/content-layer/versions/version-groups.d.ts +5 -1
  140. package/dist/content-layer/versions/version-groups.js +1 -1
  141. package/dist/server/app.js +3 -3
  142. package/dist/server/ask-ai/route.js +1 -1
  143. package/dist/server/auth/access-config.js +1 -1
  144. package/dist/server/auth/gate.js +1 -1
  145. package/dist/server/auth/middleware.js +1 -1
  146. package/dist/server/auth/oidc.js +1 -1
  147. package/dist/server/auth/routes.js +1 -1
  148. package/dist/server/content.js +9 -9
  149. package/dist/server/lambda-entry.js +1 -1
  150. package/dist/server/node-entry.js +1 -1
  151. package/dist/server/page-handlers.js +2 -2
  152. package/dist/server/redirects.js +1 -1
  153. package/dist/server/review/route.js +1 -1
  154. package/dist/server/search/route.js +1 -1
  155. package/dist/server/static-files/serve.js +1 -1
  156. package/dist/server/subprocess/child-entry.js +1 -1
  157. package/dist/server/subprocess/host.js +1 -1
  158. package/dist/server/telemetry/mock-server-events.js +1 -0
  159. package/dist/server/telemetry/redirect-event.js +1 -0
  160. package/dist/server/telemetry/sender.js +1 -1
  161. package/dist/shared/constants/content-update.js +1 -1
  162. package/dist/shared/constants/dev-content-build.js +1 -0
  163. package/dist/shared/constants/dev-problems.js +1 -1
  164. package/dist/shared/constants/dev-source-sync.js +1 -1
  165. package/dist/shared/constants/manifest-version.d.ts +3 -1
  166. package/dist/shared/constants/openapi-operation-methods.d.ts +2 -0
  167. package/dist/shared/constants/openapi-operation-methods.js +1 -0
  168. package/dist/shared/constants/review.d.ts +5 -0
  169. package/dist/shared/constants/review.js +1 -1
  170. package/dist/shared/load-dot-env.js +1 -1
  171. package/dist/shared/rbac/api-docs.d.ts +2 -1
  172. package/dist/shared/rbac/api-docs.js +1 -1
  173. package/dist/shared/rbac/engine.d.ts +12 -9
  174. package/dist/shared/rbac/engine.js +0 -0
  175. package/dist/shared/rbac/filter.js +1 -1
  176. package/dist/shared/rbac/route-scope.d.ts +1 -1
  177. package/dist/shared/types/auth.d.ts +1 -0
  178. package/dist/shared/types/config.d.ts +1 -0
  179. package/dist/shared/types/search.d.ts +7 -2
  180. package/drizzle/20261111152552_page_markdown_rbac_scope/migration.sql +1 -0
  181. package/package.json +26 -5
  182. package/dist/bundler/dev/__tests__/reset-content-update-state.js +0 -1
  183. package/dist/bundler/dev/materialization-sweeper.js +0 -1
  184. package/dist/client/dev-problems/sweep-segment.js +0 -1
  185. package/dist/client/review/use-bar-position.js +0 -1
  186. package/dist/content-layer/plugins/internal/mcp/server/gateway/__tests__/fake-kv.js +0 -1
  187. package/dist/content-layer/plugins/internal/mcp/server/gateway/__tests__/secret-store-fixture.js +0 -1
  188. package/dist/server/__tests__/rbac-fixture.js +0 -1
  189. package/dist/server/__tests__/test-session.js +0 -1
@@ -1 +1 @@
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
+ 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{publicOrigin as l}from"../../../../utils/request-origin.js";import{notFoundResponse as u}from"../../../../../../server/plugin-context.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 u();let i=l(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 u();let o=l(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{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
+ import{isMcpHidden as e}from"../config-gate.js";import{MCP_ACCESS_TOKEN_USE as t}from"../../../../../../server/auth/constants.js";import{notFoundResponse as n}from"../../../../../../server/plugin-context.js";import{getSessionIssuer as r}from"../../../../../../server/auth/middleware.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 n();let o=r(t);if(!o)return n();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{SUPPORTED_CODE_CHALLENGE_METHODS as e}from"./constants.js";import{createHash as t,timingSafeEqual as n}from"node:crypto";import{ulid as r}from"ulid";import{sign as i,verify as a}from"hono/jwt";const o=`HS256`;async function s(e,t,n){let a=Math.floor(Date.now()/1e3);return i({...e,jti:r(),iat:a,exp:n},t,o)}async function c(e,t,n){let r=await a(e,t,o);if(r.type!==n)throw Error(`Expected a ${n} token.`);return r}function l(e,r,i){if(!e||!u(r))return!1;let a=Buffer.from(t(`sha256`).update(i).digest(`base64url`)),o=Buffer.from(e);return a.length===o.length&&n(a,o)}function u(t){return e.includes(t??``)}function d(e){return t(`sha256`).update(e).digest(`base64url`)}function f({viewer:e,claims:t}){return{sub:e.sub,email:e.email,name:e.name,picture:e.picture,teams:[...e.teams],idpId:t.idpId}}export{u as isSupportedCodeChallengeMethod,f as sessionClaimsFromSession,d as sha256Base64Url,s as signMcpArtifact,c as verifyMcpArtifact,l as verifyPkce};
1
+ import{SUPPORTED_CODE_CHALLENGE_METHODS as e}from"./constants.js";import{createHash as t,timingSafeEqual as n}from"node:crypto";import{sign as r,verify as i}from"hono/jwt";import{ulid as a}from"ulid";const o=`HS256`;async function s(e,t,n){let i=Math.floor(Date.now()/1e3);return r({...e,jti:a(),iat:i,exp:n},t,o)}async function c(e,t,n){let r=await i(e,t,o);if(r.type!==n)throw Error(`Expected a ${n} token.`);return r}function l(e,r,i){if(!e||!u(r))return!1;let a=Buffer.from(t(`sha256`).update(i).digest(`base64url`)),o=Buffer.from(e);return a.length===o.length&&n(a,o)}function u(t){return e.includes(t??``)}function d(e){return t(`sha256`).update(e).digest(`base64url`)}function f({viewer:e,claims:t}){return{sub:e.sub,email:e.email,name:e.name,picture:e.picture,teams:[...e.teams],idpId:t.idpId}}export{u as isSupportedCodeChallengeMethod,f as sessionClaimsFromSession,d as sha256Base64Url,s as signMcpArtifact,c as verifyMcpArtifact,l as verifyPkce};
@@ -1 +1 @@
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{sendMcpServerCardServed as p}from"./mcp-telemetry.js";import{applyMcpRateLimit as m}from"./rate-limit.js";import{createServedMcpRequestHandler as h}from"./handler.js";import{docsServerInfo as g}from"./server-info.js";import{CLIENT_CAPABILITIES_META_KEY as _,CLIENT_INFO_META_KEY as v,LATEST_PROTOCOL_VERSION as y,PROTOCOL_VERSION_META_KEY as b}from"@modelcontextprotocol/server";const x=`2026-07-28`,S=[`dynamic`],C={capabilities:{},tools:S};async function w(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":x,"mcp-method":n},body:JSON.stringify({jsonrpc:`2.0`,id:1,method:n,params:{_meta:{[b]:x,[v]:{name:`server-card`,version:`1.0`},[_]:{}}}})}));if(r.ok)return(await r.json()).result}function T(e,t){e.logger?.warn(`MCP server card lists dynamic tools: ${l(t)}`)}async function E(r,i){let a=await r.withViewer(n),o=await h(a,{isProtected:i},Date.now()+f,{onError:e=>T(r,e)}),s=new URL(t(e),c(r.request)).href,[l,u]=await Promise.all([w(o,s,`server/discover`),i?void 0:w(o,s,`tools/list`)]);if(!l)return;if(i)return{capabilities:l.capabilities,tools:S};if(!u)return;let d=u.tools.map(({name:e,title:t,description:n,inputSchema:r,annotations:i})=>({name:e,title:t,description:n,inputSchema:r,annotations:i}));return{capabilities:l.capabilities,instructions:l.instructions,tools:d.length>0?d:S}}async function D(n,c){if(i(c.config))return o();n.set(`realmCacheControlOwned`,!0);let l=await m({kv:c.kv,ip:c.request.ip,bucket:`card`,headers:u,logger:c.logger});if(l)return l;let f=g(c.config,c.request),h=r(a(c.config)),_=await E(c,h).catch(e=>{T(c,e)}),{capabilities:v,instructions:b,tools:x}=_??C;return await p({logger:c.logger}),n.json({$schema:`https://static.modelcontextprotocol.io/schemas/mcp-server-card/v1.json`,version:`1.0`,protocolVersion:y,serverInfo:{...f,title:f.name},description:f.description,documentationUrl:s(c.config,c.request),transport:{type:`streamable-http`,endpoint:t(e)},capabilities:v,authentication:h?{required:!0,schemes:[...d]}:void 0,instructions:b,tools:x},200,{...u,"Cache-Control":_?`public, max-age=3600`:`no-store`})}export{D as mcpServerCard};
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{publicBaseUrl as o,publicOrigin as s}from"../../../utils/request-origin.js";import{formatError as c}from"./tool-errors.js";import{notFoundResponse as l}from"../../../../../server/plugin-context.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{sendMcpServerCardServed as p}from"./mcp-telemetry.js";import{applyMcpRateLimit as m}from"./rate-limit.js";import{createServedMcpRequestHandler as h}from"./handler.js";import{docsServerInfo as g}from"./server-info.js";import{CLIENT_CAPABILITIES_META_KEY as _,CLIENT_INFO_META_KEY as v,LATEST_PROTOCOL_VERSION as y,PROTOCOL_VERSION_META_KEY as b}from"@modelcontextprotocol/server";const x=`2026-07-28`,S=[`dynamic`],C={capabilities:{},tools:S};async function w(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":x,"mcp-method":n},body:JSON.stringify({jsonrpc:`2.0`,id:1,method:n,params:{_meta:{[b]:x,[v]:{name:`server-card`,version:`1.0`},[_]:{}}}})}));if(r.ok)return(await r.json()).result}function T(e,t){e.logger?.warn(`MCP server card lists dynamic tools: ${c(t)}`)}async function E(r,i){let a=await r.withViewer(n),o=await h(a,{isProtected:i},Date.now()+f,{onError:e=>T(r,e)}),c=new URL(t(e),s(r.request)).href,[l,u]=await Promise.all([w(o,c,`server/discover`),i?void 0:w(o,c,`tools/list`)]);if(!l)return;if(i)return{capabilities:l.capabilities,tools:S};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:S}}async function D(n,s){if(i(s.config))return l();n.set(`realmCacheControlOwned`,!0);let c=await m({kv:s.kv,ip:s.request.ip,bucket:`card`,headers:u,logger:s.logger});if(c)return c;let f=g(s.config,s.request),h=r(a(s.config)),_=await E(s,h).catch(e=>{T(s,e)}),{capabilities:v,instructions:b,tools:x}=_??C;return await p({logger:s.logger}),n.json({$schema:`https://static.modelcontextprotocol.io/schemas/mcp-server-card/v1.json`,version:`1.0`,protocolVersion:y,serverInfo:{...f,title:f.name},description:f.description,documentationUrl:o(s.config,s.request),transport:{type:`streamable-http`,endpoint:t(e)},capabilities:v,authentication:h?{required:!0,schemes:[...d]}:void 0,instructions:b,tools:x},200,{...u,"Cache-Control":_?`public, max-age=3600`:`no-store`})}export{D as mcpServerCard};
@@ -1 +1 @@
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
+ 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{publicOrigin as r}from"../../../utils/request-origin.js";import{isEntityScopeVisible as i}from"../../../../../shared/rbac/entity-scope.js";async function a(a){if(a.config.skills?.hide===!0)return[];let o=await a.entities.list({type:n}),s=r(a.request),c=e=>i(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{compileContentGlob as e}from"../../../../utils/glob.js";import{SPEC_KIND_OPENAPI as t}from"../../../../../../shared/constants/api-spec-kinds.js";import{filterApiDocsByRbac as n}from"../../../../../../shared/rbac/api-docs.js";import{canonicalSlugPath as r}from"../../ignored-routes.js";import{formatError as i}from"../tool-errors.js";import{OPERATION_METHODS as a,absolutePath as o,findDocumentedPath as s,formatCandidates as c,isDefinitionHidden as l,recoveryToolNames as u,visibleMethodsAt as d}from"./openapi-document.js";import{apiTitleKey as f,compareApiDescriptions as p}from"./api-titles.js";const m=/* @__PURE__ */ new WeakMap;function h(e,r){let a=m.get(e);a||(a=/* @__PURE__ */ new Map,m.set(e,a));let o=a.get(r);if(o)return o;let s=t=>e.logger?.warn(t),c=e.entities.load(r).then(r=>({full:r,visible:n(r,t,e.request.teams,{warn:s})})).catch(e=>(s(`MCP: skipping api entity "${r}": ${i(e)}`),null));return a.set(r,c),c}const g=new Set(a);function _(e){return Object.values(e.paths??{}).some(e=>typeof e==`object`&&!!e&&Object.keys(e).some(e=>g.has(e.toLowerCase())))}function v(e,t,n){let{title:r=``,version:i=``,description:a}=t.info??{};return{entityKey:e.entityKey,definition:t,fullDefinition:n,relativePath:e.relativePath,name:r,description:typeof a==`string`?a:``,version:String(i),servers:t.servers??[]}}async function y(t){let n=t.config.mcp?.ignore??[],i=n.length>0?e(n):()=>!1;return(await t.entities.list({type:`api`})).flatMap(({key:e,metadata:t})=>{let{specType:n,sourcePath:a,routeSlug:o}=t??{};return n!==`openapi`||typeof a!=`string`||i(a)||typeof o==`string`&&i(r(o,a))?[]:[{entityKey:e,relativePath:a}]})}async function b(e,t){let n=await h(e,t.entityKey);return!n?.visible||!_(n.visible)||l(n.visible.info)?null:v(t,n.visible,n.full)}async function x(e){let t=await y(e);return(await Promise.all(t.map(t=>b(e,t)))).filter(e=>e!==null)}const S=/* @__PURE__ */ new Set([`api`,`apis`,`rest`,`restful`,`openapi`,`graphql`,`spec`,`specification`,`service`,`services`]);function C(e){return e.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean)}function w(e){return new Set(C(e).filter(e=>!S.has(e)))}function T(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function E(e,t,n){let r=w(t);return e.map(e=>{let t=e[n];return{api:e,text:t,score:[...w(t)].filter(e=>r.has(e)).length}}).sort((e,t)=>t.score-e.score||e.text.localeCompare(t.text)).map(({api:e})=>e)}function D(e,t){return c(E(e,t,`name`).map(e=>`"${e.name}" (${e.relativePath})`))}function O(e,t){return c(E(e,t,`relativePath`).map(e=>`"${e.relativePath}"`))}function k(e,t){let n=f(t);if(!n)return{matches:[],isExactTitle:!1};let r=e.map(e=>({api:e,title:f(e.name)})),i=e=>e.map(({api:e})=>e),a=r.filter(({title:e})=>e===n);if(a.length>0)return{matches:i(a),isExactTitle:!0};let o=r.filter(({title:e})=>e.includes(n));if(o.length>0)return{matches:i(o),isExactTitle:!1};let s=w(n);return s.size===0?{matches:[],isExactTitle:!1}:{matches:i(r.filter(({title:e})=>{let t=w(e);return t.size>0&&T(t,s)})),isExactTitle:!1}}function A(e,t,n){let{matches:r,isExactTitle:i}=k(e,t);if(r.length===0)return;if(!i){let e=[...new Set(r.map(({name:e})=>e))];if(e.length>1)throw Error(`"${t}" matches ${e.length} APIs: ${c(e.map(e=>`"${e}"`))}. Pass one of those names exactly, or the "filePath" parameter from list-apis.`)}let a=n?r.filter(e=>e.version===n):r;if(a.length===0){let e=[...new Set(r.map(({version:e})=>e||`(no version)`))];throw Error(`"${r[0].name||t}" has no version "${n}". Available versions: ${c(e)}.`)}let[o,...s]=[...a].sort(p);return{api:o,otherMatches:s.length>0?s:void 0}}function j(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.filter(({name:e})=>e.toLowerCase().includes(n));return r.length>0?r:e.filter(({description:e})=>e.toLowerCase().includes(n))}function M({version:e,relativePath:t}){return{version:e||void 0,filePath:t}}function N(e,t=[]){return{api:e,otherMatches:t.length>0?t.map(M):void 0}}function P(e){return`Pass \`name\` (the API title, or a unique part of it) or \`filePath\` from ${u(e).listApis}.`}async function F(e,t){let{name:n,version:r,filePath:i}=e;if(!i&&!n)return I(e,t);let a=await y(t),o=i??n,s=a.find(e=>e.relativePath===o),c=s&&await b(t,s);if(c)return N(c);let l=await x(t);if(i){let e=O(l,i);throw Error(`No API found with filePath "${i}". `+(e?`Available file paths: ${e}. `:``)+`File paths come from ${u(t.mcpMode).listApis}.`)}let d=A(l,n??``,r);if(d)return N(d.api,d.otherMatches);let f=D(l,n??``);throw Error(f?`No API found matching "${n}". Available APIs: ${f}. Pass one of those names, or its \`filePath\`.`:`No API found matching "${n}".`)}async function I({path:e,method:t,version:n},r){let i=await x(r);if(i.length===0)throw Error(`This project documents no OpenAPI description.`);if(i.length===1){let[e]=i;if(n&&e.version!==n)throw Error(`"${e.name}" has no version "${n}". Available versions: ${e.version||`(no version)`}.`);return N(e)}if(!e||!t||i.length>10)throw Error(`${P(r.mcpMode)} Available APIs: ${D(i,``)}.`);let a=[],l=/* @__PURE__ */ new Set,u=[],f=t.toUpperCase();for(let t of i){let n=s(t.definition,e);if(!n)continue;let r=d(t.definition,n.path);r.includes(f)?(a.push(t),n.isTemplateMatch&&l.add(t)):r.length>0&&u.push({api:t,methods:r})}if(a.sort(p),a.length===0)throw R(i,u,e,t,r.mcpMode);let m=n?a.filter(e=>e.version===n):a;if(m.length===0){let t=[...new Set(a.map(({version:e})=>e||`(no version)`))];throw Error(`No API documenting "${o(e)}" has version "${n}". Available versions: ${c(t)}.`)}let h=m.filter(e=>!l.has(e));return L(h.length>0?h:m,e,t,r.mcpMode)}function L(e,t,n,r){let i=new Set(e.map(({name:e})=>f(e)));if(i.size>1){let a=[...i].map(t=>{let[n]=e.filter(e=>f(e.name)===t);return`"${n.name}" (${n.relativePath})`});throw Error(`${n.toUpperCase()} ${o(t)} is documented by ${i.size} APIs: ${c(a)}. Pass \`name\` or \`filePath\` from ${u(r).listApis} to pick one.`)}let[a,...s]=e;return N(a,s)}function R(e,t,n,r,i){if(t.length>0){let e=t.map(({api:e,methods:t})=>`"${e.name}" (${e.relativePath}) documents ${c(t)}.`).join(` `);return/* @__PURE__ */ Error(`No API documents ${r.toUpperCase()} ${o(n)}. ${e}`)}let{endpoints:a,search:s}=u(i);return/* @__PURE__ */ Error(`No API in this project documents ${o(n)}. Available APIs: ${D(e,``)}. Call ${a} with one of them, or ${s} with a keyword from the request.`)}export{D as describeAvailableApis,j as filterApisByName,A as findApiByNameAndVersion,x as loadApiCatalog,F as resolveApi};
1
+ import{compileContentGlob as e}from"../../../../utils/glob.js";import{SPEC_KIND_OPENAPI as t}from"../../../../../../shared/constants/api-spec-kinds.js";import{OPERATION_METHODS as n}from"../../../../../../shared/constants/openapi-operation-methods.js";import{filterApiDocsByRbac as r}from"../../../../../../shared/rbac/api-docs.js";import{canonicalSlugPath as i}from"../../ignored-routes.js";import{formatError as a}from"../tool-errors.js";import{apiTitleKey as o,compareApiDescriptions as s}from"./api-titles.js";import{absolutePath as c,findDocumentedPath as l,formatCandidates as u,isDefinitionHidden as d,recoveryToolNames as f,visibleMethodsAt as p}from"./openapi-document.js";const m=/* @__PURE__ */ new WeakMap;function h(e,n){let i=m.get(e);i||(i=/* @__PURE__ */ new Map,m.set(e,i));let o=i.get(n);if(o)return o;let s=t=>e.logger?.warn(t),c=e.entities.load(n).then(n=>({full:n,visible:r(n,t,e.request.teams,{warn:s})})).catch(e=>(s(`MCP: skipping api entity "${n}": ${a(e)}`),null));return i.set(n,c),c}const g=new Set(n);function _(e){return Object.values(e.paths??{}).some(e=>typeof e==`object`&&!!e&&Object.keys(e).some(e=>g.has(e.toLowerCase())))}function v(e,t,n){let{title:r=``,version:i=``,description:a}=t.info??{};return{entityKey:e.entityKey,definition:t,fullDefinition:n,relativePath:e.relativePath,name:r,description:typeof a==`string`?a:``,version:String(i),servers:t.servers??[]}}async function y(t){let n=t.config.mcp?.ignore??[],r=n.length>0?e(n):()=>!1;return(await t.entities.list({type:`api`})).flatMap(({key:e,metadata:t})=>{let{specType:n,sourcePath:a,routeSlug:o}=t??{};return n!==`openapi`||typeof a!=`string`||r(a)||typeof o==`string`&&r(i(o,a))?[]:[{entityKey:e,relativePath:a}]})}async function b(e,t){let n=await h(e,t.entityKey);return!n?.visible||!_(n.visible)||d(n.visible.info)?null:v(t,n.visible,n.full)}async function x(e){let t=await y(e);return(await Promise.all(t.map(t=>b(e,t)))).filter(e=>e!==null)}const S=/* @__PURE__ */ new Set([`api`,`apis`,`rest`,`restful`,`openapi`,`graphql`,`spec`,`specification`,`service`,`services`]);function C(e){return e.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean)}function w(e){return new Set(C(e).filter(e=>!S.has(e)))}function T(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function E(e,t,n){let r=w(t);return e.map(e=>{let t=e[n];return{api:e,text:t,score:[...w(t)].filter(e=>r.has(e)).length}}).sort((e,t)=>t.score-e.score||e.text.localeCompare(t.text)).map(({api:e})=>e)}function D(e,t){return u(E(e,t,`name`).map(e=>`"${e.name}" (${e.relativePath})`))}function O(e,t){return u(E(e,t,`relativePath`).map(e=>`"${e.relativePath}"`))}function k(e,t){let n=o(t);if(!n)return{matches:[],isExactTitle:!1};let r=e.map(e=>({api:e,title:o(e.name)})),i=e=>e.map(({api:e})=>e),a=r.filter(({title:e})=>e===n);if(a.length>0)return{matches:i(a),isExactTitle:!0};let s=r.filter(({title:e})=>e.includes(n));if(s.length>0)return{matches:i(s),isExactTitle:!1};let c=w(n);return c.size===0?{matches:[],isExactTitle:!1}:{matches:i(r.filter(({title:e})=>{let t=w(e);return t.size>0&&T(t,c)})),isExactTitle:!1}}function A(e,t,n){let{matches:r,isExactTitle:i}=k(e,t);if(r.length===0)return;if(!i){let e=[...new Set(r.map(({name:e})=>e))];if(e.length>1)throw Error(`"${t}" matches ${e.length} APIs: ${u(e.map(e=>`"${e}"`))}. Pass one of those names exactly, or the "filePath" parameter from list-apis.`)}let a=n?r.filter(e=>e.version===n):r;if(a.length===0){let e=[...new Set(r.map(({version:e})=>e||`(no version)`))];throw Error(`"${r[0].name||t}" has no version "${n}". Available versions: ${u(e)}.`)}let[o,...c]=[...a].sort(s);return{api:o,otherMatches:c.length>0?c:void 0}}function j(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.filter(({name:e})=>e.toLowerCase().includes(n));return r.length>0?r:e.filter(({description:e})=>e.toLowerCase().includes(n))}function M({version:e,relativePath:t}){return{version:e||void 0,filePath:t}}function N(e,t=[]){return{api:e,otherMatches:t.length>0?t.map(M):void 0}}function P(e){return`Pass \`name\` (the API title, or a unique part of it) or \`filePath\` from ${f(e).listApis}.`}async function F(e,t){let{name:n,version:r,filePath:i}=e;if(!i&&!n)return I(e,t);let a=await y(t),o=i??n,s=a.find(e=>e.relativePath===o),c=s&&await b(t,s);if(c)return N(c);let l=await x(t);if(i){let e=O(l,i);throw Error(`No API found with filePath "${i}". `+(e?`Available file paths: ${e}. `:``)+`File paths come from ${f(t.mcpMode).listApis}.`)}let u=A(l,n??``,r);if(u)return N(u.api,u.otherMatches);let d=D(l,n??``);throw Error(d?`No API found matching "${n}". Available APIs: ${d}. Pass one of those names, or its \`filePath\`.`:`No API found matching "${n}".`)}async function I({path:e,method:t,version:n},r){let i=await x(r);if(i.length===0)throw Error(`This project documents no OpenAPI description.`);if(i.length===1){let[e]=i;if(n&&e.version!==n)throw Error(`"${e.name}" has no version "${n}". Available versions: ${e.version||`(no version)`}.`);return N(e)}if(!e||!t||i.length>10)throw Error(`${P(r.mcpMode)} Available APIs: ${D(i,``)}.`);let a=[],o=/* @__PURE__ */ new Set,d=[],f=t.toUpperCase();for(let t of i){let n=l(t.definition,e);if(!n)continue;let r=p(t.definition,n.path);r.includes(f)?(a.push(t),n.isTemplateMatch&&o.add(t)):r.length>0&&d.push({api:t,methods:r})}if(a.sort(s),a.length===0)throw R(i,d,e,t,r.mcpMode);let m=n?a.filter(e=>e.version===n):a;if(m.length===0){let t=[...new Set(a.map(({version:e})=>e||`(no version)`))];throw Error(`No API documenting "${c(e)}" has version "${n}". Available versions: ${u(t)}.`)}let h=m.filter(e=>!o.has(e));return L(h.length>0?h:m,e,t,r.mcpMode)}function L(e,t,n,r){let i=new Set(e.map(({name:e})=>o(e)));if(i.size>1){let a=[...i].map(t=>{let[n]=e.filter(e=>o(e.name)===t);return`"${n.name}" (${n.relativePath})`});throw Error(`${n.toUpperCase()} ${c(t)} is documented by ${i.size} APIs: ${u(a)}. Pass \`name\` or \`filePath\` from ${f(r).listApis} to pick one.`)}let[a,...s]=e;return N(a,s)}function R(e,t,n,r,i){if(t.length>0){let e=t.map(({api:e,methods:t})=>`"${e.name}" (${e.relativePath}) documents ${u(t)}.`).join(` `);return/* @__PURE__ */ Error(`No API documents ${r.toUpperCase()} ${c(n)}. ${e}`)}let{endpoints:a,search:o}=f(i);return/* @__PURE__ */ Error(`No API in this project documents ${c(n)}. Available APIs: ${D(e,``)}. Call ${a} with one of them, or ${o} with a keyword from the request.`)}export{D as describeAvailableApis,j as filterApisByName,A as findApiByNameAndVersion,x as loadApiCatalog,F as resolveApi};
@@ -1 +1 @@
1
- import{toolNameForMode as e}from"../codemode/tool-declarations.js";import{replaceServerVariables as t}from"@redocly/api-docs/server";const n=[`get`,`put`,`post`,`delete`,`options`,`head`,`patch`,`trace`,`query`,`x-query`],r=new Set(n);function i(e,t=`docs`){return!!e?.[`x-mcp`]?.[t]?.hide}function a(e,t=`docs`){return!!e?.[`x-mcp`]?.[t]?.hide}function o(e){if(!(`x-mcp`in e))return e;let{"x-mcp":t,...n}=e;return n}function s(e){return!e||i(e)?[]:Object.entries(e).filter(e=>{let[t,n]=e;return r.has(t.toLowerCase())&&typeof n==`object`&&!!n&&!i(n)})}function c(e){let t=[];for(let[n,r]of Object.entries(e.paths??{}))for(let[e,i]of s(r))t.push({path:n,method:e.toUpperCase(),summary:i.summary,description:i.description,security:i.security});return t}function l(e,t){return s(e.paths?.[t]).map(([e])=>e.toUpperCase()).sort()}function u(e){return Object.keys(e.paths??{}).filter(t=>l(e,t).length>0).sort()}function d(e){let t={};for(let[n,a]of Object.entries(e.paths??{})){if(typeof a!=`object`||!a||i(a))continue;let e=0,s=Object.entries(o(a)).flatMap(([t,n])=>r.has(t.toLowerCase())?i(n)?[]:(e+=1,[[t,typeof n==`object`&&n?o(n):n]]):[[t,n]]);e!==0&&(t[n]=Object.fromEntries(s))}return{...e,info:o(e.info),paths:t}}function f(e){return e.startsWith(`/`)?e:`/${e}`}function p(e){let[t]=e.replace(/^[a-z][a-z\d+.-]*:\/\/[^/?#]*/i,``).split(/[?#]/,1);return f(t)}function m(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)--t;return e.slice(0,t)}function h(e,n){let r=p(n),i=m(r),a=i.toLowerCase(),o=/* @__PURE__ */ new Set([r,i]);for(let n of e.servers??[]){let e=m(p(t(n)));e!==`/`&&a.startsWith(`${e.toLowerCase()}/`)&&o.add(i.slice(e.length))}return[...o]}function g(e){return e.split(`/`).slice(1)}const _=/^\{[^}]+\}$/;function v(e){return e.startsWith(`:`)?e.length>1:_.test(e)}function y(e){let t=[],n=0;for(let r=e.indexOf(`{`);r!==-1;r=e.indexOf(`{`,n)){let i=e.indexOf(`}`,r);if(i===-1)break;t.push(e.slice(n,r)),n=i+1}return t.push(e.slice(n)),t}function b(e,t){let n=y(e);if(n.length===1)return t===n[0];let r=n[0],i=n[n.length-1];if(!t.startsWith(r))return!1;let a=r.length;for(let e of n.slice(1,-1)){let n=t.indexOf(e,a+1);if(n===-1)return!1;a=n+e.length}return t.length-i.length>a&&t.endsWith(i)}function x(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return v(r)?_.test(e):b(e,r)})}function S(e){return e.map(e=>g(e.toLowerCase()))}function C(e,t){let n=g(e.toLowerCase());return t.some(e=>x(n,e))}function w(e,t){let n=f(t);if(e.paths?.[n])return{path:n,isTemplateMatch:!1};let r=h(e,t),i=u(e),a=r.find(e=>i.includes(e));if(a)return{path:a,isTemplateMatch:!1};for(let e of r.map(e=>e.toLowerCase())){let t=i.find(t=>t.toLowerCase()===e);if(t)return{path:t,isTemplateMatch:!1}}for(let e of S(r)){let t=i.filter(t=>C(t,[e]));if(t.length===1)return{path:t[0],isTemplateMatch:!0};if(t.length>1)return}}function T(e,t){return w(e,t)?.path??p(t)}function E(e,t){let n=S(h(e,t)),r=new Set(n.flat());return u(e).map(e=>({path:e,isMatch:C(e,n),sharedSegments:g(e.toLowerCase()).filter(e=>r.has(e)).length})).sort((e,t)=>Number(t.isMatch)-Number(e.isMatch)||t.sharedSegments-e.sharedSegments).map(({path:e})=>e)}const D=15;function O(e){let t=e.slice(0,15),n=e.length-t.length;return n>0?`${t.join(`, `)} (+${n} more)`:t.join(`, `)}function k(t){let n=n=>t===`code`?`site.${e(n,t)}`:n;return{endpoints:n(`get-endpoints`),search:n(`search`),listApis:n(`list-apis`),listPages:n(`list-pages`)}}function A(e,t,n,r){let i=E(e,n);if(i.length===0)return`Endpoint not found`;let{endpoints:a,search:o}=k(r);return`No path "${n}" in "${t}". Documented paths: ${O(i)}. Call ${a} for the full list, or ${o} with a keyword from the request.`}function j(e,t,n,r){let i=l(e,n);return i.length===0?`Endpoint not found`:`"${n}" in "${t}" documents no ${r.toUpperCase()}. Available methods: ${O(i)}.`}export{D as MAX_LISTED_CANDIDATES,n as OPERATION_METHODS,f as absolutePath,j as describeMethodMiss,A as describePathMiss,w as findDocumentedPath,O as formatCandidates,a as isDefinitionHidden,i as isEndpointHidden,T as matchDocumentedPath,k as recoveryToolNames,c as visibleEndpoints,l as visibleMethodsAt,s as visibleOperations,u as visiblePaths,d as withVisibleOperationsOnly,o as withoutXMcp};
1
+ import{OPERATION_METHODS as e}from"../../../../../../shared/constants/openapi-operation-methods.js";import{toolNameForMode as t}from"../codemode/tool-declarations.js";import{replaceServerVariables as n}from"@redocly/api-docs/server";const r=new Set(e);function i(e,t=`docs`){return!!e?.[`x-mcp`]?.[t]?.hide}function a(e,t=`docs`){return!!e?.[`x-mcp`]?.[t]?.hide}function o(e){if(!(`x-mcp`in e))return e;let{"x-mcp":t,...n}=e;return n}function s(e){return!e||i(e)?[]:Object.entries(e).filter(e=>{let[t,n]=e;return r.has(t.toLowerCase())&&typeof n==`object`&&!!n&&!i(n)})}function c(e){let t=[];for(let[n,r]of Object.entries(e.paths??{}))for(let[e,i]of s(r))t.push({path:n,method:e.toUpperCase(),summary:i.summary,description:i.description,security:i.security});return t}function l(e,t){return s(e.paths?.[t]).map(([e])=>e.toUpperCase()).sort()}function u(e){return Object.keys(e.paths??{}).filter(t=>l(e,t).length>0).sort()}function d(e){let t={};for(let[n,a]of Object.entries(e.paths??{})){if(typeof a!=`object`||!a||i(a))continue;let e=0,s=Object.entries(o(a)).flatMap(([t,n])=>r.has(t.toLowerCase())?i(n)?[]:(e+=1,[[t,typeof n==`object`&&n?o(n):n]]):[[t,n]]);e!==0&&(t[n]=Object.fromEntries(s))}return{...e,info:o(e.info),paths:t}}function f(e){return e.startsWith(`/`)?e:`/${e}`}function p(e){let[t]=e.replace(/^[a-z][a-z\d+.-]*:\/\/[^/?#]*/i,``).split(/[?#]/,1);return f(t)}function m(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)--t;return e.slice(0,t)}function h(e,t){let r=p(t),i=m(r),a=i.toLowerCase(),o=/* @__PURE__ */ new Set([r,i]);for(let t of e.servers??[]){let e=m(p(n(t)));e!==`/`&&a.startsWith(`${e.toLowerCase()}/`)&&o.add(i.slice(e.length))}return[...o]}function g(e){return e.split(`/`).slice(1)}const _=/^\{[^}]+\}$/;function v(e){return e.startsWith(`:`)?e.length>1:_.test(e)}function y(e){let t=[],n=0;for(let r=e.indexOf(`{`);r!==-1;r=e.indexOf(`{`,n)){let i=e.indexOf(`}`,r);if(i===-1)break;t.push(e.slice(n,r)),n=i+1}return t.push(e.slice(n)),t}function b(e,t){let n=y(e);if(n.length===1)return t===n[0];let r=n[0],i=n[n.length-1];if(!t.startsWith(r))return!1;let a=r.length;for(let e of n.slice(1,-1)){let n=t.indexOf(e,a+1);if(n===-1)return!1;a=n+e.length}return t.length-i.length>a&&t.endsWith(i)}function x(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return v(r)?_.test(e):b(e,r)})}function S(e){return e.map(e=>g(e.toLowerCase()))}function C(e,t){let n=g(e.toLowerCase());return t.some(e=>x(n,e))}function w(e,t){let n=f(t);if(e.paths?.[n])return{path:n,isTemplateMatch:!1};let r=h(e,t),i=u(e),a=r.find(e=>i.includes(e));if(a)return{path:a,isTemplateMatch:!1};for(let e of r.map(e=>e.toLowerCase())){let t=i.find(t=>t.toLowerCase()===e);if(t)return{path:t,isTemplateMatch:!1}}for(let e of S(r)){let t=i.filter(t=>C(t,[e]));if(t.length===1)return{path:t[0],isTemplateMatch:!0};if(t.length>1)return}}function T(e,t){return w(e,t)?.path??p(t)}function E(e,t){let n=S(h(e,t)),r=new Set(n.flat());return u(e).map(e=>({path:e,isMatch:C(e,n),sharedSegments:g(e.toLowerCase()).filter(e=>r.has(e)).length})).sort((e,t)=>Number(t.isMatch)-Number(e.isMatch)||t.sharedSegments-e.sharedSegments).map(({path:e})=>e)}const D=15;function O(e){let t=e.slice(0,15),n=e.length-t.length;return n>0?`${t.join(`, `)} (+${n} more)`:t.join(`, `)}function k(e){let n=n=>e===`code`?`site.${t(n,e)}`:n;return{endpoints:n(`get-endpoints`),search:n(`search`),listApis:n(`list-apis`),listPages:n(`list-pages`)}}function A(e,t,n,r){let i=E(e,n);if(i.length===0)return`Endpoint not found`;let{endpoints:a,search:o}=k(r);return`No path "${n}" in "${t}". Documented paths: ${O(i)}. Call ${a} for the full list, or ${o} with a keyword from the request.`}function j(e,t,n,r){let i=l(e,n);return i.length===0?`Endpoint not found`:`"${n}" in "${t}" documents no ${r.toUpperCase()}. Available methods: ${O(i)}.`}export{D as MAX_LISTED_CANDIDATES,f as absolutePath,j as describeMethodMiss,A as describePathMiss,w as findDocumentedPath,O as formatCandidates,a as isDefinitionHidden,i as isEndpointHidden,T as matchDocumentedPath,k as recoveryToolNames,c as visibleEndpoints,l as visibleMethodsAt,s as visibleOperations,u as visiblePaths,d as withVisibleOperationsOnly,o as withoutXMcp};
@@ -1 +1 @@
1
- import{describeMethodMiss as e,describePathMiss as t,matchDocumentedPath as n,visibleEndpoints as r,visibleOperations as i,withVisibleOperationsOnly as a,withoutXMcp as o}from"./openapi-document.js";import{GET_ENDPOINTS_SCHEMA as s,GET_ENDPOINT_INFO_SCHEMA as c,GET_FULL_API_DESCRIPTION_SCHEMA as l,GET_SECURITY_SCHEMES_SCHEMA as u,LIST_APIS_CALLABLE_SCHEMA as d,LIST_APIS_SCHEMA as f,getEndpointInfoToolSchema as p,getEndpointsToolSchema as m,getFullApiDescriptionToolSchema as h,getSecuritySchemesToolSchema as g}from"./schemas.js";import{apiTitleKey as _,countApiTitles as v,orderSharedTitles as y}from"./api-titles.js";import{filterApisByName as b,loadApiCatalog as x,resolveApi as S}from"./openapi-catalog.js";import{callableApis as C}from"../gateway/eligibility.js";import{inlineOperation as w,resolveOperation as T}from"./openapi-refs.js";import{replaceServerVariables as E}from"@redocly/api-docs/server";const D=8388608,O={apiName:`name`,api:`name`};function k(e){return e.map(e=>({...e,url:E(e)}))}async function A(e){return new Set((await C(e)).map(e=>e.entityKey))}const j=[{schema:f,schemaFor:async e=>(await A(e)).size>0?d:f,async execute(e,t){let n=e??{},{filter:r}=n,i=n.page??1,a=n.limit??300,o=await A(t),s=y(await x(t)),c=v(s),l=r?b(s,r):s,u=(i-1)*a;return{items:l.slice(u,u+a).map(({entityKey:e,relativePath:t,name:n,description:r,version:i,servers:a})=>({filePath:t,name:n,description:r,version:i,servers:k(a),ambiguousTitle:(c.get(_(n))??0)>1||void 0,callable:o.size>0?o.has(e):void 0})),limit:a,total:l.length,page:i,totalPages:Math.ceil(l.length/a)}}},{schema:s,schemaFor:e=>m(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:i}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:i,servers:k(n.servers),endpoints:r(n.definition)}}},{schema:c,schemaFor:e=>p(e.mcpMode),inputAliases:O,async execute(r,a){let s=r??{},{path:c,method:l}=s;if(!c||!l)throw Error(`Both "path" and "method" are required (e.g. path: "/tickets", method: "GET").`);let{api:u,otherMatches:d}=await S(s,a),{definition:f}=u,p=d?` Other definitions share this title: ${d.map(e=>`"${e.filePath}"`).join(`, `)}. Pass "filePath" to check them.`:``,m=n(f,c),h=f.paths?.[m],g=i(h);if(!h||g.length===0)throw Error(t(f,u.name,m,a.mcpMode)+p);let _=g.find(([e])=>e.toLowerCase()===l.toLowerCase())?.[1];if(!_)throw Error(e(f,u.name,m,l)+p);let v={operation:o(_),pathParams:h.parameters??[],definition:f},{operation:y,components:b}=(a.mcpMode===`code`?w(v,1048576):void 0)??T(v),x={api:u.name,version:u.version,filePath:u.relativePath,otherMatches:d,servers:k(u.servers),endpoint:{path:m,method:l.toUpperCase(),...y},globalSecurity:f.security??[],securitySchemes:f.components?.securitySchemes??{},components:b},C=JSON.stringify(x,null,2).length;if(C>D)throw Error(`${l.toUpperCase()} ${m} is ${C} bytes, over the ${D} byte limit.`);return x}},{schema:u,schemaFor:e=>g(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:r}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:r,securitySchemes:n.definition.components?.securitySchemes??{},security:n.definition.security??[]}}},{schema:l,schemaFor:e=>h(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:r}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:r,definition:a(n.definition)}}}];export{j as openApiTools};
1
+ import{GET_ENDPOINTS_SCHEMA as e,GET_ENDPOINT_INFO_SCHEMA as t,GET_FULL_API_DESCRIPTION_SCHEMA as n,GET_SECURITY_SCHEMES_SCHEMA as r,LIST_APIS_CALLABLE_SCHEMA as i,LIST_APIS_SCHEMA as a,getEndpointInfoToolSchema as o,getEndpointsToolSchema as s,getFullApiDescriptionToolSchema as c,getSecuritySchemesToolSchema as l}from"./schemas.js";import{apiTitleKey as u,countApiTitles as d,orderSharedTitles as f}from"./api-titles.js";import{describeMethodMiss as p,describePathMiss as m,matchDocumentedPath as h,visibleEndpoints as g,visibleOperations as _,withVisibleOperationsOnly as v,withoutXMcp as y}from"./openapi-document.js";import{filterApisByName as b,loadApiCatalog as x,resolveApi as S}from"./openapi-catalog.js";import{callableApis as C}from"../gateway/eligibility.js";import{inlineOperation as w,resolveOperation as T}from"./openapi-refs.js";import{replaceServerVariables as E}from"@redocly/api-docs/server";const D=8388608,O={apiName:`name`,api:`name`};function k(e){return e.map(e=>({...e,url:E(e)}))}async function A(e){return new Set((await C(e)).map(e=>e.entityKey))}const j=[{schema:a,schemaFor:async e=>(await A(e)).size>0?i:a,async execute(e,t){let n=e??{},{filter:r}=n,i=n.page??1,a=n.limit??300,o=await A(t),s=f(await x(t)),c=d(s),l=r?b(s,r):s,p=(i-1)*a;return{items:l.slice(p,p+a).map(({entityKey:e,relativePath:t,name:n,description:r,version:i,servers:a})=>({filePath:t,name:n,description:r,version:i,servers:k(a),ambiguousTitle:(c.get(u(n))??0)>1||void 0,callable:o.size>0?o.has(e):void 0})),limit:a,total:l.length,page:i,totalPages:Math.ceil(l.length/a)}}},{schema:e,schemaFor:e=>s(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:r}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:r,servers:k(n.servers),endpoints:g(n.definition)}}},{schema:t,schemaFor:e=>o(e.mcpMode),inputAliases:O,async execute(e,t){let n=e??{},{path:r,method:i}=n;if(!r||!i)throw Error(`Both "path" and "method" are required (e.g. path: "/tickets", method: "GET").`);let{api:a,otherMatches:o}=await S(n,t),{definition:s}=a,c=o?` Other definitions share this title: ${o.map(e=>`"${e.filePath}"`).join(`, `)}. Pass "filePath" to check them.`:``,l=h(s,r),u=s.paths?.[l],d=_(u);if(!u||d.length===0)throw Error(m(s,a.name,l,t.mcpMode)+c);let f=d.find(([e])=>e.toLowerCase()===i.toLowerCase())?.[1];if(!f)throw Error(p(s,a.name,l,i)+c);let g={operation:y(f),pathParams:u.parameters??[],definition:s},{operation:v,components:b}=(t.mcpMode===`code`?w(g,1048576):void 0)??T(g),x={api:a.name,version:a.version,filePath:a.relativePath,otherMatches:o,servers:k(a.servers),endpoint:{path:l,method:i.toUpperCase(),...v},globalSecurity:s.security??[],securitySchemes:s.components?.securitySchemes??{},components:b},C=JSON.stringify(x,null,2).length;if(C>D)throw Error(`${i.toUpperCase()} ${l} is ${C} bytes, over the ${D} byte limit.`);return x}},{schema:r,schemaFor:e=>l(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:r}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:r,securitySchemes:n.definition.components?.securitySchemes??{},security:n.definition.security??[]}}},{schema:n,schemaFor:e=>c(e.mcpMode),inputAliases:O,async execute(e,t){let{api:n,otherMatches:r}=await S(e??{},t);return{api:n.name,version:n.version,filePath:n.relativePath,otherMatches:r,definition:v(n.definition)}}}];export{j as openApiTools};
@@ -1,4 +1,4 @@
1
- import{readIgnoredRouteSlugs as e}from"../../ignored-routes.js";import{publicOrigin as t}from"../../../../utils/request-origin.js";import{recoveryToolNames as n}from"./openapi-document.js";import{MAX_PAGE_LINES as r}from"./pages-constants.js";import{GET_PAGE_SCHEMA as i,GREP_PAGES_SCHEMA as a,LIST_PAGES_SCHEMA as o,grepPagesToolSchema as s,listPagesToolSchema as c}from"./schemas.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:o,schemaFor:e=>c(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:i,async execute(e,i){let{url:a,startLine:o,lines:s}=e??{};if(typeof a!=`string`||a.trim()===``)throw Error(`The "url" parameter is required: a page URL or path.`);let c=t(i.request),l=h(a,c),u=l===null?null:await C(l,i);if(l===null||u===null)throw Error(`No page you can read is at "${a}": it does not exist, or your access does not include it. Do not describe it from other pages. Call ${n(i.mcpMode).listPages} to see the pages you can read.`);let d=D(u.text),f=Math.max(1,Math.floor(o??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(s,200,r),m=Math.min(d.length,f+p-1);return{url:g(l,c),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:a,schemaFor:e=>s(e.mcpMode),async execute(e,r){let{query:i,section:a,maxMatches:o}=e??{};if(typeof i!=`string`||i===``)throw Error(`The "query" parameter is required: a text to find.`);let s=t(r.request),c,u;if(a){let{sections:e,pages:t}=await p(r),i=d(e,a,s);if(!i)throw Error(`No section "${a}". Call ${n(r.mcpMode).listPages} to see the sections.`);let o=new Set(l(i.nodes));i.link&&o.add(i.link),c=t.filter(e=>o.has(e.slug)),u=i.title}else c=(await m(r)).pages;let f=T(o,20,100),h=i.toLowerCase(),_=c.length,v=[];for(let e of c){let t=(await r.pageMarkdown.readPage(e.slug))?.text??``;if(t.toLowerCase().includes(h))for(let[n,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(e.slug,s),title:e.title,line:n+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 "${i}". All ${_} pages there were searched.`:`contains "${i}". All ${_} pages were searched. API references are not searched: use ${n(r.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(`
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 of s){let t=(await n.pageMarkdown.readPage(e.slug))?.text??``;if(t.toLowerCase().includes(h))for(let[n,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(e.slug,o),title:e.title,line:n+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{SUBMIT_FEEDBACK_TOOL_NAME as e}from"../../constants.js";import{toolNameForMode as t}from"../codemode/tool-declarations.js";import{GRAPHQL_LIST_SCOPES as n,GRAPHQL_TYPE_KINDS as r}from"./graphql-constants.js";import{OPERATION_METHODS as i}from"./openapi-document.js";import{MAX_PAGE_LINES as a}from"./pages-constants.js";const o={type:`string`,nullable:!0},s={limit:{type:`number`},total:{type:`number`},page:{type:`number`},totalPages:{type:`number`}},c={codemodeType:`OpenApiServer[]`},l={codemodeType:`OpenApiSecurityRequirement[]`},u={codemodeType:`Record<string, OpenApiSecurityScheme>`},d={codemodeType:`OpenApiDocument`},f={codemodeType:`OpenApiOperation & { path: string; method: string }`},p={codemodeType:`OpenApiComponents`,description:"Components the endpoint references. A `$ref` in `endpoint` resolves against the root of the result."},m={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`}}}}},h="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.",g={readOnlyHint:!0,destructiveHint:!1,openWorldHint:!1};function _(e,t){let n={query:{type:`string`,description:`What to find, as a few words or a short question.`,minLength:1}};return e.length>0&&(n.product={type:`string`,description:`Optional product name to filter search results by specific product.`,enum:[...e,null],nullable:!0}),t.length>0&&(n.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:[...t,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:n},annotations:g,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:g,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:e,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 \`${t(`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:n,filePath:r}=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:[...i.map(e=>e.toUpperCase()),...i],minLength:1},version:n,filePath:r}}}function T(e){let t={name:{type:`string`},description:{type:`string`},version:{type:`string`},servers:c,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&&(t.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:g,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`,`description`,`version`,`servers`,`filePath`],properties:t}},...s}}}}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. ${h}`,summary:`Get all endpoints for an API.`,schema:C(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoints`],properties:{api:{type:`string`},version:{type:`string`},...m,servers:c,endpoints:{type:`array`,items:{type:`object`,required:[`path`,`method`],properties:{path:{type:`string`},method:{type:`string`},summary:o,description:o,security:l}}}}}}}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. ${h}`,summary:`Get the details of an endpoint.`,schema:w(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoint`,`globalSecurity`,`securitySchemes`],properties:{api:{type:`string`},version:{type:`string`},...m,servers:c,endpoint:f,globalSecurity:l,securitySchemes:u,components:p}}}}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. ${h}`,summary:`Get the security schemes for an API.`,schema:C(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`securitySchemes`,`security`],properties:{api:{type:`string`},version:{type:`string`},...m,securitySchemes:u,security:l}}}}const N=M(`tools`);function P(e){return{name:`get-full-api-description`,title:`Get full API description`,description:`Get the complete OpenAPI description. ${h}`,summary:`Get the complete OpenAPI description.`,schema:C(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`definition`],properties:{api:{type:`string`},version:{type:`string`},...m,definition:d}}}}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:[...r,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:[...n,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:g,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`],properties:{name:{type:`string`},description:o}}},...s}}},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:g,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:[...r]},name:{type:`string`},description:o,type:{type:`string`},args:{type:`string`},directives:{type:`string`}}}},...s}}};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 ${t(`get-graphql-type-list`,e)} with \`referencesType\`.`,summary:`Get the SDL of one GraphQL type or operation.`,schema:R,annotations:g,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 ${t(`get-graphql-type-list`,e)} (filter/paginate) plus targeted ${t(`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:g,outputSchema:{type:`string`}}}const G=W(`tools`);function K(e){return`Section id from ${t(`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 ${t(`list-pages`,e)} or ${t(`grep-pages`,e)}`},title:{type:`string`},url:{type:`string`},pageCount:{type:`number`,description:`Pages inside the section`}}}}function J(e){let t=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:g,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:t}}}},section:{type:`object`,properties:{id:{type:`string`},title:{type:`string`}}},items:{type:`array`,items:t}}}}}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:a,description:`Number of lines to return (default 200)`}}},annotations:g,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:g,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,g as READ_ONLY_ANNOTATIONS,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 +1 @@
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{stripPathPrefix as i}from"../../../../../shared/path-prefix.js";import{notFoundResponse as a}from"../../../../../server/plugin-context.js";const o={"Cache-Control":`no-store`},s=/* @__PURE__ */ new Map;function c(e,n){let r=n.metadata?.mockServer;return{...e,...t(r)?r:{}}}function l(e,t){let{specType:n,routeSlug:i}=e.metadata??{};return n!==`openapi`||typeof i!=`string`||c(t,e).off===!0?null:r(i)}function u(e,t,n=void 0){let r=null,i=-1;for(let a of e){let e=l(a,n);e===null||e.length<=i||d(e,t)&&(r={api:a,path:t.slice(e.length)||`/`},i=e.length)}return r}function d(e,t){return t===e||t.startsWith(`${e}/`)}function f(e,t,{createMockServer:n}){let r=s.get(t.key);if(r&&r.dataHash===t.dataHash)return r.handler;let{strictExamples:i,errorIfForcedExampleNotFound:a}=c(e.config.mockServer,t),o=e.entities.load(t.key).then(e=>n(structuredClone(e),{strictExamples:i,errorIfForcedExampleNotFound:a}));return s.set(t.key,{dataHash:t.dataHash,handler:o}),o.catch(()=>s.delete(t.key)),o}async function p(e,t){let i=await e.entities.list({type:`api`}),a=i.filter(({metadata:e})=>e?.specType!==`openapi`||e.routeSlug!==void 0?!1:d(r(n(String(e.sourcePath))),t));return a.length===0?i:(await Promise.all(a.map(t=>e.entities.load(t.key))),e.entities.list({type:`api`}))}function m(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 h(e){return(i(new URL(e.req.url).pathname)??``).slice(6)||`/`}async function g(t,n){if(!e(n.config,`mockServer`))return a();let r=h(t),i=u(await p(n,r),r,n.config.mockServer);if(!i||!n.isSlugVisible(String(i.api.metadata?.routeSlug)))return a();let s;try{s=await import(`@redocly/mock-server`)}catch{return new Response(`Mock server is not available on this host`,{status:501})}let c=await(await f(n,i.api,s))(m(t,i.path));return new Response(c.body?new Uint8Array(c.body):null,{status:c.statusCode,headers:{...c.headers,...o}})}export{u as matchMockApi,g as mock,m as toMockRequest};
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};
@@ -7,8 +7,9 @@ import { SIDEBAR_ROUTE_DEP_KEY } from '../../../../shared/constants/route-deps.j
7
7
  export declare const SIDEBAR_PLUGIN_ID = "internal.sidebar";
8
8
  export declare const SIDEBAR_AGGREGATOR_LOADER_ID: "internal.sidebar:aggregate";
9
9
  export { SIDEBAR_ROUTE_DEP_KEY };
10
+ /** As in classic Realm, any file name that ends in `sidebars.yaml` (`api.sidebars.yaml`, `api_sidebars.yaml`). */
10
11
  export declare const SIDEBAR_FILENAME_REGEX: RegExp;
11
- /** A folder's own sidebar; a named `*.sidebars.yaml` is not one. */
12
+ /** A folder's own sidebar; a named `*sidebars.yaml` is not one. */
12
13
  export declare const FOLDER_SIDEBAR_FILENAME_REGEX: RegExp;
13
14
  export type ResolvedSidebarItem = {
14
15
  type?: SidebarItemType;
@@ -1,2 +1,2 @@
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{compareStrings as i}from"../../../../shared/utils/compare-strings.js";import"../../../../shared/constants/l10n/defaults.js";import{NAV_ITEM_RBAC as a}from"../../../../shared/rbac/types.js";import{isObject as o}from"../../../../shared/utils/is-object.js";import{toLocaleSlug as s}from"../../../../shared/utils/l10n.js";import{resolveContentPath as c}from"../../../../shared/utils/resolve-content-path.js";import{isLocalImagePath as l}from"../assets/extensions.js";import{splitUrlSuffix as u}from"../../../../shared/utils/routes/split-url-suffix.js";import{resolvePageTarget as d}from"../../../../shared/utils/routes/resolve-page-target.js";import{toPublicVersionedSlug as f}from"../../../../shared/constants/versions.js";import{collectVersionGroups as p,findVersionedDirectories as ee}from"../../../versions/version-groups.js";import{publicLink as m}from"../../../versions/public-link.js";import{linkedPageAccess as h}from"../../utils/link-access.js";import{safeDecodeURI as g}from"../../../../shared/utils/safe-decode-uri.js";import{joinSrcSet as _,parseSrcSet as v}from"../assets/srcset.js";import{bundleSidebar as y,bundleSidebarEntries as te,collectSidebarLinkRefs as b,collectSidebarRefTargets as ne,stampDefaultVersions as x}from"./bundle.js";import{SIDEBAR_CONTRIBUTIONS_ENTITY_TYPE as S,sidebarStartEntityKey as re}from"./contributions.js";import{applySubtree as C}from"./subtree.js";import{collectSlugOverrides as w}from"../../utils/slug-overrides.js";import{SIDEBAR_BACK_LINK_ROUTE_DEP_KEY as ie,SIDEBAR_BREADCRUMBS_ROUTE_DEP_KEY as T,SIDEBAR_ROUTE_DEP_KEY as E,localizedSidebarDepKey as D}from"../../../../shared/constants/route-deps.js";import{SITE_START_ENTITY_KEY as ae}from"../../../../shared/constants/site-start.js";import{posix as O}from"node:path";import{REDOCLY_TEAMS_RBAC as k}from"@redocly/config";const A=`internal.sidebar`,j=r(A,`aggregate`),M=/(^|\/)(?:[^/]*\.)?sidebars\.ya?ml$/i,N=/(^|\/)sidebars\.ya?ml$/i,P=`sidebars.yaml`,F=`redocly.yaml`;function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Array.isArray(e.tabs)}function L(e){if(Array.isArray(e))return e.find(e=>R(e.label)!==void 0)?.label}function R(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function z(e){let t=((e??``).split(/[?#]/)[0]?.split(`/`).filter(Boolean).pop()??``).replace(/[-_]+/g,` `).trim();return t.charAt(0).toUpperCase()+t.slice(1)}async function B(e,t){let n=[];for(let r of e){let e=r.link?t.subtreeKeyOf(r.link):void 0,i=e?await t.loadEntity(e):void 0,o=r.tabId!==void 0,s=o?{...r,isGroup:!0,label:r.label??L(i)}:r,c=i===void 0?[s]:C(s,i);for(let e of c){let i=e[`redocly::nav-item-rbac`]??r[`redocly::nav-item-rbac`],s=e[k]??(i===void 0&&e.link!==void 0?t.accessOf(e.link)??void 0:void 0);n.push({type:e.type,expanded:e.expanded,selectFirstItemOnExpand:e.selectFirstItemOnExpand,external:e.external,target:e.target,languageInsensitive:e.languageInsensitive,icon:e.icon===void 0?void 0:await t.resolveAsset(e.icon),srcSet:e.srcSet===void 0?void 0:await V(e.srcSet,t),items:e.items?await B(e.items,t):void 0,tab:e.tab,tabId:e.tabId,menu:e.menu?await B(e.menu,t):void 0,label:o?e.label??z(e.link):e.label,labelTranslationKey:e.labelTranslationKey,link:e.link!==void 0&&e.versionGroup!==void 0&&e.version!==void 0?f(e.link,e.versionGroup,e.version,e.isDefaultVersion===!0):e.link,separatorLine:e.separatorLine,linePosition:e.linePosition,variant:e.variant,menuStyle:e.menuStyle,sublabel:e.sublabel,version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel,httpVerb:e.httpVerb,deprecated:e.deprecated,badges:e.badges,[k]:s,[a]:i})}}return n}async function V(e,t){let n=v(e);if(n===null)return e;let r=await Promise.all(n.map(async e=>Object.assign(e,{src:await t.resolveAsset(e.src)})));return _(r)}function H(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;return{async resolve(r){if(!l(r))return r;let i=await e.resolveImageReference(r,``),a=c(g(r),``);a!==null&&t.set(`file:${a}`,{kind:`file`,path:a});for(let e of i.entityDeps)t.set(e.kind===`file`?`file:${e.path}`:`entity:${e.key}`,e);for(let e of i.assetUsages)n.set(e.path,e);return i.result.kind===`assetRef`?i.result.url:r},collected(){return{entityDeps:[...t.values()],assetUsages:[...n.values()]}}}}function U(e){return e.tabId!==void 0}function W(e){return U(e)&&e.link!==void 0}function G(e){return{tabId:e.tabId,version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel,[k]:e[k],[a]:e[a]}}function K(e){return{...G(e),label:e.label,labelTranslationKey:e.labelTranslationKey,link:e.link,icon:e.icon,items:e.items??[]}}function q(e){return{...G(e),label:e.label,labelTranslationKey:e.labelTranslationKey,link:e.menu?void 0:e.link,icon:e.icon,items:e.menu?void 0:e.items??[],menu:e.menu?.filter(W).map(K)}}const J=t(j,async e=>{let t=H(e.markdown),{locale:n,slugOverrides:r={},versionedDirectories:i=[]}=e.args,a=t=>e.routes.bySlug(t)?.sidebarSubtreeEntityKey,o=i.length===0?/* @__PURE__ */ new Map:await p({io:e.io,routes:e.routes,versionedDirectories:i}),c=await B(e.args.nodes,{loadEntity:t=>e.entities.load(t),subtreeKeyOf:e=>(n===void 0?void 0:a(r[e]??s(e,n)))??a(e),accessOf:t=>h(t,e.routes,o),resolveAsset:t.resolve});return{value:e.args.nodes.some(e=>e.tab)?{tabs:c.filter(U).map(q)}:c,...t.collected()}});async function oe(e){let t=await e.loadEntity(e.subtreeKey);return B(C({link:e.routeSlug,...e.version},t),{loadEntity:e.loadEntity,subtreeKeyOf:()=>void 0,accessOf:()=>void 0,resolveAsset:async e=>e})}function se(e){let t=typeof e==`string`?e:o(e)?e.path:void 0;return typeof t==`string`&&t.trim()!==``?t.trim():null}function Y(e){return[e.originPluginId,e.originFilePath,e.routeId].join(`\0`)}async function X(e,t){let n=/* @__PURE__ */ new Map;for(let r of e.assignedRouteSlugs){let e=t.routes.bySlug(r),i=e?.originFilePath===null?e.sidebarSubtreeEntityKey:null;if(!i||await t.entities.get(i)===null)continue;let a=e=>{for(let i of e){let e=i.link===void 0?void 0:t.routes.bySlug(i.link);e!==void 0&&!n.has(e.slug)&&n.set(e.slug,r),i.items&&a(i.items)}};a(C({link:r},await t.entities.load(i)))}return n}function ce(e,t){for(let n of t)for(let[t,r]of n){let n=e.get(r);n!==void 0&&!e.has(t)&&e.set(t,n)}}async function le(e){let t=[];for(let n of await e.list({type:S}))t.push(...await e.load(n.key));return t}function ue(e,t=[]){let n=[];for(let[r,i]of e.entries()){if(t[r]?.link!==i.link)break;n.push(i)}return n}async function de(e,t,n,r,i){let a=await Promise.all(e.map(async e=>{let r=fe(e,t,n);return r===null?null:{item:e,link:r.link,label:await Z(e,r,i)}})),o=/* @__PURE__ */ new Map;for(let{item:e,link:t,label:n}of a.filter(e=>e!==null))for(let i of e.linkedSidebars??[]){let e=c(i,F),a=e===null?void 0:r.get(e);a!==void 0&&!o.has(a)&&o.set(a,{label:n,link:t})}return o}function fe(e,t,n){if(typeof e.href==`string`&&e.href.trim()!==``)return{link:e.href.trim()};if(typeof e.page!=`string`||e.page.trim()===``)return null;let{path:r,suffix:i,anchor:a}=u(e.page.trim()),o=d(r,F,t);if(o.kind!==`found`)return null;let s=o.value;return{link:`${m(s,n)}${i}`,anchor:a,route:s}}async function Z(e,t,n){let r=R(e.label)??R(e.group)??t.anchor;if(r!==void 0)return r;let i=t.route?.sidebarSubtreeEntityKey,a=i?await n(i):void 0;return(o(a)?R(a.label):void 0)??t.link}function Q(e,t){for(let n of e){if(!t(n))continue;if(n.link!==void 0&&n.languageInsensitive!==!0)return n;let e=Q([...n.items??[],...n.menu??[]],t);if(e!==null)return e}return null}function pe(e,t){return Q(e,e=>e.version===void 0||e.version===t)?.link??null}function $(e){let t=Q(e,e=>e.version===void 0||e.isDefaultVersion===!0);return t?.link===void 0?null:t.versionGroup!==void 0&&t.version!==void 0?f(t.link,t.versionGroup,t.version,!0):t.link}function me(e){let[t]=e;if(t===void 0)return null;let n=t.path.split(`/`).length;return(e.find(({path:e})=>e.split(`/`).length===n&&N.test(e))??t).link}function he(e){let t=null;for(let{slug:n,originFilePath:r,locale:a,versionGroup:o}of e)r!==null&&a===``&&o===null&&(t===null||n.length<t.length||n.length===t.length&&i(n,t)<0)&&(t=n);return t}const ge=e({id:A,version:`1.24.0`,content:{filter:{match:e=>M.test(e)},async extractFile(e,t){let n=await t.io.readFile(e.path);return{routes:[],linkRefs:await b({source:n,filePath:e.path,readFile:t.io.readFile})}}},async finalize(e){let t=[],r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=[],c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,d=[],f=await Promise.all(e.files.map(async t=>({path:t.path,source:await e.io.readFile(t.path)}))),m=e.routes.all(),g=w(m,e.localeContext),_=ee(m),v=_.length>0?_:void 0;f.sort((e,t)=>e.path.split(`/`).length-t.path.split(`/`).length);let b=new Map(f.map(({path:e,source:t})=>[e,t])),S=/* @__PURE__ */ new Map;for(let{path:e}of f)N.test(e)&&S.set(O.dirname(e),e);let C=/* @__PURE__ */ new Set;for(let{path:e,source:t}of f)for(let n of ne(t,e))C.add(n);let A={routes:e.routes,report:e=>r.push(e),readFile:async t=>b.get(t)??e.io.readFile(t),exists:t=>e.io.exists(t),sidebarByDirectory:S},j=async(n,r)=>{if(n.nodes.length===0)return;await x({io:e.io,routes:e.routes,logger:e.logger,nodes:n.nodes,versionedDirectories:_});let i=J.withArgs({nodes:n.nodes,versionedDirectories:v},r===void 0?void 0:{metadata:{sourcePath:r}});t.push(i),l.set(i,n.nodes);let a=/* @__PURE__ */ new Map;for(let r of e.localeContext.locales){let e=J.withArgs({nodes:n.nodes,locale:r,slugOverrides:g[r]??{},versionedDirectories:v});t.push(e),a.set(r,e)}return c.set(i,a),i};for(let{path:t,source:n}of f){if(C.has(t))continue;let c=await y({...A,file:{path:t},source:n}),l=await j(c,t);if(l===void 0)continue;a.set(t,l);let u=t.startsWith(`@l10n/`)?null:$(c.nodes);u!==null&&d.push({path:t,link:u}),s.push(await X(c,e));for(let e of c.assignedRouteSlugs){let n=o.get(e);n!==void 0&&r.push({code:`sidebar/route-conflict`,message:`Page "${e}" is in sidebars ${n} and ${t}; it shows ${t}.`,location:{filePath:t}}),i.set(e,l),o.set(e,t)}}ce(i,s);let M=new Map(m.map(e=>[e.slug,e]));for(let[t,n]of Object.entries(e.routes.metadata(`sidebar`))){let e=M.get(t);if(e===void 0||e.originFilePath===null)continue;let o=se(n);if(o===null)continue;let s=O.normalize(o.startsWith(`/`)?o.slice(1):O.join(O.dirname(e.originFilePath),o)),c=a.get(s);if(c===void 0){r.push({code:`sidebar/missing-target`,message:`Front matter sidebar "${o}" is not a sidebar file of this project.`,location:{filePath:e.originFilePath}});continue}i.set(e.slug,c)}let F=await le(e.entities),I=/* @__PURE__ */ new Set,L=/* @__PURE__ */ new Map,R=/* @__PURE__ */ new Map;for(let t of F){let n=i.get(t.route);if(n===void 0){let r=await te({...A,file:{path:P},entries:t.entries});if(n=await j(r),n===void 0)continue;let a=(await X(r,e)).keys();for(let e of[...r.assignedRouteSlugs,...a])i.has(e)||(i.set(e,n),I.add(e))}let r=L.get(n);L.set(n,r===void 0?t.backLink??null:r!==null&&r.link===t.backLink?.link?r:null);let a=R.get(n);R.set(n,a===void 0?t.breadcrumbs??[]:ue(a,t.breadcrumbs))}if(f.length===0&&m.length>0){let e=await y({...A,file:{path:P},source:`- directory: .
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{compareStrings as i}from"../../../../shared/utils/compare-strings.js";import"../../../../shared/constants/l10n/defaults.js";import{NAV_ITEM_RBAC as a}from"../../../../shared/rbac/types.js";import{isObject as o}from"../../../../shared/utils/is-object.js";import{toLocaleSlug as s}from"../../../../shared/utils/l10n.js";import{resolveContentPath as c}from"../../../../shared/utils/resolve-content-path.js";import{isLocalImagePath as l}from"../assets/extensions.js";import{splitUrlSuffix as u}from"../../../../shared/utils/routes/split-url-suffix.js";import{resolvePageTarget as d}from"../../../../shared/utils/routes/resolve-page-target.js";import{toPublicVersionedSlug as f}from"../../../../shared/constants/versions.js";import{collectVersionGroups as p,findVersionedDirectories as ee}from"../../../versions/version-groups.js";import{publicLink as m}from"../../../versions/public-link.js";import{linkedPageAccess as h}from"../../utils/link-access.js";import{safeDecodeURI as g}from"../../../../shared/utils/safe-decode-uri.js";import{joinSrcSet as _,parseSrcSet as v}from"../assets/srcset.js";import{bundleSidebar as y,bundleSidebarEntries as te,collectSidebarLinkRefs as b,collectSidebarRefTargets as ne,stampDefaultVersions as x}from"./bundle.js";import{SIDEBAR_CONTRIBUTIONS_ENTITY_TYPE as S,sidebarStartEntityKey as re}from"./contributions.js";import{applySubtree as C}from"./subtree.js";import{collectSlugOverrides as w}from"../../utils/slug-overrides.js";import{SIDEBAR_BACK_LINK_ROUTE_DEP_KEY as ie,SIDEBAR_BREADCRUMBS_ROUTE_DEP_KEY as T,SIDEBAR_ROUTE_DEP_KEY as E,localizedSidebarDepKey as D}from"../../../../shared/constants/route-deps.js";import{SITE_START_ENTITY_KEY as ae}from"../../../../shared/constants/site-start.js";import{posix as O}from"node:path";import{REDOCLY_TEAMS_RBAC as k}from"@redocly/config";const A=`internal.sidebar`,j=r(A,`aggregate`),M=/sidebars\.ya?ml$/i,N=/(^|\/)sidebars\.ya?ml$/i,P=`sidebars.yaml`,F=`redocly.yaml`;function I(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Array.isArray(e.tabs)}function L(e){if(Array.isArray(e))return e.find(e=>R(e.label)!==void 0)?.label}function R(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function z(e){let t=((e??``).split(/[?#]/)[0]?.split(`/`).filter(Boolean).pop()??``).replace(/[-_]+/g,` `).trim();return t.charAt(0).toUpperCase()+t.slice(1)}async function B(e,t){let n=[];for(let r of e){let e=r.link?t.subtreeKeyOf(r.link):void 0,i=e?await t.loadEntity(e):void 0,o=r.tabId!==void 0,s=o?{...r,isGroup:!0,label:r.label??L(i)}:r,c=i===void 0?[s]:C(s,i);for(let e of c){let i=e[`redocly::nav-item-rbac`]??r[`redocly::nav-item-rbac`],s=e[k]??(i===void 0&&e.link!==void 0?t.accessOf(e.link)??void 0:void 0);n.push({type:e.type,expanded:e.expanded,selectFirstItemOnExpand:e.selectFirstItemOnExpand,external:e.external,target:e.target,languageInsensitive:e.languageInsensitive,icon:e.icon===void 0?void 0:await t.resolveAsset(e.icon),srcSet:e.srcSet===void 0?void 0:await V(e.srcSet,t),items:e.items?await B(e.items,t):void 0,tab:e.tab,tabId:e.tabId,menu:e.menu?await B(e.menu,t):void 0,label:o?e.label??z(e.link):e.label,labelTranslationKey:e.labelTranslationKey,link:e.link!==void 0&&e.versionGroup!==void 0&&e.version!==void 0?f(e.link,e.versionGroup,e.version,e.isDefaultVersion===!0):e.link,separatorLine:e.separatorLine,linePosition:e.linePosition,variant:e.variant,menuStyle:e.menuStyle,sublabel:e.sublabel,version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel,httpVerb:e.httpVerb,deprecated:e.deprecated,badges:e.badges,[k]:s,[a]:i})}}return n}async function V(e,t){let n=v(e);if(n===null)return e;let r=await Promise.all(n.map(async e=>Object.assign(e,{src:await t.resolveAsset(e.src)})));return _(r)}function H(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;return{async resolve(r){if(!l(r))return r;let i=await e.resolveImageReference(r,``),a=c(g(r),``);a!==null&&t.set(`file:${a}`,{kind:`file`,path:a});for(let e of i.entityDeps)t.set(e.kind===`file`?`file:${e.path}`:`entity:${e.key}`,e);for(let e of i.assetUsages)n.set(e.path,e);return i.result.kind===`assetRef`?i.result.url:r},collected(){return{entityDeps:[...t.values()],assetUsages:[...n.values()]}}}}function U(e){return e.tabId!==void 0}function W(e){return U(e)&&e.link!==void 0}function G(e){return{tabId:e.tabId,version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel,[k]:e[k],[a]:e[a]}}function K(e){return{...G(e),label:e.label,labelTranslationKey:e.labelTranslationKey,link:e.link,icon:e.icon,items:e.items??[]}}function q(e){return{...G(e),label:e.label,labelTranslationKey:e.labelTranslationKey,link:e.menu?void 0:e.link,icon:e.icon,items:e.menu?void 0:e.items??[],menu:e.menu?.filter(W).map(K)}}const J=t(j,async e=>{let t=H(e.markdown),{locale:n,slugOverrides:r={},versionedDirectories:i=[]}=e.args,a=t=>e.routes.bySlug(t)?.sidebarSubtreeEntityKey,o=i.length===0?/* @__PURE__ */ new Map:await p({io:e.io,routes:e.routes,versionedDirectories:i}),c=await B(e.args.nodes,{loadEntity:t=>e.entities.load(t),subtreeKeyOf:e=>(n===void 0?void 0:a(r[e]??s(e,n)))??a(e),accessOf:t=>h(t,e.routes,o),resolveAsset:t.resolve});return{value:e.args.nodes.some(e=>e.tab)?{tabs:c.filter(U).map(q)}:c,...t.collected()}});async function oe(e){let t=await e.loadEntity(e.subtreeKey);return B(C({link:e.routeSlug,...e.version},t),{loadEntity:e.loadEntity,subtreeKeyOf:()=>void 0,accessOf:()=>void 0,resolveAsset:async e=>e})}function se(e){let t=typeof e==`string`?e:o(e)?e.path:void 0;return typeof t==`string`&&t.trim()!==``?t.trim():null}function Y(e){return[e.originPluginId,e.originFilePath,e.routeId].join(`\0`)}async function X(e,t){let n=/* @__PURE__ */ new Map;for(let r of e.assignedRouteSlugs){let e=t.routes.bySlug(r),i=e?.originFilePath===null?e.sidebarSubtreeEntityKey:null;if(!i||await t.entities.get(i)===null)continue;let a=e=>{for(let i of e){let e=i.link===void 0?void 0:t.routes.bySlug(i.link);e!==void 0&&!n.has(e.slug)&&n.set(e.slug,r),i.items&&a(i.items)}};a(C({link:r},await t.entities.load(i)))}return n}function ce(e,t){for(let n of t)for(let[t,r]of n){let n=e.get(r);n!==void 0&&!e.has(t)&&e.set(t,n)}}async function le(e){let t=[];for(let n of await e.list({type:S}))t.push(...await e.load(n.key));return t}function ue(e,t=[]){let n=[];for(let[r,i]of e.entries()){if(t[r]?.link!==i.link)break;n.push(i)}return n}async function de(e,t,n,r,i){let a=await Promise.all(e.map(async e=>{let r=fe(e,t,n);return r===null?null:{item:e,link:r.link,label:await Z(e,r,i)}})),o=/* @__PURE__ */ new Map;for(let{item:e,link:t,label:n}of a.filter(e=>e!==null))for(let i of e.linkedSidebars??[]){let e=c(i,F),a=e===null?void 0:r.get(e);a!==void 0&&!o.has(a)&&o.set(a,{label:n,link:t})}return o}function fe(e,t,n){if(typeof e.href==`string`&&e.href.trim()!==``)return{link:e.href.trim()};if(typeof e.page!=`string`||e.page.trim()===``)return null;let{path:r,suffix:i,anchor:a}=u(e.page.trim()),o=d(r,F,t);if(o.kind!==`found`)return null;let s=o.value;return{link:`${m(s,n)}${i}`,anchor:a,route:s}}async function Z(e,t,n){let r=R(e.label)??R(e.group)??t.anchor;if(r!==void 0)return r;let i=t.route?.sidebarSubtreeEntityKey,a=i?await n(i):void 0;return(o(a)?R(a.label):void 0)??t.link}function Q(e,t){for(let n of e){if(!t(n))continue;if(n.link!==void 0&&n.languageInsensitive!==!0)return n;let e=Q([...n.items??[],...n.menu??[]],t);if(e!==null)return e}return null}function pe(e,t){return Q(e,e=>e.version===void 0||e.version===t)?.link??null}function $(e){let t=Q(e,e=>e.version===void 0||e.isDefaultVersion===!0);return t?.link===void 0?null:t.versionGroup!==void 0&&t.version!==void 0?f(t.link,t.versionGroup,t.version,!0):t.link}function me(e){let[t]=e;if(t===void 0)return null;let n=t.path.split(`/`).length;return(e.find(({path:e})=>e.split(`/`).length===n&&N.test(e))??t).link}function he(e){let t=null;for(let{slug:n,originFilePath:r,locale:a,versionGroup:o}of e)r!==null&&a===``&&o===null&&(t===null||n.length<t.length||n.length===t.length&&i(n,t)<0)&&(t=n);return t}const ge=e({id:A,version:`1.26.0`,content:{filter:{match:e=>M.test(e)},async extractFile(e,t){let n=await t.io.readFile(e.path);return{routes:[],linkRefs:await b({source:n,filePath:e.path,readFile:t.io.readFile})}}},async finalize(e){let t=[],r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=[],c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,d=[],f=await Promise.all(e.files.map(async t=>({path:t.path,source:await e.io.readFile(t.path)}))),m=e.routes.all(),g=w(m,e.localeContext),_=ee(m),v=_.length>0?_:void 0;f.sort((e,t)=>e.path.split(`/`).length-t.path.split(`/`).length);let b=new Map(f.map(({path:e,source:t})=>[e,t])),S=/* @__PURE__ */ new Map;for(let{path:e}of f)N.test(e)&&S.set(O.dirname(e),e);let C=/* @__PURE__ */ new Set;for(let{path:e,source:t}of f)for(let n of ne(t,e))C.add(n);let A={routes:e.routes,report:e=>r.push(e),readFile:async t=>b.get(t)??e.io.readFile(t),exists:t=>e.io.exists(t),sidebarByDirectory:S},j=async(n,r)=>{if(n.nodes.length===0)return;await x({io:e.io,routes:e.routes,logger:e.logger,nodes:n.nodes,versionedDirectories:_});let i=J.withArgs({nodes:n.nodes,versionedDirectories:v},r===void 0?void 0:{metadata:{sourcePath:r}});t.push(i),l.set(i,n.nodes);let a=/* @__PURE__ */ new Map;for(let r of e.localeContext.locales){let e=J.withArgs({nodes:n.nodes,locale:r,slugOverrides:g[r]??{},versionedDirectories:v});t.push(e),a.set(r,e)}return c.set(i,a),i};for(let{path:t,source:n}of f){if(C.has(t))continue;let c=await y({...A,file:{path:t},source:n}),l=await j(c,t);if(l===void 0)continue;a.set(t,l);let u=t.startsWith(`@l10n/`)?null:$(c.nodes);u!==null&&d.push({path:t,link:u}),s.push(await X(c,e));for(let e of c.assignedRouteSlugs){let n=o.get(e);n!==void 0&&r.push({code:`sidebar/route-conflict`,message:`Page "${e}" is in sidebars ${n} and ${t}; it shows ${t}.`,location:{filePath:t}}),i.set(e,l),o.set(e,t)}}ce(i,s);let M=new Map(m.map(e=>[e.slug,e]));for(let[t,n]of Object.entries(e.routes.metadata(`sidebar`))){let e=M.get(t);if(e===void 0||e.originFilePath===null)continue;let o=se(n);if(o===null)continue;let s=O.normalize(o.startsWith(`/`)?o.slice(1):O.join(O.dirname(e.originFilePath),o)),c=a.get(s);if(c===void 0){r.push({code:`sidebar/missing-target`,message:`Front matter sidebar "${o}" is not a sidebar file of this project.`,location:{filePath:e.originFilePath}});continue}i.set(e.slug,c)}let F=await le(e.entities),I=/* @__PURE__ */ new Set,L=/* @__PURE__ */ new Map,R=/* @__PURE__ */ new Map;for(let t of F){let n=i.get(t.route);if(n===void 0){let r=await te({...A,file:{path:P},entries:t.entries});if(n=await j(r),n===void 0)continue;let a=(await X(r,e)).keys();for(let e of[...r.assignedRouteSlugs,...a])i.has(e)||(i.set(e,n),I.add(e))}let r=L.get(n);L.set(n,r===void 0?t.backLink??null:r!==null&&r.link===t.backLink?.link?r:null);let a=R.get(n);R.set(n,a===void 0?t.breadcrumbs??[]:ue(a,t.breadcrumbs))}if(f.length===0&&m.length>0){let e=await y({...A,file:{path:P},source:`- directory: .
2
2
  `,skipRoutes:I}),t=await j(e);if(t!==void 0){for(let n of e.assignedRouteSlugs)i.has(n)||i.set(n,t);let n=$(e.nodes);n!==null&&d.push({path:P,link:n})}}let z=me(d)??he(m);if(z!==null){let{path:e}=u(z);t.push(n(e,{stableKey:ae}))}let B=/* @__PURE__ */ new Map;for(let e of m){if(e.originFilePath===null)continue;let t=Y(e);B.set(t,[...B.get(t)??[],e.slug])}for(let[e,t]of[...i]){let n=M.get(e);for(let e of(n&&B.get(Y(n)))??[])i.has(e)||i.set(e,t)}let V=/* @__PURE__ */ new Map,H=(e.config.navbar?.items??[]).filter(e=>e.linkedSidebars?.length),U=/* @__PURE__ */ new Map,W=R.size===0&&H.length===0||v===void 0?/* @__PURE__ */ new Map:await p({io:e.io,routes:e.routes,versionedDirectories:v});for(let[t,n]of await de(H,e.routes,W,a,t=>e.entities.load(t)))R.set(t,[n,...R.get(t)??[]]);let G=({label:t,link:n,icon:r})=>({label:t,link:n,icon:r,[k]:h(n,e.routes,W)??void 0});for(let[e,r]of L){if(r===null)continue;let i=n(G(r));t.push(i),V.set(e,i)}for(let[e,r]of R){if(r.length===0)continue;let i=n(r.map(G));t.push(i),U.set(e,i)}for(let r of new Set(F.map(e=>e.route))){let a=i.get(r),o=a===void 0?void 0:l.get(a),s=o===void 0?null:pe(o,e.routes.bySlug(r)?.version??null);s!==null&&t.push(n(s,{stableKey:re(r)}))}return{entities:t,attach:[...i.entries()].map(([e,t])=>{let n={[E]:t},r=V.get(t);r!==void 0&&(n[ie]=r);let i=U.get(t);if(i!==void 0&&(n[T]=i),M.get(e)?.locale===``)for(let[e,r]of c.get(t)??[])n[D(e)]=r;return{slug:e,deps:n}}),problems:r}},loaders:[J]});export{N as FOLDER_SIDEBAR_FILENAME_REGEX,j as SIDEBAR_AGGREGATOR_LOADER_ID,M as SIDEBAR_FILENAME_REGEX,A as SIDEBAR_PLUGIN_ID,E as SIDEBAR_ROUTE_DEP_KEY,I as isTabbedSidebar,oe as resolveAutoSidebar,ge as sidebarContentPlugin};
@@ -1 +1 @@
1
- function e(e,n){let r=e.version===void 0?void 0:{version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel};if(Array.isArray(n)){let i=e.isGroup===!0||Array.isArray(e.items)&&e.items.length>0,a=n.map(n=>t(n,e.link??``,r));if(i){let[t,...n]=a,r=t&&(t.link===void 0||t.link===e.link)?n:a;return[{...e,items:[...r,...e.items??[]]}]}return a}if(!n||typeof n!=`object`)return[e];let i={...e};for(let[t,r]of Object.entries(n)){if(t===`slugSuffix`&&typeof r==`string`){i.link=(e.link??``)+r;continue}i[t]===void 0&&r!==void 0&&(i[t]=r)}return e.slugSuffix&&!i.link&&(i.link=e.slugSuffix),[i]}function t(e,n,r){let i=r?{...e,...r}:{...e};return e.slugSuffix!==void 0&&(i.link=e.slugSuffix===``||e.slugSuffix===`/`?n:n+e.slugSuffix,delete i.slugSuffix),e.items&&(i.items=e.items.map(e=>t(e,n,r))),i}export{e as applySubtree};
1
+ function e(e,n){let r=e.version===void 0?void 0:{version:e.version,versionGroup:e.versionGroup,isDefaultVersion:e.isDefaultVersion,versionLabel:e.versionLabel};if(Array.isArray(n)){let i=e.isGroup===!0||Array.isArray(e.items)&&e.items.length>0,a=n.map(n=>t(n,e.link??``,r));if(i){let[t,...n]=a,r=t&&(t.link===void 0||t.link===e.link)?n:a;return[{...e,items:[...r,...e.items??[]]}]}for(let t of a)t.link===e.link&&(e.label!==void 0&&(t.label=e.label,t.labelTranslationKey=e.labelTranslationKey),(e.icon!==void 0||e.srcSet!==void 0)&&(t.icon=e.icon,t.srcSet=e.srcSet),e.badges!==void 0&&(t.badges=e.badges));return a}if(!n||typeof n!=`object`)return[e];let i={...e};for(let[t,r]of Object.entries(n)){if(t===`slugSuffix`&&typeof r==`string`){i.link=(e.link??``)+r;continue}i[t]===void 0&&r!==void 0&&(i[t]=r)}return e.slugSuffix&&!i.link&&(i.link=e.slugSuffix),[i]}function t(e,n,r){let i=r?{...e,...r}:{...e};return e.slugSuffix!==void 0&&(i.link=e.slugSuffix===``||e.slugSuffix===`/`?n:n+e.slugSuffix,delete i.slugSuffix),e.items&&(i.items=e.items.map(e=>t(e,n,r))),i}export{e as applySubtree};
@@ -1 +1 @@
1
- import{hashString as e}from"../../../../database/utils/json.js";import{withPathPrefix as t}from"../../../../../shared/path-prefix.js";import{SKILLS_INDEX_SCHEMA_URL as n,skillMarkdownPath as r}from"../../../utils/skill-paths.js";import{SKILL_ENTITY_TYPE as i,skillEntityKey as a}from"../../../types/skill-entity.js";import{isEntityScopeVisible as o}from"../../../../../shared/rbac/entity-scope.js";import{notFoundResponse as s}from"../../../../../server/plugin-context.js";import{publicOrigin as c}from"../../../utils/request-origin.js";const l={"Cache-Control":`no-store`,"Access-Control-Allow-Origin":`*`};function u(e){return e.config.skills?.hide===!0}async function d(a,d){if(u(d))return s();let f=c(d.request),p=await d.entities.list({type:i}),m=await Promise.all(p.map(async n=>{let{slug:i,title:a,description:s}=n.metadata??{};if(typeof i!=`string`||!o(n,d.request.teams,e=>d.logger?.warn(e)))return[];let{content:c}=await d.entities.load(n.key);return[{name:a??i,type:`skill-md`,description:s??``,url:`${f}${t(r(i))}`,digest:`sha256:${e(c)}`}]}));return a.json({$schema:n,skills:m.flat()},200,l)}async function f(e,t){if(u(t))return s();let n=e.req.param(`slug`)??``,r=a(n),i=await t.entities.get(r);if(!i||!o(i,t.request.teams,e=>t.logger?.warn(e)))return s();let{content:c}=await t.entities.load(r);return e.body(c,200,{"Content-Type":`text/markdown; charset=utf-8`,...l})}export{f as skillMarkdown,d as skillsIndex};
1
+ import{hashString as e}from"../../../../database/utils/json.js";import{withPathPrefix as t}from"../../../../../shared/path-prefix.js";import{SKILLS_INDEX_SCHEMA_URL as n,skillMarkdownPath as r}from"../../../utils/skill-paths.js";import{SKILL_ENTITY_TYPE as i,skillEntityKey as a}from"../../../types/skill-entity.js";import{publicOrigin as o}from"../../../utils/request-origin.js";import{isEntityScopeVisible as s}from"../../../../../shared/rbac/entity-scope.js";import{notFoundResponse as c}from"../../../../../server/plugin-context.js";const l={"Cache-Control":`no-store`,"Access-Control-Allow-Origin":`*`};function u(e){return e.config.skills?.hide===!0}async function d(a,d){if(u(d))return c();let f=o(d.request),p=await d.entities.list({type:i}),m=await Promise.all(p.map(async n=>{let{slug:i,title:a,description:o}=n.metadata??{};if(typeof i!=`string`||!s(n,d.request.teams,e=>d.logger?.warn(e)))return[];let{content:c}=await d.entities.load(n.key);return[{name:a??i,type:`skill-md`,description:o??``,url:`${f}${t(r(i))}`,digest:`sha256:${e(c)}`}]}));return a.json({$schema:n,skills:m.flat()},200,l)}async function f(e,t){if(u(t))return c();let n=e.req.param(`slug`)??``,r=a(n),i=await t.entities.get(r);if(!i||!s(i,t.request.teams,e=>t.logger?.warn(e)))return c();let{content:o}=await t.entities.load(r);return e.body(o,200,{"Content-Type":`text/markdown; charset=utf-8`,...l})}export{f as skillMarkdown,d as skillsIndex};
@@ -18,6 +18,8 @@ export type MarkdocAttributeResolverContext = ContentPluginBaseContext & {
18
18
  partialChain?: readonly string[];
19
19
  /** Lines of the Markdown source the AST was parsed from. */
20
20
  readSourceLines: () => readonly string[];
21
+ /** True inside a `json-schema` tag's descriptions. */
22
+ inJsonSchemaDescription?: boolean;
21
23
  };
22
24
  export type MarkdocAttributeResolverResult = {
23
25
  entityDeps?: readonly EntityInvalidationDep[];
@@ -1 +1 @@
1
- import{hashJsonValue as e,toStableJsonString as t}from"../../database/utils/json.js";import{compareStrings as n}from"../../../shared/utils/compare-strings.js";import{compileRouteAccessMatcher as r}from"../../../shared/rbac/engine.js";import{computePathPrefixes as i}from"../../../shared/utils/routes/compute-path-prefixes.js";import{normalizeRoutePath as a}from"../../../shared/utils/routes/normalize-route-path.js";import{resolveRouteScope as o}from"../../../shared/rbac/route-scope.js";import{hashEntityListMembership as s,hashEntityRead as c}from"../../database/entity-store.js";import{getRouteByFilePath as l,getRouteBySlug as u,getRoutesInDirectory as d}from"./state-lookup.js";function f(e,t){let f=r(t),m=e=>f===null?null:o(f,{hasRbacKey:`rbac`in e.metadata,rbacValue:e.metadata.rbac,slug:e.slug,sourcePath:e.originFilePath},()=>{})??{},h=e=>{let t=[];for(let n of e)t.push(v(n));return t.sort((e,t)=>n(e.slug,t.slug))};function*g(t){for(let n of e.routeBySlug.values())!n.isFallback&&(t===void 0||t(n))&&(yield n)}let y=e=>e!==void 0&&!e.isFallback?e:void 0,b=t=>{let n=a(t),r=y(u(e,n));if(r)return r;let o=i(n),s;for(let e of g(e=>e.wildcardPrefix&&o.includes(e.slug)))(s===void 0||e.slug.length>s.slug.length)&&(s=e);return s};function x(t,r){switch(t){case`byFilePath`:{let t=l(e,r);return _(t?v(t):void 0)}case`bySlug`:{let t=y(u(e,r));return _(t?v(t):void 0)}case`inDirectory`:return _(h(d(e,r)));case`all`:return _(h(g()));case`get`:{let t=y(u(e,r));return _(t?{...v(t),metadata:t.metadata,access:m(t)}:void 0)}case`getAccess`:{let e=b(r);return _(e?m(e):void 0)}case`list`:{let{sidebarKey:e}=JSON.parse(r);return _(h(g(t=>t.sidebarSubtreeEntityKey===e)))}case`metadata`:{let e={};for(let t of[...g()].sort((e,t)=>n(e.slug,t.slug)))Object.hasOwn(t.metadata,r)&&(e[t.slug]=t.metadata[r]);return _(e)}case`entity`:return{value:void 0,hash:c(e,r)};case`entity-type`:return{value:void 0,hash:s(e,r)};default:return{value:void 0,hash:``}}}return p(x)}function p(e){return{hash:(t,n)=>e(t,n).hash,index(n){let r=(t,r)=>{let i=e(t,r);return n?.({kind:t,argument:r,resultHash:i.hash}),i.value};return{byFilePath:e=>r(`byFilePath`,e),bySlug:e=>r(`bySlug`,e),inDirectory:e=>r(`inDirectory`,e),all:()=>r(`all`,``),get:e=>r(`get`,e),getAccess:e=>r(`getAccess`,e),list:e=>r(`list`,t({sidebarKey:e.sidebarKey})),metadata:e=>r(`metadata`,e)}},memoized(){let t=/* @__PURE__ */ new Map;return p((n,r)=>{if(n===`entity`||n===`entity-type`)return e(n,r);let i=`${n}\u0000${r}`,a=t.get(i);return a===void 0&&(a=e(n,r),t.set(i,a)),a})}}}function m(e,t,n){return f(e,t).index(n)}function h(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(`${n.kind}\u0000${n.argument}`,n);return[...t.values()].sort((e,t)=>n(e.kind,t.kind)||n(e.argument,t.argument))}function g(e,t){return e.hash(t.kind,t.argument)!==t.resultHash}function _(t){return{value:t,hash:e(t===void 0?`absent`:t)}}function v(e){return{slug:e.slug,routeId:e.routeId,originPluginId:e.originPluginId,originFilePath:e.originFilePath,versionGroup:e.versionGroup,version:e.version,sidebarSubtreeEntityKey:e.sidebarSubtreeEntityKey,template:e.template,locale:e.locale,canonicalSlug:e.canonicalSlug}}export{m as createRouteIndex,f as createRouteQueryEvaluator,h as dedupeRouteQueryDependencies,g as isRouteQueryStale};
1
+ import{hashJsonValue as e,toStableJsonString as t}from"../../database/utils/json.js";import{compareStrings as n}from"../../../shared/utils/compare-strings.js";import{compileRouteAccessMatcher as r}from"../../../shared/rbac/engine.js";import{computePathPrefixes as i}from"../../../shared/utils/routes/compute-path-prefixes.js";import{normalizeRoutePath as a}from"../../../shared/utils/routes/normalize-route-path.js";import{resolveRouteScope as o}from"../../../shared/rbac/route-scope.js";import{hashEntityListMembership as s,hashEntityRead as c}from"../../database/entity-store.js";import{getRouteByFilePath as l,getRouteBySlug as u,getRoutesInDirectory as d}from"./state-lookup.js";function f(e,t){let f=r(t),m=e=>f===null?null:o(f,{hasRbacKey:`rbac`in e.metadata,rbacValue:e.metadata.rbac,slug:e.slug,sourcePath:e.originFilePath},()=>{}),h=e=>{let t=[];for(let n of e)t.push(v(n));return t.sort((e,t)=>n(e.slug,t.slug))};function*g(t){for(let n of e.routeBySlug.values())!n.isFallback&&(t===void 0||t(n))&&(yield n)}let y=e=>e!==void 0&&!e.isFallback?e:void 0,b=t=>{let n=a(t),r=y(u(e,n));if(r)return r;let o=i(n),s;for(let e of g(e=>e.wildcardPrefix&&o.includes(e.slug)))(s===void 0||e.slug.length>s.slug.length)&&(s=e);return s};function x(t,r){switch(t){case`byFilePath`:{let t=l(e,r);return _(t?v(t):void 0)}case`bySlug`:{let t=y(u(e,r));return _(t?v(t):void 0)}case`inDirectory`:return _(h(d(e,r)));case`all`:return _(h(g()));case`get`:{let t=y(u(e,r));return _(t?{...v(t),metadata:t.metadata,access:m(t)}:void 0)}case`getAccess`:{let e=b(r);return _(e?m(e):void 0)}case`list`:{let{sidebarKey:e}=JSON.parse(r);return _(h(g(t=>t.sidebarSubtreeEntityKey===e)))}case`metadata`:{let e={};for(let t of[...g()].sort((e,t)=>n(e.slug,t.slug)))Object.hasOwn(t.metadata,r)&&(e[t.slug]=t.metadata[r]);return _(e)}case`entity`:return{value:void 0,hash:c(e,r)};case`entity-type`:return{value:void 0,hash:s(e,r)};default:return{value:void 0,hash:``}}}return p(x)}function p(e){return{hash:(t,n)=>e(t,n).hash,index(n){let r=(t,r)=>{let i=e(t,r);return n?.({kind:t,argument:r,resultHash:i.hash}),i.value};return{byFilePath:e=>r(`byFilePath`,e),bySlug:e=>r(`bySlug`,e),inDirectory:e=>r(`inDirectory`,e),all:()=>r(`all`,``),get:e=>r(`get`,e),getAccess:e=>r(`getAccess`,e),list:e=>r(`list`,t({sidebarKey:e.sidebarKey})),metadata:e=>r(`metadata`,e)}},memoized(){let t=/* @__PURE__ */ new Map;return p((n,r)=>{if(n===`entity`||n===`entity-type`)return e(n,r);let i=`${n}\u0000${r}`,a=t.get(i);return a===void 0&&(a=e(n,r),t.set(i,a)),a})}}}function m(e,t,n){return f(e,t).index(n)}function h(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(`${n.kind}\u0000${n.argument}`,n);return[...t.values()].sort((e,t)=>n(e.kind,t.kind)||n(e.argument,t.argument))}function g(e,t){return e.hash(t.kind,t.argument)!==t.resultHash}function _(t){return{value:t,hash:e(t===void 0?`absent`:t)}}function v(e){return{slug:e.slug,routeId:e.routeId,originPluginId:e.originPluginId,originFilePath:e.originFilePath,versionGroup:e.versionGroup,version:e.version,sidebarSubtreeEntityKey:e.sidebarSubtreeEntityKey,template:e.template,locale:e.locale,canonicalSlug:e.canonicalSlug}}export{m as createRouteIndex,f as createRouteQueryEvaluator,h as dedupeRouteQueryDependencies,g as isRouteQueryStale};
@@ -1 +1 @@
1
- const e={"link/missing-target":{category:`links`,severity:`error`},"link/missing-anchor":{category:`links`,severity:`error`},"markdoc/parse-error":{category:`markdown`,severity:`error`},"markdoc/validation-error":{category:`markdown`,severity:`error`},"markdoc/diagram-service-failed":{category:`markdown`,severity:`warning`},"markdown/frontmatter-parse":{category:`markdown`,severity:`warning`},"search/facet-invalid":{category:`search`,severity:`warning`},"spec/parse-failed":{category:`spec`,severity:`error`},"routing/slug-collision":{category:`routing`,severity:`error`},"routing/reserved-slug":{category:`routing`,severity:`error`},"routing/wildcard-shadowing":{category:`routing`,severity:`warning`},"plugin/extract-failed":{category:`plugin`,severity:`error`},"plugin/extract-all-failed":{category:`plugin`,severity:`error`},"plugin/finalize-failed":{category:`plugin`,severity:`error`},"plugin/loader-failed":{category:`plugin`,severity:`error`},"plugin/searchable-failed":{category:`plugin`,severity:`error`},"plugin/static-file-invalid":{category:`plugin`,severity:`error`},"plugin/static-file-conflict":{category:`plugin`,severity:`error`},"configuration/invalid":{category:`configuration`,severity:`error`},"configuration/ignored":{category:`configuration`,severity:`warning`},"configuration/deprecated":{category:`configuration`,severity:`warning`},"configuration/l10n-invalid":{category:`configuration`,severity:`error`},"configuration/l10n-layout":{category:`configuration`,severity:`warning`},"configuration/l10n-translations-invalid":{category:`configuration`,severity:`warning`},"configuration/app-data-namespace-conflict":{category:`configuration`,severity:`error`},"configuration/attach-conflict":{category:`configuration`,severity:`error`},"configuration/package-not-allowed":{category:`configuration`,severity:`error`},"sidebar/missing-target":{category:`configuration`,severity:`warning`},"sidebar/invalid-entry":{category:`configuration`,severity:`warning`},"sidebar/route-conflict":{category:`configuration`,severity:`warning`},"scorecard/lint-failed":{category:`spec`,severity:`warning`},"react-page/render-failed":{category:`page`,severity:`error`},"system/ingest-failed":{category:`system`,severity:`error`}},t=[`markdoc/diagram-service-failed`],n={category:`plugin`,severity:`error`};function r(t){return e[t]??n}function i(e){let t=r(e.code);return{code:e.code,category:t.category,severity:e.severity??t.severity,message:e.message,location:e.location,data:e.data}}export{t as RETRYABLE_PROBLEM_CODES,i as createProblem,r as resolveProblemDefaults};
1
+ const e={"link/missing-target":{category:`links`,severity:`error`},"link/missing-anchor":{category:`links`,severity:`warning`},"markdoc/parse-error":{category:`markdown`,severity:`error`},"markdoc/validation-error":{category:`markdown`,severity:`error`},"markdoc/diagram-service-failed":{category:`markdown`,severity:`warning`},"markdown/frontmatter-parse":{category:`markdown`,severity:`warning`},"search/facet-invalid":{category:`search`,severity:`warning`},"spec/parse-failed":{category:`spec`,severity:`error`},"spec/bundle-error":{category:`spec`,severity:`error`},"routing/slug-collision":{category:`routing`,severity:`error`},"routing/reserved-slug":{category:`routing`,severity:`error`},"routing/wildcard-shadowing":{category:`routing`,severity:`warning`},"plugin/extract-failed":{category:`plugin`,severity:`error`},"plugin/extract-all-failed":{category:`plugin`,severity:`error`},"plugin/finalize-failed":{category:`plugin`,severity:`error`},"plugin/loader-failed":{category:`plugin`,severity:`error`},"plugin/searchable-failed":{category:`plugin`,severity:`error`},"plugin/static-file-invalid":{category:`plugin`,severity:`error`},"plugin/static-file-conflict":{category:`plugin`,severity:`error`},"configuration/invalid":{category:`configuration`,severity:`error`},"configuration/ignored":{category:`configuration`,severity:`warning`},"configuration/deprecated":{category:`configuration`,severity:`warning`},"configuration/l10n-invalid":{category:`configuration`,severity:`error`},"configuration/l10n-layout":{category:`configuration`,severity:`warning`},"configuration/l10n-translations-invalid":{category:`configuration`,severity:`warning`},"configuration/app-data-namespace-conflict":{category:`configuration`,severity:`error`},"configuration/attach-conflict":{category:`configuration`,severity:`error`},"configuration/package-not-allowed":{category:`configuration`,severity:`error`},"sidebar/missing-target":{category:`configuration`,severity:`warning`},"sidebar/invalid-entry":{category:`configuration`,severity:`warning`},"sidebar/route-conflict":{category:`configuration`,severity:`warning`},"scorecard/lint-failed":{category:`spec`,severity:`warning`},"react-page/render-failed":{category:`page`,severity:`error`},"system/ingest-failed":{category:`system`,severity:`error`}},t=[`markdoc/diagram-service-failed`,`spec/bundle-error`],n={category:`plugin`,severity:`error`};function r(t){return e[t]??n}function i(e){let t=r(e.code);return{code:e.code,category:t.category,severity:e.severity??t.severity,message:e.message,location:e.location,data:e.data}}export{t as RETRYABLE_PROBLEM_CODES,i as createProblem,r as resolveProblemDefaults};
@@ -2,6 +2,8 @@ import type { SearchFragment } from '../../plugins/types/search.js';
2
2
  import type { SearchParameterHighlight } from '../store.js';
3
3
  /** The text the `parameters` field indexes for one fragment: its parts joined by one space. */
4
4
  export declare function indexedFragmentText(fragment: SearchFragment): string;
5
+ /** The `offsets` into a fragment's indexed text that lie in its name, which the text starts with. */
6
+ export declare function nameOffsets(name: string, offsets: readonly number[]): number[];
5
7
  /**
6
8
  * An anchor split where the fields under one parent share it: the part up to the field's
7
9
  * own segment of the `path=` value, and that segment. An anchor without a `path=` is all
@@ -1 +1 @@
1
- function e(e){return[e.name,e.description??``,e.example??``,e.enum&&e.enum.length>0?e.enum.join(` `):``].filter(e=>e!==``)}function t(t){return e(t).join(` `)}function n(e){let t=e.indexOf(`path=`);if(t===-1)return{prefix:e,tail:``};let n=e.lastIndexOf(`/`),r=n>t?n+1:t+5;return{prefix:e.slice(0,r),tail:e.slice(r)}}function r(e,t){let n=e.description??``;if(n===``)return[];let r=e.name.length+1,i=r+n.length;return t.flatMap(([e=0,...t])=>{let n=t.filter(t=>t>=r&&t+e<=i);return n.length===0?[]:[[e,...n.map(e=>e-r)]]})}function i(e){let t=[];for(let[n,...r]of e)for(let e of r)t.push({start:e,end:e+(n??0)});return t.sort((e,t)=>e.start-t.start||t.end-e.end)}function a(e,t,n){let r=t+e.length,i=``,a=0;for(let o of n){if(o.start<t||o.end>r)continue;let n=o.start-t,s=o.end-t;n<a||(i+=`${e.slice(a,n)}<mark>${e.slice(n,s)}</mark>`,a=s)}return i+e.slice(a)}function o(e,t,n){let r=n?i(n):[],o=0,s=e=>{if(e===``)return e;let t=a(e,o,r);return o+=e.length+1,t},c={place:t.place,path:[...t.path],name:s(e.name),description:s(e.description??``)};return e.example&&(c.example=s(e.example)),e.enum&&e.enum.length>0&&(c.enum=s(e.enum.join(` `))),c}export{r as descriptionOffsetGroups,o as highlightFragment,t as indexedFragmentText,n as splitAnchor};
1
+ function e(e){return[e.name,e.description??``,e.example??``,e.enum&&e.enum.length>0?e.enum.join(` `):``].filter(e=>e!==``)}function t(t){return e(t).join(` `)}function n(e,t){return t.filter(t=>t<e.length)}function r(e){let t=e.indexOf(`path=`);if(t===-1)return{prefix:e,tail:``};let n=e.lastIndexOf(`/`),r=n>t?n+1:t+5;return{prefix:e.slice(0,r),tail:e.slice(r)}}function i(e,t){let n=e.description??``;if(n===``)return[];let r=e.name.length+1,i=r+n.length;return t.flatMap(([e=0,...t])=>{let n=t.filter(t=>t>=r&&t+e<=i);return n.length===0?[]:[[e,...n.map(e=>e-r)]]})}function a(e){let t=[];for(let[n,...r]of e)for(let e of r)t.push({start:e,end:e+(n??0)});return t.sort((e,t)=>e.start-t.start||t.end-e.end)}function o(e,t,n){let r=t+e.length,i=``,a=0;for(let o of n){if(o.start<t||o.end>r)continue;let n=o.start-t,s=o.end-t;n<a||(i+=`${e.slice(a,n)}<mark>${e.slice(n,s)}</mark>`,a=s)}return i+e.slice(a)}function s(e,t,n){let r=n?a(n):[],i=0,s=e=>{if(e===``)return e;let t=o(e,i,r);return i+=e.length+1,t},c={place:t.place,path:[...t.path],name:s(e.name),description:s(e.description??``)};return e.example&&(c.example=s(e.example)),e.enum&&e.enum.length>0&&(c.enum=s(e.enum.join(` `))),c}export{i as descriptionOffsetGroups,s as highlightFragment,t as indexedFragmentText,n as nameOffsets,r as splitAnchor};