@lunora/studio 1.0.0-alpha.95 → 1.0.0-alpha.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +1 -1
- package/dist/packem_chunks/DeploymentHealthPanel.js +1 -1
- package/dist/packem_chunks/ExportImportPanel.js +1 -1
- package/dist/packem_chunks/FileBrowser.js +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
- package/dist/packem_chunks/HealthPanel.js +1 -1
- package/dist/packem_chunks/InsightsPanel.js +1 -1
- package/dist/packem_chunks/LogsPanel.js +1 -1
- package/dist/packem_chunks/MailPanel.js +1 -1
- package/dist/packem_chunks/MetricsPanel.js +1 -1
- package/dist/packem_chunks/NotificationsPanel.js +1 -1
- package/dist/packem_chunks/SchemaViewer.js +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
- package/dist/packem_chunks/SettingsPanel.js +1 -1
- package/dist/packem_chunks/SqlEditorPanel.js +6 -6
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/agents-panel.js +1 -1
- package/dist/packem_chunks/analytics-panel.js +1 -1
- package/dist/packem_chunks/auth-audit-panel.js +1 -1
- package/dist/packem_chunks/auth-config-panel.js +1 -1
- package/dist/packem_chunks/auth-sessions-panel.js +1 -1
- package/dist/packem_chunks/containers-panel.js +1 -1
- package/dist/packem_chunks/dashboards-panel.js +1 -1
- package/dist/packem_chunks/fanout-panel.js +1 -1
- package/dist/packem_chunks/flags-panel.js +1 -1
- package/dist/packem_chunks/issues-panel.js +1 -1
- package/dist/packem_chunks/kv-browser.js +1 -1
- package/dist/packem_chunks/log-drains-panel.js +2 -2
- package/dist/packem_chunks/migrations-route.js +1 -1
- package/dist/packem_chunks/organizations-panel.js +1 -1
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/packem_chunks/permissions-panel.js +1 -1
- package/dist/packem_chunks/queues-panel.js +1 -1
- package/dist/packem_chunks/rls-panel.js +1 -1
- package/dist/packem_chunks/schedule-panel.js +1 -1
- package/dist/packem_chunks/sparkline.js +1 -1
- package/dist/packem_chunks/storage-rules-panel.js +1 -1
- package/dist/packem_chunks/subscriptions-panel.js +1 -1
- package/dist/packem_chunks/sync-client-panel.js +1 -1
- package/dist/packem_chunks/traces-panel.js +1 -1
- package/dist/packem_chunks/users-panel.js +1 -1
- package/dist/packem_chunks/vector-browser.js +1 -1
- package/dist/packem_chunks/workflows-panel.js +1 -1
- package/dist/packem_shared/{DataBrowser-H4oUFkPJ.js → DataBrowser-CPNKM0KZ.js} +1 -1
- package/dist/packem_shared/{GlobalDataBrowser-CeA8bDjX.js → GlobalDataBrowser-BSmyOO0n.js} +1 -1
- package/dist/packem_shared/{HomePanel-DLP1nQdC.js → HomePanel-BUO6BcYQ.js} +1 -1
- package/dist/packem_shared/{MigrationsPanel-dm_M75mR.js → MigrationsPanel-BAnvY79E.js} +1 -1
- package/dist/packem_shared/{ScheduledJobs-DDJG9Je7.js → ScheduledJobs-pHVlh2xU.js} +1 -1
- package/dist/packem_shared/{Studio-BYg65qWq.js → Studio-DG_n-8Pc.js} +1 -1
- package/dist/packem_shared/{StudioApp-D0UOg0a_.js → StudioApp-bavavhpe.js} +1 -1
- package/dist/packem_shared/advisor-view-CGcwvlMo.js +1 -0
- package/dist/packem_shared/bar-chart-B8oDHgnw.js +6 -0
- package/dist/packem_shared/{card-CIDGUN6K.js → card-BMKx5UdA.js} +1 -1
- package/dist/packem_shared/{dropdown-menu-C3RQ_HlW.js → dropdown-menu-BgS2zw1i.js} +1 -1
- package/dist/packem_shared/error-alert-_2q2VtVG.js +1 -0
- package/dist/packem_shared/{grid-features-Db_BNYRo.js → grid-features-Y2YSjhCf.js} +2 -2
- package/dist/packem_shared/home-panel-Ir3YHReO.js +3 -0
- package/dist/packem_shared/result-chart-0VgP_3FP.js +1 -0
- package/dist/packem_shared/schema-diagram-GVgnLWTf.js +2 -0
- package/dist/packem_shared/{select-Bul-DeII.js → select-BssZMiFY.js} +1 -1
- package/dist/packem_shared/{sparkline-CgjeUU2I.js → sparkline-BNvxiJj_.js} +1 -1
- package/dist/packem_shared/{stat-card-fm_TF1mo.js → stat-card-BGJdhfm6.js} +1 -1
- package/dist/packem_shared/studio-C9Qvg13j.js +2 -0
- package/dist/packem_shared/{table-DdJBrClo.js → table-DZAB8cs3.js} +1 -1
- package/dist/packem_shared/{trace-handoff-Dw7mwjxu.js → trace-handoff-CuZ6WGgo.js} +1 -1
- package/dist/packem_shared/use-async-submit-B32whHJO.js +1 -0
- package/dist/standalone/{chunk-BN4CIAXU.js → chunk-2KRXOCZ2.js} +1 -1
- package/dist/standalone/{chunk-D62SDRMM.js → chunk-3626PHEZ.js} +1 -1
- package/dist/standalone/{chunk-TITX6XEA.js → chunk-3IF75YS7.js} +1 -1
- package/dist/standalone/chunk-3SCGCJYS.js +1 -0
- package/dist/standalone/{chunk-2OUIHY7G.js → chunk-3SGYSFRC.js} +1 -1
- package/dist/standalone/{chunk-7YJNH3RB.js → chunk-4EHNOASW.js} +1 -1
- package/dist/standalone/{chunk-YD5O2NWK.js → chunk-5A7NIX77.js} +1 -1
- package/dist/standalone/{chunk-UIGAA3GV.js → chunk-5L2VKBAJ.js} +1 -1
- package/dist/standalone/{chunk-NNKN2XEZ.js → chunk-5L63KFHD.js} +1 -1
- package/dist/standalone/{chunk-ZNAGZU6H.js → chunk-6F7KP54M.js} +1 -1
- package/dist/standalone/{chunk-3FIN5PH4.js → chunk-6V27P65N.js} +2 -2
- package/dist/standalone/{chunk-2T22UR7E.js → chunk-73B3T2SA.js} +1 -1
- package/dist/standalone/chunk-7CWPU3LW.js +1 -0
- package/dist/standalone/{chunk-PE7TI4TQ.js → chunk-A6NAMYVS.js} +1 -1
- package/dist/standalone/{chunk-RNOSWEMO.js → chunk-AB5WGAX6.js} +2 -2
- package/dist/standalone/{chunk-IBVBIKUI.js → chunk-ATLV7KWK.js} +1 -1
- package/dist/standalone/{chunk-IUUSMC2R.js → chunk-BLHSTFG3.js} +1 -1
- package/dist/standalone/chunk-C2ZFQARQ.js +11 -0
- package/dist/standalone/chunk-CXBXUT5A.js +3 -0
- package/dist/standalone/chunk-CZZWYUTR.js +1 -0
- package/dist/standalone/{chunk-LZKU262J.js → chunk-D264UAKY.js} +1 -1
- package/dist/standalone/{chunk-VVNQP4CI.js → chunk-DDO5EGID.js} +1 -1
- package/dist/standalone/{chunk-DMJDUC4L.js → chunk-E3Z4QXAD.js} +1 -1
- package/dist/standalone/{chunk-WI4XINU2.js → chunk-EZKBI7SZ.js} +1 -1
- package/dist/standalone/{chunk-BNAMPDZ2.js → chunk-FHZ5WDTU.js} +1 -1
- package/dist/standalone/{chunk-TMNKNTC4.js → chunk-FXBBFE7Y.js} +1 -1
- package/dist/standalone/{chunk-JYLYJT27.js → chunk-G2O3XP7Y.js} +5 -5
- package/dist/standalone/{chunk-SCKKQIAE.js → chunk-H5ZYPSLB.js} +1 -1
- package/dist/standalone/{chunk-Z4AX76YZ.js → chunk-HH5CZ6KD.js} +1 -1
- package/dist/standalone/{chunk-UGU5GYDV.js → chunk-I7V54EDS.js} +1 -1
- package/dist/standalone/{chunk-6K46XGR5.js → chunk-II64XEZV.js} +1 -1
- package/dist/standalone/{chunk-U6KDYJJC.js → chunk-IZFPJXB3.js} +1 -1
- package/dist/standalone/{chunk-QNHU4SKL.js → chunk-J4UYSDWF.js} +1 -1
- package/dist/standalone/{chunk-JWXKUXYA.js → chunk-JNY7CFF4.js} +1 -1
- package/dist/standalone/{chunk-DYMO6MDG.js → chunk-KP6VHTO4.js} +1 -1
- package/dist/standalone/{chunk-SKYFKPJC.js → chunk-LAEO6D34.js} +1 -1
- package/dist/standalone/{chunk-VNQB6HY4.js → chunk-LHAHIDNT.js} +1 -1
- package/dist/standalone/{chunk-4LCY5XUR.js → chunk-M2M3RYJU.js} +1 -1
- package/dist/standalone/{chunk-3KXDX76D.js → chunk-M3Z2YAHD.js} +1 -1
- package/dist/standalone/{chunk-YTWBHPAT.js → chunk-MW5YIENZ.js} +1 -1
- package/dist/standalone/chunk-NBANYYGB.js +1 -0
- package/dist/standalone/{chunk-465RIA2L.js → chunk-NCKRVNF2.js} +1 -1
- package/dist/standalone/{chunk-A3DBEJLO.js → chunk-NDO6YSEG.js} +1 -1
- package/dist/standalone/{chunk-O3UMJLO3.js → chunk-NJRW66LJ.js} +1 -1
- package/dist/standalone/{chunk-AQ4JNJF3.js → chunk-OKZP3YY3.js} +1 -1
- package/dist/standalone/{chunk-2O65JEMI.js → chunk-ON2FIVI2.js} +1 -1
- package/dist/standalone/chunk-OQIGV6FX.js +59 -0
- package/dist/standalone/{chunk-QXECM52Z.js → chunk-OZA2RA45.js} +1 -1
- package/dist/standalone/{chunk-XNGYYOLS.js → chunk-P33WK7YI.js} +4 -4
- package/dist/standalone/{chunk-KEVIGWKP.js → chunk-PKWJ7UOG.js} +1 -1
- package/dist/standalone/chunk-PLFTCTMX.js +1 -0
- package/dist/standalone/{chunk-7ONX5YGW.js → chunk-PMGTIUU2.js} +1 -1
- package/dist/standalone/{chunk-ABYJC3LS.js → chunk-QC4T2L6I.js} +1 -1
- package/dist/standalone/{chunk-3DJ3IUUG.js → chunk-QEVFPILV.js} +1 -1
- package/dist/standalone/{chunk-PGVJE5F5.js → chunk-QQYX5WN4.js} +1 -1
- package/dist/standalone/{chunk-G6GX5TVB.js → chunk-S7ZOM3NK.js} +1 -1
- package/dist/standalone/{chunk-M7AWSDGY.js → chunk-SPE3AB54.js} +1 -1
- package/dist/standalone/{chunk-OM36OEHZ.js → chunk-STESBRLN.js} +1 -1
- package/dist/standalone/{chunk-QM4EXWKF.js → chunk-SZXVX6PY.js} +1 -1
- package/dist/standalone/{chunk-EQZTSISX.js → chunk-TMGHRD6W.js} +1 -1
- package/dist/standalone/{chunk-ZA5YIHZM.js → chunk-UYPXC3OO.js} +1 -1
- package/dist/standalone/{chunk-ZVAGD3FT.js → chunk-VH2IO643.js} +1 -1
- package/dist/standalone/{chunk-5TDGHWYU.js → chunk-WLXH4ECM.js} +1 -1
- package/dist/standalone/{chunk-UZERI5YC.js → chunk-WQH3LT2P.js} +1 -1
- package/dist/standalone/{chunk-DBMFI2HC.js → chunk-XPOUF2XH.js} +1 -1
- package/dist/standalone/{chunk-JEZDJ7D6.js → chunk-YP7WZ6YM.js} +1 -1
- package/dist/standalone/chunk-YZIR7PL5.js +1 -0
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/advisor-view-Coipc04R.js +0 -1
- package/dist/packem_shared/bar-chart-DraN_srt.js +0 -9
- package/dist/packem_shared/error-alert--Ie7ofJ0.js +0 -1
- package/dist/packem_shared/home-panel-BtxdqXDe.js +0 -3
- package/dist/packem_shared/result-chart-Gywg9DOk.js +0 -1
- package/dist/packem_shared/schema-diagram-DTRaCp6Y.js +0 -2
- package/dist/packem_shared/studio-Drf4en3j.js +0 -2
- package/dist/packem_shared/use-async-submit-BFIMhRqh.js +0 -1
- package/dist/standalone/chunk-5KCULF7S.js +0 -11
- package/dist/standalone/chunk-GZMKPBTJ.js +0 -1
- package/dist/standalone/chunk-ILNELDFC.js +0 -1
- package/dist/standalone/chunk-MV4A2PAK.js +0 -1
- package/dist/standalone/chunk-Q2Q7FR3R.js +0 -1
- package/dist/standalone/chunk-S3DWUXGY.js +0 -62
- package/dist/standalone/chunk-UBIPFCOZ.js +0 -1
- package/dist/standalone/chunk-ZQPWVALL.js +0 -3
- package/dist/standalone/chunk-ZZJ7VUVZ.js +0 -1
- /package/dist/standalone/{chunk-7H7LZRLP.js → chunk-4KIQ5RLS.js} +0 -0
- /package/dist/standalone/{chunk-UU2QJMGJ.js → chunk-MKYEFQCA.js} +0 -0
- /package/dist/standalone/{chunk-KUVMORDQ.js → chunk-PKSAWP56.js} +0 -0
- /package/dist/standalone/{chunk-MIQTKZAR.js → chunk-WJQLNYGX.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as z}from"react/compiler-runtime";import{useLunora as D}from"@lunora/react";import{g as C}from"../packem_shared/badge-BbuuAio7.js";import{c as K,
|
|
1
|
+
import{c as z}from"react/compiler-runtime";import{useLunora as D}from"@lunora/react";import{g as C}from"../packem_shared/badge-BbuuAio7.js";import{c as K,f as L}from"../packem_shared/card-BMKx5UdA.js";import{E as j}from"../packem_shared/empty-state-Cg7t_8qu.js";import{d as A,n as E,f as _,m as i,b as M,p as c}from"../packem_shared/table-DZAB8cs3.js";import{O as Y}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useAutoRefresh as B}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as F}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{jsx as t,jsxs as s}from"react/jsx-runtime";const G=2e3,H=new Set(["open"]),re=O=>{const e=z(41),{read:x}=O,n=F(),P=D();let S;e[0]!==P||e[1]!==x?(S=()=>Promise.resolve(x?x():P.debug()),e[0]=P,e[1]=x,e[2]=S):S=e[2];const W=S,R=x?"injected":"live";let v;e[3]!==R?(v=["lunora-studio","sync-client-debug",R],e[3]=R,e[4]=v):v=e[4];const{data:l,refetch:q}=Y(v,W);if(B(q,!0,G),!l){let r;e[5]!==n?(r=n("Reading the sync client's state…"),e[5]=n,e[6]=r):r=e[6];let y;e[7]!==n?(y=n("Sync client"),e[7]=n,e[8]=y):y=e[8];let w;return e[9]!==r||e[10]!==y?(w=t(K,{children:t(L,{children:t(j,{description:r,title:y})})}),e[9]=r,e[10]=y,e[11]=w):w=e[11],w}const{pendingWrites:b,shards:$,subscriptions:N}=l;let o;e[12]!==n?(o=n("This Studio session's sync client"),e[12]=n,e[13]=o):o=e[13];let d;e[14]!==o?(d=t("span",{className:"text-sm font-medium",children:o}),e[14]=o,e[15]=d):d=e[15];const T=l.connectionStatus==="connected"?"default":"secondary";let a;e[16]!==l.connectionStatus||e[17]!==T?(a=t(C,{variant:T,children:l.connectionStatus}),e[16]=l.connectionStatus,e[17]=T,e[18]=a):a=e[18];let h;e[19]!==b||e[20]!==n?(h=b>0?t(C,{variant:"secondary",children:n("{count} pending writes",{count:b})}):null,e[19]=b,e[20]=n,e[21]=h):h=e[21];let u;e[22]!==d||e[23]!==a||e[24]!==h?(u=s("div",{className:"flex flex-wrap items-center gap-2",children:[d,a,h]}),e[22]=d,e[23]=a,e[24]=h,e[25]=u):u=e[25];let m;e[26]!==n?(m=n("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=n,e[27]=m):m=e[27];let p;e[28]!==m?(p=t("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=p):p=e[29];let f;e[30]!==$||e[31]!==n?(f=$.length===0?t(j,{description:n("No shard connection has been opened yet."),title:n("No shards")}):s(A,{children:[t(E,{children:s(_,{children:[t(i,{children:n("Shard")}),t(i,{children:n("Socket")}),t(i,{children:n("Confirmed watermark")})]})}),t(M,{children:$.map(r=>s(_,{children:[t(c,{children:r.shardKey??n("(default)")}),t(c,{children:t(C,{variant:H.has(r.wsState)?"default":"secondary",children:r.wsState})}),t(c,{children:r.confirmedMutationWatermark})]},r.shardKey??"__default__"))})]}),e[30]=$,e[31]=n,e[32]=f):f=e[32];let g;e[33]!==N||e[34]!==n?(g=N.length===0?t(j,{description:n("This client holds no live queries or shapes."),title:n("No subscriptions")}):s(A,{children:[t(E,{children:s(_,{children:[t(i,{children:n("Subscription")}),t(i,{children:n("Kind")}),t(i,{children:n("Acked")}),t(i,{children:n("Cursor")}),t(i,{children:n("Pending overlays")})]})}),t(M,{children:N.map(r=>s(_,{children:[t(c,{className:"font-mono text-xs",children:r.functionPath}),t(c,{children:r.kind}),t(c,{children:t(C,{variant:r.acked?"default":"secondary",children:r.acked?n("yes"):n("no")})}),t(c,{children:r.serverCursor??"—"}),t(c,{children:r.pendingOptimisticLayers})]},r.id))})]}),e[33]=N,e[34]=n,e[35]=g):g=e[35];let k;return e[36]!==p||e[37]!==f||e[38]!==g||e[39]!==u?(k=t(K,{children:s(L,{className:"flex flex-col gap-4",children:[u,p,f,g]})}),e[36]=p,e[37]=f,e[38]=g,e[39]=u,e[40]=k):k=e[40],k};export{re as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as z}from"react/compiler-runtime";import{useState as W,useEffect as J}from"react";import{f as X}from"../packem_shared/log-fields-CoL3hsIQ.js";import{E as Y}from"../packem_shared/error-alert--Ie7ofJ0.js";import{L as Z}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as ee}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as te}from"../packem_shared/badge-BbuuAio7.js";import{E as re}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ae}from"../packem_shared/input-JHu63lTv.js";import{N as se}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as ne}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as le}from"../packem_shared/internal-zkEvTqy8.js";import{r as ie}from"../packem_shared/shard-history-DMEW5VBE.js";import{p as de,c as ce}from"../packem_shared/trace-handoff-Dw7mwjxu.js";import{c as me}from"../packem_shared/utils-bhneXptQ.js";import{jsx as s,jsxs as B}from"react/jsx-runtime";const Q=o=>Math.min(100,Math.max(0,o)),ue=(o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=Q(o.offsetMs/e*100),a=o.durationMs/e*100,r=Math.max(.5,Math.min(Q(a),100-t));return{leftPercent:t,widthPercent:r}},he=(o,e)=>{const t=e.trim().toLowerCase();return t===""?[...o]:o.filter(a=>a.rootName.toLowerCase().includes(t)||a.functionPath.toLowerCase().includes(t)||a.traceId.toLowerCase().includes(t))},U=o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"—",fe=14,pe=o=>Array.isArray(o?.traces)?o.traces:[],ge=o=>{const e=z(50),{span:t,traceDurationMs:a}=o,r=G();let n;e[0]!==t||e[1]!==a?(n=ue(t,a),e[0]=t,e[1]=a,e[2]=n):n=e[2];const{leftPercent:p,widthPercent:y}=n;let g;e[3]!==t.attributes?(g=X(t.attributes),e[3]=t.attributes,e[4]=g):g=e[4];const I=g,$=t.depth*fe;let P;e[5]!==$?(P={paddingLeft:$},e[5]=$,e[6]=P):P=e[6];const x=P,b=`${String(p)}%`,w=`${String(y)}%`;let l;e[7]!==b||e[8]!==w?(l={left:b,width:w},e[7]=b,e[8]=w,e[9]=l):l=e[9];const i=l,k=t.depth;let u;e[10]!==t.ok||e[11]!==r?(u=t.ok?null:s("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"●"}),e[10]=t.ok,e[11]=r,e[12]=u):u=e[12];let h;e[13]!==x||e[14]!==t.name||e[15]!==u?(h=B("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:x,title:t.name,children:[u,t.name]}),e[13]=x,e[14]=t.name,e[15]=u,e[16]=h):h=e[16];let d;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(d=r("starts {offset} in, runs {duration}",{duration:U(t.durationMs),offset:U(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=d):d=e[20];const N=t.ok?"bg-primary/70":"bg-destructive";let c;e[21]!==N?(c=me("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=c):c=e[22];let m;e[23]!==i||e[24]!==p||e[25]!==c||e[26]!==y?(m=s("span",{className:c,"data-left":p,"data-testid":"tr-span-bar","data-width":y,style:i}),e[23]=i,e[24]=p,e[25]=c,e[26]=y,e[27]=m):m=e[27];let f;e[28]!==d||e[29]!==m?(f=s("span",{"aria-label":d,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:m}),e[28]=d,e[29]=m,e[30]=f):f=e[30];let M;e[31]!==t.durationMs?(M=U(t.durationMs),e[31]=t.durationMs,e[32]=M):M=e[32];let v;e[33]!==M?(v=s("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:M}),e[33]=M,e[34]=v):v=e[34];let S;e[35]!==t.error?(S=t.error===void 0?null:s("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=S):S=e[36];let C;e[37]!==S?(C=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:S}),e[37]=S,e[38]=C):C=e[38];let T;e[39]!==I?(T=I===""?null:s("span",{"data-testid":"tr-span-attributes",title:I,children:I}),e[39]=I,e[40]=T):T=e[40];let K;e[41]!==T?(K=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:T}),e[41]=T,e[42]=K):K=e[42];let E;return e[43]!==t.depth||e[44]!==h||e[45]!==f||e[46]!==v||e[47]!==C||e[48]!==K?(E=B("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":k,"data-testid":"tr-span-row",role:"row",children:[h,f,v,C,K]}),e[43]=t.depth,e[44]=h,e[45]=f,e[46]=v,e[47]=C,e[48]=K,e[49]=E):E=e[49],E},xe=o=>{const e=z(50),{expanded:t,onToggle:a,trace:r}=o,n=G();let p;e[0]!==a||e[1]!==r.traceId?(p=()=>{a(r.traceId)},e[0]=a,e[1]=r.traceId,e[2]=p):p=e[2];const y=p,g=`tr-row-${r.traceId}`,I=`tr-waterfall-${r.traceId}`,$=`tr-toggle-${r.traceId}`,P=t?"▾":"▸";let x;e[3]!==P?(x=s("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:P}),e[3]=P,e[4]=x):x=e[4];let b;e[5]!==r.rootName?(b=s("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=b):b=e[6];let w;e[7]!==r.functionPath?(w=s("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let l;e[9]!==r.durationMs?(l=U(r.durationMs),e[9]=r.durationMs,e[10]=l):l=e[10];let i;e[11]!==l?(i=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:l}),e[11]=l,e[12]=i):i=e[12];let k;e[13]!==n||e[14]!==r.spans.length?(k=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=k):k=e[15];let u;e[16]!==k?(u=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:k}),e[16]=k,e[17]=u):u=e[17];const h=r.ok?"secondary":"destructive";let d;e[18]!==n||e[19]!==r.ok?(d=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=d):d=e[20];let N;e[21]!==h||e[22]!==d?(N=s("span",{className:"shrink-0",children:s(te,{variant:h,children:d})}),e[21]=h,e[22]=d,e[23]=N):N=e[23];let c;e[24]!==r.startTs?(c=le(r.startTs),e[24]=r.startTs,e[25]=c):c=e[25];let m;e[26]!==c?(m=s("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:c}),e[26]=c,e[27]=m):m=e[27];let f;e[28]!==t||e[29]!==y||e[30]!==i||e[31]!==u||e[32]!==N||e[33]!==m||e[34]!==I||e[35]!==$||e[36]!==x||e[37]!==b||e[38]!==w?(f=B("button",{"aria-controls":I,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":$,onClick:y,type:"button",children:[x,b,w,i,u,N,m]}),e[28]=t,e[29]=y,e[30]=i,e[31]=u,e[32]=N,e[33]=m,e[34]=I,e[35]=$,e[36]=x,e[37]=b,e[38]=w,e[39]=f):f=e[39];let M;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(M=t&&s("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(S=>s(ge,{span:S,traceDurationMs:r.durationMs},S.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=M):M=e[45];let v;return e[46]!==f||e[47]!==M||e[48]!==g?(v=B("div",{className:"border-b border-border last:border-b-0","data-testid":g,children:[f,M]}),e[46]=f,e[47]=M,e[48]=g,e[49]=v):v=e[49],v},je=o=>{const e=z(44),{initialShardKey:t}=o,a=G(),[r]=W(de),{queryShardKey:n,setShardKey:p,shardKey:y}=ne(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[g,I]=W(r?.traceId??""),[$,P]=W(be);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0],J(we,x);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b={},e[1]=b):b=e[1];let w;e[2]!==n?(w={live:!0,shardKey:n},e[2]=n,e[3]=w):w=e[3];const{data:l,error:i,errorSource:k,isLoading:u,liveError:h}=se(oe.getTraces,b,w);let d,N;e[4]!==l||e[5]!==n?(d=()=>{l!==void 0&&ie(n)},N=[l,n],e[4]=l,e[5]=n,e[6]=d,e[7]=N):(d=e[6],N=e[7]),J(d,N);let c;if(e[8]!==l||e[9]!==i||e[10]!==k||e[11]!==$||e[12]!==u||e[13]!==h||e[14]!==g||e[15]!==p||e[16]!==y||e[17]!==a){const m=pe(l),f=l?.total??m.length,M=f>m.length,v=he(m,g);let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=L=>{I(L.target.value)},e[19]=S):S=e[19];const C=S;let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=L=>{P(V=>{const H=new Set(V);return H.has(L)?H.delete(L):H.add(L),H})},e[20]=T):T=e[20];const K=T,E=i===null&&v.length===0&&!u;let F;e[21]!==p||e[22]!==y?(F=s(ee,{onChange:p,testId:"tr-shard-input",value:y}),e[21]=p,e[22]=y,e[23]=F):F=e[23];let A;e[24]!==a?(A=a("Search traces"),e[24]=a,e[25]=A):A=e[25];let D;e[26]!==a?(D=a("search trace or function"),e[26]=a,e[27]=D):D=e[27];let _;e[28]!==g||e[29]!==A||e[30]!==D?(_=s(ae,{"aria-label":A,className:"h-8 w-56","data-testid":"tr-search",onChange:C,placeholder:D,value:g}),e[28]=g,e[29]=A,e[30]=D,e[31]=_):_=e[31];let j;e[32]!==h?(j=s(Z,{message:h,prefix:"tr"}),e[32]=h,e[33]=j):j=e[33];let q;e[34]!==_||e[35]!==j||e[36]!==F?(q=B("div",{className:"flex flex-wrap items-center gap-2",children:[F,_,j]}),e[34]=_,e[35]=j,e[36]=F,e[37]=q):q=e[37];let O;e[38]!==i||e[39]!==k?(O=i!==null&&s(Y,{error:k,testId:"tr-error"}),e[38]=i,e[39]=k,e[40]=O):O=e[40];let R;e[41]!==E||e[42]!==a?(R=E&&s(re,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:a("No traces")}),e[41]=E,e[42]=a,e[43]=R):R=e[43],c=B("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[q,O,R,i===null&&M&&s("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:a("Showing the {shown} most recent of {total} traces in the buffer.",{shown:m.length,total:f})}),i===null&&v.length>0&&s("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:v.map(L=>s(xe,{expanded:$.has(L.traceId),onToggle:K,trace:L},L.traceId))})]}),e[8]=l,e[9]=i,e[10]=k,e[11]=$,e[12]=u,e[13]=h,e[14]=g,e[15]=p,e[16]=y,e[17]=a,e[18]=c}else c=e[18];return c};function be(){return new Set}function we(){ce()}export{je as TracesPanel};
|
|
1
|
+
import{c as z}from"react/compiler-runtime";import{useState as W,useEffect as J}from"react";import{f as X}from"../packem_shared/log-fields-CoL3hsIQ.js";import{U as Y}from"../packem_shared/error-alert-_2q2VtVG.js";import{L as Z}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as ee}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as te}from"../packem_shared/badge-BbuuAio7.js";import{E as re}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ae}from"../packem_shared/input-JHu63lTv.js";import{N as se}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as ne}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as le}from"../packem_shared/internal-zkEvTqy8.js";import{r as ie}from"../packem_shared/shard-history-DMEW5VBE.js";import{p as de,c as ce}from"../packem_shared/trace-handoff-CuZ6WGgo.js";import{c as me}from"../packem_shared/utils-bhneXptQ.js";import{jsx as s,jsxs as B}from"react/jsx-runtime";const Q=o=>Math.min(100,Math.max(0,o)),ue=(o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=Q(o.offsetMs/e*100),a=o.durationMs/e*100,r=Math.max(.5,Math.min(Q(a),100-t));return{leftPercent:t,widthPercent:r}},he=(o,e)=>{const t=e.trim().toLowerCase();return t===""?[...o]:o.filter(a=>a.rootName.toLowerCase().includes(t)||a.functionPath.toLowerCase().includes(t)||a.traceId.toLowerCase().includes(t))},H=o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"—",fe=14,pe=o=>Array.isArray(o?.traces)?o.traces:[],ge=o=>{const e=z(50),{span:t,traceDurationMs:a}=o,r=G();let n;e[0]!==t||e[1]!==a?(n=ue(t,a),e[0]=t,e[1]=a,e[2]=n):n=e[2];const{leftPercent:p,widthPercent:v}=n;let g;e[3]!==t.attributes?(g=X(t.attributes),e[3]=t.attributes,e[4]=g):g=e[4];const I=g,$=t.depth*fe;let P;e[5]!==$?(P={paddingLeft:$},e[5]=$,e[6]=P):P=e[6];const x=P,b=`${String(p)}%`,w=`${String(v)}%`;let l;e[7]!==b||e[8]!==w?(l={left:b,width:w},e[7]=b,e[8]=w,e[9]=l):l=e[9];const i=l,k=t.depth;let u;e[10]!==t.ok||e[11]!==r?(u=t.ok?null:s("span",{"aria-label":r("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"●"}),e[10]=t.ok,e[11]=r,e[12]=u):u=e[12];let h;e[13]!==x||e[14]!==t.name||e[15]!==u?(h=B("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:x,title:t.name,children:[u,t.name]}),e[13]=x,e[14]=t.name,e[15]=u,e[16]=h):h=e[16];let d;e[17]!==t.durationMs||e[18]!==t.offsetMs||e[19]!==r?(d=r("starts {offset} in, runs {duration}",{duration:H(t.durationMs),offset:H(t.offsetMs)}),e[17]=t.durationMs,e[18]=t.offsetMs,e[19]=r,e[20]=d):d=e[20];const N=t.ok?"bg-primary/70":"bg-destructive";let c;e[21]!==N?(c=me("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=c):c=e[22];let m;e[23]!==i||e[24]!==p||e[25]!==c||e[26]!==v?(m=s("span",{className:c,"data-left":p,"data-testid":"tr-span-bar","data-width":v,style:i}),e[23]=i,e[24]=p,e[25]=c,e[26]=v,e[27]=m):m=e[27];let f;e[28]!==d||e[29]!==m?(f=s("span",{"aria-label":d,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:m}),e[28]=d,e[29]=m,e[30]=f):f=e[30];let y;e[31]!==t.durationMs?(y=H(t.durationMs),e[31]=t.durationMs,e[32]=y):y=e[32];let M;e[33]!==y?(M=s("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:y}),e[33]=y,e[34]=M):M=e[34];let S;e[35]!==t.error?(S=t.error===void 0?null:s("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=S):S=e[36];let C;e[37]!==S?(C=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:S}),e[37]=S,e[38]=C):C=e[38];let T;e[39]!==I?(T=I===""?null:s("span",{"data-testid":"tr-span-attributes",title:I,children:I}),e[39]=I,e[40]=T):T=e[40];let K;e[41]!==T?(K=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:T}),e[41]=T,e[42]=K):K=e[42];let F;return e[43]!==t.depth||e[44]!==h||e[45]!==f||e[46]!==M||e[47]!==C||e[48]!==K?(F=B("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":k,"data-testid":"tr-span-row",role:"row",children:[h,f,M,C,K]}),e[43]=t.depth,e[44]=h,e[45]=f,e[46]=M,e[47]=C,e[48]=K,e[49]=F):F=e[49],F},xe=o=>{const e=z(50),{expanded:t,onToggle:a,trace:r}=o,n=G();let p;e[0]!==a||e[1]!==r.traceId?(p=()=>{a(r.traceId)},e[0]=a,e[1]=r.traceId,e[2]=p):p=e[2];const v=p,g=`tr-row-${r.traceId}`,I=`tr-waterfall-${r.traceId}`,$=`tr-toggle-${r.traceId}`,P=t?"▾":"▸";let x;e[3]!==P?(x=s("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:P}),e[3]=P,e[4]=x):x=e[4];let b;e[5]!==r.rootName?(b=s("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=b):b=e[6];let w;e[7]!==r.functionPath?(w=s("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let l;e[9]!==r.durationMs?(l=H(r.durationMs),e[9]=r.durationMs,e[10]=l):l=e[10];let i;e[11]!==l?(i=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:l}),e[11]=l,e[12]=i):i=e[12];let k;e[13]!==n||e[14]!==r.spans.length?(k=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=k):k=e[15];let u;e[16]!==k?(u=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:k}),e[16]=k,e[17]=u):u=e[17];const h=r.ok?"secondary":"destructive";let d;e[18]!==n||e[19]!==r.ok?(d=r.ok?n("ok"):n("error"),e[18]=n,e[19]=r.ok,e[20]=d):d=e[20];let N;e[21]!==h||e[22]!==d?(N=s("span",{className:"shrink-0",children:s(te,{variant:h,children:d})}),e[21]=h,e[22]=d,e[23]=N):N=e[23];let c;e[24]!==r.startTs?(c=le(r.startTs),e[24]=r.startTs,e[25]=c):c=e[25];let m;e[26]!==c?(m=s("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:c}),e[26]=c,e[27]=m):m=e[27];let f;e[28]!==t||e[29]!==v||e[30]!==i||e[31]!==u||e[32]!==N||e[33]!==m||e[34]!==I||e[35]!==$||e[36]!==x||e[37]!==b||e[38]!==w?(f=B("button",{"aria-controls":I,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":$,onClick:v,type:"button",children:[x,b,w,i,u,N,m]}),e[28]=t,e[29]=v,e[30]=i,e[31]=u,e[32]=N,e[33]=m,e[34]=I,e[35]=$,e[36]=x,e[37]=b,e[38]=w,e[39]=f):f=e[39];let y;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(y=t&&s("div",{"aria-label":n("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,role:"grid",children:r.spans.map(S=>s(ge,{span:S,traceDurationMs:r.durationMs},S.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=y):y=e[45];let M;return e[46]!==f||e[47]!==y||e[48]!==g?(M=B("div",{className:"border-b border-border last:border-b-0","data-testid":g,children:[f,y]}),e[46]=f,e[47]=y,e[48]=g,e[49]=M):M=e[49],M},Ae=o=>{const e=z(44),{initialShardKey:t}=o,a=G(),[r]=W(de),{queryShardKey:n,setShardKey:p,shardKey:v}=ne(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[g,I]=W(r?.traceId??""),[$,P]=W(be);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0],J(we,x);let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b={},e[1]=b):b=e[1];let w;e[2]!==n?(w={live:!0,shardKey:n},e[2]=n,e[3]=w):w=e[3];const{data:l,error:i,errorSource:k,isLoading:u,liveError:h}=se(oe.getTraces,b,w);let d,N;e[4]!==l||e[5]!==n?(d=()=>{l!==void 0&&ie(n)},N=[l,n],e[4]=l,e[5]=n,e[6]=d,e[7]=N):(d=e[6],N=e[7]),J(d,N);let c;if(e[8]!==l||e[9]!==i||e[10]!==k||e[11]!==$||e[12]!==u||e[13]!==h||e[14]!==g||e[15]!==p||e[16]!==v||e[17]!==a){const m=pe(l),f=l?.total??m.length,y=f>m.length,M=he(m,g);let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=L=>{I(L.target.value)},e[19]=S):S=e[19];const C=S;let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=L=>{P(V=>{const U=new Set(V);return U.has(L)?U.delete(L):U.add(L),U})},e[20]=T):T=e[20];const K=T,F=i===null&&M.length===0&&!u;let D;e[21]!==p||e[22]!==v?(D=s(ee,{onChange:p,testId:"tr-shard-input",value:v}),e[21]=p,e[22]=v,e[23]=D):D=e[23];let E;e[24]!==a?(E=a("Search traces"),e[24]=a,e[25]=E):E=e[25];let _;e[26]!==a?(_=a("search trace or function"),e[26]=a,e[27]=_):_=e[27];let j;e[28]!==g||e[29]!==E||e[30]!==_?(j=s(ae,{"aria-label":E,className:"h-8 w-56","data-testid":"tr-search",onChange:C,placeholder:_,value:g}),e[28]=g,e[29]=E,e[30]=_,e[31]=j):j=e[31];let A;e[32]!==h?(A=s(Z,{message:h,prefix:"tr"}),e[32]=h,e[33]=A):A=e[33];let q;e[34]!==j||e[35]!==A||e[36]!==D?(q=B("div",{className:"flex flex-wrap items-center gap-2",children:[D,j,A]}),e[34]=j,e[35]=A,e[36]=D,e[37]=q):q=e[37];let O;e[38]!==i||e[39]!==k?(O=i!==null&&s(Y,{error:k,testId:"tr-error"}),e[38]=i,e[39]=k,e[40]=O):O=e[40];let R;e[41]!==F||e[42]!==a?(R=F&&s(re,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:a("No traces")}),e[41]=F,e[42]=a,e[43]=R):R=e[43],c=B("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[q,O,R,i===null&&y&&s("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:a("Showing the {shown} most recent of {total} traces in the buffer.",{shown:m.length,total:f})}),i===null&&M.length>0&&s("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:M.map(L=>s(xe,{expanded:$.has(L.traceId),onToggle:K,trace:L},L.traceId))})]}),e[8]=l,e[9]=i,e[10]=k,e[11]=$,e[12]=u,e[13]=h,e[14]=g,e[15]=p,e[16]=v,e[17]=a,e[18]=c}else c=e[18];return c};function be(){return new Set}function we(){ce()}export{Ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as ge}from"@lunora/react";import{useState as $,useEffect as Ve}from"react";import{g as M}from"../packem_shared/badge-BbuuAio7.js";import{u as S}from"../packem_shared/button-BkCrNcAs.js";import{c as $e,u as Fe}from"../packem_shared/card-CIDGUN6K.js";import{E as Je}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as j}from"../packem_shared/input-JHu63lTv.js";import{n as Ue,d as Pe,m as L,p as z,f as Re,u as U}from"../packem_shared/table-DdJBrClo.js";import{O as Ke}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{c as Ne}from"react/compiler-runtime";import{u as Oe}from"../packem_shared/use-auth-config-0EnNCdLu.js";import{useAutoRefresh as We}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import Ze from"../packem_shared/useDebounced-CU-uftxO.js";import{useT as ke}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as Ie,h as Ae,f as _e,b as Ee}from"../packem_shared/internal-zkEvTqy8.js";import{f as Qe}from"../packem_shared/checkbox-StT4Gob6.js";import{p as V}from"../packem_shared/label-6uP1obNF.js";import{M as Ge}from"../packem_shared/modal-shell-CUwwWC2o.js";import{u as Xe}from"../packem_shared/use-async-submit-BFIMhRqh.js";import{jsx as t,jsxs as n,Fragment as Ye}from"react/jsx-runtime";const et=()=>{const u=Ne(3),{config:e,ready:s}=Oe();let l;return u[0]!==e.capabilities||u[1]!==s?(l={capabilities:e.capabilities,ready:s},u[0]=e.capabilities,u[1]=s,u[2]=l):l=u[2],l},tt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=(u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),lt=(u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;const s=typeof e=="string"?e.trim():"";if(s!==""){if(u.type==="number"){const l=Number(s);return Number.isNaN(l)?void 0:{value:l}}return{value:s}}},st=u=>{const e=Ne(105),{onClose:s,onCreated:l}=u,c=ge(),a=ke(),{config:o}=Oe(),{busy:r,error:i,run:m}=Xe(),[k,I]=$(""),[x,w]=$(""),[y,A]=$(""),[h,g]=$("");let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];const[f,d]=$(v);let C;e[1]===Symbol.for("react.memo_cache_sentinel")?(C=p=>{I(p.target.value)},e[1]=C):C=e[1];const b=C;let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=p=>{w(p.target.value)},e[2]=F):F=e[2];const T=F;let R;e[3]===Symbol.for("react.memo_cache_sentinel")?(R=p=>{A(p.target.value)},e[3]=R):R=e[3];const De=R;let O;e[4]===Symbol.for("react.memo_cache_sentinel")?(O=p=>{g(p.target.value)},e[4]=O):O=e[4];const je=O;let G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=(p,P)=>{d(q=>({...q,[p]:P}))},e[5]=G):G=e[5];const Se=G;let H;e[6]!==f?(H=p=>f[p.name]??(p.type==="boolean"?!1:""),e[6]=f,e[7]=H):H=e[7];const _=H;let J;if(e[8]!==o.userFields||e[9]!==_){let p;e[11]!==_?(p=P=>!P.required||at(P,_(P)),e[11]=_,e[12]=p):p=e[12],J=o.userFields.every(p),e[8]=o.userFields,e[9]=_,e[10]=J}else J=e[10];const we=J;let K;e[13]!==r||e[14]!==k||e[15]!==x||e[16]!==we?(K=!r&&k.trim()!==""&&x.trim()!==""&&we,e[13]=r,e[14]=k,e[15]=x,e[16]=we,e[17]=K):K=e[17];const Te=K;let W;e[18]!==o.userFields||e[19]!==_?(W=()=>{const p={};for(const P of o.userFields){const q=lt(P,_(P));q!==void 0&&(p[P.name]=q.value)}return Object.keys(p).length===0?void 0:p},e[18]=o.userFields,e[19]=_,e[20]=W):W=e[20];const Ce=W;let Z;e[21]!==Ce||e[22]!==c||e[23]!==k||e[24]!==x||e[25]!==s||e[26]!==l||e[27]!==y||e[28]!==h||e[29]!==m?(Z=()=>{m(async()=>{await c.createAuthUser({data:Ce(),email:k.trim(),name:x.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),l(),s()})},e[21]=Ce,e[22]=c,e[23]=k,e[24]=x,e[25]=s,e[26]=l,e[27]=y,e[28]=h,e[29]=m,e[30]=Z):Z=e[30];const N=Z;let D;e[31]!==a?(D=a("Create user"),e[31]=a,e[32]=D):D=e[32];let B;e[33]!==a?(B=a("Create user"),e[33]=a,e[34]=B):B=e[34];let E;e[35]!==B?(E=t("h2",{className:"text-sm font-semibold text-foreground",children:B}),e[35]=B,e[36]=E):E=e[36];let Q;e[37]!==a?(Q=a("email"),e[37]=a,e[38]=Q):Q=e[38];let X;e[39]!==Q?(X=t(V,{htmlFor:"uc-email",children:Q}),e[39]=Q,e[40]=X):X=e[40];let Y;e[41]!==k?(Y=t(j,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:k}),e[41]=k,e[42]=Y):Y=e[42];let ee;e[43]!==X||e[44]!==Y?(ee=n("div",{className:"flex flex-col gap-1",children:[X,Y]}),e[43]=X,e[44]=Y,e[45]=ee):ee=e[45];let te;e[46]!==a?(te=a("name"),e[46]=a,e[47]=te):te=e[47];let ae;e[48]!==te?(ae=t(V,{htmlFor:"uc-name",children:te}),e[48]=te,e[49]=ae):ae=e[49];let le;e[50]!==x?(le=t(j,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:x}),e[50]=x,e[51]=le):le=e[51];let se;e[52]!==ae||e[53]!==le?(se=n("div",{className:"flex flex-col gap-1",children:[ae,le]}),e[52]=ae,e[53]=le,e[54]=se):se=e[54];let re;e[55]!==a?(re=a("Password (optional)"),e[55]=a,e[56]=re):re=e[56];let ie;e[57]!==re?(ie=t(V,{htmlFor:"uc-password",children:re}),e[57]=re,e[58]=ie):ie=e[58];let ne;e[59]!==y?(ne=t(j,{"data-testid":"uc-password",id:"uc-password",onChange:De,type:"password",value:y}),e[59]=y,e[60]=ne):ne=e[60];let de;e[61]!==ie||e[62]!==ne?(de=n("div",{className:"flex flex-col gap-1",children:[ie,ne]}),e[61]=ie,e[62]=ne,e[63]=de):de=e[63];let oe;e[64]!==a?(oe=a("Role (optional)"),e[64]=a,e[65]=oe):oe=e[65];let ce;e[66]!==oe?(ce=t(V,{htmlFor:"uc-role",children:oe}),e[66]=oe,e[67]=ce):ce=e[67];let ue;e[68]!==h?(ue=t(j,{"data-testid":"uc-role",id:"uc-role",onChange:je,value:h}),e[68]=h,e[69]=ue):ue=e[69];let me;e[70]!==ce||e[71]!==ue?(me=n("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[70]=ce,e[71]=ue,e[72]=me):me=e[72];let he;e[73]!==o.userFields||e[74]!==_||e[75]!==a?(he=o.userFields.length>0&&n("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),o.userFields.map(p=>{const P=`uc-field-${p.name}`,q=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){const Me=_(p)===!0;return n("label",{className:"flex items-center gap-2",htmlFor:P,children:[t(Qe,{checked:Me,"data-testid":P,id:P,onCheckedChange:He=>{Se(p.name,He)}}),n("span",{className:"text-sm",children:[p.name,q]})]},p.name)}const qe=_(p);return n("div",{className:"flex flex-col gap-1",children:[n(V,{htmlFor:P,children:[p.name,q]}),t(j,{"data-testid":P,id:P,onChange:Me=>{Se(p.name,Me.target.value)},type:tt[p.type],value:typeof qe=="string"?qe:""})]},p.name)})]}),e[73]=o.userFields,e[74]=_,e[75]=a,e[76]=he):he=e[76];let pe;e[77]!==i?(pe=i!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:i}),e[77]=i,e[78]=pe):pe=e[78];let fe;e[79]!==a?(fe=a("Cancel"),e[79]=a,e[80]=fe):fe=e[80];let ve;e[81]!==s||e[82]!==fe?(ve=t(S,{"data-testid":"uc-cancel",onClick:s,size:"sm",type:"button",variant:"outline",children:fe}),e[81]=s,e[82]=fe,e[83]=ve):ve=e[83];const Be=!Te;let be;e[84]!==r||e[85]!==a?(be=a(r?"Creating…":"Create"),e[84]=r,e[85]=a,e[86]=be):be=e[86];let xe;e[87]!==N||e[88]!==Be||e[89]!==be?(xe=t(S,{"data-testid":"uc-submit",disabled:Be,onClick:N,size:"sm",type:"button",children:be}),e[87]=N,e[88]=Be,e[89]=be,e[90]=xe):xe=e[90];let ye;e[91]!==ve||e[92]!==xe?(ye=n("div",{className:"flex justify-end gap-2 pt-1",children:[ve,xe]}),e[91]=ve,e[92]=xe,e[93]=ye):ye=e[93];let ze;return e[94]!==s||e[95]!==D||e[96]!==E||e[97]!==ee||e[98]!==se||e[99]!==de||e[100]!==me||e[101]!==he||e[102]!==pe||e[103]!==ye?(ze=n(Ge,{label:D,onClose:s,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[E,ee,se,de,me,he,pe,ye]}),e[94]=s,e[95]=D,e[96]=E,e[97]=ee,e[98]=se,e[99]=de,e[100]=me,e[101]=he,e[102]=pe,e[103]=ye,e[104]=ze):ze=e[104],ze},Le=u=>{const e=Ne(2),{children:s}=u;let l;return e[0]!==s?(l=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s}),e[0]=s,e[1]=l):l=e[1],l},rt=u=>{const e=Ne(29),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{_e((async()=>{I(null);try{const b=await o.listAuthSessions({limit:50,userId:c});m(b.rows)}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l?(y=b=>{l(()=>o.revokeAuthSession({sessionId:b}))},e[7]=o,e[8]=l,e[9]=y):y=e[9];const A=y;let h;e[10]!==r?(h=r("Sessions"),e[10]=r,e[11]=h):h=e[11];let g;e[12]!==h?(g=t(Le,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:k}),e[14]=k,e[15]=v):v=e[15];let f;e[16]!==i||e[17]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:r("No active sessions.")}),e[16]=i,e[17]=r,e[18]=f):f=e[18];let d;e[19]!==s||e[20]!==A||e[21]!==i||e[22]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-sessions-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:r("expires")}),t(z,{children:r("ip")}),t(z,{children:r("user agent")}),t(z,{"aria-label":r("Actions")})]})}),t(Re,{children:i.map(b=>n(L,{"data-testid":`ud-session-${b.id}`,children:[t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.expiresAt)}),t(U,{children:b.ipAddress??""}),t(U,{className:"max-w-40 truncate",children:b.userAgent??""}),t(U,{children:t(S,{"data-testid":`ud-revoke-${b.id}`,disabled:s,onClick:()=>{A(b.id)},size:"xs",type:"button",variant:"ghost",children:r("Revoke")})})]},b.id))})]})})}),e[19]=s,e[20]=A,e[21]=i,e[22]=r,e[23]=d):d=e[23];let C;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=C):C=e[28],C},it=u=>{const e=Ne(30),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{_e((async()=>{I(null);try{m(await o.listAuthAccounts({userId:c}))}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l||e[9]!==c?(y=b=>{l(()=>o.unlinkAuthAccount({accountId:b,userId:c}))},e[7]=o,e[8]=l,e[9]=c,e[10]=y):y=e[10];const A=y;let h;e[11]!==r?(h=r("Linked accounts"),e[11]=r,e[12]=h):h=e[12];let g;e[13]!==h?(g=t(Le,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:k}),e[15]=k,e[16]=v):v=e[16];let f;e[17]!==i||e[18]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground",children:r("No linked accounts.")}),e[17]=i,e[18]=r,e[19]=f):f=e[19];let d;e[20]!==i||e[21]!==s||e[22]!==A||e[23]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-accounts-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:r("provider")}),t(z,{children:r("created")}),t(z,{"aria-label":r("Actions")})]})}),t(Re,{children:i.map(b=>{const F=Ae(b.id);return n(L,{"data-testid":`ud-account-${F}`,children:[t(U,{children:Ae(b.providerId)}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-unlink-${F}`,disabled:s,onClick:()=>{A(F)},size:"xs",type:"button",variant:"ghost",children:r("Unlink")})})]},F)})})]})})}),e[20]=i,e[21]=s,e[22]=A,e[23]=r,e[24]=d):d=e[24];let C;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=C):C=e[29],C},nt=u=>{const e=Ne(40),{busy:s,capabilities:l,runAction:c,userId:a,version:o}=u,r=ge(),i=ke(),[m,k]=$(null);let I;e[0]!==l.passkey||e[1]!==r||e[2]!==a?(I=()=>{l.passkey&&_e((async()=>{try{k(await r.listAuthPasskeys({userId:a}))}catch{k(null)}})())},e[0]=l.passkey,e[1]=r,e[2]=a,e[3]=I):I=e[3];let x;e[4]!==l.passkey||e[5]!==r||e[6]!==a||e[7]!==o?(x=[l.passkey,r,a,o],e[4]=l.passkey,e[5]=r,e[6]=a,e[7]=o,e[8]=x):x=e[8],Ve(I,x);let w;e[9]!==r||e[10]!==c||e[11]!==a?(w=()=>{c(()=>r.disableAuthTwoFactor({userId:a}))},e[9]=r,e[10]=c,e[11]=a,e[12]=w):w=e[12];const y=w;let A;e[13]!==r||e[14]!==c?(A=F=>{c(()=>r.deleteAuthPasskey({passkeyId:F}))},e[13]=r,e[14]=c,e[15]=A):A=e[15];const h=A;let g;e[16]!==i?(g=i("Security"),e[16]=i,e[17]=g):g=e[17];let v;e[18]!==g?(v=t(Le,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==s||e[21]!==l.twoFactor||e[22]!==y||e[23]!==i?(f=l.twoFactor&&t(S,{"data-testid":"ud-disable-2fa",disabled:s,onClick:y,size:"sm",type:"button",variant:"outline",children:i("Disable two-factor")}),e[20]=s,e[21]=l.twoFactor,e[22]=y,e[23]=i,e[24]=f):f=e[24];let d;e[25]!==l.passkey||e[26]!==m||e[27]!==i?(d=l.passkey&&m!==null&&m.length===0&&t("p",{className:"text-sm text-muted-foreground",children:i("No passkeys.")}),e[25]=l.passkey,e[26]=m,e[27]=i,e[28]=d):d=e[28];let C;e[29]!==s||e[30]!==l.passkey||e[31]!==h||e[32]!==m||e[33]!==i?(C=l.passkey&&m!==null&&m.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-passkeys-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:i("name")}),t(z,{children:i("created")}),t(z,{"aria-label":i("Actions")})]})}),t(Re,{children:m.map(F=>{const T=Ae(F.id);return n(L,{"data-testid":`ud-passkey-${T}`,children:[t(U,{children:Ae(F.name)||T}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-delete-passkey-${T}`,disabled:s,onClick:()=>{h(T)},size:"xs",type:"button",variant:"ghost",children:i("Delete")})})]},T)})})]})})}),e[29]=s,e[30]=l.passkey,e[31]=h,e[32]=m,e[33]=i,e[34]=C):C=e[34];let b;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==C?(b=n("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,C]}),e[35]=v,e[36]=f,e[37]=d,e[38]=C,e[39]=b):b=e[39],b},dt=/(?:at|expires)$/iu,ot=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ct=(u,e)=>typeof e=="number"&&dt.test(u)?Ie(e):Ae(e),ut=({capabilities:u,onChanged:e,onClose:s,user:l})=>{const c=ge(),a=ke(),o=l.banned===!0,[r,i]=$(null),[m,k]=$(!1),[I,x]=$(0),[w,y]=$(typeof l.role=="string"?l.role:""),[A,h]=$(""),[g,v]=$(""),[f,d]=$(""),[C,b]=$(null),[F,T]=$(!1),R=(N,D)=>{_e((async()=>{k(!0),i(null);try{const B=await N();D?.refresh!==!1&&(x(E=>E+1),e()),D?.onResult?.(B)}catch(B){i(Ee(B))}k(!1)})())},De=N=>{y(N.target.value)},O=N=>{h(N.target.value)},je=N=>{v(N.target.value)},G=N=>{d(N.target.value)},Se=()=>{const N=w.trim();N!==""&&R(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},H=()=>{const N=Number.parseInt(g,10),D=Number.isFinite(N)&&N>0?N*86400:void 0;R(async()=>{await c.banAuthUser({expiresInSeconds:D,reason:A.trim()===""?void 0:A.trim(),userId:l.id})})},_=()=>{R(async()=>{await c.unbanAuthUser({userId:l.id})})},J=()=>{R(async()=>{await c.setAuthUserPassword({newPassword:f,userId:l.id}),d("")})},we=()=>{R(()=>c.impersonateAuthUser({userId:l.id}),{onResult:N=>{b(N.token)},refresh:!1})},K=()=>{R(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},Te=()=>{R(async()=>{await c.removeAuthUser({userId:l.id}),s()})},W=()=>{T(!0)},Ce=()=>{T(!1)},Z=Object.entries(l).filter(([N])=>!ot.has(N));return n(Ge,{label:a("User details"),onClose:s,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[n("div",{className:"flex items-start justify-between gap-2",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),n("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&t(M,{variant:"secondary",children:l.role}),o?t(M,{variant:"destructive",children:a("Banned")}):t(M,{variant:"outline",children:a("Active")}),l.emailVerified===!0?t(M,{variant:"secondary",children:a("verified")}):t(M,{variant:"outline",children:a("unverified")})]})]}),t(S,{"data-testid":"ud-close",onClick:s,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),r!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:r}),u.admin&&n($e,{className:"gap-0 py-0",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),n(Fe,{className:"flex flex-col gap-3 p-3",children:[n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-role",children:a("Role")}),t(j,{"data-testid":"ud-role-input",id:"ud-role",onChange:De,value:w})]}),t(S,{"data-testid":"ud-set-role",disabled:m||w.trim()==="",onClick:Se,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?t(S,{"data-testid":"ud-unban",disabled:m,onClick:_,size:"sm",type:"button",variant:"outline",children:a("Unban")}):n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),t(j,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:O,value:A})]}),n("div",{className:"flex w-24 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-days",children:a("Days")}),t(j,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:je,type:"number",value:g})]}),t(S,{"data-testid":"ud-ban",disabled:m,onClick:H,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-password",children:a("New password")}),t(j,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:f})]}),t(S,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:J,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),n("div",{className:"flex flex-wrap gap-2",children:[t(S,{"data-testid":"ud-impersonate",disabled:m,onClick:we,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),t(S,{"data-testid":"ud-revoke-all",disabled:m,onClick:K,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?n(Ye,{children:[t(S,{"data-testid":"ud-delete-confirm",disabled:m,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),t(S,{"data-testid":"ud-delete-cancel",onClick:Ce,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):t(S,{"data-testid":"ud-delete",disabled:m,onClick:W,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),C!==null&&n("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(V,{htmlFor:"ud-token",children:a("Impersonation token")}),t(j,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:C})]})]})]}),t(rt,{busy:m,runAction:R,userId:l.id,version:I}),u.accounts&&t(it,{busy:m,runAction:R,userId:l.id,version:I}),(u.twoFactor||u.passkey)&&t(nt,{busy:m,capabilities:u,runAction:R,userId:l.id,version:I}),n("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),t("dl",{className:"flex flex-col",children:Z.map(([N,D])=>n("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),t("dd",{className:"m-0 font-mono text-xs break-words",children:ct(N,D)})]},N))})]})]})},mt=50,Rt=({pageSize:u=mt}={})=>{const e=ge(),s=ke(),[l,c]=$(""),[a,o]=$(""),r=Ze(l),[i,m]=$(null),[k,I]=$(!1),{capabilities:x}=et(),w=r.trim(),y=a.trim(),A=Ke(["lunora-auth-users",w,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:w===""?void 0:w}),{keepPreviousData:!0}),h=A.data?.rows??null,g=A.error,v=()=>{A.refetch()};We(()=>{A.refetch()},!0);const f=i===null?null:h?.find(d=>d.id===i)??null;return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(j,{"aria-label":s("Search users"),className:"w-56","data-testid":"us-search",onChange:d=>{c(d.target.value)},placeholder:s("Search by email or name…"),value:l}),t(j,{"aria-label":s("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:d=>{o(d.target.value)},placeholder:s("Filter by role"),value:a}),t(S,{"data-testid":"us-new",onClick:()=>{I(!0)},size:"sm",type:"button",children:s("New user")})]}),g!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&t(Je,{description:s("Users who sign up to your app will appear here."),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:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:s("No users.")}),h!==null&&h.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"us-table",children:[t(Pe,{children:n(L,{children:[t(z,{children:s("id")}),t(z,{children:s("email")}),t(z,{children:s("name")}),t(z,{children:s("role")}),t(z,{children:s("status")}),t(z,{children:s("verified")}),t(z,{children:s("created")}),t(z,{"aria-label":s("Actions")})]})}),t(Re,{children:h.map(d=>n(L,{"data-testid":`us-row-${d.id}`,children:[t(U,{className:"font-mono text-xs",children:d.id}),t(U,{children:d.email??""}),t(U,{children:d.name??""}),t(U,{children:typeof d.role=="string"&&d.role!==""?t(M,{variant:"secondary",children:d.role}):""}),t(U,{children:d.banned===!0?t(M,{variant:"destructive",children:s("Banned")}):t(M,{variant:"success",children:s("Active")})}),t(U,{children:d.emailVerified===!0?t(M,{variant:"success",children:s("yes")}):t(M,{variant:"outline",children:s("no")})}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),t(U,{children:t(S,{"data-testid":`us-manage-${d.id}`,onClick:()=>{m(d.id)},size:"xs",type:"button",variant:"ghost",children:s("Manage")})})]},d.id))})]})})}),f!==null&&t(ut,{capabilities:x,onChanged:v,onClose:()=>{m(null)},user:f}),k&&t(st,{onClose:()=>{I(!1)},onCreated:v})]})};export{Rt as UsersPanel};
|
|
1
|
+
import{useLunora as ge}from"@lunora/react";import{useState as $,useEffect as Ve}from"react";import{g as M}from"../packem_shared/badge-BbuuAio7.js";import{u as S}from"../packem_shared/button-BkCrNcAs.js";import{c as $e,f as Fe}from"../packem_shared/card-BMKx5UdA.js";import{E as Je}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as j}from"../packem_shared/input-JHu63lTv.js";import{d as Ue,n as _e,f as L,m as z,b as Pe,p as U}from"../packem_shared/table-DZAB8cs3.js";import{O as Ke}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{c as Ne}from"react/compiler-runtime";import{u as Oe}from"../packem_shared/use-auth-config-0EnNCdLu.js";import{useAutoRefresh as We}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import Ze from"../packem_shared/useDebounced-CU-uftxO.js";import{useT as ke}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as Ie,h as Ae,f as Re,b as Ee}from"../packem_shared/internal-zkEvTqy8.js";import{f as Qe}from"../packem_shared/checkbox-StT4Gob6.js";import{p as V}from"../packem_shared/label-6uP1obNF.js";import{M as Ge}from"../packem_shared/modal-shell-CUwwWC2o.js";import{_ as Xe}from"../packem_shared/use-async-submit-B32whHJO.js";import{jsx as t,jsxs as n,Fragment as Ye}from"react/jsx-runtime";const et=()=>{const u=Ne(3),{config:e,ready:s}=Oe();let l;return u[0]!==e.capabilities||u[1]!==s?(l={capabilities:e.capabilities,ready:s},u[0]=e.capabilities,u[1]=s,u[2]=l):l=u[2],l},tt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=(u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),lt=(u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;const s=typeof e=="string"?e.trim():"";if(s!==""){if(u.type==="number"){const l=Number(s);return Number.isNaN(l)?void 0:{value:l}}return{value:s}}},st=u=>{const e=Ne(105),{onClose:s,onCreated:l}=u,c=ge(),a=ke(),{config:o}=Oe(),{busy:r,error:i,run:m}=Xe(),[k,I]=$(""),[x,w]=$(""),[y,A]=$(""),[h,g]=$("");let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];const[f,d]=$(v);let C;e[1]===Symbol.for("react.memo_cache_sentinel")?(C=p=>{I(p.target.value)},e[1]=C):C=e[1];const b=C;let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=p=>{w(p.target.value)},e[2]=F):F=e[2];const T=F;let P;e[3]===Symbol.for("react.memo_cache_sentinel")?(P=p=>{A(p.target.value)},e[3]=P):P=e[3];const De=P;let O;e[4]===Symbol.for("react.memo_cache_sentinel")?(O=p=>{g(p.target.value)},e[4]=O):O=e[4];const je=O;let G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=(p,_)=>{d(q=>({...q,[p]:_}))},e[5]=G):G=e[5];const Se=G;let H;e[6]!==f?(H=p=>f[p.name]??(p.type==="boolean"?!1:""),e[6]=f,e[7]=H):H=e[7];const R=H;let J;if(e[8]!==o.userFields||e[9]!==R){let p;e[11]!==R?(p=_=>!_.required||at(_,R(_)),e[11]=R,e[12]=p):p=e[12],J=o.userFields.every(p),e[8]=o.userFields,e[9]=R,e[10]=J}else J=e[10];const we=J;let K;e[13]!==r||e[14]!==k||e[15]!==x||e[16]!==we?(K=!r&&k.trim()!==""&&x.trim()!==""&&we,e[13]=r,e[14]=k,e[15]=x,e[16]=we,e[17]=K):K=e[17];const Te=K;let W;e[18]!==o.userFields||e[19]!==R?(W=()=>{const p={};for(const _ of o.userFields){const q=lt(_,R(_));q!==void 0&&(p[_.name]=q.value)}return Object.keys(p).length===0?void 0:p},e[18]=o.userFields,e[19]=R,e[20]=W):W=e[20];const Ce=W;let Z;e[21]!==Ce||e[22]!==c||e[23]!==k||e[24]!==x||e[25]!==s||e[26]!==l||e[27]!==y||e[28]!==h||e[29]!==m?(Z=()=>{m(async()=>{await c.createAuthUser({data:Ce(),email:k.trim(),name:x.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),l(),s()})},e[21]=Ce,e[22]=c,e[23]=k,e[24]=x,e[25]=s,e[26]=l,e[27]=y,e[28]=h,e[29]=m,e[30]=Z):Z=e[30];const N=Z;let D;e[31]!==a?(D=a("Create user"),e[31]=a,e[32]=D):D=e[32];let B;e[33]!==a?(B=a("Create user"),e[33]=a,e[34]=B):B=e[34];let E;e[35]!==B?(E=t("h2",{className:"text-sm font-semibold text-foreground",children:B}),e[35]=B,e[36]=E):E=e[36];let Q;e[37]!==a?(Q=a("email"),e[37]=a,e[38]=Q):Q=e[38];let X;e[39]!==Q?(X=t(V,{htmlFor:"uc-email",children:Q}),e[39]=Q,e[40]=X):X=e[40];let Y;e[41]!==k?(Y=t(j,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:k}),e[41]=k,e[42]=Y):Y=e[42];let ee;e[43]!==X||e[44]!==Y?(ee=n("div",{className:"flex flex-col gap-1",children:[X,Y]}),e[43]=X,e[44]=Y,e[45]=ee):ee=e[45];let te;e[46]!==a?(te=a("name"),e[46]=a,e[47]=te):te=e[47];let ae;e[48]!==te?(ae=t(V,{htmlFor:"uc-name",children:te}),e[48]=te,e[49]=ae):ae=e[49];let le;e[50]!==x?(le=t(j,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:x}),e[50]=x,e[51]=le):le=e[51];let se;e[52]!==ae||e[53]!==le?(se=n("div",{className:"flex flex-col gap-1",children:[ae,le]}),e[52]=ae,e[53]=le,e[54]=se):se=e[54];let re;e[55]!==a?(re=a("Password (optional)"),e[55]=a,e[56]=re):re=e[56];let ie;e[57]!==re?(ie=t(V,{htmlFor:"uc-password",children:re}),e[57]=re,e[58]=ie):ie=e[58];let ne;e[59]!==y?(ne=t(j,{"data-testid":"uc-password",id:"uc-password",onChange:De,type:"password",value:y}),e[59]=y,e[60]=ne):ne=e[60];let de;e[61]!==ie||e[62]!==ne?(de=n("div",{className:"flex flex-col gap-1",children:[ie,ne]}),e[61]=ie,e[62]=ne,e[63]=de):de=e[63];let oe;e[64]!==a?(oe=a("Role (optional)"),e[64]=a,e[65]=oe):oe=e[65];let ce;e[66]!==oe?(ce=t(V,{htmlFor:"uc-role",children:oe}),e[66]=oe,e[67]=ce):ce=e[67];let ue;e[68]!==h?(ue=t(j,{"data-testid":"uc-role",id:"uc-role",onChange:je,value:h}),e[68]=h,e[69]=ue):ue=e[69];let me;e[70]!==ce||e[71]!==ue?(me=n("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[70]=ce,e[71]=ue,e[72]=me):me=e[72];let he;e[73]!==o.userFields||e[74]!==R||e[75]!==a?(he=o.userFields.length>0&&n("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),o.userFields.map(p=>{const _=`uc-field-${p.name}`,q=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){const Me=R(p)===!0;return n("label",{className:"flex items-center gap-2",htmlFor:_,children:[t(Qe,{checked:Me,"data-testid":_,id:_,onCheckedChange:He=>{Se(p.name,He)}}),n("span",{className:"text-sm",children:[p.name,q]})]},p.name)}const qe=R(p);return n("div",{className:"flex flex-col gap-1",children:[n(V,{htmlFor:_,children:[p.name,q]}),t(j,{"data-testid":_,id:_,onChange:Me=>{Se(p.name,Me.target.value)},type:tt[p.type],value:typeof qe=="string"?qe:""})]},p.name)})]}),e[73]=o.userFields,e[74]=R,e[75]=a,e[76]=he):he=e[76];let pe;e[77]!==i?(pe=i!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:i}),e[77]=i,e[78]=pe):pe=e[78];let fe;e[79]!==a?(fe=a("Cancel"),e[79]=a,e[80]=fe):fe=e[80];let ve;e[81]!==s||e[82]!==fe?(ve=t(S,{"data-testid":"uc-cancel",onClick:s,size:"sm",type:"button",variant:"outline",children:fe}),e[81]=s,e[82]=fe,e[83]=ve):ve=e[83];const Be=!Te;let be;e[84]!==r||e[85]!==a?(be=a(r?"Creating…":"Create"),e[84]=r,e[85]=a,e[86]=be):be=e[86];let xe;e[87]!==N||e[88]!==Be||e[89]!==be?(xe=t(S,{"data-testid":"uc-submit",disabled:Be,onClick:N,size:"sm",type:"button",children:be}),e[87]=N,e[88]=Be,e[89]=be,e[90]=xe):xe=e[90];let ye;e[91]!==ve||e[92]!==xe?(ye=n("div",{className:"flex justify-end gap-2 pt-1",children:[ve,xe]}),e[91]=ve,e[92]=xe,e[93]=ye):ye=e[93];let ze;return e[94]!==s||e[95]!==D||e[96]!==E||e[97]!==ee||e[98]!==se||e[99]!==de||e[100]!==me||e[101]!==he||e[102]!==pe||e[103]!==ye?(ze=n(Ge,{label:D,onClose:s,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[E,ee,se,de,me,he,pe,ye]}),e[94]=s,e[95]=D,e[96]=E,e[97]=ee,e[98]=se,e[99]=de,e[100]=me,e[101]=he,e[102]=pe,e[103]=ye,e[104]=ze):ze=e[104],ze},Le=u=>{const e=Ne(2),{children:s}=u;let l;return e[0]!==s?(l=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s}),e[0]=s,e[1]=l):l=e[1],l},rt=u=>{const e=Ne(29),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{Re((async()=>{I(null);try{const b=await o.listAuthSessions({limit:50,userId:c});m(b.rows)}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l?(y=b=>{l(()=>o.revokeAuthSession({sessionId:b}))},e[7]=o,e[8]=l,e[9]=y):y=e[9];const A=y;let h;e[10]!==r?(h=r("Sessions"),e[10]=r,e[11]=h):h=e[11];let g;e[12]!==h?(g=t(Le,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:k}),e[14]=k,e[15]=v):v=e[15];let f;e[16]!==i||e[17]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:r("No active sessions.")}),e[16]=i,e[17]=r,e[18]=f):f=e[18];let d;e[19]!==s||e[20]!==A||e[21]!==i||e[22]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-sessions-table",children:[t(_e,{children:n(L,{children:[t(z,{children:r("expires")}),t(z,{children:r("ip")}),t(z,{children:r("user agent")}),t(z,{"aria-label":r("Actions")})]})}),t(Pe,{children:i.map(b=>n(L,{"data-testid":`ud-session-${b.id}`,children:[t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.expiresAt)}),t(U,{children:b.ipAddress??""}),t(U,{className:"max-w-40 truncate",children:b.userAgent??""}),t(U,{children:t(S,{"data-testid":`ud-revoke-${b.id}`,disabled:s,onClick:()=>{A(b.id)},size:"xs",type:"button",variant:"ghost",children:r("Revoke")})})]},b.id))})]})})}),e[19]=s,e[20]=A,e[21]=i,e[22]=r,e[23]=d):d=e[23];let C;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=C):C=e[28],C},it=u=>{const e=Ne(30),{busy:s,runAction:l,userId:c,version:a}=u,o=ge(),r=ke(),[i,m]=$(null),[k,I]=$(null);let x;e[0]!==o||e[1]!==c?(x=()=>{Re((async()=>{I(null);try{m(await o.listAuthAccounts({userId:c}))}catch(b){const F=b;m(null),I(Ee(F))}})())},e[0]=o,e[1]=c,e[2]=x):x=e[2];let w;e[3]!==o||e[4]!==c||e[5]!==a?(w=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=w):w=e[6],Ve(x,w);let y;e[7]!==o||e[8]!==l||e[9]!==c?(y=b=>{l(()=>o.unlinkAuthAccount({accountId:b,userId:c}))},e[7]=o,e[8]=l,e[9]=c,e[10]=y):y=e[10];const A=y;let h;e[11]!==r?(h=r("Linked accounts"),e[11]=r,e[12]=h):h=e[12];let g;e[13]!==h?(g=t(Le,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==k?(v=k!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:k}),e[15]=k,e[16]=v):v=e[16];let f;e[17]!==i||e[18]!==r?(f=i!==null&&i.length===0&&t("p",{className:"text-sm text-muted-foreground",children:r("No linked accounts.")}),e[17]=i,e[18]=r,e[19]=f):f=e[19];let d;e[20]!==i||e[21]!==s||e[22]!==A||e[23]!==r?(d=i!==null&&i.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-accounts-table",children:[t(_e,{children:n(L,{children:[t(z,{children:r("provider")}),t(z,{children:r("created")}),t(z,{"aria-label":r("Actions")})]})}),t(Pe,{children:i.map(b=>{const F=Ae(b.id);return n(L,{"data-testid":`ud-account-${F}`,children:[t(U,{children:Ae(b.providerId)}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(b.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-unlink-${F}`,disabled:s,onClick:()=>{A(F)},size:"xs",type:"button",variant:"ghost",children:r("Unlink")})})]},F)})})]})})}),e[20]=i,e[21]=s,e[22]=A,e[23]=r,e[24]=d):d=e[24];let C;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(C=n("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=C):C=e[29],C},nt=u=>{const e=Ne(40),{busy:s,capabilities:l,runAction:c,userId:a,version:o}=u,r=ge(),i=ke(),[m,k]=$(null);let I;e[0]!==l.passkey||e[1]!==r||e[2]!==a?(I=()=>{l.passkey&&Re((async()=>{try{k(await r.listAuthPasskeys({userId:a}))}catch{k(null)}})())},e[0]=l.passkey,e[1]=r,e[2]=a,e[3]=I):I=e[3];let x;e[4]!==l.passkey||e[5]!==r||e[6]!==a||e[7]!==o?(x=[l.passkey,r,a,o],e[4]=l.passkey,e[5]=r,e[6]=a,e[7]=o,e[8]=x):x=e[8],Ve(I,x);let w;e[9]!==r||e[10]!==c||e[11]!==a?(w=()=>{c(()=>r.disableAuthTwoFactor({userId:a}))},e[9]=r,e[10]=c,e[11]=a,e[12]=w):w=e[12];const y=w;let A;e[13]!==r||e[14]!==c?(A=F=>{c(()=>r.deleteAuthPasskey({passkeyId:F}))},e[13]=r,e[14]=c,e[15]=A):A=e[15];const h=A;let g;e[16]!==i?(g=i("Security"),e[16]=i,e[17]=g):g=e[17];let v;e[18]!==g?(v=t(Le,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==s||e[21]!==l.twoFactor||e[22]!==y||e[23]!==i?(f=l.twoFactor&&t(S,{"data-testid":"ud-disable-2fa",disabled:s,onClick:y,size:"sm",type:"button",variant:"outline",children:i("Disable two-factor")}),e[20]=s,e[21]=l.twoFactor,e[22]=y,e[23]=i,e[24]=f):f=e[24];let d;e[25]!==l.passkey||e[26]!==m||e[27]!==i?(d=l.passkey&&m!==null&&m.length===0&&t("p",{className:"text-sm text-muted-foreground",children:i("No passkeys.")}),e[25]=l.passkey,e[26]=m,e[27]=i,e[28]=d):d=e[28];let C;e[29]!==s||e[30]!==l.passkey||e[31]!==h||e[32]!==m||e[33]!==i?(C=l.passkey&&m!==null&&m.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"ud-passkeys-table",children:[t(_e,{children:n(L,{children:[t(z,{children:i("name")}),t(z,{children:i("created")}),t(z,{"aria-label":i("Actions")})]})}),t(Pe,{children:m.map(F=>{const T=Ae(F.id);return n(L,{"data-testid":`ud-passkey-${T}`,children:[t(U,{children:Ae(F.name)||T}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),t(U,{children:t(S,{"data-testid":`ud-delete-passkey-${T}`,disabled:s,onClick:()=>{h(T)},size:"xs",type:"button",variant:"ghost",children:i("Delete")})})]},T)})})]})})}),e[29]=s,e[30]=l.passkey,e[31]=h,e[32]=m,e[33]=i,e[34]=C):C=e[34];let b;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==C?(b=n("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,C]}),e[35]=v,e[36]=f,e[37]=d,e[38]=C,e[39]=b):b=e[39],b},dt=/(?:at|expires)$/iu,ot=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ct=(u,e)=>typeof e=="number"&&dt.test(u)?Ie(e):Ae(e),ut=({capabilities:u,onChanged:e,onClose:s,user:l})=>{const c=ge(),a=ke(),o=l.banned===!0,[r,i]=$(null),[m,k]=$(!1),[I,x]=$(0),[w,y]=$(typeof l.role=="string"?l.role:""),[A,h]=$(""),[g,v]=$(""),[f,d]=$(""),[C,b]=$(null),[F,T]=$(!1),P=(N,D)=>{Re((async()=>{k(!0),i(null);try{const B=await N();D?.refresh!==!1&&(x(E=>E+1),e()),D?.onResult?.(B)}catch(B){i(Ee(B))}k(!1)})())},De=N=>{y(N.target.value)},O=N=>{h(N.target.value)},je=N=>{v(N.target.value)},G=N=>{d(N.target.value)},Se=()=>{const N=w.trim();N!==""&&P(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},H=()=>{const N=Number.parseInt(g,10),D=Number.isFinite(N)&&N>0?N*86400:void 0;P(async()=>{await c.banAuthUser({expiresInSeconds:D,reason:A.trim()===""?void 0:A.trim(),userId:l.id})})},R=()=>{P(async()=>{await c.unbanAuthUser({userId:l.id})})},J=()=>{P(async()=>{await c.setAuthUserPassword({newPassword:f,userId:l.id}),d("")})},we=()=>{P(()=>c.impersonateAuthUser({userId:l.id}),{onResult:N=>{b(N.token)},refresh:!1})},K=()=>{P(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},Te=()=>{P(async()=>{await c.removeAuthUser({userId:l.id}),s()})},W=()=>{T(!0)},Ce=()=>{T(!1)},Z=Object.entries(l).filter(([N])=>!ot.has(N));return n(Ge,{label:a("User details"),onClose:s,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[n("div",{className:"flex items-start justify-between gap-2",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),n("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&t(M,{variant:"secondary",children:l.role}),o?t(M,{variant:"destructive",children:a("Banned")}):t(M,{variant:"outline",children:a("Active")}),l.emailVerified===!0?t(M,{variant:"secondary",children:a("verified")}):t(M,{variant:"outline",children:a("unverified")})]})]}),t(S,{"data-testid":"ud-close",onClick:s,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),r!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:r}),u.admin&&n($e,{className:"gap-0 py-0",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),n(Fe,{className:"flex flex-col gap-3 p-3",children:[n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-role",children:a("Role")}),t(j,{"data-testid":"ud-role-input",id:"ud-role",onChange:De,value:w})]}),t(S,{"data-testid":"ud-set-role",disabled:m||w.trim()==="",onClick:Se,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?t(S,{"data-testid":"ud-unban",disabled:m,onClick:R,size:"sm",type:"button",variant:"outline",children:a("Unban")}):n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),t(j,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:O,value:A})]}),n("div",{className:"flex w-24 flex-col gap-1",children:[t(V,{htmlFor:"ud-ban-days",children:a("Days")}),t(j,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:je,type:"number",value:g})]}),t(S,{"data-testid":"ud-ban",disabled:m,onClick:H,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),n("div",{className:"flex items-end gap-2",children:[n("div",{className:"flex flex-1 flex-col gap-1",children:[t(V,{htmlFor:"ud-password",children:a("New password")}),t(j,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:f})]}),t(S,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:J,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),n("div",{className:"flex flex-wrap gap-2",children:[t(S,{"data-testid":"ud-impersonate",disabled:m,onClick:we,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),t(S,{"data-testid":"ud-revoke-all",disabled:m,onClick:K,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?n(Ye,{children:[t(S,{"data-testid":"ud-delete-confirm",disabled:m,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),t(S,{"data-testid":"ud-delete-cancel",onClick:Ce,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):t(S,{"data-testid":"ud-delete",disabled:m,onClick:W,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),C!==null&&n("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(V,{htmlFor:"ud-token",children:a("Impersonation token")}),t(j,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:C})]})]})]}),t(rt,{busy:m,runAction:P,userId:l.id,version:I}),u.accounts&&t(it,{busy:m,runAction:P,userId:l.id,version:I}),(u.twoFactor||u.passkey)&&t(nt,{busy:m,capabilities:u,runAction:P,userId:l.id,version:I}),n("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),t("dl",{className:"flex flex-col",children:Z.map(([N,D])=>n("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),t("dd",{className:"m-0 font-mono text-xs break-words",children:ct(N,D)})]},N))})]})]})},mt=50,Pt=({pageSize:u=mt}={})=>{const e=ge(),s=ke(),[l,c]=$(""),[a,o]=$(""),r=Ze(l),[i,m]=$(null),[k,I]=$(!1),{capabilities:x}=et(),w=r.trim(),y=a.trim(),A=Ke(["lunora-auth-users",w,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:w===""?void 0:w}),{keepPreviousData:!0}),h=A.data?.rows??null,g=A.error,v=()=>{A.refetch()};We(()=>{A.refetch()},!0);const f=i===null?null:h?.find(d=>d.id===i)??null;return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(j,{"aria-label":s("Search users"),className:"w-56","data-testid":"us-search",onChange:d=>{c(d.target.value)},placeholder:s("Search by email or name…"),value:l}),t(j,{"aria-label":s("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:d=>{o(d.target.value)},placeholder:s("Filter by role"),value:a}),t(S,{"data-testid":"us-new",onClick:()=>{I(!0)},size:"sm",type:"button",children:s("New user")})]}),g!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&t(Je,{description:s("Users who sign up to your app will appear here."),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:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:s("No users.")}),h!==null&&h.length>0&&t($e,{className:"overflow-hidden py-0",children:t(Fe,{className:"px-0",children:n(Ue,{"data-testid":"us-table",children:[t(_e,{children:n(L,{children:[t(z,{children:s("id")}),t(z,{children:s("email")}),t(z,{children:s("name")}),t(z,{children:s("role")}),t(z,{children:s("status")}),t(z,{children:s("verified")}),t(z,{children:s("created")}),t(z,{"aria-label":s("Actions")})]})}),t(Pe,{children:h.map(d=>n(L,{"data-testid":`us-row-${d.id}`,children:[t(U,{className:"font-mono text-xs",children:d.id}),t(U,{children:d.email??""}),t(U,{children:d.name??""}),t(U,{children:typeof d.role=="string"&&d.role!==""?t(M,{variant:"secondary",children:d.role}):""}),t(U,{children:d.banned===!0?t(M,{variant:"destructive",children:s("Banned")}):t(M,{variant:"success",children:s("Active")})}),t(U,{children:d.emailVerified===!0?t(M,{variant:"success",children:s("yes")}):t(M,{variant:"outline",children:s("no")})}),t(U,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),t(U,{children:t(S,{"data-testid":`us-manage-${d.id}`,onClick:()=>{m(d.id)},size:"xs",type:"button",variant:"ghost",children:s("Manage")})})]},d.id))})]})})}),f!==null&&t(ut,{capabilities:x,onChanged:v,onClose:()=>{m(null)},user:f}),k&&t(st,{onClose:()=>{I(!1)},onCreated:v})]})};export{Pt as UsersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as A}from"react/compiler-runtime";import{useLunora as H}from"@lunora/react";import{useState as h,useEffect as Q}from"react";import{u as R}from"../packem_shared/button-BkCrNcAs.js";import{c as V,
|
|
1
|
+
import{c as A}from"react/compiler-runtime";import{useLunora as H}from"@lunora/react";import{useState as h,useEffect as Q}from"react";import{u as R}from"../packem_shared/button-BkCrNcAs.js";import{c as V,f as j}from"../packem_shared/card-BMKx5UdA.js";import{E as W}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as D}from"../packem_shared/input-JHu63lTv.js";import{d as q,n as E,f as N,m as o,b as L,p as i}from"../packem_shared/table-DZAB8cs3.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{f as M,b as B,h as J}from"../packem_shared/internal-zkEvTqy8.js";import{jsxs as n,jsx as e}from"react/jsx-runtime";const O=10,g=x=>{const r=A(7),{label:m,value:a}=x;let l;r[0]!==m?(l=e("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),r[0]=m,r[1]=l):l=r[1];const f=a??"—";let c;r[2]!==f?(c=e("span",{className:"font-mono text-sm",children:f}),r[2]=f,r[3]=c):c=r[3];let u;return r[4]!==l||r[5]!==c?(u=n("div",{className:"flex flex-col gap-0.5",children:[l,c]}),r[4]=l,r[5]=c,r[6]=u):u=r[6],u},ce=({loadIndexes:x,runQuery:r}={})=>{const m=H(),a=G(),[l,f]=h(null),[c,u]=h(null),[v,C]=h(null),[b,F]=h(""),[p,y]=h(null),[k,w]=h(null),[I,S]=h(!1);Q(()=>{const t={cancelled:!1};return M((async()=>{try{const d=await(x??(()=>m.listVectorIndexes()))();t.cancelled||(f(d),u(null),C($=>$??d[0]?.name??null))}catch(d){t.cancelled||(f(null),u(B(d)))}})()),()=>{t.cancelled=!0}},[m,x]);const s=l?.find(t=>t.name===v)??null,K=t=>{C(t.currentTarget.dataset.index??null),y(null),w(null)},T=t=>{F(t.target.value)},Z=async()=>{const t=b.trim();if(!(v===null||t==="")){S(!0),w(null);try{const d=await(r??($=>m.queryVectorIndex($)))({name:v,text:t,topK:O});y(d)}catch(d){y(null),w(B(d))}S(!1)}},z=()=>{M(Z())};return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[c!==null&&e("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:c}),l!==null&&l.length===0&&e(W,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:e("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:e("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),l!==null&&l.length>0&&e(V,{className:"overflow-hidden py-0",children:e(j,{className:"px-0",children:n(q,{"data-testid":"vector-table",children:[e(E,{children:n(N,{children:[e(o,{children:a("name")}),e(o,{children:a("table")}),e(o,{children:a("dimensions")}),e(o,{children:a("metric")}),e(o,{children:a("vectors")})]})}),e(L,{children:l.map(t=>n(N,{className:t.name===v?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:K,children:[e(i,{className:"font-mono text-xs",children:t.name}),e(i,{className:"font-mono text-xs",children:t.table}),e(i,{className:"tabular-nums",children:t.dimensions??"—"}),e(i,{children:t.metric??"—"}),e(i,{className:"tabular-nums",children:t.vectorsCount??"—"})]},t.name))})]})})}),s!==null&&n("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[n("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e(g,{label:a("field"),value:s.field}),e(g,{label:a("dimensions"),value:s.dimensions}),e(g,{label:a("metric"),value:s.metric}),e(g,{label:a("vectors"),value:s.vectorsCount})]}),s.metadata!==void 0&&s.metadata.length>0&&n("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",e("span",{className:"font-mono",children:s.metadata.join(", ")})]}),n("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e(D,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:T,placeholder:a("Search by similarity…"),value:b}),e(R,{"data-testid":"vector-search",disabled:I||b.trim()==="",onClick:z,children:a(I?"Searching…":"Search")})]}),k!==null&&e("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:k}),p!==null&&p.length===0&&e("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),p!==null&&p.length>0&&e(V,{className:"mt-3 overflow-hidden py-0",children:e(j,{className:"px-0",children:n(q,{"data-testid":"vector-matches",children:[e(E,{children:n(N,{children:[e(o,{children:a("id")}),e(o,{children:a("score")}),e(o,{children:a("metadata")})]})}),e(L,{children:p.map(t=>n(N,{"data-testid":`vector-match-${t.id}`,children:[e(i,{className:"font-mono text-xs",children:t.id}),e(i,{className:"tabular-nums",children:t.score.toFixed(4)}),e(i,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"—":J(t.metadata)})]},t.id))})]})})})]})]})};export{ce as VectorBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as Q}from"@lunora/react";import{useState as m,useEffect as te}from"react";import{u as W}from"../packem_shared/button-BkCrNcAs.js";import{c as J,u as L}from"../packem_shared/card-CIDGUN6K.js";import{E as M}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ae}from"../packem_shared/input-JHu63lTv.js";import{n as U,d as _,m as x,p as i,f as q,u as d}from"../packem_shared/table-DdJBrClo.js";import{l as re}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as ne}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{f as A,b as E,d as H,g as X}from"../packem_shared/internal-zkEvTqy8.js";import{jsxs as s,jsx as e}from"react/jsx-runtime";const se=["queued","running","paused","waiting","complete","errored","terminated"],oe=["pause","resume","terminate"],le="WORKFLOWS_NOT_CONFIGURED",ie=o=>typeof o=="object"&&o!==null&&o.code===le,de=o=>{const r=o.error??o.output;if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"(unserializable)"}},ce=({loadDetail:o,loadInstances:r,readOnly:N,runAction:T,workflowName:g})=>{const I=Q(),n=V(),[h,k]=m(null),[S,$]=m(null),[v,j]=m(""),[b,f]=m(null),[F,C]=m(!1),[R,z]=m(null),p=o??(a=>I.getWorkflowInstance(a)),w=N?void 0:T??(r===void 0?a=>I.setWorkflowInstanceStatus(a):void 0),O=async()=>{f(null),C(!1);const a=v===""?void 0:v;try{if(r===void 0){const l=await I.listWorkflowInstances({name:g,status:a});if(l.configured===!1){k(null),C(!0);return}k(l.instances);return}k(await r({name:g,status:a}))}catch(l){k(null),ie(l)?C(!0):f(E(l))}};te(()=>{$(null),A(O())},[g,v]);const D=async a=>{f(null);try{$(await p({id:a,name:g}))}catch(l){f(E(l))}},K=async(a,l)=>{if(w!==void 0){z(a),f(null);try{await w({action:l,id:a,name:g}),await O()}catch(P){f(E(P))}z(null)}};return s("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[s("div",{className:"flex items-center justify-between gap-2",children:[e("h3",{className:"text-sm font-medium",children:n("Instance history")}),s("select",{"aria-label":n("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:a=>{j(a.target.value)},value:v,children:[e("option",{value:"",children:n("All statuses")}),se.map(a=>e("option",{value:a,children:a},a))]})]}),b!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),F&&e(M,{description:n("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:n("Workflow inspection not configured")}),!F&&h!==null&&h.length===0&&e(M,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),h!==null&&h.length>0&&e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflow-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:n("Instance id")}),e(i,{children:n("Status")}),e(i,{children:n("Created")}),e(i,{children:n("Ended")}),e(i,{"aria-label":n("Actions")})]})}),e(q,{children:h.map(a=>s(x,{"data-testid":`workflow-instance-${a.id}`,children:[e(d,{className:"font-mono text-xs",children:a.id}),e(d,{className:"font-mono text-xs",children:a.status}),e(d,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"—"}),e(d,{className:"text-right",children:s("div",{className:"flex justify-end gap-1.5",children:[e(W,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:()=>{A(D(a.id))},size:"sm",type:"button",variant:"outline",children:n("Steps")}),w!==void 0&&oe.map(l=>e(W,{"data-testid":`workflow-instance-${l}-${a.id}`,disabled:R===a.id,onClick:()=>{A(K(a.id,l))},size:"sm",type:"button",variant:"ghost",children:n(l)},l))]})})]},a.id))})]})})}),S!==null&&e(J,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:s(L,{className:"flex flex-col gap-2 px-4 py-3",children:[s("div",{className:"flex items-center justify-between",children:[s("span",{className:"font-mono text-xs",children:[n("Steps")," · ",S.id]}),e(W,{"data-testid":"workflow-instance-detail-close",onClick:()=>{$(null)},size:"xs",type:"button",variant:"ghost",children:n("Close")})]}),S.steps.length===0?e("p",{className:"text-xs text-muted-foreground",children:n("This instance has no recorded steps yet.")}):s(U,{"data-testid":"workflow-instance-steps",children:[e(_,{children:s(x,{children:[e(i,{children:n("Step")}),e(i,{children:n("Type")}),e(i,{children:n("Attempts")}),e(i,{children:n("Started")}),e(i,{children:n("Output")})]})}),e(q,{children:S.steps.map((a,l)=>s(x,{"data-testid":`workflow-step-${String(l)}`,children:[e(d,{className:"font-mono text-xs",children:a.name}),e(d,{className:"text-xs text-muted-foreground",children:a.type??"—"}),e(d,{className:"tabular-nums",children:a.attempts??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.start??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:de(a)})]},`${a.name}:${String(l)}`))})]})]})})]})},me=X(B.createWorkflowInstance),ue=X(B.getWorkflowInstanceStatus),fe=o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"—";try{return JSON.stringify(o.output)}catch{return"(unserializable)"}},he=(o,r)=>o.some(N=>N.exportName===r)?r:o[0]?.exportName??"",Oe=()=>{const o=Q(),r=V(),{data:N,error:T}=ne(B.listWorkflows,{}),[g,I]=m(""),[n,h]=m(""),[k,S]=m(""),[$,v]=m(!1),[j,b]=m(null),[f,F]=m([]),[C,R]=m(null),z=N!==void 0,p=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=he(p,g),O=p.find(t=>t.exportName===w),D=t=>{F(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},K=async()=>{const t=w;if(t==="")return;let u;const c=k.trim();if(c!=="")try{u=JSON.parse(c)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{const y=n.trim(),G=await o.query(me,{exportName:t,id:y===""?void 0:y,params:u},H(""));D({exportName:t,id:G.id,status:G.status}),h("")}catch(y){b(E(y))}v(!1)},a=()=>{A(K())},l=async(t,u)=>{R(u);try{const c=await o.query(ue,{exportName:t,id:u},H(""));D({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){b(E(c))}R(null)},P=t=>{I(t.target.value)},Y=t=>{h(t.target.value)},Z=t=>{S(t.target.value)},ee=t=>{const{export:u,id:c}=t.currentTarget.dataset;u!==void 0&&c!==void 0&&A(l(u,c))};return s("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[T!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:T}),e("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),z&&p.length===0?e(M,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Export")}),e(i,{children:r("Name")}),e(i,{children:r("Class")}),e(i,{children:r("Binding")})]})}),e(q,{children:p.map(t=>s(x,{"data-testid":`workflows-row-${t.exportName}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.className}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),p.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[e("h3",{className:"text-sm font-medium",children:r("Start instance")}),j!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:j}),s("div",{className:"flex flex-wrap items-center gap-2",children:[e("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:P,value:w,children:p.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(ae,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:Y,placeholder:r("Instance id (optional)"),value:n}),e(W,{"data-testid":"workflows-start-button",disabled:$||w==="",onClick:a,children:r($?"Starting…":"Start instance")})]}),e(re,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:Z,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[e("h3",{className:"text-sm font-medium",children:r("Instances")}),e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Workflow")}),e(i,{children:r("Instance id")}),e(i,{children:r("Status")}),e(i,{children:r("Output")}),e(i,{})]})}),e(q,{children:f.map(t=>s(x,{"data-testid":`workflows-instance-${t.id}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.id}),e(d,{className:"font-mono text-xs",children:t.status}),e(d,{className:"font-mono text-xs text-muted-foreground",children:fe(t)}),e(d,{children:e(W,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:ee,size:"xs",variant:"outline",children:C===t.id?r("Refreshing…"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),O!==void 0&&e(ce,{workflowName:O.name})]})};export{Oe as default};
|
|
1
|
+
import{useLunora as Q}from"@lunora/react";import{useState as m,useEffect as te}from"react";import{u as W}from"../packem_shared/button-BkCrNcAs.js";import{c as J,f as L}from"../packem_shared/card-BMKx5UdA.js";import{E as M}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ae}from"../packem_shared/input-JHu63lTv.js";import{d as U,n as _,f as x,m as i,b as q,p as d}from"../packem_shared/table-DZAB8cs3.js";import{l as re}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as ne}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{f as A,b as E,d as H,g as X}from"../packem_shared/internal-zkEvTqy8.js";import{jsxs as s,jsx as e}from"react/jsx-runtime";const se=["queued","running","paused","waiting","complete","errored","terminated"],oe=["pause","resume","terminate"],le="WORKFLOWS_NOT_CONFIGURED",ie=o=>typeof o=="object"&&o!==null&&o.code===le,de=o=>{const r=o.error??o.output;if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"(unserializable)"}},ce=({loadDetail:o,loadInstances:r,readOnly:N,runAction:T,workflowName:g})=>{const I=Q(),n=V(),[h,k]=m(null),[S,$]=m(null),[v,j]=m(""),[b,f]=m(null),[F,C]=m(!1),[R,z]=m(null),p=o??(a=>I.getWorkflowInstance(a)),w=N?void 0:T??(r===void 0?a=>I.setWorkflowInstanceStatus(a):void 0),O=async()=>{f(null),C(!1);const a=v===""?void 0:v;try{if(r===void 0){const l=await I.listWorkflowInstances({name:g,status:a});if(l.configured===!1){k(null),C(!0);return}k(l.instances);return}k(await r({name:g,status:a}))}catch(l){k(null),ie(l)?C(!0):f(E(l))}};te(()=>{$(null),A(O())},[g,v]);const D=async a=>{f(null);try{$(await p({id:a,name:g}))}catch(l){f(E(l))}},K=async(a,l)=>{if(w!==void 0){z(a),f(null);try{await w({action:l,id:a,name:g}),await O()}catch(P){f(E(P))}z(null)}};return s("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[s("div",{className:"flex items-center justify-between gap-2",children:[e("h3",{className:"text-sm font-medium",children:n("Instance history")}),s("select",{"aria-label":n("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:a=>{j(a.target.value)},value:v,children:[e("option",{value:"",children:n("All statuses")}),se.map(a=>e("option",{value:a,children:a},a))]})]}),b!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),F&&e(M,{description:n("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:n("Workflow inspection not configured")}),!F&&h!==null&&h.length===0&&e(M,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),h!==null&&h.length>0&&e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflow-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:n("Instance id")}),e(i,{children:n("Status")}),e(i,{children:n("Created")}),e(i,{children:n("Ended")}),e(i,{"aria-label":n("Actions")})]})}),e(q,{children:h.map(a=>s(x,{"data-testid":`workflow-instance-${a.id}`,children:[e(d,{className:"font-mono text-xs",children:a.id}),e(d,{className:"font-mono text-xs",children:a.status}),e(d,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"—"}),e(d,{className:"text-right",children:s("div",{className:"flex justify-end gap-1.5",children:[e(W,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:()=>{A(D(a.id))},size:"sm",type:"button",variant:"outline",children:n("Steps")}),w!==void 0&&oe.map(l=>e(W,{"data-testid":`workflow-instance-${l}-${a.id}`,disabled:R===a.id,onClick:()=>{A(K(a.id,l))},size:"sm",type:"button",variant:"ghost",children:n(l)},l))]})})]},a.id))})]})})}),S!==null&&e(J,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:s(L,{className:"flex flex-col gap-2 px-4 py-3",children:[s("div",{className:"flex items-center justify-between",children:[s("span",{className:"font-mono text-xs",children:[n("Steps")," · ",S.id]}),e(W,{"data-testid":"workflow-instance-detail-close",onClick:()=>{$(null)},size:"xs",type:"button",variant:"ghost",children:n("Close")})]}),S.steps.length===0?e("p",{className:"text-xs text-muted-foreground",children:n("This instance has no recorded steps yet.")}):s(U,{"data-testid":"workflow-instance-steps",children:[e(_,{children:s(x,{children:[e(i,{children:n("Step")}),e(i,{children:n("Type")}),e(i,{children:n("Attempts")}),e(i,{children:n("Started")}),e(i,{children:n("Output")})]})}),e(q,{children:S.steps.map((a,l)=>s(x,{"data-testid":`workflow-step-${String(l)}`,children:[e(d,{className:"font-mono text-xs",children:a.name}),e(d,{className:"text-xs text-muted-foreground",children:a.type??"—"}),e(d,{className:"tabular-nums",children:a.attempts??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:a.start??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:de(a)})]},`${a.name}:${String(l)}`))})]})]})})]})},me=X(B.createWorkflowInstance),ue=X(B.getWorkflowInstanceStatus),fe=o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"—";try{return JSON.stringify(o.output)}catch{return"(unserializable)"}},he=(o,r)=>o.some(N=>N.exportName===r)?r:o[0]?.exportName??"",Oe=()=>{const o=Q(),r=V(),{data:N,error:T}=ne(B.listWorkflows,{}),[g,I]=m(""),[n,h]=m(""),[k,S]=m(""),[$,v]=m(!1),[j,b]=m(null),[f,F]=m([]),[C,R]=m(null),z=N!==void 0,p=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=he(p,g),O=p.find(t=>t.exportName===w),D=t=>{F(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},K=async()=>{const t=w;if(t==="")return;let u;const c=k.trim();if(c!=="")try{u=JSON.parse(c)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{const y=n.trim(),G=await o.query(me,{exportName:t,id:y===""?void 0:y,params:u},H(""));D({exportName:t,id:G.id,status:G.status}),h("")}catch(y){b(E(y))}v(!1)},a=()=>{A(K())},l=async(t,u)=>{R(u);try{const c=await o.query(ue,{exportName:t,id:u},H(""));D({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){b(E(c))}R(null)},P=t=>{I(t.target.value)},Y=t=>{h(t.target.value)},Z=t=>{S(t.target.value)},ee=t=>{const{export:u,id:c}=t.currentTarget.dataset;u!==void 0&&c!==void 0&&A(l(u,c))};return s("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[T!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:T}),e("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),z&&p.length===0?e(M,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Export")}),e(i,{children:r("Name")}),e(i,{children:r("Class")}),e(i,{children:r("Binding")})]})}),e(q,{children:p.map(t=>s(x,{"data-testid":`workflows-row-${t.exportName}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.className}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),p.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[e("h3",{className:"text-sm font-medium",children:r("Start instance")}),j!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:j}),s("div",{className:"flex flex-wrap items-center gap-2",children:[e("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:P,value:w,children:p.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(ae,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:Y,placeholder:r("Instance id (optional)"),value:n}),e(W,{"data-testid":"workflows-start-button",disabled:$||w==="",onClick:a,children:r($?"Starting…":"Start instance")})]}),e(re,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:Z,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&s("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[e("h3",{className:"text-sm font-medium",children:r("Instances")}),e(J,{className:"overflow-hidden py-0",children:e(L,{className:"px-0",children:s(U,{"data-testid":"workflows-instances-table",children:[e(_,{children:s(x,{children:[e(i,{children:r("Workflow")}),e(i,{children:r("Instance id")}),e(i,{children:r("Status")}),e(i,{children:r("Output")}),e(i,{})]})}),e(q,{children:f.map(t=>s(x,{"data-testid":`workflows-instance-${t.id}`,children:[e(d,{className:"font-mono text-xs",children:t.exportName}),e(d,{className:"font-mono text-xs text-muted-foreground",children:t.id}),e(d,{className:"font-mono text-xs",children:t.status}),e(d,{className:"font-mono text-xs text-muted-foreground",children:fe(t)}),e(d,{children:e(W,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:ee,size:"xs",variant:"outline",children:C===t.id?r("Refreshing…"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),O!==void 0&&e(ce,{workflowName:O.name})]})};export{Oe as default};
|