@thoughtspot/visual-embed-sdk 1.26.1 → 1.26.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/package.json +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/app.d.ts +0 -1
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +1 -1
- package/cjs/src/embed/app.js.map +1 -1
- 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/liveboard.d.ts +0 -1
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +1 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/sage.d.ts +0 -1
- package/cjs/src/embed/sage.d.ts.map +1 -1
- package/cjs/src/embed/sage.js +1 -1
- package/cjs/src/embed/sage.js.map +1 -1
- package/cjs/src/embed/search.d.ts +0 -1
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +5 -4
- 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 +0 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +6 -6
- 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/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 +12 -0
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/{authService.d.ts → authService/authService.d.ts} +12 -11
- package/cjs/src/utils/authService/authService.d.ts.map +1 -0
- package/cjs/src/utils/{authService.js → authService/authService.js} +31 -39
- package/cjs/src/utils/authService/authService.js.map +1 -0
- package/cjs/src/utils/authService/authService.spec.d.ts.map +1 -0
- package/cjs/src/utils/{authService.spec.js → authService/authService.spec.js} +11 -12
- 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/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/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/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/app.d.ts +0 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- 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/liveboard.d.ts +0 -1
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/sage.d.ts +0 -1
- package/dist/src/embed/sage.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +0 -1
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +0 -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 +12 -0
- package/dist/src/types.d.ts.map +1 -1
- package/{lib/src/utils → dist/src/utils/authService}/authService.d.ts +44 -43
- package/dist/src/utils/authService/authService.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/tokenizedAuthService.d.ts +11 -0
- package/dist/src/utils/authService/tokenizedAuthService.d.ts.map +1 -0
- 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 +207 -149
- package/dist/tsembed-react.js +207 -149
- package/dist/tsembed.es.js +236 -180
- package/dist/tsembed.js +236 -180
- package/dist/visual-embed-sdk-react-full.d.ts +29 -26
- package/dist/visual-embed-sdk-react.d.ts +29 -26
- package/dist/visual-embed-sdk.d.ts +29 -26
- 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/app.d.ts +0 -1
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +1 -1
- package/lib/src/embed/app.js.map +1 -1
- 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/liveboard.d.ts +0 -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/sage.d.ts +0 -1
- package/lib/src/embed/sage.d.ts.map +1 -1
- package/lib/src/embed/sage.js +1 -1
- package/lib/src/embed/sage.js.map +1 -1
- package/lib/src/embed/search.d.ts +0 -1
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +6 -5
- 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 +0 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +5 -5
- 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/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 +12 -0
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js.map +1 -1
- package/{dist/src/utils → lib/src/utils/authService}/authService.d.ts +44 -43
- package/lib/src/utils/authService/authService.d.ts.map +1 -0
- package/lib/src/utils/{authService.js → authService/authService.js} +26 -32
- package/lib/src/utils/authService/authService.js.map +1 -0
- package/lib/src/utils/authService/authService.spec.d.ts.map +1 -0
- package/lib/src/utils/{authService.spec.js → authService/authService.spec.js} +1 -2
- 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/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/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/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 +34 -27
- 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/app.ts +1 -2
- 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/liveboard.ts +1 -2
- package/src/embed/sage.ts +1 -2
- package/src/embed/search.ts +12 -14
- 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 +7 -19
- package/src/index.ts +8 -2
- package/src/tokenizedFetch.ts +18 -0
- package/src/types.ts +36 -19
- 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/cjs/src/utils/authService.d.ts.map +0 -1
- package/cjs/src/utils/authService.js.map +0 -1
- package/cjs/src/utils/authService.spec.d.ts.map +0 -1
- package/cjs/src/utils/authService.spec.js.map +0 -1
- package/dist/src/utils/authService.d.ts.map +0 -1
- package/lib/src/utils/authService.d.ts.map +0 -1
- package/lib/src/utils/authService.js.map +0 -1
- package/lib/src/utils/authService.spec.d.ts.map +0 -1
- package/lib/src/utils/authService.spec.js.map +0 -1
- /package/cjs/src/utils/{authService.spec.d.ts → authService/authService.spec.d.ts} +0 -0
- /package/dist/src/utils/{authService.spec.d.ts → authService/authService.spec.d.ts} +0 -0
- /package/dist/src/utils/{authService.spec.d.ts.map → authService/authService.spec.d.ts.map} +0 -0
- /package/lib/src/utils/{authService.spec.d.ts → authService/authService.spec.d.ts} +0 -0
package/src/embed/base.spec.ts
CHANGED
|
@@ -3,16 +3,20 @@
|
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
4
|
import { EmbedConfig } from '../index';
|
|
5
5
|
import * as auth from '../auth';
|
|
6
|
+
import * as authService from '../utils/authService/authService';
|
|
7
|
+
import * as authTokenService from '../authToken';
|
|
6
8
|
import * as index from '../index';
|
|
7
9
|
import * as base from './base';
|
|
10
|
+
import * as embedConfigInstance from './embedConfig';
|
|
11
|
+
|
|
8
12
|
import {
|
|
9
13
|
executeAfterWait,
|
|
10
14
|
getAllIframeEl,
|
|
11
15
|
getDocumentBody,
|
|
12
16
|
getRootEl,
|
|
13
|
-
getRootEl2,
|
|
14
17
|
getIFrameSrc,
|
|
15
18
|
} from '../test/test-utils';
|
|
19
|
+
import * as tokenizedFetchInstance from '../tokenizedFetch';
|
|
16
20
|
|
|
17
21
|
const thoughtSpotHost = 'tshost';
|
|
18
22
|
let authEE: EventEmitter;
|
|
@@ -107,7 +111,7 @@ describe('Base TS Embed', () => {
|
|
|
107
111
|
};
|
|
108
112
|
await index.executeTML(data);
|
|
109
113
|
expect(window.fetch).toHaveBeenCalledWith(
|
|
110
|
-
`http://${thoughtSpotHost}${
|
|
114
|
+
`http://${thoughtSpotHost}${authService.EndPoints.EXECUTE_TML}`,
|
|
111
115
|
{
|
|
112
116
|
credentials: 'include',
|
|
113
117
|
headers: {
|
|
@@ -121,32 +125,29 @@ describe('Base TS Embed', () => {
|
|
|
121
125
|
});
|
|
122
126
|
|
|
123
127
|
test('should call the executeTML API and import TML for cookiless auth', async () => {
|
|
124
|
-
jest.spyOn(
|
|
128
|
+
jest.spyOn(authTokenService, 'getAuthenticationToken').mockResolvedValue('mockAuthToken');
|
|
129
|
+
jest.spyOn(tokenizedFetchInstance, 'tokenizedFetch').mockResolvedValueOnce({
|
|
125
130
|
ok: true,
|
|
126
131
|
json: jest.fn().mockResolvedValue({}),
|
|
127
|
-
text: jest.fn().mockResolvedValue('mockAuthToken'),
|
|
128
132
|
});
|
|
129
133
|
index.init({
|
|
130
134
|
thoughtSpotHost,
|
|
131
135
|
authType: index.AuthType.TrustedAuthTokenCookieless,
|
|
132
136
|
autoLogin: true,
|
|
133
137
|
});
|
|
134
|
-
const embedConfig = base.getEmbedConfig();
|
|
135
|
-
const authToken = await auth.getAuthenticationToken(embedConfig);
|
|
136
138
|
const data: base.executeTMLInput = {
|
|
137
139
|
metadata_tmls: ['{"liveboard":{"name":"Parameters Liveboard"}}'],
|
|
138
140
|
import_policy: 'PARTIAL',
|
|
139
141
|
create_new: false,
|
|
140
142
|
};
|
|
141
143
|
await index.executeTML(data);
|
|
142
|
-
expect(
|
|
143
|
-
`http://${thoughtSpotHost}${
|
|
144
|
+
expect(tokenizedFetchInstance.tokenizedFetch).toHaveBeenCalledWith(
|
|
145
|
+
`http://${thoughtSpotHost}${authService.EndPoints.EXECUTE_TML}`,
|
|
144
146
|
{
|
|
145
147
|
credentials: 'include',
|
|
146
148
|
headers: expect.objectContaining({
|
|
147
149
|
'Content-Type': 'application/json',
|
|
148
150
|
'x-requested-by': 'ThoughtSpot',
|
|
149
|
-
Authorization: `Bearer ${authToken}`,
|
|
150
151
|
}),
|
|
151
152
|
body: JSON.stringify(data),
|
|
152
153
|
method: 'POST',
|
|
@@ -193,7 +194,7 @@ describe('Base TS Embed', () => {
|
|
|
193
194
|
});
|
|
194
195
|
|
|
195
196
|
test('should call the exportTML API and export TML', async () => {
|
|
196
|
-
jest.spyOn(
|
|
197
|
+
jest.spyOn(tokenizedFetchInstance, 'tokenizedFetch').mockResolvedValueOnce({
|
|
197
198
|
ok: true,
|
|
198
199
|
json: jest.fn().mockResolvedValue({}),
|
|
199
200
|
});
|
|
@@ -209,8 +210,8 @@ describe('Base TS Embed', () => {
|
|
|
209
210
|
edoc_format: 'YAML',
|
|
210
211
|
};
|
|
211
212
|
await index.exportTML(data);
|
|
212
|
-
expect(
|
|
213
|
-
`http://${thoughtSpotHost}${
|
|
213
|
+
expect(tokenizedFetchInstance.tokenizedFetch).toHaveBeenCalledWith(
|
|
214
|
+
`http://${thoughtSpotHost}${authService.EndPoints.EXPORT_TML}`,
|
|
214
215
|
{
|
|
215
216
|
credentials: 'include',
|
|
216
217
|
headers: {
|
|
@@ -341,7 +342,7 @@ describe('Base TS Embed', () => {
|
|
|
341
342
|
});
|
|
342
343
|
|
|
343
344
|
test('Logout method should disable autoLogin', () => {
|
|
344
|
-
jest.spyOn(window, 'fetch').
|
|
345
|
+
jest.spyOn(window, 'fetch').mockResolvedValueOnce({
|
|
345
346
|
type: 'opaque',
|
|
346
347
|
});
|
|
347
348
|
index.init({
|
|
@@ -351,7 +352,7 @@ describe('Base TS Embed', () => {
|
|
|
351
352
|
});
|
|
352
353
|
index.logout();
|
|
353
354
|
expect(window.fetch).toHaveBeenCalledWith(
|
|
354
|
-
`http://${thoughtSpotHost}${
|
|
355
|
+
`http://${thoughtSpotHost}${authService.EndPoints.LOGOUT}`,
|
|
355
356
|
{
|
|
356
357
|
credentials: 'include',
|
|
357
358
|
headers: {
|
|
@@ -360,7 +361,7 @@ describe('Base TS Embed', () => {
|
|
|
360
361
|
method: 'POST',
|
|
361
362
|
},
|
|
362
363
|
);
|
|
363
|
-
expect(
|
|
364
|
+
expect(embedConfigInstance.getEmbedConfig().autoLogin).toBe(false);
|
|
364
365
|
});
|
|
365
366
|
|
|
366
367
|
test('config sanity, no ts host', () => {
|
|
@@ -395,7 +396,7 @@ describe('Base TS Embed', () => {
|
|
|
395
396
|
thoughtSpotHost,
|
|
396
397
|
noRedirect: true,
|
|
397
398
|
});
|
|
398
|
-
expect(
|
|
399
|
+
expect(embedConfigInstance.getEmbedConfig().inPopup).toBe(true);
|
|
399
400
|
});
|
|
400
401
|
test('config backward compat, should not override inPopup with noRedirect', () => {
|
|
401
402
|
index.init({
|
|
@@ -404,7 +405,7 @@ describe('Base TS Embed', () => {
|
|
|
404
405
|
noRedirect: true,
|
|
405
406
|
inPopup: false,
|
|
406
407
|
});
|
|
407
|
-
expect(
|
|
408
|
+
expect(embedConfigInstance.getEmbedConfig().inPopup).toBe(false);
|
|
408
409
|
});
|
|
409
410
|
});
|
|
410
411
|
|
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/liveboard.ts
CHANGED
|
@@ -161,10 +161,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
161
161
|
|
|
162
162
|
private defaultHeight = 500;
|
|
163
163
|
|
|
164
|
-
protected embedComponentType = 'LiveboardEmbed';
|
|
165
|
-
|
|
166
164
|
// eslint-disable-next-line no-useless-constructor
|
|
167
165
|
constructor(domSelector: DOMSelector, viewConfig: LiveboardViewConfig) {
|
|
166
|
+
viewConfig.embedComponentType = 'LiveboardEmbed';
|
|
168
167
|
super(domSelector, viewConfig);
|
|
169
168
|
if (this.viewConfig.fullHeight === true) {
|
|
170
169
|
this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
|
package/src/embed/sage.ts
CHANGED
|
@@ -141,10 +141,9 @@ export class SageEmbed extends V1Embed {
|
|
|
141
141
|
*/
|
|
142
142
|
protected viewConfig: SageViewConfig;
|
|
143
143
|
|
|
144
|
-
protected embedComponentType = 'SageEmbed';
|
|
145
|
-
|
|
146
144
|
// eslint-disable-next-line no-useless-constructor
|
|
147
145
|
constructor(domSelector: DOMSelector, viewConfig: SageViewConfig) {
|
|
146
|
+
viewConfig.embedComponentType = 'SageEmbed';
|
|
148
147
|
super(domSelector, viewConfig);
|
|
149
148
|
}
|
|
150
149
|
|
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,
|
|
@@ -152,11 +151,9 @@ export class SearchEmbed extends TsEmbed {
|
|
|
152
151
|
*/
|
|
153
152
|
protected viewConfig: SearchViewConfig;
|
|
154
153
|
|
|
155
|
-
protected embedComponentType = 'SearchEmbed';
|
|
156
|
-
|
|
157
154
|
constructor(domSelector: DOMSelector, viewConfig: SearchViewConfig) {
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
viewConfig.embedComponentType = 'SearchEmbed';
|
|
156
|
+
super(domSelector, viewConfig);
|
|
160
157
|
}
|
|
161
158
|
|
|
162
159
|
/**
|
|
@@ -274,7 +271,8 @@ export class SearchEmbed extends TsEmbed {
|
|
|
274
271
|
if (
|
|
275
272
|
checkReleaseVersionInBeta(
|
|
276
273
|
getReleaseVersion(),
|
|
277
|
-
getEmbedConfig().suppressSearchEmbedBetaWarning
|
|
274
|
+
getEmbedConfig().suppressSearchEmbedBetaWarning
|
|
275
|
+
|| getEmbedConfig().suppressErrorAlerts,
|
|
278
276
|
)
|
|
279
277
|
) {
|
|
280
278
|
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');
|