bunqueue-dashboard 0.0.28 → 0.0.30
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/dist/.vite/manifest.json +61 -61
- package/dist/assets/{AddJob-BWQUAkBR.js → AddJob-Bsc2w6F0.js} +1 -1
- package/dist/assets/{Alerts-B0xnP5CV.js → Alerts-GhRfE6uG.js} +1 -1
- package/dist/assets/{Benchmark-Dw6Adnj6.js → Benchmark-Bc_ZEM87.js} +1 -1
- package/dist/assets/{BulkAddJobs-DAdNpGRo.js → BulkAddJobs-B9q81JAq.js} +1 -1
- package/dist/assets/{CopilotPanel-Bpxw4K9a.js → CopilotPanel-DL61f5jW.js} +2 -2
- package/dist/assets/{Cron-CV32TamV.js → Cron-BqKxXt_G.js} +1 -1
- package/dist/assets/CronManager-DuWur13m.js +1 -0
- package/dist/assets/{Database-ehv_cEQ2.js → Database-DSpCA3w7.js} +2 -2
- package/dist/assets/{Diagnostics-CorlmvKz.js → Diagnostics-DsBFg_-t.js} +1 -1
- package/dist/assets/{Dlq-Ctk9zeER.js → Dlq-BAQfqBgy.js} +1 -1
- package/dist/assets/DlqControl-B0VILOwI.js +1 -0
- package/dist/assets/{DlqPro-Bw3yQpGs.js → DlqPro-D8POex8v.js} +1 -1
- package/dist/assets/{Flows-rrvRgRtA.js → Flows-BEafLVu_.js} +1 -1
- package/dist/assets/JobInspector-Du4zhHVo.js +2 -0
- package/dist/assets/{Jobs-5faPmBs1.js → Jobs-9VzulNrm.js} +1 -1
- package/dist/assets/JobsPro-YebB40C-.js +1 -0
- package/dist/assets/{Logs-BFVWi8D3.js → Logs-DtV3k05m.js} +1 -1
- package/dist/assets/{LogsPro-CkwTCyHD.js → LogsPro-C9VmsZL-.js} +1 -1
- package/dist/assets/{McpServer-Bs9xBhXn.js → McpServer-CI9Z61Lm.js} +1 -1
- package/dist/assets/{Metrics-cYFyZR3N.js → Metrics-qsVJt17r.js} +1 -1
- package/dist/assets/{MetricsPro-DFQhOiMq.js → MetricsPro-BMNObO4L.js} +1 -1
- package/dist/assets/{Overview-CtPFwJ89.js → Overview-DtVeV_uf.js} +1 -1
- package/dist/assets/{Pagination-C_ycPjHn.js → Pagination-EJ2HGoqv.js} +1 -1
- package/dist/assets/QueueActions-qd4d3da3.js +1 -0
- package/dist/assets/QueueControl-2NXIrJqi.js +1 -0
- package/dist/assets/{QueueDetail-DJZ30jtl.js → QueueDetail-7EEYk51J.js} +1 -1
- package/dist/assets/QueueDetailPro-DDB6mrh6.js +1 -0
- package/dist/assets/{Queues-j0iVmzXB.js → Queues-ClEE2_8g.js} +1 -1
- package/dist/assets/{QueuesOverview-LFhAaVxQ.js → QueuesOverview-CzbHoeuS.js} +1 -1
- package/dist/assets/{S3Backup-B02cXBEq.js → S3Backup-ETwjL2TD.js} +1 -1
- package/dist/assets/{S3BackupPro-k_zofIyL.js → S3BackupPro-DwX9b_1u.js} +1 -1
- package/dist/assets/{ServerControl-P8h0f0HD.js → ServerControl-BOh2ncLo.js} +1 -1
- package/dist/assets/{Settings-BE7LB_rx.js → Settings-_aPq2yDv.js} +1 -1
- package/dist/assets/{Usage-DRq_sm9A.js → Usage-B6ESpkgj.js} +1 -1
- package/dist/assets/{UsagePro-CaEgDStT.js → UsagePro-Dv0izJVc.js} +1 -1
- package/dist/assets/{Webhooks-DUtMCoyF.js → Webhooks-Cs-DqyhB.js} +1 -1
- package/dist/assets/{Workers-DPryLaxE.js → Workers-CXwdSXup.js} +1 -1
- package/dist/assets/{WorkersPro-DlHDhoV4.js → WorkersPro-BBnrgBbn.js} +1 -1
- package/dist/assets/index-BFRKPhvf.js +8 -0
- package/dist/assets/{useThroughputSeries-BuNc_qkH.js → useThroughputSeries-BzUriOcf.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/scripts/embedded.gen.ts +104 -104
- package/dist/assets/CronManager-BEaa7wiR.js +0 -1
- package/dist/assets/DlqControl-CIsg8otQ.js +0 -1
- package/dist/assets/JobInspector-C7vAErSx.js +0 -2
- package/dist/assets/JobsPro-BOkJw2tF.js +0 -1
- package/dist/assets/QueueActions-BIJ-MHWn.js +0 -1
- package/dist/assets/QueueControl-OXvmyeYT.js +0 -1
- package/dist/assets/QueueDetailPro-DwOCQfIi.js +0 -1
- package/dist/assets/index-BxYFC0LS.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./cn-CMFYpumL.js";import{h as r,t as i}from"./react-vendor-B68RYDeC.js";import{E as a,nt as o}from"./index-
|
|
1
|
+
import{n as e,r as t,t as n}from"./cn-CMFYpumL.js";import{h as r,t as i}from"./react-vendor-B68RYDeC.js";import{E as a,nt as o}from"./index-BFRKPhvf.js";import{a as s,n as c,t as l}from"./form-C-zZyKfB.js";var u=t(r(),1),d=`vercel.ai.error`,f=Symbol.for(d),p,m,h=class e extends (m=Error,p=f,m){constructor({name:e,message:t,cause:n}){super(t),this[p]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,d)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},g=`AI_APICallError`,_=`vercel.ai.error.${g}`,v=Symbol.for(_),y,b,x=class extends (b=h,y=v,b){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:g,message:e,cause:o}),this[y]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return h.hasMarker(e,_)}},S=`AI_EmptyResponseBodyError`,ee=`vercel.ai.error.${S}`,te=Symbol.for(ee),ne,re,ie=class extends (re=h,ne=te,re){constructor({message:e=`Empty response body`}={}){super({name:S,message:e}),this[ne]=!0}static isInstance(e){return h.hasMarker(e,ee)}};function ae(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var oe=`AI_InvalidArgumentError`,se=`vercel.ai.error.${oe}`,C=Symbol.for(se),ce,le,ue=class extends (le=h,ce=C,le){constructor({message:e,cause:t,argument:n}){super({name:oe,message:e,cause:t}),this[ce]=!0,this.argument=n}static isInstance(e){return h.hasMarker(e,se)}},de=`AI_InvalidPromptError`,fe=`vercel.ai.error.${de}`,pe=Symbol.for(fe),me,he,ge=class extends (he=h,me=pe,he){constructor({prompt:e,message:t,cause:n}){super({name:de,message:`Invalid prompt: ${t}`,cause:n}),this[me]=!0,this.prompt=e}static isInstance(e){return h.hasMarker(e,fe)}},_e=`AI_InvalidResponseDataError`,ve=`vercel.ai.error.${_e}`,ye=Symbol.for(ve),be,xe,Se=class extends (xe=h,be=ye,xe){constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:_e,message:t}),this[be]=!0,this.data=e}static isInstance(e){return h.hasMarker(e,ve)}},Ce=`AI_JSONParseError`,we=`vercel.ai.error.${Ce}`,Te=Symbol.for(we),Ee,De,Oe=class extends (De=h,Ee=Te,De){constructor({text:e,cause:t}){super({name:Ce,message:`JSON parsing failed: Text: ${e}.
|
|
2
2
|
Error message: ${ae(t)}`,cause:t}),this[Ee]=!0,this.text=e}static isInstance(e){return h.hasMarker(e,we)}},ke=`AI_LoadAPIKeyError`,Ae=`vercel.ai.error.${ke}`,je=Symbol.for(Ae),Me,Ne,Pe=class extends (Ne=h,Me=je,Ne){constructor({message:e}){super({name:ke,message:e}),this[Me]=!0}static isInstance(e){return h.hasMarker(e,Ae)}},Fe=`AI_NoSuchModelError`,Ie=`vercel.ai.error.${Fe}`,Le=Symbol.for(Ie),Re,ze,Be=class extends (ze=h,Re=Le,ze){constructor({errorName:e=Fe,modelId:t,modelType:n,message:r=`No such ${n}: ${t}`}){super({name:e,message:r}),this[Re]=!0,this.modelId=t,this.modelType=n}static isInstance(e){return h.hasMarker(e,Ie)}},Ve=`AI_NoSuchProviderReferenceError`,He=`vercel.ai.error.${Ve}`,Ue=Symbol.for(He),We,Ge,Ke=class extends (Ge=h,We=Ue,Ge){constructor({provider:e,reference:t,message:n=`No provider reference found for provider '${e}'. Available providers: ${Object.keys(t).join(`, `)}`}){super({name:Ve,message:n}),this[We]=!0,this.provider=e,this.reference=t}static isInstance(e){return h.hasMarker(e,He)}},qe=`AI_TooManyEmbeddingValuesForCallError`,Je=`vercel.ai.error.${qe}`,Ye=Symbol.for(Je),Xe,Ze,Qe=class extends (Ze=h,Xe=Ye,Ze){constructor(e){super({name:qe,message:`Too many values for a single embedding call. The ${e.provider} model "${e.modelId}" can only embed up to ${e.maxEmbeddingsPerCall} values per call, but ${e.values.length} values were provided.`}),this[Xe]=!0,this.provider=e.provider,this.modelId=e.modelId,this.maxEmbeddingsPerCall=e.maxEmbeddingsPerCall,this.values=e.values}static isInstance(e){return h.hasMarker(e,Je)}},$e=`AI_TypeValidationError`,et=`vercel.ai.error.${$e}`,tt=Symbol.for(et),nt,rt,it=class e extends (rt=h,nt=tt,rt){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:$e,message:`${r}: Value: ${JSON.stringify(e)}.
|
|
3
3
|
Error message: ${ae(t)}`,cause:t}),this[nt]=!0,this.value=e,this.context=n}static isInstance(e){return h.hasMarker(e,et)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},at=`AI_UnsupportedFunctionalityError`,ot=`vercel.ai.error.${at}`,st=Symbol.for(ot),ct,lt,w=class extends (lt=h,ct=st,lt){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:at,message:t}),this[ct]=!0,this.functionality=e}static isInstance(e){return h.hasMarker(e,ot)}},ut;function T(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var dt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ft=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ut=globalThis).__zod_globalConfig??(ut.__zod_globalConfig={});var pt=globalThis.__zod_globalConfig;function mt(e){return e&&Object.assign(pt,e),pt}function ht(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function gt(e,t){return typeof t==`bigint`?t.toString():t}function _t(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function vt(e){return e==null}function yt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function bt(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var xt=Symbol(`evaluating`);function St(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==xt)return r===void 0&&(r=xt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ct(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function wt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Tt(e){return JSON.stringify(e)}function Et(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Dt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var kt=_t(()=>{if(pt.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function At(e){if(Ot(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Ot(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function jt(e){return At(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Mt=new Set([`string`,`number`,`symbol`]);function Nt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Pt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function E(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ft(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var It={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Lt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Pt(e,wt(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Ct(this,`shape`,e),e},checks:[]}))}function Rt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Pt(e,wt(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Ct(this,`shape`,r),r},checks:[]}))}function zt(e,t){if(!At(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Pt(e,wt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Ct(this,`shape`,n),n}}))}function Bt(e,t){if(!At(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Pt(e,wt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Ct(this,`shape`,n),n}}))}function Vt(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Pt(e,wt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Ct(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ht(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Pt(t,wt(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Ct(this,`shape`,i),i},checks:[]}))}function Ut(e,t,n){return Pt(t,wt(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Ct(this,`shape`,i),i}}))}function Wt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Gt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Kt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function qt(e){return typeof e==`string`?e:e?.message}function Jt(e,t,n){let r=e.message?e.message:qt(e.inst?._zod.def?.error?.(e))??qt(t?.error?.(e))??qt(n.customError?.(e))??qt(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Yt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Xt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Zt=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,gt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Qt=T(`$ZodError`,Zt),$t=T(`$ZodError`,Zt,{Parent:Error});function en(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function tn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var nn=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new dt;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Jt(e,a,mt())));throw Dt(t,i?.callee),t}return o.value},rn=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Jt(e,a,mt())));throw Dt(t,i?.callee),t}return o.value},an=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new dt;return a.issues.length?{success:!1,error:new(e??Qt)(a.issues.map(e=>Jt(e,i,mt())))}:{success:!0,data:a.value}},on=an($t),sn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Jt(e,i,mt())))}:{success:!0,data:a.value}},cn=sn($t),ln=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return nn(e)(t,n,i)},un=e=>(t,n,r)=>nn(e)(t,n,r),dn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return rn(e)(t,n,i)},fn=e=>async(t,n,r)=>rn(e)(t,n,r),pn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return an(e)(t,n,i)},mn=e=>(t,n,r)=>an(e)(t,n,r),hn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return sn(e)(t,n,i)},gn=e=>async(t,n,r)=>sn(e)(t,n,r),_n=/^[cC][0-9a-z]{6,}$/,vn=/^[0-9a-z]+$/,yn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bn=/^[0-9a-vA-V]{20}$/,xn=/^[A-Za-z0-9]{27}$/,Sn=/^[a-zA-Z0-9_-]{21}$/,Cn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,wn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Tn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,En=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Dn=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function On(){return new RegExp(Dn,`u`)}var kn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,An=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,jn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Mn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Nn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pn=/^[A-Za-z0-9_-]*$/,Fn=/^https?$/,In=/^\+[1-9]\d{6,14}$/,Ln=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,Rn=RegExp(`^${Ln}$`);function zn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Bn(e){return RegExp(`^${zn(e)}$`)}function Vn(e){let t=zn({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Ln}T(?:${r})$`)}var Hn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Un=/^-?\d+$/,Wn=/^-?\d+(?:\.\d+)?$/,Gn=/^(?:true|false)$/i,Kn=/^null$/i,qn=/^[^A-Z]*$/,Jn=/^[^a-z]*$/,Yn=T(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Xn={number:`number`,bigint:`bigint`,object:`date`},Zn=T(`$ZodCheckLessThan`,(e,t)=>{Yn.init(e,t);let n=Xn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Qn=T(`$ZodCheckGreaterThan`,(e,t)=>{Yn.init(e,t);let n=Xn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$n=T(`$ZodCheckMultipleOf`,(e,t)=>{Yn.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):bt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),er=T(`$ZodCheckNumberFormat`,(e,t)=>{Yn.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=It[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Un)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),tr=T(`$ZodCheckMaxLength`,(e,t)=>{var n;Yn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!vt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Yt(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),nr=T(`$ZodCheckMinLength`,(e,t)=>{var n;Yn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!vt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Yt(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),rr=T(`$ZodCheckLengthEquals`,(e,t)=>{var n;Yn.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!vt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Yt(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ir=T(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Yn.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ar=T(`$ZodCheckRegex`,(e,t)=>{ir.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),or=T(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=qn,ir.init(e,t)}),sr=T(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Jn,ir.init(e,t)}),cr=T(`$ZodCheckIncludes`,(e,t)=>{Yn.init(e,t);let n=Nt(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),lr=T(`$ZodCheckStartsWith`,(e,t)=>{Yn.init(e,t);let n=RegExp(`^${Nt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),ur=T(`$ZodCheckEndsWith`,(e,t)=>{Yn.init(e,t);let n=RegExp(`.*${Nt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),dr=T(`$ZodCheckOverwrite`,(e,t)=>{Yn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),fr=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
4
4
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
@@ -149,4 +149,4 @@ You help the operator understand and control their queues, jobs, dead-letter que
|
|
|
149
149
|
|
|
150
150
|
Mutating tools (retry, promote, remove, pause/resume, retry/purge DLQ) are gated: when you call one, the user is shown a confirmation and must approve it before it runs, so it is safe to propose a concrete action. If the user's request is ambiguous about which queue or job, ask a brief clarifying question or look it up first.
|
|
151
151
|
|
|
152
|
-
Be concise and practical. When you report data, summarize the important numbers rather than dumping raw JSON. Format with short markdown (bold, lists) when helpful.`;function SO(e,t){let n=e.toLowerCase();if(n.includes(`failed to fetch`)||n.includes(`networkerror`)||n.includes(`load failed`)){let e=sx(t);return`Could not reach the model. This is usually the provider blocking browser (CORS) requests, a wrong base URL, or no network.${e&&!e.browserDirect?` ${e.note??``}`:``}`.trim()}return n.includes(`401`)||n.includes(`403`)||n.includes(`unauthorized`)||n.includes(`api key`)||n.includes(`x-api-key`)||n.includes(`invalid_api_key`)||n.includes(`authentication`)?`The provider rejected the API key. Check the key is valid and matches the selected provider.`:n.includes(`rate limit`)||n.includes(`rate_limit`)||n.includes(`429`)||n.includes(`overloaded`)||n.includes(`quota`)||n.includes(`too many requests`)?`The provider is rate-limiting or overloaded: ${e}. Wait a moment and retry.`:n.includes(`404`)||n.includes(`not found`)||n.includes(`model_not_found`)||n.includes(`no such model`)||n.includes(`does not exist`)||n.includes(`unknown model`)||n.includes(`invalid model`)?`Model request failed: ${e}. Check the model id is valid for this provider.`:e}var CO=null;function wO(){let e=CO;CO=null;let t=a.getState();t.cancelPending(),t.setBusy(!1),e?.abort()}async function TO(e){let t=a.getState(),{config:n}=t;if(!n.apiKey.trim()){t.addUser(e);let n=t.startAssistant();t.finishAssistant(n,{error:`Add your API key in the Copilot settings (the gear) first.`});return}let r=t.messages.filter(e=>e.content.trim().length>0).map(e=>({role:e.role,content:e.content}));t.addUser(e);let i=t.startAssistant();t.setBusy(!0);let o=new AbortController;CO=o;let s=null;try{let a=mO({model:cx(n),system:xO,messages:[...r,{role:`user`,content:e}],tools:bO(i),stopWhen:pD(8),abortSignal:o.signal,onError:({error:e})=>{s=e instanceof Error?e.message:String(e)}});for await(let e of a.textStream)t.appendAssistant(i,e)}catch(e){if(e.name===`AbortError`){t.cancelPending(),t.finishAssistant(i),t.setBusy(!1),CO===o&&(CO=null);return}s||=e.message}t.finishAssistant(i,s?{error:SO(s,n.provider)}:void 0),t.setBusy(!1),CO===o&&(CO=null)}var $=i(),EO=[`Which queues are backing up right now?`,`Show DLQ stats for every queue and what is failing.`,`Summarize server health and worker status.`],DO={awaiting:`border-warning/40 text-warning`,running:`border-accent/40 text-accent`,done:`border-success/40 text-success`,error:`border-danger/40 text-danger`,declined:`border-line text-faint`};function OO(){let{config:e,setConfig:t,messages:n,pending:r,busy:i,clear:o,setOpen:d,resolveConfirm:f}=a(),p=sx(e.provider),m=e.apiKey.trim().length>0&&e.model.trim().length>0,[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(!m),y=(0,u.useRef)(null);(0,u.useEffect)(()=>{y.current?.scrollTo({top:y.current.scrollHeight})},[n,r]),(0,u.useEffect)(()=>{let e=e=>e.key===`Escape`&&d(!1);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[d]);let b=e=>{let t=e.trim();!t||i||!m||(g(``),TO(t))},x=e=>{let n=sx(e);t({provider:e,baseURL:n?.baseURL??``,model:n?.models[0]??``})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Close Copilot`,onClick:()=>d(!1),className:`fixed inset-0 z-[55] cursor-default bg-black/30`}),(0,$.jsxs)(`aside`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Copilot`,className:`fixed inset-y-0 right-0 z-[60] flex w-full max-w-md flex-col border-l border-line bg-surface shadow-xl`,children:[(0,$.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-line px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-fg`,children:`Copilot`}),(0,$.jsx)(`span`,{className:`rounded bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-accent`,children:`experimental`}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,$.jsxs)(kO,{label:`Settings`,active:_,onClick:()=>v(e=>!e),children:[(0,$.jsx)(`path`,{d:`M10 4a2 2 0 014 0 6 6 0 012.6 1.5 2 2 0 002.7 2.7 6 6 0 010 3.6 2 2 0 00-2.7 2.7A6 6 0 0114 18a2 2 0 01-4 0 6 6 0 01-2.6-1.5 2 2 0 00-2.7-2.7 6 6 0 010-3.6 2 2 0 002.7-2.7A6 6 0 0110 4z`}),(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2.5`})]}),(0,$.jsx)(kO,{label:`Clear chat`,onClick:o,children:(0,$.jsx)(`path`,{d:`M6 7h12M9 7V5h6v2m-7 0v11a1 1 0 001 1h6a1 1 0 001-1V7`})}),(0,$.jsx)(kO,{label:`Close`,onClick:()=>d(!1),children:(0,$.jsx)(`path`,{d:`M6 6l12 12M18 6L6 18`})})]})]}),_&&(0,$.jsxs)(`div`,{className:`space-y-3 border-b border-line bg-surface-2/50 px-4 py-3`,children:[(0,$.jsx)(l,{label:`Provider`,children:(0,$.jsx)(s,{value:e.provider,onChange:e=>x(e.target.value),children:ox.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),p?.kind===`compatible`&&(0,$.jsx)(l,{label:`Base URL`,children:(0,$.jsx)(c,{value:e.baseURL,onChange:e=>t({baseURL:e.target.value}),placeholder:`https://api.example.com/v1`,spellCheck:!1})}),(0,$.jsxs)(l,{label:`Model`,children:[(0,$.jsx)(c,{list:`copilot-models`,value:e.model,onChange:e=>t({model:e.target.value}),placeholder:`model id`,spellCheck:!1}),(0,$.jsx)(`datalist`,{id:`copilot-models`,children:(p?.models??[]).map(e=>(0,$.jsx)(`option`,{value:e},e))})]}),(0,$.jsx)(l,{label:`API key`,children:(0,$.jsx)(c,{type:`password`,value:e.apiKey,onChange:e=>t({apiKey:e.target.value}),placeholder:`your provider API key`,autoComplete:`off`,spellCheck:!1})}),(0,$.jsx)(`p`,{className:`text-xs text-faint`,children:`Chat and tool results (live queue/job data) are sent directly from your browser to the provider you configure.`}),(0,$.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Key stays in memory for this session only, never saved to disk.`,` `,p?.keyUrl&&(0,$.jsx)(`a`,{href:p.keyUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent hover:underline`,children:`Get a key`})]}),p&&!p.browserDirect&&(0,$.jsx)(`p`,{className:`rounded-lg border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:p.note??`This provider may block direct browser calls (CORS).`})]}),(0,$.jsxs)(`div`,{ref:y,"aria-live":`polite`,className:`flex-1 space-y-4 overflow-y-auto px-4 py-4`,children:[n.length===0&&(0,$.jsxs)(`div`,{className:`space-y-3 pt-6`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted`,children:`Ask about your queues, jobs, DLQ, workers, or crons. I read live data and can propose actions (retry, pause, purge) that you confirm before they run.`}),(0,$.jsx)(`div`,{className:`space-y-2`,children:EO.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(e),disabled:!m,className:`block w-full rounded-lg border border-line px-3 py-2 text-left text-sm text-muted transition-colors hover:border-accent/50 hover:text-fg disabled:opacity-50`,children:e},e))}),!m&&(0,$.jsx)(`p`,{className:`text-xs text-warning`,children:`Set a provider, model, and API key above to start.`})]}),n.map(e=>(0,$.jsx)(AO,{message:e},e.id))]}),r.length>0&&(0,$.jsx)(`div`,{className:`space-y-2 border-t border-line px-4 py-3`,children:r.map(e=>(0,$.jsx)(jO,{confirm:e,onConfirm:()=>f(e.id,!0),onDecline:()=>f(e.id,!1)},e.id))}),(0,$.jsx)(`div`,{className:`border-t border-line px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(`textarea`,{value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),b(h))},rows:2,placeholder:m?`Ask the Copilot…`:`Add an API key in settings first`,disabled:!m,className:`min-h-0 flex-1 resize-none rounded-lg border border-line bg-surface-2 px-3 py-2 text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-50`}),i?(0,$.jsx)(`button`,{type:`button`,onClick:()=>wO(),className:`rounded-lg border border-line px-3 py-2 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Stop`}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(h),disabled:!h.trim()||!m,className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:`Send`})]})})]})]})}function kO({label:e,active:t,onClick:r,children:i}){return(0,$.jsx)(`button`,{type:`button`,"aria-label":e,onClick:r,className:n(`rounded-md p-1.5 text-muted transition-colors hover:bg-surface-2 hover:text-fg`,t&&`bg-surface-2 text-fg`),children:(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4`,"aria-hidden":`true`,children:i})})}function AO({message:e}){let t=e.role===`user`;return(0,$.jsx)(`div`,{className:n(`flex`,t?`justify-end`:`justify-start`),children:(0,$.jsxs)(`div`,{className:n(`max-w-[85%] space-y-2`,t?`rounded-2xl rounded-br-sm bg-accent/15 px-3 py-2`:`w-full`),children:[(e.tools?.length??0)>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.tools?.map(e=>(0,$.jsxs)(`span`,{className:n(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px]`,DO[e.status]),title:e.error||(e.mutates?`mutating action`:`read`),children:[e.mutates&&(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`●`}),e.label,e.status===`declined`&&` (declined)`,e.status===`error`&&` (failed)`]},e.id))}),e.content&&(0,$.jsx)(`div`,{className:n(`whitespace-pre-wrap break-words text-sm`,e.error?`text-danger`:`text-fg`),children:e.content}),!e.content&&!t&&(e.tools?.length??0)===0&&(0,$.jsx)(`div`,{className:`text-sm text-faint`,children:`Thinking…`})]})})}function jO({confirm:e,onConfirm:t,onDecline:n}){let r=e.args;return(0,$.jsxs)(`div`,{className:`rounded-lg border border-warning/50 bg-warning/10 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[`Confirm: `,e.label]}),r&&Object.keys(r).length>0&&(0,$.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted`,children:Object.entries(r).filter(([,e])=>e!==void 0).map(([e,t])=>`${e}: ${String(t)}`).join(` · `)}),(0,$.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-accent-fg hover:opacity-90`,children:`Confirm`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Decline`})]})]})}export{OO as CopilotPanel};
|
|
152
|
+
Be concise and practical. When you report data, summarize the important numbers rather than dumping raw JSON. Format with short markdown (bold, lists) when helpful.`;function SO(e,t){let n=e.toLowerCase();if(n.includes(`failed to fetch`)||n.includes(`networkerror`)||n.includes(`load failed`)){let e=sx(t);return`Could not reach the model. This is usually the provider blocking browser (CORS) requests, a wrong base URL, or no network.${e&&!e.browserDirect?` ${e.note??``}`:``}`.trim()}return n.includes(`401`)||n.includes(`403`)||n.includes(`unauthorized`)||n.includes(`api key`)||n.includes(`x-api-key`)||n.includes(`invalid_api_key`)||n.includes(`authentication`)?`The provider rejected the API key. Check the key is valid and matches the selected provider.`:n.includes(`rate limit`)||n.includes(`rate_limit`)||n.includes(`429`)||n.includes(`overloaded`)||n.includes(`quota`)||n.includes(`too many requests`)?`The provider is rate-limiting or overloaded: ${e}. Wait a moment and retry.`:n.includes(`404`)||n.includes(`not found`)||n.includes(`model_not_found`)||n.includes(`no such model`)||n.includes(`does not exist`)||n.includes(`unknown model`)||n.includes(`invalid model`)?`Model request failed: ${e}. Check the model id is valid for this provider.`:e}var CO=null;function wO(){let e=CO;CO=null;let t=a.getState();t.cancelPending(),t.setBusy(!1),e?.abort()}async function TO(e){let t=a.getState(),{config:n}=t;if(!n.apiKey.trim()){t.addUser(e);let n=t.startAssistant();t.finishAssistant(n,{error:`Add your API key in the Copilot settings (the gear) first.`});return}let r=t.messages.filter(e=>e.content.trim().length>0).map(e=>({role:e.role,content:e.content}));t.addUser(e);let i=t.startAssistant();t.setBusy(!0);let o=new AbortController;CO=o;let s=null;try{let a=mO({model:cx(n),system:xO,messages:[...r,{role:`user`,content:e}],tools:bO(i),stopWhen:pD(8),abortSignal:o.signal,onError:({error:e})=>{s=e instanceof Error?e.message:String(e)}});for await(let e of a.textStream)t.appendAssistant(i,e)}catch(e){if(e.name===`AbortError`){t.finishAssistant(i),CO===o&&(CO=null);return}s||=e.message}t.finishAssistant(i,s?{error:SO(s,n.provider)}:void 0),CO===o&&(t.setBusy(!1),CO=null)}var $=i(),EO=[`Which queues are backing up right now?`,`Show DLQ stats for every queue and what is failing.`,`Summarize server health and worker status.`],DO={awaiting:`border-warning/40 text-warning`,running:`border-accent/40 text-accent`,done:`border-success/40 text-success`,error:`border-danger/40 text-danger`,declined:`border-line text-faint`};function OO(){let{config:e,setConfig:t,messages:n,pending:r,busy:i,clear:o,setOpen:d,resolveConfirm:f}=a(),p=sx(e.provider),m=e.apiKey.trim().length>0&&e.model.trim().length>0,[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(!m),y=(0,u.useRef)(null);(0,u.useEffect)(()=>{y.current?.scrollTo({top:y.current.scrollHeight})},[n,r]),(0,u.useEffect)(()=>{let e=e=>e.key===`Escape`&&d(!1);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[d]);let b=e=>{let t=e.trim();!t||i||!m||(g(``),TO(t))},x=e=>{let n=sx(e);t({provider:e,baseURL:n?.baseURL??``,model:n?.models[0]??``})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Close Copilot`,onClick:()=>d(!1),className:`fixed inset-0 z-[55] cursor-default bg-black/30`}),(0,$.jsxs)(`aside`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Copilot`,className:`fixed inset-y-0 right-0 z-[60] flex w-full max-w-md flex-col border-l border-line bg-surface shadow-xl`,children:[(0,$.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-line px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-fg`,children:`Copilot`}),(0,$.jsx)(`span`,{className:`rounded bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-accent`,children:`experimental`}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,$.jsxs)(kO,{label:`Settings`,active:_,onClick:()=>v(e=>!e),children:[(0,$.jsx)(`path`,{d:`M10 4a2 2 0 014 0 6 6 0 012.6 1.5 2 2 0 002.7 2.7 6 6 0 010 3.6 2 2 0 00-2.7 2.7A6 6 0 0114 18a2 2 0 01-4 0 6 6 0 01-2.6-1.5 2 2 0 00-2.7-2.7 6 6 0 010-3.6 2 2 0 002.7-2.7A6 6 0 0110 4z`}),(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2.5`})]}),(0,$.jsx)(kO,{label:`Clear chat`,onClick:o,children:(0,$.jsx)(`path`,{d:`M6 7h12M9 7V5h6v2m-7 0v11a1 1 0 001 1h6a1 1 0 001-1V7`})}),(0,$.jsx)(kO,{label:`Close`,onClick:()=>d(!1),children:(0,$.jsx)(`path`,{d:`M6 6l12 12M18 6L6 18`})})]})]}),_&&(0,$.jsxs)(`div`,{className:`space-y-3 border-b border-line bg-surface-2/50 px-4 py-3`,children:[(0,$.jsx)(l,{label:`Provider`,children:(0,$.jsx)(s,{value:e.provider,onChange:e=>x(e.target.value),children:ox.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),p?.kind===`compatible`&&(0,$.jsx)(l,{label:`Base URL`,children:(0,$.jsx)(c,{value:e.baseURL,onChange:e=>t({baseURL:e.target.value}),placeholder:`https://api.example.com/v1`,spellCheck:!1})}),(0,$.jsxs)(l,{label:`Model`,children:[(0,$.jsx)(c,{list:`copilot-models`,value:e.model,onChange:e=>t({model:e.target.value}),placeholder:`model id`,spellCheck:!1}),(0,$.jsx)(`datalist`,{id:`copilot-models`,children:(p?.models??[]).map(e=>(0,$.jsx)(`option`,{value:e},e))})]}),(0,$.jsx)(l,{label:`API key`,children:(0,$.jsx)(c,{type:`password`,value:e.apiKey,onChange:e=>t({apiKey:e.target.value}),placeholder:`your provider API key`,autoComplete:`off`,spellCheck:!1})}),(0,$.jsx)(`p`,{className:`text-xs text-faint`,children:`Chat and tool results (live queue/job data) are sent directly from your browser to the provider you configure.`}),(0,$.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Key stays in memory for this session only, never saved to disk.`,` `,p?.keyUrl&&(0,$.jsx)(`a`,{href:p.keyUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent hover:underline`,children:`Get a key`})]}),p&&!p.browserDirect&&(0,$.jsx)(`p`,{className:`rounded-lg border border-warning/40 bg-warning/10 px-3 py-2 text-xs text-warning`,children:p.note??`This provider may block direct browser calls (CORS).`})]}),(0,$.jsxs)(`div`,{ref:y,"aria-live":`polite`,className:`flex-1 space-y-4 overflow-y-auto px-4 py-4`,children:[n.length===0&&(0,$.jsxs)(`div`,{className:`space-y-3 pt-6`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted`,children:`Ask about your queues, jobs, DLQ, workers, or crons. I read live data and can propose actions (retry, pause, purge) that you confirm before they run.`}),(0,$.jsx)(`div`,{className:`space-y-2`,children:EO.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(e),disabled:!m,className:`block w-full rounded-lg border border-line px-3 py-2 text-left text-sm text-muted transition-colors hover:border-accent/50 hover:text-fg disabled:opacity-50`,children:e},e))}),!m&&(0,$.jsx)(`p`,{className:`text-xs text-warning`,children:`Set a provider, model, and API key above to start.`})]}),n.map(e=>(0,$.jsx)(AO,{message:e},e.id))]}),r.length>0&&(0,$.jsx)(`div`,{className:`space-y-2 border-t border-line px-4 py-3`,children:r.map(e=>(0,$.jsx)(jO,{confirm:e,onConfirm:()=>f(e.id,!0),onDecline:()=>f(e.id,!1)},e.id))}),(0,$.jsx)(`div`,{className:`border-t border-line px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(`textarea`,{value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),b(h))},rows:2,placeholder:m?`Ask the Copilot…`:`Add an API key in settings first`,disabled:!m,className:`min-h-0 flex-1 resize-none rounded-lg border border-line bg-surface-2 px-3 py-2 text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/40 disabled:opacity-50`}),i?(0,$.jsx)(`button`,{type:`button`,onClick:()=>wO(),className:`rounded-lg border border-line px-3 py-2 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Stop`}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(h),disabled:!h.trim()||!m,className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:`Send`})]})})]})]})}function kO({label:e,active:t,onClick:r,children:i}){return(0,$.jsx)(`button`,{type:`button`,"aria-label":e,onClick:r,className:n(`rounded-md p-1.5 text-muted transition-colors hover:bg-surface-2 hover:text-fg`,t&&`bg-surface-2 text-fg`),children:(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`size-4`,"aria-hidden":`true`,children:i})})}function AO({message:e}){let t=e.role===`user`;return(0,$.jsx)(`div`,{className:n(`flex`,t?`justify-end`:`justify-start`),children:(0,$.jsxs)(`div`,{className:n(`max-w-[85%] space-y-2`,t?`rounded-2xl rounded-br-sm bg-accent/15 px-3 py-2`:`w-full`),children:[(e.tools?.length??0)>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.tools?.map(e=>(0,$.jsxs)(`span`,{className:n(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px]`,DO[e.status]),title:e.error||(e.mutates?`mutating action`:`read`),children:[e.mutates&&(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`●`}),e.label,e.status===`declined`&&` (declined)`,e.status===`error`&&` (failed)`]},e.id))}),e.content&&(0,$.jsx)(`div`,{className:n(`whitespace-pre-wrap break-words text-sm`,e.error?`text-danger`:`text-fg`),children:e.content}),!e.content&&!t&&(e.tools?.length??0)===0&&(0,$.jsx)(`div`,{className:`text-sm text-faint`,children:e.done?`Stopped.`:`Thinking…`})]})})}function jO({confirm:e,onConfirm:t,onDecline:n}){let r=e.args;return(0,$.jsxs)(`div`,{className:`rounded-lg border border-warning/50 bg-warning/10 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[`Confirm: `,e.label]}),r&&Object.keys(r).length>0&&(0,$.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted`,children:Object.entries(r).filter(([,e])=>e!==void 0).map(([e,t])=>`${e}: ${String(t)}`).join(` · `)}),(0,$.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-accent-fg hover:opacity-90`,children:`Confirm`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Decline`})]})]})}export{OO as CopilotPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-B68RYDeC.js";import{A as r,L as i,T as a,Y as o,a as s,b as c,c as l,h as u,j as d,v as f,x as p}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-B68RYDeC.js";import{A as r,L as i,T as a,Y as o,a as s,b as c,c as l,h as u,j as d,v as f,x as p}from"./index-BFRKPhvf.js";import{t as m}from"./Pagination-EJ2HGoqv.js";var h=e(t(),1),g=n();function _(){let{data:e,error:t,loading:n,refetch:_}=r(()=>d.crons(),[]),v=(e?.crons??[]).slice(),[y,b]=(0,h.useState)(0),x=Math.max(1,Math.ceil(v.length/15)),S=Math.min(y,x-1),C=async e=>{if(window.confirm(`Delete cron "${e}"?`))try{await d.deleteCron(e),_()}catch{}};return(0,g.jsxs)(`div`,{children:[t&&(0,g.jsx)(p,{onRetry:_}),(0,g.jsx)(u,{title:`Cron Jobs`,description:`${v.length} scheduled`,live:!0}),n&&!e&&!t?(0,g.jsx)(c,{label:`Loading cron jobs…`}):v.length===0?(0,g.jsx)(f,{icon:(0,g.jsx)(i,{}),title:`No scheduled jobs`,hint:`Repeatable jobs created with upsertJobScheduler appear here.`}):(0,g.jsxs)(g.Fragment,{children:[(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:`Name`}),(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Schedule`}),(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Next Run`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Runs`}),(0,g.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,g.jsx)(`tbody`,{children:v.slice(S*15,S*15+15).map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,g.jsx)(`td`,{className:`px-5 py-3 font-medium text-fg`,children:e.name}),(0,g.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue??`—`}),(0,g.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:s(e.nextRun)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:l(e.executions??0)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,g.jsx)(a,{"aria-label":`Delete cron`,onClick:()=>C(e.name),children:(0,g.jsx)(o,{className:`size-3.5`})})})]},e.name))})]})}),(0,g.jsx)(m,{page:S,pageSize:15,total:v.length,onPageChange:b,label:`crons`})]})]})}export{_ as Cron};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-B68RYDeC.js";import{A as i,C as a,L as o,S as s,T as c,Y as l,a as u,b as d,c as f,h as p,nt as m,rt as h,v as g,w as _,x as v}from"./index-BFRKPhvf.js";import{i as y,n as b,o as x,t as S}from"./form-C-zZyKfB.js";import{t as C}from"./Pagination-EJ2HGoqv.js";var w=e(n(),1),T=[``,`jan`,`feb`,`mar`,`apr`,`may`,`jun`,`jul`,`aug`,`sep`,`oct`,`nov`,`dec`],E=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`];function D(e,t,n,r){let i=e===`*`||/^\*\/\d+$/.test(e),a=new Set;for(let i of e.split(`,`)){let e=i.trim().toLowerCase();if(e===``)return null;let o=e.match(/^(.+)\/(\d+)$/),s=o?Number(o[2]):1,c=o?o[1]:e;if(s<1)return null;let l,u;if(c===`*`)l=t,u=n;else if(c.includes(`-`)){let[e,t]=c.split(`-`),n=O(e,r),i=O(t,r);if(n==null||i==null)return null;l=n,u=i}else{let e=O(c,r);if(e==null)return null;l=e,u=o?n:e}if(l<t||u>n||l>u)return null;for(let e=l;e<=u;e+=s)a.add(e)}return a.size?{values:a,star:i}:null}function O(e,t){let n=e.trim().toLowerCase();if(n===``)return null;if(t){let e=t.indexOf(n.slice(0,3));if(e!==-1)return e}return/^\d+$/.test(n)?Number(n):null}function k(e,t,n){let r=e.trim().split(/\s+/);if(r.length!==5)return{valid:!1,error:`Expected 5 fields (min hour day month weekday), got ${r.length}.`,runs:[]};let i=D(r[0],0,59),a=D(r[1],0,23),o=D(r[2],1,31),s=D(r[3],1,12,T),c=D(r[4],0,7,E);if(!i||!a||!o||!s||!c)return{valid:!1,error:`Invalid field syntax.`,runs:[]};let l=new Set;for(let e of c.values)l.add(e===7?0:e);let u={values:l,star:c.star},d=e=>{let t=o.values.has(e.getDate()),n=u.values.has(e.getDay());return o.star||u.star?t&&n:t||n},f=[],p=new Date(n);p.setSeconds(0,0),p.setMinutes(p.getMinutes()+1);for(let e=0;e<22e5&&f.length<t;e++){if(!s.values.has(p.getMonth()+1)){p.setMonth(p.getMonth()+1,1),p.setHours(0,0,0,0);continue}if(!d(p)){p.setDate(p.getDate()+1),p.setHours(0,0,0,0);continue}if(!a.values.has(p.getHours())){p.setHours(p.getHours()+1,0,0,0);continue}if(!i.values.has(p.getMinutes())){p.setMinutes(p.getMinutes()+1,0,0);continue}f.push(p.getTime()),p.setMinutes(p.getMinutes()+1,0,0)}return{valid:!0,runs:f}}var A=r();function j(){let{data:e,error:t,loading:n,refetch:r}=i(()=>m.crons(),[]),_=e?.crons??[],[y,b]=(0,w.useState)(0),x=Math.max(1,Math.ceil(_.length/15)),S=Math.min(y,x-1),[T,E]=(0,w.useState)(null),D=async e=>{if(window.confirm(`Delete cron "${e}"?`)){E(null);try{await m.deleteCron(e),h.success(`Cron deleted`,e),r()}catch(e){E(e.message),h.error(`Delete cron failed`,e.message)}}};return(0,A.jsxs)(`div`,{children:[t&&(0,A.jsx)(v,{onRetry:r}),(0,A.jsx)(p,{title:`Cron Manager`,description:`Schedule and manage repeatable jobs.`,live:!0}),T&&(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:T}),(0,A.jsxs)(s,{className:`mb-6`,children:[(0,A.jsx)(a,{title:`Create schedule`}),(0,A.jsx)(N,{onCreate:async e=>{await m.createCron(e),h.success(`Cron created`,e.name),r()}})]}),n&&!e&&!t?(0,A.jsx)(d,{label:`Loading crons…`}):_.length===0?(0,A.jsx)(g,{icon:(0,A.jsx)(o,{}),title:`No scheduled jobs`,hint:`Create one above.`}):(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`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Name`}),(0,A.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Queue`}),(0,A.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Schedule`}),(0,A.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Next Run`}),(0,A.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Runs`}),(0,A.jsx)(`th`,{scope:`col`,className:`w-12 px-5 py-3`})]})}),(0,A.jsx)(`tbody`,{children:_.slice(S*15,S*15+15).map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,A.jsx)(`td`,{className:`px-5 py-3 font-medium text-fg`,children:e.name}),(0,A.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,A.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:u(e.nextRun)}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:f(e.executions)}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,A.jsx)(c,{"aria-label":`Delete cron`,onClick:()=>D(e.name),children:(0,A.jsx)(l,{className:`size-3.5`})})})]},e.name))})]})}),(0,A.jsx)(C,{page:S,pageSize:15,total:_.length,onPageChange:b,label:`crons`})]})]})}function M(e){let t=Number(e);if(!Number.isInteger(t)||t<=0)return null;if(t<1e3)return`every ${t}ms`;for(let[e,n]of[[864e5,`d`],[36e5,`h`],[6e4,`m`],[1e3,`s`]])if(t>=e){let r=t/e;return`${Number.isInteger(r)?``:`≈ `}every ${Math.round(r*10)/10}${n}`}return null}function N({onCreate:e}){let[n,r]=(0,w.useState)(``),[i,a]=(0,w.useState)(``),[o,s]=(0,w.useState)(`cron`),[c,l]=(0,w.useState)(``),[d,f]=(0,w.useState)(``),[p,m]=(0,w.useState)(`{}`),[h,g]=(0,w.useState)(!1),[v,C]=(0,w.useState)(``),[T,E]=(0,w.useState)(``),[D,O]=(0,w.useState)(!1),[j,N]=(0,w.useState)(!1),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(!1),[R,z]=(0,w.useState)(!1),[B,V]=(0,w.useState)(``),[H,U]=(0,w.useState)(``),[W,G]=(0,w.useState)(``),[K,q]=(0,w.useState)(null),[J,Y]=(0,w.useState)(!1),[X,Z]=(0,w.useState)(!1),Q=(0,w.useMemo)(()=>o!==`cron`||!c.trim()?null:k(c.trim(),3,Date.now()),[o,c]),$=async()=>{if(J)return;if(q(null),Z(!1),!n.trim()||!i.trim()){q(`Name and queue are required`);return}let t={};try{t=p.trim()?JSON.parse(p):{}}catch{q(`Data is not valid JSON`);return}let a={name:n,queue:i,data:t};if(o===`cron`){if(!c.trim()){q(`Cron expression required`);return}if(Q&&!Q.valid){q(Q.error??`Invalid cron expression`);return}a.schedule=c.trim()}else{let e=Number(d);if(!Number.isInteger(e)||e<=0){q(`Interval must be a whole number of milliseconds greater than 0`);return}a.repeatEvery=e}v.trim()&&(a.timezone=v.trim());let s=Number(T);T.trim()!==``&&Number.isFinite(s)&&(a.priority=s),D&&(a.preventOverlap=!0),j&&(a.skipIfNoWorker=!0);let u=Number(P);P.trim()!==``&&Number.isInteger(u)&&u>0&&(a.maxLimit=u),I&&(a.immediately=!0),R&&(a.skipMissedOnRestart=!0);let m={},h=Number(B);B.trim()!==``&&Number.isFinite(h)&&(m.maxAttempts=h);let g=Number(H);H.trim()!==``&&Number.isFinite(g)&&(m.backoff=g);let _=Number(W);W.trim()!==``&&Number.isFinite(_)&&(m.timeout=_),Object.keys(m).length>0&&(a.jobOptions=m),Y(!0);try{await e(a),r(``),l(``),f(``),Z(!0),setTimeout(()=>Z(!1),3e3)}catch(e){q(e.message)}finally{Y(!1)}};return(0,A.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),$()},children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,A.jsx)(S,{label:`Name`,children:(0,A.jsx)(b,{value:n,onChange:e=>r(e.target.value),placeholder:`daily-report`})}),(0,A.jsx)(S,{label:`Queue`,children:(0,A.jsx)(b,{value:i,onChange:e=>a(e.target.value),placeholder:`reports`})})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,A.jsx)(y,{options:[`cron`,`every`],value:o,onChange:s}),o===`cron`?(0,A.jsx)(`div`,{className:`min-w-56 flex-1`,children:(0,A.jsx)(S,{label:`Cron expression`,children:(0,A.jsx)(b,{value:c,onChange:e=>l(e.target.value),placeholder:`0 9 * * *`})})}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`w-40`,children:(0,A.jsx)(S,{label:`Every (ms)`,children:(0,A.jsx)(b,{type:`number`,value:d,onChange:e=>f(e.target.value),placeholder:`30000`})})}),d.trim()!==``&&(0,A.jsx)(`span`,{className:t(`pb-2 text-xs`,M(d)?`text-muted`:`text-danger`),children:M(d)??`not a valid interval`})]})]}),o===`cron`&&c.trim()&&Q&&(0,A.jsx)(`div`,{className:`rounded-lg border border-line bg-surface-2 px-3 py-2 text-xs`,children:Q.valid?Q.runs.length?(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,A.jsxs)(`span`,{className:`text-faint`,children:[`Next runs`,v.trim()?` (local)`:``,`:`]}),Q.runs.map(e=>(0,A.jsx)(`span`,{className:`font-mono text-muted`,children:u(e)},e)),v.trim()&&(0,A.jsxs)(`span`,{className:`text-faint`,children:[`— server evaluates in `,v.trim()]})]}):(0,A.jsx)(`span`,{className:`text-warning`,children:`Valid, but no runs in the next few years.`}):(0,A.jsx)(`span`,{className:`text-danger`,children:Q.error})}),(0,A.jsx)(S,{label:`Data (JSON)`,children:(0,A.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),rows:3,spellCheck:!1,className:`w-full rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-sm text-fg placeholder:text-faint transition-colors focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`text-xs font-medium text-muted hover:text-fg`,children:h?`− Hide advanced`:`+ Advanced options`}),h&&(0,A.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,A.jsx)(S,{label:`Timezone (IANA)`,hint:`e.g. Europe/Rome. Default: server timezone.`,children:(0,A.jsx)(b,{value:v,onChange:e=>C(e.target.value),placeholder:`Europe/Rome`})}),(0,A.jsx)(S,{label:`Priority`,children:(0,A.jsx)(b,{type:`number`,value:T,onChange:e=>E(e.target.value),placeholder:`0`})}),(0,A.jsx)(S,{label:`Max executions`,hint:`blank = unlimited`,children:(0,A.jsx)(b,{type:`number`,min:1,value:P,onChange:e=>F(e.target.value),placeholder:`∞`})}),(0,A.jsxs)(`div`,{className:`col-span-2 flex flex-wrap gap-6`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(x,{checked:D,onChange:O,label:`prevent overlap`}),(0,A.jsx)(`span`,{className:`text-sm text-muted`,children:`prevent overlap`})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(x,{checked:j,onChange:N,label:`skip if no worker`}),(0,A.jsx)(`span`,{className:`text-sm text-muted`,children:`skip if no worker`})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(x,{checked:I,onChange:L,label:`run immediately`}),(0,A.jsx)(`span`,{className:`text-sm text-muted`,children:`run immediately`})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(x,{checked:R,onChange:z,label:`skip missed on restart`}),(0,A.jsx)(`span`,{className:`text-sm text-muted`,children:`skip missed on restart`})]})]}),(0,A.jsxs)(`div`,{className:`col-span-2`,children:[(0,A.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wider text-faint`,children:`Spawned-job options`}),(0,A.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,A.jsx)(S,{label:`Max attempts`,children:(0,A.jsx)(b,{type:`number`,min:1,value:B,onChange:e=>V(e.target.value),placeholder:`3`})}),(0,A.jsx)(S,{label:`Backoff (ms)`,children:(0,A.jsx)(b,{type:`number`,min:0,value:H,onChange:e=>U(e.target.value),placeholder:`1000`})}),(0,A.jsx)(S,{label:`Timeout (ms)`,children:(0,A.jsx)(b,{type:`number`,min:0,value:W,onChange:e=>G(e.target.value),placeholder:`—`})})]})]})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(_,{type:`submit`,variant:`accent`,size:`sm`,disabled:J,children:J?`Creating…`:`Create`}),K&&(0,A.jsx)(`span`,{role:`status`,className:`text-xs text-danger`,children:K}),X&&(0,A.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Cron created ✓`})]})]})}export{j as CronManager};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-B68RYDeC.js";import{A as i,C as a,I as o,J as s,O as c,S as l,b as u,c as d,et as f,h as p,m,nt as h,r as g,rt as _,v,w as y,x as ee}from"./index-
|
|
2
|
-
`)}function j(e,t,n){let r=URL.createObjectURL(new Blob([n],{type:t})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)}function M(){try{let e=JSON.parse(localStorage.getItem(D)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function N(e){try{localStorage.setItem(D,JSON.stringify(e))}catch{}return e}function P(e){return N([e,...M().filter(t=>t!==e)].slice(0,O))}function F(e){if(e==null)return`NULL`;let t=typeof e==`string`?e:String(e);try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function I({value:e,align:n}){if(e==null)return(0,C.jsx)(`span`,{className:`italic text-faint`,children:`NULL`});let r=typeof e==`string`?e:String(e);return(0,C.jsx)(`span`,{className:t(`block max-w-[24rem] truncate`,n===`right`&&`text-right tabular-nums`),title:r,children:r})}function L({columns:e,rows:n,truncatedCells:r,colMeta:i,sort:a,onSort:o,onRowClick:s,dimmed:c}){let l=(0,S.useMemo)(()=>e.map((e,t)=>{let r=i?.[e]?.type?.toUpperCase()??``;if(/INT|REAL|NUM|DEC|DOUB|FLOA/.test(r))return!0;let a=!1;for(let e of n){let n=e[t];if(n!=null&&(a=!0,typeof n!=`number`))return!1}return a}),[e,n,i]);return(0,C.jsx)(`div`,{className:t(`max-h-[70vh] overflow-auto rounded-xl border border-line bg-surface transition-opacity`,c&&`pointer-events-none opacity-50`),children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsx)(`tr`,{className:`text-left text-[11px] uppercase tracking-wider text-faint`,children:e.map((e,n)=>{let r=i?.[e];return(0,C.jsx)(`th`,{className:t(`sticky top-0 z-10 whitespace-nowrap border-b border-line bg-surface px-4 py-3 font-medium`,l[n]&&`text-right`),"aria-sort":a?.col===e?a.dir===`asc`?`ascending`:`descending`:o?`none`:void 0,children:o?(0,C.jsxs)(`button`,{type:`button`,onClick:()=>o(e),"aria-label":`Sort by ${e}`,className:`inline-flex items-center gap-1 uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[e,r?.primaryKey&&(0,C.jsx)(`span`,{className:`rounded bg-accent/15 px-1 py-0.5 text-[9px] font-semibold text-accent`,children:`PK`}),r?.type&&(0,C.jsx)(`span`,{className:`text-faint/70`,children:r.type.toLowerCase()}),(0,C.jsx)(`span`,{"aria-hidden":`true`,className:a?.col===e?`text-accent`:`text-faint/60`,children:a?.col===e?a.dir===`asc`?`▲`:`▼`:`↕`})]}):e},e)})})}),(0,C.jsx)(`tbody`,{children:n.map((e,n)=>(0,C.jsx)(`tr`,{onClick:s?()=>s(n):void 0,onKeyDown:s?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(n))}:void 0,tabIndex:s?0:void 0,className:t(`border-b border-line font-mono text-xs last:border-0 hover:bg-surface-2/40`,s&&`cursor-pointer`),children:e.map((e,t)=>(0,C.jsx)(`td`,{className:`whitespace-nowrap px-4 py-2 text-muted`,children:(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsx)(I,{value:e,align:l[t]?`right`:`left`}),r?.[n]?.[t]&&(0,C.jsx)(`span`,{title:`Value truncated — click the row to view it in full`,className:`shrink-0 rounded bg-warning/15 px-1 text-[9px] font-semibold text-warning`,children:`…`})]})},t))},n))})]})})}function R(){let[e,n]=(0,S.useState)(``),[r,a]=(0,S.useState)(0),[o,s]=(0,S.useState)(null),[c,b]=(0,S.useState)(`data`),[D,O]=(0,S.useState)(null),[k,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(`SELECT name FROM sqlite_master WHERE type = 'table'`),F=(0,S.useRef)(null),{data:I,error:R,loading:ie,refetch:ae}=i(()=>h.db.tables(),[],{intervalMs:1e4}),B=(0,S.useMemo)(()=>I?.tables??[],[I]),V=R instanceof f&&R.status===404,{data:H}=i(()=>V?Promise.resolve(null):h.db.info(),[V],{intervalMs:15e3}),U=e||B[0]?.name||``;(0,S.useEffect)(()=>{!e&&B[0]&&n(B[0].name)},[e,B]);let{data:W}=i(()=>U?h.db.schema(U):Promise.resolve(null),[U],{intervalMs:3e4}),oe=(0,S.useMemo)(()=>{let e={};if(W?.table===U)for(let t of W.columns)e[t.name]={type:t.type,primaryKey:t.primaryKey};return e},[W,U]),G=D?`${D.column}|${D.op}|${D.value}`:``,{data:K,error:q,loading:J}=i((0,S.useCallback)(async()=>U?{...await h.db.rows(U,w,r*w,o?.col,o?.dir,D??void 0),page:r,filterKey:G}:null,[U,r,o,D,G]),[U,r,o,G],{intervalMs:6e3}),Y=K&&K.table===U&&K.page===r&&K.orderBy===(o?.col??null)&&(!o||K.dir===o.dir)&&K.filterKey===G?K:null;(0,S.useEffect)(()=>{Y&&Y.total>0&&Y.rows.length===0&&r>0&&a(Math.max(0,Math.ceil(Y.total/w)-1))},[Y,r]);let[X,Z]=(0,S.useState)(!1),[Q,$]=(0,S.useState)(null),se=()=>{a(0),s(null),O(null),M(null)},ce=e=>{n(e),b(`data`),se()},le=e=>{a(0),M(null),s(t=>t?.col===e?t.dir===`asc`?{col:e,dir:`desc`}:null:{col:e,dir:`asc`})},ue=()=>{Y&&j(`${Y.table}-page${r+1}.csv`,`text/csv`,A(Y.columns,Y.rows))},de=async()=>{if(!(!U||X)){Z(!0),$(null);try{let e=[],t=[],n=0,r=!1;for(;;){let i=await h.db.rows(U,T,n,o?.col,o?.dir,D??void 0);if(t=i.columns,e.push(...i.rows),n+=T,e.length>=E){r=!0;break}if(i.rows.length<T||n>=i.total)break}j(`${U}.csv`,`text/csv`,A(t,e));let i=r?`Exported the first ${d(e.length)} rows (export cap reached)`:`Exported ${d(e.length)} rows`;$(i),_.success(`Export of ${U} complete`,i)}catch(e){$(`Export failed: ${e.message}`),_.error(`Export of ${U} failed`,e.message)}finally{Z(!1)}}},fe=()=>{P(`SELECT * FROM "${U.replaceAll(`"`,`""`)}" LIMIT 100`),requestAnimationFrame(()=>{F.current?.focus(),F.current?.scrollIntoView({behavior:`smooth`,block:`center`})})},pe=!!Y?.truncatedCells.some(e=>e.some(Boolean));return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(p,{title:`Database`,description:`SQLite inspector — schema, data and queries over a read-only connection.`,actions:(0,C.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2.5 py-1 text-[11px] font-medium text-success`,children:`read-only`})}),R&&!V&&(0,C.jsx)(ee,{message:`Could not read the database — ${R.message}`,onRetry:ae}),H&&(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-5`,children:[(0,C.jsx)(m,{label:`SQLite`,value:H.sqliteVersion,compact:!0}),(0,C.jsx)(m,{label:`On disk`,value:g(H.fileSize+H.walSize),compact:!0}),(0,C.jsx)(m,{label:`Journal`,value:H.journalMode.toUpperCase(),compact:!0}),(0,C.jsx)(m,{label:`Tables`,value:d(H.tables),compact:!0}),(0,C.jsx)(m,{label:`Indexes`,value:d(H.indexes),compact:!0})]}),V?(0,C.jsx)(v,{title:`No database yet`,hint:R.message}):ie&&B.length===0?(0,C.jsx)(u,{label:`Reading database…`}):(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-4`,children:[(0,C.jsxs)(l,{padded:!1,className:`self-start overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-4 py-3 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Tables (`,B.length,`)`]}),(0,C.jsxs)(`ul`,{className:`max-h-[28rem] overflow-y-auto`,children:[B.map(e=>(0,C.jsx)(`li`,{children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>ce(e.name),className:t(`flex w-full items-center justify-between gap-2 px-4 py-2 text-left text-sm transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,U===e.name?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:[(0,C.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.name}),(0,C.jsx)(`span`,{className:`shrink-0 text-[11px] text-faint tabular-nums`,children:d(e.rows)})]})},e.name)),B.length===0&&(0,C.jsx)(`li`,{className:`px-4 py-6 text-center text-xs text-faint`,children:`No tables.`})]})]}),(0,C.jsx)(`div`,{className:`min-w-0 lg:col-span-3`,children:B.length===0?(0,C.jsx)(v,{title:`No tables`,hint:`This database has no user tables yet.`}):(0,C.jsxs)(C.Fragment,{children:[U&&(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`mr-auto min-w-0 truncate font-mono text-sm text-fg`,title:U,children:U}),(0,C.jsx)(y,{size:`sm`,variant:`ghost`,onClick:fe,children:`Query`}),(0,C.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:[`data`,`schema`].map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>b(e),"aria-pressed":c===e,className:t(`rounded-md px-3 py-1 text-xs font-medium capitalize transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,c===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:e},e))}),c===`data`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y,{size:`sm`,disabled:!Y||Y.rows.length===0,title:Y?`Exports the ${Y.rows.length} rows on this page only`:void 0,onClick:ue,children:[`Export page`,Y?` (${Y.rows.length})`:``]}),(0,C.jsx)(y,{size:`sm`,variant:`accent`,disabled:X||!Y||Y.total===0,onClick:de,children:X?`Exporting…`:`Export table${Y?` (${d(Y.total)})`:``}`})]})]}),c===`data`&&U&&(0,C.jsx)(z,{columns:Y?.columns??W?.columns.map(e=>e.name)??[],filter:D,onChange:e=>{O(e),a(0),M(null)}}),Q&&(0,C.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:Q}),c===`schema`?W?.table===U?(0,C.jsx)(ne,{schema:W}):(0,C.jsx)(u,{label:`Reading schema of ${U}…`}):q&&!Y?(0,C.jsx)(v,{title:`Could not read table`,hint:q.message}):J&&!Y&&K?.table!==U?(0,C.jsx)(u,{label:`Reading ${U}…`}):!Y&&!K?(0,C.jsx)(v,{title:`Select a table`,hint:`Pick a table on the left to browse its rows.`}):(Y??K)&&(Y??K)?.total===0?(0,C.jsx)(v,{title:D?`No matching rows`:`Empty table`,hint:D?`No rows match the current filter.`:`"${(Y??K)?.table}" has no rows.`}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(L,{columns:(Y??K)?.columns??[],rows:(Y??K)?.rows??[],truncatedCells:(Y??K)?.truncatedCells,colMeta:oe,sort:o,onSort:le,onRowClick:e=>M(e),dimmed:J&&!Y}),pe&&(0,C.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Cells over 2000 chars and BLOBs are abbreviated in the grid and CSV — click a row to view the full value.`}),(0,C.jsx)(x,{page:r,pageSize:w,total:(Y??K)?.total??0,onPageChange:e=>{a(e),M(null)},label:`rows`})]}),(0,C.jsx)(re,{sql:N,setSql:P,editorRef:F})]})})]}),Y&&k!=null&&Y.rows[k]&&(0,C.jsx)(te,{table:Y.table,columns:Y.columns,row:Y.rows[k],rowid:Y.rowids[k],truncated:Y.truncatedCells[k],onClose:()=>M(null)})]})}function z({columns:e,filter:t,onChange:n}){let[r,i]=(0,S.useState)(t?.column??``),[a,o]=(0,S.useState)(t?.op??`contains`),[c,l]=(0,S.useState)(t?.value??``),u=r||e[0]||``,d=()=>n(c.trim()?{column:u,op:a,value:c.trim()}:null);return e.length===0?null:(0,C.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`div`,{className:`w-40`,children:(0,C.jsx)(b,{value:u,"aria-label":`Filter column`,onChange:e=>i(e.target.value),children:e.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))})}),(0,C.jsx)(`div`,{className:`w-32`,children:(0,C.jsxs)(b,{value:a,"aria-label":`Filter operator`,onChange:e=>o(e.target.value),children:[(0,C.jsx)(`option`,{value:`contains`,children:`contains`}),(0,C.jsx)(`option`,{value:`eq`,children:`=`}),(0,C.jsx)(`option`,{value:`ne`,children:`≠`})]})}),(0,C.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,C.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,C.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&d(),"aria-label":`Filter value`,placeholder:`value — Enter to filter`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-8 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,C.jsx)(y,{size:`sm`,onClick:d,disabled:!c.trim(),children:`Filter`}),t&&(0,C.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>{l(``),n(null)},children:`Clear`}),(0,C.jsx)(`span`,{className:`text-[11px] text-faint`,children:`filters the whole table, server-side`})]})}function te({table:e,columns:t,row:n,rowid:r,truncated:i,onClose:a}){let[s,l]=(0,S.useState)({}),u=(0,S.useRef)(null);return(0,S.useEffect)(()=>{let e=e=>e.key===`Escape`&&a();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,S.useEffect)(()=>{let e=document.activeElement;return u.current?.focus(),()=>{e?.isConnected&&e.focus()}},[]),(0,S.useEffect)(()=>{if(r==null)return;let n=!1;return(async()=>{for(let a=0;a<t.length;a++)if(i[a])try{let i=await h.db.cell(e,r,t[a]);n||l(e=>({...e,[t[a]]:i.value}))}catch{}})(),()=>{n=!0}},[e,r,t,i]),(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`button`,{type:`button`,"aria-label":`Close row detail`,onClick:a,className:`fixed inset-0 z-40 bg-black/50`}),(0,C.jsxs)(`aside`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-label":`${e} row ${r??`detail`}`,tabIndex:-1,className:`fixed inset-y-0 right-0 z-50 flex w-full max-w-xl flex-col border-l border-line bg-surface shadow-xl focus-visible:outline-none`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-5 py-4`,children:[(0,C.jsxs)(`h2`,{className:`font-mono text-sm text-fg`,children:[e,` · row detail`]}),(0,C.jsx)(`button`,{type:`button`,"aria-label":`Close`,onClick:a,className:`flex size-8 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,C.jsx)(o,{className:`size-4`})})]}),(0,C.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:(0,C.jsx)(`dl`,{className:`flex flex-col gap-4`,children:t.map((e,t)=>{let r=e in s?s[e]:n[t],a=F(r),o=a.includes(`
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,t as r}from"./react-vendor-B68RYDeC.js";import{A as i,C as a,I as o,J as s,O as c,S as l,b as u,c as d,et as f,h as p,m,nt as h,r as g,rt as _,v,w as y,x as ee}from"./index-BFRKPhvf.js";import{a as b}from"./form-C-zZyKfB.js";import{t as x}from"./Pagination-EJ2HGoqv.js";var S=e(n(),1),C=r(),w=50,T=500,E=2e5,D=`bq-dash-db-history`,O=10;function k(e){let t=e==null?``:String(e),n=typeof e==`string`&&/^[=+\-@]/.test(e)?`'${e}`:t;return/[",\r\n]/.test(n)?`"${n.replaceAll(`"`,`""`)}"`:n}function A(e,t){return[e.map(k).join(`,`),...t.map(e=>e.map(k).join(`,`))].join(`
|
|
2
|
+
`)}function j(e,t,n){let r=URL.createObjectURL(new Blob([n],{type:t})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)}function M(){try{let e=JSON.parse(localStorage.getItem(D)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function N(e){try{localStorage.setItem(D,JSON.stringify(e))}catch{}return e}function P(e){return N([e,...M().filter(t=>t!==e)].slice(0,O))}function F(e){if(e==null)return`NULL`;let t=typeof e==`string`?e:String(e);try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function I({value:e,align:n}){if(e==null)return(0,C.jsx)(`span`,{className:`italic text-faint`,children:`NULL`});let r=typeof e==`string`?e:String(e);return(0,C.jsx)(`span`,{className:t(`block max-w-[24rem] truncate`,n===`right`&&`text-right tabular-nums`),title:r,children:r})}function L({columns:e,rows:n,truncatedCells:r,colMeta:i,sort:a,onSort:o,onRowClick:s,dimmed:c}){let l=(0,S.useMemo)(()=>e.map((e,t)=>{let r=i?.[e]?.type?.toUpperCase()??``;if(/INT|REAL|NUM|DEC|DOUB|FLOA/.test(r))return!0;let a=!1;for(let e of n){let n=e[t];if(n!=null&&(a=!0,typeof n!=`number`))return!1}return a}),[e,n,i]);return(0,C.jsx)(`div`,{className:t(`max-h-[70vh] overflow-auto rounded-xl border border-line bg-surface transition-opacity`,c&&`pointer-events-none opacity-50`),children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsx)(`tr`,{className:`text-left text-[11px] uppercase tracking-wider text-faint`,children:e.map((e,n)=>{let r=i?.[e];return(0,C.jsx)(`th`,{className:t(`sticky top-0 z-10 whitespace-nowrap border-b border-line bg-surface px-4 py-3 font-medium`,l[n]&&`text-right`),"aria-sort":a?.col===e?a.dir===`asc`?`ascending`:`descending`:o?`none`:void 0,children:o?(0,C.jsxs)(`button`,{type:`button`,onClick:()=>o(e),"aria-label":`Sort by ${e}`,className:`inline-flex items-center gap-1 uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[e,r?.primaryKey&&(0,C.jsx)(`span`,{className:`rounded bg-accent/15 px-1 py-0.5 text-[9px] font-semibold text-accent`,children:`PK`}),r?.type&&(0,C.jsx)(`span`,{className:`text-faint/70`,children:r.type.toLowerCase()}),(0,C.jsx)(`span`,{"aria-hidden":`true`,className:a?.col===e?`text-accent`:`text-faint/60`,children:a?.col===e?a.dir===`asc`?`▲`:`▼`:`↕`})]}):e},e)})})}),(0,C.jsx)(`tbody`,{children:n.map((e,n)=>(0,C.jsx)(`tr`,{onClick:s?()=>s(n):void 0,onKeyDown:s?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(n))}:void 0,tabIndex:s?0:void 0,className:t(`border-b border-line font-mono text-xs last:border-0 hover:bg-surface-2/40`,s&&`cursor-pointer`),children:e.map((e,t)=>(0,C.jsx)(`td`,{className:`whitespace-nowrap px-4 py-2 text-muted`,children:(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsx)(I,{value:e,align:l[t]?`right`:`left`}),r?.[n]?.[t]&&(0,C.jsx)(`span`,{title:`Value truncated — click the row to view it in full`,className:`shrink-0 rounded bg-warning/15 px-1 text-[9px] font-semibold text-warning`,children:`…`})]})},t))},n))})]})})}function R(){let[e,n]=(0,S.useState)(``),[r,a]=(0,S.useState)(0),[o,s]=(0,S.useState)(null),[c,b]=(0,S.useState)(`data`),[D,O]=(0,S.useState)(null),[k,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(`SELECT name FROM sqlite_master WHERE type = 'table'`),F=(0,S.useRef)(null),{data:I,error:R,loading:ie,refetch:ae}=i(()=>h.db.tables(),[],{intervalMs:1e4}),B=(0,S.useMemo)(()=>I?.tables??[],[I]),V=R instanceof f&&R.status===404,{data:H}=i(()=>V?Promise.resolve(null):h.db.info(),[V],{intervalMs:15e3}),U=e||B[0]?.name||``;(0,S.useEffect)(()=>{!e&&B[0]&&n(B[0].name)},[e,B]);let{data:W}=i(()=>U?h.db.schema(U):Promise.resolve(null),[U],{intervalMs:3e4}),oe=(0,S.useMemo)(()=>{let e={};if(W?.table===U)for(let t of W.columns)e[t.name]={type:t.type,primaryKey:t.primaryKey};return e},[W,U]),G=D?`${D.column}|${D.op}|${D.value}`:``,{data:K,error:q,loading:J}=i((0,S.useCallback)(async()=>U?{...await h.db.rows(U,w,r*w,o?.col,o?.dir,D??void 0),page:r,filterKey:G}:null,[U,r,o,D,G]),[U,r,o,G],{intervalMs:6e3}),Y=K&&K.table===U&&K.page===r&&K.orderBy===(o?.col??null)&&(!o||K.dir===o.dir)&&K.filterKey===G?K:null;(0,S.useEffect)(()=>{Y&&Y.total>0&&Y.rows.length===0&&r>0&&a(Math.max(0,Math.ceil(Y.total/w)-1))},[Y,r]);let[X,Z]=(0,S.useState)(!1),[Q,$]=(0,S.useState)(null),se=()=>{a(0),s(null),O(null),M(null)},ce=e=>{n(e),b(`data`),se()},le=e=>{a(0),M(null),s(t=>t?.col===e?t.dir===`asc`?{col:e,dir:`desc`}:null:{col:e,dir:`asc`})},ue=()=>{Y&&j(`${Y.table}-page${r+1}.csv`,`text/csv`,A(Y.columns,Y.rows))},de=async()=>{if(!(!U||X)){Z(!0),$(null);try{let e=[],t=[],n=0,r=!1;for(;;){let i=await h.db.rows(U,T,n,o?.col,o?.dir,D??void 0);if(t=i.columns,e.push(...i.rows),n+=T,e.length>=E){r=!0;break}if(i.rows.length<T||n>=i.total)break}j(`${U}.csv`,`text/csv`,A(t,e));let i=r?`Exported the first ${d(e.length)} rows (export cap reached)`:`Exported ${d(e.length)} rows`;$(i),_.success(`Export of ${U} complete`,i)}catch(e){$(`Export failed: ${e.message}`),_.error(`Export of ${U} failed`,e.message)}finally{Z(!1)}}},fe=()=>{P(`SELECT * FROM "${U.replaceAll(`"`,`""`)}" LIMIT 100`),requestAnimationFrame(()=>{F.current?.focus(),F.current?.scrollIntoView({behavior:`smooth`,block:`center`})})},pe=!!Y?.truncatedCells.some(e=>e.some(Boolean));return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(p,{title:`Database`,description:`SQLite inspector — schema, data and queries over a read-only connection.`,actions:(0,C.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2.5 py-1 text-[11px] font-medium text-success`,children:`read-only`})}),R&&!V&&(0,C.jsx)(ee,{message:`Could not read the database — ${R.message}`,onRetry:ae}),H&&(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-5`,children:[(0,C.jsx)(m,{label:`SQLite`,value:H.sqliteVersion,compact:!0}),(0,C.jsx)(m,{label:`On disk`,value:g(H.fileSize+H.walSize),compact:!0}),(0,C.jsx)(m,{label:`Journal`,value:H.journalMode.toUpperCase(),compact:!0}),(0,C.jsx)(m,{label:`Tables`,value:d(H.tables),compact:!0}),(0,C.jsx)(m,{label:`Indexes`,value:d(H.indexes),compact:!0})]}),V?(0,C.jsx)(v,{title:`No database yet`,hint:R.message}):ie&&B.length===0?(0,C.jsx)(u,{label:`Reading database…`}):(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-4`,children:[(0,C.jsxs)(l,{padded:!1,className:`self-start overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-4 py-3 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Tables (`,B.length,`)`]}),(0,C.jsxs)(`ul`,{className:`max-h-[28rem] overflow-y-auto`,children:[B.map(e=>(0,C.jsx)(`li`,{children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>ce(e.name),className:t(`flex w-full items-center justify-between gap-2 px-4 py-2 text-left text-sm transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,U===e.name?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:[(0,C.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:e.name}),(0,C.jsx)(`span`,{className:`shrink-0 text-[11px] text-faint tabular-nums`,children:d(e.rows)})]})},e.name)),B.length===0&&(0,C.jsx)(`li`,{className:`px-4 py-6 text-center text-xs text-faint`,children:`No tables.`})]})]}),(0,C.jsx)(`div`,{className:`min-w-0 lg:col-span-3`,children:B.length===0?(0,C.jsx)(v,{title:`No tables`,hint:`This database has no user tables yet.`}):(0,C.jsxs)(C.Fragment,{children:[U&&(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`mr-auto min-w-0 truncate font-mono text-sm text-fg`,title:U,children:U}),(0,C.jsx)(y,{size:`sm`,variant:`ghost`,onClick:fe,children:`Query`}),(0,C.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-lg border border-line bg-surface p-1`,children:[`data`,`schema`].map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>b(e),"aria-pressed":c===e,className:t(`rounded-md px-3 py-1 text-xs font-medium capitalize transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,c===e?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:e},e))}),c===`data`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y,{size:`sm`,disabled:!Y||Y.rows.length===0,title:Y?`Exports the ${Y.rows.length} rows on this page only`:void 0,onClick:ue,children:[`Export page`,Y?` (${Y.rows.length})`:``]}),(0,C.jsx)(y,{size:`sm`,variant:`accent`,disabled:X||!Y||Y.total===0,onClick:de,children:X?`Exporting…`:`Export table${Y?` (${d(Y.total)})`:``}`})]})]}),c===`data`&&U&&(0,C.jsx)(z,{columns:Y?.columns??W?.columns.map(e=>e.name)??[],filter:D,onChange:e=>{O(e),a(0),M(null)}},U),Q&&(0,C.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:Q}),c===`schema`?W?.table===U?(0,C.jsx)(ne,{schema:W}):(0,C.jsx)(u,{label:`Reading schema of ${U}…`}):q&&!Y?(0,C.jsx)(v,{title:`Could not read table`,hint:q.message}):J&&!Y&&K?.table!==U?(0,C.jsx)(u,{label:`Reading ${U}…`}):!Y&&!K?(0,C.jsx)(v,{title:`Select a table`,hint:`Pick a table on the left to browse its rows.`}):(Y??K)&&(Y??K)?.total===0?(0,C.jsx)(v,{title:D?`No matching rows`:`Empty table`,hint:D?`No rows match the current filter.`:`"${(Y??K)?.table}" has no rows.`}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(L,{columns:(Y??K)?.columns??[],rows:(Y??K)?.rows??[],truncatedCells:(Y??K)?.truncatedCells,colMeta:oe,sort:o,onSort:le,onRowClick:e=>M(e),dimmed:J&&!Y}),pe&&(0,C.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Cells over 2000 chars and BLOBs are abbreviated in the grid and CSV — click a row to view the full value.`}),(0,C.jsx)(x,{page:r,pageSize:w,total:(Y??K)?.total??0,onPageChange:e=>{a(e),M(null)},label:`rows`})]}),(0,C.jsx)(re,{sql:N,setSql:P,editorRef:F})]})})]}),Y&&k!=null&&Y.rows[k]&&(0,C.jsx)(te,{table:Y.table,columns:Y.columns,row:Y.rows[k],rowid:Y.rowids[k],truncated:Y.truncatedCells[k],onClose:()=>M(null)})]})}function z({columns:e,filter:t,onChange:n}){let[r,i]=(0,S.useState)(t?.column??``),[a,o]=(0,S.useState)(t?.op??`contains`),[c,l]=(0,S.useState)(t?.value??``),u=r||e[0]||``,d=()=>n(c.trim()?{column:u,op:a,value:c.trim()}:null);return e.length===0?null:(0,C.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`div`,{className:`w-40`,children:(0,C.jsx)(b,{value:u,"aria-label":`Filter column`,onChange:e=>i(e.target.value),children:e.map(e=>(0,C.jsx)(`option`,{value:e,children:e},e))})}),(0,C.jsx)(`div`,{className:`w-32`,children:(0,C.jsxs)(b,{value:a,"aria-label":`Filter operator`,onChange:e=>o(e.target.value),children:[(0,C.jsx)(`option`,{value:`contains`,children:`contains`}),(0,C.jsx)(`option`,{value:`eq`,children:`=`}),(0,C.jsx)(`option`,{value:`ne`,children:`≠`})]})}),(0,C.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,C.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,C.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&d(),"aria-label":`Filter value`,placeholder:`value — Enter to filter`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-8 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,C.jsx)(y,{size:`sm`,onClick:d,disabled:!c.trim(),children:`Filter`}),t&&(0,C.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>{l(``),n(null)},children:`Clear`}),(0,C.jsx)(`span`,{className:`text-[11px] text-faint`,children:`filters the whole table, server-side`})]})}function te({table:e,columns:t,row:n,rowid:r,truncated:i,onClose:a}){let[s,l]=(0,S.useState)({}),u=(0,S.useRef)(null);(0,S.useEffect)(()=>{let e=e=>e.key===`Escape`&&a();return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,S.useEffect)(()=>{let e=document.activeElement;return u.current?.focus(),()=>{e?.isConnected&&e.focus()}},[]);let d=t.filter((e,t)=>i[t]).join(``);return(0,S.useEffect)(()=>{if(r==null||!d)return;let t=d.split(``),n=!1;return(async()=>{for(let i of t)try{let t=await h.db.cell(e,r,i);n||l(e=>({...e,[i]:t.value}))}catch{}})(),()=>{n=!0}},[e,r,d]),(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`button`,{type:`button`,"aria-label":`Close row detail`,onClick:a,className:`fixed inset-0 z-40 bg-black/50`}),(0,C.jsxs)(`aside`,{ref:u,role:`dialog`,"aria-modal":`true`,"aria-label":`${e} row ${r??`detail`}`,tabIndex:-1,className:`fixed inset-y-0 right-0 z-50 flex w-full max-w-xl flex-col border-l border-line bg-surface shadow-xl focus-visible:outline-none`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between border-b border-line px-5 py-4`,children:[(0,C.jsxs)(`h2`,{className:`font-mono text-sm text-fg`,children:[e,` · row detail`]}),(0,C.jsx)(`button`,{type:`button`,"aria-label":`Close`,onClick:a,className:`flex size-8 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,C.jsx)(o,{className:`size-4`})})]}),(0,C.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5`,children:(0,C.jsx)(`dl`,{className:`flex flex-col gap-4`,children:t.map((e,t)=>{let r=e in s?s[e]:n[t],a=F(r),o=a.includes(`
|
|
3
3
|
`)||a.length>80;return(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`dt`,{className:`mb-1 flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-faint`,children:[e,r!=null&&(0,C.jsx)(c,{value:String(r)}),i[t]&&!(e in s)&&(0,C.jsx)(`span`,{className:`text-warning`,children:`(loading full value…)`})]}),(0,C.jsx)(`dd`,{children:r==null?(0,C.jsx)(`span`,{className:`italic text-faint`,children:`NULL`}):o?(0,C.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:a}):(0,C.jsx)(`span`,{className:`break-words font-mono text-sm text-fg`,children:a})})]},e)})})})]})]})}function ne({schema:e}){return(0,C.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,C.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Column`}),(0,C.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Type`}),(0,C.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Constraints`}),(0,C.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:`Default`})]})}),(0,C.jsx)(`tbody`,{children:e.columns.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-fg`,children:e.name}),(0,C.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-muted`,children:e.type}),(0,C.jsxs)(`td`,{className:`px-4 py-2 text-xs`,children:[e.primaryKey&&(0,C.jsx)(`span`,{className:`mr-1 rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold text-accent`,children:`PK`}),e.notNull&&(0,C.jsx)(`span`,{className:`rounded-md bg-surface-2 px-1.5 py-0.5 text-[10px] font-semibold text-muted`,children:`NOT NULL`})]}),(0,C.jsx)(`td`,{className:`px-4 py-2 font-mono text-xs text-faint`,children:e.defaultValue??`—`})]},e.name))})]})}),(0,C.jsxs)(l,{children:[(0,C.jsx)(a,{title:`Indexes (${e.indexes.length})`}),e.indexes.length===0?(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`No indexes on this table.`}):(0,C.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.indexes.map(e=>(0,C.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 font-mono text-xs`,children:[(0,C.jsx)(`span`,{className:`text-fg`,children:e.name}),e.unique&&(0,C.jsx)(`span`,{className:`rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold text-accent`,children:`UNIQUE`}),(0,C.jsxs)(`span`,{className:`text-faint`,children:[`(`,e.columns.join(`, `),`)`]})]},e.name))})]}),e.sql&&(0,C.jsxs)(l,{children:[(0,C.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,C.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`DDL`}),(0,C.jsx)(c,{value:e.sql})]}),(0,C.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:e.sql})]})]})}function re({sql:e,setSql:t,editorRef:n}){let[r,i]=(0,S.useState)(!1),[o,s]=(0,S.useState)(null),[c,u]=(0,S.useState)(M),[f,p]=(0,S.useState)(null),m=(0,S.useRef)(0);(0,S.useEffect)(()=>()=>{m.current++},[]);let g=async(t=e,n=!0)=>{if(!t.trim()||r)return;let a=++m.current;i(!0),s(null);try{let r=await h.db.query(t);if(a!==m.current)return;p(r),n&&u(P(e.trim()))}catch(e){if(a!==m.current)return;p(null),s(e.message)}finally{a===m.current&&i(!1)}};return(0,C.jsxs)(l,{className:`mt-6`,children:[(0,C.jsx)(a,{title:`Query`,action:(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(y,{size:`sm`,disabled:r||!e.trim(),onClick:()=>{let t=e.trim();t&&g(`EXPLAIN QUERY PLAN ${t}`,!1)},children:`Explain`}),(0,C.jsx)(y,{size:`sm`,variant:`accent`,disabled:r||!e.trim(),onClick:()=>g(),children:r?`Running…`:`Run`})]})}),(0,C.jsx)(`textarea`,{ref:n,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&g()},rows:3,spellCheck:!1,"aria-label":`SQL query`,placeholder:`SELECT … — read-only: writes are rejected by the engine`,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,C.jsx)(`p`,{className:`mt-1 text-[11px] text-faint`,children:`⌘/Ctrl+Enter runs. Connection is read-only.`}),c.length>0&&(0,C.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`History`}),c.map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>t(e),title:e,className:`max-w-56 truncate rounded-md border border-line bg-surface-2 px-2 py-1 font-mono text-[11px] text-muted transition-colors hover:border-line-strong hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e},e)),(0,C.jsx)(`button`,{type:`button`,onClick:()=>{N([]),u([])},className:`rounded-md px-2 py-1 text-[11px] text-faint transition-colors hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Clear`})]}),(0,C.jsxs)(`div`,{"aria-live":`polite`,children:[o&&(0,C.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:o}),f&&!o&&(0,C.jsxs)(`div`,{className:`mt-4`,children:[(0,C.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-3`,children:[(0,C.jsxs)(`p`,{className:`text-xs text-faint`,children:[f.truncated?`≥ `:``,d(f.rowCount),` row`,f.rowCount===1?``:`s`,` ·`,` `,d(f.ms),` ms`,f.truncated&&(0,C.jsxs)(`span`,{className:`text-warning`,children:[` — showing first `,f.rows.length]})]}),f.rows.length>0&&(0,C.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,C.jsx)(y,{size:`sm`,onClick:()=>j(`query-results.csv`,`text/csv`,A(f.columns,f.rows)),children:`CSV`}),(0,C.jsx)(y,{size:`sm`,onClick:()=>j(`query-results.json`,`application/json`,JSON.stringify(f.rows.map(e=>Object.fromEntries(f.columns.map((t,n)=>[t,e[n]]))),null,2)),children:`JSON`})]})]}),f.rows.length>0?(0,C.jsx)(L,{columns:f.columns,rows:f.rows}):(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Query returned no rows.`})]})]})]})}export{R as Database};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-B68RYDeC.js";import{A as r,C as i,O as a,S as o,b as s,c,d as l,h as u,m as d,nt as f,r as p,rt as m,w as h,x as g}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-B68RYDeC.js";import{A as r,C as i,O as a,S as o,b as s,c,d as l,h as u,m as d,nt as f,r as p,rt as m,w as h,x as g}from"./index-BFRKPhvf.js";var _=e(t(),1),v=n(),y={health:{},storage:null,stats:null};function b(){let{data:e,error:t,loading:n,refetch:b}=r(async()=>{let[e,t,n]=await Promise.all([f.health(),f.storage().catch(()=>null),f.stats().catch(()=>null)]);return{health:e,storage:t,stats:n}},[]),[C,w]=(0,_.useState)(null),T=async()=>{w(`…`);let e=performance.now();try{await f.ping(),w(`${Math.round(performance.now()-e)} ms`)}catch{w(`unreachable`)}},[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(null),A=async()=>{D(!0),k(null);try{let e=await f.gc(),t=e.before.rss-e.after.rss,n=t>0?`Freed ${t} MB (RSS ${e.before.rss}→${e.after.rss})`:`No memory reclaimed`;k(n),m.success(`Memory compacted`,n),b()}catch(e){m.error(`GC failed`,e.message),k(e.message)}finally{D(!1)}},[j,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(!1),F=async()=>{P(!0);try{M(await f.heapStats())}catch(e){m.error(`Heap stats failed`,e.message)}finally{P(!1)}};if(n&&!e&&!t)return(0,v.jsx)(s,{label:`Loading diagnostics…`});let I=e??y,L=I.health,R=I.storage?.data,z=I.stats?.stats;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(u,{title:`Diagnostics`,description:`Server health, storage, memory and connections.`,live:!t}),t&&(0,v.jsx)(g,{onRetry:b}),(0,v.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,v.jsx)(d,{label:`Status`,value:L.status??(L.ok?`healthy`:`degraded`),tone:L.ok?`green`:`red`,compact:!0}),(0,v.jsx)(d,{label:`Version`,value:L.version?`v${L.version}`:`—`,compact:!0}),(0,v.jsx)(d,{label:`Uptime`,value:l(L.uptime),compact:!0}),(0,v.jsx)(d,{label:`Disk`,value:R?.diskFull?`Full`:`Healthy`,tone:R?.diskFull?`red`:`green`,compact:!0})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,v.jsxs)(o,{children:[(0,v.jsx)(i,{title:`Connectivity`,action:(0,v.jsxs)(h,{size:`sm`,onClick:T,children:[`Ping`,C?` · ${C}`:``]})}),(0,v.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,v.jsx)(x,{k:`WebSocket clients`,v:String(L.connections?.ws??0)}),(0,v.jsx)(x,{k:`SSE clients`,v:String(L.connections?.sse??0)}),(0,v.jsx)(x,{k:`Storage error`,v:R?.error?String(R.error):`none`})]})]}),(0,v.jsxs)(o,{children:[(0,v.jsx)(i,{title:`Memory`,action:(0,v.jsx)(h,{size:`sm`,disabled:E,onClick:A,children:E?`Compacting…`:`Compact (GC)`})}),(0,v.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,v.jsx)(S,{k:`Heap used`,v:p((L.memory?.heapUsed??0)*1024*1024)}),(0,v.jsx)(S,{k:`Heap total`,v:p((L.memory?.heapTotal??0)*1024*1024)}),(0,v.jsx)(S,{k:`RSS`,v:p((L.memory?.rss??0)*1024*1024)})]}),O&&(0,v.jsx)(`p`,{className:`mt-3 text-xs text-muted`,children:O})]})]}),(0,v.jsxs)(o,{className:`mt-6`,children:[(0,v.jsx)(i,{title:`Heap statistics`,action:(0,v.jsx)(h,{size:`sm`,disabled:N,onClick:F,children:N?`Loading…`:j?`Refresh`:`Load`})}),j?(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,v.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,v.jsx)(S,{k:`Objects`,v:c(j.heap?.objectCount??0)}),(0,v.jsx)(S,{k:`Protected`,v:c(j.heap?.protectedCount??0)}),(0,v.jsx)(S,{k:`Global`,v:c(j.heap?.globalCount??0)})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wider text-faint`,children:`Top object types`}),(0,v.jsx)(`div`,{className:`max-h-52 overflow-y-auto rounded-lg border border-line`,children:(0,v.jsx)(`table`,{className:`w-full text-xs`,children:(0,v.jsx)(`tbody`,{children:(j.topObjectTypes??[]).map(e=>(0,v.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,v.jsx)(`td`,{className:`px-3 py-1.5 font-mono text-muted`,children:e.type}),(0,v.jsx)(`td`,{className:`px-3 py-1.5 text-right tnum text-fg`,children:c(e.count)})]},e.type))})})})]})]}):(0,v.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On-demand `,(0,v.jsx)(`code`,{className:`font-mono text-xs`,children:`bun:jsc`}),` heap breakdown (forces a GC first). Use it to spot which internal object type is growing when chasing a leak.`]})]}),(0,v.jsxs)(o,{className:`mt-6`,children:[(0,v.jsx)(i,{title:`Prometheus`}),(0,v.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Scrape endpoint (text exposition) for Grafana / Alertmanager. Auth is required only if the server sets `,(0,v.jsx)(`code`,{className:`font-mono text-xs`,children:`requireAuthForMetrics`}),`.`]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-line bg-surface-2 px-3 py-2`,children:[(0,v.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-fg`,children:f.prometheusUrl()}),(0,v.jsx)(a,{value:f.prometheusUrl()})]})]}),z&&(0,v.jsxs)(o,{className:`mt-6`,children:[(0,v.jsx)(i,{title:`Totals since restart`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,v.jsx)(S,{k:`Pushed`,v:c(z.totalPushed)}),(0,v.jsx)(S,{k:`Pulled`,v:c(z.totalPulled)}),(0,v.jsx)(S,{k:`Completed`,v:c(z.totalCompleted)}),(0,v.jsx)(S,{k:`Failed`,v:c(z.totalFailed)})]})]})]})}function x({k:e,v:t}){return(0,v.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,v.jsx)(`dt`,{className:`text-muted`,children:e}),(0,v.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}function S({k:e,v:t}){return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,v.jsx)(`div`,{className:`mt-1 text-lg font-semibold tnum text-fg`,children:t})]})}export{b as Diagnostics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-B68RYDeC.js";import{A as r,R as i,b as a,c as o,h as s,j as c,m as l,u,v as d,w as f,x as p}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-B68RYDeC.js";import{A as r,R as i,b as a,c as o,h as s,j as c,m as l,u,v as d,w as f,x as p}from"./index-BFRKPhvf.js";import{a as m}from"./form-C-zZyKfB.js";import{t as h}from"./Pagination-EJ2HGoqv.js";var g=e(t(),1),_=n(),v=25;function y(){let[e,t]=(0,g.useState)(``),[n,y]=(0,g.useState)(0),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(null),{data:w}=r(()=>c.queues(500),[],{intervalMs:3e4});(0,g.useEffect)(()=>{e||!w?.queues?.length||t((w.queues.find(e=>e.dlq>0)??w.queues[0]).name)},[w,e]);let{data:T,error:E,loading:D,refetch:O}=r((0,g.useCallback)(async()=>{if(!e)return{entries:[],total:0};let t=await c.dlq(e,v,n*v);return{entries:t.entries??[],total:t.total??t.entries?.length??0}},[e,n]),[e,n]),k=async(t,n)=>{if(window.confirm(`${t} the dead letter queue for "${e}"?`)){x(!0),C(null);try{await n(),C(`${t} done`),O()}catch(e){C(e.message)}finally{x(!1)}}},A=T?.entries??[];return(0,_.jsxs)(`div`,{children:[E&&(0,_.jsx)(p,{onRetry:O}),(0,_.jsx)(s,{title:`Dead Letter Queue`,description:`Jobs that exhausted their retries.`,live:!0,actions:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(f,{size:`sm`,disabled:!e||b,onClick:()=>k(`Retry`,()=>c.retryDlq(e)),children:`Retry all`}),(0,_.jsx)(f,{variant:`danger`,size:`sm`,disabled:!e||b,onClick:()=>k(`Purge`,()=>c.purgeDlq(e)),children:`Purge`})]})}),(0,_.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`w-56`,children:(0,_.jsx)(m,{value:e,onChange:e=>{t(e.target.value),y(0)},children:(w?.queues??[]).map(e=>(0,_.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,_.jsx)(`div`,{className:`w-40`,children:(0,_.jsx)(l,{label:`DLQ Entries`,value:o(T?.total),tone:T?.total?`red`:`default`,compact:!0})}),S&&(0,_.jsx)(`span`,{className:`text-xs text-muted`,children:S})]}),D&&!T&&!E?(0,_.jsx)(a,{label:`Loading DLQ…`}):A.length===0?(0,_.jsx)(d,{icon:(0,_.jsx)(i,{}),title:`Dead letter queue is empty`,hint:`Jobs land here after exhausting their retry attempts.`}):(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Reason`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,_.jsx)(`tbody`,{children:A.map((e,t)=>(0,_.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.jobId??e.id}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,_.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-red-400/90`,children:String(e.reason||e.error||`—`)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:Array.isArray(e.attempts)?e.attempts.length:e.attempts??`—`}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.failedAt??e.enteredAt)})]},e.jobId??e.id??t))})]})}),T&&(0,_.jsx)(h,{page:n,pageSize:v,total:T.total,onPageChange:y,label:`entries`})]})}export{y as Dlq};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{h as n,r,t as i}from"./react-vendor-B68RYDeC.js";import{A as a,B as o,F as s,J as c,K as l,O as u,R as d,T as f,a as p,b as m,c as h,h as g,m as _,nt as v,o as y,rt as b,u as x,v as S,w as C,x as w,z as T}from"./index-BFRKPhvf.js";import{a as E}from"./form-C-zZyKfB.js";import{t as D}from"./Pagination-EJ2HGoqv.js";import{t as O}from"./exportFile-tdUeW5m5.js";var k=e(n(),1),A=i(),j=25,M=e=>`${e.job.id}-${e.enteredAt}`;function N(){let[e,t]=(0,k.useState)(``),[n,r]=(0,k.useState)(0),[i,o]=(0,k.useState)(`all`),[s,u]=(0,k.useState)(``),[f,p]=(0,k.useState)(new Set),[y,N]=(0,k.useState)(!1),[F,I]=(0,k.useState)(null),{data:L}=a(()=>v.queues(),[],{intervalMs:3e4});(0,k.useEffect)(()=>{e||!L?.queues?.length||t((L.queues.find(e=>e.dlq>0)??L.queues[0]).name)},[L,e]);let{data:R,error:z,loading:B,refetch:V}=a((0,k.useCallback)(async()=>{if(!e)return{queue:e,page:n,entries:[],total:0,stats:null};let[t,r]=await Promise.all([v.dlq(e,j,n*j),v.dlqStats(e).catch(()=>null)]);return{queue:e,page:n,entries:t.entries??[],total:t.total??0,stats:r?.stats??null}},[e,n]),[e,n]),H=R&&R.queue===e&&R.page===n?R:null;(0,k.useEffect)(()=>{if(!H)return;let e=Math.max(0,Math.ceil((H.total??0)/j)-1);n>e&&r(e)},[H,n]),(0,k.useEffect)(()=>{p(new Set)},[e,n]);let U=async(t,n,r)=>{if(!(r&&!window.confirm(r))){N(!0),I(null);try{let r=(await n())?.count??0,i=`${t} ${h(r)} ${r===1?`entry`:`entries`}`;I({ok:!0,text:i}),b.success(i,e),V()}catch(e){let n=e.message;I({ok:!1,text:n});let r=t===`Purged`?`Purge`:`Retry`;b.error(`${r} failed`,n)}finally{N(!1)}}},W=H?.stats?.byReason??{},G=(0,k.useMemo)(()=>Object.keys(W).filter(e=>W[e]>0),[W]),K=(0,k.useMemo)(()=>[...G].sort((e,t)=>(W[t]??0)-(W[e]??0))[0],[G,W]),q=H?.entries??[],J=(0,k.useMemo)(()=>{let e=q;i!==`all`&&(e=e.filter(e=>e.reason===i));let t=s.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>t.enteredAt-e.enteredAt)},[q,i,s]),Y=i!==`all`||s.trim()!==``,X=(H?.total??0)>j,Z=e=>p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(g,{title:`DLQ Control`,description:`Inspect, triage, and replay one queue's dead-lettered jobs.`,live:!0,actions:(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(C,{size:`sm`,disabled:!e||!J.length,onClick:()=>{if(J.length===0){b.info(`Nothing to export`);return}O(`dlq-${e}`,J.map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,attempts:e.job.attempts??e.attempts?.length??``,enteredAt:new Date(e.enteredAt).toISOString()})),[`jobId`,`reason`,`error`,`attempts`,`enteredAt`])},children:[(0,A.jsx)(T,{className:`size-3.5`}),` Export`]}),(0,A.jsxs)(C,{size:`sm`,disabled:!e||y||!H?.total,onClick:()=>U(`Retried`,()=>v.retryDlq(e),`Retry all ${H?.total??0} DLQ entries for "${e}"?`),children:[(0,A.jsx)(l,{className:`size-3.5`}),` Retry all`]}),(0,A.jsx)(C,{variant:`danger`,size:`sm`,disabled:!e||y||!H?.total,onClick:()=>{let t=window.prompt(`Purge all ${H?.total??0} DLQ entries for "${e}"? This cannot be undone.\n\nType the queue name to confirm:`);if(t!=null){if(t.trim()!==e){I({ok:!1,text:`Purge cancelled — queue name did not match.`});return}U(`Purged`,()=>v.purgeDlq(e))}},children:`Purge`})]})}),z&&(0,A.jsx)(w,{onRetry:V}),(0,A.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,A.jsx)(_,{label:`Entries`,value:h(H?.total),tone:H?.total?`red`:`green`,hint:H?.total?K?`top: ${K}`:void 0:`queue is clean`,compact:!0}),(0,A.jsx)(_,{label:`Failure types`,value:H?.stats?h(G.length):`—`,hint:`distinct reasons`,compact:!0}),(0,A.jsx)(_,{label:`Pending retry`,value:H?.stats?h(H.stats.pendingRetry??0):`—`,tone:H?.stats?.pendingRetry?`amber`:`default`,hint:`auto-retry queued`,compact:!0}),(0,A.jsx)(_,{label:`Oldest entry`,value:H?.stats?.oldestEntry?x(H.stats.oldestEntry):`—`,hint:`time in DLQ`,compact:!0})]}),(0,A.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`w-56`,children:(0,A.jsx)(E,{value:e,"aria-label":`Queue`,onChange:e=>{t(e.target.value),r(0),o(`all`),u(``),I(null)},children:(L?.queues??[]).map(e=>(0,A.jsxs)(`option`,{value:e.name,children:[e.name,` `,e.dlq?`(${e.dlq})`:``]},e.name))})}),(0,A.jsx)(`div`,{className:`w-44`,children:(0,A.jsxs)(E,{value:i,"aria-label":`Filter by reason`,onChange:e=>o(e.target.value),children:[(0,A.jsx)(`option`,{value:`all`,children:`All reasons`}),G.map(e=>(0,A.jsxs)(`option`,{value:e,children:[e,` (`,W[e],`)`]},e))]})}),(0,A.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,A.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,A.jsx)(`input`,{value:s,onChange:e=>u(e.target.value),placeholder:X?`Filter this page by job ID…`:`Filter by job ID…`,"aria-label":`Filter by job ID`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),F&&(0,A.jsx)(`span`,{role:`status`,className:F.ok?`text-sm text-success`:`text-sm text-danger`,children:F.text})]}),B&&!H&&!z?(0,A.jsx)(m,{label:`Loading DLQ…`}):J.length===0?(0,A.jsx)(S,{icon:(0,A.jsx)(d,{}),title:Y?`No matches`:`Dead letter queue is empty`,hint:Y?X?`No entries on this page match your filter — filters are page-scoped. Try another page or clear them.`:`No entries match your filter. Clear it to see all entries.`:`Failed jobs that exhaust their retries land here.`}):(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,A.jsx)(`th`,{className:`w-8 py-3 pl-4`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Job ID`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Reason`}),(0,A.jsx)(`th`,{className:`px-3 py-3 font-medium`,children:`Error`}),(0,A.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Attempts`}),(0,A.jsx)(`th`,{className:`px-3 py-3 text-right font-medium`,children:`Entered`}),(0,A.jsx)(`th`,{className:`w-20 px-4 py-3`})]})}),(0,A.jsx)(`tbody`,{children:J.map(t=>{let n=M(t);return(0,A.jsx)(P,{entry:t,isOpen:f.has(n),busy:y,onToggle:()=>Z(n),onRetry:()=>U(`Retried`,()=>v.retryDlq(e,t.job.id),`Retry job ${t.job.id.slice(0,8)}… from "${e}"?`),attempts:t.attempts??[]},n)})})]})}),H&&(0,A.jsx)(D,{page:n,pageSize:j,total:H.total,onPageChange:r,label:`entries`})]})}function P({entry:e,isOpen:n,busy:i,onToggle:a,onRetry:c,attempts:d}){let m=e;return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`tr`,{className:`border-b border-line align-top last:border-0 hover:bg-surface-2/40`,children:[(0,A.jsx)(`td`,{className:`py-3 pl-4`,children:(0,A.jsx)(f,{"aria-label":n?`Collapse details`:`Expand details`,"aria-expanded":n,onClick:a,children:(0,A.jsx)(s,{className:t(`size-3.5 transition-transform`,n&&`rotate-90`)})})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(r,{to:`/job?id=${encodeURIComponent(m.job.id)}`,className:`max-w-[14rem] truncate font-mono text-xs text-accent hover:underline`,title:m.job.id,children:m.job.id}),(0,A.jsx)(u,{value:m.job.id})]})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsx)(`span`,{className:`inline-block rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:m.reason})}),(0,A.jsx)(`td`,{className:`px-3 py-3`,children:(0,A.jsx)(`span`,{className:`block max-w-md truncate text-xs text-danger/80`,title:m.error??``,children:m.error||`—`})}),(0,A.jsx)(`td`,{className:`px-3 py-3 text-right tnum text-muted`,children:m.job.attempts??d.length}),(0,A.jsx)(`td`,{className:`px-3 py-3 text-right text-faint`,title:p(m.enteredAt),children:x(m.enteredAt)}),(0,A.jsx)(`td`,{className:`px-4 py-3`,children:(0,A.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,A.jsx)(r,{to:`/job?id=${encodeURIComponent(m.job.id)}`,children:(0,A.jsx)(f,{"aria-label":`Inspect job`,children:(0,A.jsx)(o,{className:`size-3.5`})})}),(0,A.jsx)(f,{"aria-label":`Retry job`,disabled:i,onClick:c,children:(0,A.jsx)(l,{className:`size-3.5`})})]})})]}),n&&(0,A.jsxs)(`tr`,{className:`border-b border-line bg-surface-2/30 last:border-0`,children:[(0,A.jsx)(`td`,{}),(0,A.jsxs)(`td`,{colSpan:6,className:`px-3 pb-4 pt-1`,children:[m.error&&(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Error`}),(0,A.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap rounded-lg bg-surface p-3 font-mono text-xs text-danger/90`,children:m.error})]}),(0,A.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:[`Failure history`,typeof m.retryCount==`number`&&m.retryCount>0&&(0,A.jsxs)(`span`,{className:`rounded-full bg-surface px-2 py-0.5 text-[10px] normal-case text-muted`,children:[`retried `,m.retryCount,`×`]})]}),d.length===0?(0,A.jsx)(`p`,{className:`text-xs text-faint`,children:`No per-attempt history recorded.`}):(0,A.jsx)(`ol`,{className:`space-y-1.5`,children:d.map(e=>(0,A.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-0.5 rounded-lg border border-line bg-surface px-3 py-2 text-xs`,children:[(0,A.jsxs)(`span`,{className:`font-medium text-fg`,children:[`Attempt `,e.attempt]}),(0,A.jsx)(`span`,{className:`text-faint`,title:p(e.failedAt),children:x(e.failedAt)}),e.duration!=null&&(0,A.jsx)(`span`,{className:`tnum text-muted`,children:y(e.duration)}),e.reason&&(0,A.jsx)(`span`,{className:`rounded bg-red-500/10 px-1.5 text-danger`,children:e.reason}),e.error&&(0,A.jsx)(`span`,{className:`w-full truncate text-danger/70`,children:e.error})]},`${e.attempt}-${e.failedAt}`))})]})]})]})}export{N as DlqControl};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-B68RYDeC.js";import{A as o,K as s,R as c,S as l,T as u,b as ee,c as d,h as te,nt as f,rt as p,u as ne,v as m,w as h,x as re,z as g}from"./index-BxYFC0LS.js";import{a as _}from"./form-C-zZyKfB.js";import{t as ie}from"./Pagination-C_ycPjHn.js";import{t as v}from"./exportFile-tdUeW5m5.js";import{t as ae}from"./promisePool-Daxkc1OB.js";var y=e(r(),1),b=a(),oe=6,x=25;function S(){let[e,r]=n(),[a,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(`all`),[T,E]=(0,y.useState)(`newest`),[D,se]=(0,y.useState)(``),[O,k]=(0,y.useState)(0),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),[P,ce]=(0,y.useState)(new Set),{data:le,refetch:F}=o(()=>f.queues(),[],{intervalMs:1e4}),I=le?.queues??[],L=I.reduce((e,t)=>e+t.dlq,0),{data:R,error:z,loading:ue,refetch:B}=o((0,y.useCallback)(async()=>{if(!a)return{queue:a,page:O,entries:[],entriesTotal:0,stats:null};let[e,t]=await Promise.all([f.dlq(a,x,O*x),f.dlqStats(a).catch(()=>null)]);return{queue:a,page:O,entries:e.entries??[],entriesTotal:e.total??0,stats:t?.stats??null}},[a,O]),[a,O]),V=R&&R.queue===a&&R.page===O?R:null;(0,y.useEffect)(()=>{if(!V)return;let e=V.entriesTotal??0;O>0&&O*x>=e&&k(Math.max(0,Math.ceil(e/x)-1))},[V,O]);let H=async(e,t,n)=>{if(window.confirm(e)){j(!0),N(null);try{let e=(await n())?.count??0,r=`${t} ${d(e)} ${e===1?`entry`:`entries`}`;N({ok:!0,text:r}),p.success(r),B(),F()}catch(e){N({ok:!1,text:e.message}),p.error(`${t} failed`,e.message)}finally{j(!1)}}},U=async e=>{let t=q.map(e=>e.name);if(t.length===0||!window.confirm(`${e} the dead letter queue across ${t.length} queue(s) (${d(L)} entries)?`))return;j(!0),N(null);let n=await ae(t,oe,t=>e===`Retry`?f.retryDlq(t):f.purgeDlq(t)),r=0,i=0;for(let e of n)e.status===`fulfilled`?r+=e.value?.count??0:i++;let a=`${e===`Retry`?`Retried`:`Purged`} ${d(r)} across ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;N({ok:i===0,text:a}),i===0?p.success(a):p.error(a),B(),F(),j(!1)},de=()=>{let e=(V?.entries??[]).map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,enteredAt:new Date(e.enteredAt).toISOString(),attempts:e.attempts?.length??0}));if(e.length===0){p.info(`Nothing to export on this page`);return}v(`dlq-${a}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},W=e=>{J.current=!0,S(e),k(0),w(`all`),r(e?{queue:e}:{},{replace:!0})},G=V?.stats?.byReason??{},K=Object.keys(G).filter(e=>G[e]>0),fe=[...K].sort((e,t)=>(G[t]??0)-(G[e]??0))[0],q=(0,y.useMemo)(()=>I.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[I]),J=(0,y.useRef)(!1),Y=e.get(`queue`);(0,y.useEffect)(()=>{if(!(J.current||a)){if(Y){if(I.some(e=>e.name===Y)){J.current=!0,S(Y),k(0),w(`all`);return}if(I.length===0)return}q.length!==0&&(J.current=!0,S(q[0].name),k(0),w(`all`))}},[a,I,q,Y]);let X=(0,y.useMemo)(()=>{let e=V?.entries??[];C!==`all`&&(e=e.filter(e=>e.reason===C));let t=D.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>T===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[V,C,D,T]),Z=L===0,Q=C!==`all`||D.trim()!==``,$=(V?.entriesTotal??0)>x;return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(te,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Monitor, retry, or purge.`,live:!0}),z&&(0,b.jsx)(re,{onRetry:B}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsxs)(l,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,b.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Z?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:Z?`Healthy`:`Attention`})]}),(0,b.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,Z?`text-success`:`text-danger`),children:d(L)})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,b.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:a?fe??`No failures`:`Select a queue`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(V.stats.pendingRetry??0):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(K.length):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]}),q.length>0&&(0,b.jsxs)(l,{className:`mb-6`,children:[(0,b.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(h,{size:`sm`,disabled:A,onClick:()=>U(`Retry`),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry all (`,q.length,` queues)`]}),(0,b.jsxs)(h,{variant:`danger`,size:`sm`,disabled:A,onClick:()=>U(`Purge`),children:[`Purge all (`,q.length,` queues)`]})]})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:q.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>W(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,a===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,b.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,b.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:e.dlq})]},e.name))})]}),(0,b.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-48`,children:(0,b.jsxs)(_,{value:a,onChange:e=>W(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Select a queue…`}),I.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,b.jsx)(`div`,{className:`w-40`,children:(0,b.jsxs)(_,{value:C,onChange:e=>w(e.target.value),"aria-label":`Filter by reason`,children:[(0,b.jsx)(`option`,{value:`all`,children:`All Reasons`}),K.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]})}),(0,b.jsx)(`div`,{className:`w-36`,children:(0,b.jsxs)(_,{value:T,onChange:e=>E(e.target.value),"aria-label":$?`Sort this page`:`Sort`,children:[(0,b.jsxs)(`option`,{value:`newest`,children:[`Newest First`,$?` (this page)`:``]}),(0,b.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,$?` (this page)`:``]})]})}),(0,b.jsx)(`input`,{value:D,onChange:e=>se(e.target.value),placeholder:`Filter this page by job ID…`,"aria-label":`Filter this page by job ID`,className:`h-9 min-w-40 flex-1 rounded-lg border border-line bg-surface px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,b.jsxs)(h,{size:`sm`,disabled:!a||A,onClick:()=>H(`Retry all for "${a}"?`,`Retried`,()=>f.retryDlq(a)),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry All`]}),(0,b.jsx)(h,{variant:`danger`,size:`sm`,disabled:!a||A,onClick:()=>H(`Purge all for "${a}"?`,`Purged`,()=>f.purgeDlq(a)),children:`Purge All`}),(0,b.jsx)(u,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!a,onClick:de,children:(0,b.jsx)(g,{className:`size-3.5`})})]}),M&&(0,b.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),ue&&!V&&!z?(0,b.jsx)(ee,{label:`Loading DLQ…`}):a?X.length===0?(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),title:Q?`No matches on this page`:`No dead letter entries`,hint:Q?`No entries on this page match your filter — the filter is page-scoped. Use the pager below to check other pages.`:`This queue has no dead letter entries.`}):(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Reason`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Error`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,b.jsx)(`th`,{scope:`col`,className:`w-16 px-5 py-3`})]})}),(0,b.jsx)(`tbody`,{children:X.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,b.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,b.jsx)(`button`,{type:`button`,title:e.error,onClick:()=>ce(t=>{let n=new Set(t),r=`${e.job.id}-${e.enteredAt}`;return n.has(r)?n.delete(r):n.add(r),n}),className:t(`block w-full break-words text-left`,!P.has(`${e.job.id}-${e.enteredAt}`)&&`line-clamp-2`),children:e.error}):`—`}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:ne(e.enteredAt)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,b.jsx)(u,{"aria-label":`Retry`,disabled:A,onClick:()=>H(`Retry job ${e.job.id.slice(0,8)}… from "${a}"?`,`Retried`,()=>f.retryDlq(a,e.job.id)),children:(0,b.jsx)(s,{className:`size-3.5`})})})]},`${e.job.id}-${e.enteredAt}`))})]})}):(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),a&&V&&(0,b.jsx)(ie,{page:O,pageSize:x,total:V.entriesTotal,onPageChange:k,label:`entries`})]})}export{S as DlqPro};
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-B68RYDeC.js";import{A as o,K as s,R as c,S as l,T as u,b as ee,c as d,h as te,nt as f,rt as p,u as ne,v as m,w as h,x as re,z as g}from"./index-BFRKPhvf.js";import{a as _}from"./form-C-zZyKfB.js";import{t as ie}from"./Pagination-EJ2HGoqv.js";import{t as v}from"./exportFile-tdUeW5m5.js";import{t as ae}from"./promisePool-Daxkc1OB.js";var y=e(r(),1),b=a(),oe=6,x=25;function S(){let[e,r]=n(),[a,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(`all`),[T,E]=(0,y.useState)(`newest`),[D,se]=(0,y.useState)(``),[O,k]=(0,y.useState)(0),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),[P,ce]=(0,y.useState)(new Set),{data:le,refetch:F}=o(()=>f.queues(),[],{intervalMs:1e4}),I=le?.queues??[],L=I.reduce((e,t)=>e+t.dlq,0),{data:R,error:z,loading:ue,refetch:B}=o((0,y.useCallback)(async()=>{if(!a)return{queue:a,page:O,entries:[],entriesTotal:0,stats:null};let[e,t]=await Promise.all([f.dlq(a,x,O*x),f.dlqStats(a).catch(()=>null)]);return{queue:a,page:O,entries:e.entries??[],entriesTotal:e.total??0,stats:t?.stats??null}},[a,O]),[a,O]),V=R&&R.queue===a&&R.page===O?R:null;(0,y.useEffect)(()=>{if(!V)return;let e=V.entriesTotal??0;O>0&&O*x>=e&&k(Math.max(0,Math.ceil(e/x)-1))},[V,O]);let H=async(e,t,n)=>{if(window.confirm(e)){j(!0),N(null);try{let e=(await n())?.count??0,r=`${t} ${d(e)} ${e===1?`entry`:`entries`}`;N({ok:!0,text:r}),p.success(r),B(),F()}catch(e){N({ok:!1,text:e.message}),p.error(`${t} failed`,e.message)}finally{j(!1)}}},U=async e=>{let t=q.map(e=>e.name);if(t.length===0||!window.confirm(`${e} the dead letter queue across ${t.length} queue(s) (${d(L)} entries)?`))return;j(!0),N(null);let n=await ae(t,oe,t=>e===`Retry`?f.retryDlq(t):f.purgeDlq(t)),r=0,i=0;for(let e of n)e.status===`fulfilled`?r+=e.value?.count??0:i++;let a=`${e===`Retry`?`Retried`:`Purged`} ${d(r)} across ${t.length-i}/${t.length} queues${i?`, ${i} failed`:``}`;N({ok:i===0,text:a}),i===0?p.success(a):p.error(a),B(),F(),j(!1)},de=()=>{let e=(V?.entries??[]).map(e=>({jobId:e.job.id,reason:e.reason,error:e.error??``,enteredAt:new Date(e.enteredAt).toISOString(),attempts:e.attempts?.length??0}));if(e.length===0){p.info(`Nothing to export on this page`);return}v(`dlq-${a}`,e,[`jobId`,`reason`,`error`,`enteredAt`,`attempts`])},W=e=>{J.current=!0,S(e),k(0),w(`all`),r(e?{queue:e}:{},{replace:!0})},G=V?.stats?.byReason??{},K=Object.keys(G).filter(e=>G[e]>0),fe=[...K].sort((e,t)=>(G[t]??0)-(G[e]??0))[0],q=(0,y.useMemo)(()=>I.filter(e=>e.dlq>0).sort((e,t)=>t.dlq-e.dlq),[I]),J=(0,y.useRef)(!1),Y=e.get(`queue`);(0,y.useEffect)(()=>{if(!(J.current||a)){if(Y){if(I.some(e=>e.name===Y)){J.current=!0,S(Y),k(0),w(`all`);return}if(I.length===0)return}q.length!==0&&(J.current=!0,S(q[0].name),k(0),w(`all`))}},[a,I,q,Y]);let X=(0,y.useMemo)(()=>{let e=V?.entries??[];C!==`all`&&(e=e.filter(e=>e.reason===C));let t=D.trim().toLowerCase();return t&&(e=e.filter(e=>e.job.id.toLowerCase().includes(t))),[...e].sort((e,t)=>T===`newest`?t.enteredAt-e.enteredAt:e.enteredAt-t.enteredAt)},[V,C,D,T]),Z=L===0,Q=C!==`all`||D.trim()!==``,$=(V?.entriesTotal??0)>x;return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(te,{title:`Dead Letter Queue`,description:`Jobs that failed after exhausting all retries. Monitor, retry, or purge.`,live:!0}),z&&(0,b.jsx)(re,{onRetry:B}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,b.jsxs)(l,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Total in DLQ`}),(0,b.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Z?`bg-emerald-500/10 text-success`:`bg-red-500/10 text-danger`),children:Z?`Healthy`:`Attention`})]}),(0,b.jsx)(`div`,{className:t(`mt-2 text-3xl font-bold tnum`,Z?`text-success`:`text-danger`),children:d(L)})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Top Reason`}),(0,b.jsx)(`div`,{className:`mt-2 text-lg font-semibold text-fg`,children:a?fe??`No failures`:`Select a queue`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Pending Retry`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(V.stats.pendingRetry??0):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:a?`in this queue`:`awaiting retry`})]}),(0,b.jsxs)(l,{children:[(0,b.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Failure Types`}),(0,b.jsx)(`div`,{className:`mt-2 text-3xl font-bold tnum text-fg`,children:V?.stats?d(K.length):`—`}),(0,b.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`distinct reasons`})]})]}),q.length>0&&(0,b.jsxs)(l,{className:`mb-6`,children:[(0,b.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:`DLQ by queue`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(h,{size:`sm`,disabled:A,onClick:()=>U(`Retry`),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry all (`,q.length,` queues)`]}),(0,b.jsxs)(h,{variant:`danger`,size:`sm`,disabled:A,onClick:()=>U(`Purge`),children:[`Purge all (`,q.length,` queues)`]})]})]}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-5`,children:q.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>W(e.name),className:t(`rounded-lg border p-3 text-left transition-colors`,a===e.name?`border-accent/50 bg-surface-2`:`border-line hover:border-line-strong`),children:[(0,b.jsx)(`div`,{className:`truncate font-mono text-xs text-muted`,children:e.name}),(0,b.jsx)(`div`,{className:`mt-1 text-xl font-bold tnum text-danger`,children:e.dlq})]},e.name))})]}),(0,b.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-48`,children:(0,b.jsxs)(_,{value:a,onChange:e=>W(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`Select a queue…`}),I.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.name,e.dlq?` (${e.dlq})`:``]},e.name))]})}),(0,b.jsx)(`div`,{className:`w-40`,children:(0,b.jsxs)(_,{value:C,onChange:e=>w(e.target.value),"aria-label":`Filter by reason`,children:[(0,b.jsx)(`option`,{value:`all`,children:`All Reasons`}),K.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]})}),(0,b.jsx)(`div`,{className:`w-36`,children:(0,b.jsxs)(_,{value:T,onChange:e=>E(e.target.value),"aria-label":$?`Sort this page`:`Sort`,children:[(0,b.jsxs)(`option`,{value:`newest`,children:[`Newest First`,$?` (this page)`:``]}),(0,b.jsxs)(`option`,{value:`oldest`,children:[`Oldest First`,$?` (this page)`:``]})]})}),(0,b.jsx)(`input`,{value:D,onChange:e=>se(e.target.value),placeholder:`Filter this page by job ID…`,"aria-label":`Filter this page by job ID`,className:`h-9 min-w-40 flex-1 rounded-lg border border-line bg-surface px-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),(0,b.jsxs)(h,{size:`sm`,disabled:!a||A,onClick:()=>H(`Retry all for "${a}"?`,`Retried`,()=>f.retryDlq(a)),children:[(0,b.jsx)(s,{className:`size-3.5`}),` Retry All`]}),(0,b.jsx)(h,{variant:`danger`,size:`sm`,disabled:!a||A,onClick:()=>H(`Purge all for "${a}"?`,`Purged`,()=>f.purgeDlq(a)),children:`Purge All`}),(0,b.jsx)(u,{"aria-label":`Export this page to CSV`,title:`Export this page to CSV`,disabled:!a,onClick:de,children:(0,b.jsx)(g,{className:`size-3.5`})})]}),M&&(0,b.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),ue&&!V&&!z?(0,b.jsx)(ee,{label:`Loading DLQ…`}):a?X.length===0?(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),title:Q?`No matches on this page`:`No dead letter entries`,hint:Q?`No entries on this page match your filter — the filter is page-scoped. Use the pager below to check other pages.`:`This queue has no dead letter entries.`}):(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Reason`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Error`}),(0,b.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Entered`}),(0,b.jsx)(`th`,{scope:`col`,className:`w-16 px-5 py-3`})]})}),(0,b.jsx)(`tbody`,{children:X.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(i,{to:`/job?id=${encodeURIComponent(e.job.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.job.id})}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{className:`rounded-md bg-red-500/10 px-2 py-0.5 text-xs text-danger`,children:e.reason})}),(0,b.jsx)(`td`,{className:`max-w-md px-5 py-3 text-xs text-danger/80`,children:e.error?(0,b.jsx)(`button`,{type:`button`,title:e.error,onClick:()=>ce(t=>{let n=new Set(t),r=`${e.job.id}-${e.enteredAt}`;return n.has(r)?n.delete(r):n.add(r),n}),className:t(`block w-full break-words text-left`,!P.has(`${e.job.id}-${e.enteredAt}`)&&`line-clamp-2`),children:e.error}):`—`}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:ne(e.enteredAt)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,b.jsx)(u,{"aria-label":`Retry`,disabled:A,onClick:()=>H(`Retry job ${e.job.id.slice(0,8)}… from "${a}"?`,`Retried`,()=>f.retryDlq(a,e.job.id)),children:(0,b.jsx)(s,{className:`size-3.5`})})})]},`${e.job.id}-${e.enteredAt}`))})]})}):(0,b.jsx)(m,{icon:(0,b.jsx)(c,{}),title:`Select a queue`,hint:`Choose a queue from the dropdown to view its dead letter queue entries.`}),a&&V&&(0,b.jsx)(ie,{page:O,pageSize:x,total:V.entriesTotal,onPageChange:k,label:`entries`})]})}export{S as DlqPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-B68RYDeC.js";import{D as o,S as s,b as c,et as l,h as u,nt as d,x as f,y as p}from"./index-
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-B68RYDeC.js";import{D as o,S as s,b as c,et as l,h as u,nt as d,x as f,y as p}from"./index-BFRKPhvf.js";var m=e(r(),1),h={nodeWidth:168,nodeHeight:60,colGap:72,rowGap:20,padding:24};function g(e,t){let n=new Map,r=new Map,i=new Map;for(let t of e)n.set(t,0),r.set(t,0),i.set(t,[]);for(let e of t)!n.has(e.from)||!n.has(e.to)||e.from===e.to||(i.get(e.from)?.push(e.to),r.set(e.to,(r.get(e.to)??0)+1));let a=e.filter(e=>(r.get(e)??0)===0),o=0;for(;a.length;){let s=a.shift();o+=1;for(let e of i.get(s)??[]){n.set(e,Math.max(n.get(e)??0,(n.get(s)??0)+1));let t=(r.get(e)??0)-1;r.set(e,t),t===0&&a.push(e)}if(o>e.length+t.length)break}return n}function _(e,t,n={}){let r={...h,...n},i=g(e,t),a=new Map,o=0;for(let t of e){let e=i.get(t)??0;o=Math.max(o,e);let n=a.get(e);n?n.push(t):a.set(e,[t])}let s=0;for(let e of a.values())s=Math.max(s,e.length);let c=s*r.nodeHeight+Math.max(0,s-1)*r.rowGap,l=[];for(let e=0;e<=o;e++){let t=a.get(e)??[],n=t.length*r.nodeHeight+Math.max(0,t.length-1)*r.rowGap,i=r.padding+(c-n)/2;t.forEach((t,n)=>{l.push({id:t,layer:e,x:r.padding+e*(r.nodeWidth+r.colGap),y:i+n*(r.nodeHeight+r.rowGap)})})}return{nodes:l,width:r.padding*2+(o+1)*r.nodeWidth+o*r.colGap,height:r.padding*2+c}}var v=a(),y=168,b=60,x={nodeWidth:y,nodeHeight:b},S=60,C=6,w=`flow-order-9a3f`,T={completed:`border-success/50 bg-success/10 text-success`,failed:`border-danger/50 bg-danger/10 text-danger`,active:`border-blue-400/60 bg-blue-400/10 text-blue-400`,delayed:`border-accent/50 bg-accent/10 text-accent`,waiting:`border-warning/50 bg-warning/10 text-warning`,prioritized:`border-warning/50 bg-warning/10 text-warning`},E=e=>e&&T[e]||`border-line bg-surface-2 text-muted`,D=e=>e.length>12?`${e.slice(0,6)}…${e.slice(-4)}`:e,O=`bq-dash-recent-flows`,k=8;function A(){try{let e=JSON.parse(localStorage.getItem(O)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e?.root==`string`&&typeof e?.nodes==`number`&&typeof e?.at==`number`):[]}catch{return[]}}function j(e,t){let n=[t,...e.filter(e=>e.root!==t.root)].slice(0,k);try{localStorage.setItem(O,JSON.stringify(n))}catch{}return n}async function M(e){let t=e,n=new Set([e]);for(let e=0;e<12;e++){try{let{job:e}=await d.job(t),r=e?.parentId;if(r&&!n.has(r)){n.add(r),t=r;continue}}catch(t){if(e===0)throw t}break}return t}async function N(e){let t=new Map,n=[],r=new Set,i=[{id:e,depth:0}],a=!1;for(;i.length&&t.size<S;){let{id:e,depth:o}=i.shift();if(t.has(e))continue;let s=null;try{s=(await d.job(e)).job??null}catch{}if(t.set(e,s??{id:e,state:`unknown`}),!s)continue;if(o>=C){(s.childrenIds?.length??0)+(s.dependsOn?.length??0)>0&&(a=!0);continue}let c=(e,t,a,s)=>{let c=`${e}->${t}:${a}`;r.has(c)||(r.add(c),n.push({from:e,to:t,kind:a})),i.push({id:s,depth:o+1})};for(let t of s.childrenIds??[])c(e,t,`child`,t);for(let t of s.dependsOn??[])c(t,e,`depends`,t)}return i.some(e=>!t.has(e.id))&&(a=!0),{jobs:t,edges:n,truncated:a}}function P(e,t,n,r){let i=(e+n)/2;return`M${e},${t} C${i},${t} ${i},${r} ${n},${r}`}function F(){let[e,r]=n(),a=e.get(`root`)??(o()?w:``),[d,h]=(0,m.useState)(a),[g,T]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[F,L]=(0,m.useState)(!1),[R,z]=(0,m.useState)(null),[B,V]=(0,m.useState)(A),H=(0,m.useRef)(0),U=(0,m.useCallback)(async e=>{let t=e.trim();if(!t){T(null);return}let n=++H.current;L(!0),z(null);try{let e=await M(t),r=await N(e);if(n!==H.current)return;T(r),k(e),r.jobs.size>1&&V(t=>j(t,{root:e,nodes:r.jobs.size,at:Date.now()}))}catch(e){if(n!==H.current)return;z(e instanceof Error?e:Error(`Failed to load flow`)),T(null)}finally{n===H.current&&L(!1)}},[]);(0,m.useEffect)(()=>{a&&U(a)},[a,U]);let W=e=>{e.preventDefault();let t=d.trim();t&&r(t?{root:t}:{},{replace:!0})},G=g?_([...g.jobs.keys()],g.edges,x):null,K=new Map(G?.nodes.map(e=>[e.id,e])??[]),q=O?g?.jobs.get(O):void 0;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(u,{title:`Flows`,description:`Visualize a job flow: parent, children, and dependency edges as an interactive graph.`,actions:g&&(0,v.jsx)(`button`,{type:`button`,onClick:()=>U(d||a),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Refresh`})}),(0,v.jsxs)(s,{className:`mb-6`,children:[(0,v.jsxs)(`form`,{onSubmit:W,className:`flex flex-wrap items-center gap-3`,children:[(0,v.jsx)(`input`,{value:d,onChange:e=>h(e.target.value),placeholder:`Job ID (any node in the flow)`,"aria-label":`Root job ID`,className:`min-w-0 flex-1 rounded-lg border border-line bg-surface-2 px-3 py-2 font-mono text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,v.jsx)(`button`,{type:`submit`,disabled:!d.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:`Load flow`})]}),(0,v.jsxs)(`p`,{className:`mt-2 text-xs text-faint`,children:[`Paste any job ID from the Job Inspector. The graph climbs to the flow root, then walks children and dependencies (up to `,S,` nodes).`]})]}),R&&(R instanceof l?(0,v.jsx)(p,{error:R,onRetry:()=>U(d||a)}):(0,v.jsx)(f,{onRetry:()=>U(d||a)})),F&&!g&&(0,v.jsx)(c,{label:`Loading flow…`}),!F&&!g&&!R&&(0,v.jsx)(s,{children:(0,v.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,v.jsx)(`p`,{className:`text-sm text-muted`,children:`No flow loaded.`}),(0,v.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Enter a job ID above, or open a job that is part of a flow and choose “View flow”.`}),B.length>0&&(0,v.jsxs)(`div`,{className:`mt-6`,children:[(0,v.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Recently viewed`}),(0,v.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:B.map(e=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{h(e.root),r({root:e.root},{replace:!0})},className:`rounded-lg border border-line bg-surface-2 px-3 py-1.5 font-mono text-xs text-muted transition-colors hover:border-line-strong hover:text-fg`,children:[D(e.root),(0,v.jsxs)(`span`,{className:`ml-2 text-faint`,children:[e.nodes,` nodes`]})]},e.root))})]})]})}),g&&G&&(0,v.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1fr_260px]`,children:[(0,v.jsx)(s,{padded:!1,className:`overflow-auto p-4`,children:(0,v.jsxs)(`div`,{className:`relative`,style:{width:G.width,height:G.height},children:[(0,v.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 text-line`,width:G.width,height:G.height,children:[(0,v.jsx)(`title`,{children:`Flow edges`}),g.edges.map(e=>{let t=K.get(e.from),n=K.get(e.to);return!t||!n?null:(0,v.jsx)(`path`,{d:P(t.x+y,t.y+b/2,n.x,n.y+b/2),fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeDasharray:e.kind===`depends`?`4 4`:void 0,opacity:.5},`${e.from}-${e.to}-${e.kind}`)})]}),G.nodes.map(e=>{let n=g.jobs.get(e.id);return(0,v.jsxs)(`button`,{type:`button`,onClick:()=>k(e.id),style:{left:e.x,top:e.y,width:y,height:b},className:t(`absolute flex flex-col justify-center gap-0.5 rounded-lg border px-3 text-left transition-shadow`,E(n?.state),O===e.id&&`ring-2 ring-accent`),children:[(0,v.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:D(e.id)}),(0,v.jsxs)(`span`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,v.jsx)(`span`,{className:`truncate`,children:n?.queue??`—`}),(0,v.jsx)(`span`,{className:`font-medium`,children:n?.state??`unknown`})]})]},e.id)})]})}),(0,v.jsxs)(s,{children:[q?(0,v.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs text-faint`,children:`Job`}),(0,v.jsx)(`div`,{className:`break-all font-mono text-xs text-fg`,children:q.id})]}),(0,v.jsx)(I,{label:`Queue`,value:q.queue??`—`}),(0,v.jsx)(I,{label:`State`,value:q.state??`unknown`}),(0,v.jsx)(I,{label:`Priority`,value:String(q.priority??0)}),(0,v.jsx)(I,{label:`Children`,value:String(q.childrenIds?.length??0)}),(0,v.jsx)(I,{label:`Depends on`,value:String(q.dependsOn?.length??0)}),(0,v.jsx)(i,{to:`/job?id=${encodeURIComponent(q.id)}`,className:`inline-block rounded-lg border border-line px-3 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg`,children:`Open in Job Inspector`})]}):(0,v.jsx)(`p`,{className:`text-sm text-muted`,children:`Click a node to inspect it.`}),(0,v.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-xs text-faint`,children:[g.truncated&&(0,v.jsxs)(`div`,{className:`mb-1 text-warning`,children:[`Graph truncated at `,S,` nodes / depth `,C,` — not the whole flow.`]}),(0,v.jsxs)(`div`,{className:`mb-1`,children:[g.jobs.size,` node`,g.jobs.size===1?``:`s`,` · `,g.edges.length,` edge`,g.edges.length===1?``:`s`]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`inline-block h-px w-4 bg-current`}),` child`]}),(0,v.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`inline-block h-px w-4 border-t border-dashed border-current`}),` `,`depends`]})]})]})]})]})]})}function I({label:e,value:t}){return(0,v.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,v.jsx)(`span`,{className:`text-xs text-faint`,children:e}),(0,v.jsx)(`span`,{className:`text-fg`,children:t})]})}export{F as Flows};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{f as t,h as n,r,t as i}from"./react-vendor-B68RYDeC.js";import{C as a,J as o,O as s,S as c,T as l,a as u,b as d,et as f,g as p,h as m,nt as h,o as g,v as _,w as v,z as y}from"./index-BFRKPhvf.js";import{a as b,n as x}from"./form-C-zZyKfB.js";import{n as S}from"./exportFile-tdUeW5m5.js";import{t as C}from"./jobActions-CuOdMglt.js";var w=e(n(),1);function T(e){let t={};return typeof e.priority==`number`&&(t.priority=e.priority),typeof e.maxAttempts==`number`&&(t.maxAttempts=e.maxAttempts),typeof e.backoff==`number`&&(t.backoff=e.backoff),typeof e.timeout==`number`&&(t.timeout=e.timeout),typeof e.removeOnComplete==`boolean`&&(t.removeOnComplete=e.removeOnComplete),typeof e.removeOnFail==`boolean`&&(t.removeOnFail=e.removeOnFail),{clone:{queue:e.queue??``,dataText:JSON.stringify(e.data??{},null,2),options:t}}}var E=i();function ee({job:e,busy:t,act:n}){let r=C(e.state),i=r.cancel||r.discard||r.promote||r.retryActive||r.retryDlq||r.requeueCompleted||r.setPriority||r.setDelay||r.fail||r.moveToDelayed;return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Actions`}),(0,E.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.promote&&(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Promote`,()=>h.promoteJob(e.id)),children:`Promote (run now)`}),r.retryActive&&(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>h.retryJob(e.id)),children:`Retry (move to waiting)`}),r.retryDlq&&(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Retry`,()=>h.retryDlq(e.queue??``,e.id)),children:`Retry from DLQ`}),r.requeueCompleted&&(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Requeue`,()=>h.retryCompleted(e.queue??``,e.id)),children:`Requeue`}),r.moveToDelayed&&(0,E.jsx)(D,{label:`Move to delayed (ms)`,cta:`To delayed`,disabled:t,onSubmit:t=>n(`Move to delayed`,()=>h.moveToDelayed(e.id,t))}),e.state===`active`&&(0,E.jsx)(D,{label:`Set progress (0–100)`,cta:`Progress`,disabled:t,onSubmit:t=>n(`Progress`,()=>h.setJobProgress(e.id,Math.max(0,Math.min(100,t))))}),r.discard&&(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>n(`Discard`,()=>h.discardJob(e.id)),children:`Discard (to DLQ)`}),r.setPriority&&(0,E.jsx)(D,{label:`Set priority`,cta:`Set`,disabled:t,onSubmit:t=>n(`Priority`,()=>h.changePriority(e.id,t))}),r.setDelay&&(0,E.jsx)(D,{label:`Set delay (ms)`,cta:`Delay`,disabled:t,onSubmit:t=>n(`Delay`,()=>h.changeDelay(e.id,t))}),r.fail&&(0,E.jsx)(O,{label:`Fail reason (optional)`,cta:`Fail`,variant:`warning`,disabled:t,onSubmit:t=>n(`Fail`,()=>h.failJob(e.id,t||void 0),`Force-fail this active job?`)}),r.cancel&&(0,E.jsx)(v,{variant:`danger`,size:`sm`,disabled:t,onClick:()=>n(`Cancel`,()=>h.cancelJob(e.id),`Cancel and remove job ${e.id}?`),children:`Cancel (delete)`}),!i&&(0,E.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No actions available for a job in state "`,e.state??`unknown`,`".`]})]})]})}function D({label:e,cta:t,disabled:n,onSubmit:r}){let[i,a]=(0,w.useState)(``);return(0,E.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!n&&i.trim()!==``&&r(Number(i))},children:[(0,E.jsx)(x,{type:`number`,value:i,onChange:e=>a(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,E.jsx)(v,{type:`submit`,size:`sm`,disabled:n||i.trim()===``,children:t})]})}function O({label:e,cta:t,disabled:n,variant:r=`default`,onSubmit:i}){let[a,o]=(0,w.useState)(``);return(0,E.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),!n&&(i(a),o(``))},children:[(0,E.jsx)(x,{value:a,onChange:e=>o(e.target.value),placeholder:e,"aria-label":e,className:`h-8 text-xs`}),(0,E.jsx)(v,{type:`submit`,size:`sm`,variant:r,disabled:n,children:t})]})}var k=36e5,A=10;function j(e){let t=e.maxAttempts??0,n=e.attempts??0,r=e.backoffConfig,i=r?.maxDelay??k,a=r?.delay??e.backoff??1e3,o=[];for(let e=Math.max(n,1);e<t&&o.length<A;e++){let t=r?.type===`fixed`?a:a*2**e;o.push({attempt:e+1,delayMs:Math.min(t,i)})}return o}function M({job:e}){let t=e.maxAttempts??0,n=e.attempts??0;if(t<=1)return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Backoff`}),(0,E.jsxs)(`p`,{className:`text-xs text-faint`,children:[`No retries configured (max attempts = `,t||1,`).`]})]});if(n>=t)return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Backoff schedule`}),(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`Max attempts reached — no further retries will be scheduled.`})]});let r=e.backoffConfig,i=r?r.type:`exponential (default)`,o=t-n,s=j(e);return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Backoff schedule`,action:(0,E.jsxs)(`span`,{className:`text-xs capitalize text-faint`,children:[i,r?.maxDelay?` · cap ${g(r.maxDelay)}`:``]})}),(0,E.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:s.map(e=>(0,E.jsxs)(`li`,{className:`flex items-center justify-between text-sm`,children:[(0,E.jsxs)(`span`,{className:`text-muted`,children:[`Attempt `,e.attempt,` / `,t]}),(0,E.jsxs)(`span`,{className:`font-mono text-xs text-fg`,children:[`~`,g(e.delayMs)]})]},e.attempt))}),o>A&&(0,E.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Showing next `,A,` of `,o,` remaining attempts.`]}),(0,E.jsxs)(`p`,{className:`mt-2 text-[11px] text-faint`,children:[`Approximate — the server applies ±`,r?.type===`fixed`?`20`:`50`,`% jitter at retry time, capped at `,g(r?.maxDelay??k),`.`]})]})}function N({jobId:e}){let[t,n]=(0,w.useState)(!1),[r,i]=(0,w.useState)(!1),[o,s]=(0,w.useState)(!1),[l,u]=(0,w.useState)(void 0),[d,f]=(0,w.useState)(null),p=async()=>{s(!0),f(null);try{u((await h.jobChildren(e)).data?.values),i(!0)}catch(e){f(e.message)}finally{s(!1)}},m=()=>{let e=!t;n(e),e&&!r&&!o&&p()},g=l&&typeof l==`object`?Array.isArray(l)?l.length:Object.keys(l).length:0;return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Child values`,action:(0,E.jsx)(v,{size:`sm`,variant:`ghost`,onClick:m,children:t?`Hide`:`Show`})}),t?o?(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`Loading child values…`}):d?(0,E.jsx)(`p`,{className:`text-xs text-danger`,children:d}):g===0?(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`No child values available.`}):(0,E.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(l,null,2)}):(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`Resolved return values from this flow job's children.`})]})}function P({data:e,busy:t,onSave:n}){let[r,i]=(0,w.useState)(()=>JSON.stringify(e??null,null,2)),[o,s]=(0,w.useState)(null),l=(0,w.useRef)(r);return(0,w.useEffect)(()=>{let t=JSON.stringify(e??null,null,2);t!==l.current&&(l.current=t,i(t),s(null))},[e]),(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Data`,action:(0,E.jsx)(v,{size:`sm`,disabled:t,onClick:()=>{let e;try{e=JSON.parse(r)}catch(e){s(`Invalid JSON: ${e.message}`);return}s(null),n(e)},children:`Save data`})}),(0,E.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),spellCheck:!1,rows:8,className:`w-full resize-y rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`}),o&&(0,E.jsx)(`p`,{className:`mt-2 text-xs text-danger`,children:o})]})}function F({jobId:e}){let[t,n]=(0,w.useState)([]),[r,i]=(0,w.useState)(0),[o,s]=(0,w.useState)(!1),[l,u]=(0,w.useState)(null),[d,f]=(0,w.useState)(``),[p,m]=(0,w.useState)(`info`),[g,_]=(0,w.useState)(!1),y=(0,w.useCallback)(async()=>{s(!0),u(null);try{let t=await h.jobLogs(e);n(t.data?.logs??[]),i(t.data?.count??0)}catch(e){u(e.message)}finally{s(!1)}},[e]);(0,w.useEffect)(()=>{y()},[y]);let S=async()=>{if(g)return;let t=d.trim();if(t){_(!0),u(null);try{await h.addJobLog(e,t,p),f(``),await y()}catch(e){u(e.message)}finally{_(!1)}}};return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Logs`,action:(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:r}),(0,E.jsx)(v,{size:`sm`,variant:`ghost`,disabled:o||g,onClick:y,children:`Refresh`}),(0,E.jsx)(v,{size:`sm`,variant:`danger`,disabled:g||t.length===0,onClick:async()=>{if(window.confirm(`Clear all logs for this job?`)){_(!0),u(null);try{await h.clearJobLogs(e),await y()}catch(e){u(e.message)}finally{_(!1)}}},children:`Clear logs`})]})}),l&&(0,E.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:l}),t.length===0?(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`No log lines recorded for this job.`}):(0,E.jsx)(`ol`,{className:`flex max-h-64 flex-col gap-1 overflow-auto rounded-lg bg-surface-2 p-3`,children:t.map((e,t)=>(0,E.jsx)(`li`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-muted`,children:typeof e==`string`?e:JSON.stringify(e)},t))}),(0,E.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,E.jsx)(x,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.key===`Enter`&&S(),placeholder:`Add a log line…`,className:`h-8 flex-1 text-xs`}),(0,E.jsxs)(b,{value:p,onChange:e=>m(e.target.value),className:`h-8 w-24 text-xs`,children:[(0,E.jsx)(`option`,{value:`info`,children:`info`}),(0,E.jsx)(`option`,{value:`warn`,children:`warn`}),(0,E.jsx)(`option`,{value:`error`,children:`error`})]}),(0,E.jsx)(v,{size:`sm`,disabled:g||d.trim()===``,onClick:S,children:`Add`})]})]})}function I({timeline:e}){let t=e??[];return(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Timeline`}),t.length===0?(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`No state transitions recorded yet.`}):(0,E.jsx)(`ol`,{className:`flex flex-col gap-0`,children:t.map((e,t)=>(0,E.jsxs)(`li`,{className:`border-b border-line/60 py-2 last:border-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(p,{status:e.state}),e.attempt!=null&&(0,E.jsxs)(`span`,{className:`font-mono text-[11px] text-faint`,children:[`attempt `,e.attempt]})]}),(0,E.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:u(e.timestamp)})]}),(e.worker||e.error)&&(0,E.jsxs)(`div`,{className:`mt-1 pl-0.5`,children:[e.worker&&(0,E.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.worker}),e.error&&(0,E.jsx)(`div`,{className:`mt-0.5 text-xs text-danger/90`,children:e.error})]})]},t))})]})}function te(e){let t=e.timeline??[];for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.state===`failed`&&n.error)return{message:n.error,attempt:n.attempt,timestamp:n.timestamp}}return null}function L(){let[e,n]=t(),[i,l]=(0,w.useState)(e.get(`id`)??``),[x,C]=(0,w.useState)(`id`),[D,O]=(0,w.useState)(null),[k,A]=(0,w.useState)({fetched:!1,value:void 0}),[j,L]=(0,w.useState)(!1),[ie,z]=(0,w.useState)(!1),[B,V]=(0,w.useState)(null),[H,U]=(0,w.useState)(!1),W=(0,w.useRef)(0),G=async(e,t=x,r=!1)=>{let i=e.trim();if(!i)return;let a=++W.current;L(!0),z(!1),r||V(null);try{let e=(await(t===`custom`?h.jobByCustomId(i):h.job(i))).job;if(!e){if(a!==W.current)return;O(null),A({fetched:!1,value:void 0}),z(!0),n({},{replace:!0});return}let r=e.state===`completed`?await h.jobResult(e.id).catch(()=>null):null;if(a!==W.current)return;O(e),l(t===`custom`?e.id:i),n({id:e.id},{replace:!0}),A(r?{fetched:!0,value:r.result}:{fetched:!1,value:void 0})}catch(e){if(a!==W.current)return;e instanceof f&&(e.status===404||/not found/i.test(e.message))?(O(null),A({fetched:!1,value:void 0}),z(!0),n({},{replace:!0})):V({ok:!1,text:e.message})}finally{a===W.current&&L(!1)}},K=e.get(`id`);(0,w.useEffect)(()=>{K&&K!==D?.id&&G(K,`id`)},[K,D?.id]);let q=async(e,t,r)=>{if(!(r&&!window.confirm(r))&&D){U(!0),V(null);try{await t(),V({ok:!0,text:`${e} ✓`}),e===`Cancel`?(O(null),A({fetched:!1,value:void 0}),n({},{replace:!0})):await G(D.id,`id`,!0)}catch(e){V({ok:!1,text:e.message})}finally{U(!1)}}},J=D?.state,Y=D?te(D):null,X=(D?.stacktrace?.length??0)>0,Z=(D?.childrenIds?.length??0)>0,Q=J===`failed`,$=D&&(Y||X)?(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Error`}),Y&&(0,E.jsxs)(`div`,{className:`mb-3`,children:[(0,E.jsx)(`p`,{className:`text-sm text-danger`,children:Y.message}),(0,E.jsxs)(`p`,{className:`mt-1 text-[11px] text-faint`,children:[Y.attempt==null?``:`Attempt ${Y.attempt} · `,u(Y.timestamp)]})]}),X&&(0,E.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-surface-2 p-3 font-mono text-xs text-danger/90`,children:D.stacktrace?.join(`
|
|
2
|
+
`)})]}):null;return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(m,{title:`Job Inspector`,description:`Look up any job by ID and drive its full lifecycle.`,actions:D?(0,E.jsxs)(E.Fragment,{children:[(Z||D.parentId)&&(0,E.jsx)(r,{to:`/flows?root=${encodeURIComponent(D.id)}`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`View flow`}),(0,E.jsx)(r,{to:`/add-job`,state:T(D),title:`Enqueue a new job pre-filled from this one`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Clone`}),(0,E.jsxs)(v,{size:`sm`,onClick:()=>S(`job-${D.id}`,k.fetched?{...D,result:k.value}:D),children:[(0,E.jsx)(y,{className:`size-3.5`}),` Download JSON`]})]}):void 0}),(0,E.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-2`,children:[(0,E.jsxs)(b,{value:x,"aria-label":`Lookup mode`,onChange:e=>C(e.target.value),className:`w-40`,children:[(0,E.jsx)(`option`,{value:`id`,children:`By job ID`}),(0,E.jsx)(`option`,{value:`custom`,children:`By custom ID`})]}),(0,E.jsxs)(`div`,{className:`relative min-w-56 flex-1`,children:[(0,E.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,E.jsx)(`input`,{value:i,"aria-label":x===`custom`?`Custom job ID`:`Job ID`,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&G(i),placeholder:x===`custom`?`custom / idempotency id — Enter to look up`:`job id (UUID) — Enter to look up`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 font-mono text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,E.jsx)(v,{variant:`accent`,disabled:j,onClick:()=>G(i),children:`Look up`})]}),B&&(0,E.jsx)(`div`,{role:`status`,className:B.ok?`mb-4 text-sm text-success`:`mb-4 text-sm text-danger`,children:B.text}),j&&!D?(0,E.jsx)(d,{label:`Loading job…`}):ie?(0,E.jsx)(_,{title:`Job not found`,hint:`Check the ID, or the job may have been removed.`}):D?(0,E.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-6 lg:col-span-2`,children:[(0,E.jsxs)(c,{children:[(0,E.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(`div`,{className:`truncate font-mono text-sm text-fg`,children:D.id}),(0,E.jsx)(s,{value:D.id})]}),(0,E.jsx)(`div`,{className:`mt-1 font-mono text-xs text-faint`,children:D.queue})]}),(0,E.jsx)(p,{status:J??`waiting`})]}),(0,E.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm sm:grid-cols-3`,children:[(0,E.jsx)(R,{k:`Priority`,v:String(D.priority??0)}),(0,E.jsx)(R,{k:`Attempts`,v:`${D.attempts??0} / ${D.maxAttempts??`?`}`}),(0,E.jsx)(R,{k:`Progress`,v:`${D.progress??0}%`}),(0,E.jsx)(R,{k:`Created`,v:u(D.createdAt)}),(0,E.jsx)(R,{k:`Started`,v:u(D.startedAt??void 0)}),(0,E.jsx)(R,{k:`Completed`,v:u(D.completedAt??void 0)}),(0,E.jsx)(R,{k:`Duration`,v:g(D.startedAt&&D.completedAt?D.completedAt-D.startedAt:void 0)}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Custom ID`}),(0,E.jsxs)(`dd`,{className:`flex items-center gap-1 text-fg`,children:[(0,E.jsx)(`span`,{className:`truncate font-mono`,children:D.customId??`—`}),D.customId&&(0,E.jsx)(s,{value:D.customId})]})]})]})]}),Q&&$,(0,E.jsx)(P,{data:D.data,busy:H,onSave:e=>q(`Data`,()=>h.updateJobData(D.id,e))},`data-${D.id}`),J===`completed`&&(0,E.jsxs)(c,{children:[(0,E.jsx)(a,{title:`Result`,action:k.fetched&&k.value!==void 0&&k.value!==null?(0,E.jsx)(re,{value:k.value,filename:`job-${D.id}-result`}):void 0}),k.fetched&&k.value!==void 0&&k.value!==null?(0,E.jsx)(ne,{value:k.value}):(0,E.jsx)(`p`,{className:`text-xs text-faint`,children:`No result stored for this job.`})]}),!Q&&$,(0,E.jsx)(F,{jobId:D.id},`logs-${D.id}`),Z&&(0,E.jsx)(N,{jobId:D.id},`children-${D.id}`),(0,E.jsx)(I,{timeline:D.timeline}),(0,E.jsx)(M,{job:D})]}),(0,E.jsx)(`div`,{className:`order-first lg:order-none`,children:(0,E.jsx)(ee,{job:D,busy:H,act:q})})]}):(0,E.jsx)(_,{title:`No job loaded`,hint:`Enter a job ID above to inspect it.`})]})}function R({k:e,v:t}){return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`dt`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:e}),(0,E.jsx)(`dd`,{className:`text-fg`,children:t})]})}function ne({value:e}){return(0,E.jsx)(`pre`,{className:`max-h-64 overflow-auto rounded-lg bg-surface-2 p-3 font-mono text-xs text-muted`,children:JSON.stringify(e??null,null,2)})}function re({value:e,filename:t}){return(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(s,{value:JSON.stringify(e??null,null,2)}),(0,E.jsx)(l,{"aria-label":`Download JSON`,title:`Download JSON`,onClick:()=>S(t,e??null),children:(0,E.jsx)(y,{className:`size-3.5`})})]})}export{L as JobInspector};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{f as t,h as n,t as r}from"./react-vendor-B68RYDeC.js";import{A as i,J as a,T as o,Y as s,b as c,c as l,f as u,g as d,h as f,j as p,l as m,m as h,n as g,o as _,u as v,x as y}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{f as t,h as n,t as r}from"./react-vendor-B68RYDeC.js";import{A as i,J as a,T as o,Y as s,b as c,c as l,f as u,g as d,h as f,j as p,l as m,m as h,n as g,o as _,u as v,x as y}from"./index-BFRKPhvf.js";import{a as b,i as x}from"./form-C-zZyKfB.js";var S=e(n(),1),C=r(),w=`__all__`,T=[`all`,`waiting`,`active`,`completed`,`failed`];function E(){let[e]=t(),[n,r]=(0,S.useState)(e.get(`queue`)??w),[E,D]=(0,S.useState)(`all`),[O,k]=(0,S.useState)(``),{data:A}=i(()=>p.queues(500),[]),{data:j}=i(()=>p.overview(),[]),{data:M,error:N,loading:P,refetch:F}=i((0,S.useCallback)(async()=>{let e=n===w?(A?.queues??[]).map(e=>e.name).slice(0,25):[n],t=E===`all`?void 0:[E];return(await Promise.all(e.map(e=>p.jobsList(e,{states:t,limit:40}).then(t=>(t.jobs??[]).map(t=>({...t,queue:t.queue??e}))).catch(()=>[])))).flat().sort((e,t)=>(t.createdAt??0)-(e.createdAt??0))},[n,E,A]),[n,E]),I=(0,S.useMemo)(()=>{let e=M??[],t=O.trim().toLowerCase();return(t?e.filter(e=>e.id.toLowerCase().includes(t)||(e.name??``).toLowerCase().includes(t)):e).slice(0,100)},[M,O]),L=j?.stats,R=L?g(L.totalCompleted,L.totalFailed)??0:0,z=async e=>{if(window.confirm(`Cancel job ${e}?`))try{await p.cancelJob(e),F()}catch{}};return(0,C.jsxs)(`div`,{children:[N&&(0,C.jsx)(y,{onRetry:F}),(0,C.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,C.jsx)(h,{label:`Total`,value:l((L?.totalCompleted??0)+(L?.totalFailed??0)+(L?.waiting??0)+(L?.active??0)),compact:!0}),(0,C.jsx)(h,{label:`Waiting`,value:l(L?.waiting),tone:`amber`,compact:!0}),(0,C.jsx)(h,{label:`Active`,value:l(L?.active),tone:`blue`,compact:!0}),(0,C.jsx)(h,{label:`Completed`,value:l(L?.totalCompleted),tone:`green`,compact:!0}),(0,C.jsx)(h,{label:`Failed`,value:l(L?.totalFailed),tone:L?.totalFailed?`red`:`default`,compact:!0}),(0,C.jsx)(h,{label:`Error Rate`,value:m(R),tone:R>.05?`red`:`green`,compact:!0})]}),(0,C.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`w-48`,children:(0,C.jsxs)(b,{value:n,onChange:e=>r(e.target.value),children:[(0,C.jsx)(`option`,{value:w,children:`All Queues`}),(A?.queues??[]).map(e=>(0,C.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,C.jsx)(x,{options:T,value:E,onChange:D}),(0,C.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,C.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,C.jsx)(`input`,{value:O,onChange:e=>k(e.target.value),placeholder:`Search by ID or name…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),P&&!M&&!N?(0,C.jsx)(c,{label:`Loading jobs…`}):(0,C.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,C.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,C.jsx)(`tbody`,{children:I.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:`No jobs found.`})}):I.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:e.id}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:v(e.createdAt)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:_(u(e.processedOn,e.finishedOn))}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,C.jsx)(o,{"aria-label":`Cancel job`,onClick:()=>z(e.id),children:(0,C.jsx)(s,{className:`size-3.5`})})})]},`${e.queue}:${e.id}`))})]})})]})}export{E as Jobs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./cn-CMFYpumL.js";import{f as n,h as r,r as i,t as a}from"./react-vendor-B68RYDeC.js";import{A as o,B as s,I as c,J as ee,K as l,T as u,W as te,Y as ne,a as d,b as re,c as ie,g as ae,h as oe,l as se,m as f,n as ce,nt as p,o as le,rt as m,w as h,x as ue,z as g}from"./index-BFRKPhvf.js";import{a as de,i as fe}from"./form-C-zZyKfB.js";import{t as pe}from"./Pagination-EJ2HGoqv.js";import{t as me}from"./exportFile-tdUeW5m5.js";import{t as _}from"./jobActions-CuOdMglt.js";var v=e(r(),1),y=a(),b=[`all`,`waiting`,`active`,`completed`,`failed`],x=25;function he(e=0){return e>=10?{t:`HIGH`,c:`text-warning`}:e>=1?{t:`MEDIUM`,c:`text-blue-400`}:{t:`LOW`,c:`text-faint`}}function S(e){let t=_(e.state);return t.retryActive?p.retryJob(e.id):t.retryDlq?p.retryDlq(e.queue??``,e.id):Promise.reject(Error(`"${e.state??`unknown`}" is not retryable`))}function C(){let[e,r]=n(),[a,C]=(0,v.useState)(e.get(`queue`)??``),[w,ge]=(0,v.useState)(()=>{let t=e.get(`status`);return t&&b.includes(t)?t:`all`}),[T,_e]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),[O,k]=(0,v.useState)(new Set),[ve,A]=(0,v.useState)(new Set),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(null),{data:F}=o(()=>p.queuesSummary(),[],{intervalMs:3e4}),{data:ye}=o(()=>p.overview(),[],{intervalMs:1e4});(0,v.useEffect)(()=>{!a&&F?.length&&C(F[0].name)},[F,a]);let I=`${a}|${w}|${E}`,{data:L,error:R,loading:be,refetch:z}=o((0,v.useCallback)(async()=>{if(!a)return{view:I,jobs:[]};let e=w===`all`?void 0:[w];return{view:I,jobs:((await p.jobsList(a,e,x,E*x)).jobs??[]).map(e=>({...e,queue:e.queue??a}))}},[a,w,E,I]),[a,w,E]),B=L&&L.view===I?L.jobs:null,xe=(B?.length??0)===x,V=(0,v.useMemo)(()=>{let e=T.trim().toLowerCase();return e?(B??[]).filter(t=>t.id.toLowerCase().includes(e)):B??[]},[B,T]),H=ye?.stats,U=(0,v.useMemo)(()=>(F??[]).reduce((e,t)=>e+(t.counts?.failed??0),0),[F]),W=H?ce(H.completed,U):null,G=e=>H?ie(e):`—`,K=()=>D(0),q=(e,t)=>{let n={};e&&(n.queue=e),t!==`all`&&(n.status=t),r(n,{replace:!0})};(0,v.useEffect)(()=>{k(new Set)},[a,w,E]);let Se=e=>k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),J=V.length>0&&V.every(e=>O.has(e.id)),Ce=()=>k(()=>J?new Set:new Set(V.map(e=>e.id))),Y=async(e,t,n,r)=>{if(!(r&&!window.confirm(r))){A(t=>new Set(t).add(e.id)),P(null);try{await n(),P({ok:!0,text:`${t} ✓`}),m.success(`${t} ✓`,e.id)}catch(e){P({ok:!1,text:`${t} failed: ${e.message}`}),m.error(`${t} failed`,e.message)}finally{A(t=>{let n=new Set(t);return n.delete(e.id),n}),z()}}},X=async(e,t,n,r)=>{let i=V.filter(e=>O.has(e.id)&&n(e));if(i.length===0||r&&!window.confirm(r(i.length)))return;M(!0),P(null);let a=await Promise.allSettled(i.map(t)),o=a.filter(e=>e.status===`fulfilled`).length,s=a.length-o,c=`${e}: ${o} succeeded${s?`, ${s} failed`:``}`;P({ok:s===0,text:c}),s===0?m.success(c):m.error(c),k(new Set),M(!1),z()},Z={retry:e=>{let t=_(e.state);return t.retryActive||t.retryDlq},promote:e=>_(e.state).promote,requeue:e=>_(e.state).requeueCompleted,fail:e=>_(e.state).fail,cancel:e=>_(e.state).cancel},Q=V.filter(e=>O.has(e.id)),$={retry:Q.some(Z.retry),promote:Q.some(Z.promote),requeue:Q.some(Z.requeue),fail:Q.some(Z.fail),cancel:Q.some(Z.cancel)};return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(oe,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!0,actions:(0,y.jsxs)(h,{size:`sm`,disabled:!B||V.length===0,onClick:()=>{if(V.length===0){m.info(`No jobs to export on this page`);return}let e=V.map(e=>({id:e.id,queue:e.queue??a,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));me(`jobs-${a}-${w}`,e,[`id`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,y.jsx)(g,{className:`size-3.5`}),` Export CSV`]})}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total`,value:G((H?.completed??0)+U+(H?.waiting??0)+(H?.active??0)+(H?.delayed??0)),hint:`all queues`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:G(H?.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:G(H?.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:G(H?.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:G(U),tone:U?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Error Rate`,value:W==null?`—`:se(W),tone:W==null?`default`:W>.05?`red`:`green`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsx)(de,{value:a,"aria-label":`Queue`,onChange:e=>{C(e.target.value),K(),q(e.target.value,w)},children:(F??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,y.jsx)(fe,{options:b,value:w,onChange:e=>{ge(e),K(),q(a,e)}}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(ee,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{value:T,onChange:e=>_e(e.target.value),placeholder:`Filter this page by ID…`,"aria-label":`Filter by job ID`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),O.size>0&&(0,y.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,y.jsxs)(`span`,{className:`mr-1 text-muted`,children:[O.size,` selected`]}),$.retry&&(0,y.jsx)(h,{size:`sm`,disabled:j,onClick:()=>X(`Retry`,S,Z.retry),children:`Retry selected`}),$.promote&&(0,y.jsx)(h,{size:`sm`,disabled:j,onClick:()=>X(`Promote`,e=>p.promoteJob(e.id),Z.promote),children:`Promote selected`}),$.requeue&&(0,y.jsx)(h,{size:`sm`,disabled:j,onClick:()=>X(`Requeue`,e=>p.retryCompleted(e.queue??``,e.id),Z.requeue),children:`Requeue selected`}),$.fail&&(0,y.jsx)(h,{variant:`warning`,size:`sm`,disabled:j,onClick:()=>X(`Fail`,e=>p.failJob(e.id),Z.fail,e=>`Force-fail ${e} job(s)?`),children:`Fail selected`}),$.cancel&&(0,y.jsx)(h,{variant:`danger`,size:`sm`,disabled:j,onClick:()=>X(`Cancel`,e=>p.cancelJob(e.id),Z.cancel,e=>`Cancel ${e} job(s)? This cannot be undone.`),children:`Cancel selected`}),!$.retry&&!$.promote&&!$.requeue&&!$.fail&&!$.cancel&&(0,y.jsx)(`span`,{className:`text-xs text-faint`,children:`No actions apply to the selected job states.`})]}),N&&(0,y.jsx)(`div`,{role:`status`,className:t(`mb-3 text-sm`,N.ok?`text-success`:`text-danger`),children:N.text}),R&&(0,y.jsx)(ue,{onRetry:z}),be&&!B&&!R?(0,y.jsx)(re,{label:`Loading jobs…`}):(0,y.jsxs)(y.Fragment,{children:[a&&(0,y.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,y.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:a})]}),(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{scope:`col`,className:`w-10 px-5 py-3`,children:(0,y.jsx)(`input`,{type:`checkbox`,checked:J,onChange:Ce,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,y.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,y.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{scope:`col`,className:`px-5 py-3 font-medium`,children:`Priority`}),(0,y.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,y.jsx)(`th`,{scope:`col`,className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,y.jsx)(`th`,{scope:`col`,className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,y.jsx)(`tbody`,{children:V.length===0?(0,y.jsx)(`tr`,{children:(0,y.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:T.trim()?`No jobs on this page match your ID filter.`:a?`No jobs found.`:`Select a queue.`})}):V.map(e=>{let n=he(e.priority),r=_(e.state),a=ve.has(e.id);return(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`input`,{type:`checkbox`,checked:O.has(e.id),onChange:()=>Se(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,y.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(ae,{status:String(e.state??`waiting`)})}),(0,y.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.c),children:n.t}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:d(e.createdAt)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:le(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,y.jsx)(i,{to:`/job?id=${encodeURIComponent(e.id)}`,children:(0,y.jsx)(u,{"aria-label":`Inspect job`,children:(0,y.jsx)(s,{className:`size-3.5`})})}),r.promote&&(0,y.jsx)(u,{"aria-label":`Promote job`,disabled:a,onClick:()=>Y(e,`Promote`,()=>p.promoteJob(e.id)),children:(0,y.jsx)(te,{className:`size-3.5`})}),(r.retryActive||r.retryDlq)&&(0,y.jsx)(u,{"aria-label":`Retry job`,disabled:a,onClick:()=>Y(e,`Retry`,()=>S(e)),children:(0,y.jsx)(l,{className:`size-3.5`})}),r.requeueCompleted&&(0,y.jsx)(u,{"aria-label":`Requeue job`,disabled:a,onClick:()=>Y(e,`Requeue`,()=>p.retryCompleted(e.queue??``,e.id)),children:(0,y.jsx)(l,{className:`size-3.5`})}),r.fail&&(0,y.jsx)(u,{"aria-label":`Fail job`,disabled:a,onClick:()=>Y(e,`Fail`,()=>p.failJob(e.id),`Force-fail this active job?`),children:(0,y.jsx)(c,{className:`size-3.5`})}),r.cancel&&(0,y.jsx)(u,{"aria-label":`Cancel job`,disabled:a,onClick:()=>Y(e,`Cancel`,()=>p.cancelJob(e.id),`Cancel this job?`),children:(0,y.jsx)(ne,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,y.jsx)(pe,{page:E,pageSize:x,hasNext:xe,onPageChange:D,label:`jobs`})]})]})}export{C as JobsPro};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-B68RYDeC.js";import{A as r,H as i,J as a,c as o,g as s,h as c,j as l,m as u,t as d,u as f,v as p,x as m}from"./index-
|
|
1
|
+
import{r as e}from"./cn-CMFYpumL.js";import{h as t,t as n}from"./react-vendor-B68RYDeC.js";import{A as r,H as i,J as a,c as o,g as s,h as c,j as l,m as u,t as d,u as f,v as p,x as m}from"./index-BFRKPhvf.js";import{a as h,i as g}from"./form-C-zZyKfB.js";import{t as _}from"./Pagination-EJ2HGoqv.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;function C(){let[e,t]=(0,v.useState)(b),[n,C]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O}=r(()=>l.queues(500),[],{intervalMs:3e4}),{events:k,counters:A,throughput:j,connected:M}=d(e===b?void 0:e),N=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return k.filter(t=>n!==`all`&&t.status!==n?!1:e?(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e):!0)},[k,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let P=Math.max(1,Math.ceil(N.length/S)),F=Math.min(E,P-1);return(0,y.jsxs)(`div`,{children:[!M&&k.length===0&&(0,y.jsx)(m,{}),(0,y.jsx)(c,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:M}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(u,{label:`Total Events`,value:o(A.total),compact:!0}),(0,y.jsx)(u,{label:`Completed`,value:o(A.completed),tone:`green`,compact:!0}),(0,y.jsx)(u,{label:`Failed`,value:o(A.failed),tone:A.failed?`red`:`default`,compact:!0}),(0,y.jsx)(u,{label:`Waiting`,value:o(A.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(u,{label:`Active`,value:o(A.active),tone:`blue`,compact:!0}),(0,y.jsx)(u,{label:`Throughput`,value:`${j.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(h,{value:e,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(g,{options:x,value:n,onChange:C}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),N.length===0?(0,y.jsx)(p,{icon:(0,y.jsx)(i,{}),title:M?`Waiting for activity…`:`Connecting to the event stream…`,hint:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job Name`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:N.slice(F*S,F*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(s,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name||`unknown`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:f(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(_,{page:F,pageSize:S,total:N.length,onPageChange:D,label:`events`})]})}export{C as Logs};
|