@thoughtspot/visual-embed-sdk 1.20.0-prerender.2 → 1.20.1

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 (182) hide show
  1. package/README.md +1 -1
  2. package/dist/src/auth.d.ts +2 -38
  3. package/dist/src/auth.d.ts.map +1 -1
  4. package/dist/src/config.d.ts +0 -1
  5. package/dist/src/config.d.ts.map +1 -1
  6. package/dist/src/embed/app.d.ts +5 -17
  7. package/dist/src/embed/app.d.ts.map +1 -1
  8. package/dist/src/embed/base.d.ts +9 -20
  9. package/dist/src/embed/base.d.ts.map +1 -1
  10. package/dist/src/embed/liveboard.d.ts +5 -17
  11. package/dist/src/embed/liveboard.d.ts.map +1 -1
  12. package/dist/src/embed/search-bar.d.ts +0 -3
  13. package/dist/src/embed/search-bar.d.ts.map +1 -1
  14. package/dist/src/embed/search.d.ts +5 -9
  15. package/dist/src/embed/search.d.ts.map +1 -1
  16. package/dist/src/embed/ts-embed.d.ts +6 -43
  17. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  18. package/dist/src/errors.d.ts.map +1 -1
  19. package/dist/src/index.d.ts.map +1 -1
  20. package/dist/src/mixpanel-service.d.ts +0 -8
  21. package/dist/src/mixpanel-service.d.ts.map +1 -1
  22. package/dist/src/react/index.d.ts.map +1 -1
  23. package/dist/src/react/util.d.ts +0 -4
  24. package/dist/src/react/util.d.ts.map +1 -1
  25. package/dist/src/test/test-utils.d.ts +2 -11
  26. package/dist/src/test/test-utils.d.ts.map +1 -1
  27. package/dist/src/types.d.ts +76 -273
  28. package/dist/src/types.d.ts.map +1 -1
  29. package/dist/src/utils/answerService.d.ts +0 -7
  30. package/dist/src/utils/answerService.d.ts.map +1 -1
  31. package/dist/src/utils/authService.d.ts +0 -30
  32. package/dist/src/utils/authService.d.ts.map +1 -1
  33. package/dist/src/utils/processData.d.ts +0 -12
  34. package/dist/src/utils/processData.d.ts.map +1 -1
  35. package/dist/src/utils/processTrigger.d.ts +0 -7
  36. package/dist/src/utils/processTrigger.d.ts.map +1 -1
  37. package/dist/src/utils.d.ts +0 -12
  38. package/dist/src/utils.d.ts.map +1 -1
  39. package/dist/tsembed.es.js +262 -637
  40. package/dist/tsembed.js +261 -629
  41. package/lib/package.json +8 -3
  42. package/lib/src/auth.d.ts +2 -38
  43. package/lib/src/auth.d.ts.map +1 -1
  44. package/lib/src/auth.js +25 -70
  45. package/lib/src/auth.js.map +1 -1
  46. package/lib/src/auth.spec.js +5 -14
  47. package/lib/src/auth.spec.js.map +1 -1
  48. package/lib/src/config.d.ts +0 -1
  49. package/lib/src/config.d.ts.map +1 -1
  50. package/lib/src/config.js +3 -5
  51. package/lib/src/config.js.map +1 -1
  52. package/lib/src/config.spec.js.map +1 -1
  53. package/lib/src/embed/app.d.ts +5 -17
  54. package/lib/src/embed/app.d.ts.map +1 -1
  55. package/lib/src/embed/app.js +15 -25
  56. package/lib/src/embed/app.js.map +1 -1
  57. package/lib/src/embed/app.spec.js +12 -12
  58. package/lib/src/embed/app.spec.js.map +1 -1
  59. package/lib/src/embed/base.d.ts +9 -20
  60. package/lib/src/embed/base.d.ts.map +1 -1
  61. package/lib/src/embed/base.js +15 -31
  62. package/lib/src/embed/base.js.map +1 -1
  63. package/lib/src/embed/base.spec.js.map +1 -1
  64. package/lib/src/embed/embed.spec.js +1 -1
  65. package/lib/src/embed/embed.spec.js.map +1 -1
  66. package/lib/src/embed/liveboard.d.ts +5 -17
  67. package/lib/src/embed/liveboard.d.ts.map +1 -1
  68. package/lib/src/embed/liveboard.js +37 -49
  69. package/lib/src/embed/liveboard.js.map +1 -1
  70. package/lib/src/embed/liveboard.spec.js +30 -37
  71. package/lib/src/embed/liveboard.spec.js.map +1 -1
  72. package/lib/src/embed/pinboard.spec.js +26 -14
  73. package/lib/src/embed/pinboard.spec.js.map +1 -1
  74. package/lib/src/embed/search-bar.d.ts +0 -3
  75. package/lib/src/embed/search-bar.d.ts.map +1 -1
  76. package/lib/src/embed/search-bar.js +6 -5
  77. package/lib/src/embed/search-bar.js.map +1 -1
  78. package/lib/src/embed/search.d.ts +5 -9
  79. package/lib/src/embed/search.d.ts.map +1 -1
  80. package/lib/src/embed/search.js +14 -18
  81. package/lib/src/embed/search.js.map +1 -1
  82. package/lib/src/embed/search.spec.js +19 -16
  83. package/lib/src/embed/search.spec.js.map +1 -1
  84. package/lib/src/embed/searchEmbed-basic-auth.spec.js +0 -4
  85. package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
  86. package/lib/src/embed/ts-embed.d.ts +6 -43
  87. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  88. package/lib/src/embed/ts-embed.js +72 -117
  89. package/lib/src/embed/ts-embed.js.map +1 -1
  90. package/lib/src/embed/ts-embed.spec.js +24 -23
  91. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  92. package/lib/src/errors.d.ts.map +1 -1
  93. package/lib/src/errors.js.map +1 -1
  94. package/lib/src/index.d.ts.map +1 -1
  95. package/lib/src/index.js +2 -2
  96. package/lib/src/index.js.map +1 -1
  97. package/lib/src/mixpanel-service.d.ts +0 -8
  98. package/lib/src/mixpanel-service.d.ts.map +1 -1
  99. package/lib/src/mixpanel-service.js +1 -13
  100. package/lib/src/mixpanel-service.js.map +1 -1
  101. package/lib/src/mixpanel-service.spec.js.map +1 -1
  102. package/lib/src/react/index.d.ts.map +1 -1
  103. package/lib/src/react/index.js +6 -6
  104. package/lib/src/react/index.js.map +1 -1
  105. package/lib/src/react/index.spec.js +6 -15
  106. package/lib/src/react/index.spec.js.map +1 -1
  107. package/lib/src/react/util.d.ts +0 -4
  108. package/lib/src/react/util.d.ts.map +1 -1
  109. package/lib/src/react/util.js +0 -4
  110. package/lib/src/react/util.js.map +1 -1
  111. package/lib/src/test/test-utils.d.ts +2 -11
  112. package/lib/src/test/test-utils.d.ts.map +1 -1
  113. package/lib/src/test/test-utils.js +25 -36
  114. package/lib/src/test/test-utils.js.map +1 -1
  115. package/lib/src/types.d.ts +76 -273
  116. package/lib/src/types.d.ts.map +1 -1
  117. package/lib/src/types.js +54 -200
  118. package/lib/src/types.js.map +1 -1
  119. package/lib/src/utils/answerService.d.ts +0 -7
  120. package/lib/src/utils/answerService.d.ts.map +1 -1
  121. package/lib/src/utils/answerService.js +0 -7
  122. package/lib/src/utils/answerService.js.map +1 -1
  123. package/lib/src/utils/answerService.spec.js.map +1 -1
  124. package/lib/src/utils/authService.d.ts +0 -30
  125. package/lib/src/utils/authService.d.ts.map +1 -1
  126. package/lib/src/utils/authService.js +2 -39
  127. package/lib/src/utils/authService.js.map +1 -1
  128. package/lib/src/utils/authService.spec.js.map +1 -1
  129. package/lib/src/utils/processData.d.ts +0 -12
  130. package/lib/src/utils/processData.d.ts.map +1 -1
  131. package/lib/src/utils/processData.js +5 -33
  132. package/lib/src/utils/processData.js.map +1 -1
  133. package/lib/src/utils/processData.spec.js.map +1 -1
  134. package/lib/src/utils/processTrigger.d.ts +0 -7
  135. package/lib/src/utils/processTrigger.d.ts.map +1 -1
  136. package/lib/src/utils/processTrigger.js +3 -17
  137. package/lib/src/utils/processTrigger.js.map +1 -1
  138. package/lib/src/utils/processTrigger.spec.js.map +1 -1
  139. package/lib/src/utils.d.ts +0 -12
  140. package/lib/src/utils.d.ts.map +1 -1
  141. package/lib/src/utils.js +19 -24
  142. package/lib/src/utils.js.map +1 -1
  143. package/lib/src/utils.spec.js.map +1 -1
  144. package/lib/src/visual-embed-sdk.d.ts +102 -406
  145. package/package.json +8 -3
  146. package/src/auth.spec.ts +150 -68
  147. package/src/auth.ts +108 -102
  148. package/src/config.spec.ts +4 -2
  149. package/src/config.ts +3 -5
  150. package/src/embed/app.spec.ts +14 -25
  151. package/src/embed/app.ts +35 -47
  152. package/src/embed/base.spec.ts +9 -3
  153. package/src/embed/base.ts +53 -51
  154. package/src/embed/embed.spec.ts +6 -5
  155. package/src/embed/liveboard.spec.ts +37 -56
  156. package/src/embed/liveboard.ts +64 -66
  157. package/src/embed/pinboard.spec.ts +29 -26
  158. package/src/embed/search-bar.tsx +8 -10
  159. package/src/embed/search.spec.ts +21 -31
  160. package/src/embed/search.ts +25 -26
  161. package/src/embed/searchEmbed-basic-auth.spec.ts +28 -22
  162. package/src/embed/ts-embed.spec.ts +148 -70
  163. package/src/embed/ts-embed.ts +157 -147
  164. package/src/errors.ts +6 -3
  165. package/src/index.ts +10 -4
  166. package/src/mixpanel-service.spec.ts +3 -1
  167. package/src/mixpanel-service.ts +1 -13
  168. package/src/react/index.spec.tsx +13 -37
  169. package/src/react/index.tsx +57 -38
  170. package/src/react/util.ts +4 -8
  171. package/src/test/test-utils.ts +39 -43
  172. package/src/types.ts +78 -270
  173. package/src/utils/answerService.spec.ts +5 -3
  174. package/src/utils/answerService.ts +17 -21
  175. package/src/utils/authService.spec.ts +41 -26
  176. package/src/utils/authService.ts +21 -47
  177. package/src/utils/processData.spec.ts +59 -26
  178. package/src/utils/processData.ts +14 -36
  179. package/src/utils/processTrigger.spec.ts +6 -1
  180. package/src/utils/processTrigger.ts +9 -18
  181. package/src/utils.spec.ts +12 -8
  182. package/src/utils.ts +26 -25
@@ -19,20 +19,17 @@ import {
19
19
  HostEvent,
20
20
  ViewConfig,
21
21
  } from '../types';
22
- import { getQueryParamString } from '../utils';
23
- import { getAuthPromise } from './base';
22
+ import { getFilterQuery, getQueryParamString } from '../utils';
24
23
  import { V1Embed } from './ts-embed';
25
24
 
26
25
  /**
27
26
  * The configuration for the embedded Liveboard or visualization page view.
28
- *
29
27
  * @group Embed components
30
28
  */
31
29
  export interface LiveboardViewConfig extends ViewConfig {
32
30
  /**
33
31
  * If set to true, the embedded object container dynamically resizes
34
32
  * according to the height of the Liveboard.
35
- *
36
33
  * @version SDK: 1.1.0 | ThoughtSpot: ts7.may.cl, 7.2.1
37
34
  */
38
35
  fullHeight?: boolean;
@@ -40,7 +37,6 @@ export interface LiveboardViewConfig extends ViewConfig {
40
37
  * This is the minimum height(in pixels) for a full height Liveboard.
41
38
  * Setting this height helps resolves issues with empty Liveboards and
42
39
  * other screens navigable from a Liveboard.
43
- *
44
40
  * @version SDK: 1.5.0 | ThoughtSpot: ts7.oct.cl, 7.2.1
45
41
  * @default 500
46
42
  */
@@ -52,13 +48,11 @@ export interface LiveboardViewConfig extends ViewConfig {
52
48
  /**
53
49
  * The Liveboard to display in the embedded view.
54
50
  * Use either of liveboardId or pinboardId to reference the Liveboard to embed.
55
- *
56
51
  * @version SDK: 1.3.0 | ThoughtSpot ts7.aug.cl, 7.2.1
57
52
  */
58
53
  liveboardId?: string;
59
54
  /**
60
55
  * To support backward compatibility
61
- *
62
56
  * @hidden
63
57
  */
64
58
  pinboardId?: string;
@@ -69,7 +63,6 @@ export interface LiveboardViewConfig extends ViewConfig {
69
63
  /**
70
64
  * If set to true, all filter chips from a
71
65
  * Liveboard page will be read-only (no X buttons)
72
- *
73
66
  * @version SDK: 1.3.0 | ThoughtSpot ts7.aug.cl, 7.2.1
74
67
  */
75
68
  preventLiveboardFilterRemoval?: boolean;
@@ -77,25 +70,21 @@ export interface LiveboardViewConfig extends ViewConfig {
77
70
  * Array of viz ids which should be visible when the liveboard
78
71
  * first renders. This can be changed by triggering the "SetVisibleVizs"
79
72
  * event.
80
- *
81
73
  * @version SDK: 1.9.1 | ThoughtSpot: 8.1.0.cl, 8.4.1-sw
82
74
  */
83
75
  visibleVizs?: string[];
84
76
  /**
85
77
  * To support backward compatibilty
86
- *
87
78
  * @hidden
88
79
  */
89
80
  preventPinboardFilterRemoval?: boolean;
90
81
  /**
91
82
  * Render embedded Liveboards and visualizations in the new Liveboard experience mode
92
- *
93
83
  * @version SDK: 1.14.0 | ThoughtSpot: 8.6.0.cl, 8.8.1-sw
94
84
  */
95
85
  liveboardV2?: boolean;
96
86
  /**
97
87
  * Tab Id of the Liveboard that is supposed to be active
98
- *
99
88
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
100
89
  */
101
90
  activeTabId?: string;
@@ -103,7 +92,6 @@ export interface LiveboardViewConfig extends ViewConfig {
103
92
 
104
93
  /**
105
94
  * Embed a ThoughtSpot Liveboard or visualization
106
- *
107
95
  * @group Embed components
108
96
  */
109
97
  export class LiveboardEmbed extends V1Embed {
@@ -114,21 +102,14 @@ export class LiveboardEmbed extends V1Embed {
114
102
  // eslint-disable-next-line no-useless-constructor
115
103
  constructor(domSelector: DOMSelector, viewConfig: LiveboardViewConfig) {
116
104
  super(domSelector, viewConfig);
117
- if (this.viewConfig.fullHeight === true) {
118
- this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
119
- this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
120
- this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
121
- }
122
105
  }
123
106
 
124
107
  /**
125
108
  * Construct a map of params to be passed on to the
126
109
  * embedded Liveboard or visualization.
127
110
  */
128
- protected getEmbedParams() {
129
- let params = {};
130
- params[Param.EmbedApp] = true;
131
- params = this.getBaseQueryParams(params);
111
+ private getEmbedParams() {
112
+ const params = this.getBaseQueryParams();
132
113
  const {
133
114
  enableVizTransformations,
134
115
  fullHeight,
@@ -139,8 +120,9 @@ export class LiveboardEmbed extends V1Embed {
139
120
  activeTabId,
140
121
  } = this.viewConfig;
141
122
 
142
- const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval
143
- || this.viewConfig.preventPinboardFilterRemoval;
123
+ const preventLiveboardFilterRemoval =
124
+ this.viewConfig.preventLiveboardFilterRemoval ||
125
+ this.viewConfig.preventPinboardFilterRemoval;
144
126
 
145
127
  if (fullHeight === true) {
146
128
  params[Param.fullHeight] = true;
@@ -149,7 +131,9 @@ export class LiveboardEmbed extends V1Embed {
149
131
  this.defaultHeight = defaultHeight;
150
132
  }
151
133
  if (enableVizTransformations !== undefined) {
152
- params[Param.EnableVizTransformations] = enableVizTransformations.toString();
134
+ params[
135
+ Param.EnableVizTransformations
136
+ ] = enableVizTransformations.toString();
153
137
  }
154
138
  if (preventLiveboardFilterRemoval) {
155
139
  params[Param.preventLiveboardFilterRemoval] = true;
@@ -169,41 +153,47 @@ export class LiveboardEmbed extends V1Embed {
169
153
  return queryParams;
170
154
  }
171
155
 
172
- private getIframeSuffixSrc(liveboardId: string, vizId: string, activeTabId: string) {
173
- let suffix = `/embed/viz/${liveboardId}`;
156
+ /**
157
+ * Construct the URL of the embedded ThoughtSpot Liveboard or visualization
158
+ * to be loaded within the iframe.
159
+ * @param liveboardId The GUID of the Liveboard.
160
+ * @param vizId The optional GUID of a visualization within the Liveboard.
161
+ * @param runtimeFilters A list of runtime filters to be applied to
162
+ * the Liveboard or visualization on load.
163
+ */
164
+ private getIFrameSrc(
165
+ liveboardId: string,
166
+ vizId?: string,
167
+ runtimeFilters?: RuntimeFilter[],
168
+ activeTabId?: string,
169
+ ) {
170
+ const filterQuery = getFilterQuery(runtimeFilters || []);
171
+ const queryParams = this.getEmbedParams();
172
+ const queryString = [filterQuery, queryParams]
173
+ .filter(Boolean)
174
+ .join('&');
175
+ let url = `${this.getV1EmbedBasePath(
176
+ queryString,
177
+ true,
178
+ false,
179
+ false,
180
+ )}/viz/${liveboardId}`;
174
181
  if (activeTabId) {
175
- suffix = `${suffix}/tab/${activeTabId} `;
182
+ url = `${url}/tab/${activeTabId}`;
176
183
  }
177
184
  if (vizId) {
178
- suffix = `${suffix}/${vizId}`;
185
+ url = `${url}/${vizId}`;
179
186
  }
180
- const tsPostHashParams = this.getThoughtSpotPostUrlParams();
181
- suffix = `${suffix}${tsPostHashParams}`;
182
- return suffix;
183
- }
184
187
 
185
- /**
186
- * Construct the URL of the embedded ThoughtSpot Liveboard or visualization
187
- * to be loaded within the iframe.
188
- */
189
- private getIFrameSrc() {
190
- const { vizId, activeTabId } = this.viewConfig;
191
- const liveboardId = this.viewConfig.liveboardId ?? this.viewConfig.pinboardId;
188
+ const tsPostHashParams = this.getThoughtSpotPostUrlParams();
189
+ url = `${url}${tsPostHashParams}`;
192
190
 
193
- if (!liveboardId) {
194
- this.handleError(ERROR_MESSAGE.LIVEBOARD_VIZ_ID_VALIDATION);
195
- }
196
- return `${this.getRootIframeSrc()}${this.getIframeSuffixSrc(
197
- liveboardId,
198
- vizId,
199
- activeTabId,
200
- )}`;
191
+ return url;
201
192
  }
202
193
 
203
194
  /**
204
195
  * Set the iframe height as per the computed height received
205
196
  * from the ThoughtSpot app.
206
- *
207
197
  * @param data The event payload
208
198
  */
209
199
  private updateIFrameHeight = (data: MessagePayload) => {
@@ -223,13 +213,12 @@ export class LiveboardEmbed extends V1Embed {
223
213
 
224
214
  /**
225
215
  * Triggers an event to the embedded app
226
- *
227
216
  * @param messageType The event type
228
217
  * @param data The payload to send with the message
229
218
  */
230
219
  public trigger(messageType: HostEvent, data: any = {}): Promise<any> {
231
220
  const dataWithVizId = data;
232
- if (typeof dataWithVizId === 'object' && this.viewConfig.vizId) {
221
+ if (this.viewConfig.vizId) {
233
222
  dataWithVizId.vizId = this.viewConfig.vizId;
234
223
  }
235
224
  return super.trigger(messageType, dataWithVizId);
@@ -237,33 +226,42 @@ export class LiveboardEmbed extends V1Embed {
237
226
 
238
227
  /**
239
228
  * Render an embedded ThoughtSpot Liveboard or visualization
240
- *
241
229
  * @param renderOptions An object specifying the Liveboard ID,
242
230
  * visualization ID and the runtime filters.
243
231
  */
244
232
  public render(): LiveboardEmbed {
233
+ const { vizId, activeTabId, runtimeFilters } = this.viewConfig;
234
+ const liveboardId =
235
+ this.viewConfig.liveboardId ?? this.viewConfig.pinboardId;
236
+
237
+ if (!liveboardId) {
238
+ this.handleError(ERROR_MESSAGE.LIVEBOARD_VIZ_ID_VALIDATION);
239
+ }
240
+
241
+ if (this.viewConfig.fullHeight === true) {
242
+ this.on(
243
+ EmbedEvent.RouteChange,
244
+ this.setIframeHeightForNonEmbedLiveboard,
245
+ );
246
+ this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
247
+ this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
248
+ }
249
+
245
250
  super.render();
246
251
 
247
- const src = this.getIFrameSrc();
252
+ const src = this.getIFrameSrc(
253
+ liveboardId,
254
+ vizId,
255
+ runtimeFilters,
256
+ activeTabId,
257
+ );
248
258
  this.renderV1Embed(src);
249
259
 
250
260
  return this;
251
261
  }
252
-
253
- public navigateToLiveboard(liveboardId: string, vizId?: string, activeTabId?: string) {
254
- const path = this.getIframeSuffixSrc(liveboardId, vizId, activeTabId);
255
- this.viewConfig.liveboardId = liveboardId;
256
- this.viewConfig.activeTabId = activeTabId;
257
- this.viewConfig.vizId = vizId;
258
- if (this.isAppInitialized) {
259
- this.trigger(HostEvent.Navigate, path.substring(1));
260
- } else {
261
- this.render();
262
- }
263
- }
264
262
  }
265
263
 
266
264
  /**
267
265
  * @hidden
268
266
  */
269
- export class PinboardEmbed extends LiveboardEmbed { }
267
+ export class PinboardEmbed extends LiveboardEmbed {}
@@ -1,8 +1,6 @@
1
1
  import { PinboardEmbed, LiveboardViewConfig } from './liveboard';
2
2
  import { init } from '../index';
3
- import {
4
- Action, AuthType, EmbedEvent, RuntimeFilterOp,
5
- } from '../types';
3
+ import { Action, AuthType, EmbedEvent, RuntimeFilterOp } from '../types';
6
4
  import {
7
5
  executeAfterWait,
8
6
  getDocumentBody,
@@ -10,7 +8,6 @@ import {
10
8
  getRootEl,
11
9
  defaultParams,
12
10
  defaultParamsWithoutHiddenActions,
13
- expectUrlMatchesWithParams,
14
11
  } from '../test/test-utils';
15
12
  import { version } from '../../package.json';
16
13
 
@@ -44,8 +41,7 @@ describe('Pinboard/viz embed tests', () => {
44
41
  } as LiveboardViewConfig);
45
42
  pinboardEmbed.render();
46
43
  await executeAfterWait(() => {
47
- expectUrlMatchesWithParams(
48
- getIFrameSrc(),
44
+ expect(getIFrameSrc()).toBe(
49
45
  `http://${thoughtSpotHost}/?embedApp=true${defaultParams}${prefixParams}#/embed/viz/${pinboardId}`,
50
46
  );
51
47
  });
@@ -53,15 +49,18 @@ describe('Pinboard/viz embed tests', () => {
53
49
 
54
50
  test('should set disabled actions', async () => {
55
51
  const pinboardEmbed = new PinboardEmbed(getRootEl(), {
56
- disabledActions: [Action.DownloadAsCsv, Action.DownloadAsPdf, Action.DownloadAsXlsx],
52
+ disabledActions: [
53
+ Action.DownloadAsCsv,
54
+ Action.DownloadAsPdf,
55
+ Action.DownloadAsXlsx,
56
+ ],
57
57
  disabledActionReason: 'Action denied',
58
58
  ...defaultViewConfig,
59
59
  pinboardId,
60
60
  } as LiveboardViewConfig);
61
61
  pinboardEmbed.render();
62
62
  await executeAfterWait(() => {
63
- expectUrlMatchesWithParams(
64
- getIFrameSrc(),
63
+ expect(getIFrameSrc()).toBe(
65
64
  `http://${thoughtSpotHost}/?embedApp=true&${defaultParamsWithoutHiddenActions}&disableAction=[%22${Action.DownloadAsCsv}%22,%22${Action.DownloadAsPdf}%22,%22${Action.DownloadAsXlsx}%22]&disableHint=Action%20denied&hideAction=[%22${Action.ReportError}%22]${prefixParams}#/embed/viz/${pinboardId}`,
66
65
  );
67
66
  });
@@ -69,14 +68,17 @@ describe('Pinboard/viz embed tests', () => {
69
68
 
70
69
  test('should set hidden actions', async () => {
71
70
  const pinboardEmbed = new PinboardEmbed(getRootEl(), {
72
- hiddenActions: [Action.DownloadAsCsv, Action.DownloadAsPdf, Action.DownloadAsXlsx],
71
+ hiddenActions: [
72
+ Action.DownloadAsCsv,
73
+ Action.DownloadAsPdf,
74
+ Action.DownloadAsXlsx,
75
+ ],
73
76
  ...defaultViewConfig,
74
77
  pinboardId,
75
78
  } as LiveboardViewConfig);
76
79
  pinboardEmbed.render();
77
80
  await executeAfterWait(() => {
78
- expectUrlMatchesWithParams(
79
- getIFrameSrc(),
81
+ expect(getIFrameSrc()).toBe(
80
82
  `http://${thoughtSpotHost}/?embedApp=true&${defaultParamsWithoutHiddenActions}&hideAction=[%22${Action.ReportError}%22,%22${Action.DownloadAsCsv}%22,%22${Action.DownloadAsPdf}%22,%22${Action.DownloadAsXlsx}%22]${prefixParams}#/embed/viz/${pinboardId}`,
81
83
  );
82
84
  });
@@ -84,14 +86,17 @@ describe('Pinboard/viz embed tests', () => {
84
86
 
85
87
  test('should set visible actions', async () => {
86
88
  const pinboardEmbed = new PinboardEmbed(getRootEl(), {
87
- visibleActions: [Action.DownloadAsCsv, Action.DownloadAsPdf, Action.DownloadAsXlsx],
89
+ visibleActions: [
90
+ Action.DownloadAsCsv,
91
+ Action.DownloadAsPdf,
92
+ Action.DownloadAsXlsx,
93
+ ],
88
94
  ...defaultViewConfig,
89
95
  pinboardId,
90
96
  } as LiveboardViewConfig);
91
97
  pinboardEmbed.render();
92
98
  await executeAfterWait(() => {
93
- expectUrlMatchesWithParams(
94
- getIFrameSrc(),
99
+ expect(getIFrameSrc()).toBe(
95
100
  `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&visibleAction=[%22${Action.DownloadAsCsv}%22,%22${Action.DownloadAsPdf}%22,%22${Action.DownloadAsXlsx}%22]${prefixParams}#/embed/viz/${pinboardId}`,
96
101
  );
97
102
  });
@@ -105,8 +110,7 @@ describe('Pinboard/viz embed tests', () => {
105
110
  } as LiveboardViewConfig);
106
111
  pinboardEmbed.render();
107
112
  await executeAfterWait(() => {
108
- expectUrlMatchesWithParams(
109
- getIFrameSrc(),
113
+ expect(getIFrameSrc()).toBe(
110
114
  `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&visibleAction=[]${prefixParams}#/embed/viz/${pinboardId}`,
111
115
  );
112
116
  });
@@ -120,8 +124,7 @@ describe('Pinboard/viz embed tests', () => {
120
124
  } as LiveboardViewConfig);
121
125
  pinboardEmbed.render();
122
126
  await executeAfterWait(() => {
123
- expectUrlMatchesWithParams(
124
- getIFrameSrc(),
127
+ expect(getIFrameSrc()).toBe(
125
128
  `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&enableVizTransform=true${prefixParams}#/embed/viz/${pinboardId}`,
126
129
  );
127
130
  });
@@ -135,8 +138,7 @@ describe('Pinboard/viz embed tests', () => {
135
138
  } as LiveboardViewConfig);
136
139
  pinboardEmbed.render();
137
140
  await executeAfterWait(() => {
138
- expectUrlMatchesWithParams(
139
- getIFrameSrc(),
141
+ expect(getIFrameSrc()).toBe(
140
142
  `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&enableVizTransform=false${prefixParams}#/embed/viz/${pinboardId}`,
141
143
  );
142
144
  });
@@ -150,8 +152,7 @@ describe('Pinboard/viz embed tests', () => {
150
152
  } as LiveboardViewConfig);
151
153
  pinboardEmbed.render();
152
154
  await executeAfterWait(() => {
153
- expectUrlMatchesWithParams(
154
- getIFrameSrc(),
155
+ expect(getIFrameSrc()).toBe(
155
156
  `http://${thoughtSpotHost}/?embedApp=true${defaultParams}${prefixParamsVizEmbed}#/embed/viz/${pinboardId}/${vizId}`,
156
157
  );
157
158
  });
@@ -172,8 +173,7 @@ describe('Pinboard/viz embed tests', () => {
172
173
  } as LiveboardViewConfig);
173
174
  pinboardEmbed.render();
174
175
  await executeAfterWait(() => {
175
- expectUrlMatchesWithParams(
176
- getIFrameSrc(),
176
+ expect(getIFrameSrc()).toBe(
177
177
  `http://${thoughtSpotHost}/?embedApp=true&col1=sales&op1=EQ&val1=1000${defaultParams}${prefixParamsVizEmbed}#/embed/viz/${pinboardId}/${vizId}`,
178
178
  );
179
179
  });
@@ -191,7 +191,10 @@ describe('Pinboard/viz embed tests', () => {
191
191
  pinboardEmbed.render();
192
192
 
193
193
  executeAfterWait(() => {
194
- expect(onSpy).toHaveBeenCalledWith(EmbedEvent.EmbedHeight, expect.anything());
194
+ expect(onSpy).toHaveBeenCalledWith(
195
+ EmbedEvent.EmbedHeight,
196
+ expect.anything(),
197
+ );
195
198
  });
196
199
  });
197
200
  });
@@ -1,6 +1,4 @@
1
- import {
2
- DOMSelector, Param, Action, ViewConfig,
3
- } from '../types';
1
+ import { DOMSelector, Param, Action, ViewConfig } from '../types';
4
2
  import { getQueryParamString } from '../utils';
5
3
  import { TsEmbed } from './ts-embed';
6
4
  import { SearchOptions } from './search';
@@ -8,17 +6,16 @@ import { SearchOptions } from './search';
8
6
  /**
9
7
  * @group Embed components
10
8
  */
11
- export interface SearchBarViewConfig extends Omit<ViewConfig, 'runtimeFilters' | 'showAlerts'> {
9
+ export interface SearchBarViewConfig
10
+ extends Omit<ViewConfig, 'runtimeFilters' | 'showAlerts'> {
12
11
  /**
13
12
  * The array of data source GUIDs to set on load.
14
13
  * Only a single dataSource supported currently.
15
- *
16
14
  * @deprecated Use dataSource instead
17
15
  */
18
16
  dataSources?: string[];
19
17
  /**
20
18
  * The array of data source GUIDs to set on load.
21
- *
22
19
  * @version: SDK: 1.19.0
23
20
  */
24
21
  dataSource?: string;
@@ -48,7 +45,6 @@ export class SearchBarEmbed extends TsEmbed {
48
45
  /**
49
46
  * Construct the URL of the embedded ThoughtSpot search to be
50
47
  * loaded in the iframe
51
- *
52
48
  * @param dataSources A list of data source GUIDs
53
49
  */
54
50
  private getIFrameSrc() {
@@ -56,7 +52,9 @@ export class SearchBarEmbed extends TsEmbed {
56
52
  const path = 'search-bar-embed';
57
53
  const queryParams = this.getBaseQueryParams();
58
54
 
59
- queryParams[Param.HideActions] = [...(queryParams[Param.HideActions] ?? [])];
55
+ queryParams[Param.HideActions] = [
56
+ ...(queryParams[Param.HideActions] ?? []),
57
+ ];
60
58
 
61
59
  if (dataSources && dataSources.length) {
62
60
  queryParams[Param.DataSources] = JSON.stringify(dataSources);
@@ -83,7 +81,7 @@ export class SearchBarEmbed extends TsEmbed {
83
81
  }
84
82
  const tsPostHashParams = this.getThoughtSpotPostUrlParams();
85
83
 
86
- return `${this.getEmbedBasePath(query)}/embed/${path}${tsPostHashParams}`;
84
+ return `${this.getEmbedBasePath(query)}/${path}${tsPostHashParams}`;
87
85
  }
88
86
 
89
87
  /**
@@ -93,7 +91,7 @@ export class SearchBarEmbed extends TsEmbed {
93
91
  super.render();
94
92
 
95
93
  const src = this.getIFrameSrc();
96
- this.renderIFrame(src);
94
+ this.renderIFrame(src, this.viewConfig.frameParams);
97
95
  return this;
98
96
  }
99
97
  }
@@ -9,7 +9,6 @@ import {
9
9
  getRootEl,
10
10
  fixedEncodeURI,
11
11
  defaultParamsWithoutHiddenActions as defaultParams,
12
- expectUrlMatchesWithParams,
13
12
  } from '../test/test-utils';
14
13
  import { version } from '../../package.json';
15
14
 
@@ -22,7 +21,10 @@ const defaultViewConfig = {
22
21
  const answerId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
23
22
  const thoughtSpotHost = 'tshost';
24
23
  const hideBydefault = `&hideAction=${fixedEncodeURI(
25
- JSON.stringify([Action.ReportError, ...HiddenActionItemByDefaultForSearchEmbed]),
24
+ JSON.stringify([
25
+ Action.ReportError,
26
+ ...HiddenActionItemByDefaultForSearchEmbed,
27
+ ]),
26
28
  )}`;
27
29
  const defaultParamsWithHiddenActions = defaultParams + hideBydefault;
28
30
  const prefixParams = '&isSearchEmbed=true';
@@ -38,15 +40,16 @@ beforeAll(() => {
38
40
  describe('Search embed tests', () => {
39
41
  beforeEach(() => {
40
42
  document.body.innerHTML = getDocumentBody();
41
- jest.spyOn(authInstance, 'getReleaseVersion').mockReturnValue('7.4.0.sw');
43
+ jest.spyOn(authInstance, 'getReleaseVersion').mockReturnValue(
44
+ '7.4.0.sw',
45
+ );
42
46
  });
43
47
 
44
48
  test('should render', async () => {
45
49
  const searchEmbed = new SearchEmbed(getRootEl(), {});
46
50
  searchEmbed.render();
47
51
  await executeAfterWait(() => {
48
- expectUrlMatchesWithParams(
49
- getIFrameSrc(),
52
+ expect(getIFrameSrc()).toBe(
50
53
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
51
54
  );
52
55
  });
@@ -60,8 +63,7 @@ describe('Search embed tests', () => {
60
63
  });
61
64
  searchEmbed.render();
62
65
  await executeAfterWait(() => {
63
- expectUrlMatchesWithParams(
64
- getIFrameSrc(),
66
+ expect(getIFrameSrc()).toBe(
65
67
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
66
68
  );
67
69
  });
@@ -79,8 +81,7 @@ describe('Search embed tests', () => {
79
81
  });
80
82
  searchEmbed.render();
81
83
  await executeAfterWait(() => {
82
- expectUrlMatchesWithParams(
83
- getIFrameSrc(),
84
+ expect(getIFrameSrc()).toBe(
84
85
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
85
86
  );
86
87
  });
@@ -98,8 +99,7 @@ describe('Search embed tests', () => {
98
99
 
99
100
  searchEmbed.render();
100
101
  await executeAfterWait(() => {
101
- expectUrlMatchesWithParams(
102
- getIFrameSrc(),
102
+ expect(getIFrameSrc()).toBe(
103
103
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
104
104
  );
105
105
  });
@@ -114,8 +114,7 @@ describe('Search embed tests', () => {
114
114
 
115
115
  searchEmbed.render();
116
116
  await executeAfterWait(() => {
117
- expectUrlMatchesWithParams(
118
- getIFrameSrc(),
117
+ expect(getIFrameSrc()).toBe(
119
118
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&executeSearch=true&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
120
119
  );
121
120
  });
@@ -134,8 +133,7 @@ describe('Search embed tests', () => {
134
133
  });
135
134
  searchEmbed.render();
136
135
  await executeAfterWait(() => {
137
- expectUrlMatchesWithParams(
138
- getIFrameSrc(),
136
+ expect(getIFrameSrc()).toBe(
139
137
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=collapse&useLastSelectedSources=false${prefixParams}#/embed/answer`,
140
138
  );
141
139
  });
@@ -154,8 +152,7 @@ describe('Search embed tests', () => {
154
152
  });
155
153
  searchEmbed.render();
156
154
  await executeAfterWait(() => {
157
- expectUrlMatchesWithParams(
158
- getIFrameSrc(),
155
+ expect(getIFrameSrc()).toBe(
159
156
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=hide&useLastSelectedSources=false${prefixParams}#/embed/answer`,
160
157
  );
161
158
  });
@@ -181,8 +178,7 @@ describe('Search embed tests', () => {
181
178
  });
182
179
  searchEmbed.render();
183
180
  await executeAfterWait(() => {
184
- expectUrlMatchesWithParams(
185
- getIFrameSrc(),
181
+ expect(getIFrameSrc()).toBe(
186
182
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=hide&useLastSelectedSources=false${prefixParams}&col1=city&op1=EQ&val1=berkeley#/embed/answer`,
187
183
  );
188
184
  });
@@ -201,8 +197,7 @@ describe('Search embed tests', () => {
201
197
  });
202
198
  searchEmbed.render();
203
199
  await executeAfterWait(() => {
204
- expectUrlMatchesWithParams(
205
- getIFrameSrc(),
200
+ expect(getIFrameSrc()).toBe(
206
201
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSources=[%22data-source-1%22]&searchTokenString=%5Bcommit%20date%5D%5Brevenue%5D&dataSourceMode=hide&useLastSelectedSources=false${prefixParams}#/embed/answer`,
207
202
  );
208
203
  });
@@ -222,8 +217,7 @@ describe('Search embed tests', () => {
222
217
  });
223
218
  searchEmbed.render();
224
219
  await executeAfterWait(() => {
225
- expectUrlMatchesWithParams(
226
- getIFrameSrc(),
220
+ expect(getIFrameSrc()).toBe(
227
221
  `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`,
228
222
  );
229
223
  });
@@ -236,8 +230,7 @@ describe('Search embed tests', () => {
236
230
  });
237
231
  searchEmbed.render();
238
232
  await executeAfterWait(() => {
239
- expectUrlMatchesWithParams(
240
- getIFrameSrc(),
233
+ expect(getIFrameSrc()).toBe(
241
234
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&enableSearchAssist=true&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
242
235
  );
243
236
  });
@@ -263,8 +256,7 @@ describe('Search embed tests', () => {
263
256
  ]),
264
257
  );
265
258
  await executeAfterWait(() => {
266
- expectUrlMatchesWithParams(
267
- getIFrameSrc(),
259
+ expect(getIFrameSrc()).toBe(
268
260
  `http://${thoughtSpotHost}/v2/?${defaultParams}&hideAction=${hideActionUrl}&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
269
261
  );
270
262
  });
@@ -288,8 +280,7 @@ describe('Search embed tests', () => {
288
280
  ]),
289
281
  );
290
282
  await executeAfterWait(() => {
291
- expectUrlMatchesWithParams(
292
- getIFrameSrc(),
283
+ expect(getIFrameSrc()).toBe(
293
284
  `http://${thoughtSpotHost}/v2/?${defaultParams}&disableAction=[%22downloadAsXLSX%22]&disableHint=Access%20denied&hideAction=${hideActionUrl}&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
294
285
  );
295
286
  });
@@ -302,8 +293,7 @@ describe('Search embed tests', () => {
302
293
  });
303
294
  searchEmbed.render();
304
295
  await executeAfterWait(() => {
305
- expectUrlMatchesWithParams(
306
- getIFrameSrc(),
296
+ expect(getIFrameSrc()).toBe(
307
297
  `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/saved-answer/${answerId}`,
308
298
  );
309
299
  });