@thoughtspot/visual-embed-sdk 1.26.0 → 1.26.1-alpha.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 +2 -2
- package/cjs/src/auth.d.ts +0 -12
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +16 -54
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/auth.spec.d.ts.map +1 -1
- package/cjs/src/auth.spec.js +42 -32
- package/cjs/src/auth.spec.js.map +1 -1
- package/cjs/src/authToken.d.ts +4 -0
- package/cjs/src/authToken.d.ts.map +1 -0
- package/cjs/src/authToken.js +61 -0
- package/cjs/src/authToken.js.map +1 -0
- package/cjs/src/embed/TsEmbed.d.ts +302 -0
- package/cjs/src/embed/TsEmbed.d.ts.map +1 -0
- package/cjs/src/embed/TsEmbed.js +851 -0
- package/cjs/src/embed/TsEmbed.js.map +1 -0
- package/cjs/src/embed/base.d.ts +0 -9
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +21 -44
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +15 -14
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/embedConfig.d.ts +18 -0
- package/cjs/src/embed/embedConfig.d.ts.map +1 -0
- package/cjs/src/embed/embedConfig.js +25 -0
- package/cjs/src/embed/embedConfig.js.map +1 -0
- package/cjs/src/embed/search.d.ts +0 -4
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +4 -2
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js +3 -2
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +5 -3
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +58 -49
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +2 -1
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +2 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +0 -12
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/tokenizedFetch.d.ts +2 -0
- package/cjs/src/tokenizedFetch.d.ts.map +1 -0
- package/cjs/src/tokenizedFetch.js +20 -0
- package/cjs/src/tokenizedFetch.js.map +1 -0
- package/cjs/src/types.d.ts +6 -0
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/answerService.d.ts +10 -0
- package/cjs/src/utils/answerService.d.ts.map +1 -0
- package/cjs/src/utils/answerService.js +61 -0
- package/cjs/src/utils/answerService.js.map +1 -0
- package/cjs/src/utils/answerService.spec.d.ts +2 -0
- package/cjs/src/utils/answerService.spec.d.ts.map +1 -0
- package/cjs/src/utils/answerService.spec.js +31 -0
- package/cjs/src/utils/answerService.spec.js.map +1 -0
- package/cjs/src/utils/authService/authService.d.ts +45 -0
- package/cjs/src/utils/authService/authService.d.ts.map +1 -0
- package/cjs/src/utils/authService/authService.js +115 -0
- package/cjs/src/utils/authService/authService.js.map +1 -0
- package/cjs/src/utils/authService/authService.spec.d.ts +2 -0
- package/cjs/src/utils/authService/authService.spec.d.ts.map +1 -0
- package/cjs/src/utils/authService/authService.spec.js +82 -0
- package/cjs/src/utils/authService/authService.spec.js.map +1 -0
- package/cjs/src/utils/authService/index.d.ts +3 -0
- package/cjs/src/utils/authService/index.d.ts.map +1 -0
- package/cjs/src/utils/authService/index.js +14 -0
- package/cjs/src/utils/authService/index.js.map +1 -0
- package/cjs/src/utils/authService/tokenisedAuthSerice.d.ts +11 -0
- package/cjs/src/utils/authService/tokenisedAuthSerice.d.ts.map +1 -0
- package/cjs/src/utils/authService/tokenisedAuthSerice.js +44 -0
- package/cjs/src/utils/authService/tokenisedAuthSerice.js.map +1 -0
- package/cjs/src/utils/authService/tokenizedAuthService.d.ts +11 -0
- package/cjs/src/utils/authService/tokenizedAuthService.d.ts.map +1 -0
- package/cjs/src/utils/authService/tokenizedAuthService.js +44 -0
- package/cjs/src/utils/authService/tokenizedAuthService.js.map +1 -0
- package/cjs/src/utils/authService.d.ts +12 -1
- package/cjs/src/utils/authService.d.ts.map +1 -1
- package/cjs/src/utils/authService.js +32 -16
- package/cjs/src/utils/authService.js.map +1 -1
- package/cjs/src/utils/authService.spec.js +3 -4
- package/cjs/src/utils/authService.spec.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.js +2 -1
- package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.spec.js +15 -3
- package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/cjs/src/utils/graphql/graphql-request.spec.d.ts +2 -0
- package/cjs/src/utils/graphql/graphql-request.spec.d.ts.map +1 -0
- package/cjs/src/utils/graphql/graphql-request.spec.js +39 -0
- package/cjs/src/utils/graphql/graphql-request.spec.js.map +1 -0
- package/cjs/src/utils/logger.d.ts +28 -0
- package/cjs/src/utils/logger.d.ts.map +1 -0
- package/cjs/src/utils/logger.js +82 -0
- package/cjs/src/utils/logger.js.map +1 -0
- package/cjs/src/utils/processData.d.ts.map +1 -1
- package/cjs/src/utils/processData.js +5 -4
- package/cjs/src/utils/processData.js.map +1 -1
- package/cjs/src/utils/processData.spec.js +8 -7
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/dist/src/auth.d.ts +0 -12
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/auth.spec.d.ts.map +1 -1
- package/dist/src/authToken.d.ts +4 -0
- package/dist/src/authToken.d.ts.map +1 -0
- package/dist/src/embed/base.d.ts +0 -9
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/embedConfig.d.ts +18 -0
- package/dist/src/embed/embedConfig.d.ts.map +1 -0
- package/dist/src/embed/search.d.ts +0 -4
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/tokenizedFetch.d.ts +2 -0
- package/dist/src/tokenizedFetch.d.ts.map +1 -0
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/answerService.d.ts +10 -0
- package/dist/src/utils/answerService.d.ts.map +1 -0
- package/dist/src/utils/answerService.spec.d.ts +2 -0
- package/dist/src/utils/answerService.spec.d.ts.map +1 -0
- package/dist/src/utils/authService/authService.d.ts +45 -0
- package/dist/src/utils/authService/authService.d.ts.map +1 -0
- package/dist/src/utils/authService/authService.spec.d.ts +2 -0
- package/dist/src/utils/authService/authService.spec.d.ts.map +1 -0
- package/dist/src/utils/authService/index.d.ts +3 -0
- package/dist/src/utils/authService/index.d.ts.map +1 -0
- package/dist/src/utils/authService/tokenisedAuthSerice.d.ts +11 -0
- package/dist/src/utils/authService/tokenisedAuthSerice.d.ts.map +1 -0
- package/dist/src/utils/authService/tokenizedAuthService.d.ts +11 -0
- package/dist/src/utils/authService/tokenizedAuthService.d.ts.map +1 -0
- package/dist/src/utils/authService.d.ts +12 -1
- package/dist/src/utils/authService.d.ts.map +1 -1
- package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/dist/src/utils/graphql/graphql-request.spec.d.ts +2 -0
- package/dist/src/utils/graphql/graphql-request.spec.d.ts.map +1 -0
- package/dist/src/utils/logger.d.ts +28 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/processData.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +202 -141
- package/dist/tsembed-react.js +202 -141
- package/dist/tsembed.es.js +231 -172
- package/dist/tsembed.js +231 -172
- package/dist/visual-embed-sdk-react-full.d.ts +23 -25
- package/dist/visual-embed-sdk-react.d.ts +23 -25
- package/dist/visual-embed-sdk.d.ts +23 -25
- package/lib/package.json +2 -2
- package/lib/src/auth.d.ts +0 -12
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +11 -48
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.d.ts.map +1 -1
- package/lib/src/auth.spec.js +42 -32
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/authToken.d.ts +4 -0
- package/lib/src/authToken.d.ts.map +1 -0
- package/lib/src/authToken.js +56 -0
- package/lib/src/authToken.js.map +1 -0
- package/lib/src/embed/TsEmbed.d.ts +302 -0
- package/lib/src/embed/TsEmbed.d.ts.map +1 -0
- package/lib/src/embed/TsEmbed.js +847 -0
- package/lib/src/embed/TsEmbed.js.map +1 -0
- package/lib/src/embed/base.d.ts +0 -9
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +21 -43
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +15 -14
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embedConfig.d.ts +18 -0
- package/lib/src/embed/embedConfig.d.ts.map +1 -0
- package/lib/src/embed/embedConfig.js +20 -0
- package/lib/src/embed/embedConfig.js.map +1 -0
- package/lib/src/embed/search.d.ts +0 -4
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +5 -3
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.js +3 -2
- package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +4 -2
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +58 -49
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -1
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -1
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/index.spec.js +0 -12
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/tokenizedFetch.d.ts +2 -0
- package/lib/src/tokenizedFetch.d.ts.map +1 -0
- package/lib/src/tokenizedFetch.js +16 -0
- package/lib/src/tokenizedFetch.js.map +1 -0
- package/lib/src/types.d.ts +6 -0
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/answerService.d.ts +10 -0
- package/lib/src/utils/answerService.d.ts.map +1 -0
- package/lib/src/utils/answerService.js +57 -0
- package/lib/src/utils/answerService.js.map +1 -0
- package/lib/src/utils/answerService.spec.d.ts +2 -0
- package/lib/src/utils/answerService.spec.d.ts.map +1 -0
- package/lib/src/utils/answerService.spec.js +29 -0
- package/lib/src/utils/answerService.spec.js.map +1 -0
- package/lib/src/utils/authService/authService.d.ts +45 -0
- package/lib/src/utils/authService/authService.d.ts.map +1 -0
- package/lib/src/utils/authService/authService.js +107 -0
- package/lib/src/utils/authService/authService.js.map +1 -0
- package/lib/src/utils/authService/authService.spec.d.ts +2 -0
- package/lib/src/utils/authService/authService.spec.d.ts.map +1 -0
- package/lib/src/utils/authService/authService.spec.js +80 -0
- package/lib/src/utils/authService/authService.spec.js.map +1 -0
- package/lib/src/utils/authService/index.d.ts +3 -0
- package/lib/src/utils/authService/index.d.ts.map +1 -0
- package/lib/src/utils/authService/index.js +3 -0
- package/lib/src/utils/authService/index.js.map +1 -0
- package/lib/src/utils/authService/tokenisedAuthSerice.d.ts +11 -0
- package/lib/src/utils/authService/tokenisedAuthSerice.d.ts.map +1 -0
- package/lib/src/utils/authService/tokenisedAuthSerice.js +39 -0
- package/lib/src/utils/authService/tokenisedAuthSerice.js.map +1 -0
- package/lib/src/utils/authService/tokenizedAuthService.d.ts +11 -0
- package/lib/src/utils/authService/tokenizedAuthService.d.ts.map +1 -0
- package/lib/src/utils/authService/tokenizedAuthService.js +39 -0
- package/lib/src/utils/authService/tokenizedAuthService.js.map +1 -0
- package/lib/src/utils/authService.d.ts +12 -1
- package/lib/src/utils/authService.d.ts.map +1 -1
- package/lib/src/utils/authService.js +26 -10
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js +1 -2
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.js +2 -1
- package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.spec.js +14 -3
- package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/lib/src/utils/graphql/graphql-request.spec.d.ts +2 -0
- package/lib/src/utils/graphql/graphql-request.spec.d.ts.map +1 -0
- package/lib/src/utils/graphql/graphql-request.spec.js +36 -0
- package/lib/src/utils/graphql/graphql-request.spec.js.map +1 -0
- package/lib/src/utils/logger.d.ts +28 -0
- package/lib/src/utils/logger.d.ts.map +1 -0
- package/lib/src/utils/logger.js +75 -0
- package/lib/src/utils/logger.js.map +1 -0
- package/lib/src/utils/processData.d.ts.map +1 -1
- package/lib/src/utils/processData.js +4 -3
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +8 -7
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +28 -26
- package/package.json +2 -2
- package/src/auth.spec.ts +77 -63
- package/src/auth.ts +12 -55
- package/src/authToken.ts +66 -0
- package/src/embed/base.spec.ts +18 -17
- package/src/embed/base.ts +26 -51
- package/src/embed/embedConfig.ts +23 -0
- package/src/embed/search.ts +10 -15
- package/src/embed/searchEmbed-basic-auth.spec.ts +3 -2
- package/src/embed/ts-embed.spec.ts +87 -75
- package/src/embed/ts-embed.ts +11 -20
- package/src/index.ts +8 -2
- package/src/react/index.spec.tsx +0 -29
- package/src/tokenizedFetch.ts +18 -0
- package/src/types.ts +34 -24
- package/src/utils/{authService.spec.ts → authService/authService.spec.ts} +2 -3
- package/src/utils/{authService.ts → authService/authService.ts} +29 -34
- package/src/utils/authService/index.ts +9 -0
- package/src/utils/authService/tokenizedAuthService.ts +40 -0
- package/src/utils/graphql/answerService/answerService.spec.ts +16 -4
- package/src/utils/graphql/answerService/answerService.ts +2 -1
- package/src/utils/processData.spec.ts +19 -16
- package/src/utils/processData.ts +3 -2
package/src/embed/base.ts
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import EventEmitter from 'eventemitter3';
|
|
12
12
|
import uniq from 'lodash/uniq';
|
|
13
|
+
import { tokenizedFetch } from '../tokenizedFetch';
|
|
14
|
+
import { EndPoints } from '../utils/authService/authService';
|
|
13
15
|
import { getThoughtSpotHost } from '../config';
|
|
14
16
|
import { AuthType, EmbedConfig, PrefetchFeatures } from '../types';
|
|
15
17
|
import {
|
|
@@ -24,12 +26,10 @@ import {
|
|
|
24
26
|
notifyLogout,
|
|
25
27
|
setAuthEE,
|
|
26
28
|
AuthEventEmitter,
|
|
27
|
-
EndPoints,
|
|
28
|
-
getAuthenticationToken,
|
|
29
29
|
} from '../auth';
|
|
30
30
|
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
|
|
31
|
+
import { getEmbedConfig, setEmbedConfig } from './embedConfig';
|
|
31
32
|
|
|
32
|
-
let config = {} as EmbedConfig;
|
|
33
33
|
const CONFIG_DEFAULTS: Partial<EmbedConfig> = {
|
|
34
34
|
loginFailedMessage: 'Not logged in',
|
|
35
35
|
authTriggerText: 'Authorize',
|
|
@@ -53,14 +53,6 @@ export interface exportTMLInput {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export let authPromise: Promise<boolean>;
|
|
56
|
-
/**
|
|
57
|
-
* Gets the configuration embed was initialized with.
|
|
58
|
-
*
|
|
59
|
-
* @returns {@link EmbedConfig} The configuration embed was initialized with.
|
|
60
|
-
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
61
|
-
* @group Global methods
|
|
62
|
-
*/
|
|
63
|
-
export const getEmbedConfig = (): EmbedConfig => config;
|
|
64
56
|
|
|
65
57
|
export const getAuthPromise = (): Promise<boolean> => authPromise;
|
|
66
58
|
|
|
@@ -72,7 +64,7 @@ export {
|
|
|
72
64
|
* Perform authentication on the ThoughtSpot app as applicable.
|
|
73
65
|
*/
|
|
74
66
|
export const handleAuth = (): Promise<boolean> => {
|
|
75
|
-
authPromise = authenticate(
|
|
67
|
+
authPromise = authenticate(getEmbedConfig());
|
|
76
68
|
authPromise.then(
|
|
77
69
|
(isLoggedIn) => {
|
|
78
70
|
if (!isLoggedIn) {
|
|
@@ -111,7 +103,7 @@ export const prefetch = (url?: string, prefetchFeatures?: PrefetchFeatures[]): v
|
|
|
111
103
|
console.warn('The prefetch method does not have a valid URL');
|
|
112
104
|
} else {
|
|
113
105
|
const features = prefetchFeatures || [PrefetchFeatures.FullApp];
|
|
114
|
-
let hostUrl = url ||
|
|
106
|
+
let hostUrl = url || getEmbedConfig().thoughtSpotHost;
|
|
115
107
|
hostUrl = hostUrl[hostUrl.length - 1] === '/' ? hostUrl : `${hostUrl}/`;
|
|
116
108
|
uniq(features.map((feature) => hostUrlToFeatureUrl[feature](hostUrl))).forEach(
|
|
117
109
|
(prefetchUrl, index) => {
|
|
@@ -182,17 +174,18 @@ function backwardCompat(embedConfig: EmbedConfig): EmbedConfig {
|
|
|
182
174
|
*/
|
|
183
175
|
export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
|
|
184
176
|
sanity(embedConfig);
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
177
|
+
setEmbedConfig(
|
|
178
|
+
backwardCompat({
|
|
179
|
+
...CONFIG_DEFAULTS,
|
|
180
|
+
...embedConfig,
|
|
181
|
+
thoughtSpotHost: getThoughtSpotHost(embedConfig),
|
|
182
|
+
}),
|
|
183
|
+
);
|
|
191
184
|
const authEE = new EventEmitter<AuthStatus | AuthEvent>();
|
|
192
185
|
setAuthEE(authEE);
|
|
193
186
|
handleAuth();
|
|
194
187
|
|
|
195
|
-
const { password, ...configToTrack } =
|
|
188
|
+
const { password, ...configToTrack } = getEmbedConfig();
|
|
196
189
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
|
|
197
190
|
...configToTrack,
|
|
198
191
|
usedCustomizationSheet: embedConfig.customizations?.style?.customCSSUrl != null,
|
|
@@ -203,8 +196,8 @@ export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
|
|
|
203
196
|
usedCustomizationIconSprite: !!embedConfig.customizations?.iconSpriteUrl,
|
|
204
197
|
});
|
|
205
198
|
|
|
206
|
-
if (
|
|
207
|
-
prefetch(
|
|
199
|
+
if (getEmbedConfig().callPrefetch) {
|
|
200
|
+
prefetch(getEmbedConfig().thoughtSpotHost);
|
|
208
201
|
}
|
|
209
202
|
return authEE as AuthEventEmitter;
|
|
210
203
|
};
|
|
@@ -213,7 +206,7 @@ export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
|
|
|
213
206
|
*
|
|
214
207
|
*/
|
|
215
208
|
export function disableAutoLogin(): void {
|
|
216
|
-
|
|
209
|
+
getEmbedConfig().autoLogin = false;
|
|
217
210
|
}
|
|
218
211
|
|
|
219
212
|
/**
|
|
@@ -232,7 +225,7 @@ export const logout = (doNotDisableAutoLogin = false): Promise<boolean> => {
|
|
|
232
225
|
if (!doNotDisableAutoLogin) {
|
|
233
226
|
disableAutoLogin();
|
|
234
227
|
}
|
|
235
|
-
return _logout(
|
|
228
|
+
return _logout(getEmbedConfig()).then((isLoggedIn) => {
|
|
236
229
|
notifyLogout();
|
|
237
230
|
return isLoggedIn;
|
|
238
231
|
});
|
|
@@ -247,13 +240,13 @@ let renderQueue: Promise<any> = Promise.resolve();
|
|
|
247
240
|
* @param fn The function being registered
|
|
248
241
|
*/
|
|
249
242
|
export const renderInQueue = (fn: (next?: (val?: any) => void) => Promise<any>): Promise<any> => {
|
|
250
|
-
const { queueMultiRenders = false } =
|
|
243
|
+
const { queueMultiRenders = false } = getEmbedConfig();
|
|
251
244
|
if (queueMultiRenders) {
|
|
252
245
|
renderQueue = renderQueue.then(() => new Promise((res) => fn(res)));
|
|
253
246
|
return renderQueue;
|
|
254
247
|
}
|
|
255
248
|
// Sending an empty function to keep it consistent with the above usage.
|
|
256
|
-
return fn(() => {
|
|
249
|
+
return fn(() => {}); // eslint-disable-line @typescript-eslint/no-empty-function
|
|
257
250
|
};
|
|
258
251
|
|
|
259
252
|
/**
|
|
@@ -280,32 +273,24 @@ export const renderInQueue = (fn: (next?: (val?: any) => void) => Promise<any>):
|
|
|
280
273
|
* @group Global methods
|
|
281
274
|
*/
|
|
282
275
|
export const executeTML = async (data: executeTMLInput): Promise<any> => {
|
|
283
|
-
const { thoughtSpotHost, authType } = config;
|
|
284
276
|
try {
|
|
285
|
-
sanity(
|
|
277
|
+
sanity(getEmbedConfig());
|
|
286
278
|
} catch (err) {
|
|
287
279
|
return Promise.reject(err);
|
|
288
280
|
}
|
|
289
|
-
let authToken = '';
|
|
290
|
-
if (authType === AuthType.TrustedAuthTokenCookieless) {
|
|
291
|
-
authToken = await getAuthenticationToken(config);
|
|
292
|
-
}
|
|
293
281
|
|
|
282
|
+
const { thoughtSpotHost, authType } = getEmbedConfig();
|
|
294
283
|
const headers: Record<string, string | undefined> = {
|
|
295
284
|
'Content-Type': 'application/json',
|
|
296
285
|
'x-requested-by': 'ThoughtSpot',
|
|
297
286
|
};
|
|
298
287
|
|
|
299
|
-
if (authToken) {
|
|
300
|
-
headers.Authorization = `Bearer ${authToken}`;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
288
|
const payload = {
|
|
304
289
|
metadata_tmls: data.metadata_tmls,
|
|
305
290
|
import_policy: data.import_policy || 'PARTIAL',
|
|
306
291
|
create_new: data.create_new || false,
|
|
307
292
|
};
|
|
308
|
-
return
|
|
293
|
+
return tokenizedFetch(`${thoughtSpotHost}${EndPoints.EXECUTE_TML}`, {
|
|
309
294
|
method: 'POST',
|
|
310
295
|
headers,
|
|
311
296
|
body: JSON.stringify(payload),
|
|
@@ -351,14 +336,13 @@ export const executeTML = async (data: executeTMLInput): Promise<any> => {
|
|
|
351
336
|
console.error(error);
|
|
352
337
|
});
|
|
353
338
|
* ```
|
|
354
|
-
*
|
|
355
339
|
* @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
|
|
356
340
|
* @group Global methods
|
|
357
341
|
*/
|
|
358
342
|
export const exportTML = async (data: exportTMLInput): Promise<any> => {
|
|
359
|
-
const { thoughtSpotHost, authType } =
|
|
343
|
+
const { thoughtSpotHost, authType } = getEmbedConfig();
|
|
360
344
|
try {
|
|
361
|
-
sanity(
|
|
345
|
+
sanity(getEmbedConfig());
|
|
362
346
|
} catch (err) {
|
|
363
347
|
return Promise.reject(err);
|
|
364
348
|
}
|
|
@@ -369,21 +353,12 @@ export const exportTML = async (data: exportTMLInput): Promise<any> => {
|
|
|
369
353
|
edoc_format: data.edoc_format || 'YAML',
|
|
370
354
|
};
|
|
371
355
|
|
|
372
|
-
let authToken = '';
|
|
373
|
-
if (authType === AuthType.TrustedAuthTokenCookieless) {
|
|
374
|
-
authToken = await getAuthenticationToken(config);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
356
|
const headers: Record<string, string | undefined> = {
|
|
378
357
|
'Content-Type': 'application/json',
|
|
379
358
|
'x-requested-by': 'ThoughtSpot',
|
|
380
359
|
};
|
|
381
360
|
|
|
382
|
-
|
|
383
|
-
headers.Authorization = `Bearer ${authToken}`;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return fetch(`${thoughtSpotHost}${EndPoints.EXPORT_TML}`, {
|
|
361
|
+
return tokenizedFetch(`${thoughtSpotHost}${EndPoints.EXPORT_TML}`, {
|
|
387
362
|
method: 'POST',
|
|
388
363
|
headers,
|
|
389
364
|
body: JSON.stringify(payload),
|
|
@@ -407,7 +382,7 @@ export const exportTML = async (data: exportTMLInput): Promise<any> => {
|
|
|
407
382
|
*
|
|
408
383
|
*/
|
|
409
384
|
export function reset(): void {
|
|
410
|
-
|
|
385
|
+
setEmbedConfig({} as any);
|
|
411
386
|
setAuthEE(null);
|
|
412
387
|
authPromise = null;
|
|
413
388
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EmbedConfig } from '../types';
|
|
2
|
+
|
|
3
|
+
let config = {} as EmbedConfig;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Gets the configuration embed was initialized with.
|
|
7
|
+
*
|
|
8
|
+
* @returns {@link EmbedConfig} The configuration embed was initialized with.
|
|
9
|
+
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
10
|
+
* @group Global methods
|
|
11
|
+
*/
|
|
12
|
+
export const getEmbedConfig = (): EmbedConfig => config;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Sets the configuration embed was initialized with.
|
|
16
|
+
*
|
|
17
|
+
* @param newConfig The configuration to set.
|
|
18
|
+
* @version SDK: 1.27.0 | ThoughtSpot: *
|
|
19
|
+
* @group Global methods
|
|
20
|
+
*/
|
|
21
|
+
export const setEmbedConfig = (newConfig: EmbedConfig) => {
|
|
22
|
+
config = newConfig;
|
|
23
|
+
};
|
package/src/embed/search.ts
CHANGED
|
@@ -8,12 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
DataSourceVisualMode,
|
|
12
|
-
DOMSelector,
|
|
13
|
-
Param,
|
|
14
|
-
Action,
|
|
15
|
-
ViewConfig,
|
|
16
|
-
RuntimeFilter,
|
|
11
|
+
DataSourceVisualMode, DOMSelector, Param, Action, ViewConfig,
|
|
17
12
|
} from '../types';
|
|
18
13
|
import {
|
|
19
14
|
getQueryParamString,
|
|
@@ -22,10 +17,10 @@ import {
|
|
|
22
17
|
getRuntimeParameters,
|
|
23
18
|
} from '../utils';
|
|
24
19
|
import { TsEmbed } from './ts-embed';
|
|
25
|
-
import { version } from '../../package.json';
|
|
26
20
|
import { ERROR_MESSAGE } from '../errors';
|
|
27
|
-
import { getAuthPromise
|
|
21
|
+
import { getAuthPromise } from './base';
|
|
28
22
|
import { getReleaseVersion } from '../auth';
|
|
23
|
+
import { getEmbedConfig } from './embedConfig';
|
|
29
24
|
|
|
30
25
|
/**
|
|
31
26
|
* Configuration for search options
|
|
@@ -52,7 +47,11 @@ export interface SearchOptions {
|
|
|
52
47
|
export interface SearchViewConfig
|
|
53
48
|
extends Omit<
|
|
54
49
|
ViewConfig,
|
|
55
|
-
|
|
50
|
+
| 'hiddenHomepageModules'
|
|
51
|
+
| 'hiddenHomeLeftNavItems'
|
|
52
|
+
| 'hiddenTabs'
|
|
53
|
+
| 'visibleTabs'
|
|
54
|
+
| 'reorderedHomepageModules'
|
|
56
55
|
> {
|
|
57
56
|
/**
|
|
58
57
|
* If set to true, the data sources panel is collapsed on load,
|
|
@@ -69,10 +68,6 @@ export interface SearchViewConfig
|
|
|
69
68
|
* using raw answer data.
|
|
70
69
|
*/
|
|
71
70
|
hideResults?: boolean;
|
|
72
|
-
/**
|
|
73
|
-
* If set to true, expands all the data sources panel.
|
|
74
|
-
*/
|
|
75
|
-
expandAllDataSource?: boolean;
|
|
76
71
|
/**
|
|
77
72
|
* If set to true, the Search Assist feature is enabled.
|
|
78
73
|
*
|
|
@@ -178,7 +173,6 @@ export class SearchEmbed extends TsEmbed {
|
|
|
178
173
|
protected getEmbedParams(): string {
|
|
179
174
|
const {
|
|
180
175
|
hideResults,
|
|
181
|
-
expandAllDataSource,
|
|
182
176
|
enableSearchAssist,
|
|
183
177
|
forceTable,
|
|
184
178
|
searchOptions,
|
|
@@ -274,7 +268,8 @@ export class SearchEmbed extends TsEmbed {
|
|
|
274
268
|
if (
|
|
275
269
|
checkReleaseVersionInBeta(
|
|
276
270
|
getReleaseVersion(),
|
|
277
|
-
getEmbedConfig().suppressSearchEmbedBetaWarning
|
|
271
|
+
getEmbedConfig().suppressSearchEmbedBetaWarning
|
|
272
|
+
|| getEmbedConfig().suppressErrorAlerts,
|
|
278
273
|
)
|
|
279
274
|
) {
|
|
280
275
|
alert(ERROR_MESSAGE.SEARCHEMBED_BETA_WRANING_MESSAGE);
|
|
@@ -3,6 +3,7 @@ import * as baseInstance from './base';
|
|
|
3
3
|
import * as authService from '../utils/authService';
|
|
4
4
|
import * as authInstance from '../auth';
|
|
5
5
|
import * as config from '../config';
|
|
6
|
+
import * as embedConfigInstance from './embedConfig';
|
|
6
7
|
|
|
7
8
|
import { init } from '../index';
|
|
8
9
|
import { AuthType } from '../types';
|
|
@@ -86,7 +87,7 @@ describe('Search embed tests when authType is Basic', () => {
|
|
|
86
87
|
test('Alert should not appear when suppressSearchEmbedBetaWarning is true and releaseVersion is ts7.dec.cl', async () => {
|
|
87
88
|
setupVersion('ts7.dec.cl');
|
|
88
89
|
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
89
|
-
jest.spyOn(
|
|
90
|
+
jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValue({
|
|
90
91
|
suppressSearchEmbedBetaWarning: true,
|
|
91
92
|
});
|
|
92
93
|
const mockAlert = jest.spyOn(window, 'alert');
|
|
@@ -98,7 +99,7 @@ describe('Search embed tests when authType is Basic', () => {
|
|
|
98
99
|
test('Alert should not appear when suppressSearchEmbedBetaWarning is true and releaseVersion is 8.4.0.sw', async () => {
|
|
99
100
|
setupVersion('8.4.0.sw');
|
|
100
101
|
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
|
|
101
|
-
jest.spyOn(
|
|
102
|
+
jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValue({
|
|
102
103
|
suppressSearchEmbedBetaWarning: true,
|
|
103
104
|
});
|
|
104
105
|
const mockAlert = jest.spyOn(window, 'alert');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable dot-notation */
|
|
2
|
+
import { resetCachedAuthToken } from '../authToken';
|
|
2
3
|
import {
|
|
3
4
|
AuthType,
|
|
4
5
|
init,
|
|
@@ -10,11 +11,7 @@ import {
|
|
|
10
11
|
LiveboardEmbed,
|
|
11
12
|
} from '../index';
|
|
12
13
|
import {
|
|
13
|
-
Action,
|
|
14
|
-
HomeLeftNavItem,
|
|
15
|
-
RuntimeFilter,
|
|
16
|
-
RuntimeFilterOp,
|
|
17
|
-
HomepageModule,
|
|
14
|
+
Action, HomeLeftNavItem, RuntimeFilter, RuntimeFilterOp, HomepageModule,
|
|
18
15
|
} from '../types';
|
|
19
16
|
import {
|
|
20
17
|
executeAfterWait,
|
|
@@ -34,6 +31,7 @@ import * as mixpanelInstance from '../mixpanel-service';
|
|
|
34
31
|
import * as authInstance from '../auth';
|
|
35
32
|
import * as baseInstance from './base';
|
|
36
33
|
import { MIXPANEL_EVENT } from '../mixpanel-service';
|
|
34
|
+
import * as authService from '../utils/authService/authService';
|
|
37
35
|
|
|
38
36
|
const defaultViewConfig = {
|
|
39
37
|
frameParams: {
|
|
@@ -89,8 +87,51 @@ describe('Unit test case for ts embed', () => {
|
|
|
89
87
|
|
|
90
88
|
afterEach(() => {
|
|
91
89
|
jest.clearAllMocks();
|
|
90
|
+
resetCachedAuthToken();
|
|
92
91
|
});
|
|
93
92
|
|
|
93
|
+
describe('AuthExpire embedEvent in cookieless authentication authType', () => {
|
|
94
|
+
beforeAll(() => {
|
|
95
|
+
jest.spyOn(authInstance, 'doCookielessTokenAuth').mockResolvedValueOnce(true);
|
|
96
|
+
jest.spyOn(authService, 'verifyTokenService').mockResolvedValueOnce(true);
|
|
97
|
+
init({
|
|
98
|
+
thoughtSpotHost: 'tshost',
|
|
99
|
+
customizations: customisations,
|
|
100
|
+
customCssUrl: 'http://localhost:5000',
|
|
101
|
+
authType: AuthType.TrustedAuthTokenCookieless,
|
|
102
|
+
getAuthToken: () => Promise.resolve('test_auth_token2'),
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('check for new authToken based on getAuthToken function', async () => {
|
|
107
|
+
const mockEmbedEventPayload = {
|
|
108
|
+
type: EmbedEvent.AuthExpire,
|
|
109
|
+
data: {},
|
|
110
|
+
};
|
|
111
|
+
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
112
|
+
jest.spyOn(baseInstance, 'notifyAuthFailure');
|
|
113
|
+
jest.spyOn(baseInstance, 'handleAuth');
|
|
114
|
+
|
|
115
|
+
searchEmbed.render();
|
|
116
|
+
const mockPort: any = {
|
|
117
|
+
postMessage: jest.fn(),
|
|
118
|
+
};
|
|
119
|
+
await executeAfterWait(() => {
|
|
120
|
+
const iframe = getIFrameEl();
|
|
121
|
+
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
122
|
+
});
|
|
123
|
+
await executeAfterWait(() => {
|
|
124
|
+
expect(baseInstance.notifyAuthFailure).toBeCalledWith(
|
|
125
|
+
authInstance.AuthFailureType.EXPIRY,
|
|
126
|
+
);
|
|
127
|
+
expect(baseInstance.handleAuth).not.toHaveBeenCalled();
|
|
128
|
+
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
129
|
+
type: EmbedEvent.AuthExpire,
|
|
130
|
+
data: { authToken: 'test_auth_token2' },
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
94
135
|
describe('Called Embed event status for start and end', () => {
|
|
95
136
|
beforeAll(() => {
|
|
96
137
|
init({
|
|
@@ -193,8 +234,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
193
234
|
hostConfig: undefined,
|
|
194
235
|
runtimeFilterParams: null,
|
|
195
236
|
hiddenHomeLeftNavItems: [],
|
|
196
|
-
hiddenHomepageModules: [HomepageModule.MyLibrary,
|
|
197
|
-
HomepageModule.Learning],
|
|
237
|
+
hiddenHomepageModules: [HomepageModule.MyLibrary, HomepageModule.Learning],
|
|
198
238
|
reorderedHomepageModules: [],
|
|
199
239
|
},
|
|
200
240
|
});
|
|
@@ -231,8 +271,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
231
271
|
runtimeFilterParams: null,
|
|
232
272
|
hiddenHomeLeftNavItems: [],
|
|
233
273
|
hiddenHomepageModules: [],
|
|
234
|
-
reorderedHomepageModules: [HomepageModule.MyLibrary,
|
|
235
|
-
HomepageModule.Watchlist],
|
|
274
|
+
reorderedHomepageModules: [HomepageModule.MyLibrary, HomepageModule.Watchlist],
|
|
236
275
|
},
|
|
237
276
|
});
|
|
238
277
|
});
|
|
@@ -346,8 +385,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
346
385
|
authToken: '',
|
|
347
386
|
hostConfig: undefined,
|
|
348
387
|
runtimeFilterParams: null,
|
|
349
|
-
hiddenHomeLeftNavItems: [HomeLeftNavItem.Home,
|
|
350
|
-
HomeLeftNavItem.Documentation],
|
|
388
|
+
hiddenHomeLeftNavItems: [HomeLeftNavItem.Home, HomeLeftNavItem.Documentation],
|
|
351
389
|
hiddenHomepageModules: [],
|
|
352
390
|
reorderedHomepageModules: [],
|
|
353
391
|
},
|
|
@@ -483,7 +521,15 @@ describe('Unit test case for ts embed', () => {
|
|
|
483
521
|
});
|
|
484
522
|
});
|
|
485
523
|
|
|
524
|
+
afterEach(() => {
|
|
525
|
+
baseInstance.reset();
|
|
526
|
+
});
|
|
527
|
+
|
|
486
528
|
test('check for authToken based on getAuthToken function', async () => {
|
|
529
|
+
const a = jest.spyOn(authService, 'verifyTokenService');
|
|
530
|
+
a.mockResolvedValue(true);
|
|
531
|
+
|
|
532
|
+
// authVerifyMock.mockResolvedValue(true);
|
|
487
533
|
const mockEmbedEventPayload = {
|
|
488
534
|
type: EmbedEvent.APP_INIT,
|
|
489
535
|
data: {},
|
|
@@ -511,47 +557,8 @@ describe('Unit test case for ts embed', () => {
|
|
|
511
557
|
},
|
|
512
558
|
});
|
|
513
559
|
});
|
|
514
|
-
});
|
|
515
|
-
});
|
|
516
560
|
|
|
517
|
-
|
|
518
|
-
beforeAll(() => {
|
|
519
|
-
jest.spyOn(authInstance, 'doCookielessTokenAuth').mockResolvedValueOnce(true);
|
|
520
|
-
init({
|
|
521
|
-
thoughtSpotHost: 'tshost',
|
|
522
|
-
customizations: customisations,
|
|
523
|
-
customCssUrl: 'http://localhost:5000',
|
|
524
|
-
authType: AuthType.TrustedAuthTokenCookieless,
|
|
525
|
-
getAuthToken: () => Promise.resolve('test_auth_token2'),
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
test('check for new authToken based on getAuthToken function', async () => {
|
|
530
|
-
const mockEmbedEventPayload = {
|
|
531
|
-
type: EmbedEvent.AuthExpire,
|
|
532
|
-
data: {},
|
|
533
|
-
};
|
|
534
|
-
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
535
|
-
jest.spyOn(baseInstance, 'notifyAuthFailure');
|
|
536
|
-
jest.spyOn(baseInstance, 'handleAuth');
|
|
537
|
-
searchEmbed.render();
|
|
538
|
-
const mockPort: any = {
|
|
539
|
-
postMessage: jest.fn(),
|
|
540
|
-
};
|
|
541
|
-
await executeAfterWait(() => {
|
|
542
|
-
const iframe = getIFrameEl();
|
|
543
|
-
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
544
|
-
});
|
|
545
|
-
await executeAfterWait(() => {
|
|
546
|
-
expect(baseInstance.notifyAuthFailure).toBeCalledWith(
|
|
547
|
-
authInstance.AuthFailureType.EXPIRY,
|
|
548
|
-
);
|
|
549
|
-
expect(baseInstance.handleAuth).not.toHaveBeenCalled();
|
|
550
|
-
expect(mockPort.postMessage).toHaveBeenCalledWith({
|
|
551
|
-
type: EmbedEvent.AuthExpire,
|
|
552
|
-
data: { authToken: 'test_auth_token2' },
|
|
553
|
-
});
|
|
554
|
-
});
|
|
561
|
+
jest.spyOn(authService, 'verifyTokenService').mockClear();
|
|
555
562
|
});
|
|
556
563
|
});
|
|
557
564
|
|
|
@@ -1036,7 +1043,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1036
1043
|
expectUrlMatchesWithParams(
|
|
1037
1044
|
getIFrameSrc(),
|
|
1038
1045
|
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
|
|
1039
|
-
|
|
1046
|
+
+ `&foo=bar&baz=1&bool=true${defaultParamsPost}#/home`,
|
|
1040
1047
|
);
|
|
1041
1048
|
});
|
|
1042
1049
|
|
|
@@ -1052,7 +1059,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1052
1059
|
expectUrlMatchesWithParams(
|
|
1053
1060
|
getIFrameSrc(),
|
|
1054
1061
|
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
|
|
1055
|
-
|
|
1062
|
+
+ `&showAlerts=true${defaultParamsPost}#/home`,
|
|
1056
1063
|
);
|
|
1057
1064
|
});
|
|
1058
1065
|
it('Sets the locale param', async () => {
|
|
@@ -1067,7 +1074,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1067
1074
|
expectUrlMatchesWithParams(
|
|
1068
1075
|
getIFrameSrc(),
|
|
1069
1076
|
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
|
|
1070
|
-
|
|
1077
|
+
+ `&locale=ja-JP${defaultParamsPost}#/home`,
|
|
1071
1078
|
);
|
|
1072
1079
|
});
|
|
1073
1080
|
it('Sets the iconSprite url', async () => {
|
|
@@ -1084,7 +1091,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1084
1091
|
expectUrlMatchesWithParams(
|
|
1085
1092
|
getIFrameSrc(),
|
|
1086
1093
|
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}`
|
|
1087
|
-
|
|
1094
|
+
+ `&iconSprite=iconSprite.com${defaultParamsPost}#/home`,
|
|
1088
1095
|
);
|
|
1089
1096
|
});
|
|
1090
1097
|
|
|
@@ -1302,8 +1309,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1302
1309
|
expect(preRenderWrapper.style.pointerEvents).toBe('none');
|
|
1303
1310
|
expect(preRenderWrapper.style.zIndex).toBe('-1000');
|
|
1304
1311
|
|
|
1305
|
-
const preRenderChild = (
|
|
1306
|
-
.getElementById(preRenderIds.child) as HTMLIFrameElement);
|
|
1312
|
+
const preRenderChild = document.getElementById(preRenderIds.child) as HTMLIFrameElement;
|
|
1307
1313
|
expect(preRenderWrapper.children[0]).toEqual(preRenderChild);
|
|
1308
1314
|
expect(preRenderChild).toBeInstanceOf(HTMLIFrameElement);
|
|
1309
1315
|
expect(preRenderChild.src).toMatch(/^http:\/\/tshost.*\/myLiveboardId/);
|
|
@@ -1314,24 +1320,26 @@ describe('Unit test case for ts embed', () => {
|
|
|
1314
1320
|
|
|
1315
1321
|
let resizeObserverCb: any;
|
|
1316
1322
|
(window as any).ResizeObserver = window.ResizeObserver
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
+
|| jest.fn().mockImplementation((resizeObserverCbParam) => {
|
|
1324
|
+
resizeObserverCb = resizeObserverCbParam;
|
|
1325
|
+
return {
|
|
1326
|
+
disconnect: jest.fn(),
|
|
1327
|
+
observe: jest.fn(),
|
|
1328
|
+
unobserve: jest.fn(),
|
|
1329
|
+
};
|
|
1323
1330
|
});
|
|
1324
|
-
});
|
|
1325
1331
|
|
|
1326
1332
|
// show preRender
|
|
1327
1333
|
const warnSpy = spyOn(console, 'warn');
|
|
1328
1334
|
libEmbed.showPreRender();
|
|
1329
1335
|
expect(warnSpy).toHaveBeenCalledTimes(0);
|
|
1330
1336
|
|
|
1331
|
-
resizeObserverCb([
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1337
|
+
resizeObserverCb([
|
|
1338
|
+
{
|
|
1339
|
+
target: tsEmbedDiv,
|
|
1340
|
+
contentRect: { height: 297, width: 987 },
|
|
1341
|
+
},
|
|
1342
|
+
]);
|
|
1335
1343
|
|
|
1336
1344
|
expect(preRenderWrapper.style.height).toEqual(`${297}px`);
|
|
1337
1345
|
expect(preRenderWrapper.style.width).toEqual(`${987}px`);
|
|
@@ -1394,11 +1402,11 @@ describe('Unit test case for ts embed', () => {
|
|
|
1394
1402
|
createRootEleForEmbed();
|
|
1395
1403
|
mockMessageChannel();
|
|
1396
1404
|
(window as any).ResizeObserver = window.ResizeObserver
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1405
|
+
|| jest.fn().mockImplementation(() => ({
|
|
1406
|
+
disconnect: jest.fn(),
|
|
1407
|
+
observe: jest.fn(),
|
|
1408
|
+
unobserve: jest.fn(),
|
|
1409
|
+
}));
|
|
1402
1410
|
const libEmbed = new LiveboardEmbed('#tsEmbedDiv', {
|
|
1403
1411
|
preRenderId: 'i-am-preRendered',
|
|
1404
1412
|
liveboardId: 'myLiveboardId',
|
|
@@ -1451,7 +1459,9 @@ describe('Unit test case for ts embed', () => {
|
|
|
1451
1459
|
});
|
|
1452
1460
|
await libEmbed.preRender();
|
|
1453
1461
|
|
|
1454
|
-
expect(document.getElementById('tsEmbed-pre-render-child-test').innerHTML).toBe(
|
|
1462
|
+
expect(document.getElementById('tsEmbed-pre-render-child-test').innerHTML).toBe(
|
|
1463
|
+
'Not logged in',
|
|
1464
|
+
);
|
|
1455
1465
|
});
|
|
1456
1466
|
it('should log error if sync is called before preRender', async () => {
|
|
1457
1467
|
jest.spyOn(console, 'error').mockImplementation(jest.fn());
|
|
@@ -1460,7 +1470,9 @@ describe('Unit test case for ts embed', () => {
|
|
|
1460
1470
|
preRenderId: 'test',
|
|
1461
1471
|
});
|
|
1462
1472
|
await libEmbed.syncPreRenderStyle();
|
|
1463
|
-
expect(console.error).toBeCalledWith(
|
|
1473
|
+
expect(console.error).toBeCalledWith(
|
|
1474
|
+
'PreRender should be called before using syncPreRenderStyle',
|
|
1475
|
+
);
|
|
1464
1476
|
(console.error as any).mockClear();
|
|
1465
1477
|
});
|
|
1466
1478
|
});
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import isEqual from 'lodash/isEqual';
|
|
11
11
|
|
|
12
|
+
import { getAuthenticationToken } from '../authToken';
|
|
12
13
|
import { AnswerService } from '../utils/graphql/answerService/answerService';
|
|
13
14
|
import {
|
|
14
15
|
getEncodedQueryParamsString,
|
|
@@ -55,13 +56,10 @@ import { processEventData } from '../utils/processData';
|
|
|
55
56
|
import { processTrigger } from '../utils/processTrigger';
|
|
56
57
|
import pkgInfo from '../../package.json';
|
|
57
58
|
import {
|
|
58
|
-
getAuthPromise,
|
|
59
|
-
getEmbedConfig,
|
|
60
|
-
renderInQueue,
|
|
61
|
-
handleAuth,
|
|
62
|
-
notifyAuthFailure,
|
|
59
|
+
getAuthPromise, renderInQueue, handleAuth, notifyAuthFailure,
|
|
63
60
|
} from './base';
|
|
64
|
-
import { AuthFailureType
|
|
61
|
+
import { AuthFailureType } from '../auth';
|
|
62
|
+
import { getEmbedConfig } from './embedConfig';
|
|
65
63
|
|
|
66
64
|
const { version } = pkgInfo;
|
|
67
65
|
|
|
@@ -1073,11 +1071,11 @@ export class TsEmbed {
|
|
|
1073
1071
|
) {
|
|
1074
1072
|
console.warn(
|
|
1075
1073
|
`${this.embedComponentType} was pre-rendered with `
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1074
|
+
+ `"${key}" as "${JSON.stringify(preRenderedObject.viewConfig[key])}" `
|
|
1075
|
+
+ `but a different value "${JSON.stringify(viewConfig[key])}" `
|
|
1076
|
+
+ 'was passed to the Embed component. '
|
|
1077
|
+
+ 'The new value provided is ignored, the value provided during '
|
|
1078
|
+
+ 'preRender is used.',
|
|
1081
1079
|
);
|
|
1082
1080
|
}
|
|
1083
1081
|
});
|
|
@@ -1204,15 +1202,8 @@ export class TsEmbed {
|
|
|
1204
1202
|
* @version SDK: 1.25.0 / ThoughtSpot 9.10.0
|
|
1205
1203
|
*/
|
|
1206
1204
|
public async getAnswerService(vizId?: string): Promise<AnswerService> {
|
|
1207
|
-
const { session, embedAnswerData } = await this.trigger(
|
|
1208
|
-
|
|
1209
|
-
vizId,
|
|
1210
|
-
);
|
|
1211
|
-
return new AnswerService(
|
|
1212
|
-
session,
|
|
1213
|
-
embedAnswerData,
|
|
1214
|
-
this.embedConfig.thoughtSpotHost,
|
|
1215
|
-
);
|
|
1205
|
+
const { session, embedAnswerData } = await this.trigger(HostEvent.GetAnswerSession, vizId);
|
|
1206
|
+
return new AnswerService(session, embedAnswerData, this.embedConfig.thoughtSpotHost);
|
|
1216
1207
|
}
|
|
1217
1208
|
}
|
|
1218
1209
|
|