export type CreateApiWorkflowIdFeedbackArgs = {id: string, body: {payload?: Record | undefined}}; export type CreateApiWorkflowIdFeedbackOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send feedback to a workflow * * POST /workflow/{id}/feedback */ export const createApiWorkflowIdFeedback = async (args: CreateApiWorkflowIdFeedbackArgs, options?: CreateApiWorkflowIdFeedbackOptions) => { const {baseUrl = "http://localhost:3001", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/workflow/${encodeURIComponent(String(args.id))}/feedback${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 };