export type WorkerJobStoreValue = {secret: boolean, value: string}; export type UpdateApi0WorkerJobJobStoreNameArgs = {job: string, name: string, body: WorkerJobStoreValue}; export type UpdateApi0WorkerJobJobStoreNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * PUT /0/worker/job/{job}/store/{name} */ export const updateApi0WorkerJobJobStoreName = async (args: UpdateApi0WorkerJobJobStoreNameArgs, options: UpdateApi0WorkerJobJobStoreNameOptions) => { 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))}/store/${encodeURIComponent(String(args.name))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };