@thoughtspot/visual-embed-sdk 1.23.0 → 1.23.2

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.
Files changed (102) hide show
  1. package/README.md +1 -1
  2. package/cjs/package.json +1 -1
  3. package/cjs/src/auth.d.ts.map +1 -1
  4. package/cjs/src/auth.js +1 -3
  5. package/cjs/src/auth.js.map +1 -1
  6. package/cjs/src/embed/app.d.ts +9 -1
  7. package/cjs/src/embed/app.d.ts.map +1 -1
  8. package/cjs/src/embed/app.js +3 -2
  9. package/cjs/src/embed/app.js.map +1 -1
  10. package/cjs/src/embed/app.spec.js +10 -0
  11. package/cjs/src/embed/app.spec.js.map +1 -1
  12. package/cjs/src/embed/base.d.ts +8 -0
  13. package/cjs/src/embed/base.d.ts.map +1 -1
  14. package/cjs/src/embed/base.js +8 -0
  15. package/cjs/src/embed/base.js.map +1 -1
  16. package/cjs/src/embed/sage.d.ts +39 -2
  17. package/cjs/src/embed/sage.d.ts.map +1 -1
  18. package/cjs/src/embed/sage.js +17 -3
  19. package/cjs/src/embed/sage.js.map +1 -1
  20. package/cjs/src/embed/sage.spec.js +27 -1
  21. package/cjs/src/embed/sage.spec.js.map +1 -1
  22. package/cjs/src/embed/search-bar.d.ts +1 -1
  23. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  24. package/cjs/src/embed/search.d.ts +8 -0
  25. package/cjs/src/embed/search.d.ts.map +1 -1
  26. package/cjs/src/embed/search.js +2 -1
  27. package/cjs/src/embed/search.js.map +1 -1
  28. package/cjs/src/embed/search.spec.js +11 -1
  29. package/cjs/src/embed/search.spec.js.map +1 -1
  30. package/cjs/src/react/index.spec.js +1 -1
  31. package/cjs/src/react/index.spec.js.map +1 -1
  32. package/cjs/src/types.d.ts +380 -248
  33. package/cjs/src/types.d.ts.map +1 -1
  34. package/cjs/src/types.js +357 -241
  35. package/cjs/src/types.js.map +1 -1
  36. package/dist/src/auth.d.ts.map +1 -1
  37. package/dist/src/embed/app.d.ts +9 -1
  38. package/dist/src/embed/app.d.ts.map +1 -1
  39. package/dist/src/embed/base.d.ts +8 -0
  40. package/dist/src/embed/base.d.ts.map +1 -1
  41. package/dist/src/embed/sage.d.ts +39 -2
  42. package/dist/src/embed/sage.d.ts.map +1 -1
  43. package/dist/src/embed/search-bar.d.ts +1 -1
  44. package/dist/src/embed/search-bar.d.ts.map +1 -1
  45. package/dist/src/embed/search.d.ts +8 -0
  46. package/dist/src/embed/search.d.ts.map +1 -1
  47. package/dist/src/types.d.ts +380 -248
  48. package/dist/src/types.d.ts.map +1 -1
  49. package/dist/tsembed-react.es.js +381 -17448
  50. package/dist/tsembed-react.js +380 -17447
  51. package/dist/tsembed.es.js +389 -17448
  52. package/dist/tsembed.js +388 -17447
  53. package/dist/visual-embed-sdk-react-full.d.ts +445 -252
  54. package/dist/visual-embed-sdk-react.d.ts +445 -252
  55. package/dist/visual-embed-sdk.d.ts +445 -252
  56. package/lib/package.json +1 -1
  57. package/lib/src/auth.d.ts.map +1 -1
  58. package/lib/src/auth.js +1 -2
  59. package/lib/src/auth.js.map +1 -1
  60. package/lib/src/embed/app.d.ts +9 -1
  61. package/lib/src/embed/app.d.ts.map +1 -1
  62. package/lib/src/embed/app.js +3 -2
  63. package/lib/src/embed/app.js.map +1 -1
  64. package/lib/src/embed/app.spec.js +10 -0
  65. package/lib/src/embed/app.spec.js.map +1 -1
  66. package/lib/src/embed/base.d.ts +8 -0
  67. package/lib/src/embed/base.d.ts.map +1 -1
  68. package/lib/src/embed/base.js +8 -0
  69. package/lib/src/embed/base.js.map +1 -1
  70. package/lib/src/embed/sage.d.ts +39 -2
  71. package/lib/src/embed/sage.d.ts.map +1 -1
  72. package/lib/src/embed/sage.js +17 -3
  73. package/lib/src/embed/sage.js.map +1 -1
  74. package/lib/src/embed/sage.spec.js +27 -1
  75. package/lib/src/embed/sage.spec.js.map +1 -1
  76. package/lib/src/embed/search-bar.d.ts +1 -1
  77. package/lib/src/embed/search-bar.d.ts.map +1 -1
  78. package/lib/src/embed/search.d.ts +8 -0
  79. package/lib/src/embed/search.d.ts.map +1 -1
  80. package/lib/src/embed/search.js +2 -1
  81. package/lib/src/embed/search.js.map +1 -1
  82. package/lib/src/embed/search.spec.js +11 -1
  83. package/lib/src/embed/search.spec.js.map +1 -1
  84. package/lib/src/react/index.spec.js +1 -1
  85. package/lib/src/react/index.spec.js.map +1 -1
  86. package/lib/src/types.d.ts +380 -248
  87. package/lib/src/types.d.ts.map +1 -1
  88. package/lib/src/types.js +357 -241
  89. package/lib/src/types.js.map +1 -1
  90. package/lib/src/visual-embed-sdk.d.ts +445 -252
  91. package/package.json +1 -1
  92. package/src/auth.ts +1 -2
  93. package/src/embed/app.spec.ts +15 -0
  94. package/src/embed/app.ts +11 -1
  95. package/src/embed/base.ts +8 -0
  96. package/src/embed/sage.spec.ts +33 -1
  97. package/src/embed/sage.ts +59 -4
  98. package/src/embed/search-bar.tsx +1 -1
  99. package/src/embed/search.spec.ts +15 -1
  100. package/src/embed/search.ts +10 -0
  101. package/src/react/index.spec.tsx +1 -1
  102. package/src/types.ts +366 -247
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.23.0",
3
+ "version": "1.23.2",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
package/src/auth.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import EventEmitter from 'eventemitter3';
2
- import _ from 'lodash';
3
2
  import { initMixpanel } from './mixpanel-service';
4
3
  import {
5
4
  AuthType, DOMSelector, EmbedConfig, EmbedEvent, Param,
@@ -207,7 +206,7 @@ export function notifyLogout(): void {
207
206
  }
208
207
 
209
208
  export const initSession = (sessionDetails: sessionInfoInterface) => {
210
- if (_.isNull(sessionInfo)) {
209
+ if (sessionInfo == null) {
211
210
  sessionInfo = sessionDetails;
212
211
  initMixpanel(sessionInfo);
213
212
  sessionInfoResolver(sessionInfo);
@@ -254,6 +254,21 @@ describe('App embed tests', () => {
254
254
  });
255
255
  });
256
256
 
257
+ test('Should add enableDataPanelV2 flag to the iframe src', async () => {
258
+ const appEmbed = new AppEmbed(getRootEl(), {
259
+ ...defaultViewConfig,
260
+ dataPanelV2: true,
261
+ } as AppViewConfig);
262
+
263
+ appEmbed.render();
264
+ await executeAfterWait(() => {
265
+ expectUrlMatchesWithParams(
266
+ getIFrameSrc(),
267
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&enableDataPanelV2=true${defaultParams}${defaultParamsPost}#/home`,
268
+ );
269
+ });
270
+ });
271
+
257
272
  test('should register event handlers to adjust iframe height', async () => {
258
273
  const onSpy = jest.spyOn(AppEmbed.prototype, 'on')
259
274
  .mockImplementation((event, callback) => {
package/src/embed/app.ts CHANGED
@@ -47,7 +47,7 @@ export enum Page {
47
47
  /**
48
48
  * SpotIQ listing page
49
49
  */
50
- SpotIQ = 'spotiq',
50
+ SpotIQ = 'insights',
51
51
  }
52
52
 
53
53
  /**
@@ -118,6 +118,14 @@ export interface AppViewConfig extends ViewConfig {
118
118
  * @version SDK: 1.21.0 | ThoughtSpot: 9.4.0.cl, 9.4.0-sw
119
119
  */
120
120
  fullHeight?:boolean;
121
+ /**
122
+ * Flag to control Data panel experience
123
+ *
124
+ * @default false
125
+ * @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl
126
+ * @hidden
127
+ */
128
+ dataPanelV2?: boolean;
121
129
  }
122
130
 
123
131
  /**
@@ -155,6 +163,7 @@ export class AppEmbed extends V1Embed {
155
163
  hideOrgSwitcher,
156
164
  enableSearchAssist,
157
165
  fullHeight,
166
+ dataPanelV2 = false,
158
167
  } = this.viewConfig;
159
168
 
160
169
  let params = {};
@@ -184,6 +193,7 @@ export class AppEmbed extends V1Embed {
184
193
  params[Param.EnableSearchAssist] = enableSearchAssist;
185
194
  }
186
195
 
196
+ params[Param.DataPanelV2Enabled] = dataPanelV2;
187
197
  const queryParams = getQueryParamString(params, true);
188
198
 
189
199
  return queryParams;
package/src/embed/base.ts CHANGED
@@ -256,6 +256,10 @@ export const renderInQueue = (fn: (next?: (val?: any) => void) => Promise<any>):
256
256
  return fn(() => { }); // eslint-disable-line @typescript-eslint/no-empty-function
257
257
  };
258
258
 
259
+ /**
260
+ * @param data
261
+ * @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
262
+ */
259
263
  export const executeTML = async (data: executeTMLInput): Promise<any> => {
260
264
  const { thoughtSpotHost, authType } = config;
261
265
  try {
@@ -299,6 +303,10 @@ export const executeTML = async (data: executeTMLInput): Promise<any> => {
299
303
  });
300
304
  };
301
305
 
306
+ /**
307
+ * @param data
308
+ * @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
309
+ */
302
310
  export const exportTML = async (data: exportTMLInput): Promise<any> => {
303
311
  const { thoughtSpotHost, authType } = config;
304
312
  try {
@@ -37,7 +37,39 @@ describe('Sage embed tests', () => {
37
37
  await executeAfterWait(() => {
38
38
  expectUrlMatch(
39
39
  getIFrameSrc(),
40
- `http://${thoughtSpotHost}/?embedApp=true&hideEurekaResults=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=true&hideEurekaSuggestions=true&hideAction=%5B"save","pin","editACopy","saveAsView","updateTSL","editTSL","onDeleteAnswer","share"%5D#/embed/eureka`,
40
+ `http://${thoughtSpotHost}/?embedApp=true&hideEurekaResults=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=true&hideEurekaSuggestions=true&hideAction=%5B"reportError","save","pin","editACopy","saveAsView","updateTSL","editTSL","onDeleteAnswer","share"%5D#/embed/eureka`,
41
+ );
42
+ });
43
+ });
44
+ test('embed url include pre-seed dataSource and query', async () => {
45
+ const sageEmbed = new SageEmbed(getRootEl(), {
46
+ ...defaultConfig,
47
+ dataSource: 'worksheet-id',
48
+ searchOptions: {
49
+ searchQuery: 'test-query',
50
+ },
51
+ });
52
+ sageEmbed.render();
53
+ await executeAfterWait(() => {
54
+ expectUrlMatch(
55
+ getIFrameSrc(),
56
+ `http://${thoughtSpotHost}/?embedApp=true&hideEurekaResults=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=true&hideEurekaSuggestions=true&hideAction=%5B"reportError","save","pin","editACopy","saveAsView","updateTSL","editTSL","onDeleteAnswer","share"%5D#/embed/eureka?worksheet=worksheet-id&query=test-query`,
57
+ );
58
+ });
59
+ });
60
+ test('embed url include pre-seed execute flag with query', async () => {
61
+ const sageEmbed = new SageEmbed(getRootEl(), {
62
+ ...defaultConfig,
63
+ searchOptions: {
64
+ searchQuery: 'test-query',
65
+ executeSearch: true,
66
+ },
67
+ });
68
+ sageEmbed.render();
69
+ await executeAfterWait(() => {
70
+ expectUrlMatch(
71
+ getIFrameSrc(),
72
+ `http://${thoughtSpotHost}/?embedApp=true&hideEurekaResults=false&isSageEmbed=true&disableWorksheetChange=false&hideWorksheetSelector=true&hideEurekaSuggestions=true&hideAction=%5B"reportError","save","pin","editACopy","saveAsView","updateTSL","editTSL","onDeleteAnswer","share"%5D#/embed/eureka?query=test-query&executeSearch=true`,
41
73
  );
42
74
  });
43
75
  });
package/src/embed/sage.ts CHANGED
@@ -13,15 +13,35 @@ import {
13
13
  import { getQueryParamString } from '../utils';
14
14
  import { V1Embed } from './ts-embed';
15
15
 
16
+ /**
17
+ * Configuration for search options
18
+ */
19
+ export interface SearchOptions {
20
+ /**
21
+ * The tml string to load the answer
22
+ */
23
+ searchQuery: string;
24
+ /**
25
+ * Boolean to determine if the search should be executed or not.
26
+ * if it is executed, put the focus on the results.
27
+ * if it’s not executed, put the focus in the search bar - at the end of
28
+ * the tokens
29
+ */
30
+ executeSearch?: boolean;
31
+ }
32
+
16
33
  /**
17
34
  * The configuration attributes for the embedded Natural language search view. Based on
18
35
  * GPT and LLM.
19
36
  *
37
+ * @version: SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl, 9.5.1-sw
20
38
  * @group Embed components
21
39
  */
22
40
  export interface SageViewConfig extends ViewConfig {
23
41
  /**
24
- * If set to true, object results are shown.
42
+ * If set to true, a list of liveboard and answers related
43
+ * to the natural language search will be shown below the
44
+ * AI generated answer.
25
45
  */
26
46
  showObjectResults?: boolean;
27
47
  /**
@@ -33,10 +53,29 @@ export interface SageViewConfig extends ViewConfig {
33
53
  */
34
54
  hideWorksheetSelector?: boolean,
35
55
  /**
36
- * If set to true, the object search suggestions are not shown
56
+ * If set to true, the search suggestions will contain existing
57
+ * liveboards and answers in addition with the autocomplete
37
58
  *
38
59
  */
39
60
  showObjectSuggestions?: boolean;
61
+ /**
62
+ * The query string to pre-fill in natual language search bar
63
+ */
64
+ searchQuery?: string;
65
+ /**
66
+ * If set to true, sample questions would be hidden to user.
67
+ * These sample questions are autogenerated based on selected datasource.
68
+ */
69
+ hideSampleQuestions?: boolean;
70
+ /**
71
+ * The data source GUID to set on load.
72
+ */
73
+ dataSource?: string;
74
+ /**
75
+ * Configuration for search options
76
+ */
77
+ searchOptions?: SearchOptions;
78
+
40
79
  }
41
80
  export const HiddenActionItemByDefaultForSageEmbed = [
42
81
  Action.Save,
@@ -78,15 +117,17 @@ export class SageEmbed extends V1Embed {
78
117
  disableWorksheetChange,
79
118
  hideWorksheetSelector,
80
119
  showObjectSuggestions,
120
+ hideSampleQuestions,
81
121
  } = this.viewConfig;
82
122
 
83
- const params = {};
123
+ const params = this.getBaseQueryParams();
84
124
  params[Param.EmbedApp] = true;
85
125
  params[Param.HideEurekaResults] = !showObjectResults;
86
126
  params[Param.IsSageEmbed] = true;
87
127
  params[Param.DisableWorksheetChange] = !!disableWorksheetChange;
88
128
  params[Param.HideWorksheetSelector] = !!hideWorksheetSelector;
89
129
  params[Param.HideEurekaSuggestions] = !showObjectSuggestions;
130
+ params[Param.HideSampleQuestions] = !!hideSampleQuestions;
90
131
  params[Param.HideActions] = [
91
132
  ...(params[Param.HideActions] ?? []),
92
133
  ...HiddenActionItemByDefaultForSageEmbed,
@@ -103,9 +144,23 @@ export class SageEmbed extends V1Embed {
103
144
  */
104
145
  private getIFrameSrc() {
105
146
  const path = 'eureka';
147
+ const postHashObj = {};
106
148
  const tsPostHashParams = this.getThoughtSpotPostUrlParams();
149
+ const {
150
+ dataSource, searchOptions,
151
+ } = this.viewConfig;
152
+
153
+ if (dataSource) postHashObj[Param.WorksheetId] = dataSource;
154
+ if (searchOptions?.searchQuery) {
155
+ postHashObj[Param.Query] = searchOptions?.searchQuery;
156
+ if (searchOptions.executeSearch) {
157
+ postHashObj[Param.executeSearch] = true;
158
+ }
159
+ }
160
+ let sagePostHashParams = new URLSearchParams(postHashObj).toString();
161
+ if (sagePostHashParams) sagePostHashParams = `${tsPostHashParams ? '&' : '?'}${sagePostHashParams}`;
107
162
 
108
- return `${this.getRootIframeSrc()}/embed/${path}${tsPostHashParams}`;
163
+ return `${this.getRootIframeSrc()}/embed/${path}${tsPostHashParams}${sagePostHashParams}`;
109
164
  }
110
165
 
111
166
  /**
@@ -8,7 +8,7 @@ import { SearchOptions } from './search';
8
8
  /**
9
9
  * @group Embed components
10
10
  */
11
- export interface SearchBarViewConfig extends Omit<ViewConfig, 'runtimeFilters' | 'showAlerts'> {
11
+ export interface SearchBarViewConfig extends Omit<ViewConfig, 'runtimeFilters' | 'showAlerts' | 'dataPanelV2'> {
12
12
  /**
13
13
  * The array of data source GUIDs to set on load.
14
14
  * Only a single dataSource supported currently.
@@ -47,7 +47,7 @@ describe('Search embed tests', () => {
47
47
  await executeAfterWait(() => {
48
48
  expectUrlMatchesWithParams(
49
49
  getIFrameSrc(),
50
- `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
50
+ `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&enableDataPanelV2=false&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
51
51
  );
52
52
  });
53
53
  });
@@ -336,4 +336,18 @@ describe('Search embed tests', () => {
336
336
  );
337
337
  });
338
338
  });
339
+
340
+ test('should set enableDataPanelV2 to true if data panel v2 flag is true', async () => {
341
+ const searchEmbed = new SearchEmbed(getRootEl(), {
342
+ ...defaultViewConfig,
343
+ dataPanelV2: true,
344
+ });
345
+ searchEmbed.render();
346
+ await executeAfterWait(() => {
347
+ expectUrlMatchesWithParams(
348
+ getIFrameSrc(),
349
+ `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=true&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
350
+ );
351
+ });
352
+ });
339
353
  });
@@ -109,6 +109,14 @@ export interface SearchViewConfig extends ViewConfig {
109
109
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
110
110
  */
111
111
  hideSearchBar?: boolean;
112
+ /**
113
+ * Flag to control Data panel experience
114
+ *
115
+ * @default false
116
+ * @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl
117
+ * @hidden
118
+ */
119
+ dataPanelV2?: boolean;
112
120
  }
113
121
 
114
122
  export const HiddenActionItemByDefaultForSearchEmbed = [
@@ -162,6 +170,7 @@ export class SearchEmbed extends TsEmbed {
162
170
  dataSource,
163
171
  dataSources,
164
172
  excludeRuntimeFiltersfromURL,
173
+ dataPanelV2 = false,
165
174
  } = this.viewConfig;
166
175
  const queryParams = this.getBaseQueryParams();
167
176
 
@@ -195,6 +204,7 @@ export class SearchEmbed extends TsEmbed {
195
204
  queryParams[Param.ForceTable] = true;
196
205
  }
197
206
 
207
+ queryParams[Param.DataPanelV2Enabled] = dataPanelV2;
198
208
  queryParams[Param.DataSourceMode] = this.getDataSourceMode();
199
209
  queryParams[Param.UseLastSelectedDataSource] = false;
200
210
  queryParams[Param.searchEmbed] = true;
@@ -47,7 +47,7 @@ describe('React Components', () => {
47
47
  ),
48
48
  ).toBe(true);
49
49
  expect(getIFrameSrc(container)).toBe(
50
- `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true#/embed/answer`,
50
+ `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&enableDataPanelV2=false&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true#/embed/answer`,
51
51
  );
52
52
  });
53
53