@lunora/studio 1.0.0-alpha.78 → 1.0.0-alpha.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/ApiTab.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +1 -1
- package/dist/packem_chunks/ExportImportPanel.js +1 -1
- package/dist/packem_chunks/FileBrowser.js +1 -1
- package/dist/packem_chunks/FunctionRunner.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/MigrationsPanel.js +1 -1
- package/dist/packem_chunks/NotificationsPanel.js +1 -1
- package/dist/packem_chunks/PitrPanel.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 +1 -1
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/agents-panel.js +1 -1
- package/dist/packem_chunks/auth-audit-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/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/storage-rules-panel.js +1 -1
- package/dist/packem_chunks/subscriptions-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/workflows-panel.js +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js +1 -0
- package/dist/packem_shared/{ApiDocsPanel-eJYZlylw.js → ApiDocsPanel-CjdsxN1t.js} +1 -1
- package/dist/packem_shared/{DataBrowser-B8J5lHjP.js → DataBrowser-Bfstz_au.js} +1 -1
- package/dist/packem_shared/{HomePanel-DL1HupAN.js → HomePanel-B8EFM4u3.js} +1 -1
- package/dist/packem_shared/{Studio-BWBclm_C.js → Studio-BDtS9C5g.js} +1 -1
- package/dist/packem_shared/{StudioApp-BFm73yVr.js → StudioApp-DjLzIO9E.js} +1 -1
- package/dist/packem_shared/{home-panel-B-8BCffw.js → home-panel-Cm88Nvqh.js} +1 -1
- package/dist/packem_shared/{studio-BHA7hnI3.js → studio-BmWFd-Rz.js} +1 -1
- package/dist/packem_shared/use-async-submit-DLNCqLFq.js +1 -0
- package/dist/packem_shared/use-auth-config-9S_K_W-G.js +1 -0
- package/dist/standalone/{chunk-EVN46TVV.js → chunk-2SHUN7KF.js} +1 -1
- package/dist/standalone/{chunk-C43X4M5U.js → chunk-3EXLKL6V.js} +1 -1
- package/dist/standalone/{chunk-KDOC2DP5.js → chunk-3KAERFMC.js} +1 -1
- package/dist/standalone/{chunk-GSPTEMYN.js → chunk-4XDMVUS5.js} +1 -1
- package/dist/standalone/{chunk-YD5NF6UT.js → chunk-5YWJNF5X.js} +1 -1
- package/dist/standalone/chunk-66YJ3IOZ.js +1 -0
- package/dist/standalone/{chunk-2F7G7IWQ.js → chunk-6CULAILE.js} +1 -1
- package/dist/standalone/{chunk-D7XXWV4E.js → chunk-6KHEBRBB.js} +1 -1
- package/dist/standalone/{chunk-4WLYA3XE.js → chunk-6WCIFGDW.js} +1 -1
- package/dist/standalone/{chunk-OHKRN65U.js → chunk-7RG3AKPY.js} +1 -1
- package/dist/standalone/{chunk-65OTWFS3.js → chunk-A2FPLOMJ.js} +1 -1
- package/dist/standalone/chunk-AADILRJW.js +14 -0
- package/dist/standalone/chunk-AADXUXZO.js +1 -0
- package/dist/standalone/{chunk-L7N7F3DA.js → chunk-ARI4JTIH.js} +1 -1
- package/dist/standalone/chunk-AVZGVZZ7.js +1 -0
- package/dist/standalone/{chunk-5U2THBI7.js → chunk-BDO4J5AP.js} +1 -1
- package/dist/standalone/{chunk-XSD4Y6SQ.js → chunk-BMQJ4CAO.js} +1 -1
- package/dist/standalone/{chunk-5L2MD6F6.js → chunk-CMUP7HPS.js} +1 -1
- package/dist/standalone/{chunk-QGKAJTQQ.js → chunk-CP7AUUOU.js} +1 -1
- package/dist/standalone/{chunk-UIS34ZPB.js → chunk-DX3RMFQU.js} +1 -1
- package/dist/standalone/{chunk-5OWIOACV.js → chunk-E2CJUP53.js} +1 -1
- package/dist/standalone/{chunk-FGTK44LR.js → chunk-EIT7ERYE.js} +1 -1
- package/dist/standalone/{chunk-35II7U25.js → chunk-EN2QAEO4.js} +1 -1
- package/dist/standalone/{chunk-QVEHPYA5.js → chunk-FLYO3XY5.js} +1 -1
- package/dist/standalone/{chunk-DVOBKIUX.js → chunk-FWCKM2CU.js} +1 -1
- package/dist/standalone/{chunk-VPAXCQ2Y.js → chunk-GITJXQOS.js} +1 -1
- package/dist/standalone/{chunk-SA3MDZC3.js → chunk-GP6IRITM.js} +1 -1
- package/dist/standalone/{chunk-VGHSEUEX.js → chunk-GXU3ATKS.js} +1 -1
- package/dist/standalone/{chunk-FPLGBHY4.js → chunk-H5Y5NQPL.js} +1 -1
- package/dist/standalone/{chunk-34UVAASH.js → chunk-HALNNKTC.js} +1 -1
- package/dist/standalone/{chunk-UNUU7CJJ.js → chunk-HK4OVYG3.js} +1 -1
- package/dist/standalone/{chunk-ZNNAGR6N.js → chunk-HQEMYD2K.js} +1 -1
- package/dist/standalone/{chunk-F6GOKFMU.js → chunk-HYT2ZUNP.js} +2 -2
- package/dist/standalone/{chunk-7RXOPYR5.js → chunk-I4WGRDL2.js} +1 -1
- package/dist/standalone/{chunk-P24JBHEZ.js → chunk-ISZSYNTI.js} +1 -1
- package/dist/standalone/chunk-JWG3VRGB.js +1 -0
- package/dist/standalone/{chunk-RAA2RGG6.js → chunk-KDYNM3GV.js} +1 -1
- package/dist/standalone/{chunk-T2JIUFOD.js → chunk-KP6JQSH2.js} +1 -1
- package/dist/standalone/{chunk-IDNNI63H.js → chunk-LSEZN2ZL.js} +1 -1
- package/dist/standalone/{chunk-LJDP7NRB.js → chunk-LU3GW7HI.js} +1 -1
- package/dist/standalone/chunk-MVGE3JJN.js +1 -0
- package/dist/standalone/chunk-MXSHWB3M.js +1 -0
- package/dist/standalone/{chunk-BEH5N5ZA.js → chunk-NG6LYBPJ.js} +1 -1
- package/dist/standalone/{chunk-HP2UCWND.js → chunk-NL2DZKFI.js} +1 -1
- package/dist/standalone/{chunk-EXFBIISG.js → chunk-OGVCXKRL.js} +1 -1
- package/dist/standalone/{chunk-EKRN4ZQM.js → chunk-OPC233PZ.js} +1 -1
- package/dist/standalone/{chunk-TLHJRWNK.js → chunk-P4CWOYFL.js} +1 -1
- package/dist/standalone/{chunk-QLJJ5YYZ.js → chunk-PRJ4RJDU.js} +1 -1
- package/dist/standalone/{chunk-XEDU5FO4.js → chunk-PUY3YDXI.js} +1 -1
- package/dist/standalone/{chunk-FGTABSAK.js → chunk-QZMR6MUG.js} +1 -1
- package/dist/standalone/{chunk-F5QWLENA.js → chunk-W6TE2I2D.js} +1 -1
- package/dist/standalone/{chunk-PF7V3G2Z.js → chunk-WCWYSOCN.js} +1 -1
- package/dist/standalone/{chunk-BNUJ7QMG.js → chunk-WEO3YVP6.js} +1 -1
- package/dist/standalone/{chunk-6DWCIIHE.js → chunk-XIZNYKOD.js} +1 -1
- package/dist/standalone/{chunk-3FUFEZ65.js → chunk-XS6Q6GGV.js} +1 -1
- package/dist/standalone/{chunk-XQBTNJUQ.js → chunk-Y3CQDULJ.js} +1 -1
- package/dist/standalone/{chunk-7J5N6DGQ.js → chunk-YCRMVBPW.js} +1 -1
- package/dist/standalone/{chunk-H7NIIBHH.js → chunk-Z2JPEI2V.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js +0 -1
- package/dist/packem_shared/use-async-submit-H68GHPz8.js +0 -1
- package/dist/standalone/chunk-3QRTYSSX.js +0 -1
- package/dist/standalone/chunk-B43FTQJ7.js +0 -1
- package/dist/standalone/chunk-GXZAXNZI.js +0 -1
- package/dist/standalone/chunk-LE56LPNH.js +0 -13
- package/dist/standalone/chunk-PWWHP76O.js +0 -1
- package/dist/standalone/chunk-YI3WYUXK.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as P}from"react/compiler-runtime";import{useLunora as He}from"@lunora/react";import{useState as _}from"react";import{E as Ve}from"../packem_shared/error-alert-B59DnrDI.js";import{A as Xe}from"../packem_shared/alert-CVcOFuDR.js";import{g as Qe}from"../packem_shared/badge-BbuuAio7.js";import{u as oe}from"../packem_shared/button-BkCrNcAs.js";import{c as ke,u as Oe}from"../packem_shared/card-CIDGUN6K.js";import{E as Ie}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ye}from"../packem_shared/input-JHu63lTv.js";import{p as Ze}from"../packem_shared/scroll-area-DTEq6Jec.js";import{n as Be,d as Je,m as de,p as $,f as Fe,u as w}from"../packem_shared/table-DdJBrClo.js";import{l as et}from"../packem_shared/textarea-Bu2-jKAs.js";import{K as De}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useAutoRefresh as tt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as j}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{c as $e,e as we,a as Ae,i as at,f as Ce}from"../packem_shared/internal-AtZ4bTal.js";import{jsx as a,jsxs as b,Fragment as We}from"react/jsx-runtime";const st=(r,e)=>{const t=new Set(r.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),u=r.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!t.has(s.name)),d=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:d,queuesWithoutDlq:u,showReliabilityWarning:u.length>0||d>0}},rt=200,nt=Ae(j.sendQueueMessage),ot=Ae(j.replayQueueMessage),dt=Ae(j.clearQueueMessages),Re=96,lt=r=>{if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"[unserializable]"}},ut=r=>r.length>Re?`${r.slice(0,Re)}…`:r,ct=r=>r==="error"?"destructive":r==="retry"?"outline":"secondary",it=(r,e)=>e(r==="messages"?"Messages":r==="send"?"Send":"Declared"),mt=r=>{const e=P(11),{loaded:t,queues:u}=r,d=U();let s;e[0]!==d?(s=d("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=d,e[1]=s):s=e[1];let o;e[2]!==s?(o=a("p",{className:"text-sm text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let n;e[4]!==t||e[5]!==u||e[6]!==d?(n=t&&u.length===0?a(Ie,{description:d("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:d("No queues defined")}):a(ke,{className:"overflow-hidden py-0",children:a(Oe,{className:"px-0",children:b(Be,{"data-testid":"queues-table",children:[a(Je,{children:b(de,{children:[a($,{children:d("Export")}),a($,{children:d("Queue")}),a($,{children:d("Mode")}),a($,{children:d("Binding")}),a($,{children:d("Dead-letter")})]})}),a(Fe,{children:u.map(ft)})]})})}),e[4]=t,e[5]=u,e[6]=d,e[7]=n):n=e[7];let h;return e[8]!==o||e[9]!==n?(h=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,n]}),e[8]=o,e[9]=n,e[10]=h):h=e[10],h},ht=r=>{const e=P(67),{message:t,onReplay:u,replayingId:d}=r,s=U();let o,n,h,i,y,p,x,l,m,g;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==s){const J=lt(t.body);n=de,p=`queues-message-${t.id}`;const F=t.exportName??t.queue;e[19]!==F?(x=a(w,{className:"font-mono text-xs",children:F}),e[19]=F,e[20]=x):x=e[20],e[21]!==t.messageId?(l=a(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=l):l=e[22],e[23]!==t.attempts?(m=a(w,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=m):m=e[24];const E=`queues-outcome-${t.id}`;let L;e[25]!==t.outcome?(L=ct(t.outcome),e[25]=t.outcome,e[26]=L):L=e[26];let C;e[27]!==t.outcome||e[28]!==E||e[29]!==L?(C=a(Qe,{"data-testid":E,variant:L,children:t.outcome}),e[27]=t.outcome,e[28]=E,e[29]=L,e[30]=C):C=e[30];let M;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==s?(M=t.deadLettered&&a(Qe,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:s("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=s,e[34]=M):M=e[34],e[35]!==C||e[36]!==M?(g=a(w,{children:b("span",{className:"inline-flex items-center gap-1",children:[C,M]})}),e[35]=C,e[36]=M,e[37]=g):g=e[37],o=w,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",i=J,y=ut(J),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=s,e[9]=o,e[10]=n,e[11]=h,e[12]=i,e[13]=y,e[14]=p,e[15]=x,e[16]=l,e[17]=m,e[18]=g}else o=e[9],n=e[10],h=e[11],i=e[12],y=e[13],p=e[14],x=e[15],l=e[16],m=e[17],g=e[18];let f;e[38]!==o||e[39]!==h||e[40]!==i||e[41]!==y?(f=a(o,{className:h,title:i,children:y}),e[38]=o,e[39]=h,e[40]=i,e[41]=y,e[42]=f):f=e[42];let q;e[43]!==t.capturedAt?(q=at(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=q):q=e[44];let N;e[45]!==q?(N=a(w,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=N):N=e[46];const S=`queues-replay-${t.id}`,A=d!==null;let Q;e[47]!==t.id||e[48]!==d||e[49]!==s?(Q=d===t.id?s("Replaying…"):s("Replay"),e[47]=t.id,e[48]=d,e[49]=s,e[50]=Q):Q=e[50];let I;e[51]!==t.id||e[52]!==u||e[53]!==S||e[54]!==A||e[55]!==Q?(I=a(w,{children:a(oe,{"data-id":t.id,"data-testid":S,disabled:A,onClick:u,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=u,e[53]=S,e[54]=A,e[55]=Q,e[56]=I):I=e[56];let T;return e[57]!==n||e[58]!==N||e[59]!==I||e[60]!==p||e[61]!==x||e[62]!==l||e[63]!==m||e[64]!==g||e[65]!==f?(T=b(n,{"data-testid":p,children:[x,l,m,g,f,N,I]}),e[57]=n,e[58]=N,e[59]=I,e[60]=p,e[61]=x,e[62]=l,e[63]=m,e[64]=g,e[65]=f,e[66]=T):T=e[66],T},pt=r=>{const e=P(26),{hasError:t,messages:u,onClear:d,onReplay:s,replayingId:o}=r,n=U();let h;e[0]!==n?(h=n("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=n,e[1]=h):h=e[1];let i;e[2]!==h?(i=a("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=i):i=e[3];const y=u.length===0;let p;e[4]!==n?(p=n("Clear log"),e[4]=n,e[5]=p):p=e[5];let x;e[6]!==d||e[7]!==y||e[8]!==p?(x=a(oe,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:d,size:"sm",type:"button",variant:"outline",children:p}),e[6]=d,e[7]=y,e[8]=p,e[9]=x):x=e[9];let l;e[10]!==u.length||e[11]!==n?(l=u.length>0&&a(Qe,{"data-testid":"queues-count",variant:"secondary",children:n("{count} messages",{count:u.length})}),e[10]=u.length,e[11]=n,e[12]=l):l=e[12];let m;e[13]!==i||e[14]!==x||e[15]!==l?(m=b("div",{className:"flex flex-wrap items-center gap-2",children:[i,x,l]}),e[13]=i,e[14]=x,e[15]=l,e[16]=m):m=e[16];let g;e[17]!==t||e[18]!==u||e[19]!==s||e[20]!==o||e[21]!==n?(g=!t&&u.length===0?a(Ie,{description:n("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:n("No consumed messages yet.")}):a(ke,{className:"overflow-hidden py-0",children:a(Oe,{className:"px-0",children:a(Ze,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Be,{"data-testid":"queues-messages-table",children:[a(Je,{children:b(de,{children:[a($,{children:n("Export")}),a($,{children:n("Message")}),a($,{children:n("Attempts")}),a($,{children:n("Outcome")}),a($,{children:n("Body")}),a($,{children:n("Captured")}),a($,{})]})}),a(Fe,{children:u.map(q=>a(ht,{message:q,onReplay:s,replayingId:o},q.id))})]})})})}),e[17]=t,e[18]=u,e[19]=s,e[20]=o,e[21]=n,e[22]=g):g=e[22];let f;return e[23]!==m||e[24]!==g?(f=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]}),e[23]=m,e[24]=g,e[25]=f):f=e[25],f},gt=r=>{const e=P(20),{batchMode:t,bodyText:u,delayText:d,onBatchModeChange:s,onBodyChange:o,onDelayChange:n,onSelectExport:h,onSend:i,queues:y,selectedExportName:p,sending:x}=r,l=U();let m;e[0]!==l?(m=l("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=l,e[1]=m):m=e[1];let g;e[2]!==m?(g=a("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=g):g=e[3];let f;e[4]!==t||e[5]!==u||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==n||e[10]!==h||e[11]!==i||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==l?(f=y.length===0?a(Ie,{description:l("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:l("No queues to send to")}):b(We,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[a("select",{"aria-label":l("Queue"),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":"queues-send-select",onChange:h,value:p,children:y.map(xt)}),a(Ye,{"aria-label":l("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:n,placeholder:l("Delay (s)"),type:"number",value:d}),b("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[a("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),l("Send as batch (JSON array)")]}),a(oe,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:i,type:"button",children:l(x?"Sending…":"Send message")})]}),a(et,{"aria-label":l("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:u})]}),e[4]=t,e[5]=u,e[6]=d,e[7]=s,e[8]=o,e[9]=n,e[10]=h,e[11]=i,e[12]=y,e[13]=p,e[14]=x,e[15]=l,e[16]=f):f=e[16];let q;return e[17]!==g||e[18]!==f?(q=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,f]}),e[17]=g,e[18]=f,e[19]=q):q=e[19],q},Bt=r=>{const e=P(59),{limit:t}=r,u=t??rt,d=He(),s=U(),[o,n]=_("declared"),[h,i]=_(null);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];const{data:p,error:x,errorSource:l}=De(j.listQueues,y);let m;e[1]!==u?(m={limit:u},e[1]=u,e[2]=m):m=e[2];const{data:g,error:f,errorSource:q,refetch:N}=De(j.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(yt):[],A=g?.entries??[],{deadLetteredCount:Q,queuesWithoutDlq:I,showReliabilityWarning:T}=st(S,A),[J,F]=_(""),[E,L]=_(""),[C,M]=_(""),[W,ze]=_(!1),[le,Ee]=_(!1),[ue,Le]=_(null),G=S.some(c=>c.exportName===J)?J:S[0]?.exportName??"",Me=o==="messages"?f:x,je=o==="messages"?q:l,ce=Me??h,ie=Me===null?h:je;let K;e[3]!==N?(K=()=>{N()},e[3]=N,e[4]=K):K=e[4],tt(K,o==="messages");const me=async()=>{i(null);const c=G;if(c==="")return;let v=null;const _e=E.trim();if(_e!=="")try{v=JSON.parse(_e)}catch{i(s("Body must be valid JSON."));return}let Se;const Te=C.trim();if(Te!==""){const z=Number(Te);if(!Number.isFinite(z)||z<0){i(s("Delay must be a non-negative number of seconds."));return}Se=z}if(W&&!Array.isArray(v)){i(s("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ee(!0);const Ke=W?{batch:v,delaySeconds:Se,exportName:c}:{body:v,delaySeconds:Se,exportName:c};try{await d.query(nt,Ke,$e("")),N()}catch(z){i(we(z))}Ee(!1)};let H;e[5]!==d||e[6]!==N?(H=async c=>{i(null),Le(c);try{await d.query(ot,{id:c},$e("")),N()}catch(v){i(we(v))}Le(null)},e[5]=d,e[6]=N,e[7]=H):H=e[7];const he=H;let V;e[8]!==d||e[9]!==N?(V=async()=>{i(null);try{await d.query(dt,{},$e("")),N()}catch(c){i(we(c))}},e[8]=d,e[9]=N,e[10]=V):V=e[10];const pe=V;let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=c=>{const v=c.currentTarget.dataset.tab;(v==="declared"||v==="messages"||v==="send")&&n(v)},e[11]=X):X=e[11];const Pe=X;let Y;e[12]===Symbol.for("react.memo_cache_sentinel")?(Y=c=>{F(c.currentTarget.value)},e[12]=Y):Y=e[12];const ge=Y;let Z;e[13]===Symbol.for("react.memo_cache_sentinel")?(Z=c=>{L(c.currentTarget.value)},e[13]=Z):Z=e[13];const fe=Z;let ee;e[14]===Symbol.for("react.memo_cache_sentinel")?(ee=c=>{M(c.currentTarget.value)},e[14]=ee):ee=e[14];const xe=ee;let te;e[15]===Symbol.for("react.memo_cache_sentinel")?(te=c=>{ze(c.currentTarget.checked)},e[15]=te):te=e[15];const ye=te;let ae;e[16]!==me?(ae=()=>{Ce(me())},e[16]=me,e[17]=ae):ae=e[17];const Ne=ae;let se;e[18]!==he?(se=c=>{const{id:v}=c.currentTarget.dataset;v!==void 0&&Ce(he(v))},e[18]=he,e[19]=se):se=e[19];const be=se;let re;e[20]!==pe?(re=()=>{Ce(pe())},e[20]=pe,e[21]=re):re=e[21];const qe=re,Ue="flex flex-col gap-6",Ge="lunora-queues-panel";let D;e[22]!==s||e[23]!==o?(D=a("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>a(oe,{"aria-selected":o===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Pe,role:"tab",size:"sm",type:"button",variant:o===c?"secondary":"ghost",children:it(c,s)},c))}),e[22]=s,e[23]=o,e[24]=D):D=e[24];let R;e[25]!==ce||e[26]!==ie?(R=ce!==null&&a(Ve,{error:ie,testId:"queues-error"}),e[25]=ce,e[26]=ie,e[27]=R):R=e[27];const ve=T&&a(Xe,{icon:a("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[I.length>0&&b(We,{children:[a("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:I.map(Nt).join(", ")})}),a("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),Q>0&&a("p",{className:I.length>0?"text-muted-foreground":"font-medium",children:Q===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:Q})})]})});let k;e[28]!==S||e[29]!==p||e[30]!==o?(k=o==="declared"&&a(mt,{loaded:p!==void 0,queues:S}),e[28]=S,e[29]=p,e[30]=o,e[31]=k):k=e[31];let O;e[32]!==A||e[33]!==f||e[34]!==qe||e[35]!==be||e[36]!==ue||e[37]!==o?(O=o==="messages"&&a(pt,{hasError:f!==null,messages:A,onClear:qe,onReplay:be,replayingId:ue}),e[32]=A,e[33]=f,e[34]=qe,e[35]=be,e[36]=ue,e[37]=o,e[38]=O):O=e[38];let B;e[39]!==W||e[40]!==E||e[41]!==C||e[42]!==ye||e[43]!==fe||e[44]!==xe||e[45]!==ge||e[46]!==Ne||e[47]!==S||e[48]!==G||e[49]!==le||e[50]!==o?(B=o==="send"&&a(gt,{batchMode:W,bodyText:E,delayText:C,onBatchModeChange:ye,onBodyChange:fe,onDelayChange:xe,onSelectExport:ge,onSend:Ne,queues:S,selectedExportName:G,sending:le}),e[39]=W,e[40]=E,e[41]=C,e[42]=ye,e[43]=fe,e[44]=xe,e[45]=ge,e[46]=Ne,e[47]=S,e[48]=G,e[49]=le,e[50]=o,e[51]=B):B=e[51];let ne;return e[52]!==D||e[53]!==R||e[54]!==ve||e[55]!==k||e[56]!==O||e[57]!==B?(ne=b("div",{className:Ue,"data-testid":Ge,children:[D,R,ve,k,O,B]}),e[52]=D,e[53]=R,e[54]=ve,e[55]=k,e[56]=O,e[57]=B,e[58]=ne):ne=e[58],ne};function ft(r){return b(de,{"data-testid":`queues-row-${r.exportName}`,children:[a(w,{className:"font-mono text-xs",children:r.exportName}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.name}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.mode}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.binding}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.deadLetterQueue??"—"})]},r.exportName)}function xt(r){return a("option",{value:r.exportName,children:r.exportName},r.exportName)}function yt(r,e){return r.exportName.localeCompare(e.exportName)}function Nt(r){return r.name}export{Bt as default};
|
|
1
|
+
import{c as P}from"react/compiler-runtime";import{useLunora as He}from"@lunora/react";import{useState as _}from"react";import{E as Ve}from"../packem_shared/error-alert-B59DnrDI.js";import{A as Xe}from"../packem_shared/alert-CVcOFuDR.js";import{g as Qe}from"../packem_shared/badge-BbuuAio7.js";import{u as oe}from"../packem_shared/button-BkCrNcAs.js";import{c as ke,u as Oe}from"../packem_shared/card-CIDGUN6K.js";import{E as Ie}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ye}from"../packem_shared/input-JHu63lTv.js";import{p as Ze}from"../packem_shared/scroll-area-DTEq6Jec.js";import{n as Be,d as Je,m as de,p as $,f as Fe,u as w}from"../packem_shared/table-DdJBrClo.js";import{l as et}from"../packem_shared/textarea-Bu2-jKAs.js";import{K as De}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useAutoRefresh as tt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as j}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{c as $e,e as we,a as Ae,i as at,f as Ce}from"../packem_shared/internal-AtZ4bTal.js";import{jsx as a,jsxs as b,Fragment as We}from"react/jsx-runtime";const st=(r,e)=>{const t=new Set(r.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),u=r.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!t.has(s.name)),d=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:d,queuesWithoutDlq:u,showReliabilityWarning:u.length>0||d>0}},rt=200,nt=Ae(j.sendQueueMessage),ot=Ae(j.replayQueueMessage),dt=Ae(j.clearQueueMessages),Re=96,lt=r=>{if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"[unserializable]"}},ut=r=>r.length>Re?`${r.slice(0,Re)}…`:r,ct=r=>r==="error"?"destructive":r==="retry"?"outline":"secondary",it=(r,e)=>e(r==="messages"?"Messages":r==="send"?"Send":"Declared"),mt=r=>{const e=P(11),{loaded:t,queues:u}=r,d=U();let s;e[0]!==d?(s=d("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=d,e[1]=s):s=e[1];let o;e[2]!==s?(o=a("p",{className:"text-sm text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let n;e[4]!==t||e[5]!==u||e[6]!==d?(n=t&&u.length===0?a(Ie,{description:d("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:d("No queues defined")}):a(ke,{className:"overflow-hidden py-0",children:a(Oe,{className:"px-0",children:b(Be,{"data-testid":"queues-table",children:[a(Je,{children:b(de,{children:[a($,{children:d("Export")}),a($,{children:d("Queue")}),a($,{children:d("Mode")}),a($,{children:d("Binding")}),a($,{children:d("Dead-letter")})]})}),a(Fe,{children:u.map(ft)})]})})}),e[4]=t,e[5]=u,e[6]=d,e[7]=n):n=e[7];let h;return e[8]!==o||e[9]!==n?(h=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,n]}),e[8]=o,e[9]=n,e[10]=h):h=e[10],h},ht=r=>{const e=P(67),{message:t,onReplay:u,replayingId:d}=r,s=U();let o,n,h,i,y,p,x,l,m,g;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==s){const J=lt(t.body);n=de,p=`queues-message-${t.id}`;const F=t.exportName??t.queue;e[19]!==F?(x=a(w,{className:"font-mono text-xs",children:F}),e[19]=F,e[20]=x):x=e[20],e[21]!==t.messageId?(l=a(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=l):l=e[22],e[23]!==t.attempts?(m=a(w,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=m):m=e[24];const E=`queues-outcome-${t.id}`;let L;e[25]!==t.outcome?(L=ct(t.outcome),e[25]=t.outcome,e[26]=L):L=e[26];let C;e[27]!==t.outcome||e[28]!==E||e[29]!==L?(C=a(Qe,{"data-testid":E,variant:L,children:t.outcome}),e[27]=t.outcome,e[28]=E,e[29]=L,e[30]=C):C=e[30];let M;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==s?(M=t.deadLettered&&a(Qe,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:s("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=s,e[34]=M):M=e[34],e[35]!==C||e[36]!==M?(g=a(w,{children:b("span",{className:"inline-flex items-center gap-1",children:[C,M]})}),e[35]=C,e[36]=M,e[37]=g):g=e[37],o=w,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",i=J,y=ut(J),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=s,e[9]=o,e[10]=n,e[11]=h,e[12]=i,e[13]=y,e[14]=p,e[15]=x,e[16]=l,e[17]=m,e[18]=g}else o=e[9],n=e[10],h=e[11],i=e[12],y=e[13],p=e[14],x=e[15],l=e[16],m=e[17],g=e[18];let f;e[38]!==o||e[39]!==h||e[40]!==i||e[41]!==y?(f=a(o,{className:h,title:i,children:y}),e[38]=o,e[39]=h,e[40]=i,e[41]=y,e[42]=f):f=e[42];let q;e[43]!==t.capturedAt?(q=at(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=q):q=e[44];let N;e[45]!==q?(N=a(w,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=N):N=e[46];const S=`queues-replay-${t.id}`,A=d!==null;let Q;e[47]!==t.id||e[48]!==d||e[49]!==s?(Q=d===t.id?s("Replaying…"):s("Replay"),e[47]=t.id,e[48]=d,e[49]=s,e[50]=Q):Q=e[50];let I;e[51]!==t.id||e[52]!==u||e[53]!==S||e[54]!==A||e[55]!==Q?(I=a(w,{children:a(oe,{"data-id":t.id,"data-testid":S,disabled:A,onClick:u,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=u,e[53]=S,e[54]=A,e[55]=Q,e[56]=I):I=e[56];let T;return e[57]!==n||e[58]!==N||e[59]!==I||e[60]!==p||e[61]!==x||e[62]!==l||e[63]!==m||e[64]!==g||e[65]!==f?(T=b(n,{"data-testid":p,children:[x,l,m,g,f,N,I]}),e[57]=n,e[58]=N,e[59]=I,e[60]=p,e[61]=x,e[62]=l,e[63]=m,e[64]=g,e[65]=f,e[66]=T):T=e[66],T},pt=r=>{const e=P(26),{hasError:t,messages:u,onClear:d,onReplay:s,replayingId:o}=r,n=U();let h;e[0]!==n?(h=n("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=n,e[1]=h):h=e[1];let i;e[2]!==h?(i=a("p",{className:"text-sm text-muted-foreground",children:h}),e[2]=h,e[3]=i):i=e[3];const y=u.length===0;let p;e[4]!==n?(p=n("Clear log"),e[4]=n,e[5]=p):p=e[5];let x;e[6]!==d||e[7]!==y||e[8]!==p?(x=a(oe,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:d,size:"sm",type:"button",variant:"outline",children:p}),e[6]=d,e[7]=y,e[8]=p,e[9]=x):x=e[9];let l;e[10]!==u.length||e[11]!==n?(l=u.length>0&&a(Qe,{"data-testid":"queues-count",variant:"secondary",children:n("{count} messages",{count:u.length})}),e[10]=u.length,e[11]=n,e[12]=l):l=e[12];let m;e[13]!==i||e[14]!==x||e[15]!==l?(m=b("div",{className:"flex flex-wrap items-center gap-2",children:[i,x,l]}),e[13]=i,e[14]=x,e[15]=l,e[16]=m):m=e[16];let g;e[17]!==t||e[18]!==u||e[19]!==s||e[20]!==o||e[21]!==n?(g=!t&&u.length===0?a(Ie,{description:n("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:n("No consumed messages yet.")}):a(ke,{className:"overflow-hidden py-0",children:a(Oe,{className:"px-0",children:a(Ze,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Be,{"data-testid":"queues-messages-table",children:[a(Je,{children:b(de,{children:[a($,{children:n("Export")}),a($,{children:n("Message")}),a($,{children:n("Attempts")}),a($,{children:n("Outcome")}),a($,{children:n("Body")}),a($,{children:n("Captured")}),a($,{})]})}),a(Fe,{children:u.map(q=>a(ht,{message:q,onReplay:s,replayingId:o},q.id))})]})})})}),e[17]=t,e[18]=u,e[19]=s,e[20]=o,e[21]=n,e[22]=g):g=e[22];let f;return e[23]!==m||e[24]!==g?(f=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]}),e[23]=m,e[24]=g,e[25]=f):f=e[25],f},gt=r=>{const e=P(20),{batchMode:t,bodyText:u,delayText:d,onBatchModeChange:s,onBodyChange:o,onDelayChange:n,onSelectExport:h,onSend:i,queues:y,selectedExportName:p,sending:x}=r,l=U();let m;e[0]!==l?(m=l("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=l,e[1]=m):m=e[1];let g;e[2]!==m?(g=a("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=g):g=e[3];let f;e[4]!==t||e[5]!==u||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==n||e[10]!==h||e[11]!==i||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==l?(f=y.length===0?a(Ie,{description:l("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:l("No queues to send to")}):b(We,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[a("select",{"aria-label":l("Queue"),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":"queues-send-select",onChange:h,value:p,children:y.map(xt)}),a(Ye,{"aria-label":l("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:n,placeholder:l("Delay (s)"),type:"number",value:d}),b("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[a("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),l("Send as batch (JSON array)")]}),a(oe,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:i,type:"button",children:l(x?"Sending…":"Send message")})]}),a(et,{"aria-label":l("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:u})]}),e[4]=t,e[5]=u,e[6]=d,e[7]=s,e[8]=o,e[9]=n,e[10]=h,e[11]=i,e[12]=y,e[13]=p,e[14]=x,e[15]=l,e[16]=f):f=e[16];let q;return e[17]!==g||e[18]!==f?(q=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,f]}),e[17]=g,e[18]=f,e[19]=q):q=e[19],q},Bt=r=>{const e=P(59),{limit:t}=r,u=t??rt,d=He(),s=U(),[o,n]=_("declared"),[h,i]=_(null);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];const{data:p,error:x,errorSource:l}=De(j.listQueues,y);let m;e[1]!==u?(m={limit:u},e[1]=u,e[2]=m):m=e[2];const{data:g,error:f,errorSource:q,refetch:N}=De(j.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(yt):[],A=g?.entries??[],{deadLetteredCount:Q,queuesWithoutDlq:I,showReliabilityWarning:T}=st(S,A),[J,F]=_(""),[E,L]=_(""),[C,M]=_(""),[W,ze]=_(!1),[le,Ee]=_(!1),[ue,Le]=_(null),G=S.some(c=>c.exportName===J)?J:S[0]?.exportName??"",Me=o==="messages"?f:x,je=o==="messages"?q:l,ce=Me??h,ie=Me===null?h:je;let K;e[3]!==N?(K=()=>{N()},e[3]=N,e[4]=K):K=e[4],tt(K,o==="messages");const me=async()=>{i(null);const c=G;if(c==="")return;let v=null;const _e=E.trim();if(_e!=="")try{v=JSON.parse(_e)}catch{i(s("Body must be valid JSON."));return}let Se;const Te=C.trim();if(Te!==""){const z=Number(Te);if(!Number.isFinite(z)||z<0){i(s("Delay must be a non-negative number of seconds."));return}Se=z}if(W&&!Array.isArray(v)){i(s("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ee(!0);const Ke=W?{batch:v,delaySeconds:Se,exportName:c}:{body:v,delaySeconds:Se,exportName:c};try{await d.query(nt,Ke,$e("")),N()}catch(z){i(we(z))}Ee(!1)};let H;e[5]!==d||e[6]!==N?(H=async c=>{i(null),Le(c);try{await d.query(ot,{id:c},$e("")),N()}catch(v){i(we(v))}Le(null)},e[5]=d,e[6]=N,e[7]=H):H=e[7];const he=H;let V;e[8]!==d||e[9]!==N?(V=async()=>{i(null);try{await d.query(dt,{},$e("")),N()}catch(c){i(we(c))}},e[8]=d,e[9]=N,e[10]=V):V=e[10];const pe=V;let X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=c=>{const v=c.currentTarget.dataset.tab;(v==="declared"||v==="messages"||v==="send")&&n(v)},e[11]=X):X=e[11];const Pe=X;let Y;e[12]===Symbol.for("react.memo_cache_sentinel")?(Y=c=>{F(c.currentTarget.value)},e[12]=Y):Y=e[12];const ge=Y;let Z;e[13]===Symbol.for("react.memo_cache_sentinel")?(Z=c=>{L(c.currentTarget.value)},e[13]=Z):Z=e[13];const fe=Z;let ee;e[14]===Symbol.for("react.memo_cache_sentinel")?(ee=c=>{M(c.currentTarget.value)},e[14]=ee):ee=e[14];const xe=ee;let te;e[15]===Symbol.for("react.memo_cache_sentinel")?(te=c=>{ze(c.currentTarget.checked)},e[15]=te):te=e[15];const ye=te;let ae;e[16]!==me?(ae=()=>{Ce(me())},e[16]=me,e[17]=ae):ae=e[17];const Ne=ae;let se;e[18]!==he?(se=c=>{const{id:v}=c.currentTarget.dataset;v!==void 0&&Ce(he(v))},e[18]=he,e[19]=se):se=e[19];const be=se;let re;e[20]!==pe?(re=()=>{Ce(pe())},e[20]=pe,e[21]=re):re=e[21];const qe=re,Ue="flex flex-col gap-6",Ge="lunora-queues-panel";let D;e[22]!==s||e[23]!==o?(D=a("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>a(oe,{"aria-selected":o===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Pe,role:"tab",size:"sm",type:"button",variant:o===c?"secondary":"ghost",children:it(c,s)},c))}),e[22]=s,e[23]=o,e[24]=D):D=e[24];let R;e[25]!==ce||e[26]!==ie?(R=ce!==null&&a(Ve,{error:ie,testId:"queues-error"}),e[25]=ce,e[26]=ie,e[27]=R):R=e[27];const ve=T&&a(Xe,{icon:a("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[I.length>0&&b(We,{children:[a("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:I.map(Nt).join(", ")})}),a("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),Q>0&&a("p",{className:I.length>0?"text-muted-foreground":"font-medium",children:Q===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:Q})})]})});let k;e[28]!==S||e[29]!==p||e[30]!==o?(k=o==="declared"&&a(mt,{loaded:p!==void 0,queues:S}),e[28]=S,e[29]=p,e[30]=o,e[31]=k):k=e[31];let O;e[32]!==A||e[33]!==f||e[34]!==qe||e[35]!==be||e[36]!==ue||e[37]!==o?(O=o==="messages"&&a(pt,{hasError:f!==null,messages:A,onClear:qe,onReplay:be,replayingId:ue}),e[32]=A,e[33]=f,e[34]=qe,e[35]=be,e[36]=ue,e[37]=o,e[38]=O):O=e[38];let B;e[39]!==W||e[40]!==E||e[41]!==C||e[42]!==ye||e[43]!==fe||e[44]!==xe||e[45]!==ge||e[46]!==Ne||e[47]!==S||e[48]!==G||e[49]!==le||e[50]!==o?(B=o==="send"&&a(gt,{batchMode:W,bodyText:E,delayText:C,onBatchModeChange:ye,onBodyChange:fe,onDelayChange:xe,onSelectExport:ge,onSend:Ne,queues:S,selectedExportName:G,sending:le}),e[39]=W,e[40]=E,e[41]=C,e[42]=ye,e[43]=fe,e[44]=xe,e[45]=ge,e[46]=Ne,e[47]=S,e[48]=G,e[49]=le,e[50]=o,e[51]=B):B=e[51];let ne;return e[52]!==D||e[53]!==R||e[54]!==ve||e[55]!==k||e[56]!==O||e[57]!==B?(ne=b("div",{className:Ue,"data-testid":Ge,children:[D,R,ve,k,O,B]}),e[52]=D,e[53]=R,e[54]=ve,e[55]=k,e[56]=O,e[57]=B,e[58]=ne):ne=e[58],ne};function ft(r){return b(de,{"data-testid":`queues-row-${r.exportName}`,children:[a(w,{className:"font-mono text-xs",children:r.exportName}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.name}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.mode}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.binding}),a(w,{className:"font-mono text-xs text-muted-foreground",children:r.deadLetterQueue??"—"})]},r.exportName)}function xt(r){return a("option",{value:r.exportName,children:r.exportName},r.exportName)}function yt(r,e){return r.exportName.localeCompare(e.exportName)}function Nt(r){return r.name}export{Bt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as z}from"react/compiler-runtime";import{E as F}from"../packem_shared/error-alert-B59DnrDI.js";import{g as U}from"../packem_shared/badge-BbuuAio7.js";import{u as D,c as K}from"../packem_shared/card-CIDGUN6K.js";import{E as j}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as C,d as G,m as E,p as A,f as M,u as S}from"../packem_shared/table-DdJBrClo.js";import{K as J}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as z}from"react/compiler-runtime";import{E as F}from"../packem_shared/error-alert-B59DnrDI.js";import{g as U}from"../packem_shared/badge-BbuuAio7.js";import{u as D,c as K}from"../packem_shared/card-CIDGUN6K.js";import{E as j}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as C,d as G,m as E,p as A,f as M,u as S}from"../packem_shared/table-DdJBrClo.js";import{K as J}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{jsx as r,jsxs as o}from"react/jsx-runtime";const O=["read","insert","update","delete"],q=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],B=e=>{const t=new Map;for(const s of e){const l=t.get(s.table)??{operations:new Set,procedures:[],table:s.table};l.operations.add(s.on),l.procedures.includes(s.procedure)||l.procedures.push(s.procedure),t.set(s.table,l)}return[...t.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},ae=()=>{const e=z(49),t=V();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:I,errorSource:R}=J(W.rlsPolicies,s),c=l!==void 0;let p,n,m,a,h,u,f,x,i;if(e[1]!==l||e[2]!==I||e[3]!==R||e[4]!==c||e[5]!==t){const T=B(Array.isArray(l?.policies)?l.policies:[]);let k;e[15]!==l?(k=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=k):k=e[16],n=k,f="flex flex-col gap-6",x="lunora-rls-panel",e[17]!==I||e[18]!==R?(i=I!==null&&r(F,{error:R,testId:"rls-error"}),e[17]=I,e[18]=R,e[19]=i):i=e[19],u="flex flex-col gap-2",p=K,m="overflow-hidden py-0";let v;e[20]!==t?(v=t("Policies"),e[20]=t,e[21]=v):v=e[21],e[22]!==v?(a=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v})}),e[22]=v,e[23]=a):a=e[23],h=c&&T.length===0?r(j,{description:t("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:t("No policies defined")}):r(D,{className:"px-0",children:o(C,{"data-testid":"rls-policies-table",children:[r(G,{children:o(E,{children:[r(A,{children:t("Table")}),O.map(d=>r(A,{children:q(t,d)},d)),r(A,{children:t("Guarded by")})]})}),r(M,{children:T.map(d=>o(E,{"data-testid":`rls-table-${d.table}`,children:[r(S,{className:"font-mono text-xs",children:d.table}),O.map(_=>r(S,{children:d.operations.has(_)?r(U,{variant:"secondary",children:t("Guarded")}):r("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},_)),r(S,{className:"font-mono text-xs text-muted-foreground",children:d.procedures.join(", ")})]},d.table))})]})}),e[1]=l,e[2]=I,e[3]=R,e[4]=c,e[5]=t,e[6]=p,e[7]=n,e[8]=m,e[9]=a,e[10]=h,e[11]=u,e[12]=f,e[13]=x,e[14]=i}else p=e[6],n=e[7],m=e[8],a=e[9],h=e[10],u=e[11],f=e[12],x=e[13],i=e[14];let b;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==h?(b=o(p,{className:m,children:[a,h]}),e[24]=p,e[25]=m,e[26]=a,e[27]=h,e[28]=b):b=e[28];let N;e[29]!==u||e[30]!==b?(N=r("section",{className:u,children:b}),e[29]=u,e[30]=b,e[31]=N):N=e[31];let g;e[32]!==t?(g=t("Roles"),e[32]=t,e[33]=g):g=e[33];let y;e[34]!==g?(y=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g})}),e[34]=g,e[35]=y):y=e[35];let $;e[36]!==c||e[37]!==n||e[38]!==t?($=c&&n.length===0?r(j,{description:t("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:t("No roles defined")}):r(D,{className:"px-0",children:o(C,{"data-testid":"rls-roles-table",children:[r(G,{children:o(E,{children:[r(A,{children:t("Role")}),r(A,{children:t("Description")}),r(A,{children:t("Permissions")})]})}),r(M,{children:n.map(L)})]})}),e[36]=c,e[37]=n,e[38]=t,e[39]=$):$=e[39];let w;e[40]!==y||e[41]!==$?(w=r("section",{className:"flex flex-col gap-2",children:o(K,{className:"overflow-hidden py-0",children:[y,$]})}),e[40]=y,e[41]=$,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==f||e[45]!==x||e[46]!==i||e[47]!==N?(P=o("div",{className:f,"data-testid":x,children:[i,N,w]}),e[43]=w,e[44]=f,e[45]=x,e[46]=i,e[47]=N,e[48]=P):P=e[48],P};function H(e){return r(U,{variant:"outline",children:e},e)}function L(e){return o(E,{"data-testid":`rls-role-${e.name}`,children:[r(S,{className:"font-mono text-xs",children:e.name}),r(S,{className:"text-muted-foreground",children:e.description??""}),r(S,{children:e.permissions.length===0?r("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):r("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(H)})})]},e.name)}export{ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as b}from"react/compiler-runtime";import{E as y}from"../packem_shared/error-alert-B59DnrDI.js";import{g as N}from"../packem_shared/badge-BbuuAio7.js";import{c as k,u as S}from"../packem_shared/card-CIDGUN6K.js";import{E as w}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as R,d as v,m as x,p as u,f as A,u as p}from"../packem_shared/table-DdJBrClo.js";import{K as E}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as j}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as I}from"../packem_shared/ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as b}from"react/compiler-runtime";import{E as y}from"../packem_shared/error-alert-B59DnrDI.js";import{g as N}from"../packem_shared/badge-BbuuAio7.js";import{c as k,u as S}from"../packem_shared/card-CIDGUN6K.js";import{E as w}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as R,d as v,m as x,p as u,f as A,u as p}from"../packem_shared/table-DdJBrClo.js";import{K as E}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as j}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as I}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{jsx as t,jsxs as f}from"react/jsx-runtime";const C=(e,r)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[r],$={delete:2,list:3,read:0,write:1},T=e=>[...e].toSorted((r,s)=>r.bucket.localeCompare(s.bucket)||$[r.on]-$[s.on]||(r.prefix??"").localeCompare(s.prefix??"")),U=()=>{const e=b(14),r=j();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:i,errorSource:d}=E(I.storageRules,s),h=l!==void 0;let n;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==r){const g=T(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==i||e[8]!==d?(c=i!==null&&t(y,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=c):c=e[9];let a;e[10]!==r?(a=r("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=r,e[11]=a):a=e[11];let m;e[12]!==a?(m=t("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:a}),e[12]=a,e[13]=m):m=e[13],n=f("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&g.length===0?t(w,{description:r("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:r("No storage rules defined")}):t(k,{className:"overflow-hidden py-0",children:t(S,{className:"px-0",children:f(R,{"data-testid":"storage-rules-table",children:[t(v,{children:f(x,{children:[t(u,{children:r("Bucket")}),t(u,{children:r("Operation")}),t(u,{children:r("Key prefix")}),t(u,{children:r("Guarded by")})]})}),t(A,{children:g.map(o=>f(x,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[t(p,{className:"font-mono text-xs",children:o.bucket}),t(p,{children:t(N,{variant:"secondary",children:C(r,o.on)})}),t(p,{className:"font-mono text-xs",children:o.prefix??t("span",{className:"text-muted-foreground",children:r("(whole bucket)")})}),t(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=r,e[6]=n}else n=e[6];return n};export{U as StorageRulesPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as T}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-B59DnrDI.js";import{ShardInput as P}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as $}from"../packem_shared/badge-BbuuAio7.js";import{c as _,u as D}from"../packem_shared/card-CIDGUN6K.js";import{E as F}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as L,d as O,m as C,p as g,f as U,u as N}from"../packem_shared/table-DdJBrClo.js";import{K as W}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useAutoRefresh as B}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import J from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as R}from"../packem_shared/ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as T}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-B59DnrDI.js";import{ShardInput as P}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as $}from"../packem_shared/badge-BbuuAio7.js";import{c as _,u as D}from"../packem_shared/card-CIDGUN6K.js";import{E as F}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as L,d as O,m as C,p as g,f as U,u as N}from"../packem_shared/table-DdJBrClo.js";import{K as W}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useAutoRefresh as B}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import J from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as R}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{jsx as e,jsxs as c}from"react/jsx-runtime";const E=80,X=a=>{if(a===void 0)return"";const t=JSON.stringify(a);return t.length>E?`${t.slice(0,E)}…`:t},Z=a=>{const t=[];for(const o of a){const n=o.id.toString();if(o.subscriptions.length===0){t.push({admin:o.admin,connectionId:o.id,key:`c${n}`,subscription:null});continue}o.subscriptions.forEach((r,S)=>{t.push({admin:o.admin,connectionId:o.id,key:`c${n}-s${S.toString()}`,subscription:r})})}return t},w=e("span",{className:"text-muted-foreground",children:"—"}),at=a=>{const t=T(22),{initialShardKey:o}=a,n=Q(),[r,S]=j(o??"");let u;t[0]!==r?(u=r.trim(),t[0]=r,t[1]=u):u=t[1];const y=J(u,400);let h;t[2]===Symbol.for("react.memo_cache_sentinel")?(h={},t[2]=h):h=t[2];let p;t[3]!==y?(p={keepPreviousData:!0,shardKey:y},t[3]=y,t[4]=p):p=t[4];const{data:i,error:s,errorSource:m,refetch:M}=W(R.listSubscriptions,h,p);B(M,!0);let f;if(t[5]!==s||t[6]!==m||t[7]!==i||t[8]!==r||t[9]!==n){const k=i===void 0?[]:Z(i.connections);let l;t[11]!==r?(l=e(P,{onChange:S,testId:"subs-shard-input",value:r}),t[11]=r,t[12]=l):l=t[12];let d;t[13]!==i||t[14]!==n?(d=i!==void 0&&c("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[e($,{variant:"secondary",children:n("{count} connections",{count:i.totalConnections})}),e($,{variant:"secondary",children:n("{count} subscriptions",{count:i.totalSubscriptions})})]}),t[13]=i,t[14]=n,t[15]=d):d=t[15];let b;t[16]!==l||t[17]!==d?(b=c("div",{className:"flex flex-wrap items-center gap-2",children:[l,d]}),t[16]=l,t[17]=d,t[18]=b):b=t[18];let v;t[19]!==s||t[20]!==m?(v=s!==null&&e(K,{error:m,testId:"subs-error"}),t[19]=s,t[20]=m,t[21]=v):v=t[21],f=c("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[b,v,s===null&&i!==void 0&&k.length===0&&e(F,{description:n("Active WebSocket subscriptions on this shard."),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:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),s===null&&k.length>0&&e(_,{className:"overflow-hidden py-0",children:e(D,{className:"px-0",children:c(L,{"data-testid":"subs-table",children:[e(O,{children:c(C,{children:[e(g,{children:n("Connection")}),e(g,{children:n("Function path")}),e(g,{children:n("Table")}),e(g,{children:n("Arguments")})]})}),e(U,{children:k.map(x=>{const{subscription:I}=x,A=X(I?.args);return c(C,{"data-testid":"subs-row",children:[e(N,{className:"font-medium tabular-nums",children:c("span",{className:"inline-flex items-center gap-1.5",children:["#",x.connectionId,x.admin&&e($,{variant:"outline",children:n("admin")})]})}),e(N,{className:"font-mono text-xs",children:I?.functionPath??w}),e(N,{children:I?.table??w}),e(N,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:A||void 0,children:A||w})]},x.key)})})]})})})]}),t[5]=s,t[6]=m,t[7]=i,t[8]=r,t[9]=n,t[10]=f}else f=t[10];return f};export{at as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as z}from"react/compiler-runtime";import{useState as Q,useEffect as J}from"react";import{f as Y}from"../packem_shared/log-fields-CoL3hsIQ.js";import{E as Z}from"../packem_shared/error-alert-B59DnrDI.js";import{L as ee}from"../packem_shared/live-status-CGW2JHf_.js";import{ShardInput as te}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as re}from"../packem_shared/badge-BbuuAio7.js";import{E as ae}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as se}from"../packem_shared/input-JHu63lTv.js";import{K as ne}from"../packem_shared/use-admin-query-Di3fLE8H.js";import oe from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{i as ie}from"../packem_shared/internal-AtZ4bTal.js";import{r as de}from"../packem_shared/shard-history-DMEW5VBE.js";import{p as ce,c as me}from"../packem_shared/trace-handoff-Dw7mwjxu.js";import{c as ue}from"../packem_shared/utils-bhneXptQ.js";import{jsx as s,jsxs as B}from"react/jsx-runtime";const V=o=>Math.min(100,Math.max(0,o)),he=(o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=V(o.offsetMs/e*100),a=o.durationMs/e*100,r=Math.max(.5,Math.min(V(a),100-t));return{leftPercent:t,widthPercent:r}},fe=(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`:"—",pe=14,ge=o=>Array.isArray(o?.traces)?o.traces:[],xe=o=>{const e=z(50),{span:t,traceDurationMs:a}=o,r=G();let n;e[0]!==t||e[1]!==a?(n=he(t,a),e[0]=t,e[1]=a,e[2]=n):n=e[2];const{leftPercent:S,widthPercent:x}=n;let P;e[3]!==t.attributes?(P=Y(t.attributes),e[3]=t.attributes,e[4]=P):P=e[4];const M=P,L=t.depth*pe;let y;e[5]!==L?(y={paddingLeft:L},e[5]=L,e[6]=y):y=e[6];const b=y,c=`${String(S)}%`,w=`${String(x)}%`;let p;e[7]!==c||e[8]!==w?(p={left:c,width:w},e[7]=c,e[8]=w,e[9]=p):p=e[9];const l=p,f=t.depth;let i;e[10]!==t.ok||e[11]!==r?(i=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]=i):i=e[12];let v;e[13]!==b||e[14]!==t.name||e[15]!==i?(v=B("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:b,title:t.name,children:[i,t.name]}),e[13]=b,e[14]=t.name,e[15]=i,e[16]=v):v=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 m;e[21]!==N?(m=ue("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=m):m=e[22];let u;e[23]!==l||e[24]!==S||e[25]!==m||e[26]!==x?(u=s("span",{className:m,"data-left":S,"data-testid":"tr-span-bar","data-width":x,style:l}),e[23]=l,e[24]=S,e[25]=m,e[26]=x,e[27]=u):u=e[27];let h;e[28]!==d||e[29]!==u?(h=s("span",{"aria-label":d,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:u}),e[28]=d,e[29]=u,e[30]=h):h=e[30];let g;e[31]!==t.durationMs?(g=U(t.durationMs),e[31]=t.durationMs,e[32]=g):g=e[32];let k;e[33]!==g?(k=s("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:g}),e[33]=g,e[34]=k):k=e[34];let I;e[35]!==t.error?(I=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]=I):I=e[36];let T;e[37]!==I?(T=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:I}),e[37]=I,e[38]=T):T=e[38];let C;e[39]!==M?(C=M===""?null:s("span",{"data-testid":"tr-span-attributes",title:M,children:M}),e[39]=M,e[40]=C):C=e[40];let $;e[41]!==C?($=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:C}),e[41]=C,e[42]=$):$=e[42];let F;return e[43]!==t.depth||e[44]!==v||e[45]!==h||e[46]!==k||e[47]!==T||e[48]!==$?(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":f,"data-testid":"tr-span-row",role:"row",children:[v,h,k,T,$]}),e[43]=t.depth,e[44]=v,e[45]=h,e[46]=k,e[47]=T,e[48]=$,e[49]=F):F=e[49],F},be=o=>{const e=z(50),{expanded:t,onToggle:a,trace:r}=o,n=G();let S;e[0]!==a||e[1]!==r.traceId?(S=()=>{a(r.traceId)},e[0]=a,e[1]=r.traceId,e[2]=S):S=e[2];const x=S,P=`tr-row-${r.traceId}`,M=`tr-waterfall-${r.traceId}`,L=`tr-toggle-${r.traceId}`,y=t?"▾":"▸";let b;e[3]!==y?(b=s("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:y}),e[3]=y,e[4]=b):b=e[4];let c;e[5]!==r.rootName?(c=s("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=c):c=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 p;e[9]!==r.durationMs?(p=U(r.durationMs),e[9]=r.durationMs,e[10]=p):p=e[10];let l;e[11]!==p?(l=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:p}),e[11]=p,e[12]=l):l=e[12];let f;e[13]!==n||e[14]!==r.spans.length?(f=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=f):f=e[15];let i;e[16]!==f?(i=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:f}),e[16]=f,e[17]=i):i=e[17];const v=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]!==v||e[22]!==d?(N=s("span",{className:"shrink-0",children:s(re,{variant:v,children:d})}),e[21]=v,e[22]=d,e[23]=N):N=e[23];let m;e[24]!==r.startTs?(m=ie(r.startTs),e[24]=r.startTs,e[25]=m):m=e[25];let u;e[26]!==m?(u=s("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:m}),e[26]=m,e[27]=u):u=e[27];let h;e[28]!==t||e[29]!==x||e[30]!==l||e[31]!==i||e[32]!==N||e[33]!==u||e[34]!==M||e[35]!==L||e[36]!==b||e[37]!==c||e[38]!==w?(h=B("button",{"aria-controls":M,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":L,onClick:x,type:"button",children:[b,c,w,l,i,N,u]}),e[28]=t,e[29]=x,e[30]=l,e[31]=i,e[32]=N,e[33]=u,e[34]=M,e[35]=L,e[36]=b,e[37]=c,e[38]=w,e[39]=h):h=e[39];let g;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(g=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(I=>s(xe,{span:I,traceDurationMs:r.durationMs},I.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=g):g=e[45];let k;return e[46]!==h||e[47]!==g||e[48]!==P?(k=B("div",{className:"border-b border-border last:border-b-0","data-testid":P,children:[h,g]}),e[46]=h,e[47]=g,e[48]=P,e[49]=k):k=e[49],k},Be=o=>{const e=z(44),{initialShardKey:t}=o,a=G(),[r]=Q(ce),[n,S]=Q(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[x,P]=Q(r?.traceId??""),[M,L]=Q(we);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],J(Ne,y);let b;e[1]!==n?(b=n.trim(),e[1]=n,e[2]=b):b=e[2];const c=oe(b,400);let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let p;e[4]!==c?(p={live:!0,shardKey:c},e[4]=c,e[5]=p):p=e[5];const{data:l,error:f,errorSource:i,isLoading:v,liveError:d}=ne(le.getTraces,w,p);let N,m;e[6]!==l||e[7]!==c?(N=()=>{l!==void 0&&de(c)},m=[l,c],e[6]=l,e[7]=c,e[8]=N,e[9]=m):(N=e[8],m=e[9]),J(N,m);let u;if(e[10]!==l||e[11]!==f||e[12]!==i||e[13]!==M||e[14]!==v||e[15]!==d||e[16]!==x||e[17]!==n||e[18]!==a){const h=ge(l),g=l?.total??h.length,k=g>h.length,I=fe(h,x);let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=_=>{P(_.target.value)},e[20]=T):T=e[20];const C=T;let $;e[21]===Symbol.for("react.memo_cache_sentinel")?($=_=>{L(X=>{const H=new Set(X);return H.has(_)?H.delete(_):H.add(_),H})},e[21]=$):$=e[21];const F=$,W=f===null&&I.length===0&&!v;let K;e[22]!==n?(K=s(te,{onChange:S,testId:"tr-shard-input",value:n}),e[22]=n,e[23]=K):K=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 j;e[28]!==x||e[29]!==A||e[30]!==D?(j=s(se,{"aria-label":A,className:"h-8 w-56","data-testid":"tr-search",onChange:C,placeholder:D,value:x}),e[28]=x,e[29]=A,e[30]=D,e[31]=j):j=e[31];let E;e[32]!==d?(E=s(ee,{message:d,prefix:"tr"}),e[32]=d,e[33]=E):E=e[33];let R;e[34]!==K||e[35]!==j||e[36]!==E?(R=B("div",{className:"flex flex-wrap items-center gap-2",children:[K,j,E]}),e[34]=K,e[35]=j,e[36]=E,e[37]=R):R=e[37];let O;e[38]!==f||e[39]!==i?(O=f!==null&&s(Z,{error:i,testId:"tr-error"}),e[38]=f,e[39]=i,e[40]=O):O=e[40];let q;e[41]!==W||e[42]!==a?(q=W&&s(ae,{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]=W,e[42]=a,e[43]=q):q=e[43],u=B("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[R,O,q,f===null&&k&&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:h.length,total:g})}),f===null&&I.length>0&&s("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:I.map(_=>s(be,{expanded:M.has(_.traceId),onToggle:F,trace:_},_.traceId))})]}),e[10]=l,e[11]=f,e[12]=i,e[13]=M,e[14]=v,e[15]=d,e[16]=x,e[17]=n,e[18]=a,e[19]=u}else u=e[19];return u};function we(){return new Set}function Ne(){me()}export{Be as TracesPanel};
|
|
1
|
+
import{c as z}from"react/compiler-runtime";import{useState as Q,useEffect as J}from"react";import{f as Y}from"../packem_shared/log-fields-CoL3hsIQ.js";import{E as Z}from"../packem_shared/error-alert-B59DnrDI.js";import{L as ee}from"../packem_shared/live-status-CGW2JHf_.js";import{ShardInput as te}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as re}from"../packem_shared/badge-BbuuAio7.js";import{E as ae}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as se}from"../packem_shared/input-JHu63lTv.js";import{K as ne}from"../packem_shared/use-admin-query-Di3fLE8H.js";import oe from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{i as ie}from"../packem_shared/internal-AtZ4bTal.js";import{r as de}from"../packem_shared/shard-history-DMEW5VBE.js";import{p as ce,c as me}from"../packem_shared/trace-handoff-Dw7mwjxu.js";import{c as ue}from"../packem_shared/utils-bhneXptQ.js";import{jsx as s,jsxs as B}from"react/jsx-runtime";const V=o=>Math.min(100,Math.max(0,o)),he=(o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=V(o.offsetMs/e*100),a=o.durationMs/e*100,r=Math.max(.5,Math.min(V(a),100-t));return{leftPercent:t,widthPercent:r}},fe=(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`:"—",pe=14,ge=o=>Array.isArray(o?.traces)?o.traces:[],xe=o=>{const e=z(50),{span:t,traceDurationMs:a}=o,r=G();let n;e[0]!==t||e[1]!==a?(n=he(t,a),e[0]=t,e[1]=a,e[2]=n):n=e[2];const{leftPercent:S,widthPercent:x}=n;let P;e[3]!==t.attributes?(P=Y(t.attributes),e[3]=t.attributes,e[4]=P):P=e[4];const M=P,L=t.depth*pe;let y;e[5]!==L?(y={paddingLeft:L},e[5]=L,e[6]=y):y=e[6];const b=y,c=`${String(S)}%`,w=`${String(x)}%`;let p;e[7]!==c||e[8]!==w?(p={left:c,width:w},e[7]=c,e[8]=w,e[9]=p):p=e[9];const l=p,f=t.depth;let i;e[10]!==t.ok||e[11]!==r?(i=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]=i):i=e[12];let v;e[13]!==b||e[14]!==t.name||e[15]!==i?(v=B("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:b,title:t.name,children:[i,t.name]}),e[13]=b,e[14]=t.name,e[15]=i,e[16]=v):v=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 m;e[21]!==N?(m=ue("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=m):m=e[22];let u;e[23]!==l||e[24]!==S||e[25]!==m||e[26]!==x?(u=s("span",{className:m,"data-left":S,"data-testid":"tr-span-bar","data-width":x,style:l}),e[23]=l,e[24]=S,e[25]=m,e[26]=x,e[27]=u):u=e[27];let h;e[28]!==d||e[29]!==u?(h=s("span",{"aria-label":d,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:u}),e[28]=d,e[29]=u,e[30]=h):h=e[30];let g;e[31]!==t.durationMs?(g=U(t.durationMs),e[31]=t.durationMs,e[32]=g):g=e[32];let k;e[33]!==g?(k=s("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:g}),e[33]=g,e[34]=k):k=e[34];let I;e[35]!==t.error?(I=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]=I):I=e[36];let T;e[37]!==I?(T=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:I}),e[37]=I,e[38]=T):T=e[38];let C;e[39]!==M?(C=M===""?null:s("span",{"data-testid":"tr-span-attributes",title:M,children:M}),e[39]=M,e[40]=C):C=e[40];let $;e[41]!==C?($=s("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:C}),e[41]=C,e[42]=$):$=e[42];let F;return e[43]!==t.depth||e[44]!==v||e[45]!==h||e[46]!==k||e[47]!==T||e[48]!==$?(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":f,"data-testid":"tr-span-row",role:"row",children:[v,h,k,T,$]}),e[43]=t.depth,e[44]=v,e[45]=h,e[46]=k,e[47]=T,e[48]=$,e[49]=F):F=e[49],F},be=o=>{const e=z(50),{expanded:t,onToggle:a,trace:r}=o,n=G();let S;e[0]!==a||e[1]!==r.traceId?(S=()=>{a(r.traceId)},e[0]=a,e[1]=r.traceId,e[2]=S):S=e[2];const x=S,P=`tr-row-${r.traceId}`,M=`tr-waterfall-${r.traceId}`,L=`tr-toggle-${r.traceId}`,y=t?"▾":"▸";let b;e[3]!==y?(b=s("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:y}),e[3]=y,e[4]=b):b=e[4];let c;e[5]!==r.rootName?(c=s("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=c):c=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 p;e[9]!==r.durationMs?(p=U(r.durationMs),e[9]=r.durationMs,e[10]=p):p=e[10];let l;e[11]!==p?(l=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:p}),e[11]=p,e[12]=l):l=e[12];let f;e[13]!==n||e[14]!==r.spans.length?(f=n("{count} spans",{count:r.spans.length}),e[13]=n,e[14]=r.spans.length,e[15]=f):f=e[15];let i;e[16]!==f?(i=s("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:f}),e[16]=f,e[17]=i):i=e[17];const v=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]!==v||e[22]!==d?(N=s("span",{className:"shrink-0",children:s(re,{variant:v,children:d})}),e[21]=v,e[22]=d,e[23]=N):N=e[23];let m;e[24]!==r.startTs?(m=ie(r.startTs),e[24]=r.startTs,e[25]=m):m=e[25];let u;e[26]!==m?(u=s("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:m}),e[26]=m,e[27]=u):u=e[27];let h;e[28]!==t||e[29]!==x||e[30]!==l||e[31]!==i||e[32]!==N||e[33]!==u||e[34]!==M||e[35]!==L||e[36]!==b||e[37]!==c||e[38]!==w?(h=B("button",{"aria-controls":M,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":L,onClick:x,type:"button",children:[b,c,w,l,i,N,u]}),e[28]=t,e[29]=x,e[30]=l,e[31]=i,e[32]=N,e[33]=u,e[34]=M,e[35]=L,e[36]=b,e[37]=c,e[38]=w,e[39]=h):h=e[39];let g;e[40]!==t||e[41]!==n||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(g=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(I=>s(xe,{span:I,traceDurationMs:r.durationMs},I.spanId))}),e[40]=t,e[41]=n,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=g):g=e[45];let k;return e[46]!==h||e[47]!==g||e[48]!==P?(k=B("div",{className:"border-b border-border last:border-b-0","data-testid":P,children:[h,g]}),e[46]=h,e[47]=g,e[48]=P,e[49]=k):k=e[49],k},Be=o=>{const e=z(44),{initialShardKey:t}=o,a=G(),[r]=Q(ce),[n,S]=Q(r?.shardKey!==void 0&&r.shardKey!==""?r.shardKey:t??""),[x,P]=Q(r?.traceId??""),[M,L]=Q(we);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],J(Ne,y);let b;e[1]!==n?(b=n.trim(),e[1]=n,e[2]=b):b=e[2];const c=oe(b,400);let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let p;e[4]!==c?(p={live:!0,shardKey:c},e[4]=c,e[5]=p):p=e[5];const{data:l,error:f,errorSource:i,isLoading:v,liveError:d}=ne(le.getTraces,w,p);let N,m;e[6]!==l||e[7]!==c?(N=()=>{l!==void 0&&de(c)},m=[l,c],e[6]=l,e[7]=c,e[8]=N,e[9]=m):(N=e[8],m=e[9]),J(N,m);let u;if(e[10]!==l||e[11]!==f||e[12]!==i||e[13]!==M||e[14]!==v||e[15]!==d||e[16]!==x||e[17]!==n||e[18]!==a){const h=ge(l),g=l?.total??h.length,k=g>h.length,I=fe(h,x);let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=_=>{P(_.target.value)},e[20]=T):T=e[20];const C=T;let $;e[21]===Symbol.for("react.memo_cache_sentinel")?($=_=>{L(X=>{const H=new Set(X);return H.has(_)?H.delete(_):H.add(_),H})},e[21]=$):$=e[21];const F=$,W=f===null&&I.length===0&&!v;let K;e[22]!==n?(K=s(te,{onChange:S,testId:"tr-shard-input",value:n}),e[22]=n,e[23]=K):K=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 j;e[28]!==x||e[29]!==A||e[30]!==D?(j=s(se,{"aria-label":A,className:"h-8 w-56","data-testid":"tr-search",onChange:C,placeholder:D,value:x}),e[28]=x,e[29]=A,e[30]=D,e[31]=j):j=e[31];let E;e[32]!==d?(E=s(ee,{message:d,prefix:"tr"}),e[32]=d,e[33]=E):E=e[33];let R;e[34]!==K||e[35]!==j||e[36]!==E?(R=B("div",{className:"flex flex-wrap items-center gap-2",children:[K,j,E]}),e[34]=K,e[35]=j,e[36]=E,e[37]=R):R=e[37];let O;e[38]!==f||e[39]!==i?(O=f!==null&&s(Z,{error:i,testId:"tr-error"}),e[38]=f,e[39]=i,e[40]=O):O=e[40];let q;e[41]!==W||e[42]!==a?(q=W&&s(ae,{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]=W,e[42]=a,e[43]=q):q=e[43],u=B("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[R,O,q,f===null&&k&&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:h.length,total:g})}),f===null&&I.length>0&&s("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:I.map(_=>s(be,{expanded:M.has(_.traceId),onToggle:F,trace:_},_.traceId))})]}),e[10]=l,e[11]=f,e[12]=i,e[13]=M,e[14]=v,e[15]=d,e[16]=x,e[17]=n,e[18]=a,e[19]=u}else u=e[19];return u};function we(){return new Set}function Ne(){me()}export{Be as TracesPanel};
|
|
@@ -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 _e,u as U}from"../packem_shared/table-DdJBrClo.js";import{T as Ke}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{c as Ne}from"react/compiler-runtime";import{a as Oe,u as We}from"../packem_shared/use-async-submit-H68GHPz8.js";import{useAutoRefresh as Ze}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import Qe from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as ke}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as Ie,h as Ae,f as Re,e as Ee}from"../packem_shared/internal-AtZ4bTal.js";import{f as Xe}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{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}=We(),[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 _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=p=>{A(p.target.value)},e[3]=_):_=e[3];const De=_;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 R=H;let J;if(e[8]!==o.userFields||e[9]!==R){let p;e[11]!==R?(p=P=>!P.required||at(P,R(P)),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 P of o.userFields){const q=lt(P,R(P));q!==void 0&&(p[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 P=`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:P,children:[t(Xe,{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=R(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]=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(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(_e,{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(Pe,{children:n(L,{children:[t(z,{children:r("provider")}),t(z,{children:r("created")}),t(z,{"aria-label":r("Actions")})]})}),t(_e,{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(Pe,{children:n(L,{children:[t(z,{children:i("name")}),t(z,{children:i("created")}),t(z,{"aria-label":i("Actions")})]})}),t(_e,{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),_=(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))}finally{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!==""&&_(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;_(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=()=>{_(async()=>{await c.setAuthUserPassword({newPassword:f,userId:l.id}),d("")})},we=()=>{_(()=>c.impersonateAuthUser({userId:l.id}),{onResult:N=>{b(N.token)},refresh:!1})},K=()=>{_(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},Te=()=>{_(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:_,userId:l.id,version:I}),u.accounts&&t(it,{busy:m,runAction:_,userId:l.id,version:I}),(u.twoFactor||u.passkey)&&t(nt,{busy:m,capabilities:u,runAction:_,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=Qe(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()};Ze(()=>{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(_e,{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
|
+
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 _e,u as U}from"../packem_shared/table-DdJBrClo.js";import{T as Ke}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{c as Ne}from"react/compiler-runtime";import{u as Oe}from"../packem_shared/use-auth-config-9S_K_W-G.js";import{useAutoRefresh as We}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import Ze from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as ke}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as Ie,h as Ae,f as Re,e as Ee}from"../packem_shared/internal-AtZ4bTal.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-DLNCqLFq.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 _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=p=>{A(p.target.value)},e[3]=_):_=e[3];const De=_;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 R=H;let J;if(e[8]!==o.userFields||e[9]!==R){let p;e[11]!==R?(p=P=>!P.required||at(P,R(P)),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 P of o.userFields){const q=lt(P,R(P));q!==void 0&&(p[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 P=`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: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=R(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]=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(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(_e,{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(Pe,{children:n(L,{children:[t(z,{children:r("provider")}),t(z,{children:r("created")}),t(z,{"aria-label":r("Actions")})]})}),t(_e,{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(Pe,{children:n(L,{children:[t(z,{children:i("name")}),t(z,{children:i("created")}),t(z,{"aria-label":i("Actions")})]})}),t(_e,{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),_=(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))}finally{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!==""&&_(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;_(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=()=>{_(async()=>{await c.setAuthUserPassword({newPassword:f,userId:l.id}),d("")})},we=()=>{_(()=>c.impersonateAuthUser({userId:l.id}),{onResult:N=>{b(N.token)},refresh:!1})},K=()=>{_(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},Te=()=>{_(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:_,userId:l.id,version:I}),u.accounts&&t(it,{busy:m,runAction:_,userId:l.id,version:I}),(u.twoFactor||u.passkey)&&t(nt,{busy:m,capabilities:u,runAction:_,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,_t=({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(_e,{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{_t as UsersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as V}from"@lunora/react";import{useState as m,useEffect as ae,useMemo as P}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 G}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as re}from"../packem_shared/input-JHu63lTv.js";import{n as U,d as _,m as N,p as o,f as K,u as i}from"../packem_shared/table-DdJBrClo.js";import{l as ne}from"../packem_shared/textarea-Bu2-jKAs.js";import{K as se}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as H}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{f as A,e as E,c as B,a as Y}from"../packem_shared/internal-AtZ4bTal.js";import{jsxs as s,jsx as e}from"react/jsx-runtime";const le=["queued","running","paused","waiting","complete","errored","terminated"],oe=["pause","resume","terminate"],ie="WORKFLOWS_NOT_CONFIGURED",de=d=>typeof d=="object"&&d!==null&&d.code===ie,ce=d=>{const r=d.error??d.output;if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"(unserializable)"}},me=({loadDetail:d,loadInstances:r,readOnly:b,runAction:R,workflowName:h})=>{const I=V(),n=X(),[w,g]=m(null),[S,$]=m(null),[k,T]=m(""),[v,p]=m(null),[F,C]=m(!1),[j,z]=m(null),f=d??(a=>I.getWorkflowInstance(a)),x=b?void 0:R??(r===void 0?a=>I.setWorkflowInstanceStatus(a):void 0),O=async()=>{p(null),C(!1);const a=k===""?void 0:k;try{if(r===void 0){const l=await I.listWorkflowInstances({name:h,status:a});if(l.configured===!1){g(null),C(!0);return}g(l.instances);return}g(await r({name:h,status:a}))}catch(l){g(null),de(l)?C(!0):p(E(l))}};ae(()=>{$(null),A(O())},[h,k]);const D=async a=>{p(null);try{$(await f({id:a,name:h}))}catch(l){p(E(l))}},q=async(a,l)=>{if(x!==void 0){z(a),p(null);try{await x({action:l,id:a,name:h}),await O()}catch(M){p(E(M))}finally{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=>{T(a.target.value)},value:k,children:[e("option",{value:"",children:n("All statuses")}),le.map(a=>e("option",{value:a,children:a},a))]})]}),v!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:v}),F&&e(G,{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&&w!==null&&w.length===0&&e(G,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),w!==null&&w.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(N,{children:[e(o,{children:n("Instance id")}),e(o,{children:n("Status")}),e(o,{children:n("Created")}),e(o,{children:n("Ended")}),e(o,{"aria-label":n("Actions")})]})}),e(K,{children:w.map(a=>s(N,{"data-testid":`workflow-instance-${a.id}`,children:[e(i,{className:"font-mono text-xs",children:a.id}),e(i,{className:"font-mono text-xs",children:a.status}),e(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"—"}),e(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"—"}),e(i,{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")}),x!==void 0&&oe.map(l=>e(W,{"data-testid":`workflow-instance-${l}-${a.id}`,disabled:j===a.id,onClick:()=>{A(q(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(N,{children:[e(o,{children:n("Step")}),e(o,{children:n("Type")}),e(o,{children:n("Attempts")}),e(o,{children:n("Started")}),e(o,{children:n("Output")})]})}),e(K,{children:S.steps.map((a,l)=>s(N,{"data-testid":`workflow-step-${String(l)}`,children:[e(i,{className:"font-mono text-xs",children:a.name}),e(i,{className:"text-xs text-muted-foreground",children:a.type??"—"}),e(i,{className:"tabular-nums",children:a.attempts??"—"}),e(i,{className:"text-muted-foreground tabular-nums",children:a.start??"—"}),e(i,{className:"font-mono text-xs text-muted-foreground",children:ce(a)})]},`${a.name}:${String(l)}`))})]})]})})]})},ue=Y(H.createWorkflowInstance),fe=Y(H.getWorkflowInstanceStatus),he=d=>{if(d.error)return`${d.error.name}: ${d.error.message}`;if(d.output===void 0)return"—";try{return JSON.stringify(d.output)}catch{return"(unserializable)"}},Oe=()=>{const d=V(),r=X(),{data:b,error:R}=se(H.listWorkflows,{}),[h,I]=m(""),[n,w]=m(""),[g,S]=m(""),[$,k]=m(!1),[T,v]=m(null),[p,F]=m([]),[C,j]=m(null),z=b!==void 0,f=P(()=>Array.isArray(b?.workflows)?[...b.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],[b]),x=P(()=>f.some(t=>t.exportName===h)?h:f[0]?.exportName??"",[f,h]),O=P(()=>f.find(t=>t.exportName===x),[f,x]),D=t=>{F(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},q=async()=>{const t=x;if(t==="")return;let u;const c=g.trim();if(c!=="")try{u=JSON.parse(c)}catch{v(r("Params must be valid JSON"));return}k(!0),v(null);try{const y=n.trim(),Q=await d.query(ue,{exportName:t,id:y===""?void 0:y,params:u},B(""));D({exportName:t,id:Q.id,status:Q.status}),w("")}catch(y){v(E(y))}finally{k(!1)}},a=()=>{A(q())},l=async(t,u)=>{j(u);try{const c=await d.query(fe,{exportName:t,id:u},B(""));D({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){v(E(c))}finally{j(null)}},M=t=>{I(t.target.value)},Z=t=>{w(t.target.value)},ee=t=>{S(t.target.value)},te=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:[R!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),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&&f.length===0?e(G,{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(N,{children:[e(o,{children:r("Export")}),e(o,{children:r("Name")}),e(o,{children:r("Class")}),e(o,{children:r("Binding")})]})}),e(K,{children:f.map(t=>s(N,{"data-testid":`workflows-row-${t.exportName}`,children:[e(i,{className:"font-mono text-xs",children:t.exportName}),e(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),e(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),f.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")}),T!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:T}),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:M,value:x,children:f.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(re,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:Z,placeholder:r("Instance id (optional)"),value:n}),e(W,{"data-testid":"workflows-start-button",disabled:$||x==="",onClick:a,children:r($?"Starting…":"Start instance")})]}),e(ne,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:ee,placeholder:r("Params (JSON, optional)"),value:g})]}),p.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(N,{children:[e(o,{children:r("Workflow")}),e(o,{children:r("Instance id")}),e(o,{children:r("Status")}),e(o,{children:r("Output")}),e(o,{})]})}),e(K,{children:p.map(t=>s(N,{"data-testid":`workflows-instance-${t.id}`,children:[e(i,{className:"font-mono text-xs",children:t.exportName}),e(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),e(i,{className:"font-mono text-xs",children:t.status}),e(i,{className:"font-mono text-xs text-muted-foreground",children:he(t)}),e(i,{children:e(W,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:te,size:"xs",variant:"outline",children:C===t.id?r("Refreshing…"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),O!==void 0&&e(me,{workflowName:O.name})]})};export{Oe as default};
|
|
1
|
+
import{useLunora as V}from"@lunora/react";import{useState as m,useEffect as ae,useMemo as P}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 G}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as re}from"../packem_shared/input-JHu63lTv.js";import{n as U,d as _,m as N,p as o,f as K,u as i}from"../packem_shared/table-DdJBrClo.js";import{l as ne}from"../packem_shared/textarea-Bu2-jKAs.js";import{K as se}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as H}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{f as A,e as E,c as B,a as Y}from"../packem_shared/internal-AtZ4bTal.js";import{jsxs as s,jsx as e}from"react/jsx-runtime";const le=["queued","running","paused","waiting","complete","errored","terminated"],oe=["pause","resume","terminate"],ie="WORKFLOWS_NOT_CONFIGURED",de=d=>typeof d=="object"&&d!==null&&d.code===ie,ce=d=>{const r=d.error??d.output;if(r===void 0)return"—";try{return JSON.stringify(r)}catch{return"(unserializable)"}},me=({loadDetail:d,loadInstances:r,readOnly:b,runAction:R,workflowName:h})=>{const I=V(),n=X(),[w,g]=m(null),[S,$]=m(null),[k,T]=m(""),[v,p]=m(null),[F,C]=m(!1),[j,z]=m(null),f=d??(a=>I.getWorkflowInstance(a)),x=b?void 0:R??(r===void 0?a=>I.setWorkflowInstanceStatus(a):void 0),O=async()=>{p(null),C(!1);const a=k===""?void 0:k;try{if(r===void 0){const l=await I.listWorkflowInstances({name:h,status:a});if(l.configured===!1){g(null),C(!0);return}g(l.instances);return}g(await r({name:h,status:a}))}catch(l){g(null),de(l)?C(!0):p(E(l))}};ae(()=>{$(null),A(O())},[h,k]);const D=async a=>{p(null);try{$(await f({id:a,name:h}))}catch(l){p(E(l))}},q=async(a,l)=>{if(x!==void 0){z(a),p(null);try{await x({action:l,id:a,name:h}),await O()}catch(M){p(E(M))}finally{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=>{T(a.target.value)},value:k,children:[e("option",{value:"",children:n("All statuses")}),le.map(a=>e("option",{value:a,children:a},a))]})]}),v!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:v}),F&&e(G,{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&&w!==null&&w.length===0&&e(G,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),w!==null&&w.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(N,{children:[e(o,{children:n("Instance id")}),e(o,{children:n("Status")}),e(o,{children:n("Created")}),e(o,{children:n("Ended")}),e(o,{"aria-label":n("Actions")})]})}),e(K,{children:w.map(a=>s(N,{"data-testid":`workflow-instance-${a.id}`,children:[e(i,{className:"font-mono text-xs",children:a.id}),e(i,{className:"font-mono text-xs",children:a.status}),e(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"—"}),e(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"—"}),e(i,{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")}),x!==void 0&&oe.map(l=>e(W,{"data-testid":`workflow-instance-${l}-${a.id}`,disabled:j===a.id,onClick:()=>{A(q(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(N,{children:[e(o,{children:n("Step")}),e(o,{children:n("Type")}),e(o,{children:n("Attempts")}),e(o,{children:n("Started")}),e(o,{children:n("Output")})]})}),e(K,{children:S.steps.map((a,l)=>s(N,{"data-testid":`workflow-step-${String(l)}`,children:[e(i,{className:"font-mono text-xs",children:a.name}),e(i,{className:"text-xs text-muted-foreground",children:a.type??"—"}),e(i,{className:"tabular-nums",children:a.attempts??"—"}),e(i,{className:"text-muted-foreground tabular-nums",children:a.start??"—"}),e(i,{className:"font-mono text-xs text-muted-foreground",children:ce(a)})]},`${a.name}:${String(l)}`))})]})]})})]})},ue=Y(H.createWorkflowInstance),fe=Y(H.getWorkflowInstanceStatus),he=d=>{if(d.error)return`${d.error.name}: ${d.error.message}`;if(d.output===void 0)return"—";try{return JSON.stringify(d.output)}catch{return"(unserializable)"}},Oe=()=>{const d=V(),r=X(),{data:b,error:R}=se(H.listWorkflows,{}),[h,I]=m(""),[n,w]=m(""),[g,S]=m(""),[$,k]=m(!1),[T,v]=m(null),[p,F]=m([]),[C,j]=m(null),z=b!==void 0,f=P(()=>Array.isArray(b?.workflows)?[...b.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],[b]),x=P(()=>f.some(t=>t.exportName===h)?h:f[0]?.exportName??"",[f,h]),O=P(()=>f.find(t=>t.exportName===x),[f,x]),D=t=>{F(u=>{const c=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...c]})},q=async()=>{const t=x;if(t==="")return;let u;const c=g.trim();if(c!=="")try{u=JSON.parse(c)}catch{v(r("Params must be valid JSON"));return}k(!0),v(null);try{const y=n.trim(),Q=await d.query(ue,{exportName:t,id:y===""?void 0:y,params:u},B(""));D({exportName:t,id:Q.id,status:Q.status}),w("")}catch(y){v(E(y))}finally{k(!1)}},a=()=>{A(q())},l=async(t,u)=>{j(u);try{const c=await d.query(fe,{exportName:t,id:u},B(""));D({error:c.error,exportName:t,id:c.id,output:c.output,status:c.status})}catch(c){v(E(c))}finally{j(null)}},M=t=>{I(t.target.value)},Z=t=>{w(t.target.value)},ee=t=>{S(t.target.value)},te=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:[R!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:R}),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&&f.length===0?e(G,{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(N,{children:[e(o,{children:r("Export")}),e(o,{children:r("Name")}),e(o,{children:r("Class")}),e(o,{children:r("Binding")})]})}),e(K,{children:f.map(t=>s(N,{"data-testid":`workflows-row-${t.exportName}`,children:[e(i,{className:"font-mono text-xs",children:t.exportName}),e(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),e(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),f.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")}),T!==null&&e("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:T}),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:M,value:x,children:f.map(t=>e("option",{value:t.exportName,children:t.exportName},t.exportName))}),e(re,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:Z,placeholder:r("Instance id (optional)"),value:n}),e(W,{"data-testid":"workflows-start-button",disabled:$||x==="",onClick:a,children:r($?"Starting…":"Start instance")})]}),e(ne,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:ee,placeholder:r("Params (JSON, optional)"),value:g})]}),p.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(N,{children:[e(o,{children:r("Workflow")}),e(o,{children:r("Instance id")}),e(o,{children:r("Status")}),e(o,{children:r("Output")}),e(o,{})]})}),e(K,{children:p.map(t=>s(N,{"data-testid":`workflows-instance-${t.id}`,children:[e(i,{className:"font-mono text-xs",children:t.exportName}),e(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),e(i,{className:"font-mono text-xs",children:t.status}),e(i,{className:"font-mono text-xs text-muted-foreground",children:he(t)}),e(i,{children:e(W,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:C===t.id,onClick:te,size:"xs",variant:"outline",children:C===t.id?r("Refreshing…"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),O!==void 0&&e(me,{workflowName:O.name})]})};export{Oe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _="__lunora_admin__:",e={assignIssue:"__lunora_admin__:assignIssue",clearCapturedMail:"__lunora_admin__:clearCapturedMail",clearQueueMessages:"__lunora_admin__:clearQueueMessages",clearTable:"__lunora_admin__:clearTable",createWorkflowInstance:"__lunora_admin__:createWorkflowInstance",deleteRows:"__lunora_admin__:deleteRows",describeTable:"__lunora_admin__:describeTable",describeTables:"__lunora_admin__:describeTables",explainIssue:"__lunora_admin__:explainIssue",exportShard:"__lunora_admin__:exportShard",facetColumn:"__lunora_admin__:facetColumn",getAdvisories:"__lunora_admin__:getAdvisories",getAuditLog:"__lunora_admin__:getAuditLog",getAuthAuditLog:"__lunora_admin__:getAuthAuditLog",getAuthMetrics:"__lunora_admin__:getAuthMetrics",getCapturedMail:"__lunora_admin__:getCapturedMail",getFanoutMetrics:"__lunora_admin__:getFanoutMetrics",getFunctionStats:"__lunora_admin__:getFunctionStats",getIssues:"__lunora_admin__:getIssues",listFlags:"__lunora_admin__:listFlags",listPushSubscriptions:"__lunora_admin__:listPushSubscriptions",listQueues:"__lunora_admin__:listQueues",listSubscriptions:"__lunora_admin__:listSubscriptions",listTableIndexes:"__lunora_admin__:listTableIndexes",listWorkflows:"__lunora_admin__:listWorkflows",getLogs:"__lunora_admin__:getLogs",getMetricHistory:"__lunora_admin__:getMetricHistory",getMetricSeries:"__lunora_admin__:getMetricSeries",getMetrics:"__lunora_admin__:getMetrics",getPitrBookmark:"__lunora_admin__:getPitrBookmark",getQueueMessages:"__lunora_admin__:getQueueMessages",getRequestLog:"__lunora_admin__:getRequestLog",getSecurityAudit:"__lunora_admin__:getSecurityAudit",getSettings:"__lunora_admin__:getSettings",getTraces:"__lunora_admin__:getTraces",getWorkflowInstanceStatus:"__lunora_admin__:getWorkflowInstanceStatus",ignoreIssue:"__lunora_admin__:ignoreIssue",importShard:"__lunora_admin__:importShard",listTables:"__lunora_admin__:listTables",maskPolicies:"__lunora_admin__:maskPolicies",migrationStatus:"__lunora_admin__:migrationStatus",pitrRestore:"__lunora_admin__:pitrRestore",readTablePage:"__lunora_admin__:readTablePage",replayQueueMessage:"__lunora_admin__:replayQueueMessage",resolveIssue:"__lunora_admin__:resolveIssue",rlsPolicies:"__lunora_admin__:rlsPolicies",runAs:"__lunora_admin__:runAs",runMigration:"__lunora_admin__:runMigration",runSql:"__lunora_admin__:runSql",sendQueueMessage:"__lunora_admin__:sendQueueMessage",sendTestMail:"__lunora_admin__:sendTestMail",setIssueSeverity:"__lunora_admin__:setIssueSeverity",storageOrphans:"__lunora_admin__:storageOrphans",storageReferences:"__lunora_admin__:storageReferences",storageRules:"__lunora_admin__:storageRules",studioFeatures:"__lunora_admin__:studioFeatures",writeRow:"__lunora_admin__:writeRow"};export{e as ADMIN_FUNCTIONS,_ as ADMIN_FUNCTION_PREFIX};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as F}from"react/compiler-runtime";import{useLunora as G}from"@lunora/react";import{useState as Q,useEffect as ee}from"react";import{u as Z}from"./button-BkCrNcAs.js";import{E as V}from"./empty-state-Cg7t_8qu.js";import{useT as O}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as te}from"./ADMIN_FUNCTIONS-
|
|
1
|
+
import{c as F}from"react/compiler-runtime";import{useLunora as G}from"@lunora/react";import{useState as Q,useEffect as ee}from"react";import{u as Z}from"./button-BkCrNcAs.js";import{E as V}from"./empty-state-Cg7t_8qu.js";import{useT as O}from"./DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as te}from"./ADMIN_FUNCTIONS-CpgIo9pj.js";import{g as ae,c as ne,a as le}from"./internal-AtZ4bTal.js";import{jsxs as P,jsx as p}from"react/jsx-runtime";const ie=le(te.listTables),oe=["react","client","cli"],re=!1,se={action:"action",mutation:"mutation",query:"query"},X=n=>{const e=n.indexOf(":");return e===-1?{file:"",fn:n}:{file:n.slice(0,e),fn:n.slice(e+1)}},J=({file:n,fn:e,kind:r})=>`await client.${se[r]}(api.${n}.${e}, { /* args */ });`,ce=n=>{const e=`api.${n.file}.${n.fn}`;switch(n.kind){case"action":return J(n);case"mutation":return`const ${n.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},de=({file:n,fn:e})=>`lunora run ${n}:${e} --args '{ }'`,pe=n=>["// Read rows",`const rows = await ctx.db.query("${n}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${n}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${n}">;`,`type RowId = Id<"${n}">;`].join(`
|
|
2
2
|
`),fe=(n,e)=>{switch(n){case"cli":return de(e);case"client":return J(e);default:return ce(e)}},W=n=>{const e=F(19),{code:r,label:s,testId:a}=n,l=O();let o;e[0]!==r?(o=()=>{ae(r)},e[0]=r,e[1]=o):o=e[1];const f=o;let t;e[2]!==s?(t=p("span",{className:"text-xs font-medium text-muted-foreground",children:s}),e[2]=s,e[3]=t):t=e[3];const c=`${a}-copy`;let i;e[4]!==l?(i=l("Copy"),e[4]=l,e[5]=i):i=e[5];let d;e[6]!==f||e[7]!==c||e[8]!==i?(d=p(Z,{"data-testid":c,onClick:f,size:"xs",type:"button",variant:"ghost",children:i}),e[6]=f,e[7]=c,e[8]=i,e[9]=d):d=e[9];let u;e[10]!==t||e[11]!==d?(u=P("div",{className:"flex items-center justify-between gap-2",children:[t,d]}),e[10]=t,e[11]=d,e[12]=u):u=e[12];let h;e[13]!==r||e[14]!==a?(h=p("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":a,children:r}),e[13]=r,e[14]=a,e[15]=h):h=e[15];let x;return e[16]!==u||e[17]!==h?(x=P("div",{className:"flex flex-col gap-1.5",children:[u,h]}),e[16]=u,e[17]=h,e[18]=x):x=e[18],x},ue=n=>{const e=F(50),{file:r,fn:s,kind:a}=n,l=O(),[o,f]=Q("react");let t,c,i;if(e[0]!==r||e[1]!==s||e[2]!==a||e[3]!==l||e[4]!==o){const y={file:r,fn:s,kind:a};let I;e[8]!==l?(I=l("CLI"),e[8]=l,e[9]=I):I=e[9];let C;e[10]!==l?(C=l("Client"),e[10]=l,e[11]=C):C=e[11];let S;e[12]!==l?(S=l("React"),e[12]=l,e[13]=S):S=e[13];let A;e[14]!==I||e[15]!==C||e[16]!==S?(A={cli:I,client:C,react:S},e[14]=I,e[15]=C,e[16]=S,e[17]=A):A=e[17],i=A;let q;e[18]===Symbol.for("react.memo_cache_sentinel")?(q=H=>{f(H.currentTarget.dataset.tab)},e[18]=q):q=e[18],t=q,c=fe(o,y),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=o,e[5]=t,e[6]=c,e[7]=i}else t=e[5],c=e[6],i=e[7];const d=c,u=a==="action"&&o==="react"&&!re,h=`api.${r}.${s}`;let x;e[19]!==h?(x=p("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:h}),e[19]=h,e[20]=x):x=e[20];let _;e[21]!==a||e[22]!==l?(_=l("Call this {kind} from your app.",{kind:a}),e[21]=a,e[22]=l,e[23]=_):_=e[23];let k;e[24]!==_?(k=p("p",{className:"text-xs text-muted-foreground",children:_}),e[24]=_,e[25]=k):k=e[25];let m;e[26]!==x||e[27]!==k?(m=P("div",{children:[x,k]}),e[26]=x,e[27]=k,e[28]=m):m=e[28];let g;e[29]!==l?(g=l("Snippet flavour"),e[29]=l,e[30]=g):g=e[30];let $;e[31]!==t||e[32]!==o||e[33]!==i?($=oe.map(y=>p(Z,{"aria-selected":o===y,"data-tab":y,"data-testid":`api-tab-${y}`,onClick:t,role:"tab",size:"xs",type:"button",variant:o===y?"default":"outline",children:i[y]},y)),e[31]=t,e[32]=o,e[33]=i,e[34]=$):$=e[34];let N;e[35]!==g||e[36]!==$?(N=p("div",{"aria-label":g,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:$}),e[35]=g,e[36]=$,e[37]=N):N=e[37];const R=i[o],j=`api-snippet-${o}`;let w;e[38]!==d||e[39]!==R||e[40]!==j?(w=p(W,{code:d,label:R,testId:j}),e[38]=d,e[39]=R,e[40]=j,e[41]=w):w=e[41];let v;e[42]!==u||e[43]!==l?(v=u&&p("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:l("Actions have no React hook — call them through the client.")}),e[42]=u,e[43]=l,e[44]=v):v=e[44];let T;return e[45]!==w||e[46]!==v||e[47]!==m||e[48]!==N?(T=P("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[m,N,w,v]}),e[45]=w,e[46]=v,e[47]=m,e[48]=N,e[49]=T):T=e[49],T},me=n=>{const e=F(19),{name:r}=n,s=O();let a;e[0]!==r?(a=pe(r),e[0]=r,e[1]=a):a=e[1];const l=a;let o;e[2]!==r?(o=p("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:r}),e[2]=r,e[3]=o):o=e[3];let f;e[4]!==s?(f=s("Read and write this table through the typed data model."),e[4]=s,e[5]=f):f=e[5];let t;e[6]!==f?(t=p("p",{className:"text-xs text-muted-foreground",children:f}),e[6]=f,e[7]=t):t=e[7];let c;e[8]!==o||e[9]!==t?(c=P("div",{children:[o,t]}),e[8]=o,e[9]=t,e[10]=c):c=e[10];let i;e[11]!==s?(i=s("Data model"),e[11]=s,e[12]=i):i=e[12];let d;e[13]!==l||e[14]!==i?(d=p(W,{code:l,label:i,testId:"api-snippet-table"}),e[13]=l,e[14]=i,e[15]=d):d=e[15];let u;return e[16]!==c||e[17]!==d?(u=P("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,d]}),e[16]=c,e[17]=d,e[18]=u):u=e[18],u},Y=n=>{const e=F(8),{active:r,label:s,onSelect:a,testId:l,value:o}=n;let f;e[0]!==a||e[1]!==o?(f=()=>{a(o)},e[0]=a,e[1]=o,e[2]=f):f=e[2];const t=f,c=r?"page":void 0;let i;return e[3]!==s||e[4]!==t||e[5]!==c||e[6]!==l?(i=p("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":l,onClick:t,type:"button",children:s}),e[3]=s,e[4]=t,e[5]=c,e[6]=l,e[7]=i):i=e[7],i},Re=n=>{const e=F(67),{functions:r,initialShardKey:s}=n,a=O(),l=G(),[o,f]=Q(null),[t,c]=Q(null);let i,d;e[0]!==l||e[1]!==s?(i=()=>{let D=!1;return l.query(ie,{},ne(s??"")).then(E=>(D||f(E),E)).catch(()=>{D||f([])}),()=>{D=!0}},d=[l,s],e[0]=l,e[1]=s,e[2]=i,e[3]=d):(i=e[2],d=e[3]),ee(i,d);let u;e[4]!==r?(u=r??[],e[4]=r,e[5]=u):u=e[5];const h=u;let x;if(e[6]!==h){const D=new Map;for(const E of h){const{file:B,fn:L}=X(E.path),K=D.get(B)??[];K.push({fn:L,kind:E.kind,path:E.path}),D.set(B,K)}x=[...D.entries()].map(xe).toSorted(be),e[6]=h,e[7]=x}else x=e[7];const _=x;let k,m,g,$,N,R,j,w,v,T;if(e[8]!==h||e[9]!==_||e[10]!==t||e[11]!==a||e[12]!==o){const D=(o??[]).map(ge).toSorted(ve);let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=b=>{c({kind:"fn",path:b})},e[23]=E):E=e[23];const B=E;let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=b=>{c({kind:"table",name:b})},e[24]=L):L=e[24];const K=L;if(m=t?.kind==="fn"?h.find(b=>b.path===t.path):void 0,k=h.length>0||D.length>0,g=m===void 0?void 0:X(m.path),$="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",N="lunora-api-docs",e[25]!==a?(R=a("API resources"),e[25]=a,e[26]=R):R=e[26],j="flex flex-col gap-4 overflow-y-auto",w="api-rail",e[27]!==_||e[28]!==t||e[29]!==a){let b;e[31]!==t||e[32]!==a?(b=U=>P("div",{className:"flex flex-col gap-1",children:[p("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:U.file||a("(root)")}),U.items.map(M=>p(Y,{active:t?.kind==="fn"&&t.path===M.path,label:M.fn,onSelect:B,testId:`api-rail-fn-${M.path}`,value:M.path},M.path))]},U.file),e[31]=t,e[32]=a,e[33]=b):b=e[33],v=_.map(b),e[27]=_,e[28]=t,e[29]=a,e[30]=v}else v=e[30];T=D.length>0&&P("div",{className:"flex flex-col gap-1",children:[p("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Tables")}),D.map(b=>p(Y,{active:t?.kind==="table"&&t.name===b,label:b,onSelect:K,testId:`api-rail-table-${b}`,value:b},b))]}),e[8]=h,e[9]=_,e[10]=t,e[11]=a,e[12]=o,e[13]=k,e[14]=m,e[15]=g,e[16]=$,e[17]=N,e[18]=R,e[19]=j,e[20]=w,e[21]=v,e[22]=T}else k=e[13],m=e[14],g=e[15],$=e[16],N=e[17],R=e[18],j=e[19],w=e[20],v=e[21],T=e[22];let y;e[34]!==k||e[35]!==a?(y=!k&&p("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:a("No functions or tables to document yet.")}),e[34]=k,e[35]=a,e[36]=y):y=e[36];let I;e[37]!==y||e[38]!==R||e[39]!==j||e[40]!==w||e[41]!==v||e[42]!==T?(I=P("nav",{"aria-label":R,className:j,"data-testid":w,children:[v,T,y]}),e[37]=y,e[38]=R,e[39]=j,e[40]=w,e[41]=v,e[42]=T,e[43]=I):I=e[43];let C;e[44]!==t||e[45]!==a?(C=t===null&&p(V,{description:a("Select a function or table to see how to call it from your app."),testId:"api-empty",title:a("API usage snippets")}),e[44]=t,e[45]=a,e[46]=C):C=e[46];let S;e[47]!==t?.kind||e[48]!==m||e[49]!==g?(S=t?.kind==="fn"&&m!==void 0&&g!==void 0&&p(ue,{file:g.file,fn:g.fn,kind:m.kind},m.path),e[47]=t?.kind,e[48]=m,e[49]=g,e[50]=S):S=e[50];let A;e[51]!==t?.kind||e[52]!==m||e[53]!==a?(A=t?.kind==="fn"&&m===void 0&&p(V,{testId:"api-empty",title:a("API usage snippets")}),e[51]=t?.kind,e[52]=m,e[53]=a,e[54]=A):A=e[54];let q;e[55]!==t?(q=t?.kind==="table"&&p(me,{name:t.name}),e[55]=t,e[56]=q):q=e[56];let H;e[57]!==C||e[58]!==S||e[59]!==A||e[60]!==q?(H=P("div",{className:"min-w-0",children:[C,S,A,q]}),e[57]=C,e[58]=S,e[59]=A,e[60]=q,e[61]=H):H=e[61];let z;return e[62]!==$||e[63]!==N||e[64]!==I||e[65]!==H?(z=P("div",{className:$,"data-testid":N,children:[I,H]}),e[62]=$,e[63]=N,e[64]=I,e[65]=H,e[66]=z):z=e[66],z};function he(n,e){return n.fn.localeCompare(e.fn)}function xe(n){const[e,r]=n;return{file:e,items:r.toSorted(he)}}function be(n,e){return n.file.localeCompare(e.file)}function ge(n){return n.name}function ve(n,e){return n.localeCompare(e)}export{re as REACT_HAS_ACTION_HOOK,de as buildCliSnippet,J as buildClientSnippet,ce as buildReactSnippet,pe as buildTableSnippet,Re as default,X as splitPath};
|