export type ReflowEventsByEventAndWorkflowIds = {events: Array, workflows?: Array | undefined}; export type ReflowEventsBySubjectAndWorkflowIds = {subjects: Array, workflows?: Array | undefined}; export type CreateApiWorkflowsEventsReflowArgs = {body: ReflowEventsByEventAndWorkflowIds | ReflowEventsBySubjectAndWorkflowIds}; export type CreateApiWorkflowsEventsReflowOptions = {baseUrl: string, OAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Reflow * * POST /workflows/events/reflow * * Also accepts auth: ApiSecretKey */ export const createApiWorkflowsEventsReflow = async (args: CreateApiWorkflowsEventsReflowArgs, options: CreateApiWorkflowsEventsReflowOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (OAuth !== undefined) headers.set('authorization', `Bearer ${OAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/workflows/events/reflow${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 };