bunqueue-dashboard 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -11
- package/agent/backup/resultValidation.ts +1 -1
- package/agent/backup/routes.ts +63 -17
- package/agent/db/query.ts +2 -1
- package/agent/manager/config.ts +2 -1
- package/agent/manager/process.ts +51 -5
- package/agent/manager/storageMode.ts +21 -0
- package/agent/manager/types.ts +2 -0
- package/agent/manager.ts +1 -0
- package/agent/queue/routes.ts +1 -2
- package/agent/queue/runtime.ts +5 -0
- package/agent/queue/types.ts +1 -0
- package/agent/server/controlRoutes.ts +109 -8
- package/agent/server/databaseRoutes.ts +47 -14
- package/agent/server/errors.ts +1 -0
- package/agent/server/lifecycle.ts +25 -8
- package/agent/server/managedRuntime.ts +27 -0
- package/agent/server/router.ts +90 -40
- package/agent/server/workflowReadRoutes.ts +28 -11
- package/agent/workflows.ts +1 -1
- package/dist/.vite/manifest.json +490 -476
- package/dist/assets/AddJob-d5KBvmN8.js +3 -0
- package/dist/assets/{Alerts-Gh1pVbqj.js → Alerts-5I44QTnQ.js} +1 -1
- package/dist/assets/{AreaChart-w0ruozXH.js → AreaChart-DEAalJ6P.js} +1 -1
- package/dist/assets/Benchmark-S1afsQRd.js +1 -0
- package/dist/assets/{BulkAddJobs-Di_IgRSH.js → BulkAddJobs-BO8LWUHE.js} +1 -1
- package/dist/assets/{Button-BPqpRZJD.js → Button-Ch1W94fJ.js} +1 -1
- package/dist/assets/{Card-C7NMhqUt.js → Card-CWxrC8OY.js} +1 -1
- package/dist/assets/{CopilotPanel-Db5nYpo1.js → CopilotPanel-DDkRd35p.js} +4 -4
- package/dist/assets/{Cron-BRgWcBGk.js → Cron-X3Y5uISO.js} +1 -1
- package/dist/assets/CronManager-ugmYEAwY.js +1 -0
- package/dist/assets/{Database-BeoEreW0.js → Database-koy8haPX.js} +1 -1
- package/dist/assets/Diagnostics-D6oqvkOs.js +1 -0
- package/dist/assets/{Dlq-DfCg04Jd.js → Dlq-D70Lzmsa.js} +1 -1
- package/dist/assets/{DlqControl-BRCkUXvb.js → DlqControl-nUT5Zzkl.js} +1 -1
- package/dist/assets/{DlqPro-BHJwBYsN.js → DlqPro-VMuBKgP-.js} +1 -1
- package/dist/assets/Flows-CAG0nDnt.js +2 -0
- package/dist/assets/JobInspector-CiS5HOSQ.js +2 -0
- package/dist/assets/{Jobs-URpnFjC6.js → Jobs-CkyRvzOT.js} +1 -1
- package/dist/assets/{JobsPro-pQ_RFSU3.js → JobsPro-B4-CSoq3.js} +1 -1
- package/dist/assets/{Logs-C5jX2OPE.js → Logs-DBTz2PTz.js} +1 -1
- package/dist/assets/{LogsPro-Cq_npmmS.js → LogsPro-BCFeegvr.js} +1 -1
- package/dist/assets/{McpServer-DtCTmQBu.js → McpServer-BKlTR1qr.js} +2 -2
- package/dist/assets/{Metrics-BdxitePr.js → Metrics-Du__9Lbn.js} +1 -1
- package/dist/assets/{MetricsPro-orHfW0mg.js → MetricsPro-CqnaO6YX.js} +1 -1
- package/dist/assets/{Overview-DaNns1aj.js → Overview-udSSt7ZB.js} +1 -1
- package/dist/assets/{PageHeader-BXlZSBcc.js → PageHeader-CvIyaFOO.js} +1 -1
- package/dist/assets/{Pagination-Q-vf4hsX.js → Pagination-x-Cwgrul.js} +1 -1
- package/dist/assets/QueueActions-D7cQrGvJ.js +1 -0
- package/dist/assets/{QueueControl-l5bSdMgb.js → QueueControl-BF638r_0.js} +1 -1
- package/dist/assets/QueueDetail-C-ms6bMe.js +1 -0
- package/dist/assets/QueueDetailPro-DXEdsZx_.js +1 -0
- package/dist/assets/{Queues-DeLXlww2.js → Queues-BUMwTVAf.js} +1 -1
- package/dist/assets/{QueuesOverview-DoQ-MUfT.js → QueuesOverview-Du8XLgN0.js} +1 -1
- package/dist/assets/{S3Backup-D2agV9_z.js → S3Backup-CDICSzxM.js} +1 -1
- package/dist/assets/S3BackupPro-CBidbI-s.js +3 -0
- package/dist/assets/ServerControl-CPT0LpsC.js +3 -0
- package/dist/assets/{Settings-CiJRj_SM.js → Settings-CmxfSX_8.js} +1 -1
- package/dist/assets/{StatusBadge-B0I7hNBX.js → StatusBadge-BoOVTnKu.js} +1 -1
- package/dist/assets/{Usage-DbHJgA4t.js → Usage-B895tSxi.js} +1 -1
- package/dist/assets/{UsagePro-LoPo3k1L.js → UsagePro-CASN77iV.js} +1 -1
- package/dist/assets/{Webhooks-CuzIJHwk.js → Webhooks-CXbZOFFw.js} +1 -1
- package/dist/assets/{Workers-BpUgpwUH.js → Workers-BceQlUhX.js} +1 -1
- package/dist/assets/WorkersPro-Dtml89jB.js +1 -0
- package/dist/assets/Workflows-B8wmQN2X.js +1 -0
- package/dist/assets/{api-V_sVpHDo.js → api-81m1TwB7.js} +1 -1
- package/dist/assets/bq-BOfwNIlJ.js +1 -0
- package/dist/assets/{connectionStore-CKFQrxDo.js → connectionStore-CFuNYZ_8.js} +1 -1
- package/dist/assets/{controlConnectionEpoch-JM4omZ6j.js → controlConnectionEpoch-DzbuWOhe.js} +1 -1
- package/dist/assets/{feedback-BnGE2oW2.js → feedback-QDN1AsYt.js} +1 -1
- package/dist/assets/flowMutationSafety-6cP-l4Pa.js +1 -0
- package/dist/assets/{form-tC20r4Ma.js → form-C4oby9pI.js} +1 -1
- package/dist/assets/{icons-CIvFfU2b.js → icons-BVzwsfbG.js} +1 -1
- package/dist/assets/index-B-QjN7pA.css +1 -0
- package/dist/assets/index-TploGF7u.js +8 -0
- package/dist/assets/install-BPp8nydm.js +3 -0
- package/dist/assets/{react-vendor-CyjgmGTq.js → react-vendor-CvwrP0tU.js} +2 -2
- package/dist/assets/{responses-CBLyy1Ob.js → responses-C9lP49qu.js} +1 -1
- package/dist/assets/{toastStore-B7n0zS0y.js → toastStore-B31o6Z5J.js} +1 -1
- package/dist/assets/{upstreamPaths-CDVsu6IM.js → upstreamPaths-ZeijhPPb.js} +1 -1
- package/dist/assets/useControlActionGuard-DT7uudrj.js +1 -0
- package/dist/assets/{usePolledData-c53tx1jw.js → usePolledData-CNtNtd0a.js} +1 -1
- package/dist/assets/useServerActionGuard-Db7PPgaI.js +1 -0
- package/dist/assets/useThroughputSeries-_J7gWbcI.js +1 -0
- package/dist/index.html +21 -18
- package/package.json +18 -8
- package/scripts/embedded.gen.ts +152 -150
- package/scripts/serveHandler.ts +22 -1
- package/scripts/servePolicy.ts +12 -3
- package/dist/assets/AddJob-CWkkVHmf.js +0 -3
- package/dist/assets/Benchmark-Dir2A1CQ.js +0 -1
- package/dist/assets/CronManager-CbM0x_s0.js +0 -1
- package/dist/assets/Diagnostics-Cw9iJ84f.js +0 -1
- package/dist/assets/Flows-BAzbFP_W.js +0 -2
- package/dist/assets/JobInspector-qvW_APO6.js +0 -2
- package/dist/assets/QueueActions-jiTzndPH.js +0 -1
- package/dist/assets/QueueDetail-URK2pjtH.js +0 -1
- package/dist/assets/QueueDetailPro-C9M5CV4K.js +0 -1
- package/dist/assets/S3BackupPro--WSZWTQn.js +0 -3
- package/dist/assets/ServerControl-QVd6m_iR.js +0 -3
- package/dist/assets/WorkersPro-BYY0P1Pt.js +0 -1
- package/dist/assets/Workflows-ByJw4FFH.js +0 -1
- package/dist/assets/bq-DYmbVkgR.js +0 -1
- package/dist/assets/flowMutationSafety-DObp9nJo.js +0 -1
- package/dist/assets/index-D64v2vNO.js +0 -8
- package/dist/assets/index-DOze4TKg.css +0 -1
- package/dist/assets/install-jXi1SOYY.js +0 -3
- package/dist/assets/useServerActionGuard-OTv6_fU0.js +0 -1
- package/dist/assets/useThroughputSeries-DWHQl7cM.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{t as r}from"./bq-BOfwNIlJ.js";import{t as i}from"./toastStore-B31o6Z5J.js";import{t as a}from"./api-81m1TwB7.js";import{n as o}from"./usePolledData-CNtNtd0a.js";import{t as s}from"./Button-Ch1W94fJ.js";import{n as c,t as l}from"./Card-CWxrC8OY.js";import{i as u,r as d}from"./feedback-QDN1AsYt.js";import{n as f}from"./StatusBadge-BoOVTnKu.js";import{t as p}from"./PageHeader-CvIyaFOO.js";import{n as m,s as h,u as g}from"./format-Cg7VCIZW.js";import{a as _,n as v}from"./index-TploGF7u.js";import{t as y}from"./useControlActionGuard-DT7uudrj.js";var b=n();function x(e,t){return t?{label:`Unavailable`,tone:`red`,detail:t}:e===null?{label:`Unknown`,tone:`zinc`,detail:`No response yet`}:e.trim()===`OK`?{label:`Live`,tone:`green`,detail:`HTTP 200 · OK`}:{label:`Unexpected`,tone:`amber`,detail:`HTTP 200 · ${e.trim().slice(0,80)||`empty body`}`}}function S(e,t){return t?{label:`Unavailable`,tone:`red`,detail:t}:e?e.ok===!0&&e.ready===!0?{label:`Ready`,tone:`green`,detail:`Persistence accepts traffic`}:e.ok===!1&&e.ready===!1?{label:`Not ready`,tone:`red`,detail:e.storage.error??`Persistence is degraded`}:{label:`Unexpected`,tone:`amber`,detail:`Incoherent readiness payload`}:{label:`Unknown`,tone:`zinc`,detail:`No response yet`}}function C({path:e,state:t}){return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-b border-line py-2.5 last:border-0`,children:[(0,b.jsx)(`code`,{className:`w-20 shrink-0 font-mono text-xs text-fg`,children:e}),(0,b.jsx)(f,{label:t.label,tone:t.tone}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 text-right text-xs text-faint`,children:t.detail})]})}function w({snapshot:e}){let t=e.metrics?.metrics;return(0,b.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`Orchestrator probes`}),(0,b.jsx)(`p`,{className:`mb-2 text-xs text-muted`,children:`Native Bunqueue liveness and persistence-readiness endpoints.`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(C,{path:`/healthz`,state:x(e.healthz,e.healthzError)}),(0,b.jsx)(C,{path:`/live`,state:x(e.live,e.liveError)}),(0,b.jsx)(C,{path:`/ready`,state:S(e.ready,e.readyError)})]})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`JSON metrics`}),e.metricsError?(0,b.jsxs)(`p`,{className:`text-sm text-danger`,children:[`Unavailable — `,e.metricsError]}):t?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,b.jsx)(O,{k:`Pushed`,v:h(t.totalPushed)}),(0,b.jsx)(O,{k:`Pulled`,v:h(t.totalPulled)}),(0,b.jsx)(O,{k:`Completed`,v:h(t.totalCompleted)}),(0,b.jsx)(O,{k:`Failed`,v:h(t.totalFailed)})]}):(0,b.jsx)(`p`,{className:`text-sm text-muted`,children:`No metrics response yet.`}),(0,b.jsx)(`p`,{className:`mt-3 font-mono text-xs text-faint`,children:`GET /metrics · application/json`})]})]})}function T({heap:e,busy:t,onLoad:n}){return(0,b.jsxs)(l,{className:`mt-6`,children:[(0,b.jsx)(c,{title:`Heap statistics`,action:(0,b.jsx)(s,{size:`sm`,disabled:t,onClick:n,children:t?`Loading…`:e?`Refresh`:`Load`})}),e?(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,b.jsx)(O,{k:`Objects`,v:h(e.heap?.objectCount??0)}),(0,b.jsx)(O,{k:`Protected`,v:h(e.heap?.protectedCount??0)}),(0,b.jsx)(O,{k:`Global`,v:h(e.heap?.globalCount??0)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wider text-faint`,children:`Top object types`}),(0,b.jsx)(`div`,{className:`max-h-52 overflow-y-auto rounded-lg border border-line`,children:(0,b.jsx)(`table`,{className:`w-full text-xs`,children:(0,b.jsx)(`tbody`,{children:(e.topObjectTypes??[]).map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,b.jsx)(`td`,{className:`px-3 py-1.5 font-mono text-muted`,children:e.type}),(0,b.jsx)(`td`,{className:`px-3 py-1.5 text-right tnum text-fg`,children:h(e.count)})]},e.type))})})})]})]}):(0,b.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On-demand `,(0,b.jsx)(`code`,{className:`font-mono text-xs`,children:`bun:jsc`}),` heap breakdown (forces a GC first). Use it to spot which internal object type is growing when chasing a leak.`]})]})}function E(){let e=r.prometheusUrl();return(0,b.jsxs)(l,{className:`mt-6`,children:[(0,b.jsx)(c,{title:`Prometheus`}),(0,b.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Scrape endpoint (text exposition) for Grafana / Alertmanager. Auth is required only if the server sets `,(0,b.jsx)(`code`,{className:`font-mono text-xs`,children:`requireAuthForMetrics`}),`.`]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-line bg-surface-2 px-3 py-2`,children:[(0,b.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-fg`,children:e}),(0,b.jsx)(_,{value:e})]})]})}function D({stats:e}){return e?(0,b.jsxs)(l,{className:`mt-6`,children:[(0,b.jsx)(c,{title:`Totals since restart`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsx)(O,{k:`Pushed`,v:h(e.totalPushed)}),(0,b.jsx)(O,{k:`Pulled`,v:h(e.totalPulled)}),(0,b.jsx)(O,{k:`Completed`,v:h(e.totalCompleted)}),(0,b.jsx)(O,{k:`Failed`,v:h(e.totalFailed)})]})]}):null}function O({k:e,v:t}){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,b.jsx)(`div`,{className:`mt-1 text-lg font-semibold tnum text-fg`,children:t})]})}var k=e(t(),1);function A(e){let t=y(`diagnostics`),[n,a]=(0,k.useState)(null),o=n?.scope===t.scopeKey?n.value:null,s=(0,k.useRef)(0),c=async()=>{let e=++s.current,n=t.begin(`ping:${e}`);if(!n)return;a({scope:t.scopeKey,value:`…`});let i=performance.now();try{await r.ping(),n.isCurrent()&&s.current===e&&a({scope:t.scopeKey,value:`${Math.round(performance.now()-i)} ms`})}catch{n.isCurrent()&&s.current===e&&a({scope:t.scopeKey,value:`unreachable`})}finally{n.finish()}},[l,u]=(0,k.useState)(null),d=l?.scope===t.scopeKey&&l.busy,f=l?.scope===t.scopeKey?l.message:null,p=async()=>{let n=t.begin(`gc`);if(n){u({busy:!0,message:null,scope:t.scopeKey});try{let a=await r.gc();if(!n.isCurrent())return;let o=a.before.rss-a.after.rss,s=o>0?`Freed ${o} MB (RSS ${a.before.rss}→${a.after.rss})`:`No memory reclaimed`;u({busy:!0,message:s,scope:t.scopeKey}),i.success(`Memory compacted`,s),e()}catch(e){if(!n.isCurrent())return;let r=e.message;i.error(`GC failed`,r),u({busy:!0,message:r,scope:t.scopeKey})}finally{n.finish()&&u(e=>e?.scope===t.scopeKey?{...e,busy:!1}:e)}}},[m,h]=(0,k.useState)(null);return{doGc:p,doPing:c,gcBusy:d,gcMsg:f,heap:m?.scope===t.scopeKey?m.value:null,heapBusy:m?.scope===t.scopeKey&&m.busy,loadHeap:async()=>{let e=t.begin(`heap`);if(e){h({busy:!0,scope:t.scopeKey,value:null});try{let n=await r.heapStats();e.isCurrent()&&h({busy:!0,scope:t.scopeKey,value:n})}catch(t){e.isCurrent()&&i.error(`Heap stats failed`,t.message)}finally{e.finish()&&h(e=>e?.scope===t.scopeKey?{...e,busy:!1}:e)}}},ping:o}}async function j(e){try{return{value:await e,error:null}}catch(e){return{value:null,error:e instanceof Error?e.message:String(e)}}}function M(){let{data:e,error:t,loading:n,refetch:i}=o(async()=>{let[e,t,n,i,o,s,c]=await Promise.all([j(r.health()),j(r.storage()),j(r.stats()),j(a.healthz()),j(a.live()),j(a.ready()),j(a.metrics())]);return{health:e.value,storage:t.value,stats:n.value,healthError:e.error,storageError:t.error,statsError:n.error,healthz:i.value,live:o.value,ready:s.value,metrics:c.value,healthzError:i.error,liveError:o.error,readyError:s.error,metricsError:c.error}},[]),{doGc:f,doPing:h,gcBusy:_,gcMsg:y,heap:x,heapBusy:S,loadHeap:C,ping:k}=A(i);if(n&&!e&&!t)return(0,b.jsx)(d,{label:`Loading diagnostics…`});let M=e??{health:null,storage:null,stats:null,healthError:null,storageError:null,statsError:null,healthz:null,live:null,ready:null,metrics:null,healthzError:null,liveError:null,readyError:null,metricsError:null},P=M.health,F=M.storage?.data,I=M.stats?.stats,L=P!=null,R=F!=null,z=L&&P.ok===!0,B=!!t||!!M.healthError||!!M.storageError||!!M.statsError||!!M.healthzError||!!M.liveError||!!M.readyError||!!M.metricsError;return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Diagnostics`,description:`Server health, storage, memory and connections.`,live:!!e&&!B}),t&&(0,b.jsx)(u,{message:`Diagnostics refresh failed — ${t.message}`,onRetry:i}),M.healthError&&(0,b.jsx)(u,{message:`Health unavailable — ${M.healthError}`,onRetry:i}),M.storageError&&(0,b.jsx)(u,{message:`Storage diagnostics unavailable — ${M.storageError}`,onRetry:i}),M.statsError&&(0,b.jsx)(u,{message:`Server totals unavailable — ${M.statsError}`,onRetry:i}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsx)(v,{label:`Status`,value:L?P.status??(P.ok?`healthy`:`degraded`):`Unavailable`,tone:z?`green`:`red`,compact:!0}),(0,b.jsx)(v,{label:`Version`,value:P?.version?`v${P.version}`:`—`,compact:!0}),(0,b.jsx)(v,{label:`Uptime`,value:g(P?.uptime),compact:!0}),(0,b.jsx)(v,{label:`Disk`,value:R?F.diskFull?`Full`:`Healthy`:`Unavailable`,tone:!R||F.diskFull?`red`:`green`,compact:!0})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`Connectivity`,action:(0,b.jsxs)(s,{size:`sm`,onClick:h,children:[`Ping`,k?` · ${k}`:``]})}),(0,b.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,b.jsx)(N,{k:`WebSocket clients`,v:P?.connections?.ws==null?`—`:String(P.connections.ws)}),(0,b.jsx)(N,{k:`SSE clients`,v:P?.connections?.sse==null?`—`:String(P.connections.sse)}),(0,b.jsx)(N,{k:`Storage error`,v:M.storageError?`unavailable — ${M.storageError}`:F?.error?String(F.error):R?`none`:`—`})]})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`Memory`,action:(0,b.jsx)(s,{size:`sm`,disabled:_,onClick:f,children:_?`Compacting…`:`Compact (GC)`})}),(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,b.jsx)(O,{k:`Heap used`,v:P?.memory?m(P.memory.heapUsed*1024*1024):`—`}),(0,b.jsx)(O,{k:`Heap total`,v:P?.memory?m(P.memory.heapTotal*1024*1024):`—`}),(0,b.jsx)(O,{k:`RSS`,v:P?.memory?m(P.memory.rss*1024*1024):`—`})]}),y&&(0,b.jsx)(`p`,{className:`mt-3 text-xs text-muted`,children:y})]})]}),(0,b.jsx)(w,{snapshot:M}),(0,b.jsx)(T,{heap:x,busy:S,onLoad:C}),(0,b.jsx)(E,{}),(0,b.jsx)(D,{stats:I})]})}function N({k:e,v:t}){return(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,b.jsx)(`dt`,{className:`text-muted`,children:e}),(0,b.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}export{M as Diagnostics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{u as r}from"./icons-BVzwsfbG.js";import{t as i}from"./api-81m1TwB7.js";import{n as a}from"./usePolledData-CNtNtd0a.js";import{t as o}from"./Button-Ch1W94fJ.js";import{i as s,n as c,r as l,t as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./PageHeader-CvIyaFOO.js";import{l as f,s as p}from"./format-Cg7VCIZW.js";import{n as m}from"./index-TploGF7u.js";import{a as h}from"./form-C4oby9pI.js";import{t as g}from"./Pagination-x-Cwgrul.js";import{r as _,t as v}from"./flowMutationSafety-6cP-l4Pa.js";import{t as y}from"./Jobs-CkyRvzOT.js";var b=e(t(),1),x=n(),S=25;function C(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}async function w(){let e=await y();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!C(e.waiting)||!C(e.delayed)||!C(e.active)||!C(e.dlq)||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function T(){let[e,t]=(0,b.useState)(``),[n,y]=(0,b.useState)(0),{data:C,error:T,loading:E,refetch:D}=a(w,[],{intervalMs:3e4});(0,b.useEffect)(()=>{if(e||!C?.queues?.length)return;let n=C.queues.find(e=>e.dlq>0)??C.queues[0];t(n.name)},[C,e]);let{data:O,error:k,loading:A,refetch:j}=a((0,b.useCallback)(async()=>{if(!e)return{entries:[],total:0};let t=await i.dlq(e,S,n*S);return{entries:t.entries??[],total:t.total??t.entries?.length??0}},[e,n]),[e,n]),M=O?.entries??[];return(0,x.jsxs)(`div`,{children:[k&&O&&(0,x.jsx)(s,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:j}),T&&(0,x.jsx)(s,{onRetry:D,message:`Could not discover queues — ${T.message}. Retry before selecting a queue.`}),(0,x.jsx)(d,{title:`Dead Letter Queue`,description:`Jobs that exhausted their retries.`,live:!!e&&!!O&&!k&&!T,actions:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(o,{size:`sm`,disabled:!0,title:v,children:`Retry all`}),(0,x.jsx)(o,{variant:`danger`,size:`sm`,disabled:!0,title:_,children:`Purge`})]})}),(0,x.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-56`,children:(0,x.jsx)(h,{value:e,"aria-label":`Queue`,name:`classic-dlq-queue`,autoComplete:`off`,onChange:e=>{t(e.target.value),y(0)},children:(C?.queues??[]).map(e=>(0,x.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,x.jsx)(`div`,{className:`w-40`,children:(0,x.jsx)(m,{label:`DLQ Entries`,value:e&&O?p(O.total):`—`,tone:e&&O?.total?`red`:`default`,compact:!0})})]}),k&&!O?(0,x.jsx)(c,{error:k,onRetry:j}):E&&!C&&!e&&!T?(0,x.jsx)(l,{label:`Discovering queues…`}):A&&!O&&!k?(0,x.jsx)(l,{label:`Loading DLQ…`}):T&&!e?(0,x.jsx)(u,{icon:(0,x.jsx)(r,{}),title:`Could not discover queues`,hint:`${T.message}. Retry the queue discovery request above.`}):e?M.length===0?(0,x.jsx)(u,{icon:(0,x.jsx)(r,{}),title:`Dead letter queue is empty`,hint:`Jobs land here after exhausting their retry attempts.`}):(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:`Job ID`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,x.jsx)(`tbody`,{children:M.map((e,t)=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.id}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.job.name??e.job.data?.name??`default`}),(0,x.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-red-400/90`,children:String(e.reason||e.error||`—`)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.attempts?.length??e.job.attempts??`—`}),(0,x.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,x.jsx)(u,{icon:(0,x.jsx)(r,{}),title:C?.queues.length===0?`No queues available`:`Select a queue`,hint:`A queue must be selected before its dead letter entries can be inspected.`}),O&&(0,x.jsx)(g,{page:n,pageSize:S,total:O.total,onPageChange:y,label:`entries`})]})}export{T as Dlq};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CyjgmGTq.js";import{t as a}from"./bq-DYmbVkgR.js";import{t as o}from"./toastStore-B7n0zS0y.js";import{C as s,T as c,a as l,d as u,f as d,u as f}from"./icons-CIvFfU2b.js";import{n as p}from"./usePolledData-c53tx1jw.js";import{n as m,t as h}from"./Button-BPqpRZJD.js";import{i as g,n as _,r as v,t as y}from"./feedback-BnGE2oW2.js";import{t as b}from"./PageHeader-BXlZSBcc.js";import{a as x,i as S,l as C,s as w}from"./format-Cg7VCIZW.js";import{a as T,n as E}from"./index-D64v2vNO.js";import{a as D}from"./form-tC20r4Ma.js";import{t as O}from"./Pagination-Q-vf4hsX.js";import{r as k,t as A}from"./flowMutationSafety-DObp9nJo.js";import{t as j}from"./exportFile-C7xhE8Yh.js";import{t as M}from"./QueueControl-l5bSdMgb.js";var N=e(n(),1),P=i();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:s,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=>s(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)(c,{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:n,onToggle:i,attempts:a}){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":n?`Collapse details`:`Expand details`,"aria-expanded":n,onClick:i,children:(0,P.jsx)(l,{className:t(`size-3.5 transition-transform`,n&&`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)(r,{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??a.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)(r,{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)(d,{className:`size-3.5`})}),(0,P.jsx)(m,{"aria-label":`Retry job unavailable`,disabled:!0,title:A,children:(0,P.jsx)(s,{className:`size-3.5`})})]})})]}),n&&(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,`×`]})]}),a.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:a.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=e=>`${e.job.id}-${e.enteredAt}`;function B(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(0),[i,c]=(0,N.useState)(`all`),[l,d]=(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)(()=>{e||!S?.queues?.length||t((S.queues.find(e=>e.dlq>0)??S.queues[0]).name)},[S,e]);let{data:E,error:D,loading:B,refetch:V}=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([a.dlq(e,R,n*R),a.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]),H=E&&E.queue===e&&E.page===n?E:null;(0,N.useEffect)(()=>{if(!H)return;let e=Math.max(0,Math.ceil((H.total??0)/R)-1);n>e&&r(e)},[H,n]),(0,N.useEffect)(()=>{x(new Set)},[e,n]);let U=H?.stats?.byReason??{},W=(0,N.useMemo)(()=>Object.keys(U).filter(e=>U[e]>0),[U]),G=(0,N.useMemo)(()=>[...W].sort((e,t)=>(U[t]??0)-(U[e]??0))[0],[W,U]),K=H?.entries??[],q=(0,N.useMemo)(()=>{let e=K;i!==`all`&&(e=e.filter(e=>e.reason===i));let t=l.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[K,i,l]),J=i!==`all`||l.trim()!==``,Y=(H?.total??0)>R,X=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&&!!H&&!H.statsError&&!D&&!C,actions:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(h,{size:`sm`,disabled:!e||!q.length,onClick:()=>{if(q.length===0){o.info(`Nothing to export`);return}j(`dlq-${e}`,q.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)(u,{className:`size-3.5`}),` Export`]}),(0,P.jsxs)(h,{size:`sm`,disabled:!0,title:A,children:[(0,P.jsx)(s,{className:`size-3.5`}),` Retry all`]}),(0,P.jsx)(h,{variant:`danger`,size:`sm`,disabled:!0,title:k,children:`Purge`})]})}),D&&H&&(0,P.jsx)(g,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:V}),C&&(0,P.jsx)(g,{onRetry:T,message:`Could not discover queues — ${C.message}. Retry before selecting a queue.`}),H?.statsError&&(0,P.jsx)(g,{message:`DLQ statistics are unavailable — ${H.statsError}. The entry list may still be current.`,onRetry:V}),(0,P.jsx)(F,{queue:e,data:H,reasons:W,topReason:G}),(0,P.jsx)(I,{queue:e,queues:S?.queues??[],reason:i,reasons:W,byReason:U,search:l,pageScoped:Y,onQueue:e=>{t(e),r(0),c(`all`),d(``)},onReason:c,onSearch:d}),(0,P.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:A}),D&&!H?(0,P.jsx)(_,{error:D,onRetry:V}):w&&!S&&!e&&!C?(0,P.jsx)(v,{label:`Discovering queues…`}):B&&!H&&!D?(0,P.jsx)(v,{label:`Loading DLQ…`}):C&&!e?(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:`Could not discover queues`,hint:`${C.message}. Retry the queue discovery request above.`}):e?q.length===0?(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:J?`No matches`:`Dead letter queue is empty`,hint:J?Y?`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:q.map(e=>{let t=z(e);return(0,P.jsx)(L,{entry:e,isOpen:m.has(t),onToggle:()=>X(t),attempts:e.attempts??[]},t)})})]})}):(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),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.`}),H&&(0,P.jsx)(O,{page:n,pageSize:R,total:H.total,onPageChange:r,label:`entries`})]})}export{B as DlqControl};
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-BOfwNIlJ.js";import{t as o}from"./toastStore-B31o6Z5J.js";import{C as s,T as c,a as l,d as u,f as d,u as f}from"./icons-BVzwsfbG.js";import{n as p}from"./usePolledData-CNtNtd0a.js";import{n as m,t as h}from"./Button-Ch1W94fJ.js";import{i as g,n as _,r as v,t as y}from"./feedback-QDN1AsYt.js";import{t as b}from"./PageHeader-CvIyaFOO.js";import{a as x,i as S,l as C,s as w}from"./format-Cg7VCIZW.js";import{a as T,n as E}from"./index-TploGF7u.js";import{a as D}from"./form-C4oby9pI.js";import{t as O}from"./Pagination-x-Cwgrul.js";import{r as k,t as A}from"./flowMutationSafety-6cP-l4Pa.js";import{t as j}from"./exportFile-C7xhE8Yh.js";import{t as M}from"./QueueControl-BF638r_0.js";var N=e(n(),1),P=i();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:s,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=>s(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)(c,{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:n,onToggle:i,attempts:a}){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":n?`Collapse details`:`Expand details`,"aria-expanded":n,onClick:i,children:(0,P.jsx)(l,{className:t(`size-3.5 transition-transform`,n&&`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)(r,{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??a.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)(r,{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)(d,{className:`size-3.5`})}),(0,P.jsx)(m,{"aria-label":`Retry job unavailable`,disabled:!0,title:A,children:(0,P.jsx)(s,{className:`size-3.5`})})]})})]}),n&&(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,`×`]})]}),a.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:a.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=e=>`${e.job.id}-${e.enteredAt}`;function B(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(0),[i,c]=(0,N.useState)(`all`),[l,d]=(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)(()=>{e||!S?.queues?.length||t((S.queues.find(e=>e.dlq>0)??S.queues[0]).name)},[S,e]);let{data:E,error:D,loading:B,refetch:V}=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([a.dlq(e,R,n*R),a.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]),H=E?.queue===e&&E.page===n?E:null;(0,N.useEffect)(()=>{if(!H)return;let e=Math.max(0,Math.ceil((H.total??0)/R)-1);n>e&&r(e)},[H,n]),(0,N.useEffect)(()=>{x(new Set)},[e,n]);let U=H?.stats?.byReason??{},W=(0,N.useMemo)(()=>Object.keys(U).filter(e=>U[e]>0),[U]),G=(0,N.useMemo)(()=>[...W].sort((e,t)=>(U[t]??0)-(U[e]??0))[0],[W,U]),K=H?.entries??[],q=(0,N.useMemo)(()=>{let e=K;i!==`all`&&(e=e.filter(e=>e.reason===i));let t=l.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[K,i,l]),J=i!==`all`||l.trim()!==``,Y=(H?.total??0)>R,X=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&&!!H&&!H.statsError&&!D&&!C,actions:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(h,{size:`sm`,disabled:!e||!q.length,onClick:()=>{if(q.length===0){o.info(`Nothing to export`);return}j(`dlq-${e}`,q.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)(u,{className:`size-3.5`}),` Export`]}),(0,P.jsxs)(h,{size:`sm`,disabled:!0,title:A,children:[(0,P.jsx)(s,{className:`size-3.5`}),` Retry all`]}),(0,P.jsx)(h,{variant:`danger`,size:`sm`,disabled:!0,title:k,children:`Purge`})]})}),D&&H&&(0,P.jsx)(g,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:V}),C&&(0,P.jsx)(g,{onRetry:T,message:`Could not discover queues — ${C.message}. Retry before selecting a queue.`}),H?.statsError&&(0,P.jsx)(g,{message:`DLQ statistics are unavailable — ${H.statsError}. The entry list may still be current.`,onRetry:V}),(0,P.jsx)(F,{queue:e,data:H,reasons:W,topReason:G}),(0,P.jsx)(I,{queue:e,queues:S?.queues??[],reason:i,reasons:W,byReason:U,search:l,pageScoped:Y,onQueue:e=>{t(e),r(0),c(`all`),d(``)},onReason:c,onSearch:d}),(0,P.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:A}),D&&!H?(0,P.jsx)(_,{error:D,onRetry:V}):w&&!S&&!e&&!C?(0,P.jsx)(v,{label:`Discovering queues…`}):B&&!H&&!D?(0,P.jsx)(v,{label:`Loading DLQ…`}):C&&!e?(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:`Could not discover queues`,hint:`${C.message}. Retry the queue discovery request above.`}):e?q.length===0?(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:J?`No matches`:`Dead letter queue is empty`,hint:J?Y?`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:q.map(e=>{let t=z(e);return(0,P.jsx)(L,{entry:e,isOpen:m.has(t),onToggle:()=>X(t),attempts:e.attempts??[]},t)})})]})}):(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),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.`}),H&&(0,P.jsx)(O,{page:n,pageSize:R,total:H.total,onPageChange:r,label:`entries`})]})}export{B as DlqControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{t as o}from"./bq-DYmbVkgR.js";import{t as s}from"./toastStore-B7n0zS0y.js";import{C as c,d as l,u}from"./icons-CIvFfU2b.js";import{n as d}from"./usePolledData-c53tx1jw.js";import{n as f,t as p}from"./Button-BPqpRZJD.js";import{t as m}from"./Card-C7NMhqUt.js";import{i as h,n as g,r as _,t as v}from"./feedback-BnGE2oW2.js";import{t as y}from"./PageHeader-BXlZSBcc.js";import{l as b,s as x}from"./format-Cg7VCIZW.js";import{a as S}from"./form-tC20r4Ma.js";import{t as C}from"./Pagination-Q-vf4hsX.js";import{r as w,t as T}from"./flowMutationSafety-DObp9nJo.js";import{t as E}from"./exportFile-C7xhE8Yh.js";import{t as D}from"./QueueControl-l5bSdMgb.js";var O=e(r(),1),k=a();function ee({total:e,discoveryError:n,healthy:r,statsError:i,queue:a,topReason:o,pendingRetry:s,reasonCount:c}){return(0,k.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,k.jsxs)(m,{children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,k.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,n?`bg-amber-500/10 text-warning`:e==null?`bg-surface-2 text-muted`:r?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:n?`Unavailable`:e==null?`Loading`:r?`Healthy`:`Attention`})]}),(0,k.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,e==null||n?`text-muted`:r?`text-success`:`text-danger`),children:e==null?`—`:x(e)})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,k.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:n||i?`Unavailable`:a?o??`No failures`:`Select a queue`})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,k.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:s==null?`—`:x(s)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,k.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:c==null?`—`:x(c)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]})}function te({queues:e,queue:n,onSelect:r}){return e.length===0?null:(0,k.jsxs)(m,{className:`mb-6`,children:[(0,k.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(p,{size:`sm`,disabled:!0,title:T,children:[(0,k.jsx)(c,{className:`size-3.5`}),` Retry all (`,e.length,` queues)`]}),(0,k.jsxs)(p,{variant:`danger`,size:`sm`,disabled:!0,title:w,children:[`Purge all (`,e.length,` queues)`]})]})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:e.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>r(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,n===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,k.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,k.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:s,onReason:u,onSort:d,onSearch:m,onExport:h}){return(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)(S,{value:e,"aria-label":`Queue`,name:`dlq-queue`,autoComplete:`off`,onChange:e=>s(e.target.value),children:[(0,k.jsx)(`option`,{value:``,children:`Select a queue…`}),t.map(e=>(0,k.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,k.jsx)(`div`,{className:`w-40`,children:(0,k.jsxs)(S,{value:n,onChange:e=>u(e.target.value),"aria-label":`Filter by reason`,name:`dlq-reason-filter`,autoComplete:`off`,children:[(0,k.jsx)(`option`,{value:`all`,children:`All Reasons`}),r.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))]})}),(0,k.jsx)(`div`,{className:`w-36`,children:(0,k.jsxs)(S,{value:i,onChange:e=>d(e.target.value),"aria-label":o?`Sort this page`:`Sort`,name:`dlq-sort`,autoComplete:`off`,children:[(0,k.jsxs)(`option`,{value:`newest`,children:[`Newest First`,o?` (this page)`:``]}),(0,k.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,o?` (this page)`:``]})]})}),(0,k.jsx)(`input`,{value:a,onChange:e=>m(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,k.jsxs)(p,{size:`sm`,disabled:!0,title:T,children:[(0,k.jsx)(c,{className:`size-3.5`}),` Retry All`]}),(0,k.jsx)(p,{variant:`danger`,size:`sm`,disabled:!0,title:w,children:`Purge All`}),(0,k.jsx)(f,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!e,onClick:h,children:(0,k.jsx)(l,{className:`size-3.5`})})]})}function j({entries:e,expanded:n,onToggle:r}){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:`Reason`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Error`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,k.jsx)(`th`,{className:`w-16 px-5 py-3`})]})}),(0,k.jsx)(`tbody`,{children:e.map(e=>{let a=`${e.job.id}-${e.enteredAt}`;return(0,k.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,k.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,k.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,k.jsx)(`button`,{type:`button`,title:e.error,"aria-expanded":n.has(a),onClick:()=>r(a),className:t(`block w-full break-words text-left`,!n.has(a)&&`line-clamp-2`),children:e.error}):`—`}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:b(e.enteredAt)}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,k.jsx)(f,{"aria-label":`Retry unavailable`,disabled:!0,title:T,children:(0,k.jsx)(c,{className:`size-3.5`})})})]},a)})})]})})}var M=25;function N(){let[e,t]=n(),[r,i]=(0,O.useState)(``),[a,c]=(0,O.useState)(`all`),[l,f]=(0,O.useState)(`newest`),[p,m]=(0,O.useState)(``),[b,x]=(0,O.useState)(0),[S,w]=(0,O.useState)(new Set),{data:N,error:P,loading:F,refetch:I}=d(D,[],{intervalMs:1e4}),L=N?.queues??[],R=N?L.reduce((e,t)=>e+t.dlq,0):null,{data:z,error:B,loading:V,refetch:H}=d((0,O.useCallback)(async()=>{if(!r)return{queue:r,page:b,entries:[],entriesTotal:0,stats:null,statsError:null};let[e,t]=await Promise.all([o.dlq(r,M,b*M),o.dlqStats(r).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:r,page:b,entries:e.entries??[],entriesTotal:e.total??0,stats:t.stats,statsError:t.error}},[r,b]),[r,b]),U=z&&z.queue===r&&z.page===b?z:null;(0,O.useEffect)(()=>{if(!U)return;let e=U.entriesTotal??0;b>0&&b*M>=e&&x(Math.max(0,Math.ceil(e/M)-1))},[U,b]);let W=()=>{let e=(U?.entries??[]).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){s.info(`Nothing to export on this page`);return}E(`dlq-${r}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},G=e=>{X.current=!0,i(e),x(0),c(`all`),t(e?{queue:e}:{},{replace:!0})},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,O.useMemo)(()=>L.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[L]),X=(0,O.useRef)(!1),Z=e.get(`queue`);(0,O.useEffect)(()=>{if(!(X.current||r)){if(Z){if(L.some(e=>e.name===Z)){X.current=!0,i(Z),x(0),c(`all`);return}if(L.length===0)return}Y.length!==0&&(X.current=!0,i(Y[0].name),x(0),c(`all`))}},[r,L,Y,Z]);let Q=(0,O.useMemo)(()=>{let e=U?.entries??[];a!==`all`&&(e=e.filter(e=>e.reason===a));let t=p.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>l===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[U,a,p,l]),ne=R===0&&!P,$=a!==`all`||p.trim()!==``,re=(U?.entriesTotal??0)>M;return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(y,{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&&!P}),B&&U&&(0,k.jsx)(h,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:H}),P&&(0,k.jsx)(h,{onRetry:I,message:`Could not discover queue DLQ totals — ${P.message}. Health status is unavailable.`}),U?.statsError&&(0,k.jsx)(h,{message:`DLQ statistics are unavailable — ${U.statsError}. The entry list may still be current.`,onRetry:H}),(0,k.jsx)(ee,{total:R,discoveryError:!!P,healthy:ne,statsError:!!U?.statsError,queue:r,topReason:J,pendingRetry:U?.stats?.pendingRetry,reasonCount:U?.stats?q.length:void 0}),(0,k.jsx)(te,{queues:Y,queue:r,onSelect:G}),(0,k.jsx)(A,{queue:r,queues:L,reason:a,reasons:q,sort:l,search:p,pageScoped:re,onQueue:G,onReason:c,onSort:f,onSearch:m,onExport:W}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:T}),B&&!U?(0,k.jsx)(g,{error:B,onRetry:H}):F&&!N&&!r&&!P?(0,k.jsx)(_,{label:`Discovering queues…`}):V&&!U&&!B?(0,k.jsx)(_,{label:`Loading DLQ…`}):P&&!r?(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:`Could not discover queues`,hint:`${P.message}. Retry the queue discovery request above.`}):r?Q.length===0?(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),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,k.jsx)(j,{entries:Q,expanded:S,onToggle:e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}):(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),r&&U&&(0,k.jsx)(C,{page:b,pageSize:M,total:U.entriesTotal,onPageChange:x,label:`entries`})]})}export{N as DlqPro};
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{t as o}from"./bq-BOfwNIlJ.js";import{t as s}from"./toastStore-B31o6Z5J.js";import{C as c,d as l,u}from"./icons-BVzwsfbG.js";import{n as d}from"./usePolledData-CNtNtd0a.js";import{n as f,t as p}from"./Button-Ch1W94fJ.js";import{t as m}from"./Card-CWxrC8OY.js";import{i as h,n as g,r as _,t as v}from"./feedback-QDN1AsYt.js";import{t as y}from"./PageHeader-CvIyaFOO.js";import{l as b,s as x}from"./format-Cg7VCIZW.js";import{a as S}from"./form-C4oby9pI.js";import{t as C}from"./Pagination-x-Cwgrul.js";import{r as w,t as T}from"./flowMutationSafety-6cP-l4Pa.js";import{t as E}from"./exportFile-C7xhE8Yh.js";import{t as D}from"./QueueControl-BF638r_0.js";var O=e(r(),1),k=a();function ee({total:e,discoveryError:n,healthy:r,statsError:i,queue:a,topReason:o,pendingRetry:s,reasonCount:c}){return(0,k.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,k.jsxs)(m,{children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,k.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,n?`bg-amber-500/10 text-warning`:e==null?`bg-surface-2 text-muted`:r?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:n?`Unavailable`:e==null?`Loading`:r?`Healthy`:`Attention`})]}),(0,k.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,e==null||n?`text-muted`:r?`text-success`:`text-danger`),children:e==null?`—`:x(e)})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,k.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:n||i?`Unavailable`:a?o??`No failures`:`Select a queue`})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,k.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:s==null?`—`:x(s)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,k.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:c==null?`—`:x(c)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]})}function te({queues:e,queue:n,onSelect:r}){return e.length===0?null:(0,k.jsxs)(m,{className:`mb-6`,children:[(0,k.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(p,{size:`sm`,disabled:!0,title:T,children:[(0,k.jsx)(c,{className:`size-3.5`}),` Retry all (`,e.length,` queues)`]}),(0,k.jsxs)(p,{variant:`danger`,size:`sm`,disabled:!0,title:w,children:[`Purge all (`,e.length,` queues)`]})]})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:e.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>r(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,n===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,k.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,k.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:s,onReason:u,onSort:d,onSearch:m,onExport:h}){return(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)(S,{value:e,"aria-label":`Queue`,name:`dlq-queue`,autoComplete:`off`,onChange:e=>s(e.target.value),children:[(0,k.jsx)(`option`,{value:``,children:`Select a queue…`}),t.map(e=>(0,k.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,k.jsx)(`div`,{className:`w-40`,children:(0,k.jsxs)(S,{value:n,onChange:e=>u(e.target.value),"aria-label":`Filter by reason`,name:`dlq-reason-filter`,autoComplete:`off`,children:[(0,k.jsx)(`option`,{value:`all`,children:`All Reasons`}),r.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))]})}),(0,k.jsx)(`div`,{className:`w-36`,children:(0,k.jsxs)(S,{value:i,onChange:e=>d(e.target.value),"aria-label":o?`Sort this page`:`Sort`,name:`dlq-sort`,autoComplete:`off`,children:[(0,k.jsxs)(`option`,{value:`newest`,children:[`Newest First`,o?` (this page)`:``]}),(0,k.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,o?` (this page)`:``]})]})}),(0,k.jsx)(`input`,{value:a,onChange:e=>m(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,k.jsxs)(p,{size:`sm`,disabled:!0,title:T,children:[(0,k.jsx)(c,{className:`size-3.5`}),` Retry All`]}),(0,k.jsx)(p,{variant:`danger`,size:`sm`,disabled:!0,title:w,children:`Purge All`}),(0,k.jsx)(f,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!e,onClick:h,children:(0,k.jsx)(l,{className:`size-3.5`})})]})}function j({entries:e,expanded:n,onToggle:r}){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:`Reason`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Error`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,k.jsx)(`th`,{className:`w-16 px-5 py-3`})]})}),(0,k.jsx)(`tbody`,{children:e.map(e=>{let a=`${e.job.id}-${e.enteredAt}`;return(0,k.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,k.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,k.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,k.jsx)(`button`,{type:`button`,title:e.error,"aria-expanded":n.has(a),onClick:()=>r(a),className:t(`block w-full break-words text-left`,!n.has(a)&&`line-clamp-2`),children:e.error}):`—`}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:b(e.enteredAt)}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,k.jsx)(f,{"aria-label":`Retry unavailable`,disabled:!0,title:T,children:(0,k.jsx)(c,{className:`size-3.5`})})})]},a)})})]})})}var M=25;function N(){let[e,t]=n(),[r,i]=(0,O.useState)(``),[a,c]=(0,O.useState)(`all`),[l,f]=(0,O.useState)(`newest`),[p,m]=(0,O.useState)(``),[b,x]=(0,O.useState)(0),[S,w]=(0,O.useState)(new Set),{data:N,error:P,loading:F,refetch:I}=d(D,[],{intervalMs:1e4}),L=N?.queues??[],R=N?L.reduce((e,t)=>e+t.dlq,0):null,{data:z,error:B,loading:V,refetch:H}=d((0,O.useCallback)(async()=>{if(!r)return{queue:r,page:b,entries:[],entriesTotal:0,stats:null,statsError:null};let[e,t]=await Promise.all([o.dlq(r,M,b*M),o.dlqStats(r).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:r,page:b,entries:e.entries??[],entriesTotal:e.total??0,stats:t.stats,statsError:t.error}},[r,b]),[r,b]),U=z?.queue===r&&z.page===b?z:null;(0,O.useEffect)(()=>{if(!U)return;let e=U.entriesTotal??0;b>0&&b*M>=e&&x(Math.max(0,Math.ceil(e/M)-1))},[U,b]);let W=()=>{let e=(U?.entries??[]).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){s.info(`Nothing to export on this page`);return}E(`dlq-${r}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},G=e=>{X.current=!0,i(e),x(0),c(`all`),t(e?{queue:e}:{},{replace:!0})},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,O.useMemo)(()=>L.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[L]),X=(0,O.useRef)(!1),Z=e.get(`queue`);(0,O.useEffect)(()=>{if(!(X.current||r)){if(Z){if(L.some(e=>e.name===Z)){X.current=!0,i(Z),x(0),c(`all`);return}if(L.length===0)return}Y.length!==0&&(X.current=!0,i(Y[0].name),x(0),c(`all`))}},[r,L,Y,Z]);let Q=(0,O.useMemo)(()=>{let e=U?.entries??[];a!==`all`&&(e=e.filter(e=>e.reason===a));let t=p.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>l===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[U,a,p,l]),ne=R===0&&!P,$=a!==`all`||p.trim()!==``,re=(U?.entriesTotal??0)>M;return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(y,{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&&!P}),B&&U&&(0,k.jsx)(h,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:H}),P&&(0,k.jsx)(h,{onRetry:I,message:`Could not discover queue DLQ totals — ${P.message}. Health status is unavailable.`}),U?.statsError&&(0,k.jsx)(h,{message:`DLQ statistics are unavailable — ${U.statsError}. The entry list may still be current.`,onRetry:H}),(0,k.jsx)(ee,{total:R,discoveryError:!!P,healthy:ne,statsError:!!U?.statsError,queue:r,topReason:J,pendingRetry:U?.stats?.pendingRetry,reasonCount:U?.stats?q.length:void 0}),(0,k.jsx)(te,{queues:Y,queue:r,onSelect:G}),(0,k.jsx)(A,{queue:r,queues:L,reason:a,reasons:q,sort:l,search:p,pageScoped:re,onQueue:G,onReason:c,onSort:f,onSearch:m,onExport:W}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:T}),B&&!U?(0,k.jsx)(g,{error:B,onRetry:H}):F&&!N&&!r&&!P?(0,k.jsx)(_,{label:`Discovering queues…`}):V&&!U&&!B?(0,k.jsx)(_,{label:`Loading DLQ…`}):P&&!r?(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:`Could not discover queues`,hint:`${P.message}. Retry the queue discovery request above.`}):r?Q.length===0?(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),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,k.jsx)(j,{entries:Q,expanded:S,onToggle:e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}):(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),r&&U&&(0,k.jsx)(C,{page:b,pageSize:M,total:U.entriesTotal,onPageChange:x,label:`entries`})]})}export{N as DlqPro};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{i as o,o as s}from"./connectionStore-CFuNYZ_8.js";import{i as c}from"./upstreamPaths-ZeijhPPb.js";import{a as l,d as u,f as d,s as f}from"./bq-BOfwNIlJ.js";import{t as p}from"./Card-CWxrC8OY.js";import{i as m,n as h,r as g}from"./feedback-QDN1AsYt.js";import{t as _}from"./PageHeader-CvIyaFOO.js";import{i as v}from"./index-TploGF7u.js";import{n as y,t as b}from"./controlConnectionEpoch-DzbuWOhe.js";import{t as x}from"./useControlActionGuard-DT7uudrj.js";var S={nodeWidth:168,nodeHeight:60},C=`flow-order-9a3f`,w={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`},T=e=>e&&w[e]||`border-line bg-surface-2 text-muted`,E=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,D=class extends Error{constructor(e,t){super(e,t),this.name=`FlowSnapshotError`}};function O(e,t,n){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`||c(e)!==null))throw new D(`Job ${n} returned an invalid ${t} list`);return e}function k(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new D(`GET /jobs/${t} returned an invalid response`);let n=e;if(n.ok!==!0)throw new D(`GET /jobs/${t} returned an invalid success envelope`);let r=n.job;if(typeof r!=`object`||!r||Array.isArray(r))throw new D(`GET /jobs/${t} returned no job snapshot`);let i=r;if(i.id!==t)throw new D(`GET /jobs/${t} returned the wrong job id (${String(i.id)})`);if(typeof i.queue!=`string`||i.queue.length===0)throw new D(`Job ${t} returned an invalid queue`);if(typeof i.state!=`string`||i.state.length===0)throw new D(`Job ${t} returned an invalid state`);if(!Object.hasOwn(i,`parentId`)||i.parentId!==null&&(typeof i.parentId!=`string`||c(i.parentId)!==null))throw new D(`Job ${t} returned an invalid parentId`);return{...r,parentId:i.parentId,childrenIds:O(i.childrenIds,`childrenIds`,t),dependsOn:O(i.dependsOn,`dependsOn`,t)}}async function A(e,t,n){n?.throwIfAborted();let r=await d(e,t,n);return n?.throwIfAborted(),k(r,t)}function j(e){let t=c(e);return t?`Job ID: ${t}`:null}async function ee(e,t={}){let n=j(e);if(n)throw new D(n);let r=t.target??u(),{signal:i}=t,a=e,o=new Set([e]),s=[];for(let e=0;;e++){i?.throwIfAborted();let t;try{t=await A(r,a,i)}catch(t){if(i?.throwIfAborted(),e===0)throw t;if(t instanceof l&&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 D(`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 D(`Flow parent cycle detected at job ${n}`);if(e>=100)throw new D(`Flow parent chain exceeds the Bunqueue 2.9.0 limit of 100 levels`);o.add(n),a=n}}function te(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 M=[`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`];function N(e){return M.filter(t=>e[t]===!0)}function P(e,t){if(e?.parentId!==t)return null;let n=N(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 ne(e,t,n={}){let r=j(e);if(r)throw new D(r);let i=n.target??u(),{signal:a}=n,o=new Map,s=[],c=[],l=new Set,d=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,k({ok:!0,job:t},e));let y=[...n.seedPath??[]].reverse(),b=!1;if(y.length>0&&y[0]?.id!==e)throw new D(`Resolved seed path does not start at the requested flow root`);for(let[e,t]of y.entries()){let n=k({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 A(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 u=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(!u(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(u(e)){let n=`${e}->${t}`;d.has(n)||(d.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)&&N(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:P(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=P(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=te([...o.keys()],c);return{jobs:o,edges:s,truncated:S,failed:f.size,failures:f,issues:[...p],policyNotes:[...m],cycle:C,limitations:[...h]}}var re=`bq-dash-recent-flows`,F=8;function I(e){return`${re}:${encodeURIComponent(e.trim()||`/api`)}`}function L(e,t){if(!t)return[];try{let t=JSON.parse(localStorage.getItem(I(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,F):[]}catch{return[]}}function ie(e,t,n,r){let i=[n,...t.filter(e=>e.root!==n.root)].slice(0,F);if(!r)return i;try{localStorage.setItem(I(e),JSON.stringify(i))}catch{}return i}var R=e(r(),1),ae=new Set([`explore`,`create`,`operations`]);function oe(e,t=``){let n=e.get(`root`),r=le(n)?n:t,i=e.get(`mode`),a=ae.has(i)?i:`explore`,o=e.get(`node`);return{root:r,mode:a,node:r&&le(o)?o:null}}function se(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 ce(e,t,n=``){return se({...oe(e,n),...t})}function le(e){return!!(e&&j(e)===null)}function ue(){let[e,t]=n(),r=v()?C:``,i=e.toString(),a=(0,R.useMemo)(()=>oe(new URLSearchParams(i),r),[r,i]),c=a.root,l=s(e=>e.baseUrl),d=s(e=>e.token),f=o(),[p,m]=(0,R.useState)(c),[h,g]=(0,R.useState)(null),[_,y]=(0,R.useState)(!!c),[b,x]=(0,R.useState)(null),[S,w]=(0,R.useState)(()=>L(f,d.length===0)),T=(0,R.useRef)(0),E=(0,R.useRef)(null),O=(0,R.useRef)(!1),k=(0,R.useRef)(z()),A=h?.seed===c?h.graph:null,te=A?a.node&&A.jobs.has(a.node)?a.node:h?.defaultSelected??null:null,M=(0,R.useCallback)((e,n=!1)=>{t(t=>ce(t,e,r),{replace:n})},[r,t]),N=(0,R.useCallback)(async e=>{let t=s.getState();if(t.baseUrl!==l||t.token!==d)return;E.current?.abort(),E.current=null;let n=++T.current,r=e.trim();if(g(null),x(null),!r)return y(!1);let i=j(r);if(i)return x(new D(i)),y(!1);let a=u(),o=z(),c=new AbortController;E.current=c;let f=()=>O.current&&n===T.current&&!c.signal.aborted&&o===z();y(!0);try{let e={target:a,signal:c.signal},t=await ee(r,e),n=t.missingParent?[`Ancestor ${t.missingParent} is no longer available. The graph starts at the oldest surviving node.`]:[],i=await ne(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&&w(e=>ie(a.baseUrl,e,{root:t.id,nodes:i.jobs.size,at:Date.now()},s.getState().token.length===0))}catch(e){f()&&x(e instanceof Error?e:Error(`Failed to load flow`))}finally{E.current===c&&(E.current=null),f()&&y(!1)}},[l,d]);return(0,R.useEffect)(()=>{O.current=!0,k.current=z();let e=s.subscribe(()=>{let e=z();e!==k.current&&(k.current=e,T.current+=1,E.current?.abort(),E.current=null,O.current&&(g(null),x(null),y(!1)))});return()=>{O.current=!1,e(),T.current+=1,E.current?.abort()}},[]),(0,R.useEffect)(()=>w(d?[]:L(f,!0)),[f,d]),(0,R.useEffect)(()=>{let e={...a};A&&(!e.node||!A.jobs.has(e.node))&&(e.node=h?.defaultSelected??null);let n=se(e).toString();n!==i&&t(n,{replace:!0})},[A,i,t,h?.defaultSelected,a]),(0,R.useEffect)(()=>{m(c),N(c)},[c,N]),{input:p,setInput:m,rootParam:c,mode:a.mode,setMode:e=>M({mode:e}),graph:A,selected:te,setSelected:e=>{A?.jobs.has(e)&&M({node:e})},loading:_,error:b,recent:S,load:N,submit:e=>{e.preventDefault();let t=p.trim();if(t){if(j(t))return void N(t);t===c?N(t):M({root:t,mode:`explore`,node:null})}},openRecent:e=>{if(m(e),j(e))return void N(e);let t=e===c;M({root:e,mode:`explore`,node:null}),t&&N(e)}}}function z(){let{token:e}=s.getState();return JSON.stringify([o(),e])}function de(e){return e instanceof l&&e.status===0||[`TypeError`,`AbortError`,`TimeoutError`].includes(e.name)}var B=e=>({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),fe=new Set([`removeChildDependency`,`removeUnprocessedChildren`,`removeDeduplicationKey`,`retry`,`promote`,`remove`]),pe=e=>e+5e3,V={create:(e,t)=>f(`/flows/create?target=${encodeURIComponent(o())}`,B({operation:e,...t})),getFlow:e=>{let t=new URLSearchParams({id:e.id,queueName:e.queueName,target:o()});return e.depth!==void 0&&t.set(`depth`,String(e.depth)),e.maxChildren!==void 0&&t.set(`maxChildren`,String(e.maxChildren)),f(`/flows/tree?${t}`)},inspect:(e,t)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:o()})}`),getParentResult:e=>f(`/flows/results?target=${encodeURIComponent(o())}`,B({operation:`getParentResult`,parentId:e})),getParentResults:e=>f(`/flows/results?target=${encodeURIComponent(o())}`,B({operation:`getParentResults`,parentIds:e})),waitUntilFinished:(e,t)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/waitUntilFinished?${new URLSearchParams({queueName:e.queueName,target:o(),ttl:String(t)})}`,void 0,pe(t)),mutate:(e,t,n)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:o()})}`,fe.has(t)?{method:`POST`}:B(n??{}))},H=a();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,R.useMemo)(()=>({key:e,connectionEpoch:n}),[n,e]),o=(0,R.useRef)(a),s=(0,R.useRef)(void 0),c=(0,R.useRef)(void 0),l=(0,R.useRef)(void 0),u=(0,R.useRef)(0),d=(0,R.useRef)(!0),[f,p]=(0,R.useState)(),[m,h]=(0,R.useState)(),[g,_]=(0,R.useState)();return(0,R.useLayoutEffect)(()=>{o.current.connectionEpoch!==a.connectionEpoch&&(c.current=void 0),o.current=a,s.current=void 0,l.current=void 0},[a]),(0,R.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:me(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 me(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 he({repository:e=V,onOpen:t}){let[n,r]=(0,R.useState)(`add`),[i,a]=(0,R.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=ge(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 ge(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 _e({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:E(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 ve=[`getChildrenValues`,`getDependencies`,`getDependenciesCount`,`getFailedChildrenValues`,`getIgnoredChildrenFailures`],ye=[{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 be({repository:e=V,initialTarget:t={id:``,queueName:``},target:n,onTargetChange:r,showTarget:i=!0}){let[a,o]=(0,R.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=xe(s);l.run(t,()=>e.inspect(n,t))},p=t=>{let n=xe(s);window.confirm(`${t} on ${n.id} in ${n.queueName}? This changes durable queue state and has no compare-and-swap precondition.`)&&l.run(t,()=>e.mutate(n,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)(`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:ve.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:ye.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,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 xe=e=>({id:e.id.trim(),queueName:e.queueName.trim()});function Se({repository:e=V,initialIds:t=``}){let[n,r]=(0,R.useState)(t),i=G(W(n)),a=i.busy,o=Ce(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
|
+
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 Ce(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).slice(0,1e3)}function we({repository:e=V,target:t,onTargetChange:n}){let[r,i]=(0,R.useState)(`10`),[a,o]=(0,R.useState)(`100`),s=G(W(t.id,t.queueName,r,a)),c=!!s.busy,l=!!(t.id.trim()&&t.queueName.trim())&&ke(r)&&ke(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)(Te,{label:`Depth`,value:r,onChange:i}),(0,H.jsx)(Te,{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)(Ee,{loaded:s.result})]})}function Te({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 Ee({loaded:e}){let t=De(e.value),n=t?Oe(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] ${T(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 De(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 Oe(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 ke=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,Ae=[`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:{}},je={progress:{stage:`hydrate`,completed:4,total:10}};function Me({repository:e=V,initialTarget:t={id:``,queueName:``}}){let[n,r]=(0,R.useState)(t),[i,a]=(0,R.useState)(`updateData`),[o,s]=(0,R.useState)(JSON.stringify(X.updateData,null,2)),[c,l]=(0,R.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)(we,{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.0.`})]}),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)(`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:Ae.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`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d,onClick:()=>{let t;try{t=JSON.parse(o)}catch{return u.reject(`Mutation payload must be valid JSON.`)}if(!t||typeof t!=`object`||Array.isArray(t))return u.reject(`Mutation payload must be a JSON object.`);let r=Z(n),a=i;window.confirm(`${a} on ${r.id}? This writes durable job state without a compare-and-swap precondition.`)&&u.run(a,()=>e.mutate(r,a,t),{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(je,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||!Ne(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)(be,{repository:e,target:n,onTargetChange:r,showTarget:!1}),(0,H.jsx)(Se,{repository:e})]})}var Z=e=>({id:e.id.trim(),queueName:e.queueName.trim()}),Ne=e=>Number.isSafeInteger(Number(e))&&Number(e)>=1&&Number(e)<=6e4;function Pe({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.0 flow topology is resolved from durable parent, children, and dependency contracts. Up to `,500,` nodes are rendered.`]})]})}var Fe={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function Ie(e,t){let n=new Map,r=new Map,i=new Map;for(let t of e)n.set(t,0),r.set(t,0),i.set(t,[]);for(let e of t)!n.has(e.from)||!n.has(e.to)||e.from===e.to||(i.get(e.from)?.push(e.to),r.set(e.to,(r.get(e.to)??0)+1));let a=e.filter(e=>(r.get(e)??0)===0),o=new Set;for(;o.size<n.size;){for(;a.length;){let e=a.shift();if(!o.has(e)){o.add(e);for(let t of i.get(e)??[]){if(o.has(t))continue;n.set(t,Math.max(n.get(t)??0,(n.get(e)??0)+1));let i=(r.get(t)??0)-1;r.set(t,i),i===0&&a.push(t)}}}let t=e.find(e=>!o.has(e));if(t===void 0)break;a.push(t)}return n}function Le(e,t,n={}){let r={...Fe,...n},i=Ie(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 Re({graph:e,layout:n,selected:r,onSelect:i}){let a=new Map(n.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:n.width,height:n.height},children:[(0,H.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:n.width,height:n.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=a.get(e.from),n=a.get(e.to);return!t||!n?null:(0,H.jsx)(`path`,{d:Be(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}`)})]}),n.nodes.map(n=>{let a=e.jobs.get(n.id),o=e.failures.has(n.id)?`unavailable`:a?.state??`unknown`;return(0,H.jsxs)(`button`,{type:`button`,"data-flow-node":n.id,onClick:()=>i(n.id),"aria-pressed":r===n.id,"aria-label":`${n.id}, queue ${a?.queue??`unknown`}, state ${o}`,title:n.id,style:{left:n.x,top:n.y,width:168,height:60},className:t(`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`,T(a?.state),r===n.id&&`ring-2 ring-accent`),children:[(0,H.jsx)(`span`,{translate:`no`,className:`truncate font-mono text-xs text-fg`,children:E(n.id)}),(0,H.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:a?.queue??`—`}),(0,H.jsx)(`span`,{className:`font-medium`,children:o})]})]},n.id)})]})]})}function ze(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function Be(e,t){return e.x<=t.x?ze(e.x+168,e.y+60/2,t.x,t.y+60/2):ze(e.x,e.y+60/2,t.x+168,t.y+60/2)}function Ve({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)(He,{job:n,failure:r}):(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Select a node to inspect it.`}),(0,H.jsx)(Ue,{graph:e})]})})}function He({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)(i,{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 Ue({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 We({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)(Re,{graph:e,layout:(0,R.useMemo)(()=>Le([...e.jobs.keys()],e.edges,S),[e]),selected:t,onSelect:n}),(0,H.jsx)(Ve,{graph:e,selected:t})]})}function Ge(){let e=ue();return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(_,{title:`Job Flows`,description:`Inspect Bunqueue 2.9.0 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)(he,{onOpen:e.openRecent}),e.mode===`operations`&&(0,H.jsx)(Me,{initialTarget:v()?{id:`flow-order-9a3f`,queueName:`orders`}:void 0}),e.mode===`explore`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Pe,{input:e.input,loading:e.loading,onInput:e.setInput,onSubmit:e.submit}),(0,H.jsxs)(`div`,{"aria-live":`polite`,children:[e.error&&(de(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)(_e,{recent:e.recent,onOpen:e.openRecent}),e.graph&&(0,H.jsx)(We,{graph:e.graph,selected:e.selected,onSelect:e.setSelected})]})]})}export{Ge as Flows};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,l as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{i as o,o as s}from"./connectionStore-CFuNYZ_8.js";import{a as c,n as l}from"./upstreamPaths-ZeijhPPb.js";import{a as u,t as d}from"./bq-BOfwNIlJ.js";import{T as f,d as p}from"./icons-BVzwsfbG.js";import{n as m,t as h}from"./Button-Ch1W94fJ.js";import{n as g,t as _}from"./Card-CWxrC8OY.js";import{r as v,t as y}from"./feedback-QDN1AsYt.js";import{t as b}from"./StatusBadge-BoOVTnKu.js";import{t as x}from"./PageHeader-CvIyaFOO.js";import{a as S,i as C}from"./format-Cg7VCIZW.js";import{a as w}from"./index-TploGF7u.js";import{a as T,n as E,o as D}from"./form-C4oby9pI.js";import{r as O}from"./flowMutationSafety-6cP-l4Pa.js";import{n as k}from"./exportFile-C7xhE8Yh.js";import{t as A}from"./jobActions-LQD4KfCc.js";var j=1e4,M=100,ee=256*1024;function N(e){throw new u(`Invalid job response: ${e}`,200)}function P(e,t,{nullable:n=!1,nonEmpty:r=!1}={},i=`job`){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let a=e[t];n&&a===null||(typeof a!=`string`||r&&!a.trim())&&N(`${i}.${t} must be ${n?`a string or null`:`a string`}${r?` (non-empty)`:``}`)}function F(e,t,{nullable:n=!1,integer:r=!1,min:i,max:a}={},o=`job`){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let s=e[t];n&&s===null||(typeof s!=`number`||!Number.isFinite(s)||r&&!Number.isSafeInteger(s)||i!==void 0&&s<i||a!==void 0&&s>a)&&N(`${o}.${t} must be a valid${r?` safe integer`:` finite number`}`)}function I(e,t){Object.hasOwn(e,t)&&e[t]!==void 0&&typeof e[t]!=`boolean`&&N(`job.${t} must be a boolean`)}function L(e,t,{nullable:n=!1,nonEmpty:r=!1}={}){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let i=e[t];n&&i===null||(!Array.isArray(i)||i.some(e=>typeof e!=`string`||r&&!e.trim()))&&N(`job.${t} must be ${n?`a string array or null`:`a string array`}`)}function te(e,t){let n=0,r=0;for(;n<e.length&&r<t;){let t=e.codePointAt(n);n+=t!==void 0&&t>65535?2:1,r+=1}return{text:e.slice(0,n),count:r}}function ne(e){let t=[],n=0,r=!1,i=Math.min(e.length,M);for(let a=0;a<i;a++){let i=+(t.length>0),o=ee-n-i;if(o<=0){r=!0;break}let s=e[a]??``,c=te(s,o);if(t.push(c.text),n+=i+c.count,c.text.length!==s.length){r=!0;break}}return t.length<e.length&&(r=!0),{text:t.join(`
|
|
2
|
+
`),displayedLines:t.length,totalLines:e.length,truncated:r}}function re(e,t){if(t&&(typeof e.state!=`string`||!e.state.trim())&&N(`canonical job.state must be a non-empty string`),P(e,`state`,{nonEmpty:!0}),P(e,`name`,{nonEmpty:!0}),P(e,`failedReason`),t&&(typeof e.queue!=`string`||!e.queue.trim())&&N(`canonical job.queue must be a non-empty string`),P(e,`queue`,{nonEmpty:!0}),P(e,`customId`,{nullable:!0}),P(e,`parentId`,{nullable:!0,nonEmpty:!0}),P(e,`groupId`,{nullable:!0}),P(e,`progressMessage`,{nullable:!0}),L(e,`childrenIds`,{nonEmpty:!0}),L(e,`dependsOn`,{nonEmpty:!0}),L(e,`tags`),L(e,`stacktrace`,{nullable:!0}),Array.isArray(e.stacktrace)&&e.stacktrace.length>j&&N(`job.stacktrace exceeds Bunqueue's ${j}-entry limit`),F(e,`priority`,{integer:!0}),F(e,`createdAt`),F(e,`runAt`),F(e,`startedAt`,{nullable:!0}),F(e,`completedAt`,{nullable:!0}),F(e,`attempts`,{integer:!0,min:0}),F(e,`maxAttempts`,{integer:!0,min:0}),F(e,`backoff`,{integer:!0,min:0}),F(e,`timeout`,{nullable:!0,integer:!0,min:0}),F(e,`ttl`,{nullable:!0,integer:!0,min:0}),F(e,`progress`,{min:0,max:100}),F(e,`lastHeartbeat`),F(e,`stallCount`,{integer:!0,min:0}),I(e,`removeOnComplete`),I(e,`removeOnFail`),Object.hasOwn(e,`backoffConfig`)&&e.backoffConfig!==void 0){let t=e.backoffConfig;if(t!==null){(!t||typeof t!=`object`||Array.isArray(t))&&N(`job.backoffConfig must be an object or null`);let e=t;e.type!==`fixed`&&e.type!==`exponential`&&N(`job.backoffConfig.type must be fixed or exponential`),F(e,`delay`,{integer:!0,min:0},`job.backoffConfig`),(!Object.hasOwn(e,`delay`)||e.delay===void 0)&&N(`job.backoffConfig.delay is required`),F(e,`maxDelay`,{integer:!0,min:0},`job.backoffConfig`)}}if(Object.hasOwn(e,`timeline`)&&e.timeline!==void 0){Array.isArray(e.timeline)||N(`job.timeline must be an array`),e.timeline.length>20&&N(`job.timeline exceeds 20 entries`);for(let[t,n]of e.timeline.entries()){(!n||typeof n!=`object`||Array.isArray(n))&&N(`job.timeline[${t}] must be an object`);let e=n;(typeof e.state!=`string`||!e.state.trim())&&N(`job.timeline[${t}].state must be a non-empty string`),(typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp))&&N(`job.timeline[${t}].timestamp must be a finite number`);let r=`job.timeline[${t}]`;P(e,`worker`,{},r),P(e,`error`,{},r),F(e,`attempt`,{integer:!0,min:0},r)}}}function ie(e,{canonical:t,expectedId:n}){if(!e||typeof e!=`object`||Array.isArray(e))return N(`expected an object envelope`);let r=e;if(r.ok!==!0||!Object.hasOwn(r,`job`))return N(`expected { ok: true, job }`);if(r.job===null)return null;if(!r.job||typeof r.job!=`object`||Array.isArray(r.job))return N(`job must be an object or null`);let i=r.job;return typeof i.id!=`string`||!i.id.trim()?N(`job.id must be a non-empty string`):n!==void 0&&i.id!==n?N(`expected job.id ${JSON.stringify(n)}`):(re(i,t),i)}function ae(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw new u(`Invalid job result response: expected an object envelope`,200);let n=e;if(n.ok!==!0||n.id!==t)throw new u(`Invalid job result response: expected { ok: true, id, result? }`,200);return{result:n.result}}var R=3e4;function z(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function B(e,t){return e?.baseUrl===t.baseUrl&&e.authorization===t.authorization}function V(e,t,n){return t.aborted&&!n?.aborted?new u(`Request timed out`,0):e}async function H(e,t,n,r=R){let i=AbortSignal.timeout(r),a=n?AbortSignal.any([n,i]):i,o=new Headers;e.authorization&&o.set(`Authorization`,e.authorization);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{headers:o,signal:a}),a.throwIfAborted()}catch(e){throw V(e,i,n)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw V(e,i,n)}let l,d=!1;if(c)try{l=JSON.parse(c)}catch{d=!0}if(!s.ok){let t=!d&&l&&typeof l==`object`?l.error:void 0,n=typeof t==`string`?t:`HTTP ${s.status}`;throw s.status===401&&typeof window<`u`&&window.dispatchEvent(new window.CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),new u(n,s.status)}if(c){if(d)throw new u(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new u(typeof e==`string`?e:`Operation failed`,s.status)}return l}}async function oe(e,t,n={}){let r=n.target??z(),i=n.timeoutMs??R,a=ie(await H(r,t===`custom`?`/jobs/custom/${l(e,`Custom job ID`)}`:`/jobs/${c(e)}`,n.signal,i),{canonical:t===`id`,expectedId:t===`id`?e:void 0});if(!a||t===`id`)return a;if(a.customId!==e)throw new u(`Invalid job response: expected job.customId ${JSON.stringify(e)}`,200);return ie(await H(r,`/jobs/${c(a.id)}`,n.signal,i),{canonical:!0,expectedId:a.id})}function se(e,t){return async(n,r=e.lookupBy,i=!1,a=void 0,o=!1)=>{let s=n.trim();if(!s||a===void 0&&e.actionBusy.current&&!o)return;e.internalEmptyUrlPending.current=!1,e.preservedEmptyLocationKey.current=null,a===void 0&&(e.actionGen.current+=1),e.job!==null&&(r===`id`?e.job.id!==s:e.job.customId!==s)&&(e.jobTarget.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null)),e.lookupAbort.current?.abort();let l=new AbortController;e.lookupAbort.current=l,e.lookupIdentity.current={key:s,mode:r};let d=++e.lookupGen.current,f=z();e.setLoading(!0),e.setNotFound(!1),i||e.setMsg(null);try{let n=await oe(s,r,{signal:l.signal,target:f});if(!n){if(d!==e.lookupGen.current)return;e.internalEmptyUrlPending.current=!0,e.preservedEmptyLocationKey.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!0),t({},{replace:!0});return}let i=null,a=null;if(d!==e.lookupGen.current||l.signal.aborted||!B(f,z()))return;if(n.state===`completed`)if(Object.hasOwn(n,`returnvalue`))i={result:n.returnvalue};else try{i=ae(await H(f,`/jobs/${c(n.id)}/result`,l.signal),n.id)}catch(e){if(l.signal.aborted)throw e;a=e.message}if(d!==e.lookupGen.current||l.signal.aborted||!B(f,z()))return;e.jobTarget.current=f,e.setJob(n),r===`custom`?(e.setLookupBy(`id`),e.setIdInput(n.id)):e.setIdInput(s),t({id:n.id},{replace:!0}),e.setResult(i?{fetched:!0,value:i.result}:{fetched:!1,value:void 0}),e.setResultError(a)}catch(n){if(d!==e.lookupGen.current||l.signal.aborted)return;n instanceof u&&(n.status===404||/not found/i.test(n.message))?(e.internalEmptyUrlPending.current=!0,e.preservedEmptyLocationKey.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!0),t({},{replace:!0})):i?e.setMsg(e=>e?{ok:e.ok,text:`${e.text} — couldn't reload: ${n.message}`}:{ok:!1,text:n.message}):e.setMsg({ok:!1,text:n.message})}finally{d===e.lookupGen.current&&(e.lookupAbort.current===l&&(e.lookupAbort.current=null,e.lookupIdentity.current=null),e.setLoading(!1))}}}var U=e(n(),1),W=a(),G=365*24*60*60*1e3;function K(e,t){if(!e.trim())return{ok:!1,msg:`A value is required`};let n=Number(e);return Number.isFinite(n)?t===`progress`?n>=0&&n<=100?{ok:!0,value:n}:{ok:!1,msg:`Progress must be between 0 and 100`}:Number.isSafeInteger(n)?t===`priority`?n>=-1e6&&n<=1e6?{ok:!0,value:n}:{ok:!1,msg:`Priority must be between -1000000 and 1000000`}:n>=0&&n<=G?{ok:!0,value:n}:{ok:!1,msg:`Delay must be between 0 and ${G} ms`}:{ok:!1,msg:`Value must be a whole, safe integer`}:{ok:!1,msg:`Value must be a finite number`}}function ce({job:e,busy:t,act:n}){let r=A(e.state),i=r.promote||r.setPriority||r.setDelay||e.state===`active`;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Actions`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,W.jsx)(h,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>d.promoteJob(e.id)),children:`Promote (run now)`}),e.state===`failed`&&(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`DLQ retry is unavailable in Bunqueue v2.9.0: its GET and retry POST have no atomic job-generation, state, or flow-topology precondition.`}),e.state===`completed`&&(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`Completed-job requeue is unavailable in Bunqueue v2.9.0 because retry-completed re-inserts a child without rebuilding its flow dependency registration.`}),e.state===`active`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`Active-job state changes are unavailable: Bunqueue cannot stop the worker that is already processing this job, so retrying, delaying, discarding or failing it here could run side effects twice.`}),(0,W.jsx)(q,{label:`Set progress (0–100)`,cta:`Progress`,kind:`progress`,disabled:t,onSubmit:t=>n(`Progress`,()=>d.setJobProgress(e.id,t))})]}),r.setPriority&&(0,W.jsx)(le,{disabled:t,onSubmit:(t,r)=>n(`Priority`,()=>d.changePriority(e.id,t,r))}),r.setDelay&&(0,W.jsx)(q,{label:`Set delay (ms)`,cta:`Delay`,kind:`delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>d.changeDelay(e.id,t))}),(0,W.jsxs)(`p`,{role:`note`,className:`text-xs text-faint`,children:[`Cancel/delete/discard: `,O]}),!i&&(0,W.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function q({label:e,cta:t,kind:n,disabled:r,onSubmit:i}){let[a,o]=(0,U.useState)(``),s=K(a,n);return(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!r&&s.ok&&i(s.value)},children:[(0,W.jsx)(E,{type:`number`,min:0,max:n===`progress`?100:G,step:n===`progress`?`any`:1,name:n===`progress`?`job-progress`:`job-delay`,value:a,onChange:e=>o(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:r||!s.ok,children:t}),!s.ok&&a.trim()&&(0,W.jsx)(`span`,{role:`alert`,className:`self-center text-[11px] text-danger`,children:s.msg})]})}function le({disabled:e,onSubmit:t}){let[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(!1),o=K(n,`priority`);return(0,W.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault(),!e&&o.ok&&t(o.value,i)},children:[(0,W.jsx)(E,{type:`number`,min:-1e6,max:1e6,step:1,name:`job-priority`,value:n,onChange:e=>r(e.target.value),placeholder:`Set priority`,"aria-label":`Set priority`,className:`h-8 min-w-28 flex-1 text-xs`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(D,{checked:i,onChange:a,label:`Place first among equal priorities`}),(0,W.jsx)(`span`,{className:`text-xs text-muted`,children:`LIFO`})]}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:e||!o.ok,children:`Set`}),!o.ok&&n.trim()&&(0,W.jsx)(`span`,{role:`alert`,className:`w-full text-[11px] text-danger`,children:o.msg})]})}var J=36e5,Y=10,X=e=>Math.max(e,1);function ue(e){return Math.max(0,(e.maxAttempts??0)-X(e.attempts??0))}function de(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??J,a=r?.delay??e.backoff??1e3,o=[];for(let e=X(n);e<t&&o.length<Y;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function fe({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff`}),(0,W.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff schedule`}),(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,a=ue(e),o=de(e);return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff schedule`,action:(0,W.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${S(r.maxDelay)}`:``]})}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,W.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,W.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,S(e.delayMs)]})]},e.attempt))}),a>Y&&(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,Y,` of `,a,` remaining attempts.`]}),(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,S(r?.maxDelay??J),`.`]})]})}function pe({jobId:e}){let[t,n]=(0,U.useState)(!1),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(void 0),[l,u]=(0,U.useState)(null),f=async()=>{o(!0),u(null);try{let t=await d.jobChildren(e);c(t.data?.values),i(!0)}catch(e){u(e.message)}finally{o(!1)}},p=()=>{let e=!t;n(e),e&&!r&&!a&&f()},m=s&&typeof s==`object`?Array.isArray(s)?s.length:Object.keys(s).length:0;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Child values`,action:(0,W.jsx)(h,{size:`sm`,variant:`ghost`,onClick:p,children:t?`Hide`:`Show`})}),t?a?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):l?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:l}):m===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,W.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(s,null,2)}):(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function me({data:e,busy:t,editable:n,readOnlyReason:r,onSave:i}){let[a,o]=(0,U.useState)(()=>JSON.stringify(e??null,null,2)),[s,c]=(0,U.useState)(null),l=(0,U.useRef)(a);return(0,U.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,o(t),c(null))},[e]),(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Data`,action:n?(0,W.jsx)(h,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(a)}catch(e){c(`Invalid JSON: ${e.message}`);return}c(null),i(e)},children:`Save data`}):void 0}),(0,W.jsx)(`textarea`,{"aria-label":`Job data JSON`,name:`job-data-json`,value:a,onChange:e=>o(e.target.value),readOnly:!n,spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),!n&&(0,W.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:r??`Data is read-only after a job starts processing or leaves the runnable queue.`}),s&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:s})]})}function he(e){return e===`waiting`||e===`prioritized`||e===`delayed`}var ge=[`__parentId`,`__parentQueue`,`__childrenIds`,`__flowParentId`,`__flowParentIds`];function _e(e,t){if(!he(e))return`Data is read-only after a job starts processing or leaves the runnable queue.`;let n=t.data,r=typeof n==`object`&&!!n&&!Array.isArray(n)&&ge.some(e=>Object.hasOwn(n,e));return t.parentId||(t.childrenIds?.length??0)>0||r?`Data is read-only for Flow jobs because Bunqueue v2.9.0 replaces the full payload and would remove structural metadata.`:null}var ve=3e4;function Z(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function ye(e,t){return e.baseUrl===t.baseUrl&&e.authorization===t.authorization}function be(e,t,n){return t.aborted&&!n.aborted?new u(`Request timed out`,0):e}async function xe(e,t,n,r){let i=AbortSignal.timeout(ve),a=AbortSignal.any([r,i]),o=new Headers(n.headers);e.authorization&&o.set(`Authorization`,e.authorization),n.body!=null&&!o.has(`Content-Type`)&&o.set(`Content-Type`,`application/json`);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{...n,headers:o,signal:a}),a.throwIfAborted()}catch(e){throw be(e,i,r)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw be(e,i,r)}let l,d=!1;if(c)try{l=JSON.parse(c)}catch{d=!0}if(!s.ok){let t=!d&&l&&typeof l==`object`?l.error:void 0;throw s.status===401&&typeof window<`u`&&window.dispatchEvent(new window.CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),new u(typeof t==`string`?t:`HTTP ${s.status}`,s.status)}if(c){if(d)throw new u(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new u(typeof e==`string`?e:`Operation failed`,s.status)}return l}}function Se(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new u(`Invalid logs response: expected an object envelope`,200);let t=e;if(t.ok!==!0||!t.data||typeof t.data!=`object`)throw new u(`Invalid logs response: expected { ok: true, data }`,200);let n=t.data;if(!Array.isArray(n.logs)||typeof n.count!=`number`||!Number.isSafeInteger(n.count)||n.count<0)throw new u(`Invalid logs response: expected logs[] and a non-negative count`,200);return{logs:n.logs,count:n.count}}function Ce(e){let{logs:t,count:n,loading:r,busy:i,error:a,message:o,level:s,draftRevision:c}=e;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Logs`,action:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:n}),(0,W.jsx)(h,{size:`sm`,variant:`ghost`,disabled:r||i,onClick:e.load,children:`Refresh`}),(0,W.jsx)(h,{size:`sm`,variant:`danger`,disabled:i||t.length===0,onClick:e.clear,children:`Clear logs`})]})}),a&&(0,W.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:a}),t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,W.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,W.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,W.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:t=>{t.preventDefault();let n=t.currentTarget.elements.namedItem(`job-log-message`),r=t.currentTarget.elements.namedItem(`job-log-level`);e.add(n?.value??o,r?.value??s)},children:[(0,W.jsx)(E,{"aria-label":`Log message`,name:`job-log-message`,autoComplete:`off`,value:o,onInput:t=>{c.current+=1,e.setMessage(t.currentTarget.value)},placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,W.jsxs)(T,{"aria-label":`Log level`,name:`job-log-level`,value:s,onChange:t=>{c.current+=1,e.setLevel(t.target.value)},className:`h-8 w-24 text-xs`,children:[(0,W.jsx)(`option`,{value:`info`,children:`info`}),(0,W.jsx)(`option`,{value:`warn`,children:`warn`}),(0,W.jsx)(`option`,{value:`error`,children:`error`})]}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:i||o.trim()===``,children:`Add`})]})]})}function we({jobId:e}){let t=s(e=>e.baseUrl),n=s(e=>e.token),[r,i]=(0,U.useState)([]),[a,l]=(0,U.useState)(0),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(`info`),[y,b]=(0,U.useState)(!1),x=(0,U.useRef)(!1),S=(0,U.useRef)(null),C=(0,U.useRef)(0),w=(0,U.useRef)(null),T=(0,U.useRef)(0),E=(0,U.useRef)(null),D=(0,U.useRef)(!1),O=(0,U.useRef)(0);(0,U.useEffect)(()=>{x.current=!0,S.current=e;let t=()=>{C.current+=1,w.current?.abort(),w.current=null,T.current+=1,E.current?.abort(),E.current=null,D.current=!1,O.current+=1,i([]),l(0),f(!1),m(null),g(``),b(!1)},n=s.subscribe((e,n)=>{e.baseUrl===n.baseUrl&&e.token===n.token||t()});return t(),()=>{x.current=!1,S.current=null,n(),C.current+=1,w.current?.abort(),w.current=null,T.current+=1,E.current?.abort(),E.current=null,D.current=!1}},[e]);let k=(0,U.useCallback)(async r=>{w.current?.abort();let a=new AbortController;w.current=a;let u=++C.current,d=s.getState(),p=r?.target??(d.baseUrl===t&&d.token===n?{baseUrl:o(),authorization:n?`Bearer ${n}`:void 0}:Z()),h=()=>x.current&&S.current===e&&u===C.current&&!a.signal.aborted&&ye(p,Z());f(!0),m(null);try{let t=Se(await xe(p,`/jobs/${c(e)}/logs`,{},a.signal));return h()?(i(t.logs),l(t.count),!0):!1}catch(e){if(!h())return!1;let t=e instanceof Error?e.message:String(e);return m(r?.acceptedLabel?`${r.acceptedLabel} succeeded, but couldn't reload logs: ${t}`:t),!1}finally{u===C.current&&(w.current===a&&(w.current=null),x.current&&f(!1))}},[e,t,n]);(0,U.useEffect)(()=>{k()},[k]);let A=async(t,n,r)=>{if(D.current)return;D.current=!0;let i=new AbortController;E.current=i;let a=++T.current,o=Z();C.current+=1,w.current?.abort(),w.current=null,f(!1),b(!0),m(null);let s=()=>x.current&&S.current===e&&a===T.current&&!i.signal.aborted&&ye(o,Z());try{let a=await xe(o,`/jobs/${c(e)}/logs`,t,i.signal);if(!a||typeof a!=`object`||Array.isArray(a)||a.ok!==!0)throw new u(`Invalid log mutation response: expected { ok: true }`,200);if(!s())return;r(),await k({acceptedLabel:n,target:o})}catch(e){s()&&m(e instanceof Error?e.message:String(e))}finally{a===T.current&&(D.current=!1,E.current===i&&(E.current=null),x.current&&b(!1))}},j=async(e=h,t=_)=>{if(D.current)return;let n=e.trim();if(!n)return;let r=t===`warn`||t===`error`?t:`info`,i=O.current;g(e),v(r),await A({method:`POST`,body:JSON.stringify({message:n,level:r})},`Log addition`,()=>{O.current===i&&g(``)})},M=async()=>{D.current||window.confirm(`Clear all logs for this job?`)&&await A({method:`DELETE`},`Log clearing`,()=>{i([]),l(0)})};return(0,W.jsx)(Ce,{logs:r,count:a,loading:d,busy:y,error:p,message:h,level:_,draftRevision:O,setMessage:g,setLevel:v,load:()=>void k(),clear:()=>void M(),add:(e,t)=>void j(e,t)})}function Te({timeline:e}){let t=e??[];return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Timeline`}),t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,W.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,W.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(b,{status:e.state}),e.attempt!=null&&(0,W.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,W.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:C(e.timestamp)})]}),(e.worker||e.error)&&(0,W.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,W.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,W.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function Ee(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return e.failedReason?{message:e.failedReason}:null}function De({job:e,result:t,resultError:n,loading:r,notFound:i,busy:a,lookup:o,act:s}){if(r&&!e)return(0,W.jsx)(v,{label:`Loading job…`});if(i)return(0,W.jsx)(y,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`});if(!e)return(0,W.jsx)(y,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`});let c=e.state,l=Ee(e),u=e.stacktrace?.length?ne(e.stacktrace):null,f=(e.childrenIds?.length??0)>0,p=_e(c,e),m=c===`failed`,h=l||u?(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Error`}),l&&(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`p`,{className:`text-sm text-danger`,children:l.message}),(0,W.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[l.attempt==null?``:`Attempt ${l.attempt} · `,C(l.timestamp)]})]}),u&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:u.text}),u.truncated&&(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-faint`,children:[`Stack preview truncated (`,u.displayedLines,` of `,u.totalLines,` `,`lines, 262,144 characters maximum). Download JSON for the complete stored stack.`]})]})]}):null;return(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,W.jsx)(Oe,{job:e}),m&&h,(0,W.jsx)(me,{data:e.data,busy:a,editable:p===null,readOnlyReason:p??void 0,onSave:t=>s(`Data`,()=>d.updateJobData(e.id,t))},`data-${e.id}`),c===`completed`&&(0,W.jsx)(ke,{jobId:e.id,result:t,resultError:n,loading:r,onRetry:()=>o(e.id,`id`)}),!m&&h,(0,W.jsx)(we,{jobId:e.id},`logs-${e.id}`),f&&(0,W.jsx)(pe,{jobId:e.id},`children-${e.id}`),(0,W.jsx)(Te,{timeline:e.timeline}),(0,W.jsx)(fe,{job:e})]}),(0,W.jsx)(`div`,{className:`order-first lg:order-none`,children:(0,W.jsx)(ce,{job:e,busy:a,act:s})})]})}function Oe({job:e}){return(0,W.jsxs)(_,{children:[(0,W.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:e.id}),(0,W.jsx)(w,{value:e.id})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:e.queue})]}),(0,W.jsx)(b,{status:e.state??`unknown`})]}),(0,W.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,W.jsx)(Q,{label:`Priority`,value:String(e.priority??0)}),(0,W.jsx)(Q,{label:`Name`,value:e.name??`default`}),(0,W.jsx)(Q,{label:`Attempts`,value:`${e.attempts??0} / ${e.maxAttempts??`?`}`}),(0,W.jsx)(Q,{label:`Progress`,value:`${e.progress??0}%`}),(0,W.jsx)(Q,{label:`Created`,value:C(e.createdAt)}),(0,W.jsx)(Q,{label:`Started`,value:C(e.startedAt??void 0)}),(0,W.jsx)(Q,{label:`Completed`,value:C(e.completedAt??void 0)}),(0,W.jsx)(Q,{label:`Duration`,value:S(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,W.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,W.jsx)(`span`,{className:`truncate font-mono`,children:e.customId??`—`}),e.customId&&(0,W.jsx)(w,{value:e.customId})]})]})]})]})}function ke({jobId:e,result:t,resultError:n,loading:r,onRetry:i}){let a=t.fetched&&t.value!==void 0&&t.value!==null;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Result`,action:a?(0,W.jsx)(je,{value:t.value,filename:`job-${e}-result`}):void 0}),a?(0,W.jsx)(Ae,{value:t.value}):n?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,W.jsxs)(`p`,{className:`text-xs text-danger`,children:[`Couldn't load result — `,n]}),(0,W.jsx)(h,{size:`sm`,disabled:r,onClick:i,children:`Retry`})]}):(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]})}function Q({label:e,value:t}){return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`text-fg`,children:t})]})}function Ae({value:e}){return(0,W.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(e??null,null,2)})}function je({value:e,filename:t}){return(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(w,{value:JSON.stringify(e??null,null,2)}),(0,W.jsx)(m,{"aria-label":`Download JSON`,title:`Download JSON`,onClick:()=>k(t,e??null),children:(0,W.jsx)(p,{className:`size-3.5`})})]})}function Me(e){let t={};return typeof e.priority==`number`&&(t.priority=e.priority),typeof e.maxAttempts==`number`&&(t.maxAttempts=e.maxAttempts),typeof e.backoff==`number`&&(t.backoff=e.backoff),e.backoffConfig&&typeof e.backoffConfig.delay==`number`&&(t.backoffConfig={type:e.backoffConfig.type,delay:e.backoffConfig.delay},typeof t.backoff!=`number`&&(t.backoff=e.backoffConfig.delay)),typeof e.timeout==`number`&&(t.timeout=e.timeout),typeof e.removeOnComplete==`boolean`&&(t.removeOnComplete=e.removeOnComplete),typeof e.removeOnFail==`boolean`&&(t.removeOnFail=e.removeOnFail),typeof e.ttl==`number`&&(t.ttl=e.ttl),Array.isArray(e.tags)&&e.tags.length&&(t.tags=[...e.tags]),typeof e.groupId==`string`&&e.groupId&&(t.groupId=e.groupId),{clone:{queue:e.queue??``,name:e.name,dataText:JSON.stringify(e.data??{},null,2),options:t}}}function Ne({job:e,result:t,idInput:n,lookupBy:r,loading:a,busy:o,onInputChange:s,onModeChange:c,onSubmit:l}){let u=!!(e&&((e.childrenIds?.length??0)>0||e.parentId));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(x,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:e?(0,W.jsxs)(W.Fragment,{children:[u&&(0,W.jsx)(i,{to:`/flows?root=${encodeURIComponent(e.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}),(0,W.jsx)(i,{to:`/add-job`,state:Me(e),title:`Enqueue a new job pre-filled from this one`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Clone`}),(0,W.jsxs)(h,{size:`sm`,onClick:()=>k(`job-${e.id}`,t.fetched?{...e,result:t.value}:e),children:[(0,W.jsx)(p,{className:`size-3.5`}),` Download JSON`]})]}):void 0}),(0,W.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(T,{name:`job-lookup-mode`,autoComplete:`off`,value:r,"aria-label":`Lookup mode`,onChange:e=>c(e.target.value),className:`w-40`,children:[(0,W.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,W.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,W.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,W.jsx)(f,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,W.jsx)(`input`,{value:n,"aria-label":r===`custom`?`Custom job ID`:`Job ID`,name:`job-lookup-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,onInput:e=>s(e.currentTarget.value),onKeyDown:e=>e.key===`Enter`&&l(n),placeholder:r===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,W.jsx)(h,{variant:`accent`,disabled:a||o,onClick:()=>l(n),children:`Look up`})]})]})}function Pe({state:e,lookup:t,setParams:n,locationKey:r,idParam:i,customParam:a,jobBelongsToCurrentTarget:o,connectionBaseUrl:s,connectionToken:c}){(0,U.useEffect)(()=>{if(e.internalEmptyUrlPending.current){!i&&!a&&(e.internalEmptyUrlPending.current=!1,e.preservedEmptyLocationKey.current=r);return}if(!(!i&&!a&&e.preservedEmptyLocationKey.current===r))if(e.preservedEmptyLocationKey.current=null,a)if(e.job?.customId===a&&o)e.setLookupBy(`id`),e.setIdInput(e.job.id),n({id:e.job.id},{replace:!0});else{e.setLookupBy(`custom`),e.setIdInput(a);let n=e.lookupIdentity.current;(n?.mode!==`custom`||n.key!==a)&&t(a,`custom`,!1,void 0,!0)}else if(i&&(i!==e.job?.id||!o)){e.setLookupBy(`id`),e.setIdInput(i);let n=e.lookupIdentity.current;(n?.mode!==`id`||n.key!==i)&&t(i,`id`,!1,void 0,!0)}else!i&&!a&&(e.lookupGen.current+=1,e.lookupAbort.current?.abort(),e.lookupAbort.current=null,e.lookupIdentity.current=null,e.actionGen.current+=1,e.jobTarget.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!1),e.setMsg(null),e.setLoading(!1),e.setLookupBy(`id`),e.setIdInput(``))},[i,a,e.job?.id,e.job?.customId,o,r,s,c])}var $={fetched:!1,value:void 0};function Fe(e,t){let[n,r]=(0,U.useState)(e??t??``),[i,a]=(0,U.useState)(e?`custom`:`id`),[o,c]=(0,U.useState)(null),[l,u]=(0,U.useState)($),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null),[y,b]=(0,U.useState)(!1),x=(0,U.useRef)(0),S=(0,U.useRef)(null),C=(0,U.useRef)(null),w=(0,U.useRef)(null),T=(0,U.useRef)(!1),E=(0,U.useRef)(null),D=(0,U.useRef)(!1),O=(0,U.useRef)(0),k=(0,U.useRef)(!1),A=(0,U.useRef)(null);return(0,U.useEffect)(()=>{D.current=!0;let e=s.subscribe((e,t)=>{e.baseUrl===t.baseUrl&&e.token===t.token||(x.current+=1,S.current?.abort(),S.current=null,C.current=null,O.current+=1,A.current=null,k.current=!1,w.current=null,T.current=!1,E.current=null,c(null),u($),f(null),g(!1),v(null),m(!1),b(!1))});return()=>{D.current=!1,e(),x.current+=1,S.current?.abort(),S.current=null,C.current=null,O.current+=1,A.current=null,k.current=!1}},[]),{idInput:n,setIdInput:r,lookupBy:i,setLookupBy:a,job:o,setJob:c,result:l,setResult:u,resultError:d,setResultError:f,loading:p,setLoading:m,notFound:h,setNotFound:g,msg:_,setMsg:v,busy:y,setBusy:b,lookupGen:x,lookupAbort:S,lookupIdentity:C,jobTarget:w,internalEmptyUrlPending:T,preservedEmptyLocationKey:E,mounted:D,actionGen:O,actionBusy:k,actionLockOwner:A}}function Ie(){let e=r(),[n,i]=t(),a=s(e=>e.baseUrl),c=s(e=>e.token),l=Fe(n.get(`custom`),n.get(`id`)),d=se(l,i),f=n.get(`id`),p=n.get(`custom`),m={baseUrl:o(),authorization:c?`Bearer ${c}`:void 0},h=B(l.jobTarget.current,m);return Pe({state:l,lookup:d,setParams:i,locationKey:e.key,idParam:f,customParam:p,jobBelongsToCurrentTarget:h,connectionBaseUrl:a,connectionToken:c}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ne,{job:l.job,result:l.result,idInput:l.idInput,lookupBy:l.lookupBy,loading:l.loading,busy:l.busy,onInputChange:l.setIdInput,onModeChange:l.setLookupBy,onSubmit:(e,t=l.lookupBy)=>{let n=e.trim();if(!(!n||l.actionBusy.current)){if(t===`id`?f===n&&p===null:p===n&&f===null){d(n,t);return}i(t===`custom`?{custom:n}:{id:n})}}}),l.msg&&(0,W.jsx)(`div`,{role:`status`,className:l.msg.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:l.msg.text}),(0,W.jsx)(De,{job:l.job,result:l.result,resultError:l.resultError,loading:l.loading,notFound:l.notFound,busy:l.busy,lookup:d,act:async(e,t,n)=>{if(!l.job||l.actionBusy.current||l.lookupAbort.current)return;let r=z();if(!B(l.jobTarget.current,r)||n&&!window.confirm(n))return;let a=++l.actionGen.current,o=l.job.id;l.actionLockOwner.current=a,l.actionBusy.current=!0,l.setBusy(!0),l.setMsg(null);let s=()=>l.mounted.current&&a===l.actionGen.current&&B(r,z())&&B(l.jobTarget.current,r);try{let n=await t();if(!n||typeof n!=`object`||Array.isArray(n)||n.ok!==!0)throw new u(`Invalid job mutation response: expected { ok: true }`,200);if(!s())return;l.setMsg({ok:!0,text:`${e} ✓`}),e===`Cancel`?(l.internalEmptyUrlPending.current=!0,l.preservedEmptyLocationKey.current=null,l.lookupGen.current+=1,l.jobTarget.current=null,l.setJob(null),l.setResult({fetched:!1,value:void 0}),l.setResultError(null),i({},{replace:!0})):await d(o,`id`,!0,a)}catch(e){s()&&l.setMsg({ok:!1,text:e.message})}finally{l.actionLockOwner.current===a&&(l.actionLockOwner.current=null,l.actionBusy.current=!1,l.mounted.current&&l.setBusy(!1))}}})]})}export{Ie as JobInspector};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,r,t as i}from"./react-vendor-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-BOfwNIlJ.js";import{T as o}from"./icons-BVzwsfbG.js";import{t as s}from"./api-81m1TwB7.js";import{n as c}from"./usePolledData-CNtNtd0a.js";import{i as l,r as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./StatusBadge-BoOVTnKu.js";import{t as f}from"./PageHeader-CvIyaFOO.js";import{a as p,c as m,d as h,l as g,s as _,t as v}from"./format-Cg7VCIZW.js";import{n as y}from"./index-TploGF7u.js";import{a as b,i as x}from"./form-C4oby9pI.js";import{r as S}from"./flowMutationSafety-6cP-l4Pa.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";var w=e(n(),1),T=`__all__`,E=[`all`,`waiting`,`active`,`completed`,`failed`],D=500,O=20,k=D*O;function A(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>k||n!==null&&e.total!==n||e.offset!==t||e.limit!==D||e.queues.length!==Math.min(D,e.total-t)||e.queues.length>D||e.queues.some(e=>typeof e!=`object`||!e||typeof e.name!=`string`||e.name.length===0||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)))throw Error(`Queue discovery returned a malformed or unsafe page`)}async function j(){let e=await s.queues(D,0);A(e,0,null);let t=[...e.queues],n=new Set;for(let e of t){if(n.has(e.name))throw Error(`Queue discovery returned duplicate queue ${e.name}`);n.add(e.name)}let r=e.total,i=1;for(;t.length<r;){if(i>=O||t.length>=k)throw Error(`Queue discovery exceeds the safety limit of ${k}`);let e=t.length,a=await s.queues(D,e);A(a,e,r);for(let e of a.queues){if(n.has(e.name))throw Error(`Queue discovery pages overlap at queue ${e.name}`);n.add(e.name),t.push(e)}i+=1}return{...e,queues:t,total:r,limit:t.length,offset:0}}function M(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}var N=i();function P({rows:e,emptyMessage:t}){return(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,N.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,N.jsx)(`tbody`,{children:e.length===0?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:t})}):e.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,N.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`text-accent/90 hover:text-accent hover:underline`,title:`Inspect job ${e.id}`,children:e.id})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??M(e.data)??`default`}),(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,N.jsx)(`td`,{className:`px-5 py-3`,children:(0,N.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(h(e.startedAt??void 0,e.completedAt??void 0))}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,N.jsx)(`span`,{className:`text-xs text-faint`,title:S,children:`Delete unavailable`})})]},`${e.queue}:${e.id}`))})]})})}var F=8;function I(){let[e]=t(),[n,r]=(0,w.useState)(e.get(`queue`)??`__all__`),[i,d]=(0,w.useState)(`all`),[p,h]=(0,w.useState)(``),{data:g,error:S,refetch:D}=c(j,[],{intervalMs:3e4}),{data:O,error:k,refetch:A}=c(()=>s.overview(),[]),I=(0,w.useMemo)(()=>(g?.queues??[]).map(e=>e.name),[g]),L=`${n}\u0000${i}\u0000${JSON.stringify(I)}`,{data:R,error:z,loading:B,refetch:V}=c((0,w.useCallback)(async e=>{if(n===`__all__`&&!g)return null;let t=n===`__all__`?I:[n];if(n===`__all__`&&t.length>100)return{scopeKey:L,jobs:[],failures:[],queueCount:t.length,blockedReason:`All-queue job browsing is limited to 100 queues; ${_(t.length)} were discovered. Select one queue to avoid an unsafe request fan-out.`};let r=i===`all`?void 0:[i],o=a.createServerTargetClient(a.captureServerRequestTarget(),e),s=await C(t,F,async t=>(e.throwIfAborted(),(await o.jobsList(t,r,40)).jobs.map(e=>({...e,stacktrace:e.stacktrace??void 0,queue:e.queue??t}))),e);e.throwIfAborted();let c=[],l=[];return s.forEach((e,n)=>{e.status===`fulfilled`?c.push(...e.value):l.push({queue:t[n],message:e.reason instanceof Error?e.reason.message:String(e.reason)})}),{scopeKey:L,jobs:c.sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)),failures:l,queueCount:t.length,blockedReason:null}},[n,i,g,I,L]),[L],{intervalMs:15e3}),H=R?.scopeKey===L?R:null,U=H?.blockedReason?null:H?.jobs??null,{rows:W,matchingCount:G}=(0,w.useMemo)(()=>{let e=U??[],t=p.trim().toLowerCase(),n=t?e.filter(e=>typeof e.id==`string`&&e.id.toLowerCase().includes(t)||(M(e.data)?.toLowerCase().includes(t)??!1)):e;return{rows:n.slice(0,100),matchingCount:n.length}},[U,p]),K=O?.stats,q=K?v(K.totalCompleted,K.totalFailed):null,J=e=>K?_(e):`—`,Y=!!H&&H.queueCount>0&&H.failures.length===H.queueCount,X=n===`__all__`&&!g&&!S||B&&!H&&!z,Z=`No jobs found.`;return H?.blockedReason?Z=H.blockedReason:n===`__all__`&&S&&!g?Z=`Queue discovery unavailable — ${S.message}`:z&&!H?Z=`Could not load jobs — ${z.message}`:Y?Z=`Could not load jobs from any of the ${H.queueCount} queues.`:p.trim()&&H?.failures.length?Z=`No matching jobs in the queue results that could be loaded.`:p.trim()&&(Z=`No jobs match this search.`),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!H&&!S&&!k&&!z&&!H.blockedReason&&H.failures.length===0}),S&&(0,N.jsx)(l,{message:`Queue discovery unavailable — ${S.message}`,onRetry:D}),k&&(0,N.jsx)(l,{message:`Job totals unavailable — ${k.message}`,onRetry:A}),z&&(0,N.jsx)(l,{message:`Could not load jobs — ${z.message}`,onRetry:V}),H?.blockedReason&&(0,N.jsx)(l,{message:H.blockedReason}),!!H?.failures.length&&(0,N.jsx)(l,{message:`Could not load jobs from ${H.failures.length} of ${H.queueCount} queues: ${H.failures.slice(0,3).map(e=>`${e.queue} (${e.message})`).join(`, `)}${H.failures.length>3?`, …`:``}`,onRetry:V}),(0,N.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,N.jsx)(y,{label:`Total`,value:K?_(K.totalCompleted+K.totalFailed+K.waiting+K.active):`—`,compact:!0}),(0,N.jsx)(y,{label:`Waiting`,value:J(K?.waiting),tone:`amber`,compact:!0}),(0,N.jsx)(y,{label:`Active`,value:J(K?.active),tone:`blue`,compact:!0}),(0,N.jsx)(y,{label:`Completed`,value:J(K?.totalCompleted),tone:`green`,compact:!0}),(0,N.jsx)(y,{label:`Failed`,value:J(K?.totalFailed),tone:K?.totalFailed?`red`:`default`,compact:!0}),(0,N.jsx)(y,{label:`Error Rate`,value:q==null?`—`:m(q),tone:q==null?`default`:q>.05?`red`:`green`,compact:!0})]}),(0,N.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(`div`,{className:`w-48`,children:(0,N.jsxs)(b,{value:n,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>r(e.target.value),children:[(0,N.jsx)(`option`,{value:T,children:`All Queues`}),(g?.queues??[]).map(e=>(0,N.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,N.jsx)(x,{options:E,value:i,onChange:d}),(0,N.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,N.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,N.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),"aria-label":`Search jobs`,name:`jobs-search`,autoComplete:`off`,placeholder:`Search by ID or name…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),H&&!H.blockedReason&&(0,N.jsxs)(`p`,{role:`status`,className:`mb-3 text-xs text-faint`,children:[n===`__all__`?`Queried all ${_(H.queueCount)} discovered queues`:`Queried ${n}`,` `,`· up to `,40,` recent jobs per queue`,G>100?` · showing the newest 100 of ${_(G)} matches`:``]}),X?(0,N.jsx)(u,{label:`Loading jobs…`}):(0,N.jsx)(P,{rows:W,emptyMessage:Z})]})}export{I as Jobs,j as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{t as o}from"./bq-DYmbVkgR.js";import{t as s}from"./toastStore-B7n0zS0y.js";import{T as c,d as l,f as u,x as d}from"./icons-CIvFfU2b.js";import{n as f}from"./usePolledData-c53tx1jw.js";import{n as p,t as m}from"./Button-BPqpRZJD.js";import{i as h,n as g,r as _}from"./feedback-BnGE2oW2.js";import{t as v}from"./StatusBadge-B0I7hNBX.js";import{t as y}from"./PageHeader-BXlZSBcc.js";import{a as b,c as x,i as S,s as C,t as ee}from"./format-Cg7VCIZW.js";import{n as w}from"./index-D64v2vNO.js";import{a as T}from"./form-tC20r4Ma.js";import{t as E}from"./Pagination-Q-vf4hsX.js";import{r as D,t as O}from"./useServerActionGuard-OTv6_fU0.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as k}from"./jobActions-LQD4KfCc.js";var A=e(r(),1),j=a();function ne(e){return(0,j.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,j.jsx)(w,{label:`Total`,value:e.total,hint:`all queues`,compact:!0}),(0,j.jsx)(w,{label:`Waiting`,value:e.waiting,tone:`amber`,hint:`standard priority`,compact:!0}),(0,j.jsx)(w,{label:`Prioritized`,value:e.prioritized,tone:`amber`,compact:!0}),(0,j.jsx)(w,{label:`Active`,value:e.active,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Flow-blocked`,value:e.flowBlocked,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Completed`,value:e.completed,tone:`green`,compact:!0}),(0,j.jsx)(w,{label:`Failed`,value:e.failed,tone:e.failedCount!=null&&e.failedCount>0?`red`:`default`,compact:!0}),(0,j.jsx)(w,{label:`Error Rate`,value:e.errorRate,tone:e.errorRateTone,compact:!0})]})}var M=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`];function N(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function P(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function F(e=0){return e>=10?{text:`HIGH`,className:`text-warning`}:e>=1?{text:`MEDIUM`,className:`text-blue-400`}:{text:`LOW`,className:`text-faint`}}function re({queue:e,rows:n,search:r,discoveryError:a,selected:s,allSelected:c,bulkBusy:l,busyIds:f,page:m,hasNext:h,onToggleAll:g,onToggle:_,onRun:y,onPage:x}){return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,j.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:e})]}),(0,j.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:c,ref:e=>{e&&(e.indeterminate=s.size>0&&!c)},"aria-checked":s.size>0&&!c?`mixed`:c,onChange:g,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,j.jsx)(`tbody`,{children:n.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:r.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:a?`Queue discovery failed. Retry above.`:`Select a queue.`})}):n.map(e=>{let n=F(e.priority),r=k(e.state),a=l||f.has(e.id);return(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:s.has(e.id),onChange:()=>_(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,j.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(v,{status:String(e.state??`waiting`)})}),(0,j.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.className),children:n.text}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:S(e.createdAt)}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,j.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect job ${e.id}`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,j.jsx)(u,{className:`size-3.5`})}),r.promote&&(0,j.jsx)(p,{"aria-label":`Promote job`,disabled:a,onClick:()=>y(e,`Promote`,()=>o.promoteJob(e.id)),children:(0,j.jsx)(d,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,j.jsx)(E,{page:m,pageSize:25,hasNext:h,onPageChange:x,label:`jobs`})]})}function I({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:s,onQueue:l,onStatus:u,onSearch:d,onPromote:f}){return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{value:e,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:t.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{"aria-label":`Job state`,name:`jobs-state`,value:n,onChange:e=>u(e.target.value),children:M.map(e=>(0,j.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,j.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,j.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,j.jsx)(`input`,{value:r,onChange:e=>d(e.target.value),placeholder:`Filter this page by ID or name…`,"aria-label":`Filter by job ID or name`,name:`jobs-id-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),i>0&&(0,j.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`mr-1 text-muted`,children:N(a,i)}),o?(0,j.jsx)(m,{size:`sm`,disabled:s,onClick:f,children:`Promote selected`}):(0,j.jsx)(`span`,{className:`text-xs text-faint`,children:a===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]})]})}function ie({queue:e,rows:t,selected:n,setSelected:r,refetch:i}){let[a,o]=(0,A.useState)(new Set),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(null),f=D(`jobs:${e}`);return(0,A.useEffect)(()=>{o(new Set),l(!1),d(null)},[f.scopeKey]),{actionMsg:u,bulkBusy:c,busyIds:a,runBulk:async(e,a,o,c)=>{let u=t.filter(e=>n.has(e.id)&&o(e));if(u.length===0||c&&!window.confirm(c(u.length)))return;let p=f.begin([`bulk`,...u.map(e=>`job:${e.id}`)]);if(p){l(!0),d(null);try{let t=await Promise.allSettled(u.map(async t=>{O(await a(t),`${e} ${t.id}`)}));if(!p.isCurrent())return;let n=t.filter(e=>e.status===`fulfilled`).length,o=t.length-n,c=`${e}: ${n} succeeded${o?`, ${o} failed`:``}`;d({ok:o===0,text:c}),o===0?s.success(c):s.error(c),r(e=>P(e,u.map(e=>e.id))),i()}finally{p.finish()&&l(!1)}}},runOne:async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let a=f.begin(`job:${e.id}`);if(a){o(t=>new Set(t).add(e.id)),d(null);try{if(O(await n(),t),!a.isCurrent())return;d({ok:!0,text:`${t} ✓`}),s.success(`${t} ✓`,e.id),i()}catch(e){if(!a.isCurrent())return;d({ok:!1,text:`${t} failed: ${e.message}`}),s.error(`${t} failed`,e.message)}finally{a.finish()&&o(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function L(){let[e,t]=n(),[r,i]=(0,A.useState)(e.get(`queue`)??``),[a,c]=(0,A.useState)(()=>{let t=e.get(`status`);return t&&M.includes(t)?t:`all`}),[u,d]=(0,A.useState)(``),[p,v]=(0,A.useState)(0),[b,S]=(0,A.useState)(new Set),{data:w,error:T,loading:E,refetch:D}=f(()=>o.queuesSummary(),[],{intervalMs:3e4}),{data:O,error:N,refetch:P}=f(()=>o.stats(),[],{intervalMs:1e4});(0,A.useEffect)(()=>{!r&&w?.length&&i(w[0].name)},[w,r]);let F=`${r}|${a}|${p}`,{data:L,error:R,loading:z,refetch:B}=f((0,A.useCallback)(async()=>{if(!r)return{view:F,jobs:[]};let e=a===`all`?void 0:[a],t=await o.jobsList(r,e,25,p*25);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,a,p,F]),[r,a,p]),V=L&&L.view===F?L.jobs:null,ae=(V?.length??0)===25,H=(0,A.useMemo)(()=>{let e=u.trim().toLowerCase();return e?(V??[]).filter(t=>t.id.toLowerCase().includes(e)||t.name?.toLowerCase().includes(e)):V??[]},[V,u]),U=O?.stats,W=(0,A.useMemo)(()=>w?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[w]),G=U&&W!=null?ee(U.completed,W):null,K=e=>U?C(e):`—`,q=()=>v(0),J=(e,n)=>{let r={};e&&(r.queue=e),n!==`all`&&(r.status=n),t(r,{replace:!0})};(0,A.useEffect)(()=>{S(new Set)},[r,a,p]);let oe=e=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=H.length>0&&H.every(e=>b.has(e.id)),se=()=>S(()=>Y?new Set:new Set(H.map(e=>e.id))),{actionMsg:X,bulkBusy:Z,busyIds:ce,runBulk:le,runOne:ue}=ie({queue:r,rows:H,selected:b,setSelected:S,refetch:B}),Q={promote:e=>k(e.state).promote},$=H.filter(e=>b.has(e.id)),de={promote:$.some(Q.promote)};return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(y,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!r&&V!=null&&!R&&!T&&!N,actions:(0,j.jsxs)(m,{size:`sm`,disabled:!V||H.length===0,onClick:()=>{if(H.length===0){s.info(`No jobs to export on this page`);return}let e=H.map(e=>({id:e.id,name:e.name??`default`,queue:e.queue??r,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));te(`jobs-${r}-${a}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,j.jsx)(l,{className:`size-3.5`}),` Export CSV`]})}),T&&(0,j.jsx)(h,{onRetry:D,message:w?`Queue inventory refresh failed — showing the last successful queue totals. ${T.message}`:`Could not discover queues — ${T.message}. Select an existing queue from the URL or retry.`}),N&&(0,j.jsx)(h,{onRetry:P,message:O?`Server-wide totals refresh failed — showing the last successful totals. ${N.message}`:`Server-wide job totals are unavailable — ${N.message}. The selected queue page may still be current.`}),(0,j.jsx)(ne,{total:U&&W!=null?C(U.completed+W+U.waiting+U.prioritized+U.active+U.delayed+U[`waiting-children`]):`—`,waiting:K(U?.waiting),prioritized:K(U?.prioritized),active:K(U?.active),flowBlocked:K(U?.[`waiting-children`]),completed:K(U?.completed),failed:W==null?`—`:C(W),failedCount:W,errorRate:G==null?`—`:x(G),errorRateTone:G==null?`default`:G>.05?`red`:`green`}),(0,j.jsx)(I,{queue:r,summary:w??[],status:a,search:u,selectedTotal:b.size,selectedVisible:$.length,canPromote:de.promote,bulkBusy:Z,onQueue:e=>{i(e),q(),J(e,a)},onStatus:e=>{c(e),q(),J(r,e)},onSearch:d,onPromote:()=>le(`Promote`,e=>o.promoteJob(e.id),Q.promote)}),X&&(0,j.jsx)(`div`,{role:`status`,className:`mb-3 text-sm ${X.ok?`text-success`:`text-danger`}`,children:X.text}),R&&V&&(0,j.jsx)(h,{message:`Job refresh failed — showing the last successful page.`,onRetry:B}),R&&!V?(0,j.jsx)(g,{error:R,onRetry:B}):E&&!w&&!r&&!T?(0,j.jsx)(_,{label:`Discovering queues…`}):z&&!V?(0,j.jsx)(_,{label:`Loading jobs…`}):(0,j.jsx)(re,{queue:r,rows:H,search:u,discoveryError:!!T,selected:b,allSelected:Y,bulkBusy:Z,busyIds:ce,page:p,hasNext:ae,onToggleAll:se,onToggle:oe,onRun:(e,t,n)=>void ue(e,t,n),onPage:v})]})}export{L as JobsPro};
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{t as o}from"./bq-BOfwNIlJ.js";import{t as s}from"./toastStore-B31o6Z5J.js";import{T as c,d as l,f as u,x as d}from"./icons-BVzwsfbG.js";import{n as f}from"./usePolledData-CNtNtd0a.js";import{n as p,t as m}from"./Button-Ch1W94fJ.js";import{i as h,n as g,r as _}from"./feedback-QDN1AsYt.js";import{t as v}from"./StatusBadge-BoOVTnKu.js";import{t as y}from"./PageHeader-CvIyaFOO.js";import{a as b,c as x,i as S,s as C,t as ee}from"./format-Cg7VCIZW.js";import{n as w}from"./index-TploGF7u.js";import{a as T}from"./form-C4oby9pI.js";import{t as E}from"./Pagination-x-Cwgrul.js";import{r as D,t as O}from"./useServerActionGuard-Db7PPgaI.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as k}from"./jobActions-LQD4KfCc.js";var A=e(r(),1),j=a();function ne(e){return(0,j.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,j.jsx)(w,{label:`Total`,value:e.total,hint:`all queues`,compact:!0}),(0,j.jsx)(w,{label:`Waiting`,value:e.waiting,tone:`amber`,hint:`standard priority`,compact:!0}),(0,j.jsx)(w,{label:`Prioritized`,value:e.prioritized,tone:`amber`,compact:!0}),(0,j.jsx)(w,{label:`Active`,value:e.active,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Flow-blocked`,value:e.flowBlocked,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Completed`,value:e.completed,tone:`green`,compact:!0}),(0,j.jsx)(w,{label:`Failed`,value:e.failed,tone:e.failedCount!=null&&e.failedCount>0?`red`:`default`,compact:!0}),(0,j.jsx)(w,{label:`Error Rate`,value:e.errorRate,tone:e.errorRateTone,compact:!0})]})}var M=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`];function N(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function P(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function F(e=0){return e>=10?{text:`HIGH`,className:`text-warning`}:e>=1?{text:`MEDIUM`,className:`text-blue-400`}:{text:`LOW`,className:`text-faint`}}function re({queue:e,rows:n,search:r,discoveryError:a,selected:s,allSelected:c,bulkBusy:l,busyIds:f,page:m,hasNext:h,onToggleAll:g,onToggle:_,onRun:y,onPage:x}){return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,j.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:e})]}),(0,j.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:c,ref:e=>{e&&(e.indeterminate=s.size>0&&!c)},"aria-checked":s.size>0&&!c?`mixed`:c,onChange:g,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,j.jsx)(`tbody`,{children:n.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:r.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:a?`Queue discovery failed. Retry above.`:`Select a queue.`})}):n.map(e=>{let n=F(e.priority),r=k(e.state),a=l||f.has(e.id);return(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:s.has(e.id),onChange:()=>_(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,j.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(v,{status:String(e.state??`waiting`)})}),(0,j.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.className),children:n.text}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:S(e.createdAt)}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,j.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect job ${e.id}`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,j.jsx)(u,{className:`size-3.5`})}),r.promote&&(0,j.jsx)(p,{"aria-label":`Promote job`,disabled:a,onClick:()=>y(e,`Promote`,()=>o.promoteJob(e.id)),children:(0,j.jsx)(d,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,j.jsx)(E,{page:m,pageSize:25,hasNext:h,onPageChange:x,label:`jobs`})]})}function I({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:s,onQueue:l,onStatus:u,onSearch:d,onPromote:f}){return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{value:e,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:t.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{"aria-label":`Job state`,name:`jobs-state`,value:n,onChange:e=>u(e.target.value),children:M.map(e=>(0,j.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,j.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,j.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,j.jsx)(`input`,{value:r,onChange:e=>d(e.target.value),placeholder:`Filter this page by ID or name…`,"aria-label":`Filter by job ID or name`,name:`jobs-id-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),i>0&&(0,j.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`mr-1 text-muted`,children:N(a,i)}),o?(0,j.jsx)(m,{size:`sm`,disabled:s,onClick:f,children:`Promote selected`}):(0,j.jsx)(`span`,{className:`text-xs text-faint`,children:a===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]})]})}function ie({queue:e,rows:t,selected:n,setSelected:r,refetch:i}){let[a,o]=(0,A.useState)(new Set),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(null),f=D(`jobs:${e}`);return(0,A.useEffect)(()=>{o(new Set),l(!1),d(null)},[f.scopeKey]),{actionMsg:u,bulkBusy:c,busyIds:a,runBulk:async(e,a,o,c)=>{let u=t.filter(e=>n.has(e.id)&&o(e));if(u.length===0||c&&!window.confirm(c(u.length)))return;let p=f.begin([`bulk`,...u.map(e=>`job:${e.id}`)]);if(p){l(!0),d(null);try{let t=await Promise.allSettled(u.map(async t=>{O(await a(t),`${e} ${t.id}`)}));if(!p.isCurrent())return;let n=t.filter(e=>e.status===`fulfilled`).length,o=t.length-n,c=`${e}: ${n} succeeded${o?`, ${o} failed`:``}`;d({ok:o===0,text:c}),o===0?s.success(c):s.error(c),r(e=>P(e,u.map(e=>e.id))),i()}finally{p.finish()&&l(!1)}}},runOne:async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let a=f.begin(`job:${e.id}`);if(a){o(t=>new Set(t).add(e.id)),d(null);try{if(O(await n(),t),!a.isCurrent())return;d({ok:!0,text:`${t} ✓`}),s.success(`${t} ✓`,e.id),i()}catch(e){if(!a.isCurrent())return;d({ok:!1,text:`${t} failed: ${e.message}`}),s.error(`${t} failed`,e.message)}finally{a.finish()&&o(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function L(){let[e,t]=n(),[r,i]=(0,A.useState)(e.get(`queue`)??``),[a,c]=(0,A.useState)(()=>{let t=e.get(`status`);return t&&M.includes(t)?t:`all`}),[u,d]=(0,A.useState)(``),[p,v]=(0,A.useState)(0),[b,S]=(0,A.useState)(new Set),{data:w,error:T,loading:E,refetch:D}=f(()=>o.queuesSummary(),[],{intervalMs:3e4}),{data:O,error:N,refetch:P}=f(()=>o.stats(),[],{intervalMs:1e4});(0,A.useEffect)(()=>{!r&&w?.length&&i(w[0].name)},[w,r]);let F=`${r}|${a}|${p}`,{data:L,error:R,loading:z,refetch:B}=f((0,A.useCallback)(async()=>{if(!r)return{view:F,jobs:[]};let e=a===`all`?void 0:[a],t=await o.jobsList(r,e,25,p*25);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,a,p,F]),[r,a,p]),V=L?.view===F?L.jobs:null,ae=(V?.length??0)===25,H=(0,A.useMemo)(()=>{let e=u.trim().toLowerCase();return e?(V??[]).filter(t=>t.id.toLowerCase().includes(e)||t.name?.toLowerCase().includes(e)):V??[]},[V,u]),U=O?.stats,W=(0,A.useMemo)(()=>w?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[w]),G=U&&W!=null?ee(U.completed,W):null,K=e=>U?C(e):`—`,q=()=>v(0),J=(e,n)=>{let r={};e&&(r.queue=e),n!==`all`&&(r.status=n),t(r,{replace:!0})};(0,A.useEffect)(()=>{S(new Set)},[r,a,p]);let oe=e=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=H.length>0&&H.every(e=>b.has(e.id)),se=()=>S(()=>Y?new Set:new Set(H.map(e=>e.id))),{actionMsg:X,bulkBusy:Z,busyIds:ce,runBulk:le,runOne:ue}=ie({queue:r,rows:H,selected:b,setSelected:S,refetch:B}),Q={promote:e=>k(e.state).promote},$=H.filter(e=>b.has(e.id)),de={promote:$.some(Q.promote)};return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(y,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!r&&V!=null&&!R&&!T&&!N,actions:(0,j.jsxs)(m,{size:`sm`,disabled:!V||H.length===0,onClick:()=>{if(H.length===0){s.info(`No jobs to export on this page`);return}let e=H.map(e=>({id:e.id,name:e.name??`default`,queue:e.queue??r,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));te(`jobs-${r}-${a}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,j.jsx)(l,{className:`size-3.5`}),` Export CSV`]})}),T&&(0,j.jsx)(h,{onRetry:D,message:w?`Queue inventory refresh failed — showing the last successful queue totals. ${T.message}`:`Could not discover queues — ${T.message}. Select an existing queue from the URL or retry.`}),N&&(0,j.jsx)(h,{onRetry:P,message:O?`Server-wide totals refresh failed — showing the last successful totals. ${N.message}`:`Server-wide job totals are unavailable — ${N.message}. The selected queue page may still be current.`}),(0,j.jsx)(ne,{total:U&&W!=null?C(U.completed+W+U.waiting+U.prioritized+U.active+U.delayed+U[`waiting-children`]):`—`,waiting:K(U?.waiting),prioritized:K(U?.prioritized),active:K(U?.active),flowBlocked:K(U?.[`waiting-children`]),completed:K(U?.completed),failed:W==null?`—`:C(W),failedCount:W,errorRate:G==null?`—`:x(G),errorRateTone:G==null?`default`:G>.05?`red`:`green`}),(0,j.jsx)(I,{queue:r,summary:w??[],status:a,search:u,selectedTotal:b.size,selectedVisible:$.length,canPromote:de.promote,bulkBusy:Z,onQueue:e=>{i(e),q(),J(e,a)},onStatus:e=>{c(e),q(),J(r,e)},onSearch:d,onPromote:()=>le(`Promote`,e=>o.promoteJob(e.id),Q.promote)}),X&&(0,j.jsx)(`div`,{role:`status`,className:`mb-3 text-sm ${X.ok?`text-success`:`text-danger`}`,children:X.text}),R&&V&&(0,j.jsx)(h,{message:`Job refresh failed — showing the last successful page.`,onRetry:B}),R&&!V?(0,j.jsx)(g,{error:R,onRetry:B}):E&&!w&&!r&&!T?(0,j.jsx)(_,{label:`Discovering queues…`}):z&&!V?(0,j.jsx)(_,{label:`Loading jobs…`}):(0,j.jsx)(re,{queue:r,rows:H,search:u,discoveryError:!!T,selected:b,allSelected:Y,bulkBusy:Z,busyIds:ce,page:p,hasNext:ae,onToggleAll:se,onToggle:oe,onRun:(e,t,n)=>void ue(e,t,n),onPage:v})]})}export{L as JobsPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{T as r,h as i}from"./icons-BVzwsfbG.js";import{n as a}from"./usePolledData-CNtNtd0a.js";import{i as o,t as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./StatusBadge-BoOVTnKu.js";import{t as l}from"./PageHeader-CvIyaFOO.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{n as f,t as p}from"./index-TploGF7u.js";import{a as m,i as h}from"./form-C4oby9pI.js";import{t as g}from"./Pagination-x-Cwgrul.js";import{t as _}from"./Jobs-CkyRvzOT.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;async function C(){let e=await _();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!Number.isSafeInteger(e.waiting)||e.waiting<0||!Number.isSafeInteger(e.delayed)||e.delayed<0||!Number.isSafeInteger(e.active)||e.active<0||!Number.isSafeInteger(e.dlq)||e.dlq<0||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function w(){let[e,t]=(0,v.useState)(b),[n,_]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O,error:k,refetch:A}=a(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=p(e===b?void 0:e),I=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return j.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[j,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let L=Math.max(1,Math.ceil(I.length/S)),R=Math.min(E,L-1);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(o,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(o,{message:`Event stream unavailable — ${F.message}. Retrying…`}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total Events`,value:d(M.total),compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:d(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:d(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:d(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:d(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Throughput`,value:`${N.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(m,{value:e,"aria-label":`Filter by queue`,name:`classic-activity-queue-filter`,autoComplete:`off`,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(h,{options:x,value:n,onChange:_}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{"aria-label":`Search by job name or ID`,name:`classic-activity-search`,autoComplete:`off`,value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),I.length===0?(0,y.jsx)(s,{icon:(0,y.jsx)(i,{}),title:F?`Event stream unavailable`:P?`Waiting for activity…`:`Connecting to the event stream…`,hint:F?`${F.message}. The dashboard is retrying automatically.`:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:I.slice(R*S,R*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(c,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-CvwrP0tU.js";import{o as i}from"./connectionStore-CFuNYZ_8.js";import{T as a}from"./icons-BVzwsfbG.js";import{n as o}from"./usePolledData-CNtNtd0a.js";import{t as s}from"./Button-Ch1W94fJ.js";import{i as c}from"./feedback-QDN1AsYt.js";import{t as l}from"./StatusBadge-BoOVTnKu.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,n as m,t as h}from"./index-TploGF7u.js";import{a as g,i as _}from"./form-C4oby9pI.js";import{t as v}from"./Pagination-x-Cwgrul.js";import{t as y}from"./QueueControl-BF638r_0.js";var b=e(t(),1),x=r(),S=`__all__`,C=[`all`,`waiting`,`active`,`completed`,`failed`],w=10,T=250;function E(){let[e,t]=(0,b.useState)(S),[r,E]=(0,b.useState)(`all`),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0),[j,M]=(0,b.useState)(null),N=j!==null,P=i(t=>JSON.stringify([t.baseUrl,t.token,e])),{data:F,error:I,refetch:L}=o(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=h(e===S?void 0:e),U=(0,b.useMemo)(()=>{let e=j??R,t=D.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[R,j,r,D]),W=N?Math.max(0,(R[0]?.seq??0)-(j[0]?.seq??0)):0;(0,b.useEffect)(()=>A(0),[e,r,D]),(0,b.useEffect)(()=>M(null),[P]);let G=k*w,K=U.slice(G,G+w);return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:V&&!N}),I&&(0,x.jsx)(c,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(c,{message:`Event stream unavailable — ${H.message}. Retrying…`}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,x.jsx)(m,{label:`Total Events`,value:f(z.total),compact:!0}),(0,x.jsx)(m,{label:`Completed`,value:f(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(m,{label:`Failed`,value:f(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(m,{label:`Waiting`,value:f(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(m,{label:`Active`,value:f(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(m,{label:`Throughput`,value:`${B.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(g,{"aria-label":`Filter by queue`,name:`activity-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),children:[(0,x.jsx)(`option`,{value:S,children:`All Queues`}),(F?.queues??[]).map(e=>(0,x.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,x.jsx)(_,{options:C,value:r,onChange:E}),(0,x.jsx)(s,{size:`sm`,variant:N?`warning`:`default`,onClick:()=>M(N?null:R),title:N?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:N?`Resume${W?` — ${f(W)} new`:``}`:`Following · Pause`}),(0,x.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,x.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{"aria-label":`Search by job ID or queue`,name:`activity-search`,autoComplete:`off`,value:D,onChange:e=>O(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,x.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,T,` streamed events held in this browser.`]}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,x.jsx)(`tbody`,{children:K.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:H?`Event stream unavailable — ${H.message}. Retrying…`:V?R.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):K.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(l,{status:e.status})}),(0,x.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:d(e.timestamp)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,x.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,x.jsx)(p,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,x.jsx)(v,{page:k,pageSize:w,total:U.length,onPageChange:A,label:`events`})]})}export{E as LogsPro};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./react-vendor-CvwrP0tU.js";import{n as t,t as n}from"./Card-CWxrC8OY.js";import{t as r}from"./PageHeader-CvIyaFOO.js";import{a as i,n as a}from"./index-TploGF7u.js";var o=e(),s=`{
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"bunqueue": {
|
|
4
4
|
"command": "bunx",
|
|
@@ -19,4 +19,4 @@ import{t as e}from"./react-vendor-CyjgmGTq.js";import{n as t,t as n}from"./Card-
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
}`,l=`claude mcp add bunqueue -- bunx --package=bunqueue bunqueue-mcp`,u=[{name:`Jobs`,count:11,examples:[`add_job`,`get_job`,`get_jobs`,`get_job_result`,`wait_for_job`]},{name:`Job management`,count:6,examples:[`cancel_job`,`change_job_priority`,`promote_job`,`update_job_data`]},{name:`Consumption`,count:8,examples:[`pull_job`,`pull_job_batch`,`ack_job`,`fail_job`,`job_heartbeat`]},{name:`Queues`,count:11,examples:[`list_queues`,`pause_queue`,`resume_queue`,`drain_queue`,`obliterate_queue`]},{name:`Dead letter queue`,count:4,examples:[`get_dlq`,`retry_dlq`,`purge_dlq`]},{name:`Cron`,count:4,examples:[`add_cron`,`list_crons`,`get_cron`,`delete_cron`]},{name:`Flows`,count:4,examples:[`add_flow`,`add_flow_chain`,`get_flow`,`get_children_values`]},{name:`Rate limits`,count:4,examples:[`set_rate_limit`,`set_concurrency`,`clear_rate_limit`]},{name:`Webhooks`,count:4,examples:[`add_webhook`,`list_webhooks`,`remove_webhook`,`set_webhook_enabled`]},{name:`Workers`,count:3,examples:[`register_worker`,`list_workers`,`worker_heartbeat`]},{name:`Handlers`,count:3,examples:[`register_handler`,`list_handlers`,`unregister_handler`]},{name:`Monitoring`,count:11,examples:[`get_stats`,`get_queue_stats`,`get_memory_stats`,`get_prometheus_metrics`]}],d=[`bunqueue://queues`,`bunqueue://stats`,`bunqueue://workers`,`bunqueue://crons`,`bunqueue://webhooks`],f=[`bunqueue_debug_queue`,`bunqueue_health_report`,`bunqueue_incident_response`],p=u.reduce((e,t)=>e+t.count,0);function m({code:e}){return(0,o.jsxs)(`div`,{className:`relative min-w-0 max-w-full`,children:[(0,o.jsx)(`div`,{className:`absolute right-2 top-2`,children:(0,o.jsx)(i,{value:e})}),(0,o.jsx)(`pre`,{className:`max-w-full overflow-x-auto overscroll-x-contain rounded-lg border border-line bg-surface-2 p-4 pr-12 font-mono text-xs leading-relaxed text-fg`,children:e})]})}function h({children:e}){return(0,o.jsx)(`span`,{className:`max-w-full break-all rounded-md border border-line bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:e})}function g(){return(0,o.jsxs)(`div`,{className:`min-w-0 overflow-x-hidden`,children:[(0,o.jsx)(r,{title:`MCP Server`,description:`Connect bunqueue to AI agents (Claude Desktop, Claude Code) over the Model Context Protocol.`,actions:(0,o.jsx)(`a`,{href:`https://egeominotti.github.io/bunqueue-dashboard/docs/guide/mcp`,target:`_blank`,rel:`noopener noreferrer`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Docs`})}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted`,children:[`bunqueue ships a Model Context Protocol server,`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`bunqueue-mcp`}),`, that lets an AI agent drive the queue with tools, resources, and prompts. It is a separate`,` `,(0,o.jsx)(`span`,{className:`text-fg`,children:`stdio`}),` process, launched by the MCP client (not by this dashboard, and not part of the HTTP API), so this page is a setup and reference guide rather than a live monitor. It needs the optional peer dependency`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`@modelcontextprotocol/sdk`}),`.`]}),(0,o.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-warning`,children:`The upstream MCP includes destructive Cancel, Discard, Drain, Obliterate, DLQ Retry and DLQ Purge tools. They bypass this dashboard's v2.
|
|
22
|
+
}`,l=`claude mcp add bunqueue -- bunx --package=bunqueue bunqueue-mcp`,u=[{name:`Jobs`,count:11,examples:[`add_job`,`get_job`,`get_jobs`,`get_job_result`,`wait_for_job`]},{name:`Job management`,count:6,examples:[`cancel_job`,`change_job_priority`,`promote_job`,`update_job_data`]},{name:`Consumption`,count:8,examples:[`pull_job`,`pull_job_batch`,`ack_job`,`fail_job`,`job_heartbeat`]},{name:`Queues`,count:11,examples:[`list_queues`,`pause_queue`,`resume_queue`,`drain_queue`,`obliterate_queue`]},{name:`Dead letter queue`,count:4,examples:[`get_dlq`,`retry_dlq`,`purge_dlq`]},{name:`Cron`,count:4,examples:[`add_cron`,`list_crons`,`get_cron`,`delete_cron`]},{name:`Flows`,count:4,examples:[`add_flow`,`add_flow_chain`,`get_flow`,`get_children_values`]},{name:`Rate limits`,count:4,examples:[`set_rate_limit`,`set_concurrency`,`clear_rate_limit`]},{name:`Webhooks`,count:4,examples:[`add_webhook`,`list_webhooks`,`remove_webhook`,`set_webhook_enabled`]},{name:`Workers`,count:3,examples:[`register_worker`,`list_workers`,`worker_heartbeat`]},{name:`Handlers`,count:3,examples:[`register_handler`,`list_handlers`,`unregister_handler`]},{name:`Monitoring`,count:11,examples:[`get_stats`,`get_queue_stats`,`get_memory_stats`,`get_prometheus_metrics`]}],d=[`bunqueue://queues`,`bunqueue://stats`,`bunqueue://workers`,`bunqueue://crons`,`bunqueue://webhooks`],f=[`bunqueue_debug_queue`,`bunqueue_health_report`,`bunqueue_incident_response`],p=u.reduce((e,t)=>e+t.count,0);function m({code:e}){return(0,o.jsxs)(`div`,{className:`relative min-w-0 max-w-full`,children:[(0,o.jsx)(`div`,{className:`absolute right-2 top-2`,children:(0,o.jsx)(i,{value:e})}),(0,o.jsx)(`pre`,{className:`max-w-full overflow-x-auto overscroll-x-contain rounded-lg border border-line bg-surface-2 p-4 pr-12 font-mono text-xs leading-relaxed text-fg`,children:e})]})}function h({children:e}){return(0,o.jsx)(`span`,{className:`max-w-full break-all rounded-md border border-line bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:e})}function g(){return(0,o.jsxs)(`div`,{className:`min-w-0 overflow-x-hidden`,children:[(0,o.jsx)(r,{title:`MCP Server`,description:`Connect bunqueue to AI agents (Claude Desktop, Claude Code) over the Model Context Protocol.`,actions:(0,o.jsx)(`a`,{href:`https://egeominotti.github.io/bunqueue-dashboard/docs/guide/mcp`,target:`_blank`,rel:`noopener noreferrer`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Docs`})}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted`,children:[`bunqueue ships a Model Context Protocol server,`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`bunqueue-mcp`}),`, that lets an AI agent drive the queue with tools, resources, and prompts. It is a separate`,` `,(0,o.jsx)(`span`,{className:`text-fg`,children:`stdio`}),` process, launched by the MCP client (not by this dashboard, and not part of the HTTP API), so this page is a setup and reference guide rather than a live monitor. It needs the optional peer dependency`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`@modelcontextprotocol/sdk`}),`.`]}),(0,o.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-warning`,children:`The upstream MCP includes destructive Cancel, Discard, Drain, Obliterate, DLQ Retry and DLQ Purge tools. They bypass this dashboard's v2.9.0 flow-safety gates and have no atomic reverse-dependency or job-generation precondition. Grant MCP write access only after independently proving the workload is not flow-linked.`})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,o.jsx)(a,{label:`Tools`,value:String(p)}),(0,o.jsx)(a,{label:`Categories`,value:String(u.length)}),(0,o.jsx)(a,{label:`Resources`,value:String(d.length)}),(0,o.jsx)(a,{label:`Prompts`,value:String(f.length)})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(n,{className:`min-w-0`,children:[(0,o.jsx)(t,{title:`Embedded mode (default)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Direct SQLite access, no running server. Point `,(0,o.jsx)(h,{children:`DATA_PATH`}),` at the bunqueue database file. Best for a local agent on the same machine.`]}),(0,o.jsx)(m,{code:s})]}),(0,o.jsxs)(n,{className:`min-w-0`,children:[(0,o.jsx)(t,{title:`TCP mode (remote server)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Connect to a running bunqueue server over its TCP protocol port (`,(0,o.jsx)(h,{children:`6789`}),`, distinct from the HTTP admin API on 6790). Use a `,(0,o.jsx)(h,{children:`BUNQUEUE_TOKEN`}),` if the server has one.`]}),(0,o.jsx)(m,{code:c})]})]}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Where to put it`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Add the JSON above to your MCP client config (for Claude Desktop, its`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`claude_desktop_config.json`}),`). For Claude Code, register it from the CLI:`]}),(0,o.jsx)(m,{code:l})]}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Tools`,action:(0,o.jsxs)(`span`,{className:`text-xs text-faint`,children:[p,` total`]})}),(0,o.jsx)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 lg:grid-cols-3`,children:u.map(e=>(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:e.count})]}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.examples.map(e=>(0,o.jsx)(h,{children:e},e))})]},e.name))}),(0,o.jsxs)(`p`,{className:`mt-4 text-xs text-faint`,children:[`Every tool name is prefixed `,(0,o.jsx)(`span`,{className:`font-mono`,children:`bunqueue_`}),` (examples above drop it). Counts total `,p,`.`]})]}),(0,o.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Resources`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:d.length})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:d.map(e=>(0,o.jsx)(h,{children:e},e))})]}),(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Prompts`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:f.length})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,o.jsx)(h,{children:e},e))})]})]})]})}export{g as McpServer};
|