bunqueue-dashboard 0.0.36 → 0.0.38
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 +25 -10
- package/agent/backup/resultValidation.ts +1 -1
- package/agent/backup/routes.ts +4 -3
- package/agent/flow/routes.ts +7 -6
- package/agent/index.ts +17 -4
- package/agent/managedTarget.ts +41 -2
- package/agent/manager/config.ts +1 -1
- package/agent/queue/routes.ts +21 -14
- package/agent/server/controlRoutes.ts +39 -7
- package/agent/server/controlTarget.ts +116 -0
- package/agent/server/errors.ts +1 -0
- package/agent/server/handler.ts +10 -1
- package/agent/server/router.ts +19 -8
- package/agent/server/types.ts +7 -0
- package/agent/server.ts +10 -0
- package/agent/workflow/runtimeRoutes.ts +5 -4
- package/agent/workflows.ts +1 -1
- package/dist/.vite/manifest.json +207 -207
- package/dist/assets/{AddJob-UUa2fSXE.js → AddJob-CC4bfHLH.js} +1 -1
- package/dist/assets/{Alerts-7oGYfQMb.js → Alerts-C2bAi-Kj.js} +1 -1
- package/dist/assets/{Benchmark-C2NFp_kj.js → Benchmark-ClJmYZoC.js} +1 -1
- package/dist/assets/{BulkAddJobs-CL4yBae-.js → BulkAddJobs-BBWqQpP7.js} +1 -1
- package/dist/assets/{CopilotPanel-BQ2Cgo9p.js → CopilotPanel-Bhh-uCpN.js} +3 -3
- package/dist/assets/{Cron-DfWBhoBf.js → Cron-pJJ5KXFG.js} +1 -1
- package/dist/assets/{CronManager-DAK7RSOX.js → CronManager-lNZ4lHh1.js} +1 -1
- package/dist/assets/{Database-DqL7giEj.js → Database-DxiXsUl4.js} +1 -1
- package/dist/assets/{Diagnostics-D98YwN-6.js → Diagnostics-DLvCT7zI.js} +1 -1
- package/dist/assets/{Dlq-BHmA5PTI.js → Dlq-Bx4YXTp5.js} +1 -1
- package/dist/assets/{DlqControl-DihxvP-i.js → DlqControl-DJGhuyu3.js} +1 -1
- package/dist/assets/{DlqPro-ncgnDtpE.js → DlqPro-BhXIKtrt.js} +1 -1
- package/dist/assets/{Flows-B5N5Cil0.js → Flows-Bb9j-YhZ.js} +2 -2
- package/dist/assets/{JobInspector-B40nFiGh.js → JobInspector-DfqBq4O5.js} +2 -2
- package/dist/assets/{Jobs-Bla3IEef.js → Jobs-Blavwd1H.js} +1 -1
- package/dist/assets/{JobsPro-CnczVx7x.js → JobsPro-D8dH9um7.js} +1 -1
- package/dist/assets/{Logs-T91Q3cH0.js → Logs-B3dsGSF8.js} +1 -1
- package/dist/assets/{LogsPro-CMn6-Wwv.js → LogsPro-BCB7etG2.js} +1 -1
- package/dist/assets/{McpServer-BQBabwW-.js → McpServer-Cz1-GwD5.js} +2 -2
- package/dist/assets/{Metrics-DxT_RI2B.js → Metrics-Bkuy6Ntb.js} +1 -1
- package/dist/assets/{MetricsPro-Cjen-nAP.js → MetricsPro-BbJmy0oO.js} +1 -1
- package/dist/assets/{Overview-XN2ej8ph.js → Overview-Ba5odzYe.js} +1 -1
- package/dist/assets/{QueueActions-C-Aferd6.js → QueueActions-B6M0ByGt.js} +1 -1
- package/dist/assets/{QueueControl-B8Q9NX6t.js → QueueControl-CWHsVfWU.js} +1 -1
- package/dist/assets/{QueueDetail-BMhG0jUB.js → QueueDetail-BClRbWC5.js} +1 -1
- package/dist/assets/{QueueDetailPro-BKTTyLR4.js → QueueDetailPro-CIimG0pX.js} +1 -1
- package/dist/assets/{Queues-COqPMoY9.js → Queues-CGPgEkVm.js} +1 -1
- package/dist/assets/{QueuesOverview-pWdrPy8Z.js → QueuesOverview-ChC5Dtqh.js} +1 -1
- package/dist/assets/{S3Backup-BmsZ8xtq.js → S3Backup-5OKa8G13.js} +1 -1
- package/dist/assets/S3BackupPro-BkwTXdtw.js +3 -0
- package/dist/assets/{ServerControl-D3XwHr72.js → ServerControl-DJHKMaf9.js} +3 -3
- package/dist/assets/{Settings-BofKZoHn.js → Settings-C1HtCK6h.js} +1 -1
- package/dist/assets/{Usage-DAR9E22v.js → Usage-QyZkUhgs.js} +1 -1
- package/dist/assets/{UsagePro-Bc30N2Lo.js → UsagePro-DMxrXxur.js} +1 -1
- package/dist/assets/{Webhooks-Bg2k1PU4.js → Webhooks-D0JQQf0q.js} +1 -1
- package/dist/assets/{Workers-BqUZMJVQ.js → Workers-Cn8Bkgy1.js} +1 -1
- package/dist/assets/{WorkersPro-C9aSadUh.js → WorkersPro-BOTuX9EP.js} +1 -1
- package/dist/assets/{Workflows-BEFMfHmo.js → Workflows-DqTKWPmT.js} +1 -1
- package/dist/assets/{api-CQ5Z7xR7.js → api-V_sVpHDo.js} +1 -1
- package/dist/assets/bq-Bmysbg0r.js +1 -0
- package/dist/assets/{connectionStore-DbBYqHEY.js → connectionStore-CKFQrxDo.js} +1 -1
- package/dist/assets/{controlConnectionEpoch-CFSO6237.js → controlConnectionEpoch-JM4omZ6j.js} +1 -1
- package/dist/assets/{flowMutationSafety-CoOp94wS.js → flowMutationSafety-DObp9nJo.js} +1 -1
- package/dist/assets/index-Cue53Myw.js +8 -0
- package/dist/assets/install-CFiYX86d.js +3 -0
- package/dist/assets/{responses-kPO4rSu5.js → responses-CBLyy1Ob.js} +1 -1
- package/dist/assets/{toastStore-CS_9Xndn.js → toastStore-B7n0zS0y.js} +1 -1
- package/dist/assets/{upstreamPaths-D_LPsv7b.js → upstreamPaths-CDVsu6IM.js} +1 -1
- package/dist/assets/{usePolledData-DzlUpBOO.js → usePolledData-g80Z_UB-.js} +1 -1
- package/dist/assets/{useServerActionGuard-BlH-Kso1.js → useServerActionGuard-OTv6_fU0.js} +1 -1
- package/dist/assets/useThroughputSeries-CrsZYKbT.js +1 -0
- package/dist/index.html +7 -7
- package/package.json +14 -7
- package/scripts/embedded.gen.ts +160 -160
- package/scripts/serve.ts +38 -7
- package/scripts/serveHandler.ts +27 -7
- package/scripts/servePolicy.ts +54 -0
- package/dist/assets/S3BackupPro-AtlsPUJL.js +0 -3
- package/dist/assets/bq-BeBxa743.js +0 -1
- package/dist/assets/index-Cui9IwWy.js +0 -8
- package/dist/assets/install-Cd9Is10G.js +0 -3
- package/dist/assets/useThroughputSeries-C2pa1Wd_.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,h as r,t as i}from"./react-vendor-CyjgmGTq.js";import{o as a}from"./connectionStore-
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,h as r,t as i}from"./react-vendor-CyjgmGTq.js";import{o as a}from"./connectionStore-CKFQrxDo.js";import{a as o,i as s,t as c}from"./bq-Bmysbg0r.js";import{t as l}from"./toastStore-B7n0zS0y.js";import{T as u,o as d}from"./icons-CIvFfU2b.js";import{n as f}from"./usePolledData-g80Z_UB-.js";import{t as p}from"./Button-BPqpRZJD.js";import{n as m,t as h}from"./Card-C7NMhqUt.js";import{i as g,n as _,r as v,t as y}from"./feedback-BnGE2oW2.js";import{t as b}from"./PageHeader-BXlZSBcc.js";import{n as x,s as S}from"./format-Cg7VCIZW.js";import{a as C,c as w,n as T,s as E}from"./index-Cue53Myw.js";import{a as D}from"./form-tC20r4Ma.js";import{t as ee}from"./Pagination-Q-vf4hsX.js";var O=e(r(),1),k=e(n(),1),A=i();function j({columns:e,filter:t,onChange:n}){let[r,i]=(0,k.useState)(t?.column??``),[a,o]=(0,k.useState)(t?.op??`contains`),[s,c]=(0,k.useState)(t?.value??``),l=r||e[0]||``,d=()=>n(s.trim()?{column:l,op:a,value:s.trim()}:null);return e.length===0?null:(0,A.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`div`,{className:`w-40`,children:(0,A.jsx)(D,{value:l,"aria-label":`Filter column`,name:`database-filter-column`,autoComplete:`off`,onChange:e=>i(e.target.value),children:e.map(e=>(0,A.jsx)(`option`,{value:e,children:e},e))})}),(0,A.jsx)(`div`,{className:`w-32`,children:(0,A.jsxs)(D,{value:a,"aria-label":`Filter operator`,name:`database-filter-operator`,autoComplete:`off`,onChange:e=>o(e.target.value),children:[(0,A.jsx)(`option`,{value:`contains`,children:`contains`}),(0,A.jsx)(`option`,{value:`eq`,children:`=`}),(0,A.jsx)(`option`,{value:`ne`,children:`≠`})]})}),(0,A.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,A.jsx)(u,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,A.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&d(),"aria-label":`Filter value`,name:`database-filter-value`,autoComplete:`off`,placeholder:`value — Enter to filter`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-8 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,A.jsx)(p,{size:`sm`,onClick:d,disabled:!s.trim(),children:`Filter`}),t&&(0,A.jsx)(p,{size:`sm`,variant:`ghost`,onClick:()=>{c(``),n(null)},children:`Clear`}),(0,A.jsx)(`span`,{className:`text-[11px] text-faint`,children:`filters the whole table, server-side`})]})}var M=`bq-dash-db-history`,N=10,P=2e4,F=100;function I(e){let t=e==null?``:String(e),n=typeof e==`string`&&/^[=+\-@\t\r]/.test(e)?`'${e}`:t;return/[",\r\n]/.test(n)?`"${n.replaceAll(`"`,`""`)}"`:n}function L(e,t){return[e.map(I).join(`,`),...t.map(e=>e.map(I).join(`,`))].join(`
|
|
2
2
|
`)}function R(e,t,n){let r=URL.createObjectURL(new Blob([n],{type:t})),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}function z(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e.slice(0,F))if(!(typeof r!=`string`||r.length===0||r.length>P||n.has(r))&&(n.add(r),t.push(r),t.length===N))break;return t}function B(){try{return z(JSON.parse(localStorage.getItem(M)??`[]`))}catch{return[]}}function V(e){let t=z(e);try{localStorage.setItem(M,JSON.stringify(t))}catch{}return t}function H(e){return V([e,...B().filter(t=>t!==e)].slice(0,N))}function U(e){if(e==null)return`NULL`;let t=typeof e==`string`?e:String(e),n=t.trimStart();if(n.startsWith(`{`)||n.startsWith(`[`))try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}return t}async function W(e,t=c.captureAgentRequestTarget(),n){let r=Object.freeze({table:e.table,orderBy:e.orderBy,dir:e.dir,filter:e.filter?Object.freeze({...e.filter}):void 0});return c.getDbExportAtTarget(t,r,n)}var G=e=>JSON.stringify([e.baseUrl,e.token,e.agentToken]);function te({value:e,align:n}){if(e==null)return(0,A.jsx)(`span`,{className:`italic text-faint`,children:`NULL`});let r=typeof e==`string`?e:String(e);return(0,A.jsx)(`span`,{className:t(`block max-w-[24rem] truncate`,n===`right`&&`text-right tabular-nums`),title:r,children:r})}function ne({columns:e,rows:n,truncatedCells:r,colMeta:i,sort:a,onSort:o,onRowClick:s,dimmed:c}){let l=(0,k.useMemo)(()=>e.map((e,t)=>{let r=i?.[e]?.type?.toUpperCase()??``;if(/INT|REAL|NUM|DEC|DOUB|FLOA/.test(r))return!0;let a=!1;for(let e of n){let n=e[t];if(n!=null&&(a=!0,typeof n!=`number`))return!1}return a}),[e,n,i]);return(0,A.jsx)(`div`,{className:t(`max-h-[70vh] overflow-auto rounded-xl border border-line bg-surface transition-opacity`,c&&`pointer-events-none opacity-50`),children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`text-left text-[11px] uppercase tracking-wider text-faint`,children:[s&&(0,A.jsx)(`th`,{className:`sticky top-0 z-10 whitespace-nowrap border-b border-line bg-surface px-4 py-3 font-medium`,children:(0,A.jsx)(`span`,{className:`sr-only`,children:`Row actions`})}),e.map((e,n)=>{let r=i?.[e];return(0,A.jsx)(`th`,{className:t(`sticky top-0 z-10 whitespace-nowrap border-b border-line bg-surface px-4 py-3 font-medium`,l[n]&&`text-right`),"aria-sort":a?.col===e?a.dir===`asc`?`ascending`:`descending`:o?`none`:void 0,children:o?(0,A.jsxs)(`button`,{type:`button`,onClick:()=>o(e),"aria-label":`Sort by ${e}`,className:`inline-flex items-center gap-1 uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[e,r?.primaryKey&&(0,A.jsx)(`span`,{className:`rounded bg-accent/15 px-1 py-0.5 text-[9px] font-semibold text-accent`,children:`PK`}),r?.type&&(0,A.jsx)(`span`,{className:`text-faint/70`,children:r.type.toLowerCase()}),(0,A.jsx)(`span`,{"aria-hidden":`true`,className:a?.col===e?`text-accent`:`text-faint/60`,children:a?.col===e?a.dir===`asc`?`▲`:`▼`:`↕`})]}):e},e)})]})}),(0,A.jsx)(`tbody`,{children:n.map((e,t)=>(0,A.jsxs)(`tr`,{className:`border-b border-line font-mono text-xs last:border-0 hover:bg-surface-2/40`,children:[s&&(0,A.jsx)(`td`,{className:`whitespace-nowrap px-4 py-2`,children:(0,A.jsx)(`button`,{type:`button`,"aria-label":`View row ${t+1} details`,onClick:()=>s(t),className:`rounded-md border border-line px-2 py-1 font-sans text-[11px] font-medium text-muted transition-colors hover:border-line-strong hover:text-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,children:`View`})}),e.map((e,n)=>(0,A.jsx)(`td`,{className:`whitespace-nowrap px-4 py-2 text-muted`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(te,{value:e,align:l[n]?`right`:`left`}),r?.[t]?.[n]&&(0,A.jsx)(`span`,{title:`Value truncated — use the row's View action to read it in full`,className:`shrink-0 rounded bg-warning/15 px-1 text-[9px] font-semibold text-warning`,children:`…`})]})},n))]},t))})]})})}function K(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed database query response.`);let t=e;if(t.ok!==!0||!Array.isArray(t.columns)||t.columns.some(e=>typeof e!=`string`)||!Array.isArray(t.rows)||t.rows.length>500||t.rows.some(e=>!Array.isArray(e)||e.length!==t.columns.length)||!Number.isSafeInteger(t.rowCount)||t.rowCount!==t.rows.length||typeof t.truncated!=`boolean`||typeof t.ms!=`number`||!Number.isFinite(t.ms)||t.ms<0)throw Error(`Malformed database query response.`);return{columns:[...t.columns],rows:t.rows.map(e=>[...e]),rowCount:t.rowCount,truncated:t.truncated,ms:t.ms}}function re({sql:e,setSql:t,editorRef:n}){let r=a(G),[i,o]=(0,k.useState)(null),[s,l]=(0,k.useState)(null),[u,d]=(0,k.useState)(B),[f,g]=(0,k.useState)(null),_=(0,k.useRef)(0),v=(0,k.useRef)(null),y=(0,k.useRef)(r);y.current!==r&&(y.current=r,_.current++,v.current=null),(0,k.useEffect)(()=>(_.current++,v.current=null,o(null),l(null),g(null),()=>{_.current++,v.current=null}),[r]);let b=i===r,x=s?.target===r?s.message:null,C=f?.target===r?f:null,w=async(t=e,n=!0)=>{let i=t.trim();if(!i||v.current?.target===r)return;let s=++_.current,u=r;v.current={generation:s,target:u},o(u),l(null);try{let e=K(await c.db.query(t));if(s!==_.current||G(a.getState())!==u)return;g({...e,target:u}),n&&d(H(i))}catch(e){if(s!==_.current||G(a.getState())!==u)return;g(null),l({target:u,message:e.message})}finally{v.current?.generation===s&&(v.current=null),s===_.current&&o(null)}};return(0,A.jsxs)(h,{className:`mt-6`,children:[(0,A.jsx)(m,{title:`Query`,action:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(p,{size:`sm`,disabled:b||!e.trim(),onClick:()=>{let t=e.trim();t&&w(`EXPLAIN QUERY PLAN ${t}`,!1)},children:`Explain`}),(0,A.jsx)(p,{size:`sm`,variant:`accent`,disabled:b||!e.trim(),onClick:()=>w(),children:b?`Running…`:`Run`})]})}),(0,A.jsx)(`textarea`,{name:`database-sql-query`,autoComplete:`off`,ref:n,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&w()},rows:3,spellCheck:!1,"aria-label":`SQL query`,placeholder:`SELECT … — read-only: writes are rejected by the engine`,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`}),(0,A.jsx)(`p`,{className:`mt-1 text-[11px] text-faint`,children:`⌘/Ctrl+Enter runs. Connection is read-only.`}),u.length>0&&(0,A.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[(0,A.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`History`}),u.map(e=>(0,A.jsx)(`button`,{type:`button`,onClick:()=>t(e),title:e,className:`max-w-56 truncate rounded-md border border-line bg-surface-2 px-2 py-1 font-mono text-[11px] text-muted transition-colors hover:border-line-strong hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e},e)),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{V([]),d([])},className:`rounded-md px-2 py-1 text-[11px] text-faint transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Clear`})]}),(0,A.jsxs)(`div`,{"aria-live":`polite`,children:[x&&(0,A.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:x}),C&&!x&&(0,A.jsxs)(`div`,{className:`mt-4`,children:[(0,A.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-3`,children:[(0,A.jsxs)(`p`,{className:`text-xs text-faint`,children:[C.truncated?`≥ `:``,S(C.rowCount),` row`,C.rowCount===1?``:`s`,` · `,S(C.ms),` ms`,C.truncated&&(0,A.jsxs)(`span`,{className:`text-warning`,children:[` — showing first `,C.rows.length]})]}),C.rows.length>0&&(0,A.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,A.jsx)(p,{size:`sm`,onClick:()=>R(`query-results.csv`,`text/csv`,L(C.columns,C.rows)),children:`CSV`}),(0,A.jsx)(p,{size:`sm`,onClick:()=>R(`query-results.json`,`application/json`,JSON.stringify(C.rows.map(e=>Object.fromEntries(C.columns.map((t,n)=>[t,e[n]]))),null,2)),children:`JSON`})]})]}),C.rows.length>0?(0,A.jsx)(ne,{columns:C.columns,rows:C.rows}):(0,A.jsx)(`p`,{className:`text-xs text-faint`,children:`Query returned no rows.`})]})]})]})}var q=(e,t)=>t?e?.column===t.column&&e.op===t.op&&e.value===t.value:e===null;function J(e,t){return e.table===t.table&&e.limit===t.limit&&e.offset===t.offset&&e.orderBy===(t.orderBy??null)&&e.dir===t.dir&&q(e.filter,t.filter)}var Y=-(1n<<63n),X=(1n<<63n)-1n;function Z(e){if(e===null)return!0;if(typeof e==`number`)return Number.isSafeInteger(e);if(typeof e!=`string`||!/^-?(?:0|[1-9]\d*)$/.test(e)||e.length>20)return!1;try{let t=BigInt(e);return t>=Y&&t<=X}catch{return!1}}var ie=e=>e===null||typeof e==`string`||typeof e==`number`&&Number.isFinite(e);function ae(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed database rows response.`);let n=e,r=n.columns,i=n.rows,a=n.rowids,o=n.truncatedCells,s=n.filter,c=s===null||typeof s==`object`&&!!s&&!Array.isArray(s)&&typeof s.column==`string`&&(s.op===`contains`||s.op===`eq`||s.op===`ne`)&&typeof s.value==`string`;if(n.ok!==!0||typeof n.table!=`string`||!Array.isArray(r)||r.length===0||r.length>2e3||r.some(e=>typeof e!=`string`||!e)||new Set(r).size!==r.length||!Array.isArray(i)||i.length>t.limit||i.some(e=>!Array.isArray(e)||e.length!==r.length||e.some(e=>!ie(e)))||!Array.isArray(a)||a.length!==i.length||a.some(e=>!Z(e))||!Array.isArray(o)||o.length!==i.length||o.some(e=>!Array.isArray(e)||e.length!==r.length||e.some(e=>typeof e!=`boolean`))||!Number.isSafeInteger(n.total)||n.total<0||!Number.isSafeInteger(n.limit)||!Number.isSafeInteger(n.offset)||n.offset<0||n.orderBy!==null&&typeof n.orderBy!=`string`||n.dir!==`asc`&&n.dir!==`desc`||!c)throw Error(`Malformed database rows response.`);let l={ok:!0,table:n.table,columns:[...r],rows:i.map(e=>[...e]),rowids:[...a],truncatedCells:o.map(e=>[...e]),total:n.total,limit:n.limit,offset:n.offset,orderBy:n.orderBy,dir:n.dir,filter:s===null?null:{...s}};if(!J(l,t))throw Error(`Database rows identity mismatch: requested table "${t.table}" at offset ${t.offset}.`);let u=Math.min(l.limit,Math.max(0,l.total-l.offset));if(l.rows.length!==u)throw Error(`Malformed database rows response: row count does not match pagination metadata.`);return l}function Q(e,t){let n=e.rows[t],r=e.truncatedCells[t],i=e.rowids[t];return!n||!r||i===void 0||t<0?null:{index:t,table:e.table,columns:[...e.columns],row:[...n],rowid:i,truncated:[...r]}}var oe=(e,t)=>e.length===t.length&&e.every((e,n)=>Object.is(e,t[n]));function se(e,t){let n=Q(t,e.index);return n!==null&&n.table===e.table&&n.rowid===e.rowid&&oe(n.columns,e.columns)&&oe(n.row,e.row)&&oe(n.truncated,e.truncated)}function ce({schema:e}){return(0,A.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,A.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Column`}),(0,A.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Type`}),(0,A.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Constraints`}),(0,A.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Default`})]})}),(0,A.jsx)(`tbody`,{children:e.columns.map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,A.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-fg`,children:e.name}),(0,A.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-muted`,children:e.type}),(0,A.jsxs)(`td`,{className:`px-4 py-2 text-xs`,children:[e.primaryKey&&(0,A.jsx)(`span`,{className:`mr-1 rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold text-accent`,children:`PK`}),e.notNull&&(0,A.jsx)(`span`,{className:`rounded-md bg-surface-2 px-1.5 py-0.5 text-[10px] font-semibold text-muted`,children:`NOT NULL`})]}),(0,A.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-faint`,children:e.defaultValue??`—`})]},e.name))})]})}),(0,A.jsxs)(h,{children:[(0,A.jsx)(m,{title:`Indexes (${e.indexes.length})`}),e.indexes.length===0?(0,A.jsx)(`p`,{className:`text-xs text-faint`,children:`No indexes on this table.`}):(0,A.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.indexes.map(e=>(0,A.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 font-mono text-xs`,children:[(0,A.jsx)(`span`,{className:`text-fg`,children:e.name}),e.unique&&(0,A.jsx)(`span`,{className:`rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold text-accent`,children:`UNIQUE`}),(0,A.jsxs)(`span`,{className:`text-faint`,children:[`(`,e.columns.join(`, `),`)`]})]},e.name))})]}),e.sql&&(0,A.jsxs)(h,{children:[(0,A.jsx)(m,{title:`DDL`,action:(0,A.jsx)(C,{value:e.sql})}),(0,A.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:e.sql})]})]})}function le({db:e}){let{anyTruncated:n,colMeta:r,cycleSort:i,data:a,dbMissing:o,detail:s,editorRef:c,exportBusy:l,exportPage:u,exportTable:d,filter:f,info:m,infoError:C,msg:w,page:E,pageSize:D,queryThisTable:O,refetchInfo:k,refetchRows:M,refetchSchema:N,refetchTables:P,requestModal:F,rowsLoading:I,schema:L,schemaError:R,selectTable:z,selected:B,setDetailSelection:V,setFilter:H,setPage:U,setSql:W,setTab:G,sort:te,sql:K,tab:q,tables:J,tablesError:Y,tablesLoading:X,visibleRowsError:Z}=e;return(0,A.jsxs)(`div`,{"data-database-background":``,inert:s?!0:void 0,"aria-hidden":s?!0:void 0,children:[(0,A.jsx)(b,{title:`Database`,description:`SQLite inspector — schema, data and queries over a read-only connection.`,actions:(0,A.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2.5 py-1 text-[11px] font-medium text-success`,children:`read-only`})}),Y&&!o&&(0,A.jsx)(g,{message:`Could not read the database — ${Y.message}`,onRetry:P}),C&&!o&&(0,A.jsx)(g,{message:`Could not read database metadata — ${C.message}`,onRetry:k}),m&&(0,A.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-5`,children:[(0,A.jsx)(T,{label:`SQLite`,value:m.sqliteVersion,compact:!0}),(0,A.jsx)(T,{label:`On disk`,value:x(m.fileSize+m.walSize),compact:!0}),(0,A.jsx)(T,{label:`Journal`,value:m.journalMode.toUpperCase(),compact:!0}),(0,A.jsx)(T,{label:`Tables`,value:S(m.tables),compact:!0}),(0,A.jsx)(T,{label:`Indexes`,value:S(m.indexes),compact:!0})]}),o?(0,A.jsx)(y,{title:`No database yet`,hint:Y.message}):X&&J.length===0?(0,A.jsx)(v,{label:`Reading database…`}):(0,A.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-4`,children:[(0,A.jsxs)(h,{padded:!1,className:`self-start overflow-hidden`,children:[(0,A.jsxs)(`div`,{className:`border-b border-line px-4 py-3 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Tables (`,J.length,`)`]}),(0,A.jsxs)(`ul`,{className:`max-h-[28rem] overflow-y-auto`,children:[J.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{type:`button`,onClick:()=>z(e.name),className:t(`flex w-full items-center justify-between gap-2 px-4 py-2 text-left text-sm transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,B===e.name?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:[(0,A.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.name}),(0,A.jsx)(`span`,{className:`shrink-0 text-[11px] text-faint tabular-nums`,children:S(e.rows)})]})},e.name)),J.length===0&&(0,A.jsx)(`li`,{className:`px-4 py-6 text-center text-xs text-faint`,children:`No tables.`})]})]}),(0,A.jsx)(`div`,{className:`min-w-0 lg:col-span-3`,children:J.length===0?(0,A.jsx)(y,{title:`No tables`,hint:`This database has no user tables yet.`}):(0,A.jsxs)(A.Fragment,{children:[B&&(0,A.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`mr-auto min-w-0 truncate font-mono text-sm text-fg`,title:B,children:B}),(0,A.jsx)(p,{size:`sm`,variant:`ghost`,onClick:O,children:`Query`}),(0,A.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:[`data`,`schema`].map(e=>(0,A.jsx)(`button`,{type:`button`,onClick:()=>G(e),"aria-pressed":q===e,className:t(`rounded-md px-3 py-1 text-xs font-medium capitalize transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,q===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:e},e))}),q===`data`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(p,{size:`sm`,disabled:!a||a.rows.length===0,title:a?`Exports the ${a.rows.length} rows on this page only`:void 0,onClick:u,children:[`Export page`,a?` (${a.rows.length})`:``]}),(0,A.jsx)(p,{size:`sm`,variant:`accent`,disabled:l||!a||a.total===0,onClick:d,children:l?`Exporting…`:`Export table${a?` (${S(a.total)})`:``}`})]})]}),q===`data`&&B&&(0,A.jsx)(j,{columns:a?.columns??L?.columns.map(e=>e.name)??[],filter:f,onChange:e=>{H(e),U(0),V(null)}},B),w&&(0,A.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:w}),q===`schema`?R?(0,A.jsx)(y,{title:`Could not read schema`,hint:R.message,action:(0,A.jsx)(p,{size:`sm`,onClick:N,children:`Retry`})}):L?.table===B?(0,A.jsx)(ce,{schema:L}):(0,A.jsx)(v,{label:`Reading schema of ${B}…`}):Z?(0,A.jsx)(_,{error:Z,onRetry:M}):I&&!a?(0,A.jsx)(v,{label:`Reading ${B}…`}):a?a.total===0?(0,A.jsx)(y,{title:f?`No matching rows`:`Empty table`,hint:f?`No rows match the current filter.`:`"${a.table}" has no rows.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ne,{columns:a.columns,rows:a.rows,truncatedCells:a.truncatedCells,colMeta:r,sort:te,onSort:i,onRowClick:e=>{let t=Q(a,e);t&&F(`database-row`)&&V(t)},dimmed:I&&!a}),n&&(0,A.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Cells over 2000 chars and BLOBs are abbreviated in the grid and CSV — use the row's View action to read the full value.`}),(0,A.jsx)(ee,{page:E,pageSize:D,total:a.total,onPageChange:e=>{U(e),V(null)},label:`rows`})]}):(0,A.jsx)(y,{title:`Select a table`,hint:`Pick a table on the left to browse its rows.`}),(0,A.jsx)(re,{sql:K,setSql:W,editorRef:c})]})})]})]})}var ue=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function de({table:e,columns:t,row:n,rowid:r,truncated:i,onClose:a}){let[o,s]=(0,k.useState)({}),[l,u]=(0,k.useState)({}),f=(0,k.useRef)(null),p=(0,k.useRef)(null),m=(0,k.useRef)(a);m.current=a,(0,k.useEffect)(()=>{let e=document.activeElement,t=f.current,n=()=>t?Array.from(t.querySelectorAll(ue)).filter(e=>e.getAttribute(`aria-hidden`)!==`true`):[],r=(e=!1)=>{let r=n();(e?r.at(-1):r[0])?.focus(),r.length===0&&t?.focus()},i=e=>{if(e.key===`Escape`){e.preventDefault(),m.current();return}if(e.key!==`Tab`)return;let r=n();if(r.length===0){e.preventDefault(),t?.focus();return}let i=document.activeElement,a=r[0],o=r[r.length-1];e.shiftKey&&(i===a||!i||!t?.contains(i))?(e.preventDefault(),o.focus()):!e.shiftKey&&(i===o||!i||!t?.contains(i))&&(e.preventDefault(),a.focus())},a=e=>{t&&!t.contains(e.target)&&r()};return p.current?.focus(),document.activeElement!==p.current&&t?.focus(),document.addEventListener(`keydown`,i,!0),document.addEventListener(`focusin`,a),()=>{document.removeEventListener(`keydown`,i,!0),document.removeEventListener(`focusin`,a),E(`database-row`)&&e?.isConnected&&e.focus()}},[]);let h=JSON.stringify(t.filter((e,t)=>i[t]));return(0,k.useEffect)(()=>{s({}),u({});let t=JSON.parse(h);if(r==null||t.length===0)return;let n=!1;return Promise.all(t.map(async t=>{try{let i=await c.db.cell(e,r,t);if(!i||typeof i!=`object`||!Object.hasOwn(i,`value`))throw Error(`Malformed full-cell response.`);n||s(e=>({...e,[t]:i.value}))}catch(e){if(!n){let n=e instanceof Error?e.message:String(e);u(e=>({...e,[t]:n.slice(0,300)}))}}})),()=>{n=!0}},[e,r,h]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{type:`button`,"aria-label":`Close row detail`,onClick:a,className:`fixed inset-0 z-40 bg-black/50`}),(0,A.jsxs)(`aside`,{ref:f,role:`dialog`,"aria-modal":`true`,"aria-label":`${e} row ${r??`detail`}`,tabIndex:-1,className:`fixed inset-y-0 right-0 z-50 flex w-full max-w-xl flex-col border-l border-line bg-surface shadow-xl focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-accent`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-5 py-4`,children:[(0,A.jsxs)(`h2`,{className:`font-mono text-sm text-fg`,children:[e,` · row detail`]}),(0,A.jsx)(`button`,{ref:p,type:`button`,"aria-label":`Close`,onClick:a,className:`flex size-8 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,A.jsx)(d,{className:`size-4`})})]}),(0,A.jsx)(`div`,{className:`flex-1 overscroll-contain overflow-y-auto p-5`,children:(0,A.jsx)(`dl`,{className:`flex flex-col gap-4`,children:t.map((e,t)=>{let r=Object.hasOwn(o,e),a=r?o[e]:n[t],s=U(a),c=s.includes(`
|
|
3
3
|
`)||s.length>80;return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`dt`,{className:`mb-1 flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-faint`,children:[e,a!=null&&(0,A.jsx)(C,{value:String(a)}),i[t]&&!r&&(Object.hasOwn(l,e)?(0,A.jsxs)(`span`,{role:`alert`,className:`normal-case text-danger`,children:[`(full value unavailable — `,l[e],`)`]}):(0,A.jsx)(`span`,{className:`text-warning`,children:`(loading full value…)`}))]}),(0,A.jsx)(`dd`,{children:a==null?(0,A.jsx)(`span`,{className:`italic text-faint`,children:`NULL`}):c?(0,A.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:s}):(0,A.jsx)(`span`,{className:`break-words font-mono text-sm text-fg`,children:s})})]},e)})})})]})]})}function fe({data:e,filter:t,page:n,selected:r,sort:i}){let o=a(G),[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(null),m=(0,k.useRef)(!1),h=(0,k.useRef)(null);return(0,k.useEffect)(()=>(h.current?.abort(),h.current=null,m.current=!1,d(!1),p(null),()=>{h.current?.abort(),h.current=null,m.current=!1}),[o]),{exportBusy:u,exportPage:()=>{e&&R(`${e.table}-page${n+1}.csv`,`text/csv`,L(e.columns,e.rows))},exportTable:async()=>{if(!r||m.current)return;m.current=!0;let e=G(a.getState()),n={table:r,orderBy:i?.col,dir:i?.dir??`asc`,filter:t?{...t}:void 0},o=c.captureAgentRequestTarget(),u=new AbortController;h.current=u,d(!0),p(null);try{let t=await W(n,o,u.signal);if(u.signal.aborted||G(a.getState())!==e)return;R(`${n.table}.csv`,`text/csv;charset=utf-8`,t.content);let r=t.cap===`rows`?`Exported the first ${S(t.rowCount)} rows (row cap reached)`:t.cap===`bytes`?`Exported ${S(t.rowCount)} rows (${x(s)} byte cap reached)`:`Exported ${S(t.rowCount)} rows`;p(r),l.success(`Export of ${n.table} complete`,r)}catch(t){if(u.signal.aborted||G(a.getState())!==e)return;p(`Export failed: ${t.message}`),l.error(`Export of ${n.table} failed`,t.message)}finally{h.current===u&&(h.current=null,m.current=!1,u.signal.aborted||d(!1))}},msg:f}}var $=50;function pe(){let[e,t]=(0,k.useState)(``),[n,r]=(0,k.useState)(0),[i,a]=(0,k.useState)(null),[s,l]=(0,k.useState)(`data`),[u,d]=(0,k.useState)(null),[p,m]=(0,k.useState)(null),h=w(e=>e.active),g=w(e=>e.request),_=w(e=>e.release),[v,y]=(0,k.useState)(`SELECT name FROM sqlite_master WHERE type = 'table'`),b=(0,k.useRef)(null);(0,k.useEffect)(()=>{p===null?_(`database-row`):h!==`database-row`&&m(null)},[p,h,_]),(0,k.useEffect)(()=>()=>{w.getState().release(`database-row`)},[]);let{data:x,error:S,loading:C,refetch:T}=f(()=>c.db.tables(),[],{intervalMs:1e4}),E=(0,k.useMemo)(()=>x?.tables??[],[x]),D=S instanceof o&&S.status===404,{data:ee,error:O,refetch:A}=f(()=>D?Promise.resolve(null):c.db.info(),[D],{intervalMs:15e3}),j=e||E[0]?.name||``;(0,k.useEffect)(()=>{!e&&E[0]&&t(E[0].name)},[e,E]);let{data:M,error:N,refetch:P}=f(()=>j?c.db.schema(j):Promise.resolve(null),[j],{intervalMs:3e4}),F=(0,k.useMemo)(()=>{let e={};if(M?.table===j)for(let t of M.columns)e[t.name]={type:t.type,primaryKey:t.primaryKey};return e},[M,j]),I=u?JSON.stringify([u.column,u.op,u.value]):``,{data:L,error:R,loading:z,refetch:B}=f((0,k.useCallback)(async()=>{if(!j)return null;let e={table:j,limit:$,offset:n*$,orderBy:i?.col,dir:i?.dir??`asc`,filter:u??void 0};return ae(await c.db.rows(j,$,e.offset,i?.col,i?.dir,u??void 0),e)},[j,n,i,u]),[j,n,i,I],{intervalMs:6e3}),V={table:j,limit:$,offset:n*$,orderBy:i?.col,dir:i?.dir??`asc`,filter:u??void 0},H=!!L&&J(L,V),U=R??(L&&!H?Error(`Database rows identity no longer matches the selected table and page.`):null),W=!U&&H?L:null,G=p!==null&&W!==null&&se(p,W),te=G?p:null;(0,k.useEffect)(()=>{p&&!G&&m(null)},[p,G]),(0,k.useEffect)(()=>{W&&W.total>0&&W.rows.length===0&&n>0&&r(Math.max(0,Math.ceil(W.total/$)-1))},[W,n]);let ne=()=>{r(0),a(null),d(null),m(null)},K=e=>{t(e),l(`data`),ne()},re=e=>{r(0),m(null),a(t=>t?.col===e?t.dir===`asc`?{col:e,dir:`desc`}:null:{col:e,dir:`asc`})},q=()=>{let e=`SELECT * FROM "${j.replaceAll(`"`,`""`)}" LIMIT 100`;y(e),requestAnimationFrame(()=>{b.current?.focus(),b.current?.scrollIntoView({behavior:`smooth`,block:`center`})})},Y=!!W?.truncatedCells.some(e=>e.some(Boolean)),{exportBusy:X,exportPage:Z,exportTable:ie,msg:Q}=fe({data:W,filter:u,page:n,selected:j,sort:i});return{activeModal:h,anyTruncated:Y,colMeta:F,cycleSort:re,data:W,dbMissing:D,detail:te,editorRef:b,exportBusy:X,exportPage:Z,exportTable:ie,filter:u,info:ee,infoError:O,msg:Q,page:n,pageSize:$,queryThisTable:q,refetchInfo:A,refetchRows:B,refetchSchema:P,refetchTables:T,requestModal:g,rowsLoading:z,schema:M,schemaError:N,selectTable:K,selected:j,setDetailSelection:m,setFilter:d,setPage:r,setSql:y,setTab:l,sort:i,sql:v,tab:s,tables:E,tablesError:S,tablesLoading:C,visibleRowsError:U}}function me(){let e=pe(),{activeModal:t,detail:n,setDetailSelection:r}=e;return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(le,{db:e}),n&&t===`database-row`&&(0,O.createPortal)((0,A.jsx)(de,{table:n.table,columns:n.columns,row:n.row,rowid:n.rowid,truncated:n.truncated,onClose:()=>r(null)}),document.body)]})}export{me as Database};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{t as r}from"./bq-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{t as r}from"./bq-Bmysbg0r.js";import{t as i}from"./toastStore-B7n0zS0y.js";import{t as a}from"./api-V_sVpHDo.js";import{n as o}from"./usePolledData-g80Z_UB-.js";import{t as s}from"./Button-BPqpRZJD.js";import{n as c,t as l}from"./Card-C7NMhqUt.js";import{i as u,r as d}from"./feedback-BnGE2oW2.js";import{n as f}from"./StatusBadge-B0I7hNBX.js";import{t as p}from"./PageHeader-BXlZSBcc.js";import{n as m,s as h,u as g}from"./format-Cg7VCIZW.js";import{a as _,n as v}from"./index-Cue53Myw.js";var y=e(t(),1),b=n();function x(e,t){return t?{label:`Unavailable`,tone:`red`,detail:t}:e===null?{label:`Unknown`,tone:`zinc`,detail:`No response yet`}:e.trim()===`OK`?{label:`Live`,tone:`green`,detail:`HTTP 200 · OK`}:{label:`Unexpected`,tone:`amber`,detail:`HTTP 200 · ${e.trim().slice(0,80)||`empty body`}`}}function S(e,t){return t?{label:`Unavailable`,tone:`red`,detail:t}:e?e.ok===!0&&e.ready===!0?{label:`Ready`,tone:`green`,detail:`Persistence accepts traffic`}:e.ok===!1&&e.ready===!1?{label:`Not ready`,tone:`red`,detail:e.storage.error??`Persistence is degraded`}:{label:`Unexpected`,tone:`amber`,detail:`Incoherent readiness payload`}:{label:`Unknown`,tone:`zinc`,detail:`No response yet`}}function C({path:e,state:t}){return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-b border-line py-2.5 last:border-0`,children:[(0,b.jsx)(`code`,{className:`w-20 shrink-0 font-mono text-xs text-fg`,children:e}),(0,b.jsx)(f,{label:t.label,tone:t.tone}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 text-right text-xs text-faint`,children:t.detail})]})}function w({snapshot:e}){let t=e.metrics?.metrics;return(0,b.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`Orchestrator probes`}),(0,b.jsx)(`p`,{className:`mb-2 text-xs text-muted`,children:`Native Bunqueue liveness and persistence-readiness endpoints.`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(C,{path:`/healthz`,state:x(e.healthz,e.healthzError)}),(0,b.jsx)(C,{path:`/live`,state:x(e.live,e.liveError)}),(0,b.jsx)(C,{path:`/ready`,state:S(e.ready,e.readyError)})]})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`JSON metrics`}),e.metricsError?(0,b.jsxs)(`p`,{className:`text-sm text-danger`,children:[`Unavailable — `,e.metricsError]}):t?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,b.jsx)(O,{k:`Pushed`,v:h(t.totalPushed)}),(0,b.jsx)(O,{k:`Pulled`,v:h(t.totalPulled)}),(0,b.jsx)(O,{k:`Completed`,v:h(t.totalCompleted)}),(0,b.jsx)(O,{k:`Failed`,v:h(t.totalFailed)})]}):(0,b.jsx)(`p`,{className:`text-sm text-muted`,children:`No metrics response yet.`}),(0,b.jsx)(`p`,{className:`mt-3 font-mono text-xs text-faint`,children:`GET /metrics · application/json`})]})]})}function T({heap:e,busy:t,onLoad:n}){return(0,b.jsxs)(l,{className:`mt-6`,children:[(0,b.jsx)(c,{title:`Heap statistics`,action:(0,b.jsx)(s,{size:`sm`,disabled:t,onClick:n,children:t?`Loading…`:e?`Refresh`:`Load`})}),e?(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,b.jsx)(O,{k:`Objects`,v:h(e.heap?.objectCount??0)}),(0,b.jsx)(O,{k:`Protected`,v:h(e.heap?.protectedCount??0)}),(0,b.jsx)(O,{k:`Global`,v:h(e.heap?.globalCount??0)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wider text-faint`,children:`Top object types`}),(0,b.jsx)(`div`,{className:`max-h-52 overflow-y-auto rounded-lg border border-line`,children:(0,b.jsx)(`table`,{className:`w-full text-xs`,children:(0,b.jsx)(`tbody`,{children:(e.topObjectTypes??[]).map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,b.jsx)(`td`,{className:`px-3 py-1.5 font-mono text-muted`,children:e.type}),(0,b.jsx)(`td`,{className:`px-3 py-1.5 text-right tnum text-fg`,children:h(e.count)})]},e.type))})})})]})]}):(0,b.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On-demand `,(0,b.jsx)(`code`,{className:`font-mono text-xs`,children:`bun:jsc`}),` heap breakdown (forces a GC first). Use it to spot which internal object type is growing when chasing a leak.`]})]})}function E(){let e=r.prometheusUrl();return(0,b.jsxs)(l,{className:`mt-6`,children:[(0,b.jsx)(c,{title:`Prometheus`}),(0,b.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Scrape endpoint (text exposition) for Grafana / Alertmanager. Auth is required only if the server sets `,(0,b.jsx)(`code`,{className:`font-mono text-xs`,children:`requireAuthForMetrics`}),`.`]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-line bg-surface-2 px-3 py-2`,children:[(0,b.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-fg`,children:e}),(0,b.jsx)(_,{value:e})]})]})}function D({stats:e}){return e?(0,b.jsxs)(l,{className:`mt-6`,children:[(0,b.jsx)(c,{title:`Totals since restart`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsx)(O,{k:`Pushed`,v:h(e.totalPushed)}),(0,b.jsx)(O,{k:`Pulled`,v:h(e.totalPulled)}),(0,b.jsx)(O,{k:`Completed`,v:h(e.totalCompleted)}),(0,b.jsx)(O,{k:`Failed`,v:h(e.totalFailed)})]})]}):null}function O({k:e,v:t}){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,b.jsx)(`div`,{className:`mt-1 text-lg font-semibold tnum text-fg`,children:t})]})}async function k(e){try{return{value:await e,error:null}}catch(e){return{value:null,error:e instanceof Error?e.message:String(e)}}}function A(){let{data:e,error:t,loading:n,refetch:f}=o(async()=>{let[e,t,n,i,o,s,c]=await Promise.all([k(r.health()),k(r.storage()),k(r.stats()),k(a.healthz()),k(a.live()),k(a.ready()),k(a.metrics())]);return{health:e.value,storage:t.value,stats:n.value,healthError:e.error,storageError:t.error,statsError:n.error,healthz:i.value,live:o.value,ready:s.value,metrics:c.value,healthzError:i.error,liveError:o.error,readyError:s.error,metricsError:c.error}},[]),[h,_]=(0,y.useState)(null),x=(0,y.useRef)(0),S=async()=>{let e=++x.current;_(`…`);let t=performance.now();try{await r.ping(),e===x.current&&_(`${Math.round(performance.now()-t)} ms`)}catch{e===x.current&&_(`unreachable`)}},[C,A]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),P=async()=>{A(!0),N(null);try{let e=await r.gc(),t=e.before.rss-e.after.rss,n=t>0?`Freed ${t} MB (RSS ${e.before.rss}→${e.after.rss})`:`No memory reclaimed`;N(n),i.success(`Memory compacted`,n),f()}catch(e){i.error(`GC failed`,e.message),N(e.message)}finally{A(!1)}},[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(!1),z=async()=>{R(!0);try{I(await r.heapStats())}catch(e){i.error(`Heap stats failed`,e.message)}finally{R(!1)}};if(n&&!e&&!t)return(0,b.jsx)(d,{label:`Loading diagnostics…`});let B=e??{health:null,storage:null,stats:null,healthError:null,storageError:null,statsError:null,healthz:null,live:null,ready:null,metrics:null,healthzError:null,liveError:null,readyError:null,metricsError:null},V=B.health,H=B.storage?.data,U=B.stats?.stats,W=V!=null,G=H!=null,K=W&&V.ok===!0,q=!!t||!!B.healthError||!!B.storageError||!!B.statsError||!!B.healthzError||!!B.liveError||!!B.readyError||!!B.metricsError;return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Diagnostics`,description:`Server health, storage, memory and connections.`,live:!!e&&!q}),t&&(0,b.jsx)(u,{message:`Diagnostics refresh failed — ${t.message}`,onRetry:f}),B.healthError&&(0,b.jsx)(u,{message:`Health unavailable — ${B.healthError}`,onRetry:f}),B.storageError&&(0,b.jsx)(u,{message:`Storage diagnostics unavailable — ${B.storageError}`,onRetry:f}),B.statsError&&(0,b.jsx)(u,{message:`Server totals unavailable — ${B.statsError}`,onRetry:f}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsx)(v,{label:`Status`,value:W?V.status??(V.ok?`healthy`:`degraded`):`Unavailable`,tone:K?`green`:`red`,compact:!0}),(0,b.jsx)(v,{label:`Version`,value:V?.version?`v${V.version}`:`—`,compact:!0}),(0,b.jsx)(v,{label:`Uptime`,value:g(V?.uptime),compact:!0}),(0,b.jsx)(v,{label:`Disk`,value:G?H.diskFull?`Full`:`Healthy`:`Unavailable`,tone:!G||H.diskFull?`red`:`green`,compact:!0})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`Connectivity`,action:(0,b.jsxs)(s,{size:`sm`,onClick:S,children:[`Ping`,h?` · ${h}`:``]})}),(0,b.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,b.jsx)(j,{k:`WebSocket clients`,v:V?.connections?.ws==null?`—`:String(V.connections.ws)}),(0,b.jsx)(j,{k:`SSE clients`,v:V?.connections?.sse==null?`—`:String(V.connections.sse)}),(0,b.jsx)(j,{k:`Storage error`,v:B.storageError?`unavailable — ${B.storageError}`:H?.error?String(H.error):G?`none`:`—`})]})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`Memory`,action:(0,b.jsx)(s,{size:`sm`,disabled:C,onClick:P,children:C?`Compacting…`:`Compact (GC)`})}),(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,b.jsx)(O,{k:`Heap used`,v:V?.memory?m(V.memory.heapUsed*1024*1024):`—`}),(0,b.jsx)(O,{k:`Heap total`,v:V?.memory?m(V.memory.heapTotal*1024*1024):`—`}),(0,b.jsx)(O,{k:`RSS`,v:V?.memory?m(V.memory.rss*1024*1024):`—`})]}),M&&(0,b.jsx)(`p`,{className:`mt-3 text-xs text-muted`,children:M})]})]}),(0,b.jsx)(w,{snapshot:B}),(0,b.jsx)(T,{heap:F,busy:L,onLoad:z}),(0,b.jsx)(E,{}),(0,b.jsx)(D,{stats:U})]})}function j({k:e,v:t}){return(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,b.jsx)(`dt`,{className:`text-muted`,children:e}),(0,b.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}export{A as Diagnostics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{u as r}from"./icons-CIvFfU2b.js";import{t as i}from"./api-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{u as r}from"./icons-CIvFfU2b.js";import{t as i}from"./api-V_sVpHDo.js";import{n as a}from"./usePolledData-g80Z_UB-.js";import{t as o}from"./Button-BPqpRZJD.js";import{i as s,n as c,r as l,t as u}from"./feedback-BnGE2oW2.js";import{t as d}from"./PageHeader-BXlZSBcc.js";import{l as f,s as p}from"./format-Cg7VCIZW.js";import{n as m}from"./index-Cue53Myw.js";import{a as h}from"./form-tC20r4Ma.js";import{t as g}from"./Pagination-Q-vf4hsX.js";import{r as _,t as v}from"./flowMutationSafety-DObp9nJo.js";import{t as y}from"./Jobs-Blavwd1H.js";var b=e(t(),1),x=n(),S=25;function C(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}async function w(){let e=await y();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!C(e.waiting)||!C(e.delayed)||!C(e.active)||!C(e.dlq)||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function T(){let[e,t]=(0,b.useState)(``),[n,y]=(0,b.useState)(0),{data:C,error:T,loading:E,refetch:D}=a(w,[],{intervalMs:3e4});(0,b.useEffect)(()=>{if(e||!C?.queues?.length)return;let n=C.queues.find(e=>e.dlq>0)??C.queues[0];t(n.name)},[C,e]);let{data:O,error:k,loading:A,refetch:j}=a((0,b.useCallback)(async()=>{if(!e)return{entries:[],total:0};let t=await i.dlq(e,S,n*S);return{entries:t.entries??[],total:t.total??t.entries?.length??0}},[e,n]),[e,n]),M=O?.entries??[];return(0,x.jsxs)(`div`,{children:[k&&O&&(0,x.jsx)(s,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:j}),T&&(0,x.jsx)(s,{onRetry:D,message:`Could not discover queues — ${T.message}. Retry before selecting a queue.`}),(0,x.jsx)(d,{title:`Dead Letter Queue`,description:`Jobs that exhausted their retries.`,live:!!e&&!!O&&!k&&!T,actions:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(o,{size:`sm`,disabled:!0,title:v,children:`Retry all`}),(0,x.jsx)(o,{variant:`danger`,size:`sm`,disabled:!0,title:_,children:`Purge`})]})}),(0,x.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-56`,children:(0,x.jsx)(h,{value:e,"aria-label":`Queue`,name:`classic-dlq-queue`,autoComplete:`off`,onChange:e=>{t(e.target.value),y(0)},children:(C?.queues??[]).map(e=>(0,x.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,x.jsx)(`div`,{className:`w-40`,children:(0,x.jsx)(m,{label:`DLQ Entries`,value:e&&O?p(O.total):`—`,tone:e&&O?.total?`red`:`default`,compact:!0})})]}),k&&!O?(0,x.jsx)(c,{error:k,onRetry:j}):E&&!C&&!e&&!T?(0,x.jsx)(l,{label:`Discovering queues…`}):A&&!O&&!k?(0,x.jsx)(l,{label:`Loading DLQ…`}):T&&!e?(0,x.jsx)(u,{icon:(0,x.jsx)(r,{}),title:`Could not discover queues`,hint:`${T.message}. Retry the queue discovery request above.`}):e?M.length===0?(0,x.jsx)(u,{icon:(0,x.jsx)(r,{}),title:`Dead letter queue is empty`,hint:`Jobs land here after exhausting their retry attempts.`}):(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,x.jsx)(`tbody`,{children:M.map((e,t)=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.id}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.job.name??e.job.data?.name??`default`}),(0,x.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-red-400/90`,children:String(e.reason||e.error||`—`)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.attempts?.length??e.job.attempts??`—`}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:f(e.attempts?.at(-1)?.failedAt??e.enteredAt)})]},e.job.id||t))})]})}):(0,x.jsx)(u,{icon:(0,x.jsx)(r,{}),title:C?.queues.length===0?`No queues available`:`Select a queue`,hint:`A queue must be selected before its dead letter entries can be inspected.`}),O&&(0,x.jsx)(g,{page:n,pageSize:S,total:O.total,onPageChange:y,label:`entries`})]})}export{T as Dlq};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CyjgmGTq.js";import{t as a}from"./bq-BeBxa743.js";import{t as o}from"./toastStore-CS_9Xndn.js";import{C as s,T as c,a as l,d as u,f as d,u as f}from"./icons-CIvFfU2b.js";import{n as p}from"./usePolledData-DzlUpBOO.js";import{n as m,t as h}from"./Button-BPqpRZJD.js";import{i as g,n as _,r as v,t as y}from"./feedback-BnGE2oW2.js";import{t as b}from"./PageHeader-BXlZSBcc.js";import{a as x,i as S,l as C,s as w}from"./format-Cg7VCIZW.js";import{a as T,n as E}from"./index-Cui9IwWy.js";import{a as D}from"./form-tC20r4Ma.js";import{t as O}from"./Pagination-Q-vf4hsX.js";import{r as k,t as A}from"./flowMutationSafety-CoOp94wS.js";import{t as j}from"./exportFile-C7xhE8Yh.js";import{t as M}from"./QueueControl-B8Q9NX6t.js";var N=e(n(),1),P=i();function F({queue:e,data:t,reasons:n,topReason:r}){return(0,P.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,P.jsx)(E,{label:`Entries`,value:e&&t?w(t.total):`—`,tone:!e||!t?`default`:t.total?`red`:`green`,hint:!e||!t?`waiting for queue data`:t.total?r?`top: ${r}`:void 0:`queue is clean`,compact:!0}),(0,P.jsx)(E,{label:`Failure types`,value:t?.stats?w(n.length):`—`,hint:`distinct reasons`,compact:!0}),(0,P.jsx)(E,{label:`Pending retry`,value:t?.stats?w(t.stats.pendingRetry??0):`—`,tone:t?.stats?.pendingRetry?`amber`:`default`,hint:`auto-retry queued`,compact:!0}),(0,P.jsx)(E,{label:`Oldest entry`,value:t?.stats?.oldestEntry?C(t.stats.oldestEntry):`—`,hint:`time in DLQ`,compact:!0})]})}function I({queue:e,queues:t,reason:n,reasons:r,byReason:i,search:a,pageScoped:o,onQueue:s,onReason:l,onSearch:u}){return(0,P.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,P.jsx)(`div`,{className:`w-56`,children:(0,P.jsx)(D,{value:e,"aria-label":`Queue`,name:`dlq-control-queue`,autoComplete:`off`,onChange:e=>s(e.target.value),children:t.map(e=>(0,P.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,P.jsx)(`div`,{className:`w-44`,children:(0,P.jsxs)(D,{value:n,"aria-label":`Filter by reason`,name:`dlq-control-reason`,autoComplete:`off`,onChange:e=>l(e.target.value),children:[(0,P.jsx)(`option`,{value:`all`,children:`All reasons`}),r.map(e=>(0,P.jsxs)(`option`,{value:e,children:[e,` (`,i[e],`)`]},e))]})}),(0,P.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,P.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,P.jsx)(`input`,{value:a,onChange:e=>u(e.target.value),placeholder:o?`Filter this page by job ID…`:`Filter by job ID…`,"aria-label":`Filter by job ID`,name:`dlq-control-job-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]})}function L({entry:e,isOpen:n,onToggle:i,attempts:a}){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`tr`,{className:`border-b border-line align-top last:border-0 hover:bg-surface-2/40`,children:[(0,P.jsx)(`td`,{className:`py-3 pl-4`,children:(0,P.jsx)(m,{"aria-label":n?`Collapse details`:`Expand details`,"aria-expanded":n,onClick:i,children:(0,P.jsx)(l,{className:t(`size-3.5 transition-transform`,n&&`rotate-90`)})})}),(0,P.jsx)(`td`,{className:`px-3 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(r,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`max-w-[14rem] truncate font-mono text-xs text-accent hover:underline`,title:e.job.id,children:e.job.id}),(0,P.jsx)(T,{value:e.job.id})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`span`,{className:`inline-block rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`span`,{className:`block max-w-md truncate text-xs text-danger/80`,title:e.error??``,children:e.error||`—`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right tnum text-muted`,children:e.job.attempts??a.length}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right text-faint`,title:S(e.enteredAt),children:C(e.enteredAt)}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,P.jsx)(r,{to:`/job?id=${encodeURIComponent(e.job.id)}`,"aria-label":`Inspect job ${e.job.id}`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,P.jsx)(d,{className:`size-3.5`})}),(0,P.jsx)(m,{"aria-label":`Retry job unavailable`,disabled:!0,title:A,children:(0,P.jsx)(s,{className:`size-3.5`})})]})})]}),n&&(0,P.jsxs)(`tr`,{className:`border-b border-line bg-surface-2/30 last:border-0`,children:[(0,P.jsx)(`td`,{}),(0,P.jsxs)(`td`,{colSpan:7,className:`px-3 pb-4 pt-1`,children:[e.error&&(0,P.jsxs)(`div`,{className:`mb-3`,children:[(0,P.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Error`}),(0,P.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-lg bg-surface p-3 font-mono text-xs text-danger/90`,children:e.error})]}),(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Failure history`,typeof e.retryCount==`number`&&e.retryCount>0&&(0,P.jsxs)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] normal-case text-muted`,children:[`retried `,e.retryCount,`×`]})]}),a.length===0?(0,P.jsx)(`p`,{className:`text-xs text-faint`,children:`No per-attempt history recorded.`}):(0,P.jsx)(`ol`,{className:`space-y-1.5`,children:a.map(e=>(0,P.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-0.5 rounded-lg border border-line bg-surface px-3 py-2 text-xs`,children:[(0,P.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Attempt `,e.attempt]}),(0,P.jsx)(`span`,{className:`text-faint`,title:S(e.failedAt),children:C(e.failedAt)}),e.duration!=null&&(0,P.jsx)(`span`,{className:`tnum text-muted`,children:x(e.duration)}),e.reason&&(0,P.jsx)(`span`,{className:`rounded bg-red-500/10 px-1.5 text-danger`,children:e.reason}),e.error&&(0,P.jsx)(`span`,{className:`w-full truncate text-danger/70`,children:e.error})]},`${e.attempt}-${e.failedAt}`))})]})]})]})}var R=25,z=e=>`${e.job.id}-${e.enteredAt}`;function B(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(0),[i,c]=(0,N.useState)(`all`),[l,d]=(0,N.useState)(``),[m,x]=(0,N.useState)(new Set),{data:S,error:C,loading:w,refetch:T}=p(M,[],{intervalMs:3e4});(0,N.useEffect)(()=>{e||!S?.queues?.length||t((S.queues.find(e=>e.dlq>0)??S.queues[0]).name)},[S,e]);let{data:E,error:D,loading:B,refetch:V}=p((0,N.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0,stats:null,statsError:null};let[t,r]=await Promise.all([a.dlq(e,R,n*R),a.dlqStats(e).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:e,page:n,entries:t.entries??[],total:t.total??0,stats:r.stats,statsError:r.error}},[e,n]),[e,n]),H=E&&E.queue===e&&E.page===n?E:null;(0,N.useEffect)(()=>{if(!H)return;let e=Math.max(0,Math.ceil((H.total??0)/R)-1);n>e&&r(e)},[H,n]),(0,N.useEffect)(()=>{x(new Set)},[e,n]);let U=H?.stats?.byReason??{},W=(0,N.useMemo)(()=>Object.keys(U).filter(e=>U[e]>0),[U]),G=(0,N.useMemo)(()=>[...W].sort((e,t)=>(U[t]??0)-(U[e]??0))[0],[W,U]),K=H?.entries??[],q=(0,N.useMemo)(()=>{let e=K;i!==`all`&&(e=e.filter(e=>e.reason===i));let t=l.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[K,i,l]),J=i!==`all`||l.trim()!==``,Y=(H?.total??0)>R,X=e=>x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(b,{title:`DLQ Control`,description:`Inspect and triage one queue's dead-lettered jobs.`,live:!!e&&!!H&&!H.statsError&&!D&&!C,actions:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(h,{size:`sm`,disabled:!e||!q.length,onClick:()=>{if(q.length===0){o.info(`Nothing to export`);return}j(`dlq-${e}`,q.map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,attempts:e.job.attempts??e.attempts?.length??``,enteredAt:new Date(e.enteredAt).toISOString()})),[`jobId`,`reason`,`error`,`attempts`,`enteredAt`])},children:[(0,P.jsx)(u,{className:`size-3.5`}),` Export`]}),(0,P.jsxs)(h,{size:`sm`,disabled:!0,title:A,children:[(0,P.jsx)(s,{className:`size-3.5`}),` Retry all`]}),(0,P.jsx)(h,{variant:`danger`,size:`sm`,disabled:!0,title:k,children:`Purge`})]})}),D&&H&&(0,P.jsx)(g,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:V}),C&&(0,P.jsx)(g,{onRetry:T,message:`Could not discover queues — ${C.message}. Retry before selecting a queue.`}),H?.statsError&&(0,P.jsx)(g,{message:`DLQ statistics are unavailable — ${H.statsError}. The entry list may still be current.`,onRetry:V}),(0,P.jsx)(F,{queue:e,data:H,reasons:W,topReason:G}),(0,P.jsx)(I,{queue:e,queues:S?.queues??[],reason:i,reasons:W,byReason:U,search:l,pageScoped:Y,onQueue:e=>{t(e),r(0),c(`all`),d(``)},onReason:c,onSearch:d}),(0,P.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:A}),D&&!H?(0,P.jsx)(_,{error:D,onRetry:V}):w&&!S&&!e&&!C?(0,P.jsx)(v,{label:`Discovering queues…`}):B&&!H&&!D?(0,P.jsx)(v,{label:`Loading DLQ…`}):C&&!e?(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:`Could not discover queues`,hint:`${C.message}. Retry the queue discovery request above.`}):e?q.length===0?(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:J?`No matches`:`Dead letter queue is empty`,hint:J?Y?`No entries on this page match your filter — filters are page-scoped. Try another page or clear them.`:`No entries match your filter. Clear it to see all entries.`:`Failed jobs that exhaust their retries land here.`}):(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,P.jsx)(`th`,{className:`w-8 py-3 pl-4`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Name`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Job ID`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Reason`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Error`}),(0,P.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Attempts`}),(0,P.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Entered`}),(0,P.jsx)(`th`,{className:`w-20 px-4 py-3`})]})}),(0,P.jsx)(`tbody`,{children:q.map(e=>{let t=z(e);return(0,P.jsx)(L,{entry:e,isOpen:m.has(t),onToggle:()=>X(t),attempts:e.attempts??[]},t)})})]})}):(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:S?.queues.length===0?`No queues available`:`Select a queue`,hint:`A queue must be selected before its dead letter entries can be inspected.`}),H&&(0,P.jsx)(O,{page:n,pageSize:R,total:H.total,onPageChange:r,label:`entries`})]})}export{B as DlqControl};
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,r,t as i}from"./react-vendor-CyjgmGTq.js";import{t as a}from"./bq-Bmysbg0r.js";import{t as o}from"./toastStore-B7n0zS0y.js";import{C as s,T as c,a as l,d as u,f as d,u as f}from"./icons-CIvFfU2b.js";import{n as p}from"./usePolledData-g80Z_UB-.js";import{n as m,t as h}from"./Button-BPqpRZJD.js";import{i as g,n as _,r as v,t as y}from"./feedback-BnGE2oW2.js";import{t as b}from"./PageHeader-BXlZSBcc.js";import{a as x,i as S,l as C,s as w}from"./format-Cg7VCIZW.js";import{a as T,n as E}from"./index-Cue53Myw.js";import{a as D}from"./form-tC20r4Ma.js";import{t as O}from"./Pagination-Q-vf4hsX.js";import{r as k,t as A}from"./flowMutationSafety-DObp9nJo.js";import{t as j}from"./exportFile-C7xhE8Yh.js";import{t as M}from"./QueueControl-CWHsVfWU.js";var N=e(n(),1),P=i();function F({queue:e,data:t,reasons:n,topReason:r}){return(0,P.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,P.jsx)(E,{label:`Entries`,value:e&&t?w(t.total):`—`,tone:!e||!t?`default`:t.total?`red`:`green`,hint:!e||!t?`waiting for queue data`:t.total?r?`top: ${r}`:void 0:`queue is clean`,compact:!0}),(0,P.jsx)(E,{label:`Failure types`,value:t?.stats?w(n.length):`—`,hint:`distinct reasons`,compact:!0}),(0,P.jsx)(E,{label:`Pending retry`,value:t?.stats?w(t.stats.pendingRetry??0):`—`,tone:t?.stats?.pendingRetry?`amber`:`default`,hint:`auto-retry queued`,compact:!0}),(0,P.jsx)(E,{label:`Oldest entry`,value:t?.stats?.oldestEntry?C(t.stats.oldestEntry):`—`,hint:`time in DLQ`,compact:!0})]})}function I({queue:e,queues:t,reason:n,reasons:r,byReason:i,search:a,pageScoped:o,onQueue:s,onReason:l,onSearch:u}){return(0,P.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,P.jsx)(`div`,{className:`w-56`,children:(0,P.jsx)(D,{value:e,"aria-label":`Queue`,name:`dlq-control-queue`,autoComplete:`off`,onChange:e=>s(e.target.value),children:t.map(e=>(0,P.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,P.jsx)(`div`,{className:`w-44`,children:(0,P.jsxs)(D,{value:n,"aria-label":`Filter by reason`,name:`dlq-control-reason`,autoComplete:`off`,onChange:e=>l(e.target.value),children:[(0,P.jsx)(`option`,{value:`all`,children:`All reasons`}),r.map(e=>(0,P.jsxs)(`option`,{value:e,children:[e,` (`,i[e],`)`]},e))]})}),(0,P.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,P.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,P.jsx)(`input`,{value:a,onChange:e=>u(e.target.value),placeholder:o?`Filter this page by job ID…`:`Filter by job ID…`,"aria-label":`Filter by job ID`,name:`dlq-control-job-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]})}function L({entry:e,isOpen:n,onToggle:i,attempts:a}){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`tr`,{className:`border-b border-line align-top last:border-0 hover:bg-surface-2/40`,children:[(0,P.jsx)(`td`,{className:`py-3 pl-4`,children:(0,P.jsx)(m,{"aria-label":n?`Collapse details`:`Expand details`,"aria-expanded":n,onClick:i,children:(0,P.jsx)(l,{className:t(`size-3.5 transition-transform`,n&&`rotate-90`)})})}),(0,P.jsx)(`td`,{className:`px-3 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(r,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`max-w-[14rem] truncate font-mono text-xs text-accent hover:underline`,title:e.job.id,children:e.job.id}),(0,P.jsx)(T,{value:e.job.id})]})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`span`,{className:`inline-block rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,P.jsx)(`td`,{className:`px-3 py-3`,children:(0,P.jsx)(`span`,{className:`block max-w-md truncate text-xs text-danger/80`,title:e.error??``,children:e.error||`—`})}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right tnum text-muted`,children:e.job.attempts??a.length}),(0,P.jsx)(`td`,{className:`px-3 py-3 text-right text-faint`,title:S(e.enteredAt),children:C(e.enteredAt)}),(0,P.jsx)(`td`,{className:`px-4 py-3`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,P.jsx)(r,{to:`/job?id=${encodeURIComponent(e.job.id)}`,"aria-label":`Inspect job ${e.job.id}`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,P.jsx)(d,{className:`size-3.5`})}),(0,P.jsx)(m,{"aria-label":`Retry job unavailable`,disabled:!0,title:A,children:(0,P.jsx)(s,{className:`size-3.5`})})]})})]}),n&&(0,P.jsxs)(`tr`,{className:`border-b border-line bg-surface-2/30 last:border-0`,children:[(0,P.jsx)(`td`,{}),(0,P.jsxs)(`td`,{colSpan:7,className:`px-3 pb-4 pt-1`,children:[e.error&&(0,P.jsxs)(`div`,{className:`mb-3`,children:[(0,P.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Error`}),(0,P.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-lg bg-surface p-3 font-mono text-xs text-danger/90`,children:e.error})]}),(0,P.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Failure history`,typeof e.retryCount==`number`&&e.retryCount>0&&(0,P.jsxs)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] normal-case text-muted`,children:[`retried `,e.retryCount,`×`]})]}),a.length===0?(0,P.jsx)(`p`,{className:`text-xs text-faint`,children:`No per-attempt history recorded.`}):(0,P.jsx)(`ol`,{className:`space-y-1.5`,children:a.map(e=>(0,P.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-0.5 rounded-lg border border-line bg-surface px-3 py-2 text-xs`,children:[(0,P.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Attempt `,e.attempt]}),(0,P.jsx)(`span`,{className:`text-faint`,title:S(e.failedAt),children:C(e.failedAt)}),e.duration!=null&&(0,P.jsx)(`span`,{className:`tnum text-muted`,children:x(e.duration)}),e.reason&&(0,P.jsx)(`span`,{className:`rounded bg-red-500/10 px-1.5 text-danger`,children:e.reason}),e.error&&(0,P.jsx)(`span`,{className:`w-full truncate text-danger/70`,children:e.error})]},`${e.attempt}-${e.failedAt}`))})]})]})]})}var R=25,z=e=>`${e.job.id}-${e.enteredAt}`;function B(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(0),[i,c]=(0,N.useState)(`all`),[l,d]=(0,N.useState)(``),[m,x]=(0,N.useState)(new Set),{data:S,error:C,loading:w,refetch:T}=p(M,[],{intervalMs:3e4});(0,N.useEffect)(()=>{e||!S?.queues?.length||t((S.queues.find(e=>e.dlq>0)??S.queues[0]).name)},[S,e]);let{data:E,error:D,loading:B,refetch:V}=p((0,N.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0,stats:null,statsError:null};let[t,r]=await Promise.all([a.dlq(e,R,n*R),a.dlqStats(e).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:e,page:n,entries:t.entries??[],total:t.total??0,stats:r.stats,statsError:r.error}},[e,n]),[e,n]),H=E?.queue===e&&E.page===n?E:null;(0,N.useEffect)(()=>{if(!H)return;let e=Math.max(0,Math.ceil((H.total??0)/R)-1);n>e&&r(e)},[H,n]),(0,N.useEffect)(()=>{x(new Set)},[e,n]);let U=H?.stats?.byReason??{},W=(0,N.useMemo)(()=>Object.keys(U).filter(e=>U[e]>0),[U]),G=(0,N.useMemo)(()=>[...W].sort((e,t)=>(U[t]??0)-(U[e]??0))[0],[W,U]),K=H?.entries??[],q=(0,N.useMemo)(()=>{let e=K;i!==`all`&&(e=e.filter(e=>e.reason===i));let t=l.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[K,i,l]),J=i!==`all`||l.trim()!==``,Y=(H?.total??0)>R,X=e=>x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(b,{title:`DLQ Control`,description:`Inspect and triage one queue's dead-lettered jobs.`,live:!!e&&!!H&&!H.statsError&&!D&&!C,actions:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(h,{size:`sm`,disabled:!e||!q.length,onClick:()=>{if(q.length===0){o.info(`Nothing to export`);return}j(`dlq-${e}`,q.map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,attempts:e.job.attempts??e.attempts?.length??``,enteredAt:new Date(e.enteredAt).toISOString()})),[`jobId`,`reason`,`error`,`attempts`,`enteredAt`])},children:[(0,P.jsx)(u,{className:`size-3.5`}),` Export`]}),(0,P.jsxs)(h,{size:`sm`,disabled:!0,title:A,children:[(0,P.jsx)(s,{className:`size-3.5`}),` Retry all`]}),(0,P.jsx)(h,{variant:`danger`,size:`sm`,disabled:!0,title:k,children:`Purge`})]})}),D&&H&&(0,P.jsx)(g,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:V}),C&&(0,P.jsx)(g,{onRetry:T,message:`Could not discover queues — ${C.message}. Retry before selecting a queue.`}),H?.statsError&&(0,P.jsx)(g,{message:`DLQ statistics are unavailable — ${H.statsError}. The entry list may still be current.`,onRetry:V}),(0,P.jsx)(F,{queue:e,data:H,reasons:W,topReason:G}),(0,P.jsx)(I,{queue:e,queues:S?.queues??[],reason:i,reasons:W,byReason:U,search:l,pageScoped:Y,onQueue:e=>{t(e),r(0),c(`all`),d(``)},onReason:c,onSearch:d}),(0,P.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:A}),D&&!H?(0,P.jsx)(_,{error:D,onRetry:V}):w&&!S&&!e&&!C?(0,P.jsx)(v,{label:`Discovering queues…`}):B&&!H&&!D?(0,P.jsx)(v,{label:`Loading DLQ…`}):C&&!e?(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:`Could not discover queues`,hint:`${C.message}. Retry the queue discovery request above.`}):e?q.length===0?(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:J?`No matches`:`Dead letter queue is empty`,hint:J?Y?`No entries on this page match your filter — filters are page-scoped. Try another page or clear them.`:`No entries match your filter. Clear it to see all entries.`:`Failed jobs that exhaust their retries land here.`}):(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,P.jsx)(`th`,{className:`w-8 py-3 pl-4`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Name`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Job ID`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Reason`}),(0,P.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Error`}),(0,P.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Attempts`}),(0,P.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Entered`}),(0,P.jsx)(`th`,{className:`w-20 px-4 py-3`})]})}),(0,P.jsx)(`tbody`,{children:q.map(e=>{let t=z(e);return(0,P.jsx)(L,{entry:e,isOpen:m.has(t),onToggle:()=>X(t),attempts:e.attempts??[]},t)})})]})}):(0,P.jsx)(y,{icon:(0,P.jsx)(f,{}),title:S?.queues.length===0?`No queues available`:`Select a queue`,hint:`A queue must be selected before its dead letter entries can be inspected.`}),H&&(0,P.jsx)(O,{page:n,pageSize:R,total:H.total,onPageChange:r,label:`entries`})]})}export{B as DlqControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{t as o}from"./bq-BeBxa743.js";import{t as s}from"./toastStore-CS_9Xndn.js";import{C as c,d as l,u}from"./icons-CIvFfU2b.js";import{n as d}from"./usePolledData-DzlUpBOO.js";import{n as f,t as p}from"./Button-BPqpRZJD.js";import{t as m}from"./Card-C7NMhqUt.js";import{i as h,n as g,r as _,t as v}from"./feedback-BnGE2oW2.js";import{t as y}from"./PageHeader-BXlZSBcc.js";import{l as b,s as x}from"./format-Cg7VCIZW.js";import{a as S}from"./form-tC20r4Ma.js";import{t as C}from"./Pagination-Q-vf4hsX.js";import{r as w,t as T}from"./flowMutationSafety-CoOp94wS.js";import{t as E}from"./exportFile-C7xhE8Yh.js";import{t as D}from"./QueueControl-B8Q9NX6t.js";var O=e(r(),1),k=a();function ee({total:e,discoveryError:n,healthy:r,statsError:i,queue:a,topReason:o,pendingRetry:s,reasonCount:c}){return(0,k.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,k.jsxs)(m,{children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,k.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,n?`bg-amber-500/10 text-warning`:e==null?`bg-surface-2 text-muted`:r?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:n?`Unavailable`:e==null?`Loading`:r?`Healthy`:`Attention`})]}),(0,k.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,e==null||n?`text-muted`:r?`text-success`:`text-danger`),children:e==null?`—`:x(e)})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,k.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:n||i?`Unavailable`:a?o??`No failures`:`Select a queue`})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,k.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:s==null?`—`:x(s)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,k.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:c==null?`—`:x(c)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]})}function te({queues:e,queue:n,onSelect:r}){return e.length===0?null:(0,k.jsxs)(m,{className:`mb-6`,children:[(0,k.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(p,{size:`sm`,disabled:!0,title:T,children:[(0,k.jsx)(c,{className:`size-3.5`}),` Retry all (`,e.length,` queues)`]}),(0,k.jsxs)(p,{variant:`danger`,size:`sm`,disabled:!0,title:w,children:[`Purge all (`,e.length,` queues)`]})]})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:e.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>r(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,n===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,k.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,k.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:e.dlq})]},e.name))})]})}function A({queue:e,queues:t,reason:n,reasons:r,sort:i,search:a,pageScoped:o,onQueue:s,onReason:u,onSort:d,onSearch:m,onExport:h}){return(0,k.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(`div`,{className:`w-48`,children:(0,k.jsxs)(S,{value:e,"aria-label":`Queue`,name:`dlq-queue`,autoComplete:`off`,onChange:e=>s(e.target.value),children:[(0,k.jsx)(`option`,{value:``,children:`Select a queue…`}),t.map(e=>(0,k.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,k.jsx)(`div`,{className:`w-40`,children:(0,k.jsxs)(S,{value:n,onChange:e=>u(e.target.value),"aria-label":`Filter by reason`,name:`dlq-reason-filter`,autoComplete:`off`,children:[(0,k.jsx)(`option`,{value:`all`,children:`All Reasons`}),r.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))]})}),(0,k.jsx)(`div`,{className:`w-36`,children:(0,k.jsxs)(S,{value:i,onChange:e=>d(e.target.value),"aria-label":o?`Sort this page`:`Sort`,name:`dlq-sort`,autoComplete:`off`,children:[(0,k.jsxs)(`option`,{value:`newest`,children:[`Newest First`,o?` (this page)`:``]}),(0,k.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,o?` (this page)`:``]})]})}),(0,k.jsx)(`input`,{value:a,onChange:e=>m(e.target.value),placeholder:`Filter this page by job ID…`,"aria-label":`Filter this page by job ID`,name:`dlq-job-filter`,autoComplete:`off`,className:`h-9 min-w-40 flex-1 rounded-lg border border-line bg-surface px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,k.jsxs)(p,{size:`sm`,disabled:!0,title:T,children:[(0,k.jsx)(c,{className:`size-3.5`}),` Retry All`]}),(0,k.jsx)(p,{variant:`danger`,size:`sm`,disabled:!0,title:w,children:`Purge All`}),(0,k.jsx)(f,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!e,onClick:h,children:(0,k.jsx)(l,{className:`size-3.5`})})]})}function j({entries:e,expanded:n,onToggle:r}){return(0,k.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,k.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Error`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,k.jsx)(`th`,{className:`w-16 px-5 py-3`})]})}),(0,k.jsx)(`tbody`,{children:e.map(e=>{let a=`${e.job.id}-${e.enteredAt}`;return(0,k.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,k.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,k.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,k.jsx)(`button`,{type:`button`,title:e.error,"aria-expanded":n.has(a),onClick:()=>r(a),className:t(`block w-full break-words text-left`,!n.has(a)&&`line-clamp-2`),children:e.error}):`—`}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:b(e.enteredAt)}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,k.jsx)(f,{"aria-label":`Retry unavailable`,disabled:!0,title:T,children:(0,k.jsx)(c,{className:`size-3.5`})})})]},a)})})]})})}var M=25;function N(){let[e,t]=n(),[r,i]=(0,O.useState)(``),[a,c]=(0,O.useState)(`all`),[l,f]=(0,O.useState)(`newest`),[p,m]=(0,O.useState)(``),[b,x]=(0,O.useState)(0),[S,w]=(0,O.useState)(new Set),{data:N,error:P,loading:F,refetch:I}=d(D,[],{intervalMs:1e4}),L=N?.queues??[],R=N?L.reduce((e,t)=>e+t.dlq,0):null,{data:z,error:B,loading:V,refetch:H}=d((0,O.useCallback)(async()=>{if(!r)return{queue:r,page:b,entries:[],entriesTotal:0,stats:null,statsError:null};let[e,t]=await Promise.all([o.dlq(r,M,b*M),o.dlqStats(r).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:r,page:b,entries:e.entries??[],entriesTotal:e.total??0,stats:t.stats,statsError:t.error}},[r,b]),[r,b]),U=z&&z.queue===r&&z.page===b?z:null;(0,O.useEffect)(()=>{if(!U)return;let e=U.entriesTotal??0;b>0&&b*M>=e&&x(Math.max(0,Math.ceil(e/M)-1))},[U,b]);let W=()=>{let e=(U?.entries??[]).map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,enteredAt:new Date(e.enteredAt).toISOString(),attempts:e.attempts?.length??0}));if(e.length===0){s.info(`Nothing to export on this page`);return}E(`dlq-${r}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},G=e=>{X.current=!0,i(e),x(0),c(`all`),t(e?{queue:e}:{},{replace:!0})},K=U?.stats?.byReason??{},q=Object.keys(K).filter(e=>K[e]>0),J=[...q].sort((e,t)=>(K[t]??0)-(K[e]??0))[0],Y=(0,O.useMemo)(()=>L.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[L]),X=(0,O.useRef)(!1),Z=e.get(`queue`);(0,O.useEffect)(()=>{if(!(X.current||r)){if(Z){if(L.some(e=>e.name===Z)){X.current=!0,i(Z),x(0),c(`all`);return}if(L.length===0)return}Y.length!==0&&(X.current=!0,i(Y[0].name),x(0),c(`all`))}},[r,L,Y,Z]);let Q=(0,O.useMemo)(()=>{let e=U?.entries??[];a!==`all`&&(e=e.filter(e=>e.reason===a));let t=p.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>l===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[U,a,p,l]),ne=R===0&&!P,$=a!==`all`||p.trim()!==``,re=(U?.entriesTotal??0)>M;return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(y,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Inspect and export entries without mutating flow topology.`,live:!!r&&!!U&&!U.statsError&&!B&&!P}),B&&U&&(0,k.jsx)(h,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:H}),P&&(0,k.jsx)(h,{onRetry:I,message:`Could not discover queue DLQ totals — ${P.message}. Health status is unavailable.`}),U?.statsError&&(0,k.jsx)(h,{message:`DLQ statistics are unavailable — ${U.statsError}. The entry list may still be current.`,onRetry:H}),(0,k.jsx)(ee,{total:R,discoveryError:!!P,healthy:ne,statsError:!!U?.statsError,queue:r,topReason:J,pendingRetry:U?.stats?.pendingRetry,reasonCount:U?.stats?q.length:void 0}),(0,k.jsx)(te,{queues:Y,queue:r,onSelect:G}),(0,k.jsx)(A,{queue:r,queues:L,reason:a,reasons:q,sort:l,search:p,pageScoped:re,onQueue:G,onReason:c,onSort:f,onSearch:m,onExport:W}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:T}),B&&!U?(0,k.jsx)(g,{error:B,onRetry:H}):F&&!N&&!r&&!P?(0,k.jsx)(_,{label:`Discovering queues…`}):V&&!U&&!B?(0,k.jsx)(_,{label:`Loading DLQ…`}):P&&!r?(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:`Could not discover queues`,hint:`${P.message}. Retry the queue discovery request above.`}):r?Q.length===0?(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:$?`No matches on this page`:`No dead letter entries`,hint:$?`No entries on this page match your filter — the filter is page-scoped. Use the pager below to check other pages.`:`This queue has no dead letter entries.`}):(0,k.jsx)(j,{entries:Q,expanded:S,onToggle:e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}):(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),r&&U&&(0,k.jsx)(C,{page:b,pageSize:M,total:U.entriesTotal,onPageChange:x,label:`entries`})]})}export{N as DlqPro};
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{t as o}from"./bq-Bmysbg0r.js";import{t as s}from"./toastStore-B7n0zS0y.js";import{C as c,d as l,u}from"./icons-CIvFfU2b.js";import{n as d}from"./usePolledData-g80Z_UB-.js";import{n as f,t as p}from"./Button-BPqpRZJD.js";import{t as m}from"./Card-C7NMhqUt.js";import{i as h,n as g,r as _,t as v}from"./feedback-BnGE2oW2.js";import{t as y}from"./PageHeader-BXlZSBcc.js";import{l as b,s as x}from"./format-Cg7VCIZW.js";import{a as S}from"./form-tC20r4Ma.js";import{t as C}from"./Pagination-Q-vf4hsX.js";import{r as w,t as T}from"./flowMutationSafety-DObp9nJo.js";import{t as E}from"./exportFile-C7xhE8Yh.js";import{t as D}from"./QueueControl-CWHsVfWU.js";var O=e(r(),1),k=a();function ee({total:e,discoveryError:n,healthy:r,statsError:i,queue:a,topReason:o,pendingRetry:s,reasonCount:c}){return(0,k.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,k.jsxs)(m,{children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,k.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,n?`bg-amber-500/10 text-warning`:e==null?`bg-surface-2 text-muted`:r?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:n?`Unavailable`:e==null?`Loading`:r?`Healthy`:`Attention`})]}),(0,k.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,e==null||n?`text-muted`:r?`text-success`:`text-danger`),children:e==null?`—`:x(e)})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,k.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:n||i?`Unavailable`:a?o??`No failures`:`Select a queue`})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,k.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:s==null?`—`:x(s)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,k.jsxs)(m,{children:[(0,k.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,k.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:c==null?`—`:x(c)}),(0,k.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]})}function te({queues:e,queue:n,onSelect:r}){return e.length===0?null:(0,k.jsxs)(m,{className:`mb-6`,children:[(0,k.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(p,{size:`sm`,disabled:!0,title:T,children:[(0,k.jsx)(c,{className:`size-3.5`}),` Retry all (`,e.length,` queues)`]}),(0,k.jsxs)(p,{variant:`danger`,size:`sm`,disabled:!0,title:w,children:[`Purge all (`,e.length,` queues)`]})]})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:e.map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>r(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,n===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,k.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,k.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:e.dlq})]},e.name))})]})}function A({queue:e,queues:t,reason:n,reasons:r,sort:i,search:a,pageScoped:o,onQueue:s,onReason:u,onSort:d,onSearch:m,onExport:h}){return(0,k.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(`div`,{className:`w-48`,children:(0,k.jsxs)(S,{value:e,"aria-label":`Queue`,name:`dlq-queue`,autoComplete:`off`,onChange:e=>s(e.target.value),children:[(0,k.jsx)(`option`,{value:``,children:`Select a queue…`}),t.map(e=>(0,k.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,k.jsx)(`div`,{className:`w-40`,children:(0,k.jsxs)(S,{value:n,onChange:e=>u(e.target.value),"aria-label":`Filter by reason`,name:`dlq-reason-filter`,autoComplete:`off`,children:[(0,k.jsx)(`option`,{value:`all`,children:`All Reasons`}),r.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))]})}),(0,k.jsx)(`div`,{className:`w-36`,children:(0,k.jsxs)(S,{value:i,onChange:e=>d(e.target.value),"aria-label":o?`Sort this page`:`Sort`,name:`dlq-sort`,autoComplete:`off`,children:[(0,k.jsxs)(`option`,{value:`newest`,children:[`Newest First`,o?` (this page)`:``]}),(0,k.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,o?` (this page)`:``]})]})}),(0,k.jsx)(`input`,{value:a,onChange:e=>m(e.target.value),placeholder:`Filter this page by job ID…`,"aria-label":`Filter this page by job ID`,name:`dlq-job-filter`,autoComplete:`off`,className:`h-9 min-w-40 flex-1 rounded-lg border border-line bg-surface px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,k.jsxs)(p,{size:`sm`,disabled:!0,title:T,children:[(0,k.jsx)(c,{className:`size-3.5`}),` Retry All`]}),(0,k.jsx)(p,{variant:`danger`,size:`sm`,disabled:!0,title:w,children:`Purge All`}),(0,k.jsx)(f,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!e,onClick:h,children:(0,k.jsx)(l,{className:`size-3.5`})})]})}function j({entries:e,expanded:n,onToggle:r}){return(0,k.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,k.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,k.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Error`}),(0,k.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,k.jsx)(`th`,{className:`w-16 px-5 py-3`})]})}),(0,k.jsx)(`tbody`,{children:e.map(e=>{let a=`${e.job.id}-${e.enteredAt}`;return(0,k.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,k.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.name??`default`}),(0,k.jsx)(`td`,{className:`px-5 py-3`,children:(0,k.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,k.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,k.jsx)(`button`,{type:`button`,title:e.error,"aria-expanded":n.has(a),onClick:()=>r(a),className:t(`block w-full break-words text-left`,!n.has(a)&&`line-clamp-2`),children:e.error}):`—`}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:b(e.enteredAt)}),(0,k.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,k.jsx)(f,{"aria-label":`Retry unavailable`,disabled:!0,title:T,children:(0,k.jsx)(c,{className:`size-3.5`})})})]},a)})})]})})}var M=25;function N(){let[e,t]=n(),[r,i]=(0,O.useState)(``),[a,c]=(0,O.useState)(`all`),[l,f]=(0,O.useState)(`newest`),[p,m]=(0,O.useState)(``),[b,x]=(0,O.useState)(0),[S,w]=(0,O.useState)(new Set),{data:N,error:P,loading:F,refetch:I}=d(D,[],{intervalMs:1e4}),L=N?.queues??[],R=N?L.reduce((e,t)=>e+t.dlq,0):null,{data:z,error:B,loading:V,refetch:H}=d((0,O.useCallback)(async()=>{if(!r)return{queue:r,page:b,entries:[],entriesTotal:0,stats:null,statsError:null};let[e,t]=await Promise.all([o.dlq(r,M,b*M),o.dlqStats(r).then(e=>({stats:e.stats,error:null})).catch(e=>({stats:null,error:e.message||`Unknown error`}))]);return{queue:r,page:b,entries:e.entries??[],entriesTotal:e.total??0,stats:t.stats,statsError:t.error}},[r,b]),[r,b]),U=z?.queue===r&&z.page===b?z:null;(0,O.useEffect)(()=>{if(!U)return;let e=U.entriesTotal??0;b>0&&b*M>=e&&x(Math.max(0,Math.ceil(e/M)-1))},[U,b]);let W=()=>{let e=(U?.entries??[]).map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,enteredAt:new Date(e.enteredAt).toISOString(),attempts:e.attempts?.length??0}));if(e.length===0){s.info(`Nothing to export on this page`);return}E(`dlq-${r}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},G=e=>{X.current=!0,i(e),x(0),c(`all`),t(e?{queue:e}:{},{replace:!0})},K=U?.stats?.byReason??{},q=Object.keys(K).filter(e=>K[e]>0),J=[...q].sort((e,t)=>(K[t]??0)-(K[e]??0))[0],Y=(0,O.useMemo)(()=>L.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[L]),X=(0,O.useRef)(!1),Z=e.get(`queue`);(0,O.useEffect)(()=>{if(!(X.current||r)){if(Z){if(L.some(e=>e.name===Z)){X.current=!0,i(Z),x(0),c(`all`);return}if(L.length===0)return}Y.length!==0&&(X.current=!0,i(Y[0].name),x(0),c(`all`))}},[r,L,Y,Z]);let Q=(0,O.useMemo)(()=>{let e=U?.entries??[];a!==`all`&&(e=e.filter(e=>e.reason===a));let t=p.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>l===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[U,a,p,l]),ne=R===0&&!P,$=a!==`all`||p.trim()!==``,re=(U?.entriesTotal??0)>M;return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(y,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Inspect and export entries without mutating flow topology.`,live:!!r&&!!U&&!U.statsError&&!B&&!P}),B&&U&&(0,k.jsx)(h,{message:`DLQ refresh failed — showing the last successful page.`,onRetry:H}),P&&(0,k.jsx)(h,{onRetry:I,message:`Could not discover queue DLQ totals — ${P.message}. Health status is unavailable.`}),U?.statsError&&(0,k.jsx)(h,{message:`DLQ statistics are unavailable — ${U.statsError}. The entry list may still be current.`,onRetry:H}),(0,k.jsx)(ee,{total:R,discoveryError:!!P,healthy:ne,statsError:!!U?.statsError,queue:r,topReason:J,pendingRetry:U?.stats?.pendingRetry,reasonCount:U?.stats?q.length:void 0}),(0,k.jsx)(te,{queues:Y,queue:r,onSelect:G}),(0,k.jsx)(A,{queue:r,queues:L,reason:a,reasons:q,sort:l,search:p,pageScoped:re,onQueue:G,onReason:c,onSort:f,onSearch:m,onExport:W}),(0,k.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:T}),B&&!U?(0,k.jsx)(g,{error:B,onRetry:H}):F&&!N&&!r&&!P?(0,k.jsx)(_,{label:`Discovering queues…`}):V&&!U&&!B?(0,k.jsx)(_,{label:`Loading DLQ…`}):P&&!r?(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:`Could not discover queues`,hint:`${P.message}. Retry the queue discovery request above.`}):r?Q.length===0?(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:$?`No matches on this page`:`No dead letter entries`,hint:$?`No entries on this page match your filter — the filter is page-scoped. Use the pager below to check other pages.`:`This queue has no dead letter entries.`}):(0,k.jsx)(j,{entries:Q,expanded:S,onToggle:e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}):(0,k.jsx)(v,{icon:(0,k.jsx)(u,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),r&&U&&(0,k.jsx)(C,{page:b,pageSize:M,total:U.entriesTotal,onPageChange:x,label:`entries`})]})}export{N as DlqPro};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{i as o,o as s}from"./connectionStore-DbBYqHEY.js";import{i as c}from"./upstreamPaths-D_LPsv7b.js";import{a as l,c as u,l as d,o as f}from"./bq-BeBxa743.js";import{t as p}from"./Card-C7NMhqUt.js";import{i as m,n as h,r as g}from"./feedback-BnGE2oW2.js";import{t as _}from"./PageHeader-BXlZSBcc.js";import{i as v}from"./index-Cui9IwWy.js";import{n as y,t as b}from"./controlConnectionEpoch-CFSO6237.js";var x={nodeWidth:168,nodeHeight:60},S=`flow-order-9a3f`,C={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`},w=e=>e&&C[e]||`border-line bg-surface-2 text-muted`,T=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,E=class extends Error{constructor(e,t){super(e,t),this.name=`FlowSnapshotError`}};function D(e,t,n){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`||c(e)!==null))throw new E(`Job ${n} returned an invalid ${t} list`);return e}function O(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new E(`GET /jobs/${t} returned an invalid response`);let n=e;if(n.ok!==!0)throw new E(`GET /jobs/${t} returned an invalid success envelope`);let r=n.job;if(typeof r!=`object`||!r||Array.isArray(r))throw new E(`GET /jobs/${t} returned no job snapshot`);let i=r;if(i.id!==t)throw new E(`GET /jobs/${t} returned the wrong job id (${String(i.id)})`);if(typeof i.queue!=`string`||i.queue.length===0)throw new E(`Job ${t} returned an invalid queue`);if(typeof i.state!=`string`||i.state.length===0)throw new E(`Job ${t} returned an invalid state`);if(!Object.hasOwn(i,`parentId`)||i.parentId!==null&&(typeof i.parentId!=`string`||c(i.parentId)!==null))throw new E(`Job ${t} returned an invalid parentId`);return{...r,parentId:i.parentId,childrenIds:D(i.childrenIds,`childrenIds`,t),dependsOn:D(i.dependsOn,`dependsOn`,t)}}async function k(e,t,n){n?.throwIfAborted();let r=await d(e,t,n);return n?.throwIfAborted(),O(r,t)}function A(e){let t=c(e);return t?`Job ID: ${t}`:null}async function ee(e,t={}){let n=A(e);if(n)throw new E(n);let r=t.target??u(),{signal:i}=t,a=e,o=new Set([e]),s=[];for(let e=0;;e++){i?.throwIfAborted();let t;try{t=await k(r,a,i)}catch(t){if(i?.throwIfAborted(),e===0)throw t;if(t instanceof l&&t.status===404){let e=s.at(-1);if(!e)throw t;return{id:e.id,job:e,hops:Math.max(0,s.length-1),path:s,missingParent:a}}throw new E(`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 E(`Flow parent cycle detected at job ${n}`);if(e>=100)throw new E(`Flow parent chain exceeds the Bunqueue 2.8.57 limit of 100 levels`);o.add(n),a=n}}function j(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 te=[`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`];function M(e){return te.filter(t=>e[t]===!0)}function N(e,t){if(e?.parentId!==t)return null;let n=M(e);return n.length===1?n[0]===`continueParentOnFailure`?{scope:`parent`,policy:`continueParentOnFailure`}:n[0]===`removeDependencyOnFailure`?{scope:`child`,policy:`removeDependencyOnFailure`}:n[0]===`ignoreDependencyOnFailure`?{scope:`child`,policy:`ignoreDependencyOnFailure`}:null:null}async function ne(e,t,n={}){let r=A(e);if(r)throw new E(r);let i=n.target??u(),{signal:a}=n,o=new Map,s=[],c=[],l=new Set,d=new Set,f=new Map,p=new Set,m=new Set,h=new Set(n.limitations??[]),g=[{id:e,depth:0}],_=new Set([e]),v=new Map;t&&v.set(e,O({ok:!0,job:t},e));let y=[...n.seedPath??[]].reverse(),b=!1;if(y.length>0&&y[0]?.id!==e)throw new E(`Resolved seed path does not start at the requested flow root`);for(let[e,t]of y.entries()){let n=O({ok:!0,job:t},t.id);if(v.set(n.id,n),e!==0){if(e>100||_.size>=500){b=!0;continue}_.has(n.id)||(_.add(n.id),g.push({id:n.id,depth:e}))}}let x=new Set,S=b;for(;g.length;){a?.throwIfAborted();let{id:t,depth:n}=g.shift();if(x.has(t))continue;x.add(t);let r=null;try{r=v.get(t)??await k(i,t,a)}catch(n){if(a?.throwIfAborted(),t===e)throw n;f.set(t,n instanceof Error?n.message:String(n))}if(o.set(t,r??{id:t,state:`unknown`}),!r)continue;if(n>=100){(r.childrenIds?.length??0)+(r.dependsOn?.length??0)>0&&(S=!0);continue}let u=e=>_.has(e)?!0:_.size>=500?(S=!0,!1):(_.add(e),g.push({id:e,depth:n+1}),!0),m=(e,t,n,r)=>{if(!u(r))return;let i=`${e}->${t}:${n}`;l.has(i)||(l.add(i),s.push({from:e,to:t,kind:n}))},h=r.childrenIds??[],y=r.dependsOn??[],b=new Set(h),C=new Set(y);b.size!==h.length&&p.add(`Job ${t} lists a child more than once`),C.size!==y.length&&p.add(`Job ${t} lists a dependency more than once`);for(let e of h)m(t,e,`child`,e);for(let e of y)if(u(e)){let n=`${e}->${t}`;d.has(n)||(d.add(n),c.push({from:e,to:t,kind:`depends`})),b.has(e)||m(e,t,`depends`,e)}}for(let[e,t]of o)!f.has(e)&&M(t).length>1&&p.add(`Job ${e} enables mutually exclusive failure policies`);for(let e of s){if(e.kind!==`child`||f.has(e.to))continue;let t=o.get(e.to);t&&t.parentId!==e.from&&p.add(`Child ${e.to} points to parent ${String(t.parentId??`none`)}, not ${e.from}`)}for(let[e,t]of o){if(f.has(e))continue;let n=t.childrenIds??[];if(n.some(e=>!o.has(e)||f.has(e)))continue;let r=n.map(t=>({childId:t,release:N(o.get(t),e)})).find(({release:e})=>e?.scope===`parent`);for(let i of n){if(t.dependsOn?.includes(i))continue;if(r?.release?.scope===`parent`){m.add(`Parent ${e} is missing dependency ${i}; ${r.release.policy} on child ${r.childId} may have released all parent dependencies, but the HTTP snapshot cannot prove whether the policy fired`);continue}let n=N(o.get(i),e);if(n?.scope===`child`){m.add(`Parent ${e} is missing dependency ${i}; ${n.policy} may have released it, but the HTTP snapshot cannot prove whether the policy fired`);continue}p.add(`Parent ${e} lists child ${i} without the matching dependency`)}}for(let[e,t]of o){if(f.has(e)||!t.parentId)continue;let n=o.get(t.parentId);!n||f.has(t.parentId)||n.childrenIds?.includes(e)||p.add(`Parent ${t.parentId} does not list child ${e}`)}let C=j([...o.keys()],c);return{jobs:o,edges:s,truncated:S,failed:f.size,failures:f,issues:[...p],policyNotes:[...m],cycle:C,limitations:[...h]}}var re=`bq-dash-recent-flows`,P=8;function F(e){return`${re}:${encodeURIComponent(e.trim()||`/api`)}`}function I(e,t){if(!t)return[];try{let t=JSON.parse(localStorage.getItem(F(e))??`[]`);return Array.isArray(t)?t.filter(e=>typeof e?.root==`string`&&e.root.length>0&&e.root.length<=1024&&Number.isSafeInteger(e?.nodes)&&e.nodes>1&&e.nodes<=500&&Number.isFinite(e?.at)&&e.at>=0).slice(0,P):[]}catch{return[]}}function ie(e,t,n,r){let i=[n,...t.filter(e=>e.root!==n.root)].slice(0,P);if(!r)return i;try{localStorage.setItem(F(e),JSON.stringify(i))}catch{}return i}var L=e(r(),1),ae=new Set([`explore`,`create`,`operations`]);function R(e,t=``){let n=e.get(`root`),r=ce(n)?n:t,i=e.get(`mode`),a=ae.has(i)?i:`explore`,o=e.get(`node`);return{root:r,mode:a,node:r&&ce(o)?o:null}}function oe(e){let t=new URLSearchParams;return e.root&&t.set(`root`,e.root),e.mode!==`explore`&&t.set(`mode`,e.mode),e.root&&e.node&&t.set(`node`,e.node),t}function se(e,t,n=``){return oe({...R(e,n),...t})}function ce(e){return!!(e&&A(e)===null)}function le(){let[e,t]=n(),r=v()?S:``,i=e.toString(),a=(0,L.useMemo)(()=>R(new URLSearchParams(i),r),[r,i]),c=a.root,l=s(e=>e.baseUrl),d=s(e=>e.token),f=o(),[p,m]=(0,L.useState)(c),[h,g]=(0,L.useState)(null),[_,y]=(0,L.useState)(!!c),[b,x]=(0,L.useState)(null),[C,w]=(0,L.useState)(()=>I(f,d.length===0)),T=(0,L.useRef)(0),D=(0,L.useRef)(null),O=(0,L.useRef)(!1),k=(0,L.useRef)(z()),j=h?.seed===c?h.graph:null,te=j?a.node&&j.jobs.has(a.node)?a.node:h?.defaultSelected??null:null,M=(0,L.useCallback)((e,n=!1)=>{t(t=>se(t,e,r),{replace:n})},[r,t]),N=(0,L.useCallback)(async e=>{let t=s.getState();if(t.baseUrl!==l||t.token!==d)return;D.current?.abort(),D.current=null;let n=++T.current,r=e.trim();if(g(null),x(null),!r)return y(!1);let i=A(r);if(i)return x(new E(i)),y(!1);let a=u(),o=z(),c=new AbortController;D.current=c;let f=()=>O.current&&n===T.current&&!c.signal.aborted&&o===z();y(!0);try{let e={target:a,signal:c.signal},t=await ee(r,e),n=t.missingParent?[`Ancestor ${t.missingParent} is no longer available. The graph starts at the oldest surviving node.`]:[],i=await ne(t.id,t.job,{...e,seedPath:t.path,limitations:n});if(!f())return;g({seed:r,graph:i,defaultSelected:t.id}),i.jobs.size>1&&w(e=>ie(a.baseUrl,e,{root:t.id,nodes:i.jobs.size,at:Date.now()},s.getState().token.length===0))}catch(e){f()&&x(e instanceof Error?e:Error(`Failed to load flow`))}finally{D.current===c&&(D.current=null),f()&&y(!1)}},[l,d]);return(0,L.useEffect)(()=>{O.current=!0,k.current=z();let e=s.subscribe(()=>{let e=z();e!==k.current&&(k.current=e,T.current+=1,D.current?.abort(),D.current=null,O.current&&(g(null),x(null),y(!1)))});return()=>{O.current=!1,e(),T.current+=1,D.current?.abort()}},[]),(0,L.useEffect)(()=>w(d?[]:I(f,!0)),[f,d]),(0,L.useEffect)(()=>{let e={...a};j&&(!e.node||!j.jobs.has(e.node))&&(e.node=h?.defaultSelected??null);let n=oe(e).toString();n!==i&&t(n,{replace:!0})},[j,i,t,h?.defaultSelected,a]),(0,L.useEffect)(()=>{m(c),N(c)},[c,N]),{input:p,setInput:m,rootParam:c,mode:a.mode,setMode:e=>M({mode:e}),graph:j,selected:te,setSelected:e=>{j?.jobs.has(e)&&M({node:e})},loading:_,error:b,recent:C,load:N,submit:e=>{e.preventDefault();let t=p.trim();if(t){if(A(t))return void N(t);t===c?N(t):M({root:t,mode:`explore`,node:null})}},openRecent:e=>{if(m(e),A(e))return void N(e);let t=e===c;M({root:e,mode:`explore`,node:null}),t&&N(e)}}}function z(){let{token:e}=s.getState();return JSON.stringify([o(),e])}function ue(e){return e instanceof l&&e.status===0||[`TypeError`,`AbortError`,`TimeoutError`].includes(e.name)}var B=e=>({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),de=new Set([`removeChildDependency`,`removeUnprocessedChildren`,`removeDeduplicationKey`,`retry`,`promote`,`remove`]),fe=e=>e+5e3,V={create:(e,t)=>f(`/flows/create?target=${encodeURIComponent(o())}`,B({operation:e,...t})),getFlow:e=>{let t=new URLSearchParams({id:e.id,queueName:e.queueName,target:o()});return e.depth!==void 0&&t.set(`depth`,String(e.depth)),e.maxChildren!==void 0&&t.set(`maxChildren`,String(e.maxChildren)),f(`/flows/tree?${t}`)},inspect:(e,t)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:o()})}`),getParentResult:e=>f(`/flows/results?target=${encodeURIComponent(o())}`,B({operation:`getParentResult`,parentId:e})),getParentResults:e=>f(`/flows/results?target=${encodeURIComponent(o())}`,B({operation:`getParentResults`,parentIds:e})),waitUntilFinished:(e,t)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/waitUntilFinished?${new URLSearchParams({queueName:e.queueName,target:o(),ttl:String(t)})}`,void 0,fe(t)),mutate:(e,t,n)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:o()})}`,de.has(t)?{method:`POST`}:B(n??{}))},H=a();function U({value:e}){return(0,H.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-md border border-line bg-bg p-3 font-mono text-xs text-muted`,children:JSON.stringify(e,null,2)})}function W(...e){return JSON.stringify(e)}function G(e){let t=y(),n=(0,L.useMemo)(()=>({key:e,connectionEpoch:t}),[t,e]),r=(0,L.useRef)(n),i=(0,L.useRef)(void 0),a=(0,L.useRef)(void 0),o=(0,L.useRef)(0),s=(0,L.useRef)(!0),[c,l]=(0,L.useState)(),[u,d]=(0,L.useState)(),[f,p]=(0,L.useState)();return(0,L.useLayoutEffect)(()=>{r.current=n,i.current=void 0,a.current=void 0},[n]),(0,L.useEffect)(()=>(s.current=!0,()=>{s.current=!1,i.current=void 0,a.current=void 0}),[]),{busy:c?.identity===n?c.label:``,error:f?.identity===n?f.message:``,result:u?.identity===n?u.value:void 0,reject:e=>{b()===n.connectionEpoch&&(a.current=void 0,i.current=void 0,l(void 0),d(void 0),p({identity:n,message:e}))},run:async(e,t)=>{if(i.current?.identity===n||b()!==n.connectionEpoch)return;let c={id:++o.current,identity:n};i.current=c,a.current=c,l({...c,label:e}),d(void 0),p(void 0);try{let e=await t();s.current&&r.current===n&&b()===n.connectionEpoch&&a.current===c&&d({identity:n,value:e})}catch(e){s.current&&r.current===n&&b()===n.connectionEpoch&&a.current===c&&p({identity:n,message:pe(e)})}finally{i.current===c&&(i.current=void 0),s.current&&l(e=>e?.id===c.id?void 0:e)}}}}function pe(e){return e instanceof Error?e.message:String(e)}var K={add:{flow:{name:`aggregate`,queueName:`reports`,data:{},children:[{name:`fetch`,queueName:`io`,data:{source:`orders`}}]},options:{queuesOptions:{io:{attempts:3,backoff:1e3}}}},addBulk:{flows:[{name:`report-a`,queueName:`reports`,data:{region:`eu`}},{name:`report-b`,queueName:`reports`,data:{region:`us`}}]},addChain:{steps:[{name:`extract`,queueName:`pipeline`,data:{}},{name:`transform`,queueName:`pipeline`,data:{}},{name:`load`,queueName:`pipeline`,data:{}}]},addBulkThen:{parallel:[{name:`part-a`,queueName:`parallel`,data:{}},{name:`part-b`,queueName:`parallel`,data:{}}],final:{name:`merge`,queueName:`final`,data:{}}},addTree:{root:{name:`root`,queueName:`tree`,data:{},children:[{name:`child`,queueName:`tree`,data:{}}]}}};function me({repository:e=V,onOpen:t}){let[n,r]=(0,L.useState)(`add`),[i,a]=(0,L.useState)(()=>JSON.stringify(K.add,null,2)),o=G(W(n,i)),s=!!o.busy,c=e=>{r(e),a(JSON.stringify(K[e],null,2))},l=async t=>{t.preventDefault();let r;try{r=JSON.parse(i)}catch{return o.reject(`The definition must be valid JSON.`)}if(!r||typeof r!=`object`||Array.isArray(r))return o.reject(`The definition must be a JSON object.`);let a=n;await o.run(a,()=>e.create(a,r))},u=he(o.result);return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`form`,{onSubmit:l,className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`FlowProducer method`,(0,H.jsx)(`select`,{"aria-label":`FlowProducer method`,value:n,onChange:e=>c(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:Object.keys(K).map(e=>(0,H.jsx)(`option`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`submit`,disabled:s,className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:s?`Creating…`:`Run ${n}`})]}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Definition`,(0,H.jsx)(`textarea`,{"aria-label":`Flow definition JSON`,spellCheck:!1,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-80 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg outline-none focus:ring-2 focus:ring-accent/50`})]})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Atomic commit result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:`Validation is performed by Bunqueue before the graph is committed.`}),o.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:o.error}),o.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow created in this session.`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{value:o.result}),u&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(u),className:`mt-3 rounded-lg border border-line px-3 py-2 text-xs text-fg`,children:`Open created flow`})]})]})]})}function he(e){let t=e,n=t?.result?.root?.id??t?.result?.roots?.[0]?.id??t?.result?.finalId??t?.result?.jobIds?.at(-1);return typeof n==`string`?n:null}function ge({recent:e,onOpen:t}){return(0,H.jsx)(p,{children:(0,H.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID, or choose “View flow” from Job Inspector.`}),e.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,H.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:e.map(e=>(0,H.jsxs)(`button`,{type:`button`,title:e.root,onClick:()=>t(e.root),className:`min-h-10 rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted hover:text-fg`,children:[(0,H.jsx)(`span`,{translate:`no`,children:T(e.root)}),(0,H.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})})}function q({target:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Job ID`,(0,H.jsx)(`input`,{"aria-label":`Flow job ID`,value:e.id,onChange:n=>t({...e,id:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 font-mono text-sm text-fg`})]}),(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Queue name`,(0,H.jsx)(`input`,{"aria-label":`Flow queue name`,value:e.queueName,onChange:n=>t({...e,queueName:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})]})}var _e=[`getChildrenValues`,`getDependencies`,`getDependenciesCount`,`getFailedChildrenValues`,`getIgnoredChildrenFailures`],ve=[{id:`removeChildDependency`,label:`Release dependency`,dangerous:!0},{id:`removeUnprocessedChildren`,label:`Remove unprocessed children`,dangerous:!0},{id:`retry`,label:`Retry job`},{id:`promote`,label:`Promote delayed job`},{id:`remove`,label:`Remove job`,dangerous:!0}];function ye({repository:e=V,initialTarget:t={id:``,queueName:``},target:n,onTargetChange:r,showTarget:i=!0}){let[a,o]=(0,L.useState)(t),s=n??a,c=r??o,l=G(W(s.id,s.queueName)),u=l.busy,d=!!(s.id.trim()&&s.queueName.trim()),f=t=>{let n=be(s);l.run(t,()=>e.inspect(n,t))},p=t=>{let n=be(s);window.confirm(`${t} on ${n.id} in ${n.queueName}? This changes durable queue state and has no compare-and-swap precondition.`)&&l.run(t,()=>e.mutate(n,t))};return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(360px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Dependency control`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Run the official Flow Job dependency methods against the managed server TCP endpoint.`}),i&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:s,onChange:c})}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_e.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,onClick:()=>f(e),className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:e},e))}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Mutate`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ve.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,onClick:()=>p(e.id),className:e.dangerous?`rounded-md border border-danger/40 px-2.5 py-1.5 text-xs text-danger disabled:opacity-40`:`rounded-md border border-line px-2.5 py-1.5 text-xs text-muted disabled:opacity-40`,children:e.label},e.id))})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Operation result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:u?`Running ${u}…`:`The last authoritative broker response appears here.`}),l.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:l.error}),l.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Choose an inspection or mutation.`}):(0,H.jsx)(U,{value:l.result})]})]})}var be=e=>({id:e.id.trim(),queueName:e.queueName.trim()});function xe({repository:e=V,initialIds:t=``}){let[n,r]=(0,L.useState)(t),i=G(W(n)),a=i.busy,o=Se(n),s=async t=>{if(o.length===0)return;let n=[...o];await i.run(t,async()=>t===`one`?await e.getParentResult(n[0]):await e.getParentResults(n))};return(0,H.jsxs)(`section`,{className:`grid gap-5 rounded-lg border border-line bg-surface p-4 xl:grid-cols-[minmax(320px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Parent results`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Resolve completed parent values through the official FlowProducer result API.`}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Parent IDs, one per line`,(0,H.jsx)(`textarea`,{"aria-label":`Flow parent IDs`,value:n,onChange:e=>r(e.target.value),placeholder:`parent-job-id
|
|
2
|
-
another-parent-id`,className:`mt-1 min-h-28 w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg`})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:o.length===0||!!a,onClick:()=>void s(`one`),className:`rounded-md border border-line px-3 py-1.5 font-mono text-xs text-muted disabled:opacity-40`,children:`getParentResult`}),(0,H.jsxs)(`button`,{type:`button`,disabled:o.length===0||!!a,onClick:()=>void s(`many`),className:`rounded-md border border-line px-3 py-1.5 font-mono text-xs text-muted disabled:opacity-40`,children:[`getParentResults (`,o.length,`)`]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`Resolved values`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:a?`Reading durable results…`:`Falsy values and input ordering are preserved.`}),i.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:i.error}),i.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No parent result requested.`}):(0,H.jsx)(U,{value:i.result})]})]})}function Se(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).slice(0,1e3)}function Ce({repository:e=V,target:t,onTargetChange:n}){let[r,i]=(0,L.useState)(`10`),[a,o]=(0,L.useState)(`100`),s=G(W(t.id,t.queueName,r,a)),c=!!s.busy,l=!!(t.id.trim()&&t.queueName.trim())&&Oe(r)&&Oe(a),u=async()=>{if(!l)return;let n={target:{id:t.id.trim(),queueName:t.queueName.trim()},depth:Number(r),maxChildren:Number(a)};await s.run(`getFlow`,async()=>{let t=await e.getFlow({...n.target,depth:n.depth,maxChildren:n.maxChildren});return{...n,value:t}})};return(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`FlowProducer.getFlow`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Read the broker-native tree with explicit traversal limits. Results are bound to the target and limits that produced them.`})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!l||c,onClick:()=>void u(),className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:c?`Loading tree...`:`Load getFlow tree`})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:t,onChange:n})}),(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(we,{label:`Depth`,value:r,onChange:i}),(0,H.jsx)(we,{label:`Children per level`,value:a,onChange:o})]}),(0,H.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Both limits accept integers from 0 to 500.`}),s.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:s.error}),s.result&&(0,H.jsx)(Te,{loaded:s.result})]})}function we({label:e,value:t,onChange:n}){return(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[e,(0,H.jsx)(`input`,{"aria-label":`getFlow ${e}`,type:`number`,min:`0`,max:`500`,step:`1`,value:t,onChange:e=>n(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})}function Te({loaded:e}){let t=Ee(e.value),n=t?De(t):[];return(0,H.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,"aria-live":`polite`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,H.jsxs)(`span`,{className:`font-mono text-fg`,children:[e.target.queueName,`/`,e.target.id]}),(0,H.jsxs)(`span`,{className:`text-faint`,children:[`depth `,e.depth,`, max children `,e.maxChildren]})]}),t===null?(0,H.jsx)(`p`,{className:`rounded-md border border-line bg-bg p-3 text-sm text-muted`,children:`Bunqueue returned no flow for this target.`}):n.length>0?(0,H.jsx)(`ul`,{"aria-label":`getFlow tree result`,className:`max-h-72 overflow-auto rounded-md border border-line bg-bg`,children:n.map(e=>(0,H.jsxs)(`li`,{className:`flex min-w-max items-center gap-2 border-b border-line/60 px-3 py-2 last:border-b-0`,style:{paddingLeft:`${12+Math.min(e.level,20)*18}px`},children:[(0,H.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${w(e.state)}`,children:e.state}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-fg`,children:e.id}),(0,H.jsx)(`span`,{className:`text-xs text-muted`,children:e.name}),(0,H.jsx)(`span`,{className:`text-[11px] text-faint`,children:e.queueName})]},e.id))}):(0,H.jsx)(`p`,{role:`alert`,className:`rounded-md border border-warning/40 p-3 text-sm text-warning`,children:`The agent returned an unrecognized getFlow payload. Inspect the raw JSON below.`}),(0,H.jsxs)(`details`,{className:`mt-3`,open:!0,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-muted`,children:`Raw getFlow JSON`}),(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsx)(U,{value:e.value})})]})]})}function Ee(e){let t=J(e),n=J(t?.result)??t;if(!(!n||!Object.hasOwn(n,`flow`)))return n.flow===null?null:J(n.flow)}function De(e){let t=[],n=[{node:e,level:0}],r=new WeakSet;for(;n.length>0&&t.length<1e3;){let e=n.shift();if(!e||r.has(e.node))continue;r.add(e.node),t.push({id:Y(e.node.id,`(missing id)`),name:Y(e.node.name,`(unnamed)`),queueName:Y(e.node.queueName,`(missing queue)`),state:Y(e.node.state,`unknown`),level:e.level});let i=Array.isArray(e.node.children)?e.node.children:[];n.unshift(...i.map(J).filter(e=>e!==void 0).map(t=>({node:t,level:e.level+1})))}return t}var Oe=e=>/^\d+$/.test(e)&&Number(e)<=500,J=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,Y=(e,t)=>typeof e==`string`&&e.length>0?e:t,ke=[`getState`,`isWaiting`,`isActive`,`isDelayed`,`isCompleted`,`isFailed`,`isWaitingChildren`,`toJSON`,`asJSON`],X={updateData:{data:{}},updateProgress:{progress:50,message:`Halfway`},log:{message:`Operator note`},changeDelay:{delay:1e3},changePriority:{priority:1,lifo:!1},clearLogs:{keepLogs:0},removeDeduplicationKey:{}},Ae={progress:{stage:`hydrate`,completed:4,total:10}};function je({repository:e=V,initialTarget:t={id:``,queueName:``}}){let[n,r]=(0,L.useState)(t),[i,a]=(0,L.useState)(`updateData`),[o,s]=(0,L.useState)(JSON.stringify(X.updateData,null,2)),[c,l]=(0,L.useState)(`30000`),u=G(W(n.id,n.queueName,i,o,c)),d=u.busy,f=!!(n.id.trim()&&n.queueName.trim()),p=e=>{a(e),s(JSON.stringify(X[e],null,2))};return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsx)(Ce,{repository:e,target:n,onTargetChange:r}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Flow Job methods`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`State predicates, serialization, bounded waiting, and durable mutations from Bunqueue 2.8.57.`})]}),d&&(0,H.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[d,`…`]})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:n,onChange:r})}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect state and wire JSON`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ke.map(t=>(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d,onClick:()=>{let r=Z(n);u.run(t,()=>e.inspect(r,t))},className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:t},t))}),(0,H.jsxs)(`div`,{className:`mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Mutation`,(0,H.jsx)(`select`,{"aria-label":`Flow Job mutation`,value:i,onChange:e=>p(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 font-mono text-xs text-fg`,children:Object.keys(X).map(e=>(0,H.jsx)(`option`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d,onClick:()=>{let t;try{t=JSON.parse(o)}catch{return u.reject(`Mutation payload must be valid JSON.`)}if(!t||typeof t!=`object`||Array.isArray(t))return u.reject(`Mutation payload must be a JSON object.`);let r=Z(n),a=i;window.confirm(`${a} on ${r.id}? This writes durable job state without a compare-and-swap precondition.`)&&u.run(a,()=>e.mutate(r,a,t))},className:`h-9 rounded-md border border-warning/40 px-3 text-xs text-warning disabled:opacity-40`,children:`Apply mutation`}),i===`updateProgress`&&(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(JSON.stringify(X.updateProgress,null,2)),className:`h-9 rounded-md border border-line px-3 text-xs text-muted`,children:`Numeric progress`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(JSON.stringify(Ae,null,2)),className:`h-9 rounded-md border border-line px-3 text-xs text-muted`,children:`Object progress`})]})]}),(0,H.jsx)(`textarea`,{"aria-label":`Flow Job mutation JSON`,value:o,onChange:e=>s(e.target.value),className:`mt-3 min-h-32 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`waitUntilFinished TTL (ms)`,(0,H.jsx)(`input`,{"aria-label":`Flow wait TTL`,type:`number`,min:`1`,max:`60000`,value:c,onChange:e=>l(e.target.value),className:`mt-1 block h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d||!Me(c),onClick:()=>{let t=Z(n),r=Number(c);u.run(`waitUntilFinished`,()=>e.waitUntilFinished(t,r))},className:`mt-3 rounded-md border border-line px-3 py-2 font-mono text-xs text-muted disabled:opacity-40`,children:`waitUntilFinished`}),(0,H.jsx)(`p`,{className:`mt-3 text-[11px] leading-5 text-faint`,children:`Lease-only methods are not forged here: extendLock and worker state transitions require the active worker token; discard is process-local and non-awaitable.`})]})]}),u.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:u.error}),u.result!==void 0&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(U,{value:u.result})})]}),(0,H.jsx)(ye,{repository:e,target:n,onTargetChange:r,showTarget:!1}),(0,H.jsx)(xe,{repository:e})]})}var Z=e=>({id:e.id.trim(),queueName:e.queueName.trim()}),Me=e=>Number.isSafeInteger(Number(e))&&Number(e)>=1&&Number(e)<=6e4;function Ne({input:e,loading:t,onInput:n,onSubmit:r}){return(0,H.jsxs)(p,{className:`mb-6`,children:[(0,H.jsxs)(`form`,{onSubmit:r,className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`input`,{name:`flow-job-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:e,onChange:e=>n(e.target.value),placeholder:`Flow job ID`,"aria-label":`Root job ID`,"aria-describedby":`flow-input-help`,className:`min-w-0 flex-1 rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,H.jsx)(`button`,{type:`submit`,disabled:t||!e.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:t?`Loading…`:`Load Flow`})]}),(0,H.jsxs)(`p`,{id:`flow-input-help`,className:`mt-2 text-xs text-faint`,children:[`Start from any surviving structural node. Bunqueue 2.8.57 flow topology is resolved from durable parent, children, and dependency contracts. Up to `,500,` nodes are rendered.`]})]})}var Pe={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function Fe(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 Ie(e,t,n={}){let r={...Pe,...n},i=Fe(e,t),a=new Map,o=0;for(let t of e){let e=i.get(t)??0;o=Math.max(o,e);let n=a.get(e);n?n.push(t):a.set(e,[t])}let s=0;for(let e of a.values())s=Math.max(s,e.length);let c=s*r.nodeHeight+Math.max(0,s-1)*r.rowGap,l=[];for(let e=0;e<=o;e++){let t=a.get(e)??[],n=t.length*r.nodeHeight+Math.max(0,t.length-1)*r.rowGap,i=r.padding+(c-n)/2;t.forEach((t,n)=>{l.push({id:t,layer:e,x:r.padding+e*(r.nodeWidth+r.colGap),y:i+n*(r.nodeHeight+r.rowGap)})})}return{nodes:l,width:r.padding*2+(o+1)*r.nodeWidth+o*r.colGap,height:r.padding*2+c}}function Le({graph:e,layout:n,selected:r,onSelect:i}){let a=new Map(n.nodes.map(e=>[e.id,e]));return(0,H.jsxs)(p,{padded:!1,className:`max-h-[70vh] overflow-auto overscroll-contain p-4`,children:[(0,H.jsx)(`h2`,{className:`sr-only`,children:`Flow Graph`}),(0,H.jsx)(`ul`,{className:`sr-only`,"aria-label":`Flow relationships`,children:e.edges.map(e=>(0,H.jsx)(`li`,{children:e.kind===`child`?`${e.from} has child ${e.to}`:`${e.to} depends on ${e.from}`},`accessible-${e.from}-${e.to}-${e.kind}`))}),(0,H.jsxs)(`div`,{className:`relative`,style:{width:n.width,height:n.height},children:[(0,H.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:n.width,height:n.height,children:[(0,H.jsxs)(`defs`,{children:[(0,H.jsx)(`marker`,{id:`flow-arrow-child`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,H.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})}),(0,H.jsx)(`marker`,{id:`flow-arrow-dependency`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,H.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})})]}),e.edges.map(e=>{let t=a.get(e.from),n=a.get(e.to);return!t||!n?null:(0,H.jsx)(`path`,{d:ze(t,n),fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeDasharray:e.kind===`depends`?`4 4`:void 0,markerEnd:`url(#flow-arrow-${e.kind===`depends`?`dependency`:`child`})`,opacity:.5},`${e.from}-${e.to}-${e.kind}`)})]}),n.nodes.map(n=>{let a=e.jobs.get(n.id),o=e.failures.has(n.id)?`unavailable`:a?.state??`unknown`;return(0,H.jsxs)(`button`,{type:`button`,"data-flow-node":n.id,onClick:()=>i(n.id),"aria-pressed":r===n.id,"aria-label":`${n.id}, queue ${a?.queue??`unknown`}, state ${o}`,title:n.id,style:{left:n.x,top:n.y,width:168,height:60},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/70`,w(a?.state),r===n.id&&`ring-2 ring-accent`),children:[(0,H.jsx)(`span`,{translate:`no`,className:`truncate font-mono text-xs text-fg`,children:T(n.id)}),(0,H.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:a?.queue??`—`}),(0,H.jsx)(`span`,{className:`font-medium`,children:o})]})]},n.id)})]})]})}function Re(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function ze(e,t){return e.x<=t.x?Re(e.x+168,e.y+60/2,t.x,t.y+60/2):Re(e.x,e.y+60/2,t.x+168,t.y+60/2)}function Be({graph:e,selected:t}){let n=t?e.jobs.get(t):void 0,r=t?e.failures.get(t):void 0;return(0,H.jsx)(`aside`,{"aria-label":`Selected job details`,"aria-live":`polite`,children:(0,H.jsxs)(p,{children:[n?(0,H.jsx)(Ve,{job:n,failure:r}):(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Select a node to inspect it.`}),(0,H.jsx)(He,{graph:e})]})})}function Ve({job:e,failure:t}){return(0,H.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,H.jsx)(`div`,{translate:`no`,className:`break-all font-mono text-xs text-fg`,children:e.id})]}),t&&(0,H.jsxs)(`p`,{role:`alert`,className:`break-words text-xs text-warning`,children:[`Snapshot unavailable: `,t]}),(0,H.jsx)($,{label:`Queue`,value:e.queue??`—`}),(0,H.jsx)($,{label:`State`,value:t?`unavailable`:e.state??`unknown`}),(0,H.jsx)($,{label:`Priority`,value:e.priority===void 0?`—`:String(e.priority)}),(0,H.jsx)($,{label:`Parent`,value:e.parentId??`—`}),(0,H.jsx)($,{label:`Children`,value:t?`—`:String(e.childrenIds?.length??0)}),(0,H.jsx)($,{label:`Depends on`,value:t?`—`:String(e.dependsOn?.length??0)}),(0,H.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`inline-block rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Open in Job Inspector`})]})}function He({graph:e}){return(0,H.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,"aria-live":`polite`,children:[e.truncated&&(0,H.jsxs)(`div`,{className:`mb-1 text-warning`,children:[`Graph truncated at `,500,` nodes / depth `,100,`.`]}),(0,H.jsx)(Q,{label:`known snapshot limitation`,pluralLabel:`known snapshot limitations`,values:e.limitations,tone:`text-warning`}),(0,H.jsx)(Q,{label:`unavailable node`,pluralLabel:`unavailable nodes`,values:[...e.failures].map(([e,t])=>`${e}: ${t}`),tone:`text-warning`}),e.cycle&&(0,H.jsxs)(`div`,{className:`mb-1 break-words text-danger`,children:[`Dependency cycle: `,(0,H.jsx)(`span`,{className:`font-mono`,children:e.cycle.join(` → `)})]}),(0,H.jsx)(Q,{label:`snapshot inconsistency`,pluralLabel:`snapshot inconsistencies`,values:e.issues,tone:`text-warning`}),e.policyNotes.length>0&&(0,H.jsx)(`p`,{className:`mb-1 text-muted`,children:`Failure-policy notes are informational; the HTTP snapshot cannot prove that a policy fired.`}),(0,H.jsx)(Q,{label:`failure-policy ambiguity`,pluralLabel:`failure-policy ambiguities`,values:e.policyNotes,tone:`text-muted`}),(0,H.jsxs)(`div`,{className:`mb-1`,children:[e.jobs.size,` nodes · `,e.edges.length,` edges`]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` depends`]})]})]})}function Q({label:e,pluralLabel:t,values:n,tone:r}){return n.length?(0,H.jsxs)(`details`,{className:`mb-1 ${r}`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer`,children:[n.length,` `,n.length===1?e:t]}),(0,H.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:n.map(e=>(0,H.jsx)(`li`,{className:`break-words`,children:e},e))})]}):null}function $({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e}),(0,H.jsx)(`span`,{className:`min-w-0 break-all text-right text-fg`,children:t})]})}function Ue({graph:e,selected:t,onSelect:n}){return(0,H.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,H.jsx)(Le,{graph:e,layout:(0,L.useMemo)(()=>Ie([...e.jobs.keys()],e.edges,x),[e]),selected:t,onSelect:n}),(0,H.jsx)(Be,{graph:e,selected:t})]})}function We(){let e=le();return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(_,{title:`Job Flows`,description:`Inspect Bunqueue 2.8.57 parent, child, and dependency topology as an operational DAG.`,actions:e.graph&&(0,H.jsx)(`button`,{type:`button`,disabled:e.loading,onClick:()=>void e.load(e.rootParam),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg disabled:opacity-50`,children:`Refresh`})}),(0,H.jsx)(`nav`,{"aria-label":`Job Flow tools`,className:`mb-5 flex border-b border-line`,children:[`explore`,`create`,`operations`].map(t=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":e.mode===t,onClick:()=>e.setMode(t),className:e.mode===t?`border-b-2 border-accent px-4 py-2 text-sm capitalize text-fg`:`border-b-2 border-transparent px-4 py-2 text-sm capitalize text-faint hover:text-fg`,children:t===`operations`?`Job methods`:t},t))}),e.mode===`create`&&(0,H.jsx)(me,{onOpen:e.openRecent}),e.mode===`operations`&&(0,H.jsx)(je,{initialTarget:v()?{id:`flow-order-9a3f`,queueName:`orders`}:void 0}),e.mode===`explore`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ne,{input:e.input,loading:e.loading,onInput:e.setInput,onSubmit:e.submit}),(0,H.jsxs)(`div`,{"aria-live":`polite`,children:[e.error&&(ue(e.error)?(0,H.jsx)(m,{message:`Could not load the flow — ${e.error.message}`,onRetry:()=>void e.load(e.rootParam)}):(0,H.jsx)(h,{error:e.error,onRetry:()=>void e.load(e.rootParam)})),e.loading&&(0,H.jsx)(g,{label:`Loading flow…`})]}),!e.loading&&!e.graph&&!e.error&&(0,H.jsx)(ge,{recent:e.recent,onOpen:e.openRecent}),e.graph&&(0,H.jsx)(Ue,{graph:e.graph,selected:e.selected,onSelect:e.setSelected})]})]})}export{We as Flows};
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{i as o,o as s}from"./connectionStore-CKFQrxDo.js";import{i as c}from"./upstreamPaths-CDVsu6IM.js";import{a as l,d as u,f as d,s as f}from"./bq-Bmysbg0r.js";import{t as p}from"./Card-C7NMhqUt.js";import{i as m,n as h,r as g}from"./feedback-BnGE2oW2.js";import{t as _}from"./PageHeader-BXlZSBcc.js";import{i as v}from"./index-Cue53Myw.js";import{n as y,t as b}from"./controlConnectionEpoch-JM4omZ6j.js";var x={nodeWidth:168,nodeHeight:60},S=`flow-order-9a3f`,C={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`},w=e=>e&&C[e]||`border-line bg-surface-2 text-muted`,T=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,E=class extends Error{constructor(e,t){super(e,t),this.name=`FlowSnapshotError`}};function D(e,t,n){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`||c(e)!==null))throw new E(`Job ${n} returned an invalid ${t} list`);return e}function O(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new E(`GET /jobs/${t} returned an invalid response`);let n=e;if(n.ok!==!0)throw new E(`GET /jobs/${t} returned an invalid success envelope`);let r=n.job;if(typeof r!=`object`||!r||Array.isArray(r))throw new E(`GET /jobs/${t} returned no job snapshot`);let i=r;if(i.id!==t)throw new E(`GET /jobs/${t} returned the wrong job id (${String(i.id)})`);if(typeof i.queue!=`string`||i.queue.length===0)throw new E(`Job ${t} returned an invalid queue`);if(typeof i.state!=`string`||i.state.length===0)throw new E(`Job ${t} returned an invalid state`);if(!Object.hasOwn(i,`parentId`)||i.parentId!==null&&(typeof i.parentId!=`string`||c(i.parentId)!==null))throw new E(`Job ${t} returned an invalid parentId`);return{...r,parentId:i.parentId,childrenIds:D(i.childrenIds,`childrenIds`,t),dependsOn:D(i.dependsOn,`dependsOn`,t)}}async function k(e,t,n){n?.throwIfAborted();let r=await d(e,t,n);return n?.throwIfAborted(),O(r,t)}function A(e){let t=c(e);return t?`Job ID: ${t}`:null}async function ee(e,t={}){let n=A(e);if(n)throw new E(n);let r=t.target??u(),{signal:i}=t,a=e,o=new Set([e]),s=[];for(let e=0;;e++){i?.throwIfAborted();let t;try{t=await k(r,a,i)}catch(t){if(i?.throwIfAborted(),e===0)throw t;if(t instanceof l&&t.status===404){let e=s.at(-1);if(!e)throw t;return{id:e.id,job:e,hops:Math.max(0,s.length-1),path:s,missingParent:a}}throw new E(`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 E(`Flow parent cycle detected at job ${n}`);if(e>=100)throw new E(`Flow parent chain exceeds the Bunqueue 2.8.59 limit of 100 levels`);o.add(n),a=n}}function j(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 te=[`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`];function M(e){return te.filter(t=>e[t]===!0)}function N(e,t){if(e?.parentId!==t)return null;let n=M(e);return n.length===1?n[0]===`continueParentOnFailure`?{scope:`parent`,policy:`continueParentOnFailure`}:n[0]===`removeDependencyOnFailure`?{scope:`child`,policy:`removeDependencyOnFailure`}:n[0]===`ignoreDependencyOnFailure`?{scope:`child`,policy:`ignoreDependencyOnFailure`}:null:null}async function ne(e,t,n={}){let r=A(e);if(r)throw new E(r);let i=n.target??u(),{signal:a}=n,o=new Map,s=[],c=[],l=new Set,d=new Set,f=new Map,p=new Set,m=new Set,h=new Set(n.limitations??[]),g=[{id:e,depth:0}],_=new Set([e]),v=new Map;t&&v.set(e,O({ok:!0,job:t},e));let y=[...n.seedPath??[]].reverse(),b=!1;if(y.length>0&&y[0]?.id!==e)throw new E(`Resolved seed path does not start at the requested flow root`);for(let[e,t]of y.entries()){let n=O({ok:!0,job:t},t.id);if(v.set(n.id,n),e!==0){if(e>100||_.size>=500){b=!0;continue}_.has(n.id)||(_.add(n.id),g.push({id:n.id,depth:e}))}}let x=new Set,S=b;for(;g.length;){a?.throwIfAborted();let{id:t,depth:n}=g.shift();if(x.has(t))continue;x.add(t);let r=null;try{r=v.get(t)??await k(i,t,a)}catch(n){if(a?.throwIfAborted(),t===e)throw n;f.set(t,n instanceof Error?n.message:String(n))}if(o.set(t,r??{id:t,state:`unknown`}),!r)continue;if(n>=100){(r.childrenIds?.length??0)+(r.dependsOn?.length??0)>0&&(S=!0);continue}let u=e=>_.has(e)?!0:_.size>=500?(S=!0,!1):(_.add(e),g.push({id:e,depth:n+1}),!0),m=(e,t,n,r)=>{if(!u(r))return;let i=`${e}->${t}:${n}`;l.has(i)||(l.add(i),s.push({from:e,to:t,kind:n}))},h=r.childrenIds??[],y=r.dependsOn??[],b=new Set(h),C=new Set(y);b.size!==h.length&&p.add(`Job ${t} lists a child more than once`),C.size!==y.length&&p.add(`Job ${t} lists a dependency more than once`);for(let e of h)m(t,e,`child`,e);for(let e of y)if(u(e)){let n=`${e}->${t}`;d.has(n)||(d.add(n),c.push({from:e,to:t,kind:`depends`})),b.has(e)||m(e,t,`depends`,e)}}for(let[e,t]of o)!f.has(e)&&M(t).length>1&&p.add(`Job ${e} enables mutually exclusive failure policies`);for(let e of s){if(e.kind!==`child`||f.has(e.to))continue;let t=o.get(e.to);t&&t.parentId!==e.from&&p.add(`Child ${e.to} points to parent ${String(t.parentId??`none`)}, not ${e.from}`)}for(let[e,t]of o){if(f.has(e))continue;let n=t.childrenIds??[];if(n.some(e=>!o.has(e)||f.has(e)))continue;let r=n.map(t=>({childId:t,release:N(o.get(t),e)})).find(({release:e})=>e?.scope===`parent`);for(let i of n){if(t.dependsOn?.includes(i))continue;if(r?.release?.scope===`parent`){m.add(`Parent ${e} is missing dependency ${i}; ${r.release.policy} on child ${r.childId} may have released all parent dependencies, but the HTTP snapshot cannot prove whether the policy fired`);continue}let n=N(o.get(i),e);if(n?.scope===`child`){m.add(`Parent ${e} is missing dependency ${i}; ${n.policy} may have released it, but the HTTP snapshot cannot prove whether the policy fired`);continue}p.add(`Parent ${e} lists child ${i} without the matching dependency`)}}for(let[e,t]of o){if(f.has(e)||!t.parentId)continue;let n=o.get(t.parentId);!n||f.has(t.parentId)||n.childrenIds?.includes(e)||p.add(`Parent ${t.parentId} does not list child ${e}`)}let C=j([...o.keys()],c);return{jobs:o,edges:s,truncated:S,failed:f.size,failures:f,issues:[...p],policyNotes:[...m],cycle:C,limitations:[...h]}}var re=`bq-dash-recent-flows`,P=8;function F(e){return`${re}:${encodeURIComponent(e.trim()||`/api`)}`}function I(e,t){if(!t)return[];try{let t=JSON.parse(localStorage.getItem(F(e))??`[]`);return Array.isArray(t)?t.filter(e=>typeof e?.root==`string`&&e.root.length>0&&e.root.length<=1024&&Number.isSafeInteger(e?.nodes)&&e.nodes>1&&e.nodes<=500&&Number.isFinite(e?.at)&&e.at>=0).slice(0,P):[]}catch{return[]}}function ie(e,t,n,r){let i=[n,...t.filter(e=>e.root!==n.root)].slice(0,P);if(!r)return i;try{localStorage.setItem(F(e),JSON.stringify(i))}catch{}return i}var L=e(r(),1),ae=new Set([`explore`,`create`,`operations`]);function R(e,t=``){let n=e.get(`root`),r=ce(n)?n:t,i=e.get(`mode`),a=ae.has(i)?i:`explore`,o=e.get(`node`);return{root:r,mode:a,node:r&&ce(o)?o:null}}function oe(e){let t=new URLSearchParams;return e.root&&t.set(`root`,e.root),e.mode!==`explore`&&t.set(`mode`,e.mode),e.root&&e.node&&t.set(`node`,e.node),t}function se(e,t,n=``){return oe({...R(e,n),...t})}function ce(e){return!!(e&&A(e)===null)}function le(){let[e,t]=n(),r=v()?S:``,i=e.toString(),a=(0,L.useMemo)(()=>R(new URLSearchParams(i),r),[r,i]),c=a.root,l=s(e=>e.baseUrl),d=s(e=>e.token),f=o(),[p,m]=(0,L.useState)(c),[h,g]=(0,L.useState)(null),[_,y]=(0,L.useState)(!!c),[b,x]=(0,L.useState)(null),[C,w]=(0,L.useState)(()=>I(f,d.length===0)),T=(0,L.useRef)(0),D=(0,L.useRef)(null),O=(0,L.useRef)(!1),k=(0,L.useRef)(z()),j=h?.seed===c?h.graph:null,te=j?a.node&&j.jobs.has(a.node)?a.node:h?.defaultSelected??null:null,M=(0,L.useCallback)((e,n=!1)=>{t(t=>se(t,e,r),{replace:n})},[r,t]),N=(0,L.useCallback)(async e=>{let t=s.getState();if(t.baseUrl!==l||t.token!==d)return;D.current?.abort(),D.current=null;let n=++T.current,r=e.trim();if(g(null),x(null),!r)return y(!1);let i=A(r);if(i)return x(new E(i)),y(!1);let a=u(),o=z(),c=new AbortController;D.current=c;let f=()=>O.current&&n===T.current&&!c.signal.aborted&&o===z();y(!0);try{let e={target:a,signal:c.signal},t=await ee(r,e),n=t.missingParent?[`Ancestor ${t.missingParent} is no longer available. The graph starts at the oldest surviving node.`]:[],i=await ne(t.id,t.job,{...e,seedPath:t.path,limitations:n});if(!f())return;g({seed:r,graph:i,defaultSelected:t.id}),i.jobs.size>1&&w(e=>ie(a.baseUrl,e,{root:t.id,nodes:i.jobs.size,at:Date.now()},s.getState().token.length===0))}catch(e){f()&&x(e instanceof Error?e:Error(`Failed to load flow`))}finally{D.current===c&&(D.current=null),f()&&y(!1)}},[l,d]);return(0,L.useEffect)(()=>{O.current=!0,k.current=z();let e=s.subscribe(()=>{let e=z();e!==k.current&&(k.current=e,T.current+=1,D.current?.abort(),D.current=null,O.current&&(g(null),x(null),y(!1)))});return()=>{O.current=!1,e(),T.current+=1,D.current?.abort()}},[]),(0,L.useEffect)(()=>w(d?[]:I(f,!0)),[f,d]),(0,L.useEffect)(()=>{let e={...a};j&&(!e.node||!j.jobs.has(e.node))&&(e.node=h?.defaultSelected??null);let n=oe(e).toString();n!==i&&t(n,{replace:!0})},[j,i,t,h?.defaultSelected,a]),(0,L.useEffect)(()=>{m(c),N(c)},[c,N]),{input:p,setInput:m,rootParam:c,mode:a.mode,setMode:e=>M({mode:e}),graph:j,selected:te,setSelected:e=>{j?.jobs.has(e)&&M({node:e})},loading:_,error:b,recent:C,load:N,submit:e=>{e.preventDefault();let t=p.trim();if(t){if(A(t))return void N(t);t===c?N(t):M({root:t,mode:`explore`,node:null})}},openRecent:e=>{if(m(e),A(e))return void N(e);let t=e===c;M({root:e,mode:`explore`,node:null}),t&&N(e)}}}function z(){let{token:e}=s.getState();return JSON.stringify([o(),e])}function ue(e){return e instanceof l&&e.status===0||[`TypeError`,`AbortError`,`TimeoutError`].includes(e.name)}var B=e=>({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),de=new Set([`removeChildDependency`,`removeUnprocessedChildren`,`removeDeduplicationKey`,`retry`,`promote`,`remove`]),fe=e=>e+5e3,V={create:(e,t)=>f(`/flows/create?target=${encodeURIComponent(o())}`,B({operation:e,...t})),getFlow:e=>{let t=new URLSearchParams({id:e.id,queueName:e.queueName,target:o()});return e.depth!==void 0&&t.set(`depth`,String(e.depth)),e.maxChildren!==void 0&&t.set(`maxChildren`,String(e.maxChildren)),f(`/flows/tree?${t}`)},inspect:(e,t)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:o()})}`),getParentResult:e=>f(`/flows/results?target=${encodeURIComponent(o())}`,B({operation:`getParentResult`,parentId:e})),getParentResults:e=>f(`/flows/results?target=${encodeURIComponent(o())}`,B({operation:`getParentResults`,parentIds:e})),waitUntilFinished:(e,t)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/waitUntilFinished?${new URLSearchParams({queueName:e.queueName,target:o(),ttl:String(t)})}`,void 0,fe(t)),mutate:(e,t,n)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:o()})}`,de.has(t)?{method:`POST`}:B(n??{}))},H=a();function U({value:e}){return(0,H.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-md border border-line bg-bg p-3 font-mono text-xs text-muted`,children:JSON.stringify(e,null,2)})}function W(...e){return JSON.stringify(e)}function G(e){let t=y(),n=(0,L.useMemo)(()=>({key:e,connectionEpoch:t}),[t,e]),r=(0,L.useRef)(n),i=(0,L.useRef)(void 0),a=(0,L.useRef)(void 0),o=(0,L.useRef)(0),s=(0,L.useRef)(!0),[c,l]=(0,L.useState)(),[u,d]=(0,L.useState)(),[f,p]=(0,L.useState)();return(0,L.useLayoutEffect)(()=>{r.current=n,i.current=void 0,a.current=void 0},[n]),(0,L.useEffect)(()=>(s.current=!0,()=>{s.current=!1,i.current=void 0,a.current=void 0}),[]),{busy:c?.identity===n?c.label:``,error:f?.identity===n?f.message:``,result:u?.identity===n?u.value:void 0,reject:e=>{b()===n.connectionEpoch&&(a.current=void 0,i.current=void 0,l(void 0),d(void 0),p({identity:n,message:e}))},run:async(e,t)=>{if(i.current?.identity===n||b()!==n.connectionEpoch)return;let c={id:++o.current,identity:n};i.current=c,a.current=c,l({...c,label:e}),d(void 0),p(void 0);try{let e=await t();s.current&&r.current===n&&b()===n.connectionEpoch&&a.current===c&&d({identity:n,value:e})}catch(e){s.current&&r.current===n&&b()===n.connectionEpoch&&a.current===c&&p({identity:n,message:pe(e)})}finally{i.current===c&&(i.current=void 0),s.current&&l(e=>e?.id===c.id?void 0:e)}}}}function pe(e){return e instanceof Error?e.message:String(e)}var K={add:{flow:{name:`aggregate`,queueName:`reports`,data:{},children:[{name:`fetch`,queueName:`io`,data:{source:`orders`}}]},options:{queuesOptions:{io:{attempts:3,backoff:1e3}}}},addBulk:{flows:[{name:`report-a`,queueName:`reports`,data:{region:`eu`}},{name:`report-b`,queueName:`reports`,data:{region:`us`}}]},addChain:{steps:[{name:`extract`,queueName:`pipeline`,data:{}},{name:`transform`,queueName:`pipeline`,data:{}},{name:`load`,queueName:`pipeline`,data:{}}]},addBulkThen:{parallel:[{name:`part-a`,queueName:`parallel`,data:{}},{name:`part-b`,queueName:`parallel`,data:{}}],final:{name:`merge`,queueName:`final`,data:{}}},addTree:{root:{name:`root`,queueName:`tree`,data:{},children:[{name:`child`,queueName:`tree`,data:{}}]}}};function me({repository:e=V,onOpen:t}){let[n,r]=(0,L.useState)(`add`),[i,a]=(0,L.useState)(()=>JSON.stringify(K.add,null,2)),o=G(W(n,i)),s=!!o.busy,c=e=>{r(e),a(JSON.stringify(K[e],null,2))},l=async t=>{t.preventDefault();let r;try{r=JSON.parse(i)}catch{return o.reject(`The definition must be valid JSON.`)}if(!r||typeof r!=`object`||Array.isArray(r))return o.reject(`The definition must be a JSON object.`);let a=n;await o.run(a,()=>e.create(a,r))},u=he(o.result);return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`form`,{onSubmit:l,className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`FlowProducer method`,(0,H.jsx)(`select`,{"aria-label":`FlowProducer method`,value:n,onChange:e=>c(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:Object.keys(K).map(e=>(0,H.jsx)(`option`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`submit`,disabled:s,className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:s?`Creating…`:`Run ${n}`})]}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Definition`,(0,H.jsx)(`textarea`,{"aria-label":`Flow definition JSON`,spellCheck:!1,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-80 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg outline-none focus:ring-2 focus:ring-accent/50`})]})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Atomic commit result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:`Validation is performed by Bunqueue before the graph is committed.`}),o.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:o.error}),o.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow created in this session.`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{value:o.result}),u&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(u),className:`mt-3 rounded-lg border border-line px-3 py-2 text-xs text-fg`,children:`Open created flow`})]})]})]})}function he(e){let t=e,n=t?.result?.root?.id??t?.result?.roots?.[0]?.id??t?.result?.finalId??t?.result?.jobIds?.at(-1);return typeof n==`string`?n:null}function ge({recent:e,onOpen:t}){return(0,H.jsx)(p,{children:(0,H.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID, or choose “View flow” from Job Inspector.`}),e.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,H.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:e.map(e=>(0,H.jsxs)(`button`,{type:`button`,title:e.root,onClick:()=>t(e.root),className:`min-h-10 rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted hover:text-fg`,children:[(0,H.jsx)(`span`,{translate:`no`,children:T(e.root)}),(0,H.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})})}function q({target:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Job ID`,(0,H.jsx)(`input`,{"aria-label":`Flow job ID`,value:e.id,onChange:n=>t({...e,id:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 font-mono text-sm text-fg`})]}),(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Queue name`,(0,H.jsx)(`input`,{"aria-label":`Flow queue name`,value:e.queueName,onChange:n=>t({...e,queueName:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})]})}var _e=[`getChildrenValues`,`getDependencies`,`getDependenciesCount`,`getFailedChildrenValues`,`getIgnoredChildrenFailures`],ve=[{id:`removeChildDependency`,label:`Release dependency`,dangerous:!0},{id:`removeUnprocessedChildren`,label:`Remove unprocessed children`,dangerous:!0},{id:`retry`,label:`Retry job`},{id:`promote`,label:`Promote delayed job`},{id:`remove`,label:`Remove job`,dangerous:!0}];function ye({repository:e=V,initialTarget:t={id:``,queueName:``},target:n,onTargetChange:r,showTarget:i=!0}){let[a,o]=(0,L.useState)(t),s=n??a,c=r??o,l=G(W(s.id,s.queueName)),u=l.busy,d=!!(s.id.trim()&&s.queueName.trim()),f=t=>{let n=be(s);l.run(t,()=>e.inspect(n,t))},p=t=>{let n=be(s);window.confirm(`${t} on ${n.id} in ${n.queueName}? This changes durable queue state and has no compare-and-swap precondition.`)&&l.run(t,()=>e.mutate(n,t))};return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(360px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Dependency control`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Run the official Flow Job dependency methods against the managed server TCP endpoint.`}),i&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:s,onChange:c})}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_e.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,onClick:()=>f(e),className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:e},e))}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Mutate`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ve.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,onClick:()=>p(e.id),className:e.dangerous?`rounded-md border border-danger/40 px-2.5 py-1.5 text-xs text-danger disabled:opacity-40`:`rounded-md border border-line px-2.5 py-1.5 text-xs text-muted disabled:opacity-40`,children:e.label},e.id))})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Operation result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:u?`Running ${u}…`:`The last authoritative broker response appears here.`}),l.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:l.error}),l.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Choose an inspection or mutation.`}):(0,H.jsx)(U,{value:l.result})]})]})}var be=e=>({id:e.id.trim(),queueName:e.queueName.trim()});function xe({repository:e=V,initialIds:t=``}){let[n,r]=(0,L.useState)(t),i=G(W(n)),a=i.busy,o=Se(n),s=async t=>{if(o.length===0)return;let n=[...o];await i.run(t,async()=>t===`one`?await e.getParentResult(n[0]):await e.getParentResults(n))};return(0,H.jsxs)(`section`,{className:`grid gap-5 rounded-lg border border-line bg-surface p-4 xl:grid-cols-[minmax(320px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Parent results`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Resolve completed parent values through the official FlowProducer result API.`}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Parent IDs, one per line`,(0,H.jsx)(`textarea`,{"aria-label":`Flow parent IDs`,value:n,onChange:e=>r(e.target.value),placeholder:`parent-job-id
|
|
2
|
+
another-parent-id`,className:`mt-1 min-h-28 w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg`})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:o.length===0||!!a,onClick:()=>void s(`one`),className:`rounded-md border border-line px-3 py-1.5 font-mono text-xs text-muted disabled:opacity-40`,children:`getParentResult`}),(0,H.jsxs)(`button`,{type:`button`,disabled:o.length===0||!!a,onClick:()=>void s(`many`),className:`rounded-md border border-line px-3 py-1.5 font-mono text-xs text-muted disabled:opacity-40`,children:[`getParentResults (`,o.length,`)`]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`Resolved values`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:a?`Reading durable results…`:`Falsy values and input ordering are preserved.`}),i.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:i.error}),i.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No parent result requested.`}):(0,H.jsx)(U,{value:i.result})]})]})}function Se(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).slice(0,1e3)}function Ce({repository:e=V,target:t,onTargetChange:n}){let[r,i]=(0,L.useState)(`10`),[a,o]=(0,L.useState)(`100`),s=G(W(t.id,t.queueName,r,a)),c=!!s.busy,l=!!(t.id.trim()&&t.queueName.trim())&&Oe(r)&&Oe(a),u=async()=>{if(!l)return;let n={target:{id:t.id.trim(),queueName:t.queueName.trim()},depth:Number(r),maxChildren:Number(a)};await s.run(`getFlow`,async()=>{let t=await e.getFlow({...n.target,depth:n.depth,maxChildren:n.maxChildren});return{...n,value:t}})};return(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`FlowProducer.getFlow`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Read the broker-native tree with explicit traversal limits. Results are bound to the target and limits that produced them.`})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!l||c,onClick:()=>void u(),className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:c?`Loading tree...`:`Load getFlow tree`})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:t,onChange:n})}),(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(we,{label:`Depth`,value:r,onChange:i}),(0,H.jsx)(we,{label:`Children per level`,value:a,onChange:o})]}),(0,H.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Both limits accept integers from 0 to 500.`}),s.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:s.error}),s.result&&(0,H.jsx)(Te,{loaded:s.result})]})}function we({label:e,value:t,onChange:n}){return(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[e,(0,H.jsx)(`input`,{"aria-label":`getFlow ${e}`,type:`number`,min:`0`,max:`500`,step:`1`,value:t,onChange:e=>n(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})}function Te({loaded:e}){let t=Ee(e.value),n=t?De(t):[];return(0,H.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,"aria-live":`polite`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,H.jsxs)(`span`,{className:`font-mono text-fg`,children:[e.target.queueName,`/`,e.target.id]}),(0,H.jsxs)(`span`,{className:`text-faint`,children:[`depth `,e.depth,`, max children `,e.maxChildren]})]}),t===null?(0,H.jsx)(`p`,{className:`rounded-md border border-line bg-bg p-3 text-sm text-muted`,children:`Bunqueue returned no flow for this target.`}):n.length>0?(0,H.jsx)(`ul`,{"aria-label":`getFlow tree result`,className:`max-h-72 overflow-auto rounded-md border border-line bg-bg`,children:n.map(e=>(0,H.jsxs)(`li`,{className:`flex min-w-max items-center gap-2 border-b border-line/60 px-3 py-2 last:border-b-0`,style:{paddingLeft:`${12+Math.min(e.level,20)*18}px`},children:[(0,H.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${w(e.state)}`,children:e.state}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-fg`,children:e.id}),(0,H.jsx)(`span`,{className:`text-xs text-muted`,children:e.name}),(0,H.jsx)(`span`,{className:`text-[11px] text-faint`,children:e.queueName})]},e.id))}):(0,H.jsx)(`p`,{role:`alert`,className:`rounded-md border border-warning/40 p-3 text-sm text-warning`,children:`The agent returned an unrecognized getFlow payload. Inspect the raw JSON below.`}),(0,H.jsxs)(`details`,{className:`mt-3`,open:!0,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-muted`,children:`Raw getFlow JSON`}),(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsx)(U,{value:e.value})})]})]})}function Ee(e){let t=J(e),n=J(t?.result)??t;if(!(!n||!Object.hasOwn(n,`flow`)))return n.flow===null?null:J(n.flow)}function De(e){let t=[],n=[{node:e,level:0}],r=new WeakSet;for(;n.length>0&&t.length<1e3;){let e=n.shift();if(!e||r.has(e.node))continue;r.add(e.node),t.push({id:Y(e.node.id,`(missing id)`),name:Y(e.node.name,`(unnamed)`),queueName:Y(e.node.queueName,`(missing queue)`),state:Y(e.node.state,`unknown`),level:e.level});let i=Array.isArray(e.node.children)?e.node.children:[];n.unshift(...i.map(J).filter(e=>e!==void 0).map(t=>({node:t,level:e.level+1})))}return t}var Oe=e=>/^\d+$/.test(e)&&Number(e)<=500,J=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,Y=(e,t)=>typeof e==`string`&&e.length>0?e:t,ke=[`getState`,`isWaiting`,`isActive`,`isDelayed`,`isCompleted`,`isFailed`,`isWaitingChildren`,`toJSON`,`asJSON`],X={updateData:{data:{}},updateProgress:{progress:50,message:`Halfway`},log:{message:`Operator note`},changeDelay:{delay:1e3},changePriority:{priority:1,lifo:!1},clearLogs:{keepLogs:0},removeDeduplicationKey:{}},Ae={progress:{stage:`hydrate`,completed:4,total:10}};function je({repository:e=V,initialTarget:t={id:``,queueName:``}}){let[n,r]=(0,L.useState)(t),[i,a]=(0,L.useState)(`updateData`),[o,s]=(0,L.useState)(JSON.stringify(X.updateData,null,2)),[c,l]=(0,L.useState)(`30000`),u=G(W(n.id,n.queueName,i,o,c)),d=u.busy,f=!!(n.id.trim()&&n.queueName.trim()),p=e=>{a(e),s(JSON.stringify(X[e],null,2))};return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsx)(Ce,{repository:e,target:n,onTargetChange:r}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Flow Job methods`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`State predicates, serialization, bounded waiting, and durable mutations from Bunqueue 2.8.59.`})]}),d&&(0,H.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[d,`…`]})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:n,onChange:r})}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect state and wire JSON`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ke.map(t=>(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d,onClick:()=>{let r=Z(n);u.run(t,()=>e.inspect(r,t))},className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:t},t))}),(0,H.jsxs)(`div`,{className:`mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Mutation`,(0,H.jsx)(`select`,{"aria-label":`Flow Job mutation`,value:i,onChange:e=>p(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 font-mono text-xs text-fg`,children:Object.keys(X).map(e=>(0,H.jsx)(`option`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d,onClick:()=>{let t;try{t=JSON.parse(o)}catch{return u.reject(`Mutation payload must be valid JSON.`)}if(!t||typeof t!=`object`||Array.isArray(t))return u.reject(`Mutation payload must be a JSON object.`);let r=Z(n),a=i;window.confirm(`${a} on ${r.id}? This writes durable job state without a compare-and-swap precondition.`)&&u.run(a,()=>e.mutate(r,a,t))},className:`h-9 rounded-md border border-warning/40 px-3 text-xs text-warning disabled:opacity-40`,children:`Apply mutation`}),i===`updateProgress`&&(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(JSON.stringify(X.updateProgress,null,2)),className:`h-9 rounded-md border border-line px-3 text-xs text-muted`,children:`Numeric progress`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(JSON.stringify(Ae,null,2)),className:`h-9 rounded-md border border-line px-3 text-xs text-muted`,children:`Object progress`})]})]}),(0,H.jsx)(`textarea`,{"aria-label":`Flow Job mutation JSON`,value:o,onChange:e=>s(e.target.value),className:`mt-3 min-h-32 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`waitUntilFinished TTL (ms)`,(0,H.jsx)(`input`,{"aria-label":`Flow wait TTL`,type:`number`,min:`1`,max:`60000`,value:c,onChange:e=>l(e.target.value),className:`mt-1 block h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d||!Me(c),onClick:()=>{let t=Z(n),r=Number(c);u.run(`waitUntilFinished`,()=>e.waitUntilFinished(t,r))},className:`mt-3 rounded-md border border-line px-3 py-2 font-mono text-xs text-muted disabled:opacity-40`,children:`waitUntilFinished`}),(0,H.jsx)(`p`,{className:`mt-3 text-[11px] leading-5 text-faint`,children:`Lease-only methods are not forged here: extendLock and worker state transitions require the active worker token; discard is process-local and non-awaitable.`})]})]}),u.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:u.error}),u.result!==void 0&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(U,{value:u.result})})]}),(0,H.jsx)(ye,{repository:e,target:n,onTargetChange:r,showTarget:!1}),(0,H.jsx)(xe,{repository:e})]})}var Z=e=>({id:e.id.trim(),queueName:e.queueName.trim()}),Me=e=>Number.isSafeInteger(Number(e))&&Number(e)>=1&&Number(e)<=6e4;function Ne({input:e,loading:t,onInput:n,onSubmit:r}){return(0,H.jsxs)(p,{className:`mb-6`,children:[(0,H.jsxs)(`form`,{onSubmit:r,className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`input`,{name:`flow-job-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:e,onChange:e=>n(e.target.value),placeholder:`Flow job ID`,"aria-label":`Root job ID`,"aria-describedby":`flow-input-help`,className:`min-w-0 flex-1 rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,H.jsx)(`button`,{type:`submit`,disabled:t||!e.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:t?`Loading…`:`Load Flow`})]}),(0,H.jsxs)(`p`,{id:`flow-input-help`,className:`mt-2 text-xs text-faint`,children:[`Start from any surviving structural node. Bunqueue 2.8.59 flow topology is resolved from durable parent, children, and dependency contracts. Up to `,500,` nodes are rendered.`]})]})}var Pe={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function Fe(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 Ie(e,t,n={}){let r={...Pe,...n},i=Fe(e,t),a=new Map,o=0;for(let t of e){let e=i.get(t)??0;o=Math.max(o,e);let n=a.get(e);n?n.push(t):a.set(e,[t])}let s=0;for(let e of a.values())s=Math.max(s,e.length);let c=s*r.nodeHeight+Math.max(0,s-1)*r.rowGap,l=[];for(let e=0;e<=o;e++){let t=a.get(e)??[],n=t.length*r.nodeHeight+Math.max(0,t.length-1)*r.rowGap,i=r.padding+(c-n)/2;t.forEach((t,n)=>{l.push({id:t,layer:e,x:r.padding+e*(r.nodeWidth+r.colGap),y:i+n*(r.nodeHeight+r.rowGap)})})}return{nodes:l,width:r.padding*2+(o+1)*r.nodeWidth+o*r.colGap,height:r.padding*2+c}}function Le({graph:e,layout:n,selected:r,onSelect:i}){let a=new Map(n.nodes.map(e=>[e.id,e]));return(0,H.jsxs)(p,{padded:!1,className:`max-h-[70vh] overflow-auto overscroll-contain p-4`,children:[(0,H.jsx)(`h2`,{className:`sr-only`,children:`Flow Graph`}),(0,H.jsx)(`ul`,{className:`sr-only`,"aria-label":`Flow relationships`,children:e.edges.map(e=>(0,H.jsx)(`li`,{children:e.kind===`child`?`${e.from} has child ${e.to}`:`${e.to} depends on ${e.from}`},`accessible-${e.from}-${e.to}-${e.kind}`))}),(0,H.jsxs)(`div`,{className:`relative`,style:{width:n.width,height:n.height},children:[(0,H.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:n.width,height:n.height,children:[(0,H.jsxs)(`defs`,{children:[(0,H.jsx)(`marker`,{id:`flow-arrow-child`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,H.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})}),(0,H.jsx)(`marker`,{id:`flow-arrow-dependency`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,H.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})})]}),e.edges.map(e=>{let t=a.get(e.from),n=a.get(e.to);return!t||!n?null:(0,H.jsx)(`path`,{d:ze(t,n),fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeDasharray:e.kind===`depends`?`4 4`:void 0,markerEnd:`url(#flow-arrow-${e.kind===`depends`?`dependency`:`child`})`,opacity:.5},`${e.from}-${e.to}-${e.kind}`)})]}),n.nodes.map(n=>{let a=e.jobs.get(n.id),o=e.failures.has(n.id)?`unavailable`:a?.state??`unknown`;return(0,H.jsxs)(`button`,{type:`button`,"data-flow-node":n.id,onClick:()=>i(n.id),"aria-pressed":r===n.id,"aria-label":`${n.id}, queue ${a?.queue??`unknown`}, state ${o}`,title:n.id,style:{left:n.x,top:n.y,width:168,height:60},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/70`,w(a?.state),r===n.id&&`ring-2 ring-accent`),children:[(0,H.jsx)(`span`,{translate:`no`,className:`truncate font-mono text-xs text-fg`,children:T(n.id)}),(0,H.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:a?.queue??`—`}),(0,H.jsx)(`span`,{className:`font-medium`,children:o})]})]},n.id)})]})]})}function Re(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function ze(e,t){return e.x<=t.x?Re(e.x+168,e.y+60/2,t.x,t.y+60/2):Re(e.x,e.y+60/2,t.x+168,t.y+60/2)}function Be({graph:e,selected:t}){let n=t?e.jobs.get(t):void 0,r=t?e.failures.get(t):void 0;return(0,H.jsx)(`aside`,{"aria-label":`Selected job details`,"aria-live":`polite`,children:(0,H.jsxs)(p,{children:[n?(0,H.jsx)(Ve,{job:n,failure:r}):(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Select a node to inspect it.`}),(0,H.jsx)(He,{graph:e})]})})}function Ve({job:e,failure:t}){return(0,H.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,H.jsx)(`div`,{translate:`no`,className:`break-all font-mono text-xs text-fg`,children:e.id})]}),t&&(0,H.jsxs)(`p`,{role:`alert`,className:`break-words text-xs text-warning`,children:[`Snapshot unavailable: `,t]}),(0,H.jsx)($,{label:`Queue`,value:e.queue??`—`}),(0,H.jsx)($,{label:`State`,value:t?`unavailable`:e.state??`unknown`}),(0,H.jsx)($,{label:`Priority`,value:e.priority===void 0?`—`:String(e.priority)}),(0,H.jsx)($,{label:`Parent`,value:e.parentId??`—`}),(0,H.jsx)($,{label:`Children`,value:t?`—`:String(e.childrenIds?.length??0)}),(0,H.jsx)($,{label:`Depends on`,value:t?`—`:String(e.dependsOn?.length??0)}),(0,H.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`inline-block rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Open in Job Inspector`})]})}function He({graph:e}){return(0,H.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,"aria-live":`polite`,children:[e.truncated&&(0,H.jsxs)(`div`,{className:`mb-1 text-warning`,children:[`Graph truncated at `,500,` nodes / depth `,100,`.`]}),(0,H.jsx)(Q,{label:`known snapshot limitation`,pluralLabel:`known snapshot limitations`,values:e.limitations,tone:`text-warning`}),(0,H.jsx)(Q,{label:`unavailable node`,pluralLabel:`unavailable nodes`,values:[...e.failures].map(([e,t])=>`${e}: ${t}`),tone:`text-warning`}),e.cycle&&(0,H.jsxs)(`div`,{className:`mb-1 break-words text-danger`,children:[`Dependency cycle: `,(0,H.jsx)(`span`,{className:`font-mono`,children:e.cycle.join(` → `)})]}),(0,H.jsx)(Q,{label:`snapshot inconsistency`,pluralLabel:`snapshot inconsistencies`,values:e.issues,tone:`text-warning`}),e.policyNotes.length>0&&(0,H.jsx)(`p`,{className:`mb-1 text-muted`,children:`Failure-policy notes are informational; the HTTP snapshot cannot prove that a policy fired.`}),(0,H.jsx)(Q,{label:`failure-policy ambiguity`,pluralLabel:`failure-policy ambiguities`,values:e.policyNotes,tone:`text-muted`}),(0,H.jsxs)(`div`,{className:`mb-1`,children:[e.jobs.size,` nodes · `,e.edges.length,` edges`]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` depends`]})]})]})}function Q({label:e,pluralLabel:t,values:n,tone:r}){return n.length?(0,H.jsxs)(`details`,{className:`mb-1 ${r}`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer`,children:[n.length,` `,n.length===1?e:t]}),(0,H.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:n.map(e=>(0,H.jsx)(`li`,{className:`break-words`,children:e},e))})]}):null}function $({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e}),(0,H.jsx)(`span`,{className:`min-w-0 break-all text-right text-fg`,children:t})]})}function Ue({graph:e,selected:t,onSelect:n}){return(0,H.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,H.jsx)(Le,{graph:e,layout:(0,L.useMemo)(()=>Ie([...e.jobs.keys()],e.edges,x),[e]),selected:t,onSelect:n}),(0,H.jsx)(Be,{graph:e,selected:t})]})}function We(){let e=le();return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(_,{title:`Job Flows`,description:`Inspect Bunqueue 2.8.59 parent, child, and dependency topology as an operational DAG.`,actions:e.graph&&(0,H.jsx)(`button`,{type:`button`,disabled:e.loading,onClick:()=>void e.load(e.rootParam),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg disabled:opacity-50`,children:`Refresh`})}),(0,H.jsx)(`nav`,{"aria-label":`Job Flow tools`,className:`mb-5 flex border-b border-line`,children:[`explore`,`create`,`operations`].map(t=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":e.mode===t,onClick:()=>e.setMode(t),className:e.mode===t?`border-b-2 border-accent px-4 py-2 text-sm capitalize text-fg`:`border-b-2 border-transparent px-4 py-2 text-sm capitalize text-faint hover:text-fg`,children:t===`operations`?`Job methods`:t},t))}),e.mode===`create`&&(0,H.jsx)(me,{onOpen:e.openRecent}),e.mode===`operations`&&(0,H.jsx)(je,{initialTarget:v()?{id:`flow-order-9a3f`,queueName:`orders`}:void 0}),e.mode===`explore`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ne,{input:e.input,loading:e.loading,onInput:e.setInput,onSubmit:e.submit}),(0,H.jsxs)(`div`,{"aria-live":`polite`,children:[e.error&&(ue(e.error)?(0,H.jsx)(m,{message:`Could not load the flow — ${e.error.message}`,onRetry:()=>void e.load(e.rootParam)}):(0,H.jsx)(h,{error:e.error,onRetry:()=>void e.load(e.rootParam)})),e.loading&&(0,H.jsx)(g,{label:`Loading flow…`})]}),!e.loading&&!e.graph&&!e.error&&(0,H.jsx)(ge,{recent:e.recent,onOpen:e.openRecent}),e.graph&&(0,H.jsx)(Ue,{graph:e.graph,selected:e.selected,onSelect:e.setSelected})]})]})}export{We as Flows};
|