bunqueue-dashboard 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/.vite/manifest.json +114 -114
- package/dist/assets/{AddJob-CWkkVHmf.js → AddJob-CC4bfHLH.js} +1 -1
- package/dist/assets/{Alerts-Gh1pVbqj.js → Alerts-C2bAi-Kj.js} +1 -1
- package/dist/assets/{Benchmark-Dir2A1CQ.js → Benchmark-ClJmYZoC.js} +1 -1
- package/dist/assets/{BulkAddJobs-Di_IgRSH.js → BulkAddJobs-BBWqQpP7.js} +1 -1
- package/dist/assets/{CopilotPanel-Db5nYpo1.js → CopilotPanel-Bhh-uCpN.js} +3 -3
- package/dist/assets/{Cron-BRgWcBGk.js → Cron-pJJ5KXFG.js} +1 -1
- package/dist/assets/{CronManager-CbM0x_s0.js → CronManager-lNZ4lHh1.js} +1 -1
- package/dist/assets/{Database-BeoEreW0.js → Database-DxiXsUl4.js} +1 -1
- package/dist/assets/{Diagnostics-Cw9iJ84f.js → Diagnostics-DLvCT7zI.js} +1 -1
- package/dist/assets/{Dlq-DfCg04Jd.js → Dlq-Bx4YXTp5.js} +1 -1
- package/dist/assets/{DlqControl-BRCkUXvb.js → DlqControl-DJGhuyu3.js} +1 -1
- package/dist/assets/{DlqPro-BHJwBYsN.js → DlqPro-BhXIKtrt.js} +1 -1
- package/dist/assets/{Flows-BAzbFP_W.js → Flows-Bb9j-YhZ.js} +1 -1
- package/dist/assets/{JobInspector-qvW_APO6.js → JobInspector-DfqBq4O5.js} +2 -2
- package/dist/assets/{Jobs-URpnFjC6.js → Jobs-Blavwd1H.js} +1 -1
- package/dist/assets/{JobsPro-pQ_RFSU3.js → JobsPro-D8dH9um7.js} +1 -1
- package/dist/assets/{Logs-C5jX2OPE.js → Logs-B3dsGSF8.js} +1 -1
- package/dist/assets/{LogsPro-Cq_npmmS.js → LogsPro-BCB7etG2.js} +1 -1
- package/dist/assets/{McpServer-DtCTmQBu.js → McpServer-Cz1-GwD5.js} +1 -1
- package/dist/assets/{Metrics-BdxitePr.js → Metrics-Bkuy6Ntb.js} +1 -1
- package/dist/assets/{MetricsPro-orHfW0mg.js → MetricsPro-BbJmy0oO.js} +1 -1
- package/dist/assets/{Overview-DaNns1aj.js → Overview-Ba5odzYe.js} +1 -1
- package/dist/assets/{QueueActions-jiTzndPH.js → QueueActions-B6M0ByGt.js} +1 -1
- package/dist/assets/{QueueControl-l5bSdMgb.js → QueueControl-CWHsVfWU.js} +1 -1
- package/dist/assets/{QueueDetail-URK2pjtH.js → QueueDetail-BClRbWC5.js} +1 -1
- package/dist/assets/{QueueDetailPro-C9M5CV4K.js → QueueDetailPro-CIimG0pX.js} +1 -1
- package/dist/assets/{Queues-DeLXlww2.js → Queues-CGPgEkVm.js} +1 -1
- package/dist/assets/{QueuesOverview-DoQ-MUfT.js → QueuesOverview-ChC5Dtqh.js} +1 -1
- package/dist/assets/{S3Backup-D2agV9_z.js → S3Backup-5OKa8G13.js} +1 -1
- package/dist/assets/S3BackupPro-BkwTXdtw.js +3 -0
- package/dist/assets/{ServerControl-QVd6m_iR.js → ServerControl-DJHKMaf9.js} +1 -1
- package/dist/assets/{Settings-CiJRj_SM.js → Settings-C1HtCK6h.js} +1 -1
- package/dist/assets/{Usage-DbHJgA4t.js → Usage-QyZkUhgs.js} +1 -1
- package/dist/assets/{UsagePro-LoPo3k1L.js → UsagePro-DMxrXxur.js} +1 -1
- package/dist/assets/{Webhooks-CuzIJHwk.js → Webhooks-D0JQQf0q.js} +1 -1
- package/dist/assets/{Workers-BpUgpwUH.js → Workers-Cn8Bkgy1.js} +1 -1
- package/dist/assets/{WorkersPro-BYY0P1Pt.js → WorkersPro-BOTuX9EP.js} +1 -1
- package/dist/assets/{Workflows-ByJw4FFH.js → Workflows-DqTKWPmT.js} +1 -1
- package/dist/assets/bq-Bmysbg0r.js +1 -0
- package/dist/assets/index-Cue53Myw.js +8 -0
- package/dist/assets/install-CFiYX86d.js +3 -0
- package/dist/assets/{usePolledData-c53tx1jw.js → usePolledData-g80Z_UB-.js} +1 -1
- package/dist/assets/useThroughputSeries-CrsZYKbT.js +1 -0
- package/dist/index.html +3 -3
- package/package.json +10 -5
- package/scripts/embedded.gen.ts +142 -142
- package/dist/assets/S3BackupPro--WSZWTQn.js +0 -3
- package/dist/assets/bq-DYmbVkgR.js +0 -1
- package/dist/assets/index-D64v2vNO.js +0 -8
- package/dist/assets/install-jXi1SOYY.js +0 -3
- package/dist/assets/useThroughputSeries-DWHQl7cM.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,l as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{i as o,o as s}from"./connectionStore-CKFQrxDo.js";import{a as c,n as l}from"./upstreamPaths-CDVsu6IM.js";import{a as u,t as d}from"./bq-
|
|
2
|
-
`),displayedLines:t.length,totalLines:e.length,truncated:r}}function re(e,t){if(t&&(typeof e.state!=`string`||!e.state.trim())&&N(`canonical job.state must be a non-empty string`),P(e,`state`,{nonEmpty:!0}),P(e,`name`,{nonEmpty:!0}),P(e,`failedReason`),t&&(typeof e.queue!=`string`||!e.queue.trim())&&N(`canonical job.queue must be a non-empty string`),P(e,`queue`,{nonEmpty:!0}),P(e,`customId`,{nullable:!0}),P(e,`parentId`,{nullable:!0,nonEmpty:!0}),P(e,`groupId`,{nullable:!0}),P(e,`progressMessage`,{nullable:!0}),L(e,`childrenIds`,{nonEmpty:!0}),L(e,`dependsOn`,{nonEmpty:!0}),L(e,`tags`),L(e,`stacktrace`,{nullable:!0}),Array.isArray(e.stacktrace)&&e.stacktrace.length>j&&N(`job.stacktrace exceeds Bunqueue's ${j}-entry limit`),F(e,`priority`,{integer:!0}),F(e,`createdAt`),F(e,`runAt`),F(e,`startedAt`,{nullable:!0}),F(e,`completedAt`,{nullable:!0}),F(e,`attempts`,{integer:!0,min:0}),F(e,`maxAttempts`,{integer:!0,min:0}),F(e,`backoff`,{integer:!0,min:0}),F(e,`timeout`,{nullable:!0,integer:!0,min:0}),F(e,`ttl`,{nullable:!0,integer:!0,min:0}),F(e,`progress`,{min:0,max:100}),F(e,`lastHeartbeat`),F(e,`stallCount`,{integer:!0,min:0}),I(e,`removeOnComplete`),I(e,`removeOnFail`),Object.hasOwn(e,`backoffConfig`)&&e.backoffConfig!==void 0){let t=e.backoffConfig;if(t!==null){(!t||typeof t!=`object`||Array.isArray(t))&&N(`job.backoffConfig must be an object or null`);let e=t;e.type!==`fixed`&&e.type!==`exponential`&&N(`job.backoffConfig.type must be fixed or exponential`),F(e,`delay`,{integer:!0,min:0},`job.backoffConfig`),(!Object.hasOwn(e,`delay`)||e.delay===void 0)&&N(`job.backoffConfig.delay is required`),F(e,`maxDelay`,{integer:!0,min:0},`job.backoffConfig`)}}if(Object.hasOwn(e,`timeline`)&&e.timeline!==void 0){Array.isArray(e.timeline)||N(`job.timeline must be an array`),e.timeline.length>20&&N(`job.timeline exceeds 20 entries`);for(let[t,n]of e.timeline.entries()){(!n||typeof n!=`object`||Array.isArray(n))&&N(`job.timeline[${t}] must be an object`);let e=n;(typeof e.state!=`string`||!e.state.trim())&&N(`job.timeline[${t}].state must be a non-empty string`),(typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp))&&N(`job.timeline[${t}].timestamp must be a finite number`);let r=`job.timeline[${t}]`;P(e,`worker`,{},r),P(e,`error`,{},r),F(e,`attempt`,{integer:!0,min:0},r)}}}function ie(e,{canonical:t,expectedId:n}){if(!e||typeof e!=`object`||Array.isArray(e))return N(`expected an object envelope`);let r=e;if(r.ok!==!0||!Object.hasOwn(r,`job`))return N(`expected { ok: true, job }`);if(r.job===null)return null;if(!r.job||typeof r.job!=`object`||Array.isArray(r.job))return N(`job must be an object or null`);let i=r.job;return typeof i.id!=`string`||!i.id.trim()?N(`job.id must be a non-empty string`):n!==void 0&&i.id!==n?N(`expected job.id ${JSON.stringify(n)}`):(re(i,t),i)}function ae(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw new u(`Invalid job result response: expected an object envelope`,200);let n=e;if(n.ok!==!0||n.id!==t)throw new u(`Invalid job result response: expected { ok: true, id, result? }`,200);return{result:n.result}}var R=3e4;function z(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function B(e,t){return e?.baseUrl===t.baseUrl&&e.authorization===t.authorization}function V(e,t,n){return t.aborted&&!n?.aborted?new u(`Request timed out`,0):e}async function H(e,t,n,r=R){let i=AbortSignal.timeout(r),a=n?AbortSignal.any([n,i]):i,o=new Headers;e.authorization&&o.set(`Authorization`,e.authorization);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{headers:o,signal:a}),a.throwIfAborted()}catch(e){throw V(e,i,n)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw V(e,i,n)}let l,d=!1;if(c)try{l=JSON.parse(c)}catch{d=!0}if(!s.ok){let t=!d&&l&&typeof l==`object`?l.error:void 0,n=typeof t==`string`?t:`HTTP ${s.status}`;throw s.status===401&&typeof window<`u`&&window.dispatchEvent(new window.CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),new u(n,s.status)}if(c){if(d)throw new u(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new u(typeof e==`string`?e:`Operation failed`,s.status)}return l}}async function oe(e,t,n={}){let r=n.target??z(),i=n.timeoutMs??R,a=ie(await H(r,t===`custom`?`/jobs/custom/${l(e,`Custom job ID`)}`:`/jobs/${c(e)}`,n.signal,i),{canonical:t===`id`,expectedId:t===`id`?e:void 0});if(!a||t===`id`)return a;if(a.customId!==e)throw new u(`Invalid job response: expected job.customId ${JSON.stringify(e)}`,200);return ie(await H(r,`/jobs/${c(a.id)}`,n.signal,i),{canonical:!0,expectedId:a.id})}function se(e,t){return async(n,r=e.lookupBy,i=!1,a=void 0,o=!1)=>{let s=n.trim();if(!s||a===void 0&&e.actionBusy.current&&!o)return;e.internalEmptyUrlPending.current=!1,e.preservedEmptyLocationKey.current=null,a===void 0&&(e.actionGen.current+=1),e.job!==null&&(r===`id`?e.job.id!==s:e.job.customId!==s)&&(e.jobTarget.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null)),e.lookupAbort.current?.abort();let l=new AbortController;e.lookupAbort.current=l,e.lookupIdentity.current={key:s,mode:r};let d=++e.lookupGen.current,f=z();e.setLoading(!0),e.setNotFound(!1),i||e.setMsg(null);try{let n=await oe(s,r,{signal:l.signal,target:f});if(!n){if(d!==e.lookupGen.current)return;e.internalEmptyUrlPending.current=!0,e.preservedEmptyLocationKey.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!0),t({},{replace:!0});return}let i=null,a=null;if(d!==e.lookupGen.current||l.signal.aborted||!B(f,z()))return;if(n.state===`completed`)if(Object.hasOwn(n,`returnvalue`))i={result:n.returnvalue};else try{i=ae(await H(f,`/jobs/${c(n.id)}/result`,l.signal),n.id)}catch(e){if(l.signal.aborted)throw e;a=e.message}if(d!==e.lookupGen.current||l.signal.aborted||!B(f,z()))return;e.jobTarget.current=f,e.setJob(n),r===`custom`?(e.setLookupBy(`id`),e.setIdInput(n.id)):e.setIdInput(s),t({id:n.id},{replace:!0}),e.setResult(i?{fetched:!0,value:i.result}:{fetched:!1,value:void 0}),e.setResultError(a)}catch(n){if(d!==e.lookupGen.current||l.signal.aborted)return;n instanceof u&&(n.status===404||/not found/i.test(n.message))?(e.internalEmptyUrlPending.current=!0,e.preservedEmptyLocationKey.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!0),t({},{replace:!0})):i?e.setMsg(e=>e?{ok:e.ok,text:`${e.text} — couldn't reload: ${n.message}`}:{ok:!1,text:n.message}):e.setMsg({ok:!1,text:n.message})}finally{d===e.lookupGen.current&&(e.lookupAbort.current===l&&(e.lookupAbort.current=null,e.lookupIdentity.current=null),e.setLoading(!1))}}}var U=e(n(),1),W=a(),G=365*24*60*60*1e3;function K(e,t){if(!e.trim())return{ok:!1,msg:`A value is required`};let n=Number(e);return Number.isFinite(n)?t===`progress`?n>=0&&n<=100?{ok:!0,value:n}:{ok:!1,msg:`Progress must be between 0 and 100`}:Number.isSafeInteger(n)?t===`priority`?n>=-1e6&&n<=1e6?{ok:!0,value:n}:{ok:!1,msg:`Priority must be between -1000000 and 1000000`}:n>=0&&n<=G?{ok:!0,value:n}:{ok:!1,msg:`Delay must be between 0 and ${G} ms`}:{ok:!1,msg:`Value must be a whole, safe integer`}:{ok:!1,msg:`Value must be a finite number`}}function ce({job:e,busy:t,act:n}){let r=A(e.state),i=r.promote||r.setPriority||r.setDelay||e.state===`active`;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Actions`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,W.jsx)(h,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>d.promoteJob(e.id)),children:`Promote (run now)`}),e.state===`failed`&&(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`DLQ retry is unavailable in Bunqueue v2.8.59: its GET and retry POST have no atomic job-generation, state, or flow-topology precondition.`}),e.state===`completed`&&(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`Completed-job requeue is unavailable in Bunqueue v2.8.59 because retry-completed re-inserts a child without rebuilding its flow dependency registration.`}),e.state===`active`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`Active-job state changes are unavailable: Bunqueue cannot stop the worker that is already processing this job, so retrying, delaying, discarding or failing it here could run side effects twice.`}),(0,W.jsx)(q,{label:`Set progress (0–100)`,cta:`Progress`,kind:`progress`,disabled:t,onSubmit:t=>n(`Progress`,()=>d.setJobProgress(e.id,t))})]}),r.setPriority&&(0,W.jsx)(le,{disabled:t,onSubmit:(t,r)=>n(`Priority`,()=>d.changePriority(e.id,t,r))}),r.setDelay&&(0,W.jsx)(q,{label:`Set delay (ms)`,cta:`Delay`,kind:`delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>d.changeDelay(e.id,t))}),(0,W.jsxs)(`p`,{role:`note`,className:`text-xs text-faint`,children:[`Cancel/delete/discard: `,O]}),!i&&(0,W.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function q({label:e,cta:t,kind:n,disabled:r,onSubmit:i}){let[a,o]=(0,U.useState)(``),s=K(a,n);return(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!r&&s.ok&&i(s.value)},children:[(0,W.jsx)(E,{type:`number`,min:0,max:n===`progress`?100:G,step:n===`progress`?`any`:1,name:n===`progress`?`job-progress`:`job-delay`,value:a,onChange:e=>o(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:r||!s.ok,children:t}),!s.ok&&a.trim()&&(0,W.jsx)(`span`,{role:`alert`,className:`self-center text-[11px] text-danger`,children:s.msg})]})}function le({disabled:e,onSubmit:t}){let[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(!1),o=K(n,`priority`);return(0,W.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault(),!e&&o.ok&&t(o.value,i)},children:[(0,W.jsx)(E,{type:`number`,min:-1e6,max:1e6,step:1,name:`job-priority`,value:n,onChange:e=>r(e.target.value),placeholder:`Set priority`,"aria-label":`Set priority`,className:`h-8 min-w-28 flex-1 text-xs`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(D,{checked:i,onChange:a,label:`Place first among equal priorities`}),(0,W.jsx)(`span`,{className:`text-xs text-muted`,children:`LIFO`})]}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:e||!o.ok,children:`Set`}),!o.ok&&n.trim()&&(0,W.jsx)(`span`,{role:`alert`,className:`w-full text-[11px] text-danger`,children:o.msg})]})}var J=36e5,Y=10,X=e=>Math.max(e,1);function ue(e){return Math.max(0,(e.maxAttempts??0)-X(e.attempts??0))}function de(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??J,a=r?.delay??e.backoff??1e3,o=[];for(let e=X(n);e<t&&o.length<Y;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function fe({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff`}),(0,W.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff schedule`}),(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,a=ue(e),o=de(e);return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff schedule`,action:(0,W.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${S(r.maxDelay)}`:``]})}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,W.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,W.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,S(e.delayMs)]})]},e.attempt))}),a>Y&&(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,Y,` of `,a,` remaining attempts.`]}),(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,S(r?.maxDelay??J),`.`]})]})}function pe({jobId:e}){let[t,n]=(0,U.useState)(!1),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(void 0),[l,u]=(0,U.useState)(null),f=async()=>{o(!0),u(null);try{let t=await d.jobChildren(e);c(t.data?.values),i(!0)}catch(e){u(e.message)}finally{o(!1)}},p=()=>{let e=!t;n(e),e&&!r&&!a&&f()},m=s&&typeof s==`object`?Array.isArray(s)?s.length:Object.keys(s).length:0;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Child values`,action:(0,W.jsx)(h,{size:`sm`,variant:`ghost`,onClick:p,children:t?`Hide`:`Show`})}),t?a?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):l?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:l}):m===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,W.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(s,null,2)}):(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function me({data:e,busy:t,editable:n,readOnlyReason:r,onSave:i}){let[a,o]=(0,U.useState)(()=>JSON.stringify(e??null,null,2)),[s,c]=(0,U.useState)(null),l=(0,U.useRef)(a);return(0,U.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,o(t),c(null))},[e]),(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Data`,action:n?(0,W.jsx)(h,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(a)}catch(e){c(`Invalid JSON: ${e.message}`);return}c(null),i(e)},children:`Save data`}):void 0}),(0,W.jsx)(`textarea`,{"aria-label":`Job data JSON`,name:`job-data-json`,value:a,onChange:e=>o(e.target.value),readOnly:!n,spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),!n&&(0,W.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:r??`Data is read-only after a job starts processing or leaves the runnable queue.`}),s&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:s})]})}function he(e){return e===`waiting`||e===`prioritized`||e===`delayed`}var ge=[`__parentId`,`__parentQueue`,`__childrenIds`,`__flowParentId`,`__flowParentIds`];function _e(e,t){if(!he(e))return`Data is read-only after a job starts processing or leaves the runnable queue.`;let n=t.data,r=typeof n==`object`&&!!n&&!Array.isArray(n)&&ge.some(e=>Object.hasOwn(n,e));return t.parentId||(t.childrenIds?.length??0)>0||r?`Data is read-only for Flow jobs because Bunqueue v2.8.59 replaces the full payload and would remove structural metadata.`:null}function ve(e){let{logs:t,count:n,loading:r,busy:i,error:a,message:o,level:s,draftRevision:c}=e;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Logs`,action:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:n}),(0,W.jsx)(h,{size:`sm`,variant:`ghost`,disabled:r||i,onClick:e.load,children:`Refresh`}),(0,W.jsx)(h,{size:`sm`,variant:`danger`,disabled:i||t.length===0,onClick:e.clear,children:`Clear logs`})]})}),a&&(0,W.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:a}),t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,W.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,W.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,W.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:t=>{t.preventDefault();let n=t.currentTarget.elements.namedItem(`job-log-message`),r=t.currentTarget.elements.namedItem(`job-log-level`);e.add(n?.value??o,r?.value??s)},children:[(0,W.jsx)(E,{"aria-label":`Log message`,name:`job-log-message`,autoComplete:`off`,value:o,onInput:t=>{c.current+=1,e.setMessage(t.currentTarget.value)},placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,W.jsxs)(T,{"aria-label":`Log level`,name:`job-log-level`,value:s,onChange:t=>{c.current+=1,e.setLevel(t.target.value)},className:`h-8 w-24 text-xs`,children:[(0,W.jsx)(`option`,{value:`info`,children:`info`}),(0,W.jsx)(`option`,{value:`warn`,children:`warn`}),(0,W.jsx)(`option`,{value:`error`,children:`error`})]}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:i||o.trim()===``,children:`Add`})]})]})}var ye=3e4;function Z(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function be(e,t){return e.baseUrl===t.baseUrl&&e.authorization===t.authorization}function xe(e,t,n){return t.aborted&&!n.aborted?new u(`Request timed out`,0):e}async function Se(e,t,n,r){let i=AbortSignal.timeout(ye),a=AbortSignal.any([r,i]),o=new Headers(n.headers);e.authorization&&o.set(`Authorization`,e.authorization),n.body!=null&&!o.has(`Content-Type`)&&o.set(`Content-Type`,`application/json`);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{...n,headers:o,signal:a}),a.throwIfAborted()}catch(e){throw xe(e,i,r)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw xe(e,i,r)}let l,d=!1;if(c)try{l=JSON.parse(c)}catch{d=!0}if(!s.ok){let t=!d&&l&&typeof l==`object`?l.error:void 0;throw s.status===401&&typeof window<`u`&&window.dispatchEvent(new window.CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),new u(typeof t==`string`?t:`HTTP ${s.status}`,s.status)}if(c){if(d)throw new u(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new u(typeof e==`string`?e:`Operation failed`,s.status)}return l}}function Ce(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new u(`Invalid logs response: expected an object envelope`,200);let t=e;if(t.ok!==!0||!t.data||typeof t.data!=`object`)throw new u(`Invalid logs response: expected { ok: true, data }`,200);let n=t.data;if(!Array.isArray(n.logs)||typeof n.count!=`number`||!Number.isSafeInteger(n.count)||n.count<0)throw new u(`Invalid logs response: expected logs[] and a non-negative count`,200);return{logs:n.logs,count:n.count}}function we({jobId:e}){let t=s(e=>e.baseUrl),n=s(e=>e.token),[r,i]=(0,U.useState)([]),[a,l]=(0,U.useState)(0),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(`info`),[y,b]=(0,U.useState)(!1),x=(0,U.useRef)(!1),S=(0,U.useRef)(null),C=(0,U.useRef)(0),w=(0,U.useRef)(null),T=(0,U.useRef)(0),E=(0,U.useRef)(null),D=(0,U.useRef)(!1),O=(0,U.useRef)(0);(0,U.useEffect)(()=>{x.current=!0,S.current=e;let t=()=>{C.current+=1,w.current?.abort(),w.current=null,T.current+=1,E.current?.abort(),E.current=null,D.current=!1,O.current+=1,i([]),l(0),f(!1),m(null),g(``),b(!1)},n=s.subscribe((e,n)=>{e.baseUrl===n.baseUrl&&e.token===n.token||t()});return t(),()=>{x.current=!1,S.current=null,n(),C.current+=1,w.current?.abort(),w.current=null,T.current+=1,E.current?.abort(),E.current=null,D.current=!1}},[e]);let k=(0,U.useCallback)(async r=>{w.current?.abort();let a=new AbortController;w.current=a;let u=++C.current,d=s.getState(),p=r?.target??(d.baseUrl===t&&d.token===n?{baseUrl:o(),authorization:n?`Bearer ${n}`:void 0}:Z()),h=()=>x.current&&S.current===e&&u===C.current&&!a.signal.aborted&&be(p,Z());f(!0),m(null);try{let t=Ce(await Se(p,`/jobs/${c(e)}/logs`,{},a.signal));return h()?(i(t.logs),l(t.count),!0):!1}catch(e){if(!h())return!1;let t=e instanceof Error?e.message:String(e);return m(r?.acceptedLabel?`${r.acceptedLabel} succeeded, but couldn't reload logs: ${t}`:t),!1}finally{u===C.current&&(w.current===a&&(w.current=null),x.current&&f(!1))}},[e,t,n]);(0,U.useEffect)(()=>{k()},[k]);let A=async(t,n,r)=>{if(D.current)return;D.current=!0;let i=new AbortController;E.current=i;let a=++T.current,o=Z();C.current+=1,w.current?.abort(),w.current=null,f(!1),b(!0),m(null);let s=()=>x.current&&S.current===e&&a===T.current&&!i.signal.aborted&&be(o,Z());try{let a=await Se(o,`/jobs/${c(e)}/logs`,t,i.signal);if(!a||typeof a!=`object`||Array.isArray(a)||a.ok!==!0)throw new u(`Invalid log mutation response: expected { ok: true }`,200);if(!s())return;r(),await k({acceptedLabel:n,target:o})}catch(e){s()&&m(e instanceof Error?e.message:String(e))}finally{a===T.current&&(D.current=!1,E.current===i&&(E.current=null),x.current&&b(!1))}},j=async(e=h,t=_)=>{if(D.current)return;let n=e.trim();if(!n)return;let r=t===`warn`||t===`error`?t:`info`,i=O.current;g(e),v(r),await A({method:`POST`,body:JSON.stringify({message:n,level:r})},`Log addition`,()=>{O.current===i&&g(``)})},M=async()=>{D.current||window.confirm(`Clear all logs for this job?`)&&await A({method:`DELETE`},`Log clearing`,()=>{i([]),l(0)})};return(0,W.jsx)(ve,{logs:r,count:a,loading:d,busy:y,error:p,message:h,level:_,draftRevision:O,setMessage:g,setLevel:v,load:()=>void k(),clear:()=>void M(),add:(e,t)=>void j(e,t)})}function Te({timeline:e}){let t=e??[];return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Timeline`}),t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,W.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,W.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(b,{status:e.state}),e.attempt!=null&&(0,W.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,W.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:C(e.timestamp)})]}),(e.worker||e.error)&&(0,W.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,W.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,W.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function Ee(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return e.failedReason?{message:e.failedReason}:null}function De({job:e,result:t,resultError:n,loading:r,notFound:i,busy:a,lookup:o,act:s}){if(r&&!e)return(0,W.jsx)(v,{label:`Loading job…`});if(i)return(0,W.jsx)(y,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`});if(!e)return(0,W.jsx)(y,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`});let c=e.state,l=Ee(e),u=e.stacktrace?.length?ne(e.stacktrace):null,f=(e.childrenIds?.length??0)>0,p=_e(c,e),m=c===`failed`,h=l||u?(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Error`}),l&&(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`p`,{className:`text-sm text-danger`,children:l.message}),(0,W.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[l.attempt==null?``:`Attempt ${l.attempt} · `,C(l.timestamp)]})]}),u&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:u.text}),u.truncated&&(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-faint`,children:[`Stack preview truncated (`,u.displayedLines,` of `,u.totalLines,` `,`lines, 262,144 characters maximum). Download JSON for the complete stored stack.`]})]})]}):null;return(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,W.jsx)(Oe,{job:e}),m&&h,(0,W.jsx)(me,{data:e.data,busy:a,editable:p===null,readOnlyReason:p??void 0,onSave:t=>s(`Data`,()=>d.updateJobData(e.id,t))},`data-${e.id}`),c===`completed`&&(0,W.jsx)(ke,{jobId:e.id,result:t,resultError:n,loading:r,onRetry:()=>o(e.id,`id`)}),!m&&h,(0,W.jsx)(we,{jobId:e.id},`logs-${e.id}`),f&&(0,W.jsx)(pe,{jobId:e.id},`children-${e.id}`),(0,W.jsx)(Te,{timeline:e.timeline}),(0,W.jsx)(fe,{job:e})]}),(0,W.jsx)(`div`,{className:`order-first lg:order-none`,children:(0,W.jsx)(ce,{job:e,busy:a,act:s})})]})}function Oe({job:e}){return(0,W.jsxs)(_,{children:[(0,W.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:e.id}),(0,W.jsx)(w,{value:e.id})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:e.queue})]}),(0,W.jsx)(b,{status:e.state??`unknown`})]}),(0,W.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,W.jsx)(Q,{label:`Priority`,value:String(e.priority??0)}),(0,W.jsx)(Q,{label:`Name`,value:e.name??`default`}),(0,W.jsx)(Q,{label:`Attempts`,value:`${e.attempts??0} / ${e.maxAttempts??`?`}`}),(0,W.jsx)(Q,{label:`Progress`,value:`${e.progress??0}%`}),(0,W.jsx)(Q,{label:`Created`,value:C(e.createdAt)}),(0,W.jsx)(Q,{label:`Started`,value:C(e.startedAt??void 0)}),(0,W.jsx)(Q,{label:`Completed`,value:C(e.completedAt??void 0)}),(0,W.jsx)(Q,{label:`Duration`,value:S(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,W.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,W.jsx)(`span`,{className:`truncate font-mono`,children:e.customId??`—`}),e.customId&&(0,W.jsx)(w,{value:e.customId})]})]})]})]})}function ke({jobId:e,result:t,resultError:n,loading:r,onRetry:i}){let a=t.fetched&&t.value!==void 0&&t.value!==null;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Result`,action:a?(0,W.jsx)(je,{value:t.value,filename:`job-${e}-result`}):void 0}),a?(0,W.jsx)(Ae,{value:t.value}):n?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,W.jsxs)(`p`,{className:`text-xs text-danger`,children:[`Couldn't load result — `,n]}),(0,W.jsx)(h,{size:`sm`,disabled:r,onClick:i,children:`Retry`})]}):(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]})}function Q({label:e,value:t}){return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`text-fg`,children:t})]})}function Ae({value:e}){return(0,W.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(e??null,null,2)})}function je({value:e,filename:t}){return(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(w,{value:JSON.stringify(e??null,null,2)}),(0,W.jsx)(m,{"aria-label":`Download JSON`,title:`Download JSON`,onClick:()=>k(t,e??null),children:(0,W.jsx)(p,{className:`size-3.5`})})]})}function Me(e){let t={};return typeof e.priority==`number`&&(t.priority=e.priority),typeof e.maxAttempts==`number`&&(t.maxAttempts=e.maxAttempts),typeof e.backoff==`number`&&(t.backoff=e.backoff),e.backoffConfig&&typeof e.backoffConfig.delay==`number`&&(t.backoffConfig={type:e.backoffConfig.type,delay:e.backoffConfig.delay},typeof t.backoff!=`number`&&(t.backoff=e.backoffConfig.delay)),typeof e.timeout==`number`&&(t.timeout=e.timeout),typeof e.removeOnComplete==`boolean`&&(t.removeOnComplete=e.removeOnComplete),typeof e.removeOnFail==`boolean`&&(t.removeOnFail=e.removeOnFail),typeof e.ttl==`number`&&(t.ttl=e.ttl),Array.isArray(e.tags)&&e.tags.length&&(t.tags=[...e.tags]),typeof e.groupId==`string`&&e.groupId&&(t.groupId=e.groupId),{clone:{queue:e.queue??``,name:e.name,dataText:JSON.stringify(e.data??{},null,2),options:t}}}function Ne({job:e,result:t,idInput:n,lookupBy:r,loading:a,busy:o,onInputChange:s,onModeChange:c,onSubmit:l}){let u=!!(e&&((e.childrenIds?.length??0)>0||e.parentId));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(x,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:e?(0,W.jsxs)(W.Fragment,{children:[u&&(0,W.jsx)(i,{to:`/flows?root=${encodeURIComponent(e.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}),(0,W.jsx)(i,{to:`/add-job`,state:Me(e),title:`Enqueue a new job pre-filled from this one`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Clone`}),(0,W.jsxs)(h,{size:`sm`,onClick:()=>k(`job-${e.id}`,t.fetched?{...e,result:t.value}:e),children:[(0,W.jsx)(p,{className:`size-3.5`}),` Download JSON`]})]}):void 0}),(0,W.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(T,{name:`job-lookup-mode`,autoComplete:`off`,value:r,"aria-label":`Lookup mode`,onChange:e=>c(e.target.value),className:`w-40`,children:[(0,W.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,W.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,W.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,W.jsx)(f,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,W.jsx)(`input`,{value:n,"aria-label":r===`custom`?`Custom job ID`:`Job ID`,name:`job-lookup-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,onInput:e=>s(e.currentTarget.value),onKeyDown:e=>e.key===`Enter`&&l(n),placeholder:r===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,W.jsx)(h,{variant:`accent`,disabled:a||o,onClick:()=>l(n),children:`Look up`})]})]})}function Pe({state:e,lookup:t,setParams:n,locationKey:r,idParam:i,customParam:a,jobBelongsToCurrentTarget:o,connectionBaseUrl:s,connectionToken:c}){(0,U.useEffect)(()=>{if(e.internalEmptyUrlPending.current){!i&&!a&&(e.internalEmptyUrlPending.current=!1,e.preservedEmptyLocationKey.current=r);return}if(!(!i&&!a&&e.preservedEmptyLocationKey.current===r))if(e.preservedEmptyLocationKey.current=null,a)if(e.job?.customId===a&&o)e.setLookupBy(`id`),e.setIdInput(e.job.id),n({id:e.job.id},{replace:!0});else{e.setLookupBy(`custom`),e.setIdInput(a);let n=e.lookupIdentity.current;(n?.mode!==`custom`||n.key!==a)&&t(a,`custom`,!1,void 0,!0)}else if(i&&(i!==e.job?.id||!o)){e.setLookupBy(`id`),e.setIdInput(i);let n=e.lookupIdentity.current;(n?.mode!==`id`||n.key!==i)&&t(i,`id`,!1,void 0,!0)}else!i&&!a&&(e.lookupGen.current+=1,e.lookupAbort.current?.abort(),e.lookupAbort.current=null,e.lookupIdentity.current=null,e.actionGen.current+=1,e.jobTarget.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!1),e.setMsg(null),e.setLoading(!1),e.setLookupBy(`id`),e.setIdInput(``))},[i,a,e.job?.id,e.job?.customId,o,r,s,c])}var $={fetched:!1,value:void 0};function Fe(e,t){let[n,r]=(0,U.useState)(e??t??``),[i,a]=(0,U.useState)(e?`custom`:`id`),[o,c]=(0,U.useState)(null),[l,u]=(0,U.useState)($),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null),[y,b]=(0,U.useState)(!1),x=(0,U.useRef)(0),S=(0,U.useRef)(null),C=(0,U.useRef)(null),w=(0,U.useRef)(null),T=(0,U.useRef)(!1),E=(0,U.useRef)(null),D=(0,U.useRef)(!1),O=(0,U.useRef)(0),k=(0,U.useRef)(!1),A=(0,U.useRef)(null);return(0,U.useEffect)(()=>{D.current=!0;let e=s.subscribe((e,t)=>{e.baseUrl===t.baseUrl&&e.token===t.token||(x.current+=1,S.current?.abort(),S.current=null,C.current=null,O.current+=1,A.current=null,k.current=!1,w.current=null,T.current=!1,E.current=null,c(null),u($),f(null),g(!1),v(null),m(!1),b(!1))});return()=>{D.current=!1,e(),x.current+=1,S.current?.abort(),S.current=null,C.current=null,O.current+=1,A.current=null,k.current=!1}},[]),{idInput:n,setIdInput:r,lookupBy:i,setLookupBy:a,job:o,setJob:c,result:l,setResult:u,resultError:d,setResultError:f,loading:p,setLoading:m,notFound:h,setNotFound:g,msg:_,setMsg:v,busy:y,setBusy:b,lookupGen:x,lookupAbort:S,lookupIdentity:C,jobTarget:w,internalEmptyUrlPending:T,preservedEmptyLocationKey:E,mounted:D,actionGen:O,actionBusy:k,actionLockOwner:A}}function Ie(){let e=r(),[n,i]=t(),a=s(e=>e.baseUrl),c=s(e=>e.token),l=Fe(n.get(`custom`),n.get(`id`)),d=se(l,i),f=n.get(`id`),p=n.get(`custom`),m={baseUrl:o(),authorization:c?`Bearer ${c}`:void 0},h=B(l.jobTarget.current,m);return Pe({state:l,lookup:d,setParams:i,locationKey:e.key,idParam:f,customParam:p,jobBelongsToCurrentTarget:h,connectionBaseUrl:a,connectionToken:c}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ne,{job:l.job,result:l.result,idInput:l.idInput,lookupBy:l.lookupBy,loading:l.loading,busy:l.busy,onInputChange:l.setIdInput,onModeChange:l.setLookupBy,onSubmit:(e,t=l.lookupBy)=>{let n=e.trim();if(!(!n||l.actionBusy.current)){if(t===`id`?f===n&&p===null:p===n&&f===null){d(n,t);return}i(t===`custom`?{custom:n}:{id:n})}}}),l.msg&&(0,W.jsx)(`div`,{role:`status`,className:l.msg.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:l.msg.text}),(0,W.jsx)(De,{job:l.job,result:l.result,resultError:l.resultError,loading:l.loading,notFound:l.notFound,busy:l.busy,lookup:d,act:async(e,t,n)=>{if(!l.job||l.actionBusy.current||l.lookupAbort.current)return;let r=z();if(!B(l.jobTarget.current,r)||n&&!window.confirm(n))return;let a=++l.actionGen.current,o=l.job.id;l.actionLockOwner.current=a,l.actionBusy.current=!0,l.setBusy(!0),l.setMsg(null);let s=()=>l.mounted.current&&a===l.actionGen.current&&B(r,z())&&B(l.jobTarget.current,r);try{let n=await t();if(!n||typeof n!=`object`||Array.isArray(n)||n.ok!==!0)throw new u(`Invalid job mutation response: expected { ok: true }`,200);if(!s())return;l.setMsg({ok:!0,text:`${e} ✓`}),e===`Cancel`?(l.internalEmptyUrlPending.current=!0,l.preservedEmptyLocationKey.current=null,l.lookupGen.current+=1,l.jobTarget.current=null,l.setJob(null),l.setResult({fetched:!1,value:void 0}),l.setResultError(null),i({},{replace:!0})):await d(o,`id`,!0,a)}catch(e){s()&&l.setMsg({ok:!1,text:e.message})}finally{l.actionLockOwner.current===a&&(l.actionLockOwner.current=null,l.actionBusy.current=!1,l.mounted.current&&l.setBusy(!1))}}})]})}export{Ie as JobInspector};
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,l as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{i as o,o as s}from"./connectionStore-CKFQrxDo.js";import{a as c,n as l}from"./upstreamPaths-CDVsu6IM.js";import{a as u,t as d}from"./bq-Bmysbg0r.js";import{T as f,d as p}from"./icons-CIvFfU2b.js";import{n as m,t as h}from"./Button-BPqpRZJD.js";import{n as g,t as _}from"./Card-C7NMhqUt.js";import{r as v,t as y}from"./feedback-BnGE2oW2.js";import{t as b}from"./StatusBadge-B0I7hNBX.js";import{t as x}from"./PageHeader-BXlZSBcc.js";import{a as S,i as C}from"./format-Cg7VCIZW.js";import{a as w}from"./index-Cue53Myw.js";import{a as T,n as E,o as D}from"./form-tC20r4Ma.js";import{r as O}from"./flowMutationSafety-DObp9nJo.js";import{n as k}from"./exportFile-C7xhE8Yh.js";import{t as A}from"./jobActions-LQD4KfCc.js";var j=1e4,M=100,ee=256*1024;function N(e){throw new u(`Invalid job response: ${e}`,200)}function P(e,t,{nullable:n=!1,nonEmpty:r=!1}={},i=`job`){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let a=e[t];n&&a===null||(typeof a!=`string`||r&&!a.trim())&&N(`${i}.${t} must be ${n?`a string or null`:`a string`}${r?` (non-empty)`:``}`)}function F(e,t,{nullable:n=!1,integer:r=!1,min:i,max:a}={},o=`job`){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let s=e[t];n&&s===null||(typeof s!=`number`||!Number.isFinite(s)||r&&!Number.isSafeInteger(s)||i!==void 0&&s<i||a!==void 0&&s>a)&&N(`${o}.${t} must be a valid${r?` safe integer`:` finite number`}`)}function I(e,t){Object.hasOwn(e,t)&&e[t]!==void 0&&typeof e[t]!=`boolean`&&N(`job.${t} must be a boolean`)}function L(e,t,{nullable:n=!1,nonEmpty:r=!1}={}){if(!Object.hasOwn(e,t)||e[t]===void 0)return;let i=e[t];n&&i===null||(!Array.isArray(i)||i.some(e=>typeof e!=`string`||r&&!e.trim()))&&N(`job.${t} must be ${n?`a string array or null`:`a string array`}`)}function te(e,t){let n=0,r=0;for(;n<e.length&&r<t;){let t=e.codePointAt(n);n+=t!==void 0&&t>65535?2:1,r+=1}return{text:e.slice(0,n),count:r}}function ne(e){let t=[],n=0,r=!1,i=Math.min(e.length,M);for(let a=0;a<i;a++){let i=+(t.length>0),o=ee-n-i;if(o<=0){r=!0;break}let s=e[a]??``,c=te(s,o);if(t.push(c.text),n+=i+c.count,c.text.length!==s.length){r=!0;break}}return t.length<e.length&&(r=!0),{text:t.join(`
|
|
2
|
+
`),displayedLines:t.length,totalLines:e.length,truncated:r}}function re(e,t){if(t&&(typeof e.state!=`string`||!e.state.trim())&&N(`canonical job.state must be a non-empty string`),P(e,`state`,{nonEmpty:!0}),P(e,`name`,{nonEmpty:!0}),P(e,`failedReason`),t&&(typeof e.queue!=`string`||!e.queue.trim())&&N(`canonical job.queue must be a non-empty string`),P(e,`queue`,{nonEmpty:!0}),P(e,`customId`,{nullable:!0}),P(e,`parentId`,{nullable:!0,nonEmpty:!0}),P(e,`groupId`,{nullable:!0}),P(e,`progressMessage`,{nullable:!0}),L(e,`childrenIds`,{nonEmpty:!0}),L(e,`dependsOn`,{nonEmpty:!0}),L(e,`tags`),L(e,`stacktrace`,{nullable:!0}),Array.isArray(e.stacktrace)&&e.stacktrace.length>j&&N(`job.stacktrace exceeds Bunqueue's ${j}-entry limit`),F(e,`priority`,{integer:!0}),F(e,`createdAt`),F(e,`runAt`),F(e,`startedAt`,{nullable:!0}),F(e,`completedAt`,{nullable:!0}),F(e,`attempts`,{integer:!0,min:0}),F(e,`maxAttempts`,{integer:!0,min:0}),F(e,`backoff`,{integer:!0,min:0}),F(e,`timeout`,{nullable:!0,integer:!0,min:0}),F(e,`ttl`,{nullable:!0,integer:!0,min:0}),F(e,`progress`,{min:0,max:100}),F(e,`lastHeartbeat`),F(e,`stallCount`,{integer:!0,min:0}),I(e,`removeOnComplete`),I(e,`removeOnFail`),Object.hasOwn(e,`backoffConfig`)&&e.backoffConfig!==void 0){let t=e.backoffConfig;if(t!==null){(!t||typeof t!=`object`||Array.isArray(t))&&N(`job.backoffConfig must be an object or null`);let e=t;e.type!==`fixed`&&e.type!==`exponential`&&N(`job.backoffConfig.type must be fixed or exponential`),F(e,`delay`,{integer:!0,min:0},`job.backoffConfig`),(!Object.hasOwn(e,`delay`)||e.delay===void 0)&&N(`job.backoffConfig.delay is required`),F(e,`maxDelay`,{integer:!0,min:0},`job.backoffConfig`)}}if(Object.hasOwn(e,`timeline`)&&e.timeline!==void 0){Array.isArray(e.timeline)||N(`job.timeline must be an array`),e.timeline.length>20&&N(`job.timeline exceeds 20 entries`);for(let[t,n]of e.timeline.entries()){(!n||typeof n!=`object`||Array.isArray(n))&&N(`job.timeline[${t}] must be an object`);let e=n;(typeof e.state!=`string`||!e.state.trim())&&N(`job.timeline[${t}].state must be a non-empty string`),(typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp))&&N(`job.timeline[${t}].timestamp must be a finite number`);let r=`job.timeline[${t}]`;P(e,`worker`,{},r),P(e,`error`,{},r),F(e,`attempt`,{integer:!0,min:0},r)}}}function ie(e,{canonical:t,expectedId:n}){if(!e||typeof e!=`object`||Array.isArray(e))return N(`expected an object envelope`);let r=e;if(r.ok!==!0||!Object.hasOwn(r,`job`))return N(`expected { ok: true, job }`);if(r.job===null)return null;if(!r.job||typeof r.job!=`object`||Array.isArray(r.job))return N(`job must be an object or null`);let i=r.job;return typeof i.id!=`string`||!i.id.trim()?N(`job.id must be a non-empty string`):n!==void 0&&i.id!==n?N(`expected job.id ${JSON.stringify(n)}`):(re(i,t),i)}function ae(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw new u(`Invalid job result response: expected an object envelope`,200);let n=e;if(n.ok!==!0||n.id!==t)throw new u(`Invalid job result response: expected { ok: true, id, result? }`,200);return{result:n.result}}var R=3e4;function z(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function B(e,t){return e?.baseUrl===t.baseUrl&&e.authorization===t.authorization}function V(e,t,n){return t.aborted&&!n?.aborted?new u(`Request timed out`,0):e}async function H(e,t,n,r=R){let i=AbortSignal.timeout(r),a=n?AbortSignal.any([n,i]):i,o=new Headers;e.authorization&&o.set(`Authorization`,e.authorization);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{headers:o,signal:a}),a.throwIfAborted()}catch(e){throw V(e,i,n)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw V(e,i,n)}let l,d=!1;if(c)try{l=JSON.parse(c)}catch{d=!0}if(!s.ok){let t=!d&&l&&typeof l==`object`?l.error:void 0,n=typeof t==`string`?t:`HTTP ${s.status}`;throw s.status===401&&typeof window<`u`&&window.dispatchEvent(new window.CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),new u(n,s.status)}if(c){if(d)throw new u(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new u(typeof e==`string`?e:`Operation failed`,s.status)}return l}}async function oe(e,t,n={}){let r=n.target??z(),i=n.timeoutMs??R,a=ie(await H(r,t===`custom`?`/jobs/custom/${l(e,`Custom job ID`)}`:`/jobs/${c(e)}`,n.signal,i),{canonical:t===`id`,expectedId:t===`id`?e:void 0});if(!a||t===`id`)return a;if(a.customId!==e)throw new u(`Invalid job response: expected job.customId ${JSON.stringify(e)}`,200);return ie(await H(r,`/jobs/${c(a.id)}`,n.signal,i),{canonical:!0,expectedId:a.id})}function se(e,t){return async(n,r=e.lookupBy,i=!1,a=void 0,o=!1)=>{let s=n.trim();if(!s||a===void 0&&e.actionBusy.current&&!o)return;e.internalEmptyUrlPending.current=!1,e.preservedEmptyLocationKey.current=null,a===void 0&&(e.actionGen.current+=1),e.job!==null&&(r===`id`?e.job.id!==s:e.job.customId!==s)&&(e.jobTarget.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null)),e.lookupAbort.current?.abort();let l=new AbortController;e.lookupAbort.current=l,e.lookupIdentity.current={key:s,mode:r};let d=++e.lookupGen.current,f=z();e.setLoading(!0),e.setNotFound(!1),i||e.setMsg(null);try{let n=await oe(s,r,{signal:l.signal,target:f});if(!n){if(d!==e.lookupGen.current)return;e.internalEmptyUrlPending.current=!0,e.preservedEmptyLocationKey.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!0),t({},{replace:!0});return}let i=null,a=null;if(d!==e.lookupGen.current||l.signal.aborted||!B(f,z()))return;if(n.state===`completed`)if(Object.hasOwn(n,`returnvalue`))i={result:n.returnvalue};else try{i=ae(await H(f,`/jobs/${c(n.id)}/result`,l.signal),n.id)}catch(e){if(l.signal.aborted)throw e;a=e.message}if(d!==e.lookupGen.current||l.signal.aborted||!B(f,z()))return;e.jobTarget.current=f,e.setJob(n),r===`custom`?(e.setLookupBy(`id`),e.setIdInput(n.id)):e.setIdInput(s),t({id:n.id},{replace:!0}),e.setResult(i?{fetched:!0,value:i.result}:{fetched:!1,value:void 0}),e.setResultError(a)}catch(n){if(d!==e.lookupGen.current||l.signal.aborted)return;n instanceof u&&(n.status===404||/not found/i.test(n.message))?(e.internalEmptyUrlPending.current=!0,e.preservedEmptyLocationKey.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!0),t({},{replace:!0})):i?e.setMsg(e=>e?{ok:e.ok,text:`${e.text} — couldn't reload: ${n.message}`}:{ok:!1,text:n.message}):e.setMsg({ok:!1,text:n.message})}finally{d===e.lookupGen.current&&(e.lookupAbort.current===l&&(e.lookupAbort.current=null,e.lookupIdentity.current=null),e.setLoading(!1))}}}var U=e(n(),1),W=a(),G=365*24*60*60*1e3;function K(e,t){if(!e.trim())return{ok:!1,msg:`A value is required`};let n=Number(e);return Number.isFinite(n)?t===`progress`?n>=0&&n<=100?{ok:!0,value:n}:{ok:!1,msg:`Progress must be between 0 and 100`}:Number.isSafeInteger(n)?t===`priority`?n>=-1e6&&n<=1e6?{ok:!0,value:n}:{ok:!1,msg:`Priority must be between -1000000 and 1000000`}:n>=0&&n<=G?{ok:!0,value:n}:{ok:!1,msg:`Delay must be between 0 and ${G} ms`}:{ok:!1,msg:`Value must be a whole, safe integer`}:{ok:!1,msg:`Value must be a finite number`}}function ce({job:e,busy:t,act:n}){let r=A(e.state),i=r.promote||r.setPriority||r.setDelay||e.state===`active`;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Actions`}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,W.jsx)(h,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>d.promoteJob(e.id)),children:`Promote (run now)`}),e.state===`failed`&&(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`DLQ retry is unavailable in Bunqueue v2.8.59: its GET and retry POST have no atomic job-generation, state, or flow-topology precondition.`}),e.state===`completed`&&(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`Completed-job requeue is unavailable in Bunqueue v2.8.59 because retry-completed re-inserts a child without rebuilding its flow dependency registration.`}),e.state===`active`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{role:`note`,className:`rounded-lg border border-warning/30 bg-warning/5 p-2 text-xs text-warning`,children:`Active-job state changes are unavailable: Bunqueue cannot stop the worker that is already processing this job, so retrying, delaying, discarding or failing it here could run side effects twice.`}),(0,W.jsx)(q,{label:`Set progress (0–100)`,cta:`Progress`,kind:`progress`,disabled:t,onSubmit:t=>n(`Progress`,()=>d.setJobProgress(e.id,t))})]}),r.setPriority&&(0,W.jsx)(le,{disabled:t,onSubmit:(t,r)=>n(`Priority`,()=>d.changePriority(e.id,t,r))}),r.setDelay&&(0,W.jsx)(q,{label:`Set delay (ms)`,cta:`Delay`,kind:`delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>d.changeDelay(e.id,t))}),(0,W.jsxs)(`p`,{role:`note`,className:`text-xs text-faint`,children:[`Cancel/delete/discard: `,O]}),!i&&(0,W.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function q({label:e,cta:t,kind:n,disabled:r,onSubmit:i}){let[a,o]=(0,U.useState)(``),s=K(a,n);return(0,W.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!r&&s.ok&&i(s.value)},children:[(0,W.jsx)(E,{type:`number`,min:0,max:n===`progress`?100:G,step:n===`progress`?`any`:1,name:n===`progress`?`job-progress`:`job-delay`,value:a,onChange:e=>o(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:r||!s.ok,children:t}),!s.ok&&a.trim()&&(0,W.jsx)(`span`,{role:`alert`,className:`self-center text-[11px] text-danger`,children:s.msg})]})}function le({disabled:e,onSubmit:t}){let[n,r]=(0,U.useState)(``),[i,a]=(0,U.useState)(!1),o=K(n,`priority`);return(0,W.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault(),!e&&o.ok&&t(o.value,i)},children:[(0,W.jsx)(E,{type:`number`,min:-1e6,max:1e6,step:1,name:`job-priority`,value:n,onChange:e=>r(e.target.value),placeholder:`Set priority`,"aria-label":`Set priority`,className:`h-8 min-w-28 flex-1 text-xs`}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(D,{checked:i,onChange:a,label:`Place first among equal priorities`}),(0,W.jsx)(`span`,{className:`text-xs text-muted`,children:`LIFO`})]}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:e||!o.ok,children:`Set`}),!o.ok&&n.trim()&&(0,W.jsx)(`span`,{role:`alert`,className:`w-full text-[11px] text-danger`,children:o.msg})]})}var J=36e5,Y=10,X=e=>Math.max(e,1);function ue(e){return Math.max(0,(e.maxAttempts??0)-X(e.attempts??0))}function de(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??J,a=r?.delay??e.backoff??1e3,o=[];for(let e=X(n);e<t&&o.length<Y;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function fe({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff`}),(0,W.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff schedule`}),(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,a=ue(e),o=de(e);return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Backoff schedule`,action:(0,W.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${S(r.maxDelay)}`:``]})}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:o.map(e=>(0,W.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,W.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,W.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,S(e.delayMs)]})]},e.attempt))}),a>Y&&(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,Y,` of `,a,` remaining attempts.`]}),(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,S(r?.maxDelay??J),`.`]})]})}function pe({jobId:e}){let[t,n]=(0,U.useState)(!1),[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(void 0),[l,u]=(0,U.useState)(null),f=async()=>{o(!0),u(null);try{let t=await d.jobChildren(e);c(t.data?.values),i(!0)}catch(e){u(e.message)}finally{o(!1)}},p=()=>{let e=!t;n(e),e&&!r&&!a&&f()},m=s&&typeof s==`object`?Array.isArray(s)?s.length:Object.keys(s).length:0;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Child values`,action:(0,W.jsx)(h,{size:`sm`,variant:`ghost`,onClick:p,children:t?`Hide`:`Show`})}),t?a?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):l?(0,W.jsx)(`p`,{className:`text-xs text-danger`,children:l}):m===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,W.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(s,null,2)}):(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function me({data:e,busy:t,editable:n,readOnlyReason:r,onSave:i}){let[a,o]=(0,U.useState)(()=>JSON.stringify(e??null,null,2)),[s,c]=(0,U.useState)(null),l=(0,U.useRef)(a);return(0,U.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,o(t),c(null))},[e]),(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Data`,action:n?(0,W.jsx)(h,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(a)}catch(e){c(`Invalid JSON: ${e.message}`);return}c(null),i(e)},children:`Save data`}):void 0}),(0,W.jsx)(`textarea`,{"aria-label":`Job data JSON`,name:`job-data-json`,value:a,onChange:e=>o(e.target.value),readOnly:!n,spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),!n&&(0,W.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:r??`Data is read-only after a job starts processing or leaves the runnable queue.`}),s&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:s})]})}function he(e){return e===`waiting`||e===`prioritized`||e===`delayed`}var ge=[`__parentId`,`__parentQueue`,`__childrenIds`,`__flowParentId`,`__flowParentIds`];function _e(e,t){if(!he(e))return`Data is read-only after a job starts processing or leaves the runnable queue.`;let n=t.data,r=typeof n==`object`&&!!n&&!Array.isArray(n)&&ge.some(e=>Object.hasOwn(n,e));return t.parentId||(t.childrenIds?.length??0)>0||r?`Data is read-only for Flow jobs because Bunqueue v2.8.59 replaces the full payload and would remove structural metadata.`:null}var ve=3e4;function Z(){let{token:e}=s.getState();return{baseUrl:o(),authorization:e?`Bearer ${e}`:void 0}}function ye(e,t){return e.baseUrl===t.baseUrl&&e.authorization===t.authorization}function be(e,t,n){return t.aborted&&!n.aborted?new u(`Request timed out`,0):e}async function xe(e,t,n,r){let i=AbortSignal.timeout(ve),a=AbortSignal.any([r,i]),o=new Headers(n.headers);e.authorization&&o.set(`Authorization`,e.authorization),n.body!=null&&!o.has(`Content-Type`)&&o.set(`Content-Type`,`application/json`);let s;try{a.throwIfAborted(),s=await fetch(`${e.baseUrl}${t}`,{...n,headers:o,signal:a}),a.throwIfAborted()}catch(e){throw be(e,i,r)}if(s.status===204)return;let c;try{c=await s.text(),a.throwIfAborted()}catch(e){throw be(e,i,r)}let l,d=!1;if(c)try{l=JSON.parse(c)}catch{d=!0}if(!s.ok){let t=!d&&l&&typeof l==`object`?l.error:void 0;throw s.status===401&&typeof window<`u`&&window.dispatchEvent(new window.CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),new u(typeof t==`string`?t:`HTTP ${s.status}`,s.status)}if(c){if(d)throw new u(`Invalid JSON response (HTTP ${s.status})`,s.status);if(l&&typeof l==`object`&&l.ok===!1){let e=l.error;throw new u(typeof e==`string`?e:`Operation failed`,s.status)}return l}}function Se(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new u(`Invalid logs response: expected an object envelope`,200);let t=e;if(t.ok!==!0||!t.data||typeof t.data!=`object`)throw new u(`Invalid logs response: expected { ok: true, data }`,200);let n=t.data;if(!Array.isArray(n.logs)||typeof n.count!=`number`||!Number.isSafeInteger(n.count)||n.count<0)throw new u(`Invalid logs response: expected logs[] and a non-negative count`,200);return{logs:n.logs,count:n.count}}function Ce(e){let{logs:t,count:n,loading:r,busy:i,error:a,message:o,level:s,draftRevision:c}=e;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Logs`,action:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:n}),(0,W.jsx)(h,{size:`sm`,variant:`ghost`,disabled:r||i,onClick:e.load,children:`Refresh`}),(0,W.jsx)(h,{size:`sm`,variant:`danger`,disabled:i||t.length===0,onClick:e.clear,children:`Clear logs`})]})}),a&&(0,W.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:a}),t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,W.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,W.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,W.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:t=>{t.preventDefault();let n=t.currentTarget.elements.namedItem(`job-log-message`),r=t.currentTarget.elements.namedItem(`job-log-level`);e.add(n?.value??o,r?.value??s)},children:[(0,W.jsx)(E,{"aria-label":`Log message`,name:`job-log-message`,autoComplete:`off`,value:o,onInput:t=>{c.current+=1,e.setMessage(t.currentTarget.value)},placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,W.jsxs)(T,{"aria-label":`Log level`,name:`job-log-level`,value:s,onChange:t=>{c.current+=1,e.setLevel(t.target.value)},className:`h-8 w-24 text-xs`,children:[(0,W.jsx)(`option`,{value:`info`,children:`info`}),(0,W.jsx)(`option`,{value:`warn`,children:`warn`}),(0,W.jsx)(`option`,{value:`error`,children:`error`})]}),(0,W.jsx)(h,{type:`submit`,size:`sm`,disabled:i||o.trim()===``,children:`Add`})]})]})}function we({jobId:e}){let t=s(e=>e.baseUrl),n=s(e=>e.token),[r,i]=(0,U.useState)([]),[a,l]=(0,U.useState)(0),[d,f]=(0,U.useState)(!1),[p,m]=(0,U.useState)(null),[h,g]=(0,U.useState)(``),[_,v]=(0,U.useState)(`info`),[y,b]=(0,U.useState)(!1),x=(0,U.useRef)(!1),S=(0,U.useRef)(null),C=(0,U.useRef)(0),w=(0,U.useRef)(null),T=(0,U.useRef)(0),E=(0,U.useRef)(null),D=(0,U.useRef)(!1),O=(0,U.useRef)(0);(0,U.useEffect)(()=>{x.current=!0,S.current=e;let t=()=>{C.current+=1,w.current?.abort(),w.current=null,T.current+=1,E.current?.abort(),E.current=null,D.current=!1,O.current+=1,i([]),l(0),f(!1),m(null),g(``),b(!1)},n=s.subscribe((e,n)=>{e.baseUrl===n.baseUrl&&e.token===n.token||t()});return t(),()=>{x.current=!1,S.current=null,n(),C.current+=1,w.current?.abort(),w.current=null,T.current+=1,E.current?.abort(),E.current=null,D.current=!1}},[e]);let k=(0,U.useCallback)(async r=>{w.current?.abort();let a=new AbortController;w.current=a;let u=++C.current,d=s.getState(),p=r?.target??(d.baseUrl===t&&d.token===n?{baseUrl:o(),authorization:n?`Bearer ${n}`:void 0}:Z()),h=()=>x.current&&S.current===e&&u===C.current&&!a.signal.aborted&&ye(p,Z());f(!0),m(null);try{let t=Se(await xe(p,`/jobs/${c(e)}/logs`,{},a.signal));return h()?(i(t.logs),l(t.count),!0):!1}catch(e){if(!h())return!1;let t=e instanceof Error?e.message:String(e);return m(r?.acceptedLabel?`${r.acceptedLabel} succeeded, but couldn't reload logs: ${t}`:t),!1}finally{u===C.current&&(w.current===a&&(w.current=null),x.current&&f(!1))}},[e,t,n]);(0,U.useEffect)(()=>{k()},[k]);let A=async(t,n,r)=>{if(D.current)return;D.current=!0;let i=new AbortController;E.current=i;let a=++T.current,o=Z();C.current+=1,w.current?.abort(),w.current=null,f(!1),b(!0),m(null);let s=()=>x.current&&S.current===e&&a===T.current&&!i.signal.aborted&&ye(o,Z());try{let a=await xe(o,`/jobs/${c(e)}/logs`,t,i.signal);if(!a||typeof a!=`object`||Array.isArray(a)||a.ok!==!0)throw new u(`Invalid log mutation response: expected { ok: true }`,200);if(!s())return;r(),await k({acceptedLabel:n,target:o})}catch(e){s()&&m(e instanceof Error?e.message:String(e))}finally{a===T.current&&(D.current=!1,E.current===i&&(E.current=null),x.current&&b(!1))}},j=async(e=h,t=_)=>{if(D.current)return;let n=e.trim();if(!n)return;let r=t===`warn`||t===`error`?t:`info`,i=O.current;g(e),v(r),await A({method:`POST`,body:JSON.stringify({message:n,level:r})},`Log addition`,()=>{O.current===i&&g(``)})},M=async()=>{D.current||window.confirm(`Clear all logs for this job?`)&&await A({method:`DELETE`},`Log clearing`,()=>{i([]),l(0)})};return(0,W.jsx)(Ce,{logs:r,count:a,loading:d,busy:y,error:p,message:h,level:_,draftRevision:O,setMessage:g,setLevel:v,load:()=>void k(),clear:()=>void M(),add:(e,t)=>void j(e,t)})}function Te({timeline:e}){let t=e??[];return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Timeline`}),t.length===0?(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,W.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,W.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(b,{status:e.state}),e.attempt!=null&&(0,W.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,W.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:C(e.timestamp)})]}),(e.worker||e.error)&&(0,W.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,W.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,W.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function Ee(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return e.failedReason?{message:e.failedReason}:null}function De({job:e,result:t,resultError:n,loading:r,notFound:i,busy:a,lookup:o,act:s}){if(r&&!e)return(0,W.jsx)(v,{label:`Loading job…`});if(i)return(0,W.jsx)(y,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`});if(!e)return(0,W.jsx)(y,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`});let c=e.state,l=Ee(e),u=e.stacktrace?.length?ne(e.stacktrace):null,f=(e.childrenIds?.length??0)>0,p=_e(c,e),m=c===`failed`,h=l||u?(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Error`}),l&&(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`p`,{className:`text-sm text-danger`,children:l.message}),(0,W.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[l.attempt==null?``:`Attempt ${l.attempt} · `,C(l.timestamp)]})]}),u&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:u.text}),u.truncated&&(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-faint`,children:[`Stack preview truncated (`,u.displayedLines,` of `,u.totalLines,` `,`lines, 262,144 characters maximum). Download JSON for the complete stored stack.`]})]})]}):null;return(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,W.jsx)(Oe,{job:e}),m&&h,(0,W.jsx)(me,{data:e.data,busy:a,editable:p===null,readOnlyReason:p??void 0,onSave:t=>s(`Data`,()=>d.updateJobData(e.id,t))},`data-${e.id}`),c===`completed`&&(0,W.jsx)(ke,{jobId:e.id,result:t,resultError:n,loading:r,onRetry:()=>o(e.id,`id`)}),!m&&h,(0,W.jsx)(we,{jobId:e.id},`logs-${e.id}`),f&&(0,W.jsx)(pe,{jobId:e.id},`children-${e.id}`),(0,W.jsx)(Te,{timeline:e.timeline}),(0,W.jsx)(fe,{job:e})]}),(0,W.jsx)(`div`,{className:`order-first lg:order-none`,children:(0,W.jsx)(ce,{job:e,busy:a,act:s})})]})}function Oe({job:e}){return(0,W.jsxs)(_,{children:[(0,W.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:e.id}),(0,W.jsx)(w,{value:e.id})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:e.queue})]}),(0,W.jsx)(b,{status:e.state??`unknown`})]}),(0,W.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,W.jsx)(Q,{label:`Priority`,value:String(e.priority??0)}),(0,W.jsx)(Q,{label:`Name`,value:e.name??`default`}),(0,W.jsx)(Q,{label:`Attempts`,value:`${e.attempts??0} / ${e.maxAttempts??`?`}`}),(0,W.jsx)(Q,{label:`Progress`,value:`${e.progress??0}%`}),(0,W.jsx)(Q,{label:`Created`,value:C(e.createdAt)}),(0,W.jsx)(Q,{label:`Started`,value:C(e.startedAt??void 0)}),(0,W.jsx)(Q,{label:`Completed`,value:C(e.completedAt??void 0)}),(0,W.jsx)(Q,{label:`Duration`,value:S(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,W.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,W.jsx)(`span`,{className:`truncate font-mono`,children:e.customId??`—`}),e.customId&&(0,W.jsx)(w,{value:e.customId})]})]})]})]})}function ke({jobId:e,result:t,resultError:n,loading:r,onRetry:i}){let a=t.fetched&&t.value!==void 0&&t.value!==null;return(0,W.jsxs)(_,{children:[(0,W.jsx)(g,{title:`Result`,action:a?(0,W.jsx)(je,{value:t.value,filename:`job-${e}-result`}):void 0}),a?(0,W.jsx)(Ae,{value:t.value}):n?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,W.jsxs)(`p`,{className:`text-xs text-danger`,children:[`Couldn't load result — `,n]}),(0,W.jsx)(h,{size:`sm`,disabled:r,onClick:i,children:`Retry`})]}):(0,W.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]})}function Q({label:e,value:t}){return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`text-fg`,children:t})]})}function Ae({value:e}){return(0,W.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(e??null,null,2)})}function je({value:e,filename:t}){return(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(w,{value:JSON.stringify(e??null,null,2)}),(0,W.jsx)(m,{"aria-label":`Download JSON`,title:`Download JSON`,onClick:()=>k(t,e??null),children:(0,W.jsx)(p,{className:`size-3.5`})})]})}function Me(e){let t={};return typeof e.priority==`number`&&(t.priority=e.priority),typeof e.maxAttempts==`number`&&(t.maxAttempts=e.maxAttempts),typeof e.backoff==`number`&&(t.backoff=e.backoff),e.backoffConfig&&typeof e.backoffConfig.delay==`number`&&(t.backoffConfig={type:e.backoffConfig.type,delay:e.backoffConfig.delay},typeof t.backoff!=`number`&&(t.backoff=e.backoffConfig.delay)),typeof e.timeout==`number`&&(t.timeout=e.timeout),typeof e.removeOnComplete==`boolean`&&(t.removeOnComplete=e.removeOnComplete),typeof e.removeOnFail==`boolean`&&(t.removeOnFail=e.removeOnFail),typeof e.ttl==`number`&&(t.ttl=e.ttl),Array.isArray(e.tags)&&e.tags.length&&(t.tags=[...e.tags]),typeof e.groupId==`string`&&e.groupId&&(t.groupId=e.groupId),{clone:{queue:e.queue??``,name:e.name,dataText:JSON.stringify(e.data??{},null,2),options:t}}}function Ne({job:e,result:t,idInput:n,lookupBy:r,loading:a,busy:o,onInputChange:s,onModeChange:c,onSubmit:l}){let u=!!(e&&((e.childrenIds?.length??0)>0||e.parentId));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(x,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:e?(0,W.jsxs)(W.Fragment,{children:[u&&(0,W.jsx)(i,{to:`/flows?root=${encodeURIComponent(e.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}),(0,W.jsx)(i,{to:`/add-job`,state:Me(e),title:`Enqueue a new job pre-filled from this one`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Clone`}),(0,W.jsxs)(h,{size:`sm`,onClick:()=>k(`job-${e.id}`,t.fetched?{...e,result:t.value}:e),children:[(0,W.jsx)(p,{className:`size-3.5`}),` Download JSON`]})]}):void 0}),(0,W.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,W.jsxs)(T,{name:`job-lookup-mode`,autoComplete:`off`,value:r,"aria-label":`Lookup mode`,onChange:e=>c(e.target.value),className:`w-40`,children:[(0,W.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,W.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,W.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,W.jsx)(f,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,W.jsx)(`input`,{value:n,"aria-label":r===`custom`?`Custom job ID`:`Job ID`,name:`job-lookup-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,onInput:e=>s(e.currentTarget.value),onKeyDown:e=>e.key===`Enter`&&l(n),placeholder:r===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,W.jsx)(h,{variant:`accent`,disabled:a||o,onClick:()=>l(n),children:`Look up`})]})]})}function Pe({state:e,lookup:t,setParams:n,locationKey:r,idParam:i,customParam:a,jobBelongsToCurrentTarget:o,connectionBaseUrl:s,connectionToken:c}){(0,U.useEffect)(()=>{if(e.internalEmptyUrlPending.current){!i&&!a&&(e.internalEmptyUrlPending.current=!1,e.preservedEmptyLocationKey.current=r);return}if(!(!i&&!a&&e.preservedEmptyLocationKey.current===r))if(e.preservedEmptyLocationKey.current=null,a)if(e.job?.customId===a&&o)e.setLookupBy(`id`),e.setIdInput(e.job.id),n({id:e.job.id},{replace:!0});else{e.setLookupBy(`custom`),e.setIdInput(a);let n=e.lookupIdentity.current;(n?.mode!==`custom`||n.key!==a)&&t(a,`custom`,!1,void 0,!0)}else if(i&&(i!==e.job?.id||!o)){e.setLookupBy(`id`),e.setIdInput(i);let n=e.lookupIdentity.current;(n?.mode!==`id`||n.key!==i)&&t(i,`id`,!1,void 0,!0)}else!i&&!a&&(e.lookupGen.current+=1,e.lookupAbort.current?.abort(),e.lookupAbort.current=null,e.lookupIdentity.current=null,e.actionGen.current+=1,e.jobTarget.current=null,e.setJob(null),e.setResult({fetched:!1,value:void 0}),e.setResultError(null),e.setNotFound(!1),e.setMsg(null),e.setLoading(!1),e.setLookupBy(`id`),e.setIdInput(``))},[i,a,e.job?.id,e.job?.customId,o,r,s,c])}var $={fetched:!1,value:void 0};function Fe(e,t){let[n,r]=(0,U.useState)(e??t??``),[i,a]=(0,U.useState)(e?`custom`:`id`),[o,c]=(0,U.useState)(null),[l,u]=(0,U.useState)($),[d,f]=(0,U.useState)(null),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null),[y,b]=(0,U.useState)(!1),x=(0,U.useRef)(0),S=(0,U.useRef)(null),C=(0,U.useRef)(null),w=(0,U.useRef)(null),T=(0,U.useRef)(!1),E=(0,U.useRef)(null),D=(0,U.useRef)(!1),O=(0,U.useRef)(0),k=(0,U.useRef)(!1),A=(0,U.useRef)(null);return(0,U.useEffect)(()=>{D.current=!0;let e=s.subscribe((e,t)=>{e.baseUrl===t.baseUrl&&e.token===t.token||(x.current+=1,S.current?.abort(),S.current=null,C.current=null,O.current+=1,A.current=null,k.current=!1,w.current=null,T.current=!1,E.current=null,c(null),u($),f(null),g(!1),v(null),m(!1),b(!1))});return()=>{D.current=!1,e(),x.current+=1,S.current?.abort(),S.current=null,C.current=null,O.current+=1,A.current=null,k.current=!1}},[]),{idInput:n,setIdInput:r,lookupBy:i,setLookupBy:a,job:o,setJob:c,result:l,setResult:u,resultError:d,setResultError:f,loading:p,setLoading:m,notFound:h,setNotFound:g,msg:_,setMsg:v,busy:y,setBusy:b,lookupGen:x,lookupAbort:S,lookupIdentity:C,jobTarget:w,internalEmptyUrlPending:T,preservedEmptyLocationKey:E,mounted:D,actionGen:O,actionBusy:k,actionLockOwner:A}}function Ie(){let e=r(),[n,i]=t(),a=s(e=>e.baseUrl),c=s(e=>e.token),l=Fe(n.get(`custom`),n.get(`id`)),d=se(l,i),f=n.get(`id`),p=n.get(`custom`),m={baseUrl:o(),authorization:c?`Bearer ${c}`:void 0},h=B(l.jobTarget.current,m);return Pe({state:l,lookup:d,setParams:i,locationKey:e.key,idParam:f,customParam:p,jobBelongsToCurrentTarget:h,connectionBaseUrl:a,connectionToken:c}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(Ne,{job:l.job,result:l.result,idInput:l.idInput,lookupBy:l.lookupBy,loading:l.loading,busy:l.busy,onInputChange:l.setIdInput,onModeChange:l.setLookupBy,onSubmit:(e,t=l.lookupBy)=>{let n=e.trim();if(!(!n||l.actionBusy.current)){if(t===`id`?f===n&&p===null:p===n&&f===null){d(n,t);return}i(t===`custom`?{custom:n}:{id:n})}}}),l.msg&&(0,W.jsx)(`div`,{role:`status`,className:l.msg.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:l.msg.text}),(0,W.jsx)(De,{job:l.job,result:l.result,resultError:l.resultError,loading:l.loading,notFound:l.notFound,busy:l.busy,lookup:d,act:async(e,t,n)=>{if(!l.job||l.actionBusy.current||l.lookupAbort.current)return;let r=z();if(!B(l.jobTarget.current,r)||n&&!window.confirm(n))return;let a=++l.actionGen.current,o=l.job.id;l.actionLockOwner.current=a,l.actionBusy.current=!0,l.setBusy(!0),l.setMsg(null);let s=()=>l.mounted.current&&a===l.actionGen.current&&B(r,z())&&B(l.jobTarget.current,r);try{let n=await t();if(!n||typeof n!=`object`||Array.isArray(n)||n.ok!==!0)throw new u(`Invalid job mutation response: expected { ok: true }`,200);if(!s())return;l.setMsg({ok:!0,text:`${e} ✓`}),e===`Cancel`?(l.internalEmptyUrlPending.current=!0,l.preservedEmptyLocationKey.current=null,l.lookupGen.current+=1,l.jobTarget.current=null,l.setJob(null),l.setResult({fetched:!1,value:void 0}),l.setResultError(null),i({},{replace:!0})):await d(o,`id`,!0,a)}catch(e){s()&&l.setMsg({ok:!1,text:e.message})}finally{l.actionLockOwner.current===a&&(l.actionLockOwner.current=null,l.actionBusy.current=!1,l.mounted.current&&l.setBusy(!1))}}})]})}export{Ie as JobInspector};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,r,t as i}from"./react-vendor-CyjgmGTq.js";import{t as a}from"./bq-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,r,t as i}from"./react-vendor-CyjgmGTq.js";import{t as a}from"./bq-Bmysbg0r.js";import{T as o}from"./icons-CIvFfU2b.js";import{t as s}from"./api-V_sVpHDo.js";import{n as c}from"./usePolledData-g80Z_UB-.js";import{i as l,r as u}from"./feedback-BnGE2oW2.js";import{t as d}from"./StatusBadge-B0I7hNBX.js";import{t as f}from"./PageHeader-BXlZSBcc.js";import{a as p,c as m,d as h,l as g,s as _,t as v}from"./format-Cg7VCIZW.js";import{n as y}from"./index-Cue53Myw.js";import{a as b,i as x}from"./form-tC20r4Ma.js";import{r as S}from"./flowMutationSafety-DObp9nJo.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";var w=e(n(),1),T=`__all__`,E=[`all`,`waiting`,`active`,`completed`,`failed`],D=500,O=20,k=D*O;function A(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>k||n!==null&&e.total!==n||e.offset!==t||e.limit!==D||e.queues.length!==Math.min(D,e.total-t)||e.queues.length>D||e.queues.some(e=>typeof e!=`object`||!e||typeof e.name!=`string`||e.name.length===0||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)))throw Error(`Queue discovery returned a malformed or unsafe page`)}async function j(){let e=await s.queues(D,0);A(e,0,null);let t=[...e.queues],n=new Set;for(let e of t){if(n.has(e.name))throw Error(`Queue discovery returned duplicate queue ${e.name}`);n.add(e.name)}let r=e.total,i=1;for(;t.length<r;){if(i>=O||t.length>=k)throw Error(`Queue discovery exceeds the safety limit of ${k}`);let e=t.length,a=await s.queues(D,e);A(a,e,r);for(let e of a.queues){if(n.has(e.name))throw Error(`Queue discovery pages overlap at queue ${e.name}`);n.add(e.name),t.push(e)}i+=1}return{...e,queues:t,total:r,limit:t.length,offset:0}}function M(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}var N=i();function P({rows:e,emptyMessage:t}){return(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,N.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,N.jsx)(`tbody`,{children:e.length===0?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:t})}):e.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,N.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`text-accent/90 hover:text-accent hover:underline`,title:`Inspect job ${e.id}`,children:e.id})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??M(e.data)??`default`}),(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,N.jsx)(`td`,{className:`px-5 py-3`,children:(0,N.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(h(e.startedAt??void 0,e.completedAt??void 0))}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,N.jsx)(`span`,{className:`text-xs text-faint`,title:S,children:`Delete unavailable`})})]},`${e.queue}:${e.id}`))})]})})}var F=8;function I(){let[e]=t(),[n,r]=(0,w.useState)(e.get(`queue`)??`__all__`),[i,d]=(0,w.useState)(`all`),[p,h]=(0,w.useState)(``),{data:g,error:S,refetch:D}=c(j,[],{intervalMs:3e4}),{data:O,error:k,refetch:A}=c(()=>s.overview(),[]),I=(0,w.useMemo)(()=>(g?.queues??[]).map(e=>e.name),[g]),L=`${n}\u0000${i}\u0000${JSON.stringify(I)}`,{data:R,error:z,loading:B,refetch:V}=c((0,w.useCallback)(async e=>{if(n===`__all__`&&!g)return null;let t=n===`__all__`?I:[n];if(n===`__all__`&&t.length>100)return{scopeKey:L,jobs:[],failures:[],queueCount:t.length,blockedReason:`All-queue job browsing is limited to 100 queues; ${_(t.length)} were discovered. Select one queue to avoid an unsafe request fan-out.`};let r=i===`all`?void 0:[i],o=a.createServerTargetClient(a.captureServerRequestTarget(),e),s=await C(t,F,async t=>(e.throwIfAborted(),(await o.jobsList(t,r,40)).jobs.map(e=>({...e,stacktrace:e.stacktrace??void 0,queue:e.queue??t}))),e);e.throwIfAborted();let c=[],l=[];return s.forEach((e,n)=>{e.status===`fulfilled`?c.push(...e.value):l.push({queue:t[n],message:e.reason instanceof Error?e.reason.message:String(e.reason)})}),{scopeKey:L,jobs:c.sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)),failures:l,queueCount:t.length,blockedReason:null}},[n,i,g,I,L]),[L],{intervalMs:15e3}),H=R?.scopeKey===L?R:null,U=H?.blockedReason?null:H?.jobs??null,{rows:W,matchingCount:G}=(0,w.useMemo)(()=>{let e=U??[],t=p.trim().toLowerCase(),n=t?e.filter(e=>typeof e.id==`string`&&e.id.toLowerCase().includes(t)||(M(e.data)?.toLowerCase().includes(t)??!1)):e;return{rows:n.slice(0,100),matchingCount:n.length}},[U,p]),K=O?.stats,q=K?v(K.totalCompleted,K.totalFailed):null,J=e=>K?_(e):`—`,Y=!!H&&H.queueCount>0&&H.failures.length===H.queueCount,X=n===`__all__`&&!g&&!S||B&&!H&&!z,Z=`No jobs found.`;return H?.blockedReason?Z=H.blockedReason:n===`__all__`&&S&&!g?Z=`Queue discovery unavailable — ${S.message}`:z&&!H?Z=`Could not load jobs — ${z.message}`:Y?Z=`Could not load jobs from any of the ${H.queueCount} queues.`:p.trim()&&H?.failures.length?Z=`No matching jobs in the queue results that could be loaded.`:p.trim()&&(Z=`No jobs match this search.`),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!H&&!S&&!k&&!z&&!H.blockedReason&&H.failures.length===0}),S&&(0,N.jsx)(l,{message:`Queue discovery unavailable — ${S.message}`,onRetry:D}),k&&(0,N.jsx)(l,{message:`Job totals unavailable — ${k.message}`,onRetry:A}),z&&(0,N.jsx)(l,{message:`Could not load jobs — ${z.message}`,onRetry:V}),H?.blockedReason&&(0,N.jsx)(l,{message:H.blockedReason}),!!H?.failures.length&&(0,N.jsx)(l,{message:`Could not load jobs from ${H.failures.length} of ${H.queueCount} queues: ${H.failures.slice(0,3).map(e=>`${e.queue} (${e.message})`).join(`, `)}${H.failures.length>3?`, …`:``}`,onRetry:V}),(0,N.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,N.jsx)(y,{label:`Total`,value:K?_(K.totalCompleted+K.totalFailed+K.waiting+K.active):`—`,compact:!0}),(0,N.jsx)(y,{label:`Waiting`,value:J(K?.waiting),tone:`amber`,compact:!0}),(0,N.jsx)(y,{label:`Active`,value:J(K?.active),tone:`blue`,compact:!0}),(0,N.jsx)(y,{label:`Completed`,value:J(K?.totalCompleted),tone:`green`,compact:!0}),(0,N.jsx)(y,{label:`Failed`,value:J(K?.totalFailed),tone:K?.totalFailed?`red`:`default`,compact:!0}),(0,N.jsx)(y,{label:`Error Rate`,value:q==null?`—`:m(q),tone:q==null?`default`:q>.05?`red`:`green`,compact:!0})]}),(0,N.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(`div`,{className:`w-48`,children:(0,N.jsxs)(b,{value:n,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>r(e.target.value),children:[(0,N.jsx)(`option`,{value:T,children:`All Queues`}),(g?.queues??[]).map(e=>(0,N.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,N.jsx)(x,{options:E,value:i,onChange:d}),(0,N.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,N.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,N.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),"aria-label":`Search jobs`,name:`jobs-search`,autoComplete:`off`,placeholder:`Search by ID or name…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),H&&!H.blockedReason&&(0,N.jsxs)(`p`,{role:`status`,className:`mb-3 text-xs text-faint`,children:[n===`__all__`?`Queried all ${_(H.queueCount)} discovered queues`:`Queried ${n}`,` `,`· up to `,40,` recent jobs per queue`,G>100?` · showing the newest 100 of ${_(G)} matches`:``]}),X?(0,N.jsx)(u,{label:`Loading jobs…`}):(0,N.jsx)(P,{rows:W,emptyMessage:Z})]})}export{I as Jobs,j as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{t as o}from"./bq-DYmbVkgR.js";import{t as s}from"./toastStore-B7n0zS0y.js";import{T as c,d as l,f as u,x as d}from"./icons-CIvFfU2b.js";import{n as f}from"./usePolledData-c53tx1jw.js";import{n as p,t as m}from"./Button-BPqpRZJD.js";import{i as h,n as g,r as _}from"./feedback-BnGE2oW2.js";import{t as v}from"./StatusBadge-B0I7hNBX.js";import{t as y}from"./PageHeader-BXlZSBcc.js";import{a as b,c as x,i as S,s as C,t as ee}from"./format-Cg7VCIZW.js";import{n as w}from"./index-D64v2vNO.js";import{a as T}from"./form-tC20r4Ma.js";import{t as E}from"./Pagination-Q-vf4hsX.js";import{r as D,t as O}from"./useServerActionGuard-OTv6_fU0.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as k}from"./jobActions-LQD4KfCc.js";var A=e(r(),1),j=a();function ne(e){return(0,j.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,j.jsx)(w,{label:`Total`,value:e.total,hint:`all queues`,compact:!0}),(0,j.jsx)(w,{label:`Waiting`,value:e.waiting,tone:`amber`,hint:`standard priority`,compact:!0}),(0,j.jsx)(w,{label:`Prioritized`,value:e.prioritized,tone:`amber`,compact:!0}),(0,j.jsx)(w,{label:`Active`,value:e.active,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Flow-blocked`,value:e.flowBlocked,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Completed`,value:e.completed,tone:`green`,compact:!0}),(0,j.jsx)(w,{label:`Failed`,value:e.failed,tone:e.failedCount!=null&&e.failedCount>0?`red`:`default`,compact:!0}),(0,j.jsx)(w,{label:`Error Rate`,value:e.errorRate,tone:e.errorRateTone,compact:!0})]})}var M=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`];function N(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function P(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function F(e=0){return e>=10?{text:`HIGH`,className:`text-warning`}:e>=1?{text:`MEDIUM`,className:`text-blue-400`}:{text:`LOW`,className:`text-faint`}}function re({queue:e,rows:n,search:r,discoveryError:a,selected:s,allSelected:c,bulkBusy:l,busyIds:f,page:m,hasNext:h,onToggleAll:g,onToggle:_,onRun:y,onPage:x}){return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,j.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:e})]}),(0,j.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:c,ref:e=>{e&&(e.indeterminate=s.size>0&&!c)},"aria-checked":s.size>0&&!c?`mixed`:c,onChange:g,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,j.jsx)(`tbody`,{children:n.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:r.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:a?`Queue discovery failed. Retry above.`:`Select a queue.`})}):n.map(e=>{let n=F(e.priority),r=k(e.state),a=l||f.has(e.id);return(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:s.has(e.id),onChange:()=>_(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,j.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(v,{status:String(e.state??`waiting`)})}),(0,j.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.className),children:n.text}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:S(e.createdAt)}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,j.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect job ${e.id}`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,j.jsx)(u,{className:`size-3.5`})}),r.promote&&(0,j.jsx)(p,{"aria-label":`Promote job`,disabled:a,onClick:()=>y(e,`Promote`,()=>o.promoteJob(e.id)),children:(0,j.jsx)(d,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,j.jsx)(E,{page:m,pageSize:25,hasNext:h,onPageChange:x,label:`jobs`})]})}function I({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:s,onQueue:l,onStatus:u,onSearch:d,onPromote:f}){return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{value:e,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:t.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{"aria-label":`Job state`,name:`jobs-state`,value:n,onChange:e=>u(e.target.value),children:M.map(e=>(0,j.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,j.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,j.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,j.jsx)(`input`,{value:r,onChange:e=>d(e.target.value),placeholder:`Filter this page by ID or name…`,"aria-label":`Filter by job ID or name`,name:`jobs-id-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),i>0&&(0,j.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`mr-1 text-muted`,children:N(a,i)}),o?(0,j.jsx)(m,{size:`sm`,disabled:s,onClick:f,children:`Promote selected`}):(0,j.jsx)(`span`,{className:`text-xs text-faint`,children:a===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]})]})}function ie({queue:e,rows:t,selected:n,setSelected:r,refetch:i}){let[a,o]=(0,A.useState)(new Set),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(null),f=D(`jobs:${e}`);return(0,A.useEffect)(()=>{o(new Set),l(!1),d(null)},[f.scopeKey]),{actionMsg:u,bulkBusy:c,busyIds:a,runBulk:async(e,a,o,c)=>{let u=t.filter(e=>n.has(e.id)&&o(e));if(u.length===0||c&&!window.confirm(c(u.length)))return;let p=f.begin([`bulk`,...u.map(e=>`job:${e.id}`)]);if(p){l(!0),d(null);try{let t=await Promise.allSettled(u.map(async t=>{O(await a(t),`${e} ${t.id}`)}));if(!p.isCurrent())return;let n=t.filter(e=>e.status===`fulfilled`).length,o=t.length-n,c=`${e}: ${n} succeeded${o?`, ${o} failed`:``}`;d({ok:o===0,text:c}),o===0?s.success(c):s.error(c),r(e=>P(e,u.map(e=>e.id))),i()}finally{p.finish()&&l(!1)}}},runOne:async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let a=f.begin(`job:${e.id}`);if(a){o(t=>new Set(t).add(e.id)),d(null);try{if(O(await n(),t),!a.isCurrent())return;d({ok:!0,text:`${t} ✓`}),s.success(`${t} ✓`,e.id),i()}catch(e){if(!a.isCurrent())return;d({ok:!1,text:`${t} failed: ${e.message}`}),s.error(`${t} failed`,e.message)}finally{a.finish()&&o(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function L(){let[e,t]=n(),[r,i]=(0,A.useState)(e.get(`queue`)??``),[a,c]=(0,A.useState)(()=>{let t=e.get(`status`);return t&&M.includes(t)?t:`all`}),[u,d]=(0,A.useState)(``),[p,v]=(0,A.useState)(0),[b,S]=(0,A.useState)(new Set),{data:w,error:T,loading:E,refetch:D}=f(()=>o.queuesSummary(),[],{intervalMs:3e4}),{data:O,error:N,refetch:P}=f(()=>o.stats(),[],{intervalMs:1e4});(0,A.useEffect)(()=>{!r&&w?.length&&i(w[0].name)},[w,r]);let F=`${r}|${a}|${p}`,{data:L,error:R,loading:z,refetch:B}=f((0,A.useCallback)(async()=>{if(!r)return{view:F,jobs:[]};let e=a===`all`?void 0:[a],t=await o.jobsList(r,e,25,p*25);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,a,p,F]),[r,a,p]),V=L&&L.view===F?L.jobs:null,ae=(V?.length??0)===25,H=(0,A.useMemo)(()=>{let e=u.trim().toLowerCase();return e?(V??[]).filter(t=>t.id.toLowerCase().includes(e)||t.name?.toLowerCase().includes(e)):V??[]},[V,u]),U=O?.stats,W=(0,A.useMemo)(()=>w?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[w]),G=U&&W!=null?ee(U.completed,W):null,K=e=>U?C(e):`—`,q=()=>v(0),J=(e,n)=>{let r={};e&&(r.queue=e),n!==`all`&&(r.status=n),t(r,{replace:!0})};(0,A.useEffect)(()=>{S(new Set)},[r,a,p]);let oe=e=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=H.length>0&&H.every(e=>b.has(e.id)),se=()=>S(()=>Y?new Set:new Set(H.map(e=>e.id))),{actionMsg:X,bulkBusy:Z,busyIds:ce,runBulk:le,runOne:ue}=ie({queue:r,rows:H,selected:b,setSelected:S,refetch:B}),Q={promote:e=>k(e.state).promote},$=H.filter(e=>b.has(e.id)),de={promote:$.some(Q.promote)};return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(y,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!r&&V!=null&&!R&&!T&&!N,actions:(0,j.jsxs)(m,{size:`sm`,disabled:!V||H.length===0,onClick:()=>{if(H.length===0){s.info(`No jobs to export on this page`);return}let e=H.map(e=>({id:e.id,name:e.name??`default`,queue:e.queue??r,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));te(`jobs-${r}-${a}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,j.jsx)(l,{className:`size-3.5`}),` Export CSV`]})}),T&&(0,j.jsx)(h,{onRetry:D,message:w?`Queue inventory refresh failed — showing the last successful queue totals. ${T.message}`:`Could not discover queues — ${T.message}. Select an existing queue from the URL or retry.`}),N&&(0,j.jsx)(h,{onRetry:P,message:O?`Server-wide totals refresh failed — showing the last successful totals. ${N.message}`:`Server-wide job totals are unavailable — ${N.message}. The selected queue page may still be current.`}),(0,j.jsx)(ne,{total:U&&W!=null?C(U.completed+W+U.waiting+U.prioritized+U.active+U.delayed+U[`waiting-children`]):`—`,waiting:K(U?.waiting),prioritized:K(U?.prioritized),active:K(U?.active),flowBlocked:K(U?.[`waiting-children`]),completed:K(U?.completed),failed:W==null?`—`:C(W),failedCount:W,errorRate:G==null?`—`:x(G),errorRateTone:G==null?`default`:G>.05?`red`:`green`}),(0,j.jsx)(I,{queue:r,summary:w??[],status:a,search:u,selectedTotal:b.size,selectedVisible:$.length,canPromote:de.promote,bulkBusy:Z,onQueue:e=>{i(e),q(),J(e,a)},onStatus:e=>{c(e),q(),J(r,e)},onSearch:d,onPromote:()=>le(`Promote`,e=>o.promoteJob(e.id),Q.promote)}),X&&(0,j.jsx)(`div`,{role:`status`,className:`mb-3 text-sm ${X.ok?`text-success`:`text-danger`}`,children:X.text}),R&&V&&(0,j.jsx)(h,{message:`Job refresh failed — showing the last successful page.`,onRetry:B}),R&&!V?(0,j.jsx)(g,{error:R,onRetry:B}):E&&!w&&!r&&!T?(0,j.jsx)(_,{label:`Discovering queues…`}):z&&!V?(0,j.jsx)(_,{label:`Loading jobs…`}):(0,j.jsx)(re,{queue:r,rows:H,search:u,discoveryError:!!T,selected:b,allSelected:Y,bulkBusy:Z,busyIds:ce,page:p,hasNext:ae,onToggleAll:se,onToggle:oe,onRun:(e,t,n)=>void ue(e,t,n),onPage:v})]})}export{L as JobsPro};
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{t as o}from"./bq-Bmysbg0r.js";import{t as s}from"./toastStore-B7n0zS0y.js";import{T as c,d as l,f as u,x as d}from"./icons-CIvFfU2b.js";import{n as f}from"./usePolledData-g80Z_UB-.js";import{n as p,t as m}from"./Button-BPqpRZJD.js";import{i as h,n as g,r as _}from"./feedback-BnGE2oW2.js";import{t as v}from"./StatusBadge-B0I7hNBX.js";import{t as y}from"./PageHeader-BXlZSBcc.js";import{a as b,c as x,i as S,s as C,t as ee}from"./format-Cg7VCIZW.js";import{n as w}from"./index-Cue53Myw.js";import{a as T}from"./form-tC20r4Ma.js";import{t as E}from"./Pagination-Q-vf4hsX.js";import{r as D,t as O}from"./useServerActionGuard-OTv6_fU0.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as k}from"./jobActions-LQD4KfCc.js";var A=e(r(),1),j=a();function ne(e){return(0,j.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,j.jsx)(w,{label:`Total`,value:e.total,hint:`all queues`,compact:!0}),(0,j.jsx)(w,{label:`Waiting`,value:e.waiting,tone:`amber`,hint:`standard priority`,compact:!0}),(0,j.jsx)(w,{label:`Prioritized`,value:e.prioritized,tone:`amber`,compact:!0}),(0,j.jsx)(w,{label:`Active`,value:e.active,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Flow-blocked`,value:e.flowBlocked,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Completed`,value:e.completed,tone:`green`,compact:!0}),(0,j.jsx)(w,{label:`Failed`,value:e.failed,tone:e.failedCount!=null&&e.failedCount>0?`red`:`default`,compact:!0}),(0,j.jsx)(w,{label:`Error Rate`,value:e.errorRate,tone:e.errorRateTone,compact:!0})]})}var M=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`];function N(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function P(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function F(e=0){return e>=10?{text:`HIGH`,className:`text-warning`}:e>=1?{text:`MEDIUM`,className:`text-blue-400`}:{text:`LOW`,className:`text-faint`}}function re({queue:e,rows:n,search:r,discoveryError:a,selected:s,allSelected:c,bulkBusy:l,busyIds:f,page:m,hasNext:h,onToggleAll:g,onToggle:_,onRun:y,onPage:x}){return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,j.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:e})]}),(0,j.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:c,ref:e=>{e&&(e.indeterminate=s.size>0&&!c)},"aria-checked":s.size>0&&!c?`mixed`:c,onChange:g,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,j.jsx)(`tbody`,{children:n.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:r.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:a?`Queue discovery failed. Retry above.`:`Select a queue.`})}):n.map(e=>{let n=F(e.priority),r=k(e.state),a=l||f.has(e.id);return(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:s.has(e.id),onChange:()=>_(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,j.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(v,{status:String(e.state??`waiting`)})}),(0,j.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.className),children:n.text}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:S(e.createdAt)}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,j.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect job ${e.id}`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,j.jsx)(u,{className:`size-3.5`})}),r.promote&&(0,j.jsx)(p,{"aria-label":`Promote job`,disabled:a,onClick:()=>y(e,`Promote`,()=>o.promoteJob(e.id)),children:(0,j.jsx)(d,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,j.jsx)(E,{page:m,pageSize:25,hasNext:h,onPageChange:x,label:`jobs`})]})}function I({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:s,onQueue:l,onStatus:u,onSearch:d,onPromote:f}){return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{value:e,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:t.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{"aria-label":`Job state`,name:`jobs-state`,value:n,onChange:e=>u(e.target.value),children:M.map(e=>(0,j.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,j.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,j.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,j.jsx)(`input`,{value:r,onChange:e=>d(e.target.value),placeholder:`Filter this page by ID or name…`,"aria-label":`Filter by job ID or name`,name:`jobs-id-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),i>0&&(0,j.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`mr-1 text-muted`,children:N(a,i)}),o?(0,j.jsx)(m,{size:`sm`,disabled:s,onClick:f,children:`Promote selected`}):(0,j.jsx)(`span`,{className:`text-xs text-faint`,children:a===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]})]})}function ie({queue:e,rows:t,selected:n,setSelected:r,refetch:i}){let[a,o]=(0,A.useState)(new Set),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(null),f=D(`jobs:${e}`);return(0,A.useEffect)(()=>{o(new Set),l(!1),d(null)},[f.scopeKey]),{actionMsg:u,bulkBusy:c,busyIds:a,runBulk:async(e,a,o,c)=>{let u=t.filter(e=>n.has(e.id)&&o(e));if(u.length===0||c&&!window.confirm(c(u.length)))return;let p=f.begin([`bulk`,...u.map(e=>`job:${e.id}`)]);if(p){l(!0),d(null);try{let t=await Promise.allSettled(u.map(async t=>{O(await a(t),`${e} ${t.id}`)}));if(!p.isCurrent())return;let n=t.filter(e=>e.status===`fulfilled`).length,o=t.length-n,c=`${e}: ${n} succeeded${o?`, ${o} failed`:``}`;d({ok:o===0,text:c}),o===0?s.success(c):s.error(c),r(e=>P(e,u.map(e=>e.id))),i()}finally{p.finish()&&l(!1)}}},runOne:async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let a=f.begin(`job:${e.id}`);if(a){o(t=>new Set(t).add(e.id)),d(null);try{if(O(await n(),t),!a.isCurrent())return;d({ok:!0,text:`${t} ✓`}),s.success(`${t} ✓`,e.id),i()}catch(e){if(!a.isCurrent())return;d({ok:!1,text:`${t} failed: ${e.message}`}),s.error(`${t} failed`,e.message)}finally{a.finish()&&o(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function L(){let[e,t]=n(),[r,i]=(0,A.useState)(e.get(`queue`)??``),[a,c]=(0,A.useState)(()=>{let t=e.get(`status`);return t&&M.includes(t)?t:`all`}),[u,d]=(0,A.useState)(``),[p,v]=(0,A.useState)(0),[b,S]=(0,A.useState)(new Set),{data:w,error:T,loading:E,refetch:D}=f(()=>o.queuesSummary(),[],{intervalMs:3e4}),{data:O,error:N,refetch:P}=f(()=>o.stats(),[],{intervalMs:1e4});(0,A.useEffect)(()=>{!r&&w?.length&&i(w[0].name)},[w,r]);let F=`${r}|${a}|${p}`,{data:L,error:R,loading:z,refetch:B}=f((0,A.useCallback)(async()=>{if(!r)return{view:F,jobs:[]};let e=a===`all`?void 0:[a],t=await o.jobsList(r,e,25,p*25);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,a,p,F]),[r,a,p]),V=L?.view===F?L.jobs:null,ae=(V?.length??0)===25,H=(0,A.useMemo)(()=>{let e=u.trim().toLowerCase();return e?(V??[]).filter(t=>t.id.toLowerCase().includes(e)||t.name?.toLowerCase().includes(e)):V??[]},[V,u]),U=O?.stats,W=(0,A.useMemo)(()=>w?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[w]),G=U&&W!=null?ee(U.completed,W):null,K=e=>U?C(e):`—`,q=()=>v(0),J=(e,n)=>{let r={};e&&(r.queue=e),n!==`all`&&(r.status=n),t(r,{replace:!0})};(0,A.useEffect)(()=>{S(new Set)},[r,a,p]);let oe=e=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=H.length>0&&H.every(e=>b.has(e.id)),se=()=>S(()=>Y?new Set:new Set(H.map(e=>e.id))),{actionMsg:X,bulkBusy:Z,busyIds:ce,runBulk:le,runOne:ue}=ie({queue:r,rows:H,selected:b,setSelected:S,refetch:B}),Q={promote:e=>k(e.state).promote},$=H.filter(e=>b.has(e.id)),de={promote:$.some(Q.promote)};return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(y,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!r&&V!=null&&!R&&!T&&!N,actions:(0,j.jsxs)(m,{size:`sm`,disabled:!V||H.length===0,onClick:()=>{if(H.length===0){s.info(`No jobs to export on this page`);return}let e=H.map(e=>({id:e.id,name:e.name??`default`,queue:e.queue??r,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));te(`jobs-${r}-${a}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,j.jsx)(l,{className:`size-3.5`}),` Export CSV`]})}),T&&(0,j.jsx)(h,{onRetry:D,message:w?`Queue inventory refresh failed — showing the last successful queue totals. ${T.message}`:`Could not discover queues — ${T.message}. Select an existing queue from the URL or retry.`}),N&&(0,j.jsx)(h,{onRetry:P,message:O?`Server-wide totals refresh failed — showing the last successful totals. ${N.message}`:`Server-wide job totals are unavailable — ${N.message}. The selected queue page may still be current.`}),(0,j.jsx)(ne,{total:U&&W!=null?C(U.completed+W+U.waiting+U.prioritized+U.active+U.delayed+U[`waiting-children`]):`—`,waiting:K(U?.waiting),prioritized:K(U?.prioritized),active:K(U?.active),flowBlocked:K(U?.[`waiting-children`]),completed:K(U?.completed),failed:W==null?`—`:C(W),failedCount:W,errorRate:G==null?`—`:x(G),errorRateTone:G==null?`default`:G>.05?`red`:`green`}),(0,j.jsx)(I,{queue:r,summary:w??[],status:a,search:u,selectedTotal:b.size,selectedVisible:$.length,canPromote:de.promote,bulkBusy:Z,onQueue:e=>{i(e),q(),J(e,a)},onStatus:e=>{c(e),q(),J(r,e)},onSearch:d,onPromote:()=>le(`Promote`,e=>o.promoteJob(e.id),Q.promote)}),X&&(0,j.jsx)(`div`,{role:`status`,className:`mb-3 text-sm ${X.ok?`text-success`:`text-danger`}`,children:X.text}),R&&V&&(0,j.jsx)(h,{message:`Job refresh failed — showing the last successful page.`,onRetry:B}),R&&!V?(0,j.jsx)(g,{error:R,onRetry:B}):E&&!w&&!r&&!T?(0,j.jsx)(_,{label:`Discovering queues…`}):z&&!V?(0,j.jsx)(_,{label:`Loading jobs…`}):(0,j.jsx)(re,{queue:r,rows:H,search:u,discoveryError:!!T,selected:b,allSelected:Y,bulkBusy:Z,busyIds:ce,page:p,hasNext:ae,onToggleAll:se,onToggle:oe,onRun:(e,t,n)=>void ue(e,t,n),onPage:v})]})}export{L as JobsPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{T as r,h as i}from"./icons-CIvFfU2b.js";import{n as a}from"./usePolledData-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{T as r,h as i}from"./icons-CIvFfU2b.js";import{n as a}from"./usePolledData-g80Z_UB-.js";import{i as o,t as s}from"./feedback-BnGE2oW2.js";import{t as c}from"./StatusBadge-B0I7hNBX.js";import{t as l}from"./PageHeader-BXlZSBcc.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{n as f,t as p}from"./index-Cue53Myw.js";import{a as m,i as h}from"./form-tC20r4Ma.js";import{t as g}from"./Pagination-Q-vf4hsX.js";import{t as _}from"./Jobs-Blavwd1H.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;async function C(){let e=await _();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!Number.isSafeInteger(e.waiting)||e.waiting<0||!Number.isSafeInteger(e.delayed)||e.delayed<0||!Number.isSafeInteger(e.active)||e.active<0||!Number.isSafeInteger(e.dlq)||e.dlq<0||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function w(){let[e,t]=(0,v.useState)(b),[n,_]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O,error:k,refetch:A}=a(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=p(e===b?void 0:e),I=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return j.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[j,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let L=Math.max(1,Math.ceil(I.length/S)),R=Math.min(E,L-1);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(o,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(o,{message:`Event stream unavailable — ${F.message}. Retrying…`}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total Events`,value:d(M.total),compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:d(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:d(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:d(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:d(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Throughput`,value:`${N.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(m,{value:e,"aria-label":`Filter by queue`,name:`classic-activity-queue-filter`,autoComplete:`off`,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(h,{options:x,value:n,onChange:_}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{"aria-label":`Search by job name or ID`,name:`classic-activity-search`,autoComplete:`off`,value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),I.length===0?(0,y.jsx)(s,{icon:(0,y.jsx)(i,{}),title:F?`Event stream unavailable`:P?`Waiting for activity…`:`Connecting to the event stream…`,hint:F?`${F.message}. The dashboard is retrying automatically.`:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:I.slice(R*S,R*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(c,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-CyjgmGTq.js";import{o as i}from"./connectionStore-CKFQrxDo.js";import{T as a}from"./icons-CIvFfU2b.js";import{n as o}from"./usePolledData-
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-CyjgmGTq.js";import{o as i}from"./connectionStore-CKFQrxDo.js";import{T as a}from"./icons-CIvFfU2b.js";import{n as o}from"./usePolledData-g80Z_UB-.js";import{t as s}from"./Button-BPqpRZJD.js";import{i as c}from"./feedback-BnGE2oW2.js";import{t as l}from"./StatusBadge-B0I7hNBX.js";import{t as u}from"./PageHeader-BXlZSBcc.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,n as m,t as h}from"./index-Cue53Myw.js";import{a as g,i as _}from"./form-tC20r4Ma.js";import{t as v}from"./Pagination-Q-vf4hsX.js";import{t as y}from"./QueueControl-CWHsVfWU.js";var b=e(t(),1),x=r(),S=`__all__`,C=[`all`,`waiting`,`active`,`completed`,`failed`],w=10,T=250;function E(){let[e,t]=(0,b.useState)(S),[r,E]=(0,b.useState)(`all`),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0),[j,M]=(0,b.useState)(null),N=j!==null,P=i(t=>JSON.stringify([t.baseUrl,t.token,e])),{data:F,error:I,refetch:L}=o(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=h(e===S?void 0:e),U=(0,b.useMemo)(()=>{let e=j??R,t=D.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[R,j,r,D]),W=N?Math.max(0,(R[0]?.seq??0)-(j[0]?.seq??0)):0;(0,b.useEffect)(()=>A(0),[e,r,D]),(0,b.useEffect)(()=>M(null),[P]);let G=k*w,K=U.slice(G,G+w);return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:V&&!N}),I&&(0,x.jsx)(c,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(c,{message:`Event stream unavailable — ${H.message}. Retrying…`}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,x.jsx)(m,{label:`Total Events`,value:f(z.total),compact:!0}),(0,x.jsx)(m,{label:`Completed`,value:f(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(m,{label:`Failed`,value:f(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(m,{label:`Waiting`,value:f(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(m,{label:`Active`,value:f(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(m,{label:`Throughput`,value:`${B.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(g,{"aria-label":`Filter by queue`,name:`activity-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),children:[(0,x.jsx)(`option`,{value:S,children:`All Queues`}),(F?.queues??[]).map(e=>(0,x.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,x.jsx)(_,{options:C,value:r,onChange:E}),(0,x.jsx)(s,{size:`sm`,variant:N?`warning`:`default`,onClick:()=>M(N?null:R),title:N?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:N?`Resume${W?` — ${f(W)} new`:``}`:`Following · Pause`}),(0,x.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,x.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{"aria-label":`Search by job ID or queue`,name:`activity-search`,autoComplete:`off`,value:D,onChange:e=>O(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,x.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,T,` streamed events held in this browser.`]}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,x.jsx)(`tbody`,{children:K.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:H?`Event stream unavailable — ${H.message}. Retrying…`:V?R.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):K.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(l,{status:e.status})}),(0,x.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:d(e.timestamp)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,x.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,x.jsx)(p,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,x.jsx)(v,{page:k,pageSize:w,total:U.length,onPageChange:A,label:`events`})]})}export{E as LogsPro};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-CyjgmGTq.js";import{n as t,t as n}from"./Card-C7NMhqUt.js";import{t as r}from"./PageHeader-BXlZSBcc.js";import{a as i,n as a}from"./index-
|
|
1
|
+
import{t as e}from"./react-vendor-CyjgmGTq.js";import{n as t,t as n}from"./Card-C7NMhqUt.js";import{t as r}from"./PageHeader-BXlZSBcc.js";import{a as i,n as a}from"./index-Cue53Myw.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-CyjgmGTq.js";import{t}from"./api-V_sVpHDo.js";import{n}from"./usePolledData-
|
|
1
|
+
import{t as e}from"./react-vendor-CyjgmGTq.js";import{t}from"./api-V_sVpHDo.js";import{n}from"./usePolledData-g80Z_UB-.js";import{n as r,t as i}from"./Card-C7NMhqUt.js";import{i as a,n as o,r as s}from"./feedback-BnGE2oW2.js";import{t as c}from"./PageHeader-BXlZSBcc.js";import{n as l,s as u}from"./format-Cg7VCIZW.js";import{n as d}from"./index-Cue53Myw.js";var f=e(),p={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function m(){let{data:e,error:m,loading:_,refetch:v}=n(()=>t.overview(),[]);if(_&&!e&&!m)return(0,f.jsx)(s,{label:`Loading metrics…`});if(m&&!e)return(0,f.jsxs)(`div`,{children:[(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`}),(0,f.jsx)(o,{error:m,onRetry:v})]});let{stats:y,throughput:b,latency:x,memory:S,collections:C}=e??p,w={};for(let[e,t]of Object.entries(x.percentiles??{}))t&&typeof t==`object`&&(w[`${e} p50`]=t.p50,w[`${e} p95`]=t.p95,w[`${e} p99`]=t.p99);return(0,f.jsxs)(`div`,{children:[m&&(0,f.jsx)(a,{message:`Metrics refresh failed — showing the last successful snapshot.`,onRetry:v}),(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!!e&&!m}),(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,f.jsx)(d,{label:`Pushed /s`,value:b.pushPerSec.toFixed(1),compact:!0}),(0,f.jsx)(d,{label:`Pulled /s`,value:b.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,f.jsx)(d,{label:`Completed /s`,value:b.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,f.jsx)(d,{label:`Failed /s`,value:b.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,f.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Totals`}),(0,f.jsx)(h,{rows:[[`Pushed`,u(y.totalPushed)],[`Pulled`,u(y.totalPulled)],[`Completed`,u(y.totalCompleted)],[`Failed`,u(y.totalFailed)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Memory`}),(0,f.jsx)(h,{rows:[[`Heap Used`,l(S.heapUsed*1024*1024)],[`Heap Total`,l(S.heapTotal*1024*1024)],[`RSS`,l(S.rss*1024*1024)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — percentiles (ms)`}),(0,f.jsx)(g,{record:w,suffix:`ms`})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — averages (ms)`}),(0,f.jsx)(g,{record:x.averages,suffix:`ms`})]})]}),(0,f.jsx)(`div`,{className:`mt-6`,children:(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`In-memory collections`}),(0,f.jsx)(g,{record:C})]})})]})}function h({rows:e}){return(0,f.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,f.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function g({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,f.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,f.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,f.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,f.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,f.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?u(Math.round(n*100)/100):String(n),t&&(0,f.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{m as Metrics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CyjgmGTq.js";import{t as i}from"./bq-DYmbVkgR.js";import{n as a}from"./usePolledData-c53tx1jw.js";import{n as o,t as s}from"./Card-C7NMhqUt.js";import{i as c,r as l,t as u}from"./feedback-BnGE2oW2.js";import{t as d}from"./PageHeader-BXlZSBcc.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{n as _}from"./index-D64v2vNO.js";import{t as v}from"./Pagination-Q-vf4hsX.js";import{t as y}from"./AreaChart-w0ruozXH.js";import{n as b,t as x}from"./useThroughputSeries-DWHQl7cM.js";var S=e(n(),1),C=r();function w({rate:e,stats:t}){return(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsx)(T,{value:e==null?`—`:f(e),label:`error rate`,danger:e!=null&&e>.05}),(0,C.jsx)(T,{value:e==null?`—`:f(1-e),label:`success rate`,success:e!=null})]}),e==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-e)*100}%`}})})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(E,{color:`bg-blue-400`,label:`Standard waiting`,value:t?m(t.waiting):`—`}),(0,C.jsx)(E,{color:`bg-accent`,label:`Processing`,value:t?m(t.active):`—`}),(0,C.jsx)(E,{color:`bg-amber-400`,label:`Delayed`,value:t?m(t.delayed):`—`}),(0,C.jsx)(E,{color:`bg-red-400`,label:`Dead Letter`,value:t?m(t.dlq):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:t?p(t.totalPushed):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:t?p(t.totalPulled):`—`}),(0,C.jsx)(E,{color:`bg-emerald-400`,label:`Uptime`,value:t?g(t.uptime/1e3):`—`})]})]})]})}function T({value:e,label:n,danger:r,success:i}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,r?`text-danger`:i?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:n})]})}function E({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}var D=[`push`,`pull`,`ack`],O=100;function k({latency:e}){return(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:D.map(n=>{let r=e?.percentiles?.[n],i=e?.averages?.[`${n}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:n}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(i)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(r?.p99??0)>O?`text-warning`:`text-muted`),children:j(r?.p99)})]},n)})})]})})]})}function A({rows:e,total:n,page:r,pageSize:i,onPage:a,empty:o}){return(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:e.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:o})}):e.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:m(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:m(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:r,pageSize:i,total:n,onPageChange:a,label:`queues`})})]})}function j(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}var M=[`-60s`,`-45s`,`-30s`,`-15s`,`now`];function N({series:e}){let n=e.latest?.throughput,r=x(e.depth),i=e.depth.length?e.depth[e.depth.length-1]:null,a=t=>e.error?(0,C.jsx)(u,{title:`${t} unavailable`,hint:e.error.message}):(0,C.jsx)(l,{label:`Connecting ${t.toLowerCase()}…`});return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),n&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(P,{color:`#ec4899`,label:`Pushed`,value:n.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:n.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:n.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):a(`Live throughput`)]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:i==null?`—`:m(i)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,r.label===`draining`?`text-success`:r.label===`accumulating`?`text-danger`:`text-faint`),children:i==null?`unavailable`:r.label===`steady`?`steady`:`${r.slope>0?`+`:``}${r.slope.toFixed(1)}/s · ${r.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:r.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):a(`Queue depth`)]})]})}function P({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}var F=15;function I(){let e=b(60),[t,n]=(0,S.useState)(0),{data:r,error:o,loading:s,refetch:l}=a(async()=>({details:await i.queuesSummary()}),[]),u=r?.details??[],f=Math.max(1,Math.ceil(u.length/F)),g=Math.min(t,f-1),v=(0,S.useMemo)(()=>u.slice(g*F,g*F+F),[u,g]),y=(0,S.useMemo)(()=>r?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[r,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!r&&!o,j=!!e.latest&&!e.error&&!!r&&!o,M=o&&!r?`Queue metrics unavailable — ${o.message}`:O?`Loading queue metrics…`:`No queues yet.`;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(d,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:j}),o&&(0,C.jsx)(c,{message:`Queue metrics unavailable — ${o.message}`,onRetry:l}),e.error&&(0,C.jsx)(c,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),O&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),!e.latest&&!e.error&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(_,{label:`Total Completed`,value:x?p(x.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Total Failed`,value:y==null?`—`:m(y),tone:y?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Push/sec`,value:T?T.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(_,{label:`Pull/sec`,value:T?T.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsx)(N,{series:e}),(0,C.jsx)(w,{rate:D,stats:x}),(0,C.jsx)(k,{latency:E}),(0,C.jsx)(A,{rows:v,total:u.length,page:g,pageSize:F,onPage:n,empty:M})]})}export{I as MetricsPro};
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CyjgmGTq.js";import{t as i}from"./bq-Bmysbg0r.js";import{n as a}from"./usePolledData-g80Z_UB-.js";import{n as o,t as s}from"./Card-C7NMhqUt.js";import{i as c,r as l,t as u}from"./feedback-BnGE2oW2.js";import{t as d}from"./PageHeader-BXlZSBcc.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{n as _}from"./index-Cue53Myw.js";import{t as v}from"./Pagination-Q-vf4hsX.js";import{t as y}from"./AreaChart-w0ruozXH.js";import{n as b,t as x}from"./useThroughputSeries-CrsZYKbT.js";var S=e(n(),1),C=r();function w({rate:e,stats:t}){return(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsx)(T,{value:e==null?`—`:f(e),label:`error rate`,danger:e!=null&&e>.05}),(0,C.jsx)(T,{value:e==null?`—`:f(1-e),label:`success rate`,success:e!=null})]}),e==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-e)*100}%`}})})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(E,{color:`bg-blue-400`,label:`Standard waiting`,value:t?m(t.waiting):`—`}),(0,C.jsx)(E,{color:`bg-accent`,label:`Processing`,value:t?m(t.active):`—`}),(0,C.jsx)(E,{color:`bg-amber-400`,label:`Delayed`,value:t?m(t.delayed):`—`}),(0,C.jsx)(E,{color:`bg-red-400`,label:`Dead Letter`,value:t?m(t.dlq):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:t?p(t.totalPushed):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:t?p(t.totalPulled):`—`}),(0,C.jsx)(E,{color:`bg-emerald-400`,label:`Uptime`,value:t?g(t.uptime/1e3):`—`})]})]})]})}function T({value:e,label:n,danger:r,success:i}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,r?`text-danger`:i?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:n})]})}function E({color:e,label:n,value:r}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}var D=[`push`,`pull`,`ack`],O=100;function k({latency:e}){return(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:D.map(n=>{let r=e?.percentiles?.[n],i=e?.averages?.[`${n}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:n}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(i)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(r?.p99??0)>O?`text-warning`:`text-muted`),children:j(r?.p99)})]},n)})})]})})]})}function A({rows:e,total:n,page:r,pageSize:i,onPage:a,empty:o}){return(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:e.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:o})}):e.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:m(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:m(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:r,pageSize:i,total:n,onPageChange:a,label:`queues`})})]})}function j(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}var M=[`-60s`,`-45s`,`-30s`,`-15s`,`now`];function N({series:e}){let n=e.latest?.throughput,r=x(e.depth),i=e.depth.length?e.depth[e.depth.length-1]:null,a=t=>e.error?(0,C.jsx)(u,{title:`${t} unavailable`,hint:e.error.message}):(0,C.jsx)(l,{label:`Connecting ${t.toLowerCase()}…`});return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),n&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(P,{color:`#ec4899`,label:`Pushed`,value:n.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:n.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:n.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):a(`Live throughput`)]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:i==null?`—`:m(i)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,r.label===`draining`?`text-success`:r.label===`accumulating`?`text-danger`:`text-faint`),children:i==null?`unavailable`:r.label===`steady`?`steady`:`${r.slope>0?`+`:``}${r.slope.toFixed(1)}/s · ${r.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:r.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):a(`Queue depth`)]})]})}function P({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}var F=15;function I(){let e=b(60),[t,n]=(0,S.useState)(0),{data:r,error:o,loading:s,refetch:l}=a(async()=>({details:await i.queuesSummary()}),[]),u=r?.details??[],f=Math.max(1,Math.ceil(u.length/F)),g=Math.min(t,f-1),v=(0,S.useMemo)(()=>u.slice(g*F,g*F+F),[u,g]),y=(0,S.useMemo)(()=>r?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[r,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!r&&!o,j=!!e.latest&&!e.error&&!!r&&!o,M=o&&!r?`Queue metrics unavailable — ${o.message}`:O?`Loading queue metrics…`:`No queues yet.`;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(d,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:j}),o&&(0,C.jsx)(c,{message:`Queue metrics unavailable — ${o.message}`,onRetry:l}),e.error&&(0,C.jsx)(c,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),O&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),!e.latest&&!e.error&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(_,{label:`Total Completed`,value:x?p(x.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Total Failed`,value:y==null?`—`:m(y),tone:y?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Push/sec`,value:T?T.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(_,{label:`Pull/sec`,value:T?T.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsx)(N,{series:e}),(0,C.jsx)(w,{rate:D,stats:x}),(0,C.jsx)(k,{latency:E}),(0,C.jsx)(A,{rows:v,total:u.length,page:g,pageSize:F,onPage:n,empty:M})]})}export{I as MetricsPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-CyjgmGTq.js";import{A as t,c as n}from"./icons-CIvFfU2b.js";import{t as r}from"./api-V_sVpHDo.js";import{n as i}from"./usePolledData-
|
|
1
|
+
import{t as e}from"./react-vendor-CyjgmGTq.js";import{A as t,c as n}from"./icons-CIvFfU2b.js";import{t as r}from"./api-V_sVpHDo.js";import{n as i}from"./usePolledData-g80Z_UB-.js";import{n as a,t as o}from"./Card-C7NMhqUt.js";import{i as s,n as c,r as l}from"./feedback-BnGE2oW2.js";import{t as u}from"./PageHeader-BXlZSBcc.js";import{c as d,n as f,s as p,t as m,u as h}from"./format-Cg7VCIZW.js";import{n as g}from"./index-Cue53Myw.js";var _=e(),v={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function y(){let{data:e,error:y,loading:S,refetch:C}=i(()=>r.overview(),[]);if(S&&!e&&!y)return(0,_.jsx)(l,{label:`Loading overview…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`}),(0,_.jsx)(c,{error:y,onRetry:C})]});let{stats:w,throughput:T,memory:E,workers:D,crons:O,storage:k}=e??v,A=m(w.totalCompleted,w.totalFailed)??0,j=typeof k.diskFull==`boolean`;return(0,_.jsxs)(`div`,{children:[y&&(0,_.jsx)(s,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:C}),(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!!e&&!y&&j}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(g,{label:`Waiting`,value:p(w.waiting),tone:`amber`}),(0,_.jsx)(g,{label:`Active`,value:p(w.active),tone:`blue`}),(0,_.jsx)(g,{label:`Completed`,value:p(w.totalCompleted),tone:`green`}),(0,_.jsx)(g,{label:`Failed`,value:p(w.totalFailed),tone:`red`}),(0,_.jsx)(g,{label:`DLQ`,value:p(w.dlq),tone:w.dlq>0?`red`:`default`}),(0,_.jsx)(g,{label:`Error Rate`,value:d(A),tone:A>.05?`red`:`green`})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Throughput`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(b,{label:`Pushed`,value:T.pushPerSec,tone:`text-fg`}),(0,_.jsx)(b,{label:`Pulled`,value:T.pullPerSec,tone:`text-blue-400`}),(0,_.jsx)(b,{label:`Completed`,value:T.completePerSec,tone:`text-emerald-400`}),(0,_.jsx)(b,{label:`Failed`,value:T.failPerSec,tone:`text-red-400`})]})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Resources`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(x,{label:`Uptime`,value:h(w.uptime/1e3)}),(0,_.jsx)(x,{label:`Heap`,value:f(E.heapUsed*1024*1024)}),(0,_.jsx)(x,{label:`RSS`,value:f(E.rss*1024*1024)}),(0,_.jsx)(x,{label:`Storage`,value:j?k.diskFull?`Disk full`:`Healthy`:`Unavailable`,tone:j?k.diskFull?`text-red-400`:`text-emerald-400`:`text-muted`})]})]})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Workers`,icon:(0,_.jsx)(t,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,_.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:D.active}),` /`,` `,D.total,` active`]})}),D.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,_.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,p(e.processedJobs),` done`]})]},e.id))})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Cron Jobs`,icon:(0,_.jsx)(n,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[O.total,` scheduled`]})}),O.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:O.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,_.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function b({label:e,value:t,tone:n}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,_.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function x({label:e,value:t,tone:n=`text-fg`}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{y as Overview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{o as r}from"./connectionStore-CKFQrxDo.js";import{t as i}from"./bq-DYmbVkgR.js";import{t as a}from"./Button-BPqpRZJD.js";import{n as o,t as s}from"./Card-C7NMhqUt.js";import{a as c,n as l,o as u,t as d}from"./form-tC20r4Ma.js";import{n as f,r as p}from"./useServerActionGuard-OTv6_fU0.js";import{i as m,n as h,r as g}from"./flowMutationSafety-DObp9nJo.js";var _=n();function v(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 y(e,t){let n=String(e).trim();if(n===``)return null;let r=Number(n);return Number.isSafeInteger(r)&&r>=t?r:null}function b(e){let t=y(e.stallInterval,0),n=y(e.maxStalls,0),r=y(e.gracePeriod,0);return t===null||n===null||r===null?{ok:!1,error:`Stall interval, max stalls, and grace period must be non-negative whole numbers.`}:{ok:!0,value:{enabled:e.enabled,stallInterval:t,maxStalls:n,gracePeriod:r}}}function x(e){let t=y(e.autoRetryInterval,0),n=y(e.maxAutoRetries,0);return t===null||n===null?{ok:!1,error:`Retry interval and max auto-retries must be non-negative whole numbers.`}:{ok:!0,value:{autoRetry:e.autoRetry,autoRetryInterval:t,maxAutoRetries:n}}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var C=e=>typeof e==`number`&&Number.isFinite(e);function w(e){return S(e)&&typeof e.enabled==`boolean`&&C(e.stallInterval)&&C(e.maxStalls)&&C(e.gracePeriod)}function T(e){return S(e)&&typeof e.autoRetry==`boolean`&&C(e.autoRetryInterval)&&C(e.maxAutoRetries)&&(e.maxAge===null||C(e.maxAge))&&C(e.maxEntries)}function E(e,t){if(!S(e)||e.ok!==!0)throw Error(`Malformed ${t} response: expected { ok: true }.`)}var D=e(t(),1);function O(e){let[t,n]=(0,D.useState)(e),r=(0,D.useRef)(v(e));return(0,D.useEffect)(()=>{let t=v(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=v(t))}}]}function k(e){let{scopeKey:t,begin:n}=p(e),i=(0,D.useRef)(null),a=(0,D.useRef)(null),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null);let e=f(),t=r.subscribe(()=>{let t=f();t!==e&&(e=t,i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null))});return()=>{i.current=null,a.current!==null&&window.clearTimeout(a.current),t()}},[t]),{scopeKey:t,saving:o,saved:c,start:()=>{let e=n(`save`);return e?(i.current=e,s(!0),l(!1),e):null},finish:e=>{e.finish(),i.current===e&&(i.current=null,s(!1))},showSaved:e=>{i.current!==e||!e.isCurrent()||(l(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{e.isCurrent()&&l(!1),a.current=null},2e3))}}}function A({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,h]=(0,D.useState)(null),g=k(`dlq-config:${e}`);(0,D.useEffect)(()=>h(null),[g.scopeKey]);let v=x(r),y=v.ok&&v.value.autoRetry;return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`DLQ policy`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.autoRetry,disabled:!r.autoRetry,onChange:e=>c({...r,autoRetry:e}),label:`auto-retry`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:`Auto-retry can only be disabled. Bunqueue v2.8.59 cannot prove that a DLQ entry has no hidden reverse flow dependents before a background retry.`}),(0,_.jsx)(d,{label:`Retry interval (ms)`,children:(0,_.jsx)(l,{name:`dlq-auto-retry-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.autoRetryInterval,onChange:e=>c({...r,autoRetryInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max auto-retries`,children:(0,_.jsx)(l,{name:`dlq-max-auto-retries`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxAutoRetries,onChange:e=>c({...r,maxAutoRetries:e.target.value})})}),(0,_.jsx)(d,{label:`Max age (ms)`,children:(0,_.jsx)(l,{name:`dlq-max-age-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxAge??``,readOnly:!0})}),(0,_.jsx)(d,{label:`Max entries`,children:(0,_.jsx)(l,{name:`dlq-max-entries`,autoComplete:`off`,type:`number`,min:1,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxEntries,readOnly:!0})}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:m})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:g.saving||!v.ok||y,onClick:async()=>{if(!v.ok)return;let t=g.start();if(t)try{h(null);let a=f();if(E(await i.setDlqConfig(e,v.value),`/dlq-config`),!t.isCurrent())return;a({...r,...v.value}),await n(),g.showSaved(t)}catch(e){t.isCurrent()&&h(e.message)}finally{g.finish(t)}},children:`Save`}),g.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!v.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:v.error}),y&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:`Disable auto-retry before saving this policy.`}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function j({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,m]=(0,D.useState)(null),h=k(`stall-config:${e}`);(0,D.useEffect)(()=>m(null),[h.scopeKey]);let g=b(r);return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Stall detection`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.enabled,onChange:e=>c({...r,enabled:e}),label:`enabled`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,_.jsx)(d,{label:`Stall interval (ms)`,children:(0,_.jsx)(l,{name:`stall-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.stallInterval,onChange:e=>c({...r,stallInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max stalls`,children:(0,_.jsx)(l,{name:`stall-max-count`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxStalls,onChange:e=>c({...r,maxStalls:e.target.value})})}),(0,_.jsx)(d,{label:`Grace period (ms)`,children:(0,_.jsx)(l,{name:`stall-grace-period-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.gracePeriod,onChange:e=>c({...r,gracePeriod:e.target.value})})})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:h.saving||!g.ok,onClick:async()=>{if(!g.ok)return;let t=h.start();if(t)try{m(null);let r=f();if(E(await i.setStallConfig(e,g.value),`/stall-config`),!t.isCurrent())return;r(g.value),await n(),h.showSaved(t)}catch(e){t.isCurrent()&&m(e.message)}finally{h.finish(t)}},children:`Save`}),h.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!g.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:g.error}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function M({title:e,onRetry:t}){return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:e}),(0,_.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,_.jsx)(a,{size:`sm`,onClick:t,children:`Retry`})]})}function N(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&n>=0&&r>0}}function P(e){if(!e.trim())return{valid:!0};let t=Number(e);return Number.isSafeInteger(t)&&t>0?{count:t,valid:!0}:{valid:!1}}function F(e,t){return t===void 0?`Promote every delayed job in "${e}" and make it eligible to run now?`:`Promote up to ${t} delayed jobs in "${e}" and make them eligible to run now?`}function I(e,t,n){let r=e=>{if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},i=r(e),a=r(t),o=r(n);return{limit:typeof i==`number`?i:0,duration:typeof a==`number`?a:0,...typeof o==`number`?{ttl:o}:{},valid:typeof i==`number`&&typeof a==`number`&&o!==null}}function L(e){let t=Number(e);return{value:t,valid:e.trim()!==``&&Number.isSafeInteger(t)&&t>0}}function R({queue:e,paused:t,busy:n,run:r}){let[u,f]=(0,D.useState)(`0`),[p,m]=(0,D.useState)(`1000`),[v,y]=(0,D.useState)(`completed`),[b,x]=(0,D.useState)(``),S=N(u,p),C=P(b);return(0,_.jsxs)(s,{className:`mb-6`,children:[(0,_.jsx)(o,{title:`Lifecycle`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,_.jsx)(a,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>i.resume(e)),children:`Resume`}):(0,_.jsx)(a,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>i.pause(e)),children:`Pause`}),(0,_.jsx)(a,{size:`sm`,disabled:!0,title:h,children:`Requeue completed`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Promote N`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`promote-count`,"aria-invalid":!C.valid,value:b,onChange:e=>x(e.target.value),placeholder:`all`})})}),(0,_.jsx)(a,{size:`sm`,disabled:n||!C.valid,onClick:()=>r(`Promoted`,()=>i.promoteJobs(e,C.count),F(e,C.count)),children:`Promote delayed`}),!C.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Promote N must be a positive whole number, or blank for all.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:h}),(0,_.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,_.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,_.jsx)(a,{size:`sm`,disabled:!0,title:g,children:`Drain`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-40`,children:(0,_.jsx)(d,{label:`State`,children:(0,_.jsxs)(c,{name:`clean-state`,disabled:!0,value:v,onChange:e=>y(e.target.value),children:[(0,_.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,_.jsx)(`option`,{value:`failed`,children:`Failed / DLQ`}),(0,_.jsx)(`option`,{value:`waiting`,children:`Queued`})]})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Grace (ms)`,children:(0,_.jsx)(l,{type:`number`,min:0,max:2**53-1,step:1,name:`clean-grace`,disabled:!0,"aria-invalid":!S.valid,value:u,onChange:e=>f(e.target.value)})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`clean-limit`,disabled:!0,"aria-invalid":!S.valid,value:p,onChange:e=>m(e.target.value)})})}),(0,_.jsx)(a,{variant:`danger`,size:`sm`,disabled:!0,title:g,children:`Clean`}),!S.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Grace and limit must be whole numbers; limit must be positive.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:g})]})]})}function z({queue:e,busy:t,run:n}){let[r,u]=(0,D.useState)(``),[f,p]=(0,D.useState)(``),[m,h]=(0,D.useState)(`permanent`),[g,v]=(0,D.useState)(``),[y,b]=(0,D.useState)(``),[x,S]=(0,D.useState)(``),[C,w]=(0,D.useState)(``),[T,E]=(0,D.useState)(null),[O,k]=(0,D.useState)(null),A=I(r,f,m===`expires`?g:``),j=L(y);return(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Rate-limit policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a policy replaces the broker value for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-limit`,value:r,onChange:e=>u(e.target.value),placeholder:`max per window`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`Window (ms)`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-duration`,value:f,onChange:e=>p(e.target.value),placeholder:`60000`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`TTL`,children:(0,_.jsxs)(c,{name:`rate-ttl-mode`,value:m,onChange:e=>h(e.target.value),children:[(0,_.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,_.jsx)(`option`,{value:`expires`,children:`Expires after`})]})})}),(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`TTL (ms)`,hint:m===`permanent`?`Not sent`:void 0,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-ttl`,disabled:m===`permanent`,value:g,onChange:e=>v(e.target.value),placeholder:`—`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!A.valid,onClick:()=>n(`Rate limit set`,()=>i.setRateLimit(e,A.limit,A.duration,A.ttl),`Replace the current rate-limit policy for "${e}" with limit ${A.limit}, window ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`}?`,()=>E(`Applied limit ${A.limit} per ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:x,onChange:e=>S(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||x!==e,onClick:()=>n(`No rate limit ensured`,()=>i.clearRateLimit(e),`Remove the current rate-limit policy from queue "${e}"?`,()=>E(`Removed the rate-limit policy at ${new Date().toISOString()}.`)),children:`Ensure no rate limit`}),!A.valid&&(r.trim()||f.trim()||g.trim())&&(0,_.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-danger`,children:`Limit and window are required; all values must be positive whole numbers.`}),T&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:T})]})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Concurrency policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a value replaces the broker concurrency for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,_.jsx)(d,{label:`Concurrency`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`concurrency`,value:y,onChange:e=>b(e.target.value),placeholder:`max in-flight`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!j.valid,onClick:()=>n(`Concurrency set`,()=>i.setConcurrency(e,j.value),`Replace the current concurrency policy for "${e}" with ${j.value} maximum in-flight jobs?`,()=>k(`Applied concurrency ${j.value} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:C,onChange:e=>w(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||C!==e,onClick:()=>n(`No concurrency limit ensured`,()=>i.clearConcurrency(e),`Remove the current concurrency policy from queue "${e}"?`,()=>k(`Removed the concurrency policy at ${new Date().toISOString()}.`)),children:`Ensure no concurrency limit`}),!j.valid&&y.trim()&&(0,_.jsx)(`span`,{role:`alert`,className:`self-center text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),O&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:O})]})]})]})}export{A as a,j as i,R as n,T as o,M as r,w as s,z as t};
|
|
1
|
+
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{o as r}from"./connectionStore-CKFQrxDo.js";import{t as i}from"./bq-Bmysbg0r.js";import{t as a}from"./Button-BPqpRZJD.js";import{n as o,t as s}from"./Card-C7NMhqUt.js";import{a as c,n as l,o as u,t as d}from"./form-tC20r4Ma.js";import{n as f,r as p}from"./useServerActionGuard-OTv6_fU0.js";import{i as m,n as h,r as g}from"./flowMutationSafety-DObp9nJo.js";var _=n();function v(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 y(e,t){let n=String(e).trim();if(n===``)return null;let r=Number(n);return Number.isSafeInteger(r)&&r>=t?r:null}function b(e){let t=y(e.stallInterval,0),n=y(e.maxStalls,0),r=y(e.gracePeriod,0);return t===null||n===null||r===null?{ok:!1,error:`Stall interval, max stalls, and grace period must be non-negative whole numbers.`}:{ok:!0,value:{enabled:e.enabled,stallInterval:t,maxStalls:n,gracePeriod:r}}}function x(e){let t=y(e.autoRetryInterval,0),n=y(e.maxAutoRetries,0);return t===null||n===null?{ok:!1,error:`Retry interval and max auto-retries must be non-negative whole numbers.`}:{ok:!0,value:{autoRetry:e.autoRetry,autoRetryInterval:t,maxAutoRetries:n}}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var C=e=>typeof e==`number`&&Number.isFinite(e);function w(e){return S(e)&&typeof e.enabled==`boolean`&&C(e.stallInterval)&&C(e.maxStalls)&&C(e.gracePeriod)}function T(e){return S(e)&&typeof e.autoRetry==`boolean`&&C(e.autoRetryInterval)&&C(e.maxAutoRetries)&&(e.maxAge===null||C(e.maxAge))&&C(e.maxEntries)}function E(e,t){if(!S(e)||e.ok!==!0)throw Error(`Malformed ${t} response: expected { ok: true }.`)}var D=e(t(),1);function O(e){let[t,n]=(0,D.useState)(e),r=(0,D.useRef)(v(e));return(0,D.useEffect)(()=>{let t=v(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=v(t))}}]}function k(e){let{scopeKey:t,begin:n}=p(e),i=(0,D.useRef)(null),a=(0,D.useRef)(null),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null);let e=f(),t=r.subscribe(()=>{let t=f();t!==e&&(e=t,i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null))});return()=>{i.current=null,a.current!==null&&window.clearTimeout(a.current),t()}},[t]),{scopeKey:t,saving:o,saved:c,start:()=>{let e=n(`save`);return e?(i.current=e,s(!0),l(!1),e):null},finish:e=>{e.finish(),i.current===e&&(i.current=null,s(!1))},showSaved:e=>{i.current!==e||!e.isCurrent()||(l(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{e.isCurrent()&&l(!1),a.current=null},2e3))}}}function A({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,h]=(0,D.useState)(null),g=k(`dlq-config:${e}`);(0,D.useEffect)(()=>h(null),[g.scopeKey]);let v=x(r),y=v.ok&&v.value.autoRetry;return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`DLQ policy`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.autoRetry,disabled:!r.autoRetry,onChange:e=>c({...r,autoRetry:e}),label:`auto-retry`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:`Auto-retry can only be disabled. Bunqueue v2.8.59 cannot prove that a DLQ entry has no hidden reverse flow dependents before a background retry.`}),(0,_.jsx)(d,{label:`Retry interval (ms)`,children:(0,_.jsx)(l,{name:`dlq-auto-retry-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.autoRetryInterval,onChange:e=>c({...r,autoRetryInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max auto-retries`,children:(0,_.jsx)(l,{name:`dlq-max-auto-retries`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxAutoRetries,onChange:e=>c({...r,maxAutoRetries:e.target.value})})}),(0,_.jsx)(d,{label:`Max age (ms)`,children:(0,_.jsx)(l,{name:`dlq-max-age-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxAge??``,readOnly:!0})}),(0,_.jsx)(d,{label:`Max entries`,children:(0,_.jsx)(l,{name:`dlq-max-entries`,autoComplete:`off`,type:`number`,min:1,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxEntries,readOnly:!0})}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:m})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:g.saving||!v.ok||y,onClick:async()=>{if(!v.ok)return;let t=g.start();if(t)try{h(null);let a=f();if(E(await i.setDlqConfig(e,v.value),`/dlq-config`),!t.isCurrent())return;a({...r,...v.value}),await n(),g.showSaved(t)}catch(e){t.isCurrent()&&h(e.message)}finally{g.finish(t)}},children:`Save`}),g.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!v.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:v.error}),y&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:`Disable auto-retry before saving this policy.`}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function j({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,m]=(0,D.useState)(null),h=k(`stall-config:${e}`);(0,D.useEffect)(()=>m(null),[h.scopeKey]);let g=b(r);return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Stall detection`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.enabled,onChange:e=>c({...r,enabled:e}),label:`enabled`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,_.jsx)(d,{label:`Stall interval (ms)`,children:(0,_.jsx)(l,{name:`stall-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.stallInterval,onChange:e=>c({...r,stallInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max stalls`,children:(0,_.jsx)(l,{name:`stall-max-count`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxStalls,onChange:e=>c({...r,maxStalls:e.target.value})})}),(0,_.jsx)(d,{label:`Grace period (ms)`,children:(0,_.jsx)(l,{name:`stall-grace-period-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.gracePeriod,onChange:e=>c({...r,gracePeriod:e.target.value})})})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:h.saving||!g.ok,onClick:async()=>{if(!g.ok)return;let t=h.start();if(t)try{m(null);let r=f();if(E(await i.setStallConfig(e,g.value),`/stall-config`),!t.isCurrent())return;r(g.value),await n(),h.showSaved(t)}catch(e){t.isCurrent()&&m(e.message)}finally{h.finish(t)}},children:`Save`}),h.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!g.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:g.error}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function M({title:e,onRetry:t}){return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:e}),(0,_.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,_.jsx)(a,{size:`sm`,onClick:t,children:`Retry`})]})}function N(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&n>=0&&r>0}}function P(e){if(!e.trim())return{valid:!0};let t=Number(e);return Number.isSafeInteger(t)&&t>0?{count:t,valid:!0}:{valid:!1}}function F(e,t){return t===void 0?`Promote every delayed job in "${e}" and make it eligible to run now?`:`Promote up to ${t} delayed jobs in "${e}" and make them eligible to run now?`}function I(e,t,n){let r=e=>{if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},i=r(e),a=r(t),o=r(n);return{limit:typeof i==`number`?i:0,duration:typeof a==`number`?a:0,...typeof o==`number`?{ttl:o}:{},valid:typeof i==`number`&&typeof a==`number`&&o!==null}}function L(e){let t=Number(e);return{value:t,valid:e.trim()!==``&&Number.isSafeInteger(t)&&t>0}}function R({queue:e,paused:t,busy:n,run:r}){let[u,f]=(0,D.useState)(`0`),[p,m]=(0,D.useState)(`1000`),[v,y]=(0,D.useState)(`completed`),[b,x]=(0,D.useState)(``),S=N(u,p),C=P(b);return(0,_.jsxs)(s,{className:`mb-6`,children:[(0,_.jsx)(o,{title:`Lifecycle`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,_.jsx)(a,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>i.resume(e)),children:`Resume`}):(0,_.jsx)(a,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>i.pause(e)),children:`Pause`}),(0,_.jsx)(a,{size:`sm`,disabled:!0,title:h,children:`Requeue completed`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Promote N`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`promote-count`,"aria-invalid":!C.valid,value:b,onChange:e=>x(e.target.value),placeholder:`all`})})}),(0,_.jsx)(a,{size:`sm`,disabled:n||!C.valid,onClick:()=>r(`Promoted`,()=>i.promoteJobs(e,C.count),F(e,C.count)),children:`Promote delayed`}),!C.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Promote N must be a positive whole number, or blank for all.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:h}),(0,_.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,_.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,_.jsx)(a,{size:`sm`,disabled:!0,title:g,children:`Drain`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-40`,children:(0,_.jsx)(d,{label:`State`,children:(0,_.jsxs)(c,{name:`clean-state`,disabled:!0,value:v,onChange:e=>y(e.target.value),children:[(0,_.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,_.jsx)(`option`,{value:`failed`,children:`Failed / DLQ`}),(0,_.jsx)(`option`,{value:`waiting`,children:`Queued`})]})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Grace (ms)`,children:(0,_.jsx)(l,{type:`number`,min:0,max:2**53-1,step:1,name:`clean-grace`,disabled:!0,"aria-invalid":!S.valid,value:u,onChange:e=>f(e.target.value)})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`clean-limit`,disabled:!0,"aria-invalid":!S.valid,value:p,onChange:e=>m(e.target.value)})})}),(0,_.jsx)(a,{variant:`danger`,size:`sm`,disabled:!0,title:g,children:`Clean`}),!S.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Grace and limit must be whole numbers; limit must be positive.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:g})]})]})}function z({queue:e,busy:t,run:n}){let[r,u]=(0,D.useState)(``),[f,p]=(0,D.useState)(``),[m,h]=(0,D.useState)(`permanent`),[g,v]=(0,D.useState)(``),[y,b]=(0,D.useState)(``),[x,S]=(0,D.useState)(``),[C,w]=(0,D.useState)(``),[T,E]=(0,D.useState)(null),[O,k]=(0,D.useState)(null),A=I(r,f,m===`expires`?g:``),j=L(y);return(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Rate-limit policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a policy replaces the broker value for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-limit`,value:r,onChange:e=>u(e.target.value),placeholder:`max per window`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`Window (ms)`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-duration`,value:f,onChange:e=>p(e.target.value),placeholder:`60000`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`TTL`,children:(0,_.jsxs)(c,{name:`rate-ttl-mode`,value:m,onChange:e=>h(e.target.value),children:[(0,_.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,_.jsx)(`option`,{value:`expires`,children:`Expires after`})]})})}),(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`TTL (ms)`,hint:m===`permanent`?`Not sent`:void 0,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-ttl`,disabled:m===`permanent`,value:g,onChange:e=>v(e.target.value),placeholder:`—`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!A.valid,onClick:()=>n(`Rate limit set`,()=>i.setRateLimit(e,A.limit,A.duration,A.ttl),`Replace the current rate-limit policy for "${e}" with limit ${A.limit}, window ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`}?`,()=>E(`Applied limit ${A.limit} per ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:x,onChange:e=>S(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||x!==e,onClick:()=>n(`No rate limit ensured`,()=>i.clearRateLimit(e),`Remove the current rate-limit policy from queue "${e}"?`,()=>E(`Removed the rate-limit policy at ${new Date().toISOString()}.`)),children:`Ensure no rate limit`}),!A.valid&&(r.trim()||f.trim()||g.trim())&&(0,_.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-danger`,children:`Limit and window are required; all values must be positive whole numbers.`}),T&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:T})]})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Concurrency policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a value replaces the broker concurrency for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,_.jsx)(d,{label:`Concurrency`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`concurrency`,value:y,onChange:e=>b(e.target.value),placeholder:`max in-flight`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!j.valid,onClick:()=>n(`Concurrency set`,()=>i.setConcurrency(e,j.value),`Replace the current concurrency policy for "${e}" with ${j.value} maximum in-flight jobs?`,()=>k(`Applied concurrency ${j.value} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:C,onChange:e=>w(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||C!==e,onClick:()=>n(`No concurrency limit ensured`,()=>i.clearConcurrency(e),`Remove the current concurrency policy from queue "${e}"?`,()=>k(`Removed the concurrency policy at ${new Date().toISOString()}.`)),children:`Ensure no concurrency limit`}),!j.valid&&y.trim()&&(0,_.jsx)(`span`,{role:`alert`,className:`self-center text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),O&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:O})]})]})]})}export{A as a,j as i,R as n,T as o,M as r,w as s,z as t};
|