@thoughtspot/visual-embed-sdk 1.20.0 → 1.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/src/auth.d.ts +38 -4
  2. package/dist/src/auth.d.ts.map +1 -1
  3. package/dist/src/embed/app.d.ts +2 -2
  4. package/dist/src/embed/base.d.ts +25 -14
  5. package/dist/src/embed/base.d.ts.map +1 -1
  6. package/dist/src/embed/liveboard.d.ts +13 -3
  7. package/dist/src/embed/liveboard.d.ts.map +1 -1
  8. package/dist/src/embed/search-bar.d.ts +4 -1
  9. package/dist/src/embed/search-bar.d.ts.map +1 -1
  10. package/dist/src/embed/search.d.ts +2 -2
  11. package/dist/src/embed/ts-embed.d.ts +35 -1
  12. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  13. package/dist/src/index.d.ts +3 -3
  14. package/dist/src/index.d.ts.map +1 -1
  15. package/dist/src/react/index.d.ts.map +1 -1
  16. package/dist/src/types.d.ts +201 -27
  17. package/dist/src/types.d.ts.map +1 -1
  18. package/dist/tsembed.es.js +247 -38
  19. package/dist/tsembed.js +228 -38
  20. package/lib/package.json +2 -3
  21. package/lib/src/auth.d.ts +38 -4
  22. package/lib/src/auth.d.ts.map +1 -1
  23. package/lib/src/auth.js +17 -2
  24. package/lib/src/auth.js.map +1 -1
  25. package/lib/src/embed/app.d.ts +2 -2
  26. package/lib/src/embed/app.js +1 -1
  27. package/lib/src/embed/base.d.ts +25 -14
  28. package/lib/src/embed/base.d.ts.map +1 -1
  29. package/lib/src/embed/base.js +24 -4
  30. package/lib/src/embed/base.js.map +1 -1
  31. package/lib/src/embed/base.spec.js +2 -2
  32. package/lib/src/embed/base.spec.js.map +1 -1
  33. package/lib/src/embed/liveboard.d.ts +13 -3
  34. package/lib/src/embed/liveboard.d.ts.map +1 -1
  35. package/lib/src/embed/liveboard.js +12 -2
  36. package/lib/src/embed/liveboard.js.map +1 -1
  37. package/lib/src/embed/search-bar.d.ts +4 -1
  38. package/lib/src/embed/search-bar.d.ts.map +1 -1
  39. package/lib/src/embed/search-bar.js +1 -1
  40. package/lib/src/embed/search-bar.js.map +1 -1
  41. package/lib/src/embed/search.d.ts +2 -2
  42. package/lib/src/embed/search.js +1 -1
  43. package/lib/src/embed/ts-embed.d.ts +35 -1
  44. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  45. package/lib/src/embed/ts-embed.js +35 -2
  46. package/lib/src/embed/ts-embed.js.map +1 -1
  47. package/lib/src/index.d.ts +3 -3
  48. package/lib/src/index.d.ts.map +1 -1
  49. package/lib/src/index.js +1 -1
  50. package/lib/src/index.js.map +1 -1
  51. package/lib/src/react/index.d.ts.map +1 -1
  52. package/lib/src/react/index.js +4 -2
  53. package/lib/src/react/index.js.map +1 -1
  54. package/lib/src/react/index.spec.js +14 -2
  55. package/lib/src/react/index.spec.js.map +1 -1
  56. package/lib/src/types.d.ts +201 -27
  57. package/lib/src/types.d.ts.map +1 -1
  58. package/lib/src/types.js +155 -24
  59. package/lib/src/types.js.map +1 -1
  60. package/lib/src/visual-embed-sdk.d.ts +323 -57
  61. package/package.json +2 -3
  62. package/src/auth.ts +51 -5
  63. package/src/embed/app.ts +2 -2
  64. package/src/embed/base.spec.ts +3 -3
  65. package/src/embed/base.ts +30 -9
  66. package/src/embed/liveboard.ts +13 -3
  67. package/src/embed/search-bar.tsx +4 -1
  68. package/src/embed/search.ts +2 -2
  69. package/src/embed/ts-embed.ts +35 -2
  70. package/src/index.ts +24 -2
  71. package/src/react/index.spec.tsx +35 -2
  72. package/src/react/index.tsx +10 -2
  73. package/src/types.ts +202 -26
@@ -17,9 +17,9 @@ declare module '@thoughtspot/visual-embed-sdk' {
17
17
  import { PinboardEmbed, LiveboardViewConfig, LiveboardEmbed } from '@thoughtspot/visual-embed-sdk/embed/liveboard';
18
18
  import { SearchEmbed, SearchViewConfig } from '@thoughtspot/visual-embed-sdk/embed/search';
19
19
  import { SearchBarEmbed, SearchBarViewConfig } from '@thoughtspot/visual-embed-sdk/embed/search-bar';
20
- import { AuthFailureType, AuthStatus, AuthEvent, getSessionInfo } from '@thoughtspot/visual-embed-sdk/auth';
21
- import { AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, PrefetchFeatures } from '@thoughtspot/visual-embed-sdk/types';
22
- export { init, logout, prefetch, getEmbedConfig as getInitConfig, getSessionInfo, SearchEmbed, SearchBarEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, AuthFailureType, AuthStatus, AuthEvent, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, SearchBarViewConfig, LiveboardViewConfig, AppViewConfig, PrefetchFeatures, };
20
+ import { AuthFailureType, AuthStatus, AuthEvent, AuthEventEmitter, getSessionInfo } from '@thoughtspot/visual-embed-sdk/auth';
21
+ import { AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, PrefetchFeatures, FrameParams, DOMSelector, MessageOptions, MessageCallback, MessagePayload, CustomisationsInterface, CustomStyles, customCssInterface } from '@thoughtspot/visual-embed-sdk/types';
22
+ export { init, logout, prefetch, getEmbedConfig as getInitConfig, getSessionInfo, SearchEmbed, SearchBarEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, AuthFailureType, AuthStatus, AuthEvent, AuthEventEmitter, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, SearchBarViewConfig, LiveboardViewConfig, AppViewConfig, PrefetchFeatures, FrameParams, DOMSelector, MessageOptions, MessageCallback, MessagePayload, CustomisationsInterface, CustomStyles, customCssInterface, };
23
23
  }
24
24
 
25
25
  declare module '@thoughtspot/visual-embed-sdk/embed/app' {
@@ -70,7 +70,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
70
70
  }
71
71
  /**
72
72
  * The view configuration for full app embedding.
73
- * @Category App Embed
73
+ * @group Embed components
74
74
  */
75
75
  export interface AppViewConfig extends ViewConfig {
76
76
  /**
@@ -118,7 +118,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
118
118
  }
119
119
  /**
120
120
  * Embeds full ThoughtSpot experience in a host application.
121
- * @Category App Embed
121
+ * @group Embed components
122
122
  */
123
123
  export class AppEmbed extends V1Embed {
124
124
  protected viewConfig: AppViewConfig;
@@ -143,18 +143,16 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
143
143
  }
144
144
 
145
145
  declare module '@thoughtspot/visual-embed-sdk/embed/base' {
146
+ import { EmbedConfig, PrefetchFeatures } from '@thoughtspot/visual-embed-sdk/types';
147
+ import { notifyAuthFailure, notifyAuthSDKSuccess, notifyAuthSuccess, notifyLogout, AuthEventEmitter } from '@thoughtspot/visual-embed-sdk/auth';
148
+ export let authPromise: Promise<boolean>;
146
149
  /**
147
- * Copyright (c) 2022
148
- *
149
- * Base classes
150
+ * Gets the configuration embed was initialized with.
150
151
  *
151
- * @summary Base classes
152
- * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
152
+ * @returns {@link EmbedConfig} The configuration embed was initialized with.
153
+ * @version SDK: 1.19.0 | ThoughtSpot: *
154
+ * @group Global methods
153
155
  */
154
- import EventEmitter from 'eventemitter3';
155
- import { EmbedConfig, PrefetchFeatures } from '@thoughtspot/visual-embed-sdk/types';
156
- import { notifyAuthFailure, notifyAuthSDKSuccess, notifyAuthSuccess, notifyLogout } from '@thoughtspot/visual-embed-sdk/auth';
157
- export let authPromise: Promise<boolean>;
158
156
  export const getEmbedConfig: () => EmbedConfig;
159
157
  export const getAuthPromise: () => Promise<boolean>;
160
158
  export { notifyAuthFailure, notifyAuthSDKSuccess, notifyAuthSuccess, notifyLogout, };
@@ -167,19 +165,31 @@ declare module '@thoughtspot/visual-embed-sdk/embed/base' {
167
165
  * @param url The URL provided for prefetch
168
166
  * @param prefetchFeatures Specify features which needs to be prefetched.
169
167
  * @version SDK: 1.4.0 | ThoughtSpot: ts7.sep.cl, 7.2.1
168
+ * @group Global methods
170
169
  */
171
170
  export const prefetch: (url?: string, prefetchFeatures?: PrefetchFeatures[]) => void;
172
171
  /**
173
172
  * Initializes the Visual Embed SDK globally and perform
174
- * authentication if applicable.
173
+ * authentication if applicable. This function needs to be called before any ThoughtSpot
174
+ * component like liveboard etc can be embedded. But need not wait for AuthEvent.SUCCESS
175
+ * to actually embed. That is handled internally.
175
176
  * @param embedConfig The configuration object containing ThoughtSpot host,
176
177
  * authentication mechanism and so on.
177
- * example: authStatus = init(config);
178
- * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
179
- * @returns event emitter which emits events on authentication success, failure and logout. See {@link AuthStatus}
178
+ *
179
+ * @example
180
+ * ```js
181
+ * const authStatus = init({
182
+ * thoughtSpotHost: 'https://my.thoughtspot.cloud',
183
+ * authType: AuthType.None,
184
+ * });
185
+ * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
186
+ * ```
187
+ *
188
+ * @returns {@link AuthEventEmitter} event emitter which emits events on authentication success, failure and logout. See {@link AuthStatus}
180
189
  * @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
190
+ * @group Authentication / Init
181
191
  */
182
- export const init: (embedConfig: EmbedConfig) => EventEmitter;
192
+ export const init: (embedConfig: EmbedConfig) => AuthEventEmitter;
183
193
  export function disableAutoLogin(): void;
184
194
  /**
185
195
  * Logs out from ThoughtSpot. This also sets the autoLogin flag to false, to prevent
@@ -191,6 +201,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/base' {
191
201
  * @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
192
202
  * @returns Promise which resolves when logout completes.
193
203
  * @version SDK: 1.10.1 | ThoughtSpot: 8.2.0.cl, 8.4.1-sw
204
+ * @group Global methods
194
205
  */
195
206
  export const logout: (doNotDisableAutoLogin?: boolean) => Promise<boolean>;
196
207
  /**
@@ -216,7 +227,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
216
227
  import { V1Embed } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
217
228
  /**
218
229
  * The configuration for the embedded Liveboard or visualization page view.
219
- * @Category Liveboards and Charts
230
+ * @group Embed components
220
231
  */
221
232
  export interface LiveboardViewConfig extends ViewConfig {
222
233
  /**
@@ -282,8 +293,18 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
282
293
  activeTabId?: string;
283
294
  }
284
295
  /**
285
- * Embed a ThoughtSpot Liveboard or visualization
286
- * @Category Liveboards and Charts
296
+ * Embed a ThoughtSpot Liveboard or a Thoughtspot visualization. When rendered it already
297
+ * waits for the authentication to complete, so no need to wait for AuthStatus.SUCCESS.
298
+ * @example
299
+ * ```js
300
+ * import { .. } from '@thoughtspot/visual-embed-sdk';
301
+ * init({ ... });
302
+ * const embed = new LiveboardEmbed("#container", {
303
+ * liveboardId: <your-id-here>,
304
+ * // .. other params here.
305
+ * })
306
+ * ```
307
+ * @group Embed components
287
308
  */
288
309
  export class LiveboardEmbed extends V1Embed {
289
310
  protected viewConfig: LiveboardViewConfig;
@@ -337,7 +358,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
337
358
  /**
338
359
  * The configuration attributes for the embedded search view.
339
360
  *
340
- * @Category Search Embed
361
+ * @group Embed components
341
362
  */
342
363
  export interface SearchViewConfig extends ViewConfig {
343
364
  /**
@@ -404,7 +425,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
404
425
  /**
405
426
  * Embed ThoughtSpot search
406
427
  *
407
- * @Category Search Embed
428
+ * @group Embed components
408
429
  */
409
430
  export class SearchEmbed extends TsEmbed {
410
431
  /**
@@ -423,6 +444,9 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search-bar' {
423
444
  import { ViewConfig } from '@thoughtspot/visual-embed-sdk/types';
424
445
  import { TsEmbed } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
425
446
  import { SearchOptions } from '@thoughtspot/visual-embed-sdk/embed/search';
447
+ /**
448
+ * @group Embed components
449
+ */
426
450
  export interface SearchBarViewConfig extends Omit<ViewConfig, 'runtimeFilters' | 'showAlerts'> {
427
451
  /**
428
452
  * The array of data source GUIDs to set on load.
@@ -443,8 +467,8 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search-bar' {
443
467
  /**
444
468
  * Embed ThoughtSpot search bar
445
469
  *
446
- * @Category Search Embed
447
470
  * @version: SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl, 9.0.1-sw
471
+ * @group Embed components
448
472
  */
449
473
  export class SearchBarEmbed extends TsEmbed {
450
474
  /**
@@ -474,12 +498,21 @@ declare module '@thoughtspot/visual-embed-sdk/auth' {
474
498
  BASIC_LOGIN: string;
475
499
  LOGOUT: string;
476
500
  };
501
+ /**
502
+ * Enum for auth failure types. This is the parameter passed to the listner
503
+ * of {@link AuthStatus.FAILURE}.
504
+ * @group Authentication / Init
505
+ */
477
506
  export enum AuthFailureType {
478
507
  SDK = "SDK",
479
508
  NO_COOKIE_ACCESS = "NO_COOKIE_ACCESS",
480
509
  EXPIRY = "EXPIRY",
481
510
  OTHER = "OTHER"
482
511
  }
512
+ /**
513
+ * Enum for auth status emitted by the emitter returned from {@link init}.
514
+ * @group Authentication / Init
515
+ */
483
516
  export enum AuthStatus {
484
517
  /**
485
518
  * Emits when the SDK fails to authenticate
@@ -505,14 +538,38 @@ declare module '@thoughtspot/visual-embed-sdk/auth' {
505
538
  */
506
539
  WAITING_FOR_POPUP = "WAITING_FOR_POPUP"
507
540
  }
541
+ /**
542
+ * Event emitter returned from {@link init}.
543
+ * @group Authentication / Init
544
+ */
545
+ export interface AuthEventEmitter {
546
+ /**
547
+ * Registed a listener on Auth failure.
548
+ * @param event
549
+ * @param listener
550
+ */
551
+ on(event: AuthStatus.FAILURE, listener: (failureType: AuthFailureType) => void): this;
552
+ on(event: AuthStatus.SDK_SUCCESS | AuthStatus.LOGOUT | AuthStatus.WAITING_FOR_POPUP, listener: () => void): this;
553
+ on(event: AuthStatus.SUCCESS, listener: (sessionInfo: any) => void): this;
554
+ /**
555
+ * Trigger an event on the emitter returned from init.
556
+ * @param {@link AuthEvent}
557
+ */
558
+ emit(event: AuthEvent): void;
559
+ }
560
+ /**
561
+ * Events which can be triggered on the emitter returned from {@link init}.
562
+ * @group Authentication / Init
563
+ */
508
564
  export enum AuthEvent {
509
565
  /**
510
- * Manually trigger the SSO popup.
566
+ * Manually trigger the SSO popup. This is useful with
567
+ * authStatus: SAMLRedirect/OIDCRedicre and inPopup: true
511
568
  */
512
569
  TRIGGER_SSO_POPUP = "TRIGGER_SSO_POPUP"
513
570
  }
514
- export function getAuthEE(): EventEmitter;
515
- export function setAuthEE(eventEmitter: EventEmitter): void;
571
+ export function getAuthEE(): EventEmitter<AuthStatus | AuthEvent>;
572
+ export function setAuthEE(eventEmitter: EventEmitter<AuthStatus | AuthEvent>): void;
516
573
  export function notifyAuthSDKSuccess(): void;
517
574
  export function notifyAuthSuccess(): void;
518
575
  export function notifyAuthFailure(failureType: AuthFailureType): void;
@@ -522,8 +579,9 @@ declare module '@thoughtspot/visual-embed-sdk/auth' {
522
579
  */
523
580
  export function getReleaseVersion(): string;
524
581
  /**
525
- * Return a promise that resolves with the session info when authentication is
582
+ * Return a promise that resolves with the session information when authentication is
526
583
  * successful. And info is available.
584
+ * @group Global methods
527
585
  */
528
586
  export function getSessionInfo(): Promise<any>;
529
587
  export function initSession(sessionDetails: any): void;
@@ -565,6 +623,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
565
623
  /**
566
624
  * The authentication mechanism for allowing access to the
567
625
  * the embedded app
626
+ * @group Authentication / Init
568
627
  */
569
628
  export enum AuthType {
570
629
  /**
@@ -591,7 +650,47 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
591
650
  SAML = "SSO_SAML",
592
651
  /**
593
652
  * SSO using SAML
594
- * Will make the host application redirect to the SAML Idp.
653
+ * Will make the host application redirect to the SAML Idp. Use this
654
+ * when the idp does not allow itself to be embedded.
655
+ *
656
+ * This redirects the host application to the SAML Idp. The host application
657
+ * will be redirected back to the ThoughtSpot app after authentication.
658
+ * @example
659
+ * ```js
660
+ * init({
661
+ * // ...
662
+ * authType: AuthType.SAMLRedirect,
663
+ * });
664
+ * ```
665
+ *
666
+ * This opens the SAML Idp in a popup window. The popup is triggered
667
+ * when the user clicks the trigger button. The popup window will be
668
+ * closed automatically after authentication.
669
+ * @example
670
+ * ```js
671
+ * init({
672
+ * // ...
673
+ * authType: AuthType.SAMLRedirect,
674
+ * authTriggerText: 'Login with SAML',
675
+ * authTriggerContainer: '#embed-container',
676
+ * inPopup: true,
677
+ * });
678
+ * ```
679
+ *
680
+ * Can also use event to trigger the popup flow. Works the same
681
+ * as above example.
682
+ * @example
683
+ * ```js
684
+ * const authEE = init({
685
+ * // ...
686
+ * authType: AuthType.SAMLRedirect,
687
+ * inPopup: true,
688
+ * });
689
+ *
690
+ * someButtonOnYourPage.addEventListener('click', () => {
691
+ * authEE.emit(AuthEvent.TRIGGER_SSO_POPUP);
692
+ * });
693
+ * ```
595
694
  */
596
695
  SAMLRedirect = "SSO_SAML",
597
696
  /**
@@ -603,6 +702,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
603
702
  /**
604
703
  * SSO using OIDC
605
704
  * Will make the host application redirect to the OIDC Idp.
705
+ * See code samples in {@link SAMLRedirect}.
606
706
  */
607
707
  OIDCRedirect = "SSO_OIDC",
608
708
  /**
@@ -615,6 +715,18 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
615
715
  * Trusted authentication server, Use your own authentication server
616
716
  * which returns a bearer token, generated using the secret_key obtained from
617
717
  * ThoughtSpot.
718
+ *
719
+ * @example
720
+ * ```js
721
+ * init({
722
+ * // ...
723
+ * authType: AuthType.TrustedAuthToken,
724
+ * getAuthToken: () => {
725
+ * return fetch('https://my-backend.app/ts-token')
726
+ * .then((response) => response.json())
727
+ * .then((data) => data.token);
728
+ * }
729
+ * ```
618
730
  */
619
731
  TrustedAuthToken = "AuthServer",
620
732
  /**
@@ -633,7 +745,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
633
745
  Basic = "Basic"
634
746
  }
635
747
  export type DOMSelector = string | HTMLElement;
636
- interface customCssInterface {
748
+ /**
749
+ * inline customCSS within the {@link CustomisationsInterface}.
750
+ */
751
+ export interface customCssInterface {
637
752
  variables?: {
638
753
  [variableName: string]: string;
639
754
  };
@@ -643,10 +758,38 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
643
758
  };
644
759
  };
645
760
  }
646
- interface CustomStyles {
761
+ /**
762
+ * Styles within the {@link CustomisationsInterface}.
763
+ */
764
+ export interface CustomStyles {
647
765
  customCSSUrl?: string;
648
766
  customCSS?: customCssInterface;
649
767
  }
768
+ /**
769
+ * Configuration to define the customization on the Embedded
770
+ * Thoughtspot components.
771
+ *
772
+ * @example
773
+ * ```js
774
+ * init({
775
+ * // ...
776
+ * customizations: {
777
+ * style: {
778
+ * customCSS: {
779
+ * variables: {},
780
+ * rules_UNSTABLE: {}
781
+ * }
782
+ * },
783
+ * content: {
784
+ * strings: {
785
+ * 'LIVEBOARDS': 'Dashboards'
786
+ * }
787
+ * },
788
+ * iconSpriteUrl: 'https://my-custom-icon-sprite.svg'
789
+ * }
790
+ * })
791
+ * ```
792
+ */
650
793
  export interface CustomisationsInterface {
651
794
  style?: CustomStyles;
652
795
  content?: {
@@ -660,6 +803,8 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
660
803
  * It includes the ThoughtSpot hostname or IP address,
661
804
  * the type of authentication, and the authentication endpoint
662
805
  * if a trusted authentication server is used.
806
+ *
807
+ * @group Authentication / Init
663
808
  */
664
809
  export interface EmbedConfig {
665
810
  /**
@@ -820,6 +965,8 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
820
965
  }
821
966
  /**
822
967
  * Embedded iFrame configuration
968
+ *
969
+ * @group Embed components
823
970
  */
824
971
  export interface FrameParams {
825
972
  /**
@@ -830,6 +977,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
830
977
  * The height of the iFrame (unit is pixels if numeric).
831
978
  */
832
979
  height?: number | string;
980
+ /**
981
+ * Set to 'lazy' to enable lazy loading of the embedded TS frame.
982
+ * This will defer loading of the frame until it comes into the
983
+ * viewport. This is useful for performance optimization.
984
+ */
985
+ loading?: 'lazy' | 'eager' | 'auto';
833
986
  /**
834
987
  * This parameters will be passed on the iframe
835
988
  * as is.
@@ -933,6 +1086,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
933
1086
  }
934
1087
  /**
935
1088
  * MessagePayload: Embed event payload: message type, data and status (start/end)
1089
+ * @group Events
936
1090
  */
937
1091
  export type MessagePayload = {
938
1092
  type: string;
@@ -941,12 +1095,14 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
941
1095
  };
942
1096
  /**
943
1097
  * MessageOptions: By Providing options, getting specific event start / end based on option
1098
+ * @group Events
944
1099
  */
945
1100
  export type MessageOptions = {
946
1101
  start?: boolean;
947
1102
  };
948
1103
  /**
949
1104
  * MessageCallback: Embed event message callback
1105
+ * @group Events
950
1106
  */
951
1107
  export type MessageCallback = (payload: MessagePayload, responder?: (data: any) => void) => void;
952
1108
  /**
@@ -1042,6 +1198,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1042
1198
  }
1043
1199
  /**
1044
1200
  * Event types emitted by the embedded ThoughtSpot application.
1201
+ *
1202
+ * To add an event listener use the corresponding
1203
+ * {@link LiveboardEmbed.on} or {@link AppEmbed.on} or {@link SearchEmbed.on} method.
1204
+ * @group Events
1045
1205
  */
1046
1206
  export enum EmbedEvent {
1047
1207
  /**
@@ -1206,6 +1366,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1206
1366
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
1207
1367
  */
1208
1368
  Download = "download",
1369
+ /**
1370
+ * Emitted when the download action is triggered on an answer
1371
+ *
1372
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl, 9.4.0-sw
1373
+ */
1374
+ DownloadAsPng = "downloadAsPng",
1209
1375
  /**
1210
1376
  * Emitted when the Download as PDF action is triggered on an answer
1211
1377
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
@@ -1368,6 +1534,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1368
1534
  *
1369
1535
  * To trigger an event use the corresponding
1370
1536
  * {@link LiveboardEmbed.trigger} or {@link AppEmbed.trigger} or {@link SearchEmbed.trigger} method.
1537
+ * @group Events
1371
1538
  */
1372
1539
  export enum HostEvent {
1373
1540
  /**
@@ -1378,11 +1545,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1378
1545
  * @param - searchQuery - The search query
1379
1546
  * @param - execute - execute the existing / updated query
1380
1547
  * @example
1548
+ * ```js
1381
1549
  * searchEmbed.trigger(HostEvent.Search, {
1382
- * searchQuery: "[sales] by [item type],
1383
- * "dataSourceIds: ["cd252e5c-b552-49a8-821d-3eadaa049cca"]
1384
- * "execute": true
1550
+ * searchQuery: "[sales] by [item type],
1551
+ * dataSourceIds: ["cd252e5c-b552-49a8-821d-3eadaa049cca"]
1552
+ * execute: true
1385
1553
  * })
1554
+ * ```
1386
1555
  */
1387
1556
  Search = "search",
1388
1557
  /**
@@ -1391,10 +1560,14 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1391
1560
  * eg. { selectedPoints: []}
1392
1561
  * @param - columnGuid - a string guid of the column to drill by. This is optional,
1393
1562
  * if not provided it will auto drill by the configured column.
1394
- * @example searchEmbed.trigger(HostEvent.DrillDown, {
1395
- * points: clickedPointData,
1396
- * autoDrillDown: true,
1563
+ * @example
1564
+ * ```js
1565
+ * searchEmbed.trigger(HostEvent.DrillDown, {
1566
+ * points: clickedPointData,
1567
+ * autoDrillDown: true,
1397
1568
  * })
1569
+ * ```
1570
+ *
1398
1571
  * @version SDK: 1.5.0 | ThoughtSpot: ts7.oct.cl, 7.2.1
1399
1572
  */
1400
1573
  DrillDown = "triggerDrillDown",
@@ -1433,7 +1606,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1433
1606
  * Navigate to a specific page in App embed without any reload.
1434
1607
  * This is the same as calling `appEmbed.navigateToPage(path, true)`
1435
1608
  * @param - path - the path to navigate to (can be a number[1/-1] to go forward/back)
1436
- * @example appEmbed.navigateToPage(-1)
1609
+ * @example
1610
+ * ```js
1611
+ * appEmbed.navigateToPage(-1)
1612
+ * ```
1437
1613
  * @version SDK: 1.12.0 | ThoughtSpot 8.4.0.cl, 8.4.1-sw
1438
1614
  */
1439
1615
  Navigate = "Navigate",
@@ -1441,27 +1617,39 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1441
1617
  * Opens the filter panel for a particular column.
1442
1618
  * Works with Search embed.
1443
1619
  * @param - { columnId: string, name: string, type: INT64/CHAR/DATE, dataType: ATTRIBUTE/MEASURE }
1444
- * @example searchEmbed.trigger(HostEvent.OpenFilter, { columnId: '123', name: 'column name', type: 'INT64', dataType: 'ATTRIBUTE' })
1620
+ * @example
1621
+ * ```js
1622
+ * searchEmbed.trigger(HostEvent.OpenFilter, { columnId: '123', name: 'column name', type: 'INT64', dataType: 'ATTRIBUTE' })
1623
+ * ```
1445
1624
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1446
1625
  */
1447
1626
  OpenFilter = "openFilter",
1448
1627
  /**
1449
1628
  * Adds the columns to the current Search.
1450
1629
  * @param - { columnIds: string[] }
1451
- * @example searchEmbed.trigger(HostEvent.AddColumns, { columnIds: ['123', '456'] })
1630
+ * @example
1631
+ * ```js
1632
+ * searchEmbed.trigger(HostEvent.AddColumns, { columnIds: ['123', '456'] })
1633
+ * ```
1452
1634
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1453
1635
  */
1454
1636
  AddColumns = "addColumns",
1455
1637
  /**
1456
1638
  * Removes a column from the current Search.
1457
1639
  * @param - { columnId: string }
1458
- * @example - searchEmbed.trigger(HostEvent.RemoveColumn, { columnId: '123' })
1640
+ * @example
1641
+ * ```js
1642
+ * searchEmbed.trigger(HostEvent.RemoveColumn, { columnId: '123' })
1643
+ * ```
1459
1644
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
1460
1645
  */
1461
1646
  RemoveColumn = "removeColumn",
1462
1647
  /**
1463
1648
  * Gets the current pinboard content.
1464
- * @example liveboardEmbed.trigger(HostEvent.getExportRequestForCurrentPinboard)
1649
+ * @example
1650
+ * ```js
1651
+ * liveboardEmbed.trigger(HostEvent.getExportRequestForCurrentPinboard)
1652
+ * ```
1465
1653
  * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
1466
1654
  */
1467
1655
  getExportRequestForCurrentPinboard = "getExportRequestForCurrentPinboard",
@@ -1470,87 +1658,124 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1470
1658
  * @param - incase of Liveboard embed, takes in an object with vizId as a key
1471
1659
  * can be left empty for search and visualization embeds
1472
1660
  * @example
1661
+ * ```js
1473
1662
  * liveboardEmbed.trigger(HostEvent.Pin, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
1474
1663
  * vizEmbed.trigger(HostEvent.Pin)
1475
1664
  * searchEmbed.trigger(HostEvent.Pin)
1665
+ * ```
1476
1666
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1477
1667
  */
1478
1668
  Pin = "pin",
1479
1669
  /**
1480
1670
  * Triggers the Show Liveboard details action on a Liveboard
1481
- * @example liveboardEmbed.trigger(HostEvent.LiveboardInfo)
1671
+ * @example
1672
+ * ```js
1673
+ * liveboardEmbed.trigger(HostEvent.LiveboardInfo)
1674
+ * ```
1482
1675
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1483
1676
  */
1484
1677
  LiveboardInfo = "pinboardInfo",
1485
1678
  /**
1486
1679
  * Triggers the Schedule action on a Liveboard
1487
- * @example liveboardEmbed.trigger(HostEvent.Schedule)
1680
+ * @example
1681
+ * ```js
1682
+ * liveboardEmbed.trigger(HostEvent.Schedule)
1683
+ * ```
1488
1684
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1489
1685
  */
1490
1686
  Schedule = "subscription",
1491
1687
  /**
1492
1688
  * Triggers the Manage schedule action on a Liveboard
1493
- * @example liveboardEmbed.trigger(HostEvent.ScheduleList)
1689
+ * @example
1690
+ * ```js
1691
+ * liveboardEmbed.trigger(HostEvent.ScheduleList)
1692
+ * ```
1494
1693
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1495
1694
  */
1496
1695
  SchedulesList = "schedule-list",
1497
1696
  /**
1498
1697
  * Triggers the Export TML action on a Liveboard
1499
- * @example liveboardEmbed.trigger(HostEvent.ExportTML)
1698
+ * @example
1699
+ * ```js
1700
+ * liveboardEmbed.trigger(HostEvent.ExportTML)
1701
+ * ```
1500
1702
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1501
1703
  */
1502
1704
  ExportTML = "exportTSL",
1503
1705
  /**
1504
1706
  * Triggers the Edit TML action on a Liveboard
1505
- * @example liveboardEmbed.trigger(HostEvent.EditTML)
1707
+ * @example
1708
+ * ```js
1709
+ * liveboardEmbed.trigger(HostEvent.EditTML)
1710
+ * ```
1506
1711
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1507
1712
  */
1508
1713
  EditTML = "editTSL",
1509
1714
  /**
1510
1715
  * Triggers the Update TML action on a Liveboard
1511
- * @example liveboardEmbed.trigger(HostEvent.UpdateTML)
1716
+ * @example
1717
+ * ```js
1718
+ * liveboardEmbed.trigger(HostEvent.UpdateTML)
1719
+ * ```
1512
1720
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1513
1721
  */
1514
1722
  UpdateTML = "updateTSL",
1515
1723
  /**
1516
1724
  * Triggers the Download PDF action on a Liveboard
1517
- * @example liveboardEmbed.trigger(HostEvent.DownloadAsPDF)
1725
+ * @example
1726
+ * ```js
1727
+ * liveboardEmbed.trigger(HostEvent.DownloadAsPDF)
1728
+ * ```
1518
1729
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1519
1730
  */
1520
1731
  DownloadAsPdf = "downloadAsPdf",
1521
1732
  /**
1522
1733
  * Triggers the Make a copy action on a Liveboard, search or visualization
1523
1734
  * @example
1735
+ * ```js
1524
1736
  * liveboardEmbed.trigger(HostEvent.MakeACopy, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
1525
1737
  * vizEmbed.trigger(HostEvent.MakeACopy)
1526
1738
  * searchEmbed.trigger(HostEvent.MakeACopy)
1739
+ * ```
1527
1740
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1528
1741
  */
1529
1742
  MakeACopy = "makeACopy",
1530
1743
  /**
1531
1744
  * Triggers the Delete action on a Liveboard
1532
- * @example appEmbed.trigger(HostEvent.Remove)
1745
+ * @example
1746
+ * ```js
1747
+ * appEmbed.trigger(HostEvent.Remove)
1748
+ * ```
1533
1749
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1534
1750
  */
1535
1751
  Remove = "delete",
1536
1752
  /**
1537
1753
  * Triggers the Explore action on a visualization
1538
1754
  * @param - an object with vizId as a key
1539
- * @example liveboardEmbed.trigger(HostEvent.Explore, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
1755
+ * @example
1756
+ * ```js
1757
+ * liveboardEmbed.trigger(HostEvent.Explore, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
1758
+ * ```
1540
1759
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1541
1760
  */
1542
1761
  Explore = "explore",
1543
1762
  /**
1544
1763
  * Triggers the Create alert action on a visualization
1545
1764
  * @param - an object with vizId as a key
1546
- * @example liveboardEmbed.trigger(HostEvent.CreateMonitor {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
1765
+ * @example
1766
+ * ```js
1767
+ * liveboardEmbed.trigger(HostEvent.CreateMonitor {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
1768
+ * ```
1547
1769
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1548
1770
  */
1549
1771
  CreateMonitor = "createMonitor",
1550
1772
  /**
1551
1773
  * Triggers the Manage alert action on a visualization
1552
1774
  * @param - an object with vizId as a key
1553
- * @example liveboardEmbed.trigger(HostEvent.ManageMonitor, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
1775
+ * @example
1776
+ * ```js
1777
+ * liveboardEmbed.trigger(HostEvent.ManageMonitor, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
1778
+ * ```
1554
1779
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1555
1780
  */
1556
1781
  ManageMonitor = "manageMonitor",
@@ -1568,9 +1793,11 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1568
1793
  * Triggers the Copy link action on a Liveboard or visualization
1569
1794
  * @param - object - to trigger the action for a specfic visualization in Liveboard embed, pass in vizId as a key
1570
1795
  * @example
1796
+ * ```js
1571
1797
  * liveboardEmbed.trigger(HostEvent.CopyLink)
1572
1798
  * liveboardEmbed.trigger(HostEvent.CopyLink, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
1573
1799
  * vizEmbed.trigger((HostEvent.CopyLink)
1800
+ * ```
1574
1801
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1575
1802
  */
1576
1803
  CopyLink = "embedDocument",
@@ -1578,15 +1805,20 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1578
1805
  * Triggers the Present action on a Liveboard or visualization
1579
1806
  * @param - object - to trigger the action for a specfic visualization in Liveboard embed, pass in vizId as a key
1580
1807
  * @example
1808
+ * ```js
1581
1809
  * liveboardEmbed.trigger(HostEvent.Present)
1582
1810
  * liveboardEmbed.trigger(HostEvent.Present, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
1583
1811
  * vizEmbed.trigger((HostEvent.Present)
1812
+ * ```
1584
1813
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
1585
1814
  */
1586
1815
  Present = "present",
1587
1816
  /**
1588
1817
  * Get TML for the current search.
1589
- * @example searchEmbed.trigger(HostEvent.GetTML)
1818
+ * @example
1819
+ * ```js
1820
+ * searchEmbed.trigger(HostEvent.GetTML)
1821
+ * ```
1590
1822
  * @version SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl, 9.0.1-sw
1591
1823
  */
1592
1824
  GetTML = "getTML",
@@ -1814,6 +2046,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1814
2046
  ReplaySearch = "replaySearch",
1815
2047
  ShowUnderlyingData = "showUnderlyingData",
1816
2048
  Download = "download",
2049
+ DownloadAsPng = "downloadAsPng",
1817
2050
  DownloadAsPdf = "downloadAsPdf",
1818
2051
  DownloadAsCsv = "downloadAsCSV",
1819
2052
  DownloadAsXlsx = "downloadAsXLSX",
@@ -1995,7 +2228,6 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1995
2228
  LEFT_CLICK = "left-click",
1996
2229
  RIGHT_CLICK = "right-click"
1997
2230
  }
1998
- export {};
1999
2231
  }
2000
2232
 
2001
2233
  declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
@@ -2106,6 +2338,20 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
2106
2338
  * @param messageType The message type
2107
2339
  * @param callback A callback as a function
2108
2340
  * @param options The message options
2341
+ * @example
2342
+ * ```js
2343
+ * tsEmbed.on(EmbedEvent.Error, (data) => {
2344
+ * console.error(data);
2345
+ * });
2346
+ * ```
2347
+ * @example
2348
+ * ```js
2349
+ * tsEmbed.on(EmbedEvent.Save, (data) => {
2350
+ * console.log("Answer save clicked", data);
2351
+ * }, {
2352
+ * start: true // This will trigger the callback on start of save
2353
+ * });
2354
+ * ```
2109
2355
  */
2110
2356
  on(messageType: EmbedEvent, callback: MessageCallback, options?: MessageOptions): typeof TsEmbed.prototype;
2111
2357
  /**
@@ -2138,15 +2384,35 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
2138
2384
  * Base class for embedding v1 experience
2139
2385
  * Note: The v1 version of ThoughtSpot Blink works on the AngularJS stack
2140
2386
  * which is currently under migration to v2
2387
+ *
2388
+ * @inheritdoc
2141
2389
  */
2142
2390
  export class V1Embed extends TsEmbed {
2143
2391
  protected viewConfig: ViewConfig;
2144
2392
  constructor(domSelector: DOMSelector, viewConfig: ViewConfig);
2145
2393
  /**
2146
- * Render the app in an iframe and set up event handlers
2394
+ * Render the ap p in an iframe and set up event handlers
2147
2395
  * @param iframeSrc
2148
2396
  */
2149
2397
  protected renderV1Embed(iframeSrc: string): any;
2398
+ /**
2399
+ * @inheritdoc TsEmbed.on
2400
+ *
2401
+ * @example
2402
+ * ```js
2403
+ * tsEmbed.on(EmbedEvent.Error, (data) => {
2404
+ * console.error(data);
2405
+ * });
2406
+ * ```
2407
+ * @example
2408
+ * ```js
2409
+ * tsEmbed.on(EmbedEvent.Save, (data) => {
2410
+ * console.log("Answer save clicked", data);
2411
+ * }, {
2412
+ * start: true // This will trigger the callback on start of save
2413
+ * });
2414
+ * ```
2415
+ */
2150
2416
  on(messageType: EmbedEvent, callback: MessageCallback, options?: MessageOptions): typeof TsEmbed.prototype;
2151
2417
  }
2152
2418
  }