import 'rollup-plugin-inject-process-env'; import { ChannelActionRequest, IntentRequest, LaunchRequest, OptionSelectRequest, PermissionRequest, Response } from "stentor-models"; import { StentorApiConfig } from "../config"; import { WidgetEvent, WidgetEventsResponse } from "../types/events"; export type StentorRequest = IntentRequest | LaunchRequest | OptionSelectRequest | PermissionRequest | ChannelActionRequest; /** * True when the response came from the post-final suppression path rather than the * server. Callers use it to tell "we deliberately did not send this" apart from "the * server returned nothing" -- the two were indistinguishable before issue #1373. */ export declare function wasDroppedAfterFinal(response: unknown): boolean; export declare class StentorApi { private responseCache; private readonly config; private session; private prefetchSemaphore; private constructor(); /** * Returns the cached API instance for this widget config, creating it on first use. * * Instances are keyed by url + key + intentId, so two widgets on one page with different * intentIds each get their own instance (and their own session) instead of colliding on a * single process-wide one. The Form/FormWidget pair within a single widget tree passes matching * config and so shares one entry. */ static getApi(config: StentorApiConfig): StentorApi; launchRequest(query: string): Promise; intentRequest(request: { query?: string; intentId?: string; }): Promise; channelActionRequest(data: unknown, action: string): Promise; /** * Track form widget interaction events * Sends events to POST /cms/widget/events * * Authentication uses the widget key in the request body (not headers). * * @param eventType - Type of event (next_step, submit, partial_data) * @param event - The widget event to track * @returns The response with processed count, or undefined on error */ trackEvent(eventType: string, event: WidgetEvent): Promise; /** * Track form widget interaction events for page unload scenarios. * * Uses fetch with keepalive instead of sendBeacon because: * - sendBeacon with Content-Type: application/json triggers CORS preflight * - sendBeacon doesn't properly wait for preflight response before firing * - fetch with keepalive handles the preflight handshake correctly * * @param event - The widget event to track * @returns true if the request was queued (not necessarily delivered), false if queuing failed */ trackEventBeacon(event: WidgetEvent): boolean; /** * Build the tracking endpoint URL: /cms/widget/events */ private getTrackingUrl; resetSession(): void; private getCachedResponse; private send; private prefetch; } export interface StentorApiSession { readonly sessionId: string; readonly userId: string; hadFinal: boolean; }