@lunora/studio 1.0.0-alpha.190 → 1.0.0-alpha.191
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-JTDNWSOY.js → chunk-22FKIHUY.js} +1 -1
- package/dist/standalone/{chunk-HKALXRQ5.js → chunk-2T32GEQQ.js} +1 -1
- package/dist/standalone/{chunk-P62LO76E.js → chunk-33TZIQ2S.js} +1 -1
- package/dist/standalone/{chunk-B5N47BXE.js → chunk-3FTKCJ7O.js} +1 -1
- package/dist/standalone/{chunk-GSVZDPHS.js → chunk-43IYGZQ6.js} +1 -1
- package/dist/standalone/{chunk-5IHQJLV7.js → chunk-4POCWNXY.js} +1 -1
- package/dist/standalone/{chunk-YHFTNPS2.js → chunk-5FAP63DI.js} +1 -1
- package/dist/standalone/{chunk-QBXHU32E.js → chunk-7ZHHYQ4T.js} +1 -1
- package/dist/standalone/{chunk-CEQOKOTY.js → chunk-AJP7B63M.js} +1 -1
- package/dist/standalone/{chunk-QJNVJU5I.js → chunk-AYZMJVUF.js} +1 -1
- package/dist/standalone/{chunk-M4XQHWSJ.js → chunk-AZVN24IA.js} +1 -1
- package/dist/standalone/{chunk-SS2SI65S.js → chunk-BOM2BBWF.js} +1 -1
- package/dist/standalone/chunk-C6T7K5XP.js +1 -0
- package/dist/standalone/{chunk-SSERHMYQ.js → chunk-CA3OW2WZ.js} +1 -1
- package/dist/standalone/{chunk-LAT7MUQV.js → chunk-CHRWZLGV.js} +1 -1
- package/dist/standalone/{chunk-RSDM6WG5.js → chunk-DNJ65IEL.js} +1 -1
- package/dist/standalone/{chunk-KEBHEIFH.js → chunk-DWJBMAZK.js} +1 -1
- package/dist/standalone/{chunk-746WMHVP.js → chunk-EQF3OTY7.js} +1 -1
- package/dist/standalone/{chunk-46CZEK2Q.js → chunk-EVW7O6HB.js} +1 -1
- package/dist/standalone/{chunk-IWRLEQ72.js → chunk-FI3ECXVE.js} +1 -1
- package/dist/standalone/{chunk-IPCE6QOA.js → chunk-FTV2YW7O.js} +1 -1
- package/dist/standalone/{chunk-QY766ZKO.js → chunk-GUPNWYY4.js} +1 -1
- package/dist/standalone/{chunk-3GNAY2MJ.js → chunk-H7DF4RS7.js} +1 -1
- package/dist/standalone/{chunk-DDHH7VHP.js → chunk-HXD4OZRG.js} +1 -1
- package/dist/standalone/{chunk-OUDWIUT7.js → chunk-I4UWU3J5.js} +1 -1
- package/dist/standalone/{chunk-WQLNHY3B.js → chunk-IIQQMD2H.js} +1 -1
- package/dist/standalone/{chunk-ZJ4U2EWG.js → chunk-IYBEVL3D.js} +1 -1
- package/dist/standalone/{chunk-H6Y5JYSG.js → chunk-K7UN7BX4.js} +1 -1
- package/dist/standalone/chunk-KNCZAQG6.js +11 -0
- package/dist/standalone/{chunk-YWROJNX3.js → chunk-KQSYYO6Q.js} +1 -1
- package/dist/standalone/{chunk-PHCXSS6I.js → chunk-LJFYYHU7.js} +1 -1
- package/dist/standalone/{chunk-X74DHIA3.js → chunk-MEWNGXGQ.js} +1 -1
- package/dist/standalone/{chunk-E2YWM2QN.js → chunk-MN6FO3NX.js} +1 -1
- package/dist/standalone/{chunk-BXSJ3MOM.js → chunk-MTUKLG3H.js} +1 -1
- package/dist/standalone/{chunk-2H24GTUC.js → chunk-MUZKHVS3.js} +1 -1
- package/dist/standalone/{chunk-5WUSR5UW.js → chunk-MZFWCHUZ.js} +1 -1
- package/dist/standalone/{chunk-UAMGVADC.js → chunk-NZI67TPT.js} +1 -1
- package/dist/standalone/{chunk-BLQN7VBN.js → chunk-OSDSDUGS.js} +1 -1
- package/dist/standalone/{chunk-GG2N7OO3.js → chunk-OWZ3CC4J.js} +1 -1
- package/dist/standalone/{chunk-LV6N3H5U.js → chunk-PJE523S5.js} +1 -1
- package/dist/standalone/{chunk-WE3N45LG.js → chunk-Q2V33DP4.js} +1 -1
- package/dist/standalone/{chunk-4NRXTCX2.js → chunk-QCZEJFOU.js} +1 -1
- package/dist/standalone/{chunk-TACXQS76.js → chunk-QDGH4GMS.js} +1 -1
- package/dist/standalone/{chunk-AALNIR3V.js → chunk-QZGZTILS.js} +1 -1
- package/dist/standalone/{chunk-6XL3S5RE.js → chunk-RFSMJBUZ.js} +1 -1
- package/dist/standalone/{chunk-LV2OBCJS.js → chunk-UC3X7OZS.js} +1 -1
- package/dist/standalone/{chunk-NZCQC5YS.js → chunk-W6GSTWSM.js} +1 -1
- package/dist/standalone/{chunk-NID5AZAR.js → chunk-W6VN64ZP.js} +1 -1
- package/dist/standalone/{chunk-VTPGX4ZT.js → chunk-XWMTRNWU.js} +1 -1
- package/dist/standalone/{chunk-JXIPB43K.js → chunk-XYFUZ3FC.js} +1 -1
- package/dist/standalone/{chunk-IMKTN66X.js → chunk-Y5SVNBXX.js} +1 -1
- package/dist/standalone/{chunk-MRZ7CD3T.js → chunk-YAVGBYLX.js} +1 -1
- package/dist/standalone/{chunk-6UWFARCM.js → chunk-YXFRZ4WU.js} +1 -1
- package/dist/standalone/{chunk-CCRIC2PX.js → chunk-YXMBF7AD.js} +1 -1
- package/dist/standalone/{chunk-4IUB2OTN.js → chunk-ZF4ZY6GC.js} +1 -1
- package/dist/standalone/{chunk-Q5U22R2E.js → chunk-ZKUNMHG5.js} +1 -1
- package/dist/standalone/{chunk-YBQUFWZB.js → chunk-ZSLVBHNB.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +4 -4
- package/dist/standalone/chunk-EJYDHEAO.js +0 -11
- package/dist/standalone/chunk-EY7RT4YO.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as nt,b as rt}from"./chunk-
|
|
1
|
+
import{a as nt,b as rt}from"./chunk-W6VN64ZP.js";import{c as tt}from"./chunk-BDO4YYBB.js";import{a as et}from"./chunk-43IYGZQ6.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import"./chunk-XZMOZFE6.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-P5RUFDVX.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import"./chunk-PD6WIDY6.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as Ve}from"./chunk-OGUKYRFM.js";import{c as Ke,d as Ce,e as Ee,f as Le,g as He}from"./chunk-OKG3HWSJ.js";import{W as Ye}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as Je}from"./chunk-ULIQFBZU.js";import{a as qe}from"./chunk-4ZEL6BYL.js";import"./chunk-AZVN24IA.js";import{f as Ie}from"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import"./chunk-HEAQVSNS.js";import{d as ce,f as Se,g as Ne,h as Ge,o as ue}from"./chunk-FODLDLE2.js";import{a as l,d as Be,e as St,f as Nt,g as qt,i as me}from"./chunk-YKXDMIHQ.js";var G=Be(Nt(),1);var j=Be(St(),1);var u=Be(qt(),1);var Ct="x",ot=" ",kt={'"':'"',"'":"'","[":"]","`":"`"},ct=l((s,e)=>{let n=e+2;for(;n<s.length&&s[n]!==`
|
|
2
2
|
`;)n+=1;return n},"tt"),dt=l((s,e)=>{let n=s.indexOf("*/",e+2);return n===-1?-1:n+2},"nt"),ut=l(s=>{let e=s.split(""),n=0;for(;n<s.length;){let t=s[n]??"",o=kt[t];if(t==="-"&&s[n+1]==="-"){let r=ct(s,n);e.fill(ot,n,r),n=r}else if(t==="/"&&s[n+1]==="*"){let r=dt(s,n);if(r===-1)return;e.fill(ot,n,r),n=r}else if(o!==void 0){let r=n+1;for(;r<s.length;)if(s[r]!==o)r+=1;else if(o!=="]"&&s[r+1]===o)r+=2;else break;if(r>=s.length)return;e.fill(Ct,n,r+1),n=r+1}else n+=1}for(let t=0;t<s.length;t+=1)s[t]===`
|
|
3
3
|
`&&(e[t]=`
|
|
4
4
|
`);return e.join("")},"st"),Tt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,Rt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|truncate|update|vacuum)\b|\breplace\b(?!\s*\()/iu,_t=/^\w+/u,It=/;\s*$/u,Et=/\s/u,mt=l(s=>{let e=0;for(;e<s.length;){let n=s[e];if(n!==void 0&&Et.test(n))e+=1;else if(n==="-"&&s[e+1]==="-")e=ct(s,e);else if(n==="/"&&s[e+1]==="*"){let t=dt(s,e);if(t===-1)break;e=t}else break}return e},"ot"),Lt=l(s=>{let e=mt(s),n=s.slice(e).trimEnd();if(n==="")return{code:"SQL_EMPTY",message:"the query is empty"};let t=(ut(n)??n).replace(It,""),o=n.slice(0,t.length),r=t.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let a="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!Tt.test(o))return{code:"SQL_NOT_READONLY",length:_t.exec(o)?.[0].length??1,message:a,offset:e};let c=Rt.exec(o);if(c!==null)return{code:"SQL_NOT_READONLY",length:c[0].length,message:`${a} (\`${c[0].toUpperCase()}\` is not allowed)`,offset:e+c.index}},"Ot"),Ot=/^explain\b/iu,At=l(s=>Ot.test(s.slice(mt(s)))?s:`EXPLAIN QUERY PLAN ${s}`,"Mt"),Qe=l((s,e)=>{let n=s.trim();if(n==="")return[];let t=e+s.indexOf(n),o=Lt(n);return o?.code==="SQL_EMPTY"?[]:[o===void 0?{offset:t,sql:n}:{offset:t,rejection:o,sql:n}]},"We"),ft=l(s=>{let e=ut(s);if(e===void 0)return Qe(s,0);let n=[],t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(n.push(...Qe(s.slice(t,o),t)),t=o+1);return n},"lt"),Dt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Mt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],De=String.fromCodePoint(0),$t=new RegExp(`${De}${String.raw`(\d+)`}${De}`,"gu"),Ft=Dt.map(s=>({pattern:new RegExp(String.raw`\b${s.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:s})),zt=Mt.map(s=>({pattern:new RegExp(String.raw`\s+${s.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
@@ -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-5IHQJLV7.js";import"./chunk-ULIQFBZU.js";import"./chunk-QY766ZKO.js";import"./chunk-35DM4JJG.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-M4XQHWSJ.js";import{f as Je}from"./chunk-EJYDHEAO.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-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 +1 @@
|
|
|
1
|
-
import{a as re}from"./chunk-BOTGXX4H.js";import{a as X}from"./chunk-S3CRZLGS.js";import{a as V}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as R}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as O}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Y}from"./chunk-
|
|
1
|
+
import{a as re}from"./chunk-BOTGXX4H.js";import{a as X}from"./chunk-S3CRZLGS.js";import{a as V}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as R}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as O}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Y}from"./chunk-4POCWNXY.js";import"./chunk-ULIQFBZU.js";import"./chunk-GUPNWYY4.js";import"./chunk-35DM4JJG.js";import{a as Q}from"./chunk-4ZEL6BYL.js";import{c as J}from"./chunk-AZVN24IA.js";import"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as G}from"./chunk-FKVZRPV5.js";import{a as Z,b as ee,c as te,d as P,e as n,f as o}from"./chunk-HEAQVSNS.js";import{a as U,e as W}from"./chunk-WUWBZPUK.js";import{d as z,r as H}from"./chunk-FODLDLE2.js";import{a as l,d as B,e as de,f as me,g as he,i as L}from"./chunk-YKXDMIHQ.js";var se=B(me(),1),le=B(de(),1);var t=B(he(),1);var ue={action:"outline",mutation:"default",query:"secondary"},ae=l(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"q"),fe=l(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"de"),pe=l(r=>{let e=r.conflicts??0;return r.calls===0?"\u2014":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},"me"),xe={calls:l((r,e)=>e.calls-r.calls,"calls"),recent:l((r,e)=>e.lastCalledAt-r.lastCalledAt,"recent"),slowest:l((r,e)=>e.maxDurationMs-r.maxDurationMs,"slowest")},Ee=l(r=>{let e=(0,se.c)(47),{functions:K,initialShardKey:ne}=r,s=z(),{queryShardKey:_,setShardKey:N,shardKey:v}=X(ne),[i,oe]=(0,le.useState)("recent"),w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];let C;e[1]!==_?(C={live:!0,shardKey:_},e[1]=_,e[2]=C):C=e[2];let{data:ie,error:c,errorSource:S,liveError:b}=J(Q.getFunctionStats,w,C),k=ie?.functions??null,$;e[3]!==K?($=new Map((K??[]).map(ge)),e[3]=K,e[4]=$):$=e[4];let T=$,F;e[5]===Symbol.for("react.memo_cache_sentinel")?(F=l(M=>{oe(M.currentTarget.dataset.sort)},"E"),e[5]=F):F=e[5];let ce=F,I;if(e[6]!==c||e[7]!==S||e[8]!==T||e[9]!==b||e[10]!==N||e[11]!==v||e[12]!==i||e[13]!==k||e[14]!==s){let M=k===null?[]:k.toSorted(xe[i]),d;e[16]!==s?(d=s("Recent"),e[16]=s,e[17]=d):d=e[17];let m;e[18]!==d?(m={key:"recent",label:d},e[18]=d,e[19]=m):m=e[19];let h;e[20]!==s?(h=s("Most called"),e[20]=s,e[21]=h):h=e[21];let u;e[22]!==h?(u={key:"calls",label:h},e[22]=h,e[23]=u):u=e[23];let f;e[24]!==s?(f=s("Slowest"),e[24]=s,e[25]=f):f=e[25];let p;e[26]!==f?(p={key:"slowest",label:f},e[26]=f,e[27]=p):p=e[27];let A;e[28]!==p||e[29]!==m||e[30]!==u?(A=[m,u,p],e[28]=p,e[29]=m,e[30]=u,e[31]=A):A=e[31];let j=A,x;e[32]!==N||e[33]!==v?(x=(0,t.jsx)(V,{onChange:N,testId:"fs-shard-input",value:v}),e[32]=N,e[33]=v,e[34]=x):x=e[34];let g;e[35]!==b?(g=(0,t.jsx)(re,{message:b,prefix:"fs"}),e[35]=b,e[36]=g):g=e[36];let y;e[37]!==j||e[38]!==i?(y=(0,t.jsx)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:j.map(a=>(0,t.jsx)(R,{"data-sort":a.key,"data-testid":`fs-sort-${a.key}`,onClick:ce,size:"sm",type:"button",variant:i===a.key?"secondary":"ghost",children:a.label},a.key))}),e[37]=j,e[38]=i,e[39]=y):y=e[39];let D;e[40]!==x||e[41]!==g||e[42]!==y?(D=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,g,y]}),e[40]=x,e[41]=g,e[42]=y,e[43]=D):D=e[43];let E;e[44]!==c||e[45]!==S?(E=c!==null&&(0,t.jsx)(Y,{error:S,testId:"fs-error"}),e[44]=c,e[45]=S,e[46]=E):E=e[46],I=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[D,E,k!==null&&M.length===0&&c===null&&(0,t.jsx)(G,{description:s("Per-function call counts, error rates, and latency land here after your first request."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M3 3v18h18"}),(0,t.jsx)("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:s("No functions have run on this shard yet.")}),M.length>0&&(0,t.jsx)(U,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Z,{"data-testid":"fs-table",children:[(0,t.jsx)(ee,{children:(0,t.jsxs)(P,{children:[(0,t.jsx)(n,{children:s("function")}),(0,t.jsx)(n,{children:s("kind")}),(0,t.jsx)(n,{className:"text-right",children:s("calls")}),(0,t.jsx)(n,{className:"text-right",children:s("errors")}),(0,t.jsx)(n,{className:"text-right",children:s("conflicts")}),(0,t.jsx)(n,{className:"text-right",children:s("avg")}),(0,t.jsx)(n,{className:"text-right",children:s("max")}),(0,t.jsx)(n,{children:s("last run")}),(0,t.jsx)(n,{children:s("last error")})]})}),(0,t.jsx)(te,{children:M.map(a=>{let q=T.get(a.path);return(0,t.jsxs)(P,{"data-testid":`fs-row-${a.path}`,children:[(0,t.jsx)(o,{className:"font-medium",children:a.path}),(0,t.jsx)(o,{children:q===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)(O,{variant:ue[q],children:q})}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls}),(0,t.jsx)(o,{className:L("text-right tabular-nums",a.errors>0&&"text-destructive"),children:fe(a)}),(0,t.jsx)(o,{className:L("text-right tabular-nums",(a.conflicts??0)>0&&"text-warning"),children:pe(a)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls===0?"\u2014":ae(a.totalDurationMs/a.calls)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls===0?"\u2014":ae(a.maxDurationMs)}),(0,t.jsx)(o,{className:"text-muted-foreground",children:H(a.lastCalledAt,"\u2014")}),(0,t.jsx)(o,{className:"max-w-[24ch] truncate text-destructive",title:a.lastErrorMessage??void 0,children:a.lastErrorMessage??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.path)})})]})})})]}),e[6]=c,e[7]=S,e[8]=T,e[9]=b,e[10]=N,e[11]=v,e[12]=i,e[13]=k,e[14]=s,e[15]=I}else I=e[15];return I},"Ae");function ge(r){return[r.path,r.kind]}l(ge,"fe");export{Ee as FunctionStatsPanel};
|
|
@@ -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-AZVN24IA.js";import"./chunk-KNCZAQG6.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{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-4POCWNXY.js";import"./chunk-ULIQFBZU.js";import"./chunk-GUPNWYY4.js";import"./chunk-35DM4JJG.js";import{a as U}from"./chunk-4ZEL6BYL.js";import{c as O}from"./chunk-AZVN24IA.js";import"./chunk-KNCZAQG6.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 s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-AZVN24IA.js";import{a as n}from"./chunk-YKXDMIHQ.js";var b="__lunora_admin__:",g=new Set(["action","mutation","query"]),c=Symbol("lunora.operationSeq"),_=n(t=>{if(typeof t!="object"||t===null)return;let e=t[c];return typeof e=="number"?e:void 0},"g"),d=n((t,e)=>{if(!(typeof t!="object"||t===null||!Object.isExtensible(t)))try{Object.defineProperty(t,c,{configurable:!0,enumerable:!1,value:e,writable:!0})}catch{}},"h"),m=n(t=>{if(typeof t!="object"||t===null)return;let e=t.__lunoraRef;return typeof e=="string"&&e.startsWith(b)?e:void 0},"p"),h=n(t=>{if(typeof t!="object"||t===null)return"";let{shardKey:e}=t;return typeof e=="string"?e:""},"O"),w=n(t=>new Proxy(t,{get(e,u,y){let i=Reflect.get(e,u,y);if(typeof i!="function"||typeof u!="string"||!g.has(u))return typeof i=="function"?i.bind(e):i;let f=i;return async(...o)=>{let l=m(o[0]);if(l===void 0)return f.apply(e,o);let p=typeof o[1]=="object"&&o[1]!==null?o[1]:{},a=s.start(l,p,h(o[2]));try{let r=await f.apply(e,o);return s.settle(a,{result:r}),r}catch(r){throw s.settle(a,{error:r instanceof Error?r.message:String(r)}),d(r,a),r}}}}),"E");export{_ as a,w as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as K}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as Q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{f as z}from"./chunk-
|
|
1
|
+
import{W as K}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as Q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{f as z}from"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as W}from"./chunk-FKVZRPV5.js";import{a as q,b as B,c as L,d as f,e as c,f as d}from"./chunk-HEAQVSNS.js";import{a as I,e as j}from"./chunk-WUWBZPUK.js";import{d as F,h as S,n as Z,o as V}from"./chunk-FODLDLE2.js";import{a as h,d as C,e as U,f as G,g as J}from"./chunk-YKXDMIHQ.js";var A=C(G(),1);var n=C(U(),1);var e=C(J(),1);var X=10,g=h(v=>{let l=(0,A.c)(7),{label:m,value:a}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=a??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=z(),a=F(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[b,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,$]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();t.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){t.cancelled||(p(null),u(S(i)))}})()),()=>{t.cancelled=!0}},[m,v]);let o=r?.find(t=>t.name===N)??null,H=h(t=>{E(t.currentTarget.dataset.index??null),y(null),w(null)},"Q"),O=h(t=>{D(t.target.value)},"$"),P=h(async()=>{let t=b.trim();if(!(N===null||t==="")){$(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:t,topK:X});y(i)}catch(i){y(null),w(S(i))}$(!1)}},"A"),R=h(()=>{V(P())},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(W,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(B,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("name")}),(0,e.jsx)(c,{children:a("table")}),(0,e.jsx)(c,{children:a("dimensions")}),(0,e.jsx)(c,{children:a("metric")}),(0,e.jsx)(c,{children:a("vectors")})]})}),(0,e.jsx)(L,{children:r.map(t=>(0,e.jsxs)(f,{className:t.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:H,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.table}),(0,e.jsx)(d,{className:"tabular-nums",children:t.dimensions??"\u2014"}),(0,e.jsx)(d,{children:t.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:t.vectorsCount??"\u2014"})]},t.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(g,{label:a("field"),value:o.field}),(0,e.jsx)(g,{label:a("dimensions"),value:o.dimensions}),(0,e.jsx)(g,{label:a("metric"),value:o.metric}),(0,e.jsx)(g,{label:a("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(K,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:O,placeholder:a("Search by similarity\u2026"),value:b}),(0,e.jsx)(Q,{"data-testid":"vector-search",disabled:T||b.trim()==="",onClick:R,children:a(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(B,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("id")}),(0,e.jsx)(c,{children:a("score")}),(0,e.jsx)(c,{children:a("metadata")})]})}),(0,e.jsx)(L,{children:x.map(t=>(0,e.jsxs)(f,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.id}),(0,e.jsx)(d,{className:"tabular-nums",children:t.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":Z(t.metadata)})]},t.id))})]})})})]})]})},"se");export{se as VectorBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O}from"./chunk-EA2JKR5D.js";import{a as C}from"./chunk-IMOHEGMV.js";import{b as v}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as k}from"./chunk-
|
|
1
|
+
import{a as O}from"./chunk-EA2JKR5D.js";import{a as C}from"./chunk-IMOHEGMV.js";import{b as v}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as k}from"./chunk-4POCWNXY.js";import"./chunk-ULIQFBZU.js";import"./chunk-GUPNWYY4.js";import"./chunk-35DM4JJG.js";import{a as S}from"./chunk-4ZEL6BYL.js";import{c as b}from"./chunk-AZVN24IA.js";import"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as c}from"./chunk-FKVZRPV5.js";import{a as w,b as T,c as A,d as f,e as s,f as l}from"./chunk-HEAQVSNS.js";import{a as y,e as N}from"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as n,d as x,e as R,g as V}from"./chunk-YKXDMIHQ.js";var F=x(R(),1);var e=x(V(),1);var $=n(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"H"),q='{ "targetingKey": "user-123", "plan": "premium" }',D=n(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"R"),Y=n(({initialShardKey:a=""})=>{let t=p(),[o,j]=(0,F.useState)(""),{context:g,error:m}=$(o),I=g===void 0?{}:{context:g},{data:i,error:J,errorSource:K,liveError:E}=b(S.listFlags,I,{live:!0,shardKey:a}),u=i!==void 0,L=i?.configured??!1,h=Array.isArray(i?.flags)?[...i.flags].toSorted((r,B)=>r.key.localeCompare(B.key)):[],d;return u&&!L?d=(0,e.jsx)(c,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):u&&h.length===0?d=(0,e.jsx)(c,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"flags-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(s,{children:t("Key")}),(0,e.jsx)(s,{children:t("Type")}),(0,e.jsx)(s,{children:t("Value")}),(0,e.jsx)(s,{children:t("Reason")}),(0,e.jsx)(s,{children:t("Variant")})]})}),(0,e.jsx)(A,{children:h.map(r=>(0,e.jsxs)(f,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsx)(l,{className:"font-mono text-xs",children:r.key}),(0,e.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:r.type}),(0,e.jsx)(l,{className:"font-mono text-xs",children:D(r)}),(0,e.jsx)(l,{children:r.errorCode===void 0?(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"}):(0,e.jsx)(v,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),(0,e.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"})]},r.key))})]})})}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsx)(k,{error:K,testId:"flags-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(C,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),(0,e.jsx)(O,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:n(r=>{j(r.target.value)},"onChange"),placeholder:q,rows:3,value:o}),m!==null&&(0,e.jsx)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(m)}),E!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})},"W");export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as te}from"./chunk-EA2JKR5D.js";import{W as Z}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as O}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as K}from"./chunk-4ZEL6BYL.js";import{c as ee}from"./chunk-M4XQHWSJ.js";import{f as M}from"./chunk-EJYDHEAO.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as P}from"./chunk-FKVZRPV5.js";import{a as D,b as F,c as L,d as h,e as o,f as i}from"./chunk-HEAQVSNS.js";import{a as E,e as _}from"./chunk-WUWBZPUK.js";import{d as H,f as Q,g as V,h as W,o as $}from"./chunk-FODLDLE2.js";import{a as n,d as Y,e as ne,g as le}from"./chunk-YKXDMIHQ.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:j,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,C]=(0,c.useState)(null),[v,z]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,I]=(0,c.useState)(!1),[R,U]=(0,c.useState)(null),x=l??(a=>A.getWorkflowInstance(a)),w=N?void 0:j??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),T=n(async()=>{f(null),I(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),I(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?I(!0):f(W(d))}},"L");(0,c.useEffect)(()=>{C(null),$(T())},[g,v]);let q=n(async a=>{f(null);try{C(await x({id:a,name:g}))}catch(d){f(W(d))}},"K"),B=n(async(a,d)=>{if(w!==void 0){U(a),f(null);try{await w({action:d,id:a,name:g}),await T()}catch(G){f(W(G))}U(null)}},"q");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),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":"workflow-instances-filter",onChange:n(a=>{z(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(P,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(P,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(L,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(O,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(q(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),w!==void 0&&ie.map(d=>(0,e.jsx)(O,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:R===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(E,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(O,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{C(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(D,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(L,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),xe=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:j}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[C,v]=(0,c.useState)(!1),[z,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[I,R]=(0,c.useState)(null),U=N!==void 0,x=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=xe(x,g),T=x.find(t=>t.exportName===w),q=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"C"),B=n(async()=>{let t=w;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));q({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"L"),a=n(()=>{$(B())},"K"),d=n(async(t,u)=>{R(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));q({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}R(null)},"q"),G=n(t=>{A(t.target.value)},"r"),ae=n(t=>{p(t.target.value)},"l"),re=n(t=>{S(t.target.value)},"G"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[j!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:j}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),U&&x.length===0?(0,e.jsx)(P,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(L,{children:x.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),x.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),z!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:z}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),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":"workflows-start-select",onChange:G,value:w,children:x.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(O,{"data-testid":"workflows-start-button",disabled:C||w==="",onClick:a,children:r(C?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(L,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(O,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:I===t.id,onClick:se,size:"xs",variant:"outline",children:I===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),T!==void 0&&(0,e.jsx)(ue,{workflowName:T.name})]})},"Te");export{We as default};
|
|
1
|
+
import{a as te}from"./chunk-EA2JKR5D.js";import{W as Z}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as O}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as K}from"./chunk-4ZEL6BYL.js";import{c as ee}from"./chunk-AZVN24IA.js";import{f as M}from"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as P}from"./chunk-FKVZRPV5.js";import{a as D,b as F,c as L,d as h,e as o,f as i}from"./chunk-HEAQVSNS.js";import{a as E,e as _}from"./chunk-WUWBZPUK.js";import{d as H,f as Q,g as V,h as W,o as $}from"./chunk-FODLDLE2.js";import{a as n,d as Y,e as ne,g as le}from"./chunk-YKXDMIHQ.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:j,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,C]=(0,c.useState)(null),[v,z]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,I]=(0,c.useState)(!1),[R,U]=(0,c.useState)(null),x=l??(a=>A.getWorkflowInstance(a)),w=N?void 0:j??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),T=n(async()=>{f(null),I(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),I(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?I(!0):f(W(d))}},"L");(0,c.useEffect)(()=>{C(null),$(T())},[g,v]);let q=n(async a=>{f(null);try{C(await x({id:a,name:g}))}catch(d){f(W(d))}},"K"),B=n(async(a,d)=>{if(w!==void 0){U(a),f(null);try{await w({action:d,id:a,name:g}),await T()}catch(G){f(W(G))}U(null)}},"q");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),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":"workflow-instances-filter",onChange:n(a=>{z(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(P,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(P,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(L,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(O,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(q(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),w!==void 0&&ie.map(d=>(0,e.jsx)(O,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:R===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(E,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(O,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{C(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(D,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(L,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),xe=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:j}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[C,v]=(0,c.useState)(!1),[z,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[I,R]=(0,c.useState)(null),U=N!==void 0,x=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=xe(x,g),T=x.find(t=>t.exportName===w),q=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"C"),B=n(async()=>{let t=w;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));q({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"L"),a=n(()=>{$(B())},"K"),d=n(async(t,u)=>{R(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));q({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}R(null)},"q"),G=n(t=>{A(t.target.value)},"r"),ae=n(t=>{p(t.target.value)},"l"),re=n(t=>{S(t.target.value)},"G"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[j!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:j}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),U&&x.length===0?(0,e.jsx)(P,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(L,{children:x.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),x.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),z!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:z}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),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":"workflows-start-select",onChange:G,value:w,children:x.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(O,{"data-testid":"workflows-start-button",disabled:C||w==="",onClick:a,children:r(C?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(L,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(O,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:I===t.id,onClick:se,size:"xs",variant:"outline",children:I===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),T!==void 0&&(0,e.jsx)(ue,{workflowName:T.name})]})},"Te");export{We as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as k}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as j}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as U}from"./chunk-
|
|
1
|
+
import{W as k}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as j}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as U}from"./chunk-4POCWNXY.js";import"./chunk-ULIQFBZU.js";import"./chunk-GUPNWYY4.js";import"./chunk-35DM4JJG.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as P}from"./chunk-AZVN24IA.js";import"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as M}from"./chunk-FKVZRPV5.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-HEAQVSNS.js";import{a as z,e as D}from"./chunk-WUWBZPUK.js";import{d as F,r as O}from"./chunk-FODLDLE2.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-YKXDMIHQ.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=F(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=P(R.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(M,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:O(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as me}from"./chunk-SUDJTC4S.js";import{a as $}from"./chunk-YVVP4DRM.js";import{a as ue}from"./chunk-BOTGXX4H.js";import"./chunk-P5RUFDVX.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import{a as de}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as D}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as M}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-M4XQHWSJ.js";import{f as ne,g as oe}from"./chunk-EJYDHEAO.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as A}from"./chunk-WUWBZPUK.js";import{d as T,f as j,g as Q,h as W,o as _,r as ie}from"./chunk-FODLDLE2.js";import{a as h,d as I,e as Ee,f as ae,g as le,i as E}from"./chunk-YKXDMIHQ.js";var Y=I(ae(),1);var f=I(Ee(),1);var fe=I(ae(),1);var B=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive",polling:"bg-warning"},pe=h(()=>{let t=(0,fe.c)(18),e=T(),a=oe(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}case"polling":{let n;t[8]!==e?(n=e("Polling"),t[8]=e,t[9]=n):n=t[9],s=n;break e}default:s=a}let l=Me[a],c;t[10]!==l?(c=E("size-2 rounded-full",l),t[10]=l,t[11]=c):c=t[11];let i;t[12]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[12]=c,t[13]=i):i=t[13];let o;return t[14]!==a||t[15]!==i||t[16]!==s?(o=(0,B.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[14]=a,t[15]=i,t[16]=s,t[17]=o):o=t[17],o},"T");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=h((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","Q"),xe=.01,ve=.05,je=h(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=T(),o;e[0]!==i?(o=i("Functions by error rate"),e[0]=i,e[1]=o):o=e[1];let n;e[2]!==o?(n=(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:o})}),e[2]=o,e[3]=n):n=e[3];let p;e[4]!==i||e[5]!==c?(p=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(D,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=p):p=e[6];let g;e[7]!==n||e[8]!==p?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[n,p]}),e[7]=n,e[8]=p,e[9]=g):g=e[9];let b;e[10]!==i?(b=i("Recent errors"),e[10]=i,e[11]=b):b=e[11];let d;e[12]!==b?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[12]=b,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(D,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==i||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=S):S=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==v?(N=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=v,e[32]=N):N=e[32];let y;return e[33]!==N||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,N]}),e[33]=N,e[34]=g,e[35]=y):y=e[35],y},"ye");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ce,"Te");var he={completed:0,failed:2,in_progress:1},Ie=h(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:o}of t){if(o===null){l+=1;continue}s+=1,e+=o.requests,a+=o.errors,i.push(...o.history??[]),c||=o.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"ke"),De=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=he[s.status]-he[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=j(M.getAuthMetrics),Fe=j(M.getFunctionStats),Le=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,_e=5,$e=.1,Be=.3,He=1,Ue=50,Ge=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ke=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"Ge"),Ve=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ve"),Je=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=h(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,o=be[l],n;e[0]!==o?(n=E("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=n):n=e[1];let p;e[2]!==n?(p=(0,r.jsx)("span",{"aria-hidden":"true",className:n}),e[2]=n,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]}),e[4]=s,e[5]=p,e[6]=g):g=e[6];let b=Ne[l],d;e[7]!==b?(d=E("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"U"),Xe=h(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,o,n]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),p=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(p),b=s[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(p.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?W(b.reason):null,migrations:De(p.map(d=>d.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:g}},"$e"),Ye=h(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=h(({initialShardKey:t})=>{let e=ne(),a=T(),[s,l]=(0,f.useState)([]),[c,i]=(0,f.useState)(null),[o,n]=(0,f.useState)(null),[p,g]=(0,f.useState)(null),[b,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,q]=(0,f.useState)([]),[N]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let P=t??"",F=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Xe(e,P,me(P,N));if(!w.current){y.current=!1;return}n(m.totals),g(m.metricsError),d(m.functions),q(m.migrations),l(m.entries),i(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,N,P]);(0,f.useEffect)(()=>{_(F())},[F]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=h(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),_(F());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),_(F())},ge-m))},"ue");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:Z,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:P});(0,f.useEffect)(()=>{Z!==void 0&&we()},[Z]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),L=Ke(o?.history),te=Ye(u),Se=b.filter(m=>m.calls>0).toSorted((m,J)=>J.errors/J.calls-m.errors/m.calls||J.calls-m.calls).slice(0,_e),K=Ve(S),qe=o===null||o.requests===0?0:o.errors/o.requests,V=X(qe,xe,ve),re=u===null?"ok":X(u.failureRate,$e,Be),se=v===null?"ok":Ge(v.backlog,He,Ue),R=We([V,re,se,K.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:E("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[R]),children:(0,r.jsx)("span",{className:E("size-3 rounded-full",be[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(o?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:E("text-lg font-semibold tabular-nums",Ne[V]),"data-testid":"hl-error-rate",children:o===null?"\u2014":U(o.errors,o.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(pe,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),p!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p}),p===null&&o?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:L.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:V,testId:"hl-slo-errorrate",value:o===null?"\u2014":U(o.errors,o.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)($,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:K.level,testId:"hl-slo-migrations",value:Je(K,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 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:a("Shards seen")}),(0,r.jsx)(D,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(D,{variant:"secondary",children:m})},m))})]})]})},"ut");export{xt as HealthPanel};
|
|
1
|
+
import{b as me}from"./chunk-SUDJTC4S.js";import{a as $}from"./chunk-YVVP4DRM.js";import{a as ue}from"./chunk-BOTGXX4H.js";import"./chunk-P5RUFDVX.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import{a as de}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as D}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as M}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-AZVN24IA.js";import{f as ne,g as oe}from"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as A}from"./chunk-WUWBZPUK.js";import{d as T,f as j,g as Q,h as W,o as _,r as ie}from"./chunk-FODLDLE2.js";import{a as h,d as I,e as Ee,f as ae,g as le,i as E}from"./chunk-YKXDMIHQ.js";var Y=I(ae(),1);var f=I(Ee(),1);var fe=I(ae(),1);var B=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive",polling:"bg-warning"},pe=h(()=>{let t=(0,fe.c)(18),e=T(),a=oe(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}case"polling":{let n;t[8]!==e?(n=e("Polling"),t[8]=e,t[9]=n):n=t[9],s=n;break e}default:s=a}let l=Me[a],c;t[10]!==l?(c=E("size-2 rounded-full",l),t[10]=l,t[11]=c):c=t[11];let i;t[12]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[12]=c,t[13]=i):i=t[13];let o;return t[14]!==a||t[15]!==i||t[16]!==s?(o=(0,B.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[14]=a,t[15]=i,t[16]=s,t[17]=o):o=t[17],o},"T");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=h((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","Q"),xe=.01,ve=.05,je=h(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=T(),o;e[0]!==i?(o=i("Functions by error rate"),e[0]=i,e[1]=o):o=e[1];let n;e[2]!==o?(n=(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:o})}),e[2]=o,e[3]=n):n=e[3];let p;e[4]!==i||e[5]!==c?(p=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(D,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=p):p=e[6];let g;e[7]!==n||e[8]!==p?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[n,p]}),e[7]=n,e[8]=p,e[9]=g):g=e[9];let b;e[10]!==i?(b=i("Recent errors"),e[10]=i,e[11]=b):b=e[11];let d;e[12]!==b?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[12]=b,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(D,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==i||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=S):S=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==v?(N=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=v,e[32]=N):N=e[32];let y;return e[33]!==N||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,N]}),e[33]=N,e[34]=g,e[35]=y):y=e[35],y},"ye");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ce,"Te");var he={completed:0,failed:2,in_progress:1},Ie=h(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:o}of t){if(o===null){l+=1;continue}s+=1,e+=o.requests,a+=o.errors,i.push(...o.history??[]),c||=o.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"ke"),De=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=he[s.status]-he[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=j(M.getAuthMetrics),Fe=j(M.getFunctionStats),Le=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,_e=5,$e=.1,Be=.3,He=1,Ue=50,Ge=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ke=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"Ge"),Ve=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ve"),Je=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=h(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,o=be[l],n;e[0]!==o?(n=E("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=n):n=e[1];let p;e[2]!==n?(p=(0,r.jsx)("span",{"aria-hidden":"true",className:n}),e[2]=n,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]}),e[4]=s,e[5]=p,e[6]=g):g=e[6];let b=Ne[l],d;e[7]!==b?(d=E("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"U"),Xe=h(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,o,n]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),p=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(p),b=s[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(p.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?W(b.reason):null,migrations:De(p.map(d=>d.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:g}},"$e"),Ye=h(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=h(({initialShardKey:t})=>{let e=ne(),a=T(),[s,l]=(0,f.useState)([]),[c,i]=(0,f.useState)(null),[o,n]=(0,f.useState)(null),[p,g]=(0,f.useState)(null),[b,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,q]=(0,f.useState)([]),[N]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let P=t??"",F=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Xe(e,P,me(P,N));if(!w.current){y.current=!1;return}n(m.totals),g(m.metricsError),d(m.functions),q(m.migrations),l(m.entries),i(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,N,P]);(0,f.useEffect)(()=>{_(F())},[F]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=h(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),_(F());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),_(F())},ge-m))},"ue");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:Z,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:P});(0,f.useEffect)(()=>{Z!==void 0&&we()},[Z]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),L=Ke(o?.history),te=Ye(u),Se=b.filter(m=>m.calls>0).toSorted((m,J)=>J.errors/J.calls-m.errors/m.calls||J.calls-m.calls).slice(0,_e),K=Ve(S),qe=o===null||o.requests===0?0:o.errors/o.requests,V=X(qe,xe,ve),re=u===null?"ok":X(u.failureRate,$e,Be),se=v===null?"ok":Ge(v.backlog,He,Ue),R=We([V,re,se,K.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:E("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[R]),children:(0,r.jsx)("span",{className:E("size-3 rounded-full",be[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(o?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:E("text-lg font-semibold tabular-nums",Ne[V]),"data-testid":"hl-error-rate",children:o===null?"\u2014":U(o.errors,o.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(pe,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),p!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p}),p===null&&o?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:L.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:V,testId:"hl-slo-errorrate",value:o===null?"\u2014":U(o.errors,o.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)($,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:K.level,testId:"hl-slo-migrations",value:Je(K,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 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:a("Shards seen")}),(0,r.jsx)(D,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(D,{variant:"secondary",children:m})},m))})]})]})},"ut");export{xt as HealthPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as k}from"./chunk-YOB2X3FZ.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as _}from"./chunk-
|
|
1
|
+
import{d as k}from"./chunk-YOB2X3FZ.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as _}from"./chunk-33TZIQ2S.js";import"./chunk-K7AJEMKE.js";import"./chunk-6D6Z2KXU.js";import"./chunk-Y6CXU7T4.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as g}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-4POCWNXY.js";import"./chunk-ULIQFBZU.js";import"./chunk-GUPNWYY4.js";import"./chunk-35DM4JJG.js";import{a as y}from"./chunk-4ZEL6BYL.js";import{c as b}from"./chunk-AZVN24IA.js";import"./chunk-KNCZAQG6.js";import"./chunk-FSRSK4LY.js";import"./chunk-MKL7VDTL.js";import{a as w}from"./chunk-FKVZRPV5.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-HEAQVSNS.js";import{a as f,e as N}from"./chunk-WUWBZPUK.js";import{d as T,r as S}from"./chunk-FODLDLE2.js";import{a as c,d as G,g as H}from"./chunk-YKXDMIHQ.js";var e=G(H(),1);var Q=["subscriptions","events"],U={},B=new Set(["active","trialing"]),V=new Set(["past_due","unpaid"]),s=c((a,t)=>{if(a[t]!==void 0)return a[t];let m=a.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"n"),i=c(a=>typeof a=="string"?a:typeof a=="number"||typeof a=="bigint"||typeof a=="boolean"?String(a):"","a"),q=c(a=>B.has(a)?"default":V.has(a)?"destructive":"outline","G"),se=c(({limit:a=100})=>{let t=T(),m=_(),{data:x}=b(y.listTables,U,{live:!0}),D=x!==void 0,C=Array.isArray(x)&&Q.every(r=>x.some(d=>d.name===r)),p=m.payments&&C,o=b(y.readTablePage,{filters:[],limit:a,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),h=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),h.refetch())},!0);let u=o.data?.rows??[],O=h.data?.rows??[],F=o.error??h.error,L=o.error===null?h.errorSource:o.errorSource,P=u.filter(r=>B.has(i(s(r,"state")))).length,M=O.toSorted((r,d)=>Number(s(d,"processedAt")??0)-Number(s(r,"processedAt")??0));return D&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(f,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(g,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:u.length})})]})}),F===null?void 0:(0,e.jsx)(E,{error:L}),u.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(f,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(A,{children:u.map(r=>{let d=i(s(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{children:i(s(r,"referenceId"))}),(0,e.jsx)(n,{children:i(s(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(g,{variant:q(d),children:d})}),(0,e.jsx)(n,{children:S(s(r,"currentPeriodEnd"))})]},i(s(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(f,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:M.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(s(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(s(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(s(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(s(r,"processedAt"))})]},i(s(r,"providerEventId"))))})})})]})]})},"se");export{se as PaymentsPanel};
|