@thoughtspot/visual-embed-sdk 1.12.0-alpha.2 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -6
- package/README.md +1 -1
- package/dist/src/auth.d.ts +17 -1
- package/dist/src/auth.spec.d.ts +1 -0
- package/dist/src/embed/base.d.ts +1 -0
- package/dist/src/embed/liveboard.d.ts +7 -1
- package/dist/src/embed/search.d.ts +5 -0
- package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts +1 -0
- package/dist/src/embed/ts-embed.d.ts +2 -1
- package/dist/src/errors.d.ts +1 -0
- package/dist/src/types.d.ts +19 -2
- package/dist/src/utils.d.ts +1 -0
- package/dist/tsembed.es.js +80 -7
- package/dist/tsembed.js +80 -7
- package/lib/package.json +4 -2
- package/lib/src/auth.d.ts +17 -1
- package/lib/src/auth.js +23 -2
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.d.ts +1 -0
- package/lib/src/auth.spec.js +4 -1
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/app.spec.js +4 -3
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -0
- package/lib/src/embed/base.js +10 -0
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +16 -0
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +2 -0
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +1 -0
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +7 -1
- package/lib/src/embed/liveboard.js +12 -0
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +18 -4
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.spec.js +4 -3
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/search.d.ts +5 -0
- package/lib/src/embed/search.js +10 -2
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +9 -1
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts +1 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.js +96 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -0
- package/lib/src/embed/ts-embed.d.ts +2 -1
- package/lib/src/embed/ts-embed.js +7 -5
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +12 -5
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.d.ts +1 -0
- package/lib/src/errors.js +1 -0
- package/lib/src/errors.js.map +1 -1
- package/lib/src/react/index.js +3 -2
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +3 -2
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +19 -2
- package/lib/src/types.js +11 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils.d.ts +1 -0
- package/lib/src/utils.js +11 -0
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +22 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +50 -5
- package/package.json +5 -3
- package/src/auth.spec.ts +10 -1
- package/src/auth.ts +24 -2
- package/src/embed/app.spec.ts +4 -3
- package/src/embed/base.spec.ts +18 -0
- package/src/embed/base.ts +10 -0
- package/src/embed/embed.spec.ts +2 -0
- package/src/embed/events.spec.ts +1 -0
- package/src/embed/liveboard.spec.ts +27 -4
- package/src/embed/liveboard.ts +13 -0
- package/src/embed/pinboard.spec.ts +4 -3
- package/src/embed/search.spec.ts +11 -1
- package/src/embed/search.ts +20 -1
- package/src/embed/searchEmbed-basic-auth.spec.ts +115 -0
- package/src/embed/ts-embed.spec.ts +19 -5
- package/src/embed/ts-embed.ts +8 -5
- package/src/errors.ts +2 -0
- package/src/react/index.spec.tsx +4 -2
- package/src/react/index.tsx +3 -2
- package/src/types.ts +17 -0
- package/src/utils.spec.ts +29 -0
- package/src/utils.ts +16 -0
|
@@ -151,6 +151,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/base' {
|
|
|
151
151
|
export let authPromise: Promise<boolean>;
|
|
152
152
|
export const getEmbedConfig: () => EmbedConfig;
|
|
153
153
|
export const getAuthPromise: () => Promise<boolean>;
|
|
154
|
+
export function notifyAuthSDKSuccess(): void;
|
|
154
155
|
export function notifyAuthSuccess(): void;
|
|
155
156
|
export function notifyAuthFailure(failureType: AuthFailureType): void;
|
|
156
157
|
export function notifyLogout(): void;
|
|
@@ -207,7 +208,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
207
208
|
* @summary Liveboard & visualization embed
|
|
208
209
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
209
210
|
*/
|
|
210
|
-
import { DOMSelector } from '@thoughtspot/visual-embed-sdk/types';
|
|
211
|
+
import { DOMSelector, HostEvent } from '@thoughtspot/visual-embed-sdk/types';
|
|
211
212
|
import { V1Embed, ViewConfig } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
|
|
212
213
|
/**
|
|
213
214
|
* The configuration for the embedded Liveboard or visualization page view.
|
|
@@ -278,6 +279,12 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
278
279
|
export class LiveboardEmbed extends V1Embed {
|
|
279
280
|
protected viewConfig: LiveboardViewConfig;
|
|
280
281
|
constructor(domSelector: DOMSelector, viewConfig: LiveboardViewConfig);
|
|
282
|
+
/**
|
|
283
|
+
* Triggers an event to the embedded app
|
|
284
|
+
* @param messageType The event type
|
|
285
|
+
* @param data The payload to send with the message
|
|
286
|
+
*/
|
|
287
|
+
trigger(messageType: HostEvent, data?: any): Promise<any>;
|
|
281
288
|
/**
|
|
282
289
|
* Render an embedded ThoughtSpot Liveboard or visualization
|
|
283
290
|
* @param renderOptions An object specifying the Liveboard ID,
|
|
@@ -339,8 +346,13 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
339
346
|
* using raw answer data.
|
|
340
347
|
*/
|
|
341
348
|
hideResults?: boolean;
|
|
349
|
+
/**
|
|
350
|
+
* If set to true, expands all the data sources panel.
|
|
351
|
+
*/
|
|
352
|
+
expandAllDataSource?: boolean;
|
|
342
353
|
/**
|
|
343
354
|
* If set to true, the Search Assist feature is enabled.
|
|
355
|
+
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl
|
|
344
356
|
*/
|
|
345
357
|
enableSearchAssist?: boolean;
|
|
346
358
|
/**
|
|
@@ -391,7 +403,6 @@ declare module '@thoughtspot/visual-embed-sdk/auth' {
|
|
|
391
403
|
export let loggedInStatus: boolean;
|
|
392
404
|
export let samlAuthWindow: Window;
|
|
393
405
|
export let samlCompletionPromise: Promise<void>;
|
|
394
|
-
export let sessionInfo: any;
|
|
395
406
|
export const SSO_REDIRECTION_MARKER_GUID = "5e16222e-ef02-43e9-9fbd-24226bf3ce5b";
|
|
396
407
|
export const EndPoints: {
|
|
397
408
|
AUTH_VERIFICATION: string;
|
|
@@ -408,10 +419,27 @@ declare module '@thoughtspot/visual-embed-sdk/auth' {
|
|
|
408
419
|
OTHER = "OTHER"
|
|
409
420
|
}
|
|
410
421
|
export enum AuthStatus {
|
|
422
|
+
/**
|
|
423
|
+
* Emits when the SDK fails to authenticate
|
|
424
|
+
*/
|
|
411
425
|
FAILURE = "FAILURE",
|
|
426
|
+
/**
|
|
427
|
+
* Emits when the SDK succeeds to authenticate
|
|
428
|
+
*/
|
|
429
|
+
SDK_SUCCESS = "SDK_SUCCESS",
|
|
430
|
+
/**
|
|
431
|
+
* Emits when the App sends a auth success
|
|
432
|
+
*/
|
|
412
433
|
SUCCESS = "SUCCESS",
|
|
434
|
+
/**
|
|
435
|
+
* Emits when there is a logout
|
|
436
|
+
*/
|
|
413
437
|
LOGOUT = "LOGOUT"
|
|
414
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Return releaseVersion if available
|
|
441
|
+
*/
|
|
442
|
+
export function getReleaseVersion(): string;
|
|
415
443
|
/**
|
|
416
444
|
* Return sessionInfo if available else make a loggedIn check to fetch the sessionInfo
|
|
417
445
|
*/
|
|
@@ -601,6 +629,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
601
629
|
* @version SDK: 1.10.4 | ThoughtSpot: *
|
|
602
630
|
*/
|
|
603
631
|
detectCookieAccessSlow?: boolean;
|
|
632
|
+
/**
|
|
633
|
+
* Hide beta alert warning message for SearchEmbed.
|
|
634
|
+
*
|
|
635
|
+
* @version SDK: 1.12.0 | ThoughtSpot: *
|
|
636
|
+
*/
|
|
637
|
+
suppressSearchEmbedBetaWarning?: boolean;
|
|
604
638
|
}
|
|
605
639
|
/**
|
|
606
640
|
* MessagePayload: Embed event payload: message type, data and status (start/end)
|
|
@@ -1015,7 +1049,14 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
1015
1049
|
* Gets the current pinboard content.
|
|
1016
1050
|
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl
|
|
1017
1051
|
*/
|
|
1018
|
-
getExportRequestForCurrentPinboard = "getExportRequestForCurrentPinboard"
|
|
1052
|
+
getExportRequestForCurrentPinboard = "getExportRequestForCurrentPinboard",
|
|
1053
|
+
/**
|
|
1054
|
+
* Fires the pin action on an embedded object
|
|
1055
|
+
* @param - incase of liveboard embed, takes in an object with vizId as a key
|
|
1056
|
+
* can be left empty for search and viz embeds
|
|
1057
|
+
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
|
|
1058
|
+
*/
|
|
1059
|
+
Pin = "pin"
|
|
1019
1060
|
}
|
|
1020
1061
|
/**
|
|
1021
1062
|
* The different visual modes that the data sources panel within
|
|
@@ -1209,7 +1250,11 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
1209
1250
|
/**
|
|
1210
1251
|
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
|
|
1211
1252
|
*/
|
|
1212
|
-
CreateMonitor = "createMonitor"
|
|
1253
|
+
CreateMonitor = "createMonitor",
|
|
1254
|
+
/**
|
|
1255
|
+
* @version SDK: 1.11.1 | ThoughtSpot: 8.3.0.cl
|
|
1256
|
+
*/
|
|
1257
|
+
ReportError = "reportError"
|
|
1213
1258
|
}
|
|
1214
1259
|
export interface SessionInterface {
|
|
1215
1260
|
sessionId: string;
|
|
@@ -1260,7 +1305,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
1260
1305
|
* This parameters will be passed on the iframe
|
|
1261
1306
|
* as is.
|
|
1262
1307
|
*/
|
|
1263
|
-
[key: string]: string | number | boolean;
|
|
1308
|
+
[key: string]: string | number | boolean | undefined;
|
|
1264
1309
|
}
|
|
1265
1310
|
/**
|
|
1266
1311
|
* The configuration object for an embedded view.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/visual-embed-sdk",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.2",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -45,7 +45,9 @@
|
|
|
45
45
|
"algoliasearch": "^4.10.5",
|
|
46
46
|
"classnames": "^2.3.1",
|
|
47
47
|
"eventemitter3": "^4.0.7",
|
|
48
|
-
"
|
|
48
|
+
"html-react-parser": "^1.4.12",
|
|
49
|
+
"mixpanel-browser": "^2.45.0",
|
|
50
|
+
"use-deep-compare-effect": "^1.8.1"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
53
|
"@mdx-js/mdx": "^1.6.22",
|
|
@@ -144,4 +146,4 @@
|
|
|
144
146
|
"globals": {
|
|
145
147
|
"window": {}
|
|
146
148
|
}
|
|
147
|
-
}
|
|
149
|
+
}
|
package/src/auth.spec.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as authInstance from './auth';
|
|
2
2
|
import * as authService from './utils/authService';
|
|
3
|
+
import * as checkReleaseVersionInBetaInstance from './utils';
|
|
3
4
|
import { AuthType, EmbedConfig } from './types';
|
|
4
5
|
import { executeAfterWait } from './test/test-utils';
|
|
5
6
|
|
|
@@ -8,7 +9,7 @@ const username = 'tsuser';
|
|
|
8
9
|
const password = '12345678';
|
|
9
10
|
const samalLoginUrl = `${thoughtSpotHost}/callosum/v1/saml/login?targetURLPath=%235e16222e-ef02-43e9-9fbd-24226bf3ce5b`;
|
|
10
11
|
|
|
11
|
-
const embedConfig: any = {
|
|
12
|
+
export const embedConfig: any = {
|
|
12
13
|
doTokenAuthSuccess: (token: string) => ({
|
|
13
14
|
thoughtSpotHost,
|
|
14
15
|
username,
|
|
@@ -242,6 +243,10 @@ describe('Unit test for auth', () => {
|
|
|
242
243
|
});
|
|
243
244
|
|
|
244
245
|
it('when user is loggedIn', async () => {
|
|
246
|
+
spyOn(
|
|
247
|
+
checkReleaseVersionInBetaInstance,
|
|
248
|
+
'checkReleaseVersionInBeta',
|
|
249
|
+
);
|
|
245
250
|
jest.spyOn(
|
|
246
251
|
authService,
|
|
247
252
|
'fetchSessionInfoService',
|
|
@@ -280,6 +285,10 @@ describe('Unit test for auth', () => {
|
|
|
280
285
|
});
|
|
281
286
|
|
|
282
287
|
it('when user is loggedIn & isAtSSORedirectUrl is true', async () => {
|
|
288
|
+
spyOn(
|
|
289
|
+
checkReleaseVersionInBetaInstance,
|
|
290
|
+
'checkReleaseVersionInBeta',
|
|
291
|
+
);
|
|
283
292
|
Object.defineProperty(window, 'location', {
|
|
284
293
|
value: {
|
|
285
294
|
href: authInstance.SSO_REDIRECTION_MARKER_GUID,
|
package/src/auth.ts
CHANGED
|
@@ -16,8 +16,8 @@ export let loggedInStatus = false;
|
|
|
16
16
|
export let samlAuthWindow: Window = null;
|
|
17
17
|
// eslint-disable-next-line import/no-mutable-exports
|
|
18
18
|
export let samlCompletionPromise: Promise<void> = null;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
let sessionInfo: any = null;
|
|
20
|
+
let releaseVersion = '';
|
|
21
21
|
|
|
22
22
|
export const SSO_REDIRECTION_MARKER_GUID =
|
|
23
23
|
'5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
@@ -41,8 +41,21 @@ export enum AuthFailureType {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export enum AuthStatus {
|
|
44
|
+
/**
|
|
45
|
+
* Emits when the SDK fails to authenticate
|
|
46
|
+
*/
|
|
44
47
|
FAILURE = 'FAILURE',
|
|
48
|
+
/**
|
|
49
|
+
* Emits when the SDK succeeds to authenticate
|
|
50
|
+
*/
|
|
51
|
+
SDK_SUCCESS = 'SDK_SUCCESS',
|
|
52
|
+
/**
|
|
53
|
+
* Emits when the App sends a auth success
|
|
54
|
+
*/
|
|
45
55
|
SUCCESS = 'SUCCESS',
|
|
56
|
+
/**
|
|
57
|
+
* Emits when there is a logout
|
|
58
|
+
*/
|
|
46
59
|
LOGOUT = 'LOGOUT',
|
|
47
60
|
}
|
|
48
61
|
|
|
@@ -55,12 +68,21 @@ async function isLoggedIn(thoughtSpotHost: string): Promise<boolean> {
|
|
|
55
68
|
let response = null;
|
|
56
69
|
try {
|
|
57
70
|
response = await fetchSessionInfoService(authVerificationUrl);
|
|
71
|
+
const sessionInfoResp = await response.json();
|
|
72
|
+
releaseVersion = sessionInfoResp.releaseVersion;
|
|
58
73
|
} catch (e) {
|
|
59
74
|
return false;
|
|
60
75
|
}
|
|
61
76
|
return response.status === 200;
|
|
62
77
|
}
|
|
63
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Return releaseVersion if available
|
|
81
|
+
*/
|
|
82
|
+
export function getReleaseVersion() {
|
|
83
|
+
return releaseVersion;
|
|
84
|
+
}
|
|
85
|
+
|
|
64
86
|
/**
|
|
65
87
|
* Return sessionInfo if available else make a loggedIn check to fetch the sessionInfo
|
|
66
88
|
*/
|
package/src/embed/app.spec.ts
CHANGED
|
@@ -19,8 +19,9 @@ const defaultViewConfig = {
|
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
const thoughtSpotHost = 'tshost';
|
|
22
|
-
const
|
|
23
|
-
const
|
|
22
|
+
const defaultParamsWithoutHiddenActions = `&hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}`;
|
|
23
|
+
const defaultParams = `${defaultParamsWithoutHiddenActions}&hideAction=[%22${Action.ReportError}%22]`;
|
|
24
|
+
const defaultParamsForPinboardEmbed = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&hideAction=[%22${Action.ReportError}%22]`;
|
|
24
25
|
const defaultParamsPost = '&isPinboardV2Enabled=false';
|
|
25
26
|
|
|
26
27
|
beforeAll(() => {
|
|
@@ -155,7 +156,7 @@ describe('App embed tests', () => {
|
|
|
155
156
|
appEmbed.render();
|
|
156
157
|
await executeAfterWait(() => {
|
|
157
158
|
expect(getIFrameSrc()).toBe(
|
|
158
|
-
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=false&profileAndHelpInNavBarHidden=false${
|
|
159
|
+
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=false&profileAndHelpInNavBarHidden=false${defaultParamsWithoutHiddenActions}&disableAction=[%22save%22,%22update%22]&disableHint=Access%20denied&hideAction=[%22${Action.ReportError}%22,%22download%22]${defaultParamsPost}#/home`,
|
|
159
160
|
);
|
|
160
161
|
});
|
|
161
162
|
});
|
package/src/embed/base.spec.ts
CHANGED
|
@@ -113,6 +113,24 @@ describe('Base TS Embed', () => {
|
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
+
test('handleAuth notifies for SDK auth success', (done) => {
|
|
117
|
+
jest.spyOn(auth, 'authenticate').mockResolvedValue(true);
|
|
118
|
+
const failureCallback = jest.fn();
|
|
119
|
+
const authEmitter = index.init({
|
|
120
|
+
thoughtSpotHost,
|
|
121
|
+
authType: index.AuthType.Basic,
|
|
122
|
+
username: 'test',
|
|
123
|
+
password: 'test',
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
authEmitter.on(auth.AuthStatus.FAILURE, failureCallback);
|
|
127
|
+
authEmitter.on(auth.AuthStatus.SDK_SUCCESS, (reason) => {
|
|
128
|
+
expect(failureCallback).not.toBeCalled();
|
|
129
|
+
expect(reason).toBe(undefined);
|
|
130
|
+
done();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
116
134
|
test('Logout method should disable autoLogin', () => {
|
|
117
135
|
jest.spyOn(window, 'fetch').mockResolvedValue({
|
|
118
136
|
type: 'opaque',
|
package/src/embed/base.ts
CHANGED
|
@@ -32,6 +32,14 @@ export const getAuthPromise = (): Promise<boolean> => authPromise;
|
|
|
32
32
|
|
|
33
33
|
let authEE: EventEmitter;
|
|
34
34
|
|
|
35
|
+
export function notifyAuthSDKSuccess(): void {
|
|
36
|
+
if (!authEE) {
|
|
37
|
+
console.error('SDK not initialized');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
authEE.emit(AuthStatus.SDK_SUCCESS);
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
export function notifyAuthSuccess(): void {
|
|
36
44
|
if (!authEE) {
|
|
37
45
|
console.error('SDK not initialized');
|
|
@@ -64,6 +72,8 @@ export const handleAuth = (): Promise<boolean> => {
|
|
|
64
72
|
(isLoggedIn) => {
|
|
65
73
|
if (!isLoggedIn) {
|
|
66
74
|
notifyAuthFailure(AuthFailureType.SDK);
|
|
75
|
+
} else {
|
|
76
|
+
notifyAuthSDKSuccess();
|
|
67
77
|
}
|
|
68
78
|
},
|
|
69
79
|
() => {
|
package/src/embed/embed.spec.ts
CHANGED
|
@@ -20,6 +20,7 @@ beforeAll(() => {
|
|
|
20
20
|
thoughtSpotHost,
|
|
21
21
|
authType: AuthType.None,
|
|
22
22
|
});
|
|
23
|
+
spyOn(window, 'alert');
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
describe('test view config', () => {
|
|
@@ -48,6 +49,7 @@ describe('test view config', () => {
|
|
|
48
49
|
});
|
|
49
50
|
|
|
50
51
|
test('trying to register event handler after render should throw error', async () => {
|
|
52
|
+
spyOn(console, 'error');
|
|
51
53
|
const onErrorSpy = jest.fn();
|
|
52
54
|
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
53
55
|
searchEmbed
|
package/src/embed/events.spec.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { LiveboardEmbed, LiveboardViewConfig } from './liveboard';
|
|
2
2
|
import { init } from '../index';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Action,
|
|
5
|
+
AuthType,
|
|
6
|
+
EmbedEvent,
|
|
7
|
+
HostEvent,
|
|
8
|
+
RuntimeFilterOp,
|
|
9
|
+
} from '../types';
|
|
4
10
|
import {
|
|
5
11
|
executeAfterWait,
|
|
6
12
|
getDocumentBody,
|
|
@@ -8,6 +14,7 @@ import {
|
|
|
8
14
|
getRootEl,
|
|
9
15
|
} from '../test/test-utils';
|
|
10
16
|
import { version } from '../../package.json';
|
|
17
|
+
import * as processTriggerInstance from '../utils/processTrigger';
|
|
11
18
|
|
|
12
19
|
const defaultViewConfig = {
|
|
13
20
|
frameParams: {
|
|
@@ -18,7 +25,8 @@ const defaultViewConfig = {
|
|
|
18
25
|
const liveboardId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
|
|
19
26
|
const vizId = '6e73f724-660e-11eb-ae93-0242ac130002';
|
|
20
27
|
const thoughtSpotHost = 'tshost';
|
|
21
|
-
const
|
|
28
|
+
const defaultParamsSansHideAction = `&hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}`;
|
|
29
|
+
const defaultParams = `${defaultParamsSansHideAction}&hideAction=[%22${Action.ReportError}%22]`;
|
|
22
30
|
const prefixParams = '&isLiveboardEmbed=true&isPinboardV2Enabled=false';
|
|
23
31
|
|
|
24
32
|
beforeAll(() => {
|
|
@@ -60,7 +68,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
60
68
|
liveboardEmbed.render();
|
|
61
69
|
await executeAfterWait(() => {
|
|
62
70
|
expect(getIFrameSrc()).toBe(
|
|
63
|
-
`http://${thoughtSpotHost}/?embedApp=true${
|
|
71
|
+
`http://${thoughtSpotHost}/?embedApp=true${defaultParamsSansHideAction}&disableAction=[%22${Action.DownloadAsCsv}%22,%22${Action.DownloadAsPdf}%22,%22${Action.DownloadAsXlsx}%22]&disableHint=Action%20denied&hideAction=[%22${Action.ReportError}%22]${prefixParams}#/embed/viz/${liveboardId}`,
|
|
64
72
|
);
|
|
65
73
|
});
|
|
66
74
|
});
|
|
@@ -78,7 +86,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
78
86
|
liveboardEmbed.render();
|
|
79
87
|
await executeAfterWait(() => {
|
|
80
88
|
expect(getIFrameSrc()).toBe(
|
|
81
|
-
`http://${thoughtSpotHost}/?embedApp=true${
|
|
89
|
+
`http://${thoughtSpotHost}/?embedApp=true${defaultParamsSansHideAction}&hideAction=[%22${Action.ReportError}%22,%22${Action.DownloadAsCsv}%22,%22${Action.DownloadAsPdf}%22,%22${Action.DownloadAsXlsx}%22]${prefixParams}#/embed/viz/${liveboardId}`,
|
|
82
90
|
);
|
|
83
91
|
});
|
|
84
92
|
});
|
|
@@ -209,4 +217,19 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
209
217
|
);
|
|
210
218
|
});
|
|
211
219
|
});
|
|
220
|
+
test('should process the trigger, for vizEmbed', async () => {
|
|
221
|
+
const mockProcessTrigger = spyOn(
|
|
222
|
+
processTriggerInstance,
|
|
223
|
+
'processTrigger',
|
|
224
|
+
);
|
|
225
|
+
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
226
|
+
enableVizTransformations: true,
|
|
227
|
+
...defaultViewConfig,
|
|
228
|
+
vizId: '1234',
|
|
229
|
+
liveboardId,
|
|
230
|
+
} as LiveboardViewConfig);
|
|
231
|
+
liveboardEmbed.render();
|
|
232
|
+
const result = await liveboardEmbed.trigger(HostEvent.Pin);
|
|
233
|
+
expect(mockProcessTrigger).toBeCalled();
|
|
234
|
+
});
|
|
212
235
|
});
|
package/src/embed/liveboard.ts
CHANGED
|
@@ -194,6 +194,19 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Triggers an event to the embedded app
|
|
199
|
+
* @param messageType The event type
|
|
200
|
+
* @param data The payload to send with the message
|
|
201
|
+
*/
|
|
202
|
+
public trigger(messageType: HostEvent, data: any = {}): Promise<any> {
|
|
203
|
+
const dataWithVizId = data;
|
|
204
|
+
if (this.viewConfig.vizId) {
|
|
205
|
+
dataWithVizId.vizId = this.viewConfig.vizId;
|
|
206
|
+
}
|
|
207
|
+
return super.trigger(messageType, dataWithVizId);
|
|
208
|
+
}
|
|
209
|
+
|
|
197
210
|
/**
|
|
198
211
|
* Render an embedded ThoughtSpot Liveboard or visualization
|
|
199
212
|
* @param renderOptions An object specifying the Liveboard ID,
|
|
@@ -18,7 +18,8 @@ const defaultViewConfig = {
|
|
|
18
18
|
const pinboardId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
|
|
19
19
|
const vizId = '6e73f724-660e-11eb-ae93-0242ac130002';
|
|
20
20
|
const thoughtSpotHost = 'tshost';
|
|
21
|
-
const
|
|
21
|
+
const defaultParamsWithoutHideActions = `&hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}`;
|
|
22
|
+
const defaultParams = `${defaultParamsWithoutHideActions}&hideAction=[%22${Action.ReportError}%22]`;
|
|
22
23
|
const prefixParams = '&isLiveboardEmbed=true&isPinboardV2Enabled=false';
|
|
23
24
|
|
|
24
25
|
beforeAll(() => {
|
|
@@ -60,7 +61,7 @@ describe('Pinboard/viz embed tests', () => {
|
|
|
60
61
|
pinboardEmbed.render();
|
|
61
62
|
await executeAfterWait(() => {
|
|
62
63
|
expect(getIFrameSrc()).toBe(
|
|
63
|
-
`http://${thoughtSpotHost}/?embedApp=true${
|
|
64
|
+
`http://${thoughtSpotHost}/?embedApp=true${defaultParamsWithoutHideActions}&disableAction=[%22${Action.DownloadAsCsv}%22,%22${Action.DownloadAsPdf}%22,%22${Action.DownloadAsXlsx}%22]&disableHint=Action%20denied&hideAction=[%22${Action.ReportError}%22]${prefixParams}#/embed/viz/${pinboardId}`,
|
|
64
65
|
);
|
|
65
66
|
});
|
|
66
67
|
});
|
|
@@ -78,7 +79,7 @@ describe('Pinboard/viz embed tests', () => {
|
|
|
78
79
|
pinboardEmbed.render();
|
|
79
80
|
await executeAfterWait(() => {
|
|
80
81
|
expect(getIFrameSrc()).toBe(
|
|
81
|
-
`http://${thoughtSpotHost}/?embedApp=true${
|
|
82
|
+
`http://${thoughtSpotHost}/?embedApp=true${defaultParamsWithoutHideActions}&hideAction=[%22${Action.ReportError}%22,%22${Action.DownloadAsCsv}%22,%22${Action.DownloadAsPdf}%22,%22${Action.DownloadAsXlsx}%22]${prefixParams}#/embed/viz/${pinboardId}`,
|
|
82
83
|
);
|
|
83
84
|
});
|
|
84
85
|
});
|
package/src/embed/search.spec.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SearchEmbed, HiddenActionItemByDefaultForSearchEmbed } from './search';
|
|
2
|
+
import * as authInstance from '../auth';
|
|
2
3
|
import { init } from '../index';
|
|
3
4
|
import { Action, AuthType } from '../types';
|
|
4
5
|
import {
|
|
@@ -20,7 +21,10 @@ const answerId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
|
|
|
20
21
|
const thoughtSpotHost = 'tshost';
|
|
21
22
|
const defaultParams = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}`;
|
|
22
23
|
const hideBydefault = `&hideAction=${fixedEncodeURI(
|
|
23
|
-
JSON.stringify(
|
|
24
|
+
JSON.stringify([
|
|
25
|
+
Action.ReportError,
|
|
26
|
+
...HiddenActionItemByDefaultForSearchEmbed,
|
|
27
|
+
]),
|
|
24
28
|
)}`;
|
|
25
29
|
const defaultParamsWithHiddenActions = defaultParams + hideBydefault;
|
|
26
30
|
const prefixParams = '&isSearchEmbed=true';
|
|
@@ -30,11 +34,15 @@ beforeAll(() => {
|
|
|
30
34
|
thoughtSpotHost,
|
|
31
35
|
authType: AuthType.None,
|
|
32
36
|
});
|
|
37
|
+
spyOn(window, 'alert');
|
|
33
38
|
});
|
|
34
39
|
|
|
35
40
|
describe('Search embed tests', () => {
|
|
36
41
|
beforeEach(() => {
|
|
37
42
|
document.body.innerHTML = getDocumentBody();
|
|
43
|
+
jest.spyOn(authInstance, 'getReleaseVersion').mockReturnValue(
|
|
44
|
+
'7.4.0.sw',
|
|
45
|
+
);
|
|
38
46
|
});
|
|
39
47
|
|
|
40
48
|
test('should render', async () => {
|
|
@@ -197,6 +205,7 @@ describe('Search embed tests', () => {
|
|
|
197
205
|
searchEmbed.render();
|
|
198
206
|
const hideActionUrl = fixedEncodeURI(
|
|
199
207
|
JSON.stringify([
|
|
208
|
+
Action.ReportError,
|
|
200
209
|
...hiddenActionsForSearch,
|
|
201
210
|
...HiddenActionItemByDefaultForSearchEmbed,
|
|
202
211
|
]),
|
|
@@ -220,6 +229,7 @@ describe('Search embed tests', () => {
|
|
|
220
229
|
searchEmbed.render();
|
|
221
230
|
const hideActionUrl = fixedEncodeURI(
|
|
222
231
|
JSON.stringify([
|
|
232
|
+
Action.ReportError,
|
|
223
233
|
...hiddenActionsForSearch,
|
|
224
234
|
...HiddenActionItemByDefaultForSearchEmbed,
|
|
225
235
|
]),
|
package/src/embed/search.ts
CHANGED
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { DataSourceVisualMode, DOMSelector, Param, Action } from '../types';
|
|
11
|
-
import { getQueryParamString } from '../utils';
|
|
11
|
+
import { getQueryParamString, checkReleaseVersionInBeta } from '../utils';
|
|
12
12
|
import { ViewConfig, TsEmbed } from './ts-embed';
|
|
13
13
|
import { version } from '../../package.json';
|
|
14
|
+
import { ERROR_MESSAGE } from '../errors';
|
|
15
|
+
import { getAuthPromise, getEmbedConfig } from './base';
|
|
16
|
+
import { getReleaseVersion } from '../auth';
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
19
|
* Configuration for search options
|
|
@@ -49,8 +52,13 @@ export interface SearchViewConfig extends ViewConfig {
|
|
|
49
52
|
* using raw answer data.
|
|
50
53
|
*/
|
|
51
54
|
hideResults?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* If set to true, expands all the data sources panel.
|
|
57
|
+
*/
|
|
58
|
+
expandAllDataSource?: boolean;
|
|
52
59
|
/**
|
|
53
60
|
* If set to true, the Search Assist feature is enabled.
|
|
61
|
+
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl
|
|
54
62
|
*/
|
|
55
63
|
enableSearchAssist?: boolean;
|
|
56
64
|
/**
|
|
@@ -126,6 +134,7 @@ export class SearchEmbed extends TsEmbed {
|
|
|
126
134
|
private getIFrameSrc(answerId: string, dataSources?: string[]) {
|
|
127
135
|
const {
|
|
128
136
|
hideResults,
|
|
137
|
+
expandAllDataSource,
|
|
129
138
|
enableSearchAssist,
|
|
130
139
|
forceTable,
|
|
131
140
|
searchOptions,
|
|
@@ -184,6 +193,16 @@ export class SearchEmbed extends TsEmbed {
|
|
|
184
193
|
|
|
185
194
|
const src = this.getIFrameSrc(answerId, dataSources);
|
|
186
195
|
this.renderIFrame(src, this.viewConfig.frameParams);
|
|
196
|
+
getAuthPromise().then(() => {
|
|
197
|
+
if (
|
|
198
|
+
checkReleaseVersionInBeta(
|
|
199
|
+
getReleaseVersion(),
|
|
200
|
+
getEmbedConfig().suppressSearchEmbedBetaWarning,
|
|
201
|
+
)
|
|
202
|
+
) {
|
|
203
|
+
alert(ERROR_MESSAGE.SEARCHEMBED_BETA_WRANING_MESSAGE);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
187
206
|
return this;
|
|
188
207
|
}
|
|
189
208
|
}
|