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