export type CreateApiApiV1ProjectionsProjectionIdRunArgs = {projectionId: number}; export type CreateApiApiV1ProjectionsProjectionIdRunOptions = {baseUrl: string, APIToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Start a projection run. * * POST /api/v1/Projections/{projectionId}/Run */ export const createApiApiV1ProjectionsProjectionIdRun = async (args: CreateApiApiV1ProjectionsProjectionIdRunArgs, options: CreateApiApiV1ProjectionsProjectionIdRunOptions) => { const {baseUrl, fetch: fetchFn = fetch, APIToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (APIToken !== undefined) headers.set('authorization', `Bearer ${APIToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/Projections/${encodeURIComponent(String(args.projectionId))}/Run${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };