bunqueue-dashboard 0.0.33 → 0.0.34

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.
Files changed (46) hide show
  1. package/dist/.vite/manifest.json +62 -62
  2. package/dist/assets/{AddJob-ytpBLTCJ.js → AddJob-Cih9F84t.js} +1 -1
  3. package/dist/assets/{Alerts-C39RrGbQ.js → Alerts-Dp4Vclez.js} +1 -1
  4. package/dist/assets/{Benchmark-CM60tHbf.js → Benchmark-X_gdZun5.js} +1 -1
  5. package/dist/assets/{BulkAddJobs-BjL-xcQy.js → BulkAddJobs-CXTpYMZf.js} +1 -1
  6. package/dist/assets/{CopilotPanel-BGK1rw-V.js → CopilotPanel-CIXpcwkH.js} +1 -1
  7. package/dist/assets/{Cron-s1e-jgOo.js → Cron-DUHkse77.js} +1 -1
  8. package/dist/assets/{CronManager-BostU7BX.js → CronManager-BeYrLK2E.js} +1 -1
  9. package/dist/assets/{Database-ZluStWMz.js → Database-CXPb3XGr.js} +1 -1
  10. package/dist/assets/{Diagnostics-C0N5z5j-.js → Diagnostics-DDtoiDYT.js} +1 -1
  11. package/dist/assets/{Dlq-CtcLzs-b.js → Dlq-CX_uRblW.js} +1 -1
  12. package/dist/assets/{DlqControl-B_Z8KKn5.js → DlqControl-CazFmSEd.js} +1 -1
  13. package/dist/assets/{DlqPro-B68en6AG.js → DlqPro-HSffdtLJ.js} +1 -1
  14. package/dist/assets/{Flows-CD_bkCBM.js → Flows-CGmyghKF.js} +1 -1
  15. package/dist/assets/{JobInspector-DwRtyMz0.js → JobInspector-B9i1HnG5.js} +1 -1
  16. package/dist/assets/{Jobs-BUtcBKKk.js → Jobs-BZGtMnJI.js} +1 -1
  17. package/dist/assets/{JobsPro-BK_xd4ji.js → JobsPro-tmEN8f-P.js} +1 -1
  18. package/dist/assets/{Logs-CmVODYCI.js → Logs-DxUD9V2A.js} +1 -1
  19. package/dist/assets/{LogsPro-CJ-Il3LP.js → LogsPro-BTQhvPKj.js} +1 -1
  20. package/dist/assets/{McpServer-dMjyJKgT.js → McpServer-D5rwBg74.js} +1 -1
  21. package/dist/assets/{Metrics-Dsbeplz-.js → Metrics-CSPpBf1m.js} +1 -1
  22. package/dist/assets/{MetricsPro-BqxurxrJ.js → MetricsPro-DSn-3qNT.js} +1 -1
  23. package/dist/assets/{Overview-DH9C2dsf.js → Overview-StvHYRZ5.js} +1 -1
  24. package/dist/assets/{Pagination-DpxiBnt8.js → Pagination-eotgGQf9.js} +1 -1
  25. package/dist/assets/{QueueActions-D_QGBaVm.js → QueueActions-CibRLzrz.js} +1 -1
  26. package/dist/assets/{QueueControl-V0DJ6qk6.js → QueueControl-DwYNcMfI.js} +1 -1
  27. package/dist/assets/{QueueDetail-BgKAMJqf.js → QueueDetail-NMfKwj6E.js} +1 -1
  28. package/dist/assets/{QueueDetailPro-BkHYzGiq.js → QueueDetailPro-C8SBjX09.js} +1 -1
  29. package/dist/assets/{Queues-2_v7DcNi.js → Queues-BeTAi8V8.js} +1 -1
  30. package/dist/assets/{QueuesOverview-BySSkmB4.js → QueuesOverview-BfQO8NS4.js} +1 -1
  31. package/dist/assets/{S3Backup-CPADzKQE.js → S3Backup-BYkAtONl.js} +1 -1
  32. package/dist/assets/{S3BackupPro-CSrQYIDL.js → S3BackupPro-BP1Ch54R.js} +1 -1
  33. package/dist/assets/{ServerControl-C0tI1VDx.js → ServerControl-C85jYgyN.js} +1 -1
  34. package/dist/assets/{Settings-CSzoM5up.js → Settings-DjP28c_5.js} +1 -1
  35. package/dist/assets/{Usage-B4B7tmrc.js → Usage-DECeEsO2.js} +1 -1
  36. package/dist/assets/{UsagePro-CCBpgSDy.js → UsagePro-CD7dgt3d.js} +1 -1
  37. package/dist/assets/{Webhooks-aJz-GisQ.js → Webhooks-Ct-x8DD1.js} +1 -1
  38. package/dist/assets/{Workers-Bg8xKjkg.js → Workers-lP1BXHFq.js} +1 -1
  39. package/dist/assets/{WorkersPro-BOOCrXf8.js → WorkersPro-CAUqy3Cp.js} +1 -1
  40. package/dist/assets/{index-Bn2R06qm.js → index-Dr__4DsT.js} +3 -3
  41. package/dist/assets/install-DPCcfOYo.js +3 -0
  42. package/dist/assets/{useThroughputSeries-tb26_lkb.js → useThroughputSeries-Bpyg6Jaq.js} +1 -1
  43. package/dist/index.html +1 -1
  44. package/package.json +1 -1
  45. package/scripts/embedded.gen.ts +120 -120
  46. package/dist/assets/install-CUS8Kijb.js +0 -3
@@ -1 +1 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{o as r}from"./connectionStore-Cd9-3Fw0.js";import{C as i,S as a,st as o,w as s}from"./index-Bn2R06qm.js";import{a as c,n as l,o as u,t as d}from"./form-DsUq0w8s.js";import{n as f,r as p}from"./useServerActionGuard-CItj3hvh.js";import{i as m,n as h,r as g}from"./flowMutationSafety-DVD1IMr-.js";var _=e(t(),1),v=n();function y(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}return JSON.stringify(e)}function b(e){let[t,n]=(0,_.useState)(e),r=(0,_.useRef)(y(e));return(0,_.useEffect)(()=>{let t=y(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=y(t))}}]}function x(e,t){let n=String(e).trim();if(n===``)return null;let r=Number(n);return Number.isSafeInteger(r)&&r>=t?r:null}function S(e){let t=x(e.stallInterval,0),n=x(e.maxStalls,0),r=x(e.gracePeriod,0);return t===null||n===null||r===null?{ok:!1,error:`Stall interval, max stalls, and grace period must be non-negative whole numbers.`}:{ok:!0,value:{enabled:e.enabled,stallInterval:t,maxStalls:n,gracePeriod:r}}}function C(e){let t=x(e.autoRetryInterval,0),n=x(e.maxAutoRetries,0);return t===null||n===null?{ok:!1,error:`Retry interval and max auto-retries must be non-negative whole numbers.`}:{ok:!0,value:{autoRetry:e.autoRetry,autoRetryInterval:t,maxAutoRetries:n}}}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return typeof e==`number`&&Number.isFinite(e)}function E(e){return w(e)&&typeof e.enabled==`boolean`&&T(e.stallInterval)&&T(e.maxStalls)&&T(e.gracePeriod)}function D(e){return w(e)&&typeof e.autoRetry==`boolean`&&T(e.autoRetryInterval)&&T(e.maxAutoRetries)&&(e.maxAge===null||T(e.maxAge))&&T(e.maxEntries)}function O(e,t){if(!w(e)||e.ok!==!0)throw Error(`Malformed ${t} response: expected { ok: true }.`)}function k(e){let{scopeKey:t,begin:n}=p(e),i=(0,_.useRef)(null),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null);let e=f(),t=r.subscribe(()=>{let t=f();t!==e&&(e=t,i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null))});return()=>{i.current=null,a.current!==null&&window.clearTimeout(a.current),t()}},[t]),{scopeKey:t,saving:o,saved:c,start:()=>{let e=n(`save`);return e?(i.current=e,s(!0),l(!1),e):null},finish:e=>{e.finish(),i.current===e&&(i.current=null,s(!1))},showSaved:e=>{i.current!==e||!e.isCurrent()||(l(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{e.isCurrent()&&l(!1),a.current=null},2e3))}}}function A({queue:e,config:t,onSaved:n}){let[r,c,f]=b(t),[p,m]=(0,_.useState)(null),h=k(`stall-config:${e}`);(0,_.useEffect)(()=>m(null),[h.scopeKey]);let g=S(r);return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Stall detection`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,v.jsx)(u,{checked:r.enabled,onChange:e=>c({...r,enabled:e}),label:`enabled`}),(0,v.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,v.jsx)(d,{label:`Stall interval (ms)`,children:(0,v.jsx)(l,{name:`stall-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.stallInterval,onChange:e=>c({...r,stallInterval:e.target.value})})}),(0,v.jsx)(d,{label:`Max stalls`,children:(0,v.jsx)(l,{name:`stall-max-count`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxStalls,onChange:e=>c({...r,maxStalls:e.target.value})})}),(0,v.jsx)(d,{label:`Grace period (ms)`,children:(0,v.jsx)(l,{name:`stall-grace-period-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.gracePeriod,onChange:e=>c({...r,gracePeriod:e.target.value})})})]}),(0,v.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:h.saving||!g.ok,onClick:async()=>{if(!g.ok)return;let t=h.start();if(t)try{m(null);let r=f();if(O(await o.setStallConfig(e,g.value),`/stall-config`),!t.isCurrent())return;r(g.value),await n(),h.showSaved(t)}catch(e){t.isCurrent()&&m(e.message)}finally{h.finish(t)}},children:`Save`}),h.saved&&(0,v.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!g.ok&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:g.error}),p&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function j({queue:e,config:t,onSaved:n}){let[r,c,f]=b(t),[p,h]=(0,_.useState)(null),g=k(`dlq-config:${e}`);(0,_.useEffect)(()=>h(null),[g.scopeKey]);let y=C(r),x=y.ok&&y.value.autoRetry;return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`DLQ policy`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,v.jsx)(u,{checked:r.autoRetry,disabled:!r.autoRetry,onChange:e=>c({...r,autoRetry:e}),label:`auto-retry`}),(0,v.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,v.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:`Auto-retry can only be disabled. Bunqueue v2.8.55 cannot prove that a DLQ entry has no hidden reverse flow dependents before a background retry.`}),(0,v.jsx)(d,{label:`Retry interval (ms)`,children:(0,v.jsx)(l,{name:`dlq-auto-retry-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.autoRetryInterval,onChange:e=>c({...r,autoRetryInterval:e.target.value})})}),(0,v.jsx)(d,{label:`Max auto-retries`,children:(0,v.jsx)(l,{name:`dlq-max-auto-retries`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxAutoRetries,onChange:e=>c({...r,maxAutoRetries:e.target.value})})}),(0,v.jsx)(d,{label:`Max age (ms)`,children:(0,v.jsx)(l,{name:`dlq-max-age-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxAge??``,readOnly:!0})}),(0,v.jsx)(d,{label:`Max entries`,children:(0,v.jsx)(l,{name:`dlq-max-entries`,autoComplete:`off`,type:`number`,min:1,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxEntries,readOnly:!0})}),(0,v.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:m})]}),(0,v.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:g.saving||!y.ok||x,onClick:async()=>{if(!y.ok)return;let t=g.start();if(t)try{h(null);let i=f();if(O(await o.setDlqConfig(e,y.value),`/dlq-config`),!t.isCurrent())return;i({...r,...y.value}),await n(),g.showSaved(t)}catch(e){t.isCurrent()&&h(e.message)}finally{g.finish(t)}},children:`Save`}),g.saved&&(0,v.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!y.ok&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:y.error}),x&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:`Disable auto-retry before saving this policy.`}),p&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function M({title:e,onRetry:t}){return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:e}),(0,v.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,v.jsx)(s,{size:`sm`,onClick:t,children:`Retry`})]})}function N(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&n>=0&&r>0}}function P(e){if(!e.trim())return{valid:!0};let t=Number(e);return Number.isSafeInteger(t)&&t>0?{count:t,valid:!0}:{valid:!1}}function F(e,t){return t===void 0?`Promote every delayed job in "${e}" and make it eligible to run now?`:`Promote up to ${t} delayed jobs in "${e}" and make them eligible to run now?`}function I(e,t,n){let r=e=>{if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},i=r(e),a=r(t),o=r(n);return{limit:typeof i==`number`?i:0,duration:typeof a==`number`?a:0,...typeof o==`number`?{ttl:o}:{},valid:typeof i==`number`&&typeof a==`number`&&o!==null}}function L(e){let t=Number(e);return{value:t,valid:e.trim()!==``&&Number.isSafeInteger(t)&&t>0}}function R({queue:e,paused:t,busy:n,run:r}){let[u,f]=(0,_.useState)(`0`),[p,m]=(0,_.useState)(`1000`),[y,b]=(0,_.useState)(`completed`),[x,S]=(0,_.useState)(``),C=N(u,p),w=P(x);return(0,v.jsxs)(a,{className:`mb-6`,children:[(0,v.jsx)(i,{title:`Lifecycle`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,v.jsx)(s,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>o.resume(e)),children:`Resume`}):(0,v.jsx)(s,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>o.pause(e)),children:`Pause`}),(0,v.jsx)(s,{size:`sm`,disabled:!0,title:h,children:`Requeue completed`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Promote N`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`promote-count`,"aria-invalid":!w.valid,value:x,onChange:e=>S(e.target.value),placeholder:`all`})})}),(0,v.jsx)(s,{size:`sm`,disabled:n||!w.valid,onClick:()=>r(`Promoted`,()=>o.promoteJobs(e,w.count),F(e,w.count)),children:`Promote delayed`}),!w.valid&&(0,v.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Promote N must be a positive whole number, or blank for all.`})]})]}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:h}),(0,v.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,v.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,v.jsx)(s,{size:`sm`,disabled:!0,title:g,children:`Drain`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`w-40`,children:(0,v.jsx)(d,{label:`State`,children:(0,v.jsxs)(c,{name:`clean-state`,disabled:!0,value:y,onChange:e=>b(e.target.value),children:[(0,v.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,v.jsx)(`option`,{value:`failed`,children:`Failed / DLQ`}),(0,v.jsx)(`option`,{value:`waiting`,children:`Queued`})]})})}),(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Grace (ms)`,children:(0,v.jsx)(l,{type:`number`,min:0,max:2**53-1,step:1,name:`clean-grace`,disabled:!0,"aria-invalid":!C.valid,value:u,onChange:e=>f(e.target.value)})})}),(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Limit`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`clean-limit`,disabled:!0,"aria-invalid":!C.valid,value:p,onChange:e=>m(e.target.value)})})}),(0,v.jsx)(s,{variant:`danger`,size:`sm`,disabled:!0,title:g,children:`Clean`}),!C.valid&&(0,v.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Grace and limit must be whole numbers; limit must be positive.`})]})]}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:g})]})]})}function z({queue:e,busy:t,run:n}){let[r,u]=(0,_.useState)(``),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(`permanent`),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(``),[w,T]=(0,_.useState)(``),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(null),A=I(r,f,m===`expires`?g:``),j=L(b);return(0,v.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Rate-limit desired state`}),(0,v.jsx)(`p`,{className:`mb-3 text-xs text-warning`,children:`Bunqueue v2.8.55 has no read endpoint. This blindly replaces an unknown policy; a receipt proves only what this dashboard applied at that time.`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,v.jsx)(d,{label:`Limit`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-limit`,value:r,onChange:e=>u(e.target.value),placeholder:`max per window`})})}),(0,v.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,v.jsx)(d,{label:`Window (ms)`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-duration`,value:f,onChange:e=>p(e.target.value),placeholder:`60000`})})}),(0,v.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,v.jsx)(d,{label:`TTL`,children:(0,v.jsxs)(c,{name:`rate-ttl-mode`,value:m,onChange:e=>h(e.target.value),children:[(0,v.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,v.jsx)(`option`,{value:`expires`,children:`Expires after`})]})})}),(0,v.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,v.jsx)(d,{label:`TTL (ms)`,hint:m===`permanent`?`Not sent`:void 0,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-ttl`,disabled:m===`permanent`,value:g,onChange:e=>y(e.target.value),placeholder:`—`})})}),(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:t||!A.valid,onClick:()=>n(`Rate limit set`,()=>o.setRateLimit(e,A.limit,A.duration,A.ttl),`Replace the unknown rate-limit policy for "${e}" with limit ${A.limit}, window ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`}?`,()=>D(`Applied limit ${A.limit} per ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`} at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Replace policy`}),(0,v.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,v.jsx)(d,{label:`Type ${e} to clear`,children:(0,v.jsx)(l,{name:`rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:S,onChange:e=>C(e.target.value)})})}),(0,v.jsx)(s,{size:`sm`,disabled:t||S!==e,onClick:()=>n(`No rate limit ensured`,()=>o.clearRateLimit(e),`Ensure queue "${e}" has no rate-limit policy? Bunqueue v2.8.55 cannot report its previous value.`,()=>D(`Applied no rate-limit policy at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Ensure no rate limit`}),!A.valid&&(r.trim()||f.trim()||g.trim())&&(0,v.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-danger`,children:`Limit and window are required; all values must be positive whole numbers.`}),E&&(0,v.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:E})]})]}),(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Concurrency desired state`}),(0,v.jsx)(`p`,{className:`mb-3 text-xs text-warning`,children:`Bunqueue v2.8.55 has no read endpoint. This blindly replaces an unknown policy; a receipt proves only what this dashboard applied at that time.`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,v.jsx)(d,{label:`Concurrency`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`concurrency`,value:b,onChange:e=>x(e.target.value),placeholder:`max in-flight`})})}),(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:t||!j.valid,onClick:()=>n(`Concurrency set`,()=>o.setConcurrency(e,j.value),`Replace the unknown concurrency policy for "${e}" with ${j.value} maximum in-flight jobs?`,()=>k(`Applied concurrency ${j.value} at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Replace policy`}),(0,v.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,v.jsx)(d,{label:`Type ${e} to clear`,children:(0,v.jsx)(l,{name:`concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:w,onChange:e=>T(e.target.value)})})}),(0,v.jsx)(s,{size:`sm`,disabled:t||w!==e,onClick:()=>n(`No concurrency limit ensured`,()=>o.clearConcurrency(e),`Ensure queue "${e}" has no concurrency policy? Bunqueue v2.8.55 cannot report its previous value.`,()=>k(`Applied no concurrency policy at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Ensure no concurrency limit`}),!j.valid&&b.trim()&&(0,v.jsx)(`span`,{role:`alert`,className:`self-center text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),O&&(0,v.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:O})]})]})]})}export{A as a,j as i,z as n,D as o,M as r,E as s,R as t};
1
+ import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{o as r}from"./connectionStore-Cd9-3Fw0.js";import{C as i,S as a,st as o,w as s}from"./index-Dr__4DsT.js";import{a as c,n as l,o as u,t as d}from"./form-DsUq0w8s.js";import{n as f,r as p}from"./useServerActionGuard-CItj3hvh.js";import{i as m,n as h,r as g}from"./flowMutationSafety-DVD1IMr-.js";var _=e(t(),1),v=n();function y(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}return JSON.stringify(e)}function b(e){let[t,n]=(0,_.useState)(e),r=(0,_.useRef)(y(e));return(0,_.useEffect)(()=>{let t=y(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=y(t))}}]}function x(e,t){let n=String(e).trim();if(n===``)return null;let r=Number(n);return Number.isSafeInteger(r)&&r>=t?r:null}function S(e){let t=x(e.stallInterval,0),n=x(e.maxStalls,0),r=x(e.gracePeriod,0);return t===null||n===null||r===null?{ok:!1,error:`Stall interval, max stalls, and grace period must be non-negative whole numbers.`}:{ok:!0,value:{enabled:e.enabled,stallInterval:t,maxStalls:n,gracePeriod:r}}}function C(e){let t=x(e.autoRetryInterval,0),n=x(e.maxAutoRetries,0);return t===null||n===null?{ok:!1,error:`Retry interval and max auto-retries must be non-negative whole numbers.`}:{ok:!0,value:{autoRetry:e.autoRetry,autoRetryInterval:t,maxAutoRetries:n}}}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return typeof e==`number`&&Number.isFinite(e)}function E(e){return w(e)&&typeof e.enabled==`boolean`&&T(e.stallInterval)&&T(e.maxStalls)&&T(e.gracePeriod)}function D(e){return w(e)&&typeof e.autoRetry==`boolean`&&T(e.autoRetryInterval)&&T(e.maxAutoRetries)&&(e.maxAge===null||T(e.maxAge))&&T(e.maxEntries)}function O(e,t){if(!w(e)||e.ok!==!0)throw Error(`Malformed ${t} response: expected { ok: true }.`)}function k(e){let{scopeKey:t,begin:n}=p(e),i=(0,_.useRef)(null),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null);let e=f(),t=r.subscribe(()=>{let t=f();t!==e&&(e=t,i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null))});return()=>{i.current=null,a.current!==null&&window.clearTimeout(a.current),t()}},[t]),{scopeKey:t,saving:o,saved:c,start:()=>{let e=n(`save`);return e?(i.current=e,s(!0),l(!1),e):null},finish:e=>{e.finish(),i.current===e&&(i.current=null,s(!1))},showSaved:e=>{i.current!==e||!e.isCurrent()||(l(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{e.isCurrent()&&l(!1),a.current=null},2e3))}}}function A({queue:e,config:t,onSaved:n}){let[r,c,f]=b(t),[p,m]=(0,_.useState)(null),h=k(`stall-config:${e}`);(0,_.useEffect)(()=>m(null),[h.scopeKey]);let g=S(r);return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Stall detection`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,v.jsx)(u,{checked:r.enabled,onChange:e=>c({...r,enabled:e}),label:`enabled`}),(0,v.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,v.jsx)(d,{label:`Stall interval (ms)`,children:(0,v.jsx)(l,{name:`stall-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.stallInterval,onChange:e=>c({...r,stallInterval:e.target.value})})}),(0,v.jsx)(d,{label:`Max stalls`,children:(0,v.jsx)(l,{name:`stall-max-count`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxStalls,onChange:e=>c({...r,maxStalls:e.target.value})})}),(0,v.jsx)(d,{label:`Grace period (ms)`,children:(0,v.jsx)(l,{name:`stall-grace-period-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.gracePeriod,onChange:e=>c({...r,gracePeriod:e.target.value})})})]}),(0,v.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:h.saving||!g.ok,onClick:async()=>{if(!g.ok)return;let t=h.start();if(t)try{m(null);let r=f();if(O(await o.setStallConfig(e,g.value),`/stall-config`),!t.isCurrent())return;r(g.value),await n(),h.showSaved(t)}catch(e){t.isCurrent()&&m(e.message)}finally{h.finish(t)}},children:`Save`}),h.saved&&(0,v.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!g.ok&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:g.error}),p&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function j({queue:e,config:t,onSaved:n}){let[r,c,f]=b(t),[p,h]=(0,_.useState)(null),g=k(`dlq-config:${e}`);(0,_.useEffect)(()=>h(null),[g.scopeKey]);let y=C(r),x=y.ok&&y.value.autoRetry;return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`DLQ policy`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,v.jsx)(u,{checked:r.autoRetry,disabled:!r.autoRetry,onChange:e=>c({...r,autoRetry:e}),label:`auto-retry`}),(0,v.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,v.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:`Auto-retry can only be disabled. Bunqueue v2.8.55 cannot prove that a DLQ entry has no hidden reverse flow dependents before a background retry.`}),(0,v.jsx)(d,{label:`Retry interval (ms)`,children:(0,v.jsx)(l,{name:`dlq-auto-retry-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.autoRetryInterval,onChange:e=>c({...r,autoRetryInterval:e.target.value})})}),(0,v.jsx)(d,{label:`Max auto-retries`,children:(0,v.jsx)(l,{name:`dlq-max-auto-retries`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxAutoRetries,onChange:e=>c({...r,maxAutoRetries:e.target.value})})}),(0,v.jsx)(d,{label:`Max age (ms)`,children:(0,v.jsx)(l,{name:`dlq-max-age-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxAge??``,readOnly:!0})}),(0,v.jsx)(d,{label:`Max entries`,children:(0,v.jsx)(l,{name:`dlq-max-entries`,autoComplete:`off`,type:`number`,min:1,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxEntries,readOnly:!0})}),(0,v.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:m})]}),(0,v.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:g.saving||!y.ok||x,onClick:async()=>{if(!y.ok)return;let t=g.start();if(t)try{h(null);let i=f();if(O(await o.setDlqConfig(e,y.value),`/dlq-config`),!t.isCurrent())return;i({...r,...y.value}),await n(),g.showSaved(t)}catch(e){t.isCurrent()&&h(e.message)}finally{g.finish(t)}},children:`Save`}),g.saved&&(0,v.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!y.ok&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:y.error}),x&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:`Disable auto-retry before saving this policy.`}),p&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function M({title:e,onRetry:t}){return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:e}),(0,v.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,v.jsx)(s,{size:`sm`,onClick:t,children:`Retry`})]})}function N(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&n>=0&&r>0}}function P(e){if(!e.trim())return{valid:!0};let t=Number(e);return Number.isSafeInteger(t)&&t>0?{count:t,valid:!0}:{valid:!1}}function F(e,t){return t===void 0?`Promote every delayed job in "${e}" and make it eligible to run now?`:`Promote up to ${t} delayed jobs in "${e}" and make them eligible to run now?`}function I(e,t,n){let r=e=>{if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},i=r(e),a=r(t),o=r(n);return{limit:typeof i==`number`?i:0,duration:typeof a==`number`?a:0,...typeof o==`number`?{ttl:o}:{},valid:typeof i==`number`&&typeof a==`number`&&o!==null}}function L(e){let t=Number(e);return{value:t,valid:e.trim()!==``&&Number.isSafeInteger(t)&&t>0}}function R({queue:e,paused:t,busy:n,run:r}){let[u,f]=(0,_.useState)(`0`),[p,m]=(0,_.useState)(`1000`),[y,b]=(0,_.useState)(`completed`),[x,S]=(0,_.useState)(``),C=N(u,p),w=P(x);return(0,v.jsxs)(a,{className:`mb-6`,children:[(0,v.jsx)(i,{title:`Lifecycle`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,v.jsx)(s,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>o.resume(e)),children:`Resume`}):(0,v.jsx)(s,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>o.pause(e)),children:`Pause`}),(0,v.jsx)(s,{size:`sm`,disabled:!0,title:h,children:`Requeue completed`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Promote N`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`promote-count`,"aria-invalid":!w.valid,value:x,onChange:e=>S(e.target.value),placeholder:`all`})})}),(0,v.jsx)(s,{size:`sm`,disabled:n||!w.valid,onClick:()=>r(`Promoted`,()=>o.promoteJobs(e,w.count),F(e,w.count)),children:`Promote delayed`}),!w.valid&&(0,v.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Promote N must be a positive whole number, or blank for all.`})]})]}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:h}),(0,v.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,v.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,v.jsx)(s,{size:`sm`,disabled:!0,title:g,children:`Drain`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`w-40`,children:(0,v.jsx)(d,{label:`State`,children:(0,v.jsxs)(c,{name:`clean-state`,disabled:!0,value:y,onChange:e=>b(e.target.value),children:[(0,v.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,v.jsx)(`option`,{value:`failed`,children:`Failed / DLQ`}),(0,v.jsx)(`option`,{value:`waiting`,children:`Queued`})]})})}),(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Grace (ms)`,children:(0,v.jsx)(l,{type:`number`,min:0,max:2**53-1,step:1,name:`clean-grace`,disabled:!0,"aria-invalid":!C.valid,value:u,onChange:e=>f(e.target.value)})})}),(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Limit`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`clean-limit`,disabled:!0,"aria-invalid":!C.valid,value:p,onChange:e=>m(e.target.value)})})}),(0,v.jsx)(s,{variant:`danger`,size:`sm`,disabled:!0,title:g,children:`Clean`}),!C.valid&&(0,v.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Grace and limit must be whole numbers; limit must be positive.`})]})]}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:g})]})]})}function z({queue:e,busy:t,run:n}){let[r,u]=(0,_.useState)(``),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(`permanent`),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(``),[w,T]=(0,_.useState)(``),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(null),A=I(r,f,m===`expires`?g:``),j=L(b);return(0,v.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Rate-limit desired state`}),(0,v.jsx)(`p`,{className:`mb-3 text-xs text-warning`,children:`Bunqueue v2.8.55 has no read endpoint. This blindly replaces an unknown policy; a receipt proves only what this dashboard applied at that time.`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,v.jsx)(d,{label:`Limit`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-limit`,value:r,onChange:e=>u(e.target.value),placeholder:`max per window`})})}),(0,v.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,v.jsx)(d,{label:`Window (ms)`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-duration`,value:f,onChange:e=>p(e.target.value),placeholder:`60000`})})}),(0,v.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,v.jsx)(d,{label:`TTL`,children:(0,v.jsxs)(c,{name:`rate-ttl-mode`,value:m,onChange:e=>h(e.target.value),children:[(0,v.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,v.jsx)(`option`,{value:`expires`,children:`Expires after`})]})})}),(0,v.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,v.jsx)(d,{label:`TTL (ms)`,hint:m===`permanent`?`Not sent`:void 0,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-ttl`,disabled:m===`permanent`,value:g,onChange:e=>y(e.target.value),placeholder:`—`})})}),(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:t||!A.valid,onClick:()=>n(`Rate limit set`,()=>o.setRateLimit(e,A.limit,A.duration,A.ttl),`Replace the unknown rate-limit policy for "${e}" with limit ${A.limit}, window ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`}?`,()=>D(`Applied limit ${A.limit} per ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`} at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Replace policy`}),(0,v.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,v.jsx)(d,{label:`Type ${e} to clear`,children:(0,v.jsx)(l,{name:`rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:S,onChange:e=>C(e.target.value)})})}),(0,v.jsx)(s,{size:`sm`,disabled:t||S!==e,onClick:()=>n(`No rate limit ensured`,()=>o.clearRateLimit(e),`Ensure queue "${e}" has no rate-limit policy? Bunqueue v2.8.55 cannot report its previous value.`,()=>D(`Applied no rate-limit policy at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Ensure no rate limit`}),!A.valid&&(r.trim()||f.trim()||g.trim())&&(0,v.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-danger`,children:`Limit and window are required; all values must be positive whole numbers.`}),E&&(0,v.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:E})]})]}),(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Concurrency desired state`}),(0,v.jsx)(`p`,{className:`mb-3 text-xs text-warning`,children:`Bunqueue v2.8.55 has no read endpoint. This blindly replaces an unknown policy; a receipt proves only what this dashboard applied at that time.`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,v.jsx)(d,{label:`Concurrency`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`concurrency`,value:b,onChange:e=>x(e.target.value),placeholder:`max in-flight`})})}),(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:t||!j.valid,onClick:()=>n(`Concurrency set`,()=>o.setConcurrency(e,j.value),`Replace the unknown concurrency policy for "${e}" with ${j.value} maximum in-flight jobs?`,()=>k(`Applied concurrency ${j.value} at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Replace policy`}),(0,v.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,v.jsx)(d,{label:`Type ${e} to clear`,children:(0,v.jsx)(l,{name:`concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:w,onChange:e=>T(e.target.value)})})}),(0,v.jsx)(s,{size:`sm`,disabled:t||w!==e,onClick:()=>n(`No concurrency limit ensured`,()=>o.clearConcurrency(e),`Ensure queue "${e}" has no concurrency policy? Bunqueue v2.8.55 cannot report its previous value.`,()=>k(`Applied no concurrency policy at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Ensure no concurrency limit`}),!j.valid&&b.trim()&&(0,v.jsx)(`span`,{role:`alert`,className:`self-center text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),O&&(0,v.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:O})]})]})]})}export{A as a,j as i,z as n,D as o,M as r,E as s,R as t};
@@ -1 +1 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{A as r,_ as i,b as a,c as o,h as s,m as c,st as l,x as u,y as d}from"./index-Bn2R06qm.js";import{a as f}from"./form-DsUq0w8s.js";import{r as p}from"./useServerActionGuard-CItj3hvh.js";import{a as m,i as h,n as g,o as _,r as v,s as y,t as b}from"./QueueActions-D_QGBaVm.js";var x=e(t(),1),S=n(),C=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],w=500,T=200,E=w*T;function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function k(e){return D(e)&&C.every(t=>O(e[t]))}function A(e,t){if(!D(e)||e.ok!==!0||!Array.isArray(e.queues)||!O(e.total)||!O(e.limit)||e.limit<1||!O(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>D(e)&&typeof e.name==`string`&&e.name.length>0&&O(e.waiting)&&O(e.delayed)&&O(e.active)&&O(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function j(){let e=await l.queues(w,0);A(e,0);let t=e.total;if(t>E)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${E}.`);if(e.queues.length!==Math.min(w,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(w,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 i=e.queues.length,a=1;for(;i<t;){if(a>=T)throw Error(`Queue discovery exceeded the safe limit of ${T} pages.`);let e=await l.queues(w,i);if(A(e,i),e.total!==t)throw Error(`Queue discovery changed during pagination: total moved from ${t} to ${e.total}. Retry the snapshot.`);let n=Math.min(w,t-i);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${i}: expected ${n} queues, received ${e.queues.length}.`);r(e),i+=e.queues.length,a+=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:w,offset:0}}function M(e,t){if(!D(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!k(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function N(e){if(!D(e)||e.ok!==!0||!y(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function P(e){if(!D(e)||e.ok!==!0||!_(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function F(e){if(!D(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!O(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function I(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function L(){let[e,t]=(0,x.useState)(``),[n,_]=(0,x.useState)(!1),[y,w]=(0,x.useState)(null),T=p(`queue-control:${e}`);(0,x.useEffect)(()=>{_(!1),w(null)},[T.scopeKey]);let{data:E,error:D,loading:O,refetch:k}=r(j,[],{intervalMs:3e4});(0,x.useEffect)(()=>{E&&t(e=>I(e,E.queues))},[E]);let{data:A,error:L,loading:R,refetch:z}=r((0,x.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([l.queueDetail(e,!1),l.getStallConfig(e).then(N).catch(()=>null),l.getDlqConfig(e).then(P).catch(()=>null)]);return M(t,e),{queue:e,detail:t,stall:n,dlq:r}},[e]),[e]),B=!E||E.queues.some(t=>t.name===e),V=A&&A.queue===e&&B?A:null,H=(t,n,r,i)=>{let a=e;if(!a||r&&!window.confirm(r))return;let o=T.begin(`queue-write`);o&&(_(!0),w(null),(async()=>{try{let e=await l.queuesSummary();if(!o.isCurrent())return;if(!e.some(e=>e.name===a))throw Error(`Queue "${a}" no longer exists`);let r=F(await n());if(!o.isCurrent())return;w({queue:a,ok:!0,text:`${t}${r==null?` ✓`:`: ${r}`}`}),i?.(),await z()}catch(e){o.isCurrent()&&w({queue:a,ok:!1,text:e.message})}finally{o.finish()&&_(!1)}})())};return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(s,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!V?.detail&&!!V.stall&&!!V.dlq&&!L&&!D}),(0,S.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`w-56`,children:(0,S.jsx)(f,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(E?.queues??[]).map(e=>(0,S.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),V?.detail&&(0,S.jsx)(i,{label:V.detail.paused?`Paused`:`Active`,tone:V.detail.paused?`amber`:`green`}),y?.queue===e&&(0,S.jsx)(`span`,{role:`status`,className:y.ok?`text-xs text-success`:`text-xs text-danger`,children:y.text})]}),D&&(0,S.jsx)(u,{onRetry:k,message:`Could not discover queues — ${D.message}. Retry to choose a queue.`}),L&&V&&(0,S.jsx)(u,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:z}),L&&!V?(0,S.jsx)(d,{error:L,onRetry:z}):O&&!E&&!e&&!D?(0,S.jsx)(a,{label:`Discovering queues…`}):R&&!V?(0,S.jsx)(a,{}):D&&!e?(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):V?.detail?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:C.map(e=>(0,S.jsx)(c,{label:e,value:o(V.detail.counts[e]),compact:!0},e))}),(0,S.jsx)(b,{queue:e,paused:V.detail.paused,busy:n,run:H},`${e}:lifecycle`),(0,S.jsx)(g,{queue:e,busy:n,run:H},`${e}:limits`),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[V.stall?(0,S.jsx)(m,{queue:e,config:V.stall,onSaved:async()=>{w({queue:e,ok:!0,text:`Stall config saved ✓`}),await z()}},`${e}:stall`):(0,S.jsx)(v,{title:`Stall detection`,onRetry:z}),V.dlq?(0,S.jsx)(h,{queue:e,config:V.dlq,onSaved:async()=>{w({queue:e,ok:!0,text:`DLQ config saved ✓`}),await z()}},`${e}:dlq`):(0,S.jsx)(v,{title:`DLQ policy`,onRetry:z})]})]}):!L&&(0,S.jsx)(`p`,{className:`text-sm text-faint`,children:E?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{L as QueueControl,j as loadAllQueuePages};
1
+ import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{A as r,_ as i,b as a,c as o,h as s,m as c,st as l,x as u,y as d}from"./index-Dr__4DsT.js";import{a as f}from"./form-DsUq0w8s.js";import{r as p}from"./useServerActionGuard-CItj3hvh.js";import{a as m,i as h,n as g,o as _,r as v,s as y,t as b}from"./QueueActions-CibRLzrz.js";var x=e(t(),1),S=n(),C=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],w=500,T=200,E=w*T;function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function k(e){return D(e)&&C.every(t=>O(e[t]))}function A(e,t){if(!D(e)||e.ok!==!0||!Array.isArray(e.queues)||!O(e.total)||!O(e.limit)||e.limit<1||!O(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>D(e)&&typeof e.name==`string`&&e.name.length>0&&O(e.waiting)&&O(e.delayed)&&O(e.active)&&O(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function j(){let e=await l.queues(w,0);A(e,0);let t=e.total;if(t>E)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${E}.`);if(e.queues.length!==Math.min(w,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(w,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 i=e.queues.length,a=1;for(;i<t;){if(a>=T)throw Error(`Queue discovery exceeded the safe limit of ${T} pages.`);let e=await l.queues(w,i);if(A(e,i),e.total!==t)throw Error(`Queue discovery changed during pagination: total moved from ${t} to ${e.total}. Retry the snapshot.`);let n=Math.min(w,t-i);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${i}: expected ${n} queues, received ${e.queues.length}.`);r(e),i+=e.queues.length,a+=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:w,offset:0}}function M(e,t){if(!D(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!k(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function N(e){if(!D(e)||e.ok!==!0||!y(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function P(e){if(!D(e)||e.ok!==!0||!_(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function F(e){if(!D(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!O(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function I(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function L(){let[e,t]=(0,x.useState)(``),[n,_]=(0,x.useState)(!1),[y,w]=(0,x.useState)(null),T=p(`queue-control:${e}`);(0,x.useEffect)(()=>{_(!1),w(null)},[T.scopeKey]);let{data:E,error:D,loading:O,refetch:k}=r(j,[],{intervalMs:3e4});(0,x.useEffect)(()=>{E&&t(e=>I(e,E.queues))},[E]);let{data:A,error:L,loading:R,refetch:z}=r((0,x.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([l.queueDetail(e,!1),l.getStallConfig(e).then(N).catch(()=>null),l.getDlqConfig(e).then(P).catch(()=>null)]);return M(t,e),{queue:e,detail:t,stall:n,dlq:r}},[e]),[e]),B=!E||E.queues.some(t=>t.name===e),V=A&&A.queue===e&&B?A:null,H=(t,n,r,i)=>{let a=e;if(!a||r&&!window.confirm(r))return;let o=T.begin(`queue-write`);o&&(_(!0),w(null),(async()=>{try{let e=await l.queuesSummary();if(!o.isCurrent())return;if(!e.some(e=>e.name===a))throw Error(`Queue "${a}" no longer exists`);let r=F(await n());if(!o.isCurrent())return;w({queue:a,ok:!0,text:`${t}${r==null?` ✓`:`: ${r}`}`}),i?.(),await z()}catch(e){o.isCurrent()&&w({queue:a,ok:!1,text:e.message})}finally{o.finish()&&_(!1)}})())};return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(s,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!V?.detail&&!!V.stall&&!!V.dlq&&!L&&!D}),(0,S.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`w-56`,children:(0,S.jsx)(f,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(E?.queues??[]).map(e=>(0,S.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),V?.detail&&(0,S.jsx)(i,{label:V.detail.paused?`Paused`:`Active`,tone:V.detail.paused?`amber`:`green`}),y?.queue===e&&(0,S.jsx)(`span`,{role:`status`,className:y.ok?`text-xs text-success`:`text-xs text-danger`,children:y.text})]}),D&&(0,S.jsx)(u,{onRetry:k,message:`Could not discover queues — ${D.message}. Retry to choose a queue.`}),L&&V&&(0,S.jsx)(u,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:z}),L&&!V?(0,S.jsx)(d,{error:L,onRetry:z}):O&&!E&&!e&&!D?(0,S.jsx)(a,{label:`Discovering queues…`}):R&&!V?(0,S.jsx)(a,{}):D&&!e?(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):V?.detail?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:C.map(e=>(0,S.jsx)(c,{label:e,value:o(V.detail.counts[e]),compact:!0},e))}),(0,S.jsx)(b,{queue:e,paused:V.detail.paused,busy:n,run:H},`${e}:lifecycle`),(0,S.jsx)(g,{queue:e,busy:n,run:H},`${e}:limits`),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[V.stall?(0,S.jsx)(m,{queue:e,config:V.stall,onSaved:async()=>{w({queue:e,ok:!0,text:`Stall config saved ✓`}),await z()}},`${e}:stall`):(0,S.jsx)(v,{title:`Stall detection`,onRetry:z}),V.dlq?(0,S.jsx)(h,{queue:e,config:V.dlq,onSaved:async()=>{w({queue:e,ok:!0,text:`DLQ config saved ✓`}),await z()}},`${e}:dlq`):(0,S.jsx)(v,{title:`DLQ policy`,onRetry:z})]})]}):!L&&(0,S.jsx)(`p`,{className:`text-sm text-faint`,children:E?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{L as QueueControl,j as loadAllQueuePages};
@@ -1 +1 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{d as t,g as n,r,t as i}from"./react-vendor-Bjui4wS4.js";import{A as a,M as o,P as s,S as c,U as l,V as u,W as d,X as f,_ as p,b as m,c as h,f as g,g as _,j as v,l as y,m as b,n as x,o as S,st as C,u as w,v as T,w as E,x as D}from"./index-Bn2R06qm.js";import{a as O,n as k,t as A}from"./form-DsUq0w8s.js";import{r as j,t as M}from"./useServerActionGuard-CItj3hvh.js";import{r as N}from"./flowMutationSafety-DVD1IMr-.js";var P=e(n(),1),F=i();function I({queue:e}){return(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.8.55 cannot read either current policy. Every command below is an explicit blind desired-state write; a receipt proves only what this dashboard applied at that time.`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,F.jsx)(z,{queue:e}),(0,F.jsx)(B,{queue:e})]})]})}function L(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function R(e,t){let[n,r]=(0,P.useState)(!1),[i,a]=(0,P.useState)(null),[o,s]=(0,P.useState)(null),c=j(`classic-queue-policy:${e}:${t}`);return(0,P.useEffect)(()=>{r(!1),a(null),s(null)},[c.scopeKey]),{busy:n,error:i,receipt:o,run:async(n,i,o)=>{if(!window.confirm(i))return;let l=c.begin(t);if(l){r(!0),a(null),s(null);try{let t=await C.queuesSummary();if(!l.isCurrent())return;if(!t.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await o(),n),!l.isCurrent())return;s(`${n} applied at ${new Date().toISOString()}. Current server state cannot be read.`)}catch(e){l.isCurrent()&&a(e.message)}finally{l.finish()&&r(!1)}}}}}function z({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),[a,o]=(0,P.useState)(`permanent`),[s,l]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),{busy:p,error:m,receipt:h,run:g}=R(e,`rate-limit`),_=L(t),v=L(r),y=a===`expires`?L(s):void 0,b=_!==null&&v!==null&&(a===`permanent`||y!=null);return(0,F.jsxs)(c,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,F.jsx)(u,{className:`size-4 text-faint`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsx)(A,{label:`Limit`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-limit`,value:t,"aria-invalid":t.trim()!==``&&_===null,onChange:e=>n(e.target.value),placeholder:`100`})}),(0,F.jsx)(A,{label:`Window (ms)`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-duration`,value:r,"aria-invalid":r.trim()!==``&&v===null,onChange:e=>i(e.target.value),placeholder:`60000`})}),(0,F.jsx)(A,{label:`TTL`,children:(0,F.jsxs)(O,{name:`classic-rate-ttl-mode`,value:a,onChange:e=>o(e.target.value),children:[(0,F.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,F.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,F.jsx)(A,{label:`TTL (ms)`,hint:a===`permanent`?`Not sent`:void 0,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-ttl`,disabled:a===`permanent`,value:s,"aria-invalid":a===`expires`&&s.trim()!==``&&y==null,onChange:e=>l(e.target.value),placeholder:`3600000`})})]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,F.jsx)(E,{variant:`accent`,size:`sm`,disabled:p||!b,onClick:()=>{if(_===null||v===null||a===`expires`&&y===null)return;let t=typeof y==`number`?y:void 0,n=a===`permanent`?`permanent`:`TTL ${y}ms`;g(`Rate-limit policy replaced`,`Replace the unknown rate-limit policy for "${e}" with limit ${_}, window ${v}ms, ${n}?`,()=>C.setRateLimit(e,_,v,t))},children:`Replace rate-limit policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,F.jsx)(E,{className:`mt-2`,size:`sm`,disabled:p||d!==e,onClick:()=>void g(`No rate limit ensured`,`Ensure queue "${e}" has no rate-limit policy? The previous value is unavailable.`,()=>C.clearRateLimit(e)),children:`Ensure no rate limit`})]}),h&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:h}),m&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:m})]})}function B({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),{busy:a,error:o,receipt:s,run:l}=R(e,`concurrency`),u=L(t);return(0,F.jsxs)(c,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,F.jsx)(f,{className:`size-4 text-faint`})]}),(0,F.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-concurrency`,value:t,"aria-invalid":t.trim()!==``&&u===null,onChange:e=>n(e.target.value),placeholder:`5`})}),(0,F.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,F.jsx)(E,{variant:`accent`,size:`sm`,disabled:a||u===null,onClick:()=>{u!==null&&l(`Concurrency policy replaced`,`Replace the unknown concurrency policy for "${e}" with ${u} maximum in-flight jobs?`,()=>C.setConcurrency(e,u))},children:`Replace concurrency policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,F.jsx)(E,{className:`mt-2`,size:`sm`,disabled:a||r!==e,onClick:()=>void l(`No concurrency limit ensured`,`Ensure queue "${e}" has no concurrency policy? The previous value is unavailable.`,()=>C.clearConcurrency(e)),children:`Ensure no concurrency limit`})]}),s&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:s}),o&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:o})]})}var V=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],H={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,"waiting-children":0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[],recentJobsError:null};function U(){let{name:e=``}=t(),[n,i]=(0,P.useState)(null),[c,u]=(0,P.useState)(null),f=j(`classic-queue:${e}`);(0,P.useEffect)(()=>{i(null),u(null)},[f.scopeKey]);let{data:O,error:k,loading:A,refetch:L}=a((0,P.useCallback)(async()=>{if(!(await C.queuesSummary()).some(t=>t.name===e))return{exists:!1,detail:null,jobs:[],recentJobsError:null};let[t,n]=await Promise.all([v.queueDetail(e,!1),v.jobsList(e,{states:V,limit:12}).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);if(t.ok!==!0||t.name!==e)throw Error(`Malformed queue detail response for "${e}"`);return{exists:!0,detail:t,jobs:n.jobs,recentJobsError:n.error}},[e]),[e]),R=async(t,n,r)=>{if(r&&!window.confirm(r))return;let a=f.begin(t);if(a){i(t),u(null);try{let r=await C.queuesSummary();if(!a.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await n(),t),!a.isCurrent())return;await L()}catch(e){a.isCurrent()&&u(e.message)}finally{a.finish()&&i(null)}}};if(A&&!O&&!k)return(0,F.jsx)(m,{label:`Loading ${e}…`});if(k&&!O)return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(D,{onRetry:L})]});if(O?.exists===!1)return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(D,{onRetry:L}),(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(T,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,F.jsx)(r,{to:`/queues-classic`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to classic queues`})})]});let z=O?.exists===!0?O:H,{detail:B}=z,U=B.counts,W=x(U.completed??0,U.failed??0),G=[...z.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(D,{onRetry:L}),(0,F.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(r,{to:`/queues-classic`,"aria-label":`Back to classic queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,F.jsx)(s,{className:`size-4`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,F.jsx)(p,{label:B.paused?`Paused`:`Active`,tone:B.paused?`amber`:`green`}),(0,F.jsx)(p,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B.paused?(0,F.jsxs)(E,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>R(`resume`,()=>v.resume(e)),children:[(0,F.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,F.jsxs)(E,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>R(`pause`,()=>v.pause(e)),children:[(0,F.jsx)(l,{className:`size-3.5`}),` Pause`]}),(0,F.jsx)(E,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,F.jsx)(E,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),c&&(0,F.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:c}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,F.jsx)(b,{label:`Waiting`,value:h(U.waiting),tone:`amber`}),(0,F.jsx)(b,{label:`Active`,value:h(U.active),tone:`blue`}),(0,F.jsx)(b,{label:`Completed`,value:h(U.completed),tone:`green`}),(0,F.jsx)(b,{label:`Failed`,value:h(U.failed),tone:U.failed?`red`:`default`}),(0,F.jsx)(b,{label:`Delayed`,value:h(U.delayed),tone:`default`}),(0,F.jsx)(b,{label:`Error Rate`,value:W==null?`—`:y(W),tone:W==null?`default`:W>.05?`red`:`green`})]}),(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,F.jsxs)(r,{to:`/jobs-classic?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,F.jsx)(o,{className:`size-3.5`})]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,F.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,F.jsx)(`tbody`,{children:z.recentJobsError?(0,F.jsx)(`tr`,{children:(0,F.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,z.recentJobsError,`. Retry the page.`]})}):G.length===0?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.map(e=>(0,F.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,F.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,F.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e.id})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,F.jsx)(`td`,{className:`px-5 py-3`,children:(0,F.jsx)(_,{status:String(e.state??e.status??`waiting`)})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:S(g(e.startedAt,e.completedAt))}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,F.jsx)(I,{queue:e})]})}export{U as QueueDetail};
1
+ import{r as e}from"./cn-CMFYpumL.js";import{d as t,g as n,r,t as i}from"./react-vendor-Bjui4wS4.js";import{A as a,M as o,P as s,S as c,U as l,V as u,W as d,X as f,_ as p,b as m,c as h,f as g,g as _,j as v,l as y,m as b,n as x,o as S,st as C,u as w,v as T,w as E,x as D}from"./index-Dr__4DsT.js";import{a as O,n as k,t as A}from"./form-DsUq0w8s.js";import{r as j,t as M}from"./useServerActionGuard-CItj3hvh.js";import{r as N}from"./flowMutationSafety-DVD1IMr-.js";var P=e(n(),1),F=i();function I({queue:e}){return(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.8.55 cannot read either current policy. Every command below is an explicit blind desired-state write; a receipt proves only what this dashboard applied at that time.`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,F.jsx)(z,{queue:e}),(0,F.jsx)(B,{queue:e})]})]})}function L(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function R(e,t){let[n,r]=(0,P.useState)(!1),[i,a]=(0,P.useState)(null),[o,s]=(0,P.useState)(null),c=j(`classic-queue-policy:${e}:${t}`);return(0,P.useEffect)(()=>{r(!1),a(null),s(null)},[c.scopeKey]),{busy:n,error:i,receipt:o,run:async(n,i,o)=>{if(!window.confirm(i))return;let l=c.begin(t);if(l){r(!0),a(null),s(null);try{let t=await C.queuesSummary();if(!l.isCurrent())return;if(!t.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await o(),n),!l.isCurrent())return;s(`${n} applied at ${new Date().toISOString()}. Current server state cannot be read.`)}catch(e){l.isCurrent()&&a(e.message)}finally{l.finish()&&r(!1)}}}}}function z({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),[a,o]=(0,P.useState)(`permanent`),[s,l]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),{busy:p,error:m,receipt:h,run:g}=R(e,`rate-limit`),_=L(t),v=L(r),y=a===`expires`?L(s):void 0,b=_!==null&&v!==null&&(a===`permanent`||y!=null);return(0,F.jsxs)(c,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,F.jsx)(u,{className:`size-4 text-faint`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsx)(A,{label:`Limit`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-limit`,value:t,"aria-invalid":t.trim()!==``&&_===null,onChange:e=>n(e.target.value),placeholder:`100`})}),(0,F.jsx)(A,{label:`Window (ms)`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-duration`,value:r,"aria-invalid":r.trim()!==``&&v===null,onChange:e=>i(e.target.value),placeholder:`60000`})}),(0,F.jsx)(A,{label:`TTL`,children:(0,F.jsxs)(O,{name:`classic-rate-ttl-mode`,value:a,onChange:e=>o(e.target.value),children:[(0,F.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,F.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,F.jsx)(A,{label:`TTL (ms)`,hint:a===`permanent`?`Not sent`:void 0,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-ttl`,disabled:a===`permanent`,value:s,"aria-invalid":a===`expires`&&s.trim()!==``&&y==null,onChange:e=>l(e.target.value),placeholder:`3600000`})})]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,F.jsx)(E,{variant:`accent`,size:`sm`,disabled:p||!b,onClick:()=>{if(_===null||v===null||a===`expires`&&y===null)return;let t=typeof y==`number`?y:void 0,n=a===`permanent`?`permanent`:`TTL ${y}ms`;g(`Rate-limit policy replaced`,`Replace the unknown rate-limit policy for "${e}" with limit ${_}, window ${v}ms, ${n}?`,()=>C.setRateLimit(e,_,v,t))},children:`Replace rate-limit policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,F.jsx)(E,{className:`mt-2`,size:`sm`,disabled:p||d!==e,onClick:()=>void g(`No rate limit ensured`,`Ensure queue "${e}" has no rate-limit policy? The previous value is unavailable.`,()=>C.clearRateLimit(e)),children:`Ensure no rate limit`})]}),h&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:h}),m&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:m})]})}function B({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),{busy:a,error:o,receipt:s,run:l}=R(e,`concurrency`),u=L(t);return(0,F.jsxs)(c,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,F.jsx)(f,{className:`size-4 text-faint`})]}),(0,F.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-concurrency`,value:t,"aria-invalid":t.trim()!==``&&u===null,onChange:e=>n(e.target.value),placeholder:`5`})}),(0,F.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,F.jsx)(E,{variant:`accent`,size:`sm`,disabled:a||u===null,onClick:()=>{u!==null&&l(`Concurrency policy replaced`,`Replace the unknown concurrency policy for "${e}" with ${u} maximum in-flight jobs?`,()=>C.setConcurrency(e,u))},children:`Replace concurrency policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,F.jsx)(E,{className:`mt-2`,size:`sm`,disabled:a||r!==e,onClick:()=>void l(`No concurrency limit ensured`,`Ensure queue "${e}" has no concurrency policy? The previous value is unavailable.`,()=>C.clearConcurrency(e)),children:`Ensure no concurrency limit`})]}),s&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:s}),o&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:o})]})}var V=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],H={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,"waiting-children":0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[],recentJobsError:null};function U(){let{name:e=``}=t(),[n,i]=(0,P.useState)(null),[c,u]=(0,P.useState)(null),f=j(`classic-queue:${e}`);(0,P.useEffect)(()=>{i(null),u(null)},[f.scopeKey]);let{data:O,error:k,loading:A,refetch:L}=a((0,P.useCallback)(async()=>{if(!(await C.queuesSummary()).some(t=>t.name===e))return{exists:!1,detail:null,jobs:[],recentJobsError:null};let[t,n]=await Promise.all([v.queueDetail(e,!1),v.jobsList(e,{states:V,limit:12}).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);if(t.ok!==!0||t.name!==e)throw Error(`Malformed queue detail response for "${e}"`);return{exists:!0,detail:t,jobs:n.jobs,recentJobsError:n.error}},[e]),[e]),R=async(t,n,r)=>{if(r&&!window.confirm(r))return;let a=f.begin(t);if(a){i(t),u(null);try{let r=await C.queuesSummary();if(!a.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await n(),t),!a.isCurrent())return;await L()}catch(e){a.isCurrent()&&u(e.message)}finally{a.finish()&&i(null)}}};if(A&&!O&&!k)return(0,F.jsx)(m,{label:`Loading ${e}…`});if(k&&!O)return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(D,{onRetry:L})]});if(O?.exists===!1)return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(D,{onRetry:L}),(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(T,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,F.jsx)(r,{to:`/queues-classic`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to classic queues`})})]});let z=O?.exists===!0?O:H,{detail:B}=z,U=B.counts,W=x(U.completed??0,U.failed??0),G=[...z.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(D,{onRetry:L}),(0,F.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(r,{to:`/queues-classic`,"aria-label":`Back to classic queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,F.jsx)(s,{className:`size-4`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,F.jsx)(p,{label:B.paused?`Paused`:`Active`,tone:B.paused?`amber`:`green`}),(0,F.jsx)(p,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B.paused?(0,F.jsxs)(E,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>R(`resume`,()=>v.resume(e)),children:[(0,F.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,F.jsxs)(E,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>R(`pause`,()=>v.pause(e)),children:[(0,F.jsx)(l,{className:`size-3.5`}),` Pause`]}),(0,F.jsx)(E,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,F.jsx)(E,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),c&&(0,F.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:c}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,F.jsx)(b,{label:`Waiting`,value:h(U.waiting),tone:`amber`}),(0,F.jsx)(b,{label:`Active`,value:h(U.active),tone:`blue`}),(0,F.jsx)(b,{label:`Completed`,value:h(U.completed),tone:`green`}),(0,F.jsx)(b,{label:`Failed`,value:h(U.failed),tone:U.failed?`red`:`default`}),(0,F.jsx)(b,{label:`Delayed`,value:h(U.delayed),tone:`default`}),(0,F.jsx)(b,{label:`Error Rate`,value:W==null?`—`:y(W),tone:W==null?`default`:W>.05?`red`:`green`})]}),(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,F.jsxs)(r,{to:`/jobs-classic?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,F.jsx)(o,{className:`size-3.5`})]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,F.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,F.jsx)(`tbody`,{children:z.recentJobsError?(0,F.jsx)(`tr`,{children:(0,F.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,z.recentJobsError,`. Retry the page.`]})}):G.length===0?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.map(e=>(0,F.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,F.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,F.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e.id})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,F.jsx)(`td`,{className:`px-5 py-3`,children:(0,F.jsx)(_,{status:String(e.state??e.status??`waiting`)})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:S(g(e.startedAt,e.completedAt))}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,F.jsx)(I,{queue:e})]})}export{U as QueueDetail};
@@ -1 +1 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,g as r,r as i,t as a}from"./react-vendor-Bjui4wS4.js";import{A as o,C as s,M as c,P as l,S as u,_ as d,b as f,c as p,ft as m,h,l as g,m as _,n as v,o as y,st as b,v as x,w as S,x as C,y as ee}from"./index-Bn2R06qm.js";import{r as w,t as T}from"./useServerActionGuard-CItj3hvh.js";import{r as E}from"./flowMutationSafety-DVD1IMr-.js";import{t as D}from"./AreaChart-REK4ZsTC.js";import{a as O,i as k,n as te,r as A,t as ne}from"./QueueActions-D_QGBaVm.js";import{t as j}from"./useThroughputSeries-tb26_lkb.js";var M=e(r(),1),N=a(),P=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],F=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],I=2e3;function L(){let{name:e=``}=n(),[r,a]=(0,M.useState)(!1),[L,z]=(0,M.useState)(null),B=w(`queue:${e}`);(0,M.useEffect)(()=>{a(!1),z(null)},[B.scopeKey]);let{data:V,error:H,loading:U,refetch:W}=o((0,M.useCallback)(async()=>{if(!e)return null;if(!(await b.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([b.queueDetail(e,!1),b.getStallConfig(e).catch(()=>null),b.getDlqConfig(e).catch(()=>null),b.jobsList(e,F,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]),G=V&&V.queue===e?V:null,[K,q]=(0,M.useState)([]),J=(0,M.useRef)(null);(0,M.useEffect)(()=>{let e=G?.detail?.counts;e&&(J.current=(e.waiting??0)+(e.prioritized??0)+(e.active??0)+(e.delayed??0)+(e[`waiting-children`]??0))},[G]),(0,M.useEffect)(()=>{J.current=null,q([]);let e=setInterval(()=>{let e=J.current;e!=null&&q(t=>[...t,e].slice(-40))},I);return()=>clearInterval(e)},[e]);let Y=async(t,n,r,i)=>{if(r&&!window.confirm(r))return;let o=B.begin();if(o){a(!0),z(null);try{let r=await b.queuesSummary();if(!o.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);let a=await n();if(T(a,t),!o.isCurrent())return;let s=a.count;if(s!==void 0&&(!Number.isSafeInteger(s)||s<0))throw Error(`${t} returned an invalid count`);let c=`${t}${s==null?` ✓`:`: ${s}`}`;z({ok:!0,text:c}),m.success(c,e),i?.(),W()}catch(e){if(!o.isCurrent())return;let n=e.message;z({ok:!1,text:n}),m.error(`${t} failed`,n)}finally{o.finish()&&a(!1)}}},X=G?.detail,Z=X?.counts,Q=Z?v(Z.completed??0,Z.failed??0):null,$=j(K);return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(h,{title:(0,N.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and complete live non-terminal depth.`,live:G?.exists===!0&&!!G.detail&&!!G.stall&&!!G.dlq&&!G.recentJobsError&&!H,back:(0,N.jsx)(i,{to:`/queues`,"aria-label":`Back to queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,N.jsx)(l,{className:`size-4`})}),actions:G?.exists===!0?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`Jobs `,(0,N.jsx)(c,{className:`size-3.5`})]}),(0,N.jsxs)(i,{to:`/dlq?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`DLQ `,(0,N.jsx)(c,{className:`size-3.5`})]}),(0,N.jsx)(S,{variant:`danger`,size:`sm`,disabled:!0,title:E,children:`Obliterate`})]}):void 0}),H&&G&&(0,N.jsx)(C,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:W}),H&&!G?(0,N.jsx)(ee,{error:H,onRetry:W}):U&&!G?(0,N.jsx)(f,{label:`Loading ${e}…`}):G?.exists===!1||!X||!Z?!H&&(0,N.jsx)(x,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,N.jsx)(i,{to:`/queues`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to queues`})}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(d,{label:X.paused?`Paused`:`Active`,tone:X.paused?`amber`:`green`}),L&&(0,N.jsx)(`span`,{role:`status`,className:L.ok?`text-xs text-success`:`text-xs text-danger`,children:L.text}),(0,N.jsx)(`span`,{className:`text-xs text-warning`,children:E})]}),(0,N.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:P.map(e=>(0,N.jsx)(_,{label:e,value:p(Z[e]),tone:e===`failed`&&Z.failed?`red`:`default`,compact:!0},e))}),(0,N.jsxs)(u,{padded:!1,className:`mb-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,N.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,N.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,N.jsx)(c,{className:`size-3.5`})]})]}),(0,N.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,N.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`ID`}),(0,N.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`State`}),(0,N.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,N.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,N.jsx)(`tbody`,{children:G.recentJobsError?(0,N.jsx)(`tr`,{children:(0,N.jsxs)(`td`,{colSpan:4,className:`px-5 py-10 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,G.recentJobsError,`. Retry the page.`]})}):G.jobs.length===0?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:4,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.jobs.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,N.jsx)(`td`,{className:`px-5 py-3`,children:(0,N.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,N.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:y(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)})]},e.id))})]})})]}),(0,N.jsx)(R,{counts:X.priorityCounts}),(0,N.jsxs)(u,{className:`mb-6`,children:[(0,N.jsx)(s,{title:`Backlog depth`,action:(0,N.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,$.draining?`bg-emerald-500/10 text-success`:$.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:$.label})}),K.length<2?(0,N.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,N.jsx)(D,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:K,area:!0}]}),(0,N.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,N.jsx)(`span`,{children:`waiting + prioritized + active + delayed + waiting-children`}),(0,N.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,Q==null?`—`:g(Q)]})]})]}),(0,N.jsx)(ne,{queue:e,paused:X.paused,busy:r,run:Y}),(0,N.jsx)(te,{queue:e,busy:r,run:Y},`${e}:limits`),(0,N.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[G.stall?(0,N.jsx)(O,{queue:e,config:G.stall,onSaved:()=>{z({ok:!0,text:`Stall config saved ✓`}),m.success(`Stall config saved`,e)}},`${e}:stall`):(0,N.jsx)(A,{title:`Stall detection`,onRetry:W}),G.dlq?(0,N.jsx)(k,{queue:e,config:G.dlq,onSaved:()=>{z({ok:!0,text:`DLQ config saved ✓`}),m.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,N.jsx)(A,{title:`DLQ policy`,onRetry:W})]})]})]})}function R({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,N.jsxs)(u,{className:`mb-6`,children:[(0,N.jsx)(s,{title:`Jobs by priority`}),(0,N.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,N.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,N.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,N.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:p(t)})]},e))}),(0,N.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}export{L as QueueDetailPro};
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,g as r,r as i,t as a}from"./react-vendor-Bjui4wS4.js";import{A as o,C as s,M as c,P as l,S as u,_ as d,b as f,c as p,ft as m,h,l as g,m as _,n as v,o as y,st as b,v as x,w as S,x as C,y as ee}from"./index-Dr__4DsT.js";import{r as w,t as T}from"./useServerActionGuard-CItj3hvh.js";import{r as E}from"./flowMutationSafety-DVD1IMr-.js";import{t as D}from"./AreaChart-REK4ZsTC.js";import{a as O,i as k,n as te,r as A,t as ne}from"./QueueActions-CibRLzrz.js";import{t as j}from"./useThroughputSeries-Bpyg6Jaq.js";var M=e(r(),1),N=a(),P=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],F=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],I=2e3;function L(){let{name:e=``}=n(),[r,a]=(0,M.useState)(!1),[L,z]=(0,M.useState)(null),B=w(`queue:${e}`);(0,M.useEffect)(()=>{a(!1),z(null)},[B.scopeKey]);let{data:V,error:H,loading:U,refetch:W}=o((0,M.useCallback)(async()=>{if(!e)return null;if(!(await b.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([b.queueDetail(e,!1),b.getStallConfig(e).catch(()=>null),b.getDlqConfig(e).catch(()=>null),b.jobsList(e,F,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]),G=V&&V.queue===e?V:null,[K,q]=(0,M.useState)([]),J=(0,M.useRef)(null);(0,M.useEffect)(()=>{let e=G?.detail?.counts;e&&(J.current=(e.waiting??0)+(e.prioritized??0)+(e.active??0)+(e.delayed??0)+(e[`waiting-children`]??0))},[G]),(0,M.useEffect)(()=>{J.current=null,q([]);let e=setInterval(()=>{let e=J.current;e!=null&&q(t=>[...t,e].slice(-40))},I);return()=>clearInterval(e)},[e]);let Y=async(t,n,r,i)=>{if(r&&!window.confirm(r))return;let o=B.begin();if(o){a(!0),z(null);try{let r=await b.queuesSummary();if(!o.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);let a=await n();if(T(a,t),!o.isCurrent())return;let s=a.count;if(s!==void 0&&(!Number.isSafeInteger(s)||s<0))throw Error(`${t} returned an invalid count`);let c=`${t}${s==null?` ✓`:`: ${s}`}`;z({ok:!0,text:c}),m.success(c,e),i?.(),W()}catch(e){if(!o.isCurrent())return;let n=e.message;z({ok:!1,text:n}),m.error(`${t} failed`,n)}finally{o.finish()&&a(!1)}}},X=G?.detail,Z=X?.counts,Q=Z?v(Z.completed??0,Z.failed??0):null,$=j(K);return(0,N.jsxs)(`div`,{children:[(0,N.jsx)(h,{title:(0,N.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and complete live non-terminal depth.`,live:G?.exists===!0&&!!G.detail&&!!G.stall&&!!G.dlq&&!G.recentJobsError&&!H,back:(0,N.jsx)(i,{to:`/queues`,"aria-label":`Back to queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,N.jsx)(l,{className:`size-4`})}),actions:G?.exists===!0?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`Jobs `,(0,N.jsx)(c,{className:`size-3.5`})]}),(0,N.jsxs)(i,{to:`/dlq?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`DLQ `,(0,N.jsx)(c,{className:`size-3.5`})]}),(0,N.jsx)(S,{variant:`danger`,size:`sm`,disabled:!0,title:E,children:`Obliterate`})]}):void 0}),H&&G&&(0,N.jsx)(C,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:W}),H&&!G?(0,N.jsx)(ee,{error:H,onRetry:W}):U&&!G?(0,N.jsx)(f,{label:`Loading ${e}…`}):G?.exists===!1||!X||!Z?!H&&(0,N.jsx)(x,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,N.jsx)(i,{to:`/queues`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to queues`})}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(d,{label:X.paused?`Paused`:`Active`,tone:X.paused?`amber`:`green`}),L&&(0,N.jsx)(`span`,{role:`status`,className:L.ok?`text-xs text-success`:`text-xs text-danger`,children:L.text}),(0,N.jsx)(`span`,{className:`text-xs text-warning`,children:E})]}),(0,N.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:P.map(e=>(0,N.jsx)(_,{label:e,value:p(Z[e]),tone:e===`failed`&&Z.failed?`red`:`default`,compact:!0},e))}),(0,N.jsxs)(u,{padded:!1,className:`mb-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,N.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,N.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,N.jsx)(c,{className:`size-3.5`})]})]}),(0,N.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,N.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`ID`}),(0,N.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`State`}),(0,N.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,N.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,N.jsx)(`tbody`,{children:G.recentJobsError?(0,N.jsx)(`tr`,{children:(0,N.jsxs)(`td`,{colSpan:4,className:`px-5 py-10 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,G.recentJobsError,`. Retry the page.`]})}):G.jobs.length===0?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:4,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.jobs.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,N.jsx)(`td`,{className:`px-5 py-3`,children:(0,N.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,N.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:y(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)})]},e.id))})]})})]}),(0,N.jsx)(R,{counts:X.priorityCounts}),(0,N.jsxs)(u,{className:`mb-6`,children:[(0,N.jsx)(s,{title:`Backlog depth`,action:(0,N.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,$.draining?`bg-emerald-500/10 text-success`:$.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:$.label})}),K.length<2?(0,N.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,N.jsx)(D,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:K,area:!0}]}),(0,N.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,N.jsx)(`span`,{children:`waiting + prioritized + active + delayed + waiting-children`}),(0,N.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,Q==null?`—`:g(Q)]})]})]}),(0,N.jsx)(ne,{queue:e,paused:X.paused,busy:r,run:Y}),(0,N.jsx)(te,{queue:e,busy:r,run:Y},`${e}:limits`),(0,N.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[G.stall?(0,N.jsx)(O,{queue:e,config:G.stall,onSaved:()=>{z({ok:!0,text:`Stall config saved ✓`}),m.success(`Stall config saved`,e)}},`${e}:stall`):(0,N.jsx)(A,{title:`Stall detection`,onRetry:W}),G.dlq?(0,N.jsx)(k,{queue:e,config:G.dlq,onSaved:()=>{z({ok:!0,text:`DLQ config saved ✓`}),m.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,N.jsx)(A,{title:`DLQ policy`,onRetry:W})]})]})]})}function R({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,N.jsxs)(u,{className:`mb-6`,children:[(0,N.jsx)(s,{title:`Jobs by priority`}),(0,N.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,N.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,N.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,N.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:p(t)})]},e))}),(0,N.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}export{L as QueueDetailPro};
@@ -1 +1 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{g as n,r,t as i}from"./react-vendor-Bjui4wS4.js";import{A as a,G as o,J as s,M as c,b as l,c as u,h as d,j as f,m as p,x as m}from"./index-Bn2R06qm.js";import{t as h}from"./Pagination-DpxiBnt8.js";var g=e(n(),1),_=i(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let[e,n]=(0,g.useState)(``),[i,b]=(0,g.useState)(0),{data:x,error:S,loading:C,refetch:w}=a(()=>f.queues(v,i*v),[i]),{data:T}=a(()=>f.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)(l,{label:`Loading queues…`});let O=T?.stats;return(0,_.jsxs)(`div`,{children:[S&&(0,_.jsx)(m,{onRetry:w}),(0,_.jsx)(d,{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)(p,{label:`Waiting`,value:O?u(O.waiting):`—`,tone:`amber`,compact:!0}),(0,_.jsx)(p,{label:`Active`,value:O?u(O.active):`—`,tone:`blue`,compact:!0}),(0,_.jsx)(p,{label:`Delayed`,value:O?u(O.delayed):`—`,tone:`default`,compact:!0}),(0,_.jsx)(p,{label:`DLQ`,value:O?u(O.dlq):`—`,tone:O?.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{"aria-label":`Filter queues`,name:`classic-queue-filter`,autoComplete:`off`,value:e,onChange:e=>n(e.target.value),placeholder:`Search queues…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[52rem] text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Delayed`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`DLQ`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`w-10 px-5 py-3`})]})}),(0,_.jsx)(`tbody`,{children:!x&&S?(0,_.jsx)(`tr`,{children:(0,_.jsxs)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,S.message,`. Retry above.`]})}):D.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:e?`No queues match on this page.`:`No queues yet.`})}):D.map(e=>(0,_.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(r,{to:`/queues-classic/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,_.jsx)(o,{className:`size-4 text-faint`}),e.name]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:u(e.waiting)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:u(e.active)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:u(e.delayed)}),(0,_.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,e.dlq?`text-red-400`:`text-muted`),children:u(e.dlq)}),(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-emerald-400`),children:[(0,_.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:(0,_.jsx)(c,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},e.name))})]})}),x&&(0,_.jsx)(h,{page:i,pageSize:v,total:E.total,onPageChange:b,label:`queues`})]})}export{b as Queues};
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{g as n,r,t as i}from"./react-vendor-Bjui4wS4.js";import{A as a,G as o,J as s,M as c,b as l,c as u,h as d,j as f,m as p,x as m}from"./index-Dr__4DsT.js";import{t as h}from"./Pagination-eotgGQf9.js";var g=e(n(),1),_=i(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let[e,n]=(0,g.useState)(``),[i,b]=(0,g.useState)(0),{data:x,error:S,loading:C,refetch:w}=a(()=>f.queues(v,i*v),[i]),{data:T}=a(()=>f.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)(l,{label:`Loading queues…`});let O=T?.stats;return(0,_.jsxs)(`div`,{children:[S&&(0,_.jsx)(m,{onRetry:w}),(0,_.jsx)(d,{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)(p,{label:`Waiting`,value:O?u(O.waiting):`—`,tone:`amber`,compact:!0}),(0,_.jsx)(p,{label:`Active`,value:O?u(O.active):`—`,tone:`blue`,compact:!0}),(0,_.jsx)(p,{label:`Delayed`,value:O?u(O.delayed):`—`,tone:`default`,compact:!0}),(0,_.jsx)(p,{label:`DLQ`,value:O?u(O.dlq):`—`,tone:O?.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{"aria-label":`Filter queues`,name:`classic-queue-filter`,autoComplete:`off`,value:e,onChange:e=>n(e.target.value),placeholder:`Search queues…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[52rem] text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Delayed`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`DLQ`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`w-10 px-5 py-3`})]})}),(0,_.jsx)(`tbody`,{children:!x&&S?(0,_.jsx)(`tr`,{children:(0,_.jsxs)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,S.message,`. Retry above.`]})}):D.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:e?`No queues match on this page.`:`No queues yet.`})}):D.map(e=>(0,_.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(r,{to:`/queues-classic/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,_.jsx)(o,{className:`size-4 text-faint`}),e.name]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:u(e.waiting)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:u(e.active)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:u(e.delayed)}),(0,_.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,e.dlq?`text-red-400`:`text-muted`),children:u(e.dlq)}),(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-emerald-400`),children:[(0,_.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:(0,_.jsx)(c,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},e.name))})]})}),x&&(0,_.jsx)(h,{page:i,pageSize:v,total:E.total,onPageChange:b,label:`queues`})]})}export{b as Queues};
@@ -1 +1 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{g as n,r,t as i}from"./react-vendor-Bjui4wS4.js";import{A as a,G as o,J as s,M as c,T as l,U as u,W as d,b as f,c as p,ft as m,h,m as g,st as _,w as v,x as y,y as b}from"./index-Bn2R06qm.js";import{t as x}from"./Pagination-DpxiBnt8.js";import{r as ee,t as S}from"./useServerActionGuard-CItj3hvh.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";var w=e(n(),1),T=i(),E=6,D=15,O=[[`waiting`,`Waiting`],[`prioritized`,`Prioritized`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function k(){let[e,n]=(0,w.useState)(``),[i,k]=(0,w.useState)(0),[A,j]=(0,w.useState)(new Set),[M,N]=(0,w.useState)(!1),[P,F]=(0,w.useState)(null),[I,L]=(0,w.useState)(null),[R,z]=(0,w.useState)(`desc`),B=ee(`queues-overview`);(0,w.useEffect)(()=>{j(new Set),N(!1),F(null)},[B.scopeKey]);let{data:V,error:H,loading:U,refetch:W}=a(()=>_.queuesSummary(),[]),G=V??[],K=e=>{I===e?R===`desc`?z(`asc`):L(null):(L(e),z(`desc`)),k(0)},q=(0,w.useMemo)(()=>{let t=e.trim().toLowerCase(),n=[...t?G.filter(e=>e.name.toLowerCase().includes(t)):G].sort((e,t)=>e.name.localeCompare(t.name));if(I){let e=R===`desc`?-1:1;n.sort((t,n)=>e*(t.counts[I]-n.counts[I]))}return n},[G,e,I,R]),J=(0,w.useMemo)(()=>G.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}),[G]),Y=Math.max(1,Math.ceil(q.length/D)),X=Math.min(i,Y-1),Z=q.slice(X*D,X*D+D),Q=async e=>{let t=B.begin(`queue:${e.name}`);if(t){j(t=>new Set(t).add(e.name)),F(null);try{if(S(await(e.paused?_.resume(e.name):_.pause(e.name)),e.paused?`Resume queue`:`Pause queue`),!t.isCurrent())return;F({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`}),W()}catch(n){if(!t.isCurrent())return;F({ok:!1,text:n.message}),m.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,n.message)}finally{t.finish()&&j(t=>{let n=new Set(t);return n.delete(e.name),n})}}},$=async e=>{let t=G.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){m.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;let n=B.begin([`bulk`,...G.map(e=>`queue:${e.name}`)]);if(n){N(!0),F(null);try{let r=await C(t,E,async t=>{if(!n.isCurrent())throw Error(`Queue action target changed`);S(e===`pause`?await _.pause(t.name):await _.resume(t.name),`${e===`pause`?`Pause`:`Resume`} ${t.name}`)});if(!n.isCurrent())return;let i=r.filter(e=>e.status===`rejected`).length,a=`${e===`pause`?`Paused`:`Resumed`} ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;F({ok:i===0,text:a}),i===0?m.success(a):m.error(a),W()}finally{n.finish()&&N(!1)}}};return U&&!V&&!H?(0,T.jsx)(f,{label:`Loading queues…`}):H&&!V?(0,T.jsxs)(`div`,{children:[(0,T.jsx)(h,{title:`Queues`,description:`Queue inventory unavailable`}),(0,T.jsx)(b,{error:H,onRetry:W})]}):(0,T.jsxs)(`div`,{children:[(0,T.jsx)(h,{title:`Queues`,description:V?`${G.length} queues`:`Queue inventory unavailable`,live:!!V&&!H,actions:G.length>0?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(v,{variant:`warning`,size:`sm`,disabled:M||A.size>0||J.paused>=G.length,onClick:()=>$(`pause`),children:[(0,T.jsx)(u,{className:`size-3.5`}),` Pause all`]}),(0,T.jsxs)(v,{variant:`success`,size:`sm`,disabled:M||A.size>0||J.paused===0,onClick:()=>$(`resume`),children:[(0,T.jsx)(d,{className:`size-3.5`}),` Resume all`]})]}):void 0}),H&&(0,T.jsx)(y,{message:`Queue refresh failed — showing the last successful inventory.`,onRetry:W}),(0,T.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,T.jsx)(g,{label:`Waiting`,value:p(J.waiting),tone:`amber`,compact:!0}),(0,T.jsx)(g,{label:`Prioritized`,value:p(J.prioritized),tone:`amber`,compact:!0}),(0,T.jsx)(g,{label:`Active`,value:p(J.active),tone:`blue`,compact:!0}),(0,T.jsx)(g,{label:`Failed`,value:p(J.failed),tone:J.failed?`red`:`default`,compact:!0}),(0,T.jsx)(g,{label:`Paused`,value:p(J.paused),tone:J.paused?`amber`:`default`,compact:!0})]}),(0,T.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,T.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,T.jsx)(`input`,{value:e,onChange:e=>{n(e.target.value),k(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`})]}),P&&(0,T.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,P.ok?`text-success`:`text-danger`),children:P.text}),(0,T.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,T.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,T.jsx)(`thead`,{children:(0,T.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,T.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Queue`}),O.map(([e,t])=>(0,T.jsx)(`th`,{scope:`col`,"aria-sort":I===e?R===`desc`?`descending`:`ascending`:void 0,className:`px-5 py-3 text-right font-medium`,children:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>K(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,I===e&&(0,T.jsx)(`span`,{"aria-hidden":`true`,children:R===`desc`?`↓`:`↑`})]})},e)),(0,T.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Status`}),(0,T.jsx)(`th`,{scope:`col`,className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,T.jsx)(`tbody`,{children:!V&&H?(0,T.jsx)(`tr`,{children:(0,T.jsxs)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,H.message,`. Retry above.`]})}):Z.length===0?(0,T.jsx)(`tr`,{children:(0,T.jsx)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-faint`,children:e?`No queues match your search.`:`No queues yet.`})}):Z.map(e=>{let n=M||A.has(e.name);return(0,T.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,T.jsx)(`td`,{className:`px-5 py-3`,children:(0,T.jsxs)(r,{to:`/queues/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,T.jsx)(o,{className:`size-4 text-faint`}),e.name]})}),(0,T.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:p(e.counts.waiting)}),(0,T.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:p(e.counts.prioritized)}),(0,T.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:p(e.counts.active)}),(0,T.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:p(e.counts.completed)}),(0,T.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,e.counts.failed?`text-danger`:`text-muted`),children:p(e.counts.failed)}),(0,T.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.counts.delayed)}),(0,T.jsx)(`td`,{className:`px-5 py-3`,children:(0,T.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:[(0,T.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,T.jsx)(`td`,{className:`px-5 py-3`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,T.jsx)(l,{"aria-label":e.paused?`Resume queue`:`Pause queue`,disabled:n,onClick:t=>{t.stopPropagation(),Q(e)},children:e.paused?(0,T.jsx)(d,{className:`size-3.5 text-success`}):(0,T.jsx)(u,{className:`size-3.5 text-warning`})}),(0,T.jsx)(c,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},e.name)})})]})}),(0,T.jsx)(x,{page:X,pageSize:D,total:q.length,onPageChange:k,label:`queues`})]})}export{k as QueuesOverview};
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{g as n,r,t as i}from"./react-vendor-Bjui4wS4.js";import{A as a,G as o,J as s,M as c,T as l,U as u,W as d,b as f,c as p,ft as m,h,m as g,st as _,w as v,x as y,y as b}from"./index-Dr__4DsT.js";import{t as x}from"./Pagination-eotgGQf9.js";import{r as ee,t as S}from"./useServerActionGuard-CItj3hvh.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";var w=e(n(),1),T=i(),E=6,D=15,O=[[`waiting`,`Waiting`],[`prioritized`,`Prioritized`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function k(){let[e,n]=(0,w.useState)(``),[i,k]=(0,w.useState)(0),[A,j]=(0,w.useState)(new Set),[M,N]=(0,w.useState)(!1),[P,F]=(0,w.useState)(null),[I,L]=(0,w.useState)(null),[R,z]=(0,w.useState)(`desc`),B=ee(`queues-overview`);(0,w.useEffect)(()=>{j(new Set),N(!1),F(null)},[B.scopeKey]);let{data:V,error:H,loading:U,refetch:W}=a(()=>_.queuesSummary(),[]),G=V??[],K=e=>{I===e?R===`desc`?z(`asc`):L(null):(L(e),z(`desc`)),k(0)},q=(0,w.useMemo)(()=>{let t=e.trim().toLowerCase(),n=[...t?G.filter(e=>e.name.toLowerCase().includes(t)):G].sort((e,t)=>e.name.localeCompare(t.name));if(I){let e=R===`desc`?-1:1;n.sort((t,n)=>e*(t.counts[I]-n.counts[I]))}return n},[G,e,I,R]),J=(0,w.useMemo)(()=>G.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}),[G]),Y=Math.max(1,Math.ceil(q.length/D)),X=Math.min(i,Y-1),Z=q.slice(X*D,X*D+D),Q=async e=>{let t=B.begin(`queue:${e.name}`);if(t){j(t=>new Set(t).add(e.name)),F(null);try{if(S(await(e.paused?_.resume(e.name):_.pause(e.name)),e.paused?`Resume queue`:`Pause queue`),!t.isCurrent())return;F({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`}),W()}catch(n){if(!t.isCurrent())return;F({ok:!1,text:n.message}),m.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,n.message)}finally{t.finish()&&j(t=>{let n=new Set(t);return n.delete(e.name),n})}}},$=async e=>{let t=G.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){m.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;let n=B.begin([`bulk`,...G.map(e=>`queue:${e.name}`)]);if(n){N(!0),F(null);try{let r=await C(t,E,async t=>{if(!n.isCurrent())throw Error(`Queue action target changed`);S(e===`pause`?await _.pause(t.name):await _.resume(t.name),`${e===`pause`?`Pause`:`Resume`} ${t.name}`)});if(!n.isCurrent())return;let i=r.filter(e=>e.status===`rejected`).length,a=`${e===`pause`?`Paused`:`Resumed`} ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;F({ok:i===0,text:a}),i===0?m.success(a):m.error(a),W()}finally{n.finish()&&N(!1)}}};return U&&!V&&!H?(0,T.jsx)(f,{label:`Loading queues…`}):H&&!V?(0,T.jsxs)(`div`,{children:[(0,T.jsx)(h,{title:`Queues`,description:`Queue inventory unavailable`}),(0,T.jsx)(b,{error:H,onRetry:W})]}):(0,T.jsxs)(`div`,{children:[(0,T.jsx)(h,{title:`Queues`,description:V?`${G.length} queues`:`Queue inventory unavailable`,live:!!V&&!H,actions:G.length>0?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(v,{variant:`warning`,size:`sm`,disabled:M||A.size>0||J.paused>=G.length,onClick:()=>$(`pause`),children:[(0,T.jsx)(u,{className:`size-3.5`}),` Pause all`]}),(0,T.jsxs)(v,{variant:`success`,size:`sm`,disabled:M||A.size>0||J.paused===0,onClick:()=>$(`resume`),children:[(0,T.jsx)(d,{className:`size-3.5`}),` Resume all`]})]}):void 0}),H&&(0,T.jsx)(y,{message:`Queue refresh failed — showing the last successful inventory.`,onRetry:W}),(0,T.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,T.jsx)(g,{label:`Waiting`,value:p(J.waiting),tone:`amber`,compact:!0}),(0,T.jsx)(g,{label:`Prioritized`,value:p(J.prioritized),tone:`amber`,compact:!0}),(0,T.jsx)(g,{label:`Active`,value:p(J.active),tone:`blue`,compact:!0}),(0,T.jsx)(g,{label:`Failed`,value:p(J.failed),tone:J.failed?`red`:`default`,compact:!0}),(0,T.jsx)(g,{label:`Paused`,value:p(J.paused),tone:J.paused?`amber`:`default`,compact:!0})]}),(0,T.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,T.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,T.jsx)(`input`,{value:e,onChange:e=>{n(e.target.value),k(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`})]}),P&&(0,T.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,P.ok?`text-success`:`text-danger`),children:P.text}),(0,T.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,T.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,T.jsx)(`thead`,{children:(0,T.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,T.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Queue`}),O.map(([e,t])=>(0,T.jsx)(`th`,{scope:`col`,"aria-sort":I===e?R===`desc`?`descending`:`ascending`:void 0,className:`px-5 py-3 text-right font-medium`,children:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>K(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,I===e&&(0,T.jsx)(`span`,{"aria-hidden":`true`,children:R===`desc`?`↓`:`↑`})]})},e)),(0,T.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Status`}),(0,T.jsx)(`th`,{scope:`col`,className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,T.jsx)(`tbody`,{children:!V&&H?(0,T.jsx)(`tr`,{children:(0,T.jsxs)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,H.message,`. Retry above.`]})}):Z.length===0?(0,T.jsx)(`tr`,{children:(0,T.jsx)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-faint`,children:e?`No queues match your search.`:`No queues yet.`})}):Z.map(e=>{let n=M||A.has(e.name);return(0,T.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,T.jsx)(`td`,{className:`px-5 py-3`,children:(0,T.jsxs)(r,{to:`/queues/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,T.jsx)(o,{className:`size-4 text-faint`}),e.name]})}),(0,T.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:p(e.counts.waiting)}),(0,T.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:p(e.counts.prioritized)}),(0,T.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:p(e.counts.active)}),(0,T.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:p(e.counts.completed)}),(0,T.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,e.counts.failed?`text-danger`:`text-muted`),children:p(e.counts.failed)}),(0,T.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.counts.delayed)}),(0,T.jsx)(`td`,{className:`px-5 py-3`,children:(0,T.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:[(0,T.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,T.jsx)(`td`,{className:`px-5 py-3`,children:(0,T.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,T.jsx)(l,{"aria-label":e.paused?`Resume queue`:`Pause queue`,disabled:n,onClick:t=>{t.stopPropagation(),Q(e)},children:e.paused?(0,T.jsx)(d,{className:`size-3.5 text-success`}):(0,T.jsx)(u,{className:`size-3.5 text-warning`})}),(0,T.jsx)(c,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},e.name)})})]})}),(0,T.jsx)(x,{page:X,pageSize:D,total:q.length,onPageChange:k,label:`queues`})]})}export{k as QueuesOverview};
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-Bjui4wS4.js";import{A as t,C as n,S as r,b as i,h as a,j as o,x as s,y as c}from"./index-Bn2R06qm.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}=t(async()=>{let e=await o.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)(s,{message:`Storage refresh failed — showing the last successful status.`,onRetry:p}),(0,l.jsx)(a,{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)(r,{children:[(0,l.jsx)(n,{title:`Storage status`}),d&&!e?(0,l.jsx)(c,{error:d,onRetry:p}):f&&!e?(0,l.jsx)(i,{}):(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)(r,{children:[(0,l.jsx)(n,{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
+ import{t as e}from"./react-vendor-Bjui4wS4.js";import{A as t,C as n,S as r,b as i,h as a,j as o,x as s,y as c}from"./index-Dr__4DsT.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}=t(async()=>{let e=await o.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)(s,{message:`Storage refresh failed — showing the last successful status.`,onRetry:p}),(0,l.jsx)(a,{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)(r,{children:[(0,l.jsx)(n,{title:`Storage status`}),d&&!e?(0,l.jsx)(c,{error:d,onRetry:p}):f&&!e?(0,l.jsx)(i,{}):(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)(r,{children:[(0,l.jsx)(n,{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,2 +1,2 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{c as r,l as i,o as a,s as o}from"./connectionStore-Cd9-3Fw0.js";import{O as s,S as c,h as l,q as u,st as d,w as f}from"./index-Bn2R06qm.js";import{a as p,n as m,r as h,t as g}from"./form-DsUq0w8s.js";var _=e(t(),1),v=`bq-dash-s3`,y=2,b=[`disabled`,`6h`,`12h`,`24h`],x={endpoint:``,region:`us-east-1`,bucket:``,schedule:`disabled`,pathPrefix:``,virtualHostedStyle:`auto`,retention:7};function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(e,t,n){return typeof e==`string`&&e.length<=n?e:t}function w(e){return b.includes(e)?e:`disabled`}function T(e){return e===`virtual-hosted`||e===`path-style`?e:`auto`}function E(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=1&&e<=1e6?e:x.retention}function D(e){let t=S(e)?e:{};return{endpoint:C(t.endpoint,x.endpoint,2048),region:C(t.region,x.region,128),bucket:C(t.bucket,x.bucket,255),schedule:w(t.schedule),pathPrefix:C(t.pathPrefix,x.pathPrefix,1024),virtualHostedStyle:T(t.virtualHostedStyle),retention:E(t.retention)}}function O(e){return D(e)}function k(){try{return globalThis.localStorage??null}catch{return null}}function A(e){try{let t=JSON.parse(e),n=S(t)?t:{},r=D(`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:y})}}catch{return null}}var j={getItem(e){let t=k();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=A(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{k()?.setItem(e,t)}catch{}},removeItem(e){try{k()?.removeItem(e)}catch{}}},M=i()(r(e=>({...x,accessKeyId:``,secretAccessKey:``,sessionToken:``,set:t=>e(e=>{let n={...e,...t};return{...D(n),accessKeyId:C(n.accessKeyId,``,512),secretAccessKey:C(n.secretAccessKey,``,2048),sessionToken:C(n.sessionToken,``,4096)}})}),{name:v,version:y,storage:o(()=>j),partialize:O,migrate:D,merge:(e,t)=>({...t,...D(e),accessKeyId:``,secretAccessKey:``,sessionToken:``})})),N=n();function P(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 F=e=>JSON.stringify([e.baseUrl,e.token]),I={"6h":360*60*1e3,"12h":720*60*1e3,"24h":1440*60*1e3};function L(e,t){return`${e}=${typeof t==`string`?JSON.stringify(t):String(t)}`}function R(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:L(`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=[L(`S3_BACKUP_ENABLED`,!0),L(`S3_ACCESS_KEY_ID`,a),L(`S3_SECRET_ACCESS_KEY`,o),L(`S3_BUCKET`,i),L(`S3_REGION`,r),L(`S3_BACKUP_RETENTION`,e.retention)];return s&&l.push(L(`S3_SESSION_TOKEN`,s)),e.virtualHostedStyle!==`auto`&&l.push(L(`S3_VIRTUAL_HOSTED_STYLE`,e.virtualHostedStyle===`virtual-hosted`)),n&&l.push(L(`S3_ENDPOINT`,n)),c&&l.push(L(`S3_BACKUP_PREFIX`,c)),l.push(L(`S3_BACKUP_INTERVAL`,I[e.schedule])),{ok:!0,value:l.join(`
1
+ import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{c as r,l as i,o as a,s as o}from"./connectionStore-Cd9-3Fw0.js";import{O as s,S as c,h as l,q as u,st as d,w as f}from"./index-Dr__4DsT.js";import{a as p,n as m,r as h,t as g}from"./form-DsUq0w8s.js";var _=e(t(),1),v=`bq-dash-s3`,y=2,b=[`disabled`,`6h`,`12h`,`24h`],x={endpoint:``,region:`us-east-1`,bucket:``,schedule:`disabled`,pathPrefix:``,virtualHostedStyle:`auto`,retention:7};function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(e,t,n){return typeof e==`string`&&e.length<=n?e:t}function w(e){return b.includes(e)?e:`disabled`}function T(e){return e===`virtual-hosted`||e===`path-style`?e:`auto`}function E(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=1&&e<=1e6?e:x.retention}function D(e){let t=S(e)?e:{};return{endpoint:C(t.endpoint,x.endpoint,2048),region:C(t.region,x.region,128),bucket:C(t.bucket,x.bucket,255),schedule:w(t.schedule),pathPrefix:C(t.pathPrefix,x.pathPrefix,1024),virtualHostedStyle:T(t.virtualHostedStyle),retention:E(t.retention)}}function O(e){return D(e)}function k(){try{return globalThis.localStorage??null}catch{return null}}function A(e){try{let t=JSON.parse(e),n=S(t)?t:{},r=D(`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:y})}}catch{return null}}var j={getItem(e){let t=k();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=A(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{k()?.setItem(e,t)}catch{}},removeItem(e){try{k()?.removeItem(e)}catch{}}},M=i()(r(e=>({...x,accessKeyId:``,secretAccessKey:``,sessionToken:``,set:t=>e(e=>{let n={...e,...t};return{...D(n),accessKeyId:C(n.accessKeyId,``,512),secretAccessKey:C(n.secretAccessKey,``,2048),sessionToken:C(n.sessionToken,``,4096)}})}),{name:v,version:y,storage:o(()=>j),partialize:O,migrate:D,merge:(e,t)=>({...t,...D(e),accessKeyId:``,secretAccessKey:``,sessionToken:``})})),N=n();function P(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 F=e=>JSON.stringify([e.baseUrl,e.token]),I={"6h":360*60*1e3,"12h":720*60*1e3,"24h":1440*60*1e3};function L(e,t){return`${e}=${typeof t==`string`?JSON.stringify(t):String(t)}`}function R(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:L(`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=[L(`S3_BACKUP_ENABLED`,!0),L(`S3_ACCESS_KEY_ID`,a),L(`S3_SECRET_ACCESS_KEY`,o),L(`S3_BUCKET`,i),L(`S3_REGION`,r),L(`S3_BACKUP_RETENTION`,e.retention)];return s&&l.push(L(`S3_SESSION_TOKEN`,s)),e.virtualHostedStyle!==`auto`&&l.push(L(`S3_VIRTUAL_HOSTED_STYLE`,e.virtualHostedStyle===`virtual-hosted`)),n&&l.push(L(`S3_ENDPOINT`,n)),c&&l.push(L(`S3_BACKUP_PREFIX`,c)),l.push(L(`S3_BACKUP_INTERVAL`,I[e.schedule])),{ok:!0,value:l.join(`
2
2
  `)}}function z(){let e=M(),t=a(F),[n,r]=(0,_.useState)(null),[i,o]=(0,_.useState)(null),v=(0,_.useRef)(0),y=R(e),b=n?.target===t?n:null,x=i===t;return(0,_.useEffect)(()=>(v.current++,r(null),o(null),()=>{v.current++}),[t]),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(l,{title:`S3 Backup Setup`,description:`Build the server-side configuration supported by Bunqueue v2.8.55.`}),(0,N.jsxs)(`div`,{className:`mb-6 flex items-center justify-between rounded-xl border border-line bg-surface px-5 py-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-surface-2 text-faint`,children:(0,N.jsx)(u,{className:`size-5`})}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`font-semibold text-fg`,children:y.ok?`Configuration draft complete`:`Configuration draft incomplete`}),(0,N.jsx)(`div`,{className:`text-xs text-faint`,children:y.ok?e.schedule===`disabled`?`Safe disable patch ready · not yet applied to the server`:`Target: ${e.bucket.trim()} · not yet applied to the server`:`Complete the required fields to generate server settings`})]})]}),(0,N.jsx)(`span`,{className:y.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:y.ok?`Draft only`:`Configure`})]}),(0,N.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-2.5 text-xs text-faint`,children:`The dashboard cannot change a running Bunqueue server or verify S3 credentials. It generates the exact environment settings; apply them on the server, ensure persistent SQLite storage is configured, then restart Bunqueue. Non-secret draft fields are stored locally.`}),(0,N.jsxs)(c,{className:`mb-6`,children:[(0,N.jsx)(`h2`,{className:`mb-1 text-base font-semibold text-fg`,children:`Connection Settings`}),(0,N.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,N.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,N.jsx)(g,{label:`Endpoint`,children:(0,N.jsx)(m,{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,N.jsx)(g,{label:`Region`,children:(0,N.jsx)(m,{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,N.jsx)(`div`,{className:`md:col-span-2`,children:(0,N.jsx)(g,{label:`Bucket name`,children:(0,N.jsx)(m,{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,N.jsx)(g,{label:`Access key ID`,children:(0,N.jsx)(m,{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,N.jsx)(g,{label:`Secret access key`,children:(0,N.jsx)(m,{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,N.jsx)(`div`,{className:`md:col-span-2`,children:(0,N.jsx)(g,{label:`Session token (optional, for temporary STS credentials)`,children:(0,N.jsx)(m,{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,N.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,N.jsxs)(`div`,{children:[(0,N.jsx)(h,{htmlFor:`s3-backup-schedule`,children:`Backup interval`}),(0,N.jsxs)(p,{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,N.jsx)(`option`,{value:`disabled`,children:`Disabled`}),(0,N.jsx)(`option`,{value:`6h`,children:`Every 6 hours`}),(0,N.jsx)(`option`,{value:`12h`,children:`Every 12 hours`}),(0,N.jsx)(`option`,{value:`24h`,children:`Every 24 hours`})]})]}),(0,N.jsx)(g,{label:`Path prefix (optional)`,children:(0,N.jsx)(m,{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,N.jsxs)(`div`,{children:[(0,N.jsx)(h,{htmlFor:`s3-addressing-style`,children:`Addressing style`}),(0,N.jsxs)(p,{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,N.jsx)(`option`,{value:`auto`,children:`Provider default`}),(0,N.jsx)(`option`,{value:`virtual-hosted`,children:`Virtual-hosted style`}),(0,N.jsx)(`option`,{value:`path-style`,children:`Path style`})]})]}),(0,N.jsx)(g,{label:`Backups to retain`,children:(0,N.jsx)(m,{name:`s3-retention`,type:`number`,min:1,max:1e6,step:1,value:e.retention,onChange:t=>e.set({retention:Number(t.target.value)}),inputMode:`numeric`})})]}),(0,N.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(f,{onClick:async()=>{let e=t,n=++v.current;r(null),o(e);try{let t=await d.storage();if(n!==v.current||F(a.getState())!==e)return;let i=P(t);r({target:e,ok:!i.diskFull,msg:i.diskFull?`Server disk is full`:`Server disk healthy — this does not validate the S3 credentials`})}catch(t){if(n!==v.current||F(a.getState())!==e)return;r({target:e,ok:!1,msg:t.message})}finally{n===v.current&&o(null)}},children:x?`Checking server storage…`:`Check server storage`}),(0,N.jsx)(`span`,{className:`text-xs text-faint`,children:`This checks SQLite disk health only, not S3 connectivity.`}),b&&(0,N.jsx)(`span`,{role:`status`,className:b.ok?`text-xs text-success`:`text-xs text-danger`,children:b.msg})]})]}),(0,N.jsxs)(c,{children:[(0,N.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Server environment`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Credentials stay in memory and are copied only when you request it.`})]}),y.ok&&(0,N.jsx)(s,{value:y.value})]}),y.ok?(0,N.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:y.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,N.jsx)(`ul`,{className:`space-y-1 text-sm text-danger`,"aria-label":`Configuration errors`,children:y.errors.map(e=>(0,N.jsxs)(`li`,{children:[`• `,e]},e))}),(0,N.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`Bunqueue v2.8.55 exposes no dashboard HTTP endpoint for S3 credential tests, manual backups, or backup history; those controls are deliberately not simulated here.`})]})]})}export{z as S3BackupPro};
@@ -1,3 +1,3 @@
1
- import{r as e,t}from"./cn-CMFYpumL.js";import{g as n,t as r}from"./react-vendor-Bjui4wS4.js";import{A as i,C as a,J as o,K as s,O as c,S as l,U as u,W as d,a as f,b as p,d as m,h,p as g,r as _,st as v,u as y,w as b,x,y as S}from"./index-Bn2R06qm.js";import{i as C,n as w,t as T}from"./form-DsUq0w8s.js";var E=e(n(),1),D=r();function O({children:e}){return(0,D.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs text-fg`,children:e})}function k({agentBase:e}){return(0,D.jsx)(l,{children:(0,D.jsxs)(`details`,{className:`group`,children:[(0,D.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2`,children:[(0,D.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`How server control works`}),(0,D.jsx)(`span`,{className:`text-xs text-muted transition-transform group-open:rotate-90`,children:`▶`})]}),(0,D.jsxs)(`div`,{className:`mt-4 space-y-4 text-sm leading-relaxed text-muted`,children:[(0,D.jsxs)(`p`,{children:[`A browser can't start or stop an OS process, so the dashboard talks to a small local`,` `,(0,D.jsx)(`span`,{className:`font-medium text-fg`,children:`control agent`}),` (`,(0,D.jsx)(O,{children:e}),`) that supervises the bunqueue server process — start, stop and restart — and streams its logs back here.`]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Launch & environment`}),(0,D.jsxs)(`p`,{children:[`The agent runs your `,(0,D.jsx)(`span`,{className:`text-fg`,children:`Command`}),` and injects`,` `,(0,D.jsx)(O,{children:`HTTP_PORT`}),`, `,(0,D.jsx)(O,{children:`TCP_PORT`}),` and `,(0,D.jsx)(O,{children:`BUNQUEUE_DATA_PATH`}),` — plus any `,(0,D.jsx)(`span`,{className:`text-fg`,children:`Environment variables`}),` you add — into its environment. The default `,(0,D.jsx)(O,{children:`bunqueue start`}),` needs a globally-installed binary; pointing the command at a local entry (e.g.`,` `,(0,D.jsx)(O,{children:`bun run /path/to/bunqueue/src/main.ts`}),`) works without one.`]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`When changes apply`}),(0,D.jsxs)(`p`,{children:[`Config is editable any time, but `,(0,D.jsx)(`span`,{className:`text-fg`,children:`Command`}),`, ports and data path only take effect on the `,(0,D.jsx)(`span`,{className:`text-fg`,children:`next start/restart`}),` `,`— the running process keeps the config it launched with until then.`]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Data path`}),(0,D.jsxs)(`p`,{children:[`Relative paths resolve against the `,(0,D.jsx)(`span`,{className:`text-fg`,children:`agent's`}),` working directory. SQLite creates the database `,(0,D.jsx)(`span`,{className:`text-fg`,children:`file`}),` but not its parent `,(0,D.jsx)(`span`,{className:`text-fg`,children:`folder`}),` — if start fails with`,` `,(0,D.jsx)(O,{children:`SQLITE_CANTOPEN`}),`, create the directory first or use a path whose folder already exists.`]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Security`}),(0,D.jsxs)(`p`,{children:[`The direct agent listener binds `,(0,D.jsx)(O,{children:`127.0.0.1`}),`, locks CORS to an allowlist (never `,(0,D.jsx)(O,{children:`*`}),`), and rejects a disallowed `,(0,D.jsx)(O,{children:`Origin`}),` or`,` `,(0,D.jsx)(O,{children:`Host`}),` with `,(0,D.jsx)(O,{children:`403`}),`. The all-in-one server's `,(0,D.jsx)(O,{children:`/agent`}),` `,`bridge treats LAN and reverse-proxy access as remote: `,(0,D.jsx)(O,{children:`AGENT_TOKEN`}),` is then mandatory for status, logs, database reads and changes alike. Without it, the bridge stays disabled.`]}),(0,D.jsxs)(`p`,{children:[`If you started the agent with `,(0,D.jsx)(O,{children:`AGENT_TOKEN`}),`, enter that token under`,` `,(0,D.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,D.jsx)(O,{children:`VITE_*`}),` value.`]})]})]})]})})}var A=0,j=e=>Object.entries(e).map(([e,t])=>({id:A++,key:e,value:t})),M=e=>{let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return t};function N(e){let t=e.map(e=>e.trim());return[...new Set(t.filter((e,t,n)=>e&&n.indexOf(e)!==t))]}var P=[`AUTH_TOKENS`,`LOG_LEVEL`,`S3_BACKUP_ENABLED`,`S3_BUCKET`,`METRICS_ENABLED`];function F({value:e,onChange:t,disabled:n}){let[r,i]=(0,E.useState)(()=>j(e)),a=e=>{i(e),t(M(e))},o=(e,t)=>a(r.map(n=>n.id===e?{...n,...t}:n)),s=(e=``)=>a([...r,{id:A++,key:e,value:``}]),c=e=>a(r.filter(t=>t.id!==e)),l=new Set(r.map(e=>e.key.trim()).filter(Boolean)),u=N(r.map(e=>e.key)),d=[...new Set(r.map(e=>e.key.trim()).filter(e=>e&&(/[\s=]/.test(e)||/[a-z]/.test(e))))];return(0,D.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.length===0&&(0,D.jsxs)(`p`,{className:`text-xs leading-relaxed text-faint`,children:[`No custom variables. The agent already injects`,` `,(0,D.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`HTTP_PORT`}),`,`,` `,(0,D.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`TCP_PORT`}),` and`,` `,(0,D.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`BUNQUEUE_DATA_PATH`}),`.`]}),r.map(e=>(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`div`,{className:`w-2/5 shrink-0`,children:(0,D.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,D.jsx)(`span`,{className:`text-faint`,children:`=`}),(0,D.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,D.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,D.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)),u.length>0&&(0,D.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Duplicate key`,u.length>1?`s`:``,` — the last value wins: `,u.join(`, `)]}),d.length>0&&(0,D.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Unusual key`,d.length>1?`s`:``,` — env names are usually UPPER_SNAKE_CASE with no spaces or "=": `,d.join(`, `),`. Saved as-is.`]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,D.jsx)(b,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>s(),children:`+ Add variable`}),P.filter(e=>!l.has(e)).map(e=>(0,D.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))]})]})}var I=[`all`,`stdout`,`stderr`,`sys`],L=e=>`${new Date(e).toLocaleTimeString([],{hour12:!1})}.${String(e%1e3).padStart(3,`0`)}`,R=e=>e===`stderr`?`text-danger/90`:e===`sys`?`text-accent/80`:`text-muted`;function z(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 B(){let{data:e,error:n,loading:r,refetch:i}=H(),a=(0,E.useMemo)(()=>e?.lines??[],[e]),[s,u]=(0,E.useState)(`all`),[d,f]=(0,E.useState)(``),[m,h]=(0,E.useState)(!0),[_,v]=(0,E.useState)(!1),y=(0,E.useRef)(null),b=(0,E.useMemo)(()=>{let e=d.trim().toLowerCase();return a.map(e=>e.line.includes(`\x1B`)?{...e,line:g(e.line)}:e).filter(t=>(s===`all`||t.stream===s)&&(!e||t.line.toLowerCase().includes(e)))},[a,s,d]);(0,E.useEffect)(()=>{if(!m)return;let e=y.current;e&&(e.scrollTop=e.scrollHeight)},[b.length,m]);let w=(0,E.useMemo)(()=>b.map(e=>_?`${L(e.ts)} [${e.stream}] ${e.line}`:e.line).join(`
1
+ import{r as e,t}from"./cn-CMFYpumL.js";import{g as n,t as r}from"./react-vendor-Bjui4wS4.js";import{A as i,C as a,J as o,K as s,O as c,S as l,U as u,W as d,a as f,b as p,d as m,h,p as g,r as _,st as v,u as y,w as b,x,y as S}from"./index-Dr__4DsT.js";import{i as C,n as w,t as T}from"./form-DsUq0w8s.js";var E=e(n(),1),D=r();function O({children:e}){return(0,D.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs text-fg`,children:e})}function k({agentBase:e}){return(0,D.jsx)(l,{children:(0,D.jsxs)(`details`,{className:`group`,children:[(0,D.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2`,children:[(0,D.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`How server control works`}),(0,D.jsx)(`span`,{className:`text-xs text-muted transition-transform group-open:rotate-90`,children:`▶`})]}),(0,D.jsxs)(`div`,{className:`mt-4 space-y-4 text-sm leading-relaxed text-muted`,children:[(0,D.jsxs)(`p`,{children:[`A browser can't start or stop an OS process, so the dashboard talks to a small local`,` `,(0,D.jsx)(`span`,{className:`font-medium text-fg`,children:`control agent`}),` (`,(0,D.jsx)(O,{children:e}),`) that supervises the bunqueue server process — start, stop and restart — and streams its logs back here.`]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Launch & environment`}),(0,D.jsxs)(`p`,{children:[`The agent runs your `,(0,D.jsx)(`span`,{className:`text-fg`,children:`Command`}),` and injects`,` `,(0,D.jsx)(O,{children:`HTTP_PORT`}),`, `,(0,D.jsx)(O,{children:`TCP_PORT`}),` and `,(0,D.jsx)(O,{children:`BUNQUEUE_DATA_PATH`}),` — plus any `,(0,D.jsx)(`span`,{className:`text-fg`,children:`Environment variables`}),` you add — into its environment. The default `,(0,D.jsx)(O,{children:`bunqueue start`}),` needs a globally-installed binary; pointing the command at a local entry (e.g.`,` `,(0,D.jsx)(O,{children:`bun run /path/to/bunqueue/src/main.ts`}),`) works without one.`]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`When changes apply`}),(0,D.jsxs)(`p`,{children:[`Config is editable any time, but `,(0,D.jsx)(`span`,{className:`text-fg`,children:`Command`}),`, ports and data path only take effect on the `,(0,D.jsx)(`span`,{className:`text-fg`,children:`next start/restart`}),` `,`— the running process keeps the config it launched with until then.`]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Data path`}),(0,D.jsxs)(`p`,{children:[`Relative paths resolve against the `,(0,D.jsx)(`span`,{className:`text-fg`,children:`agent's`}),` working directory. SQLite creates the database `,(0,D.jsx)(`span`,{className:`text-fg`,children:`file`}),` but not its parent `,(0,D.jsx)(`span`,{className:`text-fg`,children:`folder`}),` — if start fails with`,` `,(0,D.jsx)(O,{children:`SQLITE_CANTOPEN`}),`, create the directory first or use a path whose folder already exists.`]})]}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Security`}),(0,D.jsxs)(`p`,{children:[`The direct agent listener binds `,(0,D.jsx)(O,{children:`127.0.0.1`}),`, locks CORS to an allowlist (never `,(0,D.jsx)(O,{children:`*`}),`), and rejects a disallowed `,(0,D.jsx)(O,{children:`Origin`}),` or`,` `,(0,D.jsx)(O,{children:`Host`}),` with `,(0,D.jsx)(O,{children:`403`}),`. The all-in-one server's `,(0,D.jsx)(O,{children:`/agent`}),` `,`bridge treats LAN and reverse-proxy access as remote: `,(0,D.jsx)(O,{children:`AGENT_TOKEN`}),` is then mandatory for status, logs, database reads and changes alike. Without it, the bridge stays disabled.`]}),(0,D.jsxs)(`p`,{children:[`If you started the agent with `,(0,D.jsx)(O,{children:`AGENT_TOKEN`}),`, enter that token under`,` `,(0,D.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,D.jsx)(O,{children:`VITE_*`}),` value.`]})]})]})]})})}var A=0,j=e=>Object.entries(e).map(([e,t])=>({id:A++,key:e,value:t})),M=e=>{let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return t};function N(e){let t=e.map(e=>e.trim());return[...new Set(t.filter((e,t,n)=>e&&n.indexOf(e)!==t))]}var P=[`AUTH_TOKENS`,`LOG_LEVEL`,`S3_BACKUP_ENABLED`,`S3_BUCKET`,`METRICS_ENABLED`];function F({value:e,onChange:t,disabled:n}){let[r,i]=(0,E.useState)(()=>j(e)),a=e=>{i(e),t(M(e))},o=(e,t)=>a(r.map(n=>n.id===e?{...n,...t}:n)),s=(e=``)=>a([...r,{id:A++,key:e,value:``}]),c=e=>a(r.filter(t=>t.id!==e)),l=new Set(r.map(e=>e.key.trim()).filter(Boolean)),u=N(r.map(e=>e.key)),d=[...new Set(r.map(e=>e.key.trim()).filter(e=>e&&(/[\s=]/.test(e)||/[a-z]/.test(e))))];return(0,D.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.length===0&&(0,D.jsxs)(`p`,{className:`text-xs leading-relaxed text-faint`,children:[`No custom variables. The agent already injects`,` `,(0,D.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`HTTP_PORT`}),`,`,` `,(0,D.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`TCP_PORT`}),` and`,` `,(0,D.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`BUNQUEUE_DATA_PATH`}),`.`]}),r.map(e=>(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`div`,{className:`w-2/5 shrink-0`,children:(0,D.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,D.jsx)(`span`,{className:`text-faint`,children:`=`}),(0,D.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,D.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,D.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)),u.length>0&&(0,D.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Duplicate key`,u.length>1?`s`:``,` — the last value wins: `,u.join(`, `)]}),d.length>0&&(0,D.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Unusual key`,d.length>1?`s`:``,` — env names are usually UPPER_SNAKE_CASE with no spaces or "=": `,d.join(`, `),`. Saved as-is.`]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,D.jsx)(b,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>s(),children:`+ Add variable`}),P.filter(e=>!l.has(e)).map(e=>(0,D.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))]})]})}var I=[`all`,`stdout`,`stderr`,`sys`],L=e=>`${new Date(e).toLocaleTimeString([],{hour12:!1})}.${String(e%1e3).padStart(3,`0`)}`,R=e=>e===`stderr`?`text-danger/90`:e===`sys`?`text-accent/80`:`text-muted`;function z(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 B(){let{data:e,error:n,loading:r,refetch:i}=H(),a=(0,E.useMemo)(()=>e?.lines??[],[e]),[s,u]=(0,E.useState)(`all`),[d,f]=(0,E.useState)(``),[m,h]=(0,E.useState)(!0),[_,v]=(0,E.useState)(!1),y=(0,E.useRef)(null),b=(0,E.useMemo)(()=>{let e=d.trim().toLowerCase();return a.map(e=>e.line.includes(`\x1B`)?{...e,line:g(e.line)}:e).filter(t=>(s===`all`||t.stream===s)&&(!e||t.line.toLowerCase().includes(e)))},[a,s,d]);(0,E.useEffect)(()=>{if(!m)return;let e=y.current;e&&(e.scrollTop=e.scrollHeight)},[b.length,m]);let w=(0,E.useMemo)(()=>b.map(e=>_?`${L(e.ts)} [${e.stream}] ${e.line}`:e.line).join(`
2
2
  `),[b,_]);return(0,D.jsxs)(l,{padded:!1,className:`overflow-hidden`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-4 py-3`,children:[(0,D.jsx)(`h3`,{className:`mr-1 text-base font-semibold text-fg`,children:`Process logs`}),(0,D.jsx)(C,{options:I,value:s,onChange:u}),(0,D.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,D.jsx)(o,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,D.jsx)(`input`,{value:d,onChange:e=>f(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,D.jsx)(V,{on:m,onClick:()=>h(e=>!e),label:`Follow`}),(0,D.jsx)(V,{on:_,onClick:()=>v(e=>!e),label:`Times`}),(0,D.jsx)(c,{value:w}),(0,D.jsx)(`button`,{type:`button`,onClick:()=>{z(w)},disabled:b.length===0,className:`rounded-md border border-line bg-surface-2 px-2 py-1 text-xs text-muted transition-colors hover:text-fg disabled:opacity-40`,children:`Download`})]}),n&&e&&(0,D.jsx)(`div`,{className:`border-b border-line px-4 pt-3 font-sans`,children:(0,D.jsx)(x,{message:`Process-log refresh failed — showing the last received lines. ${n.message}`,onRetry:i})}),(0,D.jsx)(`div`,{ref:y,className:`max-h-80 min-h-40 overflow-y-auto p-4 font-mono text-xs leading-relaxed`,children:r&&!e&&!n?(0,D.jsx)(`div`,{className:`font-sans`,children:(0,D.jsx)(p,{label:`Loading process logs…`})}):n&&!e?(0,D.jsx)(`div`,{className:`font-sans`,children:(0,D.jsx)(S,{error:n,onRetry:i})}):b.length===0?(0,D.jsx)(`p`,{className:`text-faint`,children:a.length===0?`No output yet.`:`No lines match the current filter.`}):b.map(e=>(0,D.jsxs)(`div`,{className:t(`whitespace-pre-wrap`,R(e.stream)),children:[_&&(0,D.jsx)(`span`,{className:`mr-2 text-faint`,children:L(e.ts)}),e.line]},e.seq))}),(0,D.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-[11px] text-faint`,children:[(0,D.jsx)(`span`,{children:n&&!e?`logs unavailable`:b.length===a.length?`${a.length} lines`:`${b.length} of ${a.length} lines`}),(0,D.jsx)(`span`,{children:n?`refresh failed`:m?`following tail`:`paused`})]})]})}function V({on:e,onClick:n,label:r}){return(0,D.jsx)(`button`,{type:`button`,onClick:n,"aria-pressed":e,className:t(`rounded-md border px-2 py-1 text-xs transition-colors`,e?`border-accent/40 bg-accent/10 text-accent`:`border-line bg-surface-2 text-muted hover:text-fg`),children:r})}function H(){return i(()=>v.control.logs(),[])}var U={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 W({startedAt:e}){let[,t]=(0,E.useState)(0);return(0,E.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,D.jsx)(D.Fragment,{children:m((Date.now()-e)/1e3)})}function G({label:e,children:t,title:n}){return(0,D.jsxs)(`div`,{className:`min-w-0`,title:n,children:[(0,D.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e}),(0,D.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,children:t})]})}function K({status:e,agentBase:n,transitioning:r,stale:i=!1,vitals:a=null,busy:o,onStart:l,onStop:p,onRestart:m}){let h=e?.status??`stopped`,g=h===`running`,_=U[h]??U.stopped,v=!!e?.healthy&&!i,y=!g&&e?.exitCode!=null&&e.exitCode!==0,x=e?.runningConfig??e?.config??null,S=`http://localhost:${x?.httpPort??6790}`;return(0,D.jsxs)(`section`,{className:`mb-6 overflow-hidden rounded-xl border border-line bg-surface`,children:[(0,D.jsx)(`div`,{className:t(`h-0.5 bg-gradient-to-r to-transparent`,g&&v?`from-emerald-400/80 via-emerald-400/25`:g||r?`from-amber-400/80 via-amber-400/25`:`from-red-400/70 via-red-400/20`)}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-5 p-5 lg:flex-row lg:items-center lg:justify-between`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,D.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[g&&v&&(0,D.jsx)(`span`,{className:`absolute inline-flex size-full rounded-full bg-emerald-400 opacity-50 motion-safe:animate-ping`}),(0,D.jsx)(`span`,{className:t(`relative inline-flex size-3.5 rounded-full`,_.dot)})]}),(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,D.jsx)(`span`,{className:t(`text-2xl font-bold tracking-tight`,_.tone),children:r&&o?`${o}…`:_.label}),e?.version&&(0,D.jsxs)(`span`,{className:`font-mono text-xs text-muted`,children:[`bunqueue v`,e.version]}),y&&(0,D.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,D.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted`,children:i?(0,D.jsxs)(`span`,{className:`text-warning`,children:[`last known: pid `,e?.pid??`—`,` — agent unreachable, state may have changed`]}):g?(0,D.jsxs)(D.Fragment,{children:[v?`healthy`:`waiting for health…`,` · pid `,e?.pid??`—`,` · up`,` `,e?.startedAt?(0,D.jsx)(W,{startedAt:e.startedAt}):`—`]}):`process not running — start it below or point the dashboard at an external server`})]})]}),(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,D.jsxs)(b,{variant:`success`,disabled:g||r||i,onClick:l,children:[(0,D.jsx)(d,{className:`size-4`}),` Start`]}),(0,D.jsxs)(b,{variant:`warning`,disabled:!g||r||i,onClick:p,children:[(0,D.jsx)(u,{className:`size-4`}),` Stop`]}),(0,D.jsxs)(b,{disabled:r||i,onClick:m,children:[(0,D.jsx)(s,{className:`size-4`}),` Restart`]})]})]}),(0,D.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,D.jsx)(G,{label:`Memory`,children:a?.memory?.rss==null?(0,D.jsx)(`span`,{className:`text-faint`,children:`—`}):(0,D.jsxs)(`span`,{title:`heap ${a.memory.heapUsed??`?`} / ${a.memory.heapTotal??`?`} MB`,children:[a.memory.rss,` MB rss`]})}),(0,D.jsx)(G,{label:`Connections`,children:a?.connections?`${a.connections.tcp??0} tcp · ${a.connections.ws??0} ws · ${a.connections.sse??0} sse`:(0,D.jsx)(`span`,{className:`text-faint`,children:`—`})}),(0,D.jsx)(G,{label:`API endpoint`,title:S,children:g?(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(`a`,{href:`${S}/health`,target:`_blank`,rel:`noreferrer`,className:`truncate text-accent hover:underline`,children:S}),(0,D.jsx)(c,{value:S})]}):(0,D.jsx)(`span`,{className:`text-faint`,children:S})}),(0,D.jsx)(G,{label:`Ports`,children:x?`${x.httpPort} http · ${x.tcpPort} tcp`:`—`}),(0,D.jsx)(G,{label:`Started`,children:g&&e?.startedAt?f(e.startedAt):`—`}),(0,D.jsx)(G,{label:`Control agent`,title:n,children:n.replace(/^https?:\/\//,``)}),(0,D.jsx)(G,{label:`Launch command`,title:x?.command,children:x?.command??`—`})]})]})}var q=[{key:`size`,label:`Database`,color:`bg-accent`},{key:`walSize`,label:`WAL`,color:`bg-amber-400`},{key:`shmSize`,label:`SHM`,color:`bg-zinc-500`}];function J({db:e}){let n=e.totalSize||0;return(0,D.jsxs)(l,{children:[(0,D.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,D.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Storage`}),(0,D.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:e.exists?`${_(n)} on disk`:`not created yet`})]}),(0,D.jsxs)(`p`,{className:`mb-4 flex items-center gap-1.5 truncate font-mono text-xs text-faint`,title:e.path,children:[(0,D.jsx)(`span`,{className:`truncate`,children:e.path}),(0,D.jsx)(c,{value:e.path})]}),e.exists&&n>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-surface-2`,children:q.map(r=>{let i=e[r.key];return i?(0,D.jsx)(`div`,{className:t(`h-full`,r.color),style:{width:`${i/n*100}%`},title:`${r.label}: ${_(i)}`},r.key):null})}),(0,D.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 font-mono text-[11px] text-faint`,children:[q.map(n=>(0,D.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,D.jsx)(`span`,{className:t(`size-2 rounded-full`,n.color)}),n.label,` `,(0,D.jsx)(`span`,{className:`text-fg`,children:_(e[n.key])})]},n.key)),e.mtimeMs?(0,D.jsxs)(`span`,{className:`ml-auto`,children:[`written `,y(e.mtimeMs)]}):null]})]}):(0,D.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 Y(){let{data:e,error:t,refetch:n}=i(()=>v.control.status(),[]),[r,o]=(0,E.useState)(null),[s,c]=(0,E.useState)(null),u=e?.status===`running`,{data:d}=i(()=>u?v.health():Promise.resolve(null),[u]),f=u?d??null:null,p=f?.connections?` This drops ${f.connections.tcp??0} TCP / ${f.connections.ws??0} WS connections; in-flight jobs are interrupted.`:` In-flight jobs are interrupted.`,m=async(e,t,r)=>{if(!(r&&!window.confirm(r))){o(e),c(null);try{await t(),await n()}catch(e){c(e.message)}finally{o(null)}}};if(t&&!e)return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(h,{title:`Server`,description:`Start, stop and restart the bunqueue server.`}),(0,D.jsx)(x,{message:`Control agent unreachable — server lifecycle controls are unavailable.`,onRetry:n}),(0,D.jsxs)(l,{children:[(0,D.jsx)(a,{title:`Control agent not running`}),(0,D.jsxs)(`p`,{className:`text-sm text-muted`,children:[`The local control agent is unreachable at`,` `,(0,D.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:v.agentBase}),`. It manages the bunqueue server process (start / stop / restart). Start it with:`]}),(0,D.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
3
  `,`bun run agent`,` `,`# agent only, if the dashboard is already running`]}),(0,D.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`This page reconnects automatically once the agent is up — no reload needed.`})]})]});let g=e?.status??`stopped`,_=g===`running`,y=g===`starting`||g===`stopping`||r!=null,b=t!=null&&e!=null;return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(h,{title:`Server`,description:`Supervise the bunqueue server process — lifecycle, configuration, storage and logs.`}),s&&(0,D.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:s}),b&&(0,D.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,D.jsx)(K,{status:e,agentBase:v.agentBase,stale:b,vitals:f,transitioning:y,busy:r,onStart:()=>m(`starting`,()=>v.control.start()),onStop:()=>m(`stopping`,()=>v.control.stop(),`Stop the bunqueue server?${p}`),onRestart:()=>m(`restarting`,()=>v.control.restart(),`Restart the bunqueue server?${p}`)}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,D.jsx)(X,{status:e,onSaved:n,running:_,transitioning:y}),(0,D.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e?.db&&(0,D.jsx)(J,{db:e.db}),(0,D.jsx)(B,{})]})]}),(0,D.jsx)(`div`,{className:`mt-6`,children:(0,D.jsx)(k,{agentBase:v.agentBase})})]})}function X({status:e,onSaved:t,running:n,transitioning:r}){let[i,o]=(0,E.useState)(null),[c,u]=(0,E.useState)(!1),[d,f]=(0,E.useState)(!1),[p,m]=(0,E.useState)(null);(0,E.useEffect)(()=>{e?.config&&!i&&o(e.config)},[e,i]);let h=i??e?.config??null;if(!h)return(0,D.jsx)(l,{children:`Loading…`});let g=e=>o({...h,...e}),_=e?.runningConfig??null,y=(e={})=>JSON.stringify(Object.keys(e).sort().map(t=>[t,e[t]])),x=[];_!=null&&(_.command!==h.command&&x.push(`command`),_.httpPort!==h.httpPort&&x.push(`HTTP port`),_.tcpPort!==h.tcpPort&&x.push(`TCP port`),_.dataPath!==h.dataPath&&x.push(`data path`),y(_.extraEnv)!==y(h.extraEnv)&&x.push(`environment variables`));let S=n&&x.length>0,C=r||d,O=()=>{u(!0),setTimeout(()=>u(!1),2e3)},k=()=>{let e=e=>Number.isInteger(e)&&e>=1&&e<=65535;return e(h.httpPort)?e(h.tcpPort)?h.httpPort===h.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`},A=async()=>{let e=k();if(e){m(e);return}m(null);try{await v.control.setConfig(h),O(),t()}catch(e){m(e.message)}};return(0,D.jsxs)(l,{children:[(0,D.jsx)(a,{title:`Configuration`}),(0,D.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,D.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),A()},children:[(0,D.jsx)(T,{label:`Command`,hint:`The exact command the agent runs to launch bunqueue. It receives HTTP_PORT, TCP_PORT and BUNQUEUE_DATA_PATH in its environment. The default needs a global 'bunqueue' binary — or point it at a local entry, e.g. bun run /path/to/bunqueue/src/main.ts.`,children:(0,D.jsx)(w,{name:`server-command`,autoComplete:`off`,spellCheck:!1,value:h.command,disabled:C,onChange:e=>g({command:e.target.value}),placeholder:`bunqueue start`})}),(0,D.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,D.jsx)(T,{label:`HTTP port`,hint:`Dashboard API + SSE.`,children:(0,D.jsx)(w,{name:`server-http-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:h.httpPort,disabled:C,onChange:e=>g({httpPort:Number(e.target.value)})})}),(0,D.jsx)(T,{label:`TCP port`,hint:`Binary protocol. Must differ from HTTP.`,children:(0,D.jsx)(w,{name:`server-tcp-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:h.tcpPort,disabled:C,onChange:e=>g({tcpPort:Number(e.target.value)})})})]}),(0,D.jsx)(T,{label:`Data path`,hint:`SQLite database file, relative to the agent's working directory. The parent folder must already exist — SQLite creates the file, not the directory.`,children:(0,D.jsx)(w,{name:`server-data-path`,autoComplete:`off`,spellCheck:!1,value:h.dataPath,disabled:C,onChange:e=>g({dataPath:e.target.value})})}),(0,D.jsx)(T,{label:`Environment variables`,hint:`Injected into the server process on start, on top of the ports + data path. Applies on the next restart.`,children:(0,D.jsx)(F,{value:h.extraEnv??{},onChange:e=>g({extraEnv:e}),disabled:C})}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,D.jsx)(b,{type:`submit`,variant:`accent`,size:`sm`,disabled:C,children:`Save config`}),n&&(0,D.jsxs)(b,{variant:`warning`,size:`sm`,disabled:C,onClick:async()=>{let e=k();if(e){m(e);return}let n=x.length>0?` Changed: ${x.join(`, `)}.`:``;if(window.confirm(`Save configuration and restart the server to apply it?${n}`)){m(null),f(!0);try{await v.control.setConfig(h),await v.control.restart(),O(),t()}catch(e){m(e.message)}finally{f(!1)}}},children:[(0,D.jsx)(s,{className:`size-3.5`}),` Save & restart`]}),S&&!c&&(0,D.jsx)(`span`,{className:`text-xs text-warning`,children:`Restart to apply changes`}),c&&(0,D.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved`}),p&&(0,D.jsx)(`span`,{role:`status`,className:`text-xs text-danger`,children:p})]})]})]})}export{Y as ServerControl};
@@ -1 +1 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{a as r,o as i,t as a}from"./connectionStore-Cd9-3Fw0.js";import{B as o,C as s,S as c,T as l,Z as u,h as d,w as f}from"./index-Bn2R06qm.js";import{a as p,n as m,t as h}from"./form-DsUq0w8s.js";var g=e(t(),1),_=n(),v=[[`1000`,`1 second`],[`2000`,`2 seconds`],[`3000`,`3 seconds`],[`5000`,`5 seconds`],[`10000`,`10 seconds`]],y=1e4,b=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;async function x(e,t={},n=y){let r=new AbortController,i=t.signal,a=i?AbortSignal.any([i,r.signal]):r.signal,o=Error(`Connection test timed out after ${Math.ceil(n/1e3)} seconds.`),s,c,l=new Promise((e,t)=>{s=setTimeout(()=>{r.abort(o),t(o)},n)}),u=i?new Promise((e,t)=>{let n=()=>{t(i.reason??new DOMException(`Connection test aborted`,`AbortError`))};i.aborted?n():(i.addEventListener(`abort`,n,{once:!0}),c=()=>i.removeEventListener(`abort`,n))}):null;try{let n=(async()=>{let n=await fetch(e,{...t,signal:a});if(!n.ok&&n.status!==503)throw Error(`HTTP ${n.status}`);let r=await n.json();if(typeof r!=`object`||!r||Array.isArray(r))throw Error(`Malformed health response`);let i=r;if(typeof i.ok!=`boolean`||i.status!==`healthy`&&i.status!==`degraded`||!Number.isSafeInteger(i.uptime)||i.uptime<0||typeof i.version!=`string`||!b.test(i.version)||i.ok!==(i.status===`healthy`))throw Error(`Malformed health response`);return{response:n,health:i}})();return await Promise.race(u?[n,l,u]:[n,l])}catch(e){throw r.signal.aborted&&r.signal.reason===o?o:e}finally{s!==void 0&&clearTimeout(s),c?.()}}function S(){let{baseUrl:e,token:t,agentToken:n,refreshMs:y,saveConnection:b,setRefreshMs:S}=i(),{theme:C,setTheme:w}=u(),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(null),[k,A]=(0,g.useState)(e),[j,M]=(0,g.useState)(t),[N,P]=(0,g.useState)(n),[F,I]=(0,g.useState)(!1),[L,R]=(0,g.useState)(!1),[z,B]=(0,g.useState)(null),[V,H]=(0,g.useState)(null),U=(0,g.useRef)(!0),W=(0,g.useRef)(0),G=(0,g.useRef)(null),K=(0,g.useRef)(null),q=(0,g.useCallback)(()=>{K.current!==null&&(clearTimeout(K.current),K.current=null),U.current&&H(null)},[]),J=(0,g.useCallback)(()=>{W.current+=1,G.current?.abort(new DOMException(`Connection test superseded`,`AbortError`)),G.current=null,U.current&&(E(!1),O(null))},[]);return(0,g.useEffect)(()=>(U.current=!0,()=>{U.current=!1,W.current+=1,G.current?.abort(new DOMException(`Settings unmounted`,`AbortError`)),G.current=null,K.current!==null&&(clearTimeout(K.current),K.current=null)}),[]),(0,g.useEffect)(()=>{A(e),M(t),P(n),J()},[n,e,J,t]),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(d,{title:`Settings`,description:`Connection and appearance.`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(c,{children:[(0,_.jsx)(s,{title:`Connection`}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,_.jsx)(h,{label:`Server URL`,children:(0,_.jsx)(m,{name:`server-url`,value:k,onChange:e=>{J(),q(),A(e.target.value),B(null)},placeholder:`/api or https://queue.example.com`,autoComplete:`off`,inputMode:`url`,"aria-invalid":z?!0:void 0,"aria-describedby":z?`server-url-error`:`server-url-help`})}),z&&(0,_.jsx)(`p`,{id:`server-url-error`,className:`-mt-2 text-xs text-danger`,children:z}),(0,_.jsxs)(`p`,{id:`server-url-help`,className:`-mt-2 text-xs text-faint`,children:[`Use `,(0,_.jsx)(`code`,{className:`font-mono`,children:`/api`}),` in dev (proxied to localhost:6790), or the server origin in production.`]}),(0,_.jsx)(h,{label:`Bearer token (optional)`,hint:`Kept in memory only — re-enter after reload. Never bake secrets into VITE_* variables.`,htmlFor:`bearer-token`,children:(0,_.jsxs)(`div`,{className:`relative`,children:[(0,_.jsx)(m,{id:`bearer-token`,name:`bearer-token`,type:F?`text`:`password`,value:j,onChange:e=>{J(),q(),M(e.target.value)},placeholder:`only if AUTH_TOKENS is set`,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,_.jsx)(l,{"aria-label":F?`Hide token`:`Show token`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>I(e=>!e),children:(0,_.jsx)(o,{className:`size-4`})})]})}),(0,_.jsx)(h,{label:`Agent token (optional)`,hint:`Only if the control agent runs with AGENT_TOKEN. Kept in memory; re-enter after reload.`,htmlFor:`agent-token`,children:(0,_.jsxs)(`div`,{className:`relative`,children:[(0,_.jsx)(m,{id:`agent-token`,name:`agent-token`,type:L?`text`:`password`,value:N,onChange:e=>{J(),q(),P(e.target.value)},placeholder:`only if AGENT_TOKEN is set`,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,_.jsx)(l,{"aria-label":L?`Hide agent token`:`Show agent token`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>R(e=>!e),children:(0,_.jsx)(o,{className:`size-4`})})]})}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,_.jsx)(f,{variant:`accent`,onClick:()=>{J();let e=r(k);if(!e){B(a);return}B(null),A(e);let t=b({baseUrl:e,token:j,agentToken:N});q(),H({persisted:t.persisted,message:t.persisted?`Saved ✓`:`Saved for this session only — browser storage unavailable${t.error?`: ${t.error}`:`.`}`}),K.current=setTimeout(()=>{K.current=null,U.current&&H(null)},4e3)},children:`Save`}),(0,_.jsx)(f,{onClick:async()=>{J();let e=r(k);if(!e){B(a),O({ok:!1,msg:a});return}B(null);let t=W.current,n=new AbortController,o=i.getState(),s=()=>{let e=i.getState();return U.current&&t===W.current&&!n.signal.aborted&&e.baseUrl===o.baseUrl&&e.token===o.token&&e.agentToken===o.agentToken};G.current=n,E(!0),O(null);let c=performance.now();try{let{response:t,health:r}=await x(`${e}/health`,{headers:j.trim()?{Authorization:`Bearer ${j.trim()}`}:void 0,signal:n.signal});if(!s())return;let i=Math.round(performance.now()-c),a=t.status===503||r.status===`degraded`;O({ok:!a,msg:`${a?`Server reachable`:`Connected`} in ${i}ms · bunqueue v${r.version}${a?` · degraded`:``}`})}catch(e){if(!s())return;O({ok:!1,msg:e.message})}finally{U.current&&t===W.current&&(G.current=null,E(!1))}},children:T?`Restart test`:`Test connection`}),V&&(0,_.jsx)(`span`,{role:`status`,className:V.persisted?`text-sm text-success`:`text-sm text-warning`,children:V.message}),D&&(0,_.jsx)(`span`,{role:`status`,className:D.ok?`text-sm text-success`:`text-sm text-danger`,children:D.msg})]}),(0,_.jsx)(`p`,{className:`-mt-1 text-xs text-faint`,children:`Test checks the values above as typed. Saving repoints every page at the new server immediately.`})]})]}),(0,_.jsxs)(c,{children:[(0,_.jsx)(s,{title:`Appearance & refresh`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,_.jsx)(h,{label:`Theme`,children:(0,_.jsxs)(p,{name:`theme`,autoComplete:`off`,value:C,onChange:e=>w(e.target.value),children:[(0,_.jsx)(`option`,{value:`dark`,children:`Dark`}),(0,_.jsx)(`option`,{value:`light`,children:`Light`})]})}),(0,_.jsx)(h,{label:`Refresh interval`,children:(0,_.jsx)(p,{name:`refresh-interval`,autoComplete:`off`,value:String(y),onChange:e=>S(Number(e.target.value)),children:v.map(([e,t])=>(0,_.jsx)(`option`,{value:e,children:t},e))})})]})]})]})]})}export{S as Settings};
1
+ import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{a as r,o as i,t as a}from"./connectionStore-Cd9-3Fw0.js";import{B as o,C as s,S as c,T as l,Z as u,h as d,w as f}from"./index-Dr__4DsT.js";import{a as p,n as m,t as h}from"./form-DsUq0w8s.js";var g=e(t(),1),_=n(),v=[[`1000`,`1 second`],[`2000`,`2 seconds`],[`3000`,`3 seconds`],[`5000`,`5 seconds`],[`10000`,`10 seconds`]],y=1e4,b=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;async function x(e,t={},n=y){let r=new AbortController,i=t.signal,a=i?AbortSignal.any([i,r.signal]):r.signal,o=Error(`Connection test timed out after ${Math.ceil(n/1e3)} seconds.`),s,c,l=new Promise((e,t)=>{s=setTimeout(()=>{r.abort(o),t(o)},n)}),u=i?new Promise((e,t)=>{let n=()=>{t(i.reason??new DOMException(`Connection test aborted`,`AbortError`))};i.aborted?n():(i.addEventListener(`abort`,n,{once:!0}),c=()=>i.removeEventListener(`abort`,n))}):null;try{let n=(async()=>{let n=await fetch(e,{...t,signal:a});if(!n.ok&&n.status!==503)throw Error(`HTTP ${n.status}`);let r=await n.json();if(typeof r!=`object`||!r||Array.isArray(r))throw Error(`Malformed health response`);let i=r;if(typeof i.ok!=`boolean`||i.status!==`healthy`&&i.status!==`degraded`||!Number.isSafeInteger(i.uptime)||i.uptime<0||typeof i.version!=`string`||!b.test(i.version)||i.ok!==(i.status===`healthy`))throw Error(`Malformed health response`);return{response:n,health:i}})();return await Promise.race(u?[n,l,u]:[n,l])}catch(e){throw r.signal.aborted&&r.signal.reason===o?o:e}finally{s!==void 0&&clearTimeout(s),c?.()}}function S(){let{baseUrl:e,token:t,agentToken:n,refreshMs:y,saveConnection:b,setRefreshMs:S}=i(),{theme:C,setTheme:w}=u(),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(null),[k,A]=(0,g.useState)(e),[j,M]=(0,g.useState)(t),[N,P]=(0,g.useState)(n),[F,I]=(0,g.useState)(!1),[L,R]=(0,g.useState)(!1),[z,B]=(0,g.useState)(null),[V,H]=(0,g.useState)(null),U=(0,g.useRef)(!0),W=(0,g.useRef)(0),G=(0,g.useRef)(null),K=(0,g.useRef)(null),q=(0,g.useCallback)(()=>{K.current!==null&&(clearTimeout(K.current),K.current=null),U.current&&H(null)},[]),J=(0,g.useCallback)(()=>{W.current+=1,G.current?.abort(new DOMException(`Connection test superseded`,`AbortError`)),G.current=null,U.current&&(E(!1),O(null))},[]);return(0,g.useEffect)(()=>(U.current=!0,()=>{U.current=!1,W.current+=1,G.current?.abort(new DOMException(`Settings unmounted`,`AbortError`)),G.current=null,K.current!==null&&(clearTimeout(K.current),K.current=null)}),[]),(0,g.useEffect)(()=>{A(e),M(t),P(n),J()},[n,e,J,t]),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(d,{title:`Settings`,description:`Connection and appearance.`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(c,{children:[(0,_.jsx)(s,{title:`Connection`}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,_.jsx)(h,{label:`Server URL`,children:(0,_.jsx)(m,{name:`server-url`,value:k,onChange:e=>{J(),q(),A(e.target.value),B(null)},placeholder:`/api or https://queue.example.com`,autoComplete:`off`,inputMode:`url`,"aria-invalid":z?!0:void 0,"aria-describedby":z?`server-url-error`:`server-url-help`})}),z&&(0,_.jsx)(`p`,{id:`server-url-error`,className:`-mt-2 text-xs text-danger`,children:z}),(0,_.jsxs)(`p`,{id:`server-url-help`,className:`-mt-2 text-xs text-faint`,children:[`Use `,(0,_.jsx)(`code`,{className:`font-mono`,children:`/api`}),` in dev (proxied to localhost:6790), or the server origin in production.`]}),(0,_.jsx)(h,{label:`Bearer token (optional)`,hint:`Kept in memory only — re-enter after reload. Never bake secrets into VITE_* variables.`,htmlFor:`bearer-token`,children:(0,_.jsxs)(`div`,{className:`relative`,children:[(0,_.jsx)(m,{id:`bearer-token`,name:`bearer-token`,type:F?`text`:`password`,value:j,onChange:e=>{J(),q(),M(e.target.value)},placeholder:`only if AUTH_TOKENS is set`,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,_.jsx)(l,{"aria-label":F?`Hide token`:`Show token`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>I(e=>!e),children:(0,_.jsx)(o,{className:`size-4`})})]})}),(0,_.jsx)(h,{label:`Agent token (optional)`,hint:`Only if the control agent runs with AGENT_TOKEN. Kept in memory; re-enter after reload.`,htmlFor:`agent-token`,children:(0,_.jsxs)(`div`,{className:`relative`,children:[(0,_.jsx)(m,{id:`agent-token`,name:`agent-token`,type:L?`text`:`password`,value:N,onChange:e=>{J(),q(),P(e.target.value)},placeholder:`only if AGENT_TOKEN is set`,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,_.jsx)(l,{"aria-label":L?`Hide agent token`:`Show agent token`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>R(e=>!e),children:(0,_.jsx)(o,{className:`size-4`})})]})}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,_.jsx)(f,{variant:`accent`,onClick:()=>{J();let e=r(k);if(!e){B(a);return}B(null),A(e);let t=b({baseUrl:e,token:j,agentToken:N});q(),H({persisted:t.persisted,message:t.persisted?`Saved ✓`:`Saved for this session only — browser storage unavailable${t.error?`: ${t.error}`:`.`}`}),K.current=setTimeout(()=>{K.current=null,U.current&&H(null)},4e3)},children:`Save`}),(0,_.jsx)(f,{onClick:async()=>{J();let e=r(k);if(!e){B(a),O({ok:!1,msg:a});return}B(null);let t=W.current,n=new AbortController,o=i.getState(),s=()=>{let e=i.getState();return U.current&&t===W.current&&!n.signal.aborted&&e.baseUrl===o.baseUrl&&e.token===o.token&&e.agentToken===o.agentToken};G.current=n,E(!0),O(null);let c=performance.now();try{let{response:t,health:r}=await x(`${e}/health`,{headers:j.trim()?{Authorization:`Bearer ${j.trim()}`}:void 0,signal:n.signal});if(!s())return;let i=Math.round(performance.now()-c),a=t.status===503||r.status===`degraded`;O({ok:!a,msg:`${a?`Server reachable`:`Connected`} in ${i}ms · bunqueue v${r.version}${a?` · degraded`:``}`})}catch(e){if(!s())return;O({ok:!1,msg:e.message})}finally{U.current&&t===W.current&&(G.current=null,E(!1))}},children:T?`Restart test`:`Test connection`}),V&&(0,_.jsx)(`span`,{role:`status`,className:V.persisted?`text-sm text-success`:`text-sm text-warning`,children:V.message}),D&&(0,_.jsx)(`span`,{role:`status`,className:D.ok?`text-sm text-success`:`text-sm text-danger`,children:D.msg})]}),(0,_.jsx)(`p`,{className:`-mt-1 text-xs text-faint`,children:`Test checks the values above as typed. Saving repoints every page at the new server immediately.`})]})]}),(0,_.jsxs)(c,{children:[(0,_.jsx)(s,{title:`Appearance & refresh`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,_.jsx)(h,{label:`Theme`,children:(0,_.jsxs)(p,{name:`theme`,autoComplete:`off`,value:C,onChange:e=>w(e.target.value),children:[(0,_.jsx)(`option`,{value:`dark`,children:`Dark`}),(0,_.jsx)(`option`,{value:`light`,children:`Light`})]})}),(0,_.jsx)(h,{label:`Refresh interval`,children:(0,_.jsx)(p,{name:`refresh-interval`,autoComplete:`off`,value:String(y),onChange:e=>S(Number(e.target.value)),children:v.map(([e,t])=>(0,_.jsx)(`option`,{value:e,children:t},e))})})]})]})]})]})}export{S as Settings};
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-Bjui4wS4.js";import{A as t,C as n,S as r,b as i,c as a,d as o,h as s,j as c,m as l,r as u,u as d,x as f,y as p}from"./index-Bn2R06qm.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}=t(()=>c.overview(),[]);if(v&&!e&&!g)return(0,m.jsx)(i,{label:`Loading usage…`});if(g&&!e)return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(s,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,m.jsx)(p,{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)(s,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!g&&T}),g&&(0,m.jsx)(f,{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)(l,{label:`Jobs Pushed`,value:a(b.totalPushed)}),(0,m.jsx)(l,{label:`Jobs Completed`,value:a(b.totalCompleted),tone:`green`}),(0,m.jsx)(l,{label:`Jobs Failed`,value:a(b.totalFailed),tone:b.totalFailed?`red`:`default`}),(0,m.jsx)(l,{label:`Jobs Pulled`,value:a(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)(r,{children:[(0,m.jsx)(n,{title:`Runtime`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Uptime`,value:o(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)(r,{children:[(0,m.jsx)(n,{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?d(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
+ import{t as e}from"./react-vendor-Bjui4wS4.js";import{A as t,C as n,S as r,b as i,c as a,d as o,h as s,j as c,m as l,r as u,u as d,x as f,y as p}from"./index-Dr__4DsT.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}=t(()=>c.overview(),[]);if(v&&!e&&!g)return(0,m.jsx)(i,{label:`Loading usage…`});if(g&&!e)return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(s,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,m.jsx)(p,{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)(s,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!g&&T}),g&&(0,m.jsx)(f,{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)(l,{label:`Jobs Pushed`,value:a(b.totalPushed)}),(0,m.jsx)(l,{label:`Jobs Completed`,value:a(b.totalCompleted),tone:`green`}),(0,m.jsx)(l,{label:`Jobs Failed`,value:a(b.totalFailed),tone:b.totalFailed?`red`:`default`}),(0,m.jsx)(l,{label:`Jobs Pulled`,value:a(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)(r,{children:[(0,m.jsx)(n,{title:`Runtime`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Uptime`,value:o(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)(r,{children:[(0,m.jsx)(n,{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?d(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 +1 @@
1
- import{t as e}from"./react-vendor-Bjui4wS4.js";import{A as t,C as n,S as r,b as i,c as a,d as o,h as s,l as c,m as l,n as u,r as d,st as f,u as p,x as m,y as h}from"./index-Bn2R06qm.js";var g=e(),_={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 v(){let{data:e,error:v,loading:b,refetch:x}=t(async()=>{let[e,t,n]=await Promise.all([f.overview(),f.storage(),f.queuesSummary()]);if(!t?.data||typeof t.data.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data`);let r=n.reduce((e,t)=>e+(t.counts?.failed??0),0);return{overview:e,storage:t.data,failedTotal:r}},[]);if(b&&!e&&!v)return(0,g.jsx)(i,{label:`Loading usage…`});if(v&&!e)return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(s,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,g.jsx)(h,{error:v,onRetry:x})]});let S=e??_,{stats:C,memory:w,crons:T}=S.overview,{storage:E,failedTotal:D}=S,O=u(C.completed,D),k=C.uptime?o(C.uptime/1e3):`—`;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(s,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!v}),v&&(0,g.jsx)(m,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:x}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,g.jsx)(l,{label:`Completed`,value:a(C.completed),tone:`green`}),(0,g.jsx)(l,{label:`Failed`,value:a(D),tone:D?`red`:`default`}),(0,g.jsx)(l,{label:`Waiting`,value:a(C.waiting),tone:`amber`}),(0,g.jsx)(l,{label:`Active`,value:a(C.active),tone:`blue`}),(0,g.jsx)(l,{label:`Error Rate`,value:O==null?`—`:c(O),tone:O==null?`default`:O>.05?`red`:`green`}),(0,g.jsx)(l,{label:`Uptime`,value:k})]}),(0,g.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(r,{children:[(0,g.jsx)(n,{title:`Runtime`}),(0,g.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,g.jsx)(y,{label:`Jobs pushed (since restart)`,value:a(C.totalPushed)}),(0,g.jsx)(y,{label:`Jobs pulled (since restart)`,value:a(C.totalPulled)}),(0,g.jsx)(y,{label:`Heap used`,value:d(w.heapUsed*1024*1024)}),(0,g.jsx)(y,{label:`RSS`,value:d(w.rss*1024*1024)}),(0,g.jsx)(y,{label:`Cron jobs`,value:String(T.total)})]})]}),(0,g.jsxs)(r,{children:[(0,g.jsx)(n,{title:`Storage`}),E.diskFull?(0,g.jsxs)(`div`,{className:`rounded-lg border border-red-500/25 bg-red-500/[0.06] px-4 py-3`,children:[(0,g.jsx)(`div`,{className:`font-semibold text-danger`,children:`Disk full — writes suspended`}),E.error&&(0,g.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:E.error}),E.since!=null&&(0,g.jsxs)(`div`,{className:`mt-1 text-xs text-faint`,children:[`since `,p(E.since)]})]}):(0,g.jsxs)(`div`,{className:`rounded-lg border border-emerald-500/25 bg-emerald-500/[0.06] px-4 py-3`,children:[(0,g.jsx)(`div`,{className:`font-semibold text-success`,children:`Healthy`}),(0,g.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`Disk writes are being accepted.`})]})]})]})]})}function y({label:e,value:t}){return(0,g.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,g.jsx)(`dt`,{className:`text-muted`,children:e}),(0,g.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}export{v as UsagePro};
1
+ import{t as e}from"./react-vendor-Bjui4wS4.js";import{A as t,C as n,S as r,b as i,c as a,d as o,h as s,l as c,m as l,n as u,r as d,st as f,u as p,x as m,y as h}from"./index-Dr__4DsT.js";var g=e(),_={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 v(){let{data:e,error:v,loading:b,refetch:x}=t(async()=>{let[e,t,n]=await Promise.all([f.overview(),f.storage(),f.queuesSummary()]);if(!t?.data||typeof t.data.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data`);let r=n.reduce((e,t)=>e+(t.counts?.failed??0),0);return{overview:e,storage:t.data,failedTotal:r}},[]);if(b&&!e&&!v)return(0,g.jsx)(i,{label:`Loading usage…`});if(v&&!e)return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(s,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,g.jsx)(h,{error:v,onRetry:x})]});let S=e??_,{stats:C,memory:w,crons:T}=S.overview,{storage:E,failedTotal:D}=S,O=u(C.completed,D),k=C.uptime?o(C.uptime/1e3):`—`;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(s,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!v}),v&&(0,g.jsx)(m,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:x}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,g.jsx)(l,{label:`Completed`,value:a(C.completed),tone:`green`}),(0,g.jsx)(l,{label:`Failed`,value:a(D),tone:D?`red`:`default`}),(0,g.jsx)(l,{label:`Waiting`,value:a(C.waiting),tone:`amber`}),(0,g.jsx)(l,{label:`Active`,value:a(C.active),tone:`blue`}),(0,g.jsx)(l,{label:`Error Rate`,value:O==null?`—`:c(O),tone:O==null?`default`:O>.05?`red`:`green`}),(0,g.jsx)(l,{label:`Uptime`,value:k})]}),(0,g.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(r,{children:[(0,g.jsx)(n,{title:`Runtime`}),(0,g.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,g.jsx)(y,{label:`Jobs pushed (since restart)`,value:a(C.totalPushed)}),(0,g.jsx)(y,{label:`Jobs pulled (since restart)`,value:a(C.totalPulled)}),(0,g.jsx)(y,{label:`Heap used`,value:d(w.heapUsed*1024*1024)}),(0,g.jsx)(y,{label:`RSS`,value:d(w.rss*1024*1024)}),(0,g.jsx)(y,{label:`Cron jobs`,value:String(T.total)})]})]}),(0,g.jsxs)(r,{children:[(0,g.jsx)(n,{title:`Storage`}),E.diskFull?(0,g.jsxs)(`div`,{className:`rounded-lg border border-red-500/25 bg-red-500/[0.06] px-4 py-3`,children:[(0,g.jsx)(`div`,{className:`font-semibold text-danger`,children:`Disk full — writes suspended`}),E.error&&(0,g.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:E.error}),E.since!=null&&(0,g.jsxs)(`div`,{className:`mt-1 text-xs text-faint`,children:[`since `,p(E.since)]})]}):(0,g.jsxs)(`div`,{className:`rounded-lg border border-emerald-500/25 bg-emerald-500/[0.06] px-4 py-3`,children:[(0,g.jsx)(`div`,{className:`font-semibold text-success`,children:`Healthy`}),(0,g.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`Disk writes are being accepted.`})]})]})]})]})}function y({label:e,value:t}){return(0,g.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,g.jsx)(`dt`,{className:`text-muted`,children:e}),(0,g.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}export{v as UsagePro};
@@ -1 +1 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{A as r,C as i,S as a,T as o,V as s,Y as c,at as l,b as u,c as d,ft as f,h as p,st as m,u as h,v as g,w as _,x as v,y}from"./index-Bn2R06qm.js";import{n as b,o as x,t as S}from"./form-DsUq0w8s.js";import{t as C}from"./Pagination-DpxiBnt8.js";import{r as w,t as T}from"./useServerActionGuard-CItj3hvh.js";var E=e(t(),1),D=n();function O(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 k(){let{data:e,error:t,loading:n,refetch:l}=r(()=>m.webhooks(),[]),_=e?.data?.webhooks??[],[b,S]=O(Math.max(1,Math.ceil(_.length/15))),[k,A]=(0,E.useState)(null),[M,P]=(0,E.useState)(new Set),F=w(`webhooks`),[I,L]=(0,E.useState)({}),R=(0,E.useRef)(new Map);(0,E.useEffect)(()=>{A(null),P(new Set),L({}),R.current.clear()},[F.scopeKey]);let z=async e=>{let t=F.begin([`registry-write`,`webhook:${e}`]);if(t){A(null),P(t=>new Set(t).add(e));try{if(T(await m.removeWebhook(e),`Remove webhook`),!t.isCurrent())return;l()}catch(e){if(!t.isCurrent())return;A(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`),r=R.current.get(e);if(r){r.desired=t,r.intent=n,L(r=>({...r,[e]:{value:t,intent:n}}));return}let i=F.begin(`webhook:${e}`);if(!i)return;let a={desired:t,intent:n,lease:i};R.current.set(e,a),L(r=>({...r,[e]:{value:t,intent:n}})),(async()=>{for(;i.isCurrent()&&R.current.get(e)===a;){let t=a.desired,n=null;try{T(await m.setWebhookEnabled(e,t),`Toggle webhook`)}catch(e){n=e instanceof Error?e:Error(String(e))}if(!i.isCurrent()||R.current.get(e)!==a)return;if(a.desired!==t)continue;if(await l(),!i.isCurrent()||R.current.get(e)!==a)return;if(a.desired!==t)continue;R.current.delete(e);let r=a.intent;L(t=>{if(t[e]?.intent!==r)return t;let{[e]:n,...i}=t;return i}),n&&f.error(`Webhook toggle failed`,n.message),i.finish();return}})()};return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(p,{title:`Webhooks`,description:`HTTP callbacks fired on job events.`,live:!!e&&!t}),t&&e&&(0,D.jsx)(v,{message:`Webhook refresh failed — showing the last successful registry.`,onRetry:l}),k&&(0,D.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:k}),(0,D.jsxs)(a,{className:`mb-6`,children:[(0,D.jsx)(i,{title:`Add webhook`}),(0,D.jsx)(N,{onAdd:e=>m.addWebhook(e),onAccepted:()=>void l(),beginAdd:()=>F.begin([`registry-write`,`add`]),scopeKey:F.scopeKey})]}),t&&!e?(0,D.jsx)(y,{error:t,onRetry:l}):n&&!e?(0,D.jsx)(u,{label:`Loading webhooks…`}):_.length===0?(0,D.jsx)(g,{icon:(0,D.jsx)(s,{}),title:`No webhooks`,hint:`Add one above to receive job-event callbacks.`}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,D.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`URL`}),(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Events`}),(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,D.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Success / Fail`}),(0,D.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last`}),(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Enabled`}),(0,D.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,D.jsx)(`tbody`,{children:_.slice(b*15,b*15+15).map(e=>(0,D.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,D.jsx)(`td`,{className:`max-w-xs truncate px-5 py-3 font-mono text-xs text-fg`,children:j(e.url)}),(0,D.jsx)(`td`,{className:`px-5 py-3 text-xs text-muted`,children:e.events.join(`, `)}),(0,D.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue??`all`}),(0,D.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[(0,D.jsx)(`span`,{className:`text-success`,children:d(e.successCount)}),` / `,(0,D.jsx)(`span`,{className:e.failureCount?`text-danger`:``,children:d(e.failureCount)})]}),(0,D.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:h(e.lastTriggered)}),(0,D.jsx)(`td`,{className:`px-5 py-3`,children:(0,D.jsx)(x,{checked:I[e.id]?.value??e.enabled,label:`${I[e.id]?.value??e.enabled?`Disable`:`Enable`} webhook`,onChange:t=>B(e.id,t)})}),(0,D.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,D.jsx)(o,{"aria-label":`Remove webhook`,disabled:M.has(e.id),onClick:()=>window.confirm(`Remove webhook for ${j(e.url)}?`)&&z(e.id),children:(0,D.jsx)(c,{className:`size-3.5`})})})]},e.id))})]})}),(0,D.jsx)(C,{page:b,pageSize:15,total:_.length,onPageChange:S,label:`webhooks`})]})]})}function A(e){try{let t=new URL(e);return e.length<=2048&&/^https?:$/.test(t.protocol)&&t.username===``&&t.password===``}catch{return!1}}function j(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 M(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(!A(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}}}function N({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 v=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),y=async()=>{if(h)return;m(null);let r=M(i,d,o,c);if(!r.ok){m(r.msg);return}let s=n();if(s){g(!0);try{if(T(await e(r.body),`Add webhook`),!s.isCurrent())return;a(``),u(``),t()}catch(e){if(!s.isCurrent())return;m(e.message)}finally{s.finish()&&g(!1)}}};return(0,D.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,D.jsx)(`div`,{className:`md:col-span-1`,children:(0,D.jsx)(S,{label:`URL`,children:(0,D.jsx)(b,{value:i,onInput:e=>a(e.currentTarget.value),name:`webhook-url`,type:`url`,maxLength:2048,autoComplete:`url`,placeholder:`https://example.com/hook`})})}),(0,D.jsx)(S,{label:`Queue (optional)`,children:(0,D.jsx)(b,{value:o,onChange:e=>s(e.target.value),name:`webhook-queue`,maxLength:256,autoComplete:`off`,placeholder:`all queues`})}),(0,D.jsx)(S,{label:`Secret (optional)`,children:(0,D.jsx)(b,{type:`password`,autoComplete:`new-password`,name:`webhook-secret`,maxLength:65536,value:c,onChange:e=>u(e.target.value),placeholder:`HMAC signing secret`})})]}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l.map(e=>(0,D.jsx)(`button`,{type:`button`,"aria-pressed":d.includes(e),onClick:()=>v(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,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(_,{type:`submit`,variant:`accent`,size:`sm`,disabled:h,children:h?`Adding…`:`Add webhook`}),p&&(0,D.jsx)(`span`,{className:`text-xs text-danger`,children:p})]})]})}export{k as Webhooks};
1
+ import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{A as r,C as i,S as a,T as o,V as s,Y as c,at as l,b as u,c as d,ft as f,h as p,st as m,u as h,v as g,w as _,x as v,y}from"./index-Dr__4DsT.js";import{n as b,o as x,t as S}from"./form-DsUq0w8s.js";import{t as C}from"./Pagination-eotgGQf9.js";import{r as w,t as T}from"./useServerActionGuard-CItj3hvh.js";var E=e(t(),1),D=n();function O(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 k(){let{data:e,error:t,loading:n,refetch:l}=r(()=>m.webhooks(),[]),_=e?.data?.webhooks??[],[b,S]=O(Math.max(1,Math.ceil(_.length/15))),[k,A]=(0,E.useState)(null),[M,P]=(0,E.useState)(new Set),F=w(`webhooks`),[I,L]=(0,E.useState)({}),R=(0,E.useRef)(new Map);(0,E.useEffect)(()=>{A(null),P(new Set),L({}),R.current.clear()},[F.scopeKey]);let z=async e=>{let t=F.begin([`registry-write`,`webhook:${e}`]);if(t){A(null),P(t=>new Set(t).add(e));try{if(T(await m.removeWebhook(e),`Remove webhook`),!t.isCurrent())return;l()}catch(e){if(!t.isCurrent())return;A(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`),r=R.current.get(e);if(r){r.desired=t,r.intent=n,L(r=>({...r,[e]:{value:t,intent:n}}));return}let i=F.begin(`webhook:${e}`);if(!i)return;let a={desired:t,intent:n,lease:i};R.current.set(e,a),L(r=>({...r,[e]:{value:t,intent:n}})),(async()=>{for(;i.isCurrent()&&R.current.get(e)===a;){let t=a.desired,n=null;try{T(await m.setWebhookEnabled(e,t),`Toggle webhook`)}catch(e){n=e instanceof Error?e:Error(String(e))}if(!i.isCurrent()||R.current.get(e)!==a)return;if(a.desired!==t)continue;if(await l(),!i.isCurrent()||R.current.get(e)!==a)return;if(a.desired!==t)continue;R.current.delete(e);let r=a.intent;L(t=>{if(t[e]?.intent!==r)return t;let{[e]:n,...i}=t;return i}),n&&f.error(`Webhook toggle failed`,n.message),i.finish();return}})()};return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(p,{title:`Webhooks`,description:`HTTP callbacks fired on job events.`,live:!!e&&!t}),t&&e&&(0,D.jsx)(v,{message:`Webhook refresh failed — showing the last successful registry.`,onRetry:l}),k&&(0,D.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:k}),(0,D.jsxs)(a,{className:`mb-6`,children:[(0,D.jsx)(i,{title:`Add webhook`}),(0,D.jsx)(N,{onAdd:e=>m.addWebhook(e),onAccepted:()=>void l(),beginAdd:()=>F.begin([`registry-write`,`add`]),scopeKey:F.scopeKey})]}),t&&!e?(0,D.jsx)(y,{error:t,onRetry:l}):n&&!e?(0,D.jsx)(u,{label:`Loading webhooks…`}):_.length===0?(0,D.jsx)(g,{icon:(0,D.jsx)(s,{}),title:`No webhooks`,hint:`Add one above to receive job-event callbacks.`}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,D.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`URL`}),(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Events`}),(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,D.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Success / Fail`}),(0,D.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last`}),(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Enabled`}),(0,D.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,D.jsx)(`tbody`,{children:_.slice(b*15,b*15+15).map(e=>(0,D.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,D.jsx)(`td`,{className:`max-w-xs truncate px-5 py-3 font-mono text-xs text-fg`,children:j(e.url)}),(0,D.jsx)(`td`,{className:`px-5 py-3 text-xs text-muted`,children:e.events.join(`, `)}),(0,D.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue??`all`}),(0,D.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[(0,D.jsx)(`span`,{className:`text-success`,children:d(e.successCount)}),` / `,(0,D.jsx)(`span`,{className:e.failureCount?`text-danger`:``,children:d(e.failureCount)})]}),(0,D.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:h(e.lastTriggered)}),(0,D.jsx)(`td`,{className:`px-5 py-3`,children:(0,D.jsx)(x,{checked:I[e.id]?.value??e.enabled,label:`${I[e.id]?.value??e.enabled?`Disable`:`Enable`} webhook`,onChange:t=>B(e.id,t)})}),(0,D.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,D.jsx)(o,{"aria-label":`Remove webhook`,disabled:M.has(e.id),onClick:()=>window.confirm(`Remove webhook for ${j(e.url)}?`)&&z(e.id),children:(0,D.jsx)(c,{className:`size-3.5`})})})]},e.id))})]})}),(0,D.jsx)(C,{page:b,pageSize:15,total:_.length,onPageChange:S,label:`webhooks`})]})]})}function A(e){try{let t=new URL(e);return e.length<=2048&&/^https?:$/.test(t.protocol)&&t.username===``&&t.password===``}catch{return!1}}function j(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 M(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(!A(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}}}function N({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 v=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),y=async()=>{if(h)return;m(null);let r=M(i,d,o,c);if(!r.ok){m(r.msg);return}let s=n();if(s){g(!0);try{if(T(await e(r.body),`Add webhook`),!s.isCurrent())return;a(``),u(``),t()}catch(e){if(!s.isCurrent())return;m(e.message)}finally{s.finish()&&g(!1)}}};return(0,D.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,D.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,D.jsx)(`div`,{className:`md:col-span-1`,children:(0,D.jsx)(S,{label:`URL`,children:(0,D.jsx)(b,{value:i,onInput:e=>a(e.currentTarget.value),name:`webhook-url`,type:`url`,maxLength:2048,autoComplete:`url`,placeholder:`https://example.com/hook`})})}),(0,D.jsx)(S,{label:`Queue (optional)`,children:(0,D.jsx)(b,{value:o,onChange:e=>s(e.target.value),name:`webhook-queue`,maxLength:256,autoComplete:`off`,placeholder:`all queues`})}),(0,D.jsx)(S,{label:`Secret (optional)`,children:(0,D.jsx)(b,{type:`password`,autoComplete:`new-password`,name:`webhook-secret`,maxLength:65536,value:c,onChange:e=>u(e.target.value),placeholder:`HMAC signing secret`})})]}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l.map(e=>(0,D.jsx)(`button`,{type:`button`,"aria-pressed":d.includes(e),onClick:()=>v(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,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(_,{type:`submit`,variant:`accent`,size:`sm`,disabled:h,children:h?`Adding…`:`Add webhook`}),p&&(0,D.jsx)(`span`,{className:`text-xs text-danger`,children:p})]})]})}export{k as Webhooks};
@@ -1 +1 @@
1
- import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{A as r,X as i,b as a,c as o,h as s,j as c,m as l,u,v as d,x as f,y as p}from"./index-Bn2R06qm.js";import{t as m}from"./Pagination-DpxiBnt8.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}=r(()=>c.overview(),[]),[b,x]=(0,h.useState)(0);if(n&&!e&&!t)return(0,g.jsx)(a,{label:`Loading workers…`});if(t&&!e)return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(s,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,g.jsx)(p,{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)(f,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:y}),(0,g.jsx)(s,{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)(l,{label:`Total`,value:o(S.total),compact:!0}),(0,g.jsx)(l,{label:`Active`,value:o(S.active),tone:`green`,compact:!0})]}),S.list.length===0?(0,g.jsx)(d,{icon:(0,g.jsx)(i,{}),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:o(e.activeJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:o(e.processedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:o(e.failedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.lastSeen)})]},e.id))})]})}),S.truncated&&(0,g.jsxs)(`p`,{className:`mt-3 text-xs text-amber-400`,children:[`Showing first `,o(S.list.length),` of `,o(S.total),` `,`workers.`]}),(0,g.jsx)(m,{page:w,pageSize:_,total:S.list.length,onPageChange:x,label:`workers`})]})}export{y as Workers};
1
+ import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{A as r,X as i,b as a,c as o,h as s,j as c,m as l,u,v as d,x as f,y as p}from"./index-Dr__4DsT.js";import{t as m}from"./Pagination-eotgGQf9.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}=r(()=>c.overview(),[]),[b,x]=(0,h.useState)(0);if(n&&!e&&!t)return(0,g.jsx)(a,{label:`Loading workers…`});if(t&&!e)return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(s,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,g.jsx)(p,{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)(f,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:y}),(0,g.jsx)(s,{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)(l,{label:`Total`,value:o(S.total),compact:!0}),(0,g.jsx)(l,{label:`Active`,value:o(S.active),tone:`green`,compact:!0})]}),S.list.length===0?(0,g.jsx)(d,{icon:(0,g.jsx)(i,{}),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:o(e.activeJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:o(e.processedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:o(e.failedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.lastSeen)})]},e.id))})]})}),S.truncated&&(0,g.jsxs)(`p`,{className:`mt-3 text-xs text-amber-400`,children:[`Showing first `,o(S.list.length),` of `,o(S.total),` `,`workers.`]}),(0,g.jsx)(m,{page:w,pageSize:_,total:S.list.length,onPageChange:x,label:`workers`})]})}export{y as Workers};