PageSourceSearch

https://xbp.app/assets/openapi-B7hvJGXV.js

js xbp.app collected 2026-10-05 06:13:13 UTC 10,414 bytes, 1 lines download raw bytes

1import{K as G,r as i,j as e,B as W,b2 as $,c as p,k as D,L as E,b5 as I,b6 as K}from"./index-CPaYb3xI.js";import{o as P}from"./download02-icon-CMrDMDg0.js";import{o as T}from"./file02-icon-CoAu7WYm.js";import{e as V}from"./link02-icon-DbOOY6NO.js";import{C as w}from"./copy-badge-DTEV2Aji.js";import{f as _}from"./format-relative-time-cNw4UkeX.js";import"./tooltip-D7tB-7w9.js";import"./index-B-8uziNJ.js";import"./index-Be0Um-nQ.js";const z="xbp generate openapi --all",R="xbp login";function k(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(2)} MB`}function A(n){return new Intl.NumberFormat("en",{notation:"compact"}).format(n)}function N({active:n,label:m,count:u,mono:f,onClick:l}){return e.jsxs("button",{className:p("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs transition-colors",n?"border-foreground/15 bg-foreground text-background":"border-border/70 bg-background text-muted-foreground hover:bg-surface-1 hover:text-foreground"),onClick:l,type:"button",children:[e.jsx("span",{className:p(f&&"font-mono"),children:m}),typeof u=="number"?e.jsx("span",{className:"tabular-nums opacity-70",children:u}):null]})}function y({label:n,value:m}){return e.jsxs("div",{className:"rounded-lg border border-border/60 bg-surface-1/50 px-3 py-2",children:[e.jsx("p",{className:"font-medium text-muted-foreground text-xs uppercase tracking-[var(--tracking-label)]",children:n}),e.jsx("p",{className:"mt-0.5 font-semibold text-sm tabular-nums tracking-tight",children:m})]})}function q({initialGenerations:n}){const m=G(),[u,f]=i.useState(()=>Array.isArray(n)?n:[]),[l,v]=i.useState(null),[d,x]=i.useState(null),[g,C]=i.useState(""),[S,L]=i.useTransition(),a=Array.isArray(u)?u:[],B=i.useMemo(()=>{const s=new Map;for(const r of a)s.set(r.repositoryFullName,(s.get(r.repositoryFullName)??0)+1);return[...s.entries()].map(([r,t])=>({name:r,count:t})).sort((r,t)=>r.name.localeCompare(t.name))},[a]),b=i.useMemo(()=>{const s=g.trim().toLowerCase();return a.filter(r=>l&&r.repositoryFullName!==l||d&&r.serviceName!==d?!1:s?r.repositoryFullName.toLowerCase().includes(s)||r.serviceName.toLowerCase().includes(s)||r.serviceVersion.toLowerCase().includes(s)||r.branch.toLowerCase().includes(s)||r.filename.toLowerCase().includes(s):!0)},[a,g,l,d]),F=i.useMemo(()=>{const s=l?a.filter(t=>t.repositoryFullName===l):a,r=new Map;for(const t of s)r.set(t.serviceName,(r.get(t.serviceName)??0)+1);return[...r.entries()].map(([t,o])=>({name:t,count:o})).sort((t,o)=>t.name.localeCompare(o.name))},[a,l]),h=i.useMemo(()=>{const s=new Map;for(const r of b){const t=[r.repositoryFullName,r.branch,r.serviceName,r.serviceVersion,r.iteration].join("::"),o=r.generatedAt instanceof Date?r.generatedAt.toISOString():String(r.generatedAt),c=s.get(t);c?(c.files.push(r),c.totalBytes+=r.byteSize):s.set(t,{key:t,repo:r.repositoryFullName,service:r.serviceName,version:r.serviceVersion,iteration:r.iteration,branch:r.branch,files:[r],generatedAt:o,totalBytes:r.byteSize})}return[...s.values()].sort((r,t)=>t.generatedAt.localeCompare(r.generatedAt))},[b]),j=i.useMemo(()=>{const s=new Set(a.map(o=>o.serviceName)),r=new Set(a.map(o=>o.repositoryFullName)),t=a.reduce((o,c)=>o+c.byteSize,0);return{files:a.length,services:s.size,repos:r.size,bytes:t}},[a]);function O(){L(async()=>{try{const s=await I({data:{limit:200}});f(Array.isArray(s)?s:[])}catch{f([])}m.invalidate()})}return e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("section",{className:"rounded-xl border border-border/70 bg-background px-4 py-4 md:px-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 max-w-2xl space-y-1",children:[e.jsx("p",{className:"font-medium text-[11px] text-muted-foreground uppercase tracking-[0.14em]",children:"OpenAPI"}),e.jsx("h2",{className:"font-semibold text-lg tracking-tight",children:"Generated contracts"}),e.jsxs("p",{className:"text-muted-foreground text-sm leading-6",children:["Specs from"," ",e.jsx("code",{className:"rounded bg-surface-1 px-1 py-0.5 font-mono text-[11px]",children:"xbp generate openapi"}),", archived locally and uploaded to R2 when signed in."]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(w,{value:z}),e.jsxs(W,{disabled:S,onClick:()=>O(),size:"sm",variant:"outline",children:[e.jsx($,{className:p(S&&"animate-spin"),size:14,strokeWidth:2}),"Refresh"]})]})]}),a.length>0?e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2 sm:grid-cols-4",children:[e.jsx(y,{label:"Files",value:A(j.files)}),e.jsx(y,{label:"Services",value:A(j.services)}),e.jsx(y,{label:"Repos",value:A(j.repos)}),e.jsx(y,{label:"Stored",value:k(j.bytes)})]}):null]}),a.length===0?e.jsxs("div",{className:"rounded-xl border border-border/70 border-dashed bg-background px-6 py-12 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 flex size-11 items-center justify-center rounded-xl border border-border/60 bg-surface-1 text-muted-foreground",children:e.jsx(T,{size:18,strokeWidth:1.8})}),e.jsx("p",{className:"font-medium text-sm tracking-tight",children:"No uploaded OpenAPI specs yet"}),e.jsxs("p",{className:"mx-auto mt-1.5 max-w-md text-muted-foreground text-sm leading-6",children:["Run"," ",e.jsx("code",{className:"rounded bg-surface-1 px-1 py-0.5 font-mono text-[11px]",children:R})," ","then generate in a project. Artifacts also land under project and global"," ",e.jsx("code",{className:"rounded bg-surface-1 px-1 py-0.5 font-mono text-[11px]",children:".xbp/openapi-generations"}),"."]}),e.jsxs("div",{className:"mt-4 flex justify-center gap-2",children:[e.jsx(w,{value:R}),e.jsx(w,{value:z})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{className:"h-8 min-w-56 flex-1 rounded-lg border border-border/70 bg-background px-2.5 text-xs outline-none placeholder:text-muted-foreground focus:border-foreground
1/25",onChange:s=>C(s.target.value),placeholder:"Search repo, service, version, file…",type:"search",value:g}),(l||d||g)&&e.jsx("button",{className:"rounded-lg border border-border/70 px-2.5 py-1.5 text-[11px] text-muted-foreground hover:bg-surface-1 hover:text-foreground",onClick:()=>{v(null),x(null),C("")},type:"button",children:"Clear filters"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(N,{active:l==null,count:a.length,label:"All repos",onClick:()=>{v(null),x(null)}}),B.map(s=>e.jsx(N,{active:l===s.name,count:s.count,label:s.name,mono:!0,onClick:()=>{v(s.name),x(null)}},s.name))]}),F.length>1?e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(N,{active:d==null,label:"All services",onClick:()=>x(null)}),F.map(s=>e.jsx(N,{active:d===s.name,count:s.count,label:s.name,onClick:()=>x(s.name)},s.name))]}):null]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between px-0.5 text-[11px] text-muted-foreground",children:e.jsxs("span",{className:"tabular-nums",children:[h.length," generation",h.length===1?"":"s",b.length!==a.length?` · ${b.length} files`:""]})}),h.length===0?e.jsx("div",{className:"rounded-xl border border-border/70 border-dashed px-4 py-8 text-center text-muted-foreground text-sm",children:"No generations match the current filters."}):h.map(s=>e.jsx("article",{className:"rounded-xl border border-border/70 bg-background px-4 py-3.5 transition-colors hover:border-border",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"rounded-md bg-surface-1 px-2 py-0.5 font-medium font-mono text-foreground text-xs",children:s.repo}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground text-xs",children:[e.jsx(D,{size:11,strokeWidth:2}),s.branch]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-medium text-foreground",children:s.service}),e.jsx("span",{className:"text-muted-foreground",children:"·"}),e.jsxs("span",{className:"text-muted-foreground tabular-nums",children:["v",s.version]}),e.jsxs("span",{className:"rounded-md border border-border/70 px-1.5 py-0.5 text-[11px] text-muted-foreground tabular-nums",children:["iter ",s.iteration]}),e.jsx("span",{className:"text-muted-foreground",children:"·"}),e.jsx("span",{className:"text-muted-foreground",children:_(s.generatedAt)}),e.jsx("span",{className:"text-muted-foreground",children:"·"}),e.jsx("span",{className:"text-muted-foreground tabular-nums",children:k(s.totalBytes)})]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.files.map(r=>{const t=r.publicUrl,o=r.format==="json"?"JSON":"YAML",c=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"rounded bg-background/80 px-1 py-px font-medium text-[10px] text-muted-foreground uppercase tracking-wide",children:o}),e.jsx("span",{className:"truncate font-mono",children:r.filename}),e.jsx("span",{className:"text-muted-foreground tabular-nums",children:k(r.byteSize)}),t?e.jsx(V,{className:"opacity-60",size:11,strokeWidth:2}):e.jsx(P,{className:"opacity-40",size:11,strokeWidth:2})]}),M="inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-surface-1 px-2 py-1.5 text-xs transition-colors";
1return t?e.jsx("a",{className:p(M,"hover:border-foreground/20 hover:bg-surface-2"),href:t,rel:"noreferrer",target:"_blank",title:r.r2Key,children:c},r.id):e.jsx("span",{className:p(M,"text-muted-foreground"),title:r.r2Key,children:c},r.id)})})]})},s.key))]})]}),e.jsxs("p",{className:"px-0.5 text-[11px] text-muted-foreground leading-5",children:["Local:"," ",e.jsx("code",{className:"rounded bg-surface-1 px-1 py-0.5 font-mono",children:"~/.xbp/openapi-generations/…"})," ","and"," ",e.jsxs("code",{className:"rounded bg-surface-1 px-1 py-0.5 font-mono",children:[".xbp/openapi-generations/","{service}/{version}/{iteration}"]}),"."," ",e.jsx(E,{className:"underline decoration-border underline-offset-4 hover:text-foreground",to:"/dashboard/worktrees",children:"Worktrees"})]})]})}function se(){const{generations:n}=K.useLoaderData();return e.jsx(q,{initialGenerations:Array.isArray(n)?n:[]})}export{se as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.