@thoughtspot/visual-embed-sdk 1.28.3 → 1.28.5-alpha-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/README.md +1 -1
- package/cjs/package.json +2 -1
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +2 -2
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/authToken.d.ts +1 -1
- package/cjs/src/authToken.d.ts.map +1 -1
- package/cjs/src/authToken.js +9 -2
- package/cjs/src/authToken.js.map +1 -1
- package/cjs/src/embed/app.d.ts +50 -6
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +9 -3
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +10 -0
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/base.d.ts +1 -1
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +6 -6
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +1 -1
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +24 -2
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +8 -3
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +61 -4
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/sage.d.ts +4 -4
- package/cjs/src/embed/sage.d.ts.map +1 -1
- package/cjs/src/embed/sage.js +2 -18
- package/cjs/src/embed/sage.js.map +1 -1
- package/cjs/src/embed/sage.spec.js +20 -31
- package/cjs/src/embed/sage.spec.js.map +1 -1
- package/cjs/src/embed/search.d.ts +33 -5
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +6 -4
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/search.spec.js +2 -1
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +1 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +15 -6
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +27 -18
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/errors.js +1 -1
- package/cjs/src/errors.js.map +1 -1
- package/cjs/src/react/index.spec.js +1 -13
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +114 -15
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +68 -7
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
- package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js +32 -0
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -0
- package/cjs/src/utils/sessionInfoService.d.ts +66 -0
- package/cjs/src/utils/sessionInfoService.d.ts.map +1 -0
- package/cjs/src/utils/sessionInfoService.js +92 -0
- package/cjs/src/utils/sessionInfoService.js.map +1 -0
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/authToken.d.ts +1 -1
- package/dist/src/authToken.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +50 -6
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +1 -1
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +24 -2
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/sage.d.ts +4 -4
- package/dist/src/embed/sage.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +33 -5
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +1 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/types.d.ts +114 -15
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
- package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
- package/dist/src/utils/sessionInfoService.d.ts +66 -0
- package/dist/src/utils/sessionInfoService.d.ts.map +1 -0
- package/dist/tsembed-react.es.js +1764 -1691
- package/dist/tsembed-react.js +7024 -6951
- package/dist/tsembed.es.js +7275 -7202
- package/dist/tsembed.js +15449 -15376
- package/dist/visual-embed-sdk-react-full.d.ts +223 -30
- package/dist/visual-embed-sdk-react.d.ts +223 -30
- package/dist/visual-embed-sdk.d.ts +223 -30
- package/lib/package.json +2 -1
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +3 -3
- package/lib/src/auth.js.map +1 -1
- package/lib/src/authToken.d.ts +1 -1
- package/lib/src/authToken.d.ts.map +1 -1
- package/lib/src/authToken.js +9 -2
- package/lib/src/authToken.js.map +1 -1
- package/lib/src/embed/app.d.ts +50 -6
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +9 -3
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +10 -0
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -1
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +5 -5
- 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 +24 -2
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +9 -4
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +61 -4
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/sage.d.ts +4 -4
- package/lib/src/embed/sage.d.ts.map +1 -1
- package/lib/src/embed/sage.js +2 -18
- package/lib/src/embed/sage.js.map +1 -1
- package/lib/src/embed/sage.spec.js +20 -31
- package/lib/src/embed/sage.spec.js.map +1 -1
- package/lib/src/embed/search.d.ts +33 -5
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +7 -5
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +2 -1
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +18 -9
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +27 -18
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.js +1 -1
- package/lib/src/errors.js.map +1 -1
- package/lib/src/react/index.spec.js +1 -13
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +114 -15
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +68 -7
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +1 -1
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
- package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
- package/lib/src/utils/authService/tokenizedAuthService.spec.js +29 -0
- package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -0
- package/lib/src/utils/sessionInfoService.d.ts +66 -0
- package/lib/src/utils/sessionInfoService.d.ts.map +1 -0
- package/lib/src/utils/sessionInfoService.js +85 -0
- package/lib/src/utils/sessionInfoService.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +228 -35
- package/package.json +2 -1
- package/src/auth.ts +6 -6
- package/src/authToken.ts +9 -2
- package/src/embed/app.spec.ts +15 -0
- package/src/embed/app.ts +67 -8
- package/src/embed/base.spec.ts +3 -3
- package/src/embed/base.ts +14 -14
- package/src/embed/liveboard.spec.ts +82 -9
- package/src/embed/liveboard.ts +42 -5
- package/src/embed/sage.spec.ts +20 -35
- package/src/embed/sage.ts +4 -21
- package/src/embed/search.spec.ts +2 -1
- package/src/embed/search.ts +45 -10
- package/src/embed/ts-embed.spec.ts +48 -34
- package/src/embed/ts-embed.ts +52 -39
- package/src/errors.ts +1 -1
- package/src/react/index.spec.tsx +1 -30
- package/src/types.ts +114 -15
- package/src/utils/authService/authService.spec.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/visual-embed-sdk",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.5-alpha-1",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -175,6 +175,7 @@
|
|
|
175
175
|
"keywords": [
|
|
176
176
|
"thoughtspot",
|
|
177
177
|
"everywhere",
|
|
178
|
+
"embedded",
|
|
178
179
|
"embed",
|
|
179
180
|
"sdk",
|
|
180
181
|
"analytics"
|
package/src/auth.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
|
-
import { getAuthenticationToken, resetCachedAuthToken } from './authToken';
|
|
3
2
|
import { initMixpanel } from './mixpanel-service';
|
|
4
3
|
import {
|
|
5
|
-
AuthType, DOMSelector, EmbedConfig, EmbedEvent,
|
|
4
|
+
AuthType, DOMSelector, EmbedConfig, EmbedEvent, Param,
|
|
6
5
|
} from './types';
|
|
7
6
|
import { getDOMNode, getRedirectUrl } from './utils';
|
|
8
7
|
import {
|
|
9
|
-
|
|
10
|
-
fetchAuthPostService,
|
|
8
|
+
fetchSessionInfoService,
|
|
11
9
|
fetchAuthService,
|
|
12
10
|
fetchBasicAuthService,
|
|
13
11
|
fetchLogoutService,
|
|
14
|
-
|
|
12
|
+
fetchAuthPostService,
|
|
13
|
+
EndPoints,
|
|
15
14
|
} from './utils/authService';
|
|
15
|
+
import { getAuthenticationToken, resetCachedAuthToken } from './authToken';
|
|
16
16
|
import { logger } from './utils/logger';
|
|
17
17
|
import { getEmbedConfig } from './embed/embedConfig';
|
|
18
18
|
|
|
@@ -492,7 +492,7 @@ export const logout = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
|
492
492
|
const { thoughtSpotHost } = embedConfig;
|
|
493
493
|
await fetchLogoutService(thoughtSpotHost);
|
|
494
494
|
resetCachedAuthToken();
|
|
495
|
-
const thoughtspotIframes = document.querySelectorAll(
|
|
495
|
+
const thoughtspotIframes = document.querySelectorAll('[data-ts-iframe=\'true\']');
|
|
496
496
|
if (thoughtspotIframes?.length) {
|
|
497
497
|
thoughtspotIframes.forEach((el) => {
|
|
498
498
|
el.parentElement.innerHTML = embedConfig.loginFailedMessage;
|
package/src/authToken.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EmbedConfig } from './types';
|
|
2
2
|
import { fetchAuthTokenService, verifyTokenService } from './utils/authService/authService';
|
|
3
|
+
import { logger } from './utils/logger';
|
|
3
4
|
|
|
4
5
|
const DUPLICATE_TOKEN_ERR = 'Duplicate token, please issue a new token every time getAuthToken callback is called.'
|
|
5
6
|
+ 'See https://developers.thoughtspot.com/docs/?pageid=embed-auth#trusted-auth-embed for more details.';
|
|
@@ -10,7 +11,9 @@ let cachedAuthToken: string | null = null;
|
|
|
10
11
|
|
|
11
12
|
// This method can be used to get the authToken using the embedConfig
|
|
12
13
|
export const getAuthenticationToken = async (embedConfig: EmbedConfig): Promise<string> => {
|
|
13
|
-
if
|
|
14
|
+
// Since we don't have token validation enabled , we cannot tell if the
|
|
15
|
+
// cached token is valid or not. So we will always fetch a new token.
|
|
16
|
+
if (cachedAuthToken && !embedConfig.disableTokenVerification) {
|
|
14
17
|
let isCachedTokenStillValid;
|
|
15
18
|
try {
|
|
16
19
|
isCachedTokenStillValid = await validateAuthToken(embedConfig, cachedAuthToken, true);
|
|
@@ -43,6 +46,10 @@ const validateAuthToken = async (
|
|
|
43
46
|
authToken: string,
|
|
44
47
|
suppressAlert?: boolean,
|
|
45
48
|
): Promise<boolean> => {
|
|
49
|
+
if (embedConfig.disableTokenVerification) {
|
|
50
|
+
logger.info('Token verification is disabled. Assuming token is valid.');
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
46
53
|
try {
|
|
47
54
|
const isTokenValid = await verifyTokenService(embedConfig.thoughtSpotHost, authToken);
|
|
48
55
|
if (isTokenValid) return true;
|
|
@@ -68,7 +75,7 @@ const validateAuthToken = async (
|
|
|
68
75
|
* ```js
|
|
69
76
|
* resetCachedAuthToken();
|
|
70
77
|
* ```
|
|
71
|
-
* @version SDK: 1.28.
|
|
78
|
+
* @version SDK: 1.28.0 | ThoughtSpot: *
|
|
72
79
|
* @group Authentication / Init
|
|
73
80
|
*/
|
|
74
81
|
export const resetCachedAuthToken = (): void => {
|
package/src/embed/app.spec.ts
CHANGED
|
@@ -289,6 +289,21 @@ describe('App embed tests', () => {
|
|
|
289
289
|
});
|
|
290
290
|
});
|
|
291
291
|
|
|
292
|
+
test('should set enable2ColumnLayout to true in url', async () => {
|
|
293
|
+
const appEmbed = new AppEmbed(getRootEl(), {
|
|
294
|
+
...defaultViewConfig,
|
|
295
|
+
enable2ColumnLayout: true,
|
|
296
|
+
} as AppViewConfig);
|
|
297
|
+
|
|
298
|
+
appEmbed.render();
|
|
299
|
+
await executeAfterWait(() => {
|
|
300
|
+
expectUrlMatchesWithParams(
|
|
301
|
+
getIFrameSrc(),
|
|
302
|
+
`http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&enable2ColumnLayout=true${defaultParamsPost}#/home`,
|
|
303
|
+
);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
292
307
|
test('Should add the tag to the iframe src', async () => {
|
|
293
308
|
const appEmbed = new AppEmbed(getRootEl(), {
|
|
294
309
|
...defaultViewConfig,
|
package/src/embed/app.ts
CHANGED
|
@@ -9,11 +9,16 @@
|
|
|
9
9
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { logger } from '../utils/logger';
|
|
13
|
+
import { getQueryParamString } from '../utils';
|
|
12
14
|
import {
|
|
13
|
-
|
|
15
|
+
Param,
|
|
16
|
+
DOMSelector,
|
|
17
|
+
HostEvent,
|
|
18
|
+
ViewConfig,
|
|
19
|
+
EmbedEvent,
|
|
20
|
+
MessagePayload,
|
|
14
21
|
} from '../types';
|
|
15
|
-
import { getQueryParamString } from '../utils';
|
|
16
|
-
import { logger } from '../utils/logger';
|
|
17
22
|
import { V1Embed } from './ts-embed';
|
|
18
23
|
|
|
19
24
|
/**
|
|
@@ -64,6 +69,7 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
64
69
|
*
|
|
65
70
|
* @default true
|
|
66
71
|
* @version SDK: 1.2.0 | Thoughtspot: 8.4.0.cl
|
|
72
|
+
*
|
|
67
73
|
* @example
|
|
68
74
|
* ```js
|
|
69
75
|
* const embed = new AppEmbed('#tsEmbed', {
|
|
@@ -79,7 +85,6 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
79
85
|
* nav-bars are visible, this flag will only hide the homepage left nav-bar.
|
|
80
86
|
* The showPrimaryNavbar flag takes precedence over the hideHomepageLeftNav.
|
|
81
87
|
*
|
|
82
|
-
*
|
|
83
88
|
* **Note**: This option does not apply to the classic homepage.
|
|
84
89
|
* To access the updated modular homepage, set
|
|
85
90
|
* `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
|
|
@@ -99,9 +104,9 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
99
104
|
/**
|
|
100
105
|
* Control the visibility of the help (?) and profile buttons on the
|
|
101
106
|
* Global nav-bar. By default, these buttons are visible on the nav-bar.
|
|
102
|
-
*
|
|
103
107
|
* @default false
|
|
104
108
|
* @version SDK: 1.2.0 | Thoughtspot: 8.4.0.cl
|
|
109
|
+
*
|
|
105
110
|
* @example
|
|
106
111
|
* ```js
|
|
107
112
|
* const embed = new AppEmbed('#tsEmbed', {
|
|
@@ -115,7 +120,6 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
115
120
|
* Control the visibility of the application switcher button on the nav-bar.
|
|
116
121
|
* By default, the application switcher is shown.
|
|
117
122
|
*
|
|
118
|
-
*
|
|
119
123
|
* **Note**: This option does not apply to the classic homepage.
|
|
120
124
|
* To access the updated modular homepage, set
|
|
121
125
|
* `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
|
|
@@ -136,7 +140,6 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
136
140
|
* Control the visibility of the Org switcher button on the nav-bar.
|
|
137
141
|
* By default, the Org switcher button is shown.
|
|
138
142
|
*
|
|
139
|
-
*
|
|
140
143
|
* **Note**: This option does not apply to the classic homepage.
|
|
141
144
|
* To access the updated modular homepage, set
|
|
142
145
|
* `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
|
|
@@ -163,6 +166,7 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
163
166
|
* you could set the path to `pinboard/<liveboardId>/tab/<tabId>`.
|
|
164
167
|
*
|
|
165
168
|
* @version SDK: 1.1.0 | Thoughtspot: 9.4.0.cl
|
|
169
|
+
*
|
|
166
170
|
* @example
|
|
167
171
|
* ```js
|
|
168
172
|
* const embed = new AppEmbed('#tsEmbed', {
|
|
@@ -180,6 +184,7 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
180
184
|
* path within the app, use the `path` attribute which is more flexible.
|
|
181
185
|
*
|
|
182
186
|
* @version SDK: 1.1.0 | Thoughtspot: 9.4.0.cl
|
|
187
|
+
*
|
|
183
188
|
* @example
|
|
184
189
|
* ```js
|
|
185
190
|
* const embed = new AppEmbed('#tsEmbed', {
|
|
@@ -208,6 +213,7 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
208
213
|
* The array of GUIDs to be hidden
|
|
209
214
|
*
|
|
210
215
|
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
|
|
216
|
+
*
|
|
211
217
|
* @example
|
|
212
218
|
* ```js
|
|
213
219
|
* const embed = new AppEmbed('#tsEmbed', {
|
|
@@ -230,9 +236,10 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
230
236
|
liveboardV2?: boolean;
|
|
231
237
|
/**
|
|
232
238
|
* If set to true, the Search Assist feature is enabled.
|
|
233
|
-
*
|
|
234
239
|
* @default true
|
|
240
|
+
*
|
|
235
241
|
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
|
|
242
|
+
*
|
|
236
243
|
* @example
|
|
237
244
|
* ```js
|
|
238
245
|
* const embed = new AppEmbed('#tsEmbed', {
|
|
@@ -247,6 +254,7 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
247
254
|
* according to the height of the pages which support fullHeight mode.
|
|
248
255
|
*
|
|
249
256
|
* @version SDK: 1.21.0 | ThoughtSpot: 9.4.0.cl, 9.4.0-sw
|
|
257
|
+
*
|
|
250
258
|
* @example
|
|
251
259
|
* ```js
|
|
252
260
|
* const embed = new AppEmbed('#tsEmbed', {
|
|
@@ -269,6 +277,7 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
269
277
|
*
|
|
270
278
|
* @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl
|
|
271
279
|
* @default false
|
|
280
|
+
*
|
|
272
281
|
* @example
|
|
273
282
|
* ```js
|
|
274
283
|
* const embed = new AppEmbed('#tsEmbed', {
|
|
@@ -283,6 +292,7 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
283
292
|
*
|
|
284
293
|
* @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl
|
|
285
294
|
* @default false
|
|
295
|
+
*
|
|
286
296
|
* @example
|
|
287
297
|
* ```js
|
|
288
298
|
* const embed = new AppEmbed('#tsEmbed', {
|
|
@@ -297,6 +307,7 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
297
307
|
*
|
|
298
308
|
* @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl
|
|
299
309
|
* @default false
|
|
310
|
+
*
|
|
300
311
|
* @example
|
|
301
312
|
* ```js
|
|
302
313
|
* const embed = new AppEmbed('#tsEmbed', {
|
|
@@ -341,6 +352,44 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
|
|
|
341
352
|
* @default false
|
|
342
353
|
*/
|
|
343
354
|
enableAskSage?: boolean;
|
|
355
|
+
/**
|
|
356
|
+
* To set the initial state of the search bar in case of saved-answers.
|
|
357
|
+
*
|
|
358
|
+
* @version SDK: 1.32.0 | Thoughtspot: 10.0.0.cl
|
|
359
|
+
* @default false
|
|
360
|
+
*/
|
|
361
|
+
collapseSearchBarInitially?: boolean;
|
|
362
|
+
/**
|
|
363
|
+
* To enable custom column groups in data panel v2
|
|
364
|
+
*
|
|
365
|
+
* @version SDK: 1.32.0 | Thoughtspot: 10.0.0.cl
|
|
366
|
+
* @default false
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```js
|
|
370
|
+
* const embed = new AppEmbed('#embed', {
|
|
371
|
+
* ... // other app view config
|
|
372
|
+
* enableCustomColumnGroups: true,
|
|
373
|
+
* });
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
enableCustomColumnGroups?: boolean;
|
|
377
|
+
/**
|
|
378
|
+
* This flag is used to enable the 2 column layout in liveboard
|
|
379
|
+
*
|
|
380
|
+
* @type {boolean}
|
|
381
|
+
* @default false
|
|
382
|
+
* @version SDK: 1.32.0 | ThoughtSpot:10.1.0.cl
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```js
|
|
386
|
+
* const embed = new LiveboardEmbed('#embed-container', {
|
|
387
|
+
* ... // other options
|
|
388
|
+
* enable2ColumnLayout: true,
|
|
389
|
+
* })
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
enable2ColumnLayout?: boolean;
|
|
344
393
|
}
|
|
345
394
|
|
|
346
395
|
/**
|
|
@@ -387,6 +436,9 @@ export class AppEmbed extends V1Embed {
|
|
|
387
436
|
modularHomeExperience = false,
|
|
388
437
|
isLiveboardHeaderSticky = true,
|
|
389
438
|
enableAskSage,
|
|
439
|
+
collapseSearchBarInitially = false,
|
|
440
|
+
enable2ColumnLayout,
|
|
441
|
+
enableCustomColumnGroups = false,
|
|
390
442
|
} = this.viewConfig;
|
|
391
443
|
|
|
392
444
|
let params = {};
|
|
@@ -399,6 +451,7 @@ export class AppEmbed extends V1Embed {
|
|
|
399
451
|
params[Param.ShowLiveboardTitle] = showLiveboardTitle;
|
|
400
452
|
params[Param.ShowLiveboardDescription] = !!showLiveboardDescription;
|
|
401
453
|
params[Param.LiveboardHeaderSticky] = isLiveboardHeaderSticky;
|
|
454
|
+
params[Param.IsFullAppEmbed] = true;
|
|
402
455
|
|
|
403
456
|
params = this.getBaseQueryParams(params);
|
|
404
457
|
|
|
@@ -420,6 +473,10 @@ export class AppEmbed extends V1Embed {
|
|
|
420
473
|
params[Param.EnableSearchAssist] = enableSearchAssist;
|
|
421
474
|
}
|
|
422
475
|
|
|
476
|
+
if (enable2ColumnLayout !== undefined) {
|
|
477
|
+
params[Param.Enable2ColumnLayout] = enable2ColumnLayout;
|
|
478
|
+
}
|
|
479
|
+
|
|
423
480
|
if (enableAskSage) {
|
|
424
481
|
params[Param.enableAskSage] = enableAskSage;
|
|
425
482
|
}
|
|
@@ -427,6 +484,8 @@ export class AppEmbed extends V1Embed {
|
|
|
427
484
|
params[Param.DataPanelV2Enabled] = dataPanelV2;
|
|
428
485
|
params[Param.HideHomepageLeftNav] = hideHomepageLeftNav;
|
|
429
486
|
params[Param.ModularHomeExperienceEnabled] = modularHomeExperience;
|
|
487
|
+
params[Param.CollapseSearchBarInitially] = collapseSearchBarInitially;
|
|
488
|
+
params[Param.EnableCustomColumnGroups] = enableCustomColumnGroups;
|
|
430
489
|
const queryParams = getQueryParamString(params, true);
|
|
431
490
|
|
|
432
491
|
return queryParams;
|
package/src/embed/base.spec.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
|
+
import { EmbedConfig } from '../index';
|
|
4
5
|
import * as auth from '../auth';
|
|
6
|
+
import * as authService from '../utils/authService/authService';
|
|
5
7
|
import * as authTokenService from '../authToken';
|
|
6
8
|
import * as index from '../index';
|
|
7
|
-
import { EmbedConfig } from '../index';
|
|
8
|
-
import * as authService from '../utils/authService/authService';
|
|
9
9
|
import * as base from './base';
|
|
10
10
|
import * as embedConfigInstance from './embedConfig';
|
|
11
11
|
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
executeAfterWait,
|
|
14
14
|
getAllIframeEl,
|
|
15
15
|
getDocumentBody,
|
|
16
|
-
getIFrameSrc,
|
|
17
16
|
getRootEl,
|
|
17
|
+
getIFrameSrc,
|
|
18
18
|
} from '../test/test-utils';
|
|
19
19
|
import * as tokenizedFetchInstance from '../tokenizedFetch';
|
|
20
20
|
import { logger } from '../utils/logger';
|
package/src/embed/base.ts
CHANGED
|
@@ -10,28 +10,28 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import EventEmitter from 'eventemitter3';
|
|
12
12
|
import uniq from 'lodash/uniq';
|
|
13
|
+
import { resetCachedAuthToken } from '../authToken';
|
|
14
|
+
import { logger, setGlobalLogLevelOverride } from '../utils/logger';
|
|
15
|
+
import { tokenizedFetch } from '../tokenizedFetch';
|
|
16
|
+
import { EndPoints } from '../utils/authService/authService';
|
|
17
|
+
import { getThoughtSpotHost } from '../config';
|
|
13
18
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
AuthType, EmbedConfig, LogLevel, PrefetchFeatures,
|
|
20
|
+
} from '../types';
|
|
21
|
+
import {
|
|
22
|
+
authenticate,
|
|
23
|
+
logout as _logout,
|
|
16
24
|
AuthFailureType,
|
|
17
25
|
AuthStatus,
|
|
18
|
-
|
|
19
|
-
authenticate,
|
|
26
|
+
AuthEvent,
|
|
20
27
|
notifyAuthFailure,
|
|
21
28
|
notifyAuthSDKSuccess,
|
|
22
29
|
notifyAuthSuccess,
|
|
23
30
|
notifyLogout,
|
|
24
31
|
setAuthEE,
|
|
32
|
+
AuthEventEmitter,
|
|
25
33
|
} from '../auth';
|
|
26
|
-
import {
|
|
27
|
-
import { getThoughtSpotHost } from '../config';
|
|
28
|
-
import { MIXPANEL_EVENT, uploadMixpanelEvent } from '../mixpanel-service';
|
|
29
|
-
import { tokenizedFetch } from '../tokenizedFetch';
|
|
30
|
-
import {
|
|
31
|
-
AuthType, EmbedConfig, LogLevel, PrefetchFeatures,
|
|
32
|
-
} from '../types';
|
|
33
|
-
import { EndPoints } from '../utils/authService/authService';
|
|
34
|
-
import { logger, setGlobalLogLevelOverride } from '../utils/logger';
|
|
34
|
+
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
|
|
35
35
|
import { getEmbedConfig, setEmbedConfig } from './embedConfig';
|
|
36
36
|
|
|
37
37
|
const CONFIG_DEFAULTS: Partial<EmbedConfig> = {
|
|
@@ -251,7 +251,7 @@ export const renderInQueue = (fn: (next?: (val?: any) => void) => Promise<any>):
|
|
|
251
251
|
return renderQueue;
|
|
252
252
|
}
|
|
253
253
|
// Sending an empty function to keep it consistent with the above usage.
|
|
254
|
-
return fn(() => {}); // eslint-disable-line @typescript-eslint/no-empty-function
|
|
254
|
+
return fn(() => { }); // eslint-disable-line @typescript-eslint/no-empty-function
|
|
255
255
|
};
|
|
256
256
|
|
|
257
257
|
/**
|
|
@@ -110,6 +110,21 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
+
test('should set enable2ColumnLayout to true in url', async () => {
|
|
114
|
+
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
115
|
+
enable2ColumnLayout: true,
|
|
116
|
+
...defaultViewConfig,
|
|
117
|
+
liveboardId,
|
|
118
|
+
} as LiveboardViewConfig);
|
|
119
|
+
liveboardEmbed.render();
|
|
120
|
+
await executeAfterWait(() => {
|
|
121
|
+
expectUrlMatchesWithParams(
|
|
122
|
+
getIFrameSrc(),
|
|
123
|
+
`http://${thoughtSpotHost}/?embedApp=true${defaultParams}&enable2ColumnLayout=true${prefixParams}#/embed/viz/${liveboardId}`,
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
113
128
|
test('should set visible actions as empty array', async () => {
|
|
114
129
|
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
115
130
|
visibleActions: [],
|
|
@@ -269,6 +284,63 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
269
284
|
expect(onSpy).toHaveBeenCalledWith(EmbedEvent.EmbedHeight, expect.anything());
|
|
270
285
|
});
|
|
271
286
|
});
|
|
287
|
+
|
|
288
|
+
test('should not call setIFrameHeight if currentPath starts with "/embed/viz/"', () => {
|
|
289
|
+
const myObject = new LiveboardEmbed(getRootEl(), {
|
|
290
|
+
...defaultViewConfig,
|
|
291
|
+
fullHeight: true,
|
|
292
|
+
liveboardId,
|
|
293
|
+
} as LiveboardViewConfig) as any;
|
|
294
|
+
const spySetIFrameHeight = jest.spyOn(myObject, 'setIFrameHeight');
|
|
295
|
+
|
|
296
|
+
myObject.render();
|
|
297
|
+
myObject.setIframeHeightForNonEmbedLiveboard({
|
|
298
|
+
data: { currentPath: '/embed/viz/' },
|
|
299
|
+
type: 'Route',
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// Assert that setIFrameHeight is not called
|
|
303
|
+
expect(spySetIFrameHeight).not.toHaveBeenCalled();
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
test('should not call setIFrameHeight if currentPath starts with "/embed/insights/viz/"', () => {
|
|
307
|
+
const myObject = new LiveboardEmbed(getRootEl(), {
|
|
308
|
+
...defaultViewConfig,
|
|
309
|
+
fullHeight: true,
|
|
310
|
+
liveboardId,
|
|
311
|
+
} as LiveboardViewConfig) as any;
|
|
312
|
+
const spySetIFrameHeight = jest.spyOn(myObject, 'setIFrameHeight');
|
|
313
|
+
|
|
314
|
+
myObject.render();
|
|
315
|
+
myObject.setIframeHeightForNonEmbedLiveboard({
|
|
316
|
+
data: { currentPath: '/embed/insights/viz/' },
|
|
317
|
+
type: 'Route',
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// Assert that setIFrameHeight is not called
|
|
321
|
+
expect(spySetIFrameHeight).not.toHaveBeenCalled();
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
test('should call setIFrameHeight if currentPath starts with "/some/other/path/"', () => {
|
|
325
|
+
const myObject = new LiveboardEmbed(getRootEl(), {
|
|
326
|
+
...defaultViewConfig,
|
|
327
|
+
fullHeight: true,
|
|
328
|
+
liveboardId,
|
|
329
|
+
} as LiveboardViewConfig) as any;
|
|
330
|
+
const spySetIFrameHeight = jest
|
|
331
|
+
.spyOn(myObject, 'setIFrameHeight')
|
|
332
|
+
.mockImplementation(jest.fn());
|
|
333
|
+
|
|
334
|
+
myObject.render();
|
|
335
|
+
myObject.setIframeHeightForNonEmbedLiveboard({
|
|
336
|
+
data: { currentPath: '/some/other/path/' },
|
|
337
|
+
type: 'Route',
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
// Assert that setIFrameHeight is not called
|
|
341
|
+
expect(spySetIFrameHeight).toHaveBeenCalled();
|
|
342
|
+
});
|
|
343
|
+
|
|
272
344
|
test('Should set the visible vizs', async () => {
|
|
273
345
|
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
274
346
|
...defaultViewConfig,
|
|
@@ -467,22 +539,23 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
467
539
|
|
|
468
540
|
let resizeObserverCb: any;
|
|
469
541
|
(window as any).ResizeObserver = window.ResizeObserver
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
542
|
+
|| jest.fn().mockImplementation((resizeObserverCbParam) => {
|
|
543
|
+
resizeObserverCb = resizeObserverCbParam;
|
|
544
|
+
return {
|
|
545
|
+
disconnect: jest.fn(),
|
|
546
|
+
observe: jest.fn(),
|
|
547
|
+
unobserve: jest.fn(),
|
|
548
|
+
};
|
|
476
549
|
});
|
|
477
|
-
});
|
|
478
550
|
|
|
479
551
|
libEmbed.preRender();
|
|
480
552
|
|
|
481
553
|
await waitFor(() => !!getIFrameEl());
|
|
482
554
|
|
|
483
555
|
const ts = '__tsEmbed';
|
|
484
|
-
expect(document.getElementById(libEmbed.getPreRenderIds().wrapper)[ts])
|
|
485
|
-
|
|
556
|
+
expect(document.getElementById(libEmbed.getPreRenderIds().wrapper)[ts]).toEqual(
|
|
557
|
+
libEmbed,
|
|
558
|
+
);
|
|
486
559
|
|
|
487
560
|
const testLiveboardId = 'testLiveboardId';
|
|
488
561
|
const newLibEmbed = new LiveboardEmbed(getRootEl(), {
|
package/src/embed/liveboard.ts
CHANGED
|
@@ -11,9 +11,16 @@
|
|
|
11
11
|
|
|
12
12
|
import { ERROR_MESSAGE } from '../errors';
|
|
13
13
|
import {
|
|
14
|
-
|
|
14
|
+
EmbedEvent,
|
|
15
|
+
MessagePayload,
|
|
16
|
+
Param,
|
|
17
|
+
RuntimeFilter,
|
|
18
|
+
DOMSelector,
|
|
19
|
+
HostEvent,
|
|
20
|
+
ViewConfig,
|
|
15
21
|
} from '../types';
|
|
16
22
|
import { getQueryParamString, isUndefined } from '../utils';
|
|
23
|
+
import { getAuthPromise } from './base';
|
|
17
24
|
import { V1Embed } from './ts-embed';
|
|
18
25
|
|
|
19
26
|
/**
|
|
@@ -37,6 +44,7 @@ export interface LiveboardViewConfig
|
|
|
37
44
|
* incrementally as users scroll the page to view the charts and tables.
|
|
38
45
|
*
|
|
39
46
|
* @version SDK: 1.1.0 | ThoughtSpot: ts7.may.cl, 7.2.1
|
|
47
|
+
*
|
|
40
48
|
* @example
|
|
41
49
|
* ```js
|
|
42
50
|
* const embed = new LiveboardEmbed('#embed', {
|
|
@@ -65,6 +73,7 @@ export interface LiveboardViewConfig
|
|
|
65
73
|
defaultHeight?: number;
|
|
66
74
|
/**
|
|
67
75
|
* @Deprecated If set to true, the context menu in visualizations will be enabled.
|
|
76
|
+
*
|
|
68
77
|
* @example
|
|
69
78
|
* ```js
|
|
70
79
|
* const embed = new LiveboardEmbed('#tsEmbed', {
|
|
@@ -72,6 +81,7 @@ export interface LiveboardViewConfig
|
|
|
72
81
|
* enableVizTransformations:true,
|
|
73
82
|
* })
|
|
74
83
|
* ```
|
|
84
|
+
*
|
|
75
85
|
* @version: SDK: 1.1.0 | ThoughtSpot: 8.1.0.sw
|
|
76
86
|
*/
|
|
77
87
|
enableVizTransformations?: boolean;
|
|
@@ -98,6 +108,7 @@ export interface LiveboardViewConfig
|
|
|
98
108
|
* The visualization within the Liveboard to display.
|
|
99
109
|
*
|
|
100
110
|
* @version SDK: 1.9.1 | ThoughtSpot: 8.1.0.cl, 8.4.1-sw
|
|
111
|
+
*
|
|
101
112
|
* @example
|
|
102
113
|
* ```js
|
|
103
114
|
* const embed = new LiveboardEmbed('#embed-container', {
|
|
@@ -127,6 +138,7 @@ export interface LiveboardViewConfig
|
|
|
127
138
|
* event.
|
|
128
139
|
*
|
|
129
140
|
* @version SDK: 1.9.1 | ThoughtSpot: 8.1.0.cl, 8.4.1-sw
|
|
141
|
+
*
|
|
130
142
|
* @example
|
|
131
143
|
* ```js
|
|
132
144
|
* const embed = new LiveboardEmbed('#embed-container', {
|
|
@@ -176,6 +188,7 @@ export interface LiveboardViewConfig
|
|
|
176
188
|
* Show or hide the tab panel of the embedded Liveboard.
|
|
177
189
|
*
|
|
178
190
|
* @version SDK: 1.25.0 | Thoughtspot: 9.6.0.cl, 9.8.0.sw
|
|
191
|
+
*
|
|
179
192
|
* @example
|
|
180
193
|
* ```js
|
|
181
194
|
* const embed = new LiveboardEmbed('#embed-container', {
|
|
@@ -201,9 +214,9 @@ export interface LiveboardViewConfig
|
|
|
201
214
|
hideLiveboardHeader?: boolean;
|
|
202
215
|
/**
|
|
203
216
|
* Show or hide the Liveboard title.
|
|
204
|
-
*
|
|
205
217
|
* @default false
|
|
206
218
|
* @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl, 9.8.0.sw
|
|
219
|
+
*
|
|
207
220
|
* @example
|
|
208
221
|
* ```js
|
|
209
222
|
* const embed = new LiveboardEmbed('#embed-container', {
|
|
@@ -215,9 +228,9 @@ export interface LiveboardViewConfig
|
|
|
215
228
|
showLiveboardTitle?: boolean;
|
|
216
229
|
/**
|
|
217
230
|
* Show or hide the Liveboard description.
|
|
218
|
-
*
|
|
219
231
|
* @default false
|
|
220
232
|
* @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl, 9.8.0.sw
|
|
233
|
+
*
|
|
221
234
|
* @example
|
|
222
235
|
* ```js
|
|
223
236
|
* const embed = new LiveboardEmbed('#embed-container', {
|
|
@@ -256,6 +269,22 @@ export interface LiveboardViewConfig
|
|
|
256
269
|
* ```
|
|
257
270
|
*/
|
|
258
271
|
enableAskSage?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* This flag is used to enable the 2 column layout in liveboard
|
|
274
|
+
*
|
|
275
|
+
* @type {boolean}
|
|
276
|
+
* @default false
|
|
277
|
+
* @version SDK: 1.32.0 | ThoughtSpot:10.1.0.cl
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```js
|
|
281
|
+
* const embed = new LiveboardEmbed('#embed-container', {
|
|
282
|
+
* ... // other options
|
|
283
|
+
* enable2ColumnLayout: true,
|
|
284
|
+
* })
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
enable2ColumnLayout?: boolean;
|
|
259
288
|
}
|
|
260
289
|
|
|
261
290
|
/**
|
|
@@ -312,6 +341,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
312
341
|
showLiveboardTitle,
|
|
313
342
|
isLiveboardHeaderSticky = true,
|
|
314
343
|
enableAskSage,
|
|
344
|
+
enable2ColumnLayout,
|
|
315
345
|
} = this.viewConfig;
|
|
316
346
|
|
|
317
347
|
const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval
|
|
@@ -339,6 +369,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
339
369
|
if (liveboardV2 !== undefined) {
|
|
340
370
|
params[Param.LiveboardV2Enabled] = liveboardV2;
|
|
341
371
|
}
|
|
372
|
+
if (enable2ColumnLayout !== undefined) {
|
|
373
|
+
params[Param.Enable2ColumnLayout] = enable2ColumnLayout;
|
|
374
|
+
}
|
|
342
375
|
if (hideTabPanel) {
|
|
343
376
|
params[Param.HideTabPanel] = hideTabPanel;
|
|
344
377
|
}
|
|
@@ -409,9 +442,13 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
409
442
|
};
|
|
410
443
|
|
|
411
444
|
private setIframeHeightForNonEmbedLiveboard = (data: MessagePayload) => {
|
|
412
|
-
if (
|
|
413
|
-
|
|
445
|
+
if (
|
|
446
|
+
data.data.currentPath.startsWith('/embed/viz/')
|
|
447
|
+
|| data.data.currentPath.startsWith('/embed/insights/viz/')
|
|
448
|
+
) {
|
|
449
|
+
return;
|
|
414
450
|
}
|
|
451
|
+
this.setIFrameHeight(this.defaultHeight);
|
|
415
452
|
};
|
|
416
453
|
|
|
417
454
|
private setActiveTab(data: { tabId: string }) {
|