bunqueue-dashboard 1.0.2 → 1.0.3

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 (82) hide show
  1. package/README.md +8 -7
  2. package/agent/manager/config.ts +2 -1
  3. package/agent/server/handler.ts +2 -1
  4. package/agent/server/router.ts +1 -0
  5. package/agent/server/types.ts +1 -1
  6. package/agent/workflow/runtime.ts +25 -7
  7. package/agent/workflow/runtimeRoutes.ts +4 -1
  8. package/dist/.vite/manifest.json +500 -489
  9. package/dist/assets/{AddJob-CiwWycYG.js → AddJob-jq-VZ_YE.js} +1 -1
  10. package/dist/assets/{Alerts-DCKl_C8D.js → Alerts-Bi8zLKXV.js} +1 -1
  11. package/dist/assets/{AreaChart-Db2UVnaK.js → AreaChart-BMYp7z5y.js} +1 -1
  12. package/dist/assets/{Benchmark-DyHvEM8x.js → Benchmark-CWYdqm55.js} +1 -1
  13. package/dist/assets/{BulkAddJobs-GRMVnf0j.js → BulkAddJobs-0cdWqkEF.js} +1 -1
  14. package/dist/assets/{Button-_aSJvRoW.js → Button-BCjgbAhY.js} +1 -1
  15. package/dist/assets/{Card-egIDLwVk.js → Card-DptfvL2O.js} +1 -1
  16. package/dist/assets/{Cron-XL0PdUEc.js → Cron-dPGwJXqY.js} +1 -1
  17. package/dist/assets/{CronManager-Cqtg9Zr8.js → CronManager-C0-Y2QDg.js} +1 -1
  18. package/dist/assets/{Database-BBzyi7f0.js → Database-CseJOrvD.js} +1 -1
  19. package/dist/assets/{Diagnostics-E_icHggb.js → Diagnostics-cZTy4Y2t.js} +1 -1
  20. package/dist/assets/{Dlq-DNs32CzV.js → Dlq-W2xOJiZM.js} +1 -1
  21. package/dist/assets/{DlqControl-DawwIsTI.js → DlqControl-CIV5278D.js} +1 -1
  22. package/dist/assets/DlqPro-BuRxGtGt.js +1 -0
  23. package/dist/assets/{Fleet-Bkbq0dFB.js → Fleet-0zKJSjCw.js} +1 -1
  24. package/dist/assets/{Flows-DKZxI7ta.js → Flows-CEfm102Y.js} +1 -1
  25. package/dist/assets/{JobInspector-BARE52q3.js → JobInspector-BlMj5-Vr.js} +1 -1
  26. package/dist/assets/{Jobs-CKzKpQ7i.js → Jobs-D_TId_Oa.js} +1 -1
  27. package/dist/assets/JobsPro-A06ZG5Xi.js +1 -0
  28. package/dist/assets/{Logs-Bj60G_FP.js → Logs-hbh7XhQU.js} +1 -1
  29. package/dist/assets/{LogsPro-Hv8xwXDK.js → LogsPro-BgEIjgfj.js} +1 -1
  30. package/dist/assets/McpServer-ffXr4nFW.js +22 -0
  31. package/dist/assets/{Metrics-BBLdWOw1.js → Metrics-CIKZGgf0.js} +1 -1
  32. package/dist/assets/{MetricsPro-D470b1aP.js → MetricsPro-CK3WfLCl.js} +1 -1
  33. package/dist/assets/{Overview-B_AOa5kW.js → Overview-BBgwyUn4.js} +1 -1
  34. package/dist/assets/{PageHeader-CQzNsw8r.js → PageHeader-DD4vnVog.js} +1 -1
  35. package/dist/assets/{Pagination-CSkzhNW6.js → Pagination-Cj7GzYNX.js} +1 -1
  36. package/dist/assets/{QueueActions-BBxRt-t0.js → QueueActions-BgdW95rN.js} +1 -1
  37. package/dist/assets/{QueueControl-DaZjeZnw.js → QueueControl-g-9kwrpt.js} +1 -1
  38. package/dist/assets/{QueueDetail-Dgo9Ukmp.js → QueueDetail-Cv3MLDoE.js} +1 -1
  39. package/dist/assets/{QueueDetailPro-D7U8ahp2.js → QueueDetailPro-AhdOAzEF.js} +1 -1
  40. package/dist/assets/{Queues-CS8LeZtJ.js → Queues-Bbvh_OCE.js} +1 -1
  41. package/dist/assets/{QueuesOverview-BySSnCm0.js → QueuesOverview-sPQILfMU.js} +1 -1
  42. package/dist/assets/{S3Backup-Ci4dJPP_.js → S3Backup-Cg6sc2JG.js} +1 -1
  43. package/dist/assets/{S3BackupPro-UwWu0yxr.js → S3BackupPro-BWV_R_Vj.js} +1 -1
  44. package/dist/assets/ServerControl-Dr2gXbaU.js +3 -0
  45. package/dist/assets/{Settings-FOzwrB25.js → Settings-BsDDlu-h.js} +1 -1
  46. package/dist/assets/{StatusBadge-DereLzOj.js → StatusBadge-cYUkK-4P.js} +1 -1
  47. package/dist/assets/{Usage-DR90dCt0.js → Usage-Cxx6pZfb.js} +1 -1
  48. package/dist/assets/{UsagePro-DAlE3oCE.js → UsagePro-CkC8WYcS.js} +1 -1
  49. package/dist/assets/{Webhooks-BonYUgMo.js → Webhooks-BKWnALGC.js} +1 -1
  50. package/dist/assets/{Workers-D1Ead02h.js → Workers-SJ9MApx3.js} +1 -1
  51. package/dist/assets/WorkersPro-BDgHBTpY.js +1 -0
  52. package/dist/assets/Workflows-Cp6jqKeM.js +1 -0
  53. package/dist/assets/{api-D9aT0ND7.js → api-Bbo86MB6.js} +1 -1
  54. package/dist/assets/{bq-DR2BTISO.js → bq-CSX8DSME.js} +1 -1
  55. package/dist/assets/{classicJobsData-Csj4iihY.js → classicJobsData-BimIyQky.js} +1 -1
  56. package/dist/assets/{connectionStore-CVjQyIZv.js → connectionStore-DdLzJyut.js} +1 -1
  57. package/dist/assets/{controlConnectionEpoch-ChAeMMLk.js → controlConnectionEpoch-D4HtriLM.js} +1 -1
  58. package/dist/assets/{feedback-CtGN_kqB.js → feedback-Dxfj-Fy1.js} +1 -1
  59. package/dist/assets/{form-DG3X6cLL.js → form-Dy-an7ew.js} +1 -1
  60. package/dist/assets/{icons-DH9SS1DA.js → icons-C1HVBnFn.js} +1 -1
  61. package/dist/assets/{index-DZFZr0Mi.js → index-CxzFSZj3.js} +3 -3
  62. package/dist/assets/index-DZXf58c2.css +1 -0
  63. package/dist/assets/install-DUkXE5kb.js +3 -0
  64. package/dist/assets/package-C7CtgBEy.js +1 -0
  65. package/dist/assets/react-vendor-DfC0iyIS.js +11 -0
  66. package/dist/assets/{toastStore-XmMX7A5W.js → toastStore-DnqA_aL-.js} +1 -1
  67. package/dist/assets/{useControlActionGuard-1i7aFA7E.js → useControlActionGuard-DImMgJtj.js} +1 -1
  68. package/dist/assets/{usePolledData-CEyyLRYa.js → usePolledData-Dp_ynL9f.js} +1 -1
  69. package/dist/assets/{useServerActionGuard-CUx8TOAC.js → useServerActionGuard-Cr4KUOeZ.js} +1 -1
  70. package/dist/assets/{useThroughputSeries-CeFx-Mwq.js → useThroughputSeries-CrTeR9s3.js} +1 -1
  71. package/dist/index.html +14 -14
  72. package/package.json +21 -24
  73. package/scripts/embedded.gen.ts +156 -154
  74. package/dist/assets/DlqPro-BEdxFiNN.js +0 -1
  75. package/dist/assets/JobsPro-DxDw-akG.js +0 -1
  76. package/dist/assets/McpServer-zxSMjG8K.js +0 -24
  77. package/dist/assets/ServerControl-Ch1wZcKB.js +0 -3
  78. package/dist/assets/WorkersPro-XuLxtU4A.js +0 -1
  79. package/dist/assets/Workflows-CqZZ96EK.js +0 -1
  80. package/dist/assets/index-DaEyLvTR.css +0 -1
  81. package/dist/assets/install-oydLpc1T.js +0 -3
  82. package/dist/assets/react-vendor-CFL9l8LK.js +0 -11
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{u as r}from"./icons-DH9SS1DA.js";import{t as i}from"./api-D9aT0ND7.js";import{n as a}from"./usePolledData-CEyyLRYa.js";import{t as o}from"./Button-_aSJvRoW.js";import{i as s,n as c,r as l,t as u}from"./feedback-CtGN_kqB.js";import{t as d}from"./PageHeader-CQzNsw8r.js";import{l as f,s as p}from"./format-Cg7VCIZW.js";import{r as m}from"./index-DZFZr0Mi.js";import{a as h}from"./form-DG3X6cLL.js";import{t as g}from"./Pagination-CSkzhNW6.js";import{r as _,t as v}from"./flowMutationSafety-YKTHxqKv.js";import{i as y,r as b}from"./classicJobsData-Csj4iihY.js";import"./Jobs-CKzKpQ7i.js";var x=e(t(),1),S=n(),C=25;function w(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}async function T(){let e=await b();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!w(e.waiting)||!w(e.delayed)||!w(e.active)||!w(e.dlq)||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function E(){let[e,t]=(0,x.useState)(``),[n,b]=(0,x.useState)(0),{data:w,error:E,loading:D,refetch:O}=a(T,[],{intervalMs:3e4});(0,x.useEffect)(()=>{if(e||!w?.queues?.length)return;let n=w.queues.find(e=>e.dlq>0)??w.queues[0];t(n.name)},[w,e]);let{data:k,error:A,loading:j,refetch:M}=a((0,x.useCallback)(async()=>{if(!e)return{entries:[],total:0};let t=await i.dlq(e,C,n*C);return{entries:t.entries??[],total:t.total??t.entries?.length??0}},[e,n]),[e,n]),N=k?.entries??[];return(0,S.jsxs)(`div`,{children:[A&&k&&(0,S.jsx)(s,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:M}),E&&(0,S.jsx)(s,{onRetry:O,message:`Could not discover queues — ${E.message}. Retry before selecting a queue.`}),(0,S.jsx)(d,{title:`Dead Letter Queue`,description:`Jobs that exhausted their retries.`,live:!!e&&!!k&&!A&&!E,actions:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{size:`sm`,disabled:!0,title:v,children:`Retry all`}),(0,S.jsx)(o,{variant:`danger`,size:`sm`,disabled:!0,title:_,children:`Purge`})]})}),(0,S.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`w-56`,children:(0,S.jsx)(h,{value:e,"aria-label":`Queue`,name:`classic-dlq-queue`,autoComplete:`off`,onChange:e=>{t(e.target.value),b(0)},children:(w?.queues??[]).map(e=>(0,S.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,S.jsx)(`div`,{className:`w-40`,children:(0,S.jsx)(m,{label:`DLQ Entries`,value:e&&k?p(k.total):`—`,tone:e&&k?.total?`red`:`default`,compact:!0})})]}),A&&!k?(0,S.jsx)(c,{error:A,onRetry:M}):D&&!w&&!e&&!E?(0,S.jsx)(l,{label:`Discovering queues…`}):j&&!k&&!A?(0,S.jsx)(l,{label:`Loading DLQ…`}):E&&!e?(0,S.jsx)(u,{icon:(0,S.jsx)(r,{}),title:`Could not discover queues`,hint:`${E.message}. Retry the queue discovery request above.`}):e?N.length===0?(0,S.jsx)(u,{icon:(0,S.jsx)(r,{}),title:`Dead letter queue is empty`,hint:`Jobs land here after exhausting their retry attempts.`}):(0,S.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,S.jsx)(`tbody`,{children:N.map((e,t)=>(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.id}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.job.name??y(e.job.data)??`default`}),(0,S.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-red-400/90`,children:String(e.reason||e.error||`—`)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.attempts?.length??e.job.attempts??`—`}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:f(e.attempts?.at(-1)?.failedAt??e.enteredAt)})]},e.job.id||t))})]})}):(0,S.jsx)(u,{icon:(0,S.jsx)(r,{}),title:w?.queues.length===0?`No queues available`:`Select a queue`,hint:`A queue must be selected before its dead letter entries can be inspected.`}),k&&(0,S.jsx)(g,{page:n,pageSize:C,total:k.total,onPageChange:b,label:`entries`})]})}export{E as Dlq};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{u as r}from"./icons-C1HVBnFn.js";import{t as i}from"./api-Bbo86MB6.js";import{n as a}from"./usePolledData-Dp_ynL9f.js";import{t as o}from"./Button-BCjgbAhY.js";import{i as s,n as c,r as l,t as u}from"./feedback-Dxfj-Fy1.js";import{t as d}from"./PageHeader-DD4vnVog.js";import{l as f,s as p}from"./format-Cg7VCIZW.js";import{r as m}from"./index-CxzFSZj3.js";import{a as h}from"./form-Dy-an7ew.js";import{t as g}from"./Pagination-Cj7GzYNX.js";import{r as _,t as v}from"./flowMutationSafety-YKTHxqKv.js";import{i as y,r as b}from"./classicJobsData-BimIyQky.js";import"./Jobs-D_TId_Oa.js";var x=e(t(),1),S=n(),C=25;function w(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}async function T(){let e=await b();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!w(e.waiting)||!w(e.delayed)||!w(e.active)||!w(e.dlq)||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function E(){let[e,t]=(0,x.useState)(``),[n,b]=(0,x.useState)(0),{data:w,error:E,loading:D,refetch:O}=a(T,[],{intervalMs:3e4});(0,x.useEffect)(()=>{if(e||!w?.queues?.length)return;let n=w.queues.find(e=>e.dlq>0)??w.queues[0];t(n.name)},[w,e]);let{data:k,error:A,loading:j,refetch:M}=a((0,x.useCallback)(async()=>{if(!e)return{entries:[],total:0};let t=await i.dlq(e,C,n*C);return{entries:t.entries??[],total:t.total??t.entries?.length??0}},[e,n]),[e,n]),N=k?.entries??[];return(0,S.jsxs)(`div`,{children:[A&&k&&(0,S.jsx)(s,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:M}),E&&(0,S.jsx)(s,{onRetry:O,message:`Could not discover queues — ${E.message}. Retry before selecting a queue.`}),(0,S.jsx)(d,{title:`Dead Letter Queue`,description:`Jobs that exhausted their retries.`,live:!!e&&!!k&&!A&&!E,actions:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{size:`sm`,disabled:!0,title:v,children:`Retry all`}),(0,S.jsx)(o,{variant:`danger`,size:`sm`,disabled:!0,title:_,children:`Purge`})]})}),(0,S.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`w-56`,children:(0,S.jsx)(h,{value:e,"aria-label":`Queue`,name:`classic-dlq-queue`,autoComplete:`off`,onChange:e=>{t(e.target.value),b(0)},children:(w?.queues??[]).map(e=>(0,S.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,S.jsx)(`div`,{className:`w-40`,children:(0,S.jsx)(m,{label:`DLQ Entries`,value:e&&k?p(k.total):`—`,tone:e&&k?.total?`red`:`default`,compact:!0})})]}),A&&!k?(0,S.jsx)(c,{error:A,onRetry:M}):D&&!w&&!e&&!E?(0,S.jsx)(l,{label:`Discovering queues…`}):j&&!k&&!A?(0,S.jsx)(l,{label:`Loading DLQ…`}):E&&!e?(0,S.jsx)(u,{icon:(0,S.jsx)(r,{}),title:`Could not discover queues`,hint:`${E.message}. Retry the queue discovery request above.`}):e?N.length===0?(0,S.jsx)(u,{icon:(0,S.jsx)(r,{}),title:`Dead letter queue is empty`,hint:`Jobs land here after exhausting their retry attempts.`}):(0,S.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,S.jsx)(`tbody`,{children:N.map((e,t)=>(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.id}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.job.name??y(e.job.data)??`default`}),(0,S.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-red-400/90`,children:String(e.reason||e.error||`—`)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.attempts?.length??e.job.attempts??`—`}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:f(e.attempts?.at(-1)?.failedAt??e.enteredAt)})]},e.job.id||t))})]})}):(0,S.jsx)(u,{icon:(0,S.jsx)(r,{}),title:w?.queues.length===0?`No queues available`:`Select a queue`,hint:`A queue must be selected before its dead letter entries can be inspected.`}),k&&(0,S.jsx)(g,{page:n,pageSize:C,total:k.total,onPageChange:b,label:`entries`})]})}export{E as Dlq};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{t as i}from"./bq-DR2BTISO.js";import{t as a}from"./toastStore-XmMX7A5W.js";import{C as o,T as s,a as c,d as l,f as u,u as d}from"./icons-DH9SS1DA.js";import{r as f}from"./StatusBadge-DereLzOj.js";import{n as p}from"./usePolledData-CEyyLRYa.js";import{n as m,t as h}from"./Button-_aSJvRoW.js";import{i as g,n as _,r as v,t as y}from"./feedback-CtGN_kqB.js";import{t as b}from"./PageHeader-CQzNsw8r.js";import{a as x,i as S,l as C,s as w}from"./format-Cg7VCIZW.js";import{a as T,r as E}from"./index-DZFZr0Mi.js";import{a as D}from"./form-DG3X6cLL.js";import{t as O}from"./Pagination-CSkzhNW6.js";import{r as k,t as A}from"./flowMutationSafety-YKTHxqKv.js";import{t as j}from"./exportFile-C7xhE8Yh.js";import{t as M}from"./QueueControl-DaZjeZnw.js";var N=e(t(),1),P=r();function F({queue:e,data:t,reasons:n,topReason:r}){return(0,P.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,P.jsx)(E,{label:`Entries`,value:e&&t?w(t.total):`—`,tone:!e||!t?`default`:t.total?`red`:`green`,hint:!e||!t?`waiting for queue data`:t.total?r?`top: ${r}`:void 0:`queue is clean`,compact:!0}),(0,P.jsx)(E,{label:`Failure types`,value:t?.stats?w(n.length):`—`,hint:`distinct reasons`,compact:!0}),(0,P.jsx)(E,{label:`Pending retry`,value:t?.stats?w(t.stats.pendingRetry??0):`—`,tone:t?.stats?.pendingRetry?`amber`:`default`,hint:`auto-retry queued`,compact:!0}),(0,P.jsx)(E,{label:`Oldest entry`,value:t?.stats?.oldestEntry?C(t.stats.oldestEntry):`—`,hint:`time in DLQ`,compact:!0})]})}function I({queue:e,queues:t,reason:n,reasons:r,byReason:i,search:a,pageScoped:o,onQueue:c,onReason:l,onSearch:u}){return(0,P.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,P.jsx)(`div`,{className:`w-56`,children:(0,P.jsx)(D,{value:e,"aria-label":`Queue`,name:`dlq-control-queue`,autoComplete:`off`,onChange:e=>c(e.target.value),children:t.map(e=>(0,P.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,P.jsx)(`div`,{className:`w-44`,children:(0,P.jsxs)(D,{value:n,"aria-label":`Filter by reason`,name:`dlq-control-reason`,autoComplete:`off`,onChange:e=>l(e.target.value),children:[(0,P.jsx)(`option`,{value:`all`,children:`All reasons`}),r.map(e=>(0,P.jsxs)(`option`,{value:e,children:[e,` (`,i[e],`)`]},e))]})}),(0,P.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,P.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,P.jsx)(`input`,{value:a,onChange:e=>u(e.target.value),placeholder:o?`Filter this page by job ID…`:`Filter by job ID…`,"aria-label":`Filter by job ID`,name:`dlq-control-job-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`})]})]})}function L({entry:e,isOpen:t,onToggle:r,attempts:i}){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`tr`,{className:`border-b border-line align-top last:border-0 hover:bg-surface-2/40`,children:[(0,P.jsx)(`td`,{className:`py-3 pl-4`,children:(0,P.jsx)(m,{"aria-label":t?`Collapse details`:`Expand details`,"aria-expanded":t,onClick:r,children:(0,P.jsx)(c,{className:f(`size-3.5 transition-transform`,t&&`rotate-90`)})})}),(0,P.jsx)(`td`,{className:`px-3 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(n,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`max-w-[14rem] truncate font-mono text-xs text-accent hover:underline`,title:e.job.id,children:e.job.id}),(0,P.jsx)(T,{value:e.job.id})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`span`,{className:`inline-block rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`span`,{className:`block max-w-md truncate text-xs text-danger/80`,title:e.error??``,children:e.error||`—`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right tnum text-muted`,children:e.job.attempts??i.length}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right text-faint`,title:S(e.enteredAt),children:C(e.enteredAt)}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,P.jsx)(n,{to:`/job?id=${encodeURIComponent(e.job.id)}`,"aria-label":`Inspect job ${e.job.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,P.jsx)(u,{className:`size-3.5`})}),(0,P.jsx)(m,{"aria-label":`Retry job unavailable`,disabled:!0,title:A,children:(0,P.jsx)(o,{className:`size-3.5`})})]})})]}),t&&(0,P.jsxs)(`tr`,{className:`border-b border-line bg-surface-2/30 last:border-0`,children:[(0,P.jsx)(`td`,{}),(0,P.jsxs)(`td`,{colSpan:7,className:`px-3 pb-4 pt-1`,children:[e.error&&(0,P.jsxs)(`div`,{className:`mb-3`,children:[(0,P.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Error`}),(0,P.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-lg bg-surface p-3 font-mono text-xs text-danger/90`,children:e.error})]}),(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Failure history`,typeof e.retryCount==`number`&&e.retryCount>0&&(0,P.jsxs)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] normal-case text-muted`,children:[`retried `,e.retryCount,`×`]})]}),i.length===0?(0,P.jsx)(`p`,{className:`text-xs text-faint`,children:`No per-attempt history recorded.`}):(0,P.jsx)(`ol`,{className:`space-y-1.5`,children:i.map(e=>(0,P.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-0.5 rounded-lg border border-line bg-surface px-3 py-2 text-xs`,children:[(0,P.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Attempt `,e.attempt]}),(0,P.jsx)(`span`,{className:`text-faint`,title:S(e.failedAt),children:C(e.failedAt)}),e.duration!=null&&(0,P.jsx)(`span`,{className:`tnum text-muted`,children:x(e.duration)}),e.reason&&(0,P.jsx)(`span`,{className:`rounded bg-red-500/10 px-1.5 text-danger`,children:e.reason}),e.error&&(0,P.jsx)(`span`,{className:`w-full truncate text-danger/70`,children:e.error})]},`${e.attempt}-${e.failedAt}`))})]})]})]})}var R=25,z={},B=[],V=e=>`${e.job.id}-${e.enteredAt}`;function H(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(0),[s,c]=(0,N.useState)(`all`),[u,f]=(0,N.useState)(``),[m,x]=(0,N.useState)(new Set),{data:S,error:C,loading:w,refetch:T}=p(M,[],{intervalMs:3e4});(0,N.useEffect)(()=>{if(e&&S&&!S.queues.some(t=>t.name===e)){t(``),r(0),c(`all`),f(``);return}e||!S?.queues?.length||t((S.queues.find(e=>e.dlq>0)??S.queues[0]).name)},[S,e]);let{data:E,error:D,loading:H,refetch:U}=p((0,N.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0,stats:null,statsError:null};let[t,r]=await Promise.all([i.dlq(e,R,n*R),i.dlqStats(e).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:e,page:n,entries:t.entries??[],total:t.total??0,stats:r.stats,statsError:r.error}},[e,n]),[e,n]),W=E?.queue===e&&E.page===n?E:null;(0,N.useEffect)(()=>{if(!W)return;let e=Math.max(0,Math.ceil((W.total??0)/R)-1);n>e&&r(e)},[W,n]),(0,N.useEffect)(()=>{x(new Set)},[e,n]);let G=W?.stats?.byReason??z,K=(0,N.useMemo)(()=>Object.keys(G).filter(e=>G[e]>0),[G]),q=(0,N.useMemo)(()=>[...K].sort((e,t)=>(G[t]??0)-(G[e]??0))[0],[K,G]);(0,N.useEffect)(()=>{s!==`all`&&W&&!K.includes(s)&&c(`all`)},[W,s,K]);let J=W?.entries??B,Y=(0,N.useMemo)(()=>{let e=J;s!==`all`&&(e=e.filter(e=>e.reason===s));let t=u.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[J,s,u]),X=s!==`all`||u.trim()!==``,Z=(W?.total??0)>R,Q=e=>x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(b,{title:`DLQ Control`,description:`Inspect and triage one queue's dead-lettered jobs.`,live:!!e&&!!W&&!W.statsError&&!D&&!C,actions:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(h,{size:`sm`,disabled:!e||!Y.length,onClick:()=>{if(Y.length===0){a.info(`Nothing to export`);return}j(`dlq-${e}`,Y.map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,attempts:e.job.attempts??e.attempts?.length??``,enteredAt:new Date(e.enteredAt).toISOString()})),[`jobId`,`reason`,`error`,`attempts`,`enteredAt`])},children:[(0,P.jsx)(l,{className:`size-3.5`}),` Export`]}),(0,P.jsxs)(h,{size:`sm`,disabled:!0,title:A,children:[(0,P.jsx)(o,{className:`size-3.5`}),` Retry all`]}),(0,P.jsx)(h,{variant:`danger`,size:`sm`,disabled:!0,title:k,children:`Purge`})]})}),D&&W&&(0,P.jsx)(g,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:U}),C&&(0,P.jsx)(g,{onRetry:T,message:`Could not discover queues — ${C.message}. Retry before selecting a queue.`}),W?.statsError&&(0,P.jsx)(g,{message:`DLQ statistics are unavailable — ${W.statsError}. The entry list may still be current.`,onRetry:U}),(0,P.jsx)(F,{queue:e,data:W,reasons:K,topReason:q}),(0,P.jsx)(I,{queue:e,queues:S?.queues??[],reason:s,reasons:K,byReason:G,search:u,pageScoped:Z,onQueue:e=>{t(e),r(0),c(`all`),f(``)},onReason:c,onSearch:f}),(0,P.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:A}),D&&!W?(0,P.jsx)(_,{error:D,onRetry:U}):w&&!S&&!e&&!C?(0,P.jsx)(v,{label:`Discovering queues…`}):H&&!W&&!D?(0,P.jsx)(v,{label:`Loading DLQ…`}):C&&!e?(0,P.jsx)(y,{icon:(0,P.jsx)(d,{}),title:`Could not discover queues`,hint:`${C.message}. Retry the queue discovery request above.`}):e?Y.length===0?(0,P.jsx)(y,{icon:(0,P.jsx)(d,{}),title:X?`No matches`:`Dead letter queue is empty`,hint:X?Z?`No entries on this page match your filter — filters are page-scoped. Try another page or clear them.`:`No entries match your filter. Clear it to see all entries.`:`Failed jobs that exhaust their retries land here.`}):(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,P.jsx)(`th`,{className:`w-8 py-3 pl-4`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Name`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Job ID`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Reason`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Error`}),(0,P.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Attempts`}),(0,P.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Entered`}),(0,P.jsx)(`th`,{className:`w-20 px-4 py-3`})]})}),(0,P.jsx)(`tbody`,{children:Y.map(e=>{let t=V(e);return(0,P.jsx)(L,{entry:e,isOpen:m.has(t),onToggle:()=>Q(t),attempts:e.attempts??[]},t)})})]})}):(0,P.jsx)(y,{icon:(0,P.jsx)(d,{}),title:S?.queues.length===0?`No queues available`:`Select a queue`,hint:`A queue must be selected before its dead letter entries can be inspected.`}),W&&(0,P.jsx)(O,{page:n,pageSize:R,total:W.total,onPageChange:r,label:`entries`})]})}export{H as DlqControl};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-DfC0iyIS.js";import{t as i}from"./bq-CSX8DSME.js";import{t as a}from"./toastStore-DnqA_aL-.js";import{C as o,T as s,a as c,d as l,f as u,u as d}from"./icons-C1HVBnFn.js";import{r as f}from"./StatusBadge-cYUkK-4P.js";import{n as p}from"./usePolledData-Dp_ynL9f.js";import{n as m,t as h}from"./Button-BCjgbAhY.js";import{i as g,n as _,r as v,t as y}from"./feedback-Dxfj-Fy1.js";import{t as b}from"./PageHeader-DD4vnVog.js";import{a as x,i as S,l as C,s as w}from"./format-Cg7VCIZW.js";import{a as T,r as E}from"./index-CxzFSZj3.js";import{a as D}from"./form-Dy-an7ew.js";import{t as O}from"./Pagination-Cj7GzYNX.js";import{r as k,t as A}from"./flowMutationSafety-YKTHxqKv.js";import{t as j}from"./exportFile-C7xhE8Yh.js";import{t as M}from"./QueueControl-g-9kwrpt.js";var N=e(t(),1),P=r();function F({queue:e,data:t,reasons:n,topReason:r}){return(0,P.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,P.jsx)(E,{label:`Entries`,value:e&&t?w(t.total):`—`,tone:!e||!t?`default`:t.total?`red`:`green`,hint:!e||!t?`waiting for queue data`:t.total?r?`top: ${r}`:void 0:`queue is clean`,compact:!0}),(0,P.jsx)(E,{label:`Failure types`,value:t?.stats?w(n.length):`—`,hint:`distinct reasons`,compact:!0}),(0,P.jsx)(E,{label:`Pending retry`,value:t?.stats?w(t.stats.pendingRetry??0):`—`,tone:t?.stats?.pendingRetry?`amber`:`default`,hint:`auto-retry queued`,compact:!0}),(0,P.jsx)(E,{label:`Oldest entry`,value:t?.stats?.oldestEntry?C(t.stats.oldestEntry):`—`,hint:`time in DLQ`,compact:!0})]})}function I({queue:e,queues:t,reason:n,reasons:r,byReason:i,search:a,pageScoped:o,onQueue:c,onReason:l,onSearch:u}){return(0,P.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,P.jsx)(`div`,{className:`w-56`,children:(0,P.jsx)(D,{value:e,"aria-label":`Queue`,name:`dlq-control-queue`,autoComplete:`off`,onChange:e=>c(e.target.value),children:t.map(e=>(0,P.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,P.jsx)(`div`,{className:`w-44`,children:(0,P.jsxs)(D,{value:n,"aria-label":`Filter by reason`,name:`dlq-control-reason`,autoComplete:`off`,onChange:e=>l(e.target.value),children:[(0,P.jsx)(`option`,{value:`all`,children:`All reasons`}),r.map(e=>(0,P.jsxs)(`option`,{value:e,children:[e,` (`,i[e],`)`]},e))]})}),(0,P.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,P.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,P.jsx)(`input`,{value:a,onChange:e=>u(e.target.value),placeholder:o?`Filter this page by job ID…`:`Filter by job ID…`,"aria-label":`Filter by job ID`,name:`dlq-control-job-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`})]})]})}function L({entry:e,isOpen:t,onToggle:r,attempts:i}){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`tr`,{className:`border-b border-line align-top last:border-0 hover:bg-surface-2/40`,children:[(0,P.jsx)(`td`,{className:`py-3 pl-4`,children:(0,P.jsx)(m,{"aria-label":t?`Collapse details`:`Expand details`,"aria-expanded":t,onClick:r,children:(0,P.jsx)(c,{className:f(`size-3.5 transition-transform`,t&&`rotate-90`)})})}),(0,P.jsx)(`td`,{className:`px-3 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(n,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`max-w-[14rem] truncate font-mono text-xs text-accent hover:underline`,title:e.job.id,children:e.job.id}),(0,P.jsx)(T,{value:e.job.id})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`span`,{className:`inline-block rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`span`,{className:`block max-w-md truncate text-xs text-danger/80`,title:e.error??``,children:e.error||`—`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right tnum text-muted`,children:e.job.attempts??i.length}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right text-faint`,title:S(e.enteredAt),children:C(e.enteredAt)}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,P.jsx)(n,{to:`/job?id=${encodeURIComponent(e.job.id)}`,"aria-label":`Inspect job ${e.job.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,P.jsx)(u,{className:`size-3.5`})}),(0,P.jsx)(m,{"aria-label":`Retry job unavailable`,disabled:!0,title:A,children:(0,P.jsx)(o,{className:`size-3.5`})})]})})]}),t&&(0,P.jsxs)(`tr`,{className:`border-b border-line bg-surface-2/30 last:border-0`,children:[(0,P.jsx)(`td`,{}),(0,P.jsxs)(`td`,{colSpan:7,className:`px-3 pb-4 pt-1`,children:[e.error&&(0,P.jsxs)(`div`,{className:`mb-3`,children:[(0,P.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Error`}),(0,P.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-lg bg-surface p-3 font-mono text-xs text-danger/90`,children:e.error})]}),(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Failure history`,typeof e.retryCount==`number`&&e.retryCount>0&&(0,P.jsxs)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] normal-case text-muted`,children:[`retried `,e.retryCount,`×`]})]}),i.length===0?(0,P.jsx)(`p`,{className:`text-xs text-faint`,children:`No per-attempt history recorded.`}):(0,P.jsx)(`ol`,{className:`space-y-1.5`,children:i.map(e=>(0,P.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-0.5 rounded-lg border border-line bg-surface px-3 py-2 text-xs`,children:[(0,P.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Attempt `,e.attempt]}),(0,P.jsx)(`span`,{className:`text-faint`,title:S(e.failedAt),children:C(e.failedAt)}),e.duration!=null&&(0,P.jsx)(`span`,{className:`tnum text-muted`,children:x(e.duration)}),e.reason&&(0,P.jsx)(`span`,{className:`rounded bg-red-500/10 px-1.5 text-danger`,children:e.reason}),e.error&&(0,P.jsx)(`span`,{className:`w-full truncate text-danger/70`,children:e.error})]},`${e.attempt}-${e.failedAt}`))})]})]})]})}var R=25,z={},B=[],V=e=>`${e.job.id}-${e.enteredAt}`;function H(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(0),[s,c]=(0,N.useState)(`all`),[u,f]=(0,N.useState)(``),[m,x]=(0,N.useState)(new Set),{data:S,error:C,loading:w,refetch:T}=p(M,[],{intervalMs:3e4});(0,N.useEffect)(()=>{if(e&&S&&!S.queues.some(t=>t.name===e)){t(``),r(0),c(`all`),f(``);return}e||!S?.queues?.length||t((S.queues.find(e=>e.dlq>0)??S.queues[0]).name)},[S,e]);let{data:E,error:D,loading:H,refetch:U}=p((0,N.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0,stats:null,statsError:null};let[t,r]=await Promise.all([i.dlq(e,R,n*R),i.dlqStats(e).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:e,page:n,entries:t.entries??[],total:t.total??0,stats:r.stats,statsError:r.error}},[e,n]),[e,n]),W=E?.queue===e&&E.page===n?E:null;(0,N.useEffect)(()=>{if(!W)return;let e=Math.max(0,Math.ceil((W.total??0)/R)-1);n>e&&r(e)},[W,n]),(0,N.useEffect)(()=>{x(new Set)},[e,n]);let G=W?.stats?.byReason??z,K=(0,N.useMemo)(()=>Object.keys(G).filter(e=>G[e]>0),[G]),q=(0,N.useMemo)(()=>[...K].sort((e,t)=>(G[t]??0)-(G[e]??0))[0],[K,G]);(0,N.useEffect)(()=>{s!==`all`&&W&&!K.includes(s)&&c(`all`)},[W,s,K]);let J=W?.entries??B,Y=(0,N.useMemo)(()=>{let e=J;s!==`all`&&(e=e.filter(e=>e.reason===s));let t=u.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[J,s,u]),X=s!==`all`||u.trim()!==``,Z=(W?.total??0)>R,Q=e=>x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(b,{title:`DLQ Control`,description:`Inspect and triage one queue's dead-lettered jobs.`,live:!!e&&!!W&&!W.statsError&&!D&&!C,actions:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(h,{size:`sm`,disabled:!e||!Y.length,onClick:()=>{if(Y.length===0){a.info(`Nothing to export`);return}j(`dlq-${e}`,Y.map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,attempts:e.job.attempts??e.attempts?.length??``,enteredAt:new Date(e.enteredAt).toISOString()})),[`jobId`,`reason`,`error`,`attempts`,`enteredAt`])},children:[(0,P.jsx)(l,{className:`size-3.5`}),` Export`]}),(0,P.jsxs)(h,{size:`sm`,disabled:!0,title:A,children:[(0,P.jsx)(o,{className:`size-3.5`}),` Retry all`]}),(0,P.jsx)(h,{variant:`danger`,size:`sm`,disabled:!0,title:k,children:`Purge`})]})}),D&&W&&(0,P.jsx)(g,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:U}),C&&(0,P.jsx)(g,{onRetry:T,message:`Could not discover queues — ${C.message}. Retry before selecting a queue.`}),W?.statsError&&(0,P.jsx)(g,{message:`DLQ statistics are unavailable — ${W.statsError}. The entry list may still be current.`,onRetry:U}),(0,P.jsx)(F,{queue:e,data:W,reasons:K,topReason:q}),(0,P.jsx)(I,{queue:e,queues:S?.queues??[],reason:s,reasons:K,byReason:G,search:u,pageScoped:Z,onQueue:e=>{t(e),r(0),c(`all`),f(``)},onReason:c,onSearch:f}),(0,P.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:A}),D&&!W?(0,P.jsx)(_,{error:D,onRetry:U}):w&&!S&&!e&&!C?(0,P.jsx)(v,{label:`Discovering queues…`}):H&&!W&&!D?(0,P.jsx)(v,{label:`Loading DLQ…`}):C&&!e?(0,P.jsx)(y,{icon:(0,P.jsx)(d,{}),title:`Could not discover queues`,hint:`${C.message}. Retry the queue discovery request above.`}):e?Y.length===0?(0,P.jsx)(y,{icon:(0,P.jsx)(d,{}),title:X?`No matches`:`Dead letter queue is empty`,hint:X?Z?`No entries on this page match your filter — filters are page-scoped. Try another page or clear them.`:`No entries match your filter. Clear it to see all entries.`:`Failed jobs that exhaust their retries land here.`}):(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,P.jsx)(`th`,{className:`w-8 py-3 pl-4`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Name`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Job ID`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Reason`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Error`}),(0,P.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Attempts`}),(0,P.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Entered`}),(0,P.jsx)(`th`,{className:`w-20 px-4 py-3`})]})}),(0,P.jsx)(`tbody`,{children:Y.map(e=>{let t=V(e);return(0,P.jsx)(L,{entry:e,isOpen:m.has(t),onToggle:()=>Q(t),attempts:e.attempts??[]},t)})})]})}):(0,P.jsx)(y,{icon:(0,P.jsx)(d,{}),title:S?.queues.length===0?`No queues available`:`Select a queue`,hint:`A queue must be selected before its dead letter entries can be inspected.`}),W&&(0,P.jsx)(O,{page:n,pageSize:R,total:W.total,onPageChange:r,label:`entries`})]})}export{H as DlqControl};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,r,t as i}from"./react-vendor-DfC0iyIS.js";import{t as a}from"./bq-CSX8DSME.js";import{t as o}from"./toastStore-DnqA_aL-.js";import{C as s,d as c,u as l}from"./icons-C1HVBnFn.js";import{r as u}from"./StatusBadge-cYUkK-4P.js";import{n as d}from"./usePolledData-Dp_ynL9f.js";import{n as f,t as p}from"./Button-BCjgbAhY.js";import{t as m}from"./Card-DptfvL2O.js";import{i as h,n as ee,r as g,t as _}from"./feedback-Dxfj-Fy1.js";import{t as v}from"./PageHeader-DD4vnVog.js";import{l as y,s as b}from"./format-Cg7VCIZW.js";import{a as x}from"./form-Dy-an7ew.js";import{t as S}from"./Pagination-Cj7GzYNX.js";import{r as C,t as w}from"./flowMutationSafety-YKTHxqKv.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as T}from"./QueueControl-g-9kwrpt.js";var E=e(n(),1),D=i();function O({total:e,discoveryError:t,healthy:n,statsError:r,queue:i,topReason:a,pendingRetry:o,reasonCount:s}){return(0,D.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,D.jsxs)(m,{children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,D.jsx)(`span`,{className:u(`rounded-full px-2 py-0.5 text-[11px] font-medium`,t?`bg-amber-500/10 text-warning`:e==null?`bg-surface-2 text-muted`:n?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:t?`Unavailable`:e==null?`Loading`:n?`Healthy`:`Attention`})]}),(0,D.jsx)(`div`,{className:u(`mt-2 text-3xl font-bold tnum`,e==null||t?`text-muted`:n?`text-success`:`text-danger`),children:e==null?`—`:b(e)})]}),(0,D.jsxs)(m,{children:[(0,D.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,D.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:t||r?`Unavailable`:i?a??`No failures`:`Select a queue`})]}),(0,D.jsxs)(m,{children:[(0,D.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,D.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:o==null?`—`:b(o)}),(0,D.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:i?`in this queue`:`awaiting retry`})]}),(0,D.jsxs)(m,{children:[(0,D.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,D.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:s==null?`—`:b(s)}),(0,D.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]})}function k({queues:e,queue:t,onSelect:n}){return e.length===0?null:(0,D.jsxs)(m,{className:`mb-6`,children:[(0,D.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,D.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsxs)(p,{size:`sm`,disabled:!0,title:w,children:[(0,D.jsx)(s,{className:`size-3.5`}),` Retry all (`,e.length,` queues)`]}),(0,D.jsxs)(p,{variant:`danger`,size:`sm`,disabled:!0,title:C,children:[`Purge all (`,e.length,` queues)`]})]})]}),(0,D.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:e.map(e=>(0,D.jsxs)(`button`,{type:`button`,onClick:()=>n(e.name),className:u(`rounded-lg border p-3 text-left transition-colors`,t===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,D.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,D.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:e.dlq})]},e.name))})]})}function A({queue:e,queues:t,reason:n,reasons:r,sort:i,search:a,pageScoped:o,onQueue:l,onReason:u,onSort:d,onSearch:f,onExport:m}){return(0,D.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,D.jsx)(`div`,{className:`w-48`,children:(0,D.jsxs)(x,{value:e,"aria-label":`Queue`,name:`dlq-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Select a queue…`}),t.map(e=>(0,D.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,D.jsx)(`div`,{className:`w-40`,children:(0,D.jsxs)(x,{value:n,onChange:e=>u(e.target.value),"aria-label":`Filter by reason`,name:`dlq-reason-filter`,autoComplete:`off`,children:[(0,D.jsx)(`option`,{value:`all`,children:`All Reasons`}),r.map(e=>(0,D.jsx)(`option`,{value:e,children:e},e))]})}),(0,D.jsx)(`div`,{className:`w-36`,children:(0,D.jsxs)(x,{value:i,onChange:e=>d(e.target.value),"aria-label":o?`Sort this page`:`Sort`,name:`dlq-sort`,autoComplete:`off`,children:[(0,D.jsxs)(`option`,{value:`newest`,children:[`Newest First`,o?` (this page)`:``]}),(0,D.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,o?` (this page)`:``]})]})}),(0,D.jsx)(`input`,{value:a,onChange:e=>f(e.target.value),placeholder:`Filter this page by job ID…`,"aria-label":`Filter this page by job ID`,name:`dlq-job-filter`,autoComplete:`off`,className:`h-9 min-w-40 flex-1 rounded-lg border border-line bg-surface px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,D.jsxs)(p,{size:`sm`,disabled:!0,title:w,children:[(0,D.jsx)(s,{className:`size-3.5`}),` Retry All`]}),(0,D.jsx)(p,{variant:`danger`,size:`sm`,disabled:!0,title:C,children:`Purge All`}),(0,D.jsxs)(p,{size:`sm`,title:`Exports the visible rows in their displayed order; other pages are not included.`,disabled:!e,onClick:m,children:[(0,D.jsx)(c,{className:`size-3.5`}),` Export page CSV`]})]})}function j({entries:e,expanded:t,onToggle:n}){return(0,D.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,D.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,D.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Error`}),(0,D.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,D.jsx)(`th`,{className:`w-16 px-5 py-3`})]})}),(0,D.jsx)(`tbody`,{children:e.map(e=>{let i=`${e.job.id}-${e.enteredAt}`;return(0,D.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,D.jsx)(`td`,{className:`px-5 py-3`,children:(0,D.jsx)(r,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,D.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,D.jsx)(`td`,{className:`px-5 py-3`,children:(0,D.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,D.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,D.jsx)(`button`,{type:`button`,title:e.error,"aria-expanded":t.has(i),onClick:()=>n(i),className:u(`block w-full break-words text-left`,!t.has(i)&&`line-clamp-2`),children:e.error}):`—`}),(0,D.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:y(e.enteredAt)}),(0,D.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,D.jsx)(f,{"aria-label":`Retry unavailable`,disabled:!0,title:w,children:(0,D.jsx)(s,{className:`size-3.5`})})})]},i)})})]})})}var M=25,N=[];function P(){let[e,n]=t(),[r,i]=(0,E.useState)(``),[s,c]=(0,E.useState)(`all`),[u,f]=(0,E.useState)(`newest`),[p,m]=(0,E.useState)(``),[y,b]=(0,E.useState)(0),[x,C]=(0,E.useState)(new Set),{data:P,error:F,loading:ne,refetch:I}=d(T,[],{intervalMs:1e4}),L=P?.queues??N,R=P?L.reduce((e,t)=>e+t.dlq,0):null,{data:z,error:B,loading:V,refetch:H}=d((0,E.useCallback)(async()=>{if(!r)return{queue:r,page:y,entries:[],entriesTotal:0,stats:null,statsError:null};let[e,t]=await Promise.all([a.dlq(r,M,y*M),a.dlqStats(r).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:r,page:y,entries:e.entries??[],entriesTotal:e.total??0,stats:t.stats,statsError:t.error}},[r,y]),[r,y]),U=z?.queue===r&&z.page===y?z:null;(0,E.useEffect)(()=>{if(!U)return;let e=U.entriesTotal??0;y>0&&y*M>=e&&b(Math.max(0,Math.ceil(e/M)-1))},[U,y]);let W=()=>{let e=Q.map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,enteredAt:new Date(e.enteredAt).toISOString(),attempts:e.attempts?.length??0}));if(e.length===0){o.info(`Nothing to export on this page`);return}te(`dlq-${r}-page-${y+1}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},G=e=>{X.current=!0,i(e),b(0),c(`all`),n(e?{queue:e}:{},{replace:!0})};(0,E.useEffect)(()=>{s===`all`||!U||(U.stats?.byReason?.[s]??0)>0||c(`all`)},[U,s]);let K=U?.stats?.byReason??{},q=Object.keys(K).filter(e=>K[e]>0),J=[...q].sort((e,t)=>(K[t]??0)-(K[e]??0))[0],Y=(0,E.useMemo)(()=>L.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[L]),X=(0,E.useRef)(!1),Z=e.get(`queue`);(0,E.useEffect)(()=>{if(!(X.current||r)){if(Z){if(L.some(e=>e.name===Z)){X.current=!0,i(Z),b(0),c(`all`);return}if(L.length===0)return}Y.length!==0&&(X.current=!0,i(Y[0].name),b(0),c(`all`))}},[r,L,Y,Z]);let Q=(0,E.useMemo)(()=>{let e=U?.entries??[];s!==`all`&&(e=e.filter(e=>e.reason===s));let t=p.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>u===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[U,s,p,u]),re=R===0&&!F,$=s!==`all`||p.trim()!==``,ie=(U?.entriesTotal??0)>M;return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(v,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Inspect and export entries without mutating flow topology.`,live:!!r&&!!U&&!U.statsError&&!B&&!F}),B&&U&&(0,D.jsx)(h,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:H}),F&&(0,D.jsx)(h,{onRetry:I,message:`Could not discover queue DLQ totals — ${F.message}. Health status is unavailable.`}),U?.statsError&&(0,D.jsx)(h,{message:`DLQ statistics are unavailable — ${U.statsError}. The entry list may still be current.`,onRetry:H}),(0,D.jsx)(O,{total:R,discoveryError:!!F,healthy:re,statsError:!!U?.statsError,queue:r,topReason:J,pendingRetry:U?.stats?.pendingRetry,reasonCount:U?.stats?q.length:void 0}),(0,D.jsx)(k,{queues:Y,queue:r,onSelect:G}),(0,D.jsx)(A,{queue:r,queues:L,reason:s,reasons:q,sort:u,search:p,pageScoped:ie,onQueue:G,onReason:c,onSort:f,onSearch:m,onExport:W}),(0,D.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:w}),B&&!U?(0,D.jsx)(ee,{error:B,onRetry:H}):ne&&!P&&!r&&!F?(0,D.jsx)(g,{label:`Discovering queues…`}):V&&!U&&!B?(0,D.jsx)(g,{label:`Loading DLQ…`}):F&&!r?(0,D.jsx)(_,{icon:(0,D.jsx)(l,{}),title:`Could not discover queues`,hint:`${F.message}. Retry the queue discovery request above.`}):r?Q.length===0?(0,D.jsx)(_,{icon:(0,D.jsx)(l,{}),title:$?`No matches on this page`:`No dead letter entries`,hint:$?`No entries on this page match your filter — the filter is page-scoped. Use the pager below to check other pages.`:`This queue has no dead letter entries.`}):(0,D.jsx)(j,{entries:Q,expanded:x,onToggle:e=>C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}):(0,D.jsx)(_,{icon:(0,D.jsx)(l,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),r&&U&&(0,D.jsx)(S,{page:y,pageSize:M,total:U.entriesTotal,onPageChange:b,label:`entries`})]})}export{P as DlqPro};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{o as r,t as i}from"./connectionStore-CVjQyIZv.js";import{n as a}from"./usePolledData-CEyyLRYa.js";import{t as o}from"./Button-_aSJvRoW.js";import{n as s,t as c}from"./Card-egIDLwVk.js";import{t as l}from"./PageHeader-CQzNsw8r.js";import{n as u}from"./controlConnectionEpoch-ChAeMMLk.js";var d=e(t(),1),f=7500;function p(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed ${t} response`);return e}async function m(e){try{let t=p(await e.json(),`error`);if(typeof t.error==`string`&&t.error)return Error(t.error)}catch{}return Error(`HTTP ${e.status}`)}async function h(e,t,n,r,i,a=[]){let o=AbortSignal.timeout(f),s=r?AbortSignal.any([r,o]):o,c=new Headers(i?.headers);n&&c.set(`Authorization`,`Bearer ${n}`);let l=await fetch(`${e}${t}`,{...i,headers:c,signal:s});if(!l.ok&&!a.includes(l.status))throw await m(l);return{response:l,body:p(await l.json(),t)}}async function g(e,t){try{let{response:n,body:r}=await h(e.baseUrl,`/health`,e.token,t,void 0,[503]);if(typeof r.ok!=`boolean`)throw Error(`Malformed Bunqueue health response`);return{reachable:!0,healthy:r.ok,statusCode:n.status,version:typeof r.version==`string`?r.version:void 0}}catch(e){return{reachable:!1,healthy:!1,error:e.message}}}function _(e){return[`running`,`stopped`,`starting`,`stopping`].includes(String(e.status))&&e.config!==null&&typeof e.config==`object`&&!Array.isArray(e.config)}async function v(e,t){try{let{response:n,body:r}=await h(e.agentBaseUrl,`/control/status`,e.agentToken,t);if(!_(r))throw Error(`Malformed control agent response`);return{reachable:!0,healthy:r.healthy===!0,statusCode:n.status,version:typeof r.version==`string`?r.version:void 0,status:r}}catch(e){return{reachable:!1,healthy:!1,error:e.message}}}async function y(e,t){let n=i(e);if(!n)throw Error(`Unknown Bunqueue connection profile: ${e}`);let[r,a]=await Promise.all([g(n,t),v(n,t)]);return{target:n,server:r,agent:a}}function b(e,t){return Promise.all(e.map(e=>y(e,t)))}async function x(e,t,n){let r=i(e);if(!r)throw Error(`Unknown Bunqueue connection profile: ${e}`);let{body:a}=await h(r.agentBaseUrl,`/control/${t}`,r.agentToken,n,{method:`POST`});if(!_(a))throw Error(`Malformed control agent response`);return a}function S(e){let t=e.agent.status;return t?.storageMode!==`postgres`||!t.postgresTarget?null:`${t.postgresTarget}\u0000${t.postgresNamespace??`default`}`}var C=n();function w({ok:e,reachable:t}){return(0,C.jsx)(`span`,{className:`inline-block size-2 rounded-full ${t?e?`bg-emerald-400`:`bg-amber-400`:`bg-red-400`}`})}function T({snapshot:e,active:t,busy:n,actionError:r,onActivate:i,onAction:a}){let{target:l,server:u,agent:d}=e,f=d.status,p=f?.managementMode===`external`,m=p?f?.reachable===!0:f?.status===`running`,h=n!==void 0||f?.status===`starting`||f?.status===`stopping`,g=f?.storageMode===`postgres`?`PostgreSQL · ${f.postgresNamespace??`default`}`:f?.storageMode??`unknown`;return(0,C.jsxs)(c,{className:t?`border-accent/60`:void 0,children:[(0,C.jsx)(s,{title:l.name,action:t?(0,C.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-1 text-[10px] font-semibold uppercase text-accent`,children:`active`}):(0,C.jsx)(o,{size:`sm`,onClick:i,children:`Use node`})}),(0,C.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-2 text-xs`,children:[(0,C.jsx)(`dt`,{className:`text-faint`,children:`Server`}),(0,C.jsxs)(`dd`,{className:`flex min-w-0 items-center gap-2 text-muted`,children:[(0,C.jsx)(w,{ok:u.healthy,reachable:u.reachable}),(0,C.jsx)(`span`,{className:`truncate`,title:l.baseUrl,children:u.reachable?`${u.healthy?`healthy`:`degraded`}${u.version?` · v${u.version}`:``}`:`offline · ${u.error??`unreachable`}`})]}),(0,C.jsx)(`dt`,{className:`text-faint`,children:`Agent`}),(0,C.jsxs)(`dd`,{className:`flex min-w-0 items-center gap-2 text-muted`,children:[(0,C.jsx)(w,{ok:d.healthy,reachable:d.reachable}),(0,C.jsx)(`span`,{className:`truncate`,title:l.agentBaseUrl,children:d.reachable?`${f?.status??`connected`}${p?` · external`:``}`:`offline · ${d.error??`unreachable`}`})]}),(0,C.jsx)(`dt`,{className:`text-faint`,children:`Storage`}),(0,C.jsx)(`dd`,{className:`truncate font-mono text-muted`,title:f?.postgresTarget,children:g}),f?.storageMode===`postgres`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`dt`,{className:`text-faint`,children:`Cluster`}),(0,C.jsx)(`dd`,{className:`truncate font-mono text-muted`,children:f.postgresTarget??`configured PostgreSQL`})]})]}),r&&(0,C.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-danger`,children:r}),!p&&(0,C.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 border-t border-line pt-4`,children:[(0,C.jsx)(o,{size:`sm`,variant:`success`,disabled:!d.reachable||m||h,onClick:()=>a(`start`),children:`Start`}),(0,C.jsx)(o,{size:`sm`,variant:`warning`,disabled:!d.reachable||!m||h,onClick:()=>a(`stop`),children:`Stop`}),(0,C.jsx)(o,{size:`sm`,disabled:!d.reachable||h,onClick:()=>a(`restart`),children:n===`restart`?`Restarting…`:`Restart`})]})]})}function E(e){let t=new Map;for(let n of e){let e=S(n);e&&t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=t[0]?.agent.status;return{key:e,target:n?.postgresTarget??`configured PostgreSQL`,namespace:n?.postgresNamespace??`default`,members:t}})}function D(){let e=r(e=>e.profiles),t=r(e=>e.activeProfileId),n=r(e=>e.activateProfile),i=u(),f=e.map(e=>e.id),p=`${i}:${JSON.stringify(e)}`,{data:m,error:h,loading:g,refetch:_}=a(e=>b(f,e),[p],{intervalMs:1e4}),[v,y]=(0,d.useState)({}),[S,w]=(0,d.useState)({}),D=(0,d.useRef)(0),O=(0,d.useMemo)(()=>E(m??[]),[m]);(0,d.useEffect)(()=>{D.current+=1,y({}),w({})},[p]);let k=async(e,t)=>{let n=e.target.id;if(v[n]||t!==`start`&&!window.confirm(`${t===`stop`?`Stop`:`Restart`} ${e.target.name}? In-flight jobs on this broker may be interrupted.`))return;let r=D.current;y(e=>({...e,[n]:t})),w(e=>({...e,[n]:``}));try{await x(n,t),r===D.current&&await _()}catch(e){r===D.current&&w(t=>({...t,[n]:e.message}))}finally{r===D.current&&y(e=>{let t={...e};return delete t[n],t})}};return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(l,{title:`Fleet`,description:`Operate every Bunqueue broker and verify shared PostgreSQL topology.`,actions:(0,C.jsx)(o,{onClick:()=>void _(),children:`Refresh all`})}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,C.jsxs)(c,{children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Configured nodes`}),(0,C.jsx)(`div`,{className:`mt-1 text-2xl font-bold text-fg`,children:e.length})]}),(0,C.jsxs)(c,{children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Healthy APIs`}),(0,C.jsxs)(`div`,{className:`mt-1 text-2xl font-bold text-fg`,children:[(m??[]).filter(e=>e.server.healthy).length,`/`,e.length]})]}),(0,C.jsxs)(c,{children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`PostgreSQL clusters`}),(0,C.jsx)(`div`,{className:`mt-1 text-2xl font-bold text-fg`,children:O.length})]})]}),h&&(0,C.jsxs)(`div`,{role:`status`,className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:[`Fleet refresh failed: `,h.message]}),O.length>0&&(0,C.jsxs)(c,{className:`mb-6`,children:[(0,C.jsx)(s,{title:`Shared PostgreSQL topology`}),(0,C.jsx)(`div`,{className:`flex flex-col gap-3`,children:O.map(e=>(0,C.jsxs)(`div`,{className:`rounded-lg border border-line bg-surface-2/40 px-4 py-3`,children:[(0,C.jsx)(`div`,{className:`font-mono text-sm text-fg`,children:e.target}),(0,C.jsxs)(`div`,{className:`mt-1 text-xs text-muted`,children:[`namespace `,(0,C.jsx)(`span`,{className:`font-mono text-fg`,children:e.namespace}),` ·`,` `,e.members.length,` broker`,e.members.length===1?``:`s`,`:`,` `,e.members.map(e=>e.target.name).join(`, `)]})]},e.key))})]}),g&&!m?(0,C.jsx)(c,{children:`Checking every Bunqueue node…`}):(0,C.jsx)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:(m??[]).map(e=>(0,C.jsx)(T,{snapshot:e,active:e.target.id===t,busy:v[e.target.id],actionError:S[e.target.id],onActivate:()=>n(e.target.id),onAction:t=>void k(e,t)},e.target.id))}),(0,C.jsx)(`p`,{className:`mt-5 text-xs leading-relaxed text-faint`,children:`PostgreSQL-backed queues, jobs, flows, crons, workers, limits, durable metrics and events are visible through every healthy broker in the same target and namespace. Lifecycle, process logs/configuration and in-memory webhooks are node-local; Workflow Engine storage uses each profile's agent data path.`})]})}export{D as Fleet};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{o as r,t as i}from"./connectionStore-DdLzJyut.js";import{n as a}from"./usePolledData-Dp_ynL9f.js";import{t as o}from"./Button-BCjgbAhY.js";import{n as s,t as c}from"./Card-DptfvL2O.js";import{t as l}from"./PageHeader-DD4vnVog.js";import{n as u}from"./controlConnectionEpoch-D4HtriLM.js";var d=e(t(),1),f=7500;function p(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed ${t} response`);return e}async function m(e){try{let t=p(await e.json(),`error`);if(typeof t.error==`string`&&t.error)return Error(t.error)}catch{}return Error(`HTTP ${e.status}`)}async function h(e,t,n,r,i,a=[]){let o=AbortSignal.timeout(f),s=r?AbortSignal.any([r,o]):o,c=new Headers(i?.headers);n&&c.set(`Authorization`,`Bearer ${n}`);let l=await fetch(`${e}${t}`,{...i,headers:c,signal:s});if(!l.ok&&!a.includes(l.status))throw await m(l);return{response:l,body:p(await l.json(),t)}}async function g(e,t){try{let{response:n,body:r}=await h(e.baseUrl,`/health`,e.token,t,void 0,[503]);if(typeof r.ok!=`boolean`)throw Error(`Malformed Bunqueue health response`);return{reachable:!0,healthy:r.ok,statusCode:n.status,version:typeof r.version==`string`?r.version:void 0}}catch(e){return{reachable:!1,healthy:!1,error:e.message}}}function _(e){return[`running`,`stopped`,`starting`,`stopping`].includes(String(e.status))&&e.config!==null&&typeof e.config==`object`&&!Array.isArray(e.config)}async function v(e,t){try{let{response:n,body:r}=await h(e.agentBaseUrl,`/control/status`,e.agentToken,t);if(!_(r))throw Error(`Malformed control agent response`);return{reachable:!0,healthy:r.healthy===!0,statusCode:n.status,version:typeof r.version==`string`?r.version:void 0,status:r}}catch(e){return{reachable:!1,healthy:!1,error:e.message}}}async function y(e,t){let n=i(e);if(!n)throw Error(`Unknown Bunqueue connection profile: ${e}`);let[r,a]=await Promise.all([g(n,t),v(n,t)]);return{target:n,server:r,agent:a}}function b(e,t){return Promise.all(e.map(e=>y(e,t)))}async function x(e,t,n){let r=i(e);if(!r)throw Error(`Unknown Bunqueue connection profile: ${e}`);let{body:a}=await h(r.agentBaseUrl,`/control/${t}`,r.agentToken,n,{method:`POST`});if(!_(a))throw Error(`Malformed control agent response`);return a}function S(e){let t=e.agent.status;return t?.storageMode!==`postgres`||!t.postgresTarget?null:`${t.postgresTarget}\u0000${t.postgresNamespace??`default`}`}var C=n();function w({ok:e,reachable:t}){return(0,C.jsx)(`span`,{className:`inline-block size-2 rounded-full ${t?e?`bg-emerald-400`:`bg-amber-400`:`bg-red-400`}`})}function T({snapshot:e,active:t,busy:n,actionError:r,onActivate:i,onAction:a}){let{target:l,server:u,agent:d}=e,f=d.status,p=f?.managementMode===`external`,m=p?f?.reachable===!0:f?.status===`running`,h=n!==void 0||f?.status===`starting`||f?.status===`stopping`,g=f?.storageMode===`postgres`?`PostgreSQL · ${f.postgresNamespace??`default`}`:f?.storageMode??`unknown`;return(0,C.jsxs)(c,{className:t?`border-accent/60`:void 0,children:[(0,C.jsx)(s,{title:l.name,action:t?(0,C.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-1 text-[10px] font-semibold uppercase text-accent`,children:`active`}):(0,C.jsx)(o,{size:`sm`,onClick:i,children:`Use node`})}),(0,C.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-2 text-xs`,children:[(0,C.jsx)(`dt`,{className:`text-faint`,children:`Server`}),(0,C.jsxs)(`dd`,{className:`flex min-w-0 items-center gap-2 text-muted`,children:[(0,C.jsx)(w,{ok:u.healthy,reachable:u.reachable}),(0,C.jsx)(`span`,{className:`truncate`,title:l.baseUrl,children:u.reachable?`${u.healthy?`healthy`:`degraded`}${u.version?` · v${u.version}`:``}`:`offline · ${u.error??`unreachable`}`})]}),(0,C.jsx)(`dt`,{className:`text-faint`,children:`Agent`}),(0,C.jsxs)(`dd`,{className:`flex min-w-0 items-center gap-2 text-muted`,children:[(0,C.jsx)(w,{ok:d.healthy,reachable:d.reachable}),(0,C.jsx)(`span`,{className:`truncate`,title:l.agentBaseUrl,children:d.reachable?`${f?.status??`connected`}${p?` · external`:``}`:`offline · ${d.error??`unreachable`}`})]}),(0,C.jsx)(`dt`,{className:`text-faint`,children:`Storage`}),(0,C.jsx)(`dd`,{className:`truncate font-mono text-muted`,title:f?.postgresTarget,children:g}),f?.storageMode===`postgres`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`dt`,{className:`text-faint`,children:`Cluster`}),(0,C.jsx)(`dd`,{className:`truncate font-mono text-muted`,children:f.postgresTarget??`configured PostgreSQL`})]})]}),r&&(0,C.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-danger`,children:r}),!p&&(0,C.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 border-t border-line pt-4`,children:[(0,C.jsx)(o,{size:`sm`,variant:`success`,disabled:!d.reachable||m||h,onClick:()=>a(`start`),children:`Start`}),(0,C.jsx)(o,{size:`sm`,variant:`warning`,disabled:!d.reachable||!m||h,onClick:()=>a(`stop`),children:`Stop`}),(0,C.jsx)(o,{size:`sm`,disabled:!d.reachable||h,onClick:()=>a(`restart`),children:n===`restart`?`Restarting…`:`Restart`})]})]})}function E(e){let t=new Map;for(let n of e){let e=S(n);e&&t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=t[0]?.agent.status;return{key:e,target:n?.postgresTarget??`configured PostgreSQL`,namespace:n?.postgresNamespace??`default`,members:t}})}function D(){let e=r(e=>e.profiles),t=r(e=>e.activeProfileId),n=r(e=>e.activateProfile),i=u(),f=e.map(e=>e.id),p=`${i}:${JSON.stringify(e)}`,{data:m,error:h,loading:g,refetch:_}=a(e=>b(f,e),[p],{intervalMs:1e4}),[v,y]=(0,d.useState)({}),[S,w]=(0,d.useState)({}),D=(0,d.useRef)(0),O=(0,d.useMemo)(()=>E(m??[]),[m]);(0,d.useEffect)(()=>{D.current+=1,y({}),w({})},[p]);let k=async(e,t)=>{let n=e.target.id;if(v[n]||t!==`start`&&!window.confirm(`${t===`stop`?`Stop`:`Restart`} ${e.target.name}? In-flight jobs on this broker may be interrupted.`))return;let r=D.current;y(e=>({...e,[n]:t})),w(e=>({...e,[n]:``}));try{await x(n,t),r===D.current&&await _()}catch(e){r===D.current&&w(t=>({...t,[n]:e.message}))}finally{r===D.current&&y(e=>{let t={...e};return delete t[n],t})}};return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(l,{title:`Fleet`,description:`Operate every Bunqueue broker and verify shared PostgreSQL topology.`,actions:(0,C.jsx)(o,{onClick:()=>void _(),children:`Refresh all`})}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,C.jsxs)(c,{children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Configured nodes`}),(0,C.jsx)(`div`,{className:`mt-1 text-2xl font-bold text-fg`,children:e.length})]}),(0,C.jsxs)(c,{children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Healthy APIs`}),(0,C.jsxs)(`div`,{className:`mt-1 text-2xl font-bold text-fg`,children:[(m??[]).filter(e=>e.server.healthy).length,`/`,e.length]})]}),(0,C.jsxs)(c,{children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`PostgreSQL clusters`}),(0,C.jsx)(`div`,{className:`mt-1 text-2xl font-bold text-fg`,children:O.length})]})]}),h&&(0,C.jsxs)(`div`,{role:`status`,className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:[`Fleet refresh failed: `,h.message]}),O.length>0&&(0,C.jsxs)(c,{className:`mb-6`,children:[(0,C.jsx)(s,{title:`Shared PostgreSQL topology`}),(0,C.jsx)(`div`,{className:`flex flex-col gap-3`,children:O.map(e=>(0,C.jsxs)(`div`,{className:`rounded-lg border border-line bg-surface-2/40 px-4 py-3`,children:[(0,C.jsx)(`div`,{className:`font-mono text-sm text-fg`,children:e.target}),(0,C.jsxs)(`div`,{className:`mt-1 text-xs text-muted`,children:[`namespace `,(0,C.jsx)(`span`,{className:`font-mono text-fg`,children:e.namespace}),` ·`,` `,e.members.length,` broker`,e.members.length===1?``:`s`,`:`,` `,e.members.map(e=>e.target.name).join(`, `)]})]},e.key))})]}),g&&!m?(0,C.jsx)(c,{children:`Checking every Bunqueue node…`}):(0,C.jsx)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:(m??[]).map(e=>(0,C.jsx)(T,{snapshot:e,active:e.target.id===t,busy:v[e.target.id],actionError:S[e.target.id],onActivate:()=>n(e.target.id),onAction:t=>void k(e,t)},e.target.id))}),(0,C.jsx)(`p`,{className:`mt-5 text-xs leading-relaxed text-faint`,children:`PostgreSQL-backed queues, jobs, flows, crons, workers, limits, durable metrics and events are visible through every healthy broker in the same target and namespace. Lifecycle, process logs/configuration and in-memory webhooks are node-local; Workflow Engine storage uses each profile's agent data path.`})]})}export{D as Fleet};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,r,t as i}from"./react-vendor-CFL9l8LK.js";import{a,o}from"./connectionStore-CVjQyIZv.js";import{i as s}from"./upstreamPaths-DQeKSxGc.js";import{a as c,d as l,s as u,u as d}from"./bq-DR2BTISO.js";import{r as f}from"./StatusBadge-DereLzOj.js";import{t as p}from"./Card-egIDLwVk.js";import{i as m,n as h,r as g}from"./feedback-CtGN_kqB.js";import{t as _}from"./PageHeader-CQzNsw8r.js";import{i as v}from"./index-DZFZr0Mi.js";import{n as y,t as b}from"./controlConnectionEpoch-ChAeMMLk.js";import{t as x}from"./useControlActionGuard-1i7aFA7E.js";import{n as S,r as C}from"./flowOperationPolicy-B2Etcb3f.js";var w={nodeWidth:168,nodeHeight:60},ee=`flow-order-9a3f`,T={completed:`border-success/50 bg-success/10 text-success`,failed:`border-danger/50 bg-danger/10 text-danger`,active:`border-blue-400/60 bg-blue-400/10 text-blue-400`,delayed:`border-accent/50 bg-accent/10 text-accent`,waiting:`border-warning/50 bg-warning/10 text-warning`,prioritized:`border-warning/50 bg-warning/10 text-warning`,"waiting-children":`border-cyan-400/60 bg-cyan-400/10 text-cyan-400`},E=e=>e&&T[e]||`border-line bg-surface-2 text-muted`,D=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,O=class extends Error{constructor(e,t){super(e,t),this.name=`FlowSnapshotError`}};function k(e,t,n){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`||s(e)!==null))throw new O(`Job ${n} returned an invalid ${t} list`);return e}function A(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new O(`GET /jobs/${t} returned an invalid response`);let n=e;if(n.ok!==!0)throw new O(`GET /jobs/${t} returned an invalid success envelope`);let r=n.job;if(typeof r!=`object`||!r||Array.isArray(r))throw new O(`GET /jobs/${t} returned no job snapshot`);let i=r;if(i.id!==t)throw new O(`GET /jobs/${t} returned the wrong job id (${String(i.id)})`);if(typeof i.queue!=`string`||i.queue.length===0)throw new O(`Job ${t} returned an invalid queue`);if(typeof i.state!=`string`||i.state.length===0)throw new O(`Job ${t} returned an invalid state`);if(!Object.hasOwn(i,`parentId`)||i.parentId!==null&&(typeof i.parentId!=`string`||s(i.parentId)!==null))throw new O(`Job ${t} returned an invalid parentId`);return{...r,parentId:i.parentId,childrenIds:k(i.childrenIds,`childrenIds`,t),dependsOn:k(i.dependsOn,`dependsOn`,t)}}async function j(e,t,n){n?.throwIfAborted();let r=await l(e,t,n);return n?.throwIfAborted(),A(r,t)}function M(e){let t=s(e);return t?`Job ID: ${t}`:null}async function te(e,t={}){let n=M(e);if(n)throw new O(n);let r=t.target??d(),{signal:i}=t,a=e,o=new Set([e]),s=[];for(let e=0;;e++){i?.throwIfAborted();let t;try{t=await j(r,a,i)}catch(t){if(i?.throwIfAborted(),e===0)throw t;if(t instanceof c&&t.status===404){let e=s.at(-1);if(!e)throw t;return{id:e.id,job:e,hops:Math.max(0,s.length-1),path:s,missingParent:a}}throw new O(`Could not resolve the flow root because parent ${a} could not be loaded: ${t instanceof Error?t.message:String(t)}`,{cause:t})}s.push(t);let n=t.parentId;if(!n)return{id:a,job:t,hops:e,path:s};if(o.has(n))throw new O(`Flow parent cycle detected at job ${n}`);if(e>=100)throw new O(`Flow parent chain exceeds the Bunqueue 2.9.3 limit of 100 levels`);o.add(n),a=n}}function N(e,t){let n=new Set(e),r=new Map(e.map(e=>[e,[]]));for(let e of t)n.has(e.from)&&n.has(e.to)&&r.get(e.from)?.push(e.to);let i=new Map,a=[],o=e=>{i.set(e,1),a.push(e);for(let t of r.get(e)??[]){if(i.get(t)===1){let e=a.lastIndexOf(t);return[...a.slice(Math.max(0,e)),t]}if(i.get(t)!==2){let e=o(t);if(e)return e}}return a.pop(),i.set(e,2),null};for(let t of e)if(!i.has(t)){let e=o(t);if(e)return e}return null}var ne=[`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`];function P(e){return ne.filter(t=>e[t]===!0)}function F(e,t){if(e?.parentId!==t)return null;let n=P(e);return n.length===1?n[0]===`continueParentOnFailure`?{scope:`parent`,policy:`continueParentOnFailure`}:n[0]===`removeDependencyOnFailure`?{scope:`child`,policy:`removeDependencyOnFailure`}:n[0]===`ignoreDependencyOnFailure`?{scope:`child`,policy:`ignoreDependencyOnFailure`}:null:null}async function re(e,t,n={}){let r=M(e);if(r)throw new O(r);let i=n.target??d(),{signal:a}=n,o=new Map,s=[],c=[],l=new Set,u=new Set,f=new Map,p=new Set,m=new Set,h=new Set(n.limitations??[]),g=[{id:e,depth:0}],_=new Set([e]),v=new Map;t&&v.set(e,A({ok:!0,job:t},e));let y=[...n.seedPath??[]].reverse(),b=!1;if(y.length>0&&y[0]?.id!==e)throw new O(`Resolved seed path does not start at the requested flow root`);for(let[e,t]of y.entries()){let n=A({ok:!0,job:t},t.id);if(v.set(n.id,n),e!==0){if(e>100||_.size>=500){b=!0;continue}_.has(n.id)||(_.add(n.id),g.push({id:n.id,depth:e}))}}let x=new Set,S=b;for(;g.length;){a?.throwIfAborted();let{id:t,depth:n}=g.shift();if(x.has(t))continue;x.add(t);let r=null;try{r=v.get(t)??await j(i,t,a)}catch(n){if(a?.throwIfAborted(),t===e)throw n;f.set(t,n instanceof Error?n.message:String(n))}if(o.set(t,r??{id:t,state:`unknown`}),!r)continue;if(n>=100){(r.childrenIds?.length??0)+(r.dependsOn?.length??0)>0&&(S=!0);continue}let d=e=>_.has(e)?!0:_.size>=500?(S=!0,!1):(_.add(e),g.push({id:e,depth:n+1}),!0),m=(e,t,n,r)=>{if(!d(r))return;let i=`${e}->${t}:${n}`;l.has(i)||(l.add(i),s.push({from:e,to:t,kind:n}))},h=r.childrenIds??[],y=r.dependsOn??[],b=new Set(h),C=new Set(y);b.size!==h.length&&p.add(`Job ${t} lists a child more than once`),C.size!==y.length&&p.add(`Job ${t} lists a dependency more than once`);for(let e of h)m(t,e,`child`,e);for(let e of y)if(d(e)){let n=`${e}->${t}`;u.has(n)||(u.add(n),c.push({from:e,to:t,kind:`depends`})),b.has(e)||m(e,t,`depends`,e)}}for(let[e,t]of o)!f.has(e)&&P(t).length>1&&p.add(`Job ${e} enables mutually exclusive failure policies`);for(let e of s){if(e.kind!==`child`||f.has(e.to))continue;let t=o.get(e.to);t&&t.parentId!==e.from&&p.add(`Child ${e.to} points to parent ${String(t.parentId??`none`)}, not ${e.from}`)}for(let[e,t]of o){if(f.has(e))continue;let n=t.childrenIds??[];if(n.some(e=>!o.has(e)||f.has(e)))continue;let r=n.map(t=>({childId:t,release:F(o.get(t),e)})).find(({release:e})=>e?.scope===`parent`);for(let i of n){if(t.dependsOn?.includes(i))continue;if(r?.release?.scope===`parent`){m.add(`Parent ${e} is missing dependency ${i}; ${r.release.policy} on child ${r.childId} may have released all parent dependencies, but the HTTP snapshot cannot prove whether the policy fired`);continue}let n=F(o.get(i),e);if(n?.scope===`child`){m.add(`Parent ${e} is missing dependency ${i}; ${n.policy} may have released it, but the HTTP snapshot cannot prove whether the policy fired`);continue}p.add(`Parent ${e} lists child ${i} without the matching dependency`)}}for(let[e,t]of o){if(f.has(e)||!t.parentId)continue;let n=o.get(t.parentId);!n||f.has(t.parentId)||n.childrenIds?.includes(e)||p.add(`Parent ${t.parentId} does not list child ${e}`)}let C=N([...o.keys()],c);return{jobs:o,edges:s,truncated:S,failed:f.size,failures:f,issues:[...p],policyNotes:[...m],cycle:C,limitations:[...h]}}var ie=`bq-dash-recent-flows`,ae=8;function oe(e){return`${ie}:${encodeURIComponent(e.trim()||`/api`)}`}function se(e,t){if(!t)return[];try{let t=JSON.parse(localStorage.getItem(oe(e))??`[]`);return Array.isArray(t)?t.filter(e=>typeof e?.root==`string`&&e.root.length>0&&e.root.length<=1024&&Number.isSafeInteger(e?.nodes)&&e.nodes>1&&e.nodes<=500&&Number.isFinite(e?.at)&&e.at>=0).slice(0,ae):[]}catch{return[]}}function ce(e,t,n,r){let i=[n,...t.filter(e=>e.root!==n.root)].slice(0,ae);if(!r)return i;try{localStorage.setItem(oe(e),JSON.stringify(i))}catch{}return i}var I=e(n(),1),le=new Set([`explore`,`create`,`operations`]);function ue(e,t=``){let n=e.get(`root`),r=R(n)?n:t,i=e.get(`mode`),a=le.has(i)?i:`explore`,o=e.get(`node`);return{root:r,mode:a,node:r&&R(o)?o:null}}function L(e){let t=new URLSearchParams;return e.root&&t.set(`root`,e.root),e.mode!==`explore`&&t.set(`mode`,e.mode),e.root&&e.node&&t.set(`node`,e.node),t}function de(e,t,n=``){return L({...ue(e,n),...t})}function R(e){return!!(e&&M(e)===null)}function fe(){let[e,n]=t(),r=v()?ee:``,i=e.toString(),s=(0,I.useMemo)(()=>ue(new URLSearchParams(i),r),[r,i]),c=s.root,l=o(e=>e.baseUrl),u=o(e=>e.token),f=a(),[p,m]=(0,I.useState)(c),[h,g]=(0,I.useState)(null),[_,y]=(0,I.useState)(!!c),[b,x]=(0,I.useState)(null),[S,C]=(0,I.useState)(()=>se(f,u.length===0)),w=(0,I.useRef)(0),T=(0,I.useRef)(null),E=(0,I.useRef)(!1),D=(0,I.useRef)(z()),k=h?.seed===c?h.graph:null,A=k?s.node&&k.jobs.has(s.node)?s.node:h?.defaultSelected??null:null,j=(0,I.useCallback)((e,t=!1)=>{n(t=>de(t,e,r),{replace:t})},[r,n]),N=(0,I.useCallback)(async e=>{let t=o.getState();if(t.baseUrl!==l||t.token!==u)return;T.current?.abort(),T.current=null;let n=++w.current,r=e.trim();if(g(null),x(null),!r)return y(!1);let i=M(r);if(i)return x(new O(i)),y(!1);let a=d(),s=z(),c=new AbortController;T.current=c;let f=()=>E.current&&n===w.current&&!c.signal.aborted&&s===z();y(!0);try{let e={target:a,signal:c.signal},t=await te(r,e),n=t.missingParent?[`Ancestor ${t.missingParent} is no longer available. The graph starts at the oldest surviving node.`]:[],i=await re(t.id,t.job,{...e,seedPath:t.path,limitations:n});if(!f())return;g({seed:r,graph:i,defaultSelected:t.id}),i.jobs.size>1&&C(e=>ce(a.baseUrl,e,{root:t.id,nodes:i.jobs.size,at:Date.now()},o.getState().token.length===0))}catch(e){f()&&x(e instanceof Error?e:Error(`Failed to load flow`))}finally{T.current===c&&(T.current=null),f()&&y(!1)}},[l,u]);return(0,I.useEffect)(()=>{E.current=!0,D.current=z();let e=o.subscribe(()=>{let e=z();e!==D.current&&(D.current=e,w.current+=1,T.current?.abort(),T.current=null,E.current&&(g(null),x(null),y(!1)))});return()=>{E.current=!1,e(),w.current+=1,T.current?.abort()}},[]),(0,I.useEffect)(()=>C(u?[]:se(f,!0)),[f,u]),(0,I.useEffect)(()=>{let e={...s};k&&(!e.node||!k.jobs.has(e.node))&&(e.node=h?.defaultSelected??null);let t=L(e).toString();t!==i&&n(t,{replace:!0})},[k,i,n,h?.defaultSelected,s]),(0,I.useEffect)(()=>{m(c),N(c)},[c,N]),{input:p,setInput:m,rootParam:c,mode:s.mode,setMode:e=>j({mode:e}),graph:k,selected:A,setSelected:e=>{k?.jobs.has(e)&&j({node:e})},loading:_,error:b,recent:S,load:N,submit:e=>{e.preventDefault();let t=p.trim();if(t){if(M(t))return void N(t);t===c?N(t):j({root:t,mode:`explore`,node:null})}},openRecent:e=>{if(m(e),M(e))return void N(e);let t=e===c;j({root:e,mode:`explore`,node:null}),t&&N(e)}}}function z(){let{token:e}=o.getState();return JSON.stringify([a(),e])}function pe(e){return e instanceof c&&e.status===0||[`TypeError`,`AbortError`,`TimeoutError`].includes(e.name)}var B=e=>({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),me=new Set([`removeChildDependency`,`removeUnprocessedChildren`,`removeDeduplicationKey`,`retry`,`promote`,`remove`]),he=e=>e+5e3,V={create:(e,t)=>u(`/flows/create?target=${encodeURIComponent(a())}`,B({operation:e,...t})),getFlow:e=>{let t=new URLSearchParams({id:e.id,queueName:e.queueName,target:a()});return e.depth!==void 0&&t.set(`depth`,String(e.depth)),e.maxChildren!==void 0&&t.set(`maxChildren`,String(e.maxChildren)),u(`/flows/tree?${t}`)},inspect:(e,t)=>u(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:a()})}`),getParentResult:e=>u(`/flows/results?target=${encodeURIComponent(a())}`,B({operation:`getParentResult`,parentId:e})),getParentResults:e=>u(`/flows/results?target=${encodeURIComponent(a())}`,B({operation:`getParentResults`,parentIds:e})),waitUntilFinished:(e,t)=>u(`/flows/jobs/${encodeURIComponent(e.id)}/waitUntilFinished?${new URLSearchParams({queueName:e.queueName,target:a(),ttl:String(t)})}`,void 0,he(t)),mutate:(e,t,n)=>(S(t),u(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:a()})}`,me.has(t)?{method:`POST`}:B(n??{})))},H=i();function U({value:e}){return(0,H.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-md border border-line bg-bg p-3 font-mono text-xs text-muted`,children:JSON.stringify(e,null,2)})}function W(...e){return JSON.stringify(e)}function G(e,t=`shared`){let n=y(),r=`flow-exclusive:${t}`,i=x(r),a=(0,I.useMemo)(()=>({key:e,connectionEpoch:n}),[n,e]),o=(0,I.useRef)(a),s=(0,I.useRef)(void 0),c=(0,I.useRef)(void 0),l=(0,I.useRef)(void 0),u=(0,I.useRef)(0),d=(0,I.useRef)(!0),[f,p]=(0,I.useState)(),[m,h]=(0,I.useState)(),[g,_]=(0,I.useState)();return(0,I.useLayoutEffect)(()=>{o.current.connectionEpoch!==a.connectionEpoch&&(c.current=void 0),o.current=a,s.current=void 0,l.current=void 0},[a]),(0,I.useEffect)(()=>(d.current=!0,()=>{d.current=!1,s.current=void 0,c.current=void 0,l.current=void 0}),[]),{busy:f?.exclusive&&f.identity.connectionEpoch===a.connectionEpoch||f?.identity===a?f.label:``,error:g?.identity===a?g.message:``,result:m?.identity===a?m.value:void 0,reject:e=>{c.current||b()!==a.connectionEpoch||(l.current=void 0,s.current=void 0,p(void 0),h(void 0),_({identity:a,message:e}))},run:async(e,t,n={})=>{let f=n.exclusive===!0;if(c.current||s.current?.identity===a||b()!==a.connectionEpoch)return;let m=i.begin(r);if(!m)return;f||m.finish();let g={id:++u.current,identity:a};f?c.current=g:s.current=g,l.current=g,p({...g,exclusive:f,label:e}),h(void 0),_(void 0);try{let e=await t();d.current&&o.current===a&&b()===a.connectionEpoch&&l.current===g&&h({identity:a,value:e})}catch(e){d.current&&o.current===a&&b()===a.connectionEpoch&&l.current===g&&_({identity:a,message:ge(e)})}finally{f&&m.finish(),c.current===g&&(c.current=void 0),s.current===g&&(s.current=void 0),d.current&&p(e=>e?.id===g.id?void 0:e)}}}}function ge(e){return e instanceof Error?e.message:String(e)}var K={add:{flow:{name:`aggregate`,queueName:`reports`,data:{},children:[{name:`fetch`,queueName:`io`,data:{source:`orders`}}]},options:{queuesOptions:{io:{attempts:3,backoff:1e3}}}},addBulk:{flows:[{name:`report-a`,queueName:`reports`,data:{region:`eu`}},{name:`report-b`,queueName:`reports`,data:{region:`us`}}]},addChain:{steps:[{name:`extract`,queueName:`pipeline`,data:{}},{name:`transform`,queueName:`pipeline`,data:{}},{name:`load`,queueName:`pipeline`,data:{}}]},addBulkThen:{parallel:[{name:`part-a`,queueName:`parallel`,data:{}},{name:`part-b`,queueName:`parallel`,data:{}}],final:{name:`merge`,queueName:`final`,data:{}}},addTree:{root:{name:`root`,queueName:`tree`,data:{},children:[{name:`child`,queueName:`tree`,data:{}}]}}};function _e({repository:e=V,onOpen:t}){let[n,r]=(0,I.useState)(`add`),[i,a]=(0,I.useState)(()=>JSON.stringify(K.add,null,2)),o=G(W(n,i),`creator`),s=!!o.busy,c=e=>{r(e),a(JSON.stringify(K[e],null,2))},l=async t=>{t.preventDefault();let r;try{r=JSON.parse(i)}catch{return o.reject(`The definition must be valid JSON.`)}if(!r||typeof r!=`object`||Array.isArray(r))return o.reject(`The definition must be a JSON object.`);let a=n;await o.run(a,()=>e.create(a,r),{exclusive:!0})},u=ve(o.result);return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`form`,{onSubmit:l,className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`FlowProducer method`,(0,H.jsx)(`select`,{"aria-label":`FlowProducer method`,value:n,onChange:e=>c(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:Object.keys(K).map(e=>(0,H.jsx)(`option`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`submit`,disabled:s,className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:s?`Creating…`:`Run ${n}`})]}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Definition`,(0,H.jsx)(`textarea`,{"aria-label":`Flow definition JSON`,spellCheck:!1,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-80 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg outline-none focus:ring-2 focus:ring-accent/50`})]})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Atomic commit result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:`Validation is performed by Bunqueue before the graph is committed.`}),o.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:o.error}),o.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow created in this session.`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{value:o.result}),u&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(u),className:`mt-3 rounded-lg border border-line px-3 py-2 text-xs text-fg`,children:`Open created flow`})]})]})]})}function ve(e){let t=e,n=t?.result?.root?.id??t?.result?.roots?.[0]?.id??t?.result?.finalId??t?.result?.jobIds?.at(-1);return typeof n==`string`?n:null}function ye({recent:e,onOpen:t}){return(0,H.jsx)(p,{children:(0,H.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID, or choose “View flow” from Job Inspector.`}),e.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,H.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:e.map(e=>(0,H.jsxs)(`button`,{type:`button`,title:e.root,onClick:()=>t(e.root),className:`min-h-10 rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted hover:text-fg`,children:[(0,H.jsx)(`span`,{translate:`no`,children:D(e.root)}),(0,H.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})})}function q({target:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Job ID`,(0,H.jsx)(`input`,{"aria-label":`Flow job ID`,value:e.id,onChange:n=>t({...e,id:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 font-mono text-sm text-fg`})]}),(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Queue name`,(0,H.jsx)(`input`,{"aria-label":`Flow queue name`,value:e.queueName,onChange:n=>t({...e,queueName:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})]})}var be=[`getChildrenValues`,`getDependencies`,`getDependenciesCount`,`getFailedChildrenValues`,`getIgnoredChildrenFailures`],xe=[{id:`removeChildDependency`,label:`Release dependency`,dangerous:!0},{id:`removeUnprocessedChildren`,label:`Remove unprocessed children`,dangerous:!0},{id:`retry`,label:`Retry job`},{id:`promote`,label:`Promote delayed job`},{id:`remove`,label:`Remove job`,dangerous:!0}];function Se({repository:e=V,initialTarget:t={id:``,queueName:``},target:n,onTargetChange:r,showTarget:i=!0}){let[a,o]=(0,I.useState)(t),s=n??a,c=r??o,l=G(W(s.id,s.queueName),`dependency-console`),u=l.busy,d=!!(s.id.trim()&&s.queueName.trim()),f=t=>{let n=Ce(s);l.run(t,()=>e.inspect(n,t))},p=t=>{let n=C(t);if(n)return l.reject(n);let r=Ce(s);window.confirm(`${t} on ${r.id} in ${r.queueName}? This changes durable queue state and has no compare-and-swap precondition.`)&&l.run(t,()=>e.mutate(r,t),{exclusive:!0})};return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(360px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Dependency control`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Run the official Flow Job dependency methods against the managed server TCP endpoint.`}),i&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:s,onChange:c})}),(0,H.jsx)(`p`,{className:`mt-3 text-xs text-muted`,children:`Payload replacement, retry and removal are unavailable because they can damage flow dependencies or restart active work.`}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:be.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,onClick:()=>f(e),className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:e},e))}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Mutate`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:xe.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u||!!C(e.id),title:C(e.id)??void 0,onClick:()=>p(e.id),className:e.dangerous?`rounded-md border border-danger/40 px-2.5 py-1.5 text-xs text-danger disabled:opacity-40`:`rounded-md border border-line px-2.5 py-1.5 text-xs text-muted disabled:opacity-40`,children:e.label},e.id))})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Operation result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:u?`Running ${u}…`:`The last authoritative broker response appears here.`}),l.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:l.error}),l.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Choose an inspection or mutation.`}):(0,H.jsx)(U,{value:l.result})]})]})}var Ce=e=>({id:e.id.trim(),queueName:e.queueName.trim()});function we({repository:e=V,initialIds:t=``}){let[n,r]=(0,I.useState)(t),i=G(W(n)),a=i.busy,o=Te(n),s=async t=>{if(o.length===0)return;let n=[...o];await i.run(t,async()=>t===`one`?await e.getParentResult(n[0]):await e.getParentResults(n))};return(0,H.jsxs)(`section`,{className:`grid gap-5 rounded-lg border border-line bg-surface p-4 xl:grid-cols-[minmax(320px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Parent results`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Resolve completed parent values through the official FlowProducer result API.`}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Parent IDs, one per line`,(0,H.jsx)(`textarea`,{"aria-label":`Flow parent IDs`,value:n,onChange:e=>r(e.target.value),placeholder:`parent-job-id
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,r,t as i}from"./react-vendor-DfC0iyIS.js";import{a,o}from"./connectionStore-DdLzJyut.js";import{i as s}from"./upstreamPaths-DQeKSxGc.js";import{a as c,d as l,s as u,u as d}from"./bq-CSX8DSME.js";import{r as f}from"./StatusBadge-cYUkK-4P.js";import{t as p}from"./Card-DptfvL2O.js";import{i as m,n as h,r as g}from"./feedback-Dxfj-Fy1.js";import{t as _}from"./PageHeader-DD4vnVog.js";import{i as v}from"./index-CxzFSZj3.js";import{n as y,t as b}from"./controlConnectionEpoch-D4HtriLM.js";import{t as x}from"./useControlActionGuard-DImMgJtj.js";import{n as S,r as C}from"./flowOperationPolicy-B2Etcb3f.js";var w={nodeWidth:168,nodeHeight:60},ee=`flow-order-9a3f`,T={completed:`border-success/50 bg-success/10 text-success`,failed:`border-danger/50 bg-danger/10 text-danger`,active:`border-blue-400/60 bg-blue-400/10 text-blue-400`,delayed:`border-accent/50 bg-accent/10 text-accent`,waiting:`border-warning/50 bg-warning/10 text-warning`,prioritized:`border-warning/50 bg-warning/10 text-warning`,"waiting-children":`border-cyan-400/60 bg-cyan-400/10 text-cyan-400`},E=e=>e&&T[e]||`border-line bg-surface-2 text-muted`,D=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,O=class extends Error{constructor(e,t){super(e,t),this.name=`FlowSnapshotError`}};function k(e,t,n){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`||s(e)!==null))throw new O(`Job ${n} returned an invalid ${t} list`);return e}function A(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new O(`GET /jobs/${t} returned an invalid response`);let n=e;if(n.ok!==!0)throw new O(`GET /jobs/${t} returned an invalid success envelope`);let r=n.job;if(typeof r!=`object`||!r||Array.isArray(r))throw new O(`GET /jobs/${t} returned no job snapshot`);let i=r;if(i.id!==t)throw new O(`GET /jobs/${t} returned the wrong job id (${String(i.id)})`);if(typeof i.queue!=`string`||i.queue.length===0)throw new O(`Job ${t} returned an invalid queue`);if(typeof i.state!=`string`||i.state.length===0)throw new O(`Job ${t} returned an invalid state`);if(!Object.hasOwn(i,`parentId`)||i.parentId!==null&&(typeof i.parentId!=`string`||s(i.parentId)!==null))throw new O(`Job ${t} returned an invalid parentId`);return{...r,parentId:i.parentId,childrenIds:k(i.childrenIds,`childrenIds`,t),dependsOn:k(i.dependsOn,`dependsOn`,t)}}async function j(e,t,n){n?.throwIfAborted();let r=await l(e,t,n);return n?.throwIfAborted(),A(r,t)}function M(e){let t=s(e);return t?`Job ID: ${t}`:null}async function te(e,t={}){let n=M(e);if(n)throw new O(n);let r=t.target??d(),{signal:i}=t,a=e,o=new Set([e]),s=[];for(let e=0;;e++){i?.throwIfAborted();let t;try{t=await j(r,a,i)}catch(t){if(i?.throwIfAborted(),e===0)throw t;if(t instanceof c&&t.status===404){let e=s.at(-1);if(!e)throw t;return{id:e.id,job:e,hops:Math.max(0,s.length-1),path:s,missingParent:a}}throw new O(`Could not resolve the flow root because parent ${a} could not be loaded: ${t instanceof Error?t.message:String(t)}`,{cause:t})}s.push(t);let n=t.parentId;if(!n)return{id:a,job:t,hops:e,path:s};if(o.has(n))throw new O(`Flow parent cycle detected at job ${n}`);if(e>=100)throw new O(`Flow parent chain exceeds the Bunqueue 2.9.3 limit of 100 levels`);o.add(n),a=n}}function N(e,t){let n=new Set(e),r=new Map(e.map(e=>[e,[]]));for(let e of t)n.has(e.from)&&n.has(e.to)&&r.get(e.from)?.push(e.to);let i=new Map,a=[],o=e=>{i.set(e,1),a.push(e);for(let t of r.get(e)??[]){if(i.get(t)===1){let e=a.lastIndexOf(t);return[...a.slice(Math.max(0,e)),t]}if(i.get(t)!==2){let e=o(t);if(e)return e}}return a.pop(),i.set(e,2),null};for(let t of e)if(!i.has(t)){let e=o(t);if(e)return e}return null}var ne=[`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`];function P(e){return ne.filter(t=>e[t]===!0)}function F(e,t){if(e?.parentId!==t)return null;let n=P(e);return n.length===1?n[0]===`continueParentOnFailure`?{scope:`parent`,policy:`continueParentOnFailure`}:n[0]===`removeDependencyOnFailure`?{scope:`child`,policy:`removeDependencyOnFailure`}:n[0]===`ignoreDependencyOnFailure`?{scope:`child`,policy:`ignoreDependencyOnFailure`}:null:null}async function re(e,t,n={}){let r=M(e);if(r)throw new O(r);let i=n.target??d(),{signal:a}=n,o=new Map,s=[],c=[],l=new Set,u=new Set,f=new Map,p=new Set,m=new Set,h=new Set(n.limitations??[]),g=[{id:e,depth:0}],_=new Set([e]),v=new Map;t&&v.set(e,A({ok:!0,job:t},e));let y=[...n.seedPath??[]].reverse(),b=!1;if(y.length>0&&y[0]?.id!==e)throw new O(`Resolved seed path does not start at the requested flow root`);for(let[e,t]of y.entries()){let n=A({ok:!0,job:t},t.id);if(v.set(n.id,n),e!==0){if(e>100||_.size>=500){b=!0;continue}_.has(n.id)||(_.add(n.id),g.push({id:n.id,depth:e}))}}let x=new Set,S=b;for(;g.length;){a?.throwIfAborted();let{id:t,depth:n}=g.shift();if(x.has(t))continue;x.add(t);let r=null;try{r=v.get(t)??await j(i,t,a)}catch(n){if(a?.throwIfAborted(),t===e)throw n;f.set(t,n instanceof Error?n.message:String(n))}if(o.set(t,r??{id:t,state:`unknown`}),!r)continue;if(n>=100){(r.childrenIds?.length??0)+(r.dependsOn?.length??0)>0&&(S=!0);continue}let d=e=>_.has(e)?!0:_.size>=500?(S=!0,!1):(_.add(e),g.push({id:e,depth:n+1}),!0),m=(e,t,n,r)=>{if(!d(r))return;let i=`${e}->${t}:${n}`;l.has(i)||(l.add(i),s.push({from:e,to:t,kind:n}))},h=r.childrenIds??[],y=r.dependsOn??[],b=new Set(h),C=new Set(y);b.size!==h.length&&p.add(`Job ${t} lists a child more than once`),C.size!==y.length&&p.add(`Job ${t} lists a dependency more than once`);for(let e of h)m(t,e,`child`,e);for(let e of y)if(d(e)){let n=`${e}->${t}`;u.has(n)||(u.add(n),c.push({from:e,to:t,kind:`depends`})),b.has(e)||m(e,t,`depends`,e)}}for(let[e,t]of o)!f.has(e)&&P(t).length>1&&p.add(`Job ${e} enables mutually exclusive failure policies`);for(let e of s){if(e.kind!==`child`||f.has(e.to))continue;let t=o.get(e.to);t&&t.parentId!==e.from&&p.add(`Child ${e.to} points to parent ${String(t.parentId??`none`)}, not ${e.from}`)}for(let[e,t]of o){if(f.has(e))continue;let n=t.childrenIds??[];if(n.some(e=>!o.has(e)||f.has(e)))continue;let r=n.map(t=>({childId:t,release:F(o.get(t),e)})).find(({release:e})=>e?.scope===`parent`);for(let i of n){if(t.dependsOn?.includes(i))continue;if(r?.release?.scope===`parent`){m.add(`Parent ${e} is missing dependency ${i}; ${r.release.policy} on child ${r.childId} may have released all parent dependencies, but the HTTP snapshot cannot prove whether the policy fired`);continue}let n=F(o.get(i),e);if(n?.scope===`child`){m.add(`Parent ${e} is missing dependency ${i}; ${n.policy} may have released it, but the HTTP snapshot cannot prove whether the policy fired`);continue}p.add(`Parent ${e} lists child ${i} without the matching dependency`)}}for(let[e,t]of o){if(f.has(e)||!t.parentId)continue;let n=o.get(t.parentId);!n||f.has(t.parentId)||n.childrenIds?.includes(e)||p.add(`Parent ${t.parentId} does not list child ${e}`)}let C=N([...o.keys()],c);return{jobs:o,edges:s,truncated:S,failed:f.size,failures:f,issues:[...p],policyNotes:[...m],cycle:C,limitations:[...h]}}var ie=`bq-dash-recent-flows`,ae=8;function oe(e){return`${ie}:${encodeURIComponent(e.trim()||`/api`)}`}function se(e,t){if(!t)return[];try{let t=JSON.parse(localStorage.getItem(oe(e))??`[]`);return Array.isArray(t)?t.filter(e=>typeof e?.root==`string`&&e.root.length>0&&e.root.length<=1024&&Number.isSafeInteger(e?.nodes)&&e.nodes>1&&e.nodes<=500&&Number.isFinite(e?.at)&&e.at>=0).slice(0,ae):[]}catch{return[]}}function ce(e,t,n,r){let i=[n,...t.filter(e=>e.root!==n.root)].slice(0,ae);if(!r)return i;try{localStorage.setItem(oe(e),JSON.stringify(i))}catch{}return i}var I=e(n(),1),le=new Set([`explore`,`create`,`operations`]);function ue(e,t=``){let n=e.get(`root`),r=R(n)?n:t,i=e.get(`mode`),a=le.has(i)?i:`explore`,o=e.get(`node`);return{root:r,mode:a,node:r&&R(o)?o:null}}function L(e){let t=new URLSearchParams;return e.root&&t.set(`root`,e.root),e.mode!==`explore`&&t.set(`mode`,e.mode),e.root&&e.node&&t.set(`node`,e.node),t}function de(e,t,n=``){return L({...ue(e,n),...t})}function R(e){return!!(e&&M(e)===null)}function fe(){let[e,n]=t(),r=v()?ee:``,i=e.toString(),s=(0,I.useMemo)(()=>ue(new URLSearchParams(i),r),[r,i]),c=s.root,l=o(e=>e.baseUrl),u=o(e=>e.token),f=a(),[p,m]=(0,I.useState)(c),[h,g]=(0,I.useState)(null),[_,y]=(0,I.useState)(!!c),[b,x]=(0,I.useState)(null),[S,C]=(0,I.useState)(()=>se(f,u.length===0)),w=(0,I.useRef)(0),T=(0,I.useRef)(null),E=(0,I.useRef)(!1),D=(0,I.useRef)(z()),k=h?.seed===c?h.graph:null,A=k?s.node&&k.jobs.has(s.node)?s.node:h?.defaultSelected??null:null,j=(0,I.useCallback)((e,t=!1)=>{n(t=>de(t,e,r),{replace:t})},[r,n]),N=(0,I.useCallback)(async e=>{let t=o.getState();if(t.baseUrl!==l||t.token!==u)return;T.current?.abort(),T.current=null;let n=++w.current,r=e.trim();if(g(null),x(null),!r)return y(!1);let i=M(r);if(i)return x(new O(i)),y(!1);let a=d(),s=z(),c=new AbortController;T.current=c;let f=()=>E.current&&n===w.current&&!c.signal.aborted&&s===z();y(!0);try{let e={target:a,signal:c.signal},t=await te(r,e),n=t.missingParent?[`Ancestor ${t.missingParent} is no longer available. The graph starts at the oldest surviving node.`]:[],i=await re(t.id,t.job,{...e,seedPath:t.path,limitations:n});if(!f())return;g({seed:r,graph:i,defaultSelected:t.id}),i.jobs.size>1&&C(e=>ce(a.baseUrl,e,{root:t.id,nodes:i.jobs.size,at:Date.now()},o.getState().token.length===0))}catch(e){f()&&x(e instanceof Error?e:Error(`Failed to load flow`))}finally{T.current===c&&(T.current=null),f()&&y(!1)}},[l,u]);return(0,I.useEffect)(()=>{E.current=!0,D.current=z();let e=o.subscribe(()=>{let e=z();e!==D.current&&(D.current=e,w.current+=1,T.current?.abort(),T.current=null,E.current&&(g(null),x(null),y(!1)))});return()=>{E.current=!1,e(),w.current+=1,T.current?.abort()}},[]),(0,I.useEffect)(()=>C(u?[]:se(f,!0)),[f,u]),(0,I.useEffect)(()=>{let e={...s};k&&(!e.node||!k.jobs.has(e.node))&&(e.node=h?.defaultSelected??null);let t=L(e).toString();t!==i&&n(t,{replace:!0})},[k,i,n,h?.defaultSelected,s]),(0,I.useEffect)(()=>{m(c),N(c)},[c,N]),{input:p,setInput:m,rootParam:c,mode:s.mode,setMode:e=>j({mode:e}),graph:k,selected:A,setSelected:e=>{k?.jobs.has(e)&&j({node:e})},loading:_,error:b,recent:S,load:N,submit:e=>{e.preventDefault();let t=p.trim();if(t){if(M(t))return void N(t);t===c?N(t):j({root:t,mode:`explore`,node:null})}},openRecent:e=>{if(m(e),M(e))return void N(e);let t=e===c;j({root:e,mode:`explore`,node:null}),t&&N(e)}}}function z(){let{token:e}=o.getState();return JSON.stringify([a(),e])}function pe(e){return e instanceof c&&e.status===0||[`TypeError`,`AbortError`,`TimeoutError`].includes(e.name)}var B=e=>({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),me=new Set([`removeChildDependency`,`removeUnprocessedChildren`,`removeDeduplicationKey`,`retry`,`promote`,`remove`]),he=e=>e+5e3,V={create:(e,t)=>u(`/flows/create?target=${encodeURIComponent(a())}`,B({operation:e,...t})),getFlow:e=>{let t=new URLSearchParams({id:e.id,queueName:e.queueName,target:a()});return e.depth!==void 0&&t.set(`depth`,String(e.depth)),e.maxChildren!==void 0&&t.set(`maxChildren`,String(e.maxChildren)),u(`/flows/tree?${t}`)},inspect:(e,t)=>u(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:a()})}`),getParentResult:e=>u(`/flows/results?target=${encodeURIComponent(a())}`,B({operation:`getParentResult`,parentId:e})),getParentResults:e=>u(`/flows/results?target=${encodeURIComponent(a())}`,B({operation:`getParentResults`,parentIds:e})),waitUntilFinished:(e,t)=>u(`/flows/jobs/${encodeURIComponent(e.id)}/waitUntilFinished?${new URLSearchParams({queueName:e.queueName,target:a(),ttl:String(t)})}`,void 0,he(t)),mutate:(e,t,n)=>(S(t),u(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:a()})}`,me.has(t)?{method:`POST`}:B(n??{})))},H=i();function U({value:e}){return(0,H.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-md border border-line bg-bg p-3 font-mono text-xs text-muted`,children:JSON.stringify(e,null,2)})}function W(...e){return JSON.stringify(e)}function G(e,t=`shared`){let n=y(),r=`flow-exclusive:${t}`,i=x(r),a=(0,I.useMemo)(()=>({key:e,connectionEpoch:n}),[n,e]),o=(0,I.useRef)(a),s=(0,I.useRef)(void 0),c=(0,I.useRef)(void 0),l=(0,I.useRef)(void 0),u=(0,I.useRef)(0),d=(0,I.useRef)(!0),[f,p]=(0,I.useState)(),[m,h]=(0,I.useState)(),[g,_]=(0,I.useState)();return(0,I.useLayoutEffect)(()=>{o.current.connectionEpoch!==a.connectionEpoch&&(c.current=void 0),o.current=a,s.current=void 0,l.current=void 0},[a]),(0,I.useEffect)(()=>(d.current=!0,()=>{d.current=!1,s.current=void 0,c.current=void 0,l.current=void 0}),[]),{busy:f?.exclusive&&f.identity.connectionEpoch===a.connectionEpoch||f?.identity===a?f.label:``,error:g?.identity===a?g.message:``,result:m?.identity===a?m.value:void 0,reject:e=>{c.current||b()!==a.connectionEpoch||(l.current=void 0,s.current=void 0,p(void 0),h(void 0),_({identity:a,message:e}))},run:async(e,t,n={})=>{let f=n.exclusive===!0;if(c.current||s.current?.identity===a||b()!==a.connectionEpoch)return;let m=i.begin(r);if(!m)return;f||m.finish();let g={id:++u.current,identity:a};f?c.current=g:s.current=g,l.current=g,p({...g,exclusive:f,label:e}),h(void 0),_(void 0);try{let e=await t();d.current&&o.current===a&&b()===a.connectionEpoch&&l.current===g&&h({identity:a,value:e})}catch(e){d.current&&o.current===a&&b()===a.connectionEpoch&&l.current===g&&_({identity:a,message:ge(e)})}finally{f&&m.finish(),c.current===g&&(c.current=void 0),s.current===g&&(s.current=void 0),d.current&&p(e=>e?.id===g.id?void 0:e)}}}}function ge(e){return e instanceof Error?e.message:String(e)}var K={add:{flow:{name:`aggregate`,queueName:`reports`,data:{},children:[{name:`fetch`,queueName:`io`,data:{source:`orders`}}]},options:{queuesOptions:{io:{attempts:3,backoff:1e3}}}},addBulk:{flows:[{name:`report-a`,queueName:`reports`,data:{region:`eu`}},{name:`report-b`,queueName:`reports`,data:{region:`us`}}]},addChain:{steps:[{name:`extract`,queueName:`pipeline`,data:{}},{name:`transform`,queueName:`pipeline`,data:{}},{name:`load`,queueName:`pipeline`,data:{}}]},addBulkThen:{parallel:[{name:`part-a`,queueName:`parallel`,data:{}},{name:`part-b`,queueName:`parallel`,data:{}}],final:{name:`merge`,queueName:`final`,data:{}}},addTree:{root:{name:`root`,queueName:`tree`,data:{},children:[{name:`child`,queueName:`tree`,data:{}}]}}};function _e({repository:e=V,onOpen:t}){let[n,r]=(0,I.useState)(`add`),[i,a]=(0,I.useState)(()=>JSON.stringify(K.add,null,2)),o=G(W(n,i),`creator`),s=!!o.busy,c=e=>{r(e),a(JSON.stringify(K[e],null,2))},l=async t=>{t.preventDefault();let r;try{r=JSON.parse(i)}catch{return o.reject(`The definition must be valid JSON.`)}if(!r||typeof r!=`object`||Array.isArray(r))return o.reject(`The definition must be a JSON object.`);let a=n;await o.run(a,()=>e.create(a,r),{exclusive:!0})},u=ve(o.result);return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`form`,{onSubmit:l,className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`FlowProducer method`,(0,H.jsx)(`select`,{"aria-label":`FlowProducer method`,value:n,onChange:e=>c(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:Object.keys(K).map(e=>(0,H.jsx)(`option`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`submit`,disabled:s,className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:s?`Creating…`:`Run ${n}`})]}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Definition`,(0,H.jsx)(`textarea`,{"aria-label":`Flow definition JSON`,spellCheck:!1,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-80 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg outline-none focus:ring-2 focus:ring-accent/50`})]})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Atomic commit result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:`Validation is performed by Bunqueue before the graph is committed.`}),o.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:o.error}),o.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow created in this session.`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{value:o.result}),u&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(u),className:`mt-3 rounded-lg border border-line px-3 py-2 text-xs text-fg`,children:`Open created flow`})]})]})]})}function ve(e){let t=e,n=t?.result?.root?.id??t?.result?.roots?.[0]?.id??t?.result?.finalId??t?.result?.jobIds?.at(-1);return typeof n==`string`?n:null}function ye({recent:e,onOpen:t}){return(0,H.jsx)(p,{children:(0,H.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID, or choose “View flow” from Job Inspector.`}),e.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,H.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:e.map(e=>(0,H.jsxs)(`button`,{type:`button`,title:e.root,onClick:()=>t(e.root),className:`min-h-10 rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted hover:text-fg`,children:[(0,H.jsx)(`span`,{translate:`no`,children:D(e.root)}),(0,H.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})})}function q({target:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Job ID`,(0,H.jsx)(`input`,{"aria-label":`Flow job ID`,value:e.id,onChange:n=>t({...e,id:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 font-mono text-sm text-fg`})]}),(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Queue name`,(0,H.jsx)(`input`,{"aria-label":`Flow queue name`,value:e.queueName,onChange:n=>t({...e,queueName:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})]})}var be=[`getChildrenValues`,`getDependencies`,`getDependenciesCount`,`getFailedChildrenValues`,`getIgnoredChildrenFailures`],xe=[{id:`removeChildDependency`,label:`Release dependency`,dangerous:!0},{id:`removeUnprocessedChildren`,label:`Remove unprocessed children`,dangerous:!0},{id:`retry`,label:`Retry job`},{id:`promote`,label:`Promote delayed job`},{id:`remove`,label:`Remove job`,dangerous:!0}];function Se({repository:e=V,initialTarget:t={id:``,queueName:``},target:n,onTargetChange:r,showTarget:i=!0}){let[a,o]=(0,I.useState)(t),s=n??a,c=r??o,l=G(W(s.id,s.queueName),`dependency-console`),u=l.busy,d=!!(s.id.trim()&&s.queueName.trim()),f=t=>{let n=Ce(s);l.run(t,()=>e.inspect(n,t))},p=t=>{let n=C(t);if(n)return l.reject(n);let r=Ce(s);window.confirm(`${t} on ${r.id} in ${r.queueName}? This changes durable queue state and has no compare-and-swap precondition.`)&&l.run(t,()=>e.mutate(r,t),{exclusive:!0})};return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(360px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Dependency control`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Run the official Flow Job dependency methods against the managed server TCP endpoint.`}),i&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:s,onChange:c})}),(0,H.jsx)(`p`,{className:`mt-3 text-xs text-muted`,children:`Payload replacement, retry and removal are unavailable because they can damage flow dependencies or restart active work.`}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:be.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,onClick:()=>f(e),className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:e},e))}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Mutate`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:xe.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u||!!C(e.id),title:C(e.id)??void 0,onClick:()=>p(e.id),className:e.dangerous?`rounded-md border border-danger/40 px-2.5 py-1.5 text-xs text-danger disabled:opacity-40`:`rounded-md border border-line px-2.5 py-1.5 text-xs text-muted disabled:opacity-40`,children:e.label},e.id))})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Operation result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:u?`Running ${u}…`:`The last authoritative broker response appears here.`}),l.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:l.error}),l.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Choose an inspection or mutation.`}):(0,H.jsx)(U,{value:l.result})]})]})}var Ce=e=>({id:e.id.trim(),queueName:e.queueName.trim()});function we({repository:e=V,initialIds:t=``}){let[n,r]=(0,I.useState)(t),i=G(W(n)),a=i.busy,o=Te(n),s=async t=>{if(o.length===0)return;let n=[...o];await i.run(t,async()=>t===`one`?await e.getParentResult(n[0]):await e.getParentResults(n))};return(0,H.jsxs)(`section`,{className:`grid gap-5 rounded-lg border border-line bg-surface p-4 xl:grid-cols-[minmax(320px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Parent results`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Resolve completed parent values through the official FlowProducer result API.`}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Parent IDs, one per line`,(0,H.jsx)(`textarea`,{"aria-label":`Flow parent IDs`,value:n,onChange:e=>r(e.target.value),placeholder:`parent-job-id
2
2
  another-parent-id`,className:`mt-1 min-h-28 w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg`})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:o.length===0||!!a,onClick:()=>void s(`one`),className:`rounded-md border border-line px-3 py-1.5 font-mono text-xs text-muted disabled:opacity-40`,children:`getParentResult`}),(0,H.jsxs)(`button`,{type:`button`,disabled:o.length===0||!!a,onClick:()=>void s(`many`),className:`rounded-md border border-line px-3 py-1.5 font-mono text-xs text-muted disabled:opacity-40`,children:[`getParentResults (`,o.length,`)`]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`Resolved values`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:a?`Reading durable results…`:`Falsy values and input ordering are preserved.`}),i.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:i.error}),i.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No parent result requested.`}):(0,H.jsx)(U,{value:i.result})]})]})}function Te(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).slice(0,1e3)}function Ee({repository:e=V,target:t,onTargetChange:n}){let[r,i]=(0,I.useState)(`10`),[a,o]=(0,I.useState)(`100`),s=G(W(t.id,t.queueName,r,a)),c=!!s.busy,l=!!(t.id.trim()&&t.queueName.trim())&&je(r)&&je(a),u=async()=>{if(!l)return;let n={target:{id:t.id.trim(),queueName:t.queueName.trim()},depth:Number(r),maxChildren:Number(a)};await s.run(`getFlow`,async()=>{let t=await e.getFlow({...n.target,depth:n.depth,maxChildren:n.maxChildren});return{...n,value:t}})};return(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`FlowProducer.getFlow`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Read the broker-native tree with explicit traversal limits. Results are bound to the target and limits that produced them.`})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!l||c,onClick:()=>void u(),className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:c?`Loading tree...`:`Load getFlow tree`})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:t,onChange:n})}),(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(De,{label:`Depth`,value:r,onChange:i}),(0,H.jsx)(De,{label:`Children per level`,value:a,onChange:o})]}),(0,H.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Both limits accept integers from 0 to 500.`}),s.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:s.error}),s.result&&(0,H.jsx)(Oe,{loaded:s.result})]})}function De({label:e,value:t,onChange:n}){return(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[e,(0,H.jsx)(`input`,{"aria-label":`getFlow ${e}`,type:`number`,min:`0`,max:`500`,step:`1`,value:t,onChange:e=>n(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})}function Oe({loaded:e}){let t=ke(e.value),n=t?Ae(t):[];return(0,H.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,"aria-live":`polite`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,H.jsxs)(`span`,{className:`font-mono text-fg`,children:[e.target.queueName,`/`,e.target.id]}),(0,H.jsxs)(`span`,{className:`text-faint`,children:[`depth `,e.depth,`, max children `,e.maxChildren]})]}),t===null?(0,H.jsx)(`p`,{className:`rounded-md border border-line bg-bg p-3 text-sm text-muted`,children:`Bunqueue returned no flow for this target.`}):n.length>0?(0,H.jsx)(`ul`,{"aria-label":`getFlow tree result`,className:`max-h-72 overflow-auto rounded-md border border-line bg-bg`,children:n.map(e=>(0,H.jsxs)(`li`,{className:`flex min-w-max items-center gap-2 border-b border-line/60 px-3 py-2 last:border-b-0`,style:{paddingLeft:`${12+Math.min(e.level,20)*18}px`},children:[(0,H.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${E(e.state)}`,children:e.state}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-fg`,children:e.id}),(0,H.jsx)(`span`,{className:`text-xs text-muted`,children:e.name}),(0,H.jsx)(`span`,{className:`text-[11px] text-faint`,children:e.queueName})]},e.id))}):(0,H.jsx)(`p`,{role:`alert`,className:`rounded-md border border-warning/40 p-3 text-sm text-warning`,children:`The agent returned an unrecognized getFlow payload. Inspect the raw JSON below.`}),(0,H.jsxs)(`details`,{className:`mt-3`,open:!0,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-muted`,children:`Raw getFlow JSON`}),(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsx)(U,{value:e.value})})]})]})}function ke(e){let t=J(e),n=J(t?.result)??t;if(!(!n||!Object.hasOwn(n,`flow`)))return n.flow===null?null:J(n.flow)}function Ae(e){let t=[],n=[{node:e,level:0}],r=new WeakSet;for(;n.length>0&&t.length<1e3;){let e=n.shift();if(!e||r.has(e.node))continue;r.add(e.node),t.push({id:Y(e.node.id,`(missing id)`),name:Y(e.node.name,`(unnamed)`),queueName:Y(e.node.queueName,`(missing queue)`),state:Y(e.node.state,`unknown`),level:e.level});let i=Array.isArray(e.node.children)?e.node.children:[];n.unshift(...i.map(J).filter(e=>e!==void 0).map(t=>({node:t,level:e.level+1})))}return t}var je=e=>/^\d+$/.test(e)&&Number(e)<=500,J=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,Y=(e,t)=>typeof e==`string`&&e.length>0?e:t,Me=[`getState`,`isWaiting`,`isActive`,`isDelayed`,`isCompleted`,`isFailed`,`isWaitingChildren`,`toJSON`,`asJSON`],X={updateData:{data:{}},updateProgress:{progress:50,message:`Halfway`},log:{message:`Operator note`},changeDelay:{delay:1e3},changePriority:{priority:1,lifo:!1},clearLogs:{keepLogs:0},removeDeduplicationKey:{}},Ne={progress:{stage:`hydrate`,completed:4,total:10}};function Pe({repository:e=V,initialTarget:t={id:``,queueName:``}}){let[n,r]=(0,I.useState)(t),[i,a]=(0,I.useState)(`updateProgress`),[o,s]=(0,I.useState)(JSON.stringify(X.updateProgress,null,2)),[c,l]=(0,I.useState)(`30000`),u=G(W(n.id,n.queueName,i,o,c),`job-toolkit`),d=u.busy,f=!!(n.id.trim()&&n.queueName.trim()),p=e=>{a(e),s(JSON.stringify(X[e],null,2))};return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsx)(Ee,{repository:e,target:n,onTargetChange:r}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Flow Job methods`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`State predicates, serialization, bounded waiting, and durable mutations from Bunqueue 2.9.4.`})]}),d&&(0,H.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[d,`…`]})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:n,onChange:r})}),(0,H.jsx)(`p`,{className:`mt-3 text-xs text-muted`,children:`Payload replacement, retry and removal are unavailable because they can damage flow dependencies or restart active work.`}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect state and wire JSON`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Me.map(t=>(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d,onClick:()=>{let r=Z(n);u.run(t,()=>e.inspect(r,t))},className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:t},t))}),(0,H.jsxs)(`div`,{className:`mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Mutation`,(0,H.jsx)(`select`,{"aria-label":`Flow Job mutation`,value:i,onChange:e=>p(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 font-mono text-xs text-fg`,children:Object.keys(X).map(e=>(0,H.jsx)(`option`,{disabled:!!C(e),children:e},e))})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d||!!C(i),title:C(i)??void 0,onClick:()=>{let t=C(i);if(t)return u.reject(t);let r;try{r=JSON.parse(o)}catch{return u.reject(`Mutation payload must be valid JSON.`)}if(!r||typeof r!=`object`||Array.isArray(r))return u.reject(`Mutation payload must be a JSON object.`);let a=Z(n),s=i;window.confirm(`${s} on ${a.id}? This writes durable job state without a compare-and-swap precondition.`)&&u.run(s,()=>e.mutate(a,s,r),{exclusive:!0})},className:`h-9 rounded-md border border-warning/40 px-3 text-xs text-warning disabled:opacity-40`,children:`Apply mutation`}),i===`updateProgress`&&(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(JSON.stringify(X.updateProgress,null,2)),className:`h-9 rounded-md border border-line px-3 text-xs text-muted`,children:`Numeric progress`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(JSON.stringify(Ne,null,2)),className:`h-9 rounded-md border border-line px-3 text-xs text-muted`,children:`Object progress`})]})]}),(0,H.jsx)(`textarea`,{"aria-label":`Flow Job mutation JSON`,value:o,onChange:e=>s(e.target.value),className:`mt-3 min-h-32 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`waitUntilFinished TTL (ms)`,(0,H.jsx)(`input`,{"aria-label":`Flow wait TTL`,type:`number`,min:`1`,max:`60000`,value:c,onChange:e=>l(e.target.value),className:`mt-1 block h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d||!Fe(c),onClick:()=>{let t=Z(n),r=Number(c);u.run(`waitUntilFinished`,()=>e.waitUntilFinished(t,r))},className:`mt-3 rounded-md border border-line px-3 py-2 font-mono text-xs text-muted disabled:opacity-40`,children:`waitUntilFinished`}),(0,H.jsx)(`p`,{className:`mt-3 text-[11px] leading-5 text-faint`,children:`Lease-only methods are not forged here: extendLock and worker state transitions require the active worker token; discard is process-local and non-awaitable.`})]})]}),u.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:u.error}),u.result!==void 0&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(U,{value:u.result})})]}),(0,H.jsx)(Se,{repository:e,target:n,onTargetChange:r,showTarget:!1}),(0,H.jsx)(we,{repository:e})]})}var Z=e=>({id:e.id.trim(),queueName:e.queueName.trim()}),Fe=e=>Number.isSafeInteger(Number(e))&&Number(e)>=1&&Number(e)<=6e4;function Ie({input:e,loading:t,onInput:n,onSubmit:r}){return(0,H.jsxs)(p,{className:`mb-6`,children:[(0,H.jsxs)(`form`,{onSubmit:r,className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`input`,{name:`flow-job-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:e,onChange:e=>n(e.target.value),placeholder:`Flow job ID`,"aria-label":`Root job ID`,"aria-describedby":`flow-input-help`,className:`min-w-0 flex-1 rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,H.jsx)(`button`,{type:`submit`,disabled:t||!e.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:t?`Loading…`:`Load Flow`})]}),(0,H.jsxs)(`p`,{id:`flow-input-help`,className:`mt-2 text-xs text-faint`,children:[`Start from any surviving structural node. Bunqueue 2.9.3 flow topology is resolved from durable parent, children, and dependency contracts. Up to `,500,` nodes are rendered.`]})]})}var Le={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function Re(e,t){let n=new Map,r=new Map;for(let t of e)n.set(t,0),r.set(t,[]);for(let e of t)!n.has(e.from)||!n.has(e.to)||e.from===e.to||r.get(e.from)?.push(e.to);let i=ze(e,r),a=new Map;for(let t of e)a.set(t,0);for(let e of i.values())for(let t of e)a.set(t,(a.get(t)??0)+1);let o=[...n.keys()].filter(e=>(a.get(e)??0)===0);for(let e=0;e<o.length;e++){let t=o[e];for(let e of i.get(t)??[]){n.set(e,Math.max(n.get(e)??0,(n.get(t)??0)+1));let r=(a.get(e)??0)-1;a.set(e,r),r===0&&o.push(e)}}return n}function ze(e,t){let n=new Map;for(let t of e)n.set(t,[]);let r=new Set,i=new Set;for(let a of e){if(i.has(a))continue;i.add(a),r.add(a);let e=[{id:a,next:0}];for(;e.length;){let a=e[e.length-1],o=t.get(a.id)??[];if(a.next>=o.length){r.delete(a.id),e.pop();continue}let s=o[a.next++];r.has(s)||(n.get(a.id)?.push(s),!i.has(s)&&(i.add(s),r.add(s),e.push({id:s,next:0})))}}return n}function Be(e,t,n={}){let r={...Le,...n},i=Re(e,t),a=new Map,o=0;for(let t of e){let e=i.get(t)??0;o=Math.max(o,e);let n=a.get(e);n?n.push(t):a.set(e,[t])}let s=0;for(let e of a.values())s=Math.max(s,e.length);let c=s*r.nodeHeight+Math.max(0,s-1)*r.rowGap,l=[];for(let e=0;e<=o;e++){let t=a.get(e)??[],n=t.length*r.nodeHeight+Math.max(0,t.length-1)*r.rowGap,i=r.padding+(c-n)/2;t.forEach((t,n)=>{l.push({id:t,layer:e,x:r.padding+e*(r.nodeWidth+r.colGap),y:i+n*(r.nodeHeight+r.rowGap)})})}return{nodes:l,width:r.padding*2+(o+1)*r.nodeWidth+o*r.colGap,height:r.padding*2+c}}function Ve({graph:e,layout:t,selected:n,onSelect:r}){let i=new Map(t.nodes.map(e=>[e.id,e]));return(0,H.jsxs)(p,{padded:!1,className:`max-h-[70vh] overflow-auto overscroll-contain p-4`,children:[(0,H.jsx)(`h2`,{className:`sr-only`,children:`Flow Graph`}),(0,H.jsx)(`ul`,{className:`sr-only`,"aria-label":`Flow relationships`,children:e.edges.map(e=>(0,H.jsx)(`li`,{children:e.kind===`child`?`${e.from} has child ${e.to}`:`${e.to} depends on ${e.from}`},`accessible-${e.from}-${e.to}-${e.kind}`))}),(0,H.jsxs)(`div`,{className:`relative`,style:{width:t.width,height:t.height},children:[(0,H.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:t.width,height:t.height,children:[(0,H.jsxs)(`defs`,{children:[(0,H.jsx)(`marker`,{id:`flow-arrow-child`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,H.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})}),(0,H.jsx)(`marker`,{id:`flow-arrow-dependency`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,H.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})})]}),e.edges.map(e=>{let t=i.get(e.from),n=i.get(e.to);return!t||!n?null:(0,H.jsx)(`path`,{d:Ue(t,n),fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeDasharray:e.kind===`depends`?`4 4`:void 0,markerEnd:`url(#flow-arrow-${e.kind===`depends`?`dependency`:`child`})`,opacity:.5},`${e.from}-${e.to}-${e.kind}`)})]}),t.nodes.map(t=>{let i=e.jobs.get(t.id),a=e.failures.has(t.id)?`unavailable`:i?.state??`unknown`;return(0,H.jsxs)(`button`,{type:`button`,"data-flow-node":t.id,onClick:()=>r(t.id),"aria-pressed":n===t.id,"aria-label":`${t.id}, queue ${i?.queue??`unknown`}, state ${a}`,title:t.id,style:{left:t.x,top:t.y,width:168,height:60},className:f(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/70`,E(i?.state),n===t.id&&`ring-2 ring-accent`),children:[(0,H.jsx)(`span`,{translate:`no`,className:`truncate font-mono text-xs text-fg`,children:D(t.id)}),(0,H.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:i?.queue??`—`}),(0,H.jsx)(`span`,{className:`font-medium`,children:a})]})]},t.id)})]})]})}function He(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function Ue(e,t){return e.x<=t.x?He(e.x+168,e.y+60/2,t.x,t.y+60/2):He(e.x,e.y+60/2,t.x+168,t.y+60/2)}function We({graph:e,selected:t}){let n=t?e.jobs.get(t):void 0,r=t?e.failures.get(t):void 0;return(0,H.jsx)(`aside`,{"aria-label":`Selected job details`,"aria-live":`polite`,children:(0,H.jsxs)(p,{children:[n?(0,H.jsx)(Ge,{job:n,failure:r}):(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Select a node to inspect it.`}),(0,H.jsx)(Ke,{graph:e})]})})}function Ge({job:e,failure:t}){return(0,H.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,H.jsx)(`div`,{translate:`no`,className:`break-all font-mono text-xs text-fg`,children:e.id})]}),t&&(0,H.jsxs)(`p`,{role:`alert`,className:`break-words text-xs text-warning`,children:[`Snapshot unavailable: `,t]}),(0,H.jsx)($,{label:`Queue`,value:e.queue??`—`}),(0,H.jsx)($,{label:`State`,value:t?`unavailable`:e.state??`unknown`}),(0,H.jsx)($,{label:`Priority`,value:e.priority===void 0?`—`:String(e.priority)}),(0,H.jsx)($,{label:`Parent`,value:e.parentId??`—`}),(0,H.jsx)($,{label:`Children`,value:t?`—`:String(e.childrenIds?.length??0)}),(0,H.jsx)($,{label:`Depends on`,value:t?`—`:String(e.dependsOn?.length??0)}),(0,H.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`inline-block rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Open in Job Inspector`})]})}function Ke({graph:e}){return(0,H.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,"aria-live":`polite`,children:[e.truncated&&(0,H.jsxs)(`div`,{className:`mb-1 text-warning`,children:[`Graph truncated at `,500,` nodes / depth `,100,`.`]}),(0,H.jsx)(Q,{label:`known snapshot limitation`,pluralLabel:`known snapshot limitations`,values:e.limitations,tone:`text-warning`}),(0,H.jsx)(Q,{label:`unavailable node`,pluralLabel:`unavailable nodes`,values:[...e.failures].map(([e,t])=>`${e}: ${t}`),tone:`text-warning`}),e.cycle&&(0,H.jsxs)(`div`,{className:`mb-1 break-words text-danger`,children:[`Dependency cycle: `,(0,H.jsx)(`span`,{className:`font-mono`,children:e.cycle.join(` → `)})]}),(0,H.jsx)(Q,{label:`snapshot inconsistency`,pluralLabel:`snapshot inconsistencies`,values:e.issues,tone:`text-warning`}),e.policyNotes.length>0&&(0,H.jsx)(`p`,{className:`mb-1 text-muted`,children:`Failure-policy notes are informational; the HTTP snapshot cannot prove that a policy fired.`}),(0,H.jsx)(Q,{label:`failure-policy ambiguity`,pluralLabel:`failure-policy ambiguities`,values:e.policyNotes,tone:`text-muted`}),(0,H.jsxs)(`div`,{className:`mb-1`,children:[e.jobs.size,` nodes · `,e.edges.length,` edges`]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` depends`]})]})]})}function Q({label:e,pluralLabel:t,values:n,tone:r}){return n.length?(0,H.jsxs)(`details`,{className:`mb-1 ${r}`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer`,children:[n.length,` `,n.length===1?e:t]}),(0,H.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:n.map(e=>(0,H.jsx)(`li`,{className:`break-words`,children:e},e))})]}):null}function $({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e}),(0,H.jsx)(`span`,{className:`min-w-0 break-all text-right text-fg`,children:t})]})}function qe({graph:e,selected:t,onSelect:n}){return(0,H.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,H.jsx)(Ve,{graph:e,layout:(0,I.useMemo)(()=>Be([...e.jobs.keys()],e.edges,w),[e]),selected:t,onSelect:n}),(0,H.jsx)(We,{graph:e,selected:t})]})}function Je(){let e=fe();return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(_,{title:`Job Flows`,description:`Inspect Bunqueue 2.9.3 parent, child, and dependency topology as an operational DAG.`,actions:e.graph&&(0,H.jsx)(`button`,{type:`button`,disabled:e.loading,onClick:()=>void e.load(e.rootParam),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg disabled:opacity-50`,children:`Refresh`})}),(0,H.jsx)(`nav`,{"aria-label":`Job Flow tools`,className:`mb-5 flex border-b border-line`,children:[`explore`,`create`,`operations`].map(t=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":e.mode===t,onClick:()=>e.setMode(t),className:e.mode===t?`border-b-2 border-accent px-4 py-2 text-sm capitalize text-fg`:`border-b-2 border-transparent px-4 py-2 text-sm capitalize text-faint hover:text-fg`,children:t===`operations`?`Job methods`:t},t))}),e.mode===`create`&&(0,H.jsx)(_e,{onOpen:e.openRecent}),e.mode===`operations`&&(0,H.jsx)(Pe,{initialTarget:v()?{id:`flow-order-9a3f`,queueName:`orders`}:void 0}),e.mode===`explore`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ie,{input:e.input,loading:e.loading,onInput:e.setInput,onSubmit:e.submit}),(0,H.jsxs)(`div`,{"aria-live":`polite`,children:[e.error&&(pe(e.error)?(0,H.jsx)(m,{message:`Could not load the flow — ${e.error.message}`,onRetry:()=>void e.load(e.rootParam)}):(0,H.jsx)(h,{error:e.error,onRetry:()=>void e.load(e.rootParam)})),e.loading&&(0,H.jsx)(g,{label:`Loading flow…`})]}),!e.loading&&!e.graph&&!e.error&&(0,H.jsx)(ye,{recent:e.recent,onOpen:e.openRecent}),e.graph&&(0,H.jsx)(qe,{graph:e.graph,selected:e.selected,onSelect:e.setSelected})]})]})}export{Je as Flows};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,l as r,r as i,t as a}from"./react-vendor-CFL9l8LK.js";import{a as o,o as s}from"./connectionStore-CVjQyIZv.js";import{a as c,n as l}from"./upstreamPaths-DQeKSxGc.js";import{a as u,n as d,t as f}from"./bq-DR2BTISO.js";import{T as p,d as m}from"./icons-DH9SS1DA.js";import{t as h}from"./StatusBadge-DereLzOj.js";import{n as g,t as _}from"./Button-_aSJvRoW.js";import{n as v,t as y}from"./Card-egIDLwVk.js";import{r as b,t as x}from"./feedback-CtGN_kqB.js";import{t as S}from"./PageHeader-CQzNsw8r.js";import{a as C,i as w}from"./format-Cg7VCIZW.js";import{a as T}from"./index-DZFZr0Mi.js";import{a as E,n as D,o as O}from"./form-DG3X6cLL.js";import{r as k}from"./flowMutationSafety-YKTHxqKv.js";import{n as A}from"./exportFile-C7xhE8Yh.js";import{t as j}from"./flowOperationPolicy-B2Etcb3f.js";var M=1e4,ee=100,te=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 ne(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 re(e){let t=[],n=0,r=!1,i=Math.min(e.length,ee);for(let a=0;a<i;a++){let i=+(t.length>0),o=te-n-i;if(o<=0){r=!0;break}let s=e[a]??``,c=ne(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{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,l as r,r as i,t as a}from"./react-vendor-DfC0iyIS.js";import{a as o,o as s}from"./connectionStore-DdLzJyut.js";import{a as c,n as l}from"./upstreamPaths-DQeKSxGc.js";import{a as u,n as d,t as f}from"./bq-CSX8DSME.js";import{T as p,d as m}from"./icons-C1HVBnFn.js";import{t as h}from"./StatusBadge-cYUkK-4P.js";import{n as g,t as _}from"./Button-BCjgbAhY.js";import{n as v,t as y}from"./Card-DptfvL2O.js";import{r as b,t as x}from"./feedback-Dxfj-Fy1.js";import{t as S}from"./PageHeader-DD4vnVog.js";import{a as C,i as w}from"./format-Cg7VCIZW.js";import{a as T}from"./index-CxzFSZj3.js";import{a as E,n as D,o as O}from"./form-Dy-an7ew.js";import{r as k}from"./flowMutationSafety-YKTHxqKv.js";import{n as A}from"./exportFile-C7xhE8Yh.js";import{t as j}from"./flowOperationPolicy-B2Etcb3f.js";var M=1e4,ee=100,te=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 ne(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 re(e){let t=[],n=0,r=!1,i=Math.min(e.length,ee);for(let a=0;a<i;a++){let i=+(t.length>0),o=te-n-i;if(o<=0){r=!0;break}let s=e[a]??``,c=ne(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 ie(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>M&&N(`job.stacktrace exceeds Bunqueue's ${M}-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 R(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)}`):(ie(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 z=3e4;function B(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function V(e,t){return e?.baseUrl===t.baseUrl&&e.authorization===t.authorization}function H(e,t,n){return t.aborted&&!n?.aborted?new u(`Request timed out`,0):e}async function U(e,t,n,r=z){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 H(e,i,n)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw H(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??B(),i=n.timeoutMs??z,a=R(await U(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 R(await U(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=B();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||!V(f,B()))return;if(n.state===`completed`)if(Object.hasOwn(n,`returnvalue`))i={result:n.returnvalue};else try{i=ae(await U(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||!V(f,B()))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 W=e(n(),1),G=a(),K=365*24*60*60*1e3;function q(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<=K?{ok:!0,value:n}:{ok:!1,msg:`Delay must be between 0 and ${K} 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=j(e.state),i=r.promote||r.setPriority||r.setDelay||e.state===`active`;return(0,G.jsxs)(y,{children:[(0,G.jsx)(v,{title:`Actions`}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,G.jsx)(_,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>f.promoteJob(e.id)),children:`Promote (run now)`}),e.state===`failed`&&(0,G.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,G.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,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsx)(J,{label:`Set progress (0–100)`,cta:`Progress`,kind:`progress`,disabled:t,onSubmit:t=>n(`Progress`,()=>f.setJobProgress(e.id,t))})]}),r.setPriority&&(0,G.jsx)(le,{disabled:t,onSubmit:(t,r)=>n(`Priority`,()=>f.changePriority(e.id,t,r))}),r.setDelay&&(0,G.jsx)(J,{label:`Set delay (ms)`,cta:`Delay`,kind:`delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>f.changeDelay(e.id,t))}),(0,G.jsxs)(`p`,{role:`note`,className:`text-xs text-faint`,children:[`Cancel/delete/discard: `,k]}),!i&&(0,G.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function J({label:e,cta:t,kind:n,disabled:r,onSubmit:i}){let[a,o]=(0,W.useState)(``),s=q(a,n);return(0,G.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!r&&s.ok&&i(s.value)},children:[(0,G.jsx)(D,{type:`number`,min:0,max:n===`progress`?100:K,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,G.jsx)(_,{type:`submit`,size:`sm`,disabled:r||!s.ok,children:t}),!s.ok&&a.trim()&&(0,G.jsx)(`span`,{role:`alert`,className:`self-center text-[11px] text-danger`,children:s.msg})]})}function le({disabled:e,onSubmit:t}){let[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(!1),o=q(n,`priority`);return(0,G.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault(),!e&&o.ok&&t(o.value,i)},children:[(0,G.jsx)(D,{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,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(O,{checked:i,onChange:a,label:`Place first among equal priorities`}),(0,G.jsx)(`span`,{className:`text-xs text-muted`,children:`LIFO`})]}),(0,G.jsx)(_,{type:`submit`,size:`sm`,disabled:e||!o.ok,children:`Set`}),!o.ok&&n.trim()&&(0,G.jsx)(`span`,{role:`alert`,className:`w-full text-[11px] text-danger`,children:o.msg})]})}var Y=36e5,X=10,Z=e=>Math.max(e,1);function ue(e){return Math.max(0,(e.maxAttempts??0)-Z(e.attempts??0))}function de(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??Y,a=r?.delay??e.backoff??1e3,o=[];for(let e=Z(n);e<t&&o.length<X;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,G.jsxs)(y,{children:[(0,G.jsx)(v,{title:`Backoff`}),(0,G.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,G.jsxs)(y,{children:[(0,G.jsx)(v,{title:`Backoff schedule`}),(0,G.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,G.jsxs)(y,{children:[(0,G.jsx)(v,{title:`Backoff schedule`,action:(0,G.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${C(r.maxDelay)}`:``]})}),(0,G.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,G.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,G.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,G.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,C(e.delayMs)]})]},e.attempt))}),a>X&&(0,G.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,X,` of `,a,` remaining attempts.`]}),(0,G.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 `,C(r?.maxDelay??Y),`.`]})]})}function pe({jobId:e}){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(void 0),[l,u]=(0,W.useState)(null),d=async()=>{o(!0),u(null);try{let t=await f.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&&d()},m=s&&typeof s==`object`?Array.isArray(s)?s.length:Object.keys(s).length:0;return(0,G.jsxs)(y,{children:[(0,G.jsx)(v,{title:`Child values`,action:(0,G.jsx)(_,{size:`sm`,variant:`ghost`,onClick:p,children:t?`Hide`:`Show`})}),t?a?(0,G.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):l?(0,G.jsx)(`p`,{className:`text-xs text-danger`,children:l}):m===0?(0,G.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,G.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,G.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,W.useState)(()=>JSON.stringify(e??null,null,2)),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(a);return(0,W.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,o(t),c(null))},[e]),(0,G.jsxs)(y,{children:[(0,G.jsx)(v,{title:`Data`,action:n?(0,G.jsx)(_,{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,G.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,G.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,G.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 Q(){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,G.jsxs)(y,{children:[(0,G.jsx)(v,{title:`Logs`,action:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:n}),(0,G.jsx)(_,{size:`sm`,variant:`ghost`,disabled:r||i,onClick:e.load,children:`Refresh`}),(0,G.jsx)(_,{size:`sm`,variant:`danger`,disabled:i||t.length===0,onClick:e.clear,children:`Clear logs`})]})}),a&&(0,G.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:a}),t.length===0?(0,G.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,G.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,G.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,G.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,G.jsx)(D,{"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,G.jsxs)(E,{"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,G.jsx)(`option`,{value:`info`,children:`info`}),(0,G.jsx)(`option`,{value:`warn`,children:`warn`}),(0,G.jsx)(`option`,{value:`error`,children:`error`})]}),(0,G.jsx)(_,{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,W.useState)([]),[a,l]=(0,W.useState)(0),[d,f]=(0,W.useState)(!1),[p,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(``),[_,v]=(0,W.useState)(`info`),[y,b]=(0,W.useState)(!1),x=(0,W.useRef)(!1),S=(0,W.useRef)(null),C=(0,W.useRef)(0),w=(0,W.useRef)(null),T=(0,W.useRef)(0),E=(0,W.useRef)(null),D=(0,W.useRef)(!1),O=(0,W.useRef)(0);(0,W.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,W.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}:Q()),h=()=>x.current&&S.current===e&&u===C.current&&!a.signal.aborted&&ye(p,Q());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,W.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=Q();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,Q());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,G.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,G.jsxs)(y,{children:[(0,G.jsx)(v,{title:`Timeline`}),t.length===0?(0,G.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,G.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,G.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(h,{status:e.state}),e.attempt!=null&&(0,G.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,G.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:w(e.timestamp)})]}),(e.worker||e.error)&&(0,G.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,G.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,G.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,G.jsx)(b,{label:`Loading job…`});if(i)return(0,G.jsx)(x,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`});if(!e)return(0,G.jsx)(x,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`});let c=e.state,l=Ee(e),u=e.stacktrace?.length?re(e.stacktrace):null,d=(e.childrenIds?.length??0)>0,p=_e(c,e),m=c===`failed`,h=l||u?(0,G.jsxs)(y,{children:[(0,G.jsx)(v,{title:`Error`}),l&&(0,G.jsxs)(`div`,{className:`mb-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-danger`,children:l.message}),(0,G.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[l.attempt==null?``:`Attempt ${l.attempt} · `,w(l.timestamp)]})]}),u&&(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.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,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,G.jsx)(Oe,{job:e}),m&&h,(0,G.jsx)(me,{data:e.data,busy:a,editable:p===null,readOnlyReason:p??void 0,onSave:t=>s(`Data`,()=>f.updateJobData(e.id,t))},`data-${e.id}`),c===`completed`&&(0,G.jsx)(ke,{jobId:e.id,result:t,resultError:n,loading:r,onRetry:()=>o(e.id,`id`)}),!m&&h,(0,G.jsx)(we,{jobId:e.id},`logs-${e.id}`),d&&(0,G.jsx)(pe,{jobId:e.id},`children-${e.id}`),(0,G.jsx)(Te,{timeline:e.timeline}),(0,G.jsx)(fe,{job:e})]}),(0,G.jsx)(`div`,{className:`order-first lg:order-none`,children:(0,G.jsx)(ce,{job:e,busy:a,act:s})})]})}function Oe({job:e}){return(0,G.jsxs)(y,{children:[(0,G.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:e.id}),(0,G.jsx)(T,{value:e.id})]}),(0,G.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:e.queue})]}),(0,G.jsx)(h,{status:e.state??`unknown`})]}),(0,G.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,G.jsx)($,{label:`Priority`,value:String(e.priority??0)}),(0,G.jsx)($,{label:`Name`,value:e.name??`default`}),(0,G.jsx)($,{label:`Attempts`,value:`${e.attempts??0} / ${e.maxAttempts??`?`}`}),(0,G.jsx)($,{label:`Progress`,value:`${e.progress??0}%`}),(0,G.jsx)($,{label:`Created`,value:w(e.createdAt)}),(0,G.jsx)($,{label:`Started`,value:w(e.startedAt??void 0)}),(0,G.jsx)($,{label:`Completed`,value:w(e.completedAt??void 0)}),(0,G.jsx)($,{label:`Duration`,value:C(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,G.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono`,children:e.customId??`—`}),e.customId&&(0,G.jsx)(T,{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,G.jsxs)(y,{children:[(0,G.jsx)(v,{title:`Result`,action:a?(0,G.jsx)(je,{value:t.value,filename:`job-${e}-result`}):void 0}),a?(0,G.jsx)(Ae,{value:t.value}):n?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsxs)(`p`,{className:`text-xs text-danger`,children:[`Couldn't load result — `,n]}),(0,G.jsx)(_,{size:`sm`,disabled:r,onClick:i,children:`Retry`})]}):(0,G.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]})}function $({label:e,value:t}){return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,G.jsx)(`dd`,{className:`text-fg`,children:t})]})}function Ae({value:e}){return(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(T,{value:JSON.stringify(e??null,null,2)}),(0,G.jsx)(g,{"aria-label":`Download JSON`,title:`Download JSON`,onClick:()=>A(t,e??null),children:(0,G.jsx)(m,{className:`size-3.5`})})]})}function Me(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e};for(let e of d)delete t[e];return t}function Ne(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(Me(e.data??{}),null,2),options:t}}}function Pe({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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(S,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:e?(0,G.jsxs)(G.Fragment,{children:[u&&(0,G.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,G.jsx)(i,{to:`/add-job`,state:Ne(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,G.jsxs)(_,{size:`sm`,onClick:()=>A(`job-${e.id}`,t.fetched?{...e,result:t.value}:e),children:[(0,G.jsx)(m,{className:`size-3.5`}),` Download JSON`]})]}):void 0}),(0,G.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(E,{name:`job-lookup-mode`,autoComplete:`off`,value:r,"aria-label":`Lookup mode`,onChange:e=>c(e.target.value),className:`w-40`,children:[(0,G.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,G.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,G.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,G.jsx)(p,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,G.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,G.jsx)(_,{variant:`accent`,disabled:a||o,onClick:()=>l(n),children:`Look up`})]})]})}function Fe({state:e,lookup:t,setParams:n,locationKey:r,idParam:i,customParam:a,jobBelongsToCurrentTarget:o,connectionBaseUrl:s,connectionToken:c}){(0,W.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 Ie={fetched:!1,value:void 0};function Le(e,t){let[n,r]=(0,W.useState)(e??t??``),[i,a]=(0,W.useState)(e?`custom`:`id`),[o,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(Ie),[d,f]=(0,W.useState)(null),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)(!1),x=(0,W.useRef)(0),S=(0,W.useRef)(null),C=(0,W.useRef)(null),w=(0,W.useRef)(null),T=(0,W.useRef)(!1),E=(0,W.useRef)(null),D=(0,W.useRef)(!1),O=(0,W.useRef)(0),k=(0,W.useRef)(!1),A=(0,W.useRef)(null);return(0,W.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(Ie),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 Re(){let e=r(),[n,i]=t(),a=s(e=>e.baseUrl),c=s(e=>e.token),l=Le(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=V(l.jobTarget.current,m);return Fe({state:l,lookup:d,setParams:i,locationKey:e.key,idParam:f,customParam:p,jobBelongsToCurrentTarget:h,connectionBaseUrl:a,connectionToken:c}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Pe,{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,G.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,G.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=B();if(!V(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&&V(r,B())&&V(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{Re as JobInspector};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,r,t as i}from"./react-vendor-CFL9l8LK.js";import{t as a}from"./bq-DR2BTISO.js";import{T as o}from"./icons-DH9SS1DA.js";import{t as s}from"./StatusBadge-DereLzOj.js";import{t as c}from"./api-D9aT0ND7.js";import{n as l}from"./usePolledData-CEyyLRYa.js";import{i as u,r as d}from"./feedback-CtGN_kqB.js";import{t as f}from"./PageHeader-CQzNsw8r.js";import{a as p,c as m,d as h,l as g,s as _,t as v}from"./format-Cg7VCIZW.js";import{r as y}from"./index-DZFZr0Mi.js";import{a as b,i as x}from"./form-DG3X6cLL.js";import{r as S}from"./flowMutationSafety-YKTHxqKv.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";import{i as w,n as T,r as E,t as D}from"./classicJobsData-Csj4iihY.js";var O=e(n(),1),k=i();function A({rows:e,emptyMessage:t}){return(0,k.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,k.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,k.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,k.jsx)(`tbody`,{children:e.length===0?(0,k.jsx)(`tr`,{children:(0,k.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:t})}):e.map(e=>(0,k.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,k.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,k.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,k.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??w(e.data)??`default`}),(0,k.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(s,{status:String(e.state??e.status??`waiting`)})}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(h(e.startedAt??void 0,e.completedAt??void 0))}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,k.jsx)(`span`,{className:`text-xs text-faint`,title:S,children:`Delete unavailable`})})]},`${e.queue}:${e.id}`))})]})})}var j=8;function M(){let[e]=t(),[n,r]=(0,O.useState)(e.get(`queue`)??`__all__`),[i,s]=(0,O.useState)(`all`),[p,h]=(0,O.useState)(``),{data:g,error:S,refetch:M}=l(E,[],{intervalMs:3e4}),{data:N,error:P,refetch:F}=l(()=>c.overview(),[]),I=(0,O.useMemo)(()=>(g?.queues??[]).map(e=>e.name),[g]),L=`${n}\u0000${i}\u0000${JSON.stringify(I)}`,{data:R,error:z,loading:B,refetch:V}=l((0,O.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,j,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,O.useMemo)(()=>{let e=U??[],t=p.trim().toLowerCase(),n=t?e.filter(e=>typeof e.id==`string`&&e.id.toLowerCase().includes(t)||typeof e.name==`string`&&e.name.toLowerCase().includes(t)||(w(e.data)?.toLowerCase().includes(t)??!1)):e;return{rows:n.slice(0,100),matchingCount:n.length}},[U,p]),K=N?.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,k.jsxs)(`div`,{children:[(0,k.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!H&&!S&&!P&&!z&&!H.blockedReason&&H.failures.length===0}),S&&(0,k.jsx)(u,{message:`Queue discovery unavailable — ${S.message}`,onRetry:M}),P&&(0,k.jsx)(u,{message:`Job totals unavailable — ${P.message}`,onRetry:F}),z&&(0,k.jsx)(u,{message:`Could not load jobs — ${z.message}`,onRetry:V}),H?.blockedReason&&(0,k.jsx)(u,{message:H.blockedReason}),!!H?.failures.length&&(0,k.jsx)(u,{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,k.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,k.jsx)(y,{label:`Total`,value:K?_(K.totalCompleted+K.totalFailed+K.waiting+K.active):`—`,compact:!0}),(0,k.jsx)(y,{label:`Waiting`,value:J(K?.waiting),tone:`amber`,compact:!0}),(0,k.jsx)(y,{label:`Active`,value:J(K?.active),tone:`blue`,compact:!0}),(0,k.jsx)(y,{label:`Completed`,value:J(K?.totalCompleted),tone:`green`,compact:!0}),(0,k.jsx)(y,{label:`Failed`,value:J(K?.totalFailed),tone:K?.totalFailed?`red`:`default`,compact:!0}),(0,k.jsx)(y,{label:`Error Rate`,value:q==null?`—`:m(q),tone:q==null?`default`:q>.05?`red`:`green`,compact:!0})]}),(0,k.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(`div`,{className:`w-48`,children:(0,k.jsxs)(b,{value:n,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>r(e.target.value),children:[(0,k.jsx)(`option`,{value:D,children:`All Queues`}),(g?.queues??[]).map(e=>(0,k.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,k.jsx)(x,{options:T,value:i,onChange:s}),(0,k.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,k.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,k.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,k.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,k.jsx)(d,{label:`Loading jobs…`}):(0,k.jsx)(A,{rows:W,emptyMessage:Z})]})}export{M as Jobs};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,r,t as i}from"./react-vendor-DfC0iyIS.js";import{t as a}from"./bq-CSX8DSME.js";import{T as o}from"./icons-C1HVBnFn.js";import{t as s}from"./StatusBadge-cYUkK-4P.js";import{t as c}from"./api-Bbo86MB6.js";import{n as l}from"./usePolledData-Dp_ynL9f.js";import{i as u,r as d}from"./feedback-Dxfj-Fy1.js";import{t as f}from"./PageHeader-DD4vnVog.js";import{a as p,c as m,d as h,l as g,s as _,t as v}from"./format-Cg7VCIZW.js";import{r as y}from"./index-CxzFSZj3.js";import{a as b,i as x}from"./form-Dy-an7ew.js";import{r as S}from"./flowMutationSafety-YKTHxqKv.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";import{i as w,n as T,r as E,t as D}from"./classicJobsData-BimIyQky.js";var O=e(n(),1),k=i();function A({rows:e,emptyMessage:t}){return(0,k.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,k.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,k.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,k.jsx)(`tbody`,{children:e.length===0?(0,k.jsx)(`tr`,{children:(0,k.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:t})}):e.map(e=>(0,k.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,k.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,k.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,k.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??w(e.data)??`default`}),(0,k.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(s,{status:String(e.state??e.status??`waiting`)})}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(h(e.startedAt??void 0,e.completedAt??void 0))}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,k.jsx)(`span`,{className:`text-xs text-faint`,title:S,children:`Delete unavailable`})})]},`${e.queue}:${e.id}`))})]})})}var j=8;function M(){let[e]=t(),[n,r]=(0,O.useState)(e.get(`queue`)??`__all__`),[i,s]=(0,O.useState)(`all`),[p,h]=(0,O.useState)(``),{data:g,error:S,refetch:M}=l(E,[],{intervalMs:3e4}),{data:N,error:P,refetch:F}=l(()=>c.overview(),[]),I=(0,O.useMemo)(()=>(g?.queues??[]).map(e=>e.name),[g]),L=`${n}\u0000${i}\u0000${JSON.stringify(I)}`,{data:R,error:z,loading:B,refetch:V}=l((0,O.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,j,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,O.useMemo)(()=>{let e=U??[],t=p.trim().toLowerCase(),n=t?e.filter(e=>typeof e.id==`string`&&e.id.toLowerCase().includes(t)||typeof e.name==`string`&&e.name.toLowerCase().includes(t)||(w(e.data)?.toLowerCase().includes(t)??!1)):e;return{rows:n.slice(0,100),matchingCount:n.length}},[U,p]),K=N?.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,k.jsxs)(`div`,{children:[(0,k.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!H&&!S&&!P&&!z&&!H.blockedReason&&H.failures.length===0}),S&&(0,k.jsx)(u,{message:`Queue discovery unavailable — ${S.message}`,onRetry:M}),P&&(0,k.jsx)(u,{message:`Job totals unavailable — ${P.message}`,onRetry:F}),z&&(0,k.jsx)(u,{message:`Could not load jobs — ${z.message}`,onRetry:V}),H?.blockedReason&&(0,k.jsx)(u,{message:H.blockedReason}),!!H?.failures.length&&(0,k.jsx)(u,{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,k.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,k.jsx)(y,{label:`Total`,value:K?_(K.totalCompleted+K.totalFailed+K.waiting+K.active):`—`,compact:!0}),(0,k.jsx)(y,{label:`Waiting`,value:J(K?.waiting),tone:`amber`,compact:!0}),(0,k.jsx)(y,{label:`Active`,value:J(K?.active),tone:`blue`,compact:!0}),(0,k.jsx)(y,{label:`Completed`,value:J(K?.totalCompleted),tone:`green`,compact:!0}),(0,k.jsx)(y,{label:`Failed`,value:J(K?.totalFailed),tone:K?.totalFailed?`red`:`default`,compact:!0}),(0,k.jsx)(y,{label:`Error Rate`,value:q==null?`—`:m(q),tone:q==null?`default`:q>.05?`red`:`green`,compact:!0})]}),(0,k.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(`div`,{className:`w-48`,children:(0,k.jsxs)(b,{value:n,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>r(e.target.value),children:[(0,k.jsx)(`option`,{value:D,children:`All Queues`}),(g?.queues??[]).map(e=>(0,k.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,k.jsx)(x,{options:T,value:i,onChange:s}),(0,k.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,k.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,k.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,k.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,k.jsx)(d,{label:`Loading jobs…`}):(0,k.jsx)(A,{rows:W,emptyMessage:Z})]})}export{M as Jobs};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,r,t as i}from"./react-vendor-DfC0iyIS.js";import{t as a}from"./bq-CSX8DSME.js";import{t as o}from"./toastStore-DnqA_aL-.js";import{T as s,d as c,f as l,x as u}from"./icons-C1HVBnFn.js";import{r as d,t as f}from"./StatusBadge-cYUkK-4P.js";import{n as p}from"./usePolledData-Dp_ynL9f.js";import{n as m,t as h}from"./Button-BCjgbAhY.js";import{i as g,n as _,r as v}from"./feedback-Dxfj-Fy1.js";import{t as y}from"./PageHeader-DD4vnVog.js";import{a as b,c as x,i as S,s as C,t as w}from"./format-Cg7VCIZW.js";import{r as T}from"./index-CxzFSZj3.js";import{a as E}from"./form-Dy-an7ew.js";import{t as D}from"./Pagination-Cj7GzYNX.js";import{r as O,t as k}from"./useServerActionGuard-Cr4KUOeZ.js";import{n as A,t as j}from"./controlConnectionEpoch-D4HtriLM.js";import{t as M}from"./exportFile-C7xhE8Yh.js";import{t as N}from"./flowOperationPolicy-B2Etcb3f.js";var P=e(n(),1),F=1e4,I=100;async function L(e,t,n,r,i){let a=[],o=new Set,s=r.trim().toLowerCase(),c=n===`all`?void 0:[n],l=0;for(;;){i.throwIfAborted();let n=l===1e4?1:Math.min(I,F-l),{jobs:r}=await e.jobsList(t,c,n,l);if(i.throwIfAborted(),r.length>n)throw Error(`The server returned an invalid export page.`);if(l===1e4){if(r.length>0)throw Error(`Export exceeds ${F.toLocaleString()} jobs. Filter by state first.`);return a}for(let e of r){if(o.has(e.id))throw Error(`The queue changed during export. Retry when it is stable.`);o.add(e.id);let t=typeof e.name==`string`?e.name.toLowerCase():``;(!s||e.id.toLowerCase().includes(s)||t.includes(s))&&a.push(e)}if(r.length<n)return a;l+=r.length}}function R(e,t,n){let r=n.map(t=>({id:t.id,name:t.name??`default`,queue:t.queue??e,state:t.state??``,priority:t.priority??0,attempts:t.attempts??0,maxAttempts:t.maxAttempts??``,createdAt:t.createdAt?new Date(t.createdAt).toISOString():``,durationMs:t.startedAt&&t.completedAt?t.completedAt-t.startedAt:``}));M(`jobs-${e}-${t}`,r,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])}var z=i();function B(e){let[t,n]=(0,P.useState)(!1),r=(0,P.useId)();return(0,z.jsxs)(`div`,{className:`mb-6`,children:[(0,z.jsxs)(`div`,{className:`rounded-xl border border-line bg-surface p-3 md:hidden`,children:[(0,z.jsx)(`dl`,{"aria-label":`Job summary`,className:`grid grid-cols-3 gap-3 text-xs`,children:[[`Total`,e.total],[`Active`,e.active],[`Failed`,e.failed]].map(([e,t])=>(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`dt`,{className:`text-faint`,children:e}),(0,z.jsx)(`dd`,{className:`mt-1 break-words font-semibold tnum text-fg`,children:t})]},e))}),(0,z.jsx)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`mt-2 min-h-[44px] w-full rounded-lg border border-line text-xs font-medium text-muted hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,children:t?`Hide detailed statistics`:`Show all 8 statistics`})]}),(0,z.jsxs)(`div`,{id:r,className:d(`mt-3 grid-cols-2 gap-3 md:mt-0 md:grid md:grid-cols-4 md:gap-4 xl:grid-cols-8`,t?`grid`:`hidden`),children:[(0,z.jsx)(T,{label:`Total`,value:e.total,hint:`all queues`,compact:!0}),(0,z.jsx)(T,{label:`Waiting`,value:e.waiting,tone:`amber`,hint:`standard priority`,compact:!0}),(0,z.jsx)(T,{label:`Prioritized`,value:e.prioritized,tone:`amber`,compact:!0}),(0,z.jsx)(T,{label:`Active`,value:e.active,tone:`blue`,compact:!0}),(0,z.jsx)(T,{label:`Flow-blocked`,value:e.flowBlocked,tone:`blue`,compact:!0}),(0,z.jsx)(T,{label:`Completed`,value:e.completed,tone:`green`,compact:!0}),(0,z.jsx)(T,{label:`Failed`,value:e.failed,tone:e.failedCount!=null&&e.failedCount>0?`red`:`default`,compact:!0}),(0,z.jsx)(T,{label:`Error Rate`,value:e.errorRate,tone:e.errorRateTone,compact:!0})]})]})}var V=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`];function H(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function U(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function W(e=0){return e>=10?{text:`HIGH`,className:`text-warning`}:e>=1?{text:`MEDIUM`,className:`text-blue-400`}:{text:`LOW`,className:`text-faint`}}function G({queue:e,rows:t,search:n,discoveryError:i,selected:o,allSelected:s,bulkBusy:c,busyIds:p,page:h,hasNext:g,onToggleAll:_,onToggle:v,onRun:y,onPage:x}){return(0,z.jsxs)(z.Fragment,{children:[e&&(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,z.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,z.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:e})]}),(0,z.jsx)(`div`,{role:`region`,"aria-label":`Jobs table`,tabIndex:0,className:`overflow-x-auto rounded-xl border border-line bg-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,children:(0,z.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,z.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,z.jsx)(`input`,{type:`checkbox`,checked:s,ref:e=>{e&&(e.indeterminate=o.size>0&&!s)},"aria-checked":o.size>0&&!s?`mixed`:s,onChange:_,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,z.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,z.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,z.jsx)(`th`,{className:`sticky right-0 z-10 w-28 bg-surface px-2 py-3 text-right font-medium md:static md:px-5`,children:`Actions`})]})}),(0,z.jsx)(`tbody`,{children:t.length===0?(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:n.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:i?`Queue discovery failed. Retry above.`:`Select a queue.`})}):t.map(e=>{let t=W(e.priority),n=N(e.state),i=c||p.has(e.id);return(0,z.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,z.jsx)(`td`,{className:`px-5 py-3`,children:(0,z.jsx)(`input`,{type:`checkbox`,checked:o.has(e.id),onChange:()=>v(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,z.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,z.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,z.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,z.jsx)(`td`,{className:`px-5 py-3`,children:(0,z.jsx)(f,{status:String(e.state??`waiting`)})}),(0,z.jsx)(`td`,{className:d(`px-5 py-3 text-xs font-semibold`,t.className),children:t.text}),(0,z.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:S(e.createdAt)}),(0,z.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,z.jsx)(`td`,{className:`sticky right-0 z-10 bg-surface px-2 py-3 md:static md:px-5`,children:(0,z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,z.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect job ${e.id}`,className:`inline-flex size-[44px] shrink-0 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 md:size-8`,children:(0,z.jsx)(l,{className:`size-3.5`})}),n.promote&&(0,z.jsx)(m,{className:`size-[44px] shrink-0 md:size-8`,"aria-label":`Promote job`,disabled:i,onClick:()=>y(e,`Promote`,()=>a.promoteJob(e.id)),children:(0,z.jsx)(u,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,z.jsx)(D,{page:h,pageSize:25,hasNext:g,onPageChange:x,label:`jobs`})]})}function ee({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:c,onQueue:l,onStatus:u,onSearch:d,onPromote:f}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`w-48`,children:(0,z.jsxs)(E,{value:e,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:[e&&!t.some(t=>t.name===e)&&(0,z.jsx)(`option`,{value:e,children:e}),t.map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,z.jsx)(`div`,{className:`w-48`,children:(0,z.jsx)(E,{"aria-label":`Job state`,name:`jobs-state`,value:n,onChange:e=>u(e.target.value),children:V.map(e=>(0,z.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,z.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,z.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,z.jsx)(`input`,{value:r,onChange:e=>d(e.target.value),placeholder:`Filter this page by ID or name…`,"aria-label":`Filter by job ID or name`,name:`jobs-id-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),i>0&&(0,z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,z.jsx)(`span`,{className:`mr-1 text-muted`,children:H(a,i)}),o?(0,z.jsx)(h,{size:`sm`,disabled:c,onClick:f,children:`Promote selected`}):(0,z.jsx)(`span`,{className:`text-xs text-faint`,children:a===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]})]})}function te({queue:e,view:t,rows:n,selected:r,setSelected:i,refetch:a}){let[s,c]=(0,P.useState)(new Set),[l,u]=(0,P.useState)(!1),[d,f]=(0,P.useState)(null),p=O(`jobs:${e}:${t}`);return(0,P.useEffect)(()=>{c(new Set),u(!1),f(null)},[p.scopeKey]),{actionMsg:d,bulkBusy:l,busyIds:s,runBulk:async(e,t,s,c)=>{let l=n.filter(e=>r.has(e.id)&&s(e));if(l.length===0||c&&!window.confirm(c(l.length)))return;let d=p.begin([`bulk`,...l.map(e=>`job:${e.id}`)]);if(d){u(!0),f(null);try{let n=await Promise.allSettled(l.map(async n=>{k(await t(n),`${e} ${n.id}`)}));if(!d.isCurrent())return;let r=n.filter(e=>e.status===`fulfilled`).length,s=n.length-r,c=`${e}: ${r} succeeded${s?`, ${s} failed`:``}`;f({ok:s===0,text:c}),s===0?o.success(c):o.error(c),i(e=>U(e,l.map(e=>e.id))),a()}finally{d.finish()&&u(!1)}}},runOne:async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let i=p.begin(`job:${e.id}`);if(i){c(t=>new Set(t).add(e.id)),f(null);try{if(k(await n(),t),!i.isCurrent())return;f({ok:!0,text:`${t} ✓`}),o.success(`${t} ✓`,e.id),a()}catch(e){if(!i.isCurrent())return;f({ok:!1,text:`${t} failed: ${e.message}`}),o.error(`${t} failed`,e.message)}finally{i.finish()&&c(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function ne(e,t,n){let[r,i]=(0,P.useState)(!1),s=(0,P.useRef)(null),c=O(JSON.stringify([`jobs-export`,e,t,n]));return(0,P.useEffect)(()=>(i(!1),()=>{s.current?.abort(),s.current=null}),[c.scopeKey]),{busy:r,exportAll:async()=>{if(!e)return;let r=c.begin(`export`);if(!r)return;let l=new AbortController;s.current=l,i(!0);try{let i=await L(a.createServerTargetClient(a.captureServerRequestTarget(),l.signal),e,t,n,l.signal);if(!r.isCurrent())return;if(i.length===0){o.info(`No jobs match this export`);return}R(e,t,i),o.success(`Exported ${i.length.toLocaleString()} jobs`)}catch(e){r.isCurrent()&&!l.signal.aborted&&o.error(`Export failed`,e instanceof Error?e.message:String(e))}finally{s.current===l&&(s.current=null),r.finish()&&i(!1)}}}}var K=new Set;function re(e){let[n,r]=t(),i=n.get(`queue`)??``,a=n.get(`status`),o=a&&V.includes(a)?a:`all`,s=e&&!e.some(e=>e.name===i)?e[0]?.name??``:i,c=A(),l=JSON.stringify([c,s,o]),u=(0,P.useRef)({identity:l,generation:0});u.current.identity!==l&&(u.current={identity:l,generation:u.current.generation+1});let d=u.current.generation,[f,p]=(0,P.useState)({generation:-1,page:0}),m=f.generation===d?f.page:0,h=(0,P.useRef)({listGeneration:d,page:m,generation:0});(h.current.listGeneration!==d||h.current.page!==m)&&(h.current={listGeneration:d,page:m,generation:h.current.generation+1});let g=h.current.generation,_=JSON.stringify([c,d,g,s,o,m]),[v,y]=(0,P.useState)({generation:-1,ids:new Set}),b=v.generation===g?v.ids:K,x=(0,P.useCallback)(e=>p(t=>u.current.generation===d&&j()===c?{generation:d,page:e}:t),[c,d]),S=(0,P.useCallback)(e=>y(t=>{if(h.current.generation!==g||j()!==c)return t;let n=t.generation===g?t.ids:K;return{generation:g,ids:typeof e==`function`?e(n):e}}),[c,g]);return(0,P.useEffect)(()=>{if(!e||i===s)return;let t=new URLSearchParams(n);s?t.set(`queue`,s):t.delete(`queue`),r(t,{replace:!0})},[n,s,i,r,e]),{queue:s,status:o,page:m,view:_,selected:b,setSelected:S,setPage:x,selectQueue:e=>{let t=new URLSearchParams(n);e?t.set(`queue`,e):t.delete(`queue`),r(t,{replace:!0})},selectStatus:e=>{let t=new URLSearchParams(n);e===`all`?t.delete(`status`):t.set(`status`,e),r(t,{replace:!0})}}}function q(){let[e,t]=(0,P.useState)(``),{data:n,error:r,loading:i,refetch:s}=p(()=>a.queuesSummary(),[],{intervalMs:3e4}),{queue:l,status:u,page:d,view:f,selected:m,setSelected:b,setPage:S,selectQueue:T,selectStatus:E}=re(n),{busy:D,exportAll:O}=ne(l,u,e),{data:k,error:A,refetch:j}=p(()=>a.stats(),[],{intervalMs:1e4}),{data:M,error:F,loading:I,refetch:L}=p((0,P.useCallback)(async()=>{if(!l)return{view:f,jobs:[]};let e=u===`all`?void 0:[u],t=await a.jobsList(l,e,25,d*25);return{view:f,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??l}))}},[l,u,d,f]),[l,u,d,f]),V=M?.view===f?M.jobs:null,H=(V?.length??0)===25,U=(0,P.useMemo)(()=>{let t=e.trim().toLowerCase();return t?(V??[]).filter(e=>e.id.toLowerCase().includes(t)||e.name?.toLowerCase().includes(t)):V??[]},[V,e]),W=k?.stats,K=(0,P.useMemo)(()=>n?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[n]),q=W&&K!=null?w(W.completed,K):null,J=e=>W?C(e):`—`,ie=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=U.length>0&&U.every(e=>m.has(e.id)),ae=()=>b(()=>Y?new Set:new Set(U.map(e=>e.id))),{actionMsg:X,bulkBusy:Z,busyIds:oe,runBulk:se,runOne:ce}=te({queue:l,view:f,rows:U,selected:m,setSelected:b,refetch:L}),Q={promote:e=>N(e.state).promote},$=U.filter(e=>m.has(e.id)),le={promote:$.some(Q.promote)};return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(y,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs. Full CSV exports read up to 10,000 live jobs and can reflect concurrent changes.`,live:!!l&&V!=null&&!F&&!r&&!A,actions:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(h,{size:`sm`,disabled:!V||U.length===0,onClick:()=>{if(U.length===0){o.info(`No jobs to export on this page`);return}R(l,u,U)},children:[(0,z.jsx)(c,{className:`size-3.5`}),` Export page CSV`]}),(0,z.jsxs)(h,{size:`sm`,disabled:!l||!V||D,onClick:()=>void O(),title:`Export matching jobs across all pages for this queue and state`,children:[(0,z.jsx)(c,{className:`size-3.5`}),D?`Exporting…`:`Export all matching CSV`]})]})}),r&&(0,z.jsx)(g,{onRetry:s,message:n?`Queue inventory refresh failed — showing the last successful queue totals. ${r.message}`:`Could not discover queues — ${r.message}. Select an existing queue from the URL or retry.`}),A&&(0,z.jsx)(g,{onRetry:j,message:k?`Server-wide totals refresh failed — showing the last successful totals. ${A.message}`:`Server-wide job totals are unavailable — ${A.message}. The selected queue page may still be current.`}),(0,z.jsx)(B,{total:W&&K!=null?C(W.completed+K+W.waiting+W.prioritized+W.active+W.delayed+W[`waiting-children`]):`—`,waiting:J(W?.waiting),prioritized:J(W?.prioritized),active:J(W?.active),flowBlocked:J(W?.[`waiting-children`]),completed:J(W?.completed),failed:K==null?`—`:C(K),failedCount:K,errorRate:q==null?`—`:x(q),errorRateTone:q==null?`default`:q>.05?`red`:`green`}),(0,z.jsx)(ee,{queue:l,summary:n??[],status:u,search:e,selectedTotal:m.size,selectedVisible:$.length,canPromote:le.promote,bulkBusy:Z,onQueue:T,onStatus:E,onSearch:t,onPromote:()=>se(`Promote`,e=>a.promoteJob(e.id),Q.promote)}),X&&(0,z.jsx)(`div`,{role:`status`,className:`mb-3 text-sm ${X.ok?`text-success`:`text-danger`}`,children:X.text}),F&&V&&(0,z.jsx)(g,{message:`Job refresh failed — showing the last successful page.`,onRetry:L}),F&&!V?(0,z.jsx)(_,{error:F,onRetry:L}):i&&!n&&!l&&!r?(0,z.jsx)(v,{label:`Discovering queues…`}):I&&!V?(0,z.jsx)(v,{label:`Loading jobs…`}):(0,z.jsx)(G,{queue:l,rows:U,search:e,discoveryError:!!r,selected:m,allSelected:Y,bulkBusy:Z,busyIds:oe,page:d,hasNext:H,onToggleAll:ae,onToggle:ie,onRun:(e,t,n)=>void ce(e,t,n),onPage:S})]})}export{q as JobsPro};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{T as r,h as i}from"./icons-DH9SS1DA.js";import{t as a}from"./StatusBadge-DereLzOj.js";import{n as o}from"./usePolledData-CEyyLRYa.js";import{i as s,t as c}from"./feedback-CtGN_kqB.js";import{t as l}from"./PageHeader-CQzNsw8r.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{r as f,t as p}from"./index-DZFZr0Mi.js";import{a as m,i as h}from"./form-DG3X6cLL.js";import{t as g}from"./Pagination-CSkzhNW6.js";import{r as _}from"./classicJobsData-Csj4iihY.js";import"./Jobs-CKzKpQ7i.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;async function C(){let e=await _();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!Number.isSafeInteger(e.waiting)||e.waiting<0||!Number.isSafeInteger(e.delayed)||e.delayed<0||!Number.isSafeInteger(e.active)||e.active<0||!Number.isSafeInteger(e.dlq)||e.dlq<0||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function w(){let[e,t]=(0,v.useState)(b),[n,_]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O,error:k,refetch:A}=o(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=p(e===b?void 0:e),I=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return j.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[j,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let L=Math.max(1,Math.ceil(I.length/S)),R=Math.min(E,L-1);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(s,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(s,{message:`Event stream unavailable — ${F.message}. Retrying…`}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total Events`,value:d(M.total),compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:d(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:d(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:d(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:d(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Throughput`,value:`${N.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(m,{value:e,"aria-label":`Filter by queue`,name:`classic-activity-queue-filter`,autoComplete:`off`,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(h,{options:x,value:n,onChange:_}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{"aria-label":`Search by job name or ID`,name:`classic-activity-search`,autoComplete:`off`,value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),I.length===0?(0,y.jsx)(c,{icon:(0,y.jsx)(i,{}),title:F?`Event stream unavailable`:P?`Waiting for activity…`:`Connecting to the event stream…`,hint:F?`${F.message}. The dashboard is retrying automatically.`:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:I.slice(R*S,R*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(a,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-DfC0iyIS.js";import{T as r,h as i}from"./icons-C1HVBnFn.js";import{t as a}from"./StatusBadge-cYUkK-4P.js";import{n as o}from"./usePolledData-Dp_ynL9f.js";import{i as s,t as c}from"./feedback-Dxfj-Fy1.js";import{t as l}from"./PageHeader-DD4vnVog.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{r as f,t as p}from"./index-CxzFSZj3.js";import{a as m,i as h}from"./form-Dy-an7ew.js";import{t as g}from"./Pagination-Cj7GzYNX.js";import{r as _}from"./classicJobsData-BimIyQky.js";import"./Jobs-D_TId_Oa.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;async function C(){let e=await _();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!Number.isSafeInteger(e.waiting)||e.waiting<0||!Number.isSafeInteger(e.delayed)||e.delayed<0||!Number.isSafeInteger(e.active)||e.active<0||!Number.isSafeInteger(e.dlq)||e.dlq<0||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function w(){let[e,t]=(0,v.useState)(b),[n,_]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O,error:k,refetch:A}=o(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=p(e===b?void 0:e),I=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return j.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[j,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let L=Math.max(1,Math.ceil(I.length/S)),R=Math.min(E,L-1);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(s,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(s,{message:`Event stream unavailable — ${F.message}. Retrying…`}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total Events`,value:d(M.total),compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:d(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:d(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:d(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:d(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Throughput`,value:`${N.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(m,{value:e,"aria-label":`Filter by queue`,name:`classic-activity-queue-filter`,autoComplete:`off`,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(h,{options:x,value:n,onChange:_}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{"aria-label":`Search by job name or ID`,name:`classic-activity-search`,autoComplete:`off`,value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),I.length===0?(0,y.jsx)(c,{icon:(0,y.jsx)(i,{}),title:F?`Event stream unavailable`:P?`Waiting for activity…`:`Connecting to the event stream…`,hint:F?`${F.message}. The dashboard is retrying automatically.`:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:I.slice(R*S,R*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(a,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{o as i}from"./connectionStore-CVjQyIZv.js";import{T as a}from"./icons-DH9SS1DA.js";import{t as o}from"./StatusBadge-DereLzOj.js";import{n as s}from"./usePolledData-CEyyLRYa.js";import{t as c}from"./Button-_aSJvRoW.js";import{i as l}from"./feedback-CtGN_kqB.js";import{t as u}from"./PageHeader-CQzNsw8r.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,r as m,t as h}from"./index-DZFZr0Mi.js";import{a as g,i as _}from"./form-DG3X6cLL.js";import{t as v}from"./Pagination-CSkzhNW6.js";import{t as y}from"./QueueControl-DaZjeZnw.js";var b=e(t(),1),x=r(),S=`__all__`,C=[`all`,`waiting`,`active`,`completed`,`failed`],w=10,T=250;function E(){let[e,t]=(0,b.useState)(S),[r,E]=(0,b.useState)(`all`),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0),[j,M]=(0,b.useState)(null),N=j!==null,P=i(t=>JSON.stringify([t.baseUrl,t.token,e])),{data:F,error:I,refetch:L}=s(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=h(e===S?void 0:e),U=(0,b.useMemo)(()=>{let e=j??R,t=D.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[R,j,r,D]),W=N?Math.max(0,(R[0]?.seq??0)-(j[0]?.seq??0)):0;(0,b.useEffect)(()=>A(0),[e,r,D]),(0,b.useEffect)(()=>M(null),[P]);let G=k*w,K=U.slice(G,G+w);return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:V&&!N}),I&&(0,x.jsx)(l,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(l,{message:`Event stream unavailable — ${H.message}. Retrying…`}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,x.jsx)(m,{label:`Total Events`,value:f(z.total),compact:!0}),(0,x.jsx)(m,{label:`Completed`,value:f(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(m,{label:`Failed`,value:f(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(m,{label:`Waiting`,value:f(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(m,{label:`Active`,value:f(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(m,{label:`Throughput`,value:`${B.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(g,{"aria-label":`Filter by queue`,name:`activity-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),children:[(0,x.jsx)(`option`,{value:S,children:`All Queues`}),(F?.queues??[]).map(e=>(0,x.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,x.jsx)(_,{options:C,value:r,onChange:E}),(0,x.jsx)(c,{size:`sm`,variant:N?`warning`:`default`,onClick:()=>M(N?null:R),title:N?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:N?`Resume${W?` — ${f(W)} new`:``}`:`Following · Pause`}),(0,x.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,x.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{"aria-label":`Search by job ID or queue`,name:`activity-search`,autoComplete:`off`,value:D,onChange:e=>O(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,x.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,T,` streamed events held in this browser.`]}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,x.jsx)(`tbody`,{children:K.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:H?`Event stream unavailable — ${H.message}. Retrying…`:V?R.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):K.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(o,{status:e.status})}),(0,x.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:d(e.timestamp)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,x.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,x.jsx)(p,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,x.jsx)(v,{page:k,pageSize:w,total:U.length,onPageChange:A,label:`events`})]})}export{E as LogsPro};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-DfC0iyIS.js";import{o as i}from"./connectionStore-DdLzJyut.js";import{T as a}from"./icons-C1HVBnFn.js";import{t as o}from"./StatusBadge-cYUkK-4P.js";import{n as s}from"./usePolledData-Dp_ynL9f.js";import{t as c}from"./Button-BCjgbAhY.js";import{i as l}from"./feedback-Dxfj-Fy1.js";import{t as u}from"./PageHeader-DD4vnVog.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,r as m,t as h}from"./index-CxzFSZj3.js";import{a as g,i as _}from"./form-Dy-an7ew.js";import{t as v}from"./Pagination-Cj7GzYNX.js";import{t as y}from"./QueueControl-g-9kwrpt.js";var b=e(t(),1),x=r(),S=`__all__`,C=[`all`,`waiting`,`active`,`completed`,`failed`],w=10,T=250;function E(){let[e,t]=(0,b.useState)(S),[r,E]=(0,b.useState)(`all`),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0),[j,M]=(0,b.useState)(null),N=j!==null,P=i(t=>JSON.stringify([t.baseUrl,t.token,e])),{data:F,error:I,refetch:L}=s(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=h(e===S?void 0:e),U=(0,b.useMemo)(()=>{let e=j??R,t=D.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[R,j,r,D]),W=N?Math.max(0,(R[0]?.seq??0)-(j[0]?.seq??0)):0;(0,b.useEffect)(()=>A(0),[e,r,D]),(0,b.useEffect)(()=>M(null),[P]);let G=k*w,K=U.slice(G,G+w);return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:V&&!N}),I&&(0,x.jsx)(l,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(l,{message:`Event stream unavailable — ${H.message}. Retrying…`}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,x.jsx)(m,{label:`Total Events`,value:f(z.total),compact:!0}),(0,x.jsx)(m,{label:`Completed`,value:f(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(m,{label:`Failed`,value:f(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(m,{label:`Waiting`,value:f(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(m,{label:`Active`,value:f(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(m,{label:`Throughput`,value:`${B.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(g,{"aria-label":`Filter by queue`,name:`activity-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),children:[(0,x.jsx)(`option`,{value:S,children:`All Queues`}),(F?.queues??[]).map(e=>(0,x.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,x.jsx)(_,{options:C,value:r,onChange:E}),(0,x.jsx)(c,{size:`sm`,variant:N?`warning`:`default`,onClick:()=>M(N?null:R),title:N?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:N?`Resume${W?` — ${f(W)} new`:``}`:`Following · Pause`}),(0,x.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,x.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{"aria-label":`Search by job ID or queue`,name:`activity-search`,autoComplete:`off`,value:D,onChange:e=>O(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,x.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,T,` streamed events held in this browser.`]}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,x.jsx)(`tbody`,{children:K.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:H?`Event stream unavailable — ${H.message}. Retrying…`:V?R.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):K.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(o,{status:e.status})}),(0,x.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:d(e.timestamp)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,x.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,x.jsx)(p,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,x.jsx)(v,{page:k,pageSize:w,total:U.length,onPageChange:A,label:`events`})]})}export{E as LogsPro};