@lunora/studio 1.0.0-alpha.43 → 1.0.0-alpha.45
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-W3SHEIAL.js → chunk-245TEXSO.js} +2 -2
- package/dist/standalone/{chunk-ISDZPW3V.js → chunk-2BBENYBY.js} +1 -1
- package/dist/standalone/{chunk-2ANAF4ZM.js → chunk-34B5ECBI.js} +1 -1
- package/dist/standalone/{chunk-GUI5GFFI.js → chunk-3IJLM4GF.js} +1 -1
- package/dist/standalone/{chunk-7MVSQS7B.js → chunk-3JO76DWI.js} +1 -1
- package/dist/standalone/{chunk-IN2SYVJB.js → chunk-3SKIYIBN.js} +1 -1
- package/dist/standalone/chunk-4WGGEF73.js +8 -0
- package/dist/standalone/{chunk-GTLEWM5Y.js → chunk-5KUKYIU6.js} +1 -1
- package/dist/standalone/{chunk-EQZQOTJY.js → chunk-6CRKDJNL.js} +1 -1
- package/dist/standalone/{chunk-BX5MKYOC.js → chunk-6HW2RKAX.js} +1 -1
- package/dist/standalone/{chunk-5C4TSNE6.js → chunk-73BV73BI.js} +1 -1
- package/dist/standalone/{chunk-BGXOXASQ.js → chunk-7JOVXGO4.js} +1 -1
- package/dist/standalone/{chunk-J73VHFCL.js → chunk-7KR346F4.js} +1 -1
- package/dist/standalone/{chunk-6VO23MMW.js → chunk-7XTR7BWT.js} +1 -1
- package/dist/standalone/{chunk-JPRH6DPK.js → chunk-AFCBRDRQ.js} +1 -1
- package/dist/standalone/{chunk-UKDJ4H7I.js → chunk-ATG3655M.js} +1 -1
- package/dist/standalone/{chunk-HZK5RQHG.js → chunk-AX7GYUQC.js} +1 -1
- package/dist/standalone/{chunk-ZFNBPAIZ.js → chunk-B4TTGYIX.js} +1 -1
- package/dist/standalone/{chunk-W3JK4YWR.js → chunk-BGHGKAOM.js} +1 -1
- package/dist/standalone/{chunk-HYDJNCGW.js → chunk-BL45HXOJ.js} +1 -1
- package/dist/standalone/{chunk-RHZ4M2NZ.js → chunk-EOSXQTSQ.js} +1 -1
- package/dist/standalone/{chunk-6HSHEMZV.js → chunk-ERUIC6WI.js} +1 -1
- package/dist/standalone/{chunk-OZACQNKG.js → chunk-ERXJPMCU.js} +1 -1
- package/dist/standalone/{chunk-WIHXMNUY.js → chunk-GNMTLLGB.js} +1 -1
- package/dist/standalone/{chunk-THNBTMUF.js → chunk-I34RPZ7P.js} +1 -1
- package/dist/standalone/{chunk-KYJPPVGB.js → chunk-I4RSHYDW.js} +1 -1
- package/dist/standalone/{chunk-KQV4NGH3.js → chunk-ICIQ2GWQ.js} +1 -1
- package/dist/standalone/{chunk-JHKMUTIF.js → chunk-J75M4LTW.js} +1 -1
- package/dist/standalone/{chunk-HN6KJXYQ.js → chunk-JEVKZIHN.js} +1 -1
- package/dist/standalone/{chunk-KUH4P5F5.js → chunk-KFNNMXUZ.js} +1 -1
- package/dist/standalone/{chunk-YBGC4PPD.js → chunk-KMNEQEHM.js} +1 -1
- package/dist/standalone/chunk-M5OMEMQ3.js +1 -0
- package/dist/standalone/{chunk-TMYVNQ66.js → chunk-MP5MTWY5.js} +1 -1
- package/dist/standalone/{chunk-PNDNXS5Z.js → chunk-O4YNKFCZ.js} +1 -1
- package/dist/standalone/{chunk-IOANPSJN.js → chunk-OLUEBOHS.js} +1 -1
- package/dist/standalone/{chunk-N2X2OO4V.js → chunk-OOETIPAO.js} +1 -1
- package/dist/standalone/{chunk-MJWVMKQ4.js → chunk-OQPT2BEZ.js} +1 -1
- package/dist/standalone/{chunk-WLDVXVI2.js → chunk-P7AMKXU2.js} +1 -1
- package/dist/standalone/{chunk-UJB2LEI4.js → chunk-PBXQ5QS4.js} +1 -1
- package/dist/standalone/{chunk-TDZ44E5I.js → chunk-PKIPNNRD.js} +1 -1
- package/dist/standalone/{chunk-NGKITPQP.js → chunk-PXR5E7AX.js} +1 -1
- package/dist/standalone/{chunk-447TAUFD.js → chunk-QB3QUTSJ.js} +1 -1
- package/dist/standalone/{chunk-MLZYX5CQ.js → chunk-QQH2YTBW.js} +1 -1
- package/dist/standalone/{chunk-KBB75WNT.js → chunk-S6JKSFSO.js} +1 -1
- package/dist/standalone/{chunk-L2TJVSDQ.js → chunk-T4XWXBKR.js} +1 -1
- package/dist/standalone/{chunk-Q7DMUTUE.js → chunk-TU5ZNEZ4.js} +1 -1
- package/dist/standalone/{chunk-3OIHOXVV.js → chunk-WATFBATD.js} +1 -1
- package/dist/standalone/{chunk-LBN7LPVK.js → chunk-WKUGR7ER.js} +1 -1
- package/dist/standalone/{chunk-UGUEC6BC.js → chunk-WKWKAU22.js} +1 -1
- package/dist/standalone/{chunk-YJAPWSDC.js → chunk-WSMZLZWM.js} +1 -1
- package/dist/standalone/{chunk-6JIZ34MB.js → chunk-XFPHUG7M.js} +1 -1
- package/dist/standalone/{chunk-KA5YB3VP.js → chunk-YSF43KIJ.js} +1 -1
- package/dist/standalone/{chunk-TIQISBGK.js → chunk-ZSNXQT4N.js} +1 -1
- package/dist/standalone/{chunk-25AYY4H7.js → chunk-ZTOATVB7.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +10 -10
- package/dist/standalone/chunk-XLXNLJ4N.js +0 -1
- package/dist/standalone/chunk-ZEJB6DXU.js +0 -8
- /package/dist/standalone/{chunk-E75ANNWX.js → chunk-2GMEK2W3.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Oe,b as Je}from"./chunk-KA5YB3VP.js";import{a as Ke}from"./chunk-7YXOPTWI.js";import{a as qe}from"./chunk-AHILM3ZP.js";import{a as We}from"./chunk-J6J54MBP.js";import"./chunk-L7SK4ZZD.js";import{a as Ge}from"./chunk-2K47A3P6.js";import{a as De,b as Re,c as Pe,d as j,e as D,f as R}from"./chunk-GTM65MVX.js";import{a as V}from"./chunk-JSEXCW5Q.js";import"./chunk-4QHKBC77.js";import{R as B}from"./chunk-3CJW6NWG.js";import{c as U}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Qe}from"./chunk-TAD43CG5.js";import{a as Ze}from"./chunk-RHZ4M2NZ.js";import{a as we,e as Ce}from"./chunk-SEU5V7I6.js";import{b as $}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as H}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Y,g as ze,j as Ae,k as Ue,o as Fe}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as i,e as je,f as _e,g as et,h as tt}from"./chunk-RRCPZMC2.js";var k=je(_e(),1);var Q=je(et(),1);var t=je(tt(),1);var st=i(()=>{let u=(0,Q.c)(3),{config:e,ready:a}=Oe(),l;return u[0]!==e.capabilities||u[1]!==a?(l={capabilities:e.capabilities,ready:a},u[0]=e.capabilities,u[1]=a,u[2]=l):l=u[2],l},"useAuthCapabilities"),lt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=i((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"isFieldFilled"),it=i((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let a=typeof e=="string"?e.trim():"";if(a!==""){if(u.type==="number"){let l=Number(a);return Number.isNaN(l)?void 0:{value:l}}return{value:a}}},"coerceFieldValue"),ot=i(u=>{let e=(0,Q.c)(105),{onClose:a,onCreated:l}=u,c=H(),s=Y(),{config:r}=Oe(),{busy:o,error:n,run:f}=Je(),[w,S]=(0,k.useState)(""),[x,C]=(0,k.useState)(""),[y,F]=(0,k.useState)(""),[v,g]=(0,k.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[h,d]=(0,k.useState)(p),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{S(m.target.value)},"t2"),e[1]=A):A=e[1];let b=A,I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I=i(m=>{C(m.target.value)},"t3"),e[2]=I):I=e[2];let M=I,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=i(m=>{F(m.target.value)},"t4"),e[3]=E):E=e[3];let Be=E,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=i(m=>{g(m.target.value)},"t5"),e[4]=Z):Z=e[4];let $e=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=i((m,P)=>{d(q=>({...q,[m]:P}))},"t6"),e[5]=G):G=e[5];let Ee=G,W;e[6]!==h?(W=i(m=>h[m.name]??(m.type==="boolean"?!1:""),"t7"),e[6]=h,e[7]=W):W=e[7];let T=W,J;if(e[8]!==r.userFields||e[9]!==T){let m;e[11]!==T?(m=i(P=>!P.required||at(P,T(P)),"t92"),e[11]=T,e[12]=m):m=e[12],J=r.userFields.every(m),e[8]=r.userFields,e[9]=T,e[10]=J}else J=e[10];let Ie=J,K;e[13]!==o||e[14]!==w||e[15]!==x||e[16]!==Ie?(K=!o&&w.trim()!==""&&x.trim()!==""&&Ie,e[13]=o,e[14]=w,e[15]=x,e[16]=Ie,e[17]=K):K=e[17];let Ve=K,X;e[18]!==r.userFields||e[19]!==T?(X=i(()=>{let m={};for(let P of r.userFields){let q=it(P,T(P));q!==void 0&&(m[P.name]=q.value)}return Object.keys(m).length===0?void 0:m},"t10"),e[18]=r.userFields,e[19]=T,e[20]=X):X=e[20];let Se=X,_;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==x||e[25]!==a||e[26]!==l||e[27]!==y||e[28]!==v||e[29]!==f?(_=i(()=>{f(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:x.trim(),password:y===""?void 0:y,role:v.trim()===""?void 0:v.trim()}),l(),a()})},"t11"),e[21]=Se,e[22]=c,e[23]=w,e[24]=x,e[25]=a,e[26]=l,e[27]=y,e[28]=v,e[29]=f,e[30]=_):_=e[30];let N=_,z;e[31]!==s?(z=s("Create user"),e[31]=s,e[32]=z):z=e[32];let L;e[33]!==s?(L=s("Create user"),e[33]=s,e[34]=L):L=e[34];let O;e[35]!==L?(O=(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:L},void 0,!1),e[35]=L,e[36]=O):O=e[36];let ee;e[37]!==s?(ee=s("email"),e[37]=s,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsxDEV)(V,{htmlFor:"uc-email",children:ee},void 0,!1),e[39]=ee,e[40]=te):te=e[40];let se;e[41]!==w?(se=(0,t.jsxDEV)(B,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:w},void 0,!1),e[41]=w,e[42]=se):se=e[42];let le;e[43]!==te||e[44]!==se?(le=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[te,se]},void 0,!0),e[43]=te,e[44]=se,e[45]=le):le=e[45];let ae;e[46]!==s?(ae=s("name"),e[46]=s,e[47]=ae):ae=e[47];let ie;e[48]!==ae?(ie=(0,t.jsxDEV)(V,{htmlFor:"uc-name",children:ae},void 0,!1),e[48]=ae,e[49]=ie):ie=e[49];let oe;e[50]!==x?(oe=(0,t.jsxDEV)(B,{"data-testid":"uc-name",id:"uc-name",onChange:M,value:x},void 0,!1),e[50]=x,e[51]=oe):oe=e[51];let ne;e[52]!==ie||e[53]!==oe?(ne=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[ie,oe]},void 0,!0),e[52]=ie,e[53]=oe,e[54]=ne):ne=e[54];let de;e[55]!==s?(de=s("Password (optional)"),e[55]=s,e[56]=de):de=e[56];let re;e[57]!==de?(re=(0,t.jsxDEV)(V,{htmlFor:"uc-password",children:de},void 0,!1),e[57]=de,e[58]=re):re=e[58];let ce;e[59]!==y?(ce=(0,t.jsxDEV)(B,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:y},void 0,!1),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==re||e[62]!==ce?(ue=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[re,ce]},void 0,!0),e[61]=re,e[62]=ce,e[63]=ue):ue=e[63];let fe;e[64]!==s?(fe=s("Role (optional)"),e[64]=s,e[65]=fe):fe=e[65];let ve;e[66]!==fe?(ve=(0,t.jsxDEV)(V,{htmlFor:"uc-role",children:fe},void 0,!1),e[66]=fe,e[67]=ve):ve=e[67];let me;e[68]!==v?(me=(0,t.jsxDEV)(B,{"data-testid":"uc-role",id:"uc-role",onChange:$e,value:v},void 0,!1),e[68]=v,e[69]=me):me=e[69];let he;e[70]!==ve||e[71]!==me?(he=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[ve,me]},void 0,!0),e[70]=ve,e[71]=me,e[72]=he):he=e[72];let pe;e[73]!==r.userFields||e[74]!==T||e[75]!==s?(pe=r.userFields.length>0&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")},void 0,!1),r.userFields.map(m=>{let P=`uc-field-${m.name}`,q=m.required?"":` (${s("optional")})`;if(m.type==="boolean"){let Le=T(m)===!0;return(0,t.jsxDEV)("label",{className:"flex items-center gap-2",htmlFor:P,children:[(0,t.jsxDEV)(Ke,{checked:Le,"data-testid":P,id:P,onCheckedChange:i(Xe=>{Ee(m.name,Xe)},"onCheckedChange")},void 0,!1),(0,t.jsxDEV)("span",{className:"text-sm",children:[m.name,q]},void 0,!0)]},m.name,!0)}let Ye=T(m);return(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:P,children:[m.name,q]},void 0,!0),(0,t.jsxDEV)(B,{"data-testid":P,id:P,onChange:i(Le=>{Ee(m.name,Le.target.value)},"onChange"),type:lt[m.type],value:typeof Ye=="string"?Ye:""},void 0,!1)]},m.name,!0)})]},void 0,!0),e[73]=r.userFields,e[74]=T,e[75]=s,e[76]=pe):pe=e[76];let be;e[77]!==n?(be=n!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n},void 0,!1),e[77]=n,e[78]=be):be=e[78];let xe;e[79]!==s?(xe=s("Cancel"),e[79]=s,e[80]=xe):xe=e[80];let ye;e[81]!==a||e[82]!==xe?(ye=(0,t.jsxDEV)(U,{"data-testid":"uc-cancel",onClick:a,size:"sm",type:"button",variant:"outline",children:xe},void 0,!1),e[81]=a,e[82]=xe,e[83]=ye):ye=e[83];let Me=!Ve,ge;e[84]!==o||e[85]!==s?(ge=s(o?"Creating\u2026":"Create"),e[84]=o,e[85]=s,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==Me||e[89]!==ge?(Ne=(0,t.jsxDEV)(U,{"data-testid":"uc-submit",disabled:Me,onClick:N,size:"sm",type:"button",children:ge},void 0,!1),e[87]=N,e[88]=Me,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxDEV)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]},void 0,!0),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let Te;return e[94]!==a||e[95]!==z||e[96]!==O||e[97]!==le||e[98]!==ne||e[99]!==ue||e[100]!==he||e[101]!==pe||e[102]!==be||e[103]!==ke?(Te=(0,t.jsxDEV)(qe,{label:z,onClose:a,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[O,le,ne,ue,he,pe,be,ke]},void 0,!0),e[94]=a,e[95]=z,e[96]=O,e[97]=le,e[98]=ne,e[99]=ue,e[100]=he,e[101]=pe,e[102]=be,e[103]=ke,e[104]=Te):Te=e[104],Te},"UserCreateDialog"),He=i(u=>{let e=(0,Q.c)(2),{children:a}=u,l;return e[0]!==a?(l=(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a},void 0,!1),e[0]=a,e[1]=l):l=e[1],l},"SectionHeading"),nt=i(u=>{let e=(0,Q.c)(29),{busy:a,runAction:l,userId:c,version:s}=u,r=H(),o=Y(),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),x;e[0]!==r||e[1]!==c?(x=i(()=>{Ue((async()=>{S(null);try{let b=await r.listAuthSessions({limit:50,userId:c});f(b.rows)}catch(b){let I=b;f(null),S(ze(I))}})())},"t1"),e[0]=r,e[1]=c,e[2]=x):x=e[2];let C;e[3]!==r||e[4]!==c||e[5]!==s?(C=[r,c,s],e[3]=r,e[4]=c,e[5]=s,e[6]=C):C=e[6],(0,k.useEffect)(x,C);let y;e[7]!==r||e[8]!==l?(y=i(b=>{l(()=>r.revokeAuthSession({sessionId:b}))},"t3"),e[7]=r,e[8]=l,e[9]=y):y=e[9];let F=y,v;e[10]!==o?(v=o("Sessions"),e[10]=o,e[11]=v):v=e[11];let g;e[12]!==v?(g=(0,t.jsxDEV)(He,{children:v},void 0,!1),e[12]=v,e[13]=g):g=e[13];let p;e[14]!==w?(p=w!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w},void 0,!1),e[14]=w,e[15]=p):p=e[15];let h;e[16]!==n||e[17]!==o?(h=n!==null&&n.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:o("No active sessions.")},void 0,!1),e[16]=n,e[17]=o,e[18]=h):h=e[18];let d;e[19]!==a||e[20]!==F||e[21]!==n||e[22]!==o?(d=n!==null&&n.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-sessions-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:o("expires")},void 0,!1),(0,t.jsxDEV)(D,{children:o("ip")},void 0,!1),(0,t.jsxDEV)(D,{children:o("user agent")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:n.map(b=>(0,t.jsxDEV)(j,{"data-testid":`ud-session-${b.id}`,children:[(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(b.expiresAt)},void 0,!1),(0,t.jsxDEV)(R,{children:b.ipAddress??""},void 0,!1),(0,t.jsxDEV)(R,{className:"max-w-40 truncate",children:b.userAgent??""},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-revoke-${b.id}`,disabled:a,onClick:i(()=>{F(b.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Revoke")},void 0,!1)},void 0,!1)]},b.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[19]=a,e[20]=F,e[21]=n,e[22]=o,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==p||e[26]!==h||e[27]!==d?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,p,h,d]},void 0,!0),e[24]=g,e[25]=p,e[26]=h,e[27]=d,e[28]=A):A=e[28],A},"UserSessionsPanel"),dt=i(u=>{let e=(0,Q.c)(30),{busy:a,runAction:l,userId:c,version:s}=u,r=H(),o=Y(),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),x;e[0]!==r||e[1]!==c?(x=i(()=>{Ue((async()=>{S(null);try{f(await r.listAuthAccounts({userId:c}))}catch(b){let I=b;f(null),S(ze(I))}})())},"t1"),e[0]=r,e[1]=c,e[2]=x):x=e[2];let C;e[3]!==r||e[4]!==c||e[5]!==s?(C=[r,c,s],e[3]=r,e[4]=c,e[5]=s,e[6]=C):C=e[6],(0,k.useEffect)(x,C);let y;e[7]!==r||e[8]!==l||e[9]!==c?(y=i(b=>{l(()=>r.unlinkAuthAccount({accountId:b,userId:c}))},"t3"),e[7]=r,e[8]=l,e[9]=c,e[10]=y):y=e[10];let F=y,v;e[11]!==o?(v=o("Linked accounts"),e[11]=o,e[12]=v):v=e[12];let g;e[13]!==v?(g=(0,t.jsxDEV)(He,{children:v},void 0,!1),e[13]=v,e[14]=g):g=e[14];let p;e[15]!==w?(p=w!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive",role:"alert",children:w},void 0,!1),e[15]=w,e[16]=p):p=e[16];let h;e[17]!==n||e[18]!==o?(h=n!==null&&n.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o("No linked accounts.")},void 0,!1),e[17]=n,e[18]=o,e[19]=h):h=e[19];let d;e[20]!==n||e[21]!==a||e[22]!==F||e[23]!==o?(d=n!==null&&n.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-accounts-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:o("provider")},void 0,!1),(0,t.jsxDEV)(D,{children:o("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:n.map(b=>{let I=Ae(b.id);return(0,t.jsxDEV)(j,{"data-testid":`ud-account-${I}`,children:[(0,t.jsxDEV)(R,{children:Ae(b.providerId)},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(b.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-unlink-${I}`,disabled:a,onClick:i(()=>{F(I)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Unlink")},void 0,!1)},void 0,!1)]},I,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[20]=n,e[21]=a,e[22]=F,e[23]=o,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==p||e[27]!==h||e[28]!==d?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,p,h,d]},void 0,!0),e[25]=g,e[26]=p,e[27]=h,e[28]=d,e[29]=A):A=e[29],A},"UserAccountsPanel"),rt=i(u=>{let e=(0,Q.c)(40),{busy:a,capabilities:l,runAction:c,userId:s,version:r}=u,o=H(),n=Y(),[f,w]=(0,k.useState)(null),S;e[0]!==l.passkey||e[1]!==o||e[2]!==s?(S=i(()=>{l.passkey&&Ue((async()=>{try{w(await o.listAuthPasskeys({userId:s}))}catch{w(null)}})())},"t1"),e[0]=l.passkey,e[1]=o,e[2]=s,e[3]=S):S=e[3];let x;e[4]!==l.passkey||e[5]!==o||e[6]!==s||e[7]!==r?(x=[l.passkey,o,s,r],e[4]=l.passkey,e[5]=o,e[6]=s,e[7]=r,e[8]=x):x=e[8],(0,k.useEffect)(S,x);let C;e[9]!==o||e[10]!==c||e[11]!==s?(C=i(()=>{c(()=>o.disableAuthTwoFactor({userId:s}))},"t3"),e[9]=o,e[10]=c,e[11]=s,e[12]=C):C=e[12];let y=C,F;e[13]!==o||e[14]!==c?(F=i(I=>{c(()=>o.deleteAuthPasskey({passkeyId:I}))},"t4"),e[13]=o,e[14]=c,e[15]=F):F=e[15];let v=F,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let p;e[18]!==g?(p=(0,t.jsxDEV)(He,{children:g},void 0,!1),e[18]=g,e[19]=p):p=e[19];let h;e[20]!==a||e[21]!==l.twoFactor||e[22]!==y||e[23]!==n?(h=l.twoFactor&&(0,t.jsxDEV)(U,{"data-testid":"ud-disable-2fa",disabled:a,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")},void 0,!1),e[20]=a,e[21]=l.twoFactor,e[22]=y,e[23]=n,e[24]=h):h=e[24];let d;e[25]!==l.passkey||e[26]!==f||e[27]!==n?(d=l.passkey&&f!==null&&f.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")},void 0,!1),e[25]=l.passkey,e[26]=f,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==a||e[30]!==l.passkey||e[31]!==v||e[32]!==f||e[33]!==n?(A=l.passkey&&f!==null&&f.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-passkeys-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:n("name")},void 0,!1),(0,t.jsxDEV)(D,{children:n("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":n("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:f.map(I=>{let M=Ae(I.id);return(0,t.jsxDEV)(j,{"data-testid":`ud-passkey-${M}`,children:[(0,t.jsxDEV)(R,{children:Ae(I.name)||M},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(I.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-delete-passkey-${M}`,disabled:a,onClick:i(()=>{v(M)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")},void 0,!1)},void 0,!1)]},M,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[29]=a,e[30]=l.passkey,e[31]=v,e[32]=f,e[33]=n,e[34]=A):A=e[34];let b;return e[35]!==p||e[36]!==h||e[37]!==d||e[38]!==A?(b=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,h,d,A]},void 0,!0),e[35]=p,e[36]=h,e[37]=d,e[38]=A,e[39]=b):b=e[39],b},"UserSecurityPanel"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=i((u,e)=>typeof e=="number"&&ct.test(u)?Fe(e):Ae(e),"formatField"),vt=i(({capabilities:u,onChanged:e,onClose:a,user:l})=>{let c=H(),s=Y(),r=l.banned===!0,[o,n]=(0,k.useState)(null),[f,w]=(0,k.useState)(!1),[S,x]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof l.role=="string"?l.role:""),[F,v]=(0,k.useState)(""),[g,p]=(0,k.useState)(""),[h,d]=(0,k.useState)(""),[A,b]=(0,k.useState)(null),[I,M]=(0,k.useState)(!1),E=i((N,z)=>{Ue((async()=>{w(!0),n(null);try{let L=await N();z?.refresh!==!1&&(x(O=>O+1),e()),z?.onResult?.(L)}catch(L){n(ze(L))}finally{w(!1)}})())},"runAction"),Be=i(N=>{y(N.target.value)},"onRoleInputChange"),Z=i(N=>{v(N.target.value)},"onBanReasonChange"),$e=i(N=>{p(N.target.value)},"onBanDaysChange"),G=i(N=>{d(N.target.value)},"onNewPasswordChange"),Ee=i(()=>{let N=C.trim();N!==""&&E(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},"onSetRole"),W=i(()=>{let N=Number.parseInt(g,10),z=Number.isFinite(N)&&N>0?N*86400:void 0;E(async()=>{await c.banAuthUser({expiresInSeconds:z,reason:F.trim()===""?void 0:F.trim(),userId:l.id})})},"onBan"),T=i(()=>{E(async()=>{await c.unbanAuthUser({userId:l.id})})},"onUnban"),J=i(()=>{E(async()=>{await c.setAuthUserPassword({newPassword:h,userId:l.id}),d("")})},"onSetPassword"),Ie=i(()=>{E(()=>c.impersonateAuthUser({userId:l.id}),{onResult:i(N=>{b(N.token)},"onResult"),refresh:!1})},"onImpersonate"),K=i(()=>{E(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},"onRevokeAll"),Ve=i(()=>{E(async()=>{await c.removeAuthUser({userId:l.id}),a()})},"onDelete"),X=i(()=>{M(!0)},"onConfirmDelete"),Se=i(()=>{M(!1)},"onCancelDelete"),_=Object.entries(l).filter(([N])=>!ut.has(N));return(0,t.jsxDEV)(qe,{label:s("User details"),onClose:a,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxDEV)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id},void 0,!1),(0,t.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsxDEV)($,{variant:"secondary",children:l.role},void 0,!1),r?(0,t.jsxDEV)($,{variant:"destructive",children:s("Banned")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:s("Active")},void 0,!1),l.emailVerified===!0?(0,t.jsxDEV)($,{variant:"secondary",children:s("verified")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:s("unverified")},void 0,!1)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-close",onClick:a,size:"sm",type:"button",variant:"ghost",children:s("Close")},void 0,!1)]},void 0,!0),o!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:o},void 0,!1),u.admin&&(0,t.jsxDEV)(we,{className:"gap-0 py-0",children:[(0,t.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(Ce,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-role",children:s("Role")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:C},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-set-role",disabled:f||C.trim()==="",onClick:Ee,size:"sm",type:"button",variant:"outline",children:s("Set role")},void 0,!1)]},void 0,!0),r?(0,t.jsxDEV)(U,{"data-testid":"ud-unban",disabled:f,onClick:T,size:"sm",type:"button",variant:"outline",children:s("Unban")},void 0,!1):(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-ban-reason",children:s("Ban reason (optional)")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:F},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-ban-days",children:s("Days")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:$e,type:"number",value:g},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-ban",disabled:f,onClick:W,size:"sm",type:"button",variant:"destructive",children:s("Ban user")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-password",children:s("New password")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:h},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-set-password",disabled:f||h==="",onClick:J,size:"sm",type:"button",variant:"outline",children:s("Set password")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxDEV)(U,{"data-testid":"ud-impersonate",disabled:f,onClick:Ie,size:"sm",type:"button",variant:"outline",children:s("Impersonate")},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"ud-revoke-all",disabled:f,onClick:K,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")},void 0,!1),I?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(U,{"data-testid":"ud-delete-confirm",disabled:f,onClick:Ve,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:s("Cancel")},void 0,!1)]},void 0,!0):(0,t.jsxDEV)(U,{"data-testid":"ud-delete",disabled:f,onClick:X,size:"sm",type:"button",variant:"destructive",children:s("Delete user")},void 0,!1)]},void 0,!0),A!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-token",children:s("Impersonation token")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(nt,{busy:f,runAction:E,userId:l.id,version:S},void 0,!1),u.accounts&&(0,t.jsxDEV)(dt,{busy:f,runAction:E,userId:l.id,version:S},void 0,!1),(u.twoFactor||u.passkey)&&(0,t.jsxDEV)(rt,{busy:f,capabilities:u,runAction:E,userId:l.id,version:S},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")},void 0,!1),(0,t.jsxDEV)("dl",{className:"flex flex-col",children:_.map(([N,z])=>(0,t.jsxDEV)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsxDEV)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N},void 0,!1),(0,t.jsxDEV)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(N,z)},void 0,!1)]},N,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},"UserDetailDrawer"),mt=50,Rt=i(({pageSize:u=mt}={})=>{let e=H(),a=Y(),[l,c]=(0,k.useState)(""),[s,r]=(0,k.useState)(""),o=Ge(l),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:x}=st(),C=o.trim(),y=s.trim(),F=Ze(["lunora-auth-users",C,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:C===""?void 0:C}),{keepPreviousData:!0}),v=F.data?.rows??null,g=F.error,p=i(()=>{F.refetch()},"reloadUsers");We(()=>{F.refetch()},!0);let h=n===null?null:v?.find(d=>d.id===n)??null;return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(B,{"aria-label":a("Search users"),className:"w-56","data-testid":"us-search",onChange:i(d=>{c(d.target.value)},"onChange"),placeholder:a("Search by email or name\u2026"),value:l},void 0,!1),(0,t.jsxDEV)(B,{"aria-label":a("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i(d=>{r(d.target.value)},"onChange"),placeholder:a("Filter by role"),value:s},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"us-new",onClick:i(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:a("New user")},void 0,!1)]},void 0,!0),g!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g},void 0,!1),v!==null&&v.length===0&&(0,t.jsxDEV)(Qe,{description:a("Users who sign up to your app will appear here."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsxDEV)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"},void 0,!1)},void 0,!1),testId:"us-empty",title:a("No users.")},void 0,!1),v!==null&&v.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"us-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:a("id")},void 0,!1),(0,t.jsxDEV)(D,{children:a("email")},void 0,!1),(0,t.jsxDEV)(D,{children:a("name")},void 0,!1),(0,t.jsxDEV)(D,{children:a("role")},void 0,!1),(0,t.jsxDEV)(D,{children:a("status")},void 0,!1),(0,t.jsxDEV)(D,{children:a("verified")},void 0,!1),(0,t.jsxDEV)(D,{children:a("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":a("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:v.map(d=>(0,t.jsxDEV)(j,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsxDEV)(R,{className:"font-mono text-xs",children:d.id},void 0,!1),(0,t.jsxDEV)(R,{children:d.email??""},void 0,!1),(0,t.jsxDEV)(R,{children:d.name??""},void 0,!1),(0,t.jsxDEV)(R,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsxDEV)($,{variant:"secondary",children:d.role},void 0,!1):""},void 0,!1),(0,t.jsxDEV)(R,{children:d.banned===!0?(0,t.jsxDEV)($,{variant:"destructive",children:a("Banned")},void 0,!1):(0,t.jsxDEV)($,{variant:"success",children:a("Active")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(R,{children:d.emailVerified===!0?(0,t.jsxDEV)($,{variant:"success",children:a("yes")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:a("no")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(d.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`us-manage-${d.id}`,onClick:i(()=>{f(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Manage")},void 0,!1)},void 0,!1)]},d.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),h!==null&&(0,t.jsxDEV)(vt,{capabilities:x,onChanged:p,onClose:i(()=>{f(null)},"onClose"),user:h},void 0,!1),w&&(0,t.jsxDEV)(ot,{onClose:i(()=>{S(!1)},"onClose"),onCreated:p},void 0,!1)]},void 0,!0)},"UsersPanel");export{Rt as UsersPanel};
|
|
1
|
+
import{a as Oe,b as Je}from"./chunk-YSF43KIJ.js";import{a as Ke}from"./chunk-7YXOPTWI.js";import{a as qe}from"./chunk-AHILM3ZP.js";import{a as We}from"./chunk-J6J54MBP.js";import"./chunk-L7SK4ZZD.js";import{a as Ge}from"./chunk-2K47A3P6.js";import{a as De,b as Re,c as Pe,d as j,e as D,f as R}from"./chunk-GTM65MVX.js";import{a as V}from"./chunk-JSEXCW5Q.js";import"./chunk-4QHKBC77.js";import{R as B}from"./chunk-3CJW6NWG.js";import{c as U}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Qe}from"./chunk-TAD43CG5.js";import{a as Ze}from"./chunk-EOSXQTSQ.js";import{a as we,e as Ce}from"./chunk-SEU5V7I6.js";import{b as $}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as H}from"./chunk-M5OMEMQ3.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Y,g as ze,j as Ae,k as Ue,o as Fe}from"./chunk-2GMEK2W3.js";import"./chunk-J75M4LTW.js";import{a as i,e as je,f as _e,g as et,h as tt}from"./chunk-RRCPZMC2.js";var k=je(_e(),1);var Q=je(et(),1);var t=je(tt(),1);var st=i(()=>{let u=(0,Q.c)(3),{config:e,ready:a}=Oe(),l;return u[0]!==e.capabilities||u[1]!==a?(l={capabilities:e.capabilities,ready:a},u[0]=e.capabilities,u[1]=a,u[2]=l):l=u[2],l},"useAuthCapabilities"),lt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=i((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"isFieldFilled"),it=i((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let a=typeof e=="string"?e.trim():"";if(a!==""){if(u.type==="number"){let l=Number(a);return Number.isNaN(l)?void 0:{value:l}}return{value:a}}},"coerceFieldValue"),ot=i(u=>{let e=(0,Q.c)(105),{onClose:a,onCreated:l}=u,c=H(),s=Y(),{config:r}=Oe(),{busy:o,error:n,run:f}=Je(),[w,S]=(0,k.useState)(""),[x,C]=(0,k.useState)(""),[y,F]=(0,k.useState)(""),[v,g]=(0,k.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[h,d]=(0,k.useState)(p),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{S(m.target.value)},"t2"),e[1]=A):A=e[1];let b=A,I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I=i(m=>{C(m.target.value)},"t3"),e[2]=I):I=e[2];let M=I,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=i(m=>{F(m.target.value)},"t4"),e[3]=E):E=e[3];let Be=E,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=i(m=>{g(m.target.value)},"t5"),e[4]=Z):Z=e[4];let $e=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=i((m,P)=>{d(q=>({...q,[m]:P}))},"t6"),e[5]=G):G=e[5];let Ee=G,W;e[6]!==h?(W=i(m=>h[m.name]??(m.type==="boolean"?!1:""),"t7"),e[6]=h,e[7]=W):W=e[7];let T=W,J;if(e[8]!==r.userFields||e[9]!==T){let m;e[11]!==T?(m=i(P=>!P.required||at(P,T(P)),"t92"),e[11]=T,e[12]=m):m=e[12],J=r.userFields.every(m),e[8]=r.userFields,e[9]=T,e[10]=J}else J=e[10];let Ie=J,K;e[13]!==o||e[14]!==w||e[15]!==x||e[16]!==Ie?(K=!o&&w.trim()!==""&&x.trim()!==""&&Ie,e[13]=o,e[14]=w,e[15]=x,e[16]=Ie,e[17]=K):K=e[17];let Ve=K,X;e[18]!==r.userFields||e[19]!==T?(X=i(()=>{let m={};for(let P of r.userFields){let q=it(P,T(P));q!==void 0&&(m[P.name]=q.value)}return Object.keys(m).length===0?void 0:m},"t10"),e[18]=r.userFields,e[19]=T,e[20]=X):X=e[20];let Se=X,_;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==x||e[25]!==a||e[26]!==l||e[27]!==y||e[28]!==v||e[29]!==f?(_=i(()=>{f(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:x.trim(),password:y===""?void 0:y,role:v.trim()===""?void 0:v.trim()}),l(),a()})},"t11"),e[21]=Se,e[22]=c,e[23]=w,e[24]=x,e[25]=a,e[26]=l,e[27]=y,e[28]=v,e[29]=f,e[30]=_):_=e[30];let N=_,z;e[31]!==s?(z=s("Create user"),e[31]=s,e[32]=z):z=e[32];let L;e[33]!==s?(L=s("Create user"),e[33]=s,e[34]=L):L=e[34];let O;e[35]!==L?(O=(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:L},void 0,!1),e[35]=L,e[36]=O):O=e[36];let ee;e[37]!==s?(ee=s("email"),e[37]=s,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsxDEV)(V,{htmlFor:"uc-email",children:ee},void 0,!1),e[39]=ee,e[40]=te):te=e[40];let se;e[41]!==w?(se=(0,t.jsxDEV)(B,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:w},void 0,!1),e[41]=w,e[42]=se):se=e[42];let le;e[43]!==te||e[44]!==se?(le=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[te,se]},void 0,!0),e[43]=te,e[44]=se,e[45]=le):le=e[45];let ae;e[46]!==s?(ae=s("name"),e[46]=s,e[47]=ae):ae=e[47];let ie;e[48]!==ae?(ie=(0,t.jsxDEV)(V,{htmlFor:"uc-name",children:ae},void 0,!1),e[48]=ae,e[49]=ie):ie=e[49];let oe;e[50]!==x?(oe=(0,t.jsxDEV)(B,{"data-testid":"uc-name",id:"uc-name",onChange:M,value:x},void 0,!1),e[50]=x,e[51]=oe):oe=e[51];let ne;e[52]!==ie||e[53]!==oe?(ne=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[ie,oe]},void 0,!0),e[52]=ie,e[53]=oe,e[54]=ne):ne=e[54];let de;e[55]!==s?(de=s("Password (optional)"),e[55]=s,e[56]=de):de=e[56];let re;e[57]!==de?(re=(0,t.jsxDEV)(V,{htmlFor:"uc-password",children:de},void 0,!1),e[57]=de,e[58]=re):re=e[58];let ce;e[59]!==y?(ce=(0,t.jsxDEV)(B,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:y},void 0,!1),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==re||e[62]!==ce?(ue=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[re,ce]},void 0,!0),e[61]=re,e[62]=ce,e[63]=ue):ue=e[63];let fe;e[64]!==s?(fe=s("Role (optional)"),e[64]=s,e[65]=fe):fe=e[65];let ve;e[66]!==fe?(ve=(0,t.jsxDEV)(V,{htmlFor:"uc-role",children:fe},void 0,!1),e[66]=fe,e[67]=ve):ve=e[67];let me;e[68]!==v?(me=(0,t.jsxDEV)(B,{"data-testid":"uc-role",id:"uc-role",onChange:$e,value:v},void 0,!1),e[68]=v,e[69]=me):me=e[69];let he;e[70]!==ve||e[71]!==me?(he=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[ve,me]},void 0,!0),e[70]=ve,e[71]=me,e[72]=he):he=e[72];let pe;e[73]!==r.userFields||e[74]!==T||e[75]!==s?(pe=r.userFields.length>0&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")},void 0,!1),r.userFields.map(m=>{let P=`uc-field-${m.name}`,q=m.required?"":` (${s("optional")})`;if(m.type==="boolean"){let Le=T(m)===!0;return(0,t.jsxDEV)("label",{className:"flex items-center gap-2",htmlFor:P,children:[(0,t.jsxDEV)(Ke,{checked:Le,"data-testid":P,id:P,onCheckedChange:i(Xe=>{Ee(m.name,Xe)},"onCheckedChange")},void 0,!1),(0,t.jsxDEV)("span",{className:"text-sm",children:[m.name,q]},void 0,!0)]},m.name,!0)}let Ye=T(m);return(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:P,children:[m.name,q]},void 0,!0),(0,t.jsxDEV)(B,{"data-testid":P,id:P,onChange:i(Le=>{Ee(m.name,Le.target.value)},"onChange"),type:lt[m.type],value:typeof Ye=="string"?Ye:""},void 0,!1)]},m.name,!0)})]},void 0,!0),e[73]=r.userFields,e[74]=T,e[75]=s,e[76]=pe):pe=e[76];let be;e[77]!==n?(be=n!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n},void 0,!1),e[77]=n,e[78]=be):be=e[78];let xe;e[79]!==s?(xe=s("Cancel"),e[79]=s,e[80]=xe):xe=e[80];let ye;e[81]!==a||e[82]!==xe?(ye=(0,t.jsxDEV)(U,{"data-testid":"uc-cancel",onClick:a,size:"sm",type:"button",variant:"outline",children:xe},void 0,!1),e[81]=a,e[82]=xe,e[83]=ye):ye=e[83];let Me=!Ve,ge;e[84]!==o||e[85]!==s?(ge=s(o?"Creating\u2026":"Create"),e[84]=o,e[85]=s,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==Me||e[89]!==ge?(Ne=(0,t.jsxDEV)(U,{"data-testid":"uc-submit",disabled:Me,onClick:N,size:"sm",type:"button",children:ge},void 0,!1),e[87]=N,e[88]=Me,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxDEV)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]},void 0,!0),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let Te;return e[94]!==a||e[95]!==z||e[96]!==O||e[97]!==le||e[98]!==ne||e[99]!==ue||e[100]!==he||e[101]!==pe||e[102]!==be||e[103]!==ke?(Te=(0,t.jsxDEV)(qe,{label:z,onClose:a,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[O,le,ne,ue,he,pe,be,ke]},void 0,!0),e[94]=a,e[95]=z,e[96]=O,e[97]=le,e[98]=ne,e[99]=ue,e[100]=he,e[101]=pe,e[102]=be,e[103]=ke,e[104]=Te):Te=e[104],Te},"UserCreateDialog"),He=i(u=>{let e=(0,Q.c)(2),{children:a}=u,l;return e[0]!==a?(l=(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a},void 0,!1),e[0]=a,e[1]=l):l=e[1],l},"SectionHeading"),nt=i(u=>{let e=(0,Q.c)(29),{busy:a,runAction:l,userId:c,version:s}=u,r=H(),o=Y(),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),x;e[0]!==r||e[1]!==c?(x=i(()=>{Ue((async()=>{S(null);try{let b=await r.listAuthSessions({limit:50,userId:c});f(b.rows)}catch(b){let I=b;f(null),S(ze(I))}})())},"t1"),e[0]=r,e[1]=c,e[2]=x):x=e[2];let C;e[3]!==r||e[4]!==c||e[5]!==s?(C=[r,c,s],e[3]=r,e[4]=c,e[5]=s,e[6]=C):C=e[6],(0,k.useEffect)(x,C);let y;e[7]!==r||e[8]!==l?(y=i(b=>{l(()=>r.revokeAuthSession({sessionId:b}))},"t3"),e[7]=r,e[8]=l,e[9]=y):y=e[9];let F=y,v;e[10]!==o?(v=o("Sessions"),e[10]=o,e[11]=v):v=e[11];let g;e[12]!==v?(g=(0,t.jsxDEV)(He,{children:v},void 0,!1),e[12]=v,e[13]=g):g=e[13];let p;e[14]!==w?(p=w!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w},void 0,!1),e[14]=w,e[15]=p):p=e[15];let h;e[16]!==n||e[17]!==o?(h=n!==null&&n.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:o("No active sessions.")},void 0,!1),e[16]=n,e[17]=o,e[18]=h):h=e[18];let d;e[19]!==a||e[20]!==F||e[21]!==n||e[22]!==o?(d=n!==null&&n.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-sessions-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:o("expires")},void 0,!1),(0,t.jsxDEV)(D,{children:o("ip")},void 0,!1),(0,t.jsxDEV)(D,{children:o("user agent")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:n.map(b=>(0,t.jsxDEV)(j,{"data-testid":`ud-session-${b.id}`,children:[(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(b.expiresAt)},void 0,!1),(0,t.jsxDEV)(R,{children:b.ipAddress??""},void 0,!1),(0,t.jsxDEV)(R,{className:"max-w-40 truncate",children:b.userAgent??""},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-revoke-${b.id}`,disabled:a,onClick:i(()=>{F(b.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Revoke")},void 0,!1)},void 0,!1)]},b.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[19]=a,e[20]=F,e[21]=n,e[22]=o,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==p||e[26]!==h||e[27]!==d?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,p,h,d]},void 0,!0),e[24]=g,e[25]=p,e[26]=h,e[27]=d,e[28]=A):A=e[28],A},"UserSessionsPanel"),dt=i(u=>{let e=(0,Q.c)(30),{busy:a,runAction:l,userId:c,version:s}=u,r=H(),o=Y(),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),x;e[0]!==r||e[1]!==c?(x=i(()=>{Ue((async()=>{S(null);try{f(await r.listAuthAccounts({userId:c}))}catch(b){let I=b;f(null),S(ze(I))}})())},"t1"),e[0]=r,e[1]=c,e[2]=x):x=e[2];let C;e[3]!==r||e[4]!==c||e[5]!==s?(C=[r,c,s],e[3]=r,e[4]=c,e[5]=s,e[6]=C):C=e[6],(0,k.useEffect)(x,C);let y;e[7]!==r||e[8]!==l||e[9]!==c?(y=i(b=>{l(()=>r.unlinkAuthAccount({accountId:b,userId:c}))},"t3"),e[7]=r,e[8]=l,e[9]=c,e[10]=y):y=e[10];let F=y,v;e[11]!==o?(v=o("Linked accounts"),e[11]=o,e[12]=v):v=e[12];let g;e[13]!==v?(g=(0,t.jsxDEV)(He,{children:v},void 0,!1),e[13]=v,e[14]=g):g=e[14];let p;e[15]!==w?(p=w!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive",role:"alert",children:w},void 0,!1),e[15]=w,e[16]=p):p=e[16];let h;e[17]!==n||e[18]!==o?(h=n!==null&&n.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o("No linked accounts.")},void 0,!1),e[17]=n,e[18]=o,e[19]=h):h=e[19];let d;e[20]!==n||e[21]!==a||e[22]!==F||e[23]!==o?(d=n!==null&&n.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-accounts-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:o("provider")},void 0,!1),(0,t.jsxDEV)(D,{children:o("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:n.map(b=>{let I=Ae(b.id);return(0,t.jsxDEV)(j,{"data-testid":`ud-account-${I}`,children:[(0,t.jsxDEV)(R,{children:Ae(b.providerId)},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(b.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-unlink-${I}`,disabled:a,onClick:i(()=>{F(I)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Unlink")},void 0,!1)},void 0,!1)]},I,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[20]=n,e[21]=a,e[22]=F,e[23]=o,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==p||e[27]!==h||e[28]!==d?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,p,h,d]},void 0,!0),e[25]=g,e[26]=p,e[27]=h,e[28]=d,e[29]=A):A=e[29],A},"UserAccountsPanel"),rt=i(u=>{let e=(0,Q.c)(40),{busy:a,capabilities:l,runAction:c,userId:s,version:r}=u,o=H(),n=Y(),[f,w]=(0,k.useState)(null),S;e[0]!==l.passkey||e[1]!==o||e[2]!==s?(S=i(()=>{l.passkey&&Ue((async()=>{try{w(await o.listAuthPasskeys({userId:s}))}catch{w(null)}})())},"t1"),e[0]=l.passkey,e[1]=o,e[2]=s,e[3]=S):S=e[3];let x;e[4]!==l.passkey||e[5]!==o||e[6]!==s||e[7]!==r?(x=[l.passkey,o,s,r],e[4]=l.passkey,e[5]=o,e[6]=s,e[7]=r,e[8]=x):x=e[8],(0,k.useEffect)(S,x);let C;e[9]!==o||e[10]!==c||e[11]!==s?(C=i(()=>{c(()=>o.disableAuthTwoFactor({userId:s}))},"t3"),e[9]=o,e[10]=c,e[11]=s,e[12]=C):C=e[12];let y=C,F;e[13]!==o||e[14]!==c?(F=i(I=>{c(()=>o.deleteAuthPasskey({passkeyId:I}))},"t4"),e[13]=o,e[14]=c,e[15]=F):F=e[15];let v=F,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let p;e[18]!==g?(p=(0,t.jsxDEV)(He,{children:g},void 0,!1),e[18]=g,e[19]=p):p=e[19];let h;e[20]!==a||e[21]!==l.twoFactor||e[22]!==y||e[23]!==n?(h=l.twoFactor&&(0,t.jsxDEV)(U,{"data-testid":"ud-disable-2fa",disabled:a,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")},void 0,!1),e[20]=a,e[21]=l.twoFactor,e[22]=y,e[23]=n,e[24]=h):h=e[24];let d;e[25]!==l.passkey||e[26]!==f||e[27]!==n?(d=l.passkey&&f!==null&&f.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")},void 0,!1),e[25]=l.passkey,e[26]=f,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==a||e[30]!==l.passkey||e[31]!==v||e[32]!==f||e[33]!==n?(A=l.passkey&&f!==null&&f.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-passkeys-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:n("name")},void 0,!1),(0,t.jsxDEV)(D,{children:n("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":n("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:f.map(I=>{let M=Ae(I.id);return(0,t.jsxDEV)(j,{"data-testid":`ud-passkey-${M}`,children:[(0,t.jsxDEV)(R,{children:Ae(I.name)||M},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(I.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-delete-passkey-${M}`,disabled:a,onClick:i(()=>{v(M)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")},void 0,!1)},void 0,!1)]},M,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[29]=a,e[30]=l.passkey,e[31]=v,e[32]=f,e[33]=n,e[34]=A):A=e[34];let b;return e[35]!==p||e[36]!==h||e[37]!==d||e[38]!==A?(b=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,h,d,A]},void 0,!0),e[35]=p,e[36]=h,e[37]=d,e[38]=A,e[39]=b):b=e[39],b},"UserSecurityPanel"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=i((u,e)=>typeof e=="number"&&ct.test(u)?Fe(e):Ae(e),"formatField"),vt=i(({capabilities:u,onChanged:e,onClose:a,user:l})=>{let c=H(),s=Y(),r=l.banned===!0,[o,n]=(0,k.useState)(null),[f,w]=(0,k.useState)(!1),[S,x]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof l.role=="string"?l.role:""),[F,v]=(0,k.useState)(""),[g,p]=(0,k.useState)(""),[h,d]=(0,k.useState)(""),[A,b]=(0,k.useState)(null),[I,M]=(0,k.useState)(!1),E=i((N,z)=>{Ue((async()=>{w(!0),n(null);try{let L=await N();z?.refresh!==!1&&(x(O=>O+1),e()),z?.onResult?.(L)}catch(L){n(ze(L))}finally{w(!1)}})())},"runAction"),Be=i(N=>{y(N.target.value)},"onRoleInputChange"),Z=i(N=>{v(N.target.value)},"onBanReasonChange"),$e=i(N=>{p(N.target.value)},"onBanDaysChange"),G=i(N=>{d(N.target.value)},"onNewPasswordChange"),Ee=i(()=>{let N=C.trim();N!==""&&E(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},"onSetRole"),W=i(()=>{let N=Number.parseInt(g,10),z=Number.isFinite(N)&&N>0?N*86400:void 0;E(async()=>{await c.banAuthUser({expiresInSeconds:z,reason:F.trim()===""?void 0:F.trim(),userId:l.id})})},"onBan"),T=i(()=>{E(async()=>{await c.unbanAuthUser({userId:l.id})})},"onUnban"),J=i(()=>{E(async()=>{await c.setAuthUserPassword({newPassword:h,userId:l.id}),d("")})},"onSetPassword"),Ie=i(()=>{E(()=>c.impersonateAuthUser({userId:l.id}),{onResult:i(N=>{b(N.token)},"onResult"),refresh:!1})},"onImpersonate"),K=i(()=>{E(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},"onRevokeAll"),Ve=i(()=>{E(async()=>{await c.removeAuthUser({userId:l.id}),a()})},"onDelete"),X=i(()=>{M(!0)},"onConfirmDelete"),Se=i(()=>{M(!1)},"onCancelDelete"),_=Object.entries(l).filter(([N])=>!ut.has(N));return(0,t.jsxDEV)(qe,{label:s("User details"),onClose:a,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxDEV)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id},void 0,!1),(0,t.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsxDEV)($,{variant:"secondary",children:l.role},void 0,!1),r?(0,t.jsxDEV)($,{variant:"destructive",children:s("Banned")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:s("Active")},void 0,!1),l.emailVerified===!0?(0,t.jsxDEV)($,{variant:"secondary",children:s("verified")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:s("unverified")},void 0,!1)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-close",onClick:a,size:"sm",type:"button",variant:"ghost",children:s("Close")},void 0,!1)]},void 0,!0),o!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:o},void 0,!1),u.admin&&(0,t.jsxDEV)(we,{className:"gap-0 py-0",children:[(0,t.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(Ce,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-role",children:s("Role")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:C},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-set-role",disabled:f||C.trim()==="",onClick:Ee,size:"sm",type:"button",variant:"outline",children:s("Set role")},void 0,!1)]},void 0,!0),r?(0,t.jsxDEV)(U,{"data-testid":"ud-unban",disabled:f,onClick:T,size:"sm",type:"button",variant:"outline",children:s("Unban")},void 0,!1):(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-ban-reason",children:s("Ban reason (optional)")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:F},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-ban-days",children:s("Days")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:$e,type:"number",value:g},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-ban",disabled:f,onClick:W,size:"sm",type:"button",variant:"destructive",children:s("Ban user")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-password",children:s("New password")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:h},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-set-password",disabled:f||h==="",onClick:J,size:"sm",type:"button",variant:"outline",children:s("Set password")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxDEV)(U,{"data-testid":"ud-impersonate",disabled:f,onClick:Ie,size:"sm",type:"button",variant:"outline",children:s("Impersonate")},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"ud-revoke-all",disabled:f,onClick:K,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")},void 0,!1),I?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(U,{"data-testid":"ud-delete-confirm",disabled:f,onClick:Ve,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:s("Cancel")},void 0,!1)]},void 0,!0):(0,t.jsxDEV)(U,{"data-testid":"ud-delete",disabled:f,onClick:X,size:"sm",type:"button",variant:"destructive",children:s("Delete user")},void 0,!1)]},void 0,!0),A!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-token",children:s("Impersonation token")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(nt,{busy:f,runAction:E,userId:l.id,version:S},void 0,!1),u.accounts&&(0,t.jsxDEV)(dt,{busy:f,runAction:E,userId:l.id,version:S},void 0,!1),(u.twoFactor||u.passkey)&&(0,t.jsxDEV)(rt,{busy:f,capabilities:u,runAction:E,userId:l.id,version:S},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")},void 0,!1),(0,t.jsxDEV)("dl",{className:"flex flex-col",children:_.map(([N,z])=>(0,t.jsxDEV)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsxDEV)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N},void 0,!1),(0,t.jsxDEV)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(N,z)},void 0,!1)]},N,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},"UserDetailDrawer"),mt=50,Rt=i(({pageSize:u=mt}={})=>{let e=H(),a=Y(),[l,c]=(0,k.useState)(""),[s,r]=(0,k.useState)(""),o=Ge(l),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:x}=st(),C=o.trim(),y=s.trim(),F=Ze(["lunora-auth-users",C,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:C===""?void 0:C}),{keepPreviousData:!0}),v=F.data?.rows??null,g=F.error,p=i(()=>{F.refetch()},"reloadUsers");We(()=>{F.refetch()},!0);let h=n===null?null:v?.find(d=>d.id===n)??null;return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(B,{"aria-label":a("Search users"),className:"w-56","data-testid":"us-search",onChange:i(d=>{c(d.target.value)},"onChange"),placeholder:a("Search by email or name\u2026"),value:l},void 0,!1),(0,t.jsxDEV)(B,{"aria-label":a("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i(d=>{r(d.target.value)},"onChange"),placeholder:a("Filter by role"),value:s},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"us-new",onClick:i(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:a("New user")},void 0,!1)]},void 0,!0),g!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g},void 0,!1),v!==null&&v.length===0&&(0,t.jsxDEV)(Qe,{description:a("Users who sign up to your app will appear here."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsxDEV)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"},void 0,!1)},void 0,!1),testId:"us-empty",title:a("No users.")},void 0,!1),v!==null&&v.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"us-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:a("id")},void 0,!1),(0,t.jsxDEV)(D,{children:a("email")},void 0,!1),(0,t.jsxDEV)(D,{children:a("name")},void 0,!1),(0,t.jsxDEV)(D,{children:a("role")},void 0,!1),(0,t.jsxDEV)(D,{children:a("status")},void 0,!1),(0,t.jsxDEV)(D,{children:a("verified")},void 0,!1),(0,t.jsxDEV)(D,{children:a("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":a("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:v.map(d=>(0,t.jsxDEV)(j,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsxDEV)(R,{className:"font-mono text-xs",children:d.id},void 0,!1),(0,t.jsxDEV)(R,{children:d.email??""},void 0,!1),(0,t.jsxDEV)(R,{children:d.name??""},void 0,!1),(0,t.jsxDEV)(R,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsxDEV)($,{variant:"secondary",children:d.role},void 0,!1):""},void 0,!1),(0,t.jsxDEV)(R,{children:d.banned===!0?(0,t.jsxDEV)($,{variant:"destructive",children:a("Banned")},void 0,!1):(0,t.jsxDEV)($,{variant:"success",children:a("Active")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(R,{children:d.emailVerified===!0?(0,t.jsxDEV)($,{variant:"success",children:a("yes")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:a("no")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(d.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`us-manage-${d.id}`,onClick:i(()=>{f(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Manage")},void 0,!1)},void 0,!1)]},d.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),h!==null&&(0,t.jsxDEV)(vt,{capabilities:x,onChanged:p,onClose:i(()=>{f(null)},"onClose"),user:h},void 0,!1),w&&(0,t.jsxDEV)(ot,{onClose:i(()=>{S(!1)},"onClose"),onCreated:p},void 0,!1)]},void 0,!0)},"UsersPanel");export{Rt as UsersPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as R}from"./chunk-TQ36RWOP.js";import{R as C}from"./chunk-3CJW6NWG.js";import{c as k}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as w,e as N}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as b,g as S,k as T,m as L}from"./chunk-
|
|
1
|
+
import{a as R}from"./chunk-TQ36RWOP.js";import{R as C}from"./chunk-3CJW6NWG.js";import{c as k}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as w,e as N}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as b,g as S,k as T,m as L}from"./chunk-2GMEK2W3.js";import{a as f,e as y,f as W,g as j,h as D}from"./chunk-RRCPZMC2.js";var O=y(j(),1),v=y(W(),1);var t=y(D(),1);var I=f(s=>{let e=(0,O.c)(23),{destination:o}=s,h=b(),m;e[0]!==o.snippet?(m=f(()=>{L(o.snippet)},"t1"),e[0]=o.snippet,e[1]=m):m=e[1];let u=m,r;e[2]!==o.title?(r=(0,t.jsxDEV)("h4",{className:"text-sm font-semibold",children:o.title},void 0,!1),e[2]=o.title,e[3]=r):r=e[3];let a;e[4]!==o.description?(a=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o.description},void 0,!1),e[4]=o.description,e[5]=a):a=e[5];let l;e[6]!==r||e[7]!==a?(l=(0,t.jsxDEV)("div",{children:[r,a]},void 0,!0),e[6]=r,e[7]=a,e[8]=l):l=e[8];let g=`drain-copy-${o.id}`,d;e[9]!==h?(d=h("Copy"),e[9]=h,e[10]=d):d=e[10];let i;e[11]!==u||e[12]!==g||e[13]!==d?(i=(0,t.jsxDEV)(k,{"data-testid":g,onClick:u,size:"sm",variant:"outline",children:d},void 0,!1),e[11]=u,e[12]=g,e[13]=d,e[14]=i):i=e[14];let n;e[15]!==l||e[16]!==i?(n=(0,t.jsxDEV)("div",{className:"flex items-start justify-between gap-3",children:[l,i]},void 0,!0),e[15]=l,e[16]=i,e[17]=n):n=e[17];let c;e[18]!==o.snippet?(c=(0,t.jsxDEV)("pre",{className:"mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-xs",children:o.snippet},void 0,!1),e[18]=o.snippet,e[19]=c):c=e[19];let p;return e[20]!==n||e[21]!==c?(p=(0,t.jsxDEV)(w,{className:"py-0","data-testid":"drain-card",children:(0,t.jsxDEV)(N,{className:"p-3",children:[n,c]},void 0,!0)},void 0,!1),e[20]=n,e[21]=c,e[22]=p):p=e[22],p},"DestinationRow"),F=f(()=>{let s=b(),e=[{description:s("Stream every request log to R2, a SIEM, or a third-party log service."),id:"logpush",snippet:["{",' "logpush": true',"}"].join(`
|
|
2
2
|
`),title:s("Logpush")},{description:s("Send logs programmatically to a Worker for custom capture and forwarding."),id:"tail-worker",snippet:["{",' "tail_consumers": [{ "service": "my-log-forwarder" }]',"}"].join(`
|
|
3
3
|
`),title:s("Tail Workers")},{description:s("Retain and query recent request logs directly in Cloudflare's dashboard."),id:"workers-logs",snippet:["{",' "observability": { "enabled": true }',"}"].join(`
|
|
4
4
|
`),title:s("Workers Logs")}],[o,h]=(0,v.useState)(""),[m,u]=(0,v.useState)(!1),[r,a]=(0,v.useState)(null),l=f(async()=>{let i=o.trim();if(i==="")return;let n="fetch"in globalThis?globalThis.fetch:void 0;if(n===void 0){a({kind:"error",message:s("fetch is unavailable in this environment.")});return}let c={durationMs:12,function:"messages:list",outcome:"ok",shard:"root",source:"lunora",tablesRead:["messages"],tablesWritten:[],ts:new Date().toISOString(),type:"request"};u(!0),a(null);let p=performance.now();try{let x=await n(i,{body:JSON.stringify(c),headers:{"Content-Type":"application/json"},method:"POST"});a({kind:"success",latencyMs:Math.round(performance.now()-p),status:x.status})}catch(x){a({kind:"error",message:S(x)})}finally{u(!1)}},"sendTest"),g=f(()=>{T(l())},"onSendTest"),d=f(i=>{h(i.target.value)},"onWebhookUrlChange");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"log-drains",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"drain-cf-link",href:R,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")},void 0,!1)},void 0,!1),(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"drain-readonly-note",children:s("Lunora does not ship logs itself \u2014 forwarding is handled by Cloudflare. Configure a destination below, then test your collector.")},void 0,!1),(0,t.jsxDEV)("section",{className:"flex flex-col gap-3","data-testid":"drain-destinations",children:[(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Cloudflare destinations")},void 0,!1),e.map(i=>(0,t.jsxDEV)(I,{destination:i},i.id,!1))]},void 0,!0),(0,t.jsxDEV)(w,{className:"py-0",children:(0,t.jsxDEV)(N,{className:"p-3",children:(0,t.jsxDEV)("section",{"data-testid":"drain-webhook",children:[(0,t.jsxDEV)("h3",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Webhook test")},void 0,!1),(0,t.jsxDEV)("p",{className:"mb-2 text-sm text-muted-foreground",children:s("POST a sample Lunora request-log envelope to your collector to confirm it is reachable.")},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(C,{className:"min-w-[20rem] flex-1","data-testid":"drain-webhook-url",onChange:d,placeholder:s("https://example.com/logs"),type:"url",value:o},void 0,!1),(0,t.jsxDEV)(k,{"data-testid":"drain-webhook-test",disabled:m||o.trim()==="",onClick:g,children:s(m?"Sending\u2026":"Send test event")},void 0,!1)]},void 0,!0),r!==null&&(0,t.jsxDEV)("p",{className:r.kind==="success"?"mt-2 text-sm text-muted-foreground":"mt-2 text-sm text-destructive","data-testid":"drain-webhook-result",role:r.kind==="error"?"alert":void 0,children:r.kind==="success"?s("Delivered \u2014 status {status} in {latency}ms",{latency:r.latencyMs,status:r.status}):s("Failed: {message}",{message:r.message})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)},"LogDrainsPanel");export{F as LogDrainsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as le}from"./chunk-UGUEC6BC.js";import{a as te}from"./chunk-HN6KJXYQ.js";import"./chunk-XNJNSCLM.js";import{a as ae,b as se,c as oe,d as Q,e as $,f as z}from"./chunk-GTM65MVX.js";import{a as re}from"./chunk-VLXV72QE.js";import{a as C}from"./chunk-JSEXCW5Q.js";import{a as ee}from"./chunk-UKDJ4H7I.js";import"./chunk-TBMYIZIO.js";import{R as E}from"./chunk-3CJW6NWG.js";import{c as k}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as L}from"./chunk-BOXSWNXZ.js";import{a as J}from"./chunk-TAD43CG5.js";import{b as U}from"./chunk-RHZ4M2NZ.js";import{a as j,b as K,c as V,d as Y,e as q}from"./chunk-SEU5V7I6.js";import{b as I}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as W}from"./chunk-XLXNLJ4N.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as O,e as G,f as X,g as Z,k as D}from"./chunk-E75ANNWX.js";import"./chunk-JHKMUTIF.js";import{a as n,e as B,f as ve,g as he,h as xe}from"./chunk-RRCPZMC2.js";var c=B(ve(),1);var ne=B(he(),1);var e=B(xe(),1);var ie=["read","insert","update","delete"],ye=n((a,t)=>({delete:a("Delete"),insert:a("Insert"),read:a("Read"),update:a("Update")})[t],"operationLabel"),ge=n(a=>{let t=new Set;for(let l of a?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:r}=l.metadata;typeof r=="string"&&r!==""&&t.add(r)}return t},"uncoveredTables"),be=n((a,t,l)=>{let r=new Map,s=n(o=>{let d=r.get(o);if(d!==void 0)return d;let i={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:[],table:o,uncovered:l.has(o)};return r.set(o,i),i},"ensure");for(let o of a)s(o.table).cells[o.on]={procedure:o.procedure};for(let o of t){let d=s(o.table);d.maskedColumns.includes(o.column)||d.maskedColumns.push(o.column)}for(let o of l)s(o);return[...r.values()].toSorted((o,d)=>o.table.localeCompare(d.table))},"buildRows"),Ne=n(a=>{let t=(0,ne.c)(17),l;t[0]!==a?(l=a===void 0?{}:a,t[0]=a,t[1]=l):l=t[1];let{onProbe:r}=l,s=O(),o,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={},d={live:!0},t[2]=o,t[3]=d):(o=t[2],d=t[3]);let i=U(L.rlsPolicies,o,d),x;t[4]===Symbol.for("react.memo_cache_sentinel")?(x={},t[4]=x):x=t[4];let p=U(L.maskPolicies,x),v;t[5]===Symbol.for("react.memo_cache_sentinel")?(v={},t[5]=v):v=t[5];let b=U(L.getAdvisories,v),N;if(t[6]!==b.data||t[7]!==p.data||t[8]!==r||t[9]!==i||t[10]!==s){let g=null;i.data!==void 0&&(g=Array.isArray(i.data.policies)?i.data.policies:[]);let _=Array.isArray(p.data?.columns)?p.data.columns:[],F=b.data??null,{error:h,errorSource:m,liveError:P}=i,A=g===null?[]:be(g,_,ge(F)),T;t[12]!==P?(T=(0,e.jsxDEV)("div",{className:"flex items-center justify-end",children:(0,e.jsxDEV)(le,{message:P,prefix:"pm"},void 0,!1)},void 0,!1),t[12]=P,t[13]=T):T=t[13];let y;t[14]!==h||t[15]!==m?(y=h!==null&&(0,e.jsxDEV)(te,{error:m,testId:"pm-error"},void 0,!1),t[14]=h,t[15]=m,t[16]=y):y=t[16],N=(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[T,y,g!==null&&A.length===0?(0,e.jsxDEV)(J,{description:s("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:s("No policy")},void 0,!1):(0,e.jsxDEV)(ae,{"data-testid":"pm-table",children:[(0,e.jsxDEV)(se,{children:(0,e.jsxDEV)(Q,{children:[(0,e.jsxDEV)($,{children:s("Table")},void 0,!1),ie.map(u=>(0,e.jsxDEV)($,{children:ye(s,u)},u,!1)),(0,e.jsxDEV)($,{children:s("Masked columns")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(oe,{children:A.map(u=>(0,e.jsxDEV)(Q,{"data-testid":`pm-row-${u.table}`,children:[(0,e.jsxDEV)(z,{className:"font-mono text-xs",children:(0,e.jsxDEV)("span",{className:"flex items-center gap-1.5",children:[u.table,u.uncovered&&(0,e.jsxDEV)(I,{"data-testid":`pm-uncovered-${u.table}`,title:s("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:s("Uncovered \u2014 reachable without a policy")},void 0,!1)]},void 0,!0)},void 0,!1),ie.map(w=>{let R=u.cells[w];return(0,e.jsxDEV)(z,{"data-testid":`pm-cell-${u.table}-${w}`,children:R.procedure===void 0?(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:s("No policy")},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Covered by {procedure}",{procedure:R.procedure})},void 0,!1),r!==void 0&&(0,e.jsxDEV)(k,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${u.table}-${w}`,onClick:n(()=>{r(u.table,w,R.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Probe this")},void 0,!1)]},void 0,!0)},w,!1)}),(0,e.jsxDEV)(z,{children:u.maskedColumns.length===0?(0,e.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:u.maskedColumns.map(ke)},void 0,!1)},void 0,!1)]},u.table,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),t[6]=b.data,t[7]=p.data,t[8]=r,t[9]=i,t[10]=s,t[11]=N}else N=t[11];return N},"PermissionsMatrix");function ke(a){return(0,e.jsxDEV)(I,{variant:"outline",children:a},a,!1)}n(ke,"_temp");var Ce=G(L.runAs),we=n(()=>{let a=W();return async({args:t,functionPath:l,shardKey:r="",userId:s})=>{let o=Ce;try{return{kind:"allowed",value:await a.query(o,{args:t,functionPath:l,userId:s},X(r))}}catch(d){return{kind:"denied",message:d instanceof Error?d.message:String(d)}}}},"useRunAsProbe"),Se=n(a=>a===void 0?"undefined":JSON.stringify(a,null,2),"formatValue"),Pe=n(({functions:a,prefill:t,runAsIdentity:l=!1}={})=>{let r=W(),s=O(),o=we(),[d,i]=(0,c.useState)(null),[x,p]=(0,c.useState)(null),v=a??d??[],[b,N]=(0,c.useState)(""),[g,_]=(0,c.useState)("{}"),[F,h]=(0,c.useState)(""),[m,P]=(0,c.useState)(""),[A,T]=(0,c.useState)(!1),[y,u]=(0,c.useState)(null),[w,R]=(0,c.useState)(null),H=(0,c.useRef)(-1);(0,c.useEffect)(()=>{if(a!==void 0)return;let f=!1;return r.listFunctions().then(S=>(f||i(S),S)).catch(S=>{f||p(Z(S))}),()=>{f=!0}},[r,a]),(0,c.useEffect)(()=>{if(t===void 0||H.current===t.nonce)return;H.current=t.nonce;let f=t.functionPath;queueMicrotask(()=>{N(f),u(null)})},[t]);let M=b===""?v[0]?.path??"":b,ce=n(async()=>{if(M==="")return;let f;try{f=g.trim()===""?{}:JSON.parse(g)}catch(S){R(s("Invalid JSON args: {message}",{message:S.message})),u(null);return}R(null),T(!0);try{let S=await o({args:f,functionPath:M,shardKey:F.trim(),userId:m.trim()});u(S)}finally{T(!1)}},"run"),fe=n(()=>{D(ce())},"runOnce"),ue=n(f=>{N(f.target.value)},"onSelectChange"),me=n(f=>{_(f.target.value)},"onArgsChange"),pe=n(f=>{P(f.target.value)},"onUserIdChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[x!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:x},void 0,!1),!l&&(0,e.jsxDEV)(J,{description:s("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:s("Set `runAsIdentity` to forge an identity and probe access.")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-function",children:s("Function")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":s("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:ue,value:M,children:v.map(f=>(0,e.jsxDEV)("option",{value:f.path,children:[f.path," (",f.kind,")"]},f.path,!0))},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-args",children:s("Arguments")},void 0,!1),(0,e.jsxDEV)(re,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:me,value:g},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(ee,{onChange:h,testId:"pp-shard",value:F},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-user",children:s("Run as (userId)")},void 0,!1),(0,e.jsxDEV)(E,{"aria-label":s("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:pe,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"pp-run",disabled:!l||A||M==="",onClick:fe,type:"button",children:s(A?"Probing\u2026":"Run probe")},void 0,!1),m.trim()!==""&&(0,e.jsxDEV)(I,{"data-testid":"pp-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),w!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:w},void 0,!1),y!==null&&y.kind==="allowed"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Allowed")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Se(y.value)},void 0,!1)]},void 0,!0),y!==null&&y.kind==="denied"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,e.jsxDEV)(I,{variant:"destructive",children:s("Denied")},void 0,!1),(0,e.jsxDEV)("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:y.message},void 0,!1)]},void 0,!0)]},void 0,!0)},"PermissionsPlayground"),Ae="/__lunora/policy-scaffold",Te={"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."},Ie=n(async a=>{let t=await fetch(Ae,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}),l=await t.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(t.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let r=l.error;return{kind:"error",message:r===void 0?`policy scaffold failed (${String(t.status)})`:Te[r]??r}},"applyPolicyScaffold"),de={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ee=n(()=>{let a=O(),[t,l]=(0,c.useState)(null),[r,s]=(0,c.useState)(!1),[o,d]=(0,c.useState)(null),[i,x]=(0,c.useState)(de),p=n(h=>{let m=h.target.name,{value:P}=h.target;x(A=>({...A,[m]:P}))},"onFieldChange"),v=n(()=>{l(null),x(de)},"reset"),b=n(async h=>{s(!0),d(null);try{let m=await Ie(h);d(m),m.kind==="ok"&&v()}catch(m){d({kind:"error",message:m instanceof Error?m.message:String(m)})}finally{s(!1)}},"submit"),N=n(()=>{D(b({kind:"scaffoldPolicy",name:i.policyName.trim(),table:i.tableName.trim()}))},"onSubmitScaffold"),g=n(()=>{D(b({exportName:i.exportName.trim(),filePath:i.filePath.trim(),kind:"wireRls",policies:i.policies.trim()}))},"onSubmitWire"),_=n(()=>{d(null),l("scaffold")},"openScaffold"),F=n(()=>{d(null),l("wire")},"openWire");return(0,e.jsxDEV)(j,{"data-testid":"policy-scaffolder",size:"sm",children:[(0,e.jsxDEV)(K,{children:[(0,e.jsxDEV)(V,{children:a("Scaffold access rules")},void 0,!1),(0,e.jsxDEV)(Y,{children:a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(q,{children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-new",onClick:_,size:"xs",type:"button",variant:t==="scaffold"?"default":"outline",children:a("New policy file")},void 0,!1),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-wire",onClick:F,size:"xs",type:"button",variant:t==="wire"?"default":"outline",children:a("Wire into a procedure")},void 0,!1)]},void 0,!0),t==="scaffold"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-name",children:a("Policy name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:p,value:i.policyName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-table",children:a("Table name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:p,value:i.tableName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-create",disabled:r||i.policyName.trim()===""||i.tableName.trim()==="",onClick:N,size:"xs",type:"button",children:a(r?"Creating\u2026":"Create policy file")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),t==="wire"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:p,value:i.filePath},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:p,value:i.exportName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:p,value:i.policies},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-apply",disabled:r||i.filePath.trim()===""||i.exportName.trim()===""||i.policies.trim()==="",onClick:g,size:"xs",type:"button",children:a(r?"Wiring\u2026":"Wire RLS")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),o?.kind==="error"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message},void 0,!1),o?.kind==="needs-manual-edit"&&(0,e.jsxDEV)("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.")},void 0,!1),o?.kind==="ok"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,e.jsxDEV)("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})},void 0,!1),o.diagnostics.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(h=>(0,e.jsxDEV)("li",{className:"font-mono text-[11px] text-destructive",children:h},h,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"PolicyScaffolder"),He=n(({functions:a,runAsIdentity:t=!1,schemaEditable:l=!1}={})=>{let r=O(),[s,o]=(0,c.useState)(void 0),d=n((i,x,p)=>{p!==""&&o(v=>({functionPath:p,nonce:(v?.nonce??0)+1}))},"onProbe");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Permissions")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(Ne,{onProbe:d},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:(0,e.jsxDEV)(j,{className:"gap-0 py-0",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Probe")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(q,{className:"px-4 py-4",children:[(0,e.jsxDEV)("p",{className:"mb-3 text-sm text-muted-foreground",children:r("Pick a function and an identity, then run it to see the access outcome.")},void 0,!1),(0,e.jsxDEV)(Pe,{functions:a,prefill:s,runAsIdentity:t},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1),l&&(0,e.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,e.jsxDEV)(Ee,{},void 0,!1)},void 0,!1)]},void 0,!0)},"PermissionsPanel");export{He as PermissionsPanel};
|
|
1
|
+
import{a as le}from"./chunk-WKWKAU22.js";import{a as te}from"./chunk-JEVKZIHN.js";import"./chunk-XNJNSCLM.js";import{a as ae,b as se,c as oe,d as Q,e as $,f as z}from"./chunk-GTM65MVX.js";import{a as re}from"./chunk-VLXV72QE.js";import{a as C}from"./chunk-JSEXCW5Q.js";import{a as ee}from"./chunk-ATG3655M.js";import"./chunk-TBMYIZIO.js";import{R as E}from"./chunk-3CJW6NWG.js";import{c as k}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as L}from"./chunk-BOXSWNXZ.js";import{a as J}from"./chunk-TAD43CG5.js";import{b as U}from"./chunk-EOSXQTSQ.js";import{a as j,b as K,c as V,d as Y,e as q}from"./chunk-SEU5V7I6.js";import{b as I}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as W}from"./chunk-M5OMEMQ3.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as O,e as G,f as X,g as Z,k as D}from"./chunk-2GMEK2W3.js";import"./chunk-J75M4LTW.js";import{a as n,e as B,f as ve,g as he,h as xe}from"./chunk-RRCPZMC2.js";var c=B(ve(),1);var ne=B(he(),1);var e=B(xe(),1);var ie=["read","insert","update","delete"],ye=n((a,t)=>({delete:a("Delete"),insert:a("Insert"),read:a("Read"),update:a("Update")})[t],"operationLabel"),ge=n(a=>{let t=new Set;for(let l of a?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:r}=l.metadata;typeof r=="string"&&r!==""&&t.add(r)}return t},"uncoveredTables"),be=n((a,t,l)=>{let r=new Map,s=n(o=>{let d=r.get(o);if(d!==void 0)return d;let i={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:[],table:o,uncovered:l.has(o)};return r.set(o,i),i},"ensure");for(let o of a)s(o.table).cells[o.on]={procedure:o.procedure};for(let o of t){let d=s(o.table);d.maskedColumns.includes(o.column)||d.maskedColumns.push(o.column)}for(let o of l)s(o);return[...r.values()].toSorted((o,d)=>o.table.localeCompare(d.table))},"buildRows"),Ne=n(a=>{let t=(0,ne.c)(17),l;t[0]!==a?(l=a===void 0?{}:a,t[0]=a,t[1]=l):l=t[1];let{onProbe:r}=l,s=O(),o,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(o={},d={live:!0},t[2]=o,t[3]=d):(o=t[2],d=t[3]);let i=U(L.rlsPolicies,o,d),x;t[4]===Symbol.for("react.memo_cache_sentinel")?(x={},t[4]=x):x=t[4];let p=U(L.maskPolicies,x),v;t[5]===Symbol.for("react.memo_cache_sentinel")?(v={},t[5]=v):v=t[5];let b=U(L.getAdvisories,v),N;if(t[6]!==b.data||t[7]!==p.data||t[8]!==r||t[9]!==i||t[10]!==s){let g=null;i.data!==void 0&&(g=Array.isArray(i.data.policies)?i.data.policies:[]);let _=Array.isArray(p.data?.columns)?p.data.columns:[],F=b.data??null,{error:h,errorSource:m,liveError:P}=i,A=g===null?[]:be(g,_,ge(F)),T;t[12]!==P?(T=(0,e.jsxDEV)("div",{className:"flex items-center justify-end",children:(0,e.jsxDEV)(le,{message:P,prefix:"pm"},void 0,!1)},void 0,!1),t[12]=P,t[13]=T):T=t[13];let y;t[14]!==h||t[15]!==m?(y=h!==null&&(0,e.jsxDEV)(te,{error:m,testId:"pm-error"},void 0,!1),t[14]=h,t[15]=m,t[16]=y):y=t[16],N=(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[T,y,g!==null&&A.length===0?(0,e.jsxDEV)(J,{description:s("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:s("No policy")},void 0,!1):(0,e.jsxDEV)(ae,{"data-testid":"pm-table",children:[(0,e.jsxDEV)(se,{children:(0,e.jsxDEV)(Q,{children:[(0,e.jsxDEV)($,{children:s("Table")},void 0,!1),ie.map(u=>(0,e.jsxDEV)($,{children:ye(s,u)},u,!1)),(0,e.jsxDEV)($,{children:s("Masked columns")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(oe,{children:A.map(u=>(0,e.jsxDEV)(Q,{"data-testid":`pm-row-${u.table}`,children:[(0,e.jsxDEV)(z,{className:"font-mono text-xs",children:(0,e.jsxDEV)("span",{className:"flex items-center gap-1.5",children:[u.table,u.uncovered&&(0,e.jsxDEV)(I,{"data-testid":`pm-uncovered-${u.table}`,title:s("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:s("Uncovered \u2014 reachable without a policy")},void 0,!1)]},void 0,!0)},void 0,!1),ie.map(w=>{let R=u.cells[w];return(0,e.jsxDEV)(z,{"data-testid":`pm-cell-${u.table}-${w}`,children:R.procedure===void 0?(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:s("No policy")},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-col gap-1",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Covered by {procedure}",{procedure:R.procedure})},void 0,!1),r!==void 0&&(0,e.jsxDEV)(k,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${u.table}-${w}`,onClick:n(()=>{r(u.table,w,R.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Probe this")},void 0,!1)]},void 0,!0)},w,!1)}),(0,e.jsxDEV)(z,{children:u.maskedColumns.length===0?(0,e.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,e.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:u.maskedColumns.map(ke)},void 0,!1)},void 0,!1)]},u.table,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),t[6]=b.data,t[7]=p.data,t[8]=r,t[9]=i,t[10]=s,t[11]=N}else N=t[11];return N},"PermissionsMatrix");function ke(a){return(0,e.jsxDEV)(I,{variant:"outline",children:a},a,!1)}n(ke,"_temp");var Ce=G(L.runAs),we=n(()=>{let a=W();return async({args:t,functionPath:l,shardKey:r="",userId:s})=>{let o=Ce;try{return{kind:"allowed",value:await a.query(o,{args:t,functionPath:l,userId:s},X(r))}}catch(d){return{kind:"denied",message:d instanceof Error?d.message:String(d)}}}},"useRunAsProbe"),Se=n(a=>a===void 0?"undefined":JSON.stringify(a,null,2),"formatValue"),Pe=n(({functions:a,prefill:t,runAsIdentity:l=!1}={})=>{let r=W(),s=O(),o=we(),[d,i]=(0,c.useState)(null),[x,p]=(0,c.useState)(null),v=a??d??[],[b,N]=(0,c.useState)(""),[g,_]=(0,c.useState)("{}"),[F,h]=(0,c.useState)(""),[m,P]=(0,c.useState)(""),[A,T]=(0,c.useState)(!1),[y,u]=(0,c.useState)(null),[w,R]=(0,c.useState)(null),H=(0,c.useRef)(-1);(0,c.useEffect)(()=>{if(a!==void 0)return;let f=!1;return r.listFunctions().then(S=>(f||i(S),S)).catch(S=>{f||p(Z(S))}),()=>{f=!0}},[r,a]),(0,c.useEffect)(()=>{if(t===void 0||H.current===t.nonce)return;H.current=t.nonce;let f=t.functionPath;queueMicrotask(()=>{N(f),u(null)})},[t]);let M=b===""?v[0]?.path??"":b,ce=n(async()=>{if(M==="")return;let f;try{f=g.trim()===""?{}:JSON.parse(g)}catch(S){R(s("Invalid JSON args: {message}",{message:S.message})),u(null);return}R(null),T(!0);try{let S=await o({args:f,functionPath:M,shardKey:F.trim(),userId:m.trim()});u(S)}finally{T(!1)}},"run"),fe=n(()=>{D(ce())},"runOnce"),ue=n(f=>{N(f.target.value)},"onSelectChange"),me=n(f=>{_(f.target.value)},"onArgsChange"),pe=n(f=>{P(f.target.value)},"onUserIdChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[x!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:x},void 0,!1),!l&&(0,e.jsxDEV)(J,{description:s("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:s("Set `runAsIdentity` to forge an identity and probe access.")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-function",children:s("Function")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":s("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:ue,value:M,children:v.map(f=>(0,e.jsxDEV)("option",{value:f.path,children:[f.path," (",f.kind,")"]},f.path,!0))},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-args",children:s("Arguments")},void 0,!1),(0,e.jsxDEV)(re,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:me,value:g},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(ee,{onChange:h,testId:"pp-shard",value:F},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(C,{htmlFor:"pp-user",children:s("Run as (userId)")},void 0,!1),(0,e.jsxDEV)(E,{"aria-label":s("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:pe,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"pp-run",disabled:!l||A||M==="",onClick:fe,type:"button",children:s(A?"Probing\u2026":"Run probe")},void 0,!1),m.trim()!==""&&(0,e.jsxDEV)(I,{"data-testid":"pp-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),w!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:w},void 0,!1),y!==null&&y.kind==="allowed"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,e.jsxDEV)(I,{variant:"secondary",children:s("Allowed")},void 0,!1),(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Se(y.value)},void 0,!1)]},void 0,!0),y!==null&&y.kind==="denied"&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,e.jsxDEV)(I,{variant:"destructive",children:s("Denied")},void 0,!1),(0,e.jsxDEV)("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:y.message},void 0,!1)]},void 0,!0)]},void 0,!0)},"PermissionsPlayground"),Ae="/__lunora/policy-scaffold",Te={"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."},Ie=n(async a=>{let t=await fetch(Ae,{body:JSON.stringify(a),headers:{"Content-Type":"application/json"},method:"POST"}),l=await t.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(t.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let r=l.error;return{kind:"error",message:r===void 0?`policy scaffold failed (${String(t.status)})`:Te[r]??r}},"applyPolicyScaffold"),de={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ee=n(()=>{let a=O(),[t,l]=(0,c.useState)(null),[r,s]=(0,c.useState)(!1),[o,d]=(0,c.useState)(null),[i,x]=(0,c.useState)(de),p=n(h=>{let m=h.target.name,{value:P}=h.target;x(A=>({...A,[m]:P}))},"onFieldChange"),v=n(()=>{l(null),x(de)},"reset"),b=n(async h=>{s(!0),d(null);try{let m=await Ie(h);d(m),m.kind==="ok"&&v()}catch(m){d({kind:"error",message:m instanceof Error?m.message:String(m)})}finally{s(!1)}},"submit"),N=n(()=>{D(b({kind:"scaffoldPolicy",name:i.policyName.trim(),table:i.tableName.trim()}))},"onSubmitScaffold"),g=n(()=>{D(b({exportName:i.exportName.trim(),filePath:i.filePath.trim(),kind:"wireRls",policies:i.policies.trim()}))},"onSubmitWire"),_=n(()=>{d(null),l("scaffold")},"openScaffold"),F=n(()=>{d(null),l("wire")},"openWire");return(0,e.jsxDEV)(j,{"data-testid":"policy-scaffolder",size:"sm",children:[(0,e.jsxDEV)(K,{children:[(0,e.jsxDEV)(V,{children:a("Scaffold access rules")},void 0,!1),(0,e.jsxDEV)(Y,{children:a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(q,{children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-new",onClick:_,size:"xs",type:"button",variant:t==="scaffold"?"default":"outline",children:a("New policy file")},void 0,!1),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-wire",onClick:F,size:"xs",type:"button",variant:t==="wire"?"default":"outline",children:a("Wire into a procedure")},void 0,!1)]},void 0,!0),t==="scaffold"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-name",children:a("Policy name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:p,value:i.policyName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-table",children:a("Table name")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:p,value:i.tableName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-create",disabled:r||i.policyName.trim()===""||i.tableName.trim()==="",onClick:N,size:"xs",type:"button",children:a(r?"Creating\u2026":"Create policy file")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),t==="wire"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:p,value:i.filePath},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:p,value:i.exportName},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,e.jsxDEV)(C,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")},void 0,!1),(0,e.jsxDEV)(E,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:p,value:i.policies},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(k,{"data-testid":"policy-scaffolder-apply",disabled:r||i.filePath.trim()===""||i.exportName.trim()===""||i.policies.trim()==="",onClick:g,size:"xs",type:"button",children:a(r?"Wiring\u2026":"Wire RLS")},void 0,!1),(0,e.jsxDEV)(k,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0),o?.kind==="error"&&(0,e.jsxDEV)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message},void 0,!1),o?.kind==="needs-manual-edit"&&(0,e.jsxDEV)("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.")},void 0,!1),o?.kind==="ok"&&(0,e.jsxDEV)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,e.jsxDEV)("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})},void 0,!1),o.diagnostics.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(h=>(0,e.jsxDEV)("li",{className:"font-mono text-[11px] text-destructive",children:h},h,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"PolicyScaffolder"),He=n(({functions:a,runAsIdentity:t=!1,schemaEditable:l=!1}={})=>{let r=O(),[s,o]=(0,c.useState)(void 0),d=n((i,x,p)=>{p!==""&&o(v=>({functionPath:p,nonce:(v?.nonce??0)+1}))},"onProbe");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Permissions")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(Ne,{onProbe:d},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("section",{className:"flex flex-col gap-3",children:(0,e.jsxDEV)(j,{className:"gap-0 py-0",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Probe")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(q,{className:"px-4 py-4",children:[(0,e.jsxDEV)("p",{className:"mb-3 text-sm text-muted-foreground",children:r("Pick a function and an identity, then run it to see the access outcome.")},void 0,!1),(0,e.jsxDEV)(Pe,{functions:a,prefill:s,runAsIdentity:t},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1),l&&(0,e.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,e.jsxDEV)(Ee,{},void 0,!1)},void 0,!1)]},void 0,!0)},"PermissionsPanel");export{He as PermissionsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as x}from"./chunk-TBMYIZIO.js";import{R as k}from"./chunk-3CJW6NWG.js";import{d as b}from"./chunk-
|
|
1
|
+
import{a as x}from"./chunk-TBMYIZIO.js";import{R as k}from"./chunk-3CJW6NWG.js";import{d as b}from"./chunk-2GMEK2W3.js";import{a as c,e as C,f as $,g as j,h as w}from"./chunk-RRCPZMC2.js";var y=C(j(),1),u=C($(),1);var e=C(w(),1);var T=c(r=>{let t=(0,y.c)(21),{id:h,onChange:g,testId:o,value:v}=r,l=b(),f=(0,u.useId)(),[d]=(0,u.useState)(D),m;t[0]!==g?(m=c(_=>{g(_.target.value)},"t1"),t[0]=g,t[1]=m):m=t[1];let I=m,a;t[2]!==l?(a=l("Shard key"),t[2]=l,t[3]=a):a=t[3];let S=d.length>0?f:void 0,n;t[4]!==l?(n=l("shard key (optional)"),t[4]=l,t[5]=n):n=t[5];let s;t[6]!==h||t[7]!==I||t[8]!==a||t[9]!==S||t[10]!==n||t[11]!==o||t[12]!==v?(s=(0,e.jsxDEV)(k,{"aria-label":a,className:"h-8 w-48","data-testid":o,id:h,list:S,onChange:I,placeholder:n,value:v},void 0,!1),t[6]=h,t[7]=I,t[8]=a,t[9]=S,t[10]=n,t[11]=o,t[12]=v,t[13]=s):s=t[13];let i;t[14]!==f||t[15]!==d||t[16]!==o?(i=d.length>0&&(0,e.jsxDEV)("datalist",{"data-testid":`${o}-recents`,id:f,children:d.map(E)},void 0,!1),t[14]=f,t[15]=d,t[16]=o,t[17]=i):i=t[17];let p;return t[18]!==s||t[19]!==i?(p=(0,e.jsxDEV)(e.Fragment,{children:[s,i]},void 0,!0),t[18]=s,t[19]=i,t[20]=p):p=t[20],p},"ShardInput");function D(){return x()}c(D,"_temp");function E(r){return(0,e.jsxDEV)("option",{"aria-label":r,value:r},r,!1)}c(E,"_temp2");export{T as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as k,b as j}from"./chunk-KJJ3WM6H.js";import{a as D}from"./chunk-
|
|
1
|
+
import{a as k,b as j}from"./chunk-KJJ3WM6H.js";import{a as D}from"./chunk-WKWKAU22.js";import{a as O}from"./chunk-2K47A3P6.js";import{a as V}from"./chunk-JEVKZIHN.js";import"./chunk-XNJNSCLM.js";import{a as _,b as z,c as B,d as f,e as l,f as n}from"./chunk-GTM65MVX.js";import{a as M}from"./chunk-ATG3655M.js";import"./chunk-TBMYIZIO.js";import{R as L}from"./chunk-3CJW6NWG.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as H}from"./chunk-BOXSWNXZ.js";import{a as I}from"./chunk-TAD43CG5.js";import{b as A}from"./chunk-EOSXQTSQ.js";import{a as y,e as E}from"./chunk-SEU5V7I6.js";import{b as T}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-M5OMEMQ3.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as C,o as R}from"./chunk-2GMEK2W3.js";import"./chunk-J75M4LTW.js";import{a as i,e as w,f as ee,h as te}from"./chunk-RRCPZMC2.js";var o=w(ee(),1);var e=w(te(),1);var K=80,ae=i(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>K?`${t.slice(0,K)}\u2026`:t},"formatDetail"),re=41,F=480,U=5,oe=i((s,t)=>k(s,d=>{t(d.height>0?d:{height:F,width:d.width})}),"observeViewportRect"),Se=i(({initialShardKey:s})=>{let t=C(),[d,G]=(0,o.useState)(s??""),[m,W]=(0,o.useState)(""),q=O(d.trim(),400),{data:v,error:p,errorSource:J,isLoading:P,liveError:Q}=A(H.getAuditLog,{},{live:!0,shardKey:q}),u=(0,o.useMemo)(()=>v?.entries??[],[v]),c=(0,o.useMemo)(()=>{let r=m.trim().toLowerCase();return r===""?u:u.filter(a=>a.op.toLowerCase().includes(r)||(a.table??"").toLowerCase().includes(r)||(a.id??"").toLowerCase().includes(r))},[u,m]),g=(0,o.useRef)(null),x=j({count:c.length,estimateSize:i(()=>re,"estimateSize"),getScrollElement:i(()=>g.current,"getScrollElement"),initialRect:{height:F,width:800},observeElementRect:oe,overscan:8}),h=x.getVirtualItems(),X=x.getTotalSize(),S=h[0]?.start??0,b=X-(h.at(-1)?.end??0),Z={height:S},$={height:b},Y=i(r=>{W(r.target.value)},"onSearchChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(M,{onChange:G,testId:"au-shard-input",value:d},void 0,!1),(0,e.jsxDEV)(D,{message:Q,prefix:"au"},void 0,!1),(0,e.jsxDEV)(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:m},void 0,!1)]},void 0,!0),p!==null&&(0,e.jsxDEV)(V,{error:J,testId:"au-error"},void 0,!1),p===null&&!P&&c.length===0&&(0,e.jsxDEV)(I,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsxDEV)("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"},void 0,!1)},void 0,!1),testId:"au-empty",title:t("No audit entries.")},void 0,!1),c.length>0&&(0,e.jsxDEV)(y,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:g,children:(0,e.jsxDEV)(_,{"data-testid":"au-table",children:[(0,e.jsxDEV)(z,{children:(0,e.jsxDEV)(f,{children:[(0,e.jsxDEV)(l,{children:t("time")},void 0,!1),(0,e.jsxDEV)(l,{children:t("op")},void 0,!1),(0,e.jsxDEV)(l,{children:t("table")},void 0,!1),(0,e.jsxDEV)(l,{children:t("id")},void 0,!1),(0,e.jsxDEV)(l,{children:t("detail")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(B,{children:[S>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:U,style:Z},void 0,!1)},void 0,!1),h.map(r=>{let a=c[r.index],N=ae(a.detail);return(0,e.jsxDEV)(f,{"data-testid":"au-row",children:[(0,e.jsxDEV)(n,{className:"text-muted-foreground tabular-nums",children:R(a.ts,"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{children:(0,e.jsxDEV)(T,{variant:"secondary",children:a.op},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"font-medium",children:a.table??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:a.id??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:N||void 0,children:N||(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},a.seq,!0)}),b>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:U,style:$},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)},"AuditPanel");export{Se as AuditPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as q,b as B,c as V,d as p,e as d,f as n}from"./chunk-GTM65MVX.js";import{R as $}from"./chunk-3CJW6NWG.js";import{c as A}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as H}from"./chunk-TAD43CG5.js";import{a as S,e as k}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import{f as F}from"./chunk-
|
|
1
|
+
import{a as q,b as B,c as V,d as p,e as d,f as n}from"./chunk-GTM65MVX.js";import{R as $}from"./chunk-3CJW6NWG.js";import{c as A}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as H}from"./chunk-TAD43CG5.js";import{a as S,e as k}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import{f as F}from"./chunk-M5OMEMQ3.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Q,g as E,j as K,k as I}from"./chunk-2GMEK2W3.js";import"./chunk-J75M4LTW.js";import{a as f,e as C,f as Z,g as G,h as J}from"./chunk-RRCPZMC2.js";var z=C(G(),1);var s=C(Z(),1);var e=C(J(),1);var X=10,g=f(x=>{let l=(0,z.c)(7),{label:m,value:a}=x,r;l[0]!==m?(r=(0,e.jsxDEV)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m},void 0,!1),l[0]=m,l[1]=r):r=l[1];let v=a??"\u2014",o;l[2]!==v?(o=(0,e.jsxDEV)("span",{className:"font-mono text-sm",children:v},void 0,!1),l[2]=v,l[3]=o):o=l[3];let u;return l[4]!==r||l[5]!==o?(u=(0,e.jsxDEV)("div",{className:"flex flex-col gap-0.5",children:[r,o]},void 0,!0),l[4]=r,l[5]=o,l[6]=u):u=l[6],u},"Detail"),oe=f(({loadIndexes:x,runQuery:l}={})=>{let m=F(),a=Q(),[r,v]=(0,s.useState)(null),[o,u]=(0,s.useState)(null),[b,L]=(0,s.useState)(null),[N,O]=(0,s.useState)(""),[h,y]=(0,s.useState)(null),[M,w]=(0,s.useState)(null),[j,D]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let t={cancelled:!1};return I((async()=>{try{let c=await(x??(()=>m.listVectorIndexes()))();t.cancelled||(v(c),u(null),L(T=>T??c[0]?.name??null))}catch(c){t.cancelled||(v(null),u(E(c)))}})()),()=>{t.cancelled=!0}},[m,x]);let i=r?.find(t=>t.name===b)??null,P=f(t=>{L(t.currentTarget.dataset.index??null),y(null),w(null)},"onSelect"),R=f(t=>{O(t.target.value)},"onQueryTextChange"),U=f(async()=>{let t=N.trim();if(!(b===null||t==="")){D(!0),w(null);try{let c=await(l??(T=>m.queryVectorIndex(T)))({name:b,text:t,topK:X});y(c)}catch(c){y(null),w(E(c))}finally{D(!1)}}},"search"),W=f(()=>{I(U())},"onSearch");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[o!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:o},void 0,!1),r!==null&&r.length===0&&(0,e.jsxDEV)(H,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsxDEV)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"},void 0,!1)},void 0,!1),testId:"vector-empty",title:a("No vector indexes.")},void 0,!1),r!==null&&r.length>0&&(0,e.jsxDEV)(S,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(k,{className:"px-0",children:(0,e.jsxDEV)(q,{"data-testid":"vector-table",children:[(0,e.jsxDEV)(B,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(d,{children:a("name")},void 0,!1),(0,e.jsxDEV)(d,{children:a("table")},void 0,!1),(0,e.jsxDEV)(d,{children:a("dimensions")},void 0,!1),(0,e.jsxDEV)(d,{children:a("metric")},void 0,!1),(0,e.jsxDEV)(d,{children:a("vectors")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(V,{children:r.map(t=>(0,e.jsxDEV)(p,{className:t.name===b?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:P,children:[(0,e.jsxDEV)(n,{className:"font-mono text-xs",children:t.name},void 0,!1),(0,e.jsxDEV)(n,{className:"font-mono text-xs",children:t.table},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums",children:t.dimensions??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{children:t.metric??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums",children:t.vectorsCount??"\u2014"},void 0,!1)]},t.name,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),i!==null&&(0,e.jsxDEV)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxDEV)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsxDEV)(g,{label:a("field"),value:i.field},void 0,!1),(0,e.jsxDEV)(g,{label:a("dimensions"),value:i.dimensions},void 0,!1),(0,e.jsxDEV)(g,{label:a("metric"),value:i.metric},void 0,!1),(0,e.jsxDEV)(g,{label:a("vectors"),value:i.vectorsCount},void 0,!1)]},void 0,!0),i.metadata!==void 0&&i.metadata.length>0&&(0,e.jsxDEV)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsxDEV)("span",{className:"font-mono",children:i.metadata.join(", ")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)($,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:R,placeholder:a("Search by similarity\u2026"),value:N},void 0,!1),(0,e.jsxDEV)(A,{"data-testid":"vector-search",disabled:j||N.trim()==="",onClick:W,children:a(j?"Searching\u2026":"Search")},void 0,!1)]},void 0,!0),M!==null&&(0,e.jsxDEV)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M},void 0,!1),h!==null&&h.length===0&&(0,e.jsxDEV)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")},void 0,!1),h!==null&&h.length>0&&(0,e.jsxDEV)(S,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsxDEV)(k,{className:"px-0",children:(0,e.jsxDEV)(q,{"data-testid":"vector-matches",children:[(0,e.jsxDEV)(B,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(d,{children:a("id")},void 0,!1),(0,e.jsxDEV)(d,{children:a("score")},void 0,!1),(0,e.jsxDEV)(d,{children:a("metadata")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(V,{children:h.map(t=>(0,e.jsxDEV)(p,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsxDEV)(n,{className:"font-mono text-xs",children:t.id},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums",children:t.score.toFixed(4)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":K(t.metadata)},void 0,!1)]},t.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"VectorBrowser");export{oe as VectorBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as $}from"./chunk-
|
|
1
|
+
import{a as $}from"./chunk-WKWKAU22.js";import{a as W}from"./chunk-KMNEQEHM.js";import{a as _}from"./chunk-2K47A3P6.js";import{a as q}from"./chunk-JEVKZIHN.js";import"./chunk-XNJNSCLM.js";import{a as G,b as P,c as V,d as b,e as i,f as o}from"./chunk-GTM65MVX.js";import{a as y}from"./chunk-JSEXCW5Q.js";import{a as U}from"./chunk-ATG3655M.js";import{b as Q}from"./chunk-TBMYIZIO.js";import{R as w}from"./chunk-3CJW6NWG.js";import{c as L}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as g}from"./chunk-BOXSWNXZ.js";import{a as A}from"./chunk-TAD43CG5.js";import{b as H}from"./chunk-EOSXQTSQ.js";import{a as k,e as B}from"./chunk-SEU5V7I6.js";import{b as T}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as M}from"./chunk-M5OMEMQ3.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as S,e as F,f as K,g as O,k as j,o as z}from"./chunk-2GMEK2W3.js";import"./chunk-J75M4LTW.js";import{a as n,e as D,f as le,h as ce}from"./chunk-RRCPZMC2.js";var a=D(le(),1);var e=D(ce(),1);var ue=F(g.runMigration),we=n(({initialShardKey:J})=>{let X=M(),r=S(),[c,Y]=(0,a.useState)(J??""),[x,Z]=(0,a.useState)(""),[R,ee]=(0,a.useState)("up"),[f,re]=(0,a.useState)(!0),[u,N]=(0,a.useState)(!1),[d,h]=(0,a.useState)(null),[C,p]=(0,a.useState)(null),m=_(c.trim(),400),I=c.trim()===m,s=H(g.migrationStatus,{},{live:!0,shardKey:m}),l=s.data?.migrations??null,te=s.error,{errorSource:ae,liveError:ie}=s;(0,a.useEffect)(()=>{s.data!==void 0&&Q(m)},[s.data,m]);let oe=n(async()=>{let t=x.trim();if(t===""){p(r("Enter a migration id")),h(null);return}N(!0),p(null);try{let v=await X.query(ue,{direction:R,dryRun:f,id:t},K(c));h(v),s.refetch()}catch(v){h(null),p(O(v))}finally{N(!1)}},"run"),E=n(()=>{j(oe())},"runMigration"),ne=n(t=>{Z(t.target.value)},"onIdChange"),se=n(t=>{ee(t.target.value==="down"?"down":"up")},"onDirectionChange"),de=n(t=>{re(t.target.checked)},"onDryRunChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-migrations",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(U,{onChange:Y,testId:"mg-shard-input",value:c},void 0,!1),(0,e.jsxDEV)($,{message:ie,prefix:"mg"},void 0,!1)]},void 0,!0),te!==null&&(0,e.jsxDEV)(q,{error:ae,testId:"mg-status-error"},void 0,!1),l!==null&&l.length===0&&(0,e.jsxDEV)(A,{description:r("Data migrations you run against this shard will be tracked here."),icon:(0,e.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsxDEV)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"},void 0,!1)},void 0,!1),testId:"mg-empty",title:r("No migrations have run on this shard.")},void 0,!1),l!==null&&l.length>0&&(0,e.jsxDEV)(k,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(B,{className:"px-0",children:(0,e.jsxDEV)(G,{"data-testid":"mg-table",children:[(0,e.jsxDEV)(P,{children:(0,e.jsxDEV)(b,{children:[(0,e.jsxDEV)(i,{children:r("id")},void 0,!1),(0,e.jsxDEV)(i,{children:r("direction")},void 0,!1),(0,e.jsxDEV)(i,{children:r("status")},void 0,!1),(0,e.jsxDEV)(i,{children:r("processed")},void 0,!1),(0,e.jsxDEV)(i,{children:r("changed")},void 0,!1),(0,e.jsxDEV)(i,{children:r("updated")},void 0,!1),(0,e.jsxDEV)(i,{children:r("error")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(V,{children:l.map(t=>(0,e.jsxDEV)(b,{"data-testid":`mg-row-${t.id}`,children:[(0,e.jsxDEV)(o,{children:t.id},void 0,!1),(0,e.jsxDEV)(o,{children:t.direction},void 0,!1),(0,e.jsxDEV)(o,{children:(0,e.jsxDEV)(T,{variant:"secondary",children:t.status},void 0,!1)},void 0,!1),(0,e.jsxDEV)(o,{children:t.processed},void 0,!1),(0,e.jsxDEV)(o,{children:t.changed},void 0,!1),(0,e.jsxDEV)(o,{children:z(t.updatedAt)},void 0,!1),(0,e.jsxDEV)(o,{children:t.error??""},void 0,!1)]},t.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsxDEV)(y,{children:r("Run migration")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(w,{"aria-label":r("Migration id"),className:"w-auto","data-testid":"mg-id-input",onChange:ne,placeholder:r("migration id"),value:x},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":r("Direction"),className:"flex h-9 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"mg-direction",onChange:se,value:R,children:[(0,e.jsxDEV)("option",{value:"up",children:r("up")},void 0,!1),(0,e.jsxDEV)("option",{value:"down",children:r("down")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(y,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[(0,e.jsxDEV)("input",{checked:f,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:de,type:"checkbox"},void 0,!1),r("Dry run")]},void 0,!0),f?(0,e.jsxDEV)(L,{"data-testid":"mg-run",disabled:u||!I,onClick:E,size:"sm",type:"button",children:r(u?"Running\u2026":"Run")},void 0,!1):(0,e.jsxDEV)(W,{confirmLabel:r(u?"Running\u2026":"Run migration?"),disabled:u||!I,onConfirm:E,testId:"mg-run",children:r("Run")},void 0,!1)]},void 0,!0)]},void 0,!0),C!==null&&(0,e.jsxDEV)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:C},void 0,!1),d!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[d.dryRun?r("Dry run: "):"",r("{status} \u2014 processed",{status:d.status}),d.processed,r(", changed"),d.changed]},void 0,!0)]},void 0,!0)},"MigrationsPanel");export{we as MigrationsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as le}from"./chunk-
|
|
1
|
+
import{a as le}from"./chunk-WKWKAU22.js";import{a as Y}from"./chunk-2K47A3P6.js";import{a as Z}from"./chunk-JEVKZIHN.js";import"./chunk-XNJNSCLM.js";import{a as ee,b as te,c as re,d as j,e as o,f as i}from"./chunk-GTM65MVX.js";import{a as X}from"./chunk-ATG3655M.js";import"./chunk-TBMYIZIO.js";import"./chunk-3CJW6NWG.js";import{c as V}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as J}from"./chunk-BOXSWNXZ.js";import{a as U}from"./chunk-TAD43CG5.js";import{b as G}from"./chunk-EOSXQTSQ.js";import{a as z,e as Q}from"./chunk-SEU5V7I6.js";import{b as O}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-M5OMEMQ3.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as H,o as W}from"./chunk-2GMEK2W3.js";import"./chunk-J75M4LTW.js";import{a,e as L,f as fe,g as me,h as ue,j as P}from"./chunk-RRCPZMC2.js";var ae=L(me(),1),q=L(fe(),1);var t=L(ue(),1);var he={action:"outline",mutation:"default",query:"secondary"},se=a(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"formatMs"),ve=a(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"errorCell"),pe=a(r=>{let e=r.conflicts??0;return r.calls===0?"\u2014":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},"conflictCell"),xe={calls:a((r,e)=>e.calls-r.calls,"calls"),recent:a((r,e)=>e.lastCalledAt-r.lastCalledAt,"recent"),slowest:a((r,e)=>e.maxDurationMs-r.maxDurationMs,"slowest")},Ie=a(r=>{let e=(0,ae.c)(47),{functions:I,initialShardKey:oe}=r,s=H(),[n,ie]=(0,q.useState)(oe??""),[d,ne]=(0,q.useState)("recent"),C;e[0]!==n?(C=n.trim(),e[0]=n,e[1]=C):C=e[1];let F=Y(C,400),M;e[2]===Symbol.for("react.memo_cache_sentinel")?(M={},e[2]=M):M=e[2];let T;e[3]!==F?(T={live:!0,shardKey:F},e[3]=F,e[4]=T):T=e[4];let{data:de,error:c,errorSource:N,liveError:b}=G(J.getFunctionStats,M,T),S=de?.functions??null,w;e[5]!==I?(w=new Map((I??[]).map(ge)),e[5]=I,e[6]=w):w=e[6];let K=w,E;e[7]===Symbol.for("react.memo_cache_sentinel")?(E=a(k=>{ne(k.currentTarget.dataset.sort)},"t5"),e[7]=E):E=e[7];let ce=E,$;if(e[8]!==c||e[9]!==N||e[10]!==K||e[11]!==b||e[12]!==n||e[13]!==d||e[14]!==S||e[15]!==s){let k=S===null?[]:S.toSorted(xe[d]),f;e[17]!==s?(f=s("Recent"),e[17]=s,e[18]=f):f=e[18];let m;e[19]!==f?(m={key:"recent",label:f},e[19]=f,e[20]=m):m=e[20];let u;e[21]!==s?(u=s("Most called"),e[21]=s,e[22]=u):u=e[22];let h;e[23]!==u?(h={key:"calls",label:u},e[23]=u,e[24]=h):h=e[24];let v;e[25]!==s?(v=s("Slowest"),e[25]=s,e[26]=v):v=e[26];let p;e[27]!==v?(p={key:"slowest",label:v},e[27]=v,e[28]=p):p=e[28];let A;e[29]!==h||e[30]!==p||e[31]!==m?(A=[m,h,p],e[29]=h,e[30]=p,e[31]=m,e[32]=A):A=e[32];let _=A,x;e[33]!==n?(x=(0,t.jsxDEV)(X,{onChange:ie,testId:"fs-shard-input",value:n},void 0,!1),e[33]=n,e[34]=x):x=e[34];let g;e[35]!==b?(g=(0,t.jsxDEV)(le,{message:b,prefix:"fs"},void 0,!1),e[35]=b,e[36]=g):g=e[36];let y;e[37]!==_||e[38]!==d?(y=(0,t.jsxDEV)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:_.map(l=>(0,t.jsxDEV)(V,{"data-sort":l.key,"data-testid":`fs-sort-${l.key}`,onClick:ce,size:"sm",type:"button",variant:d===l.key?"secondary":"ghost",children:l.label},l.key,!1))},void 0,!1),e[37]=_,e[38]=d,e[39]=y):y=e[39];let B;e[40]!==x||e[41]!==g||e[42]!==y?(B=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[x,g,y]},void 0,!0),e[40]=x,e[41]=g,e[42]=y,e[43]=B):B=e[43];let D;e[44]!==c||e[45]!==N?(D=c!==null&&(0,t.jsxDEV)(Z,{error:N,testId:"fs-error"},void 0,!1),e[44]=c,e[45]=N,e[46]=D):D=e[46],$=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[B,D,S!==null&&k.length===0&&c===null&&(0,t.jsxDEV)(U,{description:s("Per-function call counts, error rates, and latency land here after your first request."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsxDEV)("path",{d:"M3 3v18h18"},void 0,!1),(0,t.jsxDEV)("path",{d:"M7 14l4-4 3 3 5-6"},void 0,!1)]},void 0,!0),testId:"fs-empty",title:s("No functions have run on this shard yet.")},void 0,!1),k.length>0&&(0,t.jsxDEV)(z,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Q,{className:"px-0",children:(0,t.jsxDEV)(ee,{"data-testid":"fs-table",children:[(0,t.jsxDEV)(te,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(o,{children:s("function")},void 0,!1),(0,t.jsxDEV)(o,{children:s("kind")},void 0,!1),(0,t.jsxDEV)(o,{className:"text-right",children:s("calls")},void 0,!1),(0,t.jsxDEV)(o,{className:"text-right",children:s("errors")},void 0,!1),(0,t.jsxDEV)(o,{className:"text-right",children:s("conflicts")},void 0,!1),(0,t.jsxDEV)(o,{className:"text-right",children:s("avg")},void 0,!1),(0,t.jsxDEV)(o,{className:"text-right",children:s("max")},void 0,!1),(0,t.jsxDEV)(o,{children:s("last run")},void 0,!1),(0,t.jsxDEV)(o,{children:s("last error")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(re,{children:k.map(l=>{let R=K.get(l.path);return(0,t.jsxDEV)(j,{"data-testid":`fs-row-${l.path}`,children:[(0,t.jsxDEV)(i,{className:"font-medium",children:l.path},void 0,!1),(0,t.jsxDEV)(i,{children:R===void 0?(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,t.jsxDEV)(O,{variant:he[R],children:R},void 0,!1)},void 0,!1),(0,t.jsxDEV)(i,{className:"text-right tabular-nums",children:l.calls},void 0,!1),(0,t.jsxDEV)(i,{className:P("text-right tabular-nums",l.errors>0&&"text-destructive"),children:ve(l)},void 0,!1),(0,t.jsxDEV)(i,{className:P("text-right tabular-nums",(l.conflicts??0)>0&&"text-warning"),children:pe(l)},void 0,!1),(0,t.jsxDEV)(i,{className:"text-right tabular-nums",children:l.calls===0?"\u2014":se(l.totalDurationMs/l.calls)},void 0,!1),(0,t.jsxDEV)(i,{className:"text-right tabular-nums",children:l.calls===0?"\u2014":se(l.maxDurationMs)},void 0,!1),(0,t.jsxDEV)(i,{className:"text-muted-foreground",children:W(l.lastCalledAt,"\u2014")},void 0,!1),(0,t.jsxDEV)(i,{className:"max-w-[24ch] truncate text-destructive",title:l.lastErrorMessage??void 0,children:l.lastErrorMessage??(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},l.path,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),e[8]=c,e[9]=N,e[10]=K,e[11]=b,e[12]=n,e[13]=d,e[14]=S,e[15]=s,e[16]=$}else $=e[16];return $},"FunctionStatsPanel");function ge(r){return[r.path,r.kind]}a(ge,"_temp");export{Ie as FunctionStatsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b,c as v,d as g,f as D}from"./chunk-
|
|
1
|
+
import{b,c as v,d as g,f as D}from"./chunk-M5OMEMQ3.js";import{e as y,f as p,g as P,k as O}from"./chunk-2GMEK2W3.js";import{a as n,e as Q,f as N,g as _}from"./chunk-RRCPZMC2.js";var E=Q(_(),1);var c=Q(N(),1);var C=n((e,r,o)=>["lunora-admin",e,r,o.trim()],"adminQueryKey"),h=1e3,S=25,q=new Map,k=n(e=>{let r=Date.now(),o=(q.get(e)??[]).filter(s=>r-s<h);o.push(r),q.set(e,o),o.length===S&&(console.error(`[lunora-studio] possible request loop: ${e} fired ${String(S)}\xD7 in <1s \u2014 a render/effect is re-issuing this read unbounded.`),console.trace("[lunora-studio] request-loop call site"))},"noteQueryFetch");function R(e,r,o={}){let{enabled:s=!0,keepPreviousData:a=!1,staleTime:i=0}=o,t=g({enabled:s,queryFn:n(()=>(k(JSON.stringify(e)),r()),"trackedQueryFunction"),placeholderData:a?b:void 0,queryKey:e,staleTime:i});return{data:t.data,error:t.error?P(t.error):t.error,errorSource:t.error??void 0,isLoading:t.isLoading,liveError:void 0,refetch:n(()=>{O(t.refetch())},"refetch")}}n(R,"useClientQuery");function K(e,r,o={}){let s=D(),a=v(),{enabled:i=!0,keepPreviousData:u=!1,live:t=!1,shardKey:l="",staleTime:I}=o,d=C(e,r,l),L=R(d,()=>s.query(y(e),r,p(l)),{enabled:i,keepPreviousData:u,staleTime:I??(t?Number.POSITIVE_INFINITY:0)}),[T,f]=(0,c.useState)(void 0),F=JSON.stringify(d);return(0,c.useEffect)(()=>{if(!(!i||!t))return f(void 0),s.subscribe(y(e),r,m=>{f(void 0),a.setQueryData(d,m)},{...p(l),onError:n(m=>{f(m.message)},"onError")})},[F,i,t]),{...L,liveError:i&&t?T:void 0}}n(K,"useAdminQuery");var M=n(()=>{let e=(0,E.c)(2),r=v(),o;return e[0]!==r?(o=n((s,a,i)=>{let u=a===void 0?["lunora-admin",s]:C(s,a,i??"");O(r.invalidateQueries({queryKey:u}))},"t0"),e[0]=r,e[1]=o):o=e[1],o},"useInvalidateAdmin");export{R as a,K as b,M as c};
|