@redocly/revel 0.138.1 → 0.138.2
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_ROUTE_RBAC as
|
|
1
|
+
import{REDOCLY_ROUTE_RBAC as C,REDOCLY_TEAMS_RBAC as A}from"@redocly/config";import{mcpTagSchemas as tt,schemaDefinitionTag as et,markdocParser as U}from"@redocly/api-docs";import{withPathPrefix as q}from"@redocly/theme/core/utils";import{API_DOCS_TEMPLATE_ID as V,GRAPHQL_SPEC_SLUG as ot,PUBLIC_RBAC_SCOPE_ITEM as x}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as rt,PUBLIC_API_DEFINITIONS_FOLDER as at}from"../../constants/common.js";import{API_DOCS_SHARED_DATA_PREFIX as w}from"../../constants/plugins/api-docs.js";import{fromCurrentDir as st}from"../../utils/paths.js";import{normalizeRouteSlug as it}from"../../../utils/path/normalize-route-slug.js";import{removeTrailingSlash as nt}from"../../../utils/url/remove-trailing-slash.js";import{createSlugify as ct}from"../create-slugify.js";import{apiDocLoader as pt,apiDocsLoader as ut}from"./loader.js";import{getTemplatePath as j}from"./get-template-path.js";import{storeDefinitionBundles as lt}from"./store-definition-bundles.js";import{telemetryTraceStep as dt}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as mt}from"./search/search-resolver.js";import{getAiDocumentsStore as ft}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as gt}from"../get-api-config.js";import{getRouteSlugsForPath as ht}from"../utils.js";import{collectItemRoutes as Dt}from"./utils/collect-item-routes.js";import{isChunkCurrent as St}from"./utils/decorators.js";import{applyNavItemToRoot as Pt}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as yt}from"./utils/build-routes-mapping.js";import{buildItemPositions as It}from"./utils/build-item-positions.js";import{resolveApiDocTitle as At}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as W}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as vt}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as Rt}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as Q}from"./import-api-docs-builder.js";import{envConfig as $}from"../../config/env-config.js";import{logger as bt}from"../../tools/notifiers/logger.js";const T="openapi-spec-download",_t={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function pe(){let e=[],r=new Map;const s=new WeakMap;let n=new Set,m={};function k(o,g,v){const y=s.get(o)??new Map;s.set(o,y);const h=g??"";return y.get(h)===v?!1:(y.set(h,v),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":pt,"api-docs":ut},processContent:async(o,g)=>{await dt("com.redocly.build.plugin.apiDocs",async()=>{o.createRequestHandler(T,st(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:at+"/*",requestHandlerId:T,httpMethod:"all",[A]:x,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:rt+"/*",requestHandlerId:T,httpMethod:"all",[A]:x,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:ot+"/*",requestHandlerId:T,httpMethod:"all",[A]:x,getStaticData:async()=>({props:{}})});const v=o.createTemplate(V,j("../../../client/templates/api-docs/template.js")),y=o.registerServerPropsGetter(V,j("./get-server-props.js")),h=await g.getConfig();r=new Map,m={};const I=await o.loadApiDocuments(g);lt(I,o.outdir);const E=!!h.plugins?.some(t=>typeof t=="string"&&t.startsWith("@redocly/portal-plugin-async-api/"));E&&I.some(t=>t.type==="asyncapi")&&bt.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=E?I.filter(t=>t.type!=="asyncapi"):I;e=c.map(({markdocChunks:t,relativePath:P,isVirtual:p,customOutputRelativeFile:a,realRelativePath:f})=>({chunks:t??[],relativePath:P,realRelativePath:f,isVirtual:a!=null||p}));const{buildItems:i}=await Q(o.serverOutDir),D=(await g.cache.load("content-slugs","content-slugs")).data,S=ct(D),O=t=>it(S(t));for(const t of c){const P=t.customOutputRelativeFile||t.relativePath,p=O(P);wt(t,p);const{items:a,store:f}=await i({type:t.type,document:t.document,options:t.options,basePath:p,markdownParser:U}),R=`${w}${t.relativePath}`,M=$.isDevelopMode?t.relativePath:void 0,u=kt(t.document),b=u?.["x-metadata"],_=t.isVirtual?void 0:b?.apiId,N={document:t,basePath:p,sourcePath:M,apiId:_};await o.createSharedData(R,z(N,a,f));const Y=W(t.config),F=!!t.options.excludeFromSearch,X=t.type==="openapi",d=Dt(a,Y).map(l=>{const B=l.metadata?.seo,H={...Tt(l.link,p),fsPath:P,templateId:v,sharedData:[{key:"apiDocsStore",id:R}],serverPropsGetterIds:[y],excludeFromSearch:F,getStaticData:Et(l.label,B),[A]:l[A]};return X?{...H,...l.httpVerb?{httpVerb:l.httpVerb,metadata:{subType:"openapi-operation"}}:{}}:H});if(!d.length)continue;const G=At(u,t.type,a),J=Rt(u?.version),L={type:t.type,title:G,version:J,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:L,hasClientRoutes:!0,getSidebar:(l,B)=>Pt(K(a),p,B),getNavText:()=>G??_t[t.type]??"API Docs",getSearchDocuments:mt(a,L,o.getSearchFacets,o.setSearchFacets,F,f,t.document),getAiDocumentsStore:ft({items:a,metadata:L,store:f,document:t.document,specType:t.type,excludeFromSearch:F,basePath:p,getSearchFacets:o.getSearchFacets,markdocTags:{...tt,schemaDefinition:et}})};const Z=d[0];d[0]=d[d.length-1],d[d.length-1]=Z;for(const l of d)o.addRoute(l);if(_){const l=gt(t.config?.apis,t.realRelativePath);m[_]={[A]:l.rbac,[C]:{fsPath:P}}}r.set(R,N)}})},afterRoutesCreated:async(o,g)=>{const{buildItems:v,simplifyAstStructure:y}=await Q(o.serverOutDir),h=new Set,I=new Set;for(const{chunks:c,relativePath:i,isVirtual:D}of e){const S=`${w}${i}`,O=ht(o.getAllRoutes(),i);for(const{node:t,markdown:P,pointer:p,key:a,relativePath:f}of c){const{ast:R,compoundHash:M}=await o.parseMarkdoc({input:{content:P,relativePath:f,isVirtual:D},resource:p,context:g,deps:{sharedDataIds:[`${w}${f}`],routeSlugs:O}});if(h.add(p),!(a==="graphql-docs"?t?.description?.value!==void 0:!!a&&St(t,a,P))||!k(t,a,M))continue;I.add(S);const b=y(R);if(a==="graphql-docs"){t.description&&(t.description.value=b);const _=`${w}${f}`;Ct(r.get(_),b)}else a&&(t[a]=b)}}const E=n.difference(h);for(const c of E)g.cache.delete(c);n=h,Object.entries(m).forEach(([c,i])=>{const D=i[C]?.fsPath;if(!D)return;const S=o.getRouteByFsPath(D)?.baseSlug;m[c]={...i,[C]:{...i[C],slug:S},slug:S}}),o.setGlobalData({apiProducts:m});for(const[c,i]of r){if(!I.has(c))continue;const{items:D,store:S}=await v({type:i.document.type,document:i.document.document,options:i.document.options,basePath:i.basePath,markdownParser:U});await o.createSharedData(c,z(i,D,S))}}}}function z({document:e,basePath:r,sourcePath:s,apiId:n},m,k){return{[A]:W(e.config),[C]:{slug:nt(r),fsPath:e.customOutputRelativeFile||e.relativePath},items:m,store:k,options:e.options,baseSlug:r,routesMapping:$.isDevelopMode?yt(m,r):{},graphqlPositions:$.isDevelopMode&&e.type==="graphql"?It(m,r):void 0,sourcePath:s,apiId:n}}function Ct(e,r){e?.document.type!=="graphql"||!e.document.options||(e.document.options.info={...e.document.options.info||{},description:r})}function Et(e,r){return async function(s){return{props:{settings:{baseUrlPath:q(s.baseSlug)},disableAutoScroll:!0,seo:{title:e,...r}}}}}function wt(e,r){const s=e.options?.mockServer,n=q(`/_mock${vt(e.relativePath)}`);s?.url===n&&(e.options={...e.options,mockServer:{...s,url:q(`/_mock${r}`)}})}function Tt(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 kt(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{pe as apiDocsPlugin,Tt as toRouteSlugFields};
|