export type CreateApiPipelinePreBuiltArgs = {body: {origin?: ('ui' | 'system') | undefined, requested_types: Array<'DEMO' | 'OTEL' | 'OTELLOGS'>, metadata: {userFullName: string, baseUrl: string}}}; export type CreateApiPipelinePreBuiltOptions = {baseUrl?: string | undefined, PipelineServiceKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add prebuilt pipeline to account * * POST /pipeline/pre-built */ export const createApiPipelinePreBuilt = async (args: CreateApiPipelinePreBuiltArgs, options?: CreateApiPipelinePreBuiltOptions) => { const {baseUrl = "https://api.mezmo.com/v3", fetch: fetchFn = fetch, PipelineServiceKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (PipelineServiceKey !== undefined) headers.set("Authorization", PipelineServiceKey) const url = `${baseUrl.replace(/\/+$/, '')}/pipeline/pre-built${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 };