export type WorkerAppendJob = {payload: string, stream: string, time: string}; export type CreateApi0WorkerJobJobTaskTaskAppendArgs = {job: string, task: number, body: WorkerAppendJob}; export type CreateApi0WorkerJobJobTaskTaskAppendOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /0/worker/job/{job}/task/{task}/append */ export const createApi0WorkerJobJobTaskTaskAppend = async (args: CreateApi0WorkerJobJobTaskTaskAppendArgs, options: CreateApi0WorkerJobJobTaskTaskAppendOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/0/worker/job/${encodeURIComponent(String(args.job))}/task/${encodeURIComponent(String(args.task))}/append${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };