export type CreateApiApiV3DestinationsDestinationNameConnectionsArgs = {destination_name: string, body: {title?: string | undefined, create_load_for_new_tables?: boolean | undefined, destination_name?: string | undefined, connection_params?: Record | undefined}}; export type CreateApiApiV3DestinationsDestinationNameConnectionsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a connection * * POST /api/v3/destinations/{destination_name}/connections * * Also accepts auth: cookieAuth */ export const createApiApiV3DestinationsDestinationNameConnections = async (args: CreateApiApiV3DestinationsDestinationNameConnectionsArgs, options?: CreateApiApiV3DestinationsDestinationNameConnectionsOptions) => { const {baseUrl = "https://embedded.improvado.io", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/destinations/${encodeURIComponent(String(args.destination_name))}/connections${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 };