bunqueue-dashboard 0.0.42 → 0.0.43

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 (49) hide show
  1. package/README.md +5 -4
  2. package/agent/flow/routes.ts +2 -0
  3. package/agent/flow/service.ts +7 -2
  4. package/agent/managedConnection.ts +35 -0
  5. package/agent/manager/config.ts +1 -1
  6. package/agent/queue/runtime.ts +2 -2
  7. package/agent/workflow/runtime.ts +2 -6
  8. package/agent/workflow/runtimeConfig.ts +2 -2
  9. package/dist/.vite/manifest.json +40 -39
  10. package/dist/assets/{Alerts-BvWBv-z7.js → Alerts-C961Al5D.js} +1 -1
  11. package/dist/assets/{Benchmark-BywalSmU.js → Benchmark-DQNZV7dM.js} +1 -1
  12. package/dist/assets/{CopilotPanel-CH2jbbYA.js → CopilotPanel-Dlm8XwBj.js} +1 -1
  13. package/dist/assets/{Database-BzEkXws0.js → Database-DGM2BIHy.js} +1 -1
  14. package/dist/assets/{Diagnostics-CPqhV3er.js → Diagnostics-_Sh3UyaT.js} +1 -1
  15. package/dist/assets/{Dlq-CbLN0zQ5.js → Dlq-mtInIoTh.js} +1 -1
  16. package/dist/assets/{DlqControl-C5Bgzmk0.js → DlqControl-Lq9ISb9b.js} +1 -1
  17. package/dist/assets/{DlqPro-Cgaxtuwh.js → DlqPro-0_75vrd1.js} +1 -1
  18. package/dist/assets/Flows-CE7KzaFN.js +2 -0
  19. package/dist/assets/{JobInspector-DsOt4mLJ.js → JobInspector-DyWZk1eW.js} +1 -1
  20. package/dist/assets/{Jobs-BTMpbAHD.js → Jobs-ELSH1Wbd.js} +1 -1
  21. package/dist/assets/JobsPro-BlWwDeFN.js +1 -0
  22. package/dist/assets/{Logs-uuzU5ohI.js → Logs-DMukqmHy.js} +1 -1
  23. package/dist/assets/{LogsPro-DHWbhWyq.js → LogsPro-BfYbmZHi.js} +1 -1
  24. package/dist/assets/{McpServer-BqmbhrKh.js → McpServer-DNrOEp9j.js} +1 -1
  25. package/dist/assets/{Metrics-DKyBZoFa.js → Metrics-Cm5ZvfTo.js} +1 -1
  26. package/dist/assets/{MetricsPro-BR2ULqIc.js → MetricsPro-C9g1sp-u.js} +1 -1
  27. package/dist/assets/{Overview-ClsyxH2e.js → Overview-CKAA3h9f.js} +1 -1
  28. package/dist/assets/{QueueControl-BW0XXd0B.js → QueueControl-Bvm8GUQa.js} +1 -1
  29. package/dist/assets/{QueueDetail-C1dXXN70.js → QueueDetail-BRDATlp0.js} +1 -1
  30. package/dist/assets/{QueueDetailPro-DDGxs2J2.js → QueueDetailPro-Dkz4-1wn.js} +1 -1
  31. package/dist/assets/{Queues-DkPuIy1C.js → Queues-BV99vr68.js} +1 -1
  32. package/dist/assets/{QueuesOverview-COo-V8D_.js → QueuesOverview-CT6JBaim.js} +1 -1
  33. package/dist/assets/{S3BackupPro-DxNVFvY1.js → S3BackupPro-CjR0y18n.js} +1 -1
  34. package/dist/assets/{ServerControl-B0Po974t.js → ServerControl-BH6Doax0.js} +1 -1
  35. package/dist/assets/{Settings-z9k4EVa_.js → Settings-CL7odwoU.js} +1 -1
  36. package/dist/assets/{Usage-cdWDQUaq.js → Usage-BWZkz7Se.js} +1 -1
  37. package/dist/assets/{UsagePro-DLuwnM8n.js → UsagePro-CoBbI-Cl.js} +1 -1
  38. package/dist/assets/{Workers-CVo9rJ_V.js → Workers-CBEDvXm_.js} +1 -1
  39. package/dist/assets/{WorkersPro-BYaredE9.js → WorkersPro-Dk4NfplT.js} +1 -1
  40. package/dist/assets/flowOperationPolicy-B2Etcb3f.js +1 -0
  41. package/dist/assets/{index-mID5W7vq.js → index-BFW2_47n.js} +3 -3
  42. package/dist/assets/{install-D4uRZ7XA.js → install-oydLpc1T.js} +1 -1
  43. package/dist/index.html +1 -1
  44. package/package.json +8 -5
  45. package/scripts/embedded.gen.ts +164 -164
  46. package/shared/flowOperationPolicy.ts +66 -0
  47. package/dist/assets/Flows-BtUGOaif.js +0 -2
  48. package/dist/assets/JobsPro-BfXTm9gH.js +0 -1
  49. package/dist/assets/jobActions-LQD4KfCc.js +0 -1
@@ -1,2 +1,2 @@
1
- import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,l as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{a as o,o as s}from"./connectionStore-BJLihGaC.js";import{a as c,n as l}from"./upstreamPaths-DQeKSxGc.js";import{a as u,t as d}from"./bq-F5BbTG1T.js";import{T as f,d as p}from"./icons-BVzwsfbG.js";import{n as m,t as h}from"./Button-Ch1W94fJ.js";import{n as g,t as _}from"./Card-CWxrC8OY.js";import{r as v,t as y}from"./feedback-QDN1AsYt.js";import{t as b}from"./StatusBadge-BoOVTnKu.js";import{t as x}from"./PageHeader-CvIyaFOO.js";import{a as S,i as C}from"./format-Cg7VCIZW.js";import{a as w}from"./index-mID5W7vq.js";import{a as T,n as E,o as D}from"./form-C4oby9pI.js";import{r as O}from"./flowMutationSafety-YKTHxqKv.js";import{n as k}from"./exportFile-C7xhE8Yh.js";import{t as A}from"./jobActions-LQD4KfCc.js";var j=1e4,M=100,ee=256*1024;function N(e){throw new u(`Invalid job response: ${e}`,200)}function P(e,t,{nullable:n=!1,nonEmpty:r=!1}={},i=`job`){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let a=e[t];n&&a===null||(typeof a!=`string`||r&&!a.trim())&&N(`${i}.${t} must be ${n?`a string or null`:`a string`}${r?` (non-empty)`:``}`)}function F(e,t,{nullable:n=!1,integer:r=!1,min:i,max:a}={},o=`job`){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let s=e[t];n&&s===null||(typeof s!=`number`||!Number.isFinite(s)||r&&!Number.isSafeInteger(s)||i!==void 0&&s<i||a!==void 0&&s>a)&&N(`${o}.${t} must be a valid${r?` safe integer`:` finite number`}`)}function I(e,t){Object.hasOwn(e,t)&&e[t]!==void 0&&typeof e[t]!=`boolean`&&N(`job.${t} must be a boolean`)}function L(e,t,{nullable:n=!1,nonEmpty:r=!1}={}){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let i=e[t];n&&i===null||(!Array.isArray(i)||i.some(e=>typeof e!=`string`||r&&!e.trim()))&&N(`job.${t} must be ${n?`a string array or null`:`a string array`}`)}function te(e,t){let n=0,r=0;for(;n<e.length&&r<t;){let t=e.codePointAt(n);n+=t!==void 0&&t>65535?2:1,r+=1}return{text:e.slice(0,n),count:r}}function ne(e){let t=[],n=0,r=!1,i=Math.min(e.length,M);for(let a=0;a<i;a++){let i=+(t.length>0),o=ee-n-i;if(o<=0){r=!0;break}let s=e[a]??``,c=te(s,o);if(t.push(c.text),n+=i+c.count,c.text.length!==s.length){r=!0;break}}return t.length<e.length&&(r=!0),{text:t.join(`
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,l as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{a as o,o as s}from"./connectionStore-BJLihGaC.js";import{a as c,n as l}from"./upstreamPaths-DQeKSxGc.js";import{a as u,t as d}from"./bq-F5BbTG1T.js";import{T as f,d as p}from"./icons-BVzwsfbG.js";import{n as m,t as h}from"./Button-Ch1W94fJ.js";import{n as g,t as _}from"./Card-CWxrC8OY.js";import{r as v,t as y}from"./feedback-QDN1AsYt.js";import{t as b}from"./StatusBadge-BoOVTnKu.js";import{t as x}from"./PageHeader-CvIyaFOO.js";import{a as S,i as C}from"./format-Cg7VCIZW.js";import{a as w}from"./index-BFW2_47n.js";import{a as T,n as E,o as D}from"./form-C4oby9pI.js";import{r as O}from"./flowMutationSafety-YKTHxqKv.js";import{n as k}from"./exportFile-C7xhE8Yh.js";import{t as A}from"./flowOperationPolicy-B2Etcb3f.js";var j=1e4,M=100,ee=256*1024;function N(e){throw new u(`Invalid job response: ${e}`,200)}function P(e,t,{nullable:n=!1,nonEmpty:r=!1}={},i=`job`){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let a=e[t];n&&a===null||(typeof a!=`string`||r&&!a.trim())&&N(`${i}.${t} must be ${n?`a string or null`:`a string`}${r?` (non-empty)`:``}`)}function F(e,t,{nullable:n=!1,integer:r=!1,min:i,max:a}={},o=`job`){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let s=e[t];n&&s===null||(typeof s!=`number`||!Number.isFinite(s)||r&&!Number.isSafeInteger(s)||i!==void 0&&s<i||a!==void 0&&s>a)&&N(`${o}.${t} must be a valid${r?` safe integer`:` finite number`}`)}function I(e,t){Object.hasOwn(e,t)&&e[t]!==void 0&&typeof e[t]!=`boolean`&&N(`job.${t} must be a boolean`)}function L(e,t,{nullable:n=!1,nonEmpty:r=!1}={}){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let i=e[t];n&&i===null||(!Array.isArray(i)||i.some(e=>typeof e!=`string`||r&&!e.trim()))&&N(`job.${t} must be ${n?`a string array or null`:`a string array`}`)}function te(e,t){let n=0,r=0;for(;n<e.length&&r<t;){let t=e.codePointAt(n);n+=t!==void 0&&t>65535?2:1,r+=1}return{text:e.slice(0,n),count:r}}function ne(e){let t=[],n=0,r=!1,i=Math.min(e.length,M);for(let a=0;a<i;a++){let i=+(t.length>0),o=ee-n-i;if(o<=0){r=!0;break}let s=e[a]??``,c=te(s,o);if(t.push(c.text),n+=i+c.count,c.text.length!==s.length){r=!0;break}}return t.length<e.length&&(r=!0),{text:t.join(`
2
2
  `),displayedLines:t.length,totalLines:e.length,truncated:r}}function re(e,t){if(t&&(typeof e.state!=`string`||!e.state.trim())&&N(`canonical job.state must be a non-empty string`),P(e,`state`,{nonEmpty:!0}),P(e,`name`,{nonEmpty:!0}),P(e,`failedReason`),t&&(typeof e.queue!=`string`||!e.queue.trim())&&N(`canonical job.queue must be a non-empty string`),P(e,`queue`,{nonEmpty:!0}),P(e,`customId`,{nullable:!0}),P(e,`parentId`,{nullable:!0,nonEmpty:!0}),P(e,`groupId`,{nullable:!0}),P(e,`progressMessage`,{nullable:!0}),L(e,`childrenIds`,{nonEmpty:!0}),L(e,`dependsOn`,{nonEmpty:!0}),L(e,`tags`),L(e,`stacktrace`,{nullable:!0}),Array.isArray(e.stacktrace)&&e.stacktrace.length>j&&N(`job.stacktrace exceeds Bunqueue's ${j}-entry limit`),F(e,`priority`,{integer:!0}),F(e,`createdAt`),F(e,`runAt`),F(e,`startedAt`,{nullable:!0}),F(e,`completedAt`,{nullable:!0}),F(e,`attempts`,{integer:!0,min:0}),F(e,`maxAttempts`,{integer:!0,min:0}),F(e,`backoff`,{integer:!0,min:0}),F(e,`timeout`,{nullable:!0,integer:!0,min:0}),F(e,`ttl`,{nullable:!0,integer:!0,min:0}),F(e,`progress`,{min:0,max:100}),F(e,`lastHeartbeat`),F(e,`stallCount`,{integer:!0,min:0}),I(e,`removeOnComplete`),I(e,`removeOnFail`),Object.hasOwn(e,`backoffConfig`)&&e.backoffConfig!==void 0){let t=e.backoffConfig;if(t!==null){(!t||typeof t!=`object`||Array.isArray(t))&&N(`job.backoffConfig must be an object or null`);let e=t;e.type!==`fixed`&&e.type!==`exponential`&&N(`job.backoffConfig.type must be fixed or exponential`),F(e,`delay`,{integer:!0,min:0},`job.backoffConfig`),(!Object.hasOwn(e,`delay`)||e.delay===void 0)&&N(`job.backoffConfig.delay is required`),F(e,`maxDelay`,{integer:!0,min:0},`job.backoffConfig`)}}if(Object.hasOwn(e,`timeline`)&&e.timeline!==void 0){Array.isArray(e.timeline)||N(`job.timeline must be an array`),e.timeline.length>20&&N(`job.timeline exceeds 20 entries`);for(let[t,n]of e.timeline.entries()){(!n||typeof n!=`object`||Array.isArray(n))&&N(`job.timeline[${t}] must be an object`);let e=n;(typeof e.state!=`string`||!e.state.trim())&&N(`job.timeline[${t}].state must be a non-empty string`),(typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp))&&N(`job.timeline[${t}].timestamp must be a finite number`);let r=`job.timeline[${t}]`;P(e,`worker`,{},r),P(e,`error`,{},r),F(e,`attempt`,{integer:!0,min:0},r)}}}function ie(e,{canonical:t,expectedId:n}){if(!e||typeof e!=`object`||Array.isArray(e))return N(`expected an object envelope`);let r=e;if(r.ok!==!0||!Object.hasOwn(r,`job`))return N(`expected { ok: true, job }`);if(r.job===null)return null;if(!r.job||typeof r.job!=`object`||Array.isArray(r.job))return N(`job must be an object or null`);let i=r.job;return typeof i.id!=`string`||!i.id.trim()?N(`job.id must be a non-empty string`):n!==void 0&&i.id!==n?N(`expected job.id ${JSON.stringify(n)}`):(re(i,t),i)}function ae(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw new u(`Invalid job result response: expected an object envelope`,200);let n=e;if(n.ok!==!0||n.id!==t)throw new u(`Invalid job result response: expected { ok: true, id, result? }`,200);return{result:n.result}}var R=3e4;function z(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function B(e,t){return e?.baseUrl===t.baseUrl&&e.authorization===t.authorization}function V(e,t,n){return t.aborted&&!n?.aborted?new u(`Request timed out`,0):e}async function H(e,t,n,r=R){let i=AbortSignal.timeout(r),a=n?AbortSignal.any([n,i]):i,o=new Headers;e.authorization&&o.set(`Authorization`,e.authorization);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{headers:o,signal:a}),a.throwIfAborted()}catch(e){throw V(e,i,n)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw V(e,i,n)}let l,d=!1;if(c)try{l=JSON.parse(c)}catch{d=!0}if(!s.ok){let t=!d&&l&&typeof l==`object`?l.error:void 0,n=typeof t==`string`?t:`HTTP ${s.status}`;throw s.status===401&&typeof window<`u`&&window.dispatchEvent(new window.CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),new u(n,s.status)}if(c){if(d)throw new u(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new u(typeof e==`string`?e:`Operation failed`,s.status)}return l}}async function oe(e,t,n={}){let r=n.target??z(),i=n.timeoutMs??R,a=ie(await H(r,t===`custom`?`/jobs/custom/${l(e,`Custom job ID`)}`:`/jobs/${c(e)}`,n.signal,i),{canonical:t===`id`,expectedId:t===`id`?e:void 0});if(!a||t===`id`)return a;if(a.customId!==e)throw new u(`Invalid job response: expected job.customId ${JSON.stringify(e)}`,200);return ie(await H(r,`/jobs/${c(a.id)}`,n.signal,i),{canonical:!0,expectedId:a.id})}function se(e,t){return async(n,r=e.lookupBy,i=!1,a=void 0,o=!1)=>{let s=n.trim();if(!s||a===void 0&&e.actionBusy.current&&!o)return;e.internalEmptyUrlPending.current=!1,e.preservedEmptyLocationKey.current=null,a===void 0&&(e.actionGen.current+=1),e.job!==null&&(r===`id`?e.job.id!==s:e.job.customId!==s)&&(e.jobTarget.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null)),e.lookupAbort.current?.abort();let l=new AbortController;e.lookupAbort.current=l,e.lookupIdentity.current={key:s,mode:r};let d=++e.lookupGen.current,f=z();e.setLoading(!0),e.setNotFound(!1),i||e.setMsg(null);try{let n=await oe(s,r,{signal:l.signal,target:f});if(!n){if(d!==e.lookupGen.current)return;e.internalEmptyUrlPending.current=!0,e.preservedEmptyLocationKey.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!0),t({},{replace:!0});return}let i=null,a=null;if(d!==e.lookupGen.current||l.signal.aborted||!B(f,z()))return;if(n.state===`completed`)if(Object.hasOwn(n,`returnvalue`))i={result:n.returnvalue};else try{i=ae(await H(f,`/jobs/${c(n.id)}/result`,l.signal),n.id)}catch(e){if(l.signal.aborted)throw e;a=e.message}if(d!==e.lookupGen.current||l.signal.aborted||!B(f,z()))return;e.jobTarget.current=f,e.setJob(n),r===`custom`?(e.setLookupBy(`id`),e.setIdInput(n.id)):e.setIdInput(s),t({id:n.id},{replace:!0}),e.setResult(i?{fetched:!0,value:i.result}:{fetched:!1,value:void 0}),e.setResultError(a)}catch(n){if(d!==e.lookupGen.current||l.signal.aborted)return;n instanceof u&&(n.status===404||/not found/i.test(n.message))?(e.internalEmptyUrlPending.current=!0,e.preservedEmptyLocationKey.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!0),t({},{replace:!0})):i?e.setMsg(e=>e?{ok:e.ok,text:`${e.text} — couldn't reload: ${n.message}`}:{ok:!1,text:n.message}):e.setMsg({ok:!1,text:n.message})}finally{d===e.lookupGen.current&&(e.lookupAbort.current===l&&(e.lookupAbort.current=null,e.lookupIdentity.current=null),e.setLoading(!1))}}}var U=e(n(),1),W=a(),G=365*24*60*60*1e3;function K(e,t){if(!e.trim())return{ok:!1,msg:`A value is required`};let n=Number(e);return Number.isFinite(n)?t===`progress`?n>=0&&n<=100?{ok:!0,value:n}:{ok:!1,msg:`Progress must be between 0 and 100`}:Number.isSafeInteger(n)?t===`priority`?n>=-1e6&&n<=1e6?{ok:!0,value:n}:{ok:!1,msg:`Priority must be between -1000000 and 1000000`}:n>=0&&n<=G?{ok:!0,value:n}:{ok:!1,msg:`Delay must be between 0 and ${G} ms`}:{ok:!1,msg:`Value must be a whole, safe integer`}:{ok:!1,msg:`Value must be a finite number`}}function ce({job:e,busy:t,act:n}){let r=A(e.state),i=r.promote||r.setPriority||r.setDelay||e.state===`active`;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Actions`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,W.jsx)(h,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>d.promoteJob(e.id)),children:`Promote (run now)`}),e.state===`failed`&&(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`DLQ retry is unavailable in Bunqueue v2.9.3: its GET and retry POST have no atomic job-generation, state, or flow-topology precondition.`}),e.state===`completed`&&(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`Completed-job requeue is unavailable in Bunqueue v2.9.3 because retry-completed re-inserts a child without rebuilding its flow dependency registration.`}),e.state===`active`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`Active-job state changes are unavailable: Bunqueue cannot stop the worker that is already processing this job, so retrying, delaying, discarding or failing it here could run side effects twice.`}),(0,W.jsx)(q,{label:`Set progress (0–100)`,cta:`Progress`,kind:`progress`,disabled:t,onSubmit:t=>n(`Progress`,()=>d.setJobProgress(e.id,t))})]}),r.setPriority&&(0,W.jsx)(le,{disabled:t,onSubmit:(t,r)=>n(`Priority`,()=>d.changePriority(e.id,t,r))}),r.setDelay&&(0,W.jsx)(q,{label:`Set delay (ms)`,cta:`Delay`,kind:`delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>d.changeDelay(e.id,t))}),(0,W.jsxs)(`p`,{role:`note`,className:`text-xs text-faint`,children:[`Cancel/delete/discard: `,O]}),!i&&(0,W.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function q({label:e,cta:t,kind:n,disabled:r,onSubmit:i}){let[a,o]=(0,U.useState)(``),s=K(a,n);return(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!r&&s.ok&&i(s.value)},children:[(0,W.jsx)(E,{type:`number`,min:0,max:n===`progress`?100:G,step:n===`progress`?`any`:1,name:n===`progress`?`job-progress`:`job-delay`,value:a,onChange:e=>o(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:r||!s.ok,children:t}),!s.ok&&a.trim()&&(0,W.jsx)(`span`,{role:`alert`,className:`self-center text-[11px] text-danger`,children:s.msg})]})}function le({disabled:e,onSubmit:t}){let[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(!1),o=K(n,`priority`);return(0,W.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault(),!e&&o.ok&&t(o.value,i)},children:[(0,W.jsx)(E,{type:`number`,min:-1e6,max:1e6,step:1,name:`job-priority`,value:n,onChange:e=>r(e.target.value),placeholder:`Set priority`,"aria-label":`Set priority`,className:`h-8 min-w-28 flex-1 text-xs`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(D,{checked:i,onChange:a,label:`Place first among equal priorities`}),(0,W.jsx)(`span`,{className:`text-xs text-muted`,children:`LIFO`})]}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:e||!o.ok,children:`Set`}),!o.ok&&n.trim()&&(0,W.jsx)(`span`,{role:`alert`,className:`w-full text-[11px] text-danger`,children:o.msg})]})}var J=36e5,Y=10,X=e=>Math.max(e,1);function ue(e){return Math.max(0,(e.maxAttempts??0)-X(e.attempts??0))}function de(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??J,a=r?.delay??e.backoff??1e3,o=[];for(let e=X(n);e<t&&o.length<Y;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function fe({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff`}),(0,W.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff schedule`}),(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,a=ue(e),o=de(e);return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff schedule`,action:(0,W.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${S(r.maxDelay)}`:``]})}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,W.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,W.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,S(e.delayMs)]})]},e.attempt))}),a>Y&&(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,Y,` of `,a,` remaining attempts.`]}),(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,S(r?.maxDelay??J),`.`]})]})}function pe({jobId:e}){let[t,n]=(0,U.useState)(!1),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(void 0),[l,u]=(0,U.useState)(null),f=async()=>{o(!0),u(null);try{let t=await d.jobChildren(e);c(t.data?.values),i(!0)}catch(e){u(e.message)}finally{o(!1)}},p=()=>{let e=!t;n(e),e&&!r&&!a&&f()},m=s&&typeof s==`object`?Array.isArray(s)?s.length:Object.keys(s).length:0;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Child values`,action:(0,W.jsx)(h,{size:`sm`,variant:`ghost`,onClick:p,children:t?`Hide`:`Show`})}),t?a?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):l?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:l}):m===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,W.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(s,null,2)}):(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function me({data:e,busy:t,editable:n,readOnlyReason:r,onSave:i}){let[a,o]=(0,U.useState)(()=>JSON.stringify(e??null,null,2)),[s,c]=(0,U.useState)(null),l=(0,U.useRef)(a);return(0,U.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,o(t),c(null))},[e]),(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Data`,action:n?(0,W.jsx)(h,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(a)}catch(e){c(`Invalid JSON: ${e.message}`);return}c(null),i(e)},children:`Save data`}):void 0}),(0,W.jsx)(`textarea`,{"aria-label":`Job data JSON`,name:`job-data-json`,value:a,onChange:e=>o(e.target.value),readOnly:!n,spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),!n&&(0,W.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:r??`Data is read-only after a job starts processing or leaves the runnable queue.`}),s&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:s})]})}function he(e){return e===`waiting`||e===`prioritized`||e===`delayed`}var ge=[`__parentId`,`__parentQueue`,`__childrenIds`,`__flowParentId`,`__flowParentIds`];function _e(e,t){if(!he(e))return`Data is read-only after a job starts processing or leaves the runnable queue.`;let n=t.data,r=typeof n==`object`&&!!n&&!Array.isArray(n)&&ge.some(e=>Object.hasOwn(n,e));return t.parentId||(t.childrenIds?.length??0)>0||r?`Data is read-only for Flow jobs because Bunqueue v2.9.3 replaces the full payload and would remove structural metadata.`:null}var ve=3e4;function Z(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function ye(e,t){return e.baseUrl===t.baseUrl&&e.authorization===t.authorization}function be(e,t,n){return t.aborted&&!n.aborted?new u(`Request timed out`,0):e}async function xe(e,t,n,r){let i=AbortSignal.timeout(ve),a=AbortSignal.any([r,i]),o=new Headers(n.headers);e.authorization&&o.set(`Authorization`,e.authorization),n.body!=null&&!o.has(`Content-Type`)&&o.set(`Content-Type`,`application/json`);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{...n,headers:o,signal:a}),a.throwIfAborted()}catch(e){throw be(e,i,r)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw be(e,i,r)}let l,d=!1;if(c)try{l=JSON.parse(c)}catch{d=!0}if(!s.ok){let t=!d&&l&&typeof l==`object`?l.error:void 0;throw s.status===401&&typeof window<`u`&&window.dispatchEvent(new window.CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),new u(typeof t==`string`?t:`HTTP ${s.status}`,s.status)}if(c){if(d)throw new u(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new u(typeof e==`string`?e:`Operation failed`,s.status)}return l}}function Se(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new u(`Invalid logs response: expected an object envelope`,200);let t=e;if(t.ok!==!0||!t.data||typeof t.data!=`object`)throw new u(`Invalid logs response: expected { ok: true, data }`,200);let n=t.data;if(!Array.isArray(n.logs)||typeof n.count!=`number`||!Number.isSafeInteger(n.count)||n.count<0)throw new u(`Invalid logs response: expected logs[] and a non-negative count`,200);return{logs:n.logs,count:n.count}}function Ce(e){let{logs:t,count:n,loading:r,busy:i,error:a,message:o,level:s,draftRevision:c}=e;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Logs`,action:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:n}),(0,W.jsx)(h,{size:`sm`,variant:`ghost`,disabled:r||i,onClick:e.load,children:`Refresh`}),(0,W.jsx)(h,{size:`sm`,variant:`danger`,disabled:i||t.length===0,onClick:e.clear,children:`Clear logs`})]})}),a&&(0,W.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:a}),t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,W.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,W.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,W.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:t=>{t.preventDefault();let n=t.currentTarget.elements.namedItem(`job-log-message`),r=t.currentTarget.elements.namedItem(`job-log-level`);e.add(n?.value??o,r?.value??s)},children:[(0,W.jsx)(E,{"aria-label":`Log message`,name:`job-log-message`,autoComplete:`off`,value:o,onInput:t=>{c.current+=1,e.setMessage(t.currentTarget.value)},placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,W.jsxs)(T,{"aria-label":`Log level`,name:`job-log-level`,value:s,onChange:t=>{c.current+=1,e.setLevel(t.target.value)},className:`h-8 w-24 text-xs`,children:[(0,W.jsx)(`option`,{value:`info`,children:`info`}),(0,W.jsx)(`option`,{value:`warn`,children:`warn`}),(0,W.jsx)(`option`,{value:`error`,children:`error`})]}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:i||o.trim()===``,children:`Add`})]})]})}function we({jobId:e}){let t=s(e=>e.baseUrl),n=s(e=>e.token),[r,i]=(0,U.useState)([]),[a,l]=(0,U.useState)(0),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(`info`),[y,b]=(0,U.useState)(!1),x=(0,U.useRef)(!1),S=(0,U.useRef)(null),C=(0,U.useRef)(0),w=(0,U.useRef)(null),T=(0,U.useRef)(0),E=(0,U.useRef)(null),D=(0,U.useRef)(!1),O=(0,U.useRef)(0);(0,U.useEffect)(()=>{x.current=!0,S.current=e;let t=()=>{C.current+=1,w.current?.abort(),w.current=null,T.current+=1,E.current?.abort(),E.current=null,D.current=!1,O.current+=1,i([]),l(0),f(!1),m(null),g(``),b(!1)},n=s.subscribe((e,n)=>{e.baseUrl===n.baseUrl&&e.token===n.token||t()});return t(),()=>{x.current=!1,S.current=null,n(),C.current+=1,w.current?.abort(),w.current=null,T.current+=1,E.current?.abort(),E.current=null,D.current=!1}},[e]);let k=(0,U.useCallback)(async r=>{w.current?.abort();let a=new AbortController;w.current=a;let u=++C.current,d=s.getState(),p=r?.target??(d.baseUrl===t&&d.token===n?{baseUrl:o(),authorization:n?`Bearer ${n}`:void 0}:Z()),h=()=>x.current&&S.current===e&&u===C.current&&!a.signal.aborted&&ye(p,Z());f(!0),m(null);try{let t=Se(await xe(p,`/jobs/${c(e)}/logs`,{},a.signal));return h()?(i(t.logs),l(t.count),!0):!1}catch(e){if(!h())return!1;let t=e instanceof Error?e.message:String(e);return m(r?.acceptedLabel?`${r.acceptedLabel} succeeded, but couldn't reload logs: ${t}`:t),!1}finally{u===C.current&&(w.current===a&&(w.current=null),x.current&&f(!1))}},[e,t,n]);(0,U.useEffect)(()=>{k()},[k]);let A=async(t,n,r)=>{if(D.current)return;D.current=!0;let i=new AbortController;E.current=i;let a=++T.current,o=Z();C.current+=1,w.current?.abort(),w.current=null,f(!1),b(!0),m(null);let s=()=>x.current&&S.current===e&&a===T.current&&!i.signal.aborted&&ye(o,Z());try{let a=await xe(o,`/jobs/${c(e)}/logs`,t,i.signal);if(!a||typeof a!=`object`||Array.isArray(a)||a.ok!==!0)throw new u(`Invalid log mutation response: expected { ok: true }`,200);if(!s())return;r(),await k({acceptedLabel:n,target:o})}catch(e){s()&&m(e instanceof Error?e.message:String(e))}finally{a===T.current&&(D.current=!1,E.current===i&&(E.current=null),x.current&&b(!1))}},j=async(e=h,t=_)=>{if(D.current)return;let n=e.trim();if(!n)return;let r=t===`warn`||t===`error`?t:`info`,i=O.current;g(e),v(r),await A({method:`POST`,body:JSON.stringify({message:n,level:r})},`Log addition`,()=>{O.current===i&&g(``)})},M=async()=>{D.current||window.confirm(`Clear all logs for this job?`)&&await A({method:`DELETE`},`Log clearing`,()=>{i([]),l(0)})};return(0,W.jsx)(Ce,{logs:r,count:a,loading:d,busy:y,error:p,message:h,level:_,draftRevision:O,setMessage:g,setLevel:v,load:()=>void k(),clear:()=>void M(),add:(e,t)=>void j(e,t)})}function Te({timeline:e}){let t=e??[];return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Timeline`}),t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,W.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,W.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(b,{status:e.state}),e.attempt!=null&&(0,W.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,W.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:C(e.timestamp)})]}),(e.worker||e.error)&&(0,W.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,W.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,W.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function Ee(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return e.failedReason?{message:e.failedReason}:null}function De({job:e,result:t,resultError:n,loading:r,notFound:i,busy:a,lookup:o,act:s}){if(r&&!e)return(0,W.jsx)(v,{label:`Loading job…`});if(i)return(0,W.jsx)(y,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`});if(!e)return(0,W.jsx)(y,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`});let c=e.state,l=Ee(e),u=e.stacktrace?.length?ne(e.stacktrace):null,f=(e.childrenIds?.length??0)>0,p=_e(c,e),m=c===`failed`,h=l||u?(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Error`}),l&&(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`p`,{className:`text-sm text-danger`,children:l.message}),(0,W.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[l.attempt==null?``:`Attempt ${l.attempt} · `,C(l.timestamp)]})]}),u&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:u.text}),u.truncated&&(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-faint`,children:[`Stack preview truncated (`,u.displayedLines,` of `,u.totalLines,` `,`lines, 262,144 characters maximum). Download JSON for the complete stored stack.`]})]})]}):null;return(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,W.jsx)(Oe,{job:e}),m&&h,(0,W.jsx)(me,{data:e.data,busy:a,editable:p===null,readOnlyReason:p??void 0,onSave:t=>s(`Data`,()=>d.updateJobData(e.id,t))},`data-${e.id}`),c===`completed`&&(0,W.jsx)(ke,{jobId:e.id,result:t,resultError:n,loading:r,onRetry:()=>o(e.id,`id`)}),!m&&h,(0,W.jsx)(we,{jobId:e.id},`logs-${e.id}`),f&&(0,W.jsx)(pe,{jobId:e.id},`children-${e.id}`),(0,W.jsx)(Te,{timeline:e.timeline}),(0,W.jsx)(fe,{job:e})]}),(0,W.jsx)(`div`,{className:`order-first lg:order-none`,children:(0,W.jsx)(ce,{job:e,busy:a,act:s})})]})}function Oe({job:e}){return(0,W.jsxs)(_,{children:[(0,W.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:e.id}),(0,W.jsx)(w,{value:e.id})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:e.queue})]}),(0,W.jsx)(b,{status:e.state??`unknown`})]}),(0,W.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,W.jsx)(Q,{label:`Priority`,value:String(e.priority??0)}),(0,W.jsx)(Q,{label:`Name`,value:e.name??`default`}),(0,W.jsx)(Q,{label:`Attempts`,value:`${e.attempts??0} / ${e.maxAttempts??`?`}`}),(0,W.jsx)(Q,{label:`Progress`,value:`${e.progress??0}%`}),(0,W.jsx)(Q,{label:`Created`,value:C(e.createdAt)}),(0,W.jsx)(Q,{label:`Started`,value:C(e.startedAt??void 0)}),(0,W.jsx)(Q,{label:`Completed`,value:C(e.completedAt??void 0)}),(0,W.jsx)(Q,{label:`Duration`,value:S(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,W.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,W.jsx)(`span`,{className:`truncate font-mono`,children:e.customId??`—`}),e.customId&&(0,W.jsx)(w,{value:e.customId})]})]})]})]})}function ke({jobId:e,result:t,resultError:n,loading:r,onRetry:i}){let a=t.fetched&&t.value!==void 0&&t.value!==null;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Result`,action:a?(0,W.jsx)(je,{value:t.value,filename:`job-${e}-result`}):void 0}),a?(0,W.jsx)(Ae,{value:t.value}):n?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,W.jsxs)(`p`,{className:`text-xs text-danger`,children:[`Couldn't load result — `,n]}),(0,W.jsx)(h,{size:`sm`,disabled:r,onClick:i,children:`Retry`})]}):(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]})}function Q({label:e,value:t}){return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`text-fg`,children:t})]})}function Ae({value:e}){return(0,W.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(e??null,null,2)})}function je({value:e,filename:t}){return(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(w,{value:JSON.stringify(e??null,null,2)}),(0,W.jsx)(m,{"aria-label":`Download JSON`,title:`Download JSON`,onClick:()=>k(t,e??null),children:(0,W.jsx)(p,{className:`size-3.5`})})]})}function Me(e){let t={};return typeof e.priority==`number`&&(t.priority=e.priority),typeof e.maxAttempts==`number`&&(t.maxAttempts=e.maxAttempts),typeof e.backoff==`number`&&(t.backoff=e.backoff),e.backoffConfig&&typeof e.backoffConfig.delay==`number`&&(t.backoffConfig={type:e.backoffConfig.type,delay:e.backoffConfig.delay},typeof t.backoff!=`number`&&(t.backoff=e.backoffConfig.delay)),typeof e.timeout==`number`&&(t.timeout=e.timeout),typeof e.removeOnComplete==`boolean`&&(t.removeOnComplete=e.removeOnComplete),typeof e.removeOnFail==`boolean`&&(t.removeOnFail=e.removeOnFail),typeof e.ttl==`number`&&(t.ttl=e.ttl),Array.isArray(e.tags)&&e.tags.length&&(t.tags=[...e.tags]),typeof e.groupId==`string`&&e.groupId&&(t.groupId=e.groupId),{clone:{queue:e.queue??``,name:e.name,dataText:JSON.stringify(e.data??{},null,2),options:t}}}function Ne({job:e,result:t,idInput:n,lookupBy:r,loading:a,busy:o,onInputChange:s,onModeChange:c,onSubmit:l}){let u=!!(e&&((e.childrenIds?.length??0)>0||e.parentId));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(x,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:e?(0,W.jsxs)(W.Fragment,{children:[u&&(0,W.jsx)(i,{to:`/flows?root=${encodeURIComponent(e.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}),(0,W.jsx)(i,{to:`/add-job`,state:Me(e),title:`Enqueue a new job pre-filled from this one`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Clone`}),(0,W.jsxs)(h,{size:`sm`,onClick:()=>k(`job-${e.id}`,t.fetched?{...e,result:t.value}:e),children:[(0,W.jsx)(p,{className:`size-3.5`}),` Download JSON`]})]}):void 0}),(0,W.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(T,{name:`job-lookup-mode`,autoComplete:`off`,value:r,"aria-label":`Lookup mode`,onChange:e=>c(e.target.value),className:`w-40`,children:[(0,W.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,W.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,W.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,W.jsx)(f,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,W.jsx)(`input`,{value:n,"aria-label":r===`custom`?`Custom job ID`:`Job ID`,name:`job-lookup-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,onInput:e=>s(e.currentTarget.value),onKeyDown:e=>e.key===`Enter`&&l(n),placeholder:r===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,W.jsx)(h,{variant:`accent`,disabled:a||o,onClick:()=>l(n),children:`Look up`})]})]})}function Pe({state:e,lookup:t,setParams:n,locationKey:r,idParam:i,customParam:a,jobBelongsToCurrentTarget:o,connectionBaseUrl:s,connectionToken:c}){(0,U.useEffect)(()=>{if(e.internalEmptyUrlPending.current){!i&&!a&&(e.internalEmptyUrlPending.current=!1,e.preservedEmptyLocationKey.current=r);return}if(!(!i&&!a&&e.preservedEmptyLocationKey.current===r))if(e.preservedEmptyLocationKey.current=null,a)if(e.job?.customId===a&&o)e.setLookupBy(`id`),e.setIdInput(e.job.id),n({id:e.job.id},{replace:!0});else{e.setLookupBy(`custom`),e.setIdInput(a);let n=e.lookupIdentity.current;(n?.mode!==`custom`||n.key!==a)&&t(a,`custom`,!1,void 0,!0)}else if(i&&(i!==e.job?.id||!o)){e.setLookupBy(`id`),e.setIdInput(i);let n=e.lookupIdentity.current;(n?.mode!==`id`||n.key!==i)&&t(i,`id`,!1,void 0,!0)}else!i&&!a&&(e.lookupGen.current+=1,e.lookupAbort.current?.abort(),e.lookupAbort.current=null,e.lookupIdentity.current=null,e.actionGen.current+=1,e.jobTarget.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!1),e.setMsg(null),e.setLoading(!1),e.setLookupBy(`id`),e.setIdInput(``))},[i,a,e.job?.id,e.job?.customId,o,r,s,c])}var $={fetched:!1,value:void 0};function Fe(e,t){let[n,r]=(0,U.useState)(e??t??``),[i,a]=(0,U.useState)(e?`custom`:`id`),[o,c]=(0,U.useState)(null),[l,u]=(0,U.useState)($),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null),[y,b]=(0,U.useState)(!1),x=(0,U.useRef)(0),S=(0,U.useRef)(null),C=(0,U.useRef)(null),w=(0,U.useRef)(null),T=(0,U.useRef)(!1),E=(0,U.useRef)(null),D=(0,U.useRef)(!1),O=(0,U.useRef)(0),k=(0,U.useRef)(!1),A=(0,U.useRef)(null);return(0,U.useEffect)(()=>{D.current=!0;let e=s.subscribe((e,t)=>{e.baseUrl===t.baseUrl&&e.token===t.token||(x.current+=1,S.current?.abort(),S.current=null,C.current=null,O.current+=1,A.current=null,k.current=!1,w.current=null,T.current=!1,E.current=null,c(null),u($),f(null),g(!1),v(null),m(!1),b(!1))});return()=>{D.current=!1,e(),x.current+=1,S.current?.abort(),S.current=null,C.current=null,O.current+=1,A.current=null,k.current=!1}},[]),{idInput:n,setIdInput:r,lookupBy:i,setLookupBy:a,job:o,setJob:c,result:l,setResult:u,resultError:d,setResultError:f,loading:p,setLoading:m,notFound:h,setNotFound:g,msg:_,setMsg:v,busy:y,setBusy:b,lookupGen:x,lookupAbort:S,lookupIdentity:C,jobTarget:w,internalEmptyUrlPending:T,preservedEmptyLocationKey:E,mounted:D,actionGen:O,actionBusy:k,actionLockOwner:A}}function Ie(){let e=r(),[n,i]=t(),a=s(e=>e.baseUrl),c=s(e=>e.token),l=Fe(n.get(`custom`),n.get(`id`)),d=se(l,i),f=n.get(`id`),p=n.get(`custom`),m={baseUrl:o(),authorization:c?`Bearer ${c}`:void 0},h=B(l.jobTarget.current,m);return Pe({state:l,lookup:d,setParams:i,locationKey:e.key,idParam:f,customParam:p,jobBelongsToCurrentTarget:h,connectionBaseUrl:a,connectionToken:c}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ne,{job:l.job,result:l.result,idInput:l.idInput,lookupBy:l.lookupBy,loading:l.loading,busy:l.busy,onInputChange:l.setIdInput,onModeChange:l.setLookupBy,onSubmit:(e,t=l.lookupBy)=>{let n=e.trim();if(!(!n||l.actionBusy.current)){if(t===`id`?f===n&&p===null:p===n&&f===null){d(n,t);return}i(t===`custom`?{custom:n}:{id:n})}}}),l.msg&&(0,W.jsx)(`div`,{role:`status`,className:l.msg.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:l.msg.text}),(0,W.jsx)(De,{job:l.job,result:l.result,resultError:l.resultError,loading:l.loading,notFound:l.notFound,busy:l.busy,lookup:d,act:async(e,t,n)=>{if(!l.job||l.actionBusy.current||l.lookupAbort.current)return;let r=z();if(!B(l.jobTarget.current,r)||n&&!window.confirm(n))return;let a=++l.actionGen.current,o=l.job.id;l.actionLockOwner.current=a,l.actionBusy.current=!0,l.setBusy(!0),l.setMsg(null);let s=()=>l.mounted.current&&a===l.actionGen.current&&B(r,z())&&B(l.jobTarget.current,r);try{let n=await t();if(!n||typeof n!=`object`||Array.isArray(n)||n.ok!==!0)throw new u(`Invalid job mutation response: expected { ok: true }`,200);if(!s())return;l.setMsg({ok:!0,text:`${e} ✓`}),e===`Cancel`?(l.internalEmptyUrlPending.current=!0,l.preservedEmptyLocationKey.current=null,l.lookupGen.current+=1,l.jobTarget.current=null,l.setJob(null),l.setResult({fetched:!1,value:void 0}),l.setResultError(null),i({},{replace:!0})):await d(o,`id`,!0,a)}catch(e){s()&&l.setMsg({ok:!1,text:e.message})}finally{l.actionLockOwner.current===a&&(l.actionLockOwner.current=null,l.actionBusy.current=!1,l.mounted.current&&l.setBusy(!1))}}})]})}export{Ie as JobInspector};
@@ -1 +1 @@
1
- import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-F5BbTG1T.js";import{T as o}from"./icons-BVzwsfbG.js";import{t as s}from"./api-BgWE-705.js";import{n as c}from"./usePolledData-0CVelkl2.js";import{i as l,r as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./StatusBadge-BoOVTnKu.js";import{t as f}from"./PageHeader-CvIyaFOO.js";import{a as p,c as m,d as h,l as g,s as _,t as v}from"./format-Cg7VCIZW.js";import{n as y}from"./index-mID5W7vq.js";import{a as b,i as x}from"./form-C4oby9pI.js";import{r as S}from"./flowMutationSafety-YKTHxqKv.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";var w=e(n(),1),T=`__all__`,E=[`all`,`waiting`,`active`,`completed`,`failed`],D=500,O=20,k=D*O;function A(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>k||n!==null&&e.total!==n||e.offset!==t||e.limit!==D||e.queues.length!==Math.min(D,e.total-t)||e.queues.length>D||e.queues.some(e=>typeof e!=`object`||!e||typeof e.name!=`string`||e.name.length===0||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)))throw Error(`Queue discovery returned a malformed or unsafe page`)}async function j(){let e=await s.queues(D,0);A(e,0,null);let t=[...e.queues],n=new Set;for(let e of t){if(n.has(e.name))throw Error(`Queue discovery returned duplicate queue ${e.name}`);n.add(e.name)}let r=e.total,i=1;for(;t.length<r;){if(i>=O||t.length>=k)throw Error(`Queue discovery exceeds the safety limit of ${k}`);let e=t.length,a=await s.queues(D,e);A(a,e,r);for(let e of a.queues){if(n.has(e.name))throw Error(`Queue discovery pages overlap at queue ${e.name}`);n.add(e.name),t.push(e)}i+=1}return{...e,queues:t,total:r,limit:t.length,offset:0}}function M(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}var N=i();function P({rows:e,emptyMessage:t}){return(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,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`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,N.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,N.jsx)(`tbody`,{children:e.length===0?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:t})}):e.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 font-mono text-xs`,children:(0,N.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`text-accent/90 hover:text-accent hover:underline`,title:`Inspect job ${e.id}`,children:e.id})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??M(e.data)??`default`}),(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,N.jsx)(`td`,{className:`px-5 py-3`,children:(0,N.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(h(e.startedAt??void 0,e.completedAt??void 0))}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,N.jsx)(`span`,{className:`text-xs text-faint`,title:S,children:`Delete unavailable`})})]},`${e.queue}:${e.id}`))})]})})}var F=8;function I(){let[e]=t(),[n,r]=(0,w.useState)(e.get(`queue`)??`__all__`),[i,d]=(0,w.useState)(`all`),[p,h]=(0,w.useState)(``),{data:g,error:S,refetch:D}=c(j,[],{intervalMs:3e4}),{data:O,error:k,refetch:A}=c(()=>s.overview(),[]),I=(0,w.useMemo)(()=>(g?.queues??[]).map(e=>e.name),[g]),L=`${n}\u0000${i}\u0000${JSON.stringify(I)}`,{data:R,error:z,loading:B,refetch:V}=c((0,w.useCallback)(async e=>{if(n===`__all__`&&!g)return null;let t=n===`__all__`?I:[n];if(n===`__all__`&&t.length>100)return{scopeKey:L,jobs:[],failures:[],queueCount:t.length,blockedReason:`All-queue job browsing is limited to 100 queues; ${_(t.length)} were discovered. Select one queue to avoid an unsafe request fan-out.`};let r=i===`all`?void 0:[i],o=a.createServerTargetClient(a.captureServerRequestTarget(),e),s=await C(t,F,async t=>(e.throwIfAborted(),(await o.jobsList(t,r,40)).jobs.map(e=>({...e,stacktrace:e.stacktrace??void 0,queue:e.queue??t}))),e);e.throwIfAborted();let c=[],l=[];return s.forEach((e,n)=>{e.status===`fulfilled`?c.push(...e.value):l.push({queue:t[n],message:e.reason instanceof Error?e.reason.message:String(e.reason)})}),{scopeKey:L,jobs:c.sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)),failures:l,queueCount:t.length,blockedReason:null}},[n,i,g,I,L]),[L],{intervalMs:15e3}),H=R?.scopeKey===L?R:null,U=H?.blockedReason?null:H?.jobs??null,{rows:W,matchingCount:G}=(0,w.useMemo)(()=>{let e=U??[],t=p.trim().toLowerCase(),n=t?e.filter(e=>typeof e.id==`string`&&e.id.toLowerCase().includes(t)||(M(e.data)?.toLowerCase().includes(t)??!1)):e;return{rows:n.slice(0,100),matchingCount:n.length}},[U,p]),K=O?.stats,q=K?v(K.totalCompleted,K.totalFailed):null,J=e=>K?_(e):`—`,Y=!!H&&H.queueCount>0&&H.failures.length===H.queueCount,X=n===`__all__`&&!g&&!S||B&&!H&&!z,Z=`No jobs found.`;return H?.blockedReason?Z=H.blockedReason:n===`__all__`&&S&&!g?Z=`Queue discovery unavailable — ${S.message}`:z&&!H?Z=`Could not load jobs — ${z.message}`:Y?Z=`Could not load jobs from any of the ${H.queueCount} queues.`:p.trim()&&H?.failures.length?Z=`No matching jobs in the queue results that could be loaded.`:p.trim()&&(Z=`No jobs match this search.`),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!H&&!S&&!k&&!z&&!H.blockedReason&&H.failures.length===0}),S&&(0,N.jsx)(l,{message:`Queue discovery unavailable — ${S.message}`,onRetry:D}),k&&(0,N.jsx)(l,{message:`Job totals unavailable — ${k.message}`,onRetry:A}),z&&(0,N.jsx)(l,{message:`Could not load jobs — ${z.message}`,onRetry:V}),H?.blockedReason&&(0,N.jsx)(l,{message:H.blockedReason}),!!H?.failures.length&&(0,N.jsx)(l,{message:`Could not load jobs from ${H.failures.length} of ${H.queueCount} queues: ${H.failures.slice(0,3).map(e=>`${e.queue} (${e.message})`).join(`, `)}${H.failures.length>3?`, …`:``}`,onRetry:V}),(0,N.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,N.jsx)(y,{label:`Total`,value:K?_(K.totalCompleted+K.totalFailed+K.waiting+K.active):`—`,compact:!0}),(0,N.jsx)(y,{label:`Waiting`,value:J(K?.waiting),tone:`amber`,compact:!0}),(0,N.jsx)(y,{label:`Active`,value:J(K?.active),tone:`blue`,compact:!0}),(0,N.jsx)(y,{label:`Completed`,value:J(K?.totalCompleted),tone:`green`,compact:!0}),(0,N.jsx)(y,{label:`Failed`,value:J(K?.totalFailed),tone:K?.totalFailed?`red`:`default`,compact:!0}),(0,N.jsx)(y,{label:`Error Rate`,value:q==null?`—`:m(q),tone:q==null?`default`:q>.05?`red`:`green`,compact:!0})]}),(0,N.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(`div`,{className:`w-48`,children:(0,N.jsxs)(b,{value:n,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>r(e.target.value),children:[(0,N.jsx)(`option`,{value:T,children:`All Queues`}),(g?.queues??[]).map(e=>(0,N.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,N.jsx)(x,{options:E,value:i,onChange:d}),(0,N.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,N.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,N.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),"aria-label":`Search jobs`,name:`jobs-search`,autoComplete:`off`,placeholder:`Search by ID or name…`,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`})]})]}),H&&!H.blockedReason&&(0,N.jsxs)(`p`,{role:`status`,className:`mb-3 text-xs text-faint`,children:[n===`__all__`?`Queried all ${_(H.queueCount)} discovered queues`:`Queried ${n}`,` `,`· up to `,40,` recent jobs per queue`,G>100?` · showing the newest 100 of ${_(G)} matches`:``]}),X?(0,N.jsx)(u,{label:`Loading jobs…`}):(0,N.jsx)(P,{rows:W,emptyMessage:Z})]})}export{I as Jobs,j as t};
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-F5BbTG1T.js";import{T as o}from"./icons-BVzwsfbG.js";import{t as s}from"./api-BgWE-705.js";import{n as c}from"./usePolledData-0CVelkl2.js";import{i as l,r as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./StatusBadge-BoOVTnKu.js";import{t as f}from"./PageHeader-CvIyaFOO.js";import{a as p,c as m,d as h,l as g,s as _,t as v}from"./format-Cg7VCIZW.js";import{n as y}from"./index-BFW2_47n.js";import{a as b,i as x}from"./form-C4oby9pI.js";import{r as S}from"./flowMutationSafety-YKTHxqKv.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";var w=e(n(),1),T=`__all__`,E=[`all`,`waiting`,`active`,`completed`,`failed`],D=500,O=20,k=D*O;function A(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>k||n!==null&&e.total!==n||e.offset!==t||e.limit!==D||e.queues.length!==Math.min(D,e.total-t)||e.queues.length>D||e.queues.some(e=>typeof e!=`object`||!e||typeof e.name!=`string`||e.name.length===0||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)))throw Error(`Queue discovery returned a malformed or unsafe page`)}async function j(){let e=await s.queues(D,0);A(e,0,null);let t=[...e.queues],n=new Set;for(let e of t){if(n.has(e.name))throw Error(`Queue discovery returned duplicate queue ${e.name}`);n.add(e.name)}let r=e.total,i=1;for(;t.length<r;){if(i>=O||t.length>=k)throw Error(`Queue discovery exceeds the safety limit of ${k}`);let e=t.length,a=await s.queues(D,e);A(a,e,r);for(let e of a.queues){if(n.has(e.name))throw Error(`Queue discovery pages overlap at queue ${e.name}`);n.add(e.name),t.push(e)}i+=1}return{...e,queues:t,total:r,limit:t.length,offset:0}}function M(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}var N=i();function P({rows:e,emptyMessage:t}){return(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,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`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,N.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,N.jsx)(`tbody`,{children:e.length===0?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:t})}):e.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 font-mono text-xs`,children:(0,N.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`text-accent/90 hover:text-accent hover:underline`,title:`Inspect job ${e.id}`,children:e.id})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??M(e.data)??`default`}),(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,N.jsx)(`td`,{className:`px-5 py-3`,children:(0,N.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(h(e.startedAt??void 0,e.completedAt??void 0))}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,N.jsx)(`span`,{className:`text-xs text-faint`,title:S,children:`Delete unavailable`})})]},`${e.queue}:${e.id}`))})]})})}var F=8;function I(){let[e]=t(),[n,r]=(0,w.useState)(e.get(`queue`)??`__all__`),[i,d]=(0,w.useState)(`all`),[p,h]=(0,w.useState)(``),{data:g,error:S,refetch:D}=c(j,[],{intervalMs:3e4}),{data:O,error:k,refetch:A}=c(()=>s.overview(),[]),I=(0,w.useMemo)(()=>(g?.queues??[]).map(e=>e.name),[g]),L=`${n}\u0000${i}\u0000${JSON.stringify(I)}`,{data:R,error:z,loading:B,refetch:V}=c((0,w.useCallback)(async e=>{if(n===`__all__`&&!g)return null;let t=n===`__all__`?I:[n];if(n===`__all__`&&t.length>100)return{scopeKey:L,jobs:[],failures:[],queueCount:t.length,blockedReason:`All-queue job browsing is limited to 100 queues; ${_(t.length)} were discovered. Select one queue to avoid an unsafe request fan-out.`};let r=i===`all`?void 0:[i],o=a.createServerTargetClient(a.captureServerRequestTarget(),e),s=await C(t,F,async t=>(e.throwIfAborted(),(await o.jobsList(t,r,40)).jobs.map(e=>({...e,stacktrace:e.stacktrace??void 0,queue:e.queue??t}))),e);e.throwIfAborted();let c=[],l=[];return s.forEach((e,n)=>{e.status===`fulfilled`?c.push(...e.value):l.push({queue:t[n],message:e.reason instanceof Error?e.reason.message:String(e.reason)})}),{scopeKey:L,jobs:c.sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)),failures:l,queueCount:t.length,blockedReason:null}},[n,i,g,I,L]),[L],{intervalMs:15e3}),H=R?.scopeKey===L?R:null,U=H?.blockedReason?null:H?.jobs??null,{rows:W,matchingCount:G}=(0,w.useMemo)(()=>{let e=U??[],t=p.trim().toLowerCase(),n=t?e.filter(e=>typeof e.id==`string`&&e.id.toLowerCase().includes(t)||(M(e.data)?.toLowerCase().includes(t)??!1)):e;return{rows:n.slice(0,100),matchingCount:n.length}},[U,p]),K=O?.stats,q=K?v(K.totalCompleted,K.totalFailed):null,J=e=>K?_(e):`—`,Y=!!H&&H.queueCount>0&&H.failures.length===H.queueCount,X=n===`__all__`&&!g&&!S||B&&!H&&!z,Z=`No jobs found.`;return H?.blockedReason?Z=H.blockedReason:n===`__all__`&&S&&!g?Z=`Queue discovery unavailable — ${S.message}`:z&&!H?Z=`Could not load jobs — ${z.message}`:Y?Z=`Could not load jobs from any of the ${H.queueCount} queues.`:p.trim()&&H?.failures.length?Z=`No matching jobs in the queue results that could be loaded.`:p.trim()&&(Z=`No jobs match this search.`),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!H&&!S&&!k&&!z&&!H.blockedReason&&H.failures.length===0}),S&&(0,N.jsx)(l,{message:`Queue discovery unavailable — ${S.message}`,onRetry:D}),k&&(0,N.jsx)(l,{message:`Job totals unavailable — ${k.message}`,onRetry:A}),z&&(0,N.jsx)(l,{message:`Could not load jobs — ${z.message}`,onRetry:V}),H?.blockedReason&&(0,N.jsx)(l,{message:H.blockedReason}),!!H?.failures.length&&(0,N.jsx)(l,{message:`Could not load jobs from ${H.failures.length} of ${H.queueCount} queues: ${H.failures.slice(0,3).map(e=>`${e.queue} (${e.message})`).join(`, `)}${H.failures.length>3?`, …`:``}`,onRetry:V}),(0,N.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,N.jsx)(y,{label:`Total`,value:K?_(K.totalCompleted+K.totalFailed+K.waiting+K.active):`—`,compact:!0}),(0,N.jsx)(y,{label:`Waiting`,value:J(K?.waiting),tone:`amber`,compact:!0}),(0,N.jsx)(y,{label:`Active`,value:J(K?.active),tone:`blue`,compact:!0}),(0,N.jsx)(y,{label:`Completed`,value:J(K?.totalCompleted),tone:`green`,compact:!0}),(0,N.jsx)(y,{label:`Failed`,value:J(K?.totalFailed),tone:K?.totalFailed?`red`:`default`,compact:!0}),(0,N.jsx)(y,{label:`Error Rate`,value:q==null?`—`:m(q),tone:q==null?`default`:q>.05?`red`:`green`,compact:!0})]}),(0,N.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(`div`,{className:`w-48`,children:(0,N.jsxs)(b,{value:n,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>r(e.target.value),children:[(0,N.jsx)(`option`,{value:T,children:`All Queues`}),(g?.queues??[]).map(e=>(0,N.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,N.jsx)(x,{options:E,value:i,onChange:d}),(0,N.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,N.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,N.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),"aria-label":`Search jobs`,name:`jobs-search`,autoComplete:`off`,placeholder:`Search by ID or name…`,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`})]})]}),H&&!H.blockedReason&&(0,N.jsxs)(`p`,{role:`status`,className:`mb-3 text-xs text-faint`,children:[n===`__all__`?`Queried all ${_(H.queueCount)} discovered queues`:`Queried ${n}`,` `,`· up to `,40,` recent jobs per queue`,G>100?` · showing the newest 100 of ${_(G)} matches`:``]}),X?(0,N.jsx)(u,{label:`Loading jobs…`}):(0,N.jsx)(P,{rows:W,emptyMessage:Z})]})}export{I as Jobs,j as t};
@@ -0,0 +1 @@
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{t as o}from"./bq-F5BbTG1T.js";import{t as s}from"./toastStore-IZn6OPLZ.js";import{T as c,d as l,f as u,x as d}from"./icons-BVzwsfbG.js";import{n as f}from"./usePolledData-0CVelkl2.js";import{n as p,t as m}from"./Button-Ch1W94fJ.js";import{i as h,n as g,r as _}from"./feedback-QDN1AsYt.js";import{t as v}from"./StatusBadge-BoOVTnKu.js";import{t as y}from"./PageHeader-CvIyaFOO.js";import{a as b,c as x,i as S,s as C,t as ee}from"./format-Cg7VCIZW.js";import{n as w}from"./index-BFW2_47n.js";import{a as T}from"./form-C4oby9pI.js";import{t as E}from"./Pagination-x-Cwgrul.js";import{r as D,t as O}from"./useServerActionGuard-uGePilQQ.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as k}from"./flowOperationPolicy-B2Etcb3f.js";var A=e(r(),1),j=a();function ne(e){return(0,j.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,j.jsx)(w,{label:`Total`,value:e.total,hint:`all queues`,compact:!0}),(0,j.jsx)(w,{label:`Waiting`,value:e.waiting,tone:`amber`,hint:`standard priority`,compact:!0}),(0,j.jsx)(w,{label:`Prioritized`,value:e.prioritized,tone:`amber`,compact:!0}),(0,j.jsx)(w,{label:`Active`,value:e.active,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Flow-blocked`,value:e.flowBlocked,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Completed`,value:e.completed,tone:`green`,compact:!0}),(0,j.jsx)(w,{label:`Failed`,value:e.failed,tone:e.failedCount!=null&&e.failedCount>0?`red`:`default`,compact:!0}),(0,j.jsx)(w,{label:`Error Rate`,value:e.errorRate,tone:e.errorRateTone,compact:!0})]})}var M=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`];function N(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function P(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function F(e=0){return e>=10?{text:`HIGH`,className:`text-warning`}:e>=1?{text:`MEDIUM`,className:`text-blue-400`}:{text:`LOW`,className:`text-faint`}}function re({queue:e,rows:n,search:r,discoveryError:a,selected:s,allSelected:c,bulkBusy:l,busyIds:f,page:m,hasNext:h,onToggleAll:g,onToggle:_,onRun:y,onPage:x}){return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,j.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:e})]}),(0,j.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:c,ref:e=>{e&&(e.indeterminate=s.size>0&&!c)},"aria-checked":s.size>0&&!c?`mixed`:c,onChange:g,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,j.jsx)(`tbody`,{children:n.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:r.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:a?`Queue discovery failed. Retry above.`:`Select a queue.`})}):n.map(e=>{let n=F(e.priority),r=k(e.state),a=l||f.has(e.id);return(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:s.has(e.id),onChange:()=>_(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,j.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(v,{status:String(e.state??`waiting`)})}),(0,j.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.className),children:n.text}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:S(e.createdAt)}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,j.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect job ${e.id}`,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,j.jsx)(u,{className:`size-3.5`})}),r.promote&&(0,j.jsx)(p,{"aria-label":`Promote job`,disabled:a,onClick:()=>y(e,`Promote`,()=>o.promoteJob(e.id)),children:(0,j.jsx)(d,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,j.jsx)(E,{page:m,pageSize:25,hasNext:h,onPageChange:x,label:`jobs`})]})}function I({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:s,onQueue:l,onStatus:u,onSearch:d,onPromote:f}){return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{value:e,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:t.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{"aria-label":`Job state`,name:`jobs-state`,value:n,onChange:e=>u(e.target.value),children:M.map(e=>(0,j.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,j.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,j.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,j.jsx)(`input`,{value:r,onChange:e=>d(e.target.value),placeholder:`Filter this page by ID or name…`,"aria-label":`Filter by job ID or name`,name:`jobs-id-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),i>0&&(0,j.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`mr-1 text-muted`,children:N(a,i)}),o?(0,j.jsx)(m,{size:`sm`,disabled:s,onClick:f,children:`Promote selected`}):(0,j.jsx)(`span`,{className:`text-xs text-faint`,children:a===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]})]})}function ie({queue:e,rows:t,selected:n,setSelected:r,refetch:i}){let[a,o]=(0,A.useState)(new Set),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(null),f=D(`jobs:${e}`);return(0,A.useEffect)(()=>{o(new Set),l(!1),d(null)},[f.scopeKey]),{actionMsg:u,bulkBusy:c,busyIds:a,runBulk:async(e,a,o,c)=>{let u=t.filter(e=>n.has(e.id)&&o(e));if(u.length===0||c&&!window.confirm(c(u.length)))return;let p=f.begin([`bulk`,...u.map(e=>`job:${e.id}`)]);if(p){l(!0),d(null);try{let t=await Promise.allSettled(u.map(async t=>{O(await a(t),`${e} ${t.id}`)}));if(!p.isCurrent())return;let n=t.filter(e=>e.status===`fulfilled`).length,o=t.length-n,c=`${e}: ${n} succeeded${o?`, ${o} failed`:``}`;d({ok:o===0,text:c}),o===0?s.success(c):s.error(c),r(e=>P(e,u.map(e=>e.id))),i()}finally{p.finish()&&l(!1)}}},runOne:async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let a=f.begin(`job:${e.id}`);if(a){o(t=>new Set(t).add(e.id)),d(null);try{if(O(await n(),t),!a.isCurrent())return;d({ok:!0,text:`${t} ✓`}),s.success(`${t} ✓`,e.id),i()}catch(e){if(!a.isCurrent())return;d({ok:!1,text:`${t} failed: ${e.message}`}),s.error(`${t} failed`,e.message)}finally{a.finish()&&o(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function L(){let[e,t]=n(),[r,i]=(0,A.useState)(e.get(`queue`)??``),[a,c]=(0,A.useState)(()=>{let t=e.get(`status`);return t&&M.includes(t)?t:`all`}),[u,d]=(0,A.useState)(``),[p,v]=(0,A.useState)(0),[b,S]=(0,A.useState)(new Set),{data:w,error:T,loading:E,refetch:D}=f(()=>o.queuesSummary(),[],{intervalMs:3e4}),{data:O,error:N,refetch:P}=f(()=>o.stats(),[],{intervalMs:1e4});(0,A.useEffect)(()=>{!r&&w?.length&&i(w[0].name)},[w,r]);let F=`${r}|${a}|${p}`,{data:L,error:R,loading:z,refetch:B}=f((0,A.useCallback)(async()=>{if(!r)return{view:F,jobs:[]};let e=a===`all`?void 0:[a],t=await o.jobsList(r,e,25,p*25);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,a,p,F]),[r,a,p]),V=L?.view===F?L.jobs:null,ae=(V?.length??0)===25,H=(0,A.useMemo)(()=>{let e=u.trim().toLowerCase();return e?(V??[]).filter(t=>t.id.toLowerCase().includes(e)||t.name?.toLowerCase().includes(e)):V??[]},[V,u]),U=O?.stats,W=(0,A.useMemo)(()=>w?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[w]),G=U&&W!=null?ee(U.completed,W):null,K=e=>U?C(e):`—`,q=()=>v(0),J=(e,n)=>{let r={};e&&(r.queue=e),n!==`all`&&(r.status=n),t(r,{replace:!0})};(0,A.useEffect)(()=>{S(new Set)},[r,a,p]);let oe=e=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=H.length>0&&H.every(e=>b.has(e.id)),se=()=>S(()=>Y?new Set:new Set(H.map(e=>e.id))),{actionMsg:X,bulkBusy:Z,busyIds:ce,runBulk:le,runOne:ue}=ie({queue:r,rows:H,selected:b,setSelected:S,refetch:B}),Q={promote:e=>k(e.state).promote},$=H.filter(e=>b.has(e.id)),de={promote:$.some(Q.promote)};return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(y,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!r&&V!=null&&!R&&!T&&!N,actions:(0,j.jsxs)(m,{size:`sm`,disabled:!V||H.length===0,onClick:()=>{if(H.length===0){s.info(`No jobs to export on this page`);return}let e=H.map(e=>({id:e.id,name:e.name??`default`,queue:e.queue??r,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));te(`jobs-${r}-${a}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,j.jsx)(l,{className:`size-3.5`}),` Export CSV`]})}),T&&(0,j.jsx)(h,{onRetry:D,message:w?`Queue inventory refresh failed — showing the last successful queue totals. ${T.message}`:`Could not discover queues — ${T.message}. Select an existing queue from the URL or retry.`}),N&&(0,j.jsx)(h,{onRetry:P,message:O?`Server-wide totals refresh failed — showing the last successful totals. ${N.message}`:`Server-wide job totals are unavailable — ${N.message}. The selected queue page may still be current.`}),(0,j.jsx)(ne,{total:U&&W!=null?C(U.completed+W+U.waiting+U.prioritized+U.active+U.delayed+U[`waiting-children`]):`—`,waiting:K(U?.waiting),prioritized:K(U?.prioritized),active:K(U?.active),flowBlocked:K(U?.[`waiting-children`]),completed:K(U?.completed),failed:W==null?`—`:C(W),failedCount:W,errorRate:G==null?`—`:x(G),errorRateTone:G==null?`default`:G>.05?`red`:`green`}),(0,j.jsx)(I,{queue:r,summary:w??[],status:a,search:u,selectedTotal:b.size,selectedVisible:$.length,canPromote:de.promote,bulkBusy:Z,onQueue:e=>{i(e),q(),J(e,a)},onStatus:e=>{c(e),q(),J(r,e)},onSearch:d,onPromote:()=>le(`Promote`,e=>o.promoteJob(e.id),Q.promote)}),X&&(0,j.jsx)(`div`,{role:`status`,className:`mb-3 text-sm ${X.ok?`text-success`:`text-danger`}`,children:X.text}),R&&V&&(0,j.jsx)(h,{message:`Job refresh failed — showing the last successful page.`,onRetry:B}),R&&!V?(0,j.jsx)(g,{error:R,onRetry:B}):E&&!w&&!r&&!T?(0,j.jsx)(_,{label:`Discovering queues…`}):z&&!V?(0,j.jsx)(_,{label:`Loading jobs…`}):(0,j.jsx)(re,{queue:r,rows:H,search:u,discoveryError:!!T,selected:b,allSelected:Y,bulkBusy:Z,busyIds:ce,page:p,hasNext:ae,onToggleAll:se,onToggle:oe,onRun:(e,t,n)=>void ue(e,t,n),onPage:v})]})}export{L as JobsPro};
@@ -1 +1 @@
1
- import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{T as r,h as i}from"./icons-BVzwsfbG.js";import{n as a}from"./usePolledData-0CVelkl2.js";import{i as o,t as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./StatusBadge-BoOVTnKu.js";import{t as l}from"./PageHeader-CvIyaFOO.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{n as f,t as p}from"./index-mID5W7vq.js";import{a as m,i as h}from"./form-C4oby9pI.js";import{t as g}from"./Pagination-x-Cwgrul.js";import{t as _}from"./Jobs-BTMpbAHD.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;async function C(){let e=await _();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!Number.isSafeInteger(e.waiting)||e.waiting<0||!Number.isSafeInteger(e.delayed)||e.delayed<0||!Number.isSafeInteger(e.active)||e.active<0||!Number.isSafeInteger(e.dlq)||e.dlq<0||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function w(){let[e,t]=(0,v.useState)(b),[n,_]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O,error:k,refetch:A}=a(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=p(e===b?void 0:e),I=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return j.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[j,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let L=Math.max(1,Math.ceil(I.length/S)),R=Math.min(E,L-1);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(o,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(o,{message:`Event stream unavailable — ${F.message}. Retrying…`}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total Events`,value:d(M.total),compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:d(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:d(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:d(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:d(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Throughput`,value:`${N.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(m,{value:e,"aria-label":`Filter by queue`,name:`classic-activity-queue-filter`,autoComplete:`off`,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(h,{options:x,value:n,onChange:_}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{"aria-label":`Search by job name or ID`,name:`classic-activity-search`,autoComplete:`off`,value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),I.length===0?(0,y.jsx)(s,{icon:(0,y.jsx)(i,{}),title:F?`Event stream unavailable`:P?`Waiting for activity…`:`Connecting to the event stream…`,hint:F?`${F.message}. The dashboard is retrying automatically.`:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:I.slice(R*S,R*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(c,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{T as r,h as i}from"./icons-BVzwsfbG.js";import{n as a}from"./usePolledData-0CVelkl2.js";import{i as o,t as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./StatusBadge-BoOVTnKu.js";import{t as l}from"./PageHeader-CvIyaFOO.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{n as f,t as p}from"./index-BFW2_47n.js";import{a as m,i as h}from"./form-C4oby9pI.js";import{t as g}from"./Pagination-x-Cwgrul.js";import{t as _}from"./Jobs-ELSH1Wbd.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;async function C(){let e=await _();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!Number.isSafeInteger(e.waiting)||e.waiting<0||!Number.isSafeInteger(e.delayed)||e.delayed<0||!Number.isSafeInteger(e.active)||e.active<0||!Number.isSafeInteger(e.dlq)||e.dlq<0||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function w(){let[e,t]=(0,v.useState)(b),[n,_]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O,error:k,refetch:A}=a(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=p(e===b?void 0:e),I=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return j.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[j,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let L=Math.max(1,Math.ceil(I.length/S)),R=Math.min(E,L-1);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(o,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(o,{message:`Event stream unavailable — ${F.message}. Retrying…`}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total Events`,value:d(M.total),compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:d(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:d(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:d(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:d(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Throughput`,value:`${N.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(m,{value:e,"aria-label":`Filter by queue`,name:`classic-activity-queue-filter`,autoComplete:`off`,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(h,{options:x,value:n,onChange:_}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{"aria-label":`Search by job name or ID`,name:`classic-activity-search`,autoComplete:`off`,value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),I.length===0?(0,y.jsx)(s,{icon:(0,y.jsx)(i,{}),title:F?`Event stream unavailable`:P?`Waiting for activity…`:`Connecting to the event stream…`,hint:F?`${F.message}. The dashboard is retrying automatically.`:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:I.slice(R*S,R*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(c,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
@@ -1 +1 @@
1
- import{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-CvwrP0tU.js";import{o as i}from"./connectionStore-BJLihGaC.js";import{T as a}from"./icons-BVzwsfbG.js";import{n as o}from"./usePolledData-0CVelkl2.js";import{t as s}from"./Button-Ch1W94fJ.js";import{i as c}from"./feedback-QDN1AsYt.js";import{t as l}from"./StatusBadge-BoOVTnKu.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,n as m,t as h}from"./index-mID5W7vq.js";import{a as g,i as _}from"./form-C4oby9pI.js";import{t as v}from"./Pagination-x-Cwgrul.js";import{t as y}from"./QueueControl-BW0XXd0B.js";var b=e(t(),1),x=r(),S=`__all__`,C=[`all`,`waiting`,`active`,`completed`,`failed`],w=10,T=250;function E(){let[e,t]=(0,b.useState)(S),[r,E]=(0,b.useState)(`all`),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0),[j,M]=(0,b.useState)(null),N=j!==null,P=i(t=>JSON.stringify([t.baseUrl,t.token,e])),{data:F,error:I,refetch:L}=o(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=h(e===S?void 0:e),U=(0,b.useMemo)(()=>{let e=j??R,t=D.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[R,j,r,D]),W=N?Math.max(0,(R[0]?.seq??0)-(j[0]?.seq??0)):0;(0,b.useEffect)(()=>A(0),[e,r,D]),(0,b.useEffect)(()=>M(null),[P]);let G=k*w,K=U.slice(G,G+w);return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:V&&!N}),I&&(0,x.jsx)(c,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(c,{message:`Event stream unavailable — ${H.message}. Retrying…`}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,x.jsx)(m,{label:`Total Events`,value:f(z.total),compact:!0}),(0,x.jsx)(m,{label:`Completed`,value:f(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(m,{label:`Failed`,value:f(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(m,{label:`Waiting`,value:f(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(m,{label:`Active`,value:f(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(m,{label:`Throughput`,value:`${B.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(g,{"aria-label":`Filter by queue`,name:`activity-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),children:[(0,x.jsx)(`option`,{value:S,children:`All Queues`}),(F?.queues??[]).map(e=>(0,x.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,x.jsx)(_,{options:C,value:r,onChange:E}),(0,x.jsx)(s,{size:`sm`,variant:N?`warning`:`default`,onClick:()=>M(N?null:R),title:N?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:N?`Resume${W?` — ${f(W)} new`:``}`:`Following · Pause`}),(0,x.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,x.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{"aria-label":`Search by job ID or queue`,name:`activity-search`,autoComplete:`off`,value:D,onChange:e=>O(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,x.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,T,` streamed events held in this browser.`]}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,x.jsx)(`tbody`,{children:K.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:H?`Event stream unavailable — ${H.message}. Retrying…`:V?R.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):K.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(l,{status:e.status})}),(0,x.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:d(e.timestamp)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,x.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,x.jsx)(p,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,x.jsx)(v,{page:k,pageSize:w,total:U.length,onPageChange:A,label:`events`})]})}export{E as LogsPro};
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-CvwrP0tU.js";import{o as i}from"./connectionStore-BJLihGaC.js";import{T as a}from"./icons-BVzwsfbG.js";import{n as o}from"./usePolledData-0CVelkl2.js";import{t as s}from"./Button-Ch1W94fJ.js";import{i as c}from"./feedback-QDN1AsYt.js";import{t as l}from"./StatusBadge-BoOVTnKu.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,n as m,t as h}from"./index-BFW2_47n.js";import{a as g,i as _}from"./form-C4oby9pI.js";import{t as v}from"./Pagination-x-Cwgrul.js";import{t as y}from"./QueueControl-Bvm8GUQa.js";var b=e(t(),1),x=r(),S=`__all__`,C=[`all`,`waiting`,`active`,`completed`,`failed`],w=10,T=250;function E(){let[e,t]=(0,b.useState)(S),[r,E]=(0,b.useState)(`all`),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0),[j,M]=(0,b.useState)(null),N=j!==null,P=i(t=>JSON.stringify([t.baseUrl,t.token,e])),{data:F,error:I,refetch:L}=o(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=h(e===S?void 0:e),U=(0,b.useMemo)(()=>{let e=j??R,t=D.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[R,j,r,D]),W=N?Math.max(0,(R[0]?.seq??0)-(j[0]?.seq??0)):0;(0,b.useEffect)(()=>A(0),[e,r,D]),(0,b.useEffect)(()=>M(null),[P]);let G=k*w,K=U.slice(G,G+w);return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:V&&!N}),I&&(0,x.jsx)(c,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(c,{message:`Event stream unavailable — ${H.message}. Retrying…`}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,x.jsx)(m,{label:`Total Events`,value:f(z.total),compact:!0}),(0,x.jsx)(m,{label:`Completed`,value:f(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(m,{label:`Failed`,value:f(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(m,{label:`Waiting`,value:f(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(m,{label:`Active`,value:f(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(m,{label:`Throughput`,value:`${B.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(g,{"aria-label":`Filter by queue`,name:`activity-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),children:[(0,x.jsx)(`option`,{value:S,children:`All Queues`}),(F?.queues??[]).map(e=>(0,x.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,x.jsx)(_,{options:C,value:r,onChange:E}),(0,x.jsx)(s,{size:`sm`,variant:N?`warning`:`default`,onClick:()=>M(N?null:R),title:N?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:N?`Resume${W?` — ${f(W)} new`:``}`:`Following · Pause`}),(0,x.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,x.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{"aria-label":`Search by job ID or queue`,name:`activity-search`,autoComplete:`off`,value:D,onChange:e=>O(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,x.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,T,` streamed events held in this browser.`]}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,x.jsx)(`tbody`,{children:K.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:H?`Event stream unavailable — ${H.message}. Retrying…`:V?R.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):K.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(l,{status:e.status})}),(0,x.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:d(e.timestamp)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,x.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,x.jsx)(p,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,x.jsx)(v,{page:k,pageSize:w,total:U.length,onPageChange:A,label:`events`})]})}export{E as LogsPro};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./react-vendor-CvwrP0tU.js";import{n as t,t as n}from"./Card-CWxrC8OY.js";import{t as r}from"./PageHeader-CvIyaFOO.js";import{a as i,n as a}from"./index-mID5W7vq.js";var o=e(),s=`{
1
+ import{t as e}from"./react-vendor-CvwrP0tU.js";import{n as t,t as n}from"./Card-CWxrC8OY.js";import{t as r}from"./PageHeader-CvIyaFOO.js";import{a as i,n as a}from"./index-BFW2_47n.js";var o=e(),s=`{
2
2
  "mcpServers": {
3
3
  "bunqueue": {
4
4
  "command": "bunx",
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-CvwrP0tU.js";import{t}from"./api-BgWE-705.js";import{n}from"./usePolledData-0CVelkl2.js";import{n as r,t as i}from"./Card-CWxrC8OY.js";import{i as a,n as o,r as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./PageHeader-CvIyaFOO.js";import{n as l,s as u}from"./format-Cg7VCIZW.js";import{n as d}from"./index-mID5W7vq.js";var f=e(),p={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function m(){let{data:e,error:m,loading:_,refetch:v}=n(()=>t.overview(),[]);if(_&&!e&&!m)return(0,f.jsx)(s,{label:`Loading metrics…`});if(m&&!e)return(0,f.jsxs)(`div`,{children:[(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`}),(0,f.jsx)(o,{error:m,onRetry:v})]});let{stats:y,throughput:b,latency:x,memory:S,collections:C}=e??p,w={};for(let[e,t]of Object.entries(x.percentiles??{}))t&&typeof t==`object`&&(w[`${e} p50`]=t.p50,w[`${e} p95`]=t.p95,w[`${e} p99`]=t.p99);return(0,f.jsxs)(`div`,{children:[m&&(0,f.jsx)(a,{message:`Metrics refresh failed — showing the last successful snapshot.`,onRetry:v}),(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!!e&&!m}),(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,f.jsx)(d,{label:`Pushed /s`,value:b.pushPerSec.toFixed(1),compact:!0}),(0,f.jsx)(d,{label:`Pulled /s`,value:b.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,f.jsx)(d,{label:`Completed /s`,value:b.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,f.jsx)(d,{label:`Failed /s`,value:b.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,f.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Totals`}),(0,f.jsx)(h,{rows:[[`Pushed`,u(y.totalPushed)],[`Pulled`,u(y.totalPulled)],[`Completed`,u(y.totalCompleted)],[`Failed`,u(y.totalFailed)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Memory`}),(0,f.jsx)(h,{rows:[[`Heap Used`,l(S.heapUsed*1024*1024)],[`Heap Total`,l(S.heapTotal*1024*1024)],[`RSS`,l(S.rss*1024*1024)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — percentiles (ms)`}),(0,f.jsx)(g,{record:w,suffix:`ms`})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — averages (ms)`}),(0,f.jsx)(g,{record:x.averages,suffix:`ms`})]})]}),(0,f.jsx)(`div`,{className:`mt-6`,children:(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`In-memory collections`}),(0,f.jsx)(g,{record:C})]})})]})}function h({rows:e}){return(0,f.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,f.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function g({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,f.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,f.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,f.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,f.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,f.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?u(Math.round(n*100)/100):String(n),t&&(0,f.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{m as Metrics};
1
+ import{t as e}from"./react-vendor-CvwrP0tU.js";import{t}from"./api-BgWE-705.js";import{n}from"./usePolledData-0CVelkl2.js";import{n as r,t as i}from"./Card-CWxrC8OY.js";import{i as a,n as o,r as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./PageHeader-CvIyaFOO.js";import{n as l,s as u}from"./format-Cg7VCIZW.js";import{n as d}from"./index-BFW2_47n.js";var f=e(),p={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function m(){let{data:e,error:m,loading:_,refetch:v}=n(()=>t.overview(),[]);if(_&&!e&&!m)return(0,f.jsx)(s,{label:`Loading metrics…`});if(m&&!e)return(0,f.jsxs)(`div`,{children:[(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`}),(0,f.jsx)(o,{error:m,onRetry:v})]});let{stats:y,throughput:b,latency:x,memory:S,collections:C}=e??p,w={};for(let[e,t]of Object.entries(x.percentiles??{}))t&&typeof t==`object`&&(w[`${e} p50`]=t.p50,w[`${e} p95`]=t.p95,w[`${e} p99`]=t.p99);return(0,f.jsxs)(`div`,{children:[m&&(0,f.jsx)(a,{message:`Metrics refresh failed — showing the last successful snapshot.`,onRetry:v}),(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!!e&&!m}),(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,f.jsx)(d,{label:`Pushed /s`,value:b.pushPerSec.toFixed(1),compact:!0}),(0,f.jsx)(d,{label:`Pulled /s`,value:b.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,f.jsx)(d,{label:`Completed /s`,value:b.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,f.jsx)(d,{label:`Failed /s`,value:b.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,f.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Totals`}),(0,f.jsx)(h,{rows:[[`Pushed`,u(y.totalPushed)],[`Pulled`,u(y.totalPulled)],[`Completed`,u(y.totalCompleted)],[`Failed`,u(y.totalFailed)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Memory`}),(0,f.jsx)(h,{rows:[[`Heap Used`,l(S.heapUsed*1024*1024)],[`Heap Total`,l(S.heapTotal*1024*1024)],[`RSS`,l(S.rss*1024*1024)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — percentiles (ms)`}),(0,f.jsx)(g,{record:w,suffix:`ms`})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — averages (ms)`}),(0,f.jsx)(g,{record:x.averages,suffix:`ms`})]})]}),(0,f.jsx)(`div`,{className:`mt-6`,children:(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`In-memory collections`}),(0,f.jsx)(g,{record:C})]})})]})}function h({rows:e}){return(0,f.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,f.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function g({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,f.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,f.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,f.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,f.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,f.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?u(Math.round(n*100)/100):String(n),t&&(0,f.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{m as Metrics};
@@ -1 +1 @@
1
- import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-F5BbTG1T.js";import{n as a}from"./usePolledData-0CVelkl2.js";import{n as o,t as s}from"./Card-CWxrC8OY.js";import{i as c,r as l,t as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./PageHeader-CvIyaFOO.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{n as _}from"./index-mID5W7vq.js";import{t as v}from"./Pagination-x-Cwgrul.js";import{t as y}from"./AreaChart-DEAalJ6P.js";import{n as b,t as x}from"./useThroughputSeries-DgO8uicf.js";var S=e(n(),1),C=r();function w({rate:e,stats:t}){return(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsx)(T,{value:e==null?`—`:f(e),label:`error rate`,danger:e!=null&&e>.05}),(0,C.jsx)(T,{value:e==null?`—`:f(1-e),label:`success rate`,success:e!=null})]}),e==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-e)*100}%`}})})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(E,{color:`bg-blue-400`,label:`Standard waiting`,value:t?m(t.waiting):`—`}),(0,C.jsx)(E,{color:`bg-accent`,label:`Processing`,value:t?m(t.active):`—`}),(0,C.jsx)(E,{color:`bg-amber-400`,label:`Delayed`,value:t?m(t.delayed):`—`}),(0,C.jsx)(E,{color:`bg-red-400`,label:`Dead Letter`,value:t?m(t.dlq):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:t?p(t.totalPushed):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:t?p(t.totalPulled):`—`}),(0,C.jsx)(E,{color:`bg-emerald-400`,label:`Uptime`,value:t?g(t.uptime/1e3):`—`})]})]})]})}function T({value:e,label:n,danger:r,success:i}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,r?`text-danger`:i?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:n})]})}function E({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}var D=[`push`,`pull`,`ack`],O=100;function k({latency:e}){return(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:D.map(n=>{let r=e?.percentiles?.[n],i=e?.averages?.[`${n}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:n}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(i)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(r?.p99??0)>O?`text-warning`:`text-muted`),children:j(r?.p99)})]},n)})})]})})]})}function A({rows:e,total:n,page:r,pageSize:i,onPage:a,empty:o}){return(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:e.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:o})}):e.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:m(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:m(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:r,pageSize:i,total:n,onPageChange:a,label:`queues`})})]})}function j(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}var M=[`-60s`,`-45s`,`-30s`,`-15s`,`now`];function N({series:e}){let n=e.latest?.throughput,r=x(e.depth),i=e.depth.length?e.depth[e.depth.length-1]:null,a=t=>e.error?(0,C.jsx)(u,{title:`${t} unavailable`,hint:e.error.message}):(0,C.jsx)(l,{label:`Connecting ${t.toLowerCase()}…`});return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),n&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(P,{color:`#ec4899`,label:`Pushed`,value:n.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:n.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:n.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):a(`Live throughput`)]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:i==null?`—`:m(i)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,r.label===`draining`?`text-success`:r.label===`accumulating`?`text-danger`:`text-faint`),children:i==null?`unavailable`:r.label===`steady`?`steady`:`${r.slope>0?`+`:``}${r.slope.toFixed(1)}/s · ${r.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:r.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):a(`Queue depth`)]})]})}function P({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}var F=15,I=[];function L(){let e=b(60),[t,n]=(0,S.useState)(0),{data:r,error:o,loading:s,refetch:l}=a(async()=>({details:await i.queuesSummary()}),[]),u=r?.details??I,f=Math.max(1,Math.ceil(u.length/F)),g=Math.min(t,f-1),v=(0,S.useMemo)(()=>u.slice(g*F,g*F+F),[u,g]),y=(0,S.useMemo)(()=>r?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[r,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!r&&!o,j=!!e.latest&&!e.error&&!!r&&!o,M=o&&!r?`Queue metrics unavailable — ${o.message}`:O?`Loading queue metrics…`:`No queues yet.`;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(d,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:j}),o&&(0,C.jsx)(c,{message:`Queue metrics unavailable — ${o.message}`,onRetry:l}),e.error&&(0,C.jsx)(c,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),O&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),!e.latest&&!e.error&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(_,{label:`Total Completed`,value:x?p(x.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Total Failed`,value:y==null?`—`:m(y),tone:y?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Push/sec`,value:T?T.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(_,{label:`Pull/sec`,value:T?T.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsx)(N,{series:e}),(0,C.jsx)(w,{rate:D,stats:x}),(0,C.jsx)(k,{latency:E}),(0,C.jsx)(A,{rows:v,total:u.length,page:g,pageSize:F,onPage:n,empty:M})]})}export{L as MetricsPro};
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-F5BbTG1T.js";import{n as a}from"./usePolledData-0CVelkl2.js";import{n as o,t as s}from"./Card-CWxrC8OY.js";import{i as c,r as l,t as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./PageHeader-CvIyaFOO.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{n as _}from"./index-BFW2_47n.js";import{t as v}from"./Pagination-x-Cwgrul.js";import{t as y}from"./AreaChart-DEAalJ6P.js";import{n as b,t as x}from"./useThroughputSeries-DgO8uicf.js";var S=e(n(),1),C=r();function w({rate:e,stats:t}){return(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsx)(T,{value:e==null?`—`:f(e),label:`error rate`,danger:e!=null&&e>.05}),(0,C.jsx)(T,{value:e==null?`—`:f(1-e),label:`success rate`,success:e!=null})]}),e==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-e)*100}%`}})})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(E,{color:`bg-blue-400`,label:`Standard waiting`,value:t?m(t.waiting):`—`}),(0,C.jsx)(E,{color:`bg-accent`,label:`Processing`,value:t?m(t.active):`—`}),(0,C.jsx)(E,{color:`bg-amber-400`,label:`Delayed`,value:t?m(t.delayed):`—`}),(0,C.jsx)(E,{color:`bg-red-400`,label:`Dead Letter`,value:t?m(t.dlq):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:t?p(t.totalPushed):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:t?p(t.totalPulled):`—`}),(0,C.jsx)(E,{color:`bg-emerald-400`,label:`Uptime`,value:t?g(t.uptime/1e3):`—`})]})]})]})}function T({value:e,label:n,danger:r,success:i}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,r?`text-danger`:i?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:n})]})}function E({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}var D=[`push`,`pull`,`ack`],O=100;function k({latency:e}){return(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:D.map(n=>{let r=e?.percentiles?.[n],i=e?.averages?.[`${n}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:n}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(i)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(r?.p99??0)>O?`text-warning`:`text-muted`),children:j(r?.p99)})]},n)})})]})})]})}function A({rows:e,total:n,page:r,pageSize:i,onPage:a,empty:o}){return(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:e.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:o})}):e.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:m(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:m(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:r,pageSize:i,total:n,onPageChange:a,label:`queues`})})]})}function j(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}var M=[`-60s`,`-45s`,`-30s`,`-15s`,`now`];function N({series:e}){let n=e.latest?.throughput,r=x(e.depth),i=e.depth.length?e.depth[e.depth.length-1]:null,a=t=>e.error?(0,C.jsx)(u,{title:`${t} unavailable`,hint:e.error.message}):(0,C.jsx)(l,{label:`Connecting ${t.toLowerCase()}…`});return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),n&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(P,{color:`#ec4899`,label:`Pushed`,value:n.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:n.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:n.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):a(`Live throughput`)]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:i==null?`—`:m(i)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,r.label===`draining`?`text-success`:r.label===`accumulating`?`text-danger`:`text-faint`),children:i==null?`unavailable`:r.label===`steady`?`steady`:`${r.slope>0?`+`:``}${r.slope.toFixed(1)}/s · ${r.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:r.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):a(`Queue depth`)]})]})}function P({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}var F=15,I=[];function L(){let e=b(60),[t,n]=(0,S.useState)(0),{data:r,error:o,loading:s,refetch:l}=a(async()=>({details:await i.queuesSummary()}),[]),u=r?.details??I,f=Math.max(1,Math.ceil(u.length/F)),g=Math.min(t,f-1),v=(0,S.useMemo)(()=>u.slice(g*F,g*F+F),[u,g]),y=(0,S.useMemo)(()=>r?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[r,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!r&&!o,j=!!e.latest&&!e.error&&!!r&&!o,M=o&&!r?`Queue metrics unavailable — ${o.message}`:O?`Loading queue metrics…`:`No queues yet.`;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(d,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:j}),o&&(0,C.jsx)(c,{message:`Queue metrics unavailable — ${o.message}`,onRetry:l}),e.error&&(0,C.jsx)(c,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),O&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),!e.latest&&!e.error&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(_,{label:`Total Completed`,value:x?p(x.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Total Failed`,value:y==null?`—`:m(y),tone:y?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Push/sec`,value:T?T.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(_,{label:`Pull/sec`,value:T?T.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsx)(N,{series:e}),(0,C.jsx)(w,{rate:D,stats:x}),(0,C.jsx)(k,{latency:E}),(0,C.jsx)(A,{rows:v,total:u.length,page:g,pageSize:F,onPage:n,empty:M})]})}export{L as MetricsPro};
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-CvwrP0tU.js";import{A as t,c as n}from"./icons-BVzwsfbG.js";import{t as r}from"./api-BgWE-705.js";import{n as i}from"./usePolledData-0CVelkl2.js";import{n as a,t as o}from"./Card-CWxrC8OY.js";import{i as s,n as c,r as l}from"./feedback-QDN1AsYt.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{c as d,n as f,s as p,t as m,u as h}from"./format-Cg7VCIZW.js";import{n as g}from"./index-mID5W7vq.js";var _=e(),v={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function y(){let{data:e,error:y,loading:S,refetch:C}=i(()=>r.overview(),[]);if(S&&!e&&!y)return(0,_.jsx)(l,{label:`Loading overview…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`}),(0,_.jsx)(c,{error:y,onRetry:C})]});let{stats:w,throughput:T,memory:E,workers:D,crons:O,storage:k}=e??v,A=m(w.totalCompleted,w.totalFailed)??0,j=typeof k.diskFull==`boolean`;return(0,_.jsxs)(`div`,{children:[y&&(0,_.jsx)(s,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:C}),(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!!e&&!y&&j}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(g,{label:`Waiting`,value:p(w.waiting),tone:`amber`}),(0,_.jsx)(g,{label:`Active`,value:p(w.active),tone:`blue`}),(0,_.jsx)(g,{label:`Completed`,value:p(w.totalCompleted),tone:`green`}),(0,_.jsx)(g,{label:`Failed`,value:p(w.totalFailed),tone:`red`}),(0,_.jsx)(g,{label:`DLQ`,value:p(w.dlq),tone:w.dlq>0?`red`:`default`}),(0,_.jsx)(g,{label:`Error Rate`,value:d(A),tone:A>.05?`red`:`green`})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Throughput`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(b,{label:`Pushed`,value:T.pushPerSec,tone:`text-fg`}),(0,_.jsx)(b,{label:`Pulled`,value:T.pullPerSec,tone:`text-blue-400`}),(0,_.jsx)(b,{label:`Completed`,value:T.completePerSec,tone:`text-emerald-400`}),(0,_.jsx)(b,{label:`Failed`,value:T.failPerSec,tone:`text-red-400`})]})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Resources`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(x,{label:`Uptime`,value:h(w.uptime/1e3)}),(0,_.jsx)(x,{label:`Heap`,value:f(E.heapUsed*1024*1024)}),(0,_.jsx)(x,{label:`RSS`,value:f(E.rss*1024*1024)}),(0,_.jsx)(x,{label:`Storage`,value:j?k.diskFull?`Disk full`:`Healthy`:`Unavailable`,tone:j?k.diskFull?`text-red-400`:`text-emerald-400`:`text-muted`})]})]})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Workers`,icon:(0,_.jsx)(t,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,_.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:D.active}),` /`,` `,D.total,` active`]})}),D.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,_.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,p(e.processedJobs),` done`]})]},e.id))})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Cron Jobs`,icon:(0,_.jsx)(n,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[O.total,` scheduled`]})}),O.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:O.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,_.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function b({label:e,value:t,tone:n}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,_.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function x({label:e,value:t,tone:n=`text-fg`}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{y as Overview};
1
+ import{t as e}from"./react-vendor-CvwrP0tU.js";import{A as t,c as n}from"./icons-BVzwsfbG.js";import{t as r}from"./api-BgWE-705.js";import{n as i}from"./usePolledData-0CVelkl2.js";import{n as a,t as o}from"./Card-CWxrC8OY.js";import{i as s,n as c,r as l}from"./feedback-QDN1AsYt.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{c as d,n as f,s as p,t as m,u as h}from"./format-Cg7VCIZW.js";import{n as g}from"./index-BFW2_47n.js";var _=e(),v={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function y(){let{data:e,error:y,loading:S,refetch:C}=i(()=>r.overview(),[]);if(S&&!e&&!y)return(0,_.jsx)(l,{label:`Loading overview…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`}),(0,_.jsx)(c,{error:y,onRetry:C})]});let{stats:w,throughput:T,memory:E,workers:D,crons:O,storage:k}=e??v,A=m(w.totalCompleted,w.totalFailed)??0,j=typeof k.diskFull==`boolean`;return(0,_.jsxs)(`div`,{children:[y&&(0,_.jsx)(s,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:C}),(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!!e&&!y&&j}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(g,{label:`Waiting`,value:p(w.waiting),tone:`amber`}),(0,_.jsx)(g,{label:`Active`,value:p(w.active),tone:`blue`}),(0,_.jsx)(g,{label:`Completed`,value:p(w.totalCompleted),tone:`green`}),(0,_.jsx)(g,{label:`Failed`,value:p(w.totalFailed),tone:`red`}),(0,_.jsx)(g,{label:`DLQ`,value:p(w.dlq),tone:w.dlq>0?`red`:`default`}),(0,_.jsx)(g,{label:`Error Rate`,value:d(A),tone:A>.05?`red`:`green`})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Throughput`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(b,{label:`Pushed`,value:T.pushPerSec,tone:`text-fg`}),(0,_.jsx)(b,{label:`Pulled`,value:T.pullPerSec,tone:`text-blue-400`}),(0,_.jsx)(b,{label:`Completed`,value:T.completePerSec,tone:`text-emerald-400`}),(0,_.jsx)(b,{label:`Failed`,value:T.failPerSec,tone:`text-red-400`})]})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Resources`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(x,{label:`Uptime`,value:h(w.uptime/1e3)}),(0,_.jsx)(x,{label:`Heap`,value:f(E.heapUsed*1024*1024)}),(0,_.jsx)(x,{label:`RSS`,value:f(E.rss*1024*1024)}),(0,_.jsx)(x,{label:`Storage`,value:j?k.diskFull?`Disk full`:`Healthy`:`Unavailable`,tone:j?k.diskFull?`text-red-400`:`text-emerald-400`:`text-muted`})]})]})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Workers`,icon:(0,_.jsx)(t,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,_.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:D.active}),` /`,` `,D.total,` active`]})}),D.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,_.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,p(e.processedJobs),` done`]})]},e.id))})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Cron Jobs`,icon:(0,_.jsx)(n,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[O.total,` scheduled`]})}),O.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:O.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,_.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function b({label:e,value:t,tone:n}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,_.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function x({label:e,value:t,tone:n=`text-fg`}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{y as Overview};
@@ -1 +1 @@
1
- import{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-F5BbTG1T.js";import{n as a}from"./usePolledData-0CVelkl2.js";import{t as o}from"./Button-Ch1W94fJ.js";import{n as s,t as c}from"./Card-CWxrC8OY.js";import{i as l,n as u,r as d}from"./feedback-QDN1AsYt.js";import{n as f}from"./StatusBadge-BoOVTnKu.js";import{t as p}from"./PageHeader-CvIyaFOO.js";import{s as m}from"./format-Cg7VCIZW.js";import{n as h}from"./index-mID5W7vq.js";import{a as g,n as _,t as v}from"./form-C4oby9pI.js";import{r as y}from"./useServerActionGuard-uGePilQQ.js";import{t as b}from"./controlConnectionEpoch-CZsS0wAb.js";import{t as x}from"./useControlActionGuard-B-bzKZKI.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./QueueActions-BWnmNEqV.js";var k=e(t(),1),A={limits:async(e,t)=>P(await i.queueOperations.limits(e,t)),group:async(e,t,n,r,a,o)=>j(await i.queueOperations.group(e,t,n,r,a,o)),pauseGroup:async(e,t)=>M(await i.queueOperations.pauseGroup(e,t)),resumeGroup:async(e,t)=>M(await i.queueOperations.resumeGroup(e,t)),setGroupRateLimit:async(e,t,n,r)=>{N(await i.queueOperations.setGroupRateLimit(e,t,n,r))},removeGroupRateLimit:async(e,t)=>I(await i.queueOperations.removeGroupRateLimit(e,t)),setGroupConcurrency:async(e,t,n)=>{N(await i.queueOperations.setGroupConcurrency(e,t,n))},removeGroupConcurrency:async(e,t)=>I(await i.queueOperations.removeGroupConcurrency(e,t)),deduplicationJobId:async(e,t)=>F(await i.queueOperations.deduplicationJobId(e,t)),removeDeduplicationKey:async(e,t)=>I(await i.queueOperations.removeDeduplicationKey(e,t)),metrics:async(e,t,n,r)=>te(await i.queueOperations.metrics(e,t,n,r)),trimEvents:async(e,t)=>I(await i.queueOperations.trimEvents(e,t))};function j(e){let t=R(L(e,`Queue group`).group,`Queue group`),n=t.rateLimit,r=t.entries,i=t.priorityCounts;if(!V(t.jobs,0)||!V(t.active,0)||!V(t.totalGrouped,0)||typeof t.paused!=`boolean`||!Array.isArray(r)||r.length>100||!r.every(ee)||!z(i)||!Object.entries(i).every(([e,t])=>/^\d+$/.test(e)&&Number(e)<=2097151&&V(t,0))||n!==null&&(!z(n)||!B(n.max)||!B(n.duration))||!V(t.rateLimitTtl,-2)||t.concurrency!==null&&!B(t.concurrency))throw H(`Queue group`);return t}function ee(e){return z(e)?typeof e.id==`string`&&e.id.length>0&&typeof e.name==`string`&&e.name.length>0&&V(e.priority,0)&&e.priority<=2097151&&V(e.delay,0)&&V(e.timestamp,0):!1}function M(e){let t=L(e,`Queue group mutation`).changed;if(typeof t!=`boolean`)throw H(`Queue group mutation`);return t}function N(e){if(L(e,`Queue mutation`).applied!==!0)throw H(`Queue mutation`)}function P(e){let t=R(L(e,`Queue limits`).limits,`Queue limits`),n=t.rateLimit;if(n!==null&&(!z(n)||!B(n.max)||!B(n.duration))||t.concurrency!==null&&!B(t.concurrency)||!V(t.rateLimitTtl,-2)||typeof t.maxed!=`boolean`)throw H(`Queue limits`);return{rateLimit:n,concurrency:t.concurrency,rateLimitTtl:t.rateLimitTtl,maxed:t.maxed}}function F(e){let t=L(e,`deduplication lookup`).jobId;if(t!==null&&(typeof t!=`string`||!t))throw H(`deduplication lookup`);return t}function I(e){let t=L(e,`Queue mutation`).removed;if(!V(t,0))throw H(`Queue mutation`);return t}function te(e){let t=R(L(e,`Queue metrics`).metrics,`Queue metrics`),n=R(t.meta,`Queue metrics`);if(!V(n.count,0)||!V(n.prevTS,0)||!V(n.prevCount,0)||!V(t.count,0)||!Array.isArray(t.data)||t.data.length>10001||!t.data.every(e=>V(e,0)))throw H(`Queue metrics`);return t}function L(e,t){let n=R(e,t);if(n.ok!==!0)throw H(t);return n}function R(e,t){if(!z(e))throw H(t);return e}function z(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var B=e=>V(e,1),V=(e,t)=>Number.isSafeInteger(e)&&e>=t,H=e=>Error(`Malformed ${e} response`),U=r();function ne({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(``),[s,c]=(0,k.useState)(),[l,u]=(0,k.useState)(``),d=i.length>0&&i.length<=1024;return(0,U.jsxs)(`section`,{"aria-labelledby":`queue-dedup-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,U.jsx)(`h3`,{id:`queue-dedup-title`,className:`text-sm font-semibold text-fg`,children:`Deduplication registry`}),(0,U.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Resolve an official deduplication ID to its current job, or release only the registry key.`}),(0,U.jsx)(v,{label:`Deduplication ID`,children:(0,U.jsx)(_,{name:`queue-sdk-deduplication-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:i,onChange:e=>{a(e.target.value),c(void 0),u(``)}})}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsx)(o,{size:`sm`,disabled:!d||!!n,onClick:()=>r(`Looking up deduplication key`,()=>t.deduplicationJobId(e,i),c),children:`Find owner`}),(0,U.jsx)(o,{variant:`warning`,size:`sm`,disabled:!d||!!n,onClick:()=>{window.confirm(`Remove deduplication key "${i}" from queue "${e}"? The job is not deleted, but a later enqueue may reuse this key.`)&&r(`Removing deduplication key`,()=>t.removeDeduplicationKey(e,i),e=>{u(e?`Deduplication key removed.`:`No matching key was active.`),c(void 0)},!0)},children:`Remove key`})]}),s!==void 0&&(0,U.jsx)(`p`,{role:`status`,className:`mt-3 break-all text-xs text-muted`,children:s===null?`No active owner.`:`Current job: ${s}`}),l&&(0,U.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l})]})}function re({snapshot:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 rounded-lg border border-line p-3 text-xs sm:grid-cols-4 xl:grid-cols-7`,children:[(0,U.jsx)(W,{label:`Jobs`,value:e.jobs}),(0,U.jsx)(W,{label:`Active`,value:e.active}),(0,U.jsx)(W,{label:`All grouped`,value:e.totalGrouped}),(0,U.jsx)(W,{label:`Rate`,value:e.rateLimit?`${e.rateLimit.max}/${e.rateLimit.duration}ms`:`None`}),(0,U.jsx)(W,{label:`TTL`,value:`${e.rateLimitTtl} ms`}),(0,U.jsx)(W,{label:`Concurrency`,value:e.concurrency??`None`}),(0,U.jsx)(W,{label:`Paused`,value:e.paused?`Yes`:`No`}),(0,U.jsx)(W,{label:`Priority counts`,value:ie(e.priorityCounts)})]}),(0,U.jsx)(`div`,{className:`mt-3 overflow-x-auto rounded-lg border border-line`,children:(0,U.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,U.jsx)(`thead`,{className:`border-b border-line text-faint`,children:(0,U.jsxs)(`tr`,{children:[(0,U.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Pending group job`}),(0,U.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Name`}),(0,U.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Priority`}),(0,U.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Delay`})]})}),(0,U.jsx)(`tbody`,{children:e.entries.length===0?(0,U.jsx)(`tr`,{children:(0,U.jsx)(`td`,{colSpan:4,className:`px-3 py-4 text-center text-faint`,children:`No pending jobs in this page.`})}):e.entries.map(e=>(0,U.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,U.jsx)(`td`,{className:`px-3 py-2 font-mono`,children:(0,U.jsx)(n,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect grouped job ${e.id}`,className:`text-accent hover:underline`,children:e.id})}),(0,U.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,U.jsx)(`td`,{className:`px-3 py-2 text-right font-mono`,children:e.priority}),(0,U.jsxs)(`td`,{className:`px-3 py-2 text-right font-mono`,children:[e.delay,` ms`]})]},e.id))})]})})]})}function W({label:e,value:t}){return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`text-faint`,children:e}),(0,U.jsx)(`dd`,{className:`mt-1 font-mono text-fg`,children:t})]})}var ie=e=>{let t=Object.entries(e).sort(([e],[t])=>Number(e)-Number(t));return t.length?t.map(([e,t])=>`${e}: ${t}`).join(` · `):`None`};function ae({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(`default`),[s,c]=(0,k.useState)(``),[l,u]=(0,k.useState)(`100`),[d,f]=(0,k.useState)(`0`),[p,m]=(0,k.useState)(`24`),[h,g]=(0,k.useState)(`100`),[y,b]=(0,k.useState)(`60000`),[x,S]=(0,k.useState)(`1`),[C,w]=(0,k.useState)(null),T=oe(i),E=se(d,p),D=()=>{let n=K(s,0),i=K(l,1);!T||n===null||i===null||!E||r(`Reading group`,()=>t.group(e,T,n,i,E.start,E.end),w)},O=()=>{let n=G(h),i=G(y);!T||n===null||i===null||r(`Setting group rate limit`,async r=>{if(await t.setGroupRateLimit(e,T,n,i),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},w,!0)},A=()=>{let n=G(x);!T||n===null||r(`Setting group concurrency`,async r=>{if(await t.setGroupConcurrency(e,T,n),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},w,!0)},j=n=>{T&&r(n?`Pausing group`:`Resuming group`,async r=>{if(n?await t.pauseGroup(e,T):await t.resumeGroup(e,T),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},w,!0)};return(0,U.jsxs)(`section`,{className:`xl:col-span-2`,"aria-labelledby":`queue-groups-title`,children:[(0,U.jsx)(`h3`,{id:`queue-groups-title`,className:`mb-3 text-sm font-medium text-fg`,children:`Groups`}),(0,U.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4 xl:grid-cols-8`,children:[(0,U.jsx)(v,{label:`Group ID`,children:(0,U.jsx)(_,{value:i,maxLength:256,onChange:e=>a(e.target.value)})}),(0,U.jsx)(v,{label:`TTL maxJobs`,hint:`Optional`,children:(0,U.jsx)(_,{type:`number`,min:0,value:s,onChange:e=>c(e.target.value)})}),(0,U.jsx)(v,{label:`Groups maxCount`,children:(0,U.jsx)(_,{type:`number`,min:1,value:l,onChange:e=>u(e.target.value)})}),(0,U.jsx)(v,{label:`Jobs start`,children:(0,U.jsx)(_,{type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})}),(0,U.jsx)(v,{label:`Jobs end`,hint:`Inclusive; max 100`,children:(0,U.jsx)(_,{type:`number`,min:0,max:1e6,value:p,onChange:e=>m(e.target.value)})}),(0,U.jsx)(v,{label:`Rate max`,children:(0,U.jsx)(_,{type:`number`,min:1,value:h,onChange:e=>g(e.target.value)})}),(0,U.jsx)(v,{label:`Duration (ms)`,children:(0,U.jsx)(_,{type:`number`,min:1,value:y,onChange:e=>b(e.target.value)})}),(0,U.jsx)(v,{label:`Concurrency`,children:(0,U.jsx)(_,{type:`number`,min:1,value:x,onChange:e=>S(e.target.value)})})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T||!E,onClick:D,children:`Read group`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T,onClick:O,children:`Set rate limit`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T,onClick:()=>r(`Clearing group rate limit`,async n=>{if(await t.removeGroupRateLimit(e,T),!n())throw Error(`Queue operations target changed.`);return t.group(e,T)},w,!0),children:`Clear rate limit`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T,onClick:A,children:`Set concurrency`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T||C?.paused===!0,onClick:()=>j(!0),children:`Pause group`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T||C?.paused===!1,onClick:()=>j(!1),children:`Resume group`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T,onClick:()=>r(`Clearing group concurrency`,async n=>{if(await t.removeGroupConcurrency(e,T),!n())throw Error(`Queue operations target changed.`);return t.group(e,T)},w,!0),children:`Clear concurrency`})]}),!T&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group ID must contain 1–256 characters and no NUL.`}),!E&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group job range must be an inclusive page of 1–100 jobs with whole indexes from 0 to 1000000.`}),C&&(0,U.jsx)(re,{snapshot:C})]})}var oe=e=>e.length>=1&&e.length<=256&&!e.includes(`\0`)?e:null,G=e=>{let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},K=(e,t)=>{if(!e.trim())return;let n=Number(e);return Number.isSafeInteger(n)&&n>=t?n:null},se=(e,t)=>{let n=K(e,0),r=K(t,0);return n!=null&&n<=1e6&&r!=null&&r<=1e6&&r>=n&&r-n<100?{start:n,end:r}:null};function ce({snapshot:e,loading:t,error:n}){if(t&&!e)return(0,U.jsx)(`p`,{className:`text-sm text-muted`,children:`Reading broker limit state...`});if(n&&!e)return(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n});if(!e)return null;let r=e.rateLimit;return(0,U.jsxs)(`div`,{children:[n&&(0,U.jsxs)(`p`,{role:`alert`,className:`mb-3 text-xs text-warning`,children:[`Refresh failed. Showing the last successful limit snapshot: `,n]}),(0,U.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,U.jsx)(q,{label:`Global rate limit`,value:r?`${r.max} / ${r.duration} ms`:`Not configured`}),(0,U.jsx)(q,{label:`Rate-limit TTL`,value:e.rateLimitTtl===-2?`No active limit`:`${e.rateLimitTtl} ms`}),(0,U.jsx)(q,{label:`Global concurrency`,value:e.concurrency===null?`Not configured`:String(e.concurrency)}),(0,U.jsx)(q,{label:`Capacity`,value:e.maxed?`Maxed`:`Available`})]})]})}function q({label:e,value:t}){return(0,U.jsxs)(`div`,{className:`min-w-0 border-l-2 border-line pl-3`,children:[(0,U.jsx)(`dt`,{className:`text-[11px] font-medium text-faint`,children:e}),(0,U.jsx)(`dd`,{className:`mt-1 break-words font-mono text-sm text-fg`,children:t})]})}function le({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(`completed`),[s,c]=(0,k.useState)(`0`),[l,u]=(0,k.useState)(`29`),[d,f]=(0,k.useState)(`1000`),[p,m]=(0,k.useState)(null),[h,y]=(0,k.useState)(``),b=de(s,l),x=J(d,0,1e6);return(0,U.jsxs)(`section`,{"aria-labelledby":`queue-telemetry-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,U.jsx)(`h3`,{id:`queue-telemetry-title`,className:`text-sm font-semibold text-fg`,children:`Durable queue telemetry`}),(0,U.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Read paged one-minute completion or failure buckets, and bound the lifecycle-event journal.`}),(0,U.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,U.jsx)(v,{label:`Metric`,children:(0,U.jsxs)(g,{name:`queue-sdk-metric-type`,value:i,onChange:e=>a(e.target.value),children:[(0,U.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,U.jsx)(`option`,{value:`failed`,children:`Failed`})]})}),(0,U.jsx)(v,{label:`Start bucket`,children:(0,U.jsx)(_,{name:`queue-sdk-metric-start`,type:`number`,min:0,max:1e4,value:s,onChange:e=>c(e.target.value)})}),(0,U.jsx)(v,{label:`End bucket`,hint:`Use -1 for all remaining buckets`,children:(0,U.jsx)(_,{name:`queue-sdk-metric-end`,type:`number`,min:-1,max:1e4,value:l,onChange:e=>u(e.target.value)})})]}),(0,U.jsx)(o,{className:`mt-3`,size:`sm`,disabled:!b||!!n,onClick:()=>{b&&r(`Reading ${i} metrics`,()=>t.metrics(e,i,b.start,b.end),m)},children:`Read metrics`}),!b&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`Use integer buckets from 0 to 10000; end must be -1 or at least start.`}),p&&(0,U.jsx)(ue,{metrics:p}),(0,U.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end gap-3 border-t border-line pt-4`,children:[(0,U.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,U.jsx)(v,{label:`Retain lifecycle events`,hint:`0 clears the queue journal`,children:(0,U.jsx)(_,{name:`queue-sdk-event-retention`,type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})})}),(0,U.jsx)(o,{variant:`warning`,size:`sm`,disabled:x===null||!!n,onClick:()=>{x!==null&&window.confirm(`Retain at most ${x} lifecycle events for queue "${e}"? Older journal events are permanently removed; metric buckets are unchanged.`)&&r(`Trimming lifecycle journal`,()=>t.trimEvents(e,x),e=>y(`${e} lifecycle events removed.`),!0)},children:`Trim journal`})]}),h&&(0,U.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:h})]})}function ue({metrics:e}){let t=e.data.slice(0,120).map((t,n)=>({timestamp:e.meta.prevTS-n*6e4,value:t,offset:n})),n=Math.max(1,...t.map(e=>e.value));return(0,U.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-2 p-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 font-mono text-xs text-muted`,children:[(0,U.jsxs)(`span`,{children:[`Total terminal: `,e.meta.count]}),(0,U.jsxs)(`span`,{children:[`Available buckets: `,e.count]}),(0,U.jsxs)(`span`,{children:[`Latest bucket: `,e.meta.prevCount]})]}),t.length?(0,U.jsx)(`div`,{className:`mt-3 flex h-16 items-end gap-px overflow-hidden`,role:`img`,"aria-label":`${t.length} one-minute metric buckets, newest first`,children:t.map(e=>(0,U.jsx)(`span`,{title:`Bucket ${e.offset}: ${e.value}`,className:`min-w-px flex-1 bg-accent/70`,style:{height:`${Math.max(2,e.value/n*100)}%`}},e.timestamp))}):(0,U.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`No buckets in this range.`}),e.data.length>t.length&&(0,U.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Showing the first 120 returned buckets.`})]})}function de(e,t){let n=J(e,0,1e4),r=J(t,-1,1e4);return n===null||r===null||r!==-1&&r<n?null:{start:n,end:r}}function J(e,t,n){let r=Number(e);return Number.isSafeInteger(r)&&r>=t&&r<=n?r:null}function fe({queue:e,refreshKey:t=0,repository:n=A,onApplied:r}){let i=x(`queue-operations:${e}`),[a,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(null),[f,p]=(0,k.useState)(``),[m,h]=(0,k.useState)(``),g=(0,k.useRef)(!1),y=(0,k.useRef)(0),S=(0,k.useRef)(!0),C=u?.queue===e?u:{queue:e,snapshot:null,loading:!0,error:``};(0,k.useEffect)(()=>(S.current=!0,()=>{S.current=!1,y.current+=1}),[]),(0,k.useEffect)(()=>{y.current+=1,g.current=!1,d(null),p(``),h(``)},[i.scopeKey]);let w=(0,k.useCallback)(async()=>{let t=pe(a);if(t===null){d(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!1,error:`maxJobs must be a whole number from 0 to 1000000.`}));return}let r=++y.current,i=b();d(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!0,error:``}));try{let a=await n.limits(e,t);S.current&&r===y.current&&i===b()&&d({queue:e,snapshot:a,loading:!1,error:``})}catch(t){S.current&&r===y.current&&i===b()&&d({queue:e,snapshot:null,loading:!1,error:Y(t)})}},[a,e,n]);(0,k.useEffect)(()=>void w(),[e,t]);let T=(e,t,n,a=!1)=>{if(g.current)return;let o=i.begin(`queue-sdk-command`);o&&(g.current=!0,p(e),h(``),t(o.isCurrent).then(e=>{!S.current||!o.isCurrent()||(n(e),a&&(r?.(),r||w()))}).catch(e=>{S.current&&o.isCurrent()&&h(Y(e))}).finally(()=>{let e=o.finish();S.current&&e&&(g.current=!1,p(``))}))};return(0,U.jsxs)(c,{className:`mb-6`,children:[(0,U.jsx)(s,{title:`Queue SDK operations`,action:f?(0,U.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[f,`...`]}):void 0}),(0,U.jsx)(`p`,{className:`mb-5 max-w-3xl text-xs leading-5 text-faint`,children:`Live Bunqueue 2.9.3 limit, group, deduplication, metric, and event-journal contracts, including group pause, pending jobs, and priority counts. Requests are pinned to the server managed by this control agent.`}),(0,U.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-end gap-3 border-b border-line pb-5`,children:[(0,U.jsx)(`div`,{className:`w-48`,children:(0,U.jsx)(v,{label:`TTL threshold (maxJobs)`,hint:`Optional token-consumption threshold`,children:(0,U.jsx)(_,{name:`queue-sdk-max-jobs`,type:`number`,min:0,max:1e6,step:1,value:a,onChange:e=>l(e.target.value),placeholder:`Not set`})})}),(0,U.jsx)(o,{size:`sm`,disabled:C.loading||!!f,onClick:w,children:`Refresh limits`})]}),(0,U.jsx)(ce,{snapshot:C.snapshot,loading:C.loading,error:C.error}),m&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:m}),(0,U.jsxs)(`div`,{className:`mt-6 grid gap-6 xl:grid-cols-[0.8fr_1.2fr]`,children:[(0,U.jsx)(ae,{queue:e,repository:n,busy:f,run:T},`${e}:groups`),(0,U.jsx)(ne,{queue:e,repository:n,busy:f,run:T},`${e}:deduplication`),(0,U.jsx)(le,{queue:e,repository:n,busy:f,run:T},`${e}:telemetry`)]})]})}function pe(e){if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<=1e6?t:null}var Y=e=>e instanceof Error?e.message:String(e),me=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],X=500,Z=200,he=X*Z;function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ge(e){return Q(e)&&me.every(t=>$(e[t]))}function _e(e,t){if(!Q(e)||e.ok!==!0||!Array.isArray(e.queues)||!$(e.total)||!$(e.limit)||e.limit<1||!$(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>Q(e)&&typeof e.name==`string`&&e.name.length>0&&$(e.waiting)&&$(e.delayed)&&$(e.active)&&$(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function ve(){let e=await i.queues(X,0);_e(e,0);let t=e.total;if(t>he)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${he}.`);if(e.queues.length!==Math.min(X,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(X,t)} queues, received ${e.queues.length}.`);let n=new Map,r=e=>{for(let t of e.queues){if(n.has(t.name))throw Error(`Overlapping /dashboard/queues pages: queue "${t.name}" appeared more than once.`);n.set(t.name,t)}};r(e);let a=e.queues.length,o=1;for(;a<t;){if(o>=Z)throw Error(`Queue discovery exceeded the safe limit of ${Z} pages.`);let e=await i.queues(X,a);if(_e(e,a),e.total!==t)throw Error(`Queue discovery changed during pagination: total moved from ${t} to ${e.total}. Retry the snapshot.`);let n=Math.min(X,t-a);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${a}: expected ${n} queues, received ${e.queues.length}.`);r(e),a+=e.queues.length,o+=1}if(n.size!==t)throw Error(`Incomplete /dashboard/queues snapshot: expected ${t} unique queues, received ${n.size}.`);return{...e,queues:[...n.values()],total:t,limit:X,offset:0}}function ye(e,t){if(!Q(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!ge(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function be(e){if(!Q(e)||e.ok!==!0||!D(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function xe(e){if(!Q(e)||e.ok!==!0||!T(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function Se(e){if(!Q(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!$(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function Ce(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function we(){let[e,t]=(0,k.useState)(``),[n,r]=(0,k.useState)(!1),[o,s]=(0,k.useState)(0),[c,_]=(0,k.useState)(null),v=y(`queue-control:${e}`);(0,k.useEffect)(()=>{r(!1),_(null)},[v.scopeKey]);let{data:b,error:x,loading:T,refetch:D}=a(ve,[],{intervalMs:3e4});(0,k.useEffect)(()=>{b&&t(e=>Ce(e,b.queues))},[b]);let{data:A,error:j,loading:ee,refetch:M}=a((0,k.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([i.queueDetail(e,!1),i.getStallConfig(e).then(be).catch(()=>null),i.getDlqConfig(e).then(xe).catch(()=>null)]);return ye(t,e),{queue:e,detail:t,stall:n,dlq:r}},[e]),[e]),N=!b||b.queues.some(t=>t.name===e),P=A?.queue===e&&N?A:null,F=(t,n,a,o)=>{let c=e;if(!c||a&&!window.confirm(a))return;let l=v.begin(`queue-write`);l&&(r(!0),_(null),(async()=>{try{let e=await i.queuesSummary();if(!l.isCurrent())return;if(!e.some(e=>e.name===c))throw Error(`Queue "${c}" no longer exists`);let r=Se(await n());if(!l.isCurrent())return;_({queue:c,ok:!0,text:`${t}${r==null?` ✓`:`: ${r}`}`}),o?.(),s(e=>e+1),await M()}catch(e){l.isCurrent()&&_({queue:c,ok:!1,text:e.message})}finally{l.finish()&&r(!1)}})())};return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(p,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!P?.detail&&!!P.stall&&!!P.dlq&&!j&&!x}),(0,U.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`w-56`,children:(0,U.jsx)(g,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(b?.queues??[]).map(e=>(0,U.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),P?.detail&&(0,U.jsx)(f,{label:P.detail.paused?`Paused`:`Active`,tone:P.detail.paused?`amber`:`green`}),c?.queue===e&&(0,U.jsx)(`span`,{role:`status`,className:c.ok?`text-xs text-success`:`text-xs text-danger`,children:c.text})]}),x&&(0,U.jsx)(l,{onRetry:D,message:`Could not discover queues — ${x.message}. Retry to choose a queue.`}),j&&P&&(0,U.jsx)(l,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:M}),j&&!P?(0,U.jsx)(u,{error:j,onRetry:M}):T&&!b&&!e&&!x?(0,U.jsx)(d,{label:`Discovering queues…`}):ee&&!P?(0,U.jsx)(d,{}):x&&!e?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):P?.detail?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:me.map(e=>(0,U.jsx)(h,{label:e,value:m(P.detail.counts[e]),compact:!0},e))}),(0,U.jsx)(w,{queue:e,paused:P.detail.paused,busy:n,run:F},`${e}:lifecycle`),(0,U.jsx)(O,{queue:e,busy:n,run:F},`${e}:limits`),(0,U.jsx)(fe,{queue:e,refreshKey:o,onApplied:()=>s(e=>e+1)},`${v.scopeKey}:${e}:sdk-operations`),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[P.stall?(0,U.jsx)(C,{queue:e,config:P.stall,onSaved:async()=>{_({queue:e,ok:!0,text:`Stall config saved ✓`}),await M()}},`${e}:stall`):(0,U.jsx)(E,{title:`Stall detection`,onRetry:M}),P.dlq?(0,U.jsx)(S,{queue:e,config:P.dlq,onSaved:async()=>{_({queue:e,ok:!0,text:`DLQ config saved ✓`}),await M()}},`${e}:dlq`):(0,U.jsx)(E,{title:`DLQ policy`,onRetry:M})]})]}):!j&&(0,U.jsx)(`p`,{className:`text-sm text-faint`,children:b?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{we as QueueControl,ve as t};
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-F5BbTG1T.js";import{n as a}from"./usePolledData-0CVelkl2.js";import{t as o}from"./Button-Ch1W94fJ.js";import{n as s,t as c}from"./Card-CWxrC8OY.js";import{i as l,n as u,r as d}from"./feedback-QDN1AsYt.js";import{n as f}from"./StatusBadge-BoOVTnKu.js";import{t as p}from"./PageHeader-CvIyaFOO.js";import{s as m}from"./format-Cg7VCIZW.js";import{n as h}from"./index-BFW2_47n.js";import{a as g,n as _,t as v}from"./form-C4oby9pI.js";import{r as y}from"./useServerActionGuard-uGePilQQ.js";import{t as b}from"./controlConnectionEpoch-CZsS0wAb.js";import{t as x}from"./useControlActionGuard-B-bzKZKI.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./QueueActions-BWnmNEqV.js";var k=e(t(),1),A={limits:async(e,t)=>P(await i.queueOperations.limits(e,t)),group:async(e,t,n,r,a,o)=>j(await i.queueOperations.group(e,t,n,r,a,o)),pauseGroup:async(e,t)=>M(await i.queueOperations.pauseGroup(e,t)),resumeGroup:async(e,t)=>M(await i.queueOperations.resumeGroup(e,t)),setGroupRateLimit:async(e,t,n,r)=>{N(await i.queueOperations.setGroupRateLimit(e,t,n,r))},removeGroupRateLimit:async(e,t)=>I(await i.queueOperations.removeGroupRateLimit(e,t)),setGroupConcurrency:async(e,t,n)=>{N(await i.queueOperations.setGroupConcurrency(e,t,n))},removeGroupConcurrency:async(e,t)=>I(await i.queueOperations.removeGroupConcurrency(e,t)),deduplicationJobId:async(e,t)=>F(await i.queueOperations.deduplicationJobId(e,t)),removeDeduplicationKey:async(e,t)=>I(await i.queueOperations.removeDeduplicationKey(e,t)),metrics:async(e,t,n,r)=>te(await i.queueOperations.metrics(e,t,n,r)),trimEvents:async(e,t)=>I(await i.queueOperations.trimEvents(e,t))};function j(e){let t=R(L(e,`Queue group`).group,`Queue group`),n=t.rateLimit,r=t.entries,i=t.priorityCounts;if(!V(t.jobs,0)||!V(t.active,0)||!V(t.totalGrouped,0)||typeof t.paused!=`boolean`||!Array.isArray(r)||r.length>100||!r.every(ee)||!z(i)||!Object.entries(i).every(([e,t])=>/^\d+$/.test(e)&&Number(e)<=2097151&&V(t,0))||n!==null&&(!z(n)||!B(n.max)||!B(n.duration))||!V(t.rateLimitTtl,-2)||t.concurrency!==null&&!B(t.concurrency))throw H(`Queue group`);return t}function ee(e){return z(e)?typeof e.id==`string`&&e.id.length>0&&typeof e.name==`string`&&e.name.length>0&&V(e.priority,0)&&e.priority<=2097151&&V(e.delay,0)&&V(e.timestamp,0):!1}function M(e){let t=L(e,`Queue group mutation`).changed;if(typeof t!=`boolean`)throw H(`Queue group mutation`);return t}function N(e){if(L(e,`Queue mutation`).applied!==!0)throw H(`Queue mutation`)}function P(e){let t=R(L(e,`Queue limits`).limits,`Queue limits`),n=t.rateLimit;if(n!==null&&(!z(n)||!B(n.max)||!B(n.duration))||t.concurrency!==null&&!B(t.concurrency)||!V(t.rateLimitTtl,-2)||typeof t.maxed!=`boolean`)throw H(`Queue limits`);return{rateLimit:n,concurrency:t.concurrency,rateLimitTtl:t.rateLimitTtl,maxed:t.maxed}}function F(e){let t=L(e,`deduplication lookup`).jobId;if(t!==null&&(typeof t!=`string`||!t))throw H(`deduplication lookup`);return t}function I(e){let t=L(e,`Queue mutation`).removed;if(!V(t,0))throw H(`Queue mutation`);return t}function te(e){let t=R(L(e,`Queue metrics`).metrics,`Queue metrics`),n=R(t.meta,`Queue metrics`);if(!V(n.count,0)||!V(n.prevTS,0)||!V(n.prevCount,0)||!V(t.count,0)||!Array.isArray(t.data)||t.data.length>10001||!t.data.every(e=>V(e,0)))throw H(`Queue metrics`);return t}function L(e,t){let n=R(e,t);if(n.ok!==!0)throw H(t);return n}function R(e,t){if(!z(e))throw H(t);return e}function z(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var B=e=>V(e,1),V=(e,t)=>Number.isSafeInteger(e)&&e>=t,H=e=>Error(`Malformed ${e} response`),U=r();function ne({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(``),[s,c]=(0,k.useState)(),[l,u]=(0,k.useState)(``),d=i.length>0&&i.length<=1024;return(0,U.jsxs)(`section`,{"aria-labelledby":`queue-dedup-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,U.jsx)(`h3`,{id:`queue-dedup-title`,className:`text-sm font-semibold text-fg`,children:`Deduplication registry`}),(0,U.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Resolve an official deduplication ID to its current job, or release only the registry key.`}),(0,U.jsx)(v,{label:`Deduplication ID`,children:(0,U.jsx)(_,{name:`queue-sdk-deduplication-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:i,onChange:e=>{a(e.target.value),c(void 0),u(``)}})}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsx)(o,{size:`sm`,disabled:!d||!!n,onClick:()=>r(`Looking up deduplication key`,()=>t.deduplicationJobId(e,i),c),children:`Find owner`}),(0,U.jsx)(o,{variant:`warning`,size:`sm`,disabled:!d||!!n,onClick:()=>{window.confirm(`Remove deduplication key "${i}" from queue "${e}"? The job is not deleted, but a later enqueue may reuse this key.`)&&r(`Removing deduplication key`,()=>t.removeDeduplicationKey(e,i),e=>{u(e?`Deduplication key removed.`:`No matching key was active.`),c(void 0)},!0)},children:`Remove key`})]}),s!==void 0&&(0,U.jsx)(`p`,{role:`status`,className:`mt-3 break-all text-xs text-muted`,children:s===null?`No active owner.`:`Current job: ${s}`}),l&&(0,U.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l})]})}function re({snapshot:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 rounded-lg border border-line p-3 text-xs sm:grid-cols-4 xl:grid-cols-7`,children:[(0,U.jsx)(W,{label:`Jobs`,value:e.jobs}),(0,U.jsx)(W,{label:`Active`,value:e.active}),(0,U.jsx)(W,{label:`All grouped`,value:e.totalGrouped}),(0,U.jsx)(W,{label:`Rate`,value:e.rateLimit?`${e.rateLimit.max}/${e.rateLimit.duration}ms`:`None`}),(0,U.jsx)(W,{label:`TTL`,value:`${e.rateLimitTtl} ms`}),(0,U.jsx)(W,{label:`Concurrency`,value:e.concurrency??`None`}),(0,U.jsx)(W,{label:`Paused`,value:e.paused?`Yes`:`No`}),(0,U.jsx)(W,{label:`Priority counts`,value:ie(e.priorityCounts)})]}),(0,U.jsx)(`div`,{className:`mt-3 overflow-x-auto rounded-lg border border-line`,children:(0,U.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,U.jsx)(`thead`,{className:`border-b border-line text-faint`,children:(0,U.jsxs)(`tr`,{children:[(0,U.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Pending group job`}),(0,U.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Name`}),(0,U.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Priority`}),(0,U.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Delay`})]})}),(0,U.jsx)(`tbody`,{children:e.entries.length===0?(0,U.jsx)(`tr`,{children:(0,U.jsx)(`td`,{colSpan:4,className:`px-3 py-4 text-center text-faint`,children:`No pending jobs in this page.`})}):e.entries.map(e=>(0,U.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,U.jsx)(`td`,{className:`px-3 py-2 font-mono`,children:(0,U.jsx)(n,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect grouped job ${e.id}`,className:`text-accent hover:underline`,children:e.id})}),(0,U.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,U.jsx)(`td`,{className:`px-3 py-2 text-right font-mono`,children:e.priority}),(0,U.jsxs)(`td`,{className:`px-3 py-2 text-right font-mono`,children:[e.delay,` ms`]})]},e.id))})]})})]})}function W({label:e,value:t}){return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`text-faint`,children:e}),(0,U.jsx)(`dd`,{className:`mt-1 font-mono text-fg`,children:t})]})}var ie=e=>{let t=Object.entries(e).sort(([e],[t])=>Number(e)-Number(t));return t.length?t.map(([e,t])=>`${e}: ${t}`).join(` · `):`None`};function ae({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(`default`),[s,c]=(0,k.useState)(``),[l,u]=(0,k.useState)(`100`),[d,f]=(0,k.useState)(`0`),[p,m]=(0,k.useState)(`24`),[h,g]=(0,k.useState)(`100`),[y,b]=(0,k.useState)(`60000`),[x,S]=(0,k.useState)(`1`),[C,w]=(0,k.useState)(null),T=oe(i),E=se(d,p),D=()=>{let n=K(s,0),i=K(l,1);!T||n===null||i===null||!E||r(`Reading group`,()=>t.group(e,T,n,i,E.start,E.end),w)},O=()=>{let n=G(h),i=G(y);!T||n===null||i===null||r(`Setting group rate limit`,async r=>{if(await t.setGroupRateLimit(e,T,n,i),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},w,!0)},A=()=>{let n=G(x);!T||n===null||r(`Setting group concurrency`,async r=>{if(await t.setGroupConcurrency(e,T,n),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},w,!0)},j=n=>{T&&r(n?`Pausing group`:`Resuming group`,async r=>{if(n?await t.pauseGroup(e,T):await t.resumeGroup(e,T),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},w,!0)};return(0,U.jsxs)(`section`,{className:`xl:col-span-2`,"aria-labelledby":`queue-groups-title`,children:[(0,U.jsx)(`h3`,{id:`queue-groups-title`,className:`mb-3 text-sm font-medium text-fg`,children:`Groups`}),(0,U.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4 xl:grid-cols-8`,children:[(0,U.jsx)(v,{label:`Group ID`,children:(0,U.jsx)(_,{value:i,maxLength:256,onChange:e=>a(e.target.value)})}),(0,U.jsx)(v,{label:`TTL maxJobs`,hint:`Optional`,children:(0,U.jsx)(_,{type:`number`,min:0,value:s,onChange:e=>c(e.target.value)})}),(0,U.jsx)(v,{label:`Groups maxCount`,children:(0,U.jsx)(_,{type:`number`,min:1,value:l,onChange:e=>u(e.target.value)})}),(0,U.jsx)(v,{label:`Jobs start`,children:(0,U.jsx)(_,{type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})}),(0,U.jsx)(v,{label:`Jobs end`,hint:`Inclusive; max 100`,children:(0,U.jsx)(_,{type:`number`,min:0,max:1e6,value:p,onChange:e=>m(e.target.value)})}),(0,U.jsx)(v,{label:`Rate max`,children:(0,U.jsx)(_,{type:`number`,min:1,value:h,onChange:e=>g(e.target.value)})}),(0,U.jsx)(v,{label:`Duration (ms)`,children:(0,U.jsx)(_,{type:`number`,min:1,value:y,onChange:e=>b(e.target.value)})}),(0,U.jsx)(v,{label:`Concurrency`,children:(0,U.jsx)(_,{type:`number`,min:1,value:x,onChange:e=>S(e.target.value)})})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T||!E,onClick:D,children:`Read group`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T,onClick:O,children:`Set rate limit`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T,onClick:()=>r(`Clearing group rate limit`,async n=>{if(await t.removeGroupRateLimit(e,T),!n())throw Error(`Queue operations target changed.`);return t.group(e,T)},w,!0),children:`Clear rate limit`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T,onClick:A,children:`Set concurrency`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T||C?.paused===!0,onClick:()=>j(!0),children:`Pause group`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T||C?.paused===!1,onClick:()=>j(!1),children:`Resume group`}),(0,U.jsx)(o,{size:`sm`,disabled:!!n||!T,onClick:()=>r(`Clearing group concurrency`,async n=>{if(await t.removeGroupConcurrency(e,T),!n())throw Error(`Queue operations target changed.`);return t.group(e,T)},w,!0),children:`Clear concurrency`})]}),!T&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group ID must contain 1–256 characters and no NUL.`}),!E&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group job range must be an inclusive page of 1–100 jobs with whole indexes from 0 to 1000000.`}),C&&(0,U.jsx)(re,{snapshot:C})]})}var oe=e=>e.length>=1&&e.length<=256&&!e.includes(`\0`)?e:null,G=e=>{let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},K=(e,t)=>{if(!e.trim())return;let n=Number(e);return Number.isSafeInteger(n)&&n>=t?n:null},se=(e,t)=>{let n=K(e,0),r=K(t,0);return n!=null&&n<=1e6&&r!=null&&r<=1e6&&r>=n&&r-n<100?{start:n,end:r}:null};function ce({snapshot:e,loading:t,error:n}){if(t&&!e)return(0,U.jsx)(`p`,{className:`text-sm text-muted`,children:`Reading broker limit state...`});if(n&&!e)return(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n});if(!e)return null;let r=e.rateLimit;return(0,U.jsxs)(`div`,{children:[n&&(0,U.jsxs)(`p`,{role:`alert`,className:`mb-3 text-xs text-warning`,children:[`Refresh failed. Showing the last successful limit snapshot: `,n]}),(0,U.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,U.jsx)(q,{label:`Global rate limit`,value:r?`${r.max} / ${r.duration} ms`:`Not configured`}),(0,U.jsx)(q,{label:`Rate-limit TTL`,value:e.rateLimitTtl===-2?`No active limit`:`${e.rateLimitTtl} ms`}),(0,U.jsx)(q,{label:`Global concurrency`,value:e.concurrency===null?`Not configured`:String(e.concurrency)}),(0,U.jsx)(q,{label:`Capacity`,value:e.maxed?`Maxed`:`Available`})]})]})}function q({label:e,value:t}){return(0,U.jsxs)(`div`,{className:`min-w-0 border-l-2 border-line pl-3`,children:[(0,U.jsx)(`dt`,{className:`text-[11px] font-medium text-faint`,children:e}),(0,U.jsx)(`dd`,{className:`mt-1 break-words font-mono text-sm text-fg`,children:t})]})}function le({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(`completed`),[s,c]=(0,k.useState)(`0`),[l,u]=(0,k.useState)(`29`),[d,f]=(0,k.useState)(`1000`),[p,m]=(0,k.useState)(null),[h,y]=(0,k.useState)(``),b=de(s,l),x=J(d,0,1e6);return(0,U.jsxs)(`section`,{"aria-labelledby":`queue-telemetry-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,U.jsx)(`h3`,{id:`queue-telemetry-title`,className:`text-sm font-semibold text-fg`,children:`Durable queue telemetry`}),(0,U.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Read paged one-minute completion or failure buckets, and bound the lifecycle-event journal.`}),(0,U.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,U.jsx)(v,{label:`Metric`,children:(0,U.jsxs)(g,{name:`queue-sdk-metric-type`,value:i,onChange:e=>a(e.target.value),children:[(0,U.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,U.jsx)(`option`,{value:`failed`,children:`Failed`})]})}),(0,U.jsx)(v,{label:`Start bucket`,children:(0,U.jsx)(_,{name:`queue-sdk-metric-start`,type:`number`,min:0,max:1e4,value:s,onChange:e=>c(e.target.value)})}),(0,U.jsx)(v,{label:`End bucket`,hint:`Use -1 for all remaining buckets`,children:(0,U.jsx)(_,{name:`queue-sdk-metric-end`,type:`number`,min:-1,max:1e4,value:l,onChange:e=>u(e.target.value)})})]}),(0,U.jsx)(o,{className:`mt-3`,size:`sm`,disabled:!b||!!n,onClick:()=>{b&&r(`Reading ${i} metrics`,()=>t.metrics(e,i,b.start,b.end),m)},children:`Read metrics`}),!b&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`Use integer buckets from 0 to 10000; end must be -1 or at least start.`}),p&&(0,U.jsx)(ue,{metrics:p}),(0,U.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end gap-3 border-t border-line pt-4`,children:[(0,U.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,U.jsx)(v,{label:`Retain lifecycle events`,hint:`0 clears the queue journal`,children:(0,U.jsx)(_,{name:`queue-sdk-event-retention`,type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})})}),(0,U.jsx)(o,{variant:`warning`,size:`sm`,disabled:x===null||!!n,onClick:()=>{x!==null&&window.confirm(`Retain at most ${x} lifecycle events for queue "${e}"? Older journal events are permanently removed; metric buckets are unchanged.`)&&r(`Trimming lifecycle journal`,()=>t.trimEvents(e,x),e=>y(`${e} lifecycle events removed.`),!0)},children:`Trim journal`})]}),h&&(0,U.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:h})]})}function ue({metrics:e}){let t=e.data.slice(0,120).map((t,n)=>({timestamp:e.meta.prevTS-n*6e4,value:t,offset:n})),n=Math.max(1,...t.map(e=>e.value));return(0,U.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-2 p-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 font-mono text-xs text-muted`,children:[(0,U.jsxs)(`span`,{children:[`Total terminal: `,e.meta.count]}),(0,U.jsxs)(`span`,{children:[`Available buckets: `,e.count]}),(0,U.jsxs)(`span`,{children:[`Latest bucket: `,e.meta.prevCount]})]}),t.length?(0,U.jsx)(`div`,{className:`mt-3 flex h-16 items-end gap-px overflow-hidden`,role:`img`,"aria-label":`${t.length} one-minute metric buckets, newest first`,children:t.map(e=>(0,U.jsx)(`span`,{title:`Bucket ${e.offset}: ${e.value}`,className:`min-w-px flex-1 bg-accent/70`,style:{height:`${Math.max(2,e.value/n*100)}%`}},e.timestamp))}):(0,U.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`No buckets in this range.`}),e.data.length>t.length&&(0,U.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Showing the first 120 returned buckets.`})]})}function de(e,t){let n=J(e,0,1e4),r=J(t,-1,1e4);return n===null||r===null||r!==-1&&r<n?null:{start:n,end:r}}function J(e,t,n){let r=Number(e);return Number.isSafeInteger(r)&&r>=t&&r<=n?r:null}function fe({queue:e,refreshKey:t=0,repository:n=A,onApplied:r}){let i=x(`queue-operations:${e}`),[a,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(null),[f,p]=(0,k.useState)(``),[m,h]=(0,k.useState)(``),g=(0,k.useRef)(!1),y=(0,k.useRef)(0),S=(0,k.useRef)(!0),C=u?.queue===e?u:{queue:e,snapshot:null,loading:!0,error:``};(0,k.useEffect)(()=>(S.current=!0,()=>{S.current=!1,y.current+=1}),[]),(0,k.useEffect)(()=>{y.current+=1,g.current=!1,d(null),p(``),h(``)},[i.scopeKey]);let w=(0,k.useCallback)(async()=>{let t=pe(a);if(t===null){d(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!1,error:`maxJobs must be a whole number from 0 to 1000000.`}));return}let r=++y.current,i=b();d(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!0,error:``}));try{let a=await n.limits(e,t);S.current&&r===y.current&&i===b()&&d({queue:e,snapshot:a,loading:!1,error:``})}catch(t){S.current&&r===y.current&&i===b()&&d({queue:e,snapshot:null,loading:!1,error:Y(t)})}},[a,e,n]);(0,k.useEffect)(()=>void w(),[e,t]);let T=(e,t,n,a=!1)=>{if(g.current)return;let o=i.begin(`queue-sdk-command`);o&&(g.current=!0,p(e),h(``),t(o.isCurrent).then(e=>{!S.current||!o.isCurrent()||(n(e),a&&(r?.(),r||w()))}).catch(e=>{S.current&&o.isCurrent()&&h(Y(e))}).finally(()=>{let e=o.finish();S.current&&e&&(g.current=!1,p(``))}))};return(0,U.jsxs)(c,{className:`mb-6`,children:[(0,U.jsx)(s,{title:`Queue SDK operations`,action:f?(0,U.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[f,`...`]}):void 0}),(0,U.jsx)(`p`,{className:`mb-5 max-w-3xl text-xs leading-5 text-faint`,children:`Live Bunqueue 2.9.3 limit, group, deduplication, metric, and event-journal contracts, including group pause, pending jobs, and priority counts. Requests are pinned to the server managed by this control agent.`}),(0,U.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-end gap-3 border-b border-line pb-5`,children:[(0,U.jsx)(`div`,{className:`w-48`,children:(0,U.jsx)(v,{label:`TTL threshold (maxJobs)`,hint:`Optional token-consumption threshold`,children:(0,U.jsx)(_,{name:`queue-sdk-max-jobs`,type:`number`,min:0,max:1e6,step:1,value:a,onChange:e=>l(e.target.value),placeholder:`Not set`})})}),(0,U.jsx)(o,{size:`sm`,disabled:C.loading||!!f,onClick:w,children:`Refresh limits`})]}),(0,U.jsx)(ce,{snapshot:C.snapshot,loading:C.loading,error:C.error}),m&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:m}),(0,U.jsxs)(`div`,{className:`mt-6 grid gap-6 xl:grid-cols-[0.8fr_1.2fr]`,children:[(0,U.jsx)(ae,{queue:e,repository:n,busy:f,run:T},`${e}:groups`),(0,U.jsx)(ne,{queue:e,repository:n,busy:f,run:T},`${e}:deduplication`),(0,U.jsx)(le,{queue:e,repository:n,busy:f,run:T},`${e}:telemetry`)]})]})}function pe(e){if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<=1e6?t:null}var Y=e=>e instanceof Error?e.message:String(e),me=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],X=500,Z=200,he=X*Z;function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ge(e){return Q(e)&&me.every(t=>$(e[t]))}function _e(e,t){if(!Q(e)||e.ok!==!0||!Array.isArray(e.queues)||!$(e.total)||!$(e.limit)||e.limit<1||!$(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>Q(e)&&typeof e.name==`string`&&e.name.length>0&&$(e.waiting)&&$(e.delayed)&&$(e.active)&&$(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function ve(){let e=await i.queues(X,0);_e(e,0);let t=e.total;if(t>he)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${he}.`);if(e.queues.length!==Math.min(X,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(X,t)} queues, received ${e.queues.length}.`);let n=new Map,r=e=>{for(let t of e.queues){if(n.has(t.name))throw Error(`Overlapping /dashboard/queues pages: queue "${t.name}" appeared more than once.`);n.set(t.name,t)}};r(e);let a=e.queues.length,o=1;for(;a<t;){if(o>=Z)throw Error(`Queue discovery exceeded the safe limit of ${Z} pages.`);let e=await i.queues(X,a);if(_e(e,a),e.total!==t)throw Error(`Queue discovery changed during pagination: total moved from ${t} to ${e.total}. Retry the snapshot.`);let n=Math.min(X,t-a);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${a}: expected ${n} queues, received ${e.queues.length}.`);r(e),a+=e.queues.length,o+=1}if(n.size!==t)throw Error(`Incomplete /dashboard/queues snapshot: expected ${t} unique queues, received ${n.size}.`);return{...e,queues:[...n.values()],total:t,limit:X,offset:0}}function ye(e,t){if(!Q(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!ge(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function be(e){if(!Q(e)||e.ok!==!0||!D(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function xe(e){if(!Q(e)||e.ok!==!0||!T(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function Se(e){if(!Q(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!$(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function Ce(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function we(){let[e,t]=(0,k.useState)(``),[n,r]=(0,k.useState)(!1),[o,s]=(0,k.useState)(0),[c,_]=(0,k.useState)(null),v=y(`queue-control:${e}`);(0,k.useEffect)(()=>{r(!1),_(null)},[v.scopeKey]);let{data:b,error:x,loading:T,refetch:D}=a(ve,[],{intervalMs:3e4});(0,k.useEffect)(()=>{b&&t(e=>Ce(e,b.queues))},[b]);let{data:A,error:j,loading:ee,refetch:M}=a((0,k.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([i.queueDetail(e,!1),i.getStallConfig(e).then(be).catch(()=>null),i.getDlqConfig(e).then(xe).catch(()=>null)]);return ye(t,e),{queue:e,detail:t,stall:n,dlq:r}},[e]),[e]),N=!b||b.queues.some(t=>t.name===e),P=A?.queue===e&&N?A:null,F=(t,n,a,o)=>{let c=e;if(!c||a&&!window.confirm(a))return;let l=v.begin(`queue-write`);l&&(r(!0),_(null),(async()=>{try{let e=await i.queuesSummary();if(!l.isCurrent())return;if(!e.some(e=>e.name===c))throw Error(`Queue "${c}" no longer exists`);let r=Se(await n());if(!l.isCurrent())return;_({queue:c,ok:!0,text:`${t}${r==null?` ✓`:`: ${r}`}`}),o?.(),s(e=>e+1),await M()}catch(e){l.isCurrent()&&_({queue:c,ok:!1,text:e.message})}finally{l.finish()&&r(!1)}})())};return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(p,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!P?.detail&&!!P.stall&&!!P.dlq&&!j&&!x}),(0,U.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`w-56`,children:(0,U.jsx)(g,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(b?.queues??[]).map(e=>(0,U.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),P?.detail&&(0,U.jsx)(f,{label:P.detail.paused?`Paused`:`Active`,tone:P.detail.paused?`amber`:`green`}),c?.queue===e&&(0,U.jsx)(`span`,{role:`status`,className:c.ok?`text-xs text-success`:`text-xs text-danger`,children:c.text})]}),x&&(0,U.jsx)(l,{onRetry:D,message:`Could not discover queues — ${x.message}. Retry to choose a queue.`}),j&&P&&(0,U.jsx)(l,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:M}),j&&!P?(0,U.jsx)(u,{error:j,onRetry:M}):T&&!b&&!e&&!x?(0,U.jsx)(d,{label:`Discovering queues…`}):ee&&!P?(0,U.jsx)(d,{}):x&&!e?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):P?.detail?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:me.map(e=>(0,U.jsx)(h,{label:e,value:m(P.detail.counts[e]),compact:!0},e))}),(0,U.jsx)(w,{queue:e,paused:P.detail.paused,busy:n,run:F},`${e}:lifecycle`),(0,U.jsx)(O,{queue:e,busy:n,run:F},`${e}:limits`),(0,U.jsx)(fe,{queue:e,refreshKey:o,onApplied:()=>s(e=>e+1)},`${v.scopeKey}:${e}:sdk-operations`),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[P.stall?(0,U.jsx)(C,{queue:e,config:P.stall,onSaved:async()=>{_({queue:e,ok:!0,text:`Stall config saved ✓`}),await M()}},`${e}:stall`):(0,U.jsx)(E,{title:`Stall detection`,onRetry:M}),P.dlq?(0,U.jsx)(S,{queue:e,config:P.dlq,onSaved:async()=>{_({queue:e,ok:!0,text:`DLQ config saved ✓`}),await M()}},`${e}:dlq`):(0,U.jsx)(E,{title:`DLQ policy`,onRetry:M})]})]}):!j&&(0,U.jsx)(`p`,{className:`text-sm text-faint`,children:b?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{we as QueueControl,ve as t};
@@ -1 +1 @@
1
- import{i as e}from"./cn-zFEt5SO8.js";import{d as t,g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-F5BbTG1T.js";import{A as o,b as s,i as c,m as l,n as u,x as d}from"./icons-BVzwsfbG.js";import{t as f}from"./api-BgWE-705.js";import{n as p}from"./usePolledData-0CVelkl2.js";import{t as m}from"./Button-Ch1W94fJ.js";import{t as h}from"./Card-CWxrC8OY.js";import{i as g,r as _,t as v}from"./feedback-QDN1AsYt.js";import{n as y,t as b}from"./StatusBadge-BoOVTnKu.js";import{a as x,c as S,d as C,l as w,s as T,t as E}from"./format-Cg7VCIZW.js";import{n as D}from"./index-mID5W7vq.js";import{a as O,n as k,t as A}from"./form-C4oby9pI.js";import{r as j,t as M}from"./useServerActionGuard-uGePilQQ.js";import{r as N}from"./flowMutationSafety-YKTHxqKv.js";var P=e(n(),1),F=i();function I({queue:e}){return(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.9.3 cannot read either current policy. Every command below is an explicit blind desired-state write; a receipt proves only what this dashboard applied at that time.`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,F.jsx)(z,{queue:e}),(0,F.jsx)(B,{queue:e})]})]})}function L(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function R(e,t){let[n,r]=(0,P.useState)(!1),[i,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(null),l=j(`classic-queue-policy:${e}:${t}`);return(0,P.useEffect)(()=>{r(!1),o(null),c(null)},[l.scopeKey]),{busy:n,error:i,receipt:s,run:async(n,i,s)=>{if(!window.confirm(i))return;let u=l.begin(t);if(u){r(!0),o(null),c(null);try{let t=await a.queuesSummary();if(!u.isCurrent())return;if(!t.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await s(),n),!u.isCurrent())return;c(`${n} applied at ${new Date().toISOString()}. Current server state cannot be read.`)}catch(e){u.isCurrent()&&o(e.message)}finally{u.finish()&&r(!1)}}}}}function z({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),[o,s]=(0,P.useState)(`permanent`),[c,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),{busy:p,error:g,receipt:_,run:v}=R(e,`rate-limit`),y=L(t),b=L(r),x=o===`expires`?L(c):void 0,S=y!==null&&b!==null&&(o===`permanent`||x!=null);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,F.jsx)(l,{className:`size-4 text-faint`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsx)(A,{label:`Limit`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-limit`,value:t,"aria-invalid":t.trim()!==``&&y===null,onChange:e=>n(e.target.value),placeholder:`100`})}),(0,F.jsx)(A,{label:`Window (ms)`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-duration`,value:r,"aria-invalid":r.trim()!==``&&b===null,onChange:e=>i(e.target.value),placeholder:`60000`})}),(0,F.jsx)(A,{label:`TTL`,children:(0,F.jsxs)(O,{name:`classic-rate-ttl-mode`,value:o,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,F.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,F.jsx)(A,{label:`TTL (ms)`,hint:o===`permanent`?`Not sent`:void 0,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-ttl`,disabled:o===`permanent`,value:c,"aria-invalid":o===`expires`&&c.trim()!==``&&x==null,onChange:e=>u(e.target.value),placeholder:`3600000`})})]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,F.jsx)(m,{variant:`accent`,size:`sm`,disabled:p||!S,onClick:()=>{if(y===null||b===null||o===`expires`&&x===null)return;let t=typeof x==`number`?x:void 0,n=o===`permanent`?`permanent`:`TTL ${x}ms`;v(`Rate-limit policy replaced`,`Replace the unknown rate-limit policy for "${e}" with limit ${y}, window ${b}ms, ${n}?`,()=>a.setRateLimit(e,y,b,t))},children:`Replace rate-limit policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,F.jsx)(m,{className:`mt-2`,size:`sm`,disabled:p||d!==e,onClick:()=>void v(`No rate limit ensured`,`Ensure queue "${e}" has no rate-limit policy? The previous value is unavailable.`,()=>a.clearRateLimit(e)),children:`Ensure no rate limit`})]}),_&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:_}),g&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:g})]})}function B({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),{busy:s,error:c,receipt:l,run:u}=R(e,`concurrency`),d=L(t);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,F.jsx)(o,{className:`size-4 text-faint`})]}),(0,F.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-concurrency`,value:t,"aria-invalid":t.trim()!==``&&d===null,onChange:e=>n(e.target.value),placeholder:`5`})}),(0,F.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,F.jsx)(m,{variant:`accent`,size:`sm`,disabled:s||d===null,onClick:()=>{d!==null&&u(`Concurrency policy replaced`,`Replace the unknown concurrency policy for "${e}" with ${d} maximum in-flight jobs?`,()=>a.setConcurrency(e,d))},children:`Replace concurrency policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,F.jsx)(m,{className:`mt-2`,size:`sm`,disabled:s||r!==e,onClick:()=>void u(`No concurrency limit ensured`,`Ensure queue "${e}" has no concurrency policy? The previous value is unavailable.`,()=>a.clearConcurrency(e)),children:`Ensure no concurrency limit`})]}),l&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l}),c&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c})]})}var V=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],H={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,"waiting-children":0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[],recentJobsError:null};function U(){let{name:e=``}=t(),[n,i]=(0,P.useState)(null),[o,l]=(0,P.useState)(null),h=j(`classic-queue:${e}`);(0,P.useEffect)(()=>{i(null),l(null)},[h.scopeKey]);let{data:O,error:k,loading:A,refetch:L}=p((0,P.useCallback)(async()=>{if(!(await a.queuesSummary()).some(t=>t.name===e))return{exists:!1,detail:null,jobs:[],recentJobsError:null};let[t,n]=await Promise.all([f.queueDetail(e,!1),f.jobsList(e,{states:V,limit:12}).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);if(t.ok!==!0||t.name!==e)throw Error(`Malformed queue detail response for "${e}"`);return{exists:!0,detail:t,jobs:n.jobs,recentJobsError:n.error}},[e]),[e]),R=async(t,n,r)=>{if(r&&!window.confirm(r))return;let o=h.begin(t);if(o){i(t),l(null);try{let r=await a.queuesSummary();if(!o.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await n(),t),!o.isCurrent())return;await L()}catch(e){o.isCurrent()&&l(e.message)}finally{o.finish()&&i(null)}}};if(A&&!O&&!k)return(0,F.jsx)(_,{label:`Loading ${e}…`});if(k&&!O)return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(g,{onRetry:L})]});if(O?.exists===!1)return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(v,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,F.jsx)(r,{to:`/queues-classic`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to classic queues`})})]});let z=O?.exists===!0?O:H,{detail:B}=z,U=B.counts,W=E(U.completed??0,U.failed??0),G=[...z.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(r,{to:`/queues-classic`,"aria-label":`Back to classic queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,F.jsx)(c,{className:`size-4`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,F.jsx)(y,{label:B.paused?`Paused`:`Active`,tone:B.paused?`amber`:`green`}),(0,F.jsx)(y,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B.paused?(0,F.jsxs)(m,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>R(`resume`,()=>f.resume(e)),children:[(0,F.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,F.jsxs)(m,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>R(`pause`,()=>f.pause(e)),children:[(0,F.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,F.jsx)(m,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,F.jsx)(m,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),o&&(0,F.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:o}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,F.jsx)(D,{label:`Waiting`,value:T(U.waiting),tone:`amber`}),(0,F.jsx)(D,{label:`Active`,value:T(U.active),tone:`blue`}),(0,F.jsx)(D,{label:`Completed`,value:T(U.completed),tone:`green`}),(0,F.jsx)(D,{label:`Failed`,value:T(U.failed),tone:U.failed?`red`:`default`}),(0,F.jsx)(D,{label:`Delayed`,value:T(U.delayed),tone:`default`}),(0,F.jsx)(D,{label:`Error Rate`,value:W==null?`—`:S(W),tone:W==null?`default`:W>.05?`red`:`green`})]}),(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,F.jsxs)(r,{to:`/jobs-classic?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,F.jsx)(u,{className:`size-3.5`})]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,F.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,F.jsx)(`tbody`,{children:z.recentJobsError?(0,F.jsx)(`tr`,{children:(0,F.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,z.recentJobsError,`. Retry the page.`]})}):G.length===0?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.map(e=>(0,F.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,F.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,F.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e.id})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,F.jsx)(`td`,{className:`px-5 py-3`,children:(0,F.jsx)(b,{status:String(e.state??e.status??`waiting`)})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:x(C(e.startedAt,e.completedAt))}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,F.jsx)(I,{queue:e})]})}export{U as QueueDetail};
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{d as t,g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-F5BbTG1T.js";import{A as o,b as s,i as c,m as l,n as u,x as d}from"./icons-BVzwsfbG.js";import{t as f}from"./api-BgWE-705.js";import{n as p}from"./usePolledData-0CVelkl2.js";import{t as m}from"./Button-Ch1W94fJ.js";import{t as h}from"./Card-CWxrC8OY.js";import{i as g,r as _,t as v}from"./feedback-QDN1AsYt.js";import{n as y,t as b}from"./StatusBadge-BoOVTnKu.js";import{a as x,c as S,d as C,l as w,s as T,t as E}from"./format-Cg7VCIZW.js";import{n as D}from"./index-BFW2_47n.js";import{a as O,n as k,t as A}from"./form-C4oby9pI.js";import{r as j,t as M}from"./useServerActionGuard-uGePilQQ.js";import{r as N}from"./flowMutationSafety-YKTHxqKv.js";var P=e(n(),1),F=i();function I({queue:e}){return(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.9.3 cannot read either current policy. Every command below is an explicit blind desired-state write; a receipt proves only what this dashboard applied at that time.`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,F.jsx)(z,{queue:e}),(0,F.jsx)(B,{queue:e})]})]})}function L(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function R(e,t){let[n,r]=(0,P.useState)(!1),[i,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(null),l=j(`classic-queue-policy:${e}:${t}`);return(0,P.useEffect)(()=>{r(!1),o(null),c(null)},[l.scopeKey]),{busy:n,error:i,receipt:s,run:async(n,i,s)=>{if(!window.confirm(i))return;let u=l.begin(t);if(u){r(!0),o(null),c(null);try{let t=await a.queuesSummary();if(!u.isCurrent())return;if(!t.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await s(),n),!u.isCurrent())return;c(`${n} applied at ${new Date().toISOString()}. Current server state cannot be read.`)}catch(e){u.isCurrent()&&o(e.message)}finally{u.finish()&&r(!1)}}}}}function z({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),[o,s]=(0,P.useState)(`permanent`),[c,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),{busy:p,error:g,receipt:_,run:v}=R(e,`rate-limit`),y=L(t),b=L(r),x=o===`expires`?L(c):void 0,S=y!==null&&b!==null&&(o===`permanent`||x!=null);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,F.jsx)(l,{className:`size-4 text-faint`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsx)(A,{label:`Limit`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-limit`,value:t,"aria-invalid":t.trim()!==``&&y===null,onChange:e=>n(e.target.value),placeholder:`100`})}),(0,F.jsx)(A,{label:`Window (ms)`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-duration`,value:r,"aria-invalid":r.trim()!==``&&b===null,onChange:e=>i(e.target.value),placeholder:`60000`})}),(0,F.jsx)(A,{label:`TTL`,children:(0,F.jsxs)(O,{name:`classic-rate-ttl-mode`,value:o,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,F.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,F.jsx)(A,{label:`TTL (ms)`,hint:o===`permanent`?`Not sent`:void 0,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-ttl`,disabled:o===`permanent`,value:c,"aria-invalid":o===`expires`&&c.trim()!==``&&x==null,onChange:e=>u(e.target.value),placeholder:`3600000`})})]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,F.jsx)(m,{variant:`accent`,size:`sm`,disabled:p||!S,onClick:()=>{if(y===null||b===null||o===`expires`&&x===null)return;let t=typeof x==`number`?x:void 0,n=o===`permanent`?`permanent`:`TTL ${x}ms`;v(`Rate-limit policy replaced`,`Replace the unknown rate-limit policy for "${e}" with limit ${y}, window ${b}ms, ${n}?`,()=>a.setRateLimit(e,y,b,t))},children:`Replace rate-limit policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,F.jsx)(m,{className:`mt-2`,size:`sm`,disabled:p||d!==e,onClick:()=>void v(`No rate limit ensured`,`Ensure queue "${e}" has no rate-limit policy? The previous value is unavailable.`,()=>a.clearRateLimit(e)),children:`Ensure no rate limit`})]}),_&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:_}),g&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:g})]})}function B({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),{busy:s,error:c,receipt:l,run:u}=R(e,`concurrency`),d=L(t);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,F.jsx)(o,{className:`size-4 text-faint`})]}),(0,F.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-concurrency`,value:t,"aria-invalid":t.trim()!==``&&d===null,onChange:e=>n(e.target.value),placeholder:`5`})}),(0,F.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,F.jsx)(m,{variant:`accent`,size:`sm`,disabled:s||d===null,onClick:()=>{d!==null&&u(`Concurrency policy replaced`,`Replace the unknown concurrency policy for "${e}" with ${d} maximum in-flight jobs?`,()=>a.setConcurrency(e,d))},children:`Replace concurrency policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,F.jsx)(m,{className:`mt-2`,size:`sm`,disabled:s||r!==e,onClick:()=>void u(`No concurrency limit ensured`,`Ensure queue "${e}" has no concurrency policy? The previous value is unavailable.`,()=>a.clearConcurrency(e)),children:`Ensure no concurrency limit`})]}),l&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l}),c&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c})]})}var V=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],H={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,"waiting-children":0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[],recentJobsError:null};function U(){let{name:e=``}=t(),[n,i]=(0,P.useState)(null),[o,l]=(0,P.useState)(null),h=j(`classic-queue:${e}`);(0,P.useEffect)(()=>{i(null),l(null)},[h.scopeKey]);let{data:O,error:k,loading:A,refetch:L}=p((0,P.useCallback)(async()=>{if(!(await a.queuesSummary()).some(t=>t.name===e))return{exists:!1,detail:null,jobs:[],recentJobsError:null};let[t,n]=await Promise.all([f.queueDetail(e,!1),f.jobsList(e,{states:V,limit:12}).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);if(t.ok!==!0||t.name!==e)throw Error(`Malformed queue detail response for "${e}"`);return{exists:!0,detail:t,jobs:n.jobs,recentJobsError:n.error}},[e]),[e]),R=async(t,n,r)=>{if(r&&!window.confirm(r))return;let o=h.begin(t);if(o){i(t),l(null);try{let r=await a.queuesSummary();if(!o.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await n(),t),!o.isCurrent())return;await L()}catch(e){o.isCurrent()&&l(e.message)}finally{o.finish()&&i(null)}}};if(A&&!O&&!k)return(0,F.jsx)(_,{label:`Loading ${e}…`});if(k&&!O)return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(g,{onRetry:L})]});if(O?.exists===!1)return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(v,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,F.jsx)(r,{to:`/queues-classic`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to classic queues`})})]});let z=O?.exists===!0?O:H,{detail:B}=z,U=B.counts,W=E(U.completed??0,U.failed??0),G=[...z.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(r,{to:`/queues-classic`,"aria-label":`Back to classic queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,F.jsx)(c,{className:`size-4`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,F.jsx)(y,{label:B.paused?`Paused`:`Active`,tone:B.paused?`amber`:`green`}),(0,F.jsx)(y,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B.paused?(0,F.jsxs)(m,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>R(`resume`,()=>f.resume(e)),children:[(0,F.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,F.jsxs)(m,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>R(`pause`,()=>f.pause(e)),children:[(0,F.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,F.jsx)(m,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,F.jsx)(m,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),o&&(0,F.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:o}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,F.jsx)(D,{label:`Waiting`,value:T(U.waiting),tone:`amber`}),(0,F.jsx)(D,{label:`Active`,value:T(U.active),tone:`blue`}),(0,F.jsx)(D,{label:`Completed`,value:T(U.completed),tone:`green`}),(0,F.jsx)(D,{label:`Failed`,value:T(U.failed),tone:U.failed?`red`:`default`}),(0,F.jsx)(D,{label:`Delayed`,value:T(U.delayed),tone:`default`}),(0,F.jsx)(D,{label:`Error Rate`,value:W==null?`—`:S(W),tone:W==null?`default`:W>.05?`red`:`green`})]}),(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,F.jsxs)(r,{to:`/jobs-classic?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,F.jsx)(u,{className:`size-3.5`})]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,F.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,F.jsx)(`tbody`,{children:z.recentJobsError?(0,F.jsx)(`tr`,{children:(0,F.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,z.recentJobsError,`. Retry the page.`]})}):G.length===0?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.map(e=>(0,F.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,F.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,F.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e.id})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,F.jsx)(`td`,{className:`px-5 py-3`,children:(0,F.jsx)(b,{status:String(e.state??e.status??`waiting`)})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:x(C(e.startedAt,e.completedAt))}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,F.jsx)(I,{queue:e})]})}export{U as QueueDetail};