@thoughtspot/visual-embed-sdk 1.20.0 → 1.20.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/dist/src/auth.d.ts +38 -4
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +2 -2
- package/dist/src/embed/base.d.ts +22 -13
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +2 -2
- package/dist/src/embed/search-bar.d.ts +4 -1
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +2 -2
- package/dist/src/embed/ts-embed.d.ts +35 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +161 -26
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsembed.es.js +193 -35
- package/dist/tsembed.js +174 -35
- package/lib/package.json +2 -3
- package/lib/src/auth.d.ts +38 -4
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +17 -2
- package/lib/src/auth.js.map +1 -1
- package/lib/src/embed/app.d.ts +2 -2
- package/lib/src/embed/app.js +1 -1
- package/lib/src/embed/base.d.ts +22 -13
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +21 -3
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +2 -2
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +2 -2
- package/lib/src/embed/liveboard.js +1 -1
- package/lib/src/embed/search-bar.d.ts +4 -1
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +1 -1
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts +2 -2
- package/lib/src/embed/search.js +1 -1
- package/lib/src/embed/ts-embed.d.ts +35 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +35 -2
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/index.d.ts +3 -3
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +4 -2
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +14 -2
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +161 -26
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +115 -23
- package/lib/src/types.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +269 -54
- package/package.json +2 -3
- package/src/auth.ts +51 -5
- package/src/embed/app.ts +2 -2
- package/src/embed/base.spec.ts +3 -3
- package/src/embed/base.ts +26 -7
- package/src/embed/liveboard.ts +2 -2
- package/src/embed/search-bar.tsx +4 -1
- package/src/embed/search.ts +2 -2
- package/src/embed/ts-embed.ts +35 -2
- package/src/index.ts +24 -2
- package/src/react/index.spec.tsx +35 -2
- package/src/react/index.tsx +10 -2
- package/src/types.ts +162 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/visual-embed-sdk",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.1",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -135,8 +135,7 @@
|
|
|
135
135
|
"ts-jest": "^26.5.5",
|
|
136
136
|
"ts-loader": "8.0.4",
|
|
137
137
|
"typedoc": "0.21.6",
|
|
138
|
-
"typedoc-
|
|
139
|
-
"typedoc-plugin-toc-group": "0.0.5",
|
|
138
|
+
"typedoc-plugin-toc-group": "thoughtspot/typedoc-plugin-toc-group",
|
|
140
139
|
"typescript": "^4.9.4",
|
|
141
140
|
"url-search-params-polyfill": "^8.1.0",
|
|
142
141
|
"util": "^0.12.4"
|
package/src/auth.ts
CHANGED
|
@@ -39,6 +39,11 @@ export const EndPoints = {
|
|
|
39
39
|
LOGOUT: '/callosum/v1/session/logout',
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Enum for auth failure types. This is the parameter passed to the listner
|
|
44
|
+
* of {@link AuthStatus.FAILURE}.
|
|
45
|
+
* @group Authentication / Init
|
|
46
|
+
*/
|
|
42
47
|
export enum AuthFailureType {
|
|
43
48
|
SDK = 'SDK',
|
|
44
49
|
NO_COOKIE_ACCESS = 'NO_COOKIE_ACCESS',
|
|
@@ -46,6 +51,10 @@ export enum AuthFailureType {
|
|
|
46
51
|
OTHER = 'OTHER',
|
|
47
52
|
}
|
|
48
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Enum for auth status emitted by the emitter returned from {@link init}.
|
|
56
|
+
* @group Authentication / Init
|
|
57
|
+
*/
|
|
49
58
|
export enum AuthStatus {
|
|
50
59
|
/**
|
|
51
60
|
* Emits when the SDK fails to authenticate
|
|
@@ -72,20 +81,56 @@ export enum AuthStatus {
|
|
|
72
81
|
WAITING_FOR_POPUP = 'WAITING_FOR_POPUP',
|
|
73
82
|
}
|
|
74
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Event emitter returned from {@link init}.
|
|
86
|
+
* @group Authentication / Init
|
|
87
|
+
*/
|
|
88
|
+
export interface AuthEventEmitter {
|
|
89
|
+
/**
|
|
90
|
+
* Registed a listener on Auth failure.
|
|
91
|
+
* @param event
|
|
92
|
+
* @param listener
|
|
93
|
+
*/
|
|
94
|
+
on(
|
|
95
|
+
event: AuthStatus.FAILURE,
|
|
96
|
+
listener: (failureType: AuthFailureType) => void,
|
|
97
|
+
): this;
|
|
98
|
+
on(
|
|
99
|
+
event:
|
|
100
|
+
| AuthStatus.SDK_SUCCESS
|
|
101
|
+
| AuthStatus.LOGOUT
|
|
102
|
+
| AuthStatus.WAITING_FOR_POPUP,
|
|
103
|
+
listener: () => void,
|
|
104
|
+
): this;
|
|
105
|
+
on(event: AuthStatus.SUCCESS, listener: (sessionInfo: any) => void): this;
|
|
106
|
+
/**
|
|
107
|
+
* Trigger an event on the emitter returned from init.
|
|
108
|
+
* @param {@link AuthEvent}
|
|
109
|
+
*/
|
|
110
|
+
emit(event: AuthEvent): void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Events which can be triggered on the emitter returned from {@link init}.
|
|
115
|
+
* @group Authentication / Init
|
|
116
|
+
*/
|
|
75
117
|
export enum AuthEvent {
|
|
76
118
|
/**
|
|
77
|
-
* Manually trigger the SSO popup.
|
|
119
|
+
* Manually trigger the SSO popup. This is useful with
|
|
120
|
+
* authStatus: SAMLRedirect/OIDCRedicre and inPopup: true
|
|
78
121
|
*/
|
|
79
122
|
TRIGGER_SSO_POPUP = 'TRIGGER_SSO_POPUP',
|
|
80
123
|
}
|
|
81
124
|
|
|
82
|
-
let authEE: EventEmitter
|
|
125
|
+
let authEE: EventEmitter<AuthStatus | AuthEvent>;
|
|
83
126
|
|
|
84
|
-
export function getAuthEE(): EventEmitter {
|
|
127
|
+
export function getAuthEE(): EventEmitter<AuthStatus | AuthEvent> {
|
|
85
128
|
return authEE;
|
|
86
129
|
}
|
|
87
130
|
|
|
88
|
-
export function setAuthEE(
|
|
131
|
+
export function setAuthEE(
|
|
132
|
+
eventEmitter: EventEmitter<AuthStatus | AuthEvent>,
|
|
133
|
+
): void {
|
|
89
134
|
authEE = eventEmitter;
|
|
90
135
|
}
|
|
91
136
|
|
|
@@ -146,8 +191,9 @@ export function getReleaseVersion() {
|
|
|
146
191
|
}
|
|
147
192
|
|
|
148
193
|
/**
|
|
149
|
-
* Return a promise that resolves with the session
|
|
194
|
+
* Return a promise that resolves with the session information when authentication is
|
|
150
195
|
* successful. And info is available.
|
|
196
|
+
* @group Global methods
|
|
151
197
|
*/
|
|
152
198
|
export function getSessionInfo(): Promise<any> {
|
|
153
199
|
return sessionInfoPromise;
|
package/src/embed/app.ts
CHANGED
|
@@ -56,7 +56,7 @@ export enum Page {
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* The view configuration for full app embedding.
|
|
59
|
-
* @
|
|
59
|
+
* @group Embed components
|
|
60
60
|
*/
|
|
61
61
|
export interface AppViewConfig extends ViewConfig {
|
|
62
62
|
/**
|
|
@@ -105,7 +105,7 @@ export interface AppViewConfig extends ViewConfig {
|
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Embeds full ThoughtSpot experience in a host application.
|
|
108
|
-
* @
|
|
108
|
+
* @group Embed components
|
|
109
109
|
*/
|
|
110
110
|
export class AppEmbed extends V1Embed {
|
|
111
111
|
protected viewConfig: AppViewConfig;
|
package/src/embed/base.spec.ts
CHANGED
|
@@ -20,7 +20,7 @@ describe('Base TS Embed', () => {
|
|
|
20
20
|
authEE = index.init({
|
|
21
21
|
thoughtSpotHost,
|
|
22
22
|
authType: index.AuthType.None,
|
|
23
|
-
});
|
|
23
|
+
}) as EventEmitter;
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
beforeEach(() => {
|
|
@@ -148,9 +148,9 @@ describe('Base TS Embed', () => {
|
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
authEmitter.on(auth.AuthStatus.FAILURE, failureCallback);
|
|
151
|
-
authEmitter.on(auth.AuthStatus.SDK_SUCCESS, (
|
|
151
|
+
authEmitter.on(auth.AuthStatus.SDK_SUCCESS, (...args) => {
|
|
152
152
|
expect(failureCallback).not.toBeCalled();
|
|
153
|
-
expect(
|
|
153
|
+
expect(args.length).toBe(0);
|
|
154
154
|
done();
|
|
155
155
|
});
|
|
156
156
|
});
|
package/src/embed/base.ts
CHANGED
|
@@ -16,11 +16,13 @@ import {
|
|
|
16
16
|
logout as _logout,
|
|
17
17
|
AuthFailureType,
|
|
18
18
|
AuthStatus,
|
|
19
|
+
AuthEvent,
|
|
19
20
|
notifyAuthFailure,
|
|
20
21
|
notifyAuthSDKSuccess,
|
|
21
22
|
notifyAuthSuccess,
|
|
22
23
|
notifyLogout,
|
|
23
24
|
setAuthEE,
|
|
25
|
+
AuthEventEmitter,
|
|
24
26
|
} from '../auth';
|
|
25
27
|
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
|
|
26
28
|
|
|
@@ -32,7 +34,13 @@ const CONFIG_DEFAULTS: Partial<EmbedConfig> = {
|
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
export let authPromise: Promise<boolean>;
|
|
35
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Gets the configuration embed was initialized with.
|
|
39
|
+
*
|
|
40
|
+
* @returns {@link EmbedConfig} The configuration embed was initialized with.
|
|
41
|
+
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
42
|
+
* @group Global methods
|
|
43
|
+
*/
|
|
36
44
|
export const getEmbedConfig = (): EmbedConfig => config;
|
|
37
45
|
|
|
38
46
|
export const getAuthPromise = (): Promise<boolean> => authPromise;
|
|
@@ -76,6 +84,7 @@ const hostUrlToFeatureUrl = {
|
|
|
76
84
|
* @param url The URL provided for prefetch
|
|
77
85
|
* @param prefetchFeatures Specify features which needs to be prefetched.
|
|
78
86
|
* @version SDK: 1.4.0 | ThoughtSpot: ts7.sep.cl, 7.2.1
|
|
87
|
+
* @group Global methods
|
|
79
88
|
*/
|
|
80
89
|
export const prefetch = (
|
|
81
90
|
url?: string,
|
|
@@ -139,12 +148,21 @@ function backwardCompat(embedConfig: EmbedConfig): EmbedConfig {
|
|
|
139
148
|
* authentication if applicable.
|
|
140
149
|
* @param embedConfig The configuration object containing ThoughtSpot host,
|
|
141
150
|
* authentication mechanism and so on.
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```js
|
|
154
|
+
* const authStatus = init({
|
|
155
|
+
* thoughtSpotHost: 'https://my.thoughtspot.cloud',
|
|
156
|
+
* authType: AuthType.None,
|
|
157
|
+
* });
|
|
158
|
+
* authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @returns {@link AuthEventEmitter} event emitter which emits events on authentication success, failure and logout. See {@link AuthStatus}
|
|
145
162
|
* @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
|
|
163
|
+
* @group Authentication / Init
|
|
146
164
|
*/
|
|
147
|
-
export const init = (embedConfig: EmbedConfig):
|
|
165
|
+
export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
|
|
148
166
|
sanity(embedConfig);
|
|
149
167
|
config = {
|
|
150
168
|
...CONFIG_DEFAULTS,
|
|
@@ -152,7 +170,7 @@ export const init = (embedConfig: EmbedConfig): EventEmitter => {
|
|
|
152
170
|
thoughtSpotHost: getThoughtSpotHost(embedConfig),
|
|
153
171
|
};
|
|
154
172
|
config = backwardCompat(config);
|
|
155
|
-
const authEE = new EventEmitter();
|
|
173
|
+
const authEE = new EventEmitter<AuthStatus | AuthEvent>();
|
|
156
174
|
setAuthEE(authEE);
|
|
157
175
|
handleAuth();
|
|
158
176
|
|
|
@@ -175,7 +193,7 @@ export const init = (embedConfig: EmbedConfig): EventEmitter => {
|
|
|
175
193
|
if (config.callPrefetch) {
|
|
176
194
|
prefetch(config.thoughtSpotHost);
|
|
177
195
|
}
|
|
178
|
-
return authEE;
|
|
196
|
+
return authEE as AuthEventEmitter;
|
|
179
197
|
};
|
|
180
198
|
|
|
181
199
|
export function disableAutoLogin(): void {
|
|
@@ -192,6 +210,7 @@ export function disableAutoLogin(): void {
|
|
|
192
210
|
* @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
|
|
193
211
|
* @returns Promise which resolves when logout completes.
|
|
194
212
|
* @version SDK: 1.10.1 | ThoughtSpot: 8.2.0.cl, 8.4.1-sw
|
|
213
|
+
* @group Global methods
|
|
195
214
|
*/
|
|
196
215
|
export const logout = (doNotDisableAutoLogin = false): Promise<boolean> => {
|
|
197
216
|
if (!doNotDisableAutoLogin) {
|
package/src/embed/liveboard.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { V1Embed } from './ts-embed';
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* The configuration for the embedded Liveboard or visualization page view.
|
|
27
|
-
* @
|
|
27
|
+
* @group Embed components
|
|
28
28
|
*/
|
|
29
29
|
export interface LiveboardViewConfig extends ViewConfig {
|
|
30
30
|
/**
|
|
@@ -92,7 +92,7 @@ export interface LiveboardViewConfig extends ViewConfig {
|
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* Embed a ThoughtSpot Liveboard or visualization
|
|
95
|
-
* @
|
|
95
|
+
* @group Embed components
|
|
96
96
|
*/
|
|
97
97
|
export class LiveboardEmbed extends V1Embed {
|
|
98
98
|
protected viewConfig: LiveboardViewConfig;
|
package/src/embed/search-bar.tsx
CHANGED
|
@@ -3,6 +3,9 @@ import { getQueryParamString } from '../utils';
|
|
|
3
3
|
import { TsEmbed } from './ts-embed';
|
|
4
4
|
import { SearchOptions } from './search';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @group Embed components
|
|
8
|
+
*/
|
|
6
9
|
export interface SearchBarViewConfig
|
|
7
10
|
extends Omit<ViewConfig, 'runtimeFilters' | 'showAlerts'> {
|
|
8
11
|
/**
|
|
@@ -25,8 +28,8 @@ export interface SearchBarViewConfig
|
|
|
25
28
|
/**
|
|
26
29
|
* Embed ThoughtSpot search bar
|
|
27
30
|
*
|
|
28
|
-
* @Category Search Embed
|
|
29
31
|
* @version: SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl, 9.0.1-sw
|
|
32
|
+
* @group Embed components
|
|
30
33
|
*/
|
|
31
34
|
export class SearchBarEmbed extends TsEmbed {
|
|
32
35
|
/**
|
package/src/embed/search.ts
CHANGED
|
@@ -45,7 +45,7 @@ export interface SearchOptions {
|
|
|
45
45
|
/**
|
|
46
46
|
* The configuration attributes for the embedded search view.
|
|
47
47
|
*
|
|
48
|
-
* @
|
|
48
|
+
* @group Embed components
|
|
49
49
|
*/
|
|
50
50
|
export interface SearchViewConfig extends ViewConfig {
|
|
51
51
|
/**
|
|
@@ -120,7 +120,7 @@ export const HiddenActionItemByDefaultForSearchEmbed = [
|
|
|
120
120
|
/**
|
|
121
121
|
* Embed ThoughtSpot search
|
|
122
122
|
*
|
|
123
|
-
* @
|
|
123
|
+
* @group Embed components
|
|
124
124
|
*/
|
|
125
125
|
export class SearchEmbed extends TsEmbed {
|
|
126
126
|
/**
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -692,6 +692,20 @@ export class TsEmbed {
|
|
|
692
692
|
* @param messageType The message type
|
|
693
693
|
* @param callback A callback as a function
|
|
694
694
|
* @param options The message options
|
|
695
|
+
* @example
|
|
696
|
+
* ```js
|
|
697
|
+
* tsEmbed.on(EmbedEvent.Error, (data) => {
|
|
698
|
+
* console.error(data);
|
|
699
|
+
* });
|
|
700
|
+
* ```
|
|
701
|
+
* @example
|
|
702
|
+
* ```js
|
|
703
|
+
* tsEmbed.on(EmbedEvent.Save, (data) => {
|
|
704
|
+
* console.log("Answer save clicked", data);
|
|
705
|
+
* }, {
|
|
706
|
+
* start: true // This will trigger the callback on start of save
|
|
707
|
+
* });
|
|
708
|
+
* ```
|
|
695
709
|
*/
|
|
696
710
|
public on(
|
|
697
711
|
messageType: EmbedEvent,
|
|
@@ -806,6 +820,8 @@ export class TsEmbed {
|
|
|
806
820
|
* Base class for embedding v1 experience
|
|
807
821
|
* Note: The v1 version of ThoughtSpot Blink works on the AngularJS stack
|
|
808
822
|
* which is currently under migration to v2
|
|
823
|
+
*
|
|
824
|
+
* @inheritdoc
|
|
809
825
|
*/
|
|
810
826
|
export class V1Embed extends TsEmbed {
|
|
811
827
|
protected viewConfig: ViewConfig;
|
|
@@ -816,14 +832,31 @@ export class V1Embed extends TsEmbed {
|
|
|
816
832
|
}
|
|
817
833
|
|
|
818
834
|
/**
|
|
819
|
-
* Render the
|
|
835
|
+
* Render the ap p in an iframe and set up event handlers
|
|
820
836
|
* @param iframeSrc
|
|
821
837
|
*/
|
|
822
838
|
protected renderV1Embed(iframeSrc: string): any {
|
|
823
839
|
return this.renderIFrame(iframeSrc, this.viewConfig.frameParams);
|
|
824
840
|
}
|
|
825
841
|
|
|
826
|
-
|
|
842
|
+
/**
|
|
843
|
+
* @inheritdoc TsEmbed.on
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* ```js
|
|
847
|
+
* tsEmbed.on(EmbedEvent.Error, (data) => {
|
|
848
|
+
* console.error(data);
|
|
849
|
+
* });
|
|
850
|
+
* ```
|
|
851
|
+
* @example
|
|
852
|
+
* ```js
|
|
853
|
+
* tsEmbed.on(EmbedEvent.Save, (data) => {
|
|
854
|
+
* console.log("Answer save clicked", data);
|
|
855
|
+
* }, {
|
|
856
|
+
* start: true // This will trigger the callback on start of save
|
|
857
|
+
* });
|
|
858
|
+
* ```
|
|
859
|
+
*/
|
|
827
860
|
public on(
|
|
828
861
|
messageType: EmbedEvent,
|
|
829
862
|
callback: MessageCallback,
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* @summary ThoughtSpot Visual Embed SDK
|
|
8
8
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
10
|
import { AppEmbed, Page, AppViewConfig } from './embed/app';
|
|
12
11
|
import { init, prefetch, logout, getEmbedConfig } from './embed/base';
|
|
13
12
|
import {
|
|
@@ -17,7 +16,13 @@ import {
|
|
|
17
16
|
} from './embed/liveboard';
|
|
18
17
|
import { SearchEmbed, SearchViewConfig } from './embed/search';
|
|
19
18
|
import { SearchBarEmbed, SearchBarViewConfig } from './embed/search-bar';
|
|
20
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
AuthFailureType,
|
|
21
|
+
AuthStatus,
|
|
22
|
+
AuthEvent,
|
|
23
|
+
AuthEventEmitter,
|
|
24
|
+
getSessionInfo,
|
|
25
|
+
} from './auth';
|
|
21
26
|
import {
|
|
22
27
|
AuthType,
|
|
23
28
|
RuntimeFilter,
|
|
@@ -28,6 +33,14 @@ import {
|
|
|
28
33
|
Action,
|
|
29
34
|
EmbedConfig,
|
|
30
35
|
PrefetchFeatures,
|
|
36
|
+
FrameParams,
|
|
37
|
+
DOMSelector,
|
|
38
|
+
MessageOptions,
|
|
39
|
+
MessageCallback,
|
|
40
|
+
MessagePayload,
|
|
41
|
+
CustomisationsInterface,
|
|
42
|
+
CustomStyles,
|
|
43
|
+
customCssInterface,
|
|
31
44
|
} from './types';
|
|
32
45
|
|
|
33
46
|
export {
|
|
@@ -44,6 +57,7 @@ export {
|
|
|
44
57
|
AuthFailureType,
|
|
45
58
|
AuthStatus,
|
|
46
59
|
AuthEvent,
|
|
60
|
+
AuthEventEmitter,
|
|
47
61
|
// types
|
|
48
62
|
Page,
|
|
49
63
|
AuthType,
|
|
@@ -59,4 +73,12 @@ export {
|
|
|
59
73
|
LiveboardViewConfig,
|
|
60
74
|
AppViewConfig,
|
|
61
75
|
PrefetchFeatures,
|
|
76
|
+
FrameParams,
|
|
77
|
+
DOMSelector,
|
|
78
|
+
MessageOptions,
|
|
79
|
+
MessageCallback,
|
|
80
|
+
MessagePayload,
|
|
81
|
+
CustomisationsInterface,
|
|
82
|
+
CustomStyles,
|
|
83
|
+
customCssInterface,
|
|
62
84
|
};
|
package/src/react/index.spec.tsx
CHANGED
|
@@ -41,7 +41,9 @@ describe('React Components', () => {
|
|
|
41
41
|
await waitFor(() => getIFrameEl(container));
|
|
42
42
|
|
|
43
43
|
expect(
|
|
44
|
-
getIFrameEl(container).classList.contains(
|
|
44
|
+
getIFrameEl(container).parentElement.classList.contains(
|
|
45
|
+
'embedClass',
|
|
46
|
+
),
|
|
45
47
|
).toBe(true);
|
|
46
48
|
expect(getIFrameSrc(container)).toBe(
|
|
47
49
|
`http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true#/embed/answer`,
|
|
@@ -141,6 +143,35 @@ describe('React Components', () => {
|
|
|
141
143
|
'col1=revenue&op1=EQ&val1=100',
|
|
142
144
|
);
|
|
143
145
|
});
|
|
146
|
+
|
|
147
|
+
it('Should have the correct container element', async () => {
|
|
148
|
+
const { container } = render(
|
|
149
|
+
<LiveboardEmbed liveboardId="abcd" className="def" />,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
await waitFor(() => getIFrameEl(container));
|
|
153
|
+
expect(container.querySelector('div')).not.toBe(null);
|
|
154
|
+
expect(
|
|
155
|
+
container.querySelector('div').classList.contains('def'),
|
|
156
|
+
).toBe(true);
|
|
157
|
+
|
|
158
|
+
const { container: containerSibling } = render(
|
|
159
|
+
<LiveboardEmbed
|
|
160
|
+
liveboardId="abcd"
|
|
161
|
+
className="def"
|
|
162
|
+
insertAsSibling={true}
|
|
163
|
+
/>,
|
|
164
|
+
);
|
|
165
|
+
await waitFor(() => getIFrameEl(containerSibling));
|
|
166
|
+
expect(containerSibling.querySelector('span')).not.toBe(null);
|
|
167
|
+
expect(containerSibling.querySelector('span').style.position).toBe(
|
|
168
|
+
'absolute',
|
|
169
|
+
);
|
|
170
|
+
expect(
|
|
171
|
+
getIFrameEl(containerSibling).classList.contains('def'),
|
|
172
|
+
).toBe(true);
|
|
173
|
+
expect(containerSibling.querySelector('div')).toBe(null);
|
|
174
|
+
});
|
|
144
175
|
});
|
|
145
176
|
|
|
146
177
|
describe('SearchBarEmbed', () => {
|
|
@@ -159,7 +190,9 @@ describe('React Components', () => {
|
|
|
159
190
|
await waitFor(() => getIFrameEl(container));
|
|
160
191
|
|
|
161
192
|
expect(
|
|
162
|
-
getIFrameEl(container).classList.contains(
|
|
193
|
+
getIFrameEl(container).parentElement.classList.contains(
|
|
194
|
+
'embedClass',
|
|
195
|
+
),
|
|
163
196
|
).toBe(true);
|
|
164
197
|
expect(getIFrameSrc(container)).toBe(
|
|
165
198
|
`http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&hideAction=[%22${Action.ReportError}%22]&dataSources=[%22test%22]&searchTokenString=%5Brevenue%5D&executeSearch=true&useLastSelectedSources=false&isSearchEmbed=true#/embed/search-bar-embed`,
|
package/src/react/index.tsx
CHANGED
|
@@ -38,7 +38,9 @@ const componentFactory = <
|
|
|
38
38
|
{
|
|
39
39
|
insertAsSibling: viewConfig.insertAsSibling,
|
|
40
40
|
frameParams: {
|
|
41
|
-
class:
|
|
41
|
+
class: viewConfig.insertAsSibling
|
|
42
|
+
? className || ''
|
|
43
|
+
: '',
|
|
42
44
|
},
|
|
43
45
|
},
|
|
44
46
|
viewConfig,
|
|
@@ -60,12 +62,18 @@ const componentFactory = <
|
|
|
60
62
|
};
|
|
61
63
|
}, [viewConfig, listeners]);
|
|
62
64
|
|
|
63
|
-
return (
|
|
65
|
+
return viewConfig.insertAsSibling ? (
|
|
64
66
|
<span
|
|
65
67
|
data-testid="tsEmbed"
|
|
66
68
|
ref={ref}
|
|
67
69
|
style={{ position: 'absolute' }}
|
|
68
70
|
></span>
|
|
71
|
+
) : (
|
|
72
|
+
<div
|
|
73
|
+
data-testid="tsEmbed"
|
|
74
|
+
ref={ref}
|
|
75
|
+
className={className}
|
|
76
|
+
></div>
|
|
69
77
|
);
|
|
70
78
|
},
|
|
71
79
|
);
|