@lunora/studio 1.0.0-alpha.183 → 1.0.0-alpha.184
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-KX3YZ3TC.js → chunk-26L63KFY.js} +1 -1
- package/dist/standalone/{chunk-3PZNTIBM.js → chunk-2KM4MU7U.js} +1 -1
- package/dist/standalone/{chunk-IP7YCJUN.js → chunk-37CLUREK.js} +1 -1
- package/dist/standalone/{chunk-XKP3TSCE.js → chunk-3GJKDNXE.js} +1 -1
- package/dist/standalone/{chunk-FI6N7XWP.js → chunk-4P4DE3XL.js} +1 -1
- package/dist/standalone/{chunk-H43JNQM6.js → chunk-4PLYQWKJ.js} +1 -1
- package/dist/standalone/{chunk-TIIEZS24.js → chunk-4X5HAX5N.js} +1 -1
- package/dist/standalone/{chunk-QQ3CS3FX.js → chunk-55K64SUB.js} +1 -1
- package/dist/standalone/{chunk-5XRNQ732.js → chunk-56XCNBO4.js} +1 -1
- package/dist/standalone/{chunk-DAD33Q2T.js → chunk-5AQVGRDR.js} +1 -1
- package/dist/standalone/{chunk-I6FR5UAK.js → chunk-5TV5EBCO.js} +1 -1
- package/dist/standalone/{chunk-JYT34NQM.js → chunk-6VNVVY4F.js} +1 -1
- package/dist/standalone/{chunk-VWXJAY7R.js → chunk-724ZBLVZ.js} +1 -1
- package/dist/standalone/{chunk-AULH6SZB.js → chunk-75OWNJEY.js} +2 -2
- package/dist/standalone/{chunk-TTIBDOV6.js → chunk-7E4PCEOO.js} +1 -1
- package/dist/standalone/{chunk-KIW73EIK.js → chunk-7MF5C3Z6.js} +1 -1
- package/dist/standalone/{chunk-SDHFSBNM.js → chunk-7TRN7FQ4.js} +1 -1
- package/dist/standalone/{chunk-BAAPQWFF.js → chunk-AO5ROTB4.js} +1 -1
- package/dist/standalone/{chunk-A6S4TULR.js → chunk-BMVSHGFK.js} +1 -1
- package/dist/standalone/{chunk-B3JY36UV.js → chunk-CLELTQYS.js} +1 -1
- package/dist/standalone/{chunk-AX24JD2G.js → chunk-CZIPGHIR.js} +1 -1
- package/dist/standalone/{chunk-5LZJ5JBB.js → chunk-DVXDMRWA.js} +1 -1
- package/dist/standalone/{chunk-B6RRRJP5.js → chunk-EAQZEXBX.js} +1 -1
- package/dist/standalone/{chunk-IXNOQYEE.js → chunk-ETHN2RZR.js} +1 -1
- package/dist/standalone/{chunk-CBNGOAD4.js → chunk-FAFNOIJX.js} +1 -1
- package/dist/standalone/{chunk-ITMXIPQ7.js → chunk-FDB7QVEC.js} +1 -1
- package/dist/standalone/{chunk-GZAXFXZE.js → chunk-FGMA2GGM.js} +1 -1
- package/dist/standalone/{chunk-GAPFZFIL.js → chunk-FRMJ5VVM.js} +1 -1
- package/dist/standalone/{chunk-5MKG6RW3.js → chunk-FZ45WJQK.js} +1 -1
- package/dist/standalone/{chunk-2Y6PXGIS.js → chunk-GETL6R4M.js} +14 -14
- package/dist/standalone/{chunk-3TXB4AKZ.js → chunk-GKUDJ3RC.js} +1 -1
- package/dist/standalone/{chunk-AODYDAXY.js → chunk-HATH336U.js} +1 -1
- package/dist/standalone/{chunk-D4ZGY3II.js → chunk-IYUIJLIW.js} +1 -1
- package/dist/standalone/{chunk-66Z7ZIZZ.js → chunk-J6JOGFVB.js} +1 -1
- package/dist/standalone/{chunk-Y2I6GYEG.js → chunk-JM6U3CQE.js} +1 -1
- package/dist/standalone/{chunk-QWJQUQY3.js → chunk-JP6RVFCJ.js} +1 -1
- package/dist/standalone/{chunk-PGMASM2T.js → chunk-JYVJ2OWH.js} +1 -1
- package/dist/standalone/{chunk-DI34YDBW.js → chunk-LP7ELDUL.js} +1 -1
- package/dist/standalone/{chunk-L2CWAQUO.js → chunk-M3ANC2JI.js} +1 -1
- package/dist/standalone/{chunk-PZVVEPIN.js → chunk-MKRJGSYF.js} +1 -1
- package/dist/standalone/{chunk-URBHAYYZ.js → chunk-MWSNVNHE.js} +1 -1
- package/dist/standalone/{chunk-E2X625P3.js → chunk-N6LSV246.js} +1 -1
- package/dist/standalone/{chunk-RM4TNBYG.js → chunk-NRZ5MBPS.js} +1 -1
- package/dist/standalone/{chunk-4PRXEO3C.js → chunk-O337Z6XI.js} +1 -1
- package/dist/standalone/{chunk-WRZTTZFV.js → chunk-PVAE535J.js} +1 -1
- package/dist/standalone/{chunk-AFSPF2R4.js → chunk-PVV6LALL.js} +1 -1
- package/dist/standalone/{chunk-GZ6GAFM2.js → chunk-QZHPUFML.js} +1 -1
- package/dist/standalone/{chunk-MH2NGGUC.js → chunk-SDBOAPOT.js} +1 -1
- package/dist/standalone/{chunk-HGT5U6GD.js → chunk-SGL3ZV4P.js} +1 -1
- package/dist/standalone/{chunk-INXSZE5I.js → chunk-T57JAZCX.js} +1 -1
- package/dist/standalone/{chunk-WIXX2VWE.js → chunk-UZHJM2CX.js} +1 -1
- package/dist/standalone/{chunk-GP2GJRJ3.js → chunk-VCOPIBKL.js} +1 -1
- package/dist/standalone/{chunk-V7G6YTQ5.js → chunk-VG34EBBT.js} +1 -1
- package/dist/standalone/{chunk-QDHXQ56K.js → chunk-VICAUTXQ.js} +1 -1
- package/dist/standalone/{chunk-WD4WHTAV.js → chunk-WDJ4CHIO.js} +1 -1
- package/dist/standalone/{chunk-EBU3TTYR.js → chunk-XBKABVCJ.js} +1 -1
- package/dist/standalone/{chunk-NVKY4CIW.js → chunk-Y6SKU4M7.js} +1 -1
- package/dist/standalone/{chunk-5B6TTEP6.js → chunk-YBZYUPAG.js} +1 -1
- package/dist/standalone/{chunk-Z2XS4ZOO.js → chunk-Z2CLSELV.js} +1 -1
- package/dist/standalone/{chunk-J3LCGEBD.js → chunk-ZGMGMEFM.js} +1 -1
- package/dist/standalone/{chunk-TXHTSFLO.js → chunk-ZWJGQACG.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as tt}from"./chunk-K7AJEMKE.js";import{e as Be}from"./chunk-6D6Z2KXU.js";import{a as We}from"./chunk-55754F6H.js";import{b as Ve}from"./chunk-FEWMAPNI.js";import{a as z}from"./chunk-4ZEL6BYL.js";import{c as _e}from"./chunk-
|
|
1
|
+
import{a as tt}from"./chunk-K7AJEMKE.js";import{e as Be}from"./chunk-6D6Z2KXU.js";import{a as We}from"./chunk-55754F6H.js";import{b as Ve}from"./chunk-FEWMAPNI.js";import{a as z}from"./chunk-4ZEL6BYL.js";import{c as _e}from"./chunk-7TRN7FQ4.js";import{f as Pe}from"./chunk-EAQZEXBX.js";import{a as Ye}from"./chunk-FKVZRPV5.js";import{a as T,e as Fe}from"./chunk-WUWBZPUK.js";import{d as $,f as Ge,g as Ze,l as Qe,o as Ne,p as Xe,q as et}from"./chunk-FODLDLE2.js";import{a as m,d as De,e as lt,f as it,g as ct,i as Ee}from"./chunk-YKXDMIHQ.js";var _=De(it(),1);var I=De(lt(),1);var n=De(ct(),1);var dt=Ge(z.studioFeatures),ot={analytics:!0,auth:!0,containers:!0,flags:!0,kv:!0,mail:!0,notifications:!0,payments:!0,queues:!0,scheduler:!0,storage:!0,vectors:!0,workflows:!0},mt=m(t=>{if(t===null||typeof t!="object")return ot;let e=t,s=m(a=>typeof e[a]=="boolean"?e[a]:!0,"n");return{analytics:s("analytics"),auth:s("auth"),containers:s("containers"),flags:s("flags"),kv:s("kv"),mail:s("mail"),notifications:s("notifications"),payments:s("payments"),queues:s("queues"),scheduler:s("scheduler"),storage:s("storage"),vectors:s("vectors"),workflows:s("workflows")}},"dt"),ut=m(()=>{let t=(0,_.c)(3),e=Pe(),[s,a]=(0,I.useState)(ot),r,o;return t[0]!==e?(r=m(()=>{Ne((async()=>{try{a(mt(await e.query(dt,{},Ze(""))))}catch{}})())},"a"),o=[e],t[0]=e,t[1]=r,t[2]=o):(r=t[1],o=t[2]),(0,I.useEffect)(r,o),s},"ut"),pt=m(()=>{let t=(0,_.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"m9 6 6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),t[0]=e):e=t[0],e},"mt"),ft=m(t=>{let e=(0,_.c)(24),{group:s}=t,a=$(),r=Be(),o;e[0]!==s.tab||e[1]!==r?(o=m(()=>{Ne(r({to:`/${s.tab}`}))},"o"),e[0]=s.tab,e[1]=r,e[2]=o):o=e[2];let l=o,i=s.bindings.length,c;e[3]!==s.label?(c=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:s.label}),e[3]=s.label,e[4]=c):c=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,n.jsx)(pt,{}),e[5]=p):p=e[5];let d;e[6]!==c?(d=(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[c,p]}),e[6]=c,e[7]=d):d=e[7];let f;e[8]!==i||e[9]!==a?(f=i===1?a("1 binding"):a("{count} bindings",{count:i}),e[8]=i,e[9]=a,e[10]=f):f=e[10];let u;e[11]!==f?(u=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:f}),e[11]=f,e[12]=u):u=e[12];let h;e[13]!==i||e[14]!==s.bindings?(h=i>0&&(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:s.bindings.map(xt)}),e[13]=i,e[14]=s.bindings,e[15]=h):h=e[15];let g;e[16]!==d||e[17]!==u||e[18]!==h?(g=(0,n.jsxs)(Fe,{className:"flex flex-col gap-2 py-4",children:[d,u,h]}),e[16]=d,e[17]=u,e[18]=h,e[19]=g):g=e[19];let x;return e[20]!==s.testId||e[21]!==l||e[22]!==g?(x=(0,n.jsx)(T,{className:"cursor-pointer gap-0 py-0 transition-colors hover:bg-muted/40","data-testid":s.testId,onClick:l,children:g}),e[20]=s.testId,e[21]=l,e[22]=g,e[23]=x):x=e[23],x},"ft"),at=["kv","files","vectors"],ht=m((t,e)=>[...t.filter(s=>s.tab!==e.tab),e].toSorted((s,a)=>at.indexOf(s.tab)-at.indexOf(a.tab)),"pt"),gt=m(()=>{let t=(0,_.c)(19),e=Pe(),s=ut(),a=$(),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];let[o,l]=(0,I.useState)(r),i,c;if(t[1]!==e||t[2]!==s.kv||t[3]!==s.storage||t[4]!==s.vectors||t[5]!==a?(i=m(()=>{let g={cancelled:!1},x=[{enabled:s.kv,label:a("KV Namespaces"),load:m(async()=>(await e.listKvNamespaces()).map(bt),"load"),tab:"kv",testId:"home-binding-kv"},{enabled:s.storage,label:a("R2 Buckets"),load:m(()=>e.listStorageBuckets(),"load"),tab:"files",testId:"home-binding-r2"},{enabled:s.vectors,label:a("Vectorize Indexes"),load:m(async()=>(await e.listVectorIndexes()).map(yt),"load"),tab:"vectors",testId:"home-binding-vectors"}];for(let b of x)b.enabled&&Ne((async()=>{try{let v=await b.load();if(!g.cancelled){let S={bindings:v,label:b.label,tab:b.tab,testId:b.testId};l(M=>ht(M,S))}}catch{}})());return()=>{g.cancelled=!0}},"i"),c=[e,s.kv,s.storage,s.vectors,a],t[1]=e,t[2]=s.kv,t[3]=s.storage,t[4]=s.vectors,t[5]=a,t[6]=i,t[7]=c):(i=t[6],c=t[7]),(0,I.useEffect)(i,c),o.length===0)return null;let p;t[8]!==a?(p=a("Bindings"),t[8]=a,t[9]=p):p=t[9];let d;t[10]!==p?(d=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:p}),t[10]=p,t[11]=d):d=t[11];let f;t[12]!==o?(f=o.map(vt),t[12]=o,t[13]=f):f=t[13];let u;t[14]!==f?(u=(0,n.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:f}),t[14]=f,t[15]=u):u=t[15];let h;return t[16]!==d||t[17]!==u?(h=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-bindings",children:[d,u]}),t[16]=d,t[17]=u,t[18]=h):h=t[18],h},"ht");function xt(t){return(0,n.jsx)(Ve,{variant:"secondary",children:t},t)}m(xt,"gt");function bt(t){return t.binding}m(bt,"xt");function yt(t){return t.name}m(yt,"bt");function vt(t){return(0,n.jsx)(ft,{group:t},t.tab)}m(vt,"yt");var Nt=[{name:"lunora_list_functions",summary:"list every query, mutation, and action with its path"},{name:"lunora_list_tables",summary:"list the schema's tables"},{name:"lunora_get_function_schema",summary:"read a function's argument JSON Schema before calling it"},{name:"lunora_run_query",summary:"run a read-only query"},{name:"lunora_run_mutation",summary:"run a mutation \u2014 writes; only when LUNORA_MCP_ALLOW_WRITES is set"},{name:"lunora_run_action",summary:"run an action \u2014 writes/effects; only when LUNORA_MCP_ALLOW_WRITES is set"}],_t=m(t=>JSON.stringify({mcpServers:{lunora:{args:["-y","@lunora/mcp"],command:"npx",env:{LUNORA_ADMIN_TOKEN:"<your-admin-token>",LUNORA_URL:t}}}},null,2),"Nt"),St=m(t=>{let e=Nt.map(s=>`- ${s.name} \u2014 ${s.summary}`).join(`
|
|
2
2
|
`);return[`You have a Lunora MCP server connected to the deployment at ${t}.`,"It exposes this backend's functions and schema so you can inspect and operate it:",e,"",`Start by calling lunora_list_functions and lunora_list_tables to learn what exists, then lunora_get_function_schema before any run call. The full HTTP API is also documented at ${t}/_lunora/admin/openapi (that endpoint needs the same admin token the MCP server is configured with).`].join(`
|
|
3
|
-
`)},"_t"),kt=1500,wt=m(()=>{let t=(0,_.c)(35),e=$(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=Xe(),t[0]=s):s=t[0];let a=s,[r,o]=(0,I.useState)(null),l,i;t[1]!==r?(l=m(()=>{if(r===null)return;let A=globalThis.setTimeout(()=>{o(null)},kt);return()=>{globalThis.clearTimeout(A)}},"r"),i=[r],t[1]=r,t[2]=l,t[3]=i):(l=t[2],i=t[3]),(0,I.useEffect)(l,i);let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=m((A,j)=>{et(j)&&o(A)},"c"),t[4]=c):c=t[4];let p=c,d;t[5]===Symbol.for("react.memo_cache_sentinel")?(d=m(()=>{p("config",_t(a))},"d"),t[5]=d):d=t[5];let f=d,u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=m(()=>{p("prompt",St(a))},"u"),t[6]=u):u=t[6];let h=u,g;t[7]!==e?(g=e("Connect an AI agent"),t[7]=e,t[8]=g):g=t[8];let x;t[9]!==g?(x=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:g}),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==e?(b=e("Drive this deployment from an AI agent over the Model Context Protocol \u2014 it can list functions and tables, read schemas, and run read-only queries. Writes stay off unless you opt in."),t[11]=e,t[12]=b):b=t[12];let v;t[13]!==b?(v=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:b}),t[13]=b,t[14]=v):v=t[14];let S;t[15]!==x||t[16]!==v?(S=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5 p-4",children:[x,v]}),t[15]=x,t[16]=v,t[17]=S):S=t[17];let M;t[18]===Symbol.for("react.memo_cache_sentinel")?(M=(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground","data-testid":"home-connect-agent-command",children:"npx -y @lunora/mcp"}),t[18]=M):M=t[18];let k;t[19]!==r||t[20]!==e?(k=e(r==="config"?"Copied":"Copy MCP config"),t[19]=r,t[20]=e,t[21]=k):k=t[21];let y;t[22]!==k?(y=(0,n.jsx)(We,{"data-testid":"home-connect-agent-copy-config",onClick:f,size:"xs",variant:"outline",children:k}),t[22]=k,t[23]=y):y=t[23];let w;t[24]!==r||t[25]!==e?(w=e(r==="prompt"?"Copied":"Copy agent prompt"),t[24]=r,t[25]=e,t[26]=w):w=t[26];let L;t[27]!==w?(L=(0,n.jsx)(We,{"data-testid":"home-connect-agent-copy-prompt",onClick:h,size:"xs",variant:"outline",children:w}),t[27]=w,t[28]=L):L=t[28];let C;t[29]!==y||t[30]!==L?(C=(0,n.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-muted/50 px-4 py-3",children:[M,(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[y,L]})]}),t[29]=y,t[30]=L,t[31]=C):C=t[31];let N;return t[32]!==S||t[33]!==C?(N=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-connect-agent",children:[S,C]}),t[32]=S,t[33]=C,t[34]=N):N=t[34],N},"kt"),Lt=(0,I.lazy)(()=>import("./chunk-J3LCGEBD.js")),Ct=m((t,e)=>{if(e==null)return t("cache not enabled");let s=e.hits+e.misses;return s===0?t("no cache traffic yet"):`${Math.round(e.hits/s*100).toString()}% ${t("cache hit")}`},"wt"),He=m(t=>{if(t<1e3)return`${String(Math.round(t))}ms`;let e=t>=1e4?0:1;return`${(t/1e3).toFixed(e)}s`},"De"),It=m((t,e)=>{let s=Math.max(0,Math.round((e-t)/1e3));if(s<60)return`${String(s)}s ago`;let a=Math.round(s/60);if(a<60)return`${String(a)}m ago`;let r=Math.round(a/60);return r<24?`${String(r)}h ago`:`${String(Math.round(r/24))}d ago`},"$t"),nt=m((t,e)=>{if(t===void 0||t.length===0)return[];let s=new Map;for(let a of t)s.set(a.bucketMs,(s.get(a.bucketMs)??0)+a[e]);return[...s.entries()].toSorted(([a],[r])=>a-r).map(([,a])=>a)},"Ve"),st=m((t,e=!0)=>{if(t.length<4)return null;let s=Math.floor(t.length/2),a=t.slice(0,s).reduce((l,i)=>l+i,0),r=t.slice(s).reduce((l,i)=>l+i,0);if(a===0)return null;let o=(r-a)/a*100;return{positive:e?o>=0:o<=0,text:`${o>=0?"+":""}${o.toFixed(1)}%`}},"We"),Te=m(t=>{let e=(0,_.c)(24),{delta:s,footer:a,label:r,trend:o,unit:l,value:i}=t,c=$(),p;e[0]!==r?(p=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=p):p=e[1];let d;e[2]!==i?(d=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[2]=i,e[3]=d):d=e[3];let f;e[4]!==l?(f=l!==void 0&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:l}),e[4]=l,e[5]=f):f=e[5];let u;e[6]!==d||e[7]!==f?(u=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[d,f]}),e[6]=d,e[7]=f,e[8]=u):u=e[8];let h;e[9]!==o?(h=o!==void 0&&(0,n.jsx)(I.Suspense,{fallback:(0,n.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28"}),children:(0,n.jsx)(Lt,{data:o})}),e[9]=o,e[10]=h):h=e[10];let g;e[11]!==u||e[12]!==h?(g=(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,h]}),e[11]=u,e[12]=h,e[13]=g):g=e[13];let x;e[14]!==p||e[15]!==g?(x=(0,n.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]}),e[14]=p,e[15]=g,e[16]=x):x=e[16];let b;e[17]!==s||e[18]!==a||e[19]!==c?(b=s==null?a!=null&&(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:a}):(0,n.jsxs)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px]",children:[(0,n.jsx)("span",{className:Ee("font-semibold",s.positive?"text-success":"text-destructive"),children:s.text})," ",(0,n.jsx)("span",{className:"text-muted-foreground",children:c("vs. prev.")})]}),e[17]=s,e[18]=a,e[19]=c,e[20]=b):b=e[20];let v;return e[21]!==x||e[22]!==b?(v=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[x,b]}),e[21]=x,e[22]=b,e[23]=v):v=e[23],v},"Te"),Mt=m(()=>{let t=(0,_.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"m9 6 6 6-6 6"})}),t[0]=e):e=t[0],e},"At"),Ue=m(t=>{let e=(0,_.c)(7),{command:s,label:a}=t,r;e[0]!==a?(r=(0,n.jsx)("div",{className:"p-4",children:(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:a})}),e[0]=a,e[1]=r):r=e[1];let o;e[2]!==s?(o=(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5",children:(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground",children:s})}),e[2]=s,e[3]=o):o=e[3];let l;return e[4]!==r||e[5]!==o?(l=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[r,o]}),e[4]=r,e[5]=o,e[6]=l):l=e[6],l},"Be"),rt=m(t=>{let e=(0,_.c)(18),{count:s,onView:a,testId:r,title:o}=t,l=$(),i;e[0]!==o?(i=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o}),e[0]=o,e[1]=i):i=e[1];let c;e[2]!==s||e[3]!==l?(c=s===null?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:l("No data yet")}):(0,n.jsx)(Ve,{variant:s>0?"destructive":"success",children:s>0?s:l("All clear")}),e[2]=s,e[3]=l,e[4]=c):c=e[4];let p;e[5]!==i||e[6]!==c?(p=(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2 p-4",children:[i,c]}),e[5]=i,e[6]=c,e[7]=p):p=e[7];let d;e[8]!==l?(d=l("View"),e[8]=l,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsx)(Mt,{}),e[10]=f):f=e[10];let u;e[11]!==a||e[12]!==d?(u=(0,n.jsxs)("button",{className:"flex items-center gap-1 border-t border-border bg-muted/50 px-4 py-2.5 text-[12px] font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted",onClick:a,type:"button",children:[d,f]}),e[11]=a,e[12]=d,e[13]=u):u=e[13];let h;return e[14]!==p||e[15]!==u||e[16]!==r?(h=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0","data-testid":r,children:[p,u]}),e[14]=p,e[15]=u,e[16]=r,e[17]=h):h=e[17],h},"Qe"),At=m(t=>{let e=(0,_.c)(7),{functions:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let o=[...s].toSorted(Ot).slice(0,5),l;e[3]!==a?(l=a("Top functions"),e[3]=a,e[4]=l):l=e[4];let i;e[5]!==l?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l})}),e[5]=l,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-top-functions",children:[i,o.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No functions called yet.")}):(0,n.jsxs)("div",{className:"divide-y divide-border",children:[(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:[(0,n.jsx)("span",{children:a("Function")}),(0,n.jsx)("span",{className:"text-end",children:a("Calls")}),(0,n.jsx)("span",{className:"w-12 text-end",children:a("Avg")}),(0,n.jsx)("span",{className:"w-8 text-end",children:a("Err")})]}),o.map(Rt)]})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"Lt"),$t=m(t=>{let e=(0,_.c)(26),{subs:s}=t,a=$(),r;e[0]!==a?(r=a("Live connections"),e[0]=a,e[1]=r):r=e[1];let o;e[2]!==r?(o=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[2]=r,e[3]=o):o=e[3];let l=s?.totalConnections??0,i;e[4]!==l?(i=l.toLocaleString(),e[4]=l,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==a?(p=a("sockets"),e[8]=a,e[9]=p):p=e[9];let d;e[10]!==p?(d=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p}),e[10]=p,e[11]=d):d=e[11];let f;e[12]!==c||e[13]!==d?(f=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[c,d]}),e[12]=c,e[13]=d,e[14]=f):f=e[14];let u=s?.totalSubscriptions??0,h;e[15]!==u?(h=u.toLocaleString(),e[15]=u,e[16]=h):h=e[16];let g;e[17]!==a?(g=a("active subscriptions"),e[17]=a,e[18]=g):g=e[18];let x;e[19]!==h||e[20]!==g?(x=(0,n.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[h," ",g]}),e[19]=h,e[20]=g,e[21]=x):x=e[21];let b;return e[22]!==x||e[23]!==o||e[24]!==f?(b=(0,n.jsx)(T,{"data-testid":"home-live-connections",children:(0,n.jsxs)(Fe,{className:"flex flex-col gap-2.5 py-4",children:[o,f,x]})}),e[22]=x,e[23]=o,e[24]=f,e[25]=b):b=e[25],b},"Mt"),jt=m(t=>{let e=(0,_.c)(7),{entries:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let o=Date.now(),l;e[3]!==a?(l=a("Recent activity"),e[3]=a,e[4]=l):l=e[4];let i;e[5]!==l?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l})}),e[5]=l,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-recent-activity",children:[i,s.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No recent activity.")}):(0,n.jsx)("ul",{className:"divide-y divide-border",children:s.slice(0,5).map(c=>(0,n.jsxs)("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-[13px]",children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"}),(0,n.jsxs)("span",{className:"truncate text-foreground",children:[c.op,c.table!==void 0&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",c.table,c.id===void 0?"":`#${c.id}`]})]})]}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:It(c.ts,o)})]},c.seq))})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"It"),Tt=m(t=>{let e=t.reduce((s,a)=>s+a.calls,0);return e===0?null:t.reduce((s,a)=>s+a.totalDurationMs,0)/e},"Tt"),Yt=m(t=>{let e=(0,_.c)(149),{initialShardKey:s}=t,a=$(),r=Be(),o=s??"",l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let i;e[1]!==o?(i={shardKey:o},e[1]=o,e[2]=i):i=e[2];let c=_e(z.getMetrics,l,i),p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p={},e[3]=p):p=e[3];let d;e[4]!==o?(d={shardKey:o},e[4]=o,e[5]=d):d=e[5];let f=_e(z.getFunctionStats,p,d),u,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(u={},h={shardKey:""},e[6]=u,e[7]=h):(u=e[6],h=e[7]);let g=_e(z.getSecurityAudit,u,h),x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x={},e[8]=x):x=e[8];let b;e[9]!==o?(b={shardKey:o},e[9]=o,e[10]=b):b=e[10];let v=_e(z.listSubscriptions,x,b),S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S={},e[11]=S):S=e[11];let M;e[12]!==o?(M={shardKey:o},e[12]=o,e[13]=M):M=e[13];let k=_e(z.getAuditLog,S,M),y=c.data??null,w,L,C,N,A,j,D,O,R,P,B,E,q,K,V,W,F,U;if(e[14]!==k.data||e[15]!==g.data||e[16]!==y||e[17]!==c.data||e[18]!==r||e[19]!==f.data||e[20]!==v.data||e[21]!==a){N=Array.isArray(f.data?.functions)?f.data.functions:[],D=v.data??null;let Le;e[40]!==k.data?(Le=Array.isArray(k.data?.entries)?k.data.entries:[],e[40]=k.data,e[41]=Le):Le=e[41],L=Le,A=c.data===void 0||f.data===void 0?null:tt(y,N).length,j=Array.isArray(g.data?.findings)?g.data.findings.length:null;let Ce;e[42]!==r?(Ce=m(()=>{Ne(r({to:"/security"}))},"we"),e[42]=r,e[43]=Ce):Ce=e[43],U=Ce;let Ie;e[44]!==r?(Ie=m(()=>{Ne(r({to:"/insights"}))},"$e"),e[44]=r,e[45]=Ie):Ie=e[45],F=Ie;let Me=nt(y?.history,"calls"),Ae=nt(y?.history,"errors"),Je=Tt(N),$e=Math.max(0,...N.map(qt)),je;e[46]!==y||e[47]!==a?(je=y===null?void 0:Ct(a,y.cache),e[46]=y,e[47]=a,e[48]=je):je=e[48],C=je,V="flex flex-col gap-6",W="lunora-home",B="grid gap-3 sm:grid-cols-2 xl:grid-cols-4",E="home-health";let Re=st(Me),xe;e[49]!==a?(xe=a("Requests"),e[49]=a,e[50]=xe):xe=e[50];let qe=y?.requests??0,be;e[51]!==qe?(be=qe.toLocaleString(),e[51]=qe,e[52]=be):be=e[52],e[53]!==Me||e[54]!==Re||e[55]!==xe||e[56]!==be?(q=(0,n.jsx)(Te,{delta:Re,label:xe,trend:Me,value:be}),e[53]=Me,e[54]=Re,e[55]=xe,e[56]=be,e[57]=q):q=e[57];let Ke=st(Ae,!1),ye;e[58]!==a?(ye=a("Errors"),e[58]=a,e[59]=ye):ye=e[59];let ze=y?.errors??0,ve;e[60]!==ze?(ve=ze.toLocaleString(),e[60]=ze,e[61]=ve):ve=e[61],e[62]!==Ae||e[63]!==Ke||e[64]!==ye||e[65]!==ve?(K=(0,n.jsx)(Te,{delta:Ke,label:ye,trend:Ae,value:ve}),e[62]=Ae,e[63]=Ke,e[64]=ye,e[65]=ve,e[66]=K):K=e[66],w=Te,e[67]!==$e||e[68]!==a?(O=$e>0?`${a("max")} ${He($e)}`:void 0,e[67]=$e,e[68]=a,e[69]=O):O=e[69],e[70]!==a?(R=a("Avg latency"),e[70]=a,e[71]=R):R=e[71],P=Je===null?"\u2014":He(Je),e[14]=k.data,e[15]=g.data,e[16]=y,e[17]=c.data,e[18]=r,e[19]=f.data,e[20]=v.data,e[21]=a,e[22]=w,e[23]=L,e[24]=C,e[25]=N,e[26]=A,e[27]=j,e[28]=D,e[29]=O,e[30]=R,e[31]=P,e[32]=B,e[33]=E,e[34]=q,e[35]=K,e[36]=V,e[37]=W,e[38]=F,e[39]=U}else w=e[22],L=e[23],C=e[24],N=e[25],A=e[26],j=e[27],D=e[28],O=e[29],R=e[30],P=e[31],B=e[32],E=e[33],q=e[34],K=e[35],V=e[36],W=e[37],F=e[38],U=e[39];let H;e[72]!==w||e[73]!==O||e[74]!==R||e[75]!==P?(H=(0,n.jsx)(w,{footer:O,label:R,value:P}),e[72]=w,e[73]=O,e[74]=R,e[75]=P,e[76]=H):H=e[76];let J;e[77]!==a?(J=a("Database size"),e[77]=a,e[78]=J):J=e[78];let Oe=y?.databaseSize??null,Y;e[79]!==Oe?(Y=Qe(Oe),e[79]=Oe,e[80]=Y):Y=e[80];let G;e[81]!==C||e[82]!==J||e[83]!==Y?(G=(0,n.jsx)(Te,{footer:C,label:J,value:Y}),e[81]=C,e[82]=J,e[83]=Y,e[84]=G):G=e[84];let Z;e[85]!==B||e[86]!==E||e[87]!==q||e[88]!==K||e[89]!==H||e[90]!==G?(Z=(0,n.jsxs)("div",{className:B,"data-testid":E,children:[q,K,H,G]}),e[85]=B,e[86]=E,e[87]=q,e[88]=K,e[89]=H,e[90]=G,e[91]=Z):Z=e[91];let Se;e[92]===Symbol.for("react.memo_cache_sentinel")?(Se=(0,n.jsx)(gt,{}),e[92]=Se):Se=e[92];let Q;e[93]!==N?(Q=(0,n.jsx)("div",{className:"lg:col-span-2",children:(0,n.jsx)(At,{functions:N})}),e[93]=N,e[94]=Q):Q=e[94];let X;e[95]!==D?(X=(0,n.jsx)($t,{subs:D}),e[95]=D,e[96]=X):X=e[96];let ee;e[97]!==L?(ee=(0,n.jsx)(jt,{entries:L}),e[97]=L,e[98]=ee):ee=e[98];let te;e[99]!==X||e[100]!==ee?(te=(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[X,ee]}),e[99]=X,e[100]=ee,e[101]=te):te=e[101];let ae;e[102]!==Q||e[103]!==te?(ae=(0,n.jsxs)("div",{className:"grid gap-3 lg:grid-cols-3",children:[Q,te]}),e[102]=Q,e[103]=te,e[104]=ae):ae=e[104];let ne;e[105]!==a?(ne=a("Advisors"),e[105]=a,e[106]=ne):ne=e[106];let se;e[107]!==ne?(se=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:ne}),e[107]=ne,e[108]=se):se=e[108];let re;e[109]!==A||e[110]!==j||e[111]!==a||e[112]!==F||e[113]!==U?(re=j===0&&A===0?(0,n.jsx)(Ye,{description:a("No security or performance issues detected."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{d:"M12 3 4 6v5c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V6l-8-3Z"}),(0,n.jsx)("path",{d:"m9 12 2 2 4-4"})]}),testId:"home-advisors-clear",title:a("No issues found")}):(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,n.jsx)(rt,{count:j,onView:U,testId:"home-security",title:a("Security findings")}),(0,n.jsx)(rt,{count:A,onView:F,testId:"home-performance",title:a("Performance issues")})]}),e[109]=A,e[110]=j,e[111]=a,e[112]=F,e[113]=U,e[114]=re):re=e[114];let oe;e[115]!==se||e[116]!==re?(oe=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-advisors",children:[se,re]}),e[115]=se,e[116]=re,e[117]=oe):oe=e[117];let le;e[118]!==a?(le=a("Get connected"),e[118]=a,e[119]=le):le=e[119];let ie;e[120]!==le?(ie=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:le}),e[120]=le,e[121]=ie):ie=e[121];let ce;e[122]!==a?(ce=a("Client SDK"),e[122]=a,e[123]=ce):ce=e[123];let de;e[124]!==ce?(de=(0,n.jsx)(Ue,{command:"npm i @lunora/client",label:ce}),e[124]=ce,e[125]=de):de=e[125];let me;e[126]!==a?(me=a("React"),e[126]=a,e[127]=me):me=e[127];let ue;e[128]!==me?(ue=(0,n.jsx)(Ue,{command:"npm i @lunora/react",label:me}),e[128]=me,e[129]=ue):ue=e[129];let pe;e[130]!==a?(pe=a("CLI"),e[130]=a,e[131]=pe):pe=e[131];let fe;e[132]!==pe?(fe=(0,n.jsx)(Ue,{command:"lunora dev",label:pe}),e[132]=pe,e[133]=fe):fe=e[133];let he;e[134]!==de||e[135]!==ue||e[136]!==fe?(he=(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[de,ue,fe]}),e[134]=de,e[135]=ue,e[136]=fe,e[137]=he):he=e[137];let ke;e[138]===Symbol.for("react.memo_cache_sentinel")?(ke=(0,n.jsx)(wt,{}),e[138]=ke):ke=e[138];let ge;e[139]!==ie||e[140]!==he?(ge=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-get-connected",children:[ie,he,ke]}),e[139]=ie,e[140]=he,e[141]=ge):ge=e[141];let we;return e[142]!==V||e[143]!==W||e[144]!==Z||e[145]!==ae||e[146]!==oe||e[147]!==ge?(we=(0,n.jsxs)("div",{className:V,"data-testid":W,children:[Z,Se,ae,oe,ge]}),e[142]=V,e[143]=W,e[144]=Z,e[145]=ae,e[146]=oe,e[147]=ge,e[148]=we):we=e[148],we},"Yt");function Ot(t,e){return e.calls-t.calls}m(Ot,"Ot");function Rt(t){return(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] items-center gap-4 px-4 py-2 text-[13px]",children:[(0,n.jsx)("span",{className:"truncate font-mono text-xs text-foreground",children:t.path}),(0,n.jsx)("span",{className:"text-end tabular-nums",children:t.calls.toLocaleString()}),(0,n.jsx)("span",{className:"w-12 text-end tabular-nums text-muted-foreground",children:He(t.calls>0?t.totalDurationMs/t.calls:0)}),(0,n.jsx)("span",{className:Ee("w-8 text-end tabular-nums",t.errors>0?"text-destructive":"text-muted-foreground"),children:t.errors})]},t.path)}m(Rt,"Rt");function qt(t){return t.maxDurationMs}m(qt,"Et");export{ut as a,Yt as b};
|
|
3
|
+
`)},"_t"),kt=1500,wt=m(()=>{let t=(0,_.c)(35),e=$(),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=Xe(),t[0]=s):s=t[0];let a=s,[r,o]=(0,I.useState)(null),l,i;t[1]!==r?(l=m(()=>{if(r===null)return;let A=globalThis.setTimeout(()=>{o(null)},kt);return()=>{globalThis.clearTimeout(A)}},"r"),i=[r],t[1]=r,t[2]=l,t[3]=i):(l=t[2],i=t[3]),(0,I.useEffect)(l,i);let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=m((A,j)=>{et(j)&&o(A)},"c"),t[4]=c):c=t[4];let p=c,d;t[5]===Symbol.for("react.memo_cache_sentinel")?(d=m(()=>{p("config",_t(a))},"d"),t[5]=d):d=t[5];let f=d,u;t[6]===Symbol.for("react.memo_cache_sentinel")?(u=m(()=>{p("prompt",St(a))},"u"),t[6]=u):u=t[6];let h=u,g;t[7]!==e?(g=e("Connect an AI agent"),t[7]=e,t[8]=g):g=t[8];let x;t[9]!==g?(x=(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:g}),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==e?(b=e("Drive this deployment from an AI agent over the Model Context Protocol \u2014 it can list functions and tables, read schemas, and run read-only queries. Writes stay off unless you opt in."),t[11]=e,t[12]=b):b=t[12];let v;t[13]!==b?(v=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:b}),t[13]=b,t[14]=v):v=t[14];let S;t[15]!==x||t[16]!==v?(S=(0,n.jsxs)("div",{className:"flex flex-col gap-1.5 p-4",children:[x,v]}),t[15]=x,t[16]=v,t[17]=S):S=t[17];let M;t[18]===Symbol.for("react.memo_cache_sentinel")?(M=(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground","data-testid":"home-connect-agent-command",children:"npx -y @lunora/mcp"}),t[18]=M):M=t[18];let k;t[19]!==r||t[20]!==e?(k=e(r==="config"?"Copied":"Copy MCP config"),t[19]=r,t[20]=e,t[21]=k):k=t[21];let y;t[22]!==k?(y=(0,n.jsx)(We,{"data-testid":"home-connect-agent-copy-config",onClick:f,size:"xs",variant:"outline",children:k}),t[22]=k,t[23]=y):y=t[23];let w;t[24]!==r||t[25]!==e?(w=e(r==="prompt"?"Copied":"Copy agent prompt"),t[24]=r,t[25]=e,t[26]=w):w=t[26];let L;t[27]!==w?(L=(0,n.jsx)(We,{"data-testid":"home-connect-agent-copy-prompt",onClick:h,size:"xs",variant:"outline",children:w}),t[27]=w,t[28]=L):L=t[28];let C;t[29]!==y||t[30]!==L?(C=(0,n.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-muted/50 px-4 py-3",children:[M,(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[y,L]})]}),t[29]=y,t[30]=L,t[31]=C):C=t[31];let N;return t[32]!==S||t[33]!==C?(N=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-connect-agent",children:[S,C]}),t[32]=S,t[33]=C,t[34]=N):N=t[34],N},"kt"),Lt=(0,I.lazy)(()=>import("./chunk-ZGMGMEFM.js")),Ct=m((t,e)=>{if(e==null)return t("cache not enabled");let s=e.hits+e.misses;return s===0?t("no cache traffic yet"):`${Math.round(e.hits/s*100).toString()}% ${t("cache hit")}`},"wt"),He=m(t=>{if(t<1e3)return`${String(Math.round(t))}ms`;let e=t>=1e4?0:1;return`${(t/1e3).toFixed(e)}s`},"De"),It=m((t,e)=>{let s=Math.max(0,Math.round((e-t)/1e3));if(s<60)return`${String(s)}s ago`;let a=Math.round(s/60);if(a<60)return`${String(a)}m ago`;let r=Math.round(a/60);return r<24?`${String(r)}h ago`:`${String(Math.round(r/24))}d ago`},"$t"),nt=m((t,e)=>{if(t===void 0||t.length===0)return[];let s=new Map;for(let a of t)s.set(a.bucketMs,(s.get(a.bucketMs)??0)+a[e]);return[...s.entries()].toSorted(([a],[r])=>a-r).map(([,a])=>a)},"Ve"),st=m((t,e=!0)=>{if(t.length<4)return null;let s=Math.floor(t.length/2),a=t.slice(0,s).reduce((l,i)=>l+i,0),r=t.slice(s).reduce((l,i)=>l+i,0);if(a===0)return null;let o=(r-a)/a*100;return{positive:e?o>=0:o<=0,text:`${o>=0?"+":""}${o.toFixed(1)}%`}},"We"),Te=m(t=>{let e=(0,_.c)(24),{delta:s,footer:a,label:r,trend:o,unit:l,value:i}=t,c=$(),p;e[0]!==r?(p=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=p):p=e[1];let d;e[2]!==i?(d=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[2]=i,e[3]=d):d=e[3];let f;e[4]!==l?(f=l!==void 0&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:l}),e[4]=l,e[5]=f):f=e[5];let u;e[6]!==d||e[7]!==f?(u=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[d,f]}),e[6]=d,e[7]=f,e[8]=u):u=e[8];let h;e[9]!==o?(h=o!==void 0&&(0,n.jsx)(I.Suspense,{fallback:(0,n.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28"}),children:(0,n.jsx)(Lt,{data:o})}),e[9]=o,e[10]=h):h=e[10];let g;e[11]!==u||e[12]!==h?(g=(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,h]}),e[11]=u,e[12]=h,e[13]=g):g=e[13];let x;e[14]!==p||e[15]!==g?(x=(0,n.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]}),e[14]=p,e[15]=g,e[16]=x):x=e[16];let b;e[17]!==s||e[18]!==a||e[19]!==c?(b=s==null?a!=null&&(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:a}):(0,n.jsxs)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px]",children:[(0,n.jsx)("span",{className:Ee("font-semibold",s.positive?"text-success":"text-destructive"),children:s.text})," ",(0,n.jsx)("span",{className:"text-muted-foreground",children:c("vs. prev.")})]}),e[17]=s,e[18]=a,e[19]=c,e[20]=b):b=e[20];let v;return e[21]!==x||e[22]!==b?(v=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[x,b]}),e[21]=x,e[22]=b,e[23]=v):v=e[23],v},"Te"),Mt=m(()=>{let t=(0,_.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"m9 6 6 6-6 6"})}),t[0]=e):e=t[0],e},"At"),Ue=m(t=>{let e=(0,_.c)(7),{command:s,label:a}=t,r;e[0]!==a?(r=(0,n.jsx)("div",{className:"p-4",children:(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:a})}),e[0]=a,e[1]=r):r=e[1];let o;e[2]!==s?(o=(0,n.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5",children:(0,n.jsx)("code",{className:"font-mono text-xs text-muted-foreground",children:s})}),e[2]=s,e[3]=o):o=e[3];let l;return e[4]!==r||e[5]!==o?(l=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0",children:[r,o]}),e[4]=r,e[5]=o,e[6]=l):l=e[6],l},"Be"),rt=m(t=>{let e=(0,_.c)(18),{count:s,onView:a,testId:r,title:o}=t,l=$(),i;e[0]!==o?(i=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o}),e[0]=o,e[1]=i):i=e[1];let c;e[2]!==s||e[3]!==l?(c=s===null?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:l("No data yet")}):(0,n.jsx)(Ve,{variant:s>0?"destructive":"success",children:s>0?s:l("All clear")}),e[2]=s,e[3]=l,e[4]=c):c=e[4];let p;e[5]!==i||e[6]!==c?(p=(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2 p-4",children:[i,c]}),e[5]=i,e[6]=c,e[7]=p):p=e[7];let d;e[8]!==l?(d=l("View"),e[8]=l,e[9]=d):d=e[9];let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,n.jsx)(Mt,{}),e[10]=f):f=e[10];let u;e[11]!==a||e[12]!==d?(u=(0,n.jsxs)("button",{className:"flex items-center gap-1 border-t border-border bg-muted/50 px-4 py-2.5 text-[12px] font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted",onClick:a,type:"button",children:[d,f]}),e[11]=a,e[12]=d,e[13]=u):u=e[13];let h;return e[14]!==p||e[15]!==u||e[16]!==r?(h=(0,n.jsxs)(T,{className:"justify-between gap-0 py-0","data-testid":r,children:[p,u]}),e[14]=p,e[15]=u,e[16]=r,e[17]=h):h=e[17],h},"Qe"),At=m(t=>{let e=(0,_.c)(7),{functions:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let o=[...s].toSorted(Ot).slice(0,5),l;e[3]!==a?(l=a("Top functions"),e[3]=a,e[4]=l):l=e[4];let i;e[5]!==l?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l})}),e[5]=l,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-top-functions",children:[i,o.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No functions called yet.")}):(0,n.jsxs)("div",{className:"divide-y divide-border",children:[(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] gap-4 px-4 py-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:[(0,n.jsx)("span",{children:a("Function")}),(0,n.jsx)("span",{className:"text-end",children:a("Calls")}),(0,n.jsx)("span",{className:"w-12 text-end",children:a("Avg")}),(0,n.jsx)("span",{className:"w-8 text-end",children:a("Err")})]}),o.map(Rt)]})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"Lt"),$t=m(t=>{let e=(0,_.c)(26),{subs:s}=t,a=$(),r;e[0]!==a?(r=a("Live connections"),e[0]=a,e[1]=r):r=e[1];let o;e[2]!==r?(o=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[2]=r,e[3]=o):o=e[3];let l=s?.totalConnections??0,i;e[4]!==l?(i=l.toLocaleString(),e[4]=l,e[5]=i):i=e[5];let c;e[6]!==i?(c=(0,n.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:i}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==a?(p=a("sockets"),e[8]=a,e[9]=p):p=e[9];let d;e[10]!==p?(d=(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p}),e[10]=p,e[11]=d):d=e[11];let f;e[12]!==c||e[13]!==d?(f=(0,n.jsxs)("span",{className:"flex items-baseline gap-1.5",children:[c,d]}),e[12]=c,e[13]=d,e[14]=f):f=e[14];let u=s?.totalSubscriptions??0,h;e[15]!==u?(h=u.toLocaleString(),e[15]=u,e[16]=h):h=e[16];let g;e[17]!==a?(g=a("active subscriptions"),e[17]=a,e[18]=g):g=e[18];let x;e[19]!==h||e[20]!==g?(x=(0,n.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:[h," ",g]}),e[19]=h,e[20]=g,e[21]=x):x=e[21];let b;return e[22]!==x||e[23]!==o||e[24]!==f?(b=(0,n.jsx)(T,{"data-testid":"home-live-connections",children:(0,n.jsxs)(Fe,{className:"flex flex-col gap-2.5 py-4",children:[o,f,x]})}),e[22]=x,e[23]=o,e[24]=f,e[25]=b):b=e[25],b},"Mt"),jt=m(t=>{let e=(0,_.c)(7),{entries:s}=t,a=$(),r;if(e[0]!==s||e[1]!==a){let o=Date.now(),l;e[3]!==a?(l=a("Recent activity"),e[3]=a,e[4]=l):l=e[4];let i;e[5]!==l?(i=(0,n.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l})}),e[5]=l,e[6]=i):i=e[6],r=(0,n.jsxs)(T,{className:"gap-0 py-0","data-testid":"home-recent-activity",children:[i,s.length===0?(0,n.jsx)("p",{className:"px-4 py-8 text-center text-xs text-muted-foreground",children:a("No recent activity.")}):(0,n.jsx)("ul",{className:"divide-y divide-border",children:s.slice(0,5).map(c=>(0,n.jsxs)("li",{className:"flex items-center justify-between gap-3 px-4 py-2 text-[13px]",children:[(0,n.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"size-1.5 shrink-0 rounded-full bg-muted-foreground/40"}),(0,n.jsxs)("span",{className:"truncate text-foreground",children:[c.op,c.table!==void 0&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",c.table,c.id===void 0?"":`#${c.id}`]})]})]}),(0,n.jsx)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:It(c.ts,o)})]},c.seq))})]}),e[0]=s,e[1]=a,e[2]=r}else r=e[2];return r},"It"),Tt=m(t=>{let e=t.reduce((s,a)=>s+a.calls,0);return e===0?null:t.reduce((s,a)=>s+a.totalDurationMs,0)/e},"Tt"),Yt=m(t=>{let e=(0,_.c)(149),{initialShardKey:s}=t,a=$(),r=Be(),o=s??"",l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let i;e[1]!==o?(i={shardKey:o},e[1]=o,e[2]=i):i=e[2];let c=_e(z.getMetrics,l,i),p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p={},e[3]=p):p=e[3];let d;e[4]!==o?(d={shardKey:o},e[4]=o,e[5]=d):d=e[5];let f=_e(z.getFunctionStats,p,d),u,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(u={},h={shardKey:""},e[6]=u,e[7]=h):(u=e[6],h=e[7]);let g=_e(z.getSecurityAudit,u,h),x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x={},e[8]=x):x=e[8];let b;e[9]!==o?(b={shardKey:o},e[9]=o,e[10]=b):b=e[10];let v=_e(z.listSubscriptions,x,b),S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S={},e[11]=S):S=e[11];let M;e[12]!==o?(M={shardKey:o},e[12]=o,e[13]=M):M=e[13];let k=_e(z.getAuditLog,S,M),y=c.data??null,w,L,C,N,A,j,D,O,R,P,B,E,q,K,V,W,F,U;if(e[14]!==k.data||e[15]!==g.data||e[16]!==y||e[17]!==c.data||e[18]!==r||e[19]!==f.data||e[20]!==v.data||e[21]!==a){N=Array.isArray(f.data?.functions)?f.data.functions:[],D=v.data??null;let Le;e[40]!==k.data?(Le=Array.isArray(k.data?.entries)?k.data.entries:[],e[40]=k.data,e[41]=Le):Le=e[41],L=Le,A=c.data===void 0||f.data===void 0?null:tt(y,N).length,j=Array.isArray(g.data?.findings)?g.data.findings.length:null;let Ce;e[42]!==r?(Ce=m(()=>{Ne(r({to:"/security"}))},"we"),e[42]=r,e[43]=Ce):Ce=e[43],U=Ce;let Ie;e[44]!==r?(Ie=m(()=>{Ne(r({to:"/insights"}))},"$e"),e[44]=r,e[45]=Ie):Ie=e[45],F=Ie;let Me=nt(y?.history,"calls"),Ae=nt(y?.history,"errors"),Je=Tt(N),$e=Math.max(0,...N.map(qt)),je;e[46]!==y||e[47]!==a?(je=y===null?void 0:Ct(a,y.cache),e[46]=y,e[47]=a,e[48]=je):je=e[48],C=je,V="flex flex-col gap-6",W="lunora-home",B="grid gap-3 sm:grid-cols-2 xl:grid-cols-4",E="home-health";let Re=st(Me),xe;e[49]!==a?(xe=a("Requests"),e[49]=a,e[50]=xe):xe=e[50];let qe=y?.requests??0,be;e[51]!==qe?(be=qe.toLocaleString(),e[51]=qe,e[52]=be):be=e[52],e[53]!==Me||e[54]!==Re||e[55]!==xe||e[56]!==be?(q=(0,n.jsx)(Te,{delta:Re,label:xe,trend:Me,value:be}),e[53]=Me,e[54]=Re,e[55]=xe,e[56]=be,e[57]=q):q=e[57];let Ke=st(Ae,!1),ye;e[58]!==a?(ye=a("Errors"),e[58]=a,e[59]=ye):ye=e[59];let ze=y?.errors??0,ve;e[60]!==ze?(ve=ze.toLocaleString(),e[60]=ze,e[61]=ve):ve=e[61],e[62]!==Ae||e[63]!==Ke||e[64]!==ye||e[65]!==ve?(K=(0,n.jsx)(Te,{delta:Ke,label:ye,trend:Ae,value:ve}),e[62]=Ae,e[63]=Ke,e[64]=ye,e[65]=ve,e[66]=K):K=e[66],w=Te,e[67]!==$e||e[68]!==a?(O=$e>0?`${a("max")} ${He($e)}`:void 0,e[67]=$e,e[68]=a,e[69]=O):O=e[69],e[70]!==a?(R=a("Avg latency"),e[70]=a,e[71]=R):R=e[71],P=Je===null?"\u2014":He(Je),e[14]=k.data,e[15]=g.data,e[16]=y,e[17]=c.data,e[18]=r,e[19]=f.data,e[20]=v.data,e[21]=a,e[22]=w,e[23]=L,e[24]=C,e[25]=N,e[26]=A,e[27]=j,e[28]=D,e[29]=O,e[30]=R,e[31]=P,e[32]=B,e[33]=E,e[34]=q,e[35]=K,e[36]=V,e[37]=W,e[38]=F,e[39]=U}else w=e[22],L=e[23],C=e[24],N=e[25],A=e[26],j=e[27],D=e[28],O=e[29],R=e[30],P=e[31],B=e[32],E=e[33],q=e[34],K=e[35],V=e[36],W=e[37],F=e[38],U=e[39];let H;e[72]!==w||e[73]!==O||e[74]!==R||e[75]!==P?(H=(0,n.jsx)(w,{footer:O,label:R,value:P}),e[72]=w,e[73]=O,e[74]=R,e[75]=P,e[76]=H):H=e[76];let J;e[77]!==a?(J=a("Database size"),e[77]=a,e[78]=J):J=e[78];let Oe=y?.databaseSize??null,Y;e[79]!==Oe?(Y=Qe(Oe),e[79]=Oe,e[80]=Y):Y=e[80];let G;e[81]!==C||e[82]!==J||e[83]!==Y?(G=(0,n.jsx)(Te,{footer:C,label:J,value:Y}),e[81]=C,e[82]=J,e[83]=Y,e[84]=G):G=e[84];let Z;e[85]!==B||e[86]!==E||e[87]!==q||e[88]!==K||e[89]!==H||e[90]!==G?(Z=(0,n.jsxs)("div",{className:B,"data-testid":E,children:[q,K,H,G]}),e[85]=B,e[86]=E,e[87]=q,e[88]=K,e[89]=H,e[90]=G,e[91]=Z):Z=e[91];let Se;e[92]===Symbol.for("react.memo_cache_sentinel")?(Se=(0,n.jsx)(gt,{}),e[92]=Se):Se=e[92];let Q;e[93]!==N?(Q=(0,n.jsx)("div",{className:"lg:col-span-2",children:(0,n.jsx)(At,{functions:N})}),e[93]=N,e[94]=Q):Q=e[94];let X;e[95]!==D?(X=(0,n.jsx)($t,{subs:D}),e[95]=D,e[96]=X):X=e[96];let ee;e[97]!==L?(ee=(0,n.jsx)(jt,{entries:L}),e[97]=L,e[98]=ee):ee=e[98];let te;e[99]!==X||e[100]!==ee?(te=(0,n.jsxs)("div",{className:"flex flex-col gap-3",children:[X,ee]}),e[99]=X,e[100]=ee,e[101]=te):te=e[101];let ae;e[102]!==Q||e[103]!==te?(ae=(0,n.jsxs)("div",{className:"grid gap-3 lg:grid-cols-3",children:[Q,te]}),e[102]=Q,e[103]=te,e[104]=ae):ae=e[104];let ne;e[105]!==a?(ne=a("Advisors"),e[105]=a,e[106]=ne):ne=e[106];let se;e[107]!==ne?(se=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:ne}),e[107]=ne,e[108]=se):se=e[108];let re;e[109]!==A||e[110]!==j||e[111]!==a||e[112]!==F||e[113]!==U?(re=j===0&&A===0?(0,n.jsx)(Ye,{description:a("No security or performance issues detected."),icon:(0,n.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,n.jsx)("path",{d:"M12 3 4 6v5c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V6l-8-3Z"}),(0,n.jsx)("path",{d:"m9 12 2 2 4-4"})]}),testId:"home-advisors-clear",title:a("No issues found")}):(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,n.jsx)(rt,{count:j,onView:U,testId:"home-security",title:a("Security findings")}),(0,n.jsx)(rt,{count:A,onView:F,testId:"home-performance",title:a("Performance issues")})]}),e[109]=A,e[110]=j,e[111]=a,e[112]=F,e[113]=U,e[114]=re):re=e[114];let oe;e[115]!==se||e[116]!==re?(oe=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-advisors",children:[se,re]}),e[115]=se,e[116]=re,e[117]=oe):oe=e[117];let le;e[118]!==a?(le=a("Get connected"),e[118]=a,e[119]=le):le=e[119];let ie;e[120]!==le?(ie=(0,n.jsx)("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:le}),e[120]=le,e[121]=ie):ie=e[121];let ce;e[122]!==a?(ce=a("Client SDK"),e[122]=a,e[123]=ce):ce=e[123];let de;e[124]!==ce?(de=(0,n.jsx)(Ue,{command:"npm i @lunora/client",label:ce}),e[124]=ce,e[125]=de):de=e[125];let me;e[126]!==a?(me=a("React"),e[126]=a,e[127]=me):me=e[127];let ue;e[128]!==me?(ue=(0,n.jsx)(Ue,{command:"npm i @lunora/react",label:me}),e[128]=me,e[129]=ue):ue=e[129];let pe;e[130]!==a?(pe=a("CLI"),e[130]=a,e[131]=pe):pe=e[131];let fe;e[132]!==pe?(fe=(0,n.jsx)(Ue,{command:"lunora dev",label:pe}),e[132]=pe,e[133]=fe):fe=e[133];let he;e[134]!==de||e[135]!==ue||e[136]!==fe?(he=(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[de,ue,fe]}),e[134]=de,e[135]=ue,e[136]=fe,e[137]=he):he=e[137];let ke;e[138]===Symbol.for("react.memo_cache_sentinel")?(ke=(0,n.jsx)(wt,{}),e[138]=ke):ke=e[138];let ge;e[139]!==ie||e[140]!==he?(ge=(0,n.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"home-get-connected",children:[ie,he,ke]}),e[139]=ie,e[140]=he,e[141]=ge):ge=e[141];let we;return e[142]!==V||e[143]!==W||e[144]!==Z||e[145]!==ae||e[146]!==oe||e[147]!==ge?(we=(0,n.jsxs)("div",{className:V,"data-testid":W,children:[Z,Se,ae,oe,ge]}),e[142]=V,e[143]=W,e[144]=Z,e[145]=ae,e[146]=oe,e[147]=ge,e[148]=we):we=e[148],we},"Yt");function Ot(t,e){return e.calls-t.calls}m(Ot,"Ot");function Rt(t){return(0,n.jsxs)("div",{className:"grid grid-cols-[1fr_auto_auto_auto] items-center gap-4 px-4 py-2 text-[13px]",children:[(0,n.jsx)("span",{className:"truncate font-mono text-xs text-foreground",children:t.path}),(0,n.jsx)("span",{className:"text-end tabular-nums",children:t.calls.toLocaleString()}),(0,n.jsx)("span",{className:"w-12 text-end tabular-nums text-muted-foreground",children:He(t.calls>0?t.totalDurationMs/t.calls:0)}),(0,n.jsx)("span",{className:Ee("w-8 text-end tabular-nums",t.errors>0?"text-destructive":"text-muted-foreground"),children:t.errors})]},t.path)}m(Rt,"Rt");function qt(t){return t.maxDurationMs}m(qt,"Et");export{ut as a,Yt as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G}from"./chunk-EA2JKR5D.js";import{a as x}from"./chunk-IMOHEGMV.js";import{a as U}from"./chunk-2DX5MROH.js";import{b as M}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as O}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as p}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as w}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{f as D}from"./chunk-
|
|
1
|
+
import{a as G}from"./chunk-EA2JKR5D.js";import{a as x}from"./chunk-IMOHEGMV.js";import{a as U}from"./chunk-2DX5MROH.js";import{b as M}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as O}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as p}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as w}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{f as D}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{d as K,e as _,f as z,h as B,o as P,r as q}from"./chunk-FODLDLE2.js";import{a as s,d as J,e as ie,g as oe}from"./chunk-YKXDMIHQ.js";var i=J(ie(),1);var e=J(oe(),1);var de=s(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"oe"),le=s(r=>r===void 0||r.length===0?"()":`(${r.map(o=>`${o.name}${o.optional?"?":""}: ${de(o)}`).join(", ")})`,"ie"),ce=s(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"de"),ue=s(r=>{let o={};for(let a of r??[])a.optional||(o[a.name]=ce(a.kind));return JSON.stringify(o,void 0,2)},"le"),me=z(E.runAs),fe=10,he=s(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"me"),Fe=s(({functions:r,runAsIdentity:o=!1}={})=>{let a=K(),u=D(),[H,Q]=(0,i.useState)(null),[k,V]=(0,i.useState)(null),g=r??H??[],[I,S]=(0,i.useState)(""),[m,b]=(0,i.useState)("{}"),[c,F]=(0,i.useState)(""),[f,W]=(0,i.useState)(""),[v,h]=(0,i.useState)("idle"),[X,y]=(0,i.useState)(void 0),[C,N]=(0,i.useState)(null),[$,Y]=(0,i.useState)([]);(0,i.useEffect)(()=>{if(r!==void 0)return;let t=!1;return u.listFunctions().then(d=>(t||Q(d),d)).catch(d=>{t||V(B(d))}),()=>{t=!0}},[u,r]);let A=I===""?g[0]?.path??"":I,n=g.find(t=>t.path===A),Z=s(async()=>{if(!n)return;let t;try{t=m.trim()===""?{}:JSON.parse(m)}catch(l){h("error"),y(void 0),N(a("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:n.path},R=c.trim()===""?{}:{shardKey:c.trim()},j=o?f.trim():"",L=s(l=>{Y(T=>[{argsText:m,at:Date.now(),id:(T[0]?.id??0)+1,kind:n.kind,path:n.path,shardKey:c,status:l},...T].slice(0,fe))},"$");h("running"),N(null);try{let l=j===""?await _(u,n.kind,d,t,R):await u.query(me,{args:t,functionPath:n.path,userId:j},R);M(c),y(l),h("success"),L("success")}catch(l){y(void 0),N(l.message),h("error"),L("error")}},"J"),ee=s(t=>{S(t.path),b(t.argsText),F(t.shardKey)},"M"),te=s(t=>{S(t.target.value)},"P"),re=s(t=>{b(t.target.value)},"z"),ae=s(t=>{W(t.target.value)},"q"),se=s(()=>{P(Z())},"H"),ne=s(()=>{b(ue(n?.args))},"V");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(x,{htmlFor:"function-select",children:a("Function")}),(0,e.jsx)("select",{"aria-label":a("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:A,children:g.map(t=>(0,e.jsxs)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path))}),n!==void 0&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"mr-1.5 font-medium",children:a("Signature")}),(0,e.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:le(n.args)})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)(x,{htmlFor:"args-input",children:a("Arguments")}),(0,e.jsx)(p,{"data-testid":"prefill-button",disabled:n===void 0,onClick:ne,size:"xs",type:"button",variant:"ghost",children:a("Prefill")})]}),(0,e.jsx)(G,{"aria-label":a("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:m})]}),(0,e.jsx)(U,{onChange:F,testId:"shard-input",value:c}),o&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsx)(x,{htmlFor:"run-as-input",children:a("Run as identity (userId)")}),(0,e.jsx)(O,{"aria-label":a("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:ae,placeholder:a("Leave empty to run as admin"),value:f}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(p,{"data-testid":"run-button",disabled:v==="running"||n===void 0,onClick:se,type:"button",children:a("Run")}),n!==void 0&&(0,e.jsx)(w,{variant:"outline",children:n.kind}),o&&f.trim()!==""&&(0,e.jsx)(w,{"data-testid":"run-as-badge",variant:"secondary",children:a("as {userId}",{userId:f.trim()})})]})]}),v==="error"&&C!==null&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C}),v==="success"&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:he(X)}),$.length>0&&(0,e.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:$.map((t,d)=>(0,e.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsx)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"})," ",(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]})," ",(0,e.jsx)("time",{className:"text-xs text-muted-foreground",children:q(t.at)})," ",(0,e.jsx)(p,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:s(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Load")})]},t.id))})]})},"Ae");export{Fe as FunctionRunner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as na}from"./chunk-5XRNQ732.js";import"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as Me}from"./chunk-IMOHEGMV.js";import{a as ra}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 ta}from"./chunk-PD6WIDY6.js";import{a as Ye}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as Ge}from"./chunk-OGUKYRFM.js";import{d as Je,e as Ae}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Pe}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as Ue}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as Be}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Se}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as le}from"./chunk-SDHFSBNM.js";import{f as Ee}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as $e}from"./chunk-FKVZRPV5.js";import{a as Ze,b as ea,c as aa,d as Fe,e as q,f as C}from"./chunk-HEAQVSNS.js";import{a as We,e as ze}from"./chunk-WUWBZPUK.js";import{d as de,f as He,g as Qe,h as Ve,o as we,r as Ne}from"./chunk-FODLDLE2.js";import{a as s,d as se,e as De,f as Le,g as _e,i as oe}from"./chunk-YKXDMIHQ.js";var he=se(Le(),1),me=se(De(),1);var ia=se(Le(),1);var S=se(De(),1);var c=se(_e(),1);var xa=He(R.runMigration),sa=s(a=>{let e=(0,ia.c)(98),{initialShardKey:n}=a,r=Ee(),t=de(),{queryShardKey:l,setShardKey:i,shardKey:o}=Ye(n),[u,b]=(0,S.useState)(""),[h,v]=(0,S.useState)("up"),[p,g]=(0,S.useState)(!0),[f,y]=(0,S.useState)(!1),[x,m]=(0,S.useState)(null),[$,k]=(0,S.useState)(null),K;e[0]!==o?(K=o.trim(),e[0]=o,e[1]=K):K=e[1];let I=K===l,O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O={},e[2]=O):O=e[2];let F;e[3]!==l?(F={live:!0,shardKey:l},e[3]=l,e[4]=F):F=e[4];let w=le(R.migrationStatus,O,F),N=w.data?.migrations??null,Oe=w.error,{errorSource:qe,liveError:Ce}=w,pe,fe;e[5]!==l||e[6]!==w.data?(pe=s(()=>{w.data!==void 0&&Ge(l)},"W"),fe=[w.data,l],e[5]=l,e[6]=w.data,e[7]=pe,e[8]=fe):(pe=e[7],fe=e[8]),(0,S.useEffect)(pe,fe);let ge;if(e[9]!==r||e[10]!==h||e[11]!==p||e[12]!==u||e[13]!==o||e[14]!==w||e[15]!==t){let M=s(async()=>{let Te=u.trim();if(Te===""){k(t("Enter a migration id")),m(null);return}y(!0),k(null);try{let Ie=await r.query(xa,{direction:h,dryRun:p,id:Te},Qe(o));m(Ie),w.refetch()}catch(Ie){let va=Ie;m(null),k(Ve(va))}y(!1)},"m");ge=s(()=>{we(M())},"V"),e[9]=r,e[10]=h,e[11]=p,e[12]=u,e[13]=o,e[14]=w,e[15]=t,e[16]=ge}else ge=e[16];let be=ge,ve;e[17]===Symbol.for("react.memo_cache_sentinel")?(ve=s(M=>{b(M.target.value)},"Y"),e[17]=ve):ve=e[17];let fa=ve,xe;e[18]===Symbol.for("react.memo_cache_sentinel")?(xe=s(M=>{v(M.target.value==="down"?"down":"up")},"Z"),e[18]=xe):xe=e[18];let ga=xe,ye;e[19]===Symbol.for("react.memo_cache_sentinel")?(ye=s(M=>{g(M.target.checked)},"ee"),e[19]=ye):ye=e[19];let ba=ye,T;e[20]!==i||e[21]!==o?(T=(0,c.jsx)(Xe,{onChange:i,testId:"mg-shard-input",value:o}),e[20]=i,e[21]=o,e[22]=T):T=e[22];let D;e[23]!==Ce?(D=(0,c.jsx)(ra,{message:Ce,prefix:"mg"}),e[23]=Ce,e[24]=D):D=e[24];let L;e[25]!==T||e[26]!==D?(L=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[T,D]}),e[25]=T,e[26]=D,e[27]=L):L=e[27];let _;e[28]!==Oe||e[29]!==qe?(_=Oe!==null&&(0,c.jsx)(Se,{error:qe,testId:"mg-status-error"}),e[28]=Oe,e[29]=qe,e[30]=_):_=e[30];let E;e[31]!==N||e[32]!==t?(E=N!==null&&N.length===0&&(0,c.jsx)($e,{description:t("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:t("No migrations have run on this shard.")}),e[31]=N,e[32]=t,e[33]=E):E=e[33];let J;e[34]!==N||e[35]!==t?(J=N!==null&&N.length>0&&(0,c.jsx)(We,{className:"overflow-hidden py-0",children:(0,c.jsx)(ze,{className:"px-0",children:(0,c.jsxs)(Ze,{"data-testid":"mg-table",children:[(0,c.jsx)(ea,{children:(0,c.jsxs)(Fe,{children:[(0,c.jsx)(q,{children:t("id")}),(0,c.jsx)(q,{children:t("direction")}),(0,c.jsx)(q,{children:t("status")}),(0,c.jsx)(q,{children:t("processed")}),(0,c.jsx)(q,{children:t("changed")}),(0,c.jsx)(q,{children:t("updated")}),(0,c.jsx)(q,{children:t("error")})]})}),(0,c.jsx)(aa,{children:N.map(ya)})]})})}),e[34]=N,e[35]=t,e[36]=J):J=e[36];let A;e[37]!==t?(A=t("Run migration"),e[37]=t,e[38]=A):A=e[38];let B;e[39]!==A?(B=(0,c.jsx)(Me,{children:A}),e[39]=A,e[40]=B):B=e[40];let P;e[41]!==t?(P=t("Migration id"),e[41]=t,e[42]=P):P=e[42];let U;e[43]!==t?(U=t("migration id"),e[43]=t,e[44]=U):U=e[44];let W;e[45]!==u||e[46]!==P||e[47]!==U?(W=(0,c.jsx)(Pe,{"aria-label":P,className:"w-auto","data-testid":"mg-id-input",onChange:fa,placeholder:U,value:u}),e[45]=u,e[46]=P,e[47]=U,e[48]=W):W=e[48];let z;e[49]!==t?(z=t("Direction"),e[49]=t,e[50]=z):z=e[50];let H;e[51]!==t?(H=t("up"),e[51]=t,e[52]=H):H=e[52];let Q;e[53]!==H?(Q=(0,c.jsx)("option",{value:"up",children:H}),e[53]=H,e[54]=Q):Q=e[54];let V;e[55]!==t?(V=t("down"),e[55]=t,e[56]=V):V=e[56];let G;e[57]!==V?(G=(0,c.jsx)("option",{value:"down",children:V}),e[57]=V,e[58]=G):G=e[58];let X;e[59]!==h||e[60]!==z||e[61]!==Q||e[62]!==G?(X=(0,c.jsxs)("select",{"aria-label":z,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:ga,value:h,children:[Q,G]}),e[59]=h,e[60]=z,e[61]=Q,e[62]=G,e[63]=X):X=e[63];let Y;e[64]!==p?(Y=(0,c.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:ba,type:"checkbox"}),e[64]=p,e[65]=Y):Y=e[65];let Z;e[66]!==t?(Z=t("Dry run"),e[66]=t,e[67]=Z):Z=e[67];let ee;e[68]!==Y||e[69]!==Z?(ee=(0,c.jsxs)(Me,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Y,Z]}),e[68]=Y,e[69]=Z,e[70]=ee):ee=e[70];let ae;e[71]!==p||e[72]!==be||e[73]!==f||e[74]!==I||e[75]!==t?(ae=p?(0,c.jsx)(Ue,{"data-testid":"mg-run",disabled:f||!I,onClick:be,type:"button",children:t(f?"Running\u2026":"Run")}):(0,c.jsx)(ta,{confirmLabel:t(f?"Running\u2026":"Run migration?"),disabled:f||!I,onConfirm:be,testId:"mg-run",children:t("Run")}),e[71]=p,e[72]=be,e[73]=f,e[74]=I,e[75]=t,e[76]=ae):ae=e[76];let te;e[77]!==W||e[78]!==X||e[79]!==ee||e[80]!==ae?(te=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[W,X,ee,ae]}),e[77]=W,e[78]=X,e[79]=ee,e[80]=ae,e[81]=te):te=e[81];let re;e[82]!==B||e[83]!==te?(re=(0,c.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,te]}),e[82]=B,e[83]=te,e[84]=re):re=e[84];let ne;e[85]!==$?(ne=$!==null&&(0,c.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:$}),e[85]=$,e[86]=ne):ne=e[86];let ie;e[87]!==x||e[88]!==t?(ie=x!==null&&(0,c.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[x.dryRun?t("Dry run: "):"",t("{status} \u2014 processed",{status:x.status}),x.processed,t(", changed"),x.changed]}),e[87]=x,e[88]=t,e[89]=ie):ie=e[89];let ke;return e[90]!==L||e[91]!==_||e[92]!==E||e[93]!==J||e[94]!==re||e[95]!==ne||e[96]!==ie?(ke=(0,c.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[L,_,E,J,re,ne,ie]}),e[90]=L,e[91]=_,e[92]=E,e[93]=J,e[94]=re,e[95]=ne,e[96]=ie,e[97]=ke):ke=e[97],ke},"yt");function ya(a){return(0,c.jsxs)(Fe,{"data-testid":`mg-row-${a.id}`,children:[(0,c.jsx)(C,{children:a.id}),(0,c.jsx)(C,{children:a.direction}),(0,c.jsx)(C,{children:(0,c.jsx)(Be,{variant:"secondary",children:a.status})}),(0,c.jsx)(C,{children:a.processed}),(0,c.jsx)(C,{children:a.changed}),(0,c.jsx)(C,{children:Ne(a.updatedAt)}),(0,c.jsx)(C,{children:a.error??""})]},a.id)}s(ya,"Je");var d=se(_e(),1);var Re=1;function ka(a){let e={},n=Object.keys(a);n.sort();for(let r of n)e[r]=a[r];return e}s(ka,"ne");var ce=s(a=>typeof a=="object"&&a!==null,"w"),$a=s(a=>ce(a)&&ce(a.fields)&&ce(a.indexes)&&ce(a.relations)&&typeof a.shardMode=="string","ie"),wa=s(a=>{if(a===void 0||a.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(a)}catch(n){return{error:`baseline is not valid JSON: ${n instanceof Error?n.message:String(n)}`,status:"invalid"}}if(!ce(e)||e.version!==Re||!ce(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Re)})`,status:"invalid"};for(let[n,r]of Object.entries(e.tables))if(!$a(r))return{error:`baseline table "${n}" 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:Re},status:"ok"}},"se"),Na=s((a,e)=>a.unique===e.unique&&a.fields.length===e.fields.length&&a.fields.every((n,r)=>n===e.fields[r]),"ae"),oa=s(a=>a.unique!==void 0,"J"),Ke=s(({nullable:a,optional:e,refined:n,unique:r,...t})=>JSON.stringify(ka(t)),"A"),da=s(a=>({form:JSON.stringify([Ke(a),a.optional===!0,a.nullable===!0]),refined:a.refined===!0}),"P"),la=s(a=>a.kind==="union"&&a.members?a.members.map(e=>da(e)):[da({...a,nullable:!1,optional:!1})],"V"),Sa=s((a,e)=>{if(e.kind!=="union")return!1;let n=la(e);return la(a).every(r=>n.some(t=>t.form===r.form&&(r.refined||!t.refined)))},"oe"),j=s(a=>{switch(a.kind){case"array":return`array(${a.of?j(a.of):"?"})`;case"id":return`id(${a.ref??"?"})`;case"literal":return`literal(${a.literal??"?"})`;case"object":return`object({ ${Object.keys(a.fields??{}).join(", ")} })`;case"record":return`record(${a.key?j(a.key):"?"}, ${a.of?j(a.of):"?"})`;case"union":return(a.members??[]).map(e=>j(e)).join(" | ");default:return a.kind}},"y"),ue=s((a,e,n)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:n,table:a,type:e}),"O"),je=s((a,e,n)=>({remediation:"none",scope:"table",severity:"safe",summary:n,table:a,type:e}),"F"),ja=s((a,e,n,r,t)=>{if(!(n.kind===r.kind&&(!t||Ke(n)===Ke(r))))return t&&Sa(n,r)?je(a,"widenedFieldShape",`field ${a}.${e} widened: ${j(n)} \u2192 ${j(r)} \u2014 every stored value stays valid`):n.kind!==r.kind?ue(a,"changedFieldKind",`field ${a}.${e} changed type: ${n.kind} \u2192 ${r.kind} \u2014 add a data migration to convert existing values`):ue(a,"changedFieldShape",`field ${a}.${e} changed shape: ${j(n)} \u2192 ${j(r)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"re"),Oa=s((a,e,n,r)=>{let t=[];return n.unique!==r.unique&&t.push(r.unique===!0?ue(a,"addedFieldConstraint",`field ${a}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):je(a,"relaxedFieldConstraint",`field ${a}.${e} is no longer unique`)),n.nullable!==r.nullable&&t.push(r.nullable===!0?je(a,"relaxedFieldConstraint",`field ${a}.${e} became nullable`):ue(a,"addedFieldConstraint",`field ${a}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),n.refined!==r.refined&&t.push(r.refined===!0?ue(a,"addedFieldConstraint",`field ${a}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):je(a,"relaxedFieldConstraint",`field ${a}.${e} dropped its validation refinement`)),t},"de"),ha=s((a,e,n,r)=>{let t=[],l=oa(n)&&oa(r),i=ja(a,e,n,r,l);return i&&t.push(i),l&&t.push(...Oa(a,e,n,r)),n.optional&&!r.optional?t.push({remediation:"backfill",severity:"breaking",summary:`field ${a}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:a,scope:"table",type:"fieldOptionalToRequired"}):!n.optional&&r.optional&&t.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${a}.${e} became optional`,table:a,type:"fieldRequiredToOptional"}),t},"K"),qa=s((a,e,n)=>n.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${a}.${e}`,table:a,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${a}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:a,scope:"table",type:"addedRequiredField"},"le"),Ca=s((a,e,n,r)=>{for(let[t,l]of Object.entries(n.fields)){let i=e.fields[t];i===void 0?r.push(qa(a,t,l)):r.push(...ha(a,t,i,l))}for(let t of Object.keys(e.fields))n.fields[t]===void 0&&r.push({remediation:"backfill",severity:"breaking",summary:`removed field ${a}.${t} \u2014 add a data migration if stored data must be cleaned up`,table:a,scope:"table",type:"removedField"})},"ce"),Ia=s((a,e,n,r)=>{for(let[t,l]of Object.entries(n.indexes)){let i=e.indexes[t];if(i===void 0){r.push(l.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${t} on ${a} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:a,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${t} on ${a}`,table:a,type:"addedIndex"});continue}Na(i,l)||r.push({remediation:"code",severity:"breaking",summary:`index ${t} on ${a} changed shape \u2014 a query may have relied on the old index`,table:a,scope:"table",type:"changedIndex"})}for(let t of Object.keys(e.indexes))n.indexes[t]===void 0&&r.push({remediation:"code",severity:"breaking",summary:`removed index ${t} on ${a} \u2014 a query that used \`.withIndex("${t}")\` would break`,table:a,scope:"table",type:"removedIndex"})},"ue"),Fa=s((a,e,n,r)=>{for(let t of Object.keys(n.relations))e.relations[t]===void 0&&r.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${a}.${t}`,table:a,type:"addedRelation"});for(let t of Object.keys(e.relations))n.relations[t]===void 0&&r.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${a}.${t}`,table:a,type:"removedRelation"})},"me"),Ma=s((a,e,n,r)=>{e.shardMode!==n.shardMode&&r.push({remediation:"rehome",severity:"breaking",summary:`table ${a} changed shard mode: ${e.shardMode} \u2192 ${n.shardMode} \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:a,scope:"table",type:"changedShardMode"}),Ca(a,e,n,r),Ia(a,e,n,r),Fa(a,e,n,r)},"fe"),Ra=s((a,e)=>{let n=[],r=a?.tables??{};for(let[t,l]of Object.entries(e.tables)){let i=r[t];if(i===void 0){n.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${t}`,table:t,type:"addedTable"});continue}Ma(t,i,l,n)}for(let t of Object.keys(r))e.tables[t]===void 0&&n.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${t} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:t,type:"removedTable"});if(a!==void 0&&a.jurisdiction!==e.jurisdiction){let t=a.jurisdiction??"(none)",l=e.jurisdiction??"(none)";n.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${t} to ${l} \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:n}},"he"),ca=s(a=>Object.entries(a.fields).map(([e,n])=>({name:e,optional:n.optional,ref:Object.values(a.relations).find(r=>r.field===e&&r.kind==="one")?.table,type:j(n)})),"H"),ma=s((a,e,n)=>{let r={},t=e?.fields??{},l=n?.fields??{};for(let[i,o]of Object.entries(l)){let u=t[i];u===void 0?r[i]=e===void 0?"unchanged":"added":r[i]=ha(a,i,u,o).length===0?"unchanged":"changed"}for(let i of Object.keys(t))l[i]===void 0&&(r[i]="removed");return r},"Q"),Ka=s((a,e)=>{let{changes:n}=Ra(a,e),r=new Set(n.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),t=[],l=s((i,o)=>i?"added":r.has(o)?"changed":"context","o");for(let[i,o]of Object.entries(e.tables)){let u=a?.tables[i],b=l(u===void 0,i);t.push({columns:ca(o),fieldStatus:ma(i,u,o),name:i,shardMode:o.shardMode,status:b})}for(let[i,o]of Object.entries(a?.tables??{}))e.tables[i]===void 0&&t.push({columns:ca(o),fieldStatus:ma(i,o,void 0),name:i,shardMode:o.shardMode,status:"removed"});return t.sort((i,o)=>i.name.localeCompare(o.name)),{breakingCount:n.filter(i=>i.severity==="breaking").length,changes:n,tables:t}},"pe"),ua=s(a=>{let e=wa(a);return e.status==="ok"?e.snapshot:void 0},"L"),Ta={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"},Da=s(a=>a==="global"?"global":"shard","be"),La=s(a=>{let e=(0,he.c)(24),{appliedAt:n,hash:r,onSelect:t,selected:l,seq:i}=a,o=l?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==o?(u=oe("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",o),e[0]=o,e[1]=u):u=e[1];let b=`sh-version-${r}`,h;e[2]!==r||e[3]!==t?(h=s(()=>{t(r)},"h"),e[2]=r,e[3]=t,e[4]=h):h=e[4];let v;e[5]!==i?(v=(0,d.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=v):v=e[6];let p;e[7]!==r?(p=r.slice(0,7),e[7]=r,e[8]=p):p=e[8];let g;e[9]!==p?(g=(0,d.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]!==v||e[12]!==g?(f=(0,d.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[v,g]}),e[11]=v,e[12]=g,e[13]=f):f=e[13];let y;e[14]!==n?(y=Ne(n),e[14]=n,e[15]=y):y=e[15];let x;e[16]!==y?(x=(0,d.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:y}),e[16]=y,e[17]=x):x=e[17];let m;return e[18]!==x||e[19]!==u||e[20]!==b||e[21]!==h||e[22]!==f?(m=(0,d.jsx)("li",{children:(0,d.jsxs)("button",{className:u,"data-testid":b,onClick:h,type:"button",children:[f,x]})}),e[18]=x,e[19]=u,e[20]=b,e[21]=h,e[22]=f,e[23]=m):m=e[23],m},"ve"),_a=s(a=>{let e=(0,he.c)(26),{breaking:n,count:r,first:t}=a,l=de();if(t){let g;e[0]!==r?(g=(0,d.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:r}),e[0]=r,e[1]=g):g=e[1];let f;e[2]!==l?(f=l("tables"),e[2]=l,e[3]=f):f=e[3];let y;e[4]!==f?(y=(0,d.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=y):y=e[5];let x;return e[6]!==g||e[7]!==y?(x=(0,d.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[g,y]}),e[6]=g,e[7]=y,e[8]=x):x=e[8],x}let i=n>0&&"text-destructive",o;e[9]!==i?(o=oe("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=o):o=e[10];let u;e[11]!==r||e[12]!==o?(u=(0,d.jsx)("span",{className:o,children:r}),e[11]=r,e[12]=o,e[13]=u):u=e[13];let b;e[14]!==r||e[15]!==l?(b=l(r===1?"change":"changes"),e[14]=r,e[15]=l,e[16]=b):b=e[16];let h;e[17]!==b?(h=(0,d.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 v;e[19]!==n||e[20]!==l?(v=n>0&&(0,d.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",l("{count} breaking",{count:n})]}),e[19]=n,e[20]=l,e[21]=v):v=e[21];let p;return e[22]!==u||e[23]!==h||e[24]!==v?(p=(0,d.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,h,v]}),e[22]=u,e[23]=h,e[24]=v,e[25]=p):p=e[25],p},"xe"),pa={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"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},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"}},Ea=s((a,e)=>{let n=`${pa[a.type].action} ${e} `;return a.summary.startsWith(n)?a.summary.slice(n.length):a.summary},"ye"),Ja=s(a=>{let e=new Map;for(let r of a){let t=r.table??"",l=e.get(t);l===void 0?e.set(t,[r]):l.push(r)}let n=[...e].map(([r,t])=>({changes:t,table:r}));return[...n.filter(r=>r.table!==""),...n.filter(r=>r.table==="")]},"ke"),Aa=s(a=>{let e=(0,he.c)(2),{children:n}=a,r;return e[0]!==n?(r=(0,d.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:n}),e[0]=n,e[1]=r):r=e[1],r},"$e"),Ba=s(({pane:a,shardKey:e=""})=>{let n=de(),r=Ae(),t=Je({strict:!1}).version,l=s(m=>{we(r({search:{version:m},to:"/migrations"}))},"a"),i=le(R.schemaHistory,{},{shardKey:e}),o=i.data?.versions??[],u=t!==void 0&&o.some(m=>m.hash===t)?t:o[0]?.hash,b=o.findIndex(m=>m.hash===u),h=b===-1?void 0:o[b+1]?.hash,v=le(R.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=le(R.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),g=(0,me.useMemo)(()=>{let m=ua(v.data?.version?.snapshotJson);if(m!==void 0)return Ka(ua(p.data?.version?.snapshotJson),m)},[v.data,p.data]),f=(0,me.useMemo)(()=>(g?.tables??[]).map(m=>({columns:m.columns,name:m.name,tier:Da(m.shardMode)})),[g]),y=(0,me.useMemo)(()=>{let m={};for(let $ of g?.tables??[])m[$.name]=Ta[$.status];return m},[g]);if(i.error!==null)return(0,d.jsx)(Se,{error:i.errorSource,testId:"sh-error"});if(o.length===0)return(0,d.jsx)($e,{description:n("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:n("No schema versions recorded yet.")});let x=g?.changes??[];return(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,d.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,d.jsx)(Aa,{children:n("Schema versions")}),(0,d.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:o.map(m=>(0,d.jsx)(La,{appliedAt:m.appliedAt,hash:m.hash,onSelect:l,selected:m.hash===u,seq:m.seq},m.hash))})]}),(0,d.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,d.jsx)(_a,{breaking:g?.breakingCount??0,count:h===void 0?f.length:x.length,first:h===void 0}),a==="diagram"?(0,d.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,d.jsx)(na,{fill:!0,nodeClasses:y,tables:f,testIdPrefix:"sh"})}):(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Ja(x).map(m=>{let $=(g?.tables??[]).find(k=>k.name===m.table);return(0,d.jsxs)("section",{className:"mb-6",children:[(0,d.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,d.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:m.table===""?n("schema"):m.table}),$!==void 0&&(0,d.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:n("{count} columns",{count:$.columns.length})}),m.changes.length>1&&(0,d.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:m.changes.length})]}),(0,d.jsx)("ul",{children:m.changes.map(k=>{let{action:K,kind:I}=pa[k.type],O=k.severity==="breaking",F=Ea(k,I);return(0,d.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,d.jsx)("span",{"aria-hidden":"true",className:oe("-ms-3 h-3 w-0.5 shrink-0 self-center",O?"bg-destructive":"bg-transparent")}),(0,d.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[n(K)," ",I]}),F!==m.table&&(0,d.jsx)("span",{className:oe("min-w-0 font-mono text-[13px]",O?"text-destructive":"text-foreground"),children:F}),O&&(0,d.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:n("breaking")})]},`${k.type}-${k.summary}`)})})]},m.table)})})]})]})},"we"),Pa=s(a=>oe("-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",a?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Se"),yt=s(a=>{let e=(0,he.c)(11),{initialShardKey:n}=a,r=de(),[t,l]=(0,me.useState)("diagram"),i;e[0]!==t?(i=s((v,p,g,f)=>(0,d.jsxs)("button",{"aria-selected":t===v,className:Pa(t===v),"data-testid":g,onClick:s(()=>{l(v)},"onClick"),role:"tab",type:"button",children:[p,f!==void 0&&(0,d.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),"a"),e[0]=t,e[1]=i):i=e[1];let o=i,u;e[2]!==r||e[3]!==o?(u=(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[o("diagram",r("Diagram"),"mg-pane-diagram"),o("changes",r("Changes"),"mg-pane-changes"),o("data",r("Data migrations"),"mg-pane-data")]}),e[2]=r,e[3]=o,e[4]=u):u=e[4];let b;e[5]!==n||e[6]!==t?(b=(0,d.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:t==="data"?(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,d.jsx)(sa,{initialShardKey:n})}):(0,d.jsx)(Ba,{pane:t,shardKey:n})}),e[5]=n,e[6]=t,e[7]=b):b=e[7];let h;return e[8]!==u||e[9]!==b?(h=(0,d.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},"Je");export{yt as default};
|
|
1
|
+
import{a as na}from"./chunk-56XCNBO4.js";import"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as Me}from"./chunk-IMOHEGMV.js";import{a as ra}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 ta}from"./chunk-PD6WIDY6.js";import{a as Ye}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as Ge}from"./chunk-OGUKYRFM.js";import{d as Je,e as Ae}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Pe}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as Ue}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as Be}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Se}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as le}from"./chunk-7TRN7FQ4.js";import{f as Ee}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as $e}from"./chunk-FKVZRPV5.js";import{a as Ze,b as ea,c as aa,d as Fe,e as q,f as C}from"./chunk-HEAQVSNS.js";import{a as We,e as ze}from"./chunk-WUWBZPUK.js";import{d as de,f as He,g as Qe,h as Ve,o as we,r as Ne}from"./chunk-FODLDLE2.js";import{a as s,d as se,e as De,f as Le,g as _e,i as oe}from"./chunk-YKXDMIHQ.js";var he=se(Le(),1),me=se(De(),1);var ia=se(Le(),1);var S=se(De(),1);var c=se(_e(),1);var xa=He(R.runMigration),sa=s(a=>{let e=(0,ia.c)(98),{initialShardKey:n}=a,r=Ee(),t=de(),{queryShardKey:l,setShardKey:i,shardKey:o}=Ye(n),[u,b]=(0,S.useState)(""),[h,v]=(0,S.useState)("up"),[p,g]=(0,S.useState)(!0),[f,y]=(0,S.useState)(!1),[x,m]=(0,S.useState)(null),[$,k]=(0,S.useState)(null),K;e[0]!==o?(K=o.trim(),e[0]=o,e[1]=K):K=e[1];let I=K===l,O;e[2]===Symbol.for("react.memo_cache_sentinel")?(O={},e[2]=O):O=e[2];let F;e[3]!==l?(F={live:!0,shardKey:l},e[3]=l,e[4]=F):F=e[4];let w=le(R.migrationStatus,O,F),N=w.data?.migrations??null,Oe=w.error,{errorSource:qe,liveError:Ce}=w,pe,fe;e[5]!==l||e[6]!==w.data?(pe=s(()=>{w.data!==void 0&&Ge(l)},"W"),fe=[w.data,l],e[5]=l,e[6]=w.data,e[7]=pe,e[8]=fe):(pe=e[7],fe=e[8]),(0,S.useEffect)(pe,fe);let ge;if(e[9]!==r||e[10]!==h||e[11]!==p||e[12]!==u||e[13]!==o||e[14]!==w||e[15]!==t){let M=s(async()=>{let Te=u.trim();if(Te===""){k(t("Enter a migration id")),m(null);return}y(!0),k(null);try{let Ie=await r.query(xa,{direction:h,dryRun:p,id:Te},Qe(o));m(Ie),w.refetch()}catch(Ie){let va=Ie;m(null),k(Ve(va))}y(!1)},"m");ge=s(()=>{we(M())},"V"),e[9]=r,e[10]=h,e[11]=p,e[12]=u,e[13]=o,e[14]=w,e[15]=t,e[16]=ge}else ge=e[16];let be=ge,ve;e[17]===Symbol.for("react.memo_cache_sentinel")?(ve=s(M=>{b(M.target.value)},"Y"),e[17]=ve):ve=e[17];let fa=ve,xe;e[18]===Symbol.for("react.memo_cache_sentinel")?(xe=s(M=>{v(M.target.value==="down"?"down":"up")},"Z"),e[18]=xe):xe=e[18];let ga=xe,ye;e[19]===Symbol.for("react.memo_cache_sentinel")?(ye=s(M=>{g(M.target.checked)},"ee"),e[19]=ye):ye=e[19];let ba=ye,T;e[20]!==i||e[21]!==o?(T=(0,c.jsx)(Xe,{onChange:i,testId:"mg-shard-input",value:o}),e[20]=i,e[21]=o,e[22]=T):T=e[22];let D;e[23]!==Ce?(D=(0,c.jsx)(ra,{message:Ce,prefix:"mg"}),e[23]=Ce,e[24]=D):D=e[24];let L;e[25]!==T||e[26]!==D?(L=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[T,D]}),e[25]=T,e[26]=D,e[27]=L):L=e[27];let _;e[28]!==Oe||e[29]!==qe?(_=Oe!==null&&(0,c.jsx)(Se,{error:qe,testId:"mg-status-error"}),e[28]=Oe,e[29]=qe,e[30]=_):_=e[30];let E;e[31]!==N||e[32]!==t?(E=N!==null&&N.length===0&&(0,c.jsx)($e,{description:t("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:t("No migrations have run on this shard.")}),e[31]=N,e[32]=t,e[33]=E):E=e[33];let J;e[34]!==N||e[35]!==t?(J=N!==null&&N.length>0&&(0,c.jsx)(We,{className:"overflow-hidden py-0",children:(0,c.jsx)(ze,{className:"px-0",children:(0,c.jsxs)(Ze,{"data-testid":"mg-table",children:[(0,c.jsx)(ea,{children:(0,c.jsxs)(Fe,{children:[(0,c.jsx)(q,{children:t("id")}),(0,c.jsx)(q,{children:t("direction")}),(0,c.jsx)(q,{children:t("status")}),(0,c.jsx)(q,{children:t("processed")}),(0,c.jsx)(q,{children:t("changed")}),(0,c.jsx)(q,{children:t("updated")}),(0,c.jsx)(q,{children:t("error")})]})}),(0,c.jsx)(aa,{children:N.map(ya)})]})})}),e[34]=N,e[35]=t,e[36]=J):J=e[36];let A;e[37]!==t?(A=t("Run migration"),e[37]=t,e[38]=A):A=e[38];let B;e[39]!==A?(B=(0,c.jsx)(Me,{children:A}),e[39]=A,e[40]=B):B=e[40];let P;e[41]!==t?(P=t("Migration id"),e[41]=t,e[42]=P):P=e[42];let U;e[43]!==t?(U=t("migration id"),e[43]=t,e[44]=U):U=e[44];let W;e[45]!==u||e[46]!==P||e[47]!==U?(W=(0,c.jsx)(Pe,{"aria-label":P,className:"w-auto","data-testid":"mg-id-input",onChange:fa,placeholder:U,value:u}),e[45]=u,e[46]=P,e[47]=U,e[48]=W):W=e[48];let z;e[49]!==t?(z=t("Direction"),e[49]=t,e[50]=z):z=e[50];let H;e[51]!==t?(H=t("up"),e[51]=t,e[52]=H):H=e[52];let Q;e[53]!==H?(Q=(0,c.jsx)("option",{value:"up",children:H}),e[53]=H,e[54]=Q):Q=e[54];let V;e[55]!==t?(V=t("down"),e[55]=t,e[56]=V):V=e[56];let G;e[57]!==V?(G=(0,c.jsx)("option",{value:"down",children:V}),e[57]=V,e[58]=G):G=e[58];let X;e[59]!==h||e[60]!==z||e[61]!==Q||e[62]!==G?(X=(0,c.jsxs)("select",{"aria-label":z,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:ga,value:h,children:[Q,G]}),e[59]=h,e[60]=z,e[61]=Q,e[62]=G,e[63]=X):X=e[63];let Y;e[64]!==p?(Y=(0,c.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:ba,type:"checkbox"}),e[64]=p,e[65]=Y):Y=e[65];let Z;e[66]!==t?(Z=t("Dry run"),e[66]=t,e[67]=Z):Z=e[67];let ee;e[68]!==Y||e[69]!==Z?(ee=(0,c.jsxs)(Me,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Y,Z]}),e[68]=Y,e[69]=Z,e[70]=ee):ee=e[70];let ae;e[71]!==p||e[72]!==be||e[73]!==f||e[74]!==I||e[75]!==t?(ae=p?(0,c.jsx)(Ue,{"data-testid":"mg-run",disabled:f||!I,onClick:be,type:"button",children:t(f?"Running\u2026":"Run")}):(0,c.jsx)(ta,{confirmLabel:t(f?"Running\u2026":"Run migration?"),disabled:f||!I,onConfirm:be,testId:"mg-run",children:t("Run")}),e[71]=p,e[72]=be,e[73]=f,e[74]=I,e[75]=t,e[76]=ae):ae=e[76];let te;e[77]!==W||e[78]!==X||e[79]!==ee||e[80]!==ae?(te=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[W,X,ee,ae]}),e[77]=W,e[78]=X,e[79]=ee,e[80]=ae,e[81]=te):te=e[81];let re;e[82]!==B||e[83]!==te?(re=(0,c.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,te]}),e[82]=B,e[83]=te,e[84]=re):re=e[84];let ne;e[85]!==$?(ne=$!==null&&(0,c.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:$}),e[85]=$,e[86]=ne):ne=e[86];let ie;e[87]!==x||e[88]!==t?(ie=x!==null&&(0,c.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[x.dryRun?t("Dry run: "):"",t("{status} \u2014 processed",{status:x.status}),x.processed,t(", changed"),x.changed]}),e[87]=x,e[88]=t,e[89]=ie):ie=e[89];let ke;return e[90]!==L||e[91]!==_||e[92]!==E||e[93]!==J||e[94]!==re||e[95]!==ne||e[96]!==ie?(ke=(0,c.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[L,_,E,J,re,ne,ie]}),e[90]=L,e[91]=_,e[92]=E,e[93]=J,e[94]=re,e[95]=ne,e[96]=ie,e[97]=ke):ke=e[97],ke},"yt");function ya(a){return(0,c.jsxs)(Fe,{"data-testid":`mg-row-${a.id}`,children:[(0,c.jsx)(C,{children:a.id}),(0,c.jsx)(C,{children:a.direction}),(0,c.jsx)(C,{children:(0,c.jsx)(Be,{variant:"secondary",children:a.status})}),(0,c.jsx)(C,{children:a.processed}),(0,c.jsx)(C,{children:a.changed}),(0,c.jsx)(C,{children:Ne(a.updatedAt)}),(0,c.jsx)(C,{children:a.error??""})]},a.id)}s(ya,"Je");var d=se(_e(),1);var Re=1;function ka(a){let e={},n=Object.keys(a);n.sort();for(let r of n)e[r]=a[r];return e}s(ka,"ne");var ce=s(a=>typeof a=="object"&&a!==null,"w"),$a=s(a=>ce(a)&&ce(a.fields)&&ce(a.indexes)&&ce(a.relations)&&typeof a.shardMode=="string","ie"),wa=s(a=>{if(a===void 0||a.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(a)}catch(n){return{error:`baseline is not valid JSON: ${n instanceof Error?n.message:String(n)}`,status:"invalid"}}if(!ce(e)||e.version!==Re||!ce(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Re)})`,status:"invalid"};for(let[n,r]of Object.entries(e.tables))if(!$a(r))return{error:`baseline table "${n}" 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:Re},status:"ok"}},"se"),Na=s((a,e)=>a.unique===e.unique&&a.fields.length===e.fields.length&&a.fields.every((n,r)=>n===e.fields[r]),"ae"),oa=s(a=>a.unique!==void 0,"J"),Ke=s(({nullable:a,optional:e,refined:n,unique:r,...t})=>JSON.stringify(ka(t)),"A"),da=s(a=>({form:JSON.stringify([Ke(a),a.optional===!0,a.nullable===!0]),refined:a.refined===!0}),"P"),la=s(a=>a.kind==="union"&&a.members?a.members.map(e=>da(e)):[da({...a,nullable:!1,optional:!1})],"V"),Sa=s((a,e)=>{if(e.kind!=="union")return!1;let n=la(e);return la(a).every(r=>n.some(t=>t.form===r.form&&(r.refined||!t.refined)))},"oe"),j=s(a=>{switch(a.kind){case"array":return`array(${a.of?j(a.of):"?"})`;case"id":return`id(${a.ref??"?"})`;case"literal":return`literal(${a.literal??"?"})`;case"object":return`object({ ${Object.keys(a.fields??{}).join(", ")} })`;case"record":return`record(${a.key?j(a.key):"?"}, ${a.of?j(a.of):"?"})`;case"union":return(a.members??[]).map(e=>j(e)).join(" | ");default:return a.kind}},"y"),ue=s((a,e,n)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:n,table:a,type:e}),"O"),je=s((a,e,n)=>({remediation:"none",scope:"table",severity:"safe",summary:n,table:a,type:e}),"F"),ja=s((a,e,n,r,t)=>{if(!(n.kind===r.kind&&(!t||Ke(n)===Ke(r))))return t&&Sa(n,r)?je(a,"widenedFieldShape",`field ${a}.${e} widened: ${j(n)} \u2192 ${j(r)} \u2014 every stored value stays valid`):n.kind!==r.kind?ue(a,"changedFieldKind",`field ${a}.${e} changed type: ${n.kind} \u2192 ${r.kind} \u2014 add a data migration to convert existing values`):ue(a,"changedFieldShape",`field ${a}.${e} changed shape: ${j(n)} \u2192 ${j(r)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"re"),Oa=s((a,e,n,r)=>{let t=[];return n.unique!==r.unique&&t.push(r.unique===!0?ue(a,"addedFieldConstraint",`field ${a}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):je(a,"relaxedFieldConstraint",`field ${a}.${e} is no longer unique`)),n.nullable!==r.nullable&&t.push(r.nullable===!0?je(a,"relaxedFieldConstraint",`field ${a}.${e} became nullable`):ue(a,"addedFieldConstraint",`field ${a}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),n.refined!==r.refined&&t.push(r.refined===!0?ue(a,"addedFieldConstraint",`field ${a}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):je(a,"relaxedFieldConstraint",`field ${a}.${e} dropped its validation refinement`)),t},"de"),ha=s((a,e,n,r)=>{let t=[],l=oa(n)&&oa(r),i=ja(a,e,n,r,l);return i&&t.push(i),l&&t.push(...Oa(a,e,n,r)),n.optional&&!r.optional?t.push({remediation:"backfill",severity:"breaking",summary:`field ${a}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:a,scope:"table",type:"fieldOptionalToRequired"}):!n.optional&&r.optional&&t.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${a}.${e} became optional`,table:a,type:"fieldRequiredToOptional"}),t},"K"),qa=s((a,e,n)=>n.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${a}.${e}`,table:a,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${a}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:a,scope:"table",type:"addedRequiredField"},"le"),Ca=s((a,e,n,r)=>{for(let[t,l]of Object.entries(n.fields)){let i=e.fields[t];i===void 0?r.push(qa(a,t,l)):r.push(...ha(a,t,i,l))}for(let t of Object.keys(e.fields))n.fields[t]===void 0&&r.push({remediation:"backfill",severity:"breaking",summary:`removed field ${a}.${t} \u2014 add a data migration if stored data must be cleaned up`,table:a,scope:"table",type:"removedField"})},"ce"),Ia=s((a,e,n,r)=>{for(let[t,l]of Object.entries(n.indexes)){let i=e.indexes[t];if(i===void 0){r.push(l.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${t} on ${a} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:a,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${t} on ${a}`,table:a,type:"addedIndex"});continue}Na(i,l)||r.push({remediation:"code",severity:"breaking",summary:`index ${t} on ${a} changed shape \u2014 a query may have relied on the old index`,table:a,scope:"table",type:"changedIndex"})}for(let t of Object.keys(e.indexes))n.indexes[t]===void 0&&r.push({remediation:"code",severity:"breaking",summary:`removed index ${t} on ${a} \u2014 a query that used \`.withIndex("${t}")\` would break`,table:a,scope:"table",type:"removedIndex"})},"ue"),Fa=s((a,e,n,r)=>{for(let t of Object.keys(n.relations))e.relations[t]===void 0&&r.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${a}.${t}`,table:a,type:"addedRelation"});for(let t of Object.keys(e.relations))n.relations[t]===void 0&&r.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${a}.${t}`,table:a,type:"removedRelation"})},"me"),Ma=s((a,e,n,r)=>{e.shardMode!==n.shardMode&&r.push({remediation:"rehome",severity:"breaking",summary:`table ${a} changed shard mode: ${e.shardMode} \u2192 ${n.shardMode} \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:a,scope:"table",type:"changedShardMode"}),Ca(a,e,n,r),Ia(a,e,n,r),Fa(a,e,n,r)},"fe"),Ra=s((a,e)=>{let n=[],r=a?.tables??{};for(let[t,l]of Object.entries(e.tables)){let i=r[t];if(i===void 0){n.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${t}`,table:t,type:"addedTable"});continue}Ma(t,i,l,n)}for(let t of Object.keys(r))e.tables[t]===void 0&&n.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${t} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:t,type:"removedTable"});if(a!==void 0&&a.jurisdiction!==e.jurisdiction){let t=a.jurisdiction??"(none)",l=e.jurisdiction??"(none)";n.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${t} to ${l} \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:n}},"he"),ca=s(a=>Object.entries(a.fields).map(([e,n])=>({name:e,optional:n.optional,ref:Object.values(a.relations).find(r=>r.field===e&&r.kind==="one")?.table,type:j(n)})),"H"),ma=s((a,e,n)=>{let r={},t=e?.fields??{},l=n?.fields??{};for(let[i,o]of Object.entries(l)){let u=t[i];u===void 0?r[i]=e===void 0?"unchanged":"added":r[i]=ha(a,i,u,o).length===0?"unchanged":"changed"}for(let i of Object.keys(t))l[i]===void 0&&(r[i]="removed");return r},"Q"),Ka=s((a,e)=>{let{changes:n}=Ra(a,e),r=new Set(n.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),t=[],l=s((i,o)=>i?"added":r.has(o)?"changed":"context","o");for(let[i,o]of Object.entries(e.tables)){let u=a?.tables[i],b=l(u===void 0,i);t.push({columns:ca(o),fieldStatus:ma(i,u,o),name:i,shardMode:o.shardMode,status:b})}for(let[i,o]of Object.entries(a?.tables??{}))e.tables[i]===void 0&&t.push({columns:ca(o),fieldStatus:ma(i,o,void 0),name:i,shardMode:o.shardMode,status:"removed"});return t.sort((i,o)=>i.name.localeCompare(o.name)),{breakingCount:n.filter(i=>i.severity==="breaking").length,changes:n,tables:t}},"pe"),ua=s(a=>{let e=wa(a);return e.status==="ok"?e.snapshot:void 0},"L"),Ta={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"},Da=s(a=>a==="global"?"global":"shard","be"),La=s(a=>{let e=(0,he.c)(24),{appliedAt:n,hash:r,onSelect:t,selected:l,seq:i}=a,o=l?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==o?(u=oe("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",o),e[0]=o,e[1]=u):u=e[1];let b=`sh-version-${r}`,h;e[2]!==r||e[3]!==t?(h=s(()=>{t(r)},"h"),e[2]=r,e[3]=t,e[4]=h):h=e[4];let v;e[5]!==i?(v=(0,d.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=v):v=e[6];let p;e[7]!==r?(p=r.slice(0,7),e[7]=r,e[8]=p):p=e[8];let g;e[9]!==p?(g=(0,d.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]!==v||e[12]!==g?(f=(0,d.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[v,g]}),e[11]=v,e[12]=g,e[13]=f):f=e[13];let y;e[14]!==n?(y=Ne(n),e[14]=n,e[15]=y):y=e[15];let x;e[16]!==y?(x=(0,d.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:y}),e[16]=y,e[17]=x):x=e[17];let m;return e[18]!==x||e[19]!==u||e[20]!==b||e[21]!==h||e[22]!==f?(m=(0,d.jsx)("li",{children:(0,d.jsxs)("button",{className:u,"data-testid":b,onClick:h,type:"button",children:[f,x]})}),e[18]=x,e[19]=u,e[20]=b,e[21]=h,e[22]=f,e[23]=m):m=e[23],m},"ve"),_a=s(a=>{let e=(0,he.c)(26),{breaking:n,count:r,first:t}=a,l=de();if(t){let g;e[0]!==r?(g=(0,d.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:r}),e[0]=r,e[1]=g):g=e[1];let f;e[2]!==l?(f=l("tables"),e[2]=l,e[3]=f):f=e[3];let y;e[4]!==f?(y=(0,d.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=y):y=e[5];let x;return e[6]!==g||e[7]!==y?(x=(0,d.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[g,y]}),e[6]=g,e[7]=y,e[8]=x):x=e[8],x}let i=n>0&&"text-destructive",o;e[9]!==i?(o=oe("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=o):o=e[10];let u;e[11]!==r||e[12]!==o?(u=(0,d.jsx)("span",{className:o,children:r}),e[11]=r,e[12]=o,e[13]=u):u=e[13];let b;e[14]!==r||e[15]!==l?(b=l(r===1?"change":"changes"),e[14]=r,e[15]=l,e[16]=b):b=e[16];let h;e[17]!==b?(h=(0,d.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 v;e[19]!==n||e[20]!==l?(v=n>0&&(0,d.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",l("{count} breaking",{count:n})]}),e[19]=n,e[20]=l,e[21]=v):v=e[21];let p;return e[22]!==u||e[23]!==h||e[24]!==v?(p=(0,d.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,h,v]}),e[22]=u,e[23]=h,e[24]=v,e[25]=p):p=e[25],p},"xe"),pa={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"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},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"}},Ea=s((a,e)=>{let n=`${pa[a.type].action} ${e} `;return a.summary.startsWith(n)?a.summary.slice(n.length):a.summary},"ye"),Ja=s(a=>{let e=new Map;for(let r of a){let t=r.table??"",l=e.get(t);l===void 0?e.set(t,[r]):l.push(r)}let n=[...e].map(([r,t])=>({changes:t,table:r}));return[...n.filter(r=>r.table!==""),...n.filter(r=>r.table==="")]},"ke"),Aa=s(a=>{let e=(0,he.c)(2),{children:n}=a,r;return e[0]!==n?(r=(0,d.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:n}),e[0]=n,e[1]=r):r=e[1],r},"$e"),Ba=s(({pane:a,shardKey:e=""})=>{let n=de(),r=Ae(),t=Je({strict:!1}).version,l=s(m=>{we(r({search:{version:m},to:"/migrations"}))},"a"),i=le(R.schemaHistory,{},{shardKey:e}),o=i.data?.versions??[],u=t!==void 0&&o.some(m=>m.hash===t)?t:o[0]?.hash,b=o.findIndex(m=>m.hash===u),h=b===-1?void 0:o[b+1]?.hash,v=le(R.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=le(R.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),g=(0,me.useMemo)(()=>{let m=ua(v.data?.version?.snapshotJson);if(m!==void 0)return Ka(ua(p.data?.version?.snapshotJson),m)},[v.data,p.data]),f=(0,me.useMemo)(()=>(g?.tables??[]).map(m=>({columns:m.columns,name:m.name,tier:Da(m.shardMode)})),[g]),y=(0,me.useMemo)(()=>{let m={};for(let $ of g?.tables??[])m[$.name]=Ta[$.status];return m},[g]);if(i.error!==null)return(0,d.jsx)(Se,{error:i.errorSource,testId:"sh-error"});if(o.length===0)return(0,d.jsx)($e,{description:n("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:n("No schema versions recorded yet.")});let x=g?.changes??[];return(0,d.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,d.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,d.jsx)(Aa,{children:n("Schema versions")}),(0,d.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:o.map(m=>(0,d.jsx)(La,{appliedAt:m.appliedAt,hash:m.hash,onSelect:l,selected:m.hash===u,seq:m.seq},m.hash))})]}),(0,d.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,d.jsx)(_a,{breaking:g?.breakingCount??0,count:h===void 0?f.length:x.length,first:h===void 0}),a==="diagram"?(0,d.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,d.jsx)(na,{fill:!0,nodeClasses:y,tables:f,testIdPrefix:"sh"})}):(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Ja(x).map(m=>{let $=(g?.tables??[]).find(k=>k.name===m.table);return(0,d.jsxs)("section",{className:"mb-6",children:[(0,d.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,d.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:m.table===""?n("schema"):m.table}),$!==void 0&&(0,d.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:n("{count} columns",{count:$.columns.length})}),m.changes.length>1&&(0,d.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:m.changes.length})]}),(0,d.jsx)("ul",{children:m.changes.map(k=>{let{action:K,kind:I}=pa[k.type],O=k.severity==="breaking",F=Ea(k,I);return(0,d.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,d.jsx)("span",{"aria-hidden":"true",className:oe("-ms-3 h-3 w-0.5 shrink-0 self-center",O?"bg-destructive":"bg-transparent")}),(0,d.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[n(K)," ",I]}),F!==m.table&&(0,d.jsx)("span",{className:oe("min-w-0 font-mono text-[13px]",O?"text-destructive":"text-foreground"),children:F}),O&&(0,d.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:n("breaking")})]},`${k.type}-${k.summary}`)})})]},m.table)})})]})]})},"we"),Pa=s(a=>oe("-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",a?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Se"),yt=s(a=>{let e=(0,he.c)(11),{initialShardKey:n}=a,r=de(),[t,l]=(0,me.useState)("diagram"),i;e[0]!==t?(i=s((v,p,g,f)=>(0,d.jsxs)("button",{"aria-selected":t===v,className:Pa(t===v),"data-testid":g,onClick:s(()=>{l(v)},"onClick"),role:"tab",type:"button",children:[p,f!==void 0&&(0,d.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),"a"),e[0]=t,e[1]=i):i=e[1];let o=i,u;e[2]!==r||e[3]!==o?(u=(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[o("diagram",r("Diagram"),"mg-pane-diagram"),o("changes",r("Changes"),"mg-pane-changes"),o("data",r("Data migrations"),"mg-pane-data")]}),e[2]=r,e[3]=o,e[4]=u):u=e[4];let b;e[5]!==n||e[6]!==t?(b=(0,d.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:t==="data"?(0,d.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,d.jsx)(sa,{initialShardKey:n})}):(0,d.jsx)(Ba,{pane:t,shardKey:n})}),e[5]=n,e[6]=t,e[7]=b):b=e[7];let h;return e[8]!==u||e[9]!==b?(h=(0,d.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},"Je");export{yt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as j,c as v,d as D,f as g}from"./chunk-
|
|
1
|
+
import{b as j,c as v,d as D,f as g}from"./chunk-EAQZEXBX.js";import{f as S,g as w,h as P,o as q}from"./chunk-FODLDLE2.js";import{a as i,d as A,e as x,f as M}from"./chunk-YKXDMIHQ.js";var E=A(M(),1);var p=A(x(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"a"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"c"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let d=this.nextSeq;this.nextSeq+=1;let c={functionPath:r,kind:n,seq:d,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),d}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,_=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"j"),O=i((t,r)=>[...t,r],"E");function W(t,r,e={}){let s=g(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:d=0}=e,c=O(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:c,staleTime:d});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{q(o.refetch())},"refetch")}}i(W,"F");function Y(t,r,e={}){let s=g(),n=v(),{enabled:a=!0,keepPreviousData:d=!1,live:c=!1,shardKey:o="",staleTime:R}=e,m=_(t,r,o),C=W(m,()=>s.query(S(t),r,w(o)),{enabled:a,keepPreviousData:d,staleTime:R??(c?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),L=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!c)return;b(void 0);let y=f.startSubscription(t,r,o),Q=s.subscribe(S(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(O(m,s.clientIdentifier()),h)},{...w(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),Q()}},[s,L,a,c]),{...C,liveError:a&&c?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=v(),e;return t[0]!==r?(e=i((s,n,a)=>{let d=n===void 0?["lunora-admin",s]:_(s,n,a??"");q(r.invalidateQueries({queryKey:d}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as y}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as R}from"./chunk-
|
|
1
|
+
import{b as y}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as R}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as v}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as S}from"./chunk-FKVZRPV5.js";import{a as A,b as C,c as I,d as x,e as c,f as n}from"./chunk-HEAQVSNS.js";import{a as k,e as w}from"./chunk-WUWBZPUK.js";import{d as N}from"./chunk-FODLDLE2.js";import{a as f,d as b,f as E,g as O}from"./chunk-YKXDMIHQ.js";var j=b(E(),1);var r=b(O(),1);var _=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"I"),T={delete:2,list:3,read:0,write:1},B=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||T[t.on]-T[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"O"),q=f(()=>{let e=(0,j.c)(14),t=N(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=$(v.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=B(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(R,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(k,{className:"overflow-hidden py-0",children:(0,r.jsx)(w,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(C,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(c,{children:t("Bucket")}),(0,r.jsx)(c,{children:t("Operation")}),(0,r.jsx)(c,{children:t("Key prefix")}),(0,r.jsx)(c,{children:t("Guarded by")})]})}),(0,r.jsx)(I,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(n,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(n,{children:(0,r.jsx)(y,{variant:"secondary",children:_(t,s.on)})}),(0,r.jsx)(n,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(n,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"M");export{q as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as fe}from"./chunk-2URQKGWU.js";import"./chunk-4JLGLPWV.js";import{a as ie}from"./chunk-MU3P2FI7.js";import{a as pe}from"./chunk-66UGPQVC.js";import"./chunk-3Q2P62UR.js";import{W as de}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as x}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ne}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as he}from"./chunk-
|
|
1
|
+
import{a as fe}from"./chunk-2URQKGWU.js";import"./chunk-4JLGLPWV.js";import{a as ie}from"./chunk-MU3P2FI7.js";import{a as pe}from"./chunk-66UGPQVC.js";import"./chunk-3Q2P62UR.js";import{W as de}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as x}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ne}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as he}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as ue}from"./chunk-7TRN7FQ4.js";import{f as le}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as ce}from"./chunk-FKVZRPV5.js";import{d as oe,f as Z,g as ee,h as te,o as ae,q as me,r as re}from"./chunk-FODLDLE2.js";import{a as i,d as Y,e as ge,f as ve,g as Ne,i as se}from"./chunk-YKXDMIHQ.js";var t=Y(Ne(),1);var xe=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"ge");var we=/https?:\/\/[^\s"'<>)]+/i,be=i(a=>a===void 0?void 0:we.exec(a)?.[0],"re"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=i(a=>{if(a!==void 0)return be(a.html)??be(a.text)},"Ne"),ke=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"we"),Se=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"ye"),Te=Z(H.clearCapturedMail),Le=Z(H.sendTestMail),je=i(a=>{let e=(0,xe.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:q,error:w,errorSource:C,isLoading:g,refetch:n}=ue(H.getCapturedMail,p),[k,f]=(0,N.useState)(null),[D,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,P]=(0,N.useState)(""),b=q?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(Te,{},ee("")),S(null),n()}catch(m){f(te(m))}},"T"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let R=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Le,{},ee("")),n()}catch(m){f(te(m))}},"k"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let W=L,j;e[8]!==n?(j=i(()=>{n()},"L"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==R?(M=i(()=>{ae(R())},"A"),e[10]=R,e[11]=M):M=e[11];let U=M,_;e[12]!==W?(_=i(()=>{ae(W())},"E"),e[12]=W,e[13]=_):_=e[13];let G=_,z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{P(m.currentTarget.value)},"_"),e[14]=z):z=e[14];let J=z,$;e[15]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"M"),e[15]=$):$=e[15];let K=$,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"j"),e[16]=A):A=e[16];let Q=A,F=ke(b,c),O=Se(F,D),d=Ce(O),I;e[17]!==d?(I=i(()=>{d!==void 0&&me(d)},"z"),e[17]=d,e[18]=I):I=e[18];let V=I,B;e[19]!==d?(B=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"F"),e[19]=d,e[20]=B):B=e[20];let X=B,E;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==U||e[28]!==V||e[29]!==J||e[30]!==X||e[31]!==K||e[32]!==Q||e[33]!==G||e[34]!==O||e[35]!==v||e[36]!==F?(E={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:U,onCopyLink:V,onFilterChange:J,onOpenLink:X,onSelectMessage:K,onSelectTab:Q,onSendTest:G,selected:O,tab:v,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=U,e[28]=V,e[29]=J,e[30]=X,e[31]=K,e[32]=Q,e[33]=G,e[34]=O,e[35]=v,e[36]=F,e[37]=E):E=e[37],E},"Te"),Me=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=i(a=>`${Me}${a}`,"Le"),Je=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:q,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:D,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:P}=je({limit:a}),b=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"b");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(x,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(x,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:q}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:P.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:D,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(x,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(x,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(x,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
|
|
2
2
|
`)}))]})]})]})]})},"We");export{Je as MailPanel};
|