@redocly/framework 1.0.0-next.1 → 1.0.0-next.12

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 (519) hide show
  1. package/dist/bundler/build/dependency-pack.js +1 -1
  2. package/dist/bundler/build/output-metadata.js +1 -1
  3. package/dist/bundler/build/run.js +1 -1
  4. package/dist/bundler/build/theme-global-style-compiler.js +1 -0
  5. package/dist/bundler/build/theme-global-stylesheets.js +1 -0
  6. package/dist/bundler/build/vite-config.js +2 -2
  7. package/dist/bundler/dev/dev-content-build.js +1 -0
  8. package/dist/bundler/dev/dev-problems.js +1 -1
  9. package/dist/bundler/dev/dev-reporter.js +1 -1
  10. package/dist/bundler/dev/routes/dev-content-build-route.js +1 -0
  11. package/dist/bundler/dev/routes/dev-problems-route.js +1 -1
  12. package/dist/bundler/dev/routes/source-sync-route.js +1 -1
  13. package/dist/bundler/dev/run.js +1 -1
  14. package/dist/bundler/dev/runtime-app.js +1 -1
  15. package/dist/bundler/dev/vite-chunk-url.js +1 -1
  16. package/dist/bundler/dev/vite-config.js +1 -1
  17. package/dist/bundler/node-bundle.js +1 -0
  18. package/dist/bundler/runtime-files.js +1 -1
  19. package/dist/bundler/user-markdoc-schema.js +1 -1
  20. package/dist/bundler/vite-config.base.js +12 -12
  21. package/dist/cli/api-docs-build-event.js +1 -0
  22. package/dist/cli/args.js +1 -1
  23. package/dist/cli/commands/build.js +1 -1
  24. package/dist/cli/commands/dev.js +1 -1
  25. package/dist/cli/commands/ingest.js +1 -1
  26. package/dist/cli/commands/translate.js +1 -1
  27. package/dist/cli/dev-console/{sweep.js → content-build.js} +1 -1
  28. package/dist/cli/dev-console/index.js +1 -1
  29. package/dist/cli/dev-console/lines.js +2 -2
  30. package/dist/cli/dev-console/plain.js +1 -1
  31. package/dist/cli/dev-console/tui.js +2 -2
  32. package/dist/cli/output.js +12 -12
  33. package/dist/cli/problems-output.js +3 -3
  34. package/dist/cli/validate-react-pages.js +1 -1
  35. package/dist/client/ApiAccess.js +3 -0
  36. package/dist/client/NavigationProgress.js +1 -1
  37. package/dist/client/ProductsProvider.js +1 -1
  38. package/dist/client/RouteErrorBoundary.js +1 -1
  39. package/dist/client/RuntimeLink.js +1 -0
  40. package/dist/client/ThemeGlobalStyle.js +1 -0
  41. package/dist/client/UnversionedVersionButton.js +1 -1
  42. package/dist/client/ai-search/citations.js +3 -3
  43. package/dist/client/ai-search/use-ai-search.js +1 -1
  44. package/dist/client/analytics-page-view.js +1 -1
  45. package/dist/client/app.js +2 -7
  46. package/dist/client/classic-webview-sync.js +1 -0
  47. package/dist/client/client-entry.js +1 -1
  48. package/dist/client/contexts.js +1 -1
  49. package/dist/client/dev-problems/ProblemsBar.js +75 -15
  50. package/dist/client/dev-problems/ProblemsModal.js +15 -15
  51. package/dist/client/dev-problems/build-segment.js +1 -0
  52. package/dist/client/dev-problems/index.js +1 -1
  53. package/dist/client/dev-problems/use-dev-problems.js +1 -1
  54. package/dist/client/experiments/runtime.js +1 -1
  55. package/dist/client/feedback.js +1 -1
  56. package/dist/client/history-mount.js +1 -0
  57. package/dist/client/l10n/ssr-l10n.js +1 -1
  58. package/dist/client/l10n/use-l10n-config.js +1 -1
  59. package/dist/client/l10n/use-l10n-href.js +1 -1
  60. package/dist/client/l10n/use-translate.js +1 -1
  61. package/dist/client/page-sync.js +1 -0
  62. package/dist/client/products.js +1 -1
  63. package/dist/client/review/ReviewBar.js +163 -69
  64. package/dist/client/review/login-url.js +1 -0
  65. package/dist/client/review/use-review.js +1 -1
  66. package/dist/client/revisions-history.js +1 -1
  67. package/dist/client/sidebar/PoweredByRedocly.js +2 -2
  68. package/dist/client/sidebar/SidebarDataProvider.js +1 -1
  69. package/dist/client/sidebar/drilldown.js +1 -1
  70. package/dist/client/ssr.js +1 -1
  71. package/dist/client/telemetry/config.js +1 -1
  72. package/dist/client/telemetry/report-preload-failure.js +1 -0
  73. package/dist/client/templates/dev-login.js +4 -4
  74. package/dist/client/templates/unauthorized.js +5 -5
  75. package/dist/client/theme-global-css.js +1 -0
  76. package/dist/client/theme-logo.js +1 -1
  77. package/dist/client/use-banner.js +1 -1
  78. package/dist/client/use-bar-position.js +1 -0
  79. package/dist/client/use-entity-revisions.js +1 -1
  80. package/dist/client/use-page-versions.js +1 -1
  81. package/dist/client/use-router-for-local-links.js +1 -1
  82. package/dist/client/use-search.js +1 -1
  83. package/dist/client/utils/routes/is-router-path.js +1 -0
  84. package/dist/client/webmcp/tools/shared.js +1 -1
  85. package/dist/client/webmcp/tools/site-tools.js +1 -1
  86. package/dist/client/webmcp/use-webmcp-tools.js +1 -1
  87. package/dist/content-layer/allowed-packages.js +1 -1
  88. package/dist/content-layer/api-outputs.js +1 -1
  89. package/dist/content-layer/config-schema.d.ts +12 -3
  90. package/dist/content-layer/config-schema.js +1 -1
  91. package/dist/content-layer/config.d.ts +30 -12
  92. package/dist/content-layer/config.js +1 -1
  93. package/dist/content-layer/context-state.js +1 -1
  94. package/dist/content-layer/context.d.ts +2 -0
  95. package/dist/content-layer/context.js +1 -1
  96. package/dist/content-layer/database/adapters/node-sqlite-client.js +1 -1
  97. package/dist/content-layer/database/assets.js +1 -1
  98. package/dist/content-layer/database/connection.js +1 -1
  99. package/dist/content-layer/database/entity-store.d.ts +24 -3
  100. package/dist/content-layer/database/entity-store.js +1 -1
  101. package/dist/content-layer/database/invalidation.d.ts +6 -0
  102. package/dist/content-layer/database/invalidation.js +26 -26
  103. package/dist/content-layer/database/origins.d.ts +2 -4
  104. package/dist/content-layer/database/origins.js +1 -1
  105. package/dist/content-layer/database/problems.d.ts +2 -0
  106. package/dist/content-layer/database/problems.js +1 -1
  107. package/dist/content-layer/database/reset.js +1 -1
  108. package/dist/content-layer/database/schema.d.ts +50 -0
  109. package/dist/content-layer/database/schema.js +1 -1
  110. package/dist/content-layer/database/site-config.d.ts +23 -0
  111. package/dist/content-layer/database/site-config.js +1 -1
  112. package/dist/content-layer/ingest/extract-all-phase.js +1 -1
  113. package/dist/content-layer/ingest/finalize-phase.js +1 -1
  114. package/dist/content-layer/ingest/git-last-modified.js +3 -3
  115. package/dist/content-layer/ingest/hash.js +1 -1
  116. package/dist/content-layer/ingest/hook-inputs.js +1 -1
  117. package/dist/content-layer/ingest/markdoc-schema-problem.js +1 -0
  118. package/dist/content-layer/ingest/normalize-artifacts.js +1 -1
  119. package/dist/content-layer/ingest/rbac-teams.js +1 -1
  120. package/dist/content-layer/ingest/run.js +1 -1
  121. package/dist/content-layer/ingest/scan.d.ts +1 -1
  122. package/dist/content-layer/ingest/scan.js +1 -1
  123. package/dist/content-layer/ingest/search-sync.js +1 -1
  124. package/dist/content-layer/ingest/slugger/resolve-final-slugs.js +1 -1
  125. package/dist/content-layer/ingest/sync.js +1 -1
  126. package/dist/content-layer/link-checker/config-links.js +1 -1
  127. package/dist/content-layer/link-checker/delta.js +1 -1
  128. package/dist/content-layer/link-checker/fingerprint.js +1 -1
  129. package/dist/content-layer/link-checker/load-view.js +1 -1
  130. package/dist/content-layer/link-checker/node-ref.js +1 -1
  131. package/dist/content-layer/link-checker/run-build.js +1 -1
  132. package/dist/content-layer/link-checker/validate.js +1 -1
  133. package/dist/content-layer/link-checker/view.js +1 -1
  134. package/dist/content-layer/loaders/context.js +1 -1
  135. package/dist/content-layer/loaders/define.d.ts +3 -0
  136. package/dist/content-layer/markdown/client/JsonSchemaTag.js +1 -1
  137. package/dist/content-layer/markdown/client/OpenapiTagComponents.js +2 -2
  138. package/dist/content-layer/markdown/client/code-highlight-notation.js +3 -3
  139. package/dist/content-layer/markdown/client/dynamic-components.js +1 -1
  140. package/dist/content-layer/markdown/client/markdoc-components.js +2 -2
  141. package/dist/content-layer/markdown/client/markdown-text.js +1 -1
  142. package/dist/content-layer/markdown/constants/builtin-tags.js +1 -1
  143. package/dist/content-layer/markdown/constants/markdown-text-tag-set.js +1 -1
  144. package/dist/content-layer/markdown/constants/tag-sets.d.ts +20 -5
  145. package/dist/content-layer/markdown/constants/tag-sets.js +1 -1
  146. package/dist/content-layer/markdown/nodes/heading.js +1 -1
  147. package/dist/content-layer/markdown/nodes/table.js +1 -1
  148. package/dist/content-layer/markdown/resolve/ast.js +1 -1
  149. package/dist/content-layer/markdown/resolve/attribute-resolver-key.d.ts +8 -1
  150. package/dist/content-layer/markdown/resolve/attribute-resolver-key.js +1 -1
  151. package/dist/content-layer/markdown/resolve/audience-tag.d.ts +2 -6
  152. package/dist/content-layer/markdown/resolve/audience-tag.js +1 -1
  153. package/dist/content-layer/markdown/resolve/markdoc-resolvers/code-snippet.js +5 -4
  154. package/dist/content-layer/markdown/resolve/markdoc-resolvers/code-walkthrough/filesets.js +1 -1
  155. package/dist/content-layer/markdown/resolve/markdoc-resolvers/diagram-file.js +1 -1
  156. package/dist/content-layer/markdown/resolve/markdoc-resolvers/file-reference.js +1 -1
  157. package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.d.ts +2 -1
  158. package/dist/content-layer/markdown/resolve/markdoc-resolvers/json-schema.js +1 -1
  159. package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.d.ts +1 -1
  160. package/dist/content-layer/markdown/resolve/markdoc-resolvers/operation-samples.js +1 -1
  161. package/dist/content-layer/markdown/resolve/markdoc-resolvers/partial.js +1 -1
  162. package/dist/content-layer/markdown/resolve/markdoc-resolvers/svg-content.js +1 -1
  163. package/dist/content-layer/markdown/resolve/markdoc.d.ts +2 -1
  164. package/dist/content-layer/markdown/resolve/markdoc.js +1 -1
  165. package/dist/content-layer/markdown/resolve/raw-partials.d.ts +2 -1
  166. package/dist/content-layer/markdown/resolve/raw-partials.js +1 -1
  167. package/dist/content-layer/markdown/resolve/references.d.ts +3 -1
  168. package/dist/content-layer/markdown/resolve/references.js +1 -1
  169. package/dist/content-layer/markdown/resolve/render-diagrams.d.ts +8 -1
  170. package/dist/content-layer/markdown/resolve/render-diagrams.js +1 -1
  171. package/dist/content-layer/markdown/search/to-sections.d.ts +8 -3
  172. package/dist/content-layer/markdown/search/to-sections.js +1 -1
  173. package/dist/content-layer/markdown/search/to-text.d.ts +4 -1
  174. package/dist/content-layer/markdown/search/to-text.js +5 -5
  175. package/dist/content-layer/markdown/server/render.d.ts +4 -2
  176. package/dist/content-layer/markdown/server/render.js +1 -1
  177. package/dist/content-layer/markdown/service.js +1 -1
  178. package/dist/content-layer/markdown/tags/html.d.ts +5 -2
  179. package/dist/content-layer/markdown/tags/html.js +1 -1
  180. package/dist/content-layer/markdown/tags/markdoc-error.d.ts +8 -0
  181. package/dist/content-layer/markdown/tags/markdoc-error.js +1 -1
  182. package/dist/content-layer/markdown/tags/openapi.d.ts +1 -1
  183. package/dist/content-layer/markdown/tags/openapi.js +1 -1
  184. package/dist/content-layer/markdown/tags/partial.d.ts +9 -3
  185. package/dist/content-layer/markdown/tags/partial.js +1 -1
  186. package/dist/content-layer/markdown/tags/variant.d.ts +6 -0
  187. package/dist/content-layer/markdown/tags/variant.js +1 -0
  188. package/dist/content-layer/markdown/types/service.d.ts +6 -0
  189. package/dist/content-layer/markdown/utils/collect-anchors.js +1 -1
  190. package/dist/content-layer/markdown/utils/collect-headings.d.ts +3 -1
  191. package/dist/content-layer/markdown/utils/collect-headings.js +1 -1
  192. package/dist/content-layer/markdown/utils/first-heading.js +1 -1
  193. package/dist/content-layer/markdown/utils/heading-slugger.d.ts +8 -0
  194. package/dist/content-layer/markdown/utils/heading-slugger.js +1 -1
  195. package/dist/content-layer/markdown/utils/node-source-range.d.ts +3 -3
  196. package/dist/content-layer/markdown/utils/node-source-range.js +1 -1
  197. package/dist/content-layer/markdown/utils/parse-cache.js +1 -1
  198. package/dist/content-layer/markdown/utils/reparse-example-fences.d.ts +4 -1
  199. package/dist/content-layer/markdown/utils/reparse-example-fences.js +1 -1
  200. package/dist/content-layer/markdown/utils/substitute-variables.js +1 -1
  201. package/dist/content-layer/markdown/utils/walk-markdoc-ast.d.ts +2 -2
  202. package/dist/content-layer/markdown/utils/walk-markdoc-ast.js +1 -1
  203. package/dist/content-layer/materialization/asset-reconcile.js +1 -1
  204. package/dist/content-layer/materialization/entity.js +1 -1
  205. package/dist/content-layer/materialization/materializer.js +1 -0
  206. package/dist/content-layer/materialization/static-files.js +1 -1
  207. package/dist/content-layer/plan-gates.d.ts +3 -2
  208. package/dist/content-layer/plan-gates.js +1 -1
  209. package/dist/content-layer/plugins/execute.js +1 -1
  210. package/dist/content-layer/plugins/index.js +1 -1
  211. package/dist/content-layer/plugins/internal/api-docs/client/event-handlers.js +1 -1
  212. package/dist/content-layer/plugins/internal/api-docs/client/rebase-item-links.js +1 -1
  213. package/dist/content-layer/plugins/internal/api-docs/client/template.js +12 -4
  214. package/dist/content-layer/plugins/internal/api-docs/index.js +1 -1
  215. package/dist/content-layer/plugins/internal/api-docs/server/build-definition.d.ts +28 -13
  216. package/dist/content-layer/plugins/internal/api-docs/server/build-definition.js +1 -1
  217. package/dist/content-layer/plugins/internal/api-docs/server/build-sidebar.js +1 -1
  218. package/dist/content-layer/plugins/internal/api-docs/server/declares-proto-service.d.ts +2 -0
  219. package/dist/content-layer/plugins/internal/api-docs/server/declares-proto-service.js +3 -0
  220. package/dist/content-layer/plugins/internal/api-docs/server/markdown-copy.d.ts +14 -0
  221. package/dist/content-layer/plugins/internal/api-docs/server/markdown-copy.js +23 -0
  222. package/dist/content-layer/plugins/internal/api-docs/server/markdown-decorator.d.ts +1 -4
  223. package/dist/content-layer/plugins/internal/api-docs/server/markdown-decorator.js +1 -1
  224. package/dist/content-layer/plugins/internal/api-docs/server/options.d.ts +4 -2
  225. package/dist/content-layer/plugins/internal/api-docs/server/options.js +1 -1
  226. package/dist/content-layer/plugins/internal/api-docs/server/search-documents.d.ts +1 -1
  227. package/dist/content-layer/plugins/internal/api-docs/server/search-documents.js +1 -1
  228. package/dist/content-layer/plugins/internal/api-docs/server/spec-download.js +1 -1
  229. package/dist/content-layer/plugins/internal/api-functions/index.js +1 -1
  230. package/dist/content-layer/plugins/internal/api-functions/server/access.js +1 -1
  231. package/dist/content-layer/plugins/internal/api-functions/server/api-function-telemetry.js +1 -0
  232. package/dist/content-layer/plugins/internal/api-functions/server/dispatch.js +1 -1
  233. package/dist/content-layer/plugins/internal/app-data/banner.js +1 -1
  234. package/dist/content-layer/plugins/internal/app-data/index.d.ts +1 -1
  235. package/dist/content-layer/plugins/internal/app-data/index.js +1 -1
  236. package/dist/content-layer/plugins/internal/app-data/logo.js +1 -1
  237. package/dist/content-layer/plugins/internal/app-data/products.d.ts +2 -0
  238. package/dist/content-layer/plugins/internal/app-data/products.js +1 -1
  239. package/dist/content-layer/plugins/internal/assets/index.js +1 -1
  240. package/dist/content-layer/plugins/internal/catalog-classic/client/catalog-filtering.js +1 -1
  241. package/dist/content-layer/plugins/internal/catalog-classic/client/use-catalog-classic.js +1 -1
  242. package/dist/content-layer/plugins/internal/catalog-classic/index.js +1 -1
  243. package/dist/content-layer/plugins/internal/catalog-classic/resolve-items.d.ts +1 -1
  244. package/dist/content-layer/plugins/internal/catalog-classic/resolve-items.js +1 -1
  245. package/dist/content-layer/plugins/internal/catalog-classic/sidebars.d.ts +1 -1
  246. package/dist/content-layer/plugins/internal/index.js +1 -1
  247. package/dist/content-layer/plugins/internal/l10n/index.js +1 -1
  248. package/dist/content-layer/plugins/internal/markdoc/client/template.js +1 -1
  249. package/dist/content-layer/plugins/internal/markdoc/index.js +1 -1
  250. package/dist/content-layer/plugins/internal/markdoc/server/shared.d.ts +1 -1
  251. package/dist/content-layer/plugins/internal/mcp/app-data.js +1 -1
  252. package/dist/content-layer/plugins/internal/mcp/constants.d.ts +20 -0
  253. package/dist/content-layer/plugins/internal/mcp/constants.js +1 -1
  254. package/dist/content-layer/plugins/internal/mcp/content-tools.d.ts +4 -1
  255. package/dist/content-layer/plugins/internal/mcp/content-tools.js +1 -1
  256. package/dist/content-layer/plugins/internal/mcp/ignored-routes.js +1 -1
  257. package/dist/content-layer/plugins/internal/mcp/index.js +1 -1
  258. package/dist/content-layer/plugins/internal/mcp/server/agent-card.js +1 -1
  259. package/dist/content-layer/plugins/internal/mcp/server/audit.js +1 -1
  260. package/dist/content-layer/plugins/internal/mcp/server/auth.js +1 -1
  261. package/dist/content-layer/plugins/internal/mcp/server/code-credentials.js +2 -2
  262. package/dist/content-layer/plugins/internal/mcp/server/codemode/capabilities.js +6 -6
  263. package/dist/content-layer/plugins/internal/mcp/server/codemode/constants.js +1 -1
  264. package/dist/content-layer/plugins/internal/mcp/server/codemode/discover.js +1 -1
  265. package/dist/content-layer/plugins/internal/mcp/server/codemode/execute-schema.js +1 -1
  266. package/dist/content-layer/plugins/internal/mcp/server/codemode/index.js +1 -1
  267. package/dist/content-layer/plugins/internal/mcp/server/codemode/prompts.js +8 -8
  268. package/dist/content-layer/plugins/internal/mcp/server/config-gate.js +1 -1
  269. package/dist/content-layer/plugins/internal/mcp/server/custom-tools.js +1 -1
  270. package/dist/content-layer/plugins/internal/mcp/server/gateway/allowed-http-methods.js +1 -1
  271. package/dist/content-layer/plugins/internal/mcp/server/gateway/api-call-operations.js +1 -1
  272. package/dist/content-layer/plugins/internal/mcp/server/gateway/call-api.js +2 -0
  273. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-handler.js +1 -1
  274. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/form-page.js +10 -10
  275. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/outcome-pages.js +1 -1
  276. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials-page/site-branding.js +1 -1
  277. package/dist/content-layer/plugins/internal/mcp/server/gateway/credentials.js +1 -1
  278. package/dist/content-layer/plugins/internal/mcp/server/gateway/elicitation.js +6 -5
  279. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/allowed-hosts.js +1 -1
  280. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-bridge.js +1 -1
  281. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/fetch-errors.js +1 -1
  282. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/ssrf-guard.js +1 -1
  283. package/dist/content-layer/plugins/internal/mcp/server/gateway/fetch/upstream-detail.js +1 -1
  284. package/dist/content-layer/plugins/internal/mcp/server/gateway/index.js +3 -3
  285. package/dist/content-layer/plugins/internal/mcp/server/gateway/secret-store.js +1 -1
  286. package/dist/content-layer/plugins/internal/mcp/server/gateway/tool-list.js +1 -0
  287. package/dist/content-layer/plugins/internal/mcp/server/gateway/tools.js +4 -4
  288. package/dist/content-layer/plugins/internal/mcp/server/gateway/upstream-auth-scheme.js +2 -2
  289. package/dist/content-layer/plugins/internal/mcp/server/handler.js +1 -1
  290. package/dist/content-layer/plugins/internal/mcp/server/mcp-server.js +1 -1
  291. package/dist/content-layer/plugins/internal/mcp/server/mcp-telemetry.js +1 -1
  292. package/dist/content-layer/plugins/internal/mcp/server/oauth/authorize.js +1 -1
  293. package/dist/content-layer/plugins/internal/mcp/server/oauth/callback.js +1 -1
  294. package/dist/content-layer/plugins/internal/mcp/server/oauth/discovery.js +1 -1
  295. package/dist/content-layer/plugins/internal/mcp/server/oauth/error-reporting.js +1 -1
  296. package/dist/content-layer/plugins/internal/mcp/server/oauth/register.js +1 -1
  297. package/dist/content-layer/plugins/internal/mcp/server/oauth/token.js +1 -1
  298. package/dist/content-layer/plugins/internal/mcp/server/rate-limit.js +1 -1
  299. package/dist/content-layer/plugins/internal/mcp/server/server-card.js +1 -1
  300. package/dist/content-layer/plugins/internal/mcp/server/server-info.js +1 -1
  301. package/dist/content-layer/plugins/internal/mcp/server/skills-resources.js +1 -1
  302. package/dist/content-layer/plugins/internal/mcp/server/tools/graphql-catalog.js +1 -1
  303. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-catalog.js +1 -1
  304. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-document.js +1 -1
  305. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi-refs.js +1 -1
  306. package/dist/content-layer/plugins/internal/mcp/server/tools/openapi.js +1 -1
  307. package/dist/content-layer/plugins/internal/mcp/server/tools/pages-navigation.js +1 -1
  308. package/dist/content-layer/plugins/internal/mcp/server/tools/pages.js +2 -2
  309. package/dist/content-layer/plugins/internal/mcp/server/tools/schemas.js +1 -1
  310. package/dist/content-layer/plugins/internal/mcp/server/tools/search.js +2 -2
  311. package/dist/content-layer/plugins/internal/mcp/server/workflows/catalog.js +1 -0
  312. package/dist/content-layer/plugins/internal/mcp/server/workflows/document-resolver.js +1 -0
  313. package/dist/content-layer/plugins/internal/mcp/server/workflows/operations-subset.js +1 -0
  314. package/dist/content-layer/plugins/internal/mcp/server/workflows/resolve-workflows.js +1 -0
  315. package/dist/content-layer/plugins/internal/mcp/server/workflows/run-workflow.js +1 -0
  316. package/dist/content-layer/plugins/internal/mcp/server/workflows/schemas.js +1 -0
  317. package/dist/content-layer/plugins/internal/mcp/server/workflows/tools.js +1 -0
  318. package/dist/content-layer/plugins/internal/mcp/server/workflows/types.js +1 -0
  319. package/dist/content-layer/plugins/internal/mcp/server/workflows/workflow-references.js +1 -0
  320. package/dist/content-layer/plugins/internal/mcp/setup-page.js +1 -1
  321. package/dist/content-layer/plugins/internal/mock/server/handler.js +1 -1
  322. package/dist/content-layer/plugins/internal/react-page/index.d.ts +3 -2
  323. package/dist/content-layer/plugins/internal/react-page/index.js +1 -1
  324. package/dist/content-layer/plugins/internal/scorecard-classic/client/Grid.js +11 -11
  325. package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardViews.js +1 -1
  326. package/dist/content-layer/plugins/internal/scorecard-classic/client/ScorecardWidgets.js +7 -7
  327. package/dist/content-layer/plugins/internal/scorecard-classic/client/template.js +2 -2
  328. package/dist/content-layer/plugins/internal/scorecard-classic/index.js +1 -1
  329. package/dist/content-layer/plugins/internal/sidebar/bundle.d.ts +18 -17
  330. package/dist/content-layer/plugins/internal/sidebar/bundle.js +1 -1
  331. package/dist/content-layer/plugins/internal/sidebar/index.d.ts +5 -3
  332. package/dist/content-layer/plugins/internal/sidebar/index.js +2 -2
  333. package/dist/content-layer/plugins/internal/sidebar/subtree.js +1 -1
  334. package/dist/content-layer/plugins/internal/skills/index.js +1 -1
  335. package/dist/content-layer/plugins/internal/skills/server/routes.js +1 -1
  336. package/dist/content-layer/plugins/internal/versions/index.js +1 -1
  337. package/dist/content-layer/plugins/io.js +1 -1
  338. package/dist/content-layer/plugins/project/load.js +2 -2
  339. package/dist/content-layer/plugins/registry.js +1 -1
  340. package/dist/content-layer/plugins/request-context.d.ts +5 -0
  341. package/dist/content-layer/plugins/source-file.js +1 -1
  342. package/dist/content-layer/plugins/types/api-entity.d.ts +2 -6
  343. package/dist/content-layer/plugins/types/api-entity.js +1 -1
  344. package/dist/content-layer/plugins/types/markdoc.d.ts +2 -0
  345. package/dist/content-layer/plugins/types/plugin.d.ts +13 -0
  346. package/dist/content-layer/plugins/types/search.d.ts +14 -3
  347. package/dist/content-layer/plugins/utils/link-access.d.ts +2 -0
  348. package/dist/content-layer/plugins/utils/link-access.js +1 -1
  349. package/dist/content-layer/plugins/utils/route-index.d.ts +1 -1
  350. package/dist/content-layer/plugins/utils/route-index.js +1 -1
  351. package/dist/content-layer/plugins/utils/sidebar-label.d.ts +4 -1
  352. package/dist/content-layer/plugins/utils/sidebar-label.js +1 -1
  353. package/dist/content-layer/plugins/utils/version-path.js +1 -1
  354. package/dist/content-layer/plugins/work-time.js +1 -0
  355. package/dist/content-layer/problems/codes.d.ts +10 -0
  356. package/dist/content-layer/problems/codes.js +1 -1
  357. package/dist/content-layer/revisions/config.js +1 -1
  358. package/dist/content-layer/revisions/read.js +1 -1
  359. package/dist/content-layer/search/engine/core/content-parser.js +1 -1
  360. package/dist/content-layer/search/facet-rows.js +1 -1
  361. package/dist/content-layer/search/keywords.d.ts +18 -0
  362. package/dist/content-layer/search/keywords.js +1 -0
  363. package/dist/content-layer/search/postings/fragment-field.d.ts +2 -0
  364. package/dist/content-layer/search/postings/fragment-field.js +1 -1
  365. package/dist/content-layer/search/postings/postings-store.d.ts +14 -0
  366. package/dist/content-layer/search/postings/postings-store.js +1 -1
  367. package/dist/content-layer/search/store.d.ts +14 -1
  368. package/dist/content-layer/server/context.js +1 -1
  369. package/dist/content-layer/server/database.js +1 -1
  370. package/dist/content-layer/server/materialize.js +1 -1
  371. package/dist/content-layer/static/audience.js +1 -1
  372. package/dist/content-layer/static/registry.js +1 -1
  373. package/dist/content-layer/versions/group-info.d.ts +22 -0
  374. package/dist/content-layer/versions/group-info.js +1 -0
  375. package/dist/content-layer/versions/redirect.d.ts +24 -17
  376. package/dist/content-layer/versions/redirect.js +1 -1
  377. package/dist/content-layer/versions/resolve.d.ts +1 -21
  378. package/dist/content-layer/versions/resolve.js +1 -1
  379. package/dist/content-layer/versions/version-groups.d.ts +5 -1
  380. package/dist/content-layer/versions/version-groups.js +1 -1
  381. package/dist/plugin-api.d.ts +3 -0
  382. package/dist/plugin-api.js +1 -1
  383. package/dist/server/analytics-tags.js +1 -1
  384. package/dist/server/app.js +3 -3
  385. package/dist/server/ask-ai/feature-gate.js +1 -1
  386. package/dist/server/ask-ai/route.js +1 -1
  387. package/dist/server/auth/access-config.js +1 -1
  388. package/dist/server/auth/gate.js +1 -1
  389. package/dist/server/auth/middleware.js +1 -1
  390. package/dist/server/auth/oidc.js +1 -1
  391. package/dist/server/auth/request.js +1 -1
  392. package/dist/server/auth/routes.js +1 -1
  393. package/dist/server/auth/runtime.js +1 -1
  394. package/dist/server/content-assets/access.js +1 -1
  395. package/dist/server/content.js +15 -14
  396. package/dist/server/cors-proxy/handler.js +1 -1
  397. package/dist/server/feedback/route.js +1 -1
  398. package/dist/server/html-tags.js +2 -1
  399. package/dist/server/lambda-entry.js +1 -1
  400. package/dist/server/llms-txt.js +1 -1
  401. package/dist/server/manifest-assets.js +5 -5
  402. package/dist/server/metrics/request-metrics.js +1 -1
  403. package/dist/server/node-entry.js +1 -1
  404. package/dist/server/page-handlers.js +1 -1
  405. package/dist/server/plugin-context.js +1 -1
  406. package/dist/server/plugin-routes.js +1 -1
  407. package/dist/server/public-url.js +1 -0
  408. package/dist/server/rbac/content-asset-access.js +1 -1
  409. package/dist/server/redirects.js +1 -1
  410. package/dist/server/replay-oauth2/route.js +1 -1
  411. package/dist/server/review/route.js +1 -1
  412. package/dist/server/runtime-config.js +1 -1
  413. package/dist/server/search/cache.js +1 -0
  414. package/dist/server/search/route.js +1 -1
  415. package/dist/server/search/search-telemetry.js +1 -0
  416. package/dist/server/seo-tags.js +2 -2
  417. package/dist/server/sitemap.js +1 -1
  418. package/dist/server/ssrf/ssrf-blocklist.js +1 -1
  419. package/dist/server/static-files/serve.js +1 -1
  420. package/dist/server/subprocess/child-entry.js +1 -1
  421. package/dist/server/subprocess/runner.js +1 -1
  422. package/dist/server/telemetry/mock-server-events.js +1 -0
  423. package/dist/server/telemetry/redirect-event.js +1 -0
  424. package/dist/server/telemetry/route.js +1 -1
  425. package/dist/server/telemetry/sender.js +1 -1
  426. package/dist/server/telemetry/server-events.js +1 -1
  427. package/dist/server/template-ids.js +1 -1
  428. package/dist/server/wait-until.js +1 -0
  429. package/dist/shared/constants/api-spec-kinds.d.ts +7 -0
  430. package/dist/shared/constants/api-spec-kinds.js +1 -0
  431. package/dist/shared/constants/content-update.js +1 -1
  432. package/dist/shared/constants/dependency-pack.js +1 -1
  433. package/dist/shared/constants/dev-content-build.js +1 -0
  434. package/dist/shared/constants/dev-problems.js +1 -1
  435. package/dist/shared/constants/dev-source-sync.js +1 -1
  436. package/dist/shared/constants/l10n/langs/ar.js +1 -1
  437. package/dist/shared/constants/l10n/langs/de.js +1 -1
  438. package/dist/shared/constants/l10n/langs/en.js +1 -1
  439. package/dist/shared/constants/l10n/langs/es.js +1 -1
  440. package/dist/shared/constants/l10n/langs/fr.js +1 -1
  441. package/dist/shared/constants/l10n/langs/hi.js +1 -1
  442. package/dist/shared/constants/l10n/langs/it.js +1 -1
  443. package/dist/shared/constants/l10n/langs/ja.js +1 -1
  444. package/dist/shared/constants/l10n/langs/ko.js +1 -1
  445. package/dist/shared/constants/l10n/langs/pl.js +1 -1
  446. package/dist/shared/constants/l10n/langs/pt-br.js +1 -1
  447. package/dist/shared/constants/l10n/langs/pt.js +1 -1
  448. package/dist/shared/constants/l10n/langs/ru.js +1 -1
  449. package/dist/shared/constants/l10n/langs/uk.js +1 -1
  450. package/dist/shared/constants/l10n/langs/zh.js +1 -1
  451. package/dist/shared/constants/manifest-version.d.ts +3 -1
  452. package/dist/shared/constants/openapi-operation-methods.d.ts +2 -0
  453. package/dist/shared/constants/openapi-operation-methods.js +1 -0
  454. package/dist/shared/constants/review.d.ts +7 -0
  455. package/dist/shared/constants/review.js +1 -1
  456. package/dist/{server → shared}/constants/system-routes.d.ts +2 -2
  457. package/dist/shared/constants/system-routes.js +1 -0
  458. package/dist/shared/constants/versions.d.ts +2 -0
  459. package/dist/shared/constants/versions.js +1 -1
  460. package/dist/shared/experiments.js +1 -1
  461. package/dist/shared/load-dot-env.js +1 -1
  462. package/dist/shared/plan-gates.d.ts +9 -3
  463. package/dist/shared/plan-gates.js +1 -1
  464. package/dist/shared/products.js +1 -1
  465. package/dist/shared/project-env.d.ts +12 -0
  466. package/dist/shared/project-env.js +1 -0
  467. package/dist/shared/public-env.d.ts +9 -0
  468. package/dist/shared/public-env.js +1 -1
  469. package/dist/{server → shared}/rbac/api-docs.d.ts +3 -2
  470. package/dist/shared/rbac/api-docs.js +1 -0
  471. package/dist/{server → shared}/rbac/engine.d.ts +13 -10
  472. package/dist/shared/rbac/engine.js +0 -0
  473. package/dist/{server → shared}/rbac/filter.d.ts +2 -0
  474. package/dist/shared/rbac/filter.js +1 -0
  475. package/dist/{server → shared}/rbac/l10n-rules.d.ts +1 -1
  476. package/dist/shared/rbac/l10n-rules.js +1 -0
  477. package/dist/{server → shared}/rbac/route-scope.d.ts +1 -1
  478. package/dist/shared/rbac/route-scope.js +1 -0
  479. package/dist/{server → shared}/rbac/team-templates.d.ts +6 -2
  480. package/dist/shared/rbac/team-templates.js +1 -0
  481. package/dist/{server → shared}/rbac/teams.d.ts +1 -1
  482. package/dist/shared/rbac/types.js +1 -0
  483. package/dist/shared/search/facets.d.ts +5 -0
  484. package/dist/shared/search/facets.js +1 -1
  485. package/dist/shared/types/auth.d.ts +1 -0
  486. package/dist/shared/types/config.d.ts +5 -0
  487. package/dist/shared/types/search.d.ts +8 -2
  488. package/dist/shared/types/sidebar.d.ts +1 -0
  489. package/dist/shared/utils/redirect-match.js +1 -0
  490. package/dist/shared/utils/routes/file-path-to-route-slug.js +1 -1
  491. package/dist/shared/utils/routes/markdown-copy-url.js +1 -0
  492. package/drizzle/20261103061150_site_config_effective_hash/migration.sql +1 -0
  493. package/drizzle/20261105151816_search_http_path_tokens/migration.sql +1 -0
  494. package/drizzle/20261111152552_page_markdown_rbac_scope/migration.sql +1 -0
  495. package/package.json +37 -13
  496. package/dist/bundler/dev/__tests__/reset-content-update-state.js +0 -1
  497. package/dist/bundler/dev/materialization-sweeper.js +0 -1
  498. package/dist/client/dev-problems/sweep-segment.js +0 -1
  499. package/dist/client/review/use-bar-position.js +0 -1
  500. package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.d.ts +0 -5
  501. package/dist/content-layer/plugins/internal/api-docs/server/markdown-docs.js +0 -26
  502. package/dist/content-layer/plugins/internal/mcp/server/gateway/__tests__/fake-kv.js +0 -1
  503. package/dist/content-layer/server/config.js +0 -1
  504. package/dist/server/__tests__/rbac-fixture.js +0 -1
  505. package/dist/server/__tests__/test-session.js +0 -1
  506. package/dist/server/constants/system-routes.js +0 -1
  507. package/dist/server/rbac/api-docs.js +0 -1
  508. package/dist/server/rbac/engine.js +0 -0
  509. package/dist/server/rbac/filter.js +0 -1
  510. package/dist/server/rbac/l10n-rules.js +0 -1
  511. package/dist/server/rbac/route-scope.js +0 -1
  512. package/dist/server/rbac/team-templates.js +0 -1
  513. package/dist/server/rbac/types.js +0 -1
  514. package/dist/shared/utils/routes/markdown-path.js +0 -1
  515. /package/dist/{server → shared}/rbac/entity-scope.js +0 -0
  516. /package/dist/{server → shared}/rbac/teams.js +0 -0
  517. /package/dist/{server → shared}/rbac/types.d.ts +0 -0
  518. /package/dist/{content-layer/markdown → shared}/utils/packed-ast.d.ts +0 -0
  519. /package/dist/{content-layer/markdown → shared}/utils/packed-ast.js +0 -0
@@ -1 +1 @@
1
- import{SUBMIT_FEEDBACK_TOOL_NAME as e}from"../../constants.js";import{toolNameForMode as t}from"../codemode/tool-declarations.js";import{GRAPHQL_LIST_SCOPES as n,GRAPHQL_TYPE_KINDS as r}from"./graphql-constants.js";import{OPERATION_METHODS as i}from"./openapi-document.js";import{MAX_PAGE_LINES as a}from"./pages-constants.js";const o={type:`string`,nullable:!0},s={limit:{type:`number`},total:{type:`number`},page:{type:`number`},totalPages:{type:`number`}},c={codemodeType:`OpenApiServer[]`},l={codemodeType:`OpenApiSecurityRequirement[]`},u={codemodeType:`Record<string, OpenApiSecurityScheme>`},d={codemodeType:`OpenApiDocument`},f={codemodeType:`OpenApiOperation & { path: string; method: string }`},p={codemodeType:`OpenApiComponents`,description:"Components the endpoint references. A `$ref` in `endpoint` resolves against the root of the result."},m={filePath:{type:`string`,description:`API definition file path`},otherMatches:{type:`array`,description:"Other API definitions the lookup also matched. Present only when several matched; pass `filePath` to pick another one",items:{type:`object`,required:[`filePath`],properties:{version:{type:`string`},filePath:{type:`string`}}}}},h="When several definitions match the name, the highest version or the shortest file path is used and the rest are listed in `otherMatches`; tell the user which version or file the answer is based on.",g={readOnlyHint:!0,destructiveHint:!1,openWorldHint:!1};function _(e,t){let n={query:{type:`string`,description:`What to find, as a few words or a short question.`,minLength:1}};return e.length>0&&(n.product={type:`string`,description:`Optional product name to filter search results by specific product.`,enum:[...e,null],nullable:!0}),t.length>0&&(n.locale={type:`string`,description:`Optional locale code to filter search results by documentation language (e.g. 'en', 'ja'). Use the locale matching the language of the user's request. Defaults to the site's default locale.`,enum:[...t,null],nullable:!0}),{name:`search`,title:`Search documentation`,description:`Search the documentation. Returns Markdown text: one section per matching page, with its title and URL as a link.`,summary:`Search the documentation.`,schema:{type:`object`,required:[`query`],additionalProperties:!1,properties:n},annotations:g,outputSchema:{type:`string`}}}const v=_([],[]),y={name:`whoami`,title:`Who am I`,description:`Get information about the currently authenticated user`,summary:`Get the signed-in user.`,schema:{type:`object`,required:[],additionalProperties:!1,properties:{}},annotations:g,outputSchema:{type:`object`,required:[`authenticated`],properties:{authenticated:{type:`boolean`},email:{type:`string`},name:{type:`string`},subject:{type:`string`},clientId:{type:`string`},scope:{type:`string`},issuedAt:{type:`string`},expiresAt:{type:`string`}}}},b={name:e,title:`Submit feedback`,description:`Report a documentation page that is wrong or incomplete. Use it when the user reports a problem with a page on this site, or agrees to report a problem that you found. Do not use it for product bugs or support questions.`,schema:{type:`object`,required:[`path`,`summary`],additionalProperties:!1,properties:{path:{type:`string`,description:`Path or URL of the documentation page the feedback is about (e.g. /guides/auth)`,minLength:1,maxLength:1e3},summary:{type:`string`,description:`One sentence that names what is wrong with the page`,minLength:1,maxLength:500},details:{type:`string`,description:`Expected versus actual behavior, missing steps, or the snippet that failed`,maxLength:4e3,nullable:!0},targetFeature:{type:`string`,description:`The API or feature the page documents`,maxLength:500,nullable:!0}}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},outputSchema:{type:`object`,required:[`status`,`page`,`message`],properties:{status:{type:`string`},page:{type:`string`},message:{type:`string`}}}},x={type:`object`,additionalProperties:!1,required:[],properties:{filter:{type:`string`,description:`Matches part of an API name, or of a description when no name matches`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of APIs per page. Default is 300`,minimum:1,default:300,nullable:!0}}};function S(e){return{type:`string`,description:`API definition file path, as returned by \`${t(`list-apis`,e)}\``,nullable:!0}}function C(e){return{type:`object`,required:[],additionalProperties:!1,properties:{name:{type:`string`,description:"API name, or a unique part of it. Required when the project documents more than one API, unless `filePath` is given.",minLength:1,nullable:!0},version:{type:`string`,description:`API version. When omitted and several versions exist, the highest one is used`,nullable:!0},filePath:S(e)}}}function w(e){let{name:t,version:n,filePath:r}=C(e).properties;return{type:`object`,required:[`path`,`method`],additionalProperties:!1,properties:{name:t,path:{type:`string`,description:`Endpoint path (e.g. /api/v1/users)`,minLength:1},method:{type:`string`,description:`HTTP method (GET, POST, PUT, DELETE, etc.)`,enum:[...i.map(e=>e.toUpperCase()),...i],minLength:1},version:n,filePath:r}}}function T(e){let t={name:{type:`string`},description:{type:`string`},version:{type:`string`},servers:c,filePath:{type:`string`,description:`API definition file path`},ambiguousTitle:{type:`boolean`,description:"true = another API shares this title; a lookup picks the highest version, or the shortest file path at the same version, and lists the rest in `otherMatches`. Pass `filePath` to pick another one"}};return e&&(t.callable={type:`boolean`,description:"true = the documented hosts of this API are reachable via `fetch`; false = documentation only"}),{name:`list-apis`,title:`List APIs`,description:`Lists the APIs documented on this site`,summary:`List the available APIs.`,schema:x,annotations:g,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`,`description`,`version`,`servers`,`filePath`],properties:t}},...s}}}}const E=T(!1),D=T(!0);function O(e){return{name:`get-endpoints`,title:`Get endpoints`,description:`Get all endpoints for a specific API. ${h}`,summary:`Get all endpoints for an API.`,schema:C(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoints`],properties:{api:{type:`string`},version:{type:`string`},...m,servers:c,endpoints:{type:`array`,items:{type:`object`,required:[`path`,`method`],properties:{path:{type:`string`},method:{type:`string`},summary:o,description:o,security:l}}}}}}}const k=O(`tools`);function A(e){return{name:`get-endpoint-info`,title:`Get endpoint info`,description:`Get comprehensive information about specific endpoint including parameters, security, and examples. A \`$ref\` in \`endpoint\` points into the \`components\` key at the root of the result: read \`#/components/<section>/<name>\` there. ${h}`,summary:`Get the details of an endpoint.`,schema:w(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoint`,`globalSecurity`,`securitySchemes`],properties:{api:{type:`string`},version:{type:`string`},...m,servers:c,endpoint:f,globalSecurity:l,securitySchemes:u,components:p}}}}const j=A(`tools`);function M(e){return{name:`get-security-schemes`,title:`Get security schemes`,description:`Get the security schemes for a specific API. ${h}`,summary:`Get the security schemes for an API.`,schema:C(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`securitySchemes`,`security`],properties:{api:{type:`string`},version:{type:`string`},...m,securitySchemes:u,security:l}}}}const N=M(`tools`);function P(e){return{name:`get-full-api-description`,title:`Get full API description`,description:`Get the complete OpenAPI description. ${h}`,summary:`Get the complete OpenAPI description.`,schema:C(e),annotations:g,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`definition`],properties:{api:{type:`string`},version:{type:`string`},...m,definition:d}}}}const F=P(`tools`),I={type:`object`,required:[],additionalProperties:!1,properties:{filter:{type:`string`,description:`GraphQL schema name (or part of it)`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of results per page. Default is 300`,minimum:1,default:300,nullable:!0}}},L={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1},kind:{type:`string`,description:`Optional: return only a single category of schema members. With scope "fields", restricts to the fields of that parent category ("objects", "interfaces", or "inputs" only).`,enum:[...r,null],nullable:!0},scope:{type:`string`,description:'Optional: what each list item is. "members" (default) lists top-level types and operations. "fields" flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions — combine with `filter` to search nested fields anywhere in the schema.',enum:[...n,null],nullable:!0},filter:{type:`string`,description:`Optional: only members whose name or description contains this substring, case-insensitive (e.g. "custom tags")`,minLength:1,nullable:!0},referencesType:{type:`string`,description:`Optional: only members that reference this type directly or transitively (via return, field, argument, union-member or input-field types). Finds cross-cutting members that never name it — e.g. referencesType "Book" surfaces a search query returning a union that includes Book.`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of results per page. Default is 300`,minimum:1,default:300,nullable:!0}}},R={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1},type:{type:`string`,description:`Name of the type, operation, or directive`,minLength:1,nullable:!0},includeReferencedTypes:{type:`boolean`,description:`Also include the SDL of every type referenced transitively. Gives the whole subgraph at once, but can be large for highly-connected types.`,default:!1,nullable:!0}}},z={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1}}},B={name:`list-graphql-apis`,title:`List GraphQL APIs`,description:`Lists available GraphQL schemas with their context and purpose`,summary:`List the available GraphQL schemas.`,schema:I,annotations:g,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`],properties:{name:{type:`string`},description:o}}},...s}}},V={name:`get-graphql-type-list`,title:`Get GraphQL type list`,description:'List all operations and types in a GraphQL schema as a flat, paginated list. Each item is tagged with its kind (query, object, enum, …) and carries a one-line description; operations also include their return type and argument signature — use it to decide which members to fetch in detail. Narrow the result with `kind` (one category), `filter` (case-insensitive substring of the member name or description, e.g. "book"), or `referencesType` (only members that use a given type, directly or transitively) to explore a domain cheaply instead of pulling the full schema. To search nested fields — not just type names — set scope "fields": it flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions, so `filter` finds things like an input field whose docstring mentions your keyword.',summary:`List the operations and types in a GraphQL schema.`,schema:L,annotations:g,outputSchema:{type:`object`,required:[`name`,`items`,`limit`,`total`,`page`,`totalPages`],properties:{name:{type:`string`},items:{type:`array`,items:{type:`object`,required:[`kind`,`name`],properties:{kind:{type:`string`,enum:[...r]},name:{type:`string`},description:o,type:{type:`string`},args:{type:`string`},directives:{type:`string`}}}},...s}}};function H(e){return{name:`get-graphql-type`,title:`Get GraphQL type`,description:`Get the SDL for a single GraphQL type, operation (query/mutation/subscription field), or directive. Without includeReferencedTypes, the SDL is followed by a one-level manifest of every directly referenced type's field names (e.g. "input ActionOperationInput { addTags, removeTags }"), so you can see what nested types contain before fetching them. Set includeReferencedTypes to instead pull in the full SDL of every type it references transitively — the whole structural subgraph in one call, ideal for complete exploration of an entity (e.g. Book and all the types it touches). That traversal only follows what the target depends on; to go the other direction and find the members that use a type, call ${t(`get-graphql-type-list`,e)} with \`referencesType\`.`,summary:`Get the SDL of one GraphQL type or operation.`,schema:R,annotations:g,outputSchema:{type:`string`}}}const U=H(`tools`);function W(e){return{name:`get-graphql-schema`,title:`Get GraphQL schema`,description:`Get the complete GraphQL schema as SDL — the whole type graph in one call. Returns everything, so it can be very large and token-expensive for big schemas; prefer ${t(`get-graphql-type-list`,e)} (filter/paginate) plus targeted ${t(`get-graphql-type`,e)} calls, and reach for this only for small schemas or when you truly need the full SDL.`,summary:`Get the complete GraphQL schema.`,schema:z,annotations:g,outputSchema:{type:`string`}}}const G=W(`tools`);function K(e){return`Section id from ${t(`list-pages`,e)} (for example "products/ledger > Integration"), a section title, or a section URL`}function q(e){return{type:`object`,required:[`type`,`title`],properties:{type:{type:`string`,enum:[`page`,`section`]},id:{type:`string`,description:`Section id to pass to ${t(`list-pages`,e)} or ${t(`grep-pages`,e)}`},title:{type:`string`},url:{type:`string`},pageCount:{type:`number`,description:`Pages inside the section`}}}}function J(e){let t=q(e);return{name:`list-pages`,title:`List pages`,description:`Lists the docs navigation, one level per call`,summary:`List the docs navigation, one level per call.`,schema:{type:`object`,additionalProperties:!1,required:[],properties:{section:{type:`string`,nullable:!0,description:`${K(e)}. Omit it to list the top level`}}},annotations:g,outputSchema:{type:`object`,properties:{sections:{type:`array`,description:`Top level, when no section is given`,items:{type:`object`,required:[`id`,`title`,`items`],properties:{id:{type:`string`},title:{type:`string`},items:{type:`array`,items:t}}}},section:{type:`object`,properties:{id:{type:`string`},title:{type:`string`}}},items:{type:`array`,items:t}}}}}const Y=J(`tools`),X={name:`get-page`,title:`Get page`,description:`Reads a docs page as Markdown, in line windows`,summary:`Read a docs page as Markdown, in line windows.`,schema:{type:`object`,additionalProperties:!1,required:[`url`],properties:{url:{type:`string`,minLength:1,description:`Page URL or path, for example "/guides/auth"`},startLine:{type:`integer`,nullable:!0,minimum:1,description:`First line to return (default 1)`},lines:{type:`integer`,nullable:!0,minimum:1,maximum:a,description:`Number of lines to return (default 200)`}}},annotations:g,outputSchema:{type:`object`,required:[`url`,`title`,`totalLines`,`startLine`,`endLine`,`outline`,`content`],properties:{url:{type:`string`},title:{type:`string`},totalLines:{type:`number`},startLine:{type:`number`},endLine:{type:`number`},nextStartLine:{type:`number`,description:`Pass as startLine to read on; absent at the end`},outline:{type:`array`,description:`Headings (levels 1-3) with their line numbers`,items:{type:`object`,required:[`line`,`level`,`heading`],properties:{line:{type:`number`},level:{type:`number`},heading:{type:`string`}}}},content:{type:`string`}}}};function Z(e){return{name:`grep-pages`,title:`Grep pages`,description:`Finds the docs lines that contain a text`,summary:`Find the docs lines that contain a text.`,schema:{type:`object`,additionalProperties:!1,required:[`query`],properties:{query:{type:`string`,minLength:1,description:`Text to find, case-insensitive. Not a regular expression`},section:{type:`string`,nullable:!0,description:`${K(e)}. Omit it to search every page`},maxMatches:{type:`integer`,nullable:!0,minimum:1,maximum:100,description:`Maximum matching lines to return (default 20)`}}},annotations:g,outputSchema:{type:`object`,required:[`matches`,`searchedPages`,`truncated`],properties:{matches:{type:`array`,items:{type:`object`,required:[`url`,`title`,`line`,`text`],properties:{url:{type:`string`},title:{type:`string`},line:{type:`number`},text:{type:`string`}}}},searchedPages:{type:`number`,description:`Pages searched: every page you can read, or every page in the section`},truncated:{type:`boolean`,description:`true = more matches exist; narrow the query or the section`},note:{type:`string`,description:`Present when nothing matches: the docs you can read do not contain the text`}}}}}const Q=Z(`tools`);export{k as GET_ENDPOINTS_SCHEMA,j as GET_ENDPOINT_INFO_SCHEMA,F as GET_FULL_API_DESCRIPTION_SCHEMA,G as GET_GRAPHQL_SCHEMA_SCHEMA,V as GET_GRAPHQL_TYPE_LIST_SCHEMA,U as GET_GRAPHQL_TYPE_SCHEMA,X as GET_PAGE_SCHEMA,N as GET_SECURITY_SCHEMES_SCHEMA,Q as GREP_PAGES_SCHEMA,D as LIST_APIS_CALLABLE_SCHEMA,E as LIST_APIS_SCHEMA,B as LIST_GRAPHQL_APIS_SCHEMA,Y as LIST_PAGES_SCHEMA,g as READ_ONLY_ANNOTATIONS,v as SEARCH_SCHEMA,b as SUBMIT_FEEDBACK_SCHEMA,y as WHOAMI_SCHEMA,A as getEndpointInfoToolSchema,O as getEndpointsToolSchema,P as getFullApiDescriptionToolSchema,W as getGraphqlSchemaToolSchema,H as getGraphqlTypeToolSchema,M as getSecuritySchemesToolSchema,Z as grepPagesToolSchema,J as listPagesToolSchema,_ as searchSchema};
1
+ import{OPERATION_METHODS as e}from"../../../../../../shared/constants/openapi-operation-methods.js";import{READ_ONLY_ANNOTATIONS as t,SUBMIT_FEEDBACK_TOOL_NAME as n}from"../../constants.js";import{toolNameForMode as r}from"../codemode/tool-declarations.js";import{GRAPHQL_LIST_SCOPES as i,GRAPHQL_TYPE_KINDS as a}from"./graphql-constants.js";import{MAX_PAGE_LINES as o}from"./pages-constants.js";const s={type:`string`,nullable:!0},c={limit:{type:`number`},total:{type:`number`},page:{type:`number`},totalPages:{type:`number`}},l={codemodeType:`OpenApiServer[]`},u={codemodeType:`OpenApiSecurityRequirement[]`},d={codemodeType:`Record<string, OpenApiSecurityScheme>`},f={codemodeType:`OpenApiDocument`},p={codemodeType:`OpenApiOperation & { path: string; method: string }`},m={codemodeType:`OpenApiComponents`,description:"Components the endpoint references. A `$ref` in `endpoint` resolves against the root of the result."},h={filePath:{type:`string`,description:`API definition file path`},otherMatches:{type:`array`,description:"Other API definitions the lookup also matched. Present only when several matched; pass `filePath` to pick another one",items:{type:`object`,required:[`filePath`],properties:{version:{type:`string`},filePath:{type:`string`}}}}},g="When several definitions match the name, the highest version or the shortest file path is used and the rest are listed in `otherMatches`; tell the user which version or file the answer is based on.";function _(e,n){let r={query:{type:`string`,description:`What to find, as a few words or a short question.`,minLength:1}};return e.length>0&&(r.product={type:`string`,description:`Optional product name to filter search results by specific product.`,enum:[...e,null],nullable:!0}),n.length>0&&(r.locale={type:`string`,description:`Optional locale code to filter search results by documentation language (e.g. 'en', 'ja'). Use the locale matching the language of the user's request. Defaults to the site's default locale.`,enum:[...n,null],nullable:!0}),{name:`search`,title:`Search documentation`,description:`Search the documentation. Returns Markdown text: one section per matching page, with its title and URL as a link.`,summary:`Search the documentation.`,schema:{type:`object`,required:[`query`],additionalProperties:!1,properties:r},annotations:t,outputSchema:{type:`string`}}}const v=_([],[]),y={name:`whoami`,title:`Who am I`,description:`Get information about the currently authenticated user`,summary:`Get the signed-in user.`,schema:{type:`object`,required:[],additionalProperties:!1,properties:{}},annotations:t,outputSchema:{type:`object`,required:[`authenticated`],properties:{authenticated:{type:`boolean`},email:{type:`string`},name:{type:`string`},subject:{type:`string`},clientId:{type:`string`},scope:{type:`string`},issuedAt:{type:`string`},expiresAt:{type:`string`}}}},b={name:n,title:`Submit feedback`,description:`Report a documentation page that is wrong or incomplete. Use it when the user reports a problem with a page on this site, or agrees to report a problem that you found. Do not use it for product bugs or support questions.`,schema:{type:`object`,required:[`path`,`summary`],additionalProperties:!1,properties:{path:{type:`string`,description:`Path or URL of the documentation page the feedback is about (e.g. /guides/auth)`,minLength:1,maxLength:1e3},summary:{type:`string`,description:`One sentence that names what is wrong with the page`,minLength:1,maxLength:500},details:{type:`string`,description:`Expected versus actual behavior, missing steps, or the snippet that failed`,maxLength:4e3,nullable:!0},targetFeature:{type:`string`,description:`The API or feature the page documents`,maxLength:500,nullable:!0}}},annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},outputSchema:{type:`object`,required:[`status`,`page`,`message`],properties:{status:{type:`string`},page:{type:`string`},message:{type:`string`}}}},x={type:`object`,additionalProperties:!1,required:[],properties:{filter:{type:`string`,description:`Matches part of an API name, or of a description when no name matches`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of APIs per page. Default is 300`,minimum:1,default:300,nullable:!0}}};function S(e){return{type:`string`,description:`API definition file path, as returned by \`${r(`list-apis`,e)}\``,nullable:!0}}function C(e){return{type:`object`,required:[],additionalProperties:!1,properties:{name:{type:`string`,description:"API name, or a unique part of it. Required when the project documents more than one API, unless `filePath` is given.",minLength:1,nullable:!0},version:{type:`string`,description:`API version. When omitted and several versions exist, the highest one is used`,nullable:!0},filePath:S(e)}}}function w(t){let{name:n,version:r,filePath:i}=C(t).properties;return{type:`object`,required:[`path`,`method`],additionalProperties:!1,properties:{name:n,path:{type:`string`,description:`Endpoint path (e.g. /api/v1/users)`,minLength:1},method:{type:`string`,description:`HTTP method (GET, POST, PUT, DELETE, etc.)`,enum:[...e.map(e=>e.toUpperCase()),...e],minLength:1},version:r,filePath:i}}}function T(e){let n={name:{type:`string`},description:{type:`string`},version:{type:`string`},servers:l,filePath:{type:`string`,description:`API definition file path`},ambiguousTitle:{type:`boolean`,description:"true = another API shares this title; a lookup picks the highest version, or the shortest file path at the same version, and lists the rest in `otherMatches`. Pass `filePath` to pick another one"}};return e&&(n.callable={type:`boolean`,description:"true = the documented hosts of this API are reachable via `fetch`; false = documentation only"}),{name:`list-apis`,title:`List APIs`,description:`Lists the APIs documented on this site`,summary:`List the available APIs.`,schema:x,annotations:t,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`,`description`,`version`,`servers`,`filePath`],properties:n}},...c}}}}const E=T(!1),D=T(!0);function O(e){return{name:`get-endpoints`,title:`Get endpoints`,description:`Get all endpoints for a specific API. ${g}`,summary:`Get all endpoints for an API.`,schema:C(e),annotations:t,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoints`],properties:{api:{type:`string`},version:{type:`string`},...h,servers:l,endpoints:{type:`array`,items:{type:`object`,required:[`path`,`method`],properties:{path:{type:`string`},method:{type:`string`},summary:s,description:s,security:u}}}}}}}const k=O(`tools`);function A(e){return{name:`get-endpoint-info`,title:`Get endpoint info`,description:`Get comprehensive information about specific endpoint including parameters, security, and examples. A \`$ref\` in \`endpoint\` points into the \`components\` key at the root of the result: read \`#/components/<section>/<name>\` there. ${g}`,summary:`Get the details of an endpoint.`,schema:w(e),annotations:t,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`servers`,`endpoint`,`globalSecurity`,`securitySchemes`],properties:{api:{type:`string`},version:{type:`string`},...h,servers:l,endpoint:p,globalSecurity:u,securitySchemes:d,components:m}}}}const j=A(`tools`);function M(e){return{name:`get-security-schemes`,title:`Get security schemes`,description:`Get the security schemes for a specific API. ${g}`,summary:`Get the security schemes for an API.`,schema:C(e),annotations:t,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`securitySchemes`,`security`],properties:{api:{type:`string`},version:{type:`string`},...h,securitySchemes:d,security:u}}}}const N=M(`tools`);function P(e){return{name:`get-full-api-description`,title:`Get full API description`,description:`Get the complete OpenAPI description. ${g}`,summary:`Get the complete OpenAPI description.`,schema:C(e),annotations:t,outputSchema:{type:`object`,required:[`api`,`version`,`filePath`,`definition`],properties:{api:{type:`string`},version:{type:`string`},...h,definition:f}}}}const F=P(`tools`),I={type:`object`,required:[],additionalProperties:!1,properties:{filter:{type:`string`,description:`GraphQL schema name (or part of it)`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of results per page. Default is 300`,minimum:1,default:300,nullable:!0}}},L={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1},kind:{type:`string`,description:`Optional: return only a single category of schema members. With scope "fields", restricts to the fields of that parent category ("objects", "interfaces", or "inputs" only).`,enum:[...a,null],nullable:!0},scope:{type:`string`,description:'Optional: what each list item is. "members" (default) lists top-level types and operations. "fields" flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions — combine with `filter` to search nested fields anywhere in the schema.',enum:[...i,null],nullable:!0},filter:{type:`string`,description:`Optional: only members whose name or description contains this substring, case-insensitive (e.g. "custom tags")`,minLength:1,nullable:!0},referencesType:{type:`string`,description:`Optional: only members that reference this type directly or transitively (via return, field, argument, union-member or input-field types). Finds cross-cutting members that never name it — e.g. referencesType "Book" surfaces a search query returning a union that includes Book.`,minLength:1,nullable:!0},page:{type:`number`,description:`Page number`,minimum:1,default:1,nullable:!0},limit:{type:`number`,description:`Number of results per page. Default is 300`,minimum:1,default:300,nullable:!0}}},R={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1},type:{type:`string`,description:`Name of the type, operation, or directive`,minLength:1,nullable:!0},includeReferencedTypes:{type:`boolean`,description:`Also include the SDL of every type referenced transitively. Gives the whole subgraph at once, but can be large for highly-connected types.`,default:!1,nullable:!0}}},z={type:`object`,required:[`name`],additionalProperties:!1,properties:{name:{type:`string`,description:`GraphQL schema name`,minLength:1}}},B={name:`list-graphql-apis`,title:`List GraphQL APIs`,description:`Lists available GraphQL schemas with their context and purpose`,summary:`List the available GraphQL schemas.`,schema:I,annotations:t,outputSchema:{type:`object`,required:[`items`,`limit`,`total`,`page`,`totalPages`],properties:{items:{type:`array`,items:{type:`object`,required:[`name`],properties:{name:{type:`string`},description:s}}},...c}}},V={name:`get-graphql-type-list`,title:`Get GraphQL type list`,description:'List all operations and types in a GraphQL schema as a flat, paginated list. Each item is tagged with its kind (query, object, enum, …) and carries a one-line description; operations also include their return type and argument signature — use it to decide which members to fetch in detail. Narrow the result with `kind` (one category), `filter` (case-insensitive substring of the member name or description, e.g. "book"), or `referencesType` (only members that use a given type, directly or transitively) to explore a domain cheaply instead of pulling the full schema. To search nested fields — not just type names — set scope "fields": it flattens every field of every object/interface/input type into "ParentType.fieldName" entries with their descriptions, so `filter` finds things like an input field whose docstring mentions your keyword.',summary:`List the operations and types in a GraphQL schema.`,schema:L,annotations:t,outputSchema:{type:`object`,required:[`name`,`items`,`limit`,`total`,`page`,`totalPages`],properties:{name:{type:`string`},items:{type:`array`,items:{type:`object`,required:[`kind`,`name`],properties:{kind:{type:`string`,enum:[...a]},name:{type:`string`},description:s,type:{type:`string`},args:{type:`string`},directives:{type:`string`}}}},...c}}};function H(e){return{name:`get-graphql-type`,title:`Get GraphQL type`,description:`Get the SDL for a single GraphQL type, operation (query/mutation/subscription field), or directive. Without includeReferencedTypes, the SDL is followed by a one-level manifest of every directly referenced type's field names (e.g. "input ActionOperationInput { addTags, removeTags }"), so you can see what nested types contain before fetching them. Set includeReferencedTypes to instead pull in the full SDL of every type it references transitively — the whole structural subgraph in one call, ideal for complete exploration of an entity (e.g. Book and all the types it touches). That traversal only follows what the target depends on; to go the other direction and find the members that use a type, call ${r(`get-graphql-type-list`,e)} with \`referencesType\`.`,summary:`Get the SDL of one GraphQL type or operation.`,schema:R,annotations:t,outputSchema:{type:`string`}}}const U=H(`tools`);function W(e){return{name:`get-graphql-schema`,title:`Get GraphQL schema`,description:`Get the complete GraphQL schema as SDL — the whole type graph in one call. Returns everything, so it can be very large and token-expensive for big schemas; prefer ${r(`get-graphql-type-list`,e)} (filter/paginate) plus targeted ${r(`get-graphql-type`,e)} calls, and reach for this only for small schemas or when you truly need the full SDL.`,summary:`Get the complete GraphQL schema.`,schema:z,annotations:t,outputSchema:{type:`string`}}}const G=W(`tools`);function K(e){return`Section id from ${r(`list-pages`,e)} (for example "products/ledger > Integration"), a section title, or a section URL`}function q(e){return{type:`object`,required:[`type`,`title`],properties:{type:{type:`string`,enum:[`page`,`section`]},id:{type:`string`,description:`Section id to pass to ${r(`list-pages`,e)} or ${r(`grep-pages`,e)}`},title:{type:`string`},url:{type:`string`},pageCount:{type:`number`,description:`Pages inside the section`}}}}function J(e){let n=q(e);return{name:`list-pages`,title:`List pages`,description:`Lists the docs navigation, one level per call`,summary:`List the docs navigation, one level per call.`,schema:{type:`object`,additionalProperties:!1,required:[],properties:{section:{type:`string`,nullable:!0,description:`${K(e)}. Omit it to list the top level`}}},annotations:t,outputSchema:{type:`object`,properties:{sections:{type:`array`,description:`Top level, when no section is given`,items:{type:`object`,required:[`id`,`title`,`items`],properties:{id:{type:`string`},title:{type:`string`},items:{type:`array`,items:n}}}},section:{type:`object`,properties:{id:{type:`string`},title:{type:`string`}}},items:{type:`array`,items:n}}}}}const Y=J(`tools`),X={name:`get-page`,title:`Get page`,description:`Reads a docs page as Markdown, in line windows`,summary:`Read a docs page as Markdown, in line windows.`,schema:{type:`object`,additionalProperties:!1,required:[`url`],properties:{url:{type:`string`,minLength:1,description:`Page URL or path, for example "/guides/auth"`},startLine:{type:`integer`,nullable:!0,minimum:1,description:`First line to return (default 1)`},lines:{type:`integer`,nullable:!0,minimum:1,maximum:o,description:`Number of lines to return (default 200)`}}},annotations:t,outputSchema:{type:`object`,required:[`url`,`title`,`totalLines`,`startLine`,`endLine`,`outline`,`content`],properties:{url:{type:`string`},title:{type:`string`},totalLines:{type:`number`},startLine:{type:`number`},endLine:{type:`number`},nextStartLine:{type:`number`,description:`Pass as startLine to read on; absent at the end`},outline:{type:`array`,description:`Headings (levels 1-3) with their line numbers`,items:{type:`object`,required:[`line`,`level`,`heading`],properties:{line:{type:`number`},level:{type:`number`},heading:{type:`string`}}}},content:{type:`string`}}}};function Z(e){return{name:`grep-pages`,title:`Grep pages`,description:`Finds the docs lines that contain a text`,summary:`Find the docs lines that contain a text.`,schema:{type:`object`,additionalProperties:!1,required:[`query`],properties:{query:{type:`string`,minLength:1,description:`Text to find, case-insensitive. Not a regular expression`},section:{type:`string`,nullable:!0,description:`${K(e)}. Omit it to search every page`},maxMatches:{type:`integer`,nullable:!0,minimum:1,maximum:100,description:`Maximum matching lines to return (default 20)`}}},annotations:t,outputSchema:{type:`object`,required:[`matches`,`searchedPages`,`truncated`],properties:{matches:{type:`array`,items:{type:`object`,required:[`url`,`title`,`line`,`text`],properties:{url:{type:`string`},title:{type:`string`},line:{type:`number`},text:{type:`string`}}}},searchedPages:{type:`number`,description:`Pages searched: every page you can read, or every page in the section`},truncated:{type:`boolean`,description:`true = more matches exist; narrow the query or the section`},note:{type:`string`,description:`Present when nothing matches: the docs you can read do not contain the text`}}}}}const Q=Z(`tools`);export{k as GET_ENDPOINTS_SCHEMA,j as GET_ENDPOINT_INFO_SCHEMA,F as GET_FULL_API_DESCRIPTION_SCHEMA,G as GET_GRAPHQL_SCHEMA_SCHEMA,V as GET_GRAPHQL_TYPE_LIST_SCHEMA,U as GET_GRAPHQL_TYPE_SCHEMA,X as GET_PAGE_SCHEMA,N as GET_SECURITY_SCHEMES_SCHEMA,Q as GREP_PAGES_SCHEMA,D as LIST_APIS_CALLABLE_SCHEMA,E as LIST_APIS_SCHEMA,B as LIST_GRAPHQL_APIS_SCHEMA,Y as LIST_PAGES_SCHEMA,v as SEARCH_SCHEMA,b as SUBMIT_FEEDBACK_SCHEMA,y as WHOAMI_SCHEMA,A as getEndpointInfoToolSchema,O as getEndpointsToolSchema,P as getFullApiDescriptionToolSchema,W as getGraphqlSchemaToolSchema,H as getGraphqlTypeToolSchema,M as getSecuritySchemesToolSchema,Z as grepPagesToolSchema,J as listPagesToolSchema,_ as searchSchema};
@@ -1,3 +1,3 @@
1
- import{normalizeL10nConfig as e}from"../../../../../../shared/utils/l10n.js";import{withPathPrefix as t}from"../../../../../../shared/path-prefix.js";import{readIgnoredRouteSlugs as n}from"../../ignored-routes.js";import{publicOrigin as r}from"../../../../utils/request-origin.js";import{resolveSemanticSearchUpstreamUrl as i}from"../../../../../../shared/ask-ai/upstream.js";import{SemanticSearchError as a,fetchSemanticSearchDocuments as o,filterSemanticSearchDocuments as s}from"../semantic-search.js";import{SEARCH_SCHEMA as c,searchSchema as l}from"./schemas.js";const u=`No results found.`;function d(e,n){let r=e=>{try{return new URL(t(e),n).toString()}catch{return e}};return e.map(e=>`### [${e.title}](${r(e.url)})\n\n${e.content}\n`).join(`
1
+ import{withPathPrefix as e}from"../../../../../../shared/path-prefix.js";import{normalizeL10nConfig as t}from"../../../../../../shared/utils/l10n.js";import{publicOrigin as n}from"../../../../utils/request-origin.js";import{resolveSemanticSearchUpstreamUrl as r}from"../../../../../../shared/ask-ai/upstream.js";import{SemanticSearchError as i,fetchSemanticSearchDocuments as a,filterSemanticSearchDocuments as o}from"../semantic-search.js";import{readIgnoredRouteSlugs as s}from"../../ignored-routes.js";import{SEARCH_SCHEMA as c,searchSchema as l}from"./schemas.js";const u=`No results found.`;function d(t,n){let r=t=>{try{return new URL(e(t),n).toString()}catch{return t}};return t.map(e=>`### [${e.title}](${r(e.url)})\n\n${e.content}\n`).join(`
2
2
 
3
- `).trim()}const f=[{schema:c,schemaFor:t=>l(Object.values(t.config.products??{}).map(e=>e.name),e(t.config.l10n).locales?.map(e=>e.code)??[]),isAvailable:()=>i()!==``,async execute(t,i){let{query:c,product:l,locale:f}=t??{},p;try{p=await o({query:c,product:l||void 0,locale:f||e(i.config.l10n).defaultLocale})}catch(e){throw e instanceof a?(i.logger?.warn(`MCP search: ${e.message} ${e.detail}`),Error(`The search service failed. Try the call again later.`)):e}let m=await n(i.entities),h=await s(p,async e=>!m.has(e)&&i.isSlugVisible(e)&&await i.hasRoute(e));return h.length===0?u:d(h,r(i.request))||u}}];export{f as searchTools};
3
+ `).trim()}const f=[{schema:c,schemaFor:e=>l(Object.values(e.config.products??{}).map(e=>e.name),t(e.config.l10n).locales?.map(e=>e.code)??[]),isAvailable:()=>r()!==``,async execute(e,r){let{query:c,product:l,locale:f}=e??{},p;try{p=await a({query:c,product:l||void 0,locale:f||t(r.config.l10n).defaultLocale})}catch(e){throw e instanceof i?(r.logger?.warn(`MCP search: ${e.message} ${e.detail}`),Error(`The search service failed. Try the call again later.`)):e}let m=await s(r.entities),h=await o(p,async e=>!m.has(e)&&r.isSlugVisible(e)&&await r.hasRoute(e));return h.length===0?u:d(h,n(r.request))||u}}];export{f as searchTools};
@@ -0,0 +1 @@
1
+ import{isPlanFeatureGranted as e}from"../../../../../../shared/plan-gates.js";import{compileContentGlob as t}from"../../../../utils/glob.js";import{SPEC_KIND_ARAZZO as n}from"../../../../../../shared/constants/api-spec-kinds.js";import{filterApiDocsByRbac as r}from"../../../../../../shared/rbac/api-docs.js";import{formatError as i}from"../tool-errors.js";import{isDefinitionHidden as a}from"../tools/openapi-document.js";import{callableApis as o,excludedOperations as s}from"../gateway/eligibility.js";import{getAllowedHttpMethods as c}from"../gateway/allowed-http-methods.js";import{apiCallOperationsOf as l}from"../gateway/api-call-operations.js";import{resolveArazzoFile as u,sourceDescriptionPath as d}from"./resolve-workflows.js";const f=/* @__PURE__ */ new WeakMap;function p(e){let t=f.get(e);if(t)return t;let n=h(e);return f.set(e,n),n}async function m(e){return(await p(e)).some(e=>e.runnable.size>0)}async function h(t){if(!e(t.config,`mcpWorkflows`))return[];let n=await o(t);if(n.length===0)return[];let r=(await Promise.all((await g(t)).map(e=>_(t,e)))).filter(e=>e!==null);if(r.length===0)return[];let i=new Set(r.flatMap(({relativePath:e,document:t})=>v(e,t))),a=n.filter(e=>i.has(e.relativePath)).map(e=>({relativePath:e.relativePath,definition:e.definition,servers:e.servers,operations:l(e.fullDefinition,e.definition,e.servers,s(t,e.relativePath))})),d=c(t.config.mcp);return r.map(({relativePath:e,document:t})=>u({filePath:e,document:t,apis:a,allowedHttpMethods:d}))}async function g(e){let n=t(e.config.mcp?.ignore??[]),r=t(e.config.mcp?.apiCalls?.excludeFiles??[]);return(await e.entities.list({type:`api`})).flatMap(({key:e,metadata:t})=>{let{specType:i,sourcePath:a}=t??{};return i!==`arazzo`||typeof a!=`string`||n(a)||r(a)?[]:[{entityKey:e,relativePath:a}]})}async function _(e,{entityKey:t,relativePath:o}){try{let i=r(await e.entities.load(t),n,e.request.teams,{warn:t=>e.logger?.warn(t)});return!i||a(i.info,`apiCalls`)?null:{relativePath:o,document:i}}catch(n){return e.logger?.warn(`MCP: skipping Arazzo entity "${t}": ${i(n)}`),null}}function v(e,t){return(t.sourceDescriptions??[]).flatMap(t=>d(e,t.url)??[])}export{m as hasRunnableWorkflows,p as loadWorkflowCatalog};
@@ -0,0 +1 @@
1
+ import{BaseResolver as e,ResolveError as t,Source as n}from"@redocly/openapi-core";var r=class extends e{documents=/* @__PURE__ */ new Map;constructor(e,t,n){super(),this.documents.set(e,t);for(let{name:r,url:i}of t.sourceDescriptions??[])n.has(r)&&this.documents.set(this.resolveExternalRef(e,i),n.get(r))}async resolveDocument(e,r){let i=this.resolveExternalRef(e,r);return this.documents.has(i)?{source:new n(i,``),parsed:structuredClone(this.documents.get(i))}:new t(/* @__PURE__ */ Error(`"${r}" is not a document of this project`))}};export{r as InMemoryDocumentResolver};
@@ -0,0 +1 @@
1
+ import{isObject as e}from"../../../../../../shared/utils/is-object.js";function t(t,o){let s={};for(let{operationKey:r,path:i}of o){let a=t.paths?.[i];if(!e(a))continue;let{parameters:o,servers:c}=a;s[i]={...s[i],...o!==void 0&&{parameters:o},...c!==void 0&&{servers:c},[r]:n(a[r])}}let c=t.components?.securitySchemes,l={...t,paths:s,components:c?{securitySchemes:c}:{}},u=[s,l.security,c],d=/* @__PURE__ */ new Set;for(;u.length>0;){let e=u.pop();for(let n of i(e)){let[e,i,o]=n;if(e!==`components`||!i||!o)continue;let s=`${i}/${o}`;if(d.has(s))continue;d.add(s);let c=a(t,i,o),f=i===`responses`?r(c):c;if(f===void 0)continue;let p=l.components;p[i]={...p[i],[o]:f},u.push(f)}}return l}function n(t){if(!e(t)||!e(t.responses))return t;let n=Object.entries(t.responses).map(([e,t])=>[e,r(t)]);return{...t,responses:Object.fromEntries(n)}}function r(t){if(!e(t)||!e(t.content))return t;let n=Object.entries(t.content).map(([t,n])=>{if(!e(n))return[t,n];let{schema:r,...i}=n;return[t,i]});return{...t,content:Object.fromEntries(n)}}function i(t){let n=[],r=[t],i=/* @__PURE__ */ new Set;for(;r.length>0;){let t=r.pop();if(typeof t==`object`&&t&&!i.has(t)){if(i.add(t),Array.isArray(t))r.push(...t);else if(e(t)){let e=t.$ref;typeof e==`string`&&e.startsWith(`#/`)&&n.push(e.slice(2).split(`/`).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`))),r.push(...Object.values(t))}}}return n}function a(t,n,r){let i=t.components,a=e(i)?i[n]:void 0;return e(a)?a[r]:void 0}export{t as definitionForOperations};
@@ -0,0 +1 @@
1
+ import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{OPERATION_METHODS as t}from"../../../../../../shared/constants/openapi-operation-methods.js";import{withoutTrailingSlashes as n}from"../tools/openapi-document.js";import{operationHttpMethod as r,pathTemplateKey as i}from"../gateway/route-pattern.js";import{findUnresolvedPlaceholders as a}from"../gateway/fetch/url-placeholders.js";import{SOURCE_REFERENCE as o,UnsupportedWorkflowError as s,failureActionsOf as c,localWorkflowId as l,referencedWorkflowIds as u,successActionsOf as d}from"./workflow-references.js";import{definitionForOperations as f}from"./operations-subset.js";import{stepKey as p}from"./types.js";import{posix as m}from"node:path";import{replaceServerVariables as h}from"@redocly/api-docs/lib/services/code-samples/server-variables.js";import{resolveRef as g}from"@redocly/api-docs/lib/utils/inline-openapi-refs.js";const _=/^\{\$sourceDescriptions\.([\w.-]+)\.url\}#(\/.+)$/,v=/^([\w-]+)\.(.+)$/,y=/^[a-z][a-z0-9+.-]*:/i,b=/^https?:\/\//i,x=/\$components\.(\w+)\.([\w.-]+)/g,S=/\b(?:match|search)\s*\(/,C=[`multipart/form-data`,`application/octet-stream`],w=new Set(t);function T(e){let{filePath:t,document:n}=e,r=E(e),i=new Map((n.workflows??[]).map(e=>[e.workflowId,e])),a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map;for(let t of i.values())try{if(R(t,n.components))throw new s(`it generates test data with $faker`);for(let n of t.steps??[]){let i=A(n,t,r,e);i&&a.set(p(t.workflowId,n.stepId),i)}for(let e of u(t,n.components))V(e,r)}catch(e){if(!(e instanceof s))throw e;o.set(t.workflowId,e.message)}H(i,o),G(i,n.components,o);let c=/* @__PURE__ */ new Map;for(let e of i.values())o.has(e.workflowId)||c.set(e.workflowId,{workflow:e,inputs:K(e,i),methods:q(e,i,n.components,a)});return{filePath:t,title:n.info?.title??m.basename(t),document:n,sources:D(n,r,[...a.values()]),operations:a,runnable:c,unsupported:o}}function E({filePath:e,document:t,apis:n}){let r=/* @__PURE__ */ new Map;for(let i of t.sourceDescriptions??[]){let t=k(e,i.url);if(t){if(i.type===`arazzo`&&t===e)r.set(i.name,{kind:`self`});else if(i.type===`openapi`&&!i[`x-serverUrl`]){let e=n.find(e=>e.relativePath===t);e&&r.set(i.name,{kind:`api`,api:e})}}}return r}function D(e,t,n){let r=/* @__PURE__ */ new Map;for(let{name:i,type:a}of e.sourceDescriptions??[]){let e=t.get(i);if(e?.kind!==`self`){if(e?.kind===`api`){let{definition:t,servers:a}=e.api,o=n.filter(e=>e.sourceName===i);r.set(i,{...f(t,o),servers:[...a]})}else r.set(i,O(a,i))}}return r}function O(e,t){let n={title:t,version:`0`};return e===`arazzo`?{arazzo:`1.0.1`,info:n,sourceDescriptions:[],workflows:[]}:{openapi:`3.1.0`,info:n,paths:{}}}function k(e,t){if(!(y.test(t)||t.startsWith(`/`)))return m.normalize(m.join(m.dirname(e),t))}function A(e,t,n,a){if(L(e,t,a.document.components),c(e,t,a.document.components).some(B))throw new s(`step "${e.stepId}" waits more than 5 seconds before a retry`);if(e.workflowId)return;let o=j(e,n);if(!o)throw new s(`step "${e.stepId}" calls no operation of a callable API`);let{sourceName:l,api:u,path:d,method:f,operation:p}=o,m=r(f),h=i(d),g=u.operations.find(e=>e.method===m&&i(e.path)===h);if(!g?.callable||!g.visible)throw new s(`step "${e.stepId}" calls ${m} ${d}, which agents cannot call`);if(!a.allowedHttpMethods.includes(m))throw new s(`step "${e.stepId}" sends ${m}, which this project does not allow`);let _=e.requestBody?.contentType??F(p,u.definition);if(e.requestBody&&_&&C.some(e=>_.includes(e)))throw new s(`step "${e.stepId}" sends ${_}, which workflows cannot send`);if(!I(u))throw new s(`step "${e.stepId}" calls an API without an absolute server URL`);return{sourceName:l,method:m,operationKey:f,path:d}}function j(e,t){if(e.operationPath)return M(e.operationPath,t);if(!e.operationId)return;let n=o.exec(e.operationId)??v.exec(e.operationId),r=n?[[n[1],t.get(n[1])]]:[...t],i=n?n[2]:e.operationId,a=r.flatMap(([e,t])=>t?.kind===`api`?N(e,t.api,i):[]);return a.length===1?a[0]:void 0}function M(e,t){let n=_.exec(e),r=n&&t.get(n[1]);if(!n||r?.kind!==`api`)return;let i=n[2].slice(1).split(`/`).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`));if(i.length!==3||i[0]!==`paths`)return;let[,a,o]=i,s=P(r.api,a,o);return s&&{sourceName:n[1],api:r.api,path:a,method:o,operation:s}}function N(t,n,r){return Object.entries(n.definition.paths??{}).flatMap(([i,a])=>Object.keys(e(a)?a:{}).flatMap(e=>{let a=P(n,i,e);return a?.operationId===r?[{sourceName:t,api:n,path:i,method:e,operation:a}]:[]}))}function P(t,n,r){if(!w.has(r.toLowerCase()))return;let i=t.definition.paths?.[n],a=e(i)?i[r]:void 0;return e(a)?a:void 0}function F(t,n){let r=t.requestBody,i=r&&`$ref`in r&&r.$ref?g(r.$ref,n):r,a=e(i)?i.content:void 0;return e(a)?Object.keys(a)[0]:void 0}function I(e){let[t]=e.servers;if(!t)return!1;let r=n(h(t));return b.test(r)&&a(r).length===0}function L(e,t,n){let r=[...d(e,t,n),...c(e,t,n)],i=[...e.successCriteria??[],...r.flatMap(e=>e.criteria??[])];for(let{type:t,condition:n}of i){let r=typeof t==`object`?t.type:t;if(r===`xpath`)throw new s(`step "${e.stepId}" checks an XPath criterion, which workflows cannot evaluate`);if(r===`regex`||r===`jsonpath`&&S.test(n))throw new s(`step "${e.stepId}" checks a regex, which workflows cannot evaluate safely`)}}function R(e,t){let n=JSON.stringify(e);return[n,...[...n.matchAll(x)].map(([,e=``,n=``])=>JSON.stringify(z(t,e,n))??``)].some(e=>e.includes(`$faker`))}function z(t,n,r){let i=t,a=e(i)?i[n]:void 0;return e(a)?a[r]:void 0}function B(e){return e.type===`retry`&&(e.retryAfter??0)>5}function V(e,t){let n=o.exec(e);if(n&&t.get(n[1])?.kind!==`self`)throw new s(`it uses workflow "${e}" of another file`)}function H(e,t){for(let n of e.values()){let r=U(n,e);r&&!t.has(n.workflowId)&&t.set(n.workflowId,`it calls itself through workflow "${r}"`)}}function U(e,t){for(let n of W(e)){let r=/* @__PURE__ */ new Set,i=[n];for(;i.length>0;){let a=i.pop();if(a===e.workflowId)return n;if(r.has(a))continue;r.add(a);let o=t.get(a);o&&i.push(...W(o))}}}function W(e){let t=(e.steps??[]).flatMap(e=>e.workflowId?[l(e.workflowId)]:[]);return[...(e.dependsOn??[]).map(l),...t]}function G(e,t,n){let r=!0;for(;r;){r=!1;for(let i of e.values()){if(n.has(i.workflowId))continue;let a=u(i,t).map(l).find(t=>!e.has(t)||n.has(t));a!==void 0&&(n.set(i.workflowId,`it uses workflow "${a}", which cannot run`),r=!0)}}}function K(e,t){let n={},r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=e=>{if(!i.has(e.workflowId)){i.add(e.workflowId);for(let[t,r]of Object.entries(e.inputs?.properties??{}))t in n||(n[t]=r);for(let t of e.inputs?.required??[])r.add(t);for(let n of e.dependsOn??[]){let e=t.get(l(n));e&&a(e)}}};return a(e),r.size>0?{type:`object`,properties:n,required:[...r]}:{type:`object`,properties:n}}function q(e,t,n,r){let i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=[e];for(;o.length>0;){let e=o.pop();if(!a.has(e.workflowId)){a.add(e.workflowId);for(let t of e.steps??[]){let n=r.get(p(e.workflowId,t.stepId))?.method;n&&i.add(n)}for(let r of u(e,n)){let e=t.get(l(r));e&&o.push(e)}}}return[...i].sort()}export{T as resolveArazzoFile,k as sourceDescriptionPath};
@@ -0,0 +1 @@
1
+ import{isObject as e}from"../../../../../../shared/utils/is-object.js";import{errorMessage as t}from"../../../../../../shared/utils/error-message.js";import{redactSecretsFromString as n}from"../gateway/fetch/redact.js";import{stepKey as r}from"./types.js";import{stripVTControlCharacters as i}from"node:util";const a=JSON.stringify({CONTENT_TYPE_CHECK:`warn`}),o=/* @__PURE__ */ new Set([101,103,204,205,304]),s=/* @__PURE__ */ new Set([`failed network request`,`unexpected error`]),c={info:()=>{},warn:()=>{},output:()=>{},error:()=>{},printNewLine:()=>{},printSeparator:()=>{},indent:e=>e},l={getFileBody:()=>Promise.reject(/* @__PURE__ */ Error(`workflows cannot send files`))};let u;async function d(n){let{file:r,workflowId:i}=n,o=b(n),s,d;try{let[{run:t},{createConfig:o},{InMemoryDocumentResolver:p}]=await Promise.all([import(`@redocly/respect-core`),import(`@redocly/openapi-core`),import(`./document-resolver.js`)]),[m]=await t({files:[`/${r.filePath}`],workflow:[i],input:JSON.stringify(n.inputs),fetch:f(n.fetch),externalRefResolver:new p(`/${r.filePath}`,r.document,r.sources),config:await(u??=o({})),logger:c,skipLint:!0,maxSteps:100,maxFetchTimeout:Math.max(n.deadline-Date.now(),1),severity:a,requestFileLoader:l,envVariables:{}});s=m?.executedWorkflows.find(e=>e.workflowId===i);let h=m?.ctx.$outputs?.[i];d=e(h)?h:{}}catch(e){return v(i,[],{workflowId:i,reason:t(e)},o)}if(!s)return v(i,[],{workflowId:i,reason:`the workflow did not run`},o);let m=p(s),y=m.map(({step:e,workflowId:t})=>h(r,e,t,i)),x=m.find(({step:e,isRetried:t})=>!t&&g(e));return x?v(i,y,_(x),o):{workflowId:i,status:`succeeded`,outputs:d,steps:y}}function f(e){return async(t,n)=>{let r=n?.body;if(r!=null&&typeof r!=`string`&&!(r instanceof URLSearchParams))throw Error(`workflows send only text request bodies`);let i=await e({url:t instanceof Request?t.url:String(t),method:n?.method??`GET`,headers:Object.fromEntries(new Headers(n?.headers)),...r!=null&&{body:String(r)}});return new Response(o.has(i.status)?null:i.bodyText,{status:i.status,statusText:i.statusText,headers:i.headers})}}function p(e,t=!1){let n=e.executedSteps,r=/* @__PURE__ */ new Map;return n.forEach((e,t)=>{m(e)&&r.set(e.stepId,t)}),n.flatMap((n,i)=>{if(!m(n))return[{step:n,workflowId:e.workflowId,isRetried:t||!!n.retriesLeft}];let a=r.get(n.stepId)!==i;return p(n,t||a)})}function m(e){return`type`in e&&e.type===`workflow`}function h(e,t,n,i){let a=e.operations.get(r(n,t.stepId)),o={stepId:t.stepId,ms:t.response?.time??0};n!==i&&(o.workflowId=n);let c=t.response?.requestUrl;if(a){let e=typeof c==`string`?new URL(c).pathname:a.path;o.request=`${a.method} ${e}`}t.response?.statusCode&&(o.status=t.response.statusCode);let l=t.checks.find(e=>!e.passed&&s.has(e.name));return l&&(o.error=y(l.message??l.name)),o}function g(e){return e.checks.find(e=>!e.passed&&e.severity===`error`)}function _({step:e,workflowId:t}){let n=g(e),r={workflowId:t,stepId:e.stepId,reason:n?.message?y(n.message):`${n?.name??`a check`} failed`};if(e.response?.statusCode){let{body:t}=e.response;r.response={status:e.response.statusCode,body:(typeof t==`string`?t:JSON.stringify(t)).slice(0,2048)}}return r}function v(e,t,n,r){return{workflowId:e,status:`failed`,steps:t,failure:x(n,r)}}function y(e){return i(e).trim()}function b({file:t,workflowId:n,inputs:r}){let i=t.runnable.get(n)?.inputs.properties??{};return Object.entries(i).flatMap(([t,n])=>{let i=r[t];return e(n)&&n.format===`password`&&typeof i==`string`?[i]:[]})}function x(e,t){if(t.length===0)return e;let r={...e,reason:n(e.reason,t)};return e.response&&(r.response={...e.response,body:n(e.response.body,t)}),r}export{d as runWorkflow};
@@ -0,0 +1 @@
1
+ import{GET_WORKFLOW_TOOL_NAME as e,LIST_WORKFLOWS_TOOL_NAME as t,READ_ONLY_ANNOTATIONS as n,RUN_WORKFLOW_TOOL_NAME as r}from"../../constants.js";const i={type:`string`,nullable:!0},a={workflowId:{type:`string`,description:"The `workflowId` from `listWorkflows`."},filePath:{...i,description:"The `filePath` from `listWorkflows`. Needed only when several files declare the workflow ID."}},o={workflowId:{type:`string`},filePath:{type:`string`,description:`The Arazzo description that declares the workflow.`},summary:i,description:i,writes:{type:`boolean`,description:`True when a step can change data. Confirm with the user before such a run.`},inputs:{type:`object`,description:"The JSON Schema of the `inputs` that `runWorkflow` takes."}},s={name:t,title:`List API workflows`,description:'Lists the workflows that `runWorkflow` can run. Each workflow is a ready-made multi-step API action that the docs authors wrote, such as "log in, then place an order". When a workflow matches the task, run it instead of chaining `fetch` calls: it already knows the order of the calls and how data passes between them.',summary:`List the multi-step API workflows you can run.`,annotations:n,schema:{type:`object`,required:[],additionalProperties:!1,properties:{filter:{...i,description:`Case-insensitive text to find in the workflow ID, summary, or description.`}}},outputSchema:{type:`object`,required:[`items`],properties:{items:{type:`array`,items:{type:`object`,required:[`workflowId`,`filePath`,`writes`,`inputs`],properties:o}}}}},c={name:e,title:`Get an API workflow`,description:"Gets one workflow from `listWorkflows`: its inputs, outputs, and the request or sub-workflow of each step. Use it to explain a workflow to the user before you run it. For a workflow that cannot run, the error says why.",summary:`Get the inputs, steps, and outputs of one workflow.`,annotations:n,schema:{type:`object`,required:[`workflowId`],additionalProperties:!1,properties:a},outputSchema:{type:`object`,required:[`workflowId`,`filePath`,`writes`,`inputs`,`outputs`,`steps`],properties:{...o,outputs:{type:`array`,items:{type:`string`},description:"The names of the `outputs` a successful run returns."},steps:{type:`array`,items:{type:`object`,required:[`stepId`],properties:{stepId:{type:`string`},description:i,request:{...i,description:"The method and the path, such as `POST /orders`."},workflowId:{...i,description:`The sub-workflow the step runs.`}}}}}}},l={name:r,title:`Run an API workflow`,description:'Runs one workflow from `listWorkflows` with its `inputs`, and returns its `outputs` and one `steps` entry per request. Each request goes through `fetch`: the same documented operations, hosts, stored credentials, and limits. A run that fails returns `status: "failed"` with the failed step and its response. The requests in `steps` already reached the API, so do not run a workflow that writes again without asking the user.',summary:`Run a multi-step API workflow with its inputs.`,annotations:{...n,openWorldHint:!0},schema:{type:`object`,required:[`workflowId`],additionalProperties:!1,properties:{...a,inputs:{type:`object`,nullable:!0,description:"The workflow inputs; their JSON Schema is `inputs` in `listWorkflows`."}}},outputSchema:{type:`object`,required:[`workflowId`,`status`,`steps`],properties:{workflowId:{type:`string`},status:{type:`string`,enum:[`succeeded`,`failed`]},outputs:{type:`object`,nullable:!0},steps:{type:`array`,items:{type:`object`,required:[`stepId`,`ms`],properties:{stepId:{type:`string`},workflowId:{...i,description:`Set for a step of a sub-workflow or a dependency.`},request:i,status:{type:`number`,nullable:!0},ms:{type:`number`},error:{...i,description:`Why the request did not reach the API.`}}}},failure:{type:`object`,nullable:!0,required:[`workflowId`,`reason`],properties:{workflowId:{type:`string`},stepId:i,reason:{type:`string`},response:{type:`object`,nullable:!0,required:[`status`,`body`],properties:{status:{type:`number`},body:{type:`string`}}}}}}}};export{c as GET_WORKFLOW_SCHEMA,s as LIST_WORKFLOWS_SCHEMA,l as RUN_WORKFLOW_SCHEMA};
@@ -0,0 +1 @@
1
+ import{formatCandidates as e}from"../tools/openapi-document.js";import{isSafeHttpMethod as t}from"../gateway/allowed-http-methods.js";import{stepKey as n}from"./types.js";import{hasRunnableWorkflows as r,loadWorkflowCatalog as i}from"./catalog.js";import{runWorkflow as a}from"./run-workflow.js";import{GET_WORKFLOW_SCHEMA as o,LIST_WORKFLOWS_SCHEMA as s,RUN_WORKFLOW_SCHEMA as c}from"./schemas.js";import{Ajv as l,AjvJsonSchemaValidator as u}from"@modelcontextprotocol/server/validators/ajv";const d=new u(new l({allErrors:!0,strict:!1,validateFormats:!1}));function f({methods:e}){return e.some(e=>!t(e))}function p({file:e,runnable:t}){let{workflowId:n,summary:r,description:i}=t.workflow;return{workflowId:n,filePath:e.filePath,summary:r,description:i,writes:f(t),inputs:t.inputs}}function m(e){return e.flatMap(e=>Array.from(e.runnable.values(),t=>({file:e,runnable:t})))}function h({workflowId:t,filePath:n},r){let i=n?r.filter(e=>e.filePath===n):r,a=i.flatMap(e=>{let n=e.runnable.get(t);return n?[{file:e,runnable:n}]:[]});if(a.length===1)return a[0];if(a.length>1)throw Error(`Workflow "${t}" is in several files: ${e(a.map(({file:e})=>`"${e.filePath}"`))}. Pass \`filePath\`.`);let o=i.find(e=>e.unsupported.has(t));if(o)throw Error(`Workflow "${t}" in ${o.filePath} cannot run: ${o.unsupported.get(t)}.`);let s=m(r).map(({runnable:e})=>`"${e.workflow.workflowId}"`);throw Error(`No workflow "${t}"`+(n?` in ${n}`:``)+(s.length>0?`. Available workflows: ${e(s)}.`:`.`))}const g={schema:s,isAvailable:r,async execute(e,t){let n=(e??{}).filter?.trim().toLowerCase(),r=m(await i(t)).map(p);return{items:n?r.filter(e=>[e.workflowId,e.summary,e.description].some(e=>e?.toLowerCase().includes(n))):r}}},_={schema:o,isAvailable:r,async execute(e,t){let r=h(e,await i(t)),{workflow:a}=r.runnable;return{...p(r),outputs:Object.keys(a.outputs??{}),steps:(a.steps??[]).map(e=>{let t=r.file.operations.get(n(a.workflowId,e.stepId));return{stepId:e.stepId,description:e.description,request:t&&`${t.method} ${t.path}`,workflowId:e.workflowId}})}}},v={schema:c,isAvailable:r,async execute(e,t,n){let r=e,{file:o,runnable:s}=h(r,await i(t)),c=r.inputs??{},l=d.getValidator(s.inputs)(c);if(!l.valid)throw Error(`The inputs of workflow "${r.workflowId}" are not valid: ${l.errorMessage}`);let u=n?.gatewayFetch;if(!u)throw Error("`runWorkflow` runs only inside an `execute` script.");return a({file:o,workflowId:r.workflowId,inputs:c,fetch:u,deadline:t.executeDeadline})}};function y(){return[g,_,v]}export{y as workflowTools};
@@ -0,0 +1 @@
1
+ function e(e,t){return`${e}/${t}`}export{e as stepKey};
@@ -0,0 +1 @@
1
+ import{isObject as e}from"../../../../../../shared/utils/is-object.js";var t=class extends Error{};const n=/^\$components\.(successActions|failureActions)\.([\w.-]+)$/,r=/^\$sourceDescriptions\.([\w-]+)\.(.+)$/;function i(e,t,n){return c(e.onSuccess??t.successActions??[],n,l)}function a(e,t,n){return c(e.onFailure??t.failureActions??[],n,u)}function o(e){return r.exec(e)?.[2]??e}function s(e,t){let n=[...e.dependsOn??[]];for(let r of e.steps??[]){r.workflowId&&n.push(r.workflowId);let o=[...i(r,e,t),...a(r,e,t)];for(let e of o)(e.type===`goto`||e.type===`retry`)&&e.workflowId&&n.push(e.workflowId)}return n}function c(e,n,r){return e.map(e=>{let i=e.reference;if(typeof i!=`string`)return e;let a=d(i,n);if(!r(a))throw new t(`action reference "${i}" names no component`);return a})}function l(t){return e(t)&&(t.type===`goto`||t.type===`end`)}function u(t){return e(t)&&(t.type===`goto`||t.type===`retry`||t.type===`end`)}function d(t,r){let i=n.exec(t);if(!i||!r)return;let[,a,o]=i,s=r[a];return e(s)?s[o]:void 0}export{r as SOURCE_REFERENCE,t as UnsupportedWorkflowError,a as failureActionsOf,o as localWorkflowId,s as referencedWorkflowIds,i as successActionsOf};
@@ -1 +1 @@
1
- import{MCP_ROUTE as e,MCP_SETUP_TEMPLATE_ID as t,PUBLIC_MCP_ROUTE as n}from"./constants.js";import{isMcpHidden as r,isPublicEndpointServedFromConfig as i}from"./server/config-gate.js";const a={title:`Connect to the MCP server`,rbac:{"*":`read`},excludeFromSearch:!0};function o(o){return r(o)?[]:[{routeId:`mcp-setup`,slug:e,template:t,metadata:a},...i(o)?[{routeId:`mcp-public-setup`,slug:n,template:t,metadata:a}]:[]]}export{o as buildMcpSetupPageRoutes};
1
+ import{isMcpHidden as e,isPublicEndpointServedFromConfig as t}from"./server/config-gate.js";import{MCP_ROUTE as n,MCP_SETUP_TEMPLATE_ID as r,PUBLIC_MCP_ROUTE as i}from"./constants.js";const a={title:`Connect to the MCP server`,rbac:{"*":`read`},excludeFromSearch:!0};function o(o){return e(o)?[]:[{routeId:`mcp-setup`,slug:n,template:r,metadata:a},...t(o)?[{routeId:`mcp-public-setup`,slug:i,template:r,metadata:a}]:[]]}export{o as buildMcpSetupPageRoutes};
@@ -1 +1 @@
1
- import{isObject as e}from"../../../../../shared/utils/is-object.js";import{filePathToRouteSlug as t}from"../../../../../shared/utils/routes/file-path-to-route-slug.js";import{mockPathPrefix as n}from"../../../types/api-entity.js";import{isPlanFeatureGranted as r}from"../../../../../shared/plan-gates.js";import{stripPathPrefix as i}from"../../../../../shared/path-prefix.js";import{notFoundResponse as a}from"../../../../../server/plugin-context.js";const o={"Cache-Control":`no-store`},s=/* @__PURE__ */ new Map;function c(t,n){let r=n.metadata?.mockServer;return{...t,...e(r)?r:{}}}function l(e,t){let{specType:r,routeSlug:i}=e.metadata??{};return r!==`openapi`||typeof i!=`string`||c(t,e).off===!0?null:n(i)}function u(e,t,n=void 0){let r=null,i=-1;for(let a of e){let e=l(a,n);e===null||e.length<=i||d(e,t)&&(r={api:a,path:t.slice(e.length)||`/`},i=e.length)}return r}function d(e,t){return t===e||t.startsWith(`${e}/`)}function f(e,t,{createMockServer:n}){let r=s.get(t.key);if(r&&r.dataHash===t.dataHash)return r.handler;let{strictExamples:i,errorIfForcedExampleNotFound:a}=c(e.config.mockServer,t),o=e.entities.load(t.key).then(e=>n(structuredClone(e),{strictExamples:i,errorIfForcedExampleNotFound:a}));return s.set(t.key,{dataHash:t.dataHash,handler:o}),o.catch(()=>s.delete(t.key)),o}async function p(e,r){let i=await e.entities.list({type:`api`}),a=i.filter(({metadata:e})=>e?.specType!==`openapi`||e.routeSlug!==void 0?!1:d(n(t(String(e.sourcePath))),r));return a.length===0?i:(await Promise.all(a.map(t=>e.entities.load(t.key))),e.entities.list({type:`api`}))}function m(e,t){let n=(e.req.header(`x-http-method-override`)??e.req.method).toUpperCase(),{search:r}=new URL(e.req.url),i;return{path:t,method:n,query:r===``?void 0:r,headers:Object.fromEntries(e.req.raw.headers),getBody:()=>i??=e.req.arrayBuffer().then(e=>e.byteLength>0?Buffer.from(e):void 0)}}function h(e){return(i(new URL(e.req.url).pathname)??``).slice(6)||`/`}async function g(e,t){if(!r(t.config,`mockServer`))return a();let n=h(e),i=u(await p(t,n),n,t.config.mockServer);if(!i||!t.isSlugVisible(String(i.api.metadata?.routeSlug)))return a();let s;try{s=await import(`@redocly/mock-server`)}catch{return new Response(`Mock server is not available on this host`,{status:501})}let c=await(await f(t,i.api,s))(m(e,i.path));return new Response(c.body?new Uint8Array(c.body):null,{status:c.statusCode,headers:{...c.headers,...o}})}export{u as matchMockApi,g as mock,m as toMockRequest};
1
+ import{isPlanFeatureGranted as e}from"../../../../../shared/plan-gates.js";import{stripPathPrefix as t}from"../../../../../shared/path-prefix.js";import{isObject as n}from"../../../../../shared/utils/is-object.js";import{toPublicVersionedSlug as r}from"../../../../../shared/constants/versions.js";import{parseContentVersion as i}from"../../../utils/version-path.js";import{notFoundResponse as a}from"../../../../../server/plugin-context.js";import{filePathToRouteSlug as o}from"../../../../../shared/utils/routes/file-path-to-route-slug.js";import"../../../../../shared/constants/api-spec-kinds.js";import{mockPathPrefix as s}from"../../../types/api-entity.js";import{MOCK_SERVER_HANDLER_ID as c,withMockServerEvent as l}from"../../../../../server/telemetry/mock-server-events.js";const u={"Cache-Control":`no-store`},d=/* @__PURE__ */ new Map;function f(e,t){let r=t.metadata?.mockServer;return{...e,...n(r)?r:{}}}function p(e,t){let{specType:n,routeSlug:r}=e.metadata??{};return n!==`openapi`||typeof r!=`string`||f(t,e).off===!0?null:s(r)}function m(e,t,n=void 0){let r=null,i=-1;for(let a of e){let e=p(a,n);e===null||e.length<=i||h(e,t)&&(r={api:a,path:t.slice(e.length)||`/`},i=e.length)}return r}function h(e,t){return t===e||t.startsWith(`${e}/`)}async function g(e,t,n){let a=null,o=-1;for(let c of t){let t=p(c,e.config.mockServer),l=i(String(c.metadata?.sourcePath));if(t===null||l===null)continue;let u=String(c.metadata?.routeSlug),d=s(r(u,l.versionGroup,l.version,!0));d===t||d.length<=o||!h(d,n)||(await e.versions.counterparts(u))?.group.defaultVersion===l.version&&(a={api:c,path:n.slice(d.length)||`/`},o=d.length)}return a}function _(e,t,{createMockServer:n}){let r=d.get(t.key);if(r&&r.dataHash===t.dataHash)return r.handler;let{strictExamples:i,errorIfForcedExampleNotFound:a}=f(e.config.mockServer,t),o=e.entities.load(t.key).then(e=>n(structuredClone(e),{strictExamples:i,errorIfForcedExampleNotFound:a}));return d.set(t.key,{dataHash:t.dataHash,handler:o}),o.catch(()=>d.delete(t.key)),o}async function v(e,t){let n=await e.entities.list({type:`api`}),a=n.filter(({metadata:e})=>{if(e?.specType!==`openapi`||e.routeSlug!==void 0)return!1;let n=String(e.sourcePath),a=o(n),c=i(n);return(c?[a,r(a,c.versionGroup,c.version,!0)]:[a]).some(e=>h(s(e),t))});return a.length===0?n:(await Promise.all(a.map(t=>e.entities.load(t.key))),e.entities.list({type:`api`}))}function y(e,t){let n=(e.req.header(`x-http-method-override`)??e.req.method).toUpperCase(),{search:r}=new URL(e.req.url),i;return{path:t,method:n,query:r===``?void 0:r,headers:Object.fromEntries(e.req.raw.headers),getBody:()=>i??=e.req.arrayBuffer().then(e=>e.byteLength>0?Buffer.from(e):void 0)}}function b(e){return(t(new URL(e.req.url).pathname)??``).slice(6)||`/`}async function x(t,n){if(!e(n.config,`mockServer`))return a();let r=b(t),i=await v(n,r),o=m(i,r,n.config.mockServer)??await g(n,i,r);if(!o||!n.isSlugVisible(String(o.api.metadata?.routeSlug)))return a();let s;try{s=await import(`@redocly/mock-server`)}catch{return new Response(`Mock server is not available on this host`,{status:501})}return l({handler:c,request:t.req.raw,logger:n.logger},async()=>{let e=await(await _(n,o.api,s))(y(t,o.path));return new Response(e.body?new Uint8Array(e.body):null,{status:e.statusCode,headers:{...e.headers,...u}})})}export{m as matchMockApi,x as mock,y as toMockRequest};
@@ -5,7 +5,8 @@ export declare const REACT_PAGE_SEARCH_LOADER_KEY = "search";
5
5
  /**
6
6
  * Gives each `.page.tsx` or `.page.ts` file a route whose `template` is a `source:` reference
7
7
  * to the file itself. Such a file is its own template, so it needs no template registration.
8
- * An `export const frontmatter = { ... }` literal becomes the route metadata, and its `slug`
9
- * (a string or a list) the explicit route slugs: one route for each.
8
+ * An `export const frontmatter = { ... }` literal becomes the route metadata, its `slug`
9
+ * (a string or a list) the explicit route slugs: one route for each, and its `seo.title` the
10
+ * label of a sidebar entry that names none.
10
11
  */
11
12
  export declare const reactPageContentPlugin: import("../../types/plugin.js").ContentPlugin;
@@ -1 +1 @@
1
- import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t}from"../../../loaders/define.js";import{createPluginScopedId as n}from"../../utils/scoped-id.js";import{SEARCH_GROUP_FACET_FIELD as r}from"../../../../shared/search/facets.js";import{configuredFacetFields as i,extractFacetsFromFrontmatter as a,invalidFacetValueProblems as o,searchCategoryOf as s}from"../../../search/facet-values.js";import{isObject as c}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as l}from"../../../../shared/utils/routes/normalize-route-slug.js";import{notInPlanProblem as u}from"../../../plan-gates.js";import{filePathToRouteSlug as d}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{isPlanFeatureGranted as f}from"../../../../shared/plan-gates.js";import{isInternalPagePath as p}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as m}from"../../utils/explicit-slugs.js";import{SOURCE_TEMPLATE_PREFIX as h}from"../../../../shared/constants/template-ids.js";import{readPageFrontmatter as g}from"./frontmatter.js";const _=[`.page.tsx`,`.page.ts`],v=`internal.react-page`,y=`search`,b=t(n(v,`search`),async e=>({value:e.args}),{searchable(e,t){if(t.route===void 0||t.route.metadata.excludeFromSearch===!0)return{docs:[]};let{category:n,isInvalid:c}=s(t.route.metadata),{facets:l,invalidFields:u}=a(t.route.metadata,i(t.config));return{docs:[{docKey:`page`,routeSlug:t.route.slug,title:e.title,text:e.text,groupKey:n??`Documentation`,facets:l}],problems:o([...u,...c?[r]:[]],t.route.originFilePath)}}});function x(e){if(e.excludeFromSearch===!0)return;let t=c(e.search)?e.search:{},n=c(e.seo)?e.seo:{},r=e=>typeof e==`string`?e.trim():``,i=r(t.title)||r(n.title)||r(e.title),a=r(t.description)||r(n.description)||r(e.description);if(i!==``||a!==``)return{title:i,text:[a,...Array.isArray(t.keywords)?t.keywords.filter(e=>typeof e==`string`):[]].filter(e=>e!==``).join(` `)}}const S=t(n(v,`seo`),async e=>{let{result:t,entityDeps:n,assetUsages:r}=await e.markdown.resolveImageReference(e.args.image,e.file.path);return t.kind===`assetRef`?{value:{image:t.url},entityDeps:n,assetUsages:r}:{value:{image:e.args.image},entityDeps:n}}),C=e({id:v,version:`1.11.0`,loaders:[S,b],content:{filter:{extensions:_},async extractFile(e,t){if(p(e.path))return{routes:[]};if(!f(t.config,`reactPages`))return{routes:[],problems:[u(`React pages`)]};let{frontmatter:n,error:r}=g(await t.io.readFile(e.path));r!==void 0&&t.logger.warn(`Ignoring the frontmatter export of a page component`,{path:e.path,error:r});let i=m(n?.slug),a=c(n?.seo)&&typeof n.seo.image==`string`?n.seo.image:void 0,o=n===null?void 0:x(n),s={};a!==void 0&&(s.seo=S.withArgs({filePath:e.path,image:a})),o!==void 0&&(s[y]=b.withArgs(o,{stableKey:`react-page:search:${e.path}`}));let _=Object.keys(s).length===0?void 0:s,v=`${h}${e.path}`;return{routes:i.length>0?i.map(e=>({routeId:`page`,slug:l(e),template:v,metadata:n??void 0,deps:_})):[{routeId:`page`,slugHint:d(e.path,w(e.path)),template:v,metadata:n??void 0,deps:_}]}}}});function w(e){return e.toLowerCase().endsWith(`.page.ts`)?`.page.ts`:`.page.tsx`}export{y as REACT_PAGE_SEARCH_LOADER_KEY,C as reactPageContentPlugin};
1
+ import{defineContentPlugin as e}from"../../define.js";import{createEntityLoader as t,createInlineEntity as n}from"../../../loaders/define.js";import{createPluginScopedId as r}from"../../utils/scoped-id.js";import{SEARCH_GROUP_FACET_FIELD as i}from"../../../../shared/search/facets.js";import{configuredFacetFields as a,extractFacetsFromFrontmatter as o,invalidFacetValueProblems as s,searchCategoryOf as c}from"../../../search/facet-values.js";import{isPlanFeatureGranted as l}from"../../../../shared/plan-gates.js";import{isObject as u}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as d}from"../../../../shared/utils/routes/normalize-route-slug.js";import{curationKeywordsOf as f}from"../../../search/keywords.js";import{SOURCE_TEMPLATE_PREFIX as p}from"../../../../shared/constants/template-ids.js";import{notInPlanProblem as m}from"../../../plan-gates.js";import{filePathToRouteSlug as h}from"../../../../shared/utils/routes/file-path-to-route-slug.js";import{isInternalPagePath as g}from"../../utils/internal-page-path.js";import{parseExplicitSlugs as _}from"../../utils/explicit-slugs.js";import{readPageFrontmatter as v}from"./frontmatter.js";const y=[`.page.tsx`,`.page.ts`],b=`internal.react-page`,x=`search`,S=t(r(b,`search`),async e=>({value:e.args}),{searchable(e,t){if(t.route===void 0||t.route.metadata.excludeFromSearch===!0)return{docs:[]};let{category:n,isInvalid:r}=c(t.route.metadata),{facets:l,invalidFields:u}=o(t.route.metadata,a(t.config)),d={docKey:`page`,routeSlug:t.route.slug,title:e.title,text:e.text,groupKey:n??`Documentation`,facets:l};return e.keywords!==void 0&&(d.keywords=e.keywords),{docs:[d],problems:s([...u,...r?[i]:[]],t.route.originFilePath)}}});function C(e){if(e.excludeFromSearch===!0)return;let t=u(e.search)?e.search:{},n=u(e.seo)?e.seo:{},r=e=>typeof e==`string`?e.trim():``,i=r(t.title)||r(n.title)||r(e.title),a=r(t.description)||r(n.description)||r(e.description);if(i===``&&a===``)return;let o={title:i,text:[a,...Array.isArray(t.keywords)?t.keywords.filter(e=>typeof e==`string`):[]].filter(e=>e!==``).join(` `)},s=f(t.keywords);return s!==void 0&&(o.keywords=s),o}const w=t(r(b,`seo`),async e=>{let{result:t,entityDeps:n,assetUsages:r}=await e.markdown.resolveImageReference(e.args.image,e.file.path);return t.kind===`assetRef`?{value:{image:t.url},entityDeps:n,assetUsages:r}:{value:{image:e.args.image},entityDeps:n}}),T=e({id:b,version:`1.13.0`,loaders:[w,S],content:{filter:{extensions:y},async extractFile(e,t){if(g(e.path))return{routes:[]};if(!l(t.config,`reactPages`))return{routes:[],problems:[m(`React pages`)]};let{frontmatter:r,error:i}=v(await t.io.readFile(e.path));i!==void 0&&t.logger.warn(`Ignoring the frontmatter export of a page component`,{path:e.path,error:i});let a=_(r?.slug),o=u(r?.seo)&&typeof r.seo.image==`string`?r.seo.image:void 0,s=r===null?void 0:C(r),c={};o!==void 0&&(c.seo=w.withArgs({filePath:e.path,image:o})),s!==void 0&&(c[x]=S.withArgs(s,{stableKey:`react-page:search:${e.path}`}));let f=Object.keys(c).length===0?void 0:c,y=`${p}${e.path}`,b=u(r?.seo)?r.seo.title:void 0,T=typeof b==`string`&&b.trim()!==``?n({label:b}):void 0;return{routes:a.length>0?a.map(e=>({routeId:`page`,slug:d(e),template:y,metadata:r??void 0,deps:f,sidebarSubtree:T})):[{routeId:`page`,slugHint:h(e.path,E(e.path)),template:y,metadata:r??void 0,deps:f,sidebarSubtree:T}]}}}});function E(e){return e.toLowerCase().endsWith(`.page.ts`)?`.page.ts`:`.page.tsx`}export{x as REACT_PAGE_SEARCH_LOADER_KEY,T as reactPageContentPlugin};
@@ -1,23 +1,23 @@
1
- import*as e from"react";import{jsx as t,jsxs as n}from"react/jsx-runtime";import r from"styled-components";import{Button as i}from"@redocly/theme/components/Button/Button";import{AddIcon as a}from"@redocly/theme/icons/AddIcon/AddIcon";import{SubtractIcon as o}from"@redocly/theme/icons/SubtractIcon/SubtractIcon";function s(r){let{columns:s,rows:y,rowKey:b,expanded:x}=r,[S,C]=e.useState(r.initialSort),[w,T]=e.useState(/* @__PURE__ */ new Set),E=e.useMemo(()=>{let e=s.find(e=>e.id===S?.id)?.sortValue;return!S||!e?y:[...y].sort((t,n)=>{let r=e(t),i=e(n),a=r<i?-1:+(r>i);return S.desc?-a:a})},[s,y,S]),D=e=>C(t=>t?.id===e.id?{id:e.id,desc:!t.desc}:{id:e.id,desc:e.sortDescFirst===!0}),O=e=>T(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),k=x?s.length+1:s.length,A=x?`50px repeat(${s.length}, 1fr)`:`25% repeat(${s.length-1}, 1fr)`;return/* @__PURE__ */ n(`div`,{role:`table`,children:[/* @__PURE__ */ n(c,{children:[r.groupHeaderTitle&&/* @__PURE__ */ n(l,{$columns:A,role:`row`,children:[/* @__PURE__ */ t(f,{$column:`1`,role:`columnheader`}),/* @__PURE__ */ t(f,{$column:`2 / ${k+1}`,role:`columnheader`,children:r.groupHeaderTitle})]}),/* @__PURE__ */ n(l,{$columns:A,role:`row`,children:[x&&/* @__PURE__ */ t(d,{role:`columnheader`}),s.map(e=>{let r=S?.id===e.id?S.desc?`desc`:`asc`:void 0;return/* @__PURE__ */ t(d,{role:`columnheader`,$sortable:e.sortValue!==void 0,"aria-sort":r===`asc`?`ascending`:r===`desc`?`descending`:void 0,children:e.sortValue?/* @__PURE__ */ n(p,{type:`button`,onClick:()=>D(e),children:[e.header,/* @__PURE__ */ t(m,{"aria-hidden":`true`,children:r===`desc`?`▾`:r===`asc`?`▴`:`⇕`})]}):e.header},e.id)})]})]}),/* @__PURE__ */ t(`div`,{role:`rowgroup`,children:E.length===0?/* @__PURE__ */ t(u,{$columns:A,role:`row`,children:/* @__PURE__ */ t(g,{role:`cell`,children:r.empty??`No results to show`})}):E.map(e=>{let r=b(e),c=w.has(r);return/* @__PURE__ */ n(u,{$columns:A,role:`row`,children:[x&&/* @__PURE__ */ t(h,{role:`cell`,children:/* @__PURE__ */ t(i,{variant:`text`,size:`medium`,"aria-expanded":c,"aria-label":c?`Collapse`:`Expand`,icon:t(c?o:a,{}),onClick:()=>O(r)})}),s.map(n=>/* @__PURE__ */ t(h,{role:`cell`,children:n.cell(e)},n.id)),c&&x&&/* @__PURE__ */ t(_,{children:/* @__PURE__ */ t(v,{children:x(e)})})]},r)})})]})}const c=r.div`
1
+ import*as e from"react";import t from"styled-components";import{Button as n}from"@redocly/theme/components/Button/Button";import{jsx as r,jsxs as i}from"react/jsx-runtime";import{AddIcon as a}from"@redocly/theme/icons/AddIcon/AddIcon";import{SubtractIcon as o}from"@redocly/theme/icons/SubtractIcon/SubtractIcon";function s(t){let{columns:s,rows:y,rowKey:b,expanded:x}=t,[S,C]=e.useState(t.initialSort),[w,T]=e.useState(/* @__PURE__ */ new Set),E=e.useMemo(()=>{let e=s.find(e=>e.id===S?.id)?.sortValue;return!S||!e?y:[...y].sort((t,n)=>{let r=e(t),i=e(n),a=r<i?-1:+(r>i);return S.desc?-a:a})},[s,y,S]),D=e=>C(t=>t?.id===e.id?{id:e.id,desc:!t.desc}:{id:e.id,desc:e.sortDescFirst===!0}),O=e=>T(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),k=x?s.length+1:s.length,A=x?`50px repeat(${s.length}, 1fr)`:`25% repeat(${s.length-1}, 1fr)`;return/* @__PURE__ */ i(`div`,{role:`table`,children:[/* @__PURE__ */ i(c,{children:[t.groupHeaderTitle&&/* @__PURE__ */ i(l,{$columns:A,role:`row`,children:[/* @__PURE__ */ r(f,{$column:`1`,role:`columnheader`}),/* @__PURE__ */ r(f,{$column:`2 / ${k+1}`,role:`columnheader`,children:t.groupHeaderTitle})]}),/* @__PURE__ */ i(l,{$columns:A,role:`row`,children:[x&&/* @__PURE__ */ r(d,{role:`columnheader`}),s.map(e=>{let t=S?.id===e.id?S.desc?`desc`:`asc`:void 0;return/* @__PURE__ */ r(d,{role:`columnheader`,$sortable:e.sortValue!==void 0,"aria-sort":t===`asc`?`ascending`:t===`desc`?`descending`:void 0,children:e.sortValue?/* @__PURE__ */ i(p,{type:`button`,onClick:()=>D(e),children:[e.header,/* @__PURE__ */ r(m,{"aria-hidden":`true`,children:t===`desc`?`▾`:t===`asc`?`▴`:`⇕`})]}):e.header},e.id)})]})]}),/* @__PURE__ */ r(`div`,{role:`rowgroup`,children:E.length===0?/* @__PURE__ */ r(u,{$columns:A,role:`row`,children:/* @__PURE__ */ r(g,{role:`cell`,children:t.empty??`No results to show`})}):E.map(e=>{let t=b(e),c=w.has(t);return/* @__PURE__ */ i(u,{$columns:A,role:`row`,children:[x&&/* @__PURE__ */ r(h,{role:`cell`,children:/* @__PURE__ */ r(n,{variant:`text`,size:`medium`,"aria-expanded":c,"aria-label":c?`Collapse`:`Expand`,icon:r(c?o:a,{}),onClick:()=>O(t)})}),s.map(t=>/* @__PURE__ */ r(h,{role:`cell`,children:t.cell(e)},t.id)),c&&x&&/* @__PURE__ */ r(_,{children:/* @__PURE__ */ r(v,{children:x(e)})})]},t)})})]})}const c=t.div`
2
2
  border: 1px solid var(--border-color-primary);
3
3
  min-width: 775px;
4
- `,l=r.div`
4
+ `,l=t.div`
5
5
  display: grid;
6
6
  grid-template-columns: ${e=>e.$columns};
7
7
  width: 100%;
8
- `,u=r(l)`
8
+ `,u=t(l)`
9
9
  min-width: 775px;
10
10
  border-bottom: 1px solid var(--border-color-primary);
11
11
  border-left: 1px solid var(--border-color-primary);
12
12
  border-right: 1px solid var(--border-color-primary);
13
13
  align-items: center;
14
- `,d=r.div`
14
+ `,d=t.div`
15
15
  padding: ${({$sortable:e})=>e?`0`:`5px 15px`};
16
16
  background-color: var(--bg-color-raised);
17
17
  font-weight: bold;
18
18
  color: var(--text-color-secondary);
19
19
  box-sizing: border-box;
20
- `,f=r(d)`
20
+ `,f=t(d)`
21
21
  grid-column: ${e=>e.$column};
22
22
  display: flex;
23
23
  justify-content: center;
@@ -27,7 +27,7 @@ import*as e from"react";import{jsx as t,jsxs as n}from"react/jsx-runtime";import
27
27
  &:nth-child(2) {
28
28
  border-bottom: 1px solid var(--border-color-primary);
29
29
  }
30
- `,p=r.button`
30
+ `,p=t.button`
31
31
  display: block;
32
32
  width: 100%;
33
33
  height: 100%;
@@ -40,20 +40,20 @@ import*as e from"react";import{jsx as t,jsxs as n}from"react/jsx-runtime";import
40
40
  color: inherit;
41
41
  text-align: inherit;
42
42
  cursor: pointer;
43
- `,m=r.span`
43
+ `,m=t.span`
44
44
  font-family: monospace;
45
- `,h=r.div`
45
+ `,h=t.div`
46
46
  padding: 5px 15px;
47
47
  text-align: left;
48
- `,g=r.div`
48
+ `,g=t.div`
49
49
  text-align: center;
50
50
  padding: 32px;
51
51
  grid-column: 1 / -1;
52
- `,_=r.div`
52
+ `,_=t.div`
53
53
  grid-column: 1 / -1;
54
54
  margin-bottom: 8px;
55
55
  padding: 0 15px;
56
- `,v=r.div`
56
+ `,v=t.div`
57
57
  background-color: var(--bg-color-secondary);
58
58
  border-radius: 4px;
59
59
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
@@ -1 +1 @@
1
- import{NON_CONFORMANT as e,apiPagePath as t}from"./contract.js";import{Grid as n}from"./Grid.js";import{LinkButton as r}from"./styles.js";import{ApiLevel as i,Instance as a,LevelIndicator as o,RuleStatus as s}from"./ScorecardWidgets.js";import{useApiScorecard as c}from"./use-scorecard.js";import*as l from"react";import{Fragment as u,jsx as d,jsxs as f}from"react/jsx-runtime";import{getScorecardColorVariable as p}from"@redocly/theme/core/utils";import{Link as m}from"@redocly/theme/components/Link/Link";function h(e,t){return`${e}/rules/${encodeURIComponent(t)}`}function g(e){return e?new Date(e).toLocaleDateString():`-`}function _(e){return e&&new Date(e).getTime()||0}function v(e){let{base:r,levelNames:a,hasPublishedAt:s,hasTeam:c,teamLabel:u}=e,f=l.useMemo(()=>{let e=[{id:`title`,header:`API`,sortValue:e=>e.title,cell:e=>/* @__PURE__ */ d(m,{to:t(r,e.link),children:e.title})}];return s&&e.push({id:`publishedAt`,header:`Published at`,sortValue:e=>_(e.publishedAt),cell:e=>g(e.publishedAt)}),c&&e.push({id:`team`,header:u,sortValue:e=>e.team??``,cell:e=>e.team}),e.push({id:`level`,header:`Level`,sortValue:e=>e.scorecard.scorecardLevelIdx,cell:e=>/* @__PURE__ */ d(i,{level:e.scorecard.scorecardLevel,colorVariable:p(e.scorecard.scorecardLevelIdx,a.length+1)})},...a.map(e=>({id:`level-${e}`,header:e,cell:t=>{let n=t.scorecard.levels[e];return n?/* @__PURE__ */ d(o,{uniqueErrors:n.uniqueErrors,uniqueWarnings:n.uniqueWarnings}):null}}))),e},[r,s,c,a,u]);return/* @__PURE__ */ d(n,{columns:f,rows:e.apis,rowKey:e=>e.link,initialSort:{id:`title`,desc:!1}})}function y(e){let{base:t}=e,r=l.useMemo(()=>[{id:`ruleId`,header:`Rules`,sortValue:e=>e.ruleId,cell:e=>/* @__PURE__ */ d(m,{to:h(t,e.ruleId),children:e.ruleId})},{id:`status`,header:`Status`,sortValue:e=>e.status,cell:e=>/* @__PURE__ */ d(s,{errors:e.errorApisCount,warnings:e.warningApisCount})},{id:`apis`,header:`Problem APIs`,sortValue:e=>e.apis.length,sortDescFirst:!0,cell:e=>e.apis.length},{id:`count`,header:`Problem count`,sortValue:e=>e.count,sortDescFirst:!0,cell:e=>e.count}],[t]);return/* @__PURE__ */ d(n,{columns:r,rows:e.rules,rowKey:e=>e.ruleId,initialSort:{id:`status`,desc:!0}})}function b(t){let{filters:i,levelNames:a,onSelectTeam:o,teamLabel:s,teamProperty:c}=t,u=l.useMemo(()=>[{id:`team`,header:`API ${s}`,sortValue:e=>e.team,cell:e=>/* @__PURE__ */ d(r,{onClick:()=>{o(),i.find(e=>e.property===c)?.selectOption(e.team)},children:e.team})},...[e,...a].map(e=>({id:`level-${e}`,header:e,sortValue:t=>t.apis[e]??0,cell:t=>t.apis[e]??0}))],[i,a,o,s,c]);return/* @__PURE__ */ d(n,{columns:u,rows:t.teams,rowKey:e=>e.team,initialSort:{id:`team`,desc:!1},groupHeaderTitle:`APIs by level`})}function x({level:e,problems:t}){let r=l.useMemo(()=>{let e=/* @__PURE__ */ new Map;for(let n of t){let t=e.get(n.ruleId);t?t.push(n):e.set(n.ruleId,[n])}return[...e].map(([e,t])=>({ruleId:e,problems:[...t.filter(e=>e.severity===`error`),...t.filter(e=>e.severity===`warn`)],errorsCount:t.filter(e=>e.severity===`error`).length,warningsCount:t.filter(e=>e.severity===`warn`).length}))},[t]),i=l.useMemo(()=>[{id:`ruleId`,header:`Rules`,sortValue:e=>e.ruleId,cell:e=>e.ruleId},{id:`status`,header:`Status`,cell:e=>/* @__PURE__ */ d(s,{errors:e.errorsCount,warnings:e.warningsCount})},{id:`count`,header:`Problem count`,sortValue:e=>e.problems.length,sortDescFirst:!0,cell:e=>e.problems.length}],[]);return/* @__PURE__ */ d(n,{columns:i,rows:r,rowKey:e=>e.ruleId,initialSort:{id:`ruleId`,desc:!1},expanded:e=>e.problems.map((e,t)=>/* @__PURE__ */ d(a,{problem:e},t)),empty:/* @__PURE__ */ f(u,{children:[`✅ This API is compliant with `,/* @__PURE__ */ d(`strong`,{children:e}),` level rules`]})})}function S(e){let{hasPublishedAt:t,hasTeam:r,teamLabel:i}=e,a=l.useMemo(()=>{let e=[{id:`title`,header:`API`,sortValue:e=>e.title,cell:e=>e.title}];return t&&e.push({id:`publishedAt`,header:`Published at`,sortValue:e=>_(e.publishedAt),cell:e=>g(e.publishedAt)}),r&&e.push({id:`team`,header:i,sortValue:e=>e.team??``,cell:e=>e.team||`Other`}),e.push({id:`count`,header:`Problem count`,sortValue:e=>e.count,sortDescFirst:!0,cell:e=>e.count}),e},[t,r,i]);return/* @__PURE__ */ d(n,{columns:a,rows:e.apis,rowKey:e=>e.link,initialSort:{id:`title`,desc:!1},expanded:t=>/* @__PURE__ */ d(C,{api:t,ruleId:e.ruleId})})}function C({api:e,ruleId:t}){let n=c(e.scorecard.relativePath);return n===void 0?/* @__PURE__ */ d(`div`,{children:`Loading…`}):(Object.values(n?.levels??{}).map(e=>e.problems.filter(e=>e.ruleId===t)).find(e=>e.length>0)??[]).map((e,t)=>/* @__PURE__ */ d(a,{problem:e},t))}export{v as ApiListView,x as ApiProblemsView,S as RuleApisView,y as RulesView,b as TeamsView,h as rulePagePath};
1
+ import{NON_CONFORMANT as e,apiPagePath as t}from"./contract.js";import{Grid as n}from"./Grid.js";import{LinkButton as r}from"./styles.js";import{ApiLevel as i,Instance as a,LevelIndicator as o,RuleStatus as s}from"./ScorecardWidgets.js";import{useApiScorecard as c}from"./use-scorecard.js";import*as l from"react";import{getScorecardColorVariable as u}from"@redocly/theme/core/utils";import{Fragment as d,jsx as f,jsxs as p}from"react/jsx-runtime";import{Link as m}from"@redocly/theme/components/Link/Link";function h(e,t){return`${e}/rules/${encodeURIComponent(t)}`}function g(e){return e?new Date(e).toLocaleDateString():`-`}function _(e){return e&&new Date(e).getTime()||0}function v(e){let{base:r,levelNames:a,hasPublishedAt:s,hasTeam:c,teamLabel:d}=e,p=l.useMemo(()=>{let e=[{id:`title`,header:`API`,sortValue:e=>e.title,cell:e=>/* @__PURE__ */ f(m,{to:t(r,e.link),children:e.title})}];return s&&e.push({id:`publishedAt`,header:`Published at`,sortValue:e=>_(e.publishedAt),cell:e=>g(e.publishedAt)}),c&&e.push({id:`team`,header:d,sortValue:e=>e.team??``,cell:e=>e.team}),e.push({id:`level`,header:`Level`,sortValue:e=>e.scorecard.scorecardLevelIdx,cell:e=>/* @__PURE__ */ f(i,{level:e.scorecard.scorecardLevel,colorVariable:u(e.scorecard.scorecardLevelIdx,a.length+1)})},...a.map(e=>({id:`level-${e}`,header:e,cell:t=>{let n=t.scorecard.levels[e];return n?/* @__PURE__ */ f(o,{uniqueErrors:n.uniqueErrors,uniqueWarnings:n.uniqueWarnings}):null}}))),e},[r,s,c,a,d]);return/* @__PURE__ */ f(n,{columns:p,rows:e.apis,rowKey:e=>e.link,initialSort:{id:`title`,desc:!1}})}function y(e){let{base:t}=e,r=l.useMemo(()=>[{id:`ruleId`,header:`Rules`,sortValue:e=>e.ruleId,cell:e=>/* @__PURE__ */ f(m,{to:h(t,e.ruleId),children:e.ruleId})},{id:`status`,header:`Status`,sortValue:e=>e.status,cell:e=>/* @__PURE__ */ f(s,{errors:e.errorApisCount,warnings:e.warningApisCount})},{id:`apis`,header:`Problem APIs`,sortValue:e=>e.apis.length,sortDescFirst:!0,cell:e=>e.apis.length},{id:`count`,header:`Problem count`,sortValue:e=>e.count,sortDescFirst:!0,cell:e=>e.count}],[t]);return/* @__PURE__ */ f(n,{columns:r,rows:e.rules,rowKey:e=>e.ruleId,initialSort:{id:`status`,desc:!0}})}function b(t){let{filters:i,levelNames:a,onSelectTeam:o,teamLabel:s,teamProperty:c}=t,u=l.useMemo(()=>[{id:`team`,header:`API ${s}`,sortValue:e=>e.team,cell:e=>/* @__PURE__ */ f(r,{onClick:()=>{o(),i.find(e=>e.property===c)?.selectOption(e.team)},children:e.team})},...[e,...a].map(e=>({id:`level-${e}`,header:e,sortValue:t=>t.apis[e]??0,cell:t=>t.apis[e]??0}))],[i,a,o,s,c]);return/* @__PURE__ */ f(n,{columns:u,rows:t.teams,rowKey:e=>e.team,initialSort:{id:`team`,desc:!1},groupHeaderTitle:`APIs by level`})}function x({level:e,problems:t}){let r=l.useMemo(()=>{let e=/* @__PURE__ */ new Map;for(let n of t){let t=e.get(n.ruleId);t?t.push(n):e.set(n.ruleId,[n])}return[...e].map(([e,t])=>({ruleId:e,problems:[...t.filter(e=>e.severity===`error`),...t.filter(e=>e.severity===`warn`)],errorsCount:t.filter(e=>e.severity===`error`).length,warningsCount:t.filter(e=>e.severity===`warn`).length}))},[t]),i=l.useMemo(()=>[{id:`ruleId`,header:`Rules`,sortValue:e=>e.ruleId,cell:e=>e.ruleId},{id:`status`,header:`Status`,cell:e=>/* @__PURE__ */ f(s,{errors:e.errorsCount,warnings:e.warningsCount})},{id:`count`,header:`Problem count`,sortValue:e=>e.problems.length,sortDescFirst:!0,cell:e=>e.problems.length}],[]);return/* @__PURE__ */ f(n,{columns:i,rows:r,rowKey:e=>e.ruleId,initialSort:{id:`ruleId`,desc:!1},expanded:e=>e.problems.map((e,t)=>/* @__PURE__ */ f(a,{problem:e},t)),empty:/* @__PURE__ */ p(d,{children:[`✅ This API is compliant with `,/* @__PURE__ */ f(`strong`,{children:e}),` level rules`]})})}function S(e){let{hasPublishedAt:t,hasTeam:r,teamLabel:i}=e,a=l.useMemo(()=>{let e=[{id:`title`,header:`API`,sortValue:e=>e.title,cell:e=>e.title}];return t&&e.push({id:`publishedAt`,header:`Published at`,sortValue:e=>_(e.publishedAt),cell:e=>g(e.publishedAt)}),r&&e.push({id:`team`,header:i,sortValue:e=>e.team??``,cell:e=>e.team||`Other`}),e.push({id:`count`,header:`Problem count`,sortValue:e=>e.count,sortDescFirst:!0,cell:e=>e.count}),e},[t,r,i]);return/* @__PURE__ */ f(n,{columns:a,rows:e.apis,rowKey:e=>e.link,initialSort:{id:`title`,desc:!1},expanded:t=>/* @__PURE__ */ f(C,{api:t,ruleId:e.ruleId})})}function C({api:e,ruleId:t}){let n=c(e.scorecard.relativePath);return n===void 0?/* @__PURE__ */ f(`div`,{children:`Loading…`}):(Object.values(n?.levels??{}).map(e=>e.problems.filter(e=>e.ruleId===t)).find(e=>e.length>0)??[]).map((e,t)=>/* @__PURE__ */ f(a,{problem:e},t))}export{v as ApiListView,x as ApiProblemsView,S as RuleApisView,y as RulesView,b as TeamsView,h as rulePagePath};
@@ -1,23 +1,23 @@
1
- import{CardRow as e,Code as t,ContentWithDotWrap as n,Dot as r,EmojiWrap as i,FilePreview as a,InstanceControlsWrap as o,InstanceReference as s,InstanceWrap as c,ScorecardCard as l,ScorecardCardTitle as u}from"./styles.js";import*as d from"react";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{getScorecardColorVariable as m}from"@redocly/theme/core/utils";import h from"styled-components";import{Button as g}from"@redocly/theme/components/Button/Button";import{AddIcon as _}from"@redocly/theme/icons/AddIcon/AddIcon";import{SubtractIcon as v}from"@redocly/theme/icons/SubtractIcon/SubtractIcon";import{CloseFilledIcon as y}from"@redocly/theme/icons/CloseFilledIcon/CloseFilledIcon";import{WarningAltFilled as b}from"@redocly/theme/icons/WarningAltFilled/WarningAltFilled";import{CheckboxFilledIcon as x}from"@redocly/theme/icons/CheckboxFilledIcon/CheckboxFilledIcon";const S={Error:`--scorecard-color-error`,Warn:`--scorecard-color-warning`,Pass:`--scorecard-color-success`};function C({level:e,colorVariable:t}){return/* @__PURE__ */ p(n,{children:[/* @__PURE__ */ f(r,{$colorVariable:t}),/* @__PURE__ */ f(`span`,{children:e})]})}function w({summary:e}){let t=Object.keys(e.levels).length;return/* @__PURE__ */ f(M,{chunks:Object.entries(e.levels).map(([n,r],i)=>({share:r/e.total*100,colorVariable:m(i,t),title:`${r} ${n}`}))})}function T({severity:e}){return/* @__PURE__ */ f(r,{$colorVariable:S[e]})}function E(e,t){return`--scorecard-color-${e>0?`error`:t>0?`warning`:`success`}`}function D({errors:e,warnings:t}){return/* @__PURE__ */ p(n,{children:[/* @__PURE__ */ f(r,{$colorVariable:E(e,t)}),/* @__PURE__ */ f(`span`,{children:e>0?`Problem`:t>0?`Warning`:`Normal`})]})}function O({errors:e,warnings:t}){return/* @__PURE__ */ f(r,{$colorVariable:E(e,t)})}function k(e){return e===`error`?`❌`:e===`warn`?`⚠️`:`ℹ️`}function A(e){return e===`error`?`red`:e===`warn`?`orange`:`blue`}function j({problem:e}){let[n,r]=d.useState(!1);return/* @__PURE__ */ p(o,{className:n?`expanded`:``,children:[/* @__PURE__ */ f(g,{variant:`text`,size:`medium`,"aria-label":n?`Hide the code`:`Show the code`,icon:f(n?v:_,{}),onClick:()=>r(e=>!e)}),/* @__PURE__ */ p(c,{$borderColor:A(e.severity),children:[/* @__PURE__ */ p(`div`,{children:[/* @__PURE__ */ f(i,{children:k(e.severity)}),` `,e.message]}),n?/* @__PURE__ */ p(a,{children:[/* @__PURE__ */ p(s,{children:[/* @__PURE__ */ f(`strong`,{children:e.location.source.absoluteRef}),e.location.pointer]}),/* @__PURE__ */ f(t,{children:e.codeframe})]}):null]})]})}function M({chunks:e}){let t=e.map(e=>e.title).filter(Boolean).join(`, `);return/* @__PURE__ */ f(P,{"data-component-name":`Scorecard/Gauge`,title:t,children:e.map((e,t)=>/* @__PURE__ */ f(F,{$share:e.share,$colorVariable:e.colorVariable},t))})}const N=h.span`
1
+ import{CardRow as e,Code as t,ContentWithDotWrap as n,Dot as r,EmojiWrap as i,FilePreview as a,InstanceControlsWrap as o,InstanceReference as s,InstanceWrap as c,ScorecardCard as l,ScorecardCardTitle as u}from"./styles.js";import*as d from"react";import f from"styled-components";import{Button as p}from"@redocly/theme/components/Button/Button";import{getScorecardColorVariable as m}from"@redocly/theme/core/utils";import{jsx as h,jsxs as g}from"react/jsx-runtime";import{AddIcon as _}from"@redocly/theme/icons/AddIcon/AddIcon";import{SubtractIcon as v}from"@redocly/theme/icons/SubtractIcon/SubtractIcon";import{CloseFilledIcon as y}from"@redocly/theme/icons/CloseFilledIcon/CloseFilledIcon";import{WarningAltFilled as b}from"@redocly/theme/icons/WarningAltFilled/WarningAltFilled";import{CheckboxFilledIcon as x}from"@redocly/theme/icons/CheckboxFilledIcon/CheckboxFilledIcon";const S={Error:`--scorecard-color-error`,Warn:`--scorecard-color-warning`,Pass:`--scorecard-color-success`};function C({level:e,colorVariable:t}){return/* @__PURE__ */ g(n,{children:[/* @__PURE__ */ h(r,{$colorVariable:t}),/* @__PURE__ */ h(`span`,{children:e})]})}function w({summary:e}){let t=Object.keys(e.levels).length;return/* @__PURE__ */ h(M,{chunks:Object.entries(e.levels).map(([n,r],i)=>({share:r/e.total*100,colorVariable:m(i,t),title:`${r} ${n}`}))})}function T({severity:e}){return/* @__PURE__ */ h(r,{$colorVariable:S[e]})}function E(e,t){return`--scorecard-color-${e>0?`error`:t>0?`warning`:`success`}`}function D({errors:e,warnings:t}){return/* @__PURE__ */ g(n,{children:[/* @__PURE__ */ h(r,{$colorVariable:E(e,t)}),/* @__PURE__ */ h(`span`,{children:e>0?`Problem`:t>0?`Warning`:`Normal`})]})}function O({errors:e,warnings:t}){return/* @__PURE__ */ h(r,{$colorVariable:E(e,t)})}function k(e){return e===`error`?`❌`:e===`warn`?`⚠️`:`ℹ️`}function A(e){return e===`error`?`red`:e===`warn`?`orange`:`blue`}function j({problem:e}){let[n,r]=d.useState(!1);return/* @__PURE__ */ g(o,{className:n?`expanded`:``,children:[/* @__PURE__ */ h(p,{variant:`text`,size:`medium`,"aria-label":n?`Hide the code`:`Show the code`,icon:h(n?v:_,{}),onClick:()=>r(e=>!e)}),/* @__PURE__ */ g(c,{$borderColor:A(e.severity),children:[/* @__PURE__ */ g(`div`,{children:[/* @__PURE__ */ h(i,{children:k(e.severity)}),` `,e.message]}),n?/* @__PURE__ */ g(a,{children:[/* @__PURE__ */ g(s,{children:[/* @__PURE__ */ h(`strong`,{children:e.location.source.absoluteRef}),e.location.pointer]}),/* @__PURE__ */ h(t,{children:e.codeframe})]}):null]})]})}function M({chunks:e}){let t=e.map(e=>e.title).filter(Boolean).join(`, `);return/* @__PURE__ */ h(P,{"data-component-name":`Scorecard/Gauge`,title:t,children:e.map((e,t)=>/* @__PURE__ */ h(F,{$share:e.share,$colorVariable:e.colorVariable},t))})}const N=f.span`
2
2
  vertical-align: middle;
3
3
  display: inline-block;
4
4
  margin-right: 0;
5
5
  text-align: right;
6
6
  width: 70px;
7
- `,P=h.div`
7
+ `,P=f.div`
8
8
  display: flex;
9
9
  flex-direction: row;
10
10
  height: 10px;
11
11
  width: 100%;
12
- `,F=h.div`
12
+ `,F=f.div`
13
13
  width: ${e=>e.$share}%;
14
14
  background-color: var(${e=>e.$colorVariable});
15
15
  height: 10px;
16
- `,I={Pass:{background:`--color-green-1`,icon:`--color-green-6`},Warn:{background:`--color-carrot-1`,icon:`--color-carrot-6`},Error:{background:`--color-raspberry-1`,icon:`--color-raspberry-6`}};function L({uniqueErrors:e,uniqueWarnings:t}){return/* @__PURE__ */ p(R,{children:[e===0&&/* @__PURE__ */ f(z,{$color:`var(${I.Pass.background})`,children:/* @__PURE__ */ f(x,{size:`13px`,color:`var(${I.Pass.icon})`})}),e>0&&/* @__PURE__ */ p(z,{$color:`var(${I.Error.background})`,children:[/* @__PURE__ */ f(y,{size:`12px`,color:`var(${I.Error.icon})`}),/* @__PURE__ */ f(B,{$color:`var(${I.Error.icon})`,children:e})]}),t>0&&/* @__PURE__ */ p(z,{$color:`var(${I.Warn.background})`,children:[/* @__PURE__ */ f(b,{size:`12px`,color:`var(${I.Warn.icon})`}),/* @__PURE__ */ f(B,{$color:`var(${I.Warn.icon})`,children:t})]})]})}const R=h.div`
16
+ `,I={Pass:{background:`--color-green-1`,icon:`--color-green-6`},Warn:{background:`--color-carrot-1`,icon:`--color-carrot-6`},Error:{background:`--color-raspberry-1`,icon:`--color-raspberry-6`}};function L({uniqueErrors:e,uniqueWarnings:t}){return/* @__PURE__ */ g(R,{children:[e===0&&/* @__PURE__ */ h(z,{$color:`var(${I.Pass.background})`,children:/* @__PURE__ */ h(x,{size:`13px`,color:`var(${I.Pass.icon})`})}),e>0&&/* @__PURE__ */ g(z,{$color:`var(${I.Error.background})`,children:[/* @__PURE__ */ h(y,{size:`12px`,color:`var(${I.Error.icon})`}),/* @__PURE__ */ h(B,{$color:`var(${I.Error.icon})`,children:e})]}),t>0&&/* @__PURE__ */ g(z,{$color:`var(${I.Warn.background})`,children:[/* @__PURE__ */ h(b,{size:`12px`,color:`var(${I.Warn.icon})`}),/* @__PURE__ */ h(B,{$color:`var(${I.Warn.icon})`,children:t})]})]})}const R=f.div`
17
17
  display: flex;
18
18
  align-items: center;
19
19
  gap: 4px;
20
- `,z=h.div`
20
+ `,z=f.div`
21
21
  background-color: ${({$color:e})=>e};
22
22
  display: flex;
23
23
  align-items: center;
@@ -25,11 +25,11 @@ import{CardRow as e,Code as t,ContentWithDotWrap as n,Dot as r,EmojiWrap as i,Fi
25
25
  padding: 4px;
26
26
  border-radius: 4px;
27
27
  height: 20px;
28
- `,B=h.span`
28
+ `,B=f.span`
29
29
  color: ${({$color:e})=>e};
30
30
  font-size: 12px;
31
31
  margin-left: 4px;
32
- `;function V({levels:t,title:n}){return/* @__PURE__ */ p(l,{"data-component-name":`Scorecard/StatusByLevelWidget`,children:[/* @__PURE__ */ f(u,{children:n}),/* @__PURE__ */ f(H,{children:t.map(t=>{let n=t.total-t.errors-t.warnings;return/* @__PURE__ */ p(e,{children:[/* @__PURE__ */ f(`span`,{children:t.name}),/* @__PURE__ */ f(M,{chunks:[{share:n/t.total*100,colorVariable:`--scorecard-color-success`,title:`${n} passed`},{share:t.warnings/t.total*100,colorVariable:`--scorecard-color-warning`,title:`${t.warnings} ${t.warnings===1?`warning`:`warnings`}`},{share:t.errors/t.total*100,colorVariable:`--scorecard-color-error`,title:`${t.errors} ${t.errors===1?`error`:`errors`}`}]}),/* @__PURE__ */ p(N,{children:[n,`/`,t.total]})]},t.name)})})]})}const H=h.div`
32
+ `;function V({levels:t,title:n}){return/* @__PURE__ */ g(l,{"data-component-name":`Scorecard/StatusByLevelWidget`,children:[/* @__PURE__ */ h(u,{children:n}),/* @__PURE__ */ h(H,{children:t.map(t=>{let n=t.total-t.errors-t.warnings;return/* @__PURE__ */ g(e,{children:[/* @__PURE__ */ h(`span`,{children:t.name}),/* @__PURE__ */ h(M,{chunks:[{share:n/t.total*100,colorVariable:`--scorecard-color-success`,title:`${n} passed`},{share:t.warnings/t.total*100,colorVariable:`--scorecard-color-warning`,title:`${t.warnings} ${t.warnings===1?`warning`:`warnings`}`},{share:t.errors/t.total*100,colorVariable:`--scorecard-color-error`,title:`${t.errors} ${t.errors===1?`error`:`errors`}`}]}),/* @__PURE__ */ g(N,{children:[n,`/`,t.total]})]},t.name)})})]})}const H=f.div`
33
33
  display: flex;
34
34
  flex-direction: column;
35
35
  gap: 5px;
@@ -1,7 +1,7 @@
1
- import{CATALOG_CLASSIC_DEP_KEY as e}from"../../catalog-classic/client/contract.js";import"./contract.js";import{AppPageWrapper as t,CardRow as n,CardValue as r,CardsWrapper as i,ContentWithDotWrap as a,LevelComplianceCardTitle as o,LinkButton as s,ModeSwitcherTab as c,ModeSwitcherTabs as l,PageDescription as u,ProblemsByStatusCardBody as d,ScoreCardStatusCardBody as f,ScorecardCard as p,ScorecardCardTitle as m,TableWrap as h}from"./styles.js";import{ApiLevel as g,Gauge as _,GaugeValue as v,InstanceStatus as y,LevelStatus as b,StatusByLevelWidget as x,StatusDistribution as S}from"./ScorecardWidgets.js";import{useApiScorecard as C,useScorecard as w}from"./use-scorecard.js";import{ApiListView as T,ApiProblemsView as E,RuleApisView as D,RulesView as O,TeamsView as ee}from"./ScorecardViews.js";import*as k from"react";import{useLocation as A}from"react-router";import{Fragment as j,jsx as M,jsxs as N}from"react/jsx-runtime";import{breakpoints as P,getScorecardColorVariable as F}from"@redocly/theme/core/utils";import I from"styled-components";import{useModalScrollLock as L}from"@redocly/theme/core/hooks";import{Button as R}from"@redocly/theme/components/Button/Button";import{ArrowLeftIcon as z}from"@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon";import{Sidebar as B}from"@redocly/theme/components/Sidebar/Sidebar";import{useLoaderData as V}from"virtual:realm-runtime";import{Link as H}from"@redocly/theme/components/Link/Link";import{CatalogDescription as U,CatalogPageContent as W,CatalogPageDescriptionWrapper as G,CatalogPageWrapper as K,CatalogTitle as q}from"@redocly/theme/components/CatalogClassic/CatalogClassic";import{FilterContent as J}from"@redocly/theme/components/Filter/FilterContent";import{FilterPopover as Y}from"@redocly/theme/components/Filter/FilterPopover";import{HighlightContext as X}from"@redocly/theme/components/CatalogClassic/CatalogClassicHighlight";import{CatalogClassicActions as Z}from"@redocly/theme/components/CatalogClassic/CatalogClassicActions";function Q({page:t}){let n=V(e),{pathname:r}=A();if(!n)return null;let i=t.slug.replace(/\/$/,``),[a,o]=r.slice(i.length).split(`/`).filter(Boolean),s=o===void 0?void 0:decodeURIComponent(o);return/* @__PURE__ */ M(te,{base:i,data:n,view:a===`apis`&&s!==void 0?{kind:`api`,link:`/${s}`}:a===`rules`&&s!==void 0?{kind:`rule`,ruleId:s}:{kind:`dashboard`}})}function te({base:e,data:n,view:r}){let i=w(n);if(r.kind===`api`){let a=i.apis.find(e=>e.link===r.link);return a?/* @__PURE__ */ M(re,{base:e,api:a,scorecard:i,rulesPerLevel:n.scorecard.rulesPerLevel}):/* @__PURE__ */ M(t,{children:`API not found`})}if(r.kind===`rule`){let n=i.problemsByRule.find(e=>e.ruleId===r.ruleId);return n?/* @__PURE__ */ M(ie,{base:e,rule:n,scorecard:i}):/* @__PURE__ */ M(t,{children:`Rule not found`})}return/* @__PURE__ */ M(ne,{base:e,levelNames:n.scorecard.levelNames,scorecard:i})}function ne({base:e,levelNames:t,scorecard:o}){let{summary:u,filters:_,filterTerm:v,setFilterTerm:y,hasTeam:b,teamLabel:x,catalogConfig:C}=o,w={apis:`APIs`,rules:`Rules`};b&&(w.teams=x);let[E,D]=k.useState(!1),[A,j]=k.useState(`apis`),P=k.useCallback(()=>j(`apis`),[]);L(E);let I=o.teams.filter(e=>(e.apis[`Non-conformant`]??0)>0).sort((e,t)=>(t.apis[`Non-conformant`]??0)-(e.apis[`Non-conformant`]??0));return/* @__PURE__ */ M(X.Provider,{value:[v],children:/* @__PURE__ */ N(K,{"data-component-name":`Scorecard/Dashboard`,children:[/* @__PURE__ */ M(ae,{menu:/* @__PURE__ */ M(J,{setFilterTerm:y,filters:_,filterTerm:v,filterValuesCasing:C.filterValuesCasing})}),E&&/* @__PURE__ */ M(Y,{onClose:()=>D(!1),setFilterTerm:y,filterTerm:v,filters:_,filterValuesCasing:C.filterValuesCasing}),/* @__PURE__ */ M(Z,{onOpenFilter:()=>D(!0),filters:_,filterTerm:v}),/* @__PURE__ */ N(W,{children:[/* @__PURE__ */ N(G,{children:[/* @__PURE__ */ M(q,{children:`API design scorecard`}),/* @__PURE__ */ M(U,{children:`See the health of your API designs.`})]}),/* @__PURE__ */ N(i,{children:[/* @__PURE__ */ N(p,{children:[/* @__PURE__ */ M(m,{children:`Scorecard status`}),/* @__PURE__ */ N(f,{children:[/* @__PURE__ */ N(`div`,{children:[/* @__PURE__ */ M(r,{children:u.total}),/* @__PURE__ */ M(`br`,{}),`APIs`]}),/* @__PURE__ */ M(`div`,{children:Object.entries(u.levels).map(([e,t],n)=>/* @__PURE__ */ N(a,{children:[/* @__PURE__ */ M(r,{style:{width:`40px`,textAlign:`right`},children:t}),/* @__PURE__ */ M(g,{level:e,colorVariable:F(n,Object.values(u.levels).length)})]},e))})]}),/* @__PURE__ */ M(S,{summary:u})]}),b&&/* @__PURE__ */ N(p,{children:[/* @__PURE__ */ M(m,{children:`Non-conformant APIs by ${x}`}),/* @__PURE__ */ N(d,{children:[I.slice(0,4).map(e=>/* @__PURE__ */ N(n,{children:[/* @__PURE__ */ M(`span`,{style:{flex:1,textAlign:`left`},children:e.team}),/* @__PURE__ */ M(r,{children:e.apis[`Non-conformant`]})]},e.team)),o.teams.length>4&&/* @__PURE__ */ N(s,{onClick:()=>j(`teams`),children:[`See all (`,o.teams.length,`)`]})]})]})]}),/* @__PURE__ */ M(l,{"data-component-name":`Scorecard/ModeSwitcherTabs`,children:Object.entries(w).map(([e,t])=>/* @__PURE__ */ M(c,{"data-component-name":`Scorecard/ModeSwitcherTab`,$isActive:A===e,onClick:()=>j(e),children:t},e))}),/* @__PURE__ */ M(h,{$isActive:A===`apis`,children:/* @__PURE__ */ M(T,{base:e,apis:o.apis,levelNames:t,hasTeam:b,hasPublishedAt:o.hasPublishedAt,teamLabel:x})}),/* @__PURE__ */ M(h,{$isActive:A===`rules`,children:/* @__PURE__ */ M(O,{base:e,rules:o.problemsByRule})}),b&&/* @__PURE__ */ M(h,{$isActive:A===`teams`,children:/* @__PURE__ */ M(ee,{teams:o.teams,levelNames:t,filters:_,teamLabel:x,teamProperty:o.teamProperty,onSelectTeam:P})})]})]})})}function $({base:e}){return/* @__PURE__ */ M(R,{icon:/* @__PURE__ */ M(z,{}),iconPosition:`left`,variant:`ghost`,size:`large`,to:e,children:`Back to dashboard`})}function re({base:e,api:n,scorecard:s,rulesPerLevel:d}){let _=C(n.scorecard.relativePath),v=_?.levels??{},y=Object.keys(v),[S,w]=k.useState(),T=S??y[0];return _===void 0?/* @__PURE__ */ M(t,{children:`Loading…`}):_===null?/* @__PURE__ */ M(t,{children:`Scorecard not found`}):/* @__PURE__ */ N(t,{"data-component-name":`Scorecard/ApiPage`,children:[/* @__PURE__ */ M($,{base:e}),/* @__PURE__ */ M(`h1`,{children:n.title}),/* @__PURE__ */ N(u,{children:[n.publishedAt&&/* @__PURE__ */ N(j,{children:[`Published at: `,new Date(n.publishedAt).toLocaleDateString(),/* @__PURE__ */ M(`br`,{})]}),/* @__PURE__ */ M(H,{to:n.link,external:!0,children:`Documentation`})]}),/* @__PURE__ */ N(i,{children:[/* @__PURE__ */ N(p,{children:[/* @__PURE__ */ N(o,{children:[/* @__PURE__ */ M(`span`,{children:`Scorecard level`}),/* @__PURE__ */ M(g,{level:_.scorecardLevel,colorVariable:F(_.scorecardLevelIdx,y.length+1)})]}),/* @__PURE__ */ N(f,{children:[/* @__PURE__ */ M(`div`,{children:`Compliance by level`}),/* @__PURE__ */ M(`div`,{children:Object.entries(v).map(([e,t])=>/* @__PURE__ */ N(a,{children:[/* @__PURE__ */ M(r,{style:{width:`100px`,textAlign:`right`},children:e}),/* @__PURE__ */ M(b,{errors:t.errors,warnings:t.warnings})]},e))})]})]}),/* @__PURE__ */ M(x,{title:`Rules compliance`,levels:Object.entries(v).map(([e,t])=>({name:e,errors:t.uniqueErrors,warnings:t.uniqueWarnings,total:d[e]?.length??0}))}),/* @__PURE__ */ N(p,{children:[/* @__PURE__ */ M(m,{children:s.teamLabel}),/* @__PURE__ */ M(r,{style:{fontWeight:`normal`},children:n.team})]})]}),/* @__PURE__ */ M(l,{"data-component-name":`Scorecard/ModeSwitcherTabs`,children:y.map(e=>/* @__PURE__ */ M(c,{"data-component-name":`Scorecard/ModeSwitcherTab`,$isActive:T===e,onClick:()=>w(e),children:/* @__PURE__ */ N(a,{children:[/* @__PURE__ */ M(`span`,{children:e}),/* @__PURE__ */ M(b,{errors:v[e].errors,warnings:v[e].warnings})]})},e))}),y.map(e=>/* @__PURE__ */ M(h,{$isActive:T===e,children:/* @__PURE__ */ M(E,{level:e,problems:v[e].problems})},e))]})}function ie({base:e,rule:o,scorecard:s}){let c=Object.entries(o.teams).sort((e,t)=>t[1]-e[1]),l=o.apis.length;return/* @__PURE__ */ N(t,{"data-component-name":`Scorecard/RulePage`,children:[/* @__PURE__ */ M($,{base:e}),/* @__PURE__ */ N(`h1`,{children:[`Rule `,o.ruleId]}),/* @__PURE__ */ N(i,{children:[/* @__PURE__ */ N(p,{children:[/* @__PURE__ */ M(m,{children:`Rule status`}),/* @__PURE__ */ N(f,{children:[/* @__PURE__ */ N(`div`,{children:[/* @__PURE__ */ M(r,{children:l}),/* @__PURE__ */ M(`br`,{}),`APIs`]}),/* @__PURE__ */ N(`div`,{children:[/* @__PURE__ */ N(a,{children:[/* @__PURE__ */ M(r,{children:l-o.warningApisCount-o.errorApisCount}),/* @__PURE__ */ M(y,{severity:`Pass`})]}),/* @__PURE__ */ N(a,{children:[/* @__PURE__ */ M(r,{children:o.warningApisCount}),/* @__PURE__ */ M(y,{severity:`Warn`})]}),/* @__PURE__ */ N(a,{children:[/* @__PURE__ */ M(r,{children:o.errorApisCount}),/* @__PURE__ */ M(y,{severity:`Error`})]})]})]})]}),/* @__PURE__ */ N(p,{children:[/* @__PURE__ */ M(m,{children:`Problems by level`}),/* @__PURE__ */ M(d,{children:Object.entries(o.levels).map(([e,t])=>/* @__PURE__ */ N(n,{children:[/* @__PURE__ */ M(`span`,{children:e}),/* @__PURE__ */ M(_,{chunks:[{share:t.errors/o.count*100,colorVariable:`--scorecard-color-error`},{share:t.warnings/o.count*100,colorVariable:`--scorecard-color-warning`}]}),/* @__PURE__ */ M(v,{children:t.errors+t.warnings})]},e))})]}),/* @__PURE__ */ N(p,{children:[/* @__PURE__ */ M(m,{children:`Problems by ${s.teamLabel}`}),/* @__PURE__ */ M(d,{children:c.slice(0,4).map(([e,t])=>/* @__PURE__ */ N(n,{children:[/* @__PURE__ */ M(`span`,{style:{flex:1,textAlign:`left`},children:e}),/* @__PURE__ */ M(r,{children:t})]},e))})]})]}),/* @__PURE__ */ M(D,{ruleId:o.ruleId,apis:o.apis,hasPublishedAt:s.hasPublishedAt,hasTeam:s.hasTeam,teamLabel:s.teamLabel})]})}const ae=I(B)`
1
+ import{CATALOG_CLASSIC_DEP_KEY as e}from"../../catalog-classic/client/contract.js";import"./contract.js";import{AppPageWrapper as t,CardRow as n,CardValue as r,CardsWrapper as i,ContentWithDotWrap as a,LevelComplianceCardTitle as o,LinkButton as s,ModeSwitcherTab as c,ModeSwitcherTabs as l,PageDescription as u,ProblemsByStatusCardBody as d,ScoreCardStatusCardBody as f,ScorecardCard as p,ScorecardCardTitle as m,TableWrap as h}from"./styles.js";import{ApiLevel as g,Gauge as _,GaugeValue as v,InstanceStatus as y,LevelStatus as b,StatusByLevelWidget as x,StatusDistribution as S}from"./ScorecardWidgets.js";import{useApiScorecard as C,useScorecard as w}from"./use-scorecard.js";import{ApiListView as T,ApiProblemsView as E,RuleApisView as D,RulesView as ee,TeamsView as O}from"./ScorecardViews.js";import*as k from"react";import A from"styled-components";import{Button as j}from"@redocly/theme/components/Button/Button";import{useLocation as M}from"react-router";import{breakpoints as N,getScorecardColorVariable as P}from"@redocly/theme/core/utils";import{Fragment as F,jsx as I,jsxs as L}from"react/jsx-runtime";import{useModalScrollLock as R}from"@redocly/theme/core/hooks";import{ArrowLeftIcon as z}from"@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon";import{Sidebar as B}from"@redocly/theme/components/Sidebar/Sidebar";import{useLoaderData as V}from"virtual:realm-runtime";import{Link as H}from"@redocly/theme/components/Link/Link";import{CatalogDescription as U,CatalogPageContent as W,CatalogPageDescriptionWrapper as G,CatalogPageWrapper as K,CatalogTitle as q}from"@redocly/theme/components/CatalogClassic/CatalogClassic";import{FilterContent as J}from"@redocly/theme/components/Filter/FilterContent";import{FilterPopover as Y}from"@redocly/theme/components/Filter/FilterPopover";import{HighlightContext as X}from"@redocly/theme/components/CatalogClassic/CatalogClassicHighlight";import{CatalogClassicActions as Z}from"@redocly/theme/components/CatalogClassic/CatalogClassicActions";function Q({page:t}){let n=V(e),{pathname:r}=M();if(!n)return null;let i=t.slug.replace(/\/$/,``),[a,o]=r.slice(i.length).split(`/`).filter(Boolean),s=o===void 0?void 0:decodeURIComponent(o);return/* @__PURE__ */ I(te,{base:i,data:n,view:a===`apis`&&s!==void 0?{kind:`api`,link:`/${s}`}:a===`rules`&&s!==void 0?{kind:`rule`,ruleId:s}:{kind:`dashboard`}})}function te({base:e,data:n,view:r}){let i=w(n);if(r.kind===`api`){let a=i.apis.find(e=>e.link===r.link);return a?/* @__PURE__ */ I(re,{base:e,api:a,scorecard:i,rulesPerLevel:n.scorecard.rulesPerLevel}):/* @__PURE__ */ I(t,{children:`API not found`})}if(r.kind===`rule`){let n=i.problemsByRule.find(e=>e.ruleId===r.ruleId);return n?/* @__PURE__ */ I(ie,{base:e,rule:n,scorecard:i}):/* @__PURE__ */ I(t,{children:`Rule not found`})}return/* @__PURE__ */ I(ne,{base:e,levelNames:n.scorecard.levelNames,scorecard:i})}function ne({base:e,levelNames:t,scorecard:o}){let{summary:u,filters:_,filterTerm:v,setFilterTerm:y,hasTeam:b,teamLabel:x,catalogConfig:C}=o,w={apis:`APIs`,rules:`Rules`};b&&(w.teams=x);let[E,D]=k.useState(!1),[A,j]=k.useState(`apis`),M=k.useCallback(()=>j(`apis`),[]);R(E);let N=o.teams.filter(e=>(e.apis[`Non-conformant`]??0)>0).sort((e,t)=>(t.apis[`Non-conformant`]??0)-(e.apis[`Non-conformant`]??0));return/* @__PURE__ */ I(X.Provider,{value:[v],children:/* @__PURE__ */ L(K,{"data-component-name":`Scorecard/Dashboard`,children:[/* @__PURE__ */ I(ae,{menu:/* @__PURE__ */ I(J,{setFilterTerm:y,filters:_,filterTerm:v,filterValuesCasing:C.filterValuesCasing})}),E&&/* @__PURE__ */ I(Y,{onClose:()=>D(!1),setFilterTerm:y,filterTerm:v,filters:_,filterValuesCasing:C.filterValuesCasing}),/* @__PURE__ */ I(Z,{onOpenFilter:()=>D(!0),filters:_,filterTerm:v}),/* @__PURE__ */ L(W,{children:[/* @__PURE__ */ L(G,{children:[/* @__PURE__ */ I(q,{children:`API design scorecard`}),/* @__PURE__ */ I(U,{children:`See the health of your API designs.`})]}),/* @__PURE__ */ L(i,{children:[/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:`Scorecard status`}),/* @__PURE__ */ L(f,{children:[/* @__PURE__ */ L(`div`,{children:[/* @__PURE__ */ I(r,{children:u.total}),/* @__PURE__ */ I(`br`,{}),`APIs`]}),/* @__PURE__ */ I(`div`,{children:Object.entries(u.levels).map(([e,t],n)=>/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(r,{style:{width:`40px`,textAlign:`right`},children:t}),/* @__PURE__ */ I(g,{level:e,colorVariable:P(n,Object.values(u.levels).length)})]},e))})]}),/* @__PURE__ */ I(S,{summary:u})]}),b&&/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:`Non-conformant APIs by ${x}`}),/* @__PURE__ */ L(d,{children:[N.slice(0,4).map(e=>/* @__PURE__ */ L(n,{children:[/* @__PURE__ */ I(`span`,{style:{flex:1,textAlign:`left`},children:e.team}),/* @__PURE__ */ I(r,{children:e.apis[`Non-conformant`]})]},e.team)),o.teams.length>4&&/* @__PURE__ */ L(s,{onClick:()=>j(`teams`),children:[`See all (`,o.teams.length,`)`]})]})]})]}),/* @__PURE__ */ I(l,{"data-component-name":`Scorecard/ModeSwitcherTabs`,children:Object.entries(w).map(([e,t])=>/* @__PURE__ */ I(c,{"data-component-name":`Scorecard/ModeSwitcherTab`,$isActive:A===e,onClick:()=>j(e),children:t},e))}),/* @__PURE__ */ I(h,{$isActive:A===`apis`,children:/* @__PURE__ */ I(T,{base:e,apis:o.apis,levelNames:t,hasTeam:b,hasPublishedAt:o.hasPublishedAt,teamLabel:x})}),/* @__PURE__ */ I(h,{$isActive:A===`rules`,children:/* @__PURE__ */ I(ee,{base:e,rules:o.problemsByRule})}),b&&/* @__PURE__ */ I(h,{$isActive:A===`teams`,children:/* @__PURE__ */ I(O,{teams:o.teams,levelNames:t,filters:_,teamLabel:x,teamProperty:o.teamProperty,onSelectTeam:M})})]})]})})}function $({base:e}){return/* @__PURE__ */ I(j,{icon:/* @__PURE__ */ I(z,{}),iconPosition:`left`,variant:`ghost`,size:`large`,to:e,children:`Back to dashboard`})}function re({base:e,api:n,scorecard:s,rulesPerLevel:d}){let _=C(n.scorecard.relativePath),v=_?.levels??{},y=Object.keys(v),[S,w]=k.useState(),T=S??y[0];return _===void 0?/* @__PURE__ */ I(t,{children:`Loading…`}):_===null?/* @__PURE__ */ I(t,{children:`Scorecard not found`}):/* @__PURE__ */ L(t,{"data-component-name":`Scorecard/ApiPage`,children:[/* @__PURE__ */ I($,{base:e}),/* @__PURE__ */ I(`h1`,{children:n.title}),/* @__PURE__ */ L(u,{children:[n.publishedAt&&/* @__PURE__ */ L(F,{children:[`Published at: `,new Date(n.publishedAt).toLocaleDateString(),/* @__PURE__ */ I(`br`,{})]}),/* @__PURE__ */ I(H,{to:n.link,external:!0,children:`Documentation`})]}),/* @__PURE__ */ L(i,{children:[/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ L(o,{children:[/* @__PURE__ */ I(`span`,{children:`Scorecard level`}),/* @__PURE__ */ I(g,{level:_.scorecardLevel,colorVariable:P(_.scorecardLevelIdx,y.length+1)})]}),/* @__PURE__ */ L(f,{children:[/* @__PURE__ */ I(`div`,{children:`Compliance by level`}),/* @__PURE__ */ I(`div`,{children:Object.entries(v).map(([e,t])=>/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(r,{style:{width:`100px`,textAlign:`right`},children:e}),/* @__PURE__ */ I(b,{errors:t.errors,warnings:t.warnings})]},e))})]})]}),/* @__PURE__ */ I(x,{title:`Rules compliance`,levels:Object.entries(v).map(([e,t])=>({name:e,errors:t.uniqueErrors,warnings:t.uniqueWarnings,total:d[e]?.length??0}))}),/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:s.teamLabel}),/* @__PURE__ */ I(r,{style:{fontWeight:`normal`},children:n.team})]})]}),/* @__PURE__ */ I(l,{"data-component-name":`Scorecard/ModeSwitcherTabs`,children:y.map(e=>/* @__PURE__ */ I(c,{"data-component-name":`Scorecard/ModeSwitcherTab`,$isActive:T===e,onClick:()=>w(e),children:/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(`span`,{children:e}),/* @__PURE__ */ I(b,{errors:v[e].errors,warnings:v[e].warnings})]})},e))}),y.map(e=>/* @__PURE__ */ I(h,{$isActive:T===e,children:/* @__PURE__ */ I(E,{level:e,problems:v[e].problems})},e))]})}function ie({base:e,rule:o,scorecard:s}){let c=Object.entries(o.teams).sort((e,t)=>t[1]-e[1]),l=o.apis.length;return/* @__PURE__ */ L(t,{"data-component-name":`Scorecard/RulePage`,children:[/* @__PURE__ */ I($,{base:e}),/* @__PURE__ */ L(`h1`,{children:[`Rule `,o.ruleId]}),/* @__PURE__ */ L(i,{children:[/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:`Rule status`}),/* @__PURE__ */ L(f,{children:[/* @__PURE__ */ L(`div`,{children:[/* @__PURE__ */ I(r,{children:l}),/* @__PURE__ */ I(`br`,{}),`APIs`]}),/* @__PURE__ */ L(`div`,{children:[/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(r,{children:l-o.warningApisCount-o.errorApisCount}),/* @__PURE__ */ I(y,{severity:`Pass`})]}),/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(r,{children:o.warningApisCount}),/* @__PURE__ */ I(y,{severity:`Warn`})]}),/* @__PURE__ */ L(a,{children:[/* @__PURE__ */ I(r,{children:o.errorApisCount}),/* @__PURE__ */ I(y,{severity:`Error`})]})]})]})]}),/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:`Problems by level`}),/* @__PURE__ */ I(d,{children:Object.entries(o.levels).map(([e,t])=>/* @__PURE__ */ L(n,{children:[/* @__PURE__ */ I(`span`,{children:e}),/* @__PURE__ */ I(_,{chunks:[{share:t.errors/o.count*100,colorVariable:`--scorecard-color-error`},{share:t.warnings/o.count*100,colorVariable:`--scorecard-color-warning`}]}),/* @__PURE__ */ I(v,{children:t.errors+t.warnings})]},e))})]}),/* @__PURE__ */ L(p,{children:[/* @__PURE__ */ I(m,{children:`Problems by ${s.teamLabel}`}),/* @__PURE__ */ I(d,{children:c.slice(0,4).map(([e,t])=>/* @__PURE__ */ L(n,{children:[/* @__PURE__ */ I(`span`,{style:{flex:1,textAlign:`left`},children:e}),/* @__PURE__ */ I(r,{children:t})]},e))})]})]}),/* @__PURE__ */ I(D,{ruleId:o.ruleId,apis:o.apis,hasPublishedAt:s.hasPublishedAt,hasTeam:s.hasTeam,teamLabel:s.teamLabel})]})}const ae=A(B)`
2
2
  display: none;
3
3
 
4
- @media screen and (min-width: ${P.medium}) {
4
+ @media screen and (min-width: ${N.medium}) {
5
5
  display: flex;
6
6
  }
7
7
  --menu-container-padding-top: 0;
@@ -1 +1 @@
1
- import{defineContentPlugin as e}from"../../define.js";import{toJsonValue as t}from"../../../database/utils/json.js";import{createEntityLoader as n}from"../../../loaders/define.js";import{runtimeFile as r}from"../../utils/runtime-file.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{runtimeTemplate as a}from"../../templates.js";import{toPosixPath as o}from"../../../../shared/utils/to-posix-path.js";import{isObject as s}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as c}from"../../../../shared/utils/routes/normalize-route-slug.js";import{publicLink as l}from"../../../versions/public-link.js";import{createApiEntityKey as u}from"../../utils/api-entity-key.js";import{API_DOCS_INFO_BLOCK_DEP_KEY as d}from"../api-docs/server/shared.js";import{getLoadedProjectPlugins as f}from"../../project/loaded-set.js";import{API_OUTPUT_MANIFEST_KEY as p}from"../../../api-outputs.js";import{CATALOG_CLASSIC_DEP_KEY as m}from"../catalog-classic/client/contract.js";import{catalogEntityKey as h}from"../catalog-classic/entity-key.js";import{CATALOG_CARD_METADATA_ENTITY_TYPE as g}from"../catalog-classic/card-metadata.js";import{loadVersionGroups as _}from"../catalog-classic/resolve-items.js";import{NON_CONFORMANT as ee,apiPagePath as v,scorecardDetailsFile as y}from"./client/contract.js";import{findTarget as b,readScorecardSettings as x}from"./config.js";import{API_SCORECARD_ENTITY_TYPE as S,RULES_ENTITY_KEY as C,apiScorecardEntityKey as w,isScoredApi as T,scorecardPageEntityKey as E}from"./entities.js";import{collectRuleNames as te,lintApi as ne,resolveLevelConfigs as D,summarizeRules as O}from"./lint.js";import{gzip as k}from"../../../../shared/utils/gzip.js";import{join as A,posix as j,relative as M}from"node:path";import re from"picomatch";const N=`internal.scorecard-classic`,P=`scorecard-classic`,ie=i(N,`api`),ae=i(N,`rules`),oe=i(N,`page`),se=i(N,`card-metadata`),ce=i(N,`badge`),F=n(ie,async e=>{let t=e.file.path,n=e.args.source??t,r=e.routes.byFilePath(t),i=r&&e.routes.get(r.slug);if(!i)return{value:null,metadata:{sourcePath:t}};let a=async t=>({body:await e.createBlobRef(await k(new TextEncoder().encode(JSON.stringify(t))),{format:`binary`}),contentType:`application/gzip`}),o=x(e.config),s=J(e.contentDir),c=b(o.targets,i.metadata),l=b(o.targets.filter(e=>e.rules!==void 0),i.metadata),u=s.paths,d;try{let t=await D({contentDir:e.contentDir,settings:o,plugins:s.plugins,readFile:e.io.readFile});u=[...t.files,...s.paths];let r=l===void 0?void 0:t.targets[o.targets.indexOf(l)];d=await ne({contentDir:e.contentDir,filePath:n,source:await e.io.readFile(A(e.contentDir,n)),configs:Object.fromEntries(o.levels.map(e=>[e.name,r?.[e.name]??t.levels[e.name]]))})}catch(e){return{value:await a(null),metadata:{sourcePath:t},problems:[{code:`scorecard/lint-failed`,message:`The scorecard could not lint this API: ${e instanceof Error?e.message:String(e)}`,location:{filePath:t}}],entityDeps:Y([n,...u])}}let f={...L(o,d.levels,c?.minimumLevel),title:await I(e.entities,t)??j.basename(n),relativePath:t,levels:d.levels};i.version!==null&&(f.version=i.version);let{levels:p,...m}=f,h={...m,levels:Object.fromEntries(Object.entries(p).map(([e,{problems:t,...n}])=>[e,n])),rules:O(p),sourcePath:t,route:i.slug};return{value:await a(f),metadata:h,entityDeps:Y([n,...d.files,...u])}});async function I(e,t){let n=await e.load(u(t)).catch(()=>void 0),r=s(n)&&s(n.info)?n.info:{};return typeof r.title==`string`?r.title:void 0}function L(e,t,n){let r=e.levels.map(e=>e.name),i=r.findIndex(e=>t[e].errors>0),a=i===-1?r.length:i,o=n??r[0],s=r.indexOf(o),c=`HIGHEST`;return a-1<s?c=`BELOW_MINIMUM`:s<r.length-1&&(c=`MINIMUM`),{scorecardLevel:a===0?ee:r[a-1],scorecardLevelIdx:a,targetLevel:o,status:c}}async function R(e,t){let n=await e.get(t);return n!==null&&(n.status!==`ready`||!T(n.metadata))&&(await e.load(t).catch(()=>void 0),n=await e.get(t)),n!==null&&T(n.metadata)?n.metadata:null}async function z(e){let t=[];for(let n of await e.list({type:S})){let r=await R(e,n.key);r!==null&&t.push(r)}return t}function B({sourcePath:e,route:t,...n}){return n}const V=n(ae,async e=>{let t=x(e.config),{perLevel:n,all:r}=await D({contentDir:e.contentDir,settings:t,plugins:J(e.contentDir).plugins,readFile:e.io.readFile}).then(e=>te(e.levels),()=>({perLevel:{},all:[]}));return{value:{levelNames:t.levels.map(e=>e.name),rules:r,rulesPerLevel:n}}}),H=n(oe,async e=>{let t=await e.entities.load(h(e.args.catalogId)),n=await e.entities.load(C),r=(await z(e.entities)).flatMap(t=>{let n=e.routes.get(t.route);return n?[{route:n,api:t}]:[]}),{versionGroups:i,entityDeps:a}=await _(r,e),o=new Map(r.map(({route:e,api:t})=>[l(e,i),B(t)])),s=[];for(let e of t.items){let t=o.get(e.link);t!==void 0&&s.push({...e,metadata:{...e.metadata,scorecard:t,scorecardLevel:t.scorecardLevel}})}let c={...t,items:s,scorecard:{...n,teamMetadataProperty:x(e.config).teamMetadataProperty}},u=JSON.stringify(c);return{value:u.length>65536?await e.createBlobRef(u,{format:`json`}):c,entityDeps:a}}),U=n(se,async e=>({value:(await z(e.entities)).map(e=>({route:e.route,metadata:{scorecardStatus:e.status,scorecardLevel:e.scorecardLevel,scorecardLevelIdx:e.scorecardLevelIdx,scorecardLevels:G(e)}}))})),W=n(ce,async e=>{let t=await R(e.entities,w(e.args.file)),n=t&&e.routes.get(t.route);if(!t||!n)return{value:null};let{versionGroups:r,entityDeps:i}=await _([{route:n}],e),a=l(n,r),o=q(e.config);if(o.length===0)return{value:null};let s=o[0].slug;if(o.length>1){for(let{catalogId:t,slug:n}of o)if((await e.entities.load(h(t))).items.some(e=>e.link===a)){s=n;break}}return{value:{scorecardLevel:t.scorecardLevel,scorecardLevelIdx:t.scorecardLevelIdx,scorecardLevels:G(t),scoreCardSlug:v(K(s),a)},entityDeps:i}});function G(e){return Object.fromEntries(Object.entries(e.levels).map(([e,t])=>[e,{uniqueErrors:t.uniqueErrors,uniqueWarnings:t.uniqueWarnings}]))}function K(e){return j.join(c(e),`scorecard`)}function q(e){return Object.entries(e.catalogClassic??e.catalog??{}).map(([e,t])=>({catalogId:e,slug:String(t.slug)}))}function J(e){let t=f(e)?.lintPlugins??[];return{plugins:t,paths:t.map(t=>o(M(e,t.path))).filter(e=>e!==``&&!e.startsWith(`../`))}}function Y(e){return[...new Set(e)].map(e=>({kind:`file`,path:e}))}function X(e){let t=e=>typeof e==`string`||typeof e==`number`;return t(e.manifest.openapi)||t(e.manifest.swagger)}function Z(e){let t=e.manifest[p];return s(t)&&typeof t.root==`string`?t.root:e.path}function Q(e){let t=Z(e);return F.withArgs(t===e.path?{}:{source:t},{stableKey:w(e.path),type:S,metadata:{sourcePath:e.path}})}function $(e,t){if(!X(e))return!1;let n=(t.scorecardClassic??t.scorecard)?.ignore??[];return n.length===0||!re([...n])(Z(e))}function le(e,t){let n=e.filter(e=>e.status===`BELOW_MINIMUM`).map(e=>e.relativePath);if(n.length===0)return;let r=n.slice(0,15).map(e=>`\n - ${e}`),i=n.length-r.length,a=`Detected OpenAPI definitions with score below minimum level:${r.join(``)}${i>0?`\n ... and ${i} more`:``}`;t.config.platform?.ignoreLint??(t.config.scorecardClassic??t.config.scorecard)?.ignoreNonCompliant?t.logger.warn(a):t.logger.error(a)}const ue=e({id:N,version:`2.3.0`,content:{filter:{extensions:[`.yaml`,`.yml`,`.json`]},extractFile(e,t){return $(e,t.config)?{routes:[],entities:[Q(e)]}:null},extractAll(e){let t=e.config.catalogClassic??e.config.catalog??{};if(!e.files.some(X)&&Object.keys(t).length===0)return{routes:[]};let n=x(e.config),r=[V.withArgs({},{stableKey:C})];n.isDefault||r.push(U.withArgs({},{stableKey:`scorecard-classic:card-metadata`,type:g}));let i=[];for(let[e,n]of Object.entries(t)){let t=K(String(n.slug)),a=H.withArgs({catalogId:e},{stableKey:E(e),metadata:{sourcePath:t}});r.push(a),i.push({deps:{[m]:a},metadata:{title:typeof n.title==`string`?n.title:`API design scorecard`},routeId:e,slug:t,template:P,wildcardPrefix:!0})}return{entities:r,routes:i}}},finalize(e){let t=q(e.config).length>0&&!x(e.config).isDefault,n=[],r=[],i=[];for(let a of e.files){let o=$(a,e.config)?e.routes.byFilePath(a.path):void 0;if(o===void 0||(n.push({path:y(a.path),producer:Q(a),audience:{routeSlug:o.slug}}),!t))continue;let s=W.withArgs({file:a.path},{stableKey:`scorecard-classic:badge:${o.slug}`});r.push(s),i.push({slug:o.slug,deps:{[d]:s}})}return{entities:r,attach:i,staticFiles:n}},async buildMetadata(e){if(await e.entities.get(`scorecard-classic:rules`)===null)return;let n=await e.entities.load(C),r=await z(e.entities),i={};for(let e of r){let{rules:t,...n}=B(e);i[e.relativePath]=n}return le(r,e),{scorecardData:i,...n,reuniteIgnoreLint:t(e.config.platform?.ignoreLint)}},loaders:[F,V,H,U,W],templates:{[P]:a(r(`./client/template.tsx`,import.meta.url))}});export{N as SCORECARD_CLASSIC_PLUGIN_ID,P as SCORECARD_CLASSIC_TEMPLATE_ID,ue as scorecardClassicContentPlugin};
1
+ import{defineContentPlugin as e}from"../../define.js";import{toJsonValue as t}from"../../../database/utils/json.js";import{createEntityLoader as n}from"../../../loaders/define.js";import{runtimeFile as r}from"../../utils/runtime-file.js";import{createPluginScopedId as i}from"../../utils/scoped-id.js";import{runtimeTemplate as a}from"../../templates.js";import{isObject as o}from"../../../../shared/utils/is-object.js";import{normalizeRouteSlug as s}from"../../../../shared/utils/routes/normalize-route-slug.js";import{API_DOCS_INFO_BLOCK_DEP_KEY as c}from"../api-docs/server/shared.js";import{CATALOG_CLASSIC_DEP_KEY as l}from"../catalog-classic/client/contract.js";import{toPosixPath as u}from"../../../../shared/utils/to-posix-path.js";import{publicLink as d}from"../../../versions/public-link.js";import{createApiEntityKey as f}from"../../utils/api-entity-key.js";import{getLoadedProjectPlugins as p}from"../../project/loaded-set.js";import{API_OUTPUT_MANIFEST_KEY as m}from"../../../api-outputs.js";import{catalogEntityKey as h}from"../catalog-classic/entity-key.js";import{CATALOG_CARD_METADATA_ENTITY_TYPE as g}from"../catalog-classic/card-metadata.js";import{loadVersionGroups as _}from"../catalog-classic/resolve-items.js";import{NON_CONFORMANT as ee,apiPagePath as v,scorecardDetailsFile as y}from"./client/contract.js";import{findTarget as b,readScorecardSettings as x}from"./config.js";import{API_SCORECARD_ENTITY_TYPE as S,RULES_ENTITY_KEY as C,apiScorecardEntityKey as w,isScoredApi as T,scorecardPageEntityKey as E}from"./entities.js";import{collectRuleNames as te,lintApi as ne,resolveLevelConfigs as D,summarizeRules as O}from"./lint.js";import{gzip as k}from"../../../../shared/utils/gzip.js";import{join as A,posix as j,relative as M}from"node:path";import re from"picomatch";const N=`internal.scorecard-classic`,P=`scorecard-classic`,ie=i(N,`api`),ae=i(N,`rules`),oe=i(N,`page`),se=i(N,`card-metadata`),ce=i(N,`badge`),F=n(ie,async e=>{let t=e.file.path,n=e.args.source??t,r=e.routes.byFilePath(t),i=r&&e.routes.get(r.slug);if(!i)return{value:null,metadata:{sourcePath:t}};let a=async t=>({body:await e.createBlobRef(await k(new TextEncoder().encode(JSON.stringify(t))),{format:`binary`}),contentType:`application/gzip`}),o=x(e.config),s=J(e.contentDir),c=b(o.targets,i.metadata),l=b(o.targets.filter(e=>e.rules!==void 0),i.metadata),u=s.paths,d;try{let t=await D({contentDir:e.contentDir,settings:o,plugins:s.plugins,readFile:e.io.readFile});u=[...t.files,...s.paths];let r=l===void 0?void 0:t.targets[o.targets.indexOf(l)];d=await ne({contentDir:e.contentDir,filePath:n,source:await e.io.readFile(A(e.contentDir,n)),configs:Object.fromEntries(o.levels.map(e=>[e.name,r?.[e.name]??t.levels[e.name]]))})}catch(e){return{value:await a(null),metadata:{sourcePath:t},problems:[{code:`scorecard/lint-failed`,message:`The scorecard could not lint this API: ${e instanceof Error?e.message:String(e)}`,location:{filePath:t}}],entityDeps:Y([n,...u])}}let f={...L(o,d.levels,c?.minimumLevel),title:await I(e.entities,t)??j.basename(n),relativePath:t,levels:d.levels};i.version!==null&&(f.version=i.version);let{levels:p,...m}=f,h={...m,levels:Object.fromEntries(Object.entries(p).map(([e,{problems:t,...n}])=>[e,n])),rules:O(p),sourcePath:t,route:i.slug};return{value:await a(f),metadata:h,entityDeps:Y([n,...d.files,...u])}});async function I(e,t){let n=await e.load(f(t)).catch(()=>void 0),r=o(n)&&o(n.info)?n.info:{};return typeof r.title==`string`?r.title:void 0}function L(e,t,n){let r=e.levels.map(e=>e.name),i=r.findIndex(e=>t[e].errors>0),a=i===-1?r.length:i,o=n??r[0],s=r.indexOf(o),c=`HIGHEST`;return a-1<s?c=`BELOW_MINIMUM`:s<r.length-1&&(c=`MINIMUM`),{scorecardLevel:a===0?ee:r[a-1],scorecardLevelIdx:a,targetLevel:o,status:c}}async function R(e,t){let n=await e.get(t);return n!==null&&(n.status!==`ready`||!T(n.metadata))&&(await e.load(t).catch(()=>void 0),n=await e.get(t)),n!==null&&T(n.metadata)?n.metadata:null}async function z(e){let t=[];for(let n of await e.list({type:S})){let r=await R(e,n.key);r!==null&&t.push(r)}return t}function B({sourcePath:e,route:t,...n}){return n}const V=n(ae,async e=>{let t=x(e.config),{perLevel:n,all:r}=await D({contentDir:e.contentDir,settings:t,plugins:J(e.contentDir).plugins,readFile:e.io.readFile}).then(e=>te(e.levels),()=>({perLevel:{},all:[]}));return{value:{levelNames:t.levels.map(e=>e.name),rules:r,rulesPerLevel:n}}}),H=n(oe,async e=>{let t=await e.entities.load(h(e.args.catalogId)),n=await e.entities.load(C),r=(await z(e.entities)).flatMap(t=>{let n=e.routes.get(t.route);return n?[{route:n,api:t}]:[]}),{versionGroups:i,entityDeps:a}=await _(r,e),o=new Map(r.map(({route:e,api:t})=>[d(e,i),B(t)])),s=[];for(let e of t.items){let t=o.get(e.link);t!==void 0&&s.push({...e,metadata:{...e.metadata,scorecard:t,scorecardLevel:t.scorecardLevel}})}let c={...t,items:s,scorecard:{...n,teamMetadataProperty:x(e.config).teamMetadataProperty}},l=JSON.stringify(c);return{value:l.length>65536?await e.createBlobRef(l,{format:`json`}):c,entityDeps:a}}),U=n(se,async e=>({value:(await z(e.entities)).map(e=>({route:e.route,metadata:{scorecardStatus:e.status,scorecardLevel:e.scorecardLevel,scorecardLevelIdx:e.scorecardLevelIdx,scorecardLevels:G(e)}}))})),W=n(ce,async e=>{let t=await R(e.entities,w(e.args.file)),n=t&&e.routes.get(t.route);if(!t||!n)return{value:null};let{versionGroups:r,entityDeps:i}=await _([{route:n}],e),a=d(n,r),o=q(e.config);if(o.length===0)return{value:null};let s=o[0].slug;if(o.length>1){for(let{catalogId:t,slug:n}of o)if((await e.entities.load(h(t))).items.some(e=>e.link===a)){s=n;break}}return{value:{scorecardLevel:t.scorecardLevel,scorecardLevelIdx:t.scorecardLevelIdx,scorecardLevels:G(t),scoreCardSlug:v(K(s),a)},entityDeps:i}});function G(e){return Object.fromEntries(Object.entries(e.levels).map(([e,t])=>[e,{uniqueErrors:t.uniqueErrors,uniqueWarnings:t.uniqueWarnings}]))}function K(e){return j.join(s(e),`scorecard`)}function q(e){return Object.entries(e.catalogClassic??e.catalog??{}).map(([e,t])=>({catalogId:e,slug:String(t.slug)}))}function J(e){let t=p(e)?.lintPlugins??[];return{plugins:t,paths:t.map(t=>u(M(e,t.path))).filter(e=>e!==``&&!e.startsWith(`../`))}}function Y(e){return[...new Set(e)].map(e=>({kind:`file`,path:e}))}function X(e){let t=e=>typeof e==`string`||typeof e==`number`;return t(e.manifest.openapi)||t(e.manifest.swagger)}function Z(e){let t=e.manifest[m];return o(t)&&typeof t.root==`string`?t.root:e.path}function Q(e){let t=Z(e);return F.withArgs(t===e.path?{}:{source:t},{stableKey:w(e.path),type:S,metadata:{sourcePath:e.path}})}function $(e,t){if(!X(e))return!1;let n=(t.scorecardClassic??t.scorecard)?.ignore??[];return n.length===0||!re([...n])(Z(e))}function le(e,t){let n=e.filter(e=>e.status===`BELOW_MINIMUM`).map(e=>e.relativePath);if(n.length===0)return;let r=n.slice(0,15).map(e=>`\n - ${e}`),i=n.length-r.length,a=`Detected OpenAPI definitions with score below minimum level:${r.join(``)}${i>0?`\n ... and ${i} more`:``}`;t.config.platform?.ignoreLint??(t.config.scorecardClassic??t.config.scorecard)?.ignoreNonCompliant?t.logger.warn(a):t.logger.error(a)}const ue=e({id:N,version:`2.3.0`,content:{filter:{extensions:[`.yaml`,`.yml`,`.json`]},extractFile(e,t){return $(e,t.config)?{routes:[],entities:[Q(e)]}:null},extractAll(e){let t=e.config.catalogClassic??e.config.catalog??{};if(!e.files.some(X)&&Object.keys(t).length===0)return{routes:[]};let n=x(e.config),r=[V.withArgs({},{stableKey:C})];n.isDefault||r.push(U.withArgs({},{stableKey:`scorecard-classic:card-metadata`,type:g}));let i=[];for(let[e,n]of Object.entries(t)){let t=K(String(n.slug)),a=H.withArgs({catalogId:e},{stableKey:E(e),metadata:{sourcePath:t}});r.push(a),i.push({deps:{[l]:a},metadata:{title:typeof n.title==`string`?n.title:`API design scorecard`},routeId:e,slug:t,template:P,wildcardPrefix:!0})}return{entities:r,routes:i}}},finalize(e){let t=q(e.config).length>0&&!x(e.config).isDefault,n=[],r=[],i=[];for(let a of e.files){let o=$(a,e.config)?e.routes.byFilePath(a.path):void 0;if(o===void 0||(n.push({path:y(a.path),producer:Q(a),audience:{routeSlug:o.slug}}),!t))continue;let s=W.withArgs({file:a.path},{stableKey:`scorecard-classic:badge:${o.slug}`});r.push(s),i.push({slug:o.slug,deps:{[c]:s}})}return{entities:r,attach:i,staticFiles:n}},async buildMetadata(e){if(await e.entities.get(`scorecard-classic:rules`)===null)return;let n=await e.entities.load(C),r=await z(e.entities),i={};for(let e of r){let{rules:t,...n}=B(e);i[e.relativePath]=n}return le(r,e),{scorecardData:i,...n,reuniteIgnoreLint:t(e.config.platform?.ignoreLint)}},loaders:[F,V,H,U,W],templates:{[P]:a(r(`./client/template.tsx`,import.meta.url))}});export{N as SCORECARD_CLASSIC_PLUGIN_ID,P as SCORECARD_CLASSIC_TEMPLATE_ID,ue as scorecardClassicContentPlugin};