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 AppRoutesV2AnswerEngineInsightsReportsSentimentSortSpec = {field?: ('occurrence' | 'positive_sentiment' | 'negative_sentiment') | undefined, dir?: ('asc' | 'desc') | undefined}; export type SentimentV2Query = {category_id: string, asset: string, start_date: string, end_date: string, comparison_start_date?: (string | null) | undefined, comparison_end_date?: (string | null) | undefined, group_by?: (Array<'date' | 'model' | 'topic' | 'region' | 'prompt' | 'persona' | 'tag' | 'theme' | 'claim' | 'run' | 'competitor'>) | undefined, metrics?: (Array<'positive_sentiment' | 'negative_sentiment' | 'occurrence'> | null) | undefined, interval?: ('day' | 'week' | 'month') | undefined, filter?: (FilterNode | null) | undefined, sort?: AppRoutesV2AnswerEngineInsightsReportsSentimentSortSpec | undefined, include_cited_websites?: boolean | undefined, limit?: (number | null) | undefined, max_results?: (number | null) | undefined, cursor?: (string | null) | undefined}; export type CreateApiV2ReportsSentimentStreamArgs = {body: SentimentV2Query}; export type CreateApiV2ReportsSentimentStreamOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream Sentiment V2 * * POST /v2/reports/sentiment/stream * * Also accepts auth: BearerAuth */ export const createApiV2ReportsSentimentStream = async (args: CreateApiV2ReportsSentimentStreamArgs, options?: CreateApiV2ReportsSentimentStreamOptions) => { 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/sentiment/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() };