@redocly/realm 0.130.0-custom.7 → 0.130.0-custom.8

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*as e from"react";import{useCallback as se,useMemo as E,useState as ie,useEffect as oe}from"react";import{useLocation as G}from"react-router-dom";import{Flex as ce}from"@redocly/portal-legacy-ui";import{Button as I}from"@redocly/theme/components/Button/Button";import{AddIcon as _}from"@redocly/theme/icons/AddIcon/AddIcon";import{SubtractIcon as U}from"@redocly/theme/icons/SubtractIcon/SubtractIcon";import{ArrowLeftIcon as Z}from"@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon";import{useProcessScorecard as J}from"@redocly/theme/ext/process-scorecard";import{getScorecardColorVariable as Q,withoutPathPrefix as X}from"@redocly/theme/core/utils";import{Link as O}from"../../../../client/app/Link";import ue from"../../../../client/app/CircularProgress";import{isDefined as j}from"../../../../utils/guards/is-defined.js";import{removeLeadingSlash as me}from"../../../../utils/url/remove-leading-slash.js";import{StatusByLevelWidget as de}from"./StatusByLevelWidget";import{OTHER_TEAMS_LABEL as pe,NON_CONFORMANT as ge}from"./utils";import{LevelIndicator as fe}from"./LevelIndicator";import{AppPageWrapper as Y,CardValue as P,CardsWrapper as ee,CatalogDescription as Ee,ModeSwitcherTab as q,ModeSwitcherTabs as he,CardRow as te,ProblemsByStatusCardBody as re,ScoreCardStatusCardBody as ne,TableWrap as M,LevelComplianceCardTitle as ye,ContentWithDotWrap as k,ScorecardCard as V,ScorecardCardTitle as N}from"./index.styles";import{ApiLevel as ae,InstanceStatus as $,LevelStatus as R,RuleStatus as le}from"./components";import{Grid as z}from"./Grid/Grid";import{useDetailedScorecard as ve}from"./useDetailedScorecard";import{Gauge as be,GaugeValue as Se}from"./Gauge";function Ce(c,u,p){if(c===u)return 0;if(c==null||c==="")return 1;if(u==null||u==="")return-1;if(p==="number"){const m=Number(c),a=Number(u),s=Number.isNaN(m),g=Number.isNaN(a);return s&&g?0:s?1:g?-1:m-a}if(p==="date"){const m=new Date(String(c)).getTime(),a=new Date(String(u)).getTime(),s=Number.isNaN(m),g=Number.isNaN(a);return s&&g?0:s?1:g?-1:m-a}return String(c).localeCompare(String(u))}function F(c){return c==="error"?{errors:1,warnings:0}:c==="warning"?{errors:0,warnings:1}:{errors:0,warnings:0}}function He(c){const u=G(),{data:p,levelNames:m,hasPublishedAt:a,hasTeam:s,teamLabel:g}=c,{getApiTableColumns:L}=J(),h=se((y,S,A)=>{const D=y.getValue(A)?new Date(y.getValue(A)).getTime():0,r=S.getValue(A)?new Date(S.getValue(A)).getTime():0;return D>r?1:-1},[]),b=E(()=>{const y=L?.()??[],S=y.filter(r=>r.placement==="beforeLevels"),A=y.filter(r=>r.placement!=="beforeLevels"),D=r=>({id:r.id,header:String(r.header),accessorFn:o=>r.getValue?.(o)??r.getSortValue?.(o),enableSorting:!!(r.sortingFn||r.sortRule||r.getSortValue||r.getValue),sortingFn:(o,f,n)=>{const l=o.original,x=f.original,t=r.getSortValue?.(l)??o.getValue(n),i=r.getSortValue?.(x)??f.getValue(n);return r.sortingFn?r.sortingFn({rowA:l,rowB:x,valueA:t,valueB:i}):Ce(t,i,r.sortRule||"string")},...r.sortDescFirst!==void 0?{sortDescFirst:r.sortDescFirst}:{},cell:({getValue:o,row:f})=>{const n=o(),l=f.original;return r.render?r.render({row:l,value:n}):n==null||n===""?"-":String(n)},...r.size!==void 0?{size:r.size}:{},...r.minSize!==void 0?{minSize:r.minSize}:{},...r.maxSize!==void 0?{maxSize:r.maxSize}:{}});return[{id:"title",header:"API",accessorKey:"api.title",size:200,cell:({getValue:r,row:o})=>e.createElement(O,{to:X(u.pathname)+"/apis/"+encodeURIComponent(me(o.original.api.link))},r()," ",o.original.api.version)},a?{header:"Published at",accessorKey:"api.publishedAt",sortingFn:h,cell:({getValue:r})=>{const o=r();return o?new Date(o).toLocaleDateString():"-"}}:void 0,s?{header:g,accessorKey:"api.team"}:void 0,{id:"level",header:"Level",accessorKey:"scorecard.scorecardLevel",cell:({getValue:r,row:o})=>e.createElement(ae,{level:r(),colorVariable:Q(o.original?.scorecard.scorecardLevelIdx,m.length+1)})},...S.map(D),...m.map(r=>({id:r,header:`${r}`,accessorKey:"scorecard.levels",sortingFn:(o,f,n)=>{const l=o.getValue(n)[n].uniqueErrors,x=f.getValue(n)[n].uniqueErrors,t=o.getValue(n)[n].uniqueWarnings,i=f.getValue(n)[n].uniqueWarnings;return l===x?t-i:l-x},cell:({getValue:o,row:{original:f}})=>{const n=o(),l=f.api.link;return n?.[r]?e.createElement(fe,{key:l,uniqueErrors:n[r].uniqueErrors,uniqueWarnings:n[r].uniqueWarnings,customDisplay:n[r].customDisplay,id:l}):null}})),...A.map(D)].filter(j)},[h,m,u.pathname,a,s,g,L]),d=E(()=>{const y=Math.max(b.length-3,0);return`25% max(140px, 15%) max(140px, 10%)${y>0?` repeat(${y}, 1fr)`:""}`},[b.length]);return e.createElement(z,{columns:b,data:p,sortBy:[{id:"title",desc:!1}],gridTemplateColumns:d})}function Ge(c){const u=G(),{data:p}=c,m=E(()=>[{header:"Rules",accessorKey:"ruleId",cell:({getValue:a})=>e.createElement(O,{to:X(u.pathname)+"/rules/"+encodeURIComponent(a())},a())},{id:"status",header:"Status",accessorKey:"status",size:200,cell:({row:a})=>e.createElement(le,{errors:a.original.errorApisCount,warnings:a.original.warningApisCount})},{header:"Problem APIs",width:200,accessorKey:"apisCount",cell:({getValue:a})=>a(),sortDescFirst:!0},{header:"Problem count",size:200,accessorKey:"count",sortDescFirst:!0}],[u.pathname]);return e.createElement(z,{columns:m,data:p,virtualized:!1,sortBy:[{id:"status",desc:!0}]})}function _e(c){const{data:u,levelNames:p,filters:m,setActiveTab:a,teamLabel:s,teamProperty:g}=c,L=E(()=>[{id:"team",header:`API ${s}`,accessorKey:"team",size:200,cell:({getValue:h})=>e.createElement("a",{href:"#",onClick:b=>{b.preventDefault(),a("apis"),m.find(d=>d.property===g)?.selectOption(h())}},h())},...[ge,...p].map(h=>({id:h,header:`${h}`,accessorFn:b=>b.levels[h]?.apis}))],[m,p,a,s,g]);return e.createElement(z,{columns:L,data:u,sortBy:[{id:"team",desc:!1}],groupHeaderTitle:"APIs by level"})}function Ae(c){const{data:u,title:p}=c,m=E(()=>[{id:"expand",maxSize:40,size:40,header:()=>null,enableSorting:!1,cell:({row:a})=>a.getCanExpand()?e.createElement(I,{onClick:a.getToggleExpandedHandler(),variant:"text",size:"medium",icon:a.getIsExpanded()?e.createElement(U,null):e.createElement(_,null)}):null},{header:"Rules",accessorKey:"ruleId",cell:({getValue:a,row:s})=>s.getCanExpand()?e.createElement("span",{onClick:s.getToggleExpandedHandler()},a()):null},{header:"Status",accessorKey:"status",size:200,cell:({getValue:a})=>{const s=a();return e.createElement(le,{errors:s?.errorsCount,warnings:s?.warningsCount})},enableSorting:!1},{header:"Problem count",accessorKey:"problemsCount",size:200,sortDescFirst:!0}],[]);return e.createElement(z,{columns:m,data:u,sortBy:[{id:"ruleId",desc:!1}],empty:e.createElement(e.Fragment,null,"\u2705 This API is compliant with ",e.createElement("strong",null,p)," level rules"),subRowKey:"problems"})}function Ue(c){const{catalogSlug:u,slug:p,data:m,hasTeam:a,hasPublishedAt:s,teamLabel:g}=c,{apis:L,apisCount:h,warningApisCount:b,errorApisCount:d,levels:y,count:S}=m,A=E(()=>Object.values(L),[L]),D=A.length===0,r=D?void 0:{id:"expand",maxSize:40,size:40,header:()=>null,enableSorting:!1,cell:({row:n})=>n.getCanExpand()?e.createElement(I,{onClick:n.getToggleExpandedHandler(),variant:"text",size:"medium",icon:n.getIsExpanded()?e.createElement(U,null):e.createElement(_,null)}):null},o=E(()=>[r,{header:"API",accessorKey:"title"},s?{header:"Published at",accessorKey:"publishedAt",cell:({getValue:n})=>{const l=n();return l?new Date(l).toLocaleDateString():"-"}}:void 0,a?{header:g,accessorKey:"team",cell:({getValue:n})=>n()||pe}:void 0,{header:"Problem count",size:200,accessorKey:"count",cell:({getValue:n})=>n()||0,sortDescFirst:!0}].filter(j),[a,s,g,D]),f=E(()=>Object.entries(m.teams).sort((n,l)=>l[1]-n[1]),[m.teams]);return e.createElement(Y,null,e.createElement(I,{icon:e.createElement(Z,null),iconPosition:"left",variant:"ghost",size:"large",to:`${u}scorecard`},"Back to dashboard"),e.createElement("h1",null,"Rule ",p),e.createElement(ee,null,e.createElement(V,null,e.createElement(N,null,"Rule status"),e.createElement(ne,null,e.createElement("div",null,e.createElement(P,null,h),e.createElement("br",null),"APIs"),e.createElement("div",null,e.createElement(k,null,e.createElement(P,{style:{textAlign:"right"}},h-b-d),e.createElement($,{severity:"Pass"})),e.createElement(k,null,e.createElement(P,{style:{textAlign:"right"}},b),e.createElement($,{severity:"Warn"})),e.createElement(k,null,e.createElement(P,{style:{textAlign:"right"}},d),e.createElement($,{severity:"Error"}))))),e.createElement(V,null,e.createElement(N,null,"Problems by level"),e.createElement(re,null,Object.entries(y).map(([n,l])=>e.createElement(te,{key:n},e.createElement("span",null,n),e.createElement(be,{chunks:[{share:l.errors/S*100,colorVariable:"--scorecard-color-error"},{share:l.warnings/S*100,colorVariable:"--scorecard-color-warning"}]}),e.createElement(Se,null,l.errors+l.warnings))))),e.createElement(V,null,e.createElement(N,null,`Problems by ${g}`),e.createElement(re,null,f.slice(0,4).map(([n,l])=>e.createElement(te,{key:n},e.createElement("span",{style:{flex:1,textAlign:"left"}},n),e.createElement(P,null,l)))))),e.createElement(z,{columns:o,data:A,sortBy:[{id:"title",desc:!1}],subRowKey:"problems",slug:p}))}function Ze(c){const{slug:u,api:p,teamLabel:m,catalogSlug:a}=c,{api:s}=p||{},{scorecard:g,isLoading:L}=ve(`/${u}`),{processScorecard:h,getApiTableColumns:b}=J(),d=g&&h(g,p.api),y=d?.levels||{},S=E(()=>Object.keys(y),[y]),A=E(()=>s?.publishedAt instanceof Date?s?.publishedAt.toLocaleDateString():s?.publishedAt,[s]),D=E(()=>{if(!d?.levels)return{};const t={};for(const i of Object.keys(d.levels)){const w=d.levels[i].problems.reduce((T,C)=>(T[C.ruleId]||(T[C.ruleId]=[]),T[C.ruleId].push(C),T),{});t[i]=Object.entries(w).map(([T,C])=>({ruleId:T,problems:[...C.filter(v=>v.severity==="error"),...C.filter(v=>v.severity==="warn")],problemsCount:C.length,status:{errorsCount:C.filter(v=>v.severity==="error").length,warningsCount:C.filter(v=>v.severity==="warn").length}}))}return t},[d?.levels]),r=E(()=>{if(!d)return[];const t={api:p.api,scorecard:d};return(b?.()??[]).filter(i=>!i.details?.hidden).map(i=>{const w=i.getValue?.(t),T=i.details?.description,C=typeof T=="function"?T(t):T;let v;if(i.details?.render){if(v=i.details.render({row:t,value:w}),v===null)return}else if(i.render){if(v=i.render({row:t,value:w}),v===null)return}else v=w==null||w===""?"-":String(w);const K=i.details?.status,B=typeof K=="function"?K({row:t,value:w}):K,H=i.details?.statusRule;let W=B||"success";return!B&&H==="problem-if-truthy"&&(W=w?"error":"success"),!B&&H==="problem-if-falsy"&&(W=w?"success":"error"),{id:`custom-${i.id}`,label:i.details?.tabLabel||i.header,description:C,content:v,placement:i.placement==="beforeLevels"?"beforeLevels":"afterLevels",status:W}}).filter(j)},[p.api,b,d]),o=E(()=>r.filter(t=>t.placement==="beforeLevels"),[r]),f=E(()=>r.filter(t=>t.placement==="afterLevels"),[r]),n=E(()=>[...o.map(t=>t.id),...S,...f.map(t=>t.id)],[f,o,S]),[l,x]=ie(n[0]||"");return oe(()=>{n.length&&x(t=>n.includes(t)?t:n[0])},[n]),L?e.createElement(ce,{justifyContent:"center",mt:"2em"},e.createElement(ue,null)):d?e.createElement(Y,null,e.createElement(I,{icon:e.createElement(Z,null),iconPosition:"left",variant:"ghost",size:"large",to:`${a}scorecard`},"Back to dashboard"),e.createElement("h1",null,s?.title||u),e.createElement(Ee,null,A&&e.createElement(e.Fragment,null,"Published at: ",new Date().toLocaleString(void 0,{timeZoneName:"short"}),e.createElement("br",null)),e.createElement(O,{to:s?.link,external:!0},"Documentation")),e.createElement(ee,null,e.createElement(V,null,e.createElement(ye,null,e.createElement("span",null,"Scorecard level"),e.createElement(ae,{level:d.scorecardLevel,colorVariable:Q(d.scorecardLevelIdx,Object.keys(y).length)})),e.createElement(ne,null,e.createElement("div",null,"Compliance by level"),e.createElement("div",null,Object.entries(d.levels).map(([t,i])=>e.createElement(k,{key:t},e.createElement(P,{style:{width:"100px",textAlign:"right"}},t),e.createElement(R,{errors:i.errors,warnings:i.warnings})))))),e.createElement(de,{title:"Rules compliance",levels:Object.entries(d.levels).map(([t,i])=>({errors:i.uniqueErrors,warnings:i.uniqueWarnings,total:c.rulesPerLevel[t].length,name:t}))}),e.createElement(V,null,e.createElement(N,null,m),e.createElement(P,{style:{fontWeight:"normal"}},s?.team))),e.createElement(he,{style:{justifyContent:"flex-start"},"data-component-name":"Scorecard/ModeSwitcherTabs"},o.map(t=>e.createElement(q,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t.id,isActive:l===t.id,onClick:()=>x(t.id)},e.createElement(k,null,e.createElement("span",null,t.label),e.createElement(R,{errors:F(t.status).errors,warnings:F(t.status).warnings})))),S.map(t=>e.createElement(q,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t,isActive:l===t,onClick:()=>x(t)},e.createElement(k,null,e.createElement("span",null,t)," ",e.createElement(R,{errors:d.levels[t].errors,warnings:d.levels[t].warnings})))),f.map(t=>e.createElement(q,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t.id,isActive:l===t.id,onClick:()=>x(t.id)},e.createElement(k,null,e.createElement("span",null,t.label),e.createElement(R,{errors:F(t.status).errors,warnings:F(t.status).warnings}))))),o.map(t=>e.createElement(M,{key:t.id,isActive:l===t.id},e.createElement(V,null,t.description?e.createElement("p",{style:{marginTop:0,marginBottom:12,color:"var(--text-color-secondary)"}},t.description):null,e.createElement("div",null,t.content)))),S.map(t=>e.createElement(M,{key:t,isActive:l===t},e.createElement(Ae,{title:t,data:D[t]}))),f.map(t=>e.createElement(M,{key:t.id,isActive:l===t.id},e.createElement(V,null,t.description?e.createElement("p",{style:{marginTop:0,marginBottom:12,color:"var(--text-color-secondary)"}},t.description):null,e.createElement("div",null,t.content))))):e.createElement("div",null,"Scorecard not found")}export{He as ApiListView,Ze as ApiPage,Ae as ApiView,Ue as RuleView,Ge as RulesView,_e as TeamsView};
1
+ import*as e from"react";import{useCallback as ce,useMemo as E,useState as ue,useEffect as de}from"react";import{useLocation as M}from"react-router-dom";import{Flex as me}from"@redocly/portal-legacy-ui";import{Button as F}from"@redocly/theme/components/Button/Button";import{AddIcon as J}from"@redocly/theme/icons/AddIcon/AddIcon";import{SubtractIcon as Q}from"@redocly/theme/icons/SubtractIcon/SubtractIcon";import{ArrowLeftIcon as X}from"@redocly/theme/icons/ArrowLeftIcon/ArrowLeftIcon";import{useProcessScorecard as Y}from"@redocly/theme/ext/process-scorecard";import{getScorecardColorVariable as ee,withoutPathPrefix as te}from"@redocly/theme/core/utils";import{Link as $}from"../../../../client/app/Link";import pe from"../../../../client/app/CircularProgress";import{isDefined as H}from"../../../../utils/guards/is-defined.js";import{removeLeadingSlash as ge}from"../../../../utils/url/remove-leading-slash.js";import{StatusByLevelWidget as fe}from"./StatusByLevelWidget";import{OTHER_TEAMS_LABEL as Ee,NON_CONFORMANT as he}from"./utils";import{LevelIndicator as be}from"./LevelIndicator";import{AppPageWrapper as re,CardValue as V,CardsWrapper as ne,CatalogDescription as ye,ModeSwitcherTab as G,ModeSwitcherTabs as ve,CardRow as ae,ProblemsByStatusCardBody as le,ScoreCardStatusCardBody as se,TableWrap as U,LevelComplianceCardTitle as Se,ContentWithDotWrap as z,ScorecardCard as I,ScorecardCardTitle as K}from"./index.styles";import{ApiLevel as ie,InstanceStatus as _,LevelStatus as B,RuleStatus as oe}from"./components";import{Grid as N}from"./Grid/Grid";import{useDetailedScorecard as Ce}from"./useDetailedScorecard";import{Gauge as we,GaugeValue as Ae}from"./Gauge";function xe(c,d,p){if(c===d)return 0;if(c==null||c==="")return 1;if(d==null||d==="")return-1;if(p==="number"){const m=Number(c),a=Number(d),s=Number.isNaN(m),g=Number.isNaN(a);return s&&g?0:s?1:g?-1:m-a}if(p==="date"){const m=new Date(String(c)).getTime(),a=new Date(String(d)).getTime(),s=Number.isNaN(m),g=Number.isNaN(a);return s&&g?0:s?1:g?-1:m-a}return String(c).localeCompare(String(d))}function W(c){return c==="error"?{errors:1,warnings:0}:c==="warning"?{errors:0,warnings:1}:{errors:0,warnings:0}}function _e(c){const d=M(),{data:p,levelNames:m,hasPublishedAt:a,hasTeam:s,teamLabel:g}=c,{getApiTableColumns:T}=Y(),b=ce((o,S,h)=>{const P=o.getValue(h)?new Date(o.getValue(h)).getTime():0,n=S.getValue(h)?new Date(S.getValue(h)).getTime():0;return P>n?1:-1},[]),v=E(()=>{const o=T?.()??[],S=o.filter(n=>n.placement==="beforeLevels"),h=o.filter(n=>n.placement!=="beforeLevels"),P=n=>({id:n.id,header:String(n.header),accessorFn:i=>n.getValue?.(i)??n.getSortValue?.(i),enableSorting:!!(n.sortingFn||n.sortRule||n.getSortValue||n.getValue),sortingFn:(i,f,r)=>{const l=i.original,w=f.original,k=n.getSortValue?.(l)??i.getValue(r),A=n.getSortValue?.(w)??f.getValue(r);return n.sortingFn?n.sortingFn({rowA:l,rowB:w,valueA:k,valueB:A}):xe(k,A,n.sortRule||"string")},...n.sortDescFirst!==void 0?{sortDescFirst:n.sortDescFirst}:{},cell:({getValue:i,row:f})=>{const r=i(),l=f.original;return n.render?n.render({row:l,value:r}):r==null||r===""?"-":String(r)},...n.size!==void 0?{size:n.size}:{},...n.minSize!==void 0?{minSize:n.minSize}:{},...n.maxSize!==void 0?{maxSize:n.maxSize}:{}});return[{id:"title",header:"API",accessorKey:"api.title",size:200,cell:({getValue:n,row:i})=>e.createElement($,{to:te(d.pathname)+"/apis/"+encodeURIComponent(ge(i.original.api.link))},n()," ",i.original.api.version)},a?{header:"Published at",accessorKey:"api.publishedAt",sortingFn:b,cell:({getValue:n})=>{const i=n();return i?new Date(i).toLocaleDateString():"-"}}:void 0,s?{header:g,accessorKey:"api.team"}:void 0,{id:"level",header:"Level",accessorKey:"scorecard.scorecardLevel",cell:({getValue:n,row:i})=>e.createElement(ie,{level:n(),colorVariable:ee(i.original?.scorecard.scorecardLevelIdx,m.length+1)})},...S.map(P),...m.map(n=>({id:n,header:`${n}`,accessorKey:"scorecard.levels",sortingFn:(i,f,r)=>{const l=i.getValue(r)[r].uniqueErrors,w=f.getValue(r)[r].uniqueErrors,k=i.getValue(r)[r].uniqueWarnings,A=f.getValue(r)[r].uniqueWarnings;return l===w?k-A:l-w},cell:({getValue:i,row:{original:f}})=>{const r=i(),l=f.api.link;return r?.[n]?e.createElement(be,{key:l,uniqueErrors:r[n].uniqueErrors,uniqueWarnings:r[n].uniqueWarnings,customDisplay:r[n].customDisplay,id:l}):null}})),...h.map(P)].filter(H)},[b,m,d.pathname,a,s,g,T]),D=E(()=>{const o=Math.max(v.length-3,0);return`25% max(140px, 15%) max(140px, 10%)${o>0?` repeat(${o}, 1fr)`:""}`},[v.length]);return e.createElement(N,{columns:v,data:p,sortBy:[{id:"title",desc:!1}],gridTemplateColumns:D})}function Ze(c){const d=M(),{data:p}=c,m=E(()=>[{header:"Rules",accessorKey:"ruleId",cell:({getValue:a})=>e.createElement($,{to:te(d.pathname)+"/rules/"+encodeURIComponent(a())},a())},{id:"status",header:"Status",accessorKey:"status",size:200,cell:({row:a})=>e.createElement(oe,{errors:a.original.errorApisCount,warnings:a.original.warningApisCount})},{header:"Problem APIs",width:200,accessorKey:"apisCount",cell:({getValue:a})=>a(),sortDescFirst:!0},{header:"Problem count",size:200,accessorKey:"count",sortDescFirst:!0}],[d.pathname]);return e.createElement(N,{columns:m,data:p,virtualized:!1,sortBy:[{id:"status",desc:!0}]})}function Je(c){const{data:d,levelNames:p,filters:m,setActiveTab:a,teamLabel:s,teamProperty:g}=c,T=E(()=>[{id:"team",header:`API ${s}`,accessorKey:"team",size:200,cell:({getValue:b})=>e.createElement("a",{href:"#",onClick:v=>{v.preventDefault(),a("apis"),m.find(D=>D.property===g)?.selectOption(b())}},b())},...[he,...p].map(b=>({id:b,header:`${b}`,accessorFn:v=>v.levels[b]?.apis}))],[m,p,a,s,g]);return e.createElement(N,{columns:T,data:d,sortBy:[{id:"team",desc:!1}],groupHeaderTitle:"APIs by level"})}function Te(c){const{data:d,title:p}=c,m=E(()=>[{id:"expand",maxSize:40,size:40,header:()=>null,enableSorting:!1,cell:({row:a})=>a.getCanExpand()?e.createElement(F,{onClick:a.getToggleExpandedHandler(),variant:"text",size:"medium",icon:a.getIsExpanded()?e.createElement(Q,null):e.createElement(J,null)}):null},{header:"Rules",accessorKey:"ruleId",cell:({getValue:a,row:s})=>s.getCanExpand()?e.createElement("span",{onClick:s.getToggleExpandedHandler()},a()):null},{header:"Status",accessorKey:"status",size:200,cell:({getValue:a})=>{const s=a();return e.createElement(oe,{errors:s?.errorsCount,warnings:s?.warningsCount})},enableSorting:!1},{header:"Problem count",accessorKey:"problemsCount",size:200,sortDescFirst:!0}],[]);return e.createElement(N,{columns:m,data:d,sortBy:[{id:"ruleId",desc:!1}],empty:e.createElement(e.Fragment,null,"\u2705 This API is compliant with ",e.createElement("strong",null,p)," level rules"),subRowKey:"problems"})}function Qe(c){const{catalogSlug:d,slug:p,data:m,hasTeam:a,hasPublishedAt:s,teamLabel:g}=c,{apis:T,apisCount:b,warningApisCount:v,errorApisCount:D,levels:o,count:S}=m,h=E(()=>Object.values(T),[T]),P=h.length===0,n=P?void 0:{id:"expand",maxSize:40,size:40,header:()=>null,enableSorting:!1,cell:({row:r})=>r.getCanExpand()?e.createElement(F,{onClick:r.getToggleExpandedHandler(),variant:"text",size:"medium",icon:r.getIsExpanded()?e.createElement(Q,null):e.createElement(J,null)}):null},i=E(()=>[n,{header:"API",accessorKey:"title"},s?{header:"Published at",accessorKey:"publishedAt",cell:({getValue:r})=>{const l=r();return l?new Date(l).toLocaleDateString():"-"}}:void 0,a?{header:g,accessorKey:"team",cell:({getValue:r})=>r()||Ee}:void 0,{header:"Problem count",size:200,accessorKey:"count",cell:({getValue:r})=>r()||0,sortDescFirst:!0}].filter(H),[a,s,g,P]),f=E(()=>Object.entries(m.teams).sort((r,l)=>l[1]-r[1]),[m.teams]);return e.createElement(re,null,e.createElement(F,{icon:e.createElement(X,null),iconPosition:"left",variant:"ghost",size:"large",to:`${d}scorecard`},"Back to dashboard"),e.createElement("h1",null,"Rule ",p),e.createElement(ne,null,e.createElement(I,null,e.createElement(K,null,"Rule status"),e.createElement(se,null,e.createElement("div",null,e.createElement(V,null,b),e.createElement("br",null),"APIs"),e.createElement("div",null,e.createElement(z,null,e.createElement(V,{style:{textAlign:"right"}},b-v-D),e.createElement(_,{severity:"Pass"})),e.createElement(z,null,e.createElement(V,{style:{textAlign:"right"}},v),e.createElement(_,{severity:"Warn"})),e.createElement(z,null,e.createElement(V,{style:{textAlign:"right"}},D),e.createElement(_,{severity:"Error"}))))),e.createElement(I,null,e.createElement(K,null,"Problems by level"),e.createElement(le,null,Object.entries(o).map(([r,l])=>e.createElement(ae,{key:r},e.createElement("span",null,r),e.createElement(we,{chunks:[{share:l.errors/S*100,colorVariable:"--scorecard-color-error"},{share:l.warnings/S*100,colorVariable:"--scorecard-color-warning"}]}),e.createElement(Ae,null,l.errors+l.warnings))))),e.createElement(I,null,e.createElement(K,null,`Problems by ${g}`),e.createElement(le,null,f.slice(0,4).map(([r,l])=>e.createElement(ae,{key:r},e.createElement("span",{style:{flex:1,textAlign:"left"}},r),e.createElement(V,null,l)))))),e.createElement(N,{columns:i,data:h,sortBy:[{id:"title",desc:!1}],subRowKey:"problems",slug:p}))}function Xe(c){const{slug:d,api:p,teamLabel:m,catalogSlug:a}=c,{api:s}=p||{},g=M(),{scorecard:T,isLoading:b}=Ce(`/${d}`),{processScorecard:v,getApiTableColumns:D}=Y(),o=T&&v(T,p.api),S=o?.levels||{},h=E(()=>Object.keys(S),[S]),P=E(()=>s?.publishedAt instanceof Date?s?.publishedAt.toLocaleDateString():s?.publishedAt,[s]),n=E(()=>{if(!o?.levels)return{};const t={};for(const u of Object.keys(o.levels)){const x=o.levels[u].problems.reduce((L,C)=>(L[C.ruleId]||(L[C.ruleId]=[]),L[C.ruleId].push(C),L),{});t[u]=Object.entries(x).map(([L,C])=>({ruleId:L,problems:[...C.filter(y=>y.severity==="error"),...C.filter(y=>y.severity==="warn")],problemsCount:C.length,status:{errorsCount:C.filter(y=>y.severity==="error").length,warningsCount:C.filter(y=>y.severity==="warn").length}}))}return t},[o?.levels]),i=E(()=>{if(!o)return[];const t={api:p.api,scorecard:o};return(D?.()??[]).filter(u=>!u.details?.hidden).map(u=>{const x=u.getValue?.(t),L=u.details?.description,C=typeof L=="function"?L(t):L;let y;if(u.details?.render){if(y=u.details.render({row:t,value:x}),y===null)return}else if(u.render){if(y=u.render({row:t,value:x}),y===null)return}else y=x==null||x===""?"-":String(x);const O=u.details?.status,q=typeof O=="function"?O({row:t,value:x}):O,Z=u.details?.statusRule;let j=q||"success";return!q&&Z==="problem-if-truthy"&&(j=x?"error":"success"),!q&&Z==="problem-if-falsy"&&(j=x?"success":"error"),{id:`custom-${u.id}`,label:u.details?.tabLabel||u.header,description:C,content:y,placement:u.placement==="beforeLevels"?"beforeLevels":"afterLevels",status:j}}).filter(H)},[p.api,D,o]),f=E(()=>i.filter(t=>t.placement==="beforeLevels"),[i]),r=E(()=>i.filter(t=>t.placement==="afterLevels"),[i]),l=E(()=>[...f.map(t=>t.id),...h,...r.map(t=>t.id)],[r,f,h]),w=E(()=>new URLSearchParams(g.search).get("tab")?.trim()||void 0,[g.search]),k=E(()=>{if(w)return h.includes(w)?w:[...f,...r].find(t=>t.label===w)?.id},[r,f,h,w]),[A,R]=ue(l[0]||"");return de(()=>{if(l.length){if(k&&l.includes(k)){R(k);return}R(t=>l.includes(t)?t:l[0])}},[l,k]),b?e.createElement(me,{justifyContent:"center",mt:"2em"},e.createElement(pe,null)):o?e.createElement(re,null,e.createElement(F,{icon:e.createElement(X,null),iconPosition:"left",variant:"ghost",size:"large",to:`${a}scorecard`},"Back to dashboard"),e.createElement("h1",null,s?.title||d),e.createElement(ye,null,P&&e.createElement(e.Fragment,null,"Published at: ",new Date().toLocaleString(void 0,{timeZoneName:"short"}),e.createElement("br",null)),e.createElement($,{to:s?.link,external:!0},"Documentation")),e.createElement(ne,null,e.createElement(I,null,e.createElement(Se,null,e.createElement("span",null,"Scorecard level"),e.createElement(ie,{level:o.scorecardLevel,colorVariable:ee(o.scorecardLevelIdx,Object.keys(S).length)})),e.createElement(se,null,e.createElement("div",null,"Compliance by level"),e.createElement("div",null,Object.entries(o.levels).map(([t,u])=>e.createElement(z,{key:t},e.createElement(V,{style:{width:"100px",textAlign:"right"}},t),e.createElement(B,{errors:u.errors,warnings:u.warnings})))))),e.createElement(fe,{title:"Rules compliance",levels:Object.entries(o.levels).map(([t,u])=>({errors:u.uniqueErrors,warnings:u.uniqueWarnings,total:c.rulesPerLevel[t].length,name:t}))}),e.createElement(I,null,e.createElement(K,null,m),e.createElement(V,{style:{fontWeight:"normal"}},s?.team))),e.createElement(ve,{style:{justifyContent:"flex-start"},"data-component-name":"Scorecard/ModeSwitcherTabs"},f.map(t=>e.createElement(G,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t.id,isActive:A===t.id,onClick:()=>R(t.id)},e.createElement(z,null,e.createElement("span",null,t.label),e.createElement(B,{errors:W(t.status).errors,warnings:W(t.status).warnings})))),h.map(t=>e.createElement(G,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t,isActive:A===t,onClick:()=>R(t)},e.createElement(z,null,e.createElement("span",null,t)," ",e.createElement(B,{errors:o.levels[t].errors,warnings:o.levels[t].warnings})))),r.map(t=>e.createElement(G,{"data-component-name":"Scorecard/ModeSwitcherTab",key:t.id,isActive:A===t.id,onClick:()=>R(t.id)},e.createElement(z,null,e.createElement("span",null,t.label),e.createElement(B,{errors:W(t.status).errors,warnings:W(t.status).warnings}))))),f.map(t=>e.createElement(U,{key:t.id,isActive:A===t.id},e.createElement(I,null,t.description?e.createElement("p",{style:{marginTop:0,marginBottom:12,color:"var(--text-color-secondary)"}},t.description):null,e.createElement("div",null,t.content)))),h.map(t=>e.createElement(U,{key:t,isActive:A===t},e.createElement(Te,{title:t,data:n[t]}))),r.map(t=>e.createElement(U,{key:t.id,isActive:A===t.id},e.createElement(I,null,t.description?e.createElement("p",{style:{marginTop:0,marginBottom:12,color:"var(--text-color-secondary)"}},t.description):null,e.createElement("div",null,t.content))))):e.createElement("div",null,"Scorecard not found")}export{_e as ApiListView,Xe as ApiPage,Te as ApiView,Qe as RuleView,Ze as RulesView,Je as TeamsView};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/realm",
3
- "version": "0.130.0-custom.7",
3
+ "version": "0.130.0-custom.8",
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/graphql-docs": "1.7.0-custom.1",
95
94
  "@redocly/asyncapi-docs": "1.7.0-custom.1",
96
- "@redocly/portal-legacy-ui": "0.14.0-next.0",
97
- "@redocly/theme": "0.62.0-custom.2",
95
+ "@redocly/config": "0.43.0-custom.1",
96
+ "@redocly/graphql-docs": "1.7.0-custom.1",
98
97
  "@redocly/openapi-docs": "3.18.0-custom.1",
98
+ "@redocly/theme": "0.62.0-custom.2",
99
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"
100
+ "@redocly/realm-asyncapi-sdk": "0.9.0-next.1",
101
+ "@redocly/portal-legacy-ui": "0.14.0-next.0"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "react": "^19.2.4",