@thoughtspot/visual-embed-sdk 1.13.0-alpha.4 → 1.14.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/CHANGELOG.md +9 -5
- package/dist/src/embed/app.d.ts +4 -3
- package/dist/src/embed/base.d.ts +1 -1
- package/dist/src/embed/liveboard.d.ts +10 -7
- package/dist/src/embed/pinboard.d.ts +91 -0
- package/dist/src/embed/search.d.ts +5 -1
- package/dist/src/embed/ts-embed.d.ts +4 -4
- package/dist/src/types.d.ts +84 -77
- package/dist/src/utils/authService.d.ts +1 -0
- package/dist/src/utils/plugin.d.ts +0 -0
- package/dist/src/v1/api.d.ts +19 -0
- package/dist/tsembed.es.js +106 -78
- package/dist/tsembed.js +106 -78
- package/lib/package.json +1 -1
- package/lib/src/auth.js +8 -2
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +18 -0
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/app.d.ts +4 -3
- package/lib/src/embed/app.js +2 -1
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -1
- package/lib/src/embed/base.js +1 -1
- package/lib/src/embed/liveboard.d.ts +10 -7
- package/lib/src/embed/liveboard.js +7 -4
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +12 -0
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.d.ts +91 -0
- package/lib/src/embed/pinboard.js +110 -0
- package/lib/src/embed/pinboard.js.map +1 -0
- package/lib/src/embed/search.d.ts +5 -1
- package/lib/src/embed/search.js +1 -1
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +4 -4
- package/lib/src/types.d.ts +84 -77
- package/lib/src/types.js +74 -69
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService.d.ts +1 -0
- package/lib/src/utils/authService.js +13 -0
- package/lib/src/utils/authService.js.map +1 -1
- package/lib/src/utils/authService.spec.js +15 -1
- package/lib/src/utils/authService.spec.js.map +1 -1
- package/lib/src/utils/plugin.d.ts +0 -0
- package/lib/src/utils/plugin.js +1 -0
- package/lib/src/utils/plugin.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +108 -93
- package/package.json +1 -1
- package/src/auth.spec.ts +39 -0
- package/src/auth.ts +11 -5
- package/src/embed/app.ts +4 -3
- package/src/embed/base.ts +1 -1
- package/src/embed/liveboard.spec.ts +15 -0
- package/src/embed/liveboard.ts +22 -9
- package/src/embed/search.ts +6 -1
- package/src/embed/ts-embed.ts +4 -4
- package/src/types.ts +85 -77
- package/src/utils/authService.spec.ts +21 -0
- package/src/utils/authService.ts +20 -0
package/src/auth.spec.ts
CHANGED
|
@@ -240,6 +240,45 @@ describe('Unit test for auth', () => {
|
|
|
240
240
|
expect(isLoggedIn).toBe(false);
|
|
241
241
|
});
|
|
242
242
|
|
|
243
|
+
test('doTokenAuth: when user is not loggedIn & fetchAuthPostService failed than fetchAuthService should call', async () => {
|
|
244
|
+
jest.spyOn(window, 'alert').mockImplementation(() => undefined);
|
|
245
|
+
jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(
|
|
246
|
+
() => false,
|
|
247
|
+
);
|
|
248
|
+
jest.spyOn(
|
|
249
|
+
authService,
|
|
250
|
+
'fetchAuthTokenService',
|
|
251
|
+
).mockImplementation(() => ({ text: () => Promise.resolve('abc') }));
|
|
252
|
+
jest.spyOn(authService, 'fetchAuthPostService').mockImplementation(() =>
|
|
253
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
254
|
+
Promise.reject({
|
|
255
|
+
status: 500,
|
|
256
|
+
}),
|
|
257
|
+
);
|
|
258
|
+
jest.spyOn(authService, 'fetchAuthService').mockImplementation(() =>
|
|
259
|
+
Promise.resolve({
|
|
260
|
+
status: 200,
|
|
261
|
+
type: 'opaqueredirect',
|
|
262
|
+
}),
|
|
263
|
+
);
|
|
264
|
+
expect(
|
|
265
|
+
await authInstance.doTokenAuth(
|
|
266
|
+
embedConfig.doTokenAuthSuccess('authToken2'),
|
|
267
|
+
),
|
|
268
|
+
).toBe(true);
|
|
269
|
+
expect(authService.fetchSessionInfoService).toBeCalled();
|
|
270
|
+
expect(authService.fetchAuthPostService).toBeCalledWith(
|
|
271
|
+
thoughtSpotHost,
|
|
272
|
+
username,
|
|
273
|
+
'authToken2',
|
|
274
|
+
);
|
|
275
|
+
expect(authService.fetchAuthService).toBeCalledWith(
|
|
276
|
+
thoughtSpotHost,
|
|
277
|
+
username,
|
|
278
|
+
'authToken2',
|
|
279
|
+
);
|
|
280
|
+
});
|
|
281
|
+
|
|
243
282
|
describe('doBasicAuth', () => {
|
|
244
283
|
beforeEach(() => {
|
|
245
284
|
global.fetch = window.fetch;
|
package/src/auth.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
fetchAuthService,
|
|
9
9
|
fetchBasicAuthService,
|
|
10
10
|
fetchLogoutService,
|
|
11
|
+
fetchAuthPostService,
|
|
11
12
|
} from './utils/authService';
|
|
12
13
|
|
|
13
14
|
// eslint-disable-next-line import/no-mutable-exports
|
|
@@ -157,11 +158,16 @@ export const doTokenAuth = async (
|
|
|
157
158
|
const response = await fetchAuthTokenService(authEndpoint);
|
|
158
159
|
authToken = await response.text();
|
|
159
160
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
let resp;
|
|
162
|
+
try {
|
|
163
|
+
resp = await fetchAuthPostService(
|
|
164
|
+
thoughtSpotHost,
|
|
165
|
+
username,
|
|
166
|
+
authToken,
|
|
167
|
+
);
|
|
168
|
+
} catch (e) {
|
|
169
|
+
resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
170
|
+
}
|
|
165
171
|
// token login issues a 302 when successful
|
|
166
172
|
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
167
173
|
if (loggedInStatus && embedConfig.detectCookieAccessSlow) {
|
package/src/embed/app.ts
CHANGED
|
@@ -87,13 +87,13 @@ export interface AppViewConfig extends ViewConfig {
|
|
|
87
87
|
* Render liveboards using the new v2 rendering mode
|
|
88
88
|
* This is a transient flag which is primarily meant for internal use
|
|
89
89
|
* @default false
|
|
90
|
-
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
|
|
90
|
+
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
|
|
91
91
|
* @hidden
|
|
92
92
|
*/
|
|
93
93
|
liveboardV2?: boolean;
|
|
94
94
|
/**
|
|
95
95
|
* If set to true, the Search Assist feature is enabled.
|
|
96
|
-
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl
|
|
96
|
+
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
|
|
97
97
|
*/
|
|
98
98
|
enableSearchAssist?: boolean;
|
|
99
99
|
}
|
|
@@ -203,7 +203,8 @@ export class AppEmbed extends V1Embed {
|
|
|
203
203
|
* @param path string | number The string, set to iframe src and navigate to new page
|
|
204
204
|
* eg: appEmbed.navigateToPage('pinboards')
|
|
205
205
|
* When used with `noReload` this can also be a number like 1/-1 to go forward/back.
|
|
206
|
-
* @param noReload boolean Trigger the navigation without reloading the page
|
|
206
|
+
* @param noReload boolean Trigger the navigation without reloading the page
|
|
207
|
+
* @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl, 8.4.1-sw
|
|
207
208
|
*/
|
|
208
209
|
public navigateToPage(path: string | number, noReload = false): void {
|
|
209
210
|
if (!this.iFrame) {
|
package/src/embed/base.ts
CHANGED
|
@@ -146,7 +146,7 @@ export function disableAutoLogin(): void {
|
|
|
146
146
|
*
|
|
147
147
|
* @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
|
|
148
148
|
* @returns Promise which resolves when logout completes.
|
|
149
|
-
* @version SDK: 1.10.1 | ThoughtSpot:
|
|
149
|
+
* @version SDK: 1.10.1 | ThoughtSpot: 8.2.0.cl, 8.4.1-sw
|
|
150
150
|
*/
|
|
151
151
|
export const logout = (doNotDisableAutoLogin = false): Promise<boolean> => {
|
|
152
152
|
if (!doNotDisableAutoLogin) {
|
|
@@ -23,6 +23,7 @@ const defaultViewConfig = {
|
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
const liveboardId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
|
|
26
|
+
const activeTabId = '502693ba-9818-4e71-8ecd-d1a194e46861';
|
|
26
27
|
const vizId = '6e73f724-660e-11eb-ae93-0242ac130002';
|
|
27
28
|
const thoughtSpotHost = 'tshost';
|
|
28
29
|
const defaultParamsSansHideAction = `&hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}`;
|
|
@@ -234,4 +235,18 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
234
235
|
const result = await liveboardEmbed.trigger(HostEvent.Pin);
|
|
235
236
|
expect(mockProcessTrigger).toBeCalled();
|
|
236
237
|
});
|
|
238
|
+
|
|
239
|
+
test('should render active tab when activeTab present', async () => {
|
|
240
|
+
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
241
|
+
liveboardId,
|
|
242
|
+
activeTabId,
|
|
243
|
+
liveboardV2: true,
|
|
244
|
+
} as LiveboardViewConfig);
|
|
245
|
+
liveboardEmbed.render();
|
|
246
|
+
await executeAfterWait(() => {
|
|
247
|
+
expect(getIFrameSrc()).toBe(
|
|
248
|
+
`http://${thoughtSpotHost}/?embedApp=true${defaultParams}&isLiveboardEmbed=true&isPinboardV2Enabled=true#/embed/viz/${liveboardId}/tab/${activeTabId}`,
|
|
249
|
+
);
|
|
250
|
+
});
|
|
251
|
+
});
|
|
237
252
|
});
|
package/src/embed/liveboard.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface LiveboardViewConfig extends ViewConfig {
|
|
|
35
35
|
* This is the minimum height(in pixels) for a full height Liveboard.
|
|
36
36
|
* Setting this height helps resolves issues with empty Liveboards and
|
|
37
37
|
* other screens navigable from a Liveboard.
|
|
38
|
-
* @version 1.5.0
|
|
38
|
+
* @version SDK: 1.5.0 | ThoughtSpot: ts7.oct.cl, 7.2.1
|
|
39
39
|
* @default 500
|
|
40
40
|
*/
|
|
41
41
|
defaultHeight?: number;
|
|
@@ -49,7 +49,7 @@ export interface LiveboardViewConfig extends ViewConfig {
|
|
|
49
49
|
*/
|
|
50
50
|
liveboardId?: string;
|
|
51
51
|
/**
|
|
52
|
-
* To support backward
|
|
52
|
+
* To support backward compatibility
|
|
53
53
|
* @hidden
|
|
54
54
|
*/
|
|
55
55
|
pinboardId?: string;
|
|
@@ -66,7 +66,7 @@ export interface LiveboardViewConfig extends ViewConfig {
|
|
|
66
66
|
* Array of viz ids which should be visible when the liveboard
|
|
67
67
|
* first renders. This can be changed by triggering the "SetVisibleVizs"
|
|
68
68
|
* event.
|
|
69
|
-
* @version 1.9.1
|
|
69
|
+
* @version SDK: 1.9.1 | ThoughtSpot: 8.1.0.cl, 8.4.1-sw
|
|
70
70
|
*/
|
|
71
71
|
visibleVizs?: string[];
|
|
72
72
|
/**
|
|
@@ -75,13 +75,16 @@ export interface LiveboardViewConfig extends ViewConfig {
|
|
|
75
75
|
*/
|
|
76
76
|
preventPinboardFilterRemoval?: boolean;
|
|
77
77
|
/**
|
|
78
|
-
* Render embedded
|
|
79
|
-
* This is a transient flag which is primarily meant for internal use
|
|
78
|
+
* Render embedded Liveboards and visualizations in the new Liveboard experience mode
|
|
80
79
|
* @default false
|
|
81
|
-
* @version SDK: 1.
|
|
82
|
-
* @hidden
|
|
80
|
+
* @version SDK: 1.14.0 | ThoughtSpot: 8.6.0.cl, 8.8.1-sw
|
|
83
81
|
*/
|
|
84
82
|
liveboardV2?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Tab Id of the Liveboard that is supposed to be active
|
|
85
|
+
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
|
|
86
|
+
*/
|
|
87
|
+
activeTabId?: string;
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
/**
|
|
@@ -111,6 +114,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
111
114
|
visibleVizs,
|
|
112
115
|
liveboardV2 = false,
|
|
113
116
|
vizId,
|
|
117
|
+
activeTabId,
|
|
114
118
|
} = this.viewConfig;
|
|
115
119
|
|
|
116
120
|
const preventLiveboardFilterRemoval =
|
|
@@ -156,6 +160,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
156
160
|
liveboardId: string,
|
|
157
161
|
vizId?: string,
|
|
158
162
|
runtimeFilters?: RuntimeFilter[],
|
|
163
|
+
activeTabId?: string,
|
|
159
164
|
) {
|
|
160
165
|
const filterQuery = getFilterQuery(runtimeFilters || []);
|
|
161
166
|
const queryParams = this.getEmbedParams();
|
|
@@ -168,6 +173,9 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
168
173
|
false,
|
|
169
174
|
false,
|
|
170
175
|
)}/viz/${liveboardId}`;
|
|
176
|
+
if (activeTabId) {
|
|
177
|
+
url = `${url}/tab/${activeTabId}`;
|
|
178
|
+
}
|
|
171
179
|
if (vizId) {
|
|
172
180
|
url = `${url}/${vizId}`;
|
|
173
181
|
}
|
|
@@ -217,7 +225,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
217
225
|
* visualization ID and the runtime filters.
|
|
218
226
|
*/
|
|
219
227
|
public render(): LiveboardEmbed {
|
|
220
|
-
const { vizId, runtimeFilters } = this.viewConfig;
|
|
228
|
+
const { vizId, activeTabId, runtimeFilters } = this.viewConfig;
|
|
221
229
|
const liveboardId =
|
|
222
230
|
this.viewConfig.liveboardId ?? this.viewConfig.pinboardId;
|
|
223
231
|
|
|
@@ -236,7 +244,12 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
236
244
|
|
|
237
245
|
super.render();
|
|
238
246
|
|
|
239
|
-
const src = this.getIFrameSrc(
|
|
247
|
+
const src = this.getIFrameSrc(
|
|
248
|
+
liveboardId,
|
|
249
|
+
vizId,
|
|
250
|
+
runtimeFilters,
|
|
251
|
+
activeTabId,
|
|
252
|
+
);
|
|
240
253
|
this.renderV1Embed(src);
|
|
241
254
|
|
|
242
255
|
return this;
|
package/src/embed/search.ts
CHANGED
|
@@ -52,9 +52,13 @@ export interface SearchViewConfig extends ViewConfig {
|
|
|
52
52
|
* using raw answer data.
|
|
53
53
|
*/
|
|
54
54
|
hideResults?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* If set to true, expands all the data sources panel.
|
|
57
|
+
*/
|
|
58
|
+
expandAllDataSource?: boolean;
|
|
55
59
|
/**
|
|
56
60
|
* If set to true, the Search Assist feature is enabled.
|
|
57
|
-
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl
|
|
61
|
+
* @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
|
|
58
62
|
*/
|
|
59
63
|
enableSearchAssist?: boolean;
|
|
60
64
|
/**
|
|
@@ -130,6 +134,7 @@ export class SearchEmbed extends TsEmbed {
|
|
|
130
134
|
private getIFrameSrc(answerId: string, dataSources?: string[]) {
|
|
131
135
|
const {
|
|
132
136
|
hideResults,
|
|
137
|
+
expandAllDataSource,
|
|
133
138
|
enableSearchAssist,
|
|
134
139
|
forceTable,
|
|
135
140
|
searchOptions,
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -118,12 +118,12 @@ export interface ViewConfig {
|
|
|
118
118
|
/**
|
|
119
119
|
* The list of actions to display from the primary menu, more menu
|
|
120
120
|
* (...), and the contextual menu.
|
|
121
|
-
* @version 1.6.0
|
|
121
|
+
* @version SDK: 1.6.0 | ThoughtSpot: ts8.nov.cl, 8.4.1-sw
|
|
122
122
|
*/
|
|
123
123
|
visibleActions?: Action[];
|
|
124
124
|
/**
|
|
125
125
|
* Show alert messages and toast messages in the embedded view.
|
|
126
|
-
* @version 1.11.0 | ThoughtSpot: 8.3.0.cl
|
|
126
|
+
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
|
|
127
127
|
*/
|
|
128
128
|
showAlerts?: boolean;
|
|
129
129
|
/**
|
|
@@ -133,7 +133,7 @@ export interface ViewConfig {
|
|
|
133
133
|
runtimeFilters?: RuntimeFilter[];
|
|
134
134
|
/**
|
|
135
135
|
* The locale/language to use for the embedded view.
|
|
136
|
-
* @version 1.9.4
|
|
136
|
+
* @version SDK: 1.9.4 | ThoughtSpot 8.1.0.cl, 8.4.1-sw
|
|
137
137
|
*/
|
|
138
138
|
locale?: string;
|
|
139
139
|
/**
|
|
@@ -143,7 +143,7 @@ export interface ViewConfig {
|
|
|
143
143
|
* Warning: This option is for advanced use only and is used internally
|
|
144
144
|
* to control embed behavior in non-regular ways. We do not publish the
|
|
145
145
|
* list of supported keys and values associated with each.
|
|
146
|
-
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
|
|
146
|
+
* @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl, 8.4.1-sw
|
|
147
147
|
*/
|
|
148
148
|
additionalFlags?: { [key: string]: string | number | boolean };
|
|
149
149
|
}
|