@lunora/studio 1.0.0-alpha.191 → 1.0.0-alpha.192
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-NZI67TPT.js → chunk-2AF4GGEA.js} +1 -1
- package/dist/standalone/{chunk-43IYGZQ6.js → chunk-3GCIAIU7.js} +1 -1
- package/dist/standalone/{chunk-K7UN7BX4.js → chunk-4FU34V26.js} +1 -1
- package/dist/standalone/{chunk-H7DF4RS7.js → chunk-4HQT6J46.js} +1 -1
- package/dist/standalone/{chunk-2T32GEQQ.js → chunk-5CYMRJFC.js} +1 -1
- package/dist/standalone/{chunk-CHRWZLGV.js → chunk-5EK5T7RB.js} +1 -1
- package/dist/standalone/{chunk-XWMTRNWU.js → chunk-5XNZA4MW.js} +1 -1
- package/dist/standalone/{chunk-IIQQMD2H.js → chunk-6QALZUGH.js} +1 -1
- package/dist/standalone/{chunk-YXMBF7AD.js → chunk-6RZCYIZU.js} +1 -1
- package/dist/standalone/{chunk-YAVGBYLX.js → chunk-7AQCWKWG.js} +1 -1
- package/dist/standalone/{chunk-Q2V33DP4.js → chunk-7K43USMU.js} +1 -1
- package/dist/standalone/{chunk-W6VN64ZP.js → chunk-7QWIQTB5.js} +1 -1
- package/dist/standalone/{chunk-RFSMJBUZ.js → chunk-B4IBO353.js} +1 -1
- package/dist/standalone/{chunk-7ZHHYQ4T.js → chunk-BP52IAS7.js} +1 -1
- package/dist/standalone/{chunk-UC3X7OZS.js → chunk-C2JOSUSU.js} +1 -1
- package/dist/standalone/{chunk-PJE523S5.js → chunk-CUZYSM3T.js} +1 -1
- package/dist/standalone/{chunk-ZKUNMHG5.js → chunk-D4WPZ74S.js} +1 -1
- package/dist/standalone/{chunk-AYZMJVUF.js → chunk-DLGCUCVF.js} +1 -1
- package/dist/standalone/{chunk-EVW7O6HB.js → chunk-DRCZCSQB.js} +1 -1
- package/dist/standalone/{chunk-KQSYYO6Q.js → chunk-ECXGTUEB.js} +1 -1
- package/dist/standalone/{chunk-MUZKHVS3.js → chunk-EG4LQXMU.js} +1 -1
- package/dist/standalone/{chunk-Y5SVNBXX.js → chunk-G7CZLXHG.js} +1 -1
- package/dist/standalone/{chunk-GUPNWYY4.js → chunk-GCK3ETRI.js} +1 -1
- package/dist/standalone/{chunk-YXFRZ4WU.js → chunk-GRRBDTHN.js} +1 -1
- package/dist/standalone/{chunk-33TZIQ2S.js → chunk-HJDUAPFN.js} +1 -1
- package/dist/standalone/{chunk-QDGH4GMS.js → chunk-HSLBRVXG.js} +1 -1
- package/dist/standalone/{chunk-OWZ3CC4J.js → chunk-IEAB4WIW.js} +1 -1
- package/dist/standalone/{chunk-QZGZTILS.js → chunk-IGAZPEWG.js} +1 -1
- package/dist/standalone/{chunk-MEWNGXGQ.js → chunk-JAV5E2US.js} +1 -1
- package/dist/standalone/{chunk-MTUKLG3H.js → chunk-JSLOLQVJ.js} +1 -1
- package/dist/standalone/{chunk-I4UWU3J5.js → chunk-JSZ62DJR.js} +1 -1
- package/dist/standalone/{chunk-MZFWCHUZ.js → chunk-JYLNU6LY.js} +1 -1
- package/dist/standalone/{chunk-DWJBMAZK.js → chunk-KWMJBXDT.js} +1 -1
- package/dist/standalone/{chunk-IYBEVL3D.js → chunk-L2ELGA6G.js} +1 -1
- package/dist/standalone/{chunk-MN6FO3NX.js → chunk-LRMAKQ5D.js} +1 -1
- package/dist/standalone/{chunk-3FTKCJ7O.js → chunk-MRWNURCB.js} +1 -1
- package/dist/standalone/{chunk-4POCWNXY.js → chunk-MW53Q7VM.js} +1 -1
- package/dist/standalone/{chunk-ZF4ZY6GC.js → chunk-N6YASDC6.js} +1 -1
- package/dist/standalone/{chunk-DNJ65IEL.js → chunk-NC36545D.js} +1 -1
- package/dist/standalone/{chunk-ZSLVBHNB.js → chunk-NFVUUGI3.js} +1 -1
- package/dist/standalone/{chunk-EQF3OTY7.js → chunk-NW4UH6A5.js} +1 -1
- package/dist/standalone/{chunk-FI3ECXVE.js → chunk-OHUMFJGU.js} +1 -1
- package/dist/standalone/{chunk-QCZEJFOU.js → chunk-PFZ6PDDU.js} +1 -1
- package/dist/standalone/{chunk-CA3OW2WZ.js → chunk-Q3OLT6HU.js} +1 -1
- package/dist/standalone/{chunk-22FKIHUY.js → chunk-QDDROCW4.js} +1 -1
- package/dist/standalone/{chunk-AJP7B63M.js → chunk-QU6JE7AF.js} +1 -1
- package/dist/standalone/{chunk-FTV2YW7O.js → chunk-RFYWIDZ7.js} +1 -1
- package/dist/standalone/{chunk-5FAP63DI.js → chunk-S3GSNPBN.js} +1 -1
- package/dist/standalone/{chunk-W6GSTWSM.js → chunk-SDL7ZG4U.js} +1 -1
- package/dist/standalone/{chunk-LJFYYHU7.js → chunk-SRKHI5NE.js} +1 -1
- package/dist/standalone/{chunk-OSDSDUGS.js → chunk-TPW3FSXD.js} +1 -1
- package/dist/standalone/{chunk-AZVN24IA.js → chunk-UFIIJHJT.js} +1 -1
- package/dist/standalone/{chunk-BOM2BBWF.js → chunk-WQSJGN7Q.js} +1 -1
- package/dist/standalone/{chunk-KNCZAQG6.js → chunk-YUZWAZ35.js} +2 -2
- package/dist/standalone/{chunk-HXD4OZRG.js → chunk-Z6724PLT.js} +1 -1
- package/dist/standalone/{chunk-XYFUZ3FC.js → chunk-ZSGHAK2D.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f}from"./chunk-IMOHEGMV.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as C}from"./chunk-PD6WIDY6.js";import{W as v}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as q}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as w}from"./chunk-4ZEL6BYL.js";import{f as L}from"./chunk-
|
|
1
|
+
import{a as f}from"./chunk-IMOHEGMV.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as C}from"./chunk-PD6WIDY6.js";import{W as v}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as q}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as w}from"./chunk-4ZEL6BYL.js";import{f as L}from"./chunk-YUZWAZ35.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{d as P,f as y,g as p,h,o as u}from"./chunk-FODLDLE2.js";import{a as s,d as S,e as W,g as X}from"./chunk-YKXDMIHQ.js";var a=S(W(),1);var e=S(X(),1);var B=y(w.getPitrBookmark),Y=y(w.pitrRestore),de=s(({initialShardKey:z})=>{let m=L(),t=P(),o=z??"",[A,x]=(0,a.useState)(null),[l,O]=(0,a.useState)(""),[R,I]=(0,a.useState)(null),[c,D]=(0,a.useState)(""),[k,E]=(0,a.useState)(!1),[i,K]=(0,a.useState)(null),[T,n]=(0,a.useState)(null),[b,d]=(0,a.useState)(!1),g=(0,a.useCallback)(async()=>{d(!0),n(null);try{let r=await m.query(B,{},p(o));x(r.current)}catch(r){n(h(r))}d(!1)},[m,o]);(0,a.useEffect)(()=>{u(g())},[g]),j(()=>{u((async()=>{try{let r=await m.query(B,{},p(o));x(r.current)}catch{}})())},!0);let M=s(r=>{O(r.target.value)},"A"),Z=s(r=>{D(r.target.value)},"U"),_=s(r=>{E(r.target.checked)},"q"),G=s(()=>{l.trim()!==""&&u((async()=>{d(!0),n(null);try{let r=await m.query(B,{time:l.trim()},p(o));I(r.forTime??null),x(r.current)}catch(r){I(null),n(h(r))}d(!1)})())},"K"),F=s(r=>{u((async()=>{d(!0),n(null);try{let N=await m.mutation(Y,r,p(o));K(N),await g()}catch(N){n(h(N))}d(!1)})())},"C"),H=c.trim()!==""||l.trim()!=="",J=t("Restore {shard} to {target}?",{shard:o===""?t("root"):o,target:c.trim()===""?l.trim():t("the given bookmark")}),Q=s(()=>{let r=k?{restart:!0}:{};c.trim()===""?r.time=l.trim():r.bookmark=c.trim(),F(r)},"z"),V=s(()=>{i!==null&&F(k?{bookmark:i.undoBookmark,restart:!0}:{bookmark:i.undoBookmark})},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[t("Shard"),": ",(0,e.jsx)("span",{className:"font-mono",children:o===""?t("root"):o})]})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),T!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:T}),(0,e.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:t("Current bookmark")}),(0,e.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:A??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:t("Restore")}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-time",children:t("Time (ISO or epoch-ms, last 30 days)")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(v,{"data-testid":"pitr-time",id:"pitr-time",onChange:M,placeholder:"2026-06-01T00:00:00.000Z",value:l}),(0,e.jsx)(U,{"data-testid":"pitr-preview",disabled:b||l.trim()==="",onClick:G,size:"sm",type:"button",variant:"outline",children:t("Preview")})]}),R!==null&&(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",R]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-bookmark",children:t("Or an explicit bookmark (wins over time)")}),(0,e.jsx)(v,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Z,placeholder:t("bookmark string"),value:c})]}),(0,e.jsxs)(f,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsx)("input",{checked:k,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:_,type:"checkbox"}),t("Restart the shard now so recovery applies immediately")]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:J,disabled:b||!H,onConfirm:Q,testId:"pitr-restore",children:t("Restore")})})]}),i!==null&&(0,e.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),(0,e.jsx)(q,{variant:i.restarted?"destructive":"secondary",children:i.restarted?t("restarted now"):t("on next restart")})]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",i.restoredTo]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",i.undoBookmark]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:t("Confirm undo"),disabled:b,onConfirm:V,testId:"pitr-undo",children:t("Undo restore")})})]})]})},"ce");export{de as PitrPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ot}from"./chunk-23C2QL7Z.js";import"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as Re}from"./chunk-IMOHEGMV.js";import{a as it}from"./chunk-BOTGXX4H.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as nt}from"./chunk-PD6WIDY6.js";import{a as et}from"./chunk-S3CRZLGS.js";import{a as Ze}from"./chunk-2DX5MROH.js";import{b as Ye}from"./chunk-OGUKYRFM.js";import{d as Pe,e as Be}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ue}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as ze}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as We}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Oe}from"./chunk-4POCWNXY.js";import"./chunk-ULIQFBZU.js";import"./chunk-GUPNWYY4.js";import"./chunk-35DM4JJG.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-AZVN24IA.js";import{f as Je}from"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as $e}from"./chunk-FKVZRPV5.js";import{a as tt,b as at,c as rt,d as Fe,e as q,f as T}from"./chunk-HEAQVSNS.js";import{a as He,e as Qe}from"./chunk-WUWBZPUK.js";import{d as le,f as Ve,g as Ge,h as Xe,o as Ne,r as Se}from"./chunk-FODLDLE2.js";import{a as o,d as se,e as De,f as Ee,g as Ae,i as de}from"./chunk-YKXDMIHQ.js";var pe=se(Ee(),1),ue=se(De(),1);var st=se(Ee(),1);var S=se(De(),1);var c=se(Ae(),1);var Nt=Ve(F.runMigration),dt=o(t=>{let e=(0,st.c)(98),{initialShardKey:r}=t,n=Je(),a=le(),{queryShardKey:s,setShardKey:i,shardKey:d}=et(r),[u,b]=(0,S.useState)(""),[h,y]=(0,S.useState)("up"),[p,g]=(0,S.useState)(!0),[f,x]=(0,S.useState)(!1),[v,m]=(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===s,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==s?(M={live:!0,shardKey:s},e[3]=s,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Te=$.error,{errorSource:Ce,liveError:Me}=$,fe,ge;e[5]!==s||e[6]!==$.data?(fe=o(()=>{$.data!==void 0&&Ye(s)},"W"),ge=[$.data,s],e[5]=s,e[6]=$.data,e[7]=fe,e[8]=ge):(fe=e[7],ge=e[8]),(0,S.useEffect)(fe,ge);let be;if(e[9]!==n||e[10]!==h||e[11]!==p||e[12]!==u||e[13]!==d||e[14]!==$||e[15]!==a){let I=o(async()=>{let Ke=u.trim();if(Ke===""){k(a("Enter a migration id")),m(null);return}x(!0),k(null);try{let Ie=await n.query(Nt,{direction:h,dryRun:p,id:Ke},Ge(d));m(Ie),$.refetch()}catch(Ie){let $t=Ie;m(null),k(Xe($t))}x(!1)},"m");be=o(()=>{Ne(I())},"V"),e[9]=n,e[10]=h,e[11]=p,e[12]=u,e[13]=d,e[14]=$,e[15]=a,e[16]=be}else be=e[16];let ye=be,ve;e[17]===Symbol.for("react.memo_cache_sentinel")?(ve=o(I=>{b(I.target.value)},"Y"),e[17]=ve):ve=e[17];let xt=ve,xe;e[18]===Symbol.for("react.memo_cache_sentinel")?(xe=o(I=>{y(I.target.value==="down"?"down":"up")},"Z"),e[18]=xe):xe=e[18];let kt=xe,ke;e[19]===Symbol.for("react.memo_cache_sentinel")?(ke=o(I=>{g(I.target.checked)},"ee"),e[19]=ke):ke=e[19];let wt=ke,_;e[20]!==i||e[21]!==d?(_=(0,c.jsx)(Ze,{onChange:i,testId:"mg-shard-input",value:d}),e[20]=i,e[21]=d,e[22]=_):_=e[22];let K;e[23]!==Me?(K=(0,c.jsx)(it,{message:Me,prefix:"mg"}),e[23]=Me,e[24]=K):K=e[24];let D;e[25]!==_||e[26]!==K?(D=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,K]}),e[25]=_,e[26]=K,e[27]=D):D=e[27];let E;e[28]!==Te||e[29]!==Ce?(E=Te!==null&&(0,c.jsx)(Oe,{error:Ce,testId:"mg-status-error"}),e[28]=Te,e[29]=Ce,e[30]=E):E=e[30];let A;e[31]!==N||e[32]!==a?(A=N!==null&&N.length===0&&(0,c.jsx)($e,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,c.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,c.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]=A):A=e[33];let J;e[34]!==N||e[35]!==a?(J=N!==null&&N.length>0&&(0,c.jsx)(He,{className:"overflow-hidden py-0",children:(0,c.jsx)(Qe,{className:"px-0",children:(0,c.jsxs)(tt,{"data-testid":"mg-table",children:[(0,c.jsx)(at,{children:(0,c.jsxs)(Fe,{children:[(0,c.jsx)(q,{children:a("id")}),(0,c.jsx)(q,{children:a("direction")}),(0,c.jsx)(q,{children:a("status")}),(0,c.jsx)(q,{children:a("processed")}),(0,c.jsx)(q,{children:a("changed")}),(0,c.jsx)(q,{children:a("updated")}),(0,c.jsx)(q,{children:a("error")})]})}),(0,c.jsx)(rt,{children:N.map(St)})]})})}),e[34]=N,e[35]=a,e[36]=J):J=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,c.jsx)(Re,{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]!==u||e[46]!==W||e[47]!==U?(z=(0,c.jsx)(Ue,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:xt,placeholder:U,value:u}),e[45]=u,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,c.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,c.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,c.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:kt,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,c.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:wt,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,c.jsxs)(Re,{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]!==ye||e[73]!==f||e[74]!==C||e[75]!==a?(ae=p?(0,c.jsx)(ze,{"data-testid":"mg-run",disabled:f||!C,onClick:ye,type:"button",children:a(f?"Running\u2026":"Run")}):(0,c.jsx)(nt,{confirmLabel:a(f?"Running\u2026":"Run migration?"),disabled:f||!C,onConfirm:ye,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ye,e[73]=f,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,c.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 ne;e[82]!==B||e[83]!==re?(ne=(0,c.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]=ne):ne=e[84];let ie;e[85]!==w?(ie=w!==null&&(0,c.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ie):ie=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,c.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 we;return e[90]!==D||e[91]!==E||e[92]!==A||e[93]!==J||e[94]!==ne||e[95]!==ie||e[96]!==oe?(we=(0,c.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[D,E,A,J,ne,ie,oe]}),e[90]=D,e[91]=E,e[92]=A,e[93]=J,e[94]=ne,e[95]=ie,e[96]=oe,e[97]=we):we=e[97],we},"yt");function St(t){return(0,c.jsxs)(Fe,{"data-testid":`mg-row-${t.id}`,children:[(0,c.jsx)(T,{children:t.id}),(0,c.jsx)(T,{children:t.direction}),(0,c.jsx)(T,{children:(0,c.jsx)(We,{variant:"secondary",children:t.status})}),(0,c.jsx)(T,{children:t.processed}),(0,c.jsx)(T,{children:t.changed}),(0,c.jsx)(T,{children:Se(t.updatedAt)}),(0,c.jsx)(T,{children:t.error??""})]},t.id)}o(St,"Je");var l=se(Ae(),1);var Le=1;function Ot(t){let e={},r=Object.keys(t);r.sort();for(let n of r)e[n]=t[n];return e}o(Ot,"re");var me=o(t=>typeof t=="object"&&t!==null,"O"),jt=o(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","de"),qt=o(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!==Le||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Le)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!jt(n))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:Le},status:"ok"}},"le"),Tt=o((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,n)=>r===e.fields[n]),"ce"),lt=o(t=>t.unique!==void 0,"J"),_e=o(({nullable:t,optional:e,refined:r,unique:n,...a})=>JSON.stringify(Ot(a)),"D"),ct=o(t=>({form:JSON.stringify([_e(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"H"),mt=o(t=>t.kind==="union"&&t.members?t.members.map(e=>ct(e)):[ct({...t,nullable:!1,optional:!1})],"V"),Ct=o((t,e)=>{if(e.kind!=="union")return!1;let r=mt(e);return mt(t).every(n=>r.some(a=>a.form===n.form&&(n.refined||!a.refined)))},"me"),O=o(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;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"),he=o((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"T"),qe=o((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"q"),Mt=o((t,e,r,n,a)=>{if(!(r.kind===n.kind&&(!a||_e(r)===_e(n))))return a&&Ct(r,n)?qe(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(r)} \u2192 ${O(n)} \u2014 every stored value stays valid`):r.kind!==n.kind?he(t,"changedFieldKind",`field ${t}.${e} changed type: ${r.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`):he(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(r)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"he"),It=o((t,e,r,n)=>{let a=[];return r.unique!==n.unique&&a.push(n.unique===!0?he(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):qe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==n.nullable&&a.push(n.nullable===!0?qe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):he(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!==n.refined&&a.push(n.refined===!0?he(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`):qe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"fe"),yt=o((t,e,r,n)=>{let a=[],s=lt(r)&<(n),i=Mt(t,e,r,n,s);return i&&a.push(i),s&&a.push(...It(t,e,r,n)),r.optional&&!n.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&&n.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"Y"),Ft=o((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"},"ue"),Rt=o((t,e,r,n)=>{for(let[a,s]of Object.entries(r.fields)){let i=e.fields[a];i===void 0?n.push(Ft(t,a,s)):n.push(...yt(t,a,i,s))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&n.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"})},"pe"),Lt=o((t,e,r,n)=>{for(let[a,s]of Object.entries(r.indexes)){let i=e.indexes[a];if(i===void 0){n.push(s.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}Tt(i,s)||n.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&&n.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"})},"ge"),_t=o((t,e,r,n)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&n.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&&n.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"be"),ut="shardBy:_unknown_",je="global",Kt=o((t,e)=>t===je&&e.startsWith(`${je}:`)||e===je&&t.startsWith(`${je}:`),"ye"),Dt=o((t,e,r)=>{if(e===r)return r!==ut?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 "${ut}" 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(!Kt(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"}},"ve"),ht=o(t=>t.memory!==void 0,"Q"),pt=o(t=>t.after??0,"W"),R=o(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Et=o((t,e,r)=>{if(e===void 0&&r===void 0)return;let n=o(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"n"),a=o(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"s");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return n(`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 n(`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 s=pt(e),i=pt(r);return i<s?n(`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`):i>s?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"xe"),At=o((t,e,r)=>{let n=[];return e.memory!==r.memory&&n.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&&n.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"}),n},"ke"),Jt=o((t,e,r,n)=>{let a=Dt(t,e.shardMode,r.shardMode);if(a&&n.push(a),ht(e)&&ht(r)){n.push(...At(t,e,r));let s=Et(t,e.ttl,r.ttl);s&&n.push(s)}Rt(t,e,r,n),Lt(t,e,r,n),_t(t,e,r,n)},"$e"),Pt=o((t,e)=>{let r=[],n=t?.tables??{};for(let[a,s]of Object.entries(e.tables)){let i=n[a];if(i===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}Jt(a,i,s,r)}for(let a of Object.keys(n))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)",s=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${s} \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}},"we"),ft=o(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:O(r)})),"B"),gt=o((t,e,r)=>{let n={},a=e?.fields??{},s=r?.fields??{};for(let[i,d]of Object.entries(s)){let u=a[i];u===void 0?n[i]=e===void 0?"unchanged":"added":n[i]=yt(t,i,u,d).length===0?"unchanged":"changed"}for(let i of Object.keys(a))s[i]===void 0&&(n[i]="removed");return n},"U"),Bt=o((t,e)=>{let{changes:r}=Pt(t,e),n=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),a=[],s=o((i,d)=>i?"added":n.has(d)?"changed":"context","a");for(let[i,d]of Object.entries(e.tables)){let u=t?.tables[i],b=s(u===void 0,i);a.push({columns:ft(d),fieldStatus:gt(i,u,d),name:i,shardMode:d.shardMode,status:b})}for(let[i,d]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&a.push({columns:ft(d),fieldStatus:gt(i,d,void 0),name:i,shardMode:d.shardMode,status:"removed"});return a.sort((i,d)=>i.name.localeCompare(d.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:a}},"Oe"),bt=o(t=>{let e=qt(t);return e.status==="ok"?e.snapshot:void 0},"K"),Wt={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"},Ut=o(t=>t==="global"||t.startsWith("global:")?"global":"shard","Te"),zt=o(t=>{let e=(0,pe.c)(24),{appliedAt:r,hash:n,onSelect:a,selected:s,seq:i}=t,d=s?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==d?(u=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]=u):u=e[1];let b=`sh-version-${n}`,h;e[2]!==n||e[3]!==a?(h=o(()=>{a(n)},"u"),e[2]=n,e[3]=a,e[4]=h):h=e[4];let y;e[5]!==i?(y=(0,l.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=y):y=e[6];let p;e[7]!==n?(p=n.slice(0,7),e[7]=n,e[8]=p):p=e[8];let g;e[9]!==p?(g=(0,l.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=g):g=e[10];let f;e[11]!==y||e[12]!==g?(f=(0,l.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[y,g]}),e[11]=y,e[12]=g,e[13]=f):f=e[13];let x;e[14]!==r?(x=Se(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,l.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 m;return e[18]!==v||e[19]!==u||e[20]!==b||e[21]!==h||e[22]!==f?(m=(0,l.jsx)("li",{children:(0,l.jsxs)("button",{className:u,"data-testid":b,onClick:h,type:"button",children:[f,v]})}),e[18]=v,e[19]=u,e[20]=b,e[21]=h,e[22]=f,e[23]=m):m=e[23],m},"je"),Ht=o(t=>{let e=(0,pe.c)(26),{breaking:r,count:n,first:a}=t,s=le();if(a){let g;e[0]!==n?(g=(0,l.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=g):g=e[1];let f;e[2]!==s?(f=s("tables"),e[2]=s,e[3]=f):f=e[3];let x;e[4]!==f?(x=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=x):x=e[5];let v;return e[6]!==g||e[7]!==x?(v=(0,l.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[g,x]}),e[6]=g,e[7]=x,e[8]=v):v=e[8],v}let i=r>0&&"text-destructive",d;e[9]!==i?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=d):d=e[10];let u;e[11]!==n||e[12]!==d?(u=(0,l.jsx)("span",{className:d,children:n}),e[11]=n,e[12]=d,e[13]=u):u=e[13];let b;e[14]!==n||e[15]!==s?(b=s(n===1?"change":"changes"),e[14]=n,e[15]=s,e[16]=b):b=e[16];let h;e[17]!==b?(h=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:b}),e[17]=b,e[18]=h):h=e[18];let y;e[19]!==r||e[20]!==s?(y=r>0&&(0,l.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",s("{count} breaking",{count:r})]}),e[19]=r,e[20]=s,e[21]=y):y=e[21];let p;return e[22]!==u||e[23]!==h||e[24]!==y?(p=(0,l.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,h,y]}),e[22]=u,e[23]=h,e[24]=y,e[25]=p):p=e[25],p},"Fe"),vt={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"}},Qt=o((t,e)=>{let r=`${vt[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"qe"),Vt=o(t=>{let e=new Map;for(let n of t){let a=n.table??"",s=e.get(a);s===void 0?e.set(a,[n]):s.push(n)}let r=[...e].map(([n,a])=>({changes:a,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"Ce"),Gt=o(t=>{let e=(0,pe.c)(2),{children:r}=t,n;return e[0]!==r?(n=(0,l.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]=n):n=e[1],n},"Me"),Xt=o(({pane:t,shardKey:e=""})=>{let r=le(),n=Be(),a=Pe({strict:!1}).version,s=o(m=>{Ne(n({search:{version:m},to:"/migrations"}))},"o"),i=ce(F.schemaHistory,{},{shardKey:e}),d=i.data?.versions??[],u=a!==void 0&&d.some(m=>m.hash===a)?a:d[0]?.hash,b=d.findIndex(m=>m.hash===u),h=b===-1?void 0:d[b+1]?.hash,y=ce(F.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),g=(0,ue.useMemo)(()=>{let m=bt(y.data?.version?.snapshotJson);if(m!==void 0)return Bt(bt(p.data?.version?.snapshotJson),m)},[y.data,p.data]),f=(0,ue.useMemo)(()=>(g?.tables??[]).map(m=>({columns:m.columns,name:m.name,tier:Ut(m.shardMode)})),[g]),x=(0,ue.useMemo)(()=>{let m={};for(let w of g?.tables??[])m[w.name]=Wt[w.status];return m},[g]);if(i.error!==null)return(0,l.jsx)(Oe,{error:i.errorSource,testId:"sh-error"});if(d.length===0)return(0,l.jsx)($e,{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=g?.changes??[];return(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,l.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,l.jsx)(Gt,{children:r("Schema versions")}),(0,l.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(m=>(0,l.jsx)(zt,{appliedAt:m.appliedAt,hash:m.hash,onSelect:s,selected:m.hash===u,seq:m.seq},m.hash))})]}),(0,l.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,l.jsx)(Ht,{breaking:g?.breakingCount??0,count:h===void 0?f.length:v.length,first:h===void 0}),t==="diagram"?(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,l.jsx)(ot,{fill:!0,nodeClasses:x,tables:f,testIdPrefix:"sh"})}):(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Vt(v).map(m=>{let w=(g?.tables??[]).find(k=>k.name===m.table);return(0,l.jsxs)("section",{className:"mb-6",children:[(0,l.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,l.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:m.table===""?r("schema"):m.table}),w!==void 0&&(0,l.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),m.changes.length>1&&(0,l.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:m.changes.length})]}),(0,l.jsx)("ul",{children:m.changes.map(k=>{let{action:L,kind:C}=vt[k.type],j=k.severity==="breaking",M=Qt(k,C);return(0,l.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,l.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,l.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==m.table&&(0,l.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,l.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},m.table)})})]})]})},"Ie"),Yt=o(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"),"Re"),Ta=o(t=>{let e=(0,pe.c)(11),{initialShardKey:r}=t,n=le(),[a,s]=(0,ue.useState)("diagram"),i;e[0]!==a?(i=o((y,p,g,f)=>(0,l.jsxs)("button",{"aria-selected":a===y,className:Yt(a===y),"data-testid":g,onClick:o(()=>{s(y)},"onClick"),role:"tab",type:"button",children:[p,f!==void 0&&(0,l.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),"o"),e[0]=a,e[1]=i):i=e[1];let d=i,u;e[2]!==n||e[3]!==d?(u=(0,l.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",n("Diagram"),"mg-pane-diagram"),d("changes",n("Changes"),"mg-pane-changes"),d("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=d,e[4]=u):u=e[4];let b;e[5]!==r||e[6]!==a?(b=(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,l.jsx)(dt,{initialShardKey:r})}):(0,l.jsx)(Xt,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=b):b=e[7];let h;return e[8]!==u||e[9]!==b?(h=(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,b]}),e[8]=u,e[9]=b,e[10]=h):h=e[10],h},"Ue");export{Ta as default};
|
|
1
|
+
import{a as ot}from"./chunk-23C2QL7Z.js";import"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as Re}from"./chunk-IMOHEGMV.js";import{a as it}from"./chunk-BOTGXX4H.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as nt}from"./chunk-PD6WIDY6.js";import{a as et}from"./chunk-S3CRZLGS.js";import{a as Ze}from"./chunk-2DX5MROH.js";import{b as Ye}from"./chunk-OGUKYRFM.js";import{d as Pe,e as Be}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ue}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as ze}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as We}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Oe}from"./chunk-MW53Q7VM.js";import"./chunk-ULIQFBZU.js";import"./chunk-GCK3ETRI.js";import"./chunk-35DM4JJG.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-UFIIJHJT.js";import{f as Je}from"./chunk-YUZWAZ35.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as $e}from"./chunk-FKVZRPV5.js";import{a as tt,b as at,c as rt,d as Fe,e as q,f as T}from"./chunk-HEAQVSNS.js";import{a as He,e as Qe}from"./chunk-WUWBZPUK.js";import{d as le,f as Ve,g as Ge,h as Xe,o as Ne,r as Se}from"./chunk-FODLDLE2.js";import{a as o,d as se,e as De,f as Ee,g as Ae,i as de}from"./chunk-YKXDMIHQ.js";var pe=se(Ee(),1),ue=se(De(),1);var st=se(Ee(),1);var S=se(De(),1);var c=se(Ae(),1);var Nt=Ve(F.runMigration),dt=o(t=>{let e=(0,st.c)(98),{initialShardKey:r}=t,n=Je(),a=le(),{queryShardKey:s,setShardKey:i,shardKey:d}=et(r),[u,b]=(0,S.useState)(""),[h,y]=(0,S.useState)("up"),[p,g]=(0,S.useState)(!0),[f,x]=(0,S.useState)(!1),[v,m]=(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===s,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==s?(M={live:!0,shardKey:s},e[3]=s,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Te=$.error,{errorSource:Ce,liveError:Me}=$,fe,ge;e[5]!==s||e[6]!==$.data?(fe=o(()=>{$.data!==void 0&&Ye(s)},"W"),ge=[$.data,s],e[5]=s,e[6]=$.data,e[7]=fe,e[8]=ge):(fe=e[7],ge=e[8]),(0,S.useEffect)(fe,ge);let be;if(e[9]!==n||e[10]!==h||e[11]!==p||e[12]!==u||e[13]!==d||e[14]!==$||e[15]!==a){let I=o(async()=>{let Ke=u.trim();if(Ke===""){k(a("Enter a migration id")),m(null);return}x(!0),k(null);try{let Ie=await n.query(Nt,{direction:h,dryRun:p,id:Ke},Ge(d));m(Ie),$.refetch()}catch(Ie){let $t=Ie;m(null),k(Xe($t))}x(!1)},"m");be=o(()=>{Ne(I())},"V"),e[9]=n,e[10]=h,e[11]=p,e[12]=u,e[13]=d,e[14]=$,e[15]=a,e[16]=be}else be=e[16];let ye=be,ve;e[17]===Symbol.for("react.memo_cache_sentinel")?(ve=o(I=>{b(I.target.value)},"Y"),e[17]=ve):ve=e[17];let xt=ve,xe;e[18]===Symbol.for("react.memo_cache_sentinel")?(xe=o(I=>{y(I.target.value==="down"?"down":"up")},"Z"),e[18]=xe):xe=e[18];let kt=xe,ke;e[19]===Symbol.for("react.memo_cache_sentinel")?(ke=o(I=>{g(I.target.checked)},"ee"),e[19]=ke):ke=e[19];let wt=ke,_;e[20]!==i||e[21]!==d?(_=(0,c.jsx)(Ze,{onChange:i,testId:"mg-shard-input",value:d}),e[20]=i,e[21]=d,e[22]=_):_=e[22];let K;e[23]!==Me?(K=(0,c.jsx)(it,{message:Me,prefix:"mg"}),e[23]=Me,e[24]=K):K=e[24];let D;e[25]!==_||e[26]!==K?(D=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,K]}),e[25]=_,e[26]=K,e[27]=D):D=e[27];let E;e[28]!==Te||e[29]!==Ce?(E=Te!==null&&(0,c.jsx)(Oe,{error:Ce,testId:"mg-status-error"}),e[28]=Te,e[29]=Ce,e[30]=E):E=e[30];let A;e[31]!==N||e[32]!==a?(A=N!==null&&N.length===0&&(0,c.jsx)($e,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,c.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,c.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]=A):A=e[33];let J;e[34]!==N||e[35]!==a?(J=N!==null&&N.length>0&&(0,c.jsx)(He,{className:"overflow-hidden py-0",children:(0,c.jsx)(Qe,{className:"px-0",children:(0,c.jsxs)(tt,{"data-testid":"mg-table",children:[(0,c.jsx)(at,{children:(0,c.jsxs)(Fe,{children:[(0,c.jsx)(q,{children:a("id")}),(0,c.jsx)(q,{children:a("direction")}),(0,c.jsx)(q,{children:a("status")}),(0,c.jsx)(q,{children:a("processed")}),(0,c.jsx)(q,{children:a("changed")}),(0,c.jsx)(q,{children:a("updated")}),(0,c.jsx)(q,{children:a("error")})]})}),(0,c.jsx)(rt,{children:N.map(St)})]})})}),e[34]=N,e[35]=a,e[36]=J):J=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,c.jsx)(Re,{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]!==u||e[46]!==W||e[47]!==U?(z=(0,c.jsx)(Ue,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:xt,placeholder:U,value:u}),e[45]=u,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,c.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,c.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,c.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:kt,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,c.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:wt,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,c.jsxs)(Re,{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]!==ye||e[73]!==f||e[74]!==C||e[75]!==a?(ae=p?(0,c.jsx)(ze,{"data-testid":"mg-run",disabled:f||!C,onClick:ye,type:"button",children:a(f?"Running\u2026":"Run")}):(0,c.jsx)(nt,{confirmLabel:a(f?"Running\u2026":"Run migration?"),disabled:f||!C,onConfirm:ye,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ye,e[73]=f,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,c.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 ne;e[82]!==B||e[83]!==re?(ne=(0,c.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]=ne):ne=e[84];let ie;e[85]!==w?(ie=w!==null&&(0,c.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ie):ie=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,c.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 we;return e[90]!==D||e[91]!==E||e[92]!==A||e[93]!==J||e[94]!==ne||e[95]!==ie||e[96]!==oe?(we=(0,c.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[D,E,A,J,ne,ie,oe]}),e[90]=D,e[91]=E,e[92]=A,e[93]=J,e[94]=ne,e[95]=ie,e[96]=oe,e[97]=we):we=e[97],we},"yt");function St(t){return(0,c.jsxs)(Fe,{"data-testid":`mg-row-${t.id}`,children:[(0,c.jsx)(T,{children:t.id}),(0,c.jsx)(T,{children:t.direction}),(0,c.jsx)(T,{children:(0,c.jsx)(We,{variant:"secondary",children:t.status})}),(0,c.jsx)(T,{children:t.processed}),(0,c.jsx)(T,{children:t.changed}),(0,c.jsx)(T,{children:Se(t.updatedAt)}),(0,c.jsx)(T,{children:t.error??""})]},t.id)}o(St,"Je");var l=se(Ae(),1);var Le=1;function Ot(t){let e={},r=Object.keys(t);r.sort();for(let n of r)e[n]=t[n];return e}o(Ot,"re");var me=o(t=>typeof t=="object"&&t!==null,"O"),jt=o(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","de"),qt=o(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!==Le||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Le)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!jt(n))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:Le},status:"ok"}},"le"),Tt=o((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,n)=>r===e.fields[n]),"ce"),lt=o(t=>t.unique!==void 0,"J"),_e=o(({nullable:t,optional:e,refined:r,unique:n,...a})=>JSON.stringify(Ot(a)),"D"),ct=o(t=>({form:JSON.stringify([_e(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"H"),mt=o(t=>t.kind==="union"&&t.members?t.members.map(e=>ct(e)):[ct({...t,nullable:!1,optional:!1})],"V"),Ct=o((t,e)=>{if(e.kind!=="union")return!1;let r=mt(e);return mt(t).every(n=>r.some(a=>a.form===n.form&&(n.refined||!a.refined)))},"me"),O=o(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;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"),he=o((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"T"),qe=o((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"q"),Mt=o((t,e,r,n,a)=>{if(!(r.kind===n.kind&&(!a||_e(r)===_e(n))))return a&&Ct(r,n)?qe(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(r)} \u2192 ${O(n)} \u2014 every stored value stays valid`):r.kind!==n.kind?he(t,"changedFieldKind",`field ${t}.${e} changed type: ${r.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`):he(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(r)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"he"),It=o((t,e,r,n)=>{let a=[];return r.unique!==n.unique&&a.push(n.unique===!0?he(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):qe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==n.nullable&&a.push(n.nullable===!0?qe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):he(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!==n.refined&&a.push(n.refined===!0?he(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`):qe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"fe"),yt=o((t,e,r,n)=>{let a=[],s=lt(r)&<(n),i=Mt(t,e,r,n,s);return i&&a.push(i),s&&a.push(...It(t,e,r,n)),r.optional&&!n.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&&n.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"Y"),Ft=o((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"},"ue"),Rt=o((t,e,r,n)=>{for(let[a,s]of Object.entries(r.fields)){let i=e.fields[a];i===void 0?n.push(Ft(t,a,s)):n.push(...yt(t,a,i,s))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&n.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"})},"pe"),Lt=o((t,e,r,n)=>{for(let[a,s]of Object.entries(r.indexes)){let i=e.indexes[a];if(i===void 0){n.push(s.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}Tt(i,s)||n.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&&n.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"})},"ge"),_t=o((t,e,r,n)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&n.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&&n.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"be"),ut="shardBy:_unknown_",je="global",Kt=o((t,e)=>t===je&&e.startsWith(`${je}:`)||e===je&&t.startsWith(`${je}:`),"ye"),Dt=o((t,e,r)=>{if(e===r)return r!==ut?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 "${ut}" 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(!Kt(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"}},"ve"),ht=o(t=>t.memory!==void 0,"Q"),pt=o(t=>t.after??0,"W"),R=o(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Et=o((t,e,r)=>{if(e===void 0&&r===void 0)return;let n=o(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"n"),a=o(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"s");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return n(`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 n(`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 s=pt(e),i=pt(r);return i<s?n(`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`):i>s?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"xe"),At=o((t,e,r)=>{let n=[];return e.memory!==r.memory&&n.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&&n.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"}),n},"ke"),Jt=o((t,e,r,n)=>{let a=Dt(t,e.shardMode,r.shardMode);if(a&&n.push(a),ht(e)&&ht(r)){n.push(...At(t,e,r));let s=Et(t,e.ttl,r.ttl);s&&n.push(s)}Rt(t,e,r,n),Lt(t,e,r,n),_t(t,e,r,n)},"$e"),Pt=o((t,e)=>{let r=[],n=t?.tables??{};for(let[a,s]of Object.entries(e.tables)){let i=n[a];if(i===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}Jt(a,i,s,r)}for(let a of Object.keys(n))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)",s=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${s} \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}},"we"),ft=o(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:O(r)})),"B"),gt=o((t,e,r)=>{let n={},a=e?.fields??{},s=r?.fields??{};for(let[i,d]of Object.entries(s)){let u=a[i];u===void 0?n[i]=e===void 0?"unchanged":"added":n[i]=yt(t,i,u,d).length===0?"unchanged":"changed"}for(let i of Object.keys(a))s[i]===void 0&&(n[i]="removed");return n},"U"),Bt=o((t,e)=>{let{changes:r}=Pt(t,e),n=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),a=[],s=o((i,d)=>i?"added":n.has(d)?"changed":"context","a");for(let[i,d]of Object.entries(e.tables)){let u=t?.tables[i],b=s(u===void 0,i);a.push({columns:ft(d),fieldStatus:gt(i,u,d),name:i,shardMode:d.shardMode,status:b})}for(let[i,d]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&a.push({columns:ft(d),fieldStatus:gt(i,d,void 0),name:i,shardMode:d.shardMode,status:"removed"});return a.sort((i,d)=>i.name.localeCompare(d.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:a}},"Oe"),bt=o(t=>{let e=qt(t);return e.status==="ok"?e.snapshot:void 0},"K"),Wt={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"},Ut=o(t=>t==="global"||t.startsWith("global:")?"global":"shard","Te"),zt=o(t=>{let e=(0,pe.c)(24),{appliedAt:r,hash:n,onSelect:a,selected:s,seq:i}=t,d=s?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==d?(u=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]=u):u=e[1];let b=`sh-version-${n}`,h;e[2]!==n||e[3]!==a?(h=o(()=>{a(n)},"u"),e[2]=n,e[3]=a,e[4]=h):h=e[4];let y;e[5]!==i?(y=(0,l.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=y):y=e[6];let p;e[7]!==n?(p=n.slice(0,7),e[7]=n,e[8]=p):p=e[8];let g;e[9]!==p?(g=(0,l.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=g):g=e[10];let f;e[11]!==y||e[12]!==g?(f=(0,l.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[y,g]}),e[11]=y,e[12]=g,e[13]=f):f=e[13];let x;e[14]!==r?(x=Se(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,l.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 m;return e[18]!==v||e[19]!==u||e[20]!==b||e[21]!==h||e[22]!==f?(m=(0,l.jsx)("li",{children:(0,l.jsxs)("button",{className:u,"data-testid":b,onClick:h,type:"button",children:[f,v]})}),e[18]=v,e[19]=u,e[20]=b,e[21]=h,e[22]=f,e[23]=m):m=e[23],m},"je"),Ht=o(t=>{let e=(0,pe.c)(26),{breaking:r,count:n,first:a}=t,s=le();if(a){let g;e[0]!==n?(g=(0,l.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=g):g=e[1];let f;e[2]!==s?(f=s("tables"),e[2]=s,e[3]=f):f=e[3];let x;e[4]!==f?(x=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=x):x=e[5];let v;return e[6]!==g||e[7]!==x?(v=(0,l.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[g,x]}),e[6]=g,e[7]=x,e[8]=v):v=e[8],v}let i=r>0&&"text-destructive",d;e[9]!==i?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=d):d=e[10];let u;e[11]!==n||e[12]!==d?(u=(0,l.jsx)("span",{className:d,children:n}),e[11]=n,e[12]=d,e[13]=u):u=e[13];let b;e[14]!==n||e[15]!==s?(b=s(n===1?"change":"changes"),e[14]=n,e[15]=s,e[16]=b):b=e[16];let h;e[17]!==b?(h=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:b}),e[17]=b,e[18]=h):h=e[18];let y;e[19]!==r||e[20]!==s?(y=r>0&&(0,l.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",s("{count} breaking",{count:r})]}),e[19]=r,e[20]=s,e[21]=y):y=e[21];let p;return e[22]!==u||e[23]!==h||e[24]!==y?(p=(0,l.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,h,y]}),e[22]=u,e[23]=h,e[24]=y,e[25]=p):p=e[25],p},"Fe"),vt={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"}},Qt=o((t,e)=>{let r=`${vt[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"qe"),Vt=o(t=>{let e=new Map;for(let n of t){let a=n.table??"",s=e.get(a);s===void 0?e.set(a,[n]):s.push(n)}let r=[...e].map(([n,a])=>({changes:a,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"Ce"),Gt=o(t=>{let e=(0,pe.c)(2),{children:r}=t,n;return e[0]!==r?(n=(0,l.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]=n):n=e[1],n},"Me"),Xt=o(({pane:t,shardKey:e=""})=>{let r=le(),n=Be(),a=Pe({strict:!1}).version,s=o(m=>{Ne(n({search:{version:m},to:"/migrations"}))},"o"),i=ce(F.schemaHistory,{},{shardKey:e}),d=i.data?.versions??[],u=a!==void 0&&d.some(m=>m.hash===a)?a:d[0]?.hash,b=d.findIndex(m=>m.hash===u),h=b===-1?void 0:d[b+1]?.hash,y=ce(F.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),g=(0,ue.useMemo)(()=>{let m=bt(y.data?.version?.snapshotJson);if(m!==void 0)return Bt(bt(p.data?.version?.snapshotJson),m)},[y.data,p.data]),f=(0,ue.useMemo)(()=>(g?.tables??[]).map(m=>({columns:m.columns,name:m.name,tier:Ut(m.shardMode)})),[g]),x=(0,ue.useMemo)(()=>{let m={};for(let w of g?.tables??[])m[w.name]=Wt[w.status];return m},[g]);if(i.error!==null)return(0,l.jsx)(Oe,{error:i.errorSource,testId:"sh-error"});if(d.length===0)return(0,l.jsx)($e,{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=g?.changes??[];return(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,l.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,l.jsx)(Gt,{children:r("Schema versions")}),(0,l.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(m=>(0,l.jsx)(zt,{appliedAt:m.appliedAt,hash:m.hash,onSelect:s,selected:m.hash===u,seq:m.seq},m.hash))})]}),(0,l.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,l.jsx)(Ht,{breaking:g?.breakingCount??0,count:h===void 0?f.length:v.length,first:h===void 0}),t==="diagram"?(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,l.jsx)(ot,{fill:!0,nodeClasses:x,tables:f,testIdPrefix:"sh"})}):(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Vt(v).map(m=>{let w=(g?.tables??[]).find(k=>k.name===m.table);return(0,l.jsxs)("section",{className:"mb-6",children:[(0,l.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,l.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:m.table===""?r("schema"):m.table}),w!==void 0&&(0,l.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),m.changes.length>1&&(0,l.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:m.changes.length})]}),(0,l.jsx)("ul",{children:m.changes.map(k=>{let{action:L,kind:C}=vt[k.type],j=k.severity==="breaking",M=Qt(k,C);return(0,l.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,l.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,l.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==m.table&&(0,l.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,l.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},m.table)})})]})]})},"Ie"),Yt=o(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"),"Re"),Ta=o(t=>{let e=(0,pe.c)(11),{initialShardKey:r}=t,n=le(),[a,s]=(0,ue.useState)("diagram"),i;e[0]!==a?(i=o((y,p,g,f)=>(0,l.jsxs)("button",{"aria-selected":a===y,className:Yt(a===y),"data-testid":g,onClick:o(()=>{s(y)},"onClick"),role:"tab",type:"button",children:[p,f!==void 0&&(0,l.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),"o"),e[0]=a,e[1]=i):i=e[1];let d=i,u;e[2]!==n||e[3]!==d?(u=(0,l.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",n("Diagram"),"mg-pane-diagram"),d("changes",n("Changes"),"mg-pane-changes"),d("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=d,e[4]=u):u=e[4];let b;e[5]!==r||e[6]!==a?(b=(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,l.jsx)(dt,{initialShardKey:r})}):(0,l.jsx)(Xt,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=b):b=e[7];let h;return e[8]!==u||e[9]!==b?(h=(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,b]}),e[8]=u,e[9]=b,e[10]=h):h=e[10],h},"Ue");export{Ta as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-BOTGXX4H.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as L}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-BOTGXX4H.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as L}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-UFIIJHJT.js";import"./chunk-YUZWAZ35.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as I}from"./chunk-FKVZRPV5.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-HEAQVSNS.js";import{a as b,e as S}from"./chunk-WUWBZPUK.js";import{d as w}from"./chunk-FODLDLE2.js";import{a as f,d as y,f as _,g as j}from"./chunk-YKXDMIHQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(b,{className:"overflow-hidden py-0",children:(0,t.jsx)(S,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Qe}from"./chunk-23C2QL7Z.js";import{a as Me,b as Re}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as we}from"./chunk-IMOHEGMV.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as He}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as We}from"./chunk-OGUKYRFM.js";import{e as Ue}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as me}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ze}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{f as Ve}from"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as Je}from"./chunk-FKVZRPV5.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-WUWBZPUK.js";import{d as Fe,f as Ee,g as $e,h as Oe,o as ue}from"./chunk-FODLDLE2.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-YKXDMIHQ.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,b]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[p,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,be]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[J,xe]=(0,x.useState)(Y),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{be(await l.listGlobalTables())}catch(h){let w=h;be(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,pe=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||pe.current===n||i.some(h=>h.name===n)&&(pe.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(bt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:p,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:B,globalExpanded:W,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:b,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=S,e[57]=Ne,e[58]=re,e[59]=J,e[60]=B,e[61]=W,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function bt(s){return s.name}r(bt,"ft");var pt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let b;e[2]!==m||e[3]!==g||e[4]!==o?(b=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=b):b=e[5];let i=!u,v=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==p?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:p}),e[8]=l,e[9]=i,e[10]=v,e[11]=p,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==b||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[b,P,G,C]}),e[27]=G,e[28]=C,e[29]=b,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let b;e[6]!==o?(b=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=b):b=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let p;return e[13]!==b||e[14]!==v?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[b,v]}),e[13]=b,e[14]=v,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,b]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[p,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),b(null);try{let ge=await ft(T);b(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;b({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let be=k,B;e[6]!==p||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:p.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=p,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let J=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{b(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{b(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{b(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),b({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let pe=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==be||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:be,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=be,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:pe,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let b;e[4]!==m?(b=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=b):b=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==b||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",b]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=b,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==v?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=p):p=e[19],p},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:b,filteredTables:i,globalColumns:v,globalError:p,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,be;e[5]!==M?(be=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=be):be=e[6];let B=be,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==$?(W=$??[],e[12]=$,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",pe;e[30]!==ce?(pe=lt(ce),e[30]=ce,e[31]=pe):pe=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==pe||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:pe,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=pe,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==p||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=p,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==b||e[66]!==i||e[67]!==v||e[68]!==p||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:b.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&b.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),b.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:b.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=b,e[66]=i,e[67]=v,e[68]=p,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Xt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
|
|
1
|
+
import{a as Qe}from"./chunk-23C2QL7Z.js";import{a as Me,b as Re}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as we}from"./chunk-IMOHEGMV.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as He}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as We}from"./chunk-OGUKYRFM.js";import{e as Ue}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as me}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ze}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{f as Ve}from"./chunk-YUZWAZ35.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as Je}from"./chunk-FKVZRPV5.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-WUWBZPUK.js";import{d as Fe,f as Ee,g as $e,h as Oe,o as ue}from"./chunk-FODLDLE2.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-YKXDMIHQ.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,b]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[p,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,be]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[J,xe]=(0,x.useState)(Y),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{be(await l.listGlobalTables())}catch(h){let w=h;be(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,pe=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||pe.current===n||i.some(h=>h.name===n)&&(pe.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(bt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:p,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:B,globalExpanded:W,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:b,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=S,e[57]=Ne,e[58]=re,e[59]=J,e[60]=B,e[61]=W,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function bt(s){return s.name}r(bt,"ft");var pt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let b;e[2]!==m||e[3]!==g||e[4]!==o?(b=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=b):b=e[5];let i=!u,v=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==p?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:p}),e[8]=l,e[9]=i,e[10]=v,e[11]=p,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==b||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[b,P,G,C]}),e[27]=G,e[28]=C,e[29]=b,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let b;e[6]!==o?(b=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=b):b=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let p;return e[13]!==b||e[14]!==v?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[b,v]}),e[13]=b,e[14]=v,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,b]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[p,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),b(null);try{let ge=await ft(T);b(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;b({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let be=k,B;e[6]!==p||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:p.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=p,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let J=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{b(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{b(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{b(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),b({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let pe=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==be||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:be,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=be,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:pe,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let b;e[4]!==m?(b=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=b):b=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==b||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",b]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=b,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==v?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=p):p=e[19],p},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:b,filteredTables:i,globalColumns:v,globalError:p,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,be;e[5]!==M?(be=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=be):be=e[6];let B=be,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==$?(W=$??[],e[12]=$,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",pe;e[30]!==ce?(pe=lt(ce),e[30]=ce,e[31]=pe):pe=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==pe||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:pe,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=pe,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==p||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=p,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==b||e[66]!==i||e[67]!==v||e[68]!==p||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:b.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&b.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),b.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:b.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=b,e[66]=i,e[67]=v,e[68]=p,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Xt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as J}from"./chunk-
|
|
1
|
+
import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as J}from"./chunk-MW53Q7VM.js";import"./chunk-ULIQFBZU.js";import"./chunk-GCK3ETRI.js";import"./chunk-35DM4JJG.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as z}from"./chunk-UFIIJHJT.js";import"./chunk-YUZWAZ35.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as E}from"./chunk-FKVZRPV5.js";import{a as G,b as M,c as U,d as P,e as d,f as c}from"./chunk-HEAQVSNS.js";import{a as D,e as _}from"./chunk-WUWBZPUK.js";import{d as q}from"./chunk-FODLDLE2.js";import{a as S,d as O,f as Q,g as V}from"./chunk-YKXDMIHQ.js";var L=O(Q(),1);var r=O(V(),1);var K=["read","insert","update","delete"],B=S((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"z"),W=S(e=>{let s=new Map;for(let a of e){let t=s.get(a.table)??{operations:new Set,procedures:new Set,table:a.table};t.operations.add(a.on),t.procedures.add(a.procedure),s.set(a.table,t)}return[...s.values()].toSorted((a,t)=>a.table.localeCompare(t.table))},"J"),ie=S(()=>{let e=(0,L.c)(49),s=q(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:t,error:R,errorSource:k}=z(H.rlsPolicies,a),p=t!==void 0,m,n,h,l,f,u,x,b,o;if(e[1]!==t||e[2]!==R||e[3]!==k||e[4]!==p||e[5]!==s){let $=W(Array.isArray(t?.policies)?t.policies:[]),j;e[15]!==t?(j=Array.isArray(t?.roles)?t.roles:[],e[15]=t,e[16]=j):j=e[16],n=j,x="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==R||e[18]!==k?(o=R!==null&&(0,r.jsx)(J,{error:k,testId:"rls-error"}),e[17]=R,e[18]=k,e[19]=o):o=e[19],u="flex flex-col gap-2",m=D,h="overflow-hidden py-0";let I;e[20]!==s?(I=s("Policies"),e[20]=s,e[21]=I):I=e[21],e[22]!==I?(l=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=l):l=e[23],f=p&&$.length===0?(0,r.jsx)(E,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Table")}),K.map(i=>(0,r.jsx)(d,{children:B(s,i)},i)),(0,r.jsx)(d,{children:s("Guarded by")})]})}),(0,r.jsx)(U,{children:$.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),K.map(F=>(0,r.jsx)(c,{children:i.operations.has(F)?(0,r.jsx)(C,{variant:"secondary",children:s("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},F)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:[...i.procedures].join(", ")})]},i.table))})]})}),e[1]=t,e[2]=R,e[3]=k,e[4]=p,e[5]=s,e[6]=m,e[7]=n,e[8]=h,e[9]=l,e[10]=f,e[11]=u,e[12]=x,e[13]=b,e[14]=o}else m=e[6],n=e[7],h=e[8],l=e[9],f=e[10],u=e[11],x=e[12],b=e[13],o=e[14];let N;e[24]!==m||e[25]!==h||e[26]!==l||e[27]!==f?(N=(0,r.jsxs)(m,{className:h,children:[l,f]}),e[24]=m,e[25]=h,e[26]=l,e[27]=f,e[28]=N):N=e[28];let g;e[29]!==u||e[30]!==N?(g=(0,r.jsx)("section",{className:u,children:N}),e[29]=u,e[30]=N,e[31]=g):g=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==s?(v=p&&n.length===0?(0,r.jsx)(E,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Role")}),(0,r.jsx)(d,{children:s("Description")}),(0,r.jsx)(d,{children:s("Permissions")})]})}),(0,r.jsx)(U,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=s,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let T;return e[43]!==A||e[44]!==x||e[45]!==b||e[46]!==o||e[47]!==g?(T=(0,r.jsxs)("div",{className:x,"data-testid":b,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=b,e[46]=o,e[47]=g,e[48]=T):T=e[48],T},"oe");function X(e){return(0,r.jsx)(C,{variant:"outline",children:e},e)}S(X,"K");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}S(Y,"V");export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as c}from"./chunk-
|
|
1
|
+
import{b as c}from"./chunk-UFIIJHJT.js";import{f as l}from"./chunk-YUZWAZ35.js";import{a as r,d as f,f as g}from"./chunk-YKXDMIHQ.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,inviteOnly:!1,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},h=r(()=>{let a=(0,m.c)(6),s=l(),o;a[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],a[0]=o):o=a[0];let e;a[1]!==s?(e=r(()=>s.getAuthConfig(),"t"),a[1]=s,a[2]=e):e=a[2];let{data:u,isLoading:d}=c(o,e),t=u??p,n=!d,i;return a[3]!==t||a[4]!==n?(i={config:t,ready:n},a[3]=t,a[4]=n,a[5]=i):i=a[5],i},"b");export{p as a,h as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as q}from"./chunk-66UGPQVC.js";import{a as F}from"./chunk-S3CRZLGS.js";import{a as D}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as S}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as L}from"./chunk-
|
|
1
|
+
import{a as q}from"./chunk-66UGPQVC.js";import{a as F}from"./chunk-S3CRZLGS.js";import{a as D}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as S}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as L}from"./chunk-MW53Q7VM.js";import"./chunk-ULIQFBZU.js";import"./chunk-GCK3ETRI.js";import"./chunk-35DM4JJG.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-UFIIJHJT.js";import"./chunk-YUZWAZ35.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as $}from"./chunk-FKVZRPV5.js";import{a as O,b as P,c as W,d as C,e as h,f as p}from"./chunk-HEAQVSNS.js";import{a as M,e as T}from"./chunk-WUWBZPUK.js";import{d as A,m as E}from"./chunk-FODLDLE2.js";import{a as N,d as j,f as H,g as U}from"./chunk-YKXDMIHQ.js";var R=j(H(),1);var t=j(U(),1);var J=80,Z=N(a=>{if(a===void 0)return"";let e=JSON.stringify(a,E);return e.length>J?`${e.slice(0,J)}\u2026`:e},"G"),z=N(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((l,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:l})})}return e},"J"),w=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),ce=N(a=>{let e=(0,R.c)(22),{initialShardKey:r}=a,n=A(),{queryShardKey:l,setShardKey:i,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==l?(b={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=b):b=e[2];let{data:s,error:o,errorSource:u,refetch:G}=_(B.listSubscriptions,f,b);q(G,!0);let x;if(e[3]!==o||e[4]!==u||e[5]!==s||e[6]!==i||e[7]!==m||e[8]!==n){let k=s===void 0?[]:z(s.connections),c;e[10]!==i||e[11]!==m?(c=(0,t.jsx)(D,{onChange:i,testId:"subs-shard-input",value:m}),e[10]=i,e[11]=m,e[12]=c):c=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(S,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(S,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==c||e[17]!==d?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[16]=c,e[17]=d,e[18]=g):g=e[18];let v;e[19]!==o||e[20]!==u?(v=o!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=o,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,o===null&&s!==void 0&&k.length===0&&(0,t.jsx)($,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("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:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),o===null&&k.length>0&&(0,t.jsx)(M,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(C,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(W,{children:k.map(y=>{let{subscription:I}=y,K=Z(I?.args);return(0,t.jsxs)(C,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&(0,t.jsx)(S,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??w}),(0,t.jsx)(p,{children:I?.table??w}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||w})]},y.key)})})]})})})]}),e[3]=o,e[4]=u,e[5]=s,e[6]=i,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"ae");export{ce as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as R}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as B}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as S}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as q}from"./chunk-
|
|
1
|
+
import{W as R}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as B}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as S}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as q}from"./chunk-MW53Q7VM.js";import"./chunk-ULIQFBZU.js";import"./chunk-GCK3ETRI.js";import"./chunk-35DM4JJG.js";import{a as U}from"./chunk-4ZEL6BYL.js";import{c as O}from"./chunk-UFIIJHJT.js";import"./chunk-YUZWAZ35.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as D}from"./chunk-FKVZRPV5.js";import{a as G,b as J,c as K,d as F,e as s,f as o}from"./chunk-HEAQVSNS.js";import{a as V,e as W}from"./chunk-WUWBZPUK.js";import{d as P,r as H}from"./chunk-FODLDLE2.js";import{a as n,d as j,e as re,f as ae,g as ie}from"./chunk-YKXDMIHQ.js";var X=j(ae(),1),M=j(re(),1);var t=j(ie(),1);var ne=n(e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary","te"),Q=n(e=>e.endpoint??e.id,"M"),ve=n(()=>{let e=(0,X.c)(38),r=P(),[i,Y]=(0,M.useState)("all"),[l,Z]=(0,M.useState)(""),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let{data:I,error:d,errorSource:x,isLoading:_,refetch:v}=O(U.listPushSubscriptions,g),N;if(e[1]!==I?.subscriptions||e[2]!==d||e[3]!==x||e[4]!==_||e[5]!==i||e[6]!==v||e[7]!==l||e[8]!==r){let L=I?.subscriptions??[],T=l.trim().toLowerCase(),A=L.filter(a=>i!=="all"&&a.kind!==i?!1:T===""?!0:`${Q(a)} ${a.userId??""}`.toLowerCase().includes(T)),b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=n(a=>{Z(a.target.value)},"w"),e[10]=b):b=e[10];let ee=b,w;e[11]!==v?(w=n(()=>{v()},"y"),e[11]=v,e[12]=w):w=e[12];let E=w,k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=["all","web-push","fcm"],e[13]=k):k=e[13];let te=k,c;e[14]!==i||e[15]!==r?(c=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:te.map(a=>(0,t.jsx)(B,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:n(()=>{Y(a)},"onClick"),role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[14]=i,e[15]=r,e[16]=c):c=e[16];let m;e[17]!==r?(m=r("Filter devices"),e[17]=r,e[18]=m):m=e[18];let h;e[19]!==r?(h=r("filter endpoint, user"),e[19]=r,e[20]=h):h=e[20];let u;e[21]!==l||e[22]!==m||e[23]!==h?(u=(0,t.jsx)(R,{"aria-label":m,className:"h-8 w-56","data-testid":"nt-search",onChange:ee,placeholder:h,value:l}),e[21]=l,e[22]=m,e[23]=h,e[24]=u):u=e[24];let f;e[25]!==r?(f=r("Refresh"),e[25]=r,e[26]=f):f=e[26];let p;e[27]!==E||e[28]!==f?(p=(0,t.jsx)(B,{className:"ml-auto","data-testid":"nt-refresh",onClick:E,size:"sm",type:"button",variant:"outline",children:f}),e[27]=E,e[28]=f,e[29]=p):p=e[29];let $=L.length>0&&(0,t.jsx)(S,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:L.length})}),y;e[30]!==p||e[31]!==$||e[32]!==c||e[33]!==u?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p,$]}),e[30]=p,e[31]=$,e[32]=c,e[33]=u,e[34]=y):y=e[34];let C;e[35]!==d||e[36]!==x?(C=d!==null&&(0,t.jsx)(q,{error:x,testId:"nt-error"}),e[35]=d,e[36]=x,e[37]=C):C=e[37],N=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[y,C,d===null&&!_&&A.length===0&&(0,t.jsx)(D,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:(0,t.jsx)("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:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&(0,t.jsx)(V,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"nt-table",children:[(0,t.jsx)(J,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(s,{children:r("kind")}),(0,t.jsx)(s,{children:r("endpoint")}),(0,t.jsx)(s,{children:r("user")}),(0,t.jsx)(s,{children:r("last seen")}),(0,t.jsx)(s,{children:r("status")}),(0,t.jsx)(s,{children:r("error")})]})}),(0,t.jsx)(K,{children:A.map(a=>{let z=Q(a);return(0,t.jsxs)(F,{"data-testid":"nt-row",children:[(0,t.jsx)(o,{children:(0,t.jsx)(S,{variant:"outline",children:a.kind})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs",title:z,children:z}),(0,t.jsx)(o,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(o,{className:"text-muted-foreground tabular-nums",children:H(a.lastSeenAt,"\u2014")}),(0,t.jsx)(o,{children:(0,t.jsx)(S,{"data-testid":`nt-status-${a.id}`,variant:ne(a.lastStatus),children:a.lastStatus??r("n/a")})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.id)})})]})})})]}),e[1]=I?.subscriptions,e[2]=d,e[3]=x,e[4]=_,e[5]=i,e[6]=v,e[7]=l,e[8]=r,e[9]=N}else N=e[9];return N},"ge");export{ve as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ve}from"./chunk-2URQKGWU.js";import"./chunk-4JLGLPWV.js";import{a as He}from"./chunk-EA2JKR5D.js";import{a as Ke}from"./chunk-66UGPQVC.js";import"./chunk-3Q2P62UR.js";import{a as Ge}from"./chunk-PD6WIDY6.js";import{W as je}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as le}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as de}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Pe}from"./chunk-4POCWNXY.js";import{a as Ue}from"./chunk-ULIQFBZU.js";import"./chunk-GUPNWYY4.js";import"./chunk-35DM4JJG.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as Me}from"./chunk-AZVN24IA.js";import{f as We}from"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as ie}from"./chunk-FKVZRPV5.js";import{a as _e,b as Be,c as ke,d as G,e as C,f as w}from"./chunk-HEAQVSNS.js";import{a as Te,e as De}from"./chunk-WUWBZPUK.js";import{d as $,f as ue,g as ce,h as me,o as he,r as ze}from"./chunk-FODLDLE2.js";import{a as h,d as Ee,e as rt,f as nt,g as ot}from"./chunk-YKXDMIHQ.js";var W=Ee(nt(),1);var A=Ee(rt(),1);var t=Ee(ot(),1);var dt=h((n,e)=>{let a=new Set(n.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),i=n.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!a.has(s.name)),d=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:d,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||d>0}},"rt"),lt=200,it=ue(F.sendQueueMessage),ut=ue(F.replayQueueMessage),ct=ue(F.clearQueueMessages),Xe=96,mt=h(n=>{if(n===void 0)return"\u2014";try{return JSON.stringify(n)}catch{return"[unserializable]"}},"it"),ht=h(n=>n.length>Xe?`${n.slice(0,Xe)}\u2026`:n,"ct"),pt=h(n=>n==="error"?"destructive":n==="retry"?"outline":"secondary","ut"),gt=h((n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),"mt"),ft=h(n=>{let e=(0,W.c)(11),{loaded:a,queues:i}=n,d=$(),s;e[0]!==d?(s=d("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=d,e[1]=s):s=e[1];let o;e[2]!==s?(o=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let r;e[4]!==a||e[5]!==i||e[6]!==d?(r=a&&i.length===0?(0,t.jsx)(ie,{description:d("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:d("No queues defined")}):(0,t.jsx)(Te,{className:"overflow-hidden py-0",children:(0,t.jsx)(De,{className:"px-0",children:(0,t.jsxs)(_e,{"data-testid":"queues-table",children:[(0,t.jsx)(Be,{children:(0,t.jsxs)(G,{children:[(0,t.jsx)(C,{children:d("Export")}),(0,t.jsx)(C,{children:d("Queue")}),(0,t.jsx)(C,{children:d("Mode")}),(0,t.jsx)(C,{children:d("Binding")}),(0,t.jsx)(C,{children:d("Dead-letter")})]})}),(0,t.jsx)(ke,{children:i.map(bt)})]})})}),e[4]=a,e[5]=i,e[6]=d,e[7]=r):r=e[7];let p;return e[8]!==o||e[9]!==r?(p=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,r]}),e[8]=o,e[9]=r,e[10]=p):p=e[10],p},"ft"),xt=h(n=>{let e=(0,W.c)(67),{message:a,onReplay:i,replayingId:d}=n,s=$(),o,r,p,c,x,N,y,l,m,f;if(e[0]!==a.attempts||e[1]!==a.body||e[2]!==a.deadLettered||e[3]!==a.exportName||e[4]!==a.id||e[5]!==a.messageId||e[6]!==a.outcome||e[7]!==a.queue||e[8]!==s){let j=mt(a.body);r=G,N=`queues-message-${a.id}`;let z=a.exportName??a.queue;e[19]!==z?(y=(0,t.jsx)(w,{className:"font-mono text-xs",children:z}),e[19]=z,e[20]=y):y=e[20],e[21]!==a.messageId?(l=(0,t.jsx)(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:a.messageId,children:a.messageId}),e[21]=a.messageId,e[22]=l):l=e[22],e[23]!==a.attempts?(m=(0,t.jsx)(w,{className:"font-mono text-xs tabular-nums",children:a.attempts}),e[23]=a.attempts,e[24]=m):m=e[24];let T=`queues-outcome-${a.id}`,D;e[25]!==a.outcome?(D=pt(a.outcome),e[25]=a.outcome,e[26]=D):D=e[26];let I;e[27]!==a.outcome||e[28]!==T||e[29]!==D?(I=(0,t.jsx)(de,{"data-testid":T,variant:D,children:a.outcome}),e[27]=a.outcome,e[28]=T,e[29]=D,e[30]=I):I=e[30];let M;e[31]!==a.deadLettered||e[32]!==a.id||e[33]!==s?(M=a.deadLettered&&(0,t.jsx)(de,{"data-testid":`queues-dlq-${a.id}`,variant:"destructive",children:s("DLQ")}),e[31]=a.deadLettered,e[32]=a.id,e[33]=s,e[34]=M):M=e[34],e[35]!==I||e[36]!==M?(f=(0,t.jsx)(w,{children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[I,M]})}),e[35]=I,e[36]=M,e[37]=f):f=e[37],o=w,p="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=j,x=ht(j),e[0]=a.attempts,e[1]=a.body,e[2]=a.deadLettered,e[3]=a.exportName,e[4]=a.id,e[5]=a.messageId,e[6]=a.outcome,e[7]=a.queue,e[8]=s,e[9]=o,e[10]=r,e[11]=p,e[12]=c,e[13]=x,e[14]=N,e[15]=y,e[16]=l,e[17]=m,e[18]=f}else o=e[9],r=e[10],p=e[11],c=e[12],x=e[13],N=e[14],y=e[15],l=e[16],m=e[17],f=e[18];let g;e[38]!==o||e[39]!==p||e[40]!==c||e[41]!==x?(g=(0,t.jsx)(o,{className:p,title:c,children:x}),e[38]=o,e[39]=p,e[40]=c,e[41]=x,e[42]=g):g=e[42];let q;e[43]!==a.capturedAt?(q=ze(a.capturedAt,"\u2014"),e[43]=a.capturedAt,e[44]=q):q=e[44];let b;e[45]!==q?(b=(0,t.jsx)(w,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=b):b=e[46];let S=`queues-replay-${a.id}`,E=d!==null,Q;e[47]!==a.id||e[48]!==d||e[49]!==s?(Q=d===a.id?s("Replaying\u2026"):s("Replay"),e[47]=a.id,e[48]=d,e[49]=s,e[50]=Q):Q=e[50];let L;e[51]!==a.id||e[52]!==i||e[53]!==S||e[54]!==E||e[55]!==Q?(L=(0,t.jsx)(w,{children:(0,t.jsx)(le,{"data-id":a.id,"data-testid":S,disabled:E,onClick:i,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=a.id,e[52]=i,e[53]=S,e[54]=E,e[55]=Q,e[56]=L):L=e[56];let _;return e[57]!==r||e[58]!==b||e[59]!==L||e[60]!==N||e[61]!==y||e[62]!==l||e[63]!==m||e[64]!==f||e[65]!==g?(_=(0,t.jsxs)(r,{"data-testid":N,children:[y,l,m,f,g,b,L]}),e[57]=r,e[58]=b,e[59]=L,e[60]=N,e[61]=y,e[62]=l,e[63]=m,e[64]=f,e[65]=g,e[66]=_):_=e[66],_},"ht"),yt=h(n=>{let e=(0,W.c)(29),{hasError:a,messages:i,onClear:d,onReplay:s,replayingId:o}=n,r=$(),p;e[0]!==r?(p=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=r,e[1]=p):p=e[1];let c;e[2]!==p?(c=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=c):c=e[3];let x;e[4]!==r?(x=r("Clear the whole message log?"),e[4]=r,e[5]=x):x=e[5];let N=i.length===0,y;e[6]!==r?(y=r("Clear log"),e[6]=r,e[7]=y):y=e[7];let l;e[8]!==d||e[9]!==x||e[10]!==N||e[11]!==y?(l=(0,t.jsx)("div",{className:"ml-auto",children:(0,t.jsx)(Ge,{confirmLabel:x,disabled:N,onConfirm:d,testId:"queues-clear",children:y})}),e[8]=d,e[9]=x,e[10]=N,e[11]=y,e[12]=l):l=e[12];let m;e[13]!==i.length||e[14]!==r?(m=i.length>0&&(0,t.jsx)(de,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=r,e[15]=m):m=e[15];let f;e[16]!==c||e[17]!==l||e[18]!==m?(f=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,l,m]}),e[16]=c,e[17]=l,e[18]=m,e[19]=f):f=e[19];let g;e[20]!==a||e[21]!==i||e[22]!==s||e[23]!==o||e[24]!==r?(g=!a&&i.length===0?(0,t.jsx)(ie,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")}):(0,t.jsx)(Te,{className:"overflow-hidden py-0",children:(0,t.jsx)(De,{className:"px-0",children:(0,t.jsx)(Ve,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxs)(_e,{"data-testid":"queues-messages-table",children:[(0,t.jsx)(Be,{children:(0,t.jsxs)(G,{children:[(0,t.jsx)(C,{children:r("Export")}),(0,t.jsx)(C,{children:r("Message")}),(0,t.jsx)(C,{children:r("Attempts")}),(0,t.jsx)(C,{children:r("Outcome")}),(0,t.jsx)(C,{children:r("Body")}),(0,t.jsx)(C,{children:r("Captured")}),(0,t.jsx)(C,{})]})}),(0,t.jsx)(ke,{children:i.map(b=>(0,t.jsx)(xt,{message:b,onReplay:s,replayingId:o},b.id))})]})})})}),e[20]=a,e[21]=i,e[22]=s,e[23]=o,e[24]=r,e[25]=g):g=e[25];let q;return e[26]!==f||e[27]!==g?(q=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[f,g]}),e[26]=f,e[27]=g,e[28]=q):q=e[28],q},"pt"),Nt=h(n=>{let e=(0,W.c)(20),{batchMode:a,bodyText:i,delayText:d,onBatchModeChange:s,onBodyChange:o,onDelayChange:r,onSelectExport:p,onSend:c,queues:x,selectedExportName:N,sending:y}=n,l=$(),m;e[0]!==l?(m=l("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=l,e[1]=m):m=e[1];let f;e[2]!==m?(f=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=f):f=e[3];let g;e[4]!==a||e[5]!==i||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==r||e[10]!==p||e[11]!==c||e[12]!==x||e[13]!==N||e[14]!==y||e[15]!==l?(g=x.length===0?(0,t.jsx)(ie,{description:l("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:l("No queues to send to")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("select",{"aria-label":l("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:p,value:N,children:x.map(qt)}),(0,t.jsx)(je,{"aria-label":l("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:l("Delay (s)"),type:"number",value:d}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsx)("input",{checked:a,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),l("Send as batch (JSON array)")]}),(0,t.jsx)(le,{className:"ml-auto","data-testid":"queues-send-button",disabled:y||N==="",onClick:c,type:"button",children:l(y?"Sending\u2026":"Send message")})]}),(0,t.jsx)(He,{"aria-label":l("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:a?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=a,e[5]=i,e[6]=d,e[7]=s,e[8]=o,e[9]=r,e[10]=p,e[11]=c,e[12]=x,e[13]=N,e[14]=y,e[15]=l,e[16]=g):g=e[16];let q;return e[17]!==f||e[18]!==g?(q=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[f,g]}),e[17]=f,e[18]=g,e[19]=q):q=e[19],q},"gt"),Ft=h(n=>{let e=(0,W.c)(59),{limit:a}=n,i=a??lt,d=We(),s=$(),[o,r]=(0,A.useState)("declared"),[p,c]=(0,A.useState)(null),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];let{data:N,error:y,errorSource:l}=Me(F.listQueues,x),m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];let{data:f,error:g,errorSource:q,refetch:b}=Me(F.getQueueMessages,m),S=Array.isArray(N?.queues)?[...N.queues].toSorted(vt):[],E=f?.entries??[],{deadLetteredCount:Q,queuesWithoutDlq:L,showReliabilityWarning:_}=dt(S,E),[j,z]=(0,A.useState)(""),[T,D]=(0,A.useState)(""),[I,M]=(0,A.useState)(""),[U,Ye]=(0,A.useState)(!1),[pe,Oe]=(0,A.useState)(!1),[ge,Re]=(0,A.useState)(null),H=S.some(u=>u.exportName===j)?j:S[0]?.exportName??"",Je=o==="messages"?g:y,Ze=o==="messages"?q:l,fe=Je??p,xe=Je===null?p:Ze,K;e[3]!==b?(K=h(()=>{b()},"H"),e[3]=b,e[4]=K):K=e[4],Ke(K,o==="messages");let ye=h(async()=>{c(null);let u=H;if(u==="")return;let v=null,$e=T.trim();if($e!=="")try{v=JSON.parse($e)}catch{c(s("Body must be valid JSON."));return}let Ae,Fe=I.trim();if(Fe!==""){let P=Number(Fe);if(!Number.isFinite(P)||P<0){c(s("Delay must be a non-negative number of seconds."));return}Ae=P}if(U&&!Array.isArray(v)){c(s("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}Oe(!0);let st=U?{batch:v,delaySeconds:Ae,exportName:u}:{body:v,delaySeconds:Ae,exportName:u};try{await d.query(it,st,ce("")),b()}catch(P){c(me(P))}Oe(!1)},"ue"),V;e[5]!==d||e[6]!==b?(V=h(async u=>{c(null),Re(u);try{await d.query(ut,{id:u},ce("")),b()}catch(v){c(me(v))}Re(null)},"V"),e[5]=d,e[6]=b,e[7]=V):V=e[7];let Ne=V,X;e[8]!==d||e[9]!==b?(X=h(async()=>{c(null);try{await d.query(ct,{},ce("")),b()}catch(u){c(me(u))}},"Y"),e[8]=d,e[9]=b,e[10]=X):X=e[10];let be=X,Y;e[11]===Symbol.for("react.memo_cache_sentinel")?(Y=h(u=>{let v=u.currentTarget.dataset.tab;(v==="declared"||v==="messages"||v==="send")&&r(v)},"X"),e[11]=Y):Y=e[11];let et=Y,Z;e[12]===Symbol.for("react.memo_cache_sentinel")?(Z=h(u=>{z(u.currentTarget.value)},"K"),e[12]=Z):Z=e[12];let qe=Z,ee;e[13]===Symbol.for("react.memo_cache_sentinel")?(ee=h(u=>{D(u.currentTarget.value)},"Z"),e[13]=ee):ee=e[13];let ve=ee,te;e[14]===Symbol.for("react.memo_cache_sentinel")?(te=h(u=>{M(u.currentTarget.value)},"ee"),e[14]=te):te=e[14];let Se=te,ae;e[15]===Symbol.for("react.memo_cache_sentinel")?(ae=h(u=>{Ye(u.currentTarget.checked)},"te"),e[15]=ae):ae=e[15];let Ce=ae,se;e[16]!==ye?(se=h(()=>{he(ye())},"se"),e[16]=ye,e[17]=se):se=e[17];let we=se,re;e[18]!==Ne?(re=h(u=>{let{id:v}=u.currentTarget.dataset;v!==void 0&&he(Ne(v))},"ae"),e[18]=Ne,e[19]=re):re=e[19];let Ie=re,ne;e[20]!==be?(ne=h(()=>{he(be())},"re"),e[20]=be,e[21]=ne):ne=e[21];let Qe=ne,tt="flex flex-col gap-6",at="lunora-queues-panel",B;e[22]!==s||e[23]!==o?(B=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(u=>(0,t.jsx)(le,{"aria-selected":o===u,"data-tab":u,"data-testid":`queues-tab-${u}`,onClick:et,role:"tab",size:"sm",type:"button",variant:o===u?"secondary":"ghost",children:gt(u,s)},u))}),e[22]=s,e[23]=o,e[24]=B):B=e[24];let k;e[25]!==fe||e[26]!==xe?(k=fe!==null&&(0,t.jsx)(Pe,{error:xe,testId:"queues-error"}),e[25]=fe,e[26]=xe,e[27]=k):k=e[27];let Le=_&&(0,t.jsx)(Ue,{icon:(0,t.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"}),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[L.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:L.map(St).join(", ")})}),(0,t.jsx)("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),Q>0&&(0,t.jsx)("p",{className:L.length>0?"text-muted-foreground":"font-medium",children:Q===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:Q})})]})}),O;e[28]!==S||e[29]!==N||e[30]!==o?(O=o==="declared"&&(0,t.jsx)(ft,{loaded:N!==void 0,queues:S}),e[28]=S,e[29]=N,e[30]=o,e[31]=O):O=e[31];let R;e[32]!==E||e[33]!==g||e[34]!==Qe||e[35]!==Ie||e[36]!==ge||e[37]!==o?(R=o==="messages"&&(0,t.jsx)(yt,{hasError:g!==null,messages:E,onClear:Qe,onReplay:Ie,replayingId:ge}),e[32]=E,e[33]=g,e[34]=Qe,e[35]=Ie,e[36]=ge,e[37]=o,e[38]=R):R=e[38];let J;e[39]!==U||e[40]!==T||e[41]!==I||e[42]!==Ce||e[43]!==ve||e[44]!==Se||e[45]!==qe||e[46]!==we||e[47]!==S||e[48]!==H||e[49]!==pe||e[50]!==o?(J=o==="send"&&(0,t.jsx)(Nt,{batchMode:U,bodyText:T,delayText:I,onBatchModeChange:Ce,onBodyChange:ve,onDelayChange:Se,onSelectExport:qe,onSend:we,queues:S,selectedExportName:H,sending:pe}),e[39]=U,e[40]=T,e[41]=I,e[42]=Ce,e[43]=ve,e[44]=Se,e[45]=qe,e[46]=we,e[47]=S,e[48]=H,e[49]=pe,e[50]=o,e[51]=J):J=e[51];let oe;return e[52]!==B||e[53]!==k||e[54]!==Le||e[55]!==O||e[56]!==R||e[57]!==J?(oe=(0,t.jsxs)("div",{className:tt,"data-testid":at,children:[B,k,Le,O,R,J]}),e[52]=B,e[53]=k,e[54]=Le,e[55]=O,e[56]=R,e[57]=J,e[58]=oe):oe=e[58],oe},"Ft");function bt(n){return(0,t.jsxs)(G,{"data-testid":`queues-row-${n.exportName}`,children:[(0,t.jsx)(w,{className:"font-mono text-xs",children:n.exportName}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.name}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.mode}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.binding}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.deadLetterQueue??"\u2014"})]},n.exportName)}h(bt,"xt");function qt(n){return(0,t.jsx)("option",{value:n.exportName,children:n.exportName},n.exportName)}h(qt,"yt");function vt(n,e){return n.exportName.localeCompare(e.exportName)}h(vt,"bt");function St(n){return n.name}h(St,"Nt");export{Ft as default};
|
|
1
|
+
import{a as Ve}from"./chunk-2URQKGWU.js";import"./chunk-4JLGLPWV.js";import{a as He}from"./chunk-EA2JKR5D.js";import{a as Ke}from"./chunk-66UGPQVC.js";import"./chunk-3Q2P62UR.js";import{a as Ge}from"./chunk-PD6WIDY6.js";import{W as je}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as le}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as de}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Pe}from"./chunk-MW53Q7VM.js";import{a as Ue}from"./chunk-ULIQFBZU.js";import"./chunk-GCK3ETRI.js";import"./chunk-35DM4JJG.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as Me}from"./chunk-UFIIJHJT.js";import{f as We}from"./chunk-YUZWAZ35.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as ie}from"./chunk-FKVZRPV5.js";import{a as _e,b as Be,c as ke,d as G,e as C,f as w}from"./chunk-HEAQVSNS.js";import{a as Te,e as De}from"./chunk-WUWBZPUK.js";import{d as $,f as ue,g as ce,h as me,o as he,r as ze}from"./chunk-FODLDLE2.js";import{a as h,d as Ee,e as rt,f as nt,g as ot}from"./chunk-YKXDMIHQ.js";var W=Ee(nt(),1);var A=Ee(rt(),1);var t=Ee(ot(),1);var dt=h((n,e)=>{let a=new Set(n.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),i=n.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!a.has(s.name)),d=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:d,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||d>0}},"rt"),lt=200,it=ue(F.sendQueueMessage),ut=ue(F.replayQueueMessage),ct=ue(F.clearQueueMessages),Xe=96,mt=h(n=>{if(n===void 0)return"\u2014";try{return JSON.stringify(n)}catch{return"[unserializable]"}},"it"),ht=h(n=>n.length>Xe?`${n.slice(0,Xe)}\u2026`:n,"ct"),pt=h(n=>n==="error"?"destructive":n==="retry"?"outline":"secondary","ut"),gt=h((n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),"mt"),ft=h(n=>{let e=(0,W.c)(11),{loaded:a,queues:i}=n,d=$(),s;e[0]!==d?(s=d("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=d,e[1]=s):s=e[1];let o;e[2]!==s?(o=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let r;e[4]!==a||e[5]!==i||e[6]!==d?(r=a&&i.length===0?(0,t.jsx)(ie,{description:d("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:d("No queues defined")}):(0,t.jsx)(Te,{className:"overflow-hidden py-0",children:(0,t.jsx)(De,{className:"px-0",children:(0,t.jsxs)(_e,{"data-testid":"queues-table",children:[(0,t.jsx)(Be,{children:(0,t.jsxs)(G,{children:[(0,t.jsx)(C,{children:d("Export")}),(0,t.jsx)(C,{children:d("Queue")}),(0,t.jsx)(C,{children:d("Mode")}),(0,t.jsx)(C,{children:d("Binding")}),(0,t.jsx)(C,{children:d("Dead-letter")})]})}),(0,t.jsx)(ke,{children:i.map(bt)})]})})}),e[4]=a,e[5]=i,e[6]=d,e[7]=r):r=e[7];let p;return e[8]!==o||e[9]!==r?(p=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,r]}),e[8]=o,e[9]=r,e[10]=p):p=e[10],p},"ft"),xt=h(n=>{let e=(0,W.c)(67),{message:a,onReplay:i,replayingId:d}=n,s=$(),o,r,p,c,x,N,y,l,m,f;if(e[0]!==a.attempts||e[1]!==a.body||e[2]!==a.deadLettered||e[3]!==a.exportName||e[4]!==a.id||e[5]!==a.messageId||e[6]!==a.outcome||e[7]!==a.queue||e[8]!==s){let j=mt(a.body);r=G,N=`queues-message-${a.id}`;let z=a.exportName??a.queue;e[19]!==z?(y=(0,t.jsx)(w,{className:"font-mono text-xs",children:z}),e[19]=z,e[20]=y):y=e[20],e[21]!==a.messageId?(l=(0,t.jsx)(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:a.messageId,children:a.messageId}),e[21]=a.messageId,e[22]=l):l=e[22],e[23]!==a.attempts?(m=(0,t.jsx)(w,{className:"font-mono text-xs tabular-nums",children:a.attempts}),e[23]=a.attempts,e[24]=m):m=e[24];let T=`queues-outcome-${a.id}`,D;e[25]!==a.outcome?(D=pt(a.outcome),e[25]=a.outcome,e[26]=D):D=e[26];let I;e[27]!==a.outcome||e[28]!==T||e[29]!==D?(I=(0,t.jsx)(de,{"data-testid":T,variant:D,children:a.outcome}),e[27]=a.outcome,e[28]=T,e[29]=D,e[30]=I):I=e[30];let M;e[31]!==a.deadLettered||e[32]!==a.id||e[33]!==s?(M=a.deadLettered&&(0,t.jsx)(de,{"data-testid":`queues-dlq-${a.id}`,variant:"destructive",children:s("DLQ")}),e[31]=a.deadLettered,e[32]=a.id,e[33]=s,e[34]=M):M=e[34],e[35]!==I||e[36]!==M?(f=(0,t.jsx)(w,{children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[I,M]})}),e[35]=I,e[36]=M,e[37]=f):f=e[37],o=w,p="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=j,x=ht(j),e[0]=a.attempts,e[1]=a.body,e[2]=a.deadLettered,e[3]=a.exportName,e[4]=a.id,e[5]=a.messageId,e[6]=a.outcome,e[7]=a.queue,e[8]=s,e[9]=o,e[10]=r,e[11]=p,e[12]=c,e[13]=x,e[14]=N,e[15]=y,e[16]=l,e[17]=m,e[18]=f}else o=e[9],r=e[10],p=e[11],c=e[12],x=e[13],N=e[14],y=e[15],l=e[16],m=e[17],f=e[18];let g;e[38]!==o||e[39]!==p||e[40]!==c||e[41]!==x?(g=(0,t.jsx)(o,{className:p,title:c,children:x}),e[38]=o,e[39]=p,e[40]=c,e[41]=x,e[42]=g):g=e[42];let q;e[43]!==a.capturedAt?(q=ze(a.capturedAt,"\u2014"),e[43]=a.capturedAt,e[44]=q):q=e[44];let b;e[45]!==q?(b=(0,t.jsx)(w,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=b):b=e[46];let S=`queues-replay-${a.id}`,E=d!==null,Q;e[47]!==a.id||e[48]!==d||e[49]!==s?(Q=d===a.id?s("Replaying\u2026"):s("Replay"),e[47]=a.id,e[48]=d,e[49]=s,e[50]=Q):Q=e[50];let L;e[51]!==a.id||e[52]!==i||e[53]!==S||e[54]!==E||e[55]!==Q?(L=(0,t.jsx)(w,{children:(0,t.jsx)(le,{"data-id":a.id,"data-testid":S,disabled:E,onClick:i,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=a.id,e[52]=i,e[53]=S,e[54]=E,e[55]=Q,e[56]=L):L=e[56];let _;return e[57]!==r||e[58]!==b||e[59]!==L||e[60]!==N||e[61]!==y||e[62]!==l||e[63]!==m||e[64]!==f||e[65]!==g?(_=(0,t.jsxs)(r,{"data-testid":N,children:[y,l,m,f,g,b,L]}),e[57]=r,e[58]=b,e[59]=L,e[60]=N,e[61]=y,e[62]=l,e[63]=m,e[64]=f,e[65]=g,e[66]=_):_=e[66],_},"ht"),yt=h(n=>{let e=(0,W.c)(29),{hasError:a,messages:i,onClear:d,onReplay:s,replayingId:o}=n,r=$(),p;e[0]!==r?(p=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=r,e[1]=p):p=e[1];let c;e[2]!==p?(c=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=c):c=e[3];let x;e[4]!==r?(x=r("Clear the whole message log?"),e[4]=r,e[5]=x):x=e[5];let N=i.length===0,y;e[6]!==r?(y=r("Clear log"),e[6]=r,e[7]=y):y=e[7];let l;e[8]!==d||e[9]!==x||e[10]!==N||e[11]!==y?(l=(0,t.jsx)("div",{className:"ml-auto",children:(0,t.jsx)(Ge,{confirmLabel:x,disabled:N,onConfirm:d,testId:"queues-clear",children:y})}),e[8]=d,e[9]=x,e[10]=N,e[11]=y,e[12]=l):l=e[12];let m;e[13]!==i.length||e[14]!==r?(m=i.length>0&&(0,t.jsx)(de,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=r,e[15]=m):m=e[15];let f;e[16]!==c||e[17]!==l||e[18]!==m?(f=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,l,m]}),e[16]=c,e[17]=l,e[18]=m,e[19]=f):f=e[19];let g;e[20]!==a||e[21]!==i||e[22]!==s||e[23]!==o||e[24]!==r?(g=!a&&i.length===0?(0,t.jsx)(ie,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")}):(0,t.jsx)(Te,{className:"overflow-hidden py-0",children:(0,t.jsx)(De,{className:"px-0",children:(0,t.jsx)(Ve,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxs)(_e,{"data-testid":"queues-messages-table",children:[(0,t.jsx)(Be,{children:(0,t.jsxs)(G,{children:[(0,t.jsx)(C,{children:r("Export")}),(0,t.jsx)(C,{children:r("Message")}),(0,t.jsx)(C,{children:r("Attempts")}),(0,t.jsx)(C,{children:r("Outcome")}),(0,t.jsx)(C,{children:r("Body")}),(0,t.jsx)(C,{children:r("Captured")}),(0,t.jsx)(C,{})]})}),(0,t.jsx)(ke,{children:i.map(b=>(0,t.jsx)(xt,{message:b,onReplay:s,replayingId:o},b.id))})]})})})}),e[20]=a,e[21]=i,e[22]=s,e[23]=o,e[24]=r,e[25]=g):g=e[25];let q;return e[26]!==f||e[27]!==g?(q=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[f,g]}),e[26]=f,e[27]=g,e[28]=q):q=e[28],q},"pt"),Nt=h(n=>{let e=(0,W.c)(20),{batchMode:a,bodyText:i,delayText:d,onBatchModeChange:s,onBodyChange:o,onDelayChange:r,onSelectExport:p,onSend:c,queues:x,selectedExportName:N,sending:y}=n,l=$(),m;e[0]!==l?(m=l("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=l,e[1]=m):m=e[1];let f;e[2]!==m?(f=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=f):f=e[3];let g;e[4]!==a||e[5]!==i||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==r||e[10]!==p||e[11]!==c||e[12]!==x||e[13]!==N||e[14]!==y||e[15]!==l?(g=x.length===0?(0,t.jsx)(ie,{description:l("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:l("No queues to send to")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("select",{"aria-label":l("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:p,value:N,children:x.map(qt)}),(0,t.jsx)(je,{"aria-label":l("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:l("Delay (s)"),type:"number",value:d}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsx)("input",{checked:a,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),l("Send as batch (JSON array)")]}),(0,t.jsx)(le,{className:"ml-auto","data-testid":"queues-send-button",disabled:y||N==="",onClick:c,type:"button",children:l(y?"Sending\u2026":"Send message")})]}),(0,t.jsx)(He,{"aria-label":l("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:a?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=a,e[5]=i,e[6]=d,e[7]=s,e[8]=o,e[9]=r,e[10]=p,e[11]=c,e[12]=x,e[13]=N,e[14]=y,e[15]=l,e[16]=g):g=e[16];let q;return e[17]!==f||e[18]!==g?(q=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[f,g]}),e[17]=f,e[18]=g,e[19]=q):q=e[19],q},"gt"),Ft=h(n=>{let e=(0,W.c)(59),{limit:a}=n,i=a??lt,d=We(),s=$(),[o,r]=(0,A.useState)("declared"),[p,c]=(0,A.useState)(null),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];let{data:N,error:y,errorSource:l}=Me(F.listQueues,x),m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];let{data:f,error:g,errorSource:q,refetch:b}=Me(F.getQueueMessages,m),S=Array.isArray(N?.queues)?[...N.queues].toSorted(vt):[],E=f?.entries??[],{deadLetteredCount:Q,queuesWithoutDlq:L,showReliabilityWarning:_}=dt(S,E),[j,z]=(0,A.useState)(""),[T,D]=(0,A.useState)(""),[I,M]=(0,A.useState)(""),[U,Ye]=(0,A.useState)(!1),[pe,Oe]=(0,A.useState)(!1),[ge,Re]=(0,A.useState)(null),H=S.some(u=>u.exportName===j)?j:S[0]?.exportName??"",Je=o==="messages"?g:y,Ze=o==="messages"?q:l,fe=Je??p,xe=Je===null?p:Ze,K;e[3]!==b?(K=h(()=>{b()},"H"),e[3]=b,e[4]=K):K=e[4],Ke(K,o==="messages");let ye=h(async()=>{c(null);let u=H;if(u==="")return;let v=null,$e=T.trim();if($e!=="")try{v=JSON.parse($e)}catch{c(s("Body must be valid JSON."));return}let Ae,Fe=I.trim();if(Fe!==""){let P=Number(Fe);if(!Number.isFinite(P)||P<0){c(s("Delay must be a non-negative number of seconds."));return}Ae=P}if(U&&!Array.isArray(v)){c(s("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}Oe(!0);let st=U?{batch:v,delaySeconds:Ae,exportName:u}:{body:v,delaySeconds:Ae,exportName:u};try{await d.query(it,st,ce("")),b()}catch(P){c(me(P))}Oe(!1)},"ue"),V;e[5]!==d||e[6]!==b?(V=h(async u=>{c(null),Re(u);try{await d.query(ut,{id:u},ce("")),b()}catch(v){c(me(v))}Re(null)},"V"),e[5]=d,e[6]=b,e[7]=V):V=e[7];let Ne=V,X;e[8]!==d||e[9]!==b?(X=h(async()=>{c(null);try{await d.query(ct,{},ce("")),b()}catch(u){c(me(u))}},"Y"),e[8]=d,e[9]=b,e[10]=X):X=e[10];let be=X,Y;e[11]===Symbol.for("react.memo_cache_sentinel")?(Y=h(u=>{let v=u.currentTarget.dataset.tab;(v==="declared"||v==="messages"||v==="send")&&r(v)},"X"),e[11]=Y):Y=e[11];let et=Y,Z;e[12]===Symbol.for("react.memo_cache_sentinel")?(Z=h(u=>{z(u.currentTarget.value)},"K"),e[12]=Z):Z=e[12];let qe=Z,ee;e[13]===Symbol.for("react.memo_cache_sentinel")?(ee=h(u=>{D(u.currentTarget.value)},"Z"),e[13]=ee):ee=e[13];let ve=ee,te;e[14]===Symbol.for("react.memo_cache_sentinel")?(te=h(u=>{M(u.currentTarget.value)},"ee"),e[14]=te):te=e[14];let Se=te,ae;e[15]===Symbol.for("react.memo_cache_sentinel")?(ae=h(u=>{Ye(u.currentTarget.checked)},"te"),e[15]=ae):ae=e[15];let Ce=ae,se;e[16]!==ye?(se=h(()=>{he(ye())},"se"),e[16]=ye,e[17]=se):se=e[17];let we=se,re;e[18]!==Ne?(re=h(u=>{let{id:v}=u.currentTarget.dataset;v!==void 0&&he(Ne(v))},"ae"),e[18]=Ne,e[19]=re):re=e[19];let Ie=re,ne;e[20]!==be?(ne=h(()=>{he(be())},"re"),e[20]=be,e[21]=ne):ne=e[21];let Qe=ne,tt="flex flex-col gap-6",at="lunora-queues-panel",B;e[22]!==s||e[23]!==o?(B=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(u=>(0,t.jsx)(le,{"aria-selected":o===u,"data-tab":u,"data-testid":`queues-tab-${u}`,onClick:et,role:"tab",size:"sm",type:"button",variant:o===u?"secondary":"ghost",children:gt(u,s)},u))}),e[22]=s,e[23]=o,e[24]=B):B=e[24];let k;e[25]!==fe||e[26]!==xe?(k=fe!==null&&(0,t.jsx)(Pe,{error:xe,testId:"queues-error"}),e[25]=fe,e[26]=xe,e[27]=k):k=e[27];let Le=_&&(0,t.jsx)(Ue,{icon:(0,t.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"}),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[L.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:L.map(St).join(", ")})}),(0,t.jsx)("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),Q>0&&(0,t.jsx)("p",{className:L.length>0?"text-muted-foreground":"font-medium",children:Q===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:Q})})]})}),O;e[28]!==S||e[29]!==N||e[30]!==o?(O=o==="declared"&&(0,t.jsx)(ft,{loaded:N!==void 0,queues:S}),e[28]=S,e[29]=N,e[30]=o,e[31]=O):O=e[31];let R;e[32]!==E||e[33]!==g||e[34]!==Qe||e[35]!==Ie||e[36]!==ge||e[37]!==o?(R=o==="messages"&&(0,t.jsx)(yt,{hasError:g!==null,messages:E,onClear:Qe,onReplay:Ie,replayingId:ge}),e[32]=E,e[33]=g,e[34]=Qe,e[35]=Ie,e[36]=ge,e[37]=o,e[38]=R):R=e[38];let J;e[39]!==U||e[40]!==T||e[41]!==I||e[42]!==Ce||e[43]!==ve||e[44]!==Se||e[45]!==qe||e[46]!==we||e[47]!==S||e[48]!==H||e[49]!==pe||e[50]!==o?(J=o==="send"&&(0,t.jsx)(Nt,{batchMode:U,bodyText:T,delayText:I,onBatchModeChange:Ce,onBodyChange:ve,onDelayChange:Se,onSelectExport:qe,onSend:we,queues:S,selectedExportName:H,sending:pe}),e[39]=U,e[40]=T,e[41]=I,e[42]=Ce,e[43]=ve,e[44]=Se,e[45]=qe,e[46]=we,e[47]=S,e[48]=H,e[49]=pe,e[50]=o,e[51]=J):J=e[51];let oe;return e[52]!==B||e[53]!==k||e[54]!==Le||e[55]!==O||e[56]!==R||e[57]!==J?(oe=(0,t.jsxs)("div",{className:tt,"data-testid":at,children:[B,k,Le,O,R,J]}),e[52]=B,e[53]=k,e[54]=Le,e[55]=O,e[56]=R,e[57]=J,e[58]=oe):oe=e[58],oe},"Ft");function bt(n){return(0,t.jsxs)(G,{"data-testid":`queues-row-${n.exportName}`,children:[(0,t.jsx)(w,{className:"font-mono text-xs",children:n.exportName}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.name}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.mode}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.binding}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.deadLetterQueue??"\u2014"})]},n.exportName)}h(bt,"xt");function qt(n){return(0,t.jsx)("option",{value:n.exportName,children:n.exportName},n.exportName)}h(qt,"yt");function vt(n,e){return n.exportName.localeCompare(e.exportName)}h(vt,"bt");function St(n){return n.name}h(St,"Nt");export{Ft as default};
|