@thoughtspot/visual-embed-sdk 1.10.0-alpha.4 → 1.10.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 (91) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +1 -1
  3. package/dist/src/auth.d.ts +18 -5
  4. package/dist/src/embed/base.d.ts +21 -5
  5. package/dist/src/embed/pinboard.d.ts +6 -0
  6. package/dist/src/embed/search.d.ts +4 -0
  7. package/dist/src/embed/ts-embed.d.ts +1 -1
  8. package/dist/src/index.d.ts +3 -2
  9. package/dist/src/types.d.ts +29 -0
  10. package/dist/src/utils/authService.d.ts +1 -0
  11. package/dist/src/utils/plugin.d.ts +0 -0
  12. package/dist/src/utils/processData.d.ts +1 -1
  13. package/dist/src/utils.d.ts +1 -0
  14. package/dist/src/v1/api.d.ts +19 -0
  15. package/dist/tsembed.es.js +543 -39
  16. package/dist/tsembed.js +541 -38
  17. package/lib/package.json +2 -1
  18. package/lib/src/auth.d.ts +18 -5
  19. package/lib/src/auth.js +51 -12
  20. package/lib/src/auth.js.map +1 -1
  21. package/lib/src/auth.spec.js +69 -11
  22. package/lib/src/auth.spec.js.map +1 -1
  23. package/lib/src/embed/base.d.ts +21 -5
  24. package/lib/src/embed/base.js +64 -10
  25. package/lib/src/embed/base.js.map +1 -1
  26. package/lib/src/embed/base.spec.js +49 -3
  27. package/lib/src/embed/base.spec.js.map +1 -1
  28. package/lib/src/embed/embed.spec.js +1 -1
  29. package/lib/src/embed/embed.spec.js.map +1 -1
  30. package/lib/src/embed/events.spec.js +30 -1
  31. package/lib/src/embed/events.spec.js.map +1 -1
  32. package/lib/src/embed/pinboard.d.ts +6 -0
  33. package/lib/src/embed/pinboard.js +4 -1
  34. package/lib/src/embed/pinboard.js.map +1 -1
  35. package/lib/src/embed/search.d.ts +4 -0
  36. package/lib/src/embed/search.js +1 -1
  37. package/lib/src/embed/search.js.map +1 -1
  38. package/lib/src/embed/ts-embed.d.ts +1 -1
  39. package/lib/src/embed/ts-embed.js +18 -14
  40. package/lib/src/embed/ts-embed.js.map +1 -1
  41. package/lib/src/embed/ts-embed.spec.js +16 -6
  42. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  43. package/lib/src/index.d.ts +3 -2
  44. package/lib/src/index.js +3 -2
  45. package/lib/src/index.js.map +1 -1
  46. package/lib/src/test/test-utils.js +1 -1
  47. package/lib/src/test/test-utils.js.map +1 -1
  48. package/lib/src/types.d.ts +29 -0
  49. package/lib/src/types.js +16 -0
  50. package/lib/src/types.js.map +1 -1
  51. package/lib/src/utils/authService.d.ts +1 -0
  52. package/lib/src/utils/authService.js +21 -3
  53. package/lib/src/utils/authService.js.map +1 -1
  54. package/lib/src/utils/authService.spec.js +21 -5
  55. package/lib/src/utils/authService.spec.js.map +1 -1
  56. package/lib/src/utils/plugin.d.ts +0 -0
  57. package/lib/src/utils/plugin.js +1 -0
  58. package/lib/src/utils/plugin.js.map +1 -0
  59. package/lib/src/utils/processData.d.ts +1 -1
  60. package/lib/src/utils/processData.js +37 -3
  61. package/lib/src/utils/processData.js.map +1 -1
  62. package/lib/src/utils/processData.spec.js +106 -4
  63. package/lib/src/utils/processData.spec.js.map +1 -1
  64. package/lib/src/utils.d.ts +1 -0
  65. package/lib/src/utils.js +4 -0
  66. package/lib/src/utils.js.map +1 -1
  67. package/lib/src/utils.spec.js +14 -1
  68. package/lib/src/utils.spec.js.map +1 -1
  69. package/lib/src/visual-embed-sdk.d.ts +119 -8
  70. package/package.json +2 -1
  71. package/src/auth.spec.ts +90 -11
  72. package/src/auth.ts +74 -16
  73. package/src/embed/base.spec.ts +56 -4
  74. package/src/embed/base.ts +83 -16
  75. package/src/embed/embed.spec.ts +1 -1
  76. package/src/embed/events.spec.ts +32 -0
  77. package/src/embed/search.ts +5 -0
  78. package/src/embed/ts-embed.spec.ts +19 -9
  79. package/src/embed/ts-embed.ts +24 -15
  80. package/src/index.ts +5 -1
  81. package/src/test/test-utils.ts +1 -1
  82. package/src/types.ts +31 -0
  83. package/src/utils/authService.spec.ts +31 -5
  84. package/src/utils/authService.ts +27 -3
  85. package/src/utils/processData.spec.ts +139 -4
  86. package/src/utils/processData.ts +54 -4
  87. package/src/utils.spec.ts +26 -0
  88. package/src/utils.ts +5 -0
  89. package/lib/src/utils/fetchAnswers.d.ts +0 -3
  90. package/lib/src/utils/fetchAnswers.js +0 -49
  91. package/lib/src/utils/fetchAnswers.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -22,12 +22,12 @@ This project follows Semantic Versioning.
22
22
 
23
23
  ## 1.9.3 (03-22-2022)
24
24
 
25
- ### New Features
25
+ ### New Features
26
26
  - `disableLoginRedirect` option in `EmbedConfig`
27
27
 
28
28
  ## 1.9.2 (03-17-2022)
29
29
 
30
- ### New Features
30
+ ### New Features
31
31
  - Ability to trigger events on React components
32
32
  - Added new `useEmbedRef` hook, check README for usage.
33
33
 
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  <br/>
6
6
 
7
- # ThoughtSpot Visual Embed SDK [![Coverage Status](https://coveralls.io/repos/github/ts-blink/embed-sdk/badge.svg?branch=main)](https://coveralls.io/github/ts-blink/embed-sdk?branch=main) ![npm (scoped with tag)](https://img.shields.io/npm/v/@thoughtspot/visual-embed-sdk) [![](https://data.jsdelivr.com/v1/package/npm/@thoughtspot/visual-embed-sdk/badge?style=rounded)](https://www.jsdelivr.com/package/npm/@thoughtspot/visual-embed-sdk)
7
+ # ThoughtSpot Visual Embed SDK <br/> [![Coverage Status](https://coveralls.io/repos/github/ts-blink/embed-sdk/badge.svg?branch=main)](https://coveralls.io/github/ts-blink/embed-sdk?branch=main) ![npm (scoped with tag)](https://img.shields.io/npm/v/@thoughtspot/visual-embed-sdk) [![](https://data.jsdelivr.com/v1/package/npm/@thoughtspot/visual-embed-sdk/badge?style=rounded)](https://www.jsdelivr.com/package/npm/@thoughtspot/visual-embed-sdk) ![npm](https://img.shields.io/npm/dm/@thoughtspot/visual-embed-sdk?label=npm%20downloads&style=flat-square)
8
8
 
9
9
  SDK to embed ThoughtSpot into your web apps.
10
10
 
@@ -10,7 +10,19 @@ export declare const EndPoints: {
10
10
  OIDC_LOGIN_TEMPLATE: (targetUrl: string) => string;
11
11
  TOKEN_LOGIN: string;
12
12
  BASIC_LOGIN: string;
13
+ LOGOUT: string;
13
14
  };
15
+ export declare enum AuthFailureType {
16
+ SDK = "SDK",
17
+ NO_COOKIE_ACCESS = "NO_COOKIE_ACCESS",
18
+ EXPIRY = "EXPIRY",
19
+ OTHER = "OTHER"
20
+ }
21
+ export declare enum AuthStatus {
22
+ FAILURE = "FAILURE",
23
+ SUCCESS = "SUCCESS",
24
+ LOGOUT = "LOGOUT"
25
+ }
14
26
  /**
15
27
  * Return sessionInfo if available else make a loggedIn check to fetch the sessionInfo
16
28
  */
@@ -20,7 +32,7 @@ export declare function initSession(sessionDetails: any): void;
20
32
  * Perform token based authentication
21
33
  * @param embedConfig The embed configuration
22
34
  */
23
- export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<void>;
35
+ export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
24
36
  /**
25
37
  * Perform basic authentication to the ThoughtSpot cluster using the cluster
26
38
  * credentials.
@@ -29,14 +41,15 @@ export declare const doTokenAuth: (embedConfig: EmbedConfig) => Promise<void>;
29
41
  * strongly advised not to use this authentication method in production.
30
42
  * @param embedConfig The embed configuration
31
43
  */
32
- export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<void>;
33
- export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<void>;
34
- export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<void>;
44
+ export declare const doBasicAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
45
+ export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
46
+ export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<boolean>;
47
+ export declare const logout: (embedConfig: EmbedConfig) => Promise<boolean>;
35
48
  /**
36
49
  * Perform authentication on the ThoughtSpot cluster
37
50
  * @param embedConfig The embed configuration
38
51
  */
39
- export declare const authenticate: (embedConfig: EmbedConfig) => Promise<void>;
52
+ export declare const authenticate: (embedConfig: EmbedConfig) => Promise<boolean>;
40
53
  /**
41
54
  * Check if we are authenticated to the ThoughtSpot cluster
42
55
  */
@@ -1,11 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2022
3
+ *
4
+ * Base classes
5
+ *
6
+ * @summary Base classes
7
+ * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
8
+ */
9
+ import EventEmitter from 'eventemitter3';
1
10
  import { EmbedConfig } from '../types';
2
- export declare let authPromise: Promise<void>;
11
+ import { AuthFailureType } from '../auth';
12
+ export declare let authPromise: Promise<boolean>;
13
+ export declare const getEmbedConfig: () => EmbedConfig;
14
+ export declare const getAuthPromise: () => Promise<boolean>;
15
+ export declare function notifyAuthSuccess(): void;
16
+ export declare function notifyAuthFailure(failureType: AuthFailureType): void;
17
+ export declare function notifyLogout(): void;
3
18
  /**
4
19
  * Perform authentication on the ThoughtSpot app as applicable.
5
20
  */
6
- export declare const handleAuth: () => Promise<void>;
7
- export declare const getEmbedConfig: () => EmbedConfig;
8
- export declare const getAuthPromise: () => Promise<void>;
21
+ export declare const handleAuth: () => Promise<boolean>;
9
22
  /**
10
23
  * 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.
11
24
  * @param url The URL provided for prefetch
@@ -19,9 +32,12 @@ export declare const prefetch: (url?: string) => void;
19
32
  *
20
33
  * @returns authPromise Promise which resolves when authentication is complete.
21
34
  */
22
- export declare const init: (embedConfig: EmbedConfig) => Promise<void>;
35
+ export declare const init: (embedConfig: EmbedConfig) => EventEmitter;
36
+ export declare function disableAutoLogin(): void;
37
+ export declare const logout: (doNotDisableAutoLogin?: boolean) => Promise<boolean>;
23
38
  /**
24
39
  * Renders functions in a queue, resolves to next function only after the callback next is called
25
40
  * @param fn The function being registered
26
41
  */
27
42
  export declare const renderInQueue: (fn: (next?: (val?: any) => void) => void) => void;
43
+ export declare function reset(): void;
@@ -45,6 +45,12 @@ export interface PinboardViewConfig extends ViewConfig {
45
45
  * pinboard page will be read-only (no X buttons)
46
46
  */
47
47
  preventPinboardFilterRemoval?: boolean;
48
+ /**
49
+ * An array of vizids which should be visible when this pinboard loads.
50
+ * The ids not in this array are hidden from the pinboard.
51
+ * _since: 1.6.0_
52
+ */
53
+ pinboardVisibleVizs?: string[];
48
54
  }
49
55
  /**
50
56
  * Embed a ThoughtSpot pinboard or visualization
@@ -44,6 +44,10 @@ export interface SearchViewConfig extends ViewConfig {
44
44
  * using raw answer data.
45
45
  */
46
46
  hideResults?: boolean;
47
+ /**
48
+ * If set to true, expands all the data sources panel.
49
+ */
50
+ expandAllDataSource?: boolean;
47
51
  /**
48
52
  * If set to true, the Search Assist feature is enabled.
49
53
  */
@@ -293,5 +293,5 @@ export declare class V1Embed extends TsEmbed {
293
293
  * @param iframeSrc
294
294
  */
295
295
  protected renderV1Embed(iframeSrc: string): void;
296
- on(messageType: EmbedEvent, callback: MessageCallback): typeof TsEmbed.prototype;
296
+ on(messageType: EmbedEvent, callback: MessageCallback, options?: MessageOptions): typeof TsEmbed.prototype;
297
297
  }
@@ -8,8 +8,9 @@
8
8
  * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
9
9
  */
10
10
  import { AppEmbed, Page, AppViewConfig } from './embed/app';
11
- import { init, prefetch } from './embed/base';
11
+ import { init, prefetch, logout } from './embed/base';
12
12
  import { PinboardEmbed, LiveboardViewConfig, LiveboardEmbed } from './embed/liveboard';
13
13
  import { SearchEmbed, SearchViewConfig } from './embed/search';
14
+ import { AuthFailureType, AuthStatus } from './auth';
14
15
  import { AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig } from './types';
15
- export { init, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, };
16
+ export { init, logout, prefetch, SearchEmbed, PinboardEmbed, LiveboardEmbed, AppEmbed, AuthFailureType, AuthStatus, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, EmbedConfig, SearchViewConfig, LiveboardViewConfig, AppViewConfig, };
@@ -90,6 +90,14 @@ export interface EmbedConfig {
90
90
  * @default false
91
91
  */
92
92
  noRedirect?: boolean;
93
+ /**
94
+ * [SSO] For SSO Authentication, one can supply an optional path param,
95
+ * this will be the path on the host origin where the SAML flow will be
96
+ * terminated.
97
+ *
98
+ * @version SDK: 1.10.2 | ThoughtSpot: *
99
+ */
100
+ redirectPath?: string;
93
101
  /** @internal */
94
102
  basepath?: string;
95
103
  /**
@@ -119,6 +127,11 @@ export interface EmbedConfig {
119
127
  * @default false
120
128
  */
121
129
  disableLoginRedirect?: boolean;
130
+ /**
131
+ * This message is displayed on the embed view when the login fails.
132
+ * @version 1.10.1 | ThoughtSpot: *
133
+ */
134
+ loginFailedMessage?: string;
122
135
  /**
123
136
  * Calls the prefetch method internally when set to true
124
137
  * @default false
@@ -332,6 +345,16 @@ export declare enum EmbedEvent {
332
345
  * The ThoughtSpot auth session has expired.
333
346
  */
334
347
  AuthExpire = "ThoughtspotAuthExpired",
348
+ /**
349
+ * ThoughtSpot failed to validate the auth session.
350
+ * @hidden
351
+ */
352
+ AuthFailure = "ThoughtspotAuthFailure",
353
+ /**
354
+ * ThoughtSpot failed to validate the auth session.
355
+ * @hidden
356
+ */
357
+ AuthLogout = "ThoughtspotAuthLogout",
335
358
  /**
336
359
  * The height of the embedded Liveboard or visualization has been computed.
337
360
  * @return data - The height of the embedded Liveboard or visualization
@@ -383,6 +406,12 @@ export declare enum EmbedEvent {
383
406
  * @version 1.9.1 or later
384
407
  */
385
408
  LiveboardRendered = "PinboardRendered",
409
+ /**
410
+ * This can be used to register an event listener which
411
+ * is triggered on all events.
412
+ * @version SDK: 1.10.0 | ThoughtSpot: any
413
+ */
414
+ ALL = "*",
386
415
  /**
387
416
  * Emitted when answer is saved in the app
388
417
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
@@ -2,3 +2,4 @@ export declare function fetchSessionInfoService(authVerificationUrl: string): Pr
2
2
  export declare function fetchAuthTokenService(authEndpoint: string): Promise<any>;
3
3
  export declare function fetchAuthService(thoughtSpotHost: string, username: string, authToken: string): Promise<any>;
4
4
  export declare function fetchBasicAuthService(thoughtSpotHost: string, username: string, password: string): Promise<any>;
5
+ export declare function fetchLogoutService(thoughtSpotHost: string): Promise<any>;
File without changes
@@ -1,3 +1,3 @@
1
1
  import { EmbedEvent } from '../types';
2
2
  export declare function processCustomAction(e: any, thoughtSpotHost: string): any;
3
- export declare function getProcessData(type: EmbedEvent, e: any, thoughtSpotHost: string): any;
3
+ export declare function processEventData(type: EmbedEvent, e: any, thoughtSpotHost: string, containerEl: Element): any;
@@ -32,6 +32,7 @@ export declare const getCssDimension: (value: number | string) => string;
32
32
  * @param stringToAppend The string to append to the URL hash
33
33
  */
34
34
  export declare const appendToUrlHash: (url: string, stringToAppend: string) => string;
35
+ export declare function getRedirectUrl(url: string, stringToAppend: string, path?: string): string;
35
36
  export declare const getEncodedQueryParamsString: (queryString: string) => string;
36
37
  export declare const getOffsetTop: (element: any) => any;
37
38
  export declare const embedEventStatus: {
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright: ThoughtSpot Inc. 2012-2016
3
+ * Author: Shashank Singh (sunny@thoughtspot.com)
4
+ *
5
+ * @fileoverview ThoughtSpot Javascript API for use of ThoughtSpot in external webpages.
6
+ */
7
+ import { AuthType } from '../types';
8
+ export declare enum Events {
9
+ THOUGHTSPOT_AUTH_EXPIRED = "ThoughtspotAuthExpired",
10
+ EXPORT_VIZ_DATA_TO_PARENT = "exportVizDataToParent",
11
+ ALERT = "alert",
12
+ EXPORT_VIZ_DATA_TO_CHILD = "exportVizDataToChild",
13
+ GET_DATA = "getData"
14
+ }
15
+ declare type Callback = (...args: any[]) => void;
16
+ declare function checkIfLoggedIn(tsHost: string, callback: Callback): void;
17
+ declare function initialize(onInitialized: Callback, onAuthExpiration: Callback, _thoughtspotHost: string, authType: AuthType): void;
18
+ declare function notifyOnAuthExpiration(): void;
19
+ export { initialize, checkIfLoggedIn, notifyOnAuthExpiration };