@thoughtspot/visual-embed-sdk 1.39.0 → 1.39.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/cjs/package.json +1 -1
- package/cjs/src/embed/app.d.ts +13 -13
- package/cjs/src/embed/conversation.d.ts +4 -4
- package/cjs/src/embed/embedConfig.d.ts +47 -4
- package/cjs/src/embed/embedConfig.d.ts.map +1 -1
- package/cjs/src/embed/embedConfig.js +47 -4
- package/cjs/src/embed/embedConfig.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +2 -2
- package/cjs/src/embed/liveboard.js +1 -1
- package/cjs/src/embed/sage.d.ts +10 -10
- package/cjs/src/embed/search.d.ts +4 -4
- package/cjs/src/embed/ts-embed.d.ts +5 -0
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +16 -1
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +164 -0
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/types.d.ts +7 -6
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +6 -5
- package/cjs/src/types.js.map +1 -1
- package/dist/{index-sSREbWM-.js → index-CmEQfuE3.js} +1 -1
- package/dist/src/embed/app.d.ts +13 -13
- package/dist/src/embed/conversation.d.ts +4 -4
- package/dist/src/embed/embedConfig.d.ts +47 -4
- package/dist/src/embed/embedConfig.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +2 -2
- package/dist/src/embed/sage.d.ts +10 -10
- package/dist/src/embed/search.d.ts +4 -4
- package/dist/src/embed/ts-embed.d.ts +5 -0
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/types.d.ts +7 -6
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +73 -14
- package/dist/tsembed-react.js +72 -13
- package/dist/tsembed.es.js +73 -14
- package/dist/tsembed.js +72 -13
- package/dist/visual-embed-sdk-react-full.d.ts +87 -43
- package/dist/visual-embed-sdk-react.d.ts +87 -43
- package/dist/visual-embed-sdk.d.ts +87 -43
- package/lib/package.json +1 -1
- package/lib/src/embed/app.d.ts +13 -13
- package/lib/src/embed/conversation.d.ts +4 -4
- package/lib/src/embed/embedConfig.d.ts +47 -4
- package/lib/src/embed/embedConfig.d.ts.map +1 -1
- package/lib/src/embed/embedConfig.js +47 -4
- package/lib/src/embed/embedConfig.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/sage.d.ts +10 -10
- package/lib/src/embed/search.d.ts +4 -4
- package/lib/src/embed/ts-embed.d.ts +5 -0
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +16 -1
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +164 -0
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/types.d.ts +7 -6
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +6 -5
- package/lib/src/types.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +87 -43
- package/package.json +1 -1
- package/src/embed/app.ts +13 -13
- package/src/embed/conversation.ts +4 -4
- package/src/embed/embedConfig.ts +48 -5
- package/src/embed/liveboard.ts +2 -2
- package/src/embed/sage.ts +10 -10
- package/src/embed/search.ts +4 -4
- package/src/embed/ts-embed.spec.ts +225 -0
- package/src/embed/ts-embed.ts +19 -0
- package/src/types.ts +7 -6
package/src/embed/embedConfig.ts
CHANGED
|
@@ -4,9 +4,52 @@ import { EmbedConfig } from '../types';
|
|
|
4
4
|
const configKey = 'embedConfig';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Gets the configuration
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
7
|
+
* Gets the embed configuration settings that were used to
|
|
8
|
+
* initialize the SDK.
|
|
9
|
+
* @returns {@link EmbedConfig}
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* const config = getInitConfig();
|
|
14
|
+
* console.log(config);
|
|
15
|
+
* ```
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* Returns the `EmbedConfig` object, which
|
|
19
|
+
* contains the configuration settings used to
|
|
20
|
+
* initialize the SDK, including the following:
|
|
21
|
+
*
|
|
22
|
+
* - `thoughtSpotHost` - ThoughtSpot host URL
|
|
23
|
+
* - `authType`: The authentication method used. For example,
|
|
24
|
+
* `AuthServerCookieless` for `AuthType.TrustedAuthTokenCookieless`
|
|
25
|
+
* - `customizations` - Style, text, and icon customization settings
|
|
26
|
+
* that were applied during the SDK initialization.
|
|
27
|
+
*
|
|
28
|
+
* For a comprehensive list of embed configuration settings,
|
|
29
|
+
* see link:https://developers.thoughtspot.com/docs/Interface_EmbedConfig[Developer Documentation].
|
|
30
|
+
*
|
|
31
|
+
* ```json
|
|
32
|
+
* {
|
|
33
|
+
* "thoughtSpotHost": "https://{ThoughtSpot-Host}",
|
|
34
|
+
* "authType": "AuthServerCookieless",
|
|
35
|
+
* "customizations": {
|
|
36
|
+
* "style": {
|
|
37
|
+
* "customCSS": {
|
|
38
|
+
* "variables": {
|
|
39
|
+
* "--ts-var-button--secondary-background": "#7492d5",
|
|
40
|
+
* "--ts-var-button--secondary--hovers-background": "#aac2f8",
|
|
41
|
+
* "--ts-var-root-background": "#f1f4f8"
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* },
|
|
46
|
+
* "loginFailedMessage": "Login failed, please try again",
|
|
47
|
+
* "authTriggerText": "Authorize",
|
|
48
|
+
* "disableTokenVerification": true,
|
|
49
|
+
* "authTriggerContainer": "#your-own-div"
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
* @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1.cl, and later
|
|
10
53
|
* @group Global methods
|
|
11
54
|
*/
|
|
12
55
|
export const getEmbedConfig = (): EmbedConfig => getValueFromWindow(configKey) || ({} as any);
|
|
@@ -15,10 +58,10 @@ export const getEmbedConfig = (): EmbedConfig => getValueFromWindow(configKey) |
|
|
|
15
58
|
* Sets the configuration embed was initialized with.
|
|
16
59
|
* And returns the new configuration.
|
|
17
60
|
* @param newConfig The configuration to set.
|
|
18
|
-
* @version SDK: 1.27.0 | ThoughtSpot:
|
|
61
|
+
* @version SDK: 1.27.0 | ThoughtSpot: 9.8.0.cl, 9.8.1.sw, and later
|
|
19
62
|
* @group Global methods
|
|
20
63
|
*/
|
|
21
64
|
export const setEmbedConfig = (newConfig: EmbedConfig) => {
|
|
22
65
|
storeValueInWindow(configKey, newConfig);
|
|
23
66
|
return getValueFromWindow(configKey);
|
|
24
|
-
};
|
|
67
|
+
};
|
package/src/embed/liveboard.ts
CHANGED
|
@@ -192,7 +192,7 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
192
192
|
* Show or hide the tab panel of the embedded Liveboard.
|
|
193
193
|
*
|
|
194
194
|
* Supported embed types: `LiveboardEmbed`
|
|
195
|
-
* @version SDK: 1.25.0 |
|
|
195
|
+
* @version SDK: 1.25.0 | ThoughtSpot: 9.6.0.cl, 9.8.0.sw
|
|
196
196
|
* @example
|
|
197
197
|
* ```js
|
|
198
198
|
* const embed = new LiveboardEmbed('#tsEmbed', {
|
|
@@ -674,7 +674,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
674
674
|
|
|
675
675
|
/**
|
|
676
676
|
* Returns the full url of the Liveboard/visualization which can be used to open
|
|
677
|
-
* this Liveboard inside the full
|
|
677
|
+
* this Liveboard inside the full ThoughtSpot application in a new tab.
|
|
678
678
|
* @returns url string
|
|
679
679
|
*/
|
|
680
680
|
public getLiveboardUrl(): string {
|
package/src/embed/sage.ts
CHANGED
|
@@ -48,39 +48,39 @@ export interface SageViewConfig
|
|
|
48
48
|
showObjectResults?: boolean;
|
|
49
49
|
/**
|
|
50
50
|
* flag used by the TS product tour page to show the blue search bar
|
|
51
|
-
* even after the search is completed. This is different from
|
|
51
|
+
* even after the search is completed. This is different from ThoughtSpot Embedded
|
|
52
52
|
* Sage Embed experience where it mimics closer to the non-embed case.
|
|
53
53
|
* The Sample questions container is collapsed when this value is set after
|
|
54
54
|
* does a search.
|
|
55
|
-
* @version SDK: 1.26.0 |
|
|
55
|
+
* @version SDK: 1.26.0 | ThoughtSpot: 9.8.0.cl
|
|
56
56
|
* @hidden
|
|
57
57
|
*/
|
|
58
58
|
isProductTour?: boolean;
|
|
59
59
|
/**
|
|
60
60
|
* Show or hide the search bar title.
|
|
61
|
-
* @version SDK: 1.29.0 |
|
|
62
|
-
* @deprecated
|
|
61
|
+
* @version SDK: 1.29.0 | ThoughtSpot: 9.8.0.cl, 9.8.0.sw
|
|
62
|
+
* @deprecated ThoughtSpot: 9.10.0.cl | search bar doesn't have the title from 9.10.0.cl
|
|
63
63
|
*/
|
|
64
64
|
hideSearchBarTitle?: boolean;
|
|
65
65
|
/**
|
|
66
66
|
* Show or hide the Answer header, that is, the `AI Answer` title
|
|
67
67
|
* at the top of the Answer page.
|
|
68
|
-
* @version SDK: 1.26.0 |
|
|
68
|
+
* @version SDK: 1.26.0 | ThoughtSpot: 9.10.0.cl
|
|
69
69
|
*/
|
|
70
70
|
hideSageAnswerHeader?: boolean;
|
|
71
71
|
/**
|
|
72
72
|
* Disable the worksheet selection option.
|
|
73
|
-
* @version SDK: 1.26.0 |
|
|
73
|
+
* @version SDK: 1.26.0 | ThoughtSpot: 9.8.0.cl, 9.8.0.sw
|
|
74
74
|
*/
|
|
75
75
|
disableWorksheetChange?: boolean;
|
|
76
76
|
/**
|
|
77
77
|
* Hide the worksheet selection panel.
|
|
78
|
-
* @version SDK: 1.26.0 |
|
|
78
|
+
* @version SDK: 1.26.0 | ThoughtSpot: 9.8.0.cl, 9.8.0.sw
|
|
79
79
|
*/
|
|
80
80
|
hideWorksheetSelector?: boolean;
|
|
81
81
|
/**
|
|
82
82
|
* Show or hide autocomplete suggestions for the search query string.
|
|
83
|
-
* @version SDK: 1.26.0 |
|
|
83
|
+
* @version SDK: 1.26.0 | ThoughtSpot: 9.8.0.cl, 9.8.0.sw
|
|
84
84
|
*/
|
|
85
85
|
hideAutocompleteSuggestions?: boolean;
|
|
86
86
|
/**
|
|
@@ -96,7 +96,7 @@ export interface SageViewConfig
|
|
|
96
96
|
* selected for the search operation.
|
|
97
97
|
*
|
|
98
98
|
* Supported embed types: `SageEmbed`
|
|
99
|
-
* @version SDK: 1.26.0 |
|
|
99
|
+
* @version SDK: 1.26.0 | ThoughtSpot: 9.8.0.cl, 9.8.0.sw
|
|
100
100
|
* @example
|
|
101
101
|
* ```js
|
|
102
102
|
* const embed = new SageEmbed('#tsEmbed', {
|
|
@@ -129,7 +129,7 @@ export interface SageViewConfig
|
|
|
129
129
|
* executeSearch: true,
|
|
130
130
|
* }
|
|
131
131
|
* ```
|
|
132
|
-
* @version SDK: 1.26.0 |
|
|
132
|
+
* @version SDK: 1.26.0 | ThoughtSpot: 9.8.0.cl, 9.8.0.sw
|
|
133
133
|
*/
|
|
134
134
|
searchOptions?: SearchOptions;
|
|
135
135
|
}
|
package/src/embed/search.ts
CHANGED
|
@@ -272,7 +272,7 @@ export interface SearchViewConfig
|
|
|
272
272
|
/**
|
|
273
273
|
* To set the initial state of the search bar in case of saved-answers.
|
|
274
274
|
* @default false
|
|
275
|
-
* @version SDK: 1.32.0 |
|
|
275
|
+
* @version SDK: 1.32.0 | ThoughtSpot: 10.0.0.cl
|
|
276
276
|
* @deprecated Use {@link collapseSearchBar} instead
|
|
277
277
|
*/
|
|
278
278
|
collapseSearchBarInitially?: boolean;
|
|
@@ -280,7 +280,7 @@ export interface SearchViewConfig
|
|
|
280
280
|
* Flag to enable onBeforeSearchExecute Embed Event
|
|
281
281
|
*
|
|
282
282
|
* Supported embed types: `SearchEmbed`
|
|
283
|
-
* @version: SDK: 1.29.0 |
|
|
283
|
+
* @version: SDK: 1.29.0 | ThoughtSpot: 10.1.0.cl
|
|
284
284
|
*/
|
|
285
285
|
isOnBeforeGetVizDataInterceptEnabled?: boolean;
|
|
286
286
|
/**
|
|
@@ -292,7 +292,7 @@ export interface SearchViewConfig
|
|
|
292
292
|
* - EXPAND_FIRST: Expand the first accordion and collapse the rest.
|
|
293
293
|
*
|
|
294
294
|
* Supported embed types: `SearchEmbed`
|
|
295
|
-
* @version SDK: 1.32.0 |
|
|
295
|
+
* @version SDK: 1.32.0 | ThoughtSpot: 10.0.0.cl
|
|
296
296
|
* @default DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL
|
|
297
297
|
* @example
|
|
298
298
|
* ```js
|
|
@@ -309,7 +309,7 @@ export interface SearchViewConfig
|
|
|
309
309
|
* lands on search embed page.
|
|
310
310
|
*
|
|
311
311
|
* Supported embed types: `SearchEmbed`
|
|
312
|
-
* @version SDK: 1.32.0 |
|
|
312
|
+
* @version SDK: 1.32.0 | ThoughtSpot: 10.3.0.cl
|
|
313
313
|
* @default true
|
|
314
314
|
* @example
|
|
315
315
|
* ```js
|
|
@@ -1360,6 +1360,231 @@ describe('Unit test case for ts embed', () => {
|
|
|
1360
1360
|
});
|
|
1361
1361
|
});
|
|
1362
1362
|
|
|
1363
|
+
describe('Preauth Cache for FullAppEmbed with PrimaryNavBar', () => {
|
|
1364
|
+
beforeAll(() => {
|
|
1365
|
+
jest.clearAllMocks();
|
|
1366
|
+
init({
|
|
1367
|
+
thoughtSpotHost,
|
|
1368
|
+
authType: AuthType.None,
|
|
1369
|
+
});
|
|
1370
|
+
});
|
|
1371
|
+
afterEach(() => {
|
|
1372
|
+
jest.clearAllMocks();
|
|
1373
|
+
});
|
|
1374
|
+
|
|
1375
|
+
afterAll(() => {
|
|
1376
|
+
jest.clearAllMocks();
|
|
1377
|
+
});
|
|
1378
|
+
|
|
1379
|
+
const setupPreauthTest = async (
|
|
1380
|
+
embedType: 'AppEmbed' | 'SearchEmbed',
|
|
1381
|
+
showPrimaryNavbar?: boolean,
|
|
1382
|
+
overrideOrgId?: number,
|
|
1383
|
+
disablePreauthCache?: boolean
|
|
1384
|
+
) => {
|
|
1385
|
+
jest.spyOn(window, 'addEventListener').mockImplementationOnce(
|
|
1386
|
+
(event, handler, options) => {
|
|
1387
|
+
handler({
|
|
1388
|
+
data: { type: 'xyz' },
|
|
1389
|
+
ports: [3000],
|
|
1390
|
+
source: null,
|
|
1391
|
+
});
|
|
1392
|
+
},
|
|
1393
|
+
);
|
|
1394
|
+
mockProcessTrigger.mockResolvedValueOnce({ session: 'test' });
|
|
1395
|
+
jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValueOnce(true);
|
|
1396
|
+
|
|
1397
|
+
let mockGetPreauthInfo = null;
|
|
1398
|
+
|
|
1399
|
+
// Determine if preauth cache should be enabled
|
|
1400
|
+
const isAppEmbedWithPrimaryNavbar = embedType === 'AppEmbed' && showPrimaryNavbar === true;
|
|
1401
|
+
const shouldDisableCache = overrideOrgId || disablePreauthCache || isAppEmbedWithPrimaryNavbar;
|
|
1402
|
+
|
|
1403
|
+
if (shouldDisableCache) {
|
|
1404
|
+
mockGetPreauthInfo = jest.spyOn(sessionInfoService, 'getPreauthInfo')
|
|
1405
|
+
.mockImplementation(jest.fn());
|
|
1406
|
+
} else {
|
|
1407
|
+
mockGetPreauthInfo = jest.spyOn(sessionInfoService, 'getPreauthInfo')
|
|
1408
|
+
.mockResolvedValue({ info: { test: 'data' } });
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
const mockPreauthInfoFetch = jest.spyOn(authService, 'fetchPreauthInfoService')
|
|
1412
|
+
.mockResolvedValueOnce({
|
|
1413
|
+
ok: true,
|
|
1414
|
+
headers: new Headers({ 'content-type': 'application/json' }),
|
|
1415
|
+
json: async () => ({
|
|
1416
|
+
info: { test: 'data' },
|
|
1417
|
+
}),
|
|
1418
|
+
} as any);
|
|
1419
|
+
|
|
1420
|
+
const viewConfig: any = {
|
|
1421
|
+
frameParams: { width: 1280, height: 720 },
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
if (showPrimaryNavbar !== undefined) {
|
|
1425
|
+
viewConfig.showPrimaryNavbar = showPrimaryNavbar;
|
|
1426
|
+
}
|
|
1427
|
+
if (overrideOrgId !== undefined) {
|
|
1428
|
+
viewConfig.overrideOrgId = overrideOrgId;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
// Mock getEmbedConfig for disablePreauthCache
|
|
1432
|
+
if (disablePreauthCache !== undefined) {
|
|
1433
|
+
jest.spyOn(embedConfig, 'getEmbedConfig').mockReturnValueOnce({
|
|
1434
|
+
thoughtSpotHost,
|
|
1435
|
+
authType: AuthType.None,
|
|
1436
|
+
disablePreauthCache,
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
let embed;
|
|
1441
|
+
if (embedType === 'AppEmbed') {
|
|
1442
|
+
embed = new AppEmbed(getRootEl(), viewConfig);
|
|
1443
|
+
} else {
|
|
1444
|
+
embed = new SearchEmbed(getRootEl(), viewConfig);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
const iFrame: any = document.createElement('div');
|
|
1448
|
+
iFrame.contentWindow = {
|
|
1449
|
+
postMessage: jest.fn(),
|
|
1450
|
+
};
|
|
1451
|
+
jest.spyOn(iFrame, 'addEventListener').mockImplementationOnce(
|
|
1452
|
+
(event, handler, options) => {
|
|
1453
|
+
handler({});
|
|
1454
|
+
},
|
|
1455
|
+
);
|
|
1456
|
+
jest.spyOn(document, 'createElement').mockReturnValueOnce(iFrame);
|
|
1457
|
+
|
|
1458
|
+
await embed.render();
|
|
1459
|
+
|
|
1460
|
+
return {
|
|
1461
|
+
embed,
|
|
1462
|
+
mockGetPreauthInfo,
|
|
1463
|
+
mockPreauthInfoFetch,
|
|
1464
|
+
iFrame,
|
|
1465
|
+
};
|
|
1466
|
+
};
|
|
1467
|
+
|
|
1468
|
+
test('should disable preauth cache for FullAppEmbed with showPrimaryNavbar = true (default)', async () => {
|
|
1469
|
+
const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', true);
|
|
1470
|
+
|
|
1471
|
+
// Wait for any async operations
|
|
1472
|
+
await executeAfterWait(() => {
|
|
1473
|
+
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(0);
|
|
1474
|
+
});
|
|
1475
|
+
});
|
|
1476
|
+
|
|
1477
|
+
test('should enable preauth cache for FullAppEmbed with showPrimaryNavbar = undefined (no longer defaults to true)', async () => {
|
|
1478
|
+
const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', undefined);
|
|
1479
|
+
|
|
1480
|
+
await executeAfterWait(() => {
|
|
1481
|
+
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1482
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(
|
|
1483
|
+
expect.any(Object),
|
|
1484
|
+
HostEvent.InfoSuccess,
|
|
1485
|
+
'http://tshost',
|
|
1486
|
+
expect.objectContaining({ info: expect.any(Object) }),
|
|
1487
|
+
);
|
|
1488
|
+
});
|
|
1489
|
+
});
|
|
1490
|
+
|
|
1491
|
+
test('should enable preauth cache for FullAppEmbed with showPrimaryNavbar = false', async () => {
|
|
1492
|
+
const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', false);
|
|
1493
|
+
|
|
1494
|
+
await executeAfterWait(() => {
|
|
1495
|
+
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1496
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(
|
|
1497
|
+
expect.any(Object),
|
|
1498
|
+
HostEvent.InfoSuccess,
|
|
1499
|
+
'http://tshost',
|
|
1500
|
+
expect.objectContaining({ info: expect.any(Object) }),
|
|
1501
|
+
);
|
|
1502
|
+
});
|
|
1503
|
+
});
|
|
1504
|
+
|
|
1505
|
+
test('should enable preauth cache for SearchEmbed regardless of showPrimaryNavbar', async () => {
|
|
1506
|
+
const { mockGetPreauthInfo } = await setupPreauthTest('SearchEmbed', true);
|
|
1507
|
+
|
|
1508
|
+
await executeAfterWait(() => {
|
|
1509
|
+
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1510
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(
|
|
1511
|
+
expect.any(Object),
|
|
1512
|
+
HostEvent.InfoSuccess,
|
|
1513
|
+
'http://tshost',
|
|
1514
|
+
expect.objectContaining({ info: expect.any(Object) }),
|
|
1515
|
+
);
|
|
1516
|
+
});
|
|
1517
|
+
});
|
|
1518
|
+
|
|
1519
|
+
test('should enable preauth cache for SearchEmbed (verifies fix for embed type regression)', async () => {
|
|
1520
|
+
const { mockGetPreauthInfo } = await setupPreauthTest('SearchEmbed', false);
|
|
1521
|
+
|
|
1522
|
+
await executeAfterWait(() => {
|
|
1523
|
+
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(1);
|
|
1524
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(
|
|
1525
|
+
expect.any(Object),
|
|
1526
|
+
HostEvent.InfoSuccess,
|
|
1527
|
+
'http://tshost',
|
|
1528
|
+
expect.objectContaining({ info: expect.any(Object) }),
|
|
1529
|
+
);
|
|
1530
|
+
});
|
|
1531
|
+
});
|
|
1532
|
+
|
|
1533
|
+
test('should disable preauth cache for FullAppEmbed with overrideOrgId (combined condition)', async () => {
|
|
1534
|
+
const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', false, 123);
|
|
1535
|
+
|
|
1536
|
+
await executeAfterWait(() => {
|
|
1537
|
+
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(0);
|
|
1538
|
+
});
|
|
1539
|
+
});
|
|
1540
|
+
|
|
1541
|
+
test('should disable preauth cache for FullAppEmbed with disablePreauthCache = true', async () => {
|
|
1542
|
+
const { mockGetPreauthInfo } = await setupPreauthTest('AppEmbed', false, undefined, true);
|
|
1543
|
+
|
|
1544
|
+
await executeAfterWait(() => {
|
|
1545
|
+
expect(mockGetPreauthInfo).toHaveBeenCalledTimes(0);
|
|
1546
|
+
});
|
|
1547
|
+
});
|
|
1548
|
+
});
|
|
1549
|
+
|
|
1550
|
+
describe('isFullAppEmbedWithVisiblePrimaryNavbar helper method', () => {
|
|
1551
|
+
beforeAll(() => {
|
|
1552
|
+
init({
|
|
1553
|
+
thoughtSpotHost,
|
|
1554
|
+
authType: AuthType.None,
|
|
1555
|
+
});
|
|
1556
|
+
});
|
|
1557
|
+
|
|
1558
|
+
afterEach(() => {
|
|
1559
|
+
jest.clearAllMocks();
|
|
1560
|
+
});
|
|
1561
|
+
|
|
1562
|
+
test('should return true for AppEmbed with showPrimaryNavbar = true', () => {
|
|
1563
|
+
const appEmbed = new AppEmbed(getRootEl(), { showPrimaryNavbar: true });
|
|
1564
|
+
expect(appEmbed['isFullAppEmbedWithVisiblePrimaryNavbar']()).toBe(true);
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1567
|
+
test('should return false for AppEmbed with showPrimaryNavbar = undefined (no longer defaults to true)', () => {
|
|
1568
|
+
const appEmbed = new AppEmbed(getRootEl(), {});
|
|
1569
|
+
expect(appEmbed['isFullAppEmbedWithVisiblePrimaryNavbar']()).toBe(false);
|
|
1570
|
+
});
|
|
1571
|
+
|
|
1572
|
+
test('should return false for AppEmbed with showPrimaryNavbar = false', () => {
|
|
1573
|
+
const appEmbed = new AppEmbed(getRootEl(), { showPrimaryNavbar: false });
|
|
1574
|
+
expect(appEmbed['isFullAppEmbedWithVisiblePrimaryNavbar']()).toBe(false);
|
|
1575
|
+
});
|
|
1576
|
+
|
|
1577
|
+
test('should return false for SearchEmbed (not FullAppEmbed)', () => {
|
|
1578
|
+
const searchEmbed = new SearchEmbed(getRootEl(), {});
|
|
1579
|
+
expect(searchEmbed['isFullAppEmbedWithVisiblePrimaryNavbar']()).toBe(false);
|
|
1580
|
+
});
|
|
1581
|
+
|
|
1582
|
+
test('should return false for LiveboardEmbed (not FullAppEmbed)', () => {
|
|
1583
|
+
const liveboardEmbed = new LiveboardEmbed(getRootEl(), { liveboardId: 'test-id' });
|
|
1584
|
+
expect(liveboardEmbed['isFullAppEmbedWithVisiblePrimaryNavbar']()).toBe(false);
|
|
1585
|
+
});
|
|
1586
|
+
});
|
|
1587
|
+
|
|
1363
1588
|
describe('when thoughtSpotHost have value and authPromise return error', () => {
|
|
1364
1589
|
beforeAll(() => {
|
|
1365
1590
|
init({
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -264,13 +264,32 @@ export class TsEmbed {
|
|
|
264
264
|
// - cached auth info would be for wrong org
|
|
265
265
|
// - info call response changes for each different overrideOrgId
|
|
266
266
|
// 2. disablePreauthCache is explicitly set to true
|
|
267
|
+
// 3. FullAppEmbed has primary navbar visible since:
|
|
268
|
+
// - primary navbar requires fresh auth state for navigation
|
|
269
|
+
// - cached auth may not reflect current user permissions
|
|
267
270
|
const isDisabled = (
|
|
268
271
|
this.viewConfig.overrideOrgId !== undefined
|
|
269
272
|
|| this.embedConfig.disablePreauthCache === true
|
|
273
|
+
|| this.isFullAppEmbedWithVisiblePrimaryNavbar()
|
|
270
274
|
);
|
|
271
275
|
return !isDisabled;
|
|
272
276
|
}
|
|
273
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Checks if current embed is FullAppEmbed with visible primary navbar
|
|
280
|
+
* @returns boolean
|
|
281
|
+
*/
|
|
282
|
+
private isFullAppEmbedWithVisiblePrimaryNavbar(): boolean {
|
|
283
|
+
const appViewConfig = this.viewConfig as any;
|
|
284
|
+
|
|
285
|
+
// Check if this is a FullAppEmbed (AppEmbed)
|
|
286
|
+
// showPrimaryNavbar defaults to true if not explicitly set to false
|
|
287
|
+
return (
|
|
288
|
+
appViewConfig.embedComponentType === 'AppEmbed'
|
|
289
|
+
&& appViewConfig.showPrimaryNavbar === true
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
274
293
|
/**
|
|
275
294
|
* fix for ts7.sep.cl
|
|
276
295
|
* will be removed for ts7.oct.cl
|
package/src/types.ts
CHANGED
|
@@ -275,7 +275,7 @@ export interface CustomStyles {
|
|
|
275
275
|
* Configuration to define the customization on the Embedded
|
|
276
276
|
* ThoughtSpot components.
|
|
277
277
|
* You can customize styles, text strings, and icons.
|
|
278
|
-
* For more information, see https://developers.thoughtspot.com/docs/custom-css.
|
|
278
|
+
* For more information, see link:https://developers.thoughtspot.com/docs/custom-css[CSS customization framework].
|
|
279
279
|
* @example
|
|
280
280
|
* ```js
|
|
281
281
|
* init({
|
|
@@ -2554,7 +2554,7 @@ export enum EmbedEvent {
|
|
|
2554
2554
|
*
|
|
2555
2555
|
* error: Developers can customize the error message text when `execute`
|
|
2556
2556
|
* returns `false` using the error parameter in responder.
|
|
2557
|
-
* @version SDK : 1.29.0 | ThoughtSpot
|
|
2557
|
+
* @version SDK : 1.29.0 | ThoughtSpot: 10.3.0.cl
|
|
2558
2558
|
* @example
|
|
2559
2559
|
*```js
|
|
2560
2560
|
* .on(EmbedEvent.OnBeforeGetVizDataIntercept,
|
|
@@ -2601,7 +2601,7 @@ export enum EmbedEvent {
|
|
|
2601
2601
|
* console.log('payload', payload);
|
|
2602
2602
|
* })
|
|
2603
2603
|
*```
|
|
2604
|
-
* @version SDK : 1.29.0 | ThoughtSpot
|
|
2604
|
+
* @version SDK : 1.29.0 | ThoughtSpot: 10.3.0.cl
|
|
2605
2605
|
*/
|
|
2606
2606
|
ParameterChanged = 'parameterChanged',
|
|
2607
2607
|
/**
|
|
@@ -2657,18 +2657,18 @@ export enum EmbedEvent {
|
|
|
2657
2657
|
* console.log('payload', payload);
|
|
2658
2658
|
* })
|
|
2659
2659
|
*```
|
|
2660
|
-
* @version SDK : 1.37.0 | ThoughtSpot
|
|
2660
|
+
* @version SDK : 1.37.0 | ThoughtSpot: 10.8.0.cl
|
|
2661
2661
|
*/
|
|
2662
2662
|
CreateLiveboard = 'createLiveboard',
|
|
2663
2663
|
/**
|
|
2664
2664
|
* Emitted when a user creates a Model.
|
|
2665
|
-
* @version SDK : 1.37.0 | ThoughtSpot
|
|
2665
|
+
* @version SDK : 1.37.0 | ThoughtSpot: 10.8.0.cl
|
|
2666
2666
|
*/
|
|
2667
2667
|
CreateModel = 'createModel',
|
|
2668
2668
|
/**
|
|
2669
2669
|
* @hidden
|
|
2670
2670
|
* Emitted when a user exits present mode.
|
|
2671
|
-
* @version SDK : 1.40.0 | ThoughtSpot
|
|
2671
|
+
* @version SDK : 1.40.0 | ThoughtSpot: 10.11.0.cl
|
|
2672
2672
|
*/
|
|
2673
2673
|
ExitPresentMode = 'exitPresentMode',
|
|
2674
2674
|
}
|
|
@@ -3925,6 +3925,7 @@ export enum Param {
|
|
|
3925
3925
|
* hiddenActions: [Action.Edit, ActionAction.Explore],
|
|
3926
3926
|
* })
|
|
3927
3927
|
* ```
|
|
3928
|
+
* See also link:https://developers.thoughtspot.com/docs/actions[Action IDs in the SDK]
|
|
3928
3929
|
*/
|
|
3929
3930
|
// eslint-disable-next-line no-shadow
|
|
3930
3931
|
export enum Action {
|