@lunora/studio 1.0.0-alpha.83 → 1.0.0-alpha.85
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-PXYWCZ7T.js → chunk-22LOWEEC.js} +1 -1
- package/dist/standalone/{chunk-6VAKZALJ.js → chunk-232MBXB2.js} +1 -1
- package/dist/standalone/{chunk-GB6LP6UJ.js → chunk-2EJADIPC.js} +1 -1
- package/dist/standalone/{chunk-D2RKH6JK.js → chunk-2SC3EG5Y.js} +1 -1
- package/dist/standalone/{chunk-UDVB4URN.js → chunk-347H2BQO.js} +1 -1
- package/dist/standalone/{chunk-A3KUNMU6.js → chunk-4I2TBTZS.js} +1 -1
- package/dist/standalone/{chunk-B2H5DK55.js → chunk-52OYJHM7.js} +1 -1
- package/dist/standalone/{chunk-YTA2HGRD.js → chunk-5YADKLAQ.js} +1 -1
- package/dist/standalone/{chunk-C7EOC2WS.js → chunk-6IEBRNDW.js} +1 -1
- package/dist/standalone/{chunk-HEB6GQQ6.js → chunk-7AG3T4DK.js} +2 -2
- package/dist/standalone/{chunk-53WEPGUD.js → chunk-AHVDZWB3.js} +1 -1
- package/dist/standalone/{chunk-CU55Y5TV.js → chunk-AQKXMWNF.js} +1 -1
- package/dist/standalone/{chunk-LLF5KWDZ.js → chunk-BAAU4OTI.js} +1 -1
- package/dist/standalone/{chunk-Y7A5NCXT.js → chunk-D3FRQZ4X.js} +1 -1
- package/dist/standalone/{chunk-T242WITF.js → chunk-D67BVBQW.js} +1 -1
- package/dist/standalone/{chunk-WQVVA5NB.js → chunk-EDOMDMVI.js} +1 -1
- package/dist/standalone/{chunk-GM67EQJU.js → chunk-ENBTOX7N.js} +1 -1
- package/dist/standalone/{chunk-DOZAODYC.js → chunk-ESKVOZLC.js} +1 -1
- package/dist/standalone/{chunk-KAPSM6AI.js → chunk-ETZYJL7Z.js} +1 -1
- package/dist/standalone/{chunk-PD4LANXJ.js → chunk-FUBR2PAD.js} +1 -1
- package/dist/standalone/{chunk-GWQIPIYA.js → chunk-HJR42BJY.js} +1 -1
- package/dist/standalone/{chunk-SV52HB7D.js → chunk-JAT5ZBQK.js} +1 -1
- package/dist/standalone/{chunk-CGLS2ILT.js → chunk-JE3WK77V.js} +1 -1
- package/dist/standalone/{chunk-6QP5N57V.js → chunk-KNHWIHC7.js} +1 -1
- package/dist/standalone/{chunk-OE465DVY.js → chunk-LVJ5IHEU.js} +1 -1
- package/dist/standalone/{chunk-TQXZ7LG4.js → chunk-MBVSXVTV.js} +1 -1
- package/dist/standalone/{chunk-7YKWP4QK.js → chunk-MDHUWMFD.js} +1 -1
- package/dist/standalone/{chunk-WZ3B3MEV.js → chunk-MLULN4R2.js} +1 -1
- package/dist/standalone/{chunk-Y5Y7DHFW.js → chunk-MN64D74P.js} +1 -1
- package/dist/standalone/{chunk-ZHBIKP5G.js → chunk-MUGKOGZG.js} +1 -1
- package/dist/standalone/{chunk-HOR3JLUY.js → chunk-NPKNFZUW.js} +1 -1
- package/dist/standalone/{chunk-KXSSTTEY.js → chunk-OLM62NLS.js} +1 -1
- package/dist/standalone/{chunk-Q7O6B7WC.js → chunk-OOL3FV6A.js} +1 -1
- package/dist/standalone/{chunk-DGBJE7YF.js → chunk-OV63HVE4.js} +1 -1
- package/dist/standalone/{chunk-SDQBPFLO.js → chunk-PWTURL56.js} +1 -1
- package/dist/standalone/{chunk-GN567L2T.js → chunk-QFJRZR4U.js} +1 -1
- package/dist/standalone/{chunk-WJGOI3FZ.js → chunk-QI25LTPH.js} +1 -1
- package/dist/standalone/{chunk-TBRZQICB.js → chunk-QNRAMF4X.js} +1 -1
- package/dist/standalone/{chunk-AADILRJW.js → chunk-QNUWWC3N.js} +12 -12
- package/dist/standalone/{chunk-UETNCBWU.js → chunk-QS4IFAFJ.js} +1 -1
- package/dist/standalone/{chunk-ZK3XKFCI.js → chunk-QSFKPGK4.js} +1 -1
- package/dist/standalone/{chunk-GWHM4C4N.js → chunk-QZ6TCNWR.js} +1 -1
- package/dist/standalone/{chunk-VTLYN3CX.js → chunk-RC3H4OP3.js} +1 -1
- package/dist/standalone/{chunk-7ZUQE3KU.js → chunk-RFBU5RZI.js} +1 -1
- package/dist/standalone/{chunk-7L7FXGJU.js → chunk-S67SBGB3.js} +1 -1
- package/dist/standalone/{chunk-VC5SSRUP.js → chunk-SHD2IWQI.js} +1 -1
- package/dist/standalone/{chunk-NRCXRCJX.js → chunk-SKFZXESP.js} +1 -1
- package/dist/standalone/{chunk-KSRP7GZV.js → chunk-SPT3KPV7.js} +1 -1
- package/dist/standalone/{chunk-74DN6HIE.js → chunk-TIR6CWHO.js} +1 -1
- package/dist/standalone/{chunk-Q7QTRX2E.js → chunk-TO45V3L6.js} +1 -1
- package/dist/standalone/{chunk-HJD2YUQS.js → chunk-U44CWN7H.js} +1 -1
- package/dist/standalone/{chunk-VCXH5V3Z.js → chunk-U5IIRHZ6.js} +1 -1
- package/dist/standalone/{chunk-EN2QAEO4.js → chunk-UBR4KB6K.js} +1 -1
- package/dist/standalone/{chunk-ZI5ZVNIN.js → chunk-UOQ24BAY.js} +1 -1
- package/dist/standalone/{chunk-BDJCCVB6.js → chunk-VKEJTZY7.js} +1 -1
- package/dist/standalone/{chunk-RNL6BSFM.js → chunk-VORDESEQ.js} +1 -1
- package/dist/standalone/{chunk-XDAT7LHC.js → chunk-YGKR536O.js} +1 -1
- package/dist/standalone/{chunk-CU6SCYQ7.js → chunk-YNBIW2GN.js} +1 -1
- package/dist/standalone/{chunk-WDG4WFUV.js → chunk-YSMJN36P.js} +1 -1
- package/dist/standalone/{chunk-5SQRE3VR.js → chunk-ZOX6X2DL.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-54MMVNPT.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as B}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-54MMVNPT.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as B}from"./chunk-YGKR536O.js";import{f as O}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{a as W,b as q,c as E,d as S,e as r,f as s}from"./chunk-MIQTKZAR.js";import{a as A,e as L}from"./chunk-UZERI5YC.js";import{d as z}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as T,e as M,g as $,h as I}from"./chunk-3XIESWL4.js";var F=M($(),1);var n=M(I(),1);var J=2e3,Q=new Set(["open"]),re=T(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),K=O(),v;e[0]!==K||e[1]!==y?(v=T(()=>Promise.resolve(y?y():K.debug()),"S"),e[0]=K,e[1]=y,e[2]=v):v=e[2];let H=v,P=y?"injected":"live",b;e[3]!==P?(b=["lunora-studio","sync-client-debug",P],e[3]=P,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let _;return e[9]!==i||e[10]!==g?(_=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(j,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=_):_=e[11],_}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let R=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==R?(o=(0,n.jsx)(x,{variant:R,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=R,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(j,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(j,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ze}from"./chunk-YTA2HGRD.js";import{a as Me,b as Ve}from"./chunk-GMR677FL.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as _e}from"./chunk-5Y3QLNWX.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-4UOFSGUS.js";import{a as He}from"./chunk-X665E2HU.js";import{b as Xe}from"./chunk-GRL5MG3Z.js";import{e as Qe}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import{a as Ye}from"./chunk-LFKCLLPT.js";import{R as Ae}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as ge}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Fe}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as qe}from"./chunk-ERMTJYQF.js";import{f as Je}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as We}from"./chunk-XQCVZAGU.js";import{a as Oe,b as Pe,c as Ge,d as Le,e as Ke}from"./chunk-UZERI5YC.js";import{d as Ee,f as ze,g as $e,h as je,m as pe}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as r,e as De,f as nt,g as st,h as rt,j as Re}from"./chunk-3XIESWL4.js";var we=De(st(),1);var f=De(nt(),1);var t=De(rt(),1);var ot=ze(qe.listTables),it=ze(qe.listTableIndexes),dt=ze(qe.readTablePage),ct=ze(qe.describeTables),mt={},Be=[],ut=r(s=>{let e=(0,we.c)(75),{initialShardKey:u,initialTable:n}=s,l=Je(),[a,c]=(0,f.useState)("graph"),[i,d]=(0,f.useState)(u??""),[h,m]=(0,f.useState)(""),[o,p]=(0,f.useState)(null),[C,b]=(0,f.useState)(null),z;e[0]===Symbol.for("react.memo_cache_sentinel")?(z={},e[0]=z):z=e[0];let[_,ce]=(0,f.useState)(z),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let[O,$]=(0,f.useState)(v),[E,k]=(0,f.useState)(null),w;e[2]===Symbol.for("react.memo_cache_sentinel")?(w={},e[2]=w):w=e[2];let[I,P]=(0,f.useState)(w),B;e[3]===Symbol.for("react.memo_cache_sentinel")?(B={},e[3]=B):B=e[3];let[me,A]=(0,f.useState)(B),[y,xe]=(0,f.useState)(null),[G,ue]=(0,f.useState)(null),ee;e[4]===Symbol.for("react.memo_cache_sentinel")?(ee={},e[4]=ee):ee=e[4];let[J,Ne]=(0,f.useState)(ee),[Q,fe]=(0,f.useState)(null),W;e[5]!==l?(W=r(async g=>{b(null);try{let N=await l.query(ot,{},$e(g));Xe(g),p(N),ce({}),$({}),k(null),P(T=>Object.fromEntries(Object.entries(T).filter(F=>{let[S]=F;return S!==g}))),A(T=>Object.fromEntries(Object.entries(T).filter(F=>{let[S]=F;return S!==g})))}catch(N){let T=N;p(null),b(je(T))}},"Y"),e[5]=l,e[6]=W):W=e[6];let te=W,L;e[7]!==l?(L=r(async()=>{ue(null);try{xe(await l.listGlobalTables())}catch(g){let N=g;xe(null),ue(je(N))}},"L"),e[7]=l,e[8]=L):L=e[8];let le=L,ae;e[9]!==i?(ae=i.trim(),e[9]=i,e[10]=ae):ae=e[10];let he=Ye(ae,400),K,ne;e[11]!==he||e[12]!==te||e[13]!==le?(ne=r(()=>{pe(te(he)),pe(le())},"ne"),K=[te,le,he],e[11]=he,e[12]=te,e[13]=le,e[14]=K,e[15]=ne):(K=e[14],ne=e[15]),(0,f.useEffect)(ne,K);let M;e[16]!==l||e[17]!==_||e[18]!==E||e[19]!==i?(M=r(async g=>{if(E===g){k(null);return}k(g);let N=`${i}:${g}`;if(_[N]!==void 0)return;let[T,F]=await Promise.allSettled([l.query(dt,{limit:1,offset:0,table:g},$e(i)),l.query(it,{table:g},$e(i))]);T.status==="fulfilled"?ce(S=>({...S,[N]:T.value.columns})):b(je(T.reason)),F.status==="fulfilled"&&$(S=>({...S,[N]:F.value.indexes}))},"M"),e[16]=l,e[17]=_,e[18]=E,e[19]=i,e[20]=M):M=e[20];let se=M,re;e[21]!==l||e[22]!==J||e[23]!==Q?(re=r(async g=>{if(Q===g){fe(null);return}if(fe(g),J[g]===void 0)try{let N=await l.readGlobalTablePage({limit:1,offset:0,table:g});Ne(T=>({...T,[g]:N.columns}))}catch(N){ue(je(N))}},"re"),e[21]=l,e[22]=J,e[23]=Q,e[24]=re):re=e[24];let be=re,X=(0,f.useRef)(void 0),H,D;e[25]!==n||e[26]!==o||e[27]!==se?(H=r(()=>{n===void 0||o===null||X.current===n||o.some(g=>g.name===n)&&(X.current=n,pe(se(n)))},"J"),D=[n,o,se],e[25]=n,e[26]=o,e[27]=se,e[28]=H,e[29]=D):(H=e[28],D=e[29]),(0,f.useEffect)(H,D);let oe;e[30]!==l?(oe=r(async(g,N,T)=>{let[F,S]=await Promise.all([Promise.allSettled([l.query(ct,{tables:[...N,...T]},$e(g))]),Promise.all(T.map(async U=>{let Te=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:U})]),Ue=Te[0].status==="fulfilled"?Te[0].value:void 0;return{columns:Ue?.columns??[],refs:Ue?.refs??{},table:U}}))]),ke=F[0].status==="fulfilled"?F[0].value?.columnsByTable??{}:{},Se=F[0].status==="rejected",Ie=new Map(S.map(ht)),q=[...N,...T].map(U=>{let Te=ke[U]??[];return[U,Te.length>0?Te:Ie.get(U)??[]]});P(U=>({...U,[g]:Object.fromEntries(q)})),A(U=>({...U,[g]:Se}))},"oe"),e[30]=l,e[31]=oe):oe=e[31];let R=oe,ie,V;e[32]!==G||e[33]!==y||e[34]!==R||e[35]!==I||e[36]!==i||e[37]!==o||e[38]!==a?(ie=r(()=>{a!=="graph"||o===null||y===null&&G===null||I[i]!==void 0||pe(R(i,o.map(bt),(y??[]).map(gt)))},"ie"),V=[a,o,y,G,i,I,R],e[32]=G,e[33]=y,e[34]=R,e[35]=I,e[36]=i,e[37]=o,e[38]=a,e[39]=ie,e[40]=V):(ie=e[39],V=e[40]),(0,f.useEffect)(ie,V);let j=I[i]??mt,Y;if(e[41]!==j||e[42]!==y||e[43]!==o){let g;e[45]!==j?(g=r(S=>({columns:j[S.name]??Be,name:S.name,tier:"shard"}),"p"),e[45]=j,e[46]=g):g=e[46];let N=(o??[]).map(g),T;e[47]!==j?(T=r(S=>({columns:j[S.name]??Be,name:S.name,tier:"global"}),"T"),e[47]=j,e[48]=T):T=e[48];let F=(y??[]).map(T);Y=[...N,...F],e[41]=j,e[42]=y,e[43]=o,e[44]=Y}else Y=e[44];let x=Y,Z;if(e[49]!==h||e[50]!==o){let g=h.trim().toLowerCase();Z=(o??[]).filter(N=>N.name.toLowerCase().includes(g)),e[49]=h,e[50]=o,e[51]=Z}else Z=e[51];let de=Z,ve;if(e[52]!==y||e[53]!==h){let g=h.trim().toLowerCase();ve=(y??[]).filter(N=>N.name.toLowerCase().includes(g)),e[52]=y,e[53]=h,e[54]=ve}else ve=e[54];let Ce=ve,ye;return e[55]!==_||e[56]!==x||e[57]!==C||e[58]!==E||e[59]!==Ce||e[60]!==de||e[61]!==J||e[62]!==G||e[63]!==Q||e[64]!==y||e[65]!==O||e[66]!==te||e[67]!==me||e[68]!==i||e[69]!==h||e[70]!==o||e[71]!==se||e[72]!==be||e[73]!==a?(ye={columns:_,diagramTables:x,error:C,expanded:E,filteredGlobalTables:Ce,filteredTables:de,globalColumns:J,globalError:G,globalExpanded:Q,globalTables:y,indexes:O,refresh:te,setShardKey:d,setTableFilter:m,setView:c,shardColumnsError:me,shardKey:i,tableFilter:h,tables:o,toggle:se,toggleGlobal:be,view:a},e[55]=_,e[56]=x,e[57]=C,e[58]=E,e[59]=Ce,e[60]=de,e[61]=J,e[62]=G,e[63]=Q,e[64]=y,e[65]=O,e[66]=te,e[67]=me,e[68]=i,e[69]=h,e[70]=o,e[71]=se,e[72]=be,e[73]=a,e[74]=ye):ye=e[74],ye},"mt");function ht(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ht,"ut");function bt(s){return s.name}r(bt,"ht");function gt(s){return s.name}r(gt,"pt");var pt="/__lunora/schema-edit",xt=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"bt"),ft=r(s=>{let e=(0,we.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:c,onDestructive:i}=s,d=Ee(),h=n==="addTable"?"default":"outline",m;e[0]!==d?(m=d("Add table"),e[0]=d,e[1]=m):m=e[1];let o;e[2]!==c||e[3]!==h||e[4]!==m?(o=(0,t.jsx)(ge,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:h,children:m}),e[2]=c,e[3]=h,e[4]=m,e[5]=o):o=e[5];let p=!u,C=n==="addColumn"?"default":"outline",b;e[6]!==d?(b=d("Add column"),e[6]=d,e[7]=b):b=e[7];let z;e[8]!==l||e[9]!==p||e[10]!==C||e[11]!==b?(z=(0,t.jsx)(ge,{"data-testid":"sc-editor-add-column",disabled:p,onClick:l,size:"xs",type:"button",variant:C,children:b}),e[8]=l,e[9]=p,e[10]=C,e[11]=b,e[12]=z):z=e[12];let _=!u,ce=n==="addIndex"?"default":"outline",v;e[13]!==d?(v=d("Add index"),e[13]=d,e[14]=v):v=e[14];let O;e[15]!==a||e[16]!==v||e[17]!==_||e[18]!==ce?(O=(0,t.jsx)(ge,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:ce,children:v}),e[15]=a,e[16]=v,e[17]=_,e[18]=ce,e[19]=O):O=e[19];let $=!u,E=n==="destructive"?"default":"ghost",k;e[20]!==d?(k=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=k):k=e[21];let w;e[22]!==i||e[23]!==$||e[24]!==E||e[25]!==k?(w=(0,t.jsx)(ge,{"data-testid":"sc-editor-destructive",disabled:$,onClick:i,size:"xs",type:"button",variant:E,children:k}),e[22]=i,e[23]=$,e[24]=E,e[25]=k,e[26]=w):w=e[26];let I;return e[27]!==O||e[28]!==w||e[29]!==o||e[30]!==z?(I=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[o,z,O,w]}),e[27]=O,e[28]=w,e[29]=o,e[30]=z,e[31]=I):I=e[31],I},"ft"),vt=r(s=>{let e=(0,we.c)(28),{onOpenMigrations:u,result:n}=s,l=Ee();if(n===null){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(t.Fragment,{}),e[0]=m):m=e[0],m}if(n.kind==="error"){let m;return e[1]!==n.message?(m=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=m):m=e[2],m}if(n.kind==="needs-migration"){let m;e[3]!==n.message||e[4]!==l?(m=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=m):m=e[5];let o;e[6]!==m?(o=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:m}),e[6]=m,e[7]=o):o=e[7];let p;e[8]!==l?(p=l("Open Migrations"),e[8]=l,e[9]=p):p=e[9];let C;e[10]!==u||e[11]!==p?(C=(0,t.jsx)(ge,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:p}),e[10]=u,e[11]=p,e[12]=C):C=e[12];let b;return e[13]!==o||e[14]!==C?(b=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[o,C]}),e[13]=o,e[14]=C,e[15]=b):b=e[15],b}if(n.diagnostics.length===0){let m;return e[16]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(t.Fragment,{}),e[16]=m):m=e[16],m}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let c;e[19]!==a?(c=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=c):c=e[20];let i;e[21]!==n.diagnostics?(i=n.diagnostics.map(yt),e[21]=n.diagnostics,e[22]=i):i=e[22];let d;e[23]!==i?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:i}),e[23]=i,e[24]=d):d=e[24];let h;return e[25]!==c||e[26]!==d?(h=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,d]}),e[25]=c,e[26]=d,e[27]=h):h=e[27],h},"xt");function yt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(yt,"vt");var Nt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Ct="v.string()",wt=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),Tt=r(s=>{let e=(0,we.c)(83),{onApplied:u,tableNames:n}=s,l=Ee(),a=Qe(),[c,i]=(0,f.useState)(null),[d,h]=(0,f.useState)(!1),[m,o]=(0,f.useState)(null),[p,C]=(0,f.useState)(""),[b,z]=(0,f.useState)(""),[_,ce]=(0,f.useState)(Ct),[v,O]=(0,f.useState)(n[0]??""),[$,E]=(0,f.useState)(""),[k,w]=(0,f.useState)(""),[I,P]=(0,f.useState)(!1),B;e[0]===Symbol.for("react.memo_cache_sentinel")?(B=r(()=>{i(null),C(""),z(""),E(""),w(""),P(!1)},"Z"),e[0]=B):B=e[0];let me=B,A;e[1]!==u?(A=r(async q=>{h(!0),o(null);try{let U=await xt(q);o(U),U.kind==="ok"&&(u(U.tables),me())}catch(U){let Te=U;o({kind:"error",message:Te instanceof Error?Te.message:String(Te)})}h(!1)},"I"),e[1]=u,e[2]=A):A=e[2];let y=A,xe;e[3]!==y||e[4]!==p?(xe=r(()=>{pe(y({kind:"addTable",table:p.trim()}))},"ge"),e[3]=y,e[4]=p,e[5]=xe):xe=e[5];let G=xe,ue;e[6]!==b||e[7]!==y||e[8]!==v||e[9]!==_?(ue=r(()=>{pe(y({column:b.trim(),kind:"addOptionalColumn",table:v,validator:_}))},"ue"),e[6]=b,e[7]=y,e[8]=v,e[9]=_,e[10]=ue):ue=e[10];let ee=ue,J;e[11]!==k||e[12]!==$||e[13]!==y||e[14]!==v||e[15]!==I?(J=r(()=>{pe(y({fields:wt(k),kind:"addIndex",name:$.trim(),table:v,unique:I}))},"U"),e[11]=k,e[12]=$,e[13]=y,e[14]=v,e[15]=I,e[16]=J):J=e[16];let Ne=J,Q;e[17]===Symbol.for("react.memo_cache_sentinel")?(Q=r(()=>{o(null),i("addTable")},"X"),e[17]=Q):Q=e[17];let fe=Q,W;e[18]===Symbol.for("react.memo_cache_sentinel")?(W=r(()=>{o(null),i("addColumn")},"Y"),e[18]=W):W=e[18];let te=W,L;e[19]===Symbol.for("react.memo_cache_sentinel")?(L=r(()=>{o(null),i("addIndex")},"L"),e[19]=L):L=e[19];let le=L,ae;e[20]!==l?(ae=r(()=>{i("destructive"),o({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ae"),e[20]=l,e[21]=ae):ae=e[21];let he=ae,K;e[22]===Symbol.for("react.memo_cache_sentinel")?(K=r(q=>{C(q.target.value)},"K"),e[22]=K):K=e[22];let ne=K,M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=r(q=>{z(q.target.value)},"M"),e[23]=M):M=e[23];let se=M,re;e[24]===Symbol.for("react.memo_cache_sentinel")?(re=r(q=>{ce(q.target.value)},"re"),e[24]=re):re=e[24];let be=re,X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=r(q=>{O(q.target.value)},"H"),e[25]=X):X=e[25];let H=X,D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=r(q=>{E(q.target.value)},"D"),e[26]=D):D=e[26];let oe=D,R;e[27]===Symbol.for("react.memo_cache_sentinel")?(R=r(q=>{w(q.target.value)},"R"),e[27]=R):R=e[27];let ie=R,V;e[28]===Symbol.for("react.memo_cache_sentinel")?(V=r(q=>{P(q.target.checked)},"V"),e[28]=V):V=e[28];let j=V,Y;e[29]!==a?(Y=r(()=>{pe(a({to:"/migrations"}))},"W"),e[29]=a,e[30]=Y):Y=e[30];let x=Y,Z;e[31]!==l?(Z=l("Edit schema"),e[31]=l,e[32]=Z):Z=e[32];let de;e[33]!==Z?(de=(0,t.jsx)(Ge,{children:Z}),e[33]=Z,e[34]=de):de=e[34];let ve;e[35]!==l?(ve=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=ve):ve=e[36];let Ce;e[37]!==ve?(Ce=(0,t.jsx)(Le,{children:ve}),e[37]=ve,e[38]=Ce):Ce=e[38];let ye;e[39]!==de||e[40]!==Ce?(ye=(0,t.jsxs)(Pe,{children:[de,Ce]}),e[39]=de,e[40]=Ce,e[41]=ye):ye=e[41];let g=n.length>0,N;e[42]!==c||e[43]!==he||e[44]!==g?(N=(0,t.jsx)(ft,{hasTables:g,mode:c,onAddColumn:te,onAddIndex:le,onAddTable:fe,onDestructive:he}),e[42]=c,e[43]=he,e[44]=g,e[45]=N):N=e[45];let T;e[46]!==d||e[47]!==c||e[48]!==G||e[49]!==l||e[50]!==p?(T=c==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ne,value:p})]}),(0,t.jsx)(ge,{"data-testid":"sc-editor-table-apply",disabled:d||p.trim()==="",onClick:G,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(ge,{onClick:me,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=c,e[48]=G,e[49]=l,e[50]=p,e[51]=T):T=e[51];let F;e[52]!==d||e[53]!==b||e[54]!==c||e[55]!==ee||e[56]!==l||e[57]!==n||e[58]!==v||e[59]!==_?(F=c==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:H,value:v,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:se,value:b})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:be,value:_,children:Nt.map(kt)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(ge,{"data-testid":"sc-editor-column-apply",disabled:d||b.trim()===""||v==="",onClick:ee,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(ge,{onClick:me,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=b,e[54]=c,e[55]=ee,e[56]=l,e[57]=n,e[58]=v,e[59]=_,e[60]=F):F=e[60];let S;e[61]!==d||e[62]!==k||e[63]!==$||e[64]!==c||e[65]!==Ne||e[66]!==l||e[67]!==n||e[68]!==v||e[69]!==I?(S=c==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:H,value:v,children:n.map(St)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:oe,value:$})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ie,value:k})]}),(0,t.jsxs)(_e,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:I,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:j,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(ge,{"data-testid":"sc-editor-index-apply",disabled:d||$.trim()===""||k.trim()==="",onClick:Ne,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(ge,{onClick:me,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=k,e[63]=$,e[64]=c,e[65]=Ne,e[66]=l,e[67]=n,e[68]=v,e[69]=I,e[70]=S):S=e[70];let ke;e[71]!==x||e[72]!==m?(ke=(0,t.jsx)(vt,{onOpenMigrations:x,result:m}),e[71]=x,e[72]=m,e[73]=ke):ke=e[73];let Se;e[74]!==N||e[75]!==T||e[76]!==F||e[77]!==S||e[78]!==ke?(Se=(0,t.jsxs)(Ke,{children:[N,T,F,S,ke]}),e[74]=N,e[75]=T,e[76]=F,e[77]=S,e[78]=ke,e[79]=Se):Se=e[79];let Ie;return e[80]!==ye||e[81]!==Se?(Ie=(0,t.jsxs)(Oe,{"data-testid":"sc-editor",size:"sm",children:[ye,Se]}),e[80]=ye,e[81]=Se,e[82]=Ie):Ie=e[82],Ie},"Tt");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");function kt(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(kt,"St");function St(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(St,"_t");var et=[],It=r(s=>{let e=(0,we.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=Re("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let c;return e[3]!==l?(c=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=c):c=e[4],c},"$t"),tt=r(s=>{let e=(0,we.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:c,rowTestId:i,toggleTestId:d}=s,h;e[0]!==n?(h=(0,t.jsx)(It,{open:n}),e[0]=n,e[1]=h):h=e[1];let m;e[2]!==l?(m=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=m):m=e[3];let o;e[4]!==c?(o=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=o):o=e[5];let p;e[6]!==n||e[7]!==a||e[8]!==h||e[9]!==m||e[10]!==o||e[11]!==d?(p=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[h,m," ",o]}),e[6]=n,e[7]=a,e[8]=h,e[9]=m,e[10]=o,e[11]=d,e[12]=p):p=e[12];let C;e[13]!==u||e[14]!==n?(C=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=C):C=e[15];let b;return e[16]!==i||e[17]!==p||e[18]!==C?(b=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":i,children:[p,C]}),e[16]=i,e[17]=p,e[18]=C,e[19]=b):b=e[19],b},"Ye"),lt=r(s=>{let e=(0,we.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(Et),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),At=r(s=>{let e=(0,we.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let c;e[2]!==n?(c=n.map(Ft),e[2]=n,e[3]=c):c=e[3];let i;e[4]!==c||e[5]!==l?(i=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:c}),e[4]=c,e[5]=l,e[6]=i):i=e[6];let d;return e[7]!==a||e[8]!==i?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,i]}),e[7]=a,e[8]=i,e[9]=d):d=e[9],d},"kt"),at=r(s=>Re("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Ht=r(s=>{let e=(0,we.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Ee(),c;e[0]!==u||e[1]!==n?(c={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=c):c=e[2];let{columns:i,diagramTables:d,error:h,expanded:m,filteredGlobalTables:o,filteredTables:p,globalColumns:C,globalError:b,globalExpanded:z,globalTables:_,indexes:ce,refresh:v,setShardKey:O,setTableFilter:$,setView:E,shardColumnsError:k,shardKey:w,tableFilter:I,tables:P,toggle:B,toggleGlobal:me,view:A}=ut(c),y;e[3]!==E?(y=r(()=>{E("list")},"v"),e[3]=E,e[4]=y):y=e[4];let xe=y,G;e[5]!==E?(G=r(()=>{E("graph")},"G"),e[5]=E,e[6]=G):G=e[6];let ue=G,ee;e[7]!==$?(ee=r(x=>{$(x.target.value)},"ee"),e[7]=$,e[8]=ee):ee=e[8];let J=ee,Ne;e[9]!==v||e[10]!==w?(Ne=r(x=>{pe(v(w))},"Ne"),e[9]=v,e[10]=w,e[11]=Ne):Ne=e[11];let Q=Ne,fe;e[12]!==P?(fe=P??[],e[12]=P,e[13]=fe):fe=e[13];let W;e[14]!==fe?(W=fe.map(zt),e[14]=fe,e[15]=W):W=e[15];let te=W,L;e[16]!==O||e[17]!==w?(L=(0,t.jsx)(He,{onChange:O,testId:"sc-shard-input",value:w}),e[16]=O,e[17]=w,e[18]=L):L=e[18];let le;e[19]!==a?(le=a("Schema view"),e[19]=a,e[20]=le):le=e[20];let ae=A==="graph",he=A==="graph",K;e[21]!==he?(K=at(he),e[21]=he,e[22]=K):K=e[22];let ne;e[23]!==a?(ne=a("Graph"),e[23]=a,e[24]=ne):ne=e[24];let M;e[25]!==ue||e[26]!==ae||e[27]!==K||e[28]!==ne?(M=(0,t.jsx)("button",{"aria-selected":ae,className:K,"data-testid":"sc-view-graph",onClick:ue,role:"tab",type:"button",children:ne}),e[25]=ue,e[26]=ae,e[27]=K,e[28]=ne,e[29]=M):M=e[29];let se=A==="list",re=A==="list",be;e[30]!==re?(be=at(re),e[30]=re,e[31]=be):be=e[31];let X;e[32]!==a?(X=a("Table list"),e[32]=a,e[33]=X):X=e[33];let H;e[34]!==xe||e[35]!==se||e[36]!==be||e[37]!==X?(H=(0,t.jsx)("button",{"aria-selected":se,className:be,"data-testid":"sc-view-list",onClick:xe,role:"tab",type:"button",children:X}),e[34]=xe,e[35]=se,e[36]=be,e[37]=X,e[38]=H):H=e[38];let D;e[39]!==M||e[40]!==H||e[41]!==le?(D=(0,t.jsxs)("div",{"aria-label":le,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[M,H]}),e[39]=M,e[40]=H,e[41]=le,e[42]=D):D=e[42];let oe;e[43]!==D||e[44]!==L?(oe=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[L,D]}),e[43]=D,e[44]=L,e[45]=oe):oe=e[45];let R;e[46]!==Q||e[47]!==l||e[48]!==te?(R=l===!0&&(0,t.jsx)(Tt,{onApplied:Q,tableNames:te}),e[46]=Q,e[47]=l,e[48]=te,e[49]=R):R=e[49];let ie;e[50]!==J||e[51]!==a||e[52]!==I||e[53]!==A?(ie=A==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:J,placeholder:a("Filter tables"),value:I}),e[50]=J,e[51]=a,e[52]=I,e[53]=A,e[54]=ie):ie=e[54];let V;e[55]!==d||e[56]!==h||e[57]!==b||e[58]!==k||e[59]!==w||e[60]!==A?(V=A==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:h}),b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:b}),(0,t.jsx)(Ze,{columnsError:k[w]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=h,e[57]=b,e[58]=k,e[59]=w,e[60]=A,e[61]=V):V=e[61];let j;e[62]!==i||e[63]!==h||e[64]!==m||e[65]!==o||e[66]!==p||e[67]!==C||e[68]!==b||e[69]!==z||e[70]!==_||e[71]!==ce||e[72]!==w||e[73]!==a||e[74]!==P||e[75]!==B||e[76]!==me||e[77]!==A?(j=A==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(Oe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ve,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),P!==null&&(0,t.jsx)(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:p.length})]}),(0,t.jsx)(Le,{children:Me.shard.hint})]}),(0,t.jsxs)(Ke,{children:[h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:h}),P!==null&&P.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),P!==null&&P.length>0&&p.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),p.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:p.map(x=>{let Z=`${w}:${x.name}`,de=ce[Z]??[];return(0,t.jsxs)(tt,{expanded:m===x.name,name:x.name,onToggle:r(()=>{pe(B(x.name))},"onToggle"),rowCount:x.rowCount,rowTestId:`sc-table-${x.name}`,toggleTestId:`sc-toggle-${x.name}`,children:[(0,t.jsx)(lt,{columns:i[Z]??et,testId:`sc-columns-${x.name}`}),de.length>0&&(0,t.jsx)(At,{heading:a("Indexes"),indexes:de,testId:`sc-indexes-${x.name}`})]},x.name)})})]})]}),(0,t.jsxs)(Oe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ve,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:o.length})]}),(0,t.jsx)(Le,{children:Me.global.hint})]}),(0,t.jsxs)(Ke,{children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:b}),_!==null&&_.length===0&&(0,t.jsx)(We,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&o.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),o.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:o.map(x=>(0,t.jsx)(tt,{expanded:z===x.name,name:x.name,onToggle:r(()=>{pe(me(x.name))},"onToggle"),rowCount:x.rowCount,rowTestId:`sc-global-table-${x.name}`,toggleTestId:`sc-global-toggle-${x.name}`,children:(0,t.jsx)(lt,{columns:C[x.name]??et,testId:`sc-global-columns-${x.name}`})},x.name))})]})]})]}),e[62]=i,e[63]=h,e[64]=m,e[65]=o,e[66]=p,e[67]=C,e[68]=b,e[69]=z,e[70]=_,e[71]=ce,e[72]=w,e[73]=a,e[74]=P,e[75]=B,e[76]=me,e[77]=A,e[78]=j):j=e[78];let Y;return e[79]!==oe||e[80]!==R||e[81]!==ie||e[82]!==V||e[83]!==j?(Y=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[oe,R,ie,V,j]}),e[79]=oe,e[80]=R,e[81]=ie,e[82]=V,e[83]=j,e[84]=Y):Y=e[84],Y},"Qt");function Et(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(Et,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(Fe,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(Fe,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"At");function zt(s){return s.name}r(zt,"Et");export{Ht as SchemaViewer};
|
|
1
|
+
import{a as Ze}from"./chunk-5YADKLAQ.js";import{a as Me,b as Ve}from"./chunk-GMR677FL.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as _e}from"./chunk-5Y3QLNWX.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-4UOFSGUS.js";import{a as He}from"./chunk-X665E2HU.js";import{b as Xe}from"./chunk-GRL5MG3Z.js";import{e as Qe}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import{a as Ye}from"./chunk-LFKCLLPT.js";import{R as Ae}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as ge}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Fe}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as qe}from"./chunk-ERMTJYQF.js";import{f as Je}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as We}from"./chunk-XQCVZAGU.js";import{a as Oe,b as Pe,c as Ge,d as Le,e as Ke}from"./chunk-UZERI5YC.js";import{d as Ee,f as ze,g as $e,h as je,m as pe}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as r,e as De,f as nt,g as st,h as rt,j as Re}from"./chunk-3XIESWL4.js";var we=De(st(),1);var f=De(nt(),1);var t=De(rt(),1);var ot=ze(qe.listTables),it=ze(qe.listTableIndexes),dt=ze(qe.readTablePage),ct=ze(qe.describeTables),mt={},Be=[],ut=r(s=>{let e=(0,we.c)(75),{initialShardKey:u,initialTable:n}=s,l=Je(),[a,c]=(0,f.useState)("graph"),[i,d]=(0,f.useState)(u??""),[h,m]=(0,f.useState)(""),[o,p]=(0,f.useState)(null),[C,b]=(0,f.useState)(null),z;e[0]===Symbol.for("react.memo_cache_sentinel")?(z={},e[0]=z):z=e[0];let[_,ce]=(0,f.useState)(z),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let[O,$]=(0,f.useState)(v),[E,k]=(0,f.useState)(null),w;e[2]===Symbol.for("react.memo_cache_sentinel")?(w={},e[2]=w):w=e[2];let[I,P]=(0,f.useState)(w),B;e[3]===Symbol.for("react.memo_cache_sentinel")?(B={},e[3]=B):B=e[3];let[me,A]=(0,f.useState)(B),[y,xe]=(0,f.useState)(null),[G,ue]=(0,f.useState)(null),ee;e[4]===Symbol.for("react.memo_cache_sentinel")?(ee={},e[4]=ee):ee=e[4];let[J,Ne]=(0,f.useState)(ee),[Q,fe]=(0,f.useState)(null),W;e[5]!==l?(W=r(async g=>{b(null);try{let N=await l.query(ot,{},$e(g));Xe(g),p(N),ce({}),$({}),k(null),P(T=>Object.fromEntries(Object.entries(T).filter(F=>{let[S]=F;return S!==g}))),A(T=>Object.fromEntries(Object.entries(T).filter(F=>{let[S]=F;return S!==g})))}catch(N){let T=N;p(null),b(je(T))}},"Y"),e[5]=l,e[6]=W):W=e[6];let te=W,L;e[7]!==l?(L=r(async()=>{ue(null);try{xe(await l.listGlobalTables())}catch(g){let N=g;xe(null),ue(je(N))}},"L"),e[7]=l,e[8]=L):L=e[8];let le=L,ae;e[9]!==i?(ae=i.trim(),e[9]=i,e[10]=ae):ae=e[10];let he=Ye(ae,400),K,ne;e[11]!==he||e[12]!==te||e[13]!==le?(ne=r(()=>{pe(te(he)),pe(le())},"ne"),K=[te,le,he],e[11]=he,e[12]=te,e[13]=le,e[14]=K,e[15]=ne):(K=e[14],ne=e[15]),(0,f.useEffect)(ne,K);let M;e[16]!==l||e[17]!==_||e[18]!==E||e[19]!==i?(M=r(async g=>{if(E===g){k(null);return}k(g);let N=`${i}:${g}`;if(_[N]!==void 0)return;let[T,F]=await Promise.allSettled([l.query(dt,{limit:1,offset:0,table:g},$e(i)),l.query(it,{table:g},$e(i))]);T.status==="fulfilled"?ce(S=>({...S,[N]:T.value.columns})):b(je(T.reason)),F.status==="fulfilled"&&$(S=>({...S,[N]:F.value.indexes}))},"M"),e[16]=l,e[17]=_,e[18]=E,e[19]=i,e[20]=M):M=e[20];let se=M,re;e[21]!==l||e[22]!==J||e[23]!==Q?(re=r(async g=>{if(Q===g){fe(null);return}if(fe(g),J[g]===void 0)try{let N=await l.readGlobalTablePage({limit:1,offset:0,table:g});Ne(T=>({...T,[g]:N.columns}))}catch(N){ue(je(N))}},"re"),e[21]=l,e[22]=J,e[23]=Q,e[24]=re):re=e[24];let be=re,X=(0,f.useRef)(void 0),H,D;e[25]!==n||e[26]!==o||e[27]!==se?(H=r(()=>{n===void 0||o===null||X.current===n||o.some(g=>g.name===n)&&(X.current=n,pe(se(n)))},"J"),D=[n,o,se],e[25]=n,e[26]=o,e[27]=se,e[28]=H,e[29]=D):(H=e[28],D=e[29]),(0,f.useEffect)(H,D);let oe;e[30]!==l?(oe=r(async(g,N,T)=>{let[F,S]=await Promise.all([Promise.allSettled([l.query(ct,{tables:[...N,...T]},$e(g))]),Promise.all(T.map(async U=>{let Te=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:U})]),Ue=Te[0].status==="fulfilled"?Te[0].value:void 0;return{columns:Ue?.columns??[],refs:Ue?.refs??{},table:U}}))]),ke=F[0].status==="fulfilled"?F[0].value?.columnsByTable??{}:{},Se=F[0].status==="rejected",Ie=new Map(S.map(ht)),q=[...N,...T].map(U=>{let Te=ke[U]??[];return[U,Te.length>0?Te:Ie.get(U)??[]]});P(U=>({...U,[g]:Object.fromEntries(q)})),A(U=>({...U,[g]:Se}))},"oe"),e[30]=l,e[31]=oe):oe=e[31];let R=oe,ie,V;e[32]!==G||e[33]!==y||e[34]!==R||e[35]!==I||e[36]!==i||e[37]!==o||e[38]!==a?(ie=r(()=>{a!=="graph"||o===null||y===null&&G===null||I[i]!==void 0||pe(R(i,o.map(bt),(y??[]).map(gt)))},"ie"),V=[a,o,y,G,i,I,R],e[32]=G,e[33]=y,e[34]=R,e[35]=I,e[36]=i,e[37]=o,e[38]=a,e[39]=ie,e[40]=V):(ie=e[39],V=e[40]),(0,f.useEffect)(ie,V);let j=I[i]??mt,Y;if(e[41]!==j||e[42]!==y||e[43]!==o){let g;e[45]!==j?(g=r(S=>({columns:j[S.name]??Be,name:S.name,tier:"shard"}),"p"),e[45]=j,e[46]=g):g=e[46];let N=(o??[]).map(g),T;e[47]!==j?(T=r(S=>({columns:j[S.name]??Be,name:S.name,tier:"global"}),"T"),e[47]=j,e[48]=T):T=e[48];let F=(y??[]).map(T);Y=[...N,...F],e[41]=j,e[42]=y,e[43]=o,e[44]=Y}else Y=e[44];let x=Y,Z;if(e[49]!==h||e[50]!==o){let g=h.trim().toLowerCase();Z=(o??[]).filter(N=>N.name.toLowerCase().includes(g)),e[49]=h,e[50]=o,e[51]=Z}else Z=e[51];let de=Z,ve;if(e[52]!==y||e[53]!==h){let g=h.trim().toLowerCase();ve=(y??[]).filter(N=>N.name.toLowerCase().includes(g)),e[52]=y,e[53]=h,e[54]=ve}else ve=e[54];let Ce=ve,ye;return e[55]!==_||e[56]!==x||e[57]!==C||e[58]!==E||e[59]!==Ce||e[60]!==de||e[61]!==J||e[62]!==G||e[63]!==Q||e[64]!==y||e[65]!==O||e[66]!==te||e[67]!==me||e[68]!==i||e[69]!==h||e[70]!==o||e[71]!==se||e[72]!==be||e[73]!==a?(ye={columns:_,diagramTables:x,error:C,expanded:E,filteredGlobalTables:Ce,filteredTables:de,globalColumns:J,globalError:G,globalExpanded:Q,globalTables:y,indexes:O,refresh:te,setShardKey:d,setTableFilter:m,setView:c,shardColumnsError:me,shardKey:i,tableFilter:h,tables:o,toggle:se,toggleGlobal:be,view:a},e[55]=_,e[56]=x,e[57]=C,e[58]=E,e[59]=Ce,e[60]=de,e[61]=J,e[62]=G,e[63]=Q,e[64]=y,e[65]=O,e[66]=te,e[67]=me,e[68]=i,e[69]=h,e[70]=o,e[71]=se,e[72]=be,e[73]=a,e[74]=ye):ye=e[74],ye},"mt");function ht(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ht,"ut");function bt(s){return s.name}r(bt,"ht");function gt(s){return s.name}r(gt,"pt");var pt="/__lunora/schema-edit",xt=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"bt"),ft=r(s=>{let e=(0,we.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:c,onDestructive:i}=s,d=Ee(),h=n==="addTable"?"default":"outline",m;e[0]!==d?(m=d("Add table"),e[0]=d,e[1]=m):m=e[1];let o;e[2]!==c||e[3]!==h||e[4]!==m?(o=(0,t.jsx)(ge,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:h,children:m}),e[2]=c,e[3]=h,e[4]=m,e[5]=o):o=e[5];let p=!u,C=n==="addColumn"?"default":"outline",b;e[6]!==d?(b=d("Add column"),e[6]=d,e[7]=b):b=e[7];let z;e[8]!==l||e[9]!==p||e[10]!==C||e[11]!==b?(z=(0,t.jsx)(ge,{"data-testid":"sc-editor-add-column",disabled:p,onClick:l,size:"xs",type:"button",variant:C,children:b}),e[8]=l,e[9]=p,e[10]=C,e[11]=b,e[12]=z):z=e[12];let _=!u,ce=n==="addIndex"?"default":"outline",v;e[13]!==d?(v=d("Add index"),e[13]=d,e[14]=v):v=e[14];let O;e[15]!==a||e[16]!==v||e[17]!==_||e[18]!==ce?(O=(0,t.jsx)(ge,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:ce,children:v}),e[15]=a,e[16]=v,e[17]=_,e[18]=ce,e[19]=O):O=e[19];let $=!u,E=n==="destructive"?"default":"ghost",k;e[20]!==d?(k=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=k):k=e[21];let w;e[22]!==i||e[23]!==$||e[24]!==E||e[25]!==k?(w=(0,t.jsx)(ge,{"data-testid":"sc-editor-destructive",disabled:$,onClick:i,size:"xs",type:"button",variant:E,children:k}),e[22]=i,e[23]=$,e[24]=E,e[25]=k,e[26]=w):w=e[26];let I;return e[27]!==O||e[28]!==w||e[29]!==o||e[30]!==z?(I=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[o,z,O,w]}),e[27]=O,e[28]=w,e[29]=o,e[30]=z,e[31]=I):I=e[31],I},"ft"),vt=r(s=>{let e=(0,we.c)(28),{onOpenMigrations:u,result:n}=s,l=Ee();if(n===null){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(t.Fragment,{}),e[0]=m):m=e[0],m}if(n.kind==="error"){let m;return e[1]!==n.message?(m=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=m):m=e[2],m}if(n.kind==="needs-migration"){let m;e[3]!==n.message||e[4]!==l?(m=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=m):m=e[5];let o;e[6]!==m?(o=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:m}),e[6]=m,e[7]=o):o=e[7];let p;e[8]!==l?(p=l("Open Migrations"),e[8]=l,e[9]=p):p=e[9];let C;e[10]!==u||e[11]!==p?(C=(0,t.jsx)(ge,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:p}),e[10]=u,e[11]=p,e[12]=C):C=e[12];let b;return e[13]!==o||e[14]!==C?(b=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[o,C]}),e[13]=o,e[14]=C,e[15]=b):b=e[15],b}if(n.diagnostics.length===0){let m;return e[16]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(t.Fragment,{}),e[16]=m):m=e[16],m}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let c;e[19]!==a?(c=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=c):c=e[20];let i;e[21]!==n.diagnostics?(i=n.diagnostics.map(yt),e[21]=n.diagnostics,e[22]=i):i=e[22];let d;e[23]!==i?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:i}),e[23]=i,e[24]=d):d=e[24];let h;return e[25]!==c||e[26]!==d?(h=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,d]}),e[25]=c,e[26]=d,e[27]=h):h=e[27],h},"xt");function yt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(yt,"vt");var Nt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Ct="v.string()",wt=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),Tt=r(s=>{let e=(0,we.c)(83),{onApplied:u,tableNames:n}=s,l=Ee(),a=Qe(),[c,i]=(0,f.useState)(null),[d,h]=(0,f.useState)(!1),[m,o]=(0,f.useState)(null),[p,C]=(0,f.useState)(""),[b,z]=(0,f.useState)(""),[_,ce]=(0,f.useState)(Ct),[v,O]=(0,f.useState)(n[0]??""),[$,E]=(0,f.useState)(""),[k,w]=(0,f.useState)(""),[I,P]=(0,f.useState)(!1),B;e[0]===Symbol.for("react.memo_cache_sentinel")?(B=r(()=>{i(null),C(""),z(""),E(""),w(""),P(!1)},"Z"),e[0]=B):B=e[0];let me=B,A;e[1]!==u?(A=r(async q=>{h(!0),o(null);try{let U=await xt(q);o(U),U.kind==="ok"&&(u(U.tables),me())}catch(U){let Te=U;o({kind:"error",message:Te instanceof Error?Te.message:String(Te)})}h(!1)},"I"),e[1]=u,e[2]=A):A=e[2];let y=A,xe;e[3]!==y||e[4]!==p?(xe=r(()=>{pe(y({kind:"addTable",table:p.trim()}))},"ge"),e[3]=y,e[4]=p,e[5]=xe):xe=e[5];let G=xe,ue;e[6]!==b||e[7]!==y||e[8]!==v||e[9]!==_?(ue=r(()=>{pe(y({column:b.trim(),kind:"addOptionalColumn",table:v,validator:_}))},"ue"),e[6]=b,e[7]=y,e[8]=v,e[9]=_,e[10]=ue):ue=e[10];let ee=ue,J;e[11]!==k||e[12]!==$||e[13]!==y||e[14]!==v||e[15]!==I?(J=r(()=>{pe(y({fields:wt(k),kind:"addIndex",name:$.trim(),table:v,unique:I}))},"U"),e[11]=k,e[12]=$,e[13]=y,e[14]=v,e[15]=I,e[16]=J):J=e[16];let Ne=J,Q;e[17]===Symbol.for("react.memo_cache_sentinel")?(Q=r(()=>{o(null),i("addTable")},"X"),e[17]=Q):Q=e[17];let fe=Q,W;e[18]===Symbol.for("react.memo_cache_sentinel")?(W=r(()=>{o(null),i("addColumn")},"Y"),e[18]=W):W=e[18];let te=W,L;e[19]===Symbol.for("react.memo_cache_sentinel")?(L=r(()=>{o(null),i("addIndex")},"L"),e[19]=L):L=e[19];let le=L,ae;e[20]!==l?(ae=r(()=>{i("destructive"),o({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ae"),e[20]=l,e[21]=ae):ae=e[21];let he=ae,K;e[22]===Symbol.for("react.memo_cache_sentinel")?(K=r(q=>{C(q.target.value)},"K"),e[22]=K):K=e[22];let ne=K,M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=r(q=>{z(q.target.value)},"M"),e[23]=M):M=e[23];let se=M,re;e[24]===Symbol.for("react.memo_cache_sentinel")?(re=r(q=>{ce(q.target.value)},"re"),e[24]=re):re=e[24];let be=re,X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=r(q=>{O(q.target.value)},"H"),e[25]=X):X=e[25];let H=X,D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=r(q=>{E(q.target.value)},"D"),e[26]=D):D=e[26];let oe=D,R;e[27]===Symbol.for("react.memo_cache_sentinel")?(R=r(q=>{w(q.target.value)},"R"),e[27]=R):R=e[27];let ie=R,V;e[28]===Symbol.for("react.memo_cache_sentinel")?(V=r(q=>{P(q.target.checked)},"V"),e[28]=V):V=e[28];let j=V,Y;e[29]!==a?(Y=r(()=>{pe(a({to:"/migrations"}))},"W"),e[29]=a,e[30]=Y):Y=e[30];let x=Y,Z;e[31]!==l?(Z=l("Edit schema"),e[31]=l,e[32]=Z):Z=e[32];let de;e[33]!==Z?(de=(0,t.jsx)(Ge,{children:Z}),e[33]=Z,e[34]=de):de=e[34];let ve;e[35]!==l?(ve=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=ve):ve=e[36];let Ce;e[37]!==ve?(Ce=(0,t.jsx)(Le,{children:ve}),e[37]=ve,e[38]=Ce):Ce=e[38];let ye;e[39]!==de||e[40]!==Ce?(ye=(0,t.jsxs)(Pe,{children:[de,Ce]}),e[39]=de,e[40]=Ce,e[41]=ye):ye=e[41];let g=n.length>0,N;e[42]!==c||e[43]!==he||e[44]!==g?(N=(0,t.jsx)(ft,{hasTables:g,mode:c,onAddColumn:te,onAddIndex:le,onAddTable:fe,onDestructive:he}),e[42]=c,e[43]=he,e[44]=g,e[45]=N):N=e[45];let T;e[46]!==d||e[47]!==c||e[48]!==G||e[49]!==l||e[50]!==p?(T=c==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ne,value:p})]}),(0,t.jsx)(ge,{"data-testid":"sc-editor-table-apply",disabled:d||p.trim()==="",onClick:G,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(ge,{onClick:me,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=c,e[48]=G,e[49]=l,e[50]=p,e[51]=T):T=e[51];let F;e[52]!==d||e[53]!==b||e[54]!==c||e[55]!==ee||e[56]!==l||e[57]!==n||e[58]!==v||e[59]!==_?(F=c==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:H,value:v,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:se,value:b})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:be,value:_,children:Nt.map(kt)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(ge,{"data-testid":"sc-editor-column-apply",disabled:d||b.trim()===""||v==="",onClick:ee,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(ge,{onClick:me,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=b,e[54]=c,e[55]=ee,e[56]=l,e[57]=n,e[58]=v,e[59]=_,e[60]=F):F=e[60];let S;e[61]!==d||e[62]!==k||e[63]!==$||e[64]!==c||e[65]!==Ne||e[66]!==l||e[67]!==n||e[68]!==v||e[69]!==I?(S=c==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:H,value:v,children:n.map(St)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:oe,value:$})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(_e,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ie,value:k})]}),(0,t.jsxs)(_e,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:I,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:j,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(ge,{"data-testid":"sc-editor-index-apply",disabled:d||$.trim()===""||k.trim()==="",onClick:Ne,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(ge,{onClick:me,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=k,e[63]=$,e[64]=c,e[65]=Ne,e[66]=l,e[67]=n,e[68]=v,e[69]=I,e[70]=S):S=e[70];let ke;e[71]!==x||e[72]!==m?(ke=(0,t.jsx)(vt,{onOpenMigrations:x,result:m}),e[71]=x,e[72]=m,e[73]=ke):ke=e[73];let Se;e[74]!==N||e[75]!==T||e[76]!==F||e[77]!==S||e[78]!==ke?(Se=(0,t.jsxs)(Ke,{children:[N,T,F,S,ke]}),e[74]=N,e[75]=T,e[76]=F,e[77]=S,e[78]=ke,e[79]=Se):Se=e[79];let Ie;return e[80]!==ye||e[81]!==Se?(Ie=(0,t.jsxs)(Oe,{"data-testid":"sc-editor",size:"sm",children:[ye,Se]}),e[80]=ye,e[81]=Se,e[82]=Ie):Ie=e[82],Ie},"Tt");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");function kt(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(kt,"St");function St(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(St,"_t");var et=[],It=r(s=>{let e=(0,we.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=Re("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let c;return e[3]!==l?(c=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=c):c=e[4],c},"$t"),tt=r(s=>{let e=(0,we.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:c,rowTestId:i,toggleTestId:d}=s,h;e[0]!==n?(h=(0,t.jsx)(It,{open:n}),e[0]=n,e[1]=h):h=e[1];let m;e[2]!==l?(m=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=m):m=e[3];let o;e[4]!==c?(o=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=o):o=e[5];let p;e[6]!==n||e[7]!==a||e[8]!==h||e[9]!==m||e[10]!==o||e[11]!==d?(p=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[h,m," ",o]}),e[6]=n,e[7]=a,e[8]=h,e[9]=m,e[10]=o,e[11]=d,e[12]=p):p=e[12];let C;e[13]!==u||e[14]!==n?(C=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=C):C=e[15];let b;return e[16]!==i||e[17]!==p||e[18]!==C?(b=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":i,children:[p,C]}),e[16]=i,e[17]=p,e[18]=C,e[19]=b):b=e[19],b},"Ye"),lt=r(s=>{let e=(0,we.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(Et),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),At=r(s=>{let e=(0,we.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let c;e[2]!==n?(c=n.map(Ft),e[2]=n,e[3]=c):c=e[3];let i;e[4]!==c||e[5]!==l?(i=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:c}),e[4]=c,e[5]=l,e[6]=i):i=e[6];let d;return e[7]!==a||e[8]!==i?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,i]}),e[7]=a,e[8]=i,e[9]=d):d=e[9],d},"kt"),at=r(s=>Re("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Ht=r(s=>{let e=(0,we.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Ee(),c;e[0]!==u||e[1]!==n?(c={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=c):c=e[2];let{columns:i,diagramTables:d,error:h,expanded:m,filteredGlobalTables:o,filteredTables:p,globalColumns:C,globalError:b,globalExpanded:z,globalTables:_,indexes:ce,refresh:v,setShardKey:O,setTableFilter:$,setView:E,shardColumnsError:k,shardKey:w,tableFilter:I,tables:P,toggle:B,toggleGlobal:me,view:A}=ut(c),y;e[3]!==E?(y=r(()=>{E("list")},"v"),e[3]=E,e[4]=y):y=e[4];let xe=y,G;e[5]!==E?(G=r(()=>{E("graph")},"G"),e[5]=E,e[6]=G):G=e[6];let ue=G,ee;e[7]!==$?(ee=r(x=>{$(x.target.value)},"ee"),e[7]=$,e[8]=ee):ee=e[8];let J=ee,Ne;e[9]!==v||e[10]!==w?(Ne=r(x=>{pe(v(w))},"Ne"),e[9]=v,e[10]=w,e[11]=Ne):Ne=e[11];let Q=Ne,fe;e[12]!==P?(fe=P??[],e[12]=P,e[13]=fe):fe=e[13];let W;e[14]!==fe?(W=fe.map(zt),e[14]=fe,e[15]=W):W=e[15];let te=W,L;e[16]!==O||e[17]!==w?(L=(0,t.jsx)(He,{onChange:O,testId:"sc-shard-input",value:w}),e[16]=O,e[17]=w,e[18]=L):L=e[18];let le;e[19]!==a?(le=a("Schema view"),e[19]=a,e[20]=le):le=e[20];let ae=A==="graph",he=A==="graph",K;e[21]!==he?(K=at(he),e[21]=he,e[22]=K):K=e[22];let ne;e[23]!==a?(ne=a("Graph"),e[23]=a,e[24]=ne):ne=e[24];let M;e[25]!==ue||e[26]!==ae||e[27]!==K||e[28]!==ne?(M=(0,t.jsx)("button",{"aria-selected":ae,className:K,"data-testid":"sc-view-graph",onClick:ue,role:"tab",type:"button",children:ne}),e[25]=ue,e[26]=ae,e[27]=K,e[28]=ne,e[29]=M):M=e[29];let se=A==="list",re=A==="list",be;e[30]!==re?(be=at(re),e[30]=re,e[31]=be):be=e[31];let X;e[32]!==a?(X=a("Table list"),e[32]=a,e[33]=X):X=e[33];let H;e[34]!==xe||e[35]!==se||e[36]!==be||e[37]!==X?(H=(0,t.jsx)("button",{"aria-selected":se,className:be,"data-testid":"sc-view-list",onClick:xe,role:"tab",type:"button",children:X}),e[34]=xe,e[35]=se,e[36]=be,e[37]=X,e[38]=H):H=e[38];let D;e[39]!==M||e[40]!==H||e[41]!==le?(D=(0,t.jsxs)("div",{"aria-label":le,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[M,H]}),e[39]=M,e[40]=H,e[41]=le,e[42]=D):D=e[42];let oe;e[43]!==D||e[44]!==L?(oe=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[L,D]}),e[43]=D,e[44]=L,e[45]=oe):oe=e[45];let R;e[46]!==Q||e[47]!==l||e[48]!==te?(R=l===!0&&(0,t.jsx)(Tt,{onApplied:Q,tableNames:te}),e[46]=Q,e[47]=l,e[48]=te,e[49]=R):R=e[49];let ie;e[50]!==J||e[51]!==a||e[52]!==I||e[53]!==A?(ie=A==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:J,placeholder:a("Filter tables"),value:I}),e[50]=J,e[51]=a,e[52]=I,e[53]=A,e[54]=ie):ie=e[54];let V;e[55]!==d||e[56]!==h||e[57]!==b||e[58]!==k||e[59]!==w||e[60]!==A?(V=A==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:h}),b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:b}),(0,t.jsx)(Ze,{columnsError:k[w]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=h,e[57]=b,e[58]=k,e[59]=w,e[60]=A,e[61]=V):V=e[61];let j;e[62]!==i||e[63]!==h||e[64]!==m||e[65]!==o||e[66]!==p||e[67]!==C||e[68]!==b||e[69]!==z||e[70]!==_||e[71]!==ce||e[72]!==w||e[73]!==a||e[74]!==P||e[75]!==B||e[76]!==me||e[77]!==A?(j=A==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(Oe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ve,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),P!==null&&(0,t.jsx)(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:p.length})]}),(0,t.jsx)(Le,{children:Me.shard.hint})]}),(0,t.jsxs)(Ke,{children:[h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:h}),P!==null&&P.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),P!==null&&P.length>0&&p.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),p.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:p.map(x=>{let Z=`${w}:${x.name}`,de=ce[Z]??[];return(0,t.jsxs)(tt,{expanded:m===x.name,name:x.name,onToggle:r(()=>{pe(B(x.name))},"onToggle"),rowCount:x.rowCount,rowTestId:`sc-table-${x.name}`,toggleTestId:`sc-toggle-${x.name}`,children:[(0,t.jsx)(lt,{columns:i[Z]??et,testId:`sc-columns-${x.name}`}),de.length>0&&(0,t.jsx)(At,{heading:a("Indexes"),indexes:de,testId:`sc-indexes-${x.name}`})]},x.name)})})]})]}),(0,t.jsxs)(Oe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ve,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:o.length})]}),(0,t.jsx)(Le,{children:Me.global.hint})]}),(0,t.jsxs)(Ke,{children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:b}),_!==null&&_.length===0&&(0,t.jsx)(We,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&o.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),o.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:o.map(x=>(0,t.jsx)(tt,{expanded:z===x.name,name:x.name,onToggle:r(()=>{pe(me(x.name))},"onToggle"),rowCount:x.rowCount,rowTestId:`sc-global-table-${x.name}`,toggleTestId:`sc-global-toggle-${x.name}`,children:(0,t.jsx)(lt,{columns:C[x.name]??et,testId:`sc-global-columns-${x.name}`})},x.name))})]})]})]}),e[62]=i,e[63]=h,e[64]=m,e[65]=o,e[66]=p,e[67]=C,e[68]=b,e[69]=z,e[70]=_,e[71]=ce,e[72]=w,e[73]=a,e[74]=P,e[75]=B,e[76]=me,e[77]=A,e[78]=j):j=e[78];let Y;return e[79]!==oe||e[80]!==R||e[81]!==ie||e[82]!==V||e[83]!==j?(Y=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[oe,R,ie,V,j]}),e[79]=oe,e[80]=R,e[81]=ie,e[82]=V,e[83]=j,e[84]=Y):Y=e[84],Y},"Qt");function Et(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(Et,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(Fe,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(Fe,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"At");function zt(s){return s.name}r(zt,"Et");export{Ht as SchemaViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as le}from"./chunk-HPFLBYRI.js";import{b as re}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{d as de,f as oe}from"./chunk-
|
|
1
|
+
import{a as le}from"./chunk-HPFLBYRI.js";import{b as re}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{d as de,f as oe}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as me}from"./chunk-XQCVZAGU.js";import{a as ae}from"./chunk-UZERI5YC.js";import{d as ce,q as pe}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as k,e as ie,g as xe,h as ge,j as Z}from"./chunk-3XIESWL4.js";var ne=ie(xe(),1);var a=ie(ge(),1);var ye="/_lunora/health",Ne="/_lunora/health/ready",ve=k((n,e)=>(n.endsWith("/")?n.slice(0,-1):n)+e,"xe"),be=k(()=>{let n=oe();return async e=>{let w=e==="ready"?Ne:ye,t=n.getAuthToken(),_=ve(n.url,w);try{let l=await fetch(_,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),d=null;try{d=await l.json()}catch{d=null}return{body:d,ok:l.ok,status:l.status}}catch(l){return{body:null,error:l instanceof Error?l.message:String(l),ok:!1,status:0}}}},"Ne"),he={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ke={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},we=k(n=>n==="unhealthy"?"crit":n==="degraded"?"warn":"ok","ye"),ue=k(n=>{let e=(0,ne.c)(13),{label:w,level:t,testId:_,value:l}=n,d=he[t],o;e[0]!==d?(o=Z("size-1.5 shrink-0 rounded-full",d),e[0]=d,e[1]=o):o=e[1];let c;e[2]!==o?(c=(0,a.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=c):c=e[3];let x;e[4]!==w||e[5]!==c?(x=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[c,w]}),e[4]=w,e[5]=c,e[6]=x):x=e[6];let g;e[7]!==_||e[8]!==l?(g=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":_,children:l}),e[7]=_,e[8]=l,e[9]=g):g=e[9];let u;return e[10]!==x||e[11]!==g?(u=(0,a.jsx)(ae,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[x,g]})}),e[10]=x,e[11]=g,e[12]=u):u=e[12],u},"ne"),De=k(n=>{let e=(0,ne.c)(115),{probe:w}=n,t=ce(),_=be(),l=w??_,d;e[0]!==l?(d=k(async()=>{let[s,i]=await Promise.all([l("live"),l("ready")]);return{live:s,ready:i}},"d"),e[0]=l,e[1]=d):d=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=["deployment-health"],e[2]=o):o=e[2];let c;e[3]!==d?(c={queryFn:d,queryKey:o},e[3]=d,e[4]=c):c=e[4];let{data:x,isPending:g}=de(c),u=x?.live??null,fe=x?.ready??null;if(g){let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(le,{className:"h-16 w-full"}),(0,a.jsx)(le,{className:"h-40 w-full"})]}),e[5]=s):s=e[5],s}let r=u?.body??null;if(r===null){let s=u?.status===403,i;e[6]!==s||e[7]!==u?.error||e[8]!==t?(i=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:u?.error??t("no response")}),e[6]=s,e[7]=u?.error,e[8]=t,e[9]=i):i=e[9];let h;e[10]!==t?(h=t("Health endpoint unavailable"),e[10]=t,e[11]=h):h=e[11];let p;return e[12]!==i||e[13]!==h?(p=(0,a.jsx)(me,{description:i,testId:"deployment-health-error",title:h}),e[12]=i,e[13]=h,e[14]=p):p=e[14],p}let ee;e[15]!==r.status?(ee=we(r.status),e[15]=r.status,e[16]=ee):ee=e[16];let j=ee,m;if(r.status==="unhealthy"){let s;e[17]!==t?(s=t("Unhealthy"),e[17]=t,e[18]=s):s=e[18],m=s}else if(r.status==="degraded"){let s;e[19]!==t?(s=t("Degraded"),e[19]=t,e[20]=s):s=e[20],m=s}else{let s;e[21]!==t?(s=t("Healthy"),e[21]=t,e[22]=s):s=e[22],m=s}let C=fe?.ok??!1,Y=C?"ok":"crit",z,I,y,N,v,S,V,b,$,H;if(e[23]!==r.appName||e[24]!==r.appVersion||e[25]!==r.checks||e[26]!==r.timestamp||e[27]!==j||e[28]!==Y||e[29]!==C||e[30]!==m||e[31]!==t){let s=[...r.checks].toSorted(_e);H="flex flex-col gap-6",I="deployment-health";let i;e[42]!==t?(i=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[42]=t,e[43]=i):i=e[43],e[44]!==i?(y=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:i}),e[44]=i,e[45]=y):y=e[45];let h=ke[j],p;e[46]!==h?(p=Z("flex size-10 shrink-0 items-center justify-center rounded-full",h),e[46]=h,e[47]=p):p=e[47];let se=he[j],D;e[48]!==se?(D=Z("size-3 rounded-full",se),e[48]=se,e[49]=D):D=e[49];let L;e[50]!==D?(L=(0,a.jsx)("span",{className:D}),e[50]=D,e[51]=L):L=e[51];let T;e[52]!==p||e[53]!==L?(T=(0,a.jsx)("span",{"aria-hidden":"true",className:p,children:L}),e[52]=p,e[53]=L,e[54]=T):T=e[54];let q;e[55]!==m?(q=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:m}),e[55]=m,e[56]=q):q=e[56];let E;e[57]!==r.appName||e[58]!==r.appVersion?(E=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[r.appName," \xB7 ",r.appVersion]}),e[57]=r.appName,e[58]=r.appVersion,e[59]=E):E=e[59];let R;e[60]!==q||e[61]!==E?(R=(0,a.jsxs)("div",{className:"grid leading-tight",children:[q,E]}),e[60]=q,e[61]=E,e[62]=R):R=e[62];let U;e[63]!==T||e[64]!==R?(U=(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[T,R]}),e[63]=T,e[64]=R,e[65]=U):U=e[65];let A;e[66]!==t?(A=t("Checked"),e[66]=t,e[67]=A):A=e[67];let B;e[68]!==A?(B=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:A}),e[68]=A,e[69]=B):B=e[69];let F;e[70]!==r.timestamp?(F=pe(r.timestamp),e[70]=r.timestamp,e[71]=F):F=e[71];let K;e[72]!==F?(K=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:F}),e[72]=F,e[73]=K):K=e[73];let Q;e[74]!==B||e[75]!==K?(Q=(0,a.jsxs)("div",{className:"text-end",children:[B,K]}),e[74]=B,e[75]=K,e[76]=Q):Q=e[76],e[77]!==U||e[78]!==Q?(N=(0,a.jsx)(ae,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[U,Q]})}),e[77]=U,e[78]=Q,e[79]=N):N=e[79];let W;e[80]!==t?(W=t("Liveness"),e[80]=t,e[81]=W):W=e[81];let G;e[82]!==j||e[83]!==m||e[84]!==W?(G=(0,a.jsx)(ue,{label:W,level:j,testId:"dh-liveness",value:m}),e[82]=j,e[83]=m,e[84]=W,e[85]=G):G=e[85];let J;e[86]!==t?(J=t("Readiness"),e[86]=t,e[87]=J):J=e[87];let M;e[88]!==C||e[89]!==t?(M=t(C?"Ready":"Not ready"),e[88]=C,e[89]=t,e[90]=M):M=e[90];let O;e[91]!==Y||e[92]!==J||e[93]!==M?(O=(0,a.jsx)(ue,{label:J,level:Y,testId:"dh-readiness",value:M}),e[91]=Y,e[92]=J,e[93]=M,e[94]=O):O=e[94],e[95]!==G||e[96]!==O?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[G,O]}),e[95]=G,e[96]=O,e[97]=v):v=e[97],z=ae,S="gap-0 py-0",V="dh-checks";let X;e[98]!==t?(X=t("Subsystem checks"),e[98]=t,e[99]=X):X=e[99],e[100]!==X?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:X})}),e[100]=X,e[101]=b):b=e[101],$=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(f=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${f.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Z("size-1.5 shrink-0 rounded-full",f.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:f.name}),f.critical&&(0,a.jsx)(re,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[f.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:f.message}),(0,a.jsx)(re,{"data-testid":`dh-check-status-${f.name}`,variant:f.status==="up"?"secondary":"destructive",children:f.status==="up"?t("Up"):t("Down")})]})]},f.name))}),e[23]=r.appName,e[24]=r.appVersion,e[25]=r.checks,e[26]=r.timestamp,e[27]=j,e[28]=Y,e[29]=C,e[30]=m,e[31]=t,e[32]=z,e[33]=I,e[34]=y,e[35]=N,e[36]=v,e[37]=S,e[38]=V,e[39]=b,e[40]=$,e[41]=H}else z=e[32],I=e[33],y=e[34],N=e[35],v=e[36],S=e[37],V=e[38],b=e[39],$=e[40],H=e[41];let P;e[102]!==z||e[103]!==S||e[104]!==V||e[105]!==b||e[106]!==$?(P=(0,a.jsxs)(z,{className:S,"data-testid":V,children:[b,$]}),e[102]=z,e[103]=S,e[104]=V,e[105]=b,e[106]=$,e[107]=P):P=e[107];let te;return e[108]!==I||e[109]!==y||e[110]!==N||e[111]!==v||e[112]!==P||e[113]!==H?(te=(0,a.jsxs)("div",{className:H,"data-testid":I,children:[y,N,v,P]}),e[108]=I,e[109]=y,e[110]=N,e[111]=v,e[112]=P,e[113]=H,e[114]=te):te=e[114],te},"Ie");function _e(n,e){return n.name.localeCompare(e.name)}k(_e,"be");export{De as DeploymentHealthPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as We,b as qe,c as De,d as Oe,e as be}from"./chunk-UU2QJMGJ.js";import"./chunk-2PJNAWB3.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as Re}from"./chunk-U6TNNM5U.js";import{a as Ve}from"./chunk-CTNB2KIA.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as Ke}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as ze}from"./chunk-LFKCLLPT.js";import{R as ke}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as ne}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as me}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as D}from"./chunk-ERMTJYQF.js";import{c as _e}from"./chunk-XDAT7LHC.js";import{f as Ne}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as Ce}from"./chunk-XQCVZAGU.js";import{a as Le,b as je,c as Fe,d as pe,e as q,f as R}from"./chunk-MIQTKZAR.js";import{a as Me,e as Ae}from"./chunk-UZERI5YC.js";import{d as ue,f as oe,g as we,h as Ee,m as de,q as Te}from"./chunk-OG4N2XHD.js";import{a as Ie,b as $e}from"./chunk-AADILRJW.js";import{a as o,e as ye,f as Be,g as Ge,h as He}from"./chunk-3XIESWL4.js";var ge=ye(Ge(),1);var O=ye(Be(),1);var t=ye(He(),1);var Se="none",Pe=["all","open","resolved","ignored"],Je=["critical","high","medium","low"],Qe=oe(D.resolveIssue),Xe=oe(D.ignoreIssue),Ue=oe(D.assignIssue),Ye=oe(D.setIssueSeverity),Ze=oe(D.explainIssue),es=o(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=o(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Ye"),ts=o(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=o(n=>{let e=(0,ge.c)(44),{expanded:d,issue:s,shardKey:$}=n,i=Ne(),r=ue(),[a,C]=(0,O.useState)(void 0),{busy:E,error:T,run:F}=Re(),_;e[0]!==i||e[1]!==s||e[2]!==F||e[3]!==$?(_=o(()=>{C(void 0),F(async()=>{let f={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,f,we($));C(I)})},"E"),e[0]=i,e[1]=s,e[2]=F,e[3]=$,e[4]=_):_=e[4];let K=_;if(!d)return null;let h;if(e[5]!==s.sampleMessage){let f=$e(s.sampleMessage);h=f===void 0?void 0:Ie(f.body),e[5]=s.sampleMessage,e[6]=h}else h=e[6];let M=h,z=`issues-detail-${s.hash}`,c;e[7]!==s.sampleMessage?(c=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=c):c=e[8];let x;e[9]!==r?(x=r("Suggested fix"),e[9]=r,e[10]=x):x=e[10];let y;e[11]!==x?(y=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=y):y=e[12];let w;e[13]!==M||e[14]!==s.hash||e[15]!==r?(w=M===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:r("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:M}),e[13]=M,e[14]=s.hash,e[15]=r,e[16]=w):w=e[16];let u;e[17]!==y||e[18]!==w?(u=(0,t.jsxs)("div",{children:[y,w]}),e[17]=y,e[18]=w,e[19]=u):u=e[19];let A=`issues-explain-${s.hash}`,m;e[20]!==E||e[21]!==r?(m=r(E?"Explaining\u2026":"Explain in plain language"),e[20]=E,e[21]=r,e[22]=m):m=e[22];let b;e[23]!==E||e[24]!==K||e[25]!==m||e[26]!==A?(b=(0,t.jsx)("div",{children:(0,t.jsx)(ne,{"data-testid":A,disabled:E,onClick:K,size:"sm",type:"button",variant:"outline",children:m})}),e[23]=E,e[24]=K,e[25]=m,e[26]=A,e[27]=b):b=e[27];let p;e[28]!==T||e[29]!==s.hash?(p=T!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:T}),e[28]=T,e[29]=s.hash,e[30]=p):p=e[30];let v;e[31]!==a||e[32]!==s.hash||e[33]!==r?(v=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?r("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):r("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:r("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:r("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:r("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=r,e[34]=v):v=e[34];let g;e[35]!==b||e[36]!==p||e[37]!==v||e[38]!==c||e[39]!==u?(g=(0,t.jsx)(R,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[c,u,b,p,v]})}),e[35]=b,e[36]=p,e[37]=v,e[38]=c,e[39]=u,e[40]=g):g=e[40];let S;return e[41]!==g||e[42]!==z?(S=(0,t.jsx)(pe,{"data-testid":z,children:g}),e[41]=g,e[42]=z,e[43]=S):S=e[43],S},"et"),is=o(n=>{let e=(0,ge.c)(119),{busy:d,issue:s,rowError:$,runTriage:i,shardKey:r}=n,a=ue(),[C,E]=(0,O.useState)(!1),T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=o(()=>{E(ls)},"_"),e[0]=T):T=e[0];let F=T,_;e[1]!==s.hash||e[2]!==i?(_=o(re=>{let ce=re===null||re===Se?null:re;de(i(s.hash,Ye,{severity:ce}))},"E"),e[1]=s.hash,e[2]=i,e[3]=_):_=e[3];let K=_,h;e[4]!==s.hash||e[5]!==i?(h=o(re=>{if(re.key!=="Enter")return;let ce=re.currentTarget.value.trim();de(i(s.hash,Ue,{assignee:ce===""?null:ce}))},"d"),e[4]=s.hash,e[5]=i,e[6]=h):h=e[6];let M=h,z=`issues-row-${s.hash}`,c;e[7]!==a?(c=a("Toggle issue details"),e[7]=a,e[8]=c):c=e[8];let x=`issues-toggle-${s.hash}`,y=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${C?"rotate-90":""}`,w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=w):w=e[9];let u;e[10]!==y?(u=(0,t.jsx)("svg",{"aria-hidden":"true",className:y,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:w}),e[10]=y,e[11]=u):u=e[11];let A;e[12]!==s.title?(A=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=A):A=e[13];let m;e[14]!==s.culprit?(m=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=m):m=e[15];let b;e[16]!==A||e[17]!==m?(b=(0,t.jsxs)("span",{className:"min-w-0",children:[A,m]}),e[16]=A,e[17]=m,e[18]=b):b=e[18];let p;e[19]!==C||e[20]!==b||e[21]!==c||e[22]!==x||e[23]!==u?(p=(0,t.jsxs)("button",{"aria-expanded":C,"aria-label":c,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:F,type:"button",children:[u,b]}),e[19]=C,e[20]=b,e[21]=c,e[22]=x,e[23]=u,e[24]=p):p=e[24];let v;e[25]!==s.hash||e[26]!==$?(v=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=v):v=e[27];let g;e[28]!==p||e[29]!==v?(g=(0,t.jsxs)(R,{className:"max-w-80",children:[p,v]}),e[28]=p,e[29]=v,e[30]=g):g=e[30];let S=`issues-status-${s.hash}`,f;e[31]!==s.status?(f=ss(s.status),e[31]=s.status,e[32]=f):f=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==f?(I=(0,t.jsx)(R,{children:(0,t.jsx)(me,{"data-testid":S,variant:f,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=f,e[36]=I):I=e[36];let j=s.severity??Se,L;e[37]!==a?(L=a("Set severity"),e[37]=a,e[38]=L):L=e[38];let l=`issues-severity-${s.hash}`,V;e[39]!==a?(V=a("\u2014"),e[39]=a,e[40]=V):V=e[40];let W;e[41]!==s.severity||e[42]!==a?(W=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=W):W=e[43];let N;e[44]!==V||e[45]!==W?(N=(0,t.jsx)(qe,{placeholder:V,children:W}),e[44]=V,e[45]=W,e[46]=N):N=e[46];let k;e[47]!==L||e[48]!==l||e[49]!==N?(k=(0,t.jsx)(De,{"aria-label":L,className:"h-7 w-[110px]","data-testid":l,children:N}),e[47]=L,e[48]=l,e[49]=N,e[50]=k):k=e[50];let U;e[51]===Symbol.for("react.memo_cache_sentinel")?(U=Je.map(rs),e[51]=U):U=e[51];let B;e[52]!==a?(B=a("Clear"),e[52]=a,e[53]=B):B=e[53];let G;e[54]!==B?(G=(0,t.jsxs)(Oe,{children:[U,(0,t.jsx)(be,{value:Se,children:B})]}),e[54]=B,e[55]=G):G=e[55];let H;e[56]!==d||e[57]!==K||e[58]!==j||e[59]!==k||e[60]!==G?(H=(0,t.jsx)(R,{children:(0,t.jsxs)(We,{disabled:d,onValueChange:K,value:j,children:[k,G]})}),e[56]=d,e[57]=K,e[58]=j,e[59]=k,e[60]=G,e[61]=H):H=e[61];let P;e[62]!==a?(P=a("Assignee"),e[62]=a,e[63]=P):P=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",J;e[64]!==a?(J=a("Unassigned"),e[64]=a,e[65]=J):J=e[65];let Q;e[66]!==d||e[67]!==M||e[68]!==P||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==J?(Q=(0,t.jsx)(R,{children:(0,t.jsx)(ke,{"aria-label":P,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:d,onKeyDown:M,placeholder:J},ve)}),e[66]=d,e[67]=M,e[68]=P,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=J,e[73]=Q):Q=e[73];let X;e[74]!==s.count?(X=(0,t.jsx)(R,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=X):X=e[75];let Y;e[76]!==s.lastSeen?(Y=Te(s.lastSeen),e[76]=s.lastSeen,e[77]=Y):Y=e[77];let Z;e[78]!==Y?(Z=(0,t.jsx)(R,{className:"text-xs tabular-nums text-muted-foreground",children:Y}),e[78]=Y,e[79]=Z):Z=e[79];let ee;e[80]!==d||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(ee=s.status!=="resolved"&&(0,t.jsx)(ne,{"data-testid":`issues-resolve-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=d,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=ee):ee=e[85];let se;e[86]!==d||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(se=s.status!=="ignored"&&(0,t.jsx)(ne,{"data-testid":`issues-ignore-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=d,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=se):se=e[91];let te;e[92]!==d||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(te=s.status!=="open"&&(0,t.jsx)(ne,{"data-testid":`issues-reopen-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Ue,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=d,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=te):te=e[98];let ae;e[99]!==ee||e[100]!==se||e[101]!==te?(ae=(0,t.jsx)(R,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[ee,se,te]})}),e[99]=ee,e[100]=se,e[101]=te,e[102]=ae):ae=e[102];let ie;e[103]!==g||e[104]!==I||e[105]!==H||e[106]!==Q||e[107]!==X||e[108]!==Z||e[109]!==z||e[110]!==ae?(ie=(0,t.jsxs)(pe,{"data-testid":z,children:[g,I,H,Q,X,Z,ae]}),e[103]=g,e[104]=I,e[105]=H,e[106]=Q,e[107]=X,e[108]=Z,e[109]=z,e[110]=ae,e[111]=ie):ie=e[111];let le;e[112]!==C||e[113]!==s||e[114]!==r?(le=(0,t.jsx)(as,{expanded:C,issue:s,shardKey:r},s.sampleMessage),e[112]=C,e[113]=s,e[114]=r,e[115]=le):le=e[115];let he;return e[116]!==ie||e[117]!==le?(he=(0,t.jsxs)(t.Fragment,{children:[ie,le]}),e[116]=ie,e[117]=le,e[118]=he):he=e[118],he},"tt"),ks=o(n=>{let e=(0,ge.c)(38),{initialShardKey:d}=n,s=ue(),$=Ne(),[i,r]=(0,O.useState)(d??""),[a,C]=(0,O.useState)("all"),[E,T]=(0,O.useState)(ns),[F,_]=(0,O.useState)(os),K;e[0]!==i?(K=i.trim(),e[0]=i,e[1]=K):K=e[1];let h=ze(K,400),M;e[2]!==a?(M=a==="all"?{}:{status:a},e[2]=a,e[3]=M):M=e[3];let z;e[4]!==h?(z={live:!0,shardKey:h},e[4]=h,e[5]=z):z=e[5];let{data:c,error:x,liveError:y}=_e(D.getIssues,M,z),w=c!==void 0,u;if(e[6]!==F||e[7]!==E||e[8]!==$||e[9]!==c||e[10]!==h||e[11]!==x||e[12]!==y||e[13]!==w||e[14]!==i||e[15]!==a||e[16]!==s){let A=es(c),m;e[18]!==$||e[19]!==h?(m=o(async(l,V,W)=>{_(N=>{if(!N.has(l))return N;let k=new Map(N);return k.delete(l),k}),T(N=>new Set(N).add(l));try{await $.query(V,{...W,hash:l},we(h))}catch(N){let k=Ee(N);_(U=>new Map(U).set(l,k))}T(N=>{let k=new Set(N);return k.delete(l),k})},"u"),e[18]=$,e[19]=h,e[20]=m):m=e[20];let b=m,p;e[21]!==s?(p=o(l=>s(l==="all"?"All":l==="open"?"Open":l==="resolved"?"Resolved":"Ignored"),"m"),e[21]=s,e[22]=p):p=e[22];let v=p,g;e[23]!==x?(g=x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:x}),e[23]=x,e[24]=g):g=e[24];let S;e[25]!==i?(S=(0,t.jsx)(Ke,{onChange:r,testId:"issues-shard-input",value:i}),e[25]=i,e[26]=S):S=e[26];let f;e[27]!==y?(f=(0,t.jsx)(Ve,{message:y,prefix:"issues"}),e[27]=y,e[28]=f):f=e[28];let I;e[29]!==a||e[30]!==v?(I=Pe.map(l=>(0,t.jsx)(ne,{"data-active":a===l?"":void 0,"data-testid":`issues-filter-${l}`,onClick:o(()=>{C(l)},"onClick"),size:"xs",variant:a===l?"default":"outline",children:v(l)},l)),e[29]=a,e[30]=v,e[31]=I):I=e[31];let j;e[32]!==I?(j=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:I}),e[32]=I,e[33]=j):j=e[33];let L;e[34]!==j||e[35]!==S||e[36]!==f?(L=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[S,f,j]}),e[34]=j,e[35]=S,e[36]=f,e[37]=L):L=e[37],u=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[g,L,w&&A.length===0?(0,t.jsx)(Ce,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ae,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"issues-table",children:[(0,t.jsx)(je,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(q,{children:s("Issue")}),(0,t.jsx)(q,{children:s("Status")}),(0,t.jsx)(q,{children:s("Severity")}),(0,t.jsx)(q,{children:s("Assignee")}),(0,t.jsx)(q,{className:"text-right",children:s("Events")}),(0,t.jsx)(q,{children:s("Last seen")}),(0,t.jsx)(q,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(Fe,{children:A.map(l=>(0,t.jsx)(is,{busy:E.has(l.hash),issue:l,rowError:F.get(l.hash),runTriage:b,shardKey:h},l.hash))})]})})})]}),e[6]=F,e[7]=E,e[8]=$,e[9]=c,e[10]=h,e[11]=x,e[12]=y,e[13]=w,e[14]=i,e[15]=a,e[16]=s,e[17]=u}else u=e[17];return u},"kt");function ls(n){return!n}o(ls,"st");function rs(n){return(0,t.jsx)(be,{value:n,children:n},n)}o(rs,"at");function ns(){return new Set}o(ns,"it");function os(){return new Map}o(os,"rt");export{ks as IssuesPanel};
|
|
1
|
+
import{a as We,b as qe,c as De,d as Oe,e as be}from"./chunk-UU2QJMGJ.js";import"./chunk-2PJNAWB3.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as Re}from"./chunk-U6TNNM5U.js";import{a as Ve}from"./chunk-CTNB2KIA.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as Ke}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{a as ze}from"./chunk-LFKCLLPT.js";import{R as ke}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as ne}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as me}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as D}from"./chunk-ERMTJYQF.js";import{c as _e}from"./chunk-YGKR536O.js";import{f as Ne}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as Ce}from"./chunk-XQCVZAGU.js";import{a as Le,b as je,c as Fe,d as pe,e as q,f as R}from"./chunk-MIQTKZAR.js";import{a as Me,e as Ae}from"./chunk-UZERI5YC.js";import{d as ue,f as oe,g as we,h as Ee,m as de,q as Te}from"./chunk-OG4N2XHD.js";import{a as Ie,b as $e}from"./chunk-QNUWWC3N.js";import{a as o,e as ye,f as Be,g as Ge,h as He}from"./chunk-3XIESWL4.js";var ge=ye(Ge(),1);var O=ye(Be(),1);var t=ye(He(),1);var Se="none",Pe=["all","open","resolved","ignored"],Je=["critical","high","medium","low"],Qe=oe(D.resolveIssue),Xe=oe(D.ignoreIssue),Ue=oe(D.assignIssue),Ye=oe(D.setIssueSeverity),Ze=oe(D.explainIssue),es=o(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=o(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Ye"),ts=o(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=o(n=>{let e=(0,ge.c)(44),{expanded:d,issue:s,shardKey:$}=n,i=Ne(),r=ue(),[a,C]=(0,O.useState)(void 0),{busy:E,error:T,run:F}=Re(),_;e[0]!==i||e[1]!==s||e[2]!==F||e[3]!==$?(_=o(()=>{C(void 0),F(async()=>{let f={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,f,we($));C(I)})},"E"),e[0]=i,e[1]=s,e[2]=F,e[3]=$,e[4]=_):_=e[4];let K=_;if(!d)return null;let h;if(e[5]!==s.sampleMessage){let f=$e(s.sampleMessage);h=f===void 0?void 0:Ie(f.body),e[5]=s.sampleMessage,e[6]=h}else h=e[6];let M=h,z=`issues-detail-${s.hash}`,c;e[7]!==s.sampleMessage?(c=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=c):c=e[8];let x;e[9]!==r?(x=r("Suggested fix"),e[9]=r,e[10]=x):x=e[10];let y;e[11]!==x?(y=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=y):y=e[12];let w;e[13]!==M||e[14]!==s.hash||e[15]!==r?(w=M===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:r("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:M}),e[13]=M,e[14]=s.hash,e[15]=r,e[16]=w):w=e[16];let u;e[17]!==y||e[18]!==w?(u=(0,t.jsxs)("div",{children:[y,w]}),e[17]=y,e[18]=w,e[19]=u):u=e[19];let A=`issues-explain-${s.hash}`,m;e[20]!==E||e[21]!==r?(m=r(E?"Explaining\u2026":"Explain in plain language"),e[20]=E,e[21]=r,e[22]=m):m=e[22];let b;e[23]!==E||e[24]!==K||e[25]!==m||e[26]!==A?(b=(0,t.jsx)("div",{children:(0,t.jsx)(ne,{"data-testid":A,disabled:E,onClick:K,size:"sm",type:"button",variant:"outline",children:m})}),e[23]=E,e[24]=K,e[25]=m,e[26]=A,e[27]=b):b=e[27];let p;e[28]!==T||e[29]!==s.hash?(p=T!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:T}),e[28]=T,e[29]=s.hash,e[30]=p):p=e[30];let v;e[31]!==a||e[32]!==s.hash||e[33]!==r?(v=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?r("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):r("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:r("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:r("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:r("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=r,e[34]=v):v=e[34];let g;e[35]!==b||e[36]!==p||e[37]!==v||e[38]!==c||e[39]!==u?(g=(0,t.jsx)(R,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[c,u,b,p,v]})}),e[35]=b,e[36]=p,e[37]=v,e[38]=c,e[39]=u,e[40]=g):g=e[40];let S;return e[41]!==g||e[42]!==z?(S=(0,t.jsx)(pe,{"data-testid":z,children:g}),e[41]=g,e[42]=z,e[43]=S):S=e[43],S},"et"),is=o(n=>{let e=(0,ge.c)(119),{busy:d,issue:s,rowError:$,runTriage:i,shardKey:r}=n,a=ue(),[C,E]=(0,O.useState)(!1),T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=o(()=>{E(ls)},"_"),e[0]=T):T=e[0];let F=T,_;e[1]!==s.hash||e[2]!==i?(_=o(re=>{let ce=re===null||re===Se?null:re;de(i(s.hash,Ye,{severity:ce}))},"E"),e[1]=s.hash,e[2]=i,e[3]=_):_=e[3];let K=_,h;e[4]!==s.hash||e[5]!==i?(h=o(re=>{if(re.key!=="Enter")return;let ce=re.currentTarget.value.trim();de(i(s.hash,Ue,{assignee:ce===""?null:ce}))},"d"),e[4]=s.hash,e[5]=i,e[6]=h):h=e[6];let M=h,z=`issues-row-${s.hash}`,c;e[7]!==a?(c=a("Toggle issue details"),e[7]=a,e[8]=c):c=e[8];let x=`issues-toggle-${s.hash}`,y=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${C?"rotate-90":""}`,w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=w):w=e[9];let u;e[10]!==y?(u=(0,t.jsx)("svg",{"aria-hidden":"true",className:y,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:w}),e[10]=y,e[11]=u):u=e[11];let A;e[12]!==s.title?(A=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=A):A=e[13];let m;e[14]!==s.culprit?(m=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=m):m=e[15];let b;e[16]!==A||e[17]!==m?(b=(0,t.jsxs)("span",{className:"min-w-0",children:[A,m]}),e[16]=A,e[17]=m,e[18]=b):b=e[18];let p;e[19]!==C||e[20]!==b||e[21]!==c||e[22]!==x||e[23]!==u?(p=(0,t.jsxs)("button",{"aria-expanded":C,"aria-label":c,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:F,type:"button",children:[u,b]}),e[19]=C,e[20]=b,e[21]=c,e[22]=x,e[23]=u,e[24]=p):p=e[24];let v;e[25]!==s.hash||e[26]!==$?(v=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=v):v=e[27];let g;e[28]!==p||e[29]!==v?(g=(0,t.jsxs)(R,{className:"max-w-80",children:[p,v]}),e[28]=p,e[29]=v,e[30]=g):g=e[30];let S=`issues-status-${s.hash}`,f;e[31]!==s.status?(f=ss(s.status),e[31]=s.status,e[32]=f):f=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==f?(I=(0,t.jsx)(R,{children:(0,t.jsx)(me,{"data-testid":S,variant:f,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=f,e[36]=I):I=e[36];let j=s.severity??Se,L;e[37]!==a?(L=a("Set severity"),e[37]=a,e[38]=L):L=e[38];let l=`issues-severity-${s.hash}`,V;e[39]!==a?(V=a("\u2014"),e[39]=a,e[40]=V):V=e[40];let W;e[41]!==s.severity||e[42]!==a?(W=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=W):W=e[43];let N;e[44]!==V||e[45]!==W?(N=(0,t.jsx)(qe,{placeholder:V,children:W}),e[44]=V,e[45]=W,e[46]=N):N=e[46];let k;e[47]!==L||e[48]!==l||e[49]!==N?(k=(0,t.jsx)(De,{"aria-label":L,className:"h-7 w-[110px]","data-testid":l,children:N}),e[47]=L,e[48]=l,e[49]=N,e[50]=k):k=e[50];let U;e[51]===Symbol.for("react.memo_cache_sentinel")?(U=Je.map(rs),e[51]=U):U=e[51];let B;e[52]!==a?(B=a("Clear"),e[52]=a,e[53]=B):B=e[53];let G;e[54]!==B?(G=(0,t.jsxs)(Oe,{children:[U,(0,t.jsx)(be,{value:Se,children:B})]}),e[54]=B,e[55]=G):G=e[55];let H;e[56]!==d||e[57]!==K||e[58]!==j||e[59]!==k||e[60]!==G?(H=(0,t.jsx)(R,{children:(0,t.jsxs)(We,{disabled:d,onValueChange:K,value:j,children:[k,G]})}),e[56]=d,e[57]=K,e[58]=j,e[59]=k,e[60]=G,e[61]=H):H=e[61];let P;e[62]!==a?(P=a("Assignee"),e[62]=a,e[63]=P):P=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",J;e[64]!==a?(J=a("Unassigned"),e[64]=a,e[65]=J):J=e[65];let Q;e[66]!==d||e[67]!==M||e[68]!==P||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==J?(Q=(0,t.jsx)(R,{children:(0,t.jsx)(ke,{"aria-label":P,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:d,onKeyDown:M,placeholder:J},ve)}),e[66]=d,e[67]=M,e[68]=P,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=J,e[73]=Q):Q=e[73];let X;e[74]!==s.count?(X=(0,t.jsx)(R,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=X):X=e[75];let Y;e[76]!==s.lastSeen?(Y=Te(s.lastSeen),e[76]=s.lastSeen,e[77]=Y):Y=e[77];let Z;e[78]!==Y?(Z=(0,t.jsx)(R,{className:"text-xs tabular-nums text-muted-foreground",children:Y}),e[78]=Y,e[79]=Z):Z=e[79];let ee;e[80]!==d||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(ee=s.status!=="resolved"&&(0,t.jsx)(ne,{"data-testid":`issues-resolve-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=d,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=ee):ee=e[85];let se;e[86]!==d||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(se=s.status!=="ignored"&&(0,t.jsx)(ne,{"data-testid":`issues-ignore-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=d,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=se):se=e[91];let te;e[92]!==d||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(te=s.status!=="open"&&(0,t.jsx)(ne,{"data-testid":`issues-reopen-${s.hash}`,disabled:d,onClick:o(()=>{de(i(s.hash,Ue,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=d,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=te):te=e[98];let ae;e[99]!==ee||e[100]!==se||e[101]!==te?(ae=(0,t.jsx)(R,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[ee,se,te]})}),e[99]=ee,e[100]=se,e[101]=te,e[102]=ae):ae=e[102];let ie;e[103]!==g||e[104]!==I||e[105]!==H||e[106]!==Q||e[107]!==X||e[108]!==Z||e[109]!==z||e[110]!==ae?(ie=(0,t.jsxs)(pe,{"data-testid":z,children:[g,I,H,Q,X,Z,ae]}),e[103]=g,e[104]=I,e[105]=H,e[106]=Q,e[107]=X,e[108]=Z,e[109]=z,e[110]=ae,e[111]=ie):ie=e[111];let le;e[112]!==C||e[113]!==s||e[114]!==r?(le=(0,t.jsx)(as,{expanded:C,issue:s,shardKey:r},s.sampleMessage),e[112]=C,e[113]=s,e[114]=r,e[115]=le):le=e[115];let he;return e[116]!==ie||e[117]!==le?(he=(0,t.jsxs)(t.Fragment,{children:[ie,le]}),e[116]=ie,e[117]=le,e[118]=he):he=e[118],he},"tt"),ks=o(n=>{let e=(0,ge.c)(38),{initialShardKey:d}=n,s=ue(),$=Ne(),[i,r]=(0,O.useState)(d??""),[a,C]=(0,O.useState)("all"),[E,T]=(0,O.useState)(ns),[F,_]=(0,O.useState)(os),K;e[0]!==i?(K=i.trim(),e[0]=i,e[1]=K):K=e[1];let h=ze(K,400),M;e[2]!==a?(M=a==="all"?{}:{status:a},e[2]=a,e[3]=M):M=e[3];let z;e[4]!==h?(z={live:!0,shardKey:h},e[4]=h,e[5]=z):z=e[5];let{data:c,error:x,liveError:y}=_e(D.getIssues,M,z),w=c!==void 0,u;if(e[6]!==F||e[7]!==E||e[8]!==$||e[9]!==c||e[10]!==h||e[11]!==x||e[12]!==y||e[13]!==w||e[14]!==i||e[15]!==a||e[16]!==s){let A=es(c),m;e[18]!==$||e[19]!==h?(m=o(async(l,V,W)=>{_(N=>{if(!N.has(l))return N;let k=new Map(N);return k.delete(l),k}),T(N=>new Set(N).add(l));try{await $.query(V,{...W,hash:l},we(h))}catch(N){let k=Ee(N);_(U=>new Map(U).set(l,k))}T(N=>{let k=new Set(N);return k.delete(l),k})},"u"),e[18]=$,e[19]=h,e[20]=m):m=e[20];let b=m,p;e[21]!==s?(p=o(l=>s(l==="all"?"All":l==="open"?"Open":l==="resolved"?"Resolved":"Ignored"),"m"),e[21]=s,e[22]=p):p=e[22];let v=p,g;e[23]!==x?(g=x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:x}),e[23]=x,e[24]=g):g=e[24];let S;e[25]!==i?(S=(0,t.jsx)(Ke,{onChange:r,testId:"issues-shard-input",value:i}),e[25]=i,e[26]=S):S=e[26];let f;e[27]!==y?(f=(0,t.jsx)(Ve,{message:y,prefix:"issues"}),e[27]=y,e[28]=f):f=e[28];let I;e[29]!==a||e[30]!==v?(I=Pe.map(l=>(0,t.jsx)(ne,{"data-active":a===l?"":void 0,"data-testid":`issues-filter-${l}`,onClick:o(()=>{C(l)},"onClick"),size:"xs",variant:a===l?"default":"outline",children:v(l)},l)),e[29]=a,e[30]=v,e[31]=I):I=e[31];let j;e[32]!==I?(j=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:I}),e[32]=I,e[33]=j):j=e[33];let L;e[34]!==j||e[35]!==S||e[36]!==f?(L=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[S,f,j]}),e[34]=j,e[35]=S,e[36]=f,e[37]=L):L=e[37],u=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[g,L,w&&A.length===0?(0,t.jsx)(Ce,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ae,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"issues-table",children:[(0,t.jsx)(je,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(q,{children:s("Issue")}),(0,t.jsx)(q,{children:s("Status")}),(0,t.jsx)(q,{children:s("Severity")}),(0,t.jsx)(q,{children:s("Assignee")}),(0,t.jsx)(q,{className:"text-right",children:s("Events")}),(0,t.jsx)(q,{children:s("Last seen")}),(0,t.jsx)(q,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(Fe,{children:A.map(l=>(0,t.jsx)(is,{busy:E.has(l.hash),issue:l,rowError:F.get(l.hash),runTriage:b,shardKey:h},l.hash))})]})})})]}),e[6]=F,e[7]=E,e[8]=$,e[9]=c,e[10]=h,e[11]=x,e[12]=y,e[13]=w,e[14]=i,e[15]=a,e[16]=s,e[17]=u}else u=e[17];return u},"kt");function ls(n){return!n}o(ls,"st");function rs(n){return(0,t.jsx)(be,{value:n,children:n},n)}o(rs,"at");function ns(){return new Set}o(ns,"it");function os(){return new Map}o(os,"rt");export{ks as IssuesPanel};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`),header:"No Lunora schema found",id:"lunora-schema-missing",test:
|
|
3
|
-
`),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:
|
|
4
|
-
`),header:"Table name is reserved",id:"lunora-table-reserved",test:
|
|
5
|
-
`),header:"Duplicate table name",id:"lunora-table-duplicate",test:
|
|
6
|
-
`),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:
|
|
7
|
-
`),header:"`unique` must be a literal",id:"lunora-unique-literal",test:
|
|
8
|
-
`),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:
|
|
9
|
-
`),header:"Unique constraint violation",id:"lunora-runtime-unique",test:
|
|
10
|
-
`),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:
|
|
11
|
-
`),header:`Cloudflare Error ${e.code}: ${e.title}`,id:`cloudflare-error-${e.code}`}),"c"),p=
|
|
1
|
+
import{a as r}from"./chunk-3XIESWL4.js";var n="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/",s="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/",l={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["`.unique()` matched more than one document \u2014 it expects the query to identify at most one row.","","- If several matches are legitimate, use `.first()` (take one) or `.collect()` (take all) instead.","- Otherwise tighten the query (e.g. filter on a unique/indexed field) so it can only match one row."],status:400,title:"Query matched more than one document"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},RUN_DEPTH_EXCEEDED:{internal:!0,status:500,title:"Run depth exceeded"},TRANSACTION_LIMIT_EXCEEDED:{hint:["A single mutation may only read and write a bounded amount before it is stopped.","","Narrow the read with an index (`.withIndex(...)`) instead of scanning the table, or split the write across several mutations \u2014 for a large backfill use `defineMigration` + `lunora migrate up`, which batches and checkpoints for you.","","The ceilings are deliberately conservative \u2014 they exist to stop one request taking down the whole shard. A deployment that genuinely needs bigger transactions can raise them by overriding the `transactionLimits()` seam on its generated shard class."],status:413,title:"Transaction limit exceeded"},MIGRATION_NOT_FOUND:{status:404,title:"Data migration not found"},UNKNOWN_TABLE:{status:404,title:"Unknown table"},GLOBAL_TABLE_NOT_EDITABLE:{status:400,title:"Global table is not editable"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{internal:!0,status:500,title:"Invalid environment"},AUTH_HEADERS_MISSING:{internal:!0,status:500,title:"Auth headers missing"},EMAIL_DOMAIN_BLOCKED:{hint:["This address's domain is on the disposable/throwaway blocklist (or your configured deny-list).","","Sign up with a permanent mailbox. To tune the policy, pass `blockDisposable` / `allowDomains` / `denyDomains` to `emailGate(...)` (`@lunora/auth/email-guard`)."],status:400,title:"Email domain not allowed"},EMAIL_UNDELIVERABLE:{hint:["The address's domain publishes no MX (or fallback A/AAAA) records, so it can't receive mail.","","Check for a typo in the domain. MX verification is opt-in (`mx: true`) and needs DNS \u2014 leave it off on the edge path if DNS is unavailable."],status:400,title:"Email domain cannot receive mail"},ANALYTICS_SQL_ERROR:{status:502,title:"Analytics Engine SQL API error"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"}},f=r(e=>Object.hasOwn(l,e)?l[e]:void 0,"h");var m=[{body:["Lunora codegen couldn't find a schema to generate from.","","Create `lunora/schema.ts` exporting a `defineSchema(...)` call:","","```ts",'import { defineSchema, defineTable, v } from "@lunora/server";',"","export default defineSchema({"," messages: defineTable({ body: v.string() }),","});","```","","Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."].join(`
|
|
2
|
+
`),header:"No Lunora schema found",id:"lunora-schema-missing",test:r(e=>e.includes("defineSchema() not found")||e.includes("schema.ts not found at"),"test")},{body:["`defineSchema(...)` must be called with an **inline object literal** mapping table names to `defineTable(...)`:","","```ts","export default defineSchema({"," todos: defineTable({ title: v.string(), done: v.boolean() }),","});","```","","Codegen reads the schema statically, so it can't follow a variable or a spread \u2014 pass the object literal directly."].join(`
|
|
3
|
+
`),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:r(e=>e.includes("defineSchema() expects an object literal"),"test")},{body:["This table name collides with a built-in `ctx.db` member, so the generated client can't expose it.","","Rename the table to anything that isn't a reserved name (the error lists them) \u2014 e.g. `userAccounts` instead of `insert`."].join(`
|
|
4
|
+
`),header:"Table name is reserved",id:"lunora-table-reserved",test:r(e=>e.includes("is reserved")&&e.includes("ctx.db"),"test")},{body:["Two tables resolve to the same name \u2014 usually a base table and a schema **extension** both defining it.","","Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."].join(`
|
|
5
|
+
`),header:"Duplicate table name",id:"lunora-table-duplicate",test:r(e=>e.includes("already exists")&&e.includes(".extend("),"test")},{body:['`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',"","```ts",'defineSchema({ /* \u2026 */ }).jurisdiction("eu");',"```"].join(`
|
|
6
|
+
`),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:r(e=>e.includes("unknown jurisdiction")||e.includes("jurisdiction")&&e.includes('"eu", "us", or "fedramp"'),"test")},{body:["The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value \u2014 codegen needs to read it statically:","","```ts",'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',"```"].join(`
|
|
7
|
+
`),header:"`unique` must be a literal",id:"lunora-unique-literal",test:r(e=>e.includes("must be a literal")&&e.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
|
|
8
|
+
`),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:r(e=>e.includes("not exported by your worker entry"),"test")},{body:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`].join(`
|
|
9
|
+
`),header:"Unique constraint violation",id:"lunora-runtime-unique",test:r(e=>e.includes("unique constraint violation on"),"test")},{body:l.CONFLICT.hint.join(`
|
|
10
|
+
`),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:r(e=>e.includes("optimistic concurrency conflict"),"test")}],d=[{causes:"the origin returned an empty, unknown, or malformed response Cloudflare couldn't interpret (often an origin crash or an oversized response header)",code:"520",docsUrl:n,family:"5xx",fix:"check your origin's logs for a crash, ensure it returns a valid HTTP response, and keep response headers under the size limit",summary:"Cloudflare got an unknown/empty response from your origin web server.",title:"Web server returns an unknown error"},{causes:"the origin refused the connection \u2014 the web server is down, or a firewall is blocking Cloudflare's IP ranges",code:"521",docsUrl:n,family:"5xx",fix:"confirm the origin process is running and allowlist Cloudflare's published IP ranges in your firewall/security groups",summary:"Cloudflare could not connect to your origin because it refused the connection.",title:"Web server is down"},{causes:"Cloudflare could not establish a TCP connection to the origin in time \u2014 the origin is overloaded, a firewall is dropping packets, or the origin IP is wrong",code:"522",docsUrl:n,family:"5xx",fix:"verify the origin is reachable and not overloaded, and that the DNS record points at the correct origin IP",summary:"The connection to your origin timed out before it was established.",title:"Connection timed out"},{causes:"Cloudflare cannot route to the origin at all \u2014 a bad DNS record, an origin IP that changed, or invalid routing",code:"523",docsUrl:n,family:"5xx",fix:"verify the DNS A/AAAA record points at a reachable origin IP and that no upstream network is blocking Cloudflare",summary:"Cloudflare could not reach your origin server.",title:"Origin is unreachable"},{causes:"Cloudflare made a TCP connection but the origin did not return an HTTP response within 100 seconds \u2014 a slow handler or long-running request",code:"524",docsUrl:n,family:"5xx",fix:"speed up the slow origin handler, or move long work off the request path into a background job (a Durable Object, Queue, or Workflow)",summary:"Cloudflare connected to your origin but it did not respond in time.",title:"A timeout occurred"},{causes:"the TLS handshake between Cloudflare and the origin failed \u2014 a missing/invalid origin certificate, or a cipher/SNI mismatch under Full (Strict) SSL",code:"525",docsUrl:n,family:"5xx",fix:"install a valid certificate on the origin and align your Cloudflare SSL/TLS mode with the origin's certificate setup",summary:"The SSL handshake with your origin failed.",title:"SSL handshake failed"},{causes:"Cloudflare could not validate the origin's certificate under Full (Strict) SSL \u2014 it is expired, self-signed, or issued for the wrong hostname",code:"526",docsUrl:n,family:"5xx",fix:"install a valid, publicly-trusted certificate on the origin (or use a Cloudflare Origin CA cert), matching the request hostname",summary:"Cloudflare could not validate your origin's SSL certificate.",title:"Invalid SSL certificate"},{causes:"a DNS record points at a Cloudflare IP or another prohibited address instead of your real origin",code:"1000",docsUrl:s,family:"1xxx",fix:"point the DNS record at your real origin IP, not a Cloudflare-owned or loopback address",summary:"DNS points to a prohibited IP.",title:"DNS points to prohibited IP"},{causes:"Cloudflare could not resolve the requested hostname \u2014 a Worker fetched an unresolvable host, or a DNS record is misconfigured",code:"1001",docsUrl:s,family:"1xxx",fix:"check the hostname you're requesting and the DNS records for the zone resolve to a valid origin",summary:"Cloudflare could not resolve the origin DNS.",title:"DNS resolution error"},{causes:"a Worker or DNS record targets a restricted IP (for example a Cloudflare-owned or loopback address)",code:"1002",docsUrl:s,family:"1xxx",fix:"change the Worker fetch target or DNS record to a valid, non-restricted origin address",summary:"DNS points to a prohibited IP (Worker/restricted).",title:"DNS points to a prohibited IP"},{causes:"the visitor's IP was blocked by an IP Access Rule, WAF rule, or security configuration on the zone",code:"1006",docsUrl:s,family:"1xxx",fix:"review the zone's Firewall/WAF and IP Access Rules to see why the address was banned, and adjust if it was blocked in error",summary:"Access denied: the visitor's IP has been banned.",title:"Access denied: your IP has been banned"},{causes:"your Worker threw an unhandled JavaScript exception during the request",code:"1101",docsUrl:s,family:"1xxx",fix:"reproduce with `wrangler tail` (or the Workers Logs / Studio Logs panel) to get the stack trace, then handle the throwing code path",summary:"A Worker threw a JavaScript exception.",title:"Worker threw a JavaScript exception"},{causes:"the Worker used more CPU time than a single invocation is allowed \u2014 usually a hot loop or heavy synchronous work",code:"1102",docsUrl:s,family:"1xxx",fix:"reduce per-request CPU (optimize hot loops, avoid heavy synchronous work) or offload the heavy work to a Durable Object, Queue, or Workflow",summary:"A Worker exceeded its CPU-time resource limit.",title:"Worker exceeded resource limits"}],u=r(e=>e!==void 0&&e>="0"&&e<="9","l"),y=r((e,t)=>{for(let i=e.indexOf(t);i!==-1;i=e.indexOf(t,i+t.length))if(!u(e[i-1])&&!u(e[i+t.length]))return!0;return!1},"m"),b=r((e,t)=>{for(let i of[`error ${t}`,`error: ${t}`])for(let o=e.indexOf(i);o!==-1;o=e.indexOf(i,o+i.length))if(!u(e[o+i.length]))return!0;return!1},"g"),S=/error|cloudflare/iu,h=r(e=>({body:[e.summary,"",`**Likely cause:** ${e.causes}.`,"",`**Fix:** ${e.fix}.`,"",`See [Cloudflare's ${e.family} error docs](${e.docsUrl}).`].join(`
|
|
11
|
+
`),header:`Cloudflare Error ${e.code}: ${e.title}`,id:`cloudflare-error-${e.code}`}),"c"),p=r(e=>{if(!S.test(e))return;let t=e.toLowerCase(),i=t.includes("error"),o=t.includes("cloudflare");if(i){for(let a of d)if(b(t,a.code))return h(a)}if(o){for(let a of d)if(y(t,a.code))return h(a)}},"y"),x=r(e=>(typeof e=="string"?e:e.join(`
|
|
12
12
|
`)).split(`
|
|
13
13
|
`).filter(t=>!t.startsWith("```")).join(`
|
|
14
|
-
`).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"
|
|
14
|
+
`).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"x"),g=r(e=>{for(let t of m)if(t.test(e))return{body:t.body,header:t.header,id:t.id}},"d"),E=r(e=>g(e)??p(e),"S");var c=class extends Error{static{r(this,"c")}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;constructor(t,i,o={}){let a=f(t);super(i??t,o.cause===void 0?void 0:{cause:o.cause}),this.name=o.name??"LunoraError",this.hint=o.hint??a?.hint,this.title=o.title??a?.title,this.loc=o.location,this.code=t,this.status=o.status??a?.status??500,this.docsUrl=o.docsUrl??a?.docsUrl,this.data=o.data}};export{x as a,E as b,c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as B}from"./chunk-XF2B7P5A.js";import{b as A}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as P}from"./chunk-
|
|
1
|
+
import{b as B}from"./chunk-XF2B7P5A.js";import{b as A}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as P}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as M}from"./chunk-ERMTJYQF.js";import{c as F}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as R,b as q,c as z,d as K,e as _,f as C}from"./chunk-MIQTKZAR.js";import{a as D,e as j}from"./chunk-UZERI5YC.js";import{d as V}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as k,e as O,g as H,h as W}from"./chunk-3XIESWL4.js";var G=O(H(),1);var t=O(W(),1);var $={binding:"outline",secret:"destructive",var:"secondary"},J=k((n,e)=>{if(n===void 0)return[];let m=[];return n.workerUrl!==void 0&&m.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&m.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&m.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&m.push({label:e("Version"),value:n.versionTag}),m},"B"),le=k(n=>{let e=(0,G.c)(52),{initialShardKey:m}=n,r=V(),w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];let E=m??"",S;e[1]!==E?(S={shardKey:E},e[1]=E,e[2]=S):S=e[2];let{data:s,error:l,errorSource:b,isLoading:U}=F(M.getSettings,w,S),a,c,p,d,o,i,u;if(e[3]!==l||e[4]!==b||e[5]!==s?.deploy||e[6]!==s?.settings||e[7]!==r){let L=J(s?.deploy,r),T;e[15]!==s?.settings?(T=s?.settings??[],e[15]=s?.settings,e[16]=T):T=e[16],a=T,c="flex flex-col gap-4",p="lunora-settings";let y;e[17]!==r?(y=r("Open in Cloudflare"),e[17]=r,e[18]=y):y=e[18],e[19]!==y?(d=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:B,rel:"noreferrer",target:"_blank",children:y})}),e[19]=y,e[20]=d):d=e[20];let N;e[21]!==r?(N=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=N):N=e[22],e[23]!==N?(o=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:N}),e[23]=N,e[24]=o):o=e[24],e[25]!==l||e[26]!==b?(i=l!==null&&(0,t.jsx)(P,{error:b,testId:"set-error"}),e[25]=l,e[26]=b,e[27]=i):i=e[27],u=L.length>0&&(0,t.jsxs)(D,{className:"py-0","data-testid":"set-deploy",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Deployment")})}),(0,t.jsx)(j,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:L.map(Q)})})]}),e[3]=l,e[4]=b,e[5]=s?.deploy,e[6]=s?.settings,e[7]=r,e[8]=a,e[9]=c,e[10]=p,e[11]=d,e[12]=o,e[13]=i,e[14]=u}else a=e[8],c=e[9],p=e[10],d=e[11],o=e[12],i=e[13],u=e[14];let h;e[28]!==r?(h=r("Environment & bindings"),e[28]=r,e[29]=h):h=e[29];let f;e[30]!==h?(f=(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h})}),e[30]=h,e[31]=f):f=e[31];let g;e[32]!==l||e[33]!==U||e[34]!==a.length||e[35]!==r?(g=l===null&&!U&&a.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[32]=l,e[33]=U,e[34]=a.length,e[35]=r,e[36]=g):g=e[36];let x;e[37]!==a||e[38]!==r?(x=a.length>0&&(0,t.jsx)(j,{className:"px-0 py-0",children:(0,t.jsxs)(R,{"data-testid":"set-table",children:[(0,t.jsx)(q,{children:(0,t.jsxs)(K,{children:[(0,t.jsx)(_,{children:r("name")}),(0,t.jsx)(_,{children:r("kind")}),(0,t.jsx)(_,{children:r("value")})]})}),(0,t.jsx)(z,{children:a.map(X)})]})}),e[37]=a,e[38]=r,e[39]=x):x=e[39];let v;e[40]!==f||e[41]!==g||e[42]!==x?(v=(0,t.jsxs)(D,{className:"py-0",children:[f,g,x]}),e[40]=f,e[41]=g,e[42]=x,e[43]=v):v=e[43];let I;return e[44]!==v||e[45]!==c||e[46]!==p||e[47]!==d||e[48]!==o||e[49]!==i||e[50]!==u?(I=(0,t.jsxs)("div",{className:c,"data-testid":p,children:[d,o,i,u,v]}),e[44]=v,e[45]=c,e[46]=p,e[47]=d,e[48]=o,e[49]=i,e[50]=u,e[51]=I):I=e[51],I},"le");function Q(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}k(Q,"G");function X(n){return(0,t.jsxs)(K,{"data-testid":"set-row",children:[(0,t.jsx)(C,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(C,{children:(0,t.jsx)(A,{variant:$[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(C,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}k(X,"H");export{le as SettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T}from"./chunk-V53KNYRN.js";import{a as O}from"./chunk-5Y3QLNWX.js";import{b as v}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as k}from"./chunk-
|
|
1
|
+
import{a as T}from"./chunk-V53KNYRN.js";import{a as O}from"./chunk-5Y3QLNWX.js";import{b as v}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as k}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as S}from"./chunk-ERMTJYQF.js";import{c as b}from"./chunk-YGKR536O.js";import"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as c}from"./chunk-XQCVZAGU.js";import{a as w,b as A,c as F,d as f,e as l,f as s}from"./chunk-MIQTKZAR.js";import{a as y,e as N}from"./chunk-UZERI5YC.js";import{d as x}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as n,e as p,f as L,h as _}from"./chunk-3XIESWL4.js";var C=p(L(),1);var e=p(_(),1);var q=n(a=>{let t=a.trim();if(t.length===0)return{context:void 0,error:null};try{let o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},"L"),D='{ "targetingKey": "user-123", "plan": "premium" }',M=n(a=>a.type==="object"?JSON.stringify(a.value):String(a.value),"_"),Y=n(({initialShardKey:a=""})=>{let t=x(),[o,j]=(0,C.useState)(""),{context:g,error:m}=q(o),I=g===void 0?{}:{context:g},{data:i,error:J,errorSource:K,liveError:E}=b(S.listFlags,I,{live:!0,shardKey:a}),u=i!==void 0,V=i?.configured??!1,h=Array.isArray(i?.flags)?[...i.flags].toSorted((r,$)=>r.key.localeCompare($.key)):[],d;return u&&!V?d=(0,e.jsx)(c,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):u&&h.length===0?d=(0,e.jsx)(c,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"flags-table",children:[(0,e.jsx)(A,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(l,{children:t("Key")}),(0,e.jsx)(l,{children:t("Type")}),(0,e.jsx)(l,{children:t("Value")}),(0,e.jsx)(l,{children:t("Reason")}),(0,e.jsx)(l,{children:t("Variant")})]})}),(0,e.jsx)(F,{children:h.map(r=>(0,e.jsxs)(f,{"data-testid":`flags-row-${r.key}`,children:[(0,e.jsx)(s,{className:"font-mono text-xs",children:r.key}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.type}),(0,e.jsx)(s,{className:"font-mono text-xs",children:M(r)}),(0,e.jsx)(s,{children:r.errorCode===void 0?(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"\u2014"}):(0,e.jsx)(v,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),(0,e.jsx)(s,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"\u2014"})]},r.key))})]})})}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[J!==null&&(0,e.jsx)(k,{error:K,testId:"flags-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,e.jsx)(O,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),(0,e.jsx)(T,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:n(r=>{j(r.target.value)},"onChange"),placeholder:D,rows:3,value:o}),m!==null&&(0,e.jsx)("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(m)}),E!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})},"X");export{Y as FlagsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ke}from"./chunk-V53KNYRN.js";import{a as T}from"./chunk-5Y3QLNWX.js";import{a as Pe}from"./chunk-CTNB2KIA.js";import{a as be}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as M}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as F}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as j}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as ge}from"./chunk-53WEPGUD.js";import"./chunk-XXQUMVWH.js";import"./chunk-RNL6BSFM.js";import"./chunk-QLQADHFE.js";import{a as Z}from"./chunk-ERMTJYQF.js";import{c as ae}from"./chunk-XDAT7LHC.js";import{f as oe}from"./chunk-EN2QAEO4.js";import"./chunk-XBDKZZ67.js";import{a as de}from"./chunk-XQCVZAGU.js";import{a as Ne,b as ve,c as we,d as ce,e as le,f as re}from"./chunk-MIQTKZAR.js";import{a as se,b as pe,c as fe,d as ue,e as ne}from"./chunk-UZERI5YC.js";import{d as Y,f as he,g as xe,h as ye,m as te}from"./chunk-OG4N2XHD.js";import"./chunk-AADILRJW.js";import{a as d,e as ie,f as Ae,g as Ie,h as Fe}from"./chunk-3XIESWL4.js";var p=ie(Ae(),1);var me=ie(Ie(),1);var t=ie(Fe(),1);var Ce=["read","insert","update","delete"],Te=d((e,a)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[a],"$e"),Ee=d(e=>{let a=new Set;for(let i of e?.advisories??[])if(i.name==="rls_uncovered_table"){let{table:s}=i.metadata;typeof s=="string"&&s!==""&&a.add(s)}return a},"Ae"),ze=d((e,a,i)=>{let s=new Map,l=d(n=>{let o=s.get(n);if(o!==void 0)return o;let f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:i.has(n)};return s.set(n,f),f},"r");for(let n of e)l(n.table).cells[n.on]={procedure:n.procedure};for(let n of a)l(n.table).maskedColumns.add(n.column);for(let n of i)l(n);return[...s.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},"Fe"),$e=d(e=>{let a=(0,me.c)(17),i;a[0]!==e?(i=e===void 0?{}:e,a[0]=e,a[1]=i):i=a[1];let{onProbe:s}=i,l=Y(),n,o;a[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},a[2]=n,a[3]=o):(n=a[2],o=a[3]);let f=ae(Z.rlsPolicies,n,o),r;a[4]===Symbol.for("react.memo_cache_sentinel")?(r={},a[4]=r):r=a[4];let b=ae(Z.maskPolicies,r),h;a[5]===Symbol.for("react.memo_cache_sentinel")?(h={},a[5]=h):h=a[5];let g=ae(Z.getAdvisories,h),N;if(a[6]!==g.data||a[7]!==b.data||a[8]!==s||a[9]!==f||a[10]!==l){let v=null;f.data!==void 0&&(v=Array.isArray(f.data.policies)?f.data.policies:[]);let E=Array.isArray(b.data?.columns)?b.data.columns:[],R=g.data??null,{error:C,errorSource:w,liveError:S}=f,A=v===null?[]:ze(v,E,Ee(R)),k;a[12]!==S?(k=(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)(Pe,{message:S,prefix:"pm"})}),a[12]=S,a[13]=k):k=a[13];let x;a[14]!==C||a[15]!==w?(x=C!==null&&(0,t.jsx)(ge,{error:w,testId:"pm-error"}),a[14]=C,a[15]=w,a[16]=x):x=a[16],N=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,x,v!==null&&A.length===0?(0,t.jsx)(de,{description:l("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:l("No policy")}):(0,t.jsxs)(Ne,{"data-testid":"pm-table",children:[(0,t.jsx)(ve,{children:(0,t.jsxs)(ce,{children:[(0,t.jsx)(le,{children:l("Table")}),Ce.map(c=>(0,t.jsx)(le,{children:Te(l,c)},c)),(0,t.jsx)(le,{children:l("Masked columns")})]})}),(0,t.jsx)(we,{children:A.map(c=>(0,t.jsxs)(ce,{"data-testid":`pm-row-${c.table}`,children:[(0,t.jsx)(re,{className:"font-mono text-xs",children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&(0,t.jsx)(j,{"data-testid":`pm-uncovered-${c.table}`,title:l("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:l("Uncovered \u2014 reachable without a policy")})]})}),Ce.map(_=>{let y=c.cells[_];return(0,t.jsx)(re,{"data-testid":`pm-cell-${c.table}-${_}`,children:y.procedure===void 0?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l("No policy")}):(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Covered by {procedure}",{procedure:y.procedure})}),s!==void 0&&(0,t.jsx)(F,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${_}`,onClick:d(()=>{s(c.table,_,y.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Probe this")})]})},_)}),(0,t.jsx)(re,{children:c.maskedColumns.size===0?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Le)})})]},c.table))})]})]}),a[6]=g.data,a[7]=b.data,a[8]=s,a[9]=f,a[10]=l,a[11]=N}else N=a[11];return N},"Ee");function Le(e){return(0,t.jsx)(j,{variant:"outline",children:e},e)}d(Le,"Te");var Oe=he(Z.runAs),Re=d(()=>{let e=oe();return async({args:a,functionPath:i,shardKey:s="",userId:l})=>{let n=Oe;try{return{kind:"allowed",value:await e.query(n,{args:a,functionPath:i,userId:l},xe(s))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},"Re"),je=d(e=>e===void 0?"undefined":JSON.stringify(e,null,2),"Me"),Me=d(({functions:e,prefill:a,runAsIdentity:i=!1}={})=>{let s=oe(),l=Y(),n=Re(),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(null),h=e??o??[],[g,N]=(0,p.useState)(""),[v,E]=(0,p.useState)("{}"),[R,C]=(0,p.useState)(""),[w,S]=(0,p.useState)(""),[A,k]=(0,p.useState)(!1),[x,c]=(0,p.useState)(null),[_,y]=(0,p.useState)(null),I=(0,p.useRef)(-1);(0,p.useEffect)(()=>{if(e!==void 0)return;let m=!1;return s.listFunctions().then(u=>(m||f(u),u)).catch(u=>{m||b(ye(u))}),()=>{m=!0}},[s,e]),(0,p.useEffect)(()=>{if(a===void 0||I.current===a.nonce)return;I.current=a.nonce;let m=a.functionPath;queueMicrotask(()=>{N(m),c(null)})},[a]);let P=g===""?h[0]?.path??"":g,z=d(async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(u){y(l("Invalid JSON args: {message}",{message:u.message})),c(null);return}y(null),k(!0);try{let u=await n({args:m,functionPath:P,shardKey:R.trim(),userId:w.trim()});c(u)}finally{k(!1)}},"F"),$=d(()=>{te(z())},"E"),H=d(m=>{N(m.target.value)},"B"),L=d(m=>{E(m.target.value)},"T"),O=d(m=>{S(m.target.value)},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!i&&(0,t.jsx)(de,{description:l("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:l("Set `runAsIdentity` to forge an identity and probe access.")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-function",children:l("Function")}),(0,t.jsx)("select",{"aria-label":l("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:H,value:P,children:h.map(m=>(0,t.jsxs)("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-args",children:l("Arguments")}),(0,t.jsx)(ke,{"aria-label":l("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:L,value:v})]}),(0,t.jsx)(be,{onChange:C,testId:"pp-shard",value:R}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-user",children:l("Run as (userId)")}),(0,t.jsx)(M,{"aria-label":l("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:O,placeholder:l("Leave empty to run as admin"),value:w})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(F,{"data-testid":"pp-run",disabled:!i||A||P==="",onClick:$,type:"button",children:l(A?"Probing\u2026":"Run probe")}),w.trim()!==""&&(0,t.jsx)(j,{"data-testid":"pp-as-badge",variant:"secondary",children:l("as {userId}",{userId:w.trim()})})]})]}),_!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:_}),x!==null&&x.kind==="allowed"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Allowed")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:je(x.value)})]}),x!==null&&x.kind==="denied"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,t.jsx)(j,{variant:"destructive",children:l("Denied")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:x.message})]})]})},"Oe"),qe="/__lunora/policy-scaffold",De={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Je=d(async e=>{let a=await fetch(qe,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await a.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(a.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};let s=i.error;return{kind:"error",message:s===void 0?`policy scaffold failed (${String(a.status)})`:De[s]??s}},"qe"),Se={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ke=d(()=>{let e=(0,me.c)(69),a=Y(),[i,s]=(0,p.useState)(null),[l,n]=(0,p.useState)(!1),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(Se),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=d(ee=>{let G=ee.target.name,{value:V}=ee.target;b(_e=>({..._e,[G]:V}))},"u"),e[0]=h):h=e[0];let g=h,N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=d(()=>{s(null),b(Se)},"N"),e[1]=N):N=e[1];let v=N,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=d(async ee=>{n(!0),f(null);try{let G=await Je(ee);f(G),G.kind==="ok"&&v()}catch(G){let V=G;f({kind:"error",message:V instanceof Error?V.message:String(V)})}n(!1)},"A"),e[2]=E):E=e[2];let R=E,C;e[3]!==r.policyName||e[4]!==r.tableName?(C=d(()=>{te(R({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"S"),e[3]=r.policyName,e[4]=r.tableName,e[5]=C):C=e[5];let w=C,S;e[6]!==r.exportName||e[7]!==r.filePath||e[8]!==r.policies?(S=d(()=>{te(R({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"C"),e[6]=r.exportName,e[7]=r.filePath,e[8]=r.policies,e[9]=S):S=e[9];let A=S,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=d(()=>{f(null),s("scaffold")},"k"),e[10]=k):k=e[10];let x=k,c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=d(()=>{f(null),s("wire")},"c"),e[11]=c):c=e[11];let _=c,y;e[12]!==a?(y=a("Scaffold access rules"),e[12]=a,e[13]=y):y=e[13];let I;e[14]!==y?(I=(0,t.jsx)(fe,{children:y}),e[14]=y,e[15]=I):I=e[15];let P;e[16]!==a?(P=a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=a,e[17]=P):P=e[17];let z;e[18]!==P?(z=(0,t.jsx)(ue,{children:P}),e[18]=P,e[19]=z):z=e[19];let $;e[20]!==z||e[21]!==I?($=(0,t.jsxs)(pe,{children:[I,z]}),e[20]=z,e[21]=I,e[22]=$):$=e[22];let H=i==="scaffold"?"default":"outline",L;e[23]!==a?(L=a("New policy file"),e[23]=a,e[24]=L):L=e[24];let O;e[25]!==H||e[26]!==L?(O=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-new",onClick:x,size:"xs",type:"button",variant:H,children:L}),e[25]=H,e[26]=L,e[27]=O):O=e[27];let m=i==="wire"?"default":"outline",u;e[28]!==a?(u=a("Wire into a procedure"),e[28]=a,e[29]=u):u=e[29];let q;e[30]!==m||e[31]!==u?(q=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-wire",onClick:_,size:"xs",type:"button",variant:m,children:u}),e[30]=m,e[31]=u,e[32]=q):q=e[32];let D;e[33]!==O||e[34]!==q?(D=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[O,q]}),e[33]=O,e[34]=q,e[35]=D):D=e[35];let J;e[36]!==l||e[37]!==r.policyName||e[38]!==r.tableName||e[39]!==i||e[40]!==w||e[41]!==a?(J=i==="scaffold"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:r.policyName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:r.tableName})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-create",disabled:l||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:a(l?"Creating\u2026":"Create policy file")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[36]=l,e[37]=r.policyName,e[38]=r.tableName,e[39]=i,e[40]=w,e[41]=a,e[42]=J):J=e[42];let K;e[43]!==l||e[44]!==r.exportName||e[45]!==r.filePath||e[46]!==r.policies||e[47]!==i||e[48]!==A||e[49]!==a?(K=i==="wire"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:r.filePath})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:r.exportName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:r.policies})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-apply",disabled:l||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:a(l?"Wiring\u2026":"Wire RLS")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[43]=l,e[44]=r.exportName,e[45]=r.filePath,e[46]=r.policies,e[47]=i,e[48]=A,e[49]=a,e[50]=K):K=e[50];let U;e[51]!==o?(U=o?.kind==="error"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=U):U=e[52];let W;e[53]!==o?.kind||e[54]!==a?(W=o?.kind==="needs-manual-edit"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=a,e[55]=W):W=e[55];let B;e[56]!==o||e[57]!==a?(B=o?.kind==="ok"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,t.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&(0,t.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(Ue)})]}),e[56]=o,e[57]=a,e[58]=B):B=e[58];let Q;e[59]!==D||e[60]!==J||e[61]!==K||e[62]!==U||e[63]!==W||e[64]!==B?(Q=(0,t.jsxs)(ne,{children:[D,J,K,U,W,B]}),e[59]=D,e[60]=J,e[61]=K,e[62]=U,e[63]=W,e[64]=B,e[65]=Q):Q=e[65];let X;return e[66]!==$||e[67]!==Q?(X=(0,t.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[$,Q]}),e[66]=$,e[67]=Q,e[68]=X):X=e[68],X},"Je");function Ue(e){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}d(Ue,"De");var st=d(({functions:e,runAsIdentity:a=!1,schemaEditable:i=!1}={})=>{let s=Y(),[l,n]=(0,p.useState)(void 0),o=d((f,r,b)=>{b!==""&&n(h=>({functionPath:b,nonce:(h?.nonce??0)+1}))},"o");return(0,t.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Permissions")})}),(0,t.jsx)($e,{onProbe:o})]}),(0,t.jsx)("section",{className:"flex flex-col gap-3",children:(0,t.jsxs)(se,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Probe")})}),(0,t.jsxs)(ne,{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:s("Pick a function and an identity, then run it to see the access outcome.")}),(0,t.jsx)(Me,{functions:e,prefill:l,runAsIdentity:a})]})]})}),i&&(0,t.jsx)("section",{className:"flex flex-col gap-2",children:(0,t.jsx)(Ke,{})})]})},"nt");export{st as PermissionsPanel};
|
|
1
|
+
import{a as ke}from"./chunk-V53KNYRN.js";import{a as T}from"./chunk-5Y3QLNWX.js";import{a as Pe}from"./chunk-CTNB2KIA.js";import{a as be}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as M}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as F}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as j}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as ge}from"./chunk-AHVDZWB3.js";import"./chunk-XXQUMVWH.js";import"./chunk-VORDESEQ.js";import"./chunk-QLQADHFE.js";import{a as Z}from"./chunk-ERMTJYQF.js";import{c as ae}from"./chunk-YGKR536O.js";import{f as oe}from"./chunk-UBR4KB6K.js";import"./chunk-XBDKZZ67.js";import{a as de}from"./chunk-XQCVZAGU.js";import{a as Ne,b as ve,c as we,d as ce,e as le,f as re}from"./chunk-MIQTKZAR.js";import{a as se,b as pe,c as fe,d as ue,e as ne}from"./chunk-UZERI5YC.js";import{d as Y,f as he,g as xe,h as ye,m as te}from"./chunk-OG4N2XHD.js";import"./chunk-QNUWWC3N.js";import{a as d,e as ie,f as Ae,g as Ie,h as Fe}from"./chunk-3XIESWL4.js";var p=ie(Ae(),1);var me=ie(Ie(),1);var t=ie(Fe(),1);var Ce=["read","insert","update","delete"],Te=d((e,a)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[a],"$e"),Ee=d(e=>{let a=new Set;for(let i of e?.advisories??[])if(i.name==="rls_uncovered_table"){let{table:s}=i.metadata;typeof s=="string"&&s!==""&&a.add(s)}return a},"Ae"),ze=d((e,a,i)=>{let s=new Map,l=d(n=>{let o=s.get(n);if(o!==void 0)return o;let f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:i.has(n)};return s.set(n,f),f},"r");for(let n of e)l(n.table).cells[n.on]={procedure:n.procedure};for(let n of a)l(n.table).maskedColumns.add(n.column);for(let n of i)l(n);return[...s.values()].toSorted((n,o)=>n.table.localeCompare(o.table))},"Fe"),$e=d(e=>{let a=(0,me.c)(17),i;a[0]!==e?(i=e===void 0?{}:e,a[0]=e,a[1]=i):i=a[1];let{onProbe:s}=i,l=Y(),n,o;a[2]===Symbol.for("react.memo_cache_sentinel")?(n={},o={live:!0},a[2]=n,a[3]=o):(n=a[2],o=a[3]);let f=ae(Z.rlsPolicies,n,o),r;a[4]===Symbol.for("react.memo_cache_sentinel")?(r={},a[4]=r):r=a[4];let b=ae(Z.maskPolicies,r),h;a[5]===Symbol.for("react.memo_cache_sentinel")?(h={},a[5]=h):h=a[5];let g=ae(Z.getAdvisories,h),N;if(a[6]!==g.data||a[7]!==b.data||a[8]!==s||a[9]!==f||a[10]!==l){let v=null;f.data!==void 0&&(v=Array.isArray(f.data.policies)?f.data.policies:[]);let E=Array.isArray(b.data?.columns)?b.data.columns:[],R=g.data??null,{error:C,errorSource:w,liveError:S}=f,A=v===null?[]:ze(v,E,Ee(R)),k;a[12]!==S?(k=(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)(Pe,{message:S,prefix:"pm"})}),a[12]=S,a[13]=k):k=a[13];let x;a[14]!==C||a[15]!==w?(x=C!==null&&(0,t.jsx)(ge,{error:w,testId:"pm-error"}),a[14]=C,a[15]=w,a[16]=x):x=a[16],N=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,x,v!==null&&A.length===0?(0,t.jsx)(de,{description:l("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:l("No policy")}):(0,t.jsxs)(Ne,{"data-testid":"pm-table",children:[(0,t.jsx)(ve,{children:(0,t.jsxs)(ce,{children:[(0,t.jsx)(le,{children:l("Table")}),Ce.map(c=>(0,t.jsx)(le,{children:Te(l,c)},c)),(0,t.jsx)(le,{children:l("Masked columns")})]})}),(0,t.jsx)(we,{children:A.map(c=>(0,t.jsxs)(ce,{"data-testid":`pm-row-${c.table}`,children:[(0,t.jsx)(re,{className:"font-mono text-xs",children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[c.table,c.uncovered&&(0,t.jsx)(j,{"data-testid":`pm-uncovered-${c.table}`,title:l("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:l("Uncovered \u2014 reachable without a policy")})]})}),Ce.map(_=>{let y=c.cells[_];return(0,t.jsx)(re,{"data-testid":`pm-cell-${c.table}-${_}`,children:y.procedure===void 0?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:l("No policy")}):(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Covered by {procedure}",{procedure:y.procedure})}),s!==void 0&&(0,t.jsx)(F,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${c.table}-${_}`,onClick:d(()=>{s(c.table,_,y.procedure??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Probe this")})]})},_)}),(0,t.jsx)(re,{children:c.maskedColumns.size===0?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)("span",{className:"flex flex-wrap gap-1",children:[...c.maskedColumns].map(Le)})})]},c.table))})]})]}),a[6]=g.data,a[7]=b.data,a[8]=s,a[9]=f,a[10]=l,a[11]=N}else N=a[11];return N},"Ee");function Le(e){return(0,t.jsx)(j,{variant:"outline",children:e},e)}d(Le,"Te");var Oe=he(Z.runAs),Re=d(()=>{let e=oe();return async({args:a,functionPath:i,shardKey:s="",userId:l})=>{let n=Oe;try{return{kind:"allowed",value:await e.query(n,{args:a,functionPath:i,userId:l},xe(s))}}catch(o){return{kind:"denied",message:o instanceof Error?o.message:String(o)}}}},"Re"),je=d(e=>e===void 0?"undefined":JSON.stringify(e,null,2),"Me"),Me=d(({functions:e,prefill:a,runAsIdentity:i=!1}={})=>{let s=oe(),l=Y(),n=Re(),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(null),h=e??o??[],[g,N]=(0,p.useState)(""),[v,E]=(0,p.useState)("{}"),[R,C]=(0,p.useState)(""),[w,S]=(0,p.useState)(""),[A,k]=(0,p.useState)(!1),[x,c]=(0,p.useState)(null),[_,y]=(0,p.useState)(null),I=(0,p.useRef)(-1);(0,p.useEffect)(()=>{if(e!==void 0)return;let m=!1;return s.listFunctions().then(u=>(m||f(u),u)).catch(u=>{m||b(ye(u))}),()=>{m=!0}},[s,e]),(0,p.useEffect)(()=>{if(a===void 0||I.current===a.nonce)return;I.current=a.nonce;let m=a.functionPath;queueMicrotask(()=>{N(m),c(null)})},[a]);let P=g===""?h[0]?.path??"":g,z=d(async()=>{if(P==="")return;let m;try{m=v.trim()===""?{}:JSON.parse(v)}catch(u){y(l("Invalid JSON args: {message}",{message:u.message})),c(null);return}y(null),k(!0);try{let u=await n({args:m,functionPath:P,shardKey:R.trim(),userId:w.trim()});c(u)}finally{k(!1)}},"F"),$=d(()=>{te(z())},"E"),H=d(m=>{N(m.target.value)},"B"),L=d(m=>{E(m.target.value)},"T"),O=d(m=>{S(m.target.value)},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!i&&(0,t.jsx)(de,{description:l("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:l("Set `runAsIdentity` to forge an identity and probe access.")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-function",children:l("Function")}),(0,t.jsx)("select",{"aria-label":l("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:H,value:P,children:h.map(m=>(0,t.jsxs)("option",{value:m.path,children:[m.path," (",m.kind,")"]},m.path))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-args",children:l("Arguments")}),(0,t.jsx)(ke,{"aria-label":l("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:L,value:v})]}),(0,t.jsx)(be,{onChange:C,testId:"pp-shard",value:R}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)(T,{htmlFor:"pp-user",children:l("Run as (userId)")}),(0,t.jsx)(M,{"aria-label":l("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:O,placeholder:l("Leave empty to run as admin"),value:w})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(F,{"data-testid":"pp-run",disabled:!i||A||P==="",onClick:$,type:"button",children:l(A?"Probing\u2026":"Run probe")}),w.trim()!==""&&(0,t.jsx)(j,{"data-testid":"pp-as-badge",variant:"secondary",children:l("as {userId}",{userId:w.trim()})})]})]}),_!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:_}),x!==null&&x.kind==="allowed"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,t.jsx)(j,{variant:"secondary",children:l("Allowed")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:je(x.value)})]}),x!==null&&x.kind==="denied"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,t.jsx)(j,{variant:"destructive",children:l("Denied")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:x.message})]})]})},"Oe"),qe="/__lunora/policy-scaffold",De={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Je=d(async e=>{let a=await fetch(qe,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await a.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(a.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};let s=i.error;return{kind:"error",message:s===void 0?`policy scaffold failed (${String(a.status)})`:De[s]??s}},"qe"),Se={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ke=d(()=>{let e=(0,me.c)(69),a=Y(),[i,s]=(0,p.useState)(null),[l,n]=(0,p.useState)(!1),[o,f]=(0,p.useState)(null),[r,b]=(0,p.useState)(Se),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=d(ee=>{let G=ee.target.name,{value:V}=ee.target;b(_e=>({..._e,[G]:V}))},"u"),e[0]=h):h=e[0];let g=h,N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=d(()=>{s(null),b(Se)},"N"),e[1]=N):N=e[1];let v=N,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=d(async ee=>{n(!0),f(null);try{let G=await Je(ee);f(G),G.kind==="ok"&&v()}catch(G){let V=G;f({kind:"error",message:V instanceof Error?V.message:String(V)})}n(!1)},"A"),e[2]=E):E=e[2];let R=E,C;e[3]!==r.policyName||e[4]!==r.tableName?(C=d(()=>{te(R({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"S"),e[3]=r.policyName,e[4]=r.tableName,e[5]=C):C=e[5];let w=C,S;e[6]!==r.exportName||e[7]!==r.filePath||e[8]!==r.policies?(S=d(()=>{te(R({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"C"),e[6]=r.exportName,e[7]=r.filePath,e[8]=r.policies,e[9]=S):S=e[9];let A=S,k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=d(()=>{f(null),s("scaffold")},"k"),e[10]=k):k=e[10];let x=k,c;e[11]===Symbol.for("react.memo_cache_sentinel")?(c=d(()=>{f(null),s("wire")},"c"),e[11]=c):c=e[11];let _=c,y;e[12]!==a?(y=a("Scaffold access rules"),e[12]=a,e[13]=y):y=e[13];let I;e[14]!==y?(I=(0,t.jsx)(fe,{children:y}),e[14]=y,e[15]=I):I=e[15];let P;e[16]!==a?(P=a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=a,e[17]=P):P=e[17];let z;e[18]!==P?(z=(0,t.jsx)(ue,{children:P}),e[18]=P,e[19]=z):z=e[19];let $;e[20]!==z||e[21]!==I?($=(0,t.jsxs)(pe,{children:[I,z]}),e[20]=z,e[21]=I,e[22]=$):$=e[22];let H=i==="scaffold"?"default":"outline",L;e[23]!==a?(L=a("New policy file"),e[23]=a,e[24]=L):L=e[24];let O;e[25]!==H||e[26]!==L?(O=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-new",onClick:x,size:"xs",type:"button",variant:H,children:L}),e[25]=H,e[26]=L,e[27]=O):O=e[27];let m=i==="wire"?"default":"outline",u;e[28]!==a?(u=a("Wire into a procedure"),e[28]=a,e[29]=u):u=e[29];let q;e[30]!==m||e[31]!==u?(q=(0,t.jsx)(F,{"data-testid":"policy-scaffolder-wire",onClick:_,size:"xs",type:"button",variant:m,children:u}),e[30]=m,e[31]=u,e[32]=q):q=e[32];let D;e[33]!==O||e[34]!==q?(D=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[O,q]}),e[33]=O,e[34]=q,e[35]=D):D=e[35];let J;e[36]!==l||e[37]!==r.policyName||e[38]!==r.tableName||e[39]!==i||e[40]!==w||e[41]!==a?(J=i==="scaffold"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:g,value:r.policyName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:g,value:r.tableName})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-create",disabled:l||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:a(l?"Creating\u2026":"Create policy file")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[36]=l,e[37]=r.policyName,e[38]=r.tableName,e[39]=i,e[40]=w,e[41]=a,e[42]=J):J=e[42];let K;e[43]!==l||e[44]!==r.exportName||e[45]!==r.filePath||e[46]!==r.policies||e[47]!==i||e[48]!==A||e[49]!==a?(K=i==="wire"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:g,value:r.filePath})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:g,value:r.exportName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(T,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:g,value:r.policies})]}),(0,t.jsx)(F,{"data-testid":"policy-scaffolder-apply",disabled:l||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:a(l?"Wiring\u2026":"Wire RLS")}),(0,t.jsx)(F,{onClick:v,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[43]=l,e[44]=r.exportName,e[45]=r.filePath,e[46]=r.policies,e[47]=i,e[48]=A,e[49]=a,e[50]=K):K=e[50];let U;e[51]!==o?(U=o?.kind==="error"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=U):U=e[52];let W;e[53]!==o?.kind||e[54]!==a?(W=o?.kind==="needs-manual-edit"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=a,e[55]=W):W=e[55];let B;e[56]!==o||e[57]!==a?(B=o?.kind==="ok"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,t.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&(0,t.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(Ue)})]}),e[56]=o,e[57]=a,e[58]=B):B=e[58];let Q;e[59]!==D||e[60]!==J||e[61]!==K||e[62]!==U||e[63]!==W||e[64]!==B?(Q=(0,t.jsxs)(ne,{children:[D,J,K,U,W,B]}),e[59]=D,e[60]=J,e[61]=K,e[62]=U,e[63]=W,e[64]=B,e[65]=Q):Q=e[65];let X;return e[66]!==$||e[67]!==Q?(X=(0,t.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[$,Q]}),e[66]=$,e[67]=Q,e[68]=X):X=e[68],X},"Je");function Ue(e){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}d(Ue,"De");var st=d(({functions:e,runAsIdentity:a=!1,schemaEditable:i=!1}={})=>{let s=Y(),[l,n]=(0,p.useState)(void 0),o=d((f,r,b)=>{b!==""&&n(h=>({functionPath:b,nonce:(h?.nonce??0)+1}))},"o");return(0,t.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Permissions")})}),(0,t.jsx)($e,{onProbe:o})]}),(0,t.jsx)("section",{className:"flex flex-col gap-3",children:(0,t.jsxs)(se,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Probe")})}),(0,t.jsxs)(ne,{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:s("Pick a function and an identity, then run it to see the access outcome.")}),(0,t.jsx)(Me,{functions:e,prefill:l,runAsIdentity:a})]})]})}),i&&(0,t.jsx)("section",{className:"flex flex-col gap-2",children:(0,t.jsx)(Ke,{})})]})},"nt");export{st as PermissionsPanel};
|