@redocly/realm 0.130.0-custom.21 → 0.130.0-custom.22
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{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";import{combineUrls as
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as O}from"@redocly/config";import{combineUrls as Z}from"@redocly/theme/core/utils";import{OPENAPI_DOCS_TEMPLATE_ID as ee,PUBLIC_RBAC_SCOPE_ITEM as te}from"../../../constants/common.js";import{DEPRECATED_PUBLIC_API_DEFINITIONS_FOLDER as ge,PUBLIC_API_DEFINITIONS_FOLDER as Ie}from"../../constants/common.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as Pe,OPENAPI_SHARED_DATA_PREFIX as Se}from"../../constants/plugins/openapi-docs.js";import{envConfig as oe}from"../../config/env-config.js";import{logger as w}from"../../tools/notifiers/logger.js";import{searchResolver as De}from"./search/search-resolver.js";import{convertOpenAPIDocs2Sidebar as ye,shouldAddRoute as Ae}from"./utils.js";import{getTemplatePath as U}from"./get-template-path.js";import{storeDefinitionBundles as Re,storeDefinitionBundle as ve}from"./store-definition-bundles.js";import{definitionLoader as ke,definitionsLoader as _e}from"./load-definition.js";import{getAiDocumentsStore as be}from"./search/get-ai-search-documents.js";import{buildInstanceMetadata as Ee,fetchRegistryApiIdByPath as Te,filterInstancesForApiVersion as xe,getResolvedApiVersion as Fe,hasTemplateVariables as Ce,loadLinkedInstancesByApiId as Oe,patchOpenApiDefinitionWithVariables as we,resolveApiIdForDefinition as Be}from"./instances.js";import{fromCurrentDir as Me}from"../../utils/paths.js";import{telemetryTraceStep as Le}from"../../../cli/telemetry/helpers/trace-step.js";const j="openapi-spec-download";async function it(){let a=[],r={},i={},f=new Set;return{id:"openapi",requiredEntitlements:["openapi"],loaders:{"load-oas-docs":_e,"load-oas":ke},processContent:async(e,c)=>{await Le("build.plugin.openapi_docs",async l=>{e.createRequestHandler(j,Me(import.meta.url,"./spec-download.api.js")),e.addApiRoute({slug:Ie+"/*",requestHandlerId:j,httpMethod:"all",[O]:te,getStaticData:async()=>({props:{}})}),e.addApiRoute({slug:ge+"/*",requestHandlerId:j,httpMethod:"all",[O]:te,getStaticData:async()=>({props:{}})});const u=e.createTemplate(ee,U("../../../client/templates/openapi-docs/template.js")),m=e.registerServerPropsGetter(ee,U("./get-server-props.js")),p=e.registerServerPropsGetter(Pe,U("./get-server-props-custom-fields.js")),n=await c.getConfig();l?.setAttribute("config",JSON.stringify(n.openapi||{}));const P=n.rules?.["custom-fields-schema"];r={},i={};const v=w.startTiming("Loading openapi definitions..."),h=await e.loadOpenApiDefinitions(c);w.infoTime(v,"Loading openapi definitions...");const B=await Te(),E=await Oe(c);a=h.map(({markdocChunks:S,relativePath:y,customOutputRelativeFile:g,isVirtual:d,realRelativePath:M})=>({chunks:S,relativePath:y,realRelativePath:M,isVirtual:g!=null||d})),Re(h,e.outdir);const T={};for(const S of h||[]){const{definition:y,config:g,relativePath:d,customOutputRelativeFile:M,contentItems:ne,flatItems:L,parser:$,options:q,rawOptions:ae,hash:ie}=S,x=M||d,{definition:se}=$||{},{info:A}=se||{},I=Be(S,B),re={...A?.["x-metadata"]||{}},N=!!g.openapi?.excludeFromSearch||!!g.theme?.openapi?.excludeFromSearch||!!n.openapi?.excludeFromSearch||!!n.theme?.openapi?.excludeFromSearch,z={title:A?.title,description:A?.description,summary:A?.summary,...g.metadata,...re},ce=Fe(S),F=I?xe(E.get(I)||[],ce):[],K=$e(y,F),W=K.map(t=>({key:t.key,title:t.title,summary:t.summary,tags:t.tags,routePrefix:t.routePrefix,routeSuffixesByItemId:{}})),pe=new Map(W.map(t=>[t.key,t])),k={untagged:[],tagged:new Map};for(const t of L){const{operationDefinition:o}=t;if(o){const{tags:_}=o;if(_)for(const R of _)k.tagged.has(R)||k.tagged.set(R,[]),k.tagged.get(R)?.push(t);else k.untagged.push(t)}}for(const t of K){const o=[],_={},R=pe.get(t.key);if(!R)continue;const J=t.routePrefix?`${x.replace(/\.[^.]+$/,"")}/${t.routePrefix}`:x;t.routePrefix&&ve(t.definition,J,e.outdir);for(const s of L){const{id:b,href:D,operationDefinition:X}=s;if(oe.isDevelopMode){const C=X?.pointer;C&&(_[`#${C}`]=Ve(s.href,t.routePrefix))}if(!Ae({item:s}))continue;const H=s,me=H.type==="section"&&!!H.infoDefinition,Y=Ne(D,"");R.routeSuffixesByItemId[b]=Y;const he=X?.[O];o.push({excludeFromSearch:N,slugSuffix:Y,fsPath:J,metadata:{subType:"openapi-operation"},httpVerb:s?.httpVerb||"",path:d,templateId:u,[O]:he||g.rbac,getAiDocumentsStore:be({parser:$,options:q,info:A,tagOperations:k,openapiContentItem:H,metadata:z,relativePath:d,getSearchFacets:e.getSearchFacets,includeInLLMsTxt:me,excludeFromSearch:N}),getStaticData:async C=>({props:{dynamicMarkdocComponents:["openapi"],baseSlug:C.baseSlug,seo:s["x-metadata"]?.seo||{title:s.name,description:s.description},itemId:b,disableAutoScroll:!0}})})}if(!o.length)continue;const Q=t.key!==""&&!!t.sourceInstance,de=Q&&I&&t.sourceInstance?Ee(t.sourceInstance,I):{},le=Q?{}:{...F.length>0?{instanceCount:F.length}:{},...F.length===0&&Ce(y)?{isTemplate:!0}:{}},V=t.definition?.info?.title;o[0]={...o[0],metadata:{type:"openapi",...z,...de,...le,...I?{apiId:I}:{}},hasClientRoutes:!0,getSidebar:(s,b)=>{const D=[];return ye({contentItems:ne,sidebarItems:D,routeSlug:s.slug,navItem:b}),V&&D.length>0&&D[0]&&!b?.label&&(D[0].label=V),D},getNavText:()=>V||A?.title,getSearchDocuments:De($,q,L,e.getSearchFacets,e.setSearchFacets,N)},I&&t.key===""&&(T[I]={slug:o[0]?.slug||""});const fe=o[0];o[0]=o[o.length-1],o[o.length-1]=fe;const ue=oe.isDevelopMode?d:void 0,G=`${Se}${x}::${t.id}`;i[d]=[...i[d]||[],G],r[G]={fsPath:x,definition:t.definition,options:ae,instances:W,currentInstanceKey:t.key,sourcePath:ue,routesMapping:_,hash:ie};for(const s of o)e.addRoute({...s,sharedData:[{id:G,key:"openAPIDocsStore"}],serverPropsGetterIds:P?[m,p]:[m]})}}e.setGlobalData({apiProducts:T})})},afterRoutesCreated:async(e,c)=>{const l=w.startTiming("Parsing openapi markdoc chunks..."),u=new Set;for(const{chunks:p,relativePath:n,isVirtual:P,realRelativePath:v}of a){const h=(await c.cache.load(v,"load-oas")).compoundHash,B=i[n]||[];await c.cache.load(n,{loader:async function(){for(const{node:T,markdown:S,key:y,relativePath:g}of p){const{ast:d}=await e.parseMarkdoc({content:S,relativePath:g,isVirtual:P},c,{sharedDataIds:B});T[`x-parsed-md-${y}`]={result:d}}},name:"openapi-markdoc-inline-parser"},[h]);for(const{pointer:E}of p)u.add(E)}w.infoTime(l,"Parsing openapi markdoc chunks...");const m=f.difference(u);for(const p of m)c.cache.delete(p);f=u;for(const[p,n]of Object.entries(r)){for(const P of n.instances||[]){const v=P.routePrefix?`${n.fsPath.replace(/\.[^.]+$/,"")}/${P.routePrefix}`:n.fsPath,h=e.getRouteByFsPath(v);h&&(P.baseSlug=h.baseSlug)}await e.createSharedData(p,{...n,baseSlug:e.getRouteByFsPath(n.fsPath)?.baseSlug},n.hash)}}}}function $e(a,r){const i=[{id:"default",key:"",title:"Default",routePrefix:"",definition:a}],f=new Set;for(const e of r){const c=Ge(e.key)||"instance";let l=`instances/${c}`,u=2;for(;f.has(l);)l=`instances/${c}-${u}`,u++;f.add(l);const m=we(a,e.variables),p=e.title?{...m,info:{...m.info||{},title:e.title}}:m;i.push({id:`instance-${l.replace(/[\/:]/g,"-")}`,key:e.key,title:e.title,summary:e.summary,tags:e.tags,routePrefix:l,definition:p,sourceInstance:e})}return i}function Ne(a,r){const i=a.split("#")[0]+"/";return r?Z("/",r,i):i}function Ve(a,r){if(!r)return a;const[i="",f]=a.split("#"),e=Z("/",r,i||"/");return f?`${e}#${f}`:e}function Ge(a){return a.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}export{it as openAPIDocsPlugin};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BundledDefinition } from './load-definition';
|
|
2
2
|
export declare function storeDefinitionBundles(definitions: BundledDefinition[], outDir: string): void;
|
|
3
|
+
export declare function storeDefinitionBundle(definition: unknown, relativePath: string, outDir: string): void;
|
|
3
4
|
export declare function replaceFileExtension(filePath: string, fileExt: string): string;
|
|
4
5
|
//# sourceMappingURL=store-definition-bundles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as
|
|
1
|
+
import{writeFileSync as S}from"fs";import r from"path";import{dump as h}from"js-yaml";import{PUBLIC_API_DEFINITIONS_FOLDER as d,PUBLIC_STATIC_FOLDER as p}from"../../constants/common.js";import{logger as m}from"../../tools/notifiers/logger.js";import{ensureDir as D}from"../../utils/fs.js";const l=new Map;function v(i,n){const t=d.slice(1);try{for(const e of i){const{definition:s,originalDefinition:x,relativePath:o,hash:f}=e,c=x||s;if(l.get(o)!==f){if(o.startsWith(p+"/")){const g=r.posix.extname(o);a({outDir:n,definitionFolder:".",relativePath:o.replace(p+"/",""),definitionString:g===".json"?JSON.stringify(c,null,2):h(c)}),l.set(o,f);continue}a({outDir:n,definitionFolder:t,relativePath:u(o,".json"),definitionString:JSON.stringify(c,null,2)}),l.set(o,f)}}}catch(e){m.error("failed to store definition bundles",e)}}function _(i,n,t){const e=d.slice(1);try{a({outDir:t,definitionFolder:e,relativePath:u(n,".json"),definitionString:JSON.stringify(i,null,2)})}catch(s){m.error(`failed to store definition bundle for ${n}`,s)}}function u(i,n){const t=r.posix.dirname(i),e=r.posix.basename(i,r.posix.extname(i))+n;return r.posix.join(t,e)}function a({outDir:i,definitionString:n,relativePath:t,definitionFolder:e}){S(D(r.resolve(i,`${e}/${t}`)),n,"utf8")}export{u as replaceFileExtension,_ as storeDefinitionBundle,v as storeDefinitionBundles};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/realm",
|
|
3
|
-
"version": "0.130.0-custom.
|
|
3
|
+
"version": "0.130.0-custom.22",
|
|
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.2",
|
|
95
|
-
"@redocly/openapi-docs": "3.18.0-custom.1",
|
|
96
94
|
"@redocly/graphql-docs": "1.7.0-custom.2",
|
|
97
|
-
"@redocly/
|
|
98
|
-
"@redocly/portal-plugin-mock-server": "0.16.0-next.4",
|
|
95
|
+
"@redocly/asyncapi-docs": "1.7.0-custom.2",
|
|
99
96
|
"@redocly/portal-legacy-ui": "0.14.0-next.0",
|
|
97
|
+
"@redocly/openapi-docs": "3.18.0-custom.1",
|
|
100
98
|
"@redocly/realm-asyncapi-sdk": "0.9.0-next.1",
|
|
101
|
-
"@redocly/theme": "0.62.0-custom.2"
|
|
99
|
+
"@redocly/theme": "0.62.0-custom.2",
|
|
100
|
+
"@redocly/config": "0.43.0-custom.1",
|
|
101
|
+
"@redocly/portal-plugin-mock-server": "0.16.0-next.4"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^19.2.4",
|