@lunora/studio 1.0.0-alpha.333 → 1.0.0-alpha.335
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-2YEDTLGD.js → chunk-2OSBOZSF.js} +1 -1
- package/dist/standalone/{chunk-TNF67D54.js → chunk-35LRTD6L.js} +1 -1
- package/dist/standalone/{chunk-QA5RUU7W.js → chunk-3APWNQJ3.js} +1 -1
- package/dist/standalone/{chunk-UJTSGF6S.js → chunk-3DRBFZ2R.js} +1 -1
- package/dist/standalone/{chunk-5V4REVOK.js → chunk-3EFAEGID.js} +1 -1
- package/dist/standalone/{chunk-ZODHG66O.js → chunk-3LD7PBIC.js} +1 -1
- package/dist/standalone/{chunk-V5JA533L.js → chunk-3SSDUHUE.js} +1 -1
- package/dist/standalone/{chunk-KLDGZ5FU.js → chunk-3VI2EZN2.js} +1 -1
- package/dist/standalone/{chunk-RGUL4AQZ.js → chunk-5AXRIRHW.js} +1 -1
- package/dist/standalone/{chunk-IWF4IWJT.js → chunk-5OGXAO7S.js} +1 -1
- package/dist/standalone/{chunk-6JMKSAOS.js → chunk-5UDEPHRK.js} +1 -1
- package/dist/standalone/{chunk-PPXPRPMU.js → chunk-6K7ZB6M6.js} +1 -1
- package/dist/standalone/{chunk-3TL6EMCG.js → chunk-6RYVH5BG.js} +1 -1
- package/dist/standalone/{chunk-YXTJSSB4.js → chunk-6XRGQ3ND.js} +1 -1
- package/dist/standalone/{chunk-4RDTHNCM.js → chunk-7COKTU5I.js} +1 -1
- package/dist/standalone/{chunk-DCD562KJ.js → chunk-7XBIOLIW.js} +1 -1
- package/dist/standalone/{chunk-JPEXFCD7.js → chunk-AUUB5SEX.js} +1 -1
- package/dist/standalone/{chunk-CMAPNVCT.js → chunk-AWGYECJN.js} +1 -1
- package/dist/standalone/{chunk-MBW5C5GU.js → chunk-AX2GEOKC.js} +1 -1
- package/dist/standalone/{chunk-F2JMVU2F.js → chunk-BOUF5HG7.js} +1 -1
- package/dist/standalone/{chunk-NGPK5RSU.js → chunk-BPDWF4EX.js} +1 -1
- package/dist/standalone/{chunk-CWVYS5LB.js → chunk-BUH67LRI.js} +1 -1
- package/dist/standalone/{chunk-GBAQ5M7Y.js → chunk-CS7K5PAU.js} +1 -1
- package/dist/standalone/{chunk-KTJR54TW.js → chunk-EA2RNGEE.js} +1 -1
- package/dist/standalone/{chunk-ESQNSJEK.js → chunk-EOCVVABQ.js} +1 -1
- package/dist/standalone/{chunk-KPRNLQKZ.js → chunk-EQRZJZD4.js} +3 -3
- package/dist/standalone/{chunk-QYPMUUYF.js → chunk-FKS6EUNJ.js} +1 -1
- package/dist/standalone/{chunk-2VIGYW3S.js → chunk-FYW6TV4Q.js} +1 -1
- package/dist/standalone/{chunk-6T6JFHWU.js → chunk-GW4GGPRY.js} +1 -1
- package/dist/standalone/{chunk-I6VQ56RO.js → chunk-HD2IF5L4.js} +1 -1
- package/dist/standalone/{chunk-KU2V3NDJ.js → chunk-HFR5DYKT.js} +1 -1
- package/dist/standalone/{chunk-KNYZMZPY.js → chunk-IIIYLX6U.js} +1 -1
- package/dist/standalone/{chunk-HNMSVHPM.js → chunk-JNW2ARJO.js} +1 -1
- package/dist/standalone/{chunk-NQNI4E56.js → chunk-JT3XCMAO.js} +1 -1
- package/dist/standalone/{chunk-DVCBS7Z6.js → chunk-KT4UNIZB.js} +1 -1
- package/dist/standalone/{chunk-PRQKA5BT.js → chunk-KVEG7CIS.js} +1 -1
- package/dist/standalone/{chunk-WDWGLJNK.js → chunk-L3NY3CEL.js} +1 -1
- package/dist/standalone/{chunk-L5ZKGZHX.js → chunk-L5UNLRGK.js} +1 -1
- package/dist/standalone/{chunk-OOQHMMNK.js → chunk-LVKT5NQQ.js} +1 -1
- package/dist/standalone/{chunk-VKSSPTTK.js → chunk-MW6W7DGV.js} +1 -1
- package/dist/standalone/{chunk-YF3GD7OV.js → chunk-P7I3HBJN.js} +1 -1
- package/dist/standalone/{chunk-7NGFZ7OK.js → chunk-Q5KTZWZ2.js} +1 -1
- package/dist/standalone/{chunk-V6IC22GP.js → chunk-R36PEHB2.js} +1 -1
- package/dist/standalone/{chunk-I5PK6SLS.js → chunk-SBDEC37M.js} +1 -1
- package/dist/standalone/{chunk-6M5R5VXY.js → chunk-SHCUZSRI.js} +1 -1
- package/dist/standalone/{chunk-IHAUHNTM.js → chunk-SL7YMFRX.js} +1 -1
- package/dist/standalone/{chunk-544PMJL6.js → chunk-T4Y5DPRN.js} +1 -1
- package/dist/standalone/{chunk-357O3FBE.js → chunk-T6J6Q5Q2.js} +1 -1
- package/dist/standalone/{chunk-ZVGDUDHN.js → chunk-TKMI2XAK.js} +1 -1
- package/dist/standalone/{chunk-I5U5LU6L.js → chunk-VHL2HNC5.js} +1 -1
- package/dist/standalone/{chunk-XSVQZ5JW.js → chunk-VOLGQ2EF.js} +1 -1
- package/dist/standalone/{chunk-UHCFEXE5.js → chunk-VQH2F33R.js} +1 -1
- package/dist/standalone/{chunk-UUESQ5A2.js → chunk-XBTCFWYG.js} +1 -1
- package/dist/standalone/{chunk-R7SRERCX.js → chunk-XC2LTW44.js} +1 -1
- package/dist/standalone/{chunk-DMEGDUGQ.js → chunk-XN2YDTTH.js} +1 -1
- package/dist/standalone/{chunk-LSNLFUZ6.js → chunk-YHTANVUO.js} +1 -1
- package/dist/standalone/{chunk-QTDX7WSP.js → chunk-YSPQIRER.js} +1 -1
- package/dist/standalone/{chunk-2CDRWAL6.js → chunk-Z643LPA5.js} +1 -1
- package/dist/standalone/{chunk-KQ7RUNQV.js → chunk-ZPYEW5ZL.js} +1 -1
- package/dist/standalone/{chunk-3ZVTL2VM.js → chunk-ZRFRFHRU.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as fe}from"./chunk-ECY2JC5F.js";import"./chunk-NRP22GKC.js";import{a as ie}from"./chunk-Y3AYVFTK.js";import{a as pe}from"./chunk-
|
|
1
|
+
import{a as fe}from"./chunk-ECY2JC5F.js";import"./chunk-NRP22GKC.js";import{a as ie}from"./chunk-Y3AYVFTK.js";import{a as pe}from"./chunk-ZRFRFHRU.js";import"./chunk-UC7MNI2F.js";import{i as de}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as b}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ne}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as he}from"./chunk-XC2LTW44.js";import"./chunk-NCPW7WHO.js";import"./chunk-5AXRIRHW.js";import"./chunk-55UGUCQ6.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as ue}from"./chunk-YSPQIRER.js";import{l as le}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as ce}from"./chunk-RWVIV3U7.js";import{d as oe,f as Z,g as ee,h as te,q as ae,t as me,u as re}from"./chunk-74IYYDDI.js";import{a as l,d as Y,e as ge,f as ve,g as Ne,i as se}from"./chunk-I26MS5PJ.js";var t=Y(Ne(),1);var be=Y(ve(),1);var v=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}l(ye,"ge");var we=/https?:\/\/[^\s"'<>)]+/i,xe=l(a=>a===void 0?void 0:we.exec(a)?.[0],"re"),N=l(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"v"),Ce=/<a\s(?:[^>]*?\s)?href\s*=\s*["'](https?:\/\/[^"'\s]+)["']/iu,ke=/&(?:amp|#0*38|#x0*26);/giu,Se=l(a=>a===void 0?void 0:((a.html===void 0?void 0:Ce.exec(a.html)?.[1])??xe(a.text)??xe(a.html))?.replaceAll(ke,"&"),"ye"),Te=l((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${N(o.to)} ${N(o.cc)}`.toLowerCase().includes(s))},"Ce"),Le=l((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"Se"),je=Z(H.clearCapturedMail),Me=Z(H.sendTestMail),_e=l(a=>{let e=(0,be.c)(36),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:I,error:y,errorSource:w,isLoading:g,poll:P,refetch:c}=ue(H.getCapturedMail,p),[C,f]=(0,v.useState)(null),[q,k]=(0,v.useState)(null),[i,u]=(0,v.useState)("html"),[x,B]=(0,v.useState)(""),r=I?.entries??[],m=y??C,D=y===null?C:w,S;e[2]!==o||e[3]!==c?(S=l(async()=>{f(null);try{await o.query(je,{},ee("")),k(null),c()}catch(d){f(te(d))}},"S"),e[2]=o,e[3]=c,e[4]=S):S=e[4];let R=S,T;e[5]!==o||e[6]!==c?(T=l(async()=>{f(null);try{await o.query(Me,{},ee("")),c()}catch(d){f(te(d))}},"T"),e[5]=o,e[6]=c,e[7]=T):T=e[7];let Q=T;pe(P,!0);let L;e[8]!==R?(L=l(()=>{ae(R())},"k"),e[8]=R,e[9]=L):L=e[9];let U=L,j;e[10]!==Q?(j=l(()=>{ae(Q())},"A"),e[10]=Q,e[11]=j):j=e[11];let W=j,M;e[12]===Symbol.for("react.memo_cache_sentinel")?(M=l(d=>{B(d.currentTarget.value)},"E"),e[12]=M):M=e[12];let G=M,_;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=l(d=>{let{id:h}=d.currentTarget.dataset;h!==void 0&&k(h)},"L"),e[13]=_):_=e[13];let J=_,z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=l(d=>{let h=d.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&u(h)},"_"),e[14]=z):z=e[14];let K=z,$=Te(r,x),A=Le($,q),n=Se(A),O;e[15]!==n?(O=l(()=>{n!==void 0&&me(n)},"j"),e[15]=n,e[16]=O):O=e[16];let V=O,F;e[17]!==n?(F=l(()=>{n!==void 0&&"window"in globalThis&&globalThis.window.open(n,"_blank","noopener")},"$"),e[17]=n,e[18]=F):F=e[18];let X=F,E;return e[19]!==r||e[20]!==m||e[21]!==D||e[22]!==x||e[23]!==g||e[24]!==n||e[25]!==U||e[26]!==V||e[27]!==G||e[28]!==X||e[29]!==J||e[30]!==K||e[31]!==W||e[32]!==A||e[33]!==i||e[34]!==$?(E={entries:r,error:m,errorSource:D,filter:x,isLoading:g,link:n,onClear:U,onCopyLink:V,onFilterChange:G,onOpenLink:X,onSelectMessage:J,onSelectTab:K,onSendTest:W,selected:A,tab:i,visible:$},e[19]=r,e[20]=m,e[21]=D,e[22]=x,e[23]=g,e[24]=n,e[25]=U,e[26]=V,e[27]=G,e[28]=X,e[29]=J,e[30]=K,e[31]=W,e[32]=A,e[33]=i,e[34]=$,e[35]=E):E=e[35],E},"Ae"),ze=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,$e=l(a=>`${ze}${a}`,"Le"),Ke=l(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:I,isLoading:y,link:w,onClear:g,onCopyLink:P,onFilterChange:c,onOpenLink:C,onSelectMessage:f,onSelectTab:q,onSendTest:k,selected:i,tab:u,visible:x}=_e({limit:a}),B=l(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"H");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(b,{"data-testid":"mail-send-test",onClick:k,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(b,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!y&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:c,placeholder:e("Filter messages"),type:"search",value:I}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:x.map(r=>{let m=r.id===i?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${m?"bg-muted":""}`,"data-active":m,"data-id":r.id,"data-testid":"mail-list-item",onClick:f,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:N(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),i!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:i.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:i.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:N(i.to)}),i.cc!==void 0&&i.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:N(i.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(i.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(b,{"data-testid":"mail-copy-link",disabled:w===void 0,onClick:P,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(b,{"data-testid":"mail-open-link",disabled:w===void 0,onClick:C,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(b,{"aria-selected":u===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:q,role:"tab",size:"sm",type:"button",variant:u===r?"secondary":"ghost",children:B(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[u==="html"&&(i.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:$e(i.html),title:e("Email preview")})),u==="text"&&(i.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:i.text})),u==="headers"&&(i.headers===void 0||Object.keys(i.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(i.headers).map(([r,m])=>`${r}: ${m}`).join(`
|
|
2
2
|
`)}))]})]})]})]})},"Qe");export{Ke as MailPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as V}from"./chunk-4CGBMYO3.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import"./chunk-QJLHH3ET.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Q}from"./chunk-LXCVA5SP.js";import{a as H}from"./chunk-7Q256NLI.js";import{b as K}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as A}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{a as v}from"./chunk-4ZEL6BYL.js";import{d as G}from"./chunk-
|
|
1
|
+
import{c as V}from"./chunk-4CGBMYO3.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import"./chunk-QJLHH3ET.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Q}from"./chunk-LXCVA5SP.js";import{a as H}from"./chunk-7Q256NLI.js";import{b as K}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as A}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{a as v}from"./chunk-4ZEL6BYL.js";import{d as G}from"./chunk-YSPQIRER.js";import{c as k,d as M,l as U}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import{d as $}from"./chunk-NRAAYZ4C.js";import{a as B,e as D}from"./chunk-2IKDEUCX.js";import{d as _,f as E,g as L,h as C,q as J}from"./chunk-74IYYDDI.js";import{a as n,d as F,e as me,g as pe}from"./chunk-I26MS5PJ.js";var h=F(me(),1);var e=F(pe(),1);var ue=E(v.exportShard),fe=E(v.importShard),he=E(v.listTables),xe=n(i=>i.map(l=>JSON.stringify(k(l))).join(`
|
|
2
2
|
`),"ue"),Z=n((i,l)=>{let r=i.trim();if(r==="")return;let t=M(JSON.parse(r));if(typeof t!="object"||t===null)throw new $("INTERNAL",`line ${l.toString()}: expected a { table, doc } object`);let o=t;if(typeof o.table!="string"||typeof o.doc!="object"||o.doc===null||Array.isArray(o.doc))throw new $("INTERNAL",`line ${l.toString()}: expected a { table, doc } object`);return o},"q"),X=1024*1024,ee=n(async function*(i){let l=new TextDecoder("utf-8",{fatal:!0}),r="",t=0;for(let c=0;c<i.size;c+=X){let x=await i.slice(c,c+X).arrayBuffer(),d=`${r}${l.decode(x,{stream:!0})}`.split(`
|
|
3
3
|
`);r=d.pop()??"";for(let u of d)t+=1,yield{line:u,lineNumber:t}}let o=r+l.decode();o!==""&&(yield{line:o,lineNumber:t+1})},"U"),Y=50,ge=500,R=9e5,te=n(i=>new TextEncoder().encode(JSON.stringify(k(i))).byteLength,"z"),q="application/x-ndjson",be=n(async i=>{let l=0;for await(let{line:r,lineNumber:t}of ee(i)){let o=Z(r,t);if(o!==void 0){if(te(o)>R)throw new $("INTERNAL",`line ${t.toString()}: a single row is over the ${R.toString()}-byte import limit`);l+=1}}return l},"he"),we=n(async(i,l)=>{let r=[],t=0,o=0,c=0;for await(let{line:x,lineNumber:d}of ee(i)){let u=Z(x,d);if(u===void 0)continue;let g=te(u),S=d!==c+1;r.length>0&&(S||r.length===ge||t+g>R)&&(await l(r,o),r=[],t=0),r.length===0&&(o=d),r.push(u),t+=g,c=d}r.length>0&&await l(r,o)},"xe"),Ae=n(({initialShardKey:i})=>{let l=U(),r=G(),t=_(),[o,c]=(0,h.useState)(i??""),[x,d]=(0,h.useState)(null),[u,g]=(0,h.useState)(!1),[S,j]=(0,h.useState)(null),[b,T]=(0,h.useState)(null),[z,P]=(0,h.useState)(null),[f,O]=(0,h.useState)(null),re=n(async()=>{let s=o;g(!0),j(null),T(null),O(null);try{let a=await l.query(he,{},L(s)),m=new Blob([],{type:q}),w=0,y=[];for(let{name:p}of a){let{rows:I}=await l.query(ue,{tables:[p]},L(s));if(I.length===0)continue;let N=xe(I);m=new Blob([m,`${N}
|
|
4
4
|
`],{type:q}),w+=I.length,y.length<Y&&y.push(...N.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as y}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as R}from"./chunk-
|
|
1
|
+
import{b as y}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as R}from"./chunk-XC2LTW44.js";import"./chunk-NCPW7WHO.js";import"./chunk-5AXRIRHW.js";import"./chunk-55UGUCQ6.js";import{a as v}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-YSPQIRER.js";import"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as S}from"./chunk-RWVIV3U7.js";import{a as A,b as C,c as I,d as x,e as c,f as n}from"./chunk-HCTJKP5J.js";import{a as k,e as w}from"./chunk-2IKDEUCX.js";import{d as N}from"./chunk-74IYYDDI.js";import{a as f,d as b,f as E,g as O}from"./chunk-I26MS5PJ.js";var j=b(E(),1);var r=b(O(),1);var _=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"I"),T={delete:2,list:3,read:0,write:1},B=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||T[t.on]-T[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"O"),q=f(()=>{let e=(0,j.c)(14),t=N(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=$(v.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=B(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(R,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(k,{className:"overflow-hidden py-0",children:(0,r.jsx)(w,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(C,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(c,{children:t("Bucket")}),(0,r.jsx)(c,{children:t("Operation")}),(0,r.jsx)(c,{children:t("Key prefix")}),(0,r.jsx)(c,{children:t("Guarded by")})]})}),(0,r.jsx)(I,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(n,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(n,{children:(0,r.jsx)(y,{variant:"secondary",children:_(t,s.on)})}),(0,r.jsx)(n,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(n,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"M");export{q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as g}from"./chunk-
|
|
1
|
+
import{b as g}from"./chunk-Z643LPA5.js";import"./chunk-XC2LTW44.js";import"./chunk-NCPW7WHO.js";import"./chunk-5AXRIRHW.js";import"./chunk-55UGUCQ6.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-YSPQIRER.js";import"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import"./chunk-HCTJKP5J.js";import"./chunk-2IKDEUCX.js";import{d as p}from"./chunk-74IYYDDI.js";import{a as r,d as h,f as S,g as A}from"./chunk-I26MS5PJ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Pe,b as Re}from"./chunk-XKISL2CG.js";import{a as ce}from"./chunk-VCFEO3RI.js";import{a as Te}from"./chunk-K2EHRNYW.js";import"./chunk-VESGIGMQ.js";import{a as Se}from"./chunk-S4Z7K55A.js";import{b as ke}from"./chunk-5B2RTXBS.js";import{a as de}from"./chunk-UYEZR3BI.js";import{a as Le}from"./chunk-EWMBX5N2.js";import{a as ie}from"./chunk-IWZ7GVQO.js";import{a as xe}from"./chunk-R6U22RSY.js";import{a as be}from"./chunk-7Q256NLI.js";import{b as ve}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-OQ6I6OXT.js";import{i as D}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as pe}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as re}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as ye}from"./chunk-R7SRERCX.js";import"./chunk-NCPW7WHO.js";import"./chunk-RGUL4AQZ.js";import"./chunk-55UGUCQ6.js";import{a as ne}from"./chunk-4ZEL6BYL.js";import{c as oe}from"./chunk-QTDX7WSP.js";import{l as ge}from"./chunk-KPRNLQKZ.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as J}from"./chunk-RWVIV3U7.js";import{a as we,b as Ne,c as Ce,d as se,e as j,f as B}from"./chunk-HCTJKP5J.js";import{d as z,h as ae,i as fe,q as le}from"./chunk-74IYYDDI.js";import{a as v,d as te,e as _e,f as Ae,g as Ue,i as W}from"./chunk-I26MS5PJ.js";var K=te(Ae(),1);var I=te(_e(),1);var r=te(Ue(),1);var me=["trace","debug","log","info","warn","error","fatal"],$e="LOG_ARCHIVE_NOT_CONFIGURED",ze={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},De=v((i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},"De"),je=v(i=>{let e=(0,K.c)(33),{row:t}=i,n;e[0]!==t.fields?(n=ce(t.fields),e[0]=t.fields,e[1]=n):n=e[1];let s=n,o=`lg-archive-row-${String(t.ts)}`,c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let f;e[4]!==c?(f=(0,r.jsx)(B,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=f):f=e[5];let m=Pe[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,r.jsx)(B,{children:(0,r.jsx)(re,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=(0,r.jsx)(B,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==s?(l=s!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:s,children:s}),e[13]=s,e[14]=l):l=e[14];let u;e[15]!==h||e[16]!==l?(u=(0,r.jsxs)(B,{className:"max-w-md",children:[h,l]}),e[15]=h,e[16]=l,e[17]=u):u=e[17];let g=t.traceId??"\u2014",b;e[18]!==g?(b=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:g}),e[18]=g,e[19]=b):b=e[19];let x=t.shardKey??"\u2014",w;e[20]!==x?(w=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[20]=x,e[21]=w):w=e[21];let N=t.userId??"\u2014",y;e[22]!==N?(y=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:N}),e[22]=N,e[23]=y):y=e[23];let T;return e[24]!==u||e[25]!==b||e[26]!==w||e[27]!==y||e[28]!==o||e[29]!==f||e[30]!==d||e[31]!==a?(T=(0,r.jsxs)(se,{"data-testid":o,children:[f,d,a,u,b,w,y]}),e[24]=u,e[25]=b,e[26]=w,e[27]=y,e[28]=o,e[29]=f,e[30]=d,e[31]=a,e[32]=T):T=e[32],T},"Qe"),Be=v(({shardKey:i})=>{let e=ge(),t=z(),[n,s]=(0,I.useState)(""),[o,c]=(0,I.useState)(""),[f,m]=(0,I.useState)(""),[{cursor:d,error:a,loading:h,notConfigured:l,rows:u},g]=(0,I.useReducer)(De,ze),b=ie(n.trim(),400),x=ie(o.trim(),400),w={...b===""?{}:{functionPathPrefix:b},...f===""?{}:{minLevel:f},...i===""?{}:{shardKey:i},...x===""?{}:{userId:x}},N=JSON.stringify(w),y=(0,I.useRef)(N);(0,I.useEffect)(()=>{let p={cancelled:!1};return y.current=N,le((async()=>{g({type:"loading"});try{let C=await e.queryLogArchive(w);p.cancelled||g({cursor:C.nextCursor,rows:C.rows,type:"loaded"})}catch(C){p.cancelled||g(fe(C)===$e?{type:"notConfigured"}:{message:ae(C),type:"failed"})}})()),()=>{p.cancelled=!0}},[e,N]);let T=v(async()=>{if(d===void 0)return;let p=N;g({type:"loading"});try{let C=await e.queryLogArchive({...w,cursor:d});y.current===p&&g({cursor:C.nextCursor,rows:C.rows,type:"append"})}catch(C){y.current===p&&g({message:ae(C),type:"pageFailed"})}},"T"),R=v(p=>{s(p.target.value)},"R"),k=v(p=>{c(p.target.value)},"N"),L=v(p=>{m(p.target.value)},"L"),S=v(()=>{le(T())},"S");return l?(0,r.jsx)(J,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:R,placeholder:t("function path\u2026"),value:n}),(0,r.jsx)(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:k,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:L,value:f,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),me.map(p=>(0,r.jsx)("option",{value:p,children:p},p))]})]}),a!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),h&&u===null&&a===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),u!==null&&u.length===0&&(0,r.jsx)(J,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(we,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(Ne,{children:(0,r.jsxs)(se,{children:[(0,r.jsx)(j,{children:t("Time")}),(0,r.jsx)(j,{children:t("Level")}),(0,r.jsx)(j,{children:t("Function")}),(0,r.jsx)(j,{children:t("Message")}),(0,r.jsx)(j,{children:t("Trace")}),(0,r.jsx)(j,{children:t("Shard")}),(0,r.jsx)(j,{children:t("User")})]})}),(0,r.jsx)(Ce,{children:u.map((p,C)=>(0,r.jsx)(je,{row:p},`${String(p.ts)}-${String(C)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(pe,{"data-testid":"lg-archive-more",disabled:h,onClick:S,size:"sm",variant:"outline",children:t(h?"Loading\u2026":"Load more")})})]})},"ze"),We=v(i=>{let e=(0,K.c)(11),{level:t,onToggle:n,selected:s}=i,o;e[0]!==t||e[1]!==n?(o=v(()=>{n(t)},"o"),e[0]=t,e[1]=n,e[2]=o):o=e[2];let c=o,f=s?"border-border bg-muted font-medium":"border-input text-muted-foreground",m;e[3]!==f?(m=W("rounded-md border px-2 py-1 text-xs",f),e[3]=f,e[4]=m):m=e[4];let d=`logs-level-${t}`,a;return e[5]!==t||e[6]!==c||e[7]!==s||e[8]!==m||e[9]!==d?(a=(0,r.jsx)("button",{"aria-pressed":s,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=s,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},"Ge"),Ve=v(i=>{let e=(0,K.c)(68),{levelFilter:t,onLogPathChange:n,onSearchChange:s,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:f,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=z(),u;e[0]!==l?(u=l("Search messages"),e[0]=l,e[1]=u):u=e[1];let g;e[2]!==l?(g=l("search message"),e[2]=l,e[3]=g):g=e[3];let b;e[4]!==s||e[5]!==d||e[6]!==u||e[7]!==g?(b=(0,r.jsx)(D,{"aria-label":u,className:"h-8 w-48","data-testid":"lg-search",onChange:s,placeholder:g,value:d}),e[4]=s,e[5]=d,e[6]=u,e[7]=g,e[8]=b):b=e[8];let x;e[9]!==l?(x=l("Function path"),e[9]=l,e[10]=x):x=e[10];let w;e[11]!==l?(w=l("filter path"),e[11]=l,e[12]=w):w=e[12];let N;e[13]!==n||e[14]!==m||e[15]!==x||e[16]!==w?(N=(0,r.jsx)(D,{"aria-label":x,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:n,placeholder:w,value:m}),e[13]=n,e[14]=m,e[15]=x,e[16]=w,e[17]=N):N=e[17];let y;e[18]!==l?(y=l("Level filter"),e[18]=l,e[19]=y):y=e[19];let T;e[20]!==t||e[21]!==c?(T=me.map(Q=>(0,r.jsx)(We,{level:Q,onToggle:c,selected:t.has(Q)},Q)),e[20]=t,e[21]=c,e[22]=T):T=e[22];let R;e[23]!==y||e[24]!==T?(R=(0,r.jsx)("div",{"aria-label":y,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:T}),e[23]=y,e[24]=T,e[25]=R):R=e[25];let k;e[26]!==l?(k=l("Time range"),e[26]=l,e[27]=k):k=e[27];let L;e[28]!==l?(L=l("All time"),e[28]=l,e[29]=L):L=e[29];let S;e[30]!==L?(S=(0,r.jsx)("option",{value:"all",children:L}),e[30]=L,e[31]=S):S=e[31];let p;e[32]!==l?(p=l("Last 5m"),e[32]=l,e[33]=p):p=e[33];let C;e[34]!==p?(C=(0,r.jsx)("option",{value:"5m",children:p}),e[34]=p,e[35]=C):C=e[35];let q;e[36]!==l?(q=l("Last 15m"),e[36]=l,e[37]=q):q=e[37];let F;e[38]!==q?(F=(0,r.jsx)("option",{value:"15m",children:q}),e[38]=q,e[39]=F):F=e[39];let O;e[40]!==l?(O=l("Last hour"),e[40]=l,e[41]=O):O=e[41];let E;e[42]!==O?(E=(0,r.jsx)("option",{value:"1h",children:O}),e[42]=O,e[43]=E):E=e[43];let M;e[44]!==o||e[45]!==k||e[46]!==S||e[47]!==C||e[48]!==F||e[49]!==E||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":k,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:o,value:h,children:[S,C,F,E]}),e[44]=o,e[45]=k,e[46]=S,e[47]=C,e[48]=F,e[49]=E,e[50]=h,e[51]=M):M=e[51];let V=a?"border-border bg-muted font-medium":"border-input text-muted-foreground",_;e[52]!==V?(_=W("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=_):_=e[53];let U;e[54]!==a||e[55]!==l?(U=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=U):U=e[56];let A;e[57]!==f||e[58]!==a||e[59]!==_||e[60]!==U?(A=(0,r.jsx)("button",{"aria-pressed":a,className:_,"data-testid":"logs-summary-toggle",onClick:f,type:"button",children:U}),e[57]=f,e[58]=a,e[59]=_,e[60]=U,e[61]=A):A=e[61];let $;return e[62]!==M||e[63]!==A||e[64]!==b||e[65]!==N||e[66]!==R?($=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[b,N,R,M,A]}),e[62]=M,e[63]=A,e[64]=b,e[65]=N,e[66]=R,e[67]=$):$=e[67],$},"He"),Qe=v(i=>{let e=(0,K.c)(53),{onOutcomeChange:t,onPathChange:n,onTableChange:s,onUserChange:o,outcomeFilter:c,pathPrefix:f,tableFilter:m,userIdFilter:d}=i,a=z(),h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let u;e[4]!==n||e[5]!==f||e[6]!==h||e[7]!==l?(u=(0,r.jsx)(D,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:n,placeholder:l,value:f}),e[4]=n,e[5]=f,e[6]=h,e[7]=l,e[8]=u):u=e[8];let g;e[9]!==a?(g=a("User id"),e[9]=a,e[10]=g):g=e[10];let b;e[11]!==a?(b=a("userId"),e[11]=a,e[12]=b):b=e[12];let x;e[13]!==o||e[14]!==g||e[15]!==b||e[16]!==d?(x=(0,r.jsx)(D,{"aria-label":g,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:b,value:d}),e[13]=o,e[14]=g,e[15]=b,e[16]=d,e[17]=x):x=e[17];let w;e[18]!==a?(w=a("Table touched"),e[18]=a,e[19]=w):w=e[19];let N;e[20]!==a?(N=a("table"),e[20]=a,e[21]=N):N=e[21];let y;e[22]!==s||e[23]!==w||e[24]!==N||e[25]!==m?(y=(0,r.jsx)(D,{"aria-label":w,className:"h-8 w-32","data-testid":"lg-req-table",onChange:s,placeholder:N,value:m}),e[22]=s,e[23]=w,e[24]=N,e[25]=m,e[26]=y):y=e[26];let T;e[27]!==a?(T=a("Outcome filter"),e[27]=a,e[28]=T):T=e[28];let R;e[29]!==a?(R=a("all"),e[29]=a,e[30]=R):R=e[30];let k;e[31]!==R?(k=(0,r.jsx)("option",{value:"all",children:R}),e[31]=R,e[32]=k):k=e[32];let L;e[33]!==a?(L=a("ok"),e[33]=a,e[34]=L):L=e[34];let S;e[35]!==L?(S=(0,r.jsx)("option",{value:"ok",children:L}),e[35]=L,e[36]=S):S=e[36];let p;e[37]!==a?(p=a("error"),e[37]=a,e[38]=p):p=e[38];let C;e[39]!==p?(C=(0,r.jsx)("option",{value:"error",children:p}),e[39]=p,e[40]=C):C=e[40];let q;e[41]!==t||e[42]!==c||e[43]!==T||e[44]!==k||e[45]!==S||e[46]!==C?(q=(0,r.jsxs)("select",{"aria-label":T,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:t,value:c,children:[k,S,C]}),e[41]=t,e[42]=c,e[43]=T,e[44]=k,e[45]=S,e[46]=C,e[47]=q):q=e[47];let F;return e[48]!==q||e[49]!==u||e[50]!==x||e[51]!==y?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,y,q]}),e[48]=q,e[49]=u,e[50]=x,e[51]=y,e[52]=F):F=e[52],F},"We"),Fe=v(i=>{let e=(0,K.c)(7),{bucket:t}=i,n;e[0]!==t.key?(n=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=n):n=e[1];let s;e[2]!==t.count?(s=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,r.jsxs)("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:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"ve"),Ye=v(i=>{let e=(0,K.c)(31),{summary:t}=i,n=z(),s;e[0]!==t.total||e[1]!==n?(s=n("{count} entries",{count:t.total}),e[0]=t.total,e[1]=n,e[2]=s):s=e[2];let o;e[3]!==s?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:s}),e[3]=s,e[4]=o):o=e[4];let c;e[5]!==n?(c=n("By level"),e[5]=n,e[6]=c):c=e[6];let f;e[7]!==c?(f=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=f):f=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(Ge),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==f||e[14]!==d?(a=(0,r.jsxs)("div",{children:[f,d]}),e[13]=f,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==n?(h=n("By function"),e[16]=n,e[17]=h):h=e[17];let l;e[18]!==h?(l=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let u;e[20]!==t.byPath?(u=t.byPath.map(He),e[20]=t.byPath,e[21]=u):u=e[21];let g;e[22]!==u?(g=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:u}),e[22]=u,e[23]=g):g=e[23];let b;e[24]!==g||e[25]!==l?(b=(0,r.jsxs)("div",{children:[l,g]}),e[24]=g,e[25]=l,e[26]=b):b=e[26];let x;return e[27]!==b||e[28]!==o||e[29]!==a?(x=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,b]}),e[27]=b,e[28]=o,e[29]=a,e[30]=x):x=e[30],x},"Ye");function Ge(i){return(0,r.jsx)(Fe,{bucket:i},i.key)}v(Ge,"je");function He(i){return(0,r.jsx)(Fe,{bucket:i},i.key)}v(He,"Je");var Je=v(i=>{let e=(0,K.c)(46),{liveError:t,onShardKeyChange:n,onShowArchive:s,onShowErrors:o,onShowRequests:c,shardKey:f,view:m}=i,d=z(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground",l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let u;e[2]!==d?(u=d("Requests"),e[2]=d,e[3]=u):u=e[3];let g;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==u?(g=(0,r.jsx)("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:u}),e[4]=c,e[5]=a,e[6]=l,e[7]=u,e[8]=g):g=e[8];let b=m==="errors",x=m==="errors"?"bg-muted font-medium":"text-muted-foreground",w;e[9]!==x?(w=W("px-3 py-1 text-sm",x),e[9]=x,e[10]=w):w=e[10];let N;e[11]!==d?(N=d("Errors"),e[11]=d,e[12]=N):N=e[12];let y;e[13]!==o||e[14]!==b||e[15]!==w||e[16]!==N?(y=(0,r.jsx)("button",{"aria-selected":b,className:w,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:N}),e[13]=o,e[14]=b,e[15]=w,e[16]=N,e[17]=y):y=e[17];let T=m==="archive",R=m==="archive"?"bg-muted font-medium":"text-muted-foreground",k;e[18]!==R?(k=W("px-3 py-1 text-sm",R),e[18]=R,e[19]=k):k=e[19];let L;e[20]!==d?(L=d("Archive"),e[20]=d,e[21]=L):L=e[21];let S;e[22]!==s||e[23]!==T||e[24]!==k||e[25]!==L?(S=(0,r.jsx)("button",{"aria-selected":T,className:k,"data-testid":"lg-view-archive",onClick:s,role:"tab",type:"button",children:L}),e[22]=s,e[23]=T,e[24]=k,e[25]=L,e[26]=S):S=e[26];let p;e[27]!==y||e[28]!==S||e[29]!==g?(p=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[g,y,S]}),e[27]=y,e[28]=S,e[29]=g,e[30]=p):p=e[30];let C;e[31]!==n||e[32]!==f?(C=(0,r.jsx)(be,{onChange:n,testId:"lg-shard-input",value:f}),e[31]=n,e[32]=f,e[33]=C):C=e[33];let q;e[34]!==t||e[35]!==m?(q=m!=="archive"&&(0,r.jsx)(Le,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=q):q=e[36];let F;e[37]!==d?(F=d("Open in Cloudflare"),e[37]=d,e[38]=F):F=e[38];let O;e[39]!==F?(O=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=O):O=e[40];let E;return e[41]!==p||e[42]!==C||e[43]!==q||e[44]!==O?(E=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,C,q,O]}),e[41]=p,e[42]=C,e[43]=q,e[44]=O,e[45]=E):E=e[45],E},"Xe"),ue=400,Xe=36,Ze={height:ue,overflow:"auto"},Oe={left:0,position:"absolute",top:0,width:"100%"},et={error:"destructive",ok:"secondary"},Ee=v(i=>{let e=(0,K.c)(6),{onOpenTrace:t,traceId:n}=i,s=z(),o;e[0]!==t||e[1]!==s||e[2]!==n?(o=n===void 0?null:(0,r.jsx)("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:v(()=>{t(n)},"onClick"),type:"button",children:s("Trace")}),e[0]=t,e[1]=s,e[2]=n,e[3]=o):o=e[3];let c;return e[4]!==o?(c=(0,r.jsx)("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},"xe"),tt=v(i=>{let e=(0,K.c)(13),{entry:t,index:n,measureRef:s,onOpenTrace:o,start:c}=i,f=`translateY(${String(c)}px)`,m;e[0]!==f?(m={...Oe,transform:f},e[0]=f,e[1]=m):m=e[1];let d=m,a;e[2]!==t?(a=(0,r.jsx)(Re,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=(0,r.jsx)(Ee,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==n||e[8]!==s||e[9]!==d||e[10]!==a||e[11]!==h?(l=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-row",ref:s,role:"row",style:d,children:[a,h]}),e[7]=n,e[8]=s,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},"rt"),Ie=v(i=>i.length===0?"\u2014":i.join(", "),"ce"),rt=v(i=>{let e=(0,K.c)(41),{entry:t,index:n,measureRef:s,onOpenTrace:o,start:c}=i,f=`translateY(${String(c)}px)`,m;e[0]!==f?(m={...Oe,transform:f},e[0]=f,e[1]=m):m=e[1];let d=m,a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];let l=et[t.outcome],u;e[6]!==t.outcome||e[7]!==l?(u=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(re,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=u):u=e[8];let g;e[9]!==t.functionPath?(g=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=g):g=e[10];let b=t.shardKey??"\u2014",x;e[11]!==b?(x=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b}),e[11]=b,e[12]=x):x=e[12];let w=t.userId??"\u2014",N;e[13]!==w?(N=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:w}),e[13]=w,e[14]=N):N=e[14];let y;e[15]!==t.durationMs?(y=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=y):y=e[16];let T=`${String(y)}ms`,R;e[17]!==T?(R=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:T}),e[17]=T,e[18]=R):R=e[18];let k;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(k=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]=k):k=e[23];let L;e[24]!==k?(L=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:k}),e[24]=k,e[25]=L):L=e[25];let S;e[26]!==t.traceId||e[27]!==o?(S=(0,r.jsx)(Ee,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=S):S=e[28];let p;return e[29]!==n||e[30]!==s||e[31]!==d||e[32]!==N||e[33]!==R||e[34]!==L||e[35]!==S||e[36]!==h||e[37]!==u||e[38]!==g||e[39]!==x?(p=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-req-row",ref:s,role:"row",style:d,children:[h,u,g,x,N,R,L,S]}),e[29]=n,e[30]=s,e[31]=d,e[32]=N,e[33]=R,e[34]=L,e[35]=S,e[36]=h,e[37]=u,e[38]=g,e[39]=x,e[40]=p):p=e[40],p},"st"),qe=v(i=>{let{entries:e}=i??{};return Array.isArray(e)?e:[]},"de"),at=v(i=>{let e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},"lt"),lt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},ot=v((i,e)=>{let t=e.search.trim().toLowerCase(),n=e.path.trim().toLowerCase(),s=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-lt[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<s||n!==""&&!(o.functionPath??"").toLowerCase().includes(n)?!1:t===""||o.message.toLowerCase().includes(t)||ce(o.fields).toLowerCase().includes(t))},"at"),nt="\u2014",st=v(i=>{let e=new Map,t=new Map;for(let o of i){e.set(o.level,(e.get(o.level)??0)+1);let c=o.functionPath??nt;t.set(c,(t.get(c)??0)+1)}let n=me.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),s=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:n,byPath:s,total:i.length}},"it"),qt=v(({initialShardKey:i})=>{let e=z(),[t,n]=(0,I.useState)("requests"),{queryShardKey:s,setShardKey:o,shardKey:c}=xe(i),[f,m]=(0,I.useState)(""),[d,a]=(0,I.useState)(()=>new Set),[h,l]=(0,I.useState)(""),[u,g]=(0,I.useState)("all"),[b,x]=(0,I.useState)(!1),[w,N]=(0,I.useState)(""),[y,T]=(0,I.useState)(""),[R,k]=(0,I.useState)(""),[L,S]=(0,I.useState)("all"),p=at({functionPathPrefix:w,outcome:L,tableTouched:R,userId:y}),C=oe(ne.getRequestLog,p,{enabled:t==="requests",live:!0,shardKey:s}),q=oe(ne.getLogs,{},{enabled:t==="errors",live:!0,shardKey:s}),F=t==="requests"?C:q,{error:O,errorSource:E,isLoading:M,liveError:V}=F,_=Te(s),U=qe(q.data),A=qe(C.data);(0,I.useEffect)(()=>{F.data!==void 0&&ve(s)},[F.data,s]);let $=ot(U,{levels:d,now:Date.now(),path:h,range:u,search:f}),Q=st($),X=t==="requests"?A.length:$.length,Z=t==="errors"&&b,Y=(0,I.useMemo)(()=>O!==null?"error":X===0?M?Z?"summary":"list":"empty":Z?"summary":"list",[X,M,O,Z]),he=(0,I.useRef)(null),G=ke({count:X,estimateSize:v(()=>Xe,"estimateSize"),getScrollElement:v(()=>he.current,"getScrollElement"),initialRect:{height:ue,width:800},observeElementRect:v((P,ee)=>Se(P,ee,ue),"observeElementRect"),overscan:8}),Ke=G.getVirtualItems(),Me={height:G.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Je,{liveError:V,onShardKeyChange:o,onShowArchive:v(()=>{n("archive"),x(!1)},"onShowArchive"),onShowErrors:v(()=>{n("errors"),x(!1)},"onShowErrors"),onShowRequests:v(()=>{n("requests"),x(!1)},"onShowRequests"),shardKey:c,view:t}),t==="errors"&&(0,r.jsx)(Ve,{levelFilter:d,onLogPathChange:v(P=>{l(P.target.value)},"onLogPathChange"),onSearchChange:v(P=>{m(P.target.value)},"onSearchChange"),onTimeRangeChange:v(P=>{g(P.target.value)},"onTimeRangeChange"),onToggleLevel:v(P=>{a(ee=>{let H=new Set(ee);return H.has(P)?H.delete(P):H.add(P),H})},"onToggleLevel"),onToggleSummary:v(()=>{x(P=>!P)},"onToggleSummary"),pathFilter:h,search:f,showSummary:b,timeRange:u}),t==="requests"&&(0,r.jsx)(Qe,{onOutcomeChange:v(P=>{S(P.target.value)},"onOutcomeChange"),onPathChange:v(P=>{N(P.target.value)},"onPathChange"),onTableChange:v(P=>{k(P.target.value)},"onTableChange"),onUserChange:v(P=>{T(P.target.value)},"onUserChange"),outcomeFilter:L,pathPrefix:w,tableFilter:R,userIdFilter:y}),t==="archive"?(0,r.jsx)(Be,{shardKey:s}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(ye,{error:E,testId:"lg-error"}),Y==="empty"&&(0,r.jsx)(J,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&(0,r.jsx)(Ye,{summary:Q}),Y==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:he,style:Ze,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Me,children:Ke.map(P=>t==="requests"?(0,r.jsx)(rt,{entry:A[P.index],index:P.index,measureRef:G.measureElement,onOpenTrace:_,start:P.start},P.key):(0,r.jsx)(tt,{entry:$[P.index],index:P.index,measureRef:G.measureElement,onOpenTrace:_,start:P.start},P.key))})})]})]})},"Wt");export{qt as LogsPanel,ot as filterLogs,st as summarizeLogs};
|
|
1
|
+
import{a as Pe,b as Re}from"./chunk-XKISL2CG.js";import{a as ce}from"./chunk-VCFEO3RI.js";import{a as Te}from"./chunk-K2EHRNYW.js";import"./chunk-VESGIGMQ.js";import{a as Se}from"./chunk-S4Z7K55A.js";import{b as ke}from"./chunk-5B2RTXBS.js";import{a as de}from"./chunk-UYEZR3BI.js";import{a as Le}from"./chunk-EWMBX5N2.js";import{a as ie}from"./chunk-IWZ7GVQO.js";import{a as xe}from"./chunk-R6U22RSY.js";import{a as be}from"./chunk-7Q256NLI.js";import{b as ve}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-OQ6I6OXT.js";import{i as D}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as pe}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as re}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as ye}from"./chunk-XC2LTW44.js";import"./chunk-NCPW7WHO.js";import"./chunk-5AXRIRHW.js";import"./chunk-55UGUCQ6.js";import{a as ne}from"./chunk-4ZEL6BYL.js";import{c as oe}from"./chunk-YSPQIRER.js";import{l as ge}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as J}from"./chunk-RWVIV3U7.js";import{a as we,b as Ne,c as Ce,d as se,e as j,f as B}from"./chunk-HCTJKP5J.js";import{d as z,h as ae,i as fe,q as le}from"./chunk-74IYYDDI.js";import{a as v,d as te,e as _e,f as Ae,g as Ue,i as W}from"./chunk-I26MS5PJ.js";var K=te(Ae(),1);var I=te(_e(),1);var r=te(Ue(),1);var me=["trace","debug","log","info","warn","error","fatal"],$e="LOG_ARCHIVE_NOT_CONFIGURED",ze={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},De=v((i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},"De"),je=v(i=>{let e=(0,K.c)(33),{row:t}=i,n;e[0]!==t.fields?(n=ce(t.fields),e[0]=t.fields,e[1]=n):n=e[1];let s=n,o=`lg-archive-row-${String(t.ts)}`,c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let f;e[4]!==c?(f=(0,r.jsx)(B,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=f):f=e[5];let m=Pe[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,r.jsx)(B,{children:(0,r.jsx)(re,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=(0,r.jsx)(B,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==s?(l=s!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:s,children:s}),e[13]=s,e[14]=l):l=e[14];let u;e[15]!==h||e[16]!==l?(u=(0,r.jsxs)(B,{className:"max-w-md",children:[h,l]}),e[15]=h,e[16]=l,e[17]=u):u=e[17];let g=t.traceId??"\u2014",b;e[18]!==g?(b=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:g}),e[18]=g,e[19]=b):b=e[19];let x=t.shardKey??"\u2014",w;e[20]!==x?(w=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[20]=x,e[21]=w):w=e[21];let N=t.userId??"\u2014",y;e[22]!==N?(y=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:N}),e[22]=N,e[23]=y):y=e[23];let T;return e[24]!==u||e[25]!==b||e[26]!==w||e[27]!==y||e[28]!==o||e[29]!==f||e[30]!==d||e[31]!==a?(T=(0,r.jsxs)(se,{"data-testid":o,children:[f,d,a,u,b,w,y]}),e[24]=u,e[25]=b,e[26]=w,e[27]=y,e[28]=o,e[29]=f,e[30]=d,e[31]=a,e[32]=T):T=e[32],T},"Qe"),Be=v(({shardKey:i})=>{let e=ge(),t=z(),[n,s]=(0,I.useState)(""),[o,c]=(0,I.useState)(""),[f,m]=(0,I.useState)(""),[{cursor:d,error:a,loading:h,notConfigured:l,rows:u},g]=(0,I.useReducer)(De,ze),b=ie(n.trim(),400),x=ie(o.trim(),400),w={...b===""?{}:{functionPathPrefix:b},...f===""?{}:{minLevel:f},...i===""?{}:{shardKey:i},...x===""?{}:{userId:x}},N=JSON.stringify(w),y=(0,I.useRef)(N);(0,I.useEffect)(()=>{let p={cancelled:!1};return y.current=N,le((async()=>{g({type:"loading"});try{let C=await e.queryLogArchive(w);p.cancelled||g({cursor:C.nextCursor,rows:C.rows,type:"loaded"})}catch(C){p.cancelled||g(fe(C)===$e?{type:"notConfigured"}:{message:ae(C),type:"failed"})}})()),()=>{p.cancelled=!0}},[e,N]);let T=v(async()=>{if(d===void 0)return;let p=N;g({type:"loading"});try{let C=await e.queryLogArchive({...w,cursor:d});y.current===p&&g({cursor:C.nextCursor,rows:C.rows,type:"append"})}catch(C){y.current===p&&g({message:ae(C),type:"pageFailed"})}},"T"),R=v(p=>{s(p.target.value)},"R"),k=v(p=>{c(p.target.value)},"N"),L=v(p=>{m(p.target.value)},"L"),S=v(()=>{le(T())},"S");return l?(0,r.jsx)(J,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:R,placeholder:t("function path\u2026"),value:n}),(0,r.jsx)(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:k,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:L,value:f,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),me.map(p=>(0,r.jsx)("option",{value:p,children:p},p))]})]}),a!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),h&&u===null&&a===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),u!==null&&u.length===0&&(0,r.jsx)(J,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(we,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(Ne,{children:(0,r.jsxs)(se,{children:[(0,r.jsx)(j,{children:t("Time")}),(0,r.jsx)(j,{children:t("Level")}),(0,r.jsx)(j,{children:t("Function")}),(0,r.jsx)(j,{children:t("Message")}),(0,r.jsx)(j,{children:t("Trace")}),(0,r.jsx)(j,{children:t("Shard")}),(0,r.jsx)(j,{children:t("User")})]})}),(0,r.jsx)(Ce,{children:u.map((p,C)=>(0,r.jsx)(je,{row:p},`${String(p.ts)}-${String(C)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(pe,{"data-testid":"lg-archive-more",disabled:h,onClick:S,size:"sm",variant:"outline",children:t(h?"Loading\u2026":"Load more")})})]})},"ze"),We=v(i=>{let e=(0,K.c)(11),{level:t,onToggle:n,selected:s}=i,o;e[0]!==t||e[1]!==n?(o=v(()=>{n(t)},"o"),e[0]=t,e[1]=n,e[2]=o):o=e[2];let c=o,f=s?"border-border bg-muted font-medium":"border-input text-muted-foreground",m;e[3]!==f?(m=W("rounded-md border px-2 py-1 text-xs",f),e[3]=f,e[4]=m):m=e[4];let d=`logs-level-${t}`,a;return e[5]!==t||e[6]!==c||e[7]!==s||e[8]!==m||e[9]!==d?(a=(0,r.jsx)("button",{"aria-pressed":s,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=s,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},"Ge"),Ve=v(i=>{let e=(0,K.c)(68),{levelFilter:t,onLogPathChange:n,onSearchChange:s,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:f,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=z(),u;e[0]!==l?(u=l("Search messages"),e[0]=l,e[1]=u):u=e[1];let g;e[2]!==l?(g=l("search message"),e[2]=l,e[3]=g):g=e[3];let b;e[4]!==s||e[5]!==d||e[6]!==u||e[7]!==g?(b=(0,r.jsx)(D,{"aria-label":u,className:"h-8 w-48","data-testid":"lg-search",onChange:s,placeholder:g,value:d}),e[4]=s,e[5]=d,e[6]=u,e[7]=g,e[8]=b):b=e[8];let x;e[9]!==l?(x=l("Function path"),e[9]=l,e[10]=x):x=e[10];let w;e[11]!==l?(w=l("filter path"),e[11]=l,e[12]=w):w=e[12];let N;e[13]!==n||e[14]!==m||e[15]!==x||e[16]!==w?(N=(0,r.jsx)(D,{"aria-label":x,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:n,placeholder:w,value:m}),e[13]=n,e[14]=m,e[15]=x,e[16]=w,e[17]=N):N=e[17];let y;e[18]!==l?(y=l("Level filter"),e[18]=l,e[19]=y):y=e[19];let T;e[20]!==t||e[21]!==c?(T=me.map(Q=>(0,r.jsx)(We,{level:Q,onToggle:c,selected:t.has(Q)},Q)),e[20]=t,e[21]=c,e[22]=T):T=e[22];let R;e[23]!==y||e[24]!==T?(R=(0,r.jsx)("div",{"aria-label":y,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:T}),e[23]=y,e[24]=T,e[25]=R):R=e[25];let k;e[26]!==l?(k=l("Time range"),e[26]=l,e[27]=k):k=e[27];let L;e[28]!==l?(L=l("All time"),e[28]=l,e[29]=L):L=e[29];let S;e[30]!==L?(S=(0,r.jsx)("option",{value:"all",children:L}),e[30]=L,e[31]=S):S=e[31];let p;e[32]!==l?(p=l("Last 5m"),e[32]=l,e[33]=p):p=e[33];let C;e[34]!==p?(C=(0,r.jsx)("option",{value:"5m",children:p}),e[34]=p,e[35]=C):C=e[35];let q;e[36]!==l?(q=l("Last 15m"),e[36]=l,e[37]=q):q=e[37];let F;e[38]!==q?(F=(0,r.jsx)("option",{value:"15m",children:q}),e[38]=q,e[39]=F):F=e[39];let O;e[40]!==l?(O=l("Last hour"),e[40]=l,e[41]=O):O=e[41];let E;e[42]!==O?(E=(0,r.jsx)("option",{value:"1h",children:O}),e[42]=O,e[43]=E):E=e[43];let M;e[44]!==o||e[45]!==k||e[46]!==S||e[47]!==C||e[48]!==F||e[49]!==E||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":k,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:o,value:h,children:[S,C,F,E]}),e[44]=o,e[45]=k,e[46]=S,e[47]=C,e[48]=F,e[49]=E,e[50]=h,e[51]=M):M=e[51];let V=a?"border-border bg-muted font-medium":"border-input text-muted-foreground",_;e[52]!==V?(_=W("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=_):_=e[53];let U;e[54]!==a||e[55]!==l?(U=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=U):U=e[56];let A;e[57]!==f||e[58]!==a||e[59]!==_||e[60]!==U?(A=(0,r.jsx)("button",{"aria-pressed":a,className:_,"data-testid":"logs-summary-toggle",onClick:f,type:"button",children:U}),e[57]=f,e[58]=a,e[59]=_,e[60]=U,e[61]=A):A=e[61];let $;return e[62]!==M||e[63]!==A||e[64]!==b||e[65]!==N||e[66]!==R?($=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[b,N,R,M,A]}),e[62]=M,e[63]=A,e[64]=b,e[65]=N,e[66]=R,e[67]=$):$=e[67],$},"He"),Qe=v(i=>{let e=(0,K.c)(53),{onOutcomeChange:t,onPathChange:n,onTableChange:s,onUserChange:o,outcomeFilter:c,pathPrefix:f,tableFilter:m,userIdFilter:d}=i,a=z(),h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let u;e[4]!==n||e[5]!==f||e[6]!==h||e[7]!==l?(u=(0,r.jsx)(D,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:n,placeholder:l,value:f}),e[4]=n,e[5]=f,e[6]=h,e[7]=l,e[8]=u):u=e[8];let g;e[9]!==a?(g=a("User id"),e[9]=a,e[10]=g):g=e[10];let b;e[11]!==a?(b=a("userId"),e[11]=a,e[12]=b):b=e[12];let x;e[13]!==o||e[14]!==g||e[15]!==b||e[16]!==d?(x=(0,r.jsx)(D,{"aria-label":g,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:b,value:d}),e[13]=o,e[14]=g,e[15]=b,e[16]=d,e[17]=x):x=e[17];let w;e[18]!==a?(w=a("Table touched"),e[18]=a,e[19]=w):w=e[19];let N;e[20]!==a?(N=a("table"),e[20]=a,e[21]=N):N=e[21];let y;e[22]!==s||e[23]!==w||e[24]!==N||e[25]!==m?(y=(0,r.jsx)(D,{"aria-label":w,className:"h-8 w-32","data-testid":"lg-req-table",onChange:s,placeholder:N,value:m}),e[22]=s,e[23]=w,e[24]=N,e[25]=m,e[26]=y):y=e[26];let T;e[27]!==a?(T=a("Outcome filter"),e[27]=a,e[28]=T):T=e[28];let R;e[29]!==a?(R=a("all"),e[29]=a,e[30]=R):R=e[30];let k;e[31]!==R?(k=(0,r.jsx)("option",{value:"all",children:R}),e[31]=R,e[32]=k):k=e[32];let L;e[33]!==a?(L=a("ok"),e[33]=a,e[34]=L):L=e[34];let S;e[35]!==L?(S=(0,r.jsx)("option",{value:"ok",children:L}),e[35]=L,e[36]=S):S=e[36];let p;e[37]!==a?(p=a("error"),e[37]=a,e[38]=p):p=e[38];let C;e[39]!==p?(C=(0,r.jsx)("option",{value:"error",children:p}),e[39]=p,e[40]=C):C=e[40];let q;e[41]!==t||e[42]!==c||e[43]!==T||e[44]!==k||e[45]!==S||e[46]!==C?(q=(0,r.jsxs)("select",{"aria-label":T,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:t,value:c,children:[k,S,C]}),e[41]=t,e[42]=c,e[43]=T,e[44]=k,e[45]=S,e[46]=C,e[47]=q):q=e[47];let F;return e[48]!==q||e[49]!==u||e[50]!==x||e[51]!==y?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,y,q]}),e[48]=q,e[49]=u,e[50]=x,e[51]=y,e[52]=F):F=e[52],F},"We"),Fe=v(i=>{let e=(0,K.c)(7),{bucket:t}=i,n;e[0]!==t.key?(n=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=n):n=e[1];let s;e[2]!==t.count?(s=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,r.jsxs)("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:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"ve"),Ye=v(i=>{let e=(0,K.c)(31),{summary:t}=i,n=z(),s;e[0]!==t.total||e[1]!==n?(s=n("{count} entries",{count:t.total}),e[0]=t.total,e[1]=n,e[2]=s):s=e[2];let o;e[3]!==s?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:s}),e[3]=s,e[4]=o):o=e[4];let c;e[5]!==n?(c=n("By level"),e[5]=n,e[6]=c):c=e[6];let f;e[7]!==c?(f=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=f):f=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(Ge),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==f||e[14]!==d?(a=(0,r.jsxs)("div",{children:[f,d]}),e[13]=f,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==n?(h=n("By function"),e[16]=n,e[17]=h):h=e[17];let l;e[18]!==h?(l=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let u;e[20]!==t.byPath?(u=t.byPath.map(He),e[20]=t.byPath,e[21]=u):u=e[21];let g;e[22]!==u?(g=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:u}),e[22]=u,e[23]=g):g=e[23];let b;e[24]!==g||e[25]!==l?(b=(0,r.jsxs)("div",{children:[l,g]}),e[24]=g,e[25]=l,e[26]=b):b=e[26];let x;return e[27]!==b||e[28]!==o||e[29]!==a?(x=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,b]}),e[27]=b,e[28]=o,e[29]=a,e[30]=x):x=e[30],x},"Ye");function Ge(i){return(0,r.jsx)(Fe,{bucket:i},i.key)}v(Ge,"je");function He(i){return(0,r.jsx)(Fe,{bucket:i},i.key)}v(He,"Je");var Je=v(i=>{let e=(0,K.c)(46),{liveError:t,onShardKeyChange:n,onShowArchive:s,onShowErrors:o,onShowRequests:c,shardKey:f,view:m}=i,d=z(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground",l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let u;e[2]!==d?(u=d("Requests"),e[2]=d,e[3]=u):u=e[3];let g;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==u?(g=(0,r.jsx)("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:u}),e[4]=c,e[5]=a,e[6]=l,e[7]=u,e[8]=g):g=e[8];let b=m==="errors",x=m==="errors"?"bg-muted font-medium":"text-muted-foreground",w;e[9]!==x?(w=W("px-3 py-1 text-sm",x),e[9]=x,e[10]=w):w=e[10];let N;e[11]!==d?(N=d("Errors"),e[11]=d,e[12]=N):N=e[12];let y;e[13]!==o||e[14]!==b||e[15]!==w||e[16]!==N?(y=(0,r.jsx)("button",{"aria-selected":b,className:w,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:N}),e[13]=o,e[14]=b,e[15]=w,e[16]=N,e[17]=y):y=e[17];let T=m==="archive",R=m==="archive"?"bg-muted font-medium":"text-muted-foreground",k;e[18]!==R?(k=W("px-3 py-1 text-sm",R),e[18]=R,e[19]=k):k=e[19];let L;e[20]!==d?(L=d("Archive"),e[20]=d,e[21]=L):L=e[21];let S;e[22]!==s||e[23]!==T||e[24]!==k||e[25]!==L?(S=(0,r.jsx)("button",{"aria-selected":T,className:k,"data-testid":"lg-view-archive",onClick:s,role:"tab",type:"button",children:L}),e[22]=s,e[23]=T,e[24]=k,e[25]=L,e[26]=S):S=e[26];let p;e[27]!==y||e[28]!==S||e[29]!==g?(p=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[g,y,S]}),e[27]=y,e[28]=S,e[29]=g,e[30]=p):p=e[30];let C;e[31]!==n||e[32]!==f?(C=(0,r.jsx)(be,{onChange:n,testId:"lg-shard-input",value:f}),e[31]=n,e[32]=f,e[33]=C):C=e[33];let q;e[34]!==t||e[35]!==m?(q=m!=="archive"&&(0,r.jsx)(Le,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=q):q=e[36];let F;e[37]!==d?(F=d("Open in Cloudflare"),e[37]=d,e[38]=F):F=e[38];let O;e[39]!==F?(O=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=O):O=e[40];let E;return e[41]!==p||e[42]!==C||e[43]!==q||e[44]!==O?(E=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[p,C,q,O]}),e[41]=p,e[42]=C,e[43]=q,e[44]=O,e[45]=E):E=e[45],E},"Xe"),ue=400,Xe=36,Ze={height:ue,overflow:"auto"},Oe={left:0,position:"absolute",top:0,width:"100%"},et={error:"destructive",ok:"secondary"},Ee=v(i=>{let e=(0,K.c)(6),{onOpenTrace:t,traceId:n}=i,s=z(),o;e[0]!==t||e[1]!==s||e[2]!==n?(o=n===void 0?null:(0,r.jsx)("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:v(()=>{t(n)},"onClick"),type:"button",children:s("Trace")}),e[0]=t,e[1]=s,e[2]=n,e[3]=o):o=e[3];let c;return e[4]!==o?(c=(0,r.jsx)("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},"xe"),tt=v(i=>{let e=(0,K.c)(13),{entry:t,index:n,measureRef:s,onOpenTrace:o,start:c}=i,f=`translateY(${String(c)}px)`,m;e[0]!==f?(m={...Oe,transform:f},e[0]=f,e[1]=m):m=e[1];let d=m,a;e[2]!==t?(a=(0,r.jsx)(Re,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=(0,r.jsx)(Ee,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==n||e[8]!==s||e[9]!==d||e[10]!==a||e[11]!==h?(l=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-row",ref:s,role:"row",style:d,children:[a,h]}),e[7]=n,e[8]=s,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},"rt"),Ie=v(i=>i.length===0?"\u2014":i.join(", "),"ce"),rt=v(i=>{let e=(0,K.c)(41),{entry:t,index:n,measureRef:s,onOpenTrace:o,start:c}=i,f=`translateY(${String(c)}px)`,m;e[0]!==f?(m={...Oe,transform:f},e[0]=f,e[1]=m):m=e[1];let d=m,a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];let l=et[t.outcome],u;e[6]!==t.outcome||e[7]!==l?(u=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(re,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=u):u=e[8];let g;e[9]!==t.functionPath?(g=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=g):g=e[10];let b=t.shardKey??"\u2014",x;e[11]!==b?(x=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b}),e[11]=b,e[12]=x):x=e[12];let w=t.userId??"\u2014",N;e[13]!==w?(N=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:w}),e[13]=w,e[14]=N):N=e[14];let y;e[15]!==t.durationMs?(y=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=y):y=e[16];let T=`${String(y)}ms`,R;e[17]!==T?(R=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:T}),e[17]=T,e[18]=R):R=e[18];let k;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(k=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]=k):k=e[23];let L;e[24]!==k?(L=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:k}),e[24]=k,e[25]=L):L=e[25];let S;e[26]!==t.traceId||e[27]!==o?(S=(0,r.jsx)(Ee,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=S):S=e[28];let p;return e[29]!==n||e[30]!==s||e[31]!==d||e[32]!==N||e[33]!==R||e[34]!==L||e[35]!==S||e[36]!==h||e[37]!==u||e[38]!==g||e[39]!==x?(p=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-req-row",ref:s,role:"row",style:d,children:[h,u,g,x,N,R,L,S]}),e[29]=n,e[30]=s,e[31]=d,e[32]=N,e[33]=R,e[34]=L,e[35]=S,e[36]=h,e[37]=u,e[38]=g,e[39]=x,e[40]=p):p=e[40],p},"st"),qe=v(i=>{let{entries:e}=i??{};return Array.isArray(e)?e:[]},"de"),at=v(i=>{let e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},"lt"),lt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},ot=v((i,e)=>{let t=e.search.trim().toLowerCase(),n=e.path.trim().toLowerCase(),s=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-lt[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<s||n!==""&&!(o.functionPath??"").toLowerCase().includes(n)?!1:t===""||o.message.toLowerCase().includes(t)||ce(o.fields).toLowerCase().includes(t))},"at"),nt="\u2014",st=v(i=>{let e=new Map,t=new Map;for(let o of i){e.set(o.level,(e.get(o.level)??0)+1);let c=o.functionPath??nt;t.set(c,(t.get(c)??0)+1)}let n=me.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),s=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:n,byPath:s,total:i.length}},"it"),qt=v(({initialShardKey:i})=>{let e=z(),[t,n]=(0,I.useState)("requests"),{queryShardKey:s,setShardKey:o,shardKey:c}=xe(i),[f,m]=(0,I.useState)(""),[d,a]=(0,I.useState)(()=>new Set),[h,l]=(0,I.useState)(""),[u,g]=(0,I.useState)("all"),[b,x]=(0,I.useState)(!1),[w,N]=(0,I.useState)(""),[y,T]=(0,I.useState)(""),[R,k]=(0,I.useState)(""),[L,S]=(0,I.useState)("all"),p=at({functionPathPrefix:w,outcome:L,tableTouched:R,userId:y}),C=oe(ne.getRequestLog,p,{enabled:t==="requests",live:!0,shardKey:s}),q=oe(ne.getLogs,{},{enabled:t==="errors",live:!0,shardKey:s}),F=t==="requests"?C:q,{error:O,errorSource:E,isLoading:M,liveError:V}=F,_=Te(s),U=qe(q.data),A=qe(C.data);(0,I.useEffect)(()=>{F.data!==void 0&&ve(s)},[F.data,s]);let $=ot(U,{levels:d,now:Date.now(),path:h,range:u,search:f}),Q=st($),X=t==="requests"?A.length:$.length,Z=t==="errors"&&b,Y=(0,I.useMemo)(()=>O!==null?"error":X===0?M?Z?"summary":"list":"empty":Z?"summary":"list",[X,M,O,Z]),he=(0,I.useRef)(null),G=ke({count:X,estimateSize:v(()=>Xe,"estimateSize"),getScrollElement:v(()=>he.current,"getScrollElement"),initialRect:{height:ue,width:800},observeElementRect:v((P,ee)=>Se(P,ee,ue),"observeElementRect"),overscan:8}),Ke=G.getVirtualItems(),Me={height:G.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Je,{liveError:V,onShardKeyChange:o,onShowArchive:v(()=>{n("archive"),x(!1)},"onShowArchive"),onShowErrors:v(()=>{n("errors"),x(!1)},"onShowErrors"),onShowRequests:v(()=>{n("requests"),x(!1)},"onShowRequests"),shardKey:c,view:t}),t==="errors"&&(0,r.jsx)(Ve,{levelFilter:d,onLogPathChange:v(P=>{l(P.target.value)},"onLogPathChange"),onSearchChange:v(P=>{m(P.target.value)},"onSearchChange"),onTimeRangeChange:v(P=>{g(P.target.value)},"onTimeRangeChange"),onToggleLevel:v(P=>{a(ee=>{let H=new Set(ee);return H.has(P)?H.delete(P):H.add(P),H})},"onToggleLevel"),onToggleSummary:v(()=>{x(P=>!P)},"onToggleSummary"),pathFilter:h,search:f,showSummary:b,timeRange:u}),t==="requests"&&(0,r.jsx)(Qe,{onOutcomeChange:v(P=>{S(P.target.value)},"onOutcomeChange"),onPathChange:v(P=>{N(P.target.value)},"onPathChange"),onTableChange:v(P=>{k(P.target.value)},"onTableChange"),onUserChange:v(P=>{T(P.target.value)},"onUserChange"),outcomeFilter:L,pathPrefix:w,tableFilter:R,userIdFilter:y}),t==="archive"?(0,r.jsx)(Be,{shardKey:s}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(ye,{error:E,testId:"lg-error"}),Y==="empty"&&(0,r.jsx)(J,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&(0,r.jsx)(Ye,{summary:Q}),Y==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:he,style:Ze,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Me,children:Ke.map(P=>t==="requests"?(0,r.jsx)(rt,{entry:A[P.index],index:P.index,measureRef:G.measureElement,onOpenTrace:_,start:P.start},P.key):(0,r.jsx)(tt,{entry:$[P.index],index:P.index,measureRef:G.measureElement,onOpenTrace:_,start:P.start},P.key))})})]})]})},"Wt");export{qt as LogsPanel,ot as filterLogs,st as summarizeLogs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as dt}from"./chunk-IKT6EYHN.js";import"./chunk-Q6IT6ZD7.js";import"./chunk-ZFW3QEVE.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as De}from"./chunk-37WYCOQ2.js";import{a as st}from"./chunk-EWMBX5N2.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-AUGKHAMQ.js";import{a as at}from"./chunk-R6U22RSY.js";import{a as ot}from"./chunk-LXCVA5SP.js";import{a as tt}from"./chunk-7Q256NLI.js";import{b as et}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{h as We,i as Ue}from"./chunk-OQ6I6OXT.js";import{i as He}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as Qe}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ze}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as qe}from"./chunk-R7SRERCX.js";import"./chunk-NCPW7WHO.js";import"./chunk-RGUL4AQZ.js";import"./chunk-55UGUCQ6.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-QTDX7WSP.js";import{l as Be}from"./chunk-KPRNLQKZ.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as Se}from"./chunk-RWVIV3U7.js";import{a as rt,b as it,c as nt,d as _e,e as q,f as T}from"./chunk-HCTJKP5J.js";import{a as Ve,e as Ge}from"./chunk-2IKDEUCX.js";import{d as le,f as Xe,g as Ye,h as Ze,q as Oe,u as je}from"./chunk-74IYYDDI.js";import{a as s,d as se,e as Je,f as Ae,g as Pe,i as de}from"./chunk-I26MS5PJ.js";var ge=se(Ae(),1),he=se(Je(),1);var lt=se(Ae(),1);var S=se(Je(),1);var m=se(Pe(),1);var qt=Xe(F.runMigration),ct=s(t=>{let e=(0,lt.c)(98),{initialShardKey:r}=t,i=Be(),a=le(),{queryShardKey:o,setShardKey:n,shardKey:d}=at(r),[l,f]=(0,S.useState)(""),[h,g]=(0,S.useState)("up"),[p,b]=(0,S.useState)(!0),[y,x]=(0,S.useState)(!1),[v,u]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),L;e[0]!==d?(L=d.trim(),e[0]=d,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,be,ye;e[5]!==o||e[6]!==$.data?(be=s(()=>{$.data!==void 0&&et(o)},"W"),ye=[$.data,o],e[5]=o,e[6]=$.data,e[7]=be,e[8]=ye):(be=e[7],ye=e[8]),(0,S.useEffect)(be,ye);let ve;if(e[9]!==i||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==d||e[14]!==$||e[15]!==a){let I=s(async()=>{let Ee=l.trim();if(Ee===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await i.query(qt,{direction:h,dryRun:p,id:Ee},Ye(d));u(Le),$.refetch()}catch(Le){let jt=Le;u(null),k(Ze(jt))}x(!1)},"m");ve=s(()=>{Oe(I())},"V"),e[9]=i,e[10]=h,e[11]=p,e[12]=l,e[13]=d,e[14]=$,e[15]=a,e[16]=ve}else ve=e[16];let xe=ve,ke;e[17]===Symbol.for("react.memo_cache_sentinel")?(ke=s(I=>{f(I.target.value)},"Y"),e[17]=ke):ke=e[17];let Nt=ke,we;e[18]===Symbol.for("react.memo_cache_sentinel")?(we=s(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=we):we=e[18];let St=we,$e;e[19]===Symbol.for("react.memo_cache_sentinel")?($e=s(I=>{b(I.target.checked)},"ee"),e[19]=$e):$e=e[19];let Ot=$e,_;e[20]!==n||e[21]!==d?(_=(0,m.jsx)(tt,{onChange:n,testId:"mg-shard-input",value:d}),e[20]=n,e[21]=d,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(st,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(qe,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(Se,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(Ve,{className:"overflow-hidden py-0",children:(0,m.jsx)(Ge,{className:"px-0",children:(0,m.jsxs)(rt,{"data-testid":"mg-table",children:[(0,m.jsx)(it,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(nt,{children:N.map(Tt)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(He,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Nt,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let X;e[57]!==G?(X=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=X):X=e[58];let Y;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==X?(Y=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,X]}),e[59]=h,e[60]=H,e[61]=V,e[62]=X,e[63]=Y):Y=e[63];let Z;e[64]!==p?(Z=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:Ot,type:"checkbox"}),e[64]=p,e[65]=Z):Z=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Z||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Z,ee]}),e[68]=Z,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==xe||e[73]!==y||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(Qe,{"data-testid":"mg-run",disabled:y||!C,onClick:xe,type:"button",children:a(y?"Running\u2026":"Run")}):(0,m.jsx)(ot,{confirmLabel:a(y?"Running\u2026":"Run migration?"),disabled:y||!C,onConfirm:xe,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=xe,e[73]=y,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==Y||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,Y,te,ae]}),e[77]=z,e[78]=Y,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ie;e[82]!==B||e[83]!==re?(ie=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ie):ie=e[84];let ne;e[85]!==w?(ne=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ne):ne=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[v.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:v.status}),v.processed,a(", changed"),v.changed]}),e[87]=v,e[88]=a,e[89]=oe):oe=e[89];let Ne;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ie||e[95]!==ne||e[96]!==oe?(Ne=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ie,ne,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ie,e[95]=ne,e[96]=oe,e[97]=Ne):Ne=e[97],Ne},"yt");function Tt(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(ze,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:je(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}s(Tt,"Je");var c=se(Pe(),1);var Ke=1;function Ct(t){let e={},r=Object.keys(t);r.sort();for(let i of r)e[i]=t[i];return e}s(Ct,"me");var me=s(t=>typeof t=="object"&&t!==null,"O"),Mt=s(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","ue"),It=s(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,i]of Object.entries(e.tables))if(!Mt(i))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Ke},status:"ok"}},"fe"),Ft=s((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,i)=>r===e.fields[i]),"he"),mt=s(t=>t.unique!==void 0,"V"),pe=s(({nullable:t,optional:e,refined:r,unique:i,...a})=>JSON.stringify(Ct(a)),"M"),ut=s(t=>({form:JSON.stringify([pe(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"G"),ht=s(t=>t.kind==="union"&&t.members?t.members.map(e=>ut(e)):[ut({...t,nullable:!1,optional:!1})],"Q"),Rt=s((t,e)=>{if(e.kind!=="union")return!1;let r=ht(e);return ht(t).every(i=>r.some(a=>a.form===i.form&&(i.refined||!a.refined)))},"pe"),O=s(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?O(t.key):"?"}, ${t.of?O(t.of):"?"})`;case"union":return(t.members??[]).map(e=>O(e)).join(" | ");default:return t.kind}},"x"),fe=s((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"j"),Ce=s((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"C"),kt=s((t,e)=>{let r=JSON.stringify(t),i=JSON.stringify(e);return r===i?0:r<i?-1:1},"X"),ue=s(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(kt)}:{}}),"S"),ft=s(t=>t.kind==="union"?t.members??[]:[t],"U"),Lt=s((t,e)=>{let r=[...t],i=[...e],a=new Set,o=new Set,n=s((d,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=i.findIndex((p,b)=>!a.has(b)&&d(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],i[g]]=Me(h,i[g])))}},"s");return n((d,l)=>JSON.stringify(d)===JSON.stringify(l),!1),n((d,l)=>pe(ue(d))===pe(ue(l)),!0),[r,i]},"ge"),Me=s((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=Lt(ft(t),ft(e)),n=s((d,l)=>d.kind==="union"?{...d,members:l.toSorted(kt)}:l[0],"s");return[n(t,a),n(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},i={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],i[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],n=e.fields?.[a];o&&n&&r.fields&&i.fields&&([r.fields[a],i.fields[a]]=Me(o,n))}return[{...t,...r},{...e,...i}]},"I"),_t=s((t,e,r,i,a)=>{let[o,n]=Me(r,i);if(!(o.kind===n.kind&&(!a||pe(o)===pe(n))))return a&&Rt(o,n)?Ce(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(o)} \u2192 ${O(n)} \u2014 every stored value stays valid`):o.kind!==n.kind?fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(o)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Dt=s((t,e,r,i)=>{let a=[];return r.unique!==i.unique&&a.push(i.unique===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):Ce(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==i.nullable&&a.push(i.nullable===!0?Ce(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),r.refined!==i.refined&&a.push(i.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):Ce(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"ye"),wt=s((t,e,r,i)=>{let a=[],o=mt(r)&&mt(i),n=_t(t,e,r,i,o);return n&&a.push(n),o&&a.push(...Dt(t,e,r,i)),r.optional&&!i.optional?a.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&i.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"Z"),Kt=s((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"ve"),Et=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.fields)){let n=e.fields[a];n===void 0?i.push(Kt(t,a,o)):i.push(...wt(t,a,n,o))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&i.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"xe"),Jt=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.indexes)){let n=e.indexes[a];if(n===void 0){i.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Ft(n,o)||i.push({remediation:"code",severity:"breaking",summary:`index ${a} on ${t} changed shape \u2014 a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&i.push({remediation:"code",severity:"breaking",summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` would break`,table:t,scope:"table",type:"removedIndex"})},"ke"),At=s((t,e,r,i)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&i.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&i.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"$e"),pt="shardBy:_unknown_",Te="global",Pt=s((t,e)=>t===Te&&e.startsWith(`${Te}:`)||e===Te&&t.startsWith(`${Te}:`),"we"),Bt=s((t,e,r)=>{if(e===r)return r!==pt?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${pt}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Pt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},"Oe"),gt=s(t=>t.memory!==void 0,"B"),bt=s(t=>t.after??0,"K"),R=s(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Wt=s((t,e,r)=>{if(e===void 0&&r===void 0)return;let i=s(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"i"),a=s(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return i(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${r.field}" on the rows written before it`);if(e.field!==r.field)return i(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; add a data migration to populate "${r.field}"`);let o=bt(e),n=bt(r);return n<o?i(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${r.field}" on the rows that must survive`):n>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"Se"),Ut=s((t,e,r)=>{let i=[];return e.memory!==r.memory&&i.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&i.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() \u2014 new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),i},"Te"),zt=s((t,e,r,i)=>{let a=Bt(t,e.shardMode,r.shardMode);if(a&&i.push(a),gt(e)&>(r)){i.push(...Ut(t,e,r));let o=Wt(t,e.ttl,r.ttl);o&&i.push(o)}Et(t,e,r,i),Jt(t,e,r,i),At(t,e,r,i)},"je"),Ht=s((t,e)=>{let r=[],i=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let n=i[a];if(n===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}zt(a,n,o,r)}for(let a of Object.keys(i))e.tables[a]===void 0&&r.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${a} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:a,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:r}},"Fe"),yt=s(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(i=>i.field===e&&i.kind==="one")?.table,type:O(r)})),"Y"),vt=s((t,e,r)=>{let i={},a=e?.fields??{},o=r?.fields??{};for(let[n,d]of Object.entries(o)){let l=a[n];l===void 0?i[n]=e===void 0?"unchanged":"added":i[n]=wt(t,n,l,d).length===0?"unchanged":"changed"}for(let n of Object.keys(a))o[n]===void 0&&(i[n]="removed");return i},"z"),Qt=s((t,e)=>{let{changes:r}=Ht(t,e),i=new Set(r.filter(n=>n.scope==="table"&&n.table!==void 0).map(n=>n.table)),a=[],o=s((n,d)=>n?"added":i.has(d)?"changed":"context","r");for(let[n,d]of Object.entries(e.tables)){let l=t?.tables[n],f=o(l===void 0,n);a.push({columns:yt(d),fieldStatus:vt(n,l,d),name:n,shardMode:d.shardMode,status:f})}for(let[n,d]of Object.entries(t?.tables??{}))e.tables[n]===void 0&&a.push({columns:yt(d),fieldStatus:vt(n,d,void 0),name:n,shardMode:d.shardMode,status:"removed"});return a.sort((n,d)=>n.name.localeCompare(d.name)),{breakingCount:r.filter(n=>n.severity==="breaking").length,changes:r,tables:a}},"Me"),xt=s(t=>{let e=It(t);return e.status==="ok"?e.snapshot:void 0},"N"),Vt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Gt=s(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ce"),Xt=s(t=>{let e=(0,ge.c)(24),{appliedAt:r,hash:i,onSelect:a,selected:o,seq:n}=t,d=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==d?(l=de("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=l):l=e[1];let f=`sh-version-${i}`,h;e[2]!==i||e[3]!==a?(h=s(()=>{a(i)},"f"),e[2]=i,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==n?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",n]}),e[5]=n,e[6]=g):g=e[6];let p;e[7]!==i?(p=i.slice(0,7),e[7]=i,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let y;e[11]!==g||e[12]!==b?(y=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=y):y=e[13];let x;e[14]!==r?(x=je(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=v):v=e[17];let u;return e[18]!==v||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==y?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[y,v]})}),e[18]=v,e[19]=l,e[20]=f,e[21]=h,e[22]=y,e[23]=u):u=e[23],u},"Ie"),Yt=s(t=>{let e=(0,ge.c)(26),{breaking:r,count:i,first:a}=t,o=le();if(a){let b;e[0]!==i?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:i}),e[0]=i,e[1]=b):b=e[1];let y;e[2]!==o?(y=o("tables"),e[2]=o,e[3]=y):y=e[3];let x;e[4]!==y?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:y}),e[4]=y,e[5]=x):x=e[5];let v;return e[6]!==b||e[7]!==x?(v=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=v):v=e[8],v}let n=r>0&&"text-destructive",d;e[9]!==n?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",n),e[9]=n,e[10]=d):d=e[10];let l;e[11]!==i||e[12]!==d?(l=(0,c.jsx)("span",{className:d,children:i}),e[11]=i,e[12]=d,e[13]=l):l=e[13];let f;e[14]!==i||e[15]!==o?(f=o(i===1?"change":"changes"),e[14]=i,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Re"),$t={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},Zt=s((t,e)=>{let r=`${$t[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"Ee"),ea=s(t=>{let e=new Map;for(let i of t){let a=i.table??"",o=e.get(a);o===void 0?e.set(a,[i]):o.push(i)}let r=[...e].map(([i,a])=>({changes:a,table:i}));return[...r.filter(i=>i.table!==""),...r.filter(i=>i.table==="")]},"Ae"),ta=s(t=>{let e=(0,ge.c)(2),{children:r}=t,i;return e[0]!==r?(i=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=i):i=e[1],i},"De"),aa=s(({pane:t,shardKey:e=""})=>{let r=le(),i=Ue(),a=We({strict:!1}).version,o=s(u=>{Oe(i({search:{version:u},to:"/migrations"}))},"s"),n=ce(F.schemaHistory,{},{shardKey:e}),d=n.data?.versions??[],l=a!==void 0&&d.some(u=>u.hash===a)?a:d[0]?.hash,f=d.findIndex(u=>u.hash===l),h=f===-1?void 0:d[f+1]?.hash,g=ce(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=xt(g.data?.version?.snapshotJson);if(u!==void 0)return Qt(xt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),y=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Gt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Vt[w.status];return u},[b]);if(n.error!==null)return(0,c.jsx)(qe,{error:n.errorSource,testId:"sh-error"});if(d.length===0)return(0,c.jsx)(Se,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let v=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ta,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(u=>(0,c.jsx)(Xt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(Yt,{breaking:b?.breakingCount??0,count:h===void 0?y.length:v.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(dt,{fill:!0,nodeClasses:x,tables:y,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:ea(v).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=$t[k.type],j=k.severity==="breaking",M=Zt(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Le"),ra=s(t=>de("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Ra=s(t=>{let e=(0,ge.c)(11),{initialShardKey:r}=t,i=le(),[a,o]=(0,he.useState)("diagram"),n;e[0]!==a?(n=s((g,p,b,y)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ra(a===g),"data-testid":b,onClick:s(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,y!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:y})]}),"s"),e[0]=a,e[1]=n):n=e[1];let d=n,l;e[2]!==i||e[3]!==d?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",i("Diagram"),"mg-pane-diagram"),d("changes",i("Changes"),"mg-pane-changes"),d("data",i("Data migrations"),"mg-pane-data")]}),e[2]=i,e[3]=d,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ct,{initialShardKey:r})}):(0,c.jsx)(aa,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"Xe");export{Ra as default};
|
|
1
|
+
import{a as dt}from"./chunk-IKT6EYHN.js";import"./chunk-Q6IT6ZD7.js";import"./chunk-ZFW3QEVE.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as De}from"./chunk-37WYCOQ2.js";import{a as st}from"./chunk-EWMBX5N2.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-AUGKHAMQ.js";import{a as at}from"./chunk-R6U22RSY.js";import{a as ot}from"./chunk-LXCVA5SP.js";import{a as tt}from"./chunk-7Q256NLI.js";import{b as et}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{h as We,i as Ue}from"./chunk-OQ6I6OXT.js";import{i as He}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as Qe}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ze}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as qe}from"./chunk-XC2LTW44.js";import"./chunk-NCPW7WHO.js";import"./chunk-5AXRIRHW.js";import"./chunk-55UGUCQ6.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-YSPQIRER.js";import{l as Be}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as Se}from"./chunk-RWVIV3U7.js";import{a as rt,b as it,c as nt,d as _e,e as q,f as T}from"./chunk-HCTJKP5J.js";import{a as Ve,e as Ge}from"./chunk-2IKDEUCX.js";import{d as le,f as Xe,g as Ye,h as Ze,q as Oe,u as je}from"./chunk-74IYYDDI.js";import{a as s,d as se,e as Je,f as Ae,g as Pe,i as de}from"./chunk-I26MS5PJ.js";var ge=se(Ae(),1),he=se(Je(),1);var lt=se(Ae(),1);var S=se(Je(),1);var m=se(Pe(),1);var qt=Xe(F.runMigration),ct=s(t=>{let e=(0,lt.c)(98),{initialShardKey:r}=t,i=Be(),a=le(),{queryShardKey:o,setShardKey:n,shardKey:d}=at(r),[l,f]=(0,S.useState)(""),[h,g]=(0,S.useState)("up"),[p,b]=(0,S.useState)(!0),[y,x]=(0,S.useState)(!1),[v,u]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),L;e[0]!==d?(L=d.trim(),e[0]=d,e[1]=L):L=e[1];let C=L===o,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==o?(M={live:!0,shardKey:o},e[3]=o,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Ie=$.error,{errorSource:Fe,liveError:Re}=$,be,ye;e[5]!==o||e[6]!==$.data?(be=s(()=>{$.data!==void 0&&et(o)},"W"),ye=[$.data,o],e[5]=o,e[6]=$.data,e[7]=be,e[8]=ye):(be=e[7],ye=e[8]),(0,S.useEffect)(be,ye);let ve;if(e[9]!==i||e[10]!==h||e[11]!==p||e[12]!==l||e[13]!==d||e[14]!==$||e[15]!==a){let I=s(async()=>{let Ee=l.trim();if(Ee===""){k(a("Enter a migration id")),u(null);return}x(!0),k(null);try{let Le=await i.query(qt,{direction:h,dryRun:p,id:Ee},Ye(d));u(Le),$.refetch()}catch(Le){let jt=Le;u(null),k(Ze(jt))}x(!1)},"m");ve=s(()=>{Oe(I())},"V"),e[9]=i,e[10]=h,e[11]=p,e[12]=l,e[13]=d,e[14]=$,e[15]=a,e[16]=ve}else ve=e[16];let xe=ve,ke;e[17]===Symbol.for("react.memo_cache_sentinel")?(ke=s(I=>{f(I.target.value)},"Y"),e[17]=ke):ke=e[17];let Nt=ke,we;e[18]===Symbol.for("react.memo_cache_sentinel")?(we=s(I=>{g(I.target.value==="down"?"down":"up")},"Z"),e[18]=we):we=e[18];let St=we,$e;e[19]===Symbol.for("react.memo_cache_sentinel")?($e=s(I=>{b(I.target.checked)},"ee"),e[19]=$e):$e=e[19];let Ot=$e,_;e[20]!==n||e[21]!==d?(_=(0,m.jsx)(tt,{onChange:n,testId:"mg-shard-input",value:d}),e[20]=n,e[21]=d,e[22]=_):_=e[22];let D;e[23]!==Re?(D=(0,m.jsx)(st,{message:Re,prefix:"mg"}),e[23]=Re,e[24]=D):D=e[24];let K;e[25]!==_||e[26]!==D?(K=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,D]}),e[25]=_,e[26]=D,e[27]=K):K=e[27];let E;e[28]!==Ie||e[29]!==Fe?(E=Ie!==null&&(0,m.jsx)(qe,{error:Fe,testId:"mg-status-error"}),e[28]=Ie,e[29]=Fe,e[30]=E):E=e[30];let J;e[31]!==N||e[32]!==a?(J=N!==null&&N.length===0&&(0,m.jsx)(Se,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,m.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,m.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=J):J=e[33];let A;e[34]!==N||e[35]!==a?(A=N!==null&&N.length>0&&(0,m.jsx)(Ve,{className:"overflow-hidden py-0",children:(0,m.jsx)(Ge,{className:"px-0",children:(0,m.jsxs)(rt,{"data-testid":"mg-table",children:[(0,m.jsx)(it,{children:(0,m.jsxs)(_e,{children:[(0,m.jsx)(q,{children:a("id")}),(0,m.jsx)(q,{children:a("direction")}),(0,m.jsx)(q,{children:a("status")}),(0,m.jsx)(q,{children:a("processed")}),(0,m.jsx)(q,{children:a("changed")}),(0,m.jsx)(q,{children:a("updated")}),(0,m.jsx)(q,{children:a("error")})]})}),(0,m.jsx)(nt,{children:N.map(Tt)})]})})}),e[34]=N,e[35]=a,e[36]=A):A=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,m.jsx)(De,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==l||e[46]!==W||e[47]!==U?(z=(0,m.jsx)(He,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:Nt,placeholder:U,value:l}),e[45]=l,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,m.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let X;e[57]!==G?(X=(0,m.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=X):X=e[58];let Y;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==X?(Y=(0,m.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:St,value:h,children:[V,X]}),e[59]=h,e[60]=H,e[61]=V,e[62]=X,e[63]=Y):Y=e[63];let Z;e[64]!==p?(Z=(0,m.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:Ot,type:"checkbox"}),e[64]=p,e[65]=Z):Z=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Z||e[69]!==ee?(te=(0,m.jsxs)(De,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Z,ee]}),e[68]=Z,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==xe||e[73]!==y||e[74]!==C||e[75]!==a?(ae=p?(0,m.jsx)(Qe,{"data-testid":"mg-run",disabled:y||!C,onClick:xe,type:"button",children:a(y?"Running\u2026":"Run")}):(0,m.jsx)(ot,{confirmLabel:a(y?"Running\u2026":"Run migration?"),disabled:y||!C,onConfirm:xe,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=xe,e[73]=y,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==Y||e[79]!==te||e[80]!==ae?(re=(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,Y,te,ae]}),e[77]=z,e[78]=Y,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ie;e[82]!==B||e[83]!==re?(ie=(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ie):ie=e[84];let ne;e[85]!==w?(ne=w!==null&&(0,m.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ne):ne=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,m.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[v.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:v.status}),v.processed,a(", changed"),v.changed]}),e[87]=v,e[88]=a,e[89]=oe):oe=e[89];let Ne;return e[90]!==K||e[91]!==E||e[92]!==J||e[93]!==A||e[94]!==ie||e[95]!==ne||e[96]!==oe?(Ne=(0,m.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[K,E,J,A,ie,ne,oe]}),e[90]=K,e[91]=E,e[92]=J,e[93]=A,e[94]=ie,e[95]=ne,e[96]=oe,e[97]=Ne):Ne=e[97],Ne},"yt");function Tt(t){return(0,m.jsxs)(_e,{"data-testid":`mg-row-${t.id}`,children:[(0,m.jsx)(T,{children:t.id}),(0,m.jsx)(T,{children:t.direction}),(0,m.jsx)(T,{children:(0,m.jsx)(ze,{variant:"secondary",children:t.status})}),(0,m.jsx)(T,{children:t.processed}),(0,m.jsx)(T,{children:t.changed}),(0,m.jsx)(T,{children:je(t.updatedAt)}),(0,m.jsx)(T,{children:t.error??""})]},t.id)}s(Tt,"Je");var c=se(Pe(),1);var Ke=1;function Ct(t){let e={},r=Object.keys(t);r.sort();for(let i of r)e[i]=t[i];return e}s(Ct,"me");var me=s(t=>typeof t=="object"&&t!==null,"O"),Mt=s(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","ue"),It=s(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Ke||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Ke)})`,status:"invalid"};for(let[r,i]of Object.entries(e.tables))if(!Mt(i))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Ke},status:"ok"}},"fe"),Ft=s((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,i)=>r===e.fields[i]),"he"),mt=s(t=>t.unique!==void 0,"V"),pe=s(({nullable:t,optional:e,refined:r,unique:i,...a})=>JSON.stringify(Ct(a)),"M"),ut=s(t=>({form:JSON.stringify([pe(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"G"),ht=s(t=>t.kind==="union"&&t.members?t.members.map(e=>ut(e)):[ut({...t,nullable:!1,optional:!1})],"Q"),Rt=s((t,e)=>{if(e.kind!=="union")return!1;let r=ht(e);return ht(t).every(i=>r.some(a=>a.form===i.form&&(i.refined||!a.refined)))},"pe"),O=s(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;case"from":return t.output===void 0?"from":`from(${t.output})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?O(t.key):"?"}, ${t.of?O(t.of):"?"})`;case"union":return(t.members??[]).map(e=>O(e)).join(" | ");default:return t.kind}},"x"),fe=s((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"j"),Ce=s((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"C"),kt=s((t,e)=>{let r=JSON.stringify(t),i=JSON.stringify(e);return r===i?0:r<i?-1:1},"X"),ue=s(t=>({...t,...t.kind==="from"?{output:void 0}:{},...t.fields?{fields:Object.fromEntries(Object.entries(t.fields).map(([e,r])=>[e,ue(r)]))}:{},...t.key?{key:ue(t.key)}:{},...t.of?{of:ue(t.of)}:{},...t.members?{members:t.members.map(e=>ue(e)).toSorted(kt)}:{}}),"S"),ft=s(t=>t.kind==="union"?t.members??[]:[t],"U"),Lt=s((t,e)=>{let r=[...t],i=[...e],a=new Set,o=new Set,n=s((d,l)=>{for(let[f,h]of r.entries()){if(o.has(f))continue;let g=i.findIndex((p,b)=>!a.has(b)&&d(h,p));g!==-1&&(a.add(g),o.add(f),l&&([r[f],i[g]]=Me(h,i[g])))}},"s");return n((d,l)=>JSON.stringify(d)===JSON.stringify(l),!1),n((d,l)=>pe(ue(d))===pe(ue(l)),!0),[r,i]},"ge"),Me=s((t,e)=>{if(t.kind==="union"||e.kind==="union"){let[a,o]=Lt(ft(t),ft(e)),n=s((d,l)=>d.kind==="union"?{...d,members:l.toSorted(kt)}:l[0],"s");return[n(t,a),n(e,o)]}if(t.kind!==e.kind)return[t,e];if(t.kind==="from")return t.output===void 0||e.output===void 0?[{...t,output:void 0},{...e,output:void 0}]:[t,e];let r={...t.fields?{fields:{...t.fields}}:{}},i={...e.fields?{fields:{...e.fields}}:{}};for(let a of["key","of"])t[a]&&e[a]&&([r[a],i[a]]=Me(t[a],e[a]));for(let a of Object.keys(t.fields??{})){let o=t.fields?.[a],n=e.fields?.[a];o&&n&&r.fields&&i.fields&&([r.fields[a],i.fields[a]]=Me(o,n))}return[{...t,...r},{...e,...i}]},"I"),_t=s((t,e,r,i,a)=>{let[o,n]=Me(r,i);if(!(o.kind===n.kind&&(!a||pe(o)===pe(n))))return a&&Rt(o,n)?Ce(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(o)} \u2192 ${O(n)} \u2014 every stored value stays valid`):o.kind!==n.kind?fe(t,"changedFieldKind",`field ${t}.${e} changed type: ${o.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`):fe(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(o)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"be"),Dt=s((t,e,r,i)=>{let a=[];return r.unique!==i.unique&&a.push(i.unique===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):Ce(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==i.nullable&&a.push(i.nullable===!0?Ce(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):fe(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),r.refined!==i.refined&&a.push(i.refined===!0?fe(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):Ce(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"ye"),wt=s((t,e,r,i)=>{let a=[],o=mt(r)&&mt(i),n=_t(t,e,r,i,o);return n&&a.push(n),o&&a.push(...Dt(t,e,r,i)),r.optional&&!i.optional?a.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&i.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"Z"),Kt=s((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"ve"),Et=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.fields)){let n=e.fields[a];n===void 0?i.push(Kt(t,a,o)):i.push(...wt(t,a,n,o))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&i.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"xe"),Jt=s((t,e,r,i)=>{for(let[a,o]of Object.entries(r.indexes)){let n=e.indexes[a];if(n===void 0){i.push(o.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Ft(n,o)||i.push({remediation:"code",severity:"breaking",summary:`index ${a} on ${t} changed shape \u2014 a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&i.push({remediation:"code",severity:"breaking",summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` would break`,table:t,scope:"table",type:"removedIndex"})},"ke"),At=s((t,e,r,i)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&i.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&i.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"$e"),pt="shardBy:_unknown_",Te="global",Pt=s((t,e)=>t===Te&&e.startsWith(`${Te}:`)||e===Te&&t.startsWith(`${Te}:`),"we"),Bt=s((t,e,r)=>{if(e===r)return r!==pt?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${pt}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Pt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},"Oe"),gt=s(t=>t.memory!==void 0,"B"),bt=s(t=>t.after??0,"K"),R=s(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Wt=s((t,e,r)=>{if(e===void 0&&r===void 0)return;let i=s(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"i"),a=s(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"o");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return i(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${r.field}" on the rows written before it`);if(e.field!==r.field)return i(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; add a data migration to populate "${r.field}"`);let o=bt(e),n=bt(r);return n<o?i(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${r.field}" on the rows that must survive`):n>o?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"Se"),Ut=s((t,e,r)=>{let i=[];return e.memory!==r.memory&&i.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&i.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() \u2014 new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),i},"Te"),zt=s((t,e,r,i)=>{let a=Bt(t,e.shardMode,r.shardMode);if(a&&i.push(a),gt(e)&>(r)){i.push(...Ut(t,e,r));let o=Wt(t,e.ttl,r.ttl);o&&i.push(o)}Et(t,e,r,i),Jt(t,e,r,i),At(t,e,r,i)},"je"),Ht=s((t,e)=>{let r=[],i=t?.tables??{};for(let[a,o]of Object.entries(e.tables)){let n=i[a];if(n===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}zt(a,n,o,r)}for(let a of Object.keys(i))e.tables[a]===void 0&&r.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${a} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:a,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",o=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${o} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:r}},"Fe"),yt=s(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(i=>i.field===e&&i.kind==="one")?.table,type:O(r)})),"Y"),vt=s((t,e,r)=>{let i={},a=e?.fields??{},o=r?.fields??{};for(let[n,d]of Object.entries(o)){let l=a[n];l===void 0?i[n]=e===void 0?"unchanged":"added":i[n]=wt(t,n,l,d).length===0?"unchanged":"changed"}for(let n of Object.keys(a))o[n]===void 0&&(i[n]="removed");return i},"z"),Qt=s((t,e)=>{let{changes:r}=Ht(t,e),i=new Set(r.filter(n=>n.scope==="table"&&n.table!==void 0).map(n=>n.table)),a=[],o=s((n,d)=>n?"added":i.has(d)?"changed":"context","r");for(let[n,d]of Object.entries(e.tables)){let l=t?.tables[n],f=o(l===void 0,n);a.push({columns:yt(d),fieldStatus:vt(n,l,d),name:n,shardMode:d.shardMode,status:f})}for(let[n,d]of Object.entries(t?.tables??{}))e.tables[n]===void 0&&a.push({columns:yt(d),fieldStatus:vt(n,d,void 0),name:n,shardMode:d.shardMode,status:"removed"});return a.sort((n,d)=>n.name.localeCompare(d.name)),{breakingCount:r.filter(n=>n.severity==="breaking").length,changes:r,tables:a}},"Me"),xt=s(t=>{let e=It(t);return e.status==="ok"?e.snapshot:void 0},"N"),Vt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Gt=s(t=>t==="global"||t.startsWith("global:")?"global":"shard","Ce"),Xt=s(t=>{let e=(0,ge.c)(24),{appliedAt:r,hash:i,onSelect:a,selected:o,seq:n}=t,d=o?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",l;e[0]!==d?(l=de("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=l):l=e[1];let f=`sh-version-${i}`,h;e[2]!==i||e[3]!==a?(h=s(()=>{a(i)},"f"),e[2]=i,e[3]=a,e[4]=h):h=e[4];let g;e[5]!==n?(g=(0,c.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",n]}),e[5]=n,e[6]=g):g=e[6];let p;e[7]!==i?(p=i.slice(0,7),e[7]=i,e[8]=p):p=e[8];let b;e[9]!==p?(b=(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=b):b=e[10];let y;e[11]!==g||e[12]!==b?(y=(0,c.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[g,b]}),e[11]=g,e[12]=b,e[13]=y):y=e[13];let x;e[14]!==r?(x=je(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=v):v=e[17];let u;return e[18]!==v||e[19]!==l||e[20]!==f||e[21]!==h||e[22]!==y?(u=(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:l,"data-testid":f,onClick:h,type:"button",children:[y,v]})}),e[18]=v,e[19]=l,e[20]=f,e[21]=h,e[22]=y,e[23]=u):u=e[23],u},"Ie"),Yt=s(t=>{let e=(0,ge.c)(26),{breaking:r,count:i,first:a}=t,o=le();if(a){let b;e[0]!==i?(b=(0,c.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:i}),e[0]=i,e[1]=b):b=e[1];let y;e[2]!==o?(y=o("tables"),e[2]=o,e[3]=y):y=e[3];let x;e[4]!==y?(x=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:y}),e[4]=y,e[5]=x):x=e[5];let v;return e[6]!==b||e[7]!==x?(v=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[b,x]}),e[6]=b,e[7]=x,e[8]=v):v=e[8],v}let n=r>0&&"text-destructive",d;e[9]!==n?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",n),e[9]=n,e[10]=d):d=e[10];let l;e[11]!==i||e[12]!==d?(l=(0,c.jsx)("span",{className:d,children:i}),e[11]=i,e[12]=d,e[13]=l):l=e[13];let f;e[14]!==i||e[15]!==o?(f=o(i===1?"change":"changes"),e[14]=i,e[15]=o,e[16]=f):f=e[16];let h;e[17]!==f?(h=(0,c.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[17]=f,e[18]=h):h=e[18];let g;e[19]!==r||e[20]!==o?(g=r>0&&(0,c.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",o("{count} breaking",{count:r})]}),e[19]=r,e[20]=o,e[21]=g):g=e[21];let p;return e[22]!==l||e[23]!==h||e[24]!==g?(p=(0,c.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[l,h,g]}),e[22]=l,e[23]=h,e[24]=g,e[25]=p):p=e[25],p},"Re"),$t={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},Zt=s((t,e)=>{let r=`${$t[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"Ee"),ea=s(t=>{let e=new Map;for(let i of t){let a=i.table??"",o=e.get(a);o===void 0?e.set(a,[i]):o.push(i)}let r=[...e].map(([i,a])=>({changes:a,table:i}));return[...r.filter(i=>i.table!==""),...r.filter(i=>i.table==="")]},"Ae"),ta=s(t=>{let e=(0,ge.c)(2),{children:r}=t,i;return e[0]!==r?(i=(0,c.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=i):i=e[1],i},"De"),aa=s(({pane:t,shardKey:e=""})=>{let r=le(),i=Ue(),a=We({strict:!1}).version,o=s(u=>{Oe(i({search:{version:u},to:"/migrations"}))},"s"),n=ce(F.schemaHistory,{},{shardKey:e}),d=n.data?.versions??[],l=a!==void 0&&d.some(u=>u.hash===a)?a:d[0]?.hash,f=d.findIndex(u=>u.hash===l),h=f===-1?void 0:d[f+1]?.hash,g=ce(F.schemaVersion,{hash:l??""},{enabled:l!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),b=(0,he.useMemo)(()=>{let u=xt(g.data?.version?.snapshotJson);if(u!==void 0)return Qt(xt(p.data?.version?.snapshotJson),u)},[g.data,p.data]),y=(0,he.useMemo)(()=>(b?.tables??[]).map(u=>({columns:u.columns,name:u.name,tier:Gt(u.shardMode)})),[b]),x=(0,he.useMemo)(()=>{let u={};for(let w of b?.tables??[])u[w.name]=Vt[w.status];return u},[b]);if(n.error!==null)return(0,c.jsx)(qe,{error:n.errorSource,testId:"sh-error"});if(d.length===0)return(0,c.jsx)(Se,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let v=b?.changes??[];return(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,c.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,c.jsx)(ta,{children:r("Schema versions")}),(0,c.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(u=>(0,c.jsx)(Xt,{appliedAt:u.appliedAt,hash:u.hash,onSelect:o,selected:u.hash===l,seq:u.seq},u.hash))})]}),(0,c.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,c.jsx)(Yt,{breaking:b?.breakingCount??0,count:h===void 0?y.length:v.length,first:h===void 0}),t==="diagram"?(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,c.jsx)(dt,{fill:!0,nodeClasses:x,tables:y,testIdPrefix:"sh"})}):(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:ea(v).map(u=>{let w=(b?.tables??[]).find(k=>k.name===u.table);return(0,c.jsxs)("section",{className:"mb-6",children:[(0,c.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,c.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:u.table===""?r("schema"):u.table}),w!==void 0&&(0,c.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),u.changes.length>1&&(0,c.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:u.changes.length})]}),(0,c.jsx)("ul",{children:u.changes.map(k=>{let{action:L,kind:C}=$t[k.type],j=k.severity==="breaking",M=Zt(k,C);return(0,c.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,c.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,c.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==u.table&&(0,c.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,c.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},u.table)})})]})]})},"Le"),ra=s(t=>de("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Ra=s(t=>{let e=(0,ge.c)(11),{initialShardKey:r}=t,i=le(),[a,o]=(0,he.useState)("diagram"),n;e[0]!==a?(n=s((g,p,b,y)=>(0,c.jsxs)("button",{"aria-selected":a===g,className:ra(a===g),"data-testid":b,onClick:s(()=>{o(g)},"onClick"),role:"tab",type:"button",children:[p,y!==void 0&&(0,c.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:y})]}),"s"),e[0]=a,e[1]=n):n=e[1];let d=n,l;e[2]!==i||e[3]!==d?(l=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",i("Diagram"),"mg-pane-diagram"),d("changes",i("Changes"),"mg-pane-changes"),d("data",i("Data migrations"),"mg-pane-data")]}),e[2]=i,e[3]=d,e[4]=l):l=e[4];let f;e[5]!==r||e[6]!==a?(f=(0,c.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,c.jsx)(ct,{initialShardKey:r})}):(0,c.jsx)(aa,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=f):f=e[7];let h;return e[8]!==l||e[9]!==f?(h=(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[l,f]}),e[8]=l,e[9]=f,e[10]=h):h=e[10],h},"Xe");export{Ra as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-NCPW7WHO.js";import{a as T}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-NCPW7WHO.js";import{a as T}from"./chunk-5AXRIRHW.js";import{b as E}from"./chunk-55UGUCQ6.js";import{b as A}from"./chunk-NRAAYZ4C.js";import{d as H,h as I,k as O,l as S}from"./chunk-74IYYDDI.js";import{a as C,d as q,f as _,g as z}from"./chunk-I26MS5PJ.js";var K=q(_(),1);var l=q(z(),1);var P=C(U=>{let e=(0,K.c)(42),{className:y,error:t,testId:g}=U,k=H(),r=E(),n,i,a,c,m,p,o,s,d;if(e[0]!==y||e[1]!==t||e[2]!==r||e[3]!==g){let V=O(t),b;e[13]!==t?(b=S(t),e[13]=t,e[14]=b):b=e[14],i=b;let v;e[15]!==t?(v=T(t),e[15]=t,e[16]=v):v=e[16];let j=v,w=t?.why,N;e[17]!==r||e[18]!==j?(N=C(()=>{r?.openConsole({errorsOnly:!0,seq:j})},"y"),e[17]=r,e[18]=j,e[19]=N):N=e[19],a=N,n=D,c=y,m=g,p="destructive";let h;e[20]!==t?(h=I(t),e[20]=t,e[21]=h):h=e[21],e[22]!==h?(o=(0,l.jsx)("p",{className:"font-medium",children:h}),e[22]=h,e[23]=o):o=e[23],e[24]!==w?(s=typeof w=="string"?(0,l.jsx)("p",{className:"mt-1 text-xs opacity-90",children:w}):null,e[24]=w,e[25]=s):s=e[25],d=V===void 0?null:(0,l.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-xs opacity-90",children:A(V)}),e[0]=y,e[1]=t,e[2]=r,e[3]=g,e[4]=n,e[5]=i,e[6]=a,e[7]=c,e[8]=m,e[9]=p,e[10]=o,e[11]=s,e[12]=d}else n=e[4],i=e[5],a=e[6],c=e[7],m=e[8],p=e[9],o=e[10],s=e[11],d=e[12];let f;e[26]!==i?(f=i===void 0?null:(0,l.jsx)("a",{"aria-label":"View documentation for this error",className:"mt-1 inline-block text-xs underline",href:i,rel:"noreferrer",target:"_blank",children:"View error docs"}),e[26]=i,e[27]=f):f=e[27];let u;e[28]!==r||e[29]!==a||e[30]!==k?(u=r===void 0?null:(0,l.jsx)("button",{className:"mt-1 block text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"error-show-in-console",onClick:a,type:"button",children:k("Show in console")}),e[28]=r,e[29]=a,e[30]=k,e[31]=u):u=e[31];let x;return e[32]!==n||e[33]!==c||e[34]!==m||e[35]!==p||e[36]!==o||e[37]!==s||e[38]!==d||e[39]!==f||e[40]!==u?(x=(0,l.jsxs)(n,{className:c,testId:m,variant:p,children:[o,s,d,f,u]}),e[32]=n,e[33]=c,e[34]=m,e[35]=p,e[36]=o,e[37]=s,e[38]=d,e[39]=f,e[40]=u,e[41]=x):x=e[41],x},"K");export{P as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as u}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as y}from"./chunk-
|
|
1
|
+
import{b as u}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as y}from"./chunk-XC2LTW44.js";import"./chunk-NCPW7WHO.js";import"./chunk-5AXRIRHW.js";import"./chunk-55UGUCQ6.js";import{a as N}from"./chunk-4ZEL6BYL.js";import{c as v}from"./chunk-YSPQIRER.js";import"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as g}from"./chunk-RWVIV3U7.js";import{a as w,b,c as S,d as c,e as s,f as o}from"./chunk-HCTJKP5J.js";import{a as f,e as x}from"./chunk-2IKDEUCX.js";import{d as p}from"./chunk-74IYYDDI.js";import{a as n,d as R,g as T}from"./chunk-I26MS5PJ.js";var e=R(T(),1);var $={active:"default",failing:"destructive",idle:"secondary"},j=n(a=>a===void 0?"\u2014":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,"I"),U=n(a=>{let t=a.runs+a.suppressed;return t===0?void 0:Math.round(a.suppressed/t*100)},"$"),F=n(({initialShardKey:a=""})=>{let t=p(),{data:l,error:E,errorSource:A,liveError:I}=v(N.listReactors,{},{live:!0,shardKey:a}),C=l!==void 0,i=Array.isArray(l?.reactors)?l.reactors:[],d;C&&i.length===0?d=(0,e.jsx)(g,{description:t("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:t("No reactors declared")}):d=(0,e.jsx)(f,{className:"overflow-hidden py-0",children:(0,e.jsx)(x,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"reactors-table",children:[(0,e.jsx)(b,{children:(0,e.jsxs)(c,{children:[(0,e.jsx)(s,{children:t("Reactor")}),(0,e.jsx)(s,{children:t("State")}),(0,e.jsx)(s,{children:t("Ran")}),(0,e.jsx)(s,{children:t("Suppressed")}),(0,e.jsx)(s,{children:t("Errors")}),(0,e.jsx)(s,{children:t("Watches")}),(0,e.jsx)(s,{children:t("Last dispatch")})]})}),(0,e.jsx)(S,{children:i.map(r=>{let m=U(r);return(0,e.jsxs)(c,{"data-testid":`reactors-row-${r.path}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:r.path}),(0,e.jsx)(o,{children:(0,e.jsx)(u,{"data-testid":`reactors-state-${r.path}`,variant:$[r.state],children:r.state})}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.runs}),(0,e.jsxs)(o,{className:"font-mono text-xs text-muted-foreground",children:[r.suppressed,m===void 0?"":` (${String(m)}%)`]}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.errors===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"0"}):(0,e.jsx)("span",{className:"text-destructive",children:r.errors})}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:r.tables===void 0||r.tables.length===0?"\u2014":r.tables.join(", ")}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:j(r.lastRanAt)})]},r.path)})})]})})});let h=i.filter(r=>r.state==="failing");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[E!==null&&(0,e.jsx)(y,{error:A,testId:"reactors-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("A reactor runs after a write flush, but only when the result of the query it watches actually changed \u2014 a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),h.length>0&&(0,e.jsx)("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:h.map(r=>(0,e.jsxs)("p",{className:"text-xs text-destructive",role:"alert",children:[(0,e.jsx)("span",{className:"font-mono",children:r.path}),": ",r.lastError??t("last dispatch failed")]},r.path))}),I!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:t("Live updates unavailable; showing the last reading.")}),d]})},"U");export{F as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as nt}from"./chunk-FUYEZFBP.js";import{i as Pe}from"./chunk-OQ6I6OXT.js";import{a as We}from"./chunk-7G4Z6Q7X.js";import{b as Ve}from"./chunk-Q6ED4KUL.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as _e}from"./chunk-
|
|
1
|
+
import{a as nt}from"./chunk-FUYEZFBP.js";import{i as Pe}from"./chunk-OQ6I6OXT.js";import{a as We}from"./chunk-7G4Z6Q7X.js";import{b as Ve}from"./chunk-Q6ED4KUL.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as _e}from"./chunk-YSPQIRER.js";import{l as Te}from"./chunk-EQRZJZD4.js";import{a as Xe}from"./chunk-RWVIV3U7.js";import{a as T,e as Fe}from"./chunk-2IKDEUCX.js";import{d as j,f as Ye,g as Ze,m as Qe,q as Ne,s as et,t as tt}from"./chunk-74IYYDDI.js";import{a as d,d as De,e as lt,f as it,g as ct,i as Ee}from"./chunk-I26MS5PJ.js";var _=De(it(),1);var M=De(lt(),1);var a=De(ct(),1);var dt=Ye(B.studioFeatures),Je={analytics:!0,auth:!0,containers:!0,flags:!0,kv:!0,mail:!0,notifications:!0,payments:!0,privacy:!0,queues:!0,scheduler:!0,storage:!0,vectors:!0,workflows:!0},mt=d(t=>{if(t===null||typeof t!="object")return;let{id:e,name:s,unsupported:n}=t;if(!(typeof e!="string"||typeof s!="string"||!Array.isArray(n)))return{id:e,name:s,unsupported:n.filter(r=>typeof r=="string")}},"dt"),ut=d(t=>{if(t===null||typeof t!="object")return Je;let e=t,s=d(n=>typeof e[n]=="boolean"?e[n]:!0,"n");return{analytics:s("analytics"),auth:s("auth"),containers:s("containers"),flags:s("flags"),kv:s("kv"),mail:s("mail"),notifications:s("notifications"),payments:s("payments"),privacy:s("privacy"),platform:mt(e.platform),queues:s("queues"),scheduler:s("scheduler"),storage:s("storage"),vectors:s("vectors"),workflows:s("workflows")}},"ut"),pt={...Je,settled:!1},ft=d(()=>{let t=(0,_.c)(3),e=Te(),[s,n]=(0,M.useState)(void 0),r,o;return t[0]!==e?(r=d(()=>{let i=new AbortController;return Ne((async()=>{let l;try{l={...ut(await e.query(dt,{},Ze(""))),settled:!0}}catch{l={...Je,settled:!0}}i.signal.aborted||n({client:e,features:l})})()),()=>{i.abort()}},"a"),o=[e],t[0]=e,t[1]=r,t[2]=o):(r=t[1],o=t[2]),(0,M.useEffect)(r,o),s?.client===e?s.features:pt},"ft"),ht=d(()=>{let t=(0,_.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m9 6 6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),t[0]=e):e=t[0],e},"pt"),gt=d(t=>{let e=(0,_.c)(24),{group:s}=t,n=j(),r=Pe(),o;e[0]!==s.tab||e[1]!==r?(o=d(()=>{Ne(r({to:`/${s.tab}`}))},"r"),e[0]=s.tab,e[1]=r,e[2]=o):o=e[2];let i=o,l=s.bindings.length,c;e[3]!==s.label?(c=(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:s.label}),e[3]=s.label,e[4]=c):c=e[4];let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(ht,{}),e[5]=u):u=e[5];let p;e[6]!==c?(p=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[c,u]}),e[6]=c,e[7]=p):p=e[7];let m;e[8]!==l||e[9]!==n?(m=l===1?n("1 binding"):n("{count} bindings",{count:l}),e[8]=l,e[9]=n,e[10]=m):m=e[10];let f;e[11]!==m?(f=(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:m}),e[11]=m,e[12]=f):f=e[12];let h;e[13]!==l||e[14]!==s.bindings?(h=l>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.bindings.map(yt)}),e[13]=l,e[14]=s.bindings,e[15]=h):h=e[15];let g;e[16]!==p||e[17]!==f||e[18]!==h?(g=(0,a.jsxs)(Fe,{className:"flex flex-col gap-2 py-4",children:[p,f,h]}),e[16]=p,e[17]=f,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==s.testId||e[21]!==i||e[22]!==g?(x=(0,a.jsx)(T,{className:"cursor-pointer gap-0 py-0 transition-colors hover:bg-muted/40","data-testid":s.testId,onClick:i,children:g}),e[20]=s.testId,e[21]=i,e[22]=g,e[23]=x):x=e[23],x},"ht"),at=["kv","files","vectors"],xt=d((t,e)=>[...t.filter(s=>s.tab!==e.tab),e].toSorted((s,n)=>at.indexOf(s.tab)-at.indexOf(n.tab)),"gt"),bt=d(()=>{let t=(0,_.c)(19),e=Te(),s=ft(),n=j(),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];let[o,i]=(0,M.useState)(r),l,c;if(t[1]!==e||t[2]!==s.kv||t[3]!==s.storage||t[4]!==s.vectors||t[5]!==n?(l=d(()=>{let g={cancelled:!1},x=[{enabled:s.kv,label:n("KV Namespaces"),load:d(async()=>(await e.listKvNamespaces()).map(vt),"load"),tab:"kv",testId:"home-binding-kv"},{enabled:s.storage,label:n("R2 Buckets"),load:d(()=>e.listStorageBuckets(),"load"),tab:"files",testId:"home-binding-r2"},{enabled:s.vectors,label:n("Vectorize Indexes"),load:d(async()=>(await e.listVectorIndexes()).map(Nt),"load"),tab:"vectors",testId:"home-binding-vectors"}];for(let b of x)b.enabled&&Ne((async()=>{try{let v=await b.load();if(!g.cancelled){let k={bindings:v,label:b.label,tab:b.tab,testId:b.testId};i(w=>xt(w,k))}}catch{}})());return()=>{g.cancelled=!0}},"o"),c=[e,s.kv,s.storage,s.vectors,n],t[1]=e,t[2]=s.kv,t[3]=s.storage,t[4]=s.vectors,t[5]=n,t[6]=l,t[7]=c):(l=t[6],c=t[7]),(0,M.useEffect)(l,c),o.length===0)return null;let u;t[8]!==n?(u=n("Bindings"),t[8]=n,t[9]=u):u=t[9];let p;t[10]!==u?(p=(0,a.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:u}),t[10]=u,t[11]=p):p=t[11];let m;t[12]!==o?(m=o.map(_t),t[12]=o,t[13]=m):m=t[13];let f;t[14]!==m?(f=(0,a.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:m}),t[14]=m,t[15]=f):f=t[15];let h;return t[16]!==p||t[17]!==f?(h=(0,a.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-bindings",children:[p,f]}),t[16]=p,t[17]=f,t[18]=h):h=t[18],h},"xt");function yt(t){return(0,a.jsx)(Ve,{variant:"secondary",children:t},t)}d(yt,"bt");function vt(t){return t.binding}d(vt,"yt");function Nt(t){return t.name}d(Nt,"vt");function _t(t){return(0,a.jsx)(gt,{group:t},t.tab)}d(_t,"Nt");var kt=[{name:"lunora_list_functions",summary:"list every query, mutation, and action with its path"},{name:"lunora_list_tables",summary:"list the schema's tables"},{name:"lunora_get_function_schema",summary:"read a function's argument JSON Schema before calling it"},{name:"lunora_run_query",summary:"run a read-only query"},{name:"lunora_run_mutation",summary:"run a mutation \u2014 writes; only when LUNORA_MCP_ALLOW_WRITES is set"},{name:"lunora_run_action",summary:"run an action \u2014 writes/effects; only when LUNORA_MCP_ALLOW_WRITES is set"}],wt=d(t=>JSON.stringify({mcpServers:{lunora:{args:["-y","@lunora/mcp"],command:"npx",env:{LUNORA_ADMIN_TOKEN:"<your-admin-token>",LUNORA_URL:t}}}},null,2),"St"),St=d(t=>{let e=kt.map(s=>`- ${s.name} \u2014 ${s.summary}`).join(`
|
|
2
2
|
`);return[`You have a Lunora MCP server connected to the deployment at ${t}.`,"It exposes this backend's functions and schema so you can inspect and operate it:",e,"",`Start by calling lunora_list_functions and lunora_list_tables to learn what exists, then lunora_get_function_schema before any run call. The full HTTP API is also documented at ${t}/_lunora/admin/openapi (that endpoint needs the same admin token the MCP server is configured with).`].join(`
|
|
3
3
|
`)},"kt"),At=1500,Ct=d(()=>{let t=(0,_.c)(40),e=j(),{url:s}=Te(),n;t[0]!==s?(n=et(s),t[0]=s,t[1]=n):n=t[1];let r=n,[o,i]=(0,M.useState)(null),l,c;t[2]!==o?(l=d(()=>{if(o===null)return;let $=globalThis.setTimeout(()=>{i(null)},At);return()=>{globalThis.clearTimeout($)}},"o"),c=[o],t[2]=o,t[3]=l,t[4]=c):(l=t[3],c=t[4]),(0,M.useEffect)(l,c);let u;t[5]===Symbol.for("react.memo_cache_sentinel")?(u=d(($,O)=>{tt(O)&&i($)},"u"),t[5]=u):u=t[5];let p=u,m;t[6]!==r?(m=d(()=>{p("config",wt(r))},"d"),t[6]=r,t[7]=m):m=t[7];let f=m,h;t[8]!==r?(h=d(()=>{p("prompt",St(r))},"p"),t[8]=r,t[9]=h):h=t[9];let g=h,x;t[10]!==e?(x=e("Connect an AI agent"),t[10]=e,t[11]=x):x=t[11];let b;t[12]!==x?(b=(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:x}),t[12]=x,t[13]=b):b=t[13];let v;t[14]!==e?(v=e("Drive this deployment from an AI agent over the Model Context Protocol \u2014 it can list functions and tables, read schemas, and run read-only queries. Writes stay off unless you opt in."),t[14]=e,t[15]=v):v=t[15];let k;t[16]!==v?(k=(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:v}),t[16]=v,t[17]=k):k=t[17];let w;t[18]!==b||t[19]!==k?(w=(0,a.jsxs)("div",{className:"flex flex-col gap-1.5 p-4",children:[b,k]}),t[18]=b,t[19]=k,t[20]=w):w=t[20];let I;t[21]===Symbol.for("react.memo_cache_sentinel")?(I=(0,a.jsx)("code",{className:"font-mono text-xs text-muted-foreground","data-testid":"home-connect-agent-command",children:"npx -y @lunora/mcp"}),t[21]=I):I=t[21];let y;t[22]!==o||t[23]!==e?(y=e(o==="config"?"Copied":"Copy MCP config"),t[22]=o,t[23]=e,t[24]=y):y=t[24];let S;t[25]!==f||t[26]!==y?(S=(0,a.jsx)(We,{"data-testid":"home-connect-agent-copy-config",onClick:f,size:"xs",variant:"outline",children:y}),t[25]=f,t[26]=y,t[27]=S):S=t[27];let A;t[28]!==o||t[29]!==e?(A=e(o==="prompt"?"Copied":"Copy agent prompt"),t[28]=o,t[29]=e,t[30]=A):A=t[30];let C;t[31]!==g||t[32]!==A?(C=(0,a.jsx)(We,{"data-testid":"home-connect-agent-copy-prompt",onClick:g,size:"xs",variant:"outline",children:A}),t[31]=g,t[32]=A,t[33]=C):C=t[33];let N;t[34]!==S||t[35]!==C?(N=(0,a.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-muted/50 px-4 py-3",children:[I,(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[S,C]})]}),t[34]=S,t[35]=C,t[36]=N):N=t[36];let L;return t[37]!==w||t[38]!==N?(L=(0,a.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-connect-agent",children:[w,N]}),t[37]=w,t[38]=N,t[39]=L):L=t[39],L},"Ct"),Lt=(0,M.lazy)(()=>import("./chunk-MC44447W.js")),Mt=d((t,e)=>{if(e==null)return t("cache not enabled");let s=e.hits+e.misses;return s===0?t("no cache traffic yet"):`${Math.round(e.hits/s*100).toString()}% ${t("cache hit")}`},"$t"),He=d(t=>{if(t<1e3)return`${String(Math.round(t))}ms`;let e=t>=1e4?0:1;return`${(t/1e3).toFixed(e)}s`},"Pe"),It=d((t,e)=>{let s=Math.max(0,Math.round((e-t)/1e3));if(s<60)return`${String(s)}s ago`;let n=Math.round(s/60);if(n<60)return`${String(n)}m ago`;let r=Math.round(n/60);return r<24?`${String(r)}h ago`:`${String(Math.round(r/24))}d ago`},"Lt"),st=d((t,e)=>{if(t===void 0||t.length===0)return[];let s=new Map;for(let n of t)s.set(n.bucketMs,(s.get(n.bucketMs)??0)+n[e]);return[...s.entries()].toSorted(([n],[r])=>n-r).map(([,n])=>n)},"Qe"),rt=d((t,e=!0)=>{if(t.length<4)return null;let s=Math.floor(t.length/2),n=t.slice(0,s).reduce((i,l)=>i+l,0),r=t.slice(s).reduce((i,l)=>i+l,0);if(n===0)return null;let o=(r-n)/n*100;return{positive:e?o>=0:o<=0,text:`${o>=0?"+":""}${o.toFixed(1)}%`}},"He"),Oe=d(t=>{let e=(0,_.c)(24),{delta:s,footer:n,label:r,trend:o,unit:i,value:l}=t,c=j(),u;e[0]!==r?(u=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=u):u=e[1];let p;e[2]!==l?(p=(0,a.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:l}),e[2]=l,e[3]=p):p=e[3];let m;e[4]!==i?(m=i!==void 0&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[4]=i,e[5]=m):m=e[5];let f;e[6]!==p||e[7]!==m?(f=(0,a.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[p,m]}),e[6]=p,e[7]=m,e[8]=f):f=e[8];let h;e[9]!==o?(h=o!==void 0&&(0,a.jsx)(M.Suspense,{fallback:(0,a.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28"}),children:(0,a.jsx)(Lt,{data:o})}),e[9]=o,e[10]=h):h=e[10];let g;e[11]!==f||e[12]!==h?(g=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[f,h]}),e[11]=f,e[12]=h,e[13]=g):g=e[13];let x;e[14]!==u||e[15]!==g?(x=(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[u,g]}),e[14]=u,e[15]=g,e[16]=x):x=e[16];let b;e[17]!==s||e[18]!==n||e[19]!==c?(b=s==null?n!=null&&(0,a.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:n}):(0,a.jsxs)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px]",children:[(0,a.jsx)("span",{className:Ee("font-semibold",s.positive?"text-success":"text-destructive"),children:s.text})," ",(0,a.jsx)("span",{className:"text-muted-foreground",children:c("vs. prev.")})]}),e[17]=s,e[18]=n,e[19]=c,e[20]=b):b=e[20];let v;return e[21]!==x||e[22]!==b?(v=(0,a.jsxs)(T,{className:"justify-between gap-0 py-0",children:[x,b]}),e[21]=x,e[22]=b,e[23]=v):v=e[23],v},"Te"),$t=d(()=>{let t=(0,_.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m9 6 6 6-6 6"})}),t[0]=e):e=t[0],e},"Mt"),Ue=d(t=>{let e=(0,_.c)(7),{command:s,label:n}=t,r;e[0]!==n?(r=(0,a.jsx)("div",{className:"p-4",children:(0,a.jsx)("span",{className:"text-sm font-medium text-foreground",children:n})}),e[0]=n,e[1]=r):r=e[1];let o;e[2]!==s?(o=(0,a.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5",children:(0,a.jsx)("code",{className:"font-mono text-xs text-muted-foreground",children:s})}),e[2]=s,e[3]=o):o=e[3];let i;return e[4]!==r||e[5]!==o?(i=(0,a.jsxs)(T,{className:"justify-between gap-0 py-0",children:[r,o]}),e[4]=r,e[5]=o,e[6]=i):i=e[6],i},"De"),ot=d(t=>{let e=(0,_.c)(18),{count:s,onView:n,testId:r,title:o}=t,i=j(),l;e[0]!==o?(l=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o}),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s||e[3]!==i?(c=s===null?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i("No data yet")}):(0,a.jsx)(Ve,{variant:s>0?"destructive":"success",children:s>0?s:i("All clear")}),e[2]=s,e[3]=i,e[4]=c):c=e[4];let u;e[5]!==l||e[6]!==c?(u=(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2 p-4",children:[l,c]}),e[5]=l,e[6]=c,e[7]=u):u=e[7];let p;e[8]!==i?(p=i("View"),e[8]=i,e[9]=p):p=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)($t,{}),e[10]=m):m=e[10];let f;e[11]!==n||e[12]!==p?(f=(0,a.jsxs)("button",{className:"flex items-center gap-1 border-t border-border bg-muted/50 px-4 py-2.5 text-[12px] font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted",onClick:n,type:"button",children:[p,m]}),e[11]=n,e[12]=p,e[13]=f):f=e[13];let h;return e[14]!==u||e[15]!==f||e[16]!==r?(h=(0,a.jsxs)(T,{className:"justify-between gap-0 py-0","data-testid":r,children:[u,f]}),e[14]=u,e[15]=f,e[16]=r,e[17]=h):h=e[17],h},"Ge"),jt=d(t=>{let e=(0,_.c)(7),{functions:s}=t,n=j(),r;if(e[0]!==s||e[1]!==n){let o=[...s].toSorted(qt).slice(0,5),i;e[3]!==n?(i=n("Top functions"),e[3]=n,e[4]=i):i=e[4];let l;e[5]!==i?(l=(0,a.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i})}),e[5]=i,e[6]=l):l=e[6],r=(0,a.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-top-functions",children:[l,o.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:n("No functions called yet.")}):(0,a.jsxs)("div",{className:"divide-y divide-border",children:[(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:[(0,a.jsx)("span",{children:n("Function")}),(0,a.jsx)("span",{className:"text-end",children:n("Calls")}),(0,a.jsx)("span",{className:"w-12 text-end",children:n("Avg")}),(0,a.jsx)("span",{className:"w-8 text-end",children:n("Err")})]}),o.map(Kt)]})]}),e[0]=s,e[1]=n,e[2]=r}else r=e[2];return r},"It"),Tt=d(t=>{let e=(0,_.c)(26),{subs:s}=t,n=j(),r;e[0]!==n?(r=n("Live connections"),e[0]=n,e[1]=r):r=e[1];let o;e[2]!==r?(o=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[2]=r,e[3]=o):o=e[3];let i=s?.totalConnections??0,l;e[4]!==i?(l=i.toLocaleString(),e[4]=i,e[5]=l):l=e[5];let c;e[6]!==l?(c=(0,a.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:l}),e[6]=l,e[7]=c):c=e[7];let u;e[8]!==n?(u=n("sockets"),e[8]=n,e[9]=u):u=e[9];let p;e[10]!==u?(p=(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:u}),e[10]=u,e[11]=p):p=e[11];let m;e[12]!==c||e[13]!==p?(m=(0,a.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[c,p]}),e[12]=c,e[13]=p,e[14]=m):m=e[14];let f=s?.totalSubscriptions??0,h;e[15]!==f?(h=f.toLocaleString(),e[15]=f,e[16]=h):h=e[16];let g;e[17]!==n?(g=n("active subscriptions"),e[17]=n,e[18]=g):g=e[18];let x;e[19]!==h||e[20]!==g?(x=(0,a.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[h," ",g]}),e[19]=h,e[20]=g,e[21]=x):x=e[21];let b;return e[22]!==x||e[23]!==o||e[24]!==m?(b=(0,a.jsx)(T,{"data-testid":"home-live-connections",children:(0,a.jsxs)(Fe,{className:"flex flex-col gap-2.5 py-4",children:[o,m,x]})}),e[22]=x,e[23]=o,e[24]=m,e[25]=b):b=e[25],b},"Tt"),Ot=d(t=>{let e=(0,_.c)(7),{entries:s}=t,n=j(),r;if(e[0]!==s||e[1]!==n){let o=Date.now(),i;e[3]!==n?(i=n("Recent activity"),e[3]=n,e[4]=i):i=e[4];let l;e[5]!==i?(l=(0,a.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i})}),e[5]=i,e[6]=l):l=e[6],r=(0,a.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-recent-activity",children:[l,s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:n("No recent activity.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.slice(0,5).map(c=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-[13px]",children:[(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"}),(0,a.jsxs)("span",{className:"truncate text-foreground",children:[c.op,c.table!==void 0&&(0,a.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",c.table,c.id===void 0?"":`#${c.id}`]})]})]}),(0,a.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:It(c.ts,o)})]},c.seq))})]}),e[0]=s,e[1]=n,e[2]=r}else r=e[2];return r},"Ot"),Rt=d(t=>{let e=t.reduce((s,n)=>s+n.calls,0);return e===0?null:t.reduce((s,n)=>s+n.totalDurationMs,0)/e},"Rt"),Yt=d(t=>{let e=(0,_.c)(149),{initialShardKey:s}=t,n=j(),r=Pe(),o=s??"",i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let l;e[1]!==o?(l={shardKey:o},e[1]=o,e[2]=l):l=e[2];let c=_e(B.getMetrics,i,l),u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u={},e[3]=u):u=e[3];let p;e[4]!==o?(p={shardKey:o},e[4]=o,e[5]=p):p=e[5];let m=_e(B.getFunctionStats,u,p),f,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(f={},h={shardKey:""},e[6]=f,e[7]=h):(f=e[6],h=e[7]);let g=_e(B.getSecurityAudit,f,h),x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x={},e[8]=x):x=e[8];let b;e[9]!==o?(b={shardKey:o},e[9]=o,e[10]=b):b=e[10];let v=_e(B.listSubscriptions,x,b),k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k={},e[11]=k):k=e[11];let w;e[12]!==o?(w={shardKey:o},e[12]=o,e[13]=w):w=e[13];let I=_e(B.getAuditLog,k,w),y=c.data??null,S,A,C,N,L,$,O,R,q,D,P,E,K,z,V,W,F,U;if(e[14]!==I.data||e[15]!==g.data||e[16]!==y||e[17]!==c.data||e[18]!==r||e[19]!==m.data||e[20]!==v.data||e[21]!==n){N=Array.isArray(m.data?.functions)?m.data.functions:[],O=v.data??null;let Ae;e[40]!==I.data?(Ae=Array.isArray(I.data?.entries)?I.data.entries:[],e[40]=I.data,e[41]=Ae):Ae=e[41],A=Ae,L=c.data===void 0||m.data===void 0?null:nt(y,N).length,$=Array.isArray(g.data?.findings)?g.data.findings.length:null;let Ce;e[42]!==r?(Ce=d(()=>{Ne(r({to:"/security"}))},"Ce"),e[42]=r,e[43]=Ce):Ce=e[43],U=Ce;let Le;e[44]!==r?(Le=d(()=>{Ne(r({to:"/insights"}))},"Ae"),e[44]=r,e[45]=Le):Le=e[45],F=Le;let Me=st(y?.history,"calls"),Ie=st(y?.history,"errors"),Ge=Rt(N),$e=Math.max(0,...N.map(zt)),je;e[46]!==y||e[47]!==n?(je=y===null?void 0:Mt(n,y.cache),e[46]=y,e[47]=n,e[48]=je):je=e[48],C=je,V="flex flex-col gap-6",W="lunora-home",P="grid gap-3 sm:grid-cols-2 xl:grid-cols-4",E="home-health";let qe=rt(Me),xe;e[49]!==n?(xe=n("Requests"),e[49]=n,e[50]=xe):xe=e[50];let Ke=y?.requests??0,be;e[51]!==Ke?(be=Ke.toLocaleString(),e[51]=Ke,e[52]=be):be=e[52],e[53]!==Me||e[54]!==qe||e[55]!==xe||e[56]!==be?(K=(0,a.jsx)(Oe,{delta:qe,label:xe,trend:Me,value:be}),e[53]=Me,e[54]=qe,e[55]=xe,e[56]=be,e[57]=K):K=e[57];let ze=rt(Ie,!1),ye;e[58]!==n?(ye=n("Errors"),e[58]=n,e[59]=ye):ye=e[59];let Be=y?.errors??0,ve;e[60]!==Be?(ve=Be.toLocaleString(),e[60]=Be,e[61]=ve):ve=e[61],e[62]!==Ie||e[63]!==ze||e[64]!==ye||e[65]!==ve?(z=(0,a.jsx)(Oe,{delta:ze,label:ye,trend:Ie,value:ve}),e[62]=Ie,e[63]=ze,e[64]=ye,e[65]=ve,e[66]=z):z=e[66],S=Oe,e[67]!==$e||e[68]!==n?(R=$e>0?`${n("max")} ${He($e)}`:void 0,e[67]=$e,e[68]=n,e[69]=R):R=e[69],e[70]!==n?(q=n("Avg latency"),e[70]=n,e[71]=q):q=e[71],D=Ge===null?"\u2014":He(Ge),e[14]=I.data,e[15]=g.data,e[16]=y,e[17]=c.data,e[18]=r,e[19]=m.data,e[20]=v.data,e[21]=n,e[22]=S,e[23]=A,e[24]=C,e[25]=N,e[26]=L,e[27]=$,e[28]=O,e[29]=R,e[30]=q,e[31]=D,e[32]=P,e[33]=E,e[34]=K,e[35]=z,e[36]=V,e[37]=W,e[38]=F,e[39]=U}else S=e[22],A=e[23],C=e[24],N=e[25],L=e[26],$=e[27],O=e[28],R=e[29],q=e[30],D=e[31],P=e[32],E=e[33],K=e[34],z=e[35],V=e[36],W=e[37],F=e[38],U=e[39];let H;e[72]!==S||e[73]!==R||e[74]!==q||e[75]!==D?(H=(0,a.jsx)(S,{footer:R,label:q,value:D}),e[72]=S,e[73]=R,e[74]=q,e[75]=D,e[76]=H):H=e[76];let J;e[77]!==n?(J=n("Database size"),e[77]=n,e[78]=J):J=e[78];let Re=y?.databaseSize??null,G;e[79]!==Re?(G=Qe(Re),e[79]=Re,e[80]=G):G=e[80];let X;e[81]!==C||e[82]!==J||e[83]!==G?(X=(0,a.jsx)(Oe,{footer:C,label:J,value:G}),e[81]=C,e[82]=J,e[83]=G,e[84]=X):X=e[84];let Y;e[85]!==P||e[86]!==E||e[87]!==K||e[88]!==z||e[89]!==H||e[90]!==X?(Y=(0,a.jsxs)("div",{className:P,"data-testid":E,children:[K,z,H,X]}),e[85]=P,e[86]=E,e[87]=K,e[88]=z,e[89]=H,e[90]=X,e[91]=Y):Y=e[91];let ke;e[92]===Symbol.for("react.memo_cache_sentinel")?(ke=(0,a.jsx)(bt,{}),e[92]=ke):ke=e[92];let Z;e[93]!==N?(Z=(0,a.jsx)("div",{className:"lg:col-span-2",children:(0,a.jsx)(jt,{functions:N})}),e[93]=N,e[94]=Z):Z=e[94];let Q;e[95]!==O?(Q=(0,a.jsx)(Tt,{subs:O}),e[95]=O,e[96]=Q):Q=e[96];let ee;e[97]!==A?(ee=(0,a.jsx)(Ot,{entries:A}),e[97]=A,e[98]=ee):ee=e[98];let te;e[99]!==Q||e[100]!==ee?(te=(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[Q,ee]}),e[99]=Q,e[100]=ee,e[101]=te):te=e[101];let ne;e[102]!==Z||e[103]!==te?(ne=(0,a.jsxs)("div",{className:"grid gap-3 lg:grid-cols-3",children:[Z,te]}),e[102]=Z,e[103]=te,e[104]=ne):ne=e[104];let ae;e[105]!==n?(ae=n("Advisors"),e[105]=n,e[106]=ae):ae=e[106];let se;e[107]!==ae?(se=(0,a.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:ae}),e[107]=ae,e[108]=se):se=e[108];let re;e[109]!==L||e[110]!==$||e[111]!==n||e[112]!==F||e[113]!==U?(re=$===0&&L===0?(0,a.jsx)(Xe,{description:n("No security or performance issues detected."),icon:(0,a.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,a.jsx)("path",{d:"M12 3 4 6v5c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V6l-8-3Z"}),(0,a.jsx)("path",{d:"m9 12 2 2 4-4"})]}),testId:"home-advisors-clear",title:n("No issues found")}):(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,a.jsx)(ot,{count:$,onView:U,testId:"home-security",title:n("Security findings")}),(0,a.jsx)(ot,{count:L,onView:F,testId:"home-performance",title:n("Performance issues")})]}),e[109]=L,e[110]=$,e[111]=n,e[112]=F,e[113]=U,e[114]=re):re=e[114];let oe;e[115]!==se||e[116]!==re?(oe=(0,a.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-advisors",children:[se,re]}),e[115]=se,e[116]=re,e[117]=oe):oe=e[117];let le;e[118]!==n?(le=n("Get connected"),e[118]=n,e[119]=le):le=e[119];let ie;e[120]!==le?(ie=(0,a.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:le}),e[120]=le,e[121]=ie):ie=e[121];let ce;e[122]!==n?(ce=n("Client SDK"),e[122]=n,e[123]=ce):ce=e[123];let de;e[124]!==ce?(de=(0,a.jsx)(Ue,{command:"npm i @lunora/client",label:ce}),e[124]=ce,e[125]=de):de=e[125];let me;e[126]!==n?(me=n("React"),e[126]=n,e[127]=me):me=e[127];let ue;e[128]!==me?(ue=(0,a.jsx)(Ue,{command:"npm i @lunora/react",label:me}),e[128]=me,e[129]=ue):ue=e[129];let pe;e[130]!==n?(pe=n("CLI"),e[130]=n,e[131]=pe):pe=e[131];let fe;e[132]!==pe?(fe=(0,a.jsx)(Ue,{command:"lunora dev",label:pe}),e[132]=pe,e[133]=fe):fe=e[133];let he;e[134]!==de||e[135]!==ue||e[136]!==fe?(he=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[de,ue,fe]}),e[134]=de,e[135]=ue,e[136]=fe,e[137]=he):he=e[137];let we;e[138]===Symbol.for("react.memo_cache_sentinel")?(we=(0,a.jsx)(Ct,{}),e[138]=we):we=e[138];let ge;e[139]!==ie||e[140]!==he?(ge=(0,a.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-get-connected",children:[ie,he,we]}),e[139]=ie,e[140]=he,e[141]=ge):ge=e[141];let Se;return e[142]!==V||e[143]!==W||e[144]!==Y||e[145]!==ne||e[146]!==oe||e[147]!==ge?(Se=(0,a.jsxs)("div",{className:V,"data-testid":W,children:[Y,ke,ne,oe,ge]}),e[142]=V,e[143]=W,e[144]=Y,e[145]=ne,e[146]=oe,e[147]=ge,e[148]=Se):Se=e[148],Se},"Xt");function qt(t,e){return e.calls-t.calls}d(qt,"Et");function Kt(t){return(0,a.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] items-center gap-4 px-4 py-2 text-[13px]",children:[(0,a.jsx)("span",{className:"truncate font-mono text-xs text-foreground",children:t.path}),(0,a.jsx)("span",{className:"text-end tabular-nums",children:t.calls.toLocaleString()}),(0,a.jsx)("span",{className:"w-12 text-end tabular-nums text-muted-foreground",children:He(t.calls>0?t.totalDurationMs/t.calls:0)}),(0,a.jsx)("span",{className:Ee("w-8 text-end tabular-nums",t.errors>0?"text-destructive":"text-muted-foreground"),children:t.errors})]},t.path)}d(Kt,"jt");function zt(t){return t.maxDurationMs}d(zt,"Bt");export{ft as a,Yt as b};
|