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 CitationsV2Query = {category_id: string, start_date: string, end_date: string, group_by?: (Array<'page' | 'date' | 'model' | 'topic' | 'region' | 'persona' | 'prompt'>) | undefined, metrics?: (Array<'count' | 'citation_share' | 'rank' | 'first_cited_at'> | null) | undefined, interval?: ('day' | 'week' | 'month') | undefined, scope?: ('all' | 'owned') | undefined, filter?: (FilterNode | null) | undefined, limit?: (number | null) | undefined, max_results?: (number | null) | undefined, cursor?: (string | null) | undefined}; export type CreateApiV2ReportsCitationsStreamArgs = {body: CitationsV2Query}; export type CreateApiV2ReportsCitationsStreamOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream Citations V2 * * POST /v2/reports/citations/stream * * Also accepts auth: BearerAuth */ export const createApiV2ReportsCitationsStream = async (args: CreateApiV2ReportsCitationsStreamArgs, options?: CreateApiV2ReportsCitationsStreamOptions) => { 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/citations/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() };