'use strict'; var api = require('@flatfile/api'); var utilCommon = require('@flatfile/util-common'); var o=new api.FlatfileClient;function d(r,l,n={}){return s=>{let f=typeof r=="string"?{job:r}:r;s.on("job:ready",f,async i=>{let{jobId:t}=i.context;await o.jobs.ack(t,{info:"Accepted",progress:0});let m=async(e,a)=>await o.jobs.ack(t,{progress:e,...a!==void 0&&{info:a}});try{let e=await l(i,m);n.debug&&utilCommon.log("@flatfile/plugin-job-handler","Job complete"),await o.jobs.complete(t,e||{outcome:{message:"Job complete"}});}catch(e){utilCommon.logError("@flatfile/plugin-job-handler",e.message),await o.jobs.fail(t,{info:String(e.message),outcome:{acknowledge:!0,message:String(e.message)}});}});}} exports.jobHandler = d; //# sourceMappingURL=index.cjs.map //# sourceMappingURL=index.cjs.map