import{aW as f,a7 as g,a4 as n,H as j,aX as v,aQ as p,h as T,e as d,m as I,u as N,k as S,aY as J,aZ as P,a_ as _,aT as $}from"./index-BKr2rJhV.js";import{F as h,u as A,J as l}from"./utils-C3tzOLw4.js";import{s as O}from"./index-DdhqPQ_t.js";import{l as q}from"./lensPath-CdufhmA3.js";import{m as E}from"./mergeRight-Cv2eiGXV.js";var y=function(e){return{value:e,map:function(t){return y(t(e))}}},M=f(function(t,r,s){return t(function(a){return y(r(a))})(s).value}),C=(e=>(e.DYNAMIC="Dynamic",e.STATIC="Static",e))(C||{}),R=(e=>(e.SPARK="SPARK",e.PYTHON="PYTHON",e.RAY="RAY",e.INGESTION="INGESTION",e))(R||{}),u=(e=>(e.SUBMISSION_TIME="last run",e.CREATION_TIME="last created",e))(u||{});const x=e=>e===u.SUBMISSION_TIME?"submissiontime:desc":e===u.CREATION_TIME?"date_created:desc":null,Y=g.injectEndpoints({endpoints:e=>({getJobs:e.query({query:({projectId:t,sortBy:r=u.SUBMISSION_TIME,types:s=[],nameFilter:a="",lastExecState:i=[],limit:c=20,offset:o=0})=>{const m=$.stringify({expand:["creator","executions(sort_by=submissiontime:desc;offset=0;limit=10)"],limit:c,offset:o,sort_by:x(r),filter_by:[`jobtype:${((s==null?void 0:s.length)>0?s:Object.values(l).filter(b=>b!==l.PYTHON_APP&&b!==l.AGENT)).join(",")}`,...a!==""?[`name:${a}`]:[],...i.length>0?[`latest_execution_state:${i.join(",")}`]:[]]});return{url:`project/${t}/jobs?${m}`}},transformResponse:T(E({items:[],count:0}),d({items:I(d({executions:{items:{0:A}},jobSchedule:T(N(d(O)),S(J(P("*"),"cronExpression"),_("doNotRepeat",!0)))}))})),providesTags:p.providesListItems(n.ProjectTags.Job,"name")}),getJobByName:e.query({query:({pId:t,jobName:r})=>({url:`project/${t}/jobs/${r}?expand=creator`}),transformResponse:M(q(["config","envVars"]),t=>Array.isArray(t)?t.map(r=>{const s=r.indexOf("=");return s===-1?{key:r,value:""}:{key:r.slice(0,s),value:r.slice(s+1)}}):t),providesTags:p.cacheByArgProperties(n.ProjectTags.Job,["pId","jobName"])}),validateJob:e.query({query:({pId:t,jobName:r})=>({url:`project/${t}/jobs/${r}`}),extraOptions:{skipError:!0}}),createNewJob:e.mutation({query:({pId:t,data:r,name:s,runOnCreate:a})=>({url:`project/${t}/jobs/${s}${a?"?runOnCreate=true":""}`,method:"put",data:r}),invalidatesTags:(t,r,{pId:s,name:a})=>[{type:n.ProjectTags.Job,id:"LIST"},{type:n.ProjectTags.Job,id:`${s}-${a}`}]}),deleteJob:e.mutation({query:({pId:t,jobName:r})=>({url:`project/${t}/jobs/${r}`,method:"delete"}),invalidatesTags:p.invalidatesList(n.ProjectTags.Job)}),getJobConfigurations:e.query({async queryFn({id:t,excludedConfigs:r=[]},s,a,i){const c=Object.keys(h).filter(o=>!r.includes(o)).map(o=>i({url:`project/${t}/jobs/${o.toLowerCase()}/configuration`}));try{return{data:j(v(["data","type"]))(await Promise.all(c))}}catch(o){return{error:o}}},providesTags:[{type:n.ProjectTags.JobConfig,id:"LIST"}]})})}),{useGetJobsQuery:D,useGetJobByNameQuery:H,useCreateNewJobMutation:w,useDeleteJobMutation:K,useGetJobConfigurationsQuery:W,endpoints:F}=Y;export{C as D,R as F,u as J,w as a,K as b,W as c,Y as d,H as e,x as g,F as j,M as o,D as u};
