@redocly/framework 1.0.0-next.4 → 1.0.0-next.5

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 (163) 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/build/vite-config.js +2 -2
  4. package/dist/bundler/dev/materialization-sweeper.js +1 -1
  5. package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
  6. package/dist/bundler/dev/routes/source-sync-route.js +1 -1
  7. package/dist/bundler/dev/run.js +1 -1
  8. package/dist/bundler/dev/runtime-app.js +1 -1
  9. package/dist/bundler/dev/vite-chunk-url.js +1 -1
  10. package/dist/bundler/user-markdoc-schema.js +1 -1
  11. package/dist/bundler/vite-config.base.js +3 -3
  12. package/dist/cli/commands/build.js +1 -1
  13. package/dist/cli/commands/dev.js +1 -1
  14. package/dist/cli/commands/ingest.js +1 -1
  15. package/dist/cli/commands/translate.js +2 -2
  16. package/dist/cli/dev-console/index.js +1 -1
  17. package/dist/cli/log-output/index.js +1 -1
  18. package/dist/cli/validate-react-pages.js +1 -1
  19. package/dist/client/RuntimeLink.js +1 -1
  20. package/dist/client/ai-search/use-ai-search.js +1 -1
  21. package/dist/client/analytics-page-view.js +1 -1
  22. package/dist/client/app.js +3 -3
  23. package/dist/client/client-entry.js +1 -1
  24. package/dist/client/contexts.js +1 -1
  25. package/dist/client/dev-problems/ProblemsBar.js +1 -1
  26. package/dist/client/feedback.js +1 -1
  27. package/dist/client/l10n/use-l10n-config.js +1 -1
  28. package/dist/client/products.js +1 -1
  29. package/dist/client/review/ReviewBar.js +50 -50
  30. package/dist/client/review/use-review.js +1 -1
  31. package/dist/client/sidebar/SidebarDataProvider.js +1 -1
  32. package/dist/client/sidebar/drilldown.js +1 -1
  33. package/dist/client/ssr.js +1 -1
  34. package/dist/client/telemetry/config.js +1 -1
  35. package/dist/client/use-entity-revisions.js +1 -1
  36. package/dist/client/use-page-versions.js +1 -1
  37. package/dist/client/use-search.js +1 -1
  38. package/dist/client/webmcp/tools/shared.js +1 -1
  39. package/dist/client/webmcp/tools/site-tools.js +1 -1
  40. package/dist/client/webmcp/use-webmcp-tools.js +1 -1
  41. package/dist/content-layer/config.js +1 -1
  42. package/dist/content-layer/database/invalidation.js +26 -26
  43. package/dist/content-layer/ingest/finalize-phase.js +1 -1
  44. package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
  45. package/dist/content-layer/ingest/run.js +1 -1
  46. package/dist/content-layer/ingest/search-sync.js +1 -1
  47. package/dist/content-layer/ingest/sync.js +1 -1
  48. package/dist/content-layer/link-checker/load-view.js +1 -1
  49. package/dist/content-layer/link-checker/validate.js +1 -1
  50. package/dist/content-layer/loaders/context.js +1 -1
  51. package/dist/content-layer/markdown/client/markdown-text.js +1 -1
  52. package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
  53. package/dist/content-layer/markdown/constants/markdown-text-tag-set.js +1 -1
  54. package/dist/content-layer/markdown/constants/tag-sets.js +1 -1
  55. package/dist/content-layer/markdown/nodes/heading.js +1 -1
  56. package/dist/content-layer/markdown/resolve/ast.js +1 -1
  57. package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.js +1 -1
  58. package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
  59. package/dist/content-layer/markdown/resolve/markdoc-resolvers/partial.js +1 -1
  60. package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
  61. package/dist/content-layer/markdown/resolve/references.js +1 -1
  62. package/dist/content-layer/markdown/search/to-markdown.js +1 -1
  63. package/dist/content-layer/markdown/search/to-sections.js +1 -1
  64. package/dist/content-layer/markdown/server/render.js +1 -1
  65. package/dist/content-layer/markdown/service.js +1 -1
  66. package/dist/content-layer/markdown/tags/partial.d.ts +7 -2
  67. package/dist/content-layer/markdown/tags/partial.js +1 -1
  68. package/dist/content-layer/markdown/tags/variant.js +1 -1
  69. package/dist/content-layer/markdown/types/service.d.ts +2 -0
  70. package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
  71. package/dist/content-layer/markdown/utils/reparse-example-fences.d.ts +4 -1
  72. package/dist/content-layer/markdown/utils/reparse-example-fences.js +1 -1
  73. package/dist/content-layer/markdown/utils/substitute-variables.js +1 -1
  74. package/dist/content-layer/markdown/utils/walk-markdoc-ast.d.ts +2 -2
  75. package/dist/content-layer/markdown/utils/walk-markdoc-ast.js +1 -1
  76. package/dist/content-layer/plugins/index.js +1 -1
  77. package/dist/content-layer/plugins/internal/api-docs/client/template.js +2 -2
  78. package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
  79. package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.js +13 -13
  80. package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
  81. package/dist/content-layer/plugins/internal/app-data/banner.js +1 -1
  82. package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
  83. package/dist/content-layer/plugins/internal/catalog-classic/client/use-catalog-classic.js +1 -1
  84. package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
  85. package/dist/content-layer/plugins/internal/index.js +1 -1
  86. package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
  87. package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
  88. package/dist/content-layer/plugins/internal/mcp/constants.d.ts +6 -0
  89. package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
  90. package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
  91. package/dist/content-layer/plugins/internal/mcp/ignored-routes.js +1 -1
  92. package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
  93. package/dist/content-layer/plugins/internal/mcp/server/codemode/capabilities.js +3 -3
  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/execute-schema.js +1 -1
  97. package/dist/content-layer/plugins/internal/mcp/server/codemode/execution-budget.js +1 -0
  98. package/dist/content-layer/plugins/internal/mcp/server/codemode/index.js +1 -1
  99. package/dist/content-layer/plugins/internal/mcp/server/codemode/prompts.js +8 -8
  100. package/dist/content-layer/plugins/internal/mcp/server/codemode/read-result.js +1 -0
  101. package/dist/content-layer/plugins/internal/mcp/server/codemode/return-last-expression.js +6 -0
  102. package/dist/content-layer/plugins/internal/mcp/server/codemode/returns-from-top-level.js +1 -0
  103. package/dist/content-layer/plugins/internal/mcp/server/codemode/sandbox.js +1 -1
  104. package/dist/content-layer/plugins/internal/mcp/server/codemode/tool-declarations.js +4 -0
  105. package/dist/content-layer/plugins/internal/mcp/server/codemode/tool-list.js +1 -1
  106. package/dist/content-layer/plugins/internal/mcp/server/codemode/unknown-tool-hint.js +3 -0
  107. package/dist/content-layer/plugins/internal/mcp/server/gateway/api-call-operations.js +1 -1
  108. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
  109. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
  110. package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +6 -6
  111. package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
  112. package/dist/content-layer/plugins/internal/mcp/server/gateway/subject.js +1 -1
  113. package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +4 -4
  114. package/dist/content-layer/plugins/internal/mcp/server/gateway/upstream-auth-scheme.js +2 -2
  115. package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
  116. package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.js +1 -1
  117. package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
  118. package/dist/content-layer/plugins/internal/mcp/server/rate-limit.js +1 -1
  119. package/dist/content-layer/plugins/internal/mcp/server/server-info.js +1 -1
  120. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-constants.js +1 -0
  121. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-document.js +1 -1
  122. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql.js +1 -1
  123. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-catalog.js +1 -1
  124. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-document.js +1 -1
  125. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi.js +1 -1
  126. package/dist/content-layer/plugins/internal/mcp/server/tools/pages-constants.js +1 -0
  127. package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
  128. package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +3 -3
  129. package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -0
  130. package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +1 -1
  131. package/dist/content-layer/plugins/internal/mcp/server/tools/submit-feedback.js +1 -1
  132. package/dist/content-layer/plugins/internal/mcp/server/tools/whoami.js +1 -1
  133. package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
  134. package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
  135. package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
  136. package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
  137. package/dist/content-layer/plugins/internal/skills/index.js +1 -1
  138. package/dist/content-layer/plugins/project/load.js +2 -2
  139. package/dist/content-layer/plugins/utils/link-access.js +1 -1
  140. package/dist/content-layer/plugins/utils/route-index.js +1 -1
  141. package/dist/content-layer/versions/redirect.js +1 -1
  142. package/dist/content-layer/versions/resolve.js +1 -1
  143. package/dist/server/__tests__/rbac-fixture.js +1 -1
  144. package/dist/server/app.js +3 -3
  145. package/dist/server/ask-ai/route.js +1 -1
  146. package/dist/server/auth/middleware.js +1 -1
  147. package/dist/server/auth/request.js +1 -1
  148. package/dist/server/auth/routes.js +1 -1
  149. package/dist/server/constants/system-routes.js +1 -1
  150. package/dist/server/content.js +13 -13
  151. package/dist/server/cors-proxy/handler.js +1 -1
  152. package/dist/server/feedback/route.js +1 -1
  153. package/dist/server/lambda-entry.js +1 -1
  154. package/dist/server/manifest-assets.js +4 -4
  155. package/dist/server/node-entry.js +1 -1
  156. package/dist/server/plugin-context.js +1 -1
  157. package/dist/server/rbac/l10n-rules.js +1 -1
  158. package/dist/server/rbac/team-templates.js +1 -1
  159. package/dist/server/search/route.js +1 -1
  160. package/dist/server/seo-tags.js +2 -2
  161. package/dist/server/static-files/serve.js +1 -1
  162. package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
  163. package/package.json +2 -4
@@ -1,26 +1,26 @@
1
- import{isObject as e}from"../../../../../shared/utils/is-object.js";import{SPEC_DOWNLOAD_ROUTE_PATHS as t}from"./shared.js";import{headingSlugger as n}from"../../../../markdown/utils/heading-slugger.js";import{RBAC_TEAM_ANONYMOUS as r}from"../../../../../server/rbac/types.js";import{canView as i,isRbacScope as a,resolveRole as o}from"../../../../../server/rbac/engine.js";import{parseMarkdown as s}from"../../../../markdown/utils/parse-cache.js";import{markdocAstToMarkdownChunks as c}from"../../../../markdown/search/to-markdown.js";import{REDOCLY_TEAMS_RBAC as l}from"@redocly/config";const u=e=>{let t=e[l];return t!==void 0&&!i(o(a(t)?t:{},[r]))};function d(t,n,r,i={}){let a=/* @__PURE__ */ new Map,o=e=>{let t=y(e)?e:{type:`document`,children:Array.isArray(e)?e:[e]};return c(t,i)},l=e=>{if(typeof e!=`string`)return o(e);if(!e.includes(`{%`)){let t=e.trim();return t===``?[]:[t]}let t=a.get(e);return t===void 0&&(t=o(s(e)),a.set(e,t)),t},d=[],m=/* @__PURE__ */ new Set,h=t.items,g=e(t.store)?t.store.schemaStore:{},x=e(n)?n:void 0,S=x?.security,C=e(x?.info)?x.info:{},w=(e,t,n,r)=>{d.push({routeSlug:e,chunks:t,headings:f(t),...typeof n==`string`&&n!==``?{title:n}:{},...r?{description:r}:{}})},T=e(C[`x-metadata`])?C[`x-metadata`]:{},E=l((typeof T.description==`string`?T.description:void 0)??C.description).join(`
1
+ import{RBAC_TEAM_ANONYMOUS as e}from"../../../../../server/rbac/types.js";import{canView as t,isRbacScope as n,resolveRole as r}from"../../../../../server/rbac/engine.js";import{isObject as i}from"../../../../../shared/utils/is-object.js";import{headingSlugger as a}from"../../../../markdown/utils/heading-slugger.js";import{parseMarkdown as o}from"../../../../markdown/utils/parse-cache.js";import{SPEC_DOWNLOAD_ROUTE_PATHS as s}from"./shared.js";import{markdocAstToMarkdownChunks as c}from"../../../../markdown/search/to-markdown.js";import{REDOCLY_TEAMS_RBAC as l}from"@redocly/config";const u=i=>{let a=i[l];return a!==void 0&&!t(r(n(a)?a:{},[e]))};function d(e,t,n,r={}){let a=/* @__PURE__ */ new Map,s=e=>{let t=y(e)?e:{type:`document`,children:Array.isArray(e)?e:[e]};return c(t,r)},l=e=>{if(typeof e!=`string`)return s(e);if(!e.includes(`{%`)){let t=e.trim();return t===``?[]:[t]}let t=a.get(e);return t===void 0&&(t=s(o(e)),a.set(e,t)),t},d=[],m=/* @__PURE__ */ new Set,h=e.items,g=i(e.store)?e.store.schemaStore:{},x=i(t)?t:void 0,S=x?.security,C=i(x?.info)?x.info:{},w=(e,t,n,r)=>{d.push({routeSlug:e,chunks:t,headings:f(t),...typeof n==`string`&&n!==``?{title:n}:{},...r?{description:r}:{}})},T=i(C[`x-metadata`])?C[`x-metadata`]:{},E=l((typeof T.description==`string`?T.description:void 0)??C.description).join(`
2
2
 
3
- `),D=e=>{let n=e.content,i=n?.contentType??(e.items?.length&&e.link?`group`:void 0);if(!u(e)&&typeof e.link==`string`&&i!==void 0){let a=i===`overview`,o=e.link;if(!m.has(o)){if(a&&n)m.add(o),w(o,p({doc:x,info:C,description:E,specType:t.specType,items:h,originFilePath:r,renderMarkdown:l}),C.title,E);else if(i===`item`&&n)m.add(o),w(o,v(e,{info:C,schemaStore:g,document:x,globalSecurity:S,specType:t.specType,renderMarkdown:l}),e.label);else if(i===`group`){m.add(o);let t=e.deprecated===!0||n?.meta?.deprecated===!0,r=_(e.items??[],l);w(o,[`# ${e.label??``}${t?` (deprecated)`:``}`.trim(),...b(n?.children??[],l),...r?[r]:[]].filter(e=>e!==``),e.label)}}}for(let t of e.items??[])D(t)};for(let e of h)D(e);return d}function f(e){return n.reset(),e.map(e=>{let t=/^#{1,6} +(?! )(.+)$/.exec(e.split(`
4
- `,1)[0]??``);if(!t)return null;let r=t[1].trim();return{heading:r,anchor:n.slug(r)}})}function p(t){let{doc:n,info:r}=t,i=[],a=[];typeof r.title==`string`&&r.title&&a.push(`# ${r.title}`),t.description&&a.push(t.description),typeof r.summary==`string`&&r.summary&&a.push(r.summary);let o=[];r.version!==void 0&&r.version!==``&&o.push(`Version: ${String(r.version)}`);let s=e(r.license)?r.license:void 0;typeof s?.name==`string`&&o.push(`License: ${s.name}`);let c=e(r[`x-metadata`])?r[`x-metadata`]:void 0;if(c){let e=Object.entries(c).filter(([,e])=>typeof e==`string`||typeof e==`number`).filter(([e,t])=>e!==`description`||typeof t!=`string`).map(([e,t])=>`- ${e}: ${String(t)}`);e.length>0&&o.push(`Metadata:\n${e.join(`
3
+ `),D=t=>{let r=t.content,i=r?.contentType??(t.items?.length&&t.link?`group`:void 0);if(!u(t)&&typeof t.link==`string`&&i!==void 0){let a=i===`overview`,o=t.link;if(!m.has(o)){if(a&&r)m.add(o),w(o,p({doc:x,info:C,description:E,specType:e.specType,items:h,originFilePath:n,renderMarkdown:l}),C.title,E);else if(i===`item`&&r)m.add(o),w(o,v(t,{info:C,schemaStore:g,document:x,globalSecurity:S,specType:e.specType,renderMarkdown:l}),t.label);else if(i===`group`){m.add(o);let e=t.deprecated===!0||r?.meta?.deprecated===!0,n=_(t.items??[],l);w(o,[`# ${t.label??``}${e?` (deprecated)`:``}`.trim(),...b(r?.children??[],l),...n?[n]:[]].filter(e=>e!==``),t.label)}}}for(let e of t.items??[])D(e)};for(let e of h)D(e);return d}function f(e){return a.reset(),e.map(e=>{let t=/^#{1,6} +(?! )(.+)$/.exec(e.split(`
4
+ `,1)[0]??``);if(!t)return null;let n=t[1].trim();return{heading:n,anchor:a.slug(n)}})}function p(e){let{doc:t,info:n}=e,r=[],a=[];typeof n.title==`string`&&n.title&&a.push(`# ${n.title}`),e.description&&a.push(e.description),typeof n.summary==`string`&&n.summary&&a.push(n.summary);let o=[];n.version!==void 0&&n.version!==``&&o.push(`Version: ${String(n.version)}`);let s=i(n.license)?n.license:void 0;typeof s?.name==`string`&&o.push(`License: ${s.name}`);let c=i(n[`x-metadata`])?n[`x-metadata`]:void 0;if(c){let e=Object.entries(c).filter(([,e])=>typeof e==`string`||typeof e==`number`).filter(([e,t])=>e!==`description`||typeof t!=`string`).map(([e,t])=>`- ${e}: ${String(t)}`);e.length>0&&o.push(`Metadata:\n${e.join(`
5
5
  `)}`)}o.length>0&&a.push(o.join(`
6
- `)),a.length>0&&i.push(a.join(`
6
+ `)),a.length>0&&r.push(a.join(`
7
7
 
8
- `));let l=m(n,t.renderMarkdown);l&&i.push(l);let u=h(n,t.renderMarkdown);u&&i.push(u);let d=g(t.specType,r,t.originFilePath);d&&i.push(d);let f=_(t.items,t.renderMarkdown);return f&&i.push(f),i}function m(t,n){let r=t?.servers;if(!Array.isArray(r)||r.length===0)return;let i=`## Servers
8
+ `));let l=m(t,e.renderMarkdown);l&&r.push(l);let u=h(t,e.renderMarkdown);u&&r.push(u);let d=g(e.specType,n,e.originFilePath);d&&r.push(d);let f=_(e.items,e.renderMarkdown);return f&&r.push(f),r}function m(e,t){let n=e?.servers;if(!Array.isArray(n)||n.length===0)return;let r=`## Servers
9
9
 
10
- `;for(let t of r){if(!e(t))continue;let r=n(t.description).join(`
10
+ `;for(let e of n){if(!i(e))continue;let n=t(e.description).join(`
11
11
 
12
- `);if(r&&(i+=`${r}\n`),i+=`\`\`\`\n${String(t.url??``)}\n\`\`\`\n\n`,e(t.variables)){i+=`Variables:
13
- `;for(let[r,a]of Object.entries(t.variables)){if(!e(a))continue;let t=n(a.description).join(` `).replace(/\s+/g,` `);i+=`- \`${r}\`${t?`: ${t}`:``}\n`,a.default!==void 0&&(i+=` Default: ${JSON.stringify(a.default)}\n`),Array.isArray(a.enum)&&(i+=` Enum: ${a.enum.map(e=>JSON.stringify(e)).join(`, `)}\n`)}i+=`
14
- `}}return i.trim()}function h(t,n){let r=e(t?.components)?t.components:void 0,i=e(r?.securitySchemes)?r.securitySchemes:void 0;if(!i)return;let a=`## Security
12
+ `);if(n&&(r+=`${n}\n`),r+=`\`\`\`\n${String(e.url??``)}\n\`\`\`\n\n`,i(e.variables)){r+=`Variables:
13
+ `;for(let[n,a]of Object.entries(e.variables)){if(!i(a))continue;let e=t(a.description).join(` `).replace(/\s+/g,` `);r+=`- \`${n}\`${e?`: ${e}`:``}\n`,a.default!==void 0&&(r+=` Default: ${JSON.stringify(a.default)}\n`),Array.isArray(a.enum)&&(r+=` Enum: ${a.enum.map(e=>JSON.stringify(e)).join(`, `)}\n`)}r+=`
14
+ `}}return r.trim()}function h(e,t){let n=i(e?.components)?e.components:void 0,r=i(n?.securitySchemes)?n.securitySchemes:void 0;if(!r)return;let a=`## Security
15
15
 
16
- `;for(let[t,r]of Object.entries(i)){if(!e(r)||`$ref`in r)continue;a+=`### ${t}\n\n`;let i=n(r.description).join(`
16
+ `;for(let[e,n]of Object.entries(r)){if(!i(n)||`$ref`in n)continue;a+=`### ${e}\n\n`;let r=t(n.description).join(`
17
17
 
18
- `);i&&(a+=`${i}\n\n`);for(let[e,t]of[[`Type`,`type`],[`In`,`in`],[`Name`,`name`],[`Scheme`,`scheme`],[`Bearer Format`,`bearerFormat`],[`OpenID Connect URL`,`openIdConnectUrl`]])typeof r[t]==`string`&&r[t]&&(a+=`${e}: ${r[t]}\n`);let o=e(r.flows)?r.flows:void 0,s=[o?.implicit,o?.password,o?.clientCredentials,o?.authorizationCode].find(e);if(s&&(typeof s.authorizationUrl==`string`&&(a+=`Authorization URL: ${s.authorizationUrl}\n`),typeof s.tokenUrl==`string`&&(a+=`Token URL: ${s.tokenUrl}\n`),e(s.scopes))){a+=`Scopes:
18
+ `);r&&(a+=`${r}\n\n`);for(let[e,t]of[[`Type`,`type`],[`In`,`in`],[`Name`,`name`],[`Scheme`,`scheme`],[`Bearer Format`,`bearerFormat`],[`OpenID Connect URL`,`openIdConnectUrl`]])typeof n[t]==`string`&&n[t]&&(a+=`${e}: ${n[t]}\n`);let o=i(n.flows)?n.flows:void 0,s=[o?.implicit,o?.password,o?.clientCredentials,o?.authorizationCode].find(i);if(s&&(typeof s.authorizationUrl==`string`&&(a+=`Authorization URL: ${s.authorizationUrl}\n`),typeof s.tokenUrl==`string`&&(a+=`Token URL: ${s.tokenUrl}\n`),i(s.scopes))){a+=`Scopes:
19
19
  `;for(let[e,t]of Object.entries(s.scopes))a+=`- \`${e}\`: ${String(t)}\n`}a+=`
20
- `}return a.trim()}function g(e,n,r){if(!r)return;let i=typeof n.title==`string`&&n.title?n.title:void 0;if(e===`openapi`||e===`asyncapi`){let n=e===`openapi`?`OpenAPI`:`AsyncAPI`;return`## Download ${n} description\n\n[${i??`${n} definition`}](${t.bundle}/${r})`}if(e===`graphql`)return`## Download GraphQL schema\n\n[${i??`GraphQL schema`}](${t.graphql}/${r})`}function _(e,t){let n=``,r=(e,i)=>{for(let a of e)if(!(u(a)||typeof a.link!=`string`)){if(a.content?.contentType===`group`)n+=`${i} ${a.label??``}\n\n`,a.items?.length&&r(a.items,`${i}#`);else if(a.content?.contentType===`item`){let e=a.httpVerb&&a.httpPath?`${a.httpVerb.toUpperCase()} ${a.httpPath}`:a.label??``,r=x(a.content.children??[],t),i=r?`: ${r.slice(0,200)}`:``;n+=`- [${e}](${a.link}.md)${i}\n`}}};return r(e,`##`),n.trim()===``?void 0:n.trim()}function v(e,t){let n=e.content,r=n?.children??[],i=e.deprecated===!0||n?.meta?.deprecated===!0,a=[`# ${e.label??``}${i?` (deprecated)`:``}`.trim()];a.push(...b(r,t.renderMarkdown));let o=[];if(t.specType===`openapi`||t.specType===`asyncapi`){e.httpVerb&&e.httpPath?o.push(`Endpoint: ${e.httpVerb.toUpperCase()} ${e.httpPath}`):e.httpVerb&&o.push(`Method: ${e.httpVerb.toUpperCase()}`),t.info.version!==void 0&&t.info.version!==``&&o.push(`Version: ${String(t.info.version)}`);let n=S(r,t.globalSecurity);n&&o.push(`Security: ${n}`)}if(o.length>0&&a.push(o.join(`
20
+ `}return a.trim()}function g(e,t,n){if(!n)return;let r=typeof t.title==`string`&&t.title?t.title:void 0;if(e===`openapi`||e===`asyncapi`){let t=e===`openapi`?`OpenAPI`:`AsyncAPI`;return`## Download ${t} description\n\n[${r??`${t} definition`}](${s.bundle}/${n})`}if(e===`graphql`)return`## Download GraphQL schema\n\n[${r??`GraphQL schema`}](${s.graphql}/${n})`}function _(e,t){let n=``,r=(e,i)=>{for(let a of e)if(!(u(a)||typeof a.link!=`string`)){if(a.content?.contentType===`group`)n+=`${i} ${a.label??``}\n\n`,a.items?.length&&r(a.items,`${i}#`);else if(a.content?.contentType===`item`){let e=a.httpVerb&&a.httpPath?`${a.httpVerb.toUpperCase()} ${a.httpPath}`:a.label??``,r=x(a.content.children??[],t),i=r?`: ${r.slice(0,200)}`:``;n+=`- [${e}](${a.link}.md)${i}\n`}}};return r(e,`##`),n.trim()===``?void 0:n.trim()}function v(e,t){let n=e.content,r=n?.children??[],i=e.deprecated===!0||n?.meta?.deprecated===!0,a=[`# ${e.label??``}${i?` (deprecated)`:``}`.trim()];a.push(...b(r,t.renderMarkdown));let o=[];if(t.specType===`openapi`||t.specType===`asyncapi`){e.httpVerb&&e.httpPath?o.push(`Endpoint: ${e.httpVerb.toUpperCase()} ${e.httpPath}`):e.httpVerb&&o.push(`Method: ${e.httpVerb.toUpperCase()}`),t.info.version!==void 0&&t.info.version!==``&&o.push(`Version: ${String(t.info.version)}`);let n=S(r,t.globalSecurity);n&&o.push(`Security: ${n}`)}if(o.length>0&&a.push(o.join(`
21
21
  `)),t.specType!==`graphql`){let e=C(r,{schemaStore:t.schemaStore,document:t.document,renderMarkdown:t.renderMarkdown});e.length>0&&a.push(P(e))}return a.filter(e=>e!==``)}function y(e){return typeof e==`object`&&!!e&&e.type===`document`}function b(e,t){let n=[],r=e=>{if(!u(e)){if(e.nodeType===`markdoc`){n.push(...t(e.content));return}if(e.nodeType===`container`||e.nodeType===`overview-section-wrapper`)for(let t of e.children??[])r(t)}};for(let t of e)r(t);return n}function x(e,t){return b(e,t).join(` `).replace(/\s+/g,` `).trim()}function S(e,t){let n=[],r=e=>{for(let t of e)if(t.nodeType===`security`){let e=t.requirements;for(let t of e??[])for(let e of t.schemes??[])u(e)||e.name&&!n.includes(e.name)&&n.push(e.name)}else(t.nodeType===`container`||t.nodeType===`overview-section-wrapper`)&&r(t.children??[])};if(r(e),n.length>0)return n.join(`, `);if(t?.length){let e=[...new Set(t.flatMap(e=>Object.keys(e)))];if(e.length>0)return e.join(`, `)}}function C(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set,i=e=>{for(let a of e)if(a.nodeType===`item-content`){if(u(a))continue;for(let e of a.parameters??[])!u(e)&&e.name&&w(n,{name:e.name,path:[],place:E(a.variant),type:O(e.schemaId,t),required:e.required??!1,description:T(e.description,t.renderMarkdown)});D(a,n,r,t)}else if(a.nodeType===`container`||a.nodeType===`overview-section-wrapper`){if(u(a))continue;i(a.children??[])}};return i(e),[...n.values()]}function w(e,t){e.set([...t.path,t.name].join(`.`)+t.description+t.place,t)}function T(e,t){return e==null?``:t(e).join(`
22
22
 
23
- `)}function E(e){switch(e){case`query`:return`query parameters`;case`path`:return`path parameters`;case`headers`:return`header parameters`;case`cookies`:return`cookie parameters`;case`parameters`:return`channel parameters`;case`body`:return`request fields`;case`responses`:return`response fields`;default:return e?`${e} parameters`:`parameters`}}function D(e,t,n,r){let i=E(e.variant),a=i.startsWith(`response`);if(e.mediaTypeSchemas){let o=Object.values(e.mediaTypeSchemas).find(e=>!u(e));o?.schemaId&&k(o.schemaId,i,a,t,n,r)}else e.schemaId&&k(e.schemaId,i,a,t,n,r);for(let n of e.responses??[]){if(u(n))continue;let e=`response ${n.code??``} fields`.replace(` `,` `),i=/* @__PURE__ */ new Set,a=(n.mediaTypeContent?Object.values(n.mediaTypeContent).find(e=>!u(e)):void 0)?.schemaId??n.schemaId;a&&k(a,e,!0,t,i,r)}for(let n of e.messages??[])!u(n)&&n.name&&w(t,{name:n.name,path:[],place:`message`,type:`unknown`,required:!1,description:`${T(n.description,r.renderMarkdown)} ${n.summary??``}`.trim()})}function O(t,n){if(!t)return`unknown`;let r=n.schemaStore[t];return!e(r)||r.kind!==`json-schema`?`unknown`:M(j(r.data,n))}function k(t,n,r,i,a,o){let s=o.schemaStore[t];e(s)&&s.kind===`json-schema`&&!u(s)&&N(s.data,n,r,i,[],a,0,o)}function A(t,n){if(!t.startsWith(`#/`)||!n.document)return;let r=n.document;for(let e of t.slice(2).split(`/`)){if(typeof r!=`object`||!r)return;r=r[e]}return e(r)?r:void 0}function j(e,t){if(e.allOf){let n={};for(let r of e.allOf){let e=r.$ref?A(r.$ref,t):r;if(e){let t=n.properties,r=n.required;Object.assign(n,e),(t||e.properties)&&(n.properties={...t??{},...e.properties??{}}),(r||e.required)&&(n.required=[...r??[],...e.required??[]])}}return delete n.allOf,e.description&&(n.description=e.description),n}if(e.$ref){let n=A(e.$ref,t);if(n){let t={...n};return e.description&&(t.description=e.description),t}}return e}function M(e){return Array.isArray(e.type)?e.type.join(` | `):e.type?e.type:e.properties||e.additionalProperties?`object`:e.items?`array`:e.enum?`string`:`any`}function N(t,n,r,i,a,o,s,c){if(!(s>10||u(t))){if(t.$ref){if(o.has(t.$ref))return;o.add(t.$ref);let e=A(t.$ref,c);e&&N(e,n,r,i,a,o,s,c);return}if(t.allOf){N(j(t,c),n,r,i,a,o,s,c);return}if(t.discriminator&&t.properties&&t.oneOf){N({...t,oneOf:void 0,discriminator:void 0},n,r,i,a,o,s,c);return}if(t.oneOf||t.anyOf){for(let e of t.oneOf??t.anyOf??[]){if(e.$ref){if(o.has(e.$ref))continue;o.add(e.$ref)}let t=e.$ref?A(e.$ref,c):e;t&&N(t,n,r,i,a,o,s+1,c)}return}if(t.properties){let e=t.required??[];for(let[l,d]of Object.entries(t.properties)){if(u(d))continue;if(d.$ref){if(o.has(d.$ref))continue;o.add(d.$ref)}let t=d.$ref?A(d.$ref,c):d;if(!t)continue;let f=j(t,c);if(u(t)||u(f)||f.readOnly&&!r||f.writeOnly&&r||t.additionalProperties!==void 0&&!t.properties)continue;let p=t.example??f.example;w(i,{name:l,path:a,place:n,type:M(f),required:e.includes(l),description:T(t.description??f.description,c.renderMarkdown),enumValues:Array.isArray(f.enum)&&f.enum.length>0?f.enum:void 0,example:p===void 0?void 0:(typeof p==`string`?p:JSON.stringify(p)).slice(0,200)}),(f.properties||f.items)&&N(f,n,r,i,[...a,l],o,s+1,c)}}if(t.items&&e(t.items)&&!Array.isArray(t.items)){let e=t.items;if(e.$ref){if(o.has(e.$ref))return;o.add(e.$ref)}let l=e.$ref?A(e.$ref,c):e;l&&N(l,n,r,i,a,o,s+1,c)}}}function P(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.place);e?e.push(n):t.set(n.place,[n])}let n=[];for(let[e,r]of t){let t=r.map(e=>{let t=`- \`${[...e.path,e.name].join(`.`)}\` (${e.type}${e.required?`, required`:``})`,n=e.description.replace(/\s+/g,` `).trim();return n&&(t+=`\n ${n}`),e.enumValues?t+=`\n Enum: ${e.enumValues.map(e=>JSON.stringify(e)).join(`, `)}`:e.example&&(t+=`\n Example: ${e.example}`),t});n.push(`## ${e.charAt(0).toUpperCase()}${e.slice(1)}\n\n${t.join(`
23
+ `)}function E(e){switch(e){case`query`:return`query parameters`;case`path`:return`path parameters`;case`headers`:return`header parameters`;case`cookies`:return`cookie parameters`;case`parameters`:return`channel parameters`;case`body`:return`request fields`;case`responses`:return`response fields`;default:return e?`${e} parameters`:`parameters`}}function D(e,t,n,r){let i=E(e.variant),a=i.startsWith(`response`);if(e.mediaTypeSchemas){let o=Object.values(e.mediaTypeSchemas).find(e=>!u(e));o?.schemaId&&k(o.schemaId,i,a,t,n,r)}else e.schemaId&&k(e.schemaId,i,a,t,n,r);for(let n of e.responses??[]){if(u(n))continue;let e=`response ${n.code??``} fields`.replace(` `,` `),i=/* @__PURE__ */ new Set,a=(n.mediaTypeContent?Object.values(n.mediaTypeContent).find(e=>!u(e)):void 0)?.schemaId??n.schemaId;a&&k(a,e,!0,t,i,r)}for(let n of e.messages??[])!u(n)&&n.name&&w(t,{name:n.name,path:[],place:`message`,type:`unknown`,required:!1,description:`${T(n.description,r.renderMarkdown)} ${n.summary??``}`.trim()})}function O(e,t){if(!e)return`unknown`;let n=t.schemaStore[e];return!i(n)||n.kind!==`json-schema`?`unknown`:M(j(n.data,t))}function k(e,t,n,r,a,o){let s=o.schemaStore[e];i(s)&&s.kind===`json-schema`&&!u(s)&&N(s.data,t,n,r,[],a,0,o)}function A(e,t){if(!e.startsWith(`#/`)||!t.document)return;let n=t.document;for(let t of e.slice(2).split(`/`)){if(typeof n!=`object`||!n)return;n=n[t]}return i(n)?n:void 0}function j(e,t){if(e.allOf){let n={};for(let r of e.allOf){let e=r.$ref?A(r.$ref,t):r;if(e){let t=n.properties,r=n.required;Object.assign(n,e),(t||e.properties)&&(n.properties={...t??{},...e.properties??{}}),(r||e.required)&&(n.required=[...r??[],...e.required??[]])}}return delete n.allOf,e.description&&(n.description=e.description),n}if(e.$ref){let n=A(e.$ref,t);if(n){let t={...n};return e.description&&(t.description=e.description),t}}return e}function M(e){return Array.isArray(e.type)?e.type.join(` | `):e.type?e.type:e.properties||e.additionalProperties?`object`:e.items?`array`:e.enum?`string`:`any`}function N(e,t,n,r,a,o,s,c){if(!(s>10||u(e))){if(e.$ref){if(o.has(e.$ref))return;o.add(e.$ref);let i=A(e.$ref,c);i&&N(i,t,n,r,a,o,s,c);return}if(e.allOf){N(j(e,c),t,n,r,a,o,s,c);return}if(e.discriminator&&e.properties&&e.oneOf){N({...e,oneOf:void 0,discriminator:void 0},t,n,r,a,o,s,c);return}if(e.oneOf||e.anyOf){for(let i of e.oneOf??e.anyOf??[]){if(i.$ref){if(o.has(i.$ref))continue;o.add(i.$ref)}let e=i.$ref?A(i.$ref,c):i;e&&N(e,t,n,r,a,o,s+1,c)}return}if(e.properties){let i=e.required??[];for(let[l,d]of Object.entries(e.properties)){if(u(d))continue;if(d.$ref){if(o.has(d.$ref))continue;o.add(d.$ref)}let e=d.$ref?A(d.$ref,c):d;if(!e)continue;let f=j(e,c);if(u(e)||u(f)||f.readOnly&&!n||f.writeOnly&&n||e.additionalProperties!==void 0&&!e.properties)continue;let p=e.example??f.example;w(r,{name:l,path:a,place:t,type:M(f),required:i.includes(l),description:T(e.description??f.description,c.renderMarkdown),enumValues:Array.isArray(f.enum)&&f.enum.length>0?f.enum:void 0,example:p===void 0?void 0:(typeof p==`string`?p:JSON.stringify(p)).slice(0,200)}),(f.properties||f.items)&&N(f,t,n,r,[...a,l],o,s+1,c)}}if(e.items&&i(e.items)&&!Array.isArray(e.items)){let i=e.items;if(i.$ref){if(o.has(i.$ref))return;o.add(i.$ref)}let l=i.$ref?A(i.$ref,c):i;l&&N(l,t,n,r,a,o,s+1,c)}}}function P(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.place);e?e.push(n):t.set(n.place,[n])}let n=[];for(let[e,r]of t){let t=r.map(e=>{let t=`- \`${[...e.path,e.name].join(`.`)}\` (${e.type}${e.required?`, required`:``})`,n=e.description.replace(/\s+/g,` `).trim();return n&&(t+=`\n ${n}`),e.enumValues?t+=`\n Enum: ${e.enumValues.map(e=>JSON.stringify(e)).join(`, `)}`:e.example&&(t+=`\n Example: ${e.example}`),t});n.push(`## ${e.charAt(0).toUpperCase()}${e.slice(1)}\n\n${t.join(`
24
24
  `)}`)}return n.join(`
25
25
 
26
26
  `)}export{d as buildApiDocsMarkdownDocs};
@@ -1 +1 @@
1
- import{isObject as e}from"../../../../../shared/utils/is-object.js";import{withPathPrefix as t}from"../../../../../shared/path-prefix.js";import{SPEC_DOWNLOAD_ROUTE_PATHS as n}from"./shared.js";import{toPosixPath as r}from"../../../../../shared/utils/to-posix-path.js";import{isMissingError as i}from"../../../../../shared/utils/is-missing-error.js";import{NESTED_CONFIG_FILENAME as a,deepMergeConfig as o,parseNestedConfig as s}from"../../../../config.js";import{contentIgnoreMatcherOf as c}from"../../../../ingest/scan.js";import{MOCK_SERVER_ROUTE_PREFIX as l,SPEC_KIND_GRAPHQL as u,mockPathPrefix as d}from"../../../types/api-entity.js";import{isPlanFeatureGranted as f}from"../../../../../shared/plan-gates.js";import{posix as p}from"node:path";import{decoratorTypes as m,preprocessorTypes as h}from"@redocly/config";import{FEEDBACK_TYPES as g}from"@redocly/theme/core/constants";const _=[`openapi`,`asyncapi`,`graphql`];function v(e,t,n){let r=O(t),i=Object.values(e.apis??{}),a=e=>O(p.join(n,e))===r;return i.find(e=>e.output!==void 0&&a(e.output))??i.find(e=>e.output===void 0&&a(e.root))}function y(e,t,n=``){let r=v(e,t,n);if(!r)return{};let i={};r.metadata&&(i.metadata=r.metadata);for(let e of _)r[e]&&typeof r[e]==`object`&&Object.assign(i,r[e]);return r.rbac!==void 0&&(i.rbac=r.rbac),i}async function b(e,t,n,r,i=n){let a=T(t,r),s=await w(e,i,c(t));return s===null?o(a,y(t,n)):o(o(a,E(s.config,r)),y(s.config,n,s.dir))}const x=[...m,...h];async function S(t,n,r,i=r){let a=await w(t,i,c(n)),s=a===null?[n,v(n,r,``)]:[n,a.config,v(a.config,r,a.dir)],l={};for(let t of s){if(!e(t))continue;let n={};for(let r of x)e(t[r])&&(n[r]=t[r]);l=o(l,n)}return{config:l,configDir:a?.dir??``}}async function C(e,t,n){return(await w(e,n,c(t)))?.config.feedback}async function w(e,t,n){for(let r=p.dirname(t);r!==`.`&&r!==`/`;r=p.dirname(r)){let t=p.join(r,a);if(n(t))continue;let i=await D(e,t);if(i!==null)return{config:i,dir:r}}return null}function T(e,t){return t===`arazzo`?{}:e[t]??{}}function E(e,t){let n={...T(e,t)};return e.mockServer&&(n.mockServer=e.mockServer),n}async function D(e,t){let n;try{n=await e.readFile(t)}catch(e){if(i(e))return null;throw e}return s(n,t).config}function O(e){return p.normalize(r(e)).replace(/^\.\/+/,``).replace(/^\/+/,``)}function k(n,r,i){let a=e(n.mockServer)?n.mockServer:{},o={...r.mockServer,...a};if(i===void 0||o.off===!0||!f(r,`mockServer`))return n;let s=t(l+d(i));return{...n,mockServer:{url:s,position:`first`,description:`Mock server`,...o}}}function A(e,r,i){if(Array.isArray(e.downloadUrls))return e;let a=e=>e.split(`/`).map(encodeURIComponent).join(`/`),o=i===u,s=o?n.graphql:n.bundle,c=o?[r]:[`.json`,`.yaml`].map(e=>r.replace(/\.[^./]+$/u,e));return{...e,downloadUrls:c.map(e=>({url:t(`${s}/${a(e)}?download`),title:p.basename(e)}))}}function j(e){return t(`${n.bundle}/${e}`)}const M={[g.RATING]:`Rate this section`,[g.SENTIMENT]:`Was this section helpful?`,[g.MOOD]:`Was this section helpful?`,[g.COMMENT]:`Share your feedback about this section`,[g.SCALE]:`How would you rate this section?`};function N(t,n,r){let i=[e(n)?n[`x-feedback`]:void 0,t.feedback,r].find(e);if(i===void 0)return t;let a=e(i.settings)?i.settings:{},o=typeof i.type==`string`?M[i.type]:void 0,s=a.label||o||``;return{...t,feedback:{...i,settings:{...a,label:s}}}}export{y as readApiOptionsFromConfig,S as resolveApiBundleConfig,b as resolveApiOptions,C as resolveNestedFeedback,j as schemaCatalogLink,A as withDownloadUrls,N as withFeedbackOption,k as withMockServerOption};
1
+ import{toPosixPath as e}from"../../../../../shared/utils/to-posix-path.js";import{isMissingError as t}from"../../../../../shared/utils/is-missing-error.js";import{isObject as n}from"../../../../../shared/utils/is-object.js";import{NESTED_CONFIG_FILENAME as r,deepMergeConfig as i,parseNestedConfig as a}from"../../../../config.js";import{contentIgnoreMatcherOf as o}from"../../../../ingest/scan.js";import{MOCK_SERVER_ROUTE_PREFIX as s,SPEC_KIND_GRAPHQL as c,mockPathPrefix as l}from"../../../types/api-entity.js";import{isPlanFeatureGranted as u}from"../../../../../shared/plan-gates.js";import{withPathPrefix as d}from"../../../../../shared/path-prefix.js";import{SPEC_DOWNLOAD_ROUTE_PATHS as f}from"./shared.js";import{posix as p}from"node:path";import{decoratorTypes as m,preprocessorTypes as h}from"@redocly/config";import{FEEDBACK_TYPES as g}from"@redocly/theme/core/constants";const _=[`openapi`,`asyncapi`,`graphql`];function v(e,t,n){let r=O(t),i=Object.values(e.apis??{}),a=e=>O(p.join(n,e))===r;return i.find(e=>e.output!==void 0&&a(e.output))??i.find(e=>e.output===void 0&&a(e.root))}function y(e,t,n=``){let r=v(e,t,n);if(!r)return{};let i={};r.metadata&&(i.metadata=r.metadata);for(let e of _)r[e]&&typeof r[e]==`object`&&Object.assign(i,r[e]);return r.rbac!==void 0&&(i.rbac=r.rbac),i}async function b(e,t,n,r,a=n){let s=T(t,r),c=await w(e,a,o(t));return c===null?i(s,y(t,n)):i(i(s,E(c.config,r)),y(c.config,n,c.dir))}const x=[...m,...h];async function S(e,t,r,a=r){let s=await w(e,a,o(t)),c=s===null?[t,v(t,r,``)]:[t,s.config,v(s.config,r,s.dir)],l={};for(let e of c){if(!n(e))continue;let t={};for(let r of x)n(e[r])&&(t[r]=e[r]);l=i(l,t)}return{config:l,configDir:s?.dir??``}}async function C(e,t,n){return(await w(e,n,o(t)))?.config.feedback}async function w(e,t,n){for(let i=p.dirname(t);i!==`.`&&i!==`/`;i=p.dirname(i)){let t=p.join(i,r);if(n(t))continue;let a=await D(e,t);if(a!==null)return{config:a,dir:i}}return null}function T(e,t){return t===`arazzo`?{}:e[t]??{}}function E(e,t){let n={...T(e,t)};return e.mockServer&&(n.mockServer=e.mockServer),n}async function D(e,n){let r;try{r=await e.readFile(n)}catch(e){if(t(e))return null;throw e}return a(r,n).config}function O(t){return p.normalize(e(t)).replace(/^\.\/+/,``).replace(/^\/+/,``)}function k(e,t,r){let i=n(e.mockServer)?e.mockServer:{},a={...t.mockServer,...i};if(r===void 0||a.off===!0||!u(t,`mockServer`))return e;let o=d(s+l(r));return{...e,mockServer:{url:o,position:`first`,description:`Mock server`,...a}}}function A(e,t,n){if(Array.isArray(e.downloadUrls))return e;let r=e=>e.split(`/`).map(encodeURIComponent).join(`/`),i=n===c,a=i?f.graphql:f.bundle,o=i?[t]:[`.json`,`.yaml`].map(e=>t.replace(/\.[^./]+$/u,e));return{...e,downloadUrls:o.map(e=>({url:d(`${a}/${r(e)}?download`),title:p.basename(e)}))}}function j(e){return d(`${f.bundle}/${e}`)}const M={[g.RATING]:`Rate this section`,[g.SENTIMENT]:`Was this section helpful?`,[g.MOOD]:`Was this section helpful?`,[g.COMMENT]:`Share your feedback about this section`,[g.SCALE]:`How would you rate this section?`};function N(e,t,r){let i=[n(t)?t[`x-feedback`]:void 0,e.feedback,r].find(n);if(i===void 0)return e;let a=n(i.settings)?i.settings:{},o=typeof i.type==`string`?M[i.type]:void 0,s=a.label||o||``;return{...e,feedback:{...i,settings:{...a,label:s}}}}export{y as readApiOptionsFromConfig,S as resolveApiBundleConfig,b as resolveApiOptions,C as resolveNestedFeedback,j as schemaCatalogLink,A as withDownloadUrls,N as withFeedbackOption,k as withMockServerOption};
@@ -1 +1 @@
1
- import{toJsonValue as e}from"../../../database/utils/json.js";import{builtInMarkdocTags as t}from"../../../markdown/constants/builtin-tags.js";import{isRbacScope as n}from"../../../../server/rbac/engine.js";import{hashBlobContent as r}from"../../../materialization/data-ref.js";import{resolveMarkdownAst as i}from"../../../markdown/resolve/ast.js";import{REDOCLY_TEAMS_RBAC as a}from"@redocly/config";async function o(o,s){if(!o||o.length===0)return null;let c=[],l=[],u=[];for(let[d,f]of o.entries()){if(!f.content){s.logger?.warn(`${s.file.path}: banner[${d}] has no content — the item is not shown`);continue}let{content:o,rbac:p,...m}=f,{ast:h,entityDeps:g,assetUsages:_}=await i(f.content,s.file.path,{resolverContext:s,tags:t}),v=p===void 0?{}:{[a]:n(p)?p:(s.logger?.warn(`${s.file.path}: banner[${d}] has an invalid "rbac" value — the item is hidden from everyone`),{})};c.push(e({...m,...v,ast:h,hash:r(f.content)})),l.push(...g),u.push(..._)}return c.length>0?{banner:c,deps:l,assetUsages:u}:null}export{o as resolveBannerForAppData};
1
+ import{toJsonValue as e}from"../../../database/utils/json.js";import{isRbacScope as t}from"../../../../server/rbac/engine.js";import{hashBlobContent as n}from"../../../materialization/data-ref.js";import{builtInMarkdocTags as r}from"../../../markdown/constants/builtin-tags.js";import{resolveMarkdownAst as i}from"../../../markdown/resolve/ast.js";import{REDOCLY_TEAMS_RBAC as a}from"@redocly/config";async function o(o,s){if(!o||o.length===0)return null;let c=[],l=[],u=[];for(let[d,f]of o.entries()){if(!f.content){s.logger?.warn(`${s.file.path}: banner[${d}] has no content — the item is not shown`);continue}let{content:o,rbac:p,...m}=f,{ast:h,entityDeps:g,assetUsages:_}=await i(f.content,s.file.path,{resolverContext:s,tags:r}),v=p===void 0?{}:{[a]:t(p)?p:(s.logger?.warn(`${s.file.path}: banner[${d}] has an invalid "rbac" value — the item is hidden from everyone`),{})};c.push(e({...m,...v,ast:h,hash:n(f.content)})),l.push(...g),u.push(..._)}return c.length>0?{banner:c,deps:l,assetUsages:u}:null}export{o as resolveBannerForAppData};
@@ -1 +1 @@
1
- import{defineContentPlugin as e}from"../../define.js";import{toJsonObject as t,toJsonValue as n}from"../../../database/utils/json.js";import{createEntityLoader as r}from"../../../loaders/define.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{buildSearchAppData as a}from"../../../../shared/search/facets.js";import{APP_DATA_STATIC_DATA_SLUG as o}from"../../../../shared/constants/app-data.js";import{isObject as s}from"../../../../shared/utils/is-object.js";import{splitUrlSuffix as c}from"../../../../shared/utils/routes/split-url-suffix.js";import{isAiHidden as l}from"../../../../shared/ask-ai/config-gate.js";import{parseNestedConfig as u}from"../../../config.js";import{isAttributionRemoved as d,isPlanFeatureGranted as f}from"../../../../shared/plan-gates.js";import{toNavItemRbacAnnotation as p}from"../../../../server/rbac/filter.js";import{resolvePageTarget as m}from"../../../../shared/utils/routes/resolve-page-target.js";import{listConfiguredProducts as h}from"../../../products.js";import{collectVersionGroups as g,findVersionedDirectories as ee}from"../../../versions/version-groups.js";import{publicLink as _}from"../../../versions/public-link.js";import{linkedPageAccess as v}from"../../utils/link-access.js";import{loadSidebarSubtreeLabel as y}from"../../utils/sidebar-label.js";import{resolveBannerForAppData as te}from"./banner.js";import{resolveLogoForAppData as ne}from"./logo.js";import{resolveNavbarIconsForAppData as b}from"./navbar-icons.js";import{resolveHtmlForAppData as x}from"./html.js";import{resolveSeoForAppData as S}from"./seo.js";import{productConfigPath as C,productLandingLink as w,resolveProductAssetsForAppData as T}from"./products.js";import{dirname as E,resolve as D}from"node:path";import{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";const k=`internal.app-data`,A=`1.32.0`,j=i(k,`app-data`);function M(e){return s(e)&&typeof e.owner==`string`&&`value`in e}const N=r(j,async e=>{let n=new Set(e.pluginRegistry.listFinalizePlugins().map(e=>e.id)),r={};for(let[t,i]of Object.entries(e.args.fragments??{}))M(i)&&n.has(i.owner)&&(r[t]=i.value);let i=await ne(e.config.logo,e.markdown,e.file.path);if(Object.keys(i.logo).length>0){let e=s(r.theme)?r.theme:{};r.theme=t({...e,logo:i.logo})}let a=await te(e.config.banner,e);if(a){let e=s(r.theme)?r.theme:{};r.theme=t({...e,banner:a.banner})}let o=await b(s(r.theme)?r.theme.navbar:void 0,e.markdown,e.file.path);if(o){let e=s(r.theme)?r.theme:{};r.theme=t({...e,navbar:o.navbar})}let c=await b(s(r.theme)?r.theme.footer:void 0,e.markdown,e.file.path);if(c){let e=s(r.theme)?r.theme:{};r.theme=t({...e,footer:c.navbar})}let l=await T(s(r.theme)?r.theme.products:void 0,e.markdown,e.file.path);if(l){let e=s(r.theme)?r.theme:{};r.theme=t({...e,products:l.products})}let u=await x(e.config,e.markdown,e.file.path,t=>e.io.readFile(D(E(e.file.absolutePath),t)),e.logger);u&&(r.html=t(u.html));let d=await S(r.seo,e.markdown,e.file.path);d&&(r.seo=d.seo);let f=[i,a,o,c,l,u,d];return{value:r,entityDeps:f.flatMap(e=>e?.deps??[]),assetUsages:f.flatMap(e=>e?.assetUsages??[])}});function P(e){return{isSystem:!0,key:o,kind:`loader`,type:null,metadata:null,loaderArgs:{pluginVersion:A},loaderId:j,pluginId:k,shouldInvalidateValue:!1,value:null,version:null,fragmentUpdates:e.fragmentUpdates}}const F=e({id:k,version:A,async finalize(e){let r=await g({io:e.io,routes:e.routes,versionedDirectories:ee(e.routes.all())}),i=e=>e&&_(e,r),a=t=>t&&{slug:_(t,r),loadLabel:()=>y(e.entities,t)},o=t=>a(e.routes.byFilePath(t)),c=t=>a(e.routes.bySlug(t)),l=t=>v(t,e.routes,r),u=await V(e.config,o,c,e.logger,l),d=await L(e,o,c,i,l);if(Object.keys(d).length>0){let e=s(u.theme)?u.theme:{};u.theme=t({...e,products:d}),u.pageProducts=n(Object.values(d).map(I))}return{appData:u}},loaders:[N]});function I(e){let{name:t,slug:n,configOverride:r}=e,i={name:t,slug:n},a=r?.analytics?.ga;return a&&(i.ga=a),i}async function L(e,n,r,i,o){let s={};for(let t of h(e.config)){let c=await w(t,e.routes,e.io,i);if(c===void 0){e.logger.warn(`Product "${t.id}" is left out of the product picker: "${t.folder}" has no page.`);continue}let l={name:t.name,folder:t.folder,slug:t.slug,link:c,[O]:o(c)??void 0};t.icon!==void 0&&(l.icon=t.icon);let u=C(t.folder),d=await e.io.exists(u)?await z(R(await e.io.readFile(u),u),{page:Q(n,r,u,e.logger),access:o},a(e.config),e.config):{};Object.keys(d).length>0&&(l.configOverride=d),s[t.id]=l}return t(s)}function R(e,t){try{return u(e,t).config}catch{return{}}}async function z(e,t,n,r){let i={},a=await K(e.navbar,t),o=await G(e.footer,t),s=W(e.breadcrumbs,t);return e.logo&&(i.logo=e.logo),a&&(i.navbar=a),o&&(i.footer=o),s&&f(r,`breadcrumbs`)&&(i.breadcrumbs=s),e.feedback&&(i.feedback=e.feedback),e.sidebar&&(i.sidebar=e.sidebar),e.codeSnippet&&(i.codeSnippet=e.codeSnippet),e.palette&&(i.palette=e.palette),e.search&&(i.search=await B(e.search,n,t)),e.analytics?.ga&&f(r,`analytics`)&&(i.analytics={ga:e.analytics.ga}),i}async function B(e,n,r){let i={...n},a=await q(e?.suggestedPages,r);return e?.hide!==void 0&&(i.hide=e.hide),e?.placement!==void 0&&(i.placement=e.placement),e?.shortcuts!==void 0&&(i.shortcuts=e.shortcuts),a.length>0&&(i.suggestedPages=a),t(i)}async function V(e,n,r,i,o=()=>void 0){let s={},c={page:Q(n,r,ae,i),access:o},l=await K(e.navbar,c),u=await G(e.footer,c),f=e.seo?.projectTitle,p=W(e.breadcrumbs,c),m={...l?{navbar:l}:{},...u?{footer:u}:{},...p?{breadcrumbs:p}:{},markdown:e.markdown,navigation:e.navigation,userMenu:await X(e.userMenu,c),feedback:e.feedback,consent:e.consent,...f?{seo:{projectTitle:f}}:{},aiAssistant:H(e),mcp:U(e),search:await B(e.search,a(e),c),sidebar:e.sidebar,versionPicker:e.versionPicker,codeSnippet:e.codeSnippet,palette:e.palette};if(e.colorMode&&(m.colorMode=e.colorMode),Object.keys(m).length>0&&(s.theme=m),e.analytics&&(s.analytics=e.analytics),e.planGates&&(s.removeAttribution=d(e)),e.removeAttribution===!0&&(s.removeConsoleAttribution=!0),e.seo){let{projectTitle:t,llmstxt:n,...r}=e.seo;Object.keys(r).length>0&&(s.seo=r)}return t(s)}function H(e){let t=l(e),n=e.aiAssistant?.trigger;return{...e.aiAssistant,hide:t,trigger:{...n,hide:n?.hide??t}}}function U(e){let t=e.mcp?.hide===!0;return{hide:t,docs:{hide:t}}}function W(e,n){if(!e)return null;let r={};e.hide!==void 0&&(r.hide=e.hide);let i=(e.prefixItems??[]).map(e=>{let t=e.page?n.page(e.page)?.link:void 0;return{icon:$(e.icon),label:$(e.label)??``,labelTranslationKey:$(e.labelTranslationKey),link:t,[O]:Y(n,t)}});return i.length>0&&(r.prefixItems=i),Object.keys(r).length>0?t(r):null}async function G(e,n){if(!e)return null;let r={hide:e.hide===!0},i=await q(e.items,n);return e.copyrightText!==void 0&&(r.copyrightText=e.copyrightText),e.logo&&(r.logo=e.logo),i.length>0&&(r.items=i),t(r)}async function K(e,n){if(!e)return null;let r={},i=await q(e.items,n);return e.hide!==void 0&&(r.hide=e.hide),i.length>0&&(r.items=i),Object.keys(r).length>0?t(r):null}async function q(e,t){return Array.isArray(e)?(await Promise.all(e.map(e=>J(e,t)))).filter(e=>e!==null):[]}async function J(e,n){if(typeof e==`string`)return J({page:e},n);if(!s(e))return null;if(typeof e.separator==`string`)return t({...Z(e),label:e.separator,type:`separator`});let r=await q(e.items,n),i=ie(e,n.page),a=i?.link,o=e.rbac===void 0?Y(n,a):void 0,c=$(e.label)??$(e.group)??(i?i.anchor??await i.loadLabel?.()??i.link:``);return typeof e.group==`string`||r.length>0?t({...Z(e),...a?{link:a}:{},...r.length>0?{items:r}:{},label:c,labelTranslationKey:$(e.groupTranslationKey)??$(e.labelTranslationKey),type:`group`,[O]:o}):a?t({...Z(e),...ce(e.external)??oe(a)?{external:!0}:{},label:c,link:a,type:`link`,[O]:o}):null}function Y(e,t){return t===void 0?void 0:e.access(t)??void 0}async function X(e,n){if(!e)return;let r=[];for(let t of e.items??[])r.push({...t,href:t.link});let i=await q(r,n);return t({...e,menu:i.length>0?i:void 0})}function Z(e){let t=se(e,[`additionalProps`,`expanded`,`labelTranslationKey`,`languageInsensitive`,`linePosition`,`linkedSidebars`,`menuStyle`,`selectFirstItemOnExpand`,`separatorLine`,`target`,`version`]),n=re(e.icon);return n.icon&&(t.icon=n.icon),n.srcSet&&(t.srcSet=n.srcSet),{...t,...p(e.rbac)}}function re(e){return typeof e==`string`?{icon:e}:s(e)&&typeof e.srcSet==`string`?{srcSet:e.srcSet}:{}}function ie(e,t){return typeof e.href==`string`&&e.href.trim()!==``?{link:e.href.trim()}:typeof e.page==`string`&&e.page.trim()!==``?t(e.page):null}const ae=`redocly.yaml`;function Q(e,t,n,r){let i={bySlug:e=>t?.(e),byFilePath:t=>e?.(t)};return e=>{let{path:t,suffix:a,anchor:o}=c(e.trim()),s=m(t,n,i);return s.kind===`escaped`?(r?.warn(`Config page reference escapes the content root`,{page:e}),null):s.kind===`missing`?(r?.warn(`Config page has no matching route`,{page:e}),{link:e.trim()}):{link:`${s.value.slug}${a}`,anchor:o,loadLabel:s.value.loadLabel}}}function oe(e){return/^(?:[a-z][a-z\d+.-]*:)?\/\//i.test(e)||/^(?:mailto|tel):/i.test(e)}function se(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function $(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function ce(e){return typeof e==`boolean`?e:void 0}export{k as APP_DATA_PLUGIN_ID,A as APP_DATA_PLUGIN_VERSION,j as APP_DATA_STATIC_DATA_LOADER_ID,o as APP_DATA_STATIC_DATA_SLUG,F as appDataContentPlugin,P as appDataSystemEntityDescriptor,V as buildConfigAppData,M as isAppDataFragment};
1
+ import{defineContentPlugin as e}from"../../define.js";import{toJsonObject as t,toJsonValue as n}from"../../../database/utils/json.js";import{createEntityLoader as r}from"../../../loaders/define.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{buildSearchAppData as a}from"../../../../shared/search/facets.js";import{isObject as o}from"../../../../shared/utils/is-object.js";import{isAiHidden as s}from"../../../../shared/ask-ai/config-gate.js";import{parseNestedConfig as c}from"../../../config.js";import{APP_DATA_STATIC_DATA_SLUG as l}from"../../../../shared/constants/app-data.js";import{isAttributionRemoved as u,isPlanFeatureGranted as d}from"../../../../shared/plan-gates.js";import{splitUrlSuffix as f}from"../../../../shared/utils/routes/split-url-suffix.js";import{toNavItemRbacAnnotation as p}from"../../../../server/rbac/filter.js";import{resolvePageTarget as m}from"../../../../shared/utils/routes/resolve-page-target.js";import{listConfiguredProducts as h}from"../../../products.js";import{collectVersionGroups as g,findVersionedDirectories as ee}from"../../../versions/version-groups.js";import{publicLink as _}from"../../../versions/public-link.js";import{linkedPageAccess as v}from"../../utils/link-access.js";import{loadSidebarSubtreeLabel as y}from"../../utils/sidebar-label.js";import{resolveBannerForAppData as te}from"./banner.js";import{resolveLogoForAppData as ne}from"./logo.js";import{resolveNavbarIconsForAppData as b}from"./navbar-icons.js";import{resolveHtmlForAppData as x}from"./html.js";import{resolveSeoForAppData as S}from"./seo.js";import{productConfigPath as C,productLandingLink as w,resolveProductAssetsForAppData as T}from"./products.js";import{dirname as E,resolve as D}from"node:path";import{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";const k=`internal.app-data`,A=`1.32.0`,j=i(k,`app-data`);function M(e){return o(e)&&typeof e.owner==`string`&&`value`in e}const N=r(j,async e=>{let n=new Set(e.pluginRegistry.listFinalizePlugins().map(e=>e.id)),r={};for(let[t,i]of Object.entries(e.args.fragments??{}))M(i)&&n.has(i.owner)&&(r[t]=i.value);let i=await ne(e.config.logo,e.markdown,e.file.path);if(Object.keys(i.logo).length>0){let e=o(r.theme)?r.theme:{};r.theme=t({...e,logo:i.logo})}let a=await te(e.config.banner,e);if(a){let e=o(r.theme)?r.theme:{};r.theme=t({...e,banner:a.banner})}let s=await b(o(r.theme)?r.theme.navbar:void 0,e.markdown,e.file.path);if(s){let e=o(r.theme)?r.theme:{};r.theme=t({...e,navbar:s.navbar})}let c=await b(o(r.theme)?r.theme.footer:void 0,e.markdown,e.file.path);if(c){let e=o(r.theme)?r.theme:{};r.theme=t({...e,footer:c.navbar})}let l=await T(o(r.theme)?r.theme.products:void 0,e.markdown,e.file.path);if(l){let e=o(r.theme)?r.theme:{};r.theme=t({...e,products:l.products})}let u=await x(e.config,e.markdown,e.file.path,t=>e.io.readFile(D(E(e.file.absolutePath),t)),e.logger);u&&(r.html=t(u.html));let d=await S(r.seo,e.markdown,e.file.path);d&&(r.seo=d.seo);let f=[i,a,s,c,l,u,d];return{value:r,entityDeps:f.flatMap(e=>e?.deps??[]),assetUsages:f.flatMap(e=>e?.assetUsages??[])}});function P(e){return{isSystem:!0,key:l,kind:`loader`,type:null,metadata:null,loaderArgs:{pluginVersion:A},loaderId:j,pluginId:k,shouldInvalidateValue:!1,value:null,version:null,fragmentUpdates:e.fragmentUpdates}}const F=e({id:k,version:A,async finalize(e){let r=await g({io:e.io,routes:e.routes,versionedDirectories:ee(e.routes.all())}),i=e=>e&&_(e,r),a=t=>t&&{slug:_(t,r),loadLabel:()=>y(e.entities,t)},s=t=>a(e.routes.byFilePath(t)),c=t=>a(e.routes.bySlug(t)),l=t=>v(t,e.routes,r),u=await V(e.config,s,c,e.logger,l),d=await L(e,s,c,i,l);if(Object.keys(d).length>0){let e=o(u.theme)?u.theme:{};u.theme=t({...e,products:d}),u.pageProducts=n(Object.values(d).map(I))}return{appData:u}},loaders:[N]});function I(e){let{name:t,slug:n,configOverride:r}=e,i={name:t,slug:n},a=r?.analytics?.ga;return a&&(i.ga=a),i}async function L(e,n,r,i,o){let s={};for(let t of h(e.config)){let c=await w(t,e.routes,e.io,i);if(c===void 0){e.logger.warn(`Product "${t.id}" is left out of the product picker: "${t.folder}" has no page.`);continue}let l={name:t.name,folder:t.folder,slug:t.slug,link:c,[O]:o(c)??void 0};t.icon!==void 0&&(l.icon=t.icon);let u=C(t.folder),d=await e.io.exists(u)?await z(R(await e.io.readFile(u),u),{page:Q(n,r,u,e.logger),access:o},a(e.config),e.config):{};Object.keys(d).length>0&&(l.configOverride=d),s[t.id]=l}return t(s)}function R(e,t){try{return c(e,t).config}catch{return{}}}async function z(e,t,n,r){let i={},a=await K(e.navbar,t),o=await G(e.footer,t),s=W(e.breadcrumbs,t);return e.logo&&(i.logo=e.logo),a&&(i.navbar=a),o&&(i.footer=o),s&&d(r,`breadcrumbs`)&&(i.breadcrumbs=s),e.feedback&&(i.feedback=e.feedback),e.sidebar&&(i.sidebar=e.sidebar),e.codeSnippet&&(i.codeSnippet=e.codeSnippet),e.palette&&(i.palette=e.palette),e.search&&(i.search=await B(e.search,n,t)),e.analytics?.ga&&d(r,`analytics`)&&(i.analytics={ga:e.analytics.ga}),i}async function B(e,n,r){let i={...n},a=await q(e?.suggestedPages,r);return e?.hide!==void 0&&(i.hide=e.hide),e?.placement!==void 0&&(i.placement=e.placement),e?.shortcuts!==void 0&&(i.shortcuts=e.shortcuts),a.length>0&&(i.suggestedPages=a),t(i)}async function V(e,n,r,i,o=()=>void 0){let s={},c={page:Q(n,r,ae,i),access:o},l=await K(e.navbar,c),d=await G(e.footer,c),f=e.seo?.projectTitle,p=W(e.breadcrumbs,c),m={...l?{navbar:l}:{},...d?{footer:d}:{},...p?{breadcrumbs:p}:{},markdown:e.markdown,navigation:e.navigation,userMenu:await X(e.userMenu,c),feedback:e.feedback,consent:e.consent,...f?{seo:{projectTitle:f}}:{},aiAssistant:H(e),mcp:U(e),search:await B(e.search,a(e),c),sidebar:e.sidebar,versionPicker:e.versionPicker,codeSnippet:e.codeSnippet,palette:e.palette};if(e.colorMode&&(m.colorMode=e.colorMode),Object.keys(m).length>0&&(s.theme=m),e.analytics&&(s.analytics=e.analytics),e.planGates&&(s.removeAttribution=u(e)),e.removeAttribution===!0&&(s.removeConsoleAttribution=!0),e.seo){let{projectTitle:t,llmstxt:n,...r}=e.seo;Object.keys(r).length>0&&(s.seo=r)}return t(s)}function H(e){let t=s(e),n=e.aiAssistant?.trigger;return{...e.aiAssistant,hide:t,trigger:{...n,hide:n?.hide??t}}}function U(e){let t=e.mcp?.hide===!0;return{hide:t,docs:{hide:t}}}function W(e,n){if(!e)return null;let r={};e.hide!==void 0&&(r.hide=e.hide);let i=(e.prefixItems??[]).map(e=>{let t=e.page?n.page(e.page)?.link:void 0;return{icon:$(e.icon),label:$(e.label)??``,labelTranslationKey:$(e.labelTranslationKey),link:t,[O]:Y(n,t)}});return i.length>0&&(r.prefixItems=i),Object.keys(r).length>0?t(r):null}async function G(e,n){if(!e)return null;let r={hide:e.hide===!0},i=await q(e.items,n);return e.copyrightText!==void 0&&(r.copyrightText=e.copyrightText),e.logo&&(r.logo=e.logo),i.length>0&&(r.items=i),t(r)}async function K(e,n){if(!e)return null;let r={},i=await q(e.items,n);return e.hide!==void 0&&(r.hide=e.hide),i.length>0&&(r.items=i),Object.keys(r).length>0?t(r):null}async function q(e,t){return Array.isArray(e)?(await Promise.all(e.map(e=>J(e,t)))).filter(e=>e!==null):[]}async function J(e,n){if(typeof e==`string`)return J({page:e},n);if(!o(e))return null;if(typeof e.separator==`string`)return t({...Z(e),label:e.separator,type:`separator`});let r=await q(e.items,n),i=ie(e,n.page),a=i?.link,s=e.rbac===void 0?Y(n,a):void 0,c=$(e.label)??$(e.group)??(i?i.anchor??await i.loadLabel?.()??i.link:``);return typeof e.group==`string`||r.length>0?t({...Z(e),...a?{link:a}:{},...r.length>0?{items:r}:{},label:c,labelTranslationKey:$(e.groupTranslationKey)??$(e.labelTranslationKey),type:`group`,[O]:s}):a?t({...Z(e),...ce(e.external)??oe(a)?{external:!0}:{},label:c,link:a,type:`link`,[O]:s}):null}function Y(e,t){return t===void 0?void 0:e.access(t)??void 0}async function X(e,n){if(!e)return;let r=[];for(let t of e.items??[])r.push({...t,href:t.link});let i=await q(r,n);return t({...e,menu:i.length>0?i:void 0})}function Z(e){let t=se(e,[`additionalProps`,`expanded`,`labelTranslationKey`,`languageInsensitive`,`linePosition`,`linkedSidebars`,`menuStyle`,`selectFirstItemOnExpand`,`separatorLine`,`target`,`version`]),n=re(e.icon);return n.icon&&(t.icon=n.icon),n.srcSet&&(t.srcSet=n.srcSet),{...t,...p(e.rbac)}}function re(e){return typeof e==`string`?{icon:e}:o(e)&&typeof e.srcSet==`string`?{srcSet:e.srcSet}:{}}function ie(e,t){return typeof e.href==`string`&&e.href.trim()!==``?{link:e.href.trim()}:typeof e.page==`string`&&e.page.trim()!==``?t(e.page):null}const ae=`redocly.yaml`;function Q(e,t,n,r){let i={bySlug:e=>t?.(e),byFilePath:t=>e?.(t)};return e=>{let{path:t,suffix:a,anchor:o}=f(e.trim()),s=m(t,n,i);return s.kind===`escaped`?(r?.warn(`Config page reference escapes the content root`,{page:e}),null):s.kind===`missing`?(r?.warn(`Config page has no matching route`,{page:e}),{link:e.trim()}):{link:`${s.value.slug}${a}`,anchor:o,loadLabel:s.value.loadLabel}}}function oe(e){return/^(?:[a-z][a-z\d+.-]*:)?\/\//i.test(e)||/^(?:mailto|tel):/i.test(e)}function se(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function $(e){return typeof e==`string`&&e.trim()!==``?e:void 0}function ce(e){return typeof e==`boolean`?e:void 0}export{k as APP_DATA_PLUGIN_ID,A as APP_DATA_PLUGIN_VERSION,j as APP_DATA_STATIC_DATA_LOADER_ID,l as APP_DATA_STATIC_DATA_SLUG,F as appDataContentPlugin,P as appDataSystemEntityDescriptor,V as buildConfigAppData,M as isAppDataFragment};
@@ -1 +1 @@
1
- import{LoaderDataContext as e}from"../../../../../client/contexts.js";import{telemetry as t}from"../../../../../client/telemetry/telemetry.js";import{CATALOG_CLASSIC_DEP_KEY as n}from"./contract.js";import{readSelectionsFromSearch as r,readTermFromSearch as i,resolveCatalog as a,selectFilterOption as o,toCatalogItems as s,toggleFilterOption as c,writeSelectionsToSearch as l}from"./catalog-filtering.js";import*as u from"react";import{useLocation as d,useNavigate as f}from"react-router";import{getBaseDataAttributes as p}from"@redocly/theme/core/utils";const m=[];function h(e){t.sendCatalogFilterChangedMessage([{...p(`catalogFilter`,`field`),type:e}])}function g(t){let p=d(),g=f(),_=u.useContext(e)[n],v=t.filters??m,[y,b]=u.useState(()=>r(p.search,v)),[x,S]=u.useState(()=>i(p.search)),C=u.useCallback(e=>{S(e),h(`term`)},[]),w=u.useMemo(()=>s(_?.items??[]),[_]);u.useEffect(()=>{let e=l(p.search,v,y,x);e!==p.search.replace(/^\?/,``)&&g({search:e},{replace:!0})},[v,x,p.search,g,y]);let T=u.useMemo(()=>a({filters:v,groupByFirstFilter:t.groupByFirstFilter,items:w,selections:y,term:x}),[t.groupByFirstFilter,v,x,w,y]);return u.useMemo(()=>({groups:T.groups,filters:T.filters.map((e,t)=>({...e,toggleOption:e=>{b(n=>c(n,t,e)),h(`toggle`),window.scrollTo(0,0)},selectOption:e=>{b(n=>o(n,v,t,e)),h(`select`),window.scrollTo(0,0)}})),filterTerm:x,setFilterTerm:C}),[C,v,x,T])}export{g as useCatalogClassic};
1
+ import{CATALOG_CLASSIC_DEP_KEY as e}from"./contract.js";import{LoaderDataContext as t}from"../../../../../client/contexts.js";import{telemetry as n}from"../../../../../client/telemetry/telemetry.js";import{readSelectionsFromSearch as r,readTermFromSearch as i,resolveCatalog as a,selectFilterOption as o,toCatalogItems as s,toggleFilterOption as c,writeSelectionsToSearch as l}from"./catalog-filtering.js";import*as u from"react";import{useLocation as d,useNavigate as f}from"react-router";import{getBaseDataAttributes as p}from"@redocly/theme/core/utils";const m=[];function h(e){n.sendCatalogFilterChangedMessage([{...p(`catalogFilter`,`field`),type:e}])}function g(n){let p=d(),g=f(),_=u.useContext(t)[e],v=n.filters??m,[y,b]=u.useState(()=>r(p.search,v)),[x,S]=u.useState(()=>i(p.search)),C=u.useCallback(e=>{S(e),h(`term`)},[]),w=u.useMemo(()=>s(_?.items??[]),[_]);u.useEffect(()=>{let e=l(p.search,v,y,x);e!==p.search.replace(/^\?/,``)&&g({search:e},{replace:!0})},[v,x,p.search,g,y]);let T=u.useMemo(()=>a({filters:v,groupByFirstFilter:n.groupByFirstFilter,items:w,selections:y,term:x}),[n.groupByFirstFilter,v,x,w,y]);return u.useMemo(()=>({groups:T.groups,filters:T.filters.map((e,t)=>({...e,toggleOption:e=>{b(n=>c(n,t,e)),h(`toggle`),window.scrollTo(0,0)},selectOption:e=>{b(n=>o(n,v,t,e)),h(`select`),window.scrollTo(0,0)}})),filterTerm:x,setFilterTerm:C}),[C,v,x,T])}export{g as useCatalogClassic};
@@ -1 +1 @@
1
- import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{createServerFn as r}from"../../server-fn.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{runtimeTemplate as a}from"../../templates.js";import{normalizeRouteSlug as o}from"../../../../shared/utils/routes/normalize-route-slug.js";import{CATALOG_CLASSIC_DEP_KEY as s}from"./client/contract.js";import{SIDEBAR_CONTRIBUTIONS_ENTITY_TYPE as c}from"../sidebar/contributions.js";import{catalogEntityKey as l}from"./entity-key.js";import{buildCatalogCards as u,loadVersionGroups as d,pickDefaultVersions as f,resolveCatalogMembers as p}from"./resolve-items.js";import{catalogSidebarContributions as m}from"./sidebars.js";const h=`internal.catalog-classic`,g=`catalog-classic`,_=i(h,`catalog`),v=i(h,`sidebars`),y=i(h,`deliver`),b=t(_,async e=>{let t=p(e.args.items,e),{versionGroups:n,entityDeps:r}=await d(t,e),i=e.args.config.separateVersions?t:f(t,n),a=await u(i,n,e);return{value:{catalogId:e.args.catalogId,config:e.args.config,items:a},entityDeps:r}}),x=t(v,async e=>{let t=p(e.args.items,{routes:e.routes}),{versionGroups:n,entityDeps:r}=await d(t,e);return{value:await m(t,n,{label:e.args.title,link:e.args.slug},e),entityDeps:r}}),S=r(y,{filePath:`./server/deliver.ts`,importer:import.meta.url,exportName:`deliver`,cacheable:!0});function C(e){return Object.entries(e.catalogClassic??e.catalog??{})}const w=e({id:h,version:`1.7.0`,content:{extractAll(e){let t=[],n=[];for(let[r,i]of C(e.config)){let{items:e,...a}=i,u=o(String(i.slug)),d=typeof i.title==`string`?i.title:`API Catalog`;t.push(b.withArgs({catalogId:r,config:a,items:e},{stableKey:l(r),metadata:{sourcePath:u}}),x.withArgs({items:e,slug:u,title:d},{stableKey:`${l(r)}:sidebars`,type:c})),n.push({deps:{[s]:S.withArgs({catalogId:r})},metadata:{title:d},routeId:r,slug:u,template:g})}return{entities:t,routes:n}}},loaders:[b,x],server:{functions:[S]},templates:{[g]:a(n(`./client/template.tsx`,import.meta.url))}});export{_ as CATALOG_CLASSIC_LOADER_ID,h as CATALOG_CLASSIC_PLUGIN_ID,y as CATALOG_CLASSIC_SERVER_FN_ID,v as CATALOG_CLASSIC_SIDEBARS_LOADER_ID,g as CATALOG_CLASSIC_TEMPLATE_ID,w as catalogClassicContentPlugin};
1
+ import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{createServerFn as r}from"../../server-fn.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{runtimeTemplate as a}from"../../templates.js";import{normalizeRouteSlug as o}from"../../../../shared/utils/routes/normalize-route-slug.js";import{SIDEBAR_CONTRIBUTIONS_ENTITY_TYPE as s}from"../sidebar/contributions.js";import{CATALOG_CLASSIC_DEP_KEY as c}from"./client/contract.js";import{catalogEntityKey as l}from"./entity-key.js";import{buildCatalogCards as u,loadVersionGroups as d,pickDefaultVersions as f,resolveCatalogMembers as p}from"./resolve-items.js";import{catalogSidebarContributions as m}from"./sidebars.js";const h=`internal.catalog-classic`,g=`catalog-classic`,_=i(h,`catalog`),v=i(h,`sidebars`),y=i(h,`deliver`),b=t(_,async e=>{let t=p(e.args.items,e),{versionGroups:n,entityDeps:r}=await d(t,e),i=e.args.config.separateVersions?t:f(t,n),a=await u(i,n,e);return{value:{catalogId:e.args.catalogId,config:e.args.config,items:a},entityDeps:r}}),x=t(v,async e=>{let t=p(e.args.items,{routes:e.routes}),{versionGroups:n,entityDeps:r}=await d(t,e);return{value:await m(t,n,{label:e.args.title,link:e.args.slug},e),entityDeps:r}}),S=r(y,{filePath:`./server/deliver.ts`,importer:import.meta.url,exportName:`deliver`,cacheable:!0});function C(e){return Object.entries(e.catalogClassic??e.catalog??{})}const w=e({id:h,version:`1.7.0`,content:{extractAll(e){let t=[],n=[];for(let[r,i]of C(e.config)){let{items:e,...a}=i,u=o(String(i.slug)),d=typeof i.title==`string`?i.title:`API Catalog`;t.push(b.withArgs({catalogId:r,config:a,items:e},{stableKey:l(r),metadata:{sourcePath:u}}),x.withArgs({items:e,slug:u,title:d},{stableKey:`${l(r)}:sidebars`,type:s})),n.push({deps:{[c]:S.withArgs({catalogId:r})},metadata:{title:d},routeId:r,slug:u,template:g})}return{entities:t,routes:n}}},loaders:[b,x],server:{functions:[S]},templates:{[g]:a(n(`./client/template.tsx`,import.meta.url))}});export{_ as CATALOG_CLASSIC_LOADER_ID,h as CATALOG_CLASSIC_PLUGIN_ID,y as CATALOG_CLASSIC_SERVER_FN_ID,v as CATALOG_CLASSIC_SIDEBARS_LOADER_ID,g as CATALOG_CLASSIC_TEMPLATE_ID,w as catalogClassicContentPlugin};
@@ -1 +1 @@
1
- import{APP_DATA_STATIC_DATA_SLUG as e}from"../../../shared/constants/app-data.js";import{SIDEBAR_ROUTE_DEP_KEY as t}from"../../../shared/constants/route-deps.js";import{STATIC_FOLDER_PLUGIN_ID as n,STATIC_FOLDER_PREFIX as r,isStaticFolderPath as i,staticFolderContentPlugin as a}from"./static-folder/index.js";import{ASSETS_PLUGIN_ID as o,ASSET_ENTITY_KEY_PREFIX as s,assetsContentPlugin as c}from"./assets/index.js";import{FOLDER_SIDEBAR_FILENAME_REGEX as l,SIDEBAR_AGGREGATOR_LOADER_ID as u,SIDEBAR_FILENAME_REGEX as d,SIDEBAR_PLUGIN_ID as f,isTabbedSidebar as p,resolveAutoSidebar as m,sidebarContentPlugin as h}from"./sidebar/index.js";import{APP_DATA_PLUGIN_ID as g,APP_DATA_PLUGIN_VERSION as ee,APP_DATA_STATIC_DATA_LOADER_ID as _,appDataContentPlugin as v,appDataSystemEntityDescriptor as y,buildConfigAppData as b,isAppDataFragment as x}from"./app-data/index.js";import{apiDocsContentPlugin as S}from"./api-docs/index.js";import"./api-functions/constants.js";import{API_FUNCTIONS_PLUGIN_ID as C,apiFunctionsContentPlugin as w}from"./api-functions/index.js";import{CATALOG_CLASSIC_LOADER_ID as T,CATALOG_CLASSIC_PLUGIN_ID as E,CATALOG_CLASSIC_SERVER_FN_ID as D,CATALOG_CLASSIC_SIDEBARS_LOADER_ID as O,CATALOG_CLASSIC_TEMPLATE_ID as k,catalogClassicContentPlugin as A}from"./catalog-classic/index.js";import{L10N_PLUGIN_ID as j}from"./l10n/translations-loader.js";import{L10N_PLUGIN_VERSION as M,l10nContentPlugin as N}from"./l10n/index.js";import{MARKDOC_DOCUMENT_LOADER_ID as P,MARKDOC_SEARCH_GROUP as F,MARKDOC_SIDEBAR_ITEM_LOADER_ID as te,MARKDOC_TEMPLATE_ID as I,markdocContentPlugin as L}from"./markdoc/index.js";import{mcpContentPlugin as R}from"./mcp/index.js";import{MOCK_SERVER_PLUGIN_ID as z,MOCK_SERVER_ROUTE_PATH as B,mockServerContentPlugin as V}from"./mock/index.js";import{REACT_PAGE_SEARCH_LOADER_KEY as H,reactPageContentPlugin as U}from"./react-page/index.js";import{REVISIONS_PLUGIN_ID as W,revisionsContentPlugin as G}from"./revisions/index.js";import{SCORECARD_CLASSIC_PLUGIN_ID as K,SCORECARD_CLASSIC_TEMPLATE_ID as q,scorecardClassicContentPlugin as J}from"./scorecard-classic/index.js";import{SKILLS_PLUGIN_ID as Y,SKILL_MARKDOWN_ROUTE_PATH as X,skillsContentPlugin as Z}from"./skills/index.js";import{VERSIONS_PLUGIN_ID as Q,versionsContentPlugin as $}from"./versions/index.js";function ne(){return[v,N,a,c,L,h,$,G,A,S,J,w,V,R,U,Z]}export{C as API_FUNCTIONS_PLUGIN_ID,g as APP_DATA_PLUGIN_ID,ee as APP_DATA_PLUGIN_VERSION,_ as APP_DATA_STATIC_DATA_LOADER_ID,e as APP_DATA_STATIC_DATA_SLUG,o as ASSETS_PLUGIN_ID,s as ASSET_ENTITY_KEY_PREFIX,T as CATALOG_CLASSIC_LOADER_ID,E as CATALOG_CLASSIC_PLUGIN_ID,D as CATALOG_CLASSIC_SERVER_FN_ID,O as CATALOG_CLASSIC_SIDEBARS_LOADER_ID,k as CATALOG_CLASSIC_TEMPLATE_ID,l as FOLDER_SIDEBAR_FILENAME_REGEX,j as L10N_PLUGIN_ID,M as L10N_PLUGIN_VERSION,P as MARKDOC_DOCUMENT_LOADER_ID,F as MARKDOC_SEARCH_GROUP,te as MARKDOC_SIDEBAR_ITEM_LOADER_ID,I as MARKDOC_TEMPLATE_ID,z as MOCK_SERVER_PLUGIN_ID,B as MOCK_SERVER_ROUTE_PATH,H as REACT_PAGE_SEARCH_LOADER_KEY,W as REVISIONS_PLUGIN_ID,K as SCORECARD_CLASSIC_PLUGIN_ID,q as SCORECARD_CLASSIC_TEMPLATE_ID,u as SIDEBAR_AGGREGATOR_LOADER_ID,d as SIDEBAR_FILENAME_REGEX,f as SIDEBAR_PLUGIN_ID,t as SIDEBAR_ROUTE_DEP_KEY,Y as SKILLS_PLUGIN_ID,X as SKILL_MARKDOWN_ROUTE_PATH,n as STATIC_FOLDER_PLUGIN_ID,r as STATIC_FOLDER_PREFIX,Q as VERSIONS_PLUGIN_ID,S as apiDocsContentPlugin,w as apiFunctionsContentPlugin,v as appDataContentPlugin,y as appDataSystemEntityDescriptor,c as assetsContentPlugin,b as buildConfigAppData,A as catalogClassicContentPlugin,ne as createInternalContentPlugins,x as isAppDataFragment,i as isStaticFolderPath,p as isTabbedSidebar,N as l10nContentPlugin,L as markdocContentPlugin,R as mcpContentPlugin,V as mockServerContentPlugin,U as reactPageContentPlugin,m as resolveAutoSidebar,G as revisionsContentPlugin,J as scorecardClassicContentPlugin,h as sidebarContentPlugin,Z as skillsContentPlugin,a as staticFolderContentPlugin,$ as versionsContentPlugin};
1
+ import{STATIC_FOLDER_PLUGIN_ID as e,STATIC_FOLDER_PREFIX as t,isStaticFolderPath as n,staticFolderContentPlugin as r}from"./static-folder/index.js";import{ASSETS_PLUGIN_ID as i,ASSET_ENTITY_KEY_PREFIX as a,assetsContentPlugin as o}from"./assets/index.js";import{APP_DATA_STATIC_DATA_SLUG as s}from"../../../shared/constants/app-data.js";import{SIDEBAR_ROUTE_DEP_KEY as c}from"../../../shared/constants/route-deps.js";import{FOLDER_SIDEBAR_FILENAME_REGEX as l,SIDEBAR_AGGREGATOR_LOADER_ID as u,SIDEBAR_FILENAME_REGEX as d,SIDEBAR_PLUGIN_ID as f,isTabbedSidebar as p,resolveAutoSidebar as m,sidebarContentPlugin as h}from"./sidebar/index.js";import{APP_DATA_PLUGIN_ID as g,APP_DATA_PLUGIN_VERSION as ee,APP_DATA_STATIC_DATA_LOADER_ID as _,appDataContentPlugin as v,appDataSystemEntityDescriptor as y,buildConfigAppData as b,isAppDataFragment as x}from"./app-data/index.js";import{apiDocsContentPlugin as S}from"./api-docs/index.js";import"./api-functions/constants.js";import{API_FUNCTIONS_PLUGIN_ID as C,apiFunctionsContentPlugin as w}from"./api-functions/index.js";import{CATALOG_CLASSIC_LOADER_ID as T,CATALOG_CLASSIC_PLUGIN_ID as E,CATALOG_CLASSIC_SERVER_FN_ID as D,CATALOG_CLASSIC_SIDEBARS_LOADER_ID as O,CATALOG_CLASSIC_TEMPLATE_ID as k,catalogClassicContentPlugin as A}from"./catalog-classic/index.js";import{L10N_PLUGIN_ID as j}from"./l10n/translations-loader.js";import{L10N_PLUGIN_VERSION as M,l10nContentPlugin as N}from"./l10n/index.js";import{MARKDOC_DOCUMENT_LOADER_ID as P,MARKDOC_SEARCH_GROUP as F,MARKDOC_SIDEBAR_ITEM_LOADER_ID as te,MARKDOC_TEMPLATE_ID as I,markdocContentPlugin as L}from"./markdoc/index.js";import{mcpContentPlugin as R}from"./mcp/index.js";import{MOCK_SERVER_PLUGIN_ID as z,MOCK_SERVER_ROUTE_PATH as B,mockServerContentPlugin as V}from"./mock/index.js";import{REACT_PAGE_SEARCH_LOADER_KEY as H,reactPageContentPlugin as U}from"./react-page/index.js";import{REVISIONS_PLUGIN_ID as W,revisionsContentPlugin as G}from"./revisions/index.js";import{SCORECARD_CLASSIC_PLUGIN_ID as K,SCORECARD_CLASSIC_TEMPLATE_ID as q,scorecardClassicContentPlugin as J}from"./scorecard-classic/index.js";import{SKILLS_PLUGIN_ID as Y,SKILL_MARKDOWN_ROUTE_PATH as X,skillsContentPlugin as Z}from"./skills/index.js";import{VERSIONS_PLUGIN_ID as Q,versionsContentPlugin as $}from"./versions/index.js";function ne(){return[v,N,r,o,L,h,$,G,A,S,J,w,V,R,U,Z]}export{C as API_FUNCTIONS_PLUGIN_ID,g as APP_DATA_PLUGIN_ID,ee as APP_DATA_PLUGIN_VERSION,_ as APP_DATA_STATIC_DATA_LOADER_ID,s as APP_DATA_STATIC_DATA_SLUG,i as ASSETS_PLUGIN_ID,a as ASSET_ENTITY_KEY_PREFIX,T as CATALOG_CLASSIC_LOADER_ID,E as CATALOG_CLASSIC_PLUGIN_ID,D as CATALOG_CLASSIC_SERVER_FN_ID,O as CATALOG_CLASSIC_SIDEBARS_LOADER_ID,k as CATALOG_CLASSIC_TEMPLATE_ID,l as FOLDER_SIDEBAR_FILENAME_REGEX,j as L10N_PLUGIN_ID,M as L10N_PLUGIN_VERSION,P as MARKDOC_DOCUMENT_LOADER_ID,F as MARKDOC_SEARCH_GROUP,te as MARKDOC_SIDEBAR_ITEM_LOADER_ID,I as MARKDOC_TEMPLATE_ID,z as MOCK_SERVER_PLUGIN_ID,B as MOCK_SERVER_ROUTE_PATH,H as REACT_PAGE_SEARCH_LOADER_KEY,W as REVISIONS_PLUGIN_ID,K as SCORECARD_CLASSIC_PLUGIN_ID,q as SCORECARD_CLASSIC_TEMPLATE_ID,u as SIDEBAR_AGGREGATOR_LOADER_ID,d as SIDEBAR_FILENAME_REGEX,f as SIDEBAR_PLUGIN_ID,c as SIDEBAR_ROUTE_DEP_KEY,Y as SKILLS_PLUGIN_ID,X as SKILL_MARKDOWN_ROUTE_PATH,e as STATIC_FOLDER_PLUGIN_ID,t as STATIC_FOLDER_PREFIX,Q as VERSIONS_PLUGIN_ID,S as apiDocsContentPlugin,w as apiFunctionsContentPlugin,v as appDataContentPlugin,y as appDataSystemEntityDescriptor,o as assetsContentPlugin,b as buildConfigAppData,A as catalogClassicContentPlugin,ne as createInternalContentPlugins,x as isAppDataFragment,n as isStaticFolderPath,p as isTabbedSidebar,N as l10nContentPlugin,L as markdocContentPlugin,R as mcpContentPlugin,V as mockServerContentPlugin,U as reactPageContentPlugin,m as resolveAutoSidebar,G as revisionsContentPlugin,J as scorecardClassicContentPlugin,h as sidebarContentPlugin,Z as skillsContentPlugin,r as staticFolderContentPlugin,$ as versionsContentPlugin};
@@ -1 +1 @@
1
- import{MARKDOC_DOCUMENT_LOADER_KEY as e}from"../../../../../shared/constants/route-deps.js";import{collectHeadings as t}from"../../../../markdown/utils/collect-headings.js";import{MarkdocRenderer as n}from"../../../../markdown/client/markdoc-components.js";import*as r from"react";import{jsx as i}from"react/jsx-runtime";import{extendDetailsBehaviour as a}from"@redocly/theme/core/utils";import{DEFAULT_FEEDBACK_TYPE as o}from"@redocly/theme/core/constants";import{useThemeConfig as s,useThemeHooks as c}from"@redocly/theme/core/hooks";import{useLoaderData as l}from"virtual:realm-runtime";import{Feedback as u}from"@redocly/theme/components/Feedback/Feedback";import{TableOfContent as d}from"@redocly/theme/components/TableOfContent/TableOfContent";import{CodeWalkthroughLayout as f}from"@redocly/theme/layouts/CodeWalkthroughLayout";import{DocumentationLayout as p}from"@redocly/theme/layouts/DocumentationLayout";function m(m){let h=l(e),{useSidebarSiblingsData:g}=c(),{markdown:_,feedback:v}=s(),{nextPage:y,prevPage:b}=g()??{},[x,S]=r.useState(null),C=r.useMemo(()=>h?t(h.ast):[],[h]);if(r.useEffect(()=>a(),[h]),!h)return null;let w=/* @__PURE__ */ i(n,{ast:h.ast,withPageActions:!0});return h.tagList?.includes(`code-walkthrough`)?/* @__PURE__ */ i(f,{children:w}):/* @__PURE__ */ i(p,{config:_,editPage:h.editPage,lastModified:h.lastModified,feedback:/* @__PURE__ */ i(u,{...v,type:v?.type??o,settings:v?.settings??{},path:m.page.slug??m.page.path}),nextPage:y,prevPage:b,tableOfContent:/* @__PURE__ */ i(d,{contentWrapper:x,headings:C}),children:/* @__PURE__ */ i(`div`,{ref:S,children:w})})}export{m as default};
1
+ import{MARKDOC_DOCUMENT_LOADER_KEY as e}from"../../../../../shared/constants/route-deps.js";import{collectHeadings as t}from"../../../../markdown/utils/collect-headings.js";import{MarkdocRenderer as n}from"../../../../markdown/client/markdoc-components.js";import{DEFAULT_FEEDBACK_TYPE as r}from"@redocly/theme/core/constants";import*as i from"react";import{jsx as a}from"react/jsx-runtime";import{extendDetailsBehaviour as o}from"@redocly/theme/core/utils";import{useThemeConfig as s,useThemeHooks as c}from"@redocly/theme/core/hooks";import{useLoaderData as l}from"virtual:realm-runtime";import{Feedback as u}from"@redocly/theme/components/Feedback/Feedback";import{TableOfContent as d}from"@redocly/theme/components/TableOfContent/TableOfContent";import{CodeWalkthroughLayout as f}from"@redocly/theme/layouts/CodeWalkthroughLayout";import{DocumentationLayout as p}from"@redocly/theme/layouts/DocumentationLayout";function m(m){let h=l(e),{useSidebarSiblingsData:g}=c(),{markdown:_,feedback:v}=s(),{nextPage:y,prevPage:b}=g()??{},[x,S]=i.useState(null),C=i.useMemo(()=>h?t(h.ast):[],[h]);if(i.useEffect(()=>o(),[h]),!h)return null;let w=/* @__PURE__ */ a(n,{ast:h.ast,withPageActions:!0});return h.tagList?.includes(`code-walkthrough`)?/* @__PURE__ */ a(f,{children:w}):/* @__PURE__ */ a(p,{config:_,editPage:h.editPage,lastModified:h.lastModified,feedback:/* @__PURE__ */ a(u,{...v,type:v?.type??r,settings:v?.settings??{},path:m.page.slug??m.page.path}),nextPage:y,prevPage:b,tableOfContent:/* @__PURE__ */ a(d,{contentWrapper:x,headings:C}),children:/* @__PURE__ */ a(`div`,{ref:S,children:w})})}export{m as default};
@@ -1 +1 @@
1
- import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import{runtimeTemplate as i}from"../../templates.js";import{SEARCH_GROUP_FACET_FIELD as a}from"../../../../shared/search/facets.js";import{configuredFacetFields as o,extractFacetsFromFrontmatter as s,invalidFacetValueProblems as c,searchCategoryOf as l}from"../../../search/facet-values.js";import{isObject as u}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as d}from"../../../../shared/utils/routes/normalize-route-slug.js";import{MARKDOC_DOCUMENT_LOADER_KEY as f}from"../../../../shared/constants/route-deps.js";import{markdocNodeRange as p}from"../../../markdown/utils/node-source-range.js";import{replaceWithMarkdocError as m}from"../../../markdown/tags/markdoc-error.js";import{CODE_WALKTHROUGH_TAG_NAMES as h,builtInMarkdocTags as g}from"../../../markdown/constants/builtin-tags.js";import{isMarkdocValidationEnabled as ee,resolveMarkdocTagSet as _,resolveMarkdownPageValidationSet as te,userMarkdocSchemaFiles as v,userMarkdocTagNames as y}from"../../../markdown/constants/tag-sets.js";import{splitUrlSuffix as b}from"../../../../shared/utils/routes/split-url-suffix.js";import{isSkillContentPath as ne}from"../../utils/skill-paths.js";import{resolveContentPath as x}from"../../../../shared/utils/resolve-content-path.js";import{PAGE_BANNER_SCHEMA as re,sanitizeConfig as ie}from"../../../config-schema.js";import{notInPlanProblem as ae}from"../../../plan-gates.js";import{matchPathMap as oe}from"../../utils/glob.js";import{filePathToRouteSlug as se}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{isPlanFeatureGranted as S}from"../../../../shared/plan-gates.js";import{packMarkdocAst as ce,unpackMarkdocAst as C}from"../../../markdown/utils/packed-ast.js";import{isRouteSlugTarget as le}from"../../../../shared/utils/routes/is-route-slug-target.js";import{loadSidebarSubtreeLabel as ue}from"../../utils/sidebar-label.js";import{walkMarkdocAst as w}from"../../../markdown/utils/walk-markdoc-ast.js";import{markdocFirstHeading as de}from"../../../markdown/search/to-text.js";import{safeDecodeURI as fe}from"../../../../shared/utils/safe-decode-uri.js";import{shiftRange as T}from"../../../../shared/utils/shift-range.js";import{classifyLinkTarget as E}from"../../../link-checker/classify.js";import{onDiskLinkRefs as D}from"../../../link-checker/node-ref.js";import{isPartialPath as O}from"../../../markdown/utils/partials.js";import{FRONTMATTER_BLOCK_RE as k,computeFrontmatterLineOffset as A}from"../../../markdown/utils/frontmatter-offset.js";import{inlineRawPartials as j}from"../../../markdown/resolve/raw-partials.js";import{resolveMarkdownAst as M}from"../../../markdown/resolve/ast.js";import{resolveBannerForAppData as N}from"../app-data/banner.js";import{pageLocale as P}from"../../utils/page-locale.js";import{markdocAstToMarkdownDoc as F}from"../../../markdown/search/to-markdown.js";import{collectAnchors as I}from"../../../markdown/utils/collect-anchors.js";import{frontmatterVariable as L}from"../../../markdown/utils/frontmatter-variable.js";import{markdownFirstHeading as R}from"../../../markdown/utils/first-heading.js";import{markdocAstToSearchSections as z}from"../../../markdown/search/to-sections.js";import{isInternalPagePath as B}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as V}from"../../utils/explicit-slugs.js";import{SOURCE_TEMPLATE_PREFIX as pe}from"../../../../shared/constants/template-ids.js";import{captureSnippet as H,splitSourceLines as me}from"../../../../shared/utils/capture-snippet.js";import{curationKeywordsOf as he}from"../../../search/keywords.js";import ge from"js-yaml";const U=`markdoc-page`,W=r(`internal.markdoc`,`document`),G=r(`internal.markdoc`,`sidebar-item`),_e=`Documentation`,K=t(W,async e=>{let t=await e.io.readFile(e.file.absolutePath),{content:n,frontmatter:r,frontmatterError:i}=Y(t),a=J(e),{ast:o,entityDeps:s,assetUsages:c,tagList:l,problems:u,linkRefs:d}=await M(n,e.file.path,{resolverContext:a,tags:(await _()).tags,variables:{get env(){return e.config.publicEnv??{}}},transform:t=>Ee(t,e.file.path,Te(e.config)),validation:ee()?await te():void 0}),f=A(t);je(o);let p=await we(r.seo,e),m=S(e.config,`banner`)?await N(Me(r,e.file.path,e.logger),a):void 0,h=await Oe(r,e),g=await ke(r.navigation,e),v={...h.frontmatter,navigation:g.value,seo:p.seo,banner:m?.banner},y=Ne(r,o);return{value:{ast:ce(o),frontmatter:v,tagList:l,title:y,editPage:Ce(e.config,r,e.file.path),lastModified:e.file.lastModifiedAt},entityDeps:[...s,...ye(),...p.entityDeps,...m?.deps??[],...h.entityDeps,...g.entityDeps],assetUsages:[...c,...p.assetUsages,...m?.assetUsages??[],...h.assetUsages],problems:be(t,e.file.path,f,u,i),linkRefs:[...D(d,f),...g.linkRefs],targetInventories:[xe(o,{frontmatter:L(v,y)})]}},{usesProjectMarkdocSchema:!0,async markdown(e,t){let{tags:n}=await _(),{chunks:r,headings:i}=F(C(e.ast),{tags:n,locale:P(t),variables:{frontmatter:L(e.frontmatter,e.title),env:t.config.publicEnv??{}}});return[{chunks:r,headings:i,...e.title?{title:e.title}:{}}]},searchable(e,t){if(t.route===void 0||t.route.metadata.excludeFromSearch===!0)return{docs:[]};let n=t.route.slug,r=e.title??Q(t.route.originFilePath??n),{category:i,isInvalid:u}=l(t.route.metadata),{facets:d,invalidFields:f}=s(t.route.metadata,o(t.config)),p=he(e.frontmatter.keywords);return{docs:z(C(e.ast),r,{frontmatter:L(e.frontmatter,e.title)}).map((e,t)=>{let r={docKey:e.docKey,routeSlug:n,title:e.title,text:e.text,groupKey:i??`Documentation`,facets:d};e.anchor!==void 0&&(r.anchor=e.anchor),e.path!==void 0&&(r.path=e.path);let a=t===0?p:{excludes:p?.excludes};return(a?.includes||a?.excludes)&&(r.keywords=a),e.rbacTeams!==void 0&&(r.rbacScope=Object.fromEntries(e.rbacTeams.map(e=>[e,`read`]))),r}),problems:c([...f,...u?[a]:[]],t.route.originFilePath)}}}),q=t(G,async e=>{let{content:t,frontmatter:n}=Y(await e.io.readFile(e.file.absolutePath)),r=await j(t,e.file.path,J(e));return{value:{label:Z(n)??R(r.source)??Q(e.args.filePath)},entityDeps:r.entityDeps}});function J(e){return{config:e.config,contentDir:e.contentDir,entities:e.entities,file:e.file,io:e.io,logger:e.logger,markdown:e.markdown,plugin:e.plugin}}const ve=e({id:`internal.markdoc`,version:`3.44.0`,content:{filter:{match:e=>e.toLowerCase().endsWith(`.md`)&&!ne(e)},extractFile(e,t){if(B(e.path)||O(e.path,t.config))return{routes:[]};if(!S(t.config,`markdown`))return{routes:[],problems:[ae(`Markdown pages`)]};let{banner:n,...r}=e.manifest,i=Pe(e,t),a=V(r.slug),o=K.withArgs({filePath:e.path}),s=q.withArgs({filePath:e.path});return{routes:a.length>0?a.map(e=>({deps:{[f]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:e,slugHint:null,template:i})):[{deps:{[f]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:null,slugHint:se(e.path),template:i}],entities:[o]}}},loaders:[K,q],templates:{[U]:i(n(`./client/template.tsx`,import.meta.url))}});function Y(e){let t=e.match(k);if(!t)return{content:e,frontmatter:{}};let n=t[1]??``;try{let r=ge.load(n);return{content:e.slice(t[0].length),frontmatter:u(r)?r:{}}}catch(n){let r=n instanceof Error?n.message:String(n);return{content:e.slice(t[0].length),frontmatter:{},frontmatterError:r}}}function ye(){return(v()??[]).map(e=>({kind:`file`,path:e}))}function be(e,t,n,r,i){if(r.length===0&&i===void 0)return[];let a=me(e),o=r.map(e=>Se(e,a,n,t));if(i!==void 0){let e={start:{line:1},end:{line:n}};o.push({code:`markdown/frontmatter-parse`,message:i,location:{filePath:t,range:e,snippet:H(a,e)}})}return o}function xe(e,t){let{ids:n,exhaustive:r}=I(e,t);return{kind:`anchor`,exhaustive:r,targets:n}}function Se(e,t,n,r){let i=e.location?.range;if(!i)return e;let a=T(i,n);return{...e,location:{filePath:r,range:a,snippet:H(t,a)}}}function Ce(e,t,n){let r=u(t.markdown)?t.markdown:{},i={...e.markdown?.editPage,...u(r.editPage)?r.editPage:{}};if(i.hide!==!0&&typeof i.baseUrl==`string`&&i.baseUrl!==``)return{to:`${i.baseUrl.replace(/(?<!\/)\/+$/,``)}/${n}`}}async function we(e,t){if(!u(e)||typeof e.image!=`string`)return{seo:e,entityDeps:[],assetUsages:[]};let n=await t.markdown.resolveImageReference(e.image,t.file.path);return n.result.kind===`assetRef`?{seo:{...e,image:n.result.url},entityDeps:n.entityDeps,assetUsages:n.assetUsages}:{seo:e,entityDeps:n.entityDeps,assetUsages:[]}}function Te(e){let t=/* @__PURE__ */ new Map;if(!S(e,`customMarkdocTags`))for(let e of y())t.set(e,`Custom Markdoc tags are not in this project's plan, so \`${e}\` is ignored.`);if(!S(e,`codeWalkthrough`))for(let e of h)t.set(e,`\`${e}\` is not in this project's plan and is ignored.`);return t}function Ee(e,t,n){let r=[];if(n.size===0)return r;for(let i of w(e)){let e=i.type===`tag`&&i.tag!==void 0?n.get(i.tag):void 0;e!==void 0&&(r.push({code:`configuration/ignored`,message:e,location:{filePath:t,range:p(i)??{start:{line:1},end:{line:1}}}}),m(i,e))}return r}const De=[`image`,`links`];async function Oe(e,t){let n=t.config.markdown?.frontMatterKeysToResolve??De,r={...e},i=[],a=[];for(let o of n){let n=e[o];if(typeof n!=`string`)continue;let s=await t.markdown.resolveLocalReference(n,t.file.path);i.push(...s.entityDeps),a.push(...s.assetUsages),s.result.kind!==`passthrough`&&(r[o]=s.result.url)}return{frontmatter:r,entityDeps:i,assetUsages:a}}async function ke(e,t){let n=[],r=[];if(!u(e))return{value:e,entityDeps:n,linkRefs:r};let i={...e};for(let a of[`nextButton`,`previousButton`]){let o=e[a];if(!u(o)||typeof o.page!=`string`)continue;let{page:s,...c}=o,l=E(fe(s),t.file.path);l!==null&&r.push({kind:`link`,raw:s,...l});let d=await X(s,t);n.push(...d.entityDeps),i[a]={...c,label:typeof c.label==`string`?c.label:d.route&&await Ae(d.route,t),link:d.link}}return{value:i,entityDeps:n,linkRefs:r}}async function Ae(e,t){let n=await ue(t.entities,e);if(n!==void 0)return n;let r=t.routes.get(e.slug)?.metadata.seo;return u(r)&&typeof r.title==`string`&&r.title.trim()!==``?r.title:e.slug}async function X(e,t){let n=e.trim(),{path:r,suffix:i}=b(n);if(le(r)){let e=t.routes.bySlug(d(r));return{link:e&&`${e.slug}${i}`,route:e,entityDeps:[]}}let a=await t.markdown.resolveLocalReference(n,t.file.path);if(a.result.kind!==`pageUrl`)return{entityDeps:a.entityDeps};let o=a.result.url;return{link:o,route:t.routes.bySlug(b(o).path)??a.entityDeps.map(e=>e.kind===`file`?t.routes.byFilePath(e.path):void 0).reverse().find(e=>e!==void 0),entityDeps:a.entityDeps}}function je(e){let t=/* @__PURE__ */ new Map;for(let n of w(e)){if(n.type!==`tag`||n.tag===void 0||g[n.tag]?.attributes?.__idx===void 0)continue;let e=(t.get(n.tag)??0)+1;t.set(n.tag,e),n.attributes.__idx=e}}function Me(e,t,n){if(e.banner===void 0)return;let{value:r,problems:i}=ie(re,{banner:e.banner});for(let e of i)n?.warn(`${t}: ${e.message}`);return r.banner}function Ne(e,t){return Z(e)??de(t)??void 0}function Z(e){let t=u(e.seo)?e.seo.title:void 0;return typeof t==`string`&&t.trim()!==``?t:void 0}function Q(e){let t=(e.split(`/`).pop()??e).replace(/\.[^.]+$/,``);return t===``?e:t}function Pe(e,t){let n=e.manifest.template;if(typeof n==`string`&&n.trim()!==``)return $(n,e.path,t.logger);let r=oe(e.path,t.config.markdown?.template);return typeof r==`string`&&r.trim()!==``?$(r,`redocly.yaml`,t.logger):U}function $(e,t,n){if(!e.startsWith(`./`)&&!e.startsWith(`../`)&&!e.startsWith(`/`))return e;let r=x(e,t);return r===null?(n.warn(`Template reference "${e}" in ${t} escapes the content root; falling back to ${U}.`),U):`${pe}${r}`}export{W as MARKDOC_DOCUMENT_LOADER_ID,_e as MARKDOC_SEARCH_GROUP,G as MARKDOC_SIDEBAR_ITEM_LOADER_ID,U as MARKDOC_TEMPLATE_ID,ve as markdocContentPlugin};
1
+ import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{runtimeFile as n}from"../../utils/runtime-file.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import{runtimeTemplate as i}from"../../templates.js";import{SEARCH_GROUP_FACET_FIELD as a}from"../../../../shared/search/facets.js";import{configuredFacetFields as o,extractFacetsFromFrontmatter as s,invalidFacetValueProblems as c,searchCategoryOf as l}from"../../../search/facet-values.js";import{isObject as u}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as d}from"../../../../shared/utils/routes/normalize-route-slug.js";import{resolveContentPath as f}from"../../../../shared/utils/resolve-content-path.js";import{PAGE_BANNER_SCHEMA as p,sanitizeConfig as m}from"../../../config-schema.js";import{notInPlanProblem as h}from"../../../plan-gates.js";import{matchPathMap as g}from"../../utils/glob.js";import{filePathToRouteSlug as _}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{isPlanFeatureGranted as v}from"../../../../shared/plan-gates.js";import{splitUrlSuffix as y}from"../../../../shared/utils/routes/split-url-suffix.js";import{packMarkdocAst as ee,unpackMarkdocAst as b}from"../../../markdown/utils/packed-ast.js";import{isRouteSlugTarget as x}from"../../../../shared/utils/routes/is-route-slug-target.js";import{loadSidebarSubtreeLabel as S}from"../../utils/sidebar-label.js";import{markdocNodeRange as C}from"../../../markdown/utils/node-source-range.js";import{replaceWithMarkdocError as te}from"../../../markdown/tags/markdoc-error.js";import{getPartialTwins as ne}from"../../../markdown/tags/partial.js";import{CODE_WALKTHROUGH_TAG_NAMES as re,builtInMarkdocTags as ie}from"../../../markdown/constants/builtin-tags.js";import{walkMarkdocAst as w}from"../../../markdown/utils/walk-markdoc-ast.js";import{markdocFirstHeading as ae}from"../../../markdown/search/to-text.js";import{safeDecodeURI as oe}from"../../../../shared/utils/safe-decode-uri.js";import{shiftRange as se}from"../../../../shared/utils/shift-range.js";import{classifyLinkTarget as ce}from"../../../link-checker/classify.js";import{onDiskLinkRefs as le}from"../../../link-checker/node-ref.js";import{isPartialPath as ue}from"../../../markdown/utils/partials.js";import{FRONTMATTER_BLOCK_RE as de,computeFrontmatterLineOffset as fe}from"../../../markdown/utils/frontmatter-offset.js";import{inlineRawPartials as T}from"../../../markdown/resolve/raw-partials.js";import{resolveMarkdownAst as E}from"../../../markdown/resolve/ast.js";import{resolveBannerForAppData as D}from"../app-data/banner.js";import{MARKDOC_DOCUMENT_LOADER_KEY as O}from"../../../../shared/constants/route-deps.js";import{isMarkdocValidationEnabled as k,resolveMarkdocTagSet as A,resolveMarkdownPageValidationSet as j,userMarkdocSchemaFiles as M,userMarkdocTagNames as N}from"../../../markdown/constants/tag-sets.js";import{pageLocale as P}from"../../utils/page-locale.js";import{markdocAstToMarkdownDoc as F}from"../../../markdown/search/to-markdown.js";import{collectAnchors as I}from"../../../markdown/utils/collect-anchors.js";import{frontmatterVariable as L}from"../../../markdown/utils/frontmatter-variable.js";import{markdownFirstHeading as R}from"../../../markdown/utils/first-heading.js";import{markdocAstToSearchSections as z}from"../../../markdown/search/to-sections.js";import{isInternalPagePath as B}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as V}from"../../utils/explicit-slugs.js";import{isSkillContentPath as pe}from"../../utils/skill-paths.js";import{SOURCE_TEMPLATE_PREFIX as me}from"../../../../shared/constants/template-ids.js";import{captureSnippet as H,splitSourceLines as he}from"../../../../shared/utils/capture-snippet.js";import{curationKeywordsOf as ge}from"../../../search/keywords.js";import _e from"js-yaml";const U=`markdoc-page`,W=r(`internal.markdoc`,`document`),G=r(`internal.markdoc`,`sidebar-item`),ve=`Documentation`,K=t(W,async e=>{let t=await e.io.readFile(e.file.absolutePath),{content:n,frontmatter:r,frontmatterError:i}=Y(t),a=J(e),{ast:o,entityDeps:s,assetUsages:c,tagList:l,problems:u,linkRefs:d}=await E(n,e.file.path,{resolverContext:a,tags:(await A()).tags,variables:{get env(){return e.config.publicEnv??{}}},transform:t=>De(t,e.file.path,Ee(e.config)),validation:k()?await j():void 0}),f=fe(t);Me(o);let p=await Te(r.seo,e),m=v(e.config,`banner`)?await D(Ne(r,e.file.path,e.logger),a):void 0,h=await ke(r,e),g=await Ae(r.navigation,e),_={...h.frontmatter,navigation:g.value,seo:p.seo,banner:m?.banner},y=Pe(r,o);return{value:{ast:ee(o),frontmatter:_,tagList:l,title:y,editPage:we(e.config,r,e.file.path),lastModified:e.file.lastModifiedAt},entityDeps:[...s,...be(),...p.entityDeps,...m?.deps??[],...h.entityDeps,...g.entityDeps],assetUsages:[...c,...p.assetUsages,...m?.assetUsages??[],...h.assetUsages],problems:xe(t,e.file.path,f,u,i),linkRefs:[...le(d,f),...g.linkRefs],targetInventories:[Se(o,{frontmatter:L(_,y)})]}},{usesProjectMarkdocSchema:!0,async markdown(e,t){let{tags:n}=await A(),{chunks:r,headings:i}=F(b(e.ast),{tags:n,locale:P(t),variables:{frontmatter:L(e.frontmatter,e.title),env:t.config.publicEnv??{}}});return[{chunks:r,headings:i,...e.title?{title:e.title}:{}}]},searchable(e,t){if(t.route===void 0||t.route.metadata.excludeFromSearch===!0)return{docs:[]};let n=t.route.slug,r=e.title??Q(t.route.originFilePath??n),{category:i,isInvalid:u}=l(t.route.metadata),{facets:d,invalidFields:f}=s(t.route.metadata,o(t.config)),p=ge(e.frontmatter.keywords);return{docs:z(b(e.ast),r,{frontmatter:L(e.frontmatter,e.title)}).map((e,t)=>{let r={docKey:e.docKey,routeSlug:n,title:e.title,text:e.text,groupKey:i??`Documentation`,facets:d};e.anchor!==void 0&&(r.anchor=e.anchor),e.path!==void 0&&(r.path=e.path);let a=t===0?p:{excludes:p?.excludes};return(a?.includes||a?.excludes)&&(r.keywords=a),e.rbacTeams!==void 0&&(r.rbacScope=Object.fromEntries(e.rbacTeams.map(e=>[e,`read`]))),r}),problems:c([...f,...u?[a]:[]],t.route.originFilePath)}}}),q=t(G,async e=>{let{content:t,frontmatter:n}=Y(await e.io.readFile(e.file.absolutePath)),r=await T(t,e.file.path,J(e));return{value:{label:Z(n)??R(r.source)??Q(e.args.filePath)},entityDeps:r.entityDeps}});function J(e){return{config:e.config,contentDir:e.contentDir,entities:e.entities,file:e.file,io:e.io,logger:e.logger,markdown:e.markdown,plugin:e.plugin}}const ye=e({id:`internal.markdoc`,version:`3.45.0`,content:{filter:{match:e=>e.toLowerCase().endsWith(`.md`)&&!pe(e)},extractFile(e,t){if(B(e.path)||ue(e.path,t.config))return{routes:[]};if(!v(t.config,`markdown`))return{routes:[],problems:[h(`Markdown pages`)]};let{banner:n,...r}=e.manifest,i=Fe(e,t),a=V(r.slug),o=K.withArgs({filePath:e.path}),s=q.withArgs({filePath:e.path});return{routes:a.length>0?a.map(e=>({deps:{[O]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:e,slugHint:null,template:i})):[{deps:{[O]:o},metadata:r,routeId:`page`,sidebarSubtree:s,slug:null,slugHint:_(e.path),template:i}],entities:[o]}}},loaders:[K,q],templates:{[U]:i(n(`./client/template.tsx`,import.meta.url))}});function Y(e){let t=e.match(de);if(!t)return{content:e,frontmatter:{}};let n=t[1]??``;try{let r=_e.load(n);return{content:e.slice(t[0].length),frontmatter:u(r)?r:{}}}catch(n){let r=n instanceof Error?n.message:String(n);return{content:e.slice(t[0].length),frontmatter:{},frontmatterError:r}}}function be(){return(M()??[]).map(e=>({kind:`file`,path:e}))}function xe(e,t,n,r,i){if(r.length===0&&i===void 0)return[];let a=he(e),o=r.map(e=>Ce(e,a,n,t));if(i!==void 0){let e={start:{line:1},end:{line:n}};o.push({code:`markdown/frontmatter-parse`,message:i,location:{filePath:t,range:e,snippet:H(a,e)}})}return o}function Se(e,t){let{ids:n,exhaustive:r}=I(e,t);return{kind:`anchor`,exhaustive:r,targets:n}}function Ce(e,t,n,r){let i=e.location?.range;if(!i)return e;let a=se(i,n);return{...e,location:{filePath:r,range:a,snippet:H(t,a)}}}function we(e,t,n){let r=u(t.markdown)?t.markdown:{},i={...e.markdown?.editPage,...u(r.editPage)?r.editPage:{}};if(i.hide!==!0&&typeof i.baseUrl==`string`&&i.baseUrl!==``)return{to:`${i.baseUrl.replace(/(?<!\/)\/+$/,``)}/${n}`}}async function Te(e,t){if(!u(e)||typeof e.image!=`string`)return{seo:e,entityDeps:[],assetUsages:[]};let n=await t.markdown.resolveImageReference(e.image,t.file.path);return n.result.kind===`assetRef`?{seo:{...e,image:n.result.url},entityDeps:n.entityDeps,assetUsages:n.assetUsages}:{seo:e,entityDeps:n.entityDeps,assetUsages:[]}}function Ee(e){let t=/* @__PURE__ */ new Map;if(!v(e,`customMarkdocTags`))for(let e of N())t.set(e,`Custom Markdoc tags are not in this project's plan, so \`${e}\` is ignored.`);if(!v(e,`codeWalkthrough`))for(let e of re)t.set(e,`\`${e}\` is not in this project's plan and is ignored.`);return t}function De(e,t,n){let r=[];if(n.size===0)return r;for(let i of w(e,{getExtraNodes:ne})){let e=i.type===`tag`&&i.tag!==void 0?n.get(i.tag):void 0;e!==void 0&&(r.push({code:`configuration/ignored`,message:e,location:{filePath:t,range:C(i)??{start:{line:1},end:{line:1}}}}),te(i,e))}return r}const Oe=[`image`,`links`];async function ke(e,t){let n=t.config.markdown?.frontMatterKeysToResolve??Oe,r={...e},i=[],a=[];for(let o of n){let n=e[o];if(typeof n!=`string`)continue;let s=await t.markdown.resolveLocalReference(n,t.file.path);i.push(...s.entityDeps),a.push(...s.assetUsages),s.result.kind!==`passthrough`&&(r[o]=s.result.url)}return{frontmatter:r,entityDeps:i,assetUsages:a}}async function Ae(e,t){let n=[],r=[];if(!u(e))return{value:e,entityDeps:n,linkRefs:r};let i={...e};for(let a of[`nextButton`,`previousButton`]){let o=e[a];if(!u(o)||typeof o.page!=`string`)continue;let{page:s,...c}=o,l=ce(oe(s),t.file.path);l!==null&&r.push({kind:`link`,raw:s,...l});let d=await je(s,t);n.push(...d.entityDeps),i[a]={...c,label:typeof c.label==`string`?c.label:d.route&&await X(d.route,t),link:d.link}}return{value:i,entityDeps:n,linkRefs:r}}async function X(e,t){let n=await S(t.entities,e);if(n!==void 0)return n;let r=t.routes.get(e.slug)?.metadata.seo;return u(r)&&typeof r.title==`string`&&r.title.trim()!==``?r.title:e.slug}async function je(e,t){let n=e.trim(),{path:r,suffix:i}=y(n);if(x(r)){let e=t.routes.bySlug(d(r));return{link:e&&`${e.slug}${i}`,route:e,entityDeps:[]}}let a=await t.markdown.resolveLocalReference(n,t.file.path);if(a.result.kind!==`pageUrl`)return{entityDeps:a.entityDeps};let o=a.result.url;return{link:o,route:t.routes.bySlug(y(o).path)??a.entityDeps.map(e=>e.kind===`file`?t.routes.byFilePath(e.path):void 0).reverse().find(e=>e!==void 0),entityDeps:a.entityDeps}}function Me(e){let t=/* @__PURE__ */ new Map;for(let n of w(e)){if(n.type!==`tag`||n.tag===void 0||ie[n.tag]?.attributes?.__idx===void 0)continue;let e=(t.get(n.tag)??0)+1;t.set(n.tag,e),n.attributes.__idx=e}}function Ne(e,t,n){if(e.banner===void 0)return;let{value:r,problems:i}=m(p,{banner:e.banner});for(let e of i)n?.warn(`${t}: ${e.message}`);return r.banner}function Pe(e,t){return Z(e)??ae(t)??void 0}function Z(e){let t=u(e.seo)?e.seo.title:void 0;return typeof t==`string`&&t.trim()!==``?t:void 0}function Q(e){let t=(e.split(`/`).pop()??e).replace(/\.[^.]+$/,``);return t===``?e:t}function Fe(e,t){let n=e.manifest.template;if(typeof n==`string`&&n.trim()!==``)return $(n,e.path,t.logger);let r=g(e.path,t.config.markdown?.template);return typeof r==`string`&&r.trim()!==``?$(r,`redocly.yaml`,t.logger):U}function $(e,t,n){if(!e.startsWith(`./`)&&!e.startsWith(`../`)&&!e.startsWith(`/`))return e;let r=f(e,t);return r===null?(n.warn(`Template reference "${e}" in ${t} escapes the content root; falling back to ${U}.`),U):`${me}${r}`}export{W as MARKDOC_DOCUMENT_LOADER_ID,ve as MARKDOC_SEARCH_GROUP,G as MARKDOC_SIDEBAR_ITEM_LOADER_ID,U as MARKDOC_TEMPLATE_ID,ye as markdocContentPlugin};
@@ -10,6 +10,12 @@ export declare const MCP_REGISTER_ROUTE = "/_mcp/register";
10
10
  export declare const MCP_AUTHORIZE_ROUTE = "/_mcp/oauth2/auth";
11
11
  export declare const MCP_TOKEN_ROUTE = "/_mcp/oauth2/token-portal";
12
12
  export declare const MCP_CALLBACK_ROUTE = "/_mcp/oauth/callback";
13
+ export declare const EXECUTE_TOOL_NAME = "execute";
14
+ export declare const DISCOVER_TOOL_NAME = "discover";
15
+ export declare const CREATE_ANONYMOUS_SESSION_TOOL_NAME = "createAnonymousSession";
16
+ export declare const MANAGE_API_CREDENTIALS_TOOL_NAME = "manageApiCredentials";
17
+ export declare const REMOVE_API_CREDENTIALS_TOOL_NAME = "removeApiCredentials";
18
+ export declare const SUBMIT_FEEDBACK_TOOL_NAME = "submit-feedback";
13
19
  export declare const MCP_CREDENTIALS_ROUTE = "/mcp/credentials";
14
20
  export declare const DEFAULT_MCP_SERVER_NAME = "Docs MCP server";
15
21
  export declare const PLACEHOLDER_MCP_SERVER_NAMES: readonly string[];
@@ -1 +1 @@
1
- const e=`/mcp`,t=`/mcp-public`,n=`mcp-setup`,r=`/.well-known/mcp/server-card.json`,i=`/.well-known/agent-card.json`,a=`/a2a`,o=`/.well-known/oauth-protected-resource${e}`,s=`/.well-known/oauth-authorization-server`,c=`/_mcp/register`,l=`/_mcp/oauth2/auth`,u=`/_mcp/oauth2/token-portal`,d=`/_mcp/oauth/callback`,f=`/mcp/credentials`,p=`Docs MCP server`,m=[p,`MCP server`],h=`X-Redocly-AI-Metadata`,g=`mcp-tools`;export{a as A2A_ROUTE,i as AGENT_CARD_ROUTE,h as AI_METADATA_HEADER,p as DEFAULT_MCP_SERVER_NAME,s as MCP_AUTHORIZATION_SERVER_ROUTE,l as MCP_AUTHORIZE_ROUTE,d as MCP_CALLBACK_ROUTE,f as MCP_CREDENTIALS_ROUTE,o as MCP_PROTECTED_RESOURCE_ROUTE,c as MCP_REGISTER_ROUTE,e as MCP_ROUTE,r as MCP_SERVER_CARD_ROUTE,n as MCP_SETUP_TEMPLATE_ID,u as MCP_TOKEN_ROUTE,g as MCP_TOOLS_ENTITY_TYPE,m as PLACEHOLDER_MCP_SERVER_NAMES,t as PUBLIC_MCP_ROUTE};
1
+ const e=`/mcp`,t=`/mcp-public`,n=`mcp-setup`,r=`/.well-known/mcp/server-card.json`,i=`/.well-known/agent-card.json`,a=`/a2a`,o=`/.well-known/oauth-protected-resource${e}`,s=`/.well-known/oauth-authorization-server`,c=`/_mcp/register`,l=`/_mcp/oauth2/auth`,u=`/_mcp/oauth2/token-portal`,d=`/_mcp/oauth/callback`,f=`execute`,p=`discover`,m=`createAnonymousSession`,h=`manageApiCredentials`,g=`removeApiCredentials`,_=`submit-feedback`,v=`/mcp/credentials`,y=`Docs MCP server`,b=[y,`MCP server`],x=`X-Redocly-AI-Metadata`,S=`mcp-tools`;export{a as A2A_ROUTE,i as AGENT_CARD_ROUTE,x as AI_METADATA_HEADER,m as CREATE_ANONYMOUS_SESSION_TOOL_NAME,y as DEFAULT_MCP_SERVER_NAME,p as DISCOVER_TOOL_NAME,f as EXECUTE_TOOL_NAME,h as MANAGE_API_CREDENTIALS_TOOL_NAME,s as MCP_AUTHORIZATION_SERVER_ROUTE,l as MCP_AUTHORIZE_ROUTE,d as MCP_CALLBACK_ROUTE,v as MCP_CREDENTIALS_ROUTE,o as MCP_PROTECTED_RESOURCE_ROUTE,c as MCP_REGISTER_ROUTE,e as MCP_ROUTE,r as MCP_SERVER_CARD_ROUTE,n as MCP_SETUP_TEMPLATE_ID,u as MCP_TOKEN_ROUTE,S as MCP_TOOLS_ENTITY_TYPE,b as PLACEHOLDER_MCP_SERVER_NAMES,t as PUBLIC_MCP_ROUTE,g as REMOVE_API_CREDENTIALS_TOOL_NAME,_ as SUBMIT_FEEDBACK_TOOL_NAME};
@@ -1 +1 @@
1
- import{createInlineEntity as e}from"../../../loaders/define.js";import{notInPlanProblem as t}from"../../../plan-gates.js";import{MCP_TOOL_NAME_PATTERN as n}from"../../registry.js";import{isPlanFeatureGranted as r}from"../../../../shared/plan-gates.js";import{MCP_TOOLS_ENTITY_TYPE as i}from"./constants.js";import{isMcpHidden as a}from"./server/config-gate.js";import{buildMcpSetupPageRoutes as o}from"./setup-page.js";import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as s,DISCOVER_TOOL_NAME as c,EXECUTE_TOOL_NAME as l,MANAGE_API_CREDENTIALS_TOOL_NAME as u,REMOVE_API_CREDENTIALS_TOOL_NAME as d,SUBMIT_FEEDBACK_TOOL_NAME as f}from"@redocly/mcp";const p=`@mcp`,m=`mcp/invalid-tool`,h=/\.(ts|js)$/u,g=/\.d\.ts$/u,_=/* @__PURE__ */ new Set([`search`,`list-apis`,`get-endpoints`,`get-endpoint-info`,`get-security-schemes`,`get-full-api-description`,`list-graphql-apis`,`get-graphql-type-list`,`get-graphql-type`,`get-graphql-schema`,`list-pages`,`get-page`,`grep-pages`,`whoami`,f,l,c,`describe-tools`,s,u,d]);function v(e){return`mcp-tool-file:${e}`}function y(e){if(g.test(e)||!h.test(e))return!1;let t=e.split(`/`),n=t.indexOf(p);return n!==-1&&n<t.length-1}function b(e,t,r){if(!n.test(e))return`Invalid MCP tool file "${t}": the tool name "${e}" is derived from the file name and may only contain letters, numbers, hyphens, and underscores (max 64 characters). Rename the file.`;if(r!==void 0)return`Duplicate MCP tool name "${e}": defined by both "${r}" and "${t}". Tool names are file names, so each file name must be unique across @mcp folders.`;if(_.has(e))return`Invalid MCP tool file "${t}": the tool name "${e}" is already used by a built-in MCP tool. Rename the file.`}function x(n){let o=[],s=[];if(a(n.config))return{entities:o,problems:s};if(!r(n.config,`customMcpTools`)){for(let{path:e}of n.files)s.push({...t(`Custom MCP tools`),location:{filePath:e}});return{entities:o,problems:s}}let c=/* @__PURE__ */ new Map;for(let{path:t}of n.files){let n=t.slice(t.lastIndexOf(`/`)+1).replace(h,``),r=b(n,t,c.get(n));if(r!==void 0){s.push({code:m,message:r,location:{filePath:t}});continue}c.set(n,t);let a={name:n,sourcePath:t};o.push(e(a,{stableKey:v(t),type:i,metadata:a}))}return{entities:o,problems:s}}const S={filter:{match:y},extractAll(e){return{routes:o(e.config),entities:[]}}};export{p as MCP_DIR_SEGMENT,m as MCP_TOOL_PROBLEM_CODE,_ as RESERVED_MCP_TOOL_NAMES,y as isMcpToolFile,S as mcpContent,v as mcpToolFileEntityKey,x as scanMcpToolFiles};
1
+ import{createInlineEntity as e}from"../../../loaders/define.js";import{notInPlanProblem as t}from"../../../plan-gates.js";import{MCP_TOOL_NAME_PATTERN as n}from"../../registry.js";import{isPlanFeatureGranted as r}from"../../../../shared/plan-gates.js";import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as i,DISCOVER_TOOL_NAME as a,EXECUTE_TOOL_NAME as o,MANAGE_API_CREDENTIALS_TOOL_NAME as s,MCP_TOOLS_ENTITY_TYPE as c,REMOVE_API_CREDENTIALS_TOOL_NAME as l,SUBMIT_FEEDBACK_TOOL_NAME as u}from"./constants.js";import{isMcpHidden as d}from"./server/config-gate.js";import{buildMcpSetupPageRoutes as f}from"./setup-page.js";const p=`@mcp`,m=`mcp/invalid-tool`,h=/\.(ts|js)$/u,g=/\.d\.ts$/u,_=/* @__PURE__ */ new Set([`search`,`list-apis`,`get-endpoints`,`get-endpoint-info`,`get-security-schemes`,`get-full-api-description`,`list-graphql-apis`,`get-graphql-type-list`,`get-graphql-type`,`get-graphql-schema`,`list-pages`,`get-page`,`grep-pages`,`whoami`,u,o,a,`describe-tools`,i,s,l]);function v(e){return`mcp-tool-file:${e}`}function y(e){if(g.test(e)||!h.test(e))return!1;let t=e.split(`/`),n=t.indexOf(p);return n!==-1&&n<t.length-1}function b(e,t,r){if(!n.test(e))return`Invalid MCP tool file "${t}": the tool name "${e}" is derived from the file name and may only contain letters, numbers, hyphens, and underscores (max 64 characters). Rename the file.`;if(r!==void 0)return`Duplicate MCP tool name "${e}": defined by both "${r}" and "${t}". Tool names are file names, so each file name must be unique across @mcp folders.`;if(_.has(e))return`Invalid MCP tool file "${t}": the tool name "${e}" is already used by a built-in MCP tool. Rename the file.`}function x(n){let i=[],a=[];if(d(n.config))return{entities:i,problems:a};if(!r(n.config,`customMcpTools`)){for(let{path:e}of n.files)a.push({...t(`Custom MCP tools`),location:{filePath:e}});return{entities:i,problems:a}}let o=/* @__PURE__ */ new Map;for(let{path:t}of n.files){let n=t.slice(t.lastIndexOf(`/`)+1).replace(h,``),r=b(n,t,o.get(n));if(r!==void 0){a.push({code:m,message:r,location:{filePath:t}});continue}o.set(n,t);let s={name:n,sourcePath:t};i.push(e(s,{stableKey:v(t),type:c,metadata:s}))}return{entities:i,problems:a}}const S={filter:{match:y},extractAll(e){return{routes:f(e.config),entities:[]}}};export{p as MCP_DIR_SEGMENT,m as MCP_TOOL_PROBLEM_CODE,_ as RESERVED_MCP_TOOL_NAMES,y as isMcpToolFile,S as mcpContent,v as mcpToolFileEntityKey,x as scanMcpToolFiles};
@@ -1 +1 @@
1
- import{compareStrings as e}from"../../../../shared/utils/compare-strings.js";import{delocalizeRouteSlug as t,l10nDirOf as n}from"../../../../shared/utils/l10n.js";import{toPublicVersionedSlug as r}from"../../../../shared/constants/versions.js";import{compileContentGlob as i}from"../../utils/glob.js";import{MCP_IGNORED_ROUTES_ENTITY_KEY as a}from"../../../../shared/constants/mcp.js";const o=/* @__PURE__ */ new Set;function s(e,r){let i=n(r);return(i===void 0?e:t(e,i)??e).replace(/^\/+/,``)}function c(t,n,r,a){if(n.length===0)return[];let o=i(n),c=/* @__PURE__ */ new Set,u=new Set(t.map(e=>e.slug)),d=e=>{let t=l(e,r),n=t!==void 0&&!u.has(t);for(let r of n?[e.slug,t]:[e.slug])if(c.add(r),e.locale===``&&a!==void 0)for(let e of a.locales)c.add(a.toL10nSlug(r,e))};for(let e of t){let t=s(e.slug,e.originFilePath??``);(e.originFilePath!==null&&o(e.originFilePath)||o(t))&&d(e)}return[...c].sort(e)}function l(e,t){if(e.versionGroup&&e.version&&t.get(e.versionGroup)?.defaultVersion===e.version)return r(e.slug,e.versionGroup,e.version,!0)}async function u(e){if(!await e.get(`mcp:ignored-routes`))return o;let t=await e.load(a);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):o}export{a as MCP_IGNORED_ROUTES_ENTITY_KEY,s as canonicalSlugPath,c as collectIgnoredRouteSlugs,u as readIgnoredRouteSlugs};
1
+ import{compareStrings as e}from"../../../../shared/utils/compare-strings.js";import{delocalizeRouteSlug as t,l10nDirOf as n}from"../../../../shared/utils/l10n.js";import{compileContentGlob as r}from"../../utils/glob.js";import{toPublicVersionedSlug as i}from"../../../../shared/constants/versions.js";import{MCP_IGNORED_ROUTES_ENTITY_KEY as a}from"../../../../shared/constants/mcp.js";const o=/* @__PURE__ */ new Set;function s(e,r){let i=n(r);return(i===void 0?e:t(e,i)??e).replace(/^\/+/,``)}function c(t,n,i,a){if(n.length===0)return[];let o=r(n),c=/* @__PURE__ */ new Set,u=new Set(t.map(e=>e.slug)),d=e=>{let t=l(e,i),n=t!==void 0&&!u.has(t);for(let r of n?[e.slug,t]:[e.slug])if(c.add(r),e.locale===``&&a!==void 0)for(let e of a.locales)c.add(a.toL10nSlug(r,e))};for(let e of t){let t=s(e.slug,e.originFilePath??``);(e.originFilePath!==null&&o(e.originFilePath)||o(t))&&d(e)}return[...c].sort(e)}function l(e,t){if(e.versionGroup&&e.version&&t.get(e.versionGroup)?.defaultVersion===e.version)return i(e.slug,e.versionGroup,e.version,!0)}async function u(e){if(!await e.get(`mcp:ignored-routes`))return o;let t=await e.load(a);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):o}export{a as MCP_IGNORED_ROUTES_ENTITY_KEY,s as canonicalSlugPath,c as collectIgnoredRouteSlugs,u as readIgnoredRouteSlugs};
@@ -1 +1 @@
1
- import{isObject as e}from"../../../../../shared/utils/is-object.js";import{thrownErrorClass as t}from"./tool-errors.js";import{maskCodeCredentials as n}from"./code-credentials.js";import{redactSecretsFromString as r}from"./gateway/fetch/redact.js";import{redactSecretShapes as i}from"./secret-patterns.js";import{createHash as a}from"node:crypto";import{EXECUTE_TOOL_NAME as o}from"@redocly/mcp";function s(e){return{client:e.client,clientVersion:e.clientVersion,requestId:e.requestId,messageId:e.messageId,callerSubject:e.callerSubject,clientIp:e.request.ip??void 0}}const c=`[mcp-audit]`,l=4096;function u(e){return a(`sha256`).update(e,`utf8`).digest(`hex`)}function d(e){if(e.length<=4096)return e;let t=e.slice(0,l),n=t.search(/\s\S*$/),r=n>0?t.slice(0,n):t;return`${r}…[truncated: kept ${r.length} of ${e.length} chars]`}function f(e,t=[]){return i(r(d(e),t))}const p=/(?<=^|[\s('"])(?:file:\/\/\/?|\/)(?:[^\s()/:'"]+\/)+/gm;function m(e){return f(e.replace(p,``))}function h(e){return{sha256:u(e),bytes:Buffer.byteLength(e,`utf8`)}}function g(e){return Object.keys(e??{}).map(e=>e.toLowerCase()).sort().join(`,`)}const _=/* @__PURE__ */ new Set([`access_token`,`api-key`,`api_key`,`apikey`,`assertion`,`auth`,`client_secret`,`code`,`code_verifier`,`id_token`,`id_token_hint`,`key`,`password`,`refresh_token`,`samlresponse`,`secret`,`session`,`sig`,`signature`,`token`,`x-amz-credential`,`x-amz-security-token`,`x-amz-signature`]);function v(e,t=[],n=[]){let r;try{r=new URL(e)}catch{return f(e,t)}let i=new Set(n.map(e=>e.toLowerCase()));for(let e of[...r.searchParams.keys()]){let t=e.toLowerCase();(_.has(t)||i.has(t))&&r.searchParams.set(e,`redacted`)}return r.username=``,r.password=``,f(r.href,t)}function y(e,t,n){let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0&&e!==``));try{e?.info(`${c} ${t}`,r)}catch{}}const b=/(169\.254\.169\.254|metadata\.google\.internal|\.consul\b|\.internal\b|localhost|127\.0\.0\.1|\b10\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|\b192\.168\.\d{1,3}\.\d{1,3}\b|\b172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}\b)/i,x=/(process\s*(?:\.\s*env\b|\[)|globalThis|require\s*\(|__proto__)/;function S(e){let t=[];return x.test(e)&&t.push(`env_probe`),b.test(e)&&t.push(`internal_target`),{sha256:u(e),length:e.length,flags:t.sort().join(`,`)}}function C(e){try{return JSON.stringify(e)??String(e)}catch{return`«[unserializable]»`}}function w(e,{tool:t,mode:n,args:r,result:i,errorClass:a,client:s,clientVersion:c,requestId:l,messageId:d,callerSubject:p,clientIp:m}){if(t===o)return;let g=C(r),_=i===void 0?void 0:h(i),v=r?.sessionHandle,b=typeof v==`string`&&v!==``?v:void 0,x=p??b;y(e,`Record MCP tool call`,{tool:t,mode:n,server_type:`docs`,error_class:a,client:s,client_version:c,request_id:l,message_id:d,subject_sha256:x?u(x):void 0,client_ip:m,args_sha256:u(g),args:f(g,b?[b]:[]),result_sha256:_?.sha256,result_bytes:_?.bytes})}async function T(e,n,r,i){let a={tool:n,mode:e.mcpMode,args:r,...s(e)},o=Date.now(),c;try{c=await i()}catch(r){throw w(e.logger,{...a,errorClass:t(r)}),e.telemetry?.toolThrew(n,Date.now()-o,r),await e.telemetry?.flush(),r}let l=D(c)&&c.isError===!0;return w(e.logger,{...a,result:A(c),errorClass:l?`tool_error`:void 0}),e.telemetry?.toolReturned(n,Date.now()-o,c),await e.telemetry?.flush(),c}const E=/* @__PURE__ */ new Set([`text`,`image`,`audio`,`resource`,`resource_link`]);function D(t){return e(t)&&Array.isArray(t.content)&&t.content.every(t=>e(t)&&E.has(t.type))}function O(t){return e(t)&&t.resultType===`input_required`}function k(e,t=``){return e.content.map(e=>e.type===`text`?e.text:``).join(t)}function A(e){if(typeof e==`string`)return e;if(D(e))return k(e);if(O(e))return``;try{return JSON.stringify(e)??``}catch{return``}}function j(e,{audit:t,code:r,description:i,sessionHandle:a,toolNames:o,fetchBudget:s,fetchCapable:c,requestId:l,messageId:d,callerSubject:p,clientIp:m}){let h=p??a;y(e,`Record code execution input`,{code_sha256:t.sha256,code_length:t.length,request_id:l,message_id:d,flags:t.flags,subject_sha256:h?u(h):void 0,client_ip:m,description:f(i),tools:[...o].sort().join(`,`),fetch_capable:c,fetch_budget:s,code:f(n(r))})}function M(e,{rawUrl:t,method:n,host:r,outcome:i,durationMs:a,injectedSecretValues:o,credentialQueryParams:s,path:c,api:l,status:d,injectedScheme:p,requestHeaders:m,requestBody:_,responseHeaders:b,responseBody:x,caller:S={}}){let{requestId:C,callerSubject:w,clientIp:T}=S,E=x===void 0?void 0:h(x);y(e,`Record gateway fetch`,{url_sha256:u(t),host:r,method:n,path:c,api:l,outcome:i,status:d,injected_scheme:p,duration_ms:a,request_id:C,subject_sha256:w?u(w):void 0,client_ip:T,url:v(t,o,s),request_header_names:g(m),request_body:_===void 0?void 0:f(_,o),response_header_names:g(b),response_sha256:E?.sha256,response_bytes:E?.bytes})}export{l as AUDIT_FIELD_MAX_CHARS,c as AUDIT_LOG_PREFIX,S as auditCode,g as auditHeaderNames,f as auditInput,u as auditSha256,m as auditStack,T as auditToolCall,v as auditUrl,s as callAttribution,D as isCallToolResult,y as logAuditRecord,j as logCodeExecutionAudit,M as logGatewayFetchAudit,w as logMcpToolCallAudit,A as toolOutputText,k as toolResultText,d as truncateAuditField};
1
+ import{isObject as e}from"../../../../../shared/utils/is-object.js";import"../constants.js";import{thrownErrorClass as t}from"./tool-errors.js";import{maskCodeCredentials as n}from"./code-credentials.js";import{redactSecretsFromString as r}from"./gateway/fetch/redact.js";import{redactSecretShapes as i}from"./secret-patterns.js";import{createHash as a}from"node:crypto";function o(e){return{client:e.client,clientVersion:e.clientVersion,requestId:e.requestId,messageId:e.messageId,callerSubject:e.callerSubject,clientIp:e.request.ip??void 0}}const s=`[mcp-audit]`,c=4096;function l(e){return a(`sha256`).update(e,`utf8`).digest(`hex`)}function u(e){if(e.length<=4096)return e;let t=e.slice(0,c),n=t.search(/\s\S*$/),r=n>0?t.slice(0,n):t;return`${r}…[truncated: kept ${r.length} of ${e.length} chars]`}function d(e,t=[]){return i(r(u(e),t))}const f=/(?<=^|[\s('"])(?:file:\/\/\/?|\/)(?:[^\s()/:'"]+\/)+/gm;function p(e){return d(e.replace(f,``))}function m(e){return{sha256:l(e),bytes:Buffer.byteLength(e,`utf8`)}}function h(e){return Object.keys(e??{}).map(e=>e.toLowerCase()).sort().join(`,`)}const g=/* @__PURE__ */ new Set([`access_token`,`api-key`,`api_key`,`apikey`,`assertion`,`auth`,`client_secret`,`code`,`code_verifier`,`id_token`,`id_token_hint`,`key`,`password`,`refresh_token`,`samlresponse`,`secret`,`session`,`sig`,`signature`,`token`,`x-amz-credential`,`x-amz-security-token`,`x-amz-signature`]);function _(e,t=[],n=[]){let r;try{r=new URL(e)}catch{return d(e,t)}let i=new Set(n.map(e=>e.toLowerCase()));for(let e of[...r.searchParams.keys()]){let t=e.toLowerCase();(g.has(t)||i.has(t))&&r.searchParams.set(e,`redacted`)}return r.username=``,r.password=``,d(r.href,t)}function v(e,t,n){let r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!==void 0&&e!==``));try{e?.info(`${s} ${t}`,r)}catch{}}const y=/(169\.254\.169\.254|metadata\.google\.internal|\.consul\b|\.internal\b|localhost|127\.0\.0\.1|\b10\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|\b192\.168\.\d{1,3}\.\d{1,3}\b|\b172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}\b)/i,b=/(process\s*(?:\.\s*env\b|\[)|globalThis|require\s*\(|__proto__)/;function x(e){let t=[];return b.test(e)&&t.push(`env_probe`),y.test(e)&&t.push(`internal_target`),{sha256:l(e),length:e.length,flags:t.sort().join(`,`)}}function S(e){try{return JSON.stringify(e)??String(e)}catch{return`«[unserializable]»`}}function C(e,{tool:t,mode:n,args:r,result:i,errorClass:a,client:o,clientVersion:s,requestId:c,messageId:u,callerSubject:f,clientIp:p}){if(t===`execute`)return;let h=S(r),g=i===void 0?void 0:m(i),_=r?.sessionHandle,y=typeof _==`string`&&_!==``?_:void 0,b=f??y;v(e,`Record MCP tool call`,{tool:t,mode:n,server_type:`docs`,error_class:a,client:o,client_version:s,request_id:c,message_id:u,subject_sha256:b?l(b):void 0,client_ip:p,args_sha256:l(h),args:d(h,y?[y]:[]),result_sha256:g?.sha256,result_bytes:g?.bytes})}async function w(e,n,r,i){let a={tool:n,mode:e.mcpMode,args:r,...o(e)},s=Date.now(),c;try{c=await i()}catch(r){throw C(e.logger,{...a,errorClass:t(r)}),e.telemetry?.toolThrew(n,Date.now()-s,r),await e.telemetry?.flush(),r}let l=E(c)&&c.isError===!0;return C(e.logger,{...a,result:k(c),errorClass:l?`tool_error`:void 0}),e.telemetry?.toolReturned(n,Date.now()-s,c),await e.telemetry?.flush(),c}const T=/* @__PURE__ */ new Set([`text`,`image`,`audio`,`resource`,`resource_link`]);function E(t){return e(t)&&Array.isArray(t.content)&&t.content.every(t=>e(t)&&T.has(t.type))}function D(t){return e(t)&&t.resultType===`input_required`}function O(e,t=``){return e.content.map(e=>e.type===`text`?e.text:``).join(t)}function k(e){if(typeof e==`string`)return e;if(E(e))return O(e);if(D(e))return``;try{return JSON.stringify(e)??``}catch{return``}}function A(e,{audit:t,code:r,description:i,sessionHandle:a,toolNames:o,fetchBudget:s,fetchCapable:c,requestId:u,messageId:f,callerSubject:p,clientIp:m}){let h=p??a;v(e,`Record code execution input`,{code_sha256:t.sha256,code_length:t.length,request_id:u,message_id:f,flags:t.flags,subject_sha256:h?l(h):void 0,client_ip:m,description:d(i),tools:[...o].sort().join(`,`),fetch_capable:c,fetch_budget:s,code:d(n(r))})}function j(e,{rawUrl:t,method:n,host:r,outcome:i,durationMs:a,injectedSecretValues:o,credentialQueryParams:s,path:c,api:u,status:f,injectedScheme:p,requestHeaders:g,requestBody:y,responseHeaders:b,responseBody:x,caller:S={}}){let{requestId:C,callerSubject:w,clientIp:T}=S,E=x===void 0?void 0:m(x);v(e,`Record gateway fetch`,{url_sha256:l(t),host:r,method:n,path:c,api:u,outcome:i,status:f,injected_scheme:p,duration_ms:a,request_id:C,subject_sha256:w?l(w):void 0,client_ip:T,url:_(t,o,s),request_header_names:h(g),request_body:y===void 0?void 0:d(y,o),response_header_names:h(b),response_sha256:E?.sha256,response_bytes:E?.bytes})}export{c as AUDIT_FIELD_MAX_CHARS,s as AUDIT_LOG_PREFIX,x as auditCode,h as auditHeaderNames,d as auditInput,l as auditSha256,p as auditStack,w as auditToolCall,_ as auditUrl,o as callAttribution,E as isCallToolResult,v as logAuditRecord,A as logCodeExecutionAudit,j as logGatewayFetchAudit,C as logMcpToolCallAudit,k as toolOutputText,O as toolResultText,u as truncateAuditField};
@@ -1,7 +1,7 @@
1
- import{FETCH_TOOL_NAME as e}from"./constants.js";import{callableApis as t}from"../gateway/eligibility.js";import{allowsOnlySafeHttpMethods as n,getAllowedHttpMethods as r}from"../gateway/allowed-http-methods.js";import{EXECUTE_ARGS_NOTE as i,USAGE_NOTES as a,buildExecuteExample as o}from"./prompts.js";import{PLAIN_JAVASCRIPT_RULE as s,READ_ONLY_ANNOTATIONS as c,buildToolTypeDeclarations as l,sanitizeToolName as u}from"@redocly/mcp";const d=["```ts",`/**`,` * Call a documented operation of a callable API. Undocumented paths and methods are refused.`,` * Responses cap at 1 MiB and redirects are not followed.`,` */`,`declare function fetch(url: string | URL, init?: {`,` method?: string;`," /** `content-type` is set automatically for URLSearchParams/FormData unless you set one. */",` headers?: Record<string, string>;`,` /** string · URLSearchParams (→ application/x-www-form-urlencoded) · FormData (→ multipart/form-data) */`,` body?: string | URLSearchParams | FormData;`," /** Security scheme name (from the operation's `security` or `getSecuritySchemes`) whose credential to send. Omit to let the server choose. */",` securityScheme?: string;`,`}): Promise<{`,` status: number;`,` statusText: string;`,` ok: boolean;`,` headers: { get(name: string): string | null };`,` json(): Promise<unknown>;`,` text(): Promise<string>;`,`}>;`,"```"].join(`
1
+ import{FETCH_TOOL_NAME as e}from"./constants.js";import{buildToolTypeDeclarations as t,sanitizeToolName as n}from"./tool-declarations.js";import{READ_ONLY_ANNOTATIONS as r}from"../tools/schemas.js";import{callableApis as i}from"../gateway/eligibility.js";import{allowsOnlySafeHttpMethods as a,getAllowedHttpMethods as o}from"../gateway/allowed-http-methods.js";import{EXECUTE_ARGS_NOTE as s,PLAIN_JAVASCRIPT_RULE as c,USAGE_NOTES as l,buildExecuteExample as u}from"./prompts.js";const d=["```ts",`/**`,` * Call a documented operation of a callable API. Undocumented paths and methods are refused.`,` * Responses cap at 1 MiB and redirects are not followed.`,` */`,`declare function fetch(url: string | URL, init?: {`,` method?: string;`," /** `content-type` is set automatically for URLSearchParams/FormData unless you set one. */",` headers?: Record<string, string>;`,` /** string · URLSearchParams (→ application/x-www-form-urlencoded) · FormData (→ multipart/form-data) */`,` body?: string | URLSearchParams | FormData;`," /** Security scheme name (from the operation's `security` or `getSecuritySchemes`) whose credential to send. Omit to let the server choose. */",` securityScheme?: string;`,`}): Promise<{`,` status: number;`,` statusText: string;`,` ok: boolean;`,` headers: { get(name: string): string | null };`,` json(): Promise<unknown>;`,` text(): Promise<string>;`,`}>;`,"```"].join(`
2
2
  `),f=[`listApis`,`getEndpoints`,`getEndpointInfo`],p=[`Example - list the paid invoices of a billing API:`,``,"```js",`const { items } = await site.listApis({ filter: 'billing' });`,`const [api] = items;`,`if (!api) return { error: 'no API matches "billing"' };`,`const { endpoints } = await site.getEndpoints({ name: api.name });`,`const ep = endpoints.find((e) => e.method === 'GET' && e.path.includes('invoices'));`,`const info = await site.getEndpointInfo({ name: api.name, path: ep.path, method: ep.method });`,"// Replace every `{placeholder}` first.",`const url = new URL((info.servers?.[0]?.url ?? '') + ep.path);`,"// Every name below comes from `info.endpoint.parameters` - read them first, never guess them.",`url.searchParams.set('filter', 'status:paid');`,`url.searchParams.set('sort', '-createdTime');`,`url.searchParams.set('limit', '100');`,`try {`,` const res = await fetch(url, { method: ep.method });`,` return res.ok ? await res.json() : { status: res.status, error: await res.text() };`,`} catch (error) {`,` return { error: error instanceof Error ? error.message : String(error), endpointId: info };`,`}`,"```"].join(`
3
3
  `),m=[`Example - call an endpoint you already read:`,``,"```js","// Call `getEndpointInfo` first for the server URL, the path, and the parameter names.","// Replace every `{placeholder}` first.",`const url = new URL('https://api.example.com/invoices');`,`url.searchParams.set('filter', 'status:paid');`,`try {`,` const res = await fetch(url, { method: 'GET' });`,` return res.ok ? await res.json() : { status: res.status, error: await res.text() };`,`} catch (error) {`,` return { error: error instanceof Error ? error.message : String(error) };`,`}`,"```"].join(`
4
- `);function h(e){return f.every(t=>e.includes(t))?p:m}function g(e){let t=/* @__PURE__ */ new Map;for(let{name:n,version:r}of e){if(!n)continue;let e=t.get(n)??[];r&&e.push(r),t.set(n,e)}return[...t.entries()].map(([e,t])=>t.length>1?`${e} (${t.map(e=>`v${e}`).join(`, `)})`:e).join(`, `)}const _={id:e,purpose:`Call the documented APIs over HTTP`,isActive:async e=>(await t(e)).length>0,annotations:e=>n(e)?{readOnlyHint:!0,destructiveHint:!1,openWorldHint:!0}:{readOnlyHint:!1,destructiveHint:!0,openWorldHint:!0},async renderSection(e,n){let i=g(await t(e));return["## `fetch` — call the documented APIs",``,d,``,"Always call `getEndpointInfo` before `fetch` for the exact URL, required parameters, and body shape. Put filtering, sorting, and paging in the query parameters, and keep sandbox JS for what the endpoint cannot express. Never guess.",``,"An endpoint path can hold `{placeholders}`. Fill each one from `endpoint.parameters` before you call `fetch`. Server URLs come with their variable defaults filled in. A `{placeholder}` left in a server URL has no usable default, so ask the user for its value.",``,`\`fetch\` sends only the methods this project allows: ${r(e.config.mcp).join(`, `)}. Explain any other call to the user instead of making it.`,``,`Callable APIs (their documented hosts are reachable via \`fetch\`): ${i}`,``,h(n)].join(`
5
- `)}},v=[_];async function y(e){let t=await Promise.all(v.map(t=>t.isActive(e)));return v.filter((e,n)=>t[n])}function b(e,t,n){let r=[...e.map(e=>e.annotations??{}),...t.map(e=>e.annotations(n))],i=r.filter(e=>e.readOnlyHint!==!0),a=r.some(e=>e.openWorldHint!==!1);return i.length===0?{...c,openWorldHint:a}:{readOnlyHint:!1,destructiveHint:i.some(e=>e.destructiveHint!==!1),idempotentHint:i.every(e=>e.idempotentHint===!0),openWorldHint:a}}async function x(e,t,n){let r=e.map(e=>u(e.name)),c=[];if(e.length>0){let t=l(e),n=t.includes(`OpenApi`)?`\n\n${a}`:``;c.push(`## Sandbox functions\n\nThe signatures are TypeScript declarations. ${s}\n\n${t}${n}`)}c.push(i),e.length>0&&!t.some(e=>e.id===`fetch`)&&c.push(o(r));for(let e of t)c.push(await e.renderSection(n,r));return c.join(`
4
+ `);function h(e){return f.every(t=>e.includes(t))?p:m}function g(e){let t=/* @__PURE__ */ new Map;for(let{name:n,version:r}of e){if(!n)continue;let e=t.get(n)??[];r&&e.push(r),t.set(n,e)}return[...t.entries()].map(([e,t])=>t.length>1?`${e} (${t.map(e=>`v${e}`).join(`, `)})`:e).join(`, `)}const _={id:e,purpose:`Call the documented APIs over HTTP`,isActive:async e=>(await i(e)).length>0,annotations:e=>a(e)?{readOnlyHint:!0,destructiveHint:!1,openWorldHint:!0}:{readOnlyHint:!1,destructiveHint:!0,openWorldHint:!0},async renderSection(e,t){let n=g(await i(e));return["## `fetch` — call the documented APIs",``,d,``,"Always call `getEndpointInfo` before `fetch` for the exact URL, required parameters, and body shape. Put filtering, sorting, and paging in the query parameters, and keep sandbox JS for what the endpoint cannot express. Never guess.",``,"An endpoint path can hold `{placeholders}`. Fill each one from `endpoint.parameters` before you call `fetch`. Server URLs come with their variable defaults filled in. A `{placeholder}` left in a server URL has no usable default, so ask the user for its value.",``,`\`fetch\` sends only the methods this project allows: ${o(e.config.mcp).join(`, `)}. Explain any other call to the user instead of making it.`,``,`Callable APIs (their documented hosts are reachable via \`fetch\`): ${n}`,``,h(t)].join(`
5
+ `)}},v=[_];async function y(e){let t=await Promise.all(v.map(t=>t.isActive(e)));return v.filter((e,n)=>t[n])}function b(e,t,n){let i=[...e.map(e=>e.annotations??{}),...t.map(e=>e.annotations(n))],a=i.filter(e=>e.readOnlyHint!==!0),o=i.some(e=>e.openWorldHint!==!1);return a.length===0?{...r,openWorldHint:o}:{readOnlyHint:!1,destructiveHint:a.some(e=>e.destructiveHint!==!1),idempotentHint:a.every(e=>e.idempotentHint===!0),openWorldHint:o}}async function x(e,r,i){let a=e.map(e=>n(e.name)),o=[];if(e.length>0){let n=t(e),r=n.includes(`OpenApi`)?`\n\n${l}`:``;o.push(`## Sandbox functions\n\nThe signatures are TypeScript declarations. ${c}\n\n${n}${r}`)}o.push(s),e.length>0&&!r.some(e=>e.id===`fetch`)&&o.push(u(a));for(let e of r)o.push(await e.renderSection(i,a));return o.join(`
6
6
 
7
7
  `)}export{v as ALL_CAPABILITIES,d as FETCH_DECLARATION,b as composeExecuteAnnotations,_ as fetchCapability,y as getActiveCapabilities,x as renderDiscoverOutput};
@@ -1 +1 @@
1
- import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as e,DISCOVER_TOOL_NAME as t,EXECUTE_TOOL_NAME as n,MANAGE_API_CREDENTIALS_TOOL_NAME as r,REMOVE_API_CREDENTIALS_TOOL_NAME as i,SUBMIT_FEEDBACK_TOOL_NAME as a}from"@redocly/mcp";const o=`fetch`,s=/* @__PURE__ */ new Set([n,t,e,r,i,a]),c=`site`,l=`tools`,u=`__fetchBridge`,d=`fetch`,f=1e4,p=45e3,m=5e4,h=1e3,g=50,_=50,v={ratePerMin:600,quotaPerDay:1e5},y=8388608,b=1048576,x=262144,S=67108864,C=134217728,w=16777216,T=65536,E=2,D=4,O=5e3,k=`The sandbox failed to run this code. The cause was logged on the server.`,A=`HostFunctionError`,j=`HostOutputTooLargeError`;export{O as ACQUIRE_TIMEOUT_MS,s as CODE_MODE_TOOL_NAMES,p as DEFAULT_MAX_LIFETIME_MS,f as DEFAULT_TIMEOUT_MS,m as EXECUTE_DEADLINE_MS,d as FETCH_BRIDGE_FUNCTION_NAME,u as FETCH_BRIDGE_GLOBAL_NAME,o as FETCH_TOOL_NAME,_ as GATEWAY_FETCH_BUDGET_PER_EXEC,v as GATEWAY_FETCH_LIMITS,A as HOST_FUNCTION_ERROR_NAME,j as HOST_OUTPUT_TOO_LARGE_ERROR_NAME,w as INITIAL_TOTAL_MEMORY_BYTES,k as INTERNAL_ERROR_MESSAGE,S as MAX_ALLOCATION_BYTES,E as MAX_CONCURRENT_RUNS,g as MAX_FETCH_CALLS,b as MAX_FETCH_OUTPUT_BYTES,D as MAX_QUEUED_RUNS,x as MAX_STACK_SIZE_BYTES,h as MAX_TOOL_CALLS,y as MAX_TOOL_OUTPUT_BYTES,C as MAX_TOTAL_MEMORY_BYTES,c as SITE_GLOBAL_NAME,l as TOOLS_GLOBAL_ALIAS,T as WASM_PAGE_BYTES};
1
+ import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as e,DISCOVER_TOOL_NAME as t,EXECUTE_TOOL_NAME as n,MANAGE_API_CREDENTIALS_TOOL_NAME as r,REMOVE_API_CREDENTIALS_TOOL_NAME as i,SUBMIT_FEEDBACK_TOOL_NAME as a}from"../../constants.js";const o=`fetch`,s=/* @__PURE__ */ new Set([n,t,e,r,i,a]),c=`site`,l=`tools`,u=`__fetchBridge`,d=`fetch`,f=1e4,p=45e3,m=5e4,h=1e3,g=50,_=50,v={ratePerMin:600,quotaPerDay:1e5},y=8388608,b=1048576,x=1048576,S=262144,C=67108864,w=134217728,T=16777216,E=65536,D=2,O=4,k=5e3,A=`The sandbox failed to run this code. The cause was logged on the server.`,j=`HostFunctionError`,M=`HostOutputTooLargeError`,N={NoReturn:`no_return`,OutputTooLarge:`output_too_large`,Timeout:`timeout`,MemoryLimit:`memory_limit`,SyntaxError:`syntax_error`,HostError:`host_error`,RuntimeError:`runtime_error`};export{k as ACQUIRE_TIMEOUT_MS,s as CODE_MODE_TOOL_NAMES,p as DEFAULT_MAX_LIFETIME_MS,f as DEFAULT_TIMEOUT_MS,m as EXECUTE_DEADLINE_MS,d as FETCH_BRIDGE_FUNCTION_NAME,u as FETCH_BRIDGE_GLOBAL_NAME,o as FETCH_TOOL_NAME,_ as GATEWAY_FETCH_BUDGET_PER_EXEC,v as GATEWAY_FETCH_LIMITS,j as HOST_FUNCTION_ERROR_NAME,M as HOST_OUTPUT_TOO_LARGE_ERROR_NAME,T as INITIAL_TOTAL_MEMORY_BYTES,A as INTERNAL_ERROR_MESSAGE,C as MAX_ALLOCATION_BYTES,D as MAX_CONCURRENT_RUNS,g as MAX_FETCH_CALLS,b as MAX_FETCH_OUTPUT_BYTES,O as MAX_QUEUED_RUNS,x as MAX_RESULT_BYTES,S as MAX_STACK_SIZE_BYTES,h as MAX_TOOL_CALLS,y as MAX_TOOL_OUTPUT_BYTES,w as MAX_TOTAL_MEMORY_BYTES,N as SANDBOX_FAILURE,c as SITE_GLOBAL_NAME,l as TOOLS_GLOBAL_ALIAS,E as WASM_PAGE_BYTES};
@@ -1,3 +1,3 @@
1
- import{UnknownToolError as e}from"../tool-errors.js";import{buildDiscoverDescription as t}from"./prompts.js";import{renderDiscoverOutput as n}from"./capabilities.js";import{DISCOVER_TOOL_NAME as r,READ_ONLY_ANNOTATIONS as i,sanitizeToolName as a}from"@redocly/mcp";function o(e,n,o=!0){let s=[.../* @__PURE__ */ new Set([...e.map(e=>a(e.name)),...n.map(e=>a(e.id))])];return{name:r,title:`Get docs function signatures`,description:t(o),annotations:i,schema:{type:`object`,required:[],additionalProperties:!1,properties:{names:{type:`array`,description:o?`Names of the sandbox functions to discover: ${s.join(`, `)}. Omit to discover all of them.`:`Names of the sandbox functions to discover. Omit to discover all of them.`,items:s.length>0?{type:`string`,enum:s}:{type:`string`},nullable:!0}}}}}function s(t,r,i,o){let s=new Map(t.map(e=>[a(e.name),e])),c=new Set(i.map(e=>a(e.id)));return async l=>{let u=[...new Set((l.names??[]).map(a))],d=u.filter(e=>!s.has(e)&&!c.has(e));if(d.length>0){let t=[...s.keys(),...c];throw new e(`Unknown function name(s): ${d.join(`, `)}. Valid names: ${t.join(`, `)}.`)}let f=u.length===0?i:i.filter(e=>u.includes(a(e.id))),p=u.length===0?t:u.filter(e=>s.has(e)).map(e=>s.get(e)),m=await Promise.all(p.map(e=>r(e.name))),h=p.filter((e,t)=>m[t]),g=p.filter((e,t)=>!m[t]),_=[await n(h,f,o)];return g.length>0&&_.push(`Not available for this request: ${g.map(e=>a(e.name)).join(`, `)}`),{content:[{type:`text`,text:_.join(`
1
+ import{DISCOVER_TOOL_NAME as e}from"../../constants.js";import{UnknownToolError as t}from"../tool-errors.js";import{sanitizeToolName as n}from"./tool-declarations.js";import{READ_ONLY_ANNOTATIONS as r}from"../tools/schemas.js";import{buildDiscoverDescription as i}from"./prompts.js";import{renderDiscoverOutput as a}from"./capabilities.js";function o(t,a,o=!0){let s=[.../* @__PURE__ */ new Set([...t.map(e=>n(e.name)),...a.map(e=>n(e.id))])];return{name:e,title:`Get docs function signatures`,description:i(o),annotations:r,schema:{type:`object`,required:[],additionalProperties:!1,properties:{names:{type:`array`,description:o?`Names of the sandbox functions to discover: ${s.join(`, `)}. Omit to discover all of them.`:`Names of the sandbox functions to discover. Omit to discover all of them.`,items:s.length>0?{type:`string`,enum:s}:{type:`string`},nullable:!0}}}}}function s(e,r,i,o){let s=new Map(e.map(e=>[n(e.name),e])),c=new Set(i.map(e=>n(e.id)));return async l=>{let u=[...new Set((l.names??[]).map(n))],d=u.filter(e=>!s.has(e)&&!c.has(e));if(d.length>0){let e=[...s.keys(),...c];throw new t(`Unknown function name(s): ${d.join(`, `)}. Valid names: ${e.join(`, `)}.`)}let f=u.length===0?i:i.filter(e=>u.includes(n(e.id))),p=u.length===0?e:u.filter(e=>s.has(e)).map(e=>s.get(e)),m=await Promise.all(p.map(e=>r(e.name))),h=p.filter((e,t)=>m[t]),g=p.filter((e,t)=>!m[t]),_=[await a(h,f,o)];return g.length>0&&_.push(`Not available for this request: ${g.map(e=>n(e.name)).join(`, `)}`),{content:[{type:`text`,text:_.join(`
2
2
 
3
3
  `)}]}}}export{s as discover,o as discoverSchema};
@@ -1 +1 @@
1
- import{buildExecuteDescription as e}from"./prompts.js";import{EXECUTE_TOOL_NAME as t}from"@redocly/mcp";const n=`Execute code`;function r(e){return e.readOnlyHint?`Query the docs with code`:n}const i={name:t,title:n,description:e(!1),schema:{type:`object`,required:[`code`,`description`],additionalProperties:!1,properties:{code:{type:`string`,description:`JavaScript to run in the sandbox. Return a value to receive it as the result.`,minLength:1},description:{type:`string`,description:`A short, human-readable summary of what this code does.`,minLength:1},sessionHandle:{type:`string`,description:`Handle returned by createAnonymousSession. Required when an API needs credentials. This parameter is only offered when createAnonymousSession is available, so pass it whenever you have called that tool.`,minLength:1}}}},a={result:{description:`The value the code returned, as JSON`},error:{type:`string`,description:`Why the code failed. Set only on a failed call`}},o={type:`array`,description:"Every `fetch` request that reached an API before the failure, with its status; running the code again sends them again. Set only on a failed call",items:{type:`object`,properties:{method:{type:`string`},url:{type:`string`},status:{type:`number`,description:`Unset when no response arrived`}}}};function s(e){return{type:`object`,properties:e?{...a,sentFetches:o}:a}}export{i as EXECUTE_TOOL_SCHEMA,s as executeOutputSchema,r as executeToolTitle};
1
+ import{EXECUTE_TOOL_NAME as e}from"../../constants.js";import{buildExecuteDescription as t}from"./prompts.js";const n=`Execute code`;function r(e){return e.readOnlyHint?`Query the docs with code`:n}const i={name:e,title:n,description:t(!1),schema:{type:`object`,required:[`code`,`description`],additionalProperties:!1,properties:{code:{type:`string`,description:`JavaScript to run in the sandbox. Return a value to receive it as the result.`,minLength:1},description:{type:`string`,description:`A short, human-readable summary of what this code does.`,minLength:1},sessionHandle:{type:`string`,description:`Handle returned by createAnonymousSession. Required when an API needs credentials. This parameter is only offered when createAnonymousSession is available, so pass it whenever you have called that tool.`,minLength:1}}}},a={result:{description:`The value the code returned, as JSON`},error:{type:`string`,description:`Why the code failed. Set only on a failed call`}},o={type:`array`,description:"Every `fetch` request that reached an API before the failure, with its status; running the code again sends them again. Set only on a failed call",items:{type:`object`,properties:{method:{type:`string`},url:{type:`string`},status:{type:`number`,description:`Unset when no response arrived`}}}};function s(e){return{type:`object`,properties:e?{...a,sentFetches:o}:a}}export{i as EXECUTE_TOOL_SCHEMA,s as executeOutputSchema,r as executeToolTitle};
@@ -0,0 +1 @@
1
+ function e(e,t,n){let r=Math.max(0,n-Date.now()),i=`Execution timed out after ${t}ms. Do less processing in the script, or ask the functions for less data.`,a=`Exceeded the maximum lifetime of ${r}ms. Make fewer function calls in one script, or ask for less data.`,o=Date.now()+t,s=t,c,l=()=>{},u=new Promise((e,t)=>{l=e=>{c=e,t(Error(e))}}),d,f=()=>{clearTimeout(d),d=setTimeout(()=>l(i),t)};e.runtime.setInterruptHandler(()=>{let e=Date.now();return e>o?c=i:e>n&&(c=a),c!==void 0}),f();let p=setTimeout(()=>l(a),r),m=0;return{hostCall:t=>{s=o-Date.now(),m++,clearTimeout(d);let n=()=>{e.alive&&(o=Date.now()+s,--m===0&&f())},r=t();return r.then(n,n),r},aborted:u,expiredMessage:()=>c,dispose(){clearTimeout(d),clearTimeout(p)}}}export{e as createExecutionBudget};
@@ -1 +1 @@
1
- import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{formatError as t,innerToolErrorClass as n}from"../tool-errors.js";import{auditCode as r,callAttribution as i,logCodeExecutionAudit as a,logMcpToolCallAudit as o,toolOutputText as s,toolResultText as c}from"../audit.js";import{CODE_MODE_TOOL_NAMES as l,INTERNAL_ERROR_MESSAGE as u}from"./constants.js";import{availableTools as d}from"../tool-registry.js";import{SandboxBusyError as f,sandboxAdmission as p}from"./admission.js";import{createSandboxSetup as m}from"./sandbox-setup.js";import{createToolInputValidator as h}from"./tool-input-validator.js";import{SANDBOX_FAILURE as g,authoredPosition as _,describeGuestError as v,returnLastExpression as y,sanitizeToolName as b}from"@redocly/mcp";import{isCallToolResult as x}from"@modelcontextprotocol/server";async function S(e){let{code:n,registry:o,ctx:s,timeoutMs:c}=e,h=await d(o,s),x=s.telemetry?.trackCodeExecution(n,e.hostFetch),S=x?.hostFetch??e.hostFetch,w=Object.create(null);for(let e of h){if(l.has(e.schema.name))continue;let t=b(e.schema.name);w[t]=C(e,t,s,x)}let T=Object.keys(w);a(s.logger,{audit:r(n),code:n,description:e.description??``,sessionHandle:e.sessionHandle,toolNames:T,fetchBudget:e.fetchBudget,fetchCapable:S!==void 0,...i(s)});let E=y(n),D;try{let{runInSandbox:e}=await import(`./sandbox.js`);D=await p.run(()=>e(E.code,{setupContext:m(w,S),authoredCode:n,timeoutMs:c,deadline:s.executeDeadline,logger:s.logger}))}catch(e){e instanceof f?D={error:e.message}:(s.logger?.error(`MCP code mode failed before a result: ${t(e)}`),D={error:u,failure:g.RuntimeError})}let O=D.error===void 0?void 0:v(n,D.error,D.errorPosition&&_(E,D.errorPosition),T,D.failure),k=O===void 0?{result:D.result}:{error:O.message},A={content:[{type:`text`,text:JSON.stringify(k)}],structuredContent:k,isError:O!==void 0};return x?.finish(D,A,O?.unknownTool),A}function C(e,r,a,l){let{name:u}=e.schema,d=h(r,e.schema.schema),f={tool:u,mode:`code`,...i(a)},p=async r=>{let i=w(r,e.inputAliases),l=d(i);if(l)throw Error(l);let p;try{p=await e.execute(i,a)}catch(e){throw a.logger?.warn(`MCP tool "${u}" failed in code mode: ${t(e)}`),o(a.logger,{...f,args:r,errorClass:n(e)}),e}let m=x(p)&&p.isError===!0?p:void 0;if(o(a.logger,{...f,args:r,result:s(p),errorClass:m?`tool_error`:void 0}),m)throw Error(c(m));return p};return async e=>T(await(l?l.innerToolCall(u,()=>p(e)):p(e)))}function w(t,n){if(!n||!e(t))return t;let r={...t};for(let[e,t]of Object.entries(n))e in r&&(r[t]??=r[e],delete r[e]);return r}function T(e){if(!x(e))return e;if(e.structuredContent!==void 0)return e.structuredContent;let t=c(e);try{return JSON.parse(t)}catch{return t}}export{S as runCodeMode};
1
+ import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{formatError as t,innerToolErrorClass as n}from"../tool-errors.js";import{auditCode as r,callAttribution as i,logCodeExecutionAudit as a,logMcpToolCallAudit as o,toolOutputText as s,toolResultText as c}from"../audit.js";import{CODE_MODE_TOOL_NAMES as l,INTERNAL_ERROR_MESSAGE as u,SANDBOX_FAILURE as d}from"./constants.js";import{availableTools as f}from"../tool-registry.js";import{sanitizeToolName as p}from"./tool-declarations.js";import{SandboxBusyError as m,sandboxAdmission as h}from"./admission.js";import{authoredPosition as g,returnLastExpression as _}from"./return-last-expression.js";import{createSandboxSetup as v}from"./sandbox-setup.js";import{createToolInputValidator as y}from"./tool-input-validator.js";import{describeGuestError as b}from"./unknown-tool-hint.js";import{isCallToolResult as x}from"@modelcontextprotocol/server";async function S(e){let{code:n,registry:o,ctx:s,timeoutMs:c}=e,y=await f(o,s),x=s.telemetry?.trackCodeExecution(n,e.hostFetch),S=x?.hostFetch??e.hostFetch,w=Object.create(null);for(let e of y){if(l.has(e.schema.name))continue;let t=p(e.schema.name);w[t]=C(e,t,s,x)}let T=Object.keys(w);a(s.logger,{audit:r(n),code:n,description:e.description??``,sessionHandle:e.sessionHandle,toolNames:T,fetchBudget:e.fetchBudget,fetchCapable:S!==void 0,...i(s)});let E=_(n),D;try{let{runInSandbox:e}=await import(`./sandbox.js`);D=await h.run(()=>e(E.code,{setupContext:v(w,S),authoredCode:n,timeoutMs:c,deadline:s.executeDeadline,logger:s.logger}))}catch(e){e instanceof m?D={error:e.message}:(s.logger?.error(`MCP code mode failed before a result: ${t(e)}`),D={error:u,failure:d.RuntimeError})}let O=D.error===void 0?void 0:b(n,D.error,D.errorPosition&&g(E,D.errorPosition),T,D.failure),k=O===void 0?{result:D.result}:{error:O.message},A={content:[{type:`text`,text:JSON.stringify(k)}],structuredContent:k,isError:O!==void 0};return x?.finish(D,A,O?.unknownTool),A}function C(e,r,a,l){let{name:u}=e.schema,d=y(r,e.schema.schema),f={tool:u,mode:`code`,...i(a)},p=async r=>{let i=w(r,e.inputAliases),l=d(i);if(l)throw Error(l);let p;try{p=await e.execute(i,a)}catch(e){throw a.logger?.warn(`MCP tool "${u}" failed in code mode: ${t(e)}`),o(a.logger,{...f,args:r,errorClass:n(e)}),e}let m=x(p)&&p.isError===!0?p:void 0;if(o(a.logger,{...f,args:r,result:s(p),errorClass:m?`tool_error`:void 0}),m)throw Error(c(m));return p};return async e=>T(await(l?l.innerToolCall(u,()=>p(e)):p(e)))}function w(t,n){if(!n||!e(t))return t;let r={...t};for(let[e,t]of Object.entries(n))e in r&&(r[t]??=r[e],delete r[e]);return r}function T(e){if(!x(e))return e;if(e.structuredContent!==void 0)return e.structuredContent;let t=c(e);try{return JSON.parse(t)}catch{return t}}export{S as runCodeMode};
@@ -1,8 +1,8 @@
1
- import{buildToolList as e}from"./tool-list.js";const t=2048,n="Both `execute` arguments are required: `code` (the JavaScript to run; return a value to receive it) and `description` (a short human-readable summary of what the code does).";function r(n,r){if(r.length===0)return n;let i=t-n.length-66-3,a=e(r,i);return a?[n,``,"Functions for `execute` scripts (signatures come from `discover`):",a].join(`
2
- `):n}function i(e,t){return[t?`Run plain JavaScript (no TypeScript syntax) in a sandbox against the documentation at ${t}. The script calls the sandbox functions on the global \`site\` object.`:"Run plain JavaScript (no TypeScript syntax) in a sandbox against this documentation site. The script calls the sandbox functions on the global `site` object.",e?"The extra globals are `site`, `fetch`, `URL`, `URLSearchParams`, and `FormData` - there is no `console`, `setTimeout`, `require`, or Node.js API; all other I/O goes through `site`.":"The only extra global is `site` - there is no `fetch`, `console`, `setTimeout`, `require`, or Node.js API; all I/O goes through `site`.",``,"Workflow - minimize round-trips; one `discover` call plus one `execute` call covers most requests:",`1. Analyze the request and decide which sandbox functions it needs.`,"2. Call `discover` with those names to get their exact TypeScript signatures - inputs, result shapes, and a worked example. NEVER call `execute` with guessed function names, parameter names, enum values, or result field names: read fields off the declared return types, not from assumptions.","3. Batch everything into a SINGLE script: chain function calls, pass one call's output into the next, process results in plain JavaScript, and `return` only what the request needs."].join(`
3
- `)}function a(e,n){let r=e&&n(e);return r&&r.length<=t?r:n()}function o(e,t=[],n){return r(a(n,t=>i(e,t)),t)}function s(e){return e?`Tools for the documentation at ${e}.`:`Tools for this documentation site.`}function c(e){return`${s(e)} Use them to answer questions about the content of these docs.`}function l(e){return a(e,c)}function u(e){return["Get the exact TypeScript signatures of the sandbox functions that `execute` scripts can call.",`Analyze the user request first, then pass \`names\` with only the functions the request needs (${e?`every name is listed in this input schema / description`:`every name is in the enum of this input schema`}); omit \`names\` only when you cannot tell which functions apply.`,"Always call this before your first `execute` and never guess signatures. Request every function the task may need in ONE call instead of calling this repeatedly."].join(`
4
- `)}function d(e,t){let n=[c(t),"- `discover` returns the exact TypeScript signatures of the sandbox functions.","- `execute` runs a JavaScript script that calls those functions on the global `site` object.","Workflow: analyze the request, call `discover` once with `names` set to only the functions it needs, then batch everything into a single `execute` script. Minimize round-trips and never guess function signatures."];return e&&n.push("The sandbox also has a global `fetch` that can call the documented APIs (allow-listed hosts only). Include `fetch` in your `discover` call to get its contract and the list of callable APIs."),n.join(`
5
- `)}function f(e,t=[],n){return r(a(n,t=>d(e,t)),t)}const p=[`listApis`,`getEndpoints`],m=[`Example - list the write endpoints of an API:`,``,"```js",`const { items } = await site.listApis({ filter: 'billing' });`,`const [api] = items;`,`if (!api) return { error: 'no API matches "billing"' };`,`const { endpoints } = await site.getEndpoints({ name: api.name });`,`const writes = endpoints.filter((e) => e.method !== 'GET');`,"return { api: api.name, writes: writes.map((e) => `${e.method} ${e.path}`) };","```"].join(`
6
- `);function h(e){if(p.every(t=>e.includes(t)))return m;let[t]=e;return t?[`Example - call \`${t}\` and return what the request needs:`,``,"```js",`const result = await site.${t}({ /* the input its signature above declares */ });`,`return result;`,"```"].join(`
7
- `):``}const g=["Types named `OpenApi…` are the standard OpenAPI Specification objects.","Payload samples live on a media type object (`requestBody.content[mediaType]`, `responses[code].content[mediaType]`): `.example` holds a single value, `.examples[name].value` a named map, and some descriptions only set `.schema.example`. Read each before concluding a sample is absent."].join(`
8
- `);export{n as EXECUTE_ARGS_NOTE,g as USAGE_NOTES,f as buildCodeModeInstructions,u as buildDiscoverDescription,o as buildExecuteDescription,h as buildExecuteExample,l as buildToolsModeInstructions,s as docsSiteSentence};
1
+ import{buildToolList as e}from"./tool-list.js";const t=2048,n="Both `execute` arguments are required: `code` (the JavaScript to run; return a value to receive it) and `description` (a short human-readable summary of what the code does).",r="Write plain JavaScript: no type annotations, interfaces or `as` casts.";function i(n,r){if(r.length===0)return n;let i=t-n.length-66-3,a=e(r,i);return a?[n,``,"Functions for `execute` scripts (signatures come from `discover`):",a].join(`
2
+ `):n}function a(e,t){return[t?`Run plain JavaScript (no TypeScript syntax) in a sandbox against the documentation at ${t}. The script calls the sandbox functions on the global \`site\` object.`:"Run plain JavaScript (no TypeScript syntax) in a sandbox against this documentation site. The script calls the sandbox functions on the global `site` object.",e?"The extra globals are `site`, `fetch`, `URL`, `URLSearchParams`, and `FormData` - there is no `console`, `setTimeout`, `require`, or Node.js API; all other I/O goes through `site`.":"The only extra global is `site` - there is no `fetch`, `console`, `setTimeout`, `require`, or Node.js API; all I/O goes through `site`.",``,"Workflow - minimize round-trips; one `discover` call plus one `execute` call covers most requests:",`1. Analyze the request and decide which sandbox functions it needs.`,"2. Call `discover` with those names to get their exact TypeScript signatures - inputs, result shapes, and a worked example. NEVER call `execute` with guessed function names, parameter names, enum values, or result field names: read fields off the declared return types, not from assumptions.","3. Batch everything into a SINGLE script: chain function calls, pass one call's output into the next, process results in plain JavaScript, and `return` only what the request needs."].join(`
3
+ `)}function o(e,n){let r=e&&n(e);return r&&r.length<=t?r:n()}function s(e,t=[],n){return i(o(n,t=>a(e,t)),t)}function c(e){return e?`Tools for the documentation at ${e}.`:`Tools for this documentation site.`}function l(e){return`${c(e)} Use them to answer questions about the content of these docs.`}function u(e){return o(e,l)}function d(e){return["Get the exact TypeScript signatures of the sandbox functions that `execute` scripts can call.",`Analyze the user request first, then pass \`names\` with only the functions the request needs (${e?`every name is listed in this input schema / description`:`every name is in the enum of this input schema`}); omit \`names\` only when you cannot tell which functions apply.`,"Always call this before your first `execute` and never guess signatures. Request every function the task may need in ONE call instead of calling this repeatedly."].join(`
4
+ `)}function f(e,t){let n=[l(t),"- `discover` returns the exact TypeScript signatures of the sandbox functions.","- `execute` runs a JavaScript script that calls those functions on the global `site` object.","Workflow: analyze the request, call `discover` once with `names` set to only the functions it needs, then batch everything into a single `execute` script. Minimize round-trips and never guess function signatures."];return e&&n.push("The sandbox also has a global `fetch` that can call the documented APIs (allow-listed hosts only). Include `fetch` in your `discover` call to get its contract and the list of callable APIs."),n.join(`
5
+ `)}function p(e,t=[],n){return i(o(n,t=>f(e,t)),t)}const m=[`listApis`,`getEndpoints`],h=[`Example - list the write endpoints of an API:`,``,"```js",`const { items } = await site.listApis({ filter: 'billing' });`,`const [api] = items;`,`if (!api) return { error: 'no API matches "billing"' };`,`const { endpoints } = await site.getEndpoints({ name: api.name });`,`const writes = endpoints.filter((e) => e.method !== 'GET');`,"return { api: api.name, writes: writes.map((e) => `${e.method} ${e.path}`) };","```"].join(`
6
+ `);function g(e){if(m.every(t=>e.includes(t)))return h;let[t]=e;return t?[`Example - call \`${t}\` and return what the request needs:`,``,"```js",`const result = await site.${t}({ /* the input its signature above declares */ });`,`return result;`,"```"].join(`
7
+ `):``}const _=["Types named `OpenApi…` are the standard OpenAPI Specification objects.","Payload samples live on a media type object (`requestBody.content[mediaType]`, `responses[code].content[mediaType]`): `.example` holds a single value, `.examples[name].value` a named map, and some descriptions only set `.schema.example`. Read each before concluding a sample is absent."].join(`
8
+ `);export{n as EXECUTE_ARGS_NOTE,r as PLAIN_JAVASCRIPT_RULE,_ as USAGE_NOTES,p as buildCodeModeInstructions,d as buildDiscoverDescription,s as buildExecuteDescription,g as buildExecuteExample,u as buildToolsModeInstructions,c as docsSiteSentence};
@@ -0,0 +1 @@
1
+ import{SANDBOX_FAILURE as e}from"./constants.js";function t(t,a,o){try{let s=t.callFunction(a,t.undefined,o);return s.error?i(s.error.consume(e=>r(t,e))):s.value.consume(r=>{if(t.typeof(r)!==`string`)return i(n(t,o));let a=t.getProp(r,`length`).consume(e=>t.getNumber(e));return a>1048576?{error:`Result is too large (${a} bytes); return less data`,failure:e.OutputTooLarge}:{result:JSON.parse(t.getString(r))}})}finally{o.dispose()}}function n(e,t){let n=e.typeof(t);return n===`function`||n===`symbol`?`the value is a ${n}`:`the value has no JSON form`}function r(e,t){let n=e.typeof(t);if(n===`string`)return e.getString(t);if(n===`object`&&!e.eq(t,e.null)){let n=e.getProp(t,`message`).consume(t=>e.typeof(t)===`string`?e.getString(t):void 0);if(n!==void 0)return n}return`${n===`object`?`an`:`a`} ${n} was thrown`}function i(t){return t.includes(`out of memory`)?{error:`Result is too large to serialize; return less data`,failure:e.OutputTooLarge}:{error:`The result could not be converted to JSON (${t}); return plain data instead`,failure:e.RuntimeError}}export{t as readResult};
@@ -0,0 +1,6 @@
1
+ const e=(async()=>{}).constructor,t=/^(?:[)\]}]|(?:async\s+)?(?:function|class|const|let|var|if|for|while|do|switch|try|return|throw)\b)/,n=`return (`;function r(e){let r=e.length;for(;r>0&&` \r
2
+ ;`.includes(e[r-1]);)r--;let i=e.slice(0,r);for(let e of a(i)){let r=i.slice(e);if(t.test(r.slice(o(r))))continue;let a=`${i.slice(0,e)}${n}${r}\n)`;if(s(`${n}${r}\n)`)&&s(a))return{code:a,returnAt:e}}return{code:e}}function i({code:e,returnAt:t},n){if(t===void 0)return n;let r=e.slice(0,t).split(`
3
+ `),i=r.length,a=(r.at(-1)??``).length+1;return n.line!==i||n.column<a?n:{line:i,column:Math.max(a,n.column-8)}}function a(e){let t=[0];for(let n=e.length-1;n>=0&&t.length<=50;n--)(e[n]===`
4
+ `||e[n]===`;`)&&t.push(n+1);return t.sort((e,t)=>e-t)}function o(e){let t=0;for(;;){for(;t<e.length&&` \r
5
+ `.includes(e[t]);)t++;if(e.startsWith(`//`,t)){let n=e.indexOf(`
6
+ `,t);t=n===-1?e.length:n}else if(e.startsWith(`/*`,t)){let n=e.indexOf(`*/`,t+2);t=n===-1?e.length:n+2}else return t}}function s(t){try{return new e(t),!0}catch{return!1}}export{i as authoredPosition,r as returnLastExpression};
@@ -0,0 +1 @@
1
+ function e(e,t){let n=e.evalCode(t,`returns-from-top-level.js`,{type:`module`,compileOnly:!0});return n.error?n.error.consume(t=>e.dump(t))?.message===`return not in a function`:(n.value.dispose(),!1)}export{e as returnsFromTopLevel};