@thoughtspot/visual-embed-sdk 1.10.0 → 1.10.3
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/dist/src/auth.d.ts +18 -5
- package/dist/src/embed/base.d.ts +36 -6
- package/dist/src/embed/pinboard.d.ts +91 -0
- package/dist/src/index.d.ts +3 -2
- package/dist/src/types.d.ts +24 -0
- package/dist/src/utils/authService.d.ts +1 -0
- package/dist/src/utils/plugin.d.ts +0 -0
- package/dist/src/utils/processData.d.ts +1 -1
- package/dist/src/utils.d.ts +1 -0
- package/dist/src/v1/api.d.ts +19 -0
- package/dist/tsembed.es.js +544 -35
- package/dist/tsembed.js +542 -34
- package/lib/package.json +2 -1
- package/lib/src/auth.d.ts +18 -5
- package/lib/src/auth.js +51 -12
- 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/base.d.ts +36 -6
- package/lib/src/embed/base.js +79 -11
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +51 -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/pinboard.d.ts +91 -0
- package/lib/src/embed/pinboard.js +110 -0
- package/lib/src/embed/pinboard.js.map +1 -0
- package/lib/src/embed/ts-embed.js +9 -10
- 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 +24 -0
- package/lib/src/types.js +10 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService.d.ts +1 -0
- package/lib/src/utils/authService.js +23 -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/plugin.d.ts +0 -0
- package/lib/src/utils/plugin.js +1 -0
- package/lib/src/utils/plugin.js.map +1 -0
- 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/utils.d.ts +1 -0
- package/lib/src/utils.js +4 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +14 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +124 -8
- package/package.json +2 -1
- package/src/auth.spec.ts +90 -11
- package/src/auth.ts +74 -16
- package/src/embed/base.spec.ts +58 -4
- package/src/embed/base.ts +98 -17
- package/src/embed/embed.spec.ts +1 -1
- package/src/embed/ts-embed.spec.ts +19 -9
- package/src/embed/ts-embed.ts +15 -12
- package/src/index.ts +5 -1
- package/src/test/test-utils.ts +1 -1
- package/src/types.ts +26 -0
- package/src/utils/authService.spec.ts +31 -5
- package/src/utils/authService.ts +29 -3
- package/src/utils/processData.spec.ts +139 -4
- package/src/utils/processData.ts +54 -4
- package/src/utils.spec.ts +26 -0
- package/src/utils.ts +5 -0
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/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
|
|
@@ -17,11 +30,28 @@ export declare const prefetch: (url?: string) => void;
|
|
|
17
30
|
* @param embedConfig The configuration object containing ThoughtSpot host,
|
|
18
31
|
* authentication mechanism and so on.
|
|
19
32
|
*
|
|
20
|
-
*
|
|
33
|
+
* eg: authStatus = init(config);
|
|
34
|
+
* authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
|
|
35
|
+
*
|
|
36
|
+
* @returns event emitter which emits events on authentication success, failure and logout. {@link AuthStatus}
|
|
37
|
+
*/
|
|
38
|
+
export declare const init: (embedConfig: EmbedConfig) => EventEmitter;
|
|
39
|
+
export declare function disableAutoLogin(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Logout from ThoughtSpot. This also sets the autoLogin flag to false, to prevent
|
|
42
|
+
* the SDK from automatically logging in again.
|
|
43
|
+
*
|
|
44
|
+
* You can call the `init` method again to re login, if autoLogin is set to true in this
|
|
45
|
+
* second call it will be honored.
|
|
46
|
+
*
|
|
47
|
+
* @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
|
|
48
|
+
* @returns Promise which resolves when logout completes.
|
|
49
|
+
* @version SDK: 1.10.1 | ThoughtSpot: *
|
|
21
50
|
*/
|
|
22
|
-
export declare const
|
|
51
|
+
export declare const logout: (doNotDisableAutoLogin?: boolean) => Promise<boolean>;
|
|
23
52
|
/**
|
|
24
53
|
* Renders functions in a queue, resolves to next function only after the callback next is called
|
|
25
54
|
* @param fn The function being registered
|
|
26
55
|
*/
|
|
27
56
|
export declare const renderInQueue: (fn: (next?: (val?: any) => void) => void) => void;
|
|
57
|
+
export declare function reset(): void;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021
|
|
3
|
+
*
|
|
4
|
+
* Embed a ThoughtSpot pinboard or visualization
|
|
5
|
+
* https://developers.thoughtspot.com/docs/?pageid=embed-pinboard
|
|
6
|
+
* https://developers.thoughtspot.com/docs/?pageid=embed-a-viz
|
|
7
|
+
*
|
|
8
|
+
* @summary Pinboard & visualization embed
|
|
9
|
+
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
10
|
+
*/
|
|
11
|
+
import { DOMSelector } from '../types';
|
|
12
|
+
import { V1Embed, ViewConfig } from './ts-embed';
|
|
13
|
+
/**
|
|
14
|
+
* The configuration for the embedded pinboard or visualization page view.
|
|
15
|
+
* @Category Pinboards and Charts
|
|
16
|
+
*/
|
|
17
|
+
export interface PinboardViewConfig extends ViewConfig {
|
|
18
|
+
/**
|
|
19
|
+
* If set to true, the embedded object container dynamically resizes
|
|
20
|
+
* according to the height of the pinboard.
|
|
21
|
+
*/
|
|
22
|
+
fullHeight?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* This is the minimum height(in pixels) for a full height pinboard.
|
|
25
|
+
* Setting this height helps resolves issues with empty pinboards and
|
|
26
|
+
* other screens navigable from a pinboard.
|
|
27
|
+
* @default 500
|
|
28
|
+
* * _since 1.5.0_
|
|
29
|
+
*/
|
|
30
|
+
defaultHeight?: number;
|
|
31
|
+
/**
|
|
32
|
+
* If set to true, the context menu in visualizations will be enabled.
|
|
33
|
+
*/
|
|
34
|
+
enableVizTransformations?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The pinboard to display in the embedded view.
|
|
37
|
+
*/
|
|
38
|
+
pinboardId: string;
|
|
39
|
+
/**
|
|
40
|
+
* The visualization within the pinboard to display.
|
|
41
|
+
*/
|
|
42
|
+
vizId?: string;
|
|
43
|
+
/**
|
|
44
|
+
* If set to true, all filter chips from a
|
|
45
|
+
* pinboard page will be read-only (no X buttons)
|
|
46
|
+
*/
|
|
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[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Embed a ThoughtSpot pinboard or visualization
|
|
57
|
+
* @Category Pinboards and Charts
|
|
58
|
+
*/
|
|
59
|
+
export declare class PinboardEmbed extends V1Embed {
|
|
60
|
+
protected viewConfig: PinboardViewConfig;
|
|
61
|
+
private defaultHeight;
|
|
62
|
+
constructor(domSelector: DOMSelector, viewConfig: PinboardViewConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Construct a map of params to be passed on to the
|
|
65
|
+
* embedded pinboard or visualization.
|
|
66
|
+
*/
|
|
67
|
+
private getEmbedParams;
|
|
68
|
+
/**
|
|
69
|
+
* Construct the URL of the embedded ThoughtSpot pinboard or visualization
|
|
70
|
+
* to be loaded within the iframe.
|
|
71
|
+
* @param pinboardId The GUID of the pinboard.
|
|
72
|
+
* @param vizId The optional GUID of a visualization within the pinboard.
|
|
73
|
+
* @param runtimeFilters A list of runtime filters to be applied to
|
|
74
|
+
* the pinboard or visualization on load.
|
|
75
|
+
*/
|
|
76
|
+
private getIFrameSrc;
|
|
77
|
+
/**
|
|
78
|
+
* Set the iframe height as per the computed height received
|
|
79
|
+
* from the ThoughtSpot app.
|
|
80
|
+
* @param data The event payload
|
|
81
|
+
*/
|
|
82
|
+
private updateIFrameHeight;
|
|
83
|
+
private embedIframeCenter;
|
|
84
|
+
private handleRouteChangeFullHeightPinboard;
|
|
85
|
+
/**
|
|
86
|
+
* Render an embedded ThoughtSpot pinboard or visualization
|
|
87
|
+
* @param renderOptions An object specifying the pinboard ID,
|
|
88
|
+
* visualization ID and the runtime filters.
|
|
89
|
+
*/
|
|
90
|
+
render(): PinboardEmbed;
|
|
91
|
+
}
|
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
|
@@ -90,6 +90,15 @@ 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
|
+
* Eg: "/dashboard", "#/foo" [Do not include the host]
|
|
99
|
+
* @version SDK: 1.10.2 | ThoughtSpot: *
|
|
100
|
+
*/
|
|
101
|
+
redirectPath?: string;
|
|
93
102
|
/** @internal */
|
|
94
103
|
basepath?: string;
|
|
95
104
|
/**
|
|
@@ -119,6 +128,11 @@ export interface EmbedConfig {
|
|
|
119
128
|
* @default false
|
|
120
129
|
*/
|
|
121
130
|
disableLoginRedirect?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* This message is displayed on the embed view when the login fails.
|
|
133
|
+
* @version 1.10.1 | ThoughtSpot: *
|
|
134
|
+
*/
|
|
135
|
+
loginFailedMessage?: string;
|
|
122
136
|
/**
|
|
123
137
|
* Calls the prefetch method internally when set to true
|
|
124
138
|
* @default false
|
|
@@ -332,6 +346,16 @@ export declare enum EmbedEvent {
|
|
|
332
346
|
* The ThoughtSpot auth session has expired.
|
|
333
347
|
*/
|
|
334
348
|
AuthExpire = "ThoughtspotAuthExpired",
|
|
349
|
+
/**
|
|
350
|
+
* ThoughtSpot failed to validate the auth session.
|
|
351
|
+
* @hidden
|
|
352
|
+
*/
|
|
353
|
+
AuthFailure = "ThoughtspotAuthFailure",
|
|
354
|
+
/**
|
|
355
|
+
* ThoughtSpot failed to validate the auth session.
|
|
356
|
+
* @hidden
|
|
357
|
+
*/
|
|
358
|
+
AuthLogout = "ThoughtspotAuthLogout",
|
|
335
359
|
/**
|
|
336
360
|
* The height of the embedded Liveboard or visualization has been computed.
|
|
337
361
|
* @return data - The height of the embedded Liveboard or visualization
|
|
@@ -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
|
|
3
|
+
export declare function processEventData(type: EmbedEvent, e: any, thoughtSpotHost: string, containerEl: Element): any;
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -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 };
|