@thoughtspot/visual-embed-sdk 1.10.0-alpha.3 → 1.10.1
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.
- package/CHANGELOG.md +2 -2
- package/README.md +22 -3
- package/dist/src/auth.d.ts +18 -5
- package/dist/src/embed/app.d.ts +4 -2
- package/dist/src/embed/base.d.ts +21 -5
- package/dist/src/embed/search.d.ts +4 -0
- package/dist/src/embed/ts-embed.d.ts +1 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/types.d.ts +29 -1
- package/dist/src/utils/authService.d.ts +1 -0
- package/dist/src/utils/processData.d.ts +1 -1
- package/dist/tsembed.es.js +560 -43
- package/dist/tsembed.js +558 -42
- package/lib/package.json +2 -1
- package/lib/src/auth.d.ts +18 -5
- package/lib/src/auth.js +48 -9
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +69 -11
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/app.d.ts +4 -2
- package/lib/src/embed/app.js +17 -7
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +36 -2
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +21 -5
- package/lib/src/embed/base.js +64 -10
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +49 -3
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +1 -1
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +30 -1
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/search.d.ts +4 -0
- package/lib/src/embed/search.js +1 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -1
- package/lib/src/embed/ts-embed.js +18 -14
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +16 -6
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +3 -2
- package/lib/src/index.js +3 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/test/test-utils.js +1 -1
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +29 -1
- package/lib/src/types.js +23 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService.d.ts +1 -0
- package/lib/src/utils/authService.js +21 -3
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js +21 -5
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/processData.d.ts +1 -1
- package/lib/src/utils/processData.js +37 -3
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +106 -4
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +123 -11
- package/package.json +2 -1
- package/src/auth.spec.ts +90 -11
- package/src/auth.ts +63 -13
- package/src/embed/app.spec.ts +49 -1
- package/src/embed/app.ts +18 -6
- package/src/embed/base.spec.ts +56 -4
- package/src/embed/base.ts +83 -16
- package/src/embed/embed.spec.ts +1 -1
- package/src/embed/events.spec.ts +32 -0
- package/src/embed/search.ts +5 -0
- package/src/embed/ts-embed.spec.ts +19 -9
- package/src/embed/ts-embed.ts +24 -15
- package/src/index.ts +5 -1
- package/src/test/test-utils.ts +1 -1
- package/src/types.ts +29 -0
- package/src/utils/authService.spec.ts +31 -5
- package/src/utils/authService.ts +27 -3
- package/src/utils/processData.spec.ts +139 -4
- package/src/utils/processData.ts +54 -4
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 [](https://coveralls.io/github/ts-blink/embed-sdk?branch=main)  [](https://www.jsdelivr.com/package/npm/@thoughtspot/visual-embed-sdk)
|
|
7
|
+
# ThoughtSpot Visual Embed SDK <br/> [](https://coveralls.io/github/ts-blink/embed-sdk?branch=main)  [](https://www.jsdelivr.com/package/npm/@thoughtspot/visual-embed-sdk) 
|
|
8
8
|
|
|
9
9
|
SDK to embed ThoughtSpot into your web apps.
|
|
10
10
|
|
|
@@ -25,6 +25,8 @@ The SDK is written in TypeScript and is also provided both as ES Module (ESM) an
|
|
|
25
25
|
```js
|
|
26
26
|
// ESM via NPM
|
|
27
27
|
import * as TsEmbedSDK from '@thoughtspot/visual-embed-sdk';
|
|
28
|
+
// OR
|
|
29
|
+
import { LiveboardEmbed } from '@thoughtspot/visual-embed-sdk';
|
|
28
30
|
|
|
29
31
|
// NPM <script>
|
|
30
32
|
<script src="https://cdn.jsdelivr.net/npm/@thoughtspot/visual-embed-sdk/dist/tsembed.js"></script>;
|
|
@@ -41,7 +43,8 @@ import {
|
|
|
41
43
|
|
|
42
44
|
## Live Playground
|
|
43
45
|
|
|
44
|
-
Visit our [code playground](https://try-everywhere.thoughtspot.cloud/v2/#/everywhere).
|
|
46
|
+
Visit our [code playground](https://try-everywhere.thoughtspot.cloud/v2/#/everywhere). <br/><br/>
|
|
47
|
+
Start a [free trial](https://www.thoughtspot.com/trial?tsref=trialtse) on your own data.
|
|
45
48
|
|
|
46
49
|
<br/>
|
|
47
50
|
|
|
@@ -132,10 +135,26 @@ const appEmbed = new AppEmbed(document.getElementById('ts-embed'), {
|
|
|
132
135
|
appEmbed.render();
|
|
133
136
|
```
|
|
134
137
|
|
|
138
|
+
### Triggering and Listening to events
|
|
139
|
+
```js
|
|
140
|
+
// NPM
|
|
141
|
+
import { LiveboardEmbed, Page, AuthType, init, EmbedEvent, HostEvent } from '@thoughtspot/visual-embed-sdk';
|
|
142
|
+
|
|
143
|
+
// .. Do init and create a liveboardEmbed object as above.
|
|
144
|
+
|
|
145
|
+
liveboardEmbed.render();
|
|
146
|
+
|
|
147
|
+
liveboardEmbed.on(EmbedEvent.LiveboardRendered, () => {
|
|
148
|
+
liveboardEmbed.trigger(HostEvent.SetVisibleVizs, ['viz1', 'viz2']);
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
135
152
|
## React Components
|
|
136
153
|
|
|
137
154
|
All the above flavors of embedding are also provided as React components for your convenience.
|
|
138
155
|
The constructor options are passed as props and the event listeners can be attached using `on<EventName>` convention.
|
|
156
|
+
<br/><br/>
|
|
157
|
+
Checkout a comprehensive working demo [here](https://codesandbox.io/s/github/ashubham/big-react-demo)
|
|
139
158
|
|
|
140
159
|
### Search Component
|
|
141
160
|
|
|
@@ -166,7 +185,7 @@ const MyComponent = ({ dataSources }) => {
|
|
|
166
185
|
};
|
|
167
186
|
```
|
|
168
187
|
|
|
169
|
-
### Triggering events on React components
|
|
188
|
+
### Triggering events on React components (> version 1.9.2)
|
|
170
189
|
|
|
171
190
|
```jsx
|
|
172
191
|
import { HostEvent } from '@thoughtspot/visual-embed-sdk';
|
package/dist/src/auth.d.ts
CHANGED
|
@@ -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<
|
|
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<
|
|
33
|
-
export declare const doSamlAuth: (embedConfig: EmbedConfig) => Promise<
|
|
34
|
-
export declare const doOIDCAuth: (embedConfig: EmbedConfig) => Promise<
|
|
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<
|
|
52
|
+
export declare const authenticate: (embedConfig: EmbedConfig) => Promise<boolean>;
|
|
40
53
|
/**
|
|
41
54
|
* Check if we are authenticated to the ThoughtSpot cluster
|
|
42
55
|
*/
|
package/dist/src/embed/app.d.ts
CHANGED
|
@@ -118,10 +118,12 @@ export declare class AppEmbed extends V1Embed {
|
|
|
118
118
|
/**
|
|
119
119
|
* Navigate to particular page for app embed. eg:answers/pinboards/home
|
|
120
120
|
* This is used for embedding answers, pinboards, visualizations and full application only.
|
|
121
|
-
* @param path The string, set to iframe src and navigate to new page
|
|
121
|
+
* @param path string | number The string, set to iframe src and navigate to new page
|
|
122
122
|
* eg: appEmbed.navigateToPage('pinboards')
|
|
123
|
+
* When used with `noReload` this can also be a number like 1/-1 to go forward/back.
|
|
124
|
+
* @param noReload boolean Trigger the navigation without reloading the page (version: 1.12.0 | 8.4.0.cl)
|
|
123
125
|
*/
|
|
124
|
-
navigateToPage(path: string): void;
|
|
126
|
+
navigateToPage(path: string | number, noReload?: boolean): void;
|
|
125
127
|
/**
|
|
126
128
|
* Renders the embedded application pages in the ThoughtSpot app.
|
|
127
129
|
* @param renderOptions An object containing the page ID
|
package/dist/src/embed/base.d.ts
CHANGED
|
@@ -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
|
-
|
|
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<
|
|
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) =>
|
|
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;
|
|
@@ -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
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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, };
|
package/dist/src/types.d.ts
CHANGED
|
@@ -119,6 +119,11 @@ export interface EmbedConfig {
|
|
|
119
119
|
* @default false
|
|
120
120
|
*/
|
|
121
121
|
disableLoginRedirect?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* This message is displayed on the embed view when the login fails.
|
|
124
|
+
* @version 1.10.1 | ThoughtSpot: *
|
|
125
|
+
*/
|
|
126
|
+
loginFailedMessage?: string;
|
|
122
127
|
/**
|
|
123
128
|
* Calls the prefetch method internally when set to true
|
|
124
129
|
* @default false
|
|
@@ -332,6 +337,16 @@ export declare enum EmbedEvent {
|
|
|
332
337
|
* The ThoughtSpot auth session has expired.
|
|
333
338
|
*/
|
|
334
339
|
AuthExpire = "ThoughtspotAuthExpired",
|
|
340
|
+
/**
|
|
341
|
+
* ThoughtSpot failed to validate the auth session.
|
|
342
|
+
* @hidden
|
|
343
|
+
*/
|
|
344
|
+
AuthFailure = "ThoughtspotAuthFailure",
|
|
345
|
+
/**
|
|
346
|
+
* ThoughtSpot failed to validate the auth session.
|
|
347
|
+
* @hidden
|
|
348
|
+
*/
|
|
349
|
+
AuthLogout = "ThoughtspotAuthLogout",
|
|
335
350
|
/**
|
|
336
351
|
* The height of the embedded Liveboard or visualization has been computed.
|
|
337
352
|
* @return data - The height of the embedded Liveboard or visualization
|
|
@@ -383,6 +398,12 @@ export declare enum EmbedEvent {
|
|
|
383
398
|
* @version 1.9.1 or later
|
|
384
399
|
*/
|
|
385
400
|
LiveboardRendered = "PinboardRendered",
|
|
401
|
+
/**
|
|
402
|
+
* This can be used to register an event listener which
|
|
403
|
+
* is triggered on all events.
|
|
404
|
+
* @version SDK: 1.10.0 | ThoughtSpot: any
|
|
405
|
+
*/
|
|
406
|
+
ALL = "*",
|
|
386
407
|
/**
|
|
387
408
|
* Emitted when answer is saved in the app
|
|
388
409
|
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
|
|
@@ -525,7 +546,14 @@ export declare enum HostEvent {
|
|
|
525
546
|
* @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
|
|
526
547
|
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
527
548
|
*/
|
|
528
|
-
UpdateRuntimeFilters = "UpdateRuntimeFilters"
|
|
549
|
+
UpdateRuntimeFilters = "UpdateRuntimeFilters",
|
|
550
|
+
/**
|
|
551
|
+
* Navigate to a specific page in App embed without any reload.
|
|
552
|
+
* This is the same as calling `appEmbed.navigateToPage(path, true)`
|
|
553
|
+
* @param path - the path to navigate to (can be a number[1/-1] to go forward/back)
|
|
554
|
+
* @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl
|
|
555
|
+
*/
|
|
556
|
+
Navigate = "Navigate"
|
|
529
557
|
}
|
|
530
558
|
/**
|
|
531
559
|
* The different visual modes that the data sources panel within
|
|
@@ -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>;
|
|
@@ -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
|
|
3
|
+
export declare function processEventData(type: EmbedEvent, e: any, thoughtSpotHost: string, containerEl: Element): any;
|