@thoughtspot/visual-embed-sdk 1.24.0-sage.3 → 1.24.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.
Files changed (183) hide show
  1. package/README.md +1 -1
  2. package/cjs/package.json +9 -1
  3. package/cjs/src/auth.d.ts.map +1 -1
  4. package/cjs/src/auth.js +3 -0
  5. package/cjs/src/auth.js.map +1 -1
  6. package/cjs/src/css-variables.d.ts +38 -0
  7. package/cjs/src/css-variables.d.ts.map +1 -1
  8. package/cjs/src/embed/app.d.ts +32 -1
  9. package/cjs/src/embed/app.d.ts.map +1 -1
  10. package/cjs/src/embed/app.js +11 -8
  11. package/cjs/src/embed/app.js.map +1 -1
  12. package/cjs/src/embed/app.spec.js +46 -0
  13. package/cjs/src/embed/app.spec.js.map +1 -1
  14. package/cjs/src/embed/base.d.ts +4 -1
  15. package/cjs/src/embed/base.d.ts.map +1 -1
  16. package/cjs/src/embed/base.js +6 -3
  17. package/cjs/src/embed/base.js.map +1 -1
  18. package/cjs/src/embed/liveboard.d.ts +5 -1
  19. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  20. package/cjs/src/embed/liveboard.js +5 -2
  21. package/cjs/src/embed/liveboard.js.map +1 -1
  22. package/cjs/src/embed/liveboard.spec.js +23 -7
  23. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  24. package/cjs/src/embed/search-bar.d.ts +6 -0
  25. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  26. package/cjs/src/embed/search-bar.js +5 -2
  27. package/cjs/src/embed/search-bar.js.map +1 -1
  28. package/cjs/src/embed/search.d.ts +15 -2
  29. package/cjs/src/embed/search.d.ts.map +1 -1
  30. package/cjs/src/embed/search.js +8 -2
  31. package/cjs/src/embed/search.js.map +1 -1
  32. package/cjs/src/embed/search.spec.js +49 -0
  33. package/cjs/src/embed/search.spec.js.map +1 -1
  34. package/cjs/src/embed/ts-embed.d.ts +3 -1
  35. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  36. package/cjs/src/embed/ts-embed.js +28 -8
  37. package/cjs/src/embed/ts-embed.js.map +1 -1
  38. package/cjs/src/embed/ts-embed.spec.js +139 -3
  39. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  40. package/cjs/src/index.d.ts +2 -2
  41. package/cjs/src/index.d.ts.map +1 -1
  42. package/cjs/src/index.js +3 -1
  43. package/cjs/src/index.js.map +1 -1
  44. package/cjs/src/mixpanel-service.d.ts +1 -0
  45. package/cjs/src/mixpanel-service.d.ts.map +1 -1
  46. package/cjs/src/mixpanel-service.js +10 -3
  47. package/cjs/src/mixpanel-service.js.map +1 -1
  48. package/cjs/src/mixpanel-service.spec.js +12 -3
  49. package/cjs/src/mixpanel-service.spec.js.map +1 -1
  50. package/cjs/src/react/index.d.ts +15 -15
  51. package/cjs/src/react/index.d.ts.map +1 -1
  52. package/cjs/src/react/index.js +7 -3
  53. package/cjs/src/react/index.js.map +1 -1
  54. package/cjs/src/react/index.spec.js +12 -0
  55. package/cjs/src/react/index.spec.js.map +1 -1
  56. package/cjs/src/types.d.ts +176 -9
  57. package/cjs/src/types.d.ts.map +1 -1
  58. package/cjs/src/types.js +133 -7
  59. package/cjs/src/types.js.map +1 -1
  60. package/cjs/src/utils.d.ts +7 -1
  61. package/cjs/src/utils.d.ts.map +1 -1
  62. package/cjs/src/utils.js +20 -1
  63. package/cjs/src/utils.js.map +1 -1
  64. package/cjs/src/utils.spec.js +24 -0
  65. package/cjs/src/utils.spec.js.map +1 -1
  66. package/dist/src/auth.d.ts.map +1 -1
  67. package/dist/src/css-variables.d.ts +38 -0
  68. package/dist/src/css-variables.d.ts.map +1 -1
  69. package/dist/src/embed/app.d.ts +32 -1
  70. package/dist/src/embed/app.d.ts.map +1 -1
  71. package/dist/src/embed/base.d.ts +4 -1
  72. package/dist/src/embed/base.d.ts.map +1 -1
  73. package/dist/src/embed/liveboard.d.ts +5 -1
  74. package/dist/src/embed/liveboard.d.ts.map +1 -1
  75. package/dist/src/embed/search-bar.d.ts +6 -0
  76. package/dist/src/embed/search-bar.d.ts.map +1 -1
  77. package/dist/src/embed/search.d.ts +15 -2
  78. package/dist/src/embed/search.d.ts.map +1 -1
  79. package/dist/src/embed/ts-embed.d.ts +3 -1
  80. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  81. package/dist/src/index.d.ts +2 -2
  82. package/dist/src/index.d.ts.map +1 -1
  83. package/dist/src/mixpanel-service.d.ts +1 -0
  84. package/dist/src/mixpanel-service.d.ts.map +1 -1
  85. package/dist/src/react/index.d.ts +15 -15
  86. package/dist/src/react/index.d.ts.map +1 -1
  87. package/dist/src/types.d.ts +176 -9
  88. package/dist/src/types.d.ts.map +1 -1
  89. package/dist/src/utils.d.ts +7 -1
  90. package/dist/src/utils.d.ts.map +1 -1
  91. package/dist/tsembed-react.es.js +226 -35
  92. package/dist/tsembed-react.js +219 -34
  93. package/dist/tsembed.es.js +228 -36
  94. package/dist/tsembed.js +221 -35
  95. package/dist/visual-embed-sdk-react-full.d.ts +512 -248
  96. package/dist/visual-embed-sdk-react.d.ts +514 -250
  97. package/dist/visual-embed-sdk.d.ts +277 -14
  98. package/lib/package.json +9 -1
  99. package/lib/src/auth.d.ts.map +1 -1
  100. package/lib/src/auth.js +3 -0
  101. package/lib/src/auth.js.map +1 -1
  102. package/lib/src/css-variables.d.ts +38 -0
  103. package/lib/src/css-variables.d.ts.map +1 -1
  104. package/lib/src/embed/app.d.ts +32 -1
  105. package/lib/src/embed/app.d.ts.map +1 -1
  106. package/lib/src/embed/app.js +11 -8
  107. package/lib/src/embed/app.js.map +1 -1
  108. package/lib/src/embed/app.spec.js +46 -0
  109. package/lib/src/embed/app.spec.js.map +1 -1
  110. package/lib/src/embed/base.d.ts +4 -1
  111. package/lib/src/embed/base.d.ts.map +1 -1
  112. package/lib/src/embed/base.js +6 -3
  113. package/lib/src/embed/base.js.map +1 -1
  114. package/lib/src/embed/liveboard.d.ts +5 -1
  115. package/lib/src/embed/liveboard.d.ts.map +1 -1
  116. package/lib/src/embed/liveboard.js +6 -3
  117. package/lib/src/embed/liveboard.js.map +1 -1
  118. package/lib/src/embed/liveboard.spec.js +23 -7
  119. package/lib/src/embed/liveboard.spec.js.map +1 -1
  120. package/lib/src/embed/search-bar.d.ts +6 -0
  121. package/lib/src/embed/search-bar.d.ts.map +1 -1
  122. package/lib/src/embed/search-bar.js +6 -3
  123. package/lib/src/embed/search-bar.js.map +1 -1
  124. package/lib/src/embed/search.d.ts +15 -2
  125. package/lib/src/embed/search.d.ts.map +1 -1
  126. package/lib/src/embed/search.js +9 -3
  127. package/lib/src/embed/search.js.map +1 -1
  128. package/lib/src/embed/search.spec.js +49 -0
  129. package/lib/src/embed/search.spec.js.map +1 -1
  130. package/lib/src/embed/ts-embed.d.ts +3 -1
  131. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  132. package/lib/src/embed/ts-embed.js +29 -9
  133. package/lib/src/embed/ts-embed.js.map +1 -1
  134. package/lib/src/embed/ts-embed.spec.js +140 -4
  135. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  136. package/lib/src/index.d.ts +2 -2
  137. package/lib/src/index.d.ts.map +1 -1
  138. package/lib/src/index.js +2 -2
  139. package/lib/src/index.js.map +1 -1
  140. package/lib/src/mixpanel-service.d.ts +1 -0
  141. package/lib/src/mixpanel-service.d.ts.map +1 -1
  142. package/lib/src/mixpanel-service.js +10 -3
  143. package/lib/src/mixpanel-service.js.map +1 -1
  144. package/lib/src/mixpanel-service.spec.js +12 -3
  145. package/lib/src/mixpanel-service.spec.js.map +1 -1
  146. package/lib/src/react/index.d.ts +15 -15
  147. package/lib/src/react/index.d.ts.map +1 -1
  148. package/lib/src/react/index.js +5 -3
  149. package/lib/src/react/index.js.map +1 -1
  150. package/lib/src/react/index.spec.js +13 -1
  151. package/lib/src/react/index.spec.js.map +1 -1
  152. package/lib/src/types.d.ts +176 -9
  153. package/lib/src/types.d.ts.map +1 -1
  154. package/lib/src/types.js +132 -6
  155. package/lib/src/types.js.map +1 -1
  156. package/lib/src/utils.d.ts +7 -1
  157. package/lib/src/utils.d.ts.map +1 -1
  158. package/lib/src/utils.js +18 -0
  159. package/lib/src/utils.js.map +1 -1
  160. package/lib/src/utils.spec.js +25 -1
  161. package/lib/src/utils.spec.js.map +1 -1
  162. package/lib/src/visual-embed-sdk.d.ts +280 -17
  163. package/package.json +9 -1
  164. package/src/auth.ts +6 -3
  165. package/src/css-variables.ts +47 -0
  166. package/src/embed/app.spec.ts +63 -0
  167. package/src/embed/app.ts +50 -15
  168. package/src/embed/base.ts +9 -6
  169. package/src/embed/liveboard.spec.ts +29 -10
  170. package/src/embed/liveboard.ts +11 -2
  171. package/src/embed/search-bar.tsx +19 -6
  172. package/src/embed/search.spec.ts +61 -0
  173. package/src/embed/search.ts +34 -3
  174. package/src/embed/ts-embed.spec.ts +162 -8
  175. package/src/embed/ts-embed.ts +30 -9
  176. package/src/index.ts +4 -0
  177. package/src/mixpanel-service.spec.ts +12 -3
  178. package/src/mixpanel-service.ts +10 -3
  179. package/src/react/index.spec.tsx +33 -2
  180. package/src/react/index.tsx +37 -26
  181. package/src/types.ts +263 -92
  182. package/src/utils.spec.ts +31 -0
  183. package/src/utils.ts +23 -0
@@ -144,6 +144,39 @@ describe('App embed tests', () => {
144
144
  });
145
145
  });
146
146
  }
147
+
148
+ const pageRouteMapForModularHome = {
149
+ [Page.Search]: 'answer',
150
+ [Page.Answers]: 'home/answers',
151
+ [Page.Pinboards]: 'home/liveboards',
152
+ [Page.Liveboards]: 'home/liveboards',
153
+ [Page.Data]: 'data/tables',
154
+ [Page.Home]: 'home',
155
+ [Page.SpotIQ]: 'home/spotiq-analysis',
156
+ };
157
+
158
+ const pageIdsForModularHomes = Object.keys(pageRouteMapForModularHome);
159
+ for (let i = 0; i < pageIdsForModularHomes.length; i++) {
160
+ const pageIdsForModularHome = pageIdsForModularHomes[i];
161
+
162
+ test(`${pageIdsForModularHome}`, async () => {
163
+ const route = pageRouteMap[pageIdsForModularHome];
164
+ const appEmbed = new AppEmbed(getRootEl(), {
165
+ ...defaultViewConfig,
166
+ modularHomeExperience: true,
167
+ pageId: pageIdsForModularHome as Page,
168
+ } as AppViewConfig);
169
+ appEmbed.render();
170
+
171
+ await executeAfterWait(() => {
172
+ expectUrlMatchesWithParams(
173
+ getIFrameSrc(),
174
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/${route}`,
175
+ );
176
+ cleanUp();
177
+ });
178
+ });
179
+ }
147
180
  });
148
181
 
149
182
  test('should navigate to a path', async () => {
@@ -269,6 +302,36 @@ describe('App embed tests', () => {
269
302
  });
270
303
  });
271
304
 
305
+ test('Should add modularHomeExperience flag to the iframe src', async () => {
306
+ const appEmbed = new AppEmbed(getRootEl(), {
307
+ ...defaultViewConfig,
308
+ modularHomeExperience: true,
309
+ } as AppViewConfig);
310
+
311
+ appEmbed.render();
312
+ await executeAfterWait(() => {
313
+ expectUrlMatchesWithParams(
314
+ getIFrameSrc(),
315
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=true${defaultParams}${defaultParamsPost}#/home`,
316
+ );
317
+ });
318
+ });
319
+
320
+ test('Should add hideHomepageLeftNav flag to the iframe src', async () => {
321
+ const appEmbed = new AppEmbed(getRootEl(), {
322
+ ...defaultViewConfig,
323
+ hideHomepageLeftNav: false,
324
+ } as AppViewConfig);
325
+
326
+ appEmbed.render();
327
+ await executeAfterWait(() => {
328
+ expectUrlMatchesWithParams(
329
+ getIFrameSrc(),
330
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&hideHomepageLeftNav=false${defaultParams}${defaultParamsPost}#/home`,
331
+ );
332
+ });
333
+ });
334
+
272
335
  test('should register event handlers to adjust iframe height', async () => {
273
336
  const onSpy = jest.spyOn(AppEmbed.prototype, 'on')
274
337
  .mockImplementation((event, callback) => {
package/src/embed/app.ts CHANGED
@@ -59,8 +59,19 @@ export interface AppViewConfig extends ViewConfig {
59
59
  /**
60
60
  * If true, the main navigation bar within the ThoughtSpot app
61
61
  * is displayed. By default, the navigation bar is hidden.
62
+ * This flag also control the homepage left nav-bar.
62
63
  */
63
64
  showPrimaryNavbar?: boolean;
65
+ /**
66
+ * Flag to control Homepage Left Nav Bar
67
+ * If showPrimaryNavbar is true, ie navigation bar(Global nav-bar) and Homepage left
68
+ * nav-bar is visible, this flag will only hide the homepage left nav.
69
+ * Precedence of showPrimaryNavbar flag > hideHomepageLeftNav flag.
70
+ *
71
+ * @default false
72
+ * @version SDK: 1.27.0 | Thoughtspot: 9.8.0.cl
73
+ */
74
+ hideHomepageLeftNav?: boolean;
64
75
  /**
65
76
  * If true, help and profile buttons will hide on NavBar. By default,
66
77
  * they are shown.
@@ -79,12 +90,24 @@ export interface AppViewConfig extends ViewConfig {
79
90
  /**
80
91
  * A URL path within the app that is to be embedded.
81
92
  * If both path and pageId attributes are defined, the path definition
82
- * takes precedence.
93
+ * takes precedence. This is the path post the `#/` in the URL of the standalone
94
+ * ThoughtSpot app. Use this to open the embedded view to a specific path.
95
+ *
96
+ * For eg, if you want the component to open to a specific liveboard
97
+ * you could set the path to `pinboard/<liveboardId>/tab/<tabId>`.
98
+ *
99
+ * @example
100
+ * ```
101
+ * <AppEmbed path="pinboard/1234/tab/7464" />
102
+ * ```
83
103
  */
84
104
  path?: string;
85
105
  /**
86
106
  * The application page to set as the start page
87
107
  * in the embedded view.
108
+ *
109
+ * Use this to open to particular page in the app. To open to a specific
110
+ * path within the app, use the `path` attribute which is more flexible.
88
111
  */
89
112
  pageId?: Page;
90
113
  /**
@@ -111,13 +134,13 @@ export interface AppViewConfig extends ViewConfig {
111
134
  * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
112
135
  */
113
136
  enableSearchAssist?: boolean;
114
- /**
115
- * If set to true, the embedded object container dynamically resizes
116
- * according to the height of the pages which support fullHeight mode.
117
- *
118
- * @version SDK: 1.21.0 | ThoughtSpot: 9.4.0.cl, 9.4.0-sw
119
- */
120
- fullHeight?:boolean;
137
+ /**
138
+ * If set to true, the embedded object container dynamically resizes
139
+ * according to the height of the pages which support fullHeight mode.
140
+ *
141
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.4.0.cl, 9.4.0-sw
142
+ */
143
+ fullHeight?: boolean;
121
144
  /**
122
145
  * Flag to control Data panel experience
123
146
  *
@@ -126,6 +149,13 @@ export interface AppViewConfig extends ViewConfig {
126
149
  * @hidden
127
150
  */
128
151
  dataPanelV2?: boolean;
152
+ /**
153
+ * Flag to control new Modular Home experience
154
+ *
155
+ * @default false
156
+ * @version SDK: 1.27.0 | Thoughtspot: 9.8.0.cl
157
+ */
158
+ modularHomeExperience?: boolean;
129
159
  }
130
160
 
131
161
  /**
@@ -164,6 +194,8 @@ export class AppEmbed extends V1Embed {
164
194
  enableSearchAssist,
165
195
  fullHeight,
166
196
  dataPanelV2 = false,
197
+ hideHomepageLeftNav = false,
198
+ modularHomeExperience = false,
167
199
  } = this.viewConfig;
168
200
 
169
201
  let params = {};
@@ -194,6 +226,8 @@ export class AppEmbed extends V1Embed {
194
226
  }
195
227
 
196
228
  params[Param.DataPanelV2Enabled] = dataPanelV2;
229
+ params[Param.HideHomepageLeftNav] = hideHomepageLeftNav;
230
+ params[Param.ModularHomeExperienceEnabled] = modularHomeExperience;
197
231
  const queryParams = getQueryParamString(params, true);
198
232
 
199
233
  return queryParams;
@@ -205,8 +239,8 @@ export class AppEmbed extends V1Embed {
205
239
  * @param pageId The ID of the page to be embedded.
206
240
  */
207
241
  private getIFrameSrc() {
208
- const { pageId, path } = this.viewConfig;
209
- const pageRoute = this.formatPath(path) || this.getPageRoute(pageId);
242
+ const { pageId, path, modularHomeExperience } = this.viewConfig;
243
+ const pageRoute = this.formatPath(path) || this.getPageRoute(pageId, modularHomeExperience);
210
244
  let url = `${this.getRootIframeSrc()}/${pageRoute}`;
211
245
 
212
246
  const tsPostHashParams = this.getThoughtSpotPostUrlParams();
@@ -243,21 +277,22 @@ export class AppEmbed extends V1Embed {
243
277
  * Gets the ThoughtSpot route of the page for a particular page ID.
244
278
  *
245
279
  * @param pageId The identifier for a page in the ThoughtSpot app.
280
+ * @param modularHomeExperience
246
281
  */
247
- private getPageRoute(pageId: Page) {
282
+ private getPageRoute(pageId: Page, modularHomeExperience = false) {
248
283
  switch (pageId) {
249
284
  case Page.Search:
250
285
  return 'answer';
251
286
  case Page.Answers:
252
- return 'answers';
287
+ return modularHomeExperience ? 'home/answers' : 'answers';
253
288
  case Page.Liveboards:
254
- return 'pinboards';
289
+ return modularHomeExperience ? 'home/liveboards' : 'pinboards';
255
290
  case Page.Pinboards:
256
- return 'pinboards';
291
+ return modularHomeExperience ? 'home/liveboards' : 'pinboards';
257
292
  case Page.Data:
258
293
  return 'data/tables';
259
294
  case Page.SpotIQ:
260
- return 'insights/results';
295
+ return modularHomeExperience ? 'home/spotiq-analysis' : 'insights/results';
261
296
  case Page.Home:
262
297
  default:
263
298
  return 'home';
package/src/embed/base.ts CHANGED
@@ -44,13 +44,13 @@ export interface executeTMLInput {
44
44
 
45
45
  export interface exportTMLInput {
46
46
  metadata: {
47
- identifier: string;
48
- type?: 'LIVEBOARD' | 'ANSWER' | 'LOGICAL_TABLE' | 'CONNECTION';
47
+ identifier: string;
48
+ type?: 'LIVEBOARD' | 'ANSWER' | 'LOGICAL_TABLE' | 'CONNECTION';
49
49
  }[];
50
50
  export_associated?: boolean;
51
51
  export_fqn?: boolean;
52
52
  edoc_format?: 'YAML' | 'JSON';
53
- }
53
+ }
54
54
 
55
55
  export let authPromise: Promise<boolean>;
56
56
  /**
@@ -192,9 +192,9 @@ export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
192
192
  setAuthEE(authEE);
193
193
  handleAuth();
194
194
 
195
+ const { password, ...configToTrack } = config;
195
196
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
196
- authType: config.authType,
197
- host: config.thoughtSpotHost,
197
+ ...configToTrack,
198
198
  usedCustomizationSheet: embedConfig.customizations?.style?.customCSSUrl != null,
199
199
  usedCustomizationVariables: embedConfig.customizations?.style?.customCSS?.variables != null,
200
200
  usedCustomizationRules:
@@ -258,6 +258,7 @@ export const renderInQueue = (fn: (next?: (val?: any) => void) => Promise<any>):
258
258
 
259
259
  /**
260
260
  * Imports TML representation of the metadata objects into ThoughtSpot.
261
+ *
261
262
  * @param data
262
263
  * @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
263
264
  */
@@ -305,7 +306,9 @@ export const executeTML = async (data: executeTMLInput): Promise<any> => {
305
306
  };
306
307
 
307
308
  /**
308
- * Exports TML representation of the metadata objects from ThoughtSpot in JSON or YAML format.
309
+ * Exports TML representation of the metadata objects from ThoughtSpot in JSON or YAML
310
+ * format.
311
+ *
309
312
  * @param data
310
313
  * @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
311
314
  */
@@ -337,22 +337,22 @@ describe('Liveboard/viz embed tests', () => {
337
337
  done();
338
338
  });
339
339
  });
340
-
341
- test('SetActiveTab Hostevent trigger the navigate event with the correct path, not vizEmbed', async () => {
342
- const mockProcessTrigger = jest.spyOn(tsEmbed.TsEmbed.prototype, 'trigger');
340
+ test('should set runtime parametere values in url params', async () => {
343
341
  const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
344
- enableVizTransformations: true,
345
342
  ...defaultViewConfig,
346
343
  liveboardId,
344
+ runtimeParameters: [
345
+ {
346
+ name: 'Integer Date Range',
347
+ value: 1,
348
+ },
349
+ ],
347
350
  } as LiveboardViewConfig);
348
351
  liveboardEmbed.render();
349
352
  await executeAfterWait(() => {
350
- const result = liveboardEmbed.trigger(HostEvent.SetActiveTab, {
351
- tabId: newActiveTabId,
352
- });
353
- expect(mockProcessTrigger).toHaveBeenCalledWith(
354
- HostEvent.Navigate,
355
- `embed/viz/${liveboardId}/tab/${newActiveTabId}`,
353
+ expectUrlMatchesWithParams(
354
+ getIFrameSrc(),
355
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}${prefixParams}&param1=Integer%20Date%20Range&paramVal1=1#/embed/viz/${liveboardId}`,
356
356
  );
357
357
  });
358
358
  });
@@ -373,4 +373,23 @@ describe('Liveboard/viz embed tests', () => {
373
373
  expect(mockProcessTrigger).not.toBeCalled();
374
374
  });
375
375
  });
376
+
377
+ test('SetActiveTab Hostevent trigger the navigate event with the correct path, not vizEmbed', async () => {
378
+ const mockProcessTrigger = jest.spyOn(tsEmbed.TsEmbed.prototype, 'trigger');
379
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
380
+ enableVizTransformations: true,
381
+ ...defaultViewConfig,
382
+ liveboardId,
383
+ } as LiveboardViewConfig);
384
+ liveboardEmbed.render();
385
+ await executeAfterWait(() => {
386
+ const result = liveboardEmbed.trigger(HostEvent.SetActiveTab, {
387
+ tabId: newActiveTabId,
388
+ });
389
+ expect(mockProcessTrigger).toHaveBeenCalledWith(
390
+ HostEvent.Navigate,
391
+ `embed/viz/${liveboardId}/tab/${newActiveTabId}`,
392
+ );
393
+ });
394
+ });
376
395
  });
@@ -15,11 +15,12 @@ import {
15
15
  MessagePayload,
16
16
  Param,
17
17
  RuntimeFilter,
18
+ RuntimeParameter,
18
19
  DOMSelector,
19
20
  HostEvent,
20
21
  ViewConfig,
21
22
  } from '../types';
22
- import { getQueryParamString } from '../utils';
23
+ import { getQueryParamString, getRuntimeParameters } from '../utils';
23
24
  import { getAuthPromise } from './base';
24
25
  import { V1Embed } from './ts-embed';
25
26
 
@@ -105,6 +106,10 @@ export interface LiveboardViewConfig extends ViewConfig {
105
106
  * @version SDK: 1.25.0 | Thoughtspot: 9.6.0.cl
106
107
  */
107
108
  hideTabPanel?: boolean;
109
+ /**
110
+ * The list of parameter override to apply to a Liveboard.
111
+ */
112
+ runtimeParameters?: RuntimeParameter[];
108
113
  }
109
114
 
110
115
  /**
@@ -154,6 +159,7 @@ export class LiveboardEmbed extends V1Embed {
154
159
  vizId,
155
160
  hideTabPanel,
156
161
  activeTabId,
162
+ runtimeParameters,
157
163
  } = this.viewConfig;
158
164
 
159
165
  const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval
@@ -184,7 +190,10 @@ export class LiveboardEmbed extends V1Embed {
184
190
  if (hideTabPanel) {
185
191
  params[Param.HideTabPanel] = hideTabPanel;
186
192
  }
187
- const queryParams = getQueryParamString(params, true);
193
+ let queryParams = getQueryParamString(params, true);
194
+
195
+ const parameterQuery = getRuntimeParameters(runtimeParameters || []);
196
+ if (parameterQuery) queryParams += `&${parameterQuery}`;
188
197
 
189
198
  return queryParams;
190
199
  }
@@ -1,6 +1,4 @@
1
- import {
2
- DOMSelector, Param, Action, ViewConfig,
3
- } from '../types';
1
+ import { Param, ViewConfig } from '../types';
4
2
  import { getQueryParamString } from '../utils';
5
3
  import { TsEmbed } from './ts-embed';
6
4
  import { SearchOptions } from './search';
@@ -8,7 +6,8 @@ import { SearchOptions } from './search';
8
6
  /**
9
7
  * @group Embed components
10
8
  */
11
- export interface SearchBarViewConfig extends Omit<ViewConfig, 'runtimeFilters' | 'showAlerts' | 'dataPanelV2'> {
9
+ export interface SearchBarViewConfig
10
+ extends Omit<ViewConfig, 'runtimeFilters' | 'showAlerts' | 'dataPanelV2'> {
12
11
  /**
13
12
  * The array of data source GUIDs to set on load.
14
13
  * Only a single dataSource supported currently.
@@ -22,6 +21,12 @@ export interface SearchBarViewConfig extends Omit<ViewConfig, 'runtimeFilters' |
22
21
  * @version: SDK: 1.19.0
23
22
  */
24
23
  dataSource?: string;
24
+ /**
25
+ * Flag to set if last selected dataSource should be used
26
+ *
27
+ * @version: SDK: 1.24.0
28
+ */
29
+ useLastSelectedSources?: boolean;
25
30
  /**
26
31
  * Configuration for search options
27
32
  */
@@ -52,7 +57,12 @@ export class SearchBarEmbed extends TsEmbed {
52
57
  * @param dataSources A list of data source GUIDs
53
58
  */
54
59
  private getIFrameSrc() {
55
- const { searchOptions, dataSource, dataSources } = this.viewConfig;
60
+ const {
61
+ searchOptions,
62
+ dataSource,
63
+ dataSources,
64
+ useLastSelectedSources = false,
65
+ } = this.viewConfig;
56
66
  const path = 'search-bar-embed';
57
67
  const queryParams = this.getBaseQueryParams();
58
68
 
@@ -74,7 +84,10 @@ export class SearchBarEmbed extends TsEmbed {
74
84
  }
75
85
  }
76
86
 
77
- queryParams[Param.UseLastSelectedDataSource] = false;
87
+ queryParams[Param.UseLastSelectedDataSource] = useLastSelectedSources;
88
+ if (dataSource || dataSources) {
89
+ queryParams[Param.UseLastSelectedDataSource] = false;
90
+ }
78
91
  queryParams[Param.searchEmbed] = true;
79
92
  let query = '';
80
93
  const queryParamsString = getQueryParamString(queryParams, true);
@@ -350,4 +350,65 @@ describe('Search embed tests', () => {
350
350
  );
351
351
  });
352
352
  });
353
+ test('should set useLastSelectedSources to true if useLastSelectedSources flag is true', async () => {
354
+ const searchEmbed = new SearchEmbed(getRootEl(), {
355
+ ...defaultViewConfig,
356
+ useLastSelectedSources: true,
357
+ });
358
+ searchEmbed.render();
359
+ await executeAfterWait(() => {
360
+ expectUrlMatchesWithParams(
361
+ getIFrameSrc(),
362
+ `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&enableDataPanelV2=false&useLastSelectedSources=true${prefixParams}#/embed/saved-answer/${answerId}`,
363
+ );
364
+ });
365
+ });
366
+ test('should set useLastSelectedSources to false if datasource is given irrespective of useLastSelectedSources', async () => {
367
+ const dataSource = 'data-source-1';
368
+ const searchEmbed = new SearchEmbed(getRootEl(), {
369
+ ...defaultViewConfig,
370
+ useLastSelectedSources: true,
371
+ dataSource,
372
+ });
373
+ searchEmbed.render();
374
+ await executeAfterWait(() => {
375
+ expectUrlMatchesWithParams(
376
+ getIFrameSrc(),
377
+ `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&enableDataPanelV2=false&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
378
+ );
379
+ });
380
+ });
381
+ test('should set useLastSelectedSources to false if datasources are given irrespective of useLastSelectedSources', async () => {
382
+ const dataSources = ['data-source-1'];
383
+ const searchEmbed = new SearchEmbed(getRootEl(), {
384
+ ...defaultViewConfig,
385
+ useLastSelectedSources: true,
386
+ dataSources,
387
+ });
388
+ searchEmbed.render();
389
+ await executeAfterWait(() => {
390
+ expectUrlMatchesWithParams(
391
+ getIFrameSrc(),
392
+ `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&enableDataPanelV2=false&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
393
+ );
394
+ });
395
+ });
396
+ test('should set runtime parametere values in url params', async () => {
397
+ const searchEmbed = new SearchEmbed(getRootEl(), {
398
+ ...defaultViewConfig,
399
+ runtimeParameters: [
400
+ {
401
+ name: 'Integer Date Range',
402
+ value: 1,
403
+ },
404
+ ],
405
+ });
406
+ searchEmbed.render();
407
+ await executeAfterWait(() => {
408
+ expectUrlMatchesWithParams(
409
+ getIFrameSrc(),
410
+ `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}&param1=Integer%20Date%20Range&paramVal1=1#/embed/saved-answer/${answerId}`,
411
+ );
412
+ });
413
+ });
353
414
  });
@@ -14,8 +14,14 @@ import {
14
14
  Action,
15
15
  ViewConfig,
16
16
  RuntimeFilter,
17
+ RuntimeParameter,
17
18
  } from '../types';
18
- import { getQueryParamString, checkReleaseVersionInBeta, getFilterQuery } from '../utils';
19
+ import {
20
+ getQueryParamString,
21
+ checkReleaseVersionInBeta,
22
+ getFilterQuery,
23
+ getRuntimeParameters,
24
+ } from '../utils';
19
25
  import { TsEmbed } from './ts-embed';
20
26
  import { version } from '../../package.json';
21
27
  import { ERROR_MESSAGE } from '../errors';
@@ -60,6 +66,10 @@ export interface SearchViewConfig extends ViewConfig {
60
66
  * using raw answer data.
61
67
  */
62
68
  hideResults?: boolean;
69
+ /**
70
+ * If set to true, expands all the data sources panel.
71
+ */
72
+ expandAllDataSource?: boolean;
63
73
  /**
64
74
  * If set to true, the Search Assist feature is enabled.
65
75
  *
@@ -110,9 +120,18 @@ export interface SearchViewConfig extends ViewConfig {
110
120
  *
111
121
  * @default false
112
122
  * @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl
113
- * @hidden
114
123
  */
115
124
  dataPanelV2?: boolean;
125
+ /**
126
+ * Flag to set if last selected dataSource should be used
127
+ *
128
+ * @version: SDK: 1.24.0
129
+ */
130
+ useLastSelectedSources?: boolean;
131
+ /**
132
+ * The list of parameter override to apply to a search answer.
133
+ */
134
+ runtimeParameters?: RuntimeParameter[];
116
135
  }
117
136
 
118
137
  export const HiddenActionItemByDefaultForSearchEmbed = [
@@ -158,6 +177,7 @@ export class SearchEmbed extends TsEmbed {
158
177
  protected getEmbedParams(): string {
159
178
  const {
160
179
  hideResults,
180
+ expandAllDataSource,
161
181
  enableSearchAssist,
162
182
  forceTable,
163
183
  searchOptions,
@@ -166,6 +186,8 @@ export class SearchEmbed extends TsEmbed {
166
186
  dataSources,
167
187
  excludeRuntimeFiltersfromURL,
168
188
  dataPanelV2 = false,
189
+ useLastSelectedSources = false,
190
+ runtimeParameters,
169
191
  } = this.viewConfig;
170
192
  const queryParams = this.getBaseQueryParams();
171
193
 
@@ -201,13 +223,22 @@ export class SearchEmbed extends TsEmbed {
201
223
 
202
224
  queryParams[Param.DataPanelV2Enabled] = dataPanelV2;
203
225
  queryParams[Param.DataSourceMode] = this.getDataSourceMode();
204
- queryParams[Param.UseLastSelectedDataSource] = false;
226
+
227
+ queryParams[Param.UseLastSelectedDataSource] = useLastSelectedSources;
228
+ if (dataSource || dataSources) {
229
+ queryParams[Param.UseLastSelectedDataSource] = false;
230
+ }
231
+
205
232
  queryParams[Param.searchEmbed] = true;
206
233
  let query = '';
207
234
  const queryParamsString = getQueryParamString(queryParams, true);
208
235
  if (queryParamsString) {
209
236
  query = `?${queryParamsString}`;
210
237
  }
238
+
239
+ const parameterQuery = getRuntimeParameters(runtimeParameters || []);
240
+ if (parameterQuery) query += `&${parameterQuery}`;
241
+
211
242
  const filterQuery = getFilterQuery(runtimeFilters || []);
212
243
  if (filterQuery && !excludeRuntimeFiltersfromURL) {
213
244
  query += `&${filterQuery}`;