ashish-sdk
Version:
ThoughtSpot Embed SDK
1,094 lines (1,085 loc) • 42.9 kB
TypeScript
// Generated by dts-bundle v0.7.3
declare module '@thoughtspot/visual-embed-sdk' {
/**
* Copyright (c) 2022
*
* ThoughtSpot Visual Embed SDK for embedding ThoughtSpot analytics
* in other web applications.
*
* @summary ThoughtSpot Visual Embed SDK
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
*/
import { AppEmbed, Page, AppViewConfig } from '@thoughtspot/visual-embed-sdk/embed/app';
import { init, prefetch } from '@thoughtspot/visual-embed-sdk/embed/base';
import { PinboardEmbed, LiveboardViewConfig, LiveboardEmbed } from '@thoughtspot/visual-embed-sdk/embed/liveboard';
import { SearchEmbed, SearchViewConfig } from '@thoughtspot/visual-embed-sdk/embed/search';
import { AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, Plugin } from '@thoughtspot/visual-embed-sdk/types';
export { init, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, Plugin, };
}
declare module '@thoughtspot/visual-embed-sdk/embed/app' {
/**
* Copyright (c) 2022
*
* Full application embedding
* https://developers.thoughtspot.com/docs/?pageid=full-embed
*
* @summary Full app embed
* @module
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
*/
import { DOMSelector } from '@thoughtspot/visual-embed-sdk/types';
import { V1Embed, ViewConfig } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
/**
* Pages within the ThoughtSpot app that can be embedded.
*/
export enum Page {
/**
* Home page
*/
Home = "home",
/**
* Search page
*/
Search = "search",
/**
* Saved answers listing page
*/
Answers = "answers",
/**
* Liveboards listing page
*/
Liveboards = "liveboards",
/**
* @hidden
*/
Pinboards = "pinboards",
/**
* Data management page
*/
Data = "data"
}
/**
* The view configuration for full app embedding.
* @Category App Embed
*/
export interface AppViewConfig extends ViewConfig {
/**
* If true, the main navigation bar within the ThoughtSpot app
* is displayed. By default, the navigation bar is hidden.
*/
showPrimaryNavbar?: boolean;
/**
* If true, help and profile buttons will hide on NavBar. By default,
* they are shown.
*/
disableProfileAndHelp?: boolean;
/**
* A URL path within the app that is to be embedded.
* If both path and pageId attributes are defined, the path definition
* takes precedence.
*/
path?: string;
/**
* The application page to set as the start page
* in the embedded view.
*/
pageId?: Page;
/**
* This puts a filter tag on the application. All metadata lists in the application, such as
* Liveboards and answers, would be filtered by this tag.
*/
tag?: string;
/**
* The array of GUIDs to be hidden
*/
hideObjects?: string[];
}
/**
* Embeds full ThoughtSpot experience in a host application.
* @Category App Embed
*/
export class AppEmbed extends V1Embed {
protected viewConfig: AppViewConfig;
constructor(domSelector: DOMSelector, viewConfig: AppViewConfig);
/**
* Navigate to particular page for app embed. eg:answers/pinboards/home
* This is used for embedding answers, pinboards, visualizations and full application only.
* @param path The string, set to iframe src and navigate to new page
* eg: appEmbed.navigateToPage('pinboards')
*/
navigateToPage(path: string): void;
/**
* Renders the embedded application pages in the ThoughtSpot app.
* @param renderOptions An object containing the page ID
* to be embedded.
*/
render(): AppEmbed;
}
}
declare module '@thoughtspot/visual-embed-sdk/embed/base' {
import { EmbedConfig } from '@thoughtspot/visual-embed-sdk/types';
export let authPromise: Promise<void>;
/**
* Perform authentication on the ThoughtSpot app as applicable.
*/
export const handleAuth: () => void;
export const getEmbedConfig: () => EmbedConfig;
export const getAuthPromise: () => Promise<void>;
/**
* Prefetches static resources from the specified URL. Web browsers can then cache the prefetched resources and serve them from the user's local disk to provide faster access to your app.
* @param url The URL provided for prefetch
*/
export const prefetch: (url?: string) => void;
/**
* Initialize the ThoughtSpot embed settings globally and perform
* authentication if applicable.
* @param embedConfig The configuration object containing ThoughtSpot host,
* authentication mechanism and so on.
*/
export const init: (embedConfig: EmbedConfig) => void;
/**
* Renders functions in a queue, resolves to next function only after the callback next is called
* @param fn The function being registered
*/
export const renderInQueue: (fn: (next?: (val?: any) => void) => void) => void;
}
declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
/**
* Copyright (c) 2022
*
* Embed a ThoughtSpot Liveboard or visualization
* https://developers.thoughtspot.com/docs/?pageid=embed-pinboard
* https://developers.thoughtspot.com/docs/?pageid=embed-a-viz
*
* @summary Liveboard & visualization embed
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
*/
import { DOMSelector } from '@thoughtspot/visual-embed-sdk/types';
import { V1Embed, ViewConfig } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
/**
* The configuration for the embedded Liveboard or visualization page view.
* @Category Liveboards and Charts
*/
export interface LiveboardViewConfig extends ViewConfig {
/**
* If set to true, the embedded object container dynamically resizes
* according to the height of the Liveboard.
*/
fullHeight?: boolean;
/**
* This is the minimum height(in pixels) for a full height Liveboard.
* Setting this height helps resolves issues with empty Liveboards and
* other screens navigable from a Liveboard.
* @version 1.5.0 or later
* @default 500
*/
defaultHeight?: number;
/**
* If set to true, the context menu in visualizations will be enabled.
*/
enableVizTransformations?: boolean;
/**
* The Liveboard to display in the embedded view.
* Use either of liveboardId or pinboardId to reference the Liveboard to embed.
*/
liveboardId?: string;
/**
* To support backward compatibilty
* @hidden
*/
pinboardId?: string;
/**
* The visualization within the Liveboard to display.
*/
vizId?: string;
/**
* If set to true, all filter chips from a
* Liveboard page will be read-only (no X buttons)
*/
preventLiveboardFilterRemoval?: boolean;
/**
* To support backward compatibilty
* @hidden
*/
preventPinboardFilterRemoval?: boolean;
}
/**
* Embed a ThoughtSpot Liveboard or visualization
* @Category Liveboards and Charts
*/
export class LiveboardEmbed extends V1Embed {
protected viewConfig: LiveboardViewConfig;
constructor(domSelector: DOMSelector, viewConfig: LiveboardViewConfig);
/**
* Render an embedded ThoughtSpot Liveboard or visualization
* @param renderOptions An object specifying the Liveboard ID,
* visualization ID and the runtime filters.
*/
render(): LiveboardEmbed;
}
/**
* @hidden
*/
export class PinboardEmbed extends LiveboardEmbed {
}
}
declare module '@thoughtspot/visual-embed-sdk/embed/search' {
/**
* Copyright (c) 2022
*
* Embed ThoughtSpot search or a saved answer
*
* @summary Search embed
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
*/
import { DOMSelector, Action } from '@thoughtspot/visual-embed-sdk/types';
import { ViewConfig, TsEmbed } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
/**
* Configuration for search options
*/
interface SearchOptions {
/**
* The tml string to load the answer
*/
searchTokenString: string;
/**
* Boolean to determine if the search should be executed or not.
* if it is executed, put the focus on the results.
* if it’s not executed, put the focus in the search bar - at the end of the tokens
*/
executeSearch?: boolean;
}
/**
* The configuration attributes for the embedded search view.
*
* @Category Search Embed
*/
export interface SearchViewConfig extends ViewConfig {
/**
* If set to true, the data sources panel is collapsed on load,
* but can be expanded manually.
*/
collapseDataSources?: boolean;
/**
* If set to true, hides the data sources panel.
*/
hideDataSources?: boolean;
/**
* If set to true, hides the charts and tables in search answers.
* This attribute can be used to create a custom visualization
* using raw answer data.
*/
hideResults?: boolean;
/**
* If set to true, the Search Assist feature is enabled.
*/
enableSearchAssist?: boolean;
/**
* If set to true, the tabular view is set as the default
* format for presenting search data.
*/
forceTable?: boolean;
/**
* The array of data source GUIDs to set on load.
*/
dataSources?: string[];
/**
* The initial search query to load the answer with.
* @deprecated Use {@link searchOptions} instead
*/
searchQuery?: string;
/**
* Configuration for search options
*/
searchOptions?: SearchOptions;
/**
* The GUID of a saved answer to load initially.
*/
answerId?: string;
}
export const HiddenActionItemByDefaultForSearchEmbed: Action[];
/**
* Embed ThoughtSpot search
*
* @Category Search Embed
*/
export class SearchEmbed extends TsEmbed {
/**
* The view configuration for the embedded ThoughtSpot search.
*/
protected viewConfig: SearchViewConfig;
constructor(domSelector: DOMSelector, viewConfig: SearchViewConfig);
/**
* Render the embedded ThoughtSpot search
*/
render(): SearchEmbed;
}
export {};
}
declare module '@thoughtspot/visual-embed-sdk/types' {
/**
* The authentication mechanism for allowing access to the
* the embedded app
*/
export enum AuthType {
/**
* No authentication. Use this only for testing purposes.
*/
None = "None",
/**
* SSO using SAML
*/
SSO = "SSO_SAML",
/**
* SSO using OIDC
*/
OIDC = "SSO_OIDC",
/**
* Trusted authentication server
*/
AuthServer = "AuthServer",
/**
* Use the ThoughtSpot login API to authenticate to the cluster directly.
*
* Warning: This feature is primarily intended for developer testing. It is
* strongly advised not to use this authentication method in production.
*/
Basic = "Basic"
}
export type DOMSelector = string | HTMLElement;
/**
* The configuration object for embedding ThoughtSpot content.
* It includes the ThoughtSpot hostname or IP address,
* the type of authentication, and the authentication endpoint
* if a trusted authentication server is used.
*/
export interface EmbedConfig {
/**
* The ThoughtSpot cluster hostname or IP address.
*/
thoughtSpotHost: string;
/**
* The authentication mechanism to use.
*/
authType: AuthType;
/**
* [AuthServer] The trusted authentication endpoint to use to get the
* authentication token. A GET request is made to the
* authentication API endpoint, which returns the token
* as a plaintext response. For trusted authentication,
* the `authEndpoint` or `getAuthToken` attribute is required.
*/
authEndpoint?: string;
/**
* [AuthServer] A function that invokes the trusted authentication endpoint
* and returns a Promise that resolves to the `auth token` string.
* For trusted authentication, the `authEndpoint` or `getAuthToken`
* attribute is required.
*/
getAuthToken?: () => Promise<string>;
/**
* [AuthServer / Basic] The user name of the ThoughtSpot user. This attribute is
* required for trusted authentication.
*/
username?: string;
/**
* [Basic] The ThoughtSpot login password corresponding to the user name
*
* Warning: This feature is primarily intended for developer testing. It is
* strongly advised not to use this authentication method in production.
*/
password?: string;
/**
* [SSO] For SSO Authentication, if `noRedirect` is set to true, it will open the SAML auth
* flow in a popup, instead of redirecting browser in place.
*
* @default false
*/
noRedirect?: boolean;
/** @internal */
basepath?: string;
/**
* Should we encode URL Query Params using base64 encoding which thoughtspot
* will generate for embedding. This provides additional security to
* thoughtspot clusters against Cross site scripting attacks.
* @default false
*/
shouldEncodeUrlQueryParams?: boolean;
/**
* Suppress cookie access alert when third party cookies are blocked by the user's browser.
* Third party cookie blocking is the default behaviour on Safari and opt-in for Firefox/Chrome.
* If you set this to `true`, you are encouraged to handle `noCookieAccess` event, to show your own treatment
* in this case.
* @default false
*/
suppressNoCookieAccessAlert?: boolean;
/**
* Re-login when session expires with the previous login options
* @default true
*/
autoLogin?: boolean;
/**
* Calls the prefetch method internally when set to true
* @default false
*/
callPrefetch?: boolean;
/**
* When there are multiple embeds, queue the render of embed to start
* after the previous embed's render is complete. This helps in the load performance
* by decreasing the load on the browser.
* @version 1.5.0 or later
* @default false
*/
queueMultiRenders?: boolean;
/**
* Dynamic CSS Url to be injected in the loaded application.
* You would also need to set `style-src` in the CSP settings.
* @version 1.6.0 or later
* @default ''
*/
customCssUrl?: string;
}
export type MessagePayload = {
type: string;
data: any;
};
export type MessageCallback = (payload: MessagePayload, responder?: (data: any) => void) => void;
export type GenericCallbackFn = (...args: any[]) => any;
export type QueryParams = {
[key: string]: string;
};
/**
* A map of the supported runtime filter operations
*/
export enum RuntimeFilterOp {
/**
* Equals
*/
EQ = "EQ",
/**
* Does not equal
*/
NE = "NE",
/**
* Less than
*/
LT = "LT",
/**
* Less than or equal to
*/
LE = "LE",
/**
* Greater than
*/
GT = "GT",
/**
* Greater than or equal to
*/
GE = "GE",
/**
* Contains
*/
CONTAINS = "CONTAINS",
/**
* Begins with
*/
BEGINS_WITH = "BEGINS_WITH",
/**
* Ends with
*/
ENDS_WITH = "ENDS_WITH",
/**
* Between, inclusive of higher value
*/
BW_INC_MAX = "BW_INC_MAX",
/**
* Between, inclusive of lower value
*/
BW_INC_MIN = "BW_INC_MIN",
/**
* Between, inclusive of both higher and lower value
*/
BW_INC = "BW_INC",
/**
* Between, non-inclusive
*/
BW = "BW",
/**
* Is included in this list of values
*/
IN = "IN"
}
/**
* A filter that can be applied to ThoughtSpot answers, Liveboards, or
* visualizations at runtime.
*/
export interface RuntimeFilter {
/**
* The name of the column to filter on (case-sensitive)
*/
columnName: string;
/**
* The operator to apply
*/
operator: RuntimeFilterOp;
/**
* The list of operands. Some operators like EQ, LE accept
* a single operand, whereas other operators like BW and IN accept multiple operands.
*/
values: (number | boolean | string)[];
}
/**
* Event types emitted by the embedded ThoughtSpot application.
*/
export enum EmbedEvent {
/**
* Rendering has initialized.
* @return timestamp - The timestamp when the event was generated.
*/
Init = "init",
/**
* Authentication has either succeeded or failed.
* @return isLoggedIn - A Boolean specifying whether authentication was successful.
*/
AuthInit = "authInit",
/**
* The embed object container has loaded.
* @return timestamp - The timestamp when the event was generated.
*/
Load = "load",
/**
* Data pertaining to answer or Liveboard is received
* @return data - The answer or Liveboard data
*/
Data = "data",
/**
* Search/answer/Liveboard filters have been applied/updated
* @hidden
*/
FiltersChanged = "filtersChanged",
/**
* Search query has been updated
*/
QueryChanged = "queryChanged",
/**
* A drill down operation has been performed.
* @return additionalFilters - Any additional filters applied
* @return drillDownColumns - The columns on which drill down was performed
* @return nonFilteredColumns - The columns that were not filtered
*/
Drilldown = "drillDown",
/**
* One or more data sources have been selected.
* @return dataSourceIds - the list of data sources
*/
DataSourceSelected = "dataSourceSelected",
/**
* One or more data columns have been selected.
* @return columnIds - the list of columns
* @version SDK: 1.9.0 | ThoughtSpot: 8.2.0.cl
*/
AddRemoveColumns = "addRemoveColumns",
/**
* A custom action has been triggered
* @return actionId - The id of the custom action
* @return data - The answer or Liveboard data
*/
CustomAction = "customAction",
/**
* A click has been triggered on table/chart
* @return ContextMenuInputPoints - data point that is double clicked
* @version 1.10.0
*/
VizPointClick = "vizPointClick",
/**
* A double click has been triggered on table/chart
* @return ContextMenuInputPoints - data point that is double clicked
* @version 1.5.0 or later
*/
VizPointDoubleClick = "vizPointDoubleClick",
/**
* Event troggered when rendering a chart, call the supplied
* callback with the config overrides.
* @version 1.10.0
*/
GetVizConfigOverrides = "getVizConfigOverrides",
/**
* An error has occurred.
* @return error - An error object or message
*/
Error = "Error",
/**
* The embedded object has sent an alert
* @return alert - An alert object
*/
Alert = "alert",
/**
* The ThoughtSpot auth session has expired.
*/
AuthExpire = "ThoughtspotAuthExpired",
/**
* The height of the embedded Liveboard or visualization has been computed.
* @return data - The height of the embedded Liveboard or visualization
* @hidden
*/
EmbedHeight = "EMBED_HEIGHT",
/**
* The center of visible iframe viewport is calculated.
* @return data - The center of the visible Iframe viewport.
* @hidden
*/
EmbedIframeCenter = "EmbedIframeCenter",
/**
* Detects the route change.
*/
RouteChange = "ROUTE_CHANGE",
/**
* The v1 event type for Data
* @hidden
*/
V1Data = "exportVizDataToParent",
/**
* Emitted when the embed does not have cookie access. This
* happens on Safari where third-party cookies are blocked by default.
*
* @version 1.1.0 or later
*/
NoCookieAccess = "noCookieAccess",
/**
* Emitted when SAML is complete
* @private
* @hidden
*/
SAMLComplete = "samlComplete",
/**
* Emitted when any modal is opened in the app
* @version 1.6.0 or later
*/
DialogOpen = "dialog-open",
/**
* Emitted when any modal is closed in the app
* @version 1.6.0 or later
*/
DialogClose = "dialog-close"
}
/**
* Event types that can be triggered by the host application
* to the embedded ThoughtSpot app
*
* To trigger an event use the corresponding
* {@link LiveboardEmbed.trigger} or {@link AppEmbed.trigger} or {@link SearchEmbed.trigger} method.
*/
export enum HostEvent {
/**
* Trigger a search
* @param dataSourceIds - The list of data source GUIDs
* @param searchQuery - The search query
*/
Search = "search",
/**
* Trigger a drill on certain points by certain column
* @param points - an object containing selectedPoints/clickedPoints
* eg. { selectedPoints: []}
* @param columnGuid - a string guid of the column to drill by. This is optional,
* if not provided it will auto drill by the configured column. \
* @version 1.5.0 or later
*/
DrillDown = "triggerDrillDown",
/**
* Apply filters
* @hidden
*/
Filter = "filter",
/**
* Reload the answer or visualization
* @hidden
*/
Reload = "reload",
/**
* Set the visible visualizations on a Liveboard.
* @param - an array of ids of visualizations to show, the ids not passed
* will be hidden.
* @version 1.6.0 or later
*/
SetVisibleVizs = "SetPinboardVisibleVizs",
/**
* Update the runtime filters. The runtime filters passed here are extended
* on to the existing runtime filters if they exist.
* @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
* @version 1.8.0 or later
*/
UpdateRuntimeFilters = "UpdateRuntimeFilters",
/**
* Highlight the point in the chart defined by the InputPoint passed.
* @verion 1.10.0
*/
HighlightPoint = "HighlightPoint"
}
/**
* The different visual modes that the data sources panel within
* search could appear in, i.e., hidden, collapsed, or expanded.
*/
export enum DataSourceVisualMode {
/**
* Data source panel is hidden.
*/
Hidden = "hide",
/**
* Data source panel is collapsed, but the user can manually expand it.
*/
Collapsed = "collapse",
/**
* Data source panel is expanded, but the user can manually collapse it.
*/
Expanded = "expand"
}
/**
* The query params passed down to the embedded ThoughtSpot app
* containing configuration and/or visual information.
*/
export enum Param {
DataSources = "dataSources",
DataSourceMode = "dataSourceMode",
DisableActions = "disableAction",
DisableActionReason = "disableHint",
ForceTable = "forceTable",
preventLiveboardFilterRemoval = "preventPinboardFilterRemoval",
SearchQuery = "searchQuery",
HideActions = "hideAction",
HideObjects = "hideObjects",
HostAppUrl = "hostAppUrl",
EnableVizTransformations = "enableVizTransform",
EnableSearchAssist = "enableSearchAssist",
HideResult = "hideResult",
UseLastSelectedDataSource = "useLastSelectedSources",
Tag = "tag",
searchTokenString = "searchTokenString",
executeSearch = "executeSearch",
fullHeight = "isFullHeightPinboard",
livedBoardEmbed = "isLiveboardEmbed",
searchEmbed = "isSearchEmbed",
Version = "sdkVersion",
ViewPortHeight = "viewPortHeight",
ViewPortWidth = "viewPortWidth",
VisibleActions = "visibleAction",
CustomCSSUrl = "customCssUrl"
}
/**
* The list of actions that can be performed on visual ThoughtSpot
* entities, such as answers and Liveboards.
*/
export enum Action {
Save = "save",
Update = "update",
SaveUntitled = "saveUntitled",
SaveAsView = "saveAsView",
MakeACopy = "makeACopy",
EditACopy = "editACopy",
CopyLink = "embedDocument",
ResetLayout = "resetLayout",
Schedule = "subscription",
SchedulesList = "schedule-list",
Share = "share",
AddFilter = "addFilter",
ConfigureFilter = "configureFilter",
AddFormula = "addFormula",
SearchOnTop = "searchOnTop",
SpotIQAnalyze = "spotIQAnalyze",
ExplainInsight = "explainInsight",
SpotIQFollow = "spotIQFollow",
ShareViz = "shareViz",
ReplaySearch = "replaySearch",
ShowUnderlyingData = "showUnderlyingData",
Download = "download",
DownloadAsPdf = "downloadAsPdf",
DownloadAsCsv = "downloadAsCSV",
DownloadAsXlsx = "downloadAsXLSX",
DownloadTrace = "downloadTrace",
ExportTML = "exportTSL",
ImportTML = "importTSL",
UpdateTML = "updateTSL",
EditTML = "editTSL",
Present = "present",
ToggleSize = "toggleSize",
Edit = "edit",
EditTitle = "editTitle",
Remove = "delete",
Ungroup = "ungroup",
Describe = "describe",
Relate = "relate",
CustomizeHeadlines = "customizeHeadlines",
/**
* @hidden
*/
PinboardInfo = "pinboardInfo",
LiveboardInfo = "pinboardInfo",
SendAnswerFeedback = "sendFeedback",
DownloadEmbraceQueries = "downloadEmbraceQueries",
Pin = "pin",
AnalysisInfo = "analysisInfo",
Subscription = "subscription",
Explore = "explore",
DrillInclude = "context-menu-item-include",
DrillExclude = "context-menu-item-exclude",
CopyToClipboard = "context-menu-item-copy-to-clipboard",
CopyAndEdit = "context-menu-item-copy-and-edit",
DrillEdit = "context-menu-item-edit",
EditMeasure = "context-menu-item-edit-measure",
Separator = "context-menu-item-separator",
DrillDown = "DRILL",
RequestAccess = "requestAccess",
QueryDetailsButtons = "queryDetailsButtons",
/**
* @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
*/
Monitor = "createMonitor",
/**
* @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
*/
AnswerDelete = "onDeleteAnswer",
/**
* @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
*/
AnswerChartSwitcher = "answerChartSwitcher",
/**
* @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
*/
AddToFavorites = "addToFavorites",
/**
* @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
*/
EditDetails = "editDetails"
}
export interface SessionInterface {
sessionId: string;
genNo: number;
acSession: {
sessionId: string;
genNo: number;
};
}
export enum OperationType {
GetChartWithData = "GetChartWithData",
GetTableWithHeadlineData = "GetTableWithHeadlineData"
}
export interface AnswerServiceType {
getAnswer?: (offset: number, batchSize: number) => any;
}
export interface Plugin {
name: string;
handlers: {
[key in EmbedEvent]?: (payload: any, cb: (data: any) => void) => void;
};
}
}
declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
/**
* Copyright (c) 2022
*
* Base classes
*
* @summary Base classes
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
*/
import { DOMSelector, HostEvent, EmbedEvent, MessageCallback, Action, RuntimeFilter, EmbedConfig, Plugin } from '@thoughtspot/visual-embed-sdk/types';
export interface LayoutConfig {
}
/**
* Embedded iFrame configuration
*/
export interface FrameParams {
/**
* The width of the iFrame (unit is pixels if numeric).
*/
width?: number | string;
/**
* The height of the iFrame (unit is pixels if numeric).
*/
height?: number | string;
}
/**
* The configuration object for an embedded view.
*/
export interface ViewConfig {
/**
* @hidden
*/
layoutConfig?: LayoutConfig;
/**
* The <b>width</b> and <b>height</b> dimensions to render an embedded object inside your app. Specify the values in pixels or percentage.
*/
frameParams?: FrameParams;
/**
* @hidden
*/
theme?: string;
/**
* @hidden
*/
styleSheet__unstable?: string;
/**
* The list of actions to disable from the primary menu, more menu
* (...), and the contextual menu.
*/
disabledActions?: Action[];
/**
* The tooltip to display for disabled actions.
*/
disabledActionReason?: string;
/**
* The list of actions to hide from the primary menu, more menu
* (...), and the contextual menu.
*/
hiddenActions?: Action[];
/**
* The list of actions to display from the primary menu, more menu
* (...), and the contextual menu.
* @version 1.6.0 or later
*/
visibleActions?: Action[];
/**
* The list of runtime filters to apply to a search answer,
* visualization, or Liveboard.
*/
runtimeFilters?: RuntimeFilter[];
/**
* This is an object (key/val) of override flags which will be applied
* to the internal embedded object. This can be used to add any
* URL flag.
* @version 1.8.0
*/
additionalFlags?: {
[key: string]: string | number | boolean;
};
/**
* Provide a list of plugins, the plugins are executed in the order
* provided below,
*
* @version alpha
*/
plugins?: Plugin[];
}
/**
* Base class for embedding v2 experience
* Note: the v2 version of ThoughtSpot Blink is built on the new stack:
* React+GraphQL
*/
export class TsEmbed {
/**
* A reference to the iframe within which the ThoughtSpot app
* will be rendered.
*/
protected iFrame: HTMLIFrameElement;
protected viewConfig: ViewConfig;
protected embedConfig: EmbedConfig;
/**
* The ThoughtSpot hostname or IP address
*/
protected thoughtSpotHost: string;
protected thoughtSpotV2Base: string;
constructor(domSelector: DOMSelector, viewConfig?: ViewConfig);
/**
* Handles errors within the SDK
* @param error The error message or object
*/
protected handleError(error: string | Record<string, unknown>): void;
/**
* Constructs the base URL string to load the ThoughtSpot app.
*/
protected getEmbedBasePath(query: string): string;
/**
* Common query params set for all the embed modes.
* @returns queryParams
*/
protected getBaseQueryParams(): {};
/**
* Constructs the base URL string to load v1 of the ThoughtSpot app.
* This is used for embedding Liveboards, visualizations, and full application.
* @param queryString The query string to append to the URL.
* @param isAppEmbed A Boolean parameter to specify if you are embedding
* the full application.
*/
protected getV1EmbedBasePath(queryString: string, showPrimaryNavbar?: boolean, disableProfileAndHelp?: boolean, 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;
/**
* Sets the height of the iframe
* @param height The height in pixels
*/
protected setIFrameHeight(height: number): void;
/**
* Executes all registered event handlers for a particular event type
* @param eventType The event type
* @param data The payload invoked with the event handler
* @param eventPort The event Port for a specific MessageChannel
*/
protected executeCallbacks(eventType: EmbedEvent, data: any, eventPort?: MessagePort | void): void;
/**
* Returns the ThoughtSpot hostname or IP address.
*/
protected getThoughtSpotHost(): string;
/**
* Gets the v1 event type (if applicable) for the EmbedEvent type
* @param eventType The v2 event type
* @returns The corresponding v1 event type if one exists
* or else the v2 event type itself
*/
protected getCompatibleEventType(eventType: EmbedEvent): EmbedEvent;
/**
* Calculates the iframe center for the current visible viewPort
* of iframe using Scroll position of Host App, offsetTop for iframe
* in Host app. ViewPort height of the tab.
* @returns iframe Center in visible viewport,
* Iframe height,
* View port height.
*/
protected getIframeCenter(): {
iframeCenter: number;
iframeScrolled: number;
iframeHeight: number;
viewPortHeight: number;
iframeVisibleViewPort: number;
};
/**
* Registers an event listener to trigger an alert when the ThoughtSpot app
* sends an event of a particular message type to the host application.
*
* @param messageType The message type
* @param callback A callback function
*/
on(messageType: EmbedEvent, callback: MessageCallback): typeof TsEmbed.prototype;
/**
* Triggers an event to the embedded app
* @param messageType The event type
* @param data The payload to send with the message
*/
trigger(messageType: HostEvent, data: any): typeof TsEmbed.prototype;
/**
* Marks the ThoughtSpot object to have been rendered
* Needs to be overridden by subclasses to do the actual
* rendering of the iframe.
* @param args
*/
render(): TsEmbed;
}
/**
* Base class for embedding v1 experience
* Note: The v1 version of ThoughtSpot Blink works on the AngularJS stack
* which is currently under migration to v2
*/
export 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;
on(messageType: EmbedEvent, callback: MessageCallback): typeof TsEmbed.prototype;
}
}