bunqueue-dashboard 0.0.29 → 0.0.31
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/agent/db.ts +16 -19
- package/agent/server.ts +4 -4
- package/dist/.vite/manifest.json +194 -146
- package/dist/assets/{AddJob-UCSTFuum.js → AddJob-CAhdg38n.js} +1 -1
- package/dist/assets/{Alerts-CofRabaP.js → Alerts-70bxf-PT.js} +1 -1
- package/dist/assets/{AreaChart-Dl_9G6GH.js → AreaChart-2gM0YoZT.js} +1 -1
- package/dist/assets/{Benchmark-B1VUJJLw.js → Benchmark-CFZ3WCvj.js} +1 -1
- package/dist/assets/{BulkAddJobs-DVgkRtrp.js → BulkAddJobs-BzgzpGg_.js} +1 -1
- package/dist/assets/CopilotPanel-DZUGIf1q.js +44 -0
- package/dist/assets/{Cron-CqlZj2V5.js → Cron-ltjSoTjj.js} +1 -1
- package/dist/assets/CronManager-BcFALDeT.js +1 -0
- package/dist/assets/{Database-BYZ8LJb5.js → Database-CV2yt5O2.js} +2 -2
- package/dist/assets/{Diagnostics-Dk1ErNCF.js → Diagnostics-D-EK4GEi.js} +1 -1
- package/dist/assets/Dlq-fZAKwQoC.js +1 -0
- package/dist/assets/DlqControl-eTrrQCrn.js +1 -0
- package/dist/assets/{DlqPro-D8DOy5MI.js → DlqPro-CF79339e.js} +1 -1
- package/dist/assets/{Flows-DP9-h7a0.js → Flows-Ba8G7mcC.js} +1 -1
- package/dist/assets/JobInspector--d_8ca9p.js +2 -0
- package/dist/assets/Jobs-DEqAc1A5.js +1 -0
- package/dist/assets/JobsPro-BcaokZIf.js +1 -0
- package/dist/assets/Logs-DBTukPIX.js +1 -0
- package/dist/assets/LogsPro-Wl_e6hZM.js +1 -0
- package/dist/assets/{McpServer-MfQ0qsAI.js → McpServer-CnWJsKw7.js} +1 -1
- package/dist/assets/{Metrics-C4Dwg_DP.js → Metrics-DzeIhNL-.js} +1 -1
- package/dist/assets/{MetricsPro-Bt9zLjkN.js → MetricsPro-O9eVJSH0.js} +1 -1
- package/dist/assets/Overview-Bnu7rWqt.js +1 -0
- package/dist/assets/{Pagination-BQg6KGW1.js → Pagination-D4ki-pGz.js} +1 -1
- package/dist/assets/QueueActions-DHoSkWRz.js +1 -0
- package/dist/assets/QueueControl-DKqEXnkM.js +1 -0
- package/dist/assets/{QueueDetail-wjRLlCYY.js → QueueDetail-DLRow04B.js} +1 -1
- package/dist/assets/QueueDetailPro-BYmOVd4T.js +1 -0
- package/dist/assets/Queues-CoyjRFN7.js +1 -0
- package/dist/assets/{QueuesOverview-DfRqAfS1.js → QueuesOverview-BeWdJpKi.js} +1 -1
- package/dist/assets/{S3Backup-UQ_HKrn0.js → S3Backup-BaLFgl9d.js} +1 -1
- package/dist/assets/{S3BackupPro-V3JNhUK8.js → S3BackupPro-DJB4oWgz.js} +1 -1
- package/dist/assets/{ServerControl-DXidWdsq.js → ServerControl-_0lVB33E.js} +1 -1
- package/dist/assets/{Settings-0j8DZK9n.js → Settings-zKFJTtnq.js} +1 -1
- package/dist/assets/Usage-CKGkvl0j.js +1 -0
- package/dist/assets/{UsagePro-CbVFCD3J.js → UsagePro-B-TJ6fp4.js} +1 -1
- package/dist/assets/{Webhooks-Dr0oBZr9.js → Webhooks-C3zmvY-_.js} +1 -1
- package/dist/assets/{Workers-Bwil4zIU.js → Workers-jKhhXl3W.js} +1 -1
- package/dist/assets/{WorkersPro-BRYPAhyx.js → WorkersPro-mvY5VX8I.js} +1 -1
- package/dist/assets/{connectionStore-B-hNUqwK.js → connectionStore-Ci04lJmR.js} +1 -1
- package/dist/assets/dist-1f1fMHVO.js +11 -0
- package/dist/assets/dist-BlWBaCN6.js +11 -0
- package/dist/assets/dist-DZL8soAh.js +79 -0
- package/dist/assets/dist-DjvZiKhB.js +2 -0
- package/dist/assets/dist-DpZcbP9W.js +11 -0
- package/dist/assets/{form-C-zZyKfB.js → form-DGinTEEb.js} +1 -1
- package/dist/assets/index-BOcegTHa.js +8 -0
- package/dist/assets/index-DWV3tgrk.css +1 -0
- package/dist/assets/{react-vendor-B68RYDeC.js → react-vendor-BcouBxpZ.js} +2 -2
- package/dist/assets/{useThroughputSeries-defI_JpV.js → useThroughputSeries-Chp5OLx3.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +5 -5
- package/scripts/embedded.gen.ts +122 -112
- package/scripts/serve.ts +11 -0
- package/dist/assets/CopilotPanel-BJeJYfaz.js +0 -152
- package/dist/assets/CronManager-C6kjWCLE.js +0 -1
- package/dist/assets/Dlq-DANXiXsm.js +0 -1
- package/dist/assets/DlqControl-DUturU7q.js +0 -1
- package/dist/assets/JobInspector-BHZtkFL6.js +0 -2
- package/dist/assets/Jobs-Bgr-HRmL.js +0 -1
- package/dist/assets/JobsPro-C2Vc2iRC.js +0 -1
- package/dist/assets/Logs-CaOn3IpL.js +0 -1
- package/dist/assets/LogsPro-BpSZaHzN.js +0 -1
- package/dist/assets/Overview-BO3xG6I0.js +0 -1
- package/dist/assets/QueueActions-Bez_iOjl.js +0 -1
- package/dist/assets/QueueControl-CEXlJDkE.js +0 -1
- package/dist/assets/QueueDetailPro-CuVyxX4Z.js +0 -1
- package/dist/assets/Queues-2W2E6e5R.js +0 -1
- package/dist/assets/Usage-C5DsZvR5.js +0 -1
- package/dist/assets/index-BjRjwWwc.js +0 -8
- package/dist/assets/index-mF63w920.css +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-
|
|
2
|
-
`)}function j(e,t,n){let r=URL.createObjectURL(new Blob([n],{type:t})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)}function M(){try{let e=JSON.parse(localStorage.getItem(D)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function N(e){try{localStorage.setItem(D,JSON.stringify(e))}catch{}return e}function P(e){return N([e,...M().filter(t=>t!==e)].slice(0,O))}function F(e){if(e==null)return`NULL`;let t=typeof e==`string`?e:String(e);try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function I({value:e,align:n}){if(e==null)return(0,C.jsx)(`span`,{className:`italic text-faint`,children:`NULL`});let r=typeof e==`string`?e:String(e);return(0,C.jsx)(`span`,{className:t(`block max-w-[24rem] truncate`,n===`right`&&`text-right tabular-nums`),title:r,children:r})}function L({columns:e,rows:n,truncatedCells:r,colMeta:i,sort:a,onSort:o,onRowClick:s,dimmed:c}){let l=(0,S.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,C.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,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsx)(`tr`,{className:`text-left text-[11px] uppercase tracking-wider text-faint`,children:e.map((e,n)=>{let r=i?.[e];return(0,C.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,C.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,C.jsx)(`span`,{className:`rounded bg-accent/15 px-1 py-0.5 text-[9px] font-semibold text-accent`,children:`PK`}),r?.type&&(0,C.jsx)(`span`,{className:`text-faint/70`,children:r.type.toLowerCase()}),(0,C.jsx)(`span`,{"aria-hidden":`true`,className:a?.col===e?`text-accent`:`text-faint/60`,children:a?.col===e?a.dir===`asc`?`▲`:`▼`:`↕`})]}):e},e)})})}),(0,C.jsx)(`tbody`,{children:n.map((e,n)=>(0,C.jsx)(`tr`,{onClick:s?()=>s(n):void 0,onKeyDown:s?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(n))}:void 0,tabIndex:s?0:void 0,className:t(`border-b border-line font-mono text-xs last:border-0 hover:bg-surface-2/40`,s&&`cursor-pointer`),children:e.map((e,t)=>(0,C.jsx)(`td`,{className:`whitespace-nowrap px-4 py-2 text-muted`,children:(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsx)(I,{value:e,align:l[t]?`right`:`left`}),r?.[n]?.[t]&&(0,C.jsx)(`span`,{title:`Value truncated — click the row to view it in full`,className:`shrink-0 rounded bg-warning/15 px-1 text-[9px] font-semibold text-warning`,children:`…`})]})},t))},n))})]})})}function R(){let[e,n]=(0,S.useState)(``),[r,a]=(0,S.useState)(0),[o,s]=(0,S.useState)(null),[c,b]=(0,S.useState)(`data`),[D,O]=(0,S.useState)(null),[k,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(`SELECT name FROM sqlite_master WHERE type = 'table'`),F=(0,S.useRef)(null),{data:I,error:R,loading:ie,refetch:ae}=i(()=>h.db.tables(),[],{intervalMs:1e4}),B=(0,S.useMemo)(()=>I?.tables??[],[I]),V=R instanceof f&&R.status===404,{data:H}=i(()=>V?Promise.resolve(null):h.db.info(),[V],{intervalMs:15e3}),U=e||B[0]?.name||``;(0,S.useEffect)(()=>{!e&&B[0]&&n(B[0].name)},[e,B]);let{data:W}=i(()=>U?h.db.schema(U):Promise.resolve(null),[U],{intervalMs:3e4}),oe=(0,S.useMemo)(()=>{let e={};if(W?.table===U)for(let t of W.columns)e[t.name]={type:t.type,primaryKey:t.primaryKey};return e},[W,U]),G=D?`${D.column}|${D.op}|${D.value}`:``,{data:K,error:q,loading:J}=i((0,S.useCallback)(async()=>U?{...await h.db.rows(U,w,r*w,o?.col,o?.dir,D??void 0),page:r,filterKey:G}:null,[U,r,o,D,G]),[U,r,o,G],{intervalMs:6e3}),Y=K&&K.table===U&&K.page===r&&K.orderBy===(o?.col??null)&&(!o||K.dir===o.dir)&&K.filterKey===G?K:null;(0,S.useEffect)(()=>{Y&&Y.total>0&&Y.rows.length===0&&r>0&&a(Math.max(0,Math.ceil(Y.total/w)-1))},[Y,r]);let[X,Z]=(0,S.useState)(!1),[Q,$]=(0,S.useState)(null),se=()=>{a(0),s(null),O(null),M(null)},ce=e=>{n(e),b(`data`),se()},le=e=>{a(0),M(null),s(t=>t?.col===e?t.dir===`asc`?{col:e,dir:`desc`}:null:{col:e,dir:`asc`})},ue=()=>{Y&&j(`${Y.table}-page${r+1}.csv`,`text/csv`,A(Y.columns,Y.rows))},de=async()=>{if(!(!U||X)){Z(!0),$(null);try{let e=[],t=[],n=0,r=!1;for(;;){let i=await h.db.rows(U,T,n,o?.col,o?.dir,D??void 0);if(t=i.columns,e.push(...i.rows),n+=T,e.length>=E){r=!0;break}if(i.rows.length<T||n>=i.total)break}j(`${U}.csv`,`text/csv`,A(t,e));let i=r?`Exported the first ${d(e.length)} rows (export cap reached)`:`Exported ${d(e.length)} rows`;$(i),_.success(`Export of ${U} complete`,i)}catch(e){$(`Export failed: ${e.message}`),_.error(`Export of ${U} failed`,e.message)}finally{Z(!1)}}},fe=()=>{P(`SELECT * FROM "${U.replaceAll(`"`,`""`)}" LIMIT 100`),requestAnimationFrame(()=>{F.current?.focus(),F.current?.scrollIntoView({behavior:`smooth`,block:`center`})})},pe=!!Y?.truncatedCells.some(e=>e.some(Boolean));return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(p,{title:`Database`,description:`SQLite inspector — schema, data and queries over a read-only connection.`,actions:(0,C.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2.5 py-1 text-[11px] font-medium text-success`,children:`read-only`})}),R&&!V&&(0,C.jsx)(ee,{message:`Could not read the database — ${R.message}`,onRetry:ae}),H&&(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-5`,children:[(0,C.jsx)(m,{label:`SQLite`,value:H.sqliteVersion,compact:!0}),(0,C.jsx)(m,{label:`On disk`,value:g(H.fileSize+H.walSize),compact:!0}),(0,C.jsx)(m,{label:`Journal`,value:H.journalMode.toUpperCase(),compact:!0}),(0,C.jsx)(m,{label:`Tables`,value:d(H.tables),compact:!0}),(0,C.jsx)(m,{label:`Indexes`,value:d(H.indexes),compact:!0})]}),V?(0,C.jsx)(v,{title:`No database yet`,hint:R.message}):ie&&B.length===0?(0,C.jsx)(u,{label:`Reading database…`}):(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-4`,children:[(0,C.jsxs)(l,{padded:!1,className:`self-start overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-4 py-3 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Tables (`,B.length,`)`]}),(0,C.jsxs)(`ul`,{className:`max-h-[28rem] overflow-y-auto`,children:[B.map(e=>(0,C.jsx)(`li`,{children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>ce(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`,U===e.name?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:[(0,C.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.name}),(0,C.jsx)(`span`,{className:`shrink-0 text-[11px] text-faint tabular-nums`,children:d(e.rows)})]})},e.name)),B.length===0&&(0,C.jsx)(`li`,{className:`px-4 py-6 text-center text-xs text-faint`,children:`No tables.`})]})]}),(0,C.jsx)(`div`,{className:`min-w-0 lg:col-span-3`,children:B.length===0?(0,C.jsx)(v,{title:`No tables`,hint:`This database has no user tables yet.`}):(0,C.jsxs)(C.Fragment,{children:[U&&(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`mr-auto min-w-0 truncate font-mono text-sm text-fg`,title:U,children:U}),(0,C.jsx)(y,{size:`sm`,variant:`ghost`,onClick:fe,children:`Query`}),(0,C.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:[`data`,`schema`].map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>b(e),"aria-pressed":c===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`,c===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:e},e))}),c===`data`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y,{size:`sm`,disabled:!Y||Y.rows.length===0,title:Y?`Exports the ${Y.rows.length} rows on this page only`:void 0,onClick:ue,children:[`Export page`,Y?` (${Y.rows.length})`:``]}),(0,C.jsx)(y,{size:`sm`,variant:`accent`,disabled:X||!Y||Y.total===0,onClick:de,children:X?`Exporting…`:`Export table${Y?` (${d(Y.total)})`:``}`})]})]}),c===`data`&&U&&(0,C.jsx)(z,{columns:Y?.columns??W?.columns.map(e=>e.name)??[],filter:D,onChange:e=>{O(e),a(0),M(null)}}),Q&&(0,C.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:Q}),c===`schema`?W?.table===U?(0,C.jsx)(ne,{schema:W}):(0,C.jsx)(u,{label:`Reading schema of ${U}…`}):q&&!Y?(0,C.jsx)(v,{title:`Could not read table`,hint:q.message}):J&&!Y&&K?.table!==U?(0,C.jsx)(u,{label:`Reading ${U}…`}):!Y&&!K?(0,C.jsx)(v,{title:`Select a table`,hint:`Pick a table on the left to browse its rows.`}):(Y??K)&&(Y??K)?.total===0?(0,C.jsx)(v,{title:D?`No matching rows`:`Empty table`,hint:D?`No rows match the current filter.`:`"${(Y??K)?.table}" has no rows.`}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(L,{columns:(Y??K)?.columns??[],rows:(Y??K)?.rows??[],truncatedCells:(Y??K)?.truncatedCells,colMeta:oe,sort:o,onSort:le,onRowClick:e=>M(e),dimmed:J&&!Y}),pe&&(0,C.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Cells over 2000 chars and BLOBs are abbreviated in the grid and CSV — click a row to view the full value.`}),(0,C.jsx)(x,{page:r,pageSize:w,total:(Y??K)?.total??0,onPageChange:e=>{a(e),M(null)},label:`rows`})]}),(0,C.jsx)(re,{sql:N,setSql:P,editorRef:F})]})})]}),Y&&k!=null&&Y.rows[k]&&(0,C.jsx)(te,{table:Y.table,columns:Y.columns,row:Y.rows[k],rowid:Y.rowids[k],truncated:Y.truncatedCells[k],onClose:()=>M(null)})]})}function z({columns:e,filter:t,onChange:n}){let[r,i]=(0,S.useState)(t?.column??``),[a,o]=(0,S.useState)(t?.op??`contains`),[c,l]=(0,S.useState)(t?.value??``),u=r||e[0]||``,d=()=>n(c.trim()?{column:u,op:a,value:c.trim()}:null);return e.length===0?null:(0,C.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`div`,{className:`w-40`,children:(0,C.jsx)(b,{value:u,"aria-label":`Filter column`,onChange:e=>i(e.target.value),children:e.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))})}),(0,C.jsx)(`div`,{className:`w-32`,children:(0,C.jsxs)(b,{value:a,"aria-label":`Filter operator`,onChange:e=>o(e.target.value),children:[(0,C.jsx)(`option`,{value:`contains`,children:`contains`}),(0,C.jsx)(`option`,{value:`eq`,children:`=`}),(0,C.jsx)(`option`,{value:`ne`,children:`≠`})]})}),(0,C.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,C.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,C.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&d(),"aria-label":`Filter value`,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,C.jsx)(y,{size:`sm`,onClick:d,disabled:!c.trim(),children:`Filter`}),t&&(0,C.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>{l(``),n(null)},children:`Clear`}),(0,C.jsx)(`span`,{className:`text-[11px] text-faint`,children:`filters the whole table, server-side`})]})}function te({table:e,columns:t,row:n,rowid:r,truncated:i,onClose:a}){let[s,l]=(0,S.useState)({}),u=(0,S.useRef)(null);return(0,S.useEffect)(()=>{let e=e=>e.key===`Escape`&&a();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,S.useEffect)(()=>{let e=document.activeElement;return u.current?.focus(),()=>{e?.isConnected&&e.focus()}},[]),(0,S.useEffect)(()=>{if(r==null)return;let n=!1;return(async()=>{for(let a=0;a<t.length;a++)if(i[a])try{let i=await h.db.cell(e,r,t[a]);n||l(e=>({...e,[t[a]]:i.value}))}catch{}})(),()=>{n=!0}},[e,r,t,i]),(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`button`,{type:`button`,"aria-label":`Close row detail`,onClick:a,className:`fixed inset-0 z-40 bg-black/50`}),(0,C.jsxs)(`aside`,{ref:u,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-none`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-5 py-4`,children:[(0,C.jsxs)(`h2`,{className:`font-mono text-sm text-fg`,children:[e,` · row detail`]}),(0,C.jsx)(`button`,{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,C.jsx)(o,{className:`size-4`})})]}),(0,C.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:(0,C.jsx)(`dl`,{className:`flex flex-col gap-4`,children:t.map((e,t)=>{let r=e in s?s[e]:n[t],a=F(r),o=a.includes(`
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-BcouBxpZ.js";import{A as i,C as a,I as o,J as s,O as c,S as l,b as u,c as d,et as f,h as p,m,nt as h,r as g,rt as _,v,w as y,x as ee}from"./index-BOcegTHa.js";import{a as b}from"./form-DGinTEEb.js";import{t as x}from"./Pagination-D4ki-pGz.js";var S=e(n(),1),C=r(),w=50,T=500,E=2e5,D=`bq-dash-db-history`,O=10;function k(e){let t=e==null?``:String(e),n=typeof e==`string`&&/^[=+\-@]/.test(e)?`'${e}`:t;return/[",\r\n]/.test(n)?`"${n.replaceAll(`"`,`""`)}"`:n}function A(e,t){return[e.map(k).join(`,`),...t.map(e=>e.map(k).join(`,`))].join(`
|
|
2
|
+
`)}function j(e,t,n){let r=URL.createObjectURL(new Blob([n],{type:t})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)}function M(){try{let e=JSON.parse(localStorage.getItem(D)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function N(e){try{localStorage.setItem(D,JSON.stringify(e))}catch{}return e}function P(e){return N([e,...M().filter(t=>t!==e)].slice(0,O))}function F(e){if(e==null)return`NULL`;let t=typeof e==`string`?e:String(e);try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function I({value:e,align:n}){if(e==null)return(0,C.jsx)(`span`,{className:`italic text-faint`,children:`NULL`});let r=typeof e==`string`?e:String(e);return(0,C.jsx)(`span`,{className:t(`block max-w-[24rem] truncate`,n===`right`&&`text-right tabular-nums`),title:r,children:r})}function L({columns:e,rows:n,truncatedCells:r,colMeta:i,sort:a,onSort:o,onRowClick:s,dimmed:c}){let l=(0,S.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,C.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,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsx)(`tr`,{className:`text-left text-[11px] uppercase tracking-wider text-faint`,children:e.map((e,n)=>{let r=i?.[e];return(0,C.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,C.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,C.jsx)(`span`,{className:`rounded bg-accent/15 px-1 py-0.5 text-[9px] font-semibold text-accent`,children:`PK`}),r?.type&&(0,C.jsx)(`span`,{className:`text-faint/70`,children:r.type.toLowerCase()}),(0,C.jsx)(`span`,{"aria-hidden":`true`,className:a?.col===e?`text-accent`:`text-faint/60`,children:a?.col===e?a.dir===`asc`?`▲`:`▼`:`↕`})]}):e},e)})})}),(0,C.jsx)(`tbody`,{children:n.map((e,n)=>(0,C.jsx)(`tr`,{onClick:s?()=>s(n):void 0,onKeyDown:s?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(n))}:void 0,tabIndex:s?0:void 0,className:t(`border-b border-line font-mono text-xs last:border-0 hover:bg-surface-2/40`,s&&`cursor-pointer`),children:e.map((e,t)=>(0,C.jsx)(`td`,{className:`whitespace-nowrap px-4 py-2 text-muted`,children:(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsx)(I,{value:e,align:l[t]?`right`:`left`}),r?.[n]?.[t]&&(0,C.jsx)(`span`,{title:`Value truncated — click the row to view it in full`,className:`shrink-0 rounded bg-warning/15 px-1 text-[9px] font-semibold text-warning`,children:`…`})]})},t))},n))})]})})}function R(){let[e,n]=(0,S.useState)(``),[r,a]=(0,S.useState)(0),[o,s]=(0,S.useState)(null),[c,b]=(0,S.useState)(`data`),[D,O]=(0,S.useState)(null),[k,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(`SELECT name FROM sqlite_master WHERE type = 'table'`),F=(0,S.useRef)(null),{data:I,error:R,loading:ie,refetch:ae}=i(()=>h.db.tables(),[],{intervalMs:1e4}),B=(0,S.useMemo)(()=>I?.tables??[],[I]),V=R instanceof f&&R.status===404,{data:H}=i(()=>V?Promise.resolve(null):h.db.info(),[V],{intervalMs:15e3}),U=e||B[0]?.name||``;(0,S.useEffect)(()=>{!e&&B[0]&&n(B[0].name)},[e,B]);let{data:W}=i(()=>U?h.db.schema(U):Promise.resolve(null),[U],{intervalMs:3e4}),oe=(0,S.useMemo)(()=>{let e={};if(W?.table===U)for(let t of W.columns)e[t.name]={type:t.type,primaryKey:t.primaryKey};return e},[W,U]),G=D?`${D.column}|${D.op}|${D.value}`:``,{data:K,error:q,loading:J}=i((0,S.useCallback)(async()=>U?{...await h.db.rows(U,w,r*w,o?.col,o?.dir,D??void 0),page:r,filterKey:G}:null,[U,r,o,D,G]),[U,r,o,G],{intervalMs:6e3}),Y=K&&K.table===U&&K.page===r&&K.orderBy===(o?.col??null)&&(!o||K.dir===o.dir)&&K.filterKey===G?K:null;(0,S.useEffect)(()=>{Y&&Y.total>0&&Y.rows.length===0&&r>0&&a(Math.max(0,Math.ceil(Y.total/w)-1))},[Y,r]);let[X,Z]=(0,S.useState)(!1),[Q,$]=(0,S.useState)(null),se=()=>{a(0),s(null),O(null),M(null)},ce=e=>{n(e),b(`data`),se()},le=e=>{a(0),M(null),s(t=>t?.col===e?t.dir===`asc`?{col:e,dir:`desc`}:null:{col:e,dir:`asc`})},ue=()=>{Y&&j(`${Y.table}-page${r+1}.csv`,`text/csv`,A(Y.columns,Y.rows))},de=async()=>{if(!(!U||X)){Z(!0),$(null);try{let e=[],t=[],n=0,r=!1;for(;;){let i=await h.db.rows(U,T,n,o?.col,o?.dir,D??void 0);if(t=i.columns,e.push(...i.rows),n+=T,e.length>=E){r=!0;break}if(i.rows.length<T||n>=i.total)break}j(`${U}.csv`,`text/csv`,A(t,e));let i=r?`Exported the first ${d(e.length)} rows (export cap reached)`:`Exported ${d(e.length)} rows`;$(i),_.success(`Export of ${U} complete`,i)}catch(e){$(`Export failed: ${e.message}`),_.error(`Export of ${U} failed`,e.message)}finally{Z(!1)}}},fe=()=>{let e=`SELECT * FROM "${U.replaceAll(`"`,`""`)}" LIMIT 100`;P(e),requestAnimationFrame(()=>{F.current?.focus(),F.current?.scrollIntoView({behavior:`smooth`,block:`center`})})},pe=!!Y?.truncatedCells.some(e=>e.some(Boolean));return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(p,{title:`Database`,description:`SQLite inspector — schema, data and queries over a read-only connection.`,actions:(0,C.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2.5 py-1 text-[11px] font-medium text-success`,children:`read-only`})}),R&&!V&&(0,C.jsx)(ee,{message:`Could not read the database — ${R.message}`,onRetry:ae}),H&&(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-5`,children:[(0,C.jsx)(m,{label:`SQLite`,value:H.sqliteVersion,compact:!0}),(0,C.jsx)(m,{label:`On disk`,value:g(H.fileSize+H.walSize),compact:!0}),(0,C.jsx)(m,{label:`Journal`,value:H.journalMode.toUpperCase(),compact:!0}),(0,C.jsx)(m,{label:`Tables`,value:d(H.tables),compact:!0}),(0,C.jsx)(m,{label:`Indexes`,value:d(H.indexes),compact:!0})]}),V?(0,C.jsx)(v,{title:`No database yet`,hint:R.message}):ie&&B.length===0?(0,C.jsx)(u,{label:`Reading database…`}):(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-4`,children:[(0,C.jsxs)(l,{padded:!1,className:`self-start overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-4 py-3 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Tables (`,B.length,`)`]}),(0,C.jsxs)(`ul`,{className:`max-h-[28rem] overflow-y-auto`,children:[B.map(e=>(0,C.jsx)(`li`,{children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>ce(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`,U===e.name?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:[(0,C.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.name}),(0,C.jsx)(`span`,{className:`shrink-0 text-[11px] text-faint tabular-nums`,children:d(e.rows)})]})},e.name)),B.length===0&&(0,C.jsx)(`li`,{className:`px-4 py-6 text-center text-xs text-faint`,children:`No tables.`})]})]}),(0,C.jsx)(`div`,{className:`min-w-0 lg:col-span-3`,children:B.length===0?(0,C.jsx)(v,{title:`No tables`,hint:`This database has no user tables yet.`}):(0,C.jsxs)(C.Fragment,{children:[U&&(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`mr-auto min-w-0 truncate font-mono text-sm text-fg`,title:U,children:U}),(0,C.jsx)(y,{size:`sm`,variant:`ghost`,onClick:fe,children:`Query`}),(0,C.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:[`data`,`schema`].map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>b(e),"aria-pressed":c===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`,c===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:e},e))}),c===`data`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y,{size:`sm`,disabled:!Y||Y.rows.length===0,title:Y?`Exports the ${Y.rows.length} rows on this page only`:void 0,onClick:ue,children:[`Export page`,Y?` (${Y.rows.length})`:``]}),(0,C.jsx)(y,{size:`sm`,variant:`accent`,disabled:X||!Y||Y.total===0,onClick:de,children:X?`Exporting…`:`Export table${Y?` (${d(Y.total)})`:``}`})]})]}),c===`data`&&U&&(0,C.jsx)(z,{columns:Y?.columns??W?.columns.map(e=>e.name)??[],filter:D,onChange:e=>{O(e),a(0),M(null)}},U),Q&&(0,C.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:Q}),c===`schema`?W?.table===U?(0,C.jsx)(ne,{schema:W}):(0,C.jsx)(u,{label:`Reading schema of ${U}…`}):q&&!Y?(0,C.jsx)(v,{title:`Could not read table`,hint:q.message}):J&&!Y&&K?.table!==U?(0,C.jsx)(u,{label:`Reading ${U}…`}):!Y&&!K?(0,C.jsx)(v,{title:`Select a table`,hint:`Pick a table on the left to browse its rows.`}):(Y??K)&&(Y??K)?.total===0?(0,C.jsx)(v,{title:D?`No matching rows`:`Empty table`,hint:D?`No rows match the current filter.`:`"${(Y??K)?.table}" has no rows.`}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(L,{columns:(Y??K)?.columns??[],rows:(Y??K)?.rows??[],truncatedCells:(Y??K)?.truncatedCells,colMeta:oe,sort:o,onSort:le,onRowClick:e=>M(e),dimmed:J&&!Y}),pe&&(0,C.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Cells over 2000 chars and BLOBs are abbreviated in the grid and CSV — click a row to view the full value.`}),(0,C.jsx)(x,{page:r,pageSize:w,total:(Y??K)?.total??0,onPageChange:e=>{a(e),M(null)},label:`rows`})]}),(0,C.jsx)(re,{sql:N,setSql:P,editorRef:F})]})})]}),Y&&k!=null&&Y.rows[k]&&(0,C.jsx)(te,{table:Y.table,columns:Y.columns,row:Y.rows[k],rowid:Y.rowids[k],truncated:Y.truncatedCells[k],onClose:()=>M(null)})]})}function z({columns:e,filter:t,onChange:n}){let[r,i]=(0,S.useState)(t?.column??``),[a,o]=(0,S.useState)(t?.op??`contains`),[c,l]=(0,S.useState)(t?.value??``),u=r||e[0]||``,d=()=>n(c.trim()?{column:u,op:a,value:c.trim()}:null);return e.length===0?null:(0,C.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`div`,{className:`w-40`,children:(0,C.jsx)(b,{value:u,"aria-label":`Filter column`,onChange:e=>i(e.target.value),children:e.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))})}),(0,C.jsx)(`div`,{className:`w-32`,children:(0,C.jsxs)(b,{value:a,"aria-label":`Filter operator`,onChange:e=>o(e.target.value),children:[(0,C.jsx)(`option`,{value:`contains`,children:`contains`}),(0,C.jsx)(`option`,{value:`eq`,children:`=`}),(0,C.jsx)(`option`,{value:`ne`,children:`≠`})]})}),(0,C.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,C.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,C.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&d(),"aria-label":`Filter value`,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,C.jsx)(y,{size:`sm`,onClick:d,disabled:!c.trim(),children:`Filter`}),t&&(0,C.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>{l(``),n(null)},children:`Clear`}),(0,C.jsx)(`span`,{className:`text-[11px] text-faint`,children:`filters the whole table, server-side`})]})}function te({table:e,columns:t,row:n,rowid:r,truncated:i,onClose:a}){let[s,l]=(0,S.useState)({}),u=(0,S.useRef)(null);(0,S.useEffect)(()=>{let e=e=>e.key===`Escape`&&a();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,S.useEffect)(()=>{let e=document.activeElement;return u.current?.focus(),()=>{e?.isConnected&&e.focus()}},[]);let d=t.filter((e,t)=>i[t]).join(``);return(0,S.useEffect)(()=>{if(r==null||!d)return;let t=d.split(``),n=!1;return(async()=>{for(let i of t)try{let t=await h.db.cell(e,r,i);n||l(e=>({...e,[i]:t.value}))}catch{}})(),()=>{n=!0}},[e,r,d]),(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`button`,{type:`button`,"aria-label":`Close row detail`,onClick:a,className:`fixed inset-0 z-40 bg-black/50`}),(0,C.jsxs)(`aside`,{ref:u,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-none`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-5 py-4`,children:[(0,C.jsxs)(`h2`,{className:`font-mono text-sm text-fg`,children:[e,` · row detail`]}),(0,C.jsx)(`button`,{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,C.jsx)(o,{className:`size-4`})})]}),(0,C.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:(0,C.jsx)(`dl`,{className:`flex flex-col gap-4`,children:t.map((e,t)=>{let r=e in s?s[e]:n[t],a=F(r),o=a.includes(`
|
|
3
3
|
`)||a.length>80;return(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`dt`,{className:`mb-1 flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-faint`,children:[e,r!=null&&(0,C.jsx)(c,{value:String(r)}),i[t]&&!(e in s)&&(0,C.jsx)(`span`,{className:`text-warning`,children:`(loading full value…)`})]}),(0,C.jsx)(`dd`,{children:r==null?(0,C.jsx)(`span`,{className:`italic text-faint`,children:`NULL`}):o?(0,C.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:a}):(0,C.jsx)(`span`,{className:`break-words font-mono text-sm text-fg`,children:a})})]},e)})})})]})]})}function ne({schema:e}){return(0,C.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,C.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Column`}),(0,C.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Type`}),(0,C.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Constraints`}),(0,C.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Default`})]})}),(0,C.jsx)(`tbody`,{children:e.columns.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-fg`,children:e.name}),(0,C.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-muted`,children:e.type}),(0,C.jsxs)(`td`,{className:`px-4 py-2 text-xs`,children:[e.primaryKey&&(0,C.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,C.jsx)(`span`,{className:`rounded-md bg-surface-2 px-1.5 py-0.5 text-[10px] font-semibold text-muted`,children:`NOT NULL`})]}),(0,C.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-faint`,children:e.defaultValue??`—`})]},e.name))})]})}),(0,C.jsxs)(l,{children:[(0,C.jsx)(a,{title:`Indexes (${e.indexes.length})`}),e.indexes.length===0?(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`No indexes on this table.`}):(0,C.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.indexes.map(e=>(0,C.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 font-mono text-xs`,children:[(0,C.jsx)(`span`,{className:`text-fg`,children:e.name}),e.unique&&(0,C.jsx)(`span`,{className:`rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold text-accent`,children:`UNIQUE`}),(0,C.jsxs)(`span`,{className:`text-faint`,children:[`(`,e.columns.join(`, `),`)`]})]},e.name))})]}),e.sql&&(0,C.jsxs)(l,{children:[(0,C.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`DDL`}),(0,C.jsx)(c,{value:e.sql})]}),(0,C.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:e.sql})]})]})}function re({sql:e,setSql:t,editorRef:n}){let[r,i]=(0,S.useState)(!1),[o,s]=(0,S.useState)(null),[c,u]=(0,S.useState)(M),[f,p]=(0,S.useState)(null),m=(0,S.useRef)(0);(0,S.useEffect)(()=>()=>{m.current++},[]);let g=async(t=e,n=!0)=>{if(!t.trim()||r)return;let a=++m.current;i(!0),s(null);try{let r=await h.db.query(t);if(a!==m.current)return;p(r),n&&u(P(e.trim()))}catch(e){if(a!==m.current)return;p(null),s(e.message)}finally{a===m.current&&i(!1)}};return(0,C.jsxs)(l,{className:`mt-6`,children:[(0,C.jsx)(a,{title:`Query`,action:(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(y,{size:`sm`,disabled:r||!e.trim(),onClick:()=>{let t=e.trim();t&&g(`EXPLAIN QUERY PLAN ${t}`,!1)},children:`Explain`}),(0,C.jsx)(y,{size:`sm`,variant:`accent`,disabled:r||!e.trim(),onClick:()=>g(),children:r?`Running…`:`Run`})]})}),(0,C.jsx)(`textarea`,{ref:n,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&g()},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,C.jsx)(`p`,{className:`mt-1 text-[11px] text-faint`,children:`⌘/Ctrl+Enter runs. Connection is read-only.`}),c.length>0&&(0,C.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`History`}),c.map(e=>(0,C.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,C.jsx)(`button`,{type:`button`,onClick:()=>{N([]),u([])},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,C.jsxs)(`div`,{"aria-live":`polite`,children:[o&&(0,C.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:o}),f&&!o&&(0,C.jsxs)(`div`,{className:`mt-4`,children:[(0,C.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-3`,children:[(0,C.jsxs)(`p`,{className:`text-xs text-faint`,children:[f.truncated?`≥ `:``,d(f.rowCount),` row`,f.rowCount===1?``:`s`,` ·`,` `,d(f.ms),` ms`,f.truncated&&(0,C.jsxs)(`span`,{className:`text-warning`,children:[` — showing first `,f.rows.length]})]}),f.rows.length>0&&(0,C.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,C.jsx)(y,{size:`sm`,onClick:()=>j(`query-results.csv`,`text/csv`,A(f.columns,f.rows)),children:`CSV`}),(0,C.jsx)(y,{size:`sm`,onClick:()=>j(`query-results.json`,`application/json`,JSON.stringify(f.rows.map(e=>Object.fromEntries(f.columns.map((t,n)=>[t,e[n]]))),null,2)),children:`JSON`})]})]}),f.rows.length>0?(0,C.jsx)(L,{columns:f.columns,rows:f.rows}):(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Query returned no rows.`})]})]})]})}export{R as Database};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{A as r,C as i,O as a,S as o,b as s,c,d as l,h as u,m as d,nt as f,r as p,rt as m,w as h,x as g}from"./index-BOcegTHa.js";var _=e(t(),1),v=n(),y={health:{},storage:null,stats:null};function b(){let{data:e,error:t,loading:n,refetch:b}=r(async()=>{let[e,t,n]=await Promise.all([f.health(),f.storage().catch(()=>null),f.stats().catch(()=>null)]);return{health:e,storage:t,stats:n}},[]),[C,w]=(0,_.useState)(null),T=async()=>{w(`…`);let e=performance.now();try{await f.ping(),w(`${Math.round(performance.now()-e)} ms`)}catch{w(`unreachable`)}},[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(null),A=async()=>{D(!0),k(null);try{let e=await f.gc(),t=e.before.rss-e.after.rss,n=t>0?`Freed ${t} MB (RSS ${e.before.rss}→${e.after.rss})`:`No memory reclaimed`;k(n),m.success(`Memory compacted`,n),b()}catch(e){m.error(`GC failed`,e.message),k(e.message)}finally{D(!1)}},[j,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(!1),F=async()=>{P(!0);try{M(await f.heapStats())}catch(e){m.error(`Heap stats failed`,e.message)}finally{P(!1)}};if(n&&!e&&!t)return(0,v.jsx)(s,{label:`Loading diagnostics…`});let I=e??y,L=I.health,R=I.storage?.data,z=I.stats?.stats;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(u,{title:`Diagnostics`,description:`Server health, storage, memory and connections.`,live:!t}),t&&(0,v.jsx)(g,{onRetry:b}),(0,v.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,v.jsx)(d,{label:`Status`,value:L.status??(L.ok?`healthy`:`degraded`),tone:L.ok?`green`:`red`,compact:!0}),(0,v.jsx)(d,{label:`Version`,value:L.version?`v${L.version}`:`—`,compact:!0}),(0,v.jsx)(d,{label:`Uptime`,value:l(L.uptime),compact:!0}),(0,v.jsx)(d,{label:`Disk`,value:R?.diskFull?`Full`:`Healthy`,tone:R?.diskFull?`red`:`green`,compact:!0})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,v.jsxs)(o,{children:[(0,v.jsx)(i,{title:`Connectivity`,action:(0,v.jsxs)(h,{size:`sm`,onClick:T,children:[`Ping`,C?` · ${C}`:``]})}),(0,v.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,v.jsx)(x,{k:`WebSocket clients`,v:String(L.connections?.ws??0)}),(0,v.jsx)(x,{k:`SSE clients`,v:String(L.connections?.sse??0)}),(0,v.jsx)(x,{k:`Storage error`,v:R?.error?String(R.error):`none`})]})]}),(0,v.jsxs)(o,{children:[(0,v.jsx)(i,{title:`Memory`,action:(0,v.jsx)(h,{size:`sm`,disabled:E,onClick:A,children:E?`Compacting…`:`Compact (GC)`})}),(0,v.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,v.jsx)(S,{k:`Heap used`,v:p((L.memory?.heapUsed??0)*1024*1024)}),(0,v.jsx)(S,{k:`Heap total`,v:p((L.memory?.heapTotal??0)*1024*1024)}),(0,v.jsx)(S,{k:`RSS`,v:p((L.memory?.rss??0)*1024*1024)})]}),O&&(0,v.jsx)(`p`,{className:`mt-3 text-xs text-muted`,children:O})]})]}),(0,v.jsxs)(o,{className:`mt-6`,children:[(0,v.jsx)(i,{title:`Heap statistics`,action:(0,v.jsx)(h,{size:`sm`,disabled:N,onClick:F,children:N?`Loading…`:j?`Refresh`:`Load`})}),j?(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,v.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,v.jsx)(S,{k:`Objects`,v:c(j.heap?.objectCount??0)}),(0,v.jsx)(S,{k:`Protected`,v:c(j.heap?.protectedCount??0)}),(0,v.jsx)(S,{k:`Global`,v:c(j.heap?.globalCount??0)})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wider text-faint`,children:`Top object types`}),(0,v.jsx)(`div`,{className:`max-h-52 overflow-y-auto rounded-lg border border-line`,children:(0,v.jsx)(`table`,{className:`w-full text-xs`,children:(0,v.jsx)(`tbody`,{children:(j.topObjectTypes??[]).map(e=>(0,v.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,v.jsx)(`td`,{className:`px-3 py-1.5 font-mono text-muted`,children:e.type}),(0,v.jsx)(`td`,{className:`px-3 py-1.5 text-right tnum text-fg`,children:c(e.count)})]},e.type))})})})]})]}):(0,v.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On-demand `,(0,v.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.`]})]}),(0,v.jsxs)(o,{className:`mt-6`,children:[(0,v.jsx)(i,{title:`Prometheus`}),(0,v.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,v.jsx)(`code`,{className:`font-mono text-xs`,children:`requireAuthForMetrics`}),`.`]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-line bg-surface-2 px-3 py-2`,children:[(0,v.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-fg`,children:f.prometheusUrl()}),(0,v.jsx)(a,{value:f.prometheusUrl()})]})]}),z&&(0,v.jsxs)(o,{className:`mt-6`,children:[(0,v.jsx)(i,{title:`Totals since restart`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,v.jsx)(S,{k:`Pushed`,v:c(z.totalPushed)}),(0,v.jsx)(S,{k:`Pulled`,v:c(z.totalPulled)}),(0,v.jsx)(S,{k:`Completed`,v:c(z.totalCompleted)}),(0,v.jsx)(S,{k:`Failed`,v:c(z.totalFailed)})]})]})]})}function x({k:e,v:t}){return(0,v.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,v.jsx)(`dt`,{className:`text-muted`,children:e}),(0,v.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}function S({k:e,v:t}){return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,v.jsx)(`div`,{className:`mt-1 text-lg font-semibold tnum text-fg`,children:t})]})}export{b as Diagnostics};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{A as r,R as i,b as a,c as o,h as s,j as c,m as l,u,v as d,w as f,x as p}from"./index-BOcegTHa.js";import{a as m}from"./form-DGinTEEb.js";import{t as h}from"./Pagination-D4ki-pGz.js";var g=e(t(),1),_=n(),v=25;function y(){let[e,t]=(0,g.useState)(``),[n,y]=(0,g.useState)(0),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(null),{data:w}=r(()=>c.queues(500),[],{intervalMs:3e4});(0,g.useEffect)(()=>{if(e||!w?.queues?.length)return;let n=w.queues.find(e=>e.dlq>0)??w.queues[0];t(n.name)},[w,e]);let{data:T,error:E,loading:D,refetch:O}=r((0,g.useCallback)(async()=>{if(!e)return{entries:[],total:0};let t=await c.dlq(e,v,n*v);return{entries:t.entries??[],total:t.total??t.entries?.length??0}},[e,n]),[e,n]),k=async(t,n)=>{if(window.confirm(`${t} the dead letter queue for "${e}"?`)){x(!0),C(null);try{await n(),C(`${t} done`),O()}catch(e){C(e.message)}finally{x(!1)}}},A=T?.entries??[];return(0,_.jsxs)(`div`,{children:[E&&(0,_.jsx)(p,{onRetry:O}),(0,_.jsx)(s,{title:`Dead Letter Queue`,description:`Jobs that exhausted their retries.`,live:!0,actions:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(f,{size:`sm`,disabled:!e||b,onClick:()=>k(`Retry`,()=>c.retryDlq(e)),children:`Retry all`}),(0,_.jsx)(f,{variant:`danger`,size:`sm`,disabled:!e||b,onClick:()=>k(`Purge`,()=>c.purgeDlq(e)),children:`Purge`})]})}),(0,_.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`w-56`,children:(0,_.jsx)(m,{value:e,onChange:e=>{t(e.target.value),y(0)},children:(w?.queues??[]).map(e=>(0,_.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,_.jsx)(`div`,{className:`w-40`,children:(0,_.jsx)(l,{label:`DLQ Entries`,value:o(T?.total),tone:T?.total?`red`:`default`,compact:!0})}),S&&(0,_.jsx)(`span`,{className:`text-xs text-muted`,children:S})]}),D&&!T&&!E?(0,_.jsx)(a,{label:`Loading DLQ…`}):A.length===0?(0,_.jsx)(d,{icon:(0,_.jsx)(i,{}),title:`Dead letter queue is empty`,hint:`Jobs land here after exhausting their retry attempts.`}):(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,_.jsx)(`tbody`,{children:A.map((e,t)=>(0,_.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.job.id}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.job.data?.name||`unnamed`}),(0,_.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-red-400/90`,children:String(e.reason||e.error||`—`)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.attempts?.length??e.job.attempts??`—`}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.attempts?.at(-1)?.failedAt??e.enteredAt)})]},e.job.id||t))})]})}),T&&(0,_.jsx)(h,{page:n,pageSize:v,total:T.total,onPageChange:y,label:`entries`})]})}export{y as Dlq};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,r,t as i}from"./react-vendor-BcouBxpZ.js";import{A as a,B as o,F as s,J as c,K as l,O as u,R as d,T as f,a as p,b as m,c as h,h as g,m as _,nt as v,o as y,rt as b,u as x,v as S,w as C,x as w,z as T}from"./index-BOcegTHa.js";import{a as E}from"./form-DGinTEEb.js";import{t as D}from"./Pagination-D4ki-pGz.js";import{t as O}from"./exportFile-tdUeW5m5.js";var k=e(n(),1),A=i(),j=25,M=e=>`${e.job.id}-${e.enteredAt}`;function N(){let[e,t]=(0,k.useState)(``),[n,r]=(0,k.useState)(0),[i,o]=(0,k.useState)(`all`),[s,u]=(0,k.useState)(``),[f,p]=(0,k.useState)(new Set),[y,N]=(0,k.useState)(!1),[F,I]=(0,k.useState)(null),{data:L}=a(()=>v.queues(),[],{intervalMs:3e4});(0,k.useEffect)(()=>{e||!L?.queues?.length||t((L.queues.find(e=>e.dlq>0)??L.queues[0]).name)},[L,e]);let{data:R,error:z,loading:B,refetch:V}=a((0,k.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0,stats:null};let[t,r]=await Promise.all([v.dlq(e,j,n*j),v.dlqStats(e).catch(()=>null)]);return{queue:e,page:n,entries:t.entries??[],total:t.total??0,stats:r?.stats??null}},[e,n]),[e,n]),H=R&&R.queue===e&&R.page===n?R:null;(0,k.useEffect)(()=>{if(!H)return;let e=Math.max(0,Math.ceil((H.total??0)/j)-1);n>e&&r(e)},[H,n]),(0,k.useEffect)(()=>{p(new Set)},[e,n]);let U=async(t,n,r)=>{if(!(r&&!window.confirm(r))){N(!0),I(null);try{let r=(await n())?.count??0,i=`${t} ${h(r)} ${r===1?`entry`:`entries`}`;I({ok:!0,text:i}),b.success(i,e),V()}catch(e){let n=e.message;I({ok:!1,text:n});let r=t===`Purged`?`Purge`:`Retry`;b.error(`${r} failed`,n)}finally{N(!1)}}},W=H?.stats?.byReason??{},G=(0,k.useMemo)(()=>Object.keys(W).filter(e=>W[e]>0),[W]),K=(0,k.useMemo)(()=>[...G].sort((e,t)=>(W[t]??0)-(W[e]??0))[0],[G,W]),q=H?.entries??[],J=(0,k.useMemo)(()=>{let e=q;i!==`all`&&(e=e.filter(e=>e.reason===i));let t=s.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[q,i,s]),Y=i!==`all`||s.trim()!==``,X=(H?.total??0)>j,Z=e=>p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(g,{title:`DLQ Control`,description:`Inspect, triage, and replay one queue's dead-lettered jobs.`,live:!0,actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(C,{size:`sm`,disabled:!e||!J.length,onClick:()=>{if(J.length===0){b.info(`Nothing to export`);return}O(`dlq-${e}`,J.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,A.jsx)(T,{className:`size-3.5`}),` Export`]}),(0,A.jsxs)(C,{size:`sm`,disabled:!e||y||!H?.total,onClick:()=>U(`Retried`,()=>v.retryDlq(e),`Retry all ${H?.total??0} DLQ entries for "${e}"?`),children:[(0,A.jsx)(l,{className:`size-3.5`}),` Retry all`]}),(0,A.jsx)(C,{variant:`danger`,size:`sm`,disabled:!e||y||!H?.total,onClick:()=>{let t=window.prompt(`Purge all ${H?.total??0} DLQ entries for "${e}"? This cannot be undone.\n\nType the queue name to confirm:`);if(t!=null){if(t.trim()!==e){I({ok:!1,text:`Purge cancelled — queue name did not match.`});return}U(`Purged`,()=>v.purgeDlq(e))}},children:`Purge`})]})}),z&&(0,A.jsx)(w,{onRetry:V}),(0,A.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,A.jsx)(_,{label:`Entries`,value:h(H?.total),tone:H?.total?`red`:`green`,hint:H?.total?K?`top: ${K}`:void 0:`queue is clean`,compact:!0}),(0,A.jsx)(_,{label:`Failure types`,value:H?.stats?h(G.length):`—`,hint:`distinct reasons`,compact:!0}),(0,A.jsx)(_,{label:`Pending retry`,value:H?.stats?h(H.stats.pendingRetry??0):`—`,tone:H?.stats?.pendingRetry?`amber`:`default`,hint:`auto-retry queued`,compact:!0}),(0,A.jsx)(_,{label:`Oldest entry`,value:H?.stats?.oldestEntry?x(H.stats.oldestEntry):`—`,hint:`time in DLQ`,compact:!0})]}),(0,A.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`w-56`,children:(0,A.jsx)(E,{value:e,"aria-label":`Queue`,onChange:e=>{t(e.target.value),r(0),o(`all`),u(``),I(null)},children:(L?.queues??[]).map(e=>(0,A.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,A.jsx)(`div`,{className:`w-44`,children:(0,A.jsxs)(E,{value:i,"aria-label":`Filter by reason`,onChange:e=>o(e.target.value),children:[(0,A.jsx)(`option`,{value:`all`,children:`All reasons`}),G.map(e=>(0,A.jsxs)(`option`,{value:e,children:[e,` (`,W[e],`)`]},e))]})}),(0,A.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,A.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,A.jsx)(`input`,{value:s,onChange:e=>u(e.target.value),placeholder:X?`Filter this page by job ID…`:`Filter by job ID…`,"aria-label":`Filter by job ID`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),F&&(0,A.jsx)(`span`,{role:`status`,className:F.ok?`text-sm text-success`:`text-sm text-danger`,children:F.text})]}),B&&!H&&!z?(0,A.jsx)(m,{label:`Loading DLQ…`}):J.length===0?(0,A.jsx)(S,{icon:(0,A.jsx)(d,{}),title:Y?`No matches`:`Dead letter queue is empty`,hint:Y?X?`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,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:`w-8 py-3 pl-4`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Job ID`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Reason`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Error`}),(0,A.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Attempts`}),(0,A.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Entered`}),(0,A.jsx)(`th`,{className:`w-20 px-4 py-3`})]})}),(0,A.jsx)(`tbody`,{children:J.map(t=>{let n=M(t),r=f.has(n),i=t.attempts??[];return(0,A.jsx)(P,{entry:t,isOpen:r,busy:y,onToggle:()=>Z(n),onRetry:()=>U(`Retried`,()=>v.retryDlq(e,t.job.id),`Retry job ${t.job.id.slice(0,8)}… from "${e}"?`),attempts:i},n)})})]})}),H&&(0,A.jsx)(D,{page:n,pageSize:j,total:H.total,onPageChange:r,label:`entries`})]})}function P({entry:e,isOpen:n,busy:i,onToggle:a,onRetry:c,attempts:d}){let m=e;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`tr`,{className:`border-b border-line align-top last:border-0 hover:bg-surface-2/40`,children:[(0,A.jsx)(`td`,{className:`py-3 pl-4`,children:(0,A.jsx)(f,{"aria-label":n?`Collapse details`:`Expand details`,"aria-expanded":n,onClick:a,children:(0,A.jsx)(s,{className:t(`size-3.5 transition-transform`,n&&`rotate-90`)})})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(r,{to:`/job?id=${encodeURIComponent(m.job.id)}`,className:`max-w-[14rem] truncate font-mono text-xs text-accent hover:underline`,title:m.job.id,children:m.job.id}),(0,A.jsx)(u,{value:m.job.id})]})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsx)(`span`,{className:`inline-block rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:m.reason})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsx)(`span`,{className:`block max-w-md truncate text-xs text-danger/80`,title:m.error??``,children:m.error||`—`})}),(0,A.jsx)(`td`,{className:`px-3 py-3 text-right tnum text-muted`,children:m.job.attempts??d.length}),(0,A.jsx)(`td`,{className:`px-3 py-3 text-right text-faint`,title:p(m.enteredAt),children:x(m.enteredAt)}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,A.jsx)(r,{to:`/job?id=${encodeURIComponent(m.job.id)}`,children:(0,A.jsx)(f,{"aria-label":`Inspect job`,children:(0,A.jsx)(o,{className:`size-3.5`})})}),(0,A.jsx)(f,{"aria-label":`Retry job`,disabled:i,onClick:c,children:(0,A.jsx)(l,{className:`size-3.5`})})]})})]}),n&&(0,A.jsxs)(`tr`,{className:`border-b border-line bg-surface-2/30 last:border-0`,children:[(0,A.jsx)(`td`,{}),(0,A.jsxs)(`td`,{colSpan:6,className:`px-3 pb-4 pt-1`,children:[m.error&&(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Error`}),(0,A.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:m.error})]}),(0,A.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Failure history`,typeof m.retryCount==`number`&&m.retryCount>0&&(0,A.jsxs)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] normal-case text-muted`,children:[`retried `,m.retryCount,`×`]})]}),d.length===0?(0,A.jsx)(`p`,{className:`text-xs text-faint`,children:`No per-attempt history recorded.`}):(0,A.jsx)(`ol`,{className:`space-y-1.5`,children:d.map(e=>(0,A.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,A.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Attempt `,e.attempt]}),(0,A.jsx)(`span`,{className:`text-faint`,title:p(e.failedAt),children:x(e.failedAt)}),e.duration!=null&&(0,A.jsx)(`span`,{className:`tnum text-muted`,children:y(e.duration)}),e.reason&&(0,A.jsx)(`span`,{className:`rounded bg-red-500/10 px-1.5 text-danger`,children:e.reason}),e.error&&(0,A.jsx)(`span`,{className:`w-full truncate text-danger/70`,children:e.error})]},`${e.attempt}-${e.failedAt}`))})]})]})]})}export{N as DlqControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-B68RYDeC.js";import{A as o,K as s,R as c,S as l,T as u,b as ee,c as d,h as te,nt as f,rt as p,u as ne,v as m,w as h,x as re,z as g}from"./index-BjRjwWwc.js";import{a as _}from"./form-C-zZyKfB.js";import{t as ie}from"./Pagination-BQg6KGW1.js";import{t as v}from"./exportFile-tdUeW5m5.js";import{t as ae}from"./promisePool-Daxkc1OB.js";var y=e(r(),1),b=a(),oe=6,x=25;function S(){let[e,r]=n(),[a,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(`all`),[T,E]=(0,y.useState)(`newest`),[D,se]=(0,y.useState)(``),[O,k]=(0,y.useState)(0),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),[P,ce]=(0,y.useState)(new Set),{data:le,refetch:F}=o(()=>f.queues(),[],{intervalMs:1e4}),I=le?.queues??[],L=I.reduce((e,t)=>e+t.dlq,0),{data:R,error:z,loading:ue,refetch:B}=o((0,y.useCallback)(async()=>{if(!a)return{queue:a,page:O,entries:[],entriesTotal:0,stats:null};let[e,t]=await Promise.all([f.dlq(a,x,O*x),f.dlqStats(a).catch(()=>null)]);return{queue:a,page:O,entries:e.entries??[],entriesTotal:e.total??0,stats:t?.stats??null}},[a,O]),[a,O]),V=R&&R.queue===a&&R.page===O?R:null;(0,y.useEffect)(()=>{if(!V)return;let e=V.entriesTotal??0;O>0&&O*x>=e&&k(Math.max(0,Math.ceil(e/x)-1))},[V,O]);let H=async(e,t,n)=>{if(window.confirm(e)){j(!0),N(null);try{let e=(await n())?.count??0,r=`${t} ${d(e)} ${e===1?`entry`:`entries`}`;N({ok:!0,text:r}),p.success(r),B(),F()}catch(e){N({ok:!1,text:e.message}),p.error(`${t} failed`,e.message)}finally{j(!1)}}},U=async e=>{let t=q.map(e=>e.name);if(t.length===0||!window.confirm(`${e} the dead letter queue across ${t.length} queue(s) (${d(L)} entries)?`))return;j(!0),N(null);let n=await ae(t,oe,t=>e===`Retry`?f.retryDlq(t):f.purgeDlq(t)),r=0,i=0;for(let e of n)e.status===`fulfilled`?r+=e.value?.count??0:i++;let a=`${e===`Retry`?`Retried`:`Purged`} ${d(r)} across ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;N({ok:i===0,text:a}),i===0?p.success(a):p.error(a),B(),F(),j(!1)},de=()=>{let e=(V?.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){p.info(`Nothing to export on this page`);return}v(`dlq-${a}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},W=e=>{J.current=!0,S(e),k(0),w(`all`),r(e?{queue:e}:{},{replace:!0})},G=V?.stats?.byReason??{},K=Object.keys(G).filter(e=>G[e]>0),fe=[...K].sort((e,t)=>(G[t]??0)-(G[e]??0))[0],q=(0,y.useMemo)(()=>I.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[I]),J=(0,y.useRef)(!1),Y=e.get(`queue`);(0,y.useEffect)(()=>{if(!(J.current||a)){if(Y){if(I.some(e=>e.name===Y)){J.current=!0,S(Y),k(0),w(`all`);return}if(I.length===0)return}q.length!==0&&(J.current=!0,S(q[0].name),k(0),w(`all`))}},[a,I,q,Y]);let X=(0,y.useMemo)(()=>{let e=V?.entries??[];C!==`all`&&(e=e.filter(e=>e.reason===C));let t=D.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>T===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[V,C,D,T]),Z=L===0,Q=C!==`all`||D.trim()!==``,$=(V?.entriesTotal??0)>x;return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(te,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Monitor, retry, or purge.`,live:!0}),z&&(0,b.jsx)(re,{onRetry:B}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsxs)(l,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,b.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Z?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:Z?`Healthy`:`Attention`})]}),(0,b.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,Z?`text-success`:`text-danger`),children:d(L)})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,b.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:a?fe??`No failures`:`Select a queue`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(V.stats.pendingRetry??0):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(K.length):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]}),q.length>0&&(0,b.jsxs)(l,{className:`mb-6`,children:[(0,b.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(h,{size:`sm`,disabled:A,onClick:()=>U(`Retry`),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry all (`,q.length,` queues)`]}),(0,b.jsxs)(h,{variant:`danger`,size:`sm`,disabled:A,onClick:()=>U(`Purge`),children:[`Purge all (`,q.length,` queues)`]})]})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:q.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>W(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,a===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,b.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,b.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:e.dlq})]},e.name))})]}),(0,b.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-48`,children:(0,b.jsxs)(_,{value:a,onChange:e=>W(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Select a queue…`}),I.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,b.jsx)(`div`,{className:`w-40`,children:(0,b.jsxs)(_,{value:C,onChange:e=>w(e.target.value),"aria-label":`Filter by reason`,children:[(0,b.jsx)(`option`,{value:`all`,children:`All Reasons`}),K.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]})}),(0,b.jsx)(`div`,{className:`w-36`,children:(0,b.jsxs)(_,{value:T,onChange:e=>E(e.target.value),"aria-label":$?`Sort this page`:`Sort`,children:[(0,b.jsxs)(`option`,{value:`newest`,children:[`Newest First`,$?` (this page)`:``]}),(0,b.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,$?` (this page)`:``]})]})}),(0,b.jsx)(`input`,{value:D,onChange:e=>se(e.target.value),placeholder:`Filter this page by job ID…`,"aria-label":`Filter this page by job ID`,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,b.jsxs)(h,{size:`sm`,disabled:!a||A,onClick:()=>H(`Retry all for "${a}"?`,`Retried`,()=>f.retryDlq(a)),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry All`]}),(0,b.jsx)(h,{variant:`danger`,size:`sm`,disabled:!a||A,onClick:()=>H(`Purge all for "${a}"?`,`Purged`,()=>f.purgeDlq(a)),children:`Purge All`}),(0,b.jsx)(u,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!a,onClick:de,children:(0,b.jsx)(g,{className:`size-3.5`})})]}),M&&(0,b.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),ue&&!V&&!z?(0,b.jsx)(ee,{label:`Loading DLQ…`}):a?X.length===0?(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),title:Q?`No matches on this page`:`No dead letter entries`,hint:Q?`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,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Reason`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Error`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,b.jsx)(`th`,{scope:`col`,className:`w-16 px-5 py-3`})]})}),(0,b.jsx)(`tbody`,{children:X.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,b.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,b.jsx)(`button`,{type:`button`,title:e.error,onClick:()=>ce(t=>{let n=new Set(t),r=`${e.job.id}-${e.enteredAt}`;return n.has(r)?n.delete(r):n.add(r),n}),className:t(`block w-full break-words text-left`,!P.has(`${e.job.id}-${e.enteredAt}`)&&`line-clamp-2`),children:e.error}):`—`}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:ne(e.enteredAt)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,b.jsx)(u,{"aria-label":`Retry`,disabled:A,onClick:()=>H(`Retry job ${e.job.id.slice(0,8)}… from "${a}"?`,`Retried`,()=>f.retryDlq(a,e.job.id)),children:(0,b.jsx)(s,{className:`size-3.5`})})})]},`${e.job.id}-${e.enteredAt}`))})]})}):(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),a&&V&&(0,b.jsx)(ie,{page:O,pageSize:x,total:V.entriesTotal,onPageChange:k,label:`entries`})]})}export{S as DlqPro};
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-BcouBxpZ.js";import{A as o,K as s,R as c,S as l,T as u,b as ee,c as d,h as te,nt as f,rt as p,u as ne,v as m,w as h,x as re,z as g}from"./index-BOcegTHa.js";import{a as _}from"./form-DGinTEEb.js";import{t as ie}from"./Pagination-D4ki-pGz.js";import{t as v}from"./exportFile-tdUeW5m5.js";import{t as ae}from"./promisePool-Daxkc1OB.js";var y=e(r(),1),b=a(),oe=6,x=25;function S(){let[e,r]=n(),[a,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(`all`),[T,E]=(0,y.useState)(`newest`),[D,se]=(0,y.useState)(``),[O,k]=(0,y.useState)(0),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),[P,ce]=(0,y.useState)(new Set),{data:le,refetch:F}=o(()=>f.queues(),[],{intervalMs:1e4}),I=le?.queues??[],L=I.reduce((e,t)=>e+t.dlq,0),{data:R,error:z,loading:ue,refetch:B}=o((0,y.useCallback)(async()=>{if(!a)return{queue:a,page:O,entries:[],entriesTotal:0,stats:null};let[e,t]=await Promise.all([f.dlq(a,x,O*x),f.dlqStats(a).catch(()=>null)]);return{queue:a,page:O,entries:e.entries??[],entriesTotal:e.total??0,stats:t?.stats??null}},[a,O]),[a,O]),V=R&&R.queue===a&&R.page===O?R:null;(0,y.useEffect)(()=>{if(!V)return;let e=V.entriesTotal??0;O>0&&O*x>=e&&k(Math.max(0,Math.ceil(e/x)-1))},[V,O]);let H=async(e,t,n)=>{if(window.confirm(e)){j(!0),N(null);try{let e=(await n())?.count??0,r=`${t} ${d(e)} ${e===1?`entry`:`entries`}`;N({ok:!0,text:r}),p.success(r),B(),F()}catch(e){N({ok:!1,text:e.message}),p.error(`${t} failed`,e.message)}finally{j(!1)}}},U=async e=>{let t=q.map(e=>e.name);if(t.length===0||!window.confirm(`${e} the dead letter queue across ${t.length} queue(s) (${d(L)} entries)?`))return;j(!0),N(null);let n=await ae(t,oe,t=>e===`Retry`?f.retryDlq(t):f.purgeDlq(t)),r=0,i=0;for(let e of n)e.status===`fulfilled`?r+=e.value?.count??0:i++;let a=`${e===`Retry`?`Retried`:`Purged`} ${d(r)} across ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;N({ok:i===0,text:a}),i===0?p.success(a):p.error(a),B(),F(),j(!1)},de=()=>{let e=(V?.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){p.info(`Nothing to export on this page`);return}v(`dlq-${a}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},W=e=>{J.current=!0,S(e),k(0),w(`all`),r(e?{queue:e}:{},{replace:!0})},G=V?.stats?.byReason??{},K=Object.keys(G).filter(e=>G[e]>0),fe=[...K].sort((e,t)=>(G[t]??0)-(G[e]??0))[0],q=(0,y.useMemo)(()=>I.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[I]),J=(0,y.useRef)(!1),Y=e.get(`queue`);(0,y.useEffect)(()=>{if(!(J.current||a)){if(Y){if(I.some(e=>e.name===Y)){J.current=!0,S(Y),k(0),w(`all`);return}if(I.length===0)return}q.length!==0&&(J.current=!0,S(q[0].name),k(0),w(`all`))}},[a,I,q,Y]);let X=(0,y.useMemo)(()=>{let e=V?.entries??[];C!==`all`&&(e=e.filter(e=>e.reason===C));let t=D.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>T===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[V,C,D,T]),Z=L===0,Q=C!==`all`||D.trim()!==``,$=(V?.entriesTotal??0)>x;return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(te,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Monitor, retry, or purge.`,live:!0}),z&&(0,b.jsx)(re,{onRetry:B}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsxs)(l,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,b.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Z?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:Z?`Healthy`:`Attention`})]}),(0,b.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,Z?`text-success`:`text-danger`),children:d(L)})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,b.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:a?fe??`No failures`:`Select a queue`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(V.stats.pendingRetry??0):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(K.length):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]}),q.length>0&&(0,b.jsxs)(l,{className:`mb-6`,children:[(0,b.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(h,{size:`sm`,disabled:A,onClick:()=>U(`Retry`),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry all (`,q.length,` queues)`]}),(0,b.jsxs)(h,{variant:`danger`,size:`sm`,disabled:A,onClick:()=>U(`Purge`),children:[`Purge all (`,q.length,` queues)`]})]})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:q.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>W(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,a===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,b.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,b.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:e.dlq})]},e.name))})]}),(0,b.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-48`,children:(0,b.jsxs)(_,{value:a,onChange:e=>W(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Select a queue…`}),I.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,b.jsx)(`div`,{className:`w-40`,children:(0,b.jsxs)(_,{value:C,onChange:e=>w(e.target.value),"aria-label":`Filter by reason`,children:[(0,b.jsx)(`option`,{value:`all`,children:`All Reasons`}),K.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]})}),(0,b.jsx)(`div`,{className:`w-36`,children:(0,b.jsxs)(_,{value:T,onChange:e=>E(e.target.value),"aria-label":$?`Sort this page`:`Sort`,children:[(0,b.jsxs)(`option`,{value:`newest`,children:[`Newest First`,$?` (this page)`:``]}),(0,b.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,$?` (this page)`:``]})]})}),(0,b.jsx)(`input`,{value:D,onChange:e=>se(e.target.value),placeholder:`Filter this page by job ID…`,"aria-label":`Filter this page by job ID`,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,b.jsxs)(h,{size:`sm`,disabled:!a||A,onClick:()=>H(`Retry all for "${a}"?`,`Retried`,()=>f.retryDlq(a)),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry All`]}),(0,b.jsx)(h,{variant:`danger`,size:`sm`,disabled:!a||A,onClick:()=>H(`Purge all for "${a}"?`,`Purged`,()=>f.purgeDlq(a)),children:`Purge All`}),(0,b.jsx)(u,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!a,onClick:de,children:(0,b.jsx)(g,{className:`size-3.5`})})]}),M&&(0,b.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),ue&&!V&&!z?(0,b.jsx)(ee,{label:`Loading DLQ…`}):a?X.length===0?(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),title:Q?`No matches on this page`:`No dead letter entries`,hint:Q?`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,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Reason`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Error`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,b.jsx)(`th`,{scope:`col`,className:`w-16 px-5 py-3`})]})}),(0,b.jsx)(`tbody`,{children:X.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,b.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,b.jsx)(`button`,{type:`button`,title:e.error,onClick:()=>ce(t=>{let n=new Set(t),r=`${e.job.id}-${e.enteredAt}`;return n.has(r)?n.delete(r):n.add(r),n}),className:t(`block w-full break-words text-left`,!P.has(`${e.job.id}-${e.enteredAt}`)&&`line-clamp-2`),children:e.error}):`—`}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:ne(e.enteredAt)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,b.jsx)(u,{"aria-label":`Retry`,disabled:A,onClick:()=>H(`Retry job ${e.job.id.slice(0,8)}… from "${a}"?`,`Retried`,()=>f.retryDlq(a,e.job.id)),children:(0,b.jsx)(s,{className:`size-3.5`})})})]},`${e.job.id}-${e.enteredAt}`))})]})}):(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),a&&V&&(0,b.jsx)(ie,{page:O,pageSize:x,total:V.entriesTotal,onPageChange:k,label:`entries`})]})}export{S as DlqPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-BcouBxpZ.js";import{D as o,S as s,b as c,et as l,h as u,nt as d,x as f,y as p}from"./index-BOcegTHa.js";var m=e(r(),1),h={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function g(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=0;for(;a.length;){let s=a.shift();o+=1;for(let e of i.get(s)??[]){n.set(e,Math.max(n.get(e)??0,(n.get(s)??0)+1));let t=(r.get(e)??0)-1;r.set(e,t),t===0&&a.push(e)}if(o>e.length+t.length)break}return n}function _(e,t,n={}){let r={...h,...n},i=g(e,t),a=new Map,o=0;for(let t of e){let e=i.get(t)??0;o=Math.max(o,e);let n=a.get(e);n?n.push(t):a.set(e,[t])}let s=0;for(let e of a.values())s=Math.max(s,e.length);let c=s*r.nodeHeight+Math.max(0,s-1)*r.rowGap,l=[];for(let e=0;e<=o;e++){let t=a.get(e)??[],n=t.length*r.nodeHeight+Math.max(0,t.length-1)*r.rowGap,i=r.padding+(c-n)/2;t.forEach((t,n)=>{l.push({id:t,layer:e,x:r.padding+e*(r.nodeWidth+r.colGap),y:i+n*(r.nodeHeight+r.rowGap)})})}return{nodes:l,width:r.padding*2+(o+1)*r.nodeWidth+o*r.colGap,height:r.padding*2+c}}var v=a(),y=168,b=60,x={nodeWidth:y,nodeHeight:b},S=60,C=6,w=`flow-order-9a3f`,T={completed:`border-success/50 bg-success/10 text-success`,failed:`border-danger/50 bg-danger/10 text-danger`,active:`border-blue-400/60 bg-blue-400/10 text-blue-400`,delayed:`border-accent/50 bg-accent/10 text-accent`,waiting:`border-warning/50 bg-warning/10 text-warning`,prioritized:`border-warning/50 bg-warning/10 text-warning`},E=e=>e&&T[e]||`border-line bg-surface-2 text-muted`,D=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,O=`bq-dash-recent-flows`,k=8;function A(){try{let e=JSON.parse(localStorage.getItem(O)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e?.root==`string`&&typeof e?.nodes==`number`&&typeof e?.at==`number`):[]}catch{return[]}}function j(e,t){let n=[t,...e.filter(e=>e.root!==t.root)].slice(0,k);try{localStorage.setItem(O,JSON.stringify(n))}catch{}return n}async function M(e){let t=e,n=new Set([e]);for(let e=0;e<12;e++){try{let{job:e}=await d.job(t),r=e?.parentId;if(r&&!n.has(r)){n.add(r),t=r;continue}}catch(t){if(e===0)throw t}break}return t}async function N(e){let t=new Map,n=[],r=new Set,i=[{id:e,depth:0}],a=!1;for(;i.length&&t.size<S;){let{id:e,depth:o}=i.shift();if(t.has(e))continue;let s=null;try{s=(await d.job(e)).job??null}catch{}if(t.set(e,s??{id:e,state:`unknown`}),!s)continue;if(o>=C){(s.childrenIds?.length??0)+(s.dependsOn?.length??0)>0&&(a=!0);continue}let c=(e,t,a,s)=>{let c=`${e}->${t}:${a}`;r.has(c)||(r.add(c),n.push({from:e,to:t,kind:a})),i.push({id:s,depth:o+1})};for(let t of s.childrenIds??[])c(e,t,`child`,t);for(let t of s.dependsOn??[])c(t,e,`depends`,t)}return i.some(e=>!t.has(e.id))&&(a=!0),{jobs:t,edges:n,truncated:a}}function P(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function F(){let[e,r]=n(),a=e.get(`root`)??(o()?w:``),[d,h]=(0,m.useState)(a),[g,T]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[F,L]=(0,m.useState)(!1),[R,z]=(0,m.useState)(null),[B,V]=(0,m.useState)(A),H=(0,m.useRef)(0),U=(0,m.useCallback)(async e=>{let t=e.trim();if(!t){T(null);return}let n=++H.current;L(!0),z(null);try{let e=await M(t),r=await N(e);if(n!==H.current)return;T(r),k(e),r.jobs.size>1&&V(t=>j(t,{root:e,nodes:r.jobs.size,at:Date.now()}))}catch(e){if(n!==H.current)return;z(e instanceof Error?e:Error(`Failed to load flow`)),T(null)}finally{n===H.current&&L(!1)}},[]);(0,m.useEffect)(()=>{a&&U(a)},[a,U]);let W=e=>{e.preventDefault();let t=d.trim();t&&r(t?{root:t}:{},{replace:!0})},G=g?_([...g.jobs.keys()],g.edges,x):null,K=new Map(G?.nodes.map(e=>[e.id,e])??[]),q=O?g?.jobs.get(O):void 0;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(u,{title:`Flows`,description:`Visualize a job flow: parent, children, and dependency edges as an interactive graph.`,actions:g&&(0,v.jsx)(`button`,{type:`button`,onClick:()=>U(d||a),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Refresh`})}),(0,v.jsxs)(s,{className:`mb-6`,children:[(0,v.jsxs)(`form`,{onSubmit:W,className:`flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`input`,{value:d,onChange:e=>h(e.target.value),placeholder:`Job ID (any node in the flow)`,"aria-label":`Root job ID`,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,v.jsx)(`button`,{type:`submit`,disabled:!d.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:`Load flow`})]}),(0,v.jsxs)(`p`,{className:`mt-2 text-xs text-faint`,children:[`Paste any job ID from the Job Inspector. The graph climbs to the flow root, then walks children and dependencies (up to `,S,` nodes).`]})]}),R&&(R instanceof l?(0,v.jsx)(p,{error:R,onRetry:()=>U(d||a)}):(0,v.jsx)(f,{onRetry:()=>U(d||a)})),F&&!g&&(0,v.jsx)(c,{label:`Loading flow…`}),!F&&!g&&!R&&(0,v.jsx)(s,{children:(0,v.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,v.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,v.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID above, or open a job that is part of a flow and choose “View flow”.`}),B.length>0&&(0,v.jsxs)(`div`,{className:`mt-6`,children:[(0,v.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,v.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:B.map(e=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{h(e.root),r({root:e.root},{replace:!0})},className:`rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted transition-colors hover:border-line-strong hover:text-fg`,children:[D(e.root),(0,v.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})}),g&&G&&(0,v.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1fr_260px]`,children:[(0,v.jsx)(s,{padded:!1,className:`overflow-auto p-4`,children:(0,v.jsxs)(`div`,{className:`relative`,style:{width:G.width,height:G.height},children:[(0,v.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:G.width,height:G.height,children:[(0,v.jsx)(`title`,{children:`Flow edges`}),g.edges.map(e=>{let t=K.get(e.from),n=K.get(e.to);return!t||!n?null:(0,v.jsx)(`path`,{d:P(t.x+y,t.y+b/2,n.x,n.y+b/2),fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeDasharray:e.kind===`depends`?`4 4`:void 0,opacity:.5},`${e.from}-${e.to}-${e.kind}`)})]}),G.nodes.map(e=>{let n=g.jobs.get(e.id);return(0,v.jsxs)(`button`,{type:`button`,onClick:()=>k(e.id),style:{left:e.x,top:e.y,width:y,height:b},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left transition-shadow`,E(n?.state),O===e.id&&`ring-2 ring-accent`),children:[(0,v.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:D(e.id)}),(0,v.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,v.jsx)(`span`,{className:`truncate`,children:n?.queue??`—`}),(0,v.jsx)(`span`,{className:`font-medium`,children:n?.state??`unknown`})]})]},e.id)})]})}),(0,v.jsxs)(s,{children:[q?(0,v.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,v.jsx)(`div`,{className:`break-all font-mono text-xs text-fg`,children:q.id})]}),(0,v.jsx)(I,{label:`Queue`,value:q.queue??`—`}),(0,v.jsx)(I,{label:`State`,value:q.state??`unknown`}),(0,v.jsx)(I,{label:`Priority`,value:String(q.priority??0)}),(0,v.jsx)(I,{label:`Children`,value:String(q.childrenIds?.length??0)}),(0,v.jsx)(I,{label:`Depends on`,value:String(q.dependsOn?.length??0)}),(0,v.jsx)(i,{to:`/job?id=${encodeURIComponent(q.id)}`,className:`inline-block rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Open in Job Inspector`})]}):(0,v.jsx)(`p`,{className:`text-sm text-muted`,children:`Click a node to inspect it.`}),(0,v.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,children:[g.truncated&&(0,v.jsxs)(`div`,{className:`mb-1 text-warning`,children:[`Graph truncated at `,S,` nodes / depth `,C,` — not the whole flow.`]}),(0,v.jsxs)(`div`,{className:`mb-1`,children:[g.jobs.size,` node`,g.jobs.size===1?``:`s`,` · `,g.edges.length,` edge`,g.edges.length===1?``:`s`]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,v.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` `,`depends`]})]})]})]})]})]})}function I({label:e,value:t}){return(0,v.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,v.jsx)(`span`,{className:`text-xs text-faint`,children:e}),(0,v.jsx)(`span`,{className:`text-fg`,children:t})]})}export{F as Flows};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{f as t,h as n,r,t as i}from"./react-vendor-BcouBxpZ.js";import{C as a,J as o,O as s,S as c,T as l,a as u,b as d,et as f,g as p,h as m,nt as h,o as g,v as _,w as v,z as y}from"./index-BOcegTHa.js";import{a as b,n as x}from"./form-DGinTEEb.js";import{t as S}from"./jobActions-CuOdMglt.js";import{n as C}from"./exportFile-tdUeW5m5.js";var w=e(n(),1);function T(e){let t={};return typeof e.priority==`number`&&(t.priority=e.priority),typeof e.maxAttempts==`number`&&(t.maxAttempts=e.maxAttempts),typeof e.backoff==`number`&&(t.backoff=e.backoff),typeof e.timeout==`number`&&(t.timeout=e.timeout),typeof e.removeOnComplete==`boolean`&&(t.removeOnComplete=e.removeOnComplete),typeof e.removeOnFail==`boolean`&&(t.removeOnFail=e.removeOnFail),{clone:{queue:e.queue??``,dataText:JSON.stringify(e.data??{},null,2),options:t}}}var E=i();function ee({job:e,busy:t,act:n}){let r=S(e.state),i=r.cancel||r.discard||r.promote||r.retryActive||r.retryDlq||r.requeueCompleted||r.setPriority||r.setDelay||r.fail||r.moveToDelayed;return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Actions`}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>h.promoteJob(e.id)),children:`Promote (run now)`}),r.retryActive&&(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>h.retryJob(e.id)),children:`Retry (move to waiting)`}),r.retryDlq&&(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>h.retryDlq(e.queue??``,e.id)),children:`Retry from DLQ`}),r.requeueCompleted&&(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Requeue`,()=>h.retryCompleted(e.queue??``,e.id)),children:`Requeue`}),r.moveToDelayed&&(0,E.jsx)(D,{label:`Move to delayed (ms)`,cta:`To delayed`,disabled:t,onSubmit:t=>n(`Move to delayed`,()=>h.moveToDelayed(e.id,t))}),e.state===`active`&&(0,E.jsx)(D,{label:`Set progress (0–100)`,cta:`Progress`,disabled:t,onSubmit:t=>n(`Progress`,()=>h.setJobProgress(e.id,Math.max(0,Math.min(100,t))))}),r.discard&&(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Discard`,()=>h.discardJob(e.id)),children:`Discard (to DLQ)`}),r.setPriority&&(0,E.jsx)(D,{label:`Set priority`,cta:`Set`,disabled:t,onSubmit:t=>n(`Priority`,()=>h.changePriority(e.id,t))}),r.setDelay&&(0,E.jsx)(D,{label:`Set delay (ms)`,cta:`Delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>h.changeDelay(e.id,t))}),r.fail&&(0,E.jsx)(O,{label:`Fail reason (optional)`,cta:`Fail`,variant:`warning`,disabled:t,onSubmit:t=>n(`Fail`,()=>h.failJob(e.id,t||void 0),`Force-fail this active job?`)}),r.cancel&&(0,E.jsx)(v,{variant:`danger`,size:`sm`,disabled:t,onClick:()=>n(`Cancel`,()=>h.cancelJob(e.id),`Cancel and remove job ${e.id}?`),children:`Cancel (delete)`}),!i&&(0,E.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function D({label:e,cta:t,disabled:n,onSubmit:r}){let[i,a]=(0,w.useState)(``);return(0,E.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!n&&i.trim()!==``&&r(Number(i))},children:[(0,E.jsx)(x,{type:`number`,value:i,onChange:e=>a(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,E.jsx)(v,{type:`submit`,size:`sm`,disabled:n||i.trim()===``,children:t})]})}function O({label:e,cta:t,disabled:n,variant:r=`default`,onSubmit:i}){let[a,o]=(0,w.useState)(``);return(0,E.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!n&&(i(a),o(``))},children:[(0,E.jsx)(x,{value:a,onChange:e=>o(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,E.jsx)(v,{type:`submit`,size:`sm`,variant:r,disabled:n,children:t})]})}var k=36e5,A=10;function j(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??k,a=r?.delay??e.backoff??1e3,o=[];for(let e=Math.max(n,1);e<t&&o.length<A;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function M({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Backoff`}),(0,E.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Backoff schedule`}),(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,o=t-n,s=j(e);return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Backoff schedule`,action:(0,E.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${g(r.maxDelay)}`:``]})}),(0,E.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:s.map(e=>(0,E.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,E.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,E.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,g(e.delayMs)]})]},e.attempt))}),o>A&&(0,E.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,A,` of `,o,` remaining attempts.`]}),(0,E.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,g(r?.maxDelay??k),`.`]})]})}function N({jobId:e}){let[t,n]=(0,w.useState)(!1),[r,i]=(0,w.useState)(!1),[o,s]=(0,w.useState)(!1),[l,u]=(0,w.useState)(void 0),[d,f]=(0,w.useState)(null),p=async()=>{s(!0),f(null);try{let t=await h.jobChildren(e);u(t.data?.values),i(!0)}catch(e){f(e.message)}finally{s(!1)}},m=()=>{let e=!t;n(e),e&&!r&&!o&&p()},g=l&&typeof l==`object`?Array.isArray(l)?l.length:Object.keys(l).length:0;return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Child values`,action:(0,E.jsx)(v,{size:`sm`,variant:`ghost`,onClick:m,children:t?`Hide`:`Show`})}),t?o?(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):d?(0,E.jsx)(`p`,{className:`text-xs text-danger`,children:d}):g===0?(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,E.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(l,null,2)}):(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function P({data:e,busy:t,onSave:n}){let[r,i]=(0,w.useState)(()=>JSON.stringify(e??null,null,2)),[o,s]=(0,w.useState)(null),l=(0,w.useRef)(r);return(0,w.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,i(t),s(null))},[e]),(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Data`,action:(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(r)}catch(e){s(`Invalid JSON: ${e.message}`);return}s(null),n(e)},children:`Save data`})}),(0,E.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),o&&(0,E.jsx)(`p`,{className:`mt-2 text-xs text-danger`,children:o})]})}function F({jobId:e}){let[t,n]=(0,w.useState)([]),[r,i]=(0,w.useState)(0),[o,s]=(0,w.useState)(!1),[l,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(``),[p,m]=(0,w.useState)(`info`),[g,_]=(0,w.useState)(!1),y=(0,w.useCallback)(async()=>{s(!0),u(null);try{let t=await h.jobLogs(e);n(t.data?.logs??[]),i(t.data?.count??0)}catch(e){u(e.message)}finally{s(!1)}},[e]);(0,w.useEffect)(()=>{y()},[y]);let S=async()=>{if(g)return;let t=d.trim();if(t){_(!0),u(null);try{await h.addJobLog(e,t,p),f(``),await y()}catch(e){u(e.message)}finally{_(!1)}}};return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Logs`,action:(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:r}),(0,E.jsx)(v,{size:`sm`,variant:`ghost`,disabled:o||g,onClick:y,children:`Refresh`}),(0,E.jsx)(v,{size:`sm`,variant:`danger`,disabled:g||t.length===0,onClick:async()=>{if(window.confirm(`Clear all logs for this job?`)){_(!0),u(null);try{await h.clearJobLogs(e),await y()}catch(e){u(e.message)}finally{_(!1)}}},children:`Clear logs`})]})}),l&&(0,E.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:l}),t.length===0?(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,E.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,E.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,E.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,E.jsx)(x,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.key===`Enter`&&S(),placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,E.jsxs)(b,{value:p,onChange:e=>m(e.target.value),className:`h-8 w-24 text-xs`,children:[(0,E.jsx)(`option`,{value:`info`,children:`info`}),(0,E.jsx)(`option`,{value:`warn`,children:`warn`}),(0,E.jsx)(`option`,{value:`error`,children:`error`})]}),(0,E.jsx)(v,{size:`sm`,disabled:g||d.trim()===``,onClick:S,children:`Add`})]})]})}function I({timeline:e}){let t=e??[];return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Timeline`}),t.length===0?(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,E.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,E.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(p,{status:e.state}),e.attempt!=null&&(0,E.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,E.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:u(e.timestamp)})]}),(e.worker||e.error)&&(0,E.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,E.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,E.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function te(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return null}function L(){let[e,n]=t(),[i,l]=(0,w.useState)(e.get(`id`)??``),[x,S]=(0,w.useState)(`id`),[D,O]=(0,w.useState)(null),[k,A]=(0,w.useState)({fetched:!1,value:void 0}),[j,L]=(0,w.useState)(!1),[ie,z]=(0,w.useState)(!1),[B,V]=(0,w.useState)(null),[H,U]=(0,w.useState)(!1),W=(0,w.useRef)(0),G=async(e,t=x,r=!1)=>{let i=e.trim();if(!i)return;let a=++W.current;L(!0),z(!1),r||V(null);try{let e=(await(t===`custom`?h.jobByCustomId(i):h.job(i))).job;if(!e){if(a!==W.current)return;O(null),A({fetched:!1,value:void 0}),z(!0),n({},{replace:!0});return}let r=e.state===`completed`?await h.jobResult(e.id).catch(()=>null):null;if(a!==W.current)return;O(e),l(t===`custom`?e.id:i),n({id:e.id},{replace:!0}),A(r?{fetched:!0,value:r.result}:{fetched:!1,value:void 0})}catch(e){if(a!==W.current)return;e instanceof f&&(e.status===404||/not found/i.test(e.message))?(O(null),A({fetched:!1,value:void 0}),z(!0),n({},{replace:!0})):V({ok:!1,text:e.message})}finally{a===W.current&&L(!1)}},K=e.get(`id`);(0,w.useEffect)(()=>{K&&K!==D?.id&&G(K,`id`)},[K,D?.id]);let q=async(e,t,r)=>{if(!(r&&!window.confirm(r))&&D){U(!0),V(null);try{await t(),V({ok:!0,text:`${e} ✓`}),e===`Cancel`?(O(null),A({fetched:!1,value:void 0}),n({},{replace:!0})):await G(D.id,`id`,!0)}catch(e){V({ok:!1,text:e.message})}finally{U(!1)}}},J=D?.state,Y=D?te(D):null,X=(D?.stacktrace?.length??0)>0,Z=(D?.childrenIds?.length??0)>0,Q=J===`failed`,$=D&&(Y||X)?(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Error`}),Y&&(0,E.jsxs)(`div`,{className:`mb-3`,children:[(0,E.jsx)(`p`,{className:`text-sm text-danger`,children:Y.message}),(0,E.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[Y.attempt==null?``:`Attempt ${Y.attempt} · `,u(Y.timestamp)]})]}),X&&(0,E.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:D.stacktrace?.join(`
|
|
2
|
+
`)})]}):null;return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(m,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:D?(0,E.jsxs)(E.Fragment,{children:[(Z||D.parentId)&&(0,E.jsx)(r,{to:`/flows?root=${encodeURIComponent(D.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}),(0,E.jsx)(r,{to:`/add-job`,state:T(D),title:`Enqueue a new job pre-filled from this one`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Clone`}),(0,E.jsxs)(v,{size:`sm`,onClick:()=>C(`job-${D.id}`,k.fetched?{...D,result:k.value}:D),children:[(0,E.jsx)(y,{className:`size-3.5`}),` Download JSON`]})]}):void 0}),(0,E.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,E.jsxs)(b,{value:x,"aria-label":`Lookup mode`,onChange:e=>S(e.target.value),className:`w-40`,children:[(0,E.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,E.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,E.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,E.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,E.jsx)(`input`,{value:i,"aria-label":x===`custom`?`Custom job ID`:`Job ID`,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&G(i),placeholder:x===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,E.jsx)(v,{variant:`accent`,disabled:j,onClick:()=>G(i),children:`Look up`})]}),B&&(0,E.jsx)(`div`,{role:`status`,className:B.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:B.text}),j&&!D?(0,E.jsx)(d,{label:`Loading job…`}):ie?(0,E.jsx)(_,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`}):D?(0,E.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,E.jsxs)(c,{children:[(0,E.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:D.id}),(0,E.jsx)(s,{value:D.id})]}),(0,E.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:D.queue})]}),(0,E.jsx)(p,{status:J??`waiting`})]}),(0,E.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,E.jsx)(R,{k:`Priority`,v:String(D.priority??0)}),(0,E.jsx)(R,{k:`Attempts`,v:`${D.attempts??0} / ${D.maxAttempts??`?`}`}),(0,E.jsx)(R,{k:`Progress`,v:`${D.progress??0}%`}),(0,E.jsx)(R,{k:`Created`,v:u(D.createdAt)}),(0,E.jsx)(R,{k:`Started`,v:u(D.startedAt??void 0)}),(0,E.jsx)(R,{k:`Completed`,v:u(D.completedAt??void 0)}),(0,E.jsx)(R,{k:`Duration`,v:g(D.startedAt&&D.completedAt?D.completedAt-D.startedAt:void 0)}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,E.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,E.jsx)(`span`,{className:`truncate font-mono`,children:D.customId??`—`}),D.customId&&(0,E.jsx)(s,{value:D.customId})]})]})]})]}),Q&&$,(0,E.jsx)(P,{data:D.data,busy:H,onSave:e=>q(`Data`,()=>h.updateJobData(D.id,e))},`data-${D.id}`),J===`completed`&&(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Result`,action:k.fetched&&k.value!==void 0&&k.value!==null?(0,E.jsx)(re,{value:k.value,filename:`job-${D.id}-result`}):void 0}),k.fetched&&k.value!==void 0&&k.value!==null?(0,E.jsx)(ne,{value:k.value}):(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]}),!Q&&$,(0,E.jsx)(F,{jobId:D.id},`logs-${D.id}`),Z&&(0,E.jsx)(N,{jobId:D.id},`children-${D.id}`),(0,E.jsx)(I,{timeline:D.timeline}),(0,E.jsx)(M,{job:D})]}),(0,E.jsx)(`div`,{className:`order-first lg:order-none`,children:(0,E.jsx)(ee,{job:D,busy:H,act:q})})]}):(0,E.jsx)(_,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`})]})}function R({k:e,v:t}){return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,E.jsx)(`dd`,{className:`text-fg`,children:t})]})}function ne({value:e}){return(0,E.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(e??null,null,2)})}function re({value:e,filename:t}){return(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(s,{value:JSON.stringify(e??null,null,2)}),(0,E.jsx)(l,{"aria-label":`Download JSON`,title:`Download JSON`,onClick:()=>C(t,e??null),children:(0,E.jsx)(y,{className:`size-3.5`})})]})}export{L as JobInspector};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{f as t,h as n,t as r}from"./react-vendor-BcouBxpZ.js";import{A as i,J as a,T as o,Y as s,b as c,c as l,f as u,g as d,h as f,j as p,l as m,m as h,n as g,o as _,u as v,x as y}from"./index-BOcegTHa.js";import{a as b,i as x}from"./form-DGinTEEb.js";import{t as S}from"./jobActions-CuOdMglt.js";var C=e(n(),1),w=r(),T=`__all__`,E=[`all`,`waiting`,`active`,`completed`,`failed`];function D(){let[e]=t(),[n,r]=(0,C.useState)(e.get(`queue`)??T),[D,O]=(0,C.useState)(`all`),[k,A]=(0,C.useState)(``),{data:j}=i(()=>p.queues(500),[],{intervalMs:3e4}),{data:M}=i(()=>p.overview(),[]),{data:N,error:P,loading:F,refetch:I}=i((0,C.useCallback)(async()=>{let e=n===T?(j?.queues??[]).map(e=>e.name).slice(0,25):[n],t=D===`all`?void 0:[D];return(await Promise.all(e.map(e=>p.jobsList(e,{states:t,limit:40}).then(t=>(t.jobs??[]).map(t=>({...t,queue:t.queue??e}))).catch(()=>[])))).flat().sort((e,t)=>(t.createdAt??0)-(e.createdAt??0))},[n,D,j]),[n,D]),L=(0,C.useMemo)(()=>{let e=N??[],t=k.trim().toLowerCase();return(t?e.filter(e=>e.id.toLowerCase().includes(t)||(e.data?.name??``).toLowerCase().includes(t)):e).slice(0,100)},[N,k]),R=M?.stats,z=R?g(R.totalCompleted,R.totalFailed)??0:0,B=async e=>{if(window.confirm(`Cancel job ${e}?`))try{await p.cancelJob(e),I()}catch(e){window.alert(`Cancel failed: ${e.message}`)}};return(0,w.jsxs)(`div`,{children:[P&&(0,w.jsx)(y,{onRetry:I}),(0,w.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0}),(0,w.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,w.jsx)(h,{label:`Total`,value:l((R?.totalCompleted??0)+(R?.totalFailed??0)+(R?.waiting??0)+(R?.active??0)),compact:!0}),(0,w.jsx)(h,{label:`Waiting`,value:l(R?.waiting),tone:`amber`,compact:!0}),(0,w.jsx)(h,{label:`Active`,value:l(R?.active),tone:`blue`,compact:!0}),(0,w.jsx)(h,{label:`Completed`,value:l(R?.totalCompleted),tone:`green`,compact:!0}),(0,w.jsx)(h,{label:`Failed`,value:l(R?.totalFailed),tone:R?.totalFailed?`red`:`default`,compact:!0}),(0,w.jsx)(h,{label:`Error Rate`,value:m(z),tone:z>.05?`red`:`green`,compact:!0})]}),(0,w.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,w.jsx)(`div`,{className:`w-48`,children:(0,w.jsxs)(b,{value:n,onChange:e=>r(e.target.value),children:[(0,w.jsx)(`option`,{value:T,children:`All Queues`}),(j?.queues??[]).map(e=>(0,w.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,w.jsx)(x,{options:E,value:D,onChange:O}),(0,w.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,w.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,w.jsx)(`input`,{value:k,onChange:e=>A(e.target.value),placeholder:`Search by ID or name…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),F&&!N&&!P?(0,w.jsx)(c,{label:`Loading jobs…`}):(0,w.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,w.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,w.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,w.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,w.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,w.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,w.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,w.jsx)(`tbody`,{children:L.length===0?(0,w.jsx)(`tr`,{children:(0,w.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:`No jobs found.`})}):L.map(e=>(0,w.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,w.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:e.id}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unnamed`}),(0,w.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,w.jsx)(`td`,{className:`px-5 py-3`,children:(0,w.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:v(e.createdAt)}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:_(u(e.startedAt??void 0,e.completedAt??void 0))}),(0,w.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,w.jsx)(o,{"aria-label":`Cancel job`,disabled:!S(e.state??e.status).cancel,onClick:()=>B(e.id),children:(0,w.jsx)(s,{className:`size-3.5`})})})]},`${e.queue}:${e.id}`))})]})})]})}export{D as Jobs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-BcouBxpZ.js";import{A as o,B as s,I as c,J as ee,K as l,T as u,W as te,Y as ne,a as d,b as re,c as ie,g as ae,h as oe,l as se,m as f,n as ce,nt as p,o as le,rt as m,w as h,x as ue,z as de}from"./index-BOcegTHa.js";import{a as fe,i as pe}from"./form-DGinTEEb.js";import{t as me}from"./Pagination-D4ki-pGz.js";import{t as g}from"./jobActions-CuOdMglt.js";import{t as he}from"./exportFile-tdUeW5m5.js";var _=e(r(),1),v=a(),y=[`all`,`waiting`,`active`,`completed`,`failed`],b=25;function ge(e=0){return e>=10?{t:`HIGH`,c:`text-warning`}:e>=1?{t:`MEDIUM`,c:`text-blue-400`}:{t:`LOW`,c:`text-faint`}}function x(e){let t=g(e.state);return t.retryActive?p.retryJob(e.id):t.retryDlq?p.retryDlq(e.queue??``,e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not retryable`))}function S(){let[e,r]=n(),[a,S]=(0,_.useState)(e.get(`queue`)??``),[C,_e]=(0,_.useState)(()=>{let t=e.get(`status`);return t&&y.includes(t)?t:`all`}),[w,ve]=(0,_.useState)(``),[T,E]=(0,_.useState)(0),[D,O]=(0,_.useState)(new Set),[ye,k]=(0,_.useState)(new Set),[A,j]=(0,_.useState)(!1),[M,N]=(0,_.useState)(null),{data:P}=o(()=>p.queuesSummary(),[],{intervalMs:3e4}),{data:be}=o(()=>p.overview(),[],{intervalMs:1e4});(0,_.useEffect)(()=>{!a&&P?.length&&S(P[0].name)},[P,a]);let F=`${a}|${C}|${T}`,{data:I,error:L,loading:R,refetch:z}=o((0,_.useCallback)(async()=>{if(!a)return{view:F,jobs:[]};let e=C===`all`?void 0:[C],t=await p.jobsList(a,e,b,T*b);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??a}))}},[a,C,T,F]),[a,C,T]),B=I&&I.view===F?I.jobs:null,xe=(B?.length??0)===b,V=(0,_.useMemo)(()=>{let e=w.trim().toLowerCase();return e?(B??[]).filter(t=>t.id.toLowerCase().includes(e)):B??[]},[B,w]),H=be?.stats,U=(0,_.useMemo)(()=>(P??[]).reduce((e,t)=>e+(t.counts?.failed??0),0),[P]),W=H?ce(H.completed,U):null,G=e=>H?ie(e):`—`,K=()=>E(0),q=(e,t)=>{let n={};e&&(n.queue=e),t!==`all`&&(n.status=t),r(n,{replace:!0})};(0,_.useEffect)(()=>{O(new Set)},[a,C,T]);let Se=e=>O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),J=V.length>0&&V.every(e=>D.has(e.id)),Ce=()=>O(()=>J?new Set:new Set(V.map(e=>e.id))),Y=async(e,t,n,r)=>{if(!(r&&!window.confirm(r))){k(t=>new Set(t).add(e.id)),N(null);try{await n(),N({ok:!0,text:`${t} ✓`}),m.success(`${t} ✓`,e.id)}catch(e){N({ok:!1,text:`${t} failed: ${e.message}`}),m.error(`${t} failed`,e.message)}finally{k(t=>{let n=new Set(t);return n.delete(e.id),n}),z()}}},X=async(e,t,n,r)=>{let i=V.filter(e=>D.has(e.id)&&n(e));if(i.length===0||r&&!window.confirm(r(i.length)))return;j(!0),N(null);let a=await Promise.allSettled(i.map(t)),o=a.filter(e=>e.status===`fulfilled`).length,s=a.length-o,c=`${e}: ${o} succeeded${s?`, ${s} failed`:``}`;N({ok:s===0,text:c}),s===0?m.success(c):m.error(c),O(new Set),j(!1),z()},Z={retry:e=>{let t=g(e.state);return t.retryActive||t.retryDlq},promote:e=>g(e.state).promote,requeue:e=>g(e.state).requeueCompleted,fail:e=>g(e.state).fail,cancel:e=>g(e.state).cancel},Q=V.filter(e=>D.has(e.id)),$={retry:Q.some(Z.retry),promote:Q.some(Z.promote),requeue:Q.some(Z.requeue),fail:Q.some(Z.fail),cancel:Q.some(Z.cancel)};return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(oe,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0,actions:(0,v.jsxs)(h,{size:`sm`,disabled:!B||V.length===0,onClick:()=>{if(V.length===0){m.info(`No jobs to export on this page`);return}let e=V.map(e=>({id:e.id,queue:e.queue??a,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));he(`jobs-${a}-${C}`,e,[`id`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,v.jsx)(de,{className:`size-3.5`}),` Export CSV`]})}),(0,v.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,v.jsx)(f,{label:`Total`,value:G((H?.completed??0)+U+(H?.waiting??0)+(H?.active??0)+(H?.delayed??0)),hint:`all queues`,compact:!0}),(0,v.jsx)(f,{label:`Waiting`,value:G(H?.waiting),tone:`amber`,compact:!0}),(0,v.jsx)(f,{label:`Active`,value:G(H?.active),tone:`blue`,compact:!0}),(0,v.jsx)(f,{label:`Completed`,value:G(H?.completed),tone:`green`,compact:!0}),(0,v.jsx)(f,{label:`Failed`,value:G(U),tone:U?`red`:`default`,compact:!0}),(0,v.jsx)(f,{label:`Error Rate`,value:W==null?`—`:se(W),tone:W==null?`default`:W>.05?`red`:`green`,compact:!0})]}),(0,v.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`div`,{className:`w-48`,children:(0,v.jsx)(fe,{value:a,"aria-label":`Queue`,onChange:e=>{S(e.target.value),K(),q(e.target.value,C)},children:(P??[]).map(e=>(0,v.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,v.jsx)(pe,{options:y,value:C,onChange:e=>{_e(e),K(),q(a,e)}}),(0,v.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,v.jsx)(ee,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,v.jsx)(`input`,{value:w,onChange:e=>ve(e.target.value),placeholder:`Filter this page by ID…`,"aria-label":`Filter by job ID`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),D.size>0&&(0,v.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,v.jsxs)(`span`,{className:`mr-1 text-muted`,children:[D.size,` selected`]}),$.retry&&(0,v.jsx)(h,{size:`sm`,disabled:A,onClick:()=>X(`Retry`,x,Z.retry),children:`Retry selected`}),$.promote&&(0,v.jsx)(h,{size:`sm`,disabled:A,onClick:()=>X(`Promote`,e=>p.promoteJob(e.id),Z.promote),children:`Promote selected`}),$.requeue&&(0,v.jsx)(h,{size:`sm`,disabled:A,onClick:()=>X(`Requeue`,e=>p.retryCompleted(e.queue??``,e.id),Z.requeue),children:`Requeue selected`}),$.fail&&(0,v.jsx)(h,{variant:`warning`,size:`sm`,disabled:A,onClick:()=>X(`Fail`,e=>p.failJob(e.id),Z.fail,e=>`Force-fail ${e} job(s)?`),children:`Fail selected`}),$.cancel&&(0,v.jsx)(h,{variant:`danger`,size:`sm`,disabled:A,onClick:()=>X(`Cancel`,e=>p.cancelJob(e.id),Z.cancel,e=>`Cancel ${e} job(s)? This cannot be undone.`),children:`Cancel selected`}),!$.retry&&!$.promote&&!$.requeue&&!$.fail&&!$.cancel&&(0,v.jsx)(`span`,{className:`text-xs text-faint`,children:`No actions apply to the selected job states.`})]}),M&&(0,v.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),L&&(0,v.jsx)(ue,{onRetry:z}),R&&!B&&!L?(0,v.jsx)(re,{label:`Loading jobs…`}):(0,v.jsxs)(v.Fragment,{children:[a&&(0,v.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,v.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,v.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:a})]}),(0,v.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,v.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,v.jsx)(`th`,{scope:`col`,className:`w-10 px-5 py-3`,children:(0,v.jsx)(`input`,{type:`checkbox`,checked:J,onChange:Ce,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,v.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,v.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Status`}),(0,v.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Priority`}),(0,v.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,v.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,v.jsx)(`th`,{scope:`col`,className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,v.jsx)(`tbody`,{children:V.length===0?(0,v.jsx)(`tr`,{children:(0,v.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:w.trim()?`No jobs on this page match your ID filter.`:a?`No jobs found.`:`Select a queue.`})}):V.map(e=>{let n=ge(e.priority),r=g(e.state),a=ye.has(e.id);return(0,v.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,v.jsx)(`td`,{className:`px-5 py-3`,children:(0,v.jsx)(`input`,{type:`checkbox`,checked:D.has(e.id),onChange:()=>Se(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,v.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,v.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,v.jsx)(`td`,{className:`px-5 py-3`,children:(0,v.jsx)(ae,{status:String(e.state??`waiting`)})}),(0,v.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.c),children:n.t}),(0,v.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:d(e.createdAt)}),(0,v.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:le(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,v.jsx)(`td`,{className:`px-5 py-3`,children:(0,v.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,v.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,children:(0,v.jsx)(u,{"aria-label":`Inspect job`,children:(0,v.jsx)(s,{className:`size-3.5`})})}),r.promote&&(0,v.jsx)(u,{"aria-label":`Promote job`,disabled:a,onClick:()=>Y(e,`Promote`,()=>p.promoteJob(e.id)),children:(0,v.jsx)(te,{className:`size-3.5`})}),(r.retryActive||r.retryDlq)&&(0,v.jsx)(u,{"aria-label":`Retry job`,disabled:a,onClick:()=>Y(e,`Retry`,()=>x(e)),children:(0,v.jsx)(l,{className:`size-3.5`})}),r.requeueCompleted&&(0,v.jsx)(u,{"aria-label":`Requeue job`,disabled:a,onClick:()=>Y(e,`Requeue`,()=>p.retryCompleted(e.queue??``,e.id)),children:(0,v.jsx)(l,{className:`size-3.5`})}),r.fail&&(0,v.jsx)(u,{"aria-label":`Fail job`,disabled:a,onClick:()=>Y(e,`Fail`,()=>p.failJob(e.id),`Force-fail this active job?`),children:(0,v.jsx)(c,{className:`size-3.5`})}),r.cancel&&(0,v.jsx)(u,{"aria-label":`Cancel job`,disabled:a,onClick:()=>Y(e,`Cancel`,()=>p.cancelJob(e.id),`Cancel this job?`),children:(0,v.jsx)(ne,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,v.jsx)(me,{page:T,pageSize:b,hasNext:xe,onPageChange:E,label:`jobs`})]})]})}export{S as JobsPro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{A as r,H as i,J as a,c as o,g as s,h as c,j as l,m as u,t as d,u as f,v as p,x as m}from"./index-BOcegTHa.js";import{a as h,i as g}from"./form-DGinTEEb.js";import{t as _}from"./Pagination-D4ki-pGz.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;function C(){let[e,t]=(0,v.useState)(b),[n,C]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O}=r(()=>l.queues(500),[],{intervalMs:3e4}),{events:k,counters:A,throughput:j,connected:M}=d(e===b?void 0:e),N=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return k.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[k,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let P=Math.max(1,Math.ceil(N.length/S)),F=Math.min(E,P-1);return(0,y.jsxs)(`div`,{children:[!M&&k.length===0&&(0,y.jsx)(m,{}),(0,y.jsx)(c,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:M}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(u,{label:`Total Events`,value:o(A.total),compact:!0}),(0,y.jsx)(u,{label:`Completed`,value:o(A.completed),tone:`green`,compact:!0}),(0,y.jsx)(u,{label:`Failed`,value:o(A.failed),tone:A.failed?`red`:`default`,compact:!0}),(0,y.jsx)(u,{label:`Waiting`,value:o(A.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(u,{label:`Active`,value:o(A.active),tone:`blue`,compact:!0}),(0,y.jsx)(u,{label:`Throughput`,value:`${j.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(h,{value:e,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(g,{options:x,value:n,onChange:C}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),N.length===0?(0,y.jsx)(p,{icon:(0,y.jsx)(i,{}),title:M?`Waiting for activity…`:`Connecting to the event stream…`,hint:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:N.slice(F*S,F*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(s,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:f(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(_,{page:F,pageSize:S,total:N.length,onPageChange:D,label:`events`})]})}export{C as Logs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,r as n,t as r}from"./react-vendor-BcouBxpZ.js";import{A as i,J as a,O as o,c as s,g as c,h as l,m as u,nt as d,t as f,u as p,w as m,x as h}from"./index-BOcegTHa.js";import{a as g,i as _}from"./form-DGinTEEb.js";import{t as v}from"./Pagination-D4ki-pGz.js";var y=e(t(),1),b=r(),x=`__all__`,S=[`all`,`waiting`,`active`,`completed`,`failed`],C=10,w=250;function T(){let[e,t]=(0,y.useState)(x),[r,T]=(0,y.useState)(`all`),[E,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(0),[A,j]=(0,y.useState)(null),M=A!==null,{data:N,error:P,refetch:F}=i(()=>d.queues(),[],{intervalMs:3e4}),{events:I,counters:L,throughput:R,connected:z}=f(e===x?void 0:e),B=(0,y.useMemo)(()=>{let e=A??I,t=E.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[I,A,r,E]),V=M?Math.max(0,(I[0]?.seq??0)-(A[0]?.seq??0)):0;(0,y.useEffect)(()=>k(0),[e,r,E]),(0,y.useEffect)(()=>j(null),[e]);let H=O*C,U=B.slice(H,H+C);return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:z&&!M}),P&&(0,b.jsx)(h,{onRetry:F}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,b.jsx)(u,{label:`Total Events`,value:s(L.total),compact:!0}),(0,b.jsx)(u,{label:`Completed`,value:s(L.completed),tone:`green`,compact:!0}),(0,b.jsx)(u,{label:`Failed`,value:s(L.failed),tone:L.failed?`red`:`default`,compact:!0}),(0,b.jsx)(u,{label:`Waiting`,value:s(L.waiting),tone:`amber`,compact:!0}),(0,b.jsx)(u,{label:`Active`,value:s(L.active),tone:`blue`,compact:!0}),(0,b.jsx)(u,{label:`Throughput`,value:`${R.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,b.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-48`,children:(0,b.jsxs)(g,{"aria-label":`Filter by queue`,value:e,onChange:e=>t(e.target.value),children:[(0,b.jsx)(`option`,{value:x,children:`All Queues`}),(N?.queues??[]).map(e=>(0,b.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,b.jsx)(_,{options:S,value:r,onChange:T}),(0,b.jsx)(m,{size:`sm`,variant:M?`warning`:`default`,onClick:()=>j(M?null:I),title:M?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:M?`Resume${V?` — ${s(V)} new`:``}`:`Following · Pause`}),(0,b.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,b.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,b.jsx)(`input`,{"aria-label":`Search by job ID or queue`,value:E,onChange:e=>D(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,b.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,w,` streamed events held in this browser.`]}),(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,b.jsx)(`tbody`,{children:U.length===0?(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:z?I.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):U.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(c,{status:e.status})}),(0,b.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,b.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:p(e.timestamp)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,b.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,b.jsx)(o,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,b.jsx)(v,{page:O,pageSize:C,total:B.length,onPageChange:k,label:`events`})]})}export{T as LogsPro};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./react-vendor-BcouBxpZ.js";import{C as t,O as n,S as r,h as i,m as a}from"./index-BOcegTHa.js";var o=e(),s=`{
|
|
2
2
|
"mcpServers": {
|
|
3
3
|
"bunqueue": {
|
|
4
4
|
"command": "bunx",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./react-vendor-BcouBxpZ.js";import{A as t,C as n,S as r,b as i,c as a,h as o,j as s,m as c,r as l,x as u}from"./index-BOcegTHa.js";var d=e(),f={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function p(){let{data:e,error:p,loading:g,refetch:_}=t(()=>s.overview(),[]);if(g&&!e&&!p)return(0,d.jsx)(i,{label:`Loading metrics…`});let{stats:v,throughput:y,latency:b,memory:x,collections:S}=e??f,C={};for(let[e,t]of Object.entries(b.percentiles??{}))t&&typeof t==`object`&&(C[`${e} p50`]=t.p50,C[`${e} p95`]=t.p95,C[`${e} p99`]=t.p99);return(0,d.jsxs)(`div`,{children:[p&&(0,d.jsx)(u,{onRetry:_}),(0,d.jsx)(o,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!0}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,d.jsx)(c,{label:`Pushed /s`,value:y.pushPerSec.toFixed(1),compact:!0}),(0,d.jsx)(c,{label:`Pulled /s`,value:y.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,d.jsx)(c,{label:`Completed /s`,value:y.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,d.jsx)(c,{label:`Failed /s`,value:y.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,d.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,d.jsxs)(r,{children:[(0,d.jsx)(n,{title:`Totals`}),(0,d.jsx)(m,{rows:[[`Pushed`,a(v.totalPushed)],[`Pulled`,a(v.totalPulled)],[`Completed`,a(v.totalCompleted)],[`Failed`,a(v.totalFailed)]]})]}),(0,d.jsxs)(r,{children:[(0,d.jsx)(n,{title:`Memory`}),(0,d.jsx)(m,{rows:[[`Heap Used`,l(x.heapUsed*1024*1024)],[`Heap Total`,l(x.heapTotal*1024*1024)],[`RSS`,l(x.rss*1024*1024)]]})]}),(0,d.jsxs)(r,{children:[(0,d.jsx)(n,{title:`Latency — percentiles (ms)`}),(0,d.jsx)(h,{record:C,suffix:`ms`})]}),(0,d.jsxs)(r,{children:[(0,d.jsx)(n,{title:`Latency — averages (ms)`}),(0,d.jsx)(h,{record:b.averages,suffix:`ms`})]})]}),(0,d.jsx)(`div`,{className:`mt-6`,children:(0,d.jsxs)(r,{children:[(0,d.jsx)(n,{title:`In-memory collections`}),(0,d.jsx)(h,{record:S})]})})]})}function m({rows:e}){return(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,d.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function h({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,d.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,d.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,d.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,d.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,d.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?a(Math.round(n*100)/100):String(n),t&&(0,d.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{p as Metrics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-B68RYDeC.js";import{A as i,C as a,S as o,b as s,c,d as l,h as u,i as d,l as f,m as p,n as m,nt as h,x as g}from"./index-BjRjwWwc.js";import{t as _}from"./Pagination-BQg6KGW1.js";import{t as v}from"./AreaChart-Dl_9G6GH.js";import{n as y,t as b}from"./useThroughputSeries-defI_JpV.js";var x=e(n(),1),S=r(),C=[`-60s`,`-45s`,`-30s`,`-15s`,`now`],w=15,T=[`push`,`pull`,`ack`],E=100,D={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}}};function O(){let e=y(60),[n,r]=(0,x.useState)(0),{data:O,error:M,loading:N,refetch:P}=i(async()=>({details:await h.queuesSummary()}),[]),F=O?.details??[],I=Math.max(1,Math.ceil(F.length/w)),L=Math.min(n,I-1),R=(0,x.useMemo)(()=>F.slice(L*w,L*w+w),[F,L]),z=(0,x.useMemo)(()=>F.reduce((e,t)=>e+(t.counts?.failed??0),0),[F]);if(N&&!O&&!M)return(0,S.jsx)(s,{label:`Loading metrics…`});let{stats:B,throughput:V,latency:H}=e.latest??D,U=m(B.completed,z),W=b(e.depth),G=e.depth.length?e.depth[e.depth.length-1]:0;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(u,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:!M}),M&&(0,S.jsx)(g,{onRetry:P}),(0,S.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,S.jsx)(p,{label:`Total Completed`,value:d(B.completed),tone:`green`,hint:`recorded jobs`}),(0,S.jsx)(p,{label:`Total Failed`,value:c(z),tone:z?`red`:`default`,hint:`recorded jobs`}),(0,S.jsx)(p,{label:`Push/sec`,value:V.pushPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`}),(0,S.jsx)(p,{label:`Pull/sec`,value:V.pullPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`})]}),(0,S.jsxs)(o,{className:`mb-6`,children:[(0,S.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,S.jsx)(A,{color:`#ec4899`,label:`Pushed`,value:V.pushPerSec}),(0,S.jsx)(A,{color:`#34d399`,label:`Completed`,value:V.completePerSec}),(0,S.jsx)(A,{color:`#f87171`,label:`Failed`,value:V.failPerSec})]})]}),(0,S.jsx)(v,{xLabels:C,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]})]}),(0,S.jsxs)(o,{className:`mb-6`,children:[(0,S.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Backlog over time (waiting + active + delayed). The trend says whether you're draining or falling behind — more useful than any single gauge.`})]}),(0,S.jsxs)(`div`,{className:`text-right`,children:[(0,S.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:c(G)}),(0,S.jsx)(`div`,{className:t(`text-xs font-medium`,W.label===`draining`?`text-success`:W.label===`accumulating`?`text-danger`:`text-faint`),children:W.label===`steady`?`steady`:`${W.slope>0?`+`:``}${W.slope.toFixed(1)}/s · ${W.label}`})]})]}),(0,S.jsx)(v,{xLabels:C,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:W.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]})]}),(0,S.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,S.jsxs)(o,{children:[(0,S.jsx)(a,{title:`Error Rate`}),(0,S.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U!=null&&U>.05?`text-danger`:`text-fg`),children:U==null?`—`:f(U)}),(0,S.jsx)(`div`,{className:`text-xs text-faint`,children:`error rate`})]}),(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U==null?`text-fg`:`text-success`),children:U==null?`—`:f(1-U)}),(0,S.jsx)(`div`,{className:`text-xs text-faint`,children:`success rate`})]})]}),U==null?(0,S.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,S.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-U)*100}%`}})})]}),(0,S.jsxs)(o,{children:[(0,S.jsx)(a,{title:`Server Overview`}),(0,S.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,S.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,S.jsx)(j,{color:`bg-blue-400`,label:`Queued`,value:c(B.waiting)}),(0,S.jsx)(j,{color:`bg-accent`,label:`Processing`,value:c(B.active)}),(0,S.jsx)(j,{color:`bg-amber-400`,label:`Delayed`,value:c(B.delayed)}),(0,S.jsx)(j,{color:`bg-red-400`,label:`Dead Letter`,value:c(B.dlq)}),(0,S.jsx)(j,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:d(B.totalPushed)}),(0,S.jsx)(j,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:d(B.totalPulled)}),(0,S.jsx)(j,{color:`bg-emerald-400`,label:`Uptime`,value:l(B.uptime/1e3)})]})]})]}),(0,S.jsxs)(o,{className:`mb-6`,padded:!1,children:[(0,S.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,S.jsx)(`tbody`,{children:T.map(e=>{let n=H?.percentiles?.[e],r=H?.averages?.[`${e}Ms`];return(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:e}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(r)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p50)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p95)}),(0,S.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(n?.p99??0)>E?`text-warning`:`text-muted`),children:k(n?.p99)})]},e)})})]})})]}),(0,S.jsxs)(o,{padded:!1,children:[(0,S.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,S.jsx)(`tbody`,{children:R.length===0?(0,S.jsx)(`tr`,{children:(0,S.jsx)(`td`,{colSpan:6,className:`px-5 py-12 text-center text-sm text-faint`,children:`No queues yet.`})}):R.map(e=>(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,S.jsx)(`td`,{className:`px-5 py-3`,children:(0,S.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:c(e.counts.waiting)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:c(e.counts.active)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:c(e.counts.completed)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:c(e.counts.failed)})]},e.name))})]})}),(0,S.jsx)(`div`,{className:`px-5 pb-4`,children:(0,S.jsx)(_,{page:L,pageSize:w,total:F.length,onPageChange:r,label:`queues`})})]})]})}function k(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}function A({color:e,label:t,value:n}){return(0,S.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,S.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}function j({color:e,label:n,value:r}){return(0,S.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,S.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,S.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,S.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}export{O as MetricsPro};
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-BcouBxpZ.js";import{A as i,C as a,S as o,b as s,c,d as l,h as u,i as d,l as f,m as p,n as m,nt as h,x as g}from"./index-BOcegTHa.js";import{t as _}from"./Pagination-D4ki-pGz.js";import{t as v}from"./AreaChart-2gM0YoZT.js";import{n as y,t as b}from"./useThroughputSeries-Chp5OLx3.js";var x=e(n(),1),S=r(),C=[`-60s`,`-45s`,`-30s`,`-15s`,`now`],w=15,T=[`push`,`pull`,`ack`],E=100,D={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}}};function O(){let e=y(60),[n,r]=(0,x.useState)(0),{data:O,error:M,loading:N,refetch:P}=i(async()=>({details:await h.queuesSummary()}),[]),F=O?.details??[],I=Math.max(1,Math.ceil(F.length/w)),L=Math.min(n,I-1),R=(0,x.useMemo)(()=>F.slice(L*w,L*w+w),[F,L]),z=(0,x.useMemo)(()=>F.reduce((e,t)=>e+(t.counts?.failed??0),0),[F]);if(N&&!O&&!M)return(0,S.jsx)(s,{label:`Loading metrics…`});let{stats:B,throughput:V,latency:H}=e.latest??D,U=m(B.completed,z),W=b(e.depth),G=e.depth.length?e.depth[e.depth.length-1]:0;return(0,S.jsxs)(`div`,{children:[(0,S.jsx)(u,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:!M}),M&&(0,S.jsx)(g,{onRetry:P}),(0,S.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,S.jsx)(p,{label:`Total Completed`,value:d(B.completed),tone:`green`,hint:`recorded jobs`}),(0,S.jsx)(p,{label:`Total Failed`,value:c(z),tone:z?`red`:`default`,hint:`recorded jobs`}),(0,S.jsx)(p,{label:`Push/sec`,value:V.pushPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`}),(0,S.jsx)(p,{label:`Pull/sec`,value:V.pullPerSec.toFixed(1),tone:`accent`,hint:`jobs/sec`})]}),(0,S.jsxs)(o,{className:`mb-6`,children:[(0,S.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,S.jsx)(A,{color:`#ec4899`,label:`Pushed`,value:V.pushPerSec}),(0,S.jsx)(A,{color:`#34d399`,label:`Completed`,value:V.completePerSec}),(0,S.jsx)(A,{color:`#f87171`,label:`Failed`,value:V.failPerSec})]})]}),(0,S.jsx)(v,{xLabels:C,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]})]}),(0,S.jsxs)(o,{className:`mb-6`,children:[(0,S.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Backlog over time (waiting + active + delayed). The trend says whether you're draining or falling behind — more useful than any single gauge.`})]}),(0,S.jsxs)(`div`,{className:`text-right`,children:[(0,S.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:c(G)}),(0,S.jsx)(`div`,{className:t(`text-xs font-medium`,W.label===`draining`?`text-success`:W.label===`accumulating`?`text-danger`:`text-faint`),children:W.label===`steady`?`steady`:`${W.slope>0?`+`:``}${W.slope.toFixed(1)}/s · ${W.label}`})]})]}),(0,S.jsx)(v,{xLabels:C,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:W.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]})]}),(0,S.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,S.jsxs)(o,{children:[(0,S.jsx)(a,{title:`Error Rate`}),(0,S.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U!=null&&U>.05?`text-danger`:`text-fg`),children:U==null?`—`:f(U)}),(0,S.jsx)(`div`,{className:`text-xs text-faint`,children:`error rate`})]}),(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,U==null?`text-fg`:`text-success`),children:U==null?`—`:f(1-U)}),(0,S.jsx)(`div`,{className:`text-xs text-faint`,children:`success rate`})]})]}),U==null?(0,S.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,S.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-U)*100}%`}})})]}),(0,S.jsxs)(o,{children:[(0,S.jsx)(a,{title:`Server Overview`}),(0,S.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,S.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,S.jsx)(j,{color:`bg-blue-400`,label:`Queued`,value:c(B.waiting)}),(0,S.jsx)(j,{color:`bg-accent`,label:`Processing`,value:c(B.active)}),(0,S.jsx)(j,{color:`bg-amber-400`,label:`Delayed`,value:c(B.delayed)}),(0,S.jsx)(j,{color:`bg-red-400`,label:`Dead Letter`,value:c(B.dlq)}),(0,S.jsx)(j,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:d(B.totalPushed)}),(0,S.jsx)(j,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:d(B.totalPulled)}),(0,S.jsx)(j,{color:`bg-emerald-400`,label:`Uptime`,value:l(B.uptime/1e3)})]})]})]}),(0,S.jsxs)(o,{className:`mb-6`,padded:!1,children:[(0,S.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,S.jsx)(`tbody`,{children:T.map(e=>{let n=H?.percentiles?.[e],r=H?.averages?.[`${e}Ms`];return(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:e}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(r)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p50)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:k(n?.p95)}),(0,S.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(n?.p99??0)>E?`text-warning`:`text-muted`),children:k(n?.p99)})]},e)})})]})})]}),(0,S.jsxs)(o,{padded:!1,children:[(0,S.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,S.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,S.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,S.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,S.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,S.jsx)(`tbody`,{children:R.length===0?(0,S.jsx)(`tr`,{children:(0,S.jsx)(`td`,{colSpan:6,className:`px-5 py-12 text-center text-sm text-faint`,children:`No queues yet.`})}):R.map(e=>(0,S.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,S.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,S.jsx)(`td`,{className:`px-5 py-3`,children:(0,S.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:c(e.counts.waiting)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:c(e.counts.active)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:c(e.counts.completed)}),(0,S.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:c(e.counts.failed)})]},e.name))})]})}),(0,S.jsx)(`div`,{className:`px-5 pb-4`,children:(0,S.jsx)(_,{page:L,pageSize:w,total:F.length,onPageChange:r,label:`queues`})})]})]})}function k(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}function A({color:e,label:t,value:n}){return(0,S.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,S.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}function j({color:e,label:n,value:r}){return(0,S.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,S.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,S.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,S.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}export{O as MetricsPro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./react-vendor-BcouBxpZ.js";import{A as t,C as n,L as r,S as i,X as a,b as o,c as s,d as c,h as l,j as u,l as d,m as f,n as p,r as m,x as h}from"./index-BOcegTHa.js";var g=e(),_={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function v(){let{data:e,error:v,loading:x,refetch:S}=t(()=>u.overview(),[]);if(x&&!e&&!v)return(0,g.jsx)(o,{label:`Loading overview…`});let{stats:C,throughput:w,memory:T,workers:E,crons:D,storage:O}=e??_,k=p(C.totalCompleted,C.totalFailed)??0;return(0,g.jsxs)(`div`,{children:[v&&(0,g.jsx)(h,{onRetry:S}),(0,g.jsx)(l,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!0}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,g.jsx)(f,{label:`Waiting`,value:s(C.waiting),tone:`amber`}),(0,g.jsx)(f,{label:`Active`,value:s(C.active),tone:`blue`}),(0,g.jsx)(f,{label:`Completed`,value:s(C.totalCompleted),tone:`green`}),(0,g.jsx)(f,{label:`Failed`,value:s(C.totalFailed),tone:`red`}),(0,g.jsx)(f,{label:`DLQ`,value:s(C.dlq),tone:C.dlq>0?`red`:`default`}),(0,g.jsx)(f,{label:`Error Rate`,value:d(k),tone:k>.05?`red`:`green`})]}),(0,g.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(i,{children:[(0,g.jsx)(n,{title:`Throughput`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,g.jsx)(y,{label:`Pushed`,value:w.pushPerSec,tone:`text-fg`}),(0,g.jsx)(y,{label:`Pulled`,value:w.pullPerSec,tone:`text-blue-400`}),(0,g.jsx)(y,{label:`Completed`,value:w.completePerSec,tone:`text-emerald-400`}),(0,g.jsx)(y,{label:`Failed`,value:w.failPerSec,tone:`text-red-400`})]})]}),(0,g.jsxs)(i,{children:[(0,g.jsx)(n,{title:`Resources`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,g.jsx)(b,{label:`Uptime`,value:c(C.uptime/1e3)}),(0,g.jsx)(b,{label:`Heap`,value:m(T.heapUsed*1024*1024)}),(0,g.jsx)(b,{label:`RSS`,value:m(T.rss*1024*1024)}),(0,g.jsx)(b,{label:`Storage`,value:O.diskFull?`Disk full`:`Healthy`,tone:O.diskFull?`text-red-400`:`text-emerald-400`})]})]})]}),(0,g.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsxs)(i,{children:[(0,g.jsx)(n,{title:`Workers`,icon:(0,g.jsx)(a,{className:`size-4 text-faint`}),action:(0,g.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,g.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:E.active}),` /`,` `,E.total,` active`]})}),E.list.length===0?(0,g.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,g.jsx)(`ul`,{className:`divide-y divide-line`,children:E.list.slice(0,6).map(e=>(0,g.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,g.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,g.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,s(e.processedJobs),` done`]})]},e.id))})]}),(0,g.jsxs)(i,{children:[(0,g.jsx)(n,{title:`Cron Jobs`,icon:(0,g.jsx)(r,{className:`size-4 text-faint`}),action:(0,g.jsxs)(`span`,{className:`text-sm text-muted`,children:[D.total,` scheduled`]})}),D.list.length===0?(0,g.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,g.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,g.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,g.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,g.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function y({label:e,value:t,tone:n}){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,g.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,g.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function b({label:e,value:t,tone:n=`text-fg`}){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,g.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{v as Overview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{c as r}from"./index-BOcegTHa.js";var i=e(t(),1),a=n();function o({page:e,pageSize:t,total:n,hasNext:o,onPageChange:s,label:c=`items`,className:l}){let u=n!=null,d=u?Math.max(1,Math.ceil(n/t)):void 0;(0,i.useEffect)(()=>{u&&e>d-1&&s(d-1)},[u,e,d,s]);let f=u?Math.min(e,d-1):e,p=f*t,m=f>0,h=u?f<d-1:!!o;if(u&&n<=t&&f===0)return null;let g=u?n===0?`No ${c}`:`${r(p+1)}–${r(Math.min(p+t,n))} of ${r(n)} ${c}`:`Page ${f+1}`;return(0,a.jsxs)(`div`,{className:`mt-4 flex items-center justify-between text-sm text-faint ${l??``}`,children:[(0,a.jsx)(`span`,{children:g}),(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsx)(`button`,{type:`button`,disabled:!m,onClick:()=>s(f-1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Previous`}),(0,a.jsx)(`span`,{className:`rounded-md bg-accent/15 px-2.5 py-1 text-xs font-medium text-accent tnum`,children:u?`${f+1} / ${d}`:f+1}),(0,a.jsx)(`button`,{type:`button`,disabled:!h,onClick:()=>s(f+1),className:`rounded-md px-3 py-1 text-xs hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-40 disabled:hover:text-faint`,children:`Next`})]})]})}export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{C as r,S as i,nt as a,w as o}from"./index-BOcegTHa.js";import{n as s,o as c,t as l}from"./form-DGinTEEb.js";var u=e(t(),1),d=n();function f(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}return JSON.stringify(e)}function p(e){let[t,n]=(0,u.useState)(e),r=(0,u.useRef)(f(e));return(0,u.useEffect)(()=>{let t=f(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,e=>{r.current=f(e)}]}function m(e){let t=String(e).trim();if(t===``)return null;let n=Number(t);return Number.isFinite(n)?n:null}function h({queue:e,config:t,onSaved:n}){let[f,h,g]=p(t),[_,v]=(0,u.useState)(null),[y,b]=(0,u.useState)(!1),[x,S]=(0,u.useState)(!1);return(0,d.jsxs)(i,{children:[(0,d.jsx)(r,{title:`Stall detection`}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,d.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,d.jsx)(c,{checked:f.enabled,onChange:e=>h({...f,enabled:e}),label:`enabled`}),(0,d.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,d.jsx)(l,{label:`Stall interval (ms)`,children:(0,d.jsx)(s,{type:`number`,value:f.stallInterval,onChange:e=>h({...f,stallInterval:e.target.value})})}),(0,d.jsx)(l,{label:`Max stalls`,children:(0,d.jsx)(s,{type:`number`,value:f.maxStalls,onChange:e=>h({...f,maxStalls:e.target.value})})}),(0,d.jsx)(l,{label:`Grace period (ms)`,children:(0,d.jsx)(s,{type:`number`,value:f.gracePeriod,onChange:e=>h({...f,gracePeriod:e.target.value})})})]}),(0,d.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,d.jsx)(o,{variant:`accent`,size:`sm`,disabled:y,onClick:async()=>{let t=m(f.stallInterval),r=m(f.maxStalls),i=m(f.gracePeriod);if(t==null||r==null||i==null){v(`All numeric fields must be filled in`);return}b(!0),S(!1);try{v(null);let o={...f,stallInterval:t,maxStalls:r,gracePeriod:i};await a.setStallConfig(e,o),g(o),n(),S(!0),window.setTimeout(()=>S(!1),2e3)}catch(e){v(e.message)}finally{b(!1)}},children:`Save`}),x&&(0,d.jsx)(`span`,{className:`text-xs text-success`,children:`Saved ✓`}),_&&(0,d.jsx)(`span`,{className:`text-xs text-danger`,children:_})]})]})}function g({queue:e,config:t,onSaved:n}){let[f,h,g]=p(t),[_,v]=(0,u.useState)(null),[y,b]=(0,u.useState)(!1),[x,S]=(0,u.useState)(!1);return(0,d.jsxs)(i,{children:[(0,d.jsx)(r,{title:`DLQ policy`}),(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,d.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,d.jsx)(c,{checked:f.autoRetry,onChange:e=>h({...f,autoRetry:e}),label:`auto-retry`}),(0,d.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,d.jsx)(l,{label:`Retry interval (ms)`,children:(0,d.jsx)(s,{type:`number`,value:f.autoRetryInterval,onChange:e=>h({...f,autoRetryInterval:e.target.value})})}),(0,d.jsx)(l,{label:`Max auto-retries`,children:(0,d.jsx)(s,{type:`number`,value:f.maxAutoRetries,onChange:e=>h({...f,maxAutoRetries:e.target.value})})}),(0,d.jsx)(l,{label:`Max age (ms)`,children:(0,d.jsx)(s,{type:`number`,value:f.maxAge??``,onChange:e=>h({...f,maxAge:e.target.value})})}),(0,d.jsx)(l,{label:`Max entries`,children:(0,d.jsx)(s,{type:`number`,value:f.maxEntries,onChange:e=>h({...f,maxEntries:e.target.value})})})]}),(0,d.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,d.jsx)(o,{variant:`accent`,size:`sm`,disabled:y,onClick:async()=>{let t=m(f.autoRetryInterval),r=m(f.maxAutoRetries),i=m(f.maxEntries),o=f.maxAge==null?null:m(f.maxAge);if(t==null||r==null||i==null){v(`All numeric fields must be filled in`);return}b(!0),S(!1);try{v(null);let s={...f,autoRetryInterval:t,maxAutoRetries:r,maxAge:o,maxEntries:i};await a.setDlqConfig(e,s),g(s),n(),S(!0),window.setTimeout(()=>S(!1),2e3)}catch(e){v(e.message)}finally{b(!1)}},children:`Save`}),x&&(0,d.jsx)(`span`,{className:`text-xs text-success`,children:`Saved ✓`}),_&&(0,d.jsx)(`span`,{className:`text-xs text-danger`,children:_})]})]})}function _({title:e,onRetry:t}){return(0,d.jsxs)(i,{children:[(0,d.jsx)(r,{title:e}),(0,d.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,d.jsx)(o,{size:`sm`,onClick:t,children:`Retry`})]})}function v({queue:e,paused:t,busy:n,run:c}){let[f,p]=(0,u.useState)(`0`),[m,h]=(0,u.useState)(`1000`),[g,_]=(0,u.useState)(``);return(0,d.jsxs)(i,{className:`mb-6`,children:[(0,d.jsx)(r,{title:`Lifecycle`}),(0,d.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,d.jsx)(o,{variant:`success`,size:`sm`,disabled:n,onClick:()=>c(`Resumed`,()=>a.resume(e)),children:`Resume`}):(0,d.jsx)(o,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>c(`Paused`,()=>a.pause(e)),children:`Pause`}),(0,d.jsx)(o,{size:`sm`,disabled:n,onClick:()=>c(`Retried completed`,()=>a.retryCompleted(e)),children:`Retry completed`}),(0,d.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,d.jsx)(`div`,{className:`w-24`,children:(0,d.jsx)(l,{label:`Promote N`,children:(0,d.jsx)(s,{type:`number`,value:g,onChange:e=>_(e.target.value),placeholder:`all`})})}),(0,d.jsx)(o,{size:`sm`,disabled:n,onClick:()=>c(`Promoted`,()=>a.promoteJobs(e,g?Number(g):void 0)),children:`Promote delayed`})]})]}),(0,d.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,d.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,d.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,d.jsx)(o,{size:`sm`,disabled:n,onClick:()=>c(`Drained`,()=>a.drain(e),`Drain waiting jobs from "${e}"?`),children:`Drain`}),(0,d.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,d.jsx)(`div`,{className:`w-24`,children:(0,d.jsx)(l,{label:`Grace (ms)`,children:(0,d.jsx)(s,{type:`number`,value:f,onChange:e=>p(e.target.value)})})}),(0,d.jsx)(`div`,{className:`w-24`,children:(0,d.jsx)(l,{label:`Limit`,children:(0,d.jsx)(s,{type:`number`,value:m,onChange:e=>h(e.target.value)})})}),(0,d.jsx)(o,{variant:`danger`,size:`sm`,disabled:n,onClick:()=>c(`Cleaned`,()=>a.clean(e,{grace:Number(f),limit:Number(m)}),`Permanently delete up to ${m} completed/failed jobs older than ${f}ms from "${e}"?`),children:`Clean`})]})]})]})]})}function y({queue:e,busy:t,run:n}){let[c,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(``);return(0,d.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,d.jsxs)(i,{children:[(0,d.jsx)(r,{title:`Rate limit`}),(0,d.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,d.jsx)(`div`,{className:`flex-1`,children:(0,d.jsx)(l,{label:`Limit`,children:(0,d.jsx)(s,{type:`number`,value:c,onChange:e=>f(e.target.value),placeholder:`max per window`})})}),(0,d.jsx)(o,{variant:`accent`,size:`sm`,disabled:t||!c,onClick:()=>n(`Rate limit set`,()=>a.setRateLimit(e,Number(c))),children:`Set`}),(0,d.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Rate limit cleared`,()=>a.clearRateLimit(e)),children:`Clear`})]})]}),(0,d.jsxs)(i,{children:[(0,d.jsx)(r,{title:`Concurrency`}),(0,d.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,d.jsx)(`div`,{className:`flex-1`,children:(0,d.jsx)(l,{label:`Concurrency`,children:(0,d.jsx)(s,{type:`number`,value:p,onChange:e=>m(e.target.value),placeholder:`max in-flight`})})}),(0,d.jsx)(o,{variant:`accent`,size:`sm`,disabled:t||!p,onClick:()=>n(`Concurrency set`,()=>a.setConcurrency(e,Number(p))),children:`Set`}),(0,d.jsx)(o,{size:`sm`,disabled:t,onClick:()=>n(`Concurrency cleared`,()=>a.clearConcurrency(e)),children:`Clear`})]})]})]})}export{h as a,g as i,y as n,_ as r,v as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-BcouBxpZ.js";import{A as r,_ as i,b as a,c as o,h as s,m as c,nt as l,x as u}from"./index-BOcegTHa.js";import{a as d}from"./form-DGinTEEb.js";import{a as f,i as p,n as m,r as h,t as g}from"./QueueActions-DHoSkWRz.js";var _=e(t(),1),v=n(),y=[`waiting`,`active`,`completed`,`failed`,`delayed`,`paused`];function b(){let[e,t]=(0,_.useState)(``),[n,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),{data:C}=r(()=>l.queues(),[],{intervalMs:3e4});(0,_.useEffect)(()=>{!e&&C?.queues?.length&&t(C.queues[0].name)},[C,e]);let{data:w,error:T,loading:E,refetch:D}=r((0,_.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([l.queueDetail(e,!1),l.getStallConfig(e).catch(()=>null),l.getDlqConfig(e).catch(()=>null)]);return{queue:e,detail:t,stall:n?.config??null,dlq:r?.config??null}},[e]),[e]),O=w&&w.queue===e?w:null,k=(e,t,n)=>{n&&!window.confirm(n)||(b(!0),S(null),t().then(t=>{let n=t?.count;S({ok:!0,text:`${e}${n==null?` ✓`:`: ${n}`}`}),D()}).catch(e=>S({ok:!1,text:e.message})).finally(()=>b(!1)))};return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(s,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!0}),(0,v.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`div`,{className:`w-56`,children:(0,v.jsx)(d,{value:e,"aria-label":`Queue`,onChange:e=>t(e.target.value),children:(C?.queues??[]).map(e=>(0,v.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),O?.detail&&(0,v.jsx)(i,{label:O.detail.paused?`Paused`:`Active`,tone:O.detail.paused?`amber`:`green`}),x&&(0,v.jsx)(`span`,{role:`status`,className:x.ok?`text-xs text-success`:`text-xs text-danger`,children:x.text})]}),T&&(0,v.jsx)(u,{onRetry:D}),E&&!O&&!T?(0,v.jsx)(a,{}):O?.detail?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`div`,{className:`mb-6 grid grid-cols-3 gap-3 md:grid-cols-6`,children:y.map(e=>(0,v.jsx)(c,{label:e,value:o(O.detail.counts[e]),compact:!0},e))}),(0,v.jsx)(g,{queue:e,paused:O.detail.paused,busy:n,run:k}),(0,v.jsx)(m,{queue:e,busy:n,run:k}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[O.stall?(0,v.jsx)(f,{queue:e,config:O.stall,onSaved:()=>S({ok:!0,text:`Stall config saved ✓`})},e):(0,v.jsx)(h,{title:`Stall detection`,onRetry:D}),O.dlq?(0,v.jsx)(p,{queue:e,config:O.dlq,onSaved:()=>S({ok:!0,text:`DLQ config saved ✓`})},e):(0,v.jsx)(h,{title:`DLQ policy`,onRetry:D})]})]}):!T&&(0,v.jsx)(`p`,{className:`text-sm text-faint`,children:`Select a queue.`})]})}export{b as QueueControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{d as t,h as n,r,t as i,u as a}from"./react-vendor-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{d as t,h as n,r,t as i,u as a}from"./react-vendor-BcouBxpZ.js";import{A as o,M as s,P as c,S as l,T as u,U as d,V as f,W as p,X as m,_ as h,b as g,c as _,f as v,g as y,j as b,l as x,m as S,n as C,o as w,u as T,w as E,x as D}from"./index-BOcegTHa.js";import{n as O,t as k}from"./form-DGinTEEb.js";var A=e(n(),1),j=i();function M({queue:e}){return(0,j.jsxs)(`div`,{className:`mt-8`,children:[(0,j.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,j.jsx)(P,{queue:e}),(0,j.jsx)(F,{queue:e})]})]})}function N(){let[e,t]=(0,A.useState)(!1),[n,r]=(0,A.useState)(null),[i,a]=(0,A.useState)(!1);return{busy:e,error:n,done:i,run:async e=>{t(!0),r(null),a(!1);try{await e(),a(!0),setTimeout(()=>a(!1),2e3)}catch(e){r(e.message)}finally{t(!1)}}}}function P({queue:e}){let[t,n]=(0,A.useState)(``),{busy:r,error:i,done:a,run:o}=N();return(0,j.jsxs)(l,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,j.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate Limit`}),(0,j.jsx)(f,{className:`size-4 text-faint`})]}),(0,j.jsx)(k,{label:`Max jobs / second`,children:(0,j.jsx)(O,{type:`number`,inputMode:`numeric`,placeholder:`100`,value:t,onChange:e=>n(e.target.value)})}),(0,j.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,j.jsx)(E,{variant:`accent`,size:`sm`,disabled:r||!t,onClick:()=>o(()=>b.setRateLimit(e,Number(t))),children:`Set`}),(0,j.jsx)(E,{size:`sm`,disabled:r,onClick:()=>o(()=>b.clearRateLimit(e)),children:`Clear`}),a&&(0,j.jsx)(`span`,{className:`text-xs text-emerald-400`,children:`Saved`}),i&&(0,j.jsx)(`span`,{className:`text-xs text-red-400`,children:i})]})]})}function F({queue:e}){let[t,n]=(0,A.useState)(``),{busy:r,error:i,done:a,run:o}=N();return(0,j.jsxs)(l,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,j.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency`}),(0,j.jsx)(m,{className:`size-4 text-faint`})]}),(0,j.jsx)(k,{label:`Concurrency`,children:(0,j.jsx)(O,{type:`number`,inputMode:`numeric`,placeholder:`5`,value:t,onChange:e=>n(e.target.value)})}),(0,j.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,j.jsx)(E,{variant:`accent`,size:`sm`,disabled:r||!t,onClick:()=>o(()=>b.setConcurrency(e,Number(t))),children:`Set`}),(0,j.jsx)(E,{size:`sm`,disabled:r,onClick:()=>o(()=>b.clearConcurrency(e)),children:`Clear`}),a&&(0,j.jsx)(`span`,{className:`text-xs text-emerald-400`,children:`Saved`}),i&&(0,j.jsx)(`span`,{className:`text-xs text-red-400`,children:i})]})]})}var I=[`active`,`waiting`,`completed`,`failed`,`delayed`,`paused`],L={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[]};function R(){let{name:e=``}=t(),n=a(),[i,l]=(0,A.useState)(null),[f,m]=(0,A.useState)(null),{data:O,error:k,loading:N,refetch:P}=o((0,A.useCallback)(async()=>{let[t,n]=await Promise.all([b.queueDetail(e,!1),b.jobsList(e,{states:I,limit:12})]);return{detail:t,jobs:n.jobs??[]}},[e]),[e]),F=async(e,t,r)=>{if(!(r&&!window.confirm(r))){l(e),m(null);try{if(await t(),e===`obliterate`){n(`/queues`);return}await P()}catch(e){m(e.message)}finally{l(null)}}};if(N&&!O&&!k)return(0,j.jsx)(g,{label:`Loading ${e}…`});let R=O??L,{detail:z}=R,B=z.counts,V=C(B.completed??0,B.failed??0)??0,H=[...R.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,j.jsxs)(`div`,{children:[k&&(0,j.jsx)(D,{onRetry:P}),(0,j.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,j.jsx)(u,{"aria-label":`Back to queues`,onClick:()=>n(`/queues`),children:(0,j.jsx)(c,{className:`size-4`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,j.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,j.jsx)(h,{label:z.paused?`Paused`:`Active`,tone:z.paused?`amber`:`green`}),(0,j.jsx)(h,{label:`Live`,tone:`green`})]})]})]}),(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[z.paused?(0,j.jsxs)(E,{variant:`success`,size:`sm`,disabled:i!=null,onClick:()=>F(`resume`,()=>b.resume(e)),children:[(0,j.jsx)(p,{className:`size-3.5`}),` Resume`]}):(0,j.jsxs)(E,{variant:`warning`,size:`sm`,disabled:i!=null,onClick:()=>F(`pause`,()=>b.pause(e)),children:[(0,j.jsx)(d,{className:`size-3.5`}),` Pause`]}),(0,j.jsx)(E,{size:`sm`,disabled:i!=null,onClick:()=>F(`drain`,()=>b.drain(e),`Drain all waiting jobs from "${e}"?`),children:`Drain`}),(0,j.jsx)(E,{variant:`danger`,size:`sm`,disabled:i!=null,onClick:()=>F(`obliterate`,()=>b.obliterate(e),`Obliterate "${e}"? This removes the queue and all its jobs.`),children:`Obliterate`})]})]}),f&&(0,j.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:f}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,j.jsx)(S,{label:`Waiting`,value:_(B.waiting),tone:`amber`}),(0,j.jsx)(S,{label:`Active`,value:_(B.active),tone:`blue`}),(0,j.jsx)(S,{label:`Completed`,value:_(B.completed),tone:`green`}),(0,j.jsx)(S,{label:`Failed`,value:_(B.failed),tone:B.failed?`red`:`default`}),(0,j.jsx)(S,{label:`Delayed`,value:_(B.delayed),tone:`default`}),(0,j.jsx)(S,{label:`Error Rate`,value:x(V),tone:V>.05?`red`:`green`})]}),(0,j.jsxs)(`div`,{className:`mt-8`,children:[(0,j.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,j.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,j.jsxs)(r,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,j.jsx)(s,{className:`size-3.5`})]})]}),(0,j.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,j.jsx)(`tbody`,{children:H.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):H.map(e=>(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.id}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(y,{status:String(e.state??e.status??`waiting`)})}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:w(v(e.startedAt,e.completedAt))}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:T(e.createdAt)})]},e.id))})]})})]}),(0,j.jsx)(M,{queue:e})]})}export{R as QueueDetail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{d as n,h as r,r as i,t as a,u as o}from"./react-vendor-BcouBxpZ.js";import{A as s,C as c,M as l,P as u,S as d,T as f,_ as p,b as m,c as h,h as g,l as _,m as v,n as ee,nt as y,o as b,rt as x,v as S,w as C,x as w}from"./index-BOcegTHa.js";import{t as T}from"./AreaChart-2gM0YoZT.js";import{t as E}from"./useThroughputSeries-Chp5OLx3.js";import{a as D,i as O,n as te,r as k,t as A}from"./QueueActions-DHoSkWRz.js";var j=e(r(),1),M=a(),N=[`waiting`,`active`,`completed`,`failed`,`delayed`,`paused`],P=[`active`,`waiting`,`completed`,`failed`,`delayed`],F=2e3;function I(){let{name:e=``}=n(),r=o(),[a,I]=(0,j.useState)(!1),[R,z]=(0,j.useState)(null),{data:B,error:V,loading:H,refetch:U}=s((0,j.useCallback)(async()=>{if(!e)return null;let[t,n,r,i]=await Promise.all([y.queueDetail(e,!1),y.getStallConfig(e).catch(()=>null),y.getDlqConfig(e).catch(()=>null),y.jobsList(e,P,12).catch(()=>({ok:!1,jobs:[]}))]);return{queue:e,detail:t,stall:n?.config??null,dlq:r?.config??null,jobs:i.jobs??[]}},[e]),[e]),W=B&&B.queue===e?B:null,[G,K]=(0,j.useState)([]),q=(0,j.useRef)(null);(0,j.useEffect)(()=>{let e=W?.detail?.counts;e&&(q.current=(e.waiting??0)+(e.active??0)+(e.delayed??0))},[W]),(0,j.useEffect)(()=>{q.current=null,K([]);let e=setInterval(()=>{let e=q.current;e!=null&&K(t=>[...t,e].slice(-40))},F);return()=>clearInterval(e)},[e]);let J=(t,n,r)=>{r&&!window.confirm(r)||(I(!0),z(null),n().then(n=>{let r=n?.count,i=`${t}${r==null?` ✓`:`: ${r}`}`;z({ok:!0,text:i}),x.success(i,e),U()}).catch(e=>{let n=e.message;z({ok:!1,text:n}),x.error(`${t} failed`,n)}).finally(()=>I(!1)))},Y=()=>{window.confirm(`Obliterate "${e}"? This removes the queue and all its jobs.`)&&(I(!0),y.obliterate(e).then(()=>{x.success(`Queue obliterated`,e),r(`/queues`)}).catch(e=>{let t=e.message;z({ok:!1,text:t}),x.error(`Obliterate failed`,t),I(!1)}))},X=W?.detail,Z=X?.counts,Q=Z?ee(Z.completed??0,Z.failed??0):null,$=E(G);return(0,M.jsxs)(`div`,{children:[(0,M.jsx)(g,{title:(0,M.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and live backlog.`,live:!0,back:(0,M.jsx)(f,{"aria-label":`Back to queues`,onClick:()=>r(`/queues`),children:(0,M.jsx)(u,{className:`size-4`})}),actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`Jobs `,(0,M.jsx)(l,{className:`size-3.5`})]}),(0,M.jsxs)(i,{to:`/dlq?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`DLQ `,(0,M.jsx)(l,{className:`size-3.5`})]}),(0,M.jsx)(C,{variant:`danger`,size:`sm`,disabled:a,onClick:Y,children:`Obliterate`})]})}),V&&(0,M.jsx)(w,{onRetry:U}),H&&!W&&!V?(0,M.jsx)(m,{label:`Loading ${e}…`}):!X||!Z?!V&&(0,M.jsx)(S,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,M.jsx)(i,{to:`/queues`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to queues`})}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,M.jsx)(p,{label:X.paused?`Paused`:`Active`,tone:X.paused?`amber`:`green`}),R&&(0,M.jsx)(`span`,{role:`status`,className:R.ok?`text-xs text-success`:`text-xs text-danger`,children:R.text})]}),(0,M.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6`,children:N.map(e=>(0,M.jsx)(v,{label:e,value:h(Z[e]),tone:e===`failed`&&Z.failed?`red`:`default`,compact:!0},e))}),(0,M.jsxs)(d,{padded:!1,className:`mb-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,M.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,M.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,M.jsx)(l,{className:`size-3.5`})]})]}),(0,M.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,M.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`ID`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`State`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,M.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,M.jsx)(`tbody`,{children:W.jobs.length===0?(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{colSpan:4,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):W.jobs.map(e=>(0,M.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,M.jsx)(`td`,{className:`px-5 py-3`,children:(0,M.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,M.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,M.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,M.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)})]},e.id))})]})})]}),(0,M.jsx)(L,{counts:X.priorityCounts}),(0,M.jsxs)(d,{className:`mb-6`,children:[(0,M.jsx)(c,{title:`Backlog depth`,action:(0,M.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,$.draining?`bg-emerald-500/10 text-success`:$.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:$.label})}),G.length<2?(0,M.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,M.jsx)(T,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:G,area:!0}]}),(0,M.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,M.jsx)(`span`,{children:`waiting + active + delayed`}),(0,M.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,Q==null?`—`:_(Q)]})]})]}),(0,M.jsx)(A,{queue:e,paused:X.paused,busy:a,run:J}),(0,M.jsx)(te,{queue:e,busy:a,run:J}),(0,M.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[W.stall?(0,M.jsx)(D,{queue:e,config:W.stall,onSaved:()=>{z({ok:!0,text:`Stall config saved ✓`}),x.success(`Stall config saved`,e)}},e):(0,M.jsx)(k,{title:`Stall detection`,onRetry:U}),W.dlq?(0,M.jsx)(O,{queue:e,config:W.dlq,onSaved:()=>{z({ok:!0,text:`DLQ config saved ✓`}),x.success(`DLQ config saved`,e)}},e):(0,M.jsx)(k,{title:`DLQ policy`,onRetry:U})]})]})]})}function L({counts:e}){let t=Object.entries(e??{}).map(([e,t])=>[Number(e),t]).filter(([,e])=>e>0).sort((e,t)=>t[0]-e[0]);if(t.length===0)return null;let n=Math.max(...t.map(([,e])=>e));return(0,M.jsxs)(d,{className:`mb-6`,children:[(0,M.jsx)(c,{title:`Jobs by priority`}),(0,M.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,M.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,M.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,M.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:h(t)})]},e))}),(0,M.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}export{I as QueueDetailPro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r,u as i}from"./react-vendor-BcouBxpZ.js";import{A as a,G as o,J as s,M as c,b as l,c as u,h as d,j as f,m as p,x as m}from"./index-BOcegTHa.js";import{t as h}from"./Pagination-D4ki-pGz.js";var g=e(n(),1),_=r(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let e=i(),[n,r]=(0,g.useState)(``),[b,x]=(0,g.useState)(0),{data:S,error:C,loading:w,refetch:T}=a(()=>f.queues(v,b*v),[b]),{data:E}=a(()=>f.overview(),[]),D=S??y,O=(0,g.useMemo)(()=>{let e=D.queues,t=n.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)):e},[D,n]);if(w&&!S&&!C)return(0,_.jsx)(l,{label:`Loading queues…`});let k=E?.stats;return(0,_.jsxs)(`div`,{children:[C&&(0,_.jsx)(m,{onRetry:T}),(0,_.jsx)(d,{title:`Queues`,description:`${D.total} queues`,live:!0}),(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,_.jsx)(p,{label:`Waiting`,value:k?u(k.waiting):`—`,tone:`amber`,compact:!0}),(0,_.jsx)(p,{label:`Active`,value:k?u(k.active):`—`,tone:`blue`,compact:!0}),(0,_.jsx)(p,{label:`Delayed`,value:k?u(k.delayed):`—`,tone:`default`,compact:!0}),(0,_.jsx)(p,{label:`DLQ`,value:k?u(k.dlq):`—`,tone:k?.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`Search queues…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,_.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Delayed`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`DLQ`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`w-10 px-5 py-3`})]})}),(0,_.jsx)(`tbody`,{children:O.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:n?`No queues match on this page.`:`No queues yet.`})}):O.map(n=>(0,_.jsxs)(`tr`,{onClick:()=>e(`/queues/${encodeURIComponent(n.name)}`),className:`group cursor-pointer border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(`span`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,_.jsx)(o,{className:`size-4 text-faint`}),n.name]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:u(n.waiting)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:u(n.active)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:u(n.delayed)}),(0,_.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,n.dlq?`text-red-400`:`text-muted`),children:u(n.dlq)}),(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,n.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-emerald-400`),children:[(0,_.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),n.paused?`Paused`:`Active`]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:(0,_.jsx)(c,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},n.name))})]})}),(0,_.jsx)(h,{page:b,pageSize:v,total:D.total,onPageChange:x,label:`queues`})]})}export{b as Queues};
|