bunqueue-dashboard 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -11
- package/agent/backup/resultValidation.ts +1 -1
- package/agent/backup/routes.ts +63 -17
- package/agent/db/query.ts +2 -1
- package/agent/manager/config.ts +2 -1
- package/agent/manager/process.ts +51 -5
- package/agent/manager/storageMode.ts +21 -0
- package/agent/manager/types.ts +2 -0
- package/agent/manager.ts +1 -0
- package/agent/queue/routes.ts +1 -2
- package/agent/queue/runtime.ts +5 -0
- package/agent/queue/types.ts +1 -0
- package/agent/server/controlRoutes.ts +109 -8
- package/agent/server/databaseRoutes.ts +47 -14
- package/agent/server/errors.ts +1 -0
- package/agent/server/lifecycle.ts +25 -8
- package/agent/server/managedRuntime.ts +27 -0
- package/agent/server/router.ts +90 -40
- package/agent/server/workflowReadRoutes.ts +28 -11
- package/agent/workflows.ts +1 -1
- package/dist/.vite/manifest.json +490 -476
- package/dist/assets/AddJob-d5KBvmN8.js +3 -0
- package/dist/assets/{Alerts-Gh1pVbqj.js → Alerts-5I44QTnQ.js} +1 -1
- package/dist/assets/{AreaChart-w0ruozXH.js → AreaChart-DEAalJ6P.js} +1 -1
- package/dist/assets/Benchmark-S1afsQRd.js +1 -0
- package/dist/assets/{BulkAddJobs-Di_IgRSH.js → BulkAddJobs-BO8LWUHE.js} +1 -1
- package/dist/assets/{Button-BPqpRZJD.js → Button-Ch1W94fJ.js} +1 -1
- package/dist/assets/{Card-C7NMhqUt.js → Card-CWxrC8OY.js} +1 -1
- package/dist/assets/{CopilotPanel-Db5nYpo1.js → CopilotPanel-DDkRd35p.js} +4 -4
- package/dist/assets/{Cron-BRgWcBGk.js → Cron-X3Y5uISO.js} +1 -1
- package/dist/assets/CronManager-ugmYEAwY.js +1 -0
- package/dist/assets/{Database-BeoEreW0.js → Database-koy8haPX.js} +1 -1
- package/dist/assets/Diagnostics-D6oqvkOs.js +1 -0
- package/dist/assets/{Dlq-DfCg04Jd.js → Dlq-D70Lzmsa.js} +1 -1
- package/dist/assets/{DlqControl-BRCkUXvb.js → DlqControl-nUT5Zzkl.js} +1 -1
- package/dist/assets/{DlqPro-BHJwBYsN.js → DlqPro-VMuBKgP-.js} +1 -1
- package/dist/assets/Flows-CAG0nDnt.js +2 -0
- package/dist/assets/JobInspector-CiS5HOSQ.js +2 -0
- package/dist/assets/{Jobs-URpnFjC6.js → Jobs-CkyRvzOT.js} +1 -1
- package/dist/assets/{JobsPro-pQ_RFSU3.js → JobsPro-B4-CSoq3.js} +1 -1
- package/dist/assets/{Logs-C5jX2OPE.js → Logs-DBTz2PTz.js} +1 -1
- package/dist/assets/{LogsPro-Cq_npmmS.js → LogsPro-BCFeegvr.js} +1 -1
- package/dist/assets/{McpServer-DtCTmQBu.js → McpServer-BKlTR1qr.js} +2 -2
- package/dist/assets/{Metrics-BdxitePr.js → Metrics-Du__9Lbn.js} +1 -1
- package/dist/assets/{MetricsPro-orHfW0mg.js → MetricsPro-CqnaO6YX.js} +1 -1
- package/dist/assets/{Overview-DaNns1aj.js → Overview-udSSt7ZB.js} +1 -1
- package/dist/assets/{PageHeader-BXlZSBcc.js → PageHeader-CvIyaFOO.js} +1 -1
- package/dist/assets/{Pagination-Q-vf4hsX.js → Pagination-x-Cwgrul.js} +1 -1
- package/dist/assets/QueueActions-D7cQrGvJ.js +1 -0
- package/dist/assets/{QueueControl-l5bSdMgb.js → QueueControl-BF638r_0.js} +1 -1
- package/dist/assets/QueueDetail-C-ms6bMe.js +1 -0
- package/dist/assets/QueueDetailPro-DXEdsZx_.js +1 -0
- package/dist/assets/{Queues-DeLXlww2.js → Queues-BUMwTVAf.js} +1 -1
- package/dist/assets/{QueuesOverview-DoQ-MUfT.js → QueuesOverview-Du8XLgN0.js} +1 -1
- package/dist/assets/{S3Backup-D2agV9_z.js → S3Backup-CDICSzxM.js} +1 -1
- package/dist/assets/S3BackupPro-CBidbI-s.js +3 -0
- package/dist/assets/ServerControl-CPT0LpsC.js +3 -0
- package/dist/assets/{Settings-CiJRj_SM.js → Settings-CmxfSX_8.js} +1 -1
- package/dist/assets/{StatusBadge-B0I7hNBX.js → StatusBadge-BoOVTnKu.js} +1 -1
- package/dist/assets/{Usage-DbHJgA4t.js → Usage-B895tSxi.js} +1 -1
- package/dist/assets/{UsagePro-LoPo3k1L.js → UsagePro-CASN77iV.js} +1 -1
- package/dist/assets/{Webhooks-CuzIJHwk.js → Webhooks-CXbZOFFw.js} +1 -1
- package/dist/assets/{Workers-BpUgpwUH.js → Workers-BceQlUhX.js} +1 -1
- package/dist/assets/WorkersPro-Dtml89jB.js +1 -0
- package/dist/assets/Workflows-B8wmQN2X.js +1 -0
- package/dist/assets/{api-V_sVpHDo.js → api-81m1TwB7.js} +1 -1
- package/dist/assets/bq-BOfwNIlJ.js +1 -0
- package/dist/assets/{connectionStore-CKFQrxDo.js → connectionStore-CFuNYZ_8.js} +1 -1
- package/dist/assets/{controlConnectionEpoch-JM4omZ6j.js → controlConnectionEpoch-DzbuWOhe.js} +1 -1
- package/dist/assets/{feedback-BnGE2oW2.js → feedback-QDN1AsYt.js} +1 -1
- package/dist/assets/flowMutationSafety-6cP-l4Pa.js +1 -0
- package/dist/assets/{form-tC20r4Ma.js → form-C4oby9pI.js} +1 -1
- package/dist/assets/{icons-CIvFfU2b.js → icons-BVzwsfbG.js} +1 -1
- package/dist/assets/index-B-QjN7pA.css +1 -0
- package/dist/assets/index-TploGF7u.js +8 -0
- package/dist/assets/install-BPp8nydm.js +3 -0
- package/dist/assets/{react-vendor-CyjgmGTq.js → react-vendor-CvwrP0tU.js} +2 -2
- package/dist/assets/{responses-CBLyy1Ob.js → responses-C9lP49qu.js} +1 -1
- package/dist/assets/{toastStore-B7n0zS0y.js → toastStore-B31o6Z5J.js} +1 -1
- package/dist/assets/{upstreamPaths-CDVsu6IM.js → upstreamPaths-ZeijhPPb.js} +1 -1
- package/dist/assets/useControlActionGuard-DT7uudrj.js +1 -0
- package/dist/assets/{usePolledData-c53tx1jw.js → usePolledData-CNtNtd0a.js} +1 -1
- package/dist/assets/useServerActionGuard-Db7PPgaI.js +1 -0
- package/dist/assets/useThroughputSeries-_J7gWbcI.js +1 -0
- package/dist/index.html +21 -18
- package/package.json +18 -8
- package/scripts/embedded.gen.ts +152 -150
- package/scripts/serveHandler.ts +22 -1
- package/scripts/servePolicy.ts +12 -3
- package/dist/assets/AddJob-CWkkVHmf.js +0 -3
- package/dist/assets/Benchmark-Dir2A1CQ.js +0 -1
- package/dist/assets/CronManager-CbM0x_s0.js +0 -1
- package/dist/assets/Diagnostics-Cw9iJ84f.js +0 -1
- package/dist/assets/Flows-BAzbFP_W.js +0 -2
- package/dist/assets/JobInspector-qvW_APO6.js +0 -2
- package/dist/assets/QueueActions-jiTzndPH.js +0 -1
- package/dist/assets/QueueDetail-URK2pjtH.js +0 -1
- package/dist/assets/QueueDetailPro-C9M5CV4K.js +0 -1
- package/dist/assets/S3BackupPro--WSZWTQn.js +0 -3
- package/dist/assets/ServerControl-QVd6m_iR.js +0 -3
- package/dist/assets/WorkersPro-BYY0P1Pt.js +0 -1
- package/dist/assets/Workflows-ByJw4FFH.js +0 -1
- package/dist/assets/bq-DYmbVkgR.js +0 -1
- package/dist/assets/flowMutationSafety-DObp9nJo.js +0 -1
- package/dist/assets/index-D64v2vNO.js +0 -8
- package/dist/assets/index-DOze4TKg.css +0 -1
- package/dist/assets/install-jXi1SOYY.js +0 -3
- package/dist/assets/useServerActionGuard-OTv6_fU0.js +0 -1
- package/dist/assets/useThroughputSeries-DWHQl7cM.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{i as e,r as t}from"./cn-zFEt5SO8.js";import{g as n,l as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{i as o}from"./upstreamPaths-CDVsu6IM.js";import{r as s,t as c}from"./bq-DYmbVkgR.js";import{t as l}from"./toastStore-B7n0zS0y.js";import{n as u}from"./usePolledData-c53tx1jw.js";import{t as d}from"./Button-BPqpRZJD.js";import{n as f,t as p}from"./Card-C7NMhqUt.js";import{t as m}from"./PageHeader-BXlZSBcc.js";import{a as h,n as g,o as _,t as v}from"./form-tC20r4Ma.js";import{r as y}from"./useServerActionGuard-OTv6_fU0.js";import{a as b,c as x,d as S,i as C,l as w,m as T,n as E,o as D,p as O,r as k,s as A,t as j,u as M}from"./responses-CBLyy1Ob.js";var N=e(n(),1),P=a();function F({values:e,setValue:t,queueNames:n,queueDiscoveryError:r,onRetryQueues:i,jsonError:a,setJsonError:o}){return(0,P.jsxs)(p,{children:[(0,P.jsx)(f,{title:`Job`}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,P.jsxs)(v,{label:`Queue`,children:[(0,P.jsx)(g,{list:`queue-options`,"aria-label":`Queue`,name:`target-queue`,autoComplete:`off`,value:e.queue,onChange:e=>t(`queue`,e.target.value),placeholder:`queue name (existing or new)`}),(0,P.jsx)(`datalist`,{id:`queue-options`,children:n.map(e=>(0,P.jsx)(`option`,{value:e},e))})]}),(0,P.jsx)(v,{label:`Job name`,hint:`Worker routing name in Bunqueue 2.8.59; separate from the JSON payload.`,children:(0,P.jsx)(g,{name:`job-name`,autoComplete:`off`,maxLength:256,value:e.name,onChange:e=>t(`name`,e.target.value),placeholder:`default`})}),r&&(0,P.jsxs)(`p`,{role:`status`,className:`-mt-2 text-xs text-warning`,children:[`Existing queue suggestions unavailable — `,r.message,`. You can still enter a queue name manually.`,` `,(0,P.jsx)(`button`,{type:`button`,onClick:i,className:`font-medium underline underline-offset-2 hover:text-fg`,children:`Retry`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(v,{label:`Data (JSON)`,children:(0,P.jsx)(`textarea`,{name:`job-data`,value:e.dataText,onChange:e=>t(`dataText`,e.target.value),onBlur:()=>{let t=T(e.dataText);o(t.ok?null:t.msg)},maxLength:O,spellCheck:!1,rows:7,className:`w-full rounded-lg border border-line bg-surface-2 p-3 font-mono text-sm text-fg focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})}),a&&(0,P.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:a})]})]})]})}function I({values:e,setValue:t}){return(0,P.jsxs)(p,{children:[(0,P.jsx)(f,{title:`Options`}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3`,children:[(0,P.jsx)(z,{label:`Priority`,name:`priority`,value:e.priority,min:-1e6,max:1e6,placeholder:`0`,onChange:e=>t(`priority`,e)}),(0,P.jsx)(z,{label:`Delay (ms)`,name:`delay`,value:e.delay,min:0,max:C,placeholder:`0`,disabled:e.runAt.trim()!==``,onChange:e=>t(`delay`,e)}),(0,P.jsx)(v,{label:`Run at`,hint:e.runAt.trim()?`Overrides Delay — derived from this time (local time).`:`(local time)`,children:(0,P.jsx)(g,{type:`datetime-local`,name:`run-at`,value:e.runAt,onChange:e=>t(`runAt`,e.target.value)})}),(0,P.jsx)(z,{label:`Max attempts`,hint:`blank = server default`,name:`max-attempts`,value:e.maxAttempts,min:1,max:1e3,placeholder:`3`,onChange:e=>t(`maxAttempts`,e)}),(0,P.jsx)(z,{label:`Backoff (ms)`,hint:`blank = server default`,name:`backoff`,value:e.backoff,min:0,max:b,placeholder:`1000`,onChange:e=>t(`backoff`,e)}),(0,P.jsx)(v,{label:`Backoff strategy`,hint:`flat delay unless set`,children:(0,P.jsxs)(h,{name:`backoff-strategy`,value:e.backoffType,onChange:e=>t(`backoffType`,e.target.value),children:[(0,P.jsx)(`option`,{value:``,children:`flat`}),(0,P.jsx)(`option`,{value:`fixed`,children:`fixed`}),(0,P.jsx)(`option`,{value:`exponential`,children:`exponential`})]})}),(0,P.jsx)(z,{label:`Timeout (ms)`,name:`timeout`,value:e.timeout,min:0,max:b,placeholder:`—`,onChange:e=>t(`timeout`,e)}),(0,P.jsx)(z,{label:`TTL (ms)`,hint:`blank = no expiry`,name:`ttl`,value:e.ttl,min:0,max:C,placeholder:`—`,onChange:e=>t(`ttl`,e)}),(0,P.jsx)(v,{label:`Custom job ID`,children:(0,P.jsx)(g,{name:`custom-job-id`,value:e.jobId,onChange:e=>t(`jobId`,e.target.value),placeholder:`idempotency key`})})]}),(0,P.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-6`,children:[(0,P.jsx)(B,{label:`removeOnComplete`,checked:e.removeOnComplete,onChange:e=>t(`removeOnComplete`,e)}),(0,P.jsx)(B,{label:`removeOnFail`,checked:e.removeOnFail,onChange:e=>t(`removeOnFail`,e)}),(0,P.jsx)(B,{label:`durable`,checked:e.durable,onChange:e=>t(`durable`,e)}),(0,P.jsx)(B,{label:`lifo`,checked:e.lifo,onChange:e=>t(`lifo`,e)})]}),(0,P.jsx)(L,{values:e,setValue:t})]})}function L({values:e,setValue:t}){return(0,P.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,P.jsx)(`div`,{className:`mb-3 text-[11px] uppercase tracking-wider text-faint`,children:`Advanced`}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3`,children:[(0,P.jsx)(R,{label:`Tags`,hint:`comma-separated`,name:`tags`,value:e.tags,placeholder:`email, urgent`,onChange:e=>t(`tags`,e)}),(0,P.jsx)(R,{label:`Group ID`,name:`group-id`,value:e.groupId,placeholder:`—`,onChange:e=>t(`groupId`,e)}),(0,P.jsx)(R,{label:`Unique key`,hint:`dedup key`,name:`unique-key`,value:e.uniqueKey,placeholder:`—`,onChange:e=>t(`uniqueKey`,e)}),(0,P.jsx)(R,{label:`Depends on`,hint:`parent job ids, comma-separated`,name:`depends-on`,value:e.dependsOn,placeholder:`job-id-1, job-id-2`,onChange:e=>t(`dependsOn`,e)}),(0,P.jsx)(`div`,{className:`col-span-2 md:col-span-3`,children:(0,P.jsx)(v,{label:`Repeat policy (JSON)`,hint:`v2.8.59-safe form: e.g. {"every":60000,"limit":10}. Use Cron Manager for cron patterns.`,children:(0,P.jsx)(`textarea`,{name:`repeat-policy`,value:e.repeatText,onChange:e=>t(`repeatText`,e.target.value),rows:2,spellCheck:!1,placeholder:`{"every": 60000}`,className:`w-full rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})})})]})]})}function R({label:e,hint:t,name:n,value:r,placeholder:i,onChange:a}){return(0,P.jsx)(v,{label:e,hint:t,children:(0,P.jsx)(g,{name:n,value:r,onChange:e=>a(e.target.value),placeholder:i})})}function z({label:e,hint:t,name:n,value:r,min:i,max:a,placeholder:o,disabled:s,onChange:c}){return(0,P.jsx)(v,{label:e,hint:t,children:(0,P.jsx)(g,{type:`number`,min:i,max:a,step:1,name:n,value:r,onChange:e=>c(e.target.value),placeholder:o,disabled:s})})}function B({label:e,checked:t,onChange:n}){return(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(_,{checked:t,onChange:n,label:e}),(0,P.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:e})]})}function V(e){let t=e?.options??{},n=D(t);return{queue:e?.queue??``,name:e?.name??`default`,dataText:e?.dataText??`{
|
|
2
|
-
"hello": "world"
|
|
3
|
-
}`,count:`1`,priority:A(t.priority),delay:``,runAt:``,maxAttempts:A(t.maxAttempts),backoff:n.backoff,timeout:A(t.timeout),ttl:n.ttl,jobId:``,removeOnComplete:t.removeOnComplete??!1,removeOnFail:t.removeOnFail??!1,durable:!1,lifo:!1,backoffType:n.backoffType,tags:n.tags,groupId:n.groupId,dependsOn:``,uniqueKey:``,repeatText:``}}function H(e,t=Date.now()){let n=e.queue.trim(),r=M(n);if(r)return U(r);let i=e.name.trim();if(!i||i.length>256)return U(`Job name must be a non-empty string of at most 256 characters`);let a=T(e.dataText);if(!a.ok)return{ok:!1,msg:a.msg,field:a.kind===`json`?`data`:`result`};let s=x({priority:e.priority,delay:e.runAt.trim()?``:e.delay,maxAttempts:e.maxAttempts,backoff:e.backoff,timeout:e.timeout,ttl:e.ttl});if(!s.ok)return U(s.msg);let c=s.options.delay;if(e.runAt.trim()){let n=new Date(e.runAt).getTime();if(!Number.isFinite(n))return U(`Run at is not a valid date/time`);if(c=Math.max(0,n-t),c>31536e6)return U(`Run at must be within the next 365 days`)}let l=S(s.options.backoff,e.backoffType);if(!l.ok)return U(l.msg);let u=W(e.tags),d=W(e.dependsOn),f=e.jobId.trim();if(f){let e=o(f);if(e)return U(`Job ID: ${e}`)}for(let e of d){let t=o(e);if(t)return U(`Dependency ID "${e}": ${t}`)}let p=w(e.repeatText);if(!p.ok)return U(p.msg);let m=Number(e.count);return!Number.isSafeInteger(m)||m<1||m>1e4?U(`Count must be a whole number from 1 to 10000`):{ok:!0,target:n,count:m,body:{name:i,data:a.data,priority:s.options.priority,delay:c,maxAttempts:s.options.maxAttempts,backoff:l.backoff,timeout:s.options.timeout,ttl:s.options.ttl,jobId:f||void 0,removeOnComplete:e.removeOnComplete||void 0,removeOnFail:e.removeOnFail||void 0,durable:e.durable||void 0,lifo:e.lifo||void 0,tags:u.length?u:void 0,groupId:e.groupId.trim()||void 0,dependsOn:d.length?d:void 0,uniqueKey:e.uniqueKey.trim()||void 0,repeat:p.repeat}}}var U=e=>({ok:!1,msg:e,field:`result`}),W=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),G=t({AddJob:()=>K,MAX_JOB_DATA_BYTES:()=>MAX_JOB_DATA_BYTES,MAX_JOB_DATA_CHARS:()=>O});function K(){let{data:e,error:t,refetch:n}=u(()=>c.queues(),[],{intervalMs:3e4}),a=r().state?.clone,[o,f]=(0,N.useState)(()=>V(a)),[p,h]=(0,N.useState)(!1),[_,b]=(0,N.useState)(null),[x,S]=(0,N.useState)(null),C=y(`add-job`),w=(e,t)=>f(n=>({...n,[e]:t}));(0,N.useEffect)(()=>{h(!1),b(null),S(null)},[C.scopeKey]);let T=async()=>{b(null),S(null);let e=H(o);if(!e.ok){e.field===`data`?S(e.msg):b({ok:!1,msg:e.msg});return}let t=C.begin();if(!t)return;h(!0);let{target:n,body:r,count:i}=e;try{if(i===1){let e=E(await c.addJob(n,r));if(!t.isCurrent())return;b({ok:!0,msg:`Accepted job ID ${e} (it may be an existing deduplicated job)`}),l.success(`Job submission accepted`,`${n} · ${e}`)}else{let e=Array.from({length:i},()=>r),a=s(e);if(a){t.isCurrent()&&b({ok:!1,msg:a});return}let o=j(await c.addJobsBulk(n,e),i);if(!t.isCurrent())return;let u=k(new Set(o).size,i);b(u),l.success(u.msg,`in ${n}`)}}catch(e){if(!t.isCurrent())return;b({ok:!1,msg:e.message}),l.error(`Add job failed`,e.message)}finally{t.finish()&&h(!1)}};return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(m,{title:`Add Job`,description:`Enqueue a job with full options.`,actions:(0,P.jsx)(i,{to:`/jobs/bulk-add`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Bulk import`})}),a&&(0,P.jsx)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-accent/30 bg-accent/[0.06] px-4 py-2 text-sm text-accent`,children:`Pre-filled from an existing job. Review the data and options, then enqueue a fresh job.`}),(0,P.jsxs)(`form`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,onSubmit:e=>{e.preventDefault(),T()},children:[(0,P.jsx)(F,{values:o,setValue:w,queueNames:(e?.queues??[]).map(e=>e.name),queueDiscoveryError:t,onRetryQueues:()=>void n(),jsonError:x,setJsonError:S}),(0,P.jsx)(I,{values:o,setValue:w}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3 lg:col-span-2`,children:[(0,P.jsx)(`div`,{className:`w-28`,children:(0,P.jsx)(v,{label:`Count`,hint:`1–10000`,children:(0,P.jsx)(g,{type:`number`,min:1,max:1e4,step:1,name:`count`,value:o.count,onChange:e=>w(`count`,e.target.value)})})}),(0,P.jsx)(d,{type:`submit`,variant:`accent`,disabled:p,children:p?`Adding…`:`Add job`}),_&&(0,P.jsx)(`span`,{role:_.ok?`status`:`alert`,className:_.ok?`text-sm text-success`:`text-sm text-danger`,children:_.msg})]})]})]})}export{G as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CyjgmGTq.js";import{o as i}from"./connectionStore-CKFQrxDo.js";import{t as a}from"./bq-DYmbVkgR.js";import{b as o,x as s}from"./icons-CIvFfU2b.js";import{n as c}from"./usePolledData-c53tx1jw.js";import{t as l}from"./Button-BPqpRZJD.js";import{n as u,t as d}from"./Card-C7NMhqUt.js";import{t as f}from"./PageHeader-BXlZSBcc.js";import{n as p,o as m,s as h}from"./format-Cg7VCIZW.js";import{a as g,n as _}from"./index-D64v2vNO.js";import{i as v,n as y,o as b,t as x}from"./form-tC20r4Ma.js";import{t as S}from"./AreaChart-w0ruozXH.js";var C=e(n(),1),w={total:1e6,batch:5e3,producers:64,payload:65536,workers:64,workerBatch:1e3,processMs:6e4,durationS:600},T={queue:`benchmark`,mode:`count`,total:5e3,durationS:30,batch:100,producers:4,payload:128,workers:4,workerBatch:100,processMs:5,durable:!1,removeOnComplete:!0},E=`bq-dashboard-benchmark-`;function D(){if(typeof globalThis.crypto?.randomUUID!=`function`)throw Error(`A cryptographically secure browser is required to create a benchmark queue.`);return`${E}${globalThis.crypto.randomUUID()}`}function O(e){return RegExp(`^${E}[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`,`i`).test(e)}var k={Smoke:{mode:`count`,total:200,batch:50,producers:2,workers:1,workerBatch:50,processMs:0},Standard:{mode:`count`,total:5e3,batch:100,producers:4,workers:4,workerBatch:100,processMs:5},Stress:{mode:`count`,total:5e4,batch:500,producers:16,workers:16,workerBatch:200,processMs:0},Soak:{mode:`duration`,durationS:30,batch:100,producers:4,workers:8,workerBatch:100,processMs:10}},A=(e,t,n)=>Number.isFinite(e)?Math.max(t,Math.min(n,Math.floor(e))):t;function j(e){return e?e.length>256?`Queue name is too long (maximum 256 characters).`:/^[a-zA-Z0-9_\-.:]+$/.test(e)?null:`Queue name contains unsupported characters.`:`Queue name is required.`}var M=(e,t)=>e.length?e[Math.min(e.length-1,Math.max(0,Math.ceil(t/100*e.length)-1))]:0,N=(e,t,n,r,i,a,o)=>Array.from({length:t},(t,s)=>({data:{i:e+s,blob:n},durable:r,removeOnComplete:i,...o===void 0?{}:{stallTimeout:o},...a?{jobId:`${a}-${e+s}`,tags:[`bunqueue-dashboard-benchmark`,a]}:{}})),P=e=>new Promise(t=>setTimeout(t,e)),F=async(e,t)=>{let n=performance.now()+e;for(;t()&&performance.now()<n;)await P(Math.min(100,Math.max(0,n-performance.now())))},I=e=>e instanceof Error?e.message:String(e),L=e=>e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`,R=[`count`,`duration`],z=[`waiting`,`completed`,`failed`],B=null;function ee(){return B??=D(),B}var te=[`total`,`durationS`,`batch`,`producers`,`payload`,`workers`,`workerBatch`,`processMs`],V=e=>({...e,total:String(e.total),durationS:String(e.durationS),batch:String(e.batch),producers:String(e.producers),payload:String(e.payload),workers:String(e.workers),workerBatch:String(e.workerBatch),processMs:String(e.processMs)}),H=e=>({...e,total:Number(e.total),durationS:Number(e.durationS),batch:Number(e.batch),producers:Number(e.producers),payload:Number(e.payload),workers:Number(e.workers),workerBatch:Number(e.workerBatch),processMs:Number(e.processMs)}),U=r();function ne({draft:e,active:n,cleaning:r,cleanResult:i,setField:a,numberInput:o,onClean:s}){return(0,U.jsxs)(d,{className:`lg:col-span-1`,children:[(0,U.jsx)(u,{title:`Configuration`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(x,{label:`Dedicated queue`,hint:`Cryptographically generated for this browser tab; production queue names cannot be entered here.`,children:(0,U.jsx)(y,{name:`benchmark-queue`,autoComplete:`off`,value:e.queue,readOnly:!0,"aria-readonly":`true`})}),(0,U.jsx)(x,{label:`Mode`,hint:e.mode===`count`?`Push a fixed number of jobs.`:`Run producers + workers for a fixed time.`,children:(0,U.jsx)(v,{options:R,value:e.mode,onChange:e=>a(`mode`,e),disabled:n})}),e.mode===`count`?(0,U.jsx)(x,{label:`Total jobs`,hint:`max ${h(w.total)}`,children:(0,U.jsx)(y,{name:`benchmark-total`,autoComplete:`off`,type:`number`,min:1,max:w.total,value:e.total,disabled:n,onChange:o(`total`)})}):(0,U.jsx)(x,{label:`Duration (s)`,hint:`max ${w.durationS}s`,children:(0,U.jsx)(y,{name:`benchmark-duration-seconds`,autoComplete:`off`,type:`number`,min:1,max:w.durationS,value:e.durationS,disabled:n,onChange:o(`durationS`)})}),(0,U.jsx)(`div`,{className:`mt-1 text-[11px] font-semibold uppercase tracking-wider text-faint`,children:`Producers`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsx)(x,{label:`Producers`,hint:`parallel, max ${w.producers}`,children:(0,U.jsx)(y,{name:`benchmark-producers`,autoComplete:`off`,type:`number`,min:1,max:w.producers,value:e.producers,disabled:n,onChange:o(`producers`)})}),(0,U.jsx)(x,{label:`Push batch`,hint:`jobs/req, max ${w.batch}`,children:(0,U.jsx)(y,{name:`benchmark-push-batch`,autoComplete:`off`,type:`number`,min:1,max:w.batch,value:e.batch,disabled:n,onChange:o(`batch`)})}),(0,U.jsx)(x,{label:`Payload`,hint:`bytes/job, max ${h(w.payload)}`,children:(0,U.jsx)(y,{name:`benchmark-payload-bytes`,autoComplete:`off`,type:`number`,min:0,max:w.payload,value:e.payload,disabled:n,onChange:o(`payload`)})})]}),(0,U.jsx)(`div`,{className:`mt-1 text-[11px] font-semibold uppercase tracking-wider text-faint`,children:`Workers (simulated)`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsx)(x,{label:`Workers`,hint:`0 = produce only, max ${w.workers}`,children:(0,U.jsx)(y,{name:`benchmark-workers`,autoComplete:`off`,type:`number`,min:0,max:w.workers,value:e.workers,disabled:n,onChange:o(`workers`)})}),(0,U.jsx)(x,{label:`Pull batch`,hint:`jobs/pull, max ${w.workerBatch}`,children:(0,U.jsx)(y,{name:`benchmark-pull-batch`,autoComplete:`off`,type:`number`,min:1,max:w.workerBatch,value:e.workerBatch,disabled:n,onChange:o(`workerBatch`)})}),(0,U.jsx)(x,{label:`Process (ms)`,hint:`simulated work per pull`,children:(0,U.jsx)(y,{name:`benchmark-process-ms`,autoComplete:`off`,type:`number`,min:0,max:w.processMs,value:e.processMs,disabled:n,onChange:o(`processMs`)})})]}),(0,U.jsx)(W,{label:`Durable (fsync each job)`,checked:e.durable,active:n,onChange:e=>a(`durable`,e)}),(0,U.jsx)(W,{label:`Remove on complete`,checked:e.removeOnComplete,active:n,onChange:e=>a(`removeOnComplete`,e)}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3 pt-1`,children:[(0,U.jsx)(l,{variant:`ghost`,size:`sm`,disabled:n||r,onClick:s,children:r?`Cleaning…`:`Clean queue`}),i&&(`error`in i?(0,U.jsxs)(`span`,{className:`text-xs text-danger`,children:[`Clean unverified — `,i.error]}):(0,U.jsx)(`span`,{className:t(`text-xs`,i.remaining>0?`text-warning`:`text-success`),children:i.remaining>0?`Cleaned — ${h(i.remaining)} active job(s) remain (requeued after the stall timeout)`:`Cleaned — 0 jobs remain`}))]})]})]})}function W({label:e,checked:t,active:n,onChange:r}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(b,{checked:t,onChange:r,disabled:n,label:e}),(0,U.jsx)(`span`,{className:`text-sm text-muted`,children:e})]})}function re({heading:e,pollBaseUrl:t,etaText:n,shown:r,shownWorkers:i,producePct:a,drainPct:o,durationPct:s,live:c,summary:l}){return(0,U.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,U.jsxs)(d,{children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:e}),(0,U.jsxs)(`span`,{className:`text-right text-xs text-faint`,children:[(0,U.jsxs)(`span`,{className:`block`,children:[`Benchmark target: `,t]}),n&&(0,U.jsx)(`span`,{className:`block`,children:n})]})]}),(0,U.jsx)(G,{label:r.mode===`duration`?`Elapsed`:`Produced`,pct:r.mode===`duration`?s:a,tone:`accent`}),i>0&&r.mode===`count`&&(0,U.jsx)(G,{label:`Completed`,pct:o,tone:`emerald`}),(0,U.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,U.jsx)(_,{label:`Pushed`,value:h(c.pushed),tone:`accent`,compact:!0}),(0,U.jsx)(_,{label:`Completed`,value:h(c.completed),tone:`green`,compact:!0}),(0,U.jsx)(_,{label:`Push/sec`,value:L(c.pushPerSec),compact:!0}),(0,U.jsx)(_,{label:`Done/sec`,value:L(c.donePerSec),tone:`green`,compact:!0}),(0,U.jsx)(_,{label:`Elapsed`,value:m(c.elapsedMs),compact:!0}),(0,U.jsx)(_,{label:`Active workers`,value:`${c.activeWorkers}/${i}`,tone:`blue`,compact:!0}),(0,U.jsx)(_,{label:`Data`,value:p(l?.bytes??c.bytes),compact:!0}),(0,U.jsx)(_,{label:`Errors`,value:h((l?.pushFailed??c.pushFailed)+(l?.ackFailed??c.ackFailed)),tone:c.pushFailed+c.ackFailed?`red`:`default`,compact:!0})]})]}),(0,U.jsxs)(d,{children:[(0,U.jsx)(u,{title:`Throughput`}),(0,U.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Enqueue (client → server) vs completion (workers) per second`}),(0,U.jsx)(S,{series:[{label:`Push/sec`,color:`#38bdf8`,points:c.pushSeries,area:!0},{label:`Done/sec`,color:`#34d399`,points:c.doneSeries,area:!0}]}),(0,U.jsxs)(`div`,{className:`mt-2 flex items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,U.jsx)(K,{color:`#38bdf8`,label:`Push/sec`,value:c.pushPerSec}),(0,U.jsx)(K,{color:`#34d399`,label:`Done/sec`,value:c.donePerSec})]})]})]})}function ie({summary:e}){return e?(0,U.jsxs)(d,{className:`mt-6`,children:[(0,U.jsx)(u,{title:`Summary`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,U.jsx)(_,{label:`Pushed`,value:h(e.pushed),tone:`accent`,compact:!0}),(0,U.jsx)(_,{label:`Completed`,value:h(e.completed),tone:`green`,compact:!0}),(0,U.jsx)(_,{label:`Duration`,value:m(e.durationMs),compact:!0}),(0,U.jsx)(_,{label:`Avg push/s`,value:L(e.pushPerSec),tone:`accent`,compact:!0}),(0,U.jsx)(_,{label:`Avg done/s`,value:L(e.donePerSec),tone:`green`,compact:!0}),(0,U.jsx)(_,{label:`Data rate`,value:`${p(e.mbPerSec)}/s`,compact:!0}),(0,U.jsx)(_,{label:`Push p95`,value:m(e.p95),compact:!0}),(0,U.jsx)(_,{label:`Push p99`,value:m(e.p99),compact:!0})]}),(0,U.jsxs)(`p`,{className:`mt-3 text-xs text-faint`,children:[`Push-batch latency avg `,m(e.avg),` · p50 `,m(e.p50),` · p95`,` `,m(e.p95),` · p99 `,m(e.p99),` · max `,m(e.max),`.`,e.error?` First error: ${e.error}`:``]})]}):null}function ae({pollQueue:e,pollBaseUrl:t,pinned:n,counts:r,error:i}){return(0,U.jsxs)(d,{className:`mt-6`,children:[(0,U.jsx)(u,{title:`Server queue: ${e}`,action:i?(0,U.jsx)(`span`,{className:`text-xs font-medium text-warning`,children:`stale — server unreachable`}):void 0}),(0,U.jsxs)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:[`Live counts from `,t,` (poll 1s).`,n?` Pinned to the current or last benchmark run.`:``]}),r?(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,U.jsx)(_,{label:`Waiting`,value:h(r.waiting??0),tone:`amber`,compact:!0}),(0,U.jsx)(_,{label:`Active`,value:h(r.active??0),tone:`blue`,compact:!0}),(0,U.jsx)(_,{label:`Completed`,value:h(r.completed??0),tone:`green`,compact:!0}),(0,U.jsx)(_,{label:`Failed`,value:h(r.failed??0),tone:r.failed?`red`:`default`,compact:!0}),(0,U.jsx)(_,{label:`Delayed`,value:h(r.delayed??0),compact:!0})]}):(0,U.jsx)(`p`,{className:`text-sm text-faint`,children:`No counts yet — waiting for the server to answer for this queue.`})]})}function G({label:e,pct:n,tone:r}){return(0,U.jsxs)(`div`,{className:`mb-2`,children:[(0,U.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-[11px] text-faint`,children:[(0,U.jsx)(`span`,{children:e}),(0,U.jsxs)(`span`,{className:`tnum`,children:[n.toFixed(0),`%`]})]}),(0,U.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-2`,role:`progressbar`,"aria-label":e,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(n),children:(0,U.jsx)(`div`,{className:t(`h-full rounded-full transition-[width] motion-reduce:transition-none`,r===`accent`?`bg-accent`:`bg-emerald-500`),style:{width:`${n}%`}})})]})}function K({color:e,label:t,value:n}){return(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,U.jsxs)(`span`,{className:`text-fg`,children:[L(n),`/s`]})]})}function q({history:e,onClear:t}){if(!e.length)return null;let n=JSON.stringify(e,null,2);return(0,U.jsxs)(d,{padded:!1,className:`mt-6 overflow-hidden`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-5 py-3`,children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Run history`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(g,{value:n}),(0,U.jsx)(l,{size:`sm`,variant:`ghost`,onClick:()=>{let e=new Blob([n],{type:`application/json`}),t=URL.createObjectURL(e),r=document.createElement(`a`);r.href=t,r.download=`benchmark-history-${Date.now()}.json`,r.click(),URL.revokeObjectURL(t)},children:`Export JSON`}),(0,U.jsx)(l,{size:`sm`,variant:`ghost`,onClick:t,children:`Clear`})]})]}),(0,U.jsx)(`div`,{className:`overflow-x-auto`,children:(0,U.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,U.jsx)(`th`,{className:`px-5 py-2 font-medium`,children:`Mode`}),(0,U.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Prod`}),(0,U.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Wkr`}),(0,U.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Pushed`}),(0,U.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Done`}),(0,U.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Push/s`}),(0,U.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Done/s`}),(0,U.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`p95`}),(0,U.jsx)(`th`,{className:`px-5 py-2 text-right font-medium`,children:`Dur`})]})}),(0,U.jsx)(`tbody`,{children:e.map(e=>(0,U.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,U.jsx)(`td`,{className:`px-5 py-2 capitalize text-muted`,children:e.mode}),(0,U.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-muted`,children:e.producers}),(0,U.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-muted`,children:e.workers}),(0,U.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-fg`,children:h(e.pushed)}),(0,U.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-success`,children:h(e.completed)}),(0,U.jsxs)(`td`,{className:`px-5 py-2 text-right tnum text-accent`,children:[L(e.pushPerSec),`/s`]}),(0,U.jsxs)(`td`,{className:`px-5 py-2 text-right tnum text-success`,children:[L(e.donePerSec),`/s`]}),(0,U.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-muted`,children:m(e.p95)}),(0,U.jsx)(`td`,{className:`px-5 py-2 text-right tnum text-muted`,children:m(e.durationMs)})]},e.id))})]})})]})}var oe=[`waiting`,`prioritized`,`delayed`,`active`,`paused`,`waiting-children`,`completed`,`failed`];function J(e){return oe.reduce((t,n)=>{let r=e[n];if(!Number.isSafeInteger(r)||r<0)throw Error(`Malformed queue count for "${n}".`);return t+r},0)}function Y(e,t){if(!e||typeof e!=`object`||e.ok!==!0)throw Error(`${t} returned a malformed success response.`)}var X={pushed:0,completed:0,pushFailed:0,ackFailed:0,bytes:0,elapsedMs:0,pushPerSec:0,donePerSec:0,activeWorkers:0,pushSeries:[],doneSeries:[],etaMs:null,error:null},Z=()=>({pushed:0,completed:0,pushFailed:0,ackFailed:0,bytes:0,assigned:0,startedAt:0,pushLat:[],activeWorkers:0,error:null,lastAt:0,lastPushed:0,lastDone:0,pushSeries:[],doneSeries:[]});function se(e,t,n,r){let i=r-e.startedAt,a=(r-e.lastAt)/1e3,o=a>0?Math.max(0,(e.pushed-e.lastPushed)/a):0,s=a>0?Math.max(0,(e.completed-e.lastDone)/a):0;e.lastAt=r,e.lastPushed=e.pushed,e.lastDone=e.completed,e.pushSeries=[...e.pushSeries,o].slice(-60),e.doneSeries=[...e.doneSeries,s].slice(-60);let c=null;if(t?.mode===`count`){let r=A(t.total,1,w.total);if(n===`draining`){let t=e.doneSeries.slice(-10),n=t.length?t.reduce((e,t)=>e+t,0)/t.length:0;n<=0&&i>0&&(n=e.completed/(i/1e3)),n>0&&(c=Math.max(0,r-e.completed)/n*1e3)}else o>0&&(c=Math.max(0,r-e.pushed)/o*1e3)}else t?.mode===`duration`&&(c=Math.max(0,A(t.durationS,1,w.durationS)*1e3-i));return{pushed:e.pushed,completed:e.completed,pushFailed:e.pushFailed,ackFailed:e.ackFailed,bytes:e.bytes,elapsedMs:i,pushPerSec:o,donePerSec:s,activeWorkers:e.activeWorkers,pushSeries:e.pushSeries,doneSeries:e.doneSeries,etaMs:c,error:e.error}}function ce(e,t){let n=t/1e3||1,r=[...e.pushLat].sort((e,t)=>e-t);return{pushed:e.pushed,completed:e.completed,pushFailed:e.pushFailed,ackFailed:e.ackFailed,bytes:e.bytes,durationMs:t,pushPerSec:e.pushed/n,donePerSec:e.completed/n,mbPerSec:e.bytes/n,avg:r.length?r.reduce((e,t)=>e+t,0)/r.length:0,p50:M(r,50),p95:M(r,95),p99:M(r,99),max:r.length?r[r.length-1]:0,error:e.error}}function le(e){let t=e.queue.trim(),n=j(t);return n?{ok:!1,error:n}:[`count`,`duration`].includes(e.mode)?typeof e.durable!=`boolean`||typeof e.removeOnComplete!=`boolean`?{ok:!1,error:`Benchmark job options are invalid.`}:{ok:!0,config:Object.freeze({...e,queue:t,total:A(e.total,1,w.total),durationS:A(e.durationS,1,w.durationS),batch:A(e.batch,1,w.batch),producers:A(e.producers,1,w.producers),payload:A(e.payload,0,w.payload),workers:A(e.workers,0,w.workers),workerBatch:A(e.workerBatch,1,w.workerBatch),processMs:A(e.processMs,0,w.processMs)})}:{ok:!1,error:`Benchmark mode is invalid.`}}async function ue(e,t,n){try{Y(await e.overview(),`Dashboard preflight`)}catch(e){return{ok:!1,live:{...X,error:`Server unreachable — start it on the Server page first. (${I(e)})`}}}if(!n())return{ok:!0};try{let r=await e.counts(t);if(!n())return{ok:!0};if(Y(r,`Queue-count preflight`),!r.counts||typeof r.counts!=`object`||Array.isArray(r.counts))throw Error(`Malformed queue-count response.`);let i=J(r.counts);if(i>0)return{ok:!1,live:{...X,error:`Dedicated benchmark queue "${t}" is not empty (${i} job(s) across all states). Clean it before running so no external work can be consumed or deleted.`}}}catch(e){return{ok:!1,live:{...X,error:`Could not verify that dedicated queue "${t}" is empty. (${I(e)})`}}}return{ok:!0}}function de(e){return async()=>{let{stats:t}=e;for(;e.shouldContinue();){let n;if(e.runConfig.mode===`count`){if(t.assigned>=e.total)break;n=Math.min(e.batch,e.total-t.assigned)}else{if(performance.now()>=e.deadline)break;n=e.batch}let r=t.assigned;t.assigned+=n;let i=N(r,n,e.blob,e.runConfig.durable,e.runConfig.removeOnComplete,e.runId,Math.max(12e4,e.processMs+6e4)),a=performance.now(),o=e.client.addJobsBulk(e.queue,i).then(r=>{if(!e.isCurrent())return;if(Y(r,`Bulk enqueue`),!Array.isArray(r.ids)||r.ids.length!==n||r.ids.some(e=>typeof e!=`string`||e.length===0)||new Set(r.ids).size!==r.ids.length)throw Error(`Bulk enqueue returned invalid job IDs.`);let i=r.ids;for(let t of i)e.ownJobIds.add(t);t.pushed+=i.length,t.bytes+=i.length*e.payload;let a=Math.max(0,n-i.length);a>0&&(t.pushFailed+=a,t.error??=`Server created ${i.length} of ${n} jobs in a benchmark batch.`)}).catch(r=>{e.isCurrent()&&(t.pushFailed+=n,t.error??=I(r))});e.pendingPushes.add(o);try{await o}finally{e.pendingPushes.delete(o)}e.isCurrent()&&t.pushLat.push(performance.now()-a)}}}function fe(e){return async()=>{let{stats:t}=e;for(;e.shouldContinue()&&!(e.runConfig.mode===`duration`&&performance.now()>=e.deadline||e.runConfig.mode===`count`&&t.completed>=e.total);){t.activeWorkers++;let n=[];try{if(n=await pe(e),!e.shouldContinue())break;n.length>0&&await me(e,n)}finally{e.isCurrent()&&t.activeWorkers--}if(!e.shouldContinue())break;if(n.length===0){if(e.runConfig.mode===`count`&&e.producersDone()){e.ownJobIds.size>0&&(t.error??=`${e.ownJobIds.size} benchmark job(s) could not be drained.`);break}await F(50,e.shouldContinue)}}}}async function pe(e){try{let t=await e.client.pullBatch(e.queue,e.workerBatch);if(!e.shouldContinue())return[];if(t?.ok!==!0||!Array.isArray(t.jobs)||t.jobs.length>e.workerBatch||t.jobs.some(e=>!e||typeof e!=`object`||typeof e.id!=`string`||e.id.length===0)||new Set(t.jobs.map(e=>e.id)).size!==t.jobs.length)throw Error(`Malformed pull-batch response.`);return t.jobs}catch(t){return e.isCurrent()&&(e.stats.error??=I(t)),[]}}async function me(e,t){if(t.some(t=>!e.ownJobIds.has(t.id))&&e.pendingPushes.size>0&&await Promise.allSettled([...e.pendingPushes]),!e.shouldContinue())return;let n=t.filter(t=>e.ownJobIds.has(t.id)),r=t.filter(t=>!e.ownJobIds.has(t.id));if(r.length>0&&await he(e,r),!(n.length===0||!e.shouldContinue())&&(e.processMs>0&&await F(e.processMs,e.shouldContinue),e.shouldContinue()))try{let t=n.map(e=>e.id),r=await e.client.heartbeatBatch(t);Y(r,`Heartbeat benchmark jobs`);let i=r.data;if(!i||typeof i!=`object`||i.ok!==!0||!Number.isSafeInteger(i.count)||i.count!==n.length)throw Error(`Heartbeat confirmed ${String(i?.count)} of ${n.length} benchmark jobs; refusing a lossy batch ACK.`);if(!e.shouldContinue()||(Y(await e.client.ackBatch(t),`Acknowledge benchmark jobs`),!e.isCurrent()))return;e.stats.completed+=n.length;for(let t of n)e.ownJobIds.delete(t.id)}catch(t){if(!e.isCurrent())return;e.stats.ackFailed+=n.length,e.stats.error??=I(t)}}async function he(e,t){if(!e.shouldContinue())return;let n=await Promise.allSettled(t.map(async t=>{Y(await e.client.retryJob(t.id),`Restore job ${t.id}`)}));if(!e.isCurrent())return;let r=n.filter(e=>e.status===`rejected`);e.stats.error??=r.length>0?`Detected ${t.length} foreign job(s); ${r.length} could not be returned to waiting. Benchmark stopped.`:`Detected ${t.length} foreign job(s); returned them to waiting and stopped without counting them.`,e.stop()}var ge=0;async function _e(e,t,n){if(e.runningRef.current||!e.mountedRef.current)return;e.runningRef.current=!0;let r=++e.runGenerationRef.current,i=n??a.createServerTargetClient(a.captureServerRequestTarget()),o=()=>e.mountedRef.current&&e.runGenerationRef.current===r,s=()=>o()&&!e.stopRef.current;e.stopRef.current=!1;try{e.setSummary(null);let n=le(t);if(!n.ok){e.setLive({...X,error:n.error}),Q(e,`error`);return}let r=n.config,a=await ue(i,r.queue,s);if(!o())return;if(!a.ok){e.setLive(a.live),Q(e,`error`);return}if(!s())return;e.producersDoneRef.current=!1,e.configRef.current=r,e.setRunConfig(r);let c=Z();c.startedAt=performance.now(),c.lastAt=performance.now(),e.statsRef.current=c,e.setLive({...X}),Q(e,`running`);let l={batch:r.batch,blob:`x`.repeat(r.payload),client:i,deadline:performance.now()+r.durationS*1e3,isCurrent:o,ownJobIds:new Set,payload:r.payload,pendingPushes:new Set,processMs:r.processMs,producersDone:()=>e.producersDoneRef.current,queue:r.queue,runConfig:r,runId:`bqbench-${globalThis.crypto.randomUUID()}`,shouldContinue:s,stats:c,stop:()=>{e.stopRef.current=!0},total:r.total,workerBatch:r.workerBatch},u=de(l),d=fe(l),f=Array.from({length:r.producers},u),p=Array.from({length:r.workers},d),m=Promise.all(f).then(()=>{o()&&(e.producersDoneRef.current=!0,s()&&r.mode===`count`&&r.workers>0&&e.phaseRef.current===`running`&&Q(e,`draining`))});if(await Promise.all([m,...p]),!o())return;ve(e,r,c)}finally{e.runningRef.current=!1}}function ve(e,t,n){let r=performance.now()-n.startedAt,i=ce(n,r);e.setSummary(i),e.setLive(e=>({...e,pushed:n.pushed,completed:n.completed,pushFailed:n.pushFailed,ackFailed:n.ackFailed,bytes:n.bytes,elapsedMs:r,pushPerSec:0,donePerSec:0,activeWorkers:0,etaMs:0,error:n.error})),e.setHistory(e=>[{...i,id:++ge,at:Date.now(),mode:t.mode,producers:t.producers,workers:t.workers},...e].slice(0,12)),Q(e,e.stopRef.current?`stopped`:n.error?`error`:`done`)}function Q(e,t){e.phaseRef.current=t,e.setPhase(t)}function ye(){let[e,t]=(0,C.useState)(`idle`),[n,r]=(0,C.useState)(X),[i,a]=(0,C.useState)(null),[o,s]=(0,C.useState)([]),[c,l]=(0,C.useState)(null),u=(0,C.useRef)(!1),d=(0,C.useRef)(!0),f=(0,C.useRef)(0),p=(0,C.useRef)(!1),m=(0,C.useRef)(!1),h=(0,C.useRef)(null),g=(0,C.useRef)(`idle`),_=(0,C.useRef)(Z());return g.current=e,(0,C.useEffect)(()=>(d.current=!0,()=>{d.current=!1,u.current=!0,f.current++}),[]),(0,C.useEffect)(()=>{if(e!==`running`&&e!==`draining`)return;let t=setInterval(()=>{r(se(_.current,h.current,g.current,performance.now()))},200);return()=>clearInterval(t)},[e]),{phase:e,live:n,summary:i,history:o,runCfg:c,run:(e,n)=>_e({configRef:h,mountedRef:d,phaseRef:g,producersDoneRef:m,runningRef:p,runGenerationRef:f,setHistory:s,setLive:r,setPhase:t,setRunConfig:l,setSummary:a,statsRef:_,stopRef:u},e,n),stop:()=>{u.current=!0,(g.current===`running`||g.current===`draining`)&&(g.current=`stopping`,t(`stopping`))},reset:()=>{u.current=!0,f.current++,g.current=`idle`,a(null),r(X),t(`idle`)},clearHistory:()=>s([])}}function be({benchmark:e,counts:t,dedicatedQueue:n,draft:r,pollQueue:i,runTarget:a,setRunTarget:o}){let s=(0,C.useRef)(null),c=(0,C.useRef)(!0),[l,u]=(0,C.useState)(!1),[d,f]=(0,C.useState)(null);(0,C.useEffect)(()=>(c.current=!0,()=>{c.current=!1,s.current=null}),[]);let p=async()=>{let e=r.queue.trim();if(s.current||!e)return;if(!O(e)||e!==n){f({error:`refusing to clean a queue not owned by this dashboard session`});return}s.current=`clean`;let o=a??$(),l=t&&i===e?` Currently ${h(t.waiting??0)} waiting / ${h(t.completed??0)} completed.`:``;if(!window.confirm(`Clean every cleanable job from the dedicated dashboard benchmark queue "${e}" on ${o.target.baseUrl}? This is queue-wide; the cryptographic queue name is owned by this browser session.${l}`)){s.current=null;return}u(!0),f(null);try{let t=null;for(let n of z){if(!c.current)return;try{let t=await o.client.clean(e,{state:n,limit:w.total});if(Y(t,`Clean ${n} jobs`),!Number.isSafeInteger(t.count)||t.count<0)throw Error(`Clean ${n} jobs returned an invalid count.`)}catch(e){t=e.message}}if(!c.current)return;let n=await o.client.counts(e).catch(e=>(t=e.message,null));if(!c.current)return;if(!n)f({error:t??`server unreachable — could not verify`});else if(n.ok!==!0||!n.counts||typeof n.counts!=`object`||Array.isArray(n.counts))f({error:`server returned a malformed queue-count response`});else try{let e=J(n.counts);f(t||e>0?{error:t??`${h(e)} job(s) still present`}:{remaining:0})}catch{f({error:`server returned malformed queue counts`})}}finally{c.current&&u(!1),s.current===`clean`&&(s.current=null)}},m=()=>{if(s.current)return;s.current=`run`;let n=H(r),c=n.queue.trim(),l=$();if(j(c)){e.run({...n,queue:c},l.client).finally(g);return}let u=0;if(!a&&t&&i===c)try{u=J(t)}catch{}let d=u>0?` Warning: it already holds ${h(u)} job(s) across all states; the safety preflight will refuse the run until the dedicated queue is empty.`:``;if(!window.confirm(`Enqueue real jobs into "${c}" on ${l.target.baseUrl}?${d}`)){s.current=null;return}o(l),e.run(n,l.client).finally(g)},g=()=>{s.current===`run`&&(s.current=null)};return{cleaning:l,cleanResult:d,cleanup:p,start:m}}function $(){let e=a.captureServerRequestTarget();return{target:e,client:a.createServerTargetClient(e)}}function xe(){let[e]=(0,C.useState)(ee),[t,n]=(0,C.useState)(()=>V({...T,queue:e})),r=ye(),u=i(e=>e.baseUrl),[d,p]=(0,C.useState)(null),m=(e,t)=>n(n=>({...n,[e]:t})),h=e=>t=>m(e,t.target.value),g=e=>n(t=>{let n={...t};for(let[t,r]of Object.entries(e))n[t]=te.includes(t)?String(r):r;return n}),[_,v]=(0,C.useState)(e);(0,C.useEffect)(()=>{let e=setTimeout(()=>v(t.queue.trim()||T.queue),400);return()=>clearTimeout(e)},[t.queue]);let y=d?.target.baseUrl??u,{data:b,error:x}=c(()=>d?d.client.counts(_):a.counts(_),[_,d],{intervalMs:1e3}),S=b?.counts??null,E=be({benchmark:r,counts:S,dedicatedQueue:e,draft:t,pollQueue:_,runTarget:d,setRunTarget:p}),{phase:D,live:O,summary:j,history:M}=r,N=D===`running`||D===`draining`||D===`stopping`,P=r.runCfg??H(t),F=A(P.total,1,w.total),I=A(P.workers,0,w.workers),L=P.mode===`count`&&(N||j)?Math.min(100,O.pushed/F*100):0,R=P.mode===`count`&&(N||j)?Math.min(100,O.completed/F*100):0,z=P.mode===`duration`?Math.min(100,O.elapsedMs/(A(P.durationS,1,w.durationS)*1e3)*100):0,B=Se(D,P.mode,!!j),W=Ce(D,O.etaMs);return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(f,{title:`Benchmark`,description:`Drive real load against the server — producers bulk-enqueue jobs while simulated workers pull, process and ack them. Throughput is measured client-side; the queue genuinely fills and drains.`,actions:D===`stopping`?(0,U.jsxs)(l,{variant:`warning`,size:`sm`,disabled:!0,children:[(0,U.jsx)(o,{className:`size-3.5`}),` Stopping…`]}):N?(0,U.jsxs)(l,{variant:`warning`,size:`sm`,onClick:r.stop,children:[(0,U.jsx)(o,{className:`size-3.5`}),` Stop`]}):(0,U.jsxs)(l,{variant:`success`,size:`sm`,disabled:E.cleaning,onClick:E.start,children:[(0,U.jsx)(s,{className:`size-3.5`}),` Run benchmark`]})}),O.error&&(0,U.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:O.error}),(0,U.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-faint`,children:`Presets`}),Object.keys(k).map(e=>(0,U.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>g(k[e]),className:`rounded-md border border-line bg-surface-2 px-2.5 py-1 text-xs text-muted transition-colors hover:border-line-strong hover:text-fg disabled:opacity-40`,children:e},e))]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,U.jsx)(ne,{draft:t,active:N,cleaning:E.cleaning,cleanResult:E.cleanResult,setField:m,numberInput:h,onClean:()=>void E.cleanup()}),(0,U.jsx)(re,{heading:B,pollBaseUrl:y,etaText:W,shown:P,shownWorkers:I,producePct:L,drainPct:R,durationPct:z,live:O,summary:j})]}),(0,U.jsx)(ie,{summary:j}),(0,U.jsx)(ae,{pollQueue:_,pollBaseUrl:y,pinned:!!d,counts:S,error:x}),(0,U.jsx)(q,{history:M,onClear:r.clearHistory})]})}function Se(e,t,n){return e===`running`?t===`duration`?`Running…`:`Producing…`:e===`draining`?`Draining…`:e===`stopping`?`Stopping…`:e===`error`?`Error`:n?`Result`:`Ready`}function Ce(e,t){return(e===`running`||e===`draining`)&&t!=null?t>0?`ETA ${m(t)}`:`finishing…`:e===`stopped`?`stopped early`:e===`done`?`complete`:``}export{xe as Benchmark};
|
|
@@ -1 +0,0 @@
|
|
|
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"./upstreamPaths-CDVsu6IM.js";import{t as a}from"./bq-DYmbVkgR.js";import{t as o}from"./toastStore-B7n0zS0y.js";import{O as s,c}from"./icons-CIvFfU2b.js";import{n as l}from"./usePolledData-c53tx1jw.js";import{n as u,t as d}from"./Button-BPqpRZJD.js";import{n as f,t as p}from"./Card-C7NMhqUt.js";import{i as m,n as h,r as g,t as _}from"./feedback-BnGE2oW2.js";import{t as v}from"./PageHeader-BXlZSBcc.js";import{i as y,s as b}from"./format-Cg7VCIZW.js";import{i as x,n as S,o as C,t as w}from"./form-tC20r4Ma.js";import{t as T}from"./Pagination-Q-vf4hsX.js";import{r as E}from"./useServerActionGuard-OTv6_fU0.js";import{m as D,p as O,u as k}from"./responses-CBLyy1Ob.js";import"./AddJob-CWkkVHmf.js";var A=e(n(),1),j=365*24*60*60*1e3,M=1440*60*1e3;function N(e){if(typeof e!=`object`||!e||e.ok!==!0)throw Error(`Delete cron returned a malformed success response`)}function P(e,t){let n=e?.cron;if(typeof e!=`object`||!e||e.ok!==!0||typeof n!=`object`||!n||n.name!==t.name||n.queue!==t.queue)throw Error(`Create cron returned a malformed success response`)}var F=e=>`Cron "${e}" already exists. Bunqueue v2.8.59 does not return complete cron definitions, so editing could reset hidden options. Delete it explicitly, wait for the list to refresh, then create the replacement as a separate action.`;function I(e,t){let n=e.trim();return n&&t.has(n)?F(n):null}function L(e,t){let n=e;if(typeof n!=`object`||!n||n.ok!==!0||!Array.isArray(n.crons)||n.crons.some(e=>typeof e!=`object`||!e||typeof e.name!=`string`))throw Error(`Cannot verify that the cron name is unused; creation was not attempted`);if(n.crons.some(e=>e.name===t.trim()))throw Error(F(t.trim()))}function R(e){let t=Number(e);if(!Number.isInteger(t)||t<=0)return null;if(t<1e3)return`every ${t}ms`;for(let[e,n]of[[864e5,`d`],[36e5,`h`],[6e4,`m`],[1e3,`s`]])if(t>=e){let r=t/e;return`${Number.isInteger(r)?``:`≈ `}every ${Math.round(r*10)/10}${n}`}return null}function z(e,t,n,r){if(!e.trim())return{ok:!0};let i=Number(e);return!Number.isSafeInteger(i)||i<n||i>r?{ok:!1,msg:`${t} must be a whole number from ${n} to ${r}`}:{ok:!0,value:i}}function B(e,t=Date.now()){let n=e.name.trim(),r=e.queue.trim();if(!n)return{ok:!1,msg:`Name is required`};if(n.length>256)return{ok:!1,msg:`Name must be 256 characters or fewer`};let a=i(n,`Name`,256);if(a)return{ok:!1,msg:a};let o=k(r);if(o)return{ok:!1,msg:o};let s=e.jobName?.trim()||`default`;if(s.length>256)return{ok:!1,msg:`Spawned job name must be 256 characters or fewer`};let c={};if(e.dataText.trim()){let t=D(e.dataText);if(!t.ok)return{ok:!1,msg:t.kind===`json`?`Data is not valid JSON`:t.msg};c=t.data}let l={name:n,jobName:s,queue:r,data:c,preventOverlap:e.preventOverlap,skipIfNoWorker:e.skipIfNoWorker,immediately:e.immediately,skipMissedOnRestart:e.skipMissedOnRestart};if(e.mode===`cron`){let t=e.schedule.trim();if(!t)return{ok:!1,msg:`Cron expression required`};l.schedule=t}else{let t=z(e.every,`Interval`,1,j);if(!t.ok||t.value===void 0)return{ok:!1,msg:t.ok?`Interval is required`:t.msg};l.repeatEvery=t.value}let u=e.timezone.trim();if(u){if(e.mode!==`cron`)return{ok:!1,msg:`Timezone applies only to cron expressions, not intervals`};try{new Intl.DateTimeFormat(`en`,{timeZone:u}).format(t)}catch{return{ok:!1,msg:`Timezone must be a valid IANA timezone`}}l.timezone=u}let d=z(e.priority,`Priority`,-1e6,1e6);if(!d.ok)return d;d.value!==void 0&&(l.priority=d.value);let f=z(e.maxLimit,`Max executions`,1,2**53-1);if(!f.ok)return f;f.value!==void 0&&(l.maxLimit=f.value);let p=e.uniqueKey.trim();if(p.length>1024)return{ok:!1,msg:`Unique key must be 1024 characters or fewer`};p&&(l.uniqueKey=p);let m=z(e.dedupTtl,`Dedup TTL`,1,j);if(!m.ok)return m;let h=m.value!==void 0||e.dedupExtend||e.dedupReplace;if(e.dedupExtend&&e.dedupReplace)return{ok:!1,msg:`Dedup extend and replace are mutually exclusive`};if(e.dedupExtend&&m.value===void 0)return{ok:!1,msg:`Dedup extend requires a TTL`};if(h&&!p&&!e.preventOverlap)return{ok:!1,msg:`Dedup options require a unique key or Prevent overlap`};h&&(l.dedup={...m.value===void 0?{}:{ttl:m.value},...e.dedupExtend?{extend:!0}:{},...e.dedupReplace?{replace:!0}:{}});let g=[{raw:e.jobMaxAttempts,label:`Spawned-job max attempts`,min:1,max:1e3,key:`maxAttempts`},{raw:e.jobBackoff,label:`Spawned-job backoff`,min:0,max:M,key:`backoff`},{raw:e.jobTimeout,label:`Spawned-job timeout`,min:0,max:M,key:`timeout`},{raw:e.jobDelay,label:`Spawned-job delay`,min:0,max:j,key:`delay`},{raw:e.jobStallTimeout,label:`Spawned-job stall timeout`,min:0,max:M,key:`stallTimeout`}],_={};for(let e of g){let t=z(e.raw,e.label,e.min,e.max);if(!t.ok)return t;t.value!==void 0&&(_[e.key]=t.value)}return e.jobRemoveOnComplete&&(_.removeOnComplete=!0),e.jobRemoveOnFail&&(_.removeOnFail=!0),Object.keys(_).length&&(l.jobOptions=_),{ok:!0,body:l}}var V=r();function H({values:e,setValue:t}){return(0,V.jsxs)(`div`,{id:`cron-advanced-options`,className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,V.jsx)(w,{label:`Timezone (IANA)`,hint:`e.g. Europe/Rome. Default: server timezone.`,children:(0,V.jsx)(S,{name:`cron-timezone`,autoComplete:`off`,value:e.timezone,onChange:e=>t(`timezone`,e.target.value),placeholder:`Europe/Rome`})}),(0,V.jsx)(w,{label:`Priority`,children:(0,V.jsx)(S,{type:`number`,min:-1e6,max:1e6,step:1,name:`cron-priority`,value:e.priority,onChange:e=>t(`priority`,e.target.value),placeholder:`0`})}),(0,V.jsx)(w,{label:`Max executions`,hint:`blank = unlimited`,children:(0,V.jsx)(S,{type:`number`,min:1,max:2**53-1,step:1,name:`cron-max-executions`,value:e.maxLimit,onChange:e=>t(`maxLimit`,e.target.value),placeholder:`∞`})}),(0,V.jsx)(w,{label:`Unique key`,hint:`optional deduplication key`,children:(0,V.jsx)(S,{name:`cron-unique-key`,autoComplete:`off`,maxLength:1024,value:e.uniqueKey,onChange:e=>t(`uniqueKey`,e.target.value),placeholder:`daily-report`})}),(0,V.jsxs)(`div`,{className:`col-span-2 flex flex-wrap gap-6`,children:[(0,V.jsx)(W,{label:`prevent overlap`,checked:e.preventOverlap,onChange:e=>t(`preventOverlap`,e)}),(0,V.jsx)(W,{label:`skip if no worker`,checked:e.skipIfNoWorker,onChange:e=>t(`skipIfNoWorker`,e)}),(0,V.jsx)(W,{label:`run immediately`,checked:e.immediately,onChange:e=>t(`immediately`,e)}),(0,V.jsx)(W,{label:`skip missed on restart`,checked:e.skipMissedOnRestart,onChange:e=>t(`skipMissedOnRestart`,e)})]}),(0,V.jsxs)(`div`,{className:`col-span-2`,children:[(0,V.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wider text-faint`,children:`Cron deduplication`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,V.jsx)(w,{label:`Dedup TTL (ms)`,hint:`blank = no TTL`,children:(0,V.jsx)(S,{type:`number`,min:1,max:j,step:1,name:`cron-dedup-ttl`,value:e.dedupTtl,onChange:e=>t(`dedupTtl`,e.target.value),placeholder:`60000`})}),(0,V.jsx)(W,{className:`items-end pb-2`,label:`extend TTL`,controlLabel:`extend dedup TTL`,checked:e.dedupExtend,onChange:e=>t(`dedupExtend`,e)}),(0,V.jsx)(W,{className:`items-end pb-2`,label:`replace duplicate`,checked:e.dedupReplace,onChange:e=>t(`dedupReplace`,e)})]})]}),(0,V.jsxs)(`div`,{className:`col-span-2`,children:[(0,V.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wider text-faint`,children:`Spawned-job options`}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-5`,children:[(0,V.jsx)(U,{label:`Max attempts`,name:`cron-job-max-attempts`,value:e.jobMaxAttempts,min:1,max:1e3,placeholder:`3`,onChange:e=>t(`jobMaxAttempts`,e)}),(0,V.jsx)(U,{label:`Backoff (ms)`,name:`cron-job-backoff`,value:e.jobBackoff,min:0,max:M,placeholder:`1000`,onChange:e=>t(`jobBackoff`,e)}),(0,V.jsx)(U,{label:`Timeout (ms)`,name:`cron-job-timeout`,value:e.jobTimeout,min:0,max:M,placeholder:`—`,onChange:e=>t(`jobTimeout`,e)}),(0,V.jsx)(U,{label:`Delay (ms)`,name:`cron-job-delay`,value:e.jobDelay,min:0,max:j,placeholder:`0`,onChange:e=>t(`jobDelay`,e)}),(0,V.jsx)(U,{label:`Stall timeout (ms)`,name:`cron-job-stall-timeout`,value:e.jobStallTimeout,min:0,max:M,placeholder:`server default`,onChange:e=>t(`jobStallTimeout`,e)})]}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-6`,children:[(0,V.jsx)(W,{label:`remove on complete`,controlLabel:`remove spawned jobs on complete`,checked:e.jobRemoveOnComplete,onChange:e=>t(`jobRemoveOnComplete`,e)}),(0,V.jsx)(W,{label:`remove on fail`,controlLabel:`remove spawned jobs on fail`,checked:e.jobRemoveOnFail,onChange:e=>t(`jobRemoveOnFail`,e)})]})]})]})}function U({label:e,name:t,value:n,min:r,max:i,placeholder:a,onChange:o}){return(0,V.jsx)(w,{label:e,children:(0,V.jsx)(S,{type:`number`,min:r,max:i,step:1,name:t,value:n,onChange:e=>o(e.target.value),placeholder:a})})}function W({label:e,controlLabel:t=e,checked:n,onChange:r,className:i=`items-center`}){return(0,V.jsxs)(`div`,{className:`flex gap-2 ${i}`,children:[(0,V.jsx)(C,{checked:n,onChange:r,label:t}),(0,V.jsx)(`span`,{className:`text-sm text-muted`,children:e})]})}var G=[``,`jan`,`feb`,`mar`,`apr`,`may`,`jun`,`jul`,`aug`,`sep`,`oct`,`nov`,`dec`],K=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`];function q(e,t,n,r){let i=e===`*`||/^\*\/\d+$/.test(e),a=new Set;for(let i of e.split(`,`)){let e=i.trim().toLowerCase();if(e===``)return null;let o=e.match(/^(.+)\/(\d+)$/),s=o?Number(o[2]):1,c=o?o[1]:e;if(s<1)return null;let l,u;if(c===`*`)l=t,u=n;else if(c.includes(`-`)){let[e,t]=c.split(`-`),n=J(e,r),i=J(t,r);if(n==null||i==null)return null;l=n,u=i}else{let e=J(c,r);if(e==null)return null;l=e,u=o?n:e}if(l<t||u>n||l>u)return null;for(let e=l;e<=u;e+=s)a.add(e)}return a.size?{values:a,star:i}:null}function J(e,t){let n=e.trim().toLowerCase();if(n===``)return null;if(t){let e=t.indexOf(n.slice(0,3));if(e!==-1)return e}return/^\d+$/.test(n)?Number(n):null}function Y(e,t,n){let r=e.trim().split(/\s+/);if(r.length!==5)return{valid:!1,error:`Expected 5 fields (min hour day month weekday), got ${r.length}.`,runs:[]};let i=q(r[0],0,59),a=q(r[1],0,23),o=q(r[2],1,31),s=q(r[3],1,12,G),c=q(r[4],0,7,K);if(!i||!a||!o||!s||!c)return{valid:!1,error:`Invalid field syntax.`,runs:[]};let l=new Set;for(let e of c.values)l.add(e===7?0:e);let u={values:l,star:c.star},d=e=>{let t=o.values.has(e.getDate()),n=u.values.has(e.getDay());return o.star||u.star?t&&n:t||n},f=[],p=new Date(n);p.setSeconds(0,0),p.setMinutes(p.getMinutes()+1);let m=n+5*366*864e5;for(let e=0;e<22e5&&f.length<t&&!(p.getTime()>m);e++){if(!s.values.has(p.getMonth()+1)){p.setMonth(p.getMonth()+1,1),p.setHours(0,0,0,0);continue}if(!d(p)){p.setDate(p.getDate()+1),p.setHours(0,0,0,0);continue}if(!a.values.has(p.getHours())){p.setHours(p.getHours()+1,0,0,0);continue}if(!i.values.has(p.getMinutes())){p.setMinutes(p.getMinutes()+1,0,0);continue}f.push(p.getTime()),p.setMinutes(p.getMinutes()+1,0,0)}return{valid:!0,runs:f}}function X({values:e,setValue:n}){let r=e.mode===`cron`&&e.schedule.trim()?Y(e.schedule.trim(),3,Date.now()):null,i=R(e.every);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsx)(w,{label:`Name`,children:(0,V.jsx)(S,{name:`cron-name`,autoComplete:`off`,maxLength:256,value:e.name,onChange:e=>n(`name`,e.target.value),placeholder:`daily-report`})}),(0,V.jsx)(w,{label:`Queue`,children:(0,V.jsx)(S,{name:`cron-queue`,autoComplete:`off`,maxLength:256,value:e.queue,onChange:e=>n(`queue`,e.target.value),placeholder:`reports`})}),(0,V.jsx)(w,{label:`Spawned job name`,hint:`First-class worker routing name; separate from schedule data.`,children:(0,V.jsx)(S,{name:`cron-job-name`,autoComplete:`off`,maxLength:256,value:e.jobName,onChange:e=>n(`jobName`,e.target.value),placeholder:`default`})})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{className:`sr-only`,children:`Schedule type`}),(0,V.jsx)(x,{options:[`cron`,`every`],value:e.mode,onChange:e=>n(`mode`,e)})]}),e.mode===`cron`?(0,V.jsx)(`div`,{className:`min-w-56 flex-1`,children:(0,V.jsx)(w,{label:`Cron expression`,children:(0,V.jsx)(S,{name:`cron-expression`,value:e.schedule,onChange:e=>n(`schedule`,e.target.value),placeholder:`0 9 * * *`})})}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`w-40`,children:(0,V.jsx)(w,{label:`Every (ms)`,children:(0,V.jsx)(S,{type:`number`,min:1,max:j,step:1,name:`cron-interval`,value:e.every,onChange:e=>n(`every`,e.target.value),placeholder:`30000`})})}),e.every.trim()!==``&&(0,V.jsx)(`span`,{className:t(`pb-2 text-xs`,i?`text-muted`:`text-danger`),children:i??`not a valid interval`})]})]}),e.mode===`cron`&&e.schedule.trim()&&r&&(0,V.jsx)(`div`,{className:`rounded-lg border border-line bg-surface-2 px-3 py-2 text-xs`,children:r.valid?r.runs.length?(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,V.jsxs)(`span`,{className:`text-faint`,children:[`Next runs`,e.timezone.trim()?` (local)`:``,`:`]}),r.runs.map(e=>(0,V.jsx)(`span`,{className:`font-mono text-muted`,children:y(e)},e)),e.timezone.trim()&&(0,V.jsxs)(`span`,{className:`text-faint`,children:[`— server evaluates in `,e.timezone.trim()]})]}):(0,V.jsx)(`span`,{className:`text-warning`,children:`Valid, but no runs in the next few years.`}):(0,V.jsxs)(`span`,{className:`text-warning`,children:[`Preview unavailable: `,r.error,` Bunqueue will validate this expression when you create the schedule.`]})}),(0,V.jsx)(w,{label:`Data (JSON)`,children:(0,V.jsx)(`textarea`,{name:`cron-data`,value:e.dataText,onChange:e=>n(`dataText`,e.target.value),maxLength:O,rows:3,spellCheck:!1,className:`w-full rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-sm text-fg placeholder:text-faint transition-colors focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})})]})}function Z(e){let[t,n]=(0,A.useState)(0);return(0,A.useEffect)(()=>{t>e-1&&n(e-1)},[t,e]),[Math.min(t,e-1),n]}function Q(e){let[t,n]=(0,A.useState)(!1),r=(0,A.useRef)(null),i=()=>{r.current&&clearTimeout(r.current),r.current=null};return(0,A.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]),{on:t,fire:()=>{i(),n(!0),r.current=setTimeout(()=>n(!1),e)},reset:()=>{i(),n(!1)}}}var $={name:``,jobName:`default`,queue:``,mode:`cron`,schedule:``,every:``,dataText:`{}`,timezone:``,priority:``,preventOverlap:!0,skipIfNoWorker:!1,maxLimit:``,immediately:!1,skipMissedOnRestart:!0,uniqueKey:``,dedupTtl:``,dedupExtend:!1,dedupReplace:!1,jobMaxAttempts:``,jobBackoff:``,jobTimeout:``,jobDelay:``,jobStallTimeout:``,jobRemoveOnComplete:!1,jobRemoveOnFail:!1};function ee({onCreate:e,onAccepted:t,beginCreate:n,scopeKey:r,existingNames:i}){let[a,s]=(0,A.useState)($),[c,l]=(0,A.useState)(!1),[u,f]=(0,A.useState)(null),[p,m]=(0,A.useState)(!1),{on:h,fire:g,reset:_}=Q(3e3),v=(e,t)=>s(n=>({...n,[e]:t}));(0,A.useEffect)(()=>{m(!1),f(null),_()},[r]);let y=I(a.name,i),b=async()=>{f(null),_();let r=B(a);if(!r.ok){f(r.msg);return}let c=I(r.body.name,i);if(c){f(c);return}if(!window.confirm(`Submit an upsert for cron "${r.body.name}"? Bunqueue v2.8.59 has no atomic create-only condition. The dashboard will recheck immediately before writing, but another client using the same name at the same time could still be replaced. Continue only if you authorize last-writer-wins behavior for this globally unique name.`))return;let l=n(r.body.name);if(l){m(!0);try{if(P(await e(r.body,l.isCurrent),r.body),!l.isCurrent())return;s(e=>({...e,name:``,schedule:``,every:``})),g(),o.success(`Cron upsert acknowledged`,r.body.name),t()}catch(e){l.isCurrent()&&f(e.message)}finally{l.finish()&&m(!1)}}};return(0,V.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,V.jsx)(X,{values:a,setValue:v}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,"aria-controls":`cron-advanced-options`,className:`text-xs font-medium text-muted hover:text-fg`,children:c?`− Hide advanced`:`+ Advanced options`}),c&&(0,V.jsx)(H,{values:a,setValue:v})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(d,{type:`submit`,variant:`accent`,size:`sm`,disabled:p||!!y,children:p?`Saving…`:y?`Name already exists`:`Submit upsert`}),y&&!u&&(0,V.jsx)(`span`,{role:`alert`,className:`max-w-2xl text-xs text-warning`,children:y}),u&&(0,V.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:u}),h&&(0,V.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Cron upsert acknowledged ✓`})]}),(0,V.jsx)(`p`,{className:`text-xs text-warning`,children:`Creation is an upstream upsert, not an atomic create-only operation. Use a globally unique name; the fail-closed preflight cannot eliminate a simultaneous write from another client.`})]})}function te({crons:e,page:t,removing:n,onPageChange:r,onRemove:i}){let a=e.slice(t*15,t*15+15);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,V.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,V.jsx)(`thead`,{children:(0,V.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,V.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Name`}),(0,V.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Queue`}),(0,V.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job name`}),(0,V.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Schedule`}),(0,V.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Next Run`}),(0,V.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Runs`}),(0,V.jsx)(`th`,{scope:`col`,className:`w-12 px-5 py-3`})]})}),(0,V.jsx)(`tbody`,{children:a.map(e=>(0,V.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,V.jsx)(`td`,{className:`px-5 py-3 font-medium text-fg`,children:e.name}),(0,V.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,V.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.jobName??`default`}),(0,V.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)}),(0,V.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:y(e.nextRun)}),(0,V.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.executions)}),(0,V.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,V.jsx)(u,{"aria-label":`Delete cron ${e.name}`,disabled:n.has(e.name),onClick:()=>i(e.name),children:(0,V.jsx)(s,{className:`size-3.5`})})})]},e.name))})]})}),(0,V.jsx)(T,{page:t,pageSize:15,total:e.length,onPageChange:r,label:`crons`})]})}function ne(){let{data:e,error:t,loading:n,refetch:r}=l(()=>a.crons(),[]),i=e?.crons??[],s=(0,A.useMemo)(()=>new Set(i.map(e=>e.name)),[i]),[u,d]=Z(Math.max(1,Math.ceil(i.length/15))),[y,b]=(0,A.useState)(null),[x,S]=(0,A.useState)(new Set),C=E(`cron-manager`);(0,A.useEffect)(()=>{b(null),S(new Set)},[C.scopeKey]);let w=async e=>{if(!window.confirm(`Delete cron "${e}"? It will not be recreated automatically; creating a replacement is a separate action.`))return;let t=C.begin(`cron:${e}`);if(t){b(null),S(t=>new Set(t).add(e));try{if(N(await a.deleteCron(e)),!t.isCurrent())return;o.success(`Cron deleted`,e),r()}catch(e){if(!t.isCurrent())return;b(e.message),o.error(`Delete cron failed`,e.message)}finally{t.finish()&&S(t=>{let n=new Set(t);return n.delete(e),n})}}};return(0,V.jsxs)(`div`,{children:[t&&e&&(0,V.jsx)(m,{message:`Cron refresh failed — showing the last successful schedule list.`,onRetry:r}),(0,V.jsx)(v,{title:`Cron Manager`,description:`Submit explicitly acknowledged schedule upserts and manage repeatable jobs.`,live:!!e&&!t}),y&&(0,V.jsx)(`div`,{role:`status`,className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:y}),(0,V.jsxs)(p,{className:`mb-6`,children:[(0,V.jsx)(f,{title:`Create schedule via upstream upsert`}),(0,V.jsx)(ee,{existingNames:s,onCreate:async(e,t)=>{let n=await a.crons();if(!t())throw Error(`Cron creation target changed during preflight`);return L(n,e.name),a.createCron(e)},onAccepted:r,beginCreate:e=>C.begin(`cron:${e}`),scopeKey:C.scopeKey})]}),t&&!e?(0,V.jsx)(h,{error:t,onRetry:r}):n&&!e?(0,V.jsx)(g,{label:`Loading crons…`}):i.length===0?(0,V.jsx)(_,{icon:(0,V.jsx)(c,{}),title:`No scheduled jobs`,hint:`Submit one above.`}):(0,V.jsx)(te,{crons:i,page:u,removing:x,onPageChange:d,onRemove:e=>void w(e)})]})}export{ne as CronManager};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{t as r}from"./bq-DYmbVkgR.js";import{t as i}from"./toastStore-B7n0zS0y.js";import{t as a}from"./api-V_sVpHDo.js";import{n as o}from"./usePolledData-c53tx1jw.js";import{t as s}from"./Button-BPqpRZJD.js";import{n as c,t as l}from"./Card-C7NMhqUt.js";import{i as u,r as d}from"./feedback-BnGE2oW2.js";import{n as f}from"./StatusBadge-B0I7hNBX.js";import{t as p}from"./PageHeader-BXlZSBcc.js";import{n as m,s as h,u as g}from"./format-Cg7VCIZW.js";import{a as _,n as v}from"./index-D64v2vNO.js";var y=e(t(),1),b=n();function x(e,t){return t?{label:`Unavailable`,tone:`red`,detail:t}:e===null?{label:`Unknown`,tone:`zinc`,detail:`No response yet`}:e.trim()===`OK`?{label:`Live`,tone:`green`,detail:`HTTP 200 · OK`}:{label:`Unexpected`,tone:`amber`,detail:`HTTP 200 · ${e.trim().slice(0,80)||`empty body`}`}}function S(e,t){return t?{label:`Unavailable`,tone:`red`,detail:t}:e?e.ok===!0&&e.ready===!0?{label:`Ready`,tone:`green`,detail:`Persistence accepts traffic`}:e.ok===!1&&e.ready===!1?{label:`Not ready`,tone:`red`,detail:e.storage.error??`Persistence is degraded`}:{label:`Unexpected`,tone:`amber`,detail:`Incoherent readiness payload`}:{label:`Unknown`,tone:`zinc`,detail:`No response yet`}}function C({path:e,state:t}){return(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 border-b border-line py-2.5 last:border-0`,children:[(0,b.jsx)(`code`,{className:`w-20 shrink-0 font-mono text-xs text-fg`,children:e}),(0,b.jsx)(f,{label:t.label,tone:t.tone}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 text-right text-xs text-faint`,children:t.detail})]})}function w({snapshot:e}){let t=e.metrics?.metrics;return(0,b.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`Orchestrator probes`}),(0,b.jsx)(`p`,{className:`mb-2 text-xs text-muted`,children:`Native Bunqueue liveness and persistence-readiness endpoints.`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(C,{path:`/healthz`,state:x(e.healthz,e.healthzError)}),(0,b.jsx)(C,{path:`/live`,state:x(e.live,e.liveError)}),(0,b.jsx)(C,{path:`/ready`,state:S(e.ready,e.readyError)})]})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`JSON metrics`}),e.metricsError?(0,b.jsxs)(`p`,{className:`text-sm text-danger`,children:[`Unavailable — `,e.metricsError]}):t?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,b.jsx)(O,{k:`Pushed`,v:h(t.totalPushed)}),(0,b.jsx)(O,{k:`Pulled`,v:h(t.totalPulled)}),(0,b.jsx)(O,{k:`Completed`,v:h(t.totalCompleted)}),(0,b.jsx)(O,{k:`Failed`,v:h(t.totalFailed)})]}):(0,b.jsx)(`p`,{className:`text-sm text-muted`,children:`No metrics response yet.`}),(0,b.jsx)(`p`,{className:`mt-3 font-mono text-xs text-faint`,children:`GET /metrics · application/json`})]})]})}function T({heap:e,busy:t,onLoad:n}){return(0,b.jsxs)(l,{className:`mt-6`,children:[(0,b.jsx)(c,{title:`Heap statistics`,action:(0,b.jsx)(s,{size:`sm`,disabled:t,onClick:n,children:t?`Loading…`:e?`Refresh`:`Load`})}),e?(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,b.jsx)(O,{k:`Objects`,v:h(e.heap?.objectCount??0)}),(0,b.jsx)(O,{k:`Protected`,v:h(e.heap?.protectedCount??0)}),(0,b.jsx)(O,{k:`Global`,v:h(e.heap?.globalCount??0)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wider text-faint`,children:`Top object types`}),(0,b.jsx)(`div`,{className:`max-h-52 overflow-y-auto rounded-lg border border-line`,children:(0,b.jsx)(`table`,{className:`w-full text-xs`,children:(0,b.jsx)(`tbody`,{children:(e.topObjectTypes??[]).map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,b.jsx)(`td`,{className:`px-3 py-1.5 font-mono text-muted`,children:e.type}),(0,b.jsx)(`td`,{className:`px-3 py-1.5 text-right tnum text-fg`,children:h(e.count)})]},e.type))})})})]})]}):(0,b.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On-demand `,(0,b.jsx)(`code`,{className:`font-mono text-xs`,children:`bun:jsc`}),` heap breakdown (forces a GC first). Use it to spot which internal object type is growing when chasing a leak.`]})]})}function E(){let e=r.prometheusUrl();return(0,b.jsxs)(l,{className:`mt-6`,children:[(0,b.jsx)(c,{title:`Prometheus`}),(0,b.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Scrape endpoint (text exposition) for Grafana / Alertmanager. Auth is required only if the server sets `,(0,b.jsx)(`code`,{className:`font-mono text-xs`,children:`requireAuthForMetrics`}),`.`]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-line bg-surface-2 px-3 py-2`,children:[(0,b.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-fg`,children:e}),(0,b.jsx)(_,{value:e})]})]})}function D({stats:e}){return e?(0,b.jsxs)(l,{className:`mt-6`,children:[(0,b.jsx)(c,{title:`Totals since restart`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsx)(O,{k:`Pushed`,v:h(e.totalPushed)}),(0,b.jsx)(O,{k:`Pulled`,v:h(e.totalPulled)}),(0,b.jsx)(O,{k:`Completed`,v:h(e.totalCompleted)}),(0,b.jsx)(O,{k:`Failed`,v:h(e.totalFailed)})]})]}):null}function O({k:e,v:t}){return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,b.jsx)(`div`,{className:`mt-1 text-lg font-semibold tnum text-fg`,children:t})]})}async function k(e){try{return{value:await e,error:null}}catch(e){return{value:null,error:e instanceof Error?e.message:String(e)}}}function A(){let{data:e,error:t,loading:n,refetch:f}=o(async()=>{let[e,t,n,i,o,s,c]=await Promise.all([k(r.health()),k(r.storage()),k(r.stats()),k(a.healthz()),k(a.live()),k(a.ready()),k(a.metrics())]);return{health:e.value,storage:t.value,stats:n.value,healthError:e.error,storageError:t.error,statsError:n.error,healthz:i.value,live:o.value,ready:s.value,metrics:c.value,healthzError:i.error,liveError:o.error,readyError:s.error,metricsError:c.error}},[]),[h,_]=(0,y.useState)(null),x=(0,y.useRef)(0),S=async()=>{let e=++x.current;_(`…`);let t=performance.now();try{await r.ping(),e===x.current&&_(`${Math.round(performance.now()-t)} ms`)}catch{e===x.current&&_(`unreachable`)}},[C,A]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),P=async()=>{A(!0),N(null);try{let e=await r.gc(),t=e.before.rss-e.after.rss,n=t>0?`Freed ${t} MB (RSS ${e.before.rss}→${e.after.rss})`:`No memory reclaimed`;N(n),i.success(`Memory compacted`,n),f()}catch(e){i.error(`GC failed`,e.message),N(e.message)}finally{A(!1)}},[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(!1),z=async()=>{R(!0);try{I(await r.heapStats())}catch(e){i.error(`Heap stats failed`,e.message)}finally{R(!1)}};if(n&&!e&&!t)return(0,b.jsx)(d,{label:`Loading diagnostics…`});let B=e??{health:null,storage:null,stats:null,healthError:null,storageError:null,statsError:null,healthz:null,live:null,ready:null,metrics:null,healthzError:null,liveError:null,readyError:null,metricsError:null},V=B.health,H=B.storage?.data,U=B.stats?.stats,W=V!=null,G=H!=null,K=W&&V.ok===!0,q=!!t||!!B.healthError||!!B.storageError||!!B.statsError||!!B.healthzError||!!B.liveError||!!B.readyError||!!B.metricsError;return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Diagnostics`,description:`Server health, storage, memory and connections.`,live:!!e&&!q}),t&&(0,b.jsx)(u,{message:`Diagnostics refresh failed — ${t.message}`,onRetry:f}),B.healthError&&(0,b.jsx)(u,{message:`Health unavailable — ${B.healthError}`,onRetry:f}),B.storageError&&(0,b.jsx)(u,{message:`Storage diagnostics unavailable — ${B.storageError}`,onRetry:f}),B.statsError&&(0,b.jsx)(u,{message:`Server totals unavailable — ${B.statsError}`,onRetry:f}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsx)(v,{label:`Status`,value:W?V.status??(V.ok?`healthy`:`degraded`):`Unavailable`,tone:K?`green`:`red`,compact:!0}),(0,b.jsx)(v,{label:`Version`,value:V?.version?`v${V.version}`:`—`,compact:!0}),(0,b.jsx)(v,{label:`Uptime`,value:g(V?.uptime),compact:!0}),(0,b.jsx)(v,{label:`Disk`,value:G?H.diskFull?`Full`:`Healthy`:`Unavailable`,tone:!G||H.diskFull?`red`:`green`,compact:!0})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`Connectivity`,action:(0,b.jsxs)(s,{size:`sm`,onClick:S,children:[`Ping`,h?` · ${h}`:``]})}),(0,b.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,b.jsx)(j,{k:`WebSocket clients`,v:V?.connections?.ws==null?`—`:String(V.connections.ws)}),(0,b.jsx)(j,{k:`SSE clients`,v:V?.connections?.sse==null?`—`:String(V.connections.sse)}),(0,b.jsx)(j,{k:`Storage error`,v:B.storageError?`unavailable — ${B.storageError}`:H?.error?String(H.error):G?`none`:`—`})]})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(c,{title:`Memory`,action:(0,b.jsx)(s,{size:`sm`,disabled:C,onClick:P,children:C?`Compacting…`:`Compact (GC)`})}),(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,b.jsx)(O,{k:`Heap used`,v:V?.memory?m(V.memory.heapUsed*1024*1024):`—`}),(0,b.jsx)(O,{k:`Heap total`,v:V?.memory?m(V.memory.heapTotal*1024*1024):`—`}),(0,b.jsx)(O,{k:`RSS`,v:V?.memory?m(V.memory.rss*1024*1024):`—`})]}),M&&(0,b.jsx)(`p`,{className:`mt-3 text-xs text-muted`,children:M})]})]}),(0,b.jsx)(w,{snapshot:B}),(0,b.jsx)(T,{heap:F,busy:L,onLoad:z}),(0,b.jsx)(E,{}),(0,b.jsx)(D,{stats:U})]})}function j({k:e,v:t}){return(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,b.jsx)(`dt`,{className:`text-muted`,children:e}),(0,b.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}export{A as Diagnostics};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CyjgmGTq.js";import{i as o,o as s}from"./connectionStore-CKFQrxDo.js";import{i as c}from"./upstreamPaths-CDVsu6IM.js";import{a as l,c as u,l as d,o as f}from"./bq-DYmbVkgR.js";import{t as p}from"./Card-C7NMhqUt.js";import{i as m,n as h,r as g}from"./feedback-BnGE2oW2.js";import{t as _}from"./PageHeader-BXlZSBcc.js";import{i as v}from"./index-D64v2vNO.js";import{n as y,t as b}from"./controlConnectionEpoch-JM4omZ6j.js";var x={nodeWidth:168,nodeHeight:60},S=`flow-order-9a3f`,C={completed:`border-success/50 bg-success/10 text-success`,failed:`border-danger/50 bg-danger/10 text-danger`,active:`border-blue-400/60 bg-blue-400/10 text-blue-400`,delayed:`border-accent/50 bg-accent/10 text-accent`,waiting:`border-warning/50 bg-warning/10 text-warning`,prioritized:`border-warning/50 bg-warning/10 text-warning`,"waiting-children":`border-cyan-400/60 bg-cyan-400/10 text-cyan-400`},w=e=>e&&C[e]||`border-line bg-surface-2 text-muted`,T=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,E=class extends Error{constructor(e,t){super(e,t),this.name=`FlowSnapshotError`}};function D(e,t,n){if(!Array.isArray(e)||e.some(e=>typeof e!=`string`||c(e)!==null))throw new E(`Job ${n} returned an invalid ${t} list`);return e}function O(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new E(`GET /jobs/${t} returned an invalid response`);let n=e;if(n.ok!==!0)throw new E(`GET /jobs/${t} returned an invalid success envelope`);let r=n.job;if(typeof r!=`object`||!r||Array.isArray(r))throw new E(`GET /jobs/${t} returned no job snapshot`);let i=r;if(i.id!==t)throw new E(`GET /jobs/${t} returned the wrong job id (${String(i.id)})`);if(typeof i.queue!=`string`||i.queue.length===0)throw new E(`Job ${t} returned an invalid queue`);if(typeof i.state!=`string`||i.state.length===0)throw new E(`Job ${t} returned an invalid state`);if(!Object.hasOwn(i,`parentId`)||i.parentId!==null&&(typeof i.parentId!=`string`||c(i.parentId)!==null))throw new E(`Job ${t} returned an invalid parentId`);return{...r,parentId:i.parentId,childrenIds:D(i.childrenIds,`childrenIds`,t),dependsOn:D(i.dependsOn,`dependsOn`,t)}}async function k(e,t,n){n?.throwIfAborted();let r=await d(e,t,n);return n?.throwIfAborted(),O(r,t)}function A(e){let t=c(e);return t?`Job ID: ${t}`:null}async function ee(e,t={}){let n=A(e);if(n)throw new E(n);let r=t.target??u(),{signal:i}=t,a=e,o=new Set([e]),s=[];for(let e=0;;e++){i?.throwIfAborted();let t;try{t=await k(r,a,i)}catch(t){if(i?.throwIfAborted(),e===0)throw t;if(t instanceof l&&t.status===404){let e=s.at(-1);if(!e)throw t;return{id:e.id,job:e,hops:Math.max(0,s.length-1),path:s,missingParent:a}}throw new E(`Could not resolve the flow root because parent ${a} could not be loaded: ${t instanceof Error?t.message:String(t)}`,{cause:t})}s.push(t);let n=t.parentId;if(!n)return{id:a,job:t,hops:e,path:s};if(o.has(n))throw new E(`Flow parent cycle detected at job ${n}`);if(e>=100)throw new E(`Flow parent chain exceeds the Bunqueue 2.8.59 limit of 100 levels`);o.add(n),a=n}}function j(e,t){let n=new Set(e),r=new Map(e.map(e=>[e,[]]));for(let e of t)n.has(e.from)&&n.has(e.to)&&r.get(e.from)?.push(e.to);let i=new Map,a=[],o=e=>{i.set(e,1),a.push(e);for(let t of r.get(e)??[]){if(i.get(t)===1){let e=a.lastIndexOf(t);return[...a.slice(Math.max(0,e)),t]}if(i.get(t)!==2){let e=o(t);if(e)return e}}return a.pop(),i.set(e,2),null};for(let t of e)if(!i.has(t)){let e=o(t);if(e)return e}return null}var te=[`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`];function M(e){return te.filter(t=>e[t]===!0)}function N(e,t){if(e?.parentId!==t)return null;let n=M(e);return n.length===1?n[0]===`continueParentOnFailure`?{scope:`parent`,policy:`continueParentOnFailure`}:n[0]===`removeDependencyOnFailure`?{scope:`child`,policy:`removeDependencyOnFailure`}:n[0]===`ignoreDependencyOnFailure`?{scope:`child`,policy:`ignoreDependencyOnFailure`}:null:null}async function ne(e,t,n={}){let r=A(e);if(r)throw new E(r);let i=n.target??u(),{signal:a}=n,o=new Map,s=[],c=[],l=new Set,d=new Set,f=new Map,p=new Set,m=new Set,h=new Set(n.limitations??[]),g=[{id:e,depth:0}],_=new Set([e]),v=new Map;t&&v.set(e,O({ok:!0,job:t},e));let y=[...n.seedPath??[]].reverse(),b=!1;if(y.length>0&&y[0]?.id!==e)throw new E(`Resolved seed path does not start at the requested flow root`);for(let[e,t]of y.entries()){let n=O({ok:!0,job:t},t.id);if(v.set(n.id,n),e!==0){if(e>100||_.size>=500){b=!0;continue}_.has(n.id)||(_.add(n.id),g.push({id:n.id,depth:e}))}}let x=new Set,S=b;for(;g.length;){a?.throwIfAborted();let{id:t,depth:n}=g.shift();if(x.has(t))continue;x.add(t);let r=null;try{r=v.get(t)??await k(i,t,a)}catch(n){if(a?.throwIfAborted(),t===e)throw n;f.set(t,n instanceof Error?n.message:String(n))}if(o.set(t,r??{id:t,state:`unknown`}),!r)continue;if(n>=100){(r.childrenIds?.length??0)+(r.dependsOn?.length??0)>0&&(S=!0);continue}let u=e=>_.has(e)?!0:_.size>=500?(S=!0,!1):(_.add(e),g.push({id:e,depth:n+1}),!0),m=(e,t,n,r)=>{if(!u(r))return;let i=`${e}->${t}:${n}`;l.has(i)||(l.add(i),s.push({from:e,to:t,kind:n}))},h=r.childrenIds??[],y=r.dependsOn??[],b=new Set(h),C=new Set(y);b.size!==h.length&&p.add(`Job ${t} lists a child more than once`),C.size!==y.length&&p.add(`Job ${t} lists a dependency more than once`);for(let e of h)m(t,e,`child`,e);for(let e of y)if(u(e)){let n=`${e}->${t}`;d.has(n)||(d.add(n),c.push({from:e,to:t,kind:`depends`})),b.has(e)||m(e,t,`depends`,e)}}for(let[e,t]of o)!f.has(e)&&M(t).length>1&&p.add(`Job ${e} enables mutually exclusive failure policies`);for(let e of s){if(e.kind!==`child`||f.has(e.to))continue;let t=o.get(e.to);t&&t.parentId!==e.from&&p.add(`Child ${e.to} points to parent ${String(t.parentId??`none`)}, not ${e.from}`)}for(let[e,t]of o){if(f.has(e))continue;let n=t.childrenIds??[];if(n.some(e=>!o.has(e)||f.has(e)))continue;let r=n.map(t=>({childId:t,release:N(o.get(t),e)})).find(({release:e})=>e?.scope===`parent`);for(let i of n){if(t.dependsOn?.includes(i))continue;if(r?.release?.scope===`parent`){m.add(`Parent ${e} is missing dependency ${i}; ${r.release.policy} on child ${r.childId} may have released all parent dependencies, but the HTTP snapshot cannot prove whether the policy fired`);continue}let n=N(o.get(i),e);if(n?.scope===`child`){m.add(`Parent ${e} is missing dependency ${i}; ${n.policy} may have released it, but the HTTP snapshot cannot prove whether the policy fired`);continue}p.add(`Parent ${e} lists child ${i} without the matching dependency`)}}for(let[e,t]of o){if(f.has(e)||!t.parentId)continue;let n=o.get(t.parentId);!n||f.has(t.parentId)||n.childrenIds?.includes(e)||p.add(`Parent ${t.parentId} does not list child ${e}`)}let C=j([...o.keys()],c);return{jobs:o,edges:s,truncated:S,failed:f.size,failures:f,issues:[...p],policyNotes:[...m],cycle:C,limitations:[...h]}}var re=`bq-dash-recent-flows`,P=8;function F(e){return`${re}:${encodeURIComponent(e.trim()||`/api`)}`}function I(e,t){if(!t)return[];try{let t=JSON.parse(localStorage.getItem(F(e))??`[]`);return Array.isArray(t)?t.filter(e=>typeof e?.root==`string`&&e.root.length>0&&e.root.length<=1024&&Number.isSafeInteger(e?.nodes)&&e.nodes>1&&e.nodes<=500&&Number.isFinite(e?.at)&&e.at>=0).slice(0,P):[]}catch{return[]}}function ie(e,t,n,r){let i=[n,...t.filter(e=>e.root!==n.root)].slice(0,P);if(!r)return i;try{localStorage.setItem(F(e),JSON.stringify(i))}catch{}return i}var L=e(r(),1),ae=new Set([`explore`,`create`,`operations`]);function R(e,t=``){let n=e.get(`root`),r=ce(n)?n:t,i=e.get(`mode`),a=ae.has(i)?i:`explore`,o=e.get(`node`);return{root:r,mode:a,node:r&&ce(o)?o:null}}function oe(e){let t=new URLSearchParams;return e.root&&t.set(`root`,e.root),e.mode!==`explore`&&t.set(`mode`,e.mode),e.root&&e.node&&t.set(`node`,e.node),t}function se(e,t,n=``){return oe({...R(e,n),...t})}function ce(e){return!!(e&&A(e)===null)}function le(){let[e,t]=n(),r=v()?S:``,i=e.toString(),a=(0,L.useMemo)(()=>R(new URLSearchParams(i),r),[r,i]),c=a.root,l=s(e=>e.baseUrl),d=s(e=>e.token),f=o(),[p,m]=(0,L.useState)(c),[h,g]=(0,L.useState)(null),[_,y]=(0,L.useState)(!!c),[b,x]=(0,L.useState)(null),[C,w]=(0,L.useState)(()=>I(f,d.length===0)),T=(0,L.useRef)(0),D=(0,L.useRef)(null),O=(0,L.useRef)(!1),k=(0,L.useRef)(z()),j=h?.seed===c?h.graph:null,te=j?a.node&&j.jobs.has(a.node)?a.node:h?.defaultSelected??null:null,M=(0,L.useCallback)((e,n=!1)=>{t(t=>se(t,e,r),{replace:n})},[r,t]),N=(0,L.useCallback)(async e=>{let t=s.getState();if(t.baseUrl!==l||t.token!==d)return;D.current?.abort(),D.current=null;let n=++T.current,r=e.trim();if(g(null),x(null),!r)return y(!1);let i=A(r);if(i)return x(new E(i)),y(!1);let a=u(),o=z(),c=new AbortController;D.current=c;let f=()=>O.current&&n===T.current&&!c.signal.aborted&&o===z();y(!0);try{let e={target:a,signal:c.signal},t=await ee(r,e),n=t.missingParent?[`Ancestor ${t.missingParent} is no longer available. The graph starts at the oldest surviving node.`]:[],i=await ne(t.id,t.job,{...e,seedPath:t.path,limitations:n});if(!f())return;g({seed:r,graph:i,defaultSelected:t.id}),i.jobs.size>1&&w(e=>ie(a.baseUrl,e,{root:t.id,nodes:i.jobs.size,at:Date.now()},s.getState().token.length===0))}catch(e){f()&&x(e instanceof Error?e:Error(`Failed to load flow`))}finally{D.current===c&&(D.current=null),f()&&y(!1)}},[l,d]);return(0,L.useEffect)(()=>{O.current=!0,k.current=z();let e=s.subscribe(()=>{let e=z();e!==k.current&&(k.current=e,T.current+=1,D.current?.abort(),D.current=null,O.current&&(g(null),x(null),y(!1)))});return()=>{O.current=!1,e(),T.current+=1,D.current?.abort()}},[]),(0,L.useEffect)(()=>w(d?[]:I(f,!0)),[f,d]),(0,L.useEffect)(()=>{let e={...a};j&&(!e.node||!j.jobs.has(e.node))&&(e.node=h?.defaultSelected??null);let n=oe(e).toString();n!==i&&t(n,{replace:!0})},[j,i,t,h?.defaultSelected,a]),(0,L.useEffect)(()=>{m(c),N(c)},[c,N]),{input:p,setInput:m,rootParam:c,mode:a.mode,setMode:e=>M({mode:e}),graph:j,selected:te,setSelected:e=>{j?.jobs.has(e)&&M({node:e})},loading:_,error:b,recent:C,load:N,submit:e=>{e.preventDefault();let t=p.trim();if(t){if(A(t))return void N(t);t===c?N(t):M({root:t,mode:`explore`,node:null})}},openRecent:e=>{if(m(e),A(e))return void N(e);let t=e===c;M({root:e,mode:`explore`,node:null}),t&&N(e)}}}function z(){let{token:e}=s.getState();return JSON.stringify([o(),e])}function ue(e){return e instanceof l&&e.status===0||[`TypeError`,`AbortError`,`TimeoutError`].includes(e.name)}var B=e=>({method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),de=new Set([`removeChildDependency`,`removeUnprocessedChildren`,`removeDeduplicationKey`,`retry`,`promote`,`remove`]),fe=e=>e+5e3,V={create:(e,t)=>f(`/flows/create?target=${encodeURIComponent(o())}`,B({operation:e,...t})),getFlow:e=>{let t=new URLSearchParams({id:e.id,queueName:e.queueName,target:o()});return e.depth!==void 0&&t.set(`depth`,String(e.depth)),e.maxChildren!==void 0&&t.set(`maxChildren`,String(e.maxChildren)),f(`/flows/tree?${t}`)},inspect:(e,t)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:o()})}`),getParentResult:e=>f(`/flows/results?target=${encodeURIComponent(o())}`,B({operation:`getParentResult`,parentId:e})),getParentResults:e=>f(`/flows/results?target=${encodeURIComponent(o())}`,B({operation:`getParentResults`,parentIds:e})),waitUntilFinished:(e,t)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/waitUntilFinished?${new URLSearchParams({queueName:e.queueName,target:o(),ttl:String(t)})}`,void 0,fe(t)),mutate:(e,t,n)=>f(`/flows/jobs/${encodeURIComponent(e.id)}/${t}?${new URLSearchParams({queueName:e.queueName,target:o()})}`,de.has(t)?{method:`POST`}:B(n??{}))},H=a();function U({value:e}){return(0,H.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-md border border-line bg-bg p-3 font-mono text-xs text-muted`,children:JSON.stringify(e,null,2)})}function W(...e){return JSON.stringify(e)}function G(e){let t=y(),n=(0,L.useMemo)(()=>({key:e,connectionEpoch:t}),[t,e]),r=(0,L.useRef)(n),i=(0,L.useRef)(void 0),a=(0,L.useRef)(void 0),o=(0,L.useRef)(0),s=(0,L.useRef)(!0),[c,l]=(0,L.useState)(),[u,d]=(0,L.useState)(),[f,p]=(0,L.useState)();return(0,L.useLayoutEffect)(()=>{r.current=n,i.current=void 0,a.current=void 0},[n]),(0,L.useEffect)(()=>(s.current=!0,()=>{s.current=!1,i.current=void 0,a.current=void 0}),[]),{busy:c?.identity===n?c.label:``,error:f?.identity===n?f.message:``,result:u?.identity===n?u.value:void 0,reject:e=>{b()===n.connectionEpoch&&(a.current=void 0,i.current=void 0,l(void 0),d(void 0),p({identity:n,message:e}))},run:async(e,t)=>{if(i.current?.identity===n||b()!==n.connectionEpoch)return;let c={id:++o.current,identity:n};i.current=c,a.current=c,l({...c,label:e}),d(void 0),p(void 0);try{let e=await t();s.current&&r.current===n&&b()===n.connectionEpoch&&a.current===c&&d({identity:n,value:e})}catch(e){s.current&&r.current===n&&b()===n.connectionEpoch&&a.current===c&&p({identity:n,message:pe(e)})}finally{i.current===c&&(i.current=void 0),s.current&&l(e=>e?.id===c.id?void 0:e)}}}}function pe(e){return e instanceof Error?e.message:String(e)}var K={add:{flow:{name:`aggregate`,queueName:`reports`,data:{},children:[{name:`fetch`,queueName:`io`,data:{source:`orders`}}]},options:{queuesOptions:{io:{attempts:3,backoff:1e3}}}},addBulk:{flows:[{name:`report-a`,queueName:`reports`,data:{region:`eu`}},{name:`report-b`,queueName:`reports`,data:{region:`us`}}]},addChain:{steps:[{name:`extract`,queueName:`pipeline`,data:{}},{name:`transform`,queueName:`pipeline`,data:{}},{name:`load`,queueName:`pipeline`,data:{}}]},addBulkThen:{parallel:[{name:`part-a`,queueName:`parallel`,data:{}},{name:`part-b`,queueName:`parallel`,data:{}}],final:{name:`merge`,queueName:`final`,data:{}}},addTree:{root:{name:`root`,queueName:`tree`,data:{},children:[{name:`child`,queueName:`tree`,data:{}}]}}};function me({repository:e=V,onOpen:t}){let[n,r]=(0,L.useState)(`add`),[i,a]=(0,L.useState)(()=>JSON.stringify(K.add,null,2)),o=G(W(n,i)),s=!!o.busy,c=e=>{r(e),a(JSON.stringify(K[e],null,2))},l=async t=>{t.preventDefault();let r;try{r=JSON.parse(i)}catch{return o.reject(`The definition must be valid JSON.`)}if(!r||typeof r!=`object`||Array.isArray(r))return o.reject(`The definition must be a JSON object.`);let a=n;await o.run(a,()=>e.create(a,r))},u=he(o.result);return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`form`,{onSubmit:l,className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`FlowProducer method`,(0,H.jsx)(`select`,{"aria-label":`FlowProducer method`,value:n,onChange:e=>c(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:Object.keys(K).map(e=>(0,H.jsx)(`option`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`submit`,disabled:s,className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:s?`Creating…`:`Run ${n}`})]}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Definition`,(0,H.jsx)(`textarea`,{"aria-label":`Flow definition JSON`,spellCheck:!1,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-80 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg outline-none focus:ring-2 focus:ring-accent/50`})]})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Atomic commit result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:`Validation is performed by Bunqueue before the graph is committed.`}),o.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:o.error}),o.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow created in this session.`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{value:o.result}),u&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(u),className:`mt-3 rounded-lg border border-line px-3 py-2 text-xs text-fg`,children:`Open created flow`})]})]})]})}function he(e){let t=e,n=t?.result?.root?.id??t?.result?.roots?.[0]?.id??t?.result?.finalId??t?.result?.jobIds?.at(-1);return typeof n==`string`?n:null}function ge({recent:e,onOpen:t}){return(0,H.jsx)(p,{children:(0,H.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID, or choose “View flow” from Job Inspector.`}),e.length>0&&(0,H.jsxs)(`div`,{className:`mt-6`,children:[(0,H.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,H.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:e.map(e=>(0,H.jsxs)(`button`,{type:`button`,title:e.root,onClick:()=>t(e.root),className:`min-h-10 rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted hover:text-fg`,children:[(0,H.jsx)(`span`,{translate:`no`,children:T(e.root)}),(0,H.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})})}function q({target:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Job ID`,(0,H.jsx)(`input`,{"aria-label":`Flow job ID`,value:e.id,onChange:n=>t({...e,id:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 font-mono text-sm text-fg`})]}),(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Queue name`,(0,H.jsx)(`input`,{"aria-label":`Flow queue name`,value:e.queueName,onChange:n=>t({...e,queueName:n.target.value}),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})]})}var _e=[`getChildrenValues`,`getDependencies`,`getDependenciesCount`,`getFailedChildrenValues`,`getIgnoredChildrenFailures`],ve=[{id:`removeChildDependency`,label:`Release dependency`,dangerous:!0},{id:`removeUnprocessedChildren`,label:`Remove unprocessed children`,dangerous:!0},{id:`retry`,label:`Retry job`},{id:`promote`,label:`Promote delayed job`},{id:`remove`,label:`Remove job`,dangerous:!0}];function ye({repository:e=V,initialTarget:t={id:``,queueName:``},target:n,onTargetChange:r,showTarget:i=!0}){let[a,o]=(0,L.useState)(t),s=n??a,c=r??o,l=G(W(s.id,s.queueName)),u=l.busy,d=!!(s.id.trim()&&s.queueName.trim()),f=t=>{let n=be(s);l.run(t,()=>e.inspect(n,t))},p=t=>{let n=be(s);window.confirm(`${t} on ${n.id} in ${n.queueName}? This changes durable queue state and has no compare-and-swap precondition.`)&&l.run(t,()=>e.mutate(n,t))};return(0,H.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(360px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Dependency control`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Run the official Flow Job dependency methods against the managed server TCP endpoint.`}),i&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:s,onChange:c})}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_e.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,onClick:()=>f(e),className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:e},e))}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Mutate`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ve.map(e=>(0,H.jsx)(`button`,{type:`button`,disabled:!d||!!u,onClick:()=>p(e.id),className:e.dangerous?`rounded-md border border-danger/40 px-2.5 py-1.5 text-xs text-danger disabled:opacity-40`:`rounded-md border border-line px-2.5 py-1.5 text-xs text-muted disabled:opacity-40`,children:e.label},e.id))})]}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Operation result`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:u?`Running ${u}…`:`The last authoritative broker response appears here.`}),l.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:l.error}),l.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Choose an inspection or mutation.`}):(0,H.jsx)(U,{value:l.result})]})]})}var be=e=>({id:e.id.trim(),queueName:e.queueName.trim()});function xe({repository:e=V,initialIds:t=``}){let[n,r]=(0,L.useState)(t),i=G(W(n)),a=i.busy,o=Se(n),s=async t=>{if(o.length===0)return;let n=[...o];await i.run(t,async()=>t===`one`?await e.getParentResult(n[0]):await e.getParentResults(n))};return(0,H.jsxs)(`section`,{className:`grid gap-5 rounded-lg border border-line bg-surface p-4 xl:grid-cols-[minmax(320px,0.8fr)_minmax(0,1.2fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Parent results`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Resolve completed parent values through the official FlowProducer result API.`}),(0,H.jsxs)(`label`,{className:`mt-4 block text-xs text-faint`,children:[`Parent IDs, one per line`,(0,H.jsx)(`textarea`,{"aria-label":`Flow parent IDs`,value:n,onChange:e=>r(e.target.value),placeholder:`parent-job-id
|
|
2
|
-
another-parent-id`,className:`mt-1 min-h-28 w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg`})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,disabled:o.length===0||!!a,onClick:()=>void s(`one`),className:`rounded-md border border-line px-3 py-1.5 font-mono text-xs text-muted disabled:opacity-40`,children:`getParentResult`}),(0,H.jsxs)(`button`,{type:`button`,disabled:o.length===0||!!a,onClick:()=>void s(`many`),className:`rounded-md border border-line px-3 py-1.5 font-mono text-xs text-muted disabled:opacity-40`,children:[`getParentResults (`,o.length,`)`]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:`Resolved values`}),(0,H.jsx)(`p`,{className:`mt-1 mb-4 text-xs text-faint`,children:a?`Reading durable results…`:`Falsy values and input ordering are preserved.`}),i.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mb-3 text-sm text-danger`,children:i.error}),i.result===void 0?(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`No parent result requested.`}):(0,H.jsx)(U,{value:i.result})]})]})}function Se(e){return e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean).slice(0,1e3)}function Ce({repository:e=V,target:t,onTargetChange:n}){let[r,i]=(0,L.useState)(`10`),[a,o]=(0,L.useState)(`100`),s=G(W(t.id,t.queueName,r,a)),c=!!s.busy,l=!!(t.id.trim()&&t.queueName.trim())&&Oe(r)&&Oe(a),u=async()=>{if(!l)return;let n={target:{id:t.id.trim(),queueName:t.queueName.trim()},depth:Number(r),maxChildren:Number(a)};await s.run(`getFlow`,async()=>{let t=await e.getFlow({...n.target,depth:n.depth,maxChildren:n.maxChildren});return{...n,value:t}})};return(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`FlowProducer.getFlow`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Read the broker-native tree with explicit traversal limits. Results are bound to the target and limits that produced them.`})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!l||c,onClick:()=>void u(),className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:c?`Loading tree...`:`Load getFlow tree`})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:t,onChange:n})}),(0,H.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,H.jsx)(we,{label:`Depth`,value:r,onChange:i}),(0,H.jsx)(we,{label:`Children per level`,value:a,onChange:o})]}),(0,H.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Both limits accept integers from 0 to 500.`}),s.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:s.error}),s.result&&(0,H.jsx)(Te,{loaded:s.result})]})}function we({label:e,value:t,onChange:n}){return(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[e,(0,H.jsx)(`input`,{"aria-label":`getFlow ${e}`,type:`number`,min:`0`,max:`500`,step:`1`,value:t,onChange:e=>n(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]})}function Te({loaded:e}){let t=Ee(e.value),n=t?De(t):[];return(0,H.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,"aria-live":`polite`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,H.jsxs)(`span`,{className:`font-mono text-fg`,children:[e.target.queueName,`/`,e.target.id]}),(0,H.jsxs)(`span`,{className:`text-faint`,children:[`depth `,e.depth,`, max children `,e.maxChildren]})]}),t===null?(0,H.jsx)(`p`,{className:`rounded-md border border-line bg-bg p-3 text-sm text-muted`,children:`Bunqueue returned no flow for this target.`}):n.length>0?(0,H.jsx)(`ul`,{"aria-label":`getFlow tree result`,className:`max-h-72 overflow-auto rounded-md border border-line bg-bg`,children:n.map(e=>(0,H.jsxs)(`li`,{className:`flex min-w-max items-center gap-2 border-b border-line/60 px-3 py-2 last:border-b-0`,style:{paddingLeft:`${12+Math.min(e.level,20)*18}px`},children:[(0,H.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] ${w(e.state)}`,children:e.state}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-fg`,children:e.id}),(0,H.jsx)(`span`,{className:`text-xs text-muted`,children:e.name}),(0,H.jsx)(`span`,{className:`text-[11px] text-faint`,children:e.queueName})]},e.id))}):(0,H.jsx)(`p`,{role:`alert`,className:`rounded-md border border-warning/40 p-3 text-sm text-warning`,children:`The agent returned an unrecognized getFlow payload. Inspect the raw JSON below.`}),(0,H.jsxs)(`details`,{className:`mt-3`,open:!0,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-muted`,children:`Raw getFlow JSON`}),(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsx)(U,{value:e.value})})]})]})}function Ee(e){let t=J(e),n=J(t?.result)??t;if(!(!n||!Object.hasOwn(n,`flow`)))return n.flow===null?null:J(n.flow)}function De(e){let t=[],n=[{node:e,level:0}],r=new WeakSet;for(;n.length>0&&t.length<1e3;){let e=n.shift();if(!e||r.has(e.node))continue;r.add(e.node),t.push({id:Y(e.node.id,`(missing id)`),name:Y(e.node.name,`(unnamed)`),queueName:Y(e.node.queueName,`(missing queue)`),state:Y(e.node.state,`unknown`),level:e.level});let i=Array.isArray(e.node.children)?e.node.children:[];n.unshift(...i.map(J).filter(e=>e!==void 0).map(t=>({node:t,level:e.level+1})))}return t}var Oe=e=>/^\d+$/.test(e)&&Number(e)<=500,J=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,Y=(e,t)=>typeof e==`string`&&e.length>0?e:t,ke=[`getState`,`isWaiting`,`isActive`,`isDelayed`,`isCompleted`,`isFailed`,`isWaitingChildren`,`toJSON`,`asJSON`],X={updateData:{data:{}},updateProgress:{progress:50,message:`Halfway`},log:{message:`Operator note`},changeDelay:{delay:1e3},changePriority:{priority:1,lifo:!1},clearLogs:{keepLogs:0},removeDeduplicationKey:{}},Ae={progress:{stage:`hydrate`,completed:4,total:10}};function je({repository:e=V,initialTarget:t={id:``,queueName:``}}){let[n,r]=(0,L.useState)(t),[i,a]=(0,L.useState)(`updateData`),[o,s]=(0,L.useState)(JSON.stringify(X.updateData,null,2)),[c,l]=(0,L.useState)(`30000`),u=G(W(n.id,n.queueName,i,o,c)),d=u.busy,f=!!(n.id.trim()&&n.queueName.trim()),p=e=>{a(e),s(JSON.stringify(X[e],null,2))};return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsx)(Ce,{repository:e,target:n,onTargetChange:r}),(0,H.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Flow Job methods`}),(0,H.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`State predicates, serialization, bounded waiting, and durable mutations from Bunqueue 2.8.59.`})]}),d&&(0,H.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[d,`…`]})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(q,{target:n,onChange:r})}),(0,H.jsx)(`h3`,{className:`mt-5 mb-2 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:`Inspect state and wire JSON`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ke.map(t=>(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d,onClick:()=>{let r=Z(n);u.run(t,()=>e.inspect(r,t))},className:`rounded-md border border-line px-2.5 py-1.5 font-mono text-[11px] text-muted disabled:opacity-40`,children:t},t))}),(0,H.jsxs)(`div`,{className:`mt-5 grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Mutation`,(0,H.jsx)(`select`,{"aria-label":`Flow Job mutation`,value:i,onChange:e=>p(e.target.value),className:`mt-1 block h-9 rounded-lg border border-line bg-surface-2 px-3 font-mono text-xs text-fg`,children:Object.keys(X).map(e=>(0,H.jsx)(`option`,{children:e},e))})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d,onClick:()=>{let t;try{t=JSON.parse(o)}catch{return u.reject(`Mutation payload must be valid JSON.`)}if(!t||typeof t!=`object`||Array.isArray(t))return u.reject(`Mutation payload must be a JSON object.`);let r=Z(n),a=i;window.confirm(`${a} on ${r.id}? This writes durable job state without a compare-and-swap precondition.`)&&u.run(a,()=>e.mutate(r,a,t))},className:`h-9 rounded-md border border-warning/40 px-3 text-xs text-warning disabled:opacity-40`,children:`Apply mutation`}),i===`updateProgress`&&(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(JSON.stringify(X.updateProgress,null,2)),className:`h-9 rounded-md border border-line px-3 text-xs text-muted`,children:`Numeric progress`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>s(JSON.stringify(Ae,null,2)),className:`h-9 rounded-md border border-line px-3 text-xs text-muted`,children:`Object progress`})]})]}),(0,H.jsx)(`textarea`,{"aria-label":`Flow Job mutation JSON`,value:o,onChange:e=>s(e.target.value),className:`mt-3 min-h-32 w-full resize-y rounded-lg border border-line bg-bg p-3 font-mono text-xs text-fg`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`label`,{className:`text-xs text-faint`,children:[`waitUntilFinished TTL (ms)`,(0,H.jsx)(`input`,{"aria-label":`Flow wait TTL`,type:`number`,min:`1`,max:`60000`,value:c,onChange:e=>l(e.target.value),className:`mt-1 block h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]}),(0,H.jsx)(`button`,{type:`button`,disabled:!f||!!d||!Me(c),onClick:()=>{let t=Z(n),r=Number(c);u.run(`waitUntilFinished`,()=>e.waitUntilFinished(t,r))},className:`mt-3 rounded-md border border-line px-3 py-2 font-mono text-xs text-muted disabled:opacity-40`,children:`waitUntilFinished`}),(0,H.jsx)(`p`,{className:`mt-3 text-[11px] leading-5 text-faint`,children:`Lease-only methods are not forged here: extendLock and worker state transitions require the active worker token; discard is process-local and non-awaitable.`})]})]}),u.error&&(0,H.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:u.error}),u.result!==void 0&&(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(U,{value:u.result})})]}),(0,H.jsx)(ye,{repository:e,target:n,onTargetChange:r,showTarget:!1}),(0,H.jsx)(xe,{repository:e})]})}var Z=e=>({id:e.id.trim(),queueName:e.queueName.trim()}),Me=e=>Number.isSafeInteger(Number(e))&&Number(e)>=1&&Number(e)<=6e4;function Ne({input:e,loading:t,onInput:n,onSubmit:r}){return(0,H.jsxs)(p,{className:`mb-6`,children:[(0,H.jsxs)(`form`,{onSubmit:r,className:`flex flex-wrap items-center gap-3`,children:[(0,H.jsx)(`input`,{name:`flow-job-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:e,onChange:e=>n(e.target.value),placeholder:`Flow job ID`,"aria-label":`Root job ID`,"aria-describedby":`flow-input-help`,className:`min-w-0 flex-1 rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,H.jsx)(`button`,{type:`submit`,disabled:t||!e.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg disabled:opacity-50`,children:t?`Loading…`:`Load Flow`})]}),(0,H.jsxs)(`p`,{id:`flow-input-help`,className:`mt-2 text-xs text-faint`,children:[`Start from any surviving structural node. Bunqueue 2.8.59 flow topology is resolved from durable parent, children, and dependency contracts. Up to `,500,` nodes are rendered.`]})]})}var Pe={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function Fe(e,t){let n=new Map,r=new Map,i=new Map;for(let t of e)n.set(t,0),r.set(t,0),i.set(t,[]);for(let e of t)!n.has(e.from)||!n.has(e.to)||e.from===e.to||(i.get(e.from)?.push(e.to),r.set(e.to,(r.get(e.to)??0)+1));let a=e.filter(e=>(r.get(e)??0)===0),o=new Set;for(;o.size<n.size;){for(;a.length;){let e=a.shift();if(!o.has(e)){o.add(e);for(let t of i.get(e)??[]){if(o.has(t))continue;n.set(t,Math.max(n.get(t)??0,(n.get(e)??0)+1));let i=(r.get(t)??0)-1;r.set(t,i),i===0&&a.push(t)}}}let t=e.find(e=>!o.has(e));if(t===void 0)break;a.push(t)}return n}function Ie(e,t,n={}){let r={...Pe,...n},i=Fe(e,t),a=new Map,o=0;for(let t of e){let e=i.get(t)??0;o=Math.max(o,e);let n=a.get(e);n?n.push(t):a.set(e,[t])}let s=0;for(let e of a.values())s=Math.max(s,e.length);let c=s*r.nodeHeight+Math.max(0,s-1)*r.rowGap,l=[];for(let e=0;e<=o;e++){let t=a.get(e)??[],n=t.length*r.nodeHeight+Math.max(0,t.length-1)*r.rowGap,i=r.padding+(c-n)/2;t.forEach((t,n)=>{l.push({id:t,layer:e,x:r.padding+e*(r.nodeWidth+r.colGap),y:i+n*(r.nodeHeight+r.rowGap)})})}return{nodes:l,width:r.padding*2+(o+1)*r.nodeWidth+o*r.colGap,height:r.padding*2+c}}function Le({graph:e,layout:n,selected:r,onSelect:i}){let a=new Map(n.nodes.map(e=>[e.id,e]));return(0,H.jsxs)(p,{padded:!1,className:`max-h-[70vh] overflow-auto overscroll-contain p-4`,children:[(0,H.jsx)(`h2`,{className:`sr-only`,children:`Flow Graph`}),(0,H.jsx)(`ul`,{className:`sr-only`,"aria-label":`Flow relationships`,children:e.edges.map(e=>(0,H.jsx)(`li`,{children:e.kind===`child`?`${e.from} has child ${e.to}`:`${e.to} depends on ${e.from}`},`accessible-${e.from}-${e.to}-${e.kind}`))}),(0,H.jsxs)(`div`,{className:`relative`,style:{width:n.width,height:n.height},children:[(0,H.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:n.width,height:n.height,children:[(0,H.jsxs)(`defs`,{children:[(0,H.jsx)(`marker`,{id:`flow-arrow-child`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,H.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})}),(0,H.jsx)(`marker`,{id:`flow-arrow-dependency`,markerWidth:`6`,markerHeight:`6`,refX:`5`,refY:`3`,orient:`auto`,children:(0,H.jsx)(`path`,{d:`M0,0 L6,3 L0,6 Z`,fill:`currentColor`})})]}),e.edges.map(e=>{let t=a.get(e.from),n=a.get(e.to);return!t||!n?null:(0,H.jsx)(`path`,{d:ze(t,n),fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeDasharray:e.kind===`depends`?`4 4`:void 0,markerEnd:`url(#flow-arrow-${e.kind===`depends`?`dependency`:`child`})`,opacity:.5},`${e.from}-${e.to}-${e.kind}`)})]}),n.nodes.map(n=>{let a=e.jobs.get(n.id),o=e.failures.has(n.id)?`unavailable`:a?.state??`unknown`;return(0,H.jsxs)(`button`,{type:`button`,"data-flow-node":n.id,onClick:()=>i(n.id),"aria-pressed":r===n.id,"aria-label":`${n.id}, queue ${a?.queue??`unknown`}, state ${o}`,title:n.id,style:{left:n.x,top:n.y,width:168,height:60},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/70`,w(a?.state),r===n.id&&`ring-2 ring-accent`),children:[(0,H.jsx)(`span`,{translate:`no`,className:`truncate font-mono text-xs text-fg`,children:T(n.id)}),(0,H.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:a?.queue??`—`}),(0,H.jsx)(`span`,{className:`font-medium`,children:o})]})]},n.id)})]})]})}function Re(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function ze(e,t){return e.x<=t.x?Re(e.x+168,e.y+60/2,t.x,t.y+60/2):Re(e.x,e.y+60/2,t.x+168,t.y+60/2)}function Be({graph:e,selected:t}){let n=t?e.jobs.get(t):void 0,r=t?e.failures.get(t):void 0;return(0,H.jsx)(`aside`,{"aria-label":`Selected job details`,"aria-live":`polite`,children:(0,H.jsxs)(p,{children:[n?(0,H.jsx)(Ve,{job:n,failure:r}):(0,H.jsx)(`p`,{className:`text-sm text-muted`,children:`Select a node to inspect it.`}),(0,H.jsx)(He,{graph:e})]})})}function Ve({job:e,failure:t}){return(0,H.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,H.jsx)(`div`,{translate:`no`,className:`break-all font-mono text-xs text-fg`,children:e.id})]}),t&&(0,H.jsxs)(`p`,{role:`alert`,className:`break-words text-xs text-warning`,children:[`Snapshot unavailable: `,t]}),(0,H.jsx)($,{label:`Queue`,value:e.queue??`—`}),(0,H.jsx)($,{label:`State`,value:t?`unavailable`:e.state??`unknown`}),(0,H.jsx)($,{label:`Priority`,value:e.priority===void 0?`—`:String(e.priority)}),(0,H.jsx)($,{label:`Parent`,value:e.parentId??`—`}),(0,H.jsx)($,{label:`Children`,value:t?`—`:String(e.childrenIds?.length??0)}),(0,H.jsx)($,{label:`Depends on`,value:t?`—`:String(e.dependsOn?.length??0)}),(0,H.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`inline-block rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Open in Job Inspector`})]})}function He({graph:e}){return(0,H.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,"aria-live":`polite`,children:[e.truncated&&(0,H.jsxs)(`div`,{className:`mb-1 text-warning`,children:[`Graph truncated at `,500,` nodes / depth `,100,`.`]}),(0,H.jsx)(Q,{label:`known snapshot limitation`,pluralLabel:`known snapshot limitations`,values:e.limitations,tone:`text-warning`}),(0,H.jsx)(Q,{label:`unavailable node`,pluralLabel:`unavailable nodes`,values:[...e.failures].map(([e,t])=>`${e}: ${t}`),tone:`text-warning`}),e.cycle&&(0,H.jsxs)(`div`,{className:`mb-1 break-words text-danger`,children:[`Dependency cycle: `,(0,H.jsx)(`span`,{className:`font-mono`,children:e.cycle.join(` → `)})]}),(0,H.jsx)(Q,{label:`snapshot inconsistency`,pluralLabel:`snapshot inconsistencies`,values:e.issues,tone:`text-warning`}),e.policyNotes.length>0&&(0,H.jsx)(`p`,{className:`mb-1 text-muted`,children:`Failure-policy notes are informational; the HTTP snapshot cannot prove that a policy fired.`}),(0,H.jsx)(Q,{label:`failure-policy ambiguity`,pluralLabel:`failure-policy ambiguities`,values:e.policyNotes,tone:`text-muted`}),(0,H.jsxs)(`div`,{className:`mb-1`,children:[e.jobs.size,` nodes · `,e.edges.length,` edges`]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` depends`]})]})]})}function Q({label:e,pluralLabel:t,values:n,tone:r}){return n.length?(0,H.jsxs)(`details`,{className:`mb-1 ${r}`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer`,children:[n.length,` `,n.length===1?e:t]}),(0,H.jsx)(`ul`,{className:`mt-1 space-y-1 pl-3`,children:n.map(e=>(0,H.jsx)(`li`,{className:`break-words`,children:e},e))})]}):null}function $({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e}),(0,H.jsx)(`span`,{className:`min-w-0 break-all text-right text-fg`,children:t})]})}function Ue({graph:e,selected:t,onSelect:n}){return(0,H.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_280px]`,children:[(0,H.jsx)(Le,{graph:e,layout:(0,L.useMemo)(()=>Ie([...e.jobs.keys()],e.edges,x),[e]),selected:t,onSelect:n}),(0,H.jsx)(Be,{graph:e,selected:t})]})}function We(){let e=le();return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(_,{title:`Job Flows`,description:`Inspect Bunqueue 2.8.59 parent, child, and dependency topology as an operational DAG.`,actions:e.graph&&(0,H.jsx)(`button`,{type:`button`,disabled:e.loading,onClick:()=>void e.load(e.rootParam),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg disabled:opacity-50`,children:`Refresh`})}),(0,H.jsx)(`nav`,{"aria-label":`Job Flow tools`,className:`mb-5 flex border-b border-line`,children:[`explore`,`create`,`operations`].map(t=>(0,H.jsx)(`button`,{type:`button`,"aria-pressed":e.mode===t,onClick:()=>e.setMode(t),className:e.mode===t?`border-b-2 border-accent px-4 py-2 text-sm capitalize text-fg`:`border-b-2 border-transparent px-4 py-2 text-sm capitalize text-faint hover:text-fg`,children:t===`operations`?`Job methods`:t},t))}),e.mode===`create`&&(0,H.jsx)(me,{onOpen:e.openRecent}),e.mode===`operations`&&(0,H.jsx)(je,{initialTarget:v()?{id:`flow-order-9a3f`,queueName:`orders`}:void 0}),e.mode===`explore`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ne,{input:e.input,loading:e.loading,onInput:e.setInput,onSubmit:e.submit}),(0,H.jsxs)(`div`,{"aria-live":`polite`,children:[e.error&&(ue(e.error)?(0,H.jsx)(m,{message:`Could not load the flow — ${e.error.message}`,onRetry:()=>void e.load(e.rootParam)}):(0,H.jsx)(h,{error:e.error,onRetry:()=>void e.load(e.rootParam)})),e.loading&&(0,H.jsx)(g,{label:`Loading flow…`})]}),!e.loading&&!e.graph&&!e.error&&(0,H.jsx)(ge,{recent:e.recent,onOpen:e.openRecent}),e.graph&&(0,H.jsx)(Ue,{graph:e.graph,selected:e.selected,onSelect:e.setSelected})]})]})}export{We as Flows};
|
|
@@ -1,2 +0,0 @@
|
|
|
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-DYmbVkgR.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-D64v2vNO.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}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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{d as t,g as n,r,t as i}from"./react-vendor-CyjgmGTq.js";import{t as a}from"./bq-DYmbVkgR.js";import{A as o,b as s,i as c,m as l,n as u,x as d}from"./icons-CIvFfU2b.js";import{t as f}from"./api-V_sVpHDo.js";import{n as p}from"./usePolledData-c53tx1jw.js";import{t as m}from"./Button-BPqpRZJD.js";import{t as h}from"./Card-C7NMhqUt.js";import{i as g,r as _,t as v}from"./feedback-BnGE2oW2.js";import{n as y,t as b}from"./StatusBadge-B0I7hNBX.js";import{a as x,c as S,d as C,l as w,s as T,t as E}from"./format-Cg7VCIZW.js";import{n as D}from"./index-D64v2vNO.js";import{a as O,n as k,t as A}from"./form-tC20r4Ma.js";import{r as j,t as M}from"./useServerActionGuard-OTv6_fU0.js";import{r as N}from"./flowMutationSafety-DObp9nJo.js";var P=e(n(),1),F=i();function I({queue:e}){return(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.8.59 cannot read either current policy. Every command below is an explicit blind desired-state write; a receipt proves only what this dashboard applied at that time.`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,F.jsx)(z,{queue:e}),(0,F.jsx)(B,{queue:e})]})]})}function L(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function R(e,t){let[n,r]=(0,P.useState)(!1),[i,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(null),l=j(`classic-queue-policy:${e}:${t}`);return(0,P.useEffect)(()=>{r(!1),o(null),c(null)},[l.scopeKey]),{busy:n,error:i,receipt:s,run:async(n,i,s)=>{if(!window.confirm(i))return;let u=l.begin(t);if(u){r(!0),o(null),c(null);try{let t=await a.queuesSummary();if(!u.isCurrent())return;if(!t.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await s(),n),!u.isCurrent())return;c(`${n} applied at ${new Date().toISOString()}. Current server state cannot be read.`)}catch(e){u.isCurrent()&&o(e.message)}finally{u.finish()&&r(!1)}}}}}function z({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),[o,s]=(0,P.useState)(`permanent`),[c,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),{busy:p,error:g,receipt:_,run:v}=R(e,`rate-limit`),y=L(t),b=L(r),x=o===`expires`?L(c):void 0,S=y!==null&&b!==null&&(o===`permanent`||x!=null);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,F.jsx)(l,{className:`size-4 text-faint`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsx)(A,{label:`Limit`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-limit`,value:t,"aria-invalid":t.trim()!==``&&y===null,onChange:e=>n(e.target.value),placeholder:`100`})}),(0,F.jsx)(A,{label:`Window (ms)`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-duration`,value:r,"aria-invalid":r.trim()!==``&&b===null,onChange:e=>i(e.target.value),placeholder:`60000`})}),(0,F.jsx)(A,{label:`TTL`,children:(0,F.jsxs)(O,{name:`classic-rate-ttl-mode`,value:o,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,F.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,F.jsx)(A,{label:`TTL (ms)`,hint:o===`permanent`?`Not sent`:void 0,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-ttl`,disabled:o===`permanent`,value:c,"aria-invalid":o===`expires`&&c.trim()!==``&&x==null,onChange:e=>u(e.target.value),placeholder:`3600000`})})]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,F.jsx)(m,{variant:`accent`,size:`sm`,disabled:p||!S,onClick:()=>{if(y===null||b===null||o===`expires`&&x===null)return;let t=typeof x==`number`?x:void 0,n=o===`permanent`?`permanent`:`TTL ${x}ms`;v(`Rate-limit policy replaced`,`Replace the unknown rate-limit policy for "${e}" with limit ${y}, window ${b}ms, ${n}?`,()=>a.setRateLimit(e,y,b,t))},children:`Replace rate-limit policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,F.jsx)(m,{className:`mt-2`,size:`sm`,disabled:p||d!==e,onClick:()=>void v(`No rate limit ensured`,`Ensure queue "${e}" has no rate-limit policy? The previous value is unavailable.`,()=>a.clearRateLimit(e)),children:`Ensure no rate limit`})]}),_&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:_}),g&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:g})]})}function B({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),{busy:s,error:c,receipt:l,run:u}=R(e,`concurrency`),d=L(t);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,F.jsx)(o,{className:`size-4 text-faint`})]}),(0,F.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,F.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-concurrency`,value:t,"aria-invalid":t.trim()!==``&&d===null,onChange:e=>n(e.target.value),placeholder:`5`})}),(0,F.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,F.jsx)(m,{variant:`accent`,size:`sm`,disabled:s||d===null,onClick:()=>{d!==null&&u(`Concurrency policy replaced`,`Replace the unknown concurrency policy for "${e}" with ${d} maximum in-flight jobs?`,()=>a.setConcurrency(e,d))},children:`Replace concurrency policy`})}),(0,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,F.jsx)(m,{className:`mt-2`,size:`sm`,disabled:s||r!==e,onClick:()=>void u(`No concurrency limit ensured`,`Ensure queue "${e}" has no concurrency policy? The previous value is unavailable.`,()=>a.clearConcurrency(e)),children:`Ensure no concurrency limit`})]}),l&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l}),c&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c})]})}var V=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],H={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,"waiting-children":0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[],recentJobsError:null};function U(){let{name:e=``}=t(),[n,i]=(0,P.useState)(null),[o,l]=(0,P.useState)(null),h=j(`classic-queue:${e}`);(0,P.useEffect)(()=>{i(null),l(null)},[h.scopeKey]);let{data:O,error:k,loading:A,refetch:L}=p((0,P.useCallback)(async()=>{if(!(await a.queuesSummary()).some(t=>t.name===e))return{exists:!1,detail:null,jobs:[],recentJobsError:null};let[t,n]=await Promise.all([f.queueDetail(e,!1),f.jobsList(e,{states:V,limit:12}).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);if(t.ok!==!0||t.name!==e)throw Error(`Malformed queue detail response for "${e}"`);return{exists:!0,detail:t,jobs:n.jobs,recentJobsError:n.error}},[e]),[e]),R=async(t,n,r)=>{if(r&&!window.confirm(r))return;let o=h.begin(t);if(o){i(t),l(null);try{let r=await a.queuesSummary();if(!o.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await n(),t),!o.isCurrent())return;await L()}catch(e){o.isCurrent()&&l(e.message)}finally{o.finish()&&i(null)}}};if(A&&!O&&!k)return(0,F.jsx)(_,{label:`Loading ${e}…`});if(k&&!O)return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(g,{onRetry:L})]});if(O?.exists===!1)return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(v,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,F.jsx)(r,{to:`/queues-classic`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to classic queues`})})]});let z=O?.exists===!0?O:H,{detail:B}=z,U=B.counts,W=E(U.completed??0,U.failed??0),G=[...z.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(r,{to:`/queues-classic`,"aria-label":`Back to classic queues`,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,F.jsx)(c,{className:`size-4`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,F.jsx)(y,{label:B.paused?`Paused`:`Active`,tone:B.paused?`amber`:`green`}),(0,F.jsx)(y,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B.paused?(0,F.jsxs)(m,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>R(`resume`,()=>f.resume(e)),children:[(0,F.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,F.jsxs)(m,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>R(`pause`,()=>f.pause(e)),children:[(0,F.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,F.jsx)(m,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,F.jsx)(m,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),o&&(0,F.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:o}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,F.jsx)(D,{label:`Waiting`,value:T(U.waiting),tone:`amber`}),(0,F.jsx)(D,{label:`Active`,value:T(U.active),tone:`blue`}),(0,F.jsx)(D,{label:`Completed`,value:T(U.completed),tone:`green`}),(0,F.jsx)(D,{label:`Failed`,value:T(U.failed),tone:U.failed?`red`:`default`}),(0,F.jsx)(D,{label:`Delayed`,value:T(U.delayed),tone:`default`}),(0,F.jsx)(D,{label:`Error Rate`,value:W==null?`—`:S(W),tone:W==null?`default`:W>.05?`red`:`green`})]}),(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,F.jsxs)(r,{to:`/jobs-classic?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,F.jsx)(u,{className:`size-3.5`})]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,F.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,F.jsx)(`tbody`,{children:z.recentJobsError?(0,F.jsx)(`tr`,{children:(0,F.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,z.recentJobsError,`. Retry the page.`]})}):G.length===0?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.map(e=>(0,F.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,F.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,F.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e.id})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,F.jsx)(`td`,{className:`px-5 py-3`,children:(0,F.jsx)(b,{status:String(e.state??e.status??`waiting`)})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:x(C(e.startedAt,e.completedAt))}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,F.jsx)(I,{queue:e})]})}export{U as QueueDetail};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{d 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{i as c,n as l}from"./icons-CIvFfU2b.js";import{n as u}from"./usePolledData-c53tx1jw.js";import{t as d}from"./Button-BPqpRZJD.js";import{n as f,t as p}from"./Card-C7NMhqUt.js";import{i as m,n as h,r as g,t as _}from"./feedback-BnGE2oW2.js";import{n as v}from"./StatusBadge-B0I7hNBX.js";import{t as y}from"./PageHeader-BXlZSBcc.js";import{a as b,c as x,s as S,t as C}from"./format-Cg7VCIZW.js";import{n as w}from"./index-D64v2vNO.js";import{r as T,t as E}from"./useServerActionGuard-OTv6_fU0.js";import{r as D}from"./flowMutationSafety-DObp9nJo.js";import{t as O}from"./AreaChart-w0ruozXH.js";import{a as k,i as A,n as j,r as M,t as N}from"./QueueActions-jiTzndPH.js";import{t as P}from"./useThroughputSeries-DWHQl7cM.js";var F=e(r(),1),I=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],L=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],R=2e3,z=a();function B({name:e,jobs:t,error:n}){return(0,z.jsxs)(p,{padded:!1,className:`mb-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,z.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,z.jsx)(l,{className:`size-3.5`})]})]}),(0,z.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,z.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,z.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`State`}),(0,z.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,z.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,z.jsx)(`tbody`,{children:n?(0,z.jsx)(`tr`,{children:(0,z.jsxs)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,n,`. Retry the page.`]})}):t.length===0?(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):t.map(e=>(0,z.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,z.jsx)(`td`,{className:`px-5 py-3`,children:(0,z.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,z.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,z.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,z.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,z.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)})]},e.id))})]})})]})}function V({counts:e}){let t=Object.entries(e??{}).map(([e,t])=>[Number(e),t]).filter(([,e])=>e>0).sort((e,t)=>t[0]-e[0]);if(t.length===0)return null;let n=Math.max(...t.map(([,e])=>e));return(0,z.jsxs)(p,{className:`mb-6`,children:[(0,z.jsx)(f,{title:`Jobs by priority`}),(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,z.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,z.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,z.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:S(t)})]},e))}),(0,z.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}function H({name:e,depth:n,trend:r,rate:i}){return(0,z.jsxs)(p,{className:`mb-6`,children:[(0,z.jsx)(f,{title:`Backlog depth`,action:(0,z.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,r.draining?`bg-emerald-500/10 text-success`:r.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:r.label})}),n.length<2?(0,z.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,z.jsx)(O,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:n,area:!0}]}),(0,z.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,z.jsx)(`span`,{children:`waiting + prioritized + active + delayed + waiting-children`}),(0,z.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,i==null?`—`:x(i)]})]})]})}function U(e,t){let[n,r]=(0,F.useState)([]),i=(0,F.useRef)(null);return(0,F.useEffect)(()=>{t&&(i.current=(t.waiting??0)+(t.prioritized??0)+(t.active??0)+(t.delayed??0)+(t[`waiting-children`]??0))},[t]),(0,F.useEffect)(()=>{i.current=null,r([]);let e=setInterval(()=>{let e=i.current;e!=null&&r(t=>[...t,e].slice(-40))},R);return()=>clearInterval(e)},[e]),{depth:n,trend:P(n)}}function W(){let{name:e=``}=n(),[t,r]=(0,F.useState)(!1),[a,f]=(0,F.useState)(null),p=T(`queue:${e}`);(0,F.useEffect)(()=>{r(!1),f(null)},[p.scopeKey]);let{data:b,error:x,loading:O,refetch:P}=u((0,F.useCallback)(async()=>{if(!e)return null;if(!(await o.queuesSummary()).some(t=>t.name===e))return{queue:e,exists:!1,detail:null,stall:null,dlq:null,jobs:[],recentJobsError:null};let[t,n,r,i]=await Promise.all([o.queueDetail(e,!1),o.getStallConfig(e).catch(()=>null),o.getDlqConfig(e).catch(()=>null),o.jobsList(e,L,12).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);return{queue:e,exists:!0,detail:t,stall:n?.config??null,dlq:r?.config??null,jobs:i.jobs,recentJobsError:i.error}},[e]),[e]),R=b&&b.queue===e?b:null,{depth:W,trend:G}=U(e,R?.detail?.counts),K=async(t,n,i,a)=>{if(i&&!window.confirm(i))return;let c=p.begin();if(c){r(!0),f(null);try{let r=await o.queuesSummary();if(!c.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);let i=await n();if(E(i,t),!c.isCurrent())return;let l=i.count;if(l!==void 0&&(!Number.isSafeInteger(l)||l<0))throw Error(`${t} returned an invalid count`);let u=`${t}${l==null?` ✓`:`: ${l}`}`;f({ok:!0,text:u}),s.success(u,e),a?.(),P()}catch(e){if(!c.isCurrent())return;let n=e.message;f({ok:!1,text:n}),s.error(`${t} failed`,n)}finally{c.finish()&&r(!1)}}},q=R?.detail,J=q?.counts,Y=J?C(J.completed??0,J.failed??0):null;return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(y,{title:(0,z.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and complete live non-terminal depth.`,live:R?.exists===!0&&!!R.detail&&!!R.stall&&!!R.dlq&&!R.recentJobsError&&!x,back:(0,z.jsx)(i,{to:`/queues`,"aria-label":`Back to queues`,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,z.jsx)(c,{className:`size-4`})}),actions:R?.exists===!0?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`Jobs `,(0,z.jsx)(l,{className:`size-3.5`})]}),(0,z.jsxs)(i,{to:`/dlq?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`DLQ `,(0,z.jsx)(l,{className:`size-3.5`})]}),(0,z.jsx)(d,{variant:`danger`,size:`sm`,disabled:!0,title:D,children:`Obliterate`})]}):void 0}),x&&R&&(0,z.jsx)(m,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:P}),x&&!R?(0,z.jsx)(h,{error:x,onRetry:P}):O&&!R?(0,z.jsx)(g,{label:`Loading ${e}…`}):R?.exists===!1||!q||!J?!x&&(0,z.jsx)(_,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,z.jsx)(i,{to:`/queues`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to queues`})}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,z.jsx)(v,{label:q.paused?`Paused`:`Active`,tone:q.paused?`amber`:`green`}),a&&(0,z.jsx)(`span`,{role:`status`,className:a.ok?`text-xs text-success`:`text-xs text-danger`,children:a.text}),(0,z.jsx)(`span`,{className:`text-xs text-warning`,children:D})]}),(0,z.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:I.map(e=>(0,z.jsx)(w,{label:e,value:S(J[e]),tone:e===`failed`&&J.failed?`red`:`default`,compact:!0},e))}),(0,z.jsx)(B,{name:e,jobs:R.jobs,error:R.recentJobsError}),(0,z.jsx)(V,{counts:q.priorityCounts}),(0,z.jsx)(H,{name:e,depth:W,trend:G,rate:Y}),(0,z.jsx)(j,{queue:e,paused:q.paused,busy:t,run:K}),(0,z.jsx)(N,{queue:e,busy:t,run:K},`${e}:limits`),(0,z.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[R.stall?(0,z.jsx)(A,{queue:e,config:R.stall,onSaved:()=>{f({ok:!0,text:`Stall config saved ✓`}),s.success(`Stall config saved`,e)}},`${e}:stall`):(0,z.jsx)(M,{title:`Stall detection`,onRetry:P}),R.dlq?(0,z.jsx)(k,{queue:e,config:R.dlq,onSaved:()=>{f({ok:!0,text:`DLQ config saved ✓`}),s.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,z.jsx)(M,{title:`DLQ policy`,onRetry:P})]})]})]})}export{W as QueueDetailPro};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CyjgmGTq.js";import{d as r,f as i,i as a,o,u as s}from"./connectionStore-CKFQrxDo.js";import{o as c,t as l}from"./bq-DYmbVkgR.js";import{w as u}from"./icons-CIvFfU2b.js";import{n as d}from"./usePolledData-c53tx1jw.js";import{t as f}from"./Button-BPqpRZJD.js";import{t as p}from"./Card-C7NMhqUt.js";import{t as m}from"./PageHeader-BXlZSBcc.js";import{a as h}from"./index-D64v2vNO.js";import{a as g,n as _,r as v,t as y}from"./form-tC20r4Ma.js";var b=e(t(),1),ee=`bq-dash-s3`,x=2,S=[`disabled`,`6h`,`12h`,`24h`],C={endpoint:``,region:`us-east-1`,bucket:``,schedule:`disabled`,pathPrefix:``,virtualHostedStyle:`auto`,retention:7};function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e,t,n){return typeof e==`string`&&e.length<=n?e:t}function E(e){return S.includes(e)?e:`disabled`}function D(e){return e===`virtual-hosted`||e===`path-style`?e:`auto`}function O(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=1&&e<=1e6?e:C.retention}function k(e){let t=w(e)?e:{};return{endpoint:T(t.endpoint,C.endpoint,2048),region:T(t.region,C.region,128),bucket:T(t.bucket,C.bucket,255),schedule:E(t.schedule),pathPrefix:T(t.pathPrefix,C.pathPrefix,1024),virtualHostedStyle:D(t.virtualHostedStyle),retention:O(t.retention)}}function A(e){return k(e)}function j(){try{return globalThis.localStorage??null}catch{return null}}function M(e){try{let t=JSON.parse(e),n=w(t)?t:{},r=k(`state`in n?n.state:n),i=typeof n.version==`number`?n.version:void 0;return{hydration:JSON.stringify({state:r,...i===void 0?{}:{version:i}}),canonical:JSON.stringify({state:r,version:x})}}catch{return null}}var te={getItem(e){let t=j();if(!t)return null;let n;try{n=t.getItem(e)}catch{return null}if(n===null||e!==`bq-dash-s3`)return n;let r=M(n);if(!r){try{t.removeItem(e)}catch{}return null}if(n!==r.canonical)try{t.setItem(e,r.canonical)}catch{try{t.removeItem(e)}catch{}}return r.hydration},setItem(e,t){try{j()?.setItem(e,t)}catch{}},removeItem(e){try{j()?.removeItem(e)}catch{}}},ne=i()(r(e=>({...C,accessKeyId:``,secretAccessKey:``,sessionToken:``,set:t=>e(e=>{let n={...e,...t};return{...k(n),accessKeyId:T(n.accessKeyId,``,512),secretAccessKey:T(n.secretAccessKey,``,2048),sessionToken:T(n.sessionToken,``,4096)}})}),{name:ee,version:x,storage:s(()=>te),partialize:A,migrate:k,merge:(e,t)=>({...t,...k(e),accessKeyId:``,secretAccessKey:``,sessionToken:``})})),N=new Set([`enabled`,`bucket`,`endpoint`,`interval`,`retention`]),P=new Set([`key`,`size`,`date`]);function F(e){let t=L(e,N,`Backup status`);return typeof t.enabled!=`boolean`&&B(`Backup status`),{enabled:t.enabled,bucket:R(t.bucket,`Backup status bucket`,1024),endpoint:R(t.endpoint,`Backup status endpoint`,4096),interval:R(t.interval,`Backup status interval`,128),retention:R(t.retention,`Backup status retention`,128)}}function I(e){(!Array.isArray(e)||e.length>2e4)&&B(`Backup list`);let t=new Set,n=0;return e.map((e,r)=>{let i=L(e,P,`Backup list item ${r}`),a=R(i.key,`Backup list item ${r} key`,2048),o=R(i.size,`Backup list item ${r} size`,128),s=R(i.date,`Backup list item ${r} date`,128);return n+=a.length+o.length+s.length,(n>2*1024*1024||t.has(a)||!z(s))&&B(`Backup list item ${r}`),t.add(a),{key:a,size:o,date:s}})}function L(e,t,n){(!e||typeof e!=`object`||Array.isArray(e))&&B(n);let r=e;return Object.keys(r).some(e=>!t.has(e))&&B(n),r}function R(e,t,n){return(typeof e!=`string`||e.length<1||e.length>n)&&B(t),e}function z(e){let t=Date.parse(e);return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(e)&&Number.isFinite(t)&&new Date(t).toISOString()===e}function B(e){throw Error(`${e} returned an invalid Bunqueue 2.8.59 contract`)}function V(e){let t={};for(let n of e.split(`
|
|
2
|
-
`)){let e=n.indexOf(`=`);if(e<1)throw Error(`Generated backup environment is malformed`);let r=n.slice(0,e),i=n.slice(e+1);if(!/^S3_[A-Z0-9_]+$/.test(r))throw Error(`Unexpected backup key: ${r}`);let a;try{a=JSON.parse(i)}catch{if(i===`true`||i===`false`||/^\d+$/.test(i))a=i;else throw Error(`Generated backup value for ${r} is malformed`)}t[r]=String(a)}return t}var H=e=>`${e}?target=${encodeURIComponent(a())}`,U=e=>({method:`POST`,headers:e===void 0?void 0:{"Content-Type":`application/json`},body:e===void 0?void 0:JSON.stringify(e)}),W=async(e,t)=>(await c(H(e),t)).result,G={status:()=>W(`/backup/status`),list:()=>W(`/backup/list`),backupNow:()=>W(`/backup/now`,U()),restore:(e,t)=>W(`/backup/restore`,U({key:e,database:t})),configure:e=>W(`/backup/configure`,U({environment:e})),restoreContext:async()=>{let e=await c(`/control/status`);return{serverStatus:e.status,database:e.db??null}}},K=n();function q({environmentText:e,repository:t=G}){let n=d(()=>X(t),[t],{intervalMs:15e3}),[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(``),l=(0,b.useRef)(!1),u=async(e,t)=>{if(!l.current){l.current=!0,i(e),o(``),c(``);try{let r=(await t())?.message;c(r??`${e} completed.`),await n.refetch()}catch(e){o(e instanceof Error?e.message:String(e))}finally{l.current=!1,i(``)}}},f=()=>{e&&window.confirm(`Apply this S3 configuration to the managed server? A restart is required.`)&&u(`Configuration`,()=>t.configure(V(e)))},p=()=>{window.confirm(`Create a transactionally consistent S3 backup now?`)&&u(`Backup`,()=>t.backupNow())},m=e=>{let r=n.data?.context?.database;!r||n.data?.context?.serverStatus!==`stopped`||window.prompt(`Type RESTORE to replace ${r.path} with ${e}`)===`RESTORE`&&u(`Restore`,()=>t.restore(e,r))},h=n.data;return(0,K.jsxs)(`section`,{className:`mt-6 overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Live backup operations`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Official Bunqueue 2.8.59 backup CLI, executed by the local control agent.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:!e||!!r,onClick:f,className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Apply configuration`}),(0,K.jsx)(`button`,{type:`button`,disabled:!!r,onClick:p,className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:r===`Backup`?`Backing up…`:`Backup now`}),(0,K.jsx)(`button`,{type:`button`,disabled:n.loading,onClick:()=>void n.refetch(),className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Refresh`})]})]}),h?.status&&(0,K.jsx)(J,{status:h.status,context:h.context}),a||h?.errors.length?(0,K.jsx)(`div`,{role:`alert`,className:`border-b border-line px-4 py-3 text-xs text-danger`,children:a||h?.errors.join(` · `)}):null,s&&(0,K.jsx)(`div`,{role:`status`,className:`border-b border-line px-4 py-3 text-xs text-success`,children:s}),(0,K.jsx)(Y,{rows:h?.backups??[],canRestore:h?.context?.serverStatus===`stopped`&&!!h.context.database,busy:!!r,onRestore:m})]})}function J({status:e,context:t}){return(0,K.jsx)(`dl`,{className:`grid border-b border-line sm:grid-cols-2 xl:grid-cols-5`,children:[[`Scheduler`,e.enabled?`Enabled after restart`:`Disabled`],[`Bucket`,e.bucket||`—`],[`Endpoint`,e.endpoint],[`Retention`,e.retention],[`Server`,t?.serverStatus??`Unknown`]].map(([e,t])=>(0,K.jsxs)(`div`,{className:`border-b border-line px-4 py-3 last:border-b-0 xl:border-r xl:border-b-0`,children:[(0,K.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-faint`,children:e}),(0,K.jsx)(`dd`,{className:`mt-1 truncate text-xs text-fg`,title:t,children:t})]},e))})}function Y({rows:e,canRestore:t,busy:n,onRestore:r}){return e.length?(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full min-w-[680px] text-left text-xs`,children:[(0,K.jsx)(`thead`,{className:`border-b border-line text-[10px] uppercase tracking-wider text-faint`,children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Object key`}),(0,K.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Size`}),(0,K.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Created`}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-right font-medium`,children:`Restore`})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-line`,children:e.map(e=>(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`td`,{className:`max-w-md truncate px-4 py-3 font-mono text-fg`,title:e.key,children:e.key}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-muted`,children:e.size}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-muted`,children:e.date}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,K.jsx)(`button`,{type:`button`,disabled:!t||n,title:t?`Restore this backup`:`Stop the managed server before restore`,onClick:()=>r(e.key),className:`rounded-md border border-danger/40 px-2.5 py-1.5 text-danger disabled:opacity-35`,children:`Restore`})})]},e.key))})]})}):(0,K.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`No backup objects returned.`})}async function X(e){let[t,n,r]=await Promise.allSettled([e.status().then(e=>F(e.data)),e.list().then(e=>I(e.data)),e.restoreContext()]),i=[t,n,r].filter(e=>e.status===`rejected`).map(e=>e.reason instanceof Error?e.reason.message:String(e.reason));return{status:t.status===`fulfilled`?t.value:void 0,backups:n.status===`fulfilled`?n.value:[],context:r.status===`fulfilled`?r.value:void 0,errors:i}}function re(e){if(typeof e!=`object`||!e||Array.isArray(e)||typeof e.ok!=`boolean`)throw Error(`Malformed storage status response.`);let t=e.data;if(typeof t!=`object`||!t||Array.isArray(t)||typeof t.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data.`);return{diskFull:t.diskFull}}var Z=e=>JSON.stringify([e.baseUrl,e.token]),Q={"6h":360*60*1e3,"12h":720*60*1e3,"24h":1440*60*1e3};function $(e,t){return`${e}=${typeof t==`string`?JSON.stringify(t):String(t)}`}function ie(e){let t=[],n=e.endpoint.trim(),r=e.region.trim(),i=e.bucket.trim(),a=e.accessKeyId.trim(),o=e.secretAccessKey.trim(),s=e.sessionToken.trim(),c=e.pathPrefix.trim();if(e.schedule===`disabled`)return{ok:!0,value:$(`S3_BACKUP_ENABLED`,!1)};if((!r||r.length>128)&&t.push(`Region is required (maximum 128 characters).`),(!i||i.length>255)&&t.push(`Bucket is required (maximum 255 characters).`),(!a||a.length>512)&&t.push(`Access key ID is required (maximum 512 characters).`),(!o||o.length>2048)&&t.push(`Secret access key is required (maximum 2048 characters).`),s.length>4096&&t.push(`Session token is too long.`),(!Number.isSafeInteger(e.retention)||e.retention<1||e.retention>1e6)&&t.push(`Retention must be a whole number from 1 to 1000000.`),c.length>1024&&t.push(`Path prefix is too long.`),n)try{let e=new URL(n);(e.protocol!==`http:`&&e.protocol!==`https:`||e.username||e.password||n.length>2048)&&t.push(`Endpoint must be an http(s) URL without embedded credentials.`)}catch{t.push(`Endpoint must be a valid http(s) URL.`)}if(t.length)return{ok:!1,errors:t};let l=[$(`S3_BACKUP_ENABLED`,!0),$(`S3_ACCESS_KEY_ID`,a),$(`S3_SECRET_ACCESS_KEY`,o),$(`S3_BUCKET`,i),$(`S3_REGION`,r),$(`S3_BACKUP_RETENTION`,e.retention)];return s&&l.push($(`S3_SESSION_TOKEN`,s)),e.virtualHostedStyle!==`auto`&&l.push($(`S3_VIRTUAL_HOSTED_STYLE`,e.virtualHostedStyle===`virtual-hosted`)),n&&l.push($(`S3_ENDPOINT`,n)),c&&l.push($(`S3_BACKUP_PREFIX`,c)),l.push($(`S3_BACKUP_INTERVAL`,Q[e.schedule])),{ok:!0,value:l.join(`
|
|
3
|
-
`)}}function ae({environment:e}){return(0,K.jsxs)(p,{children:[(0,K.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Server environment`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Credentials stay in memory and are copied or applied only when you request it.`})]}),e.ok&&(0,K.jsx)(h,{value:e.value})]}),e.ok?(0,K.jsx)(`pre`,{className:`overflow-x-auto whitespace-pre-wrap break-all rounded-lg bg-surface-2 p-4 font-mono text-xs text-muted`,children:e.value.replace(/^S3_ACCESS_KEY_ID=.*$/m,`S3_ACCESS_KEY_ID="••••••••"`).replace(/^S3_SECRET_ACCESS_KEY=.*$/m,`S3_SECRET_ACCESS_KEY="••••••••"`).replace(/^S3_SESSION_TOKEN=.*$/m,`S3_SESSION_TOKEN="••••••••"`)}):(0,K.jsx)(`ul`,{className:`space-y-1 text-sm text-danger`,"aria-label":`Configuration errors`,children:e.errors.map(e=>(0,K.jsxs)(`li`,{children:[`• `,e]},e))})]})}function oe(){let e=ne(),t=o(Z),[n,r]=(0,b.useState)(null),[i,a]=(0,b.useState)(null),s=(0,b.useRef)(0),c=ie(e),d=n?.target===t?n:null,h=i===t;return(0,b.useEffect)(()=>(s.current++,r(null),a(null),()=>{s.current++}),[t]),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(m,{title:`S3 Backup Setup`,description:`Configure and operate Bunqueue 2.8.59 S3 backups.`}),(0,K.jsxs)(`div`,{className:`mb-6 flex items-center justify-between rounded-xl border border-line bg-surface px-5 py-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-surface-2 text-faint`,children:(0,K.jsx)(u,{className:`size-5`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-semibold text-fg`,children:c.ok?`Configuration draft complete`:`Configuration draft incomplete`}),(0,K.jsx)(`div`,{className:`text-xs text-faint`,children:c.ok?e.schedule===`disabled`?`Safe disable settings ready to apply`:`Target: ${e.bucket.trim()} · ready to apply`:`Complete the required fields to generate server settings`})]})]}),(0,K.jsx)(`span`,{className:c.ok?`rounded-full bg-emerald-500/10 px-3 py-1 text-xs font-medium text-success`:`rounded-full bg-amber-500/10 px-3 py-1 text-xs font-medium text-warning`,children:c.ok?`Ready`:`Configure`})]}),(0,K.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-2.5 text-xs text-faint`,children:`Apply the generated settings through the local control agent below, then restart Bunqueue. Status, object listing, manual backups, and guarded restores use the official Bunqueue CLI. Non-secret draft fields are stored locally; credentials remain in memory.`}),(0,K.jsxs)(p,{className:`mb-6`,children:[(0,K.jsx)(`h2`,{className:`mb-1 text-base font-semibold text-fg`,children:`Connection Settings`}),(0,K.jsx)(`p`,{className:`mb-4 text-xs text-faint`,children:`Works with AWS S3, Cloudflare R2, MinIO, DigitalOcean Spaces, and any S3-compatible provider.`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,K.jsx)(y,{label:`Endpoint`,children:(0,K.jsx)(_,{name:`s3-endpoint`,value:e.endpoint,onChange:t=>e.set({endpoint:t.target.value}),placeholder:`https://s3.amazonaws.com`,maxLength:2048,autoComplete:`off`,inputMode:`url`})}),(0,K.jsx)(y,{label:`Region`,children:(0,K.jsx)(_,{name:`s3-region`,value:e.region,onChange:t=>e.set({region:t.target.value}),placeholder:`us-east-1`,maxLength:128,autoComplete:`off`,spellCheck:!1})}),(0,K.jsx)(`div`,{className:`md:col-span-2`,children:(0,K.jsx)(y,{label:`Bucket name`,children:(0,K.jsx)(_,{name:`s3-bucket`,value:e.bucket,onChange:t=>e.set({bucket:t.target.value}),placeholder:`my-bunqueue-backups`,maxLength:255,autoComplete:`off`,spellCheck:!1})})}),(0,K.jsx)(y,{label:`Access key ID`,children:(0,K.jsx)(_,{name:`s3-access-key-id`,value:e.accessKeyId,onChange:t=>e.set({accessKeyId:t.target.value}),placeholder:`AKIA…`,maxLength:512,autoComplete:`off`,spellCheck:!1})}),(0,K.jsx)(y,{label:`Secret access key`,children:(0,K.jsx)(_,{name:`s3-secret-access-key`,type:`password`,value:e.secretAccessKey,onChange:t=>e.set({secretAccessKey:t.target.value}),placeholder:`••••••••••••••••`,maxLength:2048,autoComplete:`off`,spellCheck:!1})}),(0,K.jsx)(`div`,{className:`md:col-span-2`,children:(0,K.jsx)(y,{label:`Session token (optional, for temporary STS credentials)`,children:(0,K.jsx)(_,{name:`s3-session-token`,type:`password`,value:e.sessionToken,onChange:t=>e.set({sessionToken:t.target.value}),placeholder:`Temporary AWS session token`,maxLength:4096,autoComplete:`off`,spellCheck:!1})})}),(0,K.jsx)(`p`,{className:`-mt-2 text-xs text-faint md:col-span-2`,children:`Keys are kept in memory only and cleared on reload.`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(v,{htmlFor:`s3-backup-schedule`,children:`Backup interval`}),(0,K.jsxs)(g,{id:`s3-backup-schedule`,name:`s3-backup-schedule`,value:e.schedule,onChange:t=>e.set({schedule:t.target.value}),className:`mt-1.5`,title:`Written to S3_BACKUP_ENABLED and S3_BACKUP_INTERVAL in the generated config`,autoComplete:`off`,children:[(0,K.jsx)(`option`,{value:`disabled`,children:`Disabled`}),(0,K.jsx)(`option`,{value:`6h`,children:`Every 6 hours`}),(0,K.jsx)(`option`,{value:`12h`,children:`Every 12 hours`}),(0,K.jsx)(`option`,{value:`24h`,children:`Every 24 hours`})]})]}),(0,K.jsx)(y,{label:`Path prefix (optional)`,children:(0,K.jsx)(_,{name:`s3-path-prefix`,value:e.pathPrefix,onChange:t=>e.set({pathPrefix:t.target.value}),placeholder:`backups/production/`,maxLength:1024,autoComplete:`off`,spellCheck:!1})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(v,{htmlFor:`s3-addressing-style`,children:`Addressing style`}),(0,K.jsxs)(g,{id:`s3-addressing-style`,name:`s3-addressing-style`,value:e.virtualHostedStyle,onChange:t=>e.set({virtualHostedStyle:t.target.value}),className:`mt-1.5`,children:[(0,K.jsx)(`option`,{value:`auto`,children:`Provider default`}),(0,K.jsx)(`option`,{value:`virtual-hosted`,children:`Virtual-hosted style`}),(0,K.jsx)(`option`,{value:`path-style`,children:`Path style`})]})]}),(0,K.jsx)(y,{label:`Backups to retain`,children:(0,K.jsx)(_,{name:`s3-retention`,type:`number`,min:1,max:1e6,step:1,value:e.retention,onChange:t=>e.set({retention:Number(t.target.value)}),inputMode:`numeric`})})]}),(0,K.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(f,{onClick:async()=>{let e=t,n=++s.current;r(null),a(e);try{let t=await l.storage();if(n!==s.current||Z(o.getState())!==e)return;let i=re(t);r({target:e,ok:!i.diskFull,msg:i.diskFull?`Server disk is full`:`Server disk healthy — this does not validate the S3 credentials`})}catch(t){if(n!==s.current||Z(o.getState())!==e)return;r({target:e,ok:!1,msg:t.message})}finally{n===s.current&&a(null)}},children:h?`Checking server storage…`:`Check server storage`}),(0,K.jsx)(`span`,{className:`text-xs text-faint`,children:`This checks SQLite disk health only, not S3 connectivity.`}),d&&(0,K.jsx)(`span`,{role:`status`,className:d.ok?`text-xs text-success`:`text-xs text-danger`,children:d.msg})]})]}),(0,K.jsx)(ae,{environment:c}),(0,K.jsx)(q,{environmentText:c.ok?c.value:void 0})]})}export{oe as S3BackupPro};
|