export type FilterNode = {and?: (Array | null) | undefined, or?: (Array | null) | undefined, not?: (FilterNode | null) | undefined, field?: (string | null) | undefined, op?: (string | null) | undefined, value: unknown}; export type AppRoutesV2AnswerEngineInsightsReportsQueryFanoutsSortSpec = {field: string, dir?: ('asc' | 'desc') | undefined}; export type QueryFanoutsV2Query = {category_id: string, start_date: string, end_date: string, group_by?: (Array<'date' | 'model' | 'region' | 'prompt' | 'query'>) | undefined, metrics?: (Array<'fanouts_per_execution' | 'total_fanouts' | 'share' | 'query_variations'> | null) | undefined, interval?: ('day' | 'week' | 'month') | undefined, filter?: (FilterNode | null) | undefined, sort?: (AppRoutesV2AnswerEngineInsightsReportsQueryFanoutsSortSpec | null) | undefined, limit?: (number | null) | undefined, max_results?: (number | null) | undefined, cursor?: (string | null) | undefined}; export type CreateApiV2ReportsQueryFanoutsStreamArgs = {body: QueryFanoutsV2Query}; export type CreateApiV2ReportsQueryFanoutsStreamOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream Query Fanouts V2 * * POST /v2/reports/query-fanouts/stream * * Also accepts auth: BearerAuth */ export const createApiV2ReportsQueryFanoutsStream = async (args: CreateApiV2ReportsQueryFanoutsStreamArgs, options?: CreateApiV2ReportsQueryFanoutsStreamOptions) => { const {baseUrl = "https://api.tryprofound.com", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/event-stream") if (APIKeyHeader !== undefined) headers.set("X-API-Key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/v2/reports/query-fanouts/stream${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 res.text() };