@thoughtspot/visual-embed-sdk 1.30.0 → 1.31.0
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 +1 -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/embed/base.spec.js +1 -1
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.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 +6 -12
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/react/index.spec.js +2 -14
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +32 -5
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +32 -5
- package/cjs/src/types.js.map +1 -1
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/embed/liveboard.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 +32 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +7057 -7036
- package/dist/tsembed-react.js +7079 -7058
- package/dist/tsembed.es.js +7110 -7089
- package/dist/tsembed.js +7095 -7074
- package/dist/visual-embed-sdk-react-full.d.ts +32 -5
- package/dist/visual-embed-sdk-react.d.ts +32 -5
- package/dist/visual-embed-sdk.d.ts +32 -5
- package/lib/package.json +1 -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/embed/base.spec.js +2 -2
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +1 -1
- package/lib/src/embed/liveboard.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 +9 -15
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/react/index.spec.js +3 -15
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +32 -5
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +32 -5
- 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/visual-embed-sdk.d.ts +33 -6
- package/package.json +1 -1
- package/src/auth.ts +6 -6
- package/src/embed/base.spec.ts +3 -3
- package/src/embed/liveboard.ts +8 -1
- package/src/embed/ts-embed.ts +41 -44
- package/src/react/index.spec.tsx +59 -47
- package/src/types.ts +32 -5
- package/src/utils/authService/authService.spec.ts +4 -4
|
@@ -3797,18 +3797,30 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
3797
3797
|
*/
|
|
3798
3798
|
DownloadAsPdf = "downloadAsPdf",
|
|
3799
3799
|
/**
|
|
3800
|
-
* Trigger the **Make a copy** action on a Liveboard,
|
|
3801
|
-
* visualization page.
|
|
3800
|
+
* Trigger the **Make a copy** action on a Liveboard,
|
|
3801
|
+
* visualization, or Answer page.
|
|
3802
|
+
*
|
|
3802
3803
|
* @example
|
|
3803
3804
|
* ```js
|
|
3804
|
-
* liveboardEmbed.trigger(HostEvent.MakeACopy
|
|
3805
|
+
* liveboardEmbed.trigger(HostEvent.MakeACopy)
|
|
3805
3806
|
* ```
|
|
3807
|
+
*
|
|
3808
|
+
* @example
|
|
3809
|
+
* ```js
|
|
3810
|
+
* liveboardEmbed.trigger(HostEvent.MakeACopy, {
|
|
3811
|
+
* vizId: '730496d6-6903-4601-937e-2c691821af3c'})
|
|
3812
|
+
* ```
|
|
3813
|
+
*
|
|
3814
|
+
* @example
|
|
3806
3815
|
* ```js
|
|
3807
3816
|
* vizEmbed.trigger(HostEvent.MakeACopy)
|
|
3808
3817
|
* ```
|
|
3818
|
+
*
|
|
3819
|
+
* @example
|
|
3809
3820
|
* ```js
|
|
3810
3821
|
* searchEmbed.trigger(HostEvent.MakeACopy)
|
|
3811
3822
|
* ```
|
|
3823
|
+
*
|
|
3812
3824
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
3813
3825
|
*/
|
|
3814
3826
|
MakeACopy = "makeACopy",
|
|
@@ -3832,7 +3844,9 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
3832
3844
|
*/
|
|
3833
3845
|
Explore = "explore",
|
|
3834
3846
|
/**
|
|
3835
|
-
* Trigger the **Create alert** action on a
|
|
3847
|
+
* Trigger the **Create alert** action on a KPI chart
|
|
3848
|
+
* in a Liveboard or saved Answer.
|
|
3849
|
+
*
|
|
3836
3850
|
* @param - an object with `vizId` as a key
|
|
3837
3851
|
* @example
|
|
3838
3852
|
* ```js
|
|
@@ -3840,6 +3854,11 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
3840
3854
|
* vizId: '730496d6-6903-4601-937e-2c691821af3c'
|
|
3841
3855
|
* })
|
|
3842
3856
|
* ```
|
|
3857
|
+
*
|
|
3858
|
+
* @example
|
|
3859
|
+
* ```js
|
|
3860
|
+
* appEmbed.trigger(HostEvent.CreateMonitor)
|
|
3861
|
+
* ```
|
|
3843
3862
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
3844
3863
|
*/
|
|
3845
3864
|
CreateMonitor = "createMonitor",
|
|
@@ -4243,7 +4262,9 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
4243
4262
|
*/
|
|
4244
4263
|
UpdateSageQuery = "updateSageQuery",
|
|
4245
4264
|
/**
|
|
4246
|
-
* Get the answer session for a Search
|
|
4265
|
+
* Get the answer session for a Search or
|
|
4266
|
+
* Liveboard visualization.
|
|
4267
|
+
*
|
|
4247
4268
|
* @example
|
|
4248
4269
|
* ```js
|
|
4249
4270
|
* const {session} = await embed.trigger(
|
|
@@ -4251,6 +4272,12 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
4251
4272
|
* vizId: '123', // For Liveboard Visualization.
|
|
4252
4273
|
* })
|
|
4253
4274
|
* ```
|
|
4275
|
+
*
|
|
4276
|
+
* @example
|
|
4277
|
+
* ```js
|
|
4278
|
+
* const {session} = await embed.trigger( HostEvent.GetAnswerSession )
|
|
4279
|
+
* ```
|
|
4280
|
+
*
|
|
4254
4281
|
* @version SDK: 1.26.0 | Thoughtspot: 9.10.0.cl
|
|
4255
4282
|
*/
|
|
4256
4283
|
GetAnswerSession = "getAnswerSession",
|
|
@@ -6202,8 +6229,8 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
6202
6229
|
* @summary Base classes
|
|
6203
6230
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
6204
6231
|
*/
|
|
6205
|
-
import { DOMSelector, EmbedConfig, EmbedEvent, HostEvent, MessageCallback, MessageOptions, ViewConfig } from '@thoughtspot/visual-embed-sdk/types';
|
|
6206
6232
|
import { AnswerService } from '@thoughtspot/visual-embed-sdk/utils/graphql/answerService/answerService';
|
|
6233
|
+
import { DOMSelector, HostEvent, EmbedEvent, MessageCallback, EmbedConfig, MessageOptions, ViewConfig } from '@thoughtspot/visual-embed-sdk/types';
|
|
6207
6234
|
/**
|
|
6208
6235
|
* Global prefix for all Thoughtspot postHash Params.
|
|
6209
6236
|
*/
|
package/package.json
CHANGED
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
|
|
|
@@ -476,7 +476,7 @@ export const logout = async (embedConfig: EmbedConfig): Promise<boolean> => {
|
|
|
476
476
|
const { thoughtSpotHost } = embedConfig;
|
|
477
477
|
await fetchLogoutService(thoughtSpotHost);
|
|
478
478
|
resetCachedAuthToken();
|
|
479
|
-
const thoughtspotIframes = document.querySelectorAll(
|
|
479
|
+
const thoughtspotIframes = document.querySelectorAll('[data-ts-iframe=\'true\']');
|
|
480
480
|
if (thoughtspotIframes?.length) {
|
|
481
481
|
thoughtspotIframes.forEach((el) => {
|
|
482
482
|
el.parentElement.innerHTML = embedConfig.loginFailedMessage;
|
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/liveboard.ts
CHANGED
|
@@ -10,9 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
import { ERROR_MESSAGE } from '../errors';
|
|
12
12
|
import {
|
|
13
|
-
|
|
13
|
+
EmbedEvent,
|
|
14
|
+
MessagePayload,
|
|
15
|
+
Param,
|
|
16
|
+
RuntimeFilter,
|
|
17
|
+
DOMSelector,
|
|
18
|
+
HostEvent,
|
|
19
|
+
ViewConfig,
|
|
14
20
|
} from '../types';
|
|
15
21
|
import { getQueryParamString, isUndefined } from '../utils';
|
|
22
|
+
import { getAuthPromise } from './base';
|
|
16
23
|
import { V1Embed } from './ts-embed';
|
|
17
24
|
|
|
18
25
|
/**
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -7,54 +7,57 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import isEqual from 'lodash/isEqual';
|
|
10
|
-
import
|
|
11
|
-
import { AuthFailureType } from '../auth';
|
|
10
|
+
import { logger } from '../utils/logger';
|
|
12
11
|
import { getAuthenticationToken } from '../authToken';
|
|
12
|
+
import { AnswerService } from '../utils/graphql/answerService/answerService';
|
|
13
|
+
import {
|
|
14
|
+
getEncodedQueryParamsString,
|
|
15
|
+
getCssDimension,
|
|
16
|
+
getOffsetTop,
|
|
17
|
+
embedEventStatus,
|
|
18
|
+
setAttributes,
|
|
19
|
+
getCustomisations,
|
|
20
|
+
getRuntimeFilters,
|
|
21
|
+
getDOMNode,
|
|
22
|
+
getFilterQuery,
|
|
23
|
+
getQueryParamString,
|
|
24
|
+
getRuntimeParameters,
|
|
25
|
+
setStyleProperties,
|
|
26
|
+
removeStyleProperties,
|
|
27
|
+
isUndefined,
|
|
28
|
+
} from '../utils';
|
|
13
29
|
import {
|
|
14
|
-
DEFAULT_EMBED_HEIGHT,
|
|
15
|
-
DEFAULT_EMBED_WIDTH,
|
|
16
|
-
URL_MAX_LENGTH,
|
|
17
30
|
getThoughtSpotHost,
|
|
31
|
+
URL_MAX_LENGTH,
|
|
32
|
+
DEFAULT_EMBED_WIDTH,
|
|
33
|
+
DEFAULT_EMBED_HEIGHT,
|
|
18
34
|
getV2BasePath,
|
|
19
35
|
} from '../config';
|
|
20
|
-
import { MIXPANEL_EVENT, uploadMixpanelEvent } from '../mixpanel-service';
|
|
21
36
|
import {
|
|
22
|
-
Action,
|
|
23
37
|
AuthType,
|
|
24
|
-
ContextMenuTriggerOptions,
|
|
25
38
|
DOMSelector,
|
|
26
|
-
EmbedConfig,
|
|
27
|
-
EmbedEvent,
|
|
28
39
|
HostEvent,
|
|
40
|
+
EmbedEvent,
|
|
29
41
|
MessageCallback,
|
|
30
|
-
|
|
31
|
-
MessageOptions,
|
|
42
|
+
Action,
|
|
32
43
|
Param,
|
|
44
|
+
EmbedConfig,
|
|
45
|
+
MessageOptions,
|
|
46
|
+
MessagePayload,
|
|
47
|
+
MessageCallbackObj,
|
|
33
48
|
ViewConfig,
|
|
49
|
+
FrameParams,
|
|
50
|
+
ContextMenuTriggerOptions,
|
|
51
|
+
RuntimeFilter,
|
|
34
52
|
} from '../types';
|
|
35
|
-
import {
|
|
36
|
-
|
|
37
|
-
getCssDimension,
|
|
38
|
-
getCustomisations,
|
|
39
|
-
getDOMNode,
|
|
40
|
-
getEncodedQueryParamsString,
|
|
41
|
-
getFilterQuery,
|
|
42
|
-
getOffsetTop,
|
|
43
|
-
getQueryParamString,
|
|
44
|
-
getRuntimeFilters,
|
|
45
|
-
getRuntimeParameters,
|
|
46
|
-
isUndefined,
|
|
47
|
-
removeStyleProperties,
|
|
48
|
-
setAttributes,
|
|
49
|
-
setStyleProperties,
|
|
50
|
-
} from '../utils';
|
|
51
|
-
import { AnswerService } from '../utils/graphql/answerService/answerService';
|
|
52
|
-
import { logger } from '../utils/logger';
|
|
53
|
-
import { processAuthFailure, processEventData } from '../utils/processData';
|
|
53
|
+
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
|
|
54
|
+
import { processEventData, processAuthFailure } from '../utils/processData';
|
|
54
55
|
import { processTrigger } from '../utils/processTrigger';
|
|
56
|
+
import pkgInfo from '../../package.json';
|
|
55
57
|
import {
|
|
56
|
-
getAuthPromise, handleAuth, notifyAuthFailure,
|
|
58
|
+
getAuthPromise, renderInQueue, handleAuth, notifyAuthFailure,
|
|
57
59
|
} from './base';
|
|
60
|
+
import { AuthFailureType } from '../auth';
|
|
58
61
|
import { getEmbedConfig } from './embedConfig';
|
|
59
62
|
|
|
60
63
|
const { version } = pkgInfo;
|
|
@@ -588,7 +591,6 @@ export class TsEmbed {
|
|
|
588
591
|
* @param url - The URL of the embedded ThoughtSpot app.
|
|
589
592
|
*/
|
|
590
593
|
protected async renderIFrame(url: string): Promise<any> {
|
|
591
|
-
console.log('here 7');
|
|
592
594
|
if (this.isError) {
|
|
593
595
|
return null;
|
|
594
596
|
}
|
|
@@ -598,10 +600,8 @@ export class TsEmbed {
|
|
|
598
600
|
if (url.length > URL_MAX_LENGTH) {
|
|
599
601
|
// warn: The URL is too long
|
|
600
602
|
}
|
|
601
|
-
console.log('here 8');
|
|
602
603
|
|
|
603
604
|
return renderInQueue((nextInQueue) => {
|
|
604
|
-
console.log('here 6');
|
|
605
605
|
const initTimestamp = Date.now();
|
|
606
606
|
|
|
607
607
|
this.executeCallbacks(EmbedEvent.Init, {
|
|
@@ -614,7 +614,6 @@ export class TsEmbed {
|
|
|
614
614
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
615
615
|
return getAuthPromise()
|
|
616
616
|
?.then((isLoggedIn: boolean) => {
|
|
617
|
-
console.log('here 9', isLoggedIn);
|
|
618
617
|
if (!isLoggedIn) {
|
|
619
618
|
this.handleInsertionIntoDOM(this.embedConfig.loginFailedMessage);
|
|
620
619
|
return;
|
|
@@ -639,9 +638,7 @@ export class TsEmbed {
|
|
|
639
638
|
this.iFrame.addEventListener('error', () => {
|
|
640
639
|
nextInQueue();
|
|
641
640
|
});
|
|
642
|
-
console.log('here 10', this.iFrame);
|
|
643
641
|
this.handleInsertionIntoDOM(this.iFrame);
|
|
644
|
-
console.log('here 11', document.body.innerHTML);
|
|
645
642
|
const prefetchIframe = document.querySelectorAll('.prefetchIframe');
|
|
646
643
|
if (prefetchIframe.length) {
|
|
647
644
|
prefetchIframe.forEach((el) => {
|
|
@@ -685,7 +682,7 @@ export class TsEmbed {
|
|
|
685
682
|
protected connectPreRendered(): boolean {
|
|
686
683
|
const preRenderIds = this.getPreRenderIds();
|
|
687
684
|
this.preRenderWrapper = this.preRenderWrapper
|
|
688
|
-
|
|
685
|
+
|| document.getElementById(preRenderIds.wrapper);
|
|
689
686
|
|
|
690
687
|
this.preRenderChild = this.preRenderChild || document.getElementById(preRenderIds.child);
|
|
691
688
|
|
|
@@ -1090,11 +1087,11 @@ export class TsEmbed {
|
|
|
1090
1087
|
) {
|
|
1091
1088
|
logger.warn(
|
|
1092
1089
|
`${viewConfig.embedComponentType || 'Component'} was pre-rendered with `
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1090
|
+
+ `"${key}" as "${JSON.stringify(preRenderedObject.viewConfig[key])}" `
|
|
1091
|
+
+ `but a different value "${JSON.stringify(viewConfig[key])}" `
|
|
1092
|
+
+ 'was passed to the Embed component. '
|
|
1093
|
+
+ 'The new value provided is ignored, the value provided during '
|
|
1094
|
+
+ 'preRender is used.',
|
|
1098
1095
|
);
|
|
1099
1096
|
}
|
|
1100
1097
|
});
|
package/src/react/index.spec.tsx
CHANGED
|
@@ -15,15 +15,12 @@ import {
|
|
|
15
15
|
mockMessageChannel,
|
|
16
16
|
} from '../test/test-utils';
|
|
17
17
|
import {
|
|
18
|
-
SearchEmbed,
|
|
19
|
-
AppEmbed,
|
|
20
|
-
LiveboardEmbed,
|
|
21
|
-
useEmbedRef,
|
|
22
|
-
SearchBarEmbed,
|
|
23
|
-
PreRenderedLiveboardEmbed,
|
|
18
|
+
SearchEmbed, AppEmbed, LiveboardEmbed, useEmbedRef, SearchBarEmbed, PreRenderedLiveboardEmbed,
|
|
24
19
|
} from './index';
|
|
25
20
|
import * as allExports from './index';
|
|
26
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
AuthType, init,
|
|
23
|
+
} from '../index';
|
|
27
24
|
|
|
28
25
|
import { version } from '../../package.json';
|
|
29
26
|
|
|
@@ -46,9 +43,11 @@ describe('React Components', () => {
|
|
|
46
43
|
|
|
47
44
|
await waitFor(() => getIFrameEl(container));
|
|
48
45
|
|
|
49
|
-
expect(
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
expect(
|
|
47
|
+
getIFrameEl(container).parentElement.classList.contains(
|
|
48
|
+
'embedClass',
|
|
49
|
+
),
|
|
50
|
+
).toBe(true);
|
|
52
51
|
expect(getIFrameSrc(container)).toBe(
|
|
53
52
|
`http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&overrideConsoleLogs=true&clientLogLevel=ERROR&enableDataPanelV2=false&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true&collapseSearchBarInitially=false&enableCustomColumnGroups=false&dataPanelCustomGroupsAccordionInitialState=EXPAND_ALL#/embed/answer`,
|
|
54
53
|
);
|
|
@@ -145,53 +144,60 @@ describe('React Components', () => {
|
|
|
145
144
|
});
|
|
146
145
|
|
|
147
146
|
it('Should have the correct container element', async () => {
|
|
148
|
-
const { container } = render(
|
|
149
|
-
|
|
150
|
-
await waitFor(() => getIFrameEl(container));
|
|
151
|
-
expect(container.querySelector('div')).not.toBe(null);
|
|
152
|
-
expect(container.querySelector('div').classList.contains('def')).toBe(true);
|
|
153
|
-
|
|
154
|
-
const { container: containerSibling } = render(
|
|
155
|
-
<LiveboardEmbed liveboardId="abcd" className="def" insertAsSibling={true} />,
|
|
147
|
+
const { container } = render(
|
|
148
|
+
<LiveboardEmbed liveboardId="abcd" className="def" />,
|
|
156
149
|
);
|
|
157
|
-
await waitFor(() => getIFrameEl(containerSibling));
|
|
158
|
-
expect(containerSibling.querySelector('span')).not.toBe(null);
|
|
159
|
-
expect(containerSibling.querySelector('span').style.position).toBe('absolute');
|
|
160
|
-
expect(getIFrameEl(containerSibling).classList.contains('def')).toBe(true);
|
|
161
|
-
expect(containerSibling.querySelector('div')).toBe(null);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('Should have the correct container element', async () => {
|
|
165
|
-
const { container } = render(<LiveboardEmbed liveboardId="abcd" className="def" />);
|
|
166
150
|
|
|
167
151
|
await waitFor(() => getIFrameEl(container));
|
|
168
152
|
expect(container.querySelector('div')).not.toBe(null);
|
|
169
|
-
expect(
|
|
153
|
+
expect(
|
|
154
|
+
container.querySelector('div').classList.contains('def'),
|
|
155
|
+
).toBe(true);
|
|
170
156
|
|
|
171
157
|
const { container: containerSibling } = render(
|
|
172
|
-
<LiveboardEmbed
|
|
158
|
+
<LiveboardEmbed
|
|
159
|
+
liveboardId="abcd"
|
|
160
|
+
className="def"
|
|
161
|
+
insertAsSibling={true}
|
|
162
|
+
/>,
|
|
173
163
|
);
|
|
174
164
|
await waitFor(() => getIFrameEl(containerSibling));
|
|
175
165
|
expect(containerSibling.querySelector('span')).not.toBe(null);
|
|
176
|
-
expect(containerSibling.querySelector('span').style.position).toBe(
|
|
177
|
-
|
|
166
|
+
expect(containerSibling.querySelector('span').style.position).toBe(
|
|
167
|
+
'absolute',
|
|
168
|
+
);
|
|
169
|
+
expect(
|
|
170
|
+
getIFrameEl(containerSibling).classList.contains('def'),
|
|
171
|
+
).toBe(true);
|
|
178
172
|
expect(containerSibling.querySelector('div')).toBe(null);
|
|
179
173
|
});
|
|
180
174
|
|
|
181
175
|
it('Should have the correct container element', async () => {
|
|
182
|
-
const { container } = render(
|
|
176
|
+
const { container } = render(
|
|
177
|
+
<LiveboardEmbed liveboardId="abcd" className="def" />,
|
|
178
|
+
);
|
|
183
179
|
|
|
184
180
|
await waitFor(() => getIFrameEl(container));
|
|
185
181
|
expect(container.querySelector('div')).not.toBe(null);
|
|
186
|
-
expect(
|
|
182
|
+
expect(
|
|
183
|
+
container.querySelector('div').classList.contains('def'),
|
|
184
|
+
).toBe(true);
|
|
187
185
|
|
|
188
186
|
const { container: containerSibling } = render(
|
|
189
|
-
<LiveboardEmbed
|
|
187
|
+
<LiveboardEmbed
|
|
188
|
+
liveboardId="abcd"
|
|
189
|
+
className="def"
|
|
190
|
+
insertAsSibling={true}
|
|
191
|
+
/>,
|
|
190
192
|
);
|
|
191
193
|
await waitFor(() => getIFrameEl(containerSibling));
|
|
192
194
|
expect(containerSibling.querySelector('span')).not.toBe(null);
|
|
193
|
-
expect(containerSibling.querySelector('span').style.position).toBe(
|
|
194
|
-
|
|
195
|
+
expect(containerSibling.querySelector('span').style.position).toBe(
|
|
196
|
+
'absolute',
|
|
197
|
+
);
|
|
198
|
+
expect(
|
|
199
|
+
getIFrameEl(containerSibling).classList.contains('def'),
|
|
200
|
+
).toBe(true);
|
|
195
201
|
expect(containerSibling.querySelector('div')).toBe(null);
|
|
196
202
|
});
|
|
197
203
|
});
|
|
@@ -211,9 +217,11 @@ describe('React Components', () => {
|
|
|
211
217
|
|
|
212
218
|
await waitFor(() => getIFrameEl(container));
|
|
213
219
|
|
|
214
|
-
expect(
|
|
215
|
-
|
|
216
|
-
|
|
220
|
+
expect(
|
|
221
|
+
getIFrameEl(container).parentElement.classList.contains(
|
|
222
|
+
'embedClass',
|
|
223
|
+
),
|
|
224
|
+
).toBe(true);
|
|
217
225
|
expect(getIFrameSrc(container)).toBe(
|
|
218
226
|
`http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22]&overrideConsoleLogs=true&clientLogLevel=ERROR&dataSources=[%22test%22]&searchTokenString=%5Brevenue%5D&executeSearch=true&useLastSelectedSources=false&isSearchEmbed=true#/embed/search-bar-embed`,
|
|
219
227
|
);
|
|
@@ -233,9 +241,7 @@ describe('React Components', () => {
|
|
|
233
241
|
);
|
|
234
242
|
|
|
235
243
|
await waitFor(() => getIFrameEl());
|
|
236
|
-
const preRenderWrapper = document.body.querySelector(
|
|
237
|
-
`#${preRenderId}`,
|
|
238
|
-
) as HTMLDivElement;
|
|
244
|
+
const preRenderWrapper = document.body.querySelector(`#${preRenderId}`) as HTMLDivElement;
|
|
239
245
|
|
|
240
246
|
expect(preRenderWrapper).toBeInstanceOf(HTMLDivElement);
|
|
241
247
|
expect((preRenderWrapper as HTMLDivElement).childElementCount).toBe(1);
|
|
@@ -250,7 +256,11 @@ describe('React Components', () => {
|
|
|
250
256
|
unobserve: jest.fn(),
|
|
251
257
|
}));
|
|
252
258
|
const { container: libContainer } = render(
|
|
253
|
-
<LiveboardEmbed
|
|
259
|
+
<LiveboardEmbed
|
|
260
|
+
className="embedClass"
|
|
261
|
+
preRenderId="test"
|
|
262
|
+
liveboardId="libId"
|
|
263
|
+
/>,
|
|
254
264
|
);
|
|
255
265
|
|
|
256
266
|
expect(preRenderWrapper.style.opacity).toBe('');
|
|
@@ -266,9 +276,11 @@ describe('allExports', () => {
|
|
|
266
276
|
});
|
|
267
277
|
|
|
268
278
|
it('should not have undefined exports', () => {
|
|
269
|
-
Object.keys(allExports)
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
)
|
|
279
|
+
Object.keys(allExports).forEach(
|
|
280
|
+
(exportKey) => expect(
|
|
281
|
+
Boolean(allExports[exportKey]),
|
|
282
|
+
)
|
|
283
|
+
.toBe(true),
|
|
284
|
+
);
|
|
273
285
|
});
|
|
274
286
|
});
|
package/src/types.ts
CHANGED
|
@@ -2417,18 +2417,30 @@ export enum HostEvent {
|
|
|
2417
2417
|
*/
|
|
2418
2418
|
DownloadAsPdf = 'downloadAsPdf',
|
|
2419
2419
|
/**
|
|
2420
|
-
* Trigger the **Make a copy** action on a Liveboard,
|
|
2421
|
-
* visualization page.
|
|
2420
|
+
* Trigger the **Make a copy** action on a Liveboard,
|
|
2421
|
+
* visualization, or Answer page.
|
|
2422
|
+
*
|
|
2422
2423
|
* @example
|
|
2423
2424
|
* ```js
|
|
2424
|
-
* liveboardEmbed.trigger(HostEvent.MakeACopy
|
|
2425
|
+
* liveboardEmbed.trigger(HostEvent.MakeACopy)
|
|
2425
2426
|
* ```
|
|
2427
|
+
*
|
|
2428
|
+
* @example
|
|
2429
|
+
* ```js
|
|
2430
|
+
* liveboardEmbed.trigger(HostEvent.MakeACopy, {
|
|
2431
|
+
* vizId: '730496d6-6903-4601-937e-2c691821af3c'})
|
|
2432
|
+
* ```
|
|
2433
|
+
*
|
|
2434
|
+
* @example
|
|
2426
2435
|
* ```js
|
|
2427
2436
|
* vizEmbed.trigger(HostEvent.MakeACopy)
|
|
2428
2437
|
* ```
|
|
2438
|
+
*
|
|
2439
|
+
* @example
|
|
2429
2440
|
* ```js
|
|
2430
2441
|
* searchEmbed.trigger(HostEvent.MakeACopy)
|
|
2431
2442
|
* ```
|
|
2443
|
+
*
|
|
2432
2444
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
2433
2445
|
*/
|
|
2434
2446
|
MakeACopy = 'makeACopy',
|
|
@@ -2452,7 +2464,9 @@ export enum HostEvent {
|
|
|
2452
2464
|
*/
|
|
2453
2465
|
Explore = 'explore',
|
|
2454
2466
|
/**
|
|
2455
|
-
* Trigger the **Create alert** action on a
|
|
2467
|
+
* Trigger the **Create alert** action on a KPI chart
|
|
2468
|
+
* in a Liveboard or saved Answer.
|
|
2469
|
+
*
|
|
2456
2470
|
* @param - an object with `vizId` as a key
|
|
2457
2471
|
* @example
|
|
2458
2472
|
* ```js
|
|
@@ -2460,6 +2474,11 @@ export enum HostEvent {
|
|
|
2460
2474
|
* vizId: '730496d6-6903-4601-937e-2c691821af3c'
|
|
2461
2475
|
* })
|
|
2462
2476
|
* ```
|
|
2477
|
+
*
|
|
2478
|
+
* @example
|
|
2479
|
+
* ```js
|
|
2480
|
+
* appEmbed.trigger(HostEvent.CreateMonitor)
|
|
2481
|
+
* ```
|
|
2463
2482
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
2464
2483
|
*/
|
|
2465
2484
|
CreateMonitor = 'createMonitor',
|
|
@@ -2863,7 +2882,9 @@ export enum HostEvent {
|
|
|
2863
2882
|
*/
|
|
2864
2883
|
UpdateSageQuery = 'updateSageQuery',
|
|
2865
2884
|
/**
|
|
2866
|
-
* Get the answer session for a Search
|
|
2885
|
+
* Get the answer session for a Search or
|
|
2886
|
+
* Liveboard visualization.
|
|
2887
|
+
*
|
|
2867
2888
|
* @example
|
|
2868
2889
|
* ```js
|
|
2869
2890
|
* const {session} = await embed.trigger(
|
|
@@ -2871,6 +2892,12 @@ export enum HostEvent {
|
|
|
2871
2892
|
* vizId: '123', // For Liveboard Visualization.
|
|
2872
2893
|
* })
|
|
2873
2894
|
* ```
|
|
2895
|
+
*
|
|
2896
|
+
* @example
|
|
2897
|
+
* ```js
|
|
2898
|
+
* const {session} = await embed.trigger( HostEvent.GetAnswerSession )
|
|
2899
|
+
* ```
|
|
2900
|
+
*
|
|
2874
2901
|
* @version SDK: 1.26.0 | Thoughtspot: 9.10.0.cl
|
|
2875
2902
|
*/
|
|
2876
2903
|
GetAnswerSession = 'getAnswerSession',
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
fetchAuthPostService,
|
|
4
|
-
fetchAuthService,
|
|
2
|
+
fetchSessionInfoService,
|
|
5
3
|
fetchAuthTokenService,
|
|
4
|
+
fetchAuthService,
|
|
6
5
|
fetchBasicAuthService,
|
|
7
|
-
|
|
6
|
+
fetchAuthPostService,
|
|
8
7
|
verifyTokenService,
|
|
8
|
+
EndPoints,
|
|
9
9
|
} from '.';
|
|
10
10
|
import { logger } from '../logger';
|
|
11
11
|
|