@thoughtspot/visual-embed-sdk 1.7.0-alpha.0 → 1.7.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/dist/src/auth.d.ts +3 -5
- package/dist/src/embed/app.d.ts +1 -1
- package/dist/src/embed/liveboard.d.ts +1 -1
- package/dist/src/embed/search.d.ts +7 -2
- package/dist/src/embed/ts-embed.d.ts +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/test/test-utils.d.ts +1 -0
- package/dist/src/types.d.ts +19 -3
- package/dist/src/utils.d.ts +1 -1
- package/dist/tsembed.es.js +65 -20
- package/dist/tsembed.js +62 -20
- package/lib/package.json +2 -1
- package/lib/src/auth.d.ts +3 -5
- package/lib/src/auth.js +27 -9
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.js +2 -2
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/config.js +1 -1
- package/lib/src/embed/app.d.ts +1 -1
- package/lib/src/embed/app.js +1 -1
- package/lib/src/embed/base.js +1 -1
- package/lib/src/embed/liveboard.d.ts +1 -1
- package/lib/src/embed/liveboard.js +1 -1
- package/lib/src/embed/search.d.ts +7 -2
- package/lib/src/embed/search.js +13 -3
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +33 -20
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +1 -1
- package/lib/src/embed/ts-embed.js +3 -2
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/react/index.spec.js +1 -1
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/test/test-utils.d.ts +1 -0
- package/lib/src/test/test-utils.js +3 -0
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/types.d.ts +19 -3
- package/lib/src/types.js +18 -2
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils.d.ts +1 -1
- package/lib/src/utils.js +1 -1
- package/lib/src/visual-embed-sdk.d.ts +29 -8
- package/package.json +2 -1
- package/src/auth.spec.ts +2 -2
- package/src/auth.ts +37 -9
- package/src/config.ts +1 -1
- package/src/embed/app.ts +1 -1
- package/src/embed/base.ts +1 -1
- package/src/embed/liveboard.ts +1 -1
- package/src/embed/search.spec.ts +39 -19
- package/src/embed/search.ts +19 -2
- package/src/embed/ts-embed.ts +4 -2
- package/src/index.ts +1 -1
- package/src/react/index.spec.tsx +1 -1
- package/src/test/test-utils.ts +4 -0
- package/src/types.ts +18 -2
- package/src/utils.ts +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
declare module '@thoughtspot/visual-embed-sdk' {
|
|
4
4
|
/**
|
|
5
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) 2022
|
|
6
6
|
*
|
|
7
7
|
* ThoughtSpot Visual Embed SDK for embedding ThoughtSpot analytics
|
|
8
8
|
* in other web applications.
|
|
@@ -20,7 +20,7 @@ declare module '@thoughtspot/visual-embed-sdk' {
|
|
|
20
20
|
|
|
21
21
|
declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
22
22
|
/**
|
|
23
|
-
* Copyright (c)
|
|
23
|
+
* Copyright (c) 2022
|
|
24
24
|
*
|
|
25
25
|
* Full application embedding
|
|
26
26
|
* https://developers.thoughtspot.com/docs/?pageid=full-embed
|
|
@@ -149,7 +149,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/base' {
|
|
|
149
149
|
|
|
150
150
|
declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
151
151
|
/**
|
|
152
|
-
* Copyright (c)
|
|
152
|
+
* Copyright (c) 2022
|
|
153
153
|
*
|
|
154
154
|
* Embed a ThoughtSpot Liveboard or visualization
|
|
155
155
|
* https://developers.thoughtspot.com/docs/?pageid=embed-pinboard
|
|
@@ -230,14 +230,14 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
230
230
|
|
|
231
231
|
declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
232
232
|
/**
|
|
233
|
-
* Copyright (c)
|
|
233
|
+
* Copyright (c) 2022
|
|
234
234
|
*
|
|
235
235
|
* Embed ThoughtSpot search or a saved answer
|
|
236
236
|
*
|
|
237
237
|
* @summary Search embed
|
|
238
238
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
239
239
|
*/
|
|
240
|
-
import { DOMSelector } from '@thoughtspot/visual-embed-sdk/types';
|
|
240
|
+
import { DOMSelector, Action } from '@thoughtspot/visual-embed-sdk/types';
|
|
241
241
|
import { ViewConfig, TsEmbed } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
|
|
242
242
|
/**
|
|
243
243
|
* Configuration for search options
|
|
@@ -275,6 +275,10 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
275
275
|
* using raw answer data.
|
|
276
276
|
*/
|
|
277
277
|
hideResults?: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* If set to true, expands all the data sources panel.
|
|
280
|
+
*/
|
|
281
|
+
expandAllDataSource?: boolean;
|
|
278
282
|
/**
|
|
279
283
|
* If set to true, the Search Assist feature is enabled.
|
|
280
284
|
*/
|
|
@@ -302,6 +306,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
302
306
|
*/
|
|
303
307
|
answerId?: string;
|
|
304
308
|
}
|
|
309
|
+
export const HiddenActionItemByDefaultForSearchEmbed: Action[];
|
|
305
310
|
/**
|
|
306
311
|
* Embed ThoughtSpot search
|
|
307
312
|
*
|
|
@@ -335,6 +340,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
335
340
|
* SSO using SAML
|
|
336
341
|
*/
|
|
337
342
|
SSO = "SSO_SAML",
|
|
343
|
+
/**
|
|
344
|
+
* SSO using OIDC
|
|
345
|
+
*/
|
|
346
|
+
OIDC = "SSO_OIDC",
|
|
338
347
|
/**
|
|
339
348
|
* Trusted authentication server
|
|
340
349
|
*/
|
|
@@ -647,6 +656,9 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
647
656
|
/**
|
|
648
657
|
* Event types that can be triggered by the host application
|
|
649
658
|
* to the embedded ThoughtSpot app
|
|
659
|
+
*
|
|
660
|
+
* To trigger an event use the corresponding
|
|
661
|
+
* {@link LiveboardEmbed.trigger} or {@link AppEmbed.trigger} or {@link SearchEmbed.trigger} method.
|
|
650
662
|
*/
|
|
651
663
|
export enum HostEvent {
|
|
652
664
|
/**
|
|
@@ -680,7 +692,13 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
680
692
|
* will be hidden.
|
|
681
693
|
* @version 1.6.0 or later
|
|
682
694
|
*/
|
|
683
|
-
SetVisibleVizs = "SetPinboardVisibleVizs"
|
|
695
|
+
SetVisibleVizs = "SetPinboardVisibleVizs",
|
|
696
|
+
/**
|
|
697
|
+
* Update the runtime filters
|
|
698
|
+
* @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
|
|
699
|
+
* @version 1.8.0 or later
|
|
700
|
+
*/
|
|
701
|
+
UpdateRuntimeFilters = "UpdateRuntimeFilters"
|
|
684
702
|
}
|
|
685
703
|
/**
|
|
686
704
|
* The different visual modes that the data sources panel within
|
|
@@ -707,6 +725,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
707
725
|
export enum Param {
|
|
708
726
|
DataSources = "dataSources",
|
|
709
727
|
DataSourceMode = "dataSourceMode",
|
|
728
|
+
ExpandAllDataSource = "expandAllDataSource",
|
|
710
729
|
DisableActions = "disableAction",
|
|
711
730
|
DisableActionReason = "disableHint",
|
|
712
731
|
ForceTable = "forceTable",
|
|
@@ -724,6 +743,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
724
743
|
executeSearch = "executeSearch",
|
|
725
744
|
fullHeight = "isFullHeightPinboard",
|
|
726
745
|
livedBoardEmbed = "isLiveboardEmbed",
|
|
746
|
+
searchEmbed = "isSearchEmbed",
|
|
727
747
|
Version = "sdkVersion",
|
|
728
748
|
ViewPortHeight = "viewPortHeight",
|
|
729
749
|
ViewPortWidth = "viewPortWidth",
|
|
@@ -743,7 +763,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
743
763
|
EditACopy = "editACopy",
|
|
744
764
|
CopyLink = "embedDocument",
|
|
745
765
|
ResetLayout = "resetLayout",
|
|
746
|
-
Schedule = "
|
|
766
|
+
Schedule = "subscription",
|
|
747
767
|
SchedulesList = "schedule-list",
|
|
748
768
|
Share = "share",
|
|
749
769
|
AddFilter = "addFilter",
|
|
@@ -792,6 +812,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
792
812
|
DrillInclude = "context-menu-item-include",
|
|
793
813
|
DrillExclude = "context-menu-item-exclude",
|
|
794
814
|
CopyToClipboard = "context-menu-item-copy-to-clipboard",
|
|
815
|
+
CopyAndEdit = "context-menu-item-copy-and-edit",
|
|
795
816
|
DrillEdit = "context-menu-item-edit",
|
|
796
817
|
EditMeasure = "context-menu-item-edit-measure",
|
|
797
818
|
Separator = "context-menu-item-separator",
|
|
@@ -818,7 +839,7 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
818
839
|
|
|
819
840
|
declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
820
841
|
/**
|
|
821
|
-
* Copyright (c)
|
|
842
|
+
* Copyright (c) 2022
|
|
822
843
|
*
|
|
823
844
|
* Base classes
|
|
824
845
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/visual-embed-sdk",
|
|
3
|
-
"version": "1.7.0
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "ThoughtSpot Embed SDK",
|
|
5
5
|
"module": "lib/src/index.js",
|
|
6
6
|
"main": "dist/tsembed.js",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"asciidoctor": "^2.2.1",
|
|
66
66
|
"babel-jest": "^26.6.3",
|
|
67
67
|
"babel-preset-gatsby": "^1.10.0",
|
|
68
|
+
"classnames": "^2.3.1",
|
|
68
69
|
"command-line-args": "^5.1.1",
|
|
69
70
|
"coveralls": "^3.1.0",
|
|
70
71
|
"dts-bundle": "0.7.3",
|
package/src/auth.spec.ts
CHANGED
|
@@ -74,8 +74,8 @@ describe('Unit test for auth', () => {
|
|
|
74
74
|
global.fetch = window.fetch;
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
test('endpoints,
|
|
78
|
-
const ssoTemplateUrl = authInstance.EndPoints.
|
|
77
|
+
test('endpoints, SAML_LOGIN_TEMPLATE', () => {
|
|
78
|
+
const ssoTemplateUrl = authInstance.EndPoints.SAML_LOGIN_TEMPLATE(
|
|
79
79
|
thoughtSpotHost,
|
|
80
80
|
);
|
|
81
81
|
expect(ssoTemplateUrl).toBe(
|
package/src/auth.ts
CHANGED
|
@@ -23,8 +23,10 @@ export const SSO_REDIRECTION_MARKER_GUID =
|
|
|
23
23
|
|
|
24
24
|
export const EndPoints = {
|
|
25
25
|
AUTH_VERIFICATION: '/callosum/v1/session/info',
|
|
26
|
-
|
|
26
|
+
SAML_LOGIN_TEMPLATE: (targetUrl: string) =>
|
|
27
27
|
`/callosum/v1/saml/login?targetURLPath=${targetUrl}`,
|
|
28
|
+
OIDC_LOGIN_TEMPLATE: (targetUrl: string) =>
|
|
29
|
+
`/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
|
|
28
30
|
TOKEN_LOGIN: '/callosum/v1/session/login/token',
|
|
29
31
|
BASIC_LOGIN: '/callosum/v1/session/login',
|
|
30
32
|
};
|
|
@@ -171,7 +173,10 @@ async function samlPopupFlow(ssoURL: string) {
|
|
|
171
173
|
* Perform SAML authentication
|
|
172
174
|
* @param embedConfig The embed configuration
|
|
173
175
|
*/
|
|
174
|
-
|
|
176
|
+
const doSSOAuth = async (
|
|
177
|
+
embedConfig: EmbedConfig,
|
|
178
|
+
ssoEndPoint: string,
|
|
179
|
+
): Promise<void> => {
|
|
175
180
|
const { thoughtSpotHost } = embedConfig;
|
|
176
181
|
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
177
182
|
if (loggedIn) {
|
|
@@ -190,6 +195,17 @@ export const doSamlAuth = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
190
195
|
return;
|
|
191
196
|
}
|
|
192
197
|
|
|
198
|
+
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
199
|
+
if (embedConfig.noRedirect) {
|
|
200
|
+
await samlPopupFlow(ssoURL);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
window.location.href = ssoURL;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export const doSamlAuth = async (embedConfig: EmbedConfig) => {
|
|
208
|
+
const { thoughtSpotHost } = embedConfig;
|
|
193
209
|
// redirect for SSO, when the SSO authentication is done, this page will be loaded
|
|
194
210
|
// again and the same JS will execute again.
|
|
195
211
|
const ssoRedirectUrl = embedConfig.noRedirect
|
|
@@ -197,17 +213,27 @@ export const doSamlAuth = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
197
213
|
: appendToUrlHash(window.location.href, SSO_REDIRECTION_MARKER_GUID);
|
|
198
214
|
|
|
199
215
|
// bring back the page to the same URL
|
|
200
|
-
const ssoEndPoint = `${EndPoints.
|
|
216
|
+
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(
|
|
201
217
|
encodeURIComponent(ssoRedirectUrl),
|
|
202
218
|
)}`;
|
|
203
219
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
await samlPopupFlow(ssoURL);
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
220
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
221
|
+
};
|
|
209
222
|
|
|
210
|
-
|
|
223
|
+
export const doOIDCAuth = async (embedConfig: EmbedConfig) => {
|
|
224
|
+
const { thoughtSpotHost } = embedConfig;
|
|
225
|
+
// redirect for SSO, when the SSO authentication is done, this page will be loaded
|
|
226
|
+
// again and the same JS will execute again.
|
|
227
|
+
const ssoRedirectUrl = embedConfig.noRedirect
|
|
228
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
229
|
+
: appendToUrlHash(window.location.href, SSO_REDIRECTION_MARKER_GUID);
|
|
230
|
+
|
|
231
|
+
// bring back the page to the same URL
|
|
232
|
+
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(
|
|
233
|
+
encodeURIComponent(ssoRedirectUrl),
|
|
234
|
+
)}`;
|
|
235
|
+
|
|
236
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
211
237
|
};
|
|
212
238
|
|
|
213
239
|
/**
|
|
@@ -219,6 +245,8 @@ export const authenticate = async (embedConfig: EmbedConfig): Promise<void> => {
|
|
|
219
245
|
switch (authType) {
|
|
220
246
|
case AuthType.SSO:
|
|
221
247
|
return doSamlAuth(embedConfig);
|
|
248
|
+
case AuthType.OIDC:
|
|
249
|
+
return doOIDCAuth(embedConfig);
|
|
222
250
|
case AuthType.AuthServer:
|
|
223
251
|
return doTokenAuth(embedConfig);
|
|
224
252
|
case AuthType.Basic:
|
package/src/config.ts
CHANGED
package/src/embed/app.ts
CHANGED
package/src/embed/base.ts
CHANGED
package/src/embed/liveboard.ts
CHANGED
package/src/embed/search.spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SearchEmbed } from './search';
|
|
1
|
+
import { SearchEmbed, HiddenActionItemByDefaultForSearchEmbed } from './search';
|
|
2
2
|
import { init } from '../index';
|
|
3
3
|
import { Action, AuthType } from '../types';
|
|
4
4
|
import {
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
getDocumentBody,
|
|
7
7
|
getIFrameSrc,
|
|
8
8
|
getRootEl,
|
|
9
|
+
fixedEncodeURI,
|
|
9
10
|
} from '../test/test-utils';
|
|
10
11
|
import { version } from '../../package.json';
|
|
11
12
|
|
|
@@ -18,6 +19,11 @@ const defaultViewConfig = {
|
|
|
18
19
|
const answerId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
|
|
19
20
|
const thoughtSpotHost = 'tshost';
|
|
20
21
|
const defaultParams = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}`;
|
|
22
|
+
const hideBydefault = `&hideAction=${fixedEncodeURI(
|
|
23
|
+
JSON.stringify(HiddenActionItemByDefaultForSearchEmbed),
|
|
24
|
+
)}`;
|
|
25
|
+
const defaultParamsWithHiddenActions = defaultParams + hideBydefault;
|
|
26
|
+
const prefixParams = '&isSearchEmbed=true';
|
|
21
27
|
|
|
22
28
|
beforeAll(() => {
|
|
23
29
|
init({
|
|
@@ -36,7 +42,7 @@ describe('Search embed tests', () => {
|
|
|
36
42
|
searchEmbed.render();
|
|
37
43
|
await executeAfterWait(() => {
|
|
38
44
|
expect(getIFrameSrc()).toBe(
|
|
39
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
45
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
|
|
40
46
|
);
|
|
41
47
|
});
|
|
42
48
|
});
|
|
@@ -50,7 +56,7 @@ describe('Search embed tests', () => {
|
|
|
50
56
|
searchEmbed.render();
|
|
51
57
|
await executeAfterWait(() => {
|
|
52
58
|
expect(getIFrameSrc()).toBe(
|
|
53
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
59
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
|
|
54
60
|
);
|
|
55
61
|
});
|
|
56
62
|
});
|
|
@@ -68,7 +74,7 @@ describe('Search embed tests', () => {
|
|
|
68
74
|
searchEmbed.render();
|
|
69
75
|
await executeAfterWait(() => {
|
|
70
76
|
expect(getIFrameSrc()).toBe(
|
|
71
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
77
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
|
|
72
78
|
);
|
|
73
79
|
});
|
|
74
80
|
});
|
|
@@ -86,7 +92,7 @@ describe('Search embed tests', () => {
|
|
|
86
92
|
searchEmbed.render();
|
|
87
93
|
await executeAfterWait(() => {
|
|
88
94
|
expect(getIFrameSrc()).toBe(
|
|
89
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
95
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
|
|
90
96
|
);
|
|
91
97
|
});
|
|
92
98
|
|
|
@@ -101,7 +107,7 @@ describe('Search embed tests', () => {
|
|
|
101
107
|
searchEmbed.render();
|
|
102
108
|
await executeAfterWait(() => {
|
|
103
109
|
expect(getIFrameSrc()).toBe(
|
|
104
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
110
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&executeSearch=true&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
|
|
105
111
|
);
|
|
106
112
|
});
|
|
107
113
|
});
|
|
@@ -120,7 +126,7 @@ describe('Search embed tests', () => {
|
|
|
120
126
|
searchEmbed.render();
|
|
121
127
|
await executeAfterWait(() => {
|
|
122
128
|
expect(getIFrameSrc()).toBe(
|
|
123
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
129
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=collapse&useLastSelectedSources=false${prefixParams}#/embed/answer`,
|
|
124
130
|
);
|
|
125
131
|
});
|
|
126
132
|
});
|
|
@@ -139,7 +145,7 @@ describe('Search embed tests', () => {
|
|
|
139
145
|
searchEmbed.render();
|
|
140
146
|
await executeAfterWait(() => {
|
|
141
147
|
expect(getIFrameSrc()).toBe(
|
|
142
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
148
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=hide&useLastSelectedSources=false${prefixParams}#/embed/answer`,
|
|
143
149
|
);
|
|
144
150
|
});
|
|
145
151
|
});
|
|
@@ -159,7 +165,7 @@ describe('Search embed tests', () => {
|
|
|
159
165
|
searchEmbed.render();
|
|
160
166
|
await executeAfterWait(() => {
|
|
161
167
|
expect(getIFrameSrc()).toBe(
|
|
162
|
-
`http://${thoughtSpotHost}/v2/?${defaultParams}&disableAction=[%22download%22,%22edit%22]&disableHint=Permission%20denied&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=expand&useLastSelectedSources=false#/embed/answer`,
|
|
168
|
+
`http://${thoughtSpotHost}/v2/?${defaultParams}&disableAction=[%22download%22,%22edit%22]&disableHint=Permission%20denied${hideBydefault}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
|
|
163
169
|
);
|
|
164
170
|
});
|
|
165
171
|
});
|
|
@@ -172,41 +178,55 @@ describe('Search embed tests', () => {
|
|
|
172
178
|
searchEmbed.render();
|
|
173
179
|
await executeAfterWait(() => {
|
|
174
180
|
expect(getIFrameSrc()).toBe(
|
|
175
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
181
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&enableSearchAssist=true&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
|
|
176
182
|
);
|
|
177
183
|
});
|
|
178
184
|
});
|
|
179
185
|
|
|
180
186
|
test('should hide actions', async () => {
|
|
187
|
+
const hiddenActionsForSearch = [
|
|
188
|
+
Action.DownloadAsCsv,
|
|
189
|
+
Action.DownloadAsPdf,
|
|
190
|
+
Action.DownloadAsXlsx,
|
|
191
|
+
];
|
|
181
192
|
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
182
|
-
hiddenActions:
|
|
183
|
-
Action.DownloadAsCsv,
|
|
184
|
-
Action.DownloadAsPdf,
|
|
185
|
-
Action.DownloadAsXlsx,
|
|
186
|
-
],
|
|
193
|
+
hiddenActions: hiddenActionsForSearch,
|
|
187
194
|
...defaultViewConfig,
|
|
188
195
|
answerId,
|
|
189
196
|
});
|
|
190
197
|
searchEmbed.render();
|
|
198
|
+
const hideActionUrl = fixedEncodeURI(
|
|
199
|
+
JSON.stringify([
|
|
200
|
+
...hiddenActionsForSearch,
|
|
201
|
+
...HiddenActionItemByDefaultForSearchEmbed,
|
|
202
|
+
]),
|
|
203
|
+
);
|
|
191
204
|
await executeAfterWait(() => {
|
|
192
205
|
expect(getIFrameSrc()).toBe(
|
|
193
|
-
`http://${thoughtSpotHost}/v2/?${defaultParams}&hideAction
|
|
206
|
+
`http://${thoughtSpotHost}/v2/?${defaultParams}&hideAction=${hideActionUrl}&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
194
207
|
);
|
|
195
208
|
});
|
|
196
209
|
});
|
|
197
210
|
|
|
198
211
|
test('should disable and hide actions', async () => {
|
|
212
|
+
const hiddenActionsForSearch = [Action.DownloadAsCsv];
|
|
199
213
|
const searchEmbed = new SearchEmbed(getRootEl(), {
|
|
200
214
|
disabledActions: [Action.DownloadAsXlsx],
|
|
201
|
-
hiddenActions:
|
|
215
|
+
hiddenActions: hiddenActionsForSearch,
|
|
202
216
|
disabledActionReason: 'Access denied',
|
|
203
217
|
...defaultViewConfig,
|
|
204
218
|
answerId,
|
|
205
219
|
});
|
|
206
220
|
searchEmbed.render();
|
|
221
|
+
const hideActionUrl = fixedEncodeURI(
|
|
222
|
+
JSON.stringify([
|
|
223
|
+
...hiddenActionsForSearch,
|
|
224
|
+
...HiddenActionItemByDefaultForSearchEmbed,
|
|
225
|
+
]),
|
|
226
|
+
);
|
|
207
227
|
await executeAfterWait(() => {
|
|
208
228
|
expect(getIFrameSrc()).toBe(
|
|
209
|
-
`http://${thoughtSpotHost}/v2/?${defaultParams}&disableAction=[%22downloadAsXLSX%22]&disableHint=Access%20denied&hideAction
|
|
229
|
+
`http://${thoughtSpotHost}/v2/?${defaultParams}&disableAction=[%22downloadAsXLSX%22]&disableHint=Access%20denied&hideAction=${hideActionUrl}&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
210
230
|
);
|
|
211
231
|
});
|
|
212
232
|
});
|
|
@@ -219,7 +239,7 @@ describe('Search embed tests', () => {
|
|
|
219
239
|
searchEmbed.render();
|
|
220
240
|
await executeAfterWait(() => {
|
|
221
241
|
expect(getIFrameSrc()).toBe(
|
|
222
|
-
`http://${thoughtSpotHost}/v2/?${
|
|
242
|
+
`http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
|
|
223
243
|
);
|
|
224
244
|
});
|
|
225
245
|
});
|
package/src/embed/search.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2022
|
|
3
3
|
*
|
|
4
4
|
* Embed ThoughtSpot search or a saved answer
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { DataSourceVisualMode, DOMSelector, Param } from '../types';
|
|
10
|
+
import { DataSourceVisualMode, DOMSelector, Param, Action } from '../types';
|
|
11
11
|
import { getQueryParamString } from '../utils';
|
|
12
12
|
import { ViewConfig, TsEmbed } from './ts-embed';
|
|
13
13
|
import { version } from '../../package.json';
|
|
@@ -49,6 +49,10 @@ export interface SearchViewConfig extends ViewConfig {
|
|
|
49
49
|
* using raw answer data.
|
|
50
50
|
*/
|
|
51
51
|
hideResults?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* If set to true, expands all the data sources panel.
|
|
54
|
+
*/
|
|
55
|
+
expandAllDataSource?: boolean;
|
|
52
56
|
/**
|
|
53
57
|
* If set to true, the Search Assist feature is enabled.
|
|
54
58
|
*/
|
|
@@ -77,6 +81,11 @@ export interface SearchViewConfig extends ViewConfig {
|
|
|
77
81
|
answerId?: string;
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
export const HiddenActionItemByDefaultForSearchEmbed = [
|
|
85
|
+
Action.EditACopy,
|
|
86
|
+
Action.SaveAsView,
|
|
87
|
+
];
|
|
88
|
+
|
|
80
89
|
/**
|
|
81
90
|
* Embed ThoughtSpot search
|
|
82
91
|
*
|
|
@@ -118,12 +127,19 @@ export class SearchEmbed extends TsEmbed {
|
|
|
118
127
|
private getIFrameSrc(answerId: string, dataSources?: string[]) {
|
|
119
128
|
const {
|
|
120
129
|
hideResults,
|
|
130
|
+
expandAllDataSource,
|
|
121
131
|
enableSearchAssist,
|
|
122
132
|
forceTable,
|
|
123
133
|
searchOptions,
|
|
124
134
|
} = this.viewConfig;
|
|
125
135
|
const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
|
|
126
136
|
const queryParams = this.getBaseQueryParams();
|
|
137
|
+
|
|
138
|
+
queryParams[Param.HideActions] = [
|
|
139
|
+
...(queryParams[Param.HideActions] ?? []),
|
|
140
|
+
...HiddenActionItemByDefaultForSearchEmbed,
|
|
141
|
+
];
|
|
142
|
+
|
|
127
143
|
if (dataSources && dataSources.length) {
|
|
128
144
|
queryParams[Param.DataSources] = JSON.stringify(dataSources);
|
|
129
145
|
}
|
|
@@ -148,6 +164,7 @@ export class SearchEmbed extends TsEmbed {
|
|
|
148
164
|
|
|
149
165
|
queryParams[Param.DataSourceMode] = this.getDataSourceMode();
|
|
150
166
|
queryParams[Param.UseLastSelectedDataSource] = false;
|
|
167
|
+
queryParams[Param.searchEmbed] = true;
|
|
151
168
|
let query = '';
|
|
152
169
|
const queryParamsString = getQueryParamString(queryParams, true);
|
|
153
170
|
if (queryParamsString) {
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2022
|
|
3
3
|
*
|
|
4
4
|
* Base classes
|
|
5
5
|
*
|
|
@@ -32,9 +32,11 @@ import {
|
|
|
32
32
|
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
|
|
33
33
|
import { getProcessData } from '../utils/processData';
|
|
34
34
|
import { processTrigger } from '../utils/processTrigger';
|
|
35
|
-
import
|
|
35
|
+
import pkgInfo from '../../package.json';
|
|
36
36
|
import { getAuthPromise, getEmbedConfig, renderInQueue } from './base';
|
|
37
37
|
|
|
38
|
+
const { version } = pkgInfo;
|
|
39
|
+
|
|
38
40
|
/**
|
|
39
41
|
* The event id map from v2 event names to v1 event id
|
|
40
42
|
* v1 events are the classic embed events implemented in Blink v1
|
package/src/index.ts
CHANGED
package/src/react/index.spec.tsx
CHANGED
|
@@ -31,7 +31,7 @@ describe('React Components', () => {
|
|
|
31
31
|
await waitFor(() => getIFrameEl(container));
|
|
32
32
|
|
|
33
33
|
expect(getIFrameSrc(container)).toBe(
|
|
34
|
-
`http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&dataSourceMode=hide&useLastSelectedSources=false#/embed/answer`,
|
|
34
|
+
`http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&hideAction=[%22editACopy%22,%22saveAsView%22]&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true#/embed/answer`,
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
|
package/src/test/test-utils.ts
CHANGED
|
@@ -66,3 +66,7 @@ export const executeAfterWait = (
|
|
|
66
66
|
* Time (in milliseconds) to wait for async events to be triggered
|
|
67
67
|
*/
|
|
68
68
|
export const EVENT_WAIT_TIME = 1000;
|
|
69
|
+
|
|
70
|
+
export function fixedEncodeURI(str: string) {
|
|
71
|
+
return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']');
|
|
72
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) 2022
|
|
3
3
|
*
|
|
4
4
|
* TypeScript type definitions for ThoughtSpot Visual Embed SDK
|
|
5
5
|
*
|
|
@@ -21,6 +21,10 @@ export enum AuthType {
|
|
|
21
21
|
* SSO using SAML
|
|
22
22
|
*/
|
|
23
23
|
SSO = 'SSO_SAML',
|
|
24
|
+
/**
|
|
25
|
+
* SSO using OIDC
|
|
26
|
+
*/
|
|
27
|
+
OIDC = 'SSO_OIDC',
|
|
24
28
|
/**
|
|
25
29
|
* Trusted authentication server
|
|
26
30
|
*/
|
|
@@ -353,6 +357,9 @@ export enum EmbedEvent {
|
|
|
353
357
|
/**
|
|
354
358
|
* Event types that can be triggered by the host application
|
|
355
359
|
* to the embedded ThoughtSpot app
|
|
360
|
+
*
|
|
361
|
+
* To trigger an event use the corresponding
|
|
362
|
+
* {@link LiveboardEmbed.trigger} or {@link AppEmbed.trigger} or {@link SearchEmbed.trigger} method.
|
|
356
363
|
*/
|
|
357
364
|
// eslint-disable-next-line no-shadow
|
|
358
365
|
export enum HostEvent {
|
|
@@ -388,6 +395,12 @@ export enum HostEvent {
|
|
|
388
395
|
* @version 1.6.0 or later
|
|
389
396
|
*/
|
|
390
397
|
SetVisibleVizs = 'SetPinboardVisibleVizs',
|
|
398
|
+
/**
|
|
399
|
+
* Update the runtime filters
|
|
400
|
+
* @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
|
|
401
|
+
* @version 1.8.0 or later
|
|
402
|
+
*/
|
|
403
|
+
UpdateRuntimeFilters = 'UpdateRuntimeFilters',
|
|
391
404
|
}
|
|
392
405
|
|
|
393
406
|
/**
|
|
@@ -418,6 +431,7 @@ export enum DataSourceVisualMode {
|
|
|
418
431
|
export enum Param {
|
|
419
432
|
DataSources = 'dataSources',
|
|
420
433
|
DataSourceMode = 'dataSourceMode',
|
|
434
|
+
ExpandAllDataSource = 'expandAllDataSource',
|
|
421
435
|
DisableActions = 'disableAction',
|
|
422
436
|
DisableActionReason = 'disableHint',
|
|
423
437
|
ForceTable = 'forceTable',
|
|
@@ -435,6 +449,7 @@ export enum Param {
|
|
|
435
449
|
executeSearch = 'executeSearch',
|
|
436
450
|
fullHeight = 'isFullHeightPinboard',
|
|
437
451
|
livedBoardEmbed = 'isLiveboardEmbed',
|
|
452
|
+
searchEmbed = 'isSearchEmbed',
|
|
438
453
|
Version = 'sdkVersion',
|
|
439
454
|
ViewPortHeight = 'viewPortHeight',
|
|
440
455
|
ViewPortWidth = 'viewPortWidth',
|
|
@@ -456,7 +471,7 @@ export enum Action {
|
|
|
456
471
|
EditACopy = 'editACopy',
|
|
457
472
|
CopyLink = 'embedDocument',
|
|
458
473
|
ResetLayout = 'resetLayout',
|
|
459
|
-
Schedule = '
|
|
474
|
+
Schedule = 'subscription',
|
|
460
475
|
SchedulesList = 'schedule-list',
|
|
461
476
|
Share = 'share',
|
|
462
477
|
AddFilter = 'addFilter',
|
|
@@ -505,6 +520,7 @@ export enum Action {
|
|
|
505
520
|
DrillInclude = 'context-menu-item-include',
|
|
506
521
|
DrillExclude = 'context-menu-item-exclude',
|
|
507
522
|
CopyToClipboard = 'context-menu-item-copy-to-clipboard',
|
|
523
|
+
CopyAndEdit = 'context-menu-item-copy-and-edit',
|
|
508
524
|
DrillEdit = 'context-menu-item-edit',
|
|
509
525
|
EditMeasure = 'context-menu-item-edit-measure',
|
|
510
526
|
Separator = 'context-menu-item-separator',
|
package/src/utils.ts
CHANGED