import{u as n,b as s,c as u}from"./vendor-query-B2UbickB.js";import{b as r}from"./index-BZu5zewH.js";function f(){return n({queryKey:["activeWorkers"],queryFn:async()=>(await r("/workflows/workers")).workers})}function w(){return n({queryKey:["discoveredWorkflows"],queryFn:async()=>(await r("/workflows/discovered")).workflows})}function l(){return n({queryKey:["workflowConfigs"],queryFn:async()=>(await r("/workflows/config")).workflows})}function d(){return n({queryKey:["cronStatus"],queryFn:async()=>(await r("/workflows/cron/status")).schedules})}function k(e){return n({queryKey:["workflowExecution",e],queryFn:()=>r(`/workflow-states/${e}/execution`),enabled:!!e})}function m(e){const o=new URLSearchParams;return e.limit&&o.set("limit",String(e.limit)),e.offset!==void 0&&o.set("offset",String(e.offset)),e.entity&&o.set("entity",e.entity),e.search&&o.set("search",e.search),e.status&&o.set("status",e.status),e.sort_by&&o.set("sort_by",e.sort_by),e.order&&o.set("order",e.order),e.registered&&o.set("registered",e.registered),e.namespace&&o.set("namespace",e.namespace),n({queryKey:["jobs",e],queryFn:()=>r(`/workflow-states/jobs?${o}`)})}function q(){const e=s();return u({mutationFn:o=>r(`/workflows/${o}/terminate`,{method:"POST"}),onSuccess:(o,t)=>{e.invalidateQueries({queryKey:["workflowExecution",t],refetchType:"all"}),e.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function h(){const e=s();return u({mutationFn:({workflow_type:o,...t})=>r(`/workflows/${encodeURIComponent(o)}/config`,{method:"PUT",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function p(){const e=s();return u({mutationFn:o=>r(`/workflows/${encodeURIComponent(o)}/config`,{method:"DELETE"}),onSuccess:()=>{e.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"})}})}function g(){const e=s();return u({mutationFn:({config:o,cron_schedule:t,envelope_schema:i})=>r(`/workflows/${encodeURIComponent(o.workflow_type)}/config`,{method:"PUT",body:JSON.stringify({...o,cron_schedule:t,...i!==void 0?{envelope_schema:i}:{}})}),onSuccess:()=>{e.invalidateQueries({queryKey:["workflowConfigs"],refetchType:"all"}),e.invalidateQueries({queryKey:["cronStatus"],refetchType:"all"})}})}function C(){const e=s();return u({mutationFn:({workflowType:o,data:t,metadata:i,execute_as:a})=>r(`/workflows/${o}/invoke`,{method:"POST",body:JSON.stringify({data:t,metadata:i,...a?{execute_as:a}:{}})}),onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"],refetchType:"all"}),e.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}export{k as a,m as b,C as c,g as d,w as e,d as f,q as g,f as h,p as i,h as j,l as u};
//# sourceMappingURL=workflows-CD7-d5w8.js.map
