@lunora/studio 1.0.0-alpha.91 → 1.0.0-alpha.93
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/index.js +1 -1
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/packem_shared/{DataBrowser-BPRDaOHx.js → DataBrowser-H4oUFkPJ.js} +1 -1
- package/dist/packem_shared/wire-codec-DkrdsFXO.js +1 -0
- package/dist/standalone/{chunk-ZNMZQXWN.js → chunk-2O65JEMI.js} +1 -1
- package/dist/standalone/{chunk-RKGCSNAW.js → chunk-2OUIHY7G.js} +1 -1
- package/dist/standalone/{chunk-BCGEI67L.js → chunk-2T22UR7E.js} +1 -1
- package/dist/standalone/{chunk-WOEGO5M6.js → chunk-3DJ3IUUG.js} +1 -1
- package/dist/standalone/{chunk-QZGTDXV5.js → chunk-3KXDX76D.js} +1 -1
- package/dist/standalone/{chunk-ZKTWHB7Q.js → chunk-465RIA2L.js} +1 -1
- package/dist/standalone/chunk-5KCULF7S.js +11 -0
- package/dist/standalone/{chunk-J3FR2XBV.js → chunk-5TDGHWYU.js} +1 -1
- package/dist/standalone/{chunk-7QMX3D4D.js → chunk-6K46XGR5.js} +1 -1
- package/dist/standalone/{chunk-RHPP74O4.js → chunk-7ONX5YGW.js} +1 -1
- package/dist/standalone/{chunk-CRHCAN4W.js → chunk-7YJNH3RB.js} +1 -1
- package/dist/standalone/{chunk-ESEEVSPC.js → chunk-A3DBEJLO.js} +1 -1
- package/dist/standalone/{chunk-3XQMTTW2.js → chunk-ABYJC3LS.js} +1 -1
- package/dist/standalone/{chunk-6WWX4FJB.js → chunk-AQ4JNJF3.js} +1 -1
- package/dist/standalone/{chunk-XGMZESWC.js → chunk-BN4CIAXU.js} +1 -1
- package/dist/standalone/{chunk-XDEDCAYN.js → chunk-BNAMPDZ2.js} +1 -1
- package/dist/standalone/{chunk-XKKP2VFZ.js → chunk-D62SDRMM.js} +1 -1
- package/dist/standalone/{chunk-FBNRATNR.js → chunk-DBMFI2HC.js} +1 -1
- package/dist/standalone/{chunk-Q4AI6JRP.js → chunk-DMJDUC4L.js} +1 -1
- package/dist/standalone/{chunk-2QWHVQ6P.js → chunk-DYMO6MDG.js} +1 -1
- package/dist/standalone/{chunk-C6GLTSPO.js → chunk-G6GX5TVB.js} +1 -1
- package/dist/standalone/{chunk-4VEAVSAZ.js → chunk-GZMKPBTJ.js} +1 -1
- package/dist/standalone/{chunk-N233NOIN.js → chunk-JEZDJ7D6.js} +1 -1
- package/dist/standalone/{chunk-ZWSTXAG3.js → chunk-JYLYJT27.js} +1 -1
- package/dist/standalone/{chunk-2NX5QU44.js → chunk-KEVIGWKP.js} +1 -1
- package/dist/standalone/{chunk-ML5IJMH6.js → chunk-LZKU262J.js} +1 -1
- package/dist/standalone/{chunk-6XKVQES4.js → chunk-M7AWSDGY.js} +1 -1
- package/dist/standalone/chunk-MLT5MMMY.js +1 -0
- package/dist/standalone/{chunk-F3TP5L34.js → chunk-NNKN2XEZ.js} +1 -1
- package/dist/standalone/{chunk-NH3VWHCL.js → chunk-O3UMJLO3.js} +1 -1
- package/dist/standalone/{chunk-CUAGAM2B.js → chunk-OM36OEHZ.js} +1 -1
- package/dist/standalone/{chunk-BYIS2KWZ.js → chunk-PE7TI4TQ.js} +1 -1
- package/dist/standalone/{chunk-O2QUUHGF.js → chunk-PGVJE5F5.js} +1 -1
- package/dist/standalone/{chunk-IZ3ISXSM.js → chunk-QM4EXWKF.js} +1 -1
- package/dist/standalone/{chunk-QGA2HITH.js → chunk-QNHU4SKL.js} +1 -1
- package/dist/standalone/{chunk-LDYOCGEG.js → chunk-QXECM52Z.js} +1 -1
- package/dist/standalone/{chunk-LYQY7L72.js → chunk-SCKKQIAE.js} +1 -1
- package/dist/standalone/{chunk-6QKJ6JPJ.js → chunk-SKYFKPJC.js} +1 -1
- package/dist/standalone/{chunk-HKG5I64M.js → chunk-TITX6XEA.js} +1 -1
- package/dist/standalone/{chunk-CMP33R3N.js → chunk-TMNKNTC4.js} +1 -1
- package/dist/standalone/{chunk-NNRFDPSD.js → chunk-U6KDYJJC.js} +1 -1
- package/dist/standalone/{chunk-LUU4SDHW.js → chunk-UBIPFCOZ.js} +1 -1
- package/dist/standalone/{chunk-A7647FJE.js → chunk-UGU5GYDV.js} +1 -1
- package/dist/standalone/{chunk-QWJ4HKPY.js → chunk-UIGAA3GV.js} +1 -1
- package/dist/standalone/{chunk-4PLB4ZNI.js → chunk-VNQB6HY4.js} +1 -1
- package/dist/standalone/{chunk-AQT6EPZT.js → chunk-VVNQP4CI.js} +1 -1
- package/dist/standalone/{chunk-KUFAOKU3.js → chunk-WI4XINU2.js} +1 -1
- package/dist/standalone/{chunk-XXXMUP6L.js → chunk-YD5O2NWK.js} +1 -1
- package/dist/standalone/{chunk-ULYM26IH.js → chunk-YTWBHPAT.js} +1 -1
- package/dist/standalone/{chunk-7YXDJXNL.js → chunk-Z4AX76YZ.js} +1 -1
- package/dist/standalone/{chunk-LZH7RDRV.js → chunk-ZA5YIHZM.js} +1 -1
- package/dist/standalone/{chunk-4D7XIQ5Q.js → chunk-ZNAGZU6H.js} +1 -1
- package/dist/standalone/{chunk-XTEWLG3J.js → chunk-ZQPWVALL.js} +1 -1
- package/dist/standalone/{chunk-HWOD25QD.js → chunk-ZVAGD3FT.js} +1 -1
- package/dist/standalone/chunk-ZZJ7VUVZ.js +1 -0
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/wire-codec-BUrWLklj.js +0 -1
- package/dist/standalone/chunk-BENJFRZL.js +0 -1
- package/dist/standalone/chunk-DBWOWJYT.js +0 -11
- package/dist/standalone/chunk-FW75RYZU.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G}from"./chunk-V53KNYRN.js";import{a as g}from"./chunk-5Y3QLNWX.js";import{a as B}from"./chunk-RMN2JN4S.js";import{b as U}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as O}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as h}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as w}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as M}from"./chunk-VDW32UET.js";import{f as D}from"./chunk-
|
|
1
|
+
import{a as G}from"./chunk-V53KNYRN.js";import{a as g}from"./chunk-5Y3QLNWX.js";import{a as B}from"./chunk-RMN2JN4S.js";import{b as U}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as O}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as h}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as w}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as M}from"./chunk-VDW32UET.js";import{f as D}from"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import{d as K,e as _,f as z,h as P,o as q,r as E}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as s,e as T,f as ie,h as oe}from"./chunk-3XIESWL4.js";var i=T(ie(),1);var e=T(oe(),1);var de=s(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"ie"),le=s(r=>r===void 0||r.length===0?"()":`(${r.map(o=>`${o.name}${o.optional?"?":""}: ${de(o)}`).join(", ")})`,"oe"),ue=s(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"de"),ce=s(r=>{let o={};for(let a of r??[])a.optional||(o[a.name]=ue(a.kind));return JSON.stringify(o,void 0,2)},"le"),me=z(M.runAs),fe=10,pe=s(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"me"),Fe=s(({functions:r,runAsIdentity:o=!1}={})=>{let a=K(),c=D(),[H,Q]=(0,i.useState)(null),[k,V]=(0,i.useState)(null),x=r??H??[],[I,S]=(0,i.useState)(""),[m,b]=(0,i.useState)("{}"),[u,F]=(0,i.useState)(""),[f,W]=(0,i.useState)(""),[v,p]=(0,i.useState)("idle"),[X,y]=(0,i.useState)(void 0),[C,N]=(0,i.useState)(null),[$,Y]=(0,i.useState)([]);(0,i.useEffect)(()=>{if(r!==void 0)return;let t=!1;return c.listFunctions().then(d=>(t||Q(d),d)).catch(d=>{t||V(P(d))}),()=>{t=!0}},[c,r]);let R=I===""?x[0]?.path??"":I,n=x.find(t=>t.path===R),Z=s(async()=>{if(!n)return;let t;try{t=m.trim()===""?{}:JSON.parse(m)}catch(l){p("error"),y(void 0),N(a("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:n.path},j=u.trim()===""?{}:{shardKey:u.trim()},A=o?f.trim():"",J=s(l=>{Y(L=>[{argsText:m,at:Date.now(),id:(L[0]?.id??0)+1,kind:n.kind,path:n.path,shardKey:u,status:l},...L].slice(0,fe))},"j");p("running"),N(null);try{let l=A===""?await _(c,n.kind,d,t,j):await c.query(me,{args:t,functionPath:n.path,userId:A},j);U(u),y(l),p("success"),J("success")}catch(l){y(void 0),N(l.message),p("error"),J("error")}},"_"),ee=s(t=>{S(t.path),b(t.argsText),F(t.shardKey)},"q"),te=s(t=>{S(t.target.value)},"B"),re=s(t=>{b(t.target.value)},"D"),ae=s(t=>{W(t.target.value)},"E"),se=s(()=>{q(Z())},"U"),ne=s(()=>{b(ce(n?.args))},"X");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(g,{htmlFor:"function-select",children:a("Function")}),(0,e.jsx)("select",{"aria-label":a("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:R,children:x.map(t=>(0,e.jsxs)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path))}),n!==void 0&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"mr-1.5 font-medium",children:a("Signature")}),(0,e.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:le(n.args)})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)(g,{htmlFor:"args-input",children:a("Arguments")}),(0,e.jsx)(h,{"data-testid":"prefill-button",disabled:n===void 0,onClick:ne,size:"xs",type:"button",variant:"ghost",children:a("Prefill")})]}),(0,e.jsx)(G,{"aria-label":a("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:m})]}),(0,e.jsx)(B,{onChange:F,testId:"shard-input",value:u}),o&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsx)(g,{htmlFor:"run-as-input",children:a("Run as identity (userId)")}),(0,e.jsx)(O,{"aria-label":a("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:ae,placeholder:a("Leave empty to run as admin"),value:f}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(h,{"data-testid":"run-button",disabled:v==="running"||n===void 0,onClick:se,type:"button",children:a("Run")}),n!==void 0&&(0,e.jsx)(w,{variant:"outline",children:n.kind}),o&&f.trim()!==""&&(0,e.jsx)(w,{"data-testid":"run-as-badge",variant:"secondary",children:a("as {userId}",{userId:f.trim()})})]})]}),v==="error"&&C!==null&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C}),v==="success"&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:pe(X)}),$.length>0&&(0,e.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:$.map((t,d)=>(0,e.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsx)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"})," ",(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]})," ",(0,e.jsx)("time",{className:"text-xs text-muted-foreground",children:E(t.at)})," ",(0,e.jsx)(h,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:s(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Load")})]},t.id))})]})},"Ie");export{Fe as FunctionRunner};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ze}from"./chunk-IBVBIKUI.js";import{a as Je,b as Ve}from"./chunk-
|
|
1
|
+
import{a as Ze}from"./chunk-IBVBIKUI.js";import{a as Je,b as Ve}from"./chunk-DYMO6MDG.js";import{a as Xe}from"./chunk-3FIN5PH4.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-ESVP44Y3.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import{a as Ge}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-S3DWUXGY.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import"./chunk-AREBQI6D.js";import{a as Qe}from"./chunk-RMN2JN4S.js";import{b as Pe}from"./chunk-GRL5MG3Z.js";import{d as Ce,e as Oe,f as Me}from"./chunk-7T7UOTYK.js";import{R as Fe}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as We}from"./chunk-XXQUMVWH.js";import{a as we}from"./chunk-VDW32UET.js";import"./chunk-ZNAGZU6H.js";import{f as ke}from"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import{a as He,b as je,c as Ke,d as De,e as Ye,f as Ue}from"./chunk-MIQTKZAR.js";import{d as oe,f as ve,g as ye,h as _e,o as ie}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as i,e as Ee,f as dt,g as ut,h as mt,j as ue}from"./chunk-3XIESWL4.js";var K=Ee(ut(),1);var P=Ee(dt(),1);var c=Ee(mt(),1);var ht=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],ft=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ie=String.fromCodePoint(0),pt=new RegExp(`${Ie}${String.raw`(\d+)`}${Ie}`,"gu"),bt=ht.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),gt=ft.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
2
2
|
${l}`})),xt=i(l=>{let e=[],t=l.replaceAll(/'(?:[^']|'')*'/gu,n=>(e.push(n),`${Ie}${(e.length-1).toString()}${Ie}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:n,replacement:r}of bt)t=t.replaceAll(n,r);for(let{pattern:n,replacement:r}of gt)t=t.replaceAll(n,r);return t=t.replaceAll(pt,(n,r)=>e[Number(r)]??""),t},"yt"),vt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,yt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|replace|truncate|update|vacuum)\b/iu,wt=/^\w+/u,St=/;\s*$/u,Nt=/\s/u,kt=i((l,e)=>{let t=e+2;for(;t<l.length&&l[t]!==`
|
|
3
3
|
`;)t+=1;return t},"qt"),Ct=i((l,e)=>{let t=l.indexOf("*/",e+2);return t===-1?-1:t+2},"$t"),qt=i(l=>{let e=0;for(;e<l.length;){let t=l[e];if(t!==void 0&&Nt.test(t))e+=1;else if(t==="-"&&l[e+1]==="-")e=kt(l,e);else if(t==="/"&&l[e+1]==="*"){let n=Ct(l,e);if(n===-1)break;e=n}else break}return e},"Tt"),Tt=i(l=>{let e=qt(l),t=l.slice(e).trimEnd();if(t==="")return{code:"SQL_EMPTY",message:"the query is empty"};let n=t.replace(St,""),r=n.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let o="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!vt.test(n))return{code:"SQL_NOT_READONLY",length:wt.exec(n)?.[0].length??1,message:o,offset:e};let s=yt.exec(n);if(s!==null)return{code:"SQL_NOT_READONLY",length:s[0].length,message:`${o} (\`${s[0].toUpperCase()}\` is not allowed)`,offset:e+s.index}},"Rt"),It=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Rt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,Lt=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),Et=/[^\n]/gu,_t=i((l,e)=>{let t=l[e];if(t==="'"){let n=e+1;for(;n<l.length&&l[n]!=="'";)n+=1;return Math.min(n+1,l.length)}if(t==="-"&&l[e+1]==="-"){let n=l.indexOf(`
|
|
4
4
|
`,e);return n===-1?l.length:n}if(t==="/"&&l[e+1]==="*"){let n=l.indexOf("*/",e+2);return n===-1?l.length:n+2}return-1},"Ot"),Ot=i(l=>{let e="",t=0;for(;t<l.length;){let n=_t(l,t);n===-1?(e+=l.slice(t,t+1),t+=1):(e+=l.slice(t,n).replaceAll(Et," "),t=n)}return e},"Mt"),Mt=i(l=>{let e=new Set;for(let t of l.matchAll(Rt))e.add((t[1]??"").toLowerCase());return e},"Dt"),Dt=i((l,e)=>{let t=new Map;for(let n of l.matchAll(It)){let r=(n[1]??"").toLowerCase(),o=(n[2]??"").toLowerCase();e.has(r)&&(t.set(r,r),o!==""&&!Lt.has(o)&&t.set(o,r))}return t},"At"),ot=i((l,e)=>{let t=Ot(l),n=new Set(e.map(r=>r.toLowerCase()));return{ctes:Mt(t),masked:t,targets:Dt(t,n)}},"Ke"),At=/^(?:__lunora|sqlite_)/iu,Bt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,$t=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,zt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Ft=i((l,e,t)=>{let n=[];for(let r of l.matchAll(Bt)){let o=r[1]??"",s=o.toLowerCase();!e.has(s)&&!t.has(s)&&!zt.has(s)&&!At.test(o)&&n.push({length:o.length,message:`unknown table \`${o}\``,offset:r.index+r[0].length-o.length,severity:"error",source:"schema"})}return n},"Ft"),Pt=i((l,e,t)=>{let n=[],r=new Map;for(let[o,s]of Object.entries(e.columns))r.set(o.toLowerCase(),new Set(s.map(m=>m.toLowerCase())));for(let o of l.matchAll($t)){let s=(o[1]??"").toLowerCase(),m=o[2]??"",a=t.get(s),d=a===void 0?void 0:r.get(a);d!==void 0&&!d.has(m.toLowerCase())&&n.push({length:m.length,message:`\`${a??""}\` has no column \`${m}\``,offset:o.index+o[0].length-m.length,severity:"error",source:"schema"})}return n},"Qt"),Qt=i((l,e)=>{if(l.trim()==="")return[];let t=Tt(l);if(t!==void 0)return t.code==="SQL_EMPTY"?[]:[{length:t.length,message:t.message,offset:t.offset,severity:"error",source:"gate"}];let{ctes:n,masked:r,targets:o}=ot(l,e.tables),s=new Set(e.tables.map(m=>m.toLowerCase()));return[...Ft(r,s,n),...Pt(r,e,o)]},"jt"),Wt=ve(we.lintSql),Ht=600,jt=i((l,e,t)=>{let n=ke(),[r,o]=(0,P.useState)([]),s=(0,P.useMemo)(()=>Qt(l,e),[l,e]),m=Ge(l,Ht),a=s.some(p=>p.source==="gate")||m.trim()==="",d=(0,P.useCallback)(async p=>{try{let b=await n.query(Wt,{sql:m},ye(t));p.cancelled||o(b.diagnostics??[])}catch{p.cancelled||o([])}},[n,m,t]);(0,P.useEffect)(()=>{if(a){o([]);return}let p={cancelled:!1};return ie(d(p)),()=>{p.cancelled=!0}},[d,a]);let f=m===l;return(0,P.useMemo)(()=>f?[...s,...r]:s,[s,r,f])},"Ut"),qe=8,Kt=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],Yt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Ut=/[\w$]/,rt=i(l=>l!==void 0&&Ut.test(l),"Ue"),lt=i(l=>{let e=l.length;for(;e>0&&rt(l[e-1]);)e-=1;return l.slice(e)},"Ye"),st=i((l,e)=>{let t=e;for(;t>0&&rt(l[t-1]);)t-=1;return{end:e,start:t,text:l.slice(t,e)}},"Je"),et=i((l,e)=>{let t=l.slice(0,e).trimEnd();return t.endsWith(".")||Yt.has(lt(t).toUpperCase())},"Pe"),Gt=i((l,e,t)=>{let n=l.slice(0,e);if(!n.endsWith("."))return;let r=lt(n.slice(0,-1));if(r!=="")return ot(l,t).targets.get(r.toLowerCase())??r},"Vt"),Be=i((l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),"Me"),tt=i((l,e,t,n)=>{let r=[];for(let o of l)if(Be(o,e)&&(r.push(n(o)),r.length>=t))break;return r},"Fe"),Jt=i((l,e,t)=>{let n=new Map;for(let[r,o]of Object.entries(l.columns))for(let s of o)if(Be(s,e)&&!n.has(s)&&(n.set(s,r),n.size>=t))return[...n].map(([m,a])=>({detail:a,kind:"column",label:m}));return[...n].map(([r,o])=>({detail:o,kind:"column",label:r}))},"Xt"),Vt=i((l,e,t)=>{let n=st(l,e),r=Gt(l,n.start,t.tables);if(r!==void 0){let a=t.columns[r]??t.columns[r.toLowerCase()]??[];return tt(a,n.text,qe,d=>({detail:r,kind:"column",label:d}))}if(n.text===""&&!et(l,n.start))return[];let o=tt(t.tables,n.text,qe,a=>({kind:"table",label:a})),s=Jt(t,n.text,qe),m=Kt.flatMap(a=>n.text!==""&&Be(a,n.text)&&a.toLowerCase()!==n.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(et(l,n.start)?[...s,...o,...m]:[...o,...s,...m]).slice(0,qe)},"Zt"),Xt=i((l,e,t)=>{let n=st(l,e),r=l.slice(0,n.start)+t.label+l.slice(n.end);return{caret:n.start+t.label.length,value:r}},"en"),Zt=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],en=i((l,e)=>{let t=globalThis.getComputedStyle(l),n=globalThis.document.createElement("div"),{style:r}=n;r.position="absolute",r.visibility="hidden",r.whiteSpace="pre-wrap",r.overflowWrap="break-word";for(let a of Zt)r[a]=t[a];n.textContent=l.value.slice(0,Math.max(0,e));let o=globalThis.document.createElement("span");o.textContent=l.value.slice(Math.max(0,e))||".",n.append(o),globalThis.document.body.append(n);let s=o.offsetLeft-l.scrollLeft,m=o.offsetTop-l.scrollTop;return n.remove(),{left:s,top:m}},"nn"),tn=i((l,e,t)=>{let n=(0,K.c)(16),[r,o]=(0,P.useState)(null),s;n[0]!==l||n[1]!==e?(s=i((w,g)=>{let h=Vt(w,g,l);if(h.length===0){o(null);return}let S=e.current,{left:k,top:N}=S===null?{left:0,top:0}:en(S,g);o(C=>C!==null&&C.active===0&&C.left===k&&C.top===N&&C.suggestions.length===h.length&&C.suggestions.every((L,R)=>{let E=h.at(R);return L.kind===E?.kind&&L.label===E.label&&L.detail===E.detail})?C:{active:0,left:k,suggestions:h,top:N})},"s"),n[0]=l,n[1]=e,n[2]=s):s=n[2];let m=s,a;n[3]===Symbol.for("react.memo_cache_sentinel")?(a=i(()=>{o(null)},"a"),n[3]=a):a=n[3];let d=a,f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=i(w=>{o(g=>{if(g===null)return g;let h=g.suggestions.length,S=(g.active+w+h)%h;return{...g,active:S}})},"f"),n[4]=f):f=n[4];let p=f,b;n[5]!==t||n[6]!==r||n[7]!==e?(b=i(w=>{let g=e.current;if(r===null||g===null)return!1;let h=r.suggestions[w??r.active];if(h===void 0)return!1;let S=Xt(g.value,g.selectionStart,h);return t(S.value),o(null),requestAnimationFrame(()=>{let k=e.current;k!==null&&(k.focus(),k.setSelectionRange(S.caret,S.caret))}),!0},"p"),n[5]=t,n[6]=r,n[7]=e,n[8]=b):b=n[8];let v=b,u;n[9]!==v?(u=i(()=>v(),"c"),n[9]=v,n[10]=u):u=n[10];let x=u,y;return n[11]!==x||n[12]!==v||n[13]!==m||n[14]!==r?(y={close:d,commit:x,commitAt:v,move:p,refresh:m,state:r},n[11]=x,n[12]=v,n[13]=m,n[14]=r,n[15]=y):y=n[15],y},"on"),nn={column:"column",keyword:"keyword",table:"table"},on=20,rn=i(l=>{let e=(0,K.c)(17),{listboxId:t,onPick:n,state:r}=l,o=oe(),s;e[0]!==r?(s=r===null?void 0:{left:r.left,top:r.top+on},e[0]=r,e[1]=s):s=e[1];let m=s;if(r===null)return null;let a;if(e[2]!==t||e[3]!==n||e[4]!==r.active||e[5]!==r.suggestions||e[6]!==o){let f;e[8]!==t||e[9]!==n||e[10]!==r.active||e[11]!==o?(f=i((p,b)=>(0,c.jsxs)("li",{"aria-selected":b===r.active,className:ue("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",b===r.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${b.toString()}`,onMouseDown:i(v=>{v.preventDefault(),n(b)},"onMouseDown"),role:"option",children:[(0,c.jsx)("span",{className:"truncate font-mono",children:p.label}),p.detail!==void 0&&(0,c.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:p.detail}),(0,c.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:o(nn[p.kind])})]},`${p.kind}:${p.label}`),"f"),e[8]=t,e[9]=n,e[10]=r.active,e[11]=o,e[12]=f):f=e[12],a=r.suggestions.map(f),e[2]=t,e[3]=n,e[4]=r.active,e[5]=r.suggestions,e[6]=o,e[7]=a}else a=e[7];let d;return e[13]!==t||e[14]!==m||e[15]!==a?(d=(0,c.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:t,role:"listbox",style:m,children:a}),e[13]=t,e[14]=m,e[15]=a,e[16]=d):d=e[16],d},"sn"),ln=ve(we.listTables),sn=ve(we.readTablePage),an=i(l=>{let e=(0,K.c)(16),t=ke(),n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let[r,o]=(0,P.useState)(n),s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s={},e[1]=s):s=e[1];let[m,a]=(0,P.useState)(s),d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[2]=d):d=e[2];let f=(0,P.useRef)(d),p,b;e[3]!==t||e[4]!==l?(p=i(()=>{let g={cancelled:!1};return ie((async()=>{try{let h=await t.query(ln,{},ye(l));g.cancelled||(o(h.map(dn)),a({}),f.current=new Set)}catch{g.cancelled||(o([]),a({}),f.current=new Set)}})()),()=>{g.cancelled=!0}},"h"),b=[t,l],e[3]=t,e[4]=l,e[5]=p,e[6]=b):(p=e[5],b=e[6]),(0,P.useEffect)(p,b);let v;e[7]!==t||e[8]!==l?(v=i(g=>{f.current.has(g)||(f.current.add(g),ie((async()=>{try{let h=await t.query(sn,{limit:1,offset:0,table:g},ye(l));a(S=>({...S,[g]:h.columns}))}catch{f.current.delete(g)}})()))},"x"),e[7]=t,e[8]=l,e[9]=v):v=e[9];let u=v,x;e[10]!==m||e[11]!==r?(x={columns:m,tables:r},e[10]=m,e[11]=r,e[12]=x):x=e[12];let y=x,w;return e[13]!==u||e[14]!==y?(w={probe:u,schema:y},e[13]=u,e[14]=y,e[15]=w):w=e[15],w},"dn"),Ae=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,cn=i(l=>{let e=new Set;Ae.lastIndex=0;let t=Ae.exec(l);for(;t!==null;)e.add(t[1]??t[2]),t=Ae.exec(l);return[...e]},"un");function dn(l){return l.name}i(dn,"mn");var un=i(l=>{let e=(0,K.c)(34),{onSubmit:t,probe:n,schema:r,setDraft:o}=l,s=(0,P.useId)(),m=(0,P.useRef)(null),a=(0,P.useRef)(null),d=(0,P.useRef)(null),f=tn(r,d,o),{close:p,commit:b,commitAt:v,move:u,refresh:x,state:y}=f,w;e[0]!==v?(w=i(I=>{v(I)},"y"),e[0]=v,e[1]=w):w=e[1];let g=w,h;e[2]!==x?(h=i(()=>{let I=d.current;I!==null&&I===document.activeElement&&x(I.value,I.selectionStart)},"m"),e[2]=x,e[3]=h):h=e[3];let S;e[4]!==x||e[5]!==r?(S=[x,r],e[4]=x,e[5]=r,e[6]=S):S=e[6],(0,P.useEffect)(h,S);let k;e[7]!==n||e[8]!==x||e[9]!==o?(k=i(I=>{let{selectionStart:$,value:W}=I.target;o(W);for(let Q of cn(W))n(Q);x(W,$)},"N"),e[7]=n,e[8]=x,e[9]=o,e[10]=k):k=e[10];let N=k,C;e[11]!==x?(C=i(I=>{let $=I.currentTarget;x($.value,$.selectionStart)},"k"),e[11]=x,e[12]=C):C=e[12];let L=C,R;e[13]!==y||e[14]!==p||e[15]!==b||e[16]!==u||e[17]!==t?(R=i(I=>{if(y!==null){if(I.key==="ArrowDown"){I.preventDefault(),u(1);return}if(I.key==="ArrowUp"){I.preventDefault(),u(-1);return}if(I.key==="Escape"){I.preventDefault(),p();return}if((I.key==="Enter"||I.key==="Tab")&&!I.metaKey&&!I.ctrlKey&&b()){I.preventDefault();return}}(I.metaKey||I.ctrlKey)&&I.key==="Enter"&&(I.preventDefault(),t())},"T"),e[13]=y,e[14]=p,e[15]=b,e[16]=u,e[17]=t,e[18]=R):R=e[18];let E=R,q;e[19]!==p?(q=i(()=>{requestAnimationFrame(()=>{p()})},"C"),e[19]=p,e[20]=q):q=e[20];let O=q,M;e[21]===Symbol.for("react.memo_cache_sentinel")?(M=i(I=>{let{scrollLeft:$,scrollTop:W}=I.currentTarget;m.current!==null&&(m.current.scrollTop=W),a.current!==null&&(a.current.scrollTop=W,a.current.scrollLeft=$)},"_"),e[21]=M):M=e[21];let D=M,T;e[22]===Symbol.for("react.memo_cache_sentinel")?(T=i(I=>{let $=d.current;$===null||I.offset===void 0||($.focus(),$.setSelectionRange(I.offset,I.offset+(I.length??0)))},"q"),e[22]=T):T=e[22];let _=T,A;e[23]!==N||e[24]!==O||e[25]!==E||e[26]!==L?(A={onBlur:O,onChange:N,onKeyDown:E,onScroll:D,onSelect:L},e[23]=N,e[24]=O,e[25]=E,e[26]=L,e[27]=A):A=e[27];let B;return e[28]!==y||e[29]!==p||e[30]!==s||e[31]!==g||e[32]!==A?(B={autocompleteState:y,closeAutocomplete:p,handlers:A,listboxId:s,onPickSuggestion:g,editorRef:d,gutterRef:m,overlayRef:a,revealDiagnostic:_},e[28]=y,e[29]=p,e[30]=s,e[31]=g,e[32]=A,e[33]=B):B=e[33],B},"fn"),mn="lunora-studio-sql-tabs",hn="lunora-studio-sql-active-tab",$e=12,Se=i((l="",e="")=>({activeId:null,id:Me("tab"),name:e,sql:l}),"ve"),fn=i(()=>Oe(hn,""),"bn"),pn=i(l=>{let e=(0,K.c)(16),[t,n]=Ce(mn),[r,o]=fn(),[s]=(0,P.useState)(l),m,a;e[0]!==s||e[1]!==n||e[2]!==t.length?(m=i(()=>{t.length===0&&n([s])},"d"),a=[s,n,t.length],e[0]=s,e[1]=n,e[2]=t.length,e[3]=m,e[4]=a):(m=e[3],a=e[4]),(0,P.useEffect)(m,a);let d;e[5]!==s||e[6]!==t?(d=t.length===0?[s]:t,e[5]=s,e[6]=t,e[7]=d):d=e[7];let f=d,p;e[8]!==r||e[9]!==f?(p=f.some(u=>u.id===r)?r:f[0]?.id??"",e[8]=r,e[9]=f,e[10]=p):p=e[10];let b=p,v;return e[11]!==b||e[12]!==o||e[13]!==n||e[14]!==f?(v={activeId:b,setActiveId:o,setTabs:n,tabs:f},e[11]=b,e[12]=o,e[13]=n,e[14]=f,e[15]=v):v=e[15],v},"gn"),at=i(l=>l.activeId===null&&l.sql.trim()!=="","Ge"),bn=i((l,e)=>[...l,e].slice(-$e),"xn"),gn=i((l,e,t)=>{let n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:l[0]?.id??"",tabs:[...l]};let r=l.filter(o=>o.id!==e);if(r.length===0){let o=t();return{activeId:o.id,tabs:[o]}}return{activeId:r[Math.min(n,r.length-1)].id,tabs:r}},"vn"),xn=i((l,e)=>{let t=l.filter(n=>n.id===e);return t.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:t}},"yn"),vn=i((l,e,t)=>{let n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:t,tabs:[...l]};let r=l.slice(0,n+1);return{activeId:r.some(o=>o.id===t)?t:e,tabs:r}},"wn"),yn=i(l=>{let e=l();return{activeId:e.id,tabs:[e]}},"Sn"),wn=i((l,e,t)=>{if(l==="others")return e.filter(n=>n.id!==t);if(l==="right"){let n=e.findIndex(r=>r.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},"Nn"),nt={error:null,pane:"results",result:null,running:!1},Sn=i(l=>{let e=(0,K.c)(66),{activeId:t,setActiveId:n,setTabs:r,tabs:o}=pn(l),s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];let[m,a]=(0,P.useState)(s),[d,f]=(0,P.useState)(null),[p,b]=(0,P.useState)(null),v;e[1]!==t||e[2]!==o?(v=o.find(F=>F.id===t)??o[0]??Se(),e[1]=t,e[2]=o,e[3]=v):v=e[3];let u=v,x=m[u.id]??nt,y;e[4]!==u.id||e[5]!==r?(y=i(F=>{r(j=>j.map(U=>U.id===u.id?{...U,...F}:U))},"v"),e[4]=u.id,e[5]=r,e[6]=y):y=e[6];let w=y,g;e[7]!==u.id?(g=i(F=>{a(j=>{let U=j[u.id]??nt;return{...j,[u.id]:{...U,...F}}})},"b"),e[7]=u.id,e[8]=g):g=e[8];let h=g,S;e[9]!==n||e[10]!==r||e[11]!==o.length?(S=i(()=>{if(o.length>=$e)return;let F=Se();r(j=>bn(j,F)),n(F.id)},"w"),e[9]=n,e[10]=r,e[11]=o.length,e[12]=S):S=e[12];let k=S,N;e[13]!==n||e[14]!==r?(N=i(F=>{f(null),b(null),r(F.tabs),n(F.activeId);let j=new Set(F.tabs.map(Nn));a(U=>Object.fromEntries(Object.entries(U).filter(ae=>{let[xe]=ae;return j.has(xe)})))},"S"),e[13]=n,e[14]=r,e[15]=N):N=e[15];let C=N,L;e[16]!==C||e[17]!==o?(L=i(F=>{C(gn(o,F,Se))},"R"),e[16]=C,e[17]=o,e[18]=L):L=e[18];let R=L,E;e[19]!==t||e[20]!==C||e[21]!==o?(E=i((F,j)=>{C(F==="others"?xn(o,j):F==="right"?vn(o,j,t):yn(Se))},"I"),e[19]=t,e[20]=C,e[21]=o,e[22]=E):E=e[22];let q=E,O;e[23]!==q||e[24]!==d||e[25]!==o?(O=i(F=>{d!==null&&(wn(F,o,d.id).some(kn)?b(F):q(F,d.id))},"L"),e[23]=q,e[24]=d,e[25]=o,e[26]=O):O=e[26];let M=O,D;e[27]===Symbol.for("react.memo_cache_sentinel")?(D=i((F,j)=>{j.preventDefault(),b(null),f({id:F,x:j.clientX,y:j.clientY})},"O"),e[27]=D):D=e[27];let T=D,_;e[28]===Symbol.for("react.memo_cache_sentinel")?(_=i(()=>{f(null),b(null)},"E"),e[28]=_):_=e[28];let A=_,B;e[29]===Symbol.for("react.memo_cache_sentinel")?(B=i(F=>{F.preventDefault(),f(null),b(null)},"D"),e[29]=B):B=e[29];let I=B,$;e[30]!==M?($=i(()=>{M("others")},"B"),e[30]=M,e[31]=$):$=e[31];let W=$,Q;e[32]!==M?(Q=i(()=>{M("right")},"P"),e[32]=M,e[33]=Q):Q=e[33];let Y=Q,H;e[34]!==M?(H=i(()=>{M("all")},"Q"),e[34]=M,e[35]=H):H=e[35];let G=H,J;e[36]!==q||e[37]!==p||e[38]!==d?(J=i(()=>{d!==null&&p!==null&&q(p,d.id),b(null)},"J"),e[36]=q,e[37]=p,e[38]=d,e[39]=J):J=e[39];let z=J,V;e[40]===Symbol.for("react.memo_cache_sentinel")?(V=i(()=>{b(null)},"G"),e[40]=V):V=e[40];let re=V,X;e[41]!==d?(X=d===null?void 0:{left:d.x,top:d.y},e[41]=d,e[42]=X):X=e[42];let Z=X,ee;e[43]!==r?(ee=i(F=>{r(j=>j.map(U=>U.activeId===F?{...U,activeId:null}:U))},"Z"),e[43]=r,e[44]=ee):ee=e[44];let te=ee,ne;e[45]!==r?(ne=i((F,j)=>{r(U=>U.map(ae=>ae.id===F?{...ae,name:j}:ae))},"te"),e[45]=r,e[46]=ne):ne=e[46];let le=ne,ce;return e[47]!==u||e[48]!==t||e[49]!==k||e[50]!==R||e[51]!==z||e[52]!==G||e[53]!==W||e[54]!==Y||e[55]!==x||e[56]!==h||e[57]!==w||e[58]!==p||e[59]!==le||e[60]!==n||e[61]!==d||e[62]!==Z||e[63]!==o||e[64]!==te?(ce={activeTab:u,activeTabId:t,addEditorTab:k,cancelBulk:re,closeEditorTab:R,closeTabMenu:A,confirmBulk:z,menuStyle:Z,onBackdropContextMenu:I,onCloseAll:G,onCloseOthers:W,onCloseToRight:Y,openTabMenu:T,output:x,patchActiveOutput:h,patchActiveTab:w,pendingBulk:p,renameTab:le,setActiveTabId:n,tabMenu:d,tabs:o,unlinkQuery:te},e[47]=u,e[48]=t,e[49]=k,e[50]=R,e[51]=z,e[52]=G,e[53]=W,e[54]=Y,e[55]=x,e[56]=h,e[57]=w,e[58]=p,e[59]=le,e[60]=n,e[61]=d,e[62]=Z,e[63]=o,e[64]=te,e[65]=ce):ce=e[65],ce},"kn");function Nn(l){return l.id}i(Nn,"Cn");function kn(l){return at(l)}i(kn,"qn");var Cn="lunora-studio-sql-queries",qn="lunora-studio-sql-history",Tn=25,In=i(l=>{let e=(0,K.c)(33),{loadIntoActiveTab:t,unlinkQuery:n}=l,r=oe(),[o,s]=Ce(Cn),[m,a]=Ce(qn),[d,f]=(0,P.useState)(""),p=(0,P.useRef)(null),b;e[0]!==a?(b=i(T=>{a(_=>_[0]?.sql===T?_:[{at:Date.now(),sql:T},..._.filter(A=>A.sql!==T)].slice(0,Tn))},"p"),e[0]=a,e[1]=b):b=e[1];let v=b,u;e[2]!==t||e[3]!==s||e[4]!==r?(u=i(()=>{let T={id:Me("q"),name:r("Untitled query"),sql:""};s(_=>[T,..._]),t("",T.id)},"c"),e[2]=t,e[3]=s,e[4]=r,e[5]=u):u=e[5];let x=u,y;e[6]!==t||e[7]!==o?(y=i(T=>{let _=o.find(A=>A.id===T);_!==void 0&&(t(_.sql,T),p.current?.querySelector(`[data-testid="sql-query-${T}"]`)?.scrollIntoView({block:"nearest"}))},"v"),e[6]=t,e[7]=o,e[8]=y):y=e[8];let w=y,g;e[9]!==s||e[10]!==n?(g=i(T=>{s(_=>_.filter(A=>A.id!==T)),n(T)},"b"),e[9]=s,e[10]=n,e[11]=g):g=e[11];let h=g,S;e[12]!==t?(S=i(T=>{t(T.currentTarget.dataset.sql??"",null)},"w"),e[12]=t,e[13]=S):S=e[13];let k=S,N;e[14]!==t?(N=i(T=>{t(T.currentTarget.dataset.sql??"",null)},"S"),e[14]=t,e[15]=N):N=e[15];let C=N,L;e[16]!==a?(L=i(()=>{a([])},"R"),e[16]=a,e[17]=L):L=e[17];let R=L,E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=i(T=>{f(T.target.value)},"I"),e[18]=E):E=e[18];let q=E,O;e[19]!==s?(O=i((T,_)=>{s(A=>A.map(B=>B.id===T?{...B,sql:_}:B))},"L"),e[19]=s,e[20]=O):O=e[20];let M=O,D;return e[21]!==R||e[22]!==h||e[23]!==m||e[24]!==C||e[25]!==k||e[26]!==x||e[27]!==o||e[28]!==v||e[29]!==d||e[30]!==w||e[31]!==M?(D={clearHistory:R,deleteQuery:h,history:m,listRef:p,loadFromHistory:C,loadTemplate:k,newQuery:x,onSearchChange:q,queries:o,recordHistory:v,search:d,selectQuery:w,updateQuerySql:M},e[21]=R,e[22]=h,e[23]=m,e[24]=C,e[25]=k,e[26]=x,e[27]=o,e[28]=v,e[29]=d,e[30]=w,e[31]=M,e[32]=D):D=e[32],D},"In"),it="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Rn=i((l,e)=>{let t=[];for(let r of l){if(r.offset===void 0||r.length===void 0||r.length<=0)continue;let o=Math.max(0,Math.min(r.offset,e)),s=Math.max(o,Math.min(r.offset+r.length,e));o!==s&&t.push({end:s,severity:r.severity,start:o})}t.sort((r,o)=>r.start-o.start);let n=[];for(let r of t)r.start>=(n.at(-1)?.end??0)&&n.push(r);return n},"En"),Ln=i(l=>l==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":l==="empty-response"?"The model returned nothing usable.":"The model could not be reached.","Ln"),En=i(l=>{let e=(0,K.c)(51),{assistant:t,failed:n,onGenerated:r}=l,o=oe(),[s,m]=(0,P.useState)("");if(t.unavailable)return null;let a;e[0]!==t?(a=t.pending("sql"),e[0]=t,e[1]=a):a=e[1];let d=a,f;if(e[2]!==t||e[3]!==n||e[4]!==r||e[5]!==d||e[6]!==s||e[7]!==o){let p=t.reason("sql"),b;e[9]!==t||e[10]!==n||e[11]!==r||e[12]!==s?(b=i(q=>{let O=s.trim();O===""&&!q||ie((async()=>{let M=await t.generate(O===""?"fix the failing statement":O,q?n:void 0);M!==void 0&&r(M)})())},"p"),e[9]=t,e[10]=n,e[11]=r,e[12]=s,e[13]=b):b=e[13];let v=b,u;e[14]!==o?(u=o("Describe the query you want"),e[14]=o,e[15]=u):u=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=i(q=>{m(q.target.value)},"g"),e[16]=x):x=e[16];let y;e[17]!==v?(y=i(q=>{q.key==="Enter"&&(q.preventDefault(),v(!1))},"v"),e[17]=v,e[18]=y):y=e[18];let w;e[19]!==o?(w=o("Describe the query you want"),e[19]=o,e[20]=w):w=e[20];let g;e[21]!==d||e[22]!==s||e[23]!==u||e[24]!==y||e[25]!==w?(g=(0,c.jsx)(Fe,{"aria-label":u,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:d,onChange:x,onKeyDown:y,placeholder:w,value:s}),e[21]=d,e[22]=s,e[23]=u,e[24]=y,e[25]=w,e[26]=g):g=e[26];let h=d&&"opacity-60",S;e[27]!==h?(S=ue("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",h),e[27]=h,e[28]=S):S=e[28];let k;e[29]!==d||e[30]!==s?(k=d||s.trim()==="",e[29]=d,e[30]=s,e[31]=k):k=e[31];let N;e[32]!==v?(N=i(()=>{v(!1)},"S"),e[32]=v,e[33]=N):N=e[33];let C;e[34]!==d||e[35]!==o?(C=o(d?"Thinking\u2026":"Draft SQL"),e[34]=d,e[35]=o,e[36]=C):C=e[36];let L;e[37]!==S||e[38]!==k||e[39]!==N||e[40]!==C?(L=(0,c.jsx)("button",{className:S,"data-testid":"sql-assistant-generate",disabled:k,onClick:N,type:"button",children:C}),e[37]=S,e[38]=k,e[39]=N,e[40]=C,e[41]=L):L=e[41];let R;e[42]!==n||e[43]!==d||e[44]!==v||e[45]!==o?(R=n!==void 0&&(0,c.jsx)("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:d,onClick:i(()=>{v(!0)},"onClick"),type:"button",children:o("Fix this")}),e[42]=n,e[43]=d,e[44]=v,e[45]=o,e[46]=R):R=e[46];let E;e[47]!==L||e[48]!==R||e[49]!==g?(E=(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[g,L,R]}),e[47]=L,e[48]=R,e[49]=g,e[50]=E):E=e[50],f=(0,c.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[E,p!==void 0&&(0,c.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Ln(p)})]}),e[2]=t,e[3]=n,e[4]=r,e[5]=d,e[6]=s,e[7]=o,e[8]=f}else f=e[8];return f},"_n"),_n=i(l=>{let e=(0,K.c)(8),{diagnostics:t,draft:n,scrollRef:r}=l,o,s;if(e[0]!==t||e[1]!==n){s=Symbol.for("react.early_return_sentinel");e:{let d=Rn(t,n.length);if(d.length===0){s=null;break e}o=[];let f=0;for(let[p,b]of d.entries())b.start>f&&o.push(n.slice(f,b.start)),o.push((0,c.jsx)("span",{className:ue("decoration-wavy underline underline-offset-4",b.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:n.slice(b.start,b.end)},`${b.start.toString()}-${p.toString()}`)),f=b.end;o.push(n.slice(f))}e[0]=t,e[1]=n,e[2]=o,e[3]=s}else o=e[2],s=e[3];if(s!==Symbol.for("react.early_return_sentinel"))return s;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=ue("pointer-events-none absolute inset-0 overflow-hidden text-transparent",it),e[4]=m):m=e[4];let a;return e[5]!==o||e[6]!==r?(a=(0,c.jsx)("div",{"aria-hidden":"true",className:m,"data-testid":"sql-diagnostics-overlay",ref:r,children:o}),e[5]=o,e[6]=r,e[7]=a):a=e[7],a},"On"),On={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Mn=i(l=>{let e=(0,K.c)(10),{diagnostics:t,onSelect:n}=l,r=oe();if(t.length===0)return null;let o;e[0]!==r?(o=r("SQL problems"),e[0]=r,e[1]=o):o=e[1];let s;if(e[2]!==t||e[3]!==n){let a;e[5]!==n?(a=i((d,f)=>(0,c.jsx)("li",{children:(0,c.jsxs)("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:i(()=>{n(d)},"onClick"),type:"button",children:[(0,c.jsx)("span",{className:ue("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",d.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:On[d.source]}),(0,c.jsx)("span",{className:"min-w-0 text-muted-foreground",children:d.message})]})},`${d.source}-${(d.offset??f).toString()}-${f.toString()}`),"a"),e[5]=n,e[6]=a):a=e[6],s=t.map(a),e[2]=t,e[3]=n,e[4]=s}else s=e[4];let m;return e[7]!==o||e[8]!==s?(m=(0,c.jsx)("ul",{"aria-label":o,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:s}),e[7]=o,e[8]=s,e[9]=m):m=e[9],m},"Dn"),Dn={minWidth:"2.75rem",paddingInline:"0.5rem"},An=i(l=>{let e=(0,K.c)(64),{assistant:t,autocomplete:n,diagnostics:r,draft:o,failed:s,handlers:m,editorRef:a,gutterRef:d,listboxId:f,onGenerated:p,onPickSuggestion:b,onRevealDiagnostic:v,overlayRef:u}=l,x=oe(),y,w,g,h,S,k,N,C;if(e[0]!==t||e[1]!==o||e[2]!==s||e[3]!==d||e[4]!==p){let $=o.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as me,e as _}from"./chunk-4LCY5XUR.js";import{a as ue}from"./chunk-IGCNMZSB.js";import"./chunk-S3DWUXGY.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import{a as de}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as M}from"./chunk-VDW32UET.js";import{c as ce}from"./chunk-4D7XIQ5Q.js";import{f as ne,g as oe}from"./chunk-DBWOWJYT.js";import"./chunk-XBDKZZ67.js";import{a as A}from"./chunk-UZERI5YC.js";import{d as D,f as j,g as W,h as X,o as K,r as ie}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as p,e as I,f as Ee,g as ae,h as le,j as E}from"./chunk-3XIESWL4.js";var Z=I(ae(),1);var f=I(Ee(),1);var fe=I(ae(),1);var $=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},he=p(()=>{let t=(0,fe.c)(16),e=D(),a=oe(),s;e:switch(a){case"connected":{let o;t[0]!==e?(o=e("Connected"),t[0]=e,t[1]=o):o=t[1],s=o;break e}case"connecting":{let o;t[2]!==e?(o=e("Connecting\u2026"),t[2]=e,t[3]=o):o=t[3],s=o;break e}case"idle":{let o;t[4]!==e?(o=e("Idle"),t[4]=e,t[5]=o):o=t[5],s=o;break e}case"offline":{let o;t[6]!==e?(o=e("Offline"),t[6]=e,t[7]=o):o=t[7],s=o;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=E("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let i;t[10]!==c?(i=(0,$.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=i):i=t[11];let n;return t[12]!==a||t[13]!==i||t[14]!==s?(n=(0,$.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[12]=a,t[13]=i,t[14]=s,t[15]=n):n=t[15],n},"j");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=p((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"_"),Y=p((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","V"),xe=.01,ve=.05,je=p(t=>{let e=(0,Z.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=D(),n;e[0]!==i?(n=i("Functions by error rate"),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==n?(o=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=o):o=e[3];let h;e[4]!==i||e[5]!==c?(h=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(y=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:y.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:y.calls.toString()})}),(0,r.jsx)(T,{variant:Ae[Y(y.errors/y.calls,xe,ve)],children:U(y.errors,y.calls)})]})]},y.path))}),e[4]=i,e[5]=c,e[6]=h):h=e[6];let g;e[7]!==o||e[8]!==h?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[o,h]}),e[7]=o,e[8]=h,e[9]=g):g=e[9];let b;e[10]!==i?(b=i("Recent errors"),e[10]=i,e[11]=b):b=e[11];let d;e[12]!==b?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[12]=b,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(T,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==i||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=S):S=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==v?(N=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=v,e[32]=N):N=e[32];let w;return e[33]!==N||e[34]!==g?(w=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,N]}),e[33]=N,e[34]=g,e[35]=w):w=e[35],w},"Se");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}p(Ce,"qe");var pe={completed:0,failed:2,in_progress:1},Ie=p(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:n}of t){if(n===null){l+=1;continue}s+=1,e+=n.requests,a+=n.errors,i.push(...n.history??[]),c||=n.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ee"),De=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"Me"),Te=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=pe[s.status]-pe[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"$e"),Pe=j(M.getAuthMetrics),Fe=j(M.getFunctionStats),Le=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,Ke=5,_e=.1,$e=.3,He=1,Ue=50,Ge=p((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","_e"),Qe=p(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"ze"),Je=p(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ke"),Ve=p((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"He"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},We={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Xe=p(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Be"),H=p(t=>{let e=(0,Z.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,n=be[l],o;e[0]!==n?(o=E("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=o):o=e[1];let h;e[2]!==o?(h=(0,r.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=h):h=e[3];let g;e[4]!==s||e[5]!==h?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[h,s]}),e[4]=s,e[5]=h,e[6]=g):g=e[6];let b=Ne[l],d;e[7]!==b?(d=E("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"O"),Ye=p(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=W(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=W(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,n,o]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),h=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(h),b=s[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:De(h.map(d=>d.functions)),logsError:i.status==="rejected"?X(i.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?X(b.reason):null,migrations:Te(h.map(d=>d.migrations)),scheduler:o.status==="fulfilled"?o.value:null,totals:g}},"Ge"),Ze=p(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"Qe"),xt=p(({initialShardKey:t})=>{let e=ne(),a=D(),[s,l]=(0,f.useState)([]),[c,i]=(0,f.useState)(null),[n,o]=(0,f.useState)(null),[h,g]=(0,f.useState)(null),[b,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,q]=(0,f.useState)([]),[N]=(0,f.useState)(de),w=(0,f.useRef)(!1),y=(0,f.useRef)(!0);(0,f.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]);let P=t??"",F=(0,f.useCallback)(async()=>{if(w.current)return;w.current=!0;let m=await Ye(e,P,me(P,N));if(!y.current){w.current=!1;return}o(m.totals),g(m.metricsError),d(m.functions),q(m.migrations),l(m.entries),i(m.logsError),x(m.auth),k(m.scheduler),w.current=!1},[e,N,P]);(0,f.useEffect)(()=>{K(F())},[F]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),ye=p(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),K(F());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),K(F())},ge-m))},"de");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:B,liveError:we}=ce(M.getMetrics,{},{live:!0,shardKey:P});(0,f.useEffect)(()=>{B!==void 0&&ye()},[B]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),L=Qe(n?.history),te=Ze(u),Se=b.filter(m=>m.calls>0).toSorted((m,V)=>V.errors/V.calls-m.errors/m.calls||V.calls-m.calls).slice(0,Ke),Q=Je(S),qe=n===null||n.requests===0?0:n.errors/n.requests,J=Y(qe,xe,ve),re=u===null?"ok":Y(u.failureRate,_e,$e),se=v===null?"ok":Ge(v.backlog,He,Ue),R=Xe([J,re,se,Q.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:E("flex size-10 shrink-0 items-center justify-center rounded-full",We[R]),children:(0,r.jsx)("span",{className:E("size-3 rounded-full",be[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsx)(_,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:E("text-lg font-semibold tabular-nums",Ne[J]),"data-testid":"hl-error-rate",children:n===null?"\u2014":U(n.errors,n.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(he,{}),(0,r.jsx)(ue,{message:we,prefix:"hl"})]})]})]}),h!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:h}),h===null&&n?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:L.errors.length>=2?(0,r.jsx)(_,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:n===null?"\u2014":U(n.errors,n.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)(_,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:Q.level,testId:"hl-slo-migrations",value:Ve(Q,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(T,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(T,{variant:"secondary",children:m})},m))})]})]})},"dt");export{xt as HealthPanel};
|
|
1
|
+
import{b as me,e as _}from"./chunk-4LCY5XUR.js";import{a as ue}from"./chunk-IGCNMZSB.js";import"./chunk-S3DWUXGY.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import{a as de}from"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as M}from"./chunk-VDW32UET.js";import{c as ce}from"./chunk-ZNAGZU6H.js";import{f as ne,g as oe}from"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import{a as A}from"./chunk-UZERI5YC.js";import{d as D,f as j,g as W,h as X,o as K,r as ie}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as p,e as I,f as Ee,g as ae,h as le,j as E}from"./chunk-3XIESWL4.js";var Z=I(ae(),1);var f=I(Ee(),1);var fe=I(ae(),1);var $=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},he=p(()=>{let t=(0,fe.c)(16),e=D(),a=oe(),s;e:switch(a){case"connected":{let o;t[0]!==e?(o=e("Connected"),t[0]=e,t[1]=o):o=t[1],s=o;break e}case"connecting":{let o;t[2]!==e?(o=e("Connecting\u2026"),t[2]=e,t[3]=o):o=t[3],s=o;break e}case"idle":{let o;t[4]!==e?(o=e("Idle"),t[4]=e,t[5]=o):o=t[5],s=o;break e}case"offline":{let o;t[6]!==e?(o=e("Offline"),t[6]=e,t[7]=o):o=t[7],s=o;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=E("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let i;t[10]!==c?(i=(0,$.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=i):i=t[11];let n;return t[12]!==a||t[13]!==i||t[14]!==s?(n=(0,$.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[12]=a,t[13]=i,t[14]=s,t[15]=n):n=t[15],n},"j");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=p((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"_"),Y=p((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","V"),xe=.01,ve=.05,je=p(t=>{let e=(0,Z.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=D(),n;e[0]!==i?(n=i("Functions by error rate"),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==n?(o=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=o):o=e[3];let h;e[4]!==i||e[5]!==c?(h=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(y=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:y.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:y.calls.toString()})}),(0,r.jsx)(T,{variant:Ae[Y(y.errors/y.calls,xe,ve)],children:U(y.errors,y.calls)})]})]},y.path))}),e[4]=i,e[5]=c,e[6]=h):h=e[6];let g;e[7]!==o||e[8]!==h?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[o,h]}),e[7]=o,e[8]=h,e[9]=g):g=e[9];let b;e[10]!==i?(b=i("Recent errors"),e[10]=i,e[11]=b):b=e[11];let d;e[12]!==b?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[12]=b,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(T,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==i||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=S):S=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==v?(N=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=v,e[32]=N):N=e[32];let w;return e[33]!==N||e[34]!==g?(w=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,N]}),e[33]=N,e[34]=g,e[35]=w):w=e[35],w},"Se");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}p(Ce,"qe");var pe={completed:0,failed:2,in_progress:1},Ie=p(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:n}of t){if(n===null){l+=1;continue}s+=1,e+=n.requests,a+=n.errors,i.push(...n.history??[]),c||=n.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ee"),De=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"Me"),Te=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=pe[s.status]-pe[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"$e"),Pe=j(M.getAuthMetrics),Fe=j(M.getFunctionStats),Le=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,Ke=5,_e=.1,$e=.3,He=1,Ue=50,Ge=p((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","_e"),Qe=p(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"ze"),Je=p(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ke"),Ve=p((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"He"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},We={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Xe=p(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Be"),H=p(t=>{let e=(0,Z.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,n=be[l],o;e[0]!==n?(o=E("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=o):o=e[1];let h;e[2]!==o?(h=(0,r.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=h):h=e[3];let g;e[4]!==s||e[5]!==h?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[h,s]}),e[4]=s,e[5]=h,e[6]=g):g=e[6];let b=Ne[l],d;e[7]!==b?(d=E("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"O"),Ye=p(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=W(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=W(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,n,o]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),h=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(h),b=s[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:De(h.map(d=>d.functions)),logsError:i.status==="rejected"?X(i.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?X(b.reason):null,migrations:Te(h.map(d=>d.migrations)),scheduler:o.status==="fulfilled"?o.value:null,totals:g}},"Ge"),Ze=p(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"Qe"),xt=p(({initialShardKey:t})=>{let e=ne(),a=D(),[s,l]=(0,f.useState)([]),[c,i]=(0,f.useState)(null),[n,o]=(0,f.useState)(null),[h,g]=(0,f.useState)(null),[b,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,q]=(0,f.useState)([]),[N]=(0,f.useState)(de),w=(0,f.useRef)(!1),y=(0,f.useRef)(!0);(0,f.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]);let P=t??"",F=(0,f.useCallback)(async()=>{if(w.current)return;w.current=!0;let m=await Ye(e,P,me(P,N));if(!y.current){w.current=!1;return}o(m.totals),g(m.metricsError),d(m.functions),q(m.migrations),l(m.entries),i(m.logsError),x(m.auth),k(m.scheduler),w.current=!1},[e,N,P]);(0,f.useEffect)(()=>{K(F())},[F]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),ye=p(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),K(F());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),K(F())},ge-m))},"de");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:B,liveError:we}=ce(M.getMetrics,{},{live:!0,shardKey:P});(0,f.useEffect)(()=>{B!==void 0&&ye()},[B]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),L=Qe(n?.history),te=Ze(u),Se=b.filter(m=>m.calls>0).toSorted((m,V)=>V.errors/V.calls-m.errors/m.calls||V.calls-m.calls).slice(0,Ke),Q=Je(S),qe=n===null||n.requests===0?0:n.errors/n.requests,J=Y(qe,xe,ve),re=u===null?"ok":Y(u.failureRate,_e,$e),se=v===null?"ok":Ge(v.backlog,He,Ue),R=Xe([J,re,se,Q.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:E("flex size-10 shrink-0 items-center justify-center rounded-full",We[R]),children:(0,r.jsx)("span",{className:E("size-3 rounded-full",be[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsx)(_,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:E("text-lg font-semibold tabular-nums",Ne[J]),"data-testid":"hl-error-rate",children:n===null?"\u2014":U(n.errors,n.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(he,{}),(0,r.jsx)(ue,{message:we,prefix:"hl"})]})]})]}),h!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:h}),h===null&&n?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:L.errors.length>=2?(0,r.jsx)(_,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:n===null?"\u2014":U(n.errors,n.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)(_,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:Q.level,testId:"hl-slo-migrations",value:Ve(Q,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(T,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(T,{variant:"secondary",children:m})},m))})]})]})},"dt");export{xt as HealthPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Y}from"./chunk-AREBQI6D.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-RMN2JN4S.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-
|
|
1
|
+
import{a as Y}from"./chunk-AREBQI6D.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-RMN2JN4S.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-ZZJ7VUVZ.js";import{a as _,b as W}from"./chunk-BN4CIAXU.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-465RIA2L.js";import"./chunk-XXQUMVWH.js";import"./chunk-O3UMJLO3.js";import"./chunk-QLQADHFE.js";import{a as I}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-ZNAGZU6H.js";import{f as B}from"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import"./chunk-MIQTKZAR.js";import"./chunk-UZERI5YC.js";import{d as A,f as H,g as K,o as k}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as l,e as L,f as fe,g as he,h as me}from"./chunk-3XIESWL4.js";var j=L(he(),1);var u=L(fe(),1);var $=L(me(),1);var pe=l(t=>{let{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},"pe"),be=l((t,e,r)=>{let a=`"${t}"`,n=`"${e}"`,o=r.map(c=>`"${c}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${n} ON ${a} (${o});`},"ge"),ge=l(t=>{let e=(0,j.c)(19),{fields:r,indexName:a,table:n,testId:o}=t,c=A(),[T,p]=(0,u.useState)(!1),f;e[0]!==r||e[1]!==a||e[2]!==n?(f=l(()=>{let S="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(S===void 0)return;let y=be(n,a,r);k(S.writeText(y)),p(!0)},"d"),e[0]=r,e[1]=a,e[2]=n,e[3]=f):f=e[3];let v=f;if(T){let S=`${o}-applied`,y;e[4]!==c?(y=c("CREATE INDEX SQL copied to clipboard."),e[4]=c,e[5]=y):y=e[5];let E;return e[6]!==S||e[7]!==y?(E=(0,$.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":S,children:y}),e[6]=S,e[7]=y,e[8]=E):E=e[8],E}let w;e[9]!==c?(w=c("Apply?"),e[9]=c,e[10]=w):w=e[10];let h;e[11]!==c||e[12]!==n?(h=c("Apply index on {table}",{table:n}),e[11]=c,e[12]=n,e[13]=h):h=e[13];let x;return e[14]!==v||e[15]!==w||e[16]!==h||e[17]!==o?(x=(0,$.jsx)(Y,{confirmLabel:w,onConfirm:v,testId:o,children:h}),e[14]=v,e[15]=w,e[16]=h,e[17]=o,e[18]=x):x=e[18],x},"be"),ve=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"xe"),xe=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"ye"),te=l((t,e)=>e.map(r=>({index:r.name,table:t})),"X"),ye=l(t=>{let e=ve(t.declaredIndexes??[],t.indexHits??[]),r=xe(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,o=n&&n.indexHits.length>0?n.indexHits:e,c=n&&n.tableScans.length>0?n.tableScans:r,T=n&&n.shardTraffic.length>0?n.shardTraffic:a,p=ee({indexHits:o,schema:{tables:[]},shardTraffic:T,tableScans:c},{lints:Z,source:"runtime"}),f=t.suppressHotScanTables;return(f===void 0?p:p.filter(v=>!(v.metadata.kind==="hot_scan"&&typeof v.metadata.table=="string"&&f.has(v.metadata.table)))).map(v=>_(v))},"ve"),we=H(I.listTables),Se=H(I.listTableIndexes),Te=H(I.listTablesIndexes),q=l(t=>`${(t*100).toFixed(1)}%`,"K"),ae=l(t=>`${(t/1e3).toFixed(2)}s`,"B"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Te"),Ie=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],"Ie"),ne=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:q(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:q(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:q(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:ae(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:ae(e.value)})})[e.kind],"J"),Ee=l(t=>{let e=(0,j.c)(10),{onJump:r,table:a}=t,n=A(),o;e[0]!==r||e[1]!==a?(o=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=o):o=e[2];let c=o,T=`in-add-index-${a}`,p;e[3]!==n||e[4]!==a?(p=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=p):p=e[5];let f;return e[6]!==c||e[7]!==T||e[8]!==p?(f=(0,$.jsx)(U,{"data-testid":T,onClick:c,size:"sm",type:"button",variant:"outline",children:p}),e[6]=c,e[7]=T,e[8]=p,e[9]=f):f=e[9],f},"Ee"),De=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=B(),a=P(),n=A(),{queryShardKey:o,setShardKey:c,shardKey:T}=V(t),[p,f]=(0,u.useState)(null),[v,w]=(0,u.useState)(null),h=(0,u.useRef)(""),x=M(I.getMetrics,{},{live:!0,shardKey:o}),S=M(I.getFunctionStats,{},{live:!0,shardKey:o}),y=M(I.getAdvisories,{},{live:!0,shardKey:o}),E=x.data??null,F=S.data?.functions??null,O=y.data?.advisories??null,re=x.data?.indexHits??null,R=x.error!==null&&S.error!==null?x.error:null,se=e??(s=>r.shardTraffic(s)),ie=l(async(s,b)=>{let i=s[0];if(i===void 0||i===""){h.current===b&&w(null);return}try{let m=await se(i);if(h.current!==b)return;let d=new Map;for(let g of m.shards)d.has(g.shardKey)||d.set(g.shardKey,{requests:g.requests,shardKey:g.shardKey});w([...d.values()])}catch{h.current===b&&w(null)}},"V"),oe=l(async(s,b)=>{let i=await Promise.allSettled(s.map(async d=>[d,await r.query(Se,{table:d},K(b))])),m=[];for(let d of i)if(d.status==="fulfilled"){let[g,N]=d.value;m.push(...te(g,N.indexes))}return m},"G"),D=(0,u.useEffectEvent)(async s=>{h.current=s;let b=[];try{let i=await r.query(we,{},K(s));if(h.current!==s)return;Q(s),b=i.map(d=>d.name);let m=[];if(b.length>0)try{let d=await r.query(Te,{tables:b},K(s));if(h.current!==s)return;for(let[g,N]of Object.entries(d.indexesByTable))m.push(...te(g,N))}catch{if(m=await oe(b,s),h.current!==s)return}f(m)}catch{h.current===s&&f(null)}await ie(b,s)});(0,u.useEffect)(()=>{k(D(o))},[o]);let le=(0,u.useEffectEvent)(()=>{x.refetch(),S.refetch(),y.refetch(),k(D(o))});(0,u.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&le()},"i");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let J=(0,u.useCallback)(s=>{k(a({search:{table:s},to:"/schema"}))},[a]),C=z(E,F),ce=new Set(C.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),X=ye({declaredIndexes:p??[],functions:F,indexHits:re,shardTraffic:v,suppressHotScanTables:ce}),de=(0,u.useMemo)(()=>{let s=C.map(i=>{let m=i.kind==="missing-index"?i.tables??[]:[];return{action:m.length>0?m.map(d=>(0,$.jsx)(Ee,{onJump:J,table:d},d)):void 0,description:i.message===void 0?ne(n,i):`${ne(n,i)} \u2014 ${i.message}`,entity:i.fn,issueType:Ie(n,i),key:`${i.kind}:${i.fn??""}`,level:i.severity}}),b=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(O??[]).map(i=>{let m=_(i);if(b.has(i.name)&&pe(i.metadata)){let{table:d,suggestedIndex:g}=i.metadata,N=`in-apply-index-${d}-${g.name}`;return{...m,action:(0,$.jsx)(ge,{fields:g.fields,indexName:g.name,table:d,testId:N})}}return m}),...X,...s]},[O,C,J,X,n]),ue=(0,$.jsx)(G,{onChange:c,testId:"in-shard-input",value:T});return(0,$.jsx)(W,{error:R,errorSource:R===null?void 0:x.errorSource,rows:de,testId:"lunora-insights",toolbar:ue})},"Je");export{De as InsightsPanel};
|
|
@@ -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-ZNAGZU6H.js";import{f as O}from"./chunk-5KCULF7S.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-IUYFXK4X.js";import"./chunk-XNGYYOLS.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as y}from"./chunk-3XIESWL4.js";var p=y(e=>{let n="";for(let c=0;c<e.length;c+=32768)n+=String.fromCharCode(...e.subarray(c,c+32768));return btoa(n)},"b"),A=y(e=>{let n=atob(e),c=new Uint8Array(n.length);for(let s=0;s<n.length;s+=1)c[s]=n.codePointAt(s)??0;return c},"m"),o="$lunora.wire$",d="__proto__",g={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},w={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},m=y(e=>{if(e===null||typeof e!="object")return!1;let n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},"g"),f=y((e,n=0)=>{if(n>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(e===void 0)return[o,"undefined"];if(e===null)return null;let c=typeof e;if(c==="bigint")return[o,"bigint",e.toString()];if(c==="number"){let r=e;return Number.isNaN(r)?[o,"nan"]:r===1/0?[o,"inf"]:r===-1/0?[o,"-inf"]:r}if(c!=="object")return e;if(e instanceof Date)return[o,"date",f(e.getTime(),n+1)];if(e instanceof Error){let r=e,a={};for(let l of Object.keys(r))r[l]!==void 0&&(a[l]=f(r[l],n+1));let i=[o,"error",r.name,r.message,a];return r.cause!==void 0&&i.push(f(r.cause,n+1)),i}if(e instanceof URL)return[o,"url",e.href];if(e instanceof Map)return[o,"map",[...e.entries()].map(([r,a])=>[f(r,n+1),f(a,n+1)])];if(e instanceof Set)return[o,"set",[...e].map(r=>f(r,n+1))];if(e instanceof ArrayBuffer)return[o,"bytes",p(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){let r=e,a=r.constructor.name,i=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);return a==="Uint8Array"?[o,"bytes",p(i)]:[o,"bytes",p(i),a]}if(Array.isArray(e)){let r=e.map(a=>f(a,n+1));return r.length>0&&r[0]===o?[o,"arr",r]:r}if(!m(e)){let r=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${r} over the Lunora wire \u2014 only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}let s=e,t={};for(let r of Object.keys(s)){let a=s[r];if(a===void 0)continue;let i=f(a,n+1);r===d?Object.defineProperty(t,r,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[r]=i}return t},"s"),u=y((e,n=0)=>{if(n>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(e===null||typeof e!="object")return e;if(Array.isArray(e)){if(e[0]===o)switch(e[1]){case"-inf":return-1/0;case"arr":return e[2].map(t=>u(t,n+1));case"bigint":{let t=e[2];if(typeof t!="string"||t.length>1024||!/^-?\d+$/.test(t))throw new RangeError("wire-codec: invalid or over-long bigint (max 1024 digits)");return BigInt(t)}case"date":return new Date(u(e[2],n+1));case"map":return new Map(e[2].map(([t,r])=>[u(t,n+1),u(r,n+1)]));case"set":return new Set(e[2].map(t=>u(t,n+1)));case"url":return new URL(e[2]);case"error":{let t=e[2],r=e[3],a=(Object.hasOwn(w,t)?w[t]:void 0)??Error,i=new a(r);i.name!==t&&Object.defineProperty(i,"name",{configurable:!0,value:t,writable:!0});let l=u(e[4],n+1);for(let b of Object.keys(l))b===d?Object.defineProperty(i,b,{configurable:!0,enumerable:!0,value:l[b],writable:!0}):i[b]=l[b];return e.length>5&&Object.defineProperty(i,"cause",{configurable:!0,value:u(e[5],n+1),writable:!0}),i}case"bytes":{let t=A(e[2]),r=e[3]??"Uint8Array";if(r==="ArrayBuffer")return t.buffer.byteLength===t.byteLength?t.buffer:t.slice().buffer;let a=Object.hasOwn(g,r)?g[r]:void 0;return a?new a(t.slice().buffer):t}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return e.map(t=>u(t,n+1))}return e.map(t=>u(t,n+1))}let c=e,s={};for(let t of Object.keys(c)){let r=u(c[t],n+1);t===d?Object.defineProperty(s,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):s[t]=r}return s},"f"),h=y(e=>{try{let n=u(JSON.parse(e));return m(n)?n:void 0}catch{return}},"A");export{m as a,f as b,u as c,h as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as k}from"./chunk-
|
|
1
|
+
import{d as k}from"./chunk-MLT5MMMY.js";import{a as j}from"./chunk-54MMVNPT.js";import{a as E}from"./chunk-ZQPWVALL.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as T}from"./chunk-465RIA2L.js";import"./chunk-XXQUMVWH.js";import"./chunk-O3UMJLO3.js";import"./chunk-QLQADHFE.js";import{a as y}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-ZNAGZU6H.js";import"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-MIQTKZAR.js";import{a as u,e as N}from"./chunk-UZERI5YC.js";import{d as _,r as S}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as c,e as U,h as G}from"./chunk-3XIESWL4.js";var e=U(G(),1);var H=["subscriptions","events"],$={},D=new Set(["active","trialing"]),q=new Set(["past_due","unpaid"]),a=c((s,t)=>{if(s[t]!==void 0)return s[t];let m=s.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"i"),i=c(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","s"),z=c(s=>D.has(s)?"default":q.has(s)?"destructive":"outline","L"),ae=c(({limit:s=100})=>{let t=_(),m=E(),{data:g}=b(y.listTables,$,{live:!0}),O=g!==void 0,B=Array.isArray(g)&&H.every(r=>g.some(d=>d.name===r)),p=m.payments&&B,o=b(y.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),h=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),h.refetch())},!0);let f=o.data?.rows??[],C=h.data?.rows??[],F=o.error??h.error,L=o.error===null?h.errorSource:o.errorSource,P=f.filter(r=>D.has(i(a(r,"state")))).length,M=C.toSorted((r,d)=>Number(a(d,"processedAt")??0)-Number(a(r,"processedAt")??0));return O&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(u,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:f.length})})]})}),F===null?void 0:(0,e.jsx)(T,{error:L}),f.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(u,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(A,{children:f.map(r=>{let d=i(a(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{children:i(a(r,"referenceId"))}),(0,e.jsx)(n,{children:i(a(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(x,{variant:z(d),children:d})}),(0,e.jsx)(n,{children:S(a(r,"currentPeriodEnd"))})]},i(a(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(u,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:M.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(a(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(a(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(a(r,"processedAt"))})]},i(a(r,"providerEventId"))))})})})]})]})},"ae");export{ae as PaymentsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-ZNAGZU6H.js";import{a as o}from"./chunk-3XIESWL4.js";var b="__lunora_admin__:",g=new Set(["action","mutation","query"]),u=Symbol("lunora.operationSeq"),h=o(t=>{if(typeof t!="object"||t===null)return;let e=t[u];return typeof e=="number"?e:void 0},"j"),m=o((t,e)=>{if(!(typeof t!="object"||t===null||!Object.isExtensible(t)))try{Object.defineProperty(t,u,{configurable:!0,enumerable:!1,value:e,writable:!0})}catch{}},"g"),d=o(t=>{if(typeof t!="object"||t===null)return;let e=t.__lunoraRef;return typeof e=="string"&&e.startsWith(b)?e:void 0},"d"),j=o(t=>{if(typeof t!="object"||t===null)return"";let{shardKey:e}=t;return typeof e=="string"?e:""},"m"),w=o(t=>new Proxy(t,{get(e,a,y){let i=Reflect.get(e,a,y);if(typeof i!="function"||typeof a!="string"||!g.has(a))return typeof i=="function"?i.bind(e):i;let f=i;return async(...n)=>{let l=d(n[0]);if(l===void 0)return f.apply(e,n);let p=typeof n[1]=="object"&&n[1]!==null?n[1]:{},c=s.start(l,p,j(n[2]));try{let r=await f.apply(e,n);return s.settle(c,{result:r}),r}catch(r){throw s.settle(c,{error:r instanceof Error?r.message:String(r)}),m(r,c),r}}}}),"_");export{h as a,w as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as He}from"./chunk-IUUSMC2R.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 we}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 Ze}from"./chunk-3CWGJYBB.js";import{a as Xe}from"./chunk-RMN2JN4S.js";import{b as We}from"./chunk-GRL5MG3Z.js";import{e as Ue}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import{R as Ae}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as me}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ze}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as je}from"./chunk-VDW32UET.js";import{f as Be}from"./chunk-DBWOWJYT.js";import"./chunk-XBDKZZ67.js";import{a as Je}from"./chunk-XQCVZAGU.js";import{a as qe,b as Ke,c as Pe,d as Ge,e as Le}from"./chunk-UZERI5YC.js";import{d as Fe,f as Ee,g as Oe,h as $e,o as ue}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as r,e as De,f as at,g as nt,h as st,j as Re}from"./chunk-3XIESWL4.js";var Ce=De(nt(),1);var x=De(at(),1);var t=De(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Qe=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Be(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:b}=Ze(u),[o,p]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[g,K]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),P;e[1]===Symbol.for("react.memo_cache_sentinel")?(P={},e[1]=P):P=e[1];let[E,M]=(0,x.useState)(P),[T,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[O,he]=(0,x.useState)(F),H;e[3]===Symbol.for("react.memo_cache_sentinel")?(H={},e[3]=H):H=e[3];let[I,G]=(0,x.useState)(H),[k,pe]=(0,x.useState)(null),[D,oe]=(0,x.useState)(null),Q;e[4]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[4]=Q):Q=e[4];let[J,xe]=(0,x.useState)(Q),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{K(null);try{let w=await l.query(rt,{},Oe(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),G(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),K($e(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let $=ve,Y;e[7]!==l?(Y=r(async()=>{oe(null);try{pe(await l.listGlobalTables())}catch(h){let w=h;pe(null),oe($e(w))}},"Q"),e[7]=l,e[8]=Y):Y=e[8];let ee=Y,de,R;e[9]!==c||e[10]!==$||e[11]!==ee?(de=r(()=>{ue($(c)),ue(ee())},"de"),R=[$,ee,c],e[9]=c,e[10]=$,e[11]=ee,e[12]=de,e[13]=R):(de=e[12],R=e[13]),(0,x.useEffect)(de,R);let te;e[14]!==l||e[15]!==L||e[16]!==T||e[17]!==c?(te=r(async h=>{if(T===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},Oe(c)),l.query(ot,{table:h},Oe(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):K($e(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=T,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe($e(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,ge=(0,x.useRef)(void 0),V,X;e[23]!==n||e[24]!==i||e[25]!==j?(V=r(()=>{n===void 0||i===null||ge.current===n||i.some(h=>h.name===n)&&(ge.current=n,ue(j(n)))},"V"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=V,e[27]=X):(V=e[26],X=e[27]),(0,x.useEffect)(V,X);let B;e[28]!==l?(B=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},Oe(h))]),Promise.all(N.map(async S=>{let be=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:S})]),Ie=be[0].status==="fulfilled"?be[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:S}}))]),Se=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Te=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(S=>{let be=Se[S]??[];return[S,be.length>0?be:_e.get(S)??[]]});he(S=>({...S,[h]:Object.fromEntries(ke)})),G(S=>({...S,[h]:Te}))},"B"),e[28]=l,e[29]=B):B=e[29];let le=B,U,ae;e[30]!==D||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==O||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&D===null||O[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(pt)))},"U"),ae=[a,i,k,D,c,O,le],e[30]=D,e[31]=k,e[32]=le,e[33]=c,e[34]=O,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=O[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Qe,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Qe,name:A.name,tier:"global"}),"y"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,Z;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();Z=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=Z}else Z=e[52];let Ne=Z,fe;return e[53]!==L||e[54]!==se||e[55]!==g||e[56]!==T||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==D||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==$||e[65]!==d||e[66]!==I||e[67]!==b||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:g,expanded:T,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:D,globalExpanded:W,globalTables:k,indexes:E,refresh:$,setShardKey:d,setTableFilter:p,setView:m,shardColumnsError:I,shardKey:b,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=g,e[56]=T,e[57]=Ne,e[58]=re,e[59]=J,e[60]=D,e[61]=W,e[62]=k,e[63]=E,e[64]=$,e[65]=d,e[66]=I,e[67]=b,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(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(ut,"mt");function ht(s){return s.name}r(ht,"ut");function pt(s){return s.name}r(pt,"ht");var gt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(gt,{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)})`}},"gt"),bt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),b=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let p;e[2]!==m||e[3]!==b||e[4]!==o?(p=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:b,children:o}),e[2]=m,e[3]=b,e[4]=o,e[5]=p):p=e[5];let i=!u,v=n==="addColumn"?"default":"outline",g;e[6]!==d?(g=d("Add column"),e[6]=d,e[7]=g):g=e[7];let K;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==g?(K=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:g}),e[8]=l,e[9]=i,e[10]=v,e[11]=g,e[12]=K):K=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let P;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=P):P=e[19];let E=!u,M=n==="destructive"?"default":"ghost",T;e[20]!==d?(T=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=T):T=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==T?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:T}),e[22]=c,e[23]=E,e[24]=M,e[25]=T,e[26]=C):C=e[26];let F;return e[27]!==P||e[28]!==C||e[29]!==p||e[30]!==K?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[p,K,P,C]}),e[27]=P,e[28]=C,e[29]=p,e[30]=K,e[31]=F):F=e[31],F},"bt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(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]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=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]=o):o=e[5];let p;e[6]!==o?(p=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=p):p=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let g;return e[13]!==p||e[14]!==v?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[p,v]}),e[13]=p,e[14]=v,e[15]=g):g=e[15],g}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let b;return e[25]!==m||e[26]!==d?(b=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=b):b=e[27],b},"ft");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{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()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Nt"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,b]=(0,x.useState)(!1),[o,p]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[g,K]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,P]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[T,C]=(0,x.useState)(""),[F,O]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),K(""),M(""),C(""),O(!1)},"me"),e[0]=he):he=e[0];let H=he,I;e[1]!==u?(I=r(async S=>{b(!0),p(null);try{let be=await ft(S);p(be),be.kind==="ok"&&(u(be.tables),H())}catch(be){let Ie=be;p({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}b(!1)},"k"),e[1]=u,e[2]=I):I=e[2];let G=I,k;e[3]!==G||e[4]!==i?(k=r(()=>{ue(G({kind:"addTable",table:i.trim()}))},"_"),e[3]=G,e[4]=i,e[5]=k):k=e[5];let pe=k,D;e[6]!==g||e[7]!==G||e[8]!==y||e[9]!==_?(D=r(()=>{ue(G({column:g.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"D"),e[6]=g,e[7]=G,e[8]=y,e[9]=_,e[10]=D):D=e[10];let oe=D,Q;e[11]!==T||e[12]!==E||e[13]!==G||e[14]!==y||e[15]!==F?(Q=r(()=>{ue(G({fields:Ct(T),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"H"),e[11]=T,e[12]=E,e[13]=G,e[14]=y,e[15]=F,e[16]=Q):Q=e[16];let J=Q,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{p(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{p(null),c("addColumn")},"ie"),e[18]=ie):ie=e[18];let ve=ie,$;e[19]===Symbol.for("react.memo_cache_sentinel")?($=r(()=>{p(null),c("addIndex")},"q"),e[19]=$):$=e[19];let Y=$,ee;e[20]!==l?(ee=r(()=>{c("destructive"),p({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=r(S=>{v(S.target.value)},"R"),e[22]=R):R=e[22];let te=R,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(S=>{K(S.target.value)},"z"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(S=>{L(S.target.value)},"ce"),e[24]=ce):ce=e[24];let ge=ce,V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=r(S=>{P(S.target.value)},"V"),e[25]=V):V=e[25];let X=V,B;e[26]===Symbol.for("react.memo_cache_sentinel")?(B=r(S=>{M(S.target.value)},"B"),e[26]=B):B=e[26];let le=B,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(S=>{C(S.target.value)},"U"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(S=>{O(S.target.checked)},"E"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"se"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let Z;e[33]!==re?(Z=(0,t.jsx)(Pe,{children:re}),e[33]=re,e[34]=Z):Z=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ge,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==Z||e[40]!==fe?(h=(0,t.jsxs)(Ke,{children:[Z,fe]}),e[39]=Z,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(bt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Y,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==pe||e[49]!==l||e[50]!==i?(q=m==="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)(we,{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:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:pe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:H,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=pe,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==g||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="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)(we,{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:X,value:y,children:n.map(St)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{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:ye,value:g})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{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:ge,value:_,children:yt.map(Tt)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||g.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:H,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=g,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Se;e[61]!==d||e[62]!==T||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Se=m==="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)(we,{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:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{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:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{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:ae,value:T})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||T.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:H,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=T,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Se):Se=e[70];let Te;e[71]!==f||e[72]!==o?(Te=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Te):Te=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Se||e[78]!==Te?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Se,Te]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Se,e[78]=Te,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Ct");function St(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(St,"Tt");function Tt(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(Tt,"wt");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"St");var Ye=[],kt=r(s=>{let e=(0,Ce.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 m;return e[3]!==l?(m=(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]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,b;e[0]!==n?(b=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=b):b=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let p;e[4]!==m?(p=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=p):p=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==b||e[9]!==o||e[10]!==p||e[11]!==d?(i=(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:[b,o," ",p]}),e[6]=n,e[7]=a,e[8]=b,e[9]=o,e[10]=p,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let g;return e[16]!==c||e[17]!==i||e[18]!==v?(g=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=g):g=e[19],g},"Xe"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),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},"Ye"),It=r(s=>{let e=(0,Ce.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 m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"$t"),lt=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"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:b,expanded:o,filteredGlobalTables:p,filteredTables:i,globalColumns:v,globalError:g,globalExpanded:K,globalTables:_,indexes:L,refresh:y,setShardKey:P,setTableFilter:E,setView:M,shardColumnsError:T,shardKey:C,tableFilter:F,tables:O,toggle:he,toggleGlobal:H,view:I}=mt(m),G;e[3]!==M?(G=r(()=>{M("list")},"G"),e[3]=M,e[4]=G):G=e[4];let k=G,pe;e[5]!==M?(pe=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=pe):pe=e[6];let D=pe,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"oe"),e[7]=E,e[8]=oe):oe=e[8];let Q=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"X"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==O?(W=O??[],e[12]=O,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,$;e[16]!==P||e[17]!==C?($=(0,t.jsx)(Xe,{onChange:P,testId:"sc-shard-input",value:C}),e[16]=P,e[17]=C,e[18]=$):$=e[18];let Y;e[19]!==a?(Y=a("Schema view"),e[19]=a,e[20]=Y):Y=e[20];let ee=I==="graph",de=I==="graph",R;e[21]!==de?(R=lt(de),e[21]=de,e[22]=R):R=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==D||e[26]!==ee||e[27]!==R||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:R,"data-testid":"sc-view-graph",onClick:D,role:"tab",type:"button",children:te}),e[25]=D,e[26]=ee,e[27]=R,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",ge;e[30]!==ce?(ge=lt(ce),e[30]=ce,e[31]=ge):ge=e[31];let V;e[32]!==a?(V=a("Table list"),e[32]=a,e[33]=V):V=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==ge||e[37]!==V?(X=(0,t.jsx)("button",{"aria-selected":ye,className:ge,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:V}),e[34]=k,e[35]=ye,e[36]=ge,e[37]=V,e[38]=X):X=e[38];let B;e[39]!==j||e[40]!==X||e[41]!==Y?(B=(0,t.jsxs)("div",{"aria-label":Y,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Y,e[42]=B):B=e[42];let le;e[43]!==B||e[44]!==$?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[$,B]}),e[43]=B,e[44]=$,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Q||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Q,placeholder:a("Filter tables"),value:F}),e[50]=Q,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==b||e[57]!==g||e[58]!==T||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:g}),(0,t.jsx)(He,{columnsError:T[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=b,e[57]=g,e[58]=T,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==b||e[64]!==o||e[65]!==p||e[66]!==i||e[67]!==v||e[68]!==g||e[69]!==K||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==O||e[75]!==he||e[76]!==H||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Ke,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ve,{tier:"shard"}),(0,t.jsx)(Pe,{children:a("Shard tables")}),O!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ge,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),O!==null&&O.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),O!==null&&O.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,Z=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ye,testId:`sc-columns-${f.name}`}),Z.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:Z,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Ke,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ve,{tier:"global"}),(0,t.jsx)(Pe,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:p.length})]}),(0,t.jsx)(Ge,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:g}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&p.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.")}),p.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:p.map(f=>(0,t.jsx)(et,{expanded:K===f.name,name:f.name,onToggle:r(()=>{ue(H(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ye,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=b,e[64]=o,e[65]=p,e[66]=i,e[67]=v,e[68]=g,e[69]=K,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=O,e[75]=he,e[76]=H,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Zt");function At(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(At,"kt");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)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"It");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
|
|
1
|
+
import{a as He}from"./chunk-IUUSMC2R.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 we}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 Ze}from"./chunk-3CWGJYBB.js";import{a as Xe}from"./chunk-RMN2JN4S.js";import{b as We}from"./chunk-GRL5MG3Z.js";import{e as Ue}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import{R as Ae}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as me}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ze}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as je}from"./chunk-VDW32UET.js";import{f as Be}from"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import{a as Je}from"./chunk-XQCVZAGU.js";import{a as qe,b as Ke,c as Pe,d as Ge,e as Le}from"./chunk-UZERI5YC.js";import{d as Fe,f as Ee,g as Oe,h as $e,o as ue}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as r,e as De,f as at,g as nt,h as st,j as Re}from"./chunk-3XIESWL4.js";var Ce=De(nt(),1);var x=De(at(),1);var t=De(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Qe=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Be(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:b}=Ze(u),[o,p]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[g,K]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),P;e[1]===Symbol.for("react.memo_cache_sentinel")?(P={},e[1]=P):P=e[1];let[E,M]=(0,x.useState)(P),[T,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[O,he]=(0,x.useState)(F),H;e[3]===Symbol.for("react.memo_cache_sentinel")?(H={},e[3]=H):H=e[3];let[I,G]=(0,x.useState)(H),[k,pe]=(0,x.useState)(null),[D,oe]=(0,x.useState)(null),Q;e[4]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[4]=Q):Q=e[4];let[J,xe]=(0,x.useState)(Q),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{K(null);try{let w=await l.query(rt,{},Oe(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),G(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),K($e(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let $=ve,Y;e[7]!==l?(Y=r(async()=>{oe(null);try{pe(await l.listGlobalTables())}catch(h){let w=h;pe(null),oe($e(w))}},"Q"),e[7]=l,e[8]=Y):Y=e[8];let ee=Y,de,R;e[9]!==c||e[10]!==$||e[11]!==ee?(de=r(()=>{ue($(c)),ue(ee())},"de"),R=[$,ee,c],e[9]=c,e[10]=$,e[11]=ee,e[12]=de,e[13]=R):(de=e[12],R=e[13]),(0,x.useEffect)(de,R);let te;e[14]!==l||e[15]!==L||e[16]!==T||e[17]!==c?(te=r(async h=>{if(T===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},Oe(c)),l.query(ot,{table:h},Oe(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):K($e(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=T,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe($e(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,ge=(0,x.useRef)(void 0),V,X;e[23]!==n||e[24]!==i||e[25]!==j?(V=r(()=>{n===void 0||i===null||ge.current===n||i.some(h=>h.name===n)&&(ge.current=n,ue(j(n)))},"V"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=V,e[27]=X):(V=e[26],X=e[27]),(0,x.useEffect)(V,X);let B;e[28]!==l?(B=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},Oe(h))]),Promise.all(N.map(async S=>{let be=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:S})]),Ie=be[0].status==="fulfilled"?be[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:S}}))]),Se=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Te=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(S=>{let be=Se[S]??[];return[S,be.length>0?be:_e.get(S)??[]]});he(S=>({...S,[h]:Object.fromEntries(ke)})),G(S=>({...S,[h]:Te}))},"B"),e[28]=l,e[29]=B):B=e[29];let le=B,U,ae;e[30]!==D||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==O||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&D===null||O[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(pt)))},"U"),ae=[a,i,k,D,c,O,le],e[30]=D,e[31]=k,e[32]=le,e[33]=c,e[34]=O,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=O[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Qe,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Qe,name:A.name,tier:"global"}),"y"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,Z;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();Z=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=Z}else Z=e[52];let Ne=Z,fe;return e[53]!==L||e[54]!==se||e[55]!==g||e[56]!==T||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==D||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==$||e[65]!==d||e[66]!==I||e[67]!==b||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:g,expanded:T,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:D,globalExpanded:W,globalTables:k,indexes:E,refresh:$,setShardKey:d,setTableFilter:p,setView:m,shardColumnsError:I,shardKey:b,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=g,e[56]=T,e[57]=Ne,e[58]=re,e[59]=J,e[60]=D,e[61]=W,e[62]=k,e[63]=E,e[64]=$,e[65]=d,e[66]=I,e[67]=b,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(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(ut,"mt");function ht(s){return s.name}r(ht,"ut");function pt(s){return s.name}r(pt,"ht");var gt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(gt,{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)})`}},"gt"),bt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),b=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let p;e[2]!==m||e[3]!==b||e[4]!==o?(p=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:b,children:o}),e[2]=m,e[3]=b,e[4]=o,e[5]=p):p=e[5];let i=!u,v=n==="addColumn"?"default":"outline",g;e[6]!==d?(g=d("Add column"),e[6]=d,e[7]=g):g=e[7];let K;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==g?(K=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:g}),e[8]=l,e[9]=i,e[10]=v,e[11]=g,e[12]=K):K=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let P;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=P):P=e[19];let E=!u,M=n==="destructive"?"default":"ghost",T;e[20]!==d?(T=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=T):T=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==T?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:T}),e[22]=c,e[23]=E,e[24]=M,e[25]=T,e[26]=C):C=e[26];let F;return e[27]!==P||e[28]!==C||e[29]!==p||e[30]!==K?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[p,K,P,C]}),e[27]=P,e[28]=C,e[29]=p,e[30]=K,e[31]=F):F=e[31],F},"bt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(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]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=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]=o):o=e[5];let p;e[6]!==o?(p=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=p):p=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let g;return e[13]!==p||e[14]!==v?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[p,v]}),e[13]=p,e[14]=v,e[15]=g):g=e[15],g}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let b;return e[25]!==m||e[26]!==d?(b=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=b):b=e[27],b},"ft");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{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()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Nt"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,b]=(0,x.useState)(!1),[o,p]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[g,K]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,P]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[T,C]=(0,x.useState)(""),[F,O]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),K(""),M(""),C(""),O(!1)},"me"),e[0]=he):he=e[0];let H=he,I;e[1]!==u?(I=r(async S=>{b(!0),p(null);try{let be=await ft(S);p(be),be.kind==="ok"&&(u(be.tables),H())}catch(be){let Ie=be;p({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}b(!1)},"k"),e[1]=u,e[2]=I):I=e[2];let G=I,k;e[3]!==G||e[4]!==i?(k=r(()=>{ue(G({kind:"addTable",table:i.trim()}))},"_"),e[3]=G,e[4]=i,e[5]=k):k=e[5];let pe=k,D;e[6]!==g||e[7]!==G||e[8]!==y||e[9]!==_?(D=r(()=>{ue(G({column:g.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"D"),e[6]=g,e[7]=G,e[8]=y,e[9]=_,e[10]=D):D=e[10];let oe=D,Q;e[11]!==T||e[12]!==E||e[13]!==G||e[14]!==y||e[15]!==F?(Q=r(()=>{ue(G({fields:Ct(T),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"H"),e[11]=T,e[12]=E,e[13]=G,e[14]=y,e[15]=F,e[16]=Q):Q=e[16];let J=Q,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{p(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{p(null),c("addColumn")},"ie"),e[18]=ie):ie=e[18];let ve=ie,$;e[19]===Symbol.for("react.memo_cache_sentinel")?($=r(()=>{p(null),c("addIndex")},"q"),e[19]=$):$=e[19];let Y=$,ee;e[20]!==l?(ee=r(()=>{c("destructive"),p({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=r(S=>{v(S.target.value)},"R"),e[22]=R):R=e[22];let te=R,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(S=>{K(S.target.value)},"z"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(S=>{L(S.target.value)},"ce"),e[24]=ce):ce=e[24];let ge=ce,V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=r(S=>{P(S.target.value)},"V"),e[25]=V):V=e[25];let X=V,B;e[26]===Symbol.for("react.memo_cache_sentinel")?(B=r(S=>{M(S.target.value)},"B"),e[26]=B):B=e[26];let le=B,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(S=>{C(S.target.value)},"U"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(S=>{O(S.target.checked)},"E"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"se"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let Z;e[33]!==re?(Z=(0,t.jsx)(Pe,{children:re}),e[33]=re,e[34]=Z):Z=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ge,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==Z||e[40]!==fe?(h=(0,t.jsxs)(Ke,{children:[Z,fe]}),e[39]=Z,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(bt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Y,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==pe||e[49]!==l||e[50]!==i?(q=m==="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)(we,{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:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:pe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:H,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=pe,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==g||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="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)(we,{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:X,value:y,children:n.map(St)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{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:ye,value:g})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{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:ge,value:_,children:yt.map(Tt)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||g.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:H,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=g,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Se;e[61]!==d||e[62]!==T||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Se=m==="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)(we,{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:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{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:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{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:ae,value:T})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||T.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:H,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=T,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Se):Se=e[70];let Te;e[71]!==f||e[72]!==o?(Te=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Te):Te=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Se||e[78]!==Te?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Se,Te]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Se,e[78]=Te,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Ct");function St(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(St,"Tt");function Tt(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(Tt,"wt");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"St");var Ye=[],kt=r(s=>{let e=(0,Ce.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 m;return e[3]!==l?(m=(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]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,b;e[0]!==n?(b=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=b):b=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let p;e[4]!==m?(p=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=p):p=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==b||e[9]!==o||e[10]!==p||e[11]!==d?(i=(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:[b,o," ",p]}),e[6]=n,e[7]=a,e[8]=b,e[9]=o,e[10]=p,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let g;return e[16]!==c||e[17]!==i||e[18]!==v?(g=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=g):g=e[19],g},"Xe"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),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},"Ye"),It=r(s=>{let e=(0,Ce.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 m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"$t"),lt=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"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:b,expanded:o,filteredGlobalTables:p,filteredTables:i,globalColumns:v,globalError:g,globalExpanded:K,globalTables:_,indexes:L,refresh:y,setShardKey:P,setTableFilter:E,setView:M,shardColumnsError:T,shardKey:C,tableFilter:F,tables:O,toggle:he,toggleGlobal:H,view:I}=mt(m),G;e[3]!==M?(G=r(()=>{M("list")},"G"),e[3]=M,e[4]=G):G=e[4];let k=G,pe;e[5]!==M?(pe=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=pe):pe=e[6];let D=pe,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"oe"),e[7]=E,e[8]=oe):oe=e[8];let Q=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"X"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==O?(W=O??[],e[12]=O,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,$;e[16]!==P||e[17]!==C?($=(0,t.jsx)(Xe,{onChange:P,testId:"sc-shard-input",value:C}),e[16]=P,e[17]=C,e[18]=$):$=e[18];let Y;e[19]!==a?(Y=a("Schema view"),e[19]=a,e[20]=Y):Y=e[20];let ee=I==="graph",de=I==="graph",R;e[21]!==de?(R=lt(de),e[21]=de,e[22]=R):R=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==D||e[26]!==ee||e[27]!==R||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:R,"data-testid":"sc-view-graph",onClick:D,role:"tab",type:"button",children:te}),e[25]=D,e[26]=ee,e[27]=R,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",ge;e[30]!==ce?(ge=lt(ce),e[30]=ce,e[31]=ge):ge=e[31];let V;e[32]!==a?(V=a("Table list"),e[32]=a,e[33]=V):V=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==ge||e[37]!==V?(X=(0,t.jsx)("button",{"aria-selected":ye,className:ge,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:V}),e[34]=k,e[35]=ye,e[36]=ge,e[37]=V,e[38]=X):X=e[38];let B;e[39]!==j||e[40]!==X||e[41]!==Y?(B=(0,t.jsxs)("div",{"aria-label":Y,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Y,e[42]=B):B=e[42];let le;e[43]!==B||e[44]!==$?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[$,B]}),e[43]=B,e[44]=$,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Q||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Q,placeholder:a("Filter tables"),value:F}),e[50]=Q,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==b||e[57]!==g||e[58]!==T||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:g}),(0,t.jsx)(He,{columnsError:T[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=b,e[57]=g,e[58]=T,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==b||e[64]!==o||e[65]!==p||e[66]!==i||e[67]!==v||e[68]!==g||e[69]!==K||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==O||e[75]!==he||e[76]!==H||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Ke,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ve,{tier:"shard"}),(0,t.jsx)(Pe,{children:a("Shard tables")}),O!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ge,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[b!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),O!==null&&O.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),O!==null&&O.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,Z=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ye,testId:`sc-columns-${f.name}`}),Z.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:Z,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Ke,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Ve,{tier:"global"}),(0,t.jsx)(Pe,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:p.length})]}),(0,t.jsx)(Ge,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:g}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&p.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.")}),p.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:p.map(f=>(0,t.jsx)(et,{expanded:K===f.name,name:f.name,onToggle:r(()=>{ue(H(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ye,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=b,e[64]=o,e[65]=p,e[66]=i,e[67]=v,e[68]=g,e[69]=K,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=O,e[75]=he,e[76]=H,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Zt");function At(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(At,"kt");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)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"It");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O,b as B}from"./chunk-AVAC26HJ.js";import{a as F}from"./chunk-IGCNMZSB.js";import{a as j}from"./chunk-3CWGJYBB.js";import{a as V}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as z}from"./chunk-
|
|
1
|
+
import{a as O,b as B}from"./chunk-AVAC26HJ.js";import{a as F}from"./chunk-IGCNMZSB.js";import{a as j}from"./chunk-3CWGJYBB.js";import{a as V}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as z}from"./chunk-465RIA2L.js";import"./chunk-XXQUMVWH.js";import"./chunk-O3UMJLO3.js";import"./chunk-QLQADHFE.js";import{a as R}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-ZNAGZU6H.js";import"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import{a as K}from"./chunk-XQCVZAGU.js";import{a as A,b as T,c as q,d as p,e as n,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as E}from"./chunk-UZERI5YC.js";import{d as b,r as k}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as i,e as y,f as ee,h as te}from"./chunk-3XIESWL4.js";var o=y(ee(),1);var e=y(te(),1);var D=80,re=i(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>D?`${t.slice(0,D)}\u2026`:t},"te"),ae=41,J=480,H=5,ie=i((s,t)=>O(s,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:s})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=j(s),[c,W]=(0,o.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:$}=M(R.getAuditLog,{},{live:!0,shardKey:l}),h=(0,o.useMemo)(()=>f?.entries??[],[f]),m=(0,o.useMemo)(()=>{let a=c.trim().toLowerCase();return a===""?h:h.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[h,c]),x=(0,o.useRef)(null),v=B({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),G=v.getTotalSize(),N=u[0]?.start??0,w=G-(u.at(-1)?.end??0),Q={height:N},X={height:w},Y=i(a=>{W(a.target.value)},"k");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(V,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{message:$,prefix:"au"}),(0,e.jsx)(C,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:c})]}),g!==null&&(0,e.jsx)(z,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(K,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(A,{"data-testid":"au-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(n,{children:t("time")}),(0,e.jsx)(n,{children:t("op")}),(0,e.jsx)(n,{children:t("table")}),(0,e.jsx)(n,{children:t("id")}),(0,e.jsx)(n,{children:t("detail")})]})}),(0,e.jsxs)(q,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Q})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:k(r.ts,"\u2014")}),(0,e.jsx)(d,{children:(0,e.jsx)(L,{variant:"secondary",children:r.op})}),(0,e.jsx)(d,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})})]})]})})})]})},"we");export{Ne as AuditPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as R}from"./chunk-
|
|
1
|
+
import{b as R}from"./chunk-BN4CIAXU.js";import"./chunk-465RIA2L.js";import"./chunk-XXQUMVWH.js";import"./chunk-O3UMJLO3.js";import"./chunk-QLQADHFE.js";import{a as p}from"./chunk-VDW32UET.js";import{c as h}from"./chunk-ZNAGZU6H.js";import"./chunk-5KCULF7S.js";import"./chunk-XBDKZZ67.js";import"./chunk-MIQTKZAR.js";import"./chunk-UZERI5YC.js";import{d as g}from"./chunk-IUYFXK4X.js";import"./chunk-XNGYYOLS.js";import{a as s,e as m,g as S,h as _}from"./chunk-3XIESWL4.js";var f=m(S(),1);var k=m(_(),1);var A=s((e,t)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[t.kind],"R"),w=s(e=>Array.isArray(e.findings)?e.findings:[],"k"),E=s(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),T=s((e,t)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:t.detail?.length,min:t.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:t.detail?.length,min:t.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[t.kind],"A"),O=s(()=>{let e=(0,f.c)(8),t=g(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=h(p.getSecurityAudit,r),n;if(e[1]!==a||e[2]!==t){let u=a===void 0?null:w(a);n=u===null?null:u.map(i=>({description:T(t,i),entity:E(i),issueType:A(t,i),key:i.kind,level:i.level})),e[1]=a,e[2]=t,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(R,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"N");export{O as default};
|