var d=Object.defineProperty;var h=(s,t,e)=>t in s?d(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var n=(s,t,e)=>(h(s,typeof t!="symbol"?t+"":t,e),e);import{A as p}from"./utils.3371dfe5.js";class u{async list(){return await(await fetch("/_editor/api/jobs")).json()}async create(){return await(await fetch("/_editor/api/jobs",{method:"POST",headers:{"Content-Type":"application/json"}})).json()}async get(t){return await(await fetch(`/_editor/api/jobs/${t}`)).json()}async update(t,e){return await(await fetch(`/_editor/api/jobs/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()}async delete(t){await fetch(`/_editor/api/jobs/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})}async run(t){await fetch(`/_jobs/${t}`,{method:"POST",headers:{"Content-Type":"application/json"}})}}const a=new u;class r{constructor(t){n(this,"record");this.record=new p(a,t,"identifier")}static async list(){return(await a.list()).map(e=>new r(e))}static async create(){const t=await a.create();return new r(t)}static async get(t){const e=await a.get(t);return new r(e)}async delete(){await a.delete(this.identifier)}async duplicate(){return this}async save(){await this.record.save()}onUpdate(t){this.record.pubsub.subscribe("update",t)}hasChanges(){return this.record.hasChanges()}get schedule(){return this.record.get("schedule")}set schedule(t){this.record.set("schedule",t)}get title(){return this.record.get("title")}get file(){return this.record.get("file")}set file(t){this.record.set("file",t)}get identifier(){return this.record.get("identifier")}set identifier(t){this.record.set("identifier",t)}async run(){const t=await fetch(`/_jobs/${this.identifier}`,{method:"POST",headers:{"Content-Type":"application/json"}}),e=await t.text(),i={};return t.headers.forEach((o,c)=>{i[c]=o}),{status:t.status,headers:i,body:e}}}export{r as J};
//# sourceMappingURL=jobs.af366134.js.map
