@redocly/realm 0.130.0-custom.5 → 0.130.0-custom.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.
@@ -1 +1 @@
1
- import{LRUCache as H}from"lru-cache";import{sha1 as M}from"../utils/crypto/sha1.js";import{envConfig as S}from"../config/env-config.js";import{NestedMap as x}from"./utils/nested-map.js";import{trackAccessStore as C}from"./utils/async-storage.js";import{isLoaderCacheEnabled as k}from"./utils/is-loader-cache-enabled.js";import{LoadError as v}from"./load-error.js";import{createLifecycleContext as D}from"../plugins/lifecycle.js";function p(y,t){return y+":"+t}class J{fs;errors=new Map;#t=new Map;#a=new Map;#e=new Map;#s=new Map;#i=new x;#r;#o={};#n=new Map;constructor(t){this.fs=t,this.#r=D(t,this),this.#f()}#c(t){let e=this.#t.get(t);return e||(e=new H({max:S.isBuildMode?1e3:1e6}),this.#t.set(t,e)),e}async load(t,e,a){let s,h;typeof e=="string"?(s=e,h=this.#o[e]):(s=e.name,h=e.loader);const o=p(s,t);if(this.#n.has(o))return this.#n.get(o);const n=a?.join(""),r=n!==void 0?n.length>30?M(n):n:void 0,c=C.getStore()??[],F=!this.#h(t,s,r),g=this.#c(s),m=g.get(t);if(F&&m)return c.push({type:"load",loaderId:s,resource:t,hash:m.compoundHash}),m;const d=Promise.withResolvers();this.#n.set(o,d.promise),r!==void 0&&this.#e.set(o,r);const{status:L,value:l}=await this.#p(t,s,async()=>{let u;const I=C.getStore()||[],w=[],P=i=>w.push(i);try{u=await h(t,this.#r,P),w.length>0?this.errors.set(o,w):this.errors.delete(o)}catch(i){const f=g.get(t)?.data,E=s==="redocly-config"||s==="nearest-redocly-config"?!1:(await this.load(t,"is-ignored")).data;if(!(i instanceof v)&&!E&&this.errors.set(o,[i]),!f)return{status:"error",value:i instanceof v?i:new v(i.message,{cause:i,loaderId:s})};u=f}const R=M(t+(r??"")+I.map(i=>i.hash).sort((i,f)=>i.localeCompare(f)).join(""));return c.push({type:"load",loaderId:s,resource:t,hash:R}),{status:"success",value:{data:u,compoundHash:R}}});return L==="error"?d.reject(l):(this.#l(t),k(s)&&g.set(t,l),this.#a.set(o,l.compoundHash),d.resolve(l)),this.#n.delete(o),d.promise}setLoaders(t){this.#o={...this.#o,...t}}delete(t,e){if(e){const a=p(e,t);this.#d(t,e),this.errors.delete(a),this.#a.delete(a),this.#e.delete(a);const s=this.#s.get(t);if(s){for(const h of s)this.delete(h,e);this.#s.delete(t)}this.#i.delete(e,t)}else for(const a of this.#t.keys())this.delete(t,a)}#d(t,e){const a=this.#t.get(e);a&&a.delete(t)}#l(t){const[e,a]=t.split("#");if(!a)return;const s=this.#s.get(e);s?s.add(t):this.#s.set(e,new Set([t]))}#f(){this.fs.watch(async t=>{for(const e of t)e.event==="unlink"&&this.delete(e.path)})}#h(t,e,a){const s=p(e,t);return a!==void 0&&this.#e.get(s)!==a?!0:(this.#i.get(e,t)??[]).some(n=>{switch(n.type){case"load":const r=p(n.loaderId,n.resource);return this.#a.get(r)!==n.hash||this.#h(n.resource,n.loaderId,this.#e.get(r));case"read":return n.hash!==this.fs.getFileInfo(n.path)?.hash;case"exists":const c=this.fs.getFileInfo(n.path);return n.hash!==(c&&!c.isVirtual?"t":"f");case"scan":return n.hash!==this.fs.getPatternScanHash(n.pattern)}})}#p(t,e,a){const s=[];return this.#i.set(e,t,s),C.run(s,a)}}export{J as Cache};
1
+ import{sha1 as M}from"../utils/crypto/sha1.js";import{NestedMap as H}from"./utils/nested-map.js";import{trackAccessStore as y}from"./utils/async-storage.js";import{isLoaderCacheEnabled as S}from"./utils/is-loader-cache-enabled.js";import{LoadError as v}from"./load-error.js";import{createLifecycleContext as k}from"../plugins/lifecycle.js";function p(C,t){return C+":"+t}class z{fs;errors=new Map;#t=new Map;#n=new Map;#e=new Map;#s=new Map;#i=new H;#r;#o={};#a=new Map;constructor(t){this.fs=t,this.#r=k(t,this),this.#f()}#c(t){let e=this.#t.get(t);return e||(e=new Map,this.#t.set(t,e)),e}async load(t,e,n){let s,h;typeof e=="string"?(s=e,h=this.#o[e]):(s=e.name,h=e.loader);const o=p(s,t);if(this.#a.has(o))return this.#a.get(o);const a=n?.join(""),r=a!==void 0?a.length>30?M(a):a:void 0,c=y.getStore()??[],F=!this.#h(t,s,r),g=this.#c(s),u=g.get(t);if(F&&u)return c.push({type:"load",loaderId:s,resource:t,hash:u.compoundHash}),u;const d=Promise.withResolvers();this.#a.set(o,d.promise),r!==void 0&&this.#e.set(o,r);const{status:L,value:l}=await this.#p(t,s,async()=>{let m;const I=y.getStore()||[],w=[],P=i=>w.push(i);try{m=await h(t,this.#r,P),w.length>0?this.errors.set(o,w):this.errors.delete(o)}catch(i){const f=g.get(t)?.data,E=s==="redocly-config"||s==="nearest-redocly-config"?!1:(await this.load(t,"is-ignored")).data;if(!(i instanceof v)&&!E&&this.errors.set(o,[i]),!f)return{status:"error",value:i instanceof v?i:new v(i.message,{cause:i,loaderId:s})};m=f}const R=M(t+(r??"")+I.map(i=>i.hash).sort((i,f)=>i.localeCompare(f)).join(""));return c.push({type:"load",loaderId:s,resource:t,hash:R}),{status:"success",value:{data:m,compoundHash:R}}});return L==="error"?d.reject(l):(this.#l(t),S(s)&&g.set(t,l),this.#n.set(o,l.compoundHash),d.resolve(l)),this.#a.delete(o),d.promise}setLoaders(t){this.#o={...this.#o,...t}}delete(t,e){if(e){const n=p(e,t);this.#d(t,e),this.errors.delete(n),this.#n.delete(n),this.#e.delete(n);const s=this.#s.get(t);if(s){for(const h of s)this.delete(h,e);this.#s.delete(t)}this.#i.delete(e,t)}else for(const n of this.#t.keys())this.delete(t,n)}#d(t,e){const n=this.#t.get(e);n&&n.delete(t)}#l(t){const[e,n]=t.split("#");if(!n)return;const s=this.#s.get(e);s?s.add(t):this.#s.set(e,new Set([t]))}#f(){this.fs.watch(async t=>{for(const e of t)e.event==="unlink"&&this.delete(e.path)})}#h(t,e,n){const s=p(e,t);return n!==void 0&&this.#e.get(s)!==n?!0:(this.#i.get(e,t)??[]).some(a=>{switch(a.type){case"load":const r=p(a.loaderId,a.resource);return this.#n.get(r)!==a.hash||this.#h(a.resource,a.loaderId,this.#e.get(r));case"read":return a.hash!==this.fs.getFileInfo(a.path)?.hash;case"exists":const c=this.fs.getFileInfo(a.path);return a.hash!==(c&&!c.isVirtual?"t":"f");case"scan":return a.hash!==this.fs.getPatternScanHash(a.pattern)}})}#p(t,e,n){const s=[];return this.#i.set(e,t,s),y.run(s,n)}}export{z as Cache};
@@ -1 +1 @@
1
- import D from"path";import{simplifyAstStructure as O}from"@redocly/openapi-docs/lib/utils/simplifyAstStructure.js";import{buildMenuItems as $}from"@redocly/asyncapi-docs/lib/utils/build-menu-items.js";import{findFirstBinding as F}from"@redocly/asyncapi-docs/lib/utils/find-first-binding.js";import{ASYNC_API_DOCS_TEMPLATE_ID as v}from"../../../constants/common.js";import{combineUrls as I}from"@redocly/theme/core/utils";import{PUBLIC_API_DEFINITIONS_FOLDER as R}from"../../constants/common.js";import{logger as x}from"../../tools/notifiers/logger.js";import{getTemplatePath as E}from"./get-template-path.js";import{storeDefinitionBundles as N}from"./store-definition-bundles.js";import{asyncapiDocLoader as G,asyncapiDocsLoader as L}from"./asyncapi-doc-loader.js";import{searchResolver as j}from"./search/search-resolver.js";import{getAiDocumentsStore as M}from"./search/get-ai-search-documents.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as b}from"../../constants/plugins/openapi-docs.js";import{telemetryTraceStep as U}from"../../../cli/telemetry/helpers/trace-step.js";const C="asyncapi-docs-";async function ot(c){let l=[],d=new Set;return{id:"asyncapi",requiredEntitlements:["asyncapi"],loaders:{"asyncapi-doc":G,"asyncapi-docs":L},processContent:async(e,a)=>{await U("build.plugin.asyncapi_docs",async()=>{const p=await a.getConfig(),S=!!p.rules?.["custom-fields-schema"];if(p.plugins?.some(r=>r.startsWith("@redocly/portal-plugin-async-api/"))){x.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");return}const g=e.createTemplate(v,E("../../../client/templates/asyncapi-docs/template.js")),u=e.registerServerPropsGetter(v,E("./get-server-props.js"));for(const r of await a.fs.scan(/(\.ya?ml|\.json)$/))if(!await a.isPathIgnored(r.relativePath))try{const{data:s,compoundHash:k}=await a.cache.load(r.realRelativePath,"asyncapi-doc");if(!s?.length)continue;l=s.map(({markdocChunks:t,relativePath:n,isVirtual:m,customOutputRelativeFile:f,realRelativePath:A})=>({chunks:t,relativePath:n,realRelativePath:A,isVirtual:f!=null||r.isVirtual||m})),N(s,e.outdir,k);for(const t of s){const n=`${C}${t.relativePath}`,m=F(t.document),{navItems:f,apiItems:A}=$({asyncApiDoc:t.document,protocol:m||""}),_=[{url:I(R,`${T(t.relativePath,".json")}?download`)},{url:I(R,`${T(t.relativePath,".yaml")}?download`)}];await e.createSharedData(n,{document:t.document,apiItems:A,protocol:m,downloadUrls:_,fsPath:t.relativePath}),f.forEach(i=>{const h={fsPath:t.relativePath,slugSuffix:`/${i.link}`,templateId:g,sharedData:[{key:"AsyncApiDefinition",id:n}],getStaticData:w(a.withPathPrefix,i.label),serverPropsGetterIds:S?[u,b]:[u]};e.addRoute(h),i.items&&i.items.forEach(o=>{e.addRoute({...h,slugSuffix:`/${o.link}`,getStaticData:w(a.withPathPrefix,o.label)}),o.items&&o.items.forEach(P=>{e.addRoute({...h,slugSuffix:`/${P.link}`,getStaticData:w(a.withPathPrefix,o.label)})})})}),e.addRoute({fsPath:t.customOutputRelativeFile||t.relativePath,templateId:g,hasClientRoutes:!0,getSidebar:i=>{const h=o=>{const P={...o};return o.link&&(P.routeSlug=I(i.slug,o.link),P.link=I(i.slug,o.link)),o.items&&(P.items=o.items.map(h)),P};return[{type:"link",label:t.document.info?.title??"AsyncAPI Overview",routeSlug:i.slug,link:i.slug},...f.map(h)]},getSearchDocuments:j(e,t.document),getStaticData:w(a.withPathPrefix,t.document.info?.title??"AsyncAPI Docs"),getAiDocumentsStore:M({actions:e,document:t.document,metadata:{type:"asyncapi",title:t.document.info?.title??"AsyncAPI Docs",description:t.document.info?.description??"",...t.document.info?.["x-metadata"]??{}}}),serverPropsGetterIds:S?[u,b]:[u],metadata:{type:"asyncapi",title:t.document.info?.title??"AsyncAPI Docs",description:t.document.info?.description??"",...t.document.info?.["x-metadata"]??{}},sharedData:[{key:"AsyncApiDefinition",id:n}]})}}catch(s){console.error(s)}})},afterRoutesCreated:async(e,a)=>{const p=new Set;for(const{chunks:y,relativePath:g,isVirtual:u,realRelativePath:r}of l){const s=e.getAllRoutes().filter(t=>t.fsPath===g).map(t=>t.slug),k=(await a.cache.load(r,"asyncapi-doc")).compoundHash;await a.cache.load(g,{loader:async function(){for(const{node:n,markdown:m,pointer:f,key:A,relativePath:_}of y||[]){const{ast:i}=await e.parseMarkdoc({content:m,relativePath:f,isVirtual:u},a,{sharedDataIds:[`${C}${_}`],routeSlugs:s});n[`x-parsed-md-${A}`]={result:O(i)}}},name:"asyncapi-markdoc-inline-parser"},[k]);for(const{pointer:t}of y)p.add(t)}const S=d.difference(p);for(const y of S)a.cache.delete(y);d=p}}}function w(c,l){return async function(d,e){return{props:{settings:{baseUrlPath:c(d.baseSlug)},disableAutoScroll:!0,seo:{title:l}}}}}function T(c,l){const d=D.posix.dirname(c),e=D.posix.basename(c,D.posix.extname(c))+l;return D.posix.join(d,e)}export{ot as asyncAPIDocsPlugin};
1
+ import I from"path";import{simplifyAstStructure as O}from"@redocly/openapi-docs/lib/utils/simplifyAstStructure.js";import{buildMenuItems as $}from"@redocly/asyncapi-docs/lib/utils/build-menu-items.js";import{findFirstBinding as F}from"@redocly/asyncapi-docs/lib/utils/find-first-binding.js";import{ASYNC_API_DOCS_TEMPLATE_ID as v}from"../../../constants/common.js";import{combineUrls as w}from"@redocly/theme/core/utils";import{PUBLIC_API_DEFINITIONS_FOLDER as E}from"../../constants/common.js";import{logger as x}from"../../tools/notifiers/logger.js";import{getTemplatePath as R}from"./get-template-path.js";import{storeDefinitionBundles as N}from"./store-definition-bundles.js";import{asyncapiDocLoader as G,asyncapiDocsLoader as L}from"./asyncapi-doc-loader.js";import{searchResolver as j}from"./search/search-resolver.js";import{getAiDocumentsStore as M}from"./search/get-ai-search-documents.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as b}from"../../constants/plugins/openapi-docs.js";import{telemetryTraceStep as U}from"../../../cli/telemetry/helpers/trace-step.js";const C="asyncapi-docs-";async function ot(c){let l=[],d=new Set;return{id:"asyncapi",requiredEntitlements:["asyncapi"],loaders:{"asyncapi-doc":G,"asyncapi-docs":L},processContent:async(e,a)=>{await U("build.plugin.asyncapi_docs",async()=>{const p=await a.getConfig(),A=!!p.rules?.["custom-fields-schema"];if(p.plugins?.some(r=>r.startsWith("@redocly/portal-plugin-async-api/"))){x.warn("The plugin '@redocly/portal-plugin-async-api' is deprecated. Please remove it from your config to use built-in AsyncAPI docs.");return}const D=e.createTemplate(v,R("../../../client/templates/asyncapi-docs/template.js")),u=e.registerServerPropsGetter(v,R("./get-server-props.js"));for(const r of await a.fs.scan(/(\.ya?ml|\.json)$/))if(!await a.isPathIgnored(r.relativePath))try{const{data:s,compoundHash:S}=await a.cache.load(r.realRelativePath,"asyncapi-doc");if(!s?.length)continue;l=s.map(({markdocChunks:t,relativePath:n,isVirtual:m,customOutputRelativeFile:f,realRelativePath:g})=>({chunks:t,relativePath:n,realRelativePath:g,isVirtual:f!=null||r.isVirtual||m})),N(s,e.outdir,S);for(const t of s){const n=`${C}${t.relativePath}`,m=F(t.document),{navItems:f,apiItems:g}=$({asyncApiDoc:t.document,protocol:m||""}),_=[{url:w(E,`${T(t.relativePath,".json")}?download`)},{url:w(E,`${T(t.relativePath,".yaml")}?download`)}];await e.createSharedData(n,{document:t.document,apiItems:g,protocol:m,downloadUrls:_,fsPath:t.relativePath}),f.forEach(i=>{const h={fsPath:t.relativePath,slugSuffix:`/${i.link}`,templateId:D,sharedData:[{key:"AsyncApiDefinition",id:n}],getStaticData:k(a.withPathPrefix,i.label),serverPropsGetterIds:A?[u,b]:[u]};e.addRoute(h),i.items&&i.items.forEach(o=>{e.addRoute({...h,slugSuffix:`/${o.link}`,getStaticData:k(a.withPathPrefix,o.label)}),o.items&&o.items.forEach(P=>{e.addRoute({...h,slugSuffix:`/${P.link}`,getStaticData:k(a.withPathPrefix,o.label)})})})}),e.addRoute({fsPath:t.customOutputRelativeFile||t.relativePath,templateId:D,hasClientRoutes:!0,getSidebar:i=>{const h=o=>{const P={...o};return o.link&&(P.routeSlug=w(i.slug,o.link),P.link=w(i.slug,o.link)),o.items&&(P.items=o.items.map(h)),P};return[{type:"link",label:t.document.info?.title??"AsyncAPI Overview",routeSlug:i.slug,link:i.slug},...f.map(h)]},getSearchDocuments:j(e,t.document),getStaticData:k(a.withPathPrefix,t.document.info?.title??"AsyncAPI Docs"),getAiDocumentsStore:M({actions:e,document:t.document,metadata:{type:"asyncapi",title:t.document.info?.title??"AsyncAPI Docs",description:t.document.info?.description??"",...t.document.info?.["x-metadata"]??{}}}),serverPropsGetterIds:A?[u,b]:[u],metadata:{type:"asyncapi",title:t.document.info?.title??"AsyncAPI Docs",description:t.document.info?.description??"",...t.document.info?.["x-metadata"]??{}},sharedData:[{key:"AsyncApiDefinition",id:n}]})}}catch(s){console.error(s)}})},afterRoutesCreated:async(e,a)=>{const p=new Set;for(const{chunks:y,relativePath:D,isVirtual:u,realRelativePath:r}of l){const s=(await a.cache.load(r,"asyncapi-doc")).compoundHash;await a.cache.load(D,{loader:async function(){for(const{node:t,markdown:n,pointer:m,key:f,relativePath:g}of y||[]){const{ast:_}=await e.parseMarkdoc({content:n,relativePath:m,isVirtual:u},a,{sharedDataIds:[`${C}${g}`]});t[`x-parsed-md-${f}`]={result:O(_)}}},name:"asyncapi-markdoc-inline-parser"},[s]);for(const{pointer:S}of y)p.add(S)}const A=d.difference(p);for(const y of A)a.cache.delete(y);d=p}}}function k(c,l){return async function(d,e){return{props:{settings:{baseUrlPath:c(d.baseSlug)},disableAutoScroll:!0,seo:{title:l}}}}}function T(c,l){const d=I.posix.dirname(c),e=I.posix.basename(c,I.posix.extname(c))+l;return I.posix.join(d,e)}export{ot as asyncAPIDocsPlugin};
@@ -1 +1 @@
1
- import b from"node:path";import{REDOCLY_TEAMS_RBAC as m}from"@redocly/config";import{slash as k}from"../../../utils/path/slash.js";function p(a,r,t){if(!r)throw new Error("Visitor required");if(a){a.description&&r(a,"description",t.location.absolutePointer+"/description",t);for(const o in a["x-enumDescriptions"])r(a["x-enumDescriptions"],o,t.location.absolutePointer+"/x-enumDescriptions/"+o,t)}}const g=/^[a-zA-Z0-9\s\-,.!\?:;'"()/]+$/,u=({outputRelativePath:a,cwd:r})=>{const t=function(e,s,l,c){const{node:n}=c.resolve(e[s]);if(!n||typeof n!="string"||n.match(g))return;const i=c.getVisitorData();i.markdocChunks=i.markdocChunks||[],i.markdocChunks.push({node:e,pointer:k(b.relative(r,l)),markdown:n,relativePath:a,key:s})};return{any:{leave(o,e){p(o,t,e)}},ref:{leave(o,e){p(o,t,e)}}}},f=()=>{const a={};return{Tag:{enter(r){r?.["x-rbac"]&&(a[String(r.name)]=r["x-rbac"])}},any:{leave(r,t){if((t.type.name==="Operation"||t.type.name==="Webhook")&&"tags"in r&&Array.isArray(r.tags))for(const o of r.tags)a[o]&&(r["x-rbac"]=r["x-rbac"]||a[o]);r?.["x-rbac"]&&(r[m]=r["x-rbac"],delete r["x-rbac"])}},ref:{leave(r){r?.["x-rbac"]&&(r[m]=r["x-rbac"],delete r["x-rbac"])}}}};function h(a,r,t){const o={id:"markdown",decorators:{oas3:{markdown:u,rbac:f},async3:{markdown:u,rbac:f}}};return{...a,decorators:{"markdown/rbac":"on","markdown/markdown":{outputRelativePath:r,cwd:t},...a.decorators||{}},plugins:[...a.plugins||[],o]}}export{u as MarkdownParserDecorator,f as RbacDecorator,h as injectDecoratorIntoConfig};
1
+ import b from"node:path";import{REDOCLY_TEAMS_RBAC as m}from"@redocly/config";import{slash as k}from"../../../utils/path/slash.js";function p(a,r,t){if(!r)throw new Error("Visitor required");if(a){a.description&&r(a,"description",t.location.absolutePointer+"/description",t);for(const o in a["x-enumDescriptions"])r(a["x-enumDescriptions"],o,t.location.absolutePointer+"/x-enumDescriptions/"+o,t)}}const g=/^[\w\s\-,.!\?:;'"()/]+$/,u=({outputRelativePath:a,cwd:r})=>{const t=function(e,s,l,c){const{node:n}=c.resolve(e[s]);if(!n||typeof n!="string"||n.match(g))return;const i=c.getVisitorData();i.markdocChunks=i.markdocChunks||[],i.markdocChunks.push({node:e,pointer:k(b.relative(r,l)),markdown:n,relativePath:a,key:s})};return{any:{leave(o,e){p(o,t,e)}},ref:{leave(o,e){p(o,t,e)}}}},f=()=>{const a={};return{Tag:{enter(r){r?.["x-rbac"]&&(a[String(r.name)]=r["x-rbac"])}},any:{leave(r,t){if((t.type.name==="Operation"||t.type.name==="Webhook")&&"tags"in r&&Array.isArray(r.tags))for(const o of r.tags)a[o]&&(r["x-rbac"]=r["x-rbac"]||a[o]);r?.["x-rbac"]&&(r[m]=r["x-rbac"],delete r["x-rbac"])}},ref:{leave(r){r?.["x-rbac"]&&(r[m]=r["x-rbac"],delete r["x-rbac"])}}}};function h(a,r,t){const o={id:"markdown",decorators:{oas3:{markdown:u,rbac:f},async3:{markdown:u,rbac:f}}};return{...a,decorators:{"markdown/rbac":"on","markdown/markdown":{outputRelativePath:r,cwd:t},...a.decorators||{}},plugins:[...a.plugins||[],o]}}export{u as MarkdownParserDecorator,f as RbacDecorator,h as injectDecoratorIntoConfig};
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as D}from"@redocly/config";import{OPENAPI_DOCS_TEMPLATE_ID as U,PUBLIC_RBAC_SCOPE_ITEM as V}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as te,PUBLIC_API_DEFINITIONS_FOLDER as oe}from"../../constants/common.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as ae,OPENAPI_SHARED_DATA_PREFIX as q}from"../../constants/plugins/openapi-docs.js";import{envConfig as J}from"../../config/env-config.js";import{logger as R}from"../../tools/notifiers/logger.js";import{searchResolver as re}from"./search/search-resolver.js";import{convertOpenAPIDocs2Sidebar as se,shouldAddRoute as ne}from"./utils.js";import{getTemplatePath as k}from"./get-template-path.js";import{storeDefinitionBundles as ie}from"./store-definition-bundles.js";import{definitionLoader as pe,definitionsLoader as de}from"./load-definition.js";import{getAiDocumentsStore as ce}from"./search/get-ai-search-documents.js";import{fromCurrentDir as le}from"../../utils/paths.js";import{telemetryTraceStep as me}from"../../../cli/telemetry/helpers/trace-step.js";const w="openapi-spec-download";async function Ce(){let M=[],_={},B=new Set;return{id:"openapi",requiredEntitlements:["openapi"],loaders:{"load-oas-docs":de,"load-oas":pe},processContent:async(e,p)=>{await me("build.plugin.openapi_docs",async A=>{e.createRequestHandler(w,le(import.meta.url,"./spec-download.api.js")),e.addApiRoute({slug:oe+"/*",requestHandlerId:w,httpMethod:"all",[D]:V,getStaticData:async()=>({props:{}})}),e.addApiRoute({slug:te+"/*",requestHandlerId:w,httpMethod:"all",[D]:V,getStaticData:async()=>({props:{}})});const l=e.createTemplate(U,k("../../../client/templates/openapi-docs/template.js")),g=e.registerServerPropsGetter(U,k("./get-server-props.js")),n=e.registerServerPropsGetter(ae,k("./get-server-props-custom-fields.js")),o=await p.getConfig();A?.setAttribute("config",JSON.stringify(o.openapi||{}));const E=o.rules?.["custom-fields-schema"];_={};const T=R.startTiming("Loading openapi definitions..."),m=await e.loadOpenApiDefinitions(p);R.infoTime(T,"Loading openapi definitions..."),M=m.map(({markdocChunks:r,relativePath:u,customOutputRelativeFile:i,isVirtual:s,realRelativePath:d})=>({chunks:r,relativePath:u,realRelativePath:d,isVirtual:i!=null||s})),ie(m,e.outdir);const h={};for(const r of m||[]){const{definition:u,config:i,relativePath:s,customOutputRelativeFile:d,contentItems:v,flatItems:N,parser:C,options:x,rawOptions:Q,hash:W}=r,G=d||s,a=[],H={},{definition:X}=C||{},{info:c}=X||{},O=c?.["x-metadata"],y=!!i.openapi?.excludeFromSearch||!!i.theme?.openapi?.excludeFromSearch||!!o.openapi?.excludeFromSearch||!!o.theme?.openapi?.excludeFromSearch,$={title:c?.title,description:c?.description,summary:c?.summary,...i.metadata,...O},f={untagged:[],tagged:new Map};for(const t of N){const{id:F,href:S,operationDefinition:P}=t;if(P){const{tags:I}=P;if(I)for(const L of I)f.tagged.has(L)||f.tagged.set(L,[]),f.tagged.get(L)?.push(t);else f.untagged.push(t);J.isDevelopMode&&(H[`#${P.pointer}`]=t.href)}if(!ne({item:t}))continue;const b=t,K=b.type==="section"&&!!b.infoDefinition,Z=S.split("#")[0]+"/",ee=P?.[D];a.push({excludeFromSearch:y,slugSuffix:Z,fsPath:G,metadata:{subType:"openapi-operation"},httpVerb:t?.httpVerb||"",path:s,templateId:l,[D]:ee||i.rbac,getAiDocumentsStore:ce({parser:C,options:x,info:c,tagOperations:f,openapiContentItem:b,metadata:$,relativePath:s,getSearchFacets:e.getSearchFacets,includeInLLMsTxt:K,excludeFromSearch:y}),getStaticData:async I=>({props:{dynamicMarkdocComponents:["openapi"],baseSlug:I.baseSlug,seo:t["x-metadata"]?.seo||{title:t.name,description:t.description},itemId:F,disableAutoScroll:!0}})})}a[0]={...a[0],metadata:{type:"openapi",...$},hasClientRoutes:!0,getSidebar:(t,F)=>{const S=[];return se({contentItems:v,sidebarItems:S,routeSlug:t.slug,navItem:F}),S},getNavText:()=>c?.title,getSearchDocuments:re(C,x,N,e.getSearchFacets,e.setSearchFacets,y)},O?.apiId&&(h[O.apiId]={slug:a[0]?.slug||""});const Y=a[0];a[0]=a[a.length-1],a[a.length-1]=Y;const z=J.isDevelopMode?s:void 0,j=`${q}${s}`;_[j]={fsPath:G,definition:u,options:Q,sourcePath:z,routesMapping:H,hash:W};for(const t of a)e.addRoute({...t,sharedData:[{id:j,key:"openAPIDocsStore"}],serverPropsGetterIds:E?[g,n]:[g]})}e.setGlobalData({apiProducts:h})})},afterRoutesCreated:async(e,p)=>{const A=R.startTiming("Parsing openapi markdoc chunks..."),l=new Set;for(const{chunks:n,relativePath:o,isVirtual:E,realRelativePath:T}of M){const m=e.getAllRoutes().filter(r=>r.fsPath===o).map(r=>r.slug),h=(await p.cache.load(T,"load-oas")).compoundHash;await p.cache.load(o,{loader:async function(){for(const{node:u,markdown:i,key:s,relativePath:d}of n){const{ast:v}=await e.parseMarkdoc({content:i,relativePath:d,isVirtual:E},p,{sharedDataIds:[`${q}${d}`],routeSlugs:m});u[`x-parsed-md-${s}`]={result:v}}},name:"openapi-markdoc-inline-parser"},[h]);for(const{pointer:r}of n)l.add(r)}R.infoTime(A,"Parsing openapi markdoc chunks...");const g=B.difference(l);for(const n of g)p.cache.delete(n);B=l;for(const[n,o]of Object.entries(_))await e.createSharedData(n,{...o,baseSlug:e.getRouteByFsPath(o.fsPath)?.baseSlug},o.hash)}}}export{Ce as openAPIDocsPlugin};
1
+ import{REDOCLY_TEAMS_RBAC as D}from"@redocly/config";import{OPENAPI_DOCS_TEMPLATE_ID as j,PUBLIC_RBAC_SCOPE_ITEM as U}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as te,PUBLIC_API_DEFINITIONS_FOLDER as oe}from"../../constants/common.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as ae,OPENAPI_SHARED_DATA_PREFIX as V}from"../../constants/plugins/openapi-docs.js";import{envConfig as q}from"../../config/env-config.js";import{logger as _}from"../../tools/notifiers/logger.js";import{searchResolver as re}from"./search/search-resolver.js";import{convertOpenAPIDocs2Sidebar as se,shouldAddRoute as ne}from"./utils.js";import{getTemplatePath as L}from"./get-template-path.js";import{storeDefinitionBundles as ie}from"./store-definition-bundles.js";import{definitionLoader as pe,definitionsLoader as de}from"./load-definition.js";import{getAiDocumentsStore as ce}from"./search/get-ai-search-documents.js";import{fromCurrentDir as le}from"../../utils/paths.js";import{telemetryTraceStep as me}from"../../../cli/telemetry/helpers/trace-step.js";const k="openapi-spec-download";async function Ce(){let w=[],E={},M=new Set;return{id:"openapi",requiredEntitlements:["openapi"],loaders:{"load-oas-docs":de,"load-oas":pe},processContent:async(e,i)=>{await me("build.plugin.openapi_docs",async R=>{e.createRequestHandler(k,le(import.meta.url,"./spec-download.api.js")),e.addApiRoute({slug:oe+"/*",requestHandlerId:k,httpMethod:"all",[D]:U,getStaticData:async()=>({props:{}})}),e.addApiRoute({slug:te+"/*",requestHandlerId:k,httpMethod:"all",[D]:U,getStaticData:async()=>({props:{}})});const d=e.createTemplate(j,L("../../../client/templates/openapi-docs/template.js")),h=e.registerServerPropsGetter(j,L("./get-server-props.js")),s=e.registerServerPropsGetter(ae,L("./get-server-props-custom-fields.js")),a=await i.getConfig();R?.setAttribute("config",JSON.stringify(a.openapi||{}));const A=a.rules?.["custom-fields-schema"];E={};const T=_.startTiming("Loading openapi definitions..."),c=await e.loadOpenApiDefinitions(i);_.infoTime(T,"Loading openapi definitions..."),w=c.map(({markdocChunks:m,relativePath:u,customOutputRelativeFile:n,isVirtual:r,realRelativePath:f})=>({chunks:m,relativePath:u,realRelativePath:f,isVirtual:n!=null||r})),ie(c,e.outdir);const l={};for(const m of c||[]){const{definition:u,config:n,relativePath:r,customOutputRelativeFile:f,contentItems:J,flatItems:B,parser:v,options:N,rawOptions:Q,hash:W}=m,x=f||r,o=[],G={},{definition:X}=v||{},{info:p}=X||{},C=p?.["x-metadata"],O=!!n.openapi?.excludeFromSearch||!!n.theme?.openapi?.excludeFromSearch||!!a.openapi?.excludeFromSearch||!!a.theme?.openapi?.excludeFromSearch,H={title:p?.title,description:p?.description,summary:p?.summary,...n.metadata,...C},g={untagged:[],tagged:new Map};for(const t of B){const{id:y,href:S,operationDefinition:I}=t;if(I){const{tags:P}=I;if(P)for(const b of P)g.tagged.has(b)||g.tagged.set(b,[]),g.tagged.get(b)?.push(t);else g.untagged.push(t);q.isDevelopMode&&(G[`#${I.pointer}`]=t.href)}if(!ne({item:t}))continue;const F=t,K=F.type==="section"&&!!F.infoDefinition,Z=S.split("#")[0]+"/",ee=I?.[D];o.push({excludeFromSearch:O,slugSuffix:Z,fsPath:x,metadata:{subType:"openapi-operation"},httpVerb:t?.httpVerb||"",path:r,templateId:d,[D]:ee||n.rbac,getAiDocumentsStore:ce({parser:v,options:N,info:p,tagOperations:g,openapiContentItem:F,metadata:H,relativePath:r,getSearchFacets:e.getSearchFacets,includeInLLMsTxt:K,excludeFromSearch:O}),getStaticData:async P=>({props:{dynamicMarkdocComponents:["openapi"],baseSlug:P.baseSlug,seo:t["x-metadata"]?.seo||{title:t.name,description:t.description},itemId:y,disableAutoScroll:!0}})})}o[0]={...o[0],metadata:{type:"openapi",...H},hasClientRoutes:!0,getSidebar:(t,y)=>{const S=[];return se({contentItems:J,sidebarItems:S,routeSlug:t.slug,navItem:y}),S},getNavText:()=>p?.title,getSearchDocuments:re(v,N,B,e.getSearchFacets,e.setSearchFacets,O)},C?.apiId&&(l[C.apiId]={slug:o[0]?.slug||""});const Y=o[0];o[0]=o[o.length-1],o[o.length-1]=Y;const z=q.isDevelopMode?r:void 0,$=`${V}${r}`;E[$]={fsPath:x,definition:u,options:Q,sourcePath:z,routesMapping:G,hash:W};for(const t of o)e.addRoute({...t,sharedData:[{id:$,key:"openAPIDocsStore"}],serverPropsGetterIds:A?[h,s]:[h]})}e.setGlobalData({apiProducts:l})})},afterRoutesCreated:async(e,i)=>{const R=_.startTiming("Parsing openapi markdoc chunks..."),d=new Set;for(const{chunks:s,relativePath:a,isVirtual:A,realRelativePath:T}of w){const c=(await i.cache.load(T,"load-oas")).compoundHash;await i.cache.load(a,{loader:async function(){for(const{node:m,markdown:u,key:n,relativePath:r}of s){const{ast:f}=await e.parseMarkdoc({content:u,relativePath:r,isVirtual:A},i,{sharedDataIds:[`${V}${r}`]});m[`x-parsed-md-${n}`]={result:f}}},name:"openapi-markdoc-inline-parser"},[c]);for(const{pointer:l}of s)d.add(l)}_.infoTime(R,"Parsing openapi markdoc chunks...");const h=M.difference(d);for(const s of h)i.cache.delete(s);M=d;for(const[s,a]of Object.entries(E))await e.createSharedData(s,{...a,baseSlug:e.getRouteByFsPath(a.fsPath)?.baseSlug},a.hash)}}}export{Ce as openAPIDocsPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/realm",
3
- "version": "0.130.0-custom.5",
3
+ "version": "0.130.0-custom.7",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {
@@ -91,14 +91,14 @@
91
91
  "xpath": "0.0.34",
92
92
  "yaml-ast-parser": "0.0.43",
93
93
  "zod": "^3.25.76",
94
- "@redocly/asyncapi-docs": "1.7.0-custom.1",
95
94
  "@redocly/graphql-docs": "1.7.0-custom.1",
96
- "@redocly/config": "0.43.0-custom.1",
97
- "@redocly/realm-asyncapi-sdk": "0.9.0-next.1",
98
- "@redocly/openapi-docs": "3.18.0-custom.1",
95
+ "@redocly/asyncapi-docs": "1.7.0-custom.1",
99
96
  "@redocly/portal-legacy-ui": "0.14.0-next.0",
100
- "@redocly/theme": "0.62.0-custom.1",
101
- "@redocly/portal-plugin-mock-server": "0.16.0-next.4"
97
+ "@redocly/theme": "0.62.0-custom.2",
98
+ "@redocly/openapi-docs": "3.18.0-custom.1",
99
+ "@redocly/portal-plugin-mock-server": "0.16.0-next.4",
100
+ "@redocly/config": "0.43.0-custom.1",
101
+ "@redocly/realm-asyncapi-sdk": "0.9.0-next.1"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "react": "^19.2.4",