@lunora/studio 1.0.0-alpha.40 → 1.0.0-alpha.41
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/standalone/{chunk-AAVIFQ4Y.js → chunk-25AYY4H7.js} +1 -1
- package/dist/standalone/{chunk-Q52CHOSY.js → chunk-2ANAF4ZM.js} +1 -1
- package/dist/standalone/{chunk-BKW7FFEO.js → chunk-3OIHOXVV.js} +1 -1
- package/dist/standalone/{chunk-AJFQ3LNM.js → chunk-447TAUFD.js} +1 -1
- package/dist/standalone/{chunk-SSI4G2MY.js → chunk-5C4TSNE6.js} +1 -1
- package/dist/standalone/{chunk-DC72CQY4.js → chunk-6HSHEMZV.js} +1 -1
- package/dist/standalone/{chunk-676HEBIR.js → chunk-6JIZ34MB.js} +1 -1
- package/dist/standalone/{chunk-YTO65GHS.js → chunk-7MVSQS7B.js} +1 -1
- package/dist/standalone/{chunk-P5HJXCZS.js → chunk-BX5MKYOC.js} +1 -1
- package/dist/standalone/{chunk-V6IWFYAQ.js → chunk-EQZQOTJY.js} +1 -1
- package/dist/standalone/{chunk-ZE6FT5Z3.js → chunk-GTLEWM5Y.js} +1 -1
- package/dist/standalone/{chunk-N746FOQP.js → chunk-GUI5GFFI.js} +1 -1
- package/dist/standalone/{chunk-CACB34RQ.js → chunk-HN6KJXYQ.js} +1 -1
- package/dist/standalone/{chunk-J46WXQYL.js → chunk-HYDJNCGW.js} +1 -1
- package/dist/standalone/{chunk-DECHEGIC.js → chunk-HZK5RQHG.js} +1 -1
- package/dist/standalone/{chunk-FSGCANAU.js → chunk-IN2SYVJB.js} +1 -1
- package/dist/standalone/{chunk-JVODY4EP.js → chunk-IOANPSJN.js} +1 -1
- package/dist/standalone/{chunk-NC6MBMSI.js → chunk-ISDZPW3V.js} +1 -1
- package/dist/standalone/{chunk-QDBOPDJ7.js → chunk-J73VHFCL.js} +1 -1
- package/dist/standalone/{chunk-GMSGZDDH.js → chunk-JHKMUTIF.js} +5 -5
- package/dist/standalone/{chunk-CICVBMEN.js → chunk-JPRH6DPK.js} +1 -1
- package/dist/standalone/{chunk-PTS5TW3J.js → chunk-KA5YB3VP.js} +1 -1
- package/dist/standalone/{chunk-SG3ALJJU.js → chunk-KBB75WNT.js} +1 -1
- package/dist/standalone/{chunk-LYB5L53X.js → chunk-KQV4NGH3.js} +1 -1
- package/dist/standalone/{chunk-I7ZZRM7I.js → chunk-KUH4P5F5.js} +1 -1
- package/dist/standalone/{chunk-5ZAA2PVR.js → chunk-KYJPPVGB.js} +1 -1
- package/dist/standalone/{chunk-HZTGDL4L.js → chunk-L2TJVSDQ.js} +1 -1
- package/dist/standalone/{chunk-ERJNDIXC.js → chunk-LBN7LPVK.js} +1 -1
- package/dist/standalone/{chunk-NY6GDADQ.js → chunk-MLZYX5CQ.js} +1 -1
- package/dist/standalone/{chunk-TH45YG6Q.js → chunk-N2X2OO4V.js} +1 -1
- package/dist/standalone/{chunk-BXOYVWJR.js → chunk-NGKITPQP.js} +1 -1
- package/dist/standalone/{chunk-YNZ7ARWW.js → chunk-OZACQNKG.js} +1 -1
- package/dist/standalone/{chunk-NN27EDQB.js → chunk-PNDNXS5Z.js} +1 -1
- package/dist/standalone/{chunk-CWEAJUHW.js → chunk-Q7DMUTUE.js} +1 -1
- package/dist/standalone/{chunk-C7WTJLC3.js → chunk-RHZ4M2NZ.js} +1 -1
- package/dist/standalone/{chunk-QHFTGJPS.js → chunk-TDZ44E5I.js} +1 -1
- package/dist/standalone/{chunk-X33MSJPP.js → chunk-THNBTMUF.js} +1 -1
- package/dist/standalone/{chunk-FKACHRWO.js → chunk-TIQISBGK.js} +1 -1
- package/dist/standalone/{chunk-H6RKXQZU.js → chunk-TMYVNQ66.js} +1 -1
- package/dist/standalone/{chunk-AJULNB46.js → chunk-UJB2LEI4.js} +1 -1
- package/dist/standalone/{chunk-23C4TCRO.js → chunk-W3JK4YWR.js} +1 -1
- package/dist/standalone/{chunk-MT2J3H7O.js → chunk-W3SHEIAL.js} +2 -2
- package/dist/standalone/chunk-WIHXMNUY.js +1 -0
- package/dist/standalone/{chunk-XRNXOIVZ.js → chunk-WLDVXVI2.js} +1 -1
- package/dist/standalone/{chunk-GLUNBZRI.js → chunk-XLXNLJ4N.js} +1 -1
- package/dist/standalone/{chunk-OY3HD7BJ.js → chunk-YJAPWSDC.js} +1 -1
- package/dist/standalone/{chunk-7RE5UW27.js → chunk-ZEJB6DXU.js} +1 -1
- package/dist/standalone/{chunk-V7SRH36W.js → chunk-ZFNBPAIZ.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
- package/dist/standalone/chunk-WPNXY7IS.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as A}from"./chunk-
|
|
1
|
+
import{a as A}from"./chunk-RHZ4M2NZ.js";import{a as y,e as I}from"./chunk-SEU5V7I6.js";import{b as m}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as k}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as C}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as u,e as w,g as S,h as P}from"./chunk-RRCPZMC2.js";var N=w(S(),1);var a=w(P(),1);var z=[{key:"accounts",label:"Accounts"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],b=u(e=>{if(e===void 0)return"\u2014";let l=[[86400,"d"],[3600,"h"],[60,"m"]];for(let[t,o]of l)if(e>=t&&e%t===0)return`${String(e/t)}${o}`;return`${String(e)}s`},"formatDuration"),h=u(e=>{let l=(0,N.c)(8),{children:t,heading:o,testId:r}=e,i;l[0]!==o?(i=(0,a.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o},void 0,!1)},void 0,!1),l[0]=o,l[1]=i):i=l[1];let s;l[2]!==t?(s=(0,a.jsxDEV)(I,{className:"p-3",children:t},void 0,!1),l[2]=t,l[3]=s):s=l[3];let c;return l[4]!==i||l[5]!==s||l[6]!==r?(c=(0,a.jsxDEV)(y,{className:"gap-0 py-0","data-testid":r,children:[i,s]},void 0,!0),l[4]=i,l[5]=s,l[6]=r,l[7]=c):c=l[7],c},"ConfigCard"),d=u(e=>{let l=(0,N.c)(7),{label:t,value:o}=e,r;l[0]!==t?(r=(0,a.jsxDEV)("span",{className:"text-sm",children:t},void 0,!1),l[0]=t,l[1]=r):r=l[1];let i;l[2]!==o?(i=(0,a.jsxDEV)("span",{className:"text-sm text-muted-foreground tabular-nums",children:o},void 0,!1),l[2]=o,l[3]=i):i=l[3];let s;return l[4]!==r||l[5]!==i?(s=(0,a.jsxDEV)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[r,i]},void 0,!0),l[4]=r,l[5]=i,l[6]=s):s=l[6],s},"KeyValue"),O=u(()=>{let e=(0,N.c)(20),l=k(),t=C(),o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],e[0]=o):o=e[0];let r;e[1]!==l?(r=u(()=>l.getAuthConfig(),"t1"),e[1]=l,e[2]=r):r=e[2];let{data:i,error:s}=A(o,r),c;e[3]!==t?(c=u(n=>(0,a.jsxDEV)(m,{variant:n?"success":"outline",children:t(n?"Enabled":"Disabled")},void 0,!1),"t2"),e[3]=t,e[4]=c):c=e[4];let f=c,g;e[5]!==s?(g=s!==null&&(0,a.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s},void 0,!1),e[5]=s,e[6]=g):g=e[6];let p;e[7]!==i||e[8]!==s||e[9]!==t?(p=s===null&&i===void 0&&(0,a.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:t("Loading auth configuration\u2026")},void 0,!1),e[7]=i,e[8]=s,e[9]=t,e[10]=p):p=e[10];let v;e[11]!==i||e[12]!==s||e[13]!==f||e[14]!==t?(v=s===null&&i!==void 0&&(0,a.jsxDEV)(a.Fragment,{children:[(0,a.jsxDEV)(h,{heading:t("Enabled capabilities"),testId:"auth-config-capabilities",children:(0,a.jsxDEV)("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:z.map(n=>{let $=i.capabilities[n.key];return(0,a.jsxDEV)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${n.key}`,children:[(0,a.jsxDEV)("span",{className:"text-sm",children:t(n.label)},void 0,!1),f($)]},n.key,!0)})},void 0,!1)},void 0,!1),(0,a.jsxDEV)(h,{heading:t("Plugins"),testId:"auth-config-plugins",children:i.plugins.length===0?(0,a.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:t("No plugins enabled.")},void 0,!1):(0,a.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:i.plugins.map(L)},void 0,!1)},void 0,!1),(0,a.jsxDEV)(h,{heading:t("Sign-in methods"),testId:"auth-config-signin",children:(0,a.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxDEV)(d,{label:t("Email & password"),value:f(i.emailAndPassword)},void 0,!1),(0,a.jsxDEV)(d,{label:t("Social providers"),value:i.socialProviders.length===0?t("None"):(0,a.jsxDEV)("span",{className:"flex flex-wrap justify-end gap-1",children:i.socialProviders.map(j)},void 0,!1)},void 0,!1)]},void 0,!0)},void 0,!1),i.organization.enabled&&(0,a.jsxDEV)(h,{heading:t("Organizations"),testId:"auth-config-org",children:(0,a.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxDEV)(d,{label:t("Teams"),value:f(i.organization.teams)},void 0,!1),(0,a.jsxDEV)(d,{label:t("Custom roles"),value:f(i.organization.roles)},void 0,!1)]},void 0,!0)},void 0,!1),(0,a.jsxDEV)(h,{heading:t("Session policy"),testId:"auth-config-session",children:(0,a.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxDEV)(d,{label:t("Expires in"),value:b(i.session.expiresIn)},void 0,!1),(0,a.jsxDEV)(d,{label:t("Refresh after"),value:b(i.session.updateAge)},void 0,!1),(0,a.jsxDEV)(d,{label:t("Fresh window"),value:b(i.session.freshAge)},void 0,!1),(0,a.jsxDEV)(d,{label:t("Cookie cache"),value:f(i.session.cookieCache===!0)},void 0,!1)]},void 0,!0)},void 0,!1),(0,a.jsxDEV)(h,{heading:t("Rate limit"),testId:"auth-config-ratelimit",children:(0,a.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxDEV)(d,{label:t("Status"),value:f(i.rateLimit.enabled)},void 0,!1),i.rateLimit.enabled&&(0,a.jsxDEV)(a.Fragment,{children:[(0,a.jsxDEV)(d,{label:t("Max requests"),value:i.rateLimit.max??"\u2014"},void 0,!1),(0,a.jsxDEV)(d,{label:t("Window"),value:b(i.rateLimit.window)},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1),i.userFields.length>0&&(0,a.jsxDEV)(h,{heading:t("Plugin user fields"),testId:"auth-config-user-fields",children:(0,a.jsxDEV)("ul",{className:"flex flex-col gap-2",children:i.userFields.map(n=>(0,a.jsxDEV)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${n.name}`,children:[(0,a.jsxDEV)("span",{className:"flex flex-col",children:[(0,a.jsxDEV)("span",{className:"font-mono text-xs",children:n.name},void 0,!1),n.plugin!==void 0&&(0,a.jsxDEV)("span",{className:"text-[11px] text-muted-foreground",children:n.plugin},void 0,!1)]},void 0,!0),(0,a.jsxDEV)("span",{className:"flex items-center gap-1",children:[(0,a.jsxDEV)(m,{variant:"outline",children:n.type},void 0,!1),n.required&&(0,a.jsxDEV)(m,{variant:"secondary",children:t("required")},void 0,!1),n.unique&&(0,a.jsxDEV)(m,{variant:"secondary",children:t("unique")},void 0,!1)]},void 0,!0)]},n.name,!0))},void 0,!1)},void 0,!1),(0,a.jsxDEV)(y,{className:"gap-0 py-0",children:(0,a.jsxDEV)("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:t("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")},void 0,!1)},void 0,!1)]},void 0,!0),e[11]=i,e[12]=s,e[13]=f,e[14]=t,e[15]=v):v=e[15];let x;return e[16]!==g||e[17]!==p||e[18]!==v?(x=(0,a.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,p,v]},void 0,!0),e[16]=g,e[17]=p,e[18]=v,e[19]=x):x=e[19],x},"AuthConfigPanel");function L(e){return(0,a.jsxDEV)(m,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e,!1)}u(L,"_temp");function j(e){return(0,a.jsxDEV)(m,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e,!1)}u(j,"_temp2");export{O as AuthConfigPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as dt,b as nt,c as ct,d as ut,e as Me}from"./chunk-VON7JUPG.js";import{a as ft,b as mt,c as vt,d as ht,e as gt}from"./chunk-SG3ALJJU.js";import"./chunk-DWDILV2E.js";import"./chunk-QBAT52GB.js";import{e as ot}from"./chunk-TQ36RWOP.js";import"./chunk-QAFAJBAW.js";import{a as it}from"./chunk-UGUEC6BC.js";import"./chunk-KSKXW5PX.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-DC72CQY4.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import{a as rt}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import{a as st,b as lt,c as at,d as je,e as $e,f as Te}from"./chunk-GTM65MVX.js";import"./chunk-4QHKBC77.js";import{a as tt}from"./chunk-UKDJ4H7I.js";import{a as Ze,b as et}from"./chunk-TBMYIZIO.js";import"./chunk-3CJW6NWG.js";import{c as Oe}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Pe}from"./chunk-BOXSWNXZ.js";import{b as Ye}from"./chunk-C7WTJLC3.js";import{a as B,b as Re,c as _e,d as Ve,e as P}from"./chunk-SEU5V7I6.js";import{b as Ke}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as Ue}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Qe,e as Ge,f as Je,g as We,k as Xe,n as Ae}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as n,e as Be,f as pt,g as xt,h as bt}from"./chunk-RRCPZMC2.js";var Le=Be(xt(),1);var v=Be(pt(),1);var t=Be(bt(),1);var ze=n(l=>l>=100?"critical":l>=50?"warning":"good","performanceLevel"),He=n(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"formatLatency"),Ee=n(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"formatCount"),Nt=n(l=>{let e=(0,Le.c)(3),{level:s}=l;if(s==="critical"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxDEV)(Ke,{variant:"destructive",children:"Slow"},void 0,!1),e[0]=i):i=e[0],i}if(s==="warning"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=(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]=i):i=e[1],i}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"),yt=n(l=>{let e=(0,Le.c)(152),{queryStats:s}=l,r=Qe(),[i,Q]=(0,v.useState)("totalTime"),C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=new Set,e[0]=C):C=e[0];let[h,T]=(0,v.useState)(C),p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=n(o=>{o!==null&&Q(o)},"t2"),e[1]=p):p=e[1];let S=p,u;if(e[2]!==s||e[3]!==i){u=[...s];let o;e[5]!==i?(o=n((m,c)=>{switch(i){case"avgTime":return c.avgDurationMs-m.avgDurationMs;case"execCount":return c.execCount-m.execCount;case"rowsRead":return c.rowsRead-m.rowsRead;default:return c.totalDurationMs-m.totalDurationMs}},"t310"),e[5]=i,e[6]=o):o=e[6],u.sort(o),e[2]=s,e[3]=i,e[4]=u}else u=e[4];let g=u,$;e[7]!==s?($=s.filter(St),e[7]=s,e[8]=$):$=e[8];let j=$.length,H;e[9]!==s?(H=s.filter(wt),e[9]=s,e[10]=H):H=e[10];let d=H.length,_;e[11]!==s?(_=s.filter(qt),e[11]=s,e[12]=_):_=e[12];let U=_.length,O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=n(o=>{T(m=>{let c=new Set(m);return c.has(o)?c.delete(o):c.add(o),c})},"t6"),e[13]=O):O=e[13];let Fe=O;if(s.length===0){let o;e[14]!==r?(o=r("No query insights yet"),e[14]=r,e[15]=o):o=e[15];let m;e[16]!==o?(m=(0,t.jsxDEV)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:o},void 0,!1),e[16]=o,e[17]=m):m=e[17];let c;e[18]!==r?(c=r("Query insights appear once statements are executed against this shard."),e[18]=r,e[19]=c):c=e[19];let z;e[20]!==c?(z=(0,t.jsxDEV)("p",{className:"mt-1 text-sm",children:c},void 0,!1),e[20]=c,e[21]=z):z=e[21];let ke;return e[22]!==z||e[23]!==m?(ke=(0,t.jsxDEV)(B,{children:(0,t.jsxDEV)(P,{className:"py-12",children:(0,t.jsxDEV)("div",{className:"text-center text-muted-foreground",children:[m,z]},void 0,!0)},void 0,!1)},void 0,!1),e[22]=z,e[23]=m,e[24]=ke):ke=e[24],ke}let I;e[25]!==r?(I=r("Critical queries"),e[25]=r,e[26]=I):I=e[26];let f;e[27]!==I?(f=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:I},void 0,!1)},void 0,!1),e[27]=I,e[28]=f):f=e[28];let M;e[29]!==j?(M=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:j},void 0,!1),e[29]=j,e[30]=M):M=e[30];let D;e[31]!==r?(D=r(">100ms avg execution"),e[31]=r,e[32]=D):D=e[32];let R;e[33]!==D?(R=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:D},void 0,!1),e[33]=D,e[34]=R):R=e[34];let F;e[35]!==R||e[36]!==M?(F=(0,t.jsxDEV)(P,{children:[M,R]},void 0,!0),e[35]=R,e[36]=M,e[37]=F):F=e[37];let b;e[38]!==F||e[39]!==f?(b=(0,t.jsxDEV)(B,{children:[f,F]},void 0,!0),e[38]=F,e[39]=f,e[40]=b):b=e[40];let N;e[41]!==r?(N=r("Moderate queries"),e[41]=r,e[42]=N):N=e[42];let k;e[43]!==N?(k=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:N},void 0,!1)},void 0,!1),e[43]=N,e[44]=k):k=e[44];let A;e[45]!==d?(A=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:d},void 0,!1),e[45]=d,e[46]=A):A=e[46];let E;e[47]!==r?(E=r("50\u2013100ms avg execution"),e[47]=r,e[48]=E):E=e[48];let L;e[49]!==E?(L=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:E},void 0,!1),e[49]=E,e[50]=L):L=e[50];let a;e[51]!==A||e[52]!==L?(a=(0,t.jsxDEV)(P,{children:[A,L]},void 0,!0),e[51]=A,e[52]=L,e[53]=a):a=e[53];let w;e[54]!==k||e[55]!==a?(w=(0,t.jsxDEV)(B,{children:[k,a]},void 0,!0),e[54]=k,e[55]=a,e[56]=w):w=e[56];let x;e[57]!==r?(x=r("Fast queries"),e[57]=r,e[58]=x):x=e[58];let y;e[59]!==x?(y=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:x},void 0,!1)},void 0,!1),e[59]=x,e[60]=y):y=e[60];let K;e[61]!==U?(K=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:U},void 0,!1),e[61]=U,e[62]=K):K=e[62];let V;e[63]!==r?(V=r("<50ms avg execution"),e[63]=r,e[64]=V):V=e[64];let G;e[65]!==V?(G=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:V},void 0,!1),e[65]=V,e[66]=G):G=e[66];let J;e[67]!==K||e[68]!==G?(J=(0,t.jsxDEV)(P,{children:[K,G]},void 0,!0),e[67]=K,e[68]=G,e[69]=J):J=e[69];let W;e[70]!==y||e[71]!==J?(W=(0,t.jsxDEV)(B,{children:[y,J]},void 0,!0),e[70]=y,e[71]=J,e[72]=W):W=e[72];let X;e[73]!==b||e[74]!==w||e[75]!==W?(X=(0,t.jsxDEV)("div",{className:"grid gap-4 md:grid-cols-3",children:[b,w,W]},void 0,!0),e[73]=b,e[74]=w,e[75]=W,e[76]=X):X=e[76];let Y;e[77]!==r?(Y=r("Query leaderboard"),e[77]=r,e[78]=Y):Y=e[78];let Z;e[79]!==Y?(Z=(0,t.jsxDEV)("h3",{className:"text-lg font-semibold",children:Y},void 0,!1),e[79]=Y,e[80]=Z):Z=e[80];let ee;e[81]!==i||e[82]!==r?(ee=r("Slow queries sorted by {sortField}",{sortField:r(i)}),e[81]=i,e[82]=r,e[83]=ee):ee=e[83];let te;e[84]!==ee?(te=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:ee},void 0,!1),e[84]=ee,e[85]=te):te=e[85];let re;e[86]!==Z||e[87]!==te?(re=(0,t.jsxDEV)("div",{children:[Z,te]},void 0,!0),e[86]=Z,e[87]=te,e[88]=re):re=e[88];let se;e[89]!==r?(se=r("Sort by"),e[89]=r,e[90]=se):se=e[90];let le;e[91]!==se?(le=(0,t.jsxDEV)("span",{className:"text-sm text-muted-foreground",children:se},void 0,!1),e[91]=se,e[92]=le):le=e[92];let ae;e[93]!==r?(ae=r("Sort queries by"),e[93]=r,e[94]=ae):ae=e[94];let Ie;e[95]===Symbol.for("react.memo_cache_sentinel")?(Ie=(0,t.jsxDEV)(nt,{},void 0,!1),e[95]=Ie):Ie=e[95];let ie;e[96]!==ae?(ie=(0,t.jsxDEV)(ct,{"aria-label":ae,className:"w-[140px]","data-testid":"qi-sort",children:Ie},void 0,!1),e[96]=ae,e[97]=ie):ie=e[97];let oe;e[98]!==r?(oe=r("Total time"),e[98]=r,e[99]=oe):oe=e[99];let de;e[100]!==oe?(de=(0,t.jsxDEV)(Me,{value:"totalTime",children:oe},void 0,!1),e[100]=oe,e[101]=de):de=e[101];let ne;e[102]!==r?(ne=r("Avg time"),e[102]=r,e[103]=ne):ne=e[103];let ce;e[104]!==ne?(ce=(0,t.jsxDEV)(Me,{value:"avgTime",children:ne},void 0,!1),e[104]=ne,e[105]=ce):ce=e[105];let ue;e[106]!==r?(ue=r("Execution count"),e[106]=r,e[107]=ue):ue=e[107];let fe;e[108]!==ue?(fe=(0,t.jsxDEV)(Me,{value:"execCount",children:ue},void 0,!1),e[108]=ue,e[109]=fe):fe=e[109];let me;e[110]!==r?(me=r("Rows read"),e[110]=r,e[111]=me):me=e[111];let ve;e[112]!==me?(ve=(0,t.jsxDEV)(Me,{value:"rowsRead",children:me},void 0,!1),e[112]=me,e[113]=ve):ve=e[113];let he;e[114]!==de||e[115]!==ce||e[116]!==fe||e[117]!==ve?(he=(0,t.jsxDEV)(ut,{children:[de,ce,fe,ve]},void 0,!0),e[114]=de,e[115]=ce,e[116]=fe,e[117]=ve,e[118]=he):he=e[118];let ge;e[119]!==i||e[120]!==ie||e[121]!==he?(ge=(0,t.jsxDEV)(dt,{onValueChange:S,value:i,children:[ie,he]},void 0,!0),e[119]=i,e[120]=ie,e[121]=he,e[122]=ge):ge=e[122];let pe;e[123]!==le||e[124]!==ge?(pe=(0,t.jsxDEV)("div",{className:"flex items-center gap-2",children:[le,ge]},void 0,!0),e[123]=le,e[124]=ge,e[125]=pe):pe=e[125];let xe;e[126]!==re||e[127]!==pe?(xe=(0,t.jsxDEV)("div",{className:"flex items-center justify-between",children:[re,pe]},void 0,!0),e[126]=re,e[127]=pe,e[128]=xe):xe=e[128];let be;e[129]!==r?(be=r("Statements"),e[129]=r,e[130]=be):be=e[130];let Ne;e[131]!==be?(Ne=(0,t.jsxDEV)(_e,{children:be},void 0,!1),e[131]=be,e[132]=Ne):Ne=e[132];let ye;e[133]!==g.length||e[134]!==r?(ye=r("{count} tracked statements",{count:g.length}),e[133]=g.length,e[134]=r,e[135]=ye):ye=e[135];let Se;e[136]!==ye?(Se=(0,t.jsxDEV)(Ve,{children:ye},void 0,!1),e[136]=ye,e[137]=Se):Se=e[137];let we;e[138]!==Ne||e[139]!==Se?(we=(0,t.jsxDEV)(Re,{children:[Ne,Se]},void 0,!0),e[138]=Ne,e[139]=Se,e[140]=we):we=e[140];let qe;e[141]!==h||e[142]!==g||e[143]!==r?(qe=(0,t.jsxDEV)(P,{children:(0,t.jsxDEV)("div",{className:"space-y-2",children:g.map(o=>{let m=o.normalizedSql,c=h.has(m),z=ze(o.avgDurationMs);return(0,t.jsxDEV)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxDEV)("button",{"aria-expanded":c,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:n(()=>{Fe(m)},"onClick"),type:"button",children:[(0,t.jsxDEV)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsxDEV)(Nt,{level:z},void 0,!1),(0,t.jsxDEV)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:o.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:He(o.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:He(o.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:Ee(o.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),c&&(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:o.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:Ee(o.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:He(o.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:Ee(o.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:Ee(o.rowsWritten)},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},m,!0)})},void 0,!1)},void 0,!1),e[141]=h,e[142]=g,e[143]=r,e[144]=qe):qe=e[144];let Ce;e[145]!==we||e[146]!==qe?(Ce=(0,t.jsxDEV)(B,{children:[we,qe]},void 0,!0),e[145]=we,e[146]=qe,e[147]=Ce):Ce=e[147];let De;return e[148]!==X||e[149]!==xe||e[150]!==Ce?(De=(0,t.jsxDEV)("div",{className:"space-y-4","data-testid":"qi-root",children:[X,xe,Ce]},void 0,!0),e[148]=X,e[149]=xe,e[150]=Ce,e[151]=De):De=e[151],De},"QueryInsights");function St(l){return ze(l.avgDurationMs)==="critical"}n(St,"_temp");function wt(l){return ze(l.avgDurationMs)==="warning"}n(wt,"_temp2");function qt(l){return ze(l.avgDurationMs)==="good"}n(qt,"_temp3");var Ct=Ge(Pe.getMetrics),Tt=n(l=>{let e=Math.floor(l/1e3),s=Math.floor(e/3600),r=Math.floor(e%3600/60),i=e%60;return s>0?`${s.toString()}h ${r.toString()}m`:r>0?`${r.toString()}m ${i.toString()}s`:`${i.toString()}s`},"formatDuration"),Rt=n((l,e)=>l?e:"overview","resolveTab"),_t=n((l,e)=>{let s=l+e;return s===0?"\u2014":`${(l/s*100).toFixed(1)}%`},"hitRate"),q=n(l=>{let e=(0,Le.c)(16),{chart:s,footer:r,label:i,testId:Q,value:C}=l,h;e[0]!==i?(h=(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1),e[0]=i,e[1]=h):h=e[1];let T;e[2]!==Q||e[3]!==C?(T=(0,t.jsxDEV)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":Q,children:C},void 0,!1),e[2]=Q,e[3]=C,e[4]=T):T=e[4];let p;e[5]!==s||e[6]!==T?(p=(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[T,s]},void 0,!0),e[5]=s,e[6]=T,e[7]=p):p=e[7];let S;e[8]!==h||e[9]!==p?(S=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[h,p]},void 0,!0),e[8]=h,e[9]=p,e[10]=S):S=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 g;return e[13]!==S||e[14]!==u?(g=(0,t.jsxDEV)(B,{className:"justify-between gap-0 py-0",children:[S,u]},void 0,!0),e[13]=S,e[14]=u,e[15]=g):g=e[15],g},"StatCard"),Kt=n(({initialShardKey:l})=>{let e=Ue(),s=Qe(),[r,i]=(0,v.useState)(l??""),[Q,C]=(0,v.useState)("overview"),[h,T]=(0,v.useState)([]),p=(0,v.useRef)(null),S=(0,v.useRef)(null),u=(0,v.useRef)(!0);(0,v.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let g=rt(r.trim(),400),{data:$,error:j,liveError:H}=Ye(Pe.getMetrics,{},{live:!0,shardKey:g}),d=$??null;(0,v.useEffect)(()=>{if($===void 0)return;et(g);let a=$,w=p.current,x=S.current!==null&&S.current!==a.shard;if(S.current=a.shard,p.current=a.requests,x){T([]);return}w!==null&&a.requests>=w&&T(y=>[...y,a.requests-w].slice(-30))},[$,g]);let[_,U]=(0,v.useState)(null),[O,Fe]=(0,v.useState)(!1),I=n(async()=>{Fe(!0);let a=mt(r,Ze());try{let w=await Promise.all(a.map(async x=>{try{let y=await e.query(Ct,{},Je(x));return{error:null,metrics:y,shard:x===""?y.shard:x}}catch(y){return{error:We(y),metrics:null,shard:x===""?"__root__":x}}}));u.current&&U(w)}finally{u.current&&Fe(!1)}},"aggregateAll"),f=_===null?null:ft(_),M=d===null||d.requests===0?"\u2014":`${(d.errors/d.requests*100).toFixed(1)}%`,D=h.length>0?h.at(-1):0,R=d?vt(d):{p90:0,p95:0},F=n(a=>a<=0?"\u2014":a<1?`${(a*1e3).toFixed(0)}\u03BCs`:a<1e3?`${a.toFixed(1)}ms`:`${(a/1e3).toFixed(2)}s`,"formatMs"),b=(0,v.useMemo)(()=>{if(!d||!("queryStats"in d))return;let a=d.queryStats;if(!(!a||!Array.isArray(a)))return ht(a)},[d]),N=Rt(b!==void 0,Q),k=n(()=>{Xe(I())},"runAggregate"),A=n(()=>{U(null)},"clearAggregate"),E=n(()=>{C("overview")},"switchToOverview"),L=n(()=>{C("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)(tt,{onChange:i,testId:"mt-shard-input",value:r},void 0,!1),(0,t.jsxDEV)(it,{message:H,prefix:"mt"},void 0,!1),(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate",disabled:O,onClick:k,size:"sm",type:"button",variant:"secondary",children:s(O?"Aggregating\u2026":"All shards")},void 0,!1),_!==null&&(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:s("Hide")},void 0,!1),(0,t.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:ot,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")},void 0,!1)]},void 0,!0),j!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:j},void 0,!1),b!==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 ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:E,type:"button",children:s("Overview")},void 0,!1),(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="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:[s("Query insights"),b.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:b.length},void 0,!1)]},void 0,!0)]},void 0,!0),N==="query-insights"&&b!==void 0&&(0,t.jsxDEV)(yt,{queryStats:b},void 0,!1),N==="overview"&&d!==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)(q,{chart:h.length>=2?(0,t.jsxDEV)(gt,{ariaLabel:s("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:h,testId:"mt-sparkline"},void 0,!1):void 0,footer:h.length>=2?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("span",{className:"font-semibold text-foreground",children:`+${D.toLocaleString()}`},void 0,!1)," ",s("last interval")]},void 0,!0):(0,t.jsxDEV)("span",{"data-testid":"mt-sparkline-empty",children:s("collecting samples\u2026")},void 0,!1),label:s("Requests"),testId:"mt-requests",value:d.requests},void 0,!1),(0,t.jsxDEV)(q,{footer:s("{rate} error rate",{rate:M}),label:s("Errors"),testId:"mt-errors",value:(0,t.jsxDEV)(t.Fragment,{children:[d.errors," (",M,")"]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(q,{footer:R.p90>0?`P90 ${F(R.p90)}`:void 0,label:s("P95 latency"),testId:"mt-p95",value:R.p95>0?F(R.p95):"\u2014"},void 0,!1),(0,t.jsxDEV)(q,{footer:d.cache===null?void 0:`${d.cache.entries.toLocaleString()} ${s("cache entries")}`,label:s("Database size"),testId:"mt-db-size",value:Ae(d.databaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Shard"),testId:"mt-shard",value:d.shard},void 0,!1),(0,t.jsxDEV)(q,{label:s("Uptime"),testId:"mt-uptime",value:Tt(d.uptimeMs)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Cache hit rate"),testId:"mt-cache",value:d.cache===null?s("no cache configured"):s("{rate} ({count} entries)",{count:d.cache.entries,rate:_t(d.cache.hits,d.cache.misses)})},void 0,!1)]},void 0,!0),N==="overview"&&d===null&&null,N==="overview"&&f!==null&&_!==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)(q,{label:s("Shards"),testId:"mt-agg-shards",value:f.failed>0?s("{reachable} reachable, {failed} unreachable",{failed:f.failed,reachable:f.reachable}):s("{reachable} reachable",{reachable:f.reachable})},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total requests"),testId:"mt-agg-requests",value:f.totalRequests},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total errors"),testId:"mt-agg-errors",value:f.totalErrors},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total database size"),testId:"mt-agg-db-size",value:Ae(f.totalDatabaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Combined cache hit rate"),testId:"mt-agg-cache",value:f.hitRate===null?s("no cache configured"):`${(f.hitRate*100).toFixed(1)}%`},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(B,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(P,{className:"px-0",children:(0,t.jsxDEV)(st,{"data-testid":"mt-agg-table",children:[(0,t.jsxDEV)(lt,{children:(0,t.jsxDEV)(je,{children:[(0,t.jsxDEV)($e,{children:s("shard")},void 0,!1),(0,t.jsxDEV)($e,{children:s("requests")},void 0,!1),(0,t.jsxDEV)($e,{children:s("errors")},void 0,!1),(0,t.jsxDEV)($e,{children:s("db size")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(at,{children:_.map(a=>(0,t.jsxDEV)(je,{"data-testid":`mt-agg-row-${a.shard}`,children:[(0,t.jsxDEV)(Te,{children:a.shard},void 0,!1),a.metrics===null?(0,t.jsxDEV)(Te,{className:"text-destructive",colSpan:3,children:a.error??s("unreachable")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.requests},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.errors},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:Ae(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{Kt as MetricsPanel};
|
|
1
|
+
import{a as dt,b as nt,c as ct,d as ut,e as Me}from"./chunk-VON7JUPG.js";import{a as ft,b as mt,c as vt,d as ht,e as gt}from"./chunk-KBB75WNT.js";import"./chunk-DWDILV2E.js";import"./chunk-QBAT52GB.js";import{e as ot}from"./chunk-TQ36RWOP.js";import"./chunk-QAFAJBAW.js";import{a as it}from"./chunk-UGUEC6BC.js";import"./chunk-KSKXW5PX.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-6HSHEMZV.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import{a as rt}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import{a as st,b as lt,c as at,d as je,e as $e,f as Te}from"./chunk-GTM65MVX.js";import"./chunk-4QHKBC77.js";import{a as tt}from"./chunk-UKDJ4H7I.js";import{a as Ze,b as et}from"./chunk-TBMYIZIO.js";import"./chunk-3CJW6NWG.js";import{c as Oe}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Pe}from"./chunk-BOXSWNXZ.js";import{b as Ye}from"./chunk-RHZ4M2NZ.js";import{a as B,b as Re,c as _e,d as Ve,e as P}from"./chunk-SEU5V7I6.js";import{b as Ke}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as Ue}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Qe,e as Ge,f as Je,g as We,k as Xe,n as Ae}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as n,e as Be,f as pt,g as xt,h as bt}from"./chunk-RRCPZMC2.js";var Le=Be(xt(),1);var v=Be(pt(),1);var t=Be(bt(),1);var ze=n(l=>l>=100?"critical":l>=50?"warning":"good","performanceLevel"),He=n(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"formatLatency"),Ee=n(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"formatCount"),Nt=n(l=>{let e=(0,Le.c)(3),{level:s}=l;if(s==="critical"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxDEV)(Ke,{variant:"destructive",children:"Slow"},void 0,!1),e[0]=i):i=e[0],i}if(s==="warning"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=(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]=i):i=e[1],i}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"),yt=n(l=>{let e=(0,Le.c)(152),{queryStats:s}=l,r=Qe(),[i,Q]=(0,v.useState)("totalTime"),C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=new Set,e[0]=C):C=e[0];let[h,T]=(0,v.useState)(C),p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=n(o=>{o!==null&&Q(o)},"t2"),e[1]=p):p=e[1];let S=p,u;if(e[2]!==s||e[3]!==i){u=[...s];let o;e[5]!==i?(o=n((m,c)=>{switch(i){case"avgTime":return c.avgDurationMs-m.avgDurationMs;case"execCount":return c.execCount-m.execCount;case"rowsRead":return c.rowsRead-m.rowsRead;default:return c.totalDurationMs-m.totalDurationMs}},"t310"),e[5]=i,e[6]=o):o=e[6],u.sort(o),e[2]=s,e[3]=i,e[4]=u}else u=e[4];let g=u,$;e[7]!==s?($=s.filter(St),e[7]=s,e[8]=$):$=e[8];let j=$.length,H;e[9]!==s?(H=s.filter(wt),e[9]=s,e[10]=H):H=e[10];let d=H.length,_;e[11]!==s?(_=s.filter(qt),e[11]=s,e[12]=_):_=e[12];let U=_.length,O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=n(o=>{T(m=>{let c=new Set(m);return c.has(o)?c.delete(o):c.add(o),c})},"t6"),e[13]=O):O=e[13];let Fe=O;if(s.length===0){let o;e[14]!==r?(o=r("No query insights yet"),e[14]=r,e[15]=o):o=e[15];let m;e[16]!==o?(m=(0,t.jsxDEV)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:o},void 0,!1),e[16]=o,e[17]=m):m=e[17];let c;e[18]!==r?(c=r("Query insights appear once statements are executed against this shard."),e[18]=r,e[19]=c):c=e[19];let z;e[20]!==c?(z=(0,t.jsxDEV)("p",{className:"mt-1 text-sm",children:c},void 0,!1),e[20]=c,e[21]=z):z=e[21];let ke;return e[22]!==z||e[23]!==m?(ke=(0,t.jsxDEV)(B,{children:(0,t.jsxDEV)(P,{className:"py-12",children:(0,t.jsxDEV)("div",{className:"text-center text-muted-foreground",children:[m,z]},void 0,!0)},void 0,!1)},void 0,!1),e[22]=z,e[23]=m,e[24]=ke):ke=e[24],ke}let I;e[25]!==r?(I=r("Critical queries"),e[25]=r,e[26]=I):I=e[26];let f;e[27]!==I?(f=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:I},void 0,!1)},void 0,!1),e[27]=I,e[28]=f):f=e[28];let M;e[29]!==j?(M=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:j},void 0,!1),e[29]=j,e[30]=M):M=e[30];let D;e[31]!==r?(D=r(">100ms avg execution"),e[31]=r,e[32]=D):D=e[32];let R;e[33]!==D?(R=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:D},void 0,!1),e[33]=D,e[34]=R):R=e[34];let F;e[35]!==R||e[36]!==M?(F=(0,t.jsxDEV)(P,{children:[M,R]},void 0,!0),e[35]=R,e[36]=M,e[37]=F):F=e[37];let b;e[38]!==F||e[39]!==f?(b=(0,t.jsxDEV)(B,{children:[f,F]},void 0,!0),e[38]=F,e[39]=f,e[40]=b):b=e[40];let N;e[41]!==r?(N=r("Moderate queries"),e[41]=r,e[42]=N):N=e[42];let k;e[43]!==N?(k=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:N},void 0,!1)},void 0,!1),e[43]=N,e[44]=k):k=e[44];let A;e[45]!==d?(A=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:d},void 0,!1),e[45]=d,e[46]=A):A=e[46];let E;e[47]!==r?(E=r("50\u2013100ms avg execution"),e[47]=r,e[48]=E):E=e[48];let L;e[49]!==E?(L=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:E},void 0,!1),e[49]=E,e[50]=L):L=e[50];let a;e[51]!==A||e[52]!==L?(a=(0,t.jsxDEV)(P,{children:[A,L]},void 0,!0),e[51]=A,e[52]=L,e[53]=a):a=e[53];let w;e[54]!==k||e[55]!==a?(w=(0,t.jsxDEV)(B,{children:[k,a]},void 0,!0),e[54]=k,e[55]=a,e[56]=w):w=e[56];let x;e[57]!==r?(x=r("Fast queries"),e[57]=r,e[58]=x):x=e[58];let y;e[59]!==x?(y=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:x},void 0,!1)},void 0,!1),e[59]=x,e[60]=y):y=e[60];let K;e[61]!==U?(K=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:U},void 0,!1),e[61]=U,e[62]=K):K=e[62];let V;e[63]!==r?(V=r("<50ms avg execution"),e[63]=r,e[64]=V):V=e[64];let G;e[65]!==V?(G=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:V},void 0,!1),e[65]=V,e[66]=G):G=e[66];let J;e[67]!==K||e[68]!==G?(J=(0,t.jsxDEV)(P,{children:[K,G]},void 0,!0),e[67]=K,e[68]=G,e[69]=J):J=e[69];let W;e[70]!==y||e[71]!==J?(W=(0,t.jsxDEV)(B,{children:[y,J]},void 0,!0),e[70]=y,e[71]=J,e[72]=W):W=e[72];let X;e[73]!==b||e[74]!==w||e[75]!==W?(X=(0,t.jsxDEV)("div",{className:"grid gap-4 md:grid-cols-3",children:[b,w,W]},void 0,!0),e[73]=b,e[74]=w,e[75]=W,e[76]=X):X=e[76];let Y;e[77]!==r?(Y=r("Query leaderboard"),e[77]=r,e[78]=Y):Y=e[78];let Z;e[79]!==Y?(Z=(0,t.jsxDEV)("h3",{className:"text-lg font-semibold",children:Y},void 0,!1),e[79]=Y,e[80]=Z):Z=e[80];let ee;e[81]!==i||e[82]!==r?(ee=r("Slow queries sorted by {sortField}",{sortField:r(i)}),e[81]=i,e[82]=r,e[83]=ee):ee=e[83];let te;e[84]!==ee?(te=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:ee},void 0,!1),e[84]=ee,e[85]=te):te=e[85];let re;e[86]!==Z||e[87]!==te?(re=(0,t.jsxDEV)("div",{children:[Z,te]},void 0,!0),e[86]=Z,e[87]=te,e[88]=re):re=e[88];let se;e[89]!==r?(se=r("Sort by"),e[89]=r,e[90]=se):se=e[90];let le;e[91]!==se?(le=(0,t.jsxDEV)("span",{className:"text-sm text-muted-foreground",children:se},void 0,!1),e[91]=se,e[92]=le):le=e[92];let ae;e[93]!==r?(ae=r("Sort queries by"),e[93]=r,e[94]=ae):ae=e[94];let Ie;e[95]===Symbol.for("react.memo_cache_sentinel")?(Ie=(0,t.jsxDEV)(nt,{},void 0,!1),e[95]=Ie):Ie=e[95];let ie;e[96]!==ae?(ie=(0,t.jsxDEV)(ct,{"aria-label":ae,className:"w-[140px]","data-testid":"qi-sort",children:Ie},void 0,!1),e[96]=ae,e[97]=ie):ie=e[97];let oe;e[98]!==r?(oe=r("Total time"),e[98]=r,e[99]=oe):oe=e[99];let de;e[100]!==oe?(de=(0,t.jsxDEV)(Me,{value:"totalTime",children:oe},void 0,!1),e[100]=oe,e[101]=de):de=e[101];let ne;e[102]!==r?(ne=r("Avg time"),e[102]=r,e[103]=ne):ne=e[103];let ce;e[104]!==ne?(ce=(0,t.jsxDEV)(Me,{value:"avgTime",children:ne},void 0,!1),e[104]=ne,e[105]=ce):ce=e[105];let ue;e[106]!==r?(ue=r("Execution count"),e[106]=r,e[107]=ue):ue=e[107];let fe;e[108]!==ue?(fe=(0,t.jsxDEV)(Me,{value:"execCount",children:ue},void 0,!1),e[108]=ue,e[109]=fe):fe=e[109];let me;e[110]!==r?(me=r("Rows read"),e[110]=r,e[111]=me):me=e[111];let ve;e[112]!==me?(ve=(0,t.jsxDEV)(Me,{value:"rowsRead",children:me},void 0,!1),e[112]=me,e[113]=ve):ve=e[113];let he;e[114]!==de||e[115]!==ce||e[116]!==fe||e[117]!==ve?(he=(0,t.jsxDEV)(ut,{children:[de,ce,fe,ve]},void 0,!0),e[114]=de,e[115]=ce,e[116]=fe,e[117]=ve,e[118]=he):he=e[118];let ge;e[119]!==i||e[120]!==ie||e[121]!==he?(ge=(0,t.jsxDEV)(dt,{onValueChange:S,value:i,children:[ie,he]},void 0,!0),e[119]=i,e[120]=ie,e[121]=he,e[122]=ge):ge=e[122];let pe;e[123]!==le||e[124]!==ge?(pe=(0,t.jsxDEV)("div",{className:"flex items-center gap-2",children:[le,ge]},void 0,!0),e[123]=le,e[124]=ge,e[125]=pe):pe=e[125];let xe;e[126]!==re||e[127]!==pe?(xe=(0,t.jsxDEV)("div",{className:"flex items-center justify-between",children:[re,pe]},void 0,!0),e[126]=re,e[127]=pe,e[128]=xe):xe=e[128];let be;e[129]!==r?(be=r("Statements"),e[129]=r,e[130]=be):be=e[130];let Ne;e[131]!==be?(Ne=(0,t.jsxDEV)(_e,{children:be},void 0,!1),e[131]=be,e[132]=Ne):Ne=e[132];let ye;e[133]!==g.length||e[134]!==r?(ye=r("{count} tracked statements",{count:g.length}),e[133]=g.length,e[134]=r,e[135]=ye):ye=e[135];let Se;e[136]!==ye?(Se=(0,t.jsxDEV)(Ve,{children:ye},void 0,!1),e[136]=ye,e[137]=Se):Se=e[137];let we;e[138]!==Ne||e[139]!==Se?(we=(0,t.jsxDEV)(Re,{children:[Ne,Se]},void 0,!0),e[138]=Ne,e[139]=Se,e[140]=we):we=e[140];let qe;e[141]!==h||e[142]!==g||e[143]!==r?(qe=(0,t.jsxDEV)(P,{children:(0,t.jsxDEV)("div",{className:"space-y-2",children:g.map(o=>{let m=o.normalizedSql,c=h.has(m),z=ze(o.avgDurationMs);return(0,t.jsxDEV)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxDEV)("button",{"aria-expanded":c,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:n(()=>{Fe(m)},"onClick"),type:"button",children:[(0,t.jsxDEV)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsxDEV)(Nt,{level:z},void 0,!1),(0,t.jsxDEV)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:o.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:He(o.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:He(o.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:Ee(o.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),c&&(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:o.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:Ee(o.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:He(o.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:Ee(o.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:Ee(o.rowsWritten)},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},m,!0)})},void 0,!1)},void 0,!1),e[141]=h,e[142]=g,e[143]=r,e[144]=qe):qe=e[144];let Ce;e[145]!==we||e[146]!==qe?(Ce=(0,t.jsxDEV)(B,{children:[we,qe]},void 0,!0),e[145]=we,e[146]=qe,e[147]=Ce):Ce=e[147];let De;return e[148]!==X||e[149]!==xe||e[150]!==Ce?(De=(0,t.jsxDEV)("div",{className:"space-y-4","data-testid":"qi-root",children:[X,xe,Ce]},void 0,!0),e[148]=X,e[149]=xe,e[150]=Ce,e[151]=De):De=e[151],De},"QueryInsights");function St(l){return ze(l.avgDurationMs)==="critical"}n(St,"_temp");function wt(l){return ze(l.avgDurationMs)==="warning"}n(wt,"_temp2");function qt(l){return ze(l.avgDurationMs)==="good"}n(qt,"_temp3");var Ct=Ge(Pe.getMetrics),Tt=n(l=>{let e=Math.floor(l/1e3),s=Math.floor(e/3600),r=Math.floor(e%3600/60),i=e%60;return s>0?`${s.toString()}h ${r.toString()}m`:r>0?`${r.toString()}m ${i.toString()}s`:`${i.toString()}s`},"formatDuration"),Rt=n((l,e)=>l?e:"overview","resolveTab"),_t=n((l,e)=>{let s=l+e;return s===0?"\u2014":`${(l/s*100).toFixed(1)}%`},"hitRate"),q=n(l=>{let e=(0,Le.c)(16),{chart:s,footer:r,label:i,testId:Q,value:C}=l,h;e[0]!==i?(h=(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1),e[0]=i,e[1]=h):h=e[1];let T;e[2]!==Q||e[3]!==C?(T=(0,t.jsxDEV)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":Q,children:C},void 0,!1),e[2]=Q,e[3]=C,e[4]=T):T=e[4];let p;e[5]!==s||e[6]!==T?(p=(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[T,s]},void 0,!0),e[5]=s,e[6]=T,e[7]=p):p=e[7];let S;e[8]!==h||e[9]!==p?(S=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[h,p]},void 0,!0),e[8]=h,e[9]=p,e[10]=S):S=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 g;return e[13]!==S||e[14]!==u?(g=(0,t.jsxDEV)(B,{className:"justify-between gap-0 py-0",children:[S,u]},void 0,!0),e[13]=S,e[14]=u,e[15]=g):g=e[15],g},"StatCard"),Kt=n(({initialShardKey:l})=>{let e=Ue(),s=Qe(),[r,i]=(0,v.useState)(l??""),[Q,C]=(0,v.useState)("overview"),[h,T]=(0,v.useState)([]),p=(0,v.useRef)(null),S=(0,v.useRef)(null),u=(0,v.useRef)(!0);(0,v.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let g=rt(r.trim(),400),{data:$,error:j,liveError:H}=Ye(Pe.getMetrics,{},{live:!0,shardKey:g}),d=$??null;(0,v.useEffect)(()=>{if($===void 0)return;et(g);let a=$,w=p.current,x=S.current!==null&&S.current!==a.shard;if(S.current=a.shard,p.current=a.requests,x){T([]);return}w!==null&&a.requests>=w&&T(y=>[...y,a.requests-w].slice(-30))},[$,g]);let[_,U]=(0,v.useState)(null),[O,Fe]=(0,v.useState)(!1),I=n(async()=>{Fe(!0);let a=mt(r,Ze());try{let w=await Promise.all(a.map(async x=>{try{let y=await e.query(Ct,{},Je(x));return{error:null,metrics:y,shard:x===""?y.shard:x}}catch(y){return{error:We(y),metrics:null,shard:x===""?"__root__":x}}}));u.current&&U(w)}finally{u.current&&Fe(!1)}},"aggregateAll"),f=_===null?null:ft(_),M=d===null||d.requests===0?"\u2014":`${(d.errors/d.requests*100).toFixed(1)}%`,D=h.length>0?h.at(-1):0,R=d?vt(d):{p90:0,p95:0},F=n(a=>a<=0?"\u2014":a<1?`${(a*1e3).toFixed(0)}\u03BCs`:a<1e3?`${a.toFixed(1)}ms`:`${(a/1e3).toFixed(2)}s`,"formatMs"),b=(0,v.useMemo)(()=>{if(!d||!("queryStats"in d))return;let a=d.queryStats;if(!(!a||!Array.isArray(a)))return ht(a)},[d]),N=Rt(b!==void 0,Q),k=n(()=>{Xe(I())},"runAggregate"),A=n(()=>{U(null)},"clearAggregate"),E=n(()=>{C("overview")},"switchToOverview"),L=n(()=>{C("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)(tt,{onChange:i,testId:"mt-shard-input",value:r},void 0,!1),(0,t.jsxDEV)(it,{message:H,prefix:"mt"},void 0,!1),(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate",disabled:O,onClick:k,size:"sm",type:"button",variant:"secondary",children:s(O?"Aggregating\u2026":"All shards")},void 0,!1),_!==null&&(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:s("Hide")},void 0,!1),(0,t.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:ot,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")},void 0,!1)]},void 0,!0),j!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:j},void 0,!1),b!==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 ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:E,type:"button",children:s("Overview")},void 0,!1),(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="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:[s("Query insights"),b.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:b.length},void 0,!1)]},void 0,!0)]},void 0,!0),N==="query-insights"&&b!==void 0&&(0,t.jsxDEV)(yt,{queryStats:b},void 0,!1),N==="overview"&&d!==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)(q,{chart:h.length>=2?(0,t.jsxDEV)(gt,{ariaLabel:s("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:h,testId:"mt-sparkline"},void 0,!1):void 0,footer:h.length>=2?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("span",{className:"font-semibold text-foreground",children:`+${D.toLocaleString()}`},void 0,!1)," ",s("last interval")]},void 0,!0):(0,t.jsxDEV)("span",{"data-testid":"mt-sparkline-empty",children:s("collecting samples\u2026")},void 0,!1),label:s("Requests"),testId:"mt-requests",value:d.requests},void 0,!1),(0,t.jsxDEV)(q,{footer:s("{rate} error rate",{rate:M}),label:s("Errors"),testId:"mt-errors",value:(0,t.jsxDEV)(t.Fragment,{children:[d.errors," (",M,")"]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(q,{footer:R.p90>0?`P90 ${F(R.p90)}`:void 0,label:s("P95 latency"),testId:"mt-p95",value:R.p95>0?F(R.p95):"\u2014"},void 0,!1),(0,t.jsxDEV)(q,{footer:d.cache===null?void 0:`${d.cache.entries.toLocaleString()} ${s("cache entries")}`,label:s("Database size"),testId:"mt-db-size",value:Ae(d.databaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Shard"),testId:"mt-shard",value:d.shard},void 0,!1),(0,t.jsxDEV)(q,{label:s("Uptime"),testId:"mt-uptime",value:Tt(d.uptimeMs)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Cache hit rate"),testId:"mt-cache",value:d.cache===null?s("no cache configured"):s("{rate} ({count} entries)",{count:d.cache.entries,rate:_t(d.cache.hits,d.cache.misses)})},void 0,!1)]},void 0,!0),N==="overview"&&d===null&&null,N==="overview"&&f!==null&&_!==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)(q,{label:s("Shards"),testId:"mt-agg-shards",value:f.failed>0?s("{reachable} reachable, {failed} unreachable",{failed:f.failed,reachable:f.reachable}):s("{reachable} reachable",{reachable:f.reachable})},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total requests"),testId:"mt-agg-requests",value:f.totalRequests},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total errors"),testId:"mt-agg-errors",value:f.totalErrors},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total database size"),testId:"mt-agg-db-size",value:Ae(f.totalDatabaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Combined cache hit rate"),testId:"mt-agg-cache",value:f.hitRate===null?s("no cache configured"):`${(f.hitRate*100).toFixed(1)}%`},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(B,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(P,{className:"px-0",children:(0,t.jsxDEV)(st,{"data-testid":"mt-agg-table",children:[(0,t.jsxDEV)(lt,{children:(0,t.jsxDEV)(je,{children:[(0,t.jsxDEV)($e,{children:s("shard")},void 0,!1),(0,t.jsxDEV)($e,{children:s("requests")},void 0,!1),(0,t.jsxDEV)($e,{children:s("errors")},void 0,!1),(0,t.jsxDEV)($e,{children:s("db size")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(at,{children:_.map(a=>(0,t.jsxDEV)(je,{"data-testid":`mt-agg-row-${a.shard}`,children:[(0,t.jsxDEV)(Te,{children:a.shard},void 0,!1),a.metrics===null?(0,t.jsxDEV)(Te,{className:"text-destructive",colSpan:3,children:a.error??s("unreachable")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.requests},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.errors},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:Ae(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{Kt as MetricsPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ae}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 Ce}from"./chunk-UKDJ4H7I.js";import"./chunk-TBMYIZIO.js";import{R as ke}from"./chunk-3CJW6NWG.js";import{c as H}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Te}from"./chunk-BOXSWNXZ.js";import{a as W}from"./chunk-TAD43CG5.js";import{b as Se}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as G}from"./chunk-
|
|
1
|
+
import{a as Ae}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 Ce}from"./chunk-UKDJ4H7I.js";import"./chunk-TBMYIZIO.js";import{R as ke}from"./chunk-3CJW6NWG.js";import{c as H}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Te}from"./chunk-BOXSWNXZ.js";import{a as W}from"./chunk-TAD43CG5.js";import{b as Se}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as G}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as M,e as le,f as de,g as ce,k as Ie,m as re}from"./chunk-E75ANNWX.js";import{b as Ne}from"./chunk-JHKMUTIF.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 Ue=q(oe(),1),ye=q(he(),1);var ee=q(oe(),1);var Z=q(he(),1);var B=q(ne(),1);var Ye=le(Te.listTables),Qe=["react","client","cli"],Xe=!1,Ze={action:"action",mutation:"mutation",query:"query"},Pe=p(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"splitPath"),Ee=p(({file:t,fn:e,kind:o})=>`await client.${Ze[o]}(api.${t}.${e}, { /* args */ });`,"buildClientSnippet"),et=p(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Ee(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"buildReactSnippet"),tt=p(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"buildCliSnippet"),st=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"),ot=p((t,e)=>{switch(t){case"cli":return tt(e);case"client":return Ee(e);default:return et(e)}},"snippetForTab"),_e=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 k;return e[16]!==u||e[17]!==v?(k=(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]=k):k=e[18],k},"SnippetBlock"),nt=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 T={file:o,fn:s,kind:n},I;e[8]!==r?(I=r("CLI"),e[8]=r,e[9]=I):I=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]!==I||e[15]!==P||e[16]!==E?(j={cli:I,client:P,react:E},e[14]=I,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=ot(l,T),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"&&!Xe,v=`api.${o}.${s}`,k;e[19]!==v?(k=(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]=k):k=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]!==k||e[27]!==h?(g=(0,B.jsxDEV)("div",{children:[k,h]},void 0,!0),e[26]=k,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=Qe.map(T=>(0,B.jsxDEV)(H,{"aria-selected":l===T,"data-tab":T,"data-testid":`api-tab-${T}`,onClick:d,role:"tab",size:"xs",type:"button",variant:l===T?"default":"outline",children:m[T]},T,!1)),e[31]=d,e[32]=l,e[33]=m,e[34]=b):b=e[34];let S;e[35]!==x||e[36]!==b?(S=(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]=S):S=e[37];let y=m[l],$=`api-snippet-${l}`,N;e[38]!==a||e[39]!==y||e[40]!==$?(N=(0,B.jsxDEV)(_e,{code:a,label:y,testId:$},void 0,!1),e[38]=a,e[39]=y,e[40]=$,e[41]=N):N=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]!==N||e[46]!==w||e[47]!==g||e[48]!==S?(C=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[g,S,N,w]},void 0,!0),e[45]=N,e[46]=w,e[47]=g,e[48]=S,e[49]=C):C=e[49],C},"FunctionDoc"),rt=p(t=>{let e=(0,ee.c)(19),{name:o}=t,s=M(),n;e[0]!==o?(n=st(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)(_e,{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"),Re=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"),je=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(Ye,{},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,k;if(e[6]!==v){let _=new Map;for(let D of v){let{file:V,fn:U}=Pe(D.path),ie=_.get(V)??[];ie.push({fn:U,kind:D.kind,path:D.path}),_.set(V,ie)}k=[..._.entries()].map(at).toSorted(lt),e[6]=v,e[7]=k}else k=e[7];let O=k,h,g,x,b,S,y,$,N,w,C;if(e[8]!==v||e[9]!==O||e[10]!==d||e[11]!==n||e[12]!==l){let _=(l??[]).map(dt).toSorted(ct),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:Pe(g.path),b="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",S="lunora-api-docs",e[25]!==n?(y=n("API resources"),e[25]=n,e[26]=y):y=e[26],$="flex flex-col gap-4 overflow-y-auto",N="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)(Re,{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)(Re,{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]=S,e[18]=y,e[19]=$,e[20]=N,e[21]=w,e[22]=C}else h=e[13],g=e[14],x=e[15],b=e[16],S=e[17],y=e[18],$=e[19],N=e[20],w=e[21],C=e[22];let T;e[34]!==h||e[35]!==n?(T=!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]=T):T=e[36];let I;e[37]!==T||e[38]!==y||e[39]!==$||e[40]!==N||e[41]!==w||e[42]!==C?(I=(0,B.jsxDEV)("nav",{"aria-label":y,className:$,"data-testid":N,children:[w,C,T]},void 0,!0),e[37]=T,e[38]=y,e[39]=$,e[40]=N,e[41]=w,e[42]=C,e[43]=I):I=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)(nt,{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)(rt,{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]!==S||e[64]!==I||e[65]!==L?(A=(0,B.jsxDEV)("div",{className:b,"data-testid":S,children:[I,L]},void 0,!0),e[62]=b,e[63]=S,e[64]=I,e[65]=L,e[66]=A):A=e[66],A},"ApiDocsPanel");function it(t,e){return t.fn.localeCompare(e.fn)}p(it,"_temp");function at(t){let[e,o]=t;return{file:e,items:o.toSorted(it)}}p(at,"_temp2");function lt(t,e){return t.file.localeCompare(e.file)}p(lt,"_temp3");function dt(t){return t.name}p(dt,"_temp4");function ct(t,e){return t.localeCompare(e)}p(ct,"_temp5");var Ve=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"),ft=p(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","scalarOf"),De=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"),pt=p(t=>{let e=De(t);return e!==void 0?t.type??ft(e[0]):pe(t)},"fieldTypeLabel"),ut=p(t=>{let e=De(t);return e===void 0?void 0:e.map(o=>JSON.stringify(o)).join(" | ")},"valueInText"),mt=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"),vt=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"),ht=p(t=>{let e=(0,J.c)(40),{name:o,required:s,schema:n}=t,r=M(),l;e[0]!==n?(l=mt(n),e[0]=n,e[1]=l):l=e[1];let i=l,d;e[2]!==n?(d=ut(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=vt(n),e[4]=n,e[5]=u):u=e[5];let v=u,k=s?"*":"?",O;e[6]!==k?(O=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:k},void 0,!1),e[6]=k,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=pt(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 S;e[18]!==n.description?(S=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]=S):S=e[19];let y;e[20]!==a||e[21]!==i||e[22]!==m||e[23]!==n.format||e[24]!==r||e[25]!==c?(y=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]=y):y=e[26];let $;e[27]!==S||e[28]!==y||e[29]!==b?($=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1 py-2",children:[b,S,y]},void 0,!0),e[27]=S,e[28]=y,e[29]=b,e[30]=$):$=e[30];let N=$;if(v===void 0){let I;return e[31]!==N?(I=(0,f.jsxDEV)("div",{className:"border-b border-border/50 last:border-b-0",children:N},void 0,!1),e[31]=N,e[32]=I):I=e[32],I}let w;e[33]!==N?(w=(0,f.jsxDEV)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:N},void 0,!1),e[33]=N,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)(Me,{schema:v},void 0,!1)},void 0,!1),e[35]=v,e[36]=C):C=e[36];let T;return e[37]!==w||e[38]!==C?(T=(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]=T):T=e[39],T},"FieldRow"),Me=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)(ht,{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"),Le=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)(Me,{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"),gt=["curl","javascript","lunora"],xt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},bt=p(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"apiReferenceOf"),yt=p(t=>{let e=te(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"requestBody"),Nt=p((t,e,o)=>{let s=`${o}${e.httpPath}`,n=JSON.stringify(yt(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 le}from"./chunk-LAK5VSPI.js";import{b as ae}from"./chunk-KJJ3WM6H.js";import{a as ne}from"./chunk-TQ36RWOP.js";import{a as oe}from"./chunk-UGUEC6BC.js";import{a as re}from"./chunk-2K47A3P6.js";import{a as se}from"./chunk-CACB34RQ.js";import"./chunk-XNJNSCLM.js";import{a as te}from"./chunk-UKDJ4H7I.js";import{b as ee}from"./chunk-TBMYIZIO.js";import{R as E}from"./chunk-3CJW6NWG.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as U}from"./chunk-BOXSWNXZ.js";import{a as Z}from"./chunk-TAD43CG5.js";import{b as K}from"./chunk-C7WTJLC3.js";import{b as D}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as X}from"./chunk-E75ANNWX.js";import"./chunk-GMSGZDDH.js";import{a as i,e as z,f as Te,g as qe,h as Pe,j as R}from"./chunk-RRCPZMC2.js";var T=z(qe(),1);var m=z(Te(),1);var r=z(Pe(),1);var Y=400,Me=36,Oe={height:Y,overflow:"auto"},ue={left:0,position:"absolute",top:0,width:"100%"},Ae={debug:"secondary",error:"destructive",info:"outline",warn:"secondary"},Fe={error:"destructive",ok:"secondary"},_e=i(a=>{let e=(0,T.c)(21),{entry:t,index:l,measureRef:n,start:o}=a,d=`translateY(${String(o)}px)`,v;e[0]!==d?(v={...ue,transform:d},e[0]=d,e[1]=v):v=e[1];let f=v,u;e[2]!==t.timestamp?(u=new Date(t.timestamp).toLocaleString(),e[2]=t.timestamp,e[3]=u):u=e[3];let c;e[4]!==u?(c=(0,r.jsxDEV)("span",{className:"w-44 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u},void 0,!1),e[4]=u,e[5]=c):c=e[5];let y=Ae[t.level],g;e[6]!==t.level||e[7]!==y?(g=(0,r.jsxDEV)("span",{className:"w-20 shrink-0",role:"gridcell",children:(0,r.jsxDEV)(D,{variant:y,children:t.level},void 0,!1)},void 0,!1),e[6]=t.level,e[7]=y,e[8]=g):g=e[8];let b=t.functionPath??"\u2014",p;e[9]!==b?(p=(0,r.jsxDEV)("span",{className:"w-48 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b},void 0,!1),e[9]=b,e[10]=p):p=e[10];let h;e[11]!==t.message?(h=(0,r.jsxDEV)("span",{className:"flex-1 truncate",role:"gridcell",children:t.message},void 0,!1),e[11]=t.message,e[12]=h):h=e[12];let x;return e[13]!==l||e[14]!==n||e[15]!==f||e[16]!==c||e[17]!==g||e[18]!==p||e[19]!==h?(x=(0,r.jsxDEV)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":l,"data-testid":"lg-row",ref:n,role:"row",style:f,children:[c,g,p,h]},void 0,!0),e[13]=l,e[14]=n,e[15]=f,e[16]=c,e[17]=g,e[18]=p,e[19]=h,e[20]=x):x=e[20],x},"LogRow"),ie=i(a=>a.length===0?"\u2014":a.join(", "),"tablesLabel"),Ve=i(a=>{let e=(0,T.c)(37),{entry:t,index:l,measureRef:n,start:o}=a,d=`translateY(${String(o)}px)`,v;e[0]!==d?(v={...ue,transform:d},e[0]=d,e[1]=v):v=e[1];let f=v,u;e[2]!==t.ts?(u=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=u):u=e[3];let c;e[4]!==u?(c=(0,r.jsxDEV)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u},void 0,!1),e[4]=u,e[5]=c):c=e[5];let y=Fe[t.outcome],g;e[6]!==t.outcome||e[7]!==y?(g=(0,r.jsxDEV)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsxDEV)(D,{variant:y,children:t.outcome},void 0,!1)},void 0,!1),e[6]=t.outcome,e[7]=y,e[8]=g):g=e[8];let b;e[9]!==t.functionPath?(b=(0,r.jsxDEV)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath},void 0,!1),e[9]=t.functionPath,e[10]=b):b=e[10];let p=t.shardKey??"\u2014",h;e[11]!==p?(h=(0,r.jsxDEV)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:p},void 0,!1),e[11]=p,e[12]=h):h=e[12];let x=t.userId??"\u2014",L;e[13]!==x?(L=(0,r.jsxDEV)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x},void 0,!1),e[13]=x,e[14]=L):L=e[14];let k;e[15]!==t.durationMs?(k=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=k):k=e[16];let I=`${String(k)}ms`,w;e[17]!==I?(w=(0,r.jsxDEV)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:I},void 0,!1),e[17]=I,e[18]=w):w=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ie(t.tablesRead)} \xB7 w:${ie(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let N;e[24]!==S?(N=(0,r.jsxDEV)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S},void 0,!1),e[24]=S,e[25]=N):N=e[25];let C;return e[26]!==l||e[27]!==n||e[28]!==f||e[29]!==L||e[30]!==w||e[31]!==N||e[32]!==c||e[33]!==g||e[34]!==b||e[35]!==h?(C=(0,r.jsxDEV)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":l,"data-testid":"lg-req-row",ref:n,role:"row",style:f,children:[c,g,b,h,L,w,N]},void 0,!0),e[26]=l,e[27]=n,e[28]=f,e[29]=L,e[30]=w,e[31]=N,e[32]=c,e[33]=g,e[34]=b,e[35]=h,e[36]=C):C=e[36],C},"RequestRow"),de=i(a=>{let{entries:e}=a??{};return Array.isArray(e)?e:[]},"entriesOf"),$e=i(a=>{let e={};return a.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=a.functionPathPrefix.trim()),a.userId.trim()!==""&&(e.userId=a.userId.trim()),a.tableTouched.trim()!==""&&(e.tableTouched=a.tableTouched.trim()),(a.outcome==="ok"||a.outcome==="error")&&(e.outcome=a.outcome),e},"buildRequestQuery"),me=["debug","info","warn","error"],Be={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},ze=i((a,e)=>{let t=e.search.trim().toLowerCase(),l=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-Be[e.range];return a.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||l!==""&&!(o.functionPath??"").toLowerCase().includes(l)?!1:t===""||o.message.toLowerCase().includes(t))},"filterLogs"),De="\u2014",Ke=i(a=>{let e=new Map,t=new Map;for(let o of a){e.set(o.level,(e.get(o.level)??0)+1);let d=o.functionPath??De;t.set(d,(t.get(d)??0)+1)}let l=me.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,d])=>({count:d,key:o})).toSorted((o,d)=>d.count===o.count?o.key.localeCompare(d.key):d.count-o.count);return{byLevel:l,byPath:n,total:a.length}},"summarizeLogs"),Ue=i(a=>{let e=(0,T.c)(11),{level:t,onToggle:l,selected:n}=a,o;e[0]!==t||e[1]!==l?(o=i(()=>{l(t)},"t1"),e[0]=t,e[1]=l,e[2]=o):o=e[2];let d=o,v=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",f;e[3]!==v?(f=R("rounded-md border px-2 py-1 text-xs",v),e[3]=v,e[4]=f):f=e[4];let u=`logs-level-${t}`,c;return e[5]!==t||e[6]!==d||e[7]!==n||e[8]!==f||e[9]!==u?(c=(0,r.jsxDEV)("button",{"aria-pressed":n,className:f,"data-testid":u,onClick:d,type:"button",children:t},void 0,!1),e[5]=t,e[6]=d,e[7]=n,e[8]=f,e[9]=u,e[10]=c):c=e[10],c},"LevelToggle"),ce=i(a=>{let e=(0,T.c)(7),{bucket:t}=a,l;e[0]!==t.key?(l=(0,r.jsxDEV)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key},void 0,!1),e[0]=t.key,e[1]=l):l=e[1];let n;e[2]!==t.count?(n=(0,r.jsxDEV)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count},void 0,!1),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==l||e[5]!==n?(o=(0,r.jsxDEV)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[l,n]},void 0,!0),e[4]=l,e[5]=n,e[6]=o):o=e[6],o},"SummaryBucketRow"),nt=i(({initialShardKey:a})=>{let e=X(),[t,l]=(0,m.useState)("requests"),[n,o]=(0,m.useState)(a??""),[d,v]=(0,m.useState)(""),[f,u]=(0,m.useState)(()=>new Set),[c,y]=(0,m.useState)(""),[g,b]=(0,m.useState)("all"),[p,h]=(0,m.useState)(!1),[x,L]=(0,m.useState)(""),[k,I]=(0,m.useState)(""),[w,S]=(0,m.useState)(""),[N,C]=(0,m.useState)("all"),q=re(n.trim(),400),fe=$e({functionPathPrefix:x,outcome:N,tableTouched:w,userId:k}),Q=K(U.getRequestLog,fe,{enabled:t==="requests",live:!0,shardKey:q}),W=K(U.getLogs,{},{enabled:t==="errors",live:!0,shardKey:q}),A=t==="requests"?Q:W,{error:G,errorSource:he,isLoading:H,liveError:ge}=A,ve=de(W.data),j=de(Q.data);(0,m.useEffect)(()=>{A.data!==void 0&&ee(q)},[A.data,q]);let F=ze(ve,{levels:f,now:Date.now(),path:c,range:g,search:d}),_=Ke(F),V=t==="requests"?j.length:F.length,$=t==="errors"&&p,P=(0,m.useMemo)(()=>G!==null?"error":V===0?H?$?"summary":"list":"empty":$?"summary":"list",[V,H,G,$]),J=(0,m.useRef)(null),M=ae({count:V,estimateSize:i(()=>Me,"estimateSize"),getScrollElement:i(()=>J.current,"getScrollElement"),initialRect:{height:Y,width:800},observeElementRect:i((s,B)=>le(s,B,Y),"observeElementRect"),overscan:8}),pe=M.getVirtualItems(),be={height:M.getTotalSize(),position:"relative",width:"100%"},xe=i(s=>{v(s.target.value)},"onSearchChange"),ye=i(s=>{u(B=>{let O=new Set(B);return O.has(s)?O.delete(s):O.add(s),O})},"toggleLevel"),we=i(s=>{y(s.target.value)},"onLogPathChange"),Ne=i(s=>{b(s.target.value)},"onTimeRangeChange"),Le=i(()=>{h(s=>!s)},"toggleSummary"),Se=i(s=>{L(s.target.value)},"onPathChange"),ke=i(s=>{I(s.target.value)},"onUserChange"),Ce=i(s=>{S(s.target.value)},"onTableChange"),Ee=i(s=>{C(s.target.value)},"onOutcomeChange"),Ie=i(()=>{l("requests"),h(!1)},"showRequests"),Re=i(()=>{l("errors"),h(!1)},"showErrors");return(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[(0,r.jsxDEV)("button",{"aria-selected":t==="requests",className:R("px-3 py-1 text-sm",t==="requests"?"bg-muted font-medium":"text-muted-foreground"),"data-testid":"lg-view-requests",onClick:Ie,role:"tab",type:"button",children:e("Requests")},void 0,!1),(0,r.jsxDEV)("button",{"aria-selected":t==="errors",className:R("px-3 py-1 text-sm",t==="errors"?"bg-muted font-medium":"text-muted-foreground"),"data-testid":"lg-view-errors",onClick:Re,role:"tab",type:"button",children:e("Errors")},void 0,!1)]},void 0,!0),(0,r.jsxDEV)(te,{onChange:o,testId:"lg-shard-input",value:n},void 0,!1),(0,r.jsxDEV)(oe,{message:ge,prefix:"lg"},void 0,!1),(0,r.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:ne,rel:"noreferrer",target:"_blank",children:e("Open in Cloudflare")},void 0,!1)]},void 0,!0),t==="errors"&&(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)(E,{"aria-label":e("Search messages"),className:"h-8 w-48","data-testid":"lg-search",onChange:xe,placeholder:e("search message"),value:d},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("Function path"),className:"h-8 w-40","data-testid":"logs-path-filter",onChange:we,placeholder:e("filter path"),value:c},void 0,!1),(0,r.jsxDEV)("div",{"aria-label":e("Level filter"),className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:me.map(s=>(0,r.jsxDEV)(Ue,{level:s,onToggle:ye,selected:f.has(s)},s,!1))},void 0,!1),(0,r.jsxDEV)("select",{"aria-label":e("Time range"),className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:Ne,value:g,children:[(0,r.jsxDEV)("option",{value:"all",children:e("All time")},void 0,!1),(0,r.jsxDEV)("option",{value:"5m",children:e("Last 5m")},void 0,!1),(0,r.jsxDEV)("option",{value:"15m",children:e("Last 15m")},void 0,!1),(0,r.jsxDEV)("option",{value:"1h",children:e("Last hour")},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("button",{"aria-pressed":p,className:R("h-8 rounded-md border px-3 text-sm",p?"border-border bg-muted font-medium":"border-input text-muted-foreground"),"data-testid":"logs-summary-toggle",onClick:Le,type:"button",children:e(p?"List":"Summary")},void 0,!1)]},void 0,!0),t==="requests"&&(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)(E,{"aria-label":e("Function path"),className:"h-8 w-44","data-testid":"lg-req-path",onChange:Se,placeholder:e("file:function"),value:x},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("User id"),className:"h-8 w-32","data-testid":"lg-req-user",onChange:ke,placeholder:e("userId"),value:k},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("Table touched"),className:"h-8 w-32","data-testid":"lg-req-table",onChange:Ce,placeholder:e("table"),value:w},void 0,!1),(0,r.jsxDEV)("select",{"aria-label":e("Outcome filter"),className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:Ee,value:N,children:[(0,r.jsxDEV)("option",{value:"all",children:e("all")},void 0,!1),(0,r.jsxDEV)("option",{value:"ok",children:e("ok")},void 0,!1),(0,r.jsxDEV)("option",{value:"error",children:e("error")},void 0,!1)]},void 0,!0)]},void 0,!0),P==="error"&&(0,r.jsxDEV)(se,{error:he,testId:"lg-error"},void 0,!1),P==="empty"&&(0,r.jsxDEV)(Z,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsxDEV)("path",{d:"M4 5h16M4 12h16M4 19h10"},void 0,!1)},void 0,!1),testId:"lg-empty",title:e("No logs.")},void 0,!1),P==="summary"&&(0,r.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[(0,r.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:e("{count} entries",{count:_.total})},void 0,!1),(0,r.jsxDEV)("div",{children:[(0,r.jsxDEV)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:e("By level")},void 0,!1),(0,r.jsxDEV)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:_.byLevel.map(s=>(0,r.jsxDEV)(ce,{bucket:s},s.key,!1))},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{children:[(0,r.jsxDEV)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:e("By function")},void 0,!1),(0,r.jsxDEV)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:_.byPath.map(s=>(0,r.jsxDEV)(ce,{bucket:s},s.key,!1))},void 0,!1)]},void 0,!0)]},void 0,!0),P==="list"&&(0,r.jsxDEV)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:J,style:Oe,children:(0,r.jsxDEV)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:be,children:pe.map(s=>t==="requests"?(0,r.jsxDEV)(Ve,{entry:j[s.index],index:s.index,measureRef:M.measureElement,start:s.start},s.key,!1):(0,r.jsxDEV)(_e,{entry:F[s.index],index:s.index,measureRef:M.measureElement,start:s.start},s.key,!1))},void 0,!1)},void 0,!1)]},void 0,!0)},"LogsPanel");export{nt as LogsPanel,ze as filterLogs,Ke as summarizeLogs};
|
|
1
|
+
import{a as le}from"./chunk-LAK5VSPI.js";import{b as ae}from"./chunk-KJJ3WM6H.js";import{a as ne}from"./chunk-TQ36RWOP.js";import{a as oe}from"./chunk-UGUEC6BC.js";import{a as re}from"./chunk-2K47A3P6.js";import{a as se}from"./chunk-HN6KJXYQ.js";import"./chunk-XNJNSCLM.js";import{a as te}from"./chunk-UKDJ4H7I.js";import{b as ee}from"./chunk-TBMYIZIO.js";import{R as E}from"./chunk-3CJW6NWG.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as U}from"./chunk-BOXSWNXZ.js";import{a as Z}from"./chunk-TAD43CG5.js";import{b as K}from"./chunk-RHZ4M2NZ.js";import{b as D}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as X}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as i,e as z,f as Te,g as qe,h as Pe,j as R}from"./chunk-RRCPZMC2.js";var T=z(qe(),1);var m=z(Te(),1);var r=z(Pe(),1);var Y=400,Me=36,Oe={height:Y,overflow:"auto"},ue={left:0,position:"absolute",top:0,width:"100%"},Ae={debug:"secondary",error:"destructive",info:"outline",warn:"secondary"},Fe={error:"destructive",ok:"secondary"},_e=i(a=>{let e=(0,T.c)(21),{entry:t,index:l,measureRef:n,start:o}=a,d=`translateY(${String(o)}px)`,v;e[0]!==d?(v={...ue,transform:d},e[0]=d,e[1]=v):v=e[1];let f=v,u;e[2]!==t.timestamp?(u=new Date(t.timestamp).toLocaleString(),e[2]=t.timestamp,e[3]=u):u=e[3];let c;e[4]!==u?(c=(0,r.jsxDEV)("span",{className:"w-44 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u},void 0,!1),e[4]=u,e[5]=c):c=e[5];let y=Ae[t.level],g;e[6]!==t.level||e[7]!==y?(g=(0,r.jsxDEV)("span",{className:"w-20 shrink-0",role:"gridcell",children:(0,r.jsxDEV)(D,{variant:y,children:t.level},void 0,!1)},void 0,!1),e[6]=t.level,e[7]=y,e[8]=g):g=e[8];let b=t.functionPath??"\u2014",p;e[9]!==b?(p=(0,r.jsxDEV)("span",{className:"w-48 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b},void 0,!1),e[9]=b,e[10]=p):p=e[10];let h;e[11]!==t.message?(h=(0,r.jsxDEV)("span",{className:"flex-1 truncate",role:"gridcell",children:t.message},void 0,!1),e[11]=t.message,e[12]=h):h=e[12];let x;return e[13]!==l||e[14]!==n||e[15]!==f||e[16]!==c||e[17]!==g||e[18]!==p||e[19]!==h?(x=(0,r.jsxDEV)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":l,"data-testid":"lg-row",ref:n,role:"row",style:f,children:[c,g,p,h]},void 0,!0),e[13]=l,e[14]=n,e[15]=f,e[16]=c,e[17]=g,e[18]=p,e[19]=h,e[20]=x):x=e[20],x},"LogRow"),ie=i(a=>a.length===0?"\u2014":a.join(", "),"tablesLabel"),Ve=i(a=>{let e=(0,T.c)(37),{entry:t,index:l,measureRef:n,start:o}=a,d=`translateY(${String(o)}px)`,v;e[0]!==d?(v={...ue,transform:d},e[0]=d,e[1]=v):v=e[1];let f=v,u;e[2]!==t.ts?(u=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=u):u=e[3];let c;e[4]!==u?(c=(0,r.jsxDEV)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u},void 0,!1),e[4]=u,e[5]=c):c=e[5];let y=Fe[t.outcome],g;e[6]!==t.outcome||e[7]!==y?(g=(0,r.jsxDEV)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsxDEV)(D,{variant:y,children:t.outcome},void 0,!1)},void 0,!1),e[6]=t.outcome,e[7]=y,e[8]=g):g=e[8];let b;e[9]!==t.functionPath?(b=(0,r.jsxDEV)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath},void 0,!1),e[9]=t.functionPath,e[10]=b):b=e[10];let p=t.shardKey??"\u2014",h;e[11]!==p?(h=(0,r.jsxDEV)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:p},void 0,!1),e[11]=p,e[12]=h):h=e[12];let x=t.userId??"\u2014",L;e[13]!==x?(L=(0,r.jsxDEV)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x},void 0,!1),e[13]=x,e[14]=L):L=e[14];let k;e[15]!==t.durationMs?(k=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=k):k=e[16];let I=`${String(k)}ms`,w;e[17]!==I?(w=(0,r.jsxDEV)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:I},void 0,!1),e[17]=I,e[18]=w):w=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ie(t.tablesRead)} \xB7 w:${ie(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let N;e[24]!==S?(N=(0,r.jsxDEV)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S},void 0,!1),e[24]=S,e[25]=N):N=e[25];let C;return e[26]!==l||e[27]!==n||e[28]!==f||e[29]!==L||e[30]!==w||e[31]!==N||e[32]!==c||e[33]!==g||e[34]!==b||e[35]!==h?(C=(0,r.jsxDEV)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":l,"data-testid":"lg-req-row",ref:n,role:"row",style:f,children:[c,g,b,h,L,w,N]},void 0,!0),e[26]=l,e[27]=n,e[28]=f,e[29]=L,e[30]=w,e[31]=N,e[32]=c,e[33]=g,e[34]=b,e[35]=h,e[36]=C):C=e[36],C},"RequestRow"),de=i(a=>{let{entries:e}=a??{};return Array.isArray(e)?e:[]},"entriesOf"),$e=i(a=>{let e={};return a.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=a.functionPathPrefix.trim()),a.userId.trim()!==""&&(e.userId=a.userId.trim()),a.tableTouched.trim()!==""&&(e.tableTouched=a.tableTouched.trim()),(a.outcome==="ok"||a.outcome==="error")&&(e.outcome=a.outcome),e},"buildRequestQuery"),me=["debug","info","warn","error"],Be={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},ze=i((a,e)=>{let t=e.search.trim().toLowerCase(),l=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-Be[e.range];return a.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||l!==""&&!(o.functionPath??"").toLowerCase().includes(l)?!1:t===""||o.message.toLowerCase().includes(t))},"filterLogs"),De="\u2014",Ke=i(a=>{let e=new Map,t=new Map;for(let o of a){e.set(o.level,(e.get(o.level)??0)+1);let d=o.functionPath??De;t.set(d,(t.get(d)??0)+1)}let l=me.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,d])=>({count:d,key:o})).toSorted((o,d)=>d.count===o.count?o.key.localeCompare(d.key):d.count-o.count);return{byLevel:l,byPath:n,total:a.length}},"summarizeLogs"),Ue=i(a=>{let e=(0,T.c)(11),{level:t,onToggle:l,selected:n}=a,o;e[0]!==t||e[1]!==l?(o=i(()=>{l(t)},"t1"),e[0]=t,e[1]=l,e[2]=o):o=e[2];let d=o,v=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",f;e[3]!==v?(f=R("rounded-md border px-2 py-1 text-xs",v),e[3]=v,e[4]=f):f=e[4];let u=`logs-level-${t}`,c;return e[5]!==t||e[6]!==d||e[7]!==n||e[8]!==f||e[9]!==u?(c=(0,r.jsxDEV)("button",{"aria-pressed":n,className:f,"data-testid":u,onClick:d,type:"button",children:t},void 0,!1),e[5]=t,e[6]=d,e[7]=n,e[8]=f,e[9]=u,e[10]=c):c=e[10],c},"LevelToggle"),ce=i(a=>{let e=(0,T.c)(7),{bucket:t}=a,l;e[0]!==t.key?(l=(0,r.jsxDEV)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key},void 0,!1),e[0]=t.key,e[1]=l):l=e[1];let n;e[2]!==t.count?(n=(0,r.jsxDEV)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count},void 0,!1),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==l||e[5]!==n?(o=(0,r.jsxDEV)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[l,n]},void 0,!0),e[4]=l,e[5]=n,e[6]=o):o=e[6],o},"SummaryBucketRow"),nt=i(({initialShardKey:a})=>{let e=X(),[t,l]=(0,m.useState)("requests"),[n,o]=(0,m.useState)(a??""),[d,v]=(0,m.useState)(""),[f,u]=(0,m.useState)(()=>new Set),[c,y]=(0,m.useState)(""),[g,b]=(0,m.useState)("all"),[p,h]=(0,m.useState)(!1),[x,L]=(0,m.useState)(""),[k,I]=(0,m.useState)(""),[w,S]=(0,m.useState)(""),[N,C]=(0,m.useState)("all"),q=re(n.trim(),400),fe=$e({functionPathPrefix:x,outcome:N,tableTouched:w,userId:k}),Q=K(U.getRequestLog,fe,{enabled:t==="requests",live:!0,shardKey:q}),W=K(U.getLogs,{},{enabled:t==="errors",live:!0,shardKey:q}),A=t==="requests"?Q:W,{error:G,errorSource:he,isLoading:H,liveError:ge}=A,ve=de(W.data),j=de(Q.data);(0,m.useEffect)(()=>{A.data!==void 0&&ee(q)},[A.data,q]);let F=ze(ve,{levels:f,now:Date.now(),path:c,range:g,search:d}),_=Ke(F),V=t==="requests"?j.length:F.length,$=t==="errors"&&p,P=(0,m.useMemo)(()=>G!==null?"error":V===0?H?$?"summary":"list":"empty":$?"summary":"list",[V,H,G,$]),J=(0,m.useRef)(null),M=ae({count:V,estimateSize:i(()=>Me,"estimateSize"),getScrollElement:i(()=>J.current,"getScrollElement"),initialRect:{height:Y,width:800},observeElementRect:i((s,B)=>le(s,B,Y),"observeElementRect"),overscan:8}),pe=M.getVirtualItems(),be={height:M.getTotalSize(),position:"relative",width:"100%"},xe=i(s=>{v(s.target.value)},"onSearchChange"),ye=i(s=>{u(B=>{let O=new Set(B);return O.has(s)?O.delete(s):O.add(s),O})},"toggleLevel"),we=i(s=>{y(s.target.value)},"onLogPathChange"),Ne=i(s=>{b(s.target.value)},"onTimeRangeChange"),Le=i(()=>{h(s=>!s)},"toggleSummary"),Se=i(s=>{L(s.target.value)},"onPathChange"),ke=i(s=>{I(s.target.value)},"onUserChange"),Ce=i(s=>{S(s.target.value)},"onTableChange"),Ee=i(s=>{C(s.target.value)},"onOutcomeChange"),Ie=i(()=>{l("requests"),h(!1)},"showRequests"),Re=i(()=>{l("errors"),h(!1)},"showErrors");return(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[(0,r.jsxDEV)("button",{"aria-selected":t==="requests",className:R("px-3 py-1 text-sm",t==="requests"?"bg-muted font-medium":"text-muted-foreground"),"data-testid":"lg-view-requests",onClick:Ie,role:"tab",type:"button",children:e("Requests")},void 0,!1),(0,r.jsxDEV)("button",{"aria-selected":t==="errors",className:R("px-3 py-1 text-sm",t==="errors"?"bg-muted font-medium":"text-muted-foreground"),"data-testid":"lg-view-errors",onClick:Re,role:"tab",type:"button",children:e("Errors")},void 0,!1)]},void 0,!0),(0,r.jsxDEV)(te,{onChange:o,testId:"lg-shard-input",value:n},void 0,!1),(0,r.jsxDEV)(oe,{message:ge,prefix:"lg"},void 0,!1),(0,r.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:ne,rel:"noreferrer",target:"_blank",children:e("Open in Cloudflare")},void 0,!1)]},void 0,!0),t==="errors"&&(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)(E,{"aria-label":e("Search messages"),className:"h-8 w-48","data-testid":"lg-search",onChange:xe,placeholder:e("search message"),value:d},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("Function path"),className:"h-8 w-40","data-testid":"logs-path-filter",onChange:we,placeholder:e("filter path"),value:c},void 0,!1),(0,r.jsxDEV)("div",{"aria-label":e("Level filter"),className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:me.map(s=>(0,r.jsxDEV)(Ue,{level:s,onToggle:ye,selected:f.has(s)},s,!1))},void 0,!1),(0,r.jsxDEV)("select",{"aria-label":e("Time range"),className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:Ne,value:g,children:[(0,r.jsxDEV)("option",{value:"all",children:e("All time")},void 0,!1),(0,r.jsxDEV)("option",{value:"5m",children:e("Last 5m")},void 0,!1),(0,r.jsxDEV)("option",{value:"15m",children:e("Last 15m")},void 0,!1),(0,r.jsxDEV)("option",{value:"1h",children:e("Last hour")},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("button",{"aria-pressed":p,className:R("h-8 rounded-md border px-3 text-sm",p?"border-border bg-muted font-medium":"border-input text-muted-foreground"),"data-testid":"logs-summary-toggle",onClick:Le,type:"button",children:e(p?"List":"Summary")},void 0,!1)]},void 0,!0),t==="requests"&&(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)(E,{"aria-label":e("Function path"),className:"h-8 w-44","data-testid":"lg-req-path",onChange:Se,placeholder:e("file:function"),value:x},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("User id"),className:"h-8 w-32","data-testid":"lg-req-user",onChange:ke,placeholder:e("userId"),value:k},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("Table touched"),className:"h-8 w-32","data-testid":"lg-req-table",onChange:Ce,placeholder:e("table"),value:w},void 0,!1),(0,r.jsxDEV)("select",{"aria-label":e("Outcome filter"),className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:Ee,value:N,children:[(0,r.jsxDEV)("option",{value:"all",children:e("all")},void 0,!1),(0,r.jsxDEV)("option",{value:"ok",children:e("ok")},void 0,!1),(0,r.jsxDEV)("option",{value:"error",children:e("error")},void 0,!1)]},void 0,!0)]},void 0,!0),P==="error"&&(0,r.jsxDEV)(se,{error:he,testId:"lg-error"},void 0,!1),P==="empty"&&(0,r.jsxDEV)(Z,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsxDEV)("path",{d:"M4 5h16M4 12h16M4 19h10"},void 0,!1)},void 0,!1),testId:"lg-empty",title:e("No logs.")},void 0,!1),P==="summary"&&(0,r.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[(0,r.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:e("{count} entries",{count:_.total})},void 0,!1),(0,r.jsxDEV)("div",{children:[(0,r.jsxDEV)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:e("By level")},void 0,!1),(0,r.jsxDEV)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:_.byLevel.map(s=>(0,r.jsxDEV)(ce,{bucket:s},s.key,!1))},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{children:[(0,r.jsxDEV)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:e("By function")},void 0,!1),(0,r.jsxDEV)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:_.byPath.map(s=>(0,r.jsxDEV)(ce,{bucket:s},s.key,!1))},void 0,!1)]},void 0,!0)]},void 0,!0),P==="list"&&(0,r.jsxDEV)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:J,style:Oe,children:(0,r.jsxDEV)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:be,children:pe.map(s=>t==="requests"?(0,r.jsxDEV)(Ve,{entry:j[s.index],index:s.index,measureRef:M.measureElement,start:s.start},s.key,!1):(0,r.jsxDEV)(_e,{entry:F[s.index],index:s.index,measureRef:M.measureElement,start:s.start},s.key,!1))},void 0,!1)},void 0,!1)]},void 0,!0)},"LogsPanel");export{nt as LogsPanel,ze as filterLogs,Ke as summarizeLogs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T,b as w,c as A,d as C}from"./chunk-
|
|
1
|
+
import{a as T,b as w,c as A,d as C}from"./chunk-6HSHEMZV.js";import{d as y,j as N}from"./chunk-E75ANNWX.js";import{a as i,e as b,f as x,g as E,h as I}from"./chunk-RRCPZMC2.js";var g=b(E(),1);var m=b(I(),1),S=b(x(),1);var _=50,B={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},J=i(s=>{let t=s.columns.find(l=>s.rows.length>0&&s.rows.every(n=>typeof n[l]=="number"))??null;return{label:s.columns.find(l=>l!==t)??null,value:t}},"pickColumns"),X=i(s=>{let t=(0,g.c)(15),{result:e}=s,l=y(),n;t[0]!==e?(n=J(e),t[0]=e,t[1]=n):n=t[1];let{label:o,value:r}=n,a;t[2]!==o||t[3]!==e||t[4]!==r?(a=r===null?[]:e.rows.slice(0,_).map((c,h)=>({label:o===null?`#${(h+1).toString()}`:N(c[o]),value:Number(c[r])||0})),t[2]=o,t[3]=e,t[4]=r,t[5]=a):a=t[5];let u=a;if(r===null){let c;t[6]!==l?(c=l("No numeric column to chart."),t[6]=l,t[7]=c):c=t[7];let h;return t[8]!==c?(h=(0,m.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:c},void 0,!1),t[8]=c,t[9]=h):h=t[9],h}let f,d,v;t[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,m.jsxDEV)(A,{dataKey:"label"},void 0,!1),d=(0,m.jsxDEV)(w,{dataKey:"value"},void 0,!1),v=(0,m.jsxDEV)(C,{},void 0,!1),t[10]=f,t[11]=d,t[12]=v):(f=t[10],d=t[11],v=t[12]);let p;return t[13]!==u?(p=(0,m.jsxDEV)("div",{className:"h-80 w-full p-3","data-testid":"sql-chart",children:(0,m.jsxDEV)(T,{className:"h-full w-full",config:B,data:u,children:[f,d,v]},void 0,!0)},void 0,!1),t[13]=u,t[14]=p):p=t[14],p},"SqlResultChart"),$=i(()=>{try{return globalThis.localStorage}catch{return}},"store"),R=i(function(s){try{let t=$()?.getItem(s)??void 0,e=t===void 0?[]:JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}},"loadJsonArray"),V=i((s,t)=>{let e=$();if(e!==void 0)try{e.setItem(s,JSON.stringify(t))}catch{}},"saveJson"),q=i(function(s){let t=(0,g.c)(8),e;t[0]!==s?(e=i(()=>R(s),"t0"),t[0]=s,t[1]=e):e=t[1];let[l,n]=(0,S.useState)(e),o,r;t[2]!==s||t[3]!==l?(o=i(()=>{V(s,l)},"t1"),r=[s,l],t[2]=s,t[3]=l,t[4]=o,t[5]=r):(o=t[4],r=t[5]),(0,S.useEffect)(o,r);let a;return t[6]!==l?(a=[l,n],t[6]=l,t[7]=a):a=t[7],a},"usePersistedList"),D=i(function(s,t){let e=(0,g.c)(6),[l,n]=q(s),o;e[0]!==t||e[1]!==n?(o=i(f=>{n(d=>{let v=d[0]??t;return[typeof f=="function"?f(v):f]})},"t0"),e[0]=t,e[1]=n,e[2]=o):o=e[2];let r=o,a=l[0]??t,u;return e[3]!==r||e[4]!==a?(u=[a,r],e[3]=r,e[4]=a,e[5]=u):u=e[5],u},"usePersistedValue"),K=i(s=>globalThis.crypto?.randomUUID?.()??`${s}-${globalThis.performance.now().toString(36)}`,"newId");export{X as a,q as b,D as c,K as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as V}from"./chunk-VLXV72QE.js";import{a as g}from"./chunk-JSEXCW5Q.js";import{a as z}from"./chunk-UKDJ4H7I.js";import{b as q}from"./chunk-TBMYIZIO.js";import{R as j}from"./chunk-3CJW6NWG.js";import{c as p}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as P}from"./chunk-BOXSWNXZ.js";import{b as w}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as L}from"./chunk-
|
|
1
|
+
import{a as V}from"./chunk-VLXV72QE.js";import{a as g}from"./chunk-JSEXCW5Q.js";import{a as z}from"./chunk-UKDJ4H7I.js";import{b as q}from"./chunk-TBMYIZIO.js";import{R as j}from"./chunk-3CJW6NWG.js";import{c as p}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as P}from"./chunk-BOXSWNXZ.js";import{b as w}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as L}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U,e as B,g as J,k as K,o as M}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a,e as D,f as oe,h as ne}from"./chunk-RRCPZMC2.js";var n=D(oe(),1);var t=D(ne(),1);var ie=a(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"argumentType"),de=a(r=>r===void 0||r.length===0?"()":`(${r.map(l=>`${l.name}${l.optional?"?":""}: ${ie(l)}`).join(", ")})`,"formatSignature"),le=a(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"placeholderValue"),ce=a(r=>{let l={};for(let s of r??[])s.optional||(l[s.name]=le(s.kind));return JSON.stringify(l,void 0,2)},"argumentsTemplate"),ue=B(P.runAs),fe=10,me=a(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"formatResult"),Ie=a(({functions:r,runAsIdentity:l=!1}={})=>{let s=U(),c=L(),[H,X]=(0,n.useState)(null),[k,Y]=(0,n.useState)(null),x=r??H??[],[R,I]=(0,n.useState)(""),[f,b]=(0,n.useState)("{}"),[u,A]=(0,n.useState)(""),[m,G]=(0,n.useState)(""),[N,h]=(0,n.useState)("idle"),[Q,y]=(0,n.useState)(void 0),[C,S]=(0,n.useState)(null),[T,W]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(r!==void 0)return;let e=!1;return c.listFunctions().then(i=>(e||X(i),i)).catch(i=>{e||Y(J(i))}),()=>{e=!0}},[c,r]);let F=R===""?x[0]?.path??"":R,o=x.find(e=>e.path===F),Z=a(async()=>{if(!o)return;let e;try{e=f.trim()===""?{}:JSON.parse(f)}catch(d){h("error"),y(void 0),S(s("Invalid JSON args: {message}",{message:d.message}));return}let i={__lunoraRef:o.path},v=u.trim()===""?{}:{shardKey:u.trim()},$=l?m.trim():"",E=a(d=>{W(O=>[{argsText:f,at:Date.now(),id:(O[0]?.id??0)+1,kind:o.kind,path:o.path,shardKey:u,status:d},...O].slice(0,fe))},"record");h("running"),S(null);try{let d;if($==="")switch(o.kind){case"action":{d=await c.action(i,e,v);break}case"mutation":{d=await c.mutation(i,e,v);break}default:d=await c.query(i,e,v)}else d=await c.query(ue,{args:e,functionPath:o.path,userId:$},v);q(u),y(d),h("success"),E("success")}catch(d){y(void 0),S(d.message),h("error"),E("error")}},"run"),_=a(e=>{I(e.path),b(e.argsText),A(e.shardKey)},"loadRun"),ee=a(e=>{I(e.target.value)},"onSelectChange"),te=a(e=>{b(e.target.value)},"onArgsChange"),re=a(e=>{G(e.target.value)},"onRunAsChange"),se=a(()=>{K(Z())},"runOnce"),ae=a(()=>{b(ce(o?.args))},"prefillArgs");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxDEV)(g,{htmlFor:"function-select",children:s("Function")},void 0,!1),(0,t.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 transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:ee,value:F,children:x.map(e=>(0,t.jsxDEV)("option",{value:e.path,children:[e.path," (",e.kind,")"]},e.path,!0))},void 0,!1),o!==void 0&&(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:[(0,t.jsxDEV)("span",{className:"mr-1.5 font-medium",children:s("Signature")},void 0,!1),(0,t.jsxDEV)("code",{className:"font-mono","data-testid":"function-signature",children:de(o.args)},void 0,!1)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxDEV)(g,{htmlFor:"args-input",children:s("Arguments")},void 0,!1),(0,t.jsxDEV)(p,{"data-testid":"prefill-button",disabled:o===void 0,onClick:ae,size:"xs",type:"button",variant:"ghost",children:s("Prefill")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(V,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:te,value:f},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(z,{onChange:A,testId:"shard-input",value:u},void 0,!1),l&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,t.jsxDEV)(g,{htmlFor:"run-as-input",children:s("Run as identity (userId)")},void 0,!1),(0,t.jsxDEV)(j,{"aria-label":s("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:re,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1),(0,t.jsxDEV)("p",{className:"text-[11px] text-muted-foreground",children:s("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(p,{"data-testid":"run-button",disabled:N==="running"||o===void 0,onClick:se,type:"button",children:s("Run")},void 0,!1),o!==void 0&&(0,t.jsxDEV)(w,{variant:"outline",children:o.kind},void 0,!1),l&&m.trim()!==""&&(0,t.jsxDEV)(w,{"data-testid":"run-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),N==="error"&&C!==null&&(0,t.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C},void 0,!1),N==="success"&&(0,t.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:me(Q)},void 0,!1),T.length>0&&(0,t.jsxDEV)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:T.map((e,i)=>(0,t.jsxDEV)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,t.jsxDEV)("span",{className:e.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${i.toString()}`,children:e.status==="success"?"\u2713":"\u2717"},void 0,!1)," ",(0,t.jsxDEV)("span",{className:"font-mono text-xs",children:[e.path," (",e.kind,")"]},void 0,!0)," ",(0,t.jsxDEV)("time",{className:"text-xs text-muted-foreground",children:M(e.at)},void 0,!1)," ",(0,t.jsxDEV)(p,{className:"ml-auto","data-testid":`fn-history-load-${i.toString()}`,onClick:a(()=>{_(e)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Load")},void 0,!1)]},e.id,!0))},void 0,!1)]},void 0,!0)},"FunctionRunner");export{Ie as FunctionRunner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b,c as v,d as g,f as D}from"./chunk-
|
|
1
|
+
import{b,c as v,d as g,f as D}from"./chunk-XLXNLJ4N.js";import{e as y,f as p,g as P,k as O}from"./chunk-E75ANNWX.js";import{a as n,e as Q,f as N,g as _}from"./chunk-RRCPZMC2.js";var E=Q(_(),1);var c=Q(N(),1);var C=n((e,r,o)=>["lunora-admin",e,r,o.trim()],"adminQueryKey"),h=1e3,S=25,q=new Map,k=n(e=>{let r=Date.now(),o=(q.get(e)??[]).filter(s=>r-s<h);o.push(r),q.set(e,o),o.length===S&&(console.error(`[lunora-studio] possible request loop: ${e} fired ${String(S)}\xD7 in <1s \u2014 a render/effect is re-issuing this read unbounded.`),console.trace("[lunora-studio] request-loop call site"))},"noteQueryFetch");function R(e,r,o={}){let{enabled:s=!0,keepPreviousData:a=!1,staleTime:i=0}=o,t=g({enabled:s,queryFn:n(()=>(k(JSON.stringify(e)),r()),"trackedQueryFunction"),placeholderData:a?b:void 0,queryKey:e,staleTime:i});return{data:t.data,error:t.error?P(t.error):t.error,errorSource:t.error??void 0,isLoading:t.isLoading,liveError:void 0,refetch:n(()=>{O(t.refetch())},"refetch")}}n(R,"useClientQuery");function K(e,r,o={}){let s=D(),a=v(),{enabled:i=!0,keepPreviousData:u=!1,live:t=!1,shardKey:l="",staleTime:I}=o,d=C(e,r,l),L=R(d,()=>s.query(y(e),r,p(l)),{enabled:i,keepPreviousData:u,staleTime:I??(t?Number.POSITIVE_INFINITY:0)}),[T,f]=(0,c.useState)(void 0),F=JSON.stringify(d);return(0,c.useEffect)(()=>{if(!(!i||!t))return f(void 0),s.subscribe(y(e),r,m=>{f(void 0),a.setQueryData(d,m)},{...p(l),onError:n(m=>{f(m.message)},"onError")})},[F,i,t]),{...L,liveError:i&&t?T:void 0}}n(K,"useAdminQuery");var M=n(()=>{let e=(0,E.c)(2),r=v(),o;return e[0]!==r?(o=n((s,a,i)=>{let u=a===void 0?["lunora-admin",s]:C(s,a,i??"");O(r.invalidateQueries({queryKey:u}))},"t0"),e[0]=r,e[1]=o):o=e[1],o},"useInvalidateAdmin");export{R as a,K as b,M as c};
|