/** * Copyright (c) 2021 * * Base classes * * @summary Base classes * @author Ayon Ghosh */ import { DOMSelector, EmbedConfig, EventType, EventTypeV1, GenericCallbackFn, MessageCallback } from '../types'; /** * Initialize the ThoughtSpot embed settings globally * @param embedConfig The configuration object containing ThoughtSpot host, * authentication mecheanism etc. */ export declare const init: (embedConfig: EmbedConfig) => void; export interface LayoutConfig { } export interface FrameParams { width?: number; height?: number; } export interface ViewConfig { layoutConfig?: LayoutConfig; frameParams?: FrameParams; theme?: string; styleSheet__unstable?: string; } /** * Base class for embedding v2 experience */ export declare class TsEmbed { /** * The identifier for the instance */ private id; /** * The DOM node where the ThoughtSpot app is to be embedded */ private el; /** * A reference to the iframe within which the ThoughtSpot app * will be rendered */ private iFrame; /** * A map of event handlers for particular message types triggered * by the embdedded app; multiple event handlers can be registered * against a particular message type */ private eventHandlerMap; /** * The ThoughtSpot host name or IP address */ private thoughtSpotHost; /** * A flag that is set to true post render */ private isRendered; constructor(domSelector: DOMSelector); /** * Get a reference to the root DOM node where * the embedded content will appear * @param domSelector */ private getDOMNode; /** * Throw error encountered during initialization */ private throwInitError; /** * Add an global event listener to window for "message" events * We detect if a particular event is targeted to this particular * embed instance through an identifier contained in the payload, * and execute the registere callbacks accordingly */ private subscribeToEvents; /** * Construct the base URL string to load the ThoughtSpot app */ protected getEmbedBasePath(): string; /** * Construct the base URL string to load v1 of the ThoughtSpot app * This is used for pinboards, visualizations and full app embedding * @param queryString Query string to append to the URL * @param isAppEmbed A Boolean parameter to specify if we're embedding * the full app */ protected getV1EmbedBasePath(queryString: string, isAppEmbed?: boolean): string; /** * Renders the embedded ThoughtSpot app in an iframe and sets up * event listeners * @param url * @param frameOptions */ protected renderIFrame(url: string, frameOptions: FrameParams): void; protected setIFrameHeight(height: number): void; /** * Execute all registered event handlers for a particular event type * @param eventType The event type * @param data The payload the event handler will be invoked with */ protected executeCallbacks(eventType: EventType | EventTypeV1, data: any): void; /** * Return the identifier for this instance */ getId(): string; /** * Return the ThoughtSpot host name or IP address */ getThoughtSpotHost(): string; /** * Register an event listener to be triggered when we receive * an event of a particular message type from the embedded app * @param messageType The message type * @param callback A callback function */ on(messageType: string, callback: MessageCallback): typeof TsEmbed.prototype; /** * Trigger a message event to the embedded app * @param messageType The message type * @param data The payload to send with the message */ trigger(messageType: string, data: any): typeof TsEmbed.prototype; render(...args: any[]): void; } /** * Base class for embedding legacy v1 experience */ export declare class V1Embed extends TsEmbed { protected viewConfig: ViewConfig; constructor(domSelector: DOMSelector, viewConfig: ViewConfig); /** * Render the app in an iframe and set up event handlers * @param iframeSrc */ protected renderV1Embed(iframeSrc: string): void; /** * Fetch the current pinboard or answer data from the * embedded app asynchronously * @param callback A function to be executed with the * fetched as an argument */ getCurrentData(callback: GenericCallbackFn): void; }