@lunora/studio 1.0.0-alpha.176 → 1.0.0-alpha.178
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-YKA2P52S.js → chunk-2ADU5FA5.js} +1 -1
- package/dist/standalone/{chunk-RH2G72SL.js → chunk-2NYASBOP.js} +1 -1
- package/dist/standalone/{chunk-Y3G2ZPOD.js → chunk-2W365SXI.js} +1 -1
- package/dist/standalone/{chunk-KSYIH3NO.js → chunk-2Y6PXGIS.js} +4 -4
- package/dist/standalone/{chunk-KRXDSPZ4.js → chunk-3JDH25N2.js} +1 -1
- package/dist/standalone/{chunk-L6W4QXGJ.js → chunk-5PBVNSPQ.js} +1 -1
- package/dist/standalone/{chunk-52Y5BCFW.js → chunk-5XRNQ732.js} +1 -1
- package/dist/standalone/{chunk-NXZGWCUN.js → chunk-6HVFOKP5.js} +1 -1
- package/dist/standalone/{chunk-KSRQTLE3.js → chunk-7HFDITXH.js} +1 -1
- package/dist/standalone/{chunk-3LGVSZ4D.js → chunk-AKG3SL2Z.js} +1 -1
- package/dist/standalone/{chunk-JWJFB4ZB.js → chunk-ANXXWNJG.js} +1 -1
- package/dist/standalone/{chunk-4OGX6UIE.js → chunk-BR64TOG4.js} +1 -1
- package/dist/standalone/{chunk-CO7D5QQA.js → chunk-CBNGOAD4.js} +1 -1
- package/dist/standalone/{chunk-V5PJJYCF.js → chunk-CXGPKEDJ.js} +1 -1
- package/dist/standalone/{chunk-F4W5DVWA.js → chunk-D2SSRZG5.js} +1 -1
- package/dist/standalone/{chunk-NZDNC4KZ.js → chunk-D7PVLNBP.js} +1 -1
- package/dist/standalone/{chunk-TX4KHOV2.js → chunk-E366YQXO.js} +1 -1
- package/dist/standalone/{chunk-CQ4VSTAW.js → chunk-FTR6JAWG.js} +1 -1
- package/dist/standalone/{chunk-MKRHFCPJ.js → chunk-G22LSAIH.js} +1 -1
- package/dist/standalone/{chunk-IMLGMLYE.js → chunk-GDYRC6T6.js} +1 -1
- package/dist/standalone/{chunk-4G7WDTSC.js → chunk-I3OOVU3O.js} +1 -1
- package/dist/standalone/{chunk-FKBX44FM.js → chunk-I5V3IHPF.js} +1 -1
- package/dist/standalone/{chunk-SPERI4DG.js → chunk-IBM6X4XI.js} +1 -1
- package/dist/standalone/{chunk-OS6CZ56E.js → chunk-IUKHT5XV.js} +1 -1
- package/dist/standalone/{chunk-HKPAFIMB.js → chunk-J3LCGEBD.js} +1 -1
- package/dist/standalone/{chunk-T6X7NXEE.js → chunk-KIEUFC6E.js} +1 -1
- package/dist/standalone/{chunk-X5AXABWH.js → chunk-KQMWK6QZ.js} +1 -1
- package/dist/standalone/{chunk-DL3DYOZA.js → chunk-KYMUE3MZ.js} +1 -1
- package/dist/standalone/{chunk-F7UZBTKS.js → chunk-KZDIKRZ3.js} +1 -1
- package/dist/standalone/{chunk-JXJZMINI.js → chunk-LKKZMIZK.js} +1 -1
- package/dist/standalone/{chunk-CQO3Z2AB.js → chunk-M7QQYXU4.js} +1 -1
- package/dist/standalone/{chunk-D6UKRXIS.js → chunk-MBP4SZYB.js} +1 -1
- package/dist/standalone/{chunk-5JHPL7FH.js → chunk-MNQSYFV6.js} +1 -1
- package/dist/standalone/{chunk-CWTUCGWD.js → chunk-MOMBFDIA.js} +1 -1
- package/dist/standalone/{chunk-KY7U3EOR.js → chunk-MOYNBJNW.js} +1 -1
- package/dist/standalone/{chunk-SZUW2MXD.js → chunk-MWUR2KP6.js} +1 -1
- package/dist/standalone/{chunk-GXVTU7FF.js → chunk-N2VWHDGA.js} +1 -1
- package/dist/standalone/{chunk-WDYULSDM.js → chunk-NLHKRU3D.js} +2 -2
- package/dist/standalone/{chunk-I3PD3ZML.js → chunk-P4V5VRUR.js} +1 -1
- package/dist/standalone/{chunk-XAGNBUL3.js → chunk-P6F4CNT5.js} +1 -1
- package/dist/standalone/{chunk-I4YTKLE7.js → chunk-PHYKYBCE.js} +1 -1
- package/dist/standalone/{chunk-RQPSYNGU.js → chunk-QCFJKKLX.js} +1 -1
- package/dist/standalone/{chunk-YYR4P344.js → chunk-RSULZ5QU.js} +1 -1
- package/dist/standalone/{chunk-KPISDHKV.js → chunk-RY66ZJJQ.js} +1 -1
- package/dist/standalone/{chunk-OBSMXNVJ.js → chunk-SA5SGD3V.js} +1 -1
- package/dist/standalone/{chunk-N3MMJZQW.js → chunk-TXLWUHAU.js} +1 -1
- package/dist/standalone/{chunk-XTC4KFYF.js → chunk-U2YJ64UT.js} +1 -1
- package/dist/standalone/{chunk-B62IS74K.js → chunk-U3T6FYYZ.js} +1 -1
- package/dist/standalone/{chunk-E67LBUZU.js → chunk-U7A2W7UG.js} +1 -1
- package/dist/standalone/{chunk-O7D7DJVB.js → chunk-URBHAYYZ.js} +1 -1
- package/dist/standalone/{chunk-KMLTYAJF.js → chunk-V5FOHTRB.js} +1 -1
- package/dist/standalone/{chunk-3UOVQ3YN.js → chunk-VR3OL4A6.js} +1 -1
- package/dist/standalone/{chunk-7PEQ4RPL.js → chunk-WHPKXZN2.js} +1 -1
- package/dist/standalone/{chunk-WWHDFIP5.js → chunk-WV2AW6IT.js} +1 -1
- package/dist/standalone/{chunk-VYLHUJVG.js → chunk-WX6MJS7P.js} +1 -1
- package/dist/standalone/{chunk-ERLNG3BC.js → chunk-Y5IE2W4U.js} +1 -1
- package/dist/standalone/{chunk-TPVTZE6M.js → chunk-YAAM5IKA.js} +1 -1
- package/dist/standalone/{chunk-KF2YSK5Z.js → chunk-YK7JO7NP.js} +1 -1
- package/dist/standalone/{chunk-JMXDVWZG.js → chunk-YRZFU7OM.js} +1 -1
- package/dist/standalone/chunk-Z7WCKAUJ.js +11 -0
- package/dist/standalone/{chunk-EFMYOSXQ.js → chunk-ZTA7WN4R.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
- package/dist/standalone/chunk-VWWJIICI.js +0 -11
|
@@ -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-MBP4SZYB.js";import{f as Pe}from"./chunk-Z7WCKAUJ.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-HKPAFIMB.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-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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as P}from"./chunk-
|
|
1
|
+
import{b as P}from"./chunk-2ADU5FA5.js";import{c as K,d as X,e as z,f as L,h as B,i as E,j as G,k as q,l as A,m as O,n as W,o as $,p as D}from"./chunk-URBHAYYZ.js";import{a as F,b as H,c as I,d as S,e as J,f as M}from"./chunk-HEAQVSNS.js";import{d as C,n as j}from"./chunk-FODLDLE2.js";import{a as f,d as T,f as U,g as V}from"./chunk-YKXDMIHQ.js";var N=T(U(),1);var t=T(V(),1);var _=50,R={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},Q=f(r=>{let a=r.columns.find(e=>r.rows.length>0&&r.rows.every(n=>typeof n[e]=="number"))??null;return{label:r.columns.find(e=>e!==a)??null,value:a}},"D"),Y=f(r=>{let a=(0,N.c)(3),{data:e,kind:n}=r,l;return a[0]!==e||a[1]!==n?(l=(0,t.jsx)(G,{className:"h-full w-full",config:R,children:n==="area"?(0,t.jsxs)(E,{data:e,children:[(0,t.jsx)(K,{vertical:!1}),(0,t.jsx)(L,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(A,{content:(0,t.jsx)(q,{})}),(0,t.jsx)(z,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,t.jsxs)(B,{data:e,children:[(0,t.jsx)(K,{vertical:!1}),(0,t.jsx)(L,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(A,{content:(0,t.jsx)(q,{})}),(0,t.jsx)(X,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=e,a[1]=n,a[2]=l):l=a[2],l},"J"),na=f(r=>{let a=(0,N.c)(21),{axes:e,kind:n,result:l}=r,u=C(),o;a[0]!==l?(o=Q(l),a[0]=l,a[1]=o):o=a[1];let d=o,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let s=m,c=e!==void 0&&s.has(e.x)?e.x:d.label,p;a[4]!==e?.y||a[5]!==s?(p=e?.y.find(i=>s.has(i)),a[4]=e?.y,a[5]=s,a[6]=p):p=a[6];let x=p,y=x??d.value,b;a[7]!==c||a[8]!==l.rows||a[9]!==y?(b=y===null?[]:l.rows.slice(0,_).map((i,w)=>({label:c===null?`#${(w+1).toString()}`:j(i[c]),value:Number(i[y])||0})),a[7]=c,a[8]=l.rows,a[9]=y,a[10]=b):b=a[10];let k=b;if(y===null){let i;a[11]!==u?(i=u("No numeric column to chart."),a[11]=u,a[12]=i):i=a[12];let w;return a[13]!==i?(w=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:i}),a[13]=i,a[14]=w):w=a[14],w}let h=n??(e!==void 0&&x!==void 0?e.kind:"bar"),v;a[15]!==k||a[16]!==h?(v=h==="bar"?(0,t.jsxs)(O,{className:"h-full w-full",config:R,data:k,children:[(0,t.jsx)($,{dataKey:"label"}),(0,t.jsx)(W,{dataKey:"value"}),(0,t.jsx)(D,{})]}):(0,t.jsx)(Y,{data:k,kind:h}),a[15]=k,a[16]=h,a[17]=v):v=a[17];let g;return a[18]!==h||a[19]!==v?(g=(0,t.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":h,"data-testid":"sql-chart",children:v}),a[18]=h,a[19]=v,a[20]=g):g=a[20],g},"oe"),oa=f(r=>{let a=(0,N.c)(19),{result:e}=r,n=C();if(e.columns.length===0){let s;a[0]!==e.rowCount||a[1]!==n?(s=n("{count} rows",{count:e.rowCount}),a[0]=e.rowCount,a[1]=n,a[2]=s):s=a[2];let c;return a[3]!==s?(c=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:s}),a[3]=s,a[4]=c):c=a[4],c}let l;a[5]!==e.columns?(l=e.columns.map(Z),a[5]=e.columns,a[6]=l):l=a[6];let u;a[7]!==l?(u=(0,t.jsx)(H,{className:"sticky top-0 z-10 bg-muted",children:(0,t.jsx)(S,{children:l})}),a[7]=l,a[8]=u):u=a[8];let o;if(a[9]!==e.columns||a[10]!==e.rows){let s;a[12]!==e.columns?(s=f((c,p)=>(0,t.jsx)(S,{"data-testid":"sql-row",children:e.columns.map(x=>(0,t.jsx)(M,{className:"max-w-md truncate font-mono text-xs",children:(0,t.jsx)(P,{value:c[x]})},x))},p),"s"),a[12]=e.columns,a[13]=s):s=a[13],o=e.rows.map(s),a[9]=e.columns,a[10]=e.rows,a[11]=o}else o=a[11];let d;a[14]!==o?(d=(0,t.jsx)(I,{children:o}),a[14]=o,a[15]=d):d=a[15];let m;return a[16]!==u||a[17]!==d?(m=(0,t.jsxs)(F,{"data-testid":"sql-rows",children:[u,d]}),a[16]=u,a[17]=d,a[18]=m):m=a[18],m},"ne");function Z(r){return(0,t.jsx)(J,{children:r},r)}f(Z,"P");export{na as a,oa as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as F,b as O}from"./chunk-CMA4PTV7.js";import{a as B}from"./chunk-BOTGXX4H.js";import{a as V}from"./chunk-S3CRZLGS.js";import{a as T}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as L}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as j}from"./chunk-
|
|
1
|
+
import{a as F,b as O}from"./chunk-CMA4PTV7.js";import{a as B}from"./chunk-BOTGXX4H.js";import{a as V}from"./chunk-S3CRZLGS.js";import{a as T}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as L}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as j}from"./chunk-KZDIKRZ3.js";import"./chunk-ULIQFBZU.js";import"./chunk-2W365SXI.js";import"./chunk-35DM4JJG.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as M}from"./chunk-MBP4SZYB.js";import"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as K}from"./chunk-FKVZRPV5.js";import{a as z,b as A,c as q,d as p,e as n,f as d}from"./chunk-HEAQVSNS.js";import{a as I,e as E}from"./chunk-WUWBZPUK.js";import{d as b,r as k}from"./chunk-FODLDLE2.js";import{a as i,d as y,e as ee,g as te}from"./chunk-YKXDMIHQ.js";var o=y(ee(),1);var e=y(te(),1);var D=80,re=i(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>D?`${t.slice(0,D)}\u2026`:t},"te"),ae=41,J=480,H=5,ie=i((s,t)=>F(s,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:s})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=V(s),[h,W]=(0,o.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:$}=M(R.getAuditLog,{},{live:!0,shardKey:l}),m=(0,o.useMemo)(()=>f?.entries??[],[f]),c=(0,o.useMemo)(()=>{let a=h.trim().toLowerCase();return a===""?m:m.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[m,h]),x=(0,o.useRef)(null),v=O({count:c.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),G=v.getTotalSize(),N=u[0]?.start??0,w=G-(u.at(-1)?.end??0),Q={height:N},X={height:w},Y=i(a=>{W(a.target.value)},"_");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(T,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(B,{message:$,prefix:"au"}),(0,e.jsx)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:h})]}),g!==null&&(0,e.jsx)(j,{error:Z,testId:"au-error"}),g===null&&!_&&c.length===0&&(0,e.jsx)(K,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),c.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(z,{"data-testid":"au-table",children:[(0,e.jsx)(A,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(n,{children:t("time")}),(0,e.jsx)(n,{children:t("op")}),(0,e.jsx)(n,{children:t("table")}),(0,e.jsx)(n,{children:t("id")}),(0,e.jsx)(n,{children:t("detail")})]})}),(0,e.jsxs)(q,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Q})}),u.map(a=>{let r=c[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:k(r.ts,"\u2014")}),(0,e.jsx)(d,{children:(0,e.jsx)(C,{variant:"secondary",children:r.op})}),(0,e.jsx)(d,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})})]})]})})})]})},"Ne");export{Ne as AuditPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as g}from"./chunk-
|
|
1
|
+
import{b as g}from"./chunk-YRZFU7OM.js";import"./chunk-KZDIKRZ3.js";import"./chunk-ULIQFBZU.js";import"./chunk-2W365SXI.js";import"./chunk-35DM4JJG.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-MBP4SZYB.js";import"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as r,d as h,f as S,g as A}from"./chunk-YKXDMIHQ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H}from"./chunk-66UGPQVC.js";import{b as x}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as z}from"./chunk-
|
|
1
|
+
import{a as H}from"./chunk-66UGPQVC.js";import{b as x}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as z}from"./chunk-MBP4SZYB.js";import{f as O}from"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as _}from"./chunk-FKVZRPV5.js";import{a as q,b as B,c as E,d as S,e as i,f as s}from"./chunk-HEAQVSNS.js";import{a as A,e as L}from"./chunk-WUWBZPUK.js";import{d as W}from"./chunk-FODLDLE2.js";import{a as R,d as M,f as $,g as D}from"./chunk-YKXDMIHQ.js";var I=M($(),1);var n=M(D(),1);var F=2e3,G=new Set(["open"]),ie=R(Q=>{let e=(0,I.c)(41),{read:y}=Q,t=W(),j=O(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"T"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let V=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,refetch:Y}=z(b,V);if(H(Y,!0,F),!c){let r;e[5]!==t?(r=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=r):r=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==r||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:r,title:g})})}),e[9]=r,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let l;e[14]!==a?(l=(0,n.jsx)("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=l):l=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==l||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[l,o,d]}),e[22]=l,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Shard")}),(0,n.jsx)(i,{children:t("Socket")}),(0,n.jsx)(i,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:r.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:G.has(r.wsState)?"default":"secondary",children:r.wsState})}),(0,n.jsx)(s,{children:r.confirmedMutationWatermark})]},r.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Subscription")}),(0,n.jsx)(i,{children:t("Kind")}),(0,n.jsx)(i,{children:t("Acked")}),(0,n.jsx)(i,{children:t("Cursor")}),(0,n.jsx)(i,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:r.functionPath}),(0,n.jsx)(s,{children:r.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:r.acked?"default":"secondary",children:r.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:r.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:r.pendingOptimisticLayers})]},r.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"ie");export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ce,b as Ne}from"./chunk-I3PD3ZML.js";import{a as ye}from"./chunk-YKA2P52S.js";import"./chunk-O7D7DJVB.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import{e as ke,g as we}from"./chunk-OKG3HWSJ.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as X}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as le}from"./chunk-ULIQFBZU.js";import{a as pe}from"./chunk-4ZEL6BYL.js";import"./chunk-D6UKRXIS.js";import{f as he}from"./chunk-VWWJIICI.js";import"./chunk-FSRSK4LY.js";import"./chunk-KSYIH3NO.js";import{a as me}from"./chunk-FKVZRPV5.js";import"./chunk-HEAQVSNS.js";import{a as oe,b as ue,c as ge,e as ae}from"./chunk-WUWBZPUK.js";import{d as te,f as ve,g as be,h as fe,n as xe,o as ne}from"./chunk-FODLDLE2.js";import{a as g,d as ie,e as Se,f as Ke,g as Le}from"./chunk-YKXDMIHQ.js";var Y=ie(Ke(),1),G=ie(Se(),1);var a=ie(Le(),1);var Me=ve(pe.runSql),qe=g((f,e)=>{let t=(0,Y.c)(11),n=he(),[l,d]=(0,G.useState)(void 0),[s,i]=(0,G.useState)(void 0),[h,x]=(0,G.useState)(!0),m;t[0]!==n||t[1]!==e||t[2]!==f?(m=g(async u=>{x(!0);try{let C=await n.query(Me,{sql:f},be(e));u.cancelled||(d(C),i(void 0))}catch(C){let k=C;u.cancelled||(d(void 0),i(fe(k)))}u.cancelled||x(!1)},"h"),t[0]=n,t[1]=e,t[2]=f,t[3]=m):m=t[3];let r=m,o,v;t[4]!==r?(o=g(()=>{let u={cancelled:!1};return ne(r(u)),()=>{u.cancelled=!0}},"l"),v=[r],t[4]=r,t[5]=o,t[6]=v):(o=t[5],v=t[6]),(0,G.useEffect)(o,v);let S;return t[7]!==s||t[8]!==h||t[9]!==l?(S={error:s,loading:h,result:l},t[7]=s,t[8]=h,t[9]=l,t[10]=S):S=t[10],S},"Le"),Ee=g(f=>{f.preventDefault()},"Me"),ce=g(f=>f.kind??"chart","le"),Re=g(f=>{let e=(0,Y.c)(80),{actions:t,children:n,draggedRef:l,first:d,last:s,onEdit:i,onMove:h,onRemove:x,onReorder:m,widget:r}=f,o=te(),v;e[0]!==h||e[1]!==r.id?(v=g(()=>{h(r.id,-1)},"g"),e[0]=h,e[1]=r.id,e[2]=v):v=e[2];let S=v,u;e[3]!==h||e[4]!==r.id?(u=g(()=>{h(r.id,1)},"f"),e[3]=h,e[4]=r.id,e[5]=u):u=e[5];let C=u,k;e[6]!==i||e[7]!==r.id?(k=g(()=>{i(r.id)},"x"),e[6]=i,e[7]=r.id,e[8]=k):k=e[8];let E=k,O;e[9]!==x||e[10]!==r.id?(O=g(()=>{x(r.id)},"O"),e[9]=x,e[10]=r.id,e[11]=O):O=e[11];let j=O,T;e[12]!==l||e[13]!==r.id?(T=g(()=>{l.current=r.id},"z"),e[12]=l,e[13]=r.id,e[14]=T):T=e[14];let w=T,K;e[15]!==l||e[16]!==m||e[17]!==r.id?(K=g(()=>{let de=l.current;l.current=null,de!==null&&de!==r.id&&m(de,r.id)},"K"),e[15]=l,e[16]=m,e[17]=r.id,e[18]=K):K=e[18];let _=K,R=`dashboards-widget-${r.id}`,y;e[19]!==r.title?(y=(0,a.jsx)(ge,{className:"min-w-0 cursor-grab truncate",title:r.title,children:r.title}),e[19]=r.title,e[20]=y):y=e[20];let N;e[21]!==o?(N=o("Move widget up"),e[21]=o,e[22]=N):N=e[22];let F=`dashboards-move-up-${r.id}`,H;e[23]!==o?(H=o("Move widget up"),e[23]=o,e[24]=H):H=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m6 15 6-6 6 6"})}),e[25]=D):D=e[25];let W;e[26]!==d||e[27]!==S||e[28]!==F||e[29]!==H||e[30]!==N?(W=(0,a.jsx)(X,{"aria-label":N,"data-testid":F,disabled:d,onClick:S,size:"icon-xs",title:H,type:"button",variant:"ghost",children:D}),e[26]=d,e[27]=S,e[28]=F,e[29]=H,e[30]=N,e[31]=W):W=e[31];let L;e[32]!==o?(L=o("Move widget down"),e[32]=o,e[33]=L):L=e[33];let $=`dashboards-move-down-${r.id}`,M;e[34]!==o?(M=o("Move widget down"),e[34]=o,e[35]=M):M=e[35];let z;e[36]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m6 9 6 6 6-6"})}),e[36]=z):z=e[36];let q;e[37]!==s||e[38]!==C||e[39]!==L||e[40]!==$||e[41]!==M?(q=(0,a.jsx)(X,{"aria-label":L,"data-testid":$,disabled:s,onClick:C,size:"icon-xs",title:M,type:"button",variant:"ghost",children:z}),e[37]=s,e[38]=C,e[39]=L,e[40]=$,e[41]=M,e[42]=q):q=e[42];let B;e[43]!==o?(B=o("Edit widget"),e[43]=o,e[44]=B):B=e[44];let I=`dashboards-widget-edit-${r.id}`,A;e[45]!==o?(A=o("Edit widget"),e[45]=o,e[46]=A):A=e[46];let p;e[47]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[47]=p):p=e[47];let b;e[48]!==E||e[49]!==B||e[50]!==I||e[51]!==A?(b=(0,a.jsx)(X,{"aria-label":B,"data-testid":I,onClick:E,size:"icon-xs",title:A,type:"button",variant:"ghost",children:p}),e[48]=E,e[49]=B,e[50]=I,e[51]=A,e[52]=b):b=e[52];let c;e[53]!==o?(c=o("Remove widget"),e[53]=o,e[54]=c):c=e[54];let J=`dashboards-widget-remove-${r.id}`,V;e[55]!==o?(V=o("Remove widget"),e[55]=o,e[56]=V):V=e[56];let U;e[57]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[57]=U):U=e[57];let Q;e[58]!==j||e[59]!==c||e[60]!==J||e[61]!==V?(Q=(0,a.jsx)(X,{"aria-label":c,"data-testid":J,onClick:j,size:"icon-xs",title:V,type:"button",variant:"ghost",children:U}),e[58]=j,e[59]=c,e[60]=J,e[61]=V,e[62]=Q):Q=e[62];let Z;e[63]!==t||e[64]!==W||e[65]!==q||e[66]!==b||e[67]!==Q?(Z=(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[t,W,q,b,Q]}),e[63]=t,e[64]=W,e[65]=q,e[66]=b,e[67]=Q,e[68]=Z):Z=e[68];let P;e[69]!==Z||e[70]!==y?(P=(0,a.jsxs)(ue,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[y,Z]}),e[69]=Z,e[70]=y,e[71]=P):P=e[71];let ee;e[72]!==n?(ee=(0,a.jsx)(ae,{className:"min-h-32 py-2",children:n}),e[72]=n,e[73]=ee):ee=e[73];let re;return e[74]!==w||e[75]!==_||e[76]!==P||e[77]!==ee||e[78]!==R?(re=(0,a.jsxs)(oe,{"data-testid":R,draggable:!0,onDragOver:Ee,onDragStart:w,onDrop:_,children:[P,ee]}),e[74]=w,e[75]=_,e[76]=P,e[77]=ee,e[78]=R,e[79]=re):re=e[79],re},"ce"),je=g(f=>{let e=(0,Y.c)(10),{result:t}=f,n=te(),l=t.columns[0],d=l===void 0?void 0:t.rows[0]?.[l],s;e[0]!==d||e[1]!==n?(s=d===void 0?n("\u2014"):xe(d),e[0]=d,e[1]=n,e[2]=s):s=e[2];let i;e[3]!==s?(i=(0,a.jsx)("p",{className:"truncate font-mono text-3xl font-semibold text-foreground",children:s}),e[3]=s,e[4]=i):i=e[4];let h;e[5]!==l?(h=l!==void 0&&(0,a.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:l}),e[5]=l,e[6]=h):h=e[6];let x;return e[7]!==i||e[8]!==h?(x=(0,a.jsxs)("div",{className:"flex h-full flex-col justify-center gap-1 p-4","data-testid":"dashboards-kpi",children:[i,h]}),e[7]=i,e[8]=h,e[9]=x):x=e[9],x},"qe"),ze=g(f=>{let e=(0,Y.c)(12),{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x}=f,m=x.text??"",r;e[0]!==m?(r=(0,a.jsx)("p",{className:"p-2 text-sm whitespace-pre-wrap text-muted-foreground","data-testid":"dashboards-text",children:m}),e[0]=m,e[1]=r):r=e[1];let o;return e[2]!==t||e[3]!==n||e[4]!==l||e[5]!==d||e[6]!==s||e[7]!==i||e[8]!==h||e[9]!==r||e[10]!==x?(o=(0,a.jsx)(Re,{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x,children:r}),e[2]=t,e[3]=n,e[4]=l,e[5]=d,e[6]=s,e[7]=i,e[8]=h,e[9]=r,e[10]=x,e[11]=o):o=e[11],o},"Ee"),Ae=g(f=>{let e=(0,Y.c)(52),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o=te(),{error:v,loading:S,result:u}=qe(r.sql,r.shardKey??""),C;e[0]!==r?(C=ce(r),e[0]=r,e[1]=C):C=e[1];let k=C,E;e[2]!==m||e[3]!==u||e[4]!==r.id?(E=g(()=>{u!==void 0&&m?.(r.id,u)},"q"),e[2]=m,e[3]=u,e[4]=r.id,e[5]=E):E=e[5];let O=E,j;e[6]!==l||e[7]!==k||e[8]!==m||e[9]!==O||e[10]!==u||e[11]!==o||e[12]!==r.id?(j=k==="chart"&&m!==void 0&&u!==void 0?(0,a.jsx)(X,{"aria-label":o("Suggest chart"),"data-testid":`dashboards-widget-suggest-${r.id}`,disabled:l,onClick:O,size:"icon-xs",title:o(l?"Suggesting\u2026":"Suggest chart"),type:"button",variant:"ghost",children:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m12 3 1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3ZM18 15l.9 2.1 2.1.9-2.1.9L18 21l-.9-2.1-2.1-.9 2.1-.9L18 15Z"})})}):void 0,e[6]=l,e[7]=k,e[8]=m,e[9]=O,e[10]=u,e[11]=o,e[12]=r.id,e[13]=j):j=e[13];let T=j,w;e[14]!==v||e[15]!==r.id?(w=v!==void 0&&(0,a.jsx)(le,{className:"font-mono text-xs",testId:`dashboards-widget-error-${r.id}`,variant:"destructive",children:v}),e[14]=v,e[15]=r.id,e[16]=w):w=e[16];let K;e[17]!==v||e[18]!==S||e[19]!==u||e[20]!==o||e[21]!==r.id?(K=v===void 0&&S&&u===void 0&&(0,a.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${r.id}`,children:o("Running\u2026")}),e[17]=v,e[18]=S,e[19]=u,e[20]=o,e[21]=r.id,e[22]=K):K=e[22];let _;e[23]!==v||e[24]!==k||e[25]!==u||e[26]!==r.chartAxes||e[27]!==r.chartKind?(_=v===void 0&&u!==void 0&&k==="chart"&&(0,a.jsx)(Ce,{axes:r.chartAxes,kind:r.chartKind,result:u}),e[23]=v,e[24]=k,e[25]=u,e[26]=r.chartAxes,e[27]=r.chartKind,e[28]=_):_=e[28];let R;e[29]!==v||e[30]!==k||e[31]!==u?(R=v===void 0&&u!==void 0&&k==="kpi"&&(0,a.jsx)(je,{result:u}),e[29]=v,e[30]=k,e[31]=u,e[32]=R):R=e[32];let y;e[33]!==v||e[34]!==k||e[35]!==u?(y=v===void 0&&u!==void 0&&k==="table"&&(0,a.jsx)("div",{className:"max-h-72 overflow-auto",children:(0,a.jsx)(Ne,{result:u})}),e[33]=v,e[34]=k,e[35]=u,e[36]=y):y=e[36];let N;return e[37]!==t||e[38]!==n||e[39]!==d||e[40]!==s||e[41]!==i||e[42]!==h||e[43]!==x||e[44]!==T||e[45]!==w||e[46]!==K||e[47]!==_||e[48]!==R||e[49]!==y||e[50]!==r?(N=(0,a.jsxs)(Re,{actions:T,draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r,children:[w,K,_,R,y]}),e[37]=t,e[38]=n,e[39]=d,e[40]=s,e[41]=i,e[42]=h,e[43]=x,e[44]=T,e[45]=w,e[46]=K,e[47]=_,e[48]=R,e[49]=y,e[50]=r,e[51]=N):N=e[51],N},"Ae"),_e=g(f=>{let e=(0,Y.c)(11),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o;return e[0]!==t||e[1]!==n||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==i||e[6]!==h||e[7]!==x||e[8]!==m||e[9]!==r?(o=ce(r)==="text"?(0,a.jsx)(ze,{draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r}):(0,a.jsx)(Ae,{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}),e[0]=t,e[1]=n,e[2]=l,e[3]=d,e[4]=s,e[5]=i,e[6]=h,e[7]=x,e[8]=m,e[9]=r,e[10]=o):o=e[10],o},"Te"),We=["bar","line","area"],$e=["chart","kpi","table","text"],Be="lunora-studio-dashboards",se={chartKind:"bar",kind:"chart",shardKey:"",sql:"",text:"",title:""},Ie=g((f,e)=>t=>t.map(n=>n.id===f?{...n,chartAxes:e,chartKind:e.kind}:n),"De"),Te=g((f,e)=>t=>{let n=t.find(s=>s.id===f),l=t.filter(s=>s.id!==f),d=l.findIndex(s=>s.id===e);return n===void 0||d===-1?t:[...l.slice(0,d),n,...l.slice(d)]},"je"),De=g((f,e)=>e(f==="line"?"Line":f==="area"?"Area":"Bar"),"ze"),Oe=g((f,e)=>e(f==="kpi"?"Single value":f==="table"?"Table":f==="text"?"Text":"Chart"),"Be"),Fe=g(f=>{let e=(0,Y.c)(82),{draft:t,editing:n,onCancel:l,onChange:d,onSubmit:s}=f,i=te(),h;e[0]!==t||e[1]!==d?(h=g(c=>{d({...t,title:c.target.value})},"c"),e[0]=t,e[1]=d,e[2]=h):h=e[2];let x=h,m;e[3]!==t||e[4]!==d?(m=g(c=>{d({...t,sql:c.target.value})},"h"),e[3]=t,e[4]=d,e[5]=m):m=e[5];let r=m,o;e[6]!==t||e[7]!==d?(o=g(c=>{d({...t,text:c.target.value})},"l"),e[6]=t,e[7]=d,e[8]=o):o=e[8];let v=o,S;e[9]!==t||e[10]!==d?(S=g(c=>{d({...t,shardKey:c.target.value})},"N"),e[9]=t,e[10]=d,e[11]=S):S=e[11];let u=S,C;e[12]!==t||e[13]!==d?(C=g(c=>{d({...t,chartKind:c.target.value})},"y"),e[12]=t,e[13]=d,e[14]=C):C=e[14];let k=C,E;e[15]!==t||e[16]!==d?(E=g(c=>{d({...t,kind:c.target.value})},"q"),e[15]=t,e[16]=d,e[17]=E):E=e[17];let O=E,j;e[18]!==s?(j=g(()=>{s()},"E"),e[18]=s,e[19]=j):j=e[19];let T=j,w=t.kind==="text",K;e[20]!==t.sql||e[21]!==t.text||e[22]!==t.title||e[23]!==w?(K=t.title.trim()!==""&&(w?t.text.trim()!=="":t.sql.trim()!==""),e[20]=t.sql,e[21]=t.text,e[22]=t.title,e[23]=w,e[24]=K):K=e[24];let _=K,R;e[25]!==i?(R=i("Widget title"),e[25]=i,e[26]=R):R=e[26];let y;e[27]!==i?(y=i("Widget title"),e[27]=i,e[28]=y):y=e[28];let N;e[29]!==t.title||e[30]!==x||e[31]!==y||e[32]!==R?(N=(0,a.jsx)("input",{"aria-label":R,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:x,placeholder:y,type:"text",value:t.title}),e[29]=t.title,e[30]=x,e[31]=y,e[32]=R,e[33]=N):N=e[33];let F;e[34]!==i?(F=i("Widget type"),e[34]=i,e[35]=F):F=e[35];let H=t.kind,D;e[36]!==i?(D=$e.map(c=>(0,a.jsx)("option",{value:c,children:Oe(c,i)},c)),e[36]=i,e[37]=D):D=e[37];let W;e[38]!==t.kind||e[39]!==O||e[40]!==F||e[41]!==D?(W=(0,a.jsx)("select",{"aria-label":F,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-widget-kind",onChange:O,value:H,children:D}),e[38]=t.kind,e[39]=O,e[40]=F,e[41]=D,e[42]=W):W=e[42];let L;e[43]!==t.sql||e[44]!==t.text||e[45]!==w||e[46]!==r||e[47]!==v||e[48]!==i?(L=w?(0,a.jsx)("textarea",{"aria-label":i("Text"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-text",onChange:v,placeholder:i("Notes for whoever reads this dashboard."),value:t.text}):(0,a.jsx)("textarea",{"aria-label":i("SQL query"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:r,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[43]=t.sql,e[44]=t.text,e[45]=w,e[46]=r,e[47]=v,e[48]=i,e[49]=L):L=e[49];let $;e[50]!==t.chartKind||e[51]!==t.kind||e[52]!==k||e[53]!==i?($=t.kind==="chart"&&(0,a.jsx)("select",{"aria-label":i("Chart type"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-kind",onChange:k,value:t.chartKind,children:We.map(c=>(0,a.jsx)("option",{value:c,children:De(c,i)},c))}),e[50]=t.chartKind,e[51]=t.kind,e[52]=k,e[53]=i,e[54]=$):$=e[54];let M;e[55]!==t.shardKey||e[56]!==w||e[57]!==u||e[58]!==i?(M=!w&&(0,a.jsx)("input",{"aria-label":i("Shard key (optional)"),className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:u,placeholder:i("Shard key (optional)"),type:"text",value:t.shardKey}),e[55]=t.shardKey,e[56]=w,e[57]=u,e[58]=i,e[59]=M):M=e[59];let z;e[60]!==i?(z=i("Cancel"),e[60]=i,e[61]=z):z=e[61];let q;e[62]!==l||e[63]!==z?(q=(0,a.jsx)(X,{"data-testid":"dashboards-form-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:z}),e[62]=l,e[63]=z,e[64]=q):q=e[64];let B=!_,I;e[65]!==n||e[66]!==i?(I=i(n?"Save widget":"Add widget"),e[65]=n,e[66]=i,e[67]=I):I=e[67];let A;e[68]!==T||e[69]!==B||e[70]!==I?(A=(0,a.jsx)(X,{"data-testid":"dashboards-form-save",disabled:B,onClick:T,size:"sm",type:"button",children:I}),e[68]=T,e[69]=B,e[70]=I,e[71]=A):A=e[71];let p;e[72]!==q||e[73]!==A?(p=(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[q,A]}),e[72]=q,e[73]=A,e[74]=p):p=e[74];let b;return e[75]!==N||e[76]!==W||e[77]!==L||e[78]!==$||e[79]!==M||e[80]!==p?(b=(0,a.jsx)(oe,{"data-testid":"dashboards-form",children:(0,a.jsxs)(ae,{className:"flex flex-col gap-3 py-4",children:[N,W,L,$,M,p]})}),e[75]=N,e[76]=W,e[77]=L,e[78]=$,e[79]=M,e[80]=p,e[81]=b):b=e[81],b},"Fe"),tt=g(f=>{let e=(0,Y.c)(53),{initialShardKey:t}=f,n=te(),[l,d]=ke(Be),[s,i]=(0,G.useState)(se),[h,x]=(0,G.useState)(null),[m,r]=(0,G.useState)(!1),o=ye(t??""),[v,S]=(0,G.useState)(null),u=(0,G.useRef)(null),C;e[0]!==t?(C=g(()=>{x(null),i({...se,shardKey:t??""}),r(!0)},"y"),e[0]=t,e[1]=C):C=e[1];let k=C,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=g(()=>{r(!1),x(null),i(se)},"q"),e[2]=E):E=e[2];let O=E,j;e[3]!==l?(j=g(p=>{let b=l.find(c=>c.id===p);b!==void 0&&(x(p),i({chartKind:b.chartKind??"bar",kind:ce(b),shardKey:b.shardKey??"",sql:b.sql,text:b.text??"",title:b.title}),r(!0))},"E"),e[3]=l,e[4]=j):j=e[4];let T=j,w;e[5]!==o||e[6]!==d?(w=g((p,b)=>{S(p),ne((async()=>{let c=await o.inferChart({columns:b.columns,rowCount:b.rowCount});c!==void 0&&d(Ie(p,c))})().finally(()=>{S(c=>c===p?null:c)}))},"C"),e[5]=o,e[6]=d,e[7]=w):w=e[7];let K=w,_;e[8]!==d?(_=g(p=>{d(b=>b.filter(c=>c.id!==p))},"W"),e[8]=d,e[9]=_):_=e[9];let R=_,y;e[10]!==d?(y=g((p,b)=>{d(Te(p,b))},"k"),e[10]=d,e[11]=y):y=e[11];let N=y,F;e[12]!==d?(F=g((p,b)=>{d(c=>{let J=c.findIndex(P=>P.id===p),V=J+b;if(J===-1||V<0||V>=c.length)return c;let U=[...c],Q=U[J],Z=U[V];return Q===void 0||Z===void 0?c:(U[J]=Z,U[V]=Q,U)})},"_"),e[12]=d,e[13]=F):F=e[13];let H=F,D;e[14]!==s||e[15]!==h||e[16]!==d?(D=g(()=>{let p=s.title.trim(),b=s.sql.trim(),c=s.text.trim(),{chartKind:J,kind:V}=s;if(p===""||(V==="text"?c==="":b===""))return;let U={chartKind:J,kind:V,shardKey:s.shardKey.trim(),sql:b,text:c,title:p};d(h===null?Q=>[...Q,{...U,id:we("w")}]:Q=>Q.map(Z=>Z.id===h?{...Z,...U}:Z)),O()},"B"),e[14]=s,e[15]=h,e[16]=d,e[17]=D):D=e[17];let W=D,L;e[18]!==n?(L=n("Charts, values, tables, and notes. Drag a tile to reorder."),e[18]=n,e[19]=L):L=e[19];let $;e[20]!==L?($=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:L}),e[20]=L,e[21]=$):$=e[21];let M;e[22]!==m||e[23]!==k||e[24]!==n?(M=!m&&(0,a.jsx)(X,{"data-testid":"dashboards-add",onClick:k,size:"sm",type:"button",children:n("Add widget")}),e[22]=m,e[23]=k,e[24]=n,e[25]=M):M=e[25];let z;e[26]!==$||e[27]!==M?(z=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[$,M]}),e[26]=$,e[27]=M,e[28]=z):z=e[28];let q;e[29]!==o||e[30]!==n?(q=o.reason("chart")!==void 0&&(0,a.jsx)(le,{className:"text-xs",testId:"dashboards-suggest-error",variant:"destructive",children:n("Could not suggest a chart for that result.")}),e[29]=o,e[30]=n,e[31]=q):q=e[31];let B;e[32]!==s||e[33]!==h||e[34]!==m||e[35]!==W?(B=m&&(0,a.jsx)(Fe,{draft:s,editing:h!==null,onCancel:O,onChange:i,onSubmit:W}),e[32]=s,e[33]=h,e[34]=m,e[35]=W,e[36]=B):B=e[36];let I;e[37]!==o.unavailable||e[38]!==m||e[39]!==v||e[40]!==T||e[41]!==H||e[42]!==R||e[43]!==N||e[44]!==K||e[45]!==n||e[46]!==l?(I=l.length===0&&!m?(0,a.jsx)(me,{description:n("Add a chart, a single value, a table, or a note. Everything is saved on this browser."),testId:"dashboards-empty",title:n("No widgets yet")}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:l.map((p,b)=>(0,a.jsx)(_e,{draggedRef:u,first:b===0,inferring:v===p.id,last:b===l.length-1,onEdit:T,onMove:H,onRemove:R,onReorder:N,onSuggest:o.unavailable?void 0:K,widget:p},p.id))}),e[37]=o.unavailable,e[38]=m,e[39]=v,e[40]=T,e[41]=H,e[42]=R,e[43]=N,e[44]=K,e[45]=n,e[46]=l,e[47]=I):I=e[47];let A;return e[48]!==z||e[49]!==q||e[50]!==B||e[51]!==I?(A=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[z,q,B,I]}),e[48]=z,e[49]=q,e[50]=B,e[51]=I,e[52]=A):A=e[52],A},"it");export{tt as default};
|
|
1
|
+
import{a as Ce,b as Ne}from"./chunk-P4V5VRUR.js";import{a as ye}from"./chunk-2ADU5FA5.js";import"./chunk-URBHAYYZ.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import{e as ke,g as we}from"./chunk-OKG3HWSJ.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as X}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as le}from"./chunk-ULIQFBZU.js";import{a as pe}from"./chunk-4ZEL6BYL.js";import"./chunk-MBP4SZYB.js";import{f as he}from"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as me}from"./chunk-FKVZRPV5.js";import"./chunk-HEAQVSNS.js";import{a as oe,b as ue,c as ge,e as ae}from"./chunk-WUWBZPUK.js";import{d as te,f as ve,g as be,h as fe,n as xe,o as ne}from"./chunk-FODLDLE2.js";import{a as g,d as ie,e as Se,f as Ke,g as Le}from"./chunk-YKXDMIHQ.js";var Y=ie(Ke(),1),G=ie(Se(),1);var a=ie(Le(),1);var Me=ve(pe.runSql),qe=g((f,e)=>{let t=(0,Y.c)(11),n=he(),[l,d]=(0,G.useState)(void 0),[s,i]=(0,G.useState)(void 0),[h,x]=(0,G.useState)(!0),m;t[0]!==n||t[1]!==e||t[2]!==f?(m=g(async u=>{x(!0);try{let C=await n.query(Me,{sql:f},be(e));u.cancelled||(d(C),i(void 0))}catch(C){let k=C;u.cancelled||(d(void 0),i(fe(k)))}u.cancelled||x(!1)},"h"),t[0]=n,t[1]=e,t[2]=f,t[3]=m):m=t[3];let r=m,o,v;t[4]!==r?(o=g(()=>{let u={cancelled:!1};return ne(r(u)),()=>{u.cancelled=!0}},"l"),v=[r],t[4]=r,t[5]=o,t[6]=v):(o=t[5],v=t[6]),(0,G.useEffect)(o,v);let S;return t[7]!==s||t[8]!==h||t[9]!==l?(S={error:s,loading:h,result:l},t[7]=s,t[8]=h,t[9]=l,t[10]=S):S=t[10],S},"Le"),Ee=g(f=>{f.preventDefault()},"Me"),ce=g(f=>f.kind??"chart","le"),Re=g(f=>{let e=(0,Y.c)(80),{actions:t,children:n,draggedRef:l,first:d,last:s,onEdit:i,onMove:h,onRemove:x,onReorder:m,widget:r}=f,o=te(),v;e[0]!==h||e[1]!==r.id?(v=g(()=>{h(r.id,-1)},"g"),e[0]=h,e[1]=r.id,e[2]=v):v=e[2];let S=v,u;e[3]!==h||e[4]!==r.id?(u=g(()=>{h(r.id,1)},"f"),e[3]=h,e[4]=r.id,e[5]=u):u=e[5];let C=u,k;e[6]!==i||e[7]!==r.id?(k=g(()=>{i(r.id)},"x"),e[6]=i,e[7]=r.id,e[8]=k):k=e[8];let E=k,O;e[9]!==x||e[10]!==r.id?(O=g(()=>{x(r.id)},"O"),e[9]=x,e[10]=r.id,e[11]=O):O=e[11];let j=O,T;e[12]!==l||e[13]!==r.id?(T=g(()=>{l.current=r.id},"z"),e[12]=l,e[13]=r.id,e[14]=T):T=e[14];let w=T,K;e[15]!==l||e[16]!==m||e[17]!==r.id?(K=g(()=>{let de=l.current;l.current=null,de!==null&&de!==r.id&&m(de,r.id)},"K"),e[15]=l,e[16]=m,e[17]=r.id,e[18]=K):K=e[18];let _=K,R=`dashboards-widget-${r.id}`,y;e[19]!==r.title?(y=(0,a.jsx)(ge,{className:"min-w-0 cursor-grab truncate",title:r.title,children:r.title}),e[19]=r.title,e[20]=y):y=e[20];let N;e[21]!==o?(N=o("Move widget up"),e[21]=o,e[22]=N):N=e[22];let F=`dashboards-move-up-${r.id}`,H;e[23]!==o?(H=o("Move widget up"),e[23]=o,e[24]=H):H=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m6 15 6-6 6 6"})}),e[25]=D):D=e[25];let W;e[26]!==d||e[27]!==S||e[28]!==F||e[29]!==H||e[30]!==N?(W=(0,a.jsx)(X,{"aria-label":N,"data-testid":F,disabled:d,onClick:S,size:"icon-xs",title:H,type:"button",variant:"ghost",children:D}),e[26]=d,e[27]=S,e[28]=F,e[29]=H,e[30]=N,e[31]=W):W=e[31];let L;e[32]!==o?(L=o("Move widget down"),e[32]=o,e[33]=L):L=e[33];let $=`dashboards-move-down-${r.id}`,M;e[34]!==o?(M=o("Move widget down"),e[34]=o,e[35]=M):M=e[35];let z;e[36]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m6 9 6 6 6-6"})}),e[36]=z):z=e[36];let q;e[37]!==s||e[38]!==C||e[39]!==L||e[40]!==$||e[41]!==M?(q=(0,a.jsx)(X,{"aria-label":L,"data-testid":$,disabled:s,onClick:C,size:"icon-xs",title:M,type:"button",variant:"ghost",children:z}),e[37]=s,e[38]=C,e[39]=L,e[40]=$,e[41]=M,e[42]=q):q=e[42];let B;e[43]!==o?(B=o("Edit widget"),e[43]=o,e[44]=B):B=e[44];let I=`dashboards-widget-edit-${r.id}`,A;e[45]!==o?(A=o("Edit widget"),e[45]=o,e[46]=A):A=e[46];let p;e[47]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[47]=p):p=e[47];let b;e[48]!==E||e[49]!==B||e[50]!==I||e[51]!==A?(b=(0,a.jsx)(X,{"aria-label":B,"data-testid":I,onClick:E,size:"icon-xs",title:A,type:"button",variant:"ghost",children:p}),e[48]=E,e[49]=B,e[50]=I,e[51]=A,e[52]=b):b=e[52];let c;e[53]!==o?(c=o("Remove widget"),e[53]=o,e[54]=c):c=e[54];let J=`dashboards-widget-remove-${r.id}`,V;e[55]!==o?(V=o("Remove widget"),e[55]=o,e[56]=V):V=e[56];let U;e[57]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[57]=U):U=e[57];let Q;e[58]!==j||e[59]!==c||e[60]!==J||e[61]!==V?(Q=(0,a.jsx)(X,{"aria-label":c,"data-testid":J,onClick:j,size:"icon-xs",title:V,type:"button",variant:"ghost",children:U}),e[58]=j,e[59]=c,e[60]=J,e[61]=V,e[62]=Q):Q=e[62];let Z;e[63]!==t||e[64]!==W||e[65]!==q||e[66]!==b||e[67]!==Q?(Z=(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[t,W,q,b,Q]}),e[63]=t,e[64]=W,e[65]=q,e[66]=b,e[67]=Q,e[68]=Z):Z=e[68];let P;e[69]!==Z||e[70]!==y?(P=(0,a.jsxs)(ue,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[y,Z]}),e[69]=Z,e[70]=y,e[71]=P):P=e[71];let ee;e[72]!==n?(ee=(0,a.jsx)(ae,{className:"min-h-32 py-2",children:n}),e[72]=n,e[73]=ee):ee=e[73];let re;return e[74]!==w||e[75]!==_||e[76]!==P||e[77]!==ee||e[78]!==R?(re=(0,a.jsxs)(oe,{"data-testid":R,draggable:!0,onDragOver:Ee,onDragStart:w,onDrop:_,children:[P,ee]}),e[74]=w,e[75]=_,e[76]=P,e[77]=ee,e[78]=R,e[79]=re):re=e[79],re},"ce"),je=g(f=>{let e=(0,Y.c)(10),{result:t}=f,n=te(),l=t.columns[0],d=l===void 0?void 0:t.rows[0]?.[l],s;e[0]!==d||e[1]!==n?(s=d===void 0?n("\u2014"):xe(d),e[0]=d,e[1]=n,e[2]=s):s=e[2];let i;e[3]!==s?(i=(0,a.jsx)("p",{className:"truncate font-mono text-3xl font-semibold text-foreground",children:s}),e[3]=s,e[4]=i):i=e[4];let h;e[5]!==l?(h=l!==void 0&&(0,a.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:l}),e[5]=l,e[6]=h):h=e[6];let x;return e[7]!==i||e[8]!==h?(x=(0,a.jsxs)("div",{className:"flex h-full flex-col justify-center gap-1 p-4","data-testid":"dashboards-kpi",children:[i,h]}),e[7]=i,e[8]=h,e[9]=x):x=e[9],x},"qe"),ze=g(f=>{let e=(0,Y.c)(12),{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x}=f,m=x.text??"",r;e[0]!==m?(r=(0,a.jsx)("p",{className:"p-2 text-sm whitespace-pre-wrap text-muted-foreground","data-testid":"dashboards-text",children:m}),e[0]=m,e[1]=r):r=e[1];let o;return e[2]!==t||e[3]!==n||e[4]!==l||e[5]!==d||e[6]!==s||e[7]!==i||e[8]!==h||e[9]!==r||e[10]!==x?(o=(0,a.jsx)(Re,{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x,children:r}),e[2]=t,e[3]=n,e[4]=l,e[5]=d,e[6]=s,e[7]=i,e[8]=h,e[9]=r,e[10]=x,e[11]=o):o=e[11],o},"Ee"),Ae=g(f=>{let e=(0,Y.c)(52),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o=te(),{error:v,loading:S,result:u}=qe(r.sql,r.shardKey??""),C;e[0]!==r?(C=ce(r),e[0]=r,e[1]=C):C=e[1];let k=C,E;e[2]!==m||e[3]!==u||e[4]!==r.id?(E=g(()=>{u!==void 0&&m?.(r.id,u)},"q"),e[2]=m,e[3]=u,e[4]=r.id,e[5]=E):E=e[5];let O=E,j;e[6]!==l||e[7]!==k||e[8]!==m||e[9]!==O||e[10]!==u||e[11]!==o||e[12]!==r.id?(j=k==="chart"&&m!==void 0&&u!==void 0?(0,a.jsx)(X,{"aria-label":o("Suggest chart"),"data-testid":`dashboards-widget-suggest-${r.id}`,disabled:l,onClick:O,size:"icon-xs",title:o(l?"Suggesting\u2026":"Suggest chart"),type:"button",variant:"ghost",children:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m12 3 1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3ZM18 15l.9 2.1 2.1.9-2.1.9L18 21l-.9-2.1-2.1-.9 2.1-.9L18 15Z"})})}):void 0,e[6]=l,e[7]=k,e[8]=m,e[9]=O,e[10]=u,e[11]=o,e[12]=r.id,e[13]=j):j=e[13];let T=j,w;e[14]!==v||e[15]!==r.id?(w=v!==void 0&&(0,a.jsx)(le,{className:"font-mono text-xs",testId:`dashboards-widget-error-${r.id}`,variant:"destructive",children:v}),e[14]=v,e[15]=r.id,e[16]=w):w=e[16];let K;e[17]!==v||e[18]!==S||e[19]!==u||e[20]!==o||e[21]!==r.id?(K=v===void 0&&S&&u===void 0&&(0,a.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${r.id}`,children:o("Running\u2026")}),e[17]=v,e[18]=S,e[19]=u,e[20]=o,e[21]=r.id,e[22]=K):K=e[22];let _;e[23]!==v||e[24]!==k||e[25]!==u||e[26]!==r.chartAxes||e[27]!==r.chartKind?(_=v===void 0&&u!==void 0&&k==="chart"&&(0,a.jsx)(Ce,{axes:r.chartAxes,kind:r.chartKind,result:u}),e[23]=v,e[24]=k,e[25]=u,e[26]=r.chartAxes,e[27]=r.chartKind,e[28]=_):_=e[28];let R;e[29]!==v||e[30]!==k||e[31]!==u?(R=v===void 0&&u!==void 0&&k==="kpi"&&(0,a.jsx)(je,{result:u}),e[29]=v,e[30]=k,e[31]=u,e[32]=R):R=e[32];let y;e[33]!==v||e[34]!==k||e[35]!==u?(y=v===void 0&&u!==void 0&&k==="table"&&(0,a.jsx)("div",{className:"max-h-72 overflow-auto",children:(0,a.jsx)(Ne,{result:u})}),e[33]=v,e[34]=k,e[35]=u,e[36]=y):y=e[36];let N;return e[37]!==t||e[38]!==n||e[39]!==d||e[40]!==s||e[41]!==i||e[42]!==h||e[43]!==x||e[44]!==T||e[45]!==w||e[46]!==K||e[47]!==_||e[48]!==R||e[49]!==y||e[50]!==r?(N=(0,a.jsxs)(Re,{actions:T,draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r,children:[w,K,_,R,y]}),e[37]=t,e[38]=n,e[39]=d,e[40]=s,e[41]=i,e[42]=h,e[43]=x,e[44]=T,e[45]=w,e[46]=K,e[47]=_,e[48]=R,e[49]=y,e[50]=r,e[51]=N):N=e[51],N},"Ae"),_e=g(f=>{let e=(0,Y.c)(11),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o;return e[0]!==t||e[1]!==n||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==i||e[6]!==h||e[7]!==x||e[8]!==m||e[9]!==r?(o=ce(r)==="text"?(0,a.jsx)(ze,{draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r}):(0,a.jsx)(Ae,{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}),e[0]=t,e[1]=n,e[2]=l,e[3]=d,e[4]=s,e[5]=i,e[6]=h,e[7]=x,e[8]=m,e[9]=r,e[10]=o):o=e[10],o},"Te"),We=["bar","line","area"],$e=["chart","kpi","table","text"],Be="lunora-studio-dashboards",se={chartKind:"bar",kind:"chart",shardKey:"",sql:"",text:"",title:""},Ie=g((f,e)=>t=>t.map(n=>n.id===f?{...n,chartAxes:e,chartKind:e.kind}:n),"De"),Te=g((f,e)=>t=>{let n=t.find(s=>s.id===f),l=t.filter(s=>s.id!==f),d=l.findIndex(s=>s.id===e);return n===void 0||d===-1?t:[...l.slice(0,d),n,...l.slice(d)]},"je"),De=g((f,e)=>e(f==="line"?"Line":f==="area"?"Area":"Bar"),"ze"),Oe=g((f,e)=>e(f==="kpi"?"Single value":f==="table"?"Table":f==="text"?"Text":"Chart"),"Be"),Fe=g(f=>{let e=(0,Y.c)(82),{draft:t,editing:n,onCancel:l,onChange:d,onSubmit:s}=f,i=te(),h;e[0]!==t||e[1]!==d?(h=g(c=>{d({...t,title:c.target.value})},"c"),e[0]=t,e[1]=d,e[2]=h):h=e[2];let x=h,m;e[3]!==t||e[4]!==d?(m=g(c=>{d({...t,sql:c.target.value})},"h"),e[3]=t,e[4]=d,e[5]=m):m=e[5];let r=m,o;e[6]!==t||e[7]!==d?(o=g(c=>{d({...t,text:c.target.value})},"l"),e[6]=t,e[7]=d,e[8]=o):o=e[8];let v=o,S;e[9]!==t||e[10]!==d?(S=g(c=>{d({...t,shardKey:c.target.value})},"N"),e[9]=t,e[10]=d,e[11]=S):S=e[11];let u=S,C;e[12]!==t||e[13]!==d?(C=g(c=>{d({...t,chartKind:c.target.value})},"y"),e[12]=t,e[13]=d,e[14]=C):C=e[14];let k=C,E;e[15]!==t||e[16]!==d?(E=g(c=>{d({...t,kind:c.target.value})},"q"),e[15]=t,e[16]=d,e[17]=E):E=e[17];let O=E,j;e[18]!==s?(j=g(()=>{s()},"E"),e[18]=s,e[19]=j):j=e[19];let T=j,w=t.kind==="text",K;e[20]!==t.sql||e[21]!==t.text||e[22]!==t.title||e[23]!==w?(K=t.title.trim()!==""&&(w?t.text.trim()!=="":t.sql.trim()!==""),e[20]=t.sql,e[21]=t.text,e[22]=t.title,e[23]=w,e[24]=K):K=e[24];let _=K,R;e[25]!==i?(R=i("Widget title"),e[25]=i,e[26]=R):R=e[26];let y;e[27]!==i?(y=i("Widget title"),e[27]=i,e[28]=y):y=e[28];let N;e[29]!==t.title||e[30]!==x||e[31]!==y||e[32]!==R?(N=(0,a.jsx)("input",{"aria-label":R,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:x,placeholder:y,type:"text",value:t.title}),e[29]=t.title,e[30]=x,e[31]=y,e[32]=R,e[33]=N):N=e[33];let F;e[34]!==i?(F=i("Widget type"),e[34]=i,e[35]=F):F=e[35];let H=t.kind,D;e[36]!==i?(D=$e.map(c=>(0,a.jsx)("option",{value:c,children:Oe(c,i)},c)),e[36]=i,e[37]=D):D=e[37];let W;e[38]!==t.kind||e[39]!==O||e[40]!==F||e[41]!==D?(W=(0,a.jsx)("select",{"aria-label":F,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-widget-kind",onChange:O,value:H,children:D}),e[38]=t.kind,e[39]=O,e[40]=F,e[41]=D,e[42]=W):W=e[42];let L;e[43]!==t.sql||e[44]!==t.text||e[45]!==w||e[46]!==r||e[47]!==v||e[48]!==i?(L=w?(0,a.jsx)("textarea",{"aria-label":i("Text"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-text",onChange:v,placeholder:i("Notes for whoever reads this dashboard."),value:t.text}):(0,a.jsx)("textarea",{"aria-label":i("SQL query"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:r,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[43]=t.sql,e[44]=t.text,e[45]=w,e[46]=r,e[47]=v,e[48]=i,e[49]=L):L=e[49];let $;e[50]!==t.chartKind||e[51]!==t.kind||e[52]!==k||e[53]!==i?($=t.kind==="chart"&&(0,a.jsx)("select",{"aria-label":i("Chart type"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-kind",onChange:k,value:t.chartKind,children:We.map(c=>(0,a.jsx)("option",{value:c,children:De(c,i)},c))}),e[50]=t.chartKind,e[51]=t.kind,e[52]=k,e[53]=i,e[54]=$):$=e[54];let M;e[55]!==t.shardKey||e[56]!==w||e[57]!==u||e[58]!==i?(M=!w&&(0,a.jsx)("input",{"aria-label":i("Shard key (optional)"),className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:u,placeholder:i("Shard key (optional)"),type:"text",value:t.shardKey}),e[55]=t.shardKey,e[56]=w,e[57]=u,e[58]=i,e[59]=M):M=e[59];let z;e[60]!==i?(z=i("Cancel"),e[60]=i,e[61]=z):z=e[61];let q;e[62]!==l||e[63]!==z?(q=(0,a.jsx)(X,{"data-testid":"dashboards-form-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:z}),e[62]=l,e[63]=z,e[64]=q):q=e[64];let B=!_,I;e[65]!==n||e[66]!==i?(I=i(n?"Save widget":"Add widget"),e[65]=n,e[66]=i,e[67]=I):I=e[67];let A;e[68]!==T||e[69]!==B||e[70]!==I?(A=(0,a.jsx)(X,{"data-testid":"dashboards-form-save",disabled:B,onClick:T,size:"sm",type:"button",children:I}),e[68]=T,e[69]=B,e[70]=I,e[71]=A):A=e[71];let p;e[72]!==q||e[73]!==A?(p=(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[q,A]}),e[72]=q,e[73]=A,e[74]=p):p=e[74];let b;return e[75]!==N||e[76]!==W||e[77]!==L||e[78]!==$||e[79]!==M||e[80]!==p?(b=(0,a.jsx)(oe,{"data-testid":"dashboards-form",children:(0,a.jsxs)(ae,{className:"flex flex-col gap-3 py-4",children:[N,W,L,$,M,p]})}),e[75]=N,e[76]=W,e[77]=L,e[78]=$,e[79]=M,e[80]=p,e[81]=b):b=e[81],b},"Fe"),tt=g(f=>{let e=(0,Y.c)(53),{initialShardKey:t}=f,n=te(),[l,d]=ke(Be),[s,i]=(0,G.useState)(se),[h,x]=(0,G.useState)(null),[m,r]=(0,G.useState)(!1),o=ye(t??""),[v,S]=(0,G.useState)(null),u=(0,G.useRef)(null),C;e[0]!==t?(C=g(()=>{x(null),i({...se,shardKey:t??""}),r(!0)},"y"),e[0]=t,e[1]=C):C=e[1];let k=C,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=g(()=>{r(!1),x(null),i(se)},"q"),e[2]=E):E=e[2];let O=E,j;e[3]!==l?(j=g(p=>{let b=l.find(c=>c.id===p);b!==void 0&&(x(p),i({chartKind:b.chartKind??"bar",kind:ce(b),shardKey:b.shardKey??"",sql:b.sql,text:b.text??"",title:b.title}),r(!0))},"E"),e[3]=l,e[4]=j):j=e[4];let T=j,w;e[5]!==o||e[6]!==d?(w=g((p,b)=>{S(p),ne((async()=>{let c=await o.inferChart({columns:b.columns,rowCount:b.rowCount});c!==void 0&&d(Ie(p,c))})().finally(()=>{S(c=>c===p?null:c)}))},"C"),e[5]=o,e[6]=d,e[7]=w):w=e[7];let K=w,_;e[8]!==d?(_=g(p=>{d(b=>b.filter(c=>c.id!==p))},"W"),e[8]=d,e[9]=_):_=e[9];let R=_,y;e[10]!==d?(y=g((p,b)=>{d(Te(p,b))},"k"),e[10]=d,e[11]=y):y=e[11];let N=y,F;e[12]!==d?(F=g((p,b)=>{d(c=>{let J=c.findIndex(P=>P.id===p),V=J+b;if(J===-1||V<0||V>=c.length)return c;let U=[...c],Q=U[J],Z=U[V];return Q===void 0||Z===void 0?c:(U[J]=Z,U[V]=Q,U)})},"_"),e[12]=d,e[13]=F):F=e[13];let H=F,D;e[14]!==s||e[15]!==h||e[16]!==d?(D=g(()=>{let p=s.title.trim(),b=s.sql.trim(),c=s.text.trim(),{chartKind:J,kind:V}=s;if(p===""||(V==="text"?c==="":b===""))return;let U={chartKind:J,kind:V,shardKey:s.shardKey.trim(),sql:b,text:c,title:p};d(h===null?Q=>[...Q,{...U,id:we("w")}]:Q=>Q.map(Z=>Z.id===h?{...Z,...U}:Z)),O()},"B"),e[14]=s,e[15]=h,e[16]=d,e[17]=D):D=e[17];let W=D,L;e[18]!==n?(L=n("Charts, values, tables, and notes. Drag a tile to reorder."),e[18]=n,e[19]=L):L=e[19];let $;e[20]!==L?($=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:L}),e[20]=L,e[21]=$):$=e[21];let M;e[22]!==m||e[23]!==k||e[24]!==n?(M=!m&&(0,a.jsx)(X,{"data-testid":"dashboards-add",onClick:k,size:"sm",type:"button",children:n("Add widget")}),e[22]=m,e[23]=k,e[24]=n,e[25]=M):M=e[25];let z;e[26]!==$||e[27]!==M?(z=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[$,M]}),e[26]=$,e[27]=M,e[28]=z):z=e[28];let q;e[29]!==o||e[30]!==n?(q=o.reason("chart")!==void 0&&(0,a.jsx)(le,{className:"text-xs",testId:"dashboards-suggest-error",variant:"destructive",children:n("Could not suggest a chart for that result.")}),e[29]=o,e[30]=n,e[31]=q):q=e[31];let B;e[32]!==s||e[33]!==h||e[34]!==m||e[35]!==W?(B=m&&(0,a.jsx)(Fe,{draft:s,editing:h!==null,onCancel:O,onChange:i,onSubmit:W}),e[32]=s,e[33]=h,e[34]=m,e[35]=W,e[36]=B):B=e[36];let I;e[37]!==o.unavailable||e[38]!==m||e[39]!==v||e[40]!==T||e[41]!==H||e[42]!==R||e[43]!==N||e[44]!==K||e[45]!==n||e[46]!==l?(I=l.length===0&&!m?(0,a.jsx)(me,{description:n("Add a chart, a single value, a table, or a note. Everything is saved on this browser."),testId:"dashboards-empty",title:n("No widgets yet")}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:l.map((p,b)=>(0,a.jsx)(_e,{draggedRef:u,first:b===0,inferring:v===p.id,last:b===l.length-1,onEdit:T,onMove:H,onRemove:R,onReorder:N,onSuggest:o.unavailable?void 0:K,widget:p},p.id))}),e[37]=o.unavailable,e[38]=m,e[39]=v,e[40]=T,e[41]=H,e[42]=R,e[43]=N,e[44]=K,e[45]=n,e[46]=l,e[47]=I):I=e[47];let A;return e[48]!==z||e[49]!==q||e[50]!==B||e[51]!==I?(A=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[z,q,B,I]}),e[48]=z,e[49]=q,e[50]=B,e[51]=I,e[52]=A):A=e[52],A},"it");export{tt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ke}from"./chunk-EA2JKR5D.js";import{a as A}from"./chunk-IMOHEGMV.js";import{a as Pe}from"./chunk-BOTGXX4H.js";import{a as be}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as M}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as T}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as O}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ge}from"./chunk-F7UZBTKS.js";import"./chunk-ULIQFBZU.js";import"./chunk-Y3G2ZPOD.js";import"./chunk-35DM4JJG.js";import{a as Z}from"./chunk-4ZEL6BYL.js";import{c as ae}from"./chunk-D6UKRXIS.js";import{f as oe}from"./chunk-VWWJIICI.js";import"./chunk-FSRSK4LY.js";import"./chunk-KSYIH3NO.js";import{a as de}from"./chunk-FKVZRPV5.js";import{a as Ne,b as ve,c as we,d as ce,e as le,f as re}from"./chunk-HEAQVSNS.js";import{a as se,b as pe,c as fe,d as ue,e as ne}from"./chunk-WUWBZPUK.js";import{d as V,f as he,g as xe,h as ye,o as te}from"./chunk-FODLDLE2.js";import{a as d,d as ie,e as _e,f as Fe,g as Te}from"./chunk-YKXDMIHQ.js";var p=ie(_e(),1);var me=ie(Fe(),1);var t=ie(Te(),1);var Ce=["read","insert","update","delete"],Ae=d((e,a)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[a],"_e"),Ee=d(e=>{let a=new Set;for(let i of e?.advisories??[])if(i.name==="rls_uncovered_table"){let{table:s}=i.metadata;typeof s=="string"&&s!==""&&a.add(s)}return a},"Ie"),Re=d((e,a,i)=>{let s=new Map,l=d(n=>{let o=s.get(n);if(o!==void 0)return o;let f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:i.has(n)};return s.set(n,f),f},"l");for(let n of e)l(n.table).cells[n.on]={procedure:n.procedure};for(let n of a)l(n.table).maskedColumns.add(n.column);for(let n of i)l(n);return[...s.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},"Ee"),$e=d(e=>{let a=(0,me.c)(17),i;a[0]!==e?(i=e===void 0?{}:e,a[0]=e,a[1]=i):i=a[1];let{onProbe:s}=i,l=V(),n,o;a[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},a[2]=n,a[3]=o):(n=a[2],o=a[3]);let f=ae(Z.rlsPolicies,n,o),r;a[4]===Symbol.for("react.memo_cache_sentinel")?(r={},a[4]=r):r=a[4];let b=ae(Z.maskPolicies,r),x;a[5]===Symbol.for("react.memo_cache_sentinel")?(x={},a[5]=x):x=a[5];let g=ae(Z.getAdvisories,x),N;if(a[6]!==g.data||a[7]!==b.data||a[8]!==s||a[9]!==f||a[10]!==l){let v=null;f.data!==void 0&&(v=Array.isArray(f.data.policies)?f.data.policies:[]);let E=Array.isArray(b.data?.columns)?b.data.columns:[],j=g.data??null,{error:C,errorSource:w,liveError:S}=f,_=v===null?[]:Re(v,E,Ee(j)),k;a[12]!==S?(k=(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)(Pe,{message:S,prefix:"pm"})}),a[12]=S,a[13]=k):k=a[13];let u;a[14]!==C||a[15]!==w?(u=C!==null&&(0,t.jsx)(ge,{error:w,testId:"pm-error"}),a[14]=C,a[15]=w,a[16]=u):u=a[16],N=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,u,v!==null&&_.length===0?(0,t.jsx)(de,{description:l("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:l("No policy")}):(0,t.jsxs)(Ne,{"data-testid":"pm-table",children:[(0,t.jsx)(ve,{children:(0,t.jsxs)(ce,{children:[(0,t.jsx)(le,{children:l("Table")}),Ce.map(c=>(0,t.jsx)(le,{children:Ae(l,c)},c)),(0,t.jsx)(le,{children:l("Masked columns")})]})}),(0,t.jsx)(we,{children:_.map(c=>(0,t.jsxs)(ce,{"data-testid":`pm-row-${c.table}`,children:[(0,t.jsx)(re,{className:"font-mono text-xs",children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&(0,t.jsx)(O,{"data-testid":`pm-uncovered-${c.table}`,title:l("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:l("Uncovered \u2014 reachable without a policy")})]})}),Ce.map(I=>{let y=c.cells[I];return(0,t.jsx)(re,{"data-testid":`pm-cell-${c.table}-${I}`,children:y.procedure===void 0?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l("No policy")}):(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)(O,{variant:"secondary",children:l("Covered by {procedure}",{procedure:y.procedure})}),s!==void 0&&(0,t.jsx)(T,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${I}`,onClick:d(()=>{s(c.table,I,y.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Probe this")})]})},I)}),(0,t.jsx)(re,{children:c.maskedColumns.size===0?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(ze)})})]},c.table))})]})]}),a[6]=g.data,a[7]=b.data,a[8]=s,a[9]=f,a[10]=l,a[11]=N}else N=a[11];return N},"Fe");function ze(e){return(0,t.jsx)(O,{variant:"outline",children:e},e)}d(ze,"Re");var Le=he(Z.runAs),Oe=d(()=>{let e=oe();return async({args:a,functionPath:i,shardKey:s="",userId:l})=>{if(l.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let n=Le;try{return{kind:"allowed",value:await e.query(n,{args:a,functionPath:i,userId:l},xe(s))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},"Le"),je=d(e=>e===void 0?"undefined":JSON.stringify(e,null,2),"Me"),Me=d(({functions:e,prefill:a,runAsIdentity:i=!1}={})=>{let s=oe(),l=V(),n=Oe(),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(null),x=e??o??[],[g,N]=(0,p.useState)(""),[v,E]=(0,p.useState)("{}"),[j,C]=(0,p.useState)(""),[w,S]=(0,p.useState)(""),[_,k]=(0,p.useState)(!1),[u,c]=(0,p.useState)(null),[I,y]=(0,p.useState)(null),F=(0,p.useRef)(-1);(0,p.useEffect)(()=>{if(e!==void 0)return;let m=!1;return s.listFunctions().then(h=>(m||f(h),h)).catch(h=>{m||b(ye(h))}),()=>{m=!0}},[s,e]),(0,p.useEffect)(()=>{if(a===void 0||F.current===a.nonce)return;F.current=a.nonce;let m=a.functionPath;queueMicrotask(()=>{N(m),c(null)})},[a]);let P=g===""?x[0]?.path??"":g,R=d(async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(h){y(l("Invalid JSON args: {message}",{message:h.message})),c(null);return}y(null),k(!0);try{let h=await n({args:m,functionPath:P,shardKey:j.trim(),userId:w.trim()});c(h)}finally{k(!1)}},"E"),$=d(()=>{te(R())},"F"),Y=d(m=>{N(m.target.value)},"Y"),z=d(m=>{E(m.target.value)},"R"),L=d(m=>{S(m.target.value)},"O");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!i&&(0,t.jsx)(de,{description:l("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:l("Set `runAsIdentity` to forge an identity and probe access.")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(A,{htmlFor:"pp-function",children:l("Function")}),(0,t.jsx)("select",{"aria-label":l("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:Y,value:P,children:x.map(m=>(0,t.jsxs)("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(A,{htmlFor:"pp-args",children:l("Arguments")}),(0,t.jsx)(ke,{"aria-label":l("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:z,value:v})]}),(0,t.jsx)(be,{onChange:C,testId:"pp-shard",value:j}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(A,{htmlFor:"pp-user",children:l("Run as (userId)")}),(0,t.jsx)(M,{"aria-label":l("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:L,placeholder:l("Required \u2014 the identity to probe as"),value:w})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(T,{"data-testid":"pp-run",disabled:!i||_||P==="",onClick:$,type:"button",children:l(_?"Probing\u2026":"Run probe")}),w.trim()!==""&&(0,t.jsx)(O,{"data-testid":"pp-as-badge",variant:"secondary",children:l("as {userId}",{userId:w.trim()})})]})]}),I!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),u!==null&&u.kind==="allowed"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,t.jsx)(O,{variant:"secondary",children:l("Allowed")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:je(u.value)})]}),u!==null&&u.kind==="invalid"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[(0,t.jsx)(O,{variant:"outline",children:l("Not run")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:u.message})]}),u!==null&&u.kind==="denied"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,t.jsx)(O,{variant:"destructive",children:l("Denied")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:u.message})]})]})},"$e"),qe="/__lunora/policy-scaffold",De={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ue=d(async e=>{let a=await fetch(qe,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await a.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(a.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};let s=i.error;return{kind:"error",message:s===void 0?`policy scaffold failed (${String(a.status)})`:De[s]??s}},"Ue"),Se={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Je=d(()=>{let e=(0,me.c)(69),a=V(),[i,s]=(0,p.useState)(null),[l,n]=(0,p.useState)(!1),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(Se),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=d(ee=>{let G=ee.target.name,{value:Q}=ee.target;b(Ie=>({...Ie,[G]:Q}))},"h"),e[0]=x):x=e[0];let g=x,N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=d(()=>{s(null),b(Se)},"v"),e[1]=N):N=e[1];let v=N,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=d(async ee=>{n(!0),f(null);try{let G=await Ue(ee);f(G),G.kind==="ok"&&v()}catch(G){let Q=G;f({kind:"error",message:Q instanceof Error?Q.message:String(Q)})}n(!1)},"I"),e[2]=E):E=e[2];let j=E,C;e[3]!==r.policyName||e[4]!==r.tableName?(C=d(()=>{te(j({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"P"),e[3]=r.policyName,e[4]=r.tableName,e[5]=C):C=e[5];let w=C,S;e[6]!==r.exportName||e[7]!==r.filePath||e[8]!==r.policies?(S=d(()=>{te(j({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"w"),e[6]=r.exportName,e[7]=r.filePath,e[8]=r.policies,e[9]=S):S=e[9];let _=S,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=d(()=>{f(null),s("scaffold")},"S"),e[10]=k):k=e[10];let u=k,c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=d(()=>{f(null),s("wire")},"d"),e[11]=c):c=e[11];let I=c,y;e[12]!==a?(y=a("Scaffold access rules"),e[12]=a,e[13]=y):y=e[13];let F;e[14]!==y?(F=(0,t.jsx)(fe,{children:y}),e[14]=y,e[15]=F):F=e[15];let P;e[16]!==a?(P=a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=a,e[17]=P):P=e[17];let R;e[18]!==P?(R=(0,t.jsx)(ue,{children:P}),e[18]=P,e[19]=R):R=e[19];let $;e[20]!==R||e[21]!==F?($=(0,t.jsxs)(pe,{children:[F,R]}),e[20]=R,e[21]=F,e[22]=$):$=e[22];let Y=i==="scaffold"?"default":"outline",z;e[23]!==a?(z=a("New policy file"),e[23]=a,e[24]=z):z=e[24];let L;e[25]!==Y||e[26]!==z?(L=(0,t.jsx)(T,{"data-testid":"policy-scaffolder-new",onClick:u,size:"xs",type:"button",variant:Y,children:z}),e[25]=Y,e[26]=z,e[27]=L):L=e[27];let m=i==="wire"?"default":"outline",h;e[28]!==a?(h=a("Wire into a procedure"),e[28]=a,e[29]=h):h=e[29];let q;e[30]!==m||e[31]!==h?(q=(0,t.jsx)(T,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:m,children:h}),e[30]=m,e[31]=h,e[32]=q):q=e[32];let D;e[33]!==L||e[34]!==q?(D=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,q]}),e[33]=L,e[34]=q,e[35]=D):D=e[35];let U;e[36]!==l||e[37]!==r.policyName||e[38]!==r.tableName||e[39]!==i||e[40]!==w||e[41]!==a?(U=i==="scaffold"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(A,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:r.policyName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(A,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:r.tableName})]}),(0,t.jsx)(T,{"data-testid":"policy-scaffolder-create",disabled:l||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:a(l?"Creating\u2026":"Create policy file")}),(0,t.jsx)(T,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[36]=l,e[37]=r.policyName,e[38]=r.tableName,e[39]=i,e[40]=w,e[41]=a,e[42]=U):U=e[42];let J;e[43]!==l||e[44]!==r.exportName||e[45]!==r.filePath||e[46]!==r.policies||e[47]!==i||e[48]!==_||e[49]!==a?(J=i==="wire"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(A,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:r.filePath})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(A,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:r.exportName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(A,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:r.policies})]}),(0,t.jsx)(T,{"data-testid":"policy-scaffolder-apply",disabled:l||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:_,size:"xs",type:"button",children:a(l?"Wiring\u2026":"Wire RLS")}),(0,t.jsx)(T,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[43]=l,e[44]=r.exportName,e[45]=r.filePath,e[46]=r.policies,e[47]=i,e[48]=_,e[49]=a,e[50]=J):J=e[50];let W;e[51]!==o?(W=o?.kind==="error"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=W):W=e[52];let B;e[53]!==o?.kind||e[54]!==a?(B=o?.kind==="needs-manual-edit"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=a,e[55]=B):B=e[55];let H;e[56]!==o||e[57]!==a?(H=o?.kind==="ok"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,t.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&(0,t.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(We)})]}),e[56]=o,e[57]=a,e[58]=H):H=e[58];let K;e[59]!==D||e[60]!==U||e[61]!==J||e[62]!==W||e[63]!==B||e[64]!==H?(K=(0,t.jsxs)(ne,{children:[D,U,J,W,B,H]}),e[59]=D,e[60]=U,e[61]=J,e[62]=W,e[63]=B,e[64]=H,e[65]=K):K=e[65];let X;return e[66]!==$||e[67]!==K?(X=(0,t.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[$,K]}),e[66]=$,e[67]=K,e[68]=X):X=e[68],X},"je");function We(e){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}d(We,"Be");var st=d(({functions:e,runAsIdentity:a=!1,schemaEditable:i=!1}={})=>{let s=V(),[l,n]=(0,p.useState)(void 0),o=d((f,r,b)=>{b!==""&&n(x=>({functionPath:b,nonce:(x?.nonce??0)+1}))},"o");return(0,t.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Permissions")})}),(0,t.jsx)($e,{onProbe:o})]}),(0,t.jsx)("section",{className:"flex flex-col gap-3",children:(0,t.jsxs)(se,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Probe")})}),(0,t.jsxs)(ne,{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:s("Pick a function and an identity, then run it to see the access outcome.")}),(0,t.jsx)(Me,{functions:e,prefill:l,runAsIdentity:a})]})]})}),i&&(0,t.jsx)("section",{className:"flex flex-col gap-2",children:(0,t.jsx)(Je,{})})]})},"nt");export{st as PermissionsPanel};
|
|
1
|
+
import{a as ke}from"./chunk-EA2JKR5D.js";import{a as A}from"./chunk-IMOHEGMV.js";import{a as Pe}from"./chunk-BOTGXX4H.js";import{a as be}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as M}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as T}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as O}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ge}from"./chunk-KZDIKRZ3.js";import"./chunk-ULIQFBZU.js";import"./chunk-2W365SXI.js";import"./chunk-35DM4JJG.js";import{a as Z}from"./chunk-4ZEL6BYL.js";import{c as ae}from"./chunk-MBP4SZYB.js";import{f as oe}from"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as de}from"./chunk-FKVZRPV5.js";import{a as Ne,b as ve,c as we,d as ce,e as le,f as re}from"./chunk-HEAQVSNS.js";import{a as se,b as pe,c as fe,d as ue,e as ne}from"./chunk-WUWBZPUK.js";import{d as V,f as he,g as xe,h as ye,o as te}from"./chunk-FODLDLE2.js";import{a as d,d as ie,e as _e,f as Fe,g as Te}from"./chunk-YKXDMIHQ.js";var p=ie(_e(),1);var me=ie(Fe(),1);var t=ie(Te(),1);var Ce=["read","insert","update","delete"],Ae=d((e,a)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[a],"_e"),Ee=d(e=>{let a=new Set;for(let i of e?.advisories??[])if(i.name==="rls_uncovered_table"){let{table:s}=i.metadata;typeof s=="string"&&s!==""&&a.add(s)}return a},"Ie"),Re=d((e,a,i)=>{let s=new Map,l=d(n=>{let o=s.get(n);if(o!==void 0)return o;let f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:i.has(n)};return s.set(n,f),f},"l");for(let n of e)l(n.table).cells[n.on]={procedure:n.procedure};for(let n of a)l(n.table).maskedColumns.add(n.column);for(let n of i)l(n);return[...s.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},"Ee"),$e=d(e=>{let a=(0,me.c)(17),i;a[0]!==e?(i=e===void 0?{}:e,a[0]=e,a[1]=i):i=a[1];let{onProbe:s}=i,l=V(),n,o;a[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},a[2]=n,a[3]=o):(n=a[2],o=a[3]);let f=ae(Z.rlsPolicies,n,o),r;a[4]===Symbol.for("react.memo_cache_sentinel")?(r={},a[4]=r):r=a[4];let b=ae(Z.maskPolicies,r),x;a[5]===Symbol.for("react.memo_cache_sentinel")?(x={},a[5]=x):x=a[5];let g=ae(Z.getAdvisories,x),N;if(a[6]!==g.data||a[7]!==b.data||a[8]!==s||a[9]!==f||a[10]!==l){let v=null;f.data!==void 0&&(v=Array.isArray(f.data.policies)?f.data.policies:[]);let E=Array.isArray(b.data?.columns)?b.data.columns:[],j=g.data??null,{error:C,errorSource:w,liveError:S}=f,_=v===null?[]:Re(v,E,Ee(j)),k;a[12]!==S?(k=(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)(Pe,{message:S,prefix:"pm"})}),a[12]=S,a[13]=k):k=a[13];let u;a[14]!==C||a[15]!==w?(u=C!==null&&(0,t.jsx)(ge,{error:w,testId:"pm-error"}),a[14]=C,a[15]=w,a[16]=u):u=a[16],N=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,u,v!==null&&_.length===0?(0,t.jsx)(de,{description:l("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:l("No policy")}):(0,t.jsxs)(Ne,{"data-testid":"pm-table",children:[(0,t.jsx)(ve,{children:(0,t.jsxs)(ce,{children:[(0,t.jsx)(le,{children:l("Table")}),Ce.map(c=>(0,t.jsx)(le,{children:Ae(l,c)},c)),(0,t.jsx)(le,{children:l("Masked columns")})]})}),(0,t.jsx)(we,{children:_.map(c=>(0,t.jsxs)(ce,{"data-testid":`pm-row-${c.table}`,children:[(0,t.jsx)(re,{className:"font-mono text-xs",children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&(0,t.jsx)(O,{"data-testid":`pm-uncovered-${c.table}`,title:l("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:l("Uncovered \u2014 reachable without a policy")})]})}),Ce.map(I=>{let y=c.cells[I];return(0,t.jsx)(re,{"data-testid":`pm-cell-${c.table}-${I}`,children:y.procedure===void 0?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l("No policy")}):(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)(O,{variant:"secondary",children:l("Covered by {procedure}",{procedure:y.procedure})}),s!==void 0&&(0,t.jsx)(T,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${I}`,onClick:d(()=>{s(c.table,I,y.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Probe this")})]})},I)}),(0,t.jsx)(re,{children:c.maskedColumns.size===0?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(ze)})})]},c.table))})]})]}),a[6]=g.data,a[7]=b.data,a[8]=s,a[9]=f,a[10]=l,a[11]=N}else N=a[11];return N},"Fe");function ze(e){return(0,t.jsx)(O,{variant:"outline",children:e},e)}d(ze,"Re");var Le=he(Z.runAs),Oe=d(()=>{let e=oe();return async({args:a,functionPath:i,shardKey:s="",userId:l})=>{if(l.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let n=Le;try{return{kind:"allowed",value:await e.query(n,{args:a,functionPath:i,userId:l},xe(s))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},"Le"),je=d(e=>e===void 0?"undefined":JSON.stringify(e,null,2),"Me"),Me=d(({functions:e,prefill:a,runAsIdentity:i=!1}={})=>{let s=oe(),l=V(),n=Oe(),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(null),x=e??o??[],[g,N]=(0,p.useState)(""),[v,E]=(0,p.useState)("{}"),[j,C]=(0,p.useState)(""),[w,S]=(0,p.useState)(""),[_,k]=(0,p.useState)(!1),[u,c]=(0,p.useState)(null),[I,y]=(0,p.useState)(null),F=(0,p.useRef)(-1);(0,p.useEffect)(()=>{if(e!==void 0)return;let m=!1;return s.listFunctions().then(h=>(m||f(h),h)).catch(h=>{m||b(ye(h))}),()=>{m=!0}},[s,e]),(0,p.useEffect)(()=>{if(a===void 0||F.current===a.nonce)return;F.current=a.nonce;let m=a.functionPath;queueMicrotask(()=>{N(m),c(null)})},[a]);let P=g===""?x[0]?.path??"":g,R=d(async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(h){y(l("Invalid JSON args: {message}",{message:h.message})),c(null);return}y(null),k(!0);try{let h=await n({args:m,functionPath:P,shardKey:j.trim(),userId:w.trim()});c(h)}finally{k(!1)}},"E"),$=d(()=>{te(R())},"F"),Y=d(m=>{N(m.target.value)},"Y"),z=d(m=>{E(m.target.value)},"R"),L=d(m=>{S(m.target.value)},"O");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!i&&(0,t.jsx)(de,{description:l("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:l("Set `runAsIdentity` to forge an identity and probe access.")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(A,{htmlFor:"pp-function",children:l("Function")}),(0,t.jsx)("select",{"aria-label":l("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:Y,value:P,children:x.map(m=>(0,t.jsxs)("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(A,{htmlFor:"pp-args",children:l("Arguments")}),(0,t.jsx)(ke,{"aria-label":l("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:z,value:v})]}),(0,t.jsx)(be,{onChange:C,testId:"pp-shard",value:j}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(A,{htmlFor:"pp-user",children:l("Run as (userId)")}),(0,t.jsx)(M,{"aria-label":l("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:L,placeholder:l("Required \u2014 the identity to probe as"),value:w})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(T,{"data-testid":"pp-run",disabled:!i||_||P==="",onClick:$,type:"button",children:l(_?"Probing\u2026":"Run probe")}),w.trim()!==""&&(0,t.jsx)(O,{"data-testid":"pp-as-badge",variant:"secondary",children:l("as {userId}",{userId:w.trim()})})]})]}),I!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),u!==null&&u.kind==="allowed"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,t.jsx)(O,{variant:"secondary",children:l("Allowed")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:je(u.value)})]}),u!==null&&u.kind==="invalid"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[(0,t.jsx)(O,{variant:"outline",children:l("Not run")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:u.message})]}),u!==null&&u.kind==="denied"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,t.jsx)(O,{variant:"destructive",children:l("Denied")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:u.message})]})]})},"$e"),qe="/__lunora/policy-scaffold",De={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ue=d(async e=>{let a=await fetch(qe,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await a.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(a.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};let s=i.error;return{kind:"error",message:s===void 0?`policy scaffold failed (${String(a.status)})`:De[s]??s}},"Ue"),Se={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Je=d(()=>{let e=(0,me.c)(69),a=V(),[i,s]=(0,p.useState)(null),[l,n]=(0,p.useState)(!1),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(Se),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=d(ee=>{let G=ee.target.name,{value:Q}=ee.target;b(Ie=>({...Ie,[G]:Q}))},"h"),e[0]=x):x=e[0];let g=x,N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=d(()=>{s(null),b(Se)},"v"),e[1]=N):N=e[1];let v=N,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=d(async ee=>{n(!0),f(null);try{let G=await Ue(ee);f(G),G.kind==="ok"&&v()}catch(G){let Q=G;f({kind:"error",message:Q instanceof Error?Q.message:String(Q)})}n(!1)},"I"),e[2]=E):E=e[2];let j=E,C;e[3]!==r.policyName||e[4]!==r.tableName?(C=d(()=>{te(j({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"P"),e[3]=r.policyName,e[4]=r.tableName,e[5]=C):C=e[5];let w=C,S;e[6]!==r.exportName||e[7]!==r.filePath||e[8]!==r.policies?(S=d(()=>{te(j({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"w"),e[6]=r.exportName,e[7]=r.filePath,e[8]=r.policies,e[9]=S):S=e[9];let _=S,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=d(()=>{f(null),s("scaffold")},"S"),e[10]=k):k=e[10];let u=k,c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=d(()=>{f(null),s("wire")},"d"),e[11]=c):c=e[11];let I=c,y;e[12]!==a?(y=a("Scaffold access rules"),e[12]=a,e[13]=y):y=e[13];let F;e[14]!==y?(F=(0,t.jsx)(fe,{children:y}),e[14]=y,e[15]=F):F=e[15];let P;e[16]!==a?(P=a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=a,e[17]=P):P=e[17];let R;e[18]!==P?(R=(0,t.jsx)(ue,{children:P}),e[18]=P,e[19]=R):R=e[19];let $;e[20]!==R||e[21]!==F?($=(0,t.jsxs)(pe,{children:[F,R]}),e[20]=R,e[21]=F,e[22]=$):$=e[22];let Y=i==="scaffold"?"default":"outline",z;e[23]!==a?(z=a("New policy file"),e[23]=a,e[24]=z):z=e[24];let L;e[25]!==Y||e[26]!==z?(L=(0,t.jsx)(T,{"data-testid":"policy-scaffolder-new",onClick:u,size:"xs",type:"button",variant:Y,children:z}),e[25]=Y,e[26]=z,e[27]=L):L=e[27];let m=i==="wire"?"default":"outline",h;e[28]!==a?(h=a("Wire into a procedure"),e[28]=a,e[29]=h):h=e[29];let q;e[30]!==m||e[31]!==h?(q=(0,t.jsx)(T,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:m,children:h}),e[30]=m,e[31]=h,e[32]=q):q=e[32];let D;e[33]!==L||e[34]!==q?(D=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,q]}),e[33]=L,e[34]=q,e[35]=D):D=e[35];let U;e[36]!==l||e[37]!==r.policyName||e[38]!==r.tableName||e[39]!==i||e[40]!==w||e[41]!==a?(U=i==="scaffold"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(A,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:r.policyName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(A,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:r.tableName})]}),(0,t.jsx)(T,{"data-testid":"policy-scaffolder-create",disabled:l||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:a(l?"Creating\u2026":"Create policy file")}),(0,t.jsx)(T,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[36]=l,e[37]=r.policyName,e[38]=r.tableName,e[39]=i,e[40]=w,e[41]=a,e[42]=U):U=e[42];let J;e[43]!==l||e[44]!==r.exportName||e[45]!==r.filePath||e[46]!==r.policies||e[47]!==i||e[48]!==_||e[49]!==a?(J=i==="wire"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(A,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:r.filePath})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(A,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:r.exportName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(A,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:r.policies})]}),(0,t.jsx)(T,{"data-testid":"policy-scaffolder-apply",disabled:l||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:_,size:"xs",type:"button",children:a(l?"Wiring\u2026":"Wire RLS")}),(0,t.jsx)(T,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[43]=l,e[44]=r.exportName,e[45]=r.filePath,e[46]=r.policies,e[47]=i,e[48]=_,e[49]=a,e[50]=J):J=e[50];let W;e[51]!==o?(W=o?.kind==="error"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=W):W=e[52];let B;e[53]!==o?.kind||e[54]!==a?(B=o?.kind==="needs-manual-edit"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=a,e[55]=B):B=e[55];let H;e[56]!==o||e[57]!==a?(H=o?.kind==="ok"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,t.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&(0,t.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(We)})]}),e[56]=o,e[57]=a,e[58]=H):H=e[58];let K;e[59]!==D||e[60]!==U||e[61]!==J||e[62]!==W||e[63]!==B||e[64]!==H?(K=(0,t.jsxs)(ne,{children:[D,U,J,W,B,H]}),e[59]=D,e[60]=U,e[61]=J,e[62]=W,e[63]=B,e[64]=H,e[65]=K):K=e[65];let X;return e[66]!==$||e[67]!==K?(X=(0,t.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[$,K]}),e[66]=$,e[67]=K,e[68]=X):X=e[68],X},"je");function We(e){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}d(We,"Be");var st=d(({functions:e,runAsIdentity:a=!1,schemaEditable:i=!1}={})=>{let s=V(),[l,n]=(0,p.useState)(void 0),o=d((f,r,b)=>{b!==""&&n(x=>({functionPath:b,nonce:(x?.nonce??0)+1}))},"o");return(0,t.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Permissions")})}),(0,t.jsx)($e,{onProbe:o})]}),(0,t.jsx)("section",{className:"flex flex-col gap-3",children:(0,t.jsxs)(se,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Probe")})}),(0,t.jsxs)(ne,{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:s("Pick a function and an identity, then run it to see the access outcome.")}),(0,t.jsx)(Me,{functions:e,prefill:l,runAsIdentity:a})]})]})}),i&&(0,t.jsx)("section",{className:"flex flex-col gap-2",children:(0,t.jsx)(Je,{})})]})},"nt");export{st as PermissionsPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as nt,b as rt}from"./chunk-
|
|
1
|
+
import{a as nt,b as rt}from"./chunk-P4V5VRUR.js";import{c as tt}from"./chunk-QY4V5UOY.js";import{a as et}from"./chunk-2ADU5FA5.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import"./chunk-XZMOZFE6.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-URBHAYYZ.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import"./chunk-PD6WIDY6.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as Ve}from"./chunk-OGUKYRFM.js";import{c as Ke,d as qe,e as Ee,f as _e,g as Pe}from"./chunk-OKG3HWSJ.js";import{W as Ye}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as Je}from"./chunk-ULIQFBZU.js";import{a as Ne}from"./chunk-4ZEL6BYL.js";import"./chunk-MBP4SZYB.js";import{f as Le}from"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import"./chunk-HEAQVSNS.js";import{d as ce,f as we,g as ke,h as Ge,o as ue}from"./chunk-FODLDLE2.js";import{a as l,d as We,e as wt,f as kt,g as Nt,i as me}from"./chunk-YKXDMIHQ.js";var G=We(kt(),1);var z=We(wt(),1);var d=We(Nt(),1);var qt="x",ot=" ",Ct={'"':'"',"'":"'","[":"]","`":"`"},ct=l((s,e)=>{let n=e+2;for(;n<s.length&&s[n]!==`
|
|
2
2
|
`;)n+=1;return n},"tt"),dt=l((s,e)=>{let n=s.indexOf("*/",e+2);return n===-1?-1:n+2},"nt"),ut=l(s=>{let e=s.split(""),n=0;for(;n<s.length;){let t=s[n]??"",o=Ct[t];if(t==="-"&&s[n+1]==="-"){let r=ct(s,n);e.fill(ot,n,r),n=r}else if(t==="/"&&s[n+1]==="*"){let r=dt(s,n);if(r===-1)return;e.fill(ot,n,r),n=r}else if(o!==void 0){let r=n+1;for(;r<s.length;)if(s[r]!==o)r+=1;else if(o!=="]"&&s[r+1]===o)r+=2;else break;if(r>=s.length)return;e.fill(qt,n,r+1),n=r+1}else n+=1}for(let t=0;t<s.length;t+=1)s[t]===`
|
|
3
3
|
`&&(e[t]=`
|
|
4
4
|
`);return e.join("")},"st"),Tt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,It=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|truncate|update|vacuum)\b|\breplace\b(?!\s*\()/iu,Rt=/^\w+/u,Lt=/;\s*$/u,Et=/\s/u,mt=l(s=>{let e=0;for(;e<s.length;){let n=s[e];if(n!==void 0&&Et.test(n))e+=1;else if(n==="-"&&s[e+1]==="-")e=ct(s,e);else if(n==="/"&&s[e+1]==="*"){let t=dt(s,e);if(t===-1)break;e=t}else break}return e},"ot"),_t=l(s=>{let e=mt(s),n=s.slice(e).trimEnd();if(n==="")return{code:"SQL_EMPTY",message:"the query is empty"};let t=(ut(n)??n).replace(Lt,""),o=n.slice(0,t.length),r=t.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let a="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!Tt.test(o))return{code:"SQL_NOT_READONLY",length:Rt.exec(o)?.[0].length??1,message:a,offset:e};let c=It.exec(o);if(c!==null)return{code:"SQL_NOT_READONLY",length:c[0].length,message:`${a} (\`${c[0].toUpperCase()}\` is not allowed)`,offset:e+c.index}},"Ot"),Ot=/^explain\b/iu,Dt=l(s=>Ot.test(s.slice(mt(s)))?s:`EXPLAIN QUERY PLAN ${s}`,"Mt"),Qe=l((s,e)=>{let n=s.trim();if(n==="")return[];let t=e+s.indexOf(n),o=_t(n);return o?.code==="SQL_EMPTY"?[]:[o===void 0?{offset:t,sql:n}:{offset:t,rejection:o,sql:n}]},"Fe"),ft=l(s=>{let e=ut(s);if(e===void 0)return Qe(s,0);let n=[],t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(n.push(...Qe(s.slice(t,o),t)),t=o+1);return n},"lt"),Mt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],At=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Me=String.fromCodePoint(0),$t=new RegExp(`${Me}${String.raw`(\d+)`}${Me}`,"gu"),Bt=Mt.map(s=>({pattern:new RegExp(String.raw`\b${s.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:s})),Ht=At.map(s=>({pattern:new RegExp(String.raw`\s+${s.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as de}from"./chunk-UYEZR3BI.js";import{a as te,b as re,c as ne}from"./chunk-Q4CAKBWN.js";import"./chunk-OKG3HWSJ.js";import{b as Y}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ae}from"./chunk-
|
|
1
|
+
import{b as de}from"./chunk-UYEZR3BI.js";import{a as te,b as re,c as ne}from"./chunk-Q4CAKBWN.js";import"./chunk-OKG3HWSJ.js";import{b as Y}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ae}from"./chunk-KZDIKRZ3.js";import"./chunk-ULIQFBZU.js";import"./chunk-2W365SXI.js";import"./chunk-35DM4JJG.js";import{a as ee}from"./chunk-4ZEL6BYL.js";import{c as Z}from"./chunk-MBP4SZYB.js";import"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as le,b as oe,c as se,d as H,e as z,f as G}from"./chunk-HEAQVSNS.js";import{a as P,e as q}from"./chunk-WUWBZPUK.js";import{d as X}from"./chunk-FODLDLE2.js";import{a as g,d as W,f as ce,g as me}from"./chunk-YKXDMIHQ.js";var J=W(ce(),1);var t=W(me(),1);var ue={binding:"outline",secret:"destructive",var:"secondary"},pe=g((n,e)=>{if(n===void 0)return[];let u=[];return n.workerUrl!==void 0&&u.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&u.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&u.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&u.push({label:e("Version"),value:n.versionTag}),u},"ce"),ie=g(n=>{let e=(0,J.c)(18),{modifier:u,name:r,label:p}=n,A=te(),x;e[0]!==r?(x=g(o=>{if(!["Escape","Tab"].includes(o.key)){if(o.shiftKey){o.preventDefault();return}o.preventDefault(),re(r,o.key)}},"b"),e[0]=r,e[1]=x):x=e[1];let i=x,c=`set-shortcut-${r}`,m;e[2]!==p?(m=(0,t.jsx)("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3];let h;e[4]!==u?(h=(0,t.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];let l=`set-shortcut-input-${r}`,f=A[r],s;e[6]!==p||e[7]!==i||e[8]!==l||e[9]!==f?(s=(0,t.jsx)("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":l,onKeyDown:i,readOnly:!0,value:f}),e[6]=p,e[7]=i,e[8]=l,e[9]=f,e[10]=s):s=e[10];let a;e[11]!==h||e[12]!==s?(a=(0,t.jsxs)("dd",{className:"flex items-center gap-1.5",children:[h,s]}),e[11]=h,e[12]=s,e[13]=a):a=e[13];let d;return e[14]!==c||e[15]!==m||e[16]!==a?(d=(0,t.jsxs)("div",{className:"contents","data-testid":c,children:[m,a]}),e[14]=c,e[15]=m,e[16]=a,e[17]=d):d=e[17],d},"z"),Se=g(n=>{let e=(0,J.c)(85),{initialShardKey:u}=n,r=X(),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let A=u??"",x;e[1]!==A?(x={shardKey:A},e[1]=A,e[2]=x):x=e[2];let{data:i,error:c,errorSource:m,isLoading:h}=Z(ee.getSettings,p,x),l,f,s,a,d,o,b;if(e[3]!==c||e[4]!==m||e[5]!==i?.deploy||e[6]!==i?.settings||e[7]!==r){let Q=pe(i?.deploy,r),M;e[15]!==i?.settings?(M=i?.settings??[],e[15]=i?.settings,e[16]=M):M=e[16],l=M,f="flex flex-col gap-4",s="lunora-settings";let V;e[17]!==r?(V=r("Open in Cloudflare"),e[17]=r,e[18]=V):V=e[18],e[19]!==V?(a=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:de,rel:"noreferrer",target:"_blank",children:V})}),e[19]=V,e[20]=a):a=e[20];let $;e[21]!==r?($=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=$):$=e[22],e[23]!==$?(d=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=d):d=e[24],e[25]!==c||e[26]!==m?(o=c!==null&&(0,t.jsx)(ae,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=o):o=e[27],b=Q.length>0&&(0,t.jsxs)(P,{className:"py-0","data-testid":"set-deploy",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Deployment")})}),(0,t.jsx)(q,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:Q.map(he)})})]}),e[3]=c,e[4]=m,e[5]=i?.deploy,e[6]=i?.settings,e[7]=r,e[8]=l,e[9]=f,e[10]=s,e[11]=a,e[12]=d,e[13]=o,e[14]=b}else l=e[8],f=e[9],s=e[10],a=e[11],d=e[12],o=e[13],b=e[14];let y;e[28]!==r?(y=r("Keyboard shortcuts"),e[28]=r,e[29]=y):y=e[29];let v;e[30]!==y?(v=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y}),e[30]=y,e[31]=v):v=e[31];let N;e[32]!==r?(N=r("Reset"),e[32]=r,e[33]=N):N=e[33];let k;e[34]!==N?(k=(0,t.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ne,type:"button",children:N}),e[34]=N,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=(0,t.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==r?(C=r("Command palette"),e[39]=r,e[40]=C):C=e[40];let S;e[41]!==C?(S=(0,t.jsx)(ie,{label:C,modifier:"\u2318/Ctrl",name:"palette"}),e[41]=C,e[42]=S):S=e[42];let T;e[43]!==r?(T=r("Operation console"),e[43]=r,e[44]=T):T=e[44];let D;e[45]!==T?(D=(0,t.jsx)(ie,{label:T,modifier:"Ctrl",name:"console"}),e[45]=T,e[46]=D):D=e[46];let _;e[47]!==S||e[48]!==D?(_=(0,t.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[S,D]}),e[47]=S,e[48]=D,e[49]=_):_=e[49];let E;e[50]!==r?(E=r("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=r,e[51]=E):E=e[51];let I;e[52]!==E?(I=(0,t.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:E}),e[52]=E,e[53]=I):I=e[53];let K;e[54]!==_||e[55]!==I?(K=(0,t.jsxs)(q,{className:"py-3",children:[_,I]}),e[54]=_,e[55]=I,e[56]=K):K=e[56];let O;e[57]!==w||e[58]!==K?(O=(0,t.jsxs)(P,{className:"py-0","data-testid":"set-preferences",children:[w,K]}),e[57]=w,e[58]=K,e[59]=O):O=e[59];let U;e[60]!==r?(U=r("Environment & bindings"),e[60]=r,e[61]=U):U=e[61];let j;e[62]!==U?(j=(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:U})}),e[62]=U,e[63]=j):j=e[63];let F;e[64]!==c||e[65]!==h||e[66]!==l.length||e[67]!==r?(F=c===null&&!h&&l.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[64]=c,e[65]=h,e[66]=l.length,e[67]=r,e[68]=F):F=e[68];let L;e[69]!==l||e[70]!==r?(L=l.length>0&&(0,t.jsx)(q,{className:"px-0 py-0",children:(0,t.jsxs)(le,{"data-testid":"set-table",children:[(0,t.jsx)(oe,{children:(0,t.jsxs)(H,{children:[(0,t.jsx)(z,{children:r("name")}),(0,t.jsx)(z,{children:r("kind")}),(0,t.jsx)(z,{children:r("value")})]})}),(0,t.jsx)(se,{children:l.map(fe)})]})}),e[69]=l,e[70]=r,e[71]=L):L=e[71];let R;e[72]!==j||e[73]!==F||e[74]!==L?(R=(0,t.jsxs)(P,{className:"py-0",children:[j,F,L]}),e[72]=j,e[73]=F,e[74]=L,e[75]=R):R=e[75];let B;return e[76]!==O||e[77]!==R||e[78]!==f||e[79]!==s||e[80]!==a||e[81]!==d||e[82]!==o||e[83]!==b?(B=(0,t.jsxs)("div",{className:f,"data-testid":s,children:[a,d,o,b,O,R]}),e[76]=O,e[77]=R,e[78]=f,e[79]=s,e[80]=a,e[81]=d,e[82]=o,e[83]=b,e[84]=B):B=e[84],B},"Ce");function he(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}g(he,"me");function fe(n){return(0,t.jsxs)(H,{"data-testid":"set-row",children:[(0,t.jsx)(G,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(G,{children:(0,t.jsx)(Y,{variant:ue[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(G,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}g(fe,"fe");export{Se as SettingsPanel};
|
|
@@ -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-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.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};
|