bunqueue-dashboard 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +335 -608
- package/dist/assets/AddJob-Dgjlhzn2.js +3 -0
- package/dist/assets/Alerts-Lyzbq0qw.js +1 -0
- package/dist/assets/{AreaChart-BMYp7z5y.js → AreaChart-CSP0-00u.js} +1 -1
- package/dist/assets/Benchmark-B4NfYkAi.js +1 -0
- package/dist/assets/{BulkAddJobs-0cdWqkEF.js → BulkAddJobs-BAN5wT8A.js} +3 -3
- package/dist/assets/Cron-Bz46oVXB.js +1 -0
- package/dist/assets/CronManager-Cl5RW2cB.js +1 -0
- package/dist/assets/Database-CeUKS6Nf.js +3 -0
- package/dist/assets/Diagnostics-DuzTPfyb.js +1 -0
- package/dist/assets/Dlq-D8s-NhV2.js +1 -0
- package/dist/assets/DlqControl-DDxRMM8i.js +1 -0
- package/dist/assets/DlqPro-xj-MM6u8.js +1 -0
- package/dist/assets/Fleet-BAziMWfo.js +1 -0
- package/dist/assets/Flows-BFUMTSWv.js +2 -0
- package/dist/assets/JobInspector-BXuXxDwR.js +2 -0
- package/dist/assets/Jobs-pQBmffni.js +1 -0
- package/dist/assets/JobsPro-k20Pas24.js +1 -0
- package/dist/assets/Logs-DA4JFvpM.js +1 -0
- package/dist/assets/LogsPro-hna5L6sP.js +1 -0
- package/dist/assets/{McpServer-ffXr4nFW.js → McpServer-Cqem-L3z.js} +2 -2
- package/dist/assets/Metrics-CJ9dW0me.js +1 -0
- package/dist/assets/MetricsPro-BslYrx1A.js +1 -0
- package/dist/assets/Overview-Cmg_2NAt.js +1 -0
- package/dist/assets/Pagination-WVfHLHDS.js +1 -0
- package/dist/assets/{QueueActions-BgdW95rN.js → QueueActions-BQf1-g5m.js} +1 -1
- package/dist/assets/QueueControl-BiMM0jLp.js +1 -0
- package/dist/assets/QueueDetail-DfRY4jS4.js +1 -0
- package/dist/assets/QueueDetailPro-CpSMSo8A.js +1 -0
- package/dist/assets/Queues-C5lElTjp.js +1 -0
- package/dist/assets/QueuesOverview-DRohFtuC.js +1 -0
- package/dist/assets/S3Backup-DUHmp2Xw.js +1 -0
- package/dist/assets/S3BackupPro-Cr2ZJZkw.js +3 -0
- package/dist/assets/ServerControl-m58ooJT2.js +3 -0
- package/dist/assets/Settings-DXsjoOqD.js +1 -0
- package/dist/assets/{StatusBadge-cYUkK-4P.js → StatusBadge-D-mexaga.js} +1 -1
- package/dist/assets/Usage-CY2uEJEu.js +1 -0
- package/dist/assets/UsagePro-DtlB1dJc.js +1 -0
- package/dist/assets/Webhooks-B_GwTCBW.js +1 -0
- package/dist/assets/Workers-Bu8aJlZf.js +1 -0
- package/dist/assets/WorkersPro-C6gNYGfo.js +1 -0
- package/dist/assets/Workflows-ClF4YzhW.js +1 -0
- package/dist/assets/{api-Bbo86MB6.js → api-CCgfskjt.js} +1 -1
- package/dist/assets/{classicJobsData-BimIyQky.js → classicJobsData-wdIr-E4y.js} +1 -1
- package/dist/assets/connectionStore-B946Fhuv.js +1 -0
- package/dist/assets/controlConnectionEpoch-x9VjrWgN.js +1 -0
- package/dist/assets/{form-Dy-an7ew.js → form-DBkslwzu.js} +1 -1
- package/dist/assets/{icons-C1HVBnFn.js → icons-BIT5aq1c.js} +1 -1
- package/dist/assets/index-DR8flo6r.css +1 -0
- package/dist/assets/index-X_fHGbXZ.js +8 -0
- package/dist/assets/install-hFu5e6YM.js +3 -0
- package/dist/assets/package-Bb3FkjoS.js +1 -0
- package/dist/assets/react-vendor-08inPAVO.js +11 -0
- package/dist/assets/responses-YgpvqWEr.js +1 -0
- package/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/assets/{useControlActionGuard-DImMgJtj.js → useControlActionGuard-Bx5MkufG.js} +1 -1
- package/dist/assets/{useServerActionGuard-Cr4KUOeZ.js → useServerActionGuard-uiZWD3dS.js} +1 -1
- package/dist/assets/useThroughputSeries-BN5QmKPt.js +1 -0
- package/dist/index.html +8 -16
- package/package.json +29 -36
- package/scripts/embedded.gen.ts +132 -148
- package/dist/assets/AddJob-jq-VZ_YE.js +0 -3
- package/dist/assets/Alerts-Bi8zLKXV.js +0 -1
- package/dist/assets/Benchmark-CWYdqm55.js +0 -1
- package/dist/assets/Button-BCjgbAhY.js +0 -1
- package/dist/assets/Card-DptfvL2O.js +0 -1
- package/dist/assets/Cron-dPGwJXqY.js +0 -1
- package/dist/assets/CronManager-C0-Y2QDg.js +0 -1
- package/dist/assets/Database-CseJOrvD.js +0 -3
- package/dist/assets/Diagnostics-cZTy4Y2t.js +0 -1
- package/dist/assets/Dlq-W2xOJiZM.js +0 -1
- package/dist/assets/DlqControl-CIV5278D.js +0 -1
- package/dist/assets/DlqPro-BuRxGtGt.js +0 -1
- package/dist/assets/Fleet-0zKJSjCw.js +0 -1
- package/dist/assets/Flows-CEfm102Y.js +0 -2
- package/dist/assets/JobInspector-BlMj5-Vr.js +0 -2
- package/dist/assets/Jobs-D_TId_Oa.js +0 -1
- package/dist/assets/JobsPro-A06ZG5Xi.js +0 -1
- package/dist/assets/Logs-hbh7XhQU.js +0 -1
- package/dist/assets/LogsPro-BgEIjgfj.js +0 -1
- package/dist/assets/Metrics-CIKZGgf0.js +0 -1
- package/dist/assets/MetricsPro-CK3WfLCl.js +0 -1
- package/dist/assets/Overview-BBgwyUn4.js +0 -1
- package/dist/assets/PageHeader-DD4vnVog.js +0 -1
- package/dist/assets/Pagination-Cj7GzYNX.js +0 -1
- package/dist/assets/QueueControl-g-9kwrpt.js +0 -1
- package/dist/assets/QueueDetail-Cv3MLDoE.js +0 -1
- package/dist/assets/QueueDetailPro-AhdOAzEF.js +0 -1
- package/dist/assets/Queues-Bbvh_OCE.js +0 -1
- package/dist/assets/QueuesOverview-sPQILfMU.js +0 -1
- package/dist/assets/S3Backup-Cg6sc2JG.js +0 -1
- package/dist/assets/S3BackupPro-BWV_R_Vj.js +0 -3
- package/dist/assets/ServerControl-Dr2gXbaU.js +0 -3
- package/dist/assets/Settings-BsDDlu-h.js +0 -1
- package/dist/assets/Usage-Cxx6pZfb.js +0 -1
- package/dist/assets/UsagePro-CkC8WYcS.js +0 -1
- package/dist/assets/Webhooks-BKWnALGC.js +0 -1
- package/dist/assets/Workers-SJ9MApx3.js +0 -1
- package/dist/assets/WorkersPro-BDgHBTpY.js +0 -1
- package/dist/assets/Workflows-Cp6jqKeM.js +0 -1
- package/dist/assets/bq-CSX8DSME.js +0 -1
- package/dist/assets/connectionStore-DdLzJyut.js +0 -1
- package/dist/assets/controlConnectionEpoch-D4HtriLM.js +0 -1
- package/dist/assets/feedback-Dxfj-Fy1.js +0 -1
- package/dist/assets/format-Cg7VCIZW.js +0 -1
- package/dist/assets/index-CxzFSZj3.js +0 -8
- package/dist/assets/index-DZXf58c2.css +0 -1
- package/dist/assets/install-DUkXE5kb.js +0 -3
- package/dist/assets/package-C7CtgBEy.js +0 -1
- package/dist/assets/react-vendor-DfC0iyIS.js +0 -11
- package/dist/assets/responses-BkR2JTH9.js +0 -1
- package/dist/assets/rolldown-runtime-QTnfLwEv.js +0 -1
- package/dist/assets/toastStore-DnqA_aL-.js +0 -1
- package/dist/assets/usePolledData-Dp_ynL9f.js +0 -1
- package/dist/assets/useThroughputSeries-CrTeR9s3.js +0 -1
- package/patches/ai@7.0.14.patch +0 -25
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,r,t as i}from"./react-vendor-DfC0iyIS.js";import{t as a}from"./bq-CSX8DSME.js";import{t as o}from"./toastStore-DnqA_aL-.js";import{T as s,d as c,f as l,x as u}from"./icons-C1HVBnFn.js";import{r as d,t as f}from"./StatusBadge-cYUkK-4P.js";import{n as p}from"./usePolledData-Dp_ynL9f.js";import{n as m,t as h}from"./Button-BCjgbAhY.js";import{i as g,n as _,r as v}from"./feedback-Dxfj-Fy1.js";import{t as y}from"./PageHeader-DD4vnVog.js";import{a as b,c as x,i as S,s as C,t as w}from"./format-Cg7VCIZW.js";import{r as T}from"./index-CxzFSZj3.js";import{a as E}from"./form-Dy-an7ew.js";import{t as D}from"./Pagination-Cj7GzYNX.js";import{r as O,t as k}from"./useServerActionGuard-Cr4KUOeZ.js";import{n as A,t as j}from"./controlConnectionEpoch-D4HtriLM.js";import{t as M}from"./exportFile-C7xhE8Yh.js";import{t as N}from"./flowOperationPolicy-B2Etcb3f.js";var P=e(n(),1),F=1e4,I=100;async function L(e,t,n,r,i){let a=[],o=new Set,s=r.trim().toLowerCase(),c=n===`all`?void 0:[n],l=0;for(;;){i.throwIfAborted();let n=l===1e4?1:Math.min(I,F-l),{jobs:r}=await e.jobsList(t,c,n,l);if(i.throwIfAborted(),r.length>n)throw Error(`The server returned an invalid export page.`);if(l===1e4){if(r.length>0)throw Error(`Export exceeds ${F.toLocaleString()} jobs. Filter by state first.`);return a}for(let e of r){if(o.has(e.id))throw Error(`The queue changed during export. Retry when it is stable.`);o.add(e.id);let t=typeof e.name==`string`?e.name.toLowerCase():``;(!s||e.id.toLowerCase().includes(s)||t.includes(s))&&a.push(e)}if(r.length<n)return a;l+=r.length}}function R(e,t,n){let r=n.map(t=>({id:t.id,name:t.name??`default`,queue:t.queue??e,state:t.state??``,priority:t.priority??0,attempts:t.attempts??0,maxAttempts:t.maxAttempts??``,createdAt:t.createdAt?new Date(t.createdAt).toISOString():``,durationMs:t.startedAt&&t.completedAt?t.completedAt-t.startedAt:``}));M(`jobs-${e}-${t}`,r,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])}var z=i();function B(e){let[t,n]=(0,P.useState)(!1),r=(0,P.useId)();return(0,z.jsxs)(`div`,{className:`mb-6`,children:[(0,z.jsxs)(`div`,{className:`rounded-xl border border-line bg-surface p-3 md:hidden`,children:[(0,z.jsx)(`dl`,{"aria-label":`Job summary`,className:`grid grid-cols-3 gap-3 text-xs`,children:[[`Total`,e.total],[`Active`,e.active],[`Failed`,e.failed]].map(([e,t])=>(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`dt`,{className:`text-faint`,children:e}),(0,z.jsx)(`dd`,{className:`mt-1 break-words font-semibold tnum text-fg`,children:t})]},e))}),(0,z.jsx)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`mt-2 min-h-[44px] w-full rounded-lg border border-line text-xs font-medium text-muted hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,children:t?`Hide detailed statistics`:`Show all 8 statistics`})]}),(0,z.jsxs)(`div`,{id:r,className:d(`mt-3 grid-cols-2 gap-3 md:mt-0 md:grid md:grid-cols-4 md:gap-4 xl:grid-cols-8`,t?`grid`:`hidden`),children:[(0,z.jsx)(T,{label:`Total`,value:e.total,hint:`all queues`,compact:!0}),(0,z.jsx)(T,{label:`Waiting`,value:e.waiting,tone:`amber`,hint:`standard priority`,compact:!0}),(0,z.jsx)(T,{label:`Prioritized`,value:e.prioritized,tone:`amber`,compact:!0}),(0,z.jsx)(T,{label:`Active`,value:e.active,tone:`blue`,compact:!0}),(0,z.jsx)(T,{label:`Flow-blocked`,value:e.flowBlocked,tone:`blue`,compact:!0}),(0,z.jsx)(T,{label:`Completed`,value:e.completed,tone:`green`,compact:!0}),(0,z.jsx)(T,{label:`Failed`,value:e.failed,tone:e.failedCount!=null&&e.failedCount>0?`red`:`default`,compact:!0}),(0,z.jsx)(T,{label:`Error Rate`,value:e.errorRate,tone:e.errorRateTone,compact:!0})]})]})}var V=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`];function H(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function U(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function W(e=0){return e>=10?{text:`HIGH`,className:`text-warning`}:e>=1?{text:`MEDIUM`,className:`text-blue-400`}:{text:`LOW`,className:`text-faint`}}function G({queue:e,rows:t,search:n,discoveryError:i,selected:o,allSelected:s,bulkBusy:c,busyIds:p,page:h,hasNext:g,onToggleAll:_,onToggle:v,onRun:y,onPage:x}){return(0,z.jsxs)(z.Fragment,{children:[e&&(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,z.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,z.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:e})]}),(0,z.jsx)(`div`,{role:`region`,"aria-label":`Jobs table`,tabIndex:0,className:`overflow-x-auto rounded-xl border border-line bg-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,children:(0,z.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,z.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,z.jsx)(`input`,{type:`checkbox`,checked:s,ref:e=>{e&&(e.indeterminate=o.size>0&&!s)},"aria-checked":o.size>0&&!s?`mixed`:s,onChange:_,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,z.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,z.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,z.jsx)(`th`,{className:`sticky right-0 z-10 w-28 bg-surface px-2 py-3 text-right font-medium md:static md:px-5`,children:`Actions`})]})}),(0,z.jsx)(`tbody`,{children:t.length===0?(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:n.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:i?`Queue discovery failed. Retry above.`:`Select a queue.`})}):t.map(e=>{let t=W(e.priority),n=N(e.state),i=c||p.has(e.id);return(0,z.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,z.jsx)(`td`,{className:`px-5 py-3`,children:(0,z.jsx)(`input`,{type:`checkbox`,checked:o.has(e.id),onChange:()=>v(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,z.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,z.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,z.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,z.jsx)(`td`,{className:`px-5 py-3`,children:(0,z.jsx)(f,{status:String(e.state??`waiting`)})}),(0,z.jsx)(`td`,{className:d(`px-5 py-3 text-xs font-semibold`,t.className),children:t.text}),(0,z.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:S(e.createdAt)}),(0,z.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,z.jsx)(`td`,{className:`sticky right-0 z-10 bg-surface px-2 py-3 md:static md:px-5`,children:(0,z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,z.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect job ${e.id}`,className:`inline-flex size-[44px] shrink-0 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 md:size-8`,children:(0,z.jsx)(l,{className:`size-3.5`})}),n.promote&&(0,z.jsx)(m,{className:`size-[44px] shrink-0 md:size-8`,"aria-label":`Promote job`,disabled:i,onClick:()=>y(e,`Promote`,()=>a.promoteJob(e.id)),children:(0,z.jsx)(u,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,z.jsx)(D,{page:h,pageSize:25,hasNext:g,onPageChange:x,label:`jobs`})]})}function ee({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:c,onQueue:l,onStatus:u,onSearch:d,onPromote:f}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`w-48`,children:(0,z.jsxs)(E,{value:e,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:[e&&!t.some(t=>t.name===e)&&(0,z.jsx)(`option`,{value:e,children:e}),t.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,z.jsx)(`div`,{className:`w-48`,children:(0,z.jsx)(E,{"aria-label":`Job state`,name:`jobs-state`,value:n,onChange:e=>u(e.target.value),children:V.map(e=>(0,z.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,z.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,z.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,z.jsx)(`input`,{value:r,onChange:e=>d(e.target.value),placeholder:`Filter this page by ID or name…`,"aria-label":`Filter by job ID or name`,name:`jobs-id-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`})]})]}),i>0&&(0,z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,z.jsx)(`span`,{className:`mr-1 text-muted`,children:H(a,i)}),o?(0,z.jsx)(h,{size:`sm`,disabled:c,onClick:f,children:`Promote selected`}):(0,z.jsx)(`span`,{className:`text-xs text-faint`,children:a===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]})]})}function te({queue:e,view:t,rows:n,selected:r,setSelected:i,refetch:a}){let[s,c]=(0,P.useState)(new Set),[l,u]=(0,P.useState)(!1),[d,f]=(0,P.useState)(null),p=O(`jobs:${e}:${t}`);return(0,P.useEffect)(()=>{c(new Set),u(!1),f(null)},[p.scopeKey]),{actionMsg:d,bulkBusy:l,busyIds:s,runBulk:async(e,t,s,c)=>{let l=n.filter(e=>r.has(e.id)&&s(e));if(l.length===0||c&&!window.confirm(c(l.length)))return;let d=p.begin([`bulk`,...l.map(e=>`job:${e.id}`)]);if(d){u(!0),f(null);try{let n=await Promise.allSettled(l.map(async n=>{k(await t(n),`${e} ${n.id}`)}));if(!d.isCurrent())return;let r=n.filter(e=>e.status===`fulfilled`).length,s=n.length-r,c=`${e}: ${r} succeeded${s?`, ${s} failed`:``}`;f({ok:s===0,text:c}),s===0?o.success(c):o.error(c),i(e=>U(e,l.map(e=>e.id))),a()}finally{d.finish()&&u(!1)}}},runOne:async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let i=p.begin(`job:${e.id}`);if(i){c(t=>new Set(t).add(e.id)),f(null);try{if(k(await n(),t),!i.isCurrent())return;f({ok:!0,text:`${t} ✓`}),o.success(`${t} ✓`,e.id),a()}catch(e){if(!i.isCurrent())return;f({ok:!1,text:`${t} failed: ${e.message}`}),o.error(`${t} failed`,e.message)}finally{i.finish()&&c(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function ne(e,t,n){let[r,i]=(0,P.useState)(!1),s=(0,P.useRef)(null),c=O(JSON.stringify([`jobs-export`,e,t,n]));return(0,P.useEffect)(()=>(i(!1),()=>{s.current?.abort(),s.current=null}),[c.scopeKey]),{busy:r,exportAll:async()=>{if(!e)return;let r=c.begin(`export`);if(!r)return;let l=new AbortController;s.current=l,i(!0);try{let i=await L(a.createServerTargetClient(a.captureServerRequestTarget(),l.signal),e,t,n,l.signal);if(!r.isCurrent())return;if(i.length===0){o.info(`No jobs match this export`);return}R(e,t,i),o.success(`Exported ${i.length.toLocaleString()} jobs`)}catch(e){r.isCurrent()&&!l.signal.aborted&&o.error(`Export failed`,e instanceof Error?e.message:String(e))}finally{s.current===l&&(s.current=null),r.finish()&&i(!1)}}}}var K=new Set;function re(e){let[n,r]=t(),i=n.get(`queue`)??``,a=n.get(`status`),o=a&&V.includes(a)?a:`all`,s=e&&!e.some(e=>e.name===i)?e[0]?.name??``:i,c=A(),l=JSON.stringify([c,s,o]),u=(0,P.useRef)({identity:l,generation:0});u.current.identity!==l&&(u.current={identity:l,generation:u.current.generation+1});let d=u.current.generation,[f,p]=(0,P.useState)({generation:-1,page:0}),m=f.generation===d?f.page:0,h=(0,P.useRef)({listGeneration:d,page:m,generation:0});(h.current.listGeneration!==d||h.current.page!==m)&&(h.current={listGeneration:d,page:m,generation:h.current.generation+1});let g=h.current.generation,_=JSON.stringify([c,d,g,s,o,m]),[v,y]=(0,P.useState)({generation:-1,ids:new Set}),b=v.generation===g?v.ids:K,x=(0,P.useCallback)(e=>p(t=>u.current.generation===d&&j()===c?{generation:d,page:e}:t),[c,d]),S=(0,P.useCallback)(e=>y(t=>{if(h.current.generation!==g||j()!==c)return t;let n=t.generation===g?t.ids:K;return{generation:g,ids:typeof e==`function`?e(n):e}}),[c,g]);return(0,P.useEffect)(()=>{if(!e||i===s)return;let t=new URLSearchParams(n);s?t.set(`queue`,s):t.delete(`queue`),r(t,{replace:!0})},[n,s,i,r,e]),{queue:s,status:o,page:m,view:_,selected:b,setSelected:S,setPage:x,selectQueue:e=>{let t=new URLSearchParams(n);e?t.set(`queue`,e):t.delete(`queue`),r(t,{replace:!0})},selectStatus:e=>{let t=new URLSearchParams(n);e===`all`?t.delete(`status`):t.set(`status`,e),r(t,{replace:!0})}}}function q(){let[e,t]=(0,P.useState)(``),{data:n,error:r,loading:i,refetch:s}=p(()=>a.queuesSummary(),[],{intervalMs:3e4}),{queue:l,status:u,page:d,view:f,selected:m,setSelected:b,setPage:S,selectQueue:T,selectStatus:E}=re(n),{busy:D,exportAll:O}=ne(l,u,e),{data:k,error:A,refetch:j}=p(()=>a.stats(),[],{intervalMs:1e4}),{data:M,error:F,loading:I,refetch:L}=p((0,P.useCallback)(async()=>{if(!l)return{view:f,jobs:[]};let e=u===`all`?void 0:[u],t=await a.jobsList(l,e,25,d*25);return{view:f,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??l}))}},[l,u,d,f]),[l,u,d,f]),V=M?.view===f?M.jobs:null,H=(V?.length??0)===25,U=(0,P.useMemo)(()=>{let t=e.trim().toLowerCase();return t?(V??[]).filter(e=>e.id.toLowerCase().includes(t)||e.name?.toLowerCase().includes(t)):V??[]},[V,e]),W=k?.stats,K=(0,P.useMemo)(()=>n?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[n]),q=W&&K!=null?w(W.completed,K):null,J=e=>W?C(e):`—`,ie=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=U.length>0&&U.every(e=>m.has(e.id)),ae=()=>b(()=>Y?new Set:new Set(U.map(e=>e.id))),{actionMsg:X,bulkBusy:Z,busyIds:oe,runBulk:se,runOne:ce}=te({queue:l,view:f,rows:U,selected:m,setSelected:b,refetch:L}),Q={promote:e=>N(e.state).promote},$=U.filter(e=>m.has(e.id)),le={promote:$.some(Q.promote)};return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(y,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs. Full CSV exports read up to 10,000 live jobs and can reflect concurrent changes.`,live:!!l&&V!=null&&!F&&!r&&!A,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(h,{size:`sm`,disabled:!V||U.length===0,onClick:()=>{if(U.length===0){o.info(`No jobs to export on this page`);return}R(l,u,U)},children:[(0,z.jsx)(c,{className:`size-3.5`}),` Export page CSV`]}),(0,z.jsxs)(h,{size:`sm`,disabled:!l||!V||D,onClick:()=>void O(),title:`Export matching jobs across all pages for this queue and state`,children:[(0,z.jsx)(c,{className:`size-3.5`}),D?`Exporting…`:`Export all matching CSV`]})]})}),r&&(0,z.jsx)(g,{onRetry:s,message:n?`Queue inventory refresh failed — showing the last successful queue totals. ${r.message}`:`Could not discover queues — ${r.message}. Select an existing queue from the URL or retry.`}),A&&(0,z.jsx)(g,{onRetry:j,message:k?`Server-wide totals refresh failed — showing the last successful totals. ${A.message}`:`Server-wide job totals are unavailable — ${A.message}. The selected queue page may still be current.`}),(0,z.jsx)(B,{total:W&&K!=null?C(W.completed+K+W.waiting+W.prioritized+W.active+W.delayed+W[`waiting-children`]):`—`,waiting:J(W?.waiting),prioritized:J(W?.prioritized),active:J(W?.active),flowBlocked:J(W?.[`waiting-children`]),completed:J(W?.completed),failed:K==null?`—`:C(K),failedCount:K,errorRate:q==null?`—`:x(q),errorRateTone:q==null?`default`:q>.05?`red`:`green`}),(0,z.jsx)(ee,{queue:l,summary:n??[],status:u,search:e,selectedTotal:m.size,selectedVisible:$.length,canPromote:le.promote,bulkBusy:Z,onQueue:T,onStatus:E,onSearch:t,onPromote:()=>se(`Promote`,e=>a.promoteJob(e.id),Q.promote)}),X&&(0,z.jsx)(`div`,{role:`status`,className:`mb-3 text-sm ${X.ok?`text-success`:`text-danger`}`,children:X.text}),F&&V&&(0,z.jsx)(g,{message:`Job refresh failed — showing the last successful page.`,onRetry:L}),F&&!V?(0,z.jsx)(_,{error:F,onRetry:L}):i&&!n&&!l&&!r?(0,z.jsx)(v,{label:`Discovering queues…`}):I&&!V?(0,z.jsx)(v,{label:`Loading jobs…`}):(0,z.jsx)(G,{queue:l,rows:U,search:e,discoveryError:!!r,selected:m,allSelected:Y,bulkBusy:Z,busyIds:oe,page:d,hasNext:H,onToggleAll:ae,onToggle:ie,onRun:(e,t,n)=>void ce(e,t,n),onPage:S})]})}export{q as JobsPro};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{T as r,h as i}from"./icons-C1HVBnFn.js";import{t as a}from"./StatusBadge-cYUkK-4P.js";import{n as o}from"./usePolledData-Dp_ynL9f.js";import{i as s,t as c}from"./feedback-Dxfj-Fy1.js";import{t as l}from"./PageHeader-DD4vnVog.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{r as f,t as p}from"./index-CxzFSZj3.js";import{a as m,i as h}from"./form-Dy-an7ew.js";import{t as g}from"./Pagination-Cj7GzYNX.js";import{r as _}from"./classicJobsData-BimIyQky.js";import"./Jobs-D_TId_Oa.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;async function C(){let e=await _();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!Number.isSafeInteger(e.waiting)||e.waiting<0||!Number.isSafeInteger(e.delayed)||e.delayed<0||!Number.isSafeInteger(e.active)||e.active<0||!Number.isSafeInteger(e.dlq)||e.dlq<0||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function w(){let[e,t]=(0,v.useState)(b),[n,_]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O,error:k,refetch:A}=o(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=p(e===b?void 0:e),I=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return j.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[j,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let L=Math.max(1,Math.ceil(I.length/S)),R=Math.min(E,L-1);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(s,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(s,{message:`Event stream unavailable — ${F.message}. Retrying…`}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total Events`,value:d(M.total),compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:d(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:d(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:d(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:d(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Throughput`,value:`${N.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(m,{value:e,"aria-label":`Filter by queue`,name:`classic-activity-queue-filter`,autoComplete:`off`,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(h,{options:x,value:n,onChange:_}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{"aria-label":`Search by job name or ID`,name:`classic-activity-search`,autoComplete:`off`,value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,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`})]})]}),I.length===0?(0,y.jsx)(c,{icon:(0,y.jsx)(i,{}),title:F?`Event stream unavailable`:P?`Waiting for activity…`:`Connecting to the event stream…`,hint:F?`${F.message}. The dashboard is retrying automatically.`:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:I.slice(R*S,R*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(a,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-DfC0iyIS.js";import{o as i}from"./connectionStore-DdLzJyut.js";import{T as a}from"./icons-C1HVBnFn.js";import{t as o}from"./StatusBadge-cYUkK-4P.js";import{n as s}from"./usePolledData-Dp_ynL9f.js";import{t as c}from"./Button-BCjgbAhY.js";import{i as l}from"./feedback-Dxfj-Fy1.js";import{t as u}from"./PageHeader-DD4vnVog.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,r as m,t as h}from"./index-CxzFSZj3.js";import{a as g,i as _}from"./form-Dy-an7ew.js";import{t as v}from"./Pagination-Cj7GzYNX.js";import{t as y}from"./QueueControl-g-9kwrpt.js";var b=e(t(),1),x=r(),S=`__all__`,C=[`all`,`waiting`,`active`,`completed`,`failed`],w=10,T=250;function E(){let[e,t]=(0,b.useState)(S),[r,E]=(0,b.useState)(`all`),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0),[j,M]=(0,b.useState)(null),N=j!==null,P=i(t=>JSON.stringify([t.baseUrl,t.token,e])),{data:F,error:I,refetch:L}=s(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=h(e===S?void 0:e),U=(0,b.useMemo)(()=>{let e=j??R,t=D.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[R,j,r,D]),W=N?Math.max(0,(R[0]?.seq??0)-(j[0]?.seq??0)):0;(0,b.useEffect)(()=>A(0),[e,r,D]),(0,b.useEffect)(()=>M(null),[P]);let G=k*w,K=U.slice(G,G+w);return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:V&&!N}),I&&(0,x.jsx)(l,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(l,{message:`Event stream unavailable — ${H.message}. Retrying…`}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,x.jsx)(m,{label:`Total Events`,value:f(z.total),compact:!0}),(0,x.jsx)(m,{label:`Completed`,value:f(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(m,{label:`Failed`,value:f(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(m,{label:`Waiting`,value:f(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(m,{label:`Active`,value:f(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(m,{label:`Throughput`,value:`${B.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(g,{"aria-label":`Filter by queue`,name:`activity-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),children:[(0,x.jsx)(`option`,{value:S,children:`All Queues`}),(F?.queues??[]).map(e=>(0,x.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,x.jsx)(_,{options:C,value:r,onChange:E}),(0,x.jsx)(c,{size:`sm`,variant:N?`warning`:`default`,onClick:()=>M(N?null:R),title:N?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:N?`Resume${W?` — ${f(W)} new`:``}`:`Following · Pause`}),(0,x.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,x.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{"aria-label":`Search by job ID or queue`,name:`activity-search`,autoComplete:`off`,value:D,onChange:e=>O(e.target.value),placeholder:`Search by job ID or queue…`,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,x.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,T,` streamed events held in this browser.`]}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,x.jsx)(`tbody`,{children:K.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:H?`Event stream unavailable — ${H.message}. Retrying…`:V?R.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):K.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(o,{status:e.status})}),(0,x.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:d(e.timestamp)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,x.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,x.jsx)(p,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,x.jsx)(v,{page:k,pageSize:w,total:U.length,onPageChange:A,label:`events`})]})}export{E as LogsPro};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-DfC0iyIS.js";import{t}from"./api-Bbo86MB6.js";import{n}from"./usePolledData-Dp_ynL9f.js";import{n as r,t as i}from"./Card-DptfvL2O.js";import{i as a,n as o,r as s}from"./feedback-Dxfj-Fy1.js";import{t as c}from"./PageHeader-DD4vnVog.js";import{n as l,s as u}from"./format-Cg7VCIZW.js";import{r as d}from"./index-CxzFSZj3.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 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{t as r}from"./bq-CSX8DSME.js";import{r as i}from"./StatusBadge-cYUkK-4P.js";import{n as a}from"./usePolledData-Dp_ynL9f.js";import{n as o,t as s}from"./Card-DptfvL2O.js";import{i as c,r as l,t as u}from"./feedback-Dxfj-Fy1.js";import{t as d}from"./PageHeader-DD4vnVog.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{r as _}from"./index-CxzFSZj3.js";import{t as v}from"./Pagination-Cj7GzYNX.js";import{t as y}from"./AreaChart-BMYp7z5y.js";import{n as b,t as x}from"./useThroughputSeries-CrTeR9s3.js";var S=e(t(),1),C=n();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:t,danger:n,success:r}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:i(`text-3xl font-bold tnum`,n?`text-danger`:r?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:t})]})}function E({color:e,label:t,value:n}){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:i(`size-2 rounded-full`,e)}),t]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:n})]})}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(t=>{let n=e?.percentiles?.[t],r=e?.averages?.[`${t}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:t}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(n?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(n?.p95)}),(0,C.jsx)(`td`,{className:i(`px-5 py-3 text-right tnum`,(n?.p99??0)>O?`text-warning`:`text-muted`),children:j(n?.p99)})]},t)})})]})})]})}function A({rows:e,total:t,page:n,pageSize:r,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:i(`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:n,pageSize:r,total:t,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 t=e.latest?.throughput,n=x(e.depth),r=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)`})]}),t&&(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:t.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:t.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:t.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:r==null?`—`:m(r)}),(0,C.jsx)(`div`,{className:i(`text-xs font-medium`,n.label===`draining`?`text-success`:n.label===`accumulating`?`text-danger`:`text-faint`),children:r==null?`unavailable`:n.label===`steady`?`steady`:`${n.slope>0?`+`:``}${n.slope.toFixed(1)}/s · ${n.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:n.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,I=[];function L(){let e=b(60),[t,n]=(0,S.useState)(0),{data:i,error:o,loading:s,refetch:l}=a(async()=>({details:await r.queuesSummary()}),[]),u=i?.details??I,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)(()=>i?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[i,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!i&&!o,j=!!e.latest&&!e.error&&!!i&&!o,M=o&&!i?`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{L as MetricsPro};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-DfC0iyIS.js";import{A as t,c as n}from"./icons-C1HVBnFn.js";import{t as r}from"./api-Bbo86MB6.js";import{n as i}from"./usePolledData-Dp_ynL9f.js";import{n as a,t as o}from"./Card-DptfvL2O.js";import{i as s,n as c,r as l}from"./feedback-Dxfj-Fy1.js";import{t as u}from"./PageHeader-DD4vnVog.js";import{c as d,n as f,s as p,t as m,u as h}from"./format-Cg7VCIZW.js";import{r as g}from"./index-CxzFSZj3.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 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-DfC0iyIS.js";import{n as t}from"./StatusBadge-cYUkK-4P.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 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-DfC0iyIS.js";import{t as i}from"./bq-CSX8DSME.js";import{n as a}from"./StatusBadge-cYUkK-4P.js";import{n as o}from"./usePolledData-Dp_ynL9f.js";import{t as s}from"./Button-BCjgbAhY.js";import{n as c,t as l}from"./Card-DptfvL2O.js";import{i as u,n as d,r as f}from"./feedback-Dxfj-Fy1.js";import{t as p}from"./PageHeader-DD4vnVog.js";import{s as m}from"./format-Cg7VCIZW.js";import{r as h}from"./index-CxzFSZj3.js";import{a as g,n as _,t as v}from"./form-Dy-an7ew.js";import{r as y}from"./useServerActionGuard-Cr4KUOeZ.js";import{t as b}from"./controlConnectionEpoch-D4HtriLM.js";import{t as x}from"./useControlActionGuard-DImMgJtj.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./QueueActions-BgdW95rN.js";var k=e(t(),1),A={limits:async(e,t)=>F(await i.queueOperations.limits(e,t)),group:async(e,t,n,r,a,o)=>j(await i.queueOperations.group(e,t,n,r,a,o)),pauseGroup:async(e,t)=>N(await i.queueOperations.pauseGroup(e,t)),resumeGroup:async(e,t)=>N(await i.queueOperations.resumeGroup(e,t)),setGroupRateLimit:async(e,t,n,r)=>{P(await i.queueOperations.setGroupRateLimit(e,t,n,r))},removeGroupRateLimit:async(e,t)=>L(await i.queueOperations.removeGroupRateLimit(e,t)),setGroupConcurrency:async(e,t,n)=>{P(await i.queueOperations.setGroupConcurrency(e,t,n))},removeGroupConcurrency:async(e,t)=>L(await i.queueOperations.removeGroupConcurrency(e,t)),deduplicationJobId:async(e,t)=>I(await i.queueOperations.deduplicationJobId(e,t)),removeDeduplicationKey:async(e,t)=>L(await i.queueOperations.removeDeduplicationKey(e,t)),metrics:async(e,t,n,r)=>ee(await i.queueOperations.metrics(e,t,n,r)),trimEvents:async(e,t)=>L(await i.queueOperations.trimEvents(e,t))};function j(e){let t=z(R(e,`Queue group`).group,`Queue group`),n=t.rateLimit,r=t.entries,i=t.priorityCounts;if(!H(t.jobs,0)||!H(t.active,0)||!H(t.totalGrouped,0)||typeof t.paused!=`boolean`||!Array.isArray(r)||r.length>100||!r.every(M)||!B(i)||!Object.entries(i).every(([e,t])=>/^\d+$/.test(e)&&Number(e)<=2097151&&H(t,0))||n!==null&&(!B(n)||!V(n.max)||!V(n.duration))||!H(t.rateLimitTtl,-2)||t.concurrency!==null&&!V(t.concurrency))throw U(`Queue group`);return t}function M(e){return B(e)?typeof e.id==`string`&&e.id.length>0&&typeof e.name==`string`&&e.name.length>0&&H(e.priority,0)&&e.priority<=2097151&&H(e.delay,0)&&H(e.timestamp,0):!1}function N(e){let t=R(e,`Queue group mutation`).changed;if(typeof t!=`boolean`)throw U(`Queue group mutation`);return t}function P(e){if(R(e,`Queue mutation`).applied!==!0)throw U(`Queue mutation`)}function F(e){let t=z(R(e,`Queue limits`).limits,`Queue limits`),n=t.rateLimit;if(n!==null&&(!B(n)||!V(n.max)||!V(n.duration))||t.concurrency!==null&&!V(t.concurrency)||!H(t.rateLimitTtl,-2)||typeof t.maxed!=`boolean`)throw U(`Queue limits`);return{rateLimit:n,concurrency:t.concurrency,rateLimitTtl:t.rateLimitTtl,maxed:t.maxed}}function I(e){let t=R(e,`deduplication lookup`).jobId;if(t!==null&&(typeof t!=`string`||!t))throw U(`deduplication lookup`);return t}function L(e){let t=R(e,`Queue mutation`).removed;if(!H(t,0))throw U(`Queue mutation`);return t}function ee(e){let t=z(R(e,`Queue metrics`).metrics,`Queue metrics`),n=z(t.meta,`Queue metrics`);if(!H(n.count,0)||!H(n.prevTS,0)||!H(n.prevCount,0)||!H(t.count,0)||!Array.isArray(t.data)||t.data.length>10001||!t.data.every(e=>H(e,0)))throw U(`Queue metrics`);return t}function R(e,t){let n=z(e,t);if(n.ok!==!0)throw U(t);return n}function z(e,t){if(!B(e))throw U(t);return e}function B(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var V=e=>H(e,1),H=(e,t)=>Number.isSafeInteger(e)&&e>=t,U=e=>Error(`Malformed ${e} response`),W=r();function te({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(``),[o,c]=(0,k.useState)(),[l,u]=(0,k.useState)(``),d=i.length>0&&i.length<=1024;return(0,W.jsxs)(`section`,{"aria-labelledby":`queue-dedup-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,W.jsx)(`h3`,{id:`queue-dedup-title`,className:`text-sm font-semibold text-fg`,children:`Deduplication registry`}),(0,W.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,W.jsx)(v,{label:`Deduplication ID`,children:(0,W.jsx)(_,{name:`queue-sdk-deduplication-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:i,onChange:e=>{a(e.target.value),c(void 0),u(``)}})}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsx)(s,{size:`sm`,disabled:!d||!!n,onClick:()=>r(`Looking up deduplication key`,()=>t.deduplicationJobId(e,i),c),children:`Find owner`}),(0,W.jsx)(s,{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`})]}),o!==void 0&&(0,W.jsx)(`p`,{role:`status`,className:`mt-3 break-all text-xs text-muted`,children:o===null?`No active owner.`:`Current job: ${o}`}),l&&(0,W.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l})]})}function ne({snapshot:e}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 rounded-lg border border-line p-3 text-xs sm:grid-cols-4 xl:grid-cols-7`,children:[(0,W.jsx)(G,{label:`Jobs`,value:e.jobs}),(0,W.jsx)(G,{label:`Active`,value:e.active}),(0,W.jsx)(G,{label:`All grouped`,value:e.totalGrouped}),(0,W.jsx)(G,{label:`Rate`,value:e.rateLimit?`${e.rateLimit.max}/${e.rateLimit.duration}ms`:`None`}),(0,W.jsx)(G,{label:`TTL`,value:`${e.rateLimitTtl} ms`}),(0,W.jsx)(G,{label:`Concurrency`,value:e.concurrency??`None`}),(0,W.jsx)(G,{label:`Paused`,value:e.paused?`Yes`:`No`}),(0,W.jsx)(G,{label:`Priority counts`,value:re(e.priorityCounts)})]}),(0,W.jsx)(`div`,{className:`mt-3 overflow-x-auto rounded-lg border border-line`,children:(0,W.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,W.jsx)(`thead`,{className:`border-b border-line text-faint`,children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Pending group job`}),(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Name`}),(0,W.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Priority`}),(0,W.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Delay`})]})}),(0,W.jsx)(`tbody`,{children:e.entries.length===0?(0,W.jsx)(`tr`,{children:(0,W.jsx)(`td`,{colSpan:4,className:`px-3 py-4 text-center text-faint`,children:`No pending jobs in this page.`})}):e.entries.map(e=>(0,W.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,W.jsx)(`td`,{className:`px-3 py-2 font-mono`,children:(0,W.jsx)(n,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect grouped job ${e.id}`,className:`text-accent hover:underline`,children:e.id})}),(0,W.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,W.jsx)(`td`,{className:`px-3 py-2 text-right font-mono`,children:e.priority}),(0,W.jsxs)(`td`,{className:`px-3 py-2 text-right font-mono`,children:[e.delay,` ms`]})]},e.id))})]})})]})}function G({label:e,value:t}){return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`mt-1 font-mono text-fg`,children:t})]})}var re=e=>{let t=Object.entries(e).sort(([e],[t])=>Number(e)-Number(t));return t.length?t.map(([e,t])=>`${e}: ${t}`).join(` · `):`None`};function ie({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(`default`),[o,c]=(0,k.useState)(``),[l,u]=(0,k.useState)(`100`),[d,f]=(0,k.useState)(`0`),[p,m]=(0,k.useState)(`24`),[h,g]=(0,k.useState)(`100`),[y,b]=(0,k.useState)(`60000`),[x,S]=(0,k.useState)(`1`),[C,w]=(0,k.useState)(null),T=ae(i),E=C?.groupId===i?C.snapshot:null,D=e=>w({groupId:i,snapshot:e}),O=oe(d,p),A=K(h),j=K(y),M=A!==null&&j!==null,N=K(x),P=()=>{let n=q(o,0),i=q(l,1);!T||n===null||i===null||!O||r(`Reading group`,()=>t.group(e,T,n,i,O.start,O.end),D)},F=()=>{let n=K(h),i=K(y);!T||n===null||i===null||r(`Setting group rate limit`,async r=>{if(await t.setGroupRateLimit(e,T,n,i),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0)},I=()=>{let n=K(x);!T||n===null||r(`Setting group concurrency`,async r=>{if(await t.setGroupConcurrency(e,T,n),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0)},L=n=>{T&&r(n?`Pausing group`:`Resuming group`,async r=>{if(n?await t.pauseGroup(e,T):await t.resumeGroup(e,T),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0)};return(0,W.jsxs)(`section`,{className:`xl:col-span-2`,"aria-labelledby":`queue-groups-title`,children:[(0,W.jsx)(`h3`,{id:`queue-groups-title`,className:`mb-3 text-sm font-medium text-fg`,children:`Groups`}),(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4 xl:grid-cols-8`,children:[(0,W.jsx)(v,{label:`Group ID`,children:(0,W.jsx)(_,{value:i,maxLength:256,onChange:e=>{a(e.target.value),w(null)}})}),(0,W.jsx)(v,{label:`TTL maxJobs`,hint:`Optional`,children:(0,W.jsx)(_,{type:`number`,min:0,value:o,onChange:e=>c(e.target.value)})}),(0,W.jsx)(v,{label:`Groups maxCount`,children:(0,W.jsx)(_,{type:`number`,min:1,value:l,onChange:e=>u(e.target.value)})}),(0,W.jsx)(v,{label:`Jobs start`,children:(0,W.jsx)(_,{type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})}),(0,W.jsx)(v,{label:`Jobs end`,hint:`Inclusive; max 100`,children:(0,W.jsx)(_,{type:`number`,min:0,max:1e6,value:p,onChange:e=>m(e.target.value)})}),(0,W.jsx)(v,{label:`Rate max`,children:(0,W.jsx)(_,{type:`number`,min:1,value:h,onChange:e=>g(e.target.value)})}),(0,W.jsx)(v,{label:`Duration (ms)`,children:(0,W.jsx)(_,{type:`number`,min:1,value:y,onChange:e=>b(e.target.value)})}),(0,W.jsx)(v,{label:`Concurrency`,children:(0,W.jsx)(_,{type:`number`,min:1,value:x,onChange:e=>S(e.target.value)})})]}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||!O,onClick:P,children:`Read group`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||!M,onClick:F,children:`Set rate limit`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T,onClick:()=>r(`Clearing group rate limit`,async n=>{if(await t.removeGroupRateLimit(e,T),!n())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0),children:`Clear rate limit`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||N===null,onClick:I,children:`Set concurrency`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||E?.paused===!0,onClick:()=>L(!0),children:`Pause group`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||E?.paused===!1,onClick:()=>L(!1),children:`Resume group`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T,onClick:()=>r(`Clearing group concurrency`,async n=>{if(await t.removeGroupConcurrency(e,T),!n())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0),children:`Clear concurrency`})]}),!T&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group ID must contain 1–256 characters and no NUL.`}),!O&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group job range must be an inclusive page of 1–100 jobs with whole indexes from 0 to 1000000.`}),!M&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Rate max and duration must be positive whole numbers.`}),N===null&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),E&&(0,W.jsx)(ne,{snapshot:E})]})}var ae=e=>e.length>=1&&e.length<=256&&!e.includes(`\0`)?e:null,K=e=>{let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},q=(e,t)=>{if(!e.trim())return;let n=Number(e);return Number.isSafeInteger(n)&&n>=t?n:null},oe=(e,t)=>{let n=q(e,0),r=q(t,0);return n!=null&&n<=1e6&&r!=null&&r<=1e6&&r>=n&&r-n<100?{start:n,end:r}:null};function se({snapshot:e,loading:t,error:n}){if(t&&!e)return(0,W.jsx)(`p`,{className:`text-sm text-muted`,children:`Reading broker limit state...`});if(n&&!e)return(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n});if(!e)return null;let r=e.rateLimit;return(0,W.jsxs)(`div`,{children:[n&&(0,W.jsxs)(`p`,{role:`alert`,className:`mb-3 text-xs text-warning`,children:[`Refresh failed. Showing the last successful limit snapshot: `,n]}),(0,W.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,W.jsx)(J,{label:`Global rate limit`,value:r?`${r.max} / ${r.duration} ms`:`Not configured`}),(0,W.jsx)(J,{label:`Rate-limit TTL`,value:e.rateLimitTtl===-2?`No active limit`:`${e.rateLimitTtl} ms`}),(0,W.jsx)(J,{label:`Global concurrency`,value:e.concurrency===null?`Not configured`:String(e.concurrency)}),(0,W.jsx)(J,{label:`Capacity`,value:e.maxed?`Maxed`:`Available`})]})]})}function J({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`min-w-0 border-l-2 border-line pl-3`,children:[(0,W.jsx)(`dt`,{className:`text-[11px] font-medium text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`mt-1 break-words font-mono text-sm text-fg`,children:t})]})}function ce({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(`completed`),[o,c]=(0,k.useState)(`0`),[l,u]=(0,k.useState)(`29`),[d,f]=(0,k.useState)(`1000`),[p,m]=(0,k.useState)(null),[h,y]=(0,k.useState)(``),b=ue(o,l),x=Y(d,0,1e6);return(0,W.jsxs)(`section`,{"aria-labelledby":`queue-telemetry-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,W.jsx)(`h3`,{id:`queue-telemetry-title`,className:`text-sm font-semibold text-fg`,children:`Durable queue telemetry`}),(0,W.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,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsx)(v,{label:`Metric`,children:(0,W.jsxs)(g,{name:`queue-sdk-metric-type`,value:i,onChange:e=>a(e.target.value),children:[(0,W.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,W.jsx)(`option`,{value:`failed`,children:`Failed`})]})}),(0,W.jsx)(v,{label:`Start bucket`,children:(0,W.jsx)(_,{name:`queue-sdk-metric-start`,type:`number`,min:0,max:1e4,value:o,onChange:e=>c(e.target.value)})}),(0,W.jsx)(v,{label:`End bucket`,hint:`Use -1 for all remaining buckets`,children:(0,W.jsx)(_,{name:`queue-sdk-metric-end`,type:`number`,min:-1,max:1e4,value:l,onChange:e=>u(e.target.value)})})]}),(0,W.jsx)(s,{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,W.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,W.jsx)(le,{metrics:p}),(0,W.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end gap-3 border-t border-line pt-4`,children:[(0,W.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,W.jsx)(v,{label:`Retain lifecycle events`,hint:`0 clears the queue journal`,children:(0,W.jsx)(_,{name:`queue-sdk-event-retention`,type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})})}),(0,W.jsx)(s,{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`})]}),h&&(0,W.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:h})]})}function le({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,W.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-2 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 font-mono text-xs text-muted`,children:[(0,W.jsxs)(`span`,{children:[`Total terminal: `,e.meta.count]}),(0,W.jsxs)(`span`,{children:[`Available buckets: `,e.count]}),(0,W.jsxs)(`span`,{children:[`Latest bucket: `,e.meta.prevCount]})]}),t.length?(0,W.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,W.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,W.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`No buckets in this range.`}),e.data.length>t.length&&(0,W.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Showing the first 120 returned buckets.`})]})}function ue(e,t){let n=Y(e,0,1e4),r=Y(t,-1,1e4);return n===null||r===null||r!==-1&&r<n?null:{start:n,end:r}}function Y(e,t,n){if(e.trim()===``)return null;let r=Number(e);return Number.isSafeInteger(r)&&r>=t&&r<=n?r:null}function de({queue:e,refreshKey:t=0,repository:n=A,onApplied:r}){let i=x(`queue-operations:${e}`),[a,o]=(0,k.useState)(``),[u,d]=(0,k.useState)(null),[f,p]=(0,k.useState)(``),[m,h]=(0,k.useState)(``),g=(0,k.useRef)(!1),y=(0,k.useRef)(0),S=(0,k.useRef)(!0),C=u?.queue===e?u:{queue:e,snapshot:null,loading:!0,error:``};(0,k.useEffect)(()=>(S.current=!0,()=>{S.current=!1,y.current+=1}),[]),(0,k.useEffect)(()=>{y.current+=1,g.current=!1,d(null),p(``),h(``)},[i.scopeKey]);let w=(0,k.useCallback)(async()=>{let t=fe(a);if(t===null){d(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=++y.current,i=b();d(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!0,error:``}));try{let a=await n.limits(e,t);S.current&&r===y.current&&i===b()&&d({queue:e,snapshot:a,loading:!1,error:``})}catch(t){S.current&&r===y.current&&i===b()&&d({queue:e,snapshot:null,loading:!1,error:pe(t)})}},[a,e,n]);(0,k.useEffect)(()=>void w(),[e,t]);let T=(e,t,n,a=!1)=>{if(g.current)return;let o=i.begin(`queue-sdk-command`);o&&(g.current=!0,p(e),h(``),t(o.isCurrent).then(e=>{!S.current||!o.isCurrent()||(n(e),a&&(r?.(),r||w()))}).catch(e=>{S.current&&o.isCurrent()&&h(pe(e))}).finally(()=>{let e=o.finish();S.current&&e&&(g.current=!1,p(``))}))};return(0,W.jsxs)(l,{className:`mb-6`,children:[(0,W.jsx)(c,{title:`Queue SDK operations`,action:f?(0,W.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[f,`...`]}):void 0}),(0,W.jsx)(`p`,{className:`mb-5 max-w-3xl text-xs leading-5 text-faint`,children:`Live Bunqueue 2.9.3 limit, group, deduplication, metric, and event-journal contracts, including group pause, pending jobs, and priority counts. Requests are pinned to the server managed by this control agent.`}),(0,W.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-end gap-3 border-b border-line pb-5`,children:[(0,W.jsx)(`div`,{className:`w-48`,children:(0,W.jsx)(v,{label:`TTL threshold (maxJobs)`,hint:`Optional token-consumption threshold`,children:(0,W.jsx)(_,{name:`queue-sdk-max-jobs`,type:`number`,min:0,max:1e6,step:1,value:a,onChange:e=>o(e.target.value),placeholder:`Not set`})})}),(0,W.jsx)(s,{size:`sm`,disabled:C.loading||!!f,onClick:w,children:`Refresh limits`})]}),(0,W.jsx)(se,{snapshot:C.snapshot,loading:C.loading,error:C.error}),m&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:m}),(0,W.jsxs)(`div`,{className:`mt-6 grid gap-6 xl:grid-cols-[0.8fr_1.2fr]`,children:[(0,W.jsx)(ie,{queue:e,repository:n,busy:f,run:T},`${e}:groups`),(0,W.jsx)(te,{queue:e,repository:n,busy:f,run:T},`${e}:deduplication`),(0,W.jsx)(ce,{queue:e,repository:n,busy:f,run:T},`${e}:telemetry`)]})]})}function fe(e){if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<=1e6?t:null}var pe=e=>e instanceof Error?e.message:String(e),me=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],X=500,Z=200,he=X*Z;function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ge(e){return Q(e)&&me.every(t=>$(e[t]))}function _e(e,t){if(!Q(e)||e.ok!==!0||!Array.isArray(e.queues)||!$(e.total)||!$(e.limit)||e.limit<1||!$(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>Q(e)&&typeof e.name==`string`&&e.name.length>0&&$(e.waiting)&&$(e.delayed)&&$(e.active)&&$(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function ve(){let e=await i.queues(X,0);_e(e,0);let t=e.total;if(t>he)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${he}.`);if(e.queues.length!==Math.min(X,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(X,t)} queues, received ${e.queues.length}.`);let n=new Map,r=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)}};r(e);let a=e.queues.length,o=1;for(;a<t;){if(o>=Z)throw Error(`Queue discovery exceeded the safe limit of ${Z} pages.`);let e=await i.queues(X,a);if(_e(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(X,t-a);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${a}: expected ${n} queues, received ${e.queues.length}.`);r(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:X,offset:0}}function ye(e,t){if(!Q(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!ge(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function be(e){if(!Q(e)||e.ok!==!0||!D(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function xe(e){if(!Q(e)||e.ok!==!0||!T(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function Se(e){if(!Q(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!$(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 we(){let[e,t]=(0,k.useState)(``),[n,r]=(0,k.useState)(!1),[s,c]=(0,k.useState)(0),[l,_]=(0,k.useState)(null),v=y(`queue-control:${e}`);(0,k.useEffect)(()=>{r(!1),_(null)},[v.scopeKey]);let{data:b,error:x,loading:T,refetch:D}=o(ve,[],{intervalMs:3e4});(0,k.useEffect)(()=>{b&&t(e=>Ce(e,b.queues))},[b]);let{data:A,error:j,loading:M,refetch:N}=o((0,k.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([i.queueDetail(e,!1),i.getStallConfig(e).then(be).catch(()=>null),i.getDlqConfig(e).then(xe).catch(()=>null)]);return ye(t,e),{queue:e,detail:t,stall:n,dlq:r}},[e]),[e]),P=!b||b.queues.some(t=>t.name===e),F=A?.queue===e&&P?A:null,I=(t,n,a,o)=>{let s=e;if(!s||a&&!window.confirm(a))return;let l=v.begin(`queue-write`);l&&(r(!0),_(null),(async()=>{try{let e=await i.queuesSummary();if(!l.isCurrent())return;if(!e.some(e=>e.name===s))throw Error(`Queue "${s}" no longer exists`);let r=Se(await n());if(!l.isCurrent())return;_({queue:s,ok:!0,text:`${t}${r==null?` ✓`:`: ${r}`}`}),o?.(),c(e=>e+1),await N()}catch(e){l.isCurrent()&&_({queue:s,ok:!1,text:e.message})}finally{l.finish()&&r(!1)}})())};return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(p,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!F?.detail&&!!F.stall&&!!F.dlq&&!j&&!x}),(0,W.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`w-56`,children:(0,W.jsx)(g,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(b?.queues??[]).map(e=>(0,W.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),F?.detail&&(0,W.jsx)(a,{label:F.detail.paused?`Paused`:`Active`,tone:F.detail.paused?`amber`:`green`}),l?.queue===e&&(0,W.jsx)(`span`,{role:`status`,className:l.ok?`text-xs text-success`:`text-xs text-danger`,children:l.text})]}),x&&(0,W.jsx)(u,{onRetry:D,message:`Could not discover queues — ${x.message}. Retry to choose a queue.`}),j&&F&&(0,W.jsx)(u,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:N}),j&&!F?(0,W.jsx)(d,{error:j,onRetry:N}):T&&!b&&!e&&!x?(0,W.jsx)(f,{label:`Discovering queues…`}):M&&!F?(0,W.jsx)(f,{}):x&&!e?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):F?.detail?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:me.map(e=>(0,W.jsx)(h,{label:e,value:m(F.detail.counts[e]),compact:!0},e))}),(0,W.jsx)(w,{queue:e,paused:F.detail.paused,busy:n,run:I},`${e}:lifecycle`),(0,W.jsx)(O,{queue:e,busy:n,run:I},`${e}:limits`),(0,W.jsx)(de,{queue:e,refreshKey:s,onApplied:()=>c(e=>e+1)},`${v.scopeKey}:${e}:sdk-operations`),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[F.stall?(0,W.jsx)(C,{queue:e,config:F.stall,onSaved:async()=>{_({queue:e,ok:!0,text:`Stall config saved ✓`}),await N()}},`${e}:stall`):(0,W.jsx)(E,{title:`Stall detection`,onRetry:N}),F.dlq?(0,W.jsx)(S,{queue:e,config:F.dlq,onSaved:async()=>{_({queue:e,ok:!0,text:`DLQ config saved ✓`}),await N()}},`${e}:dlq`):(0,W.jsx)(E,{title:`DLQ policy`,onRetry:N})]})]}):!j&&(0,W.jsx)(`p`,{className:`text-sm text-faint`,children:b?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{we as QueueControl,ve as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,g as n,r,t as i}from"./react-vendor-DfC0iyIS.js";import{t as a}from"./bq-CSX8DSME.js";import{A as o,b as s,i as c,m as l,n as u,x as d}from"./icons-C1HVBnFn.js";import{n as f,t as p}from"./StatusBadge-cYUkK-4P.js";import{t as m}from"./api-Bbo86MB6.js";import{n as h}from"./usePolledData-Dp_ynL9f.js";import{t as g}from"./Button-BCjgbAhY.js";import{t as _}from"./Card-DptfvL2O.js";import{i as v,r as y,t as b}from"./feedback-Dxfj-Fy1.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{r as D}from"./index-CxzFSZj3.js";import{a as O,n as k,t as A}from"./form-Dy-an7ew.js";import{r as j,t as M}from"./useServerActionGuard-Cr4KUOeZ.js";import{r as N}from"./flowMutationSafety-YKTHxqKv.js";import{i as P}from"./classicJobsData-BimIyQky.js";var F=e(n(),1),I=i();function L({queue:e}){return(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,I.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.9.3 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,I.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,I.jsx)(B,{queue:e}),(0,I.jsx)(V,{queue:e})]})]})}function R(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function z(e,t){let[n,r]=(0,F.useState)(!1),[i,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(null),l=j(`classic-queue-policy:${e}:${t}`);return(0,F.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 B({queue:e}){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(``),[o,s]=(0,F.useState)(`permanent`),[c,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(``),{busy:p,error:m,receipt:h,run:v}=z(e,`rate-limit`),y=R(t),b=R(r),x=o===`expires`?R(c):void 0,S=y!==null&&b!==null&&(o===`permanent`||x!=null);return(0,I.jsxs)(_,{children:[(0,I.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,I.jsx)(l,{className:`size-4 text-faint`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,I.jsx)(A,{label:`Limit`,children:(0,I.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,I.jsx)(A,{label:`Window (ms)`,children:(0,I.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,I.jsx)(A,{label:`TTL`,children:(0,I.jsxs)(O,{name:`classic-rate-ttl-mode`,value:o,onChange:e=>s(e.target.value),children:[(0,I.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,I.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,I.jsx)(A,{label:`TTL (ms)`,hint:o===`permanent`?`Not sent`:void 0,children:(0,I.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,I.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,I.jsx)(g,{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,I.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,I.jsx)(A,{label:`Type ${e} to clear`,children:(0,I.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,I.jsx)(g,{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`})]}),h&&(0,I.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:h}),m&&(0,I.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:m})]})}function V({queue:e}){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(``),{busy:s,error:c,receipt:l,run:u}=z(e,`concurrency`),d=R(t);return(0,I.jsxs)(_,{children:[(0,I.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,I.jsx)(o,{className:`size-4 text-faint`})]}),(0,I.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,I.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,I.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,I.jsx)(g,{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,I.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,I.jsx)(A,{label:`Type ${e} to clear`,children:(0,I.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,I.jsx)(g,{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,I.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l}),c&&(0,I.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c})]})}var H=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],U={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 W(){let{name:e=``}=t(),[n,i]=(0,F.useState)(null),[o,l]=(0,F.useState)(null),_=j(`classic-queue:${e}`);(0,F.useEffect)(()=>{i(null),l(null)},[_.scopeKey]);let{data:O,error:k,loading:A,refetch:R}=h((0,F.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([m.queueDetail(e,!1),m.jobsList(e,{states:H,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]),z=async(t,n,r)=>{if(r&&!window.confirm(r))return;let o=_.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 R()}catch(e){o.isCurrent()&&l(e.message)}finally{o.finish()&&i(null)}}};if(A&&!O&&!k)return(0,I.jsx)(y,{label:`Loading ${e}…`});if(k&&!O)return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,I.jsx)(v,{onRetry:R})]});if(O?.exists===!1)return(0,I.jsxs)(`div`,{children:[k&&(0,I.jsx)(v,{onRetry:R}),(0,I.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,I.jsx)(b,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,I.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 B=O?.exists===!0?O:U,{detail:V}=B,W=V.counts,G=E(W.completed??0,W.failed??0),K=[...B.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,I.jsxs)(`div`,{children:[k&&(0,I.jsx)(v,{onRetry:R}),(0,I.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.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,I.jsx)(c,{className:`size-4`})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,I.jsx)(f,{label:V.paused?`Paused`:`Active`,tone:V.paused?`amber`:`green`}),(0,I.jsx)(f,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[V.paused?(0,I.jsxs)(g,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>z(`resume`,()=>m.resume(e)),children:[(0,I.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,I.jsxs)(g,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>z(`pause`,()=>m.pause(e)),children:[(0,I.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,I.jsx)(g,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,I.jsx)(g,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),o&&(0,I.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,I.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,I.jsx)(D,{label:`Waiting`,value:T(W.waiting),tone:`amber`}),(0,I.jsx)(D,{label:`Active`,value:T(W.active),tone:`blue`}),(0,I.jsx)(D,{label:`Completed`,value:T(W.completed),tone:`green`}),(0,I.jsx)(D,{label:`Failed`,value:T(W.failed),tone:W.failed?`red`:`default`}),(0,I.jsx)(D,{label:`Delayed`,value:T(W.delayed),tone:`default`}),(0,I.jsx)(D,{label:`Error Rate`,value:G==null?`—`:S(G),tone:G==null?`default`:G>.05?`red`:`green`})]}),(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,I.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,I.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,I.jsx)(u,{className:`size-3.5`})]})]}),(0,I.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,I.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,I.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,I.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,I.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,I.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,I.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,I.jsx)(`tbody`,{children:B.recentJobsError?(0,I.jsx)(`tr`,{children:(0,I.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,B.recentJobsError,`. Retry the page.`]})}):K.length===0?(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):K.map(e=>(0,I.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,I.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,I.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,I.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??P(e.data)??`default`}),(0,I.jsx)(`td`,{className:`px-5 py-3`,children:(0,I.jsx)(p,{status:String(e.state??e.status??`waiting`)})}),(0,I.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:x(C(e.startedAt,e.completedAt))}),(0,I.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,I.jsx)(L,{queue:e})]})}export{W as QueueDetail};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,g as n,r,t as i}from"./react-vendor-DfC0iyIS.js";import{t as a}from"./bq-CSX8DSME.js";import{t as o}from"./toastStore-DnqA_aL-.js";import{i as s,n as c}from"./icons-C1HVBnFn.js";import{n as l,r as u}from"./StatusBadge-cYUkK-4P.js";import{n as d}from"./usePolledData-Dp_ynL9f.js";import{t as f}from"./Button-BCjgbAhY.js";import{n as p,t as m}from"./Card-DptfvL2O.js";import{i as h,n as g,r as _,t as v}from"./feedback-Dxfj-Fy1.js";import{t as y}from"./PageHeader-DD4vnVog.js";import{a as b,c as x,s as S,t as C}from"./format-Cg7VCIZW.js";import{r as w}from"./index-CxzFSZj3.js";import{r as T,t as E}from"./useServerActionGuard-Cr4KUOeZ.js";import{r as D}from"./flowMutationSafety-YKTHxqKv.js";import{n as O}from"./controlConnectionEpoch-D4HtriLM.js";import{t as k}from"./AreaChart-BMYp7z5y.js";import{a as A,i as j,n as M,r as N,t as P}from"./QueueActions-BgdW95rN.js";import{t as F}from"./useThroughputSeries-CrTeR9s3.js";var I=e(n(),1),L=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],R=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],z=2e3,B=i();function V({name:e,jobs:t,error:n}){return(0,B.jsxs)(m,{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)(r,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,B.jsx)(c,{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)(r,{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)(m,{className:`mb-6`,children:[(0,B.jsx)(p,{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:t,trend:n,rate:r}){return(0,B.jsxs)(m,{className:`mb-6`,children:[(0,B.jsx)(p,{title:`Backlog depth`,action:(0,B.jsx)(`span`,{className:u(`rounded-full px-2 py-0.5 text-[11px] font-medium`,n.draining?`bg-emerald-500/10 text-success`:n.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:n.label})}),t.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)(k,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:t,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 `,r==null?`—`:x(r)]})]})]})}function W(e,t){let n=`${O()}\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,z)}}function G(){let{name:e=``}=t(),[n,i]=(0,I.useState)(!1),[u,p]=(0,I.useState)(null),m=T(`queue:${e}`);(0,I.useEffect)(()=>{i(!1),p(null)},[m.scopeKey]);let{data:b,error:x,loading:O,refetch:k}=d((0,I.useCallback)(async()=>{if(!e)return null;if(!(await a.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([a.queueDetail(e,!1),a.getStallConfig(e).catch(()=>null),a.getDlqConfig(e).catch(()=>null),a.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,r,s)=>{if(r&&!window.confirm(r))return;let c=m.begin();if(c){i(!0),p(null);try{let r=await a.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}`}`;p({ok:!0,text:u}),o.success(u,e),s?.(),k()}catch(e){if(!c.isCurrent())return;let n=e.message;p({ok:!1,text:n}),o.error(`${t} failed`,n)}finally{c.finish()&&i(!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)(r,{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)(s,{className:`size-4`})}),actions:F?.exists===!0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(r,{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)(c,{className:`size-3.5`})]}),(0,B.jsxs)(r,{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)(c,{className:`size-3.5`})]}),(0,B.jsx)(f,{variant:`danger`,size:`sm`,disabled:!0,title:D,children:`Obliterate`})]}):void 0}),x&&F&&(0,B.jsx)(h,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:k}),x&&!F?(0,B.jsx)(g,{error:x,onRetry:k}):O&&!F?(0,B.jsx)(_,{label:`Loading ${e}…`}):F?.exists===!1||!q||!J?!x&&(0,B.jsx)(v,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,B.jsx)(r,{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)(l,{label:q.paused?`Paused`:`Active`,tone:q.paused?`amber`:`green`}),u&&(0,B.jsx)(`span`,{role:`status`,className:u.ok?`text-xs text-success`:`text-xs text-danger`,children:u.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:n,run:K}),(0,B.jsx)(P,{queue:e,busy:n,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:()=>{p({ok:!0,text:`Stall config saved ✓`}),o.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:()=>{p({ok:!0,text:`DLQ config saved ✓`}),o.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,B.jsx)(N,{title:`DLQ policy`,onRetry:k})]})]})]})}export{G as QueueDetailPro};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-DfC0iyIS.js";import{S as i,T as a,n as o}from"./icons-C1HVBnFn.js";import{r as s}from"./StatusBadge-cYUkK-4P.js";import{t as c}from"./api-Bbo86MB6.js";import{n as l}from"./usePolledData-Dp_ynL9f.js";import{i as u,r as d}from"./feedback-Dxfj-Fy1.js";import{t as f}from"./PageHeader-DD4vnVog.js";import{s as p}from"./format-Cg7VCIZW.js";import{r as m}from"./index-CxzFSZj3.js";import{t as h}from"./Pagination-Cj7GzYNX.js";var g=e(t(),1),_=r(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let[e,t]=(0,g.useState)(``),[r,b]=(0,g.useState)(0),{data:x,error:S,loading:C,refetch:w}=l(()=>c.queues(v,r*v),[r]),{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)(a,{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=>t(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)(n,{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)(i,{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:s(`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:s(`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)(o,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},e.name))})]})}),x&&(0,_.jsx)(h,{page:r,pageSize:v,total:E.total,onPageChange:b,label:`queues`})]})}export{b as Queues};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-DfC0iyIS.js";import{t as i}from"./bq-CSX8DSME.js";import{t as a}from"./toastStore-DnqA_aL-.js";import{S as o,T as s,b as c,n as l,x as u}from"./icons-C1HVBnFn.js";import{r as d}from"./StatusBadge-cYUkK-4P.js";import{n as f}from"./usePolledData-Dp_ynL9f.js";import{n as p,t as m}from"./Button-BCjgbAhY.js";import{i as h,n as g,r as _}from"./feedback-Dxfj-Fy1.js";import{t as v}from"./PageHeader-DD4vnVog.js";import{s as y}from"./format-Cg7VCIZW.js";import{r as b}from"./index-CxzFSZj3.js";import{t as x}from"./Pagination-Cj7GzYNX.js";import{r as S,t as C}from"./useServerActionGuard-Cr4KUOeZ.js";import{t as w}from"./promisePool-BVfQ9n9Q.js";var T=e(t(),1),E=r(),D=[[`waiting`,`Waiting`],[`prioritized`,`Prioritized`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function O({rows:e,hasData:t,error:r,search:i,sortCol:a,sortDir:s,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":a===e?s===`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,a===e&&(0,E.jsx)(`span`,{"aria-hidden":`true`,children:s===`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:!t&&r?(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 — `,r.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:i?`No queues match your search.`:`No queues yet.`})}):e.map(e=>{let t=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)(n,{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)(o,{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:d(`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:d(`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:t,onClick:t=>{t.stopPropagation(),g(e)},children:e.paused?(0,E.jsx)(u,{className:`size-3.5 text-success`}):(0,E.jsx)(c,{className:`size-3.5 text-warning`})}),(0,E.jsx)(l,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},e.name)})})]})})}var k=6,A=15,j=[];function M(){let[e,t]=(0,T.useState)(``),[n,r]=(0,T.useState)(0),[o,l]=(0,T.useState)(new Set),[p,D]=(0,T.useState)(!1),[M,N]=(0,T.useState)(null),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(`desc`),R=S(`queues-overview`);(0,T.useEffect)(()=>{l(new Set),D(!1),N(null)},[R.scopeKey]);let{data:z,error:B,loading:V,refetch:H}=f(()=>i.queuesSummary(),[]),U=z??j,W=e=>{P===e?I===`desc`?L(`asc`):F(null):(F(e),L(`desc`)),r(0)},G=(0,T.useMemo)(()=>{let t=e.trim().toLowerCase(),n=[...t?U.filter(e=>e.name.toLowerCase().includes(t)):U].sort((e,t)=>e.name.localeCompare(t.name));if(P){let e=I===`desc`?-1:1;n.sort((t,n)=>e*(t.counts[P]-n.counts[P]))}return n},[U,e,P,I]),K=(0,T.useMemo)(()=>U.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}),[U]),q=Math.max(1,Math.ceil(G.length/A)),J=Math.min(n,q-1),Y=G.slice(J*A,J*A+A),X=async e=>{let t=R.begin(`queue:${e.name}`);if(t){l(t=>new Set(t).add(e.name)),N(null);try{if(C(await(e.paused?i.resume(e.name):i.pause(e.name)),e.paused?`Resume queue`:`Pause queue`),!t.isCurrent())return;N({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`}),H()}catch(n){if(!t.isCurrent())return;N({ok:!1,text:n.message}),a.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,n.message)}finally{t.finish()&&l(t=>{let n=new Set(t);return n.delete(e.name),n})}}},Z=async e=>{let t=U.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){a.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;let n=R.begin([`bulk`,...U.map(e=>`queue:${e.name}`)]);if(n){D(!0),N(null);try{let r=await w(t,k,async t=>{if(!n.isCurrent())throw Error(`Queue action target changed`);C(e===`pause`?await i.pause(t.name):await i.resume(t.name),`${e===`pause`?`Pause`:`Resume`} ${t.name}`)});if(!n.isCurrent())return;let o=r.filter(e=>e.status===`rejected`).length,s=`${e===`pause`?`Paused`:`Resumed`} ${t.length-o}/${t.length} queues${o?`, ${o} failed`:``}`;N({ok:o===0,text:s}),o===0?a.success(s):a.error(s),H()}finally{n.finish()&&D(!1)}}};return V&&!z&&!B?(0,E.jsx)(_,{label:`Loading queues…`}):B&&!z?(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:`Queue inventory unavailable`}),(0,E.jsx)(g,{error:B,onRetry:H})]}):(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:z?`${U.length} queues`:`Queue inventory unavailable`,live:!!z&&!B,actions:U.length>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m,{variant:`warning`,size:`sm`,disabled:p||o.size>0||K.paused>=U.length,onClick:()=>Z(`pause`),children:[(0,E.jsx)(c,{className:`size-3.5`}),` Pause all`]}),(0,E.jsxs)(m,{variant:`success`,size:`sm`,disabled:p||o.size>0||K.paused===0,onClick:()=>Z(`resume`),children:[(0,E.jsx)(u,{className:`size-3.5`}),` Resume all`]})]}):void 0}),B&&(0,E.jsx)(h,{message:`Queue refresh failed — showing the last successful inventory.`,onRetry:H}),(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(K.waiting),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Prioritized`,value:y(K.prioritized),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Active`,value:y(K.active),tone:`blue`,compact:!0}),(0,E.jsx)(b,{label:`Failed`,value:y(K.failed),tone:K.failed?`red`:`default`,compact:!0}),(0,E.jsx)(b,{label:`Paused`,value:y(K.paused),tone:K.paused?`amber`:`default`,compact:!0})]}),(0,E.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,E.jsx)(s,{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=>{t(e.target.value),r(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`})]}),M&&(0,E.jsx)(`div`,{role:`status`,className:d(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),(0,E.jsx)(O,{rows:Y,hasData:!!z,error:B,search:e,sortCol:P,sortDir:I,bulkBusy:p,busy:o,onSort:W,onToggle:e=>void X(e)}),(0,E.jsx)(x,{page:J,pageSize:A,total:G.length,onPageChange:r,label:`queues`})]})}export{M as QueuesOverview};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-DfC0iyIS.js";import{t}from"./api-Bbo86MB6.js";import{n}from"./usePolledData-Dp_ynL9f.js";import{n as r,t as i}from"./Card-DptfvL2O.js";import{i as a,n as o,r as s}from"./feedback-Dxfj-Fy1.js";import{t as c}from"./PageHeader-DD4vnVog.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};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{a as r,f as i,m as a,o,p as s}from"./connectionStore-DdLzJyut.js";import{c,l,o as u,s as d,t as f}from"./bq-CSX8DSME.js";import{w as p}from"./icons-C1HVBnFn.js";import{n as m}from"./usePolledData-Dp_ynL9f.js";import{t as h}from"./Button-BCjgbAhY.js";import{t as g}from"./Card-DptfvL2O.js";import{t as _}from"./PageHeader-DD4vnVog.js";import{a as v}from"./index-CxzFSZj3.js";import{a as y,n as b,r as x,t as S}from"./form-Dy-an7ew.js";var C=e(t(),1),ee=`bq-dash-s3`,w=2,T=[`disabled`,`6h`,`12h`,`24h`],E={endpoint:``,region:`us-east-1`,bucket:``,schedule:`disabled`,pathPrefix:``,virtualHostedStyle:`auto`,retention:7};function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e,t,n){return typeof e==`string`&&e.length<=n?e:t}function k(e){return T.includes(e)?e:`disabled`}function te(e){return e===`virtual-hosted`||e===`path-style`?e:`auto`}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=1&&e<=1e6}function ne(e){return A(e)?e:E.retention}function j(e){let t=D(e)?e:{};return{endpoint:O(t.endpoint,E.endpoint,2048),region:O(t.region,E.region,128),bucket:O(t.bucket,E.bucket,255),schedule:k(t.schedule),pathPrefix:O(t.pathPrefix,E.pathPrefix,1024),virtualHostedStyle:te(t.virtualHostedStyle),retention:ne(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=D(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:w})}}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{}}},I=a()(s(e=>({...E,accessKeyId:``,secretAccessKey:``,sessionToken:``,set:t=>e(e=>{let n={...e,...t};return{...j(n),accessKeyId:O(n.accessKeyId,``,512),secretAccessKey:O(n.secretAccessKey,``,2048),sessionToken:O(n.sessionToken,``,4096)}})}),{name:ee,version:w,storage:i(()=>F),partialize:M,migrate:j,merge:(e,t)=>({...t,...j(e),accessKeyId:``,secretAccessKey:``,sessionToken:``})}));function L(){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 re=new Set([`enabled`,`bucket`,`endpoint`,`interval`,`retention`]),ie=new Set([`key`,`size`,`date`]);function ae(e){let t=z(e,re,`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,ie,`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.3 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=>ae(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 oe(){let e=r(),t=l(),n={...u(t)};return J(()=>e,(e,r)=>c(t.baseUrl,e,n,r,!0,`agent`))}var se={...J(r,d),capture:oe},Y=n();function ce({environmentText:e,pollIntervalMs:t=15e3,repository:n=se}){let r=o(e=>JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken])),i=(0,C.useRef)(!0),a=(0,C.useRef)(null);(!a.current||a.current.connectionIdentity!==r||a.current.repository!==n)&&(a.current={connectionIdentity:r,repository:n});let[s]=(0,C.useState)(L),c=m(e=>W(U(n),s,e),[n,s],{intervalMs:t}),[l,u]=(0,C.useState)(``),[d,f]=(0,C.useState)(``),[p,h]=(0,C.useState)(``),g=(0,C.useRef)(!1);(0,C.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]),(0,C.useEffect)(()=>{g.current=!1,u(``),f(``),h(``)},[r,n]);let _=async(e,t)=>{if(g.current)return;let r=a.current;g.current=!0,u(e),f(``),h(``);try{let o=U(n),l=await s.run(async()=>{if(!X(r,a,i))throw Error(`Backup operation scope changed before admission.`);return t(o)});if(!X(r,a,i))return;let u=l?.message;h(u??`${e} completed.`),await c.refetch()}catch(e){X(r,a,i)&&f(e instanceof Error?e.message:String(e))}finally{X(r,a,i)&&(g.current=!1,u(``))}},v=()=>{e&&window.confirm(`Apply this S3 configuration to the managed server? A restart is required.`)&&_(`Configuration`,t=>t.configure(K(e)))},y=()=>{window.confirm(`Create a transactionally consistent S3 backup now?`)&&_(`Backup`,e=>e.backupNow())},b=e=>{let t=c.data?.context?.database;!t||c.data?.context?.serverStatus!==`stopped`||window.prompt(`Type RESTORE to replace ${t.path} with ${e}`)===`RESTORE`&&_(`Restore`,n=>n.restore(e,t))},x=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.3 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:v,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:y,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`})]})]}),x?.status&&(0,Y.jsx)(le,{status:x.status,context:x.context}),d||x?.errors.length?(0,Y.jsx)(`div`,{role:`alert`,className:`border-b border-line px-4 py-3 text-xs text-danger`,children:d||x?.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)(ue,{rows:x?.backups??[],canRestore:x?.context?.serverStatus===`stopped`&&!!x.context.database,busy:!!l,onRestore:b})]})}function le({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 ue({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 X(e,t,n){return n.current&&e!==null&&t.current===e}function de(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 Z=e=>JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken]),fe={"6h":360*60*1e3,"12h":720*60*1e3,"24h":1440*60*1e3};function Q(e,t){return`${e}=${typeof t==`string`?JSON.stringify(t):String(t)}`}function pe(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:Q(`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=[Q(`S3_BACKUP_ENABLED`,!0),Q(`S3_ACCESS_KEY_ID`,a),Q(`S3_SECRET_ACCESS_KEY`,o),Q(`S3_BUCKET`,i),Q(`S3_REGION`,r),Q(`S3_BACKUP_RETENTION`,e.retention)];return s&&l.push(Q(`S3_SESSION_TOKEN`,s)),e.virtualHostedStyle!==`auto`&&l.push(Q(`S3_VIRTUAL_HOSTED_STYLE`,e.virtualHostedStyle===`virtual-hosted`)),n&&l.push(Q(`S3_ENDPOINT`,n)),c&&l.push(Q(`S3_BACKUP_PREFIX`,c)),l.push(Q(`S3_BACKUP_INTERVAL`,fe[e.schedule])),{ok:!0,value:l.join(`
|
|
3
|
-
`)}}function $(e){let t=e.trim();return t?Number(t):NaN}function me(e,t){let[n,r]=(0,C.useState)(()=>({text:String(e),base:e})),i=n.base===e?n.text:String(e);return{text:i,value:$(i),change(n){let i=$(n),a=A(i);a&&t(i),r({text:n,base:a?i:e})}}}function he({environment:e}){return(0,Y.jsxs)(g,{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)(v,{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 ge(){let e=I(),t=me(e.retention,t=>e.set({retention:t})),n=o(Z),[r,i]=(0,C.useState)(null),[a,s]=(0,C.useState)(null),c=(0,C.useRef)(0),l=pe({...e,retention:t.value}),u=r?.target===n?r:null,d=a===n;return(0,C.useEffect)(()=>(c.current++,i(null),s(null),()=>{c.current++}),[n]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(_,{title:`S3 Backup Setup`,description:`Configure and operate Bunqueue 2.9.3 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:l.ok?`Configuration draft complete`:`Configuration draft incomplete`}),(0,Y.jsx)(`div`,{className:`text-xs text-faint`,children:l.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:l.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:l.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)(g,{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)(S,{label:`Endpoint`,children:(0,Y.jsx)(b,{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)(S,{label:`Region`,children:(0,Y.jsx)(b,{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)(S,{label:`Bucket name`,children:(0,Y.jsx)(b,{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)(S,{label:`Access key ID`,children:(0,Y.jsx)(b,{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)(S,{label:`Secret access key`,children:(0,Y.jsx)(b,{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)(S,{label:`Session token (optional, for temporary STS credentials)`,children:(0,Y.jsx)(b,{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)(x,{htmlFor:`s3-backup-schedule`,children:`Backup interval`}),(0,Y.jsxs)(y,{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)(S,{label:`Path prefix (optional)`,children:(0,Y.jsx)(b,{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)(x,{htmlFor:`s3-addressing-style`,children:`Addressing style`}),(0,Y.jsxs)(y,{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)(S,{label:`Backups to retain`,children:(0,Y.jsx)(b,{name:`s3-retention`,type:`number`,min:1,max:1e6,step:1,value:t.text,onChange:e=>t.change(e.target.value),inputMode:`numeric`})})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(h,{onClick:async()=>{let e=n,t=++c.current;i(null),s(e);try{let n=await f.storage();if(t!==c.current||Z(o.getState())!==e)return;let r=de(n);i({target:e,ok:!r.diskFull,msg:r.diskFull?`Server disk is full`:`Server disk healthy — this does not validate the S3 credentials`})}catch(n){if(t!==c.current||Z(o.getState())!==e)return;i({target:e,ok:!1,msg:n.message})}finally{t===c.current&&s(null)}},children:d?`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.`}),u&&(0,Y.jsx)(`span`,{role:`status`,className:u.ok?`text-xs text-success`:`text-xs text-danger`,children:u.msg})]})]}),(0,Y.jsx)(he,{environment:l}),(0,Y.jsx)(ce,{environmentText:l.ok?l.value:void 0})]})}export{ge as S3BackupPro};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{t as r}from"./bq-CSX8DSME.js";import{C as i,T as a,b as o,x as s}from"./icons-C1HVBnFn.js";import{r as c}from"./StatusBadge-cYUkK-4P.js";import{n as l}from"./usePolledData-Dp_ynL9f.js";import{t as u}from"./Button-BCjgbAhY.js";import{n as d,t as f}from"./Card-DptfvL2O.js";import{i as p,n as m,r as h}from"./feedback-Dxfj-Fy1.js";import{t as g}from"./PageHeader-DD4vnVog.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-CxzFSZj3.js";import{i as C,n as w,t as T}from"./form-Dy-an7ew.js";import{t as E}from"./package-C7CtgBEy.js";import{t as D}from"./useControlActionGuard-DImMgJtj.js";var O=e(t(),1),k=n();function A({children:e}){return(0,k.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs text-fg`,children:e})}function j({agentBase:e}){return(0,k.jsx)(f,{children:(0,k.jsxs)(`details`,{className:`group`,children:[(0,k.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`How server control works`}),(0,k.jsx)(`span`,{className:`text-xs text-muted transition-transform group-open:rotate-90`,children:`▶`})]}),(0,k.jsxs)(`div`,{className:`mt-4 space-y-4 text-sm leading-relaxed text-muted`,children:[(0,k.jsxs)(`p`,{children:[`A browser can't start or stop an OS process, so the dashboard talks to a small local`,` `,(0,k.jsx)(`span`,{className:`font-medium text-fg`,children:`control agent`}),` (`,(0,k.jsx)(A,{children:e}),`) that supervises the bunqueue server process — start, stop and restart — and streams its logs back here.`]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Launch & environment`}),(0,k.jsxs)(`p`,{children:[`The agent runs your `,(0,k.jsx)(`span`,{className:`text-fg`,children:`Command`}),` and injects`,` `,(0,k.jsx)(A,{children:`HTTP_PORT`}),` and `,(0,k.jsx)(A,{children:`TCP_PORT`}),`, plus `,(0,k.jsx)(A,{children:`BUNQUEUE_DATA_PATH`}),` `,`only for SQLite. Memory and PostgreSQL modes remove every SQLite path alias before launch. Any `,(0,k.jsx)(`span`,{className:`text-fg`,children:`Environment variables`}),` you add are included too. The default`,` `,(0,k.jsx)(A,{children:`bunx bunqueue@${E.dependencies.bunqueue} start`}),` resolves the verified release; pointing the command at a local entry (e.g.`,` `,(0,k.jsx)(A,{children:`bun run /path/to/bunqueue/src/main.ts`}),`) works without one.`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`When changes apply`}),(0,k.jsxs)(`p`,{children:[`Config is editable any time, but `,(0,k.jsx)(`span`,{className:`text-fg`,children:`Command`}),`, ports and data path only take effect on the `,(0,k.jsx)(`span`,{className:`text-fg`,children:`next start/restart`}),` `,`— the running process keeps the config it launched with until then.`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Data path`}),(0,k.jsxs)(`p`,{children:[`Relative paths resolve against the `,(0,k.jsx)(`span`,{className:`text-fg`,children:`agent's`}),` working directory. SQLite creates the database `,(0,k.jsx)(`span`,{className:`text-fg`,children:`file`}),` but not its parent `,(0,k.jsx)(`span`,{className:`text-fg`,children:`folder`}),` — if start fails with`,` `,(0,k.jsx)(A,{children:`SQLITE_CANTOPEN`}),`, create the directory first or use a path whose folder already exists.`]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Security`}),(0,k.jsxs)(`p`,{children:[`The direct agent listener binds `,(0,k.jsx)(A,{children:`127.0.0.1`}),`, locks CORS to an allowlist (never `,(0,k.jsx)(A,{children:`*`}),`), and rejects a disallowed `,(0,k.jsx)(A,{children:`Origin`}),` or`,` `,(0,k.jsx)(A,{children:`Host`}),` with `,(0,k.jsx)(A,{children:`403`}),`. The all-in-one server's `,(0,k.jsx)(A,{children:`/agent`}),` `,`bridge treats LAN and reverse-proxy access as remote: `,(0,k.jsx)(A,{children:`AGENT_TOKEN`}),` is then mandatory for status, logs, database reads and changes alike. Without it, the bridge stays disabled.`]}),(0,k.jsxs)(`p`,{children:[`If you started the agent with `,(0,k.jsx)(A,{children:`AGENT_TOKEN`}),`, enter that token under`,` `,(0,k.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,k.jsx)(A,{children:`VITE_*`}),` value.`]})]})]})]})})}function M(e,t,n,r){return{baseline:z(e),id:r,revision:t,scope:n,value:z(e)}}function N(e,t,n,r,i){return{accepted:z(e),acceptedRevision:t,before:n?z(n):null,beforeRevision:r,ignoreThroughRequestId:i}}function P(e,t,n,r){return R(t,e.accepted)?!1:r!==void 0&&e.ignoreThroughRequestId!==void 0?r<=e.ignoreThroughRequestId:n===void 0?e.before!==null&&R(t,e.before):n===e.beforeRevision||n===e.acceptedRevision}function ee(e){if(!V(e))return H();let{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:a}=e;if(typeof t!=`string`||t.trim()===``||!B(n)||!B(r)||n===r||typeof i!=`string`||!V(a)||Object.values(a).some(e=>typeof e!=`string`))return H();let o=F(e.configRevision);return e.configRevision!==void 0&&o===void 0?H():{config:{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:Object.fromEntries(Object.entries(a))},revision:o}}function F(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0}function I(e){return B(e.httpPort)?B(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 L(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`),U(e.extraEnv)!==U(t.extraEnv)&&n.push(`environment variables`),n}function R(e,t){return JSON.stringify(W(e))===JSON.stringify(W(t))}function z(e){return{...e,extraEnv:{...e.extraEnv}}}function B(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=65535}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(){throw Error(`Configuration save returned a malformed response`)}function U(e){return JSON.stringify(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)))}function W(e){return{...e,extraEnv:Object.fromEntries(Object.entries(e.extraEnv).sort(([e],[t])=>e.localeCompare(t)))}}var G=0,K=e=>Object.entries(e).map(([e,t])=>({id:G++,key:e,value:t})),q=e=>{let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return t};function J(e){let t=e.map(e=>e.trim());return[...new Set(t.filter((e,t,n)=>e&&n.indexOf(e)!==t))]}var te=[`AUTH_TOKENS`,`LOG_LEVEL`,`BUNQUEUE_STORAGE_DRIVER`,`BUNQUEUE_POSTGRES_URL`,`BUNQUEUE_POSTGRES_NAMESPACE`,`BUNQUEUE_POSTGRES_POOL_SIZE`,`BUNQUEUE_MAX_COMPLETED_JOBS`,`BUNQUEUE_COMPLETED_RETENTION_MS`,`S3_BACKUP_ENABLED`,`S3_BUCKET`,`METRICS_ENABLED`];function ne({value:e,onChange:t,disabled:n}){let[r,i]=(0,O.useState)(()=>K(e)),a=e=>{i(e),t(q(e))},o=(e,t)=>a(r.map(n=>n.id===e?{...n,...t}:n)),s=(e=``)=>a([...r,{id:G++,key:e,value:``}]),c=e=>a(r.filter(t=>t.id!==e)),l=new Set(r.map(e=>e.key.trim()).filter(Boolean)),d=J(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,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.length===0&&(0,k.jsxs)(`p`,{className:`text-xs leading-relaxed text-faint`,children:[`No custom variables. The agent already injects`,` `,(0,k.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`HTTP_PORT`}),`,`,` `,(0,k.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,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`div`,{className:`w-2/5 shrink-0`,children:(0,k.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,k.jsx)(`span`,{className:`text-faint`,children:`=`}),(0,k.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,k.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,k.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,k.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Duplicate key`,d.length>1?`s`:``,` — the last value wins: `,d.join(`, `)]}),f.length>0&&(0,k.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,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,k.jsx)(u,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>s(),children:`+ Add variable`}),te.filter(e=>!l.has(e)).map(e=>(0,k.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 re({status:e,onSaved:t,running:n,statusRequestId:a,getStatusRequestSequence:o,transitioning:s}){let c=D(`server-config`),l=(0,O.useRef)(0),p=(0,O.useRef)(null),m=(0,O.useRef)(null),[h,g]=(0,O.useState)(null),[_,v]=(0,O.useState)(!1),[y,b]=(0,O.useState)(!1),[x,S]=(0,O.useState)(null),[C,A]=(0,O.useState)(!1),[j,z]=(0,O.useState)(null);(0,O.useEffect)(()=>{p.current&&clearTimeout(p.current),p.current=null,m.current=null,g(null),v(!1),b(!1),S(null),A(!1),z(null)},[c.scopeKey]),(0,O.useEffect)(()=>{if(!e?.config||_)return;let t=m.current;t&&P(t,e.config,F(e.configRevision),a)||(m.current=null,g(M(e.config,F(e.configRevision),c.scopeKey,++l.current)),A(!1))},[c.scopeKey,_,e?.config,e?.configRevision,a]),(0,O.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let B=h?.scope===c.scopeKey?h:null,V=B?.value??e?.config??null;if(!V)return(0,k.jsx)(f,{children:`Loading…`});let H=t=>{let n=B??M(V,F(e?.configRevision),c.scopeKey,++l.current);g({...n,value:{...n.value,...t}}),v(!0),b(!1),A(!1)},U=L(e?.runningConfig??null,V),W=n&&U.length>0,G=s||x!==null,K=()=>{p.current&&clearTimeout(p.current),b(!0),p.current=setTimeout(()=>{p.current=null,b(!1)},2e3)},q=async n=>{let i=c.begin([`config`,`lifecycle`]);if(!i)return;let a=I(V);if(a)return i.finish(),z(a);let s=B?.baseline??e?.config,u=B?.revision??F(e?.configRevision);if(u===void 0&&s&&e?.config&&!R(s,e.config))return i.finish(),A(!0),z(`Configuration changed elsewhere; reload the latest values before saving.`);z(null),A(!1),S(n?`restart`:`save`);try{let a=await r.control.setConfig(V,u);if(!i.isCurrent())return;let{config:s,revision:d}=ee(a);if(m.current=N(s,d,e?.config??null,F(e?.configRevision),o?.()),g(M(s,d,c.scopeKey,++l.current)),v(!1),n&&await r.control.restart(),!i.isCurrent())return;K(),await t()}catch(e){if(!i.isCurrent())return;let t=e.message;t.startsWith(`Configuration changed since revision`)&&A(!0),z(t)}finally{i.finish()&&S(null)}},J=()=>q(!1);return(0,k.jsxs)(f,{children:[(0,k.jsx)(d,{title:`Configuration`}),(0,k.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,k.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),J()},children:[(0,k.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 ${E.dependencies.bunqueue} with bunx; offline installs can point at a local entry.`,children:(0,k.jsx)(w,{name:`server-command`,autoComplete:`off`,spellCheck:!1,value:V.command,disabled:G,onChange:e=>H({command:e.target.value}),placeholder:`bunx bunqueue@${E.dependencies.bunqueue} start`})}),(0,k.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,k.jsx)(T,{label:`HTTP port`,hint:`Dashboard API + SSE.`,children:(0,k.jsx)(w,{name:`server-http-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:V.httpPort,disabled:G,onChange:e=>H({httpPort:Number(e.target.value)})})}),(0,k.jsx)(T,{label:`TCP port`,hint:`Binary protocol. Must differ from HTTP.`,children:(0,k.jsx)(w,{name:`server-tcp-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:V.tcpPort,disabled:G,onChange:e=>H({tcpPort:Number(e.target.value)})})})]}),(0,k.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,k.jsx)(w,{name:`server-data-path`,autoComplete:`off`,spellCheck:!1,value:V.dataPath,disabled:G,onChange:e=>H({dataPath:e.target.value})})}),(0,k.jsx)(T,{label:`Environment variables`,hint:`Injected on start. Includes Bunqueue 2.9.3 completed-history controls: BUNQUEUE_MAX_COMPLETED_JOBS bounds hot memory, while BUNQUEUE_COMPLETED_RETENTION_MS opts into durable age-based expiry. Memory and PostgreSQL modes remove inherited SQLite path aliases. Applies on the next restart.`,children:(0,k.jsx)(ne,{value:V.extraEnv??{},onChange:e=>H({extraEnv:e}),disabled:G},B?.id??`initial`)}),(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(u,{type:`submit`,variant:`accent`,size:`sm`,disabled:G,children:`Save config`}),n&&(0,k.jsxs)(u,{variant:`warning`,size:`sm`,disabled:G,onClick:()=>{let e=U.length>0?` Changed: ${U.join(`, `)}.`:``;if(window.confirm(`Save configuration and restart the server to apply it?${e}`))return q(!0)},children:[(0,k.jsx)(i,{className:`size-3.5`}),` Save & restart`]}),W&&!y&&(0,k.jsx)(`span`,{className:`text-xs text-warning`,children:`Restart to apply changes`}),y&&(0,k.jsx)(`span`,{className:`text-xs text-success`,children:`Saved`}),C&&(0,k.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,disabled:G,onClick:()=>{e?.config&&(m.current=null,g(M(e.config,F(e.configRevision),c.scopeKey,++l.current)),v(!1),A(!1),z(null))},children:`Reload latest`}),j&&(0,k.jsx)(`span`,{className:`text-xs text-danger`,children:j})]})]})]})}var ie=[`all`,`stdout`,`stderr`,`sys`],Y=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:t,loading:n,refetch:r}=ce(),i=(0,O.useMemo)(()=>e?.lines??[],[e]),[o,s]=(0,O.useState)(`all`),[l,u]=(0,O.useState)(``),[d,g]=(0,O.useState)(!0),[v,y]=(0,O.useState)(!1),b=(0,O.useRef)(null),x=(0,O.useMemo)(()=>{let e=l.trim().toLowerCase();return i.map(e=>e.line.includes(`\x1B`)?{...e,line:_(e.line)}:e).filter(t=>(o===`all`||t.stream===o)&&(!e||t.line.toLowerCase().includes(e)))},[i,o,l]);(0,O.useEffect)(()=>{if(!d)return;let e=b.current;e&&(e.scrollTop=e.scrollHeight)},[x.length,d]);let w=(0,O.useMemo)(()=>x.map(e=>v?`${Y(e.ts)} [${e.stream}] ${e.line}`:e.line).join(`
|
|
2
|
-
`),[x,v]);return(0,k.jsxs)(f,{padded:!1,className:`overflow-hidden`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-4 py-3`,children:[(0,k.jsx)(`h3`,{className:`mr-1 text-base font-semibold text-fg`,children:`Process logs`}),(0,k.jsx)(C,{options:ie,value:o,onChange:s}),(0,k.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,k.jsx)(a,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,k.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,k.jsx)(X,{on:d,onClick:()=>g(e=>!e),label:`Follow`}),(0,k.jsx)(X,{on:v,onClick:()=>y(e=>!e),label:`Times`}),(0,k.jsx)(S,{value:w}),(0,k.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`})]}),t&&e&&(0,k.jsx)(`div`,{className:`border-b border-line px-4 pt-3 font-sans`,children:(0,k.jsx)(p,{message:`Process-log refresh failed — showing the last received lines. ${t.message}`,onRetry:r})}),(0,k.jsx)(`div`,{ref:b,className:`max-h-80 min-h-40 overflow-y-auto p-4 font-mono text-xs leading-relaxed`,children:n&&!e&&!t?(0,k.jsx)(`div`,{className:`font-sans`,children:(0,k.jsx)(h,{label:`Loading process logs…`})}):t&&!e?(0,k.jsx)(`div`,{className:`font-sans`,children:(0,k.jsx)(m,{error:t,onRetry:r})}):x.length===0?(0,k.jsx)(`p`,{className:`text-faint`,children:i.length===0?`No output yet.`:`No lines match the current filter.`}):x.map(e=>(0,k.jsxs)(`div`,{className:c(`whitespace-pre-wrap`,ae(e.stream)),children:[v&&(0,k.jsx)(`span`,{className:`mr-2 text-faint`,children:Y(e.ts)}),e.line]},e.seq))}),(0,k.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-[11px] text-faint`,children:[(0,k.jsx)(`span`,{children:t&&!e?`logs unavailable`:x.length===i.length?`${i.length} lines`:`${x.length} of ${i.length} lines`}),(0,k.jsx)(`span`,{children:t?`refresh failed`:d?`following tail`:`paused`})]})]})}function X({on:e,onClick:t,label:n}){return(0,k.jsx)(`button`,{type:`button`,onClick:t,"aria-pressed":e,className:c(`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:n})}function ce(){return l(()=>r.control.logs(),[])}var Z={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 le({startedAt:e}){let[,t]=(0,O.useState)(0);return(0,O.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,k.jsx)(k.Fragment,{children:x((Date.now()-e)/1e3)})}function Q({label:e,children:t,title:n}){return(0,k.jsxs)(`div`,{className:`min-w-0`,title:n,children:[(0,k.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e}),(0,k.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,children:t})]})}function ue({status:e,agentBase:t,transitioning:n,stale:r=!1,vitals:a=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`}:Z[m]??Z.stopped,y=!!e?.healthy&&!r,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,k.jsxs)(`section`,{className:`mb-6 overflow-hidden rounded-xl border border-line bg-surface`,children:[(0,k.jsx)(`div`,{className:c(`h-0.5 bg-gradient-to-r to-transparent`,g&&y?`from-emerald-400/80 via-emerald-400/25`:g||n?`from-amber-400/80 via-amber-400/25`:`from-red-400/70 via-red-400/20`)}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-5 p-5 lg:flex-row lg:items-center lg:justify-between`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,k.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[g&&y&&(0,k.jsx)(`span`,{className:`absolute inline-flex size-full rounded-full bg-emerald-400 opacity-50 motion-safe:animate-ping`}),(0,k.jsx)(`span`,{className:c(`relative inline-flex size-3.5 rounded-full`,_.dot)})]}),(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,k.jsx)(`span`,{className:c(`text-2xl font-bold tracking-tight`,_.tone),children:n&&l?`${l}…`:_.label}),e?.version&&(0,k.jsxs)(`span`,{className:`font-mono text-xs text-muted`,children:[`bunqueue v`,e.version]}),b&&(0,k.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,k.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted`,children:r?(0,k.jsxs)(`span`,{className:`text-warning`,children:[`last known: pid `,e?.pid??`—`,` — agent unreachable, state may have changed`]}):h?(0,k.jsx)(`span`,{title:e?.healthError,children:e?.reachable?y?`healthy via ${T}`:`reachable but unhealthy via ${T}`:`unreachable via ${T}`}):g?(0,k.jsxs)(k.Fragment,{children:[y?`healthy`:`waiting for health…`,` · pid `,e?.pid??`—`,` · up`,` `,e?.startedAt?(0,k.jsx)(le,{startedAt:e.startedAt}):`—`]}):`process not running — start it below or point the dashboard at an external server`})]})]}),!h&&(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,k.jsxs)(u,{variant:`success`,disabled:g||n||r,onClick:d,children:[(0,k.jsx)(s,{className:`size-4`}),` Start`]}),(0,k.jsxs)(u,{variant:`warning`,disabled:!g||n||r,onClick:f,children:[(0,k.jsx)(o,{className:`size-4`}),` Stop`]}),(0,k.jsxs)(u,{disabled:n||r,onClick:p,children:[(0,k.jsx)(i,{className:`size-4`}),` Restart`]})]})]}),(0,k.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,k.jsx)(Q,{label:`Memory`,children:a?.memory?.rss==null?(0,k.jsx)(`span`,{className:`text-faint`,children:`—`}):(0,k.jsxs)(`span`,{title:`heap ${a.memory.heapUsed??`?`} / ${a.memory.heapTotal??`?`} MB`,children:[a.memory.rss,` MB rss`]})}),(0,k.jsx)(Q,{label:`Connections`,children:a?.connections?`${a.connections.tcp??0} tcp · ${a.connections.ws??0} ws · ${a.connections.sse??0} sse`:(0,k.jsx)(`span`,{className:`text-faint`,children:`—`})}),(0,k.jsx)(Q,{label:h?`Health target`:`API endpoint`,title:T,children:w===`—`?(0,k.jsx)(`span`,{className:`text-faint`,children:w}):(0,k.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(`a`,{href:T,target:`_blank`,rel:`noreferrer`,className:`truncate text-accent hover:underline`,children:w}),(0,k.jsx)(S,{value:w})]})}),(0,k.jsx)(Q,{label:h?`Lifecycle`:`Ports`,children:h?`external`:x?`${x.httpPort} http · ${x.tcpPort} tcp`:`—`}),(0,k.jsx)(Q,{label:h?`Health HTTP`:`Started`,children:h?e?.healthStatus??`—`:g&&e?.startedAt?v(e.startedAt):`—`}),(0,k.jsx)(Q,{label:`Control agent`,title:t,children:t.replace(/^https?:\/\//,``)}),(0,k.jsx)(Q,{label:h?`Supervisor`:`Storage`,title:e?.storageMode===`postgres`?`PostgreSQL ${e.postgresTarget??`configured`} · namespace ${e.postgresNamespace??`default`}`:e?.storageMode,children:h?`managed elsewhere`:e?.storageMode===`postgres`?`postgres · ${e.postgresNamespace??`default`}`:e?.storageMode??`—`})]})]})}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 de({db:e}){let t=e.totalSize||0;return(0,k.jsxs)(f,{children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,k.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Storage`}),(0,k.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:e.exists?`${b(t)} on disk`:`not created yet`})]}),(0,k.jsxs)(`p`,{className:`mb-4 flex items-center gap-1.5 truncate font-mono text-xs text-faint`,title:e.path,children:[(0,k.jsx)(`span`,{className:`truncate`,children:e.path}),(0,k.jsx)(S,{value:e.path})]}),e.exists&&t>0?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-surface-2`,children:$.map(n=>{let r=e[n.key];return r?(0,k.jsx)(`div`,{className:c(`h-full`,n.color),style:{width:`${r/t*100}%`},title:`${n.label}: ${b(r)}`},n.key):null})}),(0,k.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(t=>(0,k.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(`span`,{className:c(`size-2 rounded-full`,t.color)}),t.label,` `,(0,k.jsx)(`span`,{className:`text-fg`,children:b(e[t.key])})]},t.key)),e.mtimeMs?(0,k.jsxs)(`span`,{className:`ml-auto`,children:[`written `,y(e.mtimeMs)]}):null]})]}):(0,k.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 fe(){let e=(0,O.useRef)(0),t=(0,O.useRef)(new WeakMap),{data:n,error:i,refetch:a}=l(async()=>{let n=++e.current,i=await r.control.status();return t.current.set(i,n),i},[]),o=D(`server-lifecycle`),[s,c]=(0,O.useState)(null),[u,m]=(0,O.useState)(null);(0,O.useEffect)(()=>{c(null),m(null)},[o.scopeKey]);let h=n?.managementMode===`external`,_=h?n?.reachable===!0:n?.status===`running`,{data:v}=l(()=>_?r.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(i&&!n)return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(g,{title:`Server`,description:`Start, stop and restart the bunqueue server.`}),(0,k.jsx)(p,{message:`Control agent unreachable — server lifecycle controls are unavailable.`,onRetry:a}),(0,k.jsxs)(f,{children:[(0,k.jsx)(d,{title:`Control agent not running`}),(0,k.jsxs)(`p`,{className:`text-sm text-muted`,children:[`The local control agent is unreachable at`,` `,(0,k.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:r.agentBase}),`. It manages the bunqueue server process (start / stop / restart). Start it with:`]}),(0,k.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,k.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=i!=null&&n!=null;return(0,k.jsxs)(`div`,{children:[(0,k.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,k.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,k.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,k.jsx)(ue,{status:n,agentBase:r.agentBase,stale:T,vitals:y,transitioning:w,busy:s,onStart:()=>x(`starting`,()=>r.control.start()),onStop:()=>x(`stopping`,()=>r.control.stop(),`Stop the bunqueue server?${b}`),onRestart:()=>x(`restarting`,()=>r.control.restart(),`Restart the bunqueue server?${b}`)}),h?(0,k.jsxs)(f,{children:[(0,k.jsx)(d,{title:`Managed externally`}),(0,k.jsxs)(`p`,{className:`text-sm text-muted`,children:[`This dashboard is attached to`,` `,(0,k.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,k.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,k.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,k.jsx)(re,{status:n,onSaved:a,running:C,statusRequestId:n?t.current.get(n):void 0,getStatusRequestSequence:()=>e.current,transitioning:w}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[n?.db&&(0,k.jsx)(de,{db:n.db}),(0,k.jsx)(se,{})]})]}),(0,k.jsx)(`div`,{className:`mt-6`,children:(0,k.jsx)(j,{agentBase:r.agentBase})})]})}export{fe as ServerControl};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{c as r,o as i,s as a}from"./connectionStore-DdLzJyut.js";import{f as o}from"./icons-C1HVBnFn.js";import{n as s,t as c}from"./Button-BCjgbAhY.js";import{n as l,t as u}from"./Card-DptfvL2O.js";import{t as d}from"./PageHeader-DD4vnVog.js";import{o as f}from"./index-CxzFSZj3.js";import{a as p,n as m,t as h}from"./form-Dy-an7ew.js";var g=n(),_=[[`1000`,`1 second`],[`2000`,`2 seconds`],[`3000`,`3 seconds`],[`5000`,`5 seconds`],[`10000`,`10 seconds`]];function v(){let{refreshMs:e,setRefreshMs:t}=i(),{theme:n,setTheme:r}=f();return(0,g.jsxs)(u,{children:[(0,g.jsx)(l,{title:`Appearance & refresh`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,g.jsx)(h,{label:`Theme`,children:(0,g.jsxs)(p,{name:`theme`,autoComplete:`off`,value:n,onChange:e=>r(e.target.value),children:[(0,g.jsx)(`option`,{value:`dark`,children:`Dark`}),(0,g.jsx)(`option`,{value:`light`,children:`Light`})]})}),(0,g.jsx)(h,{label:`Refresh interval`,children:(0,g.jsx)(p,{name:`refresh-interval`,autoComplete:`off`,value:String(e),onChange:e=>t(Number(e.target.value)),children:_.map(([e,t])=>(0,g.jsx)(`option`,{value:e,children:t},e))})})]})]})}var y=e(t(),1),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});return{response:n,value:await n.json()}})();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?.()}}async function C(e,t={},n=b){let{response:r,value:i}=await S(e,t,n);if(!r.ok&&r.status!==503)throw Error(`HTTP ${r.status}`);if(typeof i!=`object`||!i||Array.isArray(i))throw Error(`Malformed health response`);let a=i;if(typeof a.ok!=`boolean`||a.status!==`healthy`&&a.status!==`degraded`||!Number.isSafeInteger(a.uptime)||a.uptime<0||typeof a.version!=`string`||!x.test(a.version)||a.ok!==(a.status===`healthy`))throw Error(`Malformed health response`);return{response:r,health:a}}function w(){let e=i(),[t,n]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,w]=(0,y.useState)(null),[T,E]=(0,y.useState)(null),D=(0,y.useRef)(!0),O=(0,y.useRef)(0),k=(0,y.useRef)(null),A=(0,y.useRef)(null),j=(0,y.useCallback)(()=>{A.current!==null&&clearTimeout(A.current),A.current=null,D.current&&E(null)},[]),M=(0,y.useCallback)(()=>{O.current+=1,k.current?.abort(new DOMException(`Connection test superseded`,`AbortError`)),k.current=null,D.current&&(h(null),_(null))},[]),N=(0,y.useCallback)(()=>{M(),j()},[j,M]);(0,y.useEffect)(()=>(D.current=!0,()=>{D.current=!1,O.current+=1,k.current?.abort(new DOMException(`Settings unmounted`,`AbortError`)),A.current!==null&&clearTimeout(A.current)}),[]),(0,y.useEffect)(()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);n(t?.name??`Bunqueue`),s(e.baseUrl),l(e.agentBaseUrl),d(e.token),p(e.agentToken),b(null),w(null),M()},[e.activeProfileId,e.agentBaseUrl,e.baseUrl,e.profiles,e.token,e.agentToken,M]);let P=()=>{let e=i.getState();return JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken])},F=async e=>{M();let t=r(e===`server`?o:c);if(!t){e===`server`?b(a):w(a),_({ok:!1,msg:a});return}e===`server`?b(null):w(null);let n=O.current,i=new AbortController,s=P(),l=()=>D.current&&n===O.current&&!i.signal.aborted&&P()===s;k.current=i,h(e),_(null);let d=performance.now();try{if(e===`server`){let{response:e,health:n}=await C(`${t}/health`,{headers:u.trim()?{Authorization:`Bearer ${u.trim()}`}:void 0,signal:i.signal});if(!l())return;let r=e.status===503||n.status===`degraded`;_({ok:!r,msg:`${r?`Server reachable`:`Connected`} in ${Math.round(performance.now()-d)}ms · bunqueue v${n.version}${r?` · degraded`:``}`})}else{let{response:e,value:n}=await S(`${t}/control/status`,{headers:f.trim()?{Authorization:`Bearer ${f.trim()}`}:void 0,signal:i.signal});if(!e.ok)throw Error(`HTTP ${e.status}`);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Malformed control agent response`);let r=n;if(![`running`,`stopped`,`starting`,`stopping`].includes(String(r.status)))throw Error(`Malformed control agent response`);if(!l())return;_({ok:!0,msg:`Agent connected in ${Math.round(performance.now()-d)}ms · server ${r.status}${r.storageMode?` · ${r.storageMode}`:``}`})}}catch(e){l()&&_({ok:!1,msg:e.message})}finally{D.current&&n===O.current&&(k.current=null,h(null))}},I=()=>{M();let n=r(o),i=r(c);if(b(n?null:a),w(i?null:a),!n||!i)return;let s=e.saveConnection({name:t,baseUrl:n,agentBaseUrl:i,token:u,agentToken:f});j(),E({ok:s.persisted,msg:s.persisted?`Saved ✓`:`Saved for this session only — browser storage unavailable${s.error?`: ${s.error}`:`.`}`}),A.current=setTimeout(()=>D.current&&E(null),4e3)},L=()=>{N(),e.addProfile({name:`Bunqueue ${e.profiles.length+1}`,baseUrl:`http://localhost:6790`,agentBaseUrl:`http://localhost:6800`,token:``,agentToken:``})},R=()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);!t||!window.confirm(`Remove connection profile "${t.name}"?`)||e.removeProfile(t.id)};return{...e,name:t,setName:n,url:o,setUrl:s,agentUrl:c,setAgentUrl:l,tok:u,setTok:d,agentTok:f,setAgentTok:p,testing:m,result:g,urlError:v,agentUrlError:x,saveNotice:T,edit:N,save:I,add:L,remove:R,testServer:()=>F(`server`),testAgent:()=>F(`agent`)}}function T({id:e,label:t,hint:n,value:r,placeholder:i,onChange:a}){let[c,l]=(0,y.useState)(!1);return(0,g.jsx)(h,{label:t,hint:n,htmlFor:e,children:(0,g.jsxs)(`div`,{className:`relative`,children:[(0,g.jsx)(m,{id:e,name:e,type:c?`text`:`password`,value:r,onChange:e=>a(e.target.value),placeholder:i,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,g.jsx)(s,{"aria-label":c?`Hide ${t.toLowerCase()}`:`Show ${t.toLowerCase()}`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>l(e=>!e),children:(0,g.jsx)(o,{className:`size-4`})})]})})}function E(){let e=w(),t=t=>n=>{e.edit(),t(n)};return(0,g.jsxs)(u,{children:[(0,g.jsx)(l,{title:`Bunqueue fleet connections`}),(0,g.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_auto_auto]`,children:[(0,g.jsx)(h,{label:`Active node`,children:(0,g.jsx)(p,{"aria-label":`Active Bunqueue node`,value:e.activeProfileId,onChange:t=>e.activateProfile(t.target.value),children:e.profiles.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))})}),(0,g.jsx)(c,{className:`self-end`,onClick:e.add,children:`Add node`}),(0,g.jsx)(c,{className:`self-end`,variant:`danger`,disabled:e.profiles.length===1,onClick:e.remove,children:`Remove`})]}),(0,g.jsx)(h,{label:`Node name`,children:(0,g.jsx)(m,{name:`profile-name`,value:e.name,onChange:n=>t(e.setName)(n.target.value),maxLength:64,autoComplete:`off`,placeholder:`broker-eu-1`})}),(0,g.jsx)(h,{label:`Server URL`,children:(0,g.jsx)(m,{name:`server-url`,value:e.url,onChange:n=>{t(e.setUrl)(n.target.value)},placeholder:`/api or https://queue.example.com`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.urlError?!0:void 0,"aria-describedby":e.urlError?`server-url-error`:`server-url-help`})}),e.urlError?(0,g.jsx)(`p`,{id:`server-url-error`,className:`-mt-2 text-xs text-danger`,children:e.urlError}):(0,g.jsx)(`p`,{id:`server-url-help`,className:`-mt-2 text-xs text-faint`,children:`Bunqueue HTTP API for this broker. All queue pages use the selected node.`}),(0,g.jsx)(h,{label:`Control agent URL`,children:(0,g.jsx)(m,{name:`agent-url`,value:e.agentUrl,onChange:n=>t(e.setAgentUrl)(n.target.value),placeholder:`/agent or https://broker.example.com/agent`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.agentUrlError?!0:void 0,"aria-describedby":e.agentUrlError?`agent-url-error`:`agent-url-help`})}),e.agentUrlError?(0,g.jsx)(`p`,{id:`agent-url-error`,className:`-mt-2 text-xs text-danger`,children:e.agentUrlError}):(0,g.jsx)(`p`,{id:`agent-url-help`,className:`-mt-2 text-xs text-faint`,children:`One paired agent per broker enables lifecycle, configuration, Flow, Workflow and advanced queue controls.`}),(0,g.jsx)(T,{id:`bearer-token`,label:`Bearer token (optional)`,hint:`Server credential, kept in memory only and isolated to this node.`,value:e.tok,onChange:t(e.setTok),placeholder:`only if AUTH_TOKENS is set`}),(0,g.jsx)(T,{id:`agent-token`,label:`Agent token (optional)`,hint:`AGENT_TOKEN for this node, kept in memory only.`,value:e.agentTok,onChange:t(e.setAgentTok),placeholder:`only if AGENT_TOKEN is set`}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(c,{variant:`accent`,onClick:e.save,children:`Save`}),(0,g.jsx)(c,{onClick:e.testServer,children:e.testing===`server`?`Restart test`:`Test connection`}),(0,g.jsx)(c,{onClick:e.testAgent,children:e.testing===`agent`?`Restart agent test`:`Test agent`}),e.saveNotice&&(0,g.jsx)(`span`,{role:`status`,className:e.saveNotice.ok?`text-sm text-success`:`text-sm text-warning`,children:e.saveNotice.msg}),e.result&&(0,g.jsx)(`span`,{role:`status`,className:e.result.ok?`text-sm text-success`:`text-sm text-danger`,children:e.result.msg})]}),(0,g.jsx)(`p`,{className:`-mt-1 text-xs text-faint`,children:`Switching the active node retargets every Dashboard feature atomically. Profile metadata persists; both credentials are erased on reload.`})]})]})}function D(){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(d,{title:`Settings`,description:`Bunqueue fleet connections, credentials and appearance.`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsx)(E,{}),(0,g.jsx)(v,{})]})]})}export{D as Settings};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-DfC0iyIS.js";import{t}from"./api-Bbo86MB6.js";import{n}from"./usePolledData-Dp_ynL9f.js";import{n as r,t as i}from"./Card-DptfvL2O.js";import{i as a,n as o,r as s}from"./feedback-Dxfj-Fy1.js";import{t as c}from"./PageHeader-DD4vnVog.js";import{l,n as u,s as d,u as f}from"./format-Cg7VCIZW.js";import{r as p}from"./index-CxzFSZj3.js";var m=e(),h={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},memory:{heapUsed:0,heapTotal:0,rss:0},workers:{total:0,active:0},crons:{total:0},storage:{}};function g(){let{data:e,error:g,loading:v,refetch:y}=n(()=>t.overview(),[]);if(v&&!e&&!g)return(0,m.jsx)(s,{label:`Loading usage…`});if(g&&!e)return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(c,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,m.jsx)(o,{error:g,onRetry:y})]});let{stats:b,memory:x,workers:S,crons:C,storage:w}=e??h,T=typeof w.diskFull==`boolean`;return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(c,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!g&&T}),g&&(0,m.jsx)(a,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:y}),(0,m.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,m.jsx)(p,{label:`Jobs Pushed`,value:d(b.totalPushed)}),(0,m.jsx)(p,{label:`Jobs Completed`,value:d(b.totalCompleted),tone:`green`}),(0,m.jsx)(p,{label:`Jobs Failed`,value:d(b.totalFailed),tone:b.totalFailed?`red`:`default`}),(0,m.jsx)(p,{label:`Jobs Pulled`,value:d(b.totalPulled),tone:`blue`})]}),(0,m.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,m.jsxs)(i,{children:[(0,m.jsx)(r,{title:`Runtime`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Uptime`,value:f(b.uptime/1e3)}),(0,m.jsx)(_,{label:`Heap used`,value:u(x.heapUsed*1024*1024)}),(0,m.jsx)(_,{label:`RSS`,value:u(x.rss*1024*1024)}),(0,m.jsx)(_,{label:`Workers`,value:`${S.active} active / ${S.total}`}),(0,m.jsx)(_,{label:`Cron jobs`,value:String(C.total)})]})]}),(0,m.jsxs)(i,{children:[(0,m.jsx)(r,{title:`Storage`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Status`,value:T?w.diskFull?`Disk full`:`Healthy`:`Unavailable`}),(0,m.jsx)(_,{label:`Disk full since`,value:w.diskFull?l(w.since):`—`}),w.error?(0,m.jsx)(_,{label:`Error`,value:String(w.error)}):null]})]})]})]})}function _({label:e,value:t,mono:n}){return(0,m.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,m.jsx)(`dt`,{className:`text-muted`,children:e}),(0,m.jsx)(`dd`,{className:n?`font-mono text-xs text-fg`:`font-medium text-fg`,children:t})]})}export{g as Usage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-DfC0iyIS.js";import{t}from"./bq-CSX8DSME.js";import{n}from"./usePolledData-Dp_ynL9f.js";import{n as r,t as i}from"./Card-DptfvL2O.js";import{i as a,n as o,r as s}from"./feedback-Dxfj-Fy1.js";import{t as c}from"./PageHeader-DD4vnVog.js";import{c as l,l as u,n as d,s as f,t as p,u as m}from"./format-Cg7VCIZW.js";import{n as h,r as g}from"./index-CxzFSZj3.js";var _=e(),v={overview:{stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},memory:{heapUsed:0,heapTotal:0,rss:0},crons:{total:0}},storage:{},failedTotal:0};function y(){let{data:e,error:y,loading:x,refetch:S}=n(async()=>{let[e,n,r]=await Promise.all([t.overview(),t.storage(),t.queuesSummary()]);if(!n?.data||typeof n.data.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data`);if(h(e),!Number.isFinite(e.memory.heapUsed))throw Error(`Malformed /dashboard response: memory.heapUsed is missing or non-numeric.`);let i=r.reduce((e,t)=>e+(t.counts?.failed??0),0);return{overview:e,storage:n.data,failedTotal:i}},[]);if(x&&!e&&!y)return(0,_.jsx)(s,{label:`Loading usage…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(c,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,_.jsx)(o,{error:y,onRetry:S})]});let C=e??v,{stats:w,memory:T,crons:E}=C.overview,{storage:D,failedTotal:O}=C,k=p(w.completed,O),A=w.uptime?m(w.uptime/1e3):`—`;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(c,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!y}),y&&(0,_.jsx)(a,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:S}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(g,{label:`Completed`,value:f(w.completed),tone:`green`}),(0,_.jsx)(g,{label:`Failed`,value:f(O),tone:O?`red`:`default`}),(0,_.jsx)(g,{label:`Waiting`,value:f(w.waiting),tone:`amber`}),(0,_.jsx)(g,{label:`Active`,value:f(w.active),tone:`blue`}),(0,_.jsx)(g,{label:`Error Rate`,value:k==null?`—`:l(k),tone:k==null?`default`:k>.05?`red`:`green`}),(0,_.jsx)(g,{label:`Uptime`,value:A})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(i,{children:[(0,_.jsx)(r,{title:`Runtime`}),(0,_.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,_.jsx)(b,{label:`Jobs pushed (since restart)`,value:f(w.totalPushed)}),(0,_.jsx)(b,{label:`Jobs pulled (since restart)`,value:f(w.totalPulled)}),(0,_.jsx)(b,{label:`Heap used`,value:d(T.heapUsed*1024*1024)}),(0,_.jsx)(b,{label:`RSS`,value:d(T.rss*1024*1024)}),(0,_.jsx)(b,{label:`Cron jobs`,value:String(E.total)})]})]}),(0,_.jsxs)(i,{children:[(0,_.jsx)(r,{title:`Storage`}),D.diskFull?(0,_.jsxs)(`div`,{className:`rounded-lg border border-red-500/25 bg-red-500/[0.06] px-4 py-3`,children:[(0,_.jsx)(`div`,{className:`font-semibold text-danger`,children:`Disk full — writes suspended`}),D.error&&(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:D.error}),D.since!=null&&(0,_.jsxs)(`div`,{className:`mt-1 text-xs text-faint`,children:[`since `,u(D.since)]})]}):(0,_.jsxs)(`div`,{className:`rounded-lg border border-emerald-500/25 bg-emerald-500/[0.06] px-4 py-3`,children:[(0,_.jsx)(`div`,{className:`font-semibold text-success`,children:`Healthy`}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`Disk writes are being accepted.`})]})]})]})]})}function b({label:e,value:t}){return(0,_.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,_.jsx)(`dt`,{className:`text-muted`,children:e}),(0,_.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}export{y as UsagePro};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{t as r}from"./bq-CSX8DSME.js";import{t as i}from"./toastStore-DnqA_aL-.js";import{O as a,m as o}from"./icons-C1HVBnFn.js";import{n as s}from"./usePolledData-Dp_ynL9f.js";import{n as c,t as l}from"./Button-BCjgbAhY.js";import{n as u,t as d}from"./Card-DptfvL2O.js";import{i as f,n as p,r as m,t as h}from"./feedback-Dxfj-Fy1.js";import{t as g}from"./PageHeader-DD4vnVog.js";import{l as _,s as v}from"./format-Cg7VCIZW.js";import{n as y,o as b,t as x}from"./form-Dy-an7ew.js";import{t as S}from"./Pagination-Cj7GzYNX.js";import{r as C,t as w}from"./useServerActionGuard-Cr4KUOeZ.js";var T=[`job.pushed`,`job.started`,`job.completed`,`job.failed`,`job.progress`],E=e(t(),1);function D(e){try{let t=new URL(e);return e.length<=2048&&/^https?:$/.test(t.protocol)&&t.username===``&&t.password===``}catch{return!1}}function O(e){try{let t=new URL(e);return!t.username&&!t.password?e:(t.username=`redacted`,t.password=`redacted`,t.toString())}catch{return e}}function k(e,t,n,r){let i=e.trim();if(!i||t.length===0)return{ok:!1,msg:`URL and at least one event are required`};if(!D(i))return{ok:!1,msg:`URL must be a valid http:// or https:// address without embedded credentials`};let a=n.trim();return a&&(a.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(a))?{ok:!1,msg:`Queue must be at most 256 characters using letters, numbers, _, -, . or :`}:{ok:!0,body:{url:i,events:t,queue:a||void 0,secret:r.trim()||void 0}}}var A=n();function j({onAdd:e,onAccepted:t,beginAdd:n,scopeKey:r}){let[i,a]=(0,E.useState)(``),[o,s]=(0,E.useState)(``),[c,u]=(0,E.useState)(``),[d,f]=(0,E.useState)([`job.completed`,`job.failed`]),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)(!1);(0,E.useEffect)(()=>{g(!1),m(null)},[r]);let _=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),v=async()=>{if(h)return;m(null);let r=k(i,d,o,c);if(!r.ok)return m(r.msg);let s=n();if(s){g(!0);try{if(w(await e(r.body),`Add webhook`),!s.isCurrent())return;a(``),u(``),t()}catch(e){s.isCurrent()&&m(e.message)}finally{s.finish()&&g(!1)}}};return(0,A.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),v()},children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,A.jsx)(`div`,{className:`md:col-span-1`,children:(0,A.jsx)(x,{label:`URL`,children:(0,A.jsx)(y,{value:i,onInput:e=>a(e.currentTarget.value),name:`webhook-url`,type:`url`,maxLength:2048,autoComplete:`url`,placeholder:`https://example.com/hook`})})}),(0,A.jsx)(x,{label:`Queue (optional)`,children:(0,A.jsx)(y,{value:o,onChange:e=>s(e.target.value),name:`webhook-queue`,maxLength:256,autoComplete:`off`,placeholder:`all queues`})}),(0,A.jsx)(x,{label:`Secret (optional)`,children:(0,A.jsx)(y,{type:`password`,autoComplete:`new-password`,name:`webhook-secret`,maxLength:65536,value:c,onChange:e=>u(e.target.value),placeholder:`HMAC signing secret`})})]}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.map(e=>(0,A.jsx)(`button`,{type:`button`,"aria-pressed":d.includes(e),onClick:()=>_(e),className:d.includes(e)?`rounded-full bg-accent/15 px-3 py-1 text-xs font-medium text-accent`:`rounded-full border border-line px-3 py-1 text-xs font-medium text-muted hover:text-fg`,children:e},e))}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(l,{type:`submit`,variant:`accent`,size:`sm`,disabled:h,children:h?`Adding…`:`Add webhook`}),p&&(0,A.jsx)(`span`,{className:`text-xs text-danger`,children:p})]})]})}function M(e){let[t,n]=(0,E.useState)(0);return(0,E.useEffect)(()=>{t>e-1&&n(e-1)},[t,e]),[Math.min(t,e-1),n]}function N(){let{data:e,error:t,loading:n,refetch:l}=s(()=>r.webhooks(),[]),y=e?.data?.webhooks??[],[x,T]=M(Math.max(1,Math.ceil(y.length/15))),[D,k]=(0,E.useState)(null),[N,P]=(0,E.useState)(new Set),F=C(`webhooks`),[I,L]=(0,E.useState)({}),R=(0,E.useRef)(new Map);(0,E.useEffect)(()=>{k(null),P(new Set),L({}),R.current.clear()},[F.scopeKey]);let z=async e=>{let t=F.begin([`registry-write`,`webhook:${e}`]);if(t){k(null),P(t=>new Set(t).add(e));try{if(w(await r.removeWebhook(e),`Remove webhook`),!t.isCurrent())return;l()}catch(e){if(!t.isCurrent())return;k(e.message)}finally{t.finish()&&P(t=>{let n=new Set(t);return n.delete(e),n})}}},B=(e,t)=>{let n=Symbol(`webhook-toggle`),a=R.current.get(e);if(a){a.desired=t,a.intent=n,L(r=>({...r,[e]:{value:t,intent:n}}));return}let o=F.begin(`webhook:${e}`);if(!o)return;let s={desired:t,intent:n,lease:o};R.current.set(e,s),L(r=>({...r,[e]:{value:t,intent:n}})),(async()=>{try{for(;o.isCurrent()&&R.current.get(e)===s;){let t=s.desired,n=null;try{w(await r.setWebhookEnabled(e,t),`Toggle webhook`)}catch(e){n=e instanceof Error?e:Error(String(e))}if(!o.isCurrent()||R.current.get(e)!==s)return;if(s.desired!==t)continue;if(await l(),!o.isCurrent()||R.current.get(e)!==s)return;if(s.desired!==t)continue;R.current.delete(e);let a=s.intent;L(t=>{if(t[e]?.intent!==a)return t;let{[e]:n,...r}=t;return r}),n&&i.error(`Webhook toggle failed`,n.message);return}}finally{o.finish()}})()};return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(g,{title:`Webhooks`,description:`HTTP callbacks fired on job events.`,live:!!e&&!t}),t&&e&&(0,A.jsx)(f,{message:`Webhook refresh failed — showing the last successful registry.`,onRetry:l}),D&&(0,A.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:D}),(0,A.jsxs)(d,{className:`mb-6`,children:[(0,A.jsx)(u,{title:`Add webhook`}),(0,A.jsx)(j,{onAdd:e=>r.addWebhook(e),onAccepted:()=>void l(),beginAdd:()=>F.begin([`registry-write`,`add`]),scopeKey:F.scopeKey})]}),t&&!e?(0,A.jsx)(p,{error:t,onRetry:l}):n&&!e?(0,A.jsx)(m,{label:`Loading webhooks…`}):y.length===0?(0,A.jsx)(h,{icon:(0,A.jsx)(o,{}),title:`No webhooks`,hint:`Add one above to receive job-event callbacks.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`URL`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Events`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,A.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Success / Fail`}),(0,A.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Enabled`}),(0,A.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,A.jsx)(`tbody`,{children:y.slice(x*15,x*15+15).map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,A.jsx)(`td`,{className:`max-w-xs truncate px-5 py-3 font-mono text-xs text-fg`,children:O(e.url)}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-xs text-muted`,children:e.events.join(`, `)}),(0,A.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue??`all`}),(0,A.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[(0,A.jsx)(`span`,{className:`text-success`,children:v(e.successCount)}),` / `,(0,A.jsx)(`span`,{className:e.failureCount?`text-danger`:``,children:v(e.failureCount)})]}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:_(e.lastTriggered)}),(0,A.jsx)(`td`,{className:`px-5 py-3`,children:(0,A.jsx)(b,{checked:I[e.id]?.value??e.enabled,label:`${I[e.id]?.value??e.enabled?`Disable`:`Enable`} webhook`,onChange:t=>B(e.id,t)})}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,A.jsx)(c,{"aria-label":`Remove webhook`,disabled:N.has(e.id),onClick:()=>window.confirm(`Remove webhook for ${O(e.url)}?`)&&z(e.id),children:(0,A.jsx)(a,{className:`size-3.5`})})})]},e.id))})]})}),(0,A.jsx)(S,{page:x,pageSize:15,total:y.length,onPageChange:T,label:`webhooks`})]})]})}export{N as Webhooks};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{A as r}from"./icons-C1HVBnFn.js";import{t as i}from"./api-Bbo86MB6.js";import{n as a}from"./usePolledData-Dp_ynL9f.js";import{i as o,n as s,r as c,t as l}from"./feedback-Dxfj-Fy1.js";import{t as u}from"./PageHeader-DD4vnVog.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{r as p}from"./index-CxzFSZj3.js";import{t as m}from"./Pagination-Cj7GzYNX.js";var h=e(t(),1),g=n(),_=20,v={workers:{total:0,active:0,list:[],truncated:!1}};function y(){let{data:e,error:t,loading:n,refetch:y}=a(()=>i.overview(),[]),[b,x]=(0,h.useState)(0);if(n&&!e&&!t)return(0,g.jsx)(c,{label:`Loading workers…`});if(t&&!e)return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(u,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,g.jsx)(s,{error:t,onRetry:y})]});let{workers:S}=e??v,C=Math.max(1,Math.ceil(S.list.length/_)),w=Math.min(b,C-1),T=S.list.slice(w*_,w*_+_);return(0,g.jsxs)(`div`,{children:[t&&(0,g.jsx)(o,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:y}),(0,g.jsx)(u,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!t}),(0,g.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,g.jsx)(p,{label:`Total`,value:f(S.total),compact:!0}),(0,g.jsx)(p,{label:`Active`,value:f(S.active),tone:`green`,compact:!0})]}),S.list.length===0?(0,g.jsx)(l,{icon:(0,g.jsx)(r,{}),title:`No workers registered`,hint:`Workers appear here once they connect and register with the server.`}):(0,g.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,g.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Worker`}),(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last Seen`})]})}),(0,g.jsx)(`tbody`,{children:T.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,g.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,g.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,g.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,g.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:f(e.activeJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:f(e.processedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:f(e.failedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:d(e.lastSeen)})]},e.id))})]})}),S.truncated&&(0,g.jsxs)(`p`,{className:`mt-3 text-xs text-amber-400`,children:[`Showing first `,f(S.list.length),` of `,f(S.total),` `,`workers.`]}),(0,g.jsx)(m,{page:w,pageSize:_,total:S.list.length,onPageChange:x,label:`workers`})]})}export{y as Workers};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{t as r}from"./bq-CSX8DSME.js";import{A as i,O as a}from"./icons-C1HVBnFn.js";import{r as o}from"./StatusBadge-cYUkK-4P.js";import{n as s}from"./usePolledData-Dp_ynL9f.js";import{n as c}from"./Button-BCjgbAhY.js";import{i as l,n as u,r as d,t as f}from"./feedback-Dxfj-Fy1.js";import{t as p}from"./PageHeader-DD4vnVog.js";import{l as m,s as h}from"./format-Cg7VCIZW.js";import{r as g}from"./index-CxzFSZj3.js";import{t as _}from"./Pagination-Cj7GzYNX.js";import{r as v,t as y}from"./useServerActionGuard-Cr4KUOeZ.js";var b=e(t(),1),x=n(),S=`No heartbeat recently — derived from lastSeen`;function C({rows:e,sort:t,busyIds:n,onSort:r,onRemove:i}){return(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Worker`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,x.jsx)(w,{label:`Failed`,active:t?.key===`failed`?t.dir:null,onClick:()=>r(`failed`)})}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,x.jsx)(w,{label:`Last Seen`,active:t?.key===`lastSeen`?t.dir:null,onClick:()=>r(`lastSeen`)})}),(0,x.jsx)(`th`,{className:`w-16 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,x.jsx)(`tbody`,{children:e.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,x.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,x.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,x.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{title:e.status===`active`?void 0:S,className:o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.status===`active`?`bg-emerald-500/10 text-success`:`bg-amber-500/10 text-warning`),children:e.status})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:h(e.activeJobs)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(e.processedJobs)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(e.failedJobs)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:m(e.lastSeen)}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`div`,{className:`flex justify-end`,children:e.status===`stale`&&e.activeJobs===0?(0,x.jsx)(c,{"aria-label":`Remove stale registry record for worker ${e.id}`,title:`Registry cleanup only — does not stop the worker process`,disabled:n.has(e.id),onClick:()=>i(e.id),children:(0,x.jsx)(a,{className:`size-3.5`})}):(0,x.jsx)(`span`,{className:`text-xs text-faint`,title:e.status===`stale`?`Registry cleanup is blocked while active jobs are reported`:`Only stale, idle registry records can be removed`,children:`—`})})})]},e.id))})]})})}function w({label:e,active:t,onClick:n}){return(0,x.jsxs)(`button`,{type:`button`,onClick:n,title:`Sort by ${e}`,className:o(`inline-flex items-center gap-1 uppercase tracking-wider transition-colors hover:text-fg`,t?`text-fg`:`text-faint`),children:[e,(0,x.jsx)(`span`,{"aria-hidden":`true`,children:t===`desc`?`↓`:t===`asc`?`↑`:``})]})}var T=100;function E(){let{data:e,error:t,loading:n,refetch:a}=s(async()=>(await r.workers()).data,[]),[c,m]=(0,b.useState)(new Set),[w,E]=(0,b.useState)(null),[D,O]=(0,b.useState)(null),[k,A]=(0,b.useState)(``),[j,M]=(0,b.useState)(0),N=v(`workers-pro`);if((0,b.useEffect)(()=>{m(new Set),E(null),M(0),A(``)},[N.scopeKey]),n&&!e&&!t)return(0,x.jsx)(d,{label:`Loading workers…`});if(t&&!e)return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(p,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,x.jsx)(u,{error:t,onRetry:a})]});let P=e?.workers??[],F=e?.quarantinedWorkers??[],I=D?[...P].sort((e,t)=>{let n=D.key===`failed`?e.failedJobs??0:e.lastSeen??0,r=D.key===`failed`?t.failedJobs??0:t.lastSeen??0;return D.dir===`asc`?n-r:r-n}):P,L=k.trim().toLowerCase(),R=L?I.filter(e=>[e.name,e.id,e.hostname,e.status,...e.queues].some(e=>e.toLowerCase().includes(L))):I,z=Math.min(j,Math.max(0,Math.ceil(R.length/T)-1)),B=R.slice(z*T,(z+1)*T),V=e=>{M(0),O(t=>t?.key===e?{key:e,dir:t.dir===`desc`?`asc`:`desc`}:{key:e,dir:`desc`})},H=P.filter(e=>e.status===`active`).length,U=P.length-H,W=P.reduce((e,t)=>e+(t.activeJobs??0),0),G=async e=>{if(!window.confirm(`Remove the stale registry record for worker "${e}"? This does not stop the worker process. Continue only after confirming that process is stopped; Bunqueue v2.9.3 workers do not automatically re-register after their heartbeat record is removed.`))return;let t=N.begin(`worker:${e}`);if(t){m(t=>new Set(t).add(e)),E(null);try{if(y(await r.unregisterWorker(e),`Remove stale worker registry record`),!t.isCurrent())return;E({ok:!0,text:`Removed stale registry record for ${e} ✓`}),a()}catch(e){if(!t.isCurrent())return;E({ok:!1,text:`Removal failed: ${e.message}`})}finally{t.finish()&&m(t=>{let n=new Set(t);return n.delete(e),n})}}};return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(p,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!t}),t&&(0,x.jsx)(l,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:a}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,x.jsx)(g,{label:`Total`,value:h(P.length+F.length),compact:!0}),(0,x.jsx)(g,{label:`Active`,value:h(H),tone:`green`,compact:!0}),(0,x.jsx)(`div`,{title:S,children:(0,x.jsx)(g,{label:`Stale`,value:h(U),tone:U?`amber`:`default`,compact:!0})}),(0,x.jsx)(g,{label:`Active Jobs`,value:h(W),tone:`blue`,compact:!0}),(0,x.jsx)(g,{label:`Quarantined`,value:h(F.length),tone:F.length?`red`:`default`,compact:!0})]}),F.length>0&&(0,x.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,x.jsxs)(`p`,{className:`text-sm font-medium text-danger`,children:[F.length,` worker registration(s) contain values accepted by Bunqueue 2.9.3 but unsafe to render. Healthy workers remain available below.`]}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Their status and active-job count are unknown, so this dashboard will not offer the registry-only removal action for them.`}),(0,x.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted`,children:F.slice(0,20).map(e=>(0,x.jsxs)(`li`,{className:`truncate font-mono`,children:[`#`,e.index+1,` `,e.id??`(unaddressable id)`,` — `,e.reason]},`${e.index}:${e.id??`unknown`}`))})]}),w&&(0,x.jsx)(`div`,{className:o(`mb-3 text-sm`,w.ok?`text-success`:`text-danger`),children:w.text}),P.length>0&&(0,x.jsx)(`div`,{className:`mb-4`,children:(0,x.jsx)(`input`,{"aria-label":`Search workers`,name:`workers-search`,value:k,onInput:e=>{A(e.currentTarget.value),M(0)},placeholder:`Search workers, queues or hosts…`,className:`h-9 w-full max-w-sm rounded-lg border border-line bg-surface px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})}),P.length===0?(0,x.jsx)(f,{icon:(0,x.jsx)(i,{}),title:F.length?`No renderable workers`:`No workers registered`,hint:F.length?`Malformed registrations are isolated above instead of taking down the inventory.`:`Workers appear here once they connect and register with the server.`}):R.length===0?(0,x.jsx)(f,{icon:(0,x.jsx)(i,{}),title:`No workers match your search`,hint:`Try a different name, ID, queue, host, or status.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(C,{rows:B,sort:D,busyIds:c,onSort:V,onRemove:e=>void G(e)}),(0,x.jsx)(_,{page:j,pageSize:T,total:R.length,onPageChange:M,label:`workers`})]})]})}export{E as WorkersPro};
|