@redocly/redoc-reef 0.140.0-next.7 → 0.140.0-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/client/app/useGlobalData.d.ts +1 -1
- package/dist/client/providers/post-message/use-post-message.d.ts +1 -1
- package/dist/server/config/env-config.d.ts +2 -0
- package/dist/server/config/env-schema.d.ts +4 -0
- package/dist/server/config/env-schemas/feature-flags.d.ts +4 -0
- package/dist/server/config/env-schemas/feature-flags.js +1 -1
- package/dist/server/plugins/api-docs/definition-access.d.ts +22 -0
- package/dist/server/plugins/api-docs/definition-access.js +1 -0
- package/dist/server/plugins/api-docs/index.js +1 -1
- package/dist/server/plugins/api-docs/options.js +1 -1
- package/dist/server/plugins/api-docs/spec-download.api.js +1 -1
- package/dist/server/plugins/api-docs/store-definition-bundles.d.ts +0 -6
- package/dist/server/plugins/api-docs/store-definition-bundles.js +1 -1
- package/dist/server/plugins/config-parser/loaders/utils/read-and-validate-config.js +1 -1
- package/dist/server/plugins/mcp/handlers/docs-mcp-handler.js +1 -1
- package/dist/server/plugins/mcp/handlers/errors.d.ts +0 -5
- package/dist/server/plugins/mcp/handlers/errors.js +1 -1
- package/dist/server/plugins/mcp/handlers/mcp-credentials-handler.js +1 -1
- package/dist/server/plugins/mcp/servers/mcp-server.js +2 -2
- package/dist/server/plugins/scorecard-classic/compute-scorecard.d.ts +2 -2
- package/dist/server/plugins/scorecard-classic/compute-scorecard.js +1 -1
- package/dist/server/plugins/scorecard-classic/index.js +1 -1
- package/dist/server/tools/notifiers/helpers/colors.d.ts +1 -1
- package/dist/server/utils/envs/load-env-variables.js +1 -1
- package/dist/server/utils/rbac-expand.js +1 -1
- package/dist/server/utils/rbac.d.ts +5 -1
- package/dist/server/utils/rbac.js +1 -1
- package/dist/server/utils/report-all-errors.js +1 -1
- package/dist/server/web-server/middleware/jsonValidatorMiddleware.d.ts +1 -590
- package/dist/server/web-server/utils/ssrf-safe-lookup.d.ts +2 -1
- package/dist/server/web-server/utils/ssrf-safe-lookup.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @redocly/redoc-reef
|
|
2
2
|
|
|
3
|
+
## 0.140.0-next.9
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c99079a7487: Renamed the `reunite` option and the `access.rbac.reunite` scope in `redocly.yaml` to `platform` and deprecated the old names.
|
|
8
|
+
Using the old names does not fail the build, but produces warnings in the build log.
|
|
9
|
+
|
|
10
|
+
## 0.140.0-next.8
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- dc825f9c248: Improved keyboard navigation in catalog entity version history.
|
|
15
|
+
The arrow keys open the version list and move between versions, the `Escape` key closes the list, and the focused version shows a focus ring.
|
|
16
|
+
- fee19712620: Fixed an issue where reaction-specific reasons in page feedback forms did not use the configured labels or components.
|
|
17
|
+
- fee19712620: Fixed an issue where the `rating` and `sentiment` page feedback forms accepted invalid email addresses without prompting users to correct them.
|
|
18
|
+
- fee19712620: Improved page feedback forms so that screen readers announce the comment and email fields with their labels.
|
|
19
|
+
- fee19712620: Fixed the `mood` form to show its reaction-specific default comment label when `comment` is not configured.
|
|
20
|
+
- fee19712620: Fixed an issue where the `sentiment` and `mood` page feedback forms sent the reasons a user selected for one reaction after they switched to another reaction.
|
|
21
|
+
- fee19712620: Fixed the **Cancel** button in the `scale` page feedback form so it uses the same translation key as other feedback forms. If you translated `feedback.settings.comment.cancel` for this button, move that translation to `feedback.cancel`.
|
|
22
|
+
- 5dbc15ee73c: Fixed a security vulnerability that could allow a request to the Docs MCP server to consume excessive memory.
|
|
23
|
+
- Updated dependencies [dc825f9c248]
|
|
24
|
+
- Updated dependencies [fee19712620]
|
|
25
|
+
- Updated dependencies [fee19712620]
|
|
26
|
+
- Updated dependencies [fee19712620]
|
|
27
|
+
- Updated dependencies [fee19712620]
|
|
28
|
+
- Updated dependencies [fee19712620]
|
|
29
|
+
- Updated dependencies [fee19712620]
|
|
30
|
+
- @redocly/theme@0.72.0-next.5
|
|
31
|
+
- @redocly/api-docs@0.5.0-next.6
|
|
32
|
+
|
|
3
33
|
## 0.140.0-next.7
|
|
4
34
|
|
|
5
35
|
### Minor Changes
|
|
@@ -147,6 +177,17 @@
|
|
|
147
177
|
- Updated dependencies [cc40376e265]
|
|
148
178
|
- @redocly/api-docs@0.5.0-next.0
|
|
149
179
|
|
|
180
|
+
## 0.139.4
|
|
181
|
+
|
|
182
|
+
### Patch Changes
|
|
183
|
+
|
|
184
|
+
- 3a1bc71aaf5: Fixed an issue in OpenAPI docs where the page of a schema that other schemas extend through `allOf` never finished rendering when its properties reached schemas that refer back to those extensions.
|
|
185
|
+
- 3a1bc71aaf5: Fixed an issue in OpenAPI docs where a page never finished rendering when two discriminator schemas listed the same variants and both declared the properties the variants inherit.
|
|
186
|
+
- 460fdd452f2: Fixed an issue where the Docs MCP server in projects with large configurations used too much memory and responded slowly.
|
|
187
|
+
- Updated dependencies [3a1bc71aaf5]
|
|
188
|
+
- Updated dependencies [3a1bc71aaf5]
|
|
189
|
+
- @redocly/api-docs@0.4.2
|
|
190
|
+
|
|
150
191
|
## 0.139.3
|
|
151
192
|
|
|
152
193
|
### Patch Changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function useGlobalData(): import("../../types
|
|
1
|
+
export declare function useGlobalData(): import("../../types").GlobalData;
|
|
2
2
|
//# sourceMappingURL=useGlobalData.d.ts.map
|
|
@@ -53,6 +53,7 @@ declare function loadEnvConfig(): {
|
|
|
53
53
|
REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_URL?: string | undefined;
|
|
54
54
|
REDOCLY_EXP_LLMSTXT_AGENT_ENDPOINT?: string | undefined;
|
|
55
55
|
REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED: boolean | undefined;
|
|
56
|
+
REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED: boolean | undefined;
|
|
56
57
|
SEARCH_DEV_REINIT?: string | undefined;
|
|
57
58
|
SEARCH_DEV_DEBUG: boolean;
|
|
58
59
|
REDOCLY_SKIP_TYPESENSE_INDEXING: boolean;
|
|
@@ -134,6 +135,7 @@ export declare const envConfig: {
|
|
|
134
135
|
REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_URL?: string | undefined;
|
|
135
136
|
REDOCLY_EXP_LLMSTXT_AGENT_ENDPOINT?: string | undefined;
|
|
136
137
|
REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED: boolean | undefined;
|
|
138
|
+
REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED: boolean | undefined;
|
|
137
139
|
SEARCH_DEV_REINIT?: string | undefined;
|
|
138
140
|
SEARCH_DEV_DEBUG: boolean;
|
|
139
141
|
REDOCLY_SKIP_TYPESENSE_INDEXING: boolean;
|
|
@@ -96,6 +96,10 @@ export declare const envSchema: z.ZodObject<{
|
|
|
96
96
|
false: "false";
|
|
97
97
|
true: "true";
|
|
98
98
|
}>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
|
|
99
|
+
REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
|
|
100
|
+
false: "false";
|
|
101
|
+
true: "true";
|
|
102
|
+
}>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
|
|
99
103
|
SEARCH_DEV_REINIT: z.ZodOptional<z.ZodString>;
|
|
100
104
|
SEARCH_DEV_DEBUG: z.ZodPipe<z.ZodDefault<z.ZodEnum<{
|
|
101
105
|
false: "false";
|
|
@@ -31,5 +31,9 @@ export declare const featureFlagsSchema: z.ZodObject<{
|
|
|
31
31
|
false: "false";
|
|
32
32
|
true: "true";
|
|
33
33
|
}>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
|
|
34
|
+
REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
|
|
35
|
+
false: "false";
|
|
36
|
+
true: "true";
|
|
37
|
+
}>>, z.ZodTransform<boolean | undefined, "false" | "true" | undefined>>;
|
|
34
38
|
}, z.core.$strip>;
|
|
35
39
|
//# sourceMappingURL=feature-flags.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as _}from"zod";import{envBooleanStringOptional as E}from"../../utils/envs/env-boolean-string.js";const o=_.object({NEW_CATALOG_ENABLED:E(),NEW_SCORECARDS_ENABLED:E(),ENABLE_COMMENTS:_.string().optional(),REDOCLY_EXP_DISABLE_MD_VALIDATION:E(),ENABLE_SOURCE_MAPS:E(),PLAN_GATES:_.string().optional(),REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_ENABLED:E(),REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_URL:_.string().optional(),REDOCLY_EXP_LLMSTXT_AGENT_ENDPOINT:_.string().optional(),REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED:E()});export{o as featureFlagsSchema};
|
|
1
|
+
import{z as _}from"zod";import{envBooleanStringOptional as E}from"../../utils/envs/env-boolean-string.js";const o=_.object({NEW_CATALOG_ENABLED:E(),NEW_SCORECARDS_ENABLED:E(),ENABLE_COMMENTS:_.string().optional(),REDOCLY_EXP_DISABLE_MD_VALIDATION:E(),ENABLE_SOURCE_MAPS:E(),PLAN_GATES:_.string().optional(),REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_ENABLED:E(),REDOCLY_EXP_LLMSTXT_AGENT_FEEDBACK_URL:_.string().optional(),REDOCLY_EXP_LLMSTXT_AGENT_ENDPOINT:_.string().optional(),REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED:E(),REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED:E()});export{o as featureFlagsSchema};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RbacScopeItems } from '@redocly/config';
|
|
2
|
+
import type { BundledApiDefinition } from './loader.js';
|
|
3
|
+
/** What the download route needs to apply the API page's access rule to one definition. */
|
|
4
|
+
export type ApiDefinitionAccess = {
|
|
5
|
+
/** Content-relative source file (`customOutputRelativeFile || relativePath`). */
|
|
6
|
+
sourcePath: string;
|
|
7
|
+
/** The API's base page slug, e.g. `/apis/internal`. */
|
|
8
|
+
slug: string;
|
|
9
|
+
/** `apis.<name>.rbac`; replaces the content rule when present. */
|
|
10
|
+
rbac?: RbacScopeItems;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The key of the definition that a download of `stem` on the GraphQL route (`/_spec-gql`) or
|
|
14
|
+
* on a bundle route (`/_bundle`, `/_spec`) describes; `stem` is the request path after the
|
|
15
|
+
* route prefix without its extension (`apis/museum` for `apis/museum.yaml`), so one bundle
|
|
16
|
+
* answers under `.json`, `.yaml` and `.yml`. A schema and a bundle of one stem have distinct keys.
|
|
17
|
+
*/
|
|
18
|
+
export declare function requestDefinitionAccessKey(isGraphql: boolean, stem: string): string;
|
|
19
|
+
/** The key of `definition` in the access map; undefined for one under the public static folder. */
|
|
20
|
+
export declare function definitionAccessKey(definition: Pick<BundledApiDefinition, 'relativePath' | 'type'>): string | undefined;
|
|
21
|
+
export declare function describeDefinitionAccess(definition: BundledApiDefinition, basePath: string): ApiDefinitionAccess;
|
|
22
|
+
//# sourceMappingURL=definition-access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PUBLIC_STATIC_FOLDER as o}from"../../constants/common.js";import{removeTrailingSlash as i}from"../../../utils/url/remove-trailing-slash.js";import{resolveConfigRbac as n}from"./utils/resolve-config-rbac.js";import{replaceFileExtension as c}from"./utils/replace-file-extension.js";function s(e,r){return`${e?"graphql":"bundle"}:${r}`}function f(e){if(!e.relativePath.startsWith(o+"/"))return s(e.type==="graphql",c(e.relativePath,""))}function m(e,r){const t=n(e.config);return{sourcePath:e.customOutputRelativeFile||e.relativePath,slug:i(r),...t===void 0?{}:{rbac:t}}}export{f as definitionAccessKey,m as describeDefinitionAccess,s as requestDefinitionAccessKey};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_ROUTE_RBAC as T,REDOCLY_TEAMS_RBAC as
|
|
1
|
+
import{REDOCLY_ROUTE_RBAC as T,REDOCLY_TEAMS_RBAC as v}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 O}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{storeDefinitionBundles as gt}from"./store-definition-bundles.js";import{definitionAccessKey as ht,describeDefinitionAccess as Dt}from"./definition-access.js";import{telemetryTraceStep as St}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as Pt}from"./search/search-resolver.js";import{getAiDocumentsStore as yt}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as At}from"../get-api-config.js";import{getRouteSlugsForPath as It}from"../utils.js";import{collectItemRoutes as vt}from"./utils/collect-item-routes.js";import{isChunkCurrent as bt}from"./utils/decorators.js";import{applyNavItemToRoot as Rt}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as _t}from"./utils/build-routes-mapping.js";import{buildItemPositions as Ct}from"./utils/build-item-positions.js";import{resolveApiDocTitle as Tt}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as K}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as wt}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as Et}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as W}from"./import-api-docs-builder.js";import{envConfig as G}from"../../config/env-config.js";import{logger as kt}from"../../tools/notifiers/logger.js";const F="openapi-spec-download",Ot={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function he(){let e=[],r=new Map;const s=new WeakMap;let n=new Set,f={},A={};function Y(o,S,b){const I=s.get(o)??new Map;s.set(o,I);const P=S??"";return I.get(P)===b?!1:(I.set(P,b),!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(F,ct(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:nt+"/*",requestHandlerId:F,httpMethod:"all",[v]:N,getStaticData:async()=>({props:{definitionAccess:A}})}),o.addApiRoute({slug:it+"/*",requestHandlerId:F,httpMethod:"all",[v]:N,getStaticData:async()=>({props:{definitionAccess:A}})}),o.addApiRoute({slug:st+"/*",requestHandlerId:F,httpMethod:"all",[v]:N,getStaticData:async()=>({props:{definitionAccess:A}})});const b=o.createTemplate(j,V("../../../client/templates/api-docs/template.js")),I=o.registerServerPropsGetter(j,V("./get-server-props.js")),P=await S.getConfig();r=new Map,f={};const y=await o.loadApiDocuments(S);gt(y,o.outdir),A={};const w=!!P.plugins?.some(t=>typeof t=="string"&&t.startsWith("@redocly/portal-plugin-async-api/"));w&&y.some(t=>t.type==="asyncapi")&&kt.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const p=w?y.filter(t=>t.type!=="asyncapi"):y;e=p.map(({markdocChunks:t,relativePath:u,isVirtual:c,customOutputRelativeFile:a,realRelativePath:D})=>({chunks:t??[],relativePath:u,realRelativePath:D,isVirtual:a!=null||c}));const{buildItems:i}=await W(o.serverOutDir),g=(await S.cache.load("content-slugs","content-slugs")).data,h=dt(g),E=t=>pt(h(t));for(const t of y){const u=ht(t);if(u===void 0)continue;const c=E(t.customOutputRelativeFile||t.relativePath);A[u]=Dt(t,c)}for(const t of p){const u=t.customOutputRelativeFile||t.relativePath,c=E(u);Lt(t,c);const{items:a,store:D}=await i({type:t.type,document:t.document,options:t.options,basePath:c,markdownParser:U}),R=`${O}${t.relativePath}`,M=G.isDevelopMode?t.relativePath:void 0,l=qt(t.document),_=l?.["x-metadata"],C=t.isVirtual?void 0:_?.apiId,L={document:t,basePath:c,sourcePath:M,apiId:C,build:{items:a,store:D}};await o.createSharedData(R,Q(L,a,D));const X=K(t.config),B=!!t.options.excludeFromSearch,J=t.type==="openapi",Z=vt(a,X),tt=lt(t),m=Z.map(d=>{const x=d.metadata?.seo,k={fsPath:u,templateId:b,sharedData:[{key:"apiDocsStore",id:R}],serverPropsGetterIds:[I],excludeFromSearch:B,getStaticData:Mt(d.label,x,tt),[v]:d[v]};return Object.assign(k,Bt(d.link,c)),J&&d.httpVerb&&(k.httpVerb=d.httpVerb,k.metadata={subType:"openapi-operation"}),k});if(!m.length)continue;const H=Tt(l,t.type,a),et=Et(l?.version),q={type:t.type,title:H,version:et,description:typeof l?.description=="string"?l.description:void 0,summary:typeof l?.summary=="string"?l.summary:void 0,...l?.["x-metadata"]&&typeof l["x-metadata"]=="object"?l["x-metadata"]:{}};m[0]={...m[0],metadata:q,hasClientRoutes:!0,getSidebar:(d,x)=>Rt(z(a),c,x),getNavText:()=>H??Ot[t.type]??"API Docs",getSearchDocuments:Pt(a,q,o.getSearchFacets,o.setSearchFacets,B,D,t.document),getAiDocumentsStore:yt({getBuild:()=>L.build,metadata:q,document:t.document,specType:t.type,excludeFromSearch:B,basePath:c,getSearchFacets:o.getSearchFacets,markdocTags:{...rt,schemaDefinition:at}})};const ot=m[0];m[0]=m[m.length-1],m[m.length-1]=ot;for(const d of m)o.addRoute(d);if(C){const d=At(t.config?.apis,t.realRelativePath);f[C]={[v]:d.rbac,[T]:{fsPath:u}}}r.set(R,L)}})},afterRoutesCreated:async(o,S)=>{const{buildItems:b,simplifyAstStructure:I}=await W(o.serverOutDir),P=new Set,y=new Set;for(const{chunks:p,relativePath:i,isVirtual:g}of e){const h=`${O}${i}`,E=It(o.getAllRoutes(),i);for(const{node:t,markdown:u,pointer:c,key:a,relativePath:D}of p){const{ast:R,compoundHash:M}=await o.parseMarkdoc({input:{content:u,relativePath:D,isVirtual:g},resource:c,context:S,deps:{sharedDataIds:[`${O}${D}`],routeSlugs:E}});if(P.add(c),!(a==="graphql-docs"?t?.description?.value!==void 0:!!a&&bt(t,a,u))||!Y(t,a,M))continue;y.add(h);const _=I(R);if(a==="graphql-docs"){t.description&&(t.description.value=_);const C=`${O}${D}`;Ft(r.get(C),_)}else a&&(t[a]=_)}}const w=n.difference(P);for(const p of w)S.cache.delete(p);n=P,Object.entries(f).forEach(([p,i])=>{const g=i[T]?.fsPath;if(!g)return;const h=o.getRouteByFsPath(g)?.baseSlug;f[p]={...i,[T]:{...i[T],slug:h},slug:h}}),o.setGlobalData({apiProducts:f});for(const[p,i]of r){if(!y.has(p))continue;const{items:g,store:h}=await b({type:i.document.type,document:i.document.document,options:i.document.options,basePath:i.basePath,markdownParser:U});i.build={items:g,store:h},await o.createSharedData(p,Q(i,g,h))}}}}function Q({document:e,basePath:r,sourcePath:s,apiId:n},f,A){return{[v]:K(e.config),[T]:{slug:ut(r),fsPath:e.customOutputRelativeFile||e.relativePath},items:f,store:A,options:e.options,baseSlug:r,routesMapping:G.isDevelopMode?_t(f,r):{},graphqlPositions:G.isDevelopMode&&e.type==="graphql"?Ct(f,r):void 0,sourcePath:s,apiId:n}}function Ft(e,r){e?.document.type!=="graphql"||!e.document.options||(e.document.options.info={...e.document.options.info||{},description:r})}function Mt(e,r,s){return async function(n){return{...s?{isTranslationFallback:!0}:{},props:{settings:{baseUrlPath:$(n.baseSlug)},disableAutoScroll:!0,seo:{title:e,...r}}}}}function Lt(e,r){const s=e.options?.mockServer,n=$(`/_mock${wt(e.relativePath)}`);s?.url===n&&(e.options={...e.options,mockServer:{...s,url:$(`/_mock${r}`)}})}function Bt(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 qt(e){if(e&&typeof e=="object"&&"info"in e)return e.info}function z(e){return e.map(({content:r,items:s,...n})=>({...n,...s&&{items:z(s)}}))}export{he as apiDocsPlugin,Bt as toRouteSlugFields};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as O from"node:path";import{findFirstBinding as A,markdocParser as F}from"@redocly/api-docs";import{combineUrls as i}from"@redocly/theme/core/openapi";import{withPathPrefix as k}from"@redocly/theme/core/utils";import{GRAPHQL_SPEC_SLUG as L}from"../../../constants/common.js";import{PUBLIC_API_DEFINITIONS_FOLDER as f}from"../../constants/common.js";import{envConfig as E}from"../../config/env-config.js";import{deepMerge as w}from"../../../utils/object/deep-merge.js";import{normalizeFeedbackOptions as B}from"./utils/normalize-feedback-options.js";import{replaceFileExtension as p}from"./utils/replace-file-extension.js";import{relativePathToBaseSlug as M}from"./utils/relative-path-to-base-slug.js";const R={tags:{},nodes:{},components:{}};function D(o,r){if(!(o?.off!==!0))return o;const a=M(r);return{url:k(`/_mock${a}`),position:"first",description:"Mock server",...o}}function I(o,r){return(r==="graphql"?[i(L,`${p(o,O.posix.extname(o))}?download`)]:[i(f,`${p(o,".json")}?download`),i(f,`${p(o,".yaml")}?download`)]).map(a=>({url:k(a)}))}function X(o,r,m){const{rootConfig:a,config:s,apiConfig:c,mergedConfig:e,relativePath:l}=m,n=w(a?.[o]||{},s[o]||{},c[o]||c.theme?.[o]||{}),S=r["x-feedback"]||n.feedback||s.feedback,b=!!e[o]?.excludeFromSearch||!!e.theme?.[o]?.excludeFromSearch||!!a?.[o]?.excludeFromSearch||!!a?.theme?.[o]?.excludeFromSearch,_=e.rbac||c.rbac,g=B(S),u=s.metadata,x={...g&&{feedback:g},mockServer:D(e?.mockServer||a?.mockServer,l),disableRouter:!0,downloadUrls:n.downloadUrls||I(l,o),excludeFromSearch:b,rbac:_,markdownParser:F,replayFeatures:{graphql:E.REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED??!1,asyncapi:E.REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED??!1}};let d;if(o==="graphql"){const t=n;d={title:t.info?.title,...u,...t.metadata??{}}}else{const t=r.info,P=t?.["x-metadata"];d={title:t?.title,description:t?.description,...o==="openapi"&&{summary:t?.summary},...u,...P}}o==="openapi"&&n.showSchemaCatalogLinks&&(r["x-schema-catalog-link"]=i(f,l));const C=n.markdocOptions??R,h={...n,...x,specType:o,markdocOptions:C,metadata:d};return o==="asyncapi"&&(h.protocol=A(r)??void 0),h}export{I as buildDownloadUrls,X as createOptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"node:path";import{existsSync as
|
|
1
|
+
import e from"node:path";import{existsSync as u}from"node:fs";import{readFile as I}from"node:fs/promises";import L from"js-yaml";import{withoutPathPrefix as j}from"@redocly/theme/core/utils";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as g,PUBLIC_API_DEFINITIONS_FOLDER as w}from"../../constants/common.js";import{GRAPHQL_SPEC_SLUG as T}from"../../../constants/common.js";import{requestDefinitionAccessKey as C}from"./definition-access.js";import{canDownloadApiDefinition as U,filterDataByAccessDeep as B}from"../../utils/rbac.js";import{API_DOWNLOAD_PREFIXES as G}from"../../utils/is-api-download-link.js";import{decodeRequestPath as W}from"../../utils/decode-request-path.js";import{replaceFileExtension as X}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:a,teams:m,claims:{email:d}}=o.user,S=new URL(r.url),n=W(j(S.pathname));if(n===void 0||n.endsWith("/"))return new Response("Bad Request",{status:400});const c=G.find(i=>n.startsWith(`${i}/`));if(c===void 0)return new Response("Not found",{status:404});const p=c===T,s=n.slice(c.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?.definitionAccess??{})[C(p,X(s.slice(1),""))];if(!U(n,h,P,{isAuthenticated:a,email:d,teams:m},y))return new Response("Unauthorized",{status:a?403:401});const f=t.props?.outdir||"";if(p){const i=e.join(f,w,s);if(!u(i))return new Response("Not found",{status:404});const q=await I(i,"utf-8");return new Response(q,{headers:{"Content-Type":"application/graphql"}})}const E=e.join(f,w,F(s,".json")),R=e.join(f,g,F(s,".json")),A=u(E),D=u(R);if(!A&&!D)return new Response("Not found",{status:404});const _=await I(A?E:R,"utf-8"),x=JSON.parse(_),N=B(x,{isAuthenticated:a,email:d,teams:m},h,P),O=l===".yaml"?L.dump(N):JSON.stringify(N,null,2);return new Response(O,{headers:{"Content-Type":l===".yaml"?"application/yaml":"application/json"}})};var ie=J;export{ie as default};
|
|
@@ -1,9 +1,3 @@
|
|
|
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>;
|
|
8
2
|
export declare function storeDefinitionBundles(definitions: BundledApiDefinition[], outDir: string): void;
|
|
9
3
|
//# sourceMappingURL=store-definition-bundles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as
|
|
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 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import R from"path";import{lintConfig as O,loadConfig as j,createConfigTypes as E}from"@redocly/openapi-core";import{rbacConfigSchema as q,rootRedoclyConfigSchema as S,withPlatformSection as x}from"@redocly/config";import{deepMerge as B}from"../../../../../utils/object/deep-merge.js";import{isPlainObject as y}from"../../../../../utils/guards/is-plain-object.js";import{logger as p}from"../../../../tools/notifiers/logger.js";import{BRANCH_ENV_PREFIX as k}from"../../../../../constants/common.js";import{sanitizeBranchName as I}from"../../../../utils/envs/sanitize-branch-name.js";import{envConfig as C}from"../../../../config/env-config.js";import{ajv as M,safeParsePartial as N}from"../../safe-parse.js";import{formatConfigProblem as _}from"../../format-error.js";import{ExternalResolver as D}from"../../../../fs/utils/external-ref-resolver.js";import{resolveMutuallyExclusiveProps as F}from"../../resolve-mutual-exclusion.js";function v(e,t,s,r){t in e&&e[t]&&typeof e[t]=="string"&&(/^https?:\/\/.*/.test(e[t])||r(new Error(`Invalid ${s} URL: "${e[t]}". ${s} must start with "http://" or "https://".`)))}function G(e,t){if("access"in e&&e.access&&typeof e.access=="object"){const s=e.access;v(s,"logoutReturnUrl","access.logoutReturnUrl",t),v(s,"residency","access.residency",t);const r=["requiresLogin","logoutReturnUrl","residency","sso","rbac"];for(const o of r)o in s&&s[o]!==void 0&&o in e&&e[o]!==void 0&&t(new Error(`Property '${o}' is defined both at root level and in 'access' object. Please use 'access.${o}' to define this configuration.`))}}function z(e){return M.compile(S.properties.graphql.properties.servers.items.properties.url)(e)}function T(e,t,s){if(y(e)&&Array.isArray(e.servers))for(const r of e.servers){const o=y(r)?r.url:void 0;if(typeof o=="string"&&!z(o)){const a=e.servers.indexOf(r),c=`${t}.servers[${a}].url`;s(new Error(`Invalid ${c}: "${o}". It must be an absolute http:// or https:// URL.`))}}}function V(e,t){if(T(e.graphql,"graphql",t),!!y(e.apis))for(const[s,r]of Object.entries(e.apis))y(r)&&T(r.graphql,`apis.${s}.graphql`,t)}async function ue(e,t,s,r){const a=t.getFileInfo(e)?.realRelativePath||e;async function c(){const f=new D(t),m=R.join(t.cwd,a),d=await j({configPath:m,externalRefResolver:f}),h=await r(d.resolvedConfig);if(h===void 0)return d.resolvedConfig;const g=d.document?.source,P=[...g?await O({config:d,externalConfigTypes:E(h,d)}):[],...g?F(d.resolvedConfig,g):[]];if(P.length>0)for(const L of P)s(new Error(_(L,t.cwd)));return d.resolvedConfig}const n=t.exists(e)?await c():{},l=X(n),w=await r(n);v(n,"residency","Residency",s),v(n,"logoutReturnUrl","Logout return URL",s),G(n,s),V(n,s);let u=w?N(w,n):n;u=H(u),u=W(u,s);const{env:b}=u;if(b){const f=C.REDOCLY_ENV,m=b[f]||{},d=C.PUBLIC_REDOCLY_BRANCH_NAME||"",h=d?I(d):"",g=h&&b[`${k}${h}`]||{};u=B(u,g,m)}const i=J(u,l);if(i.imports&&i.imports.length>0){p.warn("The 'imports' property is deprecated. Please use 'plugins' property instead.");const f=new Set([...i.plugins||[],...i.imports.map(m=>R.posix.join(m,"plugin.js"))]);i.plugins=Array.from(f),delete i.imports}if(i.catalog&&(p.warn("The 'catalog' property is deprecated. Please use 'catalogClassic' property instead."),i.catalogClassic={...i.catalog},delete i.catalog),i.scorecard&&(p.warn("The 'scorecard' property is deprecated. Please use 'scorecardClassic' property instead."),i.scorecardClassic=i.scorecard,delete i.scorecard),i.search?.ai){p.warn("The 'search.ai' property is deprecated. Please use 'aiAssistant' property instead.");const f={...i.search?.ai,...i.aiAssistant,suggestions:i.aiAssistant?.suggestions?.length?i.aiAssistant.suggestions:i.search?.ai.suggestions||[]};i.aiAssistant=f,delete i.search.ai}return Y(i)}function Y(e){const t={...e},r={..."access"in e&&e.access&&typeof e.access=="object"?e.access:{}},o=["requiresLogin","logoutReturnUrl","residency","sso","idps","rbac"],a=[];for(const c of o){const n=t[c];n!==void 0&&(a.push(c),c==="requiresLogin"&&r.requiresLogin===void 0&&(r.requiresLogin=n),c==="logoutReturnUrl"&&r.logoutReturnUrl===void 0&&(r.logoutReturnUrl=n),c==="residency"&&r.residency===void 0&&(r.residency=n),c==="sso"&&r.sso===void 0&&(r.sso=n),c==="idps"&&r.idps===void 0&&(r.idps=n),c==="rbac"&&r.rbac===void 0&&(r.rbac=n),delete t[c])}return a.length>0&&p.warn(`The following properties at root level are deprecated: ${a.join(", ")}. Please move them to the 'access' object.`),Object.keys(r).length>0&&(t.access=r),t}function H(e){const t=Object.entries(e.env??{});[e,...t.map(([,o])=>o)].some(o=>o?.mcp?.docs)&&p.warn("The 'mcp.docs' property is deprecated. Please use the 'mcp' properties instead.");const s=e.mcp?{...e,mcp:A(e.mcp)}:e;if(!e.env)return s;const r=t.map(([o,a])=>[o,a?.mcp?{...a,mcp:A(a.mcp)}:a]);return{...s,env:Object.fromEntries(r)}}function A(e){const t=e.docs??{},s={};(e.hide??t.hide)!==void 0&&(s.hide=e.hide===!0||t.hide===!0);const r=e.name??t.name;r!==void 0&&(s.name=r);const o=e.ignore??t.ignore;o!==void 0&&(s.ignore=o);const a=e.publicEndpoint??t.publicEndpoint;return a!==void 0&&(s.publicEndpoint=a),{...e,...s,docs:{...t,...s}}}function K(e){if(!y(e)||e.platform===void 0)return!1;const t=Object.keys(e).filter(s=>s!=="platform");return t.length>0&&t.every(s=>!Object.hasOwn(q.properties,s))}function W(e,t){const s=Object.entries(e.env??{}),r=new Set;let o=!1;for(const n of[e,...s.map(([,l])=>l)])n?.reunite!==void 0&&r.add("The 'reunite' property is deprecated. Please use 'platform' property instead."),n?.reunite!==void 0&&n?.platform!==void 0&&r.add("Both 'platform' and 'reunite' are set. 'reunite' is ignored, so remove it."),[n?.rbac,n?.access?.rbac].some(l=>l?.reunite!==void 0)&&r.add("The 'access.rbac.reunite' property is deprecated. Please use 'access.rbac.platform' property instead."),[n?.rbac,n?.access?.rbac].some(K)&&(o=!0);for(const n of r)p.warn(n);o&&t(new Error("You are using an incorrect format of 'rbac:' configuration. See: https://redocly.com/docs/realm/access"));const a=U(e);if(!e.env)return a;const c=s.map(([n,l])=>[n,l&&U(l)]);return{...a,env:Object.fromEntries(c)}}function U(e){const t=x(e),s=e.rbac?{...t,rbac:$(e.rbac)}:t;return e.access?.rbac?{...s,access:{...e.access,rbac:$(e.access.rbac)}}:s}function $(e){const{reunite:t,...s}=e;return t===void 0?s:{...s,platform:e.platform??t}}function X(e){if(!e.theme)return[];p.warn("The 'theme' property in redocly.yaml is deprecated. Please move all of the properties from 'theme' to the root of the config.");const t=[];for(const s of Object.keys(e.theme))e[s]==null?t.push(s):p.warn(`Detected both '${s}' and 'theme.${s}' properties in redocly.yaml. The 'theme.${s}' property will be ignored and needs to be removed or merged into the '${s}'.`);return t}function J(e,t){if(!e.theme||t.length===0)return e;const s={...e};for(const r of t)s[r]=e.theme[r];return delete s.theme,s}export{Y as ensureAccessBackwardsCompatibility,ue as readAndValidateConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{logger as A}from"../../../tools/notifiers/logger.js";import{getFeedbackClientIp as
|
|
1
|
+
import{logger as A}from"../../../tools/notifiers/logger.js";import{getFeedbackClientIp as v}from"../../../web-server/utils/feedback-ip.js";import{getForwardedOrigin as M,getInternalOrigin as N}from"../../../web-server/utils/get-request-origin.js";import{GATEWAY_FETCH_LIMIT_DEFAULTS as L,DEFAULT_ANONYMOUS_VISITOR_TEAM as B,RbacFeatures as H}from"../../../../constants/common.js";import{isObject as j}from"../../../../utils/guards/is-object.js";import{getAccessibleSkills as V}from"../../../utils/skills/get-accessible-skills.js";import{getSkillUrl as $}from"../../../utils/skills/get-skill-url.js";import{createMcpHandler as Y}from"@modelcontextprotocol/server";import{createDocsMcpServer as G}from"../servers/docs-server.js";import{filterApiDescriptionsByRbac as J,filterGraphqlDescriptionsByRbac as K}from"../utils.js";import{userSubject as z}from"../gateway-mcp/subject.js";import{ipRateLimitKey as X}from"../gateway-mcp/rate-limit/utils/ip-key.js";import{createMethodNotAllowedError as Q,withErrorHandling as W}from"./errors.js";import{constructForbiddenResponse as Z,constructInvalidTokenResponse as q,constructUnauthorizedResponse as x,handleMcpAuth as ee}from"../auth/auth-handlers.js";import{isAssistantAnonymousToken as oe}from"../auth/assistant-anonymous-token.js";import{shouldHandleMcpAuth as re}from"../../../utils/rbac/should-handle-mcp-auth.js";import{extractTokenFromAuthHeader as se}from"../utils/jwt.js";import{resolveMcpClient as ie}from"../utils/mcp-client.js";import{randomUUID as ne}from"../../../utils/crypto/random-uuid.js";import{getPublicMcpEndpointStatus as te}from"../utils/public-endpoint.js";import{narrowMcpConfigForCaller as ce}from"../gateway-mcp/caller-api-calls.js";import{DEFAULT_DOCS_MCP_SERVER_NAME as ae,SSE_KEEPALIVE_INTERVAL_MS as pe}from"../constants.js";import{withPathPrefix as de}from"@redocly/theme/core/utils";import{PUBLIC_MCP_ROUTE as le}from"@redocly/theme/core/constants/mcp";import{canAccessFeature as me}from"../../../utils/rbac.js";import{ANONYMOUS_AUTH_DETAILS as fe}from"../../../constants/rbac.js";const E="X-Redocly-AI-Metadata",ue=1024*1024;function ge(o){if(o)try{const e=JSON.parse(o);if(j(e))return e;A.warn(`Ignoring ${E} header: not a JSON object.`)}catch{A.warn(`Ignoring ${E} header: invalid JSON.`)}}function he(o,e){return new URL(o).searchParams.get("mode")==="tools"?"tools":e}function b(){return{...fe,email:"",idpAccessToken:void 0,idpId:void 0}}const Ae=async(o,e,n)=>{const t=!!e?.config?.access?.requiresLogin,c=e?.config?.access?.rbac||{},I=n?.props?.config?.mcpMode??"tools",p=he(o.url,I),U=n?.props?.config?.gatewayFetchBudgetPerExec??L.budgetPerExec,R=n?.props?.config?.searchIgnoredRoutes??[],r=n,C=!!r?.props?.config?.isPublicEndpoint;let u;const T=o.headers.get("Authorization");if(C)e.user=b();else if(re(t,c)){const{isAuthenticated:i,isTokenValid:d,isFirstPartyAnonymous:g,currentUser:l,accessToken:h}=await ee(o,e);if(g)e.user=b();else if(i)l&&(e.user=l),u=h;else{const a=M(o),m=te(e.config)==="served"?`${a}${de(le)}`:void 0;return d===!1?q(a,m):x(a,m)}}else if(T){const i=se(T)??void 0;u=(i?await oe(i):!1)?void 0:i}const _={isAuthenticated:!!e.user?.isAuthenticated,teams:e.user?.teams||[B],claims:e.user?.claims??{}};return me(H.MCP,_,c,t)?await W(async()=>{const i=p==="code"&&(n?.props?.config?.elicitationEnabled??!1);if(o.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: ${o.url}`}),{status:405,headers:{"Content-Type":"application/json"}});if(o.method!=="POST")return Q();const d=r?.props?.config?.apiDescriptionsMap||{},g=r?.props?.config?.graphqlDescriptions||[],l=r?.props?.config?.mcpDocsServerName||ae,{config:{mcp:h={}}}=e,a=J(d,e.user,c,t),m=K(g,e.user,c,t),y=e.config.products?Object.values(e.config.products).map(s=>s?.name):[],D=h.docs?.name||l,f=ge(o.headers.get(E)),P=r?.props?.tools||[],O=r?.props?.skillsBaseUrl||M(o),w=V(r?.props?.skills||[],e.user,c,t).map(s=>({slug:s.slug,name:s.name,description:s.description,content:s.content,uri:$(O,s.slug)})),S=r?.props?.fetchCountSecret,F={name:D,tools:P,skills:w,context:{...e,config:{...e.config,mcp:ce(e.config.mcp,f)},configFile:r?.props?.configFile,accessToken:u,outdir:e.outdir||"",baseUrl:e.baseUrl||M(o),internalBaseUrl:N(o),apiDescriptionsMap:a,graphqlDescriptions:m,products:y,metadata:f,mcpMode:p,elicitationEnabled:i,gatewayFetchBudgetPerExec:U,fetchCountRequest:p==="code"&&S?{caller:{subject:z(e.user),ip:X(o)},secret:S}:void 0,searchIgnoredRoutes:R,clientIp:v(o),...ie(o),requestId:ne(),messageId:typeof f?.messageId=="string"?f.messageId:void 0}},k=await G({...F,getKv:e.getKv});return await Y(async()=>k,{keepAliveMs:pe,maxRequestBodySize:ue,onerror:s=>A.warn(`MCP handler: ${s.message}`)}).fetch(o)},p):Z()};var Je=Ae;export{Je as default};
|
|
@@ -12,11 +12,6 @@ export declare class McpError extends Error {
|
|
|
12
12
|
constructor(code: McpErrorCodeTypes, message: string, data?: unknown, requestId?: string | number | null);
|
|
13
13
|
createErrorResponse(): Response;
|
|
14
14
|
}
|
|
15
|
-
export declare class McpClientInputError extends Error {
|
|
16
|
-
constructor(message: string, options?: {
|
|
17
|
-
cause?: unknown;
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
15
|
export declare function createMethodNotAllowedError(requestId?: string | number | null): Response;
|
|
21
16
|
export declare function createInternalServerError(error: Error | string, requestId?: string | number | null): Response;
|
|
22
17
|
export declare function withErrorHandling<T>(operation: () => Promise<T>, mode?: McpMode): Promise<T | Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{telemetry as c}from"../../../telemetry/index.js";import{McpErrorCodes as o,McpServerType as
|
|
1
|
+
import{telemetry as c}from"../../../telemetry/index.js";import{McpErrorCodes as o,McpServerType as d}from"../constants.js";import{serverAttributes as i}from"../utils/telemetry-attributes.js";class n extends Error{code;data;requestId;constructor(t,e,s,a){super(e),this.name="McpError",this.code=t,this.data=s,this.requestId=a}createErrorResponse(){const t={jsonrpc:"2.0",error:{code:this.code,message:this.message,...this.data?{data:this.data}:{}},id:this.requestId??null},e=p(this.code);return new Response(JSON.stringify(t),{status:e,headers:{"Content-Type":"application/json"}})}}function p(r){switch(r){case o.InvalidRequest:case o.InvalidParams:return 400;case o.MethodNotFound:return 404;case o.ServerError:return 405;case o.InternalError:default:return 500}}function h(r){return new n(o.ServerError,"Method not allowed",void 0,r).createErrorResponse()}function u(r,t){const e=r instanceof Error?r.message:String(r);return new n(o.InternalError,"Internal server error mcp",e,t).createErrorResponse()}async function f(r,t="tools"){try{return await r()}catch(e){return c.sendMcpErrorMessage([{...i(d.Docs),message:e?.message||"",stack:e?.stack||"",error_class:"server_error",mode:t}]),u(e)}}export{n as McpError,u as createInternalServerError,h as createMethodNotAllowedError,f as withErrorHandling};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{secretStore as d}from"../gateway-mcp/secret-store.js";import{rejectCredential as _}from"../gateway-mcp/credential-validation.js";import{buildAllowedHostMatchers as
|
|
1
|
+
import{readRequestBody as C}from"@modelcontextprotocol/server";import{secretStore as d}from"../gateway-mcp/secret-store.js";import{rejectCredential as _}from"../gateway-mcp/credential-validation.js";import{buildAllowedHostMatchers as T}from"../gateway-mcp/fetch/allowed-hosts.js";import{assertUrlAllowed as A}from"../gateway-mcp/fetch/ssrf-guard.js";import{readCappedBody as R,getDefaultAgent as P}from"../gateway-mcp/fetch/fetch-bridge.js";import{logger as x}from"../../../tools/notifiers/logger.js";import{FORM_ACTIONS as k}from"./credentials-page/constants.js";import{credentialSchemesOf as w,schemeFieldName as f}from"./credentials-page/form-contract.js";import{formPage as O}from"./credentials-page/form-page.js";import{htmlDocument as N}from"./credentials-page/layout.js";import{declinedPage as I,expiredPage as j,outcomePage as D}from"./credentials-page/outcome-pages.js";const $={"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store","X-Frame-Options":"DENY","Referrer-Policy":"no-referrer","Content-Security-Policy":"default-src 'none'; style-src 'unsafe-inline'; img-src 'self'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'"},M=3e4,B=64*1024,F=64*1024,U=/^bearer\s+/i,X=/^\d+$/,H=async(e,t,o)=>{const n=await t.getKv(),r=J(e,t.baseUrl,o);if(e.method==="GET"){const i=new URL(e.url).searchParams.get("token")??"",a=await d.peekElicitation(n,i);return a?E({kv:n,site:r,token:i,target:a},{},200):p(r)}if(e.method==="POST"){const i=await C(e,F);if(i.tooLarge)return new Response("Payload Too Large",{status:413});const a=await new Response(i.text,{headers:{"Content-Type":e.headers.get("content-type")??""}}).formData(),c=u(a,"token"),s=await d.peekElicitation(n,c);if(!s)return p(r);const l={kv:n,site:r,token:c,target:s,form:a};switch(u(a,"action")){case k.remove:return b(l,K(s,u(a,"scheme")));case k.removeAll:return b(l,w(s));case k.decline:return Y(l);default:return L(l)}}return new Response("Method Not Allowed",{status:405,headers:{Allow:"GET, POST"}})};async function L(e){const{target:t,form:o}=e,n=w(t),r=n.map((s,l)=>u(o,f("client_id",l)).trim()),i=s=>E(e,{error:s,clientIds:r},400),a=G(n,o);if("error"in a)return i(a.error);if(a.writes.length===0)return i(z(n));const c=[];for(const s of a.writes){if(s.kind!=="exchange"){c.push(s);continue}const l=await W(s.auth,s.clientId,s.clientSecret);if(!l.ok)return x.warn(`gateway oauth2 client_credentials exchange failed for ${t.api}: ${l.reason}`),i(y(n,s.schemeIndex,"client_id","We could not exchange those client credentials for a token. Check the client ID and secret, then try again."));c.push({kind:"set",scheme:s.scheme,secret:l.secret})}return v(e,c)}function G(e,t){const o=[];for(const[n,r]of e.entries()){const i=u(t,f("secret",n)).trim();if(i){const s=_(r.auth,i);if(s)return{error:y(e,n,"secret",s)};o.push({kind:"set",scheme:r.name,secret:Q(r.auth,i)});continue}if(r.auth.kind!=="oauth2ClientCredentials")continue;const a=u(t,f("client_id",n)).trim(),c=u(t,f("client_secret",n)).trim();if(a&&c)o.push({kind:"exchange",scheme:r.name,schemeIndex:n,auth:r.auth,clientId:a,clientSecret:c});else if(a||c)return{error:y(e,n,a?"client_secret":"client_id","Enter both the client ID and the client secret, or leave both blank.")}}return{writes:o}}function z(e){return e.length>1?{message:"Fill in at least one credential before saving."}:{message:e[0].auth.kind==="oauth2ClientCredentials"?"Enter an access token, or the client ID and the client secret, before saving.":"Enter a value before saving.",schemeIndex:0,field:"secret"}}function y(e,t,o,n){return{message:e.length>1?`${e[t].name}: ${n}`:n,schemeIndex:t,field:o}}async function b(e,t){const{kv:o,target:n}=e,r=await d.getStoredSchemes(o,n.subject,n.api),i=t.filter(a=>r[a.name]).map(a=>({kind:"remove",scheme:a.name}));return i.length===0?E(e,{error:{message:"No credential is stored there, so there is nothing to remove."}},400):v(e,i)}function K(e,t){const o=X.test(t)?w(e)[Number(t)]:void 0;return o?[o]:[]}async function Y({kv:e,site:t,token:o}){return await d.consumeElicitation(e,o)?h(t,I(),200):p(t)}async function v({kv:e,site:t,token:o},n){const r=await d.consumeElicitation(e,o);if(!r)return p(t);for(const c of n)c.kind==="remove"?await d.deleteSecret(e,r.subject,r.api,c.scheme):await d.setSecret(e,r.subject,r.api,c.scheme,c.secret);const i=await d.getStoredSchemes(e,r.subject,r.api),a={action:n.some(c=>c.kind==="set")?"saved":"removed",schemes:n.map(c=>c.scheme),stored:Object.keys(i).sort()};return h(t,D(r,a),200)}async function E({kv:e,site:t,token:o,target:n},r,i){const a=await d.getStoredSchemes(e,n.subject,n.api);return h(t,O({site:t,target:n,token:o,stored:a,...r}),i)}function J(e,t,o){const n=o?.props?.branding??{},r=t&&URL.canParse(t)?t:e.url;return{...n,host:new URL(r).host}}async function W(e,t,o){try{const n=T([{url:e.tokenUrl}]),r=A(e.tokenUrl,n),i=new AbortController,a=setTimeout(()=>i.abort(),M);let c;try{c=await fetch(r,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"client_credentials",client_id:t,client_secret:o}),redirect:"manual",signal:i.signal,dispatcher:P()})}finally{clearTimeout(a)}if(!c.ok)return m(`token endpoint returned ${c.status}`);let s;try{s=await R(c,B)}catch{return m("token response exceeded the size cap")}let l;try{l=JSON.parse(s)}catch{return m("token response was not valid JSON")}const S=typeof l=="object"&&l!==null&&"access_token"in l?l.access_token:void 0,g=typeof S=="string"?S.trim():"";return g?_(e,g)?m("token response had an access_token that cannot be sent in a header"):{ok:!0,secret:{header:"Authorization",value:`Bearer ${g}`}}:m("token response had no access_token")}catch(n){return m(n instanceof Error?n.message:String(n))}}function m(e){return{ok:!1,reason:e}}function u(e,t){const o=e.get(t);return typeof o=="string"?o:""}function h(e,t,o){return new Response(N(t,e.colorScheme),{status:o,headers:$})}function p(e){return h(e,j(),404)}function Q(e,t){return e.kind==="apiKey"?{header:e.header,value:t}:e.kind==="cookie"?{header:"Cookie",value:`${e.name}=${t}`}:e.kind==="bearer"||e.kind==="oauth2ClientCredentials"?{header:"Authorization",value:V(t)}:{header:"Authorization",value:t}}function V(e){return`Bearer ${e.replace(U,"")}`}var de=H;export{de as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{McpServer as
|
|
1
|
+
import{McpServer as C}from"@modelcontextprotocol/server";import{logger as S}from"../../../tools/notifiers/logger.js";import{mcpToolWorkers as U,MCP_TOOL_WORKER_KEY as O}from"../../../workers/mcp-tool-worker-pool.js";import{secretStore as L}from"../gateway-mcp/secret-store.js";import{readAuthRequiredMeta as F,stripAuthRequiredMeta as k,upstreamAuthKey as b}from"../gateway-mcp/upstream-auth.js";import{acceptedCredentialsLink as D,buildCredentialsAcceptedHint as K,buildCredentialsToolHint as N,buildUpstreamCredentialFallback as q,buildUpstreamCredentialInputRequired as j,credentialElicitationAnswer as P,dedupeElicitation as v,isStatelessRequest as H,schemeLabelOf as $,supportsUrlElicitation as B}from"../gateway-mcp/elicitation.js";import{DEFAULT_SCHEME_NAME as y,resolveUpstreamApiAuth as W}from"../gateway-mcp/upstream-auth-scheme.js";import{MISSING_SESSION_HANDLE_MESSAGE as G,resolveSecretSubject as V}from"../gateway-mcp/subject.js";import{toWorkerContext as X}from"../workers/worker-context.js";const Y=6e4,J=1e4;function de(e,t){return new C({name:e,version:new Date().toISOString().slice(0,10)},{capabilities:{logging:{}},maxToolInputElements:J,...t?{instructions:t}:{}})}function me(e,t){return r=>async(n,s)=>{S.info(`MCP tool called: ${r}`);const i=e.elicitationEnabled??!1,u=H(s.mcpReq),a=i?V(e.user,n.sessionHandle):{kind:"anonymous"},o=a.kind==="resolved"?a.subject:void 0;if(a.kind==="invalid")return{content:[{type:"text",text:a.message}],isError:!0};const c=async()=>{if(!(!i||!o||!t?.getKv))try{const m=await t.getKv();return await L.getSecretsForSubject(m,o)}catch(m){S.warn(`gateway mcp secret store error, continuing unauthenticated: ${String(m)}`);return}};let l;const p=async()=>{l=await c();const m={toolName:r,args:n,context:X({...e,upstreamSecrets:l}),extra:re(s)};return await U.exec(O,[m],{timeout:Y})};let d=await p();const f=F(d);if(f.length>0&&i&&!o)return k(T(d,[{type:"text",text:G}]));if(f.length>0&&i&&o&&t?.getKv){S.info(`gateway mcp credentials prompt: era=${u?"2026-07-28":"2025"} clientElicitation=${Q(t)}`);const m=await t.getKv(),h=await Z(e,f),w=f.map(_=>x(_,h)),E=z(l),g=u?await ee(e,s,w,o,m,E,h,t):await te(e,w,o,m,E,h);switch(g.kind){case"inputRequired":return g.result;case"retry":d=await p();break;case"prependText":d=T(d,[{type:"text",text:g.text},...d.content]);break;case"none":break}}return k(d)}}function T(e,t){const{structuredContent:r,...n}=e;return{...n,content:t,isError:!0}}function Q(e){const t=e?.getClientCapabilities()?.elicitation;if(!t)return"none";const r=[t.form?"form":void 0,t.url?"url":void 0].filter(Boolean);return r.length>0?r.join("+"):"none"}async function Z(e,t){const r=new Map;for(const n of new Set(t.map(s=>s.api)))r.set(n,await W(e,n));return r}function x(e,t){const r=t.get(e.api);if(!r)return{...e,scheme:e.scheme??y};const n=e.scheme&&r.schemes[e.scheme]?e.scheme:r.defaultScheme;return{...e,scheme:n}}function z(e){const t=new Set;for(const[r,n]of Object.entries(e??{}))for(const s of Object.keys(n))t.add(b({api:r,scheme:s}));return t}function I(e,t){return e.status===401&&!t.has(b(e))}function R(e,t){const r=t.get(e.api),n=e.sentScheme??e.scheme;return r&&n?$(r.schemes,n):void 0}function M(e,t){return e.map(r=>N(r,R(r,t))).join(`
|
|
2
2
|
|
|
3
|
-
`)}function A(e,t,r,n,s){const[i,...u]=t,a=s.get(i.api),o=i.scheme??a?.defaultScheme??y,c=i.schemes&&i.schemes.length>1?i.schemes:void 0,l=c?void 0:
|
|
3
|
+
`)}function A(e,t,r,n,s){const[i,...u]=t,a=s.get(i.api),o=i.scheme??a?.defaultScheme??y,c=i.schemes&&i.schemes.length>1?i.schemes:void 0,l=c?void 0:R(i,s);return{subject:r,baseUrl:e.baseUrl??"",target:{api:i.api,name:i.name,scheme:o,...l?{schemeLabel:l}:{},...c?{acceptedSchemes:c}:{}},auth:a?.schemes[o]??{kind:"raw"},...a?{apiAuth:a}:{},kv:n,hasExistingSecret:!1,reason:{kind:"authFailure",status:i.status,...i.detail?{detail:i.detail}:{},otherApiNames:u.map(p=>p.name)}}}async function ee(e,t,r,n,s,i,u,a){const o=P(t.mcpReq.inputResponses);if(o==="declined")return{kind:"none"};const c=r.filter(p=>I(p,i));if(c.length===0)return{kind:"prependText",text:M(r,u)};if(o==="accepted"){const p=await D(t.mcpReq.requestState(),{kv:s,subject:n,baseUrl:e.baseUrl??"",apis:c.map(f=>f.api)}),d=p?.apiName??c[0].name;return{kind:"prependText",text:K(d,p?.url)}}const l=A(e,c,n,s,u);return B(a?.getClientCapabilities())?{kind:"inputRequired",result:await j(l)}:{kind:"prependText",text:await q(l)}}async function te(e,t,r,n,s,i){const u=t.filter(c=>I(c,s));if(u.length===0)return{kind:"prependText",text:M(t,i)};const a=A(e,u,r,n,i);return{kind:"prependText",text:await v(`${r}:${b(u[0])}`,()=>q(a))}}function re(e){return{sessionId:e.sessionId,authInfo:e.http?.authInfo,requestId:e.mcpReq.id,_meta:e.mcpReq._meta}}function fe(e){return{user:e.user,config:e.config,outdir:e.outdir,baseUrl:e.baseUrl,params:e.params,query:e.query,cookies:e.cookies,apiDescriptionsMap:e.apiDescriptionsMap,graphqlDescriptions:e.graphqlDescriptions,products:e.products,accessToken:e.accessToken,metadata:e.metadata,upstreamAuthorization:e.upstreamAuthorization,mcpMode:e.mcpMode,elicitationEnabled:e.elicitationEnabled,gatewayFetchBudgetPerExec:e.gatewayFetchBudgetPerExec,fetchCountRequest:e.fetchCountRequest,clientIp:e.clientIp,client:e.client,clientVersion:e.clientVersion,requestId:e.requestId,messageId:e.messageId,upstreamSecrets:e.upstreamSecrets,searchIgnoredRoutes:e.searchIgnoredRoutes,internalBaseUrl:e.internalBaseUrl,sandboxToolSchemas:e.sandboxToolSchemas,configFile:e.configFile,fs:void 0}}export{de as createMcpServer,me as createToolDispatch,fe as extractSerializableContext};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { LifecycleContext, ProcessContentActions } from '../../types';
|
|
2
2
|
import type { DetailedScorecardData } from './types.js';
|
|
3
3
|
import { type ScorecardConfig, type RedoclyConfig } from '@redocly/theme/config';
|
|
4
|
-
export declare function computeScorecard({ actions, context, scorecardConfig,
|
|
4
|
+
export declare function computeScorecard({ actions, context, scorecardConfig, platformConfig, }: {
|
|
5
5
|
actions: ProcessContentActions;
|
|
6
6
|
context: LifecycleContext;
|
|
7
7
|
scorecardConfig: ScorecardConfig;
|
|
8
|
-
|
|
8
|
+
platformConfig: RedoclyConfig['platform'];
|
|
9
9
|
}): Promise<Record<string, DetailedScorecardData>>;
|
|
10
10
|
//# sourceMappingURL=compute-scorecard.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import w from"node:path";import S from"picomatch";import{removeLeadingSlash as O}from"@redocly/theme/core/utils";import{parsePathVersions as D}from"../../../utils/path/parse-path-versions.js";import{logger as c}from"../../tools/notifiers/logger.js";import{ScorecardStatus as d}from"./types.js";import{getTarget as M}from"./loaders/scorecard.js";const R=15;async function $({actions:t,context:i,scorecardConfig:e,
|
|
1
|
+
import w from"node:path";import S from"picomatch";import{removeLeadingSlash as O}from"@redocly/theme/core/utils";import{parsePathVersions as D}from"../../../utils/path/parse-path-versions.js";import{logger as c}from"../../tools/notifiers/logger.js";import{ScorecardStatus as d}from"./types.js";import{getTarget as M}from"./loaders/scorecard.js";const R=15;async function $({actions:t,context:i,scorecardConfig:e,platformConfig:o}){c.info("Computing scorecard...");const a=e.levels||[],n=a[0],u=await t.loadApiDocuments(i),r=B(u),h=e.ignore||[],v=S(h),m=new Set,f=c.startTiming(),p={},l={};for(const s of r){if(!L(s,v,m))continue;const g=s.customOutputRelativeFile||s.realRelativePath;m.add(g);const P=await N(s,i,e,a,n);p[s.realRelativePath]=P,l[P.relativePath]=P}return c.infoTime(f,"Scorecard processed"),T(p,o,e),l}function L(t,i,e){if(t.isVirtual||!t.definition)return!1;const o=t.customOutputRelativeFile||t.realRelativePath,a=O(t.realRelativePath);return i(a)?(c.info(`Skipping scorecard calculation for ignored file: ${t.realRelativePath}`),!1):!e.has(o)}function F(t,i,e){return t-1<i?d.BelowMinimum:i<e-1?d.Minimum:d.Highest}async function N(t,i,e,o,a){let n=a.name;if(e.targets?.length){const l=await i.getConfig(w.posix.dirname(t.realRelativePath)),s=t.definition.info?.["x-metadata"]||{},g={title:t.definition.info?.title,version:t.definition.info?.version,...s,...l.metadata};n=(await M(e.targets,g))?.minimumLevel||a.name}const{data:{levels:u,scorecardLevelIdx:r,scorecardLevel:h}}=await i.cache.load(t.realRelativePath,"scorecard"),v=o.findIndex(l=>l.name===n),m=F(r,v,o.length),f=t.customOutputRelativeFile||t.realRelativePath,p=D(f)?.versionName;return{levels:u,status:m,targetLevel:n,scorecardLevel:h,scorecardLevelIdx:r,relativePath:f,title:t.definition.info?.title,version:p}}function T(t,i,e){const o=Object.values(t).filter(r=>r.status===d.BelowMinimum);if(o.length===0)return;const a=o.map(r=>r.relativePath);let n=`Detected OpenAPI definitions with score below minimum level:
|
|
2
2
|
- ${a.slice(0,R).map(()=>"%rp").join(`
|
|
3
3
|
- `)}`;a.length>R&&(n+=`
|
|
4
4
|
... and ${a.length-R} more`),i?.ignoreLint??e.ignoreNonCompliant?c.warn(n,...a):c.error(n,...a)}function B(t){const i=[];for(const e of t){if(e.type!=="openapi")continue;const o=e.document;i.push({realRelativePath:e.realRelativePath,customOutputRelativeFile:e.customOutputRelativeFile,isVirtual:e.isVirtual,definition:{info:o.info}})}return i}export{$ as computeScorecard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as
|
|
1
|
+
import{writeFileSync as R}from"node:fs";import L from"path";import{SCORECARD_CLASSIC_FOLDER as A,SCORECARD_OUTPUT_FILE_NAME as w}from"../../constants/common.js";import{mapObject as E}from"../../../utils/object/map-object.js";import{envConfig as j}from"../../config/env-config.js";import{removeLeadingSlash as _}from"../../../utils/url/remove-leading-slash.js";import{combineUrls as O}from"@redocly/theme/core/utils";import{logger as F}from"../../tools/notifiers/logger.js";import{getRouteSlugToCatalogSlugMap as N}from"../../utils/catalog-classic/get-route-slug-to-catalog-slug-map.js";import{getCatalogSharedDataId as q}from"../../utils/catalog-classic/get-catalog-shared-data-id.js";import{deepEqual as I}from"../../../utils/object/deep-equal.js";import{ensureDir as U}from"../../utils/index.js";import{getTemplatePath as k}from"./get-template-path.js";import{getAllRuleNames as M}from"./lint.js";import{getScorecardConfig as P}from"./get-scorecard-config.js";import{getScorecardSlug as W}from"./shared-utils.js";import{scorecardConfigLoader as B}from"./loaders/scorecard-config.js";import{scorecardLoader as J}from"./loaders/scorecard.js";import{computeScorecard as $}from"./compute-scorecard.js";import{telemetryTraceStep as x}from"../../../cli/telemetry/helpers/trace-step.js";const G="scorecardClassic";let g={},D={};async function ue({id:T,requiredEntitlements:b,loadersPrefix:v=""}){let p=null,y=null,h=!1;return{id:T??"scorecardClassic",requiredEntitlements:b??["scorecard"],loaders:{[`${v}scorecard-config`]:B,[`${v}scorecard`]:J},async processContent(r,l){await x("com.redocly.build.plugin.scorecardClassic",async C=>{const a=r.createTemplate(G,k("./template/index.js")),u=await l.getConfig(),m=P(u),f=u?.platform??{},i=[()=>p===null,()=>!I(g,m),()=>!I(D,f)].some(e=>e());g=m,C?.setAttribute("config",JSON.stringify(g||{})),D=f;const n=u.catalogClassic??{},c=g.levels||[];if(c.length<1)throw Error("Invalid configuration of levels config");i&&(p=await $({actions:r,context:l,scorecardConfig:g,platformConfig:D}));const{data:{configs:o}}=await l.cache.load("",`${v}scorecard-config`),{perLevel:d,all:s}=M(o);y={levelNames:c.map(e=>e.name),rules:s,rulesPerLevel:d};for(const[e,t]of Object.entries(n)){const S=O(t.slug,"scorecard/");r.addRoute({duplicateInAllLocales:!0,slug:S,fsPath:O(t.slug,"scorecard/"),templateId:a,hasClientRoutes:!0,excludeFromSidebar:!0,serverPropsGetterIds:[],sharedData:[{id:"scorecard",key:"scorecard"},{key:"catalog",id:q(e)}],getNavText:()=>Promise.resolve(t.title||"API design scorecard"),getStaticData:async()=>({props:{catalogId:e,catalogConfig:{...t,items:void 0},scorecardConfig:g,scorecardInfo:y}})})}})},afterRoutesCreated:async(r,l)=>{const C=await l.getConfig(),a=C.catalogClassic??{},u=P(C);if(Object.keys(a).length){const i=Object.keys(a).length>1?await N(r,l,a):null,n={};for(const[c,o]of Object.entries(p||{})){const d=r.getRouteByFsPath(c),s=d?.slug;if(s){if(d&&!u.ignoreMetadata){const e=i?i.get(s)??Object.values(a)[0].slug:Object.values(a)[0].slug,t=O(e,"scorecard/");d.metadata={...d.metadata,scorecardStatus:o.status,scorecardLevel:o.scorecardLevel,scorecardLevelIdx:o.scorecardLevelIdx,scorecardLevels:E(o.levels,S=>({uniqueErrors:S.uniqueErrors,uniqueWarnings:S.uniqueWarnings})),scoreCardSlug:t+"apis/"+encodeURIComponent(_(s))}}if(n[s]={...o,levels:E(o.levels,e=>({...e,problems:e.problems.map(t=>({ruleId:t.ruleId,severity:t.severity}))}))},!h){const e=L.resolve(r.outdir,A,W(s));R(U(e),JSON.stringify(o))}}}await r.createSharedData("scorecard",n)}const m={};for(const[i,n]of Object.entries(p||{})){const c=r.getRouteByFsPath(i)?.slug;c&&(m[c]=n)}const f=j.REDOCLY_METADATA_OUTPUT_FOLDER;!h&&f&&(F.info("Writing scorecard data..."),R(L.join(f,w),JSON.stringify({scorecardData:m,...y}))),h=!0}}}export{ue as scorecardClassicPlugin};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const colorsAreEnabled: boolean;
|
|
2
|
-
declare const red
|
|
2
|
+
declare const { red, green, bold, blue, gray, yellow, cyan }: import("colorette").Colorette;
|
|
3
3
|
declare const stripColors: (input: string) => string;
|
|
4
4
|
export { red, gray, green, blue, bold, yellow, cyan, colorsAreEnabled, stripColors };
|
|
5
5
|
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as o from"dotenv";import*as n from"path";import{simpleGit as
|
|
1
|
+
import*as o from"dotenv";import*as n from"path";import{simpleGit as E}from"simple-git";import{envConfig as s,reloadEnvConfig as c,setEnv as p}from"../../config/env-config.js";import{readEnvVariable as m}from"../../utils/envs/read-env-variable.js";import{sanitizeBranchName as f}from"../../utils/envs/sanitize-branch-name.js";async function l(e){try{return(await E(e??process.cwd()).revparse(["--abbrev-ref","HEAD"])).trim()}catch{return""}}const _=["REDOCLY_EXP_REPLAY_GRAPHQL_ENABLED","REDOCLY_EXP_REPLAY_ASYNCAPI_ENABLED"];async function d(e){const a=Object.fromEntries(_.map(t=>[t,m(t)]));o.config({path:n.resolve(e??"",".env")}),c();const i=s.PUBLIC_REDOCLY_BRANCH_NAME||await l(e);if(i){const t=f(i);o.config({path:n.resolve(e??"",`.env.branch.${t}`),override:!0}),c()}const v=s.REDOCLY_ENV;let r;switch(v){case"production":r=".env.production";break;case"preview":r=".env.preview";break;default:r=".env.development";break}o.config({path:n.resolve(e??"",r),override:!0}),p(a)}export{d as loadEnvVariables};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getHigherRole as c}from"./rbac.js";function R(e,r){if(!e)return;if(!p(e))return e;const o={
|
|
1
|
+
import{getHigherRole as c}from"./rbac.js";function R(e,r){if(!e)return;if(!p(e))return e;const o={platform:{},content:i(e)},n=f(e,r);for(const t of n)o.platform[t.teamName]=t.projectRole,o.content={...o.content,...Object.fromEntries((e.teamFolders||[]).flatMap(a=>{const l={...e.teamFoldersBaseRoles||{authenticated:"READ"},[t.teamName]:t.projectRole,"redocly.owners":"ADMIN"},m=a.replaceAll("{teamPathSegment}",t.teamPathSegment),s=m+"/**";return[[m,l],[s,l]]}))};return{...e,platform:{...e.platform,...o.platform},content:{...d(e.content||{},o.content)}}}function p(e){return!!(e.teamNamePatterns&&e.teamFolders)}function u(e,r){for(const o of e.teamNamePatterns||[]){if(!o.includes("{teamPathSegment}")&&!o.includes("{projectRole}"))continue;const n="^"+o.replace("{teamPathSegment}","(?<teamPathSegment>[a-zA-Z0-9_.-]+)").replace("{projectRole}","(?<projectRole>admin|maintain|triage|write|read|none)")+"$",a=new RegExp(n,"i").exec(r)?.groups;if(a?.projectRole||a?.teamPathSegment)return{teamName:r,projectRole:a.projectRole?.toUpperCase(),teamPathSegment:a.teamPathSegment?.toLowerCase()}}return null}function g(e,r){for(const o of e?.teamFolders||[]){if(!o.includes("{teamPathSegment}"))continue;const n=`^${o.replace("{teamPathSegment}","(?<teamPathSegment>[a-zA-Z0-9_.-]+)")}($|/)`,t=new RegExp(n,"i");for(const a of r){const l=t.exec(a)?.groups;if(l?.teamPathSegment)return{teamPathSegment:l.teamPathSegment.toLowerCase()}}}return null}function f(e,r){const o=r.map(t=>u(e,t));let n=null;for(const t of o)t?.projectRole&&!t.teamPathSegment&&(n=n?c(n,t.projectRole):t.projectRole);return o.map(t=>!t?.teamPathSegment||!t.projectRole&&!n?null:(t.projectRole=t.projectRole??n??void 0,t)).filter(Boolean)}function i(e){const r={};if(e.teamFoldersBaseRoles)for(const o of e.teamFolders){const n=o.replaceAll("{teamPathSegment}","**");r[n]=e.teamFoldersBaseRoles}return r}function d(e,r){const o={...e};for(const[n,t]of Object.entries(r))o[n]?o[n]={...o[n],...t}:o[n]=t;return o}export{p as canExpandConfig,R as expandRbacConfig,i as getTeamFolderDefaults,g as parseTeamFoldersTemplate,u as parseTeamNameTemplate,f as parseTeams};
|
|
@@ -2,6 +2,7 @@ import '../node-crypto-polyfill.js';
|
|
|
2
2
|
import { REDOCLY_TEAMS_RBAC, REDOCLY_ROUTE_RBAC } from '@redocly/config';
|
|
3
3
|
import type { RbacConfig, RbacScopeItems, RedoclyConfig, SsoConfig } from '@redocly/config';
|
|
4
4
|
import type { AuthDetails } from '../types';
|
|
5
|
+
import type { ApiDefinitionAccess } from '../plugins/api-docs/definition-access.js';
|
|
5
6
|
import type { ContentFs } from '../fs/content-fs.js';
|
|
6
7
|
import type { RbacFeatures } from '../../constants/common.js';
|
|
7
8
|
export type ProjectRole = 'NONE' | 'READ' | 'TRIAGE' | 'WRITE' | 'MAINTAIN' | 'ADMIN';
|
|
@@ -33,7 +34,7 @@ export declare function canDownloadApiDefinition(pathname: string, rbacConfig: R
|
|
|
33
34
|
isAuthenticated?: boolean;
|
|
34
35
|
email?: string;
|
|
35
36
|
teams?: string[];
|
|
36
|
-
}): boolean;
|
|
37
|
+
}, definitionAccess?: ApiDefinitionAccess): boolean;
|
|
37
38
|
export declare function canAccessAsset(pathname: string, rbacConfig: RbacConfig, requiresLogin: boolean, directoryPaths: Record<string, string>, user?: {
|
|
38
39
|
isAuthenticated?: boolean;
|
|
39
40
|
email?: string;
|
|
@@ -145,6 +146,9 @@ export declare const normalizeRbacConfig: (rbacConfig: RbacConfig) => {
|
|
|
145
146
|
[x: string]: string;
|
|
146
147
|
} | undefined;
|
|
147
148
|
} | undefined;
|
|
149
|
+
platform?: {
|
|
150
|
+
[x: string]: string;
|
|
151
|
+
} | undefined;
|
|
148
152
|
reunite?: {
|
|
149
153
|
[x: string]: string;
|
|
150
154
|
} | undefined;
|