@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,5 +1,7 @@
1
1
  # @redocly/revel
2
2
 
3
+ ## 0.138.2
4
+
3
5
  ## 0.138.1
4
6
 
5
7
  ### Patch Changes
@@ -1 +1 @@
1
- import{REDOCLY_ROUTE_RBAC as E,REDOCLY_TEAMS_RBAC as v}from"@redocly/config";import{mcpTagSchemas as Z,schemaDefinitionTag as ee,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 te,PUBLIC_RBAC_SCOPE_ITEM as x}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as oe,PUBLIC_API_DEFINITIONS_FOLDER as re}from"../../constants/common.js";import{API_DOCS_SHARED_DATA_PREFIX as w}from"../../constants/plugins/api-docs.js";import{fromCurrentDir as ae}from"../../utils/paths.js";import{normalizeRouteSlug as se}from"../../../utils/path/normalize-route-slug.js";import{createSlugify as ie}from"../create-slugify.js";import{apiDocLoader as ne,apiDocsLoader as ce}from"./loader.js";import{getTemplatePath as j}from"./get-template-path.js";import{storeDefinitionBundles as pe}from"./store-definition-bundles.js";import{telemetryTraceStep as ue}from"../../../cli/telemetry/helpers/trace-step.js";import{searchResolver as de}from"./search/search-resolver.js";import{getAiDocumentsStore as le}from"./search/get-ai-search-documents.js";import{getApiConfigByPath as me}from"../get-api-config.js";import{getRouteSlugsForPath as fe}from"../utils.js";import{collectItemRoutes as he}from"./utils/collect-item-routes.js";import{isChunkCurrent as ge}from"./utils/decorators.js";import{applyNavItemToRoot as De}from"./utils/apply-nav-item-to-root.js";import{buildRoutesMapping as Se}from"./utils/build-routes-mapping.js";import{buildItemPositions as Pe}from"./utils/build-item-positions.js";import{resolveApiDocTitle as ye}from"./utils/resolve-api-doc-title.js";import{resolveConfigRbac as Ie}from"./utils/resolve-config-rbac.js";import{relativePathToBaseSlug as Ae}from"./utils/relative-path-to-base-slug.js";import{normalizeApiVersion as ve}from"./utils/normalize-api-version.js";import{importApiDocsBuilder as W}from"./import-api-docs-builder.js";import{envConfig as $}from"../../config/env-config.js";import{logger as Re}from"../../tools/notifiers/logger.js";const T="openapi-spec-download",be={asyncapi:"AsyncAPI Docs",graphql:"GraphQL Docs",openapi:"OpenAPI Docs"};async function nt(){let t=[],r=new Map;const s=new WeakMap;let n=new Set,m={};function k(o,h,A){const y=s.get(o)??new Map;s.set(o,y);const g=h??"";return y.get(g)===A?!1:(y.set(g,A),!0)}return{id:"api-docs",requiredEntitlements:["openapi","asyncapi","graphql"],loaders:{"api-doc":ne,"api-docs":ce},processContent:async(o,h)=>{await ue("com.redocly.build.plugin.apiDocs",async()=>{o.createRequestHandler(T,ae(import.meta.url,"./spec-download.api.js")),o.addApiRoute({slug:re+"/*",requestHandlerId:T,httpMethod:"all",[v]:x,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:oe+"/*",requestHandlerId:T,httpMethod:"all",[v]:x,getStaticData:async()=>({props:{}})}),o.addApiRoute({slug:te+"/*",requestHandlerId:T,httpMethod:"all",[v]:x,getStaticData:async()=>({props:{}})});const A=o.createTemplate(V,j("../../../client/templates/api-docs/template.js")),y=o.registerServerPropsGetter(V,j("./get-server-props.js")),g=await h.getConfig();r=new Map,m={};const I=await o.loadApiDocuments(h);pe(I,o.outdir);const C=!!g.plugins?.some(e=>typeof e=="string"&&e.startsWith("@redocly/portal-plugin-async-api/"));C&&I.some(e=>e.type==="asyncapi")&&Re.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");const c=C?I.filter(e=>e.type!=="asyncapi"):I;t=c.map(({markdocChunks:e,relativePath:P,isVirtual:p,customOutputRelativeFile:a,realRelativePath:f})=>({chunks:e??[],relativePath:P,realRelativePath:f,isVirtual:a!=null||p}));const{buildItems:i}=await W(o.serverOutDir),D=(await h.cache.load("content-slugs","content-slugs")).data,S=ie(D),O=e=>se(S(e));for(const e of c){const P=e.customOutputRelativeFile||e.relativePath,p=O(P);Ee(e,p);const{items:a,store:f}=await i({type:e.type,document:e.document,options:e.options,basePath:p,markdownParser:U}),R=`${w}${e.relativePath}`,M=$.isDevelopMode?e.relativePath:void 0,u=Te(e.document),b=u?.["x-metadata"],_=e.isVirtual?void 0:b?.apiId,N={document:e,basePath:p,sourcePath:M,apiId:_};await o.createSharedData(R,Q(N,a,f));const K=Ie(e.config),F=!!e.options.excludeFromSearch,Y=e.type==="openapi",l=he(a,K).map(d=>{const B=d.metadata?.seo,H={...we(d.link,p),fsPath:P,templateId:A,sharedData:[{key:"apiDocsStore",id:R}],serverPropsGetterIds:[y],excludeFromSearch:F,getStaticData:Ce(d.label,B),[v]:d[v]};return Y?{...H,...d.httpVerb?{httpVerb:d.httpVerb,metadata:{subType:"openapi-operation"}}:{}}:H});if(!l.length)continue;const G=ye(u,e.type,a),X=ve(u?.version),L={type:e.type,title:G,version:X,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"]:{}};l[0]={...l[0],metadata:L,hasClientRoutes:!0,getSidebar:(d,B)=>De(z(a),p,B),getNavText:()=>G??be[e.type]??"API Docs",getSearchDocuments:de(a,L,o.getSearchFacets,o.setSearchFacets,F,f,e.document),getAiDocumentsStore:le({items:a,metadata:L,store:f,document:e.document,specType:e.type,excludeFromSearch:F,basePath:p,getSearchFacets:o.getSearchFacets,markdocTags:{...Z,schemaDefinition:ee}})};const J=l[0];l[0]=l[l.length-1],l[l.length-1]=J;for(const d of l)o.addRoute(d);if(_){const d=me(e.config?.apis,e.realRelativePath);m[_]={[v]:d.rbac,[E]:{fsPath:P}}}r.set(R,N)}})},afterRoutesCreated:async(o,h)=>{const{buildItems:A,simplifyAstStructure:y}=await W(o.serverOutDir),g=new Set,I=new Set;for(const{chunks:c,relativePath:i,isVirtual:D}of t){const S=`${w}${i}`,O=fe(o.getAllRoutes(),i);for(const{node:e,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:h,deps:{sharedDataIds:[`${w}${f}`],routeSlugs:O}});if(g.add(p),!(a==="graphql-docs"?e?.description?.value!==void 0:!!a&&ge(e,a,P))||!k(e,a,M))continue;I.add(S);const b=y(R);if(a==="graphql-docs"){e.description&&(e.description.value=b);const _=`${w}${f}`;_e(r.get(_),b)}else a&&(e[a]=b)}}const C=n.difference(g);for(const c of C)h.cache.delete(c);n=g,Object.entries(m).forEach(([c,i])=>{const D=i[E]?.fsPath;if(!D)return;const S=o.getRouteByFsPath(D)?.baseSlug;m[c]={...i,[E]:{...i[E],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 A({type:i.document.type,document:i.document.document,options:i.document.options,basePath:i.basePath,markdownParser:U});await o.createSharedData(c,Q(i,D,S))}}}}function Q({document:t,basePath:r,sourcePath:s,apiId:n},m,k){return{items:m,store:k,options:t.options,baseSlug:r,routesMapping:$.isDevelopMode?Se(m,r):{},graphqlPositions:$.isDevelopMode&&t.type==="graphql"?Pe(m,r):void 0,sourcePath:s,apiId:n}}function _e(t,r){t?.document.type!=="graphql"||!t.document.options||(t.document.options.info={...t.document.options.info||{},description:r})}function Ce(t,r){return async function(s){return{props:{settings:{baseUrlPath:q(s.baseSlug)},disableAutoScroll:!0,seo:{title:t,...r}}}}}function Ee(t,r){const s=t.options?.mockServer,n=q(`/_mock${Ae(t.relativePath)}`);s?.url===n&&(t.options={...t.options,mockServer:{...s,url:q(`/_mock${r}`)}})}function we(t,r){if(t===r)return{};const s=r==="/"?"/":`${r}/`;if(t.startsWith(s)){const n=t.slice(s.length);return n?{slugSuffix:n}:{}}return{slug:t}}function Te(t){if(t&&typeof t=="object"&&"info"in t)return t.info}function z(t){return t.map(({content:r,items:s,...n})=>({...n,...s&&{items:z(s)}}))}export{nt as apiDocsPlugin,we as toRouteSlugFields};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/revel",
3
- "version": "0.138.1",
3
+ "version": "0.138.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {