@redocly/redoc-reef 0.140.0-next.6 → 0.140.0-next.7

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 (77) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/api-schemas/mcp-fetch-count.d.ts +2 -18
  3. package/dist/api-schemas/otel-traces.d.ts +7 -1345
  4. package/dist/api-schemas/otel-traces.js +1 -1
  5. package/dist/api-schemas/search-facets.d.ts +3 -31
  6. package/dist/api-schemas/search.d.ts +6 -52
  7. package/dist/cli/build/index.js +1 -1
  8. package/dist/cli/eject/resolveEjectParams.js +1 -1
  9. package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.d.ts +2 -0
  10. package/dist/client/app/markdoc/custom-components/openapi/openapi-code-sample.js +1 -1
  11. package/dist/compiled/@redocly/pii/index.mjs +1 -0
  12. package/dist/compiled/@redocly/pii/package.json +1 -1
  13. package/dist/markdoc/tags/openapi-code-sample.js +1 -1
  14. package/dist/server/api-routes/execute-api-route.js +1 -1
  15. package/dist/server/api-routes/run-api-routes-worker.js +1 -1
  16. package/dist/server/config/env-config.d.ts +24 -24
  17. package/dist/server/config/env-schema.d.ts +83 -326
  18. package/dist/server/config/env-schemas/api-urls.d.ts +2 -14
  19. package/dist/server/config/env-schemas/auth.d.ts +10 -32
  20. package/dist/server/config/env-schemas/catalog.d.ts +6 -9
  21. package/dist/server/config/env-schemas/database.d.ts +2 -8
  22. package/dist/server/config/env-schemas/environment-detection.d.ts +20 -18
  23. package/dist/server/config/env-schemas/feature-flags.d.ts +25 -33
  24. package/dist/server/config/env-schemas/organization-project.d.ts +3 -21
  25. package/dist/server/config/env-schemas/scorecards.d.ts +2 -6
  26. package/dist/server/config/env-schemas/search.d.ts +9 -15
  27. package/dist/server/config/env-schemas/server-config.d.ts +6 -31
  28. package/dist/server/config/env-schemas/site.d.ts +1 -5
  29. package/dist/server/config/env-schemas/ssr.d.ts +7 -12
  30. package/dist/server/config/env-schemas/telemetry.d.ts +1 -7
  31. package/dist/server/esbuild/plugins/themes-resolver.js +3 -3
  32. package/dist/server/external-plugins/resolve-external-plugins.js +1 -1
  33. package/dist/server/node-bundle-entry.js +1 -1
  34. package/dist/server/plugins/api-docs/index.js +1 -1
  35. package/dist/server/plugins/api-docs/spec-download.api.js +1 -1
  36. package/dist/server/plugins/api-docs/store-definition-bundles.d.ts +6 -0
  37. package/dist/server/plugins/api-docs/store-definition-bundles.js +1 -1
  38. package/dist/server/plugins/config-parser/index.js +1 -1
  39. package/dist/server/plugins/markdown/attribute-resolvers/resolve-openapi-code-samples.js +1 -1
  40. package/dist/server/plugins/mcp/codemode/tools/describe-tools.d.ts +1 -1
  41. package/dist/server/plugins/mcp/codemode/tools/describe-tools.js +1 -3
  42. package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
  43. package/dist/server/plugins/mcp/handlers/handle-mcp-request.js +1 -1
  44. package/dist/server/plugins/mcp/servers/docs-server.js +1 -1
  45. package/dist/server/plugins/mcp/servers/mcp-server.js +2 -2
  46. package/dist/server/plugins/mcp/types.d.ts +10 -0
  47. package/dist/server/plugins/mcp/utils/available-tools.d.ts +5 -0
  48. package/dist/server/plugins/mcp/utils/available-tools.js +1 -0
  49. package/dist/server/plugins/mcp/workers/worker-context.d.ts +4 -0
  50. package/dist/server/plugins/mcp/workers/worker-context.js +1 -0
  51. package/dist/server/plugins/scorecard-classic/template/Grid/GridHeader.js +3 -3
  52. package/dist/server/store-config.d.ts +33 -0
  53. package/dist/server/store-config.js +1 -0
  54. package/dist/server/store.d.ts +10 -15
  55. package/dist/server/store.js +1 -1
  56. package/dist/server/tools/notifiers/formatter.js +1 -1
  57. package/dist/server/types/plugins/api-routes.d.ts +4 -1
  58. package/dist/server/utils/envs/env-boolean-string.d.ts +9 -3
  59. package/dist/server/utils/envs/get-api-route-allowed-env-variables.d.ts +2 -0
  60. package/dist/server/utils/envs/get-api-route-allowed-env-variables.js +1 -1
  61. package/dist/server/utils/envs/interpolate-env-variables.d.ts +5 -1
  62. package/dist/server/utils/envs/interpolate-env-variables.js +1 -1
  63. package/dist/server/utils/envs/replace-env-variables-deep.d.ts +17 -9
  64. package/dist/server/utils/envs/replace-env-variables-deep.js +1 -1
  65. package/dist/server/web-server/middleware/jsonValidatorMiddleware.d.ts +556 -287
  66. package/dist/server/workers/mcp-tool-worker-methods.d.ts +7 -0
  67. package/dist/server/workers/mcp-tool-worker-methods.js +1 -0
  68. package/dist/server/workers/mcp-tool-worker-pool.d.ts +0 -1
  69. package/dist/server/workers/mcp-tool-worker-pool.js +1 -1
  70. package/dist/server/workers/mcp-tool-worker.js +1 -1
  71. package/dist/server/workers/types.d.ts +4 -8
  72. package/dist/server/workers/worker-config.d.ts +33 -0
  73. package/dist/server/workers/worker-config.js +1 -0
  74. package/package.json +8 -8
  75. package/dist/compiled/@redocly/pii/index.js +0 -1
  76. package/dist/server/plugins/mcp/utils/available-sandbox-tools.d.ts +0 -4
  77. package/dist/server/plugins/mcp/utils/available-sandbox-tools.js +0 -1
@@ -3,41 +3,33 @@ import { z } from 'zod';
3
3
  * Schema for feature flags.
4
4
  */
5
5
  export declare const featureFlagsSchema: z.ZodObject<{
6
- NEW_CATALOG_ENABLED: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false"]>>, boolean | undefined, "false" | "true" | undefined>;
7
- NEW_SCORECARDS_ENABLED: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false"]>>, boolean | undefined, "false" | "true" | undefined>;
6
+ NEW_CATALOG_ENABLED: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
7
+ false: "false";
8
+ true: "true";
9
+ }>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
10
+ NEW_SCORECARDS_ENABLED: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
11
+ false: "false";
12
+ true: "true";
13
+ }>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
8
14
  ENABLE_COMMENTS: z.ZodOptional<z.ZodString>;
9
- REDOCLY_EXP_DISABLE_MD_VALIDATION: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false"]>>, boolean | undefined, "false" | "true" | undefined>;
10
- ENABLE_SOURCE_MAPS: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false"]>>, boolean | undefined, "false" | "true" | undefined>;
15
+ REDOCLY_EXP_DISABLE_MD_VALIDATION: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
16
+ false: "false";
17
+ true: "true";
18
+ }>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
19
+ ENABLE_SOURCE_MAPS: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
20
+ false: "false";
21
+ true: "true";
22
+ }>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
11
23
  PLAN_GATES: z.ZodOptional<z.ZodString>;
12
- /** Experimental: append agent feedback instructions to llms.txt Markdown chunks. */
13
- REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_ENABLED: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false"]>>, boolean | undefined, "false" | "true" | undefined>;
14
- /** Optional URL for the agent feedback footer; defaults to `{seo.siteUrl|REDOCLY_PUBLIC_URL}/api/agent-feedback`, or `/api/agent-feedback` on the same origin. */
24
+ REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_ENABLED: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
25
+ false: "false";
26
+ true: "true";
27
+ }>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
15
28
  REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_URL: z.ZodOptional<z.ZodString>;
16
- /** (Optional) API endpoint for the agent feedback endpoint;**/
17
29
  REDOCLY_EXP_LLMSTXT_AGENT_ENDPOINT: z.ZodOptional<z.ZodString>;
18
- /** Experimental: enables the GraphQL request body in Try It and embedded Replay, and shows Try it on GraphQL operation pages. */
19
- REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false"]>>, boolean | undefined, "false" | "true" | undefined>;
20
- }, "strip", z.ZodTypeAny, {
21
- NEW_CATALOG_ENABLED?: boolean | undefined;
22
- NEW_SCORECARDS_ENABLED?: boolean | undefined;
23
- ENABLE_COMMENTS?: string | undefined;
24
- REDOCLY_EXP_DISABLE_MD_VALIDATION?: boolean | undefined;
25
- ENABLE_SOURCE_MAPS?: boolean | undefined;
26
- PLAN_GATES?: string | undefined;
27
- REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_ENABLED?: boolean | undefined;
28
- REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_URL?: string | undefined;
29
- REDOCLY_EXP_LLMSTXT_AGENT_ENDPOINT?: string | undefined;
30
- REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED?: boolean | undefined;
31
- }, {
32
- NEW_CATALOG_ENABLED?: "false" | "true" | undefined;
33
- NEW_SCORECARDS_ENABLED?: "false" | "true" | undefined;
34
- ENABLE_COMMENTS?: string | undefined;
35
- REDOCLY_EXP_DISABLE_MD_VALIDATION?: "false" | "true" | undefined;
36
- ENABLE_SOURCE_MAPS?: "false" | "true" | undefined;
37
- PLAN_GATES?: string | undefined;
38
- REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_ENABLED?: "false" | "true" | undefined;
39
- REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_URL?: string | undefined;
40
- REDOCLY_EXP_LLMSTXT_AGENT_ENDPOINT?: string | undefined;
41
- REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED?: "false" | "true" | undefined;
42
- }>;
30
+ REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
31
+ false: "false";
32
+ true: "true";
33
+ }>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
34
+ }, z.core.$strip>;
43
35
  //# sourceMappingURL=feature-flags.d.ts.map
@@ -1,30 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  export declare const organizationProjectSchema: z.ZodObject<{
3
- ORGANIZATION_ID: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
3
+ ORGANIZATION_ID: z.ZodOptional<z.ZodString>;
4
4
  ORGANIZATION_SLUG: z.ZodOptional<z.ZodString>;
5
5
  ORG_SLUG: z.ZodOptional<z.ZodString>;
6
- PROJECT_ID: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
6
+ PROJECT_ID: z.ZodOptional<z.ZodString>;
7
7
  PROJECT_SLUG: z.ZodOptional<z.ZodString>;
8
8
  PROJECT_URL: z.ZodOptional<z.ZodString>;
9
9
  PROJECT_BUILD_ID: z.ZodOptional<z.ZodString>;
10
10
  PUBLIC_REDOCLY_BRANCH_NAME: z.ZodOptional<z.ZodString>;
11
- }, "strip", z.ZodTypeAny, {
12
- ORGANIZATION_ID?: string | undefined;
13
- ORGANIZATION_SLUG?: string | undefined;
14
- ORG_SLUG?: string | undefined;
15
- PROJECT_ID?: string | undefined;
16
- PROJECT_SLUG?: string | undefined;
17
- PROJECT_URL?: string | undefined;
18
- PROJECT_BUILD_ID?: string | undefined;
19
- PUBLIC_REDOCLY_BRANCH_NAME?: string | undefined;
20
- }, {
21
- ORGANIZATION_ID?: string | undefined;
22
- ORGANIZATION_SLUG?: string | undefined;
23
- ORG_SLUG?: string | undefined;
24
- PROJECT_ID?: string | undefined;
25
- PROJECT_SLUG?: string | undefined;
26
- PROJECT_URL?: string | undefined;
27
- PROJECT_BUILD_ID?: string | undefined;
28
- PUBLIC_REDOCLY_BRANCH_NAME?: string | undefined;
29
- }>;
11
+ }, z.core.$strip>;
30
12
  //# sourceMappingURL=organization-project.d.ts.map
@@ -3,10 +3,6 @@ import { z } from 'zod';
3
3
  * Schema for scorecards configuration variables.
4
4
  */
5
5
  export declare const scorecardsSchema: z.ZodObject<{
6
- SCORECARDS_POLLING_INTERVAL_MS: z.ZodOptional<z.ZodString>;
7
- }, "strip", z.ZodTypeAny, {
8
- SCORECARDS_POLLING_INTERVAL_MS?: string | undefined;
9
- }, {
10
- SCORECARDS_POLLING_INTERVAL_MS?: string | undefined;
11
- }>;
6
+ SCORECARDS_POLLING_INTERVAL_MS: z.ZodOptional<z.ZodCoercedString<unknown>>;
7
+ }, z.core.$strip>;
12
8
  //# sourceMappingURL=scorecards.d.ts.map
@@ -4,21 +4,15 @@ import { z } from 'zod';
4
4
  */
5
5
  export declare const searchSchema: z.ZodObject<{
6
6
  SEARCH_DEV_REINIT: z.ZodOptional<z.ZodString>;
7
- SEARCH_DEV_DEBUG: z.ZodEffects<z.ZodDefault<z.ZodEnum<["true", "false"]>>, boolean, "false" | "true" | undefined>;
8
- REDOCLY_SKIP_TYPESENSE_INDEXING: z.ZodEffects<z.ZodDefault<z.ZodEnum<["true", "false"]>>, boolean, "false" | "true" | undefined>;
7
+ SEARCH_DEV_DEBUG: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
8
+ false: "false";
9
+ true: "true";
10
+ }>>, z.ZodTransform<boolean, "false" | "true">>;
11
+ REDOCLY_SKIP_TYPESENSE_INDEXING: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
12
+ false: "false";
13
+ true: "true";
14
+ }>>, z.ZodTransform<boolean, "false" | "true">>;
9
15
  TYPESENSE_API_URL: z.ZodOptional<z.ZodString>;
10
16
  TYPESENSE_API_KEY: z.ZodOptional<z.ZodString>;
11
- }, "strip", z.ZodTypeAny, {
12
- SEARCH_DEV_REINIT?: string | undefined;
13
- SEARCH_DEV_DEBUG: boolean;
14
- REDOCLY_SKIP_TYPESENSE_INDEXING: boolean;
15
- TYPESENSE_API_URL?: string | undefined;
16
- TYPESENSE_API_KEY?: string | undefined;
17
- }, {
18
- SEARCH_DEV_REINIT?: string | undefined;
19
- SEARCH_DEV_DEBUG?: "false" | "true" | undefined;
20
- REDOCLY_SKIP_TYPESENSE_INDEXING?: "false" | "true" | undefined;
21
- TYPESENSE_API_URL?: string | undefined;
22
- TYPESENSE_API_KEY?: string | undefined;
23
- }>;
17
+ }, z.core.$strip>;
24
18
  //# sourceMappingURL=search.d.ts.map
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
3
  * Schema for server configuration variables.
4
4
  */
5
5
  export declare const serverConfigSchema: z.ZodObject<{
6
- PORT: z.ZodOptional<z.ZodNumber>;
6
+ PORT: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
7
7
  REDOCLY_LOG_FORMAT: z.ZodOptional<z.ZodString>;
8
8
  REDOCLY_LOG_LEVEL: z.ZodOptional<z.ZodString>;
9
9
  TERM: z.ZodOptional<z.ZodString>;
@@ -12,37 +12,12 @@ export declare const serverConfigSchema: z.ZodObject<{
12
12
  REDOCLY_CONTENT_DIR: z.ZodOptional<z.ZodString>;
13
13
  REDOCLY_PORTAL_VERSION: z.ZodOptional<z.ZodString>;
14
14
  REDOCLY_TELEMETRY: z.ZodOptional<z.ZodString>;
15
- TELEMETRY_DEV_DEBUG: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false"]>>, boolean | undefined, "false" | "true" | undefined>;
15
+ TELEMETRY_DEV_DEBUG: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
16
+ false: "false";
17
+ true: "true";
18
+ }>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
16
19
  WEB_SERVER_IDLE_TIMEOUT: z.ZodOptional<z.ZodString>;
17
20
  REDOCLY_PROBLEMS_OUTPUT_FILE: z.ZodOptional<z.ZodString>;
18
21
  REDOCLY_METADATA_OUTPUT_FOLDER: z.ZodOptional<z.ZodString>;
19
- }, "strip", z.ZodTypeAny, {
20
- PORT?: number | undefined;
21
- REDOCLY_LOG_FORMAT?: string | undefined;
22
- REDOCLY_LOG_LEVEL?: string | undefined;
23
- TERM?: string | undefined;
24
- INSPECT_MODE?: string | undefined;
25
- REDOCLY_PREFIX_PATHS?: string | undefined;
26
- REDOCLY_CONTENT_DIR?: string | undefined;
27
- REDOCLY_PORTAL_VERSION?: string | undefined;
28
- REDOCLY_TELEMETRY?: string | undefined;
29
- TELEMETRY_DEV_DEBUG?: boolean | undefined;
30
- WEB_SERVER_IDLE_TIMEOUT?: string | undefined;
31
- REDOCLY_PROBLEMS_OUTPUT_FILE?: string | undefined;
32
- REDOCLY_METADATA_OUTPUT_FOLDER?: string | undefined;
33
- }, {
34
- PORT?: number | undefined;
35
- REDOCLY_LOG_FORMAT?: string | undefined;
36
- REDOCLY_LOG_LEVEL?: string | undefined;
37
- TERM?: string | undefined;
38
- INSPECT_MODE?: string | undefined;
39
- REDOCLY_PREFIX_PATHS?: string | undefined;
40
- REDOCLY_CONTENT_DIR?: string | undefined;
41
- REDOCLY_PORTAL_VERSION?: string | undefined;
42
- REDOCLY_TELEMETRY?: string | undefined;
43
- TELEMETRY_DEV_DEBUG?: "false" | "true" | undefined;
44
- WEB_SERVER_IDLE_TIMEOUT?: string | undefined;
45
- REDOCLY_PROBLEMS_OUTPUT_FILE?: string | undefined;
46
- REDOCLY_METADATA_OUTPUT_FOLDER?: string | undefined;
47
- }>;
22
+ }, z.core.$strip>;
48
23
  //# sourceMappingURL=server-config.d.ts.map
@@ -4,9 +4,5 @@ import { z } from 'zod';
4
4
  */
5
5
  export declare const siteSchema: z.ZodObject<{
6
6
  SITE_URL: z.ZodOptional<z.ZodString>;
7
- }, "strip", z.ZodTypeAny, {
8
- SITE_URL?: string | undefined;
9
- }, {
10
- SITE_URL?: string | undefined;
11
- }>;
7
+ }, z.core.$strip>;
12
8
  //# sourceMappingURL=site.d.ts.map
@@ -3,16 +3,11 @@ import { z } from 'zod';
3
3
  * Schema for SSR (Server-Side Rendering) configuration variables.
4
4
  */
5
5
  export declare const ssrSchema: z.ZodObject<{
6
- REDOCLY_SSR_RENDER_MODE: z.ZodOptional<z.ZodEnum<["worker", "main"]>>;
7
- REDOCLY_SSR_WORKERS_MIN: z.ZodOptional<z.ZodNumber>;
8
- REDOCLY_SSR_WORKERS_MAX: z.ZodOptional<z.ZodNumber>;
9
- }, "strip", z.ZodTypeAny, {
10
- REDOCLY_SSR_RENDER_MODE?: "main" | "worker" | undefined;
11
- REDOCLY_SSR_WORKERS_MIN?: number | undefined;
12
- REDOCLY_SSR_WORKERS_MAX?: number | undefined;
13
- }, {
14
- REDOCLY_SSR_RENDER_MODE?: "main" | "worker" | undefined;
15
- REDOCLY_SSR_WORKERS_MIN?: number | undefined;
16
- REDOCLY_SSR_WORKERS_MAX?: number | undefined;
17
- }>;
6
+ REDOCLY_SSR_RENDER_MODE: z.ZodOptional<z.ZodEnum<{
7
+ main: "main";
8
+ worker: "worker";
9
+ }>>;
10
+ REDOCLY_SSR_WORKERS_MIN: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
11
+ REDOCLY_SSR_WORKERS_MAX: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
12
+ }, z.core.$strip>;
18
13
  //# sourceMappingURL=ssr.d.ts.map
@@ -5,11 +5,5 @@ import { z } from 'zod';
5
5
  export declare const telemetrySchema: z.ZodObject<{
6
6
  OTEL_TRACES_URL: z.ZodOptional<z.ZodString>;
7
7
  REQUEST_ID: z.ZodOptional<z.ZodString>;
8
- }, "strip", z.ZodTypeAny, {
9
- OTEL_TRACES_URL?: string | undefined;
10
- REQUEST_ID?: string | undefined;
11
- }, {
12
- OTEL_TRACES_URL?: string | undefined;
13
- REQUEST_ID?: string | undefined;
14
- }>;
8
+ }, z.core.$strip>;
15
9
  //# sourceMappingURL=telemetry.d.ts.map
@@ -1,4 +1,4 @@
1
- import*as c from"node:path";import{CONFIG_FILE_NAME as x,DEFAULT_THEME_NAME as $,USER_THEME_ALIAS as y}from"../../../constants/common.js";import{isDefined as g}from"../../../utils/guards/is-defined.js";import{slash as D}from"../../../utils/path/slash.js";import{resolveExternalPlugins as p}from"../../external-plugins/resolve-external-plugins.js";import{generateMarkdocComponentsEntry as L,generateMarkdocSchemasEntry as M}from"./codegen/index.js";const d=new Map,S=(a,o)=>{const h=c.resolve(o,y),i=c.resolve(o,x),k=["components","core","layouts","markdoc","icons","config","ext"],R="@redocly\\/theme\\/",w=k.map(s=>`${R}${s}`).join("|"),E=new RegExp(`^(@redocly/theme$|${w})`);return{name:"esbuild-redocly-custom-themes-resolver",setup:s=>{s.onResolve({filter:/@redocly-markdoc\/schema/},async e=>{const r=(await p(o,a.config.plugins)).flatMap(n=>n.markdoc?.schemaFile).filter(g);return{namespace:"markdoc-schema-ns",path:e.path,watchFiles:[...r,i],watchDirs:[c.resolve(h,"markdoc")],pluginData:{schemaFiles:r}}}),s.onLoad({filter:/@redocly-markdoc\/schema/,namespace:"markdoc-schema-ns"},({pluginData:e})=>({contents:M(e),resolveDir:"/",loader:"ts"})),s.onResolve({filter:/@redocly-markdoc\/components/},async e=>{const r=[...(await p(o,a.config.plugins)).map(n=>n.markdoc?.componentsFile).filter(g)];return{namespace:"markdoc-schema-ns",path:e.path,watchFiles:[...r,i],pluginData:{componentsFiles:r},watchDirs:[c.resolve(h,"markdoc")]}}),s.onLoad({filter:/@redocly-markdoc\/components/,namespace:"markdoc-schema-ns"},({pluginData:e})=>({contents:L(e),resolveDir:"/",loader:"ts"})),s.onResolve({filter:/@styles/},async e=>{const r=(await p(o,a.config.plugins)).map(n=>n.stylesFile).filter(Boolean);return{namespace:"user-styles-ns",path:e.path,watchFiles:[...r,i],pluginData:{styleFiles:r},watchDirs:[h]}}),s.onLoad({filter:/@styles/,namespace:"user-styles-ns"},async({pluginData:e})=>{const{styleFiles:t}=e;return{contents:t.map(n=>`@import url("${D(c.relative(o,n))}");`).join(`
2
- `),loader:"css",resolveDir:o}}),s.onResolve({filter:/(^|\/)styles\.css$/},async({path:e,...t})=>{if(t.pluginData==="missing-styles-ns")return;const r=await s.resolve(e,{...t,pluginData:"missing-styles-ns"});return r.errors.length&&r.errors.some(n=>n.text.match(/^Could not resolve .*?\bstyles.css\b/))?{namespace:"missing-styles-ns",path:e}:r}),s.onLoad({filter:/(^|\/)styles\.css$/,namespace:"missing-styles-ns"},async()=>({contents:"",loader:"css"})),s.onResolve({filter:/^react-router-dom$/},()=>({namespace:"react-router-dom-ns",path:"react-router-dom"})),s.onLoad({filter:/^react-router-dom$/,namespace:"react-router-dom-ns"},async()=>{const e=await s.resolve("@redocly/theme/package.json",{resolveDir:o,kind:"require-resolve"});return{contents:`import * as ReactRouter from 'react-router';
1
+ import*as m from"node:path";import{CONFIG_FILE_NAME as D,DEFAULT_THEME_NAME as g,USER_THEME_ALIAS as d}from"../../../constants/common.js";import{isDefined as k}from"../../../utils/guards/is-defined.js";import{slash as $}from"../../../utils/path/slash.js";import{resolveExternalPlugins as i}from"../../external-plugins/resolve-external-plugins.js";import{generateMarkdocComponentsEntry as L,generateMarkdocSchemasEntry as M}from"./codegen/index.js";const y=new Map,S=(a,n)=>{const h=m.resolve(n,d),p=m.resolve(n,D),R=["components","core","layouts","markdoc","icons","config","ext"],w="@redocly\\/theme\\/",E=R.map(t=>`${w}${t}`).join("|"),F=new RegExp(`^(@redocly/theme$|${E})`);return{name:"esbuild-redocly-custom-themes-resolver",setup:t=>{t.onResolve({filter:/@redocly-markdoc\/schema/},async e=>{const s=(await i(n,a.config.plugins)).flatMap(r=>r.markdoc?.schemaFile).filter(k);return{namespace:"markdoc-schema-ns",path:e.path,watchFiles:[...s,p],watchDirs:[m.resolve(h,"markdoc")],pluginData:{schemaFiles:s}}}),t.onLoad({filter:/@redocly-markdoc\/schema/,namespace:"markdoc-schema-ns"},({pluginData:e})=>({contents:M(e),resolveDir:"/",loader:"ts"})),t.onResolve({filter:/@redocly-markdoc\/components/},async e=>{const s=[...(await i(n,a.config.plugins)).map(r=>r.markdoc?.componentsFile).filter(k)];return{namespace:"markdoc-schema-ns",path:e.path,watchFiles:[...s,p],pluginData:{componentsFiles:s},watchDirs:[m.resolve(h,"markdoc")]}}),t.onLoad({filter:/@redocly-markdoc\/components/,namespace:"markdoc-schema-ns"},({pluginData:e})=>({contents:L(e),resolveDir:"/",loader:"ts"})),t.onResolve({filter:/@styles/},async e=>{const s=(await i(n,a.config.plugins)).map(r=>r.stylesFile).filter(Boolean);return{namespace:"user-styles-ns",path:e.path,watchFiles:[...s,p],pluginData:{styleFiles:s},watchDirs:[h]}}),t.onLoad({filter:/@styles/,namespace:"user-styles-ns"},async({pluginData:e})=>{const{styleFiles:o}=e;return{contents:o.map(r=>`@import url("${$(m.relative(n,r))}");`).join(`
2
+ `),loader:"css",resolveDir:n}}),t.onResolve({filter:/(^|\/)styles\.css$/},async({path:e,...o})=>{if(o.pluginData==="missing-styles-ns")return;const s=await t.resolve(e,{...o,pluginData:"missing-styles-ns"});return s.errors.length&&s.errors.some(r=>r.text.match(/^Could not resolve .*?\bstyles.css\b/))?{namespace:"missing-styles-ns",path:e}:s}),t.onLoad({filter:/(^|\/)styles\.css$/,namespace:"missing-styles-ns"},async()=>({contents:"",loader:"css"})),t.onResolve({filter:/^react-router-dom$/},()=>({namespace:"react-router-dom-ns",path:"react-router-dom"})),t.onLoad({filter:/^react-router-dom$/,namespace:"react-router-dom-ns"},async()=>{const o=(await i(n,a.config.plugins)).find(({name:c})=>c===g),s=await t.resolve("@redocly/theme/package.json",{resolveDir:o?.pluginDirAbsolutePath??n,kind:"require-resolve"});return{contents:`import * as ReactRouter from 'react-router';
3
3
  export const useLocation = ReactRouter.useLocation;
4
- export const useInRouterContext = ReactRouter.useInRouterContext;`,loader:"js",resolveDir:e.errors.length?o:c.dirname(e.path)}}),s.onResolve({filter:E},async e=>{if(e.resolveDir==="")return;const t=`${e.path}:${e.importer}`;if(d.has(t))return d.get(t);const{path:r,...n}=e,l=await p(o,a.config.plugins),u=e.path.replace($,"")||"index";for(let m=l.length-1;m>=0;m--){const F=l[m].isNpmPackage?[c.join(l[m].name,"src",u),{...n,resolveDir:o}]:[`./${u}`,{...n,resolveDir:l[m].pluginDirAbsolutePath}],f=C(await s.resolve(...F));if("path"in f&&f.path!==e.importer){const v={...f,watchFiles:[i,c.join(o,y,u+".tsx")]};return l[m].name===y||d.set(t,v),v}}})}}};function C(a){return a.errors.length?{errors:a.errors}:a}export{S as ThemesResolver,d as resolveCache};
4
+ export const useInRouterContext = ReactRouter.useInRouterContext;`,loader:"js",resolveDir:s.errors.length?n:m.dirname(s.path)}}),t.onResolve({filter:F},async e=>{if(e.resolveDir==="")return;const o=`${e.path}:${e.importer}`;if(y.has(o))return y.get(o);const{path:s,...r}=e,c=await i(n,a.config.plugins),u=e.path.replace(g,"")||"index";for(let l=c.length-1;l>=0;l--){const x=c[l].isNpmPackage?[m.join(c[l].name,"src",u),{...r,resolveDir:c[l].pluginDirAbsolutePath}]:[`./${u}`,{...r,resolveDir:c[l].pluginDirAbsolutePath}],f=T(await t.resolve(...x));if("path"in f&&f.path!==e.importer){const v={...f,watchFiles:[p,m.join(n,d,u+".tsx")]};return c[l].name===d||y.set(o,v),v}}})}}};function T(a){return a.errors.length?{errors:a.errors}:a}export{S as ThemesResolver,y as resolveCache};
@@ -1 +1 @@
1
- import{existsSync as f}from"node:fs";import n from"node:path";import{resolvePlugins as g}from"@redocly/openapi-core";import{DEFAULT_PROJECT_PLUGIN_PATHS as m,DEFAULT_THEME_PLUGIN_PATH as d,STYLES_FILE as p}from"../constants/common.js";import{GATED_PLUGINS as P}from"../constants/entitlements.js";import{isDefined as y}from"../../utils/guards/is-defined.js";import{reporter as E}from"../tools/notifiers/reporter.js";import{sha as F}from"../utils/crypto/sha.js";import{resolveModule as C}from"./resolve-module.js";import{EntitlementsProvider as D}from"../entitlements/entitlements-provider.js";const u={sha:"",value:Promise.resolve({resolvedPlugins:[],errors:[]})};async function M(e,t=[]){const r=F(JSON.stringify(t));if(u.sha!==r){u.sha=r;const s=j(e,t),l=await g(s,e)||[];if(!s.some(i=>m.includes(i))){const i=m[0],a=n.join(e,i);l.push({id:"",absolutePath:a,path:i})}u.value=Promise.all(l.map(i=>A(i))).then(i=>{const a=i.filter(y),h=a.filter(c=>c?.type&&["error","warning"].includes(c.type)),v=a.filter(c=>c.type==="resolvedPlugin");return{errors:h,resolvedPlugins:v}})}const o=await u.value;if(o.errors.length)for(let s=0;s<o.errors.length;s++)await E.panicOnBuildContentError(o.errors[s].error);return o.resolvedPlugins}function j(e,t=[]){const r=[...t];for(const o of m)!r.includes(o)&&f(n.join(e,o))&&r.push(o);return r.includes(d)||r.unshift(d),r}async function A(e){if(!e.absolutePath||!e.path)return{type:"error",error:`Plugin with path "${e}" not found`};const t=n.dirname(e.absolutePath),{lifecyclePlugin:r,config:o}=L(e);return{name:n.dirname(e.path),type:"resolvedPlugin",isNpmPackage:I(e.path),pluginDirAbsolutePath:t,lifecyclePlugin:r,config:o,stylesFile:n.resolve(t,p),markdoc:S(t)}}function I(e){const t=n.dirname(e);return C(n.join(t,"package.json"))!=null}function L(e){const t=D.instance(),r=e.path||"",o=!t.canAccessFeature("customPlugins")&&!P.includes(r),s=e.requiredEntitlements&&P.includes(r)&&!e.requiredEntitlements.every(l=>t.canAccessFeature(l));return o||s?{lifecyclePlugin:{id:e.id},config:{}}:{lifecyclePlugin:{id:e.id,processContent:e.processContent,afterRoutesCreated:e.afterRoutesCreated,loaders:e.loaders,requiredEntitlements:e.requiredEntitlements},config:{schema:e.redoclyConfigSchema,ejectIgnore:e.ejectIgnore}}}function S(e){const t=n.resolve(e,"markdoc"),r=n.join(t,"schema.ts");if(!f(r))return null;const o=n.join(t,"components.tsx");return{schemaFile:r,componentsFile:f(o)?o:void 0}}export{M as resolveExternalPlugins};
1
+ import{existsSync as m,readFileSync as F}from"node:fs";import{createRequire as k}from"node:module";import s from"node:path";import{resolvePlugins as A}from"@redocly/openapi-core";import{DEFAULT_PROJECT_PLUGIN_PATHS as d,DEFAULT_THEME_PLUGIN_PATH as c,STYLES_FILE as S}from"../constants/common.js";import{GATED_PLUGINS as v}from"../constants/entitlements.js";import{DEFAULT_THEME_NAME as h}from"../../constants/common.js";import{isDefined as _}from"../../utils/guards/is-defined.js";import{isPlainObject as g}from"../../utils/guards/is-plain-object.js";import{logger as C}from"../tools/notifiers/logger.js";import{reporter as L}from"../tools/notifiers/reporter.js";import{sha as w}from"../utils/crypto/sha.js";import{resolveModule as P}from"./resolve-module.js";import{EntitlementsProvider as I}from"../entitlements/entitlements-provider.js";const f={sha:"",value:Promise.resolve({resolvedPlugins:[],errors:[]})};async function ee(e,r=[]){const n=w(JSON.stringify(r));if(f.sha!==n){f.sha=n;const o=M(e),a=N(e,r,o),p=await A(a,e)||[];if(!a.some(i=>d.includes(i))){const i=d[0],l=s.join(e,i);p.push({id:"",absolutePath:l,path:i})}f.value=Promise.all(p.map(i=>b(i,i.path===o?c:i.path))).then(i=>{const l=i.filter(_),j=l.filter(u=>u?.type&&["error","warning"].includes(u.type)),D=l.filter(u=>u.type==="resolvedPlugin");return{errors:j,resolvedPlugins:D}})}const t=await f.value;if(t.errors.length)for(let o=0;o<t.errors.length;o++)await L.panicOnBuildContentError(t.errors[o].error);return t.resolvedPlugins}function M(e){const r=s.resolve(e,"package.json");if(!y(s.dirname(r)))return P(c)??c;const n=E(o=>k(r).resolve(o)),t=E(P);return n&&t&&n!==t&&C.warn("The project declares %s %s, and Realm uses it instead of the %s it was built with.",h,n,t),c}function y(e){const r=T(s.join(e,"package.json")),n=[r?.dependencies,r?.devDependencies].some(o=>g(o)&&h in o),t=s.dirname(e);return n||t!==e&&y(t)}function E(e){try{const r=e(`${h}/package.json`),n=r&&T(r)?.version;return typeof n=="string"?n:void 0}catch{return}}function T(e){try{const r=JSON.parse(F(e,"utf8"));return g(r)?r:void 0}catch{return}}function N(e,r=[],n){const t=[...r];for(const o of d)!t.includes(o)&&m(s.join(e,o))&&t.push(o);return t.includes(c)||t.unshift(n),t}async function b(e,r){if(!e.absolutePath||!r)return{type:"error",error:`Plugin with path "${e}" not found`};const n=s.dirname(e.absolutePath),{lifecyclePlugin:t,config:o}=R(e,r);return{name:s.dirname(r),type:"resolvedPlugin",isNpmPackage:O(r),pluginDirAbsolutePath:n,lifecyclePlugin:t,config:o,stylesFile:s.resolve(n,S),markdoc:U(n)}}function O(e){const r=s.dirname(e);return P(s.join(r,"package.json"))!=null}function R(e,r){const n=I.instance(),t=!n.canAccessFeature("customPlugins")&&!v.includes(r),o=e.requiredEntitlements&&v.includes(r)&&!e.requiredEntitlements.every(a=>n.canAccessFeature(a));return t||o?{lifecyclePlugin:{id:e.id},config:{}}:{lifecyclePlugin:{id:e.id,processContent:e.processContent,afterRoutesCreated:e.afterRoutesCreated,loaders:e.loaders,requiredEntitlements:e.requiredEntitlements},config:{schema:e.redoclyConfigSchema,ejectIgnore:e.ejectIgnore}}}function U(e){const r=s.resolve(e,"markdoc"),n=s.join(r,"schema.ts");if(!m(n))return null;const t=s.join(r,"components.tsx");return{schemaFile:n,componentsFile:m(t)?t:void 0}}export{ee as resolveExternalPlugins};
@@ -1 +1 @@
1
- import{resolve as n,dirname as f}from"node:path";import{fileURLToPath as l}from"node:url";import{readFile as u}from"fs/promises";import{createReadStream as d}from"fs";import{envConfig as v}from"./config/env-config.js";import{telemetry as g}from"./telemetry/index.js";import{createRouter as S}from"./web-server/router.js";import{installProdRoutes as R}from"./web-server/routes/index.js";import{Store as x}from"./store.js";import{loadEnvVariables as D}from"./utils/envs/load-env-variables.js";import{startHttpServer as P}from"./web-server/http.js";import{readStaticData as w}from"./utils/static-data.js";import{startIdleTimeout as E}from"./web-server/middleware/idleTimeoutMiddleware.js";import{reporter as y}from"./tools/notifiers/reporter.js";import{logger as b}from"./tools/notifiers/logger.js";import{EntitlementsProvider as h}from"./entitlements/entitlements-provider.js";import{DatabasePreconnectService as I}from"./providers/database/database-preconnect-service.js";import{KvService as O}from"./persistence/kv/services/kv-service.js";import{runScorecardsWorker as N}from"./plugins/scorecards/workers/run-scorecards-worker.js";import{isScorecardsEnabled as T}from"./utils/is-scorecards-enabled.js";import{isRealmOrReef as k}from"./utils/is-realm-or-reef.js";import{renderPage as or}from"./ssr/index.js";const A=new URL(import.meta.url),F=A.searchParams.get("only-exports")==="true";if(!F){let p=function(){const r=process.argv.findIndex(i=>i==="--port"||i==="-p");if(r===-1)return null;const t=process.argv[r+1];if(t.startsWith("-"))return null;const o=parseInt(t,10);return isNaN(o)?null:o};const e=f(l(import.meta.url));await D(e);const s=JSON.parse(await u(n(e,"./store.json"),"utf-8")),m=x.fromJson(s,{outdir:n(e,"../client"),serverOutDir:e,serverMode:!0,contentDir:""});if(await h.instance().init({ignoreTokenExpiration:!0}),k()){await I.init(e);const r=await O.getInstance({baseDbDir:e});setInterval(()=>{r.clearExpired().catch(t=>{b.error("Failed to clear expired KV entries",t)})},300*1e3)}c(m).catch(r=>{console.error(r)});async function c(r){g.initialize();const t=S();R(t,r,{readStaticAsset:async a=>d(a),resolveRouteData:async a=>w(a.slug,r.outdir)}),y.printErrors();const o=p(),i=v.PORT;return await P(t,o??i??4e3),E(),T(r.config)&&N(r.serverOutDir,r.config.scorecards),t}}export{or as renderPage};
1
+ import{resolve as c,dirname as p}from"node:path";import{fileURLToPath as f}from"node:url";import{createReadStream as l}from"fs";import{envConfig as u}from"./config/env-config.js";import{telemetry as d}from"./telemetry/index.js";import{createRouter as v}from"./web-server/router.js";import{installProdRoutes as g}from"./web-server/routes/index.js";import{Store as S}from"./store.js";import{loadEnvVariables as R}from"./utils/envs/load-env-variables.js";import{startHttpServer as x}from"./web-server/http.js";import{readStaticData as D}from"./utils/static-data.js";import{startIdleTimeout as P}from"./web-server/middleware/idleTimeoutMiddleware.js";import{reporter as w}from"./tools/notifiers/reporter.js";import{logger as E}from"./tools/notifiers/logger.js";import{EntitlementsProvider as y}from"./entitlements/entitlements-provider.js";import{DatabasePreconnectService as b}from"./providers/database/database-preconnect-service.js";import{KvService as h}from"./persistence/kv/services/kv-service.js";import{runScorecardsWorker as I}from"./plugins/scorecards/workers/run-scorecards-worker.js";import{isScorecardsEnabled as O}from"./utils/is-scorecards-enabled.js";import{isRealmOrReef as T}from"./utils/is-realm-or-reef.js";import{renderPage as rr}from"./ssr/index.js";const k=new URL(import.meta.url),A=k.searchParams.get("only-exports")==="true";if(!A){let s=function(){const r=process.argv.findIndex(i=>i==="--port"||i==="-p");if(r===-1)return null;const t=process.argv[r+1];if(t.startsWith("-"))return null;const o=parseInt(t,10);return isNaN(o)?null:o};const e=p(f(import.meta.url));await R(e);const n=await S.fromServerFiles({outdir:c(e,"../client"),serverOutDir:e,serverMode:!0,contentDir:""});if(await y.instance().init({ignoreTokenExpiration:!0}),T()){await b.init(e);const r=await h.getInstance({baseDbDir:e});setInterval(()=>{r.clearExpired().catch(t=>{E.error("Failed to clear expired KV entries",t)})},300*1e3)}m(n).catch(r=>{console.error(r)});async function m(r){d.initialize();const t=v();g(t,r,{readStaticAsset:async a=>l(a),resolveRouteData:async a=>D(a.slug,r.outdir)}),w.printErrors();const o=s(),i=u.PORT;return await x(t,o??i??4e3),P(),O(r.config)&&I(r.serverOutDir,r.config.scorecards),t}}export{rr as renderPage};
@@ -1 +1 @@
1
- import{REDOCLY_ROUTE_RBAC as C,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{mcpTagSchemas as ot,schemaDefinitionTag as rt,markdocParser as U}from"@redocly/api-docs";import{withPathPrefix as $}from"@redocly/theme/core/utils";import{API_DOCS_TEMPLATE_ID as j,GRAPHQL_SPEC_SLUG as at,PUBLIC_RBAC_SCOPE_ITEM as N}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as st,PUBLIC_API_DEFINITIONS_FOLDER as it}from"../../constants/common.js";import{API_DOCS_SHARED_DATA_PREFIX as E}from"../../constants/plugins/api-docs.js";import{fromCurrentDir as nt}from"../../utils/paths.js";import{normalizeRouteSlug as ct}from"../../../utils/path/normalize-route-slug.js";import{removeTrailingSlash as pt}from"../../../utils/url/remove-trailing-slash.js";import{isTranslationFallback as ut}from"../../fs/utils/is-translation-fallback.js";import{createSlugify as lt}from"../create-slugify.js";import{apiDocLoader as dt,apiDocsLoader as mt}from"./loader.js";import{getTemplatePath as V}from"./get-template-path.js";import{storeDefinitionBundles as ft}from"./store-definition-bundles.js";import{telemetryTraceStep as gt}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as ht}from"./search/search-resolver.js";import{getAiDocumentsStore as Dt}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as St}from"../get-api-config.js";import{getRouteSlugsForPath as Pt}from"../utils.js";import{collectItemRoutes as yt}from"./utils/collect-item-routes.js";import{isChunkCurrent as It}from"./utils/decorators.js";import{applyNavItemToRoot as At}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as vt}from"./utils/build-routes-mapping.js";import{buildItemPositions as bt}from"./utils/build-item-positions.js";import{resolveApiDocTitle as Rt}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as W}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as _t}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as Ct}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as Q}from"./import-api-docs-builder.js";import{envConfig as G}from"../../config/env-config.js";import{logger as Tt}from"../../tools/notifiers/logger.js";const k="openapi-spec-download",wt={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function de(){let e=[],r=new Map;const s=new WeakMap;let n=new Set,m={};function O(o,D,v){const y=s.get(o)??new Map;s.set(o,y);const S=D??"";return y.get(S)===v?!1:(y.set(S,v),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":dt,"api-docs":mt},processContent:async(o,D)=>{await gt("com.redocly.build.plugin.apiDocs",async()=>{o.createRequestHandler(k,nt(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:it+"/*",requestHandlerId:k,httpMethod:"all",[A]:N,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:st+"/*",requestHandlerId:k,httpMethod:"all",[A]:N,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:at+"/*",requestHandlerId:k,httpMethod:"all",[A]:N,getStaticData:async()=>({props:{}})});const v=o.createTemplate(j,V("../../../client/templates/api-docs/template.js")),y=o.registerServerPropsGetter(j,V("./get-server-props.js")),S=await D.getConfig();r=new Map,m={};const I=await o.loadApiDocuments(D);ft(I,o.outdir);const T=!!S.plugins?.some(t=>typeof t=="string"&&t.startsWith("@redocly/portal-plugin-async-api/"));T&&I.some(t=>t.type==="asyncapi")&&Tt.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=T?I.filter(t=>t.type!=="asyncapi"):I;e=c.map(({markdocChunks:t,relativePath:P,isVirtual:p,customOutputRelativeFile:a,realRelativePath:h})=>({chunks:t??[],relativePath:P,realRelativePath:h,isVirtual:a!=null||p}));const{buildItems:i}=await Q(o.serverOutDir),f=(await D.cache.load("content-slugs","content-slugs")).data,g=lt(f),F=t=>ct(g(t));for(const t of c){const P=t.customOutputRelativeFile||t.relativePath,p=F(P);Ot(t,p);const{items:a,store:h}=await i({type:t.type,document:t.document,options:t.options,basePath:p,markdownParser:U}),b=`${E}${t.relativePath}`,M=G.isDevelopMode?t.relativePath:void 0,u=Mt(t.document),R=u?.["x-metadata"],_=t.isVirtual?void 0:R?.apiId,L={document:t,basePath:p,sourcePath:M,apiId:_,build:{items:a,store:h}};await o.createSharedData(b,z(L,a,h));const Y=W(t.config),B=!!t.options.excludeFromSearch,X=t.type==="openapi",J=yt(a,Y),Z=ut(t),d=J.map(l=>{const x=l.metadata?.seo,w={fsPath:P,templateId:v,sharedData:[{key:"apiDocsStore",id:b}],serverPropsGetterIds:[y],excludeFromSearch:B,getStaticData:kt(l.label,x,Z),[A]:l[A]};return Object.assign(w,Ft(l.link,p)),X&&l.httpVerb&&(w.httpVerb=l.httpVerb,w.metadata={subType:"openapi-operation"}),w});if(!d.length)continue;const H=Rt(u,t.type,a),tt=Ct(u?.version),q={type:t.type,title:H,version:tt,description:typeof u?.description=="string"?u.description:void 0,summary:typeof u?.summary=="string"?u.summary:void 0,...u?.["x-metadata"]&&typeof u["x-metadata"]=="object"?u["x-metadata"]:{}};d[0]={...d[0],metadata:q,hasClientRoutes:!0,getSidebar:(l,x)=>At(K(a),p,x),getNavText:()=>H??wt[t.type]??"API Docs",getSearchDocuments:ht(a,q,o.getSearchFacets,o.setSearchFacets,B,h,t.document),getAiDocumentsStore:Dt({getBuild:()=>L.build,metadata:q,document:t.document,specType:t.type,excludeFromSearch:B,basePath:p,getSearchFacets:o.getSearchFacets,markdocTags:{...ot,schemaDefinition:rt}})};const et=d[0];d[0]=d[d.length-1],d[d.length-1]=et;for(const l of d)o.addRoute(l);if(_){const l=St(t.config?.apis,t.realRelativePath);m[_]={[A]:l.rbac,[C]:{fsPath:P}}}r.set(b,L)}})},afterRoutesCreated:async(o,D)=>{const{buildItems:v,simplifyAstStructure:y}=await Q(o.serverOutDir),S=new Set,I=new Set;for(const{chunks:c,relativePath:i,isVirtual:f}of e){const g=`${E}${i}`,F=Pt(o.getAllRoutes(),i);for(const{node:t,markdown:P,pointer:p,key:a,relativePath:h}of c){const{ast:b,compoundHash:M}=await o.parseMarkdoc({input:{content:P,relativePath:h,isVirtual:f},resource:p,context:D,deps:{sharedDataIds:[`${E}${h}`],routeSlugs:F}});if(S.add(p),!(a==="graphql-docs"?t?.description?.value!==void 0:!!a&&It(t,a,P))||!O(t,a,M))continue;I.add(g);const R=y(b);if(a==="graphql-docs"){t.description&&(t.description.value=R);const _=`${E}${h}`;Et(r.get(_),R)}else a&&(t[a]=R)}}const T=n.difference(S);for(const c of T)D.cache.delete(c);n=S,Object.entries(m).forEach(([c,i])=>{const f=i[C]?.fsPath;if(!f)return;const g=o.getRouteByFsPath(f)?.baseSlug;m[c]={...i,[C]:{...i[C],slug:g},slug:g}}),o.setGlobalData({apiProducts:m});for(const[c,i]of r){if(!I.has(c))continue;const{items:f,store:g}=await v({type:i.document.type,document:i.document.document,options:i.document.options,basePath:i.basePath,markdownParser:U});i.build={items:f,store:g},await o.createSharedData(c,z(i,f,g))}}}}function z({document:e,basePath:r,sourcePath:s,apiId:n},m,O){return{[A]:W(e.config),[C]:{slug:pt(r),fsPath:e.customOutputRelativeFile||e.relativePath},items:m,store:O,options:e.options,baseSlug:r,routesMapping:G.isDevelopMode?vt(m,r):{},graphqlPositions:G.isDevelopMode&&e.type==="graphql"?bt(m,r):void 0,sourcePath:s,apiId:n}}function Et(e,r){e?.document.type!=="graphql"||!e.document.options||(e.document.options.info={...e.document.options.info||{},description:r})}function kt(e,r,s){return async function(n){return{...s?{isTranslationFallback:!0}:{},props:{settings:{baseUrlPath:$(n.baseSlug)},disableAutoScroll:!0,seo:{title:e,...r}}}}}function Ot(e,r){const s=e.options?.mockServer,n=$(`/_mock${_t(e.relativePath)}`);s?.url===n&&(e.options={...e.options,mockServer:{...s,url:$(`/_mock${r}`)}})}function Ft(e,r){if(e===r)return{};const s=r==="/"?"/":`${r}/`;if(e.startsWith(s)){const n=e.slice(s.length);return n?{slugSuffix:n}:{}}return{slug:e}}function Mt(e){if(e&&typeof e=="object"&&"info"in e)return e.info}function K(e){return e.map(({content:r,items:s,...n})=>({...n,...s&&{items:K(s)}}))}export{de as apiDocsPlugin,Ft as toRouteSlugFields};
1
+ import{REDOCLY_ROUTE_RBAC as T,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{mcpTagSchemas as rt,schemaDefinitionTag as at,markdocParser as U}from"@redocly/api-docs";import{withPathPrefix as $}from"@redocly/theme/core/utils";import{API_DOCS_TEMPLATE_ID as j,GRAPHQL_SPEC_SLUG as st,PUBLIC_RBAC_SCOPE_ITEM as N}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as it,PUBLIC_API_DEFINITIONS_FOLDER as nt}from"../../constants/common.js";import{API_DOCS_SHARED_DATA_PREFIX as k}from"../../constants/plugins/api-docs.js";import{fromCurrentDir as ct}from"../../utils/paths.js";import{normalizeRouteSlug as pt}from"../../../utils/path/normalize-route-slug.js";import{removeTrailingSlash as ut}from"../../../utils/url/remove-trailing-slash.js";import{isTranslationFallback as lt}from"../../fs/utils/is-translation-fallback.js";import{createSlugify as dt}from"../create-slugify.js";import{apiDocLoader as mt,apiDocsLoader as ft}from"./loader.js";import{getTemplatePath as V}from"./get-template-path.js";import{getDefinitionSourcePaths as gt,storeDefinitionBundles as ht}from"./store-definition-bundles.js";import{telemetryTraceStep as St}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as Dt}from"./search/search-resolver.js";import{getAiDocumentsStore as Pt}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as yt}from"../get-api-config.js";import{getRouteSlugsForPath as It}from"../utils.js";import{collectItemRoutes as At}from"./utils/collect-item-routes.js";import{isChunkCurrent as vt}from"./utils/decorators.js";import{applyNavItemToRoot as bt}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as Rt}from"./utils/build-routes-mapping.js";import{buildItemPositions as _t}from"./utils/build-item-positions.js";import{resolveApiDocTitle as Ct}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as W}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as Tt}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as wt}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as Q}from"./import-api-docs-builder.js";import{envConfig as G}from"../../config/env-config.js";import{logger as Et}from"../../tools/notifiers/logger.js";const O="openapi-spec-download",kt={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function fe(){let e=[],r=new Map;const s=new WeakMap;let n=new Set,m={},b={};function Y(o,S,v){const I=s.get(o)??new Map;s.set(o,I);const D=S??"";return I.get(D)===v?!1:(I.set(D,v),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":mt,"api-docs":ft},processContent:async(o,S)=>{await St("com.redocly.build.plugin.apiDocs",async()=>{o.createRequestHandler(O,ct(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:nt+"/*",requestHandlerId:O,httpMethod:"all",[A]:N,getStaticData:async()=>({props:{definitionSourcePaths:b}})}),o.addApiRoute({slug:it+"/*",requestHandlerId:O,httpMethod:"all",[A]:N,getStaticData:async()=>({props:{definitionSourcePaths:b}})}),o.addApiRoute({slug:st+"/*",requestHandlerId:O,httpMethod:"all",[A]:N,getStaticData:async()=>({props:{}})});const v=o.createTemplate(j,V("../../../client/templates/api-docs/template.js")),I=o.registerServerPropsGetter(j,V("./get-server-props.js")),D=await S.getConfig();r=new Map,m={};const P=await o.loadApiDocuments(S);ht(P,o.outdir),b=gt(P);const w=!!D.plugins?.some(t=>typeof t=="string"&&t.startsWith("@redocly/portal-plugin-async-api/"));w&&P.some(t=>t.type==="asyncapi")&&Et.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=w?P.filter(t=>t.type!=="asyncapi"):P;e=c.map(({markdocChunks:t,relativePath:y,isVirtual:p,customOutputRelativeFile:a,realRelativePath:h})=>({chunks:t??[],relativePath:y,realRelativePath:h,isVirtual:a!=null||p}));const{buildItems:i}=await Q(o.serverOutDir),f=(await S.cache.load("content-slugs","content-slugs")).data,g=dt(f),F=t=>pt(g(t));for(const t of c){const y=t.customOutputRelativeFile||t.relativePath,p=F(y);Mt(t,p);const{items:a,store:h}=await i({type:t.type,document:t.document,options:t.options,basePath:p,markdownParser:U}),R=`${k}${t.relativePath}`,M=G.isDevelopMode?t.relativePath:void 0,u=Bt(t.document),_=u?.["x-metadata"],C=t.isVirtual?void 0:_?.apiId,L={document:t,basePath:p,sourcePath:M,apiId:C,build:{items:a,store:h}};await o.createSharedData(R,z(L,a,h));const X=W(t.config),B=!!t.options.excludeFromSearch,J=t.type==="openapi",Z=At(a,X),tt=lt(t),d=Z.map(l=>{const x=l.metadata?.seo,E={fsPath:y,templateId:v,sharedData:[{key:"apiDocsStore",id:R}],serverPropsGetterIds:[I],excludeFromSearch:B,getStaticData:Ft(l.label,x,tt),[A]:l[A]};return Object.assign(E,Lt(l.link,p)),J&&l.httpVerb&&(E.httpVerb=l.httpVerb,E.metadata={subType:"openapi-operation"}),E});if(!d.length)continue;const H=Ct(u,t.type,a),et=wt(u?.version),q={type:t.type,title:H,version:et,description:typeof u?.description=="string"?u.description:void 0,summary:typeof u?.summary=="string"?u.summary:void 0,...u?.["x-metadata"]&&typeof u["x-metadata"]=="object"?u["x-metadata"]:{}};d[0]={...d[0],metadata:q,hasClientRoutes:!0,getSidebar:(l,x)=>bt(K(a),p,x),getNavText:()=>H??kt[t.type]??"API Docs",getSearchDocuments:Dt(a,q,o.getSearchFacets,o.setSearchFacets,B,h,t.document),getAiDocumentsStore:Pt({getBuild:()=>L.build,metadata:q,document:t.document,specType:t.type,excludeFromSearch:B,basePath:p,getSearchFacets:o.getSearchFacets,markdocTags:{...rt,schemaDefinition:at}})};const ot=d[0];d[0]=d[d.length-1],d[d.length-1]=ot;for(const l of d)o.addRoute(l);if(C){const l=yt(t.config?.apis,t.realRelativePath);m[C]={[A]:l.rbac,[T]:{fsPath:y}}}r.set(R,L)}})},afterRoutesCreated:async(o,S)=>{const{buildItems:v,simplifyAstStructure:I}=await Q(o.serverOutDir),D=new Set,P=new Set;for(const{chunks:c,relativePath:i,isVirtual:f}of e){const g=`${k}${i}`,F=It(o.getAllRoutes(),i);for(const{node:t,markdown:y,pointer:p,key:a,relativePath:h}of c){const{ast:R,compoundHash:M}=await o.parseMarkdoc({input:{content:y,relativePath:h,isVirtual:f},resource:p,context:S,deps:{sharedDataIds:[`${k}${h}`],routeSlugs:F}});if(D.add(p),!(a==="graphql-docs"?t?.description?.value!==void 0:!!a&&vt(t,a,y))||!Y(t,a,M))continue;P.add(g);const _=I(R);if(a==="graphql-docs"){t.description&&(t.description.value=_);const C=`${k}${h}`;Ot(r.get(C),_)}else a&&(t[a]=_)}}const w=n.difference(D);for(const c of w)S.cache.delete(c);n=D,Object.entries(m).forEach(([c,i])=>{const f=i[T]?.fsPath;if(!f)return;const g=o.getRouteByFsPath(f)?.baseSlug;m[c]={...i,[T]:{...i[T],slug:g},slug:g}}),o.setGlobalData({apiProducts:m});for(const[c,i]of r){if(!P.has(c))continue;const{items:f,store:g}=await v({type:i.document.type,document:i.document.document,options:i.document.options,basePath:i.basePath,markdownParser:U});i.build={items:f,store:g},await o.createSharedData(c,z(i,f,g))}}}}function z({document:e,basePath:r,sourcePath:s,apiId:n},m,b){return{[A]:W(e.config),[T]:{slug:ut(r),fsPath:e.customOutputRelativeFile||e.relativePath},items:m,store:b,options:e.options,baseSlug:r,routesMapping:G.isDevelopMode?Rt(m,r):{},graphqlPositions:G.isDevelopMode&&e.type==="graphql"?_t(m,r):void 0,sourcePath:s,apiId:n}}function Ot(e,r){e?.document.type!=="graphql"||!e.document.options||(e.document.options.info={...e.document.options.info||{},description:r})}function Ft(e,r,s){return async function(n){return{...s?{isTranslationFallback:!0}:{},props:{settings:{baseUrlPath:$(n.baseSlug)},disableAutoScroll:!0,seo:{title:e,...r}}}}}function Mt(e,r){const s=e.options?.mockServer,n=$(`/_mock${Tt(e.relativePath)}`);s?.url===n&&(e.options={...e.options,mockServer:{...s,url:$(`/_mock${r}`)}})}function Lt(e,r){if(e===r)return{};const s=r==="/"?"/":`${r}/`;if(e.startsWith(s)){const n=e.slice(s.length);return n?{slugSuffix:n}:{}}return{slug:e}}function Bt(e){if(e&&typeof e=="object"&&"info"in e)return e.info}function K(e){return e.map(({content:r,items:s,...n})=>({...n,...s&&{items:K(s)}}))}export{fe as apiDocsPlugin,Lt as toRouteSlugFields};
@@ -1 +1 @@
1
- import t from"node:path";import{existsSync as u}from"node:fs";import{readFile as w}from"node:fs/promises";import q from"js-yaml";import{withoutPathPrefix as j}from"@redocly/theme/core/utils";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as x,PUBLIC_API_DEFINITIONS_FOLDER as A}from"../../constants/common.js";import{GRAPHQL_SPEC_SLUG as g}from"../../../constants/common.js";import{canDownloadApiDefinition as T,filterDataByAccessDeep as C}from"../../utils/rbac.js";import{API_DOWNLOAD_PREFIXES as U}from"../../utils/is-api-download-link.js";import{decodeRequestPath as B}from"../../utils/decode-request-path.js";const G=[".json",".yaml",".yml"],W=[".graphql",".gql"];function S(i,n){const s=t.parse(i);return t.join(s.dir,s.name+n)}const X=async(i,n,s)=>{const{isAuthenticated:r,teams:f,claims:{email:m}}=n.user,D=new URL(i.url),e=B(j(D.pathname));if(e===void 0||e.endsWith("/"))return new Response("Bad Request",{status:400});const c=U.find(a=>e.startsWith(`${a}/`));if(c===void 0)return new Response("Not found",{status:404});const d=c===g,o=e.slice(c.length),p=t.extname(o);if(!(d?W:G).includes(p))return new Response("Not found",{status:404});const{rbac:h={},requiresLogin:P=!1}=n.config.access||{};if(!T(e,h,P,{isAuthenticated:r,email:m,teams:f}))return new Response("Unauthorized",{status:r?403:401});const l=s.props?.outdir||"";if(d){const a=t.join(l,A,o);if(!u(a))return new Response("Not found",{status:404});const L=await w(a,"utf-8");return new Response(L,{headers:{"Content-Type":"application/graphql"}})}const R=t.join(l,A,S(o,".json")),E=t.join(l,x,S(o,".json")),N=u(R),_=u(E);if(!N&&!_)return new Response("Not found",{status:404});const y=await w(N?R:E,"utf-8"),F=JSON.parse(y),I=C(F,{isAuthenticated:r,email:m,teams:f},h,P),O=p===".yaml"?q.dump(I):JSON.stringify(I,null,2);return new Response(O,{headers:{"Content-Type":p===".yaml"?"application/yaml":"application/json"}})};var Z=X;export{Z as default};
1
+ import e from"node:path";import{existsSync as f}from"node:fs";import{readFile as w}from"node:fs/promises";import g from"js-yaml";import{withoutPathPrefix as T}from"@redocly/theme/core/utils";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as C,PUBLIC_API_DEFINITIONS_FOLDER as A}from"../../constants/common.js";import{GRAPHQL_SPEC_SLUG as U}from"../../../constants/common.js";import{canDownloadApiDefinition as B,filterDataByAccessDeep as G}from"../../utils/rbac.js";import{API_DOWNLOAD_PREFIXES as W}from"../../utils/is-api-download-link.js";import{decodeRequestPath as X}from"../../utils/decode-request-path.js";import{replaceFileExtension as $}from"./utils/replace-file-extension.js";const v=[".json",".yaml",".yml"],H=[".graphql",".gql"];function F(r,o){const t=e.parse(r);return e.join(t.dir,t.name+o)}const J=async(r,o,t)=>{const{isAuthenticated:c,teams:d,claims:{email:m}}=o.user,_=new URL(r.url),n=X(T(_.pathname));if(n===void 0||n.endsWith("/"))return new Response("Bad Request",{status:400});const i=W.find(a=>n.startsWith(`${a}/`));if(i===void 0)return new Response("Not found",{status:404});const p=i===U,s=n.slice(i.length),l=e.extname(s);if(!(p?H:v).includes(l))return new Response("Not found",{status:404});const{rbac:h={},requiresLogin:P=!1}=o.config.access||{},y=t.props?.definitionSourcePaths??{},E=p?void 0:y[$(s.slice(1),"")],D=E?`${i}/${E}`:n;if(!B(D,h,P,{isAuthenticated:c,email:m,teams:d}))return new Response("Unauthorized",{status:c?403:401});const u=t.props?.outdir||"";if(p){const a=e.join(u,A,s);if(!f(a))return new Response("Not found",{status:404});const j=await w(a,"utf-8");return new Response(j,{headers:{"Content-Type":"application/graphql"}})}const R=e.join(u,A,F(s,".json")),N=e.join(u,C,F(s,".json")),S=f(R),x=f(N);if(!S&&!x)return new Response("Not found",{status:404});const O=await w(S?R:N,"utf-8"),L=JSON.parse(O),I=G(L,{isAuthenticated:c,email:m,teams:d},h,P),q=l===".yaml"?g.dump(I):JSON.stringify(I,null,2);return new Response(q,{headers:{"Content-Type":l===".yaml"?"application/yaml":"application/json"}})};var oe=J;export{oe as default};
@@ -1,3 +1,9 @@
1
1
  import type { BundledApiDefinition } from './loader.js';
2
+ /**
3
+ * Source file of each OpenAPI/AsyncAPI bundle, keyed by the bundle path without its extension
4
+ * (`apis/museum` for `apis/museum.yaml`): the download route serves one bundle under `.json`,
5
+ * `.yaml` and `.yml`, and access rules name the source file.
6
+ */
7
+ export declare function getDefinitionSourcePaths(definitions: BundledApiDefinition[]): Record<string, string>;
2
8
  export declare function storeDefinitionBundles(definitions: BundledApiDefinition[], outDir: string): void;
3
9
  //# sourceMappingURL=store-definition-bundles.d.ts.map
@@ -1 +1 @@
1
- import{writeFileSync as m}from"fs";import p from"path";import{print as d}from"graphql";import{PUBLIC_API_DEFINITIONS_FOLDER as h,PUBLIC_STATIC_FOLDER as a}from"../../constants/common.js";import{logger as u}from"../../tools/notifiers/logger.js";import{ensureDir as g}from"../../utils/fs.js";import{replaceFileExtension as S}from"./utils/replace-file-extension.js";const r=new Map;function D(f,t){const n=h.slice(1);try{for(const e of f){const{document:s,relativePath:i,hash:o,type:c}=e;if(r.get(i)!==o){if(c==="graphql"){l({outDir:t,definitionFolder:n,relativePath:i,definitionString:d(s)}),r.set(i,o);continue}if(i.startsWith(a+"/")){l({outDir:t,definitionFolder:".",relativePath:i.replace(a+"/",""),definitionString:JSON.stringify(s,null,2)}),r.set(i,o);continue}l({outDir:t,definitionFolder:n,relativePath:S(i,".json"),definitionString:JSON.stringify(s,null,2)}),r.set(i,o)}}}catch(e){u.error("failed to store definition bundles",e)}}function l({outDir:f,definitionString:t,relativePath:n,definitionFolder:e}){m(g(p.resolve(f,`${e}/${n}`)),t,"utf8")}export{D as storeDefinitionBundles};
1
+ import{writeFileSync as h}from"fs";import m from"path";import{print as u}from"graphql";import{PUBLIC_API_DEFINITIONS_FOLDER as d,PUBLIC_STATIC_FOLDER as a}from"../../constants/common.js";import{logger as g}from"../../tools/notifiers/logger.js";import{ensureDir as P}from"../../utils/fs.js";import{replaceFileExtension as l}from"./utils/replace-file-extension.js";const f=new Map;function _(o){const t={};for(const{relativePath:i,type:n}of o)n==="graphql"||i.startsWith(a+"/")||(t[l(i,"")]=i);return t}function E(o,t){const i=d.slice(1);try{for(const n of o){const{document:s,relativePath:e,hash:r,type:p}=n;if(f.get(e)!==r){if(p==="graphql"){c({outDir:t,definitionFolder:i,relativePath:e,definitionString:u(s)}),f.set(e,r);continue}if(e.startsWith(a+"/")){c({outDir:t,definitionFolder:".",relativePath:e.replace(a+"/",""),definitionString:JSON.stringify(s,null,2)}),f.set(e,r);continue}c({outDir:t,definitionFolder:i,relativePath:l(e,".json"),definitionString:JSON.stringify(s,null,2)}),f.set(e,r)}}}catch(n){g.error("failed to store definition bundles",n)}}function c({outDir:o,definitionString:t,relativePath:i,definitionFolder:n}){h(P(m.resolve(o,`${n}/${i}`)),t,"utf8")}export{_ as getDefinitionSourcePaths,E as storeDefinitionBundles};
@@ -1 +1 @@
1
- import S from"path";import{REDOCLY_ROUTE_RBAC as u,REDOCLY_TEAMS_RBAC as y}from"@redocly/config";import{deepMerge as T}from"../../../utils/object/deep-merge.js";import{parsePathVersions as D}from"../../../utils/path/parse-path-versions.js";import{buildWildcardRedirectsTree as w}from"../../utils/redirects/build-wildcard-redirects-tree.js";import{shaHexShort as E}from"../../utils/crypto/sha-hex-short.js";import{formatCustomScripts as h,formatCustomLinks as L}from"./format-custom-tags.js";import{applyL10nToRbacConfig as O,resolveDirectoryHashes as k}from"../../utils/rbac.js";import{isConsentEnabled as G}from"../consent/is-consent-enabled.js";import{copySeoAssets as B}from"./copy-seo-assets.js";import{normalizeRedirectSources as F}from"./normalize-redirect-sources.js";import{applyL10nToRedirects as _}from"./apply-l10n-to-redirects.js";import{DEFAULT_LOADERS as j}from"./loaders/index.js";import{resolveSearchFacets as x}from"./resolve-search-facets.js";import{telemetryTraceStep as M}from"../../../cli/telemetry/helpers/trace-step.js";import{transformMdAst as z}from"../markdown/runtime-transform.js";import{EntitlementsProvider as I}from"../../entitlements/entitlements-provider.js";async function ir(){return{id:"Config Parser",loaders:j,async processContent(e,{getConfig:a,fs:o}){await M("com.redocly.build.plugin.configParser",async t=>{const{contentDir:l,setGlobalConfig:s,setGlobalData:i}=e,r=await a(),n=r.access||{},m=O(o,n.rbac||{}),f={outdir:e.outdir,contentDir:l,consentEnabled:G(r.consent)},C=await h(r.scripts?.head,f),P=await L(r.links,f),R=await h(r.scripts?.body,f),d=T(r,{headScriptTags:C,linkTags:P,postBodyScriptTags:R});t?.setAttribute("config",JSON.stringify(d));const p=r.redirects?F(r.redirects):{},v=Object.keys(p),A=d.banner?.map(c=>typeof c=="object"&&c!==null&&c.rbac?{...c,[y]:c.rbac}:c);s({...d,banner:A,access:{...n,requiresLogin:!!n.requiresLogin,rbac:m},directoryPaths:await k(o,n.rbac),seo:r.seo&&await B(r.seo,f.contentDir,f.outdir),redirects:_(p,r.l10n),wildcardRedirectsTree:w(p),originalRedirectSources:v}),x(r.search?.filters?.facets||[],e.getSearchFacets,e.setSearchFacets);const b=I.instance(),g=!!b.canAccessFeature("removeAttribution");i({removeAttribution:b.pricingTier?g:!0,removeConsoleAttribution:g&&r.removeAttribution===!0})})},async afterRoutesCreated(e,a){V(e);const o=e.getGlobalConfig("banner");if(Array.isArray(o)){const t=await Promise.all(o.map(async(l,s)=>{const{content:i,...r}=l,{ast:n}=await e.parseMarkdoc({input:{content:i,relativePath:"redocly.yaml"},context:a,resource:`redocly.yaml#banner${s}`}),{renderableAst:m}=await z(n,{variables:{},partials:{}},e.serverOutDir);return{...r,ast:m,hash:E(i)}}));e.setGlobalConfig({banner:t})}}}}function V(e){const a=e.getGlobalConfig("access")?.rbac,o=e.getGlobalConfig("directoryPaths");if(!(!a||Object.keys(a).length===0))for(const t of e.getAllRoutes()){if(t.versions&&o){const l=D(t.fsPath)?.filePathInVersion||"index.md";for(const s of t.versions){const i=o[s.folderId],n=i==="."||i==="/"?"":i;s[u]={slug:s.link,fsPath:S.posix.join(n,"@"+s.version,l)}}}t[u]||t[y]||(t[u]={slug:t.slug,fsPath:t.fsPath})}}export{ir as configParserPlugin};
1
+ import S from"path";import{REDOCLY_ROUTE_RBAC as b,REDOCLY_TEAMS_RBAC as y}from"@redocly/config";import{deepMerge as w}from"../../../utils/object/deep-merge.js";import{parsePathVersions as D}from"../../../utils/path/parse-path-versions.js";import{buildWildcardRedirectsTree as T}from"../../utils/redirects/build-wildcard-redirects-tree.js";import{shaHexShort as O}from"../../utils/crypto/sha-hex-short.js";import{isDefined as E}from"../../../utils/guards/is-defined.js";import{logger as L}from"../../tools/notifiers/logger.js";import{formatCustomScripts as h,formatCustomLinks as k}from"./format-custom-tags.js";import{applyL10nToRbacConfig as G,resolveDirectoryHashes as j}from"../../utils/rbac.js";import{isConsentEnabled as B}from"../consent/is-consent-enabled.js";import{copySeoAssets as F}from"./copy-seo-assets.js";import{normalizeRedirectSources as _}from"./normalize-redirect-sources.js";import{applyL10nToRedirects as x}from"./apply-l10n-to-redirects.js";import{DEFAULT_LOADERS as M}from"./loaders/index.js";import{resolveSearchFacets as z}from"./resolve-search-facets.js";import{telemetryTraceStep as I}from"../../../cli/telemetry/helpers/trace-step.js";import{transformMdAst as V}from"../markdown/runtime-transform.js";import{EntitlementsProvider as q}from"../../entitlements/entitlements-provider.js";async function lr(){return{id:"Config Parser",loaders:M,async processContent(e,{getConfig:a,fs:n}){await I("com.redocly.build.plugin.configParser",async t=>{const{contentDir:l,setGlobalConfig:o,setGlobalData:s}=e,r=await a(),i=r.access||{},m=G(n,i.rbac||{}),f={outdir:e.outdir,contentDir:l,consentEnabled:B(r.consent)},C=await h(r.scripts?.head,f),P=await k(r.links,f),R=await h(r.scripts?.body,f),d=w(r,{headScriptTags:C,linkTags:P,postBodyScriptTags:R});t?.setAttribute("config",JSON.stringify(d));const p=r.redirects?_(r.redirects):{},v=Object.keys(p),A=d.banner?.map(c=>typeof c=="object"&&c!==null&&c.rbac?{...c,[y]:c.rbac}:c);o({...d,banner:A,access:{...i,requiresLogin:!!i.requiresLogin,rbac:m},directoryPaths:await j(n,i.rbac),seo:r.seo&&await F(r.seo,f.contentDir,f.outdir),redirects:x(p,r.l10n),wildcardRedirectsTree:T(p),originalRedirectSources:v}),z(r.search?.filters?.facets||[],e.getSearchFacets,e.setSearchFacets);const g=q.instance(),u=!!g.canAccessFeature("removeAttribution");s({removeAttribution:g.pricingTier?u:!0,removeConsoleAttribution:u&&r.removeAttribution===!0})})},async afterRoutesCreated(e,a){H(e);const n=e.getGlobalConfig("banner");if(Array.isArray(n)){const t=await Promise.all(n.map(async(l,o)=>{const{content:s,...r}=l;if(!s){L.warn(`redocly.yaml: banner[${o}] has no content and is not shown.`);return}const{ast:i}=await e.parseMarkdoc({input:{content:s,relativePath:"redocly.yaml"},context:a,resource:`redocly.yaml#banner${o}`}),{renderableAst:m}=await V(i,{variables:{},partials:{}},e.serverOutDir);return Object.assign(r,{ast:m,hash:O(s)})}));e.setGlobalConfig({banner:t.filter(E)})}}}}function H(e){const a=e.getGlobalConfig("access")?.rbac,n=e.getGlobalConfig("directoryPaths");if(!(!a||Object.keys(a).length===0))for(const t of e.getAllRoutes()){if(t.versions&&n){const l=D(t.fsPath)?.filePathInVersion||"index.md";for(const o of t.versions){const s=n[o.folderId],i=s==="."||s==="/"?"":s;o[b]={slug:o.link,fsPath:S.posix.join(i,"@"+o.version,l)}}}t[b]||t[y]||(t[b]={slug:t.slug,fsPath:t.fsPath})}}export{lr as configParserPlugin};
@@ -1 +1 @@
1
- import{buildCodeSamples as y,getRequestBodySamples as v,normalizeOptions as d,resolveOperationSampleContext as f}from"@redocly/api-docs";import{setNodeAttributeValue as S}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{loadOpenapiBundle as O}from"./helpers/load-openapi-bundle.js";import{getOptionalAttribute as t}from"./utils.js";const b={curl:"shell",JavaScript:"javascript","Node.js":"javascript",Python:"python",Java:"java","Java8+Apache":"java","C#":"csharp","C#+Newtonsoft":"csharp",PHP:"php",Go:"go",Ruby:"ruby",R:"r"};async function B(e,c,h,{context:u}){const o=await O(e,u);if(!o)return;const s=t(e,"language"),r={exampleKey:t(e,"exampleKey"),mimeType:t(e,"mimeType"),parameters:t(e,"parameters"),requestBody:t(e,"requestBody"),environments:t(e,"environments"),environment:t(e,"environment")},g={...o.rawOptions,...o.rawOptions.mockServer&&{mockServer:{...o.rawOptions.mockServer,position:"off"}},...s&&{codeSamples:{...o.rawOptions.codeSamples,languages:[{lang:s}]}}},l=d(g),n=f(o.definition,l,{operationId:t(e,"operationId"),pointer:t(e,"pointer")});if(!n)return;const i=y(n,r).map(a=>({lang:b[a.lang]??a.lang.toLowerCase(),title:a.label??a.lang,source:a.source})),m=l.codeSamples?.languages??[],p=m.findIndex(({lang:a})=>a==="Payload");if(p!==-1){const a=v(n,{exampleKey:r.exampleKey,mimeType:r.mimeType,titlePrefix:m[p].label});i.splice(p,0,...a)}i.length&&S(e,c,i)}export{B as resolveOpenapiCodeSamples};
1
+ import{buildCodeSamples as v,getRequestBodySamples as d,normalizeOptions as f,resolveOperationSampleContext as S}from"@redocly/api-docs";import{setNodeAttributeValue as O}from"../../../../markdoc/helpers/set-node-attribute-value.js";import{loadOpenapiBundle as b}from"./helpers/load-openapi-bundle.js";import{getOptionalAttribute as t}from"./utils.js";const h={curl:"shell",JavaScript:"javascript","Node.js":"javascript",Python:"python",Java:"java","Java8+Apache":"java","C#":"csharp","C#+Newtonsoft":"csharp",PHP:"php",Go:"go",Ruby:"ruby",R:"r"};async function N(e,u,x,{context:g}){const o=await b(e,g);if(!o)return;const i=t(e,"language"),l=t(e,"options"),n={exampleKey:t(e,"exampleKey"),mimeType:t(e,"mimeType"),parameters:t(e,"parameters"),requestBody:t(e,"requestBody"),environments:t(e,"environments"),environment:t(e,"environment")},y={...o.rawOptions,...l,...o.rawOptions.mockServer&&{mockServer:{...o.rawOptions.mockServer,position:"off"}},codeSamples:{...o.rawOptions.codeSamples,...l?.codeSamples,...i&&{languages:[{lang:i}]}}},m=f(y),r=S(o.definition,m,{operationId:t(e,"operationId"),pointer:t(e,"pointer")});if(!r)return;const s=v(r,n).map(a=>({lang:h[a.lang]??a.lang.toLowerCase(),title:a.label??a.lang,source:a.source})),c=m.codeSamples?.languages??[],p=c.findIndex(({lang:a})=>a==="Payload");if(p!==-1){const a=d(r,{exampleKey:n.exampleKey,mimeType:n.mimeType,titlePrefix:c[p].label});s.splice(p,0,...a)}s.length&&O(e,u,s)}export{N as resolveOpenapiCodeSamples};
@@ -2,5 +2,5 @@ import type { McpToolSchema } from '../../../../types';
2
2
  import type { McpToolCallback, McpToolContext } from '../../types.js';
3
3
  import { type SandboxCapability } from '../capabilities/index.js';
4
4
  export declare function describeToolsSchema(tools: McpToolSchema[], capabilities: SandboxCapability[]): McpToolSchema;
5
- export declare function describeTools(tools: McpToolSchema[], isToolAvailable: (toolName: string) => Promise<boolean>, capabilities: SandboxCapability[], context: McpToolContext): McpToolCallback;
5
+ export declare function describeTools(tools: McpToolSchema[], capabilities: SandboxCapability[], context: McpToolContext): McpToolCallback;
6
6
  //# sourceMappingURL=describe-tools.d.ts.map
@@ -1,3 +1 @@
1
- import{renderDescribeToolsOutput as N}from"../capabilities/index.js";import{McpServerType as u,READ_ONLY_ANNOTATIONS as D}from"../../constants.js";import{logMcpToolCallAudit as E,reportMcpToolCalled as k,reportMcpToolError as C}from"../../workers/mcp-tool-telemetry.js";import{DESCRIBE_TOOLS_TOOL_NAME as l}from"../constants.js";import{DESCRIBE_TOOLS_DESCRIPTION as j}from"../prompts.js";import{sanitizeToolName as s}from"../build-tool-type-declarations.js";import{UnknownToolError as O}from"./tool-errors.js";import{callAttribution as A}from"../../utils/telemetry-attributes.js";function B(c,f){const r=[...new Set([...c.map(n=>s(n.name)),...f.map(n=>s(n.id))])];return{name:l,title:"Get docs function signatures",description:j,annotations:D,schema:{type:"object",required:[],additionalProperties:!1,properties:{tools:{type:"array",description:`Tool names to describe: ${r.join(", ")}. Omit to describe everything.`,items:r.length>0?{type:"string",enum:r}:{type:"string"},nullable:!0}}}}}function z(c,f,r,n){const p=new Map(c.map(t=>[s(t.name),t])),w=new Map(r.map(t=>[s(t.id),t]));return async t=>{const b=performance.now(),m=n.mcpMode??"code",d=A(n);try{const e=[...new Set((t.tools??[]).map(s))],i=e.length===0,a=e.filter(o=>!p.has(o)&&!w.has(o));if(a.length>0){const o=[...p.keys(),...w.keys()];throw new O(`Unknown tool(s): ${a.join(", ")}. Valid tools: ${o.join(", ")}.`)}const S=i?r:r.filter(o=>e.includes(s(o.id))),T=i?c:e.filter(o=>p.has(o)).map(o=>p.get(o)),g=await Promise.all(T.map(o=>f(o.name))),_=T.filter((o,y)=>g[y]),v=T.filter((o,y)=>!g[y]),M=[N(_,S,n)];v.length>0&&M.push(`Not available for this request: ${v.map(o=>s(o.name)).join(", ")}`);const h=M.join(`
2
-
3
- `);return E({tool:l,mode:m,serverType:u.Docs,args:t,result:h,...d}),k({tool:l,mode:m,serverType:u.Docs,durationMs:Math.round(performance.now()-b),outputLength:h.length,...d}),{content:[{type:"text",text:h}]}}catch(e){const i=e instanceof O,a=i?"tool_error":"server_error";throw E({tool:l,mode:m,serverType:u.Docs,args:t,errorClass:a,...d}),C({tool:l,mode:m,serverType:u.Docs,durationMs:Math.round(performance.now()-b),message:e instanceof Error?e.message:String(e),stack:!i&&e instanceof Error&&e.stack||"",errorClass:a,...d}),e}}}export{z as describeTools,B as describeToolsSchema};
1
+ import{renderDescribeToolsOutput as E}from"../capabilities/index.js";import{McpServerType as u,READ_ONLY_ANNOTATIONS as O}from"../../constants.js";import{logMcpToolCallAudit as h,reportMcpToolCalled as S,reportMcpToolError as b}from"../../workers/mcp-tool-telemetry.js";import{DESCRIBE_TOOLS_TOOL_NAME as l}from"../constants.js";import{DESCRIBE_TOOLS_DESCRIPTION as v}from"../prompts.js";import{sanitizeToolName as s}from"../build-tool-type-declarations.js";import{UnknownToolError as w}from"./tool-errors.js";import{callAttribution as D}from"../../utils/telemetry-attributes.js";function R(p,i){const n=[...new Set([...p.map(r=>s(r.name)),...i.map(r=>s(r.id))])];return{name:l,title:"Get docs function signatures",description:v,annotations:O,schema:{type:"object",required:[],additionalProperties:!1,properties:{tools:{type:"array",description:`Tool names to describe: ${n.join(", ")}. Omit to describe everything.`,items:n.length>0?{type:"string",enum:n}:{type:"string"},nullable:!0}}}}}function U(p,i,n){const r=new Map(p.map(t=>[s(t.name),t])),T=new Map(i.map(t=>[s(t.id),t]));return async t=>{const y=performance.now(),m=n.mcpMode??"code",d=D(n);try{const o=[...new Set((t.tools??[]).map(s))],a=o.length===0,c=o.filter(e=>!r.has(e)&&!T.has(e));if(c.length>0){const e=[...r.keys(),...T.keys()];throw new w(`Unknown tool(s): ${c.join(", ")}. Valid tools: ${e.join(", ")}.`)}const M=a?i:i.filter(e=>o.includes(s(e.id))),g=a?p:o.filter(e=>r.has(e)).map(e=>r.get(e)),f=E(g,M,n);return h({tool:l,mode:m,serverType:u.Docs,args:t,result:f,...d}),S({tool:l,mode:m,serverType:u.Docs,durationMs:Math.round(performance.now()-y),outputLength:f.length,...d}),{content:[{type:"text",text:f}]}}catch(o){const a=o instanceof w,c=a?"tool_error":"server_error";throw h({tool:l,mode:m,serverType:u.Docs,args:t,errorClass:c,...d}),b({tool:l,mode:m,serverType:u.Docs,durationMs:Math.round(performance.now()-y),message:o instanceof Error?o.message:String(o),stack:!a&&o instanceof Error&&o.stack||"",errorClass:c,...d}),o}}}export{U as describeTools,R as describeToolsSchema};
@@ -1 +1 @@
1
- import{logger as A}from"../../../tools/notifiers/logger.js";import{getFeedbackClientIp as N}from"../../../web-server/utils/feedback-ip.js";import{getForwardedOrigin as M,getInternalOrigin as L}from"../../../web-server/utils/get-request-origin.js";import{GATEWAY_FETCH_LIMIT_DEFAULTS as B,DEFAULT_ANONYMOUS_VISITOR_TEAM as H,RbacFeatures as j}from"../../../../constants/common.js";import{isObject as V}from"../../../../utils/guards/is-object.js";import{getAccessibleSkills as $}from"../../../utils/skills/get-accessible-skills.js";import{getSkillUrl as G}from"../../../utils/skills/get-skill-url.js";import{createMcpHandler as J}from"@modelcontextprotocol/server";import{createDocsMcpServer as K}from"../servers/docs-server.js";import{filterApiDescriptionsByRbac as Y,filterGraphqlDescriptionsByRbac as z}from"../utils.js";import{userSubject as W}from"../gateway-mcp/subject.js";import{ipRateLimitKey as X}from"../gateway-mcp/rate-limit/utils/ip-key.js";import{McpClientInputError as Q,createMethodNotAllowedError as Z,withErrorHandling as q}from"./errors.js";import{constructForbiddenResponse as x,constructInvalidTokenResponse as ee,constructUnauthorizedResponse as re,handleMcpAuth as oe}from"../auth/auth-handlers.js";import{isAssistantAnonymousToken as se}from"../auth/assistant-anonymous-token.js";import{shouldHandleMcpAuth as ne}from"../../../utils/rbac/should-handle-mcp-auth.js";import{extractTokenFromAuthHeader as ie}from"../utils/jwt.js";import{resolveMcpClient as te}from"../utils/mcp-client.js";import{randomUUID as ce}from"../../../utils/crypto/random-uuid.js";import{getPublicMcpEndpointStatus as ae}from"../utils/public-endpoint.js";import{narrowMcpConfigForCaller as pe}from"../gateway-mcp/caller-api-calls.js";import{DEFAULT_DOCS_MCP_SERVER_NAME as de,SSE_KEEPALIVE_INTERVAL_MS as me}from"../constants.js";import{withPathPrefix as le}from"@redocly/theme/core/utils";import{PUBLIC_MCP_ROUTE as ue}from"@redocly/theme/core/constants/mcp";import{canAccessFeature as fe}from"../../../utils/rbac.js";import{ANONYMOUS_AUTH_DETAILS as ge}from"../../../constants/rbac.js";const E="X-Redocly-AI-Metadata";function he(r){if(r)try{const e=JSON.parse(r);if(V(e))return e;A.warn(`Ignoring ${E} header: not a JSON object.`)}catch{A.warn(`Ignoring ${E} header: invalid JSON.`)}}function Ae(r,e){return new URL(r).searchParams.get("mode")==="tools"?"tools":e}function I(){return{...ge,email:"",idpAccessToken:void 0,idpId:void 0}}const Me=async(r,e,i)=>{const t=!!e?.config?.access?.requiresLogin,c=e?.config?.access?.rbac||{},y=i?.props?.config?.mcpMode??"tools",p=Ae(r.url,y),C=i?.props?.config?.gatewayFetchBudgetPerExec??B.budgetPerExec,U=i?.props?.config?.searchIgnoredRoutes??[],s=i,R=!!s?.props?.config?.isPublicEndpoint;let f;const T=r.headers.get("Authorization");if(R)e.user=I();else if(ne(t,c)){const{isAuthenticated:n,isTokenValid:d,isFirstPartyAnonymous:g,currentUser:m,accessToken:h}=await oe(r,e);if(g)e.user=I();else if(n)m&&(e.user=m),f=h;else{const a=M(r),l=ae(e.config)==="served"?`${a}${le(ue)}`:void 0;return d===!1?ee(a,l):re(a,l)}}else if(T){const n=ie(T)??void 0;f=(n?await se(n):!1)?void 0:n}const w={isAuthenticated:!!e.user?.isAuthenticated,teams:e.user?.teams||[H],claims:e.user?.claims??{}};return fe(j.MCP,w,c,t)?await q(async()=>{const n=p==="code"&&(i?.props?.config?.elicitationEnabled??!1);if(r.method==="GET")return new Response(JSON.stringify({error:"Method Not Allowed",message:`In order to use this MCP server, you need to register it in your MCP client (VS Code, Cursor, Claude Code, etc.) using this URL: ${r.url}`}),{status:405,headers:{"Content-Type":"application/json"}});if(r.method!=="POST")return Z();const d=s?.props?.config?.apiDescriptionsMap||{},g=s?.props?.config?.graphqlDescriptions||[],m=s?.props?.config?.mcpDocsServerName||de,{config:{mcp:h={}}}=e,a=Y(d,e.user,c,t),l=z(g,e.user,c,t),P=e.config.products?Object.values(e.config.products).map(o=>o?.name):[],D=h.docs?.name||m,u=he(r.headers.get(E)),_=s?.props?.tools||[],O=s?.props?.skillsBaseUrl||M(r),k=$(s?.props?.skills||[],e.user,c,t).map(o=>({slug:o.slug,name:o.name,description:o.description,content:o.content,uri:G(O,o.slug)})),S=await Ee(r),b=s?.props?.fetchCountSecret,v={name:D,tools:_,skills:k,context:{...e,config:{...e.config,mcp:pe(e.config.mcp,u)},accessToken:f,outdir:e.outdir||"",baseUrl:e.baseUrl||M(r),internalBaseUrl:L(r),apiDescriptionsMap:a,graphqlDescriptions:l,products:P,metadata:u,mcpMode:p,elicitationEnabled:n,gatewayFetchBudgetPerExec:C,fetchCountRequest:p==="code"&&b?{caller:{subject:W(e.user),ip:X(r)},secret:b}:void 0,searchIgnoredRoutes:U,clientIp:N(r),...te(r),requestId:ce(),messageId:typeof u?.messageId=="string"?u.messageId:void 0}},F=await K({...v,getKv:e.getKv});return await J(async()=>F,{keepAliveMs:me,onerror:o=>A.warn(`MCP handler: ${o.message}`)}).fetch(r,S!==void 0?{parsedBody:S}:void 0)},p):x()};async function Ee(r){try{return await r.json()}catch(e){throw new Q(e instanceof Error?e.message:String(e),{cause:e})}}var ze=Me;export{ze as default};
1
+ import{logger as A}from"../../../tools/notifiers/logger.js";import{getFeedbackClientIp as N}from"../../../web-server/utils/feedback-ip.js";import{getForwardedOrigin as M,getInternalOrigin as L}from"../../../web-server/utils/get-request-origin.js";import{GATEWAY_FETCH_LIMIT_DEFAULTS as B,DEFAULT_ANONYMOUS_VISITOR_TEAM as H,RbacFeatures as j}from"../../../../constants/common.js";import{isObject as V}from"../../../../utils/guards/is-object.js";import{getAccessibleSkills as $}from"../../../utils/skills/get-accessible-skills.js";import{getSkillUrl as G}from"../../../utils/skills/get-skill-url.js";import{createMcpHandler as J}from"@modelcontextprotocol/server";import{createDocsMcpServer as K}from"../servers/docs-server.js";import{filterApiDescriptionsByRbac as Y,filterGraphqlDescriptionsByRbac as z}from"../utils.js";import{userSubject as W}from"../gateway-mcp/subject.js";import{ipRateLimitKey as X}from"../gateway-mcp/rate-limit/utils/ip-key.js";import{McpClientInputError as Q,createMethodNotAllowedError as Z,withErrorHandling as q}from"./errors.js";import{constructForbiddenResponse as x,constructInvalidTokenResponse as ee,constructUnauthorizedResponse as re,handleMcpAuth as oe}from"../auth/auth-handlers.js";import{isAssistantAnonymousToken as se}from"../auth/assistant-anonymous-token.js";import{shouldHandleMcpAuth as ne}from"../../../utils/rbac/should-handle-mcp-auth.js";import{extractTokenFromAuthHeader as ie}from"../utils/jwt.js";import{resolveMcpClient as te}from"../utils/mcp-client.js";import{randomUUID as ce}from"../../../utils/crypto/random-uuid.js";import{getPublicMcpEndpointStatus as ae}from"../utils/public-endpoint.js";import{narrowMcpConfigForCaller as pe}from"../gateway-mcp/caller-api-calls.js";import{DEFAULT_DOCS_MCP_SERVER_NAME as de,SSE_KEEPALIVE_INTERVAL_MS as le}from"../constants.js";import{withPathPrefix as me}from"@redocly/theme/core/utils";import{PUBLIC_MCP_ROUTE as fe}from"@redocly/theme/core/constants/mcp";import{canAccessFeature as ue}from"../../../utils/rbac.js";import{ANONYMOUS_AUTH_DETAILS as ge}from"../../../constants/rbac.js";const E="X-Redocly-AI-Metadata";function he(r){if(r)try{const e=JSON.parse(r);if(V(e))return e;A.warn(`Ignoring ${E} header: not a JSON object.`)}catch{A.warn(`Ignoring ${E} header: invalid JSON.`)}}function Ae(r,e){return new URL(r).searchParams.get("mode")==="tools"?"tools":e}function I(){return{...ge,email:"",idpAccessToken:void 0,idpId:void 0}}const Me=async(r,e,i)=>{const t=!!e?.config?.access?.requiresLogin,c=e?.config?.access?.rbac||{},y=i?.props?.config?.mcpMode??"tools",p=Ae(r.url,y),C=i?.props?.config?.gatewayFetchBudgetPerExec??B.budgetPerExec,U=i?.props?.config?.searchIgnoredRoutes??[],o=i,R=!!o?.props?.config?.isPublicEndpoint;let u;const T=r.headers.get("Authorization");if(R)e.user=I();else if(ne(t,c)){const{isAuthenticated:n,isTokenValid:d,isFirstPartyAnonymous:g,currentUser:l,accessToken:h}=await oe(r,e);if(g)e.user=I();else if(n)l&&(e.user=l),u=h;else{const a=M(r),m=ae(e.config)==="served"?`${a}${me(fe)}`:void 0;return d===!1?ee(a,m):re(a,m)}}else if(T){const n=ie(T)??void 0;u=(n?await se(n):!1)?void 0:n}const w={isAuthenticated:!!e.user?.isAuthenticated,teams:e.user?.teams||[H],claims:e.user?.claims??{}};return ue(j.MCP,w,c,t)?await q(async()=>{const n=p==="code"&&(i?.props?.config?.elicitationEnabled??!1);if(r.method==="GET")return new Response(JSON.stringify({error:"Method Not Allowed",message:`In order to use this MCP server, you need to register it in your MCP client (VS Code, Cursor, Claude Code, etc.) using this URL: ${r.url}`}),{status:405,headers:{"Content-Type":"application/json"}});if(r.method!=="POST")return Z();const d=o?.props?.config?.apiDescriptionsMap||{},g=o?.props?.config?.graphqlDescriptions||[],l=o?.props?.config?.mcpDocsServerName||de,{config:{mcp:h={}}}=e,a=Y(d,e.user,c,t),m=z(g,e.user,c,t),P=e.config.products?Object.values(e.config.products).map(s=>s?.name):[],D=h.docs?.name||l,f=he(r.headers.get(E)),_=o?.props?.tools||[],O=o?.props?.skillsBaseUrl||M(r),F=$(o?.props?.skills||[],e.user,c,t).map(s=>({slug:s.slug,name:s.name,description:s.description,content:s.content,uri:G(O,s.slug)})),S=await Ee(r),b=o?.props?.fetchCountSecret,k={name:D,tools:_,skills:F,context:{...e,config:{...e.config,mcp:pe(e.config.mcp,f)},configFile:o?.props?.configFile,accessToken:u,outdir:e.outdir||"",baseUrl:e.baseUrl||M(r),internalBaseUrl:L(r),apiDescriptionsMap:a,graphqlDescriptions:m,products:P,metadata:f,mcpMode:p,elicitationEnabled:n,gatewayFetchBudgetPerExec:C,fetchCountRequest:p==="code"&&b?{caller:{subject:W(e.user),ip:X(r)},secret:b}:void 0,searchIgnoredRoutes:U,clientIp:N(r),...te(r),requestId:ce(),messageId:typeof f?.messageId=="string"?f.messageId:void 0}},v=await K({...k,getKv:e.getKv});return await J(async()=>v,{keepAliveMs:le,onerror:s=>A.warn(`MCP handler: ${s.message}`)}).fetch(r,S!==void 0?{parsedBody:S}:void 0)},p):x()};async function Ee(r){try{return await r.json()}catch(e){throw new Q(e instanceof Error?e.message:String(e),{cause:e})}}var ze=Me;export{ze as default};
@@ -1 +1 @@
1
- import{withPathPrefix as g}from"@redocly/theme/core/utils";import{importApiRoutesHandler as h}from"../../../api-routes/import-api-routes-handlers.js";import{enhanceContext as D}from"../../../api-routes/helpers/enhance-context.js";import{telemetry as A}from"../../../telemetry/index.js";import{KvService as E}from"../../../persistence/kv/services/kv-service.js";import{envConfig as l}from"../../../config/env-config.js";import{acceptsHtml as R}from"../../../utils/ai-agent-detection.js";import{handleErrorPageRender as T}from"../../../web-server/utils.js";import{MCP_DOCS_SERVER_HANDLER_ID as _,MCP_NOT_ALLOWED_TEMPLATE_ID as w}from"../../../constants/mcp.js";import{resolvePublicBaseUrl as S}from"../../../web-server/utils/resolve-public-base-url.js";import{getForwardedOrigin as q}from"../../../web-server/utils/get-request-origin.js";import{applyEdgeRateLimit as C}from"../gateway-mcp/rate-limit/request-limiter/apply-edge-rate-limit.js";import{fetchCountSecret as O}from"../gateway-mcp/rate-limit/fetch-limiter/fetch-count-secret.js";async function G(a,t,e){const n=t.req.raw;if(a.requestHandlerId===_&&n.method==="GET"&&R(n.headers.get("accept"))&&e.globalData.mcpData?.docs?.enabled)return T(t,e,{slug:a.slug},405,w);const r=t.get("auth"),o=await C(n,e);if(o)return o;const s=await e.resolveRouteStaticData(a)||{},m=g(a.slug),{requestHandlers:c}=await h(e.serverOutDir),p=c[a.requestHandlerId],d=(await p()).default,u=async()=>await E.getInstance({baseDbDir:e.serverOutDir,sqldRemoteDatabaseUrl:l.SQLD_REMOTE_DATABASE_URL,sqldRemoteDatabaseAuthToken:l.SQLD_REMOTE_DATABASE_AUTH_TOKEN}),f=D({honoCtx:t,ctx:{user:{teams:r.teams,email:r.claims.email,claims:r.claims,idpAccessToken:r.idpAccessToken,idpId:r.claims.idpId,isAuthenticated:r.isAuthenticated},config:e.config,outdir:e.outdir,baseUrl:q(t.req.raw)},telemetry:A,getKv:u}),i=await d(t.req.raw,f,{...s,props:{...s.props,routeSlug:m,outdir:e.outdir,fetchCountSecret:O(),skills:e.config.skills?.hide===!0?[]:e.getSkills(),skillsBaseUrl:S(e,t)}});return i instanceof Response?i:typeof i=="string"?new Response(i,{headers:{"Content-Type":"text/plain"}}):new Response(JSON.stringify(i),{headers:{"Content-Type":"application/json"}})}export{G as handleMcpRequest};
1
+ import{withPathPrefix as g}from"@redocly/theme/core/utils";import{importApiRoutesHandler as h}from"../../../api-routes/import-api-routes-handlers.js";import{enhanceContext as D}from"../../../api-routes/helpers/enhance-context.js";import{telemetry as A}from"../../../telemetry/index.js";import{KvService as E}from"../../../persistence/kv/services/kv-service.js";import{envConfig as l}from"../../../config/env-config.js";import{acceptsHtml as R}from"../../../utils/ai-agent-detection.js";import{handleErrorPageRender as T}from"../../../web-server/utils.js";import{MCP_DOCS_SERVER_HANDLER_ID as _,MCP_NOT_ALLOWED_TEMPLATE_ID as w}from"../../../constants/mcp.js";import{resolvePublicBaseUrl as S}from"../../../web-server/utils/resolve-public-base-url.js";import{getForwardedOrigin as q}from"../../../web-server/utils/get-request-origin.js";import{applyEdgeRateLimit as C}from"../gateway-mcp/rate-limit/request-limiter/apply-edge-rate-limit.js";import{fetchCountSecret as O}from"../gateway-mcp/rate-limit/fetch-limiter/fetch-count-secret.js";async function K(i,t,e){const n=t.req.raw;if(i.requestHandlerId===_&&n.method==="GET"&&R(n.headers.get("accept"))&&e.globalData.mcpData?.docs?.enabled)return T(t,e,{slug:i.slug},405,w);const r=t.get("auth"),o=await C(n,e);if(o)return o;const s=await e.resolveRouteStaticData(i)||{},c=g(i.slug),{requestHandlers:m}=await h(e.serverOutDir),p=m[i.requestHandlerId],d=(await p()).default,u=async()=>await E.getInstance({baseDbDir:e.serverOutDir,sqldRemoteDatabaseUrl:l.SQLD_REMOTE_DATABASE_URL,sqldRemoteDatabaseAuthToken:l.SQLD_REMOTE_DATABASE_AUTH_TOKEN}),f=D({honoCtx:t,ctx:{user:{teams:r.teams,email:r.claims.email,claims:r.claims,idpAccessToken:r.idpAccessToken,idpId:r.claims.idpId,isAuthenticated:r.isAuthenticated},config:e.config,outdir:e.outdir,baseUrl:q(t.req.raw)},telemetry:A,getKv:u}),a=await d(t.req.raw,f,{...s,props:{...s.props,routeSlug:c,outdir:e.outdir,fetchCountSecret:O(),skills:e.config.skills?.hide===!0?[]:e.getSkills(),skillsBaseUrl:S(e,t),configFile:e.configFile}});return a instanceof Response?a:typeof a=="string"?new Response(a,{headers:{"Content-Type":"text/plain"}}):new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"}})}export{K as handleMcpRequest};
@@ -1 +1 @@
1
- import{logger as N}from"../../../tools/notifiers/logger.js";import{mcpToolWorkers as y,MCP_TOOL_IS_AVAILABLE_KEY as U}from"../../../workers/mcp-tool-worker-pool.js";import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as S,MANAGE_API_CREDENTIALS_TOOL_NAME as w,SUBMIT_FEEDBACK_TOOL_NAME as h}from"../constants.js";import{isAnonymousSessionToolAvailable as I}from"../docs-mcp/tools/core/create-anonymous-session.js";import{isManageApiCredentialsToolAvailable as x,manageApiCredentials as H,manageApiCredentialsSchema as B}from"../codemode/tools/manage-credentials.js";import{EXECUTE_TOOL_SCHEMA as M,executeToolTitle as F}from"../codemode/tools/execute-schema.js";import{EXECUTE_TOOL_NAME as P,CODE_MODE_TOOL_NAMES as g,FETCH_TOOL_NAME as R}from"../codemode/constants.js";import{buildCodeModeInstructions as Y,buildExecuteDescription as z}from"../codemode/prompts.js";import{toToolListEntries as K}from"../codemode/build-tool-list.js";import{composeExecuteAnnotations as W,getActiveCapabilities as X}from"../codemode/capabilities/index.js";import{describeToolsSchema as $,describeTools as j}from"../codemode/tools/describe-tools.js";import{availableSandboxTools as G}from"../utils/available-sandbox-tools.js";import{resolveDocsSiteUrl as V}from"../utils/docs-site-url.js";import{isToolDisabledByCaller as b}from"../utils/disabled-tools.js";import{toRegisterToolConfig as L}from"../utils/tool-registration.js";import{createMcpServer as q,createToolDispatch as J,extractSerializableContext as Q}from"./mcp-server.js";const Z=new Set([...g].filter(s=>s!==h));function v(s,a){const o=a.schema;if(s)return o;const{sessionHandle:u,...f}=o.properties;return{...o,properties:f}}function ee(s){return Object.fromEntries(s.map(a=>[a.name,a.schema]))}async function ue({name:s,tools:a,context:o,skills:u=[],getKv:f}){const l=Q(o),r=o.mcpMode==="code",c=r?X(o):[],_=c.some(e=>e.id===R),m=r?await G(a.filter(e=>!g.has(e.name)),l):[],A=K(m,c),T=I(o)&&!b(S,o.metadata),D=r&&x(o)&&!b(w,o.metadata),p=q(s,r?Y(_,A):void 0),O={getClientCapabilities:()=>p.server.getClientCapabilities(),getKv:f},d=J(r?{...l,sandboxToolSchemas:ee(m)}:l,O),C=async e=>{try{return await y.exec(U,[{toolName:e,context:l}],{timeout:1e4})}catch(i){return N.error(`Failed to check MCP tool availability for "${e}": ${i instanceof Error?i.message:String(i)}`),!1}};if(r){const e=W(m,c,o.config?.mcp),i=[{tool:{...M,title:F(e),description:z(_,A,V(o.config?.seo?.siteUrl,o.baseUrl)),schema:v(T,M),annotations:e},callback:d(P)},{tool:$(m,c),callback:j(m,C,c,o)}],n=a.find(t=>t.name===h);n&&!b(n.name,o.metadata)&&i.push({tool:n,callback:d(n.name)});const E=a.find(t=>t.name===S);if(E&&T&&i.push({tool:E,callback:d(E.name)}),D){const t=B(o);i.push({tool:{...t,schema:v(T,t)},callback:H(l,O)})}for(const{tool:t,callback:k}of i)p.registerTool(t.name,L(t),k)}else{const e=a.filter(i=>!Z.has(i.name));await Promise.all(e.map(async i=>{const n=p.registerTool(i.name,L({...i,outputSchema:void 0}),d(i.name));await C(i.name)||n.disable()}))}for(const e of u)p.registerResource(e.slug,e.uri,{title:e.name,description:e.description,mimeType:"text/markdown"},async()=>({contents:[{uri:e.uri,mimeType:"text/markdown",text:e.content}]}));return p}export{ue as createDocsMcpServer};
1
+ import{CREATE_ANONYMOUS_SESSION_TOOL_NAME as C,MANAGE_API_CREDENTIALS_TOOL_NAME as k,SUBMIT_FEEDBACK_TOOL_NAME as S}from"../constants.js";import{isAnonymousSessionToolAvailable as U}from"../docs-mcp/tools/core/create-anonymous-session.js";import{isManageApiCredentialsToolAvailable as w,manageApiCredentials as y,manageApiCredentialsSchema as H}from"../codemode/tools/manage-credentials.js";import{EXECUTE_TOOL_SCHEMA as h,executeToolTitle as I}from"../codemode/tools/execute-schema.js";import{EXECUTE_TOOL_NAME as R,CODE_MODE_TOOL_NAMES as M,FETCH_TOOL_NAME as B}from"../codemode/constants.js";import{buildCodeModeInstructions as F,buildExecuteDescription as x}from"../codemode/prompts.js";import{toToolListEntries as z}from"../codemode/build-tool-list.js";import{composeExecuteAnnotations as X,getActiveCapabilities as Y}from"../codemode/capabilities/index.js";import{describeToolsSchema as j,describeTools as G}from"../codemode/tools/describe-tools.js";import{availableTools as g}from"../utils/available-tools.js";import{resolveDocsSiteUrl as K}from"../utils/docs-site-url.js";import{isToolDisabledByCaller as b}from"../utils/disabled-tools.js";import{toRegisterToolConfig as N}from"../utils/tool-registration.js";import{createMcpServer as P,createToolDispatch as W,extractSerializableContext as q}from"./mcp-server.js";const J=new Set([...M].filter(s=>s!==S));function D(s,t){const e=t.schema;if(s)return e;const{sessionHandle:u,...T}=e.properties;return{...e,properties:T}}function Q(s){return Object.fromEntries(s.map(t=>[t.name,t.schema]))}async function pe({name:s,tools:t,context:e,skills:u=[],getKv:T}){const l=q(e),n=e.mcpMode==="code",c=n?Y(e):[],O=c.some(o=>o.id===B),m=n?await g(t.filter(o=>!M.has(o.name)),l):[],_=z(m,c),E=U(e)&&!b(C,e.metadata),v=n&&w(e)&&!b(k,e.metadata),p=P(s,n?F(O,_):void 0),A={getClientCapabilities:()=>p.server.getClientCapabilities(),getKv:T},f=W(n?{...l,sandboxToolSchemas:Q(m)}:l,A);if(n){const o=X(m,c,e.config?.mcp),r=[{tool:{...h,title:I(o),description:x(O,_,K(e.config?.seo?.siteUrl,e.baseUrl)),schema:D(E,h),annotations:o},callback:f(R)},{tool:j(m,c),callback:G(m,c,e)}],i=t.find(a=>a.name===S);i&&!b(i.name,e.metadata)&&r.push({tool:i,callback:f(i.name)});const d=t.find(a=>a.name===C);if(d&&E&&r.push({tool:d,callback:f(d.name)}),v){const a=H(e);r.push({tool:{...a,schema:D(E,a)},callback:y(l,A)})}for(const{tool:a,callback:L}of r)p.registerTool(a.name,N(a),L)}else{const o=t.filter(i=>!J.has(i.name)),r=new Set((await g(o,l)).map(i=>i.name));for(const i of o){const d=p.registerTool(i.name,N({...i,outputSchema:void 0}),f(i.name));r.has(i.name)||d.disable()}}for(const o of u)p.registerResource(o.slug,o.uri,{title:o.name,description:o.description,mimeType:"text/markdown"},async()=>({contents:[{uri:o.uri,mimeType:"text/markdown",text:o.content}]}));return p}export{pe as createDocsMcpServer};