bunqueue-dashboard 0.0.46 → 1.0.1
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 +6 -6
- package/agent/compiledRuntime.ts +27 -0
- package/agent/db/boundedStream.ts +18 -0
- package/agent/db/exportTimeout.ts +8 -6
- package/agent/db/processWorker.ts +121 -0
- package/agent/db/queryTimeout.ts +62 -50
- package/agent/db/readAdmission.ts +53 -0
- package/agent/db/readOperations.ts +27 -0
- package/agent/db/readProcessMain.ts +64 -0
- package/agent/db/types.ts +3 -0
- package/agent/db/workerFactory.ts +12 -10
- package/agent/dbReadWorker.ts +21 -0
- package/agent/index.ts +2 -1
- package/agent/managedTarget.ts +3 -1
- package/agent/manager/commandLine.ts +33 -0
- package/agent/manager/configStore.ts +65 -0
- package/agent/manager/errors.ts +4 -0
- package/agent/manager/process.ts +12 -3
- package/agent/manager.ts +1 -0
- package/agent/server/controlRoutes.ts +10 -0
- package/agent/server/controlStatus.ts +26 -5
- package/agent/server/databaseRoutes.ts +13 -17
- package/agent/server/errors.ts +6 -0
- package/agent/server/handler.ts +2 -1
- package/agent/server/router.ts +2 -1
- package/agent/server/workflowReadRoutes.ts +9 -11
- package/agent/shutdown.ts +3 -2
- package/agent/workflow/sqlite.ts +1 -1
- package/dist/.vite/manifest.json +537 -575
- package/dist/assets/AddJob-CiwWycYG.js +3 -0
- package/dist/assets/Alerts-DzKKoA9U.js +1 -0
- package/dist/assets/AreaChart-Db2UVnaK.js +1 -0
- package/dist/assets/Benchmark-CHYDL31K.js +1 -0
- package/dist/assets/BulkAddJobs-GRMVnf0j.js +5 -0
- package/dist/assets/Button-_aSJvRoW.js +1 -0
- package/dist/assets/Card-egIDLwVk.js +1 -0
- package/dist/assets/Cron-XL0PdUEc.js +1 -0
- package/dist/assets/CronManager-Cqtg9Zr8.js +1 -0
- package/dist/assets/{Database-DV2pcDLL.js → Database-BoxVpjts.js} +3 -3
- package/dist/assets/Diagnostics-B3QSQuFF.js +1 -0
- package/dist/assets/Dlq-DHOfgORa.js +1 -0
- package/dist/assets/DlqControl-BY1e55-x.js +1 -0
- package/dist/assets/DlqPro-CfwKDcpc.js +1 -0
- package/dist/assets/Fleet-Bkbq0dFB.js +1 -0
- package/dist/assets/Flows-CDCQrPit.js +2 -0
- package/dist/assets/JobInspector-Bw3Gs1Iy.js +2 -0
- package/dist/assets/Jobs-IrlneOy6.js +1 -0
- package/dist/assets/JobsPro-vlPd6Ows.js +1 -0
- package/dist/assets/Logs-DG7cK-tF.js +1 -0
- package/dist/assets/LogsPro-ClSqFKys.js +1 -0
- package/dist/assets/{McpServer-fVy27Mof.js → McpServer-DoNFY0Pj.js} +1 -1
- package/dist/assets/{Metrics-Ba46pdzT.js → Metrics-BkePZiCZ.js} +1 -1
- package/dist/assets/MetricsPro-ooSvpQ3H.js +1 -0
- package/dist/assets/{Overview-DV2qo5v3.js → Overview-CuWmPRra.js} +1 -1
- package/dist/assets/{PageHeader-CvIyaFOO.js → PageHeader-CQzNsw8r.js} +1 -1
- package/dist/assets/Pagination-CSkzhNW6.js +1 -0
- package/dist/assets/QueueActions-BBxRt-t0.js +1 -0
- package/dist/assets/QueueControl-C01l6bBJ.js +1 -0
- package/dist/assets/QueueDetail-gSf9Tb7G.js +1 -0
- package/dist/assets/QueueDetailPro-BKszqI0M.js +1 -0
- package/dist/assets/Queues-BAg2nSz0.js +1 -0
- package/dist/assets/QueuesOverview-BLSjiYsA.js +1 -0
- package/dist/assets/{S3Backup-DNABHR2Q.js → S3Backup-Ci4dJPP_.js} +1 -1
- package/dist/assets/S3BackupPro-DcjlrzC5.js +3 -0
- package/dist/assets/ServerControl-SiZBNo9P.js +3 -0
- package/dist/assets/Settings-DR_iqW0T.js +1 -0
- package/dist/assets/StatusBadge-DereLzOj.js +1 -0
- package/dist/assets/{Usage-1KxG1mJ9.js → Usage-ZWfB7PcR.js} +1 -1
- package/dist/assets/UsagePro-BjdeS2zb.js +1 -0
- package/dist/assets/Webhooks-BonYUgMo.js +1 -0
- package/dist/assets/Workers-C1h6hCPp.js +1 -0
- package/dist/assets/WorkersPro-B0f_Nfdz.js +1 -0
- package/dist/assets/Workflows-CqZZ96EK.js +1 -0
- package/dist/assets/{api-BgWE-705.js → api-D9aT0ND7.js} +1 -1
- package/dist/assets/bq-DR2BTISO.js +1 -0
- package/dist/assets/classicJobsData-Csj4iihY.js +1 -0
- package/dist/assets/connectionStore-CVjQyIZv.js +1 -0
- package/dist/assets/controlConnectionEpoch-ChAeMMLk.js +1 -0
- package/dist/assets/feedback-CtGN_kqB.js +1 -0
- package/dist/assets/form-DG3X6cLL.js +1 -0
- package/dist/assets/{icons-BVzwsfbG.js → icons-DH9SS1DA.js} +1 -1
- package/dist/assets/index-Bat1DN5U.js +8 -0
- package/dist/assets/react-vendor-CFL9l8LK.js +11 -0
- package/dist/assets/{cn-zFEt5SO8.js → rolldown-runtime-QTnfLwEv.js} +1 -1
- package/dist/assets/{toastStore-IZn6OPLZ.js → toastStore-XmMX7A5W.js} +1 -1
- package/dist/assets/useControlActionGuard-1i7aFA7E.js +1 -0
- package/dist/assets/usePolledData-CEyyLRYa.js +1 -0
- package/dist/assets/useServerActionGuard-CUx8TOAC.js +1 -0
- package/dist/assets/useThroughputSeries-CeFx-Mwq.js +1 -0
- package/dist/index.html +14 -14
- package/package.json +16 -10
- package/scripts/embedded.gen.ts +152 -162
- package/scripts/serve.ts +10 -15
- package/scripts/serveHandler.ts +28 -1
- package/dist/assets/AddJob-FNaPbs_V.js +0 -3
- package/dist/assets/Alerts-vzIYtFpW.js +0 -1
- package/dist/assets/AreaChart-DEAalJ6P.js +0 -1
- package/dist/assets/Benchmark-C16tT4pF.js +0 -1
- package/dist/assets/BulkAddJobs-IiL1uud0.js +0 -5
- package/dist/assets/Button-Ch1W94fJ.js +0 -1
- package/dist/assets/Card-CWxrC8OY.js +0 -1
- package/dist/assets/CopilotPanel-FlAW3RlL.js +0 -44
- package/dist/assets/Cron-1DZTZWXO.js +0 -1
- package/dist/assets/CronManager-B6xLLgI5.js +0 -1
- package/dist/assets/Diagnostics-B6apZrC5.js +0 -1
- package/dist/assets/Dlq-MRmkQrNC.js +0 -1
- package/dist/assets/DlqControl-DNJPVOTF.js +0 -1
- package/dist/assets/DlqPro-CwtTDwGN.js +0 -1
- package/dist/assets/Fleet-Bdrj9bLI.js +0 -1
- package/dist/assets/Flows-1dC8F_wx.js +0 -2
- package/dist/assets/JobInspector-Ct9Ga-UT.js +0 -2
- package/dist/assets/Jobs-Chqv0RuL.js +0 -1
- package/dist/assets/JobsPro-CLzOhKAL.js +0 -1
- package/dist/assets/Logs-C5PNP9Wq.js +0 -1
- package/dist/assets/LogsPro-B3KwTSsn.js +0 -1
- package/dist/assets/MetricsPro-B9rD_KQc.js +0 -1
- package/dist/assets/Pagination-x-Cwgrul.js +0 -1
- package/dist/assets/QueueActions-BWnmNEqV.js +0 -1
- package/dist/assets/QueueControl-DqBvuDnF.js +0 -1
- package/dist/assets/QueueDetail-COSH9bJl.js +0 -1
- package/dist/assets/QueueDetailPro-ClKtyHIf.js +0 -1
- package/dist/assets/Queues-D2-R8nYh.js +0 -1
- package/dist/assets/QueuesOverview-tokquA3g.js +0 -1
- package/dist/assets/S3BackupPro-CDX5WQUY.js +0 -3
- package/dist/assets/ServerControl-BmccMNW9.js +0 -3
- package/dist/assets/Settings-UcujwvKv.js +0 -1
- package/dist/assets/StatusBadge-BoOVTnKu.js +0 -1
- package/dist/assets/UsagePro-BGLufsE7.js +0 -1
- package/dist/assets/Webhooks-DT2LK17V.js +0 -1
- package/dist/assets/Workers-BX1qspaQ.js +0 -1
- package/dist/assets/WorkersPro-BsUQVgQZ.js +0 -1
- package/dist/assets/Workflows-DZZA6aGW.js +0 -1
- package/dist/assets/bq-F5BbTG1T.js +0 -1
- package/dist/assets/connectionStore-BJLihGaC.js +0 -1
- package/dist/assets/controlConnectionEpoch-CZsS0wAb.js +0 -1
- package/dist/assets/dist-1f1fMHVO.js +0 -11
- package/dist/assets/dist-BlWBaCN6.js +0 -11
- package/dist/assets/dist-DZL8soAh.js +0 -79
- package/dist/assets/dist-DjvZiKhB.js +0 -2
- package/dist/assets/dist-DpZcbP9W.js +0 -11
- package/dist/assets/feedback-QDN1AsYt.js +0 -1
- package/dist/assets/form-C4oby9pI.js +0 -1
- package/dist/assets/index-8Ii-_Rml.js +0 -8
- package/dist/assets/react-vendor-CvwrP0tU.js +0 -11
- package/dist/assets/useControlActionGuard-B-bzKZKI.js +0 -1
- package/dist/assets/usePolledData-0CVelkl2.js +0 -1
- package/dist/assets/useServerActionGuard-uGePilQQ.js +0 -1
- package/dist/assets/useThroughputSeries-DgO8uicf.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{t as i}from"./bq-DR2BTISO.js";import{t as a}from"./toastStore-XmMX7A5W.js";import{S as o,T as s,b as c,n as l,x as u}from"./icons-DH9SS1DA.js";import{r as d}from"./StatusBadge-DereLzOj.js";import{n as f}from"./usePolledData-CEyyLRYa.js";import{n as p,t as m}from"./Button-_aSJvRoW.js";import{i as h,n as g,r as _}from"./feedback-CtGN_kqB.js";import{t as v}from"./PageHeader-CQzNsw8r.js";import{s as y}from"./format-Cg7VCIZW.js";import{r as b}from"./index-Bat1DN5U.js";import{t as x}from"./Pagination-CSkzhNW6.js";import{r as S,t as C}from"./useServerActionGuard-CUx8TOAC.js";import{t as w}from"./promisePool-BVfQ9n9Q.js";var T=e(t(),1),E=r(),D=[[`waiting`,`Waiting`],[`prioritized`,`Prioritized`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function O({rows:e,hasData:t,error:r,search:i,sortCol:a,sortDir:s,bulkBusy:f,busy:m,onSort:h,onToggle:g}){return(0,E.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,E.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),D.map(([e,t])=>(0,E.jsx)(`th`,{"aria-sort":a===e?s===`desc`?`descending`:`ascending`:void 0,className:`px-5 py-3 text-right font-medium`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>h(e),className:`inline-flex items-center gap-1 rounded uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[t,a===e&&(0,E.jsx)(`span`,{"aria-hidden":`true`,children:s===`desc`?`↓`:`↑`})]})},e)),(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,E.jsx)(`th`,{className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,E.jsx)(`tbody`,{children:!t&&r?(0,E.jsx)(`tr`,{children:(0,E.jsxs)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,r.message,`. Retry above.`]})}):e.length===0?(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-faint`,children:i?`No queues match your search.`:`No queues yet.`})}):e.map(e=>{let t=f||m.has(e.name);return(0,E.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(n,{to:`/queues/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,E.jsx)(o,{className:`size-4 text-faint`}),e.name]})}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:y(e.counts.waiting)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:y(e.counts.prioritized)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:y(e.counts.active)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:y(e.counts.completed)}),(0,E.jsx)(`td`,{className:d(`px-5 py-3 text-right tnum`,e.counts.failed?`text-danger`:`text-muted`),children:y(e.counts.failed)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:y(e.counts.delayed)}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`span`,{className:d(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:[(0,E.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,E.jsx)(p,{"aria-label":e.paused?`Resume queue`:`Pause queue`,disabled:t,onClick:t=>{t.stopPropagation(),g(e)},children:e.paused?(0,E.jsx)(u,{className:`size-3.5 text-success`}):(0,E.jsx)(c,{className:`size-3.5 text-warning`})}),(0,E.jsx)(l,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},e.name)})})]})})}var k=6,A=15,j=[];function M(){let[e,t]=(0,T.useState)(``),[n,r]=(0,T.useState)(0),[o,l]=(0,T.useState)(new Set),[p,D]=(0,T.useState)(!1),[M,N]=(0,T.useState)(null),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(`desc`),R=S(`queues-overview`);(0,T.useEffect)(()=>{l(new Set),D(!1),N(null)},[R.scopeKey]);let{data:z,error:B,loading:V,refetch:H}=f(()=>i.queuesSummary(),[]),U=z??j,W=e=>{P===e?I===`desc`?L(`asc`):F(null):(F(e),L(`desc`)),r(0)},G=(0,T.useMemo)(()=>{let t=e.trim().toLowerCase(),n=[...t?U.filter(e=>e.name.toLowerCase().includes(t)):U].sort((e,t)=>e.name.localeCompare(t.name));if(P){let e=I===`desc`?-1:1;n.sort((t,n)=>e*(t.counts[P]-n.counts[P]))}return n},[U,e,P,I]),K=(0,T.useMemo)(()=>U.reduce((e,t)=>(e.waiting+=t.counts.waiting,e.prioritized+=t.counts.prioritized,e.active+=t.counts.active,e.failed+=t.counts.failed,e.paused+=+!!t.paused,e),{waiting:0,prioritized:0,active:0,failed:0,paused:0}),[U]),q=Math.max(1,Math.ceil(G.length/A)),J=Math.min(n,q-1),Y=G.slice(J*A,J*A+A),X=async e=>{let t=R.begin(`queue:${e.name}`);if(t){l(t=>new Set(t).add(e.name)),N(null);try{if(C(await(e.paused?i.resume(e.name):i.pause(e.name)),e.paused?`Resume queue`:`Pause queue`),!t.isCurrent())return;N({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`}),H()}catch(n){if(!t.isCurrent())return;N({ok:!1,text:n.message}),a.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,n.message)}finally{t.finish()&&l(t=>{let n=new Set(t);return n.delete(e.name),n})}}},Z=async e=>{let t=U.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){a.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;let n=R.begin([`bulk`,...U.map(e=>`queue:${e.name}`)]);if(n){D(!0),N(null);try{let r=await w(t,k,async t=>{if(!n.isCurrent())throw Error(`Queue action target changed`);C(e===`pause`?await i.pause(t.name):await i.resume(t.name),`${e===`pause`?`Pause`:`Resume`} ${t.name}`)});if(!n.isCurrent())return;let o=r.filter(e=>e.status===`rejected`).length,s=`${e===`pause`?`Paused`:`Resumed`} ${t.length-o}/${t.length} queues${o?`, ${o} failed`:``}`;N({ok:o===0,text:s}),o===0?a.success(s):a.error(s),H()}finally{n.finish()&&D(!1)}}};return V&&!z&&!B?(0,E.jsx)(_,{label:`Loading queues…`}):B&&!z?(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:`Queue inventory unavailable`}),(0,E.jsx)(g,{error:B,onRetry:H})]}):(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:z?`${U.length} queues`:`Queue inventory unavailable`,live:!!z&&!B,actions:U.length>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m,{variant:`warning`,size:`sm`,disabled:p||o.size>0||K.paused>=U.length,onClick:()=>Z(`pause`),children:[(0,E.jsx)(c,{className:`size-3.5`}),` Pause all`]}),(0,E.jsxs)(m,{variant:`success`,size:`sm`,disabled:p||o.size>0||K.paused===0,onClick:()=>Z(`resume`),children:[(0,E.jsx)(u,{className:`size-3.5`}),` Resume all`]})]}):void 0}),B&&(0,E.jsx)(h,{message:`Queue refresh failed — showing the last successful inventory.`,onRetry:H}),(0,E.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,E.jsx)(b,{label:`Waiting`,value:y(K.waiting),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Prioritized`,value:y(K.prioritized),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Active`,value:y(K.active),tone:`blue`,compact:!0}),(0,E.jsx)(b,{label:`Failed`,value:y(K.failed),tone:K.failed?`red`:`default`,compact:!0}),(0,E.jsx)(b,{label:`Paused`,value:y(K.paused),tone:K.paused?`amber`:`default`,compact:!0})]}),(0,E.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,E.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,E.jsx)(`input`,{value:e,onChange:e=>{t(e.target.value),r(0)},placeholder:`Search queues…`,"aria-label":`Filter queues`,name:`queue-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),M&&(0,E.jsx)(`div`,{role:`status`,className:d(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),(0,E.jsx)(O,{rows:Y,hasData:!!z,error:B,search:e,sortCol:P,sortDir:I,bulkBusy:p,busy:o,onSort:W,onToggle:e=>void X(e)}),(0,E.jsx)(x,{page:J,pageSize:A,total:G.length,onPageChange:r,label:`queues`})]})}export{M as QueuesOverview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./react-vendor-CFL9l8LK.js";import{t}from"./api-D9aT0ND7.js";import{n}from"./usePolledData-CEyyLRYa.js";import{n as r,t as i}from"./Card-egIDLwVk.js";import{i as a,n as o,r as s}from"./feedback-CtGN_kqB.js";import{t as c}from"./PageHeader-CQzNsw8r.js";var l=e(),u=[[`S3_BACKUP_ENABLED`,`Set to 1 to enable periodic backups`],[`S3_BUCKET`,`Target bucket name`],[`S3_REGION`,`Bucket region (default us-east-1)`],[`S3_ENDPOINT`,`Custom endpoint (for S3-compatible stores)`],[`S3_ACCESS_KEY_ID`,`Access key`],[`S3_SECRET_ACCESS_KEY`,`Secret key`],[`S3_BACKUP_INTERVAL`,`Interval in ms (default 21600000 = 6h)`],[`S3_BACKUP_RETENTION`,`Backups to keep (default 7)`]];function d(){let{data:e,error:d,loading:f,refetch:p}=n(async()=>{let e=await t.storage();if(!e?.data||typeof e.data.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data`);return e},[]);return(0,l.jsxs)(`div`,{children:[d&&e&&(0,l.jsx)(a,{message:`Storage refresh failed — showing the last successful status.`,onRetry:p}),(0,l.jsx)(c,{title:`S3 Backup`,description:`SQLite snapshot backups to object storage.`,live:!!e?.data&&!d}),(0,l.jsx)(`div`,{className:`mb-6 rounded-lg border border-line bg-surface/60 px-4 py-3 text-sm text-muted`,children:`S3 backup runs on the server and is configured via environment variables — it cannot be toggled from the dashboard. The status below reflects the connected server's storage.`}),(0,l.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,l.jsxs)(i,{children:[(0,l.jsx)(r,{title:`Storage status`}),d&&!e?(0,l.jsx)(o,{error:d,onRetry:p}):f&&!e?(0,l.jsx)(s,{}):(0,l.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,l.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,l.jsx)(`dt`,{className:`text-muted`,children:`Disk`}),(0,l.jsx)(`dd`,{className:e?.data?e.data.diskFull?`font-medium text-red-400`:`font-medium text-emerald-400`:`font-medium text-muted`,children:e?.data?e.data.diskFull?`Full`:`Healthy`:`Unavailable`})]}),(0,l.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,l.jsx)(`dt`,{className:`text-muted`,children:`Error`}),(0,l.jsx)(`dd`,{className:`font-mono text-xs text-fg`,children:e?.data?.error?String(e.data.error):`—`})]})]})]}),(0,l.jsxs)(i,{children:[(0,l.jsx)(r,{title:`Configuration (server env)`}),(0,l.jsx)(`dl`,{className:`divide-y divide-line text-sm`,children:u.map(([e,t])=>(0,l.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-2.5`,children:[(0,l.jsx)(`dt`,{className:`font-mono text-xs text-accent/90`,children:e}),(0,l.jsx)(`dd`,{className:`text-right text-xs text-faint`,children:t})]},e))})]})]})]})}export{d as S3Backup};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{a as r,f as i,m as a,o,p as s}from"./connectionStore-CVjQyIZv.js";import{c,l,o as u,s as d,t as f}from"./bq-DR2BTISO.js";import{w as p}from"./icons-DH9SS1DA.js";import{n as m}from"./usePolledData-CEyyLRYa.js";import{t as h}from"./Button-_aSJvRoW.js";import{t as g}from"./Card-egIDLwVk.js";import{t as _}from"./PageHeader-CQzNsw8r.js";import{a as v}from"./index-Bat1DN5U.js";import{a as y,n as b,r as x,t as S}from"./form-DG3X6cLL.js";var C=e(t(),1),ee=`bq-dash-s3`,w=2,T=[`disabled`,`6h`,`12h`,`24h`],E={endpoint:``,region:`us-east-1`,bucket:``,schedule:`disabled`,pathPrefix:``,virtualHostedStyle:`auto`,retention:7};function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e,t,n){return typeof e==`string`&&e.length<=n?e:t}function k(e){return T.includes(e)?e:`disabled`}function te(e){return e===`virtual-hosted`||e===`path-style`?e:`auto`}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=1&&e<=1e6}function ne(e){return A(e)?e:E.retention}function j(e){let t=D(e)?e:{};return{endpoint:O(t.endpoint,E.endpoint,2048),region:O(t.region,E.region,128),bucket:O(t.bucket,E.bucket,255),schedule:k(t.schedule),pathPrefix:O(t.pathPrefix,E.pathPrefix,1024),virtualHostedStyle:te(t.virtualHostedStyle),retention:ne(t.retention)}}function M(e){return j(e)}function N(){try{return globalThis.localStorage??null}catch{return null}}function P(e){try{let t=JSON.parse(e),n=D(t)?t:{},r=j(`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:w})}}catch{return null}}var F={getItem(e){let t=N();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=P(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{N()?.setItem(e,t)}catch{}},removeItem(e){try{N()?.removeItem(e)}catch{}}},I=a()(s(e=>({...E,accessKeyId:``,secretAccessKey:``,sessionToken:``,set:t=>e(e=>{let n={...e,...t};return{...j(n),accessKeyId:O(n.accessKeyId,``,512),secretAccessKey:O(n.secretAccessKey,``,2048),sessionToken:O(n.sessionToken,``,4096)}})}),{name:ee,version:w,storage:i(()=>F),partialize:M,migrate:j,merge:(e,t)=>({...t,...j(e),accessKeyId:``,secretAccessKey:``,sessionToken:``})}));function L(){let e=Promise.resolve();return{async run(t,n){let r=e,i;e=new Promise(e=>{i=e}),await r;try{return n?.throwIfAborted(),await t()}finally{i()}}}}var re=new Set([`enabled`,`bucket`,`endpoint`,`interval`,`retention`]),ie=new Set([`key`,`size`,`date`]);function ae(e){let t=z(e,re,`Backup status`);return typeof t.enabled!=`boolean`&&H(`Backup status`),{enabled:t.enabled,bucket:B(t.bucket,`Backup status bucket`,1024),endpoint:B(t.endpoint,`Backup status endpoint`,4096),interval:B(t.interval,`Backup status interval`,128),retention:B(t.retention,`Backup status retention`,128)}}function R(e){(!Array.isArray(e)||e.length>2e4)&&H(`Backup list`);let t=new Set,n=0;return e.map((e,r)=>{let i=z(e,ie,`Backup list item ${r}`),a=B(i.key,`Backup list item ${r} key`,2048),o=B(i.size,`Backup list item ${r} size`,128),s=B(i.date,`Backup list item ${r} date`,128);return n+=a.length+o.length+s.length,(n>2*1024*1024||t.has(a)||!V(s))&&H(`Backup list item ${r}`),t.add(a),{key:a,size:o,date:s}})}function z(e,t,n){(!e||typeof e!=`object`||Array.isArray(e))&&H(n);let r=e;return Object.keys(r).some(e=>!t.has(e))&&H(n),r}function B(e,t,n){return(typeof e!=`string`||e.length<1||e.length>n)&&H(t),e}function V(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 H(e){throw Error(`${e} returned an invalid Bunqueue 2.9.3 contract`)}function U(e){return e.capture?.()??e}async function W(e,t,n){let r=await t.run(async()=>{let t=G(()=>e.restoreContext()),n=await G(()=>e.status().then(e=>ae(e.data)));return{context:t,list:await G(()=>e.list().then(e=>R(e.data))),status:n}},n),{list:i,status:a}=r,o=await r.context,s=Array.from(new Set([a,i,o].filter(e=>e.status===`rejected`).map(e=>e.reason instanceof Error?e.reason.message:String(e.reason))));return{status:a.status===`fulfilled`?a.value:void 0,backups:i.status===`fulfilled`?i.value:[],context:o.status===`fulfilled`?o.value:void 0,errors:s}}async function G(e){try{return{status:`fulfilled`,value:await e()}}catch(e){return{status:`rejected`,reason:e}}}function K(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 q=e=>({method:`POST`,headers:e===void 0?void 0:{"Content-Type":`application/json`},body:e===void 0?void 0:JSON.stringify(e)});function J(e,t){let n=async(n,r)=>(await t(`${n}?target=${encodeURIComponent(e())}`,r)).result;return{status:()=>n(`/backup/status`),list:()=>n(`/backup/list`),backupNow:()=>n(`/backup/now`,q()),restore:(e,t)=>n(`/backup/restore`,q({key:e,database:t})),configure:e=>n(`/backup/configure`,q({environment:e})),restoreContext:async()=>{let e=await t(`/control/status`);return{serverStatus:e.status,database:e.db??null}}}}function oe(){let e=r(),t=l(),n={...u(t)};return J(()=>e,(e,r)=>c(t.baseUrl,e,n,r,!0,`agent`))}var se={...J(r,d),capture:oe},Y=n();function ce({environmentText:e,pollIntervalMs:t=15e3,repository:n=se}){let r=o(e=>JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken])),i=(0,C.useRef)(!0),a=(0,C.useRef)(null);(!a.current||a.current.connectionIdentity!==r||a.current.repository!==n)&&(a.current={connectionIdentity:r,repository:n});let[s]=(0,C.useState)(L),c=m(e=>W(U(n),s,e),[n,s],{intervalMs:t}),[l,u]=(0,C.useState)(``),[d,f]=(0,C.useState)(``),[p,h]=(0,C.useState)(``),g=(0,C.useRef)(!1);(0,C.useEffect)(()=>(i.current=!0,()=>{i.current=!1}),[]),(0,C.useEffect)(()=>{g.current=!1,u(``),f(``),h(``)},[r,n]);let _=async(e,t)=>{if(g.current)return;let r=a.current;g.current=!0,u(e),f(``),h(``);try{let o=U(n),l=await s.run(async()=>{if(!X(r,a,i))throw Error(`Backup operation scope changed before admission.`);return t(o)});if(!X(r,a,i))return;let u=l?.message;h(u??`${e} completed.`),await c.refetch()}catch(e){X(r,a,i)&&f(e instanceof Error?e.message:String(e))}finally{X(r,a,i)&&(g.current=!1,u(``))}},v=()=>{e&&window.confirm(`Apply this S3 configuration to the managed server? A restart is required.`)&&_(`Configuration`,t=>t.configure(K(e)))},y=()=>{window.confirm(`Create a transactionally consistent S3 backup now?`)&&_(`Backup`,e=>e.backupNow())},b=e=>{let t=c.data?.context?.database;!t||c.data?.context?.serverStatus!==`stopped`||window.prompt(`Type RESTORE to replace ${t.path} with ${e}`)===`RESTORE`&&_(`Restore`,n=>n.restore(e,t))},x=c.data;return(0,Y.jsxs)(`section`,{className:`mt-6 overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,Y.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Live backup operations`}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Official Bunqueue 2.9.3 backup CLI, executed by the local control agent.`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:!e||!!l,onClick:v,className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Apply configuration`}),(0,Y.jsx)(`button`,{type:`button`,disabled:!!l,onClick:y,className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:l===`Backup`?`Backing up…`:`Backup now`}),(0,Y.jsx)(`button`,{type:`button`,disabled:!!l||c.loading,onClick:()=>void c.refetch(),className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Refresh`})]})]}),x?.status&&(0,Y.jsx)(le,{status:x.status,context:x.context}),d||x?.errors.length?(0,Y.jsx)(`div`,{role:`alert`,className:`border-b border-line px-4 py-3 text-xs text-danger`,children:d||x?.errors.join(` · `)}):null,p&&(0,Y.jsx)(`div`,{role:`status`,className:`border-b border-line px-4 py-3 text-xs text-success`,children:p}),(0,Y.jsx)(ue,{rows:x?.backups??[],canRestore:x?.context?.serverStatus===`stopped`&&!!x.context.database,busy:!!l,onRestore:b})]})}function le({status:e,context:t}){return(0,Y.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,Y.jsxs)(`div`,{className:`border-b border-line px-4 py-3 last:border-b-0 xl:border-r xl:border-b-0`,children:[(0,Y.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-faint`,children:e}),(0,Y.jsx)(`dd`,{className:`mt-1 truncate text-xs text-fg`,title:t,children:t})]},e))})}function ue({rows:e,canRestore:t,busy:n,onRestore:r}){return e.length?(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full min-w-[680px] text-left text-xs`,children:[(0,Y.jsx)(`thead`,{className:`border-b border-line text-[10px] uppercase tracking-wider text-faint`,children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Object key`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Size`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 font-medium`,children:`Created`}),(0,Y.jsx)(`th`,{className:`px-4 py-2 text-right font-medium`,children:`Restore`})]})}),(0,Y.jsx)(`tbody`,{className:`divide-y divide-line`,children:e.map(e=>(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`max-w-md truncate px-4 py-3 font-mono text-fg`,title:e.key,children:e.key}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-muted`,children:e.size}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-muted`,children:e.date}),(0,Y.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,Y.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,Y.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`No backup objects returned.`})}function X(e,t,n){return n.current&&e!==null&&t.current===e}function de(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.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken]),fe={"6h":360*60*1e3,"12h":720*60*1e3,"24h":1440*60*1e3};function Q(e,t){return`${e}=${typeof t==`string`?JSON.stringify(t):String(t)}`}function pe(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:Q(`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=[Q(`S3_BACKUP_ENABLED`,!0),Q(`S3_ACCESS_KEY_ID`,a),Q(`S3_SECRET_ACCESS_KEY`,o),Q(`S3_BUCKET`,i),Q(`S3_REGION`,r),Q(`S3_BACKUP_RETENTION`,e.retention)];return s&&l.push(Q(`S3_SESSION_TOKEN`,s)),e.virtualHostedStyle!==`auto`&&l.push(Q(`S3_VIRTUAL_HOSTED_STYLE`,e.virtualHostedStyle===`virtual-hosted`)),n&&l.push(Q(`S3_ENDPOINT`,n)),c&&l.push(Q(`S3_BACKUP_PREFIX`,c)),l.push(Q(`S3_BACKUP_INTERVAL`,fe[e.schedule])),{ok:!0,value:l.join(`
|
|
3
|
+
`)}}function $(e){let t=e.trim();return t?Number(t):NaN}function me(e,t){let[n,r]=(0,C.useState)(()=>({text:String(e),base:e})),i=n.base===e?n.text:String(e);return{text:i,value:$(i),change(n){let i=$(n),a=A(i);a&&t(i),r({text:n,base:a?i:e})}}}function he({environment:e}){return(0,Y.jsxs)(g,{children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Server environment`}),(0,Y.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,Y.jsx)(v,{value:e.value})]}),e.ok?(0,Y.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,Y.jsx)(`ul`,{className:`space-y-1 text-sm text-danger`,"aria-label":`Configuration errors`,children:e.errors.map(e=>(0,Y.jsxs)(`li`,{children:[`• `,e]},e))})]})}function ge(){let e=I(),t=me(e.retention,t=>e.set({retention:t})),n=o(Z),[r,i]=(0,C.useState)(null),[a,s]=(0,C.useState)(null),c=(0,C.useRef)(0),l=pe({...e,retention:t.value}),u=r?.target===n?r:null,d=a===n;return(0,C.useEffect)(()=>(c.current++,i(null),s(null),()=>{c.current++}),[n]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(_,{title:`S3 Backup Setup`,description:`Configure and operate Bunqueue 2.9.3 S3 backups.`}),(0,Y.jsxs)(`div`,{className:`mb-6 flex items-center justify-between rounded-xl border border-line bg-surface px-5 py-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-lg bg-surface-2 text-faint`,children:(0,Y.jsx)(p,{className:`size-5`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`font-semibold text-fg`,children:l.ok?`Configuration draft complete`:`Configuration draft incomplete`}),(0,Y.jsx)(`div`,{className:`text-xs text-faint`,children:l.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,Y.jsx)(`span`,{className:l.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:l.ok?`Ready`:`Configure`})]}),(0,Y.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,Y.jsxs)(g,{className:`mb-6`,children:[(0,Y.jsx)(`h2`,{className:`mb-1 text-base font-semibold text-fg`,children:`Connection Settings`}),(0,Y.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,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,Y.jsx)(S,{label:`Endpoint`,children:(0,Y.jsx)(b,{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,Y.jsx)(S,{label:`Region`,children:(0,Y.jsx)(b,{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,Y.jsx)(`div`,{className:`md:col-span-2`,children:(0,Y.jsx)(S,{label:`Bucket name`,children:(0,Y.jsx)(b,{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,Y.jsx)(S,{label:`Access key ID`,children:(0,Y.jsx)(b,{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,Y.jsx)(S,{label:`Secret access key`,children:(0,Y.jsx)(b,{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,Y.jsx)(`div`,{className:`md:col-span-2`,children:(0,Y.jsx)(S,{label:`Session token (optional, for temporary STS credentials)`,children:(0,Y.jsx)(b,{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,Y.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,Y.jsxs)(`div`,{children:[(0,Y.jsx)(x,{htmlFor:`s3-backup-schedule`,children:`Backup interval`}),(0,Y.jsxs)(y,{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,Y.jsx)(`option`,{value:`disabled`,children:`Disabled`}),(0,Y.jsx)(`option`,{value:`6h`,children:`Every 6 hours`}),(0,Y.jsx)(`option`,{value:`12h`,children:`Every 12 hours`}),(0,Y.jsx)(`option`,{value:`24h`,children:`Every 24 hours`})]})]}),(0,Y.jsx)(S,{label:`Path prefix (optional)`,children:(0,Y.jsx)(b,{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,Y.jsxs)(`div`,{children:[(0,Y.jsx)(x,{htmlFor:`s3-addressing-style`,children:`Addressing style`}),(0,Y.jsxs)(y,{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,Y.jsx)(`option`,{value:`auto`,children:`Provider default`}),(0,Y.jsx)(`option`,{value:`virtual-hosted`,children:`Virtual-hosted style`}),(0,Y.jsx)(`option`,{value:`path-style`,children:`Path style`})]})]}),(0,Y.jsx)(S,{label:`Backups to retain`,children:(0,Y.jsx)(b,{name:`s3-retention`,type:`number`,min:1,max:1e6,step:1,value:t.text,onChange:e=>t.change(e.target.value),inputMode:`numeric`})})]}),(0,Y.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(h,{onClick:async()=>{let e=n,t=++c.current;i(null),s(e);try{let n=await f.storage();if(t!==c.current||Z(o.getState())!==e)return;let r=de(n);i({target:e,ok:!r.diskFull,msg:r.diskFull?`Server disk is full`:`Server disk healthy — this does not validate the S3 credentials`})}catch(n){if(t!==c.current||Z(o.getState())!==e)return;i({target:e,ok:!1,msg:n.message})}finally{t===c.current&&s(null)}},children:d?`Checking server storage…`:`Check server storage`}),(0,Y.jsx)(`span`,{className:`text-xs text-faint`,children:`This checks SQLite disk health only, not S3 connectivity.`}),u&&(0,Y.jsx)(`span`,{role:`status`,className:u.ok?`text-xs text-success`:`text-xs text-danger`,children:u.msg})]})]}),(0,Y.jsx)(he,{environment:l}),(0,Y.jsx)(ce,{environmentText:l.ok?l.value:void 0})]})}export{ge as S3BackupPro};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{t as r}from"./bq-DR2BTISO.js";import{C as i,T as a,b as o,x as s}from"./icons-DH9SS1DA.js";import{r as c}from"./StatusBadge-DereLzOj.js";import{n as l}from"./usePolledData-CEyyLRYa.js";import{t as u}from"./Button-_aSJvRoW.js";import{n as d,t as f}from"./Card-egIDLwVk.js";import{i as p,n as m,r as h}from"./feedback-CtGN_kqB.js";import{t as g}from"./PageHeader-CQzNsw8r.js";import{f as _,i as v,l as y,n as b,u as x}from"./format-Cg7VCIZW.js";import{a as S}from"./index-Bat1DN5U.js";import{i as C,n as w,t as T}from"./form-DG3X6cLL.js";import{t as E}from"./useControlActionGuard-1i7aFA7E.js";var D=e(t(),1),O=n();function k({children:e}){return(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs text-fg`,children:e})}function A({agentBase:e}){return(0,O.jsx)(f,{children:(0,O.jsxs)(`details`,{className:`group`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`How server control works`}),(0,O.jsx)(`span`,{className:`text-xs text-muted transition-transform group-open:rotate-90`,children:`▶`})]}),(0,O.jsxs)(`div`,{className:`mt-4 space-y-4 text-sm leading-relaxed text-muted`,children:[(0,O.jsxs)(`p`,{children:[`A browser can't start or stop an OS process, so the dashboard talks to a small local`,` `,(0,O.jsx)(`span`,{className:`font-medium text-fg`,children:`control agent`}),` (`,(0,O.jsx)(k,{children:e}),`) that supervises the bunqueue server process — start, stop and restart — and streams its logs back here.`]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Launch & environment`}),(0,O.jsxs)(`p`,{children:[`The agent runs your `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Command`}),` and injects`,` `,(0,O.jsx)(k,{children:`HTTP_PORT`}),` and `,(0,O.jsx)(k,{children:`TCP_PORT`}),`, plus `,(0,O.jsx)(k,{children:`BUNQUEUE_DATA_PATH`}),` `,`only for SQLite. Memory and PostgreSQL modes remove every SQLite path alias before launch. Any `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Environment variables`}),` you add are included too. The default `,(0,O.jsx)(k,{children:`bunx bunqueue@2.9.4 start`}),` resolves the verified release; pointing the command at a local entry (e.g.`,` `,(0,O.jsx)(k,{children:`bun run /path/to/bunqueue/src/main.ts`}),`) works without one.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`When changes apply`}),(0,O.jsxs)(`p`,{children:[`Config is editable any time, but `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Command`}),`, ports and data path only take effect on the `,(0,O.jsx)(`span`,{className:`text-fg`,children:`next start/restart`}),` `,`— the running process keeps the config it launched with until then.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Data path`}),(0,O.jsxs)(`p`,{children:[`Relative paths resolve against the `,(0,O.jsx)(`span`,{className:`text-fg`,children:`agent's`}),` working directory. SQLite creates the database `,(0,O.jsx)(`span`,{className:`text-fg`,children:`file`}),` but not its parent `,(0,O.jsx)(`span`,{className:`text-fg`,children:`folder`}),` — if start fails with`,` `,(0,O.jsx)(k,{children:`SQLITE_CANTOPEN`}),`, create the directory first or use a path whose folder already exists.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Security`}),(0,O.jsxs)(`p`,{children:[`The direct agent listener binds `,(0,O.jsx)(k,{children:`127.0.0.1`}),`, locks CORS to an allowlist (never `,(0,O.jsx)(k,{children:`*`}),`), and rejects a disallowed `,(0,O.jsx)(k,{children:`Origin`}),` or`,` `,(0,O.jsx)(k,{children:`Host`}),` with `,(0,O.jsx)(k,{children:`403`}),`. The all-in-one server's `,(0,O.jsx)(k,{children:`/agent`}),` `,`bridge treats LAN and reverse-proxy access as remote: `,(0,O.jsx)(k,{children:`AGENT_TOKEN`}),` is then mandatory for status, logs, database reads and changes alike. Without it, the bridge stays disabled.`]}),(0,O.jsxs)(`p`,{children:[`If you started the agent with `,(0,O.jsx)(k,{children:`AGENT_TOKEN`}),`, enter that token under`,` `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Settings → Agent token`}),` (or when the lock screen prompts). It stays in memory for this browser session; never bake it into a public`,` `,(0,O.jsx)(k,{children:`VITE_*`}),` value.`]})]})]})]})})}function j(e,t,n,r){return{baseline:F(e),id:r,revision:t,scope:n,value:F(e)}}function ee(e,t,n,r,i){return{accepted:F(e),acceptedRevision:t,before:n?F(n):null,beforeRevision:r,ignoreThroughRequestId:i}}function te(e,t,n,r){return P(t,e.accepted)?!1:r!==void 0&&e.ignoreThroughRequestId!==void 0?r<=e.ignoreThroughRequestId:n===void 0?e.before!==null&&P(t,e.before):n===e.beforeRevision||n===e.acceptedRevision}function M(e){if(!L(e))return R();let{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:a}=e;if(typeof t!=`string`||t.trim()===``||!I(n)||!I(r)||n===r||typeof i!=`string`||!L(a)||Object.values(a).some(e=>typeof e!=`string`))return R();let o=N(e.configRevision);return e.configRevision!==void 0&&o===void 0?R():{config:{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:Object.fromEntries(Object.entries(a))},revision:o}}function N(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0}function ne(e){return I(e.httpPort)?I(e.tcpPort)?e.httpPort===e.tcpPort?`HTTP and TCP ports must differ`:null:`TCP port must be an integer between 1 and 65535`:`HTTP port must be an integer between 1 and 65535`}function re(e,t){if(!e)return[];let n=[];return e.command!==t.command&&n.push(`command`),e.httpPort!==t.httpPort&&n.push(`HTTP port`),e.tcpPort!==t.tcpPort&&n.push(`TCP port`),e.dataPath!==t.dataPath&&n.push(`data path`),z(e.extraEnv)!==z(t.extraEnv)&&n.push(`environment variables`),n}function P(e,t){return JSON.stringify(B(e))===JSON.stringify(B(t))}function F(e){return{...e,extraEnv:{...e.extraEnv}}}function I(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=65535}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(){throw Error(`Configuration save returned a malformed response`)}function z(e){return JSON.stringify(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)))}function B(e){return{...e,extraEnv:Object.fromEntries(Object.entries(e.extraEnv).sort(([e],[t])=>e.localeCompare(t)))}}var V=0,H=e=>Object.entries(e).map(([e,t])=>({id:V++,key:e,value:t})),U=e=>{let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return t};function W(e){let t=e.map(e=>e.trim());return[...new Set(t.filter((e,t,n)=>e&&n.indexOf(e)!==t))]}var ie=[`AUTH_TOKENS`,`LOG_LEVEL`,`BUNQUEUE_STORAGE_DRIVER`,`BUNQUEUE_POSTGRES_URL`,`BUNQUEUE_POSTGRES_NAMESPACE`,`BUNQUEUE_POSTGRES_POOL_SIZE`,`BUNQUEUE_MAX_COMPLETED_JOBS`,`BUNQUEUE_COMPLETED_RETENTION_MS`,`S3_BACKUP_ENABLED`,`S3_BUCKET`,`METRICS_ENABLED`];function G({value:e,onChange:t,disabled:n}){let[r,i]=(0,D.useState)(()=>H(e)),a=e=>{i(e),t(U(e))},o=(e,t)=>a(r.map(n=>n.id===e?{...n,...t}:n)),s=(e=``)=>a([...r,{id:V++,key:e,value:``}]),c=e=>a(r.filter(t=>t.id!==e)),l=new Set(r.map(e=>e.key.trim()).filter(Boolean)),d=W(r.map(e=>e.key)),f=[...new Set(r.map(e=>e.key.trim()).filter(e=>e&&(/[\s=]/.test(e)||/[a-z]/.test(e))))];return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.length===0&&(0,O.jsxs)(`p`,{className:`text-xs leading-relaxed text-faint`,children:[`No custom variables. The agent already injects`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`HTTP_PORT`}),`,`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`TCP_PORT`}),`, plus the SQLite data path unless PostgreSQL mode is selected.`]}),r.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-2/5 shrink-0`,children:(0,O.jsx)(w,{id:`env-key-${e.id}`,name:`env-key-${e.id}`,"aria-label":`Variable name${e.key?` ${e.key}`:``}`,className:`font-mono`,placeholder:`KEY`,value:e.key,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{key:t.target.value})})}),(0,O.jsx)(`span`,{className:`text-faint`,children:`=`}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,O.jsx)(w,{id:`env-value-${e.id}`,name:`env-value-${e.id}`,"aria-label":`Value for ${e.key||`variable`}`,className:`font-mono`,placeholder:`value`,value:e.value,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{value:t.target.value})})}),(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.key||`variable`}`,disabled:n,onClick:()=>c(e.id),className:`shrink-0 rounded-md px-2 py-1 text-xs text-faint transition-colors hover:text-danger disabled:opacity-40`,children:`✕`})]},e.id)),d.length>0&&(0,O.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Duplicate key`,d.length>1?`s`:``,` — the last value wins: `,d.join(`, `)]}),f.length>0&&(0,O.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Unusual key`,f.length>1?`s`:``,` — env names are usually UPPER_SNAKE_CASE with no spaces or "=": `,f.join(`, `),`. Saved as-is.`]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,O.jsx)(u,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>s(),children:`+ Add variable`}),ie.filter(e=>!l.has(e)).map(e=>(0,O.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>s(e),className:`rounded-md border border-line bg-surface-2 px-2 py-1 font-mono text-[11px] text-muted transition-colors hover:border-line-strong hover:text-fg disabled:opacity-40`,children:[`+ `,e]},e))]})]})}function K({status:e,onSaved:t,running:n,statusRequestId:a,getStatusRequestSequence:o,transitioning:s}){let c=E(`server-config`),l=(0,D.useRef)(0),p=(0,D.useRef)(null),m=(0,D.useRef)(null),[h,g]=(0,D.useState)(null),[_,v]=(0,D.useState)(!1),[y,b]=(0,D.useState)(!1),[x,S]=(0,D.useState)(null),[C,k]=(0,D.useState)(!1),[A,F]=(0,D.useState)(null);(0,D.useEffect)(()=>{p.current&&clearTimeout(p.current),p.current=null,m.current=null,g(null),v(!1),b(!1),S(null),k(!1),F(null)},[c.scopeKey]),(0,D.useEffect)(()=>{if(!e?.config||_)return;let t=m.current;t&&te(t,e.config,N(e.configRevision),a)||(m.current=null,g(j(e.config,N(e.configRevision),c.scopeKey,++l.current)),k(!1))},[c.scopeKey,_,e?.config,e?.configRevision,a]),(0,D.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let I=h?.scope===c.scopeKey?h:null,L=I?.value??e?.config??null;if(!L)return(0,O.jsx)(f,{children:`Loading…`});let R=t=>{let n=I??j(L,N(e?.configRevision),c.scopeKey,++l.current);g({...n,value:{...n.value,...t}}),v(!0),b(!1),k(!1)},z=re(e?.runningConfig??null,L),B=n&&z.length>0,V=s||x!==null,H=()=>{p.current&&clearTimeout(p.current),b(!0),p.current=setTimeout(()=>{p.current=null,b(!1)},2e3)},U=async n=>{let i=c.begin([`config`,`lifecycle`]);if(!i)return;let a=ne(L);if(a)return i.finish(),F(a);let s=I?.baseline??e?.config,u=I?.revision??N(e?.configRevision);if(u===void 0&&s&&e?.config&&!P(s,e.config))return i.finish(),k(!0),F(`Configuration changed elsewhere; reload the latest values before saving.`);F(null),k(!1),S(n?`restart`:`save`);try{let a=await r.control.setConfig(L,u);if(!i.isCurrent())return;let{config:s,revision:d}=M(a);if(m.current=ee(s,d,e?.config??null,N(e?.configRevision),o?.()),g(j(s,d,c.scopeKey,++l.current)),v(!1),n&&await r.control.restart(),!i.isCurrent())return;H(),await t()}catch(e){if(!i.isCurrent())return;let t=e.message;t.startsWith(`Configuration changed since revision`)&&k(!0),F(t)}finally{i.finish()&&S(null)}},W=()=>U(!1);return(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Configuration`}),(0,O.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:n?`Ports and data path apply on the next restart — edit freely, then restart.`:`Edit and save; the config is used the next time the server starts.`}),(0,O.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),W()},children:[(0,O.jsx)(T,{label:`Command`,hint:`The exact command the agent runs to launch bunqueue. It receives HTTP_PORT and TCP_PORT; BUNQUEUE_DATA_PATH is injected only for SQLite and removed in non-SQLite modes. The default resolves Bunqueue 2.9.4 with bunx; offline installs can point at a local entry.`,children:(0,O.jsx)(w,{name:`server-command`,autoComplete:`off`,spellCheck:!1,value:L.command,disabled:V,onChange:e=>R({command:e.target.value}),placeholder:`bunx bunqueue@2.9.4 start`})}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,O.jsx)(T,{label:`HTTP port`,hint:`Dashboard API + SSE.`,children:(0,O.jsx)(w,{name:`server-http-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:L.httpPort,disabled:V,onChange:e=>R({httpPort:Number(e.target.value)})})}),(0,O.jsx)(T,{label:`TCP port`,hint:`Binary protocol. Must differ from HTTP.`,children:(0,O.jsx)(w,{name:`server-tcp-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:L.tcpPort,disabled:V,onChange:e=>R({tcpPort:Number(e.target.value)})})})]}),(0,O.jsx)(T,{label:`Data path`,hint:`Durable SQLite path for the managed broker and Workflow Engine, relative to the agent's working directory. In PostgreSQL mode the agent keeps it for Workflow state but does not pass it to the broker.`,children:(0,O.jsx)(w,{name:`server-data-path`,autoComplete:`off`,spellCheck:!1,value:L.dataPath,disabled:V,onChange:e=>R({dataPath:e.target.value})})}),(0,O.jsx)(T,{label:`Environment variables`,hint:`Injected on start. Includes Bunqueue 2.9.3 completed-history controls: BUNQUEUE_MAX_COMPLETED_JOBS bounds hot memory, while BUNQUEUE_COMPLETED_RETENTION_MS opts into durable age-based expiry. Memory and PostgreSQL modes remove inherited SQLite path aliases. Applies on the next restart.`,children:(0,O.jsx)(G,{value:L.extraEnv??{},onChange:e=>R({extraEnv:e}),disabled:V},I?.id??`initial`)}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsx)(u,{type:`submit`,variant:`accent`,size:`sm`,disabled:V,children:`Save config`}),n&&(0,O.jsxs)(u,{variant:`warning`,size:`sm`,disabled:V,onClick:()=>{let e=z.length>0?` Changed: ${z.join(`, `)}.`:``;if(window.confirm(`Save configuration and restart the server to apply it?${e}`))return U(!0)},children:[(0,O.jsx)(i,{className:`size-3.5`}),` Save & restart`]}),B&&!y&&(0,O.jsx)(`span`,{className:`text-xs text-warning`,children:`Restart to apply changes`}),y&&(0,O.jsx)(`span`,{className:`text-xs text-success`,children:`Saved`}),C&&(0,O.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,disabled:V,onClick:()=>{e?.config&&(m.current=null,g(j(e.config,N(e.configRevision),c.scopeKey,++l.current)),v(!1),k(!1),F(null))},children:`Reload latest`}),A&&(0,O.jsx)(`span`,{className:`text-xs text-danger`,children:A})]})]})]})}var q=[`all`,`stdout`,`stderr`,`sys`],J=e=>`${new Date(e).toLocaleTimeString([],{hour12:!1})}.${String(e%1e3).padStart(3,`0`)}`,ae=e=>e===`stderr`?`text-danger/90`:e===`sys`?`text-accent/80`:`text-muted`;function oe(e,t=Date.now()){let n=new Blob([e],{type:`text/plain`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`bunqueue-logs-${t}.log`;try{document.body.appendChild(i),i.click()}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}}function se(){let{data:e,error:t,loading:n,refetch:r}=ce(),i=(0,D.useMemo)(()=>e?.lines??[],[e]),[o,s]=(0,D.useState)(`all`),[l,u]=(0,D.useState)(``),[d,g]=(0,D.useState)(!0),[v,y]=(0,D.useState)(!1),b=(0,D.useRef)(null),x=(0,D.useMemo)(()=>{let e=l.trim().toLowerCase();return i.map(e=>e.line.includes(`\x1B`)?{...e,line:_(e.line)}:e).filter(t=>(o===`all`||t.stream===o)&&(!e||t.line.toLowerCase().includes(e)))},[i,o,l]);(0,D.useEffect)(()=>{if(!d)return;let e=b.current;e&&(e.scrollTop=e.scrollHeight)},[x.length,d]);let w=(0,D.useMemo)(()=>x.map(e=>v?`${J(e.ts)} [${e.stream}] ${e.line}`:e.line).join(`
|
|
2
|
+
`),[x,v]);return(0,O.jsxs)(f,{padded:!1,className:`overflow-hidden`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-4 py-3`,children:[(0,O.jsx)(`h3`,{className:`mr-1 text-base font-semibold text-fg`,children:`Process logs`}),(0,O.jsx)(C,{options:q,value:o,onChange:s}),(0,O.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,O.jsx)(a,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,O.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),"aria-label":`Filter log lines`,name:`process-log-filter`,autoComplete:`off`,placeholder:`Filter…`,className:`h-8 w-full rounded-lg border border-line bg-surface-2 pl-8 pr-2 text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,O.jsx)(Y,{on:d,onClick:()=>g(e=>!e),label:`Follow`}),(0,O.jsx)(Y,{on:v,onClick:()=>y(e=>!e),label:`Times`}),(0,O.jsx)(S,{value:w}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{oe(w)},disabled:x.length===0,className:`rounded-md border border-line bg-surface-2 px-2 py-1 text-xs text-muted transition-colors hover:text-fg disabled:opacity-40`,children:`Download`})]}),t&&e&&(0,O.jsx)(`div`,{className:`border-b border-line px-4 pt-3 font-sans`,children:(0,O.jsx)(p,{message:`Process-log refresh failed — showing the last received lines. ${t.message}`,onRetry:r})}),(0,O.jsx)(`div`,{ref:b,className:`max-h-80 min-h-40 overflow-y-auto p-4 font-mono text-xs leading-relaxed`,children:n&&!e&&!t?(0,O.jsx)(`div`,{className:`font-sans`,children:(0,O.jsx)(h,{label:`Loading process logs…`})}):t&&!e?(0,O.jsx)(`div`,{className:`font-sans`,children:(0,O.jsx)(m,{error:t,onRetry:r})}):x.length===0?(0,O.jsx)(`p`,{className:`text-faint`,children:i.length===0?`No output yet.`:`No lines match the current filter.`}):x.map(e=>(0,O.jsxs)(`div`,{className:c(`whitespace-pre-wrap`,ae(e.stream)),children:[v&&(0,O.jsx)(`span`,{className:`mr-2 text-faint`,children:J(e.ts)}),e.line]},e.seq))}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-[11px] text-faint`,children:[(0,O.jsx)(`span`,{children:t&&!e?`logs unavailable`:x.length===i.length?`${i.length} lines`:`${x.length} of ${i.length} lines`}),(0,O.jsx)(`span`,{children:t?`refresh failed`:d?`following tail`:`paused`})]})]})}function Y({on:e,onClick:t,label:n}){return(0,O.jsx)(`button`,{type:`button`,onClick:t,"aria-pressed":e,className:c(`rounded-md border px-2 py-1 text-xs transition-colors`,e?`border-accent/40 bg-accent/10 text-accent`:`border-line bg-surface-2 text-muted hover:text-fg`),children:n})}function ce(){return l(()=>r.control.logs(),[])}var X={running:{label:`Running`,tone:`text-success`,dot:`bg-emerald-400`},starting:{label:`Starting`,tone:`text-warning`,dot:`bg-amber-400`},stopping:{label:`Stopping`,tone:`text-warning`,dot:`bg-amber-400`},stopped:{label:`Stopped`,tone:`text-danger`,dot:`bg-red-400`}};function Z({startedAt:e}){let[,t]=(0,D.useState)(0);return(0,D.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,O.jsx)(O.Fragment,{children:x((Date.now()-e)/1e3)})}function Q({label:e,children:t,title:n}){return(0,O.jsxs)(`div`,{className:`min-w-0`,title:n,children:[(0,O.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e}),(0,O.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,children:t})]})}function le({status:e,agentBase:t,transitioning:n,stale:r=!1,vitals:a=null,busy:l,onStart:d,onStop:f,onRestart:p}){let m=e?.status??`stopped`,h=e?.managementMode===`external`,g=h?e?.reachable===!0:m===`running`,_=h?e?.healthy?{label:`External`,tone:`text-success`,dot:`bg-emerald-400`}:e?.reachable?{label:`External`,tone:`text-warning`,dot:`bg-amber-400`}:{label:`External`,tone:`text-danger`,dot:`bg-red-400`}:X[m]??X.stopped,y=!!e?.healthy&&!r,b=!h&&!g&&e?.exitCode!=null&&e.exitCode!==0,x=e?.runningConfig??e?.config??null,C=x?.httpPort??6790,w=h?e?.externalUrl??`—`:`http://localhost:${C}`,T=w===`—`?`—`:`${w}/health`;return(0,O.jsxs)(`section`,{className:`mb-6 overflow-hidden rounded-xl border border-line bg-surface`,children:[(0,O.jsx)(`div`,{className:c(`h-0.5 bg-gradient-to-r to-transparent`,g&&y?`from-emerald-400/80 via-emerald-400/25`:g||n?`from-amber-400/80 via-amber-400/25`:`from-red-400/70 via-red-400/20`)}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-5 p-5 lg:flex-row lg:items-center lg:justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[g&&y&&(0,O.jsx)(`span`,{className:`absolute inline-flex size-full rounded-full bg-emerald-400 opacity-50 motion-safe:animate-ping`}),(0,O.jsx)(`span`,{className:c(`relative inline-flex size-3.5 rounded-full`,_.dot)})]}),(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,O.jsx)(`span`,{className:c(`text-2xl font-bold tracking-tight`,_.tone),children:n&&l?`${l}…`:_.label}),e?.version&&(0,O.jsxs)(`span`,{className:`font-mono text-xs text-muted`,children:[`bunqueue v`,e.version]}),b&&(0,O.jsxs)(`span`,{className:`rounded-full bg-red-500/15 px-2 py-0.5 font-mono text-[11px] font-medium text-danger`,children:[`crashed · exit `,e?.exitCode]})]}),(0,O.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted`,children:r?(0,O.jsxs)(`span`,{className:`text-warning`,children:[`last known: pid `,e?.pid??`—`,` — agent unreachable, state may have changed`]}):h?(0,O.jsx)(`span`,{title:e?.healthError,children:e?.reachable?y?`healthy via ${T}`:`reachable but unhealthy via ${T}`:`unreachable via ${T}`}):g?(0,O.jsxs)(O.Fragment,{children:[y?`healthy`:`waiting for health…`,` · pid `,e?.pid??`—`,` · up`,` `,e?.startedAt?(0,O.jsx)(Z,{startedAt:e.startedAt}):`—`]}):`process not running — start it below or point the dashboard at an external server`})]})]}),!h&&(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(u,{variant:`success`,disabled:g||n||r,onClick:d,children:[(0,O.jsx)(s,{className:`size-4`}),` Start`]}),(0,O.jsxs)(u,{variant:`warning`,disabled:!g||n||r,onClick:f,children:[(0,O.jsx)(o,{className:`size-4`}),` Stop`]}),(0,O.jsxs)(u,{disabled:n||r,onClick:p,children:[(0,O.jsx)(i,{className:`size-4`}),` Restart`]})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 border-t border-line bg-surface-2/30 px-5 py-4 md:grid-cols-3 xl:grid-cols-7`,children:[(0,O.jsx)(Q,{label:`Memory`,children:a?.memory?.rss==null?(0,O.jsx)(`span`,{className:`text-faint`,children:`—`}):(0,O.jsxs)(`span`,{title:`heap ${a.memory.heapUsed??`?`} / ${a.memory.heapTotal??`?`} MB`,children:[a.memory.rss,` MB rss`]})}),(0,O.jsx)(Q,{label:`Connections`,children:a?.connections?`${a.connections.tcp??0} tcp · ${a.connections.ws??0} ws · ${a.connections.sse??0} sse`:(0,O.jsx)(`span`,{className:`text-faint`,children:`—`})}),(0,O.jsx)(Q,{label:h?`Health target`:`API endpoint`,title:T,children:w===`—`?(0,O.jsx)(`span`,{className:`text-faint`,children:w}):(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`a`,{href:T,target:`_blank`,rel:`noreferrer`,className:`truncate text-accent hover:underline`,children:w}),(0,O.jsx)(S,{value:w})]})}),(0,O.jsx)(Q,{label:h?`Lifecycle`:`Ports`,children:h?`external`:x?`${x.httpPort} http · ${x.tcpPort} tcp`:`—`}),(0,O.jsx)(Q,{label:h?`Health HTTP`:`Started`,children:h?e?.healthStatus??`—`:g&&e?.startedAt?v(e.startedAt):`—`}),(0,O.jsx)(Q,{label:`Control agent`,title:t,children:t.replace(/^https?:\/\//,``)}),(0,O.jsx)(Q,{label:h?`Supervisor`:`Storage`,title:e?.storageMode===`postgres`?`PostgreSQL ${e.postgresTarget??`configured`} · namespace ${e.postgresNamespace??`default`}`:e?.storageMode,children:h?`managed elsewhere`:e?.storageMode===`postgres`?`postgres · ${e.postgresNamespace??`default`}`:e?.storageMode??`—`})]})]})}var $=[{key:`size`,label:`Database`,color:`bg-accent`},{key:`walSize`,label:`WAL`,color:`bg-amber-400`},{key:`shmSize`,label:`SHM`,color:`bg-zinc-500`}];function ue({db:e}){let t=e.totalSize||0;return(0,O.jsxs)(f,{children:[(0,O.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Storage`}),(0,O.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:e.exists?`${b(t)} on disk`:`not created yet`})]}),(0,O.jsxs)(`p`,{className:`mb-4 flex items-center gap-1.5 truncate font-mono text-xs text-faint`,title:e.path,children:[(0,O.jsx)(`span`,{className:`truncate`,children:e.path}),(0,O.jsx)(S,{value:e.path})]}),e.exists&&t>0?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-surface-2`,children:$.map(n=>{let r=e[n.key];return r?(0,O.jsx)(`div`,{className:c(`h-full`,n.color),style:{width:`${r/t*100}%`},title:`${n.label}: ${b(r)}`},n.key):null})}),(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 font-mono text-[11px] text-faint`,children:[$.map(t=>(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`span`,{className:c(`size-2 rounded-full`,t.color)}),t.label,` `,(0,O.jsx)(`span`,{className:`text-fg`,children:b(e[t.key])})]},t.key)),e.mtimeMs?(0,O.jsxs)(`span`,{className:`ml-auto`,children:[`written `,y(e.mtimeMs)]}):null]})]}):(0,O.jsx)(`p`,{className:`rounded-lg border border-dashed border-line px-4 py-6 text-center text-sm text-faint`,children:`The database appears here after the first start — SQLite creates the file at the configured data path.`})]})}function de(){let e=(0,D.useRef)(0),t=(0,D.useRef)(new WeakMap),{data:n,error:i,refetch:a}=l(async()=>{let n=++e.current,i=await r.control.status();return t.current.set(i,n),i},[]),o=E(`server-lifecycle`),[s,c]=(0,D.useState)(null),[u,m]=(0,D.useState)(null);(0,D.useEffect)(()=>{c(null),m(null)},[o.scopeKey]);let h=n?.managementMode===`external`,_=h?n?.reachable===!0:n?.status===`running`,{data:v}=l(()=>_?r.health():Promise.resolve(null),[_]),y=_?v??null:null,b=y?.connections?` This drops ${y.connections.tcp??0} TCP / ${y.connections.ws??0} WS connections; in-flight jobs are interrupted.`:` In-flight jobs are interrupted.`,x=async(e,t,n)=>{let r=o.begin(`lifecycle`);if(r){if(n&&!window.confirm(n)){r.finish();return}if(!r.isCurrent()){r.finish();return}c(e),m(null);try{if(await t(),!r.isCurrent())return;await a()}catch(e){if(!r.isCurrent())return;m(e.message)}finally{r.finish()&&c(null)}}};if(i&&!n)return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(g,{title:`Server`,description:`Start, stop and restart the bunqueue server.`}),(0,O.jsx)(p,{message:`Control agent unreachable — server lifecycle controls are unavailable.`,onRetry:a}),(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Control agent not running`}),(0,O.jsxs)(`p`,{className:`text-sm text-muted`,children:[`The local control agent is unreachable at`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:r.agentBase}),`. It manages the bunqueue server process (start / stop / restart). Start it with:`]}),(0,O.jsxs)(`pre`,{className:`mt-3 overflow-x-auto rounded-lg border border-line bg-surface-2 px-3 py-2 text-xs`,children:[`bun start`,` `,`# agent + dashboard together (recommended)`,`
|
|
3
|
+
`,`bun run agent`,` `,`# agent only, if the dashboard is already running`]}),(0,O.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`This page reconnects automatically once the agent is up — no reload needed.`})]})]});let S=n?.status??`stopped`,C=S===`running`,w=S===`starting`||S===`stopping`||s!=null,T=i!=null&&n!=null;return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(g,{title:`Server`,description:h?`Observe the Bunqueue server managed by an external supervisor.`:`Supervise the bunqueue server process — lifecycle, configuration, storage and logs.`}),u&&(0,O.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:u}),T&&(0,O.jsx)(`div`,{className:`mb-4 rounded-lg border border-amber-500/20 bg-amber-500/5 px-4 py-2 text-sm text-warning`,children:`Control agent unreachable — showing last known state. Lifecycle actions are disabled until it responds again.`}),(0,O.jsx)(le,{status:n,agentBase:r.agentBase,stale:T,vitals:y,transitioning:w,busy:s,onStart:()=>x(`starting`,()=>r.control.start()),onStop:()=>x(`stopping`,()=>r.control.stop(),`Stop the bunqueue server?${b}`),onRestart:()=>x(`restarting`,()=>r.control.restart(),`Restart the bunqueue server?${b}`)}),h?(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Managed externally`}),(0,O.jsxs)(`p`,{className:`text-sm text-muted`,children:[`This dashboard is attached to`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:n?.externalUrl??`BUNQUEUE_URL`}),`. Start, stop, restart and launch configuration are intentionally unavailable while`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:`BUNQUEUE_MANAGED=0`}),`. Use systemd, Docker, Kubernetes or the broker's external supervisor instead.`]})]}):(0,O.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,O.jsx)(K,{status:n,onSaved:a,running:C,statusRequestId:n?t.current.get(n):void 0,getStatusRequestSequence:()=>e.current,transitioning:w}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[n?.db&&(0,O.jsx)(ue,{db:n.db}),(0,O.jsx)(se,{})]})]}),(0,O.jsx)(`div`,{className:`mt-6`,children:(0,O.jsx)(A,{agentBase:r.agentBase})})]})}export{de as ServerControl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{c as r,o as i,s as a}from"./connectionStore-CVjQyIZv.js";import{f as o}from"./icons-DH9SS1DA.js";import{n as s,t as c}from"./Button-_aSJvRoW.js";import{n as l,t as u}from"./Card-egIDLwVk.js";import{t as d}from"./PageHeader-CQzNsw8r.js";import{o as f}from"./index-Bat1DN5U.js";import{a as p,n as m,t as h}from"./form-DG3X6cLL.js";var g=n(),_=[[`1000`,`1 second`],[`2000`,`2 seconds`],[`3000`,`3 seconds`],[`5000`,`5 seconds`],[`10000`,`10 seconds`]];function v(){let{refreshMs:e,setRefreshMs:t}=i(),{theme:n,setTheme:r}=f();return(0,g.jsxs)(u,{children:[(0,g.jsx)(l,{title:`Appearance & refresh`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,g.jsx)(h,{label:`Theme`,children:(0,g.jsxs)(p,{name:`theme`,autoComplete:`off`,value:n,onChange:e=>r(e.target.value),children:[(0,g.jsx)(`option`,{value:`dark`,children:`Dark`}),(0,g.jsx)(`option`,{value:`light`,children:`Light`})]})}),(0,g.jsx)(h,{label:`Refresh interval`,children:(0,g.jsx)(p,{name:`refresh-interval`,autoComplete:`off`,value:String(e),onChange:e=>t(Number(e.target.value)),children:_.map(([e,t])=>(0,g.jsx)(`option`,{value:e,children:t},e))})})]})]})}var y=e(t(),1),b=1e4,x=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;async function S(e,t={},n=b){let r=new AbortController,i=t.signal,a=i?AbortSignal.any([i,r.signal]):r.signal,o=Error(`Connection test timed out after ${Math.ceil(n/1e3)} seconds.`),s,c,l=new Promise((e,t)=>{s=setTimeout(()=>{r.abort(o),t(o)},n)}),u=i?new Promise((e,t)=>{let n=()=>{t(i.reason??new DOMException(`Connection test aborted`,`AbortError`))};i.aborted?n():(i.addEventListener(`abort`,n,{once:!0}),c=()=>i.removeEventListener(`abort`,n))}):null;try{let n=(async()=>{let n=await fetch(e,{...t,signal:a});return{response:n,value:await n.json()}})();return await Promise.race(u?[n,l,u]:[n,l])}catch(e){throw r.signal.aborted&&r.signal.reason===o?o:e}finally{s!==void 0&&clearTimeout(s),c?.()}}async function C(e,t={},n=b){let{response:r,value:i}=await S(e,t,n);if(!r.ok&&r.status!==503)throw Error(`HTTP ${r.status}`);if(typeof i!=`object`||!i||Array.isArray(i))throw Error(`Malformed health response`);let a=i;if(typeof a.ok!=`boolean`||a.status!==`healthy`&&a.status!==`degraded`||!Number.isSafeInteger(a.uptime)||a.uptime<0||typeof a.version!=`string`||!x.test(a.version)||a.ok!==(a.status===`healthy`))throw Error(`Malformed health response`);return{response:r,health:a}}function w(){let e=i(),[t,n]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,w]=(0,y.useState)(null),[T,E]=(0,y.useState)(null),D=(0,y.useRef)(!0),O=(0,y.useRef)(0),k=(0,y.useRef)(null),A=(0,y.useRef)(null),j=(0,y.useCallback)(()=>{A.current!==null&&clearTimeout(A.current),A.current=null,D.current&&E(null)},[]),M=(0,y.useCallback)(()=>{O.current+=1,k.current?.abort(new DOMException(`Connection test superseded`,`AbortError`)),k.current=null,D.current&&(h(null),_(null))},[]),N=(0,y.useCallback)(()=>{M(),j()},[j,M]);(0,y.useEffect)(()=>(D.current=!0,()=>{D.current=!1,O.current+=1,k.current?.abort(new DOMException(`Settings unmounted`,`AbortError`)),A.current!==null&&clearTimeout(A.current)}),[]),(0,y.useEffect)(()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);n(t?.name??`Bunqueue`),s(e.baseUrl),l(e.agentBaseUrl),d(e.token),p(e.agentToken),b(null),w(null),M()},[e.activeProfileId,e.agentBaseUrl,e.baseUrl,e.profiles,e.token,e.agentToken,M]);let P=()=>{let e=i.getState();return JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken])},F=async e=>{M();let t=r(e===`server`?o:c);if(!t){e===`server`?b(a):w(a),_({ok:!1,msg:a});return}e===`server`?b(null):w(null);let n=O.current,i=new AbortController,s=P(),l=()=>D.current&&n===O.current&&!i.signal.aborted&&P()===s;k.current=i,h(e),_(null);let d=performance.now();try{if(e===`server`){let{response:e,health:n}=await C(`${t}/health`,{headers:u.trim()?{Authorization:`Bearer ${u.trim()}`}:void 0,signal:i.signal});if(!l())return;let r=e.status===503||n.status===`degraded`;_({ok:!r,msg:`${r?`Server reachable`:`Connected`} in ${Math.round(performance.now()-d)}ms · bunqueue v${n.version}${r?` · degraded`:``}`})}else{let{response:e,value:n}=await S(`${t}/control/status`,{headers:f.trim()?{Authorization:`Bearer ${f.trim()}`}:void 0,signal:i.signal});if(!e.ok)throw Error(`HTTP ${e.status}`);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Malformed control agent response`);let r=n;if(![`running`,`stopped`,`starting`,`stopping`].includes(String(r.status)))throw Error(`Malformed control agent response`);if(!l())return;_({ok:!0,msg:`Agent connected in ${Math.round(performance.now()-d)}ms · server ${r.status}${r.storageMode?` · ${r.storageMode}`:``}`})}}catch(e){l()&&_({ok:!1,msg:e.message})}finally{D.current&&n===O.current&&(k.current=null,h(null))}},I=()=>{M();let n=r(o),i=r(c);if(b(n?null:a),w(i?null:a),!n||!i)return;let s=e.saveConnection({name:t,baseUrl:n,agentBaseUrl:i,token:u,agentToken:f});j(),E({ok:s.persisted,msg:s.persisted?`Saved ✓`:`Saved for this session only — browser storage unavailable${s.error?`: ${s.error}`:`.`}`}),A.current=setTimeout(()=>D.current&&E(null),4e3)},L=()=>{N(),e.addProfile({name:`Bunqueue ${e.profiles.length+1}`,baseUrl:`http://localhost:6790`,agentBaseUrl:`http://localhost:6800`,token:``,agentToken:``})},R=()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);!t||!window.confirm(`Remove connection profile "${t.name}"?`)||e.removeProfile(t.id)};return{...e,name:t,setName:n,url:o,setUrl:s,agentUrl:c,setAgentUrl:l,tok:u,setTok:d,agentTok:f,setAgentTok:p,testing:m,result:g,urlError:v,agentUrlError:x,saveNotice:T,edit:N,save:I,add:L,remove:R,testServer:()=>F(`server`),testAgent:()=>F(`agent`)}}function T({id:e,label:t,hint:n,value:r,placeholder:i,onChange:a}){let[c,l]=(0,y.useState)(!1);return(0,g.jsx)(h,{label:t,hint:n,htmlFor:e,children:(0,g.jsxs)(`div`,{className:`relative`,children:[(0,g.jsx)(m,{id:e,name:e,type:c?`text`:`password`,value:r,onChange:e=>a(e.target.value),placeholder:i,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,g.jsx)(s,{"aria-label":c?`Hide ${t.toLowerCase()}`:`Show ${t.toLowerCase()}`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>l(e=>!e),children:(0,g.jsx)(o,{className:`size-4`})})]})})}function E(){let e=w(),t=t=>n=>{e.edit(),t(n)};return(0,g.jsxs)(u,{children:[(0,g.jsx)(l,{title:`Bunqueue fleet connections`}),(0,g.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_auto_auto]`,children:[(0,g.jsx)(h,{label:`Active node`,children:(0,g.jsx)(p,{"aria-label":`Active Bunqueue node`,value:e.activeProfileId,onChange:t=>e.activateProfile(t.target.value),children:e.profiles.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))})}),(0,g.jsx)(c,{className:`self-end`,onClick:e.add,children:`Add node`}),(0,g.jsx)(c,{className:`self-end`,variant:`danger`,disabled:e.profiles.length===1,onClick:e.remove,children:`Remove`})]}),(0,g.jsx)(h,{label:`Node name`,children:(0,g.jsx)(m,{name:`profile-name`,value:e.name,onChange:n=>t(e.setName)(n.target.value),maxLength:64,autoComplete:`off`,placeholder:`broker-eu-1`})}),(0,g.jsx)(h,{label:`Server URL`,children:(0,g.jsx)(m,{name:`server-url`,value:e.url,onChange:n=>{t(e.setUrl)(n.target.value)},placeholder:`/api or https://queue.example.com`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.urlError?!0:void 0,"aria-describedby":e.urlError?`server-url-error`:`server-url-help`})}),e.urlError?(0,g.jsx)(`p`,{id:`server-url-error`,className:`-mt-2 text-xs text-danger`,children:e.urlError}):(0,g.jsx)(`p`,{id:`server-url-help`,className:`-mt-2 text-xs text-faint`,children:`Bunqueue HTTP API for this broker. All queue pages use the selected node.`}),(0,g.jsx)(h,{label:`Control agent URL`,children:(0,g.jsx)(m,{name:`agent-url`,value:e.agentUrl,onChange:n=>t(e.setAgentUrl)(n.target.value),placeholder:`/agent or https://broker.example.com/agent`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.agentUrlError?!0:void 0,"aria-describedby":e.agentUrlError?`agent-url-error`:`agent-url-help`})}),e.agentUrlError?(0,g.jsx)(`p`,{id:`agent-url-error`,className:`-mt-2 text-xs text-danger`,children:e.agentUrlError}):(0,g.jsx)(`p`,{id:`agent-url-help`,className:`-mt-2 text-xs text-faint`,children:`One paired agent per broker enables lifecycle, configuration, Flow, Workflow and advanced queue controls.`}),(0,g.jsx)(T,{id:`bearer-token`,label:`Bearer token (optional)`,hint:`Server credential, kept in memory only and isolated to this node.`,value:e.tok,onChange:t(e.setTok),placeholder:`only if AUTH_TOKENS is set`}),(0,g.jsx)(T,{id:`agent-token`,label:`Agent token (optional)`,hint:`AGENT_TOKEN for this node, kept in memory only.`,value:e.agentTok,onChange:t(e.setAgentTok),placeholder:`only if AGENT_TOKEN is set`}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(c,{variant:`accent`,onClick:e.save,children:`Save`}),(0,g.jsx)(c,{onClick:e.testServer,children:e.testing===`server`?`Restart test`:`Test connection`}),(0,g.jsx)(c,{onClick:e.testAgent,children:e.testing===`agent`?`Restart agent test`:`Test agent`}),e.saveNotice&&(0,g.jsx)(`span`,{role:`status`,className:e.saveNotice.ok?`text-sm text-success`:`text-sm text-warning`,children:e.saveNotice.msg}),e.result&&(0,g.jsx)(`span`,{role:`status`,className:e.result.ok?`text-sm text-success`:`text-sm text-danger`,children:e.result.msg})]}),(0,g.jsx)(`p`,{className:`-mt-1 text-xs text-faint`,children:`Switching the active node retargets every Dashboard feature atomically. Profile metadata persists; both credentials are erased on reload.`})]})]})}function D(){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(d,{title:`Settings`,description:`Bunqueue fleet connections, credentials and appearance.`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsx)(E,{}),(0,g.jsx)(v,{})]})]})}export{D as Settings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./react-vendor-CFL9l8LK.js";function t(...e){return e.filter(Boolean).join(` `)}var n=e(),r={completed:`text-success bg-emerald-500/10`,active:`text-blue-400 light:text-blue-700 bg-blue-500/10`,failed:`text-danger bg-red-500/10`,waiting:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,prioritized:`text-violet-400 light:text-violet-700 bg-violet-500/10`,delayed:`text-warning bg-amber-500/10`,paused:`text-orange-400 light:text-orange-700 bg-orange-500/10`,"waiting-children":`text-cyan-400 light:text-cyan-700 bg-cyan-500/10`,stalled:`text-orange-400 light:text-orange-700 bg-orange-500/10`,running:`text-blue-400 light:text-blue-700 bg-blue-500/10`,compensating:`text-violet-400 light:text-violet-700 bg-violet-500/10`,"compensation-stuck":`text-danger bg-red-500/10`,compensated:`text-success bg-emerald-500/10`,"compensation-failed":`text-danger bg-red-500/10`,"compensation-skipped":`text-warning bg-amber-500/10`,enqueued:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,started:`text-blue-400 light:text-blue-700 bg-blue-500/10`,finished:`text-success bg-emerald-500/10`,retry:`text-warning bg-amber-500/10`,cancelled:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`,default:`text-zinc-400 light:text-zinc-600 bg-zinc-500/10`};function i({status:e}){let i=(e||``).toLowerCase();return(0,n.jsxs)(`span`,{className:t(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium capitalize`,r[i]??r.default),children:[(0,n.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e||`unknown`]})}function a({label:e,tone:r=`green`}){return(0,n.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted`,children:[(0,n.jsx)(`span`,{className:t(`size-1.5 rounded-full`,r===`green`?`bg-emerald-400`:r===`amber`?`bg-amber-400`:r===`red`?`bg-red-400`:`bg-zinc-400`)}),e]})}export{a as n,t as r,i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./react-vendor-CFL9l8LK.js";import{t}from"./api-D9aT0ND7.js";import{n}from"./usePolledData-CEyyLRYa.js";import{n as r,t as i}from"./Card-egIDLwVk.js";import{i as a,n as o,r as s}from"./feedback-CtGN_kqB.js";import{t as c}from"./PageHeader-CQzNsw8r.js";import{l,n as u,s as d,u as f}from"./format-Cg7VCIZW.js";import{r as p}from"./index-Bat1DN5U.js";var m=e(),h={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},memory:{heapUsed:0,heapTotal:0,rss:0},workers:{total:0,active:0},crons:{total:0},storage:{}};function g(){let{data:e,error:g,loading:v,refetch:y}=n(()=>t.overview(),[]);if(v&&!e&&!g)return(0,m.jsx)(s,{label:`Loading usage…`});if(g&&!e)return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(c,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,m.jsx)(o,{error:g,onRetry:y})]});let{stats:b,memory:x,workers:S,crons:C,storage:w}=e??h,T=typeof w.diskFull==`boolean`;return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(c,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!g&&T}),g&&(0,m.jsx)(a,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:y}),(0,m.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,m.jsx)(p,{label:`Jobs Pushed`,value:d(b.totalPushed)}),(0,m.jsx)(p,{label:`Jobs Completed`,value:d(b.totalCompleted),tone:`green`}),(0,m.jsx)(p,{label:`Jobs Failed`,value:d(b.totalFailed),tone:b.totalFailed?`red`:`default`}),(0,m.jsx)(p,{label:`Jobs Pulled`,value:d(b.totalPulled),tone:`blue`})]}),(0,m.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,m.jsxs)(i,{children:[(0,m.jsx)(r,{title:`Runtime`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Uptime`,value:f(b.uptime/1e3)}),(0,m.jsx)(_,{label:`Heap used`,value:u(x.heapUsed*1024*1024)}),(0,m.jsx)(_,{label:`RSS`,value:u(x.rss*1024*1024)}),(0,m.jsx)(_,{label:`Workers`,value:`${S.active} active / ${S.total}`}),(0,m.jsx)(_,{label:`Cron jobs`,value:String(C.total)})]})]}),(0,m.jsxs)(i,{children:[(0,m.jsx)(r,{title:`Storage`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Status`,value:T?w.diskFull?`Disk full`:`Healthy`:`Unavailable`}),(0,m.jsx)(_,{label:`Disk full since`,value:w.diskFull?l(w.since):`—`}),w.error?(0,m.jsx)(_,{label:`Error`,value:String(w.error)}):null]})]})]})]})}function _({label:e,value:t,mono:n}){return(0,m.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,m.jsx)(`dt`,{className:`text-muted`,children:e}),(0,m.jsx)(`dd`,{className:n?`font-mono text-xs text-fg`:`font-medium text-fg`,children:t})]})}export{g as Usage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./react-vendor-CFL9l8LK.js";import{t}from"./bq-DR2BTISO.js";import{n}from"./usePolledData-CEyyLRYa.js";import{n as r,t as i}from"./Card-egIDLwVk.js";import{i as a,n as o,r as s}from"./feedback-CtGN_kqB.js";import{t as c}from"./PageHeader-CQzNsw8r.js";import{c as l,l as u,n as d,s as f,t as p,u as m}from"./format-Cg7VCIZW.js";import{n as h,r as g}from"./index-Bat1DN5U.js";var _=e(),v={overview:{stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},memory:{heapUsed:0,heapTotal:0,rss:0},crons:{total:0}},storage:{},failedTotal:0};function y(){let{data:e,error:y,loading:x,refetch:S}=n(async()=>{let[e,n,r]=await Promise.all([t.overview(),t.storage(),t.queuesSummary()]);if(!n?.data||typeof n.data.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data`);if(h(e),!Number.isFinite(e.memory.heapUsed))throw Error(`Malformed /dashboard response: memory.heapUsed is missing or non-numeric.`);let i=r.reduce((e,t)=>e+(t.counts?.failed??0),0);return{overview:e,storage:n.data,failedTotal:i}},[]);if(x&&!e&&!y)return(0,_.jsx)(s,{label:`Loading usage…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(c,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,_.jsx)(o,{error:y,onRetry:S})]});let C=e??v,{stats:w,memory:T,crons:E}=C.overview,{storage:D,failedTotal:O}=C,k=p(w.completed,O),A=w.uptime?m(w.uptime/1e3):`—`;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(c,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!y}),y&&(0,_.jsx)(a,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:S}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(g,{label:`Completed`,value:f(w.completed),tone:`green`}),(0,_.jsx)(g,{label:`Failed`,value:f(O),tone:O?`red`:`default`}),(0,_.jsx)(g,{label:`Waiting`,value:f(w.waiting),tone:`amber`}),(0,_.jsx)(g,{label:`Active`,value:f(w.active),tone:`blue`}),(0,_.jsx)(g,{label:`Error Rate`,value:k==null?`—`:l(k),tone:k==null?`default`:k>.05?`red`:`green`}),(0,_.jsx)(g,{label:`Uptime`,value:A})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(i,{children:[(0,_.jsx)(r,{title:`Runtime`}),(0,_.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,_.jsx)(b,{label:`Jobs pushed (since restart)`,value:f(w.totalPushed)}),(0,_.jsx)(b,{label:`Jobs pulled (since restart)`,value:f(w.totalPulled)}),(0,_.jsx)(b,{label:`Heap used`,value:d(T.heapUsed*1024*1024)}),(0,_.jsx)(b,{label:`RSS`,value:d(T.rss*1024*1024)}),(0,_.jsx)(b,{label:`Cron jobs`,value:String(E.total)})]})]}),(0,_.jsxs)(i,{children:[(0,_.jsx)(r,{title:`Storage`}),D.diskFull?(0,_.jsxs)(`div`,{className:`rounded-lg border border-red-500/25 bg-red-500/[0.06] px-4 py-3`,children:[(0,_.jsx)(`div`,{className:`font-semibold text-danger`,children:`Disk full — writes suspended`}),D.error&&(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:D.error}),D.since!=null&&(0,_.jsxs)(`div`,{className:`mt-1 text-xs text-faint`,children:[`since `,u(D.since)]})]}):(0,_.jsxs)(`div`,{className:`rounded-lg border border-emerald-500/25 bg-emerald-500/[0.06] px-4 py-3`,children:[(0,_.jsx)(`div`,{className:`font-semibold text-success`,children:`Healthy`}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`Disk writes are being accepted.`})]})]})]})]})}function b({label:e,value:t}){return(0,_.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,_.jsx)(`dt`,{className:`text-muted`,children:e}),(0,_.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}export{y as UsagePro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{t as r}from"./bq-DR2BTISO.js";import{t as i}from"./toastStore-XmMX7A5W.js";import{O as a,m as o}from"./icons-DH9SS1DA.js";import{n as s}from"./usePolledData-CEyyLRYa.js";import{n as c,t as l}from"./Button-_aSJvRoW.js";import{n as u,t as d}from"./Card-egIDLwVk.js";import{i as f,n as p,r as m,t as h}from"./feedback-CtGN_kqB.js";import{t as g}from"./PageHeader-CQzNsw8r.js";import{l as _,s as v}from"./format-Cg7VCIZW.js";import{n as y,o as b,t as x}from"./form-DG3X6cLL.js";import{t as S}from"./Pagination-CSkzhNW6.js";import{r as C,t as w}from"./useServerActionGuard-CUx8TOAC.js";var T=[`job.pushed`,`job.started`,`job.completed`,`job.failed`,`job.progress`],E=e(t(),1);function D(e){try{let t=new URL(e);return e.length<=2048&&/^https?:$/.test(t.protocol)&&t.username===``&&t.password===``}catch{return!1}}function O(e){try{let t=new URL(e);return!t.username&&!t.password?e:(t.username=`redacted`,t.password=`redacted`,t.toString())}catch{return e}}function k(e,t,n,r){let i=e.trim();if(!i||t.length===0)return{ok:!1,msg:`URL and at least one event are required`};if(!D(i))return{ok:!1,msg:`URL must be a valid http:// or https:// address without embedded credentials`};let a=n.trim();return a&&(a.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(a))?{ok:!1,msg:`Queue must be at most 256 characters using letters, numbers, _, -, . or :`}:{ok:!0,body:{url:i,events:t,queue:a||void 0,secret:r.trim()||void 0}}}var A=n();function j({onAdd:e,onAccepted:t,beginAdd:n,scopeKey:r}){let[i,a]=(0,E.useState)(``),[o,s]=(0,E.useState)(``),[c,u]=(0,E.useState)(``),[d,f]=(0,E.useState)([`job.completed`,`job.failed`]),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)(!1);(0,E.useEffect)(()=>{g(!1),m(null)},[r]);let _=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),v=async()=>{if(h)return;m(null);let r=k(i,d,o,c);if(!r.ok)return m(r.msg);let s=n();if(s){g(!0);try{if(w(await e(r.body),`Add webhook`),!s.isCurrent())return;a(``),u(``),t()}catch(e){s.isCurrent()&&m(e.message)}finally{s.finish()&&g(!1)}}};return(0,A.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),v()},children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,A.jsx)(`div`,{className:`md:col-span-1`,children:(0,A.jsx)(x,{label:`URL`,children:(0,A.jsx)(y,{value:i,onInput:e=>a(e.currentTarget.value),name:`webhook-url`,type:`url`,maxLength:2048,autoComplete:`url`,placeholder:`https://example.com/hook`})})}),(0,A.jsx)(x,{label:`Queue (optional)`,children:(0,A.jsx)(y,{value:o,onChange:e=>s(e.target.value),name:`webhook-queue`,maxLength:256,autoComplete:`off`,placeholder:`all queues`})}),(0,A.jsx)(x,{label:`Secret (optional)`,children:(0,A.jsx)(y,{type:`password`,autoComplete:`new-password`,name:`webhook-secret`,maxLength:65536,value:c,onChange:e=>u(e.target.value),placeholder:`HMAC signing secret`})})]}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.map(e=>(0,A.jsx)(`button`,{type:`button`,"aria-pressed":d.includes(e),onClick:()=>_(e),className:d.includes(e)?`rounded-full bg-accent/15 px-3 py-1 text-xs font-medium text-accent`:`rounded-full border border-line px-3 py-1 text-xs font-medium text-muted hover:text-fg`,children:e},e))}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(l,{type:`submit`,variant:`accent`,size:`sm`,disabled:h,children:h?`Adding…`:`Add webhook`}),p&&(0,A.jsx)(`span`,{className:`text-xs text-danger`,children:p})]})]})}function M(e){let[t,n]=(0,E.useState)(0);return(0,E.useEffect)(()=>{t>e-1&&n(e-1)},[t,e]),[Math.min(t,e-1),n]}function N(){let{data:e,error:t,loading:n,refetch:l}=s(()=>r.webhooks(),[]),y=e?.data?.webhooks??[],[x,T]=M(Math.max(1,Math.ceil(y.length/15))),[D,k]=(0,E.useState)(null),[N,P]=(0,E.useState)(new Set),F=C(`webhooks`),[I,L]=(0,E.useState)({}),R=(0,E.useRef)(new Map);(0,E.useEffect)(()=>{k(null),P(new Set),L({}),R.current.clear()},[F.scopeKey]);let z=async e=>{let t=F.begin([`registry-write`,`webhook:${e}`]);if(t){k(null),P(t=>new Set(t).add(e));try{if(w(await r.removeWebhook(e),`Remove webhook`),!t.isCurrent())return;l()}catch(e){if(!t.isCurrent())return;k(e.message)}finally{t.finish()&&P(t=>{let n=new Set(t);return n.delete(e),n})}}},B=(e,t)=>{let n=Symbol(`webhook-toggle`),a=R.current.get(e);if(a){a.desired=t,a.intent=n,L(r=>({...r,[e]:{value:t,intent:n}}));return}let o=F.begin(`webhook:${e}`);if(!o)return;let s={desired:t,intent:n,lease:o};R.current.set(e,s),L(r=>({...r,[e]:{value:t,intent:n}})),(async()=>{try{for(;o.isCurrent()&&R.current.get(e)===s;){let t=s.desired,n=null;try{w(await r.setWebhookEnabled(e,t),`Toggle webhook`)}catch(e){n=e instanceof Error?e:Error(String(e))}if(!o.isCurrent()||R.current.get(e)!==s)return;if(s.desired!==t)continue;if(await l(),!o.isCurrent()||R.current.get(e)!==s)return;if(s.desired!==t)continue;R.current.delete(e);let a=s.intent;L(t=>{if(t[e]?.intent!==a)return t;let{[e]:n,...r}=t;return r}),n&&i.error(`Webhook toggle failed`,n.message);return}}finally{o.finish()}})()};return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(g,{title:`Webhooks`,description:`HTTP callbacks fired on job events.`,live:!!e&&!t}),t&&e&&(0,A.jsx)(f,{message:`Webhook refresh failed — showing the last successful registry.`,onRetry:l}),D&&(0,A.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:D}),(0,A.jsxs)(d,{className:`mb-6`,children:[(0,A.jsx)(u,{title:`Add webhook`}),(0,A.jsx)(j,{onAdd:e=>r.addWebhook(e),onAccepted:()=>void l(),beginAdd:()=>F.begin([`registry-write`,`add`]),scopeKey:F.scopeKey})]}),t&&!e?(0,A.jsx)(p,{error:t,onRetry:l}):n&&!e?(0,A.jsx)(m,{label:`Loading webhooks…`}):y.length===0?(0,A.jsx)(h,{icon:(0,A.jsx)(o,{}),title:`No webhooks`,hint:`Add one above to receive job-event callbacks.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`URL`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Events`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,A.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Success / Fail`}),(0,A.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Enabled`}),(0,A.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,A.jsx)(`tbody`,{children:y.slice(x*15,x*15+15).map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,A.jsx)(`td`,{className:`max-w-xs truncate px-5 py-3 font-mono text-xs text-fg`,children:O(e.url)}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-xs text-muted`,children:e.events.join(`, `)}),(0,A.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue??`all`}),(0,A.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[(0,A.jsx)(`span`,{className:`text-success`,children:v(e.successCount)}),` / `,(0,A.jsx)(`span`,{className:e.failureCount?`text-danger`:``,children:v(e.failureCount)})]}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:_(e.lastTriggered)}),(0,A.jsx)(`td`,{className:`px-5 py-3`,children:(0,A.jsx)(b,{checked:I[e.id]?.value??e.enabled,label:`${I[e.id]?.value??e.enabled?`Disable`:`Enable`} webhook`,onChange:t=>B(e.id,t)})}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,A.jsx)(c,{"aria-label":`Remove webhook`,disabled:N.has(e.id),onClick:()=>window.confirm(`Remove webhook for ${O(e.url)}?`)&&z(e.id),children:(0,A.jsx)(a,{className:`size-3.5`})})})]},e.id))})]})}),(0,A.jsx)(S,{page:x,pageSize:15,total:y.length,onPageChange:T,label:`webhooks`})]})]})}export{N as Webhooks};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{A as r}from"./icons-DH9SS1DA.js";import{t as i}from"./api-D9aT0ND7.js";import{n as a}from"./usePolledData-CEyyLRYa.js";import{i as o,n as s,r as c,t as l}from"./feedback-CtGN_kqB.js";import{t as u}from"./PageHeader-CQzNsw8r.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{r as p}from"./index-Bat1DN5U.js";import{t as m}from"./Pagination-CSkzhNW6.js";var h=e(t(),1),g=n(),_=20,v={workers:{total:0,active:0,list:[],truncated:!1}};function y(){let{data:e,error:t,loading:n,refetch:y}=a(()=>i.overview(),[]),[b,x]=(0,h.useState)(0);if(n&&!e&&!t)return(0,g.jsx)(c,{label:`Loading workers…`});if(t&&!e)return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(u,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,g.jsx)(s,{error:t,onRetry:y})]});let{workers:S}=e??v,C=Math.max(1,Math.ceil(S.list.length/_)),w=Math.min(b,C-1),T=S.list.slice(w*_,w*_+_);return(0,g.jsxs)(`div`,{children:[t&&(0,g.jsx)(o,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:y}),(0,g.jsx)(u,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!t}),(0,g.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,g.jsx)(p,{label:`Total`,value:f(S.total),compact:!0}),(0,g.jsx)(p,{label:`Active`,value:f(S.active),tone:`green`,compact:!0})]}),S.list.length===0?(0,g.jsx)(l,{icon:(0,g.jsx)(r,{}),title:`No workers registered`,hint:`Workers appear here once they connect and register with the server.`}):(0,g.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,g.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Worker`}),(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last Seen`})]})}),(0,g.jsx)(`tbody`,{children:T.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,g.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,g.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,g.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,g.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:f(e.activeJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:f(e.processedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:f(e.failedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:d(e.lastSeen)})]},e.id))})]})}),S.truncated&&(0,g.jsxs)(`p`,{className:`mt-3 text-xs text-amber-400`,children:[`Showing first `,f(S.list.length),` of `,f(S.total),` `,`workers.`]}),(0,g.jsx)(m,{page:w,pageSize:_,total:S.list.length,onPageChange:x,label:`workers`})]})}export{y as Workers};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{t as r}from"./bq-DR2BTISO.js";import{A as i,O as a}from"./icons-DH9SS1DA.js";import{r as o}from"./StatusBadge-DereLzOj.js";import{n as s}from"./usePolledData-CEyyLRYa.js";import{n as c}from"./Button-_aSJvRoW.js";import{i as l,n as u,r as d,t as f}from"./feedback-CtGN_kqB.js";import{t as p}from"./PageHeader-CQzNsw8r.js";import{l as m,s as h}from"./format-Cg7VCIZW.js";import{r as g}from"./index-Bat1DN5U.js";import{r as _,t as v}from"./useServerActionGuard-CUx8TOAC.js";var y=e(t(),1),b=n(),x=100,S=`No heartbeat recently — derived from lastSeen`;function C(){let{data:e,error:t,loading:n,refetch:C}=s(async()=>(await r.workers()).data,[]),[T,E]=(0,y.useState)(new Set),[D,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(null),j=_(`workers-pro`);if((0,y.useEffect)(()=>{E(new Set),O(null)},[j.scopeKey]),n&&!e&&!t)return(0,b.jsx)(d,{label:`Loading workers…`});if(t&&!e)return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,b.jsx)(u,{error:t,onRetry:C})]});let M=e?.workers??[],N=e?.quarantinedWorkers??[],P=(k?[...M].sort((e,t)=>{let n=k.key===`failed`?e.failedJobs??0:e.lastSeen??0,r=k.key===`failed`?t.failedJobs??0:t.lastSeen??0;return k.dir===`asc`?n-r:r-n}):M).slice(0,x),F=e=>A(t=>t?.key===e?{key:e,dir:t.dir===`desc`?`asc`:`desc`}:{key:e,dir:`desc`}),I=M.filter(e=>e.status===`active`).length,L=M.length-I,R=M.reduce((e,t)=>e+(t.activeJobs??0),0),z=async e=>{if(!window.confirm(`Remove the stale registry record for worker "${e}"? This does not stop the worker process. Continue only after confirming that process is stopped; Bunqueue v2.9.3 workers do not automatically re-register after their heartbeat record is removed.`))return;let t=j.begin(`worker:${e}`);if(t){E(t=>new Set(t).add(e)),O(null);try{if(v(await r.unregisterWorker(e),`Remove stale worker registry record`),!t.isCurrent())return;O({ok:!0,text:`Removed stale registry record for ${e} ✓`}),C()}catch(e){if(!t.isCurrent())return;O({ok:!1,text:`Removal failed: ${e.message}`})}finally{t.finish()&&E(t=>{let n=new Set(t);return n.delete(e),n})}}};return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!t}),t&&(0,b.jsx)(l,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:C}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,b.jsx)(g,{label:`Total`,value:h(M.length+N.length),compact:!0}),(0,b.jsx)(g,{label:`Active`,value:h(I),tone:`green`,compact:!0}),(0,b.jsx)(`div`,{title:S,children:(0,b.jsx)(g,{label:`Stale`,value:h(L),tone:L?`amber`:`default`,compact:!0})}),(0,b.jsx)(g,{label:`Active Jobs`,value:h(R),tone:`blue`,compact:!0}),(0,b.jsx)(g,{label:`Quarantined`,value:h(N.length),tone:N.length?`red`:`default`,compact:!0})]}),N.length>0&&(0,b.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,b.jsxs)(`p`,{className:`text-sm font-medium text-danger`,children:[N.length,` worker registration(s) contain values accepted by Bunqueue 2.9.3 but unsafe to render. Healthy workers remain available below.`]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Their status and active-job count are unknown, so this dashboard will not offer the registry-only removal action for them.`}),(0,b.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted`,children:N.slice(0,20).map(e=>(0,b.jsxs)(`li`,{className:`truncate font-mono`,children:[`#`,e.index+1,` `,e.id??`(unaddressable id)`,` — `,e.reason]},`${e.index}:${e.id??`unknown`}`))})]}),D&&(0,b.jsx)(`div`,{className:o(`mb-3 text-sm`,D.ok?`text-success`:`text-danger`),children:D.text}),M.length===0?(0,b.jsx)(f,{icon:(0,b.jsx)(i,{}),title:N.length?`No renderable workers`:`No workers registered`,hint:N.length?`Malformed registrations are isolated above instead of taking down the inventory.`:`Workers appear here once they connect and register with the server.`}):(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Worker`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,b.jsx)(w,{label:`Failed`,active:k?.key===`failed`?k.dir:null,onClick:()=>F(`failed`)})}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,b.jsx)(w,{label:`Last Seen`,active:k?.key===`lastSeen`?k.dir:null,onClick:()=>F(`lastSeen`)})}),(0,b.jsx)(`th`,{className:`w-16 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,b.jsx)(`tbody`,{children:P.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,b.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,b.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,b.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,b.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{title:e.status===`active`?void 0:S,className:o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.status===`active`?`bg-emerald-500/10 text-success`:`bg-amber-500/10 text-warning`),children:e.status})}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:h(e.activeJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(e.processedJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(e.failedJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:m(e.lastSeen)}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`div`,{className:`flex justify-end`,children:e.status===`stale`&&e.activeJobs===0?(0,b.jsx)(c,{"aria-label":`Remove stale registry record for worker ${e.id}`,title:`Registry cleanup only — does not stop the worker process`,disabled:T.has(e.id),onClick:()=>z(e.id),children:(0,b.jsx)(a,{className:`size-3.5`})}):(0,b.jsx)(`span`,{className:`text-xs text-faint`,title:e.status===`stale`?`Registry cleanup is blocked while active jobs are reported`:`Only stale, idle registry records can be removed`,children:`—`})})})]},e.id))})]})}),M.length>x&&(0,b.jsxs)(`p`,{className:`mt-3 text-xs text-warning`,children:[`Showing first `,h(x),` of `,h(M.length),` workers.`]})]})}function w({label:e,active:t,onClick:n}){return(0,b.jsxs)(`button`,{type:`button`,onClick:n,title:`Sort by ${e}`,className:o(`inline-flex items-center gap-1 uppercase tracking-wider transition-colors hover:text-fg`,t?`text-fg`:`text-faint`),children:[e,(0,b.jsx)(`span`,{"aria-hidden":`true`,children:t===`desc`?`↓`:t===`asc`?`↑`:``})]})}export{C as WorkersPro};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,l as r,t as i}from"./react-vendor-CFL9l8LK.js";import{a}from"./connectionStore-CVjQyIZv.js";import{t as o}from"./upstreamPaths-DQeKSxGc.js";import{s,t as c}from"./bq-DR2BTISO.js";import{t as l}from"./toastStore-XmMX7A5W.js";import{r as u,t as d}from"./StatusBadge-DereLzOj.js";import{n as f}from"./usePolledData-CEyyLRYa.js";import{t as p}from"./Card-egIDLwVk.js";import{i as m,n as h,r as g,t as _}from"./feedback-CtGN_kqB.js";import{t as v}from"./PageHeader-CQzNsw8r.js";import{a as y,i as b,l as x}from"./format-Cg7VCIZW.js";import{n as S,t as C}from"./controlConnectionEpoch-ChAeMMLk.js";import{t as w}from"./useControlActionGuard-1i7aFA7E.js";var T={"/workflows":{id:`overview`,label:`Overview`,description:`The complete durable command center for Bunqueue Workflow Engine.`,kind:`active`,state:``},"/workflows/executions":{id:`executions`,label:`Executions`,description:`Inspect every active execution, step record, decision, and nested run.`,kind:`active`,state:``},"/workflows/waiting":{id:`waiting`,label:`Waiting & Signals`,description:`Focus on parked executions and their durable signal payloads.`,kind:`active`,state:`waiting`,lockKind:!0,lockState:!0},"/workflows/compensation":{id:`compensation`,label:`Compensation`,description:`See running, completed, skipped, failed, and parked saga compensation outcomes.`,kind:`active`,state:`compensation`,lockKind:!0,lockState:!0},"/workflows/archive":{id:`archive`,label:`Archive`,description:`Audit terminal executions retained by Workflow Engine archival.`,kind:`archive`,state:``,lockKind:!0}};function ee(e){return T[e]??T[`/workflows`]}function te(e,t){return e?.source===`link`||e&&t.some(t=>t.id===e.id)?e:t[0]?{id:t[0].id,source:`page`}:null}var E=e(n(),1),ne=[`waiting`,`failed`,`compensation-stuck`];async function re(e,t){let[n,r]=await Promise.all([e.stats(),e.list(t)]);return{stats:n,page:r}}async function ie(e,t){let[n,...r]=await Promise.all([e.stats(),...ne.map(n=>e.list({kind:`active`,state:n,limit:t,offset:0}))]),i=r.flatMap(e=>e.executions).sort(ae).slice(0,t);return{stats:n,page:{ok:r.every(e=>e.ok),available:r.every(e=>e.available),executions:i,total:r.reduce((e,t)=>e+t.total,0),limit:t,offset:0}}}function ae(e,t){return t.createdAt-e.createdAt||t.id.localeCompare(e.id)}var D=new Set([`summary`,`history`,`payloads`]),oe=new Set([`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`]);function O(e,t){let n=e.get(`kind`),r=t.id===`executions`&&(n===`active`||n===`archive`)?n:t.kind,i=t.id===`overview`?``:ce(e.get(`workflow`)),a=ue(e.get(`state`),t),s=t.id===`overview`?0:le(e.get(`offset`)),c=e.get(`execution`),l=c&&o(c,`Workflow execution id`)===null?c:null,u=e.get(`tab`),d=t.id===`overview`||t.id===`executions`;return{kind:r,workflowName:i,state:a,offset:s,executionId:l,tab:l&&d&&D.has(u)?u:`summary`}}function k(e,t){let n=new URLSearchParams;return e.id===`executions`&&t.kind===`archive`&&n.set(`kind`,`archive`),e.id!==`overview`&&t.workflowName&&n.set(`workflow`,t.workflowName),j(e)&&t.state&&n.set(`state`,t.state),e.id!==`overview`&&t.offset>0&&n.set(`offset`,String(t.offset)),t.executionId&&n.set(`execution`,t.executionId),t.executionId&&t.tab!==`summary`&&(e.id===`overview`||e.id===`executions`)&&n.set(`tab`,t.tab),n}function A(e,t,n){return k(t,{...O(e,t),...n})}function se(e){return D.has(e)}function ce(e){return e&&e.length<=256?e:``}function le(e){if(!e||!/^(0|[1-9]\d*)$/.test(e))return 0;let t=Number(e);return Number.isSafeInteger(t)&&t<=1e6?Math.floor(t/25)*25:0}function ue(e,t){return j(t)?e?t.id===`archive`?e===`completed`||e===`failed`?e:``:oe.has(e)?e:``:``:t.state}function j(e){return e.id===`executions`||e.id===`archive`}var de=e=>`${e}?target=${encodeURIComponent(a())}`,M=e=>({method:`POST`,headers:e===void 0?void 0:{"Content-Type":`application/json`},body:e===void 0?void 0:JSON.stringify(e)});async function N(e,t){return(await s(de(e),t)).result}var P={status:()=>N(`/workflows/runtime`),reload:()=>N(`/workflows/runtime/reload`,M()),start:async(e,t)=>(await N(`/workflows/start`,M({workflowName:e,input:t}))).run,signal:async(e,t,n)=>{await N(`/workflows/${encodeURIComponent(e)}/signal`,M({event:t,payload:n}))},recover:async()=>(await N(`/workflows/recover`,M())).recovered,resumeCompensation:async e=>{await N(`/workflows/${encodeURIComponent(e)}/resume-compensation`,M())},abandonCompensation:async e=>{await N(`/workflows/${encodeURIComponent(e)}/abandon-compensation`,M())},archive:async(e,t)=>(await N(`/workflows/archive`,M({maxAgeMs:e,states:t}))).affected,cleanup:async(e,t)=>(await N(`/workflows/cleanup`,M({maxAgeMs:e,states:t}))).affected},fe={stats:()=>c.workflows.stats(),list:e=>c.workflows.list(e),get:(e,t)=>c.workflows.get(e,t)};function pe(e){let[n,r]=t(),i=n.toString(),a=(0,E.useMemo)(()=>O(new URLSearchParams(i),e),[i,e]),o=(0,E.useMemo)(()=>k(e,a).toString(),[e,a]),s=(0,E.useRef)(null);(0,E.useEffect)(()=>{o!==i&&r(o,{replace:!0})},[o,i,r]);let c=(0,E.useCallback)((t,n=!1)=>{r(n=>A(n,e,t),{replace:n})},[e,r]),l=(0,E.useCallback)((e,t=!1)=>{s.current=e,c({executionId:e?.id??null,tab:`summary`},t)},[c]),u=a.executionId?{id:a.executionId,source:s.current?.id===a.executionId?s.current.source:`link`}:null;return{...a,selected:u,update:c,select:l}}function F(e){let t=S(),n=`workflow-command:${e.operationGroup}`,r=w(n),i=(0,E.useMemo)(()=>({local:e.scopeKey,connectionEpoch:t}),[t,e.scopeKey]),a=(0,E.useRef)(e);a.current=e;let o=(0,E.useRef)(null),s=(0,E.useRef)(!0),c=(0,E.useRef)(i),l=(0,E.useRef)(0);if(!Object.is(c.current,i)){let e=c.current.connectionEpoch!==t;c.current=i,l.current+=1,e&&(o.current=null)}let[u,d]=(0,E.useState)(()=>I(i,t));(0,E.useEffect)(()=>(s.current=!0,()=>{s.current=!1,l.current+=1,o.current=null}),[]);let f=(e,t)=>s.current&&e===l.current&&t===C(),p=async(e,c)=>{if(o.current||t!==C())return;let u=r.begin(n);if(!u)return;let p=Symbol(`workflow-command`);o.current=p;let m=l.current,h=t,{onApplied:g,onSucceeded:_}=a.current;try{d({connectionEpoch:t,scope:i,busy:e,error:``,receipt:null});let n=await c();if(!f(m,h))return;d({connectionEpoch:t,scope:i,busy:e,error:``,receipt:{label:e,value:n}});try{_?.(e,n)}catch{}try{await g?.()}catch(e){f(m,h)&&d(t=>({...t,error:`Command succeeded; refresh failed: ${L(e)}`}))}}catch(n){f(m,h)&&d({connectionEpoch:t,scope:i,busy:e,error:L(n),receipt:null})}finally{u.finish(),o.current===p&&(o.current=null,s.current&&h===C()&&d(e=>({...e,busy:``})))}},m=Object.is(u.scope,i)?u:I(i,t);return{busy:u.connectionEpoch===t?u.busy:``,error:m.error,result:m.receipt?.value,succeeded:m.receipt?.label??``,run:p,clearResult:()=>d(e=>({...e,receipt:null}))}}function I(e,t){return{connectionEpoch:t,scope:e,busy:``,error:``,receipt:null}}function L(e){return e instanceof Error?e.message:String(e)}var R=i(),z=e=>JSON.stringify(e,null,2)??`null`;function B({value:e,empty:t=`None`}){return e==null||typeof e==`object`&&Object.keys(e).length===0?(0,R.jsx)(`p`,{className:`text-xs text-faint`,children:t}):(0,R.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs leading-5 text-muted`,children:z(e)})}function V({label:e,value:t}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`text-faint`,children:e}),(0,R.jsx)(`dd`,{className:`mt-0.5 break-words text-muted`,children:t})]})}var me=3600*1e3;function he({repository:e=P,onApplied:t}){let[n,r]=(0,E.useState)(`720`),[i,a]=(0,E.useState)(!0),[o,s]=(0,E.useState)(!0),c=F({operationGroup:`maintenance`,scopeKey:(0,E.useMemo)(()=>Symbol(`workflow-maintenance:${n.length}:${i}:${o}`),[i,o,n]),onApplied:t}),l=[...i?[`completed`]:[],...o?[`failed`]:[]],u=n.trim()===``?NaN:Number(n),d=Number.isFinite(u)&&u>=0&&l.length>0,f=t=>{if(!d)return;let n=t===`archive`?`Archive ${l.join(` and `)} workflows at least ${u} hours old?`:`Permanently delete ${l.join(` and `)} workflows at least ${u} hours old from the active execution store? Archive records are not deleted.`;if(!window.confirm(n))return;let r=Math.round(u*me);c.run(t,async()=>({operation:t,affected:t===`archive`?await e.archive(r,l):await e.cleanup(r,l)}))};return(0,R.jsxs)(`section`,{className:`mb-5 rounded-lg border border-line bg-surface p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Retention operations`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Archive moves terminal runs into retention. Cleanup permanently deletes eligible terminal runs from the active store only; archive records remain intact.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Minimum age (hours)`,(0,R.jsx)(`input`,{"aria-label":`Workflow retention age hours`,type:`number`,min:`0`,step:`1`,value:n,onChange:e=>r(e.target.value),className:`mt-1 block h-9 w-32 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]}),(0,R.jsxs)(`label`,{className:`flex h-9 items-center gap-2 text-xs text-muted`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),`Completed`]}),(0,R.jsxs)(`label`,{className:`flex h-9 items-center gap-2 text-xs text-muted`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Failed`]})]})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!d||!!c.busy,onClick:()=>f(`archive`),className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:`Archive eligible`}),(0,R.jsx)(`button`,{type:`button`,disabled:!d||!!c.busy,onClick:()=>f(`cleanup`),className:`rounded-md border border-danger/40 px-3 py-2 text-xs text-danger disabled:opacity-40`,children:`Delete eligible`})]}),c.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c.error}),c.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:c.result})})]})}var ge=[[`Active`,`activeTotal`,`text-fg`],[`Running`,`running`,`text-blue-400`],[`Waiting`,`waiting`,`text-warning`],[`Completed`,`completed`,`text-success`],[`Failed`,`failed`,`text-danger`],[`Compensating`,`compensating`,`text-violet-400`],[`Stuck`,`compensation-stuck`,`text-danger`]];function _e({stats:e}){return(0,R.jsx)(`dl`,{className:`mb-4 grid grid-cols-2 divide-x divide-y divide-line overflow-hidden rounded-lg border border-line bg-surface sm:grid-cols-4 xl:grid-cols-7 xl:divide-y-0`,children:ge.map(([t,n,r])=>(0,R.jsxs)(`div`,{className:`px-3 py-2.5 first:border-0`,children:[(0,R.jsx)(`dt`,{className:`text-[10px] font-medium uppercase tracking-wider text-faint`,children:t}),(0,R.jsx)(`dd`,{className:u(`mt-1 tnum font-mono text-lg font-semibold`,r),children:n===`activeTotal`?e.activeTotal:e.states[n]})]},n))})}function ve({repository:e=P,onApplied:t}){let[n,r]=(0,E.useState)(``),[i,a]=(0,E.useState)(`{}`),o=(0,E.useMemo)(()=>Symbol(`workflow-runtime:${n.length}:${i.length}`),[i,n]),s=f(()=>e.status(),[e],{intervalMs:5e3}),c=F({operationGroup:`runtime`,scopeKey:o,onApplied:async()=>{await s.refetch(),await t?.()}}),l=s.data?.ready===!0;return(0,R.jsxs)(`section`,{className:`mb-5 overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Workflow runtime`}),(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-faint`,children:`Registered application handlers stay in the agent-side runtime; commands never edit SQLite directly.`})]}),(0,R.jsx)(ye,{ready:l,configured:s.data?.configured===!0,unavailable:!!(s.error&&!s.data)})]}),s.data?.configured&&(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-line px-4 py-2 text-[11px] text-faint`,children:[(0,R.jsxs)(`span`,{children:[`Module`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.moduleName??`—`})]}),(0,R.jsxs)(`span`,{children:[`Queue`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.queueName??`—`})]}),(0,R.jsxs)(`span`,{children:[`Concurrency`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.concurrency??`—`})]})]}),s.error&&s.data&&(0,R.jsx)(m,{message:`Runtime status refresh failed; showing the last snapshot.`,onRetry:s.refetch}),s.error&&!s.data&&(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(h,{error:s.error,onRetry:s.refetch})}),(0,R.jsxs)(`div`,{className:`grid gap-5 p-4 lg:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Registered workflow`,(0,R.jsx)(`input`,{"aria-label":`Registered workflow`,list:`workflow-runtime-names`,value:n,onChange:e=>r(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`}),(0,R.jsx)(`datalist`,{id:`workflow-runtime-names`,children:s.data?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e},e))})]}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Input JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Workflow input JSON`,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-20 w-full resize-y rounded-lg border border-line bg-surface-2 p-2 font-mono text-xs text-fg`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap content-start gap-2 lg:w-48 lg:flex-col`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!l||!n.trim()||!!c.busy,onClick:()=>{let t;try{t=JSON.parse(i)}catch{c.run(`start`,async()=>{throw Error(`Workflow input must be valid JSON.`)});return}c.run(`start`,()=>e.start(n.trim(),t))},className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:c.busy===`start`?`Starting…`:`Start execution`}),(0,R.jsx)(`button`,{type:`button`,disabled:!l||!!c.busy,onClick:()=>{window.confirm(`Recover every orphaned workflow using the registered idempotent handlers?`)&&c.run(`recover`,()=>e.recover())},className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Recover orphaned`}),(0,R.jsx)(`button`,{type:`button`,disabled:!s.data?.configured||!!c.busy,onClick:()=>void c.run(`reload`,()=>e.reload()),className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Reload definitions`})]})]}),!s.loading&&!s.error&&!s.data?.configured&&(0,R.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-xs text-warning`,children:[`Set `,(0,R.jsx)(`code`,{children:`BUNQUEUE_WORKFLOW_MODULE`}),` to an absolute module path in Server → Extra environment, then start the managed server.`]}),s.data?.error&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:s.data.error}),c.error&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:c.error}),c.result!==void 0&&(0,R.jsx)(`div`,{className:`border-t border-line p-4`,children:(0,R.jsx)(B,{value:c.result})})]})}function ye({ready:e,configured:t,unavailable:n}){return(0,R.jsx)(`span`,{className:e?`rounded-full bg-success/10 px-2 py-1 text-[11px] text-success`:`rounded-full bg-warning/10 px-2 py-1 text-[11px] text-warning`,children:e?`Handlers loaded`:n?`Status unavailable`:t?`Unavailable`:`Not configured`})}var be=[``,`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`];function xe({section:e,kind:t,workflowName:n,state:r,stats:i,total:a,onKind:o,onWorkflowName:s,onState:c}){return(0,R.jsx)(p,{className:`mb-5`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[e.lockKind?(0,R.jsx)(H,{label:`Store`,value:`${e.kind}${e.kind===`archive`&&i?` · ${i.archiveTotal}`:``}`,capitalize:!0}):(0,R.jsx)(Se,{kind:t,archiveTotal:i?.archiveTotal,onChange:o}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Workflow`,(0,R.jsxs)(`select`,{value:n,onChange:e=>s(e.target.value),className:`mt-1 block h-9 min-w-48 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All workflows`}),i?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]}),e.lockState?(0,R.jsx)(H,{label:`State scope`,value:e.state===`compensation`?`Compensating + stuck`:e.state}):(0,R.jsx)(Ce,{state:r,onChange:c}),a!==void 0&&(0,R.jsxs)(`span`,{className:`ml-auto text-xs text-faint`,children:[a,` execution`,a===1?``:`s`]})]})})}function Se({kind:e,archiveTotal:t,onChange:n}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mb-1 block text-xs text-faint`,children:`Store`}),(0,R.jsx)(`div`,{className:`flex rounded-lg border border-line p-0.5`,children:[`active`,`archive`].map(r=>(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":e===r,onClick:()=>n(r),className:u(`rounded-md px-3 py-1.5 text-xs capitalize`,e===r?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:[r,r===`archive`&&t!==void 0?` (${t})`:``]},r))})]})}function Ce({state:e,onChange:t}){return(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`State`,(0,R.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`mt-1 block h-9 min-w-44 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:be.map(e=>(0,R.jsx)(`option`,{value:e,children:e===`compensation`?`All compensation`:e||`All states`},e||`all`))})]})}function H({label:e,value:t,capitalize:n=!1}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mb-1 block text-xs text-faint`,children:e}),(0,R.jsx)(`span`,{className:u(`inline-flex h-9 items-center rounded-lg border border-line bg-surface-2 px-3 text-xs text-fg`,n&&`capitalize`),children:t})]})}function we({label:e=`Workflow`,value:t,stats:n,onChange:r}){return(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[e,(0,R.jsxs)(`select`,{value:t,onChange:e=>r(e.target.value),className:`mt-1 block h-9 min-w-52 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All workflows`}),n?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})}function Te(e){return e.section.id===`overview`?null:e.section.id===`executions`?(0,R.jsx)(xe,{...e}):(0,R.jsxs)(`div`,{className:`mb-5 flex items-end gap-4 rounded-lg border border-line bg-surface px-4 py-3`,children:[(0,R.jsx)(we,{value:e.workflowName,stats:e.stats,onChange:e.onWorkflowName}),e.section.id===`archive`&&(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Outcome`,(0,R.jsxs)(`select`,{value:e.state,onChange:t=>e.onState(t.target.value),className:`mt-1 block h-9 min-w-36 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All outcomes`}),(0,R.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,R.jsx)(`option`,{value:`failed`,children:`Failed`})]})]}),(0,R.jsxs)(`span`,{className:`ml-auto pb-2 text-xs text-faint`,children:[e.total??0,` `,e.section.id===`archive`?`records`:`executions`]})]})}function Ee(e){let t=[{id:`execution-started`,at:e.createdAt,title:`Execution started`,detail:e.workflowName,status:`running`,category:`execution`}];for(let[n,r]of Object.entries(e.steps))t.push(...De(n,r));for(let n of Object.keys(e.signals))t.push({id:`signal:${n}`,title:`Signal persisted: ${n}`,detail:`The store does not expose an exact signal timestamp.`,category:`signal`});return e.state!==`running`&&e.state!==`waiting`&&t.push({id:`execution-settled`,at:e.updatedAt,title:`Execution ${e.state}`,detail:e.failureReason,status:e.state,category:`execution`}),t.sort(Oe)}function De(e,t){let n=[];return t.startedAt!==void 0&&n.push({id:`step:${e}:started`,at:t.startedAt,title:`Step started: ${e}`,detail:t.attempts?`Attempt ${t.attempts}`:void 0,status:`running`,category:`step`}),(t.completedAt!==void 0||t.status===`failed`)&&n.push({id:`step:${e}:settled`,at:t.completedAt,title:`Step ${t.status}: ${e}`,detail:t.error,status:t.status,category:`step`}),t.compensation&&n.push({id:`step:${e}:compensation`,at:t.compensation.at,title:`Compensation ${t.compensation.status}: ${e}`,detail:t.compensation.error,status:t.compensation.status,category:`compensation`}),n}function Oe(e,t){return e.at===void 0&&t.at===void 0?e.id.localeCompare(t.id):e.at===void 0?1:t.at===void 0?-1:e.at-t.at||e.id.localeCompare(t.id)}function U({execution:e}){let t=Ee(e);return(0,R.jsx)(`ol`,{className:`divide-y divide-line/70 border-y border-line/70`,children:t.map((e,n)=>(0,R.jsxs)(`li`,{className:`grid grid-cols-[28px_minmax(0,1fr)] gap-3 py-3`,children:[(0,R.jsxs)(`div`,{className:`relative flex justify-center`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:`mt-1.5 size-2 rounded-full border-2 border-surface bg-accent ring-1 ring-line`}),n<t.length-1&&(0,R.jsx)(`span`,{className:`absolute top-5 bottom-[-13px] w-px bg-line`})]}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`break-words text-sm font-medium text-fg`,children:e.title}),e.status&&(0,R.jsx)(d,{status:e.status})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 text-xs text-faint`,children:[(0,R.jsx)(`span`,{className:`capitalize`,children:e.category}),(0,R.jsx)(`span`,{children:e.at===void 0?`Timestamp unavailable`:b(e.at)})]}),e.detail&&(0,R.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-muted`,children:e.detail})]})]},e.id))})}var W={now:Date.now,subscribe:e=>{let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)}};function ke({since:e,clock:t=W}){let n=G(t);return(0,R.jsx)(R.Fragment,{children:y(Math.max(0,n-e))})}function G(e=W,t=!0){let[n,r]=(0,E.useState)(()=>e.now());return(0,E.useEffect)(()=>{if(r(e.now()),t)return e.subscribe(()=>r(e.now()))},[e,t]),n}function K({error:e,onRetry:t}){return e?(0,R.jsx)(m,{message:`Execution refresh failed; showing the last persisted snapshot.`,onRetry:t}):null}async function q(e,t){await Promise.all([e(),t?.()])}function Ae({repository:e,id:t,pollIntervalMs:n=1e4}){let{data:r,error:i,loading:a,refetch:o}=f(()=>e.get(t,`archive`),[e,t],{intervalMs:n});if(a&&!r)return(0,R.jsx)(g,{label:`Loading audit record…`});if(i&&!r)return(0,R.jsx)(h,{error:i,onRetry:o});let s=r?.execution;return s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:i,onRetry:o}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Immutable audit record`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:s.id})]}),(0,R.jsx)(d,{status:s.state})]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Workflow`,value:s.workflowName}),(0,R.jsx)(V,{label:`Runtime`,value:y(s.updatedAt-s.createdAt)}),(0,R.jsx)(V,{label:`Archived`,value:s.archivedAt?b(s.archivedAt):`Unavailable`}),(0,R.jsx)(V,{label:`Definition hash`,value:s.definitionHash??`Unavailable`}),(0,R.jsx)(V,{label:`Final node`,value:String(s.currentNodeIndex)}),(0,R.jsx)(V,{label:`Final transition`,value:b(s.updatedAt)})]}),(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(U,{execution:s})})]})]}):null}function je({repository:e,executionId:t,stuck:n,onApplied:r}){let i=F({operationGroup:`compensation`,scopeKey:`${t}:${n}`,onApplied:r,onSucceeded:e=>l.success(e===`resume`?`Compensation resumed`:`Compensation abandoned`,t)});return n?(0,R.jsxs)(`div`,{className:`border-t border-line p-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-faint`,children:`Operator decision`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Retry after fixing the reversal, or explicitly abandon the remaining compensation steps.`}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!!i.busy,onClick:()=>{window.confirm(`Retry the stuck compensation for ${t}? Handlers must be idempotent.`)&&i.run(`resume`,()=>e.resumeCompensation(t))},className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:`Resume compensation`}),(0,R.jsx)(`button`,{type:`button`,disabled:!!i.busy,onClick:()=>{window.confirm(`Abandon remaining compensation for ${t}? This is irreversible.`)&&i.run(`abandon`,()=>e.abandonCompensation(t))},className:`rounded-md border border-danger/40 px-3 py-2 text-xs text-danger disabled:opacity-40`,children:`Abandon remainder`})]}),i.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:i.error}),i.succeeded&&(0,R.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:i.succeeded===`resume`?`Resume command accepted; recovery state refreshed.`:`Abandon command accepted; recovery state refreshed.`}),i.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:i.result})})]}):null}function Me({repository:e,controlRepository:t,id:n,onApplied:r,pollIntervalMs:i=5e3}){let{data:a,error:o,loading:s,refetch:c}=f(()=>e.get(n,`active`),[e,n],{intervalMs:i});if(s&&!a)return(0,R.jsx)(g,{label:`Loading recovery plan…`});if(o&&!a)return(0,R.jsx)(h,{error:o,onRetry:c});let l=a?.execution;if(!l)return null;let u=Object.entries(l.steps).filter(([,e])=>e.compensatable||e.compensation);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:o,onRetry:c}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-violet-400`,children:`Recovery plan`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:l.id})]}),(0,R.jsx)(d,{status:l.state})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Compensation pivot`}),(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:l.committedAt===void 0?`Not committed`:`Node ${l.committedAt}`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Rollback state`}),(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:l.rollbackStatus??l.state})]})]}),l.failureReason&&(0,R.jsx)(`div`,{role:`alert`,className:`border-b border-danger/30 bg-danger/[0.06] px-4 py-3 text-xs text-danger`,children:l.failureReason}),(0,R.jsxs)(`div`,{className:`p-4`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Compensation ledger`}),u.length?(0,R.jsx)(`ol`,{className:`space-y-2`,children:u.reverse().map(([e,t])=>(0,R.jsxs)(`li`,{className:`grid gap-2 rounded-md border border-line px-3 py-2 text-xs sm:grid-cols-[1fr_auto]`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-mono text-fg`,children:e}),(0,R.jsx)(`div`,{className:`mt-1 text-faint`,children:t.compensation?.error??`Compensation handler registered`})]}),(0,R.jsxs)(`div`,{className:`text-right text-muted`,children:[t.compensation?t.compensation.status:`pending`,t.compensation?.at?(0,R.jsx)(`div`,{className:`mt-1 text-[10px] text-faint`,children:b(t.compensation.at)}):null]})]},e))}):(0,R.jsx)(`p`,{className:`text-sm text-muted`,children:`No compensatable step was persisted.`})]}),(0,R.jsx)(je,{repository:t,executionId:n,stuck:l.state===`compensation-stuck`,onApplied:()=>q(c,r)},n)]})]})}function Ne({execution:e}){return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsx)(J,{title:`Input`,value:e.input}),(0,R.jsx)(J,{title:`Signals`,value:e.signals}),(0,R.jsx)(J,{title:`Resolved steps`,value:e.resolvedSteps}),(0,R.jsx)(J,{title:`Decisions`,value:e.decisions})]})}function J({title:e,value:t}){return(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-faint`,children:e}),(0,R.jsx)(B,{value:t})]})}function Pe({steps:e,onSelect:t}){let n=Object.entries(e);return n.length===0?(0,R.jsx)(`p`,{className:`text-xs text-faint`,children:`No persisted step records.`}):(0,R.jsx)(`ol`,{className:`space-y-3`,children:n.map(([e,r],i)=>(0,R.jsx)(Fe,{name:e,step:r,last:i===n.length-1,onSelect:t},e))})}function Fe({name:e,step:t,last:n,onSelect:r}){let i=t.startedAt!==void 0&&t.completedAt!==void 0?t.completedAt-t.startedAt:void 0;return(0,R.jsxs)(`li`,{className:`relative grid grid-cols-[18px_1fr] gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col items-center`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full bg-current text-accent`}),!n&&(0,R.jsx)(`span`,{className:`mt-1 w-px flex-1 bg-line`})]}),(0,R.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-line bg-surface-2 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{translate:`no`,className:`break-all font-mono text-sm font-medium text-fg`,children:e}),(0,R.jsx)(d,{status:t.status})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-faint`,children:[t.attempts!==void 0&&(0,R.jsxs)(`span`,{children:[t.attempts,` attempt`,t.attempts===1?``:`s`]}),i!==void 0&&(0,R.jsx)(`span`,{children:y(i)}),t.occurrence!==void 0&&(0,R.jsxs)(`span`,{children:[`Occurrence `,t.occurrence]}),t.loopIndex!==void 0&&(0,R.jsxs)(`span`,{children:[`Loop index `,t.loopIndex]}),t.compensatable&&(0,R.jsx)(`span`,{children:`Compensatable`})]}),t.idempotencyKey&&(0,R.jsxs)(`div`,{className:`mt-2 break-all font-mono text-[11px] text-faint`,children:[`Idempotency: `,t.idempotencyKey]}),t.childExecutionId&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t.childExecutionId),className:`mt-2 break-all font-mono text-xs text-accent hover:underline`,children:[`Child execution: `,t.childExecutionId]}),t.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-2 whitespace-pre-wrap text-xs text-danger`,children:t.error}),t.compensation&&(0,R.jsxs)(`div`,{className:`mt-3 rounded-md border border-line px-3 py-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-faint`,children:`Compensation`}),(0,R.jsx)(d,{status:t.compensation.status}),(0,R.jsx)(`span`,{className:`text-faint`,children:b(t.compensation.at)})]}),t.compensation.error&&(0,R.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-danger`,children:t.compensation.error})]}),(0,R.jsx)(Ie,{step:t})]})]})}function Ie({step:e}){return(0,R.jsxs)(R.Fragment,{children:[Object.hasOwn(e,`result`)&&(0,R.jsx)(Y,{label:`Result`,value:e.result}),Object.hasOwn(e,`loopItem`)&&(0,R.jsx)(Y,{label:`Loop item`,value:e.loopItem})]})}function Y({label:e,value:t}){return(0,R.jsxs)(`details`,{className:`mt-3`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted`,children:e}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(B,{value:t})})]})}function Le({execution:e,onSelect:t}){let n=Object.values(e.steps),r=n.filter(e=>e.status===`completed`).length;return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 border-b border-line pb-5 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Current node`,value:String(e.currentNodeIndex)}),(0,R.jsx)(V,{label:`Step progress`,value:`${r}/${n.length} completed`}),(0,R.jsx)(V,{label:`Duration`,value:y(e.updatedAt-e.createdAt)}),(0,R.jsx)(V,{label:`Started`,value:b(e.createdAt)}),(0,R.jsx)(V,{label:`Last transition`,value:b(e.updatedAt)}),(0,R.jsx)(V,{label:`Rollback`,value:e.rollbackStatus??`Not started`})]}),e.failureReason&&(0,R.jsxs)(`div`,{role:`alert`,className:`border-l-2 border-danger bg-danger/[0.06] px-3 py-2 text-xs text-danger`,children:[(0,R.jsx)(`div`,{className:`mb-1 font-medium`,children:`Failure`}),(0,R.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.failureReason})]}),(0,R.jsx)(Re,{execution:e,onSelect:t}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Step state`}),(0,R.jsx)(Pe,{steps:e.steps,onSelect:t})]})]})}function Re({execution:e,onSelect:t}){return!e.parentExecutionId&&!e.definitionHash&&e.committedAt===void 0?null:(0,R.jsxs)(`div`,{className:`grid gap-3 border-b border-line pb-5 text-xs sm:grid-cols-2`,children:[e.parentExecutionId&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Parent execution`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.parentExecutionId),className:`mt-1 break-all font-mono text-accent hover:underline`,children:e.parentExecutionId})]}),e.definitionHash&&(0,R.jsx)(V,{label:`Definition hash`,value:e.definitionHash}),e.committedAt!==void 0&&(0,R.jsx)(V,{label:`Compensation pivot`,value:`Node ${e.committedAt}`}),(0,R.jsx)(`div`,{className:`flex items-end`,children:(0,R.jsx)(d,{status:e.state})})]})}var ze=[{id:`summary`,label:`Summary`},{id:`history`,label:`History`},{id:`payloads`,label:`Payloads`}];function X({repository:e,id:t,kind:n,onSelect:r}){return(0,R.jsx)(Be,{repository:e,id:t,kind:n,onSelect:r},`${n}:${t}`)}function Be({repository:e,id:n,kind:r,onSelect:i}){let[a,o]=t(),s=a.get(`tab`),c=se(s)?s:`summary`,{data:l,error:p,loading:_,refetch:v}=f(()=>e.get(n,r),[e,n,r],{intervalMs:5e3});if(_&&!l)return(0,R.jsx)(Z,{children:(0,R.jsx)(g,{label:`Loading execution…`})});if(p&&!l)return(0,R.jsx)(Z,{children:(0,R.jsx)(h,{error:p,onRetry:v})});let y=l?.execution;return y?(0,R.jsxs)(Z,{children:[p&&(0,R.jsx)(m,{message:`Execution refresh failed. Showing the last snapshot.`,onRetry:v}),(0,R.jsx)(`header`,{className:`border-b border-line px-4 py-3`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Execution`}),(0,R.jsx)(`h2`,{translate:`no`,className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:y.id}),(0,R.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:y.workflowName})]}),(0,R.jsx)(d,{status:y.state})]})}),(0,R.jsx)(`nav`,{"aria-label":`Execution detail`,className:`flex border-b border-line px-2`,children:ze.map(e=>(0,R.jsx)(`button`,{type:`button`,"aria-pressed":c===e.id,onClick:()=>{o(t=>{let n=new URLSearchParams(t);return e.id===`summary`?n.delete(`tab`):n.set(`tab`,e.id),n})},className:u(`border-b-2 px-3 py-2 text-xs font-medium`,c===e.id?`border-accent text-fg`:`border-transparent text-faint hover:text-muted`),children:e.label},e.id))}),(0,R.jsxs)(`div`,{className:`p-4`,"aria-live":`polite`,children:[c===`summary`&&(0,R.jsx)(Le,{execution:y,onSelect:i}),c===`history`&&(0,R.jsx)(U,{execution:y}),c===`payloads`&&(0,R.jsx)(Ne,{execution:y})]})]}):null}function Z({children:e}){return(0,R.jsx)(`section`,{className:`min-w-0 overflow-hidden rounded-lg border border-line bg-surface`,children:e})}function Q({total:e,offset:t,pageSize:n,count:r,onPage:i}){let a=r===0?0:t+1,o=Math.min(t+r,e);return(0,R.jsxs)(`nav`,{"aria-label":`Workflow execution pages`,className:`mt-3 flex items-center justify-between`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:t===0,onClick:()=>i(Math.max(0,t-n)),className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted disabled:opacity-40`,children:`Previous`}),(0,R.jsxs)(`span`,{className:`text-xs text-faint`,children:[a,`–`,o,` of `,e]}),(0,R.jsx)(`button`,{type:`button`,disabled:t+n>=e,onClick:()=>i(t+n),className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted disabled:opacity-40`,children:`Next`})]})}var Ve=e=>e.length>22?`${e.slice(0,12)}…${e.slice(-7)}`:e;function He({executions:e,total:t,offset:n,pageSize:r,selected:i,onSelect:a,onPage:o}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-line bg-surface`,children:(0,R.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,R.jsx)(`thead`,{className:`bg-surface-2/80`,children:(0,R.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workflow / execution`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Status`}),(0,R.jsx)(`th`,{className:`hidden px-3 py-2 font-medium md:table-cell`,children:`Node`}),(0,R.jsx)(`th`,{className:`hidden px-3 py-2 font-medium lg:table-cell`,children:`Elapsed`}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Updated`})]})}),(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsx)(Ue,{execution:e,selected:i?.id===e.id,onSelect:a},e.id))})]})}),(0,R.jsx)(Q,{total:t,offset:n,pageSize:r,count:e.length,onPage:o})]})}function Ue({execution:e,selected:t,onSelect:n}){return(0,R.jsxs)(`tr`,{className:u(`border-b border-line/70 last:border-0`,t&&`bg-surface-2`),children:[(0,R.jsx)(`td`,{className:`p-0`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n({id:e.id,source:`page`}),className:`block w-full px-3 py-2.5 text-left focus-visible:outline-2 focus-visible:outline-inset focus-visible:outline-accent`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium text-fg`,children:e.workflowName}),(0,R.jsx)(`span`,{translate:`no`,title:e.id,className:`mt-0.5 block font-mono text-[11px] text-faint`,children:Ve(e.id)})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,R.jsx)(d,{status:e.state})}),(0,R.jsx)(`td`,{className:`hidden px-3 py-2.5 font-mono text-xs text-muted md:table-cell`,children:e.currentNodeIndex}),(0,R.jsx)(`td`,{className:`hidden whitespace-nowrap px-3 py-2.5 font-mono text-xs text-muted lg:table-cell`,children:y(e.updatedAt-e.createdAt)}),(0,R.jsx)(`td`,{title:b(e.updatedAt),className:`whitespace-nowrap px-3 py-2.5 text-right text-xs text-muted`,children:x(e.updatedAt)})]})}function We({mode:e,rows:t,selected:n,onSelect:r,total:i,offset:a,pageSize:o,onPage:s,clock:c=W}){let l=G(c,e===`waiting`);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`section`,{className:`overflow-x-auto rounded-lg border border-line bg-surface`,children:(0,R.jsxs)(`table`,{className:`w-full min-w-[560px] text-sm`,children:[(0,R.jsx)(`thead`,{className:`border-b border-line bg-surface-2/80 text-left text-[10px] uppercase tracking-wider text-faint`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e===`archive`?`Execution record`:`Execution`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workflow`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:Ge(e)}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:Ke(e)})]})}),(0,R.jsx)(`tbody`,{children:t.map(t=>(0,R.jsxs)(`tr`,{className:u(`border-b border-line last:border-0`,n?.id===t.id&&`bg-surface-2`),children:[(0,R.jsx)(`td`,{className:`p-0`,children:(0,R.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-3 text-left font-mono text-xs text-fg`,onClick:()=>r({id:t.id,source:`page`}),children:t.id})}),(0,R.jsx)(`td`,{className:`px-3 py-3 text-muted`,children:t.workflowName}),(0,R.jsx)(`td`,{className:`px-3 py-3`,children:(0,R.jsx)(qe,{mode:e,row:t})}),(0,R.jsx)(`td`,{className:`whitespace-nowrap px-3 py-3 text-right text-xs text-muted`,children:Je(e,t,l)})]},t.id))})]})}),(0,R.jsx)(Q,{total:i,offset:a,pageSize:o,count:t.length,onPage:s})]})}var Ge=e=>e===`waiting`?`Resume node`:e===`compensation`?`Recovery state`:`Outcome`,Ke=e=>e===`archive`?`Archived`:e===`waiting`?`Waiting`:`Updated`;function qe({mode:e,row:t}){return e===`waiting`?(0,R.jsxs)(`span`,{className:`font-mono text-xs text-warning`,children:[`Node `,t.currentNodeIndex]}):(0,R.jsx)(d,{status:t.state})}function Je(e,t,n){return e===`archive`?t.archivedAt?b(t.archivedAt):`Unavailable`:e===`waiting`?y(Math.max(0,n-t.updatedAt)):x(t.updatedAt)}function $({stats:e,page:t,repository:n,kind:r,selected:i,onSelect:a}){let o=t.executions.filter(e=>[`waiting`,`failed`,`compensation-stuck`].includes(e.state));return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsx)(Ye,{stats:e}),(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(320px,0.7fr)_minmax(0,1.3fr)]`,children:[(0,R.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`border-b border-line px-4 py-3`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Needs attention`}),(0,R.jsxs)(`p`,{className:`mt-0.5 text-xs text-faint`,children:[`Waiting, failed, and stuck executions · showing `,o.length,` of `,t.total,`.`]})]}),(0,R.jsx)(Xe,{rows:o,selected:i,onSelect:a})]}),i&&(0,R.jsx)(X,{repository:n,id:i.id,kind:r,onSelect:e=>a({id:e,source:`link`})})]})]})}function Ye({stats:e}){return(0,R.jsx)(`dl`,{className:`grid overflow-hidden rounded-lg border border-line bg-surface sm:grid-cols-2 xl:grid-cols-4`,children:[[`Open executions`,e.activeTotal],[`Waiting for signal`,e.states.waiting],[`Recovery required`,e.states[`compensation-stuck`]+e.states.failed],[`Retained in archive`,e.archiveTotal]].map(([e,t])=>(0,R.jsxs)(`div`,{className:`border-b border-line px-4 py-3 sm:border-r xl:border-b-0`,children:[(0,R.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-faint`,children:e}),(0,R.jsx)(`dd`,{className:`mt-1 font-mono text-xl font-semibold text-fg`,children:t})]},e))})}function Xe({rows:e,selected:t,onSelect:n}){return e.length?(0,R.jsx)(`ul`,{className:`divide-y divide-line`,children:e.map(e=>(0,R.jsx)(`li`,{className:t?.id===e.id?`bg-surface-2`:void 0,children:(0,R.jsxs)(`button`,{type:`button`,className:`w-full px-4 py-3 text-left`,onClick:()=>n({id:e.id,source:`page`}),children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.workflowName}),(0,R.jsx)(`span`,{className:`text-xs text-faint`,children:x(e.updatedAt)})]}),(0,R.jsxs)(`span`,{className:`mt-1 flex items-center justify-between gap-3 font-mono text-[11px] text-faint`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.id}),(0,R.jsx)(`span`,{children:e.state})]})]})},e.id))}):(0,R.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`No intervention required.`})}function Ze({repository:e,executionId:t,onApplied:n}){let[r,i]=(0,E.useState)(``),[a,o]=(0,E.useState)(`{}`),s=F({operationGroup:`signal`,scopeKey:t,onApplied:n,onSucceeded:()=>l.success(`Workflow signal accepted`,`${r.trim()} · ${t}`)});return(0,R.jsxs)(`div`,{className:`border-t border-line p-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-faint`,children:`Send signal`}),(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Event name`,(0,R.jsx)(`input`,{"aria-label":`Workflow signal event`,value:r,onChange:e=>i(e.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,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Payload JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Workflow signal payload`,value:a,onChange:e=>o(e.target.value),className:`mt-1 min-h-20 w-full resize-y rounded-lg border border-line bg-surface-2 p-2 font-mono text-xs text-fg`})]})]}),(0,R.jsx)(`button`,{type:`button`,disabled:!r.trim()||!!s.busy,onClick:()=>{let n;try{n=JSON.parse(a)}catch{s.run(`signal`,async()=>{throw Error(`Signal payload must be valid JSON.`)});return}window.confirm(`Send durable signal "${r.trim()}" to ${t}?`)&&s.run(`signal`,()=>e.signal(t,r.trim(),n))},className:`mt-3 rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:s.busy?`Sending…`:`Send durable signal`}),s.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:s.error}),s.succeeded&&(0,R.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:`Durable signal accepted; execution and list refreshed.`}),s.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:s.result})})]})}function Qe({repository:e,controlRepository:t,id:n,onApplied:r,clock:i,pollIntervalMs:a=5e3}){let{data:o,error:s,loading:c,refetch:l}=f(()=>e.get(n,`active`),[e,n],{intervalMs:a});if(c&&!o)return(0,R.jsx)(g,{label:`Loading signal inbox…`});if(s&&!o)return(0,R.jsx)(h,{error:s,onRetry:l});let u=o?.execution;if(!u)return null;let d=Object.entries(u.signals);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:s,onRetry:l}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`border-b border-line px-4 py-3`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-warning`,children:`Signal inbox`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:u.id})]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Waiting at node`,value:String(u.currentNodeIndex)}),(0,R.jsx)(V,{label:`Parked for`,value:(0,R.jsx)(ke,{since:u.updatedAt,clock:i})}),(0,R.jsx)(V,{label:`Last transition`,value:b(u.updatedAt)})]}),(0,R.jsxs)(`div`,{className:`p-4`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Durable signals`}),d.length?d.map(([e,t])=>(0,R.jsxs)(`div`,{className:`mb-3 last:mb-0`,children:[(0,R.jsx)(`div`,{className:`mb-1 font-mono text-xs text-warning`,children:e}),(0,R.jsx)(B,{value:t})]},e)):(0,R.jsx)(`p`,{className:`text-sm text-muted`,children:`No signal has been persisted yet. The execution remains parked.`})]}),(0,R.jsx)(Ze,{repository:t,executionId:n,onApplied:()=>q(l,r)},n)]})]})}function $e(e){return e.section.id===`overview`?(0,R.jsx)($,{...e}):e.section.id===`executions`?(0,R.jsx)(et,{...e}):(0,R.jsx)(tt,{...e})}function et({repository:e,kind:t,page:n,selected:r,offset:i,pageSize:a,onSelect:o,onPage:s}){return(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(390px,0.8fr)_minmax(0,1.4fr)]`,children:[(0,R.jsx)(He,{executions:n.executions,total:n.total,offset:i,pageSize:a,selected:r,onSelect:o,onPage:s}),r&&(0,R.jsx)(X,{repository:e,id:r.id,kind:t,onSelect:e=>o({id:e,source:`link`})})]})}function tt(e){let t=e.section.id;return(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(420px,0.95fr)_minmax(0,1.05fr)]`,children:[(0,R.jsx)(We,{mode:t,rows:e.page.executions,selected:e.selected,onSelect:e.onSelect,total:e.page.total,offset:e.offset,pageSize:e.pageSize,onPage:e.onPage}),e.selected&&(0,R.jsx)(nt,{...e,id:e.selected.id})]})}function nt({section:e,repository:t,controlRepository:n,onRefresh:r,id:i}){return e.id===`waiting`?(0,R.jsx)(Qe,{repository:t,controlRepository:n,id:i,onApplied:r}):e.id===`compensation`?(0,R.jsx)(Me,{repository:t,controlRepository:n,id:i,onApplied:r}):(0,R.jsx)(Ae,{repository:t,id:i})}function rt({repository:e=fe,controlRepository:t=P}){let{pathname:n}=r(),i=ee(n),a=pe(i),{kind:o,workflowName:s,state:c,offset:l,selected:u,update:d,select:p}=a,h={kind:o,workflowName:s||void 0,state:c||void 0,limit:25,offset:l},{data:g,error:_,loading:y,refetch:b}=f(()=>i.id===`overview`?ie(e,25):re(e,h),[e,i.id,o,s,c,l],{intervalMs:5e3});(0,E.useEffect)(()=>{let e=g?.page.total;if(e===void 0||l===0)return;let t=e===0?0:Math.floor((e-1)/25)*25;l>t&&d({offset:t,executionId:null,tab:`summary`},!0)},[g?.page.total,l,d]),(0,E.useEffect)(()=>{let e=g?.page.executions;if(e){let t=i.id===`overview`?e.filter(e=>[`waiting`,`failed`,`compensation-stuck`].includes(e.state)):e,n=te(u,t);n?.id!==u?.id&&p(n,!0)}},[g?.page.executions,i.id,u,p]);let x=g?.stats,S=g?.page;return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(v,{title:(0,R.jsxs)(R.Fragment,{children:[`Workflow `,(0,R.jsxs)(`span`,{className:`text-faint`,children:[`/ `,i.label]})]}),description:i.description,live:!!(g&&!_),actions:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Refresh`})}),i.id===`overview`&&(0,R.jsx)(ve,{repository:t,onApplied:b}),i.id===`archive`&&(0,R.jsx)(he,{repository:t,onApplied:b}),i.id===`executions`&&x&&(0,R.jsx)(_e,{stats:x}),(0,R.jsx)(Te,{section:i,kind:o,workflowName:s,state:c,stats:x??void 0,total:S?.total,onKind:e=>{a.update({kind:e,offset:0,executionId:null,tab:`summary`},!1)},onWorkflowName:e=>{a.update({workflowName:e,offset:0,executionId:null,tab:`summary`},!1)},onState:e=>{a.update({state:e,offset:0,executionId:null,tab:`summary`},!1)}}),_&&g&&(0,R.jsx)(m,{message:`Workflow refresh failed — showing the last snapshot.`,onRetry:b}),(0,R.jsx)(it,{repository:e,controlRepository:t,section:i,stats:x,kind:o,page:S,error:_,loading:y,dataPresent:!!g,selected:u,offset:l,onRetry:b,onSelect:e=>a.select(e),onPage:e=>{a.update({offset:e,executionId:null,tab:`summary`})}})]})}function it({repository:e,controlRepository:t,section:n,stats:r,kind:i,page:a,error:o,loading:s,dataPresent:c,selected:l,offset:u,onRetry:d,onSelect:f,onPage:p}){return o&&!c?(0,R.jsx)(h,{error:o,onRetry:d}):s&&!c?(0,R.jsx)(g,{label:`Loading workflows…`}):a?.available?a.executions.length===0&&a.total>0&&u>0?(0,R.jsx)(g,{label:`Loading workflow page…`}):a.executions.length===0?(0,R.jsx)(_,{title:`No executions match these filters`,hint:`Change the store, workflow, or state filter.`}):r?(0,R.jsx)($e,{section:n,repository:e,controlRepository:t,kind:i,stats:r,page:a,selected:l,offset:u,pageSize:25,onSelect:f,onPage:p,onRefresh:d}):null:(0,R.jsx)(_,{title:`Workflow store not initialized`,hint:`Start a Bunqueue Workflow Engine with this server dataPath; its official workflow_executions tables will appear here automatically.`})}export{rt as Workflows};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t}from"./connectionStore-
|
|
1
|
+
import{a as e,i as t}from"./connectionStore-CVjQyIZv.js";import{a as n,n as r,r as i,s as a}from"./upstreamPaths-DQeKSxGc.js";var o=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`ApiError`}},s=3e4;async function c(n,r,i=!0,a=[],c=`json`){let l=AbortSignal.timeout(s),u=r?.signal?AbortSignal.any([r.signal,l]):l,d=new Headers(t());r?.headers&&new Headers(r.headers).forEach((e,t)=>{d.set(t,e)}),r?.body!=null&&!d.has(`Content-Type`)&&d.set(`Content-Type`,`application/json`);let f;try{f=await fetch(e()+n,{...r,headers:d,signal:u})}catch(e){throw l.aborted&&!r?.signal?.aborted||e?.name===`TimeoutError`?new o(`Request timed out`,0):e}if(!f.ok&&!a.includes(f.status)){let e=`HTTP ${f.status}`;try{let t=await f.json();t?.error&&(e=t.error)}catch{}throw new o(e,f.status)}if(f.status===204)return;let p;try{p=await f.text()}catch(e){throw l.aborted&&!r?.signal?.aborted?new o(`Request timed out`,0):e}if(!p)return;if(c===`text`)return p;let m;try{m=JSON.parse(p)}catch{throw new o(`Invalid JSON response (HTTP ${f.status})`,f.status)}if(i&&m&&typeof m==`object`&&m.ok===!1){let e=m.error;throw new o(e??`Operation failed`,f.status)}return m}var l=a,u=(e,t)=>c(e,{method:`POST`,body:t?JSON.stringify(t):void 0}),d=(e,t)=>c(e,{method:`PUT`,body:t?JSON.stringify(t):void 0}),f=e=>c(e,{method:`DELETE`}),p={overview:()=>c(`/dashboard`),queues:(e=200,t=0)=>c(`/dashboard/queues?limit=${e}&offset=${t}`),queueDetail:(e,t=!0)=>c(`/dashboard/queues/${l(e)}?includeJobs=${t}`),stats:()=>c(`/stats`),storage:()=>c(`/storage`,void 0,!1),health:()=>c(`/health`,void 0,!1,[503]),healthz:()=>c(`/healthz`,void 0,!0,[],`text`),live:()=>c(`/live`,void 0,!0,[],`text`),ready:()=>c(`/ready`,void 0,!1,[503]),metrics:()=>c(`/metrics`),jobsList:(e,t={})=>{let n=new URLSearchParams;return t.states?.length&&n.set(`states`,t.states.join(`,`)),n.set(`limit`,String(t.limit??50)),n.set(`offset`,String(t.offset??0)),c(`/queues/${l(e)}/jobs/list?${n.toString()}`)},job:e=>c(`/jobs/${n(e)}`),cancelJob:e=>f(`/jobs/${n(e)}`),promoteJob:e=>u(`/jobs/${n(e)}/promote`),retryJob:e=>u(`/jobs/${n(e)}/move-to-wait`),pause:e=>u(`/queues/${l(e)}/pause`),resume:e=>u(`/queues/${l(e)}/resume`),drain:e=>u(`/queues/${l(e)}/drain`),obliterate:e=>u(`/queues/${l(e)}/obliterate`),clean:(e,t=0,n=1e3)=>u(`/queues/${l(e)}/clean`,{grace:t,limit:n}),retryCompleted:e=>{throw TypeError(`Completed-job requeue is unavailable in Bunqueue v2.9.3 because flow dependency registration is not rebuilt.`)},setRateLimit:(e,t)=>d(`/queues/${l(e)}/rate-limit`,{limit:t}),clearRateLimit:e=>f(`/queues/${l(e)}/rate-limit`),setConcurrency:(e,t)=>d(`/queues/${l(e)}/concurrency`,{concurrency:t}),clearConcurrency:e=>f(`/queues/${l(e)}/concurrency`),dlq:(e,t=50,n=0)=>c(`/queues/${l(e)}/dlq?limit=${t}&offset=${n}`),dlqStats:e=>c(`/queues/${l(e)}/dlq/stats`),retryDlq:e=>{throw TypeError(`DLQ retry is unavailable in Bunqueue v2.9.3 because the endpoint has no atomic flow-safety precondition.`)},purgeDlq:e=>u(`/queues/${l(e)}/dlq/purge`),crons:()=>c(`/crons`),deleteCron:e=>f(`/crons/${r(e,`Cron name`,256)}`),workers:()=>c(`/workers`),eventsUrl:t=>e()+(t?`/events/queues/${i(t)}`:`/events`)};export{p as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,r}from"./connectionStore-CVjQyIZv.js";import{a as i,i as a,n as o,r as s,s as c}from"./upstreamPaths-DQeKSxGc.js";var l=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`BqError`}},u=3e4,d=()=>u;async function f(e,t,n,r,i=!0,a=`server`,o=[],s=u){let c=AbortSignal.timeout(s),d=r?.signal?AbortSignal.any([r.signal,c]):c,f=new Headers(n);r?.headers&&new Headers(r.headers).forEach((e,t)=>{f.set(t,e)}),r?.body!=null&&!f.has(`Content-Type`)&&f.set(`Content-Type`,`application/json`);let p;try{p=await fetch(e+t,{...r,headers:f,signal:d})}catch(e){throw c.aborted&&!r?.signal?.aborted||e?.name===`TimeoutError`?new l(`Request timed out`,0):e}if(!p.ok&&!o.includes(p.status)){let t=`HTTP ${p.status}`;try{let e=await p.json();e?.error&&(t=e.error)}catch{}throw p.status===401&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(`auth:required`,{detail:{scope:a,auth:f.get(`Authorization`)??void 0,target:e}})),new l(t,p.status)}if(p.status===204)return;let m;try{m=await p.text()}catch(e){throw c.aborted&&!r?.signal?.aborted?new l(`Request timed out`,0):e}if(!m)return;let h;try{h=JSON.parse(m)}catch{throw new l(`Invalid JSON response (HTTP ${p.status})`,p.status)}if(i&&h&&typeof h==`object`&&h.ok===!1)throw new l(h.error??`Operation failed`,p.status);return h}var p=(n,r,i=!0,a=[],o=u)=>f(e(),n,t(),r,i,`server`,a,o),m=()=>r(),h=(e,t,r=u)=>f(m(),e,n(),t,!0,`agent`,[],r),g=(e,t)=>({method:e,body:t===void 0?void 0:JSON.stringify(t)}),_=3e5,ee=(e,t)=>g(e,t),v=new WeakMap,y=new WeakMap;function b(){let n=Object.freeze({baseUrl:e()});return v.set(n,Object.freeze({...t()})),n}function x(){let e=Object.freeze({baseUrl:m()});return y.set(e,Object.freeze({...n()})),e}function S(e){let t=v.get(e);if(!t)throw TypeError(`Invalid server request target.`);return t}function C(e){let t=y.get(e);if(!t)throw TypeError(`Invalid agent request target.`);return t}async function w(e,t,n){n?.throwIfAborted();let r=await f(e.baseUrl,`/jobs/${i(t)}`,{...S(e)},n?{signal:n}:void 0);return n?.throwIfAborted(),r}var T=encodeURIComponent,te={info:()=>h(`/db/info`),tables:()=>h(`/db/tables`),schema:e=>h(`/db/tables/${o(e,`Database table`)}/schema`),rows:(e,t=50,n=0,r,i=`asc`,a)=>h(`/db/tables/${o(e,`Database table`)}?limit=${t}&offset=${n}${r?`&orderBy=${T(r)}&dir=${i}`:``}${a?.value?`&fcol=${T(a.column)}&fop=${a.op}&fval=${T(a.value)}`:``}`),cell:(e,t,n)=>h(`/db/tables/${o(e,`Database table`)}/cell?rowid=${T(String(t))}&column=${T(n)}`),query:e=>h(`/db/query`,g(`POST`,{sql:e}))},ne={status:()=>h(`/control/status`),start:()=>h(`/control/start`,{method:`POST`}),stop:()=>h(`/control/stop`,{method:`POST`}),restart:()=>h(`/control/restart`,{method:`POST`}),logs:()=>h(`/control/logs`),getConfig:()=>h(`/control/config`),setConfig:(e,t)=>h(`/control/config`,g(`PUT`,{...e,...t===void 0?{}:{expectedRevision:t}}))},re={stats:()=>h(`/workflows/stats`),list:(e={})=>{let t=new URLSearchParams;return e.kind&&t.set(`kind`,e.kind),e.workflowName&&t.set(`workflowName`,e.workflowName),e.state&&t.set(`state`,e.state),e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.offset!==void 0&&t.set(`offset`,String(e.offset)),h(`/workflows${t.size?`?${t}`:``}`)},get:(e,t=`active`)=>h(`/workflows/${o(e,`Workflow execution id`)}?kind=${t}`)},ie=2e5,ae=16*1024*1024,oe=12e4,se=64*1024,E=encodeURIComponent;async function ce(e,t,n=50,r=0,i,a=`asc`,s,c){c?.throwIfAborted();let l=await f(e.baseUrl,`/db/tables/${o(t,`Database table`)}?limit=${n}&offset=${r}${i?`&orderBy=${E(i)}&dir=${a}`:``}${s?.value?`&fcol=${E(s.column)}&fop=${s.op}&fval=${E(s.value)}`:``}`,{...C(e)},c?{signal:c}:void 0,!0,`agent`);return c?.throwIfAborted(),l}function D(e,t,n,r=!0){let i=e.get(t);if(!i||!/^\d+$/.test(i))throw new l(`Malformed database export response: invalid ${t} header.`,200);let a=Number(i);if(!Number.isSafeInteger(a)||a>n||!r&&a===0)throw new l(`Malformed database export response: invalid ${t} header.`,200);return a}async function le(e){if(!e.body)return``;let t=e.body.getReader(),n=new Uint8Array(se),r=0;try{for(;;){let e=await t.read();if(e.done)break;if(r+e.value.byteLength>n.byteLength)return t.cancel().catch(()=>void 0),``;n.set(e.value,r),r+=e.value.byteLength}}finally{t.releaseLock()}return new TextDecoder().decode(n.subarray(0,r))}async function ue(e,t,n){if(!e.body)throw new l(`Malformed database export response: missing CSV body.`,200);let r=new Uint8Array(t),i=e.body.getReader(),a=0;try{for(;;){n?.throwIfAborted();let e=await i.read();if(e.done)break;if(a+e.value.byteLength>t)throw i.cancel().catch(()=>void 0),new l(`Malformed database export response: body exceeds declared ${t} bytes.`,200);r.set(e.value,a),a+=e.value.byteLength}}finally{i.releaseLock()}if(n?.throwIfAborted(),a!==t)throw new l(`Malformed database export response: received ${a} of ${t} declared bytes.`,200);return r}function de(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`Invalid database export request.`);if(typeof e.table!=`string`||!e.table)throw TypeError(`Database export table must not be empty.`);if(e.dir!==`asc`&&e.dir!==`desc`)throw TypeError(`Invalid database export sort direction.`);if(e.orderBy!==void 0&&(typeof e.orderBy!=`string`||!e.orderBy))throw TypeError(`Database export sort column must not be empty.`);let t=e.filter;if(t&&(typeof t!=`object`||Array.isArray(t)||typeof t.column!=`string`||!t.column||typeof t.value!=`string`||!t.value||![`contains`,`eq`,`ne`].includes(t.op)))throw TypeError(`Invalid database export filter.`);return Object.freeze({table:e.table,orderBy:e.orderBy,dir:e.dir,filter:t?Object.freeze({...t}):void 0})}async function fe(e,t,n){e.status===401&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(`auth:required`,{detail:{scope:`agent`,auth:new Headers(n).get(`Authorization`)??void 0,target:t.baseUrl}}));let r=`HTTP ${e.status}`,i=await le(e);if(i)try{let e=JSON.parse(i);typeof e?.error==`string`&&(r=e.error)}catch{}return new l(r,e.status)}async function pe(e,t,n){n?.throwIfAborted();let r={...C(e)},i=de(t),a=new URLSearchParams;i.orderBy&&a.set(`orderBy`,i.orderBy),a.set(`dir`,i.dir),i.filter&&(a.set(`fcol`,i.filter.column),a.set(`fop`,i.filter.op),a.set(`fval`,i.filter.value));let s=`/db/tables/${o(i.table,`Database table`)}/export?${a}`,c=AbortSignal.timeout(oe),u=n?AbortSignal.any([n,c]):c;try{let t=await fetch(e.baseUrl+s,{headers:r,signal:u});if(!t.ok)throw await fe(t,e,r);if(t.headers.get(`X-Bunqueue-Db-Export-Version`)!==`1`)throw new l(`Malformed database export response: unsupported contract version.`,200);if(!/^text\/csv(?:;|$)/i.test(t.headers.get(`Content-Type`)??``))throw new l(`Malformed database export response: expected CSV content.`,200);let a;try{let e=t.headers.get(`X-Bunqueue-Db-Export-Table`);if(!e)throw Error(`missing`);a=decodeURIComponent(e)}catch{throw new l(`Malformed database export response: invalid table identity.`,200)}if(a!==i.table)throw new l(`Database export target changed: requested "${i.table}", received "${a}".`,200);let o=D(t.headers,`X-Bunqueue-Db-Export-Rows`,ie),c=D(t.headers,`X-Bunqueue-Db-Export-Bytes`,ae,!1);if(D(t.headers,`Content-Length`,16777216,!1)!==c)throw new l(`Malformed database export response: Content-Length does not match X-Bunqueue-Db-Export-Bytes.`,200);let d=t.headers.get(`X-Bunqueue-Db-Export-Cap`);if(d!==`none`&&d!==`rows`&&d!==`bytes`)throw new l(`Malformed database export response: invalid export cap.`,200);if(d===`rows`&&o!==2e5)throw new l(`Malformed database export response: inconsistent row cap.`,200);let f=await ue(t,c,u);return n?.throwIfAborted(),{table:a,content:f,rowCount:o,bytes:c,cap:d===`none`?null:d}}catch(e){throw c.aborted&&!n?.aborted?new l(`Database export timed out`,0):e}}var me={counts:e=>p(`/queues/${c(e)}/counts`),pause:e=>p(`/queues/${c(e)}/pause`,g(`POST`)),resume:e=>p(`/queues/${c(e)}/resume`,g(`POST`)),drain:e=>p(`/queues/${c(e)}/drain`,ee(`POST`),!0,[],_),obliterate:e=>p(`/queues/${c(e)}/obliterate`,ee(`POST`),!0,[],_),clean:(e,t={})=>p(`/queues/${c(e)}/clean`,g(`POST`,t)),promoteJobs:(e,t)=>p(`/queues/${c(e)}/promote-jobs`,g(`POST`,t==null?void 0:{count:t})),retryCompleted:(e,t)=>{throw TypeError(`Completed-job requeue is unavailable in Bunqueue v2.9.3 because flow dependency registration is not rebuilt.`)},setRateLimit:(e,t,n,r)=>p(`/queues/${c(e)}/rate-limit`,g(`PUT`,{limit:t,...n===void 0?{}:{duration:n},...r===void 0?{}:{ttl:r}})),clearRateLimit:e=>p(`/queues/${c(e)}/rate-limit`,{method:`DELETE`}),setConcurrency:(e,t)=>p(`/queues/${c(e)}/concurrency`,g(`PUT`,{concurrency:t})),clearConcurrency:e=>p(`/queues/${c(e)}/concurrency`,{method:`DELETE`}),getStallConfig:e=>p(`/queues/${c(e)}/stall-config`),setStallConfig:(e,t)=>p(`/queues/${c(e)}/stall-config`,g(`PUT`,{config:t})),getDlqConfig:e=>p(`/queues/${c(e)}/dlq-config`),setDlqConfig:(e,t)=>{if(t.autoRetry===!0)throw TypeError(`DLQ auto-retry is unavailable: Bunqueue v2.9.3 does not rebuild flow dependency registration.`);if(t.maxAge!==void 0||t.maxEntries!==void 0)throw TypeError(`DLQ retention is read-only: maxAge/maxEntries can destructively expire or evict flow jobs without an atomic dependency check.`);return p(`/queues/${c(e)}/dlq-config`,g(`PUT`,{config:t}))},dlq:(e,t=100,n=0)=>p(`/queues/${c(e)}/dlq?limit=${t}&offset=${n}`),dlqStats:e=>p(`/queues/${c(e)}/dlq/stats`),retryDlq:(e,t)=>{throw TypeError(`DLQ retry is unavailable in Bunqueue v2.9.3 because the endpoint has no atomic job-generation, state, or flow-topology precondition.`)},purgeDlq:e=>p(`/queues/${c(e)}/dlq/purge`,g(`POST`))},O=()=>encodeURIComponent(e()),he={limits:(e,t)=>{let n=t===void 0?``:`&maxJobs=${t}`;return h(`/queue-operations/${c(e)}/limits?target=${O()}${n}`)},group:(t,n,r,i,a,o)=>{let s=new URLSearchParams({target:e(),groupId:n});return r!==void 0&&s.set(`maxJobs`,String(r)),i!==void 0&&s.set(`maxCount`,String(i)),a!==void 0&&s.set(`start`,String(a)),o!==void 0&&s.set(`end`,String(o)),h(`/queue-operations/${c(t)}/groups?${s}`)},setGroupRateLimit:(e,t,n,r)=>h(`/queue-operations/${c(e)}/groups/rate-limit?target=${O()}`,g(`POST`,{groupId:t,max:n,duration:r})),removeGroupRateLimit:(e,t)=>h(`/queue-operations/${c(e)}/groups/rate-limit/remove?target=${O()}`,g(`POST`,{groupId:t})),setGroupConcurrency:(e,t,n)=>h(`/queue-operations/${c(e)}/groups/concurrency?target=${O()}`,g(`POST`,{groupId:t,concurrency:n})),removeGroupConcurrency:(e,t)=>h(`/queue-operations/${c(e)}/groups/concurrency/remove?target=${O()}`,g(`POST`,{groupId:t})),pauseGroup:(e,t)=>h(`/queue-operations/${c(e)}/groups/pause?target=${O()}`,g(`POST`,{groupId:t})),resumeGroup:(e,t)=>h(`/queue-operations/${c(e)}/groups/resume?target=${O()}`,g(`POST`,{groupId:t})),deduplicationJobId:(t,n)=>h(`/queue-operations/${c(t)}/deduplication?${new URLSearchParams({target:e(),deduplicationId:n})}`),removeDeduplicationKey:(e,t)=>h(`/queue-operations/${c(e)}/deduplication/remove?target=${O()}`,g(`POST`,{deduplicationId:t})),metrics:(t,n,r,i)=>h(`/queue-operations/${c(t)}/metrics?${new URLSearchParams({target:e(),type:n,start:String(r),end:String(i)})}`),trimEvents:(e,t)=>h(`/queue-operations/${c(e)}/events/trim?target=${O()}`,g(`POST`,{maxLength:t}))},k=1e4,ge=1e3,_e=864e13,ve=new Set([`job.pushed`,`job.started`,`job.completed`,`job.failed`,`job.progress`,`job.stalled`]);function A(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function j(e,t,n=!1){if(typeof e!=`string`||e.length>t||!n&&e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return!1}return!0}function M(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ye(e){return typeof e==`number`&&Number.isFinite(e)}function N(e){return M(e)&&e<=_e}function be(e,t){return e===null||j(e,t)}function xe(e,t,n){if(!Array.isArray(e)||e.length>t)return!1;let r=new Set;for(let t of e){if(!j(t,n)||r.has(t))return!1;r.add(t)}return!0}function P(e,t){let n=A(e),r=n&&A(n.data);if(n?.ok!==!0||!r)throw Error(`Malformed ${t} response.`);return r}function F(e){if(!Array.isArray(e))throw Error(`Malformed queue summary response.`);let t=new Set,n=[];for(let r of e){let e=A(r),i=e&&A(e.counts);if(!e||!j(e.name,256)||t.has(e.name)||typeof e.paused!=`boolean`||!i||!M(i.waiting)||!M(i.prioritized)||!M(i.active)||!M(i.completed)||!M(i.failed)||!M(i.delayed))throw Error(`Malformed queue summary response.`);t.add(e.name),n.push(r)}return n}function I(e){let t=P(e,`workers`);if(!Array.isArray(t.workers)||t.workers.length>k)throw Error(`Malformed workers response.`);let n=new Set,r=[],i=[];for(let e=0;e<t.workers.length;e++){let a=t.workers[e],o=A(a),s=o&&typeof o.id==`string`?o.id:null,c=[];if(o?(j(o.id,1024)?n.has(o.id)&&c.push(`duplicate id`):c.push(`id`),j(o.name,512,!0)||c.push(`name`),xe(o.queues,ge,256)||c.push(`queues`),(!M(o.concurrency)||o.concurrency<1)&&c.push(`concurrency`),j(o.hostname,512,!0)||c.push(`hostname`),M(o.pid)||c.push(`pid`),o.status!==`active`&&o.status!==`stale`&&c.push(`status`),N(o.registeredAt)||c.push(`registeredAt`),N(o.lastSeen)||c.push(`lastSeen`),M(o.activeJobs)||c.push(`activeJobs`),M(o.processedJobs)||c.push(`processedJobs`),M(o.failedJobs)||c.push(`failedJobs`),be(o.currentJob,1024)||c.push(`currentJob`),ye(o.uptime)||c.push(`uptime`)):c.push(`entry is not an object`),s&&n.add(s),c.length>0){i.push({index:e,id:s,reason:c.join(`, `)});continue}r.push(a)}return{ok:!0,data:{workers:r,quarantinedWorkers:i,...Object.hasOwn(t,`stats`)?{stats:t.stats}:{}}}}function Se(e){if(!j(e,2048))return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Ce(e){let t=P(e,`webhooks`);if(!Array.isArray(t.webhooks)||t.webhooks.length>k)throw Error(`Malformed webhooks response.`);let n=new Set,r=[];for(let e of t.webhooks){let t=A(e);if(!t||!j(t.id,1024)||n.has(t.id)||!Se(t.url)||!Array.isArray(t.events)||!t.events.every(e=>ve.has(e))||!(t.queue===null||typeof t.queue==`string`)||!N(t.createdAt)||!(t.lastTriggered===null||N(t.lastTriggered))||!M(t.successCount)||!M(t.failureCount)||typeof t.enabled!=`boolean`)throw Error(`Malformed webhooks response.`);n.add(t.id),r.push(e)}return{ok:!0,data:{webhooks:r,...Object.hasOwn(t,`stats`)?{stats:t.stats}:{}}}}var we={crons:()=>p(`/crons`),createCron:e=>p(`/crons`,g(`POST`,e)),deleteCron:e=>p(`/crons/${o(e,`Cron name`,256)}`,{method:`DELETE`}),webhooks:async()=>Ce(await p(`/webhooks`)),addWebhook:e=>p(`/webhooks`,g(`POST`,e)),removeWebhook:e=>p(`/webhooks/${i(e)}`,{method:`DELETE`}),setWebhookEnabled:(e,t)=>p(`/webhooks/${i(e)}/enabled`,g(`PUT`,{enabled:t})),workers:async()=>I(await p(`/workers`)),unregisterWorker:e=>p(`/workers/${i(e)}`,{method:`DELETE`}),eventsUrl:t=>e()+(t?`/events/queues/${s(t)}`:`/events`)},L=365*24*60*60*1e3,R=2097151,z=64*1024*1024,B=1e4,Te=[`childrenIds`,`parentId`,`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`,`keepLogs`,`sizeLimit`,`debounceId`,`debounceTtl`],V=[`__parentId`,`__parentQueue`,`__childrenIds`,`__flowParentId`,`__flowParentIds`];function H(e){if(e===void 0)return;if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`Repeat must be an object with a positive "every" interval`);let t=Object.keys(e).filter(e=>e!==`every`&&e!==`limit`);if(t.length)throw TypeError(`Unsupported repeat option(s): ${t.join(`, `)}. bunqueue v2.9.3 pattern repeats are unsafe; use the Cron API instead.`);if(!Number.isSafeInteger(e.every)||e.every<1||e.every>L)throw TypeError(`Repeat "every" must be a whole number from 1 to ${L} ms`);if(e.limit!==void 0&&(!Number.isSafeInteger(e.limit)||e.limit<1))throw TypeError(`Repeat "limit" must be a whole number of at least 1`)}function U(e){if(e!==void 0&&(typeof e!=`string`||!e||e.length>256))throw TypeError(`Job name must be a non-empty string of at most 256 characters`)}function W(e){let t=e,n=Te.filter(e=>t[e]!==void 0);if(n.length)throw TypeError(`Unsupported Bunqueue v2.9.3 enqueue option(s): ${n.join(`, `)}. Flow topology must use the atomic flow API; inert compatibility fields are not sent.`)}function G(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=V.filter(t=>Object.hasOwn(e,t));if(t.length)throw TypeError(`Job data must not contain broker-owned flow metadata: ${t.join(`, `)}. A plain enqueue with these keys would be misread as a flow child; use the atomic flow API for topology.`)}function K(e){let t=e.groupId;if(t!==void 0&&(typeof t!=`string`||!t||t.length>256||t.includes(`\0`)))throw TypeError(`groupId must be a non-empty string of at most 256 characters without NUL`);if(e.groupMaxSize!==void 0){if(t===void 0)throw TypeError(`groupMaxSize requires groupId`);if(!Number.isSafeInteger(e.groupMaxSize)||e.groupMaxSize<1)throw TypeError(`groupMaxSize must be a positive safe integer`)}if(t!==void 0&&e.priority!==void 0&&(!Number.isSafeInteger(e.priority)||e.priority<0||e.priority>R))throw TypeError(`Grouped priority must be an integer from 0 to ${R}`)}function q(e,t){let n=a(t);if(n)throw TypeError(`${e}: ${n}. The job would not be manageable through v2.9.3 HTTP.`)}function Ee(e){if(U(e.name),H(e.repeat),W(e),G(e.data),K(e),e.groupMaxSize!==void 0)throw TypeError(`groupMaxSize is not forwarded by Bunqueue 2.9.3 single-job HTTP; use the bulk transport`);if(e.dependsOn!==void 0&&(!Array.isArray(e.dependsOn)||!e.dependsOn.every(e=>typeof e==`string`)))throw TypeError(`dependsOn must be an array of job ID strings`);e.jobId!==void 0&&q(`jobId`,e.jobId);for(let t of e.dependsOn??[])q(`dependsOn`,t)}function De(e){let t;try{t=JSON.stringify(e)}catch{throw TypeError(`Job payload must be JSON serializable`)}if(t===void 0)throw TypeError(`Job payload must be JSON serializable`);let n;try{n=JSON.parse(t)}catch{throw TypeError(`Job payload encoding failed`)}if(typeof n!=`object`||!n||Array.isArray(n))throw TypeError(`Job payload must serialize to a JSON object`);return Ee(n),t}function Oe({jobId:e,...t}){return e===void 0?t:{...t,customId:e}}function ke(e){let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`must serialize to a JSON object`);let n=t;if(n.jobId!==void 0)throw TypeError(`serialized jobId is invalid; the bulk transport requires customId`);if(U(n.name),H(n.repeat),W(n),G(n.data),K(n),n.customId!==void 0){if(typeof n.customId!=`string`)throw TypeError(`customId must be a string`);q(`customId`,n.customId)}if(n.dependsOn!==void 0){if(!Array.isArray(n.dependsOn)||!n.dependsOn.every(e=>typeof e==`string`))throw TypeError(`dependsOn must be an array of job ID strings`);for(let e of n.dependsOn)q(`dependsOn`,e)}}function Ae(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i<=127?n+=1:i<=2047?n+=2:i>=55296&&i<=56319&&r+1<e.length&&e.charCodeAt(r+1)>=56320&&e.charCodeAt(r+1)<=57343?(n+=4,r+=1):n+=3,n>t)return n}return n}function J(e,t,n){if(!Array.isArray(e)||e.length>1e4)return{ok:!1,error:`Bulk request must contain at most ${B} jobs`};if(!Number.isSafeInteger(t)||t<0)return{ok:!1,error:`Bulk request payload limit is invalid`};let r=11,i=n?Array(e.length):null;for(let a=0;a<e.length;a++){if(a&&(r+=1),r>t)return{ok:!1,error:`Bulk request payload exceeds the 64 MiB UTF-8 safety limit`};let o;try{o=JSON.stringify(Oe(e[a]))}catch{return{ok:!1,error:`Bulk request payload must be JSON serializable`}}if(o===void 0)return{ok:!1,error:`Bulk request payload must be JSON serializable`};if(r+=Ae(o,t-r),r>t)return{ok:!1,error:`Bulk request payload exceeds the 64 MiB UTF-8 safety limit`};if(n)try{ke(o)}catch(e){return{ok:!1,error:`Bulk job ${a+1}: ${e instanceof Error?e.message:String(e)}`}}i&&(i[a]=o)}return{ok:!0,bytes:r,body:i?`{"jobs":[${i.join(`,`)}]}`:void 0}}function je(e,t=z){let n=J(e,t,!1);return n.ok?null:n.error}function Y(e){let t=J(e,z,!0);if(!t.ok)throw TypeError(t.error);if(t.body===void 0)throw TypeError(`Bulk request payload encoding failed`);return t.body}function Me(e){if(!Array.isArray(e)||e.length>1e4)throw TypeError(`Bulk request must contain at most ${B} jobs`)}var Ne={overview:e=>p(`/dashboard`,e),queues:(e=500,t=0)=>p(`/dashboard/queues?limit=${e}&offset=${t}`),queuesSummary:async()=>F(await p(`/queues/summary`)),queueDetail:(e,t=!0)=>p(`/dashboard/queues/${c(e)}?includeJobs=${t}`),stats:e=>p(`/stats`,e),storage:()=>p(`/storage`,void 0,!1),health:()=>p(`/health`,void 0,!1,[503]),ping:()=>p(`/ping`),prometheusUrl:()=>`${e()}/prometheus`,gc:()=>p(`/gc`,g(`POST`)),heapStats:()=>p(`/heapstats`)},Pe={jobsList:(e,t,n=50,r=0)=>{let i=new URLSearchParams;return t?.length&&i.set(`states`,t.join(`,`)),i.set(`limit`,String(n)),i.set(`offset`,String(r)),p(`/queues/${c(e)}/jobs/list?${i}`)},job:e=>p(`/jobs/${i(e)}`),jobByCustomId:e=>p(`/jobs/custom/${o(e,`Custom job ID`)}`),jobResult:e=>p(`/jobs/${i(e)}/result`),jobLogs:e=>p(`/jobs/${i(e)}/logs`),jobChildren:e=>p(`/jobs/${i(e)}/children`),addJob:async(e,t)=>p(`/queues/${c(e)}/jobs`,{method:`POST`,body:De(t)}),addJobsBulk:async(e,t)=>(Me(t),p(`/queues/${c(e)}/jobs/bulk`,{method:`POST`,body:Y(t)},!0,[],_)),pullBatch:(e,t,n)=>p(`/queues/${c(e)}/jobs/pull-batch`,g(`POST`,{count:t,...n?{owner:n}:{}})),ackBatch:(e,t)=>p(`/jobs/ack-batch`,g(`POST`,{ids:e,...t?{tokens:t}:{}})),cancelJob:e=>p(`/jobs/${i(e)}`,{method:`DELETE`}),promoteJob:e=>p(`/jobs/${i(e)}/promote`,g(`POST`)),discardJob:e=>p(`/jobs/${i(e)}/discard`,g(`POST`)),retryJob:e=>p(`/jobs/${i(e)}/move-to-wait`,g(`POST`)),failJob:(e,t,n={})=>p(`/jobs/${i(e)}/fail`,g(`POST`,{error:t,...n})),updateJobData:(e,t)=>p(`/jobs/${i(e)}/data`,g(`PUT`,{data:t})),changePriority:(e,t,n)=>p(`/jobs/${i(e)}/priority`,g(`PUT`,{priority:t,...n===void 0?{}:{lifo:n}})),changeDelay:(e,t)=>p(`/jobs/${i(e)}/delay`,g(`PUT`,{delay:t})),moveToDelayed:(e,t)=>p(`/jobs/${i(e)}/move-to-delayed`,g(`POST`,{delay:t})),addJobLog:(e,t,n)=>p(`/jobs/${i(e)}/logs`,g(`POST`,{message:t,level:n})),clearJobLogs:e=>p(`/jobs/${i(e)}/logs`,{method:`DELETE`}),setJobProgress:(e,t,n)=>p(`/jobs/${i(e)}/progress`,g(`POST`,{progress:t,message:n}))};function X(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new l(`Malformed ${t} response.`,200);return e}function Z(e,t){let n=X(e,t);if(n.ok!==!0)throw new l(`Malformed ${t} response.`,200);return n}var Q=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0;function $(e,t){if(e!==void 0)return Z(e,t)}function Fe(e,t){let n={...S(e)},r=(r,i,a=d())=>{let o=t?{...i,signal:i?.signal?AbortSignal.any([i.signal,t]):t}:i;return f(e.baseUrl,r,n,o,!0,`server`,[],a)};return Object.freeze({queuesSummary:async()=>F(await r(`/queues/summary`)),overview:()=>r(`/dashboard`),counts:async e=>{let t=X(Z(await r(`/queues/${c(e)}/counts`),`queue counts`).counts,`queue counts`);if(!Object.values(t).every(Q))throw new l(`Malformed queue counts response.`,200);return{ok:!0,counts:t}},jobsList:async(e,t,n=50,i=0)=>{let a=new URLSearchParams;t?.length&&a.set(`states`,t.join(`,`)),a.set(`limit`,String(n)),a.set(`offset`,String(i));let o=Z(await r(`/queues/${c(e)}/jobs/list?${a}`),`jobs list`);if(!Array.isArray(o.jobs)||!o.jobs.every(t=>{let n=t;return typeof n==`object`&&!!n&&!Array.isArray(n)&&typeof n.id==`string`&&n.id.length>0&&(n.queue===void 0||n.queue===e)}))throw new l(`Malformed jobs list response.`,200);return{ok:!0,jobs:o.jobs}},job:async e=>{let t=X(Z(await r(`/jobs/${i(e)}`),`job`).job,`job`);if(t.id!==e)throw new l(`Malformed job response.`,200);return{ok:!0,job:t}},dlqStats:async e=>{let t=X(Z(await r(`/queues/${c(e)}/dlq/stats`),`DLQ stats`).stats,`DLQ stats`);if(!Q(t.total))throw new l(`Malformed DLQ stats response.`,200);return{ok:!0,stats:t}},dlq:async(e,t=100,n=0)=>{let i=Z(await r(`/queues/${c(e)}/dlq?limit=${t}&offset=${n}`),`DLQ list`);if(!Array.isArray(i.entries)||!Q(i.total))throw new l(`Malformed DLQ list response.`,200);for(let e of i.entries){let t=X(X(e,`DLQ list`).job,`DLQ list`);if(typeof t.id!=`string`||!t.id)throw new l(`Malformed DLQ list response.`,200)}return{ok:!0,entries:i.entries,total:i.total}},health:async()=>X(await f(e.baseUrl,`/health`,n,t?{signal:t}:void 0,!1,`server`,[503]),`health`),stats:async()=>{let e=await r(`/stats`);return X(Z(e,`server stats`).stats,`server stats`),e},workers:async()=>I(await r(`/workers`)),crons:async()=>{let e=Z(await r(`/crons`),`crons`);if(!Array.isArray(e.crons)||!e.crons.every(e=>{let t=e;return typeof t==`object`&&!!t&&!Array.isArray(t)&&typeof t.name==`string`&&!!t.name&&typeof t.queue==`string`&&!!t.queue}))throw new l(`Malformed crons response.`,200);return{ok:!0,crons:e.crons}},addJobsBulk:async(e,t)=>(Me(t),r(`/queues/${c(e)}/jobs/bulk`,{method:`POST`,body:Y(t)},_)),pullBatch:(e,t,n)=>r(`/queues/${c(e)}/jobs/pull-batch`,g(`POST`,{count:t,...n?{owner:n}:{}})),heartbeatBatch:(e,t)=>r(`/jobs/heartbeat-batch`,g(`POST`,{ids:e,...t?{tokens:t}:{}})),ackBatch:(e,t)=>r(`/jobs/ack-batch`,g(`POST`,{ids:e,...t?{tokens:t}:{}})),retryJob:(e,t)=>r(`/jobs/${i(e)}/move-to-wait`,g(`POST`,t?{token:t}:{})),promoteJob:async e=>$(await r(`/jobs/${i(e)}/promote`,g(`POST`)),`promote job`),pause:async e=>$(await r(`/queues/${c(e)}/pause`,g(`POST`)),`pause queue`),resume:async e=>$(await r(`/queues/${c(e)}/resume`,g(`POST`)),`resume queue`),clean:(e,t={})=>r(`/queues/${c(e)}/clean`,g(`POST`,t))})}var Ie={...Ne,captureServerRequestTarget:b,createServerTargetClient:Fe,getJobAtTarget:w,captureAgentRequestTarget:x,getDbRowsAtTarget:ce,getDbExportAtTarget:pe,...Pe,...me,queueOperations:he,...we,db:te,get agentBase(){return m()},control:ne,workflows:re};Object.defineProperty(Ie,"agentBase",{configurable:!1});export{l as a,f as c,w as d,ae as i,x as l,V as n,C as o,je as r,h as s,Ie as t,b as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./api-D9aT0ND7.js";var t=`__all__`,n=[`all`,`waiting`,`active`,`completed`,`failed`],r=500,i=20,a=r*i;function o(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>a||n!==null&&e.total!==n||e.offset!==t||e.limit!==r||e.queues.length!==Math.min(r,e.total-t)||e.queues.length>r||e.queues.some(e=>typeof e!=`object`||!e||typeof e.name!=`string`||e.name.length===0||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)))throw Error(`Queue discovery returned a malformed or unsafe page`)}async function s(){let t=await e.queues(r,0);o(t,0,null);let n=[...t.queues],s=new Set;for(let e of n){if(s.has(e.name))throw Error(`Queue discovery returned duplicate queue ${e.name}`);s.add(e.name)}let c=t.total,l=1;for(;n.length<c;){if(l>=i||n.length>=a)throw Error(`Queue discovery exceeds the safety limit of ${a}`);let t=n.length,u=await e.queues(r,t);o(u,t,c);for(let e of u.queues){if(s.has(e.name))throw Error(`Queue discovery pages overlap at queue ${e.name}`);s.add(e.name),n.push(e)}l+=1}return{...t,queues:n,total:c,limit:n.length,offset:0}}function c(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}export{c as i,n,s as r,t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t}from"./react-vendor-CFL9l8LK.js";var n=e(t(),1),r=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},i=(e=>e?r(e):r),a=e=>e;function o(e,t=a){let r=n.useSyncExternalStore(e.subscribe,n.useCallback(()=>t(e.getState()),[e,t]),n.useCallback(()=>t(e.getInitialState()),[e,t]));return n.useDebugValue(r),r}var s=e=>{let t=i(e),n=e=>o(t,e);return Object.assign(n,t),n},c=(e=>e?s(e):s);function l(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var u=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return u(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return u(t)(e)}}}},d=(e,t)=>(n,r,i)=>{let a={storage:l(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,d=new Set,f=a.storage;if(!f)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let p=()=>{let e=a.partialize({...r()});return f.setItem(a.name,{state:e,version:a.version})},m=i.setState;i.setState=(e,t)=>(m(e,t),p());let h=e((...e)=>(n(...e),p()),r,i);i.getInitialState=()=>h;let g,_=()=>{if(!f)return;let e=++s;o=!1,c.forEach(e=>e(r()??h));let t=a.onRehydrateStorage?.call(a,r()??h)||void 0;return u(f.getItem.bind(f))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(g=a.merge(o,r()??h),n(g,!0),i)return p()}).then(()=>{e===s&&(t?.(r(),void 0),g=r(),o=!0,d.forEach(e=>e(g)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(f=e.storage)},clearStorage:()=>{f?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>_(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},a.skipHydration||_(),g||h},f=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function p(e,t=!1){try{let n=globalThis.localStorage??null;return!n&&t&&e.reportMissingWrites&&e.onError?.(Error(`localStorage is unavailable`)),n}catch(t){return e.onError?.(t),null}}function m(e,t){try{let n=JSON.parse(e),r=f(n)?n:{},i=typeof r.version==`number`?r.version:void 0,a=t.sanitizeState(`state`in r?r.state:r,i);return{hydration:JSON.stringify({state:a,...i===void 0?{}:{version:i}}),canonical:JSON.stringify({state:a,version:t.version})}}catch(e){return t.onError?.(e),null}}function h(e){let t=t=>e.onError?.(t);return{getItem(n){let r=p(e);if(!r)return null;let i;try{i=r.getItem(n)}catch(e){return t(e),null}if(i===null||n!==e.key)return i;let a=m(i,e);if(!a){try{r.removeItem(n)}catch(e){t(e)}return null}if(i!==a.canonical)try{r.setItem(n,a.canonical)}catch(e){t(e);try{r.removeItem(n)}catch(e){t(e)}}return a.hydration},setItem(n,r){let i=p(e,!0);if(i)try{i.setItem(n,r)}catch(e){t(e)}},removeItem(n){let r=p(e);if(r)try{r.removeItem(n)}catch(e){t(e)}}}}var g=/^\/(?:[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*)?\/?$/;function _(e){try{return globalThis[e]}catch{return}}function v(e){if(typeof e!=`string`)return null;let t=e.trim();return!g.test(t)||t.split(`/`).some(e=>e===`.`||e===`..`)?null:t.replace(/\/+$/,``)||`/`}function y(e,t){return v(e)??v(t)??`/`}var b=`Use an http(s) URL without credentials, query, or fragment, or a non-root path starting with '/'.`,x=`https://bunqueue-dashboard.invalid`,ee=/\s/u;function te(e){return[...e].some(e=>{let t=e.charCodeAt(0);return e===`\\`||ee.test(e)||t<32||t===127})}function S(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t||t.includes(`?`)||t.includes(`#`)||te(t))return null;if(t.startsWith(`/`)){if(t.startsWith(`//`))return null;try{let e=new URL(t,x),n=e.pathname.replace(/\/+$/,``);return e.origin!==x||!n||n===`/`||n.startsWith(`//`)?null:n}catch{return null}}let n=t.match(/^https?:\/\//i)?.[0];if(!n)return null;let r=t.slice(n.length).split(`/`,1)[0];if(!r||r.includes(`@`))return null;try{let e=new URL(t);if(e.protocol!==`http:`&&e.protocol!==`https:`||!e.hostname||e.username||e.password)return null;let n=e.pathname.replace(/\/+$/,``);return n.startsWith(`//`)?null:`${e.origin}${n}`}catch{return null}}function C(e,t){return S(e)??S(t)??`/api`}function w(e,t){return S(e)??S(t)??`http://localhost:6800`}function T(e,t){return S(e)??t}function E(e){return typeof e==`string`?e.trim():``}var ne=`default`,re=64,D=/^[a-zA-Z0-9_-]{1,64}$/u;function O(e){return{id:ne,name:`Local Bunqueue`,baseUrl:e.baseUrl,agentBaseUrl:e.agentBaseUrl}}function k(e,t){if(typeof e!=`string`)return t;let n=[...e].map(e=>{let t=e.codePointAt(0)??0;return t<=31||t===127?` `:e}).join(``).trim();return n?[...n].slice(0,re).join(``):t}function A(e,t){return typeof e==`string`&&D.test(e)?e:t}function j(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return null;let r=e,i=S(r.baseUrl);return i?{id:A(r.id,`profile-${t+1}`),name:k(r.name,`Bunqueue ${t+1}`),baseUrl:i,agentBaseUrl:T(r.agentBaseUrl,n.agentBaseUrl)}:null}function M(e,t){if(!Array.isArray(e))return[O(t)];let n=[],r=new Set;for(let[i,a]of e.slice(0,32).entries()){let e=j(a,i,t);!e||r.has(e.id)||(r.add(e.id),n.push(e))}return n.length?n:[O(t)]}function N(e,t,n){let r=e&&typeof e==`object`&&!Array.isArray(e)?e:{},i=M(r.profiles,t),a=typeof r.activeProfileId==`string`?r.activeProfileId:``;return{profiles:i,activeProfileId:i.some(e=>e.id===a)?a:i[0].id,refreshMs:n(r.refreshMs)}}function P(e,t,n){let r=e&&typeof e==`object`&&!Array.isArray(e)?e:{};if(Array.isArray(r.profiles))return N(r,t,n);let i=O({...t,baseUrl:T(r.baseUrl,t.baseUrl)});return{profiles:[i],activeProfileId:i.id,refreshMs:n(r.refreshMs)}}function ie(e){let t=new Set(e.map(e=>e.id)),n=globalThis.crypto?.randomUUID?.().replaceAll(`-`,``).slice(0,16)||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`,r=`node-${n}`,i=2;for(;t.has(r);)r=`node-${n}-${i++}`;return r}var F=`bq-dash-connection`,I=3e3,ae=500,oe=6e4,L={baseUrl:C(void 0,_(`__BUNQUEUE_API_URL__`)),agentBaseUrl:w(_(`__BUNQUEUE_AGENT_URL__`),void 0),refreshMs:I},R=O(L);function z(e){return typeof e!=`number`||!Number.isFinite(e)?I:Math.min(oe,Math.max(ae,Math.round(e)))}function B(e){let t=e;return N({profiles:t?.profiles??(t?.baseUrl?[{...R,baseUrl:t.baseUrl}]:void 0),activeProfileId:t?.activeProfileId,refreshMs:t?.refreshMs},L,z)}function V(e,t){if(t!==void 0&&t<4)return H(e,t);let n=e;return Array.isArray(n?.profiles)?N(e,L,z):P(e,L,z)}function H(e,t,n=L.baseUrl){let r={...L,baseUrl:C(void 0,n)},i=e&&typeof e==`object`&&!Array.isArray(e)?e:{},a=t<3&&i.baseUrl===`/api`?{...i,baseUrl:r.baseUrl}:e;return t<4?P(a,r,z):N(e,r,z)}var U=null;function W(e){U=e instanceof Error?e:Error(String(e))}function G(){U=null}function K(){return U?{persisted:!1,error:`${U.name&&U.name!==`Error`?`${U.name}: `:``}${U.message}`}:{persisted:!0}}var se=l(()=>h({key:F,version:4,sanitizeState:V,onError:W,reportMissingWrites:!0})),q=new Map;function J(e){return e.profiles.find(t=>t.id===e.activeProfileId)??e.profiles[0]??R}function Y(e,t){let n=J(e),r={...n,...t,id:n.id};return e.profiles.map(e=>e.id===n.id?r:e)}function X(e,t,n){q.set(e,{token:E(t),agentToken:E(n)})}var Z=c()(d((e,t)=>({profiles:[R],activeProfileId:R.id,baseUrl:R.baseUrl,agentBaseUrl:R.agentBaseUrl,token:``,agentToken:``,refreshMs:L.refreshMs,saveConnection:n=>{G();let r=t(),i=J(r),a={...i,name:k(n.name,i.name),baseUrl:T(n.baseUrl,L.baseUrl),agentBaseUrl:T(n.agentBaseUrl??i.agentBaseUrl,L.agentBaseUrl)};return X(i.id,n.token,n.agentToken),e({profiles:Y(r,a),baseUrl:a.baseUrl,agentBaseUrl:a.agentBaseUrl,token:E(n.token),agentToken:E(n.agentToken)}),K()},addProfile:n=>{let r=t();if(r.profiles.length>=32)return{persisted:!1,error:`At most 32 Bunqueue nodes are supported.`};G();let i=ie(r.profiles),a={id:i,name:k(n.name,`Bunqueue ${r.profiles.length+1}`),baseUrl:T(n.baseUrl,L.baseUrl),agentBaseUrl:T(n.agentBaseUrl,L.agentBaseUrl)};return X(i,n.token,n.agentToken),e({profiles:[...r.profiles,a],activeProfileId:i,baseUrl:a.baseUrl,agentBaseUrl:a.agentBaseUrl,token:E(n.token),agentToken:E(n.agentToken)}),{...K(),id:i}},activateProfile:n=>{let r=t(),i=r.profiles.find(e=>e.id===n);if(!i)return!1;X(r.activeProfileId,r.token,r.agentToken);let a=q.get(n)??{token:``,agentToken:``};return e({activeProfileId:n,baseUrl:i.baseUrl,agentBaseUrl:i.agentBaseUrl,...a}),!0},removeProfile:n=>{let r=t();if(r.profiles.length===1||!r.profiles.some(e=>e.id===n))return!1;q.delete(n);let i=r.profiles.filter(e=>e.id!==n);if(n!==r.activeProfileId)return e({profiles:i}),!0;let a=i[0],o=q.get(a.id)??{token:``,agentToken:``};return e({profiles:i,activeProfileId:a.id,baseUrl:a.baseUrl,agentBaseUrl:a.agentBaseUrl,...o}),!0},setBaseUrl:t=>e(e=>{let n=T(t,L.baseUrl);return{baseUrl:n,profiles:Y(e,{baseUrl:n})}}),setAgentBaseUrl:t=>e(e=>{let n=T(t,L.agentBaseUrl);return{agentBaseUrl:n,profiles:Y(e,{agentBaseUrl:n})}}),setToken:t=>e(e=>{let n=E(t);return X(e.activeProfileId,n,e.agentToken),{token:n}}),setAgentToken:t=>e(e=>{let n=E(t);return X(e.activeProfileId,e.token,n),{agentToken:n}}),setRefreshMs:t=>e({refreshMs:z(t)})}),{name:F,storage:se,version:4,partialize:B,migrate:H,merge:(e,t)=>{q.clear();let n=V(e),r=n.profiles.find(e=>e.id===n.activeProfileId)??n.profiles[0];return{...t,...n,baseUrl:r.baseUrl,agentBaseUrl:r.agentBaseUrl,token:``,agentToken:``}}}));function ce(e){let t=Z.getState(),n=t.profiles.find(t=>t.id===e);if(!n)return null;let r=e===t.activeProfileId?{token:E(t.token),agentToken:E(t.agentToken)}:q.get(e)??{token:``,agentToken:``};return Object.freeze({...n,...r})}var le=()=>T(Z.getState().baseUrl,L.baseUrl),ue=()=>T(Z.getState().agentBaseUrl,L.agentBaseUrl),Q=()=>$(Z.getState().token),de=()=>$(Z.getState().agentToken);function $(e){let t=E(e);return t?{Authorization:`Bearer ${t}`}:{}}export{le as a,S as c,h as d,l as f,Q as i,y as l,c as m,de as n,Z as o,d as p,ue as r,b as s,ce as t,_ as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t}from"./react-vendor-CFL9l8LK.js";import{o as n}from"./connectionStore-CVjQyIZv.js";var r=e(t(),1),i=0,a=new Set;n.subscribe((e,t)=>{if(!(e.baseUrl===t.baseUrl&&e.agentBaseUrl===t.agentBaseUrl&&e.activeProfileId===t.activeProfileId&&e.token===t.token&&e.agentToken===t.agentToken)){i+=1;for(let e of a)e()}});function o(){return i}function s(){return(0,r.useSyncExternalStore)(c,o,o)}function c(e){return a.add(e),()=>a.delete(e)}export{s as n,o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./react-vendor-CFL9l8LK.js";import{r as t}from"./StatusBadge-DereLzOj.js";var n=e();function r({className:e,decorative:r=!1}){let i=t(`inline-block size-4 animate-spin rounded-full border-2 border-current border-t-transparent`,e);return r?(0,n.jsx)(`span`,{className:i,"aria-hidden":`true`}):(0,n.jsx)(`span`,{className:i,role:`status`,"aria-label":`Loading`})}function i({label:e=`Loading…`}){return(0,n.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`flex items-center justify-center gap-3 py-16 text-sm text-muted`,children:[(0,n.jsx)(r,{decorative:!0}),e]})}function a({icon:e,title:t,hint:r,action:i}){return(0,n.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-line py-14 text-center`,children:[e&&(0,n.jsx)(`div`,{className:`text-faint [&>svg]:size-8`,children:e}),(0,n.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t}),r&&(0,n.jsx)(`div`,{className:`max-w-sm text-xs text-faint`,children:r}),i&&(0,n.jsx)(`div`,{className:`mt-2`,children:i})]})}function o({onRetry:e,message:t=`Could not refresh bunqueue data — the view may be unavailable or stale.`}){return(0,n.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`mb-4 flex flex-wrap items-center gap-3 rounded-lg border border-amber-500/25 bg-amber-500/[0.06] px-4 py-2.5 text-sm`,children:[(0,n.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-amber-400`,"aria-hidden":`true`}),(0,n.jsx)(`span`,{className:`text-amber-300/90 light:text-amber-700`,children:t}),e&&(0,n.jsx)(`button`,{type:`button`,onClick:e,className:`ml-auto shrink-0 rounded-md border border-amber-500/30 px-2.5 py-1 text-xs font-medium text-amber-200 light:text-amber-700 hover:border-amber-400/50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,children:`Retry`})]})}function s({error:e,onRetry:t}){return(0,n.jsxs)(`div`,{role:`alert`,"aria-atomic":`true`,className:`flex flex-col items-center justify-center gap-3 rounded-xl border border-red-500/20 bg-red-500/5 py-14 text-center`,children:[(0,n.jsx)(`div`,{className:`text-sm font-medium text-danger`,children:`Something went wrong`}),(0,n.jsx)(`div`,{className:`max-w-md text-xs text-faint`,children:e.message}),t&&(0,n.jsx)(`button`,{type:`button`,onClick:t,className:`mt-1 rounded-lg border border-line bg-surface-2 px-3 py-1.5 text-xs font-medium text-fg hover:border-line-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,children:`Retry`})]})}export{o as i,s as n,i as r,a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{r}from"./StatusBadge-DereLzOj.js";var i=e(t(),1),a=n();function o({children:e,htmlFor:t}){return(0,a.jsx)(`label`,{htmlFor:t,className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e})}function s({label:e,hint:t,htmlFor:n,children:r}){let s=(0,i.useId)(),c=r,d=n;if(!n&&(0,i.isValidElement)(r)){let e=r;(typeof e.type==`string`&&[`input`,`select`,`textarea`].includes(e.type)||e.type===l||e.type===u)&&(d=e.props.id??s,c=e.props.id?e:(0,i.cloneElement)(e,{id:s}))}return(0,a.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,a.jsx)(o,{htmlFor:d,children:e}),c,t&&(0,a.jsx)(`p`,{className:`text-xs leading-relaxed text-faint`,children:t})]})}var c=`h-9 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg placeholder:text-faint transition-colors focus-visible:border-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`;function l({className:e,...t}){return(0,a.jsx)(`input`,{className:r(c,`w-full`,e),...t})}function u({className:e,children:t,...n}){return(0,a.jsx)(`select`,{className:r(c,`w-full cursor-pointer pr-8`,e),...n,children:t})}function d({checked:e,onChange:t,label:n,disabled:i}){return(0,a.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":n,disabled:i,onClick:()=>t(!e),className:r(`relative inline-flex h-6 w-11 items-center rounded-full transition-colors`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,e?`bg-accent`:`bg-surface-2 border border-line`,i&&`opacity-40`),children:(0,a.jsx)(`span`,{className:r(`inline-block size-4 transform rounded-full bg-white shadow transition-transform`,e?`translate-x-6`:`translate-x-1`)})})}function f({options:e,value:t,onChange:n,disabled:i,label:o=`View options`}){return(0,a.jsxs)(`fieldset`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:[(0,a.jsx)(`legend`,{className:`sr-only`,children:o}),e.map(e=>(0,a.jsx)(`button`,{type:`button`,"aria-pressed":t===e,disabled:i,onClick:()=>n(e),className:r(`rounded-md px-3 py-1 text-xs font-medium capitalize transition-colors`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,t===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`,i&&`opacity-40`),children:e},e))]})}export{u as a,f as i,l as n,d as o,o as r,s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-vendor-
|
|
1
|
+
import{t as e}from"./react-vendor-CFL9l8LK.js";var t=e();function n({children:e,...n}){return(0,t.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,...n,children:e})}var r=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M3 3v18h18`}),(0,t.jsx)(`rect`,{x:`7`,y:`12`,width:`3`,height:`6`}),(0,t.jsx)(`rect`,{x:`12`,y:`8`,width:`3`,height:`10`}),(0,t.jsx)(`rect`,{x:`17`,y:`5`,width:`3`,height:`13`})]}),i=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,t.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,t.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,t.jsx)(`line`,{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`}),(0,t.jsx)(`line`,{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`}),(0,t.jsx)(`line`,{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`})]}),a=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`2`,y:`7`,width:`20`,height:`14`,rx:`2`}),(0,t.jsx)(`path`,{d:`M16 7V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`})]}),o=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z`}),(0,t.jsx)(`line`,{x1:`12`,y1:`9`,x2:`12`,y2:`13`}),(0,t.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`})]}),s=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,t.jsx)(`polyline`,{points:`12 7 12 12 15 14`})]}),c=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M3 3v18h18`}),(0,t.jsx)(`path`,{d:`m19 9-5 5-4-4-3 3`})]}),l=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`8`,rx:`2`}),(0,t.jsx)(`rect`,{x:`4`,y:`14`,width:`16`,height:`6`,rx:`2`}),(0,t.jsx)(`line`,{x1:`8`,y1:`8`,x2:`8.01`,y2:`8`}),(0,t.jsx)(`line`,{x1:`8`,y1:`17`,x2:`8.01`,y2:`17`})]}),u=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`}),(0,t.jsx)(`path`,{d:`M13.73 21a2 2 0 0 1-3.46 0`})]}),d=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,t.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,t.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,t.jsx)(`path`,{d:`M3 6h.01M3 12h.01M3 18h.01`})]}),f=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M12 20V10`}),(0,t.jsx)(`path`,{d:`M18 20V4`}),(0,t.jsx)(`path`,{d:`M6 20v-4`})]}),p=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,t.jsx)(`path`,{d:`M4 5v6c0 1.66 3.58 3 8 3s8-1.34 8-3V5`}),(0,t.jsx)(`path`,{d:`M4 11v6c0 1.66 3.58 3 8 3s8-1.34 8-3v-6`})]}),m=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,t.jsx)(`path`,{d:`M3 10h18`}),(0,t.jsx)(`path`,{d:`M9 10v10`})]}),h=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,t.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z`})]}),g=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,t.jsx)(`path`,{d:`M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41`})]}),_=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`path`,{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79Z`})}),v=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),y=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polyline`,{points:`9 18 15 12 9 6`})}),b=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polygon`,{points:`5 3 19 12 5 21 5 3`})}),x=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`6`,y:`4`,width:`4`,height:`16`}),(0,t.jsx)(`rect`,{x:`14`,y:`4`,width:`4`,height:`16`})]}),S=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`polyline`,{points:`3 6 5 6 21 6`}),(0,t.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]}),C=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`polyline`,{points:`23 4 23 10 17 10`}),(0,t.jsx)(`polyline`,{points:`1 20 1 14 7 14`}),(0,t.jsx)(`path`,{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`})]}),w=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,t.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),T=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8Z`}),(0,t.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]}),E=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polygon`,{points:`13 2 3 14 12 14 11 22 21 10 12 10 13 2`})}),D=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,t.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]}),O=e=>(0,t.jsx)(n,{...e,children:(0,t.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),k=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,t.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]}),A=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,t.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]}),j=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`line`,{x1:`3`,y1:`6`,x2:`21`,y2:`6`}),(0,t.jsx)(`line`,{x1:`3`,y1:`12`,x2:`21`,y2:`12`}),(0,t.jsx)(`line`,{x1:`3`,y1:`18`,x2:`21`,y2:`18`})]}),M=e=>(0,t.jsxs)(n,{...e,children:[(0,t.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,t.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,t.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]});export{l as A,C,g as D,h as E,S as O,i as S,w as T,c as _,y as a,x as b,s as c,M as d,T as f,j as g,d as h,v as i,f as k,m as l,E as m,k as n,D as o,a as p,O as r,A as s,u as t,o as u,_ as v,p as w,b as x,r as y};
|