bunqueue-dashboard 0.0.33 → 0.0.35
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 +2 -2
- package/agent/manager.ts +3 -3
- package/agent/server.ts +72 -0
- package/agent/workflows.ts +491 -0
- package/dist/.vite/manifest.json +93 -81
- package/dist/assets/AddJob-CG28MSxU.js +3 -0
- package/dist/assets/{Alerts-C39RrGbQ.js → Alerts-D9JojJrj.js} +1 -1
- package/dist/assets/{Benchmark-CM60tHbf.js → Benchmark-BVjUH9dG.js} +1 -1
- package/dist/assets/{BulkAddJobs-BjL-xcQy.js → BulkAddJobs-BHzUCMj_.js} +1 -1
- package/dist/assets/{CopilotPanel-BGK1rw-V.js → CopilotPanel-COLw-atS.js} +1 -1
- package/dist/assets/{Cron-s1e-jgOo.js → Cron-DoEHDHwy.js} +1 -1
- package/dist/assets/CronManager-vulcesqJ.js +1 -0
- package/dist/assets/{Database-ZluStWMz.js → Database-DlB_t04Z.js} +1 -1
- package/dist/assets/{Diagnostics-C0N5z5j-.js → Diagnostics-DddCUgeR.js} +1 -1
- package/dist/assets/{Dlq-CtcLzs-b.js → Dlq-DMKrsSMP.js} +1 -1
- package/dist/assets/{DlqControl-B_Z8KKn5.js → DlqControl-9m0Re_TH.js} +1 -1
- package/dist/assets/{DlqPro-B68en6AG.js → DlqPro-Dmw-0wta.js} +1 -1
- package/dist/assets/{Flows-CD_bkCBM.js → Flows-C3-9nXW4.js} +1 -1
- package/dist/assets/JobInspector-DwIfABmI.js +2 -0
- package/dist/assets/{Jobs-BUtcBKKk.js → Jobs-j8tTS3NC.js} +1 -1
- package/dist/assets/JobsPro-CS__CJJl.js +1 -0
- package/dist/assets/{Logs-CmVODYCI.js → Logs-BB-VDPA1.js} +1 -1
- package/dist/assets/{LogsPro-CJ-Il3LP.js → LogsPro-RNtSQZRT.js} +1 -1
- package/dist/assets/{McpServer-dMjyJKgT.js → McpServer-CbaU52l2.js} +2 -2
- package/dist/assets/{Metrics-Dsbeplz-.js → Metrics-ivcddPwT.js} +1 -1
- package/dist/assets/{MetricsPro-BqxurxrJ.js → MetricsPro-xjZno4vg.js} +1 -1
- package/dist/assets/{Overview-DH9C2dsf.js → Overview-D84aD2ph.js} +1 -1
- package/dist/assets/{Pagination-DpxiBnt8.js → Pagination-Bfi4vkpp.js} +1 -1
- package/dist/assets/{QueueActions-D_QGBaVm.js → QueueActions-DTbD6uek.js} +1 -1
- package/dist/assets/{QueueControl-V0DJ6qk6.js → QueueControl-B5xK_SQ-.js} +1 -1
- package/dist/assets/{QueueDetail-BgKAMJqf.js → QueueDetail-BH59kwm9.js} +1 -1
- package/dist/assets/{QueueDetailPro-BkHYzGiq.js → QueueDetailPro-DoN25ndy.js} +1 -1
- package/dist/assets/{Queues-2_v7DcNi.js → Queues-CKMJqFHX.js} +1 -1
- package/dist/assets/{QueuesOverview-BySSkmB4.js → QueuesOverview-BX1lzojl.js} +1 -1
- package/dist/assets/{S3Backup-CPADzKQE.js → S3Backup-Bz3GfoZ9.js} +1 -1
- package/dist/assets/{S3BackupPro-CSrQYIDL.js → S3BackupPro-BC_6-uX-.js} +1 -1
- package/dist/assets/{ServerControl-C0tI1VDx.js → ServerControl-CSSrN8G5.js} +2 -2
- package/dist/assets/{Settings-CSzoM5up.js → Settings-DkqmZUIS.js} +1 -1
- package/dist/assets/{Usage-B4B7tmrc.js → Usage-Ba20p0xd.js} +1 -1
- package/dist/assets/{UsagePro-CCBpgSDy.js → UsagePro-C2pQwjN9.js} +1 -1
- package/dist/assets/{Webhooks-aJz-GisQ.js → Webhooks-CVuuvb0L.js} +1 -1
- package/dist/assets/{Workers-Bg8xKjkg.js → Workers-C1wPU6CS.js} +1 -1
- package/dist/assets/{WorkersPro-BOOCrXf8.js → WorkersPro-B0vEkC0T.js} +1 -1
- package/dist/assets/Workflows-C8Qmkflf.js +1 -0
- package/dist/assets/{flowMutationSafety-DVD1IMr-.js → flowMutationSafety-CoOp94wS.js} +1 -1
- package/dist/assets/index-BCNzbhhD.css +1 -0
- package/dist/assets/index-CAtsVmyh.js +8 -0
- package/dist/assets/install-D0eRLf9F.js +3 -0
- package/dist/assets/{upstreamPaths-nG8N1XAz.js → upstreamPaths-D_LPsv7b.js} +1 -1
- package/dist/assets/{useThroughputSeries-tb26_lkb.js → useThroughputSeries-DjxGN8ob.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +4 -1
- package/scripts/embedded.gen.ts +122 -120
- package/dist/assets/AddJob-ytpBLTCJ.js +0 -3
- package/dist/assets/CronManager-BostU7BX.js +0 -1
- package/dist/assets/JobInspector-DwRtyMz0.js +0 -2
- package/dist/assets/JobsPro-BK_xd4ji.js +0 -1
- package/dist/assets/index-BWoUj86M.css +0 -1
- package/dist/assets/index-Bn2R06qm.js +0 -8
- package/dist/assets/install-CUS8Kijb.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-Bjui4wS4.js";import{i as o,o as s}from"./connectionStore-Cd9-3Fw0.js";import{i as c}from"./upstreamPaths-nG8N1XAz.js";import{D as l,S as u,b as d,dt as f,h as p,lt as m,rt as h,x as g,y as _}from"./index-Bn2R06qm.js";var v=e(r(),1),y={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function b(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 x(e,t,n={}){let r={...y,...n},i=b(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}}var S=a(),C=168,w=60,ee={nodeWidth:C,nodeHeight:w},T=500,E=100,D=100,O=`flow-order-9a3f`,k={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`},te=e=>e&&k[e]||`border-line bg-surface-2 text-muted`,A=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,j=`bq-dash-recent-flows`,M=8;function N(e){return`${j}:${encodeURIComponent(e.trim()||`/api`)}`}function P(e,t){if(!t)return[];try{let t=JSON.parse(localStorage.getItem(N(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<=T&&Number.isFinite(e?.at)&&e.at>=0).slice(0,M):[]}catch{return[]}}function ne(e,t,n,r){let i=[n,...t.filter(e=>e.root!==n.root)].slice(0,M);if(!r)return i;try{localStorage.setItem(N(e),JSON.stringify(i))}catch{}return i}var F=class extends Error{constructor(e,t){super(e,t),this.name=`FlowSnapshotError`}};function I(e,t,n){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`||c(e)!==null))throw new F(`Job ${n} returned an invalid ${t} list`);return e}function L(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new F(`GET /jobs/${t} returned an invalid response`);let n=e;if(n.ok!==!0)throw new F(`GET /jobs/${t} returned an invalid success envelope`);let r=n.job;if(typeof r!=`object`||!r||Array.isArray(r))throw new F(`GET /jobs/${t} returned no job snapshot`);let i=r;if(i.id!==t)throw new F(`GET /jobs/${t} returned the wrong job id (${String(i.id)})`);if(typeof i.queue!=`string`||i.queue.length===0)throw new F(`Job ${t} returned an invalid queue`);if(typeof i.state!=`string`||i.state.length===0)throw new F(`Job ${t} returned an invalid state`);if(!Object.hasOwn(i,`parentId`)||i.parentId!==null&&(typeof i.parentId!=`string`||c(i.parentId)!==null))throw new F(`Job ${t} returned an invalid parentId`);return{...r,parentId:i.parentId,childrenIds:I(i.childrenIds,`childrenIds`,t),dependsOn:I(i.dependsOn,`dependsOn`,t)}}async function R(e,t,n){n?.throwIfAborted();let r=await f(e,t,n);return n?.throwIfAborted(),L(r,t)}function z(e){let t=c(e);return t?`Job ID: ${t}`:null}async function re(e,t={}){let n=z(e);if(n)throw new F(n);let r=t.target??m(),{signal:i}=t,a=e,o=new Set([e]),s=[];for(let e=0;;e++){i?.throwIfAborted();let t;try{t=await R(r,a,i)}catch(t){if(i?.throwIfAborted(),e===0)throw t;if(t instanceof h&&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 F(`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 F(`Flow parent cycle detected at job ${n}`);if(e>=D)throw new F(`Flow parent chain exceeds the v2.8.55 limit of ${D} levels`);o.add(n),a=n}}function B(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 V=[`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`];function H(e){return V.filter(t=>e[t]===!0)}function U(e,t){if(e?.parentId!==t)return null;let n=H(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 ie(e,t,n={}){let r=z(e);if(r)throw new F(r);let i=n.target??m(),{signal:a}=n,o=new Map,s=[],c=[],l=new Set,u=new Set,d=new Map,f=new Set,p=new Set,h=new Set(n.limitations??[]),g=[{id:e,depth:0}],_=new Set([e]),v=new Map;t&&v.set(e,L({ok:!0,job:t},e));let y=[...n.seedPath??[]].reverse(),b=!1;if(y.length>0&&y[0]?.id!==e)throw new F(`Resolved seed path does not start at the requested flow root`);for(let[e,t]of y.entries()){let n=L({ok:!0,job:t},t.id);if(v.set(n.id,n),e!==0){if(e>E||_.size>=T){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 R(i,t,a)}catch(n){if(a?.throwIfAborted(),t===e)throw n;d.set(t,n instanceof Error?n.message:String(n))}if(o.set(t,r??{id:t,state:`unknown`}),!r)continue;if(n>=E){(r.childrenIds?.length??0)+(r.dependsOn?.length??0)>0&&(S=!0);continue}let p=e=>_.has(e)?!0:_.size>=T?(S=!0,!1):(_.add(e),g.push({id:e,depth:n+1}),!0),m=(e,t,n,r)=>{if(!p(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&&f.add(`Job ${t} lists a child more than once`),C.size!==y.length&&f.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(p(e)){let n=`${e}->${t}`;u.has(n)||(u.add(n),c.push({from:e,to:t,kind:`depends`})),b.has(e)||m(e,t,`depends`,e)}}for(let[e,t]of o)!d.has(e)&&H(t).length>1&&f.add(`Job ${e} enables mutually exclusive failure policies`);for(let e of s){if(e.kind!==`child`||d.has(e.to))continue;let t=o.get(e.to);t&&t.parentId!==e.from&&f.add(`Child ${e.to} points to parent ${String(t.parentId??`none`)}, not ${e.from}`)}for(let[e,t]of o){if(d.has(e))continue;let n=t.childrenIds??[];if(n.some(e=>!o.has(e)||d.has(e)))continue;let r=n.map(t=>({childId:t,release:U(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`){p.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=U(o.get(i),e);if(n?.scope===`child`){p.add(`Parent ${e} is missing dependency ${i}; ${n.policy} may have released it, but the HTTP snapshot cannot prove whether the policy fired`);continue}f.add(`Parent ${e} lists child ${i} without the matching dependency`)}}for(let[e,t]of o){if(d.has(e)||!t.parentId)continue;let n=o.get(t.parentId);!n||d.has(t.parentId)||n.childrenIds?.includes(e)||f.add(`Parent ${t.parentId} does not list child ${e}`)}let C=B([...o.keys()],c);return{jobs:o,edges:s,truncated:S,failed:d.size,failures:d,issues:[...f],policyNotes:[...p],cycle:C,limitations:[...h]}}function W(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function ae(e,t){return e.x<=t.x?W(e.x+C,e.y+w/2,t.x,t.y+w/2):W(e.x,e.y+w/2,t.x+C,t.y+w/2)}function oe(e){return e instanceof h&&e.status===0||e.name===`TypeError`||e.name===`AbortError`||e.name===`TimeoutError`}function G(){let{token:e}=s.getState();return JSON.stringify([o(),e])}function K(){let[e,r]=n(),a=e.get(`root`)??(l()?O:``),c=s(e=>e.baseUrl),f=s(e=>e.token),h=o(),y=f.length===0,[b,D]=(0,v.useState)(a),[k,j]=(0,v.useState)(null),[M,N]=(0,v.useState)(null),[I,L]=(0,v.useState)(!1),[R,B]=(0,v.useState)(null),[V,H]=(0,v.useState)(()=>P(h,y)),U=(0,v.useRef)(0),W=(0,v.useRef)(null),K=(0,v.useRef)(!1),J=(0,v.useRef)(G()),Y=(0,v.useCallback)(async e=>{let t=s.getState();if(t.baseUrl!==c||t.token!==f)return;W.current?.abort(),W.current=null;let n=++U.current,r=e.trim();if(j(null),N(null),B(null),!r){L(!1);return}let i=z(r);if(i){B(new F(i)),L(!1);return}let a=m(),o=G(),l=s.getState().token.length===0,u=new AbortController;W.current=u;let d=()=>K.current&&n===U.current&&!u.signal.aborted&&o===G();L(!0);try{let e={target:a,signal:u.signal},t=await re(r,e),n=t.missingParent?[`Ancestor ${t.missingParent} is no longer available. Bunqueue may legitimately remove a completed flow root, so this graph starts at the oldest surviving node.`]:[],i=await ie(t.id,t.job,{...e,seedPath:t.path,limitations:n});if(!d())return;j(i),N(t.id),i.jobs.size>1&&H(e=>ne(a.baseUrl,e,{root:t.id,nodes:i.jobs.size,at:Date.now()},l))}catch(e){if(!d())return;B(e instanceof Error?e:Error(`Failed to load flow`))}finally{W.current===u&&(W.current=null),d()&&L(!1)}},[c,f]);(0,v.useEffect)(()=>{K.current=!0,J.current=G();let e=s.subscribe(()=>{let e=G();e!==J.current&&(J.current=e,U.current+=1,W.current?.abort(),W.current=null,K.current&&(j(null),N(null),B(null),L(!1)))});return()=>{K.current=!1,e(),U.current+=1,W.current?.abort(),W.current=null}},[]),(0,v.useEffect)(()=>{H(f?[]:P(h,!0))},[h,f]),(0,v.useEffect)(()=>{D(a),Y(a)},[a,Y]);let se=e=>{e.preventDefault();let t=b.trim();t&&(t===a?Y(t):r({root:t},{replace:!0}))},X=(0,v.useMemo)(()=>k?x([...k.jobs.keys()],k.edges,ee):null,[k]),Z=(0,v.useMemo)(()=>new Map(X?.nodes.map(e=>[e.id,e])??[]),[X]),Q=M?k?.jobs.get(M):void 0,$=M?k?.failures.get(M):void 0;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(p,{title:`Flows`,description:`Visualize a job flow: parent, children, and dependency edges as an interactive graph.`,actions:k&&(0,S.jsx)(`button`,{type:`button`,disabled:I,onClick:()=>void Y(a),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 disabled:opacity-50`,children:`Refresh`})}),(0,S.jsxs)(u,{className:`mb-6`,children:[(0,S.jsxs)(`form`,{onSubmit:se,className:`flex flex-wrap items-center gap-3`,children:[(0,S.jsx)(`input`,{name:`flow-job-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:b,onChange:e=>D(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,S.jsx)(`button`,{type:`submit`,disabled:I||!b.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:I?`Loading…`:`Load Flow`})]}),(0,S.jsxs)(`p`,{id:`flow-input-help`,className:`mt-2 text-xs text-faint`,children:[`Structural parent/child flows can start from any surviving node. Dependency-only chains can only be followed upstream with the v2.8.55 HTTP API, so use the most downstream job to see the full chain. Up to `,T,` nodes are rendered.`]})]}),(0,S.jsxs)(`div`,{"aria-live":`polite`,children:[R&&(oe(R)?(0,S.jsx)(g,{message:`Could not load the flow — ${R.message}`,onRetry:()=>void Y(a)}):(0,S.jsx)(_,{error:R,onRetry:()=>void Y(a)})),I&&(0,S.jsx)(d,{label:`Loading flow…`})]}),!I&&!k&&!R&&(0,S.jsx)(u,{children:(0,S.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,S.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,S.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID above, or open a job that is part of a flow and choose “View flow”.`}),V.length>0&&(0,S.jsxs)(`div`,{className:`mt-6`,children:[(0,S.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,S.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:V.map(e=>(0,S.jsxs)(`button`,{type:`button`,title:e.root,onClick:()=>{D(e.root),r({root:e.root},{replace:!0})},className:`min-h-10 rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted transition-colors hover:border-line-strong hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,S.jsx)(`span`,{translate:`no`,children:A(e.root)}),(0,S.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})}),k&&X&&(0,S.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1fr_260px]`,children:[(0,S.jsxs)(u,{padded:!1,className:`max-h-[70vh] overflow-auto overscroll-contain p-4`,children:[(0,S.jsx)(`h2`,{className:`sr-only`,children:`Flow Graph`}),(0,S.jsx)(`ul`,{className:`sr-only`,"aria-label":`Flow relationships`,children:k.edges.map(e=>(0,S.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,S.jsxs)(`div`,{className:`relative`,style:{width:X.width,height:X.height},children:[(0,S.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:X.width,height:X.height,children:[(0,S.jsxs)(`defs`,{children:[(0,S.jsx)(`marker`,{id:`flow-arrow-child`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,S.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})}),(0,S.jsx)(`marker`,{id:`flow-arrow-dependency`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,S.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})})]}),k.edges.map(e=>{let t=Z.get(e.from),n=Z.get(e.to);return!t||!n?null:(0,S.jsx)(`path`,{d:ae(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}`)})]}),X.nodes.map(e=>{let n=k.jobs.get(e.id),r=k.failures.has(e.id)?`unavailable`:n?.state??`unknown`;return(0,S.jsxs)(`button`,{type:`button`,"data-flow-node":e.id,onClick:()=>N(e.id),"aria-pressed":M===e.id,"aria-label":`${e.id}, queue ${n?.queue??`unknown`}, state ${r}`,title:e.id,style:{left:e.x,top:e.y,width:C,height:w},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left transition-shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/70`,te(n?.state),M===e.id&&`ring-2 ring-accent`),children:[(0,S.jsx)(`span`,{translate:`no`,className:`truncate font-mono text-xs text-fg`,children:A(e.id)}),(0,S.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,S.jsx)(`span`,{className:`truncate`,children:n?.queue??`—`}),(0,S.jsx)(`span`,{className:`font-medium`,children:r})]})]},e.id)})]})]}),(0,S.jsx)(`aside`,{"aria-label":`Selected job details`,"aria-live":`polite`,children:(0,S.jsxs)(u,{children:[Q?(0,S.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,S.jsx)(`div`,{translate:`no`,className:`break-all font-mono text-xs text-fg`,children:Q.id})]}),$&&(0,S.jsxs)(`p`,{role:`alert`,className:`break-words text-xs text-warning`,children:[`Snapshot unavailable: `,$]}),(0,S.jsx)(q,{label:`Queue`,value:Q.queue??`—`}),(0,S.jsx)(q,{label:`State`,value:$?`unavailable`:Q.state??`unknown`}),(0,S.jsx)(q,{label:`Priority`,value:Q.priority===void 0?`—`:String(Q.priority)}),(0,S.jsx)(q,{label:`Parent`,value:Q.parentId??`—`}),(0,S.jsx)(q,{label:`Children`,value:$?`—`:String(Q.childrenIds?.length??0)}),(0,S.jsx)(q,{label:`Depends On`,value:$?`—`:String(Q.dependsOn?.length??0)}),(0,S.jsx)(i,{to:`/job?id=${encodeURIComponent(Q.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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Open in Job Inspector`})]}):(0,S.jsx)(`p`,{className:`text-sm text-muted`,children:`Select a node to inspect it.`}),(0,S.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,"aria-live":`polite`,children:[k.truncated&&(0,S.jsxs)(`div`,{className:`mb-1 text-warning`,children:[`Graph truncated at `,T,` nodes / depth `,E,` — not the whole flow.`]}),k.limitations.length>0&&(0,S.jsxs)(`details`,{className:`mb-1 text-warning`,children:[(0,S.jsxs)(`summary`,{className:`cursor-pointer`,children:[k.limitations.length,` known snapshot limitation`,k.limitations.length===1?``:`s`]}),(0,S.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:k.limitations.map(e=>(0,S.jsx)(`li`,{className:`break-words`,children:e},e))})]}),k.failed>0&&(0,S.jsxs)(`details`,{className:`mb-1 text-warning`,children:[(0,S.jsxs)(`summary`,{className:`cursor-pointer`,children:[k.failed,` node`,k.failed===1?``:`s`,` couldn't be loaded — this is not the whole flow`]}),(0,S.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:[...k.failures].map(([e,t])=>(0,S.jsxs)(`li`,{className:`break-words`,children:[(0,S.jsx)(`span`,{translate:`no`,className:`font-mono`,children:e}),`: `,t]},e))})]}),k.cycle&&(0,S.jsxs)(`div`,{className:`mb-1 break-words text-danger`,children:[`Dependency cycle detected:`,` `,(0,S.jsx)(`span`,{translate:`no`,className:`font-mono`,children:k.cycle.join(` → `)}),`. This is not a valid atomic v2.8.55 flow.`]}),k.issues.length>0&&(0,S.jsxs)(`details`,{className:`mb-1 text-warning`,children:[(0,S.jsxs)(`summary`,{className:`cursor-pointer`,children:[k.issues.length,` `,k.issues.length===1?`possible snapshot inconsistency`:`possible snapshot inconsistencies`,` `,`detected (the flow may have changed during these requests)`]}),(0,S.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:k.issues.map(e=>(0,S.jsx)(`li`,{className:`break-words`,children:e},e))})]}),k.policyNotes.length>0&&(0,S.jsxs)(`details`,{className:`mb-1 text-muted`,children:[(0,S.jsxs)(`summary`,{className:`cursor-pointer`,children:[k.policyNotes.length,` failure-policy`,` `,k.policyNotes.length===1?`ambiguity`:`ambiguities`]}),(0,S.jsx)(`p`,{className:`mt-1`,children:`These are informational: the HTTP snapshot cannot prove whether a configured policy fired.`}),(0,S.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:k.policyNotes.map(e=>(0,S.jsx)(`li`,{className:`break-words`,children:e},e))})]}),(0,S.jsxs)(`div`,{className:`mb-1`,children:[k.jobs.size,` node`,k.jobs.size===1?``:`s`,` · `,k.edges.length,` `,`edge`,k.edges.length===1?``:`s`]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,S.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` `,`depends`]})]})]})]})})]})]})}function q({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,S.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e}),(0,S.jsx)(`span`,{className:`min-w-0 break-all text-right text-fg`,children:t})]})}export{K as Flows};
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-Bjui4wS4.js";import{i as o,o as s}from"./connectionStore-Cd9-3Fw0.js";import{i as c}from"./upstreamPaths-D_LPsv7b.js";import{D as l,S as u,b as d,dt as f,h as p,lt as m,rt as h,x as g,y as _}from"./index-CAtsVmyh.js";var v=e(r(),1),y={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function b(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 x(e,t,n={}){let r={...y,...n},i=b(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}}var S=a(),C=168,w=60,ee={nodeWidth:C,nodeHeight:w},T=500,E=100,D=100,O=`flow-order-9a3f`,k={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`},te=e=>e&&k[e]||`border-line bg-surface-2 text-muted`,A=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,j=`bq-dash-recent-flows`,M=8;function N(e){return`${j}:${encodeURIComponent(e.trim()||`/api`)}`}function P(e,t){if(!t)return[];try{let t=JSON.parse(localStorage.getItem(N(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<=T&&Number.isFinite(e?.at)&&e.at>=0).slice(0,M):[]}catch{return[]}}function ne(e,t,n,r){let i=[n,...t.filter(e=>e.root!==n.root)].slice(0,M);if(!r)return i;try{localStorage.setItem(N(e),JSON.stringify(i))}catch{}return i}var F=class extends Error{constructor(e,t){super(e,t),this.name=`FlowSnapshotError`}};function I(e,t,n){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`||c(e)!==null))throw new F(`Job ${n} returned an invalid ${t} list`);return e}function L(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new F(`GET /jobs/${t} returned an invalid response`);let n=e;if(n.ok!==!0)throw new F(`GET /jobs/${t} returned an invalid success envelope`);let r=n.job;if(typeof r!=`object`||!r||Array.isArray(r))throw new F(`GET /jobs/${t} returned no job snapshot`);let i=r;if(i.id!==t)throw new F(`GET /jobs/${t} returned the wrong job id (${String(i.id)})`);if(typeof i.queue!=`string`||i.queue.length===0)throw new F(`Job ${t} returned an invalid queue`);if(typeof i.state!=`string`||i.state.length===0)throw new F(`Job ${t} returned an invalid state`);if(!Object.hasOwn(i,`parentId`)||i.parentId!==null&&(typeof i.parentId!=`string`||c(i.parentId)!==null))throw new F(`Job ${t} returned an invalid parentId`);return{...r,parentId:i.parentId,childrenIds:I(i.childrenIds,`childrenIds`,t),dependsOn:I(i.dependsOn,`dependsOn`,t)}}async function R(e,t,n){n?.throwIfAborted();let r=await f(e,t,n);return n?.throwIfAborted(),L(r,t)}function z(e){let t=c(e);return t?`Job ID: ${t}`:null}async function re(e,t={}){let n=z(e);if(n)throw new F(n);let r=t.target??m(),{signal:i}=t,a=e,o=new Set([e]),s=[];for(let e=0;;e++){i?.throwIfAborted();let t;try{t=await R(r,a,i)}catch(t){if(i?.throwIfAborted(),e===0)throw t;if(t instanceof h&&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 F(`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 F(`Flow parent cycle detected at job ${n}`);if(e>=D)throw new F(`Flow parent chain exceeds the v2.8.55 limit of ${D} levels`);o.add(n),a=n}}function B(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 V=[`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`];function H(e){return V.filter(t=>e[t]===!0)}function U(e,t){if(e?.parentId!==t)return null;let n=H(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 ie(e,t,n={}){let r=z(e);if(r)throw new F(r);let i=n.target??m(),{signal:a}=n,o=new Map,s=[],c=[],l=new Set,u=new Set,d=new Map,f=new Set,p=new Set,h=new Set(n.limitations??[]),g=[{id:e,depth:0}],_=new Set([e]),v=new Map;t&&v.set(e,L({ok:!0,job:t},e));let y=[...n.seedPath??[]].reverse(),b=!1;if(y.length>0&&y[0]?.id!==e)throw new F(`Resolved seed path does not start at the requested flow root`);for(let[e,t]of y.entries()){let n=L({ok:!0,job:t},t.id);if(v.set(n.id,n),e!==0){if(e>E||_.size>=T){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 R(i,t,a)}catch(n){if(a?.throwIfAborted(),t===e)throw n;d.set(t,n instanceof Error?n.message:String(n))}if(o.set(t,r??{id:t,state:`unknown`}),!r)continue;if(n>=E){(r.childrenIds?.length??0)+(r.dependsOn?.length??0)>0&&(S=!0);continue}let p=e=>_.has(e)?!0:_.size>=T?(S=!0,!1):(_.add(e),g.push({id:e,depth:n+1}),!0),m=(e,t,n,r)=>{if(!p(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&&f.add(`Job ${t} lists a child more than once`),C.size!==y.length&&f.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(p(e)){let n=`${e}->${t}`;u.has(n)||(u.add(n),c.push({from:e,to:t,kind:`depends`})),b.has(e)||m(e,t,`depends`,e)}}for(let[e,t]of o)!d.has(e)&&H(t).length>1&&f.add(`Job ${e} enables mutually exclusive failure policies`);for(let e of s){if(e.kind!==`child`||d.has(e.to))continue;let t=o.get(e.to);t&&t.parentId!==e.from&&f.add(`Child ${e.to} points to parent ${String(t.parentId??`none`)}, not ${e.from}`)}for(let[e,t]of o){if(d.has(e))continue;let n=t.childrenIds??[];if(n.some(e=>!o.has(e)||d.has(e)))continue;let r=n.map(t=>({childId:t,release:U(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`){p.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=U(o.get(i),e);if(n?.scope===`child`){p.add(`Parent ${e} is missing dependency ${i}; ${n.policy} may have released it, but the HTTP snapshot cannot prove whether the policy fired`);continue}f.add(`Parent ${e} lists child ${i} without the matching dependency`)}}for(let[e,t]of o){if(d.has(e)||!t.parentId)continue;let n=o.get(t.parentId);!n||d.has(t.parentId)||n.childrenIds?.includes(e)||f.add(`Parent ${t.parentId} does not list child ${e}`)}let C=B([...o.keys()],c);return{jobs:o,edges:s,truncated:S,failed:d.size,failures:d,issues:[...f],policyNotes:[...p],cycle:C,limitations:[...h]}}function W(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function ae(e,t){return e.x<=t.x?W(e.x+C,e.y+w/2,t.x,t.y+w/2):W(e.x,e.y+w/2,t.x+C,t.y+w/2)}function oe(e){return e instanceof h&&e.status===0||e.name===`TypeError`||e.name===`AbortError`||e.name===`TimeoutError`}function G(){let{token:e}=s.getState();return JSON.stringify([o(),e])}function K(){let[e,r]=n(),a=e.get(`root`)??(l()?O:``),c=s(e=>e.baseUrl),f=s(e=>e.token),h=o(),y=f.length===0,[b,D]=(0,v.useState)(a),[k,j]=(0,v.useState)(null),[M,N]=(0,v.useState)(null),[I,L]=(0,v.useState)(!1),[R,B]=(0,v.useState)(null),[V,H]=(0,v.useState)(()=>P(h,y)),U=(0,v.useRef)(0),W=(0,v.useRef)(null),K=(0,v.useRef)(!1),J=(0,v.useRef)(G()),Y=(0,v.useCallback)(async e=>{let t=s.getState();if(t.baseUrl!==c||t.token!==f)return;W.current?.abort(),W.current=null;let n=++U.current,r=e.trim();if(j(null),N(null),B(null),!r){L(!1);return}let i=z(r);if(i){B(new F(i)),L(!1);return}let a=m(),o=G(),l=s.getState().token.length===0,u=new AbortController;W.current=u;let d=()=>K.current&&n===U.current&&!u.signal.aborted&&o===G();L(!0);try{let e={target:a,signal:u.signal},t=await re(r,e),n=t.missingParent?[`Ancestor ${t.missingParent} is no longer available. Bunqueue may legitimately remove a completed flow root, so this graph starts at the oldest surviving node.`]:[],i=await ie(t.id,t.job,{...e,seedPath:t.path,limitations:n});if(!d())return;j(i),N(t.id),i.jobs.size>1&&H(e=>ne(a.baseUrl,e,{root:t.id,nodes:i.jobs.size,at:Date.now()},l))}catch(e){if(!d())return;B(e instanceof Error?e:Error(`Failed to load flow`))}finally{W.current===u&&(W.current=null),d()&&L(!1)}},[c,f]);(0,v.useEffect)(()=>{K.current=!0,J.current=G();let e=s.subscribe(()=>{let e=G();e!==J.current&&(J.current=e,U.current+=1,W.current?.abort(),W.current=null,K.current&&(j(null),N(null),B(null),L(!1)))});return()=>{K.current=!1,e(),U.current+=1,W.current?.abort(),W.current=null}},[]),(0,v.useEffect)(()=>{H(f?[]:P(h,!0))},[h,f]),(0,v.useEffect)(()=>{D(a),Y(a)},[a,Y]);let se=e=>{e.preventDefault();let t=b.trim();t&&(t===a?Y(t):r({root:t},{replace:!0}))},X=(0,v.useMemo)(()=>k?x([...k.jobs.keys()],k.edges,ee):null,[k]),Z=(0,v.useMemo)(()=>new Map(X?.nodes.map(e=>[e.id,e])??[]),[X]),Q=M?k?.jobs.get(M):void 0,$=M?k?.failures.get(M):void 0;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(p,{title:`Flows`,description:`Visualize a job flow: parent, children, and dependency edges as an interactive graph.`,actions:k&&(0,S.jsx)(`button`,{type:`button`,disabled:I,onClick:()=>void Y(a),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 disabled:opacity-50`,children:`Refresh`})}),(0,S.jsxs)(u,{className:`mb-6`,children:[(0,S.jsxs)(`form`,{onSubmit:se,className:`flex flex-wrap items-center gap-3`,children:[(0,S.jsx)(`input`,{name:`flow-job-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:b,onChange:e=>D(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,S.jsx)(`button`,{type:`submit`,disabled:I||!b.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:I?`Loading…`:`Load Flow`})]}),(0,S.jsxs)(`p`,{id:`flow-input-help`,className:`mt-2 text-xs text-faint`,children:[`Structural parent/child flows can start from any surviving node. Dependency-only chains can only be followed upstream with the v2.8.55 HTTP API, so use the most downstream job to see the full chain. Up to `,T,` nodes are rendered.`]})]}),(0,S.jsxs)(`div`,{"aria-live":`polite`,children:[R&&(oe(R)?(0,S.jsx)(g,{message:`Could not load the flow — ${R.message}`,onRetry:()=>void Y(a)}):(0,S.jsx)(_,{error:R,onRetry:()=>void Y(a)})),I&&(0,S.jsx)(d,{label:`Loading flow…`})]}),!I&&!k&&!R&&(0,S.jsx)(u,{children:(0,S.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,S.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,S.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID above, or open a job that is part of a flow and choose “View flow”.`}),V.length>0&&(0,S.jsxs)(`div`,{className:`mt-6`,children:[(0,S.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,S.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:V.map(e=>(0,S.jsxs)(`button`,{type:`button`,title:e.root,onClick:()=>{D(e.root),r({root:e.root},{replace:!0})},className:`min-h-10 rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted transition-colors hover:border-line-strong hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,S.jsx)(`span`,{translate:`no`,children:A(e.root)}),(0,S.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})}),k&&X&&(0,S.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1fr_260px]`,children:[(0,S.jsxs)(u,{padded:!1,className:`max-h-[70vh] overflow-auto overscroll-contain p-4`,children:[(0,S.jsx)(`h2`,{className:`sr-only`,children:`Flow Graph`}),(0,S.jsx)(`ul`,{className:`sr-only`,"aria-label":`Flow relationships`,children:k.edges.map(e=>(0,S.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,S.jsxs)(`div`,{className:`relative`,style:{width:X.width,height:X.height},children:[(0,S.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:X.width,height:X.height,children:[(0,S.jsxs)(`defs`,{children:[(0,S.jsx)(`marker`,{id:`flow-arrow-child`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,S.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})}),(0,S.jsx)(`marker`,{id:`flow-arrow-dependency`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,S.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})})]}),k.edges.map(e=>{let t=Z.get(e.from),n=Z.get(e.to);return!t||!n?null:(0,S.jsx)(`path`,{d:ae(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}`)})]}),X.nodes.map(e=>{let n=k.jobs.get(e.id),r=k.failures.has(e.id)?`unavailable`:n?.state??`unknown`;return(0,S.jsxs)(`button`,{type:`button`,"data-flow-node":e.id,onClick:()=>N(e.id),"aria-pressed":M===e.id,"aria-label":`${e.id}, queue ${n?.queue??`unknown`}, state ${r}`,title:e.id,style:{left:e.x,top:e.y,width:C,height:w},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left transition-shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/70`,te(n?.state),M===e.id&&`ring-2 ring-accent`),children:[(0,S.jsx)(`span`,{translate:`no`,className:`truncate font-mono text-xs text-fg`,children:A(e.id)}),(0,S.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,S.jsx)(`span`,{className:`truncate`,children:n?.queue??`—`}),(0,S.jsx)(`span`,{className:`font-medium`,children:r})]})]},e.id)})]})]}),(0,S.jsx)(`aside`,{"aria-label":`Selected job details`,"aria-live":`polite`,children:(0,S.jsxs)(u,{children:[Q?(0,S.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,S.jsx)(`div`,{translate:`no`,className:`break-all font-mono text-xs text-fg`,children:Q.id})]}),$&&(0,S.jsxs)(`p`,{role:`alert`,className:`break-words text-xs text-warning`,children:[`Snapshot unavailable: `,$]}),(0,S.jsx)(q,{label:`Queue`,value:Q.queue??`—`}),(0,S.jsx)(q,{label:`State`,value:$?`unavailable`:Q.state??`unknown`}),(0,S.jsx)(q,{label:`Priority`,value:Q.priority===void 0?`—`:String(Q.priority)}),(0,S.jsx)(q,{label:`Parent`,value:Q.parentId??`—`}),(0,S.jsx)(q,{label:`Children`,value:$?`—`:String(Q.childrenIds?.length??0)}),(0,S.jsx)(q,{label:`Depends On`,value:$?`—`:String(Q.dependsOn?.length??0)}),(0,S.jsx)(i,{to:`/job?id=${encodeURIComponent(Q.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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Open in Job Inspector`})]}):(0,S.jsx)(`p`,{className:`text-sm text-muted`,children:`Select a node to inspect it.`}),(0,S.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,"aria-live":`polite`,children:[k.truncated&&(0,S.jsxs)(`div`,{className:`mb-1 text-warning`,children:[`Graph truncated at `,T,` nodes / depth `,E,` — not the whole flow.`]}),k.limitations.length>0&&(0,S.jsxs)(`details`,{className:`mb-1 text-warning`,children:[(0,S.jsxs)(`summary`,{className:`cursor-pointer`,children:[k.limitations.length,` known snapshot limitation`,k.limitations.length===1?``:`s`]}),(0,S.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:k.limitations.map(e=>(0,S.jsx)(`li`,{className:`break-words`,children:e},e))})]}),k.failed>0&&(0,S.jsxs)(`details`,{className:`mb-1 text-warning`,children:[(0,S.jsxs)(`summary`,{className:`cursor-pointer`,children:[k.failed,` node`,k.failed===1?``:`s`,` couldn't be loaded — this is not the whole flow`]}),(0,S.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:[...k.failures].map(([e,t])=>(0,S.jsxs)(`li`,{className:`break-words`,children:[(0,S.jsx)(`span`,{translate:`no`,className:`font-mono`,children:e}),`: `,t]},e))})]}),k.cycle&&(0,S.jsxs)(`div`,{className:`mb-1 break-words text-danger`,children:[`Dependency cycle detected:`,` `,(0,S.jsx)(`span`,{translate:`no`,className:`font-mono`,children:k.cycle.join(` → `)}),`. This is not a valid atomic v2.8.55 flow.`]}),k.issues.length>0&&(0,S.jsxs)(`details`,{className:`mb-1 text-warning`,children:[(0,S.jsxs)(`summary`,{className:`cursor-pointer`,children:[k.issues.length,` `,k.issues.length===1?`possible snapshot inconsistency`:`possible snapshot inconsistencies`,` `,`detected (the flow may have changed during these requests)`]}),(0,S.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:k.issues.map(e=>(0,S.jsx)(`li`,{className:`break-words`,children:e},e))})]}),k.policyNotes.length>0&&(0,S.jsxs)(`details`,{className:`mb-1 text-muted`,children:[(0,S.jsxs)(`summary`,{className:`cursor-pointer`,children:[k.policyNotes.length,` failure-policy`,` `,k.policyNotes.length===1?`ambiguity`:`ambiguities`]}),(0,S.jsx)(`p`,{className:`mt-1`,children:`These are informational: the HTTP snapshot cannot prove whether a configured policy fired.`}),(0,S.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:k.policyNotes.map(e=>(0,S.jsx)(`li`,{className:`break-words`,children:e},e))})]}),(0,S.jsxs)(`div`,{className:`mb-1`,children:[k.jobs.size,` node`,k.jobs.size===1?``:`s`,` · `,k.edges.length,` `,`edge`,k.edges.length===1?``:`s`]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,S.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` `,`depends`]})]})]})]})})]})]})}function q({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,S.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e}),(0,S.jsx)(`span`,{className:`min-w-0 break-all text-right text-fg`,children:t})]})}export{K as Flows};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{f as t,g as n,l as r,r as i,t as a}from"./react-vendor-Bjui4wS4.js";import{i as o,o as s}from"./connectionStore-Cd9-3Fw0.js";import{a as c,n as l}from"./upstreamPaths-D_LPsv7b.js";import{C as u,J as d,O as f,S as p,T as m,a as h,b as ee,g,h as te,o as _,rt as v,st as y,v as ne,w as b,z as x}from"./index-CAtsVmyh.js";import{a as re,n as ie,o as S}from"./form-DsUq0w8s.js";import{r as C}from"./flowMutationSafety-CoOp94wS.js";import{n as w}from"./exportFile-C7xhE8Yh.js";import{t as T}from"./jobActions-LQD4KfCc.js";var E=e(n(),1);function D(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}}}var O=a(),k=365*24*60*60*1e3;function A(e,t){if(!e.trim())return{ok:!1,msg:`A value is required`};let n=Number(e);return Number.isFinite(n)?t===`progress`?n>=0&&n<=100?{ok:!0,value:n}:{ok:!1,msg:`Progress must be between 0 and 100`}:Number.isSafeInteger(n)?t===`priority`?n>=-1e6&&n<=1e6?{ok:!0,value:n}:{ok:!1,msg:`Priority must be between -1000000 and 1000000`}:n>=0&&n<=k?{ok:!0,value:n}:{ok:!1,msg:`Delay must be between 0 and ${k} ms`}:{ok:!1,msg:`Value must be a whole, safe integer`}:{ok:!1,msg:`Value must be a finite number`}}function ae({job:e,busy:t,act:n}){let r=T(e.state),i=r.promote||r.setPriority||r.setDelay||e.state===`active`;return(0,O.jsxs)(p,{children:[(0,O.jsx)(u,{title:`Actions`}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,O.jsx)(b,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>y.promoteJob(e.id)),children:`Promote (run now)`}),e.state===`failed`&&(0,O.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.8.57: its GET and retry POST have no atomic job-generation, state, or flow-topology precondition.`}),e.state===`completed`&&(0,O.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.8.57 because retry-completed re-inserts a child without rebuilding its flow dependency registration.`}),e.state===`active`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.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,O.jsx)(j,{label:`Set progress (0–100)`,cta:`Progress`,kind:`progress`,disabled:t,onSubmit:t=>n(`Progress`,()=>y.setJobProgress(e.id,t))})]}),r.setPriority&&(0,O.jsx)(M,{disabled:t,onSubmit:(t,r)=>n(`Priority`,()=>y.changePriority(e.id,t,r))}),r.setDelay&&(0,O.jsx)(j,{label:`Set delay (ms)`,cta:`Delay`,kind:`delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>y.changeDelay(e.id,t))}),(0,O.jsxs)(`p`,{role:`note`,className:`text-xs text-faint`,children:[`Cancel/delete/discard: `,C]}),!i&&(0,O.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function j({label:e,cta:t,kind:n,disabled:r,onSubmit:i}){let[a,o]=(0,E.useState)(``),s=A(a,n);return(0,O.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!r&&s.ok&&i(s.value)},children:[(0,O.jsx)(ie,{type:`number`,min:0,max:n===`progress`?100:k,step:n===`progress`?`any`:1,name:n===`progress`?`job-progress`:`job-delay`,value:a,onChange:e=>o(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,O.jsx)(b,{type:`submit`,size:`sm`,disabled:r||!s.ok,children:t}),!s.ok&&a.trim()&&(0,O.jsx)(`span`,{role:`alert`,className:`self-center text-[11px] text-danger`,children:s.msg})]})}function M({disabled:e,onSubmit:t}){let[n,r]=(0,E.useState)(``),[i,a]=(0,E.useState)(!1),o=A(n,`priority`);return(0,O.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault(),!e&&o.ok&&t(o.value,i)},children:[(0,O.jsx)(ie,{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,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(S,{checked:i,onChange:a,label:`Place first among equal priorities`}),(0,O.jsx)(`span`,{className:`text-xs text-muted`,children:`LIFO`})]}),(0,O.jsx)(b,{type:`submit`,size:`sm`,disabled:e||!o.ok,children:`Set`}),!o.ok&&n.trim()&&(0,O.jsx)(`span`,{role:`alert`,className:`w-full text-[11px] text-danger`,children:o.msg})]})}var N=36e5,oe=10,P=e=>Math.max(e,1);function se(e){return Math.max(0,(e.maxAttempts??0)-P(e.attempts??0))}function ce(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??N,a=r?.delay??e.backoff??1e3,o=[];for(let e=P(n);e<t&&o.length<oe;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function le({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,O.jsxs)(p,{children:[(0,O.jsx)(u,{title:`Backoff`}),(0,O.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,O.jsxs)(p,{children:[(0,O.jsx)(u,{title:`Backoff schedule`}),(0,O.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=se(e),o=ce(e);return(0,O.jsxs)(p,{children:[(0,O.jsx)(u,{title:`Backoff schedule`,action:(0,O.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${_(r.maxDelay)}`:``]})}),(0,O.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,O.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,O.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,O.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,_(e.delayMs)]})]},e.attempt))}),a>oe&&(0,O.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,oe,` of `,a,` remaining attempts.`]}),(0,O.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 `,_(r?.maxDelay??N),`.`]})]})}function ue({jobId:e}){let[t,n]=(0,E.useState)(!1),[r,i]=(0,E.useState)(!1),[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)(void 0),[l,d]=(0,E.useState)(null),f=async()=>{o(!0),d(null);try{let t=await y.jobChildren(e);c(t.data?.values),i(!0)}catch(e){d(e.message)}finally{o(!1)}},m=()=>{let e=!t;n(e),e&&!r&&!a&&f()},h=s&&typeof s==`object`?Array.isArray(s)?s.length:Object.keys(s).length:0;return(0,O.jsxs)(p,{children:[(0,O.jsx)(u,{title:`Child values`,action:(0,O.jsx)(b,{size:`sm`,variant:`ghost`,onClick:m,children:t?`Hide`:`Show`})}),t?a?(0,O.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):l?(0,O.jsx)(`p`,{className:`text-xs text-danger`,children:l}):h===0?(0,O.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,O.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,O.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function de({data:e,busy:t,editable:n,readOnlyReason:r,onSave:i}){let[a,o]=(0,E.useState)(()=>JSON.stringify(e??null,null,2)),[s,c]=(0,E.useState)(null),l=(0,E.useRef)(a);return(0,E.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,o(t),c(null))},[e]),(0,O.jsxs)(p,{children:[(0,O.jsx)(u,{title:`Data`,action:n?(0,O.jsx)(b,{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,O.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,O.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,O.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:s})]})}function fe(e){return e===`waiting`||e===`prioritized`||e===`delayed`}var F=[`__parentId`,`__parentQueue`,`__childrenIds`,`__flowParentId`,`__flowParentIds`];function pe(e,t){if(!fe(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)&&F.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.8.57 replaces the full payload and would remove structural metadata.`:null}var me=3e4;function I(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function he(e,t){return e.baseUrl===t.baseUrl&&e.authorization===t.authorization}function ge(e,t,n){return t.aborted&&!n.aborted?new v(`Request timed out`,0):e}async function L(e,t,n,r){let i=AbortSignal.timeout(me),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 ge(e,i,r)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw ge(e,i,r)}let l,u=!1;if(c)try{l=JSON.parse(c)}catch{u=!0}if(!s.ok){let t=!u&&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 v(typeof t==`string`?t:`HTTP ${s.status}`,s.status)}if(c){if(u)throw new v(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new v(typeof e==`string`?e:`Operation failed`,s.status)}return l}}function R(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new v(`Invalid logs response: expected an object envelope`,200);let t=e;if(t.ok!==!0||!t.data||typeof t.data!=`object`)throw new v(`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 v(`Invalid logs response: expected logs[] and a non-negative count`,200);return{logs:n.logs,count:n.count}}function _e({jobId:e}){let t=s(e=>e.baseUrl),n=s(e=>e.token),[r,i]=(0,E.useState)([]),[a,l]=(0,E.useState)(0),[d,f]=(0,E.useState)(!1),[m,h]=(0,E.useState)(null),[ee,g]=(0,E.useState)(``),[te,_]=(0,E.useState)(`info`),[y,ne]=(0,E.useState)(!1),x=(0,E.useRef)(!1),S=(0,E.useRef)(null),C=(0,E.useRef)(0),w=(0,E.useRef)(null),T=(0,E.useRef)(0),D=(0,E.useRef)(null),k=(0,E.useRef)(!1),A=(0,E.useRef)(0);(0,E.useEffect)(()=>{x.current=!0,S.current=e;let t=()=>{C.current+=1,w.current?.abort(),w.current=null,T.current+=1,D.current?.abort(),D.current=null,k.current=!1,A.current+=1,i([]),l(0),f(!1),h(null),g(``),ne(!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,D.current?.abort(),D.current=null,k.current=!1}},[e]);let ae=(0,E.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}:I()),m=()=>x.current&&S.current===e&&u===C.current&&!a.signal.aborted&&he(p,I());f(!0),h(null);try{let t=R(await L(p,`/jobs/${c(e)}/logs`,{},a.signal));return m()?(i(t.logs),l(t.count),!0):!1}catch(e){if(!m())return!1;let t=e instanceof Error?e.message:String(e);return h(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,E.useEffect)(()=>{ae()},[ae]);let j=async(t,n,r)=>{if(k.current)return;k.current=!0;let i=new AbortController;D.current=i;let a=++T.current,o=I();C.current+=1,w.current?.abort(),w.current=null,f(!1),ne(!0),h(null);let s=()=>x.current&&S.current===e&&a===T.current&&!i.signal.aborted&&he(o,I());try{let a=await L(o,`/jobs/${c(e)}/logs`,t,i.signal);if(!a||typeof a!=`object`||Array.isArray(a)||a.ok!==!0)throw new v(`Invalid log mutation response: expected { ok: true }`,200);if(!s())return;r(),await ae({acceptedLabel:n,target:o})}catch(e){s()&&h(e instanceof Error?e.message:String(e))}finally{a===T.current&&(k.current=!1,D.current===i&&(D.current=null),x.current&&ne(!1))}},M=async(e=ee,t=te)=>{if(k.current)return;let n=e.trim();if(!n)return;let r=t===`warn`||t===`error`?t:`info`,i=A.current;g(e),_(r),await j({method:`POST`,body:JSON.stringify({message:n,level:r})},`Log addition`,()=>{A.current===i&&g(``)})};return(0,O.jsxs)(p,{children:[(0,O.jsx)(u,{title:`Logs`,action:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:a}),(0,O.jsx)(b,{size:`sm`,variant:`ghost`,disabled:d||y,onClick:()=>void ae(),children:`Refresh`}),(0,O.jsx)(b,{size:`sm`,variant:`danger`,disabled:y||r.length===0,onClick:async()=>{k.current||window.confirm(`Clear all logs for this job?`)&&await j({method:`DELETE`},`Log clearing`,()=>{i([]),l(0)})},children:`Clear logs`})]})}),m&&(0,O.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:m}),r.length===0?(0,O.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,O.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:r.map((e,t)=>(0,O.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,O.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:e=>{e.preventDefault();let t=e.currentTarget.elements.namedItem(`job-log-message`),n=e.currentTarget.elements.namedItem(`job-log-level`);M(t?.value??ee,n?.value??te)},children:[(0,O.jsx)(ie,{"aria-label":`Log message`,name:`job-log-message`,autoComplete:`off`,value:ee,onInput:e=>{A.current+=1,g(e.currentTarget.value)},placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,O.jsxs)(re,{"aria-label":`Log level`,name:`job-log-level`,value:te,onChange:e=>{A.current+=1,_(e.target.value)},className:`h-8 w-24 text-xs`,children:[(0,O.jsx)(`option`,{value:`info`,children:`info`}),(0,O.jsx)(`option`,{value:`warn`,children:`warn`}),(0,O.jsx)(`option`,{value:`error`,children:`error`})]}),(0,O.jsx)(b,{type:`submit`,size:`sm`,disabled:y||ee.trim()===``,children:`Add`})]})]})}function ve({timeline:e}){let t=e??[];return(0,O.jsxs)(p,{children:[(0,O.jsx)(u,{title:`Timeline`}),t.length===0?(0,O.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,O.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,O.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(g,{status:e.state}),e.attempt!=null&&(0,O.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,O.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:h(e.timestamp)})]}),(e.worker||e.error)&&(0,O.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,O.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,O.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}var z=3e4;function B(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function V(e,t){return e?.baseUrl===t.baseUrl&&e.authorization===t.authorization}function H(e,t,n){return t.aborted&&!n?.aborted?new v(`Request timed out`,0):e}async function ye(e,t,n,r=z){let i=AbortSignal.timeout(r),a=n?AbortSignal.any([n,i]):i,o=new Headers;e.authorization&&o.set(`Authorization`,e.authorization);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{headers:o,signal:a}),a.throwIfAborted()}catch(e){throw H(e,i,n)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw H(e,i,n)}let l,u=!1;if(c)try{l=JSON.parse(c)}catch{u=!0}if(!s.ok){let t=!u&&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 v(n,s.status)}if(c){if(u)throw new v(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new v(typeof e==`string`?e:`Operation failed`,s.status)}return l}}function U(e){throw new v(`Invalid job response: ${e}`,200)}function W(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())&&U(`${i}.${t} must be ${n?`a string or null`:`a string`}${r?` (non-empty)`:``}`)}function G(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)&&U(`${o}.${t} must be a valid${r?` safe integer`:` finite number`}`)}function K(e,t){Object.hasOwn(e,t)&&e[t]!==void 0&&typeof e[t]!=`boolean`&&U(`job.${t} must be a boolean`)}function q(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()))&&U(`job.${t} must be ${n?`a string array or null`:`a string array`}`)}var J=1e4,Y=100,X=256*1024;function Z(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 be(e){let t=[],n=0,r=!1,i=Math.min(e.length,Y);for(let a=0;a<i;a++){let i=+(t.length>0),o=X-n-i;if(o<=0){r=!0;break}let s=e[a]??``,c=Z(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 xe(e,t){if(t&&(typeof e.state!=`string`||!e.state.trim())&&U(`canonical job.state must be a non-empty string`),W(e,`state`,{nonEmpty:!0}),W(e,`name`,{nonEmpty:!0}),W(e,`failedReason`),t&&(typeof e.queue!=`string`||!e.queue.trim())&&U(`canonical job.queue must be a non-empty string`),W(e,`queue`,{nonEmpty:!0}),W(e,`customId`,{nullable:!0}),W(e,`parentId`,{nullable:!0,nonEmpty:!0}),W(e,`groupId`,{nullable:!0}),W(e,`progressMessage`,{nullable:!0}),q(e,`childrenIds`,{nonEmpty:!0}),q(e,`dependsOn`,{nonEmpty:!0}),q(e,`tags`),q(e,`stacktrace`,{nullable:!0}),Array.isArray(e.stacktrace)&&e.stacktrace.length>J&&U(`job.stacktrace exceeds Bunqueue's ${J}-entry limit`),G(e,`priority`,{integer:!0}),G(e,`createdAt`),G(e,`runAt`),G(e,`startedAt`,{nullable:!0}),G(e,`completedAt`,{nullable:!0}),G(e,`attempts`,{integer:!0,min:0}),G(e,`maxAttempts`,{integer:!0,min:0}),G(e,`backoff`,{integer:!0,min:0}),G(e,`timeout`,{nullable:!0,integer:!0,min:0}),G(e,`ttl`,{nullable:!0,integer:!0,min:0}),G(e,`progress`,{min:0,max:100}),G(e,`lastHeartbeat`),G(e,`stallCount`,{integer:!0,min:0}),K(e,`removeOnComplete`),K(e,`removeOnFail`),Object.hasOwn(e,`backoffConfig`)&&e.backoffConfig!==void 0){let t=e.backoffConfig;if(t!==null){(!t||typeof t!=`object`||Array.isArray(t))&&U(`job.backoffConfig must be an object or null`);let e=t;e.type!==`fixed`&&e.type!==`exponential`&&U(`job.backoffConfig.type must be fixed or exponential`),G(e,`delay`,{integer:!0,min:0},`job.backoffConfig`),(!Object.hasOwn(e,`delay`)||e.delay===void 0)&&U(`job.backoffConfig.delay is required`),G(e,`maxDelay`,{integer:!0,min:0},`job.backoffConfig`)}}if(Object.hasOwn(e,`timeline`)&&e.timeline!==void 0){Array.isArray(e.timeline)||U(`job.timeline must be an array`),e.timeline.length>20&&U(`job.timeline exceeds 20 entries`);for(let[t,n]of e.timeline.entries()){(!n||typeof n!=`object`||Array.isArray(n))&&U(`job.timeline[${t}] must be an object`);let e=n;(typeof e.state!=`string`||!e.state.trim())&&U(`job.timeline[${t}].state must be a non-empty string`),(typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp))&&U(`job.timeline[${t}].timestamp must be a finite number`);let r=`job.timeline[${t}]`;W(e,`worker`,{},r),W(e,`error`,{},r),G(e,`attempt`,{integer:!0,min:0},r)}}}function Se(e,{canonical:t,expectedId:n}){if(!e||typeof e!=`object`||Array.isArray(e))return U(`expected an object envelope`);let r=e;if(r.ok!==!0||!Object.hasOwn(r,`job`))return U(`expected { ok: true, job }`);if(r.job===null)return null;if(!r.job||typeof r.job!=`object`||Array.isArray(r.job))return U(`job must be an object or null`);let i=r.job;return typeof i.id!=`string`||!i.id.trim()?U(`job.id must be a non-empty string`):n!==void 0&&i.id!==n?U(`expected job.id ${JSON.stringify(n)}`):(xe(i,t),i)}function Ce(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw new v(`Invalid job result response: expected an object envelope`,200);let n=e;if(n.ok!==!0||n.id!==t)throw new v(`Invalid job result response: expected { ok: true, id, result? }`,200);return{result:n.result}}async function we(e,t,n={}){let r=n.target??B(),i=n.timeoutMs??z,a=Se(await ye(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});return!a||t===`id`?a:a.customId===e?Se(await ye(r,`/jobs/${c(a.id)}`,n.signal,i),{canonical:!0,expectedId:a.id}):U(`expected job.customId ${JSON.stringify(e)}`)}function Te(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 Ee(){let e=r(),[n,a]=t(),l=s(e=>e.baseUrl),m=s(e=>e.token),ie=n.get(`custom`),[S,C]=(0,E.useState)(ie??n.get(`id`)??``),[T,k]=(0,E.useState)(ie?`custom`:`id`),[A,j]=(0,E.useState)(null),[M,N]=(0,E.useState)({fetched:!1,value:void 0}),[oe,P]=(0,E.useState)(null),[se,ce]=(0,E.useState)(!1),[fe,F]=(0,E.useState)(!1),[me,I]=(0,E.useState)(null),[he,ge]=(0,E.useState)(!1),L=(0,E.useRef)(0),R=(0,E.useRef)(null),z=(0,E.useRef)(null),H=(0,E.useRef)(null),U=(0,E.useRef)(!1),W=(0,E.useRef)(null),G=(0,E.useRef)(!1),K=(0,E.useRef)(0),q=(0,E.useRef)(!1),J=(0,E.useRef)(null);(0,E.useEffect)(()=>{G.current=!0;let e=s.subscribe((e,t)=>{e.baseUrl===t.baseUrl&&e.token===t.token||(L.current+=1,R.current?.abort(),R.current=null,z.current=null,K.current+=1,J.current=null,q.current=!1,H.current=null,U.current=!1,W.current=null,j(null),N({fetched:!1,value:void 0}),P(null),F(!1),I(null),ce(!1),ge(!1))});return()=>{G.current=!1,e(),L.current+=1,R.current?.abort(),R.current=null,z.current=null,K.current+=1,J.current=null,q.current=!1}},[]);let Y=async(e,t=T,n=!1,r,i=!1)=>{let o=e.trim();if(!o||r===void 0&&q.current&&!i)return;U.current=!1,W.current=null,r===void 0&&(K.current+=1),A!==null&&(t===`id`?A.id!==o:A.customId!==o)&&(H.current=null,j(null),N({fetched:!1,value:void 0}),P(null)),R.current?.abort();let s=new AbortController;R.current=s,z.current={key:o,mode:t};let l=++L.current,u=B();ce(!0),F(!1),n||I(null);try{let e=await we(o,t,{signal:s.signal,target:u});if(!e){if(l!==L.current)return;U.current=!0,W.current=null,j(null),N({fetched:!1,value:void 0}),P(null),F(!0),a({},{replace:!0});return}let n=null,r=null;if(l!==L.current||s.signal.aborted||!V(u,B()))return;if(e.state===`completed`)if(Object.hasOwn(e,`returnvalue`))n={result:e.returnvalue};else try{n=Ce(await ye(u,`/jobs/${c(e.id)}/result`,s.signal),e.id)}catch(e){if(s.signal.aborted)throw e;r=e.message}if(l!==L.current||s.signal.aborted||!V(u,B()))return;H.current=u,j(e),t===`custom`?(k(`id`),C(e.id)):C(o),a({id:e.id},{replace:!0}),N(n?{fetched:!0,value:n.result}:{fetched:!1,value:void 0}),P(r)}catch(e){if(l!==L.current||s.signal.aborted)return;e instanceof v&&(e.status===404||/not found/i.test(e.message))?(U.current=!0,W.current=null,j(null),N({fetched:!1,value:void 0}),P(null),F(!0),a({},{replace:!0})):I(n?t=>t?{ok:t.ok,text:`${t.text} — couldn't reload: ${e.message}`}:{ok:!1,text:e.message}:{ok:!1,text:e.message})}finally{l===L.current&&(R.current===s&&(R.current=null,z.current=null),ce(!1))}},X=n.get(`id`),Z=n.get(`custom`),xe={baseUrl:o(),authorization:m?`Bearer ${m}`:void 0},Se=V(H.current,xe);(0,E.useEffect)(()=>{if(U.current){!X&&!Z&&(U.current=!1,W.current=e.key);return}if(!(!X&&!Z&&W.current===e.key))if(W.current=null,Z)if(A?.customId===Z&&Se)k(`id`),C(A.id),a({id:A.id},{replace:!0});else{k(`custom`),C(Z);let e=z.current;(e?.mode!==`custom`||e.key!==Z)&&Y(Z,`custom`,!1,void 0,!0)}else if(X&&(X!==A?.id||!Se)){k(`id`),C(X);let e=z.current;(e?.mode!==`id`||e.key!==X)&&Y(X,`id`,!1,void 0,!0)}else!X&&!Z&&(L.current+=1,R.current?.abort(),R.current=null,z.current=null,K.current+=1,H.current=null,j(null),N({fetched:!1,value:void 0}),P(null),F(!1),I(null),ce(!1),k(`id`),C(``))},[X,Z,A?.id,A?.customId,Se,e.key,l,m]);let Ee=(e,t=T)=>{let n=e.trim();if(!(!n||q.current)){if(t===`id`?X===n&&Z===null:Z===n&&X===null){Y(n,t);return}a(t===`custom`?{custom:n}:{id:n})}},ke=async(e,t,n)=>{if(!A||q.current||R.current)return;let r=B();if(!V(H.current,r)||n&&!window.confirm(n))return;let i=++K.current,o=A.id;J.current=i,q.current=!0,ge(!0),I(null);let s=()=>G.current&&i===K.current&&V(r,B())&&V(H.current,r);try{let n=await t();if(!n||typeof n!=`object`||Array.isArray(n)||n.ok!==!0)throw new v(`Invalid job mutation response: expected { ok: true }`,200);if(!s())return;I({ok:!0,text:`${e} ✓`}),e===`Cancel`?(U.current=!0,W.current=null,L.current+=1,H.current=null,j(null),N({fetched:!1,value:void 0}),P(null),a({},{replace:!0})):await Y(o,`id`,!0,i)}catch(e){s()&&I({ok:!1,text:e.message})}finally{J.current===i&&(J.current=null,q.current=!1,G.current&&ge(!1))}},Ae=A?.state,$=A?Te(A):null,je=A?.stacktrace?.length?be(A.stacktrace):null,Me=je!==null,Ne=(A?.childrenIds?.length??0)>0,Pe=A?pe(Ae,A):null,Fe=Ae===`failed`,Ie=A&&($||Me)?(0,O.jsxs)(p,{children:[(0,O.jsx)(u,{title:`Error`}),$&&(0,O.jsxs)(`div`,{className:`mb-3`,children:[(0,O.jsx)(`p`,{className:`text-sm text-danger`,children:$.message}),(0,O.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[$.attempt==null?``:`Attempt ${$.attempt} · `,h($.timestamp)]})]}),je&&(0,O.jsxs)(O.Fragment,{children:[(0,O.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:je.text}),je.truncated&&(0,O.jsxs)(`p`,{className:`mt-2 text-xs text-faint`,children:[`Stack preview truncated (`,je.displayedLines,` of `,je.totalLines,` `,`lines, 262,144 characters maximum). Download JSON for the complete stored stack.`]})]})]}):null;return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(te,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:A?(0,O.jsxs)(O.Fragment,{children:[(Ne||A.parentId)&&(0,O.jsx)(i,{to:`/flows?root=${encodeURIComponent(A.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,O.jsx)(i,{to:`/add-job`,state:D(A),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,O.jsxs)(b,{size:`sm`,onClick:()=>w(`job-${A.id}`,M.fetched?{...A,result:M.value}:A),children:[(0,O.jsx)(x,{className:`size-3.5`}),` Download JSON`]})]}):void 0}),(0,O.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,O.jsxs)(re,{name:`job-lookup-mode`,autoComplete:`off`,value:T,"aria-label":`Lookup mode`,onChange:e=>k(e.target.value),className:`w-40`,children:[(0,O.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,O.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,O.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,O.jsx)(d,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,O.jsx)(`input`,{value:S,"aria-label":T===`custom`?`Custom job ID`:`Job ID`,name:`job-lookup-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,onInput:e=>C(e.currentTarget.value),onKeyDown:e=>e.key===`Enter`&&Ee(S),placeholder:T===`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,O.jsx)(b,{variant:`accent`,disabled:se||he,onClick:()=>Ee(S),children:`Look up`})]}),me&&(0,O.jsx)(`div`,{role:`status`,className:me.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:me.text}),se&&!A?(0,O.jsx)(ee,{label:`Loading job…`}):fe?(0,O.jsx)(ne,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`}):A?(0,O.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,O.jsxs)(p,{children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:A.id}),(0,O.jsx)(f,{value:A.id})]}),(0,O.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:A.queue})]}),(0,O.jsx)(g,{status:Ae??`unknown`})]}),(0,O.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,O.jsx)(Q,{k:`Priority`,v:String(A.priority??0)}),(0,O.jsx)(Q,{k:`Name`,v:A.name??`default`}),(0,O.jsx)(Q,{k:`Attempts`,v:`${A.attempts??0} / ${A.maxAttempts??`?`}`}),(0,O.jsx)(Q,{k:`Progress`,v:`${A.progress??0}%`}),(0,O.jsx)(Q,{k:`Created`,v:h(A.createdAt)}),(0,O.jsx)(Q,{k:`Started`,v:h(A.startedAt??void 0)}),(0,O.jsx)(Q,{k:`Completed`,v:h(A.completedAt??void 0)}),(0,O.jsx)(Q,{k:`Duration`,v:_(A.startedAt&&A.completedAt?A.completedAt-A.startedAt:void 0)}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,O.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,O.jsx)(`span`,{className:`truncate font-mono`,children:A.customId??`—`}),A.customId&&(0,O.jsx)(f,{value:A.customId})]})]})]})]}),Fe&&Ie,(0,O.jsx)(de,{data:A.data,busy:he,editable:Pe===null,readOnlyReason:Pe??void 0,onSave:e=>ke(`Data`,()=>y.updateJobData(A.id,e))},`data-${A.id}`),Ae===`completed`&&(0,O.jsxs)(p,{children:[(0,O.jsx)(u,{title:`Result`,action:M.fetched&&M.value!==void 0&&M.value!==null?(0,O.jsx)(Oe,{value:M.value,filename:`job-${A.id}-result`}):void 0}),M.fetched&&M.value!==void 0&&M.value!==null?(0,O.jsx)(De,{value:M.value}):oe?(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsxs)(`p`,{className:`text-xs text-danger`,children:[`Couldn't load result — `,oe]}),(0,O.jsx)(b,{size:`sm`,disabled:se,onClick:()=>Y(A.id,`id`),children:`Retry`})]}):(0,O.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]}),!Fe&&Ie,(0,O.jsx)(_e,{jobId:A.id},`logs-${A.id}`),Ne&&(0,O.jsx)(ue,{jobId:A.id},`children-${A.id}`),(0,O.jsx)(ve,{timeline:A.timeline}),(0,O.jsx)(le,{job:A})]}),(0,O.jsx)(`div`,{className:`order-first lg:order-none`,children:(0,O.jsx)(ae,{job:A,busy:he,act:ke})})]}):(0,O.jsx)(ne,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`})]})}function Q({k:e,v:t}){return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,O.jsx)(`dd`,{className:`text-fg`,children:t})]})}function De({value:e}){return(0,O.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 Oe({value:e,filename:t}){return(0,O.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(f,{value:JSON.stringify(e??null,null,2)}),(0,O.jsx)(m,{"aria-label":`Download JSON`,title:`Download JSON`,onClick:()=>w(t,e??null),children:(0,O.jsx)(x,{className:`size-3.5`})})]})}export{Ee as JobInspector};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{f as t,g as n,r,t as i}from"./react-vendor-Bjui4wS4.js";import{A as a,J as o,b as s,c,f as l,g as u,h as d,j as f,l as p,m,n as h,o as g,st as _,u as v,x as y}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{f as t,g as n,r,t as i}from"./react-vendor-Bjui4wS4.js";import{A as a,J as o,b as s,c,f as l,g as u,h as d,j as f,l as p,m,n as h,o as g,st as _,u as v,x as y}from"./index-CAtsVmyh.js";import{a as b,i as ee}from"./form-DsUq0w8s.js";import{r as te}from"./flowMutationSafety-CoOp94wS.js";import{t as ne}from"./promisePool-BVfQ9n9Q.js";var x=e(n(),1),S=i(),C=`__all__`,w=[`all`,`waiting`,`active`,`completed`,`failed`],T=500,E=40,D=8,O=100,k=20,A=T*k;function j(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>A||n!==null&&e.total!==n||e.offset!==t||e.limit!==T||e.queues.length!==Math.min(T,e.total-t)||e.queues.length>T||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 M(){let e=await f.queues(T,0);j(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>=k||t.length>=A)throw Error(`Queue discovery exceeds the safety limit of ${A}`);let e=t.length,a=await f.queues(T,e);j(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 N(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}function P(){let[e]=t(),[n,i]=(0,x.useState)(e.get(`queue`)??C),[T,k]=(0,x.useState)(`all`),[A,j]=(0,x.useState)(``),{data:P,error:F,refetch:I}=a(M,[],{intervalMs:3e4}),{data:L,error:R,refetch:z}=a(()=>f.overview(),[]),B=(0,x.useMemo)(()=>(P?.queues??[]).map(e=>e.name),[P]),V=`${n}\u0000${T}\u0000${JSON.stringify(B)}`,{data:H,error:U,loading:W,refetch:G}=a((0,x.useCallback)(async e=>{if(n===C&&!P)return null;let t=n===C?B:[n];if(n===C&&t.length>100)return{scopeKey:V,jobs:[],failures:[],queueCount:t.length,blockedReason:`All-queue job browsing is limited to 100 queues; ${c(t.length)} were discovered. Select one queue to avoid an unsafe request fan-out.`};let r=T===`all`?void 0:[T],i=_.createServerTargetClient(_.captureServerRequestTarget(),e),a=await ne(t,D,async t=>(e.throwIfAborted(),(await i.jobsList(t,r,E)).jobs.map(e=>({...e,stacktrace:e.stacktrace??void 0,queue:e.queue??t}))),e);e.throwIfAborted();let o=[],s=[];return a.forEach((e,n)=>{e.status===`fulfilled`?o.push(...e.value):s.push({queue:t[n],message:e.reason instanceof Error?e.reason.message:String(e.reason)})}),{scopeKey:V,jobs:o.sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)),failures:s,queueCount:t.length,blockedReason:null}},[n,T,P,B,V]),[V],{intervalMs:15e3}),K=H?.scopeKey===V?H:null,q=K?.blockedReason?null:K?.jobs??null,{rows:J,matchingCount:Y}=(0,x.useMemo)(()=>{let e=q??[],t=A.trim().toLowerCase(),n=t?e.filter(e=>typeof e.id==`string`&&e.id.toLowerCase().includes(t)||(N(e.data)?.toLowerCase().includes(t)??!1)):e;return{rows:n.slice(0,O),matchingCount:n.length}},[q,A]),X=L?.stats,Z=X?h(X.totalCompleted,X.totalFailed):null,Q=e=>X?c(e):`—`,re=!!K&&K.queueCount>0&&K.failures.length===K.queueCount,ie=n===C&&!P&&!F||W&&!K&&!U,$=`No jobs found.`;return K?.blockedReason?$=K.blockedReason:n===C&&F&&!P?$=`Queue discovery unavailable — ${F.message}`:U&&!K?$=`Could not load jobs — ${U.message}`:re?$=`Could not load jobs from any of the ${K.queueCount} queues.`:A.trim()&&K?.failures.length?$=`No matching jobs in the queue results that could be loaded.`:A.trim()&&($=`No jobs match this search.`),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(d,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!K&&!F&&!R&&!U&&!K.blockedReason&&K.failures.length===0}),F&&(0,S.jsx)(y,{message:`Queue discovery unavailable — ${F.message}`,onRetry:I}),R&&(0,S.jsx)(y,{message:`Job totals unavailable — ${R.message}`,onRetry:z}),U&&(0,S.jsx)(y,{message:`Could not load jobs — ${U.message}`,onRetry:G}),K?.blockedReason&&(0,S.jsx)(y,{message:K.blockedReason}),!!K?.failures.length&&(0,S.jsx)(y,{message:`Could not load jobs from ${K.failures.length} of ${K.queueCount} queues: ${K.failures.slice(0,3).map(e=>`${e.queue} (${e.message})`).join(`, `)}${K.failures.length>3?`, …`:``}`,onRetry:G}),(0,S.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,S.jsx)(m,{label:`Total`,value:X?c(X.totalCompleted+X.totalFailed+X.waiting+X.active):`—`,compact:!0}),(0,S.jsx)(m,{label:`Waiting`,value:Q(X?.waiting),tone:`amber`,compact:!0}),(0,S.jsx)(m,{label:`Active`,value:Q(X?.active),tone:`blue`,compact:!0}),(0,S.jsx)(m,{label:`Completed`,value:Q(X?.totalCompleted),tone:`green`,compact:!0}),(0,S.jsx)(m,{label:`Failed`,value:Q(X?.totalFailed),tone:X?.totalFailed?`red`:`default`,compact:!0}),(0,S.jsx)(m,{label:`Error Rate`,value:Z==null?`—`:p(Z),tone:Z==null?`default`:Z>.05?`red`:`green`,compact:!0})]}),(0,S.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`w-48`,children:(0,S.jsxs)(b,{value:n,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>i(e.target.value),children:[(0,S.jsx)(`option`,{value:C,children:`All Queues`}),(P?.queues??[]).map(e=>(0,S.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,S.jsx)(ee,{options:w,value:T,onChange:k}),(0,S.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,S.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,S.jsx)(`input`,{value:A,onChange:e=>j(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`})]})]}),K&&!K.blockedReason&&(0,S.jsxs)(`p`,{role:`status`,className:`mb-3 text-xs text-faint`,children:[n===C?`Queried all ${c(K.queueCount)} discovered queues`:`Queried ${n}`,` `,`· up to `,E,` recent jobs per queue`,Y>O?` · showing the newest ${O} of ${c(Y)} matches`:``]}),ie?(0,S.jsx)(s,{label:`Loading jobs…`}):(0,S.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,S.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,S.jsx)(`tbody`,{children:J.length===0?(0,S.jsx)(`tr`,{children:(0,S.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:$})}):J.map(e=>(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,S.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,S.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??N(e.data)??`default`}),(0,S.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,S.jsx)(`td`,{className:`px-5 py-3`,children:(0,S.jsx)(u,{status:String(e.state??e.status??`waiting`)})}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:v(e.createdAt)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:g(l(e.startedAt??void 0,e.completedAt??void 0))}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,S.jsx)(`span`,{className:`text-xs text-faint`,title:te,children:`Delete unavailable`})})]},`${e.queue}:${e.id}`))})]})})]})}export{P as Jobs,M as discoverAllQueues};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-Bjui4wS4.js";import{A as o,B as s,J as c,T as ee,W as te,a as ne,b as l,c as u,ft as d,g as re,h as ie,l as ae,m as f,n as oe,o as se,st as p,w as m,x as h,y as ce,z as le}from"./index-CAtsVmyh.js";import{a as g}from"./form-DsUq0w8s.js";import{t as ue}from"./Pagination-Bfi4vkpp.js";import{r as de,t as _}from"./useServerActionGuard-CItj3hvh.js";import{t as fe}from"./exportFile-C7xhE8Yh.js";import{t as v}from"./jobActions-LQD4KfCc.js";var y=e(r(),1),b=a(),x=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`],S=25;function pe(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function me(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function he(e=0){return e>=10?{t:`HIGH`,c:`text-warning`}:e>=1?{t:`MEDIUM`,c:`text-blue-400`}:{t:`LOW`,c:`text-faint`}}function C(){let[e,r]=n(),[a,C]=(0,y.useState)(e.get(`queue`)??``),[w,ge]=(0,y.useState)(()=>{let t=e.get(`status`);return t&&x.includes(t)?t:`all`}),[T,_e]=(0,y.useState)(``),[E,D]=(0,y.useState)(0),[O,k]=(0,y.useState)(new Set),[ve,A]=(0,y.useState)(new Set),[j,M]=(0,y.useState)(!1),[N,P]=(0,y.useState)(null),{data:F,error:I,loading:ye,refetch:be}=o(()=>p.queuesSummary(),[],{intervalMs:3e4}),{data:L,error:R,refetch:xe}=o(()=>p.stats(),[],{intervalMs:1e4});(0,y.useEffect)(()=>{!a&&F?.length&&C(F[0].name)},[F,a]);let z=`${a}|${w}|${E}`,B=de(`jobs:${a}`),{data:V,error:H,loading:Se,refetch:U}=o((0,y.useCallback)(async()=>{if(!a)return{view:z,jobs:[]};let e=w===`all`?void 0:[w],t=await p.jobsList(a,e,S,E*S);return{view:z,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??a}))}},[a,w,E,z]),[a,w,E]),W=V&&V.view===z?V.jobs:null;(0,y.useEffect)(()=>{A(new Set),M(!1),P(null)},[B.scopeKey]);let Ce=(W?.length??0)===S,G=(0,y.useMemo)(()=>{let e=T.trim().toLowerCase();return e?(W??[]).filter(t=>t.id.toLowerCase().includes(e)||t.name?.toLowerCase().includes(e)):W??[]},[W,T]),K=L?.stats,q=(0,y.useMemo)(()=>F?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[F]),J=K&&q!=null?oe(K.completed,q):null,Y=e=>K?u(e):`—`,X=()=>D(0),we=(e,t)=>{let n={};e&&(n.queue=e),t!==`all`&&(n.status=t),r(n,{replace:!0})};(0,y.useEffect)(()=>{k(new Set)},[a,w,E]);let Te=e=>k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Z=G.length>0&&G.every(e=>O.has(e.id)),Ee=()=>k(()=>Z?new Set:new Set(G.map(e=>e.id))),De=async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let i=B.begin(`job:${e.id}`);if(i){A(t=>new Set(t).add(e.id)),P(null);try{if(_(await n(),t),!i.isCurrent())return;P({ok:!0,text:`${t} ✓`}),d.success(`${t} ✓`,e.id),U()}catch(e){if(!i.isCurrent())return;P({ok:!1,text:`${t} failed: ${e.message}`}),d.error(`${t} failed`,e.message)}finally{i.finish()&&A(t=>{let n=new Set(t);return n.delete(e.id),n})}}},Oe=async(e,t,n,r)=>{let i=G.filter(e=>O.has(e.id)&&n(e));if(i.length===0||r&&!window.confirm(r(i.length)))return;let a=B.begin([`bulk`,...i.map(e=>`job:${e.id}`)]);if(a){M(!0),P(null);try{let n=await Promise.allSettled(i.map(async n=>{_(await t(n),`${e} ${n.id}`)}));if(!a.isCurrent())return;let r=n.filter(e=>e.status===`fulfilled`).length,o=n.length-r,s=`${e}: ${r} succeeded${o?`, ${o} failed`:``}`;P({ok:o===0,text:s}),o===0?d.success(s):d.error(s);let c=i.map(e=>e.id);k(e=>me(e,c)),U()}finally{a.finish()&&M(!1)}}},ke={promote:e=>v(e.state).promote},Q=G.filter(e=>O.has(e.id)),$={promote:Q.some(ke.promote)};return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(ie,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!a&&W!=null&&!H&&!I&&!R,actions:(0,b.jsxs)(m,{size:`sm`,disabled:!W||G.length===0,onClick:()=>{if(G.length===0){d.info(`No jobs to export on this page`);return}let e=G.map(e=>({id:e.id,name:e.name??`default`,queue:e.queue??a,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:``}));fe(`jobs-${a}-${w}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,b.jsx)(le,{className:`size-3.5`}),` Export CSV`]})}),I&&(0,b.jsx)(h,{onRetry:be,message:F?`Queue inventory refresh failed — showing the last successful queue totals. ${I.message}`:`Could not discover queues — ${I.message}. Select an existing queue from the URL or retry.`}),R&&(0,b.jsx)(h,{onRetry:xe,message:L?`Server-wide totals refresh failed — showing the last successful totals. ${R.message}`:`Server-wide job totals are unavailable — ${R.message}. The selected queue page may still be current.`}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,b.jsx)(f,{label:`Total`,value:K&&q!=null?u(K.completed+q+K.waiting+K.prioritized+K.active+K.delayed+K[`waiting-children`]):`—`,hint:`all queues`,compact:!0}),(0,b.jsx)(f,{label:`Waiting`,value:Y(K?.waiting),tone:`amber`,hint:`standard priority`,compact:!0}),(0,b.jsx)(f,{label:`Prioritized`,value:Y(K?.prioritized),tone:`amber`,compact:!0}),(0,b.jsx)(f,{label:`Active`,value:Y(K?.active),tone:`blue`,compact:!0}),(0,b.jsx)(f,{label:`Flow-blocked`,value:Y(K?.[`waiting-children`]),tone:`blue`,compact:!0}),(0,b.jsx)(f,{label:`Completed`,value:Y(K?.completed),tone:`green`,compact:!0}),(0,b.jsx)(f,{label:`Failed`,value:q==null?`—`:u(q),tone:q!=null&&q>0?`red`:`default`,compact:!0}),(0,b.jsx)(f,{label:`Error Rate`,value:J==null?`—`:ae(J),tone:J==null?`default`:J>.05?`red`:`green`,compact:!0})]}),(0,b.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-48`,children:(0,b.jsx)(g,{value:a,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>{C(e.target.value),X(),we(e.target.value,w)},children:(F??[]).map(e=>(0,b.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,b.jsx)(`div`,{className:`w-48`,children:(0,b.jsx)(g,{"aria-label":`Job state`,name:`jobs-state`,value:w,onChange:e=>{let t=e.target.value;ge(t),X(),we(a,t)},children:x.map(e=>(0,b.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,b.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,b.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,b.jsx)(`input`,{value:T,onChange:e=>_e(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`})]})]}),O.size>0&&(0,b.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,b.jsx)(`span`,{className:`mr-1 text-muted`,children:pe(Q.length,O.size)}),$.promote&&(0,b.jsx)(m,{size:`sm`,disabled:j,onClick:()=>Oe(`Promote`,e=>p.promoteJob(e.id),ke.promote),children:`Promote selected`}),!$.promote&&(0,b.jsx)(`span`,{className:`text-xs text-faint`,children:Q.length===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]}),N&&(0,b.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,N.ok?`text-success`:`text-danger`),children:N.text}),H&&W&&(0,b.jsx)(h,{message:`Job refresh failed — showing the last successful page.`,onRetry:U}),H&&!W?(0,b.jsx)(ce,{error:H,onRetry:U}):ye&&!F&&!a&&!I?(0,b.jsx)(l,{label:`Discovering queues…`}):Se&&!W?(0,b.jsx)(l,{label:`Loading jobs…`}):(0,b.jsxs)(b.Fragment,{children:[a&&(0,b.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,b.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:a})]}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,b.jsx)(`th`,{scope:`col`,className:`w-10 px-5 py-3`,children:(0,b.jsx)(`input`,{type:`checkbox`,checked:Z,ref:e=>{e&&(e.indeterminate=O.size>0&&!Z)},"aria-checked":O.size>0&&!Z?`mixed`:Z,onChange:Ee,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Name`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Status`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Priority`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,b.jsx)(`th`,{scope:`col`,className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,b.jsx)(`tbody`,{children:G.length===0?(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:T.trim()?`No jobs on this page match your ID or name filter.`:a?`No jobs found.`:I?`Queue discovery failed. Retry above.`:`Select a queue.`})}):G.map(e=>{let n=he(e.priority),r=v(e.state),a=j||ve.has(e.id);return(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`input`,{type:`checkbox`,checked:O.has(e.id),onChange:()=>Te(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,b.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,b.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,b.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(re,{status:String(e.state??`waiting`)})}),(0,b.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.c),children:n.t}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:ne(e.createdAt)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:se(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,b.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,b.jsx)(s,{className:`size-3.5`})}),r.promote&&(0,b.jsx)(ee,{"aria-label":`Promote job`,disabled:a,onClick:()=>De(e,`Promote`,()=>p.promoteJob(e.id)),children:(0,b.jsx)(te,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,b.jsx)(ue,{page:E,pageSize:S,hasNext:Ce,onPageChange:D,label:`jobs`})]})]})}export{C as JobsPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{A as r,H as i,J as a,c as o,g as s,h as c,m as l,t as u,u as d,v as f,x as p}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{A as r,H as i,J as a,c as o,g as s,h as c,m as l,t as u,u as d,v as f,x as p}from"./index-CAtsVmyh.js";import{a as m,i as h}from"./form-DsUq0w8s.js";import{t as g}from"./Pagination-Bfi4vkpp.js";import{discoverAllQueues as _}from"./Jobs-j8tTS3NC.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}=r(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=u(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)(c,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(p,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(p,{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)(l,{label:`Total Events`,value:o(M.total),compact:!0}),(0,y.jsx)(l,{label:`Completed`,value:o(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(l,{label:`Failed`,value:o(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(l,{label:`Waiting`,value:o(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(l,{label:`Active`,value:o(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(l,{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)(a,{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)(f,{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)(s,{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:d(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{g as t,r as n,t as r}from"./react-vendor-Bjui4wS4.js";import{o as i}from"./connectionStore-Cd9-3Fw0.js";import{A as a,J as o,O as s,c,g as l,h as u,m as d,t as f,u as p,w as m,x as h}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{g as t,r as n,t as r}from"./react-vendor-Bjui4wS4.js";import{o as i}from"./connectionStore-Cd9-3Fw0.js";import{A as a,J as o,O as s,c,g as l,h as u,m as d,t as f,u as p,w as m,x as h}from"./index-CAtsVmyh.js";import{a as g,i as _}from"./form-DsUq0w8s.js";import{t as v}from"./Pagination-Bfi4vkpp.js";import{loadAllQueuePages as y}from"./QueueControl-B5xK_SQ-.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}=a(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=f(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)(h,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(h,{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)(d,{label:`Total Events`,value:c(z.total),compact:!0}),(0,x.jsx)(d,{label:`Completed`,value:c(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(d,{label:`Failed`,value:c(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(d,{label:`Waiting`,value:c(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(d,{label:`Active`,value:c(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(d,{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)(m,{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?` — ${c(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)(o,{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:p(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)(s,{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-Bjui4wS4.js";import{C as t,O as n,S as r,h as i,m as a}from"./index-
|
|
1
|
+
import{t as e}from"./react-vendor-Bjui4wS4.js";import{C as t,O as n,S as r,h as i,m as a}from"./index-CAtsVmyh.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-Bjui4wS4.js";import{C as t,O as n,S as r,h as
|
|
|
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)(n,{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)(i,{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)(r,{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.8.
|
|
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)(n,{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)(i,{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)(r,{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.8.57 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)(r,{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)(r,{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)(r,{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)(r,{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)(r,{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)(r,{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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-Bjui4wS4.js";import{A as t,C as n,S as r,b as i,c as a,h as o,j as s,m as c,r as l,x as u,y as d}from"./index-
|
|
1
|
+
import{t as e}from"./react-vendor-Bjui4wS4.js";import{A as t,C as n,S as r,b as i,c as a,h as o,j as s,m as c,r as l,x as u,y as d}from"./index-CAtsVmyh.js";var f=e(),p={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function m(){let{data:e,error:m,loading:_,refetch:v}=t(()=>s.overview(),[]);if(_&&!e&&!m)return(0,f.jsx)(i,{label:`Loading metrics…`});if(m&&!e)return(0,f.jsxs)(`div`,{children:[(0,f.jsx)(o,{title:`Metrics`,description:`Throughput, latency, and resource internals.`}),(0,f.jsx)(d,{error:m,onRetry:v})]});let{stats:y,throughput:b,latency:x,memory:S,collections:C}=e??p,w={};for(let[e,t]of Object.entries(x.percentiles??{}))t&&typeof t==`object`&&(w[`${e} p50`]=t.p50,w[`${e} p95`]=t.p95,w[`${e} p99`]=t.p99);return(0,f.jsxs)(`div`,{children:[m&&(0,f.jsx)(u,{message:`Metrics refresh failed — showing the last successful snapshot.`,onRetry:v}),(0,f.jsx)(o,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!!e&&!m}),(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,f.jsx)(c,{label:`Pushed /s`,value:b.pushPerSec.toFixed(1),compact:!0}),(0,f.jsx)(c,{label:`Pulled /s`,value:b.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,f.jsx)(c,{label:`Completed /s`,value:b.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,f.jsx)(c,{label:`Failed /s`,value:b.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,f.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,f.jsxs)(r,{children:[(0,f.jsx)(n,{title:`Totals`}),(0,f.jsx)(h,{rows:[[`Pushed`,a(y.totalPushed)],[`Pulled`,a(y.totalPulled)],[`Completed`,a(y.totalCompleted)],[`Failed`,a(y.totalFailed)]]})]}),(0,f.jsxs)(r,{children:[(0,f.jsx)(n,{title:`Memory`}),(0,f.jsx)(h,{rows:[[`Heap Used`,l(S.heapUsed*1024*1024)],[`Heap Total`,l(S.heapTotal*1024*1024)],[`RSS`,l(S.rss*1024*1024)]]})]}),(0,f.jsxs)(r,{children:[(0,f.jsx)(n,{title:`Latency — percentiles (ms)`}),(0,f.jsx)(g,{record:w,suffix:`ms`})]}),(0,f.jsxs)(r,{children:[(0,f.jsx)(n,{title:`Latency — averages (ms)`}),(0,f.jsx)(g,{record:x.averages,suffix:`ms`})]})]}),(0,f.jsx)(`div`,{className:`mt-6`,children:(0,f.jsxs)(r,{children:[(0,f.jsx)(n,{title:`In-memory collections`}),(0,f.jsx)(g,{record:C})]})})]})}function h({rows:e}){return(0,f.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,f.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function g({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,f.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,f.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,f.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,f.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,f.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?a(Math.round(n*100)/100):String(n),t&&(0,f.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{m as Metrics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{g as n,t as r}from"./react-vendor-Bjui4wS4.js";import{A as i,C as a,S as o,b as s,c,d as l,h as u,i as d,l as f,m as p,n as m,st as h,v as g,x as _}from"./index-Bn2R06qm.js";import{t as v}from"./Pagination-DpxiBnt8.js";import{t as y}from"./AreaChart-REK4ZsTC.js";import{n as b,t as x}from"./useThroughputSeries-tb26_lkb.js";var S=e(n(),1),C=r(),w=[`-60s`,`-45s`,`-30s`,`-15s`,`now`],T=15,E=[`push`,`pull`,`ack`],D=100;function O(){let e=b(60),[n,r]=(0,S.useState)(0),{data:O,error:M,loading:N,refetch:P}=i(async()=>({details:await h.queuesSummary()}),[]),F=O?.details??[],I=Math.max(1,Math.ceil(F.length/T)),L=Math.min(n,I-1),R=(0,S.useMemo)(()=>F.slice(L*T,L*T+T),[F,L]),z=(0,S.useMemo)(()=>O?F.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[O,F]),B=e.latest?.stats,V=e.latest?.throughput,H=e.latest?.latency,U=B&&z!=null?m(B.completed,z):null,W=x(e.depth),G=e.depth.length?e.depth[e.depth.length-1]:null,K=!e.latest&&!e.error,q=N&&!O&&!M;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(u,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:!!e.latest&&!e.error&&!!O&&!M}),M&&(0,C.jsx)(_,{message:`Queue metrics unavailable — ${M.message}`,onRetry:P}),e.error&&(0,C.jsx)(_,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),q&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),K&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(p,{label:`Total Completed`,value:B?d(B.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(p,{label:`Total Failed`,value:z==null?`—`:c(z),tone:z?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(p,{label:`Push/sec`,value:V?V.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(p,{label:`Pull/sec`,value:V?V.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsxs)(o,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),V&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(A,{color:`#ec4899`,label:`Pushed`,value:V.pushPerSec}),(0,C.jsx)(A,{color:`#34d399`,label:`Completed`,value:V.completePerSec}),(0,C.jsx)(A,{color:`#f87171`,label:`Failed`,value:V.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:w,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):e.error?(0,C.jsx)(g,{title:`Live throughput unavailable`,hint:e.error.message}):(0,C.jsx)(s,{label:`Connecting live throughput…`})]}),(0,C.jsxs)(o,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:G==null?`—`:c(G)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,W.label===`draining`?`text-success`:W.label===`accumulating`?`text-danger`:`text-faint`),children:G==null?`unavailable`:W.label===`steady`?`steady`:`${W.slope>0?`+`:``}${W.slope.toFixed(1)}/s · ${W.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:w,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:W.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):e.error?(0,C.jsx)(g,{title:`Queue depth unavailable`,hint:e.error.message}):(0,C.jsx)(s,{label:`Connecting queue depth…`})]}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(o,{children:[(0,C.jsx)(a,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U!=null&&U>.05?`text-danger`:`text-fg`),children:U==null?`—`:f(U)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`error rate`})]}),(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U==null?`text-fg`:`text-success`),children:U==null?`—`:f(1-U)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`success rate`})]})]}),U==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-U)*100}%`}})})]}),(0,C.jsxs)(o,{children:[(0,C.jsx)(a,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(j,{color:`bg-blue-400`,label:`Standard waiting`,value:B?c(B.waiting):`—`}),(0,C.jsx)(j,{color:`bg-accent`,label:`Processing`,value:B?c(B.active):`—`}),(0,C.jsx)(j,{color:`bg-amber-400`,label:`Delayed`,value:B?c(B.delayed):`—`}),(0,C.jsx)(j,{color:`bg-red-400`,label:`Dead Letter`,value:B?c(B.dlq):`—`}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:B?d(B.totalPushed):`—`}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:B?d(B.totalPulled):`—`}),(0,C.jsx)(j,{color:`bg-emerald-400`,label:`Uptime`,value:B?l(B.uptime/1e3):`—`})]})]})]}),(0,C.jsxs)(o,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:E.map(e=>{let n=H?.percentiles?.[e],r=H?.averages?.[`${e}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:e}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(r)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(n?.p99??0)>D?`text-warning`:`text-muted`),children:k(n?.p99)})]},e)})})]})})]}),(0,C.jsxs)(o,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:R.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:M&&!O?`Queue metrics unavailable — ${M.message}`:q?`Loading queue metrics…`:`No queues yet.`})}):R.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:c(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:c(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:c(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:c(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:c(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:L,pageSize:T,total:F.length,onPageChange:r,label:`queues`})})]})]})}function k(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}function A({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}function j({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}export{O as MetricsPro};
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{g as n,t as r}from"./react-vendor-Bjui4wS4.js";import{A as i,C as a,S as o,b as s,c,d as l,h as u,i as d,l as f,m as p,n as m,st as h,v as g,x as _}from"./index-CAtsVmyh.js";import{t as v}from"./Pagination-Bfi4vkpp.js";import{t as y}from"./AreaChart-REK4ZsTC.js";import{n as b,t as x}from"./useThroughputSeries-DjxGN8ob.js";var S=e(n(),1),C=r(),w=[`-60s`,`-45s`,`-30s`,`-15s`,`now`],T=15,E=[`push`,`pull`,`ack`],D=100;function O(){let e=b(60),[n,r]=(0,S.useState)(0),{data:O,error:M,loading:N,refetch:P}=i(async()=>({details:await h.queuesSummary()}),[]),F=O?.details??[],I=Math.max(1,Math.ceil(F.length/T)),L=Math.min(n,I-1),R=(0,S.useMemo)(()=>F.slice(L*T,L*T+T),[F,L]),z=(0,S.useMemo)(()=>O?F.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[O,F]),B=e.latest?.stats,V=e.latest?.throughput,H=e.latest?.latency,U=B&&z!=null?m(B.completed,z):null,W=x(e.depth),G=e.depth.length?e.depth[e.depth.length-1]:null,K=!e.latest&&!e.error,q=N&&!O&&!M;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(u,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:!!e.latest&&!e.error&&!!O&&!M}),M&&(0,C.jsx)(_,{message:`Queue metrics unavailable — ${M.message}`,onRetry:P}),e.error&&(0,C.jsx)(_,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),q&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),K&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(p,{label:`Total Completed`,value:B?d(B.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(p,{label:`Total Failed`,value:z==null?`—`:c(z),tone:z?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(p,{label:`Push/sec`,value:V?V.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(p,{label:`Pull/sec`,value:V?V.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsxs)(o,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),V&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(A,{color:`#ec4899`,label:`Pushed`,value:V.pushPerSec}),(0,C.jsx)(A,{color:`#34d399`,label:`Completed`,value:V.completePerSec}),(0,C.jsx)(A,{color:`#f87171`,label:`Failed`,value:V.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:w,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):e.error?(0,C.jsx)(g,{title:`Live throughput unavailable`,hint:e.error.message}):(0,C.jsx)(s,{label:`Connecting live throughput…`})]}),(0,C.jsxs)(o,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:G==null?`—`:c(G)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,W.label===`draining`?`text-success`:W.label===`accumulating`?`text-danger`:`text-faint`),children:G==null?`unavailable`:W.label===`steady`?`steady`:`${W.slope>0?`+`:``}${W.slope.toFixed(1)}/s · ${W.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:w,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:W.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):e.error?(0,C.jsx)(g,{title:`Queue depth unavailable`,hint:e.error.message}):(0,C.jsx)(s,{label:`Connecting queue depth…`})]}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(o,{children:[(0,C.jsx)(a,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U!=null&&U>.05?`text-danger`:`text-fg`),children:U==null?`—`:f(U)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`error rate`})]}),(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U==null?`text-fg`:`text-success`),children:U==null?`—`:f(1-U)}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:`success rate`})]})]}),U==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-U)*100}%`}})})]}),(0,C.jsxs)(o,{children:[(0,C.jsx)(a,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(j,{color:`bg-blue-400`,label:`Standard waiting`,value:B?c(B.waiting):`—`}),(0,C.jsx)(j,{color:`bg-accent`,label:`Processing`,value:B?c(B.active):`—`}),(0,C.jsx)(j,{color:`bg-amber-400`,label:`Delayed`,value:B?c(B.delayed):`—`}),(0,C.jsx)(j,{color:`bg-red-400`,label:`Dead Letter`,value:B?c(B.dlq):`—`}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:B?d(B.totalPushed):`—`}),(0,C.jsx)(j,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:B?d(B.totalPulled):`—`}),(0,C.jsx)(j,{color:`bg-emerald-400`,label:`Uptime`,value:B?l(B.uptime/1e3):`—`})]})]})]}),(0,C.jsxs)(o,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:E.map(e=>{let n=H?.percentiles?.[e],r=H?.averages?.[`${e}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:e}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(r)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(n?.p99??0)>D?`text-warning`:`text-muted`),children:k(n?.p99)})]},e)})})]})})]}),(0,C.jsxs)(o,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:R.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:M&&!O?`Queue metrics unavailable — ${M.message}`:q?`Loading queue metrics…`:`No queues yet.`})}):R.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:c(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:c(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:c(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:c(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:c(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:L,pageSize:T,total:F.length,onPageChange:r,label:`queues`})})]})]})}function k(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}function A({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}function j({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}export{O as MetricsPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-Bjui4wS4.js";import{A as t,C as n,L as r,S as i,X as a,b as o,c as s,d as c,h as l,j as u,l as d,m as f,n as p,r as m,x as h,y as g}from"./index-
|
|
1
|
+
import{t as e}from"./react-vendor-Bjui4wS4.js";import{A as t,C as n,L as r,S as i,X as a,b as o,c as s,d as c,h as l,j as u,l as d,m as f,n as p,r as m,x as h,y as g}from"./index-CAtsVmyh.js";var _=e(),v={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function y(){let{data:e,error:y,loading:S,refetch:C}=t(()=>u.overview(),[]);if(S&&!e&&!y)return(0,_.jsx)(o,{label:`Loading overview…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(l,{title:`Overview`,description:`Live health and throughput across all queues.`}),(0,_.jsx)(g,{error:y,onRetry:C})]});let{stats:w,throughput:T,memory:E,workers:D,crons:O,storage:k}=e??v,A=p(w.totalCompleted,w.totalFailed)??0,j=typeof k.diskFull==`boolean`;return(0,_.jsxs)(`div`,{children:[y&&(0,_.jsx)(h,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:C}),(0,_.jsx)(l,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!!e&&!y&&j}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(f,{label:`Waiting`,value:s(w.waiting),tone:`amber`}),(0,_.jsx)(f,{label:`Active`,value:s(w.active),tone:`blue`}),(0,_.jsx)(f,{label:`Completed`,value:s(w.totalCompleted),tone:`green`}),(0,_.jsx)(f,{label:`Failed`,value:s(w.totalFailed),tone:`red`}),(0,_.jsx)(f,{label:`DLQ`,value:s(w.dlq),tone:w.dlq>0?`red`:`default`}),(0,_.jsx)(f,{label:`Error Rate`,value:d(A),tone:A>.05?`red`:`green`})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(i,{children:[(0,_.jsx)(n,{title:`Throughput`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(b,{label:`Pushed`,value:T.pushPerSec,tone:`text-fg`}),(0,_.jsx)(b,{label:`Pulled`,value:T.pullPerSec,tone:`text-blue-400`}),(0,_.jsx)(b,{label:`Completed`,value:T.completePerSec,tone:`text-emerald-400`}),(0,_.jsx)(b,{label:`Failed`,value:T.failPerSec,tone:`text-red-400`})]})]}),(0,_.jsxs)(i,{children:[(0,_.jsx)(n,{title:`Resources`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(x,{label:`Uptime`,value:c(w.uptime/1e3)}),(0,_.jsx)(x,{label:`Heap`,value:m(E.heapUsed*1024*1024)}),(0,_.jsx)(x,{label:`RSS`,value:m(E.rss*1024*1024)}),(0,_.jsx)(x,{label:`Storage`,value:j?k.diskFull?`Disk full`:`Healthy`:`Unavailable`,tone:j?k.diskFull?`text-red-400`:`text-emerald-400`:`text-muted`})]})]})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(i,{children:[(0,_.jsx)(n,{title:`Workers`,icon:(0,_.jsx)(a,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,_.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:D.active}),` /`,` `,D.total,` active`]})}),D.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,_.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,s(e.processedJobs),` done`]})]},e.id))})]}),(0,_.jsxs)(i,{children:[(0,_.jsx)(n,{title:`Cron Jobs`,icon:(0,_.jsx)(r,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[O.total,` scheduled`]})}),O.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:O.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,_.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function b({label:e,value:t,tone:n}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,_.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function x({label:e,value:t,tone:n=`text-fg`}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{y as Overview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{c as r}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{c as r}from"./index-CAtsVmyh.js";var i=e(t(),1),a=n();function o({page:e,pageSize:t,total:n,hasNext:o,onPageChange:s,label:c=`items`,className:l}){let u=n!=null,d=u?Math.max(1,Math.ceil(n/t)):void 0;(0,i.useEffect)(()=>{u&&e>d-1&&s(d-1)},[u,e,d,s]);let f=u?Math.min(e,d-1):e,p=f*t,m=f>0,h=u?f<d-1:!!o;if(u&&n<=t&&f===0)return null;let g=u?n===0?`No ${c}`:`${r(p+1)}–${r(Math.min(p+t,n))} of ${r(n)} ${c}`:`Page ${f+1}`;return(0,a.jsxs)(`div`,{className:`mt-4 flex items-center justify-between text-sm text-faint ${l??``}`,children:[(0,a.jsx)(`span`,{children:g}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsx)(`button`,{type:`button`,disabled:!m,onClick:()=>s(f-1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Previous`}),(0,a.jsx)(`span`,{className:`rounded-md bg-accent/15 px-2.5 py-1 text-xs font-medium text-accent tnum`,children:u?`${f+1} / ${d}`:f+1}),(0,a.jsx)(`button`,{type:`button`,disabled:!h,onClick:()=>s(f+1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Next`})]})]})}export{o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{o as r}from"./connectionStore-Cd9-3Fw0.js";import{C as i,S as a,st as o,w as s}from"./index-Bn2R06qm.js";import{a as c,n as l,o as u,t as d}from"./form-DsUq0w8s.js";import{n as f,r as p}from"./useServerActionGuard-CItj3hvh.js";import{i as m,n as h,r as g}from"./flowMutationSafety-DVD1IMr-.js";var _=e(t(),1),v=n();function y(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}return JSON.stringify(e)}function b(e){let[t,n]=(0,_.useState)(e),r=(0,_.useRef)(y(e));return(0,_.useEffect)(()=>{let t=y(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=y(t))}}]}function x(e,t){let n=String(e).trim();if(n===``)return null;let r=Number(n);return Number.isSafeInteger(r)&&r>=t?r:null}function S(e){let t=x(e.stallInterval,0),n=x(e.maxStalls,0),r=x(e.gracePeriod,0);return t===null||n===null||r===null?{ok:!1,error:`Stall interval, max stalls, and grace period must be non-negative whole numbers.`}:{ok:!0,value:{enabled:e.enabled,stallInterval:t,maxStalls:n,gracePeriod:r}}}function C(e){let t=x(e.autoRetryInterval,0),n=x(e.maxAutoRetries,0);return t===null||n===null?{ok:!1,error:`Retry interval and max auto-retries must be non-negative whole numbers.`}:{ok:!0,value:{autoRetry:e.autoRetry,autoRetryInterval:t,maxAutoRetries:n}}}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return typeof e==`number`&&Number.isFinite(e)}function E(e){return w(e)&&typeof e.enabled==`boolean`&&T(e.stallInterval)&&T(e.maxStalls)&&T(e.gracePeriod)}function D(e){return w(e)&&typeof e.autoRetry==`boolean`&&T(e.autoRetryInterval)&&T(e.maxAutoRetries)&&(e.maxAge===null||T(e.maxAge))&&T(e.maxEntries)}function O(e,t){if(!w(e)||e.ok!==!0)throw Error(`Malformed ${t} response: expected { ok: true }.`)}function k(e){let{scopeKey:t,begin:n}=p(e),i=(0,_.useRef)(null),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null);let e=f(),t=r.subscribe(()=>{let t=f();t!==e&&(e=t,i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null))});return()=>{i.current=null,a.current!==null&&window.clearTimeout(a.current),t()}},[t]),{scopeKey:t,saving:o,saved:c,start:()=>{let e=n(`save`);return e?(i.current=e,s(!0),l(!1),e):null},finish:e=>{e.finish(),i.current===e&&(i.current=null,s(!1))},showSaved:e=>{i.current!==e||!e.isCurrent()||(l(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{e.isCurrent()&&l(!1),a.current=null},2e3))}}}function A({queue:e,config:t,onSaved:n}){let[r,c,f]=b(t),[p,m]=(0,_.useState)(null),h=k(`stall-config:${e}`);(0,_.useEffect)(()=>m(null),[h.scopeKey]);let g=S(r);return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Stall detection`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,v.jsx)(u,{checked:r.enabled,onChange:e=>c({...r,enabled:e}),label:`enabled`}),(0,v.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,v.jsx)(d,{label:`Stall interval (ms)`,children:(0,v.jsx)(l,{name:`stall-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.stallInterval,onChange:e=>c({...r,stallInterval:e.target.value})})}),(0,v.jsx)(d,{label:`Max stalls`,children:(0,v.jsx)(l,{name:`stall-max-count`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxStalls,onChange:e=>c({...r,maxStalls:e.target.value})})}),(0,v.jsx)(d,{label:`Grace period (ms)`,children:(0,v.jsx)(l,{name:`stall-grace-period-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.gracePeriod,onChange:e=>c({...r,gracePeriod:e.target.value})})})]}),(0,v.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:h.saving||!g.ok,onClick:async()=>{if(!g.ok)return;let t=h.start();if(t)try{m(null);let r=f();if(O(await o.setStallConfig(e,g.value),`/stall-config`),!t.isCurrent())return;r(g.value),await n(),h.showSaved(t)}catch(e){t.isCurrent()&&m(e.message)}finally{h.finish(t)}},children:`Save`}),h.saved&&(0,v.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!g.ok&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:g.error}),p&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function j({queue:e,config:t,onSaved:n}){let[r,c,f]=b(t),[p,h]=(0,_.useState)(null),g=k(`dlq-config:${e}`);(0,_.useEffect)(()=>h(null),[g.scopeKey]);let y=C(r),x=y.ok&&y.value.autoRetry;return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`DLQ policy`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,v.jsx)(u,{checked:r.autoRetry,disabled:!r.autoRetry,onChange:e=>c({...r,autoRetry:e}),label:`auto-retry`}),(0,v.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,v.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:`Auto-retry can only be disabled. Bunqueue v2.8.55 cannot prove that a DLQ entry has no hidden reverse flow dependents before a background retry.`}),(0,v.jsx)(d,{label:`Retry interval (ms)`,children:(0,v.jsx)(l,{name:`dlq-auto-retry-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.autoRetryInterval,onChange:e=>c({...r,autoRetryInterval:e.target.value})})}),(0,v.jsx)(d,{label:`Max auto-retries`,children:(0,v.jsx)(l,{name:`dlq-max-auto-retries`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxAutoRetries,onChange:e=>c({...r,maxAutoRetries:e.target.value})})}),(0,v.jsx)(d,{label:`Max age (ms)`,children:(0,v.jsx)(l,{name:`dlq-max-age-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxAge??``,readOnly:!0})}),(0,v.jsx)(d,{label:`Max entries`,children:(0,v.jsx)(l,{name:`dlq-max-entries`,autoComplete:`off`,type:`number`,min:1,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxEntries,readOnly:!0})}),(0,v.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:m})]}),(0,v.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:g.saving||!y.ok||x,onClick:async()=>{if(!y.ok)return;let t=g.start();if(t)try{h(null);let i=f();if(O(await o.setDlqConfig(e,y.value),`/dlq-config`),!t.isCurrent())return;i({...r,...y.value}),await n(),g.showSaved(t)}catch(e){t.isCurrent()&&h(e.message)}finally{g.finish(t)}},children:`Save`}),g.saved&&(0,v.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!y.ok&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:y.error}),x&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:`Disable auto-retry before saving this policy.`}),p&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function M({title:e,onRetry:t}){return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:e}),(0,v.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,v.jsx)(s,{size:`sm`,onClick:t,children:`Retry`})]})}function N(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&n>=0&&r>0}}function P(e){if(!e.trim())return{valid:!0};let t=Number(e);return Number.isSafeInteger(t)&&t>0?{count:t,valid:!0}:{valid:!1}}function F(e,t){return t===void 0?`Promote every delayed job in "${e}" and make it eligible to run now?`:`Promote up to ${t} delayed jobs in "${e}" and make them eligible to run now?`}function I(e,t,n){let r=e=>{if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},i=r(e),a=r(t),o=r(n);return{limit:typeof i==`number`?i:0,duration:typeof a==`number`?a:0,...typeof o==`number`?{ttl:o}:{},valid:typeof i==`number`&&typeof a==`number`&&o!==null}}function L(e){let t=Number(e);return{value:t,valid:e.trim()!==``&&Number.isSafeInteger(t)&&t>0}}function R({queue:e,paused:t,busy:n,run:r}){let[u,f]=(0,_.useState)(`0`),[p,m]=(0,_.useState)(`1000`),[y,b]=(0,_.useState)(`completed`),[x,S]=(0,_.useState)(``),C=N(u,p),w=P(x);return(0,v.jsxs)(a,{className:`mb-6`,children:[(0,v.jsx)(i,{title:`Lifecycle`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,v.jsx)(s,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>o.resume(e)),children:`Resume`}):(0,v.jsx)(s,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>o.pause(e)),children:`Pause`}),(0,v.jsx)(s,{size:`sm`,disabled:!0,title:h,children:`Requeue completed`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Promote N`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`promote-count`,"aria-invalid":!w.valid,value:x,onChange:e=>S(e.target.value),placeholder:`all`})})}),(0,v.jsx)(s,{size:`sm`,disabled:n||!w.valid,onClick:()=>r(`Promoted`,()=>o.promoteJobs(e,w.count),F(e,w.count)),children:`Promote delayed`}),!w.valid&&(0,v.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Promote N must be a positive whole number, or blank for all.`})]})]}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:h}),(0,v.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,v.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,v.jsx)(s,{size:`sm`,disabled:!0,title:g,children:`Drain`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`w-40`,children:(0,v.jsx)(d,{label:`State`,children:(0,v.jsxs)(c,{name:`clean-state`,disabled:!0,value:y,onChange:e=>b(e.target.value),children:[(0,v.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,v.jsx)(`option`,{value:`failed`,children:`Failed / DLQ`}),(0,v.jsx)(`option`,{value:`waiting`,children:`Queued`})]})})}),(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Grace (ms)`,children:(0,v.jsx)(l,{type:`number`,min:0,max:2**53-1,step:1,name:`clean-grace`,disabled:!0,"aria-invalid":!C.valid,value:u,onChange:e=>f(e.target.value)})})}),(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Limit`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`clean-limit`,disabled:!0,"aria-invalid":!C.valid,value:p,onChange:e=>m(e.target.value)})})}),(0,v.jsx)(s,{variant:`danger`,size:`sm`,disabled:!0,title:g,children:`Clean`}),!C.valid&&(0,v.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Grace and limit must be whole numbers; limit must be positive.`})]})]}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:g})]})]})}function z({queue:e,busy:t,run:n}){let[r,u]=(0,_.useState)(``),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(`permanent`),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(``),[w,T]=(0,_.useState)(``),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(null),A=I(r,f,m===`expires`?g:``),j=L(b);return(0,v.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Rate-limit desired state`}),(0,v.jsx)(`p`,{className:`mb-3 text-xs text-warning`,children:`Bunqueue v2.8.55 has no read endpoint. This blindly replaces an unknown policy; a receipt proves only what this dashboard applied at that time.`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,v.jsx)(d,{label:`Limit`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-limit`,value:r,onChange:e=>u(e.target.value),placeholder:`max per window`})})}),(0,v.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,v.jsx)(d,{label:`Window (ms)`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-duration`,value:f,onChange:e=>p(e.target.value),placeholder:`60000`})})}),(0,v.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,v.jsx)(d,{label:`TTL`,children:(0,v.jsxs)(c,{name:`rate-ttl-mode`,value:m,onChange:e=>h(e.target.value),children:[(0,v.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,v.jsx)(`option`,{value:`expires`,children:`Expires after`})]})})}),(0,v.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,v.jsx)(d,{label:`TTL (ms)`,hint:m===`permanent`?`Not sent`:void 0,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-ttl`,disabled:m===`permanent`,value:g,onChange:e=>y(e.target.value),placeholder:`—`})})}),(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:t||!A.valid,onClick:()=>n(`Rate limit set`,()=>o.setRateLimit(e,A.limit,A.duration,A.ttl),`Replace the unknown rate-limit policy for "${e}" with limit ${A.limit}, window ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`}?`,()=>D(`Applied limit ${A.limit} per ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`} at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Replace policy`}),(0,v.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,v.jsx)(d,{label:`Type ${e} to clear`,children:(0,v.jsx)(l,{name:`rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:S,onChange:e=>C(e.target.value)})})}),(0,v.jsx)(s,{size:`sm`,disabled:t||S!==e,onClick:()=>n(`No rate limit ensured`,()=>o.clearRateLimit(e),`Ensure queue "${e}" has no rate-limit policy? Bunqueue v2.8.55 cannot report its previous value.`,()=>D(`Applied no rate-limit policy at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Ensure no rate limit`}),!A.valid&&(r.trim()||f.trim()||g.trim())&&(0,v.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-danger`,children:`Limit and window are required; all values must be positive whole numbers.`}),E&&(0,v.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:E})]})]}),(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Concurrency desired state`}),(0,v.jsx)(`p`,{className:`mb-3 text-xs text-warning`,children:`Bunqueue v2.8.55 has no read endpoint. This blindly replaces an unknown policy; a receipt proves only what this dashboard applied at that time.`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,v.jsx)(d,{label:`Concurrency`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`concurrency`,value:b,onChange:e=>x(e.target.value),placeholder:`max in-flight`})})}),(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:t||!j.valid,onClick:()=>n(`Concurrency set`,()=>o.setConcurrency(e,j.value),`Replace the unknown concurrency policy for "${e}" with ${j.value} maximum in-flight jobs?`,()=>k(`Applied concurrency ${j.value} at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Replace policy`}),(0,v.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,v.jsx)(d,{label:`Type ${e} to clear`,children:(0,v.jsx)(l,{name:`concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:w,onChange:e=>T(e.target.value)})})}),(0,v.jsx)(s,{size:`sm`,disabled:t||w!==e,onClick:()=>n(`No concurrency limit ensured`,()=>o.clearConcurrency(e),`Ensure queue "${e}" has no concurrency policy? Bunqueue v2.8.55 cannot report its previous value.`,()=>k(`Applied no concurrency policy at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Ensure no concurrency limit`}),!j.valid&&b.trim()&&(0,v.jsx)(`span`,{role:`alert`,className:`self-center text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),O&&(0,v.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:O})]})]})]})}export{A as a,j as i,z as n,D as o,M as r,E as s,R as t};
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{o as r}from"./connectionStore-Cd9-3Fw0.js";import{C as i,S as a,st as o,w as s}from"./index-CAtsVmyh.js";import{a as c,n as l,o as u,t as d}from"./form-DsUq0w8s.js";import{n as f,r as p}from"./useServerActionGuard-CItj3hvh.js";import{i as m,n as h,r as g}from"./flowMutationSafety-CoOp94wS.js";var _=e(t(),1),v=n();function y(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}return JSON.stringify(e)}function b(e){let[t,n]=(0,_.useState)(e),r=(0,_.useRef)(y(e));return(0,_.useEffect)(()=>{let t=y(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=y(t))}}]}function x(e,t){let n=String(e).trim();if(n===``)return null;let r=Number(n);return Number.isSafeInteger(r)&&r>=t?r:null}function S(e){let t=x(e.stallInterval,0),n=x(e.maxStalls,0),r=x(e.gracePeriod,0);return t===null||n===null||r===null?{ok:!1,error:`Stall interval, max stalls, and grace period must be non-negative whole numbers.`}:{ok:!0,value:{enabled:e.enabled,stallInterval:t,maxStalls:n,gracePeriod:r}}}function C(e){let t=x(e.autoRetryInterval,0),n=x(e.maxAutoRetries,0);return t===null||n===null?{ok:!1,error:`Retry interval and max auto-retries must be non-negative whole numbers.`}:{ok:!0,value:{autoRetry:e.autoRetry,autoRetryInterval:t,maxAutoRetries:n}}}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return typeof e==`number`&&Number.isFinite(e)}function E(e){return w(e)&&typeof e.enabled==`boolean`&&T(e.stallInterval)&&T(e.maxStalls)&&T(e.gracePeriod)}function D(e){return w(e)&&typeof e.autoRetry==`boolean`&&T(e.autoRetryInterval)&&T(e.maxAutoRetries)&&(e.maxAge===null||T(e.maxAge))&&T(e.maxEntries)}function O(e,t){if(!w(e)||e.ok!==!0)throw Error(`Malformed ${t} response: expected { ok: true }.`)}function k(e){let{scopeKey:t,begin:n}=p(e),i=(0,_.useRef)(null),a=(0,_.useRef)(null),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null);let e=f(),t=r.subscribe(()=>{let t=f();t!==e&&(e=t,i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null))});return()=>{i.current=null,a.current!==null&&window.clearTimeout(a.current),t()}},[t]),{scopeKey:t,saving:o,saved:c,start:()=>{let e=n(`save`);return e?(i.current=e,s(!0),l(!1),e):null},finish:e=>{e.finish(),i.current===e&&(i.current=null,s(!1))},showSaved:e=>{i.current!==e||!e.isCurrent()||(l(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{e.isCurrent()&&l(!1),a.current=null},2e3))}}}function A({queue:e,config:t,onSaved:n}){let[r,c,f]=b(t),[p,m]=(0,_.useState)(null),h=k(`stall-config:${e}`);(0,_.useEffect)(()=>m(null),[h.scopeKey]);let g=S(r);return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Stall detection`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,v.jsx)(u,{checked:r.enabled,onChange:e=>c({...r,enabled:e}),label:`enabled`}),(0,v.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,v.jsx)(d,{label:`Stall interval (ms)`,children:(0,v.jsx)(l,{name:`stall-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.stallInterval,onChange:e=>c({...r,stallInterval:e.target.value})})}),(0,v.jsx)(d,{label:`Max stalls`,children:(0,v.jsx)(l,{name:`stall-max-count`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxStalls,onChange:e=>c({...r,maxStalls:e.target.value})})}),(0,v.jsx)(d,{label:`Grace period (ms)`,children:(0,v.jsx)(l,{name:`stall-grace-period-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.gracePeriod,onChange:e=>c({...r,gracePeriod:e.target.value})})})]}),(0,v.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:h.saving||!g.ok,onClick:async()=>{if(!g.ok)return;let t=h.start();if(t)try{m(null);let r=f();if(O(await o.setStallConfig(e,g.value),`/stall-config`),!t.isCurrent())return;r(g.value),await n(),h.showSaved(t)}catch(e){t.isCurrent()&&m(e.message)}finally{h.finish(t)}},children:`Save`}),h.saved&&(0,v.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!g.ok&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:g.error}),p&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function j({queue:e,config:t,onSaved:n}){let[r,c,f]=b(t),[p,h]=(0,_.useState)(null),g=k(`dlq-config:${e}`);(0,_.useEffect)(()=>h(null),[g.scopeKey]);let y=C(r),x=y.ok&&y.value.autoRetry;return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`DLQ policy`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,v.jsx)(u,{checked:r.autoRetry,disabled:!r.autoRetry,onChange:e=>c({...r,autoRetry:e}),label:`auto-retry`}),(0,v.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,v.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:`Auto-retry can only be disabled. Bunqueue v2.8.57 cannot prove that a DLQ entry has no hidden reverse flow dependents before a background retry.`}),(0,v.jsx)(d,{label:`Retry interval (ms)`,children:(0,v.jsx)(l,{name:`dlq-auto-retry-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.autoRetryInterval,onChange:e=>c({...r,autoRetryInterval:e.target.value})})}),(0,v.jsx)(d,{label:`Max auto-retries`,children:(0,v.jsx)(l,{name:`dlq-max-auto-retries`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxAutoRetries,onChange:e=>c({...r,maxAutoRetries:e.target.value})})}),(0,v.jsx)(d,{label:`Max age (ms)`,children:(0,v.jsx)(l,{name:`dlq-max-age-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxAge??``,readOnly:!0})}),(0,v.jsx)(d,{label:`Max entries`,children:(0,v.jsx)(l,{name:`dlq-max-entries`,autoComplete:`off`,type:`number`,min:1,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxEntries,readOnly:!0})}),(0,v.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:m})]}),(0,v.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:g.saving||!y.ok||x,onClick:async()=>{if(!y.ok)return;let t=g.start();if(t)try{h(null);let i=f();if(O(await o.setDlqConfig(e,y.value),`/dlq-config`),!t.isCurrent())return;i({...r,...y.value}),await n(),g.showSaved(t)}catch(e){t.isCurrent()&&h(e.message)}finally{g.finish(t)}},children:`Save`}),g.saved&&(0,v.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!y.ok&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:y.error}),x&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:`Disable auto-retry before saving this policy.`}),p&&(0,v.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function M({title:e,onRetry:t}){return(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:e}),(0,v.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,v.jsx)(s,{size:`sm`,onClick:t,children:`Retry`})]})}function N(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&n>=0&&r>0}}function P(e){if(!e.trim())return{valid:!0};let t=Number(e);return Number.isSafeInteger(t)&&t>0?{count:t,valid:!0}:{valid:!1}}function F(e,t){return t===void 0?`Promote every delayed job in "${e}" and make it eligible to run now?`:`Promote up to ${t} delayed jobs in "${e}" and make them eligible to run now?`}function I(e,t,n){let r=e=>{if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},i=r(e),a=r(t),o=r(n);return{limit:typeof i==`number`?i:0,duration:typeof a==`number`?a:0,...typeof o==`number`?{ttl:o}:{},valid:typeof i==`number`&&typeof a==`number`&&o!==null}}function L(e){let t=Number(e);return{value:t,valid:e.trim()!==``&&Number.isSafeInteger(t)&&t>0}}function R({queue:e,paused:t,busy:n,run:r}){let[u,f]=(0,_.useState)(`0`),[p,m]=(0,_.useState)(`1000`),[y,b]=(0,_.useState)(`completed`),[x,S]=(0,_.useState)(``),C=N(u,p),w=P(x);return(0,v.jsxs)(a,{className:`mb-6`,children:[(0,v.jsx)(i,{title:`Lifecycle`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,v.jsx)(s,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>o.resume(e)),children:`Resume`}):(0,v.jsx)(s,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>o.pause(e)),children:`Pause`}),(0,v.jsx)(s,{size:`sm`,disabled:!0,title:h,children:`Requeue completed`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Promote N`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`promote-count`,"aria-invalid":!w.valid,value:x,onChange:e=>S(e.target.value),placeholder:`all`})})}),(0,v.jsx)(s,{size:`sm`,disabled:n||!w.valid,onClick:()=>r(`Promoted`,()=>o.promoteJobs(e,w.count),F(e,w.count)),children:`Promote delayed`}),!w.valid&&(0,v.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Promote N must be a positive whole number, or blank for all.`})]})]}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:h}),(0,v.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,v.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,v.jsx)(s,{size:`sm`,disabled:!0,title:g,children:`Drain`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`w-40`,children:(0,v.jsx)(d,{label:`State`,children:(0,v.jsxs)(c,{name:`clean-state`,disabled:!0,value:y,onChange:e=>b(e.target.value),children:[(0,v.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,v.jsx)(`option`,{value:`failed`,children:`Failed / DLQ`}),(0,v.jsx)(`option`,{value:`waiting`,children:`Queued`})]})})}),(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Grace (ms)`,children:(0,v.jsx)(l,{type:`number`,min:0,max:2**53-1,step:1,name:`clean-grace`,disabled:!0,"aria-invalid":!C.valid,value:u,onChange:e=>f(e.target.value)})})}),(0,v.jsx)(`div`,{className:`w-24`,children:(0,v.jsx)(d,{label:`Limit`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`clean-limit`,disabled:!0,"aria-invalid":!C.valid,value:p,onChange:e=>m(e.target.value)})})}),(0,v.jsx)(s,{variant:`danger`,size:`sm`,disabled:!0,title:g,children:`Clean`}),!C.valid&&(0,v.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Grace and limit must be whole numbers; limit must be positive.`})]})]}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:g})]})]})}function z({queue:e,busy:t,run:n}){let[r,u]=(0,_.useState)(``),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(`permanent`),[g,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(``),[w,T]=(0,_.useState)(``),[E,D]=(0,_.useState)(null),[O,k]=(0,_.useState)(null),A=I(r,f,m===`expires`?g:``),j=L(b);return(0,v.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Rate-limit desired state`}),(0,v.jsx)(`p`,{className:`mb-3 text-xs text-warning`,children:`Bunqueue v2.8.57 has no read endpoint. This blindly replaces an unknown policy; a receipt proves only what this dashboard applied at that time.`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,v.jsx)(d,{label:`Limit`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-limit`,value:r,onChange:e=>u(e.target.value),placeholder:`max per window`})})}),(0,v.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,v.jsx)(d,{label:`Window (ms)`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-duration`,value:f,onChange:e=>p(e.target.value),placeholder:`60000`})})}),(0,v.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,v.jsx)(d,{label:`TTL`,children:(0,v.jsxs)(c,{name:`rate-ttl-mode`,value:m,onChange:e=>h(e.target.value),children:[(0,v.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,v.jsx)(`option`,{value:`expires`,children:`Expires after`})]})})}),(0,v.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,v.jsx)(d,{label:`TTL (ms)`,hint:m===`permanent`?`Not sent`:void 0,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-ttl`,disabled:m===`permanent`,value:g,onChange:e=>y(e.target.value),placeholder:`—`})})}),(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:t||!A.valid,onClick:()=>n(`Rate limit set`,()=>o.setRateLimit(e,A.limit,A.duration,A.ttl),`Replace the unknown rate-limit policy for "${e}" with limit ${A.limit}, window ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`}?`,()=>D(`Applied limit ${A.limit} per ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`} at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Replace policy`}),(0,v.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,v.jsx)(d,{label:`Type ${e} to clear`,children:(0,v.jsx)(l,{name:`rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:S,onChange:e=>C(e.target.value)})})}),(0,v.jsx)(s,{size:`sm`,disabled:t||S!==e,onClick:()=>n(`No rate limit ensured`,()=>o.clearRateLimit(e),`Ensure queue "${e}" has no rate-limit policy? Bunqueue v2.8.57 cannot report its previous value.`,()=>D(`Applied no rate-limit policy at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Ensure no rate limit`}),!A.valid&&(r.trim()||f.trim()||g.trim())&&(0,v.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-danger`,children:`Limit and window are required; all values must be positive whole numbers.`}),E&&(0,v.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:E})]})]}),(0,v.jsxs)(a,{children:[(0,v.jsx)(i,{title:`Concurrency desired state`}),(0,v.jsx)(`p`,{className:`mb-3 text-xs text-warning`,children:`Bunqueue v2.8.57 has no read endpoint. This blindly replaces an unknown policy; a receipt proves only what this dashboard applied at that time.`}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,v.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,v.jsx)(d,{label:`Concurrency`,children:(0,v.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`concurrency`,value:b,onChange:e=>x(e.target.value),placeholder:`max in-flight`})})}),(0,v.jsx)(s,{variant:`accent`,size:`sm`,disabled:t||!j.valid,onClick:()=>n(`Concurrency set`,()=>o.setConcurrency(e,j.value),`Replace the unknown concurrency policy for "${e}" with ${j.value} maximum in-flight jobs?`,()=>k(`Applied concurrency ${j.value} at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Replace policy`}),(0,v.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,v.jsx)(d,{label:`Type ${e} to clear`,children:(0,v.jsx)(l,{name:`concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:w,onChange:e=>T(e.target.value)})})}),(0,v.jsx)(s,{size:`sm`,disabled:t||w!==e,onClick:()=>n(`No concurrency limit ensured`,()=>o.clearConcurrency(e),`Ensure queue "${e}" has no concurrency policy? Bunqueue v2.8.57 cannot report its previous value.`,()=>k(`Applied no concurrency policy at ${new Date().toISOString()}. Current server state cannot be read.`)),children:`Ensure no concurrency limit`}),!j.valid&&b.trim()&&(0,v.jsx)(`span`,{role:`alert`,className:`self-center text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),O&&(0,v.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:O})]})]})]})}export{A as a,j as i,z as n,D as o,M as r,E as s,R as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{A as r,_ as i,b as a,c as o,h as s,m as c,st as l,x as u,y as d}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{g as t,t as n}from"./react-vendor-Bjui4wS4.js";import{A as r,_ as i,b as a,c as o,h as s,m as c,st as l,x as u,y as d}from"./index-CAtsVmyh.js";import{a as f}from"./form-DsUq0w8s.js";import{r as p}from"./useServerActionGuard-CItj3hvh.js";import{a as m,i as h,n as g,o as _,r as v,s as y,t as b}from"./QueueActions-DTbD6uek.js";var x=e(t(),1),S=n(),C=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],w=500,T=200,E=w*T;function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function k(e){return D(e)&&C.every(t=>O(e[t]))}function A(e,t){if(!D(e)||e.ok!==!0||!Array.isArray(e.queues)||!O(e.total)||!O(e.limit)||e.limit<1||!O(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>D(e)&&typeof e.name==`string`&&e.name.length>0&&O(e.waiting)&&O(e.delayed)&&O(e.active)&&O(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function j(){let e=await l.queues(w,0);A(e,0);let t=e.total;if(t>E)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${E}.`);if(e.queues.length!==Math.min(w,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(w,t)} queues, received ${e.queues.length}.`);let n=new Map,r=e=>{for(let t of e.queues){if(n.has(t.name))throw Error(`Overlapping /dashboard/queues pages: queue "${t.name}" appeared more than once.`);n.set(t.name,t)}};r(e);let i=e.queues.length,a=1;for(;i<t;){if(a>=T)throw Error(`Queue discovery exceeded the safe limit of ${T} pages.`);let e=await l.queues(w,i);if(A(e,i),e.total!==t)throw Error(`Queue discovery changed during pagination: total moved from ${t} to ${e.total}. Retry the snapshot.`);let n=Math.min(w,t-i);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${i}: expected ${n} queues, received ${e.queues.length}.`);r(e),i+=e.queues.length,a+=1}if(n.size!==t)throw Error(`Incomplete /dashboard/queues snapshot: expected ${t} unique queues, received ${n.size}.`);return{...e,queues:[...n.values()],total:t,limit:w,offset:0}}function M(e,t){if(!D(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!k(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function N(e){if(!D(e)||e.ok!==!0||!y(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function P(e){if(!D(e)||e.ok!==!0||!_(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function F(e){if(!D(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!O(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function I(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function L(){let[e,t]=(0,x.useState)(``),[n,_]=(0,x.useState)(!1),[y,w]=(0,x.useState)(null),T=p(`queue-control:${e}`);(0,x.useEffect)(()=>{_(!1),w(null)},[T.scopeKey]);let{data:E,error:D,loading:O,refetch:k}=r(j,[],{intervalMs:3e4});(0,x.useEffect)(()=>{E&&t(e=>I(e,E.queues))},[E]);let{data:A,error:L,loading:R,refetch:z}=r((0,x.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([l.queueDetail(e,!1),l.getStallConfig(e).then(N).catch(()=>null),l.getDlqConfig(e).then(P).catch(()=>null)]);return M(t,e),{queue:e,detail:t,stall:n,dlq:r}},[e]),[e]),B=!E||E.queues.some(t=>t.name===e),V=A&&A.queue===e&&B?A:null,H=(t,n,r,i)=>{let a=e;if(!a||r&&!window.confirm(r))return;let o=T.begin(`queue-write`);o&&(_(!0),w(null),(async()=>{try{let e=await l.queuesSummary();if(!o.isCurrent())return;if(!e.some(e=>e.name===a))throw Error(`Queue "${a}" no longer exists`);let r=F(await n());if(!o.isCurrent())return;w({queue:a,ok:!0,text:`${t}${r==null?` ✓`:`: ${r}`}`}),i?.(),await z()}catch(e){o.isCurrent()&&w({queue:a,ok:!1,text:e.message})}finally{o.finish()&&_(!1)}})())};return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(s,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!V?.detail&&!!V.stall&&!!V.dlq&&!L&&!D}),(0,S.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`w-56`,children:(0,S.jsx)(f,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(E?.queues??[]).map(e=>(0,S.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),V?.detail&&(0,S.jsx)(i,{label:V.detail.paused?`Paused`:`Active`,tone:V.detail.paused?`amber`:`green`}),y?.queue===e&&(0,S.jsx)(`span`,{role:`status`,className:y.ok?`text-xs text-success`:`text-xs text-danger`,children:y.text})]}),D&&(0,S.jsx)(u,{onRetry:k,message:`Could not discover queues — ${D.message}. Retry to choose a queue.`}),L&&V&&(0,S.jsx)(u,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:z}),L&&!V?(0,S.jsx)(d,{error:L,onRetry:z}):O&&!E&&!e&&!D?(0,S.jsx)(a,{label:`Discovering queues…`}):R&&!V?(0,S.jsx)(a,{}):D&&!e?(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):V?.detail?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:C.map(e=>(0,S.jsx)(c,{label:e,value:o(V.detail.counts[e]),compact:!0},e))}),(0,S.jsx)(b,{queue:e,paused:V.detail.paused,busy:n,run:H},`${e}:lifecycle`),(0,S.jsx)(g,{queue:e,busy:n,run:H},`${e}:limits`),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[V.stall?(0,S.jsx)(m,{queue:e,config:V.stall,onSaved:async()=>{w({queue:e,ok:!0,text:`Stall config saved ✓`}),await z()}},`${e}:stall`):(0,S.jsx)(v,{title:`Stall detection`,onRetry:z}),V.dlq?(0,S.jsx)(h,{queue:e,config:V.dlq,onSaved:async()=>{w({queue:e,ok:!0,text:`DLQ config saved ✓`}),await z()}},`${e}:dlq`):(0,S.jsx)(v,{title:`DLQ policy`,onRetry:z})]})]}):!L&&(0,S.jsx)(`p`,{className:`text-sm text-faint`,children:E?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{L as QueueControl,j as loadAllQueuePages};
|