bunqueue-dashboard 0.0.37 → 0.0.39
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/README.md +21 -11
- package/agent/backup/resultValidation.ts +1 -1
- package/agent/backup/routes.ts +63 -17
- package/agent/db/query.ts +2 -1
- package/agent/manager/config.ts +2 -1
- package/agent/manager/process.ts +51 -5
- package/agent/manager/storageMode.ts +21 -0
- package/agent/manager/types.ts +2 -0
- package/agent/manager.ts +1 -0
- package/agent/queue/routes.ts +1 -2
- package/agent/queue/runtime.ts +5 -0
- package/agent/queue/types.ts +1 -0
- package/agent/server/controlRoutes.ts +109 -8
- package/agent/server/databaseRoutes.ts +47 -14
- package/agent/server/errors.ts +1 -0
- package/agent/server/lifecycle.ts +25 -8
- package/agent/server/managedRuntime.ts +27 -0
- package/agent/server/router.ts +90 -40
- package/agent/server/workflowReadRoutes.ts +28 -11
- package/agent/workflows.ts +1 -1
- package/dist/.vite/manifest.json +490 -476
- package/dist/assets/AddJob-d5KBvmN8.js +3 -0
- package/dist/assets/{Alerts-Gh1pVbqj.js → Alerts-5I44QTnQ.js} +1 -1
- package/dist/assets/{AreaChart-w0ruozXH.js → AreaChart-DEAalJ6P.js} +1 -1
- package/dist/assets/Benchmark-S1afsQRd.js +1 -0
- package/dist/assets/{BulkAddJobs-Di_IgRSH.js → BulkAddJobs-BO8LWUHE.js} +1 -1
- package/dist/assets/{Button-BPqpRZJD.js → Button-Ch1W94fJ.js} +1 -1
- package/dist/assets/{Card-C7NMhqUt.js → Card-CWxrC8OY.js} +1 -1
- package/dist/assets/{CopilotPanel-Db5nYpo1.js → CopilotPanel-DDkRd35p.js} +4 -4
- package/dist/assets/{Cron-BRgWcBGk.js → Cron-X3Y5uISO.js} +1 -1
- package/dist/assets/CronManager-ugmYEAwY.js +1 -0
- package/dist/assets/{Database-BeoEreW0.js → Database-koy8haPX.js} +1 -1
- package/dist/assets/Diagnostics-D6oqvkOs.js +1 -0
- package/dist/assets/{Dlq-DfCg04Jd.js → Dlq-D70Lzmsa.js} +1 -1
- package/dist/assets/{DlqControl-BRCkUXvb.js → DlqControl-nUT5Zzkl.js} +1 -1
- package/dist/assets/{DlqPro-BHJwBYsN.js → DlqPro-VMuBKgP-.js} +1 -1
- package/dist/assets/Flows-CAG0nDnt.js +2 -0
- package/dist/assets/JobInspector-CiS5HOSQ.js +2 -0
- package/dist/assets/{Jobs-URpnFjC6.js → Jobs-CkyRvzOT.js} +1 -1
- package/dist/assets/{JobsPro-pQ_RFSU3.js → JobsPro-B4-CSoq3.js} +1 -1
- package/dist/assets/{Logs-C5jX2OPE.js → Logs-DBTz2PTz.js} +1 -1
- package/dist/assets/{LogsPro-Cq_npmmS.js → LogsPro-BCFeegvr.js} +1 -1
- package/dist/assets/{McpServer-DtCTmQBu.js → McpServer-BKlTR1qr.js} +2 -2
- package/dist/assets/{Metrics-BdxitePr.js → Metrics-Du__9Lbn.js} +1 -1
- package/dist/assets/{MetricsPro-orHfW0mg.js → MetricsPro-CqnaO6YX.js} +1 -1
- package/dist/assets/{Overview-DaNns1aj.js → Overview-udSSt7ZB.js} +1 -1
- package/dist/assets/{PageHeader-BXlZSBcc.js → PageHeader-CvIyaFOO.js} +1 -1
- package/dist/assets/{Pagination-Q-vf4hsX.js → Pagination-x-Cwgrul.js} +1 -1
- package/dist/assets/QueueActions-D7cQrGvJ.js +1 -0
- package/dist/assets/{QueueControl-l5bSdMgb.js → QueueControl-BF638r_0.js} +1 -1
- package/dist/assets/QueueDetail-C-ms6bMe.js +1 -0
- package/dist/assets/QueueDetailPro-DXEdsZx_.js +1 -0
- package/dist/assets/{Queues-DeLXlww2.js → Queues-BUMwTVAf.js} +1 -1
- package/dist/assets/{QueuesOverview-DoQ-MUfT.js → QueuesOverview-Du8XLgN0.js} +1 -1
- package/dist/assets/{S3Backup-D2agV9_z.js → S3Backup-CDICSzxM.js} +1 -1
- package/dist/assets/S3BackupPro-CBidbI-s.js +3 -0
- package/dist/assets/ServerControl-CPT0LpsC.js +3 -0
- package/dist/assets/{Settings-CiJRj_SM.js → Settings-CmxfSX_8.js} +1 -1
- package/dist/assets/{StatusBadge-B0I7hNBX.js → StatusBadge-BoOVTnKu.js} +1 -1
- package/dist/assets/{Usage-DbHJgA4t.js → Usage-B895tSxi.js} +1 -1
- package/dist/assets/{UsagePro-LoPo3k1L.js → UsagePro-CASN77iV.js} +1 -1
- package/dist/assets/{Webhooks-CuzIJHwk.js → Webhooks-CXbZOFFw.js} +1 -1
- package/dist/assets/{Workers-BpUgpwUH.js → Workers-BceQlUhX.js} +1 -1
- package/dist/assets/WorkersPro-Dtml89jB.js +1 -0
- package/dist/assets/Workflows-B8wmQN2X.js +1 -0
- package/dist/assets/{api-V_sVpHDo.js → api-81m1TwB7.js} +1 -1
- package/dist/assets/bq-BOfwNIlJ.js +1 -0
- package/dist/assets/{connectionStore-CKFQrxDo.js → connectionStore-CFuNYZ_8.js} +1 -1
- package/dist/assets/{controlConnectionEpoch-JM4omZ6j.js → controlConnectionEpoch-DzbuWOhe.js} +1 -1
- package/dist/assets/{feedback-BnGE2oW2.js → feedback-QDN1AsYt.js} +1 -1
- package/dist/assets/flowMutationSafety-6cP-l4Pa.js +1 -0
- package/dist/assets/{form-tC20r4Ma.js → form-C4oby9pI.js} +1 -1
- package/dist/assets/{icons-CIvFfU2b.js → icons-BVzwsfbG.js} +1 -1
- package/dist/assets/index-B-QjN7pA.css +1 -0
- package/dist/assets/index-TploGF7u.js +8 -0
- package/dist/assets/install-BPp8nydm.js +3 -0
- package/dist/assets/{react-vendor-CyjgmGTq.js → react-vendor-CvwrP0tU.js} +2 -2
- package/dist/assets/{responses-CBLyy1Ob.js → responses-C9lP49qu.js} +1 -1
- package/dist/assets/{toastStore-B7n0zS0y.js → toastStore-B31o6Z5J.js} +1 -1
- package/dist/assets/{upstreamPaths-CDVsu6IM.js → upstreamPaths-ZeijhPPb.js} +1 -1
- package/dist/assets/useControlActionGuard-DT7uudrj.js +1 -0
- package/dist/assets/{usePolledData-c53tx1jw.js → usePolledData-CNtNtd0a.js} +1 -1
- package/dist/assets/useServerActionGuard-Db7PPgaI.js +1 -0
- package/dist/assets/useThroughputSeries-_J7gWbcI.js +1 -0
- package/dist/index.html +21 -18
- package/package.json +18 -8
- package/scripts/embedded.gen.ts +152 -150
- package/scripts/serveHandler.ts +22 -1
- package/scripts/servePolicy.ts +12 -3
- package/dist/assets/AddJob-CWkkVHmf.js +0 -3
- package/dist/assets/Benchmark-Dir2A1CQ.js +0 -1
- package/dist/assets/CronManager-CbM0x_s0.js +0 -1
- package/dist/assets/Diagnostics-Cw9iJ84f.js +0 -1
- package/dist/assets/Flows-BAzbFP_W.js +0 -2
- package/dist/assets/JobInspector-qvW_APO6.js +0 -2
- package/dist/assets/QueueActions-jiTzndPH.js +0 -1
- package/dist/assets/QueueDetail-URK2pjtH.js +0 -1
- package/dist/assets/QueueDetailPro-C9M5CV4K.js +0 -1
- package/dist/assets/S3BackupPro--WSZWTQn.js +0 -3
- package/dist/assets/ServerControl-QVd6m_iR.js +0 -3
- package/dist/assets/WorkersPro-BYY0P1Pt.js +0 -1
- package/dist/assets/Workflows-ByJw4FFH.js +0 -1
- package/dist/assets/bq-DYmbVkgR.js +0 -1
- package/dist/assets/flowMutationSafety-DObp9nJo.js +0 -1
- package/dist/assets/index-D64v2vNO.js +0 -8
- package/dist/assets/index-DOze4TKg.css +0 -1
- package/dist/assets/install-jXi1SOYY.js +0 -3
- package/dist/assets/useServerActionGuard-OTv6_fU0.js +0 -1
- package/dist/assets/useThroughputSeries-DWHQl7cM.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./react-vendor-CvwrP0tU.js";import{t}from"./api-81m1TwB7.js";import{n}from"./usePolledData-CNtNtd0a.js";import{n as r,t as i}from"./Card-CWxrC8OY.js";import{i as a,n as o,r as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./PageHeader-CvIyaFOO.js";import{n as l,s as u}from"./format-Cg7VCIZW.js";import{n as d}from"./index-TploGF7u.js";var f=e(),p={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function m(){let{data:e,error:m,loading:_,refetch:v}=n(()=>t.overview(),[]);if(_&&!e&&!m)return(0,f.jsx)(s,{label:`Loading metrics…`});if(m&&!e)return(0,f.jsxs)(`div`,{children:[(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`}),(0,f.jsx)(o,{error:m,onRetry:v})]});let{stats:y,throughput:b,latency:x,memory:S,collections:C}=e??p,w={};for(let[e,t]of Object.entries(x.percentiles??{}))t&&typeof t==`object`&&(w[`${e} p50`]=t.p50,w[`${e} p95`]=t.p95,w[`${e} p99`]=t.p99);return(0,f.jsxs)(`div`,{children:[m&&(0,f.jsx)(a,{message:`Metrics refresh failed — showing the last successful snapshot.`,onRetry:v}),(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!!e&&!m}),(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,f.jsx)(d,{label:`Pushed /s`,value:b.pushPerSec.toFixed(1),compact:!0}),(0,f.jsx)(d,{label:`Pulled /s`,value:b.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,f.jsx)(d,{label:`Completed /s`,value:b.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,f.jsx)(d,{label:`Failed /s`,value:b.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,f.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Totals`}),(0,f.jsx)(h,{rows:[[`Pushed`,u(y.totalPushed)],[`Pulled`,u(y.totalPulled)],[`Completed`,u(y.totalCompleted)],[`Failed`,u(y.totalFailed)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Memory`}),(0,f.jsx)(h,{rows:[[`Heap Used`,l(S.heapUsed*1024*1024)],[`Heap Total`,l(S.heapTotal*1024*1024)],[`RSS`,l(S.rss*1024*1024)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — percentiles (ms)`}),(0,f.jsx)(g,{record:w,suffix:`ms`})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — averages (ms)`}),(0,f.jsx)(g,{record:x.averages,suffix:`ms`})]})]}),(0,f.jsx)(`div`,{className:`mt-6`,children:(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`In-memory collections`}),(0,f.jsx)(g,{record:C})]})})]})}function h({rows:e}){return(0,f.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,f.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function g({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,f.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,f.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,f.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,f.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,f.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?u(Math.round(n*100)/100):String(n),t&&(0,f.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{m as Metrics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CyjgmGTq.js";import{t as i}from"./bq-DYmbVkgR.js";import{n as a}from"./usePolledData-c53tx1jw.js";import{n as o,t as s}from"./Card-C7NMhqUt.js";import{i as c,r as l,t as u}from"./feedback-BnGE2oW2.js";import{t as d}from"./PageHeader-BXlZSBcc.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{n as _}from"./index-D64v2vNO.js";import{t as v}from"./Pagination-Q-vf4hsX.js";import{t as y}from"./AreaChart-w0ruozXH.js";import{n as b,t as x}from"./useThroughputSeries-DWHQl7cM.js";var S=e(n(),1),C=r();function w({rate:e,stats:t}){return(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsx)(T,{value:e==null?`—`:f(e),label:`error rate`,danger:e!=null&&e>.05}),(0,C.jsx)(T,{value:e==null?`—`:f(1-e),label:`success rate`,success:e!=null})]}),e==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-e)*100}%`}})})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(E,{color:`bg-blue-400`,label:`Standard waiting`,value:t?m(t.waiting):`—`}),(0,C.jsx)(E,{color:`bg-accent`,label:`Processing`,value:t?m(t.active):`—`}),(0,C.jsx)(E,{color:`bg-amber-400`,label:`Delayed`,value:t?m(t.delayed):`—`}),(0,C.jsx)(E,{color:`bg-red-400`,label:`Dead Letter`,value:t?m(t.dlq):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:t?p(t.totalPushed):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:t?p(t.totalPulled):`—`}),(0,C.jsx)(E,{color:`bg-emerald-400`,label:`Uptime`,value:t?g(t.uptime/1e3):`—`})]})]})]})}function T({value:e,label:n,danger:r,success:i}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,r?`text-danger`:i?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:n})]})}function E({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}var D=[`push`,`pull`,`ack`],O=100;function k({latency:e}){return(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:D.map(n=>{let r=e?.percentiles?.[n],i=e?.averages?.[`${n}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:n}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(i)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(r?.p99??0)>O?`text-warning`:`text-muted`),children:j(r?.p99)})]},n)})})]})})]})}function A({rows:e,total:n,page:r,pageSize:i,onPage:a,empty:o}){return(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:e.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:o})}):e.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:m(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:m(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:r,pageSize:i,total:n,onPageChange:a,label:`queues`})})]})}function j(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}var M=[`-60s`,`-45s`,`-30s`,`-15s`,`now`];function N({series:e}){let n=e.latest?.throughput,r=x(e.depth),i=e.depth.length?e.depth[e.depth.length-1]:null,a=t=>e.error?(0,C.jsx)(u,{title:`${t} unavailable`,hint:e.error.message}):(0,C.jsx)(l,{label:`Connecting ${t.toLowerCase()}…`});return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),n&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(P,{color:`#ec4899`,label:`Pushed`,value:n.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:n.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:n.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):a(`Live throughput`)]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:i==null?`—`:m(i)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,r.label===`draining`?`text-success`:r.label===`accumulating`?`text-danger`:`text-faint`),children:i==null?`unavailable`:r.label===`steady`?`steady`:`${r.slope>0?`+`:``}${r.slope.toFixed(1)}/s · ${r.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:r.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):a(`Queue depth`)]})]})}function P({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}var F=15;function I(){let e=b(60),[t,n]=(0,S.useState)(0),{data:r,error:o,loading:s,refetch:l}=a(async()=>({details:await i.queuesSummary()}),[]),u=r?.details??[],f=Math.max(1,Math.ceil(u.length/F)),g=Math.min(t,f-1),v=(0,S.useMemo)(()=>u.slice(g*F,g*F+F),[u,g]),y=(0,S.useMemo)(()=>r?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[r,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!r&&!o,j=!!e.latest&&!e.error&&!!r&&!o,M=o&&!r?`Queue metrics unavailable — ${o.message}`:O?`Loading queue metrics…`:`No queues yet.`;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(d,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:j}),o&&(0,C.jsx)(c,{message:`Queue metrics unavailable — ${o.message}`,onRetry:l}),e.error&&(0,C.jsx)(c,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),O&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),!e.latest&&!e.error&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(_,{label:`Total Completed`,value:x?p(x.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Total Failed`,value:y==null?`—`:m(y),tone:y?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Push/sec`,value:T?T.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(_,{label:`Pull/sec`,value:T?T.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsx)(N,{series:e}),(0,C.jsx)(w,{rate:D,stats:x}),(0,C.jsx)(k,{latency:E}),(0,C.jsx)(A,{rows:v,total:u.length,page:g,pageSize:F,onPage:n,empty:M})]})}export{I as MetricsPro};
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-BOfwNIlJ.js";import{n as a}from"./usePolledData-CNtNtd0a.js";import{n as o,t as s}from"./Card-CWxrC8OY.js";import{i as c,r as l,t as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./PageHeader-CvIyaFOO.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{n as _}from"./index-TploGF7u.js";import{t as v}from"./Pagination-x-Cwgrul.js";import{t as y}from"./AreaChart-DEAalJ6P.js";import{n as b,t as x}from"./useThroughputSeries-_J7gWbcI.js";var S=e(n(),1),C=r();function w({rate:e,stats:t}){return(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsx)(T,{value:e==null?`—`:f(e),label:`error rate`,danger:e!=null&&e>.05}),(0,C.jsx)(T,{value:e==null?`—`:f(1-e),label:`success rate`,success:e!=null})]}),e==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-e)*100}%`}})})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(E,{color:`bg-blue-400`,label:`Standard waiting`,value:t?m(t.waiting):`—`}),(0,C.jsx)(E,{color:`bg-accent`,label:`Processing`,value:t?m(t.active):`—`}),(0,C.jsx)(E,{color:`bg-amber-400`,label:`Delayed`,value:t?m(t.delayed):`—`}),(0,C.jsx)(E,{color:`bg-red-400`,label:`Dead Letter`,value:t?m(t.dlq):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:t?p(t.totalPushed):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:t?p(t.totalPulled):`—`}),(0,C.jsx)(E,{color:`bg-emerald-400`,label:`Uptime`,value:t?g(t.uptime/1e3):`—`})]})]})]})}function T({value:e,label:n,danger:r,success:i}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,r?`text-danger`:i?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:n})]})}function E({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}var D=[`push`,`pull`,`ack`],O=100;function k({latency:e}){return(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:D.map(n=>{let r=e?.percentiles?.[n],i=e?.averages?.[`${n}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:n}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(i)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(r?.p99??0)>O?`text-warning`:`text-muted`),children:j(r?.p99)})]},n)})})]})})]})}function A({rows:e,total:n,page:r,pageSize:i,onPage:a,empty:o}){return(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:e.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:o})}):e.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:m(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:m(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:r,pageSize:i,total:n,onPageChange:a,label:`queues`})})]})}function j(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}var M=[`-60s`,`-45s`,`-30s`,`-15s`,`now`];function N({series:e}){let n=e.latest?.throughput,r=x(e.depth),i=e.depth.length?e.depth[e.depth.length-1]:null,a=t=>e.error?(0,C.jsx)(u,{title:`${t} unavailable`,hint:e.error.message}):(0,C.jsx)(l,{label:`Connecting ${t.toLowerCase()}…`});return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),n&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(P,{color:`#ec4899`,label:`Pushed`,value:n.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:n.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:n.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):a(`Live throughput`)]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:i==null?`—`:m(i)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,r.label===`draining`?`text-success`:r.label===`accumulating`?`text-danger`:`text-faint`),children:i==null?`unavailable`:r.label===`steady`?`steady`:`${r.slope>0?`+`:``}${r.slope.toFixed(1)}/s · ${r.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:r.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):a(`Queue depth`)]})]})}function P({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}var F=15;function I(){let e=b(60),[t,n]=(0,S.useState)(0),{data:r,error:o,loading:s,refetch:l}=a(async()=>({details:await i.queuesSummary()}),[]),u=r?.details??[],f=Math.max(1,Math.ceil(u.length/F)),g=Math.min(t,f-1),v=(0,S.useMemo)(()=>u.slice(g*F,g*F+F),[u,g]),y=(0,S.useMemo)(()=>r?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[r,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!r&&!o,j=!!e.latest&&!e.error&&!!r&&!o,M=o&&!r?`Queue metrics unavailable — ${o.message}`:O?`Loading queue metrics…`:`No queues yet.`;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(d,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:j}),o&&(0,C.jsx)(c,{message:`Queue metrics unavailable — ${o.message}`,onRetry:l}),e.error&&(0,C.jsx)(c,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),O&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),!e.latest&&!e.error&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(_,{label:`Total Completed`,value:x?p(x.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Total Failed`,value:y==null?`—`:m(y),tone:y?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Push/sec`,value:T?T.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(_,{label:`Pull/sec`,value:T?T.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsx)(N,{series:e}),(0,C.jsx)(w,{rate:D,stats:x}),(0,C.jsx)(k,{latency:E}),(0,C.jsx)(A,{rows:v,total:u.length,page:g,pageSize:F,onPage:n,empty:M})]})}export{I as MetricsPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./react-vendor-CvwrP0tU.js";import{A as t,c as n}from"./icons-BVzwsfbG.js";import{t as r}from"./api-81m1TwB7.js";import{n as i}from"./usePolledData-CNtNtd0a.js";import{n as a,t as o}from"./Card-CWxrC8OY.js";import{i as s,n as c,r as l}from"./feedback-QDN1AsYt.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{c as d,n as f,s as p,t as m,u as h}from"./format-Cg7VCIZW.js";import{n as g}from"./index-TploGF7u.js";var _=e(),v={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function y(){let{data:e,error:y,loading:S,refetch:C}=i(()=>r.overview(),[]);if(S&&!e&&!y)return(0,_.jsx)(l,{label:`Loading overview…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`}),(0,_.jsx)(c,{error:y,onRetry:C})]});let{stats:w,throughput:T,memory:E,workers:D,crons:O,storage:k}=e??v,A=m(w.totalCompleted,w.totalFailed)??0,j=typeof k.diskFull==`boolean`;return(0,_.jsxs)(`div`,{children:[y&&(0,_.jsx)(s,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:C}),(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!!e&&!y&&j}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(g,{label:`Waiting`,value:p(w.waiting),tone:`amber`}),(0,_.jsx)(g,{label:`Active`,value:p(w.active),tone:`blue`}),(0,_.jsx)(g,{label:`Completed`,value:p(w.totalCompleted),tone:`green`}),(0,_.jsx)(g,{label:`Failed`,value:p(w.totalFailed),tone:`red`}),(0,_.jsx)(g,{label:`DLQ`,value:p(w.dlq),tone:w.dlq>0?`red`:`default`}),(0,_.jsx)(g,{label:`Error Rate`,value:d(A),tone:A>.05?`red`:`green`})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Throughput`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(b,{label:`Pushed`,value:T.pushPerSec,tone:`text-fg`}),(0,_.jsx)(b,{label:`Pulled`,value:T.pullPerSec,tone:`text-blue-400`}),(0,_.jsx)(b,{label:`Completed`,value:T.completePerSec,tone:`text-emerald-400`}),(0,_.jsx)(b,{label:`Failed`,value:T.failPerSec,tone:`text-red-400`})]})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Resources`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(x,{label:`Uptime`,value:h(w.uptime/1e3)}),(0,_.jsx)(x,{label:`Heap`,value:f(E.heapUsed*1024*1024)}),(0,_.jsx)(x,{label:`RSS`,value:f(E.rss*1024*1024)}),(0,_.jsx)(x,{label:`Storage`,value:j?k.diskFull?`Disk full`:`Healthy`:`Unavailable`,tone:j?k.diskFull?`text-red-400`:`text-emerald-400`:`text-muted`})]})]})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Workers`,icon:(0,_.jsx)(t,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,_.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:D.active}),` /`,` `,D.total,` active`]})}),D.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,_.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,p(e.processedJobs),` done`]})]},e.id))})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Cron Jobs`,icon:(0,_.jsx)(n,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[O.total,` scheduled`]})}),O.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:O.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,_.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function b({label:e,value:t,tone:n}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,_.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function x({label:e,value:t,tone:n=`text-fg`}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{y as Overview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./react-vendor-CvwrP0tU.js";import{n as t}from"./StatusBadge-BoOVTnKu.js";var n=e();function r({title:e,description:r,live:i,actions:a,back:o}){return(0,n.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,n.jsxs)(`div`,{className:`flex items-start gap-3`,children:[o,(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,n.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg`,children:e}),i&&(0,n.jsx)(t,{label:`Live`,tone:`green`})]}),r&&(0,n.jsx)(`p`,{className:`mt-1 text-sm text-muted`,children:r})]})]}),a&&(0,n.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:a})]})}export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{s as r}from"./format-Cg7VCIZW.js";var i=e(t(),1),a=n();function o({page:e,pageSize:t,total:n,hasNext:o,onPageChange:s,label:c=`items`,className:l}){let u=n!=null,d=u?Math.max(1,Math.ceil(n/t)):void 0;(0,i.useEffect)(()=>{u&&e>d-1&&s(d-1)},[u,e,d,s]);let f=u?Math.min(e,d-1):e,p=f*t,m=f>0,h=u?f<d-1:!!o;if(u&&n<=t&&f===0)return null;let g=u?n===0?`No ${c}`:`${r(p+1)}–${r(Math.min(p+t,n))} of ${r(n)} ${c}`:`Page ${f+1}`;return(0,a.jsxs)(`div`,{className:`mt-4 flex items-center justify-between text-sm text-faint ${l??``}`,children:[(0,a.jsx)(`span`,{children:g}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsx)(`button`,{type:`button`,disabled:!m,onClick:()=>s(f-1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Previous`}),(0,a.jsx)(`span`,{className:`rounded-md bg-accent/15 px-2.5 py-1 text-xs font-medium text-accent tnum`,children:u?`${f+1} / ${d}`:f+1}),(0,a.jsx)(`button`,{type:`button`,disabled:!h,onClick:()=>s(f+1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Next`})]})]})}export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{o as r}from"./connectionStore-CFuNYZ_8.js";import{t as i}from"./bq-BOfwNIlJ.js";import{t as a}from"./Button-Ch1W94fJ.js";import{n as o,t as s}from"./Card-CWxrC8OY.js";import{a as c,n as l,o as u,t as d}from"./form-C4oby9pI.js";import{n as f,r as p}from"./useServerActionGuard-Db7PPgaI.js";import{i as m,n as h,r as g}from"./flowMutationSafety-6cP-l4Pa.js";var _=n();function v(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}return JSON.stringify(e)}function y(e,t){let n=String(e).trim();if(n===``)return null;let r=Number(n);return Number.isSafeInteger(r)&&r>=t?r:null}function b(e){let t=y(e.stallInterval,0),n=y(e.maxStalls,0),r=y(e.gracePeriod,0);return t===null||n===null||r===null?{ok:!1,error:`Stall interval, max stalls, and grace period must be non-negative whole numbers.`}:{ok:!0,value:{enabled:e.enabled,stallInterval:t,maxStalls:n,gracePeriod:r}}}function x(e){let t=y(e.autoRetryInterval,0),n=y(e.maxAutoRetries,0);return t===null||n===null?{ok:!1,error:`Retry interval and max auto-retries must be non-negative whole numbers.`}:{ok:!0,value:{autoRetry:e.autoRetry,autoRetryInterval:t,maxAutoRetries:n}}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var C=e=>typeof e==`number`&&Number.isFinite(e);function w(e){return S(e)&&typeof e.enabled==`boolean`&&C(e.stallInterval)&&C(e.maxStalls)&&C(e.gracePeriod)}function T(e){return S(e)&&typeof e.autoRetry==`boolean`&&C(e.autoRetryInterval)&&C(e.maxAutoRetries)&&(e.maxAge===null||C(e.maxAge))&&C(e.maxEntries)}function E(e,t){if(!S(e)||e.ok!==!0)throw Error(`Malformed ${t} response: expected { ok: true }.`)}var D=e(t(),1);function O(e){let[t,n]=(0,D.useState)(e),r=(0,D.useRef)(v(e));return(0,D.useEffect)(()=>{let t=v(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=v(t))}}]}function k(e){let{scopeKey:t,begin:n}=p(e),i=(0,D.useRef)(null),a=(0,D.useRef)(null),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null);let e=f(),t=r.subscribe(()=>{let t=f();t!==e&&(e=t,i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null))});return()=>{i.current=null,a.current!==null&&window.clearTimeout(a.current),t()}},[t]),{scopeKey:t,saving:o,saved:c,start:()=>{let e=n(`save`);return e?(i.current=e,s(!0),l(!1),e):null},finish:e=>{e.finish(),i.current===e&&(i.current=null,s(!1))},showSaved:e=>{i.current!==e||!e.isCurrent()||(l(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{e.isCurrent()&&l(!1),a.current=null},2e3))}}}function A({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,h]=(0,D.useState)(null),g=k(`dlq-config:${e}`);(0,D.useEffect)(()=>h(null),[g.scopeKey]);let v=x(r),y=v.ok&&v.value.autoRetry;return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`DLQ policy`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.autoRetry,disabled:!r.autoRetry,onChange:e=>c({...r,autoRetry:e}),label:`auto-retry`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:`Auto-retry can only be disabled. Bunqueue v2.9.0 cannot prove that a DLQ entry has no hidden reverse flow dependents before a background retry.`}),(0,_.jsx)(d,{label:`Retry interval (ms)`,children:(0,_.jsx)(l,{name:`dlq-auto-retry-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.autoRetryInterval,onChange:e=>c({...r,autoRetryInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max auto-retries`,children:(0,_.jsx)(l,{name:`dlq-max-auto-retries`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxAutoRetries,onChange:e=>c({...r,maxAutoRetries:e.target.value})})}),(0,_.jsx)(d,{label:`Max age (ms)`,children:(0,_.jsx)(l,{name:`dlq-max-age-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxAge??``,readOnly:!0})}),(0,_.jsx)(d,{label:`Max entries`,children:(0,_.jsx)(l,{name:`dlq-max-entries`,autoComplete:`off`,type:`number`,min:1,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxEntries,readOnly:!0})}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:m})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:g.saving||!v.ok||y,onClick:async()=>{if(!v.ok)return;let t=g.start();if(t)try{h(null);let a=f();if(E(await i.setDlqConfig(e,v.value),`/dlq-config`),!t.isCurrent())return;a({...r,...v.value}),await n(),g.showSaved(t)}catch(e){t.isCurrent()&&h(e.message)}finally{g.finish(t)}},children:`Save`}),g.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!v.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:v.error}),y&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:`Disable auto-retry before saving this policy.`}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function j({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,m]=(0,D.useState)(null),h=k(`stall-config:${e}`);(0,D.useEffect)(()=>m(null),[h.scopeKey]);let g=b(r);return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Stall detection`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.enabled,onChange:e=>c({...r,enabled:e}),label:`enabled`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,_.jsx)(d,{label:`Stall interval (ms)`,children:(0,_.jsx)(l,{name:`stall-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.stallInterval,onChange:e=>c({...r,stallInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max stalls`,children:(0,_.jsx)(l,{name:`stall-max-count`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxStalls,onChange:e=>c({...r,maxStalls:e.target.value})})}),(0,_.jsx)(d,{label:`Grace period (ms)`,children:(0,_.jsx)(l,{name:`stall-grace-period-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.gracePeriod,onChange:e=>c({...r,gracePeriod:e.target.value})})})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:h.saving||!g.ok,onClick:async()=>{if(!g.ok)return;let t=h.start();if(t)try{m(null);let r=f();if(E(await i.setStallConfig(e,g.value),`/stall-config`),!t.isCurrent())return;r(g.value),await n(),h.showSaved(t)}catch(e){t.isCurrent()&&m(e.message)}finally{h.finish(t)}},children:`Save`}),h.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!g.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:g.error}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function M({title:e,onRetry:t}){return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:e}),(0,_.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,_.jsx)(a,{size:`sm`,onClick:t,children:`Retry`})]})}function N(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&n>=0&&r>0}}function P(e){if(!e.trim())return{valid:!0};let t=Number(e);return Number.isSafeInteger(t)&&t>0?{count:t,valid:!0}:{valid:!1}}function F(e,t){return t===void 0?`Promote every delayed job in "${e}" and make it eligible to run now?`:`Promote up to ${t} delayed jobs in "${e}" and make them eligible to run now?`}function I(e,t,n){let r=e=>{if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},i=r(e),a=r(t),o=r(n);return{limit:typeof i==`number`?i:0,duration:typeof a==`number`?a:0,...typeof o==`number`?{ttl:o}:{},valid:typeof i==`number`&&typeof a==`number`&&o!==null}}function L(e){let t=Number(e);return{value:t,valid:e.trim()!==``&&Number.isSafeInteger(t)&&t>0}}function R({queue:e,paused:t,busy:n,run:r}){let[u,f]=(0,D.useState)(`0`),[p,m]=(0,D.useState)(`1000`),[v,y]=(0,D.useState)(`completed`),[b,x]=(0,D.useState)(``),S=N(u,p),C=P(b);return(0,_.jsxs)(s,{className:`mb-6`,children:[(0,_.jsx)(o,{title:`Lifecycle`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,_.jsx)(a,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>i.resume(e)),children:`Resume`}):(0,_.jsx)(a,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>i.pause(e)),children:`Pause`}),(0,_.jsx)(a,{size:`sm`,disabled:!0,title:h,children:`Requeue completed`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Promote N`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`promote-count`,"aria-invalid":!C.valid,value:b,onChange:e=>x(e.target.value),placeholder:`all`})})}),(0,_.jsx)(a,{size:`sm`,disabled:n||!C.valid,onClick:()=>r(`Promoted`,()=>i.promoteJobs(e,C.count),F(e,C.count)),children:`Promote delayed`}),!C.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Promote N must be a positive whole number, or blank for all.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:h}),(0,_.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,_.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,_.jsx)(a,{size:`sm`,disabled:!0,title:g,children:`Drain`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-40`,children:(0,_.jsx)(d,{label:`State`,children:(0,_.jsxs)(c,{name:`clean-state`,disabled:!0,value:v,onChange:e=>y(e.target.value),children:[(0,_.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,_.jsx)(`option`,{value:`failed`,children:`Failed / DLQ`}),(0,_.jsx)(`option`,{value:`waiting`,children:`Queued`})]})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Grace (ms)`,children:(0,_.jsx)(l,{type:`number`,min:0,max:2**53-1,step:1,name:`clean-grace`,disabled:!0,"aria-invalid":!S.valid,value:u,onChange:e=>f(e.target.value)})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`clean-limit`,disabled:!0,"aria-invalid":!S.valid,value:p,onChange:e=>m(e.target.value)})})}),(0,_.jsx)(a,{variant:`danger`,size:`sm`,disabled:!0,title:g,children:`Clean`}),!S.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Grace and limit must be whole numbers; limit must be positive.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:g})]})]})}function z({queue:e,busy:t,run:n}){let[r,u]=(0,D.useState)(``),[f,p]=(0,D.useState)(``),[m,h]=(0,D.useState)(`permanent`),[g,v]=(0,D.useState)(``),[y,b]=(0,D.useState)(``),[x,S]=(0,D.useState)(``),[C,w]=(0,D.useState)(``),[T,E]=(0,D.useState)(null),[O,k]=(0,D.useState)(null),A=I(r,f,m===`expires`?g:``),j=L(y);return(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Rate-limit policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a policy replaces the broker value for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-limit`,value:r,onChange:e=>u(e.target.value),placeholder:`max per window`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`Window (ms)`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-duration`,value:f,onChange:e=>p(e.target.value),placeholder:`60000`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`TTL`,children:(0,_.jsxs)(c,{name:`rate-ttl-mode`,value:m,onChange:e=>h(e.target.value),children:[(0,_.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,_.jsx)(`option`,{value:`expires`,children:`Expires after`})]})})}),(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`TTL (ms)`,hint:m===`permanent`?`Not sent`:void 0,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-ttl`,disabled:m===`permanent`,value:g,onChange:e=>v(e.target.value),placeholder:`—`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!A.valid,onClick:()=>n(`Rate limit set`,()=>i.setRateLimit(e,A.limit,A.duration,A.ttl),`Replace the current rate-limit policy for "${e}" with limit ${A.limit}, window ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`}?`,()=>E(`Applied limit ${A.limit} per ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:x,onChange:e=>S(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||x!==e,onClick:()=>n(`No rate limit ensured`,()=>i.clearRateLimit(e),`Remove the current rate-limit policy from queue "${e}"?`,()=>E(`Removed the rate-limit policy at ${new Date().toISOString()}.`)),children:`Ensure no rate limit`}),!A.valid&&(r.trim()||f.trim()||g.trim())&&(0,_.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-danger`,children:`Limit and window are required; all values must be positive whole numbers.`}),T&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:T})]})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Concurrency policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a value replaces the broker concurrency for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,_.jsx)(d,{label:`Concurrency`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`concurrency`,value:y,onChange:e=>b(e.target.value),placeholder:`max in-flight`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!j.valid,onClick:()=>n(`Concurrency set`,()=>i.setConcurrency(e,j.value),`Replace the current concurrency policy for "${e}" with ${j.value} maximum in-flight jobs?`,()=>k(`Applied concurrency ${j.value} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:C,onChange:e=>w(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||C!==e,onClick:()=>n(`No concurrency limit ensured`,()=>i.clearConcurrency(e),`Remove the current concurrency policy from queue "${e}"?`,()=>k(`Removed the concurrency policy at ${new Date().toISOString()}.`)),children:`Ensure no concurrency limit`}),!j.valid&&y.trim()&&(0,_.jsx)(`span`,{role:`alert`,className:`self-center text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),O&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:O})]})]})]})}export{A as a,j as i,R as n,T as o,M as r,w as s,z as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{t as r}from"./bq-DYmbVkgR.js";import{n as i}from"./usePolledData-c53tx1jw.js";import{t as a}from"./Button-BPqpRZJD.js";import{n as o,t as s}from"./Card-C7NMhqUt.js";import{i as c,n as l,r as u}from"./feedback-BnGE2oW2.js";import{n as d}from"./StatusBadge-B0I7hNBX.js";import{t as f}from"./PageHeader-BXlZSBcc.js";import{s as p}from"./format-Cg7VCIZW.js";import{n as m}from"./index-D64v2vNO.js";import{a as h,n as g,t as _}from"./form-tC20r4Ma.js";import{r as v}from"./useServerActionGuard-OTv6_fU0.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as ee}from"./QueueActions-jiTzndPH.js";var T=e(t(),1),E={limits:async(e,t)=>D(await r.queueOperations.limits(e,t)),deduplicationJobId:async(e,t)=>O(await r.queueOperations.deduplicationJobId(e,t)),removeDeduplicationKey:async(e,t)=>k(await r.queueOperations.removeDeduplicationKey(e,t)),metrics:async(e,t,n,i)=>A(await r.queueOperations.metrics(e,t,n,i)),trimEvents:async(e,t)=>k(await r.queueOperations.trimEvents(e,t))};function D(e){let t=M(j(e,`Queue limits`).limits,`Queue limits`),n=t.rateLimit;if(n!==null&&(!N(n)||!P(n.max)||!P(n.duration))||t.concurrency!==null&&!P(t.concurrency)||!F(t.rateLimitTtl,-2)||typeof t.maxed!=`boolean`)throw I(`Queue limits`);return{rateLimit:n,concurrency:t.concurrency,rateLimitTtl:t.rateLimitTtl,maxed:t.maxed}}function O(e){let t=j(e,`deduplication lookup`).jobId;if(t!==null&&(typeof t!=`string`||!t))throw I(`deduplication lookup`);return t}function k(e){let t=j(e,`Queue mutation`).removed;if(!F(t,0))throw I(`Queue mutation`);return t}function A(e){let t=M(j(e,`Queue metrics`).metrics,`Queue metrics`),n=M(t.meta,`Queue metrics`);if(!F(n.count,0)||!F(n.prevTS,0)||!F(n.prevCount,0)||!F(t.count,0)||!Array.isArray(t.data)||t.data.length>10001||!t.data.every(e=>F(e,0)))throw I(`Queue metrics`);return t}function j(e,t){let n=M(e,t);if(n.ok!==!0)throw I(t);return n}function M(e,t){if(!N(e))throw I(t);return e}function N(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var P=e=>F(e,1),F=(e,t)=>Number.isSafeInteger(e)&&e>=t,I=e=>Error(`Malformed ${e} response`),L=n();function R({queue:e,repository:t,busy:n,run:r}){let[i,o]=(0,T.useState)(``),[s,c]=(0,T.useState)(),[l,u]=(0,T.useState)(``),d=i.length>0&&i.length<=1024;return(0,L.jsxs)(`section`,{"aria-labelledby":`queue-dedup-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,L.jsx)(`h3`,{id:`queue-dedup-title`,className:`text-sm font-semibold text-fg`,children:`Deduplication registry`}),(0,L.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Resolve an official deduplication ID to its current job, or release only the registry key.`}),(0,L.jsx)(_,{label:`Deduplication ID`,children:(0,L.jsx)(g,{name:`queue-sdk-deduplication-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:i,onChange:e=>{o(e.target.value),c(void 0),u(``)}})}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,L.jsx)(a,{size:`sm`,disabled:!d||!!n,onClick:()=>r(`Looking up deduplication key`,()=>t.deduplicationJobId(e,i),c),children:`Find owner`}),(0,L.jsx)(a,{variant:`warning`,size:`sm`,disabled:!d||!!n,onClick:()=>{window.confirm(`Remove deduplication key "${i}" from queue "${e}"? The job is not deleted, but a later enqueue may reuse this key.`)&&r(`Removing deduplication key`,()=>t.removeDeduplicationKey(e,i),e=>{u(e?`Deduplication key removed.`:`No matching key was active.`),c(void 0)},!0)},children:`Remove key`})]}),s!==void 0&&(0,L.jsx)(`p`,{role:`status`,className:`mt-3 break-all text-xs text-muted`,children:s===null?`No active owner.`:`Current job: ${s}`}),l&&(0,L.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l})]})}function te({snapshot:e,loading:t,error:n}){if(t&&!e)return(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:`Reading broker limit state...`});if(n&&!e)return(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n});if(!e)return null;let r=e.rateLimit;return(0,L.jsxs)(`div`,{children:[n&&(0,L.jsxs)(`p`,{role:`alert`,className:`mb-3 text-xs text-warning`,children:[`Refresh failed. Showing the last successful limit snapshot: `,n]}),(0,L.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,L.jsx)(z,{label:`Global rate limit`,value:r?`${r.max} / ${r.duration} ms`:`Not configured`}),(0,L.jsx)(z,{label:`Rate-limit TTL`,value:e.rateLimitTtl===-2?`No active limit`:`${e.rateLimitTtl} ms`}),(0,L.jsx)(z,{label:`Global concurrency`,value:e.concurrency===null?`Not configured`:String(e.concurrency)}),(0,L.jsx)(z,{label:`Capacity`,value:e.maxed?`Maxed`:`Available`})]})]})}function z({label:e,value:t}){return(0,L.jsxs)(`div`,{className:`min-w-0 border-l-2 border-line pl-3`,children:[(0,L.jsx)(`dt`,{className:`text-[11px] font-medium text-faint`,children:e}),(0,L.jsx)(`dd`,{className:`mt-1 break-words font-mono text-sm text-fg`,children:t})]})}function B({queue:e,repository:t,busy:n,run:r}){let[i,o]=(0,T.useState)(`completed`),[s,c]=(0,T.useState)(`0`),[l,u]=(0,T.useState)(`29`),[d,f]=(0,T.useState)(`1000`),[p,m]=(0,T.useState)(null),[v,y]=(0,T.useState)(``),b=H(s,l),x=U(d,0,1e6);return(0,L.jsxs)(`section`,{"aria-labelledby":`queue-telemetry-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,L.jsx)(`h3`,{id:`queue-telemetry-title`,className:`text-sm font-semibold text-fg`,children:`Durable queue telemetry`}),(0,L.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Read paged one-minute completion or failure buckets, and bound the lifecycle-event journal.`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsx)(_,{label:`Metric`,children:(0,L.jsxs)(h,{name:`queue-sdk-metric-type`,value:i,onChange:e=>o(e.target.value),children:[(0,L.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,L.jsx)(`option`,{value:`failed`,children:`Failed`})]})}),(0,L.jsx)(_,{label:`Start bucket`,children:(0,L.jsx)(g,{name:`queue-sdk-metric-start`,type:`number`,min:0,max:1e4,value:s,onChange:e=>c(e.target.value)})}),(0,L.jsx)(_,{label:`End bucket`,hint:`Use -1 for all remaining buckets`,children:(0,L.jsx)(g,{name:`queue-sdk-metric-end`,type:`number`,min:-1,max:1e4,value:l,onChange:e=>u(e.target.value)})})]}),(0,L.jsx)(a,{className:`mt-3`,size:`sm`,disabled:!b||!!n,onClick:()=>{b&&r(`Reading ${i} metrics`,()=>t.metrics(e,i,b.start,b.end),m)},children:`Read metrics`}),!b&&(0,L.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`Use integer buckets from 0 to 10000; end must be -1 or at least start.`}),p&&(0,L.jsx)(V,{metrics:p}),(0,L.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end gap-3 border-t border-line pt-4`,children:[(0,L.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,L.jsx)(_,{label:`Retain lifecycle events`,hint:`0 clears the queue journal`,children:(0,L.jsx)(g,{name:`queue-sdk-event-retention`,type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})})}),(0,L.jsx)(a,{variant:`warning`,size:`sm`,disabled:x===null||!!n,onClick:()=>{x!==null&&window.confirm(`Retain at most ${x} lifecycle events for queue "${e}"? Older journal events are permanently removed; metric buckets are unchanged.`)&&r(`Trimming lifecycle journal`,()=>t.trimEvents(e,x),e=>y(`${e} lifecycle events removed.`),!0)},children:`Trim journal`})]}),v&&(0,L.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:v})]})}function V({metrics:e}){let t=e.data.slice(0,120).map((t,n)=>({timestamp:e.meta.prevTS-n*6e4,value:t,offset:n})),n=Math.max(1,...t.map(e=>e.value));return(0,L.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-2 p-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 font-mono text-xs text-muted`,children:[(0,L.jsxs)(`span`,{children:[`Total terminal: `,e.meta.count]}),(0,L.jsxs)(`span`,{children:[`Available buckets: `,e.count]}),(0,L.jsxs)(`span`,{children:[`Latest bucket: `,e.meta.prevCount]})]}),t.length?(0,L.jsx)(`div`,{className:`mt-3 flex h-16 items-end gap-px overflow-hidden`,role:`img`,"aria-label":`${t.length} one-minute metric buckets, newest first`,children:t.map(e=>(0,L.jsx)(`span`,{title:`Bucket ${e.offset}: ${e.value}`,className:`min-w-px flex-1 bg-accent/70`,style:{height:`${Math.max(2,e.value/n*100)}%`}},e.timestamp))}):(0,L.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`No buckets in this range.`}),e.data.length>t.length&&(0,L.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Showing the first 120 returned buckets.`})]})}function H(e,t){let n=U(e,0,1e4),r=U(t,-1,1e4);return n===null||r===null||r!==-1&&r<n?null:{start:n,end:r}}function U(e,t,n){let r=Number(e);return Number.isSafeInteger(r)&&r>=t&&r<=n?r:null}function ne({queue:e,refreshKey:t=0,repository:n=E,onApplied:r}){let[i,c]=(0,T.useState)(``),[l,u]=(0,T.useState)(null),[d,f]=(0,T.useState)(``),[p,m]=(0,T.useState)(``),h=(0,T.useRef)(!1),v=(0,T.useRef)(0),y=(0,T.useRef)(!0),b=l?.queue===e?l:{queue:e,snapshot:null,loading:!0,error:``};(0,T.useEffect)(()=>(y.current=!0,()=>{y.current=!1,v.current+=1}),[]);let x=(0,T.useCallback)(async()=>{let t=re(i);if(t===null){u(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!1,error:`maxJobs must be a whole number from 0 to 1000000.`}));return}let r=++v.current;u(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!0,error:``}));try{let i=await n.limits(e,t);y.current&&r===v.current&&u({queue:e,snapshot:i,loading:!1,error:``})}catch(t){y.current&&r===v.current&&u({queue:e,snapshot:null,loading:!1,error:W(t)})}},[i,e,n]);(0,T.useEffect)(()=>void x(),[e,t]);let S=(e,t,n,i=!1)=>{h.current||(h.current=!0,f(e),m(``),t().then(e=>{y.current&&(n(e),i&&(r?.(),r||x()))}).catch(e=>{y.current&&m(W(e))}).finally(()=>{h.current=!1,y.current&&f(``)}))};return(0,L.jsxs)(s,{className:`mb-6`,children:[(0,L.jsx)(o,{title:`Queue SDK operations`,action:d?(0,L.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[d,`...`]}):void 0}),(0,L.jsx)(`p`,{className:`mb-5 max-w-3xl text-xs leading-5 text-faint`,children:`Live Bunqueue 2.8.59 limit, deduplication, metric, and event-journal contracts. Requests are pinned to the server managed by this control agent.`}),(0,L.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-end gap-3 border-b border-line pb-5`,children:[(0,L.jsx)(`div`,{className:`w-48`,children:(0,L.jsx)(_,{label:`TTL threshold (maxJobs)`,hint:`Optional token-consumption threshold`,children:(0,L.jsx)(g,{name:`queue-sdk-max-jobs`,type:`number`,min:0,max:1e6,step:1,value:i,onChange:e=>c(e.target.value),placeholder:`Not set`})})}),(0,L.jsx)(a,{size:`sm`,disabled:b.loading||!!d,onClick:x,children:`Refresh limits`})]}),(0,L.jsx)(te,{snapshot:b.snapshot,loading:b.loading,error:b.error}),p&&(0,L.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:p}),(0,L.jsxs)(`div`,{className:`mt-6 grid gap-6 xl:grid-cols-[0.8fr_1.2fr]`,children:[(0,L.jsx)(R,{queue:e,repository:n,busy:d,run:S},`${e}:deduplication`),(0,L.jsx)(B,{queue:e,repository:n,busy:d,run:S},`${e}:telemetry`)]})]})}function re(e){if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<=1e6?t:null}var W=e=>e instanceof Error?e.message:String(e),G=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],K=500,q=200,J=K*q;function Y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){return Y(e)&&G.every(t=>X(e[t]))}function Z(e,t){if(!Y(e)||e.ok!==!0||!Array.isArray(e.queues)||!X(e.total)||!X(e.limit)||e.limit<1||!X(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>Y(e)&&typeof e.name==`string`&&e.name.length>0&&X(e.waiting)&&X(e.delayed)&&X(e.active)&&X(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function Q(){let e=await r.queues(K,0);Z(e,0);let t=e.total;if(t>J)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${J}.`);if(e.queues.length!==Math.min(K,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(K,t)} queues, received ${e.queues.length}.`);let n=new Map,i=e=>{for(let t of e.queues){if(n.has(t.name))throw Error(`Overlapping /dashboard/queues pages: queue "${t.name}" appeared more than once.`);n.set(t.name,t)}};i(e);let a=e.queues.length,o=1;for(;a<t;){if(o>=q)throw Error(`Queue discovery exceeded the safe limit of ${q} pages.`);let e=await r.queues(K,a);if(Z(e,a),e.total!==t)throw Error(`Queue discovery changed during pagination: total moved from ${t} to ${e.total}. Retry the snapshot.`);let n=Math.min(K,t-a);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${a}: expected ${n} queues, received ${e.queues.length}.`);i(e),a+=e.queues.length,o+=1}if(n.size!==t)throw Error(`Incomplete /dashboard/queues snapshot: expected ${t} unique queues, received ${n.size}.`);return{...e,queues:[...n.values()],total:t,limit:K,offset:0}}function ae(e,t){if(!Y(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!ie(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function $(e){if(!Y(e)||e.ok!==!0||!w(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function oe(e){if(!Y(e)||e.ok!==!0||!S(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function se(e){if(!Y(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!X(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function ce(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function le(){let[e,t]=(0,T.useState)(``),[n,a]=(0,T.useState)(!1),[o,s]=(0,T.useState)(0),[g,_]=(0,T.useState)(null),S=v(`queue-control:${e}`);(0,T.useEffect)(()=>{a(!1),_(null)},[S.scopeKey]);let{data:w,error:E,loading:D,refetch:O}=i(Q,[],{intervalMs:3e4});(0,T.useEffect)(()=>{w&&t(e=>ce(e,w.queues))},[w]);let{data:k,error:A,loading:j,refetch:M}=i((0,T.useCallback)(async()=>{if(!e)return null;let[t,n,i]=await Promise.all([r.queueDetail(e,!1),r.getStallConfig(e).then($).catch(()=>null),r.getDlqConfig(e).then(oe).catch(()=>null)]);return ae(t,e),{queue:e,detail:t,stall:n,dlq:i}},[e]),[e]),N=!w||w.queues.some(t=>t.name===e),P=k&&k.queue===e&&N?k:null,F=(t,n,i,o)=>{let c=e;if(!c||i&&!window.confirm(i))return;let l=S.begin(`queue-write`);l&&(a(!0),_(null),(async()=>{try{let e=await r.queuesSummary();if(!l.isCurrent())return;if(!e.some(e=>e.name===c))throw Error(`Queue "${c}" no longer exists`);let i=se(await n());if(!l.isCurrent())return;_({queue:c,ok:!0,text:`${t}${i==null?` ✓`:`: ${i}`}`}),o?.(),s(e=>e+1),await M()}catch(e){l.isCurrent()&&_({queue:c,ok:!1,text:e.message})}finally{l.finish()&&a(!1)}})())};return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(f,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!P?.detail&&!!P.stall&&!!P.dlq&&!A&&!E}),(0,L.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`w-56`,children:(0,L.jsx)(h,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(w?.queues??[]).map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),P?.detail&&(0,L.jsx)(d,{label:P.detail.paused?`Paused`:`Active`,tone:P.detail.paused?`amber`:`green`}),g?.queue===e&&(0,L.jsx)(`span`,{role:`status`,className:g.ok?`text-xs text-success`:`text-xs text-danger`,children:g.text})]}),E&&(0,L.jsx)(c,{onRetry:O,message:`Could not discover queues — ${E.message}. Retry to choose a queue.`}),A&&P&&(0,L.jsx)(c,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:M}),A&&!P?(0,L.jsx)(l,{error:A,onRetry:M}):D&&!w&&!e&&!E?(0,L.jsx)(u,{label:`Discovering queues…`}):j&&!P?(0,L.jsx)(u,{}):E&&!e?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):P?.detail?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:G.map(e=>(0,L.jsx)(m,{label:e,value:p(P.detail.counts[e]),compact:!0},e))}),(0,L.jsx)(x,{queue:e,paused:P.detail.paused,busy:n,run:F},`${e}:lifecycle`),(0,L.jsx)(ee,{queue:e,busy:n,run:F},`${e}:limits`),(0,L.jsx)(ne,{queue:e,refreshKey:o,onApplied:()=>s(e=>e+1)},`${e}:sdk-operations`),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[P.stall?(0,L.jsx)(b,{queue:e,config:P.stall,onSaved:async()=>{_({queue:e,ok:!0,text:`Stall config saved ✓`}),await M()}},`${e}:stall`):(0,L.jsx)(C,{title:`Stall detection`,onRetry:M}),P.dlq?(0,L.jsx)(y,{queue:e,config:P.dlq,onSaved:async()=>{_({queue:e,ok:!0,text:`DLQ config saved ✓`}),await M()}},`${e}:dlq`):(0,L.jsx)(C,{title:`DLQ policy`,onRetry:M})]})]}):!A&&(0,L.jsx)(`p`,{className:`text-sm text-faint`,children:w?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{le as QueueControl,Q as t};
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{t as r}from"./bq-BOfwNIlJ.js";import{n as i}from"./usePolledData-CNtNtd0a.js";import{t as a}from"./Button-Ch1W94fJ.js";import{n as o,t as s}from"./Card-CWxrC8OY.js";import{i as c,n as l,r as u}from"./feedback-QDN1AsYt.js";import{n as d}from"./StatusBadge-BoOVTnKu.js";import{t as f}from"./PageHeader-CvIyaFOO.js";import{s as p}from"./format-Cg7VCIZW.js";import{n as m}from"./index-TploGF7u.js";import{a as h,n as g,t as _}from"./form-C4oby9pI.js";import{r as v}from"./useServerActionGuard-Db7PPgaI.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as ee}from"./QueueActions-D7cQrGvJ.js";var T=e(t(),1),E={limits:async(e,t)=>D(await r.queueOperations.limits(e,t)),deduplicationJobId:async(e,t)=>O(await r.queueOperations.deduplicationJobId(e,t)),removeDeduplicationKey:async(e,t)=>k(await r.queueOperations.removeDeduplicationKey(e,t)),metrics:async(e,t,n,i)=>A(await r.queueOperations.metrics(e,t,n,i)),trimEvents:async(e,t)=>k(await r.queueOperations.trimEvents(e,t))};function D(e){let t=M(j(e,`Queue limits`).limits,`Queue limits`),n=t.rateLimit;if(n!==null&&(!N(n)||!P(n.max)||!P(n.duration))||t.concurrency!==null&&!P(t.concurrency)||!F(t.rateLimitTtl,-2)||typeof t.maxed!=`boolean`)throw I(`Queue limits`);return{rateLimit:n,concurrency:t.concurrency,rateLimitTtl:t.rateLimitTtl,maxed:t.maxed}}function O(e){let t=j(e,`deduplication lookup`).jobId;if(t!==null&&(typeof t!=`string`||!t))throw I(`deduplication lookup`);return t}function k(e){let t=j(e,`Queue mutation`).removed;if(!F(t,0))throw I(`Queue mutation`);return t}function A(e){let t=M(j(e,`Queue metrics`).metrics,`Queue metrics`),n=M(t.meta,`Queue metrics`);if(!F(n.count,0)||!F(n.prevTS,0)||!F(n.prevCount,0)||!F(t.count,0)||!Array.isArray(t.data)||t.data.length>10001||!t.data.every(e=>F(e,0)))throw I(`Queue metrics`);return t}function j(e,t){let n=M(e,t);if(n.ok!==!0)throw I(t);return n}function M(e,t){if(!N(e))throw I(t);return e}function N(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var P=e=>F(e,1),F=(e,t)=>Number.isSafeInteger(e)&&e>=t,I=e=>Error(`Malformed ${e} response`),L=n();function R({queue:e,repository:t,busy:n,run:r}){let[i,o]=(0,T.useState)(``),[s,c]=(0,T.useState)(),[l,u]=(0,T.useState)(``),d=i.length>0&&i.length<=1024;return(0,L.jsxs)(`section`,{"aria-labelledby":`queue-dedup-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,L.jsx)(`h3`,{id:`queue-dedup-title`,className:`text-sm font-semibold text-fg`,children:`Deduplication registry`}),(0,L.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Resolve an official deduplication ID to its current job, or release only the registry key.`}),(0,L.jsx)(_,{label:`Deduplication ID`,children:(0,L.jsx)(g,{name:`queue-sdk-deduplication-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:i,onChange:e=>{o(e.target.value),c(void 0),u(``)}})}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,L.jsx)(a,{size:`sm`,disabled:!d||!!n,onClick:()=>r(`Looking up deduplication key`,()=>t.deduplicationJobId(e,i),c),children:`Find owner`}),(0,L.jsx)(a,{variant:`warning`,size:`sm`,disabled:!d||!!n,onClick:()=>{window.confirm(`Remove deduplication key "${i}" from queue "${e}"? The job is not deleted, but a later enqueue may reuse this key.`)&&r(`Removing deduplication key`,()=>t.removeDeduplicationKey(e,i),e=>{u(e?`Deduplication key removed.`:`No matching key was active.`),c(void 0)},!0)},children:`Remove key`})]}),s!==void 0&&(0,L.jsx)(`p`,{role:`status`,className:`mt-3 break-all text-xs text-muted`,children:s===null?`No active owner.`:`Current job: ${s}`}),l&&(0,L.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l})]})}function te({snapshot:e,loading:t,error:n}){if(t&&!e)return(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:`Reading broker limit state...`});if(n&&!e)return(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n});if(!e)return null;let r=e.rateLimit;return(0,L.jsxs)(`div`,{children:[n&&(0,L.jsxs)(`p`,{role:`alert`,className:`mb-3 text-xs text-warning`,children:[`Refresh failed. Showing the last successful limit snapshot: `,n]}),(0,L.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,L.jsx)(z,{label:`Global rate limit`,value:r?`${r.max} / ${r.duration} ms`:`Not configured`}),(0,L.jsx)(z,{label:`Rate-limit TTL`,value:e.rateLimitTtl===-2?`No active limit`:`${e.rateLimitTtl} ms`}),(0,L.jsx)(z,{label:`Global concurrency`,value:e.concurrency===null?`Not configured`:String(e.concurrency)}),(0,L.jsx)(z,{label:`Capacity`,value:e.maxed?`Maxed`:`Available`})]})]})}function z({label:e,value:t}){return(0,L.jsxs)(`div`,{className:`min-w-0 border-l-2 border-line pl-3`,children:[(0,L.jsx)(`dt`,{className:`text-[11px] font-medium text-faint`,children:e}),(0,L.jsx)(`dd`,{className:`mt-1 break-words font-mono text-sm text-fg`,children:t})]})}function B({queue:e,repository:t,busy:n,run:r}){let[i,o]=(0,T.useState)(`completed`),[s,c]=(0,T.useState)(`0`),[l,u]=(0,T.useState)(`29`),[d,f]=(0,T.useState)(`1000`),[p,m]=(0,T.useState)(null),[v,y]=(0,T.useState)(``),b=H(s,l),x=U(d,0,1e6);return(0,L.jsxs)(`section`,{"aria-labelledby":`queue-telemetry-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,L.jsx)(`h3`,{id:`queue-telemetry-title`,className:`text-sm font-semibold text-fg`,children:`Durable queue telemetry`}),(0,L.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Read paged one-minute completion or failure buckets, and bound the lifecycle-event journal.`}),(0,L.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,L.jsx)(_,{label:`Metric`,children:(0,L.jsxs)(h,{name:`queue-sdk-metric-type`,value:i,onChange:e=>o(e.target.value),children:[(0,L.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,L.jsx)(`option`,{value:`failed`,children:`Failed`})]})}),(0,L.jsx)(_,{label:`Start bucket`,children:(0,L.jsx)(g,{name:`queue-sdk-metric-start`,type:`number`,min:0,max:1e4,value:s,onChange:e=>c(e.target.value)})}),(0,L.jsx)(_,{label:`End bucket`,hint:`Use -1 for all remaining buckets`,children:(0,L.jsx)(g,{name:`queue-sdk-metric-end`,type:`number`,min:-1,max:1e4,value:l,onChange:e=>u(e.target.value)})})]}),(0,L.jsx)(a,{className:`mt-3`,size:`sm`,disabled:!b||!!n,onClick:()=>{b&&r(`Reading ${i} metrics`,()=>t.metrics(e,i,b.start,b.end),m)},children:`Read metrics`}),!b&&(0,L.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`Use integer buckets from 0 to 10000; end must be -1 or at least start.`}),p&&(0,L.jsx)(V,{metrics:p}),(0,L.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end gap-3 border-t border-line pt-4`,children:[(0,L.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,L.jsx)(_,{label:`Retain lifecycle events`,hint:`0 clears the queue journal`,children:(0,L.jsx)(g,{name:`queue-sdk-event-retention`,type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})})}),(0,L.jsx)(a,{variant:`warning`,size:`sm`,disabled:x===null||!!n,onClick:()=>{x!==null&&window.confirm(`Retain at most ${x} lifecycle events for queue "${e}"? Older journal events are permanently removed; metric buckets are unchanged.`)&&r(`Trimming lifecycle journal`,()=>t.trimEvents(e,x),e=>y(`${e} lifecycle events removed.`),!0)},children:`Trim journal`})]}),v&&(0,L.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:v})]})}function V({metrics:e}){let t=e.data.slice(0,120).map((t,n)=>({timestamp:e.meta.prevTS-n*6e4,value:t,offset:n})),n=Math.max(1,...t.map(e=>e.value));return(0,L.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-2 p-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 font-mono text-xs text-muted`,children:[(0,L.jsxs)(`span`,{children:[`Total terminal: `,e.meta.count]}),(0,L.jsxs)(`span`,{children:[`Available buckets: `,e.count]}),(0,L.jsxs)(`span`,{children:[`Latest bucket: `,e.meta.prevCount]})]}),t.length?(0,L.jsx)(`div`,{className:`mt-3 flex h-16 items-end gap-px overflow-hidden`,role:`img`,"aria-label":`${t.length} one-minute metric buckets, newest first`,children:t.map(e=>(0,L.jsx)(`span`,{title:`Bucket ${e.offset}: ${e.value}`,className:`min-w-px flex-1 bg-accent/70`,style:{height:`${Math.max(2,e.value/n*100)}%`}},e.timestamp))}):(0,L.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`No buckets in this range.`}),e.data.length>t.length&&(0,L.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Showing the first 120 returned buckets.`})]})}function H(e,t){let n=U(e,0,1e4),r=U(t,-1,1e4);return n===null||r===null||r!==-1&&r<n?null:{start:n,end:r}}function U(e,t,n){let r=Number(e);return Number.isSafeInteger(r)&&r>=t&&r<=n?r:null}function ne({queue:e,refreshKey:t=0,repository:n=E,onApplied:r}){let[i,c]=(0,T.useState)(``),[l,u]=(0,T.useState)(null),[d,f]=(0,T.useState)(``),[p,m]=(0,T.useState)(``),h=(0,T.useRef)(!1),v=(0,T.useRef)(0),y=(0,T.useRef)(!0),b=l?.queue===e?l:{queue:e,snapshot:null,loading:!0,error:``};(0,T.useEffect)(()=>(y.current=!0,()=>{y.current=!1,v.current+=1}),[]);let x=(0,T.useCallback)(async()=>{let t=re(i);if(t===null){u(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!1,error:`maxJobs must be a whole number from 0 to 1000000.`}));return}let r=++v.current;u(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!0,error:``}));try{let i=await n.limits(e,t);y.current&&r===v.current&&u({queue:e,snapshot:i,loading:!1,error:``})}catch(t){y.current&&r===v.current&&u({queue:e,snapshot:null,loading:!1,error:W(t)})}},[i,e,n]);(0,T.useEffect)(()=>void x(),[e,t]);let S=(e,t,n,i=!1)=>{h.current||(h.current=!0,f(e),m(``),t().then(e=>{y.current&&(n(e),i&&(r?.(),r||x()))}).catch(e=>{y.current&&m(W(e))}).finally(()=>{h.current=!1,y.current&&f(``)}))};return(0,L.jsxs)(s,{className:`mb-6`,children:[(0,L.jsx)(o,{title:`Queue SDK operations`,action:d?(0,L.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[d,`...`]}):void 0}),(0,L.jsx)(`p`,{className:`mb-5 max-w-3xl text-xs leading-5 text-faint`,children:`Live Bunqueue 2.9.0 limit, deduplication, metric, and event-journal contracts. Requests are pinned to the server managed by this control agent.`}),(0,L.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-end gap-3 border-b border-line pb-5`,children:[(0,L.jsx)(`div`,{className:`w-48`,children:(0,L.jsx)(_,{label:`TTL threshold (maxJobs)`,hint:`Optional token-consumption threshold`,children:(0,L.jsx)(g,{name:`queue-sdk-max-jobs`,type:`number`,min:0,max:1e6,step:1,value:i,onChange:e=>c(e.target.value),placeholder:`Not set`})})}),(0,L.jsx)(a,{size:`sm`,disabled:b.loading||!!d,onClick:x,children:`Refresh limits`})]}),(0,L.jsx)(te,{snapshot:b.snapshot,loading:b.loading,error:b.error}),p&&(0,L.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:p}),(0,L.jsxs)(`div`,{className:`mt-6 grid gap-6 xl:grid-cols-[0.8fr_1.2fr]`,children:[(0,L.jsx)(R,{queue:e,repository:n,busy:d,run:S},`${e}:deduplication`),(0,L.jsx)(B,{queue:e,repository:n,busy:d,run:S},`${e}:telemetry`)]})]})}function re(e){if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<=1e6?t:null}var W=e=>e instanceof Error?e.message:String(e),G=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],K=500,q=200,J=K*q;function Y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){return Y(e)&&G.every(t=>X(e[t]))}function Z(e,t){if(!Y(e)||e.ok!==!0||!Array.isArray(e.queues)||!X(e.total)||!X(e.limit)||e.limit<1||!X(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>Y(e)&&typeof e.name==`string`&&e.name.length>0&&X(e.waiting)&&X(e.delayed)&&X(e.active)&&X(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function Q(){let e=await r.queues(K,0);Z(e,0);let t=e.total;if(t>J)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${J}.`);if(e.queues.length!==Math.min(K,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(K,t)} queues, received ${e.queues.length}.`);let n=new Map,i=e=>{for(let t of e.queues){if(n.has(t.name))throw Error(`Overlapping /dashboard/queues pages: queue "${t.name}" appeared more than once.`);n.set(t.name,t)}};i(e);let a=e.queues.length,o=1;for(;a<t;){if(o>=q)throw Error(`Queue discovery exceeded the safe limit of ${q} pages.`);let e=await r.queues(K,a);if(Z(e,a),e.total!==t)throw Error(`Queue discovery changed during pagination: total moved from ${t} to ${e.total}. Retry the snapshot.`);let n=Math.min(K,t-a);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${a}: expected ${n} queues, received ${e.queues.length}.`);i(e),a+=e.queues.length,o+=1}if(n.size!==t)throw Error(`Incomplete /dashboard/queues snapshot: expected ${t} unique queues, received ${n.size}.`);return{...e,queues:[...n.values()],total:t,limit:K,offset:0}}function ae(e,t){if(!Y(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!ie(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function $(e){if(!Y(e)||e.ok!==!0||!w(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function oe(e){if(!Y(e)||e.ok!==!0||!S(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function se(e){if(!Y(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!X(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function ce(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function le(){let[e,t]=(0,T.useState)(``),[n,a]=(0,T.useState)(!1),[o,s]=(0,T.useState)(0),[g,_]=(0,T.useState)(null),S=v(`queue-control:${e}`);(0,T.useEffect)(()=>{a(!1),_(null)},[S.scopeKey]);let{data:w,error:E,loading:D,refetch:O}=i(Q,[],{intervalMs:3e4});(0,T.useEffect)(()=>{w&&t(e=>ce(e,w.queues))},[w]);let{data:k,error:A,loading:j,refetch:M}=i((0,T.useCallback)(async()=>{if(!e)return null;let[t,n,i]=await Promise.all([r.queueDetail(e,!1),r.getStallConfig(e).then($).catch(()=>null),r.getDlqConfig(e).then(oe).catch(()=>null)]);return ae(t,e),{queue:e,detail:t,stall:n,dlq:i}},[e]),[e]),N=!w||w.queues.some(t=>t.name===e),P=k?.queue===e&&N?k:null,F=(t,n,i,o)=>{let c=e;if(!c||i&&!window.confirm(i))return;let l=S.begin(`queue-write`);l&&(a(!0),_(null),(async()=>{try{let e=await r.queuesSummary();if(!l.isCurrent())return;if(!e.some(e=>e.name===c))throw Error(`Queue "${c}" no longer exists`);let i=se(await n());if(!l.isCurrent())return;_({queue:c,ok:!0,text:`${t}${i==null?` ✓`:`: ${i}`}`}),o?.(),s(e=>e+1),await M()}catch(e){l.isCurrent()&&_({queue:c,ok:!1,text:e.message})}finally{l.finish()&&a(!1)}})())};return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(f,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!P?.detail&&!!P.stall&&!!P.dlq&&!A&&!E}),(0,L.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`w-56`,children:(0,L.jsx)(h,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(w?.queues??[]).map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),P?.detail&&(0,L.jsx)(d,{label:P.detail.paused?`Paused`:`Active`,tone:P.detail.paused?`amber`:`green`}),g?.queue===e&&(0,L.jsx)(`span`,{role:`status`,className:g.ok?`text-xs text-success`:`text-xs text-danger`,children:g.text})]}),E&&(0,L.jsx)(c,{onRetry:O,message:`Could not discover queues — ${E.message}. Retry to choose a queue.`}),A&&P&&(0,L.jsx)(c,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:M}),A&&!P?(0,L.jsx)(l,{error:A,onRetry:M}):D&&!w&&!e&&!E?(0,L.jsx)(u,{label:`Discovering queues…`}):j&&!P?(0,L.jsx)(u,{}):E&&!e?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):P?.detail?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:G.map(e=>(0,L.jsx)(m,{label:e,value:p(P.detail.counts[e]),compact:!0},e))}),(0,L.jsx)(x,{queue:e,paused:P.detail.paused,busy:n,run:F},`${e}:lifecycle`),(0,L.jsx)(ee,{queue:e,busy:n,run:F},`${e}:limits`),(0,L.jsx)(ne,{queue:e,refreshKey:o,onApplied:()=>s(e=>e+1)},`${e}:sdk-operations`),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[P.stall?(0,L.jsx)(b,{queue:e,config:P.stall,onSaved:async()=>{_({queue:e,ok:!0,text:`Stall config saved ✓`}),await M()}},`${e}:stall`):(0,L.jsx)(C,{title:`Stall detection`,onRetry:M}),P.dlq?(0,L.jsx)(y,{queue:e,config:P.dlq,onSaved:async()=>{_({queue:e,ok:!0,text:`DLQ config saved ✓`}),await M()}},`${e}:dlq`):(0,L.jsx)(C,{title:`DLQ policy`,onRetry:M})]})]}):!A&&(0,L.jsx)(`p`,{className:`text-sm text-faint`,children:w?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{le as QueueControl,Q as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{d as t,g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-BOfwNIlJ.js";import{A as o,b as s,i as c,m as l,n as u,x as d}from"./icons-BVzwsfbG.js";import{t as f}from"./api-81m1TwB7.js";import{n as p}from"./usePolledData-CNtNtd0a.js";import{t as m}from"./Button-Ch1W94fJ.js";import{t as h}from"./Card-CWxrC8OY.js";import{i as g,r as _,t as v}from"./feedback-QDN1AsYt.js";import{n as y,t as b}from"./StatusBadge-BoOVTnKu.js";import{a as x,c as S,d as C,l as w,s as T,t as E}from"./format-Cg7VCIZW.js";import{n as D}from"./index-TploGF7u.js";import{a as O,n as k,t as A}from"./form-C4oby9pI.js";import{r as j,t as M}from"./useServerActionGuard-Db7PPgaI.js";import{r as N}from"./flowMutationSafety-6cP-l4Pa.js";var P=e(n(),1),F=i();function I({queue:e}){return(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.9.0 cannot read either current policy. Every command below is an explicit blind desired-state write; a receipt proves only what this dashboard applied at that time.`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,F.jsx)(z,{queue:e}),(0,F.jsx)(B,{queue:e})]})]})}function L(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function R(e,t){let[n,r]=(0,P.useState)(!1),[i,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(null),l=j(`classic-queue-policy:${e}:${t}`);return(0,P.useEffect)(()=>{r(!1),o(null),c(null)},[l.scopeKey]),{busy:n,error:i,receipt:s,run:async(n,i,s)=>{if(!window.confirm(i))return;let u=l.begin(t);if(u){r(!0),o(null),c(null);try{let t=await a.queuesSummary();if(!u.isCurrent())return;if(!t.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await s(),n),!u.isCurrent())return;c(`${n} applied at ${new Date().toISOString()}. Current server state cannot be read.`)}catch(e){u.isCurrent()&&o(e.message)}finally{u.finish()&&r(!1)}}}}}function z({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),[o,s]=(0,P.useState)(`permanent`),[c,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),{busy:p,error:g,receipt:_,run:v}=R(e,`rate-limit`),y=L(t),b=L(r),x=o===`expires`?L(c):void 0,S=y!==null&&b!==null&&(o===`permanent`||x!=null);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,F.jsx)(l,{className:`size-4 text-faint`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsx)(A,{label:`Limit`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-limit`,value:t,"aria-invalid":t.trim()!==``&&y===null,onChange:e=>n(e.target.value),placeholder:`100`})}),(0,F.jsx)(A,{label:`Window (ms)`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-duration`,value:r,"aria-invalid":r.trim()!==``&&b===null,onChange:e=>i(e.target.value),placeholder:`60000`})}),(0,F.jsx)(A,{label:`TTL`,children:(0,F.jsxs)(O,{name:`classic-rate-ttl-mode`,value:o,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,F.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,F.jsx)(A,{label:`TTL (ms)`,hint:o===`permanent`?`Not sent`:void 0,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-ttl`,disabled:o===`permanent`,value:c,"aria-invalid":o===`expires`&&c.trim()!==``&&x==null,onChange:e=>u(e.target.value),placeholder:`3600000`})})]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,F.jsx)(m,{variant:`accent`,size:`sm`,disabled:p||!S,onClick:()=>{if(y===null||b===null||o===`expires`&&x===null)return;let t=typeof x==`number`?x:void 0,n=o===`permanent`?`permanent`:`TTL ${x}ms`;v(`Rate-limit policy replaced`,`Replace the unknown rate-limit policy for "${e}" with limit ${y}, window ${b}ms, ${n}?`,()=>a.setRateLimit(e,y,b,t))},children:`Replace rate-limit policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,F.jsx)(m,{className:`mt-2`,size:`sm`,disabled:p||d!==e,onClick:()=>void v(`No rate limit ensured`,`Ensure queue "${e}" has no rate-limit policy? The previous value is unavailable.`,()=>a.clearRateLimit(e)),children:`Ensure no rate limit`})]}),_&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:_}),g&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:g})]})}function B({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),{busy:s,error:c,receipt:l,run:u}=R(e,`concurrency`),d=L(t);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,F.jsx)(o,{className:`size-4 text-faint`})]}),(0,F.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-concurrency`,value:t,"aria-invalid":t.trim()!==``&&d===null,onChange:e=>n(e.target.value),placeholder:`5`})}),(0,F.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,F.jsx)(m,{variant:`accent`,size:`sm`,disabled:s||d===null,onClick:()=>{d!==null&&u(`Concurrency policy replaced`,`Replace the unknown concurrency policy for "${e}" with ${d} maximum in-flight jobs?`,()=>a.setConcurrency(e,d))},children:`Replace concurrency policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,F.jsx)(m,{className:`mt-2`,size:`sm`,disabled:s||r!==e,onClick:()=>void u(`No concurrency limit ensured`,`Ensure queue "${e}" has no concurrency policy? The previous value is unavailable.`,()=>a.clearConcurrency(e)),children:`Ensure no concurrency limit`})]}),l&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l}),c&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c})]})}var V=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],H={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,"waiting-children":0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[],recentJobsError:null};function U(){let{name:e=``}=t(),[n,i]=(0,P.useState)(null),[o,l]=(0,P.useState)(null),h=j(`classic-queue:${e}`);(0,P.useEffect)(()=>{i(null),l(null)},[h.scopeKey]);let{data:O,error:k,loading:A,refetch:L}=p((0,P.useCallback)(async()=>{if(!(await a.queuesSummary()).some(t=>t.name===e))return{exists:!1,detail:null,jobs:[],recentJobsError:null};let[t,n]=await Promise.all([f.queueDetail(e,!1),f.jobsList(e,{states:V,limit:12}).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);if(t.ok!==!0||t.name!==e)throw Error(`Malformed queue detail response for "${e}"`);return{exists:!0,detail:t,jobs:n.jobs,recentJobsError:n.error}},[e]),[e]),R=async(t,n,r)=>{if(r&&!window.confirm(r))return;let o=h.begin(t);if(o){i(t),l(null);try{let r=await a.queuesSummary();if(!o.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await n(),t),!o.isCurrent())return;await L()}catch(e){o.isCurrent()&&l(e.message)}finally{o.finish()&&i(null)}}};if(A&&!O&&!k)return(0,F.jsx)(_,{label:`Loading ${e}…`});if(k&&!O)return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(g,{onRetry:L})]});if(O?.exists===!1)return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(v,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,F.jsx)(r,{to:`/queues-classic`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to classic queues`})})]});let z=O?.exists===!0?O:H,{detail:B}=z,U=B.counts,W=E(U.completed??0,U.failed??0),G=[...z.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(r,{to:`/queues-classic`,"aria-label":`Back to classic queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,F.jsx)(c,{className:`size-4`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,F.jsx)(y,{label:B.paused?`Paused`:`Active`,tone:B.paused?`amber`:`green`}),(0,F.jsx)(y,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B.paused?(0,F.jsxs)(m,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>R(`resume`,()=>f.resume(e)),children:[(0,F.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,F.jsxs)(m,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>R(`pause`,()=>f.pause(e)),children:[(0,F.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,F.jsx)(m,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,F.jsx)(m,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),o&&(0,F.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:o}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,F.jsx)(D,{label:`Waiting`,value:T(U.waiting),tone:`amber`}),(0,F.jsx)(D,{label:`Active`,value:T(U.active),tone:`blue`}),(0,F.jsx)(D,{label:`Completed`,value:T(U.completed),tone:`green`}),(0,F.jsx)(D,{label:`Failed`,value:T(U.failed),tone:U.failed?`red`:`default`}),(0,F.jsx)(D,{label:`Delayed`,value:T(U.delayed),tone:`default`}),(0,F.jsx)(D,{label:`Error Rate`,value:W==null?`—`:S(W),tone:W==null?`default`:W>.05?`red`:`green`})]}),(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,F.jsxs)(r,{to:`/jobs-classic?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,F.jsx)(u,{className:`size-3.5`})]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,F.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,F.jsx)(`tbody`,{children:z.recentJobsError?(0,F.jsx)(`tr`,{children:(0,F.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,z.recentJobsError,`. Retry the page.`]})}):G.length===0?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.map(e=>(0,F.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,F.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,F.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e.id})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,F.jsx)(`td`,{className:`px-5 py-3`,children:(0,F.jsx)(b,{status:String(e.state??e.status??`waiting`)})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:x(C(e.startedAt,e.completedAt))}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,F.jsx)(I,{queue:e})]})}export{U as QueueDetail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{d as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{t as o}from"./bq-BOfwNIlJ.js";import{t as s}from"./toastStore-B31o6Z5J.js";import{i as c,n as l}from"./icons-BVzwsfbG.js";import{n as u}from"./usePolledData-CNtNtd0a.js";import{t as d}from"./Button-Ch1W94fJ.js";import{n as f,t as p}from"./Card-CWxrC8OY.js";import{i as m,n as h,r as g,t as _}from"./feedback-QDN1AsYt.js";import{n as v}from"./StatusBadge-BoOVTnKu.js";import{t as y}from"./PageHeader-CvIyaFOO.js";import{a as b,c as x,s as S,t as C}from"./format-Cg7VCIZW.js";import{n as w}from"./index-TploGF7u.js";import{r as T,t as E}from"./useServerActionGuard-Db7PPgaI.js";import{r as D}from"./flowMutationSafety-6cP-l4Pa.js";import{t as O}from"./AreaChart-DEAalJ6P.js";import{n as k}from"./controlConnectionEpoch-DzbuWOhe.js";import{a as A,i as j,n as M,r as N,t as P}from"./QueueActions-D7cQrGvJ.js";import{t as F}from"./useThroughputSeries-_J7gWbcI.js";var I=e(r(),1),L=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],R=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],z=2e3,B=a();function V({name:e,jobs:t,error:n}){return(0,B.jsxs)(p,{padded:!1,className:`mb-6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,B.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,B.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,B.jsx)(l,{className:`size-3.5`})]})]}),(0,B.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,B.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`State`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,B.jsx)(`tbody`,{children:n?(0,B.jsx)(`tr`,{children:(0,B.jsxs)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,n,`. Retry the page.`]})}):t.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):t.map(e=>(0,B.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,B.jsx)(`td`,{className:`px-5 py-3`,children:(0,B.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,B.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,B.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,B.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,B.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)})]},e.id))})]})})]})}function H({counts:e}){let t=Object.entries(e??{}).map(([e,t])=>[Number(e),t]).filter(([,e])=>e>0).sort((e,t)=>t[0]-e[0]);if(t.length===0)return null;let n=Math.max(...t.map(([,e])=>e));return(0,B.jsxs)(p,{className:`mb-6`,children:[(0,B.jsx)(f,{title:`Jobs by priority`}),(0,B.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,B.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,B.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,B.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:S(t)})]},e))}),(0,B.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}function U({name:e,depth:n,trend:r,rate:i}){return(0,B.jsxs)(p,{className:`mb-6`,children:[(0,B.jsx)(f,{title:`Backlog depth`,action:(0,B.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,r.draining?`bg-emerald-500/10 text-success`:r.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:r.label})}),n.length<2?(0,B.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,B.jsx)(O,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:n,area:!0}]}),(0,B.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,B.jsx)(`span`,{children:`waiting + prioritized + active + delayed + waiting-children`}),(0,B.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,i==null?`—`:x(i)]})]})]})}function W(e,t){let n=`${k()}\u0000${e}`,[r,i]=(0,I.useState)(()=>({scope:n,values:[]})),a=(0,I.useRef)(null);(0,I.useEffect)(()=>{a.current=null,i({scope:n,values:[]});let e=setInterval(()=>{let e=a.current;e!=null&&i(t=>({scope:n,values:[...t.scope===n?t.values:[],e].slice(-40)}))},z);return()=>clearInterval(e)},[n]),(0,I.useEffect)(()=>{t&&(a.current=(t.waiting??0)+(t.prioritized??0)+(t.active??0)+(t.delayed??0)+(t[`waiting-children`]??0))},[t,n]);let o=r.scope===n?r.values:[];return{depth:o,trend:F(o)}}function G(){let{name:e=``}=n(),[t,r]=(0,I.useState)(!1),[a,f]=(0,I.useState)(null),p=T(`queue:${e}`);(0,I.useEffect)(()=>{r(!1),f(null)},[p.scopeKey]);let{data:b,error:x,loading:O,refetch:k}=u((0,I.useCallback)(async()=>{if(!e)return null;if(!(await o.queuesSummary()).some(t=>t.name===e))return{queue:e,exists:!1,detail:null,stall:null,dlq:null,jobs:[],recentJobsError:null};let[t,n,r,i]=await Promise.all([o.queueDetail(e,!1),o.getStallConfig(e).catch(()=>null),o.getDlqConfig(e).catch(()=>null),o.jobsList(e,R,12).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);return{queue:e,exists:!0,detail:t,stall:n?.config??null,dlq:r?.config??null,jobs:i.jobs,recentJobsError:i.error}},[e]),[e]),F=b?.queue===e?b:null,{depth:z,trend:G}=W(e,F?.detail?.counts),K=async(t,n,i,a)=>{if(i&&!window.confirm(i))return;let c=p.begin();if(c){r(!0),f(null);try{let r=await o.queuesSummary();if(!c.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);let i=await n();if(E(i,t),!c.isCurrent())return;let l=i.count;if(l!==void 0&&(!Number.isSafeInteger(l)||l<0))throw Error(`${t} returned an invalid count`);let u=`${t}${l==null?` ✓`:`: ${l}`}`;f({ok:!0,text:u}),s.success(u,e),a?.(),k()}catch(e){if(!c.isCurrent())return;let n=e.message;f({ok:!1,text:n}),s.error(`${t} failed`,n)}finally{c.finish()&&r(!1)}}},q=F?.detail,J=q?.counts,Y=J?C(J.completed??0,J.failed??0):null;return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(y,{title:(0,B.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and complete live non-terminal depth.`,live:F?.exists===!0&&!!F.detail&&!!F.stall&&!!F.dlq&&!F.recentJobsError&&!x,back:(0,B.jsx)(i,{to:`/queues`,"aria-label":`Back to queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,B.jsx)(c,{className:`size-4`})}),actions:F?.exists===!0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`Jobs `,(0,B.jsx)(l,{className:`size-3.5`})]}),(0,B.jsxs)(i,{to:`/dlq?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`DLQ `,(0,B.jsx)(l,{className:`size-3.5`})]}),(0,B.jsx)(d,{variant:`danger`,size:`sm`,disabled:!0,title:D,children:`Obliterate`})]}):void 0}),x&&F&&(0,B.jsx)(m,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:k}),x&&!F?(0,B.jsx)(h,{error:x,onRetry:k}):O&&!F?(0,B.jsx)(g,{label:`Loading ${e}…`}):F?.exists===!1||!q||!J?!x&&(0,B.jsx)(_,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,B.jsx)(i,{to:`/queues`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to queues`})}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(v,{label:q.paused?`Paused`:`Active`,tone:q.paused?`amber`:`green`}),a&&(0,B.jsx)(`span`,{role:`status`,className:a.ok?`text-xs text-success`:`text-xs text-danger`,children:a.text}),(0,B.jsx)(`span`,{className:`text-xs text-warning`,children:D})]}),(0,B.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:L.map(e=>(0,B.jsx)(w,{label:e,value:S(J[e]),tone:e===`failed`&&J.failed?`red`:`default`,compact:!0},e))}),(0,B.jsx)(V,{name:e,jobs:F.jobs,error:F.recentJobsError}),(0,B.jsx)(H,{counts:q.priorityCounts}),(0,B.jsx)(U,{name:e,depth:z,trend:G,rate:Y}),(0,B.jsx)(M,{queue:e,paused:q.paused,busy:t,run:K}),(0,B.jsx)(P,{queue:e,busy:t,run:K},`${e}:limits`),(0,B.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[F.stall?(0,B.jsx)(j,{queue:e,config:F.stall,onSaved:()=>{f({ok:!0,text:`Stall config saved ✓`}),s.success(`Stall config saved`,e)}},`${e}:stall`):(0,B.jsx)(N,{title:`Stall detection`,onRetry:k}),F.dlq?(0,B.jsx)(A,{queue:e,config:F.dlq,onSaved:()=>{f({ok:!0,text:`DLQ config saved ✓`}),s.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,B.jsx)(N,{title:`DLQ policy`,onRetry:k})]})]})]})}export{G as QueueDetailPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{S as a,T as o,n as s}from"./icons-BVzwsfbG.js";import{t as c}from"./api-81m1TwB7.js";import{n as l}from"./usePolledData-CNtNtd0a.js";import{i as u,r as d}from"./feedback-QDN1AsYt.js";import{t as f}from"./PageHeader-CvIyaFOO.js";import{s as p}from"./format-Cg7VCIZW.js";import{n as m}from"./index-TploGF7u.js";import{t as h}from"./Pagination-x-Cwgrul.js";var g=e(n(),1),_=i(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let[e,n]=(0,g.useState)(``),[i,b]=(0,g.useState)(0),{data:x,error:S,loading:C,refetch:w}=l(()=>c.queues(v,i*v),[i]),{data:T}=l(()=>c.overview(),[]),E=x??y,D=(0,g.useMemo)(()=>{let t=E.queues,n=e.trim().toLowerCase();return n?t.filter(e=>e.name.toLowerCase().includes(n)):t},[E,e]);if(C&&!x&&!S)return(0,_.jsx)(d,{label:`Loading queues…`});let O=T?.stats;return(0,_.jsxs)(`div`,{children:[S&&(0,_.jsx)(u,{onRetry:w}),(0,_.jsx)(f,{title:`Queues`,description:x?`${E.total} queues`:`Queue inventory unavailable`,live:!!x&&!S}),(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,_.jsx)(m,{label:`Waiting`,value:O?p(O.waiting):`—`,tone:`amber`,compact:!0}),(0,_.jsx)(m,{label:`Active`,value:O?p(O.active):`—`,tone:`blue`,compact:!0}),(0,_.jsx)(m,{label:`Delayed`,value:O?p(O.delayed):`—`,tone:`default`,compact:!0}),(0,_.jsx)(m,{label:`DLQ`,value:O?p(O.dlq):`—`,tone:O?.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{"aria-label":`Filter queues`,name:`classic-queue-filter`,autoComplete:`off`,value:e,onChange:e=>n(e.target.value),placeholder:`Search queues…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[52rem] text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Delayed`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`DLQ`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`w-10 px-5 py-3`})]})}),(0,_.jsx)(`tbody`,{children:!x&&S?(0,_.jsx)(`tr`,{children:(0,_.jsxs)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,S.message,`. Retry above.`]})}):D.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:e?`No queues match on this page.`:`No queues yet.`})}):D.map(e=>(0,_.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(r,{to:`/queues-classic/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,_.jsx)(a,{className:`size-4 text-faint`}),e.name]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.waiting)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:p(e.active)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.delayed)}),(0,_.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,e.dlq?`text-red-400`:`text-muted`),children:p(e.dlq)}),(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-emerald-400`),children:[(0,_.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:(0,_.jsx)(s,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},e.name))})]})}),x&&(0,_.jsx)(h,{page:i,pageSize:v,total:E.total,onPageChange:b,label:`queues`})]})}export{b as Queues};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-BOfwNIlJ.js";import{t as o}from"./toastStore-B31o6Z5J.js";import{S as s,T as c,b as l,n as u,x as d}from"./icons-BVzwsfbG.js";import{n as f}from"./usePolledData-CNtNtd0a.js";import{n as p,t as m}from"./Button-Ch1W94fJ.js";import{i as h,n as g,r as _}from"./feedback-QDN1AsYt.js";import{t as v}from"./PageHeader-CvIyaFOO.js";import{s as y}from"./format-Cg7VCIZW.js";import{n as b}from"./index-TploGF7u.js";import{t as x}from"./Pagination-x-Cwgrul.js";import{r as S,t as C}from"./useServerActionGuard-Db7PPgaI.js";import{t as w}from"./promisePool-BVfQ9n9Q.js";var T=e(n(),1),E=i(),D=[[`waiting`,`Waiting`],[`prioritized`,`Prioritized`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function O({rows:e,hasData:n,error:i,search:a,sortCol:o,sortDir:c,bulkBusy:f,busy:m,onSort:h,onToggle:g}){return(0,E.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,E.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),D.map(([e,t])=>(0,E.jsx)(`th`,{"aria-sort":o===e?c===`desc`?`descending`:`ascending`:void 0,className:`px-5 py-3 text-right font-medium`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>h(e),className:`inline-flex items-center gap-1 rounded uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[t,o===e&&(0,E.jsx)(`span`,{"aria-hidden":`true`,children:c===`desc`?`↓`:`↑`})]})},e)),(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,E.jsx)(`th`,{className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,E.jsx)(`tbody`,{children:!n&&i?(0,E.jsx)(`tr`,{children:(0,E.jsxs)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,i.message,`. Retry above.`]})}):e.length===0?(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-faint`,children:a?`No queues match your search.`:`No queues yet.`})}):e.map(e=>{let n=f||m.has(e.name);return(0,E.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(r,{to:`/queues/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,E.jsx)(s,{className:`size-4 text-faint`}),e.name]})}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:y(e.counts.waiting)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:y(e.counts.prioritized)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:y(e.counts.active)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:y(e.counts.completed)}),(0,E.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,e.counts.failed?`text-danger`:`text-muted`),children:y(e.counts.failed)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:y(e.counts.delayed)}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:[(0,E.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,E.jsx)(p,{"aria-label":e.paused?`Resume queue`:`Pause queue`,disabled:n,onClick:t=>{t.stopPropagation(),g(e)},children:e.paused?(0,E.jsx)(d,{className:`size-3.5 text-success`}):(0,E.jsx)(l,{className:`size-3.5 text-warning`})}),(0,E.jsx)(u,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},e.name)})})]})})}var k=6,A=15;function j(){let[e,n]=(0,T.useState)(``),[r,i]=(0,T.useState)(0),[s,u]=(0,T.useState)(new Set),[p,D]=(0,T.useState)(!1),[j,M]=(0,T.useState)(null),[N,P]=(0,T.useState)(null),[F,I]=(0,T.useState)(`desc`),L=S(`queues-overview`);(0,T.useEffect)(()=>{u(new Set),D(!1),M(null)},[L.scopeKey]);let{data:R,error:z,loading:B,refetch:V}=f(()=>a.queuesSummary(),[]),H=R??[],U=e=>{N===e?F===`desc`?I(`asc`):P(null):(P(e),I(`desc`)),i(0)},W=(0,T.useMemo)(()=>{let t=e.trim().toLowerCase(),n=[...t?H.filter(e=>e.name.toLowerCase().includes(t)):H].sort((e,t)=>e.name.localeCompare(t.name));if(N){let e=F===`desc`?-1:1;n.sort((t,n)=>e*(t.counts[N]-n.counts[N]))}return n},[H,e,N,F]),G=(0,T.useMemo)(()=>H.reduce((e,t)=>(e.waiting+=t.counts.waiting,e.prioritized+=t.counts.prioritized,e.active+=t.counts.active,e.failed+=t.counts.failed,e.paused+=+!!t.paused,e),{waiting:0,prioritized:0,active:0,failed:0,paused:0}),[H]),K=Math.max(1,Math.ceil(W.length/A)),q=Math.min(r,K-1),J=W.slice(q*A,q*A+A),Y=async e=>{let t=L.begin(`queue:${e.name}`);if(t){u(t=>new Set(t).add(e.name)),M(null);try{if(C(await(e.paused?a.resume(e.name):a.pause(e.name)),e.paused?`Resume queue`:`Pause queue`),!t.isCurrent())return;M({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`}),V()}catch(n){if(!t.isCurrent())return;M({ok:!1,text:n.message}),o.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,n.message)}finally{t.finish()&&u(t=>{let n=new Set(t);return n.delete(e.name),n})}}},X=async e=>{let t=H.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){o.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;let n=L.begin([`bulk`,...H.map(e=>`queue:${e.name}`)]);if(n){D(!0),M(null);try{let r=await w(t,k,async t=>{if(!n.isCurrent())throw Error(`Queue action target changed`);C(e===`pause`?await a.pause(t.name):await a.resume(t.name),`${e===`pause`?`Pause`:`Resume`} ${t.name}`)});if(!n.isCurrent())return;let i=r.filter(e=>e.status===`rejected`).length,s=`${e===`pause`?`Paused`:`Resumed`} ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;M({ok:i===0,text:s}),i===0?o.success(s):o.error(s),V()}finally{n.finish()&&D(!1)}}};return B&&!R&&!z?(0,E.jsx)(_,{label:`Loading queues…`}):z&&!R?(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:`Queue inventory unavailable`}),(0,E.jsx)(g,{error:z,onRetry:V})]}):(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:R?`${H.length} queues`:`Queue inventory unavailable`,live:!!R&&!z,actions:H.length>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m,{variant:`warning`,size:`sm`,disabled:p||s.size>0||G.paused>=H.length,onClick:()=>X(`pause`),children:[(0,E.jsx)(l,{className:`size-3.5`}),` Pause all`]}),(0,E.jsxs)(m,{variant:`success`,size:`sm`,disabled:p||s.size>0||G.paused===0,onClick:()=>X(`resume`),children:[(0,E.jsx)(d,{className:`size-3.5`}),` Resume all`]})]}):void 0}),z&&(0,E.jsx)(h,{message:`Queue refresh failed — showing the last successful inventory.`,onRetry:V}),(0,E.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,E.jsx)(b,{label:`Waiting`,value:y(G.waiting),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Prioritized`,value:y(G.prioritized),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Active`,value:y(G.active),tone:`blue`,compact:!0}),(0,E.jsx)(b,{label:`Failed`,value:y(G.failed),tone:G.failed?`red`:`default`,compact:!0}),(0,E.jsx)(b,{label:`Paused`,value:y(G.paused),tone:G.paused?`amber`:`default`,compact:!0})]}),(0,E.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,E.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,E.jsx)(`input`,{value:e,onChange:e=>{n(e.target.value),i(0)},placeholder:`Search queues…`,"aria-label":`Filter queues`,name:`queue-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),j&&(0,E.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,j.ok?`text-success`:`text-danger`),children:j.text}),(0,E.jsx)(O,{rows:J,hasData:!!R,error:z,search:e,sortCol:N,sortDir:F,bulkBusy:p,busy:s,onSort:U,onToggle:e=>void Y(e)}),(0,E.jsx)(x,{page:q,pageSize:A,total:W.length,onPageChange:i,label:`queues`})]})}export{j as QueuesOverview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./react-vendor-CvwrP0tU.js";import{t}from"./api-81m1TwB7.js";import{n}from"./usePolledData-CNtNtd0a.js";import{n as r,t as i}from"./Card-CWxrC8OY.js";import{i as a,n as o,r as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./PageHeader-CvIyaFOO.js";var l=e(),u=[[`S3_BACKUP_ENABLED`,`Set to 1 to enable periodic backups`],[`S3_BUCKET`,`Target bucket name`],[`S3_REGION`,`Bucket region (default us-east-1)`],[`S3_ENDPOINT`,`Custom endpoint (for S3-compatible stores)`],[`S3_ACCESS_KEY_ID`,`Access key`],[`S3_SECRET_ACCESS_KEY`,`Secret key`],[`S3_BACKUP_INTERVAL`,`Interval in ms (default 21600000 = 6h)`],[`S3_BACKUP_RETENTION`,`Backups to keep (default 7)`]];function d(){let{data:e,error:d,loading:f,refetch:p}=n(async()=>{let e=await t.storage();if(!e?.data||typeof e.data.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data`);return e},[]);return(0,l.jsxs)(`div`,{children:[d&&e&&(0,l.jsx)(a,{message:`Storage refresh failed — showing the last successful status.`,onRetry:p}),(0,l.jsx)(c,{title:`S3 Backup`,description:`SQLite snapshot backups to object storage.`,live:!!e?.data&&!d}),(0,l.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-3 text-sm text-muted`,children:`S3 backup runs on the server and is configured via environment variables — it cannot be toggled from the dashboard. The status below reflects the connected server's storage.`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,l.jsxs)(i,{children:[(0,l.jsx)(r,{title:`Storage status`}),d&&!e?(0,l.jsx)(o,{error:d,onRetry:p}):f&&!e?(0,l.jsx)(s,{}):(0,l.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,l.jsx)(`dt`,{className:`text-muted`,children:`Disk`}),(0,l.jsx)(`dd`,{className:e?.data?e.data.diskFull?`font-medium text-red-400`:`font-medium text-emerald-400`:`font-medium text-muted`,children:e?.data?e.data.diskFull?`Full`:`Healthy`:`Unavailable`})]}),(0,l.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,l.jsx)(`dt`,{className:`text-muted`,children:`Error`}),(0,l.jsx)(`dd`,{className:`font-mono text-xs text-fg`,children:e?.data?.error?String(e.data.error):`—`})]})]})]}),(0,l.jsxs)(i,{children:[(0,l.jsx)(r,{title:`Configuration (server env)`}),(0,l.jsx)(`dl`,{className:`divide-y divide-line text-sm`,children:u.map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-2.5`,children:[(0,l.jsx)(`dt`,{className:`font-mono text-xs text-accent/90`,children:e}),(0,l.jsx)(`dd`,{className:`text-right text-xs text-faint`,children:t})]},e))})]})]})]})}export{d as S3Backup};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{d as r,f as i,i as a,o,u as s}from"./connectionStore-CFuNYZ_8.js";import{l as c,o as l,s as u,t as d,u as f}from"./bq-BOfwNIlJ.js";import{w as p}from"./icons-BVzwsfbG.js";import{n as ee}from"./usePolledData-CNtNtd0a.js";import{t as m}from"./Button-Ch1W94fJ.js";import{t as h}from"./Card-CWxrC8OY.js";import{t as g}from"./PageHeader-CvIyaFOO.js";import{a as _}from"./index-TploGF7u.js";import{a as v,n as y,r as b,t as x}from"./form-C4oby9pI.js";var S=e(t(),1),te=`bq-dash-s3`,C=2,w=[`disabled`,`6h`,`12h`,`24h`],T={endpoint:``,region:`us-east-1`,bucket:``,schedule:`disabled`,pathPrefix:``,virtualHostedStyle:`auto`,retention:7};function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function D(e,t,n){return typeof e==`string`&&e.length<=n?e:t}function O(e){return w.includes(e)?e:`disabled`}function k(e){return e===`virtual-hosted`||e===`path-style`?e:`auto`}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=1&&e<=1e6?e:T.retention}function j(e){let t=E(e)?e:{};return{endpoint:D(t.endpoint,T.endpoint,2048),region:D(t.region,T.region,128),bucket:D(t.bucket,T.bucket,255),schedule:O(t.schedule),pathPrefix:D(t.pathPrefix,T.pathPrefix,1024),virtualHostedStyle:k(t.virtualHostedStyle),retention:A(t.retention)}}function M(e){return j(e)}function N(){try{return globalThis.localStorage??null}catch{return null}}function P(e){try{let t=JSON.parse(e),n=E(t)?t:{},r=j(`state`in n?n.state:n),i=typeof n.version==`number`?n.version:void 0;return{hydration:JSON.stringify({state:r,...i===void 0?{}:{version:i}}),canonical:JSON.stringify({state:r,version:C})}}catch{return null}}var F={getItem(e){let t=N();if(!t)return null;let n;try{n=t.getItem(e)}catch{return null}if(n===null||e!==`bq-dash-s3`)return n;let r=P(n);if(!r){try{t.removeItem(e)}catch{}return null}if(n!==r.canonical)try{t.setItem(e,r.canonical)}catch{try{t.removeItem(e)}catch{}}return r.hydration},setItem(e,t){try{N()?.setItem(e,t)}catch{}},removeItem(e){try{N()?.removeItem(e)}catch{}}},ne=i()(r(e=>({...T,accessKeyId:``,secretAccessKey:``,sessionToken:``,set:t=>e(e=>{let n={...e,...t};return{...j(n),accessKeyId:D(n.accessKeyId,``,512),secretAccessKey:D(n.secretAccessKey,``,2048),sessionToken:D(n.sessionToken,``,4096)}})}),{name:te,version:C,storage:s(()=>F),partialize:M,migrate:j,merge:(e,t)=>({...t,...j(e),accessKeyId:``,secretAccessKey:``,sessionToken:``})}));function re(){let e=Promise.resolve();return{async run(t,n){let r=e,i;e=new Promise(e=>{i=e}),await r;try{return n?.throwIfAborted(),await t()}finally{i()}}}}var ie=new Set([`enabled`,`bucket`,`endpoint`,`interval`,`retention`]),I=new Set([`key`,`size`,`date`]);function L(e){let t=z(e,ie,`Backup status`);return typeof t.enabled!=`boolean`&&H(`Backup status`),{enabled:t.enabled,bucket:B(t.bucket,`Backup status bucket`,1024),endpoint:B(t.endpoint,`Backup status endpoint`,4096),interval:B(t.interval,`Backup status interval`,128),retention:B(t.retention,`Backup status retention`,128)}}function R(e){(!Array.isArray(e)||e.length>2e4)&&H(`Backup list`);let t=new Set,n=0;return e.map((e,r)=>{let i=z(e,I,`Backup list item ${r}`),a=B(i.key,`Backup list item ${r} key`,2048),o=B(i.size,`Backup list item ${r} size`,128),s=B(i.date,`Backup list item ${r} date`,128);return n+=a.length+o.length+s.length,(n>2*1024*1024||t.has(a)||!V(s))&&H(`Backup list item ${r}`),t.add(a),{key:a,size:o,date:s}})}function z(e,t,n){(!e||typeof e!=`object`||Array.isArray(e))&&H(n);let r=e;return Object.keys(r).some(e=>!t.has(e))&&H(n),r}function B(e,t,n){return(typeof e!=`string`||e.length<1||e.length>n)&&H(t),e}function V(e){let t=Date.parse(e);return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(e)&&Number.isFinite(t)&&new Date(t).toISOString()===e}function H(e){throw Error(`${e} returned an invalid Bunqueue 2.9.0 contract`)}function U(e){return e.capture?.()??e}async function W(e,t,n){let r=await t.run(async()=>{let t=G(()=>e.restoreContext()),n=await G(()=>e.status().then(e=>L(e.data)));return{context:t,list:await G(()=>e.list().then(e=>R(e.data))),status:n}},n),{list:i,status:a}=r,o=await r.context,s=Array.from(new Set([a,i,o].filter(e=>e.status===`rejected`).map(e=>e.reason instanceof Error?e.reason.message:String(e.reason))));return{status:a.status===`fulfilled`?a.value:void 0,backups:i.status===`fulfilled`?i.value:[],context:o.status===`fulfilled`?o.value:void 0,errors:s}}async function G(e){try{return{status:`fulfilled`,value:await e()}}catch(e){return{status:`rejected`,reason:e}}}function K(e){let t={};for(let n of e.split(`
|
|
2
|
+
`)){let e=n.indexOf(`=`);if(e<1)throw Error(`Generated backup environment is malformed`);let r=n.slice(0,e),i=n.slice(e+1);if(!/^S3_[A-Z0-9_]+$/.test(r))throw Error(`Unexpected backup key: ${r}`);let a;try{a=JSON.parse(i)}catch{if(i===`true`||i===`false`||/^\d+$/.test(i))a=i;else throw Error(`Generated backup value for ${r} is malformed`)}t[r]=String(a)}return t}var q=e=>({method:`POST`,headers:e===void 0?void 0:{"Content-Type":`application/json`},body:e===void 0?void 0:JSON.stringify(e)});function J(e,t){let n=async(n,r)=>(await t(`${n}?target=${encodeURIComponent(e())}`,r)).result;return{status:()=>n(`/backup/status`),list:()=>n(`/backup/list`),backupNow:()=>n(`/backup/now`,q()),restore:(e,t)=>n(`/backup/restore`,q({key:e,database:t})),configure:e=>n(`/backup/configure`,q({environment:e})),restoreContext:async()=>{let e=await t(`/control/status`);return{serverStatus:e.status,database:e.db??null}}}}function ae(){let e=a(),t=f(),n={...l(t)};return J(()=>e,(e,r)=>c(t.baseUrl,e,n,r,!0,`agent`))}var oe={...J(a,u),capture:ae},Y=n();function se({environmentText:e,pollIntervalMs:t=15e3,repository:n=oe}){let r=o(e=>JSON.stringify([e.baseUrl,e.token,e.agentToken])),i=(0,S.useRef)(!0),a=(0,S.useRef)(null);(!a.current||a.current.connectionIdentity!==r||a.current.repository!==n)&&(a.current={connectionIdentity:r,repository:n});let[s]=(0,S.useState)(re),c=ee(e=>W(U(n),s,e),[n,s],{intervalMs:t}),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(``),[p,m]=(0,S.useState)(``),h=(0,S.useRef)(!1);(0,S.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]),(0,S.useEffect)(()=>{h.current=!1,u(``),f(``),m(``)},[r,n]);let g=async(e,t)=>{if(h.current)return;let r=a.current;h.current=!0,u(e),f(``),m(``);try{let o=U(n),l=await s.run(async()=>{if(!Z(r,a,i))throw Error(`Backup operation scope changed before admission.`);return t(o)});if(!Z(r,a,i))return;let u=l?.message;m(u??`${e} completed.`),await c.refetch()}catch(e){Z(r,a,i)&&f(e instanceof Error?e.message:String(e))}finally{Z(r,a,i)&&(h.current=!1,u(``))}},_=()=>{e&&window.confirm(`Apply this S3 configuration to the managed server? A restart is required.`)&&g(`Configuration`,t=>t.configure(K(e)))},v=()=>{window.confirm(`Create a transactionally consistent S3 backup now?`)&&g(`Backup`,e=>e.backupNow())},y=e=>{let t=c.data?.context?.database;!t||c.data?.context?.serverStatus!==`stopped`||window.prompt(`Type RESTORE to replace ${t.path} with ${e}`)===`RESTORE`&&g(`Restore`,n=>n.restore(e,t))},b=c.data;return(0,Y.jsxs)(`section`,{className:`mt-6 overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Live backup operations`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Official Bunqueue 2.9.0 backup CLI, executed by the local control agent.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:!e||!!l,onClick:_,className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Apply configuration`}),(0,Y.jsx)(`button`,{type:`button`,disabled:!!l,onClick:v,className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:l===`Backup`?`Backing up…`:`Backup now`}),(0,Y.jsx)(`button`,{type:`button`,disabled:!!l||c.loading,onClick:()=>void c.refetch(),className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Refresh`})]})]}),b?.status&&(0,Y.jsx)(ce,{status:b.status,context:b.context}),d||b?.errors.length?(0,Y.jsx)(`div`,{role:`alert`,className:`border-b border-line px-4 py-3 text-xs text-danger`,children:d||b?.errors.join(` · `)}):null,p&&(0,Y.jsx)(`div`,{role:`status`,className:`border-b border-line px-4 py-3 text-xs text-success`,children:p}),(0,Y.jsx)(X,{rows:b?.backups??[],canRestore:b?.context?.serverStatus===`stopped`&&!!b.context.database,busy:!!l,onRestore:y})]})}function ce({status:e,context:t}){return(0,Y.jsx)(`dl`,{className:`grid border-b border-line sm:grid-cols-2 xl:grid-cols-5`,children:[[`Scheduler`,e.enabled?`Enabled after restart`:`Disabled`],[`Bucket`,e.bucket||`—`],[`Endpoint`,e.endpoint],[`Retention`,e.retention],[`Server`,t?.serverStatus??`Unknown`]].map(([e,t])=>(0,Y.jsxs)(`div`,{className:`border-b border-line px-4 py-3 last:border-b-0 xl:border-r xl:border-b-0`,children:[(0,Y.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-faint`,children:e}),(0,Y.jsx)(`dd`,{className:`mt-1 truncate text-xs text-fg`,title:t,children:t})]},e))})}function X({rows:e,canRestore:t,busy:n,onRestore:r}){return e.length?(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full min-w-[680px] text-left text-xs`,children:[(0,Y.jsx)(`thead`,{className:`border-b border-line text-[10px] uppercase tracking-wider text-faint`,children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Object key`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Size`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Created`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 text-right font-medium`,children:`Restore`})]})}),(0,Y.jsx)(`tbody`,{className:`divide-y divide-line`,children:e.map(e=>(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`max-w-md truncate px-4 py-3 font-mono text-fg`,title:e.key,children:e.key}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-muted`,children:e.size}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-muted`,children:e.date}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,Y.jsx)(`button`,{type:`button`,disabled:!t||n,title:t?`Restore this backup`:`Stop the managed server before restore`,onClick:()=>r(e.key),className:`rounded-md border border-danger/40 px-2.5 py-1.5 text-danger disabled:opacity-35`,children:`Restore`})})]},e.key))})]})}):(0,Y.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`No backup objects returned.`})}function Z(e,t,n){return n.current&&e!==null&&t.current===e}function le(e){if(typeof e!=`object`||!e||Array.isArray(e)||typeof e.ok!=`boolean`)throw Error(`Malformed storage status response.`);let t=e.data;if(typeof t!=`object`||!t||Array.isArray(t)||typeof t.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data.`);return{diskFull:t.diskFull}}var Q=e=>JSON.stringify([e.baseUrl,e.token]),ue={"6h":360*60*1e3,"12h":720*60*1e3,"24h":1440*60*1e3};function $(e,t){return`${e}=${typeof t==`string`?JSON.stringify(t):String(t)}`}function de(e){let t=[],n=e.endpoint.trim(),r=e.region.trim(),i=e.bucket.trim(),a=e.accessKeyId.trim(),o=e.secretAccessKey.trim(),s=e.sessionToken.trim(),c=e.pathPrefix.trim();if(e.schedule===`disabled`)return{ok:!0,value:$(`S3_BACKUP_ENABLED`,!1)};if((!r||r.length>128)&&t.push(`Region is required (maximum 128 characters).`),(!i||i.length>255)&&t.push(`Bucket is required (maximum 255 characters).`),(!a||a.length>512)&&t.push(`Access key ID is required (maximum 512 characters).`),(!o||o.length>2048)&&t.push(`Secret access key is required (maximum 2048 characters).`),s.length>4096&&t.push(`Session token is too long.`),(!Number.isSafeInteger(e.retention)||e.retention<1||e.retention>1e6)&&t.push(`Retention must be a whole number from 1 to 1000000.`),c.length>1024&&t.push(`Path prefix is too long.`),n)try{let e=new URL(n);(e.protocol!==`http:`&&e.protocol!==`https:`||e.username||e.password||n.length>2048)&&t.push(`Endpoint must be an http(s) URL without embedded credentials.`)}catch{t.push(`Endpoint must be a valid http(s) URL.`)}if(t.length)return{ok:!1,errors:t};let l=[$(`S3_BACKUP_ENABLED`,!0),$(`S3_ACCESS_KEY_ID`,a),$(`S3_SECRET_ACCESS_KEY`,o),$(`S3_BUCKET`,i),$(`S3_REGION`,r),$(`S3_BACKUP_RETENTION`,e.retention)];return s&&l.push($(`S3_SESSION_TOKEN`,s)),e.virtualHostedStyle!==`auto`&&l.push($(`S3_VIRTUAL_HOSTED_STYLE`,e.virtualHostedStyle===`virtual-hosted`)),n&&l.push($(`S3_ENDPOINT`,n)),c&&l.push($(`S3_BACKUP_PREFIX`,c)),l.push($(`S3_BACKUP_INTERVAL`,ue[e.schedule])),{ok:!0,value:l.join(`
|
|
3
|
+
`)}}function fe({environment:e}){return(0,Y.jsxs)(h,{children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Server environment`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Credentials stay in memory and are copied or applied only when you request it.`})]}),e.ok&&(0,Y.jsx)(_,{value:e.value})]}),e.ok?(0,Y.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap break-all rounded-lg bg-surface-2 p-4 font-mono text-xs text-muted`,children:e.value.replace(/^S3_ACCESS_KEY_ID=.*$/m,`S3_ACCESS_KEY_ID="••••••••"`).replace(/^S3_SECRET_ACCESS_KEY=.*$/m,`S3_SECRET_ACCESS_KEY="••••••••"`).replace(/^S3_SESSION_TOKEN=.*$/m,`S3_SESSION_TOKEN="••••••••"`)}):(0,Y.jsx)(`ul`,{className:`space-y-1 text-sm text-danger`,"aria-label":`Configuration errors`,children:e.errors.map(e=>(0,Y.jsxs)(`li`,{children:[`• `,e]},e))})]})}function pe(){let e=ne(),t=o(Q),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(null),s=(0,S.useRef)(0),c=de(e),l=n?.target===t?n:null,u=i===t;return(0,S.useEffect)(()=>(s.current++,r(null),a(null),()=>{s.current++}),[t]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(g,{title:`S3 Backup Setup`,description:`Configure and operate Bunqueue 2.9.0 S3 backups.`}),(0,Y.jsxs)(`div`,{className:`mb-6 flex items-center justify-between rounded-xl border border-line bg-surface px-5 py-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-surface-2 text-faint`,children:(0,Y.jsx)(p,{className:`size-5`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`font-semibold text-fg`,children:c.ok?`Configuration draft complete`:`Configuration draft incomplete`}),(0,Y.jsx)(`div`,{className:`text-xs text-faint`,children:c.ok?e.schedule===`disabled`?`Safe disable settings ready to apply`:`Target: ${e.bucket.trim()} · ready to apply`:`Complete the required fields to generate server settings`})]})]}),(0,Y.jsx)(`span`,{className:c.ok?`rounded-full bg-emerald-500/10 px-3 py-1 text-xs font-medium text-success`:`rounded-full bg-amber-500/10 px-3 py-1 text-xs font-medium text-warning`,children:c.ok?`Ready`:`Configure`})]}),(0,Y.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-2.5 text-xs text-faint`,children:`Apply the generated settings through the local control agent below, then restart Bunqueue. Status, object listing, manual backups, and guarded restores use the official Bunqueue CLI. Non-secret draft fields are stored locally; credentials remain in memory.`}),(0,Y.jsxs)(h,{className:`mb-6`,children:[(0,Y.jsx)(`h2`,{className:`mb-1 text-base font-semibold text-fg`,children:`Connection Settings`}),(0,Y.jsx)(`p`,{className:`mb-4 text-xs text-faint`,children:`Works with AWS S3, Cloudflare R2, MinIO, DigitalOcean Spaces, and any S3-compatible provider.`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,Y.jsx)(x,{label:`Endpoint`,children:(0,Y.jsx)(y,{name:`s3-endpoint`,value:e.endpoint,onChange:t=>e.set({endpoint:t.target.value}),placeholder:`https://s3.amazonaws.com`,maxLength:2048,autoComplete:`off`,inputMode:`url`})}),(0,Y.jsx)(x,{label:`Region`,children:(0,Y.jsx)(y,{name:`s3-region`,value:e.region,onChange:t=>e.set({region:t.target.value}),placeholder:`us-east-1`,maxLength:128,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsx)(`div`,{className:`md:col-span-2`,children:(0,Y.jsx)(x,{label:`Bucket name`,children:(0,Y.jsx)(y,{name:`s3-bucket`,value:e.bucket,onChange:t=>e.set({bucket:t.target.value}),placeholder:`my-bunqueue-backups`,maxLength:255,autoComplete:`off`,spellCheck:!1})})}),(0,Y.jsx)(x,{label:`Access key ID`,children:(0,Y.jsx)(y,{name:`s3-access-key-id`,value:e.accessKeyId,onChange:t=>e.set({accessKeyId:t.target.value}),placeholder:`AKIA…`,maxLength:512,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsx)(x,{label:`Secret access key`,children:(0,Y.jsx)(y,{name:`s3-secret-access-key`,type:`password`,value:e.secretAccessKey,onChange:t=>e.set({secretAccessKey:t.target.value}),placeholder:`••••••••••••••••`,maxLength:2048,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsx)(`div`,{className:`md:col-span-2`,children:(0,Y.jsx)(x,{label:`Session token (optional, for temporary STS credentials)`,children:(0,Y.jsx)(y,{name:`s3-session-token`,type:`password`,value:e.sessionToken,onChange:t=>e.set({sessionToken:t.target.value}),placeholder:`Temporary AWS session token`,maxLength:4096,autoComplete:`off`,spellCheck:!1})})}),(0,Y.jsx)(`p`,{className:`-mt-2 text-xs text-faint md:col-span-2`,children:`Keys are kept in memory only and cleared on reload.`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(b,{htmlFor:`s3-backup-schedule`,children:`Backup interval`}),(0,Y.jsxs)(v,{id:`s3-backup-schedule`,name:`s3-backup-schedule`,value:e.schedule,onChange:t=>e.set({schedule:t.target.value}),className:`mt-1.5`,title:`Written to S3_BACKUP_ENABLED and S3_BACKUP_INTERVAL in the generated config`,autoComplete:`off`,children:[(0,Y.jsx)(`option`,{value:`disabled`,children:`Disabled`}),(0,Y.jsx)(`option`,{value:`6h`,children:`Every 6 hours`}),(0,Y.jsx)(`option`,{value:`12h`,children:`Every 12 hours`}),(0,Y.jsx)(`option`,{value:`24h`,children:`Every 24 hours`})]})]}),(0,Y.jsx)(x,{label:`Path prefix (optional)`,children:(0,Y.jsx)(y,{name:`s3-path-prefix`,value:e.pathPrefix,onChange:t=>e.set({pathPrefix:t.target.value}),placeholder:`backups/production/`,maxLength:1024,autoComplete:`off`,spellCheck:!1})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(b,{htmlFor:`s3-addressing-style`,children:`Addressing style`}),(0,Y.jsxs)(v,{id:`s3-addressing-style`,name:`s3-addressing-style`,value:e.virtualHostedStyle,onChange:t=>e.set({virtualHostedStyle:t.target.value}),className:`mt-1.5`,children:[(0,Y.jsx)(`option`,{value:`auto`,children:`Provider default`}),(0,Y.jsx)(`option`,{value:`virtual-hosted`,children:`Virtual-hosted style`}),(0,Y.jsx)(`option`,{value:`path-style`,children:`Path style`})]})]}),(0,Y.jsx)(x,{label:`Backups to retain`,children:(0,Y.jsx)(y,{name:`s3-retention`,type:`number`,min:1,max:1e6,step:1,value:e.retention,onChange:t=>e.set({retention:Number(t.target.value)}),inputMode:`numeric`})})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(m,{onClick:async()=>{let e=t,n=++s.current;r(null),a(e);try{let t=await d.storage();if(n!==s.current||Q(o.getState())!==e)return;let i=le(t);r({target:e,ok:!i.diskFull,msg:i.diskFull?`Server disk is full`:`Server disk healthy — this does not validate the S3 credentials`})}catch(t){if(n!==s.current||Q(o.getState())!==e)return;r({target:e,ok:!1,msg:t.message})}finally{n===s.current&&a(null)}},children:u?`Checking server storage…`:`Check server storage`}),(0,Y.jsx)(`span`,{className:`text-xs text-faint`,children:`This checks SQLite disk health only, not S3 connectivity.`}),l&&(0,Y.jsx)(`span`,{role:`status`,className:l.ok?`text-xs text-success`:`text-xs text-danger`,children:l.msg})]})]}),(0,Y.jsx)(fe,{environment:c}),(0,Y.jsx)(se,{environmentText:c.ok?c.value:void 0})]})}export{pe as S3BackupPro};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-BOfwNIlJ.js";import{C as a,T as o,b as s,x as c}from"./icons-BVzwsfbG.js";import{n as l}from"./usePolledData-CNtNtd0a.js";import{t as u}from"./Button-Ch1W94fJ.js";import{n as d,t as f}from"./Card-CWxrC8OY.js";import{i as p,n as m,r as h}from"./feedback-QDN1AsYt.js";import{t as g}from"./PageHeader-CvIyaFOO.js";import{f as _,i as v,l as y,n as b,u as x}from"./format-Cg7VCIZW.js";import{a as S}from"./index-TploGF7u.js";import{i as C,n as w,t as T}from"./form-C4oby9pI.js";import{t as E}from"./useControlActionGuard-DT7uudrj.js";var D=e(n(),1),O=r();function k({children:e}){return(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs text-fg`,children:e})}function A({agentBase:e}){return(0,O.jsx)(f,{children:(0,O.jsxs)(`details`,{className:`group`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`How server control works`}),(0,O.jsx)(`span`,{className:`text-xs text-muted transition-transform group-open:rotate-90`,children:`▶`})]}),(0,O.jsxs)(`div`,{className:`mt-4 space-y-4 text-sm leading-relaxed text-muted`,children:[(0,O.jsxs)(`p`,{children:[`A browser can't start or stop an OS process, so the dashboard talks to a small local`,` `,(0,O.jsx)(`span`,{className:`font-medium text-fg`,children:`control agent`}),` (`,(0,O.jsx)(k,{children:e}),`) that supervises the bunqueue server process — start, stop and restart — and streams its logs back here.`]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Launch & environment`}),(0,O.jsxs)(`p`,{children:[`The agent runs your `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Command`}),` and injects`,` `,(0,O.jsx)(k,{children:`HTTP_PORT`}),` and `,(0,O.jsx)(k,{children:`TCP_PORT`}),`, plus `,(0,O.jsx)(k,{children:`BUNQUEUE_DATA_PATH`}),` `,`only for SQLite. Memory and PostgreSQL modes remove every SQLite path alias before launch. Any `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Environment variables`}),` you add are included too. The default `,(0,O.jsx)(k,{children:`bunx bunqueue@2.9.0 start`}),` resolves the verified release; pointing the command at a local entry (e.g.`,` `,(0,O.jsx)(k,{children:`bun run /path/to/bunqueue/src/main.ts`}),`) works without one.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`When changes apply`}),(0,O.jsxs)(`p`,{children:[`Config is editable any time, but `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Command`}),`, ports and data path only take effect on the `,(0,O.jsx)(`span`,{className:`text-fg`,children:`next start/restart`}),` `,`— the running process keeps the config it launched with until then.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Data path`}),(0,O.jsxs)(`p`,{children:[`Relative paths resolve against the `,(0,O.jsx)(`span`,{className:`text-fg`,children:`agent's`}),` working directory. SQLite creates the database `,(0,O.jsx)(`span`,{className:`text-fg`,children:`file`}),` but not its parent `,(0,O.jsx)(`span`,{className:`text-fg`,children:`folder`}),` — if start fails with`,` `,(0,O.jsx)(k,{children:`SQLITE_CANTOPEN`}),`, create the directory first or use a path whose folder already exists.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Security`}),(0,O.jsxs)(`p`,{children:[`The direct agent listener binds `,(0,O.jsx)(k,{children:`127.0.0.1`}),`, locks CORS to an allowlist (never `,(0,O.jsx)(k,{children:`*`}),`), and rejects a disallowed `,(0,O.jsx)(k,{children:`Origin`}),` or`,` `,(0,O.jsx)(k,{children:`Host`}),` with `,(0,O.jsx)(k,{children:`403`}),`. The all-in-one server's `,(0,O.jsx)(k,{children:`/agent`}),` `,`bridge treats LAN and reverse-proxy access as remote: `,(0,O.jsx)(k,{children:`AGENT_TOKEN`}),` is then mandatory for status, logs, database reads and changes alike. Without it, the bridge stays disabled.`]}),(0,O.jsxs)(`p`,{children:[`If you started the agent with `,(0,O.jsx)(k,{children:`AGENT_TOKEN`}),`, enter that token under`,` `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Settings → Agent token`}),` (or when the lock screen prompts). It stays in memory for this browser session; never bake it into a public`,` `,(0,O.jsx)(k,{children:`VITE_*`}),` value.`]})]})]})]})})}function j(e,t,n,r){return{baseline:F(e),id:r,revision:t,scope:n,value:F(e)}}function ee(e,t,n,r,i){return{accepted:F(e),acceptedRevision:t,before:n?F(n):null,beforeRevision:r,ignoreThroughRequestId:i}}function te(e,t,n,r){return P(t,e.accepted)?!1:r!==void 0&&e.ignoreThroughRequestId!==void 0?r<=e.ignoreThroughRequestId:n===void 0?e.before!==null&&P(t,e.before):n===e.beforeRevision||n===e.acceptedRevision}function M(e){if(!L(e))return R();let{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:a}=e;if(typeof t!=`string`||t.trim()===``||!I(n)||!I(r)||n===r||typeof i!=`string`||!L(a)||Object.values(a).some(e=>typeof e!=`string`))return R();let o=N(e.configRevision);return e.configRevision!==void 0&&o===void 0?R():{config:{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:Object.fromEntries(Object.entries(a))},revision:o}}function N(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0}function ne(e){return I(e.httpPort)?I(e.tcpPort)?e.httpPort===e.tcpPort?`HTTP and TCP ports must differ`:null:`TCP port must be an integer between 1 and 65535`:`HTTP port must be an integer between 1 and 65535`}function re(e,t){if(!e)return[];let n=[];return e.command!==t.command&&n.push(`command`),e.httpPort!==t.httpPort&&n.push(`HTTP port`),e.tcpPort!==t.tcpPort&&n.push(`TCP port`),e.dataPath!==t.dataPath&&n.push(`data path`),z(e.extraEnv)!==z(t.extraEnv)&&n.push(`environment variables`),n}function P(e,t){return JSON.stringify(B(e))===JSON.stringify(B(t))}function F(e){return{...e,extraEnv:{...e.extraEnv}}}function I(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=65535}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(){throw Error(`Configuration save returned a malformed response`)}function z(e){return JSON.stringify(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)))}function B(e){return{...e,extraEnv:Object.fromEntries(Object.entries(e.extraEnv).sort(([e],[t])=>e.localeCompare(t)))}}var V=0,H=e=>Object.entries(e).map(([e,t])=>({id:V++,key:e,value:t})),U=e=>{let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return t};function W(e){let t=e.map(e=>e.trim());return[...new Set(t.filter((e,t,n)=>e&&n.indexOf(e)!==t))]}var ie=[`AUTH_TOKENS`,`LOG_LEVEL`,`BUNQUEUE_STORAGE_DRIVER`,`BUNQUEUE_POSTGRES_URL`,`S3_BACKUP_ENABLED`,`S3_BUCKET`,`METRICS_ENABLED`];function G({value:e,onChange:t,disabled:n}){let[r,i]=(0,D.useState)(()=>H(e)),a=e=>{i(e),t(U(e))},o=(e,t)=>a(r.map(n=>n.id===e?{...n,...t}:n)),s=(e=``)=>a([...r,{id:V++,key:e,value:``}]),c=e=>a(r.filter(t=>t.id!==e)),l=new Set(r.map(e=>e.key.trim()).filter(Boolean)),d=W(r.map(e=>e.key)),f=[...new Set(r.map(e=>e.key.trim()).filter(e=>e&&(/[\s=]/.test(e)||/[a-z]/.test(e))))];return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.length===0&&(0,O.jsxs)(`p`,{className:`text-xs leading-relaxed text-faint`,children:[`No custom variables. The agent already injects`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`HTTP_PORT`}),`,`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`TCP_PORT`}),`, plus the SQLite data path unless PostgreSQL mode is selected.`]}),r.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-2/5 shrink-0`,children:(0,O.jsx)(w,{id:`env-key-${e.id}`,name:`env-key-${e.id}`,"aria-label":`Variable name${e.key?` ${e.key}`:``}`,className:`font-mono`,placeholder:`KEY`,value:e.key,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{key:t.target.value})})}),(0,O.jsx)(`span`,{className:`text-faint`,children:`=`}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,O.jsx)(w,{id:`env-value-${e.id}`,name:`env-value-${e.id}`,"aria-label":`Value for ${e.key||`variable`}`,className:`font-mono`,placeholder:`value`,value:e.value,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{value:t.target.value})})}),(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.key||`variable`}`,disabled:n,onClick:()=>c(e.id),className:`shrink-0 rounded-md px-2 py-1 text-xs text-faint transition-colors hover:text-danger disabled:opacity-40`,children:`✕`})]},e.id)),d.length>0&&(0,O.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Duplicate key`,d.length>1?`s`:``,` — the last value wins: `,d.join(`, `)]}),f.length>0&&(0,O.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Unusual key`,f.length>1?`s`:``,` — env names are usually UPPER_SNAKE_CASE with no spaces or "=": `,f.join(`, `),`. Saved as-is.`]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,O.jsx)(u,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>s(),children:`+ Add variable`}),ie.filter(e=>!l.has(e)).map(e=>(0,O.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>s(e),className:`rounded-md border border-line bg-surface-2 px-2 py-1 font-mono text-[11px] text-muted transition-colors hover:border-line-strong hover:text-fg disabled:opacity-40`,children:[`+ `,e]},e))]})]})}function K({status:e,onSaved:t,running:n,statusRequestId:r,getStatusRequestSequence:o,transitioning:s}){let c=E(`server-config`),l=(0,D.useRef)(0),p=(0,D.useRef)(null),m=(0,D.useRef)(null),[h,g]=(0,D.useState)(null),[_,v]=(0,D.useState)(!1),[y,b]=(0,D.useState)(!1),[x,S]=(0,D.useState)(null),[C,k]=(0,D.useState)(!1),[A,F]=(0,D.useState)(null);(0,D.useEffect)(()=>{p.current&&clearTimeout(p.current),p.current=null,m.current=null,g(null),v(!1),b(!1),S(null),k(!1),F(null)},[c.scopeKey]),(0,D.useEffect)(()=>{if(!e?.config||_)return;let t=m.current;t&&te(t,e.config,N(e.configRevision),r)||(m.current=null,g(j(e.config,N(e.configRevision),c.scopeKey,++l.current)),k(!1))},[c.scopeKey,_,e?.config,e?.configRevision,r]),(0,D.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let I=h?.scope===c.scopeKey?h:null,L=I?.value??e?.config??null;if(!L)return(0,O.jsx)(f,{children:`Loading…`});let R=t=>{let n=I??j(L,N(e?.configRevision),c.scopeKey,++l.current);g({...n,value:{...n.value,...t}}),v(!0),b(!1),k(!1)},z=re(e?.runningConfig??null,L),B=n&&z.length>0,V=s||x!==null,H=()=>{p.current&&clearTimeout(p.current),b(!0),p.current=setTimeout(()=>{p.current=null,b(!1)},2e3)},U=async n=>{let r=c.begin([`config`,`lifecycle`]);if(!r)return;let a=ne(L);if(a)return r.finish(),F(a);let s=I?.baseline??e?.config,u=I?.revision??N(e?.configRevision);if(u===void 0&&s&&e?.config&&!P(s,e.config))return r.finish(),k(!0),F(`Configuration changed elsewhere; reload the latest values before saving.`);F(null),k(!1),S(n?`restart`:`save`);try{let a=await i.control.setConfig(L,u);if(!r.isCurrent())return;let{config:s,revision:d}=M(a);if(m.current=ee(s,d,e?.config??null,N(e?.configRevision),o?.()),g(j(s,d,c.scopeKey,++l.current)),v(!1),n&&await i.control.restart(),!r.isCurrent())return;H(),await t()}catch(e){if(!r.isCurrent())return;let t=e.message;t.startsWith(`Configuration changed since revision`)&&k(!0),F(t)}finally{r.finish()&&S(null)}},W=()=>U(!1);return(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Configuration`}),(0,O.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:n?`Ports and data path apply on the next restart — edit freely, then restart.`:`Edit and save; the config is used the next time the server starts.`}),(0,O.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),W()},children:[(0,O.jsx)(T,{label:`Command`,hint:`The exact command the agent runs to launch bunqueue. It receives HTTP_PORT and TCP_PORT; BUNQUEUE_DATA_PATH is injected only for SQLite and removed in non-SQLite modes. The default resolves Bunqueue 2.9.0 with bunx; offline installs can point at a local entry.`,children:(0,O.jsx)(w,{name:`server-command`,autoComplete:`off`,spellCheck:!1,value:L.command,disabled:V,onChange:e=>R({command:e.target.value}),placeholder:`bunx bunqueue@2.9.0 start`})}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,O.jsx)(T,{label:`HTTP port`,hint:`Dashboard API + SSE.`,children:(0,O.jsx)(w,{name:`server-http-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:L.httpPort,disabled:V,onChange:e=>R({httpPort:Number(e.target.value)})})}),(0,O.jsx)(T,{label:`TCP port`,hint:`Binary protocol. Must differ from HTTP.`,children:(0,O.jsx)(w,{name:`server-tcp-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:L.tcpPort,disabled:V,onChange:e=>R({tcpPort:Number(e.target.value)})})})]}),(0,O.jsx)(T,{label:`Data path`,hint:`Durable SQLite path for the managed broker and Workflow Engine, relative to the agent's working directory. In PostgreSQL mode the agent keeps it for Workflow state but does not pass it to the broker.`,children:(0,O.jsx)(w,{name:`server-data-path`,autoComplete:`off`,spellCheck:!1,value:L.dataPath,disabled:V,onChange:e=>R({dataPath:e.target.value})})}),(0,O.jsx)(T,{label:`Environment variables`,hint:`Injected on start. Memory and PostgreSQL modes remove inherited SQLite path aliases so Bunqueue cannot start with ambiguous storage. Applies on the next restart.`,children:(0,O.jsx)(G,{value:L.extraEnv??{},onChange:e=>R({extraEnv:e}),disabled:V},I?.id??`initial`)}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsx)(u,{type:`submit`,variant:`accent`,size:`sm`,disabled:V,children:`Save config`}),n&&(0,O.jsxs)(u,{variant:`warning`,size:`sm`,disabled:V,onClick:()=>{let e=z.length>0?` Changed: ${z.join(`, `)}.`:``;if(window.confirm(`Save configuration and restart the server to apply it?${e}`))return U(!0)},children:[(0,O.jsx)(a,{className:`size-3.5`}),` Save & restart`]}),B&&!y&&(0,O.jsx)(`span`,{className:`text-xs text-warning`,children:`Restart to apply changes`}),y&&(0,O.jsx)(`span`,{className:`text-xs text-success`,children:`Saved`}),C&&(0,O.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,disabled:V,onClick:()=>{e?.config&&(m.current=null,g(j(e.config,N(e.configRevision),c.scopeKey,++l.current)),v(!1),k(!1),F(null))},children:`Reload latest`}),A&&(0,O.jsx)(`span`,{className:`text-xs text-danger`,children:A})]})]})]})}var q=[`all`,`stdout`,`stderr`,`sys`],J=e=>`${new Date(e).toLocaleTimeString([],{hour12:!1})}.${String(e%1e3).padStart(3,`0`)}`,ae=e=>e===`stderr`?`text-danger/90`:e===`sys`?`text-accent/80`:`text-muted`;function oe(e,t=Date.now()){let n=new Blob([e],{type:`text/plain`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`bunqueue-logs-${t}.log`;try{document.body.appendChild(i),i.click()}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}}function se(){let{data:e,error:n,loading:r,refetch:i}=ce(),a=(0,D.useMemo)(()=>e?.lines??[],[e]),[s,c]=(0,D.useState)(`all`),[l,u]=(0,D.useState)(``),[d,g]=(0,D.useState)(!0),[v,y]=(0,D.useState)(!1),b=(0,D.useRef)(null),x=(0,D.useMemo)(()=>{let e=l.trim().toLowerCase();return a.map(e=>e.line.includes(`\x1B`)?{...e,line:_(e.line)}:e).filter(t=>(s===`all`||t.stream===s)&&(!e||t.line.toLowerCase().includes(e)))},[a,s,l]);(0,D.useEffect)(()=>{if(!d)return;let e=b.current;e&&(e.scrollTop=e.scrollHeight)},[x.length,d]);let w=(0,D.useMemo)(()=>x.map(e=>v?`${J(e.ts)} [${e.stream}] ${e.line}`:e.line).join(`
|
|
2
|
+
`),[x,v]);return(0,O.jsxs)(f,{padded:!1,className:`overflow-hidden`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-4 py-3`,children:[(0,O.jsx)(`h3`,{className:`mr-1 text-base font-semibold text-fg`,children:`Process logs`}),(0,O.jsx)(C,{options:q,value:s,onChange:c}),(0,O.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,O.jsx)(o,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,O.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),"aria-label":`Filter log lines`,name:`process-log-filter`,autoComplete:`off`,placeholder:`Filter…`,className:`h-8 w-full rounded-lg border border-line bg-surface-2 pl-8 pr-2 text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,O.jsx)(Y,{on:d,onClick:()=>g(e=>!e),label:`Follow`}),(0,O.jsx)(Y,{on:v,onClick:()=>y(e=>!e),label:`Times`}),(0,O.jsx)(S,{value:w}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{oe(w)},disabled:x.length===0,className:`rounded-md border border-line bg-surface-2 px-2 py-1 text-xs text-muted transition-colors hover:text-fg disabled:opacity-40`,children:`Download`})]}),n&&e&&(0,O.jsx)(`div`,{className:`border-b border-line px-4 pt-3 font-sans`,children:(0,O.jsx)(p,{message:`Process-log refresh failed — showing the last received lines. ${n.message}`,onRetry:i})}),(0,O.jsx)(`div`,{ref:b,className:`max-h-80 min-h-40 overflow-y-auto p-4 font-mono text-xs leading-relaxed`,children:r&&!e&&!n?(0,O.jsx)(`div`,{className:`font-sans`,children:(0,O.jsx)(h,{label:`Loading process logs…`})}):n&&!e?(0,O.jsx)(`div`,{className:`font-sans`,children:(0,O.jsx)(m,{error:n,onRetry:i})}):x.length===0?(0,O.jsx)(`p`,{className:`text-faint`,children:a.length===0?`No output yet.`:`No lines match the current filter.`}):x.map(e=>(0,O.jsxs)(`div`,{className:t(`whitespace-pre-wrap`,ae(e.stream)),children:[v&&(0,O.jsx)(`span`,{className:`mr-2 text-faint`,children:J(e.ts)}),e.line]},e.seq))}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-[11px] text-faint`,children:[(0,O.jsx)(`span`,{children:n&&!e?`logs unavailable`:x.length===a.length?`${a.length} lines`:`${x.length} of ${a.length} lines`}),(0,O.jsx)(`span`,{children:n?`refresh failed`:d?`following tail`:`paused`})]})]})}function Y({on:e,onClick:n,label:r}){return(0,O.jsx)(`button`,{type:`button`,onClick:n,"aria-pressed":e,className:t(`rounded-md border px-2 py-1 text-xs transition-colors`,e?`border-accent/40 bg-accent/10 text-accent`:`border-line bg-surface-2 text-muted hover:text-fg`),children:r})}function ce(){return l(()=>i.control.logs(),[])}var X={running:{label:`Running`,tone:`text-success`,dot:`bg-emerald-400`},starting:{label:`Starting`,tone:`text-warning`,dot:`bg-amber-400`},stopping:{label:`Stopping`,tone:`text-warning`,dot:`bg-amber-400`},stopped:{label:`Stopped`,tone:`text-danger`,dot:`bg-red-400`}};function Z({startedAt:e}){let[,t]=(0,D.useState)(0);return(0,D.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,O.jsx)(O.Fragment,{children:x((Date.now()-e)/1e3)})}function Q({label:e,children:t,title:n}){return(0,O.jsxs)(`div`,{className:`min-w-0`,title:n,children:[(0,O.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e}),(0,O.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,children:t})]})}function le({status:e,agentBase:n,transitioning:r,stale:i=!1,vitals:o=null,busy:l,onStart:d,onStop:f,onRestart:p}){let m=e?.status??`stopped`,h=e?.managementMode===`external`,g=h?e?.reachable===!0:m===`running`,_=h?e?.healthy?{label:`External`,tone:`text-success`,dot:`bg-emerald-400`}:e?.reachable?{label:`External`,tone:`text-warning`,dot:`bg-amber-400`}:{label:`External`,tone:`text-danger`,dot:`bg-red-400`}:X[m]??X.stopped,y=!!e?.healthy&&!i,b=!h&&!g&&e?.exitCode!=null&&e.exitCode!==0,x=e?.runningConfig??e?.config??null,C=x?.httpPort??6790,w=h?e?.externalUrl??`—`:`http://localhost:${C}`,T=w===`—`?`—`:`${w}/health`;return(0,O.jsxs)(`section`,{className:`mb-6 overflow-hidden rounded-xl border border-line bg-surface`,children:[(0,O.jsx)(`div`,{className:t(`h-0.5 bg-gradient-to-r to-transparent`,g&&y?`from-emerald-400/80 via-emerald-400/25`:g||r?`from-amber-400/80 via-amber-400/25`:`from-red-400/70 via-red-400/20`)}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-5 p-5 lg:flex-row lg:items-center lg:justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[g&&y&&(0,O.jsx)(`span`,{className:`absolute inline-flex size-full rounded-full bg-emerald-400 opacity-50 motion-safe:animate-ping`}),(0,O.jsx)(`span`,{className:t(`relative inline-flex size-3.5 rounded-full`,_.dot)})]}),(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,O.jsx)(`span`,{className:t(`text-2xl font-bold tracking-tight`,_.tone),children:r&&l?`${l}…`:_.label}),e?.version&&(0,O.jsxs)(`span`,{className:`font-mono text-xs text-muted`,children:[`bunqueue v`,e.version]}),b&&(0,O.jsxs)(`span`,{className:`rounded-full bg-red-500/15 px-2 py-0.5 font-mono text-[11px] font-medium text-danger`,children:[`crashed · exit `,e?.exitCode]})]}),(0,O.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted`,children:i?(0,O.jsxs)(`span`,{className:`text-warning`,children:[`last known: pid `,e?.pid??`—`,` — agent unreachable, state may have changed`]}):h?(0,O.jsx)(`span`,{title:e?.healthError,children:e?.reachable?y?`healthy via ${T}`:`reachable but unhealthy via ${T}`:`unreachable via ${T}`}):g?(0,O.jsxs)(O.Fragment,{children:[y?`healthy`:`waiting for health…`,` · pid `,e?.pid??`—`,` · up`,` `,e?.startedAt?(0,O.jsx)(Z,{startedAt:e.startedAt}):`—`]}):`process not running — start it below or point the dashboard at an external server`})]})]}),!h&&(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(u,{variant:`success`,disabled:g||r||i,onClick:d,children:[(0,O.jsx)(c,{className:`size-4`}),` Start`]}),(0,O.jsxs)(u,{variant:`warning`,disabled:!g||r||i,onClick:f,children:[(0,O.jsx)(s,{className:`size-4`}),` Stop`]}),(0,O.jsxs)(u,{disabled:r||i,onClick:p,children:[(0,O.jsx)(a,{className:`size-4`}),` Restart`]})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 border-t border-line bg-surface-2/30 px-5 py-4 md:grid-cols-3 xl:grid-cols-7`,children:[(0,O.jsx)(Q,{label:`Memory`,children:o?.memory?.rss==null?(0,O.jsx)(`span`,{className:`text-faint`,children:`—`}):(0,O.jsxs)(`span`,{title:`heap ${o.memory.heapUsed??`?`} / ${o.memory.heapTotal??`?`} MB`,children:[o.memory.rss,` MB rss`]})}),(0,O.jsx)(Q,{label:`Connections`,children:o?.connections?`${o.connections.tcp??0} tcp · ${o.connections.ws??0} ws · ${o.connections.sse??0} sse`:(0,O.jsx)(`span`,{className:`text-faint`,children:`—`})}),(0,O.jsx)(Q,{label:h?`Health target`:`API endpoint`,title:T,children:w===`—`?(0,O.jsx)(`span`,{className:`text-faint`,children:w}):(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`a`,{href:T,target:`_blank`,rel:`noreferrer`,className:`truncate text-accent hover:underline`,children:w}),(0,O.jsx)(S,{value:w})]})}),(0,O.jsx)(Q,{label:h?`Lifecycle`:`Ports`,children:h?`external`:x?`${x.httpPort} http · ${x.tcpPort} tcp`:`—`}),(0,O.jsx)(Q,{label:h?`Health HTTP`:`Started`,children:h?e?.healthStatus??`—`:g&&e?.startedAt?v(e.startedAt):`—`}),(0,O.jsx)(Q,{label:`Control agent`,title:n,children:n.replace(/^https?:\/\//,``)}),(0,O.jsx)(Q,{label:h?`Supervisor`:`Launch command`,title:x?.command,children:h?`managed elsewhere`:x?.command??`—`})]})]})}var $=[{key:`size`,label:`Database`,color:`bg-accent`},{key:`walSize`,label:`WAL`,color:`bg-amber-400`},{key:`shmSize`,label:`SHM`,color:`bg-zinc-500`}];function ue({db:e}){let n=e.totalSize||0;return(0,O.jsxs)(f,{children:[(0,O.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Storage`}),(0,O.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:e.exists?`${b(n)} on disk`:`not created yet`})]}),(0,O.jsxs)(`p`,{className:`mb-4 flex items-center gap-1.5 truncate font-mono text-xs text-faint`,title:e.path,children:[(0,O.jsx)(`span`,{className:`truncate`,children:e.path}),(0,O.jsx)(S,{value:e.path})]}),e.exists&&n>0?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-surface-2`,children:$.map(r=>{let i=e[r.key];return i?(0,O.jsx)(`div`,{className:t(`h-full`,r.color),style:{width:`${i/n*100}%`},title:`${r.label}: ${b(i)}`},r.key):null})}),(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 font-mono text-[11px] text-faint`,children:[$.map(n=>(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`span`,{className:t(`size-2 rounded-full`,n.color)}),n.label,` `,(0,O.jsx)(`span`,{className:`text-fg`,children:b(e[n.key])})]},n.key)),e.mtimeMs?(0,O.jsxs)(`span`,{className:`ml-auto`,children:[`written `,y(e.mtimeMs)]}):null]})]}):(0,O.jsx)(`p`,{className:`rounded-lg border border-dashed border-line px-4 py-6 text-center text-sm text-faint`,children:`The database appears here after the first start — SQLite creates the file at the configured data path.`})]})}function de(){let e=(0,D.useRef)(0),t=(0,D.useRef)(new WeakMap),{data:n,error:r,refetch:a}=l(async()=>{let n=++e.current,r=await i.control.status();return t.current.set(r,n),r},[]),o=E(`server-lifecycle`),[s,c]=(0,D.useState)(null),[u,m]=(0,D.useState)(null);(0,D.useEffect)(()=>{c(null),m(null)},[o.scopeKey]);let h=n?.managementMode===`external`,_=h?n?.reachable===!0:n?.status===`running`,{data:v}=l(()=>_?i.health():Promise.resolve(null),[_]),y=_?v??null:null,b=y?.connections?` This drops ${y.connections.tcp??0} TCP / ${y.connections.ws??0} WS connections; in-flight jobs are interrupted.`:` In-flight jobs are interrupted.`,x=async(e,t,n)=>{let r=o.begin(`lifecycle`);if(r){if(n&&!window.confirm(n)){r.finish();return}if(!r.isCurrent()){r.finish();return}c(e),m(null);try{if(await t(),!r.isCurrent())return;await a()}catch(e){if(!r.isCurrent())return;m(e.message)}finally{r.finish()&&c(null)}}};if(r&&!n)return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(g,{title:`Server`,description:`Start, stop and restart the bunqueue server.`}),(0,O.jsx)(p,{message:`Control agent unreachable — server lifecycle controls are unavailable.`,onRetry:a}),(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Control agent not running`}),(0,O.jsxs)(`p`,{className:`text-sm text-muted`,children:[`The local control agent is unreachable at`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:i.agentBase}),`. It manages the bunqueue server process (start / stop / restart). Start it with:`]}),(0,O.jsxs)(`pre`,{className:`mt-3 overflow-x-auto rounded-lg border border-line bg-surface-2 px-3 py-2 text-xs`,children:[`bun start`,` `,`# agent + dashboard together (recommended)`,`
|
|
3
|
+
`,`bun run agent`,` `,`# agent only, if the dashboard is already running`]}),(0,O.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`This page reconnects automatically once the agent is up — no reload needed.`})]})]});let S=n?.status??`stopped`,C=S===`running`,w=S===`starting`||S===`stopping`||s!=null,T=r!=null&&n!=null;return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(g,{title:`Server`,description:h?`Observe the Bunqueue server managed by an external supervisor.`:`Supervise the bunqueue server process — lifecycle, configuration, storage and logs.`}),u&&(0,O.jsx)(`div`,{role:`status`,className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:u}),T&&(0,O.jsx)(`div`,{className:`mb-4 rounded-lg border border-amber-500/20 bg-amber-500/5 px-4 py-2 text-sm text-warning`,children:`Control agent unreachable — showing last known state. Lifecycle actions are disabled until it responds again.`}),(0,O.jsx)(le,{status:n,agentBase:i.agentBase,stale:T,vitals:y,transitioning:w,busy:s,onStart:()=>x(`starting`,()=>i.control.start()),onStop:()=>x(`stopping`,()=>i.control.stop(),`Stop the bunqueue server?${b}`),onRestart:()=>x(`restarting`,()=>i.control.restart(),`Restart the bunqueue server?${b}`)}),h?(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Managed externally`}),(0,O.jsxs)(`p`,{className:`text-sm text-muted`,children:[`This dashboard is attached to`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:n?.externalUrl??`BUNQUEUE_URL`}),`. Start, stop, restart and launch configuration are intentionally unavailable while`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:`BUNQUEUE_MANAGED=0`}),`. Use systemd, Docker, Kubernetes or the broker's external supervisor instead.`]})]}):(0,O.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,O.jsx)(K,{status:n,onSaved:a,running:C,statusRequestId:n?t.current.get(n):void 0,getStatusRequestSequence:()=>e.current,transitioning:w}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[n?.db&&(0,O.jsx)(ue,{db:n.db}),(0,O.jsx)(se,{})]})]}),(0,O.jsx)(`div`,{className:`mt-6`,children:(0,O.jsx)(A,{agentBase:i.agentBase})})]})}export{de as ServerControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{a as r,o as i,t as a}from"./connectionStore-CFuNYZ_8.js";import{f as o}from"./icons-BVzwsfbG.js";import{n as s,t as c}from"./Button-Ch1W94fJ.js";import{n as l,t as u}from"./Card-CWxrC8OY.js";import{t as d}from"./PageHeader-CvIyaFOO.js";import{o as f}from"./index-TploGF7u.js";import{a as p,n as m,t as h}from"./form-C4oby9pI.js";var g=e(t(),1),_=n(),v=[[`1000`,`1 second`],[`2000`,`2 seconds`],[`3000`,`3 seconds`],[`5000`,`5 seconds`],[`10000`,`10 seconds`]];function y(){let{refreshMs:e,setRefreshMs:t}=i(),{theme:n,setTheme:r}=f();return(0,_.jsxs)(u,{children:[(0,_.jsx)(l,{title:`Appearance & refresh`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,_.jsx)(h,{label:`Theme`,children:(0,_.jsxs)(p,{name:`theme`,autoComplete:`off`,value:n,onChange:e=>r(e.target.value),children:[(0,_.jsx)(`option`,{value:`dark`,children:`Dark`}),(0,_.jsx)(`option`,{value:`light`,children:`Light`})]})}),(0,_.jsx)(h,{label:`Refresh interval`,children:(0,_.jsx)(p,{name:`refresh-interval`,autoComplete:`off`,value:String(e),onChange:e=>t(Number(e.target.value)),children:v.map(([e,t])=>(0,_.jsx)(`option`,{value:e,children:t},e))})})]})]})}var b=1e4,x=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;async function S(e,t={},n=b){let r=new AbortController,i=t.signal,a=i?AbortSignal.any([i,r.signal]):r.signal,o=Error(`Connection test timed out after ${Math.ceil(n/1e3)} seconds.`),s,c,l=new Promise((e,t)=>{s=setTimeout(()=>{r.abort(o),t(o)},n)}),u=i?new Promise((e,t)=>{let n=()=>{t(i.reason??new DOMException(`Connection test aborted`,`AbortError`))};i.aborted?n():(i.addEventListener(`abort`,n,{once:!0}),c=()=>i.removeEventListener(`abort`,n))}):null;try{let n=(async()=>{let n=await fetch(e,{...t,signal:a});if(!n.ok&&n.status!==503)throw Error(`HTTP ${n.status}`);let r=await n.json();if(typeof r!=`object`||!r||Array.isArray(r))throw Error(`Malformed health response`);let i=r;if(typeof i.ok!=`boolean`||i.status!==`healthy`&&i.status!==`degraded`||!Number.isSafeInteger(i.uptime)||i.uptime<0||typeof i.version!=`string`||!x.test(i.version)||i.ok!==(i.status===`healthy`))throw Error(`Malformed health response`);return{response:n,health:i}})();return await Promise.race(u?[n,l,u]:[n,l])}catch(e){throw r.signal.aborted&&r.signal.reason===o?o:e}finally{s!==void 0&&clearTimeout(s),c?.()}}function C(){let{baseUrl:e,token:t,agentToken:n,saveConnection:f}=i(),[p,v]=(0,g.useState)(!1),[b,x]=(0,g.useState)(null),[C,w]=(0,g.useState)(e),[T,E]=(0,g.useState)(t),[D,O]=(0,g.useState)(n),[k,A]=(0,g.useState)(!1),[j,M]=(0,g.useState)(!1),[N,P]=(0,g.useState)(null),[F,I]=(0,g.useState)(null),L=(0,g.useRef)(!0),R=(0,g.useRef)(0),z=(0,g.useRef)(null),B=(0,g.useRef)(null),V=(0,g.useCallback)(()=>{B.current!==null&&(clearTimeout(B.current),B.current=null),L.current&&I(null)},[]),H=(0,g.useCallback)(()=>{R.current+=1,z.current?.abort(new DOMException(`Connection test superseded`,`AbortError`)),z.current=null,L.current&&(v(!1),x(null))},[]);return(0,g.useEffect)(()=>(L.current=!0,()=>{L.current=!1,R.current+=1,z.current?.abort(new DOMException(`Settings unmounted`,`AbortError`)),z.current=null,B.current!==null&&(clearTimeout(B.current),B.current=null)}),[]),(0,g.useEffect)(()=>{w(e),E(t),O(n),H()},[n,e,H,t]),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(d,{title:`Settings`,description:`Connection and appearance.`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(u,{children:[(0,_.jsx)(l,{title:`Connection`}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,_.jsx)(h,{label:`Server URL`,children:(0,_.jsx)(m,{name:`server-url`,value:C,onChange:e=>{H(),V(),w(e.target.value),P(null)},placeholder:`/api or https://queue.example.com`,autoComplete:`off`,inputMode:`url`,"aria-invalid":N?!0:void 0,"aria-describedby":N?`server-url-error`:`server-url-help`})}),N&&(0,_.jsx)(`p`,{id:`server-url-error`,className:`-mt-2 text-xs text-danger`,children:N}),(0,_.jsxs)(`p`,{id:`server-url-help`,className:`-mt-2 text-xs text-faint`,children:[`Use `,(0,_.jsx)(`code`,{className:`font-mono`,children:`/api`}),` in dev (proxied to localhost:6790), or the server origin in production.`]}),(0,_.jsx)(h,{label:`Bearer token (optional)`,hint:`Kept in memory only — re-enter after reload. Never bake secrets into VITE_* variables.`,htmlFor:`bearer-token`,children:(0,_.jsxs)(`div`,{className:`relative`,children:[(0,_.jsx)(m,{id:`bearer-token`,name:`bearer-token`,type:k?`text`:`password`,value:T,onChange:e=>{H(),V(),E(e.target.value)},placeholder:`only if AUTH_TOKENS is set`,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,_.jsx)(s,{"aria-label":k?`Hide token`:`Show token`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>A(e=>!e),children:(0,_.jsx)(o,{className:`size-4`})})]})}),(0,_.jsx)(h,{label:`Agent token (optional)`,hint:`Only if the control agent runs with AGENT_TOKEN. Kept in memory; re-enter after reload.`,htmlFor:`agent-token`,children:(0,_.jsxs)(`div`,{className:`relative`,children:[(0,_.jsx)(m,{id:`agent-token`,name:`agent-token`,type:j?`text`:`password`,value:D,onChange:e=>{H(),V(),O(e.target.value)},placeholder:`only if AGENT_TOKEN is set`,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,_.jsx)(s,{"aria-label":j?`Hide agent token`:`Show agent token`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>M(e=>!e),children:(0,_.jsx)(o,{className:`size-4`})})]})}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,_.jsx)(c,{variant:`accent`,onClick:()=>{H();let e=r(C);if(!e){P(a);return}P(null),w(e);let t=f({baseUrl:e,token:T,agentToken:D});V(),I({persisted:t.persisted,message:t.persisted?`Saved ✓`:`Saved for this session only — browser storage unavailable${t.error?`: ${t.error}`:`.`}`}),B.current=setTimeout(()=>{B.current=null,L.current&&I(null)},4e3)},children:`Save`}),(0,_.jsx)(c,{onClick:async()=>{H();let e=r(C);if(!e){P(a),x({ok:!1,msg:a});return}P(null);let t=R.current,n=new AbortController,o=i.getState(),s=()=>{let e=i.getState();return L.current&&t===R.current&&!n.signal.aborted&&e.baseUrl===o.baseUrl&&e.token===o.token&&e.agentToken===o.agentToken};z.current=n,v(!0),x(null);let c=performance.now();try{let{response:t,health:r}=await S(`${e}/health`,{headers:T.trim()?{Authorization:`Bearer ${T.trim()}`}:void 0,signal:n.signal});if(!s())return;let i=Math.round(performance.now()-c),a=t.status===503||r.status===`degraded`;x({ok:!a,msg:`${a?`Server reachable`:`Connected`} in ${i}ms · bunqueue v${r.version}${a?` · degraded`:``}`})}catch(e){if(!s())return;x({ok:!1,msg:e.message})}finally{L.current&&t===R.current&&(z.current=null,v(!1))}},children:p?`Restart test`:`Test connection`}),F&&(0,_.jsx)(`span`,{role:`status`,className:F.persisted?`text-sm text-success`:`text-sm text-warning`,children:F.message}),b&&(0,_.jsx)(`span`,{role:`status`,className:b.ok?`text-sm text-success`:`text-sm text-danger`,children:b.msg})]}),(0,_.jsx)(`p`,{className:`-mt-1 text-xs text-faint`,children:`Test checks the values above as typed. Saving repoints every page at the new server immediately.`})]})]}),(0,_.jsx)(y,{})]})]})}export{C as Settings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./cn-zFEt5SO8.js";import{t}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./cn-zFEt5SO8.js";import{t}from"./react-vendor-CvwrP0tU.js";var n=t(),r={completed:`text-success bg-emerald-500/10`,active:`text-blue-400 light:text-blue-700 bg-blue-500/10`,failed:`text-danger bg-red-500/10`,waiting:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,prioritized:`text-violet-400 light:text-violet-700 bg-violet-500/10`,delayed:`text-warning bg-amber-500/10`,paused:`text-orange-400 light:text-orange-700 bg-orange-500/10`,"waiting-children":`text-cyan-400 light:text-cyan-700 bg-cyan-500/10`,stalled:`text-orange-400 light:text-orange-700 bg-orange-500/10`,running:`text-blue-400 light:text-blue-700 bg-blue-500/10`,compensating:`text-violet-400 light:text-violet-700 bg-violet-500/10`,"compensation-stuck":`text-danger bg-red-500/10`,compensated:`text-success bg-emerald-500/10`,"compensation-failed":`text-danger bg-red-500/10`,"compensation-skipped":`text-warning bg-amber-500/10`,enqueued:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,started:`text-blue-400 light:text-blue-700 bg-blue-500/10`,finished:`text-success bg-emerald-500/10`,retry:`text-warning bg-amber-500/10`,cancelled:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,default:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`};function i({status:t}){let i=(t||``).toLowerCase();return(0,n.jsxs)(`span`,{className:e(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium capitalize`,r[i]??r.default),children:[(0,n.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),t||`unknown`]})}function a({label:t,tone:r=`green`}){return(0,n.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted`,children:[(0,n.jsx)(`span`,{className:e(`size-1.5 rounded-full`,r===`green`?`bg-emerald-400`:r===`amber`?`bg-amber-400`:r===`red`?`bg-red-400`:`bg-zinc-400`)}),t]})}export{a as n,i as t};
|