@lunora/studio 1.0.0-alpha.55 → 1.0.0-alpha.56
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/dist/index.d.ts +5 -1
- package/dist/index.js +6 -6
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/ApiTab.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +1 -1
- package/dist/packem_chunks/ExportImportPanel.js +1 -1
- package/dist/packem_chunks/FileBrowser.js +1 -1
- package/dist/packem_chunks/FunctionRunner.js +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
- package/dist/packem_chunks/HealthPanel.js +1 -1
- package/dist/packem_chunks/InsightsPanel.js +1 -1
- package/dist/packem_chunks/LogsPanel.js +1 -1
- package/dist/packem_chunks/MailPanel.js +1 -1
- package/dist/packem_chunks/MetricsPanel.js +2 -2
- package/dist/packem_chunks/MigrationsPanel.js +1 -1
- package/dist/packem_chunks/PitrPanel.js +1 -1
- package/dist/packem_chunks/SchemaViewer.js +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
- package/dist/packem_chunks/SettingsPanel.js +1 -1
- package/dist/packem_chunks/SqlEditorPanel.js +1 -1
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/agents-panel.js +1 -1
- package/dist/packem_chunks/containers-panel.js +1 -1
- package/dist/packem_chunks/dashboards-panel.js +1 -1
- package/dist/packem_chunks/fanout-panel.js +1 -1
- package/dist/packem_chunks/flags-panel.js +1 -1
- package/dist/packem_chunks/issues-panel.js +320 -81
- package/dist/packem_chunks/kv-browser.js +2 -2
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/packem_chunks/permissions-panel.js +1 -1
- package/dist/packem_chunks/queues-panel.js +1 -1
- package/dist/packem_chunks/rls-panel.js +1 -1
- package/dist/packem_chunks/storage-rules-panel.js +1 -1
- package/dist/packem_chunks/subscriptions-panel.js +1 -1
- package/dist/packem_chunks/traces-panel.js +1 -1
- package/dist/packem_chunks/workflows-panel.js +1 -1
- package/dist/packem_shared/{ADMIN_FUNCTIONS-C6TEeUiJ.js → ADMIN_FUNCTIONS-C1LXrovV.js} +4 -0
- package/dist/packem_shared/{ApiDocsPanel-CcC6ucbp.js → ApiDocsPanel-cYkYKjK3.js} +1 -1
- package/dist/packem_shared/{DataBrowser-BuFEPTiv.js → DataBrowser-CowupumK.js} +1 -1
- package/dist/packem_shared/{HomePanel-2I1YZm0A.js → HomePanel-B12QgvIn.js} +2 -2
- package/dist/packem_shared/{Studio-CCJBI2wP.js → Studio-DV1PhCIl.js} +2 -2
- package/dist/packem_shared/{StudioApp-Daeqxw2h.js → StudioApp-BF2rK77z.js} +1 -1
- package/dist/packem_shared/{home-panel-DHHUtnKU.js → home-panel-DDo_fi19.js} +1 -1
- package/dist/packem_shared/{select-UkNYCT3s.js → select-D9OwHEch.js} +1 -1
- package/dist/packem_shared/{studio-0479nrrm.js → studio-CuNuEnSJ.js} +1 -1
- package/dist/standalone/{chunk-G5CMK5GY.js → chunk-25CDYYNE.js} +1 -1
- package/dist/standalone/{chunk-AE3AKGOW.js → chunk-2DCA6LV7.js} +1 -1
- package/dist/standalone/{chunk-EOE5NDMK.js → chunk-2TJVFKD2.js} +1 -1
- package/dist/standalone/{chunk-RG4HLPM2.js → chunk-2U3KE6IP.js} +1 -1
- package/dist/standalone/{chunk-DVBY6YQK.js → chunk-2XJ3WRKW.js} +1 -1
- package/dist/standalone/{chunk-4AZYW2PI.js → chunk-3BYY75EO.js} +1 -1
- package/dist/standalone/chunk-3HGNPZBN.js +1 -0
- package/dist/standalone/{chunk-VQ3YOUZB.js → chunk-4A7VE2UO.js} +1 -1
- package/dist/standalone/{chunk-TTEEPVCN.js → chunk-5SXQWGTH.js} +1 -1
- package/dist/standalone/{chunk-OVSBLTAA.js → chunk-6LQ3FXP2.js} +1 -1
- package/dist/standalone/{chunk-FPKTXKPE.js → chunk-6RW37KKD.js} +1 -1
- package/dist/standalone/{chunk-W7ND56KZ.js → chunk-6ZGXWDSY.js} +1 -1
- package/dist/standalone/{chunk-XG4TZSP4.js → chunk-AL5UKM6M.js} +1 -1
- package/dist/standalone/{chunk-N5FMEYSL.js → chunk-BZ5BHTVF.js} +1 -1
- package/dist/standalone/{chunk-RDA4VTHI.js → chunk-D54HL2MW.js} +1 -1
- package/dist/standalone/chunk-DBCP55V6.js +1 -0
- package/dist/standalone/{chunk-PIB7VUVM.js → chunk-DGWFJ3GW.js} +1 -1
- package/dist/standalone/{chunk-FBGC3RSU.js → chunk-DOLG4V3A.js} +1 -1
- package/dist/standalone/{chunk-MWH5LBNF.js → chunk-E5Z2TAAR.js} +1 -1
- package/dist/standalone/{chunk-CW7LZ4SR.js → chunk-EGANQQLW.js} +1 -1
- package/dist/standalone/{chunk-JHR3HKT5.js → chunk-ILGPO3PK.js} +2 -2
- package/dist/standalone/{chunk-JQPHZL2A.js → chunk-JWCCDDLY.js} +1 -1
- package/dist/standalone/{chunk-S5NTGHCG.js → chunk-JZLGLG4T.js} +1 -1
- package/dist/standalone/{chunk-ZUTFDG76.js → chunk-LJ3KEIPO.js} +1 -1
- package/dist/standalone/{chunk-Q3X7IMLF.js → chunk-LYAWJGSH.js} +1 -1
- package/dist/standalone/chunk-MHGJUKCZ.js +1 -0
- package/dist/standalone/{chunk-YNSFQKMM.js → chunk-N3V74RBP.js} +1 -1
- package/dist/standalone/{chunk-IKVZUVHJ.js → chunk-OBFYFJYZ.js} +1 -1
- package/dist/standalone/{chunk-YRE6TGXH.js → chunk-OEIBZ5AI.js} +1 -1
- package/dist/standalone/{chunk-FXNS5NBY.js → chunk-OOLK6C5I.js} +1 -1
- package/dist/standalone/{chunk-SP7GSPKX.js → chunk-RVVADT2N.js} +1 -1
- package/dist/standalone/{chunk-NAFKYFBZ.js → chunk-S7BCXJWD.js} +1 -1
- package/dist/standalone/{chunk-6LLFTVEI.js → chunk-ULOBAURC.js} +1 -1
- package/dist/standalone/{chunk-LTCX3QOE.js → chunk-VDOUWYIZ.js} +1 -1
- package/dist/standalone/{chunk-EIZG4GOM.js → chunk-VJABWVPW.js} +1 -1
- package/dist/standalone/{chunk-EPDC422O.js → chunk-WQC5IIF7.js} +1 -1
- package/dist/standalone/{chunk-WA3DGSC2.js → chunk-XFINDIAB.js} +1 -1
- package/dist/standalone/{chunk-JGCRBFFO.js → chunk-XTOCLVRS.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/standalone/chunk-DWDILV2E.js +0 -1
- package/dist/standalone/chunk-EBTLTGG3.js +0 -1
- package/dist/standalone/chunk-G5RC7USY.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as de,e as j}from"./chunk-7YGTGBP7.js";import{a as ce}from"./chunk-FQUNSQLG.js";import"./chunk-SWMBBYJU.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import"./chunk-KEGAWN6Y.js";import{b as ne}from"./chunk-4F72YCTU.js";import{a as S}from"./chunk-Y572GMZE.js";import{a as ie}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import"./chunk-HV7G6DFP.js";import{b as A}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as E}from"./chunk-EBTLTGG3.js";import{f as ae,g as le}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as D,f as T,g as H,h as Q,l as F,p as oe}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as h,e as k,f as ke,g as re,h as se,j as w}from"./chunk-RRCPZMC2.js";var ve=k(re(),1);var c=k(ke(),1);var ue=k(re(),1);var W=k(se(),1);var Ae={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},fe=h(()=>{let t=(0,ue.c)(16),e=D(),a=le(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}default:s=a}let l=Ae[a],d;t[8]!==l?(d=w("size-2 rounded-full",l),t[8]=l,t[9]=d):d=t[9];let u;t[10]!==d?(u=(0,W.jsxDEV)("span",{"aria-hidden":"true",className:d},void 0,!1),t[10]=d,t[11]=u):u=t[11];let i;return t[12]!==a||t[13]!==u||t[14]!==s?(i=(0,W.jsxDEV)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[u,s]},void 0,!0),t[12]=a,t[13]=u,t[14]=s,t[15]=i):i=t[15],i},"ConnectionBadge");var r=k(se(),1);var me={completed:0,failed:2,in_progress:1},Re=h(t=>{let e=0,a=0,s=0,l=0,d=[];for(let{metrics:u}of t){if(u===null){l+=1;continue}s+=1,e+=u.requests,a+=u.errors,d.push(...u.history??[])}return{errors:a,failed:l,history:d,reachable:s,requests:e}},"sumShardMetrics"),Me=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"mergeFunctionStats"),_e=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let d=me[s.status]-me[l.status];(d>0||d===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"dedupeMigrations"),Ie=T(E.getAuthMetrics),Le=T(E.getFunctionStats),Ce=T(E.getLogs),Oe=T(E.getMetrics),qe=T(E.migrationStatus),De=5,he=2e3,Fe=5,pe=.01,ge=.05,je=.1,Ue=.3,Pe=1,Ge=50,X=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","rateLevel"),Ve=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","countLevel"),Be={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"ratePercent"),Ke=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"requestErrorSeries"),$e=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"migrationSummary"),ze=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"migrationTileValue"),xe={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},He={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Qe=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","worstLevel"),P=h(t=>{let e=(0,ve.c)(19),{chart:a,label:s,level:l,testId:d,value:u}=t,i=xe[l],n;e[0]!==i?(n=w("size-1.5 shrink-0 rounded-full",i),e[0]=i,e[1]=n):n=e[1];let p;e[2]!==n?(p=(0,r.jsxDEV)("span",{"aria-hidden":"true",className:n},void 0,!1),e[2]=n,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxDEV)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]},void 0,!0),e[4]=s,e[5]=p,e[6]=g):g=e[6];let b=Ne[l],m;e[7]!==b?(m=w("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=m):m=e[8];let f;e[9]!==m||e[10]!==d||e[11]!==u?(f=(0,r.jsxDEV)("span",{className:m,"data-testid":d,children:u},void 0,!1),e[9]=m,e[10]=d,e[11]=u,e[12]=f):f=e[12];let v;e[13]!==a||e[14]!==f?(v=(0,r.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[f,a]},void 0,!0),e[13]=a,e[14]=f,e[15]=v):v=e[15];let x;return e[16]!==g||e[17]!==v?(x=(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:(0,r.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,v]},void 0,!0)},void 0,!1),e[16]=g,e[17]=v,e[18]=x):x=e[18],x},"SloCard"),We=h(async(t,e,a)=>{let s=await Promise.all(a.map(m=>{let f=H(m);return Promise.allSettled([t.query(Oe,{},f),t.query(Le,{},f),t.query(qe,{},f)])})),l=H(e),d=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[u,i,n]=await Promise.allSettled([t.query(Ce,{},l),t.query(Ie,{},l),d]),p=s.map(([m,f,v])=>({functions:f.status==="fulfilled"?f.value.functions:[],metrics:m.status==="fulfilled"?m.value:null,migrations:v.status==="fulfilled"?v.value.migrations:[]})),g=Re(p),b=s[0]?.[0];return{auth:i.status==="fulfilled"?i.value:null,entries:u.status==="fulfilled"?u.value.entries:[],functions:Me(p.map(m=>m.functions)),logsError:u.status==="rejected"?Q(u.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?Q(b.reason):null,migrations:_e(p.map(m=>m.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:g}},"loadSloData"),ht=h(({initialShardKey:t})=>{let e=ae(),a=D(),[s,l]=(0,c.useState)([]),[d,u]=(0,c.useState)(null),[i,n]=(0,c.useState)(null),[p,g]=(0,c.useState)(null),[b,m]=(0,c.useState)([]),[f,v]=(0,c.useState)(null),[x,be]=(0,c.useState)(null),[we,Ee]=(0,c.useState)([]),[y]=(0,c.useState)(ie),R=(0,c.useRef)(!1),G=(0,c.useRef)(!0);(0,c.useEffect)(()=>(G.current=!0,()=>{G.current=!1}),[]);let M=t??"",_=(0,c.useCallback)(async()=>{if(R.current)return;R.current=!0;let o=await We(e,M,de(M,y));if(!G.current){R.current=!1;return}n(o.totals),g(o.metricsError),m(o.functions),Ee(o.migrations),l(o.entries),u(o.logsError),v(o.auth),be(o.scheduler),R.current=!1},[e,y,M]);(0,c.useEffect)(()=>{F(_())},[_]);let V=(0,c.useRef)(0),I=(0,c.useRef)(null),Se=h(()=>{let o=Date.now()-V.current;if(o>=he){V.current=Date.now(),F(_());return}I.current??=setTimeout(()=>{I.current=null,V.current=Date.now(),F(_())},he-o)},"scheduleFanOut");(0,c.useEffect)(()=>()=>{I.current!==null&&clearTimeout(I.current)},[]);let{data:J,liveError:Te}=ne(E.getMetrics,{},{live:!0,shardKey:M});(0,c.useEffect)(()=>{J!==void 0&&Se()},[J]);let B=s.filter(o=>o.level==="error"),K=B.slice(0,De),L=Ke(i?.history),Y=(0,c.useMemo)(()=>{let o=f?.history??[];return{attempts:o.map(N=>N.attempts),failures:o.map(N=>N.failures)}},[f?.history]),Z=b.filter(o=>o.calls>0).toSorted((o,N)=>N.errors/N.calls-o.errors/o.calls||N.calls-o.calls).slice(0,Fe),$=$e(we),ye=i===null||i.requests===0?0:i.errors/i.requests,z=X(ye,pe,ge),ee=f===null?"ok":X(f.failureRate,je,Ue),te=x===null?"ok":Ve(x.backlog,Pe,Ge),C=Qe([z,ee,te,$.level]),O,q;return C==="crit"?(O=a("Critical"),q=a("One or more service levels are breached.")):C==="warn"?(O=a("Degraded"),q=a("Some service levels need attention.")):(O=a("All systems healthy"),q=a("All service levels are within target.")),(0,r.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxDEV)("div",{className:"flex items-center gap-3",children:[(0,r.jsxDEV)("span",{"aria-hidden":"true",className:w("flex size-10 shrink-0 items-center justify-center rounded-full",He[C]),children:(0,r.jsxDEV)("span",{className:w("size-3 rounded-full",xe[C])},void 0,!1)},void 0,!1),(0,r.jsxDEV)("div",{className:"grid leading-tight",children:[(0,r.jsxDEV)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:O},void 0,!1),(0,r.jsxDEV)("span",{className:"text-[13px] text-muted-foreground",children:q},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxDEV)("div",{className:"text-end",children:[(0,r.jsxDEV)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")},void 0,!1),(0,r.jsxDEV)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsxDEV)(j,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"},void 0,!1),(0,r.jsxDEV)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(i?.requests??0).toString()},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"},void 0,!1),(0,r.jsxDEV)("div",{className:"text-end",children:[(0,r.jsxDEV)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")},void 0,!1),(0,r.jsxDEV)("div",{className:w("text-lg font-semibold tabular-nums",Ne[z]),"data-testid":"hl-error-rate",children:i===null?"\u2014":U(i.errors,i.requests)},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"},void 0,!1),(0,r.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,r.jsxDEV)(fe,{},void 0,!1),(0,r.jsxDEV)(ce,{message:Te,prefix:"hl"},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),p!==null&&(0,r.jsxDEV)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsxDEV)(P,{chart:L.errors.length>=2?(0,r.jsxDEV)(j,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"},void 0,!1):void 0,label:a("Error rate"),level:z,testId:"hl-slo-errorrate",value:i===null?"\u2014":U(i.errors,i.requests)},void 0,!1),(0,r.jsxDEV)(P,{chart:Y.failures.length>=2?(0,r.jsxDEV)(j,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:Y.failures,testId:"hl-spark-auth"},void 0,!1):void 0,label:a("Auth failures"),level:ee,testId:"hl-slo-auth",value:f===null?"\u2014":U(f.failures,f.attempts)},void 0,!1),(0,r.jsxDEV)(P,{label:a("Scheduler backlog"),level:te,testId:"hl-slo-backlog",value:x===null?"\u2014":x.backlog.toString()},void 0,!1),(0,r.jsxDEV)(P,{label:a("Migrations"),level:$.level,testId:"hl-slo-migrations",value:ze($,a)},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{className:"grid gap-3 lg:grid-cols-2",children:[(0,r.jsxDEV)(S,{className:"gap-0 py-0","data-testid":"hl-functions",children:[(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Functions by error rate")},void 0,!1)},void 0,!1),Z.length===0?(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:a("No function activity yet.")},void 0,!1):(0,r.jsxDEV)("ul",{className:"divide-y divide-border",children:Z.map(o=>(0,r.jsxDEV)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsxDEV)("span",{className:"truncate font-mono text-foreground",children:o.path},void 0,!1),(0,r.jsxDEV)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsxDEV)("span",{className:"tabular-nums text-muted-foreground",children:a("{count} calls",{count:o.calls.toString()})},void 0,!1),(0,r.jsxDEV)(A,{variant:Be[X(o.errors/o.calls,pe,ge)],children:U(o.errors,o.calls)},void 0,!1)]},void 0,!0)]},o.path,!0))},void 0,!1)]},void 0,!0),(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Recent errors")},void 0,!1),(0,r.jsxDEV)(A,{"data-testid":"hl-error-count",variant:B.length>0?"destructive":"outline",children:B.length},void 0,!1)]},void 0,!0),d!==null&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:d},void 0,!1),d===null&&K.length===0&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:a("No recent errors.")},void 0,!1),K.length>0&&(0,r.jsxDEV)("ul",{className:"divide-y divide-border",children:K.map((o,N)=>(0,r.jsxDEV)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxDEV)("span",{className:"flex items-center gap-2",children:[(0,r.jsxDEV)("time",{className:"shrink-0 text-muted-foreground",children:oe(o.timestamp)},void 0,!1),o.functionPath!==void 0&&(0,r.jsxDEV)("span",{className:"truncate font-mono text-foreground",children:o.functionPath},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("span",{className:"text-destructive",children:o.message},void 0,!1)]},`${o.timestamp.toString()}-${N.toString()}`,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")},void 0,!1),(0,r.jsxDEV)(A,{"data-testid":"hl-shard-count",variant:"outline",children:y.length},void 0,!1)]},void 0,!0),y.length>0&&(0,r.jsxDEV)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:y.map(o=>(0,r.jsxDEV)("li",{"data-testid":"hl-shard",children:(0,r.jsxDEV)(A,{variant:"secondary",children:o},void 0,!1)},o,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)},"HealthPanel");export{ht as HealthPanel};
|
|
1
|
+
import{b as de,e as j}from"./chunk-7YGTGBP7.js";import{a as ce}from"./chunk-FQUNSQLG.js";import"./chunk-SWMBBYJU.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import"./chunk-KEGAWN6Y.js";import{b as ne}from"./chunk-4F72YCTU.js";import{a as S}from"./chunk-Y572GMZE.js";import{a as ie}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import"./chunk-HV7G6DFP.js";import{b as A}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as E}from"./chunk-MHGJUKCZ.js";import{f as ae,g as le}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as D,f as T,g as H,h as Q,l as F,p as oe}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as h,e as k,f as ke,g as re,h as se,j as w}from"./chunk-RRCPZMC2.js";var ve=k(re(),1);var c=k(ke(),1);var ue=k(re(),1);var W=k(se(),1);var Ae={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},fe=h(()=>{let t=(0,ue.c)(16),e=D(),a=le(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}default:s=a}let l=Ae[a],d;t[8]!==l?(d=w("size-2 rounded-full",l),t[8]=l,t[9]=d):d=t[9];let u;t[10]!==d?(u=(0,W.jsxDEV)("span",{"aria-hidden":"true",className:d},void 0,!1),t[10]=d,t[11]=u):u=t[11];let i;return t[12]!==a||t[13]!==u||t[14]!==s?(i=(0,W.jsxDEV)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[u,s]},void 0,!0),t[12]=a,t[13]=u,t[14]=s,t[15]=i):i=t[15],i},"ConnectionBadge");var r=k(se(),1);var me={completed:0,failed:2,in_progress:1},Re=h(t=>{let e=0,a=0,s=0,l=0,d=[];for(let{metrics:u}of t){if(u===null){l+=1;continue}s+=1,e+=u.requests,a+=u.errors,d.push(...u.history??[])}return{errors:a,failed:l,history:d,reachable:s,requests:e}},"sumShardMetrics"),Me=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"mergeFunctionStats"),_e=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let d=me[s.status]-me[l.status];(d>0||d===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"dedupeMigrations"),Ie=T(E.getAuthMetrics),Le=T(E.getFunctionStats),Ce=T(E.getLogs),Oe=T(E.getMetrics),qe=T(E.migrationStatus),De=5,he=2e3,Fe=5,pe=.01,ge=.05,je=.1,Ue=.3,Pe=1,Ge=50,X=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","rateLevel"),Ve=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","countLevel"),Be={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"ratePercent"),Ke=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"requestErrorSeries"),$e=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"migrationSummary"),ze=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"migrationTileValue"),xe={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},He={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Qe=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","worstLevel"),P=h(t=>{let e=(0,ve.c)(19),{chart:a,label:s,level:l,testId:d,value:u}=t,i=xe[l],n;e[0]!==i?(n=w("size-1.5 shrink-0 rounded-full",i),e[0]=i,e[1]=n):n=e[1];let p;e[2]!==n?(p=(0,r.jsxDEV)("span",{"aria-hidden":"true",className:n},void 0,!1),e[2]=n,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxDEV)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]},void 0,!0),e[4]=s,e[5]=p,e[6]=g):g=e[6];let b=Ne[l],m;e[7]!==b?(m=w("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=m):m=e[8];let f;e[9]!==m||e[10]!==d||e[11]!==u?(f=(0,r.jsxDEV)("span",{className:m,"data-testid":d,children:u},void 0,!1),e[9]=m,e[10]=d,e[11]=u,e[12]=f):f=e[12];let v;e[13]!==a||e[14]!==f?(v=(0,r.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[f,a]},void 0,!0),e[13]=a,e[14]=f,e[15]=v):v=e[15];let x;return e[16]!==g||e[17]!==v?(x=(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:(0,r.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,v]},void 0,!0)},void 0,!1),e[16]=g,e[17]=v,e[18]=x):x=e[18],x},"SloCard"),We=h(async(t,e,a)=>{let s=await Promise.all(a.map(m=>{let f=H(m);return Promise.allSettled([t.query(Oe,{},f),t.query(Le,{},f),t.query(qe,{},f)])})),l=H(e),d=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[u,i,n]=await Promise.allSettled([t.query(Ce,{},l),t.query(Ie,{},l),d]),p=s.map(([m,f,v])=>({functions:f.status==="fulfilled"?f.value.functions:[],metrics:m.status==="fulfilled"?m.value:null,migrations:v.status==="fulfilled"?v.value.migrations:[]})),g=Re(p),b=s[0]?.[0];return{auth:i.status==="fulfilled"?i.value:null,entries:u.status==="fulfilled"?u.value.entries:[],functions:Me(p.map(m=>m.functions)),logsError:u.status==="rejected"?Q(u.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?Q(b.reason):null,migrations:_e(p.map(m=>m.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:g}},"loadSloData"),ht=h(({initialShardKey:t})=>{let e=ae(),a=D(),[s,l]=(0,c.useState)([]),[d,u]=(0,c.useState)(null),[i,n]=(0,c.useState)(null),[p,g]=(0,c.useState)(null),[b,m]=(0,c.useState)([]),[f,v]=(0,c.useState)(null),[x,be]=(0,c.useState)(null),[we,Ee]=(0,c.useState)([]),[y]=(0,c.useState)(ie),R=(0,c.useRef)(!1),G=(0,c.useRef)(!0);(0,c.useEffect)(()=>(G.current=!0,()=>{G.current=!1}),[]);let M=t??"",_=(0,c.useCallback)(async()=>{if(R.current)return;R.current=!0;let o=await We(e,M,de(M,y));if(!G.current){R.current=!1;return}n(o.totals),g(o.metricsError),m(o.functions),Ee(o.migrations),l(o.entries),u(o.logsError),v(o.auth),be(o.scheduler),R.current=!1},[e,y,M]);(0,c.useEffect)(()=>{F(_())},[_]);let V=(0,c.useRef)(0),I=(0,c.useRef)(null),Se=h(()=>{let o=Date.now()-V.current;if(o>=he){V.current=Date.now(),F(_());return}I.current??=setTimeout(()=>{I.current=null,V.current=Date.now(),F(_())},he-o)},"scheduleFanOut");(0,c.useEffect)(()=>()=>{I.current!==null&&clearTimeout(I.current)},[]);let{data:J,liveError:Te}=ne(E.getMetrics,{},{live:!0,shardKey:M});(0,c.useEffect)(()=>{J!==void 0&&Se()},[J]);let B=s.filter(o=>o.level==="error"),K=B.slice(0,De),L=Ke(i?.history),Y=(0,c.useMemo)(()=>{let o=f?.history??[];return{attempts:o.map(N=>N.attempts),failures:o.map(N=>N.failures)}},[f?.history]),Z=b.filter(o=>o.calls>0).toSorted((o,N)=>N.errors/N.calls-o.errors/o.calls||N.calls-o.calls).slice(0,Fe),$=$e(we),ye=i===null||i.requests===0?0:i.errors/i.requests,z=X(ye,pe,ge),ee=f===null?"ok":X(f.failureRate,je,Ue),te=x===null?"ok":Ve(x.backlog,Pe,Ge),C=Qe([z,ee,te,$.level]),O,q;return C==="crit"?(O=a("Critical"),q=a("One or more service levels are breached.")):C==="warn"?(O=a("Degraded"),q=a("Some service levels need attention.")):(O=a("All systems healthy"),q=a("All service levels are within target.")),(0,r.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxDEV)("div",{className:"flex items-center gap-3",children:[(0,r.jsxDEV)("span",{"aria-hidden":"true",className:w("flex size-10 shrink-0 items-center justify-center rounded-full",He[C]),children:(0,r.jsxDEV)("span",{className:w("size-3 rounded-full",xe[C])},void 0,!1)},void 0,!1),(0,r.jsxDEV)("div",{className:"grid leading-tight",children:[(0,r.jsxDEV)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:O},void 0,!1),(0,r.jsxDEV)("span",{className:"text-[13px] text-muted-foreground",children:q},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxDEV)("div",{className:"text-end",children:[(0,r.jsxDEV)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")},void 0,!1),(0,r.jsxDEV)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsxDEV)(j,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"},void 0,!1),(0,r.jsxDEV)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(i?.requests??0).toString()},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"},void 0,!1),(0,r.jsxDEV)("div",{className:"text-end",children:[(0,r.jsxDEV)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")},void 0,!1),(0,r.jsxDEV)("div",{className:w("text-lg font-semibold tabular-nums",Ne[z]),"data-testid":"hl-error-rate",children:i===null?"\u2014":U(i.errors,i.requests)},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"},void 0,!1),(0,r.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,r.jsxDEV)(fe,{},void 0,!1),(0,r.jsxDEV)(ce,{message:Te,prefix:"hl"},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),p!==null&&(0,r.jsxDEV)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsxDEV)(P,{chart:L.errors.length>=2?(0,r.jsxDEV)(j,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"},void 0,!1):void 0,label:a("Error rate"),level:z,testId:"hl-slo-errorrate",value:i===null?"\u2014":U(i.errors,i.requests)},void 0,!1),(0,r.jsxDEV)(P,{chart:Y.failures.length>=2?(0,r.jsxDEV)(j,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:Y.failures,testId:"hl-spark-auth"},void 0,!1):void 0,label:a("Auth failures"),level:ee,testId:"hl-slo-auth",value:f===null?"\u2014":U(f.failures,f.attempts)},void 0,!1),(0,r.jsxDEV)(P,{label:a("Scheduler backlog"),level:te,testId:"hl-slo-backlog",value:x===null?"\u2014":x.backlog.toString()},void 0,!1),(0,r.jsxDEV)(P,{label:a("Migrations"),level:$.level,testId:"hl-slo-migrations",value:ze($,a)},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{className:"grid gap-3 lg:grid-cols-2",children:[(0,r.jsxDEV)(S,{className:"gap-0 py-0","data-testid":"hl-functions",children:[(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Functions by error rate")},void 0,!1)},void 0,!1),Z.length===0?(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:a("No function activity yet.")},void 0,!1):(0,r.jsxDEV)("ul",{className:"divide-y divide-border",children:Z.map(o=>(0,r.jsxDEV)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsxDEV)("span",{className:"truncate font-mono text-foreground",children:o.path},void 0,!1),(0,r.jsxDEV)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsxDEV)("span",{className:"tabular-nums text-muted-foreground",children:a("{count} calls",{count:o.calls.toString()})},void 0,!1),(0,r.jsxDEV)(A,{variant:Be[X(o.errors/o.calls,pe,ge)],children:U(o.errors,o.calls)},void 0,!1)]},void 0,!0)]},o.path,!0))},void 0,!1)]},void 0,!0),(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Recent errors")},void 0,!1),(0,r.jsxDEV)(A,{"data-testid":"hl-error-count",variant:B.length>0?"destructive":"outline",children:B.length},void 0,!1)]},void 0,!0),d!==null&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:d},void 0,!1),d===null&&K.length===0&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:a("No recent errors.")},void 0,!1),K.length>0&&(0,r.jsxDEV)("ul",{className:"divide-y divide-border",children:K.map((o,N)=>(0,r.jsxDEV)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxDEV)("span",{className:"flex items-center gap-2",children:[(0,r.jsxDEV)("time",{className:"shrink-0 text-muted-foreground",children:oe(o.timestamp)},void 0,!1),o.functionPath!==void 0&&(0,r.jsxDEV)("span",{className:"truncate font-mono text-foreground",children:o.functionPath},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("span",{className:"text-destructive",children:o.message},void 0,!1)]},`${o.timestamp.toString()}-${N.toString()}`,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")},void 0,!1),(0,r.jsxDEV)(A,{"data-testid":"hl-shard-count",variant:"outline",children:y.length},void 0,!1)]},void 0,!0),y.length>0&&(0,r.jsxDEV)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:y.map(o=>(0,r.jsxDEV)("li",{"data-testid":"hl-shard",children:(0,r.jsxDEV)(A,{variant:"secondary",children:o},void 0,!1)},o,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)},"HealthPanel");export{ht as HealthPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as S}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as T}from"./chunk-4F72YCTU.js";import{a as w,b as A,c as E,d as m,e as s,f as l}from"./chunk-GTM65MVX.js";import{a as N,e as b}from"./chunk-Y572GMZE.js";import{a as O}from"./chunk-VLXV72QE.js";import{a as k}from"./chunk-JSEXCW5Q.js";import{b as y}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as C}from"./chunk-
|
|
1
|
+
import{a as S}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as T}from"./chunk-4F72YCTU.js";import{a as w,b as A,c as E,d as m,e as s,f as l}from"./chunk-GTM65MVX.js";import{a as N,e as b}from"./chunk-Y572GMZE.js";import{a as O}from"./chunk-VLXV72QE.js";import{a as k}from"./chunk-JSEXCW5Q.js";import{b as y}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as C}from"./chunk-MHGJUKCZ.js";import"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as u}from"./chunk-TAD43CG5.js";import{d as h}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as d,e as p,f as D,h as H}from"./chunk-RRCPZMC2.js";var n=p(D(),1);var e=p(H(),1);var K=d(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"parseContext"),R='{ "targetingKey": "user-123", "plan": "premium" }',M=d(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"formatValue"),Y=d(({initialShardKey:a=""})=>{let t=h(),[o,F]=(0,n.useState)(""),{context:f,error:g}=K(o),I=(0,n.useMemo)(()=>f===void 0?{}:{context:f},[f]),{data:i,error:J,errorSource:L,liveError:j}=T(C.listFlags,I,{live:!0,shardKey:a}),v=i!==void 0,V=i?.configured??!1,x=(0,n.useMemo)(()=>Array.isArray(i?.flags)?[...i.flags].toSorted((r,B)=>r.key.localeCompare(B.key)):[],[i]),c;return v&&!V?c=(0,e.jsxDEV)(u,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")},void 0,!1):v&&x.length===0?c=(0,e.jsxDEV)(u,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")},void 0,!1):c=(0,e.jsxDEV)(N,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(b,{className:"px-0",children:(0,e.jsxDEV)(w,{"data-testid":"flags-table",children:[(0,e.jsxDEV)(A,{children:(0,e.jsxDEV)(m,{children:[(0,e.jsxDEV)(s,{children:t("Key")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Type")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Value")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Reason")},void 0,!1),(0,e.jsxDEV)(s,{children:t("Variant")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(E,{children:x.map(r=>(0,e.jsxDEV)(m,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsxDEV)(l,{className:"font-mono text-xs",children:r.key},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs text-muted-foreground",children:r.type},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs",children:M(r)},void 0,!1),(0,e.jsxDEV)(l,{children:r.errorCode===void 0?(0,e.jsxDEV)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"},void 0,!1):(0,e.jsxDEV)(y,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode},void 0,!1)},void 0,!1),(0,e.jsxDEV)(l,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"},void 0,!1)]},r.key,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsxDEV)(S,{error:L,testId:"flags-error"},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,e.jsxDEV)(k,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")},void 0,!1),(0,e.jsxDEV)(O,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:d(r=>{F(r.target.value)},"onChange"),placeholder:R,rows:3,value:o},void 0,!1),g!==null&&(0,e.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(g)},void 0,!1),j!==void 0&&(0,e.jsxDEV)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")},void 0,!1)]},void 0,!0),c]},void 0,!0)},"FlagsPanel");export{Y as FlagsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as le}from"./chunk-FQUNSQLG.js";import{a as te}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as U}from"./chunk-4F72YCTU.js";import{a as ae,b as se,c as oe,d as Q,e as $,f as z}from"./chunk-GTM65MVX.js";import{a as j,b as K,c as V,d as Y,e as q}from"./chunk-Y572GMZE.js";import{a as re}from"./chunk-VLXV72QE.js";import{a as C}from"./chunk-JSEXCW5Q.js";import{a as ee}from"./chunk-FDWXYXOM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as E}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as k}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as I}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as L}from"./chunk-EBTLTGG3.js";import{f as W}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as J}from"./chunk-TAD43CG5.js";import{d as O,f as G,g as X,h as Z,l as D}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as n,e as B,f as ve,g as he,h as xe}from"./chunk-RRCPZMC2.js";var c=B(ve(),1);var ne=B(he(),1);var e=B(xe(),1);var ie=["read","insert","update","delete"],ye=n((a,t)=>({delete:a("Delete"),insert:a("Insert"),read:a("Read"),update:a("Update")})[t],"operationLabel"),ge=n(a=>{let t=new Set;for(let l of a?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:r}=l.metadata;typeof r=="string"&&r!==""&&t.add(r)}return t},"uncoveredTables"),be=n((a,t,l)=>{let r=new Map,s=n(o=>{let d=r.get(o);if(d!==void 0)return d;let i={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:[],table:o,uncovered:l.has(o)};return r.set(o,i),i},"ensure");for(let o of a)s(o.table).cells[o.on]={procedure:o.procedure};for(let o of t){let d=s(o.table);d.maskedColumns.includes(o.column)||d.maskedColumns.push(o.column)}for(let o of l)s(o);return[...r.values()].toSorted((o,d)=>o.table.localeCompare(d.table))},"buildRows"),Ne=n(a=>{let t=(0,ne.c)(17),l;t[0]!==a?(l=a===void 0?{}:a,t[0]=a,t[1]=l):l=t[1];let{onProbe:r}=l,s=O(),o,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={},d={live:!0},t[2]=o,t[3]=d):(o=t[2],d=t[3]);let i=U(L.rlsPolicies,o,d),x;t[4]===Symbol.for("react.memo_cache_sentinel")?(x={},t[4]=x):x=t[4];let p=U(L.maskPolicies,x),v;t[5]===Symbol.for("react.memo_cache_sentinel")?(v={},t[5]=v):v=t[5];let b=U(L.getAdvisories,v),N;if(t[6]!==b.data||t[7]!==p.data||t[8]!==r||t[9]!==i||t[10]!==s){let g=null;i.data!==void 0&&(g=Array.isArray(i.data.policies)?i.data.policies:[]);let _=Array.isArray(p.data?.columns)?p.data.columns:[],F=b.data??null,{error:h,errorSource:m,liveError:P}=i,A=g===null?[]:be(g,_,ge(F)),T;t[12]!==P?(T=(0,e.jsxDEV)("div",{className:"flex items-center justify-end",children:(0,e.jsxDEV)(le,{message:P,prefix:"pm"},void 0,!1)},void 0,!1),t[12]=P,t[13]=T):T=t[13];let y;t[14]!==h||t[15]!==m?(y=h!==null&&(0,e.jsxDEV)(te,{error:m,testId:"pm-error"},void 0,!1),t[14]=h,t[15]=m,t[16]=y):y=t[16],N=(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[T,y,g!==null&&A.length===0?(0,e.jsxDEV)(J,{description:s("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:s("No policy")},void 0,!1):(0,e.jsxDEV)(ae,{"data-testid":"pm-table",children:[(0,e.jsxDEV)(se,{children:(0,e.jsxDEV)(Q,{children:[(0,e.jsxDEV)($,{children:s("Table")},void 0,!1),ie.map(u=>(0,e.jsxDEV)($,{children:ye(s,u)},u,!1)),(0,e.jsxDEV)($,{children:s("Masked columns")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(oe,{children:A.map(u=>(0,e.jsxDEV)(Q,{"data-testid":`pm-row-${u.table}`,children:[(0,e.jsxDEV)(z,{className:"font-mono text-xs",children:(0,e.jsxDEV)("span",{className:"flex items-center gap-1.5",children:[u.table,u.uncovered&&(0,e.jsxDEV)(I,{"data-testid":`pm-uncovered-${u.table}`,title:s("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:s("Uncovered \u2014 reachable without a policy")},void 0,!1)]},void 0,!0)},void 0,!1),ie.map(w=>{let R=u.cells[w];return(0,e.jsxDEV)(z,{"data-testid":`pm-cell-${u.table}-${w}`,children:R.procedure===void 0?(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:s("No policy")},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Covered by {procedure}",{procedure:R.procedure})},void 0,!1),r!==void 0&&(0,e.jsxDEV)(k,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${u.table}-${w}`,onClick:n(()=>{r(u.table,w,R.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Probe this")},void 0,!1)]},void 0,!0)},w,!1)}),(0,e.jsxDEV)(z,{children:u.maskedColumns.length===0?(0,e.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:u.maskedColumns.map(ke)},void 0,!1)},void 0,!1)]},u.table,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),t[6]=b.data,t[7]=p.data,t[8]=r,t[9]=i,t[10]=s,t[11]=N}else N=t[11];return N},"PermissionsMatrix");function ke(a){return(0,e.jsxDEV)(I,{variant:"outline",children:a},a,!1)}n(ke,"_temp");var Ce=G(L.runAs),we=n(()=>{let a=W();return async({args:t,functionPath:l,shardKey:r="",userId:s})=>{let o=Ce;try{return{kind:"allowed",value:await a.query(o,{args:t,functionPath:l,userId:s},X(r))}}catch(d){return{kind:"denied",message:d instanceof Error?d.message:String(d)}}}},"useRunAsProbe"),Se=n(a=>a===void 0?"undefined":JSON.stringify(a,null,2),"formatValue"),Pe=n(({functions:a,prefill:t,runAsIdentity:l=!1}={})=>{let r=W(),s=O(),o=we(),[d,i]=(0,c.useState)(null),[x,p]=(0,c.useState)(null),v=a??d??[],[b,N]=(0,c.useState)(""),[g,_]=(0,c.useState)("{}"),[F,h]=(0,c.useState)(""),[m,P]=(0,c.useState)(""),[A,T]=(0,c.useState)(!1),[y,u]=(0,c.useState)(null),[w,R]=(0,c.useState)(null),H=(0,c.useRef)(-1);(0,c.useEffect)(()=>{if(a!==void 0)return;let f=!1;return r.listFunctions().then(S=>(f||i(S),S)).catch(S=>{f||p(Z(S))}),()=>{f=!0}},[r,a]),(0,c.useEffect)(()=>{if(t===void 0||H.current===t.nonce)return;H.current=t.nonce;let f=t.functionPath;queueMicrotask(()=>{N(f),u(null)})},[t]);let M=b===""?v[0]?.path??"":b,ce=n(async()=>{if(M==="")return;let f;try{f=g.trim()===""?{}:JSON.parse(g)}catch(S){R(s("Invalid JSON args: {message}",{message:S.message})),u(null);return}R(null),T(!0);try{let S=await o({args:f,functionPath:M,shardKey:F.trim(),userId:m.trim()});u(S)}finally{T(!1)}},"run"),fe=n(()=>{D(ce())},"runOnce"),ue=n(f=>{N(f.target.value)},"onSelectChange"),me=n(f=>{_(f.target.value)},"onArgsChange"),pe=n(f=>{P(f.target.value)},"onUserIdChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[x!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:x},void 0,!1),!l&&(0,e.jsxDEV)(J,{description:s("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:s("Set `runAsIdentity` to forge an identity and probe access.")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-function",children:s("Function")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":s("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:ue,value:M,children:v.map(f=>(0,e.jsxDEV)("option",{value:f.path,children:[f.path," (",f.kind,")"]},f.path,!0))},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-args",children:s("Arguments")},void 0,!1),(0,e.jsxDEV)(re,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:me,value:g},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(ee,{onChange:h,testId:"pp-shard",value:F},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-user",children:s("Run as (userId)")},void 0,!1),(0,e.jsxDEV)(E,{"aria-label":s("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:pe,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"pp-run",disabled:!l||A||M==="",onClick:fe,type:"button",children:s(A?"Probing\u2026":"Run probe")},void 0,!1),m.trim()!==""&&(0,e.jsxDEV)(I,{"data-testid":"pp-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),w!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:w},void 0,!1),y!==null&&y.kind==="allowed"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Allowed")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Se(y.value)},void 0,!1)]},void 0,!0),y!==null&&y.kind==="denied"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,e.jsxDEV)(I,{variant:"destructive",children:s("Denied")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:y.message},void 0,!1)]},void 0,!0)]},void 0,!0)},"PermissionsPlayground"),Ae="/__lunora/policy-scaffold",Te={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ie=n(async a=>{let t=await fetch(Ae,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}),l=await t.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(t.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let r=l.error;return{kind:"error",message:r===void 0?`policy scaffold failed (${String(t.status)})`:Te[r]??r}},"applyPolicyScaffold"),de={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ee=n(()=>{let a=O(),[t,l]=(0,c.useState)(null),[r,s]=(0,c.useState)(!1),[o,d]=(0,c.useState)(null),[i,x]=(0,c.useState)(de),p=n(h=>{let m=h.target.name,{value:P}=h.target;x(A=>({...A,[m]:P}))},"onFieldChange"),v=n(()=>{l(null),x(de)},"reset"),b=n(async h=>{s(!0),d(null);try{let m=await Ie(h);d(m),m.kind==="ok"&&v()}catch(m){d({kind:"error",message:m instanceof Error?m.message:String(m)})}finally{s(!1)}},"submit"),N=n(()=>{D(b({kind:"scaffoldPolicy",name:i.policyName.trim(),table:i.tableName.trim()}))},"onSubmitScaffold"),g=n(()=>{D(b({exportName:i.exportName.trim(),filePath:i.filePath.trim(),kind:"wireRls",policies:i.policies.trim()}))},"onSubmitWire"),_=n(()=>{d(null),l("scaffold")},"openScaffold"),F=n(()=>{d(null),l("wire")},"openWire");return(0,e.jsxDEV)(j,{"data-testid":"policy-scaffolder",size:"sm",children:[(0,e.jsxDEV)(K,{children:[(0,e.jsxDEV)(V,{children:a("Scaffold access rules")},void 0,!1),(0,e.jsxDEV)(Y,{children:a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(q,{children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-new",onClick:_,size:"xs",type:"button",variant:t==="scaffold"?"default":"outline",children:a("New policy file")},void 0,!1),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-wire",onClick:F,size:"xs",type:"button",variant:t==="wire"?"default":"outline",children:a("Wire into a procedure")},void 0,!1)]},void 0,!0),t==="scaffold"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-name",children:a("Policy name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:p,value:i.policyName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-table",children:a("Table name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:p,value:i.tableName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-create",disabled:r||i.policyName.trim()===""||i.tableName.trim()==="",onClick:N,size:"xs",type:"button",children:a(r?"Creating\u2026":"Create policy file")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),t==="wire"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:p,value:i.filePath},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:p,value:i.exportName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:p,value:i.policies},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-apply",disabled:r||i.filePath.trim()===""||i.exportName.trim()===""||i.policies.trim()==="",onClick:g,size:"xs",type:"button",children:a(r?"Wiring\u2026":"Wire RLS")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),o?.kind==="error"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message},void 0,!1),o?.kind==="needs-manual-edit"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")},void 0,!1),o?.kind==="ok"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,e.jsxDEV)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})},void 0,!1),o.diagnostics.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(h=>(0,e.jsxDEV)("li",{className:"font-mono text-[11px] text-destructive",children:h},h,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"PolicyScaffolder"),He=n(({functions:a,runAsIdentity:t=!1,schemaEditable:l=!1}={})=>{let r=O(),[s,o]=(0,c.useState)(void 0),d=n((i,x,p)=>{p!==""&&o(v=>({functionPath:p,nonce:(v?.nonce??0)+1}))},"onProbe");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Permissions")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(Ne,{onProbe:d},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:(0,e.jsxDEV)(j,{className:"gap-0 py-0",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Probe")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(q,{className:"px-4 py-4",children:[(0,e.jsxDEV)("p",{className:"mb-3 text-sm text-muted-foreground",children:r("Pick a function and an identity, then run it to see the access outcome.")},void 0,!1),(0,e.jsxDEV)(Pe,{functions:a,prefill:s,runAsIdentity:t},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1),l&&(0,e.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,e.jsxDEV)(Ee,{},void 0,!1)},void 0,!1)]},void 0,!0)},"PermissionsPanel");export{He as PermissionsPanel};
|
|
1
|
+
import{a as le}from"./chunk-FQUNSQLG.js";import{a as te}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as U}from"./chunk-4F72YCTU.js";import{a as ae,b as se,c as oe,d as Q,e as $,f as z}from"./chunk-GTM65MVX.js";import{a as j,b as K,c as V,d as Y,e as q}from"./chunk-Y572GMZE.js";import{a as re}from"./chunk-VLXV72QE.js";import{a as C}from"./chunk-JSEXCW5Q.js";import{a as ee}from"./chunk-FDWXYXOM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as E}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as k}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as I}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as L}from"./chunk-MHGJUKCZ.js";import{f as W}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as J}from"./chunk-TAD43CG5.js";import{d as O,f as G,g as X,h as Z,l as D}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as n,e as B,f as ve,g as he,h as xe}from"./chunk-RRCPZMC2.js";var c=B(ve(),1);var ne=B(he(),1);var e=B(xe(),1);var ie=["read","insert","update","delete"],ye=n((a,t)=>({delete:a("Delete"),insert:a("Insert"),read:a("Read"),update:a("Update")})[t],"operationLabel"),ge=n(a=>{let t=new Set;for(let l of a?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:r}=l.metadata;typeof r=="string"&&r!==""&&t.add(r)}return t},"uncoveredTables"),be=n((a,t,l)=>{let r=new Map,s=n(o=>{let d=r.get(o);if(d!==void 0)return d;let i={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:[],table:o,uncovered:l.has(o)};return r.set(o,i),i},"ensure");for(let o of a)s(o.table).cells[o.on]={procedure:o.procedure};for(let o of t){let d=s(o.table);d.maskedColumns.includes(o.column)||d.maskedColumns.push(o.column)}for(let o of l)s(o);return[...r.values()].toSorted((o,d)=>o.table.localeCompare(d.table))},"buildRows"),Ne=n(a=>{let t=(0,ne.c)(17),l;t[0]!==a?(l=a===void 0?{}:a,t[0]=a,t[1]=l):l=t[1];let{onProbe:r}=l,s=O(),o,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={},d={live:!0},t[2]=o,t[3]=d):(o=t[2],d=t[3]);let i=U(L.rlsPolicies,o,d),x;t[4]===Symbol.for("react.memo_cache_sentinel")?(x={},t[4]=x):x=t[4];let p=U(L.maskPolicies,x),v;t[5]===Symbol.for("react.memo_cache_sentinel")?(v={},t[5]=v):v=t[5];let b=U(L.getAdvisories,v),N;if(t[6]!==b.data||t[7]!==p.data||t[8]!==r||t[9]!==i||t[10]!==s){let g=null;i.data!==void 0&&(g=Array.isArray(i.data.policies)?i.data.policies:[]);let _=Array.isArray(p.data?.columns)?p.data.columns:[],F=b.data??null,{error:h,errorSource:m,liveError:P}=i,A=g===null?[]:be(g,_,ge(F)),T;t[12]!==P?(T=(0,e.jsxDEV)("div",{className:"flex items-center justify-end",children:(0,e.jsxDEV)(le,{message:P,prefix:"pm"},void 0,!1)},void 0,!1),t[12]=P,t[13]=T):T=t[13];let y;t[14]!==h||t[15]!==m?(y=h!==null&&(0,e.jsxDEV)(te,{error:m,testId:"pm-error"},void 0,!1),t[14]=h,t[15]=m,t[16]=y):y=t[16],N=(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[T,y,g!==null&&A.length===0?(0,e.jsxDEV)(J,{description:s("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:s("No policy")},void 0,!1):(0,e.jsxDEV)(ae,{"data-testid":"pm-table",children:[(0,e.jsxDEV)(se,{children:(0,e.jsxDEV)(Q,{children:[(0,e.jsxDEV)($,{children:s("Table")},void 0,!1),ie.map(u=>(0,e.jsxDEV)($,{children:ye(s,u)},u,!1)),(0,e.jsxDEV)($,{children:s("Masked columns")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(oe,{children:A.map(u=>(0,e.jsxDEV)(Q,{"data-testid":`pm-row-${u.table}`,children:[(0,e.jsxDEV)(z,{className:"font-mono text-xs",children:(0,e.jsxDEV)("span",{className:"flex items-center gap-1.5",children:[u.table,u.uncovered&&(0,e.jsxDEV)(I,{"data-testid":`pm-uncovered-${u.table}`,title:s("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:s("Uncovered \u2014 reachable without a policy")},void 0,!1)]},void 0,!0)},void 0,!1),ie.map(w=>{let R=u.cells[w];return(0,e.jsxDEV)(z,{"data-testid":`pm-cell-${u.table}-${w}`,children:R.procedure===void 0?(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:s("No policy")},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Covered by {procedure}",{procedure:R.procedure})},void 0,!1),r!==void 0&&(0,e.jsxDEV)(k,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${u.table}-${w}`,onClick:n(()=>{r(u.table,w,R.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Probe this")},void 0,!1)]},void 0,!0)},w,!1)}),(0,e.jsxDEV)(z,{children:u.maskedColumns.length===0?(0,e.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:u.maskedColumns.map(ke)},void 0,!1)},void 0,!1)]},u.table,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),t[6]=b.data,t[7]=p.data,t[8]=r,t[9]=i,t[10]=s,t[11]=N}else N=t[11];return N},"PermissionsMatrix");function ke(a){return(0,e.jsxDEV)(I,{variant:"outline",children:a},a,!1)}n(ke,"_temp");var Ce=G(L.runAs),we=n(()=>{let a=W();return async({args:t,functionPath:l,shardKey:r="",userId:s})=>{let o=Ce;try{return{kind:"allowed",value:await a.query(o,{args:t,functionPath:l,userId:s},X(r))}}catch(d){return{kind:"denied",message:d instanceof Error?d.message:String(d)}}}},"useRunAsProbe"),Se=n(a=>a===void 0?"undefined":JSON.stringify(a,null,2),"formatValue"),Pe=n(({functions:a,prefill:t,runAsIdentity:l=!1}={})=>{let r=W(),s=O(),o=we(),[d,i]=(0,c.useState)(null),[x,p]=(0,c.useState)(null),v=a??d??[],[b,N]=(0,c.useState)(""),[g,_]=(0,c.useState)("{}"),[F,h]=(0,c.useState)(""),[m,P]=(0,c.useState)(""),[A,T]=(0,c.useState)(!1),[y,u]=(0,c.useState)(null),[w,R]=(0,c.useState)(null),H=(0,c.useRef)(-1);(0,c.useEffect)(()=>{if(a!==void 0)return;let f=!1;return r.listFunctions().then(S=>(f||i(S),S)).catch(S=>{f||p(Z(S))}),()=>{f=!0}},[r,a]),(0,c.useEffect)(()=>{if(t===void 0||H.current===t.nonce)return;H.current=t.nonce;let f=t.functionPath;queueMicrotask(()=>{N(f),u(null)})},[t]);let M=b===""?v[0]?.path??"":b,ce=n(async()=>{if(M==="")return;let f;try{f=g.trim()===""?{}:JSON.parse(g)}catch(S){R(s("Invalid JSON args: {message}",{message:S.message})),u(null);return}R(null),T(!0);try{let S=await o({args:f,functionPath:M,shardKey:F.trim(),userId:m.trim()});u(S)}finally{T(!1)}},"run"),fe=n(()=>{D(ce())},"runOnce"),ue=n(f=>{N(f.target.value)},"onSelectChange"),me=n(f=>{_(f.target.value)},"onArgsChange"),pe=n(f=>{P(f.target.value)},"onUserIdChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[x!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:x},void 0,!1),!l&&(0,e.jsxDEV)(J,{description:s("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:s("Set `runAsIdentity` to forge an identity and probe access.")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-function",children:s("Function")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":s("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:ue,value:M,children:v.map(f=>(0,e.jsxDEV)("option",{value:f.path,children:[f.path," (",f.kind,")"]},f.path,!0))},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-args",children:s("Arguments")},void 0,!1),(0,e.jsxDEV)(re,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:me,value:g},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(ee,{onChange:h,testId:"pp-shard",value:F},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-user",children:s("Run as (userId)")},void 0,!1),(0,e.jsxDEV)(E,{"aria-label":s("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:pe,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"pp-run",disabled:!l||A||M==="",onClick:fe,type:"button",children:s(A?"Probing\u2026":"Run probe")},void 0,!1),m.trim()!==""&&(0,e.jsxDEV)(I,{"data-testid":"pp-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),w!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:w},void 0,!1),y!==null&&y.kind==="allowed"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Allowed")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Se(y.value)},void 0,!1)]},void 0,!0),y!==null&&y.kind==="denied"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,e.jsxDEV)(I,{variant:"destructive",children:s("Denied")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:y.message},void 0,!1)]},void 0,!0)]},void 0,!0)},"PermissionsPlayground"),Ae="/__lunora/policy-scaffold",Te={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ie=n(async a=>{let t=await fetch(Ae,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}),l=await t.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(t.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let r=l.error;return{kind:"error",message:r===void 0?`policy scaffold failed (${String(t.status)})`:Te[r]??r}},"applyPolicyScaffold"),de={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ee=n(()=>{let a=O(),[t,l]=(0,c.useState)(null),[r,s]=(0,c.useState)(!1),[o,d]=(0,c.useState)(null),[i,x]=(0,c.useState)(de),p=n(h=>{let m=h.target.name,{value:P}=h.target;x(A=>({...A,[m]:P}))},"onFieldChange"),v=n(()=>{l(null),x(de)},"reset"),b=n(async h=>{s(!0),d(null);try{let m=await Ie(h);d(m),m.kind==="ok"&&v()}catch(m){d({kind:"error",message:m instanceof Error?m.message:String(m)})}finally{s(!1)}},"submit"),N=n(()=>{D(b({kind:"scaffoldPolicy",name:i.policyName.trim(),table:i.tableName.trim()}))},"onSubmitScaffold"),g=n(()=>{D(b({exportName:i.exportName.trim(),filePath:i.filePath.trim(),kind:"wireRls",policies:i.policies.trim()}))},"onSubmitWire"),_=n(()=>{d(null),l("scaffold")},"openScaffold"),F=n(()=>{d(null),l("wire")},"openWire");return(0,e.jsxDEV)(j,{"data-testid":"policy-scaffolder",size:"sm",children:[(0,e.jsxDEV)(K,{children:[(0,e.jsxDEV)(V,{children:a("Scaffold access rules")},void 0,!1),(0,e.jsxDEV)(Y,{children:a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(q,{children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-new",onClick:_,size:"xs",type:"button",variant:t==="scaffold"?"default":"outline",children:a("New policy file")},void 0,!1),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-wire",onClick:F,size:"xs",type:"button",variant:t==="wire"?"default":"outline",children:a("Wire into a procedure")},void 0,!1)]},void 0,!0),t==="scaffold"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-name",children:a("Policy name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:p,value:i.policyName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-table",children:a("Table name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:p,value:i.tableName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-create",disabled:r||i.policyName.trim()===""||i.tableName.trim()==="",onClick:N,size:"xs",type:"button",children:a(r?"Creating\u2026":"Create policy file")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),t==="wire"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:p,value:i.filePath},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:p,value:i.exportName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:p,value:i.policies},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-apply",disabled:r||i.filePath.trim()===""||i.exportName.trim()===""||i.policies.trim()==="",onClick:g,size:"xs",type:"button",children:a(r?"Wiring\u2026":"Wire RLS")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),o?.kind==="error"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message},void 0,!1),o?.kind==="needs-manual-edit"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")},void 0,!1),o?.kind==="ok"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,e.jsxDEV)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})},void 0,!1),o.diagnostics.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(h=>(0,e.jsxDEV)("li",{className:"font-mono text-[11px] text-destructive",children:h},h,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"PolicyScaffolder"),He=n(({functions:a,runAsIdentity:t=!1,schemaEditable:l=!1}={})=>{let r=O(),[s,o]=(0,c.useState)(void 0),d=n((i,x,p)=>{p!==""&&o(v=>({functionPath:p,nonce:(v?.nonce??0)+1}))},"onProbe");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Permissions")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(Ne,{onProbe:d},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:(0,e.jsxDEV)(j,{className:"gap-0 py-0",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Probe")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(q,{className:"px-4 py-4",children:[(0,e.jsxDEV)("p",{className:"mb-3 text-sm text-muted-foreground",children:r("Pick a function and an identity, then run it to see the access outcome.")},void 0,!1),(0,e.jsxDEV)(Pe,{functions:a,prefill:s,runAsIdentity:t},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1),l&&(0,e.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,e.jsxDEV)(Ee,{},void 0,!1)},void 0,!1)]},void 0,!0)},"PermissionsPanel");export{He as PermissionsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as $}from"./chunk-IYHPYY4A.js";import{a as M}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as H}from"./chunk-4F72YCTU.js";import{a as P,b as Q,c as W,d as V,e as C,f as E}from"./chunk-GTM65MVX.js";import{a as K,e as O}from"./chunk-Y572GMZE.js";import{b as F}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as j}from"./chunk-
|
|
1
|
+
import{b as $}from"./chunk-IYHPYY4A.js";import{a as M}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as H}from"./chunk-4F72YCTU.js";import{a as P,b as Q,c as W,d as V,e as C,f as E}from"./chunk-GTM65MVX.js";import{a as K,e as O}from"./chunk-Y572GMZE.js";import{b as F}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as j}from"./chunk-MHGJUKCZ.js";import"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as B}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as U,e as L,f as G,g as J,h as X}from"./chunk-RRCPZMC2.js";var q=L(J(),1),te=L(G(),1);var r=L(X(),1);var Y={binding:"outline",secret:"destructive",var:"secondary"},me=U(i=>{let e=(0,q.c)(68),{initialShardKey:z}=i,t=B(),N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N={},e[0]=N):N=e[0];let R=z??"",T;e[1]!==R?(T={shardKey:R},e[1]=R,e[2]=T):T=e[2];let{data:k,error:d,errorSource:S,isLoading:A}=H(j.getSettings,N,T),D;e:{let s=k?.deploy;if(s===void 0){let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[3]=l):l=e[3],D=l;break e}let o;if(e[4]!==s.deploymentId||e[5]!==s.environment||e[6]!==s.versionTag||e[7]!==s.workerUrl||e[8]!==t){if(o=[],s.workerUrl!==void 0){let l;e[10]!==t?(l=t("URL"),e[10]=t,e[11]=l):l=e[11];let a;e[12]!==s.workerUrl||e[13]!==l?(a={label:l,value:s.workerUrl},e[12]=s.workerUrl,e[13]=l,e[14]=a):a=e[14],o.push(a)}if(s.environment!==void 0){let l;e[15]!==t?(l=t("Environment"),e[15]=t,e[16]=l):l=e[16];let a;e[17]!==s.environment||e[18]!==l?(a={label:l,value:s.environment},e[17]=s.environment,e[18]=l,e[19]=a):a=e[19],o.push(a)}if(s.deploymentId!==void 0){let l;e[20]!==t?(l=t("Deployment"),e[20]=t,e[21]=l):l=e[21];let a;e[22]!==s.deploymentId||e[23]!==l?(a={label:l,value:s.deploymentId},e[22]=s.deploymentId,e[23]=l,e[24]=a):a=e[24],o.push(a)}if(s.versionTag!==void 0){let l;e[25]!==t?(l=t("Version"),e[25]=t,e[26]=l):l=e[26];let a;e[27]!==s.versionTag||e[28]!==l?(a={label:l,value:s.versionTag},e[27]=s.versionTag,e[28]=l,e[29]=a):a=e[29],o.push(a)}e[4]=s.deploymentId,e[5]=s.environment,e[6]=s.versionTag,e[7]=s.workerUrl,e[8]=t,e[9]=o}else o=e[9];D=o}let w=D,_;e[30]!==k?.settings?(_=k?.settings??[],e[30]=k?.settings,e[31]=_):_=e[31];let n=_,m;e[32]!==t?(m=t("Open in Cloudflare"),e[32]=t,e[33]=m):m=e[33];let f;e[34]!==m?(f=(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-3",children:(0,r.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:$,rel:"noreferrer",target:"_blank",children:m},void 0,!1)},void 0,!1),e[34]=m,e[35]=f):f=e[35];let c;e[36]!==t?(c=t("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[36]=t,e[37]=c):c=e[37];let v;e[38]!==c?(v=(0,r.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:c},void 0,!1),e[38]=c,e[39]=v):v=e[39];let p;e[40]!==d||e[41]!==S?(p=d!==null&&(0,r.jsxDEV)(M,{error:S,testId:"set-error"},void 0,!1),e[40]=d,e[41]=S,e[42]=p):p=e[42];let u;e[43]!==w||e[44]!==t?(u=w.length>0&&(0,r.jsxDEV)(K,{className:"py-0","data-testid":"set-deploy",children:[(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Deployment")},void 0,!1)},void 0,!1),(0,r.jsxDEV)(O,{className:"py-3",children:(0,r.jsxDEV)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:w.map(Z)},void 0,!1)},void 0,!1)]},void 0,!0),e[43]=w,e[44]=t,e[45]=u):u=e[45];let h;e[46]!==t?(h=t("Environment & bindings"),e[46]=t,e[47]=h):h=e[47];let g;e[48]!==h?(g=(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h},void 0,!1)},void 0,!1),e[48]=h,e[49]=g):g=e[49];let x;e[50]!==d||e[51]!==A||e[52]!==n.length||e[53]!==t?(x=d===null&&!A&&n.length===0&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:t("No environment variables or bindings.")},void 0,!1),e[50]=d,e[51]=A,e[52]=n.length,e[53]=t,e[54]=x):x=e[54];let b;e[55]!==n||e[56]!==t?(b=n.length>0&&(0,r.jsxDEV)(O,{className:"px-0 py-0",children:(0,r.jsxDEV)(P,{"data-testid":"set-table",children:[(0,r.jsxDEV)(Q,{children:(0,r.jsxDEV)(V,{children:[(0,r.jsxDEV)(C,{children:t("name")},void 0,!1),(0,r.jsxDEV)(C,{children:t("kind")},void 0,!1),(0,r.jsxDEV)(C,{children:t("value")},void 0,!1)]},void 0,!0)},void 0,!1),(0,r.jsxDEV)(W,{children:n.map(ee)},void 0,!1)]},void 0,!0)},void 0,!1),e[55]=n,e[56]=t,e[57]=b):b=e[57];let y;e[58]!==g||e[59]!==x||e[60]!==b?(y=(0,r.jsxDEV)(K,{className:"py-0",children:[g,x,b]},void 0,!0),e[58]=g,e[59]=x,e[60]=b,e[61]=y):y=e[61];let I;return e[62]!==p||e[63]!==u||e[64]!==y||e[65]!==f||e[66]!==v?(I=(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-settings",children:[f,v,p,u,y]},void 0,!0),e[62]=p,e[63]=u,e[64]=y,e[65]=f,e[66]=v,e[67]=I):I=e[67],I},"SettingsPanel");function Z(i){return(0,r.jsxDEV)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,r.jsxDEV)("dt",{className:"text-muted-foreground",children:i.label},void 0,!1),(0,r.jsxDEV)("dd",{className:"truncate font-mono text-xs",title:i.value,children:i.value},void 0,!1)]},i.label,!0)}U(Z,"_temp");function ee(i){return(0,r.jsxDEV)(V,{"data-testid":"set-row",children:[(0,r.jsxDEV)(E,{className:"font-mono text-xs font-medium",children:i.name},void 0,!1),(0,r.jsxDEV)(E,{children:(0,r.jsxDEV)(F,{variant:Y[i.kind],children:i.bindingType??i.kind},void 0,!1)},void 0,!1),(0,r.jsxDEV)(E,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:i.value??(0,r.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},i.name,!0)}U(ee,"_temp2");export{me as SettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as he,b as ue,c as me,d as ve,e as M}from"./chunk-JZLGLG4T.js";import"./chunk-3HGNPZBN.js";import"./chunk-APSSZB6Z.js";import"./chunk-QAFAJBAW.js";import{a as fe}from"./chunk-FQUNSQLG.js";import"./chunk-SHERR7ZP.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import{a as oe}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import{b as ie}from"./chunk-4F72YCTU.js";import{a as ne,b as de,c as ce,d as G,e as f,f as h}from"./chunk-GTM65MVX.js";import{a as _,e as ee}from"./chunk-Y572GMZE.js";import"./chunk-4QHKBC77.js";import{a as le}from"./chunk-FDWXYXOM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as Z}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as b}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as D}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as N}from"./chunk-MHGJUKCZ.js";import{f as J}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as te}from"./chunk-TAD43CG5.js";import{d as X,f as T,g as se,h as ae,l as x,p as re}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as l,e as j,f as be,g as Te,h as Ce}from"./chunk-RRCPZMC2.js";var ge=j(Te(),1);var C=j(be(),1);var s=j(Ce(),1);var P="none",we=["all","open","resolved","ignored"],Ae=["critical","high","medium","low"],Re=T(N.resolveIssue),Ve=T(N.ignoreIssue),pe=T(N.assignIssue),Oe=T(N.setIssueSeverity),$e=l(r=>Array.isArray(r?.issues)?r.issues:[],"issuesOf"),Le=l(r=>r==="resolved"?"success":r==="ignored"?"secondary":"warning","statusVariant"),Ue=l(r=>r==="critical"?"destructive":r==="high"?"warning":r==="medium"?"info":"secondary","severityVariant"),Ze=l(r=>{let e=(0,ge.c)(44),{initialShardKey:Se}=r,a=X(),I=J(),[d,ye]=(0,C.useState)(Se??""),[o,xe]=(0,C.useState)("all"),[z,q]=(0,C.useState)(null),[u,Q]=(0,C.useState)(null),w;e[0]!==d?(w=d.trim(),e[0]=d,e[1]=w):w=e[1];let c=oe(w,400),A;e[2]!==o?(A=o==="all"?{}:{status:o},e[2]=o,e[3]=A):A=e[3];let R;e[4]!==c?(R={live:!0,shardKey:c},e[4]=c,e[5]=R):R=e[5];let{data:V,error:m,liveError:E}=ie(N.getIssues,A,R),H=V!==void 0,O;if(e[6]!==u||e[7]!==z||e[8]!==I||e[9]!==V||e[10]!==c||e[11]!==m||e[12]!==E||e[13]!==H||e[14]!==d||e[15]!==o||e[16]!==a){let W=$e(V),$;e[18]!==I||e[19]!==c?($=l(async(t,i,y)=>{Q(null),q(t);try{await I.query(i,{...y,hash:t},se(c))}catch(Ee){Q(ae(Ee))}q(null)},"t5"),e[18]=I,e[19]=c,e[20]=$):$=e[20];let n=$,L;e[21]!==n?(L=l(t=>i=>{if(i.key!=="Enter")return;let y=i.currentTarget.value.trim();x(n(t.hash,pe,{assignee:y===""?null:y}))},"t6"),e[21]=n,e[22]=L):L=e[22];let Ne=L,U;e[23]!==n?(U=l(t=>i=>{let y=i===null||i===P?null:i;x(n(t.hash,Oe,{severity:y}))},"t7"),e[23]=n,e[24]=U):U=e[24];let Ie=U,B;e[25]!==a?(B=l(t=>a(t==="all"?"All":t==="open"?"Open":t==="resolved"?"Resolved":"Ignored"),"t8"),e[25]=a,e[26]=B):B=e[26];let Y=B,F;e[27]!==m?(F=m!==null&&(0,s.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:m},void 0,!1),e[27]=m,e[28]=F):F=e[28];let K;e[29]!==u?(K=u!==null&&(0,s.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"issues-action-error",role:"alert",children:u},void 0,!1),e[29]=u,e[30]=K):K=e[30];let v;e[31]!==d?(v=(0,s.jsxDEV)(le,{onChange:ye,testId:"issues-shard-input",value:d},void 0,!1),e[31]=d,e[32]=v):v=e[32];let p;e[33]!==E?(p=(0,s.jsxDEV)(fe,{message:E,prefix:"issues"},void 0,!1),e[33]=E,e[34]=p):p=e[34];let g;e[35]!==o||e[36]!==Y?(g=we.map(t=>(0,s.jsxDEV)(b,{"data-active":o===t?"":void 0,"data-testid":`issues-filter-${t}`,onClick:l(()=>{xe(t)},"onClick"),size:"xs",variant:o===t?"default":"outline",children:Y(t)},t,!1)),e[35]=o,e[36]=Y,e[37]=g):g=e[37];let S;e[38]!==g?(S=(0,s.jsxDEV)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g},void 0,!1),e[38]=g,e[39]=S):S=e[39];let k;e[40]!==v||e[41]!==p||e[42]!==S?(k=(0,s.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[v,p,S]},void 0,!0),e[40]=v,e[41]=p,e[42]=S,e[43]=k):k=e[43],O=(0,s.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[F,K,k,H&&W.length===0?(0,s.jsxDEV)(te,{description:a("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:a("No issues")},void 0,!1):(0,s.jsxDEV)(_,{className:"overflow-hidden py-0",children:(0,s.jsxDEV)(ee,{className:"px-0",children:(0,s.jsxDEV)(ne,{"data-testid":"issues-table",children:[(0,s.jsxDEV)(de,{children:(0,s.jsxDEV)(G,{children:[(0,s.jsxDEV)(f,{children:a("Issue")},void 0,!1),(0,s.jsxDEV)(f,{children:a("Status")},void 0,!1),(0,s.jsxDEV)(f,{children:a("Severity")},void 0,!1),(0,s.jsxDEV)(f,{children:a("Assignee")},void 0,!1),(0,s.jsxDEV)(f,{className:"text-right",children:a("Events")},void 0,!1),(0,s.jsxDEV)(f,{children:a("Last seen")},void 0,!1),(0,s.jsxDEV)(f,{className:"text-right",children:a("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,s.jsxDEV)(ce,{children:W.map(t=>{let i=z===t.hash;return(0,s.jsxDEV)(G,{"data-testid":`issues-row-${t.hash}`,children:[(0,s.jsxDEV)(h,{className:"max-w-80",children:[(0,s.jsxDEV)("div",{className:"truncate font-medium",title:t.title,children:t.title},void 0,!1),(0,s.jsxDEV)("div",{className:"truncate font-mono text-xs text-muted-foreground",title:t.culprit,children:t.culprit},void 0,!1)]},void 0,!0),(0,s.jsxDEV)(h,{children:(0,s.jsxDEV)(D,{"data-testid":`issues-status-${t.hash}`,variant:Le(t.status),children:t.status},void 0,!1)},void 0,!1),(0,s.jsxDEV)(h,{children:(0,s.jsxDEV)(he,{disabled:i,onValueChange:Ie(t),value:t.severity??P,children:[(0,s.jsxDEV)(me,{"aria-label":a("Set severity"),className:"h-7 w-[110px]","data-testid":`issues-severity-${t.hash}`,children:(0,s.jsxDEV)(ue,{placeholder:a("\u2014"),children:t.severity===void 0?(0,s.jsxDEV)("span",{className:"text-muted-foreground",children:a("\u2014")},void 0,!1):(0,s.jsxDEV)(D,{variant:Ue(t.severity),children:t.severity},void 0,!1)},void 0,!1)},void 0,!1),(0,s.jsxDEV)(ve,{children:[Ae.map(Be),(0,s.jsxDEV)(M,{value:P,children:a("Clear")},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1),(0,s.jsxDEV)(h,{children:(0,s.jsxDEV)(Z,{"aria-label":a("Assignee"),className:"h-7 w-32","data-testid":`issues-assignee-${t.hash}`,defaultValue:t.assignee??"",disabled:i,onKeyDown:Ne(t),placeholder:a("Unassigned")},t.assignee??"",!1)},void 0,!1),(0,s.jsxDEV)(h,{className:"text-right",children:(0,s.jsxDEV)(D,{variant:"secondary",children:t.count},void 0,!1)},void 0,!1),(0,s.jsxDEV)(h,{className:"text-xs tabular-nums text-muted-foreground",children:re(t.lastSeen)},void 0,!1),(0,s.jsxDEV)(h,{className:"text-right",children:(0,s.jsxDEV)("div",{className:"flex justify-end gap-1",children:[t.status!=="resolved"&&(0,s.jsxDEV)(b,{"data-testid":`issues-resolve-${t.hash}`,disabled:i,onClick:l(()=>{x(n(t.hash,Re,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")},void 0,!1),t.status!=="ignored"&&(0,s.jsxDEV)(b,{"data-testid":`issues-ignore-${t.hash}`,disabled:i,onClick:l(()=>{x(n(t.hash,Ve,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")},void 0,!1),t.status!=="open"&&(0,s.jsxDEV)(b,{"data-testid":`issues-reopen-${t.hash}`,disabled:i,onClick:l(()=>{x(n(t.hash,pe,{assignee:t.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")},void 0,!1)]},void 0,!0)},void 0,!1)]},t.hash,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),e[6]=u,e[7]=z,e[8]=I,e[9]=V,e[10]=c,e[11]=m,e[12]=E,e[13]=H,e[14]=d,e[15]=o,e[16]=a,e[17]=O}else O=e[17];return O},"IssuesPanel");function Be(r){return(0,s.jsxDEV)(M,{value:r,children:r},r,!1)}l(Be,"_temp");export{Ze as IssuesPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as vt,b as ht,c as gt,d as xt,e as pt}from"./chunk-7YGTGBP7.js";import{a as ct,b as ft,c as ut,d as mt,e as ke}from"./chunk-S5NTGHCG.js";import"./chunk-DWDILV2E.js";import{a as dt}from"./chunk-N7SVJOHN.js";import"./chunk-APSSZB6Z.js";import"./chunk-QAFAJBAW.js";import{e as nt}from"./chunk-IYHPYY4A.js";import{a as ot}from"./chunk-FQUNSQLG.js";import"./chunk-SHERR7ZP.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-SWMBBYJU.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import{a as it}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import{b as je}from"./chunk-4F72YCTU.js";import{a as Ue,b as Ve,c as Ge,d as Ie,e as Z,f as G}from"./chunk-GTM65MVX.js";import{a as ee,b as Re,c as Me,d as Ye,e as le}from"./chunk-Y572GMZE.js";import"./chunk-4QHKBC77.js";import{a as at}from"./chunk-FDWXYXOM.js";import{a as lt,b as st}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as Ke}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as He}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as Be}from"./chunk-EBTLTGG3.js";import{f as Xe}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Ee,f as Ze,g as et,h as tt,l as rt,o as ze}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as d,e as Qe,f as bt,g as Nt,h as yt}from"./chunk-RRCPZMC2.js";var Fe=Qe(Nt(),1);var _=Qe(bt(),1);var t=Qe(yt(),1);var St=d(s=>s.kind==="gauge"?s.last:s.kind==="histogram"?s.sum/Math.max(1,s.count):s.sum,"metricHeadline"),Je=d(s=>Number.isInteger(s)?s.toLocaleString():s.toLocaleString(void 0,{maximumFractionDigits:2}),"formatMetricValue"),wt=d(s=>Array.isArray(s?.series)?s.series:[],"seriesOf"),qt={counter:"secondary",gauge:"default",histogram:"outline"},Tt=d(s=>{let e=(0,Fe.c)(79),{shardKey:l}=s,r=Ee(),o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let U;e[1]!==l?(U={live:!0,shardKey:l},e[1]=l,e[2]=U):U=e[2];let{data:M,error:g}=je(Be.getMetricSeries,o,U),y,v,p,u,c,C,z,B,i,q,O,E,W;if(e[3]!==M||e[4]!==g||e[5]!==r){C=Symbol.for("react.early_return_sentinel");e:{let V=wt(M);if(g!==null||V.length===0){C=null;break e}let S;e[19]!==r?(S=d(f=>r(f==="counter"?"Counter":f==="gauge"?"Gauge":"Histogram"),"t122"),e[19]=r,e[20]=S):S=e[20];let w=S;E="flex flex-col gap-2",W="mt-instruments";let F;e[21]!==r?(F=r("Instruments"),e[21]=r,e[22]=F):F=e[22],e[23]!==F?(c=(0,t.jsxDEV)("h3",{className:"text-sm font-semibold text-foreground",children:F},void 0,!1),e[23]=F,e[24]=c):c=e[24],u=ee,O="overflow-hidden py-0",p=le,q="px-0",v=Ue,B="mt-instruments-table";let D;e[25]!==r?(D=r("name"),e[25]=r,e[26]=D):D=e[26];let A;e[27]!==D?(A=(0,t.jsxDEV)(Z,{children:D},void 0,!1),e[27]=D,e[28]=A):A=e[28];let L;e[29]!==r?(L=r("kind"),e[29]=r,e[30]=L):L=e[30];let a;e[31]!==L?(a=(0,t.jsxDEV)(Z,{children:L},void 0,!1),e[31]=L,e[32]=a):a=e[32];let b;e[33]!==r?(b=r("value"),e[33]=r,e[34]=b):b=e[34];let h;e[35]!==b?(h=(0,t.jsxDEV)(Z,{className:"text-right",children:b},void 0,!1),e[35]=b,e[36]=h):h=e[36];let x;e[37]!==r?(x=r("count"),e[37]=r,e[38]=x):x=e[38];let P;e[39]!==x?(P=(0,t.jsxDEV)(Z,{className:"text-right",children:x},void 0,!1),e[39]=x,e[40]=P):P=e[40];let Q;e[41]!==r?(Q=r("range"),e[41]=r,e[42]=Q):Q=e[42];let H;e[43]!==Q?(H=(0,t.jsxDEV)(Z,{className:"text-right",children:Q},void 0,!1),e[43]=Q,e[44]=H):H=e[44];let K;e[45]!==r?(K=r("dimensions"),e[45]=r,e[46]=K):K=e[46];let j;e[47]!==K?(j=(0,t.jsxDEV)(Z,{children:K},void 0,!1),e[47]=K,e[48]=j):j=e[48],e[49]!==A||e[50]!==a||e[51]!==h||e[52]!==P||e[53]!==H||e[54]!==j?(i=(0,t.jsxDEV)(Ve,{children:(0,t.jsxDEV)(Ie,{children:[A,a,h,P,H,j]},void 0,!0)},void 0,!1),e[49]=A,e[50]=a,e[51]=h,e[52]=P,e[53]=H,e[54]=j,e[55]=i):i=e[55],y=Ge;let X;e[56]!==w?(X=d(f=>{let Y=dt(f.attributes),te=`${f.kind}:${f.name}:${Y}`;return(0,t.jsxDEV)(Ie,{"data-testid":`mt-instrument-${f.name}`,children:[(0,t.jsxDEV)(G,{className:"font-mono text-xs",title:f.functionPath,children:f.name},void 0,!1),(0,t.jsxDEV)(G,{children:(0,t.jsxDEV)(He,{variant:qt[f.kind],children:w(f.kind)},void 0,!1)},void 0,!1),(0,t.jsxDEV)(G,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${f.name}`,children:Je(St(f))},void 0,!1),(0,t.jsxDEV)(G,{className:"text-right tabular-nums text-muted-foreground",children:f.count.toLocaleString()},void 0,!1),(0,t.jsxDEV)(G,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:f.min===f.max?"\u2014":`${Je(f.min)}\u2013${Je(f.max)}`},void 0,!1),(0,t.jsxDEV)(G,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:Y,children:Y===""?"\u2014":Y},void 0,!1)]},te,!0)},"t26"),e[56]=w,e[57]=X):X=e[57],z=V.map(X)}e[3]=M,e[4]=g,e[5]=r,e[6]=y,e[7]=v,e[8]=p,e[9]=u,e[10]=c,e[11]=C,e[12]=z,e[13]=B,e[14]=i,e[15]=q,e[16]=O,e[17]=E,e[18]=W}else y=e[6],v=e[7],p=e[8],u=e[9],c=e[10],C=e[11],z=e[12],B=e[13],i=e[14],q=e[15],O=e[16],E=e[17],W=e[18];if(C!==Symbol.for("react.early_return_sentinel"))return C;let I;e[58]!==y||e[59]!==z?(I=(0,t.jsxDEV)(y,{children:z},void 0,!1),e[58]=y,e[59]=z,e[60]=I):I=e[60];let m;e[61]!==v||e[62]!==I||e[63]!==B||e[64]!==i?(m=(0,t.jsxDEV)(v,{"data-testid":B,children:[i,I]},void 0,!0),e[61]=v,e[62]=I,e[63]=B,e[64]=i,e[65]=m):m=e[65];let $;e[66]!==p||e[67]!==m||e[68]!==q?($=(0,t.jsxDEV)(p,{className:q,children:m},void 0,!1),e[66]=p,e[67]=m,e[68]=q,e[69]=$):$=e[69];let k;e[70]!==u||e[71]!==$||e[72]!==O?(k=(0,t.jsxDEV)(u,{className:O,children:$},void 0,!1),e[70]=u,e[71]=$,e[72]=O,e[73]=k):k=e[73];let R;return e[74]!==c||e[75]!==k||e[76]!==E||e[77]!==W?(R=(0,t.jsxDEV)("section",{className:E,"data-testid":W,children:[c,k]},void 0,!0),e[74]=c,e[75]=k,e[76]=E,e[77]=W,e[78]=R):R=e[78],R},"InstrumentsTable"),Pe=d(s=>s>=100?"critical":s>=50?"warning":"good","performanceLevel"),We=d(s=>s<1?`${(s*1e3).toFixed(0)}\u03BCs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,"formatLatency"),Oe=d(s=>s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString(),"formatCount"),_t=d(s=>{let e=(0,Fe.c)(3),{level:l}=s;if(l==="critical"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsxDEV)(He,{variant:"destructive",children:"Slow"},void 0,!1),e[0]=o):o=e[0],o}if(l==="warning"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"},void 0,!1),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"},void 0,!1),e[2]=r):r=e[2],r},"PerformanceBadge"),Ct=d(s=>{let e=(0,Fe.c)(152),{queryStats:l}=s,r=Ee(),[o,U]=(0,_.useState)("totalTime"),M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M=new Set,e[0]=M):M=e[0];let[g,y]=(0,_.useState)(M),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=d(n=>{n!==null&&U(n)},"t2"),e[1]=v):v=e[1];let p=v,u;if(e[2]!==l||e[3]!==o){u=[...l];let n;e[5]!==o?(n=d((T,N)=>{switch(o){case"avgTime":return N.avgDurationMs-T.avgDurationMs;case"execCount":return N.execCount-T.execCount;case"rowsRead":return N.rowsRead-T.rowsRead;default:return N.totalDurationMs-T.totalDurationMs}},"t310"),e[5]=o,e[6]=n):n=e[6],u.sort(n),e[2]=l,e[3]=o,e[4]=u}else u=e[4];let c=u,C;e[7]!==l?(C=l.filter($t),e[7]=l,e[8]=C):C=e[8];let z=C.length,B;e[9]!==l?(B=l.filter(Rt),e[9]=l,e[10]=B):B=e[10];let i=B.length,q;e[11]!==l?(q=l.filter(Mt),e[11]=l,e[12]=q):q=e[12];let O=q.length,E;e[13]===Symbol.for("react.memo_cache_sentinel")?(E=d(n=>{y(T=>{let N=new Set(T);return N.has(n)?N.delete(n):N.add(n),N})},"t6"),e[13]=E):E=e[13];let W=E;if(l.length===0){let n;e[14]!==r?(n=r("No query insights yet"),e[14]=r,e[15]=n):n=e[15];let T;e[16]!==n?(T=(0,t.jsxDEV)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:n},void 0,!1),e[16]=n,e[17]=T):T=e[17];let N;e[18]!==r?(N=r("Query insights appear once statements are executed against this shard."),e[18]=r,e[19]=N):N=e[19];let re;e[20]!==N?(re=(0,t.jsxDEV)("p",{className:"mt-1 text-sm",children:N},void 0,!1),e[20]=N,e[21]=re):re=e[21];let Le;return e[22]!==re||e[23]!==T?(Le=(0,t.jsxDEV)(ee,{children:(0,t.jsxDEV)(le,{className:"py-12",children:(0,t.jsxDEV)("div",{className:"text-center text-muted-foreground",children:[T,re]},void 0,!0)},void 0,!1)},void 0,!1),e[22]=re,e[23]=T,e[24]=Le):Le=e[24],Le}let I;e[25]!==r?(I=r("Critical queries"),e[25]=r,e[26]=I):I=e[26];let m;e[27]!==I?(m=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(Me,{className:"text-sm font-medium",children:I},void 0,!1)},void 0,!1),e[27]=I,e[28]=m):m=e[28];let $;e[29]!==z?($=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:z},void 0,!1),e[29]=z,e[30]=$):$=e[30];let k;e[31]!==r?(k=r(">100ms avg execution"),e[31]=r,e[32]=k):k=e[32];let R;e[33]!==k?(R=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:k},void 0,!1),e[33]=k,e[34]=R):R=e[34];let V;e[35]!==R||e[36]!==$?(V=(0,t.jsxDEV)(le,{children:[$,R]},void 0,!0),e[35]=R,e[36]=$,e[37]=V):V=e[37];let S;e[38]!==V||e[39]!==m?(S=(0,t.jsxDEV)(ee,{children:[m,V]},void 0,!0),e[38]=V,e[39]=m,e[40]=S):S=e[40];let w;e[41]!==r?(w=r("Moderate queries"),e[41]=r,e[42]=w):w=e[42];let F;e[43]!==w?(F=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(Me,{className:"text-sm font-medium",children:w},void 0,!1)},void 0,!1),e[43]=w,e[44]=F):F=e[44];let D;e[45]!==i?(D=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:i},void 0,!1),e[45]=i,e[46]=D):D=e[46];let A;e[47]!==r?(A=r("50\u2013100ms avg execution"),e[47]=r,e[48]=A):A=e[48];let L;e[49]!==A?(L=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:A},void 0,!1),e[49]=A,e[50]=L):L=e[50];let a;e[51]!==D||e[52]!==L?(a=(0,t.jsxDEV)(le,{children:[D,L]},void 0,!0),e[51]=D,e[52]=L,e[53]=a):a=e[53];let b;e[54]!==F||e[55]!==a?(b=(0,t.jsxDEV)(ee,{children:[F,a]},void 0,!0),e[54]=F,e[55]=a,e[56]=b):b=e[56];let h;e[57]!==r?(h=r("Fast queries"),e[57]=r,e[58]=h):h=e[58];let x;e[59]!==h?(x=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(Me,{className:"text-sm font-medium",children:h},void 0,!1)},void 0,!1),e[59]=h,e[60]=x):x=e[60];let P;e[61]!==O?(P=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:O},void 0,!1),e[61]=O,e[62]=P):P=e[62];let Q;e[63]!==r?(Q=r("<50ms avg execution"),e[63]=r,e[64]=Q):Q=e[64];let H;e[65]!==Q?(H=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:Q},void 0,!1),e[65]=Q,e[66]=H):H=e[66];let K;e[67]!==P||e[68]!==H?(K=(0,t.jsxDEV)(le,{children:[P,H]},void 0,!0),e[67]=P,e[68]=H,e[69]=K):K=e[69];let j;e[70]!==x||e[71]!==K?(j=(0,t.jsxDEV)(ee,{children:[x,K]},void 0,!0),e[70]=x,e[71]=K,e[72]=j):j=e[72];let X;e[73]!==S||e[74]!==b||e[75]!==j?(X=(0,t.jsxDEV)("div",{className:"grid gap-4 md:grid-cols-3",children:[S,b,j]},void 0,!0),e[73]=S,e[74]=b,e[75]=j,e[76]=X):X=e[76];let f;e[77]!==r?(f=r("Query leaderboard"),e[77]=r,e[78]=f):f=e[78];let Y;e[79]!==f?(Y=(0,t.jsxDEV)("h3",{className:"text-lg font-semibold",children:f},void 0,!1),e[79]=f,e[80]=Y):Y=e[80];let te;e[81]!==o||e[82]!==r?(te=r("Slow queries sorted by {sortField}",{sortField:r(o)}),e[81]=o,e[82]=r,e[83]=te):te=e[83];let se;e[84]!==te?(se=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:te},void 0,!1),e[84]=te,e[85]=se):se=e[85];let ae;e[86]!==Y||e[87]!==se?(ae=(0,t.jsxDEV)("div",{children:[Y,se]},void 0,!0),e[86]=Y,e[87]=se,e[88]=ae):ae=e[88];let ie;e[89]!==r?(ie=r("Sort by"),e[89]=r,e[90]=ie):ie=e[90];let oe;e[91]!==ie?(oe=(0,t.jsxDEV)("span",{className:"text-sm text-muted-foreground",children:ie},void 0,!1),e[91]=ie,e[92]=oe):oe=e[92];let ne;e[93]!==r?(ne=r("Sort queries by"),e[93]=r,e[94]=ne):ne=e[94];let De;e[95]===Symbol.for("react.memo_cache_sentinel")?(De=(0,t.jsxDEV)(ft,{},void 0,!1),e[95]=De):De=e[95];let de;e[96]!==ne?(de=(0,t.jsxDEV)(ut,{"aria-label":ne,className:"w-[140px]","data-testid":"qi-sort",children:De},void 0,!1),e[96]=ne,e[97]=de):de=e[97];let ce;e[98]!==r?(ce=r("Total time"),e[98]=r,e[99]=ce):ce=e[99];let fe;e[100]!==ce?(fe=(0,t.jsxDEV)(ke,{value:"totalTime",children:ce},void 0,!1),e[100]=ce,e[101]=fe):fe=e[101];let ue;e[102]!==r?(ue=r("Avg time"),e[102]=r,e[103]=ue):ue=e[103];let me;e[104]!==ue?(me=(0,t.jsxDEV)(ke,{value:"avgTime",children:ue},void 0,!1),e[104]=ue,e[105]=me):me=e[105];let ve;e[106]!==r?(ve=r("Execution count"),e[106]=r,e[107]=ve):ve=e[107];let he;e[108]!==ve?(he=(0,t.jsxDEV)(ke,{value:"execCount",children:ve},void 0,!1),e[108]=ve,e[109]=he):he=e[109];let ge;e[110]!==r?(ge=r("Rows read"),e[110]=r,e[111]=ge):ge=e[111];let xe;e[112]!==ge?(xe=(0,t.jsxDEV)(ke,{value:"rowsRead",children:ge},void 0,!1),e[112]=ge,e[113]=xe):xe=e[113];let pe;e[114]!==fe||e[115]!==me||e[116]!==he||e[117]!==xe?(pe=(0,t.jsxDEV)(mt,{children:[fe,me,he,xe]},void 0,!0),e[114]=fe,e[115]=me,e[116]=he,e[117]=xe,e[118]=pe):pe=e[118];let be;e[119]!==o||e[120]!==de||e[121]!==pe?(be=(0,t.jsxDEV)(ct,{onValueChange:p,value:o,children:[de,pe]},void 0,!0),e[119]=o,e[120]=de,e[121]=pe,e[122]=be):be=e[122];let Ne;e[123]!==oe||e[124]!==be?(Ne=(0,t.jsxDEV)("div",{className:"flex items-center gap-2",children:[oe,be]},void 0,!0),e[123]=oe,e[124]=be,e[125]=Ne):Ne=e[125];let ye;e[126]!==ae||e[127]!==Ne?(ye=(0,t.jsxDEV)("div",{className:"flex items-center justify-between",children:[ae,Ne]},void 0,!0),e[126]=ae,e[127]=Ne,e[128]=ye):ye=e[128];let Se;e[129]!==r?(Se=r("Statements"),e[129]=r,e[130]=Se):Se=e[130];let we;e[131]!==Se?(we=(0,t.jsxDEV)(Me,{children:Se},void 0,!1),e[131]=Se,e[132]=we):we=e[132];let qe;e[133]!==c.length||e[134]!==r?(qe=r("{count} tracked statements",{count:c.length}),e[133]=c.length,e[134]=r,e[135]=qe):qe=e[135];let Te;e[136]!==qe?(Te=(0,t.jsxDEV)(Ye,{children:qe},void 0,!1),e[136]=qe,e[137]=Te):Te=e[137];let _e;e[138]!==we||e[139]!==Te?(_e=(0,t.jsxDEV)(Re,{children:[we,Te]},void 0,!0),e[138]=we,e[139]=Te,e[140]=_e):_e=e[140];let Ce;e[141]!==g||e[142]!==c||e[143]!==r?(Ce=(0,t.jsxDEV)(le,{children:(0,t.jsxDEV)("div",{className:"space-y-2",children:c.map(n=>{let T=n.normalizedSql,N=g.has(T),re=Pe(n.avgDurationMs);return(0,t.jsxDEV)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxDEV)("button",{"aria-expanded":N,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:d(()=>{W(T)},"onClick"),type:"button",children:[(0,t.jsxDEV)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsxDEV)(_t,{level:re},void 0,!1),(0,t.jsxDEV)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:n.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:We(n.totalDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("total")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:We(n.avgDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("avg")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:Oe(n.execCount)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("calls")},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),N&&(0,t.jsxDEV)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")},void 0,!1),(0,t.jsxDEV)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:n.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Exec count")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Oe(n.execCount)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Total time")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:We(n.totalDurationMs)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows read")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Oe(n.rowsRead)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows written")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Oe(n.rowsWritten)},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},T,!0)})},void 0,!1)},void 0,!1),e[141]=g,e[142]=c,e[143]=r,e[144]=Ce):Ce=e[144];let $e;e[145]!==_e||e[146]!==Ce?($e=(0,t.jsxDEV)(ee,{children:[_e,Ce]},void 0,!0),e[145]=_e,e[146]=Ce,e[147]=$e):$e=e[147];let Ae;return e[148]!==X||e[149]!==ye||e[150]!==$e?(Ae=(0,t.jsxDEV)("div",{className:"space-y-4","data-testid":"qi-root",children:[X,ye,$e]},void 0,!0),e[148]=X,e[149]=ye,e[150]=$e,e[151]=Ae):Ae=e[151],Ae},"QueryInsights");function $t(s){return Pe(s.avgDurationMs)==="critical"}d($t,"_temp");function Rt(s){return Pe(s.avgDurationMs)==="warning"}d(Rt,"_temp2");function Mt(s){return Pe(s.avgDurationMs)==="good"}d(Mt,"_temp3");var It=Ze(Be.getMetrics),kt=d(s=>{let e=Math.floor(s/1e3),l=Math.floor(e/3600),r=Math.floor(e%3600/60),o=e%60;return l>0?`${l.toString()}h ${r.toString()}m`:r>0?`${r.toString()}m ${o.toString()}s`:`${o.toString()}s`},"formatDuration"),Ft=d((s,e)=>s?e:"overview","resolveTab"),Dt=d((s,e)=>{let l=s+e;return l===0?"\u2014":`${(s/l*100).toFixed(1)}%`},"hitRate"),J=d(s=>{let e=(0,Fe.c)(16),{chart:l,footer:r,label:o,testId:U,value:M}=s,g;e[0]!==o?(g=(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o},void 0,!1),e[0]=o,e[1]=g):g=e[1];let y;e[2]!==U||e[3]!==M?(y=(0,t.jsxDEV)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":U,children:M},void 0,!1),e[2]=U,e[3]=M,e[4]=y):y=e[4];let v;e[5]!==l||e[6]!==y?(v=(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[y,l]},void 0,!0),e[5]=l,e[6]=y,e[7]=v):v=e[7];let p;e[8]!==g||e[9]!==v?(p=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,v]},void 0,!0),e[8]=g,e[9]=v,e[10]=p):p=e[10];let u;e[11]!==r?(u=r!=null&&(0,t.jsxDEV)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r},void 0,!1),e[11]=r,e[12]=u):u=e[12];let c;return e[13]!==p||e[14]!==u?(c=(0,t.jsxDEV)(ee,{className:"justify-between gap-0 py-0",children:[p,u]},void 0,!0),e[13]=p,e[14]=u,e[15]=c):c=e[15],c},"StatCard"),Zt=d(({initialShardKey:s})=>{let e=Xe(),l=Ee(),[r,o]=(0,_.useState)(s??""),[U,M]=(0,_.useState)("overview"),[g,y]=(0,_.useState)([]),v=(0,_.useRef)(null),p=(0,_.useRef)(null),u=(0,_.useRef)(!0);(0,_.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let c=it(r.trim(),400),{data:C,error:z,liveError:B}=je(Be.getMetrics,{},{live:!0,shardKey:c}),i=C??null;(0,_.useEffect)(()=>{if(C===void 0)return;st(c);let a=C,b=v.current,h=p.current!==null&&p.current!==a.shard;if(p.current=a.shard,v.current=a.requests,h){y([]);return}b!==null&&a.requests>=b&&y(x=>[...x,a.requests-b].slice(-30))},[C,c]);let[q,O]=(0,_.useState)(null),[E,W]=(0,_.useState)(!1),I=d(async()=>{W(!0);let a=ht(r,lt());try{let b=await Promise.all(a.map(async h=>{try{let x=await e.query(It,{},et(h));return{error:null,metrics:x,shard:h===""?x.shard:h}}catch(x){return{error:tt(x),metrics:null,shard:h===""?"__root__":h}}}));u.current&&O(b)}finally{u.current&&W(!1)}},"aggregateAll"),m=q===null?null:vt(q),$=i===null||i.requests===0?"\u2014":`${(i.errors/i.requests*100).toFixed(1)}%`,k=g.length>0?g.at(-1):0,R=i?gt(i):{p90:0,p95:0},V=d(a=>a<=0?"\u2014":a<1?`${(a*1e3).toFixed(0)}\u03BCs`:a<1e3?`${a.toFixed(1)}ms`:`${(a/1e3).toFixed(2)}s`,"formatMs"),S=(0,_.useMemo)(()=>{if(!i||!("queryStats"in i))return;let a=i.queryStats;if(!(!a||!Array.isArray(a)))return xt(a)},[i]),w=Ft(S!==void 0,U),F=d(()=>{rt(I())},"runAggregate"),D=d(()=>{O(null)},"clearAggregate"),A=d(()=>{M("overview")},"switchToOverview"),L=d(()=>{M("query-insights")},"switchToQueryInsights");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(at,{onChange:o,testId:"mt-shard-input",value:r},void 0,!1),(0,t.jsxDEV)(ot,{message:B,prefix:"mt"},void 0,!1),(0,t.jsxDEV)(Ke,{"data-testid":"mt-aggregate",disabled:E,onClick:F,size:"sm",type:"button",variant:"secondary",children:l(E?"Aggregating\u2026":"All shards")},void 0,!1),q!==null&&(0,t.jsxDEV)(Ke,{"data-testid":"mt-aggregate-clear",onClick:D,size:"sm",type:"button",variant:"ghost",children:l("Hide")},void 0,!1),(0,t.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:nt,rel:"noreferrer",target:"_blank",children:l("Open in Cloudflare")},void 0,!1)]},void 0,!0),z!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:z},void 0,!1),S!==void 0&&(0,t.jsxDEV)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${w==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:A,type:"button",children:l("Overview")},void 0,!1),(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${w==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:L,type:"button",children:[l("Query insights"),S.length>0&&(0,t.jsxDEV)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:S.length},void 0,!1)]},void 0,!0)]},void 0,!0),w==="query-insights"&&S!==void 0&&(0,t.jsxDEV)(Ct,{queryStats:S},void 0,!1),w==="overview"&&i!==null&&(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[(0,t.jsxDEV)(J,{chart:g.length>=2?(0,t.jsxDEV)(pt,{ariaLabel:l("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:g,testId:"mt-sparkline"},void 0,!1):void 0,footer:g.length>=2?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("span",{className:"font-semibold text-foreground",children:`+${k.toLocaleString()}`},void 0,!1)," ",l("last interval")]},void 0,!0):(0,t.jsxDEV)("span",{"data-testid":"mt-sparkline-empty",children:l("collecting samples\u2026")},void 0,!1),label:l("Requests"),testId:"mt-requests",value:i.requests},void 0,!1),(0,t.jsxDEV)(J,{footer:l("{rate} error rate",{rate:$}),label:l("Errors"),testId:"mt-errors",value:(0,t.jsxDEV)(t.Fragment,{children:[i.errors," (",$,")"]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(J,{footer:R.p90>0?`P90 ${V(R.p90)}`:void 0,label:l("P95 latency"),testId:"mt-p95",value:R.p95>0?V(R.p95):"\u2014"},void 0,!1),(0,t.jsxDEV)(J,{footer:i.cache===null?void 0:`${i.cache.entries.toLocaleString()} ${l("cache entries")}`,label:l("Database size"),testId:"mt-db-size",value:ze(i.databaseSize)},void 0,!1),(0,t.jsxDEV)(J,{label:l("Shard"),testId:"mt-shard",value:i.shard},void 0,!1),(0,t.jsxDEV)(J,{label:l("Uptime"),testId:"mt-uptime",value:kt(i.uptimeMs)},void 0,!1),(0,t.jsxDEV)(J,{label:l("Cache hit rate"),testId:"mt-cache",value:i.cache===null?l("no cache configured"):l("{rate} ({count} entries)",{count:i.cache.entries,rate:Dt(i.cache.hits,i.cache.misses)})},void 0,!1)]},void 0,!0),w==="overview"&&i===null&&null,w==="overview"&&(0,t.jsxDEV)(Tt,{shardKey:c},void 0,!1),w==="overview"&&m!==null&&q!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[(0,t.jsxDEV)(J,{label:l("Shards"),testId:"mt-agg-shards",value:m.failed>0?l("{reachable} reachable, {failed} unreachable",{failed:m.failed,reachable:m.reachable}):l("{reachable} reachable",{reachable:m.reachable})},void 0,!1),(0,t.jsxDEV)(J,{label:l("Total requests"),testId:"mt-agg-requests",value:m.totalRequests},void 0,!1),(0,t.jsxDEV)(J,{label:l("Total errors"),testId:"mt-agg-errors",value:m.totalErrors},void 0,!1),(0,t.jsxDEV)(J,{label:l("Total database size"),testId:"mt-agg-db-size",value:ze(m.totalDatabaseSize)},void 0,!1),(0,t.jsxDEV)(J,{label:l("Combined cache hit rate"),testId:"mt-agg-cache",value:m.hitRate===null?l("no cache configured"):`${(m.hitRate*100).toFixed(1)}%`},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(ee,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(le,{className:"px-0",children:(0,t.jsxDEV)(Ue,{"data-testid":"mt-agg-table",children:[(0,t.jsxDEV)(Ve,{children:(0,t.jsxDEV)(Ie,{children:[(0,t.jsxDEV)(Z,{children:l("shard")},void 0,!1),(0,t.jsxDEV)(Z,{children:l("requests")},void 0,!1),(0,t.jsxDEV)(Z,{children:l("errors")},void 0,!1),(0,t.jsxDEV)(Z,{children:l("db size")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Ge,{children:q.map(a=>(0,t.jsxDEV)(Ie,{"data-testid":`mt-agg-row-${a.shard}`,children:[(0,t.jsxDEV)(G,{children:a.shard},void 0,!1),a.metrics===null?(0,t.jsxDEV)(G,{className:"text-destructive",colSpan:3,children:a.error??l("unreachable")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(G,{className:"tabular-nums",children:a.metrics.requests},void 0,!1),(0,t.jsxDEV)(G,{className:"tabular-nums",children:a.metrics.errors},void 0,!1),(0,t.jsxDEV)(G,{className:"tabular-nums",children:ze(a.metrics.databaseSize)},void 0,!1)]},void 0,!0)]},a.shard,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"MetricsPanel");export{Zt as MetricsPanel};
|
|
1
|
+
import{a as vt,b as ht,c as gt,d as xt,e as pt}from"./chunk-7YGTGBP7.js";import{a as dt,b as ct,c as ft,d as ut,e as ke}from"./chunk-JZLGLG4T.js";import"./chunk-3HGNPZBN.js";import{a as mt}from"./chunk-N7SVJOHN.js";import"./chunk-APSSZB6Z.js";import"./chunk-QAFAJBAW.js";import{e as nt}from"./chunk-IYHPYY4A.js";import{a as ot}from"./chunk-FQUNSQLG.js";import"./chunk-SHERR7ZP.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-SWMBBYJU.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import{a as it}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import{b as je}from"./chunk-4F72YCTU.js";import{a as Ue,b as Ve,c as Ge,d as Ie,e as Z,f as G}from"./chunk-GTM65MVX.js";import{a as ee,b as Re,c as Me,d as Ye,e as le}from"./chunk-Y572GMZE.js";import"./chunk-4QHKBC77.js";import{a as at}from"./chunk-FDWXYXOM.js";import{a as lt,b as st}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as Ke}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as He}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as Be}from"./chunk-MHGJUKCZ.js";import{f as Xe}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Ee,f as Ze,g as et,h as tt,l as rt,o as ze}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as d,e as Qe,f as bt,g as Nt,h as yt}from"./chunk-RRCPZMC2.js";var Fe=Qe(Nt(),1);var _=Qe(bt(),1);var t=Qe(yt(),1);var St=d(s=>s.kind==="gauge"?s.last:s.kind==="histogram"?s.sum/Math.max(1,s.count):s.sum,"metricHeadline"),Je=d(s=>Number.isInteger(s)?s.toLocaleString():s.toLocaleString(void 0,{maximumFractionDigits:2}),"formatMetricValue"),wt=d(s=>Array.isArray(s?.series)?s.series:[],"seriesOf"),qt={counter:"secondary",gauge:"default",histogram:"outline"},Tt=d(s=>{let e=(0,Fe.c)(79),{shardKey:l}=s,r=Ee(),o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let U;e[1]!==l?(U={live:!0,shardKey:l},e[1]=l,e[2]=U):U=e[2];let{data:M,error:g}=je(Be.getMetricSeries,o,U),y,v,p,u,c,C,z,B,i,q,O,E,W;if(e[3]!==M||e[4]!==g||e[5]!==r){C=Symbol.for("react.early_return_sentinel");e:{let V=wt(M);if(g!==null||V.length===0){C=null;break e}let S;e[19]!==r?(S=d(f=>r(f==="counter"?"Counter":f==="gauge"?"Gauge":"Histogram"),"t122"),e[19]=r,e[20]=S):S=e[20];let w=S;E="flex flex-col gap-2",W="mt-instruments";let F;e[21]!==r?(F=r("Instruments"),e[21]=r,e[22]=F):F=e[22],e[23]!==F?(c=(0,t.jsxDEV)("h3",{className:"text-sm font-semibold text-foreground",children:F},void 0,!1),e[23]=F,e[24]=c):c=e[24],u=ee,O="overflow-hidden py-0",p=le,q="px-0",v=Ue,B="mt-instruments-table";let D;e[25]!==r?(D=r("name"),e[25]=r,e[26]=D):D=e[26];let A;e[27]!==D?(A=(0,t.jsxDEV)(Z,{children:D},void 0,!1),e[27]=D,e[28]=A):A=e[28];let L;e[29]!==r?(L=r("kind"),e[29]=r,e[30]=L):L=e[30];let a;e[31]!==L?(a=(0,t.jsxDEV)(Z,{children:L},void 0,!1),e[31]=L,e[32]=a):a=e[32];let b;e[33]!==r?(b=r("value"),e[33]=r,e[34]=b):b=e[34];let h;e[35]!==b?(h=(0,t.jsxDEV)(Z,{className:"text-right",children:b},void 0,!1),e[35]=b,e[36]=h):h=e[36];let x;e[37]!==r?(x=r("count"),e[37]=r,e[38]=x):x=e[38];let P;e[39]!==x?(P=(0,t.jsxDEV)(Z,{className:"text-right",children:x},void 0,!1),e[39]=x,e[40]=P):P=e[40];let Q;e[41]!==r?(Q=r("range"),e[41]=r,e[42]=Q):Q=e[42];let H;e[43]!==Q?(H=(0,t.jsxDEV)(Z,{className:"text-right",children:Q},void 0,!1),e[43]=Q,e[44]=H):H=e[44];let K;e[45]!==r?(K=r("dimensions"),e[45]=r,e[46]=K):K=e[46];let j;e[47]!==K?(j=(0,t.jsxDEV)(Z,{children:K},void 0,!1),e[47]=K,e[48]=j):j=e[48],e[49]!==A||e[50]!==a||e[51]!==h||e[52]!==P||e[53]!==H||e[54]!==j?(i=(0,t.jsxDEV)(Ve,{children:(0,t.jsxDEV)(Ie,{children:[A,a,h,P,H,j]},void 0,!0)},void 0,!1),e[49]=A,e[50]=a,e[51]=h,e[52]=P,e[53]=H,e[54]=j,e[55]=i):i=e[55],y=Ge;let X;e[56]!==w?(X=d(f=>{let Y=mt(f.attributes),te=`${f.kind}:${f.name}:${Y}`;return(0,t.jsxDEV)(Ie,{"data-testid":`mt-instrument-${f.name}`,children:[(0,t.jsxDEV)(G,{className:"font-mono text-xs",title:f.functionPath,children:f.name},void 0,!1),(0,t.jsxDEV)(G,{children:(0,t.jsxDEV)(He,{variant:qt[f.kind],children:w(f.kind)},void 0,!1)},void 0,!1),(0,t.jsxDEV)(G,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${f.name}`,children:Je(St(f))},void 0,!1),(0,t.jsxDEV)(G,{className:"text-right tabular-nums text-muted-foreground",children:f.count.toLocaleString()},void 0,!1),(0,t.jsxDEV)(G,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:f.min===f.max?"\u2014":`${Je(f.min)}\u2013${Je(f.max)}`},void 0,!1),(0,t.jsxDEV)(G,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:Y,children:Y===""?"\u2014":Y},void 0,!1)]},te,!0)},"t26"),e[56]=w,e[57]=X):X=e[57],z=V.map(X)}e[3]=M,e[4]=g,e[5]=r,e[6]=y,e[7]=v,e[8]=p,e[9]=u,e[10]=c,e[11]=C,e[12]=z,e[13]=B,e[14]=i,e[15]=q,e[16]=O,e[17]=E,e[18]=W}else y=e[6],v=e[7],p=e[8],u=e[9],c=e[10],C=e[11],z=e[12],B=e[13],i=e[14],q=e[15],O=e[16],E=e[17],W=e[18];if(C!==Symbol.for("react.early_return_sentinel"))return C;let I;e[58]!==y||e[59]!==z?(I=(0,t.jsxDEV)(y,{children:z},void 0,!1),e[58]=y,e[59]=z,e[60]=I):I=e[60];let m;e[61]!==v||e[62]!==I||e[63]!==B||e[64]!==i?(m=(0,t.jsxDEV)(v,{"data-testid":B,children:[i,I]},void 0,!0),e[61]=v,e[62]=I,e[63]=B,e[64]=i,e[65]=m):m=e[65];let $;e[66]!==p||e[67]!==m||e[68]!==q?($=(0,t.jsxDEV)(p,{className:q,children:m},void 0,!1),e[66]=p,e[67]=m,e[68]=q,e[69]=$):$=e[69];let k;e[70]!==u||e[71]!==$||e[72]!==O?(k=(0,t.jsxDEV)(u,{className:O,children:$},void 0,!1),e[70]=u,e[71]=$,e[72]=O,e[73]=k):k=e[73];let R;return e[74]!==c||e[75]!==k||e[76]!==E||e[77]!==W?(R=(0,t.jsxDEV)("section",{className:E,"data-testid":W,children:[c,k]},void 0,!0),e[74]=c,e[75]=k,e[76]=E,e[77]=W,e[78]=R):R=e[78],R},"InstrumentsTable"),Pe=d(s=>s>=100?"critical":s>=50?"warning":"good","performanceLevel"),We=d(s=>s<1?`${(s*1e3).toFixed(0)}\u03BCs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,"formatLatency"),Oe=d(s=>s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString(),"formatCount"),_t=d(s=>{let e=(0,Fe.c)(3),{level:l}=s;if(l==="critical"){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsxDEV)(He,{variant:"destructive",children:"Slow"},void 0,!1),e[0]=o):o=e[0],o}if(l==="warning"){let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"},void 0,!1),e[1]=o):o=e[1],o}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"},void 0,!1),e[2]=r):r=e[2],r},"PerformanceBadge"),Ct=d(s=>{let e=(0,Fe.c)(152),{queryStats:l}=s,r=Ee(),[o,U]=(0,_.useState)("totalTime"),M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M=new Set,e[0]=M):M=e[0];let[g,y]=(0,_.useState)(M),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=d(n=>{n!==null&&U(n)},"t2"),e[1]=v):v=e[1];let p=v,u;if(e[2]!==l||e[3]!==o){u=[...l];let n;e[5]!==o?(n=d((T,N)=>{switch(o){case"avgTime":return N.avgDurationMs-T.avgDurationMs;case"execCount":return N.execCount-T.execCount;case"rowsRead":return N.rowsRead-T.rowsRead;default:return N.totalDurationMs-T.totalDurationMs}},"t310"),e[5]=o,e[6]=n):n=e[6],u.sort(n),e[2]=l,e[3]=o,e[4]=u}else u=e[4];let c=u,C;e[7]!==l?(C=l.filter($t),e[7]=l,e[8]=C):C=e[8];let z=C.length,B;e[9]!==l?(B=l.filter(Rt),e[9]=l,e[10]=B):B=e[10];let i=B.length,q;e[11]!==l?(q=l.filter(Mt),e[11]=l,e[12]=q):q=e[12];let O=q.length,E;e[13]===Symbol.for("react.memo_cache_sentinel")?(E=d(n=>{y(T=>{let N=new Set(T);return N.has(n)?N.delete(n):N.add(n),N})},"t6"),e[13]=E):E=e[13];let W=E;if(l.length===0){let n;e[14]!==r?(n=r("No query insights yet"),e[14]=r,e[15]=n):n=e[15];let T;e[16]!==n?(T=(0,t.jsxDEV)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:n},void 0,!1),e[16]=n,e[17]=T):T=e[17];let N;e[18]!==r?(N=r("Query insights appear once statements are executed against this shard."),e[18]=r,e[19]=N):N=e[19];let re;e[20]!==N?(re=(0,t.jsxDEV)("p",{className:"mt-1 text-sm",children:N},void 0,!1),e[20]=N,e[21]=re):re=e[21];let Le;return e[22]!==re||e[23]!==T?(Le=(0,t.jsxDEV)(ee,{children:(0,t.jsxDEV)(le,{className:"py-12",children:(0,t.jsxDEV)("div",{className:"text-center text-muted-foreground",children:[T,re]},void 0,!0)},void 0,!1)},void 0,!1),e[22]=re,e[23]=T,e[24]=Le):Le=e[24],Le}let I;e[25]!==r?(I=r("Critical queries"),e[25]=r,e[26]=I):I=e[26];let m;e[27]!==I?(m=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(Me,{className:"text-sm font-medium",children:I},void 0,!1)},void 0,!1),e[27]=I,e[28]=m):m=e[28];let $;e[29]!==z?($=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:z},void 0,!1),e[29]=z,e[30]=$):$=e[30];let k;e[31]!==r?(k=r(">100ms avg execution"),e[31]=r,e[32]=k):k=e[32];let R;e[33]!==k?(R=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:k},void 0,!1),e[33]=k,e[34]=R):R=e[34];let V;e[35]!==R||e[36]!==$?(V=(0,t.jsxDEV)(le,{children:[$,R]},void 0,!0),e[35]=R,e[36]=$,e[37]=V):V=e[37];let S;e[38]!==V||e[39]!==m?(S=(0,t.jsxDEV)(ee,{children:[m,V]},void 0,!0),e[38]=V,e[39]=m,e[40]=S):S=e[40];let w;e[41]!==r?(w=r("Moderate queries"),e[41]=r,e[42]=w):w=e[42];let F;e[43]!==w?(F=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(Me,{className:"text-sm font-medium",children:w},void 0,!1)},void 0,!1),e[43]=w,e[44]=F):F=e[44];let D;e[45]!==i?(D=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:i},void 0,!1),e[45]=i,e[46]=D):D=e[46];let A;e[47]!==r?(A=r("50\u2013100ms avg execution"),e[47]=r,e[48]=A):A=e[48];let L;e[49]!==A?(L=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:A},void 0,!1),e[49]=A,e[50]=L):L=e[50];let a;e[51]!==D||e[52]!==L?(a=(0,t.jsxDEV)(le,{children:[D,L]},void 0,!0),e[51]=D,e[52]=L,e[53]=a):a=e[53];let b;e[54]!==F||e[55]!==a?(b=(0,t.jsxDEV)(ee,{children:[F,a]},void 0,!0),e[54]=F,e[55]=a,e[56]=b):b=e[56];let h;e[57]!==r?(h=r("Fast queries"),e[57]=r,e[58]=h):h=e[58];let x;e[59]!==h?(x=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(Me,{className:"text-sm font-medium",children:h},void 0,!1)},void 0,!1),e[59]=h,e[60]=x):x=e[60];let P;e[61]!==O?(P=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:O},void 0,!1),e[61]=O,e[62]=P):P=e[62];let Q;e[63]!==r?(Q=r("<50ms avg execution"),e[63]=r,e[64]=Q):Q=e[64];let H;e[65]!==Q?(H=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:Q},void 0,!1),e[65]=Q,e[66]=H):H=e[66];let K;e[67]!==P||e[68]!==H?(K=(0,t.jsxDEV)(le,{children:[P,H]},void 0,!0),e[67]=P,e[68]=H,e[69]=K):K=e[69];let j;e[70]!==x||e[71]!==K?(j=(0,t.jsxDEV)(ee,{children:[x,K]},void 0,!0),e[70]=x,e[71]=K,e[72]=j):j=e[72];let X;e[73]!==S||e[74]!==b||e[75]!==j?(X=(0,t.jsxDEV)("div",{className:"grid gap-4 md:grid-cols-3",children:[S,b,j]},void 0,!0),e[73]=S,e[74]=b,e[75]=j,e[76]=X):X=e[76];let f;e[77]!==r?(f=r("Query leaderboard"),e[77]=r,e[78]=f):f=e[78];let Y;e[79]!==f?(Y=(0,t.jsxDEV)("h3",{className:"text-lg font-semibold",children:f},void 0,!1),e[79]=f,e[80]=Y):Y=e[80];let te;e[81]!==o||e[82]!==r?(te=r("Slow queries sorted by {sortField}",{sortField:r(o)}),e[81]=o,e[82]=r,e[83]=te):te=e[83];let se;e[84]!==te?(se=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:te},void 0,!1),e[84]=te,e[85]=se):se=e[85];let ae;e[86]!==Y||e[87]!==se?(ae=(0,t.jsxDEV)("div",{children:[Y,se]},void 0,!0),e[86]=Y,e[87]=se,e[88]=ae):ae=e[88];let ie;e[89]!==r?(ie=r("Sort by"),e[89]=r,e[90]=ie):ie=e[90];let oe;e[91]!==ie?(oe=(0,t.jsxDEV)("span",{className:"text-sm text-muted-foreground",children:ie},void 0,!1),e[91]=ie,e[92]=oe):oe=e[92];let ne;e[93]!==r?(ne=r("Sort queries by"),e[93]=r,e[94]=ne):ne=e[94];let De;e[95]===Symbol.for("react.memo_cache_sentinel")?(De=(0,t.jsxDEV)(ct,{},void 0,!1),e[95]=De):De=e[95];let de;e[96]!==ne?(de=(0,t.jsxDEV)(ft,{"aria-label":ne,className:"w-[140px]","data-testid":"qi-sort",children:De},void 0,!1),e[96]=ne,e[97]=de):de=e[97];let ce;e[98]!==r?(ce=r("Total time"),e[98]=r,e[99]=ce):ce=e[99];let fe;e[100]!==ce?(fe=(0,t.jsxDEV)(ke,{value:"totalTime",children:ce},void 0,!1),e[100]=ce,e[101]=fe):fe=e[101];let ue;e[102]!==r?(ue=r("Avg time"),e[102]=r,e[103]=ue):ue=e[103];let me;e[104]!==ue?(me=(0,t.jsxDEV)(ke,{value:"avgTime",children:ue},void 0,!1),e[104]=ue,e[105]=me):me=e[105];let ve;e[106]!==r?(ve=r("Execution count"),e[106]=r,e[107]=ve):ve=e[107];let he;e[108]!==ve?(he=(0,t.jsxDEV)(ke,{value:"execCount",children:ve},void 0,!1),e[108]=ve,e[109]=he):he=e[109];let ge;e[110]!==r?(ge=r("Rows read"),e[110]=r,e[111]=ge):ge=e[111];let xe;e[112]!==ge?(xe=(0,t.jsxDEV)(ke,{value:"rowsRead",children:ge},void 0,!1),e[112]=ge,e[113]=xe):xe=e[113];let pe;e[114]!==fe||e[115]!==me||e[116]!==he||e[117]!==xe?(pe=(0,t.jsxDEV)(ut,{children:[fe,me,he,xe]},void 0,!0),e[114]=fe,e[115]=me,e[116]=he,e[117]=xe,e[118]=pe):pe=e[118];let be;e[119]!==o||e[120]!==de||e[121]!==pe?(be=(0,t.jsxDEV)(dt,{onValueChange:p,value:o,children:[de,pe]},void 0,!0),e[119]=o,e[120]=de,e[121]=pe,e[122]=be):be=e[122];let Ne;e[123]!==oe||e[124]!==be?(Ne=(0,t.jsxDEV)("div",{className:"flex items-center gap-2",children:[oe,be]},void 0,!0),e[123]=oe,e[124]=be,e[125]=Ne):Ne=e[125];let ye;e[126]!==ae||e[127]!==Ne?(ye=(0,t.jsxDEV)("div",{className:"flex items-center justify-between",children:[ae,Ne]},void 0,!0),e[126]=ae,e[127]=Ne,e[128]=ye):ye=e[128];let Se;e[129]!==r?(Se=r("Statements"),e[129]=r,e[130]=Se):Se=e[130];let we;e[131]!==Se?(we=(0,t.jsxDEV)(Me,{children:Se},void 0,!1),e[131]=Se,e[132]=we):we=e[132];let qe;e[133]!==c.length||e[134]!==r?(qe=r("{count} tracked statements",{count:c.length}),e[133]=c.length,e[134]=r,e[135]=qe):qe=e[135];let Te;e[136]!==qe?(Te=(0,t.jsxDEV)(Ye,{children:qe},void 0,!1),e[136]=qe,e[137]=Te):Te=e[137];let _e;e[138]!==we||e[139]!==Te?(_e=(0,t.jsxDEV)(Re,{children:[we,Te]},void 0,!0),e[138]=we,e[139]=Te,e[140]=_e):_e=e[140];let Ce;e[141]!==g||e[142]!==c||e[143]!==r?(Ce=(0,t.jsxDEV)(le,{children:(0,t.jsxDEV)("div",{className:"space-y-2",children:c.map(n=>{let T=n.normalizedSql,N=g.has(T),re=Pe(n.avgDurationMs);return(0,t.jsxDEV)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxDEV)("button",{"aria-expanded":N,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:d(()=>{W(T)},"onClick"),type:"button",children:[(0,t.jsxDEV)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsxDEV)(_t,{level:re},void 0,!1),(0,t.jsxDEV)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:n.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:We(n.totalDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("total")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:We(n.avgDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("avg")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:Oe(n.execCount)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("calls")},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),N&&(0,t.jsxDEV)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")},void 0,!1),(0,t.jsxDEV)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:n.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Exec count")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Oe(n.execCount)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Total time")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:We(n.totalDurationMs)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows read")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Oe(n.rowsRead)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows written")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Oe(n.rowsWritten)},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},T,!0)})},void 0,!1)},void 0,!1),e[141]=g,e[142]=c,e[143]=r,e[144]=Ce):Ce=e[144];let $e;e[145]!==_e||e[146]!==Ce?($e=(0,t.jsxDEV)(ee,{children:[_e,Ce]},void 0,!0),e[145]=_e,e[146]=Ce,e[147]=$e):$e=e[147];let Ae;return e[148]!==X||e[149]!==ye||e[150]!==$e?(Ae=(0,t.jsxDEV)("div",{className:"space-y-4","data-testid":"qi-root",children:[X,ye,$e]},void 0,!0),e[148]=X,e[149]=ye,e[150]=$e,e[151]=Ae):Ae=e[151],Ae},"QueryInsights");function $t(s){return Pe(s.avgDurationMs)==="critical"}d($t,"_temp");function Rt(s){return Pe(s.avgDurationMs)==="warning"}d(Rt,"_temp2");function Mt(s){return Pe(s.avgDurationMs)==="good"}d(Mt,"_temp3");var It=Ze(Be.getMetrics),kt=d(s=>{let e=Math.floor(s/1e3),l=Math.floor(e/3600),r=Math.floor(e%3600/60),o=e%60;return l>0?`${l.toString()}h ${r.toString()}m`:r>0?`${r.toString()}m ${o.toString()}s`:`${o.toString()}s`},"formatDuration"),Ft=d((s,e)=>s?e:"overview","resolveTab"),Dt=d((s,e)=>{let l=s+e;return l===0?"\u2014":`${(s/l*100).toFixed(1)}%`},"hitRate"),J=d(s=>{let e=(0,Fe.c)(16),{chart:l,footer:r,label:o,testId:U,value:M}=s,g;e[0]!==o?(g=(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o},void 0,!1),e[0]=o,e[1]=g):g=e[1];let y;e[2]!==U||e[3]!==M?(y=(0,t.jsxDEV)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":U,children:M},void 0,!1),e[2]=U,e[3]=M,e[4]=y):y=e[4];let v;e[5]!==l||e[6]!==y?(v=(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[y,l]},void 0,!0),e[5]=l,e[6]=y,e[7]=v):v=e[7];let p;e[8]!==g||e[9]!==v?(p=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,v]},void 0,!0),e[8]=g,e[9]=v,e[10]=p):p=e[10];let u;e[11]!==r?(u=r!=null&&(0,t.jsxDEV)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r},void 0,!1),e[11]=r,e[12]=u):u=e[12];let c;return e[13]!==p||e[14]!==u?(c=(0,t.jsxDEV)(ee,{className:"justify-between gap-0 py-0",children:[p,u]},void 0,!0),e[13]=p,e[14]=u,e[15]=c):c=e[15],c},"StatCard"),Zt=d(({initialShardKey:s})=>{let e=Xe(),l=Ee(),[r,o]=(0,_.useState)(s??""),[U,M]=(0,_.useState)("overview"),[g,y]=(0,_.useState)([]),v=(0,_.useRef)(null),p=(0,_.useRef)(null),u=(0,_.useRef)(!0);(0,_.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let c=it(r.trim(),400),{data:C,error:z,liveError:B}=je(Be.getMetrics,{},{live:!0,shardKey:c}),i=C??null;(0,_.useEffect)(()=>{if(C===void 0)return;st(c);let a=C,b=v.current,h=p.current!==null&&p.current!==a.shard;if(p.current=a.shard,v.current=a.requests,h){y([]);return}b!==null&&a.requests>=b&&y(x=>[...x,a.requests-b].slice(-30))},[C,c]);let[q,O]=(0,_.useState)(null),[E,W]=(0,_.useState)(!1),I=d(async()=>{W(!0);let a=ht(r,lt());try{let b=await Promise.all(a.map(async h=>{try{let x=await e.query(It,{},et(h));return{error:null,metrics:x,shard:h===""?x.shard:h}}catch(x){return{error:tt(x),metrics:null,shard:h===""?"__root__":h}}}));u.current&&O(b)}finally{u.current&&W(!1)}},"aggregateAll"),m=q===null?null:vt(q),$=i===null||i.requests===0?"\u2014":`${(i.errors/i.requests*100).toFixed(1)}%`,k=g.length>0?g.at(-1):0,R=i?gt(i):{p90:0,p95:0},V=d(a=>a<=0?"\u2014":a<1?`${(a*1e3).toFixed(0)}\u03BCs`:a<1e3?`${a.toFixed(1)}ms`:`${(a/1e3).toFixed(2)}s`,"formatMs"),S=(0,_.useMemo)(()=>{if(!i||!("queryStats"in i))return;let a=i.queryStats;if(!(!a||!Array.isArray(a)))return xt(a)},[i]),w=Ft(S!==void 0,U),F=d(()=>{rt(I())},"runAggregate"),D=d(()=>{O(null)},"clearAggregate"),A=d(()=>{M("overview")},"switchToOverview"),L=d(()=>{M("query-insights")},"switchToQueryInsights");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(at,{onChange:o,testId:"mt-shard-input",value:r},void 0,!1),(0,t.jsxDEV)(ot,{message:B,prefix:"mt"},void 0,!1),(0,t.jsxDEV)(Ke,{"data-testid":"mt-aggregate",disabled:E,onClick:F,size:"sm",type:"button",variant:"secondary",children:l(E?"Aggregating\u2026":"All shards")},void 0,!1),q!==null&&(0,t.jsxDEV)(Ke,{"data-testid":"mt-aggregate-clear",onClick:D,size:"sm",type:"button",variant:"ghost",children:l("Hide")},void 0,!1),(0,t.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:nt,rel:"noreferrer",target:"_blank",children:l("Open in Cloudflare")},void 0,!1)]},void 0,!0),z!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:z},void 0,!1),S!==void 0&&(0,t.jsxDEV)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${w==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:A,type:"button",children:l("Overview")},void 0,!1),(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${w==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:L,type:"button",children:[l("Query insights"),S.length>0&&(0,t.jsxDEV)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:S.length},void 0,!1)]},void 0,!0)]},void 0,!0),w==="query-insights"&&S!==void 0&&(0,t.jsxDEV)(Ct,{queryStats:S},void 0,!1),w==="overview"&&i!==null&&(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[(0,t.jsxDEV)(J,{chart:g.length>=2?(0,t.jsxDEV)(pt,{ariaLabel:l("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:g,testId:"mt-sparkline"},void 0,!1):void 0,footer:g.length>=2?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("span",{className:"font-semibold text-foreground",children:`+${k.toLocaleString()}`},void 0,!1)," ",l("last interval")]},void 0,!0):(0,t.jsxDEV)("span",{"data-testid":"mt-sparkline-empty",children:l("collecting samples\u2026")},void 0,!1),label:l("Requests"),testId:"mt-requests",value:i.requests},void 0,!1),(0,t.jsxDEV)(J,{footer:l("{rate} error rate",{rate:$}),label:l("Errors"),testId:"mt-errors",value:(0,t.jsxDEV)(t.Fragment,{children:[i.errors," (",$,")"]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(J,{footer:R.p90>0?`P90 ${V(R.p90)}`:void 0,label:l("P95 latency"),testId:"mt-p95",value:R.p95>0?V(R.p95):"\u2014"},void 0,!1),(0,t.jsxDEV)(J,{footer:i.cache===null?void 0:`${i.cache.entries.toLocaleString()} ${l("cache entries")}`,label:l("Database size"),testId:"mt-db-size",value:ze(i.databaseSize)},void 0,!1),(0,t.jsxDEV)(J,{label:l("Shard"),testId:"mt-shard",value:i.shard},void 0,!1),(0,t.jsxDEV)(J,{label:l("Uptime"),testId:"mt-uptime",value:kt(i.uptimeMs)},void 0,!1),(0,t.jsxDEV)(J,{label:l("Cache hit rate"),testId:"mt-cache",value:i.cache===null?l("no cache configured"):l("{rate} ({count} entries)",{count:i.cache.entries,rate:Dt(i.cache.hits,i.cache.misses)})},void 0,!1)]},void 0,!0),w==="overview"&&i===null&&null,w==="overview"&&(0,t.jsxDEV)(Tt,{shardKey:c},void 0,!1),w==="overview"&&m!==null&&q!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[(0,t.jsxDEV)(J,{label:l("Shards"),testId:"mt-agg-shards",value:m.failed>0?l("{reachable} reachable, {failed} unreachable",{failed:m.failed,reachable:m.reachable}):l("{reachable} reachable",{reachable:m.reachable})},void 0,!1),(0,t.jsxDEV)(J,{label:l("Total requests"),testId:"mt-agg-requests",value:m.totalRequests},void 0,!1),(0,t.jsxDEV)(J,{label:l("Total errors"),testId:"mt-agg-errors",value:m.totalErrors},void 0,!1),(0,t.jsxDEV)(J,{label:l("Total database size"),testId:"mt-agg-db-size",value:ze(m.totalDatabaseSize)},void 0,!1),(0,t.jsxDEV)(J,{label:l("Combined cache hit rate"),testId:"mt-agg-cache",value:m.hitRate===null?l("no cache configured"):`${(m.hitRate*100).toFixed(1)}%`},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(ee,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(le,{className:"px-0",children:(0,t.jsxDEV)(Ue,{"data-testid":"mt-agg-table",children:[(0,t.jsxDEV)(Ve,{children:(0,t.jsxDEV)(Ie,{children:[(0,t.jsxDEV)(Z,{children:l("shard")},void 0,!1),(0,t.jsxDEV)(Z,{children:l("requests")},void 0,!1),(0,t.jsxDEV)(Z,{children:l("errors")},void 0,!1),(0,t.jsxDEV)(Z,{children:l("db size")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Ge,{children:q.map(a=>(0,t.jsxDEV)(Ie,{"data-testid":`mt-agg-row-${a.shard}`,children:[(0,t.jsxDEV)(G,{children:a.shard},void 0,!1),a.metrics===null?(0,t.jsxDEV)(G,{className:"text-destructive",colSpan:3,children:a.error??l("unreachable")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(G,{className:"tabular-nums",children:a.metrics.requests},void 0,!1),(0,t.jsxDEV)(G,{className:"tabular-nums",children:a.metrics.errors},void 0,!1),(0,t.jsxDEV)(G,{className:"tabular-nums",children:ze(a.metrics.databaseSize)},void 0,!1)]},void 0,!0)]},a.shard,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"MetricsPanel");export{Zt as MetricsPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Pe}from"./chunk-VLXV72QE.js";import{a as xe}from"./chunk-JSEXCW5Q.js";import{a as X}from"./chunk-KZ6INM5M.js";import{d as we,f as Oe,g as $e,k as ae}from"./chunk-4QHKBC77.js";import{a as Ae}from"./chunk-FDWXYXOM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as ke}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as H}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as Se}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as Ce}from"./chunk-
|
|
1
|
+
import{a as Pe}from"./chunk-VLXV72QE.js";import{a as xe}from"./chunk-JSEXCW5Q.js";import{a as X}from"./chunk-KZ6INM5M.js";import{d as we,f as Oe,g as $e,k as ae}from"./chunk-4QHKBC77.js";import{a as Ae}from"./chunk-FDWXYXOM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as ke}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as H}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as Se}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as Ce}from"./chunk-MHGJUKCZ.js";import{f as G}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as W}from"./chunk-TAD43CG5.js";import{d as M,e as Ie,f as le,g as de,h as ce,l as Te,n as re}from"./chunk-5XO36X4C.js";import{b as Ne}from"./chunk-ZXLEXF4X.js";import{a as p,e as q,f as he,g as oe,h as ne,j as ge}from"./chunk-RRCPZMC2.js";var Ye=q(oe(),1),ye=q(he(),1);var ee=q(oe(),1);var Z=q(he(),1);var B=q(ne(),1);var Qe=le(Ce.listTables),Xe=["react","client","cli"],Ze=!1,et={action:"action",mutation:"mutation",query:"query"},Re=p(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"splitPath"),_e=p(({file:t,fn:e,kind:o})=>`await client.${et[o]}(api.${t}.${e}, { /* args */ });`,"buildClientSnippet"),tt=p(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return _e(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"buildReactSnippet"),st=p(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"buildCliSnippet"),ot=p(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
|
|
2
2
|
`),"buildTableSnippet"),nt=p((t,e)=>{switch(t){case"cli":return st(e);case"client":return _e(e);default:return tt(e)}},"snippetForTab"),je=p(t=>{let e=(0,ee.c)(19),{code:o,label:s,testId:n}=t,r=M(),l;e[0]!==o?(l=p(()=>{re(o)},"t1"),e[0]=o,e[1]=l):l=e[1];let i=l,d;e[2]!==s?(d=(0,B.jsxDEV)("span",{className:"text-xs font-medium text-muted-foreground",children:s},void 0,!1),e[2]=s,e[3]=d):d=e[3];let c=`${n}-copy`,m;e[4]!==r?(m=r("Copy"),e[4]=r,e[5]=m):m=e[5];let a;e[6]!==i||e[7]!==c||e[8]!==m?(a=(0,B.jsxDEV)(H,{"data-testid":c,onClick:i,size:"xs",type:"button",variant:"ghost",children:m},void 0,!1),e[6]=i,e[7]=c,e[8]=m,e[9]=a):a=e[9];let u;e[10]!==d||e[11]!==a?(u=(0,B.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[d,a]},void 0,!0),e[10]=d,e[11]=a,e[12]=u):u=e[12];let v;e[13]!==o||e[14]!==n?(v=(0,B.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:o},void 0,!1),e[13]=o,e[14]=n,e[15]=v):v=e[15];let S;return e[16]!==u||e[17]!==v?(S=(0,B.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[u,v]},void 0,!0),e[16]=u,e[17]=v,e[18]=S):S=e[18],S},"SnippetBlock"),rt=p(t=>{let e=(0,ee.c)(50),{file:o,fn:s,kind:n}=t,r=M(),[l,i]=(0,Z.useState)("react"),d,c,m;if(e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==r||e[4]!==l){let I={file:o,fn:s,kind:n},$;e[8]!==r?($=r("CLI"),e[8]=r,e[9]=$):$=e[9];let P;e[10]!==r?(P=r("Client"),e[10]=r,e[11]=P):P=e[11];let E;e[12]!==r?(E=r("React"),e[12]=r,e[13]=E):E=e[13];let j;e[14]!==$||e[15]!==P||e[16]!==E?(j={cli:$,client:P,react:E},e[14]=$,e[15]=P,e[16]=E,e[17]=j):j=e[17],m=j;let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=p(L=>{i(L.currentTarget.dataset.tab)},"t62"),e[18]=R):R=e[18],d=R,c=nt(l,I),e[0]=o,e[1]=s,e[2]=n,e[3]=r,e[4]=l,e[5]=d,e[6]=c,e[7]=m}else d=e[5],c=e[6],m=e[7];let a=c,u=n==="action"&&l==="react"&&!Ze,v=`api.${o}.${s}`,S;e[19]!==v?(S=(0,B.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:v},void 0,!1),e[19]=v,e[20]=S):S=e[20];let O;e[21]!==n||e[22]!==r?(O=r("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=r,e[23]=O):O=e[23];let h;e[24]!==O?(h=(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:O},void 0,!1),e[24]=O,e[25]=h):h=e[25];let g;e[26]!==S||e[27]!==h?(g=(0,B.jsxDEV)("div",{children:[S,h]},void 0,!0),e[26]=S,e[27]=h,e[28]=g):g=e[28];let x;e[29]!==r?(x=r("Snippet flavour"),e[29]=r,e[30]=x):x=e[30];let b;e[31]!==d||e[32]!==l||e[33]!==m?(b=Xe.map(I=>(0,B.jsxDEV)(H,{"aria-selected":l===I,"data-tab":I,"data-testid":`api-tab-${I}`,onClick:d,role:"tab",size:"xs",type:"button",variant:l===I?"default":"outline",children:m[I]},I,!1)),e[31]=d,e[32]=l,e[33]=m,e[34]=b):b=e[34];let y;e[35]!==x||e[36]!==b?(y=(0,B.jsxDEV)("div",{"aria-label":x,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:b},void 0,!1),e[35]=x,e[36]=b,e[37]=y):y=e[37];let N=m[l],T=`api-snippet-${l}`,k;e[38]!==a||e[39]!==N||e[40]!==T?(k=(0,B.jsxDEV)(je,{code:a,label:N,testId:T},void 0,!1),e[38]=a,e[39]=N,e[40]=T,e[41]=k):k=e[41];let w;e[42]!==u||e[43]!==r?(w=u&&(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:r("Actions have no React hook \u2014 call them through the client.")},void 0,!1),e[42]=u,e[43]=r,e[44]=w):w=e[44];let C;return e[45]!==k||e[46]!==w||e[47]!==g||e[48]!==y?(C=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[g,y,k,w]},void 0,!0),e[45]=k,e[46]=w,e[47]=g,e[48]=y,e[49]=C):C=e[49],C},"FunctionDoc"),it=p(t=>{let e=(0,ee.c)(19),{name:o}=t,s=M(),n;e[0]!==o?(n=ot(o),e[0]=o,e[1]=n):n=e[1];let r=n,l;e[2]!==o?(l=(0,B.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:o},void 0,!1),e[2]=o,e[3]=l):l=e[3];let i;e[4]!==s?(i=s("Read and write this table through the typed data model."),e[4]=s,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:i},void 0,!1),e[6]=i,e[7]=d):d=e[7];let c;e[8]!==l||e[9]!==d?(c=(0,B.jsxDEV)("div",{children:[l,d]},void 0,!0),e[8]=l,e[9]=d,e[10]=c):c=e[10];let m;e[11]!==s?(m=s("Data model"),e[11]=s,e[12]=m):m=e[12];let a;e[13]!==r||e[14]!==m?(a=(0,B.jsxDEV)(je,{code:r,label:m,testId:"api-snippet-table"},void 0,!1),e[13]=r,e[14]=m,e[15]=a):a=e[15];let u;return e[16]!==c||e[17]!==a?(u=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,a]},void 0,!0),e[16]=c,e[17]=a,e[18]=u):u=e[18],u},"TableDoc"),Ee=p(t=>{let e=(0,ee.c)(8),{active:o,label:s,onSelect:n,testId:r,value:l}=t,i;e[0]!==n||e[1]!==l?(i=p(()=>{n(l)},"t1"),e[0]=n,e[1]=l,e[2]=i):i=e[2];let d=i,c=o?"page":void 0,m;return e[3]!==s||e[4]!==d||e[5]!==c||e[6]!==r?(m=(0,B.jsxDEV)("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":r,onClick:d,type:"button",children:s},void 0,!1),e[3]=s,e[4]=d,e[5]=c,e[6]=r,e[7]=m):m=e[7],m},"RailButton"),Le=p(t=>{let e=(0,ee.c)(67),{functions:o,initialShardKey:s}=t,n=M(),r=G(),[l,i]=(0,Z.useState)(null),[d,c]=(0,Z.useState)(null),m,a;e[0]!==r||e[1]!==s?(m=p(()=>{let _=!1;return r.query(Qe,{},de(s??"")).then(D=>(_||i(D),D)).catch(()=>{_||i([])}),()=>{_=!0}},"t1"),a=[r,s],e[0]=r,e[1]=s,e[2]=m,e[3]=a):(m=e[2],a=e[3]),(0,Z.useEffect)(m,a);let u;e[4]!==o?(u=o??[],e[4]=o,e[5]=u):u=e[5];let v=u,S;if(e[6]!==v){let _=new Map;for(let D of v){let{file:V,fn:U}=Re(D.path),ie=_.get(V)??[];ie.push({fn:U,kind:D.kind,path:D.path}),_.set(V,ie)}S=[..._.entries()].map(lt).toSorted(dt),e[6]=v,e[7]=S}else S=e[7];let O=S,h,g,x,b,y,N,T,k,w,C;if(e[8]!==v||e[9]!==O||e[10]!==d||e[11]!==n||e[12]!==l){let _=(l??[]).map(ct).toSorted(ft),D;e[23]===Symbol.for("react.memo_cache_sentinel")?(D=p(F=>{c({kind:"fn",path:F})},"t122"),e[23]=D):D=e[23];let V=D,U;e[24]===Symbol.for("react.memo_cache_sentinel")?(U=p(F=>{c({kind:"table",name:F})},"t132"),e[24]=U):U=e[24];let ie=U;if(g=d?.kind==="fn"?v.find(F=>F.path===d.path):void 0,h=v.length>0||_.length>0,x=g===void 0?void 0:Re(g.path),b="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",y="lunora-api-docs",e[25]!==n?(N=n("API resources"),e[25]=n,e[26]=N):N=e[26],T="flex flex-col gap-4 overflow-y-auto",k="api-rail",e[27]!==O||e[28]!==d||e[29]!==n){let F;e[31]!==d||e[32]!==n?(F=p(ve=>(0,B.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,B.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:ve.file||n("(root)")},void 0,!1),ve.items.map(se=>(0,B.jsxDEV)(Ee,{active:d?.kind==="fn"&&d.path===se.path,label:se.fn,onSelect:V,testId:`api-rail-fn-${se.path}`,value:se.path},se.path,!1))]},ve.file,!0),"t142"),e[31]=d,e[32]=n,e[33]=F):F=e[33],w=O.map(F),e[27]=O,e[28]=d,e[29]=n,e[30]=w}else w=e[30];C=_.length>0&&(0,B.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,B.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")},void 0,!1),_.map(F=>(0,B.jsxDEV)(Ee,{active:d?.kind==="table"&&d.name===F,label:F,onSelect:ie,testId:`api-rail-table-${F}`,value:F},F,!1))]},void 0,!0),e[8]=v,e[9]=O,e[10]=d,e[11]=n,e[12]=l,e[13]=h,e[14]=g,e[15]=x,e[16]=b,e[17]=y,e[18]=N,e[19]=T,e[20]=k,e[21]=w,e[22]=C}else h=e[13],g=e[14],x=e[15],b=e[16],y=e[17],N=e[18],T=e[19],k=e[20],w=e[21],C=e[22];let I;e[34]!==h||e[35]!==n?(I=!h&&(0,B.jsxDEV)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")},void 0,!1),e[34]=h,e[35]=n,e[36]=I):I=e[36];let $;e[37]!==I||e[38]!==N||e[39]!==T||e[40]!==k||e[41]!==w||e[42]!==C?($=(0,B.jsxDEV)("nav",{"aria-label":N,className:T,"data-testid":k,children:[w,C,I]},void 0,!0),e[37]=I,e[38]=N,e[39]=T,e[40]=k,e[41]=w,e[42]=C,e[43]=$):$=e[43];let P;e[44]!==d||e[45]!==n?(P=d===null&&(0,B.jsxDEV)(W,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[44]=d,e[45]=n,e[46]=P):P=e[46];let E;e[47]!==d?.kind||e[48]!==g||e[49]!==x?(E=d?.kind==="fn"&&g!==void 0&&x!==void 0&&(0,B.jsxDEV)(rt,{file:x.file,fn:x.fn,kind:g.kind},g.path,!1),e[47]=d?.kind,e[48]=g,e[49]=x,e[50]=E):E=e[50];let j;e[51]!==d?.kind||e[52]!==g||e[53]!==n?(j=d?.kind==="fn"&&g===void 0&&(0,B.jsxDEV)(W,{testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[51]=d?.kind,e[52]=g,e[53]=n,e[54]=j):j=e[54];let R;e[55]!==d?(R=d?.kind==="table"&&(0,B.jsxDEV)(it,{name:d.name},void 0,!1),e[55]=d,e[56]=R):R=e[56];let L;e[57]!==P||e[58]!==E||e[59]!==j||e[60]!==R?(L=(0,B.jsxDEV)("div",{className:"min-w-0",children:[P,E,j,R]},void 0,!0),e[57]=P,e[58]=E,e[59]=j,e[60]=R,e[61]=L):L=e[61];let A;return e[62]!==b||e[63]!==y||e[64]!==$||e[65]!==L?(A=(0,B.jsxDEV)("div",{className:b,"data-testid":y,children:[$,L]},void 0,!0),e[62]=b,e[63]=y,e[64]=$,e[65]=L,e[66]=A):A=e[66],A},"ApiDocsPanel");function at(t,e){return t.fn.localeCompare(e.fn)}p(at,"_temp");function lt(t){let[e,o]=t;return{file:e,items:o.toSorted(at)}}p(lt,"_temp2");function dt(t,e){return t.file.localeCompare(e.file)}p(dt,"_temp3");function ct(t){return t.name}p(ct,"_temp4");function ft(t,e){return t.localeCompare(e)}p(ft,"_temp5");var ze=q(oe(),1);var J=q(oe(),1),K=q(he(),1);var f=q(ne(),1);var ue=p(function(t,e,o){let s=(0,J.c)(10),n;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},s[0]=n):n=s[0];let[r,l]=(0,K.useState)(n),i,d;s[1]!==o||s[2]!==e||s[3]!==t?(i=p(()=>{if(t!==void 0)return;let m=!1;return e().then(a=>(m||l(o(a)),a)).catch(a=>{m||l({kind:"error",message:ce(a)})}),()=>{m=!0}},"t1"),d=[o,e,t],s[1]=o,s[2]=e,s[3]=t,s[4]=i,s[5]=d):(i=s[4],d=s[5]),(0,K.useEffect)(i,d);let c;return s[6]!==o||s[7]!==r||s[8]!==t?(c=t===void 0?r:o(t),s[6]=o,s[7]=r,s[8]=t,s[9]=c):c=s[9],c},"useAdminSpec"),pt=p(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","scalarOf"),Me=p(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"enumValues"),pe=p(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>pe(e)).join(" | "):t.type==="array"?`array<${pe(t.items)}>`:t.type??"any","typeLabel"),ut=p(t=>{let e=Me(t);return e!==void 0?t.type??pt(e[0]):pe(t)},"fieldTypeLabel"),mt=p(t=>{let e=Me(t);return e===void 0?void 0:e.map(o=>JSON.stringify(o)).join(" | ")},"valueInText"),vt=p(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let o=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let s=e.length>(o?2:1);return o||s?e.join(" "):void 0},"rangeText"),ht=p(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"childObject"),te=p(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return te(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[o,s]of Object.entries(t.properties??{}))e[o]=te(s);return e}case"string":return"";default:return null}},"exampleForSchema"),fe=p(t=>{let e=(0,J.c)(7),{label:o,value:s}=t,n;e[0]!==o?(n=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:o},void 0,!1),e[0]=o,e[1]=n):n=e[1];let r;e[2]!==s?(r=(0,f.jsxDEV)("span",{className:"text-foreground",children:s},void 0,!1),e[2]=s,e[3]=r):r=e[3];let l;return e[4]!==n||e[5]!==r?(l=(0,f.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,r]},void 0,!0),e[4]=n,e[5]=r,e[6]=l):l=e[6],l},"Badge"),gt=p(t=>{let e=(0,J.c)(40),{name:o,required:s,schema:n}=t,r=M(),l;e[0]!==n?(l=vt(n),e[0]=n,e[1]=l):l=e[1];let i=l,d;e[2]!==n?(d=mt(n),e[2]=n,e[3]=d):d=e[3];let c=d,m=n["x-lunora-table"],a=n.format!==void 0||i!==void 0||c!==void 0||m!==void 0,u;e[4]!==n?(u=ht(n),e[4]=n,e[5]=u):u=e[5];let v=u,S=s?"*":"?",O;e[6]!==S?(O=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:S},void 0,!1),e[6]=S,e[7]=O):O=e[7];let h;e[8]!==o||e[9]!==O?(h=(0,f.jsxDEV)("span",{className:"font-mono text-foreground",children:[o,O]},void 0,!0),e[8]=o,e[9]=O,e[10]=h):h=e[10];let g;e[11]!==n?(g=ut(n),e[11]=n,e[12]=g):g=e[12];let x;e[13]!==g?(x=(0,f.jsxDEV)("span",{className:"font-mono text-muted-foreground",children:g},void 0,!1),e[13]=g,e[14]=x):x=e[14];let b;e[15]!==h||e[16]!==x?(b=(0,f.jsxDEV)("div",{className:"flex items-baseline gap-2",children:[h,x]},void 0,!0),e[15]=h,e[16]=x,e[17]=b):b=e[17];let y;e[18]!==n.description?(y=n.description!==void 0&&(0,f.jsxDEV)("p",{className:"max-w-prose text-muted-foreground",children:n.description},void 0,!1),e[18]=n.description,e[19]=y):y=e[19];let N;e[20]!==a||e[21]!==i||e[22]!==m||e[23]!==n.format||e[24]!==r||e[25]!==c?(N=a&&(0,f.jsxDEV)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,f.jsxDEV)(fe,{label:r("Format"),value:n.format},void 0,!1),i!==void 0&&(0,f.jsxDEV)(fe,{label:r("Range"),value:i},void 0,!1),c!==void 0&&(0,f.jsxDEV)(fe,{label:r("Value in"),value:c},void 0,!1),m!==void 0&&(0,f.jsxDEV)(fe,{label:r("relation"),value:m},void 0,!1)]},void 0,!0),e[20]=a,e[21]=i,e[22]=m,e[23]=n.format,e[24]=r,e[25]=c,e[26]=N):N=e[26];let T;e[27]!==y||e[28]!==N||e[29]!==b?(T=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1 py-2",children:[b,y,N]},void 0,!0),e[27]=y,e[28]=N,e[29]=b,e[30]=T):T=e[30];let k=T;if(v===void 0){let $;return e[31]!==k?($=(0,f.jsxDEV)("div",{className:"border-b border-border/50 last:border-b-0",children:k},void 0,!1),e[31]=k,e[32]=$):$=e[32],$}let w;e[33]!==k?(w=(0,f.jsxDEV)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:k},void 0,!1),e[33]=k,e[34]=w):w=e[34];let C;e[35]!==v?(C=(0,f.jsxDEV)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,f.jsxDEV)(Ke,{schema:v},void 0,!1)},void 0,!1),e[35]=v,e[36]=C):C=e[36];let I;return e[37]!==w||e[38]!==C?(I=(0,f.jsxDEV)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,C]},void 0,!0),e[37]=w,e[38]=C,e[39]=I):I=e[39],I},"FieldRow"),Ke=p(t=>{let e=(0,J.c)(7),{schema:o}=t,s;e[0]!==o.required?(s=new Set(o.required),e[0]=o.required,e[1]=s):s=e[1];let n=s,r;e[2]!==o.properties?(r=Object.entries(o.properties??{}),e[2]=o.properties,e[3]=r):r=e[3];let l=r,i;return e[4]!==n||e[5]!==l?(i=(0,f.jsxDEV)("div",{className:"flex flex-col",children:l.map(d=>{let[c,m]=d;return(0,f.jsxDEV)(gt,{name:c,required:n.has(c),schema:m},c,!1)})},void 0,!1),e[4]=n,e[5]=l,e[6]=i):i=e[6],i},"SchemaFields"),Be=p(t=>{let e=(0,J.c)(10),{schema:o,testId:s}=t;if(o?.type!=="object"||Object.keys(o.properties??{}).length===0){let l;e[0]!==o?(l=pe(o),e[0]=o,e[1]=l):l=e[1];let i;return e[2]!==l||e[3]!==s?(i=(0,f.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":s,children:l},void 0,!1),e[2]=l,e[3]=s,e[4]=i):i=e[4],i}let n;e[5]!==o?(n=(0,f.jsxDEV)(Ke,{schema:o},void 0,!1),e[5]=o,e[6]=n):n=e[6];let r;return e[7]!==n||e[8]!==s?(r=(0,f.jsxDEV)("div",{className:"text-xs","data-testid":s,children:n},void 0,!1),e[7]=n,e[8]=s,e[9]=r):r=e[9],r},"SchemaTable"),xt=["curl","javascript","lunora"],bt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},yt=p(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"apiReferenceOf"),Nt=p(t=>{let e=te(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"requestBody"),St=p((t,e,o)=>{let s=`${o}${e.httpPath}`,n=JSON.stringify(Nt(e),void 0,2),r=JSON.stringify(te(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let l=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(s)}`];return l&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
|
|
3
3
|
`)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
|
|
4
4
|
import { api } from "./_generated/api";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Q}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as F}from"./chunk-4F72YCTU.js";import{a as O,b as $,c as j,d as S,e as n,f as c}from"./chunk-GTM65MVX.js";import{a as B,e as D}from"./chunk-Y572GMZE.js";import{b as k}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as L}from"./chunk-
|
|
1
|
+
import{a as Q}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as F}from"./chunk-4F72YCTU.js";import{a as O,b as $,c as j,d as S,e as n,f as c}from"./chunk-GTM65MVX.js";import{a as B,e as D}from"./chunk-Y572GMZE.js";import{b as k}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as L}from"./chunk-MHGJUKCZ.js";import"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as _}from"./chunk-TAD43CG5.js";import{d as U}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as R,e as M,g as z,h as J}from"./chunk-RRCPZMC2.js";var q=M(z(),1);var l=M(J(),1);var V=["read","insert","update","delete"],K=R((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"operationLabel"),W=R(e=>{let s=new Map;for(let t of e){let r=s.get(t.table)??{operations:new Set,procedures:[],table:t.table};r.operations.add(t.on),r.procedures.includes(t.procedure)||r.procedures.push(t.procedure),s.set(t.table,r)}return[...s.values()].toSorted((t,r)=>t.table.localeCompare(r.table))},"groupByTable"),ie=R(()=>{let e=(0,q.c)(49),s=U(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];let{data:r,error:C,errorSource:I}=F(L.rlsPolicies,t),f=r!==void 0,p,d,m,a,u,h,v,b,o;if(e[1]!==r||e[2]!==C||e[3]!==I||e[4]!==f||e[5]!==s){let G=W(Array.isArray(r?.policies)?r.policies:[]),P;e[15]!==r?(P=Array.isArray(r?.roles)?r.roles:[],e[15]=r,e[16]=P):P=e[16],d=P,v="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(o=C!==null&&(0,l.jsxDEV)(Q,{error:I,testId:"rls-error"},void 0,!1),e[17]=C,e[18]=I,e[19]=o):o=e[19],h="flex flex-col gap-2",p=B,m="overflow-hidden py-0";let A;e[20]!==s?(A=s("Policies"),e[20]=s,e[21]=A):A=e[21],e[22]!==A?(a=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A},void 0,!1)},void 0,!1),e[22]=A,e[23]=a):a=e[23],u=f&&G.length===0?(0,l.jsxDEV)(_,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-policies-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Table")},void 0,!1),V.map(i=>(0,l.jsxDEV)(n,{children:K(s,i)},i,!1)),(0,l.jsxDEV)(n,{children:s("Guarded by")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:G.map(i=>(0,l.jsxDEV)(S,{"data-testid":`rls-table-${i.table}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:i.table},void 0,!1),V.map(H=>(0,l.jsxDEV)(c,{children:i.operations.has(H)?(0,l.jsxDEV)(k,{variant:"secondary",children:s("Guarded")},void 0,!1):(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1)},H,!1)),(0,l.jsxDEV)(c,{className:"font-mono text-xs text-muted-foreground",children:i.procedures.join(", ")},void 0,!1)]},i.table,!0))},void 0,!1)]},void 0,!0)},void 0,!1),e[1]=r,e[2]=C,e[3]=I,e[4]=f,e[5]=s,e[6]=p,e[7]=d,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=v,e[13]=b,e[14]=o}else p=e[6],d=e[7],m=e[8],a=e[9],u=e[10],h=e[11],v=e[12],b=e[13],o=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==u?(x=(0,l.jsxDEV)(p,{className:m,children:[a,u]},void 0,!0),e[24]=p,e[25]=m,e[26]=a,e[27]=u,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=(0,l.jsxDEV)("section",{className:h,children:x},void 0,!1),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let g;e[34]!==y?(g=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1)},void 0,!1),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==f||e[37]!==d||e[38]!==s?(T=f&&d.length===0?(0,l.jsxDEV)(_,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-roles-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Role")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Description")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Permissions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:d.map(Y)},void 0,!1)]},void 0,!0)},void 0,!1),e[36]=f,e[37]=d,e[38]=s,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=(0,l.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,l.jsxDEV)(B,{className:"overflow-hidden py-0",children:[g,T]},void 0,!0)},void 0,!1),e[40]=g,e[41]=T,e[42]=w):w=e[42];let E;return e[43]!==w||e[44]!==v||e[45]!==b||e[46]!==o||e[47]!==N?(E=(0,l.jsxDEV)("div",{className:v,"data-testid":b,children:[o,N,w]},void 0,!0),e[43]=w,e[44]=v,e[45]=b,e[46]=o,e[47]=N,e[48]=E):E=e[48],E},"RlsPanel");function X(e){return(0,l.jsxDEV)(k,{variant:"outline",children:e},e,!1)}R(X,"_temp");function Y(e){return(0,l.jsxDEV)(S,{"data-testid":`rls-role-${e.name}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,l.jsxDEV)(c,{className:"text-muted-foreground",children:e.description??""},void 0,!1),(0,l.jsxDEV)(c,{children:e.permissions.length===0?(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,l.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)},void 0,!1)},void 0,!1)]},e.name,!0)}R(Y,"_temp2");export{ie as default};
|