@lunora/studio 1.0.0-alpha.143 → 1.0.0-alpha.145
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.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/mount.d.mts +1 -1
- package/dist/mount.d.ts +1 -1
- package/dist/mount.mjs +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ApiTab.mjs +1 -1
- package/dist/packem_chunks/AuditPanel.mjs +1 -1
- package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
- package/dist/packem_chunks/FileBrowser.mjs +1 -1
- package/dist/packem_chunks/FunctionRunner.mjs +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
- package/dist/packem_chunks/HealthPanel.mjs +1 -1
- package/dist/packem_chunks/InsightsPanel.mjs +1 -1
- package/dist/packem_chunks/LogsPanel.mjs +1 -1
- package/dist/packem_chunks/MailPanel.mjs +1 -1
- package/dist/packem_chunks/MetricsPanel.mjs +1 -1
- package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
- package/dist/packem_chunks/PitrPanel.mjs +1 -1
- package/dist/packem_chunks/SchemaViewer.mjs +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
- package/dist/packem_chunks/SettingsPanel.mjs +1 -1
- package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/agents-panel.mjs +1 -1
- package/dist/packem_chunks/analytics-panel.mjs +1 -1
- package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
- package/dist/packem_chunks/auth-config-panel.mjs +1 -1
- package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
- package/dist/packem_chunks/containers-panel.mjs +1 -1
- package/dist/packem_chunks/dashboards-panel.mjs +1 -1
- package/dist/packem_chunks/evals-panel.mjs +1 -1
- package/dist/packem_chunks/fanout-panel.mjs +1 -1
- package/dist/packem_chunks/flags-panel.mjs +1 -1
- package/dist/packem_chunks/issues-panel.mjs +1 -1
- package/dist/packem_chunks/kv-browser.mjs +1 -1
- package/dist/packem_chunks/log-drains-panel.mjs +1 -1
- package/dist/packem_chunks/migrations-route.mjs +1 -1
- package/dist/packem_chunks/organizations-panel.mjs +1 -1
- package/dist/packem_chunks/payments-panel.mjs +1 -1
- package/dist/packem_chunks/permissions-panel.mjs +1 -1
- package/dist/packem_chunks/queues-panel.mjs +1 -1
- package/dist/packem_chunks/reactors-panel.mjs +1 -1
- package/dist/packem_chunks/rls-panel.mjs +1 -1
- package/dist/packem_chunks/schedule-panel.mjs +1 -1
- package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
- package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
- package/dist/packem_chunks/sync-client-panel.mjs +1 -1
- package/dist/packem_chunks/traces-panel.mjs +1 -1
- package/dist/packem_chunks/users-panel.mjs +1 -1
- package/dist/packem_chunks/vector-browser.mjs +1 -1
- package/dist/packem_chunks/workflows-panel.mjs +1 -1
- package/dist/packem_shared/{ApiDocsPanel-l4DQX1Vq.mjs → ApiDocsPanel-CHCIjzZu.mjs} +1 -1
- package/dist/packem_shared/{ApiReferencePanel--YThTzHb.mjs → ApiReferencePanel-Cqy9Z7mO.mjs} +1 -1
- package/dist/packem_shared/{CommandPalette-C4UrhLxv.mjs → CommandPalette-DtLEYVhX.mjs} +1 -1
- package/dist/packem_shared/DataBrowser-Bf32rBcr.mjs +4 -0
- package/dist/packem_shared/{GlobalDataBrowser-DK4fgb7h.mjs → GlobalDataBrowser-CDpzXZxj.mjs} +1 -1
- package/dist/packem_shared/{HomePanel-B869m6wb.mjs → HomePanel-4gpRjcch.mjs} +1 -1
- package/dist/packem_shared/{MigrationsPanel-BZJ_Rv4t.mjs → MigrationsPanel-Cz0x3Pv6.mjs} +1 -1
- package/dist/packem_shared/{OpenRpcReferencePanel-Bn5UVD7s.mjs → OpenRpcReferencePanel-DZicbIOf.mjs} +1 -1
- package/dist/packem_shared/{ScheduledJobs-Db0HZ8R9.mjs → ScheduledJobs-BWziDVZO.mjs} +1 -1
- package/dist/packem_shared/{Studio-UxOpDgEl.mjs → Studio-C_yEjXcG.mjs} +1 -1
- package/dist/packem_shared/StudioApp-BQAxVB3v.mjs +1 -0
- package/dist/packem_shared/{advisor-view-DoSv436g.mjs → advisor-view-DyXQCN4y.mjs} +1 -1
- package/dist/packem_shared/{app.d-DFjg4Uki.d.mts → app.d-BbmO2HA2.d.mts} +25 -8
- package/dist/packem_shared/{app.d-DFjg4Uki.d.ts → app.d-BbmO2HA2.d.ts} +25 -8
- package/dist/packem_shared/{data-grid-BqNXJ9PF.mjs → data-grid-B8WGnT-5.mjs} +1 -1
- package/dist/packem_shared/{error-alert-CWs6gA3I.mjs → error-alert-ClpDVYvo.mjs} +1 -1
- package/dist/packem_shared/{grid-features-D8w5isjt.mjs → grid-features-CGs2pKcr.mjs} +1 -1
- package/dist/packem_shared/{home-panel-ChKczU0I.mjs → home-panel-CHtt8k50.mjs} +1 -1
- package/dist/packem_shared/{internal-CwaF9YNk.mjs → internal-D4gBuklE.mjs} +1 -1
- package/dist/packem_shared/{log-line-Dzg4YZ-K.mjs → log-line-DpRfHaVQ.mjs} +1 -1
- package/dist/packem_shared/{recording-client-BGyq5_JP.mjs → recording-client-CMvFFEC0.mjs} +1 -1
- package/dist/packem_shared/{reference-view-CZxBZSRo.mjs → reference-view-DS7FFPpP.mjs} +1 -1
- package/dist/packem_shared/{schema-diagram-DU83ObYH.mjs → schema-diagram-C27ETi10.mjs} +1 -1
- package/dist/packem_shared/{sql-result-table-DysT8h5P.mjs → sql-result-table-BLIMecXM.mjs} +1 -1
- package/dist/packem_shared/{studio-DE8N0tIQ.mjs → studio-DF0GqQBP.mjs} +1 -1
- package/dist/packem_shared/{table-list-sidebar-T7--Fv-V.mjs → table-list-sidebar-DKpSAP6p.mjs} +1 -1
- package/dist/packem_shared/use-admin-query-BvZH4unR.mjs +1 -0
- package/dist/packem_shared/{use-async-submit-DAKymxcP.mjs → use-async-submit-C1A11ka9.mjs} +1 -1
- package/dist/packem_shared/{use-auth-config-o-FcIXzR.mjs → use-auth-config-DocoJ5uQ.mjs} +1 -1
- package/dist/packem_shared/{use-open-trace-B5LJ96_0.mjs → use-open-trace-CTQIPjo9.mjs} +1 -1
- package/dist/packem_shared/{use-sql-assistant-Ib7Ik6cw.mjs → use-sql-assistant-BGoWYcGL.mjs} +1 -1
- package/dist/packem_shared/{wire-codec-DGcjNTbZ.mjs → wire-codec-BE-vgg1L.mjs} +1 -1
- package/dist/standalone/{chunk-UVY6KN6G.js → chunk-2IRZXHAZ.js} +1 -1
- package/dist/standalone/{chunk-MWHKPKQC.js → chunk-2IUHQB2Q.js} +1 -1
- package/dist/standalone/{chunk-ICVRD6K5.js → chunk-2KAH7DVZ.js} +1 -1
- package/dist/standalone/{chunk-OIZ7KE2D.js → chunk-3BFUVYWS.js} +1 -1
- package/dist/standalone/{chunk-3ILVYCWG.js → chunk-3DL3MLWV.js} +1 -1
- package/dist/standalone/{chunk-XKABJHJG.js → chunk-3HEXTCWR.js} +1 -1
- package/dist/standalone/{chunk-NBC6NJFJ.js → chunk-3JV5F5SY.js} +1 -1
- package/dist/standalone/{chunk-QDUP4VDB.js → chunk-447V2Q3F.js} +1 -1
- package/dist/standalone/{chunk-VQS5E53D.js → chunk-46XX646F.js} +1 -1
- package/dist/standalone/{chunk-7QRRR3K6.js → chunk-5JEYBOS6.js} +1 -1
- package/dist/standalone/{chunk-RROTBODU.js → chunk-5L3SHBMK.js} +1 -1
- package/dist/standalone/{chunk-MOSQV7WU.js → chunk-6NO6WOSN.js} +1 -1
- package/dist/standalone/{chunk-DEJLINCJ.js → chunk-6T3STPM7.js} +1 -1
- package/dist/standalone/chunk-7AU5QSY7.js +1 -0
- package/dist/standalone/{chunk-TUHIU3JC.js → chunk-7B3OQXWL.js} +1 -1
- package/dist/standalone/{chunk-OVCT4ANW.js → chunk-7MJY23GU.js} +1 -1
- package/dist/standalone/{chunk-4RDRBZ3Z.js → chunk-AJQKSUVQ.js} +1 -1
- package/dist/standalone/{chunk-FSFJ5LI2.js → chunk-B5WPIRI3.js} +1 -1
- package/dist/standalone/{chunk-5OWAVF7Y.js → chunk-BN5TOI5O.js} +1 -1
- package/dist/standalone/chunk-BQ4P3PLU.js +1 -0
- package/dist/standalone/{chunk-I6GOQSDQ.js → chunk-CIQRB2ET.js} +1 -1
- package/dist/standalone/{chunk-DPS5Q64N.js → chunk-CKKZCUAV.js} +1 -1
- package/dist/standalone/{chunk-DHSCHEJZ.js → chunk-CZU3LZ2O.js} +1 -1
- package/dist/standalone/{chunk-VRLTD6I6.js → chunk-DDI4VSJH.js} +1 -1
- package/dist/standalone/{chunk-FRIPZLHV.js → chunk-DMPVOWA7.js} +1 -1
- package/dist/standalone/{chunk-TJPEAOEL.js → chunk-E6LDY3TC.js} +1 -1
- package/dist/standalone/{chunk-IFLTA2OD.js → chunk-E723DEAW.js} +1 -1
- package/dist/standalone/{chunk-WJBOVMUO.js → chunk-EDYGNYP2.js} +1 -1
- package/dist/standalone/{chunk-V7HAXWCR.js → chunk-EX33M5EE.js} +1 -1
- package/dist/standalone/{chunk-P6NXPLYT.js → chunk-FZKQX74O.js} +1 -1
- package/dist/standalone/{chunk-73TWF2G4.js → chunk-GMEE5NFG.js} +1 -1
- package/dist/standalone/{chunk-64KROZ2C.js → chunk-H3UCYGKY.js} +1 -1
- package/dist/standalone/{chunk-KVPXTLKG.js → chunk-H5PZ7JXM.js} +1 -1
- package/dist/standalone/{chunk-YM62NSM6.js → chunk-HDWOQTDN.js} +1 -1
- package/dist/standalone/{chunk-5OSOXQGT.js → chunk-HLE46T7J.js} +1 -1
- package/dist/standalone/{chunk-6DSKJTA4.js → chunk-HQPQTWW4.js} +1 -1
- package/dist/standalone/{chunk-X6KMHRS7.js → chunk-IAWCSJRR.js} +1 -1
- package/dist/standalone/chunk-IB3MWLG4.js +1 -0
- package/dist/standalone/{chunk-XYZBO7IN.js → chunk-IDB7SMQU.js} +1 -1
- package/dist/standalone/{chunk-6GTVFSLV.js → chunk-IYYZMNOB.js} +1 -1
- package/dist/standalone/{chunk-5UFDH5PE.js → chunk-JMNCMGSE.js} +1 -1
- package/dist/standalone/chunk-JOQUDV7F.js +1 -0
- package/dist/standalone/{chunk-IPIFMAW4.js → chunk-JRN7SEJN.js} +1 -1
- package/dist/standalone/{chunk-2DRUQ42V.js → chunk-JSXJND3V.js} +1 -1
- package/dist/standalone/{chunk-VFMJJZVG.js → chunk-KLQEN4KA.js} +1 -1
- package/dist/standalone/chunk-L2OWXMYF.js +1 -0
- package/dist/standalone/{chunk-2BN33A2H.js → chunk-L3JA4OKZ.js} +1 -1
- package/dist/standalone/{chunk-CDTGKA5J.js → chunk-MDVH5C5A.js} +1 -1
- package/dist/standalone/{chunk-VKYBRQC2.js → chunk-MHLBCDVW.js} +1 -1
- package/dist/standalone/{chunk-PKCC4J5W.js → chunk-MJG6GTPL.js} +1 -1
- package/dist/standalone/{chunk-Y4Q25F6X.js → chunk-NXKPFGOP.js} +1 -1
- package/dist/standalone/{chunk-B5FXTB7H.js → chunk-OUD7BAWE.js} +1 -1
- package/dist/standalone/{chunk-UAN6GGJ4.js → chunk-PEEGF7YA.js} +2 -2
- package/dist/standalone/{chunk-WRLGCVLF.js → chunk-PWHV7BUN.js} +1 -1
- package/dist/standalone/{chunk-T5JCEI5W.js → chunk-QPVND4TE.js} +1 -1
- package/dist/standalone/{chunk-MUOVSMDK.js → chunk-RFTFYKFL.js} +1 -1
- package/dist/standalone/{chunk-T2IE5GKA.js → chunk-RIO2HPN7.js} +4 -4
- package/dist/standalone/{chunk-ZJ6AMQGH.js → chunk-RNZ7XXND.js} +1 -1
- package/dist/standalone/{chunk-SSNHCN4D.js → chunk-SMVAE2AQ.js} +1 -1
- package/dist/standalone/{chunk-I5OKDKON.js → chunk-TWXJF4C2.js} +1 -1
- package/dist/standalone/{chunk-Q2ONYLZ3.js → chunk-UKQTCLDK.js} +4 -4
- package/dist/standalone/{chunk-SFZVHU6C.js → chunk-UZ5QI3PB.js} +1 -1
- package/dist/standalone/{chunk-GUIGDTCU.js → chunk-V5M356X3.js} +1 -1
- package/dist/standalone/{chunk-AQI7ZNT2.js → chunk-VHMOFAJT.js} +1 -1
- package/dist/standalone/{chunk-XSLMHPP2.js → chunk-VSHZE77Y.js} +1 -1
- package/dist/standalone/{chunk-NDVLXSQJ.js → chunk-VXWAQW3F.js} +1 -1
- package/dist/standalone/chunk-W3Q32C24.js +11 -0
- package/dist/standalone/{chunk-76EQ5JUU.js → chunk-XABVLLMA.js} +1 -1
- package/dist/standalone/{chunk-RI6SDJNF.js → chunk-XGPF7VOP.js} +1 -1
- package/dist/standalone/{chunk-YQOVNRK5.js → chunk-YL7OENDU.js} +1 -1
- package/dist/standalone/{chunk-44XP35PZ.js → chunk-YWYJLVEP.js} +1 -1
- package/dist/standalone/{chunk-OOKV3V3X.js → chunk-ZZENQM5W.js} +1 -1
- package/dist/standalone/studio.js +2 -2
- package/package.json +6 -6
- package/dist/packem_shared/DataBrowser-C2B-HNOL.mjs +0 -4
- package/dist/packem_shared/StudioApp-BdisV3FN.mjs +0 -1
- package/dist/packem_shared/use-admin-query-C7JRlFIE.mjs +0 -1
- package/dist/standalone/chunk-ADJTCEH3.js +0 -1
- package/dist/standalone/chunk-HWBXHONF.js +0 -1
- package/dist/standalone/chunk-M5ROVSBF.js +0 -1
- package/dist/standalone/chunk-MM322O3E.js +0 -1
- package/dist/standalone/chunk-OAEQLGGA.js +0 -1
- package/dist/standalone/chunk-Q3627RWT.js +0 -11
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{E as ie}from"../packem_shared/error-alert-
|
|
1
|
+
import{E as ie}from"../packem_shared/error-alert-ClpDVYvo.mjs";import{B as se}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as v}from"../packem_shared/button-q0UYSmrn.mjs";import{E as oe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ne}from"../packem_shared/input-CXhxesPC.mjs";import{S as le}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{Separator as de}from"@base-ui/react/separator";import{c as ce}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as t,jsxs as n,Fragment as me}from"react/jsx-runtime";import{useT as ue}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as ae,d as Y,b as Z,f as ee,g as he,i as te}from"../packem_shared/internal-D4gBuklE.mjs";import{c as pe}from"react/compiler-runtime";import{useLunora as fe}from"@lunora/react";import{useState as O}from"react";import{u as be}from"../packem_shared/use-admin-query-BvZH4unR.mjs";import{useAutoRefresh as xe}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{ADMIN_FUNCTIONS as X}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";function ge({className:r,orientation:e="horizontal",...s}){return t(de,{"data-slot":"separator",orientation:e,className:ce("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...s})}const ve=/https?:\/\/[^\s"'<>)]+/i,re=r=>r===void 0?void 0:ve.exec(r)?.[0],N=r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,Ne=r=>{if(r!==void 0)return re(r.html)??re(r.text)},we=(r,e)=>{const s=e.trim().toLowerCase();return s===""?r:r.filter(o=>`${o.subject} ${N(o.to)} ${N(o.cc)}`.toLowerCase().includes(s))},ye=(r,e)=>{if(r.length!==0)return r.find(s=>s.id===e)??r[0]},Ce=ae(X.clearCapturedMail),Se=ae(X.sendTestMail),Te=r=>{const e=pe(38),{limit:s}=r,o=fe();let p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];const{data:R,error:w,errorSource:y,isLoading:x,refetch:l}=be(X.getCapturedMail,p),[C,f]=O(null),[B,S]=O(null),[g,i]=O("html"),[c,D]=O(""),b=R?.entries??[],a=w??C,h=w===null?C:y;let T;e[2]!==o||e[3]!==l?(T=async()=>{f(null);try{await o.query(Ce,{},Y("")),S(null),l()}catch(m){f(Z(m))}},e[2]=o,e[3]=l,e[4]=T):T=e[4];const H=T;let k;e[5]!==o||e[6]!==l?(k=async()=>{f(null);try{await o.query(Se,{},Y("")),l()}catch(m){f(Z(m))}},e[5]=o,e[6]=l,e[7]=k):k=e[7];const q=k;let L;e[8]!==l?(L=()=>{l()},e[8]=l,e[9]=L):L=e[9],xe(L,!0);let A;e[10]!==H?(A=()=>{ee(H())},e[10]=H,e[11]=A):A=e[11];const U=A;let E;e[12]!==q?(E=()=>{ee(q())},e[12]=q,e[13]=E):E=e[13];const W=E;let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=m=>{D(m.currentTarget.value)},e[14]=_):_=e[14];const K=_;let M;e[15]===Symbol.for("react.memo_cache_sentinel")?(M=m=>{const{id:u}=m.currentTarget.dataset;u!==void 0&&S(u)},e[15]=M):M=e[15];const Q=M;let j;e[16]===Symbol.for("react.memo_cache_sentinel")?(j=m=>{const u=m.currentTarget.dataset.tab;(u==="headers"||u==="html"||u==="text")&&i(u)},e[16]=j):j=e[16];const V=j,I=we(b,c),$=ye(I,B),d=Ne($);let z;e[17]!==d?(z=()=>{d!==void 0&&he(d)},e[17]=d,e[18]=z):z=e[18];const G=z;let F;e[19]!==d?(F=()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},e[19]=d,e[20]=F):F=e[20];const J=F;let P;return e[21]!==b||e[22]!==a||e[23]!==h||e[24]!==c||e[25]!==x||e[26]!==d||e[27]!==U||e[28]!==G||e[29]!==K||e[30]!==J||e[31]!==Q||e[32]!==V||e[33]!==W||e[34]!==$||e[35]!==g||e[36]!==I?(P={entries:b,error:a,errorSource:h,filter:c,isLoading:x,link:d,onClear:U,onCopyLink:G,onFilterChange:K,onOpenLink:J,onSelectMessage:Q,onSelectTab:V,onSendTest:W,selected:$,tab:g,visible:I},e[21]=b,e[22]=a,e[23]=h,e[24]=c,e[25]=x,e[26]=d,e[27]=U,e[28]=G,e[29]=K,e[30]=J,e[31]=Q,e[32]=V,e[33]=W,e[34]=$,e[35]=g,e[36]=I,e[37]=P):P=e[37],P},ke=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,Le=r=>`${ke}${r}`,We=({limit:r=100})=>{const e=ue(),{entries:s,error:o,errorSource:p,filter:R,isLoading:w,link:y,onClear:x,onCopyLink:l,onFilterChange:C,onOpenLink:f,onSelectMessage:B,onSelectTab:S,onSendTest:g,selected:i,tab:c,visible:D}=Te({limit:r}),b=a=>e(a==="html"?"HTML":a==="text"?"Plain text":"Headers");return n("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(v,{"data-testid":"mail-send-test",onClick:g,size:"sm",type:"button",variant:"outline",children:e("Send test")}),t(v,{"data-testid":"mail-clear",disabled:s.length===0,onClick:x,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&t(se,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&t(ie,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&t(oe,{description:e("Email your app sends in dev is captured here — nothing is delivered."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M4 5h16v14H4z"}),t("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&n("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[n("div",{className:"flex flex-col gap-2",children:[t(ne,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:C,placeholder:e("Filter messages"),type:"search",value:R}),t(le,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:t("ul",{className:"divide-y",children:D.map(a=>{const h=a.id===i?.id;return t("li",{children:n("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${h?"bg-muted":""}`,"data-active":h,"data-id":a.id,"data-testid":"mail-list-item",onClick:B,type:"button",children:[t("span",{className:"w-full truncate font-medium",children:a.subject||e("(no subject)")}),t("span",{className:"w-full truncate text-xs text-muted-foreground",children:N(a.to)}),t("span",{className:"text-xs text-muted-foreground tabular-nums",children:te(a.capturedAt,"—")})]})},a.id)})})})]}),i!==void 0&&n("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:i.subject||e("(no subject)")}),n("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[t("dt",{children:e("From")}),t("dd",{className:"truncate font-mono",children:i.from??"—"}),t("dt",{children:e("To")}),t("dd",{className:"truncate font-mono",children:N(i.to)}),i.cc!==void 0&&i.cc.length>0&&n(me,{children:[t("dt",{children:e("Cc")}),t("dd",{className:"truncate font-mono",children:N(i.cc)})]}),t("dt",{children:e("Sent")}),t("dd",{className:"tabular-nums",children:te(i.capturedAt,"—")})]})]}),n("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[t(v,{"data-testid":"mail-copy-link",disabled:y===void 0,onClick:l,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),t(v,{"data-testid":"mail-open-link",disabled:y===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),t(ge,{}),t("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(a=>t(v,{"aria-selected":c===a,"data-tab":a,"data-testid":`mail-tab-${a}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===a?"secondary":"ghost",children:b(a)},a))}),n("div",{className:"min-h-[12rem]",children:[c==="html"&&(i.html===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):t("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:Le(i.html),title:e("Email preview")})),c==="text"&&(i.text===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:i.text})),c==="headers"&&(i.headers===void 0||Object.keys(i.headers).length===0?t("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(i.headers).map(([a,h])=>`${a}: ${h}`).join(`
|
|
2
2
|
`)}))]})]})]})]})};export{We as MailPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as pt}from"@lunora/react";import{useState as pe,useRef as Ge,useEffect as tt,useMemo as xt}from"react";import{L as bt}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as yt}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as rt}from"../packem_shared/button-q0UYSmrn.mjs";import{u as Ue}from"../packem_shared/use-admin-query-C7JRlFIE.mjs";import{u as vt}from"../packem_shared/use-open-trace-B5LJ96_0.mjs";import{u as Nt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as xe}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as Oe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as St}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{m as wt,l as Xe,f as qt,d as Tt,b as _t,c as Ct}from"../packem_shared/internal-CwaF9YNk.mjs";import{r as Rt,l as kt}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{c as Fe}from"react/compiler-runtime";import{f as $t}from"../packem_shared/log-fields-SBxKyBug.mjs";import{B as et}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as he,a as ge,c as Be,d as Mt,b as je}from"../packem_shared/card--2hKx4L2.mjs";import{b as Je,e as oe,T as dt,c as de,a as mt,d as ut}from"../packem_shared/table-D0SBiDu-.mjs";import{S as ft}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as n,jsx as t,Fragment as Ye}from"react/jsx-runtime";import{aggregateMetrics as It,computeLatencyPercentiles as Dt,enrichQueryStats as Et,shardsToAggregate as Ft}from"../packem_shared/aggregateMetrics-CY05xrYU.mjs";import{S as me}from"../packem_shared/stat-card-D0Fe04cX.mjs";import{ResponsiveContainer as st,AreaChart as At,CartesianGrid as lt,XAxis as it,YAxis as at,Tooltip as nt,Area as Ot,LineChart as Lt,Line as zt}from"recharts";import{E as Kt}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as Pt}from"../packem_shared/utils-bhneXptQ.mjs";import{S as Bt,a as jt,c as Qe,b as Qt,d as Ht}from"../packem_shared/select-DPyS18Vy.mjs";const Ut=/["\\\u0000-\u001F\uD800-\uDFFF]/,ot=l=>Ut.test(l)?JSON.stringify(l):`"${l}"`,Ze=l=>{if(l===void 0)return"null";if(typeof l=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof l=="number"){if(Number.isNaN(l))return"nan";if(l===1/0)return"inf";if(l===-1/0)return"-inf";if(Object.is(l,-0))return"-0"}if(typeof l=="string")return ot(l);if(l===null||typeof l!="object")return JSON.stringify(l);if(Array.isArray(l)){let o="[";for(let i=0;i<l.length;i++)i>0&&(o+=","),o+=Ze(l[i]);return o+"]"}const e=Object.getPrototypeOf(l);if(e!==null&&e!==Object.prototype){const o=l.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${o} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const a=l,s=Object.keys(a).sort();let r="{",u=!0;for(const o of s){const i=a[o];i!==void 0&&(u?u=!1:r+=",",r+=ot(o),r+=":",r+=Ze(i))}return r+"}"},ht=(l,e,a)=>`${l}:${e}:${Ze(a??{})}`,gt=(l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,Jt=(l,e)=>gt(l,e),Vt=l=>gt(l.kind,l),We=l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),Gt=l=>Array.isArray(l?.series)?l.series:[],Wt="FUNCTION_NOT_FOUND",Xt=l=>{const e=new Map;if(!Array.isArray(l?.series))return e;for(const a of l.series)e.set(ht(a.kind,a.name,a.attributes),a.points);return e},Yt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=l=>{const e=Fe(18),{name:a,onOpenTrace:s,traceId:r}=l,u=xe();if(r===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=t("span",{className:"text-muted-foreground",children:"—"}),e[0]=d):d=e[0],d}let o;e[1]!==r?(o=r.slice(0,8),e[1]=r,e[2]=o):o=e[2];const i=o;if(s===void 0){const d=`mt-instrument-trace-${a}`;let g;return e[3]!==i||e[4]!==d||e[5]!==r?(g=t("span",{className:"text-muted-foreground","data-testid":d,title:r,children:i}),e[3]=i,e[4]=d,e[5]=r,e[6]=g):g=e[6],g}const f=`mt-instrument-trace-${a}`;let v;e[7]!==s||e[8]!==r?(v=()=>{s(r)},e[7]=s,e[8]=r,e[9]=v):v=e[9];let w;e[10]!==u||e[11]!==r?(w=u("Open the exemplar trace {trace}",{trace:r}),e[10]=u,e[11]=r,e[12]=w):w=e[12];let h;return e[13]!==i||e[14]!==f||e[15]!==v||e[16]!==w?(h=t("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":f,onClick:v,title:w,type:"button",children:i}),e[13]=i,e[14]=f,e[15]=v,e[16]=w,e[17]=h):h=e[17],h},er=l=>{const e=Fe(105),{onOpenTrace:a,shardKey:s}=l,r=xe();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={},e[0]=u):u=e[0];let o;e[1]!==s?(o={live:!0,shardKey:s},e[1]=s,e[2]=o):o=e[2];const{data:i,error:f,errorSource:v}=Ue(Oe.getMetricSeries,u,o);let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let h;e[4]!==s?(h={live:!0,shardKey:s},e[4]=s,e[5]=h):h=e[5];const{data:d}=Ue(Oe.getMetricHistory,w,h);let g,N,q,C,c,x,p,b,T,R,S,M,$;if(e[6]!==i||e[7]!==f||e[8]!==v||e[9]!==d||e[10]!==a||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{const A=Gt(i),O=wt(v)===Wt;if(f!==null&&!O){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let K;e[27]!==m?(K=t("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=K):K=e[28];let B;e[29]!==f||e[30]!==r?(B=r("Instruments unavailable: {error}",{error:f}),e[29]=f,e[30]=r,e[31]=B):B=e[31];let j;e[32]!==B?(j=t("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:B}),e[32]=B,e[33]=j):j=e[33];let Q;e[34]!==K||e[35]!==j?(Q=n("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[K,j]}),e[34]=K,e[35]=j,e[36]=Q):Q=e[36],b=Q;break e}if(A.length===0){b=null;break e}const k=Xt(d);let z;e[37]!==r?(z=m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),e[37]=r,e[38]=z):z=e[38];const P=z;c="flex flex-col gap-2",x="mt-instruments";let L;e[39]!==r?(L=r("Instruments"),e[39]=r,e[40]=L):L=e[40],e[41]!==L?(p=t("h3",{className:"text-sm font-semibold text-foreground",children:L}),e[41]=L,e[42]=p):p=e[42],C=he,$="overflow-hidden py-0",q=ge,M="px-0",N=dt,R="mt-instruments-table";let U;e[43]!==r?(U=r("name"),e[43]=r,e[44]=U):U=e[44];let J;e[45]!==U?(J=t(de,{children:U}),e[45]=U,e[46]=J):J=e[46];let V;e[47]!==r?(V=r("kind"),e[47]=r,e[48]=V):V=e[48];let G;e[49]!==V?(G=t(de,{children:V}),e[49]=V,e[50]=G):G=e[50];let W;e[51]!==r?(W=r("value"),e[51]=r,e[52]=W):W=e[52];let X;e[53]!==W?(X=t(de,{className:"text-right",children:W}),e[53]=W,e[54]=X):X=e[54];let Y;e[55]!==r?(Y=r("count"),e[55]=r,e[56]=Y):Y=e[56];let Z;e[57]!==Y?(Z=t(de,{className:"text-right",children:Y}),e[57]=Y,e[58]=Z):Z=e[58];let ee;e[59]!==r?(ee=r("range"),e[59]=r,e[60]=ee):ee=e[60];let te;e[61]!==ee?(te=t(de,{className:"text-right",children:ee}),e[61]=ee,e[62]=te):te=e[62];let re;e[63]!==r?(re=r("trend"),e[63]=r,e[64]=re):re=e[64];let se;e[65]!==re?(se=t(de,{children:re}),e[65]=re,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ie;e[69]!==le?(ie=t(de,{children:le}),e[69]=le,e[70]=ie):ie=e[70];let ae;e[71]!==r?(ae=r("dimensions"),e[71]=r,e[72]=ae):ae=e[72];let ne;e[73]!==ae?(ne=t(de,{children:ae}),e[73]=ae,e[74]=ne):ne=e[74],e[75]!==J||e[76]!==G||e[77]!==X||e[78]!==Z||e[79]!==te||e[80]!==se||e[81]!==ie||e[82]!==ne?(S=t(mt,{children:n(Je,{children:[J,G,X,Z,te,se,ie,ne]})}),e[75]=J,e[76]=G,e[77]=X,e[78]=Z,e[79]=te,e[80]=se,e[81]=ie,e[82]=ne,e[83]=S):S=e[83],g=ut,T=A.map(m=>{const K=$t(m.attributes),B=ht(m.kind,m.name,m.attributes),Q=(k.get(B)??[]).map(ue=>Jt(m.kind,ue));return n(Je,{"data-testid":`mt-instrument-${m.name}`,children:[t(oe,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),t(oe,{children:t(et,{variant:Yt[m.kind],children:P(m.kind)})}),t(oe,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:We(Vt(m))}),t(oe,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),t(oe,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"—":`${We(m.min)}–${We(m.max)}`}),t(oe,{children:Q.length>=2?t(ft,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:Q,testId:`mt-instrument-trend-${m.name}`}):t("span",{className:"text-xs text-muted-foreground",children:"—"})}),t(oe,{className:"font-mono text-xs",children:t(Zt,{name:m.name,onOpenTrace:a,traceId:m.exemplarTraceId})}),t(oe,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:K,children:K===""?"—":K})]},B)})}e[6]=i,e[7]=f,e[8]=v,e[9]=d,e[10]=a,e[11]=r,e[12]=g,e[13]=N,e[14]=q,e[15]=C,e[16]=c,e[17]=x,e[18]=p,e[19]=b,e[20]=T,e[21]=R,e[22]=S,e[23]=M,e[24]=$}else g=e[12],N=e[13],q=e[14],C=e[15],c=e[16],x=e[17],p=e[18],b=e[19],T=e[20],R=e[21],S=e[22],M=e[23],$=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let I;e[84]!==g||e[85]!==T?(I=t(g,{children:T}),e[84]=g,e[85]=T,e[86]=I):I=e[86];let _;e[87]!==N||e[88]!==I||e[89]!==R||e[90]!==S?(_=n(N,{"data-testid":R,children:[S,I]}),e[87]=N,e[88]=I,e[89]=R,e[90]=S,e[91]=_):_=e[91];let y;e[92]!==q||e[93]!==_||e[94]!==M?(y=t(q,{className:M,children:_}),e[92]=q,e[93]=_,e[94]=M,e[95]=y):y=e[95];let D;e[96]!==C||e[97]!==y||e[98]!==$?(D=t(C,{className:$,children:y}),e[96]=C,e[97]=y,e[98]=$,e[99]=D):D=e[99];let F;return e[100]!==c||e[101]!==x||e[102]!==p||e[103]!==D?(F=n("section",{className:c,"data-testid":x,children:[p,D]}),e[100]=c,e[101]=x,e[102]=p,e[103]=D,e[104]=F):F=e[104],F},tr=l=>{const e=Fe(74),{aggregate:a,shardResults:s}=l,r=xe();let u;e[0]!==r?(u=r("Shards"),e[0]=r,e[1]=u):u=e[1];let o;e[2]!==a.failed||e[3]!==a.reachable||e[4]!==r?(o=a.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:a.failed,reachable:a.reachable}):r("{reachable} reachable",{reachable:a.reachable}),e[2]=a.failed,e[3]=a.reachable,e[4]=r,e[5]=o):o=e[5];let i;e[6]!==u||e[7]!==o?(i=t(me,{label:u,testId:"mt-agg-shards",value:o}),e[6]=u,e[7]=o,e[8]=i):i=e[8];let f;e[9]!==r?(f=r("Total requests"),e[9]=r,e[10]=f):f=e[10];let v;e[11]!==a.totalRequests||e[12]!==f?(v=t(me,{label:f,testId:"mt-agg-requests",value:a.totalRequests}),e[11]=a.totalRequests,e[12]=f,e[13]=v):v=e[13];let w;e[14]!==r?(w=r("Total errors"),e[14]=r,e[15]=w):w=e[15];let h;e[16]!==a.totalErrors||e[17]!==w?(h=t(me,{label:w,testId:"mt-agg-errors",value:a.totalErrors}),e[16]=a.totalErrors,e[17]=w,e[18]=h):h=e[18];let d;e[19]!==r?(d=r("Total database size"),e[19]=r,e[20]=d):d=e[20];let g;e[21]!==a.totalDatabaseSize?(g=Xe(a.totalDatabaseSize),e[21]=a.totalDatabaseSize,e[22]=g):g=e[22];let N;e[23]!==d||e[24]!==g?(N=t(me,{label:d,testId:"mt-agg-db-size",value:g}),e[23]=d,e[24]=g,e[25]=N):N=e[25];let q;e[26]!==r?(q=r("Combined cache hit rate"),e[26]=r,e[27]=q):q=e[27];let C;e[28]!==a.hitRate||e[29]!==r?(C=a.hitRate===null?r("no cache configured"):`${(a.hitRate*100).toFixed(1)}%`,e[28]=a.hitRate,e[29]=r,e[30]=C):C=e[30];let c;e[31]!==q||e[32]!==C?(c=t(me,{label:q,testId:"mt-agg-cache",value:C}),e[31]=q,e[32]=C,e[33]=c):c=e[33];let x;e[34]!==N||e[35]!==c||e[36]!==i||e[37]!==v||e[38]!==h?(x=n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[i,v,h,N,c]}),e[34]=N,e[35]=c,e[36]=i,e[37]=v,e[38]=h,e[39]=x):x=e[39];let p;e[40]!==r?(p=r("shard"),e[40]=r,e[41]=p):p=e[41];let b;e[42]!==p?(b=t(de,{children:p}),e[42]=p,e[43]=b):b=e[43];let T;e[44]!==r?(T=r("requests"),e[44]=r,e[45]=T):T=e[45];let R;e[46]!==T?(R=t(de,{children:T}),e[46]=T,e[47]=R):R=e[47];let S;e[48]!==r?(S=r("errors"),e[48]=r,e[49]=S):S=e[49];let M;e[50]!==S?(M=t(de,{children:S}),e[50]=S,e[51]=M):M=e[51];let $;e[52]!==r?($=r("db size"),e[52]=r,e[53]=$):$=e[53];let I;e[54]!==$?(I=t(de,{children:$}),e[54]=$,e[55]=I):I=e[55];let _;e[56]!==b||e[57]!==R||e[58]!==M||e[59]!==I?(_=t(mt,{children:n(Je,{children:[b,R,M,I]})}),e[56]=b,e[57]=R,e[58]=M,e[59]=I,e[60]=_):_=e[60];let y;if(e[61]!==s||e[62]!==r){let O;e[64]!==r?(O=k=>n(Je,{"data-testid":`mt-agg-row-${k.shard}`,children:[t(oe,{children:k.shard}),k.metrics===null?t(oe,{className:"text-destructive",colSpan:3,children:k.error??r("unreachable")}):n(Ye,{children:[t(oe,{className:"tabular-nums",children:k.metrics.requests}),t(oe,{className:"tabular-nums",children:k.metrics.errors}),t(oe,{className:"tabular-nums",children:Xe(k.metrics.databaseSize)})]})]},k.shard),e[64]=r,e[65]=O):O=e[65],y=s.map(O),e[61]=s,e[62]=r,e[63]=y}else y=e[63];let D;e[66]!==y?(D=t(ut,{children:y}),e[66]=y,e[67]=D):D=e[67];let F;e[68]!==_||e[69]!==D?(F=t(he,{className:"overflow-hidden py-0",children:t(ge,{className:"px-0",children:n(dt,{"data-testid":"mt-agg-table",children:[_,D]})})}),e[68]=_,e[69]=D,e[70]=F):F=e[70];let A;return e[71]!==x||e[72]!==F?(A=n("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[x,F]}),e[71]=x,e[72]=F,e[73]=A):A=e[73],A},rr=l=>{const e=Math.floor(l/1e3),a=Math.floor(e/3600),s=Math.floor(e%3600/60),r=e%60;return a>0?`${a.toString()}h ${s.toString()}m`:s>0?`${s.toString()}m ${r.toString()}s`:`${r.toString()}s`},sr=(l,e)=>{const a=l+e;return a===0?"—":`${(l/a*100).toFixed(1)}%`},ct=l=>l<=0?"—":l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,lr=l=>{const e=Fe(75),{currentDelta:a,errorRate:s,history:r,latencyPercentiles:u,metrics:o}=l,i=xe(),{cache:f}=o;let v;e[0]!==r||e[1]!==i?(v=r.length>=2?t(ft,{ariaLabel:i("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=i,e[2]=v):v=e[2];let w;e[3]!==a||e[4]!==r.length||e[5]!==i?(w=r.length>=2?n(Ye,{children:[t("span",{className:"font-semibold text-foreground",children:`+${a.toLocaleString()}`})," ",i("last interval")]}):t("span",{"data-testid":"mt-sparkline-empty",children:i("collecting samples…")}),e[3]=a,e[4]=r.length,e[5]=i,e[6]=w):w=e[6];let h;e[7]!==i?(h=i("Requests"),e[7]=i,e[8]=h):h=e[8];let d;e[9]!==o.requests||e[10]!==v||e[11]!==w||e[12]!==h?(d=t(me,{chart:v,footer:w,label:h,testId:"mt-requests",value:o.requests}),e[9]=o.requests,e[10]=v,e[11]=w,e[12]=h,e[13]=d):d=e[13];let g;e[14]!==s||e[15]!==i?(g=i("{rate} error rate",{rate:s}),e[14]=s,e[15]=i,e[16]=g):g=e[16];let N;e[17]!==i?(N=i("Errors"),e[17]=i,e[18]=N):N=e[18];let q;e[19]!==s||e[20]!==o.errors?(q=n(Ye,{children:[o.errors," (",s,")"]}),e[19]=s,e[20]=o.errors,e[21]=q):q=e[21];let C;e[22]!==g||e[23]!==N||e[24]!==q?(C=t(me,{footer:g,label:N,testId:"mt-errors",value:q}),e[22]=g,e[23]=N,e[24]=q,e[25]=C):C=e[25];let c;e[26]!==u.p90?(c=u.p90>0?`P90 ${ct(u.p90)}`:void 0,e[26]=u.p90,e[27]=c):c=e[27];let x;e[28]!==i?(x=i("P95 latency"),e[28]=i,e[29]=x):x=e[29];let p;e[30]!==u.p95?(p=u.p95>0?ct(u.p95):"—",e[30]=u.p95,e[31]=p):p=e[31];let b;e[32]!==x||e[33]!==p||e[34]!==c?(b=t(me,{footer:c,label:x,testId:"mt-p95",value:p}),e[32]=x,e[33]=p,e[34]=c,e[35]=b):b=e[35];let T;e[36]!==f||e[37]!==i?(T=f?`${f.entries.toLocaleString()} ${i("cache entries")}`:void 0,e[36]=f,e[37]=i,e[38]=T):T=e[38];let R;e[39]!==i?(R=i("Database size"),e[39]=i,e[40]=R):R=e[40];let S;e[41]!==o.databaseSize?(S=Xe(o.databaseSize),e[41]=o.databaseSize,e[42]=S):S=e[42];let M;e[43]!==T||e[44]!==R||e[45]!==S?(M=t(me,{footer:T,label:R,testId:"mt-db-size",value:S}),e[43]=T,e[44]=R,e[45]=S,e[46]=M):M=e[46];let $;e[47]!==i?($=i("Shard"),e[47]=i,e[48]=$):$=e[48];let I;e[49]!==o.shard||e[50]!==$?(I=t(me,{label:$,testId:"mt-shard",value:o.shard}),e[49]=o.shard,e[50]=$,e[51]=I):I=e[51];let _;e[52]!==i?(_=i("Uptime"),e[52]=i,e[53]=_):_=e[53];let y;e[54]!==o.uptimeMs?(y=rr(o.uptimeMs),e[54]=o.uptimeMs,e[55]=y):y=e[55];let D;e[56]!==_||e[57]!==y?(D=t(me,{label:_,testId:"mt-uptime",value:y}),e[56]=_,e[57]=y,e[58]=D):D=e[58];let F;e[59]!==i?(F=i("Cache hit rate"),e[59]=i,e[60]=F):F=e[60];let A;e[61]!==f||e[62]!==i?(A=f?i("{rate} ({count} entries)",{count:f.entries,rate:sr(f.hits,f.misses)}):i("no cache configured"),e[61]=f,e[62]=i,e[63]=A):A=e[63];let O;e[64]!==F||e[65]!==A?(O=t(me,{label:F,testId:"mt-cache",value:A}),e[64]=F,e[65]=A,e[66]=O):O=e[66];let k;return e[67]!==b||e[68]!==M||e[69]!==I||e[70]!==D||e[71]!==O||e[72]!==d||e[73]!==C?(k=n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[d,C,b,M,I,D,O]}),e[67]=b,e[68]=M,e[69]=I,e[70]=D,e[71]=O,e[72]=d,e[73]=C,e[74]=k):k=e[74],k},Ve=l=>l>=100?"critical":l>=50?"warning":"good",Ae=l=>l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,He=l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),ir=l=>{const e=Fe(3),{level:a}=l;if(a==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t(et,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(a==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=r):r=e[1],r}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=s):s=e[2],s},ar=(l,e)=>{const a=[...l];return a.sort((s,r)=>{switch(e){case"avgTime":return r.avgDurationMs-s.avgDurationMs;case"execCount":return r.execCount-s.execCount;case"rowsRead":return r.rowsRead-s.rowsRead;default:return r.totalDurationMs-s.totalDurationMs}}),a},nr=l=>{const e=Fe(161),{queryStats:a}=l,s=xe(),[r,u]=pe("totalTime");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,e[0]=o):o=e[0];const[i,f]=pe(o);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=$=>{$!==null&&u($)},e[1]=v):v=e[1];const w=v;let h,d,g,N,q,C,c,x,p,b;if(e[2]!==i||e[3]!==a||e[4]!==r||e[5]!==s){g=Symbol.for("react.early_return_sentinel");e:{const $=ar(a,r);let I;e[16]!==a?(I=a.filter(or),e[16]=a,e[17]=I):I=e[17];const _=I.length;let y;e[18]!==a?(y=a.filter(cr),e[18]=a,e[19]=y):y=e[19];const D=y.length;let F;e[20]!==a?(F=a.filter(dr),e[20]=a,e[21]=F):F=e[21];const A=F.length;let O;e[22]===Symbol.for("react.memo_cache_sentinel")?(O=E=>{f(ce=>{const H=new Set(ce);return H.has(E)?H.delete(E):H.add(E),H})},e[22]=O):O=e[22];const k=O;if(a.length===0){let E;e[23]!==s?(E=s("No query insights yet"),e[23]=s,e[24]=E):E=e[24];let ce;e[25]!==E?(ce=t("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:E}),e[25]=E,e[26]=ce):ce=e[26];let H;e[27]!==s?(H=s("Query insights appear once statements are executed against this shard."),e[27]=s,e[28]=H):H=e[28];let fe;e[29]!==H?(fe=t("p",{className:"mt-1 text-sm",children:H}),e[29]=H,e[30]=fe):fe=e[30];let Pe;e[31]!==ce||e[32]!==fe?(Pe=t(he,{children:t(ge,{className:"py-12",children:n("div",{className:"text-center text-muted-foreground",children:[ce,fe]})})}),e[31]=ce,e[32]=fe,e[33]=Pe):Pe=e[33],g=Pe;break e}c="space-y-4",x="qi-root";let z;e[34]!==s?(z=s("Critical queries"),e[34]=s,e[35]=z):z=e[35];let P;e[36]!==z?(P=t(Be,{className:"pb-2",children:t(je,{className:"text-sm font-medium",children:z})}),e[36]=z,e[37]=P):P=e[37];let L;e[38]!==_?(L=t("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:_}),e[38]=_,e[39]=L):L=e[39];let U;e[40]!==s?(U=s(">100ms avg execution"),e[40]=s,e[41]=U):U=e[41];let J;e[42]!==U?(J=t("p",{className:"text-xs text-muted-foreground",children:U}),e[42]=U,e[43]=J):J=e[43];let V;e[44]!==L||e[45]!==J?(V=n(ge,{children:[L,J]}),e[44]=L,e[45]=J,e[46]=V):V=e[46];let G;e[47]!==P||e[48]!==V?(G=n(he,{children:[P,V]}),e[47]=P,e[48]=V,e[49]=G):G=e[49];let W;e[50]!==s?(W=s("Moderate queries"),e[50]=s,e[51]=W):W=e[51];let X;e[52]!==W?(X=t(Be,{className:"pb-2",children:t(je,{className:"text-sm font-medium",children:W})}),e[52]=W,e[53]=X):X=e[53];let Y;e[54]!==D?(Y=t("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:D}),e[54]=D,e[55]=Y):Y=e[55];let Z;e[56]!==s?(Z=s("50–100ms avg execution"),e[56]=s,e[57]=Z):Z=e[57];let ee;e[58]!==Z?(ee=t("p",{className:"text-xs text-muted-foreground",children:Z}),e[58]=Z,e[59]=ee):ee=e[59];let te;e[60]!==Y||e[61]!==ee?(te=n(ge,{children:[Y,ee]}),e[60]=Y,e[61]=ee,e[62]=te):te=e[62];let re;e[63]!==X||e[64]!==te?(re=n(he,{children:[X,te]}),e[63]=X,e[64]=te,e[65]=re):re=e[65];let se;e[66]!==s?(se=s("Fast queries"),e[66]=s,e[67]=se):se=e[67];let le;e[68]!==se?(le=t(Be,{className:"pb-2",children:t(je,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ie;e[70]!==A?(ie=t("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:A}),e[70]=A,e[71]=ie):ie=e[71];let ae;e[72]!==s?(ae=s("<50ms avg execution"),e[72]=s,e[73]=ae):ae=e[73];let ne;e[74]!==ae?(ne=t("p",{className:"text-xs text-muted-foreground",children:ae}),e[74]=ae,e[75]=ne):ne=e[75];let m;e[76]!==ie||e[77]!==ne?(m=n(ge,{children:[ie,ne]}),e[76]=ie,e[77]=ne,e[78]=m):m=e[78];let K;e[79]!==le||e[80]!==m?(K=n(he,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=K):K=e[81],e[82]!==G||e[83]!==re||e[84]!==K?(p=n("div",{className:"grid gap-4 md:grid-cols-3",children:[G,re,K]}),e[82]=G,e[83]=re,e[84]=K,e[85]=p):p=e[85];let B;e[86]!==s?(B=s("Query leaderboard"),e[86]=s,e[87]=B):B=e[87];let j;e[88]!==B?(j=t("h3",{className:"text-lg font-semibold",children:B}),e[88]=B,e[89]=j):j=e[89];let Q;e[90]!==r||e[91]!==s?(Q=s("Slow queries sorted by {sortField}",{sortField:s(r)}),e[90]=r,e[91]=s,e[92]=Q):Q=e[92];let ue;e[93]!==Q?(ue=t("p",{className:"text-sm text-muted-foreground",children:Q}),e[93]=Q,e[94]=ue):ue=e[94];let be;e[95]!==j||e[96]!==ue?(be=n("div",{children:[j,ue]}),e[95]=j,e[96]=ue,e[97]=be):be=e[97];let ye;e[98]!==s?(ye=s("Sort by"),e[98]=s,e[99]=ye):ye=e[99];let ve;e[100]!==ye?(ve=t("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=ve):ve=e[101];let Ne;e[102]!==s?(Ne=s("Sort queries by"),e[102]=s,e[103]=Ne):Ne=e[103];let Le;e[104]===Symbol.for("react.memo_cache_sentinel")?(Le=t(Bt,{}),e[104]=Le):Le=e[104];let Se;e[105]!==Ne?(Se=t(jt,{"aria-label":Ne,className:"w-[140px]","data-testid":"qi-sort",children:Le}),e[105]=Ne,e[106]=Se):Se=e[106];let we;e[107]!==s?(we=s("Total time"),e[107]=s,e[108]=we):we=e[108];let qe;e[109]!==we?(qe=t(Qe,{value:"totalTime",children:we}),e[109]=we,e[110]=qe):qe=e[110];let Te;e[111]!==s?(Te=s("Avg time"),e[111]=s,e[112]=Te):Te=e[112];let _e;e[113]!==Te?(_e=t(Qe,{value:"avgTime",children:Te}),e[113]=Te,e[114]=_e):_e=e[114];let Ce;e[115]!==s?(Ce=s("Execution count"),e[115]=s,e[116]=Ce):Ce=e[116];let Re;e[117]!==Ce?(Re=t(Qe,{value:"execCount",children:Ce}),e[117]=Ce,e[118]=Re):Re=e[118];let ke;e[119]!==s?(ke=s("Rows read"),e[119]=s,e[120]=ke):ke=e[120];let $e;e[121]!==ke?($e=t(Qe,{value:"rowsRead",children:ke}),e[121]=ke,e[122]=$e):$e=e[122];let Me;e[123]!==qe||e[124]!==_e||e[125]!==Re||e[126]!==$e?(Me=n(Qt,{children:[qe,_e,Re,$e]}),e[123]=qe,e[124]=_e,e[125]=Re,e[126]=$e,e[127]=Me):Me=e[127];let Ie;e[128]!==r||e[129]!==Se||e[130]!==Me?(Ie=n(Ht,{onValueChange:w,value:r,children:[Se,Me]}),e[128]=r,e[129]=Se,e[130]=Me,e[131]=Ie):Ie=e[131];let De;e[132]!==ve||e[133]!==Ie?(De=n("div",{className:"flex items-center gap-2",children:[ve,Ie]}),e[132]=ve,e[133]=Ie,e[134]=De):De=e[134],e[135]!==be||e[136]!==De?(b=n("div",{className:"flex items-center justify-between",children:[be,De]}),e[135]=be,e[136]=De,e[137]=b):b=e[137],d=he;let Ee;e[138]!==s?(Ee=s("Statements"),e[138]=s,e[139]=Ee):Ee=e[139];let ze;e[140]!==Ee?(ze=t(je,{children:Ee}),e[140]=Ee,e[141]=ze):ze=e[141],C=n(Be,{children:[ze,t(Mt,{children:s("{count} tracked statements",{count:$.length})})]}),h=ge,N="space-y-2";let Ke;e[142]!==i||e[143]!==s?(Ke=E=>{const ce=E.normalizedSql,H=i.has(ce),fe=Ve(E.avgDurationMs);return n("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[n("button",{"aria-expanded":H,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{k(ce)},type:"button",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t(ir,{level:fe}),t("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:E.normalizedSql})]}),n("div",{className:"flex shrink-0 items-center gap-4",children:[n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ae(E.totalDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("total")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ae(E.avgDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("avg")})]}),E.p95DurationMs!==void 0&&n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ae(E.p95DurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("p95")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:He(E.execCount)}),t("div",{className:"text-xs text-muted-foreground",children:s("calls")})]})]})]}),H&&n("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[n("div",{children:[t("p",{className:"mb-2 text-sm font-medium",children:s("Full statement")}),t("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:E.normalizedSql})]}),n("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[E.p50DurationMs!==void 0&&n("div",{children:[t("span",{className:"text-muted-foreground",children:s("p50")}),t("span",{className:"block font-medium tabular-nums",children:Ae(E.p50DurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Exec count")}),t("span",{className:"block font-medium tabular-nums",children:He(E.execCount)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Total time")}),t("span",{className:"block font-medium tabular-nums",children:Ae(E.totalDurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Rows read")}),t("span",{className:"block font-medium tabular-nums",children:He(E.rowsRead)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Rows written")}),t("span",{className:"block font-medium tabular-nums",children:He(E.rowsWritten)})]})]})]})]},ce)},e[142]=i,e[143]=s,e[144]=Ke):Ke=e[144],q=$.map(Ke)}e[2]=i,e[3]=a,e[4]=r,e[5]=s,e[6]=h,e[7]=d,e[8]=g,e[9]=N,e[10]=q,e[11]=C,e[12]=c,e[13]=x,e[14]=p,e[15]=b}else h=e[6],d=e[7],g=e[8],N=e[9],q=e[10],C=e[11],c=e[12],x=e[13],p=e[14],b=e[15];if(g!==Symbol.for("react.early_return_sentinel"))return g;let T;e[145]!==N||e[146]!==q?(T=t("div",{className:N,children:q}),e[145]=N,e[146]=q,e[147]=T):T=e[147];let R;e[148]!==h||e[149]!==T?(R=t(h,{children:T}),e[148]=h,e[149]=T,e[150]=R):R=e[150];let S;e[151]!==d||e[152]!==R||e[153]!==C?(S=n(d,{children:[C,R]}),e[151]=d,e[152]=R,e[153]=C,e[154]=S):S=e[154];let M;return e[155]!==S||e[156]!==c||e[157]!==x||e[158]!==p||e[159]!==b?(M=n("div",{className:c,"data-testid":x,children:[p,b,S]}),e[155]=S,e[156]=c,e[157]=x,e[158]=p,e[159]=b,e[160]=M):M=e[160],M};function or(l){return Ve(l.avgDurationMs)==="critical"}function cr(l){return Ve(l.avgDurationMs)==="warning"}function dr(l){return Ve(l.avgDurationMs)==="good"}const mr=["1m","5m","15m","1h"],ur=l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),fr=l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),hr=({shardKey:l=""})=>{const e=xe(),[a,s]=pe("15m"),u=Ue(Oe.getQueryInsights,{range:a},{live:!0,shardKey:l}).data,o=fr(u?.buckets??[]);return n("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:mr.map(i=>t("button",{"aria-pressed":i===a,className:Pt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===a&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:()=>{s(i)},type:"button",children:i},i))}),u?.capped===!0&&t(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),o.length===0?t(Kt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):n("div",{className:"grid gap-4 lg:grid-cols-2",children:[n("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),t(st,{height:140,width:"100%",children:n(At,{data:o,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(it,{dataKey:"label",fontSize:10,tickLine:!1}),t(at,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),t(nt,{}),t(Ot,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),n("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),t(st,{height:140,width:"100%",children:n(Lt,{data:o,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(it,{dataKey:"label",fontSize:10,tickLine:!1}),t(at,{fontSize:10,tickLine:!1,width:32}),t(nt,{}),t(zt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),t(nr,{queryStats:u?.entries??[]})]})},gr=Ct(Oe.getMetrics),pr=(l,e)=>l?e:"overview",jr=({initialShardKey:l})=>{const e=pt(),a=xe(),{queryShardKey:s,setShardKey:r,shardKey:u}=Nt(l),[o,i]=pe("overview"),[f,v]=pe([]),w=Ge(null),h=Ge(null),d=Ge(!0);tt(()=>(d.current=!0,()=>{d.current=!1}),[]);const g=vt(s),{data:N,error:q,liveError:C}=Ue(Oe.getMetrics,{},{live:!0,shardKey:s}),c=N??null;tt(()=>{if(N===void 0)return;Rt(s);const k=N,z=w.current,P=h.current!==null&&h.current!==k.shard;if(h.current=k.shard,w.current=k.requests,P){v([]);return}z!==null&&k.requests>=z&&v(L=>[...L,k.requests-z].slice(-30))},[N,s]);const[x,p]=pe(null),[b,T]=pe(!1),R=async()=>{T(!0);const k=Ft(u,kt());try{const z=await Promise.all(k.map(async P=>{try{const L=await e.query(gr,{},Tt(P));return{error:null,metrics:L,shard:P===""?L.shard:P}}catch(L){return{error:_t(L),metrics:null,shard:P===""?"__root__":P}}}));d.current&&p(z)}finally{d.current&&T(!1)}},S=x===null?null:It(x),M=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,$=f.length>0?f.at(-1):0,I=c?Dt(c):{p90:0,p95:0},_=xt(()=>{if(!c||!("queryStats"in c))return;const k=c.queryStats;if(!(!k||!Array.isArray(k)))return Et(k)},[c]),y=pr(_!==void 0,o),D=()=>{qt(R())},F=()=>{p(null)},A=()=>{i("overview")},O=()=>{i("query-insights")};return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(yt,{onChange:r,testId:"mt-shard-input",value:u}),t(bt,{message:C,prefix:"mt"}),t(rt,{"data-testid":"mt-aggregate",disabled:b,onClick:D,size:"sm",type:"button",variant:"secondary",children:a(b?"Aggregating…":"All shards")}),x!==null&&t(rt,{"data-testid":"mt-aggregate-clear",onClick:F,size:"sm",type:"button",variant:"ghost",children:a("Hide")}),t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:St,rel:"noreferrer",target:"_blank",children:a("Open in Cloudflare")})]}),q!==null&&t("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:q}),_!==void 0&&n("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[t("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:A,type:"button",children:a("Overview")}),n("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:O,type:"button",children:[a("Query insights"),_.length>0&&t("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:_.length})]})]}),y==="query-insights"&&_!==void 0&&t(hr,{shardKey:s}),y==="overview"&&c!==null&&t(lr,{currentDelta:$,errorRate:M,history:f,latencyPercentiles:I,metrics:c}),y==="overview"&&c===null&&null,y==="overview"&&t(er,{onOpenTrace:g,shardKey:s}),y==="overview"&&S!==null&&x!==null&&t(tr,{aggregate:S,shardResults:x})]})};export{jr as MetricsPanel};
|
|
1
|
+
import{useLunora as pt}from"@lunora/react";import{useState as pe,useRef as Ge,useEffect as tt,useMemo as xt}from"react";import{L as bt}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as yt}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as rt}from"../packem_shared/button-q0UYSmrn.mjs";import{u as Ue}from"../packem_shared/use-admin-query-BvZH4unR.mjs";import{u as vt}from"../packem_shared/use-open-trace-CTQIPjo9.mjs";import{u as Nt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as xe}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as Oe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as St}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{m as wt,l as Xe,f as qt,d as Tt,b as _t,c as Ct}from"../packem_shared/internal-D4gBuklE.mjs";import{r as Rt,l as kt}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{c as Fe}from"react/compiler-runtime";import{f as $t}from"../packem_shared/log-fields-SBxKyBug.mjs";import{B as et}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as he,a as ge,c as Be,d as Mt,b as je}from"../packem_shared/card--2hKx4L2.mjs";import{b as Je,e as oe,T as dt,c as de,a as mt,d as ut}from"../packem_shared/table-D0SBiDu-.mjs";import{S as ft}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as n,jsx as t,Fragment as Ye}from"react/jsx-runtime";import{aggregateMetrics as It,computeLatencyPercentiles as Dt,enrichQueryStats as Et,shardsToAggregate as Ft}from"../packem_shared/aggregateMetrics-CY05xrYU.mjs";import{S as me}from"../packem_shared/stat-card-D0Fe04cX.mjs";import{ResponsiveContainer as st,AreaChart as At,CartesianGrid as lt,XAxis as it,YAxis as at,Tooltip as nt,Area as Ot,LineChart as Lt,Line as zt}from"recharts";import{E as Kt}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as Pt}from"../packem_shared/utils-bhneXptQ.mjs";import{S as Bt,a as jt,c as Qe,b as Qt,d as Ht}from"../packem_shared/select-DPyS18Vy.mjs";const Ut=/["\\\u0000-\u001F\uD800-\uDFFF]/,ot=l=>Ut.test(l)?JSON.stringify(l):`"${l}"`,Ze=l=>{if(l===void 0)return"null";if(typeof l=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof l=="number"){if(Number.isNaN(l))return"nan";if(l===1/0)return"inf";if(l===-1/0)return"-inf";if(Object.is(l,-0))return"-0"}if(typeof l=="string")return ot(l);if(l===null||typeof l!="object")return JSON.stringify(l);if(Array.isArray(l)){let o="[";for(let i=0;i<l.length;i++)i>0&&(o+=","),o+=Ze(l[i]);return o+"]"}const e=Object.getPrototypeOf(l);if(e!==null&&e!==Object.prototype){const o=l.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${o} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const a=l,s=Object.keys(a).sort();let r="{",u=!0;for(const o of s){const i=a[o];i!==void 0&&(u?u=!1:r+=",",r+=ot(o),r+=":",r+=Ze(i))}return r+"}"},ht=(l,e,a)=>`${l}:${e}:${Ze(a??{})}`,gt=(l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,Jt=(l,e)=>gt(l,e),Vt=l=>gt(l.kind,l),We=l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),Gt=l=>Array.isArray(l?.series)?l.series:[],Wt="FUNCTION_NOT_FOUND",Xt=l=>{const e=new Map;if(!Array.isArray(l?.series))return e;for(const a of l.series)e.set(ht(a.kind,a.name,a.attributes),a.points);return e},Yt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=l=>{const e=Fe(18),{name:a,onOpenTrace:s,traceId:r}=l,u=xe();if(r===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=t("span",{className:"text-muted-foreground",children:"—"}),e[0]=d):d=e[0],d}let o;e[1]!==r?(o=r.slice(0,8),e[1]=r,e[2]=o):o=e[2];const i=o;if(s===void 0){const d=`mt-instrument-trace-${a}`;let g;return e[3]!==i||e[4]!==d||e[5]!==r?(g=t("span",{className:"text-muted-foreground","data-testid":d,title:r,children:i}),e[3]=i,e[4]=d,e[5]=r,e[6]=g):g=e[6],g}const f=`mt-instrument-trace-${a}`;let v;e[7]!==s||e[8]!==r?(v=()=>{s(r)},e[7]=s,e[8]=r,e[9]=v):v=e[9];let w;e[10]!==u||e[11]!==r?(w=u("Open the exemplar trace {trace}",{trace:r}),e[10]=u,e[11]=r,e[12]=w):w=e[12];let h;return e[13]!==i||e[14]!==f||e[15]!==v||e[16]!==w?(h=t("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":f,onClick:v,title:w,type:"button",children:i}),e[13]=i,e[14]=f,e[15]=v,e[16]=w,e[17]=h):h=e[17],h},er=l=>{const e=Fe(105),{onOpenTrace:a,shardKey:s}=l,r=xe();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={},e[0]=u):u=e[0];let o;e[1]!==s?(o={live:!0,shardKey:s},e[1]=s,e[2]=o):o=e[2];const{data:i,error:f,errorSource:v}=Ue(Oe.getMetricSeries,u,o);let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let h;e[4]!==s?(h={live:!0,shardKey:s},e[4]=s,e[5]=h):h=e[5];const{data:d}=Ue(Oe.getMetricHistory,w,h);let g,N,q,C,c,x,p,b,T,R,S,M,$;if(e[6]!==i||e[7]!==f||e[8]!==v||e[9]!==d||e[10]!==a||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{const A=Gt(i),O=wt(v)===Wt;if(f!==null&&!O){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let K;e[27]!==m?(K=t("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=K):K=e[28];let B;e[29]!==f||e[30]!==r?(B=r("Instruments unavailable: {error}",{error:f}),e[29]=f,e[30]=r,e[31]=B):B=e[31];let j;e[32]!==B?(j=t("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:B}),e[32]=B,e[33]=j):j=e[33];let Q;e[34]!==K||e[35]!==j?(Q=n("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[K,j]}),e[34]=K,e[35]=j,e[36]=Q):Q=e[36],b=Q;break e}if(A.length===0){b=null;break e}const k=Xt(d);let z;e[37]!==r?(z=m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),e[37]=r,e[38]=z):z=e[38];const P=z;c="flex flex-col gap-2",x="mt-instruments";let L;e[39]!==r?(L=r("Instruments"),e[39]=r,e[40]=L):L=e[40],e[41]!==L?(p=t("h3",{className:"text-sm font-semibold text-foreground",children:L}),e[41]=L,e[42]=p):p=e[42],C=he,$="overflow-hidden py-0",q=ge,M="px-0",N=dt,R="mt-instruments-table";let U;e[43]!==r?(U=r("name"),e[43]=r,e[44]=U):U=e[44];let J;e[45]!==U?(J=t(de,{children:U}),e[45]=U,e[46]=J):J=e[46];let V;e[47]!==r?(V=r("kind"),e[47]=r,e[48]=V):V=e[48];let G;e[49]!==V?(G=t(de,{children:V}),e[49]=V,e[50]=G):G=e[50];let W;e[51]!==r?(W=r("value"),e[51]=r,e[52]=W):W=e[52];let X;e[53]!==W?(X=t(de,{className:"text-right",children:W}),e[53]=W,e[54]=X):X=e[54];let Y;e[55]!==r?(Y=r("count"),e[55]=r,e[56]=Y):Y=e[56];let Z;e[57]!==Y?(Z=t(de,{className:"text-right",children:Y}),e[57]=Y,e[58]=Z):Z=e[58];let ee;e[59]!==r?(ee=r("range"),e[59]=r,e[60]=ee):ee=e[60];let te;e[61]!==ee?(te=t(de,{className:"text-right",children:ee}),e[61]=ee,e[62]=te):te=e[62];let re;e[63]!==r?(re=r("trend"),e[63]=r,e[64]=re):re=e[64];let se;e[65]!==re?(se=t(de,{children:re}),e[65]=re,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ie;e[69]!==le?(ie=t(de,{children:le}),e[69]=le,e[70]=ie):ie=e[70];let ae;e[71]!==r?(ae=r("dimensions"),e[71]=r,e[72]=ae):ae=e[72];let ne;e[73]!==ae?(ne=t(de,{children:ae}),e[73]=ae,e[74]=ne):ne=e[74],e[75]!==J||e[76]!==G||e[77]!==X||e[78]!==Z||e[79]!==te||e[80]!==se||e[81]!==ie||e[82]!==ne?(S=t(mt,{children:n(Je,{children:[J,G,X,Z,te,se,ie,ne]})}),e[75]=J,e[76]=G,e[77]=X,e[78]=Z,e[79]=te,e[80]=se,e[81]=ie,e[82]=ne,e[83]=S):S=e[83],g=ut,T=A.map(m=>{const K=$t(m.attributes),B=ht(m.kind,m.name,m.attributes),Q=(k.get(B)??[]).map(ue=>Jt(m.kind,ue));return n(Je,{"data-testid":`mt-instrument-${m.name}`,children:[t(oe,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),t(oe,{children:t(et,{variant:Yt[m.kind],children:P(m.kind)})}),t(oe,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:We(Vt(m))}),t(oe,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),t(oe,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"—":`${We(m.min)}–${We(m.max)}`}),t(oe,{children:Q.length>=2?t(ft,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:Q,testId:`mt-instrument-trend-${m.name}`}):t("span",{className:"text-xs text-muted-foreground",children:"—"})}),t(oe,{className:"font-mono text-xs",children:t(Zt,{name:m.name,onOpenTrace:a,traceId:m.exemplarTraceId})}),t(oe,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:K,children:K===""?"—":K})]},B)})}e[6]=i,e[7]=f,e[8]=v,e[9]=d,e[10]=a,e[11]=r,e[12]=g,e[13]=N,e[14]=q,e[15]=C,e[16]=c,e[17]=x,e[18]=p,e[19]=b,e[20]=T,e[21]=R,e[22]=S,e[23]=M,e[24]=$}else g=e[12],N=e[13],q=e[14],C=e[15],c=e[16],x=e[17],p=e[18],b=e[19],T=e[20],R=e[21],S=e[22],M=e[23],$=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let I;e[84]!==g||e[85]!==T?(I=t(g,{children:T}),e[84]=g,e[85]=T,e[86]=I):I=e[86];let _;e[87]!==N||e[88]!==I||e[89]!==R||e[90]!==S?(_=n(N,{"data-testid":R,children:[S,I]}),e[87]=N,e[88]=I,e[89]=R,e[90]=S,e[91]=_):_=e[91];let y;e[92]!==q||e[93]!==_||e[94]!==M?(y=t(q,{className:M,children:_}),e[92]=q,e[93]=_,e[94]=M,e[95]=y):y=e[95];let D;e[96]!==C||e[97]!==y||e[98]!==$?(D=t(C,{className:$,children:y}),e[96]=C,e[97]=y,e[98]=$,e[99]=D):D=e[99];let F;return e[100]!==c||e[101]!==x||e[102]!==p||e[103]!==D?(F=n("section",{className:c,"data-testid":x,children:[p,D]}),e[100]=c,e[101]=x,e[102]=p,e[103]=D,e[104]=F):F=e[104],F},tr=l=>{const e=Fe(74),{aggregate:a,shardResults:s}=l,r=xe();let u;e[0]!==r?(u=r("Shards"),e[0]=r,e[1]=u):u=e[1];let o;e[2]!==a.failed||e[3]!==a.reachable||e[4]!==r?(o=a.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:a.failed,reachable:a.reachable}):r("{reachable} reachable",{reachable:a.reachable}),e[2]=a.failed,e[3]=a.reachable,e[4]=r,e[5]=o):o=e[5];let i;e[6]!==u||e[7]!==o?(i=t(me,{label:u,testId:"mt-agg-shards",value:o}),e[6]=u,e[7]=o,e[8]=i):i=e[8];let f;e[9]!==r?(f=r("Total requests"),e[9]=r,e[10]=f):f=e[10];let v;e[11]!==a.totalRequests||e[12]!==f?(v=t(me,{label:f,testId:"mt-agg-requests",value:a.totalRequests}),e[11]=a.totalRequests,e[12]=f,e[13]=v):v=e[13];let w;e[14]!==r?(w=r("Total errors"),e[14]=r,e[15]=w):w=e[15];let h;e[16]!==a.totalErrors||e[17]!==w?(h=t(me,{label:w,testId:"mt-agg-errors",value:a.totalErrors}),e[16]=a.totalErrors,e[17]=w,e[18]=h):h=e[18];let d;e[19]!==r?(d=r("Total database size"),e[19]=r,e[20]=d):d=e[20];let g;e[21]!==a.totalDatabaseSize?(g=Xe(a.totalDatabaseSize),e[21]=a.totalDatabaseSize,e[22]=g):g=e[22];let N;e[23]!==d||e[24]!==g?(N=t(me,{label:d,testId:"mt-agg-db-size",value:g}),e[23]=d,e[24]=g,e[25]=N):N=e[25];let q;e[26]!==r?(q=r("Combined cache hit rate"),e[26]=r,e[27]=q):q=e[27];let C;e[28]!==a.hitRate||e[29]!==r?(C=a.hitRate===null?r("no cache configured"):`${(a.hitRate*100).toFixed(1)}%`,e[28]=a.hitRate,e[29]=r,e[30]=C):C=e[30];let c;e[31]!==q||e[32]!==C?(c=t(me,{label:q,testId:"mt-agg-cache",value:C}),e[31]=q,e[32]=C,e[33]=c):c=e[33];let x;e[34]!==N||e[35]!==c||e[36]!==i||e[37]!==v||e[38]!==h?(x=n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[i,v,h,N,c]}),e[34]=N,e[35]=c,e[36]=i,e[37]=v,e[38]=h,e[39]=x):x=e[39];let p;e[40]!==r?(p=r("shard"),e[40]=r,e[41]=p):p=e[41];let b;e[42]!==p?(b=t(de,{children:p}),e[42]=p,e[43]=b):b=e[43];let T;e[44]!==r?(T=r("requests"),e[44]=r,e[45]=T):T=e[45];let R;e[46]!==T?(R=t(de,{children:T}),e[46]=T,e[47]=R):R=e[47];let S;e[48]!==r?(S=r("errors"),e[48]=r,e[49]=S):S=e[49];let M;e[50]!==S?(M=t(de,{children:S}),e[50]=S,e[51]=M):M=e[51];let $;e[52]!==r?($=r("db size"),e[52]=r,e[53]=$):$=e[53];let I;e[54]!==$?(I=t(de,{children:$}),e[54]=$,e[55]=I):I=e[55];let _;e[56]!==b||e[57]!==R||e[58]!==M||e[59]!==I?(_=t(mt,{children:n(Je,{children:[b,R,M,I]})}),e[56]=b,e[57]=R,e[58]=M,e[59]=I,e[60]=_):_=e[60];let y;if(e[61]!==s||e[62]!==r){let O;e[64]!==r?(O=k=>n(Je,{"data-testid":`mt-agg-row-${k.shard}`,children:[t(oe,{children:k.shard}),k.metrics===null?t(oe,{className:"text-destructive",colSpan:3,children:k.error??r("unreachable")}):n(Ye,{children:[t(oe,{className:"tabular-nums",children:k.metrics.requests}),t(oe,{className:"tabular-nums",children:k.metrics.errors}),t(oe,{className:"tabular-nums",children:Xe(k.metrics.databaseSize)})]})]},k.shard),e[64]=r,e[65]=O):O=e[65],y=s.map(O),e[61]=s,e[62]=r,e[63]=y}else y=e[63];let D;e[66]!==y?(D=t(ut,{children:y}),e[66]=y,e[67]=D):D=e[67];let F;e[68]!==_||e[69]!==D?(F=t(he,{className:"overflow-hidden py-0",children:t(ge,{className:"px-0",children:n(dt,{"data-testid":"mt-agg-table",children:[_,D]})})}),e[68]=_,e[69]=D,e[70]=F):F=e[70];let A;return e[71]!==x||e[72]!==F?(A=n("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[x,F]}),e[71]=x,e[72]=F,e[73]=A):A=e[73],A},rr=l=>{const e=Math.floor(l/1e3),a=Math.floor(e/3600),s=Math.floor(e%3600/60),r=e%60;return a>0?`${a.toString()}h ${s.toString()}m`:s>0?`${s.toString()}m ${r.toString()}s`:`${r.toString()}s`},sr=(l,e)=>{const a=l+e;return a===0?"—":`${(l/a*100).toFixed(1)}%`},ct=l=>l<=0?"—":l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,lr=l=>{const e=Fe(75),{currentDelta:a,errorRate:s,history:r,latencyPercentiles:u,metrics:o}=l,i=xe(),{cache:f}=o;let v;e[0]!==r||e[1]!==i?(v=r.length>=2?t(ft,{ariaLabel:i("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=i,e[2]=v):v=e[2];let w;e[3]!==a||e[4]!==r.length||e[5]!==i?(w=r.length>=2?n(Ye,{children:[t("span",{className:"font-semibold text-foreground",children:`+${a.toLocaleString()}`})," ",i("last interval")]}):t("span",{"data-testid":"mt-sparkline-empty",children:i("collecting samples…")}),e[3]=a,e[4]=r.length,e[5]=i,e[6]=w):w=e[6];let h;e[7]!==i?(h=i("Requests"),e[7]=i,e[8]=h):h=e[8];let d;e[9]!==o.requests||e[10]!==v||e[11]!==w||e[12]!==h?(d=t(me,{chart:v,footer:w,label:h,testId:"mt-requests",value:o.requests}),e[9]=o.requests,e[10]=v,e[11]=w,e[12]=h,e[13]=d):d=e[13];let g;e[14]!==s||e[15]!==i?(g=i("{rate} error rate",{rate:s}),e[14]=s,e[15]=i,e[16]=g):g=e[16];let N;e[17]!==i?(N=i("Errors"),e[17]=i,e[18]=N):N=e[18];let q;e[19]!==s||e[20]!==o.errors?(q=n(Ye,{children:[o.errors," (",s,")"]}),e[19]=s,e[20]=o.errors,e[21]=q):q=e[21];let C;e[22]!==g||e[23]!==N||e[24]!==q?(C=t(me,{footer:g,label:N,testId:"mt-errors",value:q}),e[22]=g,e[23]=N,e[24]=q,e[25]=C):C=e[25];let c;e[26]!==u.p90?(c=u.p90>0?`P90 ${ct(u.p90)}`:void 0,e[26]=u.p90,e[27]=c):c=e[27];let x;e[28]!==i?(x=i("P95 latency"),e[28]=i,e[29]=x):x=e[29];let p;e[30]!==u.p95?(p=u.p95>0?ct(u.p95):"—",e[30]=u.p95,e[31]=p):p=e[31];let b;e[32]!==x||e[33]!==p||e[34]!==c?(b=t(me,{footer:c,label:x,testId:"mt-p95",value:p}),e[32]=x,e[33]=p,e[34]=c,e[35]=b):b=e[35];let T;e[36]!==f||e[37]!==i?(T=f?`${f.entries.toLocaleString()} ${i("cache entries")}`:void 0,e[36]=f,e[37]=i,e[38]=T):T=e[38];let R;e[39]!==i?(R=i("Database size"),e[39]=i,e[40]=R):R=e[40];let S;e[41]!==o.databaseSize?(S=Xe(o.databaseSize),e[41]=o.databaseSize,e[42]=S):S=e[42];let M;e[43]!==T||e[44]!==R||e[45]!==S?(M=t(me,{footer:T,label:R,testId:"mt-db-size",value:S}),e[43]=T,e[44]=R,e[45]=S,e[46]=M):M=e[46];let $;e[47]!==i?($=i("Shard"),e[47]=i,e[48]=$):$=e[48];let I;e[49]!==o.shard||e[50]!==$?(I=t(me,{label:$,testId:"mt-shard",value:o.shard}),e[49]=o.shard,e[50]=$,e[51]=I):I=e[51];let _;e[52]!==i?(_=i("Uptime"),e[52]=i,e[53]=_):_=e[53];let y;e[54]!==o.uptimeMs?(y=rr(o.uptimeMs),e[54]=o.uptimeMs,e[55]=y):y=e[55];let D;e[56]!==_||e[57]!==y?(D=t(me,{label:_,testId:"mt-uptime",value:y}),e[56]=_,e[57]=y,e[58]=D):D=e[58];let F;e[59]!==i?(F=i("Cache hit rate"),e[59]=i,e[60]=F):F=e[60];let A;e[61]!==f||e[62]!==i?(A=f?i("{rate} ({count} entries)",{count:f.entries,rate:sr(f.hits,f.misses)}):i("no cache configured"),e[61]=f,e[62]=i,e[63]=A):A=e[63];let O;e[64]!==F||e[65]!==A?(O=t(me,{label:F,testId:"mt-cache",value:A}),e[64]=F,e[65]=A,e[66]=O):O=e[66];let k;return e[67]!==b||e[68]!==M||e[69]!==I||e[70]!==D||e[71]!==O||e[72]!==d||e[73]!==C?(k=n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[d,C,b,M,I,D,O]}),e[67]=b,e[68]=M,e[69]=I,e[70]=D,e[71]=O,e[72]=d,e[73]=C,e[74]=k):k=e[74],k},Ve=l=>l>=100?"critical":l>=50?"warning":"good",Ae=l=>l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,He=l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),ir=l=>{const e=Fe(3),{level:a}=l;if(a==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t(et,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(a==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=r):r=e[1],r}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=s):s=e[2],s},ar=(l,e)=>{const a=[...l];return a.sort((s,r)=>{switch(e){case"avgTime":return r.avgDurationMs-s.avgDurationMs;case"execCount":return r.execCount-s.execCount;case"rowsRead":return r.rowsRead-s.rowsRead;default:return r.totalDurationMs-s.totalDurationMs}}),a},nr=l=>{const e=Fe(161),{queryStats:a}=l,s=xe(),[r,u]=pe("totalTime");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,e[0]=o):o=e[0];const[i,f]=pe(o);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=$=>{$!==null&&u($)},e[1]=v):v=e[1];const w=v;let h,d,g,N,q,C,c,x,p,b;if(e[2]!==i||e[3]!==a||e[4]!==r||e[5]!==s){g=Symbol.for("react.early_return_sentinel");e:{const $=ar(a,r);let I;e[16]!==a?(I=a.filter(or),e[16]=a,e[17]=I):I=e[17];const _=I.length;let y;e[18]!==a?(y=a.filter(cr),e[18]=a,e[19]=y):y=e[19];const D=y.length;let F;e[20]!==a?(F=a.filter(dr),e[20]=a,e[21]=F):F=e[21];const A=F.length;let O;e[22]===Symbol.for("react.memo_cache_sentinel")?(O=E=>{f(ce=>{const H=new Set(ce);return H.has(E)?H.delete(E):H.add(E),H})},e[22]=O):O=e[22];const k=O;if(a.length===0){let E;e[23]!==s?(E=s("No query insights yet"),e[23]=s,e[24]=E):E=e[24];let ce;e[25]!==E?(ce=t("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:E}),e[25]=E,e[26]=ce):ce=e[26];let H;e[27]!==s?(H=s("Query insights appear once statements are executed against this shard."),e[27]=s,e[28]=H):H=e[28];let fe;e[29]!==H?(fe=t("p",{className:"mt-1 text-sm",children:H}),e[29]=H,e[30]=fe):fe=e[30];let Pe;e[31]!==ce||e[32]!==fe?(Pe=t(he,{children:t(ge,{className:"py-12",children:n("div",{className:"text-center text-muted-foreground",children:[ce,fe]})})}),e[31]=ce,e[32]=fe,e[33]=Pe):Pe=e[33],g=Pe;break e}c="space-y-4",x="qi-root";let z;e[34]!==s?(z=s("Critical queries"),e[34]=s,e[35]=z):z=e[35];let P;e[36]!==z?(P=t(Be,{className:"pb-2",children:t(je,{className:"text-sm font-medium",children:z})}),e[36]=z,e[37]=P):P=e[37];let L;e[38]!==_?(L=t("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:_}),e[38]=_,e[39]=L):L=e[39];let U;e[40]!==s?(U=s(">100ms avg execution"),e[40]=s,e[41]=U):U=e[41];let J;e[42]!==U?(J=t("p",{className:"text-xs text-muted-foreground",children:U}),e[42]=U,e[43]=J):J=e[43];let V;e[44]!==L||e[45]!==J?(V=n(ge,{children:[L,J]}),e[44]=L,e[45]=J,e[46]=V):V=e[46];let G;e[47]!==P||e[48]!==V?(G=n(he,{children:[P,V]}),e[47]=P,e[48]=V,e[49]=G):G=e[49];let W;e[50]!==s?(W=s("Moderate queries"),e[50]=s,e[51]=W):W=e[51];let X;e[52]!==W?(X=t(Be,{className:"pb-2",children:t(je,{className:"text-sm font-medium",children:W})}),e[52]=W,e[53]=X):X=e[53];let Y;e[54]!==D?(Y=t("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:D}),e[54]=D,e[55]=Y):Y=e[55];let Z;e[56]!==s?(Z=s("50–100ms avg execution"),e[56]=s,e[57]=Z):Z=e[57];let ee;e[58]!==Z?(ee=t("p",{className:"text-xs text-muted-foreground",children:Z}),e[58]=Z,e[59]=ee):ee=e[59];let te;e[60]!==Y||e[61]!==ee?(te=n(ge,{children:[Y,ee]}),e[60]=Y,e[61]=ee,e[62]=te):te=e[62];let re;e[63]!==X||e[64]!==te?(re=n(he,{children:[X,te]}),e[63]=X,e[64]=te,e[65]=re):re=e[65];let se;e[66]!==s?(se=s("Fast queries"),e[66]=s,e[67]=se):se=e[67];let le;e[68]!==se?(le=t(Be,{className:"pb-2",children:t(je,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ie;e[70]!==A?(ie=t("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:A}),e[70]=A,e[71]=ie):ie=e[71];let ae;e[72]!==s?(ae=s("<50ms avg execution"),e[72]=s,e[73]=ae):ae=e[73];let ne;e[74]!==ae?(ne=t("p",{className:"text-xs text-muted-foreground",children:ae}),e[74]=ae,e[75]=ne):ne=e[75];let m;e[76]!==ie||e[77]!==ne?(m=n(ge,{children:[ie,ne]}),e[76]=ie,e[77]=ne,e[78]=m):m=e[78];let K;e[79]!==le||e[80]!==m?(K=n(he,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=K):K=e[81],e[82]!==G||e[83]!==re||e[84]!==K?(p=n("div",{className:"grid gap-4 md:grid-cols-3",children:[G,re,K]}),e[82]=G,e[83]=re,e[84]=K,e[85]=p):p=e[85];let B;e[86]!==s?(B=s("Query leaderboard"),e[86]=s,e[87]=B):B=e[87];let j;e[88]!==B?(j=t("h3",{className:"text-lg font-semibold",children:B}),e[88]=B,e[89]=j):j=e[89];let Q;e[90]!==r||e[91]!==s?(Q=s("Slow queries sorted by {sortField}",{sortField:s(r)}),e[90]=r,e[91]=s,e[92]=Q):Q=e[92];let ue;e[93]!==Q?(ue=t("p",{className:"text-sm text-muted-foreground",children:Q}),e[93]=Q,e[94]=ue):ue=e[94];let be;e[95]!==j||e[96]!==ue?(be=n("div",{children:[j,ue]}),e[95]=j,e[96]=ue,e[97]=be):be=e[97];let ye;e[98]!==s?(ye=s("Sort by"),e[98]=s,e[99]=ye):ye=e[99];let ve;e[100]!==ye?(ve=t("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=ve):ve=e[101];let Ne;e[102]!==s?(Ne=s("Sort queries by"),e[102]=s,e[103]=Ne):Ne=e[103];let Le;e[104]===Symbol.for("react.memo_cache_sentinel")?(Le=t(Bt,{}),e[104]=Le):Le=e[104];let Se;e[105]!==Ne?(Se=t(jt,{"aria-label":Ne,className:"w-[140px]","data-testid":"qi-sort",children:Le}),e[105]=Ne,e[106]=Se):Se=e[106];let we;e[107]!==s?(we=s("Total time"),e[107]=s,e[108]=we):we=e[108];let qe;e[109]!==we?(qe=t(Qe,{value:"totalTime",children:we}),e[109]=we,e[110]=qe):qe=e[110];let Te;e[111]!==s?(Te=s("Avg time"),e[111]=s,e[112]=Te):Te=e[112];let _e;e[113]!==Te?(_e=t(Qe,{value:"avgTime",children:Te}),e[113]=Te,e[114]=_e):_e=e[114];let Ce;e[115]!==s?(Ce=s("Execution count"),e[115]=s,e[116]=Ce):Ce=e[116];let Re;e[117]!==Ce?(Re=t(Qe,{value:"execCount",children:Ce}),e[117]=Ce,e[118]=Re):Re=e[118];let ke;e[119]!==s?(ke=s("Rows read"),e[119]=s,e[120]=ke):ke=e[120];let $e;e[121]!==ke?($e=t(Qe,{value:"rowsRead",children:ke}),e[121]=ke,e[122]=$e):$e=e[122];let Me;e[123]!==qe||e[124]!==_e||e[125]!==Re||e[126]!==$e?(Me=n(Qt,{children:[qe,_e,Re,$e]}),e[123]=qe,e[124]=_e,e[125]=Re,e[126]=$e,e[127]=Me):Me=e[127];let Ie;e[128]!==r||e[129]!==Se||e[130]!==Me?(Ie=n(Ht,{onValueChange:w,value:r,children:[Se,Me]}),e[128]=r,e[129]=Se,e[130]=Me,e[131]=Ie):Ie=e[131];let De;e[132]!==ve||e[133]!==Ie?(De=n("div",{className:"flex items-center gap-2",children:[ve,Ie]}),e[132]=ve,e[133]=Ie,e[134]=De):De=e[134],e[135]!==be||e[136]!==De?(b=n("div",{className:"flex items-center justify-between",children:[be,De]}),e[135]=be,e[136]=De,e[137]=b):b=e[137],d=he;let Ee;e[138]!==s?(Ee=s("Statements"),e[138]=s,e[139]=Ee):Ee=e[139];let ze;e[140]!==Ee?(ze=t(je,{children:Ee}),e[140]=Ee,e[141]=ze):ze=e[141],C=n(Be,{children:[ze,t(Mt,{children:s("{count} tracked statements",{count:$.length})})]}),h=ge,N="space-y-2";let Ke;e[142]!==i||e[143]!==s?(Ke=E=>{const ce=E.normalizedSql,H=i.has(ce),fe=Ve(E.avgDurationMs);return n("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[n("button",{"aria-expanded":H,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{k(ce)},type:"button",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t(ir,{level:fe}),t("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:E.normalizedSql})]}),n("div",{className:"flex shrink-0 items-center gap-4",children:[n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ae(E.totalDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("total")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ae(E.avgDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("avg")})]}),E.p95DurationMs!==void 0&&n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ae(E.p95DurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("p95")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:He(E.execCount)}),t("div",{className:"text-xs text-muted-foreground",children:s("calls")})]})]})]}),H&&n("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[n("div",{children:[t("p",{className:"mb-2 text-sm font-medium",children:s("Full statement")}),t("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:E.normalizedSql})]}),n("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[E.p50DurationMs!==void 0&&n("div",{children:[t("span",{className:"text-muted-foreground",children:s("p50")}),t("span",{className:"block font-medium tabular-nums",children:Ae(E.p50DurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Exec count")}),t("span",{className:"block font-medium tabular-nums",children:He(E.execCount)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Total time")}),t("span",{className:"block font-medium tabular-nums",children:Ae(E.totalDurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Rows read")}),t("span",{className:"block font-medium tabular-nums",children:He(E.rowsRead)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Rows written")}),t("span",{className:"block font-medium tabular-nums",children:He(E.rowsWritten)})]})]})]})]},ce)},e[142]=i,e[143]=s,e[144]=Ke):Ke=e[144],q=$.map(Ke)}e[2]=i,e[3]=a,e[4]=r,e[5]=s,e[6]=h,e[7]=d,e[8]=g,e[9]=N,e[10]=q,e[11]=C,e[12]=c,e[13]=x,e[14]=p,e[15]=b}else h=e[6],d=e[7],g=e[8],N=e[9],q=e[10],C=e[11],c=e[12],x=e[13],p=e[14],b=e[15];if(g!==Symbol.for("react.early_return_sentinel"))return g;let T;e[145]!==N||e[146]!==q?(T=t("div",{className:N,children:q}),e[145]=N,e[146]=q,e[147]=T):T=e[147];let R;e[148]!==h||e[149]!==T?(R=t(h,{children:T}),e[148]=h,e[149]=T,e[150]=R):R=e[150];let S;e[151]!==d||e[152]!==R||e[153]!==C?(S=n(d,{children:[C,R]}),e[151]=d,e[152]=R,e[153]=C,e[154]=S):S=e[154];let M;return e[155]!==S||e[156]!==c||e[157]!==x||e[158]!==p||e[159]!==b?(M=n("div",{className:c,"data-testid":x,children:[p,b,S]}),e[155]=S,e[156]=c,e[157]=x,e[158]=p,e[159]=b,e[160]=M):M=e[160],M};function or(l){return Ve(l.avgDurationMs)==="critical"}function cr(l){return Ve(l.avgDurationMs)==="warning"}function dr(l){return Ve(l.avgDurationMs)==="good"}const mr=["1m","5m","15m","1h"],ur=l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),fr=l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),hr=({shardKey:l=""})=>{const e=xe(),[a,s]=pe("15m"),u=Ue(Oe.getQueryInsights,{range:a},{live:!0,shardKey:l}).data,o=fr(u?.buckets??[]);return n("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:mr.map(i=>t("button",{"aria-pressed":i===a,className:Pt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===a&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:()=>{s(i)},type:"button",children:i},i))}),u?.capped===!0&&t(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),o.length===0?t(Kt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):n("div",{className:"grid gap-4 lg:grid-cols-2",children:[n("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),t(st,{height:140,width:"100%",children:n(At,{data:o,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(it,{dataKey:"label",fontSize:10,tickLine:!1}),t(at,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),t(nt,{}),t(Ot,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),n("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),t(st,{height:140,width:"100%",children:n(Lt,{data:o,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(it,{dataKey:"label",fontSize:10,tickLine:!1}),t(at,{fontSize:10,tickLine:!1,width:32}),t(nt,{}),t(zt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),t(nr,{queryStats:u?.entries??[]})]})},gr=Ct(Oe.getMetrics),pr=(l,e)=>l?e:"overview",jr=({initialShardKey:l})=>{const e=pt(),a=xe(),{queryShardKey:s,setShardKey:r,shardKey:u}=Nt(l),[o,i]=pe("overview"),[f,v]=pe([]),w=Ge(null),h=Ge(null),d=Ge(!0);tt(()=>(d.current=!0,()=>{d.current=!1}),[]);const g=vt(s),{data:N,error:q,liveError:C}=Ue(Oe.getMetrics,{},{live:!0,shardKey:s}),c=N??null;tt(()=>{if(N===void 0)return;Rt(s);const k=N,z=w.current,P=h.current!==null&&h.current!==k.shard;if(h.current=k.shard,w.current=k.requests,P){v([]);return}z!==null&&k.requests>=z&&v(L=>[...L,k.requests-z].slice(-30))},[N,s]);const[x,p]=pe(null),[b,T]=pe(!1),R=async()=>{T(!0);const k=Ft(u,kt());try{const z=await Promise.all(k.map(async P=>{try{const L=await e.query(gr,{},Tt(P));return{error:null,metrics:L,shard:P===""?L.shard:P}}catch(L){return{error:_t(L),metrics:null,shard:P===""?"__root__":P}}}));d.current&&p(z)}finally{d.current&&T(!1)}},S=x===null?null:It(x),M=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,$=f.length>0?f.at(-1):0,I=c?Dt(c):{p90:0,p95:0},_=xt(()=>{if(!c||!("queryStats"in c))return;const k=c.queryStats;if(!(!k||!Array.isArray(k)))return Et(k)},[c]),y=pr(_!==void 0,o),D=()=>{qt(R())},F=()=>{p(null)},A=()=>{i("overview")},O=()=>{i("query-insights")};return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(yt,{onChange:r,testId:"mt-shard-input",value:u}),t(bt,{message:C,prefix:"mt"}),t(rt,{"data-testid":"mt-aggregate",disabled:b,onClick:D,size:"sm",type:"button",variant:"secondary",children:a(b?"Aggregating…":"All shards")}),x!==null&&t(rt,{"data-testid":"mt-aggregate-clear",onClick:F,size:"sm",type:"button",variant:"ghost",children:a("Hide")}),t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:St,rel:"noreferrer",target:"_blank",children:a("Open in Cloudflare")})]}),q!==null&&t("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:q}),_!==void 0&&n("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[t("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:A,type:"button",children:a("Overview")}),n("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:O,type:"button",children:[a("Query insights"),_.length>0&&t("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:_.length})]})]}),y==="query-insights"&&_!==void 0&&t(hr,{shardKey:s}),y==="overview"&&c!==null&&t(lr,{currentDelta:$,errorRate:M,history:f,latencyPercentiles:I,metrics:c}),y==="overview"&&c===null&&null,y==="overview"&&t(er,{onOpenTrace:g,shardKey:s}),y==="overview"&&S!==null&&x!==null&&t(tr,{aggregate:S,shardResults:x})]})};export{jr as MetricsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as D}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-
|
|
1
|
+
import{c as D}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-ClpDVYvo.mjs";import{B as L}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as F}from"../packem_shared/button-q0UYSmrn.mjs";import{C as O,a as Q}from"../packem_shared/card--2hKx4L2.mjs";import{E as U}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as q}from"../packem_shared/input-CXhxesPC.mjs";import{T as G,a as J,b as H,c as h,d as X,e as u}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Y}from"../packem_shared/use-admin-query-BvZH4unR.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as _}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{i as ee}from"../packem_shared/internal-D4gBuklE.mjs";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",M=e=>e.endpoint??e.id,ge=()=>{const e=D(38),r=Z(),[a,P]=j("all"),[n,V]=j("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:T,error:i,errorSource:p,isLoading:v,refetch:g}=Y(_.listPushSubscriptions,b);let N;if(e[1]!==T?.subscriptions||e[2]!==i||e[3]!==p||e[4]!==v||e[5]!==a||e[6]!==g||e[7]!==n||e[8]!==r){const I=T?.subscriptions??[],$=n.trim().toLowerCase(),A=I.filter(s=>a!=="all"&&s.kind!==a?!1:$===""?!0:`${M(s)} ${s.userId??""}`.toLowerCase().includes($));let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=s=>{V(s.target.value)},e[10]=w):w=e[10];const z=w;let y;e[11]!==g?(y=()=>{g()},e[11]=g,e[12]=y):y=e[12];const B=y;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=["all","web-push","fcm"],e[13]=C):C=e[13];const W=C;let o;e[14]!==a||e[15]!==r?(o=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:W.map(s=>t(F,{"aria-selected":a===s,"data-testid":`nt-kind-${s}`,onClick:()=>{P(s)},role:"tab",size:"sm",type:"button",variant:a===s?"secondary":"ghost",children:s==="all"?r("All"):s},s))}),e[14]=a,e[15]=r,e[16]=o):o=e[16];let l;e[17]!==r?(l=r("Filter devices"),e[17]=r,e[18]=l):l=e[18];let d;e[19]!==r?(d=r("filter endpoint, user"),e[19]=r,e[20]=d):d=e[20];let c;e[21]!==n||e[22]!==l||e[23]!==d?(c=t(q,{"aria-label":l,className:"h-8 w-56","data-testid":"nt-search",onChange:z,placeholder:d,value:n}),e[21]=n,e[22]=l,e[23]=d,e[24]=c):c=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let f;e[27]!==B||e[28]!==m?(f=t(F,{className:"ml-auto","data-testid":"nt-refresh",onClick:B,size:"sm",type:"button",variant:"outline",children:m}),e[27]=B,e[28]=m,e[29]=f):f=e[29];const E=I.length>0&&t(L,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:I.length})});let k;e[30]!==f||e[31]!==E||e[32]!==o||e[33]!==c?(k=x("div",{className:"flex flex-wrap items-center gap-2",children:[o,c,f,E]}),e[30]=f,e[31]=E,e[32]=o,e[33]=c,e[34]=k):k=e[34];let S;e[35]!==i||e[36]!==p?(S=i!==null&&t(K,{error:p,testId:"nt-error"}),e[35]=i,e[36]=p,e[37]=S):S=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[k,S,i===null&&!v&&A.length===0&&t(U,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&t(O,{className:"overflow-hidden py-0",children:t(Q,{className:"max-h-[30rem] overflow-auto px-0",children:x(G,{"data-testid":"nt-table",children:[t(J,{children:x(H,{children:[t(h,{children:r("kind")}),t(h,{children:r("endpoint")}),t(h,{children:r("user")}),t(h,{children:r("last seen")}),t(h,{children:r("status")}),t(h,{children:r("error")})]})}),t(X,{children:A.map(s=>{const R=M(s);return x(H,{"data-testid":"nt-row",children:[t(u,{children:t(L,{variant:"outline",children:s.kind})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs",title:R,children:R}),t(u,{className:"max-w-[16ch] truncate font-mono text-xs",children:s.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(u,{className:"text-muted-foreground tabular-nums",children:ee(s.lastSeenAt,"—")}),t(u,{children:t(L,{"data-testid":`nt-status-${s.id}`,variant:te(s.lastStatus),children:s.lastStatus??r("n/a")})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:s.lastError??void 0,children:s.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},s.id)})})]})})})]}),e[1]=T?.subscriptions,e[2]=i,e[3]=p,e[4]=v,e[5]=a,e[6]=g,e[7]=n,e[8]=r,e[9]=N}else N=e[9];return N};export{ge as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as
|
|
1
|
+
import{useLunora as G}from"@lunora/react";import{useState as n,useCallback as Z,useEffect as H}from"react";import{ConfirmButton as B}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{B as J}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Q}from"../packem_shared/button-q0UYSmrn.mjs";import{I as _}from"../packem_shared/input-CXhxesPC.mjs";import{L as g}from"../packem_shared/label-DKFzyHq6.mjs";import{useAutoRefresh as V}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{useT as W}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as T}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{d as u,b as v,f as p,c as I}from"../packem_shared/internal-D4gBuklE.mjs";import{jsxs as o,jsx as r}from"react/jsx-runtime";const N=I(T.getPitrBookmark),X=I(T.pitrRestore),ce=({initialShardKey:O})=>{const c=G(),e=W(),a=O??"",[P,f]=n(null),[i,F]=n(""),[y,R]=n(null),[m,L]=n(""),[h,E]=n(!1),[s,S]=n(null),[w,l]=n(null),[x,d]=n(!1),k=Z(async()=>{d(!0),l(null);try{const t=await c.query(N,{},u(a));f(t.current)}catch(t){l(v(t))}d(!1)},[c,a]);H(()=>{p(k())},[k]),V(()=>{p((async()=>{try{const t=await c.query(N,{},u(a));f(t.current)}catch{}})())},!0);const A=t=>{F(t.target.value)},U=t=>{L(t.target.value)},q=t=>{E(t.target.checked)},K=()=>{i.trim()!==""&&p((async()=>{d(!0),l(null);try{const t=await c.query(N,{time:i.trim()},u(a));R(t.forTime??null),f(t.current)}catch(t){R(null),l(v(t))}d(!1)})())},C=t=>{p((async()=>{d(!0),l(null);try{const b=await c.mutation(X,t,u(a));S(b),await k()}catch(b){l(v(b))}d(!1)})())},M=m.trim()!==""||i.trim()!=="",j=e("Restore {shard} to {target}?",{shard:a===""?e("root"):a,target:m.trim()===""?i.trim():e("the given bookmark")}),z=()=>{const t=h?{restart:!0}:{};m.trim()===""?t.time=i.trim():t.bookmark=m.trim(),C(t)},D=()=>{s!==null&&C(h?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})};return o("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[r("div",{className:"flex flex-wrap items-center gap-3",children:o("span",{className:"text-xs text-muted-foreground",children:[e("Shard"),": ",r("span",{className:"font-mono",children:a===""?e("root"):a})]})}),r("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:e("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),w!==null&&r("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:w}),o("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[r("h3",{className:"mb-2 text-sm font-semibold",children:e("Current bookmark")}),r("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:P??r("span",{className:"text-muted-foreground",children:"—"})})]}),o("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[r("h3",{className:"text-sm font-semibold",children:e("Restore")}),o("div",{className:"flex flex-col gap-1",children:[r(g,{htmlFor:"pitr-time",children:e("Time (ISO or epoch-ms, last 30 days)")}),o("div",{className:"flex items-center gap-2",children:[r(_,{"data-testid":"pitr-time",id:"pitr-time",onChange:A,placeholder:"2026-06-01T00:00:00.000Z",value:i}),r(Q,{"data-testid":"pitr-preview",disabled:x||i.trim()==="",onClick:K,size:"sm",type:"button",variant:"outline",children:e("Preview")})]}),y!==null&&o("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[e("Bookmark for that time"),": ",y]})]}),o("div",{className:"flex flex-col gap-1",children:[r(g,{htmlFor:"pitr-bookmark",children:e("Or an explicit bookmark (wins over time)")}),r(_,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:U,placeholder:e("bookmark string"),value:m})]}),o(g,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[r("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:q,type:"checkbox"}),e("Restart the shard now so recovery applies immediately")]}),r("div",{children:r(B,{confirmLabel:j,disabled:x||!M,onConfirm:z,testId:"pitr-restore",children:e("Restore")})})]}),s!==null&&o("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[o("div",{className:"flex items-center gap-2",children:[r("h3",{className:"text-sm font-semibold",children:e("Restore armed")}),r(J,{variant:s.restarted?"destructive":"secondary",children:s.restarted?e("restarted now"):e("on next restart")})]}),o("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[e("Restored to"),": ",s.restoredTo]}),o("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[e("Undo bookmark"),": ",s.undoBookmark]}),r("div",{children:r(B,{confirmLabel:e("Confirm undo"),disabled:x,onConfirm:D,testId:"pitr-undo",children:e("Undo restore")})})]})]})};export{ce as PitrPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as Ne}from"react/compiler-runtime";import{ShardInput as We}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{S as Re,T as Pe}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{B as Fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{b as ze,d as qe,c as Be,a as De,C as je}from"../packem_shared/card--2hKx4L2.mjs";import{E as Qe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ke}from"../packem_shared/input-CXhxesPC.mjs";import{useT as Le}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as Oe,d as Ae,b as $e,f as be}from"../packem_shared/internal-CwaF9YNk.mjs";import{c as Je}from"../packem_shared/utils-bhneXptQ.mjs";import{useLunora as Ze}from"@lunora/react";import{useState as E,useEffect as Ge,useRef as et}from"react";import{u as tt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{ADMIN_FUNCTIONS as Me}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{r as lt}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{S as st}from"../packem_shared/schema-diagram-DU83ObYH.mjs";import{useNavigate as at}from"@tanstack/react-router";import{B as ge}from"../packem_shared/button-q0UYSmrn.mjs";import{L as _e}from"../packem_shared/label-DKFzyHq6.mjs";import{jsx as l,jsxs as p,Fragment as Ke}from"react/jsx-runtime";const nt=Oe(Me.listTables),ot=Oe(Me.listTableIndexes),it=Oe(Me.readTablePage),rt=Oe(Me.describeTables),dt={},Ue=[],ct=n=>{const e=Ne(74),{initialShardKey:m,initialTable:a}=n,t=Ze(),[s,c]=E("graph"),{queryShardKey:d,setShardKey:r,shardKey:b}=tt(m),[o,f]=E(""),[i,v]=E(null),[h,G]=E(null);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];const[B,y]=E(w);let z;e[1]===Symbol.for("react.memo_cache_sentinel")?(z={},e[1]=z):z=e[1];const[F,D]=E(z),[S,C]=E(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[L,me]=E(A);let W;e[3]===Symbol.for("react.memo_cache_sentinel")?(W={},e[3]=W):W=e[3];const[I,q]=E(W),[_,ue]=E(null),[j,ie]=E(null);let Q;e[4]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[4]=Q):Q=e[4];const[Y,xe]=E(Q),[H,re]=E(null);let ve;e[5]!==t?(ve=async u=>{G(null);try{const N=await t.query(nt,{},Ae(u));lt(u),v(N),y({}),D({}),C(null),me(x=>Object.fromEntries(Object.entries(x).filter(P=>{const[k]=P;return k!==u}))),q(x=>Object.fromEntries(Object.entries(x).filter(P=>{const[k]=P;return k!==u})))}catch(N){const x=N;v(null),G($e(x))}},e[5]=t,e[6]=ve):ve=e[6];const O=ve;let Z;e[7]!==t?(Z=async()=>{ie(null);try{ue(await t.listGlobalTables())}catch(u){const N=u;ue(null),ie($e(N))}},e[7]=t,e[8]=Z):Z=e[8];const ee=Z;let de,R;e[9]!==d||e[10]!==O||e[11]!==ee?(de=()=>{be(O(d)),be(ee())},R=[O,ee,d],e[9]=d,e[10]=O,e[11]=ee,e[12]=de,e[13]=R):(de=e[12],R=e[13]),Ge(de,R);let te;e[14]!==t||e[15]!==B||e[16]!==S||e[17]!==d?(te=async u=>{if(S===u){C(null);return}C(u);const N=`${d}:${u}`;if(B[N]!==void 0)return;const[x,P]=await Promise.allSettled([t.query(it,{limit:1,offset:0,table:u},Ae(d)),t.query(ot,{table:u},Ae(d))]);x.status==="fulfilled"?y(k=>({...k,[N]:x.value.columns})):G($e(x.reason)),P.status==="fulfilled"&&D(k=>({...k,[N]:P.value.indexes}))},e[14]=t,e[15]=B,e[16]=S,e[17]=d,e[18]=te):te=e[18];const M=te;let ye;e[19]!==t||e[20]!==Y||e[21]!==H?(ye=async u=>{if(H===u){re(null);return}if(re(u),Y[u]===void 0)try{const N=await t.readGlobalTablePage({limit:1,offset:0,table:u});xe(x=>({...x,[u]:N.columns}))}catch(N){ie($e(N))}},e[19]=t,e[20]=Y,e[21]=H,e[22]=ye):ye=e[22];const ce=ye,fe=et(void 0);let K,X;e[23]!==a||e[24]!==i||e[25]!==M?(K=()=>{a===void 0||i===null||fe.current===a||i.some(u=>u.name===a)&&(fe.current=a,be(M(a)))},X=[a,i,M],e[23]=a,e[24]=i,e[25]=M,e[26]=K,e[27]=X):(K=e[26],X=e[27]),Ge(K,X);let U;e[28]!==t?(U=async(u,N,x)=>{const[P,k]=await Promise.all([Promise.allSettled([t.query(rt,{tables:[...N,...x]},Ae(u))]),Promise.all(x.map(async T=>{const pe=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=pe[0].status==="fulfilled"?pe[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=P[0].status==="fulfilled"?P[0].value?.columnsByTable??{}:{},Se=P[0].status==="rejected",we=new Map(k.map(mt)),Ee=[...N,...x].map(T=>{const pe=Te[T]??[];return[T,pe.length>0?pe:we.get(T)??[]]});me(T=>({...T,[u]:Object.fromEntries(Ee)})),q(T=>({...T,[u]:Se}))},e[28]=t,e[29]=U):U=e[29];const le=U;let V,se;e[30]!==j||e[31]!==_||e[32]!==le||e[33]!==d||e[34]!==L||e[35]!==i||e[36]!==s?(V=()=>{s!=="graph"||i===null||_===null&&j===null||L[d]!==void 0||be(le(d,i.map(ut),(_??[]).map(ft)))},se=[s,i,_,j,d,L,le],e[30]=j,e[31]=_,e[32]=le,e[33]=d,e[34]=L,e[35]=i,e[36]=s,e[37]=V,e[38]=se):(V=e[37],se=e[38]),Ge(V,se);const $=L[d]??dt;let ae;if(e[39]!==$||e[40]!==_||e[41]!==i){let u;e[43]!==$?(u=k=>({columns:$[k.name]??Ue,name:k.name,tier:"shard"}),e[43]=$,e[44]=u):u=e[44];const N=(i??[]).map(u);let x;e[45]!==$?(x=k=>({columns:$[k.name]??Ue,name:k.name,tier:"global"}),e[45]=$,e[46]=x):x=e[46];const P=(_??[]).map(x);ae=[...N,...P],e[39]=$,e[40]=_,e[41]=i,e[42]=ae}else ae=e[42];const ne=ae;let g;if(e[47]!==o||e[48]!==i){const u=o.trim().toLowerCase();g=(i??[]).filter(N=>N.name.toLowerCase().includes(u)),e[47]=o,e[48]=i,e[49]=g}else g=e[49];const oe=g;let J;if(e[50]!==_||e[51]!==o){const u=o.trim().toLowerCase();J=(_??[]).filter(N=>N.name.toLowerCase().includes(u)),e[50]=_,e[51]=o,e[52]=J}else J=e[52];const Ce=J;let he;return e[53]!==B||e[54]!==ne||e[55]!==h||e[56]!==S||e[57]!==Ce||e[58]!==oe||e[59]!==Y||e[60]!==j||e[61]!==H||e[62]!==_||e[63]!==F||e[64]!==O||e[65]!==r||e[66]!==I||e[67]!==b||e[68]!==o||e[69]!==i||e[70]!==M||e[71]!==ce||e[72]!==s?(he={columns:B,diagramTables:ne,error:h,expanded:S,filteredGlobalTables:Ce,filteredTables:oe,globalColumns:Y,globalError:j,globalExpanded:H,globalTables:_,indexes:F,refresh:O,setShardKey:r,setTableFilter:f,setView:c,shardColumnsError:I,shardKey:b,tableFilter:o,tables:i,toggle:M,toggleGlobal:ce,view:s},e[53]=B,e[54]=ne,e[55]=h,e[56]=S,e[57]=Ce,e[58]=oe,e[59]=Y,e[60]=j,e[61]=H,e[62]=_,e[63]=F,e[64]=O,e[65]=r,e[66]=I,e[67]=b,e[68]=o,e[69]=i,e[70]=M,e[71]=ce,e[72]=s,e[73]=he):he=e[73],he};function mt(n){const{columns:e,refs:m,table:a}=n;return[a,e.map(t=>{const s=m[t];return s===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:s,type:"id"}})]}function ut(n){return n.name}function ft(n){return n.name}const ht="/__lunora/schema-edit",pt=async n=>{const e=await fetch(ht,{body:JSON.stringify(n),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},gt=n=>{const e=Ne(32),{hasTables:m,mode:a,onAddColumn:t,onAddIndex:s,onAddTable:c,onDestructive:d}=n,r=Le(),b=a==="addTable"?"default":"outline";let o;e[0]!==r?(o=r("Add table"),e[0]=r,e[1]=o):o=e[1];let f;e[2]!==c||e[3]!==b||e[4]!==o?(f=l(ge,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:b,children:o}),e[2]=c,e[3]=b,e[4]=o,e[5]=f):f=e[5];const i=!m,v=a==="addColumn"?"default":"outline";let h;e[6]!==r?(h=r("Add column"),e[6]=r,e[7]=h):h=e[7];let G;e[8]!==t||e[9]!==i||e[10]!==v||e[11]!==h?(G=l(ge,{"data-testid":"sc-editor-add-column",disabled:i,onClick:t,size:"xs",type:"button",variant:v,children:h}),e[8]=t,e[9]=i,e[10]=v,e[11]=h,e[12]=G):G=e[12];const w=!m,B=a==="addIndex"?"default":"outline";let y;e[13]!==r?(y=r("Add index"),e[13]=r,e[14]=y):y=e[14];let z;e[15]!==s||e[16]!==y||e[17]!==w||e[18]!==B?(z=l(ge,{"data-testid":"sc-editor-add-index",disabled:w,onClick:s,size:"xs",type:"button",variant:B,children:y}),e[15]=s,e[16]=y,e[17]=w,e[18]=B,e[19]=z):z=e[19];const F=!m,D=a==="destructive"?"default":"ghost";let S;e[20]!==r?(S=r("Rename / drop / change type…"),e[20]=r,e[21]=S):S=e[21];let C;e[22]!==d||e[23]!==F||e[24]!==D||e[25]!==S?(C=l(ge,{"data-testid":"sc-editor-destructive",disabled:F,onClick:d,size:"xs",type:"button",variant:D,children:S}),e[22]=d,e[23]=F,e[24]=D,e[25]=S,e[26]=C):C=e[26];let A;return e[27]!==z||e[28]!==C||e[29]!==f||e[30]!==G?(A=p("div",{className:"flex flex-wrap gap-2",children:[f,G,z,C]}),e[27]=z,e[28]=C,e[29]=f,e[30]=G,e[31]=A):A=e[31],A},bt=n=>{const e=Ne(28),{onOpenMigrations:m,result:a}=n,t=Le();if(a===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ke,{}),e[0]=o):o=e[0],o}if(a.kind==="error"){let o;return e[1]!==a.message?(o=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:a.message}),e[1]=a.message,e[2]=o):o=e[2],o}if(a.kind==="needs-migration"){let o;e[3]!==a.message||e[4]!==t?(o=a.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):a.message,e[3]=a.message,e[4]=t,e[5]=o):o=e[5];let f;e[6]!==o?(f=l("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=f):f=e[7];let i;e[8]!==t?(i=t("Open Migrations"),e[8]=t,e[9]=i):i=e[9];let v;e[10]!==m||e[11]!==i?(v=l(ge,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:i}),e[10]=m,e[11]=i,e[12]=v):v=e[12];let h;return e[13]!==f||e[14]!==v?(h=p("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[f,v]}),e[13]=f,e[14]=v,e[15]=h):h=e[15],h}if(a.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ke,{}),e[16]=o):o=e[16],o}let s;e[17]!==t?(s=t("Codegen reported diagnostics:"),e[17]=t,e[18]=s):s=e[18];let c;e[19]!==s?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:s}),e[19]=s,e[20]=c):c=e[20];let d;e[21]!==a.diagnostics?(d=a.diagnostics.map(xt),e[21]=a.diagnostics,e[22]=d):d=e[22];let r;e[23]!==d?(r=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=r):r=e[24];let b;return e[25]!==c||e[26]!==r?(b=p("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,r]}),e[25]=c,e[26]=r,e[27]=b):b=e[27],b};function xt(n){return l("li",{className:"font-mono text-[11px] text-destructive",children:n},n)}const vt=[{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()"}],yt="v.string()",Ct=n=>n.split(",").map(e=>e.trim()).filter(e=>e!==""),Nt=n=>{const e=Ne(83),{onApplied:m,tableNames:a}=n,t=Le(),s=at(),[c,d]=E(null),[r,b]=E(!1),[o,f]=E(null),[i,v]=E(""),[h,G]=E(""),[w,B]=E(yt),[y,z]=E(a[0]??""),[F,D]=E(""),[S,C]=E(""),[A,L]=E(!1);let me;e[0]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{d(null),v(""),G(""),D(""),C(""),L(!1)},e[0]=me):me=e[0];const W=me;let I;e[1]!==m?(I=async T=>{b(!0),f(null);try{const pe=await pt(T);f(pe),pe.kind==="ok"&&(m(pe.tables),W())}catch(pe){const Ie=pe;f({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}b(!1)},e[1]=m,e[2]=I):I=e[2];const q=I;let _;e[3]!==q||e[4]!==i?(_=()=>{be(q({kind:"addTable",table:i.trim()}))},e[3]=q,e[4]=i,e[5]=_):_=e[5];const ue=_;let j;e[6]!==h||e[7]!==q||e[8]!==y||e[9]!==w?(j=()=>{be(q({column:h.trim(),kind:"addOptionalColumn",table:y,validator:w}))},e[6]=h,e[7]=q,e[8]=y,e[9]=w,e[10]=j):j=e[10];const ie=j;let Q;e[11]!==S||e[12]!==F||e[13]!==q||e[14]!==y||e[15]!==A?(Q=()=>{be(q({fields:Ct(S),kind:"addIndex",name:F.trim(),table:y,unique:A}))},e[11]=S,e[12]=F,e[13]=q,e[14]=y,e[15]=A,e[16]=Q):Q=e[16];const Y=Q;let xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>{f(null),d("addTable")},e[17]=xe):xe=e[17];const H=xe;let re;e[18]===Symbol.for("react.memo_cache_sentinel")?(re=()=>{f(null),d("addColumn")},e[18]=re):re=e[18];const ve=re;let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=()=>{f(null),d("addIndex")},e[19]=O):O=e[19];const Z=O;let ee;e[20]!==t?(ee=()=>{d("destructive"),f({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=ee):ee=e[21];const de=ee;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=T=>{v(T.target.value)},e[22]=R):R=e[22];const te=R;let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=T=>{G(T.target.value)},e[23]=M):M=e[23];const ye=M;let ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=T=>{B(T.target.value)},e[24]=ce):ce=e[24];const fe=ce;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=T=>{z(T.target.value)},e[25]=K):K=e[25];const X=K;let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=T=>{D(T.target.value)},e[26]=U):U=e[26];const le=U;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V=T=>{C(T.target.value)},e[27]=V):V=e[27];const se=V;let $;e[28]===Symbol.for("react.memo_cache_sentinel")?($=T=>{L(T.target.checked)},e[28]=$):$=e[28];const ae=$;let ne;e[29]!==s?(ne=()=>{be(s({to:"/migrations"}))},e[29]=s,e[30]=ne):ne=e[30];const g=ne;let oe;e[31]!==t?(oe=t("Edit schema"),e[31]=t,e[32]=oe):oe=e[32];let J;e[33]!==oe?(J=l(ze,{children:oe}),e[33]=oe,e[34]=J):J=e[34];let Ce;e[35]!==t?(Ce=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=Ce):Ce=e[36];let he;e[37]!==Ce?(he=l(qe,{children:Ce}),e[37]=Ce,e[38]=he):he=e[38];let u;e[39]!==J||e[40]!==he?(u=p(Be,{children:[J,he]}),e[39]=J,e[40]=he,e[41]=u):u=e[41];const N=a.length>0;let x;e[42]!==c||e[43]!==de||e[44]!==N?(x=l(gt,{hasTables:N,mode:c,onAddColumn:ve,onAddIndex:Z,onAddTable:H,onDestructive:de}),e[42]=c,e[43]=de,e[44]=N,e[45]=x):x=e[45];let P;e[46]!==r||e[47]!==c||e[48]!==ue||e[49]!==t||e[50]!==i?(P=c==="addTable"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(ke,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),l(ge,{"data-testid":"sc-editor-table-apply",disabled:r||i.trim()==="",onClick:ue,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ge,{onClick:W,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=r,e[47]=c,e[48]=ue,e[49]=t,e[50]=i,e[51]=P):P=e[51];let k;e[52]!==r||e[53]!==h||e[54]!==c||e[55]!==ie||e[56]!==t||e[57]!==a||e[58]!==y||e[59]!==w?(k=c==="addColumn"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("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:a.map(Tt)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(ke,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:h})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("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:fe,value:w,children:vt.map(St)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(ge,{"data-testid":"sc-editor-column-apply",disabled:r||h.trim()===""||y==="",onClick:ie,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ge,{onClick:W,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=r,e[53]=h,e[54]=c,e[55]=ie,e[56]=t,e[57]=a,e[58]=y,e[59]=w,e[60]=k):k=e[60];let Te;e[61]!==r||e[62]!==S||e[63]!==F||e[64]!==c||e[65]!==Y||e[66]!==t||e[67]!==a||e[68]!==y||e[69]!==A?(Te=c==="addIndex"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("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:a.map(wt)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(ke,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:F})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(ke,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:se,value:S})]}),p(_e,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ae,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(ge,{"data-testid":"sc-editor-index-apply",disabled:r||F.trim()===""||S.trim()==="",onClick:Y,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ge,{onClick:W,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=r,e[62]=S,e[63]=F,e[64]=c,e[65]=Y,e[66]=t,e[67]=a,e[68]=y,e[69]=A,e[70]=Te):Te=e[70];let Se;e[71]!==g||e[72]!==o?(Se=l(bt,{onOpenMigrations:g,result:o}),e[71]=g,e[72]=o,e[73]=Se):Se=e[73];let we;e[74]!==x||e[75]!==P||e[76]!==k||e[77]!==Te||e[78]!==Se?(we=p(De,{children:[x,P,k,Te,Se]}),e[74]=x,e[75]=P,e[76]=k,e[77]=Te,e[78]=Se,e[79]=we):we=e[79];let Ee;return e[80]!==u||e[81]!==we?(Ee=p(je,{"data-testid":"sc-editor",size:"sm",children:[u,we]}),e[80]=u,e[81]=we,e[82]=Ee):Ee=e[82],Ee};function Tt(n){return l("option",{value:n,children:n},n)}function St(n){return l("option",{value:n.validator,children:n.label},n.validator)}function wt(n){return l("option",{value:n,children:n},n)}const Ve=[],_t=n=>{const e=Ne(5),{open:m}=n,a=m&&"rotate-90";let t;e[0]!==a?(t=Je("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",a),e[0]=a,e[1]=t):t=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=l("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=t,e[4]=c):c=e[4],c},Ye=n=>{const e=Ne(20),{children:m,expanded:a,name:t,onToggle:s,rowCount:c,rowTestId:d,toggleTestId:r}=n;let b;e[0]!==a?(b=l(_t,{open:a}),e[0]=a,e[1]=b):b=e[1];let o;e[2]!==t?(o=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=o):o=e[3];let f;e[4]!==c?(f=p("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=f):f=e[5];let i;e[6]!==a||e[7]!==s||e[8]!==b||e[9]!==o||e[10]!==f||e[11]!==r?(i=p("button",{"aria-expanded":a,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":r,onClick:s,type:"button",children:[b,o," ",f]}),e[6]=a,e[7]=s,e[8]=b,e[9]=o,e[10]=f,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==m||e[14]!==a?(v=a&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=a,e[15]=v):v=e[15];let h;return e[16]!==d||e[17]!==i||e[18]!==v?(h=p("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[i,v]}),e[16]=d,e[17]=i,e[18]=v,e[19]=h):h=e[19],h},He=n=>{const e=Ne(5),{columns:m,testId:a}=n;let t;e[0]!==m?(t=m.map(It),e[0]=m,e[1]=t):t=e[1];let s;return e[2]!==t||e[3]!==a?(s=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":a,children:t}),e[2]=t,e[3]=a,e[4]=s):s=e[4],s},Et=n=>{const e=Ne(10),{heading:m,indexes:a,testId:t}=n;let s;e[0]!==m?(s=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=s):s=e[1];let c;e[2]!==a?(c=a.map(kt),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let r;return e[7]!==s||e[8]!==d?(r=p("div",{className:"pt-3",children:[s,d]}),e[7]=s,e[8]=d,e[9]=r):r=e[9],r},Xe=n=>Je("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",n?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Wt=n=>{const e=Ne(85),{initialShardKey:m,initialTable:a,schemaEditable:t}=n,s=Le();let c;e[0]!==m||e[1]!==a?(c={initialShardKey:m,initialTable:a},e[0]=m,e[1]=a,e[2]=c):c=e[2];const{columns:d,diagramTables:r,error:b,expanded:o,filteredGlobalTables:f,filteredTables:i,globalColumns:v,globalError:h,globalExpanded:G,globalTables:w,indexes:B,refresh:y,setShardKey:z,setTableFilter:F,setView:D,shardColumnsError:S,shardKey:C,tableFilter:A,tables:L,toggle:me,toggleGlobal:W,view:I}=ct(c);let q;e[3]!==D?(q=()=>{D("list")},e[3]=D,e[4]=q):q=e[4];const _=q;let ue;e[5]!==D?(ue=()=>{D("graph")},e[5]=D,e[6]=ue):ue=e[6];const j=ue;let ie;e[7]!==F?(ie=g=>{F(g.target.value)},e[7]=F,e[8]=ie):ie=e[8];const Q=ie;let Y;e[9]!==y||e[10]!==C?(Y=g=>{be(y(C))},e[9]=y,e[10]=C,e[11]=Y):Y=e[11];const xe=Y;let H;e[12]!==L?(H=L??[],e[12]=L,e[13]=H):H=e[13];let re;e[14]!==H?(re=H.map(At),e[14]=H,e[15]=re):re=e[15];const ve=re;let O;e[16]!==z||e[17]!==C?(O=l(We,{onChange:z,testId:"sc-shard-input",value:C}),e[16]=z,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==s?(Z=s("Schema view"),e[19]=s,e[20]=Z):Z=e[20];const ee=I==="graph",de=I==="graph";let R;e[21]!==de?(R=Xe(de),e[21]=de,e[22]=R):R=e[22];let te;e[23]!==s?(te=s("Graph"),e[23]=s,e[24]=te):te=e[24];let M;e[25]!==j||e[26]!==ee||e[27]!==R||e[28]!==te?(M=l("button",{"aria-selected":ee,className:R,"data-testid":"sc-view-graph",onClick:j,role:"tab",type:"button",children:te}),e[25]=j,e[26]=ee,e[27]=R,e[28]=te,e[29]=M):M=e[29];const ye=I==="list",ce=I==="list";let fe;e[30]!==ce?(fe=Xe(ce),e[30]=ce,e[31]=fe):fe=e[31];let K;e[32]!==s?(K=s("Table list"),e[32]=s,e[33]=K):K=e[33];let X;e[34]!==_||e[35]!==ye||e[36]!==fe||e[37]!==K?(X=l("button",{"aria-selected":ye,className:fe,"data-testid":"sc-view-list",onClick:_,role:"tab",type:"button",children:K}),e[34]=_,e[35]=ye,e[36]=fe,e[37]=K,e[38]=X):X=e[38];let U;e[39]!==M||e[40]!==X||e[41]!==Z?(U=p("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[M,X]}),e[39]=M,e[40]=X,e[41]=Z,e[42]=U):U=e[42];let le;e[43]!==U||e[44]!==O?(le=p("div",{className:"flex flex-wrap items-center gap-3",children:[O,U]}),e[43]=U,e[44]=O,e[45]=le):le=e[45];let V;e[46]!==xe||e[47]!==t||e[48]!==ve?(V=t===!0&&l(Nt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=t,e[48]=ve,e[49]=V):V=e[49];let se;e[50]!==Q||e[51]!==s||e[52]!==A||e[53]!==I?(se=I==="list"&&l(ke,{"aria-label":s("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Q,placeholder:s("Filter tables"),value:A}),e[50]=Q,e[51]=s,e[52]=A,e[53]=I,e[54]=se):se=e[54];let $;e[55]!==r||e[56]!==b||e[57]!==h||e[58]!==S||e[59]!==C||e[60]!==I?($=I==="graph"&&p("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[b!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),h!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:h}),l(st,{columnsError:S[C]===!0,tables:r,testIdPrefix:"sc-graph"})]}),e[55]=r,e[56]=b,e[57]=h,e[58]=S,e[59]=C,e[60]=I,e[61]=$):$=e[61];let ae;e[62]!==d||e[63]!==b||e[64]!==o||e[65]!==f||e[66]!==i||e[67]!==v||e[68]!==h||e[69]!==G||e[70]!==w||e[71]!==B||e[72]!==C||e[73]!==s||e[74]!==L||e[75]!==me||e[76]!==W||e[77]!==I?(ae=I==="list"&&p("div",{className:"flex flex-col gap-4",children:[p(je,{"data-testid":"sc-shard-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Re,{tier:"shard"}),l(ze,{children:s("Shard tables")}),L!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),l(qe,{children:Pe.shard.hint})]}),p(De,{children:[b!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),L!==null&&L.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:s("No tables in this shard.")}),L!==null&&L.length>0&&i.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:s("No tables match your filter.")}),i.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(g=>{const oe=`${C}:${g.name}`,J=B[oe]??[];return p(Ye,{expanded:o===g.name,name:g.name,onToggle:()=>{be(me(g.name))},rowCount:g.rowCount,rowTestId:`sc-table-${g.name}`,toggleTestId:`sc-toggle-${g.name}`,children:[l(He,{columns:d[oe]??Ve,testId:`sc-columns-${g.name}`}),J.length>0&&l(Et,{heading:s("Indexes"),indexes:J,testId:`sc-indexes-${g.name}`})]},g.name)})})]})]}),p(je,{"data-testid":"sc-global-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Re,{tier:"global"}),l(ze,{children:s("Global tables (D1)")}),w!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:f.length})]}),l(qe,{children:Pe.global.hint})]}),p(De,{children:[h!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:h}),w!==null&&w.length===0&&l(Qe,{description:Pe.global.hint,testId:"sc-global-empty",title:s("No global tables.")}),w!==null&&w.length>0&&f.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:s("No tables match your filter.")}),f.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:f.map(g=>l(Ye,{expanded:G===g.name,name:g.name,onToggle:()=>{be(W(g.name))},rowCount:g.rowCount,rowTestId:`sc-global-table-${g.name}`,toggleTestId:`sc-global-toggle-${g.name}`,children:l(He,{columns:v[g.name]??Ve,testId:`sc-global-columns-${g.name}`})},g.name))})]})]})]}),e[62]=d,e[63]=b,e[64]=o,e[65]=f,e[66]=i,e[67]=v,e[68]=h,e[69]=G,e[70]=w,e[71]=B,e[72]=C,e[73]=s,e[74]=L,e[75]=me,e[76]=W,e[77]=I,e[78]=ae):ae=e[78];let ne;return e[79]!==le||e[80]!==V||e[81]!==se||e[82]!==$||e[83]!==ae?(ne=p("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,V,se,$,ae]}),e[79]=le,e[80]=V,e[81]=se,e[82]=$,e[83]=ae,e[84]=ne):ne=e[84],ne};function It(n){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:n},n)}function kt(n){return p("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:n.name}),l(Fe,{variant:"outline",children:n.type}),n.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:n.fields.join(", ")})]},`${n.type}:${n.name}`)}function At(n){return n.name}export{Wt as SchemaViewer};
|
|
1
|
+
import{c as Ne}from"react/compiler-runtime";import{ShardInput as We}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{S as Re,T as Pe}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{B as Fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{b as ze,d as qe,c as Be,a as De,C as je}from"../packem_shared/card--2hKx4L2.mjs";import{E as Qe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ke}from"../packem_shared/input-CXhxesPC.mjs";import{useT as Le}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as Oe,d as Ae,b as $e,f as be}from"../packem_shared/internal-D4gBuklE.mjs";import{c as Je}from"../packem_shared/utils-bhneXptQ.mjs";import{useLunora as Ze}from"@lunora/react";import{useState as E,useEffect as Ge,useRef as et}from"react";import{u as tt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{ADMIN_FUNCTIONS as Me}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{r as lt}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{S as st}from"../packem_shared/schema-diagram-C27ETi10.mjs";import{useNavigate as at}from"@tanstack/react-router";import{B as ge}from"../packem_shared/button-q0UYSmrn.mjs";import{L as _e}from"../packem_shared/label-DKFzyHq6.mjs";import{jsx as l,jsxs as p,Fragment as Ke}from"react/jsx-runtime";const nt=Oe(Me.listTables),ot=Oe(Me.listTableIndexes),it=Oe(Me.readTablePage),rt=Oe(Me.describeTables),dt={},Ue=[],ct=n=>{const e=Ne(74),{initialShardKey:m,initialTable:a}=n,t=Ze(),[s,c]=E("graph"),{queryShardKey:d,setShardKey:r,shardKey:b}=tt(m),[o,f]=E(""),[i,v]=E(null),[h,G]=E(null);let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];const[B,y]=E(w);let z;e[1]===Symbol.for("react.memo_cache_sentinel")?(z={},e[1]=z):z=e[1];const[F,D]=E(z),[S,C]=E(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[L,me]=E(A);let W;e[3]===Symbol.for("react.memo_cache_sentinel")?(W={},e[3]=W):W=e[3];const[I,q]=E(W),[_,ue]=E(null),[j,ie]=E(null);let Q;e[4]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[4]=Q):Q=e[4];const[Y,xe]=E(Q),[H,re]=E(null);let ve;e[5]!==t?(ve=async u=>{G(null);try{const N=await t.query(nt,{},Ae(u));lt(u),v(N),y({}),D({}),C(null),me(x=>Object.fromEntries(Object.entries(x).filter(P=>{const[k]=P;return k!==u}))),q(x=>Object.fromEntries(Object.entries(x).filter(P=>{const[k]=P;return k!==u})))}catch(N){const x=N;v(null),G($e(x))}},e[5]=t,e[6]=ve):ve=e[6];const O=ve;let Z;e[7]!==t?(Z=async()=>{ie(null);try{ue(await t.listGlobalTables())}catch(u){const N=u;ue(null),ie($e(N))}},e[7]=t,e[8]=Z):Z=e[8];const ee=Z;let de,R;e[9]!==d||e[10]!==O||e[11]!==ee?(de=()=>{be(O(d)),be(ee())},R=[O,ee,d],e[9]=d,e[10]=O,e[11]=ee,e[12]=de,e[13]=R):(de=e[12],R=e[13]),Ge(de,R);let te;e[14]!==t||e[15]!==B||e[16]!==S||e[17]!==d?(te=async u=>{if(S===u){C(null);return}C(u);const N=`${d}:${u}`;if(B[N]!==void 0)return;const[x,P]=await Promise.allSettled([t.query(it,{limit:1,offset:0,table:u},Ae(d)),t.query(ot,{table:u},Ae(d))]);x.status==="fulfilled"?y(k=>({...k,[N]:x.value.columns})):G($e(x.reason)),P.status==="fulfilled"&&D(k=>({...k,[N]:P.value.indexes}))},e[14]=t,e[15]=B,e[16]=S,e[17]=d,e[18]=te):te=e[18];const M=te;let ye;e[19]!==t||e[20]!==Y||e[21]!==H?(ye=async u=>{if(H===u){re(null);return}if(re(u),Y[u]===void 0)try{const N=await t.readGlobalTablePage({limit:1,offset:0,table:u});xe(x=>({...x,[u]:N.columns}))}catch(N){ie($e(N))}},e[19]=t,e[20]=Y,e[21]=H,e[22]=ye):ye=e[22];const ce=ye,fe=et(void 0);let K,X;e[23]!==a||e[24]!==i||e[25]!==M?(K=()=>{a===void 0||i===null||fe.current===a||i.some(u=>u.name===a)&&(fe.current=a,be(M(a)))},X=[a,i,M],e[23]=a,e[24]=i,e[25]=M,e[26]=K,e[27]=X):(K=e[26],X=e[27]),Ge(K,X);let U;e[28]!==t?(U=async(u,N,x)=>{const[P,k]=await Promise.all([Promise.allSettled([t.query(rt,{tables:[...N,...x]},Ae(u))]),Promise.all(x.map(async T=>{const pe=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=pe[0].status==="fulfilled"?pe[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=P[0].status==="fulfilled"?P[0].value?.columnsByTable??{}:{},Se=P[0].status==="rejected",we=new Map(k.map(mt)),Ee=[...N,...x].map(T=>{const pe=Te[T]??[];return[T,pe.length>0?pe:we.get(T)??[]]});me(T=>({...T,[u]:Object.fromEntries(Ee)})),q(T=>({...T,[u]:Se}))},e[28]=t,e[29]=U):U=e[29];const le=U;let V,se;e[30]!==j||e[31]!==_||e[32]!==le||e[33]!==d||e[34]!==L||e[35]!==i||e[36]!==s?(V=()=>{s!=="graph"||i===null||_===null&&j===null||L[d]!==void 0||be(le(d,i.map(ut),(_??[]).map(ft)))},se=[s,i,_,j,d,L,le],e[30]=j,e[31]=_,e[32]=le,e[33]=d,e[34]=L,e[35]=i,e[36]=s,e[37]=V,e[38]=se):(V=e[37],se=e[38]),Ge(V,se);const $=L[d]??dt;let ae;if(e[39]!==$||e[40]!==_||e[41]!==i){let u;e[43]!==$?(u=k=>({columns:$[k.name]??Ue,name:k.name,tier:"shard"}),e[43]=$,e[44]=u):u=e[44];const N=(i??[]).map(u);let x;e[45]!==$?(x=k=>({columns:$[k.name]??Ue,name:k.name,tier:"global"}),e[45]=$,e[46]=x):x=e[46];const P=(_??[]).map(x);ae=[...N,...P],e[39]=$,e[40]=_,e[41]=i,e[42]=ae}else ae=e[42];const ne=ae;let g;if(e[47]!==o||e[48]!==i){const u=o.trim().toLowerCase();g=(i??[]).filter(N=>N.name.toLowerCase().includes(u)),e[47]=o,e[48]=i,e[49]=g}else g=e[49];const oe=g;let J;if(e[50]!==_||e[51]!==o){const u=o.trim().toLowerCase();J=(_??[]).filter(N=>N.name.toLowerCase().includes(u)),e[50]=_,e[51]=o,e[52]=J}else J=e[52];const Ce=J;let he;return e[53]!==B||e[54]!==ne||e[55]!==h||e[56]!==S||e[57]!==Ce||e[58]!==oe||e[59]!==Y||e[60]!==j||e[61]!==H||e[62]!==_||e[63]!==F||e[64]!==O||e[65]!==r||e[66]!==I||e[67]!==b||e[68]!==o||e[69]!==i||e[70]!==M||e[71]!==ce||e[72]!==s?(he={columns:B,diagramTables:ne,error:h,expanded:S,filteredGlobalTables:Ce,filteredTables:oe,globalColumns:Y,globalError:j,globalExpanded:H,globalTables:_,indexes:F,refresh:O,setShardKey:r,setTableFilter:f,setView:c,shardColumnsError:I,shardKey:b,tableFilter:o,tables:i,toggle:M,toggleGlobal:ce,view:s},e[53]=B,e[54]=ne,e[55]=h,e[56]=S,e[57]=Ce,e[58]=oe,e[59]=Y,e[60]=j,e[61]=H,e[62]=_,e[63]=F,e[64]=O,e[65]=r,e[66]=I,e[67]=b,e[68]=o,e[69]=i,e[70]=M,e[71]=ce,e[72]=s,e[73]=he):he=e[73],he};function mt(n){const{columns:e,refs:m,table:a}=n;return[a,e.map(t=>{const s=m[t];return s===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:s,type:"id"}})]}function ut(n){return n.name}function ft(n){return n.name}const ht="/__lunora/schema-edit",pt=async n=>{const e=await fetch(ht,{body:JSON.stringify(n),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},gt=n=>{const e=Ne(32),{hasTables:m,mode:a,onAddColumn:t,onAddIndex:s,onAddTable:c,onDestructive:d}=n,r=Le(),b=a==="addTable"?"default":"outline";let o;e[0]!==r?(o=r("Add table"),e[0]=r,e[1]=o):o=e[1];let f;e[2]!==c||e[3]!==b||e[4]!==o?(f=l(ge,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:b,children:o}),e[2]=c,e[3]=b,e[4]=o,e[5]=f):f=e[5];const i=!m,v=a==="addColumn"?"default":"outline";let h;e[6]!==r?(h=r("Add column"),e[6]=r,e[7]=h):h=e[7];let G;e[8]!==t||e[9]!==i||e[10]!==v||e[11]!==h?(G=l(ge,{"data-testid":"sc-editor-add-column",disabled:i,onClick:t,size:"xs",type:"button",variant:v,children:h}),e[8]=t,e[9]=i,e[10]=v,e[11]=h,e[12]=G):G=e[12];const w=!m,B=a==="addIndex"?"default":"outline";let y;e[13]!==r?(y=r("Add index"),e[13]=r,e[14]=y):y=e[14];let z;e[15]!==s||e[16]!==y||e[17]!==w||e[18]!==B?(z=l(ge,{"data-testid":"sc-editor-add-index",disabled:w,onClick:s,size:"xs",type:"button",variant:B,children:y}),e[15]=s,e[16]=y,e[17]=w,e[18]=B,e[19]=z):z=e[19];const F=!m,D=a==="destructive"?"default":"ghost";let S;e[20]!==r?(S=r("Rename / drop / change type…"),e[20]=r,e[21]=S):S=e[21];let C;e[22]!==d||e[23]!==F||e[24]!==D||e[25]!==S?(C=l(ge,{"data-testid":"sc-editor-destructive",disabled:F,onClick:d,size:"xs",type:"button",variant:D,children:S}),e[22]=d,e[23]=F,e[24]=D,e[25]=S,e[26]=C):C=e[26];let A;return e[27]!==z||e[28]!==C||e[29]!==f||e[30]!==G?(A=p("div",{className:"flex flex-wrap gap-2",children:[f,G,z,C]}),e[27]=z,e[28]=C,e[29]=f,e[30]=G,e[31]=A):A=e[31],A},bt=n=>{const e=Ne(28),{onOpenMigrations:m,result:a}=n,t=Le();if(a===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ke,{}),e[0]=o):o=e[0],o}if(a.kind==="error"){let o;return e[1]!==a.message?(o=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:a.message}),e[1]=a.message,e[2]=o):o=e[2],o}if(a.kind==="needs-migration"){let o;e[3]!==a.message||e[4]!==t?(o=a.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):a.message,e[3]=a.message,e[4]=t,e[5]=o):o=e[5];let f;e[6]!==o?(f=l("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=f):f=e[7];let i;e[8]!==t?(i=t("Open Migrations"),e[8]=t,e[9]=i):i=e[9];let v;e[10]!==m||e[11]!==i?(v=l(ge,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:i}),e[10]=m,e[11]=i,e[12]=v):v=e[12];let h;return e[13]!==f||e[14]!==v?(h=p("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[f,v]}),e[13]=f,e[14]=v,e[15]=h):h=e[15],h}if(a.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ke,{}),e[16]=o):o=e[16],o}let s;e[17]!==t?(s=t("Codegen reported diagnostics:"),e[17]=t,e[18]=s):s=e[18];let c;e[19]!==s?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:s}),e[19]=s,e[20]=c):c=e[20];let d;e[21]!==a.diagnostics?(d=a.diagnostics.map(xt),e[21]=a.diagnostics,e[22]=d):d=e[22];let r;e[23]!==d?(r=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=r):r=e[24];let b;return e[25]!==c||e[26]!==r?(b=p("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,r]}),e[25]=c,e[26]=r,e[27]=b):b=e[27],b};function xt(n){return l("li",{className:"font-mono text-[11px] text-destructive",children:n},n)}const vt=[{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()"}],yt="v.string()",Ct=n=>n.split(",").map(e=>e.trim()).filter(e=>e!==""),Nt=n=>{const e=Ne(83),{onApplied:m,tableNames:a}=n,t=Le(),s=at(),[c,d]=E(null),[r,b]=E(!1),[o,f]=E(null),[i,v]=E(""),[h,G]=E(""),[w,B]=E(yt),[y,z]=E(a[0]??""),[F,D]=E(""),[S,C]=E(""),[A,L]=E(!1);let me;e[0]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{d(null),v(""),G(""),D(""),C(""),L(!1)},e[0]=me):me=e[0];const W=me;let I;e[1]!==m?(I=async T=>{b(!0),f(null);try{const pe=await pt(T);f(pe),pe.kind==="ok"&&(m(pe.tables),W())}catch(pe){const Ie=pe;f({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}b(!1)},e[1]=m,e[2]=I):I=e[2];const q=I;let _;e[3]!==q||e[4]!==i?(_=()=>{be(q({kind:"addTable",table:i.trim()}))},e[3]=q,e[4]=i,e[5]=_):_=e[5];const ue=_;let j;e[6]!==h||e[7]!==q||e[8]!==y||e[9]!==w?(j=()=>{be(q({column:h.trim(),kind:"addOptionalColumn",table:y,validator:w}))},e[6]=h,e[7]=q,e[8]=y,e[9]=w,e[10]=j):j=e[10];const ie=j;let Q;e[11]!==S||e[12]!==F||e[13]!==q||e[14]!==y||e[15]!==A?(Q=()=>{be(q({fields:Ct(S),kind:"addIndex",name:F.trim(),table:y,unique:A}))},e[11]=S,e[12]=F,e[13]=q,e[14]=y,e[15]=A,e[16]=Q):Q=e[16];const Y=Q;let xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>{f(null),d("addTable")},e[17]=xe):xe=e[17];const H=xe;let re;e[18]===Symbol.for("react.memo_cache_sentinel")?(re=()=>{f(null),d("addColumn")},e[18]=re):re=e[18];const ve=re;let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=()=>{f(null),d("addIndex")},e[19]=O):O=e[19];const Z=O;let ee;e[20]!==t?(ee=()=>{d("destructive"),f({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=ee):ee=e[21];const de=ee;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=T=>{v(T.target.value)},e[22]=R):R=e[22];const te=R;let M;e[23]===Symbol.for("react.memo_cache_sentinel")?(M=T=>{G(T.target.value)},e[23]=M):M=e[23];const ye=M;let ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=T=>{B(T.target.value)},e[24]=ce):ce=e[24];const fe=ce;let K;e[25]===Symbol.for("react.memo_cache_sentinel")?(K=T=>{z(T.target.value)},e[25]=K):K=e[25];const X=K;let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=T=>{D(T.target.value)},e[26]=U):U=e[26];const le=U;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V=T=>{C(T.target.value)},e[27]=V):V=e[27];const se=V;let $;e[28]===Symbol.for("react.memo_cache_sentinel")?($=T=>{L(T.target.checked)},e[28]=$):$=e[28];const ae=$;let ne;e[29]!==s?(ne=()=>{be(s({to:"/migrations"}))},e[29]=s,e[30]=ne):ne=e[30];const g=ne;let oe;e[31]!==t?(oe=t("Edit schema"),e[31]=t,e[32]=oe):oe=e[32];let J;e[33]!==oe?(J=l(ze,{children:oe}),e[33]=oe,e[34]=J):J=e[34];let Ce;e[35]!==t?(Ce=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=Ce):Ce=e[36];let he;e[37]!==Ce?(he=l(qe,{children:Ce}),e[37]=Ce,e[38]=he):he=e[38];let u;e[39]!==J||e[40]!==he?(u=p(Be,{children:[J,he]}),e[39]=J,e[40]=he,e[41]=u):u=e[41];const N=a.length>0;let x;e[42]!==c||e[43]!==de||e[44]!==N?(x=l(gt,{hasTables:N,mode:c,onAddColumn:ve,onAddIndex:Z,onAddTable:H,onDestructive:de}),e[42]=c,e[43]=de,e[44]=N,e[45]=x):x=e[45];let P;e[46]!==r||e[47]!==c||e[48]!==ue||e[49]!==t||e[50]!==i?(P=c==="addTable"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(ke,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),l(ge,{"data-testid":"sc-editor-table-apply",disabled:r||i.trim()==="",onClick:ue,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ge,{onClick:W,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=r,e[47]=c,e[48]=ue,e[49]=t,e[50]=i,e[51]=P):P=e[51];let k;e[52]!==r||e[53]!==h||e[54]!==c||e[55]!==ie||e[56]!==t||e[57]!==a||e[58]!==y||e[59]!==w?(k=c==="addColumn"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("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:a.map(Tt)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(ke,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:h})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("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:fe,value:w,children:vt.map(St)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(ge,{"data-testid":"sc-editor-column-apply",disabled:r||h.trim()===""||y==="",onClick:ie,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ge,{onClick:W,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=r,e[53]=h,e[54]=c,e[55]=ie,e[56]=t,e[57]=a,e[58]=y,e[59]=w,e[60]=k):k=e[60];let Te;e[61]!==r||e[62]!==S||e[63]!==F||e[64]!==c||e[65]!==Y||e[66]!==t||e[67]!==a||e[68]!==y||e[69]!==A?(Te=c==="addIndex"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("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:a.map(wt)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(ke,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:F})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(ke,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:se,value:S})]}),p(_e,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ae,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(ge,{"data-testid":"sc-editor-index-apply",disabled:r||F.trim()===""||S.trim()==="",onClick:Y,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ge,{onClick:W,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=r,e[62]=S,e[63]=F,e[64]=c,e[65]=Y,e[66]=t,e[67]=a,e[68]=y,e[69]=A,e[70]=Te):Te=e[70];let Se;e[71]!==g||e[72]!==o?(Se=l(bt,{onOpenMigrations:g,result:o}),e[71]=g,e[72]=o,e[73]=Se):Se=e[73];let we;e[74]!==x||e[75]!==P||e[76]!==k||e[77]!==Te||e[78]!==Se?(we=p(De,{children:[x,P,k,Te,Se]}),e[74]=x,e[75]=P,e[76]=k,e[77]=Te,e[78]=Se,e[79]=we):we=e[79];let Ee;return e[80]!==u||e[81]!==we?(Ee=p(je,{"data-testid":"sc-editor",size:"sm",children:[u,we]}),e[80]=u,e[81]=we,e[82]=Ee):Ee=e[82],Ee};function Tt(n){return l("option",{value:n,children:n},n)}function St(n){return l("option",{value:n.validator,children:n.label},n.validator)}function wt(n){return l("option",{value:n,children:n},n)}const Ve=[],_t=n=>{const e=Ne(5),{open:m}=n,a=m&&"rotate-90";let t;e[0]!==a?(t=Je("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",a),e[0]=a,e[1]=t):t=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=l("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=t,e[4]=c):c=e[4],c},Ye=n=>{const e=Ne(20),{children:m,expanded:a,name:t,onToggle:s,rowCount:c,rowTestId:d,toggleTestId:r}=n;let b;e[0]!==a?(b=l(_t,{open:a}),e[0]=a,e[1]=b):b=e[1];let o;e[2]!==t?(o=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=o):o=e[3];let f;e[4]!==c?(f=p("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=f):f=e[5];let i;e[6]!==a||e[7]!==s||e[8]!==b||e[9]!==o||e[10]!==f||e[11]!==r?(i=p("button",{"aria-expanded":a,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":r,onClick:s,type:"button",children:[b,o," ",f]}),e[6]=a,e[7]=s,e[8]=b,e[9]=o,e[10]=f,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==m||e[14]!==a?(v=a&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=a,e[15]=v):v=e[15];let h;return e[16]!==d||e[17]!==i||e[18]!==v?(h=p("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[i,v]}),e[16]=d,e[17]=i,e[18]=v,e[19]=h):h=e[19],h},He=n=>{const e=Ne(5),{columns:m,testId:a}=n;let t;e[0]!==m?(t=m.map(It),e[0]=m,e[1]=t):t=e[1];let s;return e[2]!==t||e[3]!==a?(s=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":a,children:t}),e[2]=t,e[3]=a,e[4]=s):s=e[4],s},Et=n=>{const e=Ne(10),{heading:m,indexes:a,testId:t}=n;let s;e[0]!==m?(s=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=s):s=e[1];let c;e[2]!==a?(c=a.map(kt),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let r;return e[7]!==s||e[8]!==d?(r=p("div",{className:"pt-3",children:[s,d]}),e[7]=s,e[8]=d,e[9]=r):r=e[9],r},Xe=n=>Je("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",n?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Wt=n=>{const e=Ne(85),{initialShardKey:m,initialTable:a,schemaEditable:t}=n,s=Le();let c;e[0]!==m||e[1]!==a?(c={initialShardKey:m,initialTable:a},e[0]=m,e[1]=a,e[2]=c):c=e[2];const{columns:d,diagramTables:r,error:b,expanded:o,filteredGlobalTables:f,filteredTables:i,globalColumns:v,globalError:h,globalExpanded:G,globalTables:w,indexes:B,refresh:y,setShardKey:z,setTableFilter:F,setView:D,shardColumnsError:S,shardKey:C,tableFilter:A,tables:L,toggle:me,toggleGlobal:W,view:I}=ct(c);let q;e[3]!==D?(q=()=>{D("list")},e[3]=D,e[4]=q):q=e[4];const _=q;let ue;e[5]!==D?(ue=()=>{D("graph")},e[5]=D,e[6]=ue):ue=e[6];const j=ue;let ie;e[7]!==F?(ie=g=>{F(g.target.value)},e[7]=F,e[8]=ie):ie=e[8];const Q=ie;let Y;e[9]!==y||e[10]!==C?(Y=g=>{be(y(C))},e[9]=y,e[10]=C,e[11]=Y):Y=e[11];const xe=Y;let H;e[12]!==L?(H=L??[],e[12]=L,e[13]=H):H=e[13];let re;e[14]!==H?(re=H.map(At),e[14]=H,e[15]=re):re=e[15];const ve=re;let O;e[16]!==z||e[17]!==C?(O=l(We,{onChange:z,testId:"sc-shard-input",value:C}),e[16]=z,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==s?(Z=s("Schema view"),e[19]=s,e[20]=Z):Z=e[20];const ee=I==="graph",de=I==="graph";let R;e[21]!==de?(R=Xe(de),e[21]=de,e[22]=R):R=e[22];let te;e[23]!==s?(te=s("Graph"),e[23]=s,e[24]=te):te=e[24];let M;e[25]!==j||e[26]!==ee||e[27]!==R||e[28]!==te?(M=l("button",{"aria-selected":ee,className:R,"data-testid":"sc-view-graph",onClick:j,role:"tab",type:"button",children:te}),e[25]=j,e[26]=ee,e[27]=R,e[28]=te,e[29]=M):M=e[29];const ye=I==="list",ce=I==="list";let fe;e[30]!==ce?(fe=Xe(ce),e[30]=ce,e[31]=fe):fe=e[31];let K;e[32]!==s?(K=s("Table list"),e[32]=s,e[33]=K):K=e[33];let X;e[34]!==_||e[35]!==ye||e[36]!==fe||e[37]!==K?(X=l("button",{"aria-selected":ye,className:fe,"data-testid":"sc-view-list",onClick:_,role:"tab",type:"button",children:K}),e[34]=_,e[35]=ye,e[36]=fe,e[37]=K,e[38]=X):X=e[38];let U;e[39]!==M||e[40]!==X||e[41]!==Z?(U=p("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[M,X]}),e[39]=M,e[40]=X,e[41]=Z,e[42]=U):U=e[42];let le;e[43]!==U||e[44]!==O?(le=p("div",{className:"flex flex-wrap items-center gap-3",children:[O,U]}),e[43]=U,e[44]=O,e[45]=le):le=e[45];let V;e[46]!==xe||e[47]!==t||e[48]!==ve?(V=t===!0&&l(Nt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=t,e[48]=ve,e[49]=V):V=e[49];let se;e[50]!==Q||e[51]!==s||e[52]!==A||e[53]!==I?(se=I==="list"&&l(ke,{"aria-label":s("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Q,placeholder:s("Filter tables"),value:A}),e[50]=Q,e[51]=s,e[52]=A,e[53]=I,e[54]=se):se=e[54];let $;e[55]!==r||e[56]!==b||e[57]!==h||e[58]!==S||e[59]!==C||e[60]!==I?($=I==="graph"&&p("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[b!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),h!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:h}),l(st,{columnsError:S[C]===!0,tables:r,testIdPrefix:"sc-graph"})]}),e[55]=r,e[56]=b,e[57]=h,e[58]=S,e[59]=C,e[60]=I,e[61]=$):$=e[61];let ae;e[62]!==d||e[63]!==b||e[64]!==o||e[65]!==f||e[66]!==i||e[67]!==v||e[68]!==h||e[69]!==G||e[70]!==w||e[71]!==B||e[72]!==C||e[73]!==s||e[74]!==L||e[75]!==me||e[76]!==W||e[77]!==I?(ae=I==="list"&&p("div",{className:"flex flex-col gap-4",children:[p(je,{"data-testid":"sc-shard-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Re,{tier:"shard"}),l(ze,{children:s("Shard tables")}),L!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),l(qe,{children:Pe.shard.hint})]}),p(De,{children:[b!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:b}),L!==null&&L.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:s("No tables in this shard.")}),L!==null&&L.length>0&&i.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:s("No tables match your filter.")}),i.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(g=>{const oe=`${C}:${g.name}`,J=B[oe]??[];return p(Ye,{expanded:o===g.name,name:g.name,onToggle:()=>{be(me(g.name))},rowCount:g.rowCount,rowTestId:`sc-table-${g.name}`,toggleTestId:`sc-toggle-${g.name}`,children:[l(He,{columns:d[oe]??Ve,testId:`sc-columns-${g.name}`}),J.length>0&&l(Et,{heading:s("Indexes"),indexes:J,testId:`sc-indexes-${g.name}`})]},g.name)})})]})]}),p(je,{"data-testid":"sc-global-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Re,{tier:"global"}),l(ze,{children:s("Global tables (D1)")}),w!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:f.length})]}),l(qe,{children:Pe.global.hint})]}),p(De,{children:[h!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:h}),w!==null&&w.length===0&&l(Qe,{description:Pe.global.hint,testId:"sc-global-empty",title:s("No global tables.")}),w!==null&&w.length>0&&f.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:s("No tables match your filter.")}),f.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:f.map(g=>l(Ye,{expanded:G===g.name,name:g.name,onToggle:()=>{be(W(g.name))},rowCount:g.rowCount,rowTestId:`sc-global-table-${g.name}`,toggleTestId:`sc-global-toggle-${g.name}`,children:l(He,{columns:v[g.name]??Ve,testId:`sc-global-columns-${g.name}`})},g.name))})]})]})]}),e[62]=d,e[63]=b,e[64]=o,e[65]=f,e[66]=i,e[67]=v,e[68]=h,e[69]=G,e[70]=w,e[71]=B,e[72]=C,e[73]=s,e[74]=L,e[75]=me,e[76]=W,e[77]=I,e[78]=ae):ae=e[78];let ne;return e[79]!==le||e[80]!==V||e[81]!==se||e[82]!==$||e[83]!==ae?(ne=p("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,V,se,$,ae]}),e[79]=le,e[80]=V,e[81]=se,e[82]=$,e[83]=ae,e[84]=ne):ne=e[84],ne};function It(n){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:n},n)}function kt(n){return p("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:n.name}),l(Fe,{variant:"outline",children:n.type}),n.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:n.fields.join(", ")})]},`${n.type}:${n.name}`)}function At(n){return n.name}export{Wt as SchemaViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as u}from"react/compiler-runtime";import{u as m}from"../packem_shared/use-admin-query-
|
|
1
|
+
import{c as u}from"react/compiler-runtime";import{u as m}from"../packem_shared/use-admin-query-BvZH4unR.mjs";import{useT as h}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as p}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{A as R}from"../packem_shared/advisor-view-DyXQCN4y.mjs";import{jsx as g}from"react/jsx-runtime";const f=(e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[s.kind],k=e=>Array.isArray(e.findings)?e.findings:[],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],A=(e,s)=>({"admin-token-weak":e("Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — 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.")})[s.kind],y=()=>{const e=u(8),s=h();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];const{data:r,error:n,errorSource:d}=m(p.getSecurityAudit,i);let a;if(e[1]!==r||e[2]!==s){const l=r===void 0?null:k(r);a=l===null?null:l.map(t=>({description:A(s,t),entity:S(t),issueType:f(s,t),key:t.kind,level:t.level})),e[1]=r,e[2]=s,e[3]=a}else a=e[3];const c=a;let o;return e[4]!==n||e[5]!==d||e[6]!==c?(o=g(R,{error:n,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=n,e[5]=d,e[6]=c,e[7]=o):o=e[7],o};export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as G}from"react/compiler-runtime";import{E as X}from"../packem_shared/error-alert-
|
|
1
|
+
import{c as G}from"react/compiler-runtime";import{E as X}from"../packem_shared/error-alert-ClpDVYvo.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as P}from"../packem_shared/card--2hKx4L2.mjs";import{T as Z,a as ee,b as J,c as Q,d as te,e as W}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-BvZH4unR.mjs";import{useT as se}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{C as ne}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{r as ae,u as ie,s as oe}from"../packem_shared/shortcuts-B9gDaXmw.mjs";import{jsxs as d,jsx as r}from"react/jsx-runtime";const de={binding:"outline",secret:"destructive",var:"secondary"},ce=(s,e)=>{if(s===void 0)return[];const u=[];return s.workerUrl!==void 0&&u.push({label:e("URL"),value:s.workerUrl}),s.environment!==void 0&&u.push({label:e("Environment"),value:s.environment}),s.deploymentId!==void 0&&u.push({label:e("Deployment"),value:s.deploymentId}),s.versionTag!==void 0&&u.push({label:e("Version"),value:s.versionTag}),u},z=s=>{const e=G(18),{modifier:u,name:t,label:p}=s,F=ie();let b;e[0]!==t?(b=a=>{if(!["Escape","Tab"].includes(a.key)){if(a.shiftKey){a.preventDefault();return}a.preventDefault(),oe(t,a.key)}},e[0]=t,e[1]=b):b=e[1];const c=b,m=`set-shortcut-${t}`;let f;e[2]!==p?(f=r("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=f):f=e[3];let h;e[4]!==u?(h=r("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];const n=`set-shortcut-input-${t}`,x=F[t];let i;e[6]!==p||e[7]!==c||e[8]!==n||e[9]!==x?(i=r("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":n,onKeyDown:c,readOnly:!0,value:x}),e[6]=p,e[7]=c,e[8]=n,e[9]=x,e[10]=i):i=e[10];let l;e[11]!==h||e[12]!==i?(l=d("dd",{className:"flex items-center gap-1.5",children:[h,i]}),e[11]=h,e[12]=i,e[13]=l):l=e[13];let o;return e[14]!==m||e[15]!==f||e[16]!==l?(o=d("div",{className:"contents","data-testid":m,children:[f,l]}),e[14]=m,e[15]=f,e[16]=l,e[17]=o):o=e[17],o},Ce=s=>{const e=G(85),{initialShardKey:u}=s,t=se();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];const F=u??"";let b;e[1]!==F?(b={shardKey:F},e[1]=F,e[2]=b):b=e[2];const{data:c,error:m,errorSource:f,isLoading:h}=re(le.getSettings,p,b);let n,x,i,l,o,a,g;if(e[3]!==m||e[4]!==f||e[5]!==c?.deploy||e[6]!==c?.settings||e[7]!==t){const q=ce(c?.deploy,t);let H;e[15]!==c?.settings?(H=c?.settings??[],e[15]=c?.settings,e[16]=H):H=e[16],n=H,x="flex flex-col gap-4",i="lunora-settings";let j;e[17]!==t?(j=t("Open in Cloudflare"),e[17]=t,e[18]=j):j=e[18],e[19]!==j?(l=r("div",{className:"flex flex-wrap items-center gap-3",children:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:ne,rel:"noreferrer",target:"_blank",children:j})}),e[19]=j,e[20]=l):l=e[20];let B;e[21]!==t?(B=t("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=t,e[22]=B):B=e[22],e[23]!==B?(o=r("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:B}),e[23]=B,e[24]=o):o=e[24],e[25]!==m||e[26]!==f?(a=m!==null&&r(X,{error:f,testId:"set-error"}),e[25]=m,e[26]=f,e[27]=a):a=e[27],g=q.length>0&&d(M,{className:"py-0","data-testid":"set-deploy",children:[r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Deployment")})}),r(P,{className:"py-3",children:r("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:q.map(me)})})]}),e[3]=m,e[4]=f,e[5]=c?.deploy,e[6]=c?.settings,e[7]=t,e[8]=n,e[9]=x,e[10]=i,e[11]=l,e[12]=o,e[13]=a,e[14]=g}else n=e[8],x=e[9],i=e[10],l=e[11],o=e[12],a=e[13],g=e[14];let N;e[28]!==t?(N=t("Keyboard shortcuts"),e[28]=t,e[29]=N):N=e[29];let v;e[30]!==N?(v=r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),e[30]=N,e[31]=v):v=e[31];let y;e[32]!==t?(y=t("Reset"),e[32]=t,e[33]=y):y=e[33];let k;e[34]!==y?(k=r("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ae,type:"button",children:y}),e[34]=y,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=d("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==t?(C=t("Command palette"),e[39]=t,e[40]=C):C=e[40];let T;e[41]!==C?(T=r(z,{label:C,modifier:"⌘/Ctrl",name:"palette"}),e[41]=C,e[42]=T):T=e[42];let S;e[43]!==t?(S=t("Operation console"),e[43]=t,e[44]=S):S=e[44];let R;e[45]!==S?(R=r(z,{label:S,modifier:"Ctrl",name:"console"}),e[45]=S,e[46]=R):R=e[46];let _;e[47]!==T||e[48]!==R?(_=d("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[T,R]}),e[47]=T,e[48]=R,e[49]=_):_=e[49];let D;e[50]!==t?(D=t("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=t,e[51]=D):D=e[51];let E;e[52]!==D?(E=r("p",{className:"pt-3 text-xs text-muted-foreground",children:D}),e[52]=D,e[53]=E):E=e[53];let I;e[54]!==_||e[55]!==E?(I=d(P,{className:"py-3",children:[_,E]}),e[54]=_,e[55]=E,e[56]=I):I=e[56];let K;e[57]!==w||e[58]!==I?(K=d(M,{className:"py-0","data-testid":"set-preferences",children:[w,I]}),e[57]=w,e[58]=I,e[59]=K):K=e[59];let A;e[60]!==t?(A=t("Environment & bindings"),e[60]=t,e[61]=A):A=e[61];let O;e[62]!==A?(O=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A})}),e[62]=A,e[63]=O):O=e[63];let U;e[64]!==m||e[65]!==h||e[66]!==n.length||e[67]!==t?(U=m===null&&!h&&n.length===0&&r("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:t("No environment variables or bindings.")}),e[64]=m,e[65]=h,e[66]=n.length,e[67]=t,e[68]=U):U=e[68];let L;e[69]!==n||e[70]!==t?(L=n.length>0&&r(P,{className:"px-0 py-0",children:d(Z,{"data-testid":"set-table",children:[r(ee,{children:d(J,{children:[r(Q,{children:t("name")}),r(Q,{children:t("kind")}),r(Q,{children:t("value")})]})}),r(te,{children:n.map(fe)})]})}),e[69]=n,e[70]=t,e[71]=L):L=e[71];let $;e[72]!==O||e[73]!==U||e[74]!==L?($=d(M,{className:"py-0",children:[O,U,L]}),e[72]=O,e[73]=U,e[74]=L,e[75]=$):$=e[75];let V;return e[76]!==K||e[77]!==$||e[78]!==x||e[79]!==i||e[80]!==l||e[81]!==o||e[82]!==a||e[83]!==g?(V=d("div",{className:x,"data-testid":i,children:[l,o,a,g,K,$]}),e[76]=K,e[77]=$,e[78]=x,e[79]=i,e[80]=l,e[81]=o,e[82]=a,e[83]=g,e[84]=V):V=e[84],V};function me(s){return d("div",{className:"contents","data-testid":"set-deploy-row",children:[r("dt",{className:"text-muted-foreground",children:s.label}),r("dd",{className:"truncate font-mono text-xs",title:s.value,children:s.value})]},s.label)}function fe(s){return d(J,{"data-testid":"set-row",children:[r(W,{className:"font-mono text-xs font-medium",children:s.name}),r(W,{children:r(Y,{variant:de[s.kind],children:s.bindingType??s.kind})}),r(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:s.value??r("span",{className:"text-muted-foreground",children:"—"})})]},s.name)}export{Ce as SettingsPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Y}from"react/compiler-runtime";import{useLunora as Ue}from"@lunora/react";import{useState as ce,useMemo as Ge,useCallback as ut,useEffect as Ne,useRef as Ce,useId as ft}from"react";import{ADMIN_FUNCTIONS as _e}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{u as Fe,n as et,b as je,r as Re,s as mt}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{d as qe,f as ue,c as Oe,b as ht}from"../packem_shared/internal-
|
|
1
|
+
import{c as Y}from"react/compiler-runtime";import{useLunora as Ue}from"@lunora/react";import{useState as ce,useMemo as Ge,useCallback as ut,useEffect as Ne,useRef as Ce,useId as ft}from"react";import{ADMIN_FUNCTIONS as _e}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{u as Fe,n as et,b as je,r as Re,s as mt}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{d as qe,f as ue,c as Oe,b as ht}from"../packem_shared/internal-D4gBuklE.mjs";import{r as pt}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{u as bt}from"../packem_shared/use-sql-assistant-BGoWYcGL.mjs";import gt from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{useT as de}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as fe}from"../packem_shared/utils-bhneXptQ.mjs";import{jsxs as F,jsx as b,Fragment as He}from"react/jsx-runtime";import{I as xt}from"../packem_shared/input-CXhxesPC.mjs";import{S as yt,a as vt}from"../packem_shared/sql-result-table-BLIMecXM.mjs";import{ShardInput as St}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{A as wt}from"../packem_shared/alert-PB5W11MM.mjs";import{E as Ct}from"../packem_shared/grid-features-CGs2pKcr.mjs";const Nt=["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"],kt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ae=String.fromCodePoint(0),Tt=new RegExp(`${Ae}${String.raw`(\d+)`}${Ae}`,"gu"),Et=Nt.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),Rt=kt.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
2
2
|
${l}`})),Lt=l=>{const e=[];let t=l.replaceAll(/'(?:[^']|'')*'/gu,o=>(e.push(o),`${Ae}${(e.length-1).toString()}${Ae}`)).replaceAll(/\s+/gu," ").trim();for(const{pattern:o,replacement:s}of Et)t=t.replaceAll(o,s);for(const{pattern:o,replacement:s}of Rt)t=t.replaceAll(o,s);return t=t.replaceAll(Tt,(o,s)=>e[Number(s)]??""),t},Pe="x",It={'"':'"',"'":"'","[":"]","`":"`"},qt=(l,e)=>{let n=e+2;for(;n<l.length&&l[n]!==`
|
|
3
3
|
`;)n+=1;return n},At=(l,e)=>{const n=l.indexOf("*/",e+2);return n===-1?-1:n+2},tt=l=>{const e=l.split("");let n=0;for(;n<l.length;){const t=l[n]??"",o=It[t];if(t==="-"&&l[n+1]==="-"){const s=qt(l,n);e.fill(Pe,n,s),n=s}else if(t==="/"&&l[n+1]==="*"){const s=At(l,n);if(s===-1)return;e.fill(Pe,n,s),n=s}else if(o!==void 0){let s=n+1;for(;s<l.length;)if(l[s]!==o)s+=1;else if(o!=="]"&&l[s+1]===o)s+=2;else break;if(s>=l.length)return;e.fill(Pe,n,s+1),n=s+1}else n+=1}for(let t=0;t<l.length;t+=1)l[t]===`
|
|
4
4
|
`&&(e[t]=`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as V}from"react/compiler-runtime";import{useLunora as k}from"@lunora/react";import{useNavigate as F,useRouter as L,useSearch as M}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{u as P}from"../packem_shared/table-list-sidebar-
|
|
1
|
+
import{c as V}from"react/compiler-runtime";import{useLunora as k}from"@lunora/react";import{useNavigate as F,useRouter as L,useSearch as M}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{u as P}from"../packem_shared/table-list-sidebar-DKpSAP6p.mjs";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{s as J,d as D}from"../packem_shared/data-view-params-qoSTqjAj.mjs";import{f}from"../packem_shared/internal-D4gBuklE.mjs";import{l as K,s as O}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{DataBrowser as I}from"../packem_shared/DataBrowser-Bf32rBcr.mjs";import{GlobalDataBrowser as X}from"../packem_shared/GlobalDataBrowser-CDpzXZxj.mjs";import{jsx as v,jsxs as E}from"react/jsx-runtime";const N="lunora-studio-saved-queries",Y=50,$=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,S=()=>K(N).filter($),B=r=>{O(N,r)},z=(r,e)=>{const s=r.trim();if(s==="")return S();const o=[{name:s,view:e},...S().filter(b=>b.name!==s)].slice(0,Y);return B(o),o},H=r=>{const e=S().filter(s=>s.name!==r);return B(e),e},U=r=>{const e=V(15),{onChange:s,tier:o}=r,b=q();let d;e[0]!==s?(d=y=>{s(y.target.value)},e[0]=s,e[1]=d):d=e[1];const l=d;let h;e[2]!==b?(h=b("Storage tier"),e[2]=b,e[3]=h):h=e[3];let i;e[4]!==h?(i=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:h}),e[4]=h,e[5]=i):i=e[5];const m=w[o];let n,g;e[6]===Symbol.for("react.memo_cache_sentinel")?(n=v("option",{value:"shard",children:w.shard.label}),g=v("option",{value:"global",children:w.global.label}),e[6]=n,e[7]=g):(n=e[6],g=e[7]);let c;e[8]!==l||e[9]!==m.title||e[10]!==o?(c=E("select",{className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm outline-none focus-visible:border-ring","data-testid":"table-editor-schema",id:"table-editor-schema",onChange:l,title:m.title,value:o,children:[n,g]}),e[8]=l,e[9]=m.title,e[10]=o,e[11]=c):c=e[11];let u;return e[12]!==i||e[13]!==c?(u=E("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[i,c]}),e[12]=i,e[13]=c,e[14]=u):u=e[14],u},W=()=>{try{f(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},pe=({editable:r=!1,initialShardKey:e})=>{const s=k(),o=F(),b=L(),d=M({strict:!1}),l=J(d),h=P(d),i=()=>b.state.location.pathname.split("/").findLast(Boolean)==="data",m=l.tier??"shard",n=l.table,[g,c]=Q(()=>S()),[u,y]=Q(()=>new Set);A(()=>{f((async()=>{try{const a=await s.listGlobalTables();y(new Set(a.map(t=>t.name)))}catch{}})())},[s]),A(()=>{m==="shard"&&n!==void 0&&u.has(n)&&f(o({replace:!0,search:a=>({...a,schema:"global"}),to:"/data"}))},[u,o,n,m]);const R=a=>{f(o({search:t=>({...t,schema:a==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(a,t)=>{i()&&f(o({search:p=>({schema:p.schema,search:t?.search,shard:p.shard,table:a}),to:"/data"}))},C=a=>{f(o({search:t=>({...t,schema:"global",table:a}),to:"/data"}))},G=a=>{const t=D(a),{current:p}=h;(p.filters??void 0)===t.filters&&(p.order??void 0)===t.order&&(p.search??void 0)===t.search&&(p.shard??void 0)===t.shard||!i()||f(o({replace:!0,search:j=>({...j,filters:t.filters,order:t.order,search:t.search,shard:t.shard}),to:"/data"}))},_={onApplyQuery:a=>{const t=D(a.view);f(o({search:()=>({filters:t.filters,order:t.order,schema:t.schema,search:t.search,shard:t.shard,table:t.table}),to:"/data"}))},onCopyLink:W,onDeleteQuery:a=>{c(H(a))},onSaveQuery:(a,t)=>{c(z(a,t))},saved:g},x=v(U,{onChange:R,tier:m});return m==="global"?v(X,{initialTable:n,onSelectTable:T,schemaSwitch:x}):v(I,{editable:r,globalTableNames:u,initialFilters:l.filters,initialOrderBy:l.orderBy,initialPins:d.pins,initialSearch:l.search,initialShardKey:l.shard??e,onNavigateToGlobal:C,onSelectTable:T,onViewChange:G,queryBar:_,schemaSwitch:x,tableParam:n})};export{pe as TableEditor};
|