@thoughtspot/visual-embed-sdk 1.44.2 → 1.44.4-HE-beta.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 (213) hide show
  1. package/README.md +1 -1
  2. package/cjs/package.json +1 -1
  3. package/cjs/src/embed/app.d.ts +44 -32
  4. package/cjs/src/embed/app.d.ts.map +1 -1
  5. package/cjs/src/embed/app.js.map +1 -1
  6. package/cjs/src/embed/base.d.ts +1 -1
  7. package/cjs/src/embed/base.d.ts.map +1 -1
  8. package/cjs/src/embed/base.js +4 -0
  9. package/cjs/src/embed/base.js.map +1 -1
  10. package/cjs/src/embed/base.spec.js +60 -0
  11. package/cjs/src/embed/base.spec.js.map +1 -1
  12. package/cjs/src/embed/conversation.d.ts +7 -0
  13. package/cjs/src/embed/conversation.d.ts.map +1 -1
  14. package/cjs/src/embed/conversation.js +9 -0
  15. package/cjs/src/embed/conversation.js.map +1 -1
  16. package/cjs/src/embed/hostEventClient/contracts.d.ts +20 -3
  17. package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  18. package/cjs/src/embed/hostEventClient/contracts.js +6 -1
  19. package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
  20. package/cjs/src/embed/hostEventClient/host-event-client.d.ts +8 -8
  21. package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  22. package/cjs/src/embed/hostEventClient/host-event-client.js +18 -18
  23. package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
  24. package/cjs/src/embed/hostEventClient/host-event-client.spec.js +7 -7
  25. package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  26. package/cjs/src/embed/liveboard.d.ts +10 -4
  27. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  28. package/cjs/src/embed/liveboard.js +12 -2
  29. package/cjs/src/embed/liveboard.js.map +1 -1
  30. package/cjs/src/embed/liveboard.spec.js +1 -1
  31. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  32. package/cjs/src/embed/sage.d.ts +7 -0
  33. package/cjs/src/embed/sage.d.ts.map +1 -1
  34. package/cjs/src/embed/sage.js +9 -0
  35. package/cjs/src/embed/sage.js.map +1 -1
  36. package/cjs/src/embed/search-bar.d.ts +7 -0
  37. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  38. package/cjs/src/embed/search-bar.js +9 -0
  39. package/cjs/src/embed/search-bar.js.map +1 -1
  40. package/cjs/src/embed/search.d.ts +7 -0
  41. package/cjs/src/embed/search.d.ts.map +1 -1
  42. package/cjs/src/embed/search.js +9 -0
  43. package/cjs/src/embed/search.js.map +1 -1
  44. package/cjs/src/embed/ts-embed.d.ts +9 -3
  45. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  46. package/cjs/src/embed/ts-embed.js +41 -8
  47. package/cjs/src/embed/ts-embed.js.map +1 -1
  48. package/cjs/src/embed/ts-embed.spec.js +156 -24
  49. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  50. package/cjs/src/errors.d.ts +2 -0
  51. package/cjs/src/errors.d.ts.map +1 -1
  52. package/cjs/src/errors.js +2 -0
  53. package/cjs/src/errors.js.map +1 -1
  54. package/cjs/src/index.d.ts +2 -2
  55. package/cjs/src/index.d.ts.map +1 -1
  56. package/cjs/src/index.js +5 -1
  57. package/cjs/src/index.js.map +1 -1
  58. package/cjs/src/types.d.ts +142 -45
  59. package/cjs/src/types.d.ts.map +1 -1
  60. package/cjs/src/types.js +91 -16
  61. package/cjs/src/types.js.map +1 -1
  62. package/cjs/src/utils/logger.spec.d.ts +20 -5
  63. package/cjs/src/utils/logger.spec.d.ts.map +1 -1
  64. package/cjs/src/utils/processTrigger.d.ts +3 -2
  65. package/cjs/src/utils/processTrigger.d.ts.map +1 -1
  66. package/cjs/src/utils/processTrigger.js +4 -2
  67. package/cjs/src/utils/processTrigger.js.map +1 -1
  68. package/cjs/src/utils.d.ts +15 -4
  69. package/cjs/src/utils.d.ts.map +1 -1
  70. package/cjs/src/utils.js +38 -6
  71. package/cjs/src/utils.js.map +1 -1
  72. package/cjs/src/utils.spec.js +53 -0
  73. package/cjs/src/utils.spec.js.map +1 -1
  74. package/dist/index-BFdRRz03.js +7371 -0
  75. package/dist/index-BUfrYJ3w.js +7371 -0
  76. package/dist/index-CI6s4VMY.js +7371 -0
  77. package/dist/{index-CSFjfTVk.js → index-CWQnMX2L.js} +1 -1
  78. package/dist/index-CaW-1mu5.js +7371 -0
  79. package/dist/index-CcSgNJVi.js +7371 -0
  80. package/dist/index-Djtv-y7A.js +7371 -0
  81. package/dist/index-UY-4yjBN.js +7371 -0
  82. package/dist/src/embed/app.d.ts +44 -32
  83. package/dist/src/embed/app.d.ts.map +1 -1
  84. package/dist/src/embed/base.d.ts +1 -1
  85. package/dist/src/embed/base.d.ts.map +1 -1
  86. package/dist/src/embed/conversation.d.ts +7 -0
  87. package/dist/src/embed/conversation.d.ts.map +1 -1
  88. package/dist/src/embed/hostEventClient/contracts.d.ts +20 -3
  89. package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  90. package/dist/src/embed/hostEventClient/host-event-client.d.ts +8 -8
  91. package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  92. package/dist/src/embed/liveboard.d.ts +10 -4
  93. package/dist/src/embed/liveboard.d.ts.map +1 -1
  94. package/dist/src/embed/sage.d.ts +7 -0
  95. package/dist/src/embed/sage.d.ts.map +1 -1
  96. package/dist/src/embed/search-bar.d.ts +7 -0
  97. package/dist/src/embed/search-bar.d.ts.map +1 -1
  98. package/dist/src/embed/search.d.ts +7 -0
  99. package/dist/src/embed/search.d.ts.map +1 -1
  100. package/dist/src/embed/ts-embed.d.ts +9 -3
  101. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  102. package/dist/src/errors.d.ts +2 -0
  103. package/dist/src/errors.d.ts.map +1 -1
  104. package/dist/src/index.d.ts +2 -2
  105. package/dist/src/index.d.ts.map +1 -1
  106. package/dist/src/types.d.ts +142 -45
  107. package/dist/src/types.d.ts.map +1 -1
  108. package/dist/src/utils/logger.spec.d.ts +20 -5
  109. package/dist/src/utils/logger.spec.d.ts.map +1 -1
  110. package/dist/src/utils/processTrigger.d.ts +3 -2
  111. package/dist/src/utils/processTrigger.d.ts.map +1 -1
  112. package/dist/src/utils.d.ts +15 -4
  113. package/dist/src/utils.d.ts.map +1 -1
  114. package/dist/tsembed-react.es.js +288 -95
  115. package/dist/tsembed-react.js +287 -94
  116. package/dist/tsembed.es.js +289 -96
  117. package/dist/tsembed.js +314 -121
  118. package/dist/visual-embed-sdk-react-full.d.ts +246 -83
  119. package/dist/visual-embed-sdk-react.d.ts +251 -90
  120. package/dist/visual-embed-sdk.d.ts +299 -93
  121. package/lib/package.json +1 -1
  122. package/lib/src/embed/app.d.ts +44 -32
  123. package/lib/src/embed/app.d.ts.map +1 -1
  124. package/lib/src/embed/app.js.map +1 -1
  125. package/lib/src/embed/base.d.ts +1 -1
  126. package/lib/src/embed/base.d.ts.map +1 -1
  127. package/lib/src/embed/base.js +5 -1
  128. package/lib/src/embed/base.js.map +1 -1
  129. package/lib/src/embed/base.spec.js +61 -1
  130. package/lib/src/embed/base.spec.js.map +1 -1
  131. package/lib/src/embed/conversation.d.ts +7 -0
  132. package/lib/src/embed/conversation.d.ts.map +1 -1
  133. package/lib/src/embed/conversation.js +9 -0
  134. package/lib/src/embed/conversation.js.map +1 -1
  135. package/lib/src/embed/hostEventClient/contracts.d.ts +20 -3
  136. package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  137. package/lib/src/embed/hostEventClient/contracts.js +5 -0
  138. package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
  139. package/lib/src/embed/hostEventClient/host-event-client.d.ts +8 -8
  140. package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  141. package/lib/src/embed/hostEventClient/host-event-client.js +18 -18
  142. package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
  143. package/lib/src/embed/hostEventClient/host-event-client.spec.js +7 -7
  144. package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  145. package/lib/src/embed/liveboard.d.ts +10 -4
  146. package/lib/src/embed/liveboard.d.ts.map +1 -1
  147. package/lib/src/embed/liveboard.js +12 -2
  148. package/lib/src/embed/liveboard.js.map +1 -1
  149. package/lib/src/embed/liveboard.spec.js +1 -1
  150. package/lib/src/embed/liveboard.spec.js.map +1 -1
  151. package/lib/src/embed/sage.d.ts +7 -0
  152. package/lib/src/embed/sage.d.ts.map +1 -1
  153. package/lib/src/embed/sage.js +9 -0
  154. package/lib/src/embed/sage.js.map +1 -1
  155. package/lib/src/embed/search-bar.d.ts +7 -0
  156. package/lib/src/embed/search-bar.d.ts.map +1 -1
  157. package/lib/src/embed/search-bar.js +9 -0
  158. package/lib/src/embed/search-bar.js.map +1 -1
  159. package/lib/src/embed/search.d.ts +7 -0
  160. package/lib/src/embed/search.d.ts.map +1 -1
  161. package/lib/src/embed/search.js +9 -0
  162. package/lib/src/embed/search.js.map +1 -1
  163. package/lib/src/embed/ts-embed.d.ts +9 -3
  164. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  165. package/lib/src/embed/ts-embed.js +41 -8
  166. package/lib/src/embed/ts-embed.js.map +1 -1
  167. package/lib/src/embed/ts-embed.spec.js +156 -24
  168. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  169. package/lib/src/errors.d.ts +2 -0
  170. package/lib/src/errors.d.ts.map +1 -1
  171. package/lib/src/errors.js +2 -0
  172. package/lib/src/errors.js.map +1 -1
  173. package/lib/src/index.d.ts +2 -2
  174. package/lib/src/index.d.ts.map +1 -1
  175. package/lib/src/index.js +2 -2
  176. package/lib/src/index.js.map +1 -1
  177. package/lib/src/types.d.ts +142 -45
  178. package/lib/src/types.d.ts.map +1 -1
  179. package/lib/src/types.js +90 -15
  180. package/lib/src/types.js.map +1 -1
  181. package/lib/src/utils/logger.spec.d.ts +20 -5
  182. package/lib/src/utils/logger.spec.d.ts.map +1 -1
  183. package/lib/src/utils/processTrigger.d.ts +3 -2
  184. package/lib/src/utils/processTrigger.d.ts.map +1 -1
  185. package/lib/src/utils/processTrigger.js +4 -2
  186. package/lib/src/utils/processTrigger.js.map +1 -1
  187. package/lib/src/utils.d.ts +15 -4
  188. package/lib/src/utils.d.ts.map +1 -1
  189. package/lib/src/utils.js +35 -5
  190. package/lib/src/utils.js.map +1 -1
  191. package/lib/src/utils.spec.js +54 -1
  192. package/lib/src/utils.spec.js.map +1 -1
  193. package/package.json +1 -1
  194. package/src/embed/app.ts +45 -32
  195. package/src/embed/base.spec.ts +79 -1
  196. package/src/embed/base.ts +5 -2
  197. package/src/embed/conversation.ts +11 -0
  198. package/src/embed/hostEventClient/contracts.ts +23 -4
  199. package/src/embed/hostEventClient/host-event-client.spec.ts +7 -1
  200. package/src/embed/hostEventClient/host-event-client.ts +22 -11
  201. package/src/embed/liveboard.spec.ts +1 -1
  202. package/src/embed/liveboard.ts +18 -5
  203. package/src/embed/sage.ts +11 -0
  204. package/src/embed/search-bar.tsx +11 -0
  205. package/src/embed/search.ts +11 -0
  206. package/src/embed/ts-embed.spec.ts +205 -18
  207. package/src/embed/ts-embed.ts +45 -9
  208. package/src/errors.ts +2 -0
  209. package/src/index.ts +6 -0
  210. package/src/types.ts +146 -43
  211. package/src/utils/processTrigger.ts +6 -3
  212. package/src/utils.spec.ts +78 -0
  213. package/src/utils.ts +35 -8
@@ -60,6 +60,7 @@ import {
60
60
  EmbedErrorDetailsEvent,
61
61
  ErrorDetailsTypes,
62
62
  EmbedErrorCodes,
63
+ ContextType,
63
64
  } from '../types';
64
65
  import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
65
66
  import { processEventData, processAuthFailure } from '../utils/processData';
@@ -75,6 +76,7 @@ import { ERROR_MESSAGE } from '../errors';
75
76
  import { getPreauthInfo } from '../utils/sessionInfoService';
76
77
  import { HostEventClient } from './hostEventClient/host-event-client';
77
78
  import { getInterceptInitData, handleInterceptEvent, processApiInterceptResponse, processLegacyInterceptResponse } from '../api-intercept';
79
+ import { getHostEventsConfig } from '../utils';
78
80
 
79
81
  const { version } = pkgInfo;
80
82
 
@@ -480,6 +482,7 @@ export class TsEmbed {
480
482
  hiddenListColumns: this.viewConfig.hiddenListColumns || [],
481
483
  customActions: customActionsResult.actions,
482
484
  ...getInterceptInitData(this.viewConfig),
485
+ ...getHostEventsConfig(this.viewConfig),
483
486
  };
484
487
 
485
488
  return baseInitData;
@@ -592,9 +595,11 @@ export class TsEmbed {
592
595
  return `${basePath}#`;
593
596
  }
594
597
 
595
- protected getUpdateEmbedParamsObject() {
598
+ protected async getUpdateEmbedParamsObject() {
596
599
  let queryParams = this.getEmbedParamsObject();
597
- queryParams = { ...this.viewConfig, ...queryParams, ...this.getAppInitData() };
600
+ const appInitData = await this.getAppInitData();
601
+ queryParams = { ...this.viewConfig, ...queryParams, ...appInitData };
602
+
598
603
  return queryParams;
599
604
  }
600
605
 
@@ -957,6 +962,8 @@ export class TsEmbed {
957
962
  preRenderWrapper.id = preRenderIds.wrapper;
958
963
  const initialPreRenderWrapperStyle = {
959
964
  position: 'absolute',
965
+ top: '0',
966
+ left: '0',
960
967
  width: '100vw',
961
968
  height: '100vh',
962
969
  };
@@ -1343,10 +1350,11 @@ export class TsEmbed {
1343
1350
  * @param {any} data The payload to send with the message
1344
1351
  * @returns A promise that resolves with the response from the embedded app
1345
1352
  */
1346
- public async trigger<HostEventT extends HostEvent, PayloadT>(
1353
+ public async trigger<HostEventT extends HostEvent, PayloadT, ContextT extends ContextType>(
1347
1354
  messageType: HostEventT,
1348
1355
  data: TriggerPayload<PayloadT, HostEventT> = {} as any,
1349
- ): Promise<TriggerResponse<PayloadT, HostEventT>> {
1356
+ context?: ContextT,
1357
+ ): Promise<TriggerResponse<PayloadT, HostEventT, ContextT>> {
1350
1358
  uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_TRIGGER}-${messageType}`);
1351
1359
 
1352
1360
  if (!this.isRendered) {
@@ -1379,7 +1387,7 @@ export class TsEmbed {
1379
1387
  }
1380
1388
 
1381
1389
  // send an empty object, this is needed for liveboard default handlers
1382
- return this.hostEventClient.triggerHostEvent(messageType, data);
1390
+ return this.hostEventClient.triggerHostEvent(messageType, data, context);
1383
1391
  }
1384
1392
 
1385
1393
  /**
@@ -1421,6 +1429,20 @@ export class TsEmbed {
1421
1429
  return this.render();
1422
1430
  }
1423
1431
 
1432
+ /**
1433
+ * Get the current context of the embedded TS component.
1434
+ * @returns The current context object containing the page type and object ids.
1435
+ * @version SDK: 1.46.0 | ThoughtSpot: 26.3.0.cl
1436
+ */
1437
+ public async getCurrentContext(): Promise<any> {
1438
+ return new Promise((resolve) => {
1439
+ this.executeAfterEmbedContainerLoaded(async () => {
1440
+ const context = await this.trigger(HostEvent.GetPageContext, {});
1441
+ resolve(context);
1442
+ });
1443
+ });
1444
+ }
1445
+
1424
1446
  /**
1425
1447
  * Creates the preRender shell
1426
1448
  * @param showPreRenderByDefault - Show the preRender after render, hidden by default
@@ -1574,8 +1596,19 @@ export class TsEmbed {
1574
1596
  }
1575
1597
  this.validatePreRenderViewConfig(this.viewConfig);
1576
1598
  logger.debug('triggering UpdateEmbedParams', this.viewConfig);
1577
- this.executeAfterEmbedContainerLoaded(() => {
1578
- this.trigger(HostEvent.UpdateEmbedParams, this.getUpdateEmbedParamsObject());
1599
+ this.executeAfterEmbedContainerLoaded(async () => {
1600
+ try {
1601
+ const params = await this.getUpdateEmbedParamsObject();
1602
+ this.trigger(HostEvent.UpdateEmbedParams, params);
1603
+ } catch (error) {
1604
+ logger.error(ERROR_MESSAGE.UPDATE_PARAMS_FAILED, error);
1605
+ this.handleError({
1606
+ errorType: ErrorDetailsTypes.API,
1607
+ message: error?.message || ERROR_MESSAGE.UPDATE_PARAMS_FAILED,
1608
+ code: EmbedErrorCodes.UPDATE_PARAMS_FAILED,
1609
+ error: error?.message || error,
1610
+ });
1611
+ }
1579
1612
  });
1580
1613
  }
1581
1614
 
@@ -1598,7 +1631,7 @@ export class TsEmbed {
1598
1631
  }
1599
1632
  }
1600
1633
 
1601
- removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events']);
1634
+ removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events', 'overflow']);
1602
1635
 
1603
1636
  this.subscribeToEvents();
1604
1637
 
@@ -1647,7 +1680,10 @@ export class TsEmbed {
1647
1680
  opacity: '0',
1648
1681
  pointerEvents: 'none',
1649
1682
  zIndex: '-1000',
1650
- position: 'absolute ',
1683
+ position: 'absolute',
1684
+ top: '0',
1685
+ left: '0',
1686
+ overflow: 'hidden',
1651
1687
  };
1652
1688
  setStyleProperties(this.preRenderWrapper, preRenderHideStyles);
1653
1689
 
package/src/errors.ts CHANGED
@@ -27,6 +27,8 @@ export const ERROR_MESSAGE = {
27
27
  HOST_EVENT_TYPE_UNDEFINED: 'Host event type is undefined',
28
28
  LOGIN_FAILED: 'Login failed',
29
29
  ERROR_PARSING_API_INTERCEPT_BODY: 'Error parsing api intercept body',
30
+ SSR_ENVIRONMENT_ERROR: 'SSR environment detected. This function cannot be called in SSR environment.',
31
+ UPDATE_PARAMS_FAILED: 'Failed to update embed parameters',
30
32
  };
31
33
 
32
34
  export const CUSTOM_ACTIONS_ERROR_MESSAGE = {
package/src/index.ts CHANGED
@@ -66,6 +66,9 @@ import {
66
66
  CustomActionsPosition,
67
67
  CustomActionTarget,
68
68
  InterceptedApiType,
69
+ EmbedErrorCodes,
70
+ ErrorDetailsTypes,
71
+ ContextType,
69
72
  } from './types';
70
73
  import { CustomCssVariables } from './css-variables';
71
74
  import { SageEmbed, SageViewConfig } from './embed/sage';
@@ -119,6 +122,7 @@ export {
119
122
  RuntimeFilterOp,
120
123
  EmbedEvent,
121
124
  HostEvent,
125
+ ContextType,
122
126
  DataSourceVisualMode,
123
127
  Action,
124
128
  ContextMenuTriggerOptions,
@@ -156,6 +160,8 @@ export {
156
160
  CustomActionsPosition,
157
161
  CustomActionTarget,
158
162
  InterceptedApiType,
163
+ EmbedErrorCodes,
164
+ ErrorDetailsTypes,
159
165
  };
160
166
 
161
167
  export { resetCachedAuthToken } from './authToken';
package/src/types.ts CHANGED
@@ -169,57 +169,71 @@ export enum AuthType {
169
169
  }
170
170
  /**
171
171
  *
172
- * This option does not apply to the classic homepage experience.
173
- * To access the updated modular homepage,
174
- * set `modularHomeExperience` to `true`
175
- * (available as Early Access feature in 9.12.5.cl).
172
+ * **Note**: This attribute is not supported in the classic (V1) homepage experience.
176
173
  *
177
174
  */
178
175
 
179
176
  export enum HomeLeftNavItem {
180
177
  /**
178
+ * The *Search data* option in
179
+ * the *Insights* left navigation panel.
181
180
  * @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
182
181
  */
183
182
  SearchData = 'search-data',
184
183
  /**
184
+ * The *Home* menu option in
185
+ * the *Insights* left navigation panel.
185
186
  * @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
186
187
  */
187
188
  Home = 'insights-home',
188
189
  /**
190
+ * The *Liveboards* menu option in
191
+ * the *Insights* left navigation panel.
189
192
  * @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
190
193
  */
191
194
  Liveboards = 'liveboards',
192
195
  /**
196
+ * The *Answers* menu option in
197
+ * the *Insights* left navigation panel.
193
198
  * @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
194
199
  */
195
200
  Answers = 'answers',
196
201
  /**
202
+ * The *Monitor subscriptions* menu option in
203
+ * the *Insights* left navigation panel.
197
204
  * @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
198
205
  */
199
206
  MonitorSubscription = 'monitor-alerts',
200
207
  /**
208
+ * The *SpotIQ analysis* menu option in
209
+ * the *Insights* left navigation panel.
201
210
  * @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
202
211
  */
203
212
  SpotIQAnalysis = 'spotiq-analysis',
204
213
  /**
214
+ * The *Liveboard schedules* menu option in
215
+ * the *Insights* left navigation panel.
205
216
  * @version SDK: 1.34.0| ThoughtSpot: 10.3.0.cl
206
217
  */
207
218
  LiveboardSchedules = 'liveboard-schedules',
208
219
  /**
209
- * Create new options in the insights left navigation,
210
- * available when new navigation V3 is enabled.
220
+ * The create option in the *Insights*
221
+ * left navigation panel.
222
+ * Available in the V3 navigation experience.
211
223
  * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
212
224
  */
213
225
  Create = 'create',
214
226
  /**
215
- * Spotter option in the insights left navigation,
216
- * available when new navigation V3 is enabled.
227
+ * The *Spotter* menu option in the *Insights*
228
+ * left navigation panel.
229
+ * Available in the V3 navigation experience.
217
230
  * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
218
231
  */
219
232
  Spotter = 'spotter',
220
233
  /**
221
- * Favorites option in the insights left navigation,
222
- * available when new navigation V3 is enabled.
234
+ * The *Favorites* section in the *Insights*
235
+ * left navigation panel.
236
+ * Available in the V3 navigation experience.
223
237
  * @version SDK: 1.41.0 | ThoughtSpot: 10.12.0.cl
224
238
  */
225
239
  Favorites = 'favorites',
@@ -1106,6 +1120,34 @@ export interface BaseViewConfig extends ApiInterceptFlags {
1106
1120
  * ```
1107
1121
  */
1108
1122
  customActions?: CustomAction[];
1123
+
1124
+ /**
1125
+ * Flag to bypass host events payload validation
1126
+ * @default false
1127
+ * @version SDK: 1.46.0 | ThoughtSpot: 26.3.0.cl
1128
+ * @example
1129
+ * ```js
1130
+ * const embed = new AppEmbed('#tsEmbed', {
1131
+ * ... // other embed view config
1132
+ * shouldBypassPayloadValidation:true,
1133
+ * })
1134
+ * ```
1135
+ */
1136
+ shouldBypassPayloadValidation?: boolean;
1137
+
1138
+ /**
1139
+ * Flag to use host events v2. This is used to enable the new host events v2 API.
1140
+ * @default false
1141
+ * @version SDK: 1.46.0 | ThoughtSpot: 26.3.0.cl
1142
+ * @example
1143
+ * ```js
1144
+ * const embed = new AppEmbed('#tsEmbed', {
1145
+ * ... // other embed view config
1146
+ * useHostEventsV2:true,
1147
+ * })
1148
+ * ```
1149
+ */
1150
+ useHostEventsV2?: boolean;
1109
1151
  }
1110
1152
 
1111
1153
  /**
@@ -1113,11 +1155,13 @@ export interface BaseViewConfig extends ApiInterceptFlags {
1113
1155
  */
1114
1156
  export interface HomePageConfig {
1115
1157
  /**
1116
- * Hide list page columns
1117
- * For example: hiddenListColumns = [ListPageColumns.Author]
1158
+ * Hide columns on list pages such as
1159
+ * *Liveboards* and *Answers*.
1160
+ * For example: `hiddenListColumns = [ListPageColumns.Author]`
1118
1161
  *
1119
- * **Note**: This option is currently available only in full app embedding and requires importing the ListPageColumns enum.
1120
- * At present, it can be used with Liveboard and Answer list pages, and starting with version 10.14.0.cl, it will also be supported for the Home page.
1162
+ * **Note**: This option is available only in full app embedding and requires importing the `ListPageColumns` enum.
1163
+ * Starting with version 10.14.0.cl, you can use this attribute to
1164
+ * hide the columns on all list pages in the *Insights* section.
1121
1165
  *
1122
1166
  * Supported embed types: `AppEmbed`
1123
1167
  * @version SDK: 1.38.0 | ThoughtSpot: 10.9.0.cl
@@ -1133,13 +1177,11 @@ export interface HomePageConfig {
1133
1177
  */
1134
1178
  hiddenListColumns?: ListPageColumns[];
1135
1179
  /**
1136
- * Hide the home page modules
1137
- * For example: hiddenHomepageModules = [HomepageModule.MyLibrary]
1180
+ * Control the visibility of home page modules.
1181
+ * To specify the modules, import the `HomepageModule` enum.
1182
+ * For example: `hiddenHomepageModules = [HomepageModule.MyLibrary]`
1138
1183
  *
1139
- * **Note**: This option does not apply to the classic homepage.
1140
- * To access the updated modular homepage, set
1141
- * `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
1142
- * To use it, you need to import `HomepageModule` enum.
1184
+ * **Note**: This attribute is not supported in the classic (v1) experience.
1143
1185
  *
1144
1186
  * Supported embed types: `AppEmbed`
1145
1187
  * @version SDK: 1.28.0 | ThoughtSpot: 9.12.5.cl, 10.1.0.sw
@@ -1148,20 +1190,18 @@ export interface HomePageConfig {
1148
1190
  * import { HomepageModule } from '@thoughtspot/visual-embed-sdk';
1149
1191
  *
1150
1192
  * const embed = new AppEmbed('#tsEmbed', {
1151
- * ... //other embed view config
1193
+ * ... // V2/V3 navigation and home page experience attributes
1152
1194
  * hiddenHomepageModules : [HomepageModule.Favorite,HomepageModule.Learning],
1195
+ * //...other embed view configuration attributes
1153
1196
  * })
1154
1197
  * ```
1155
1198
  */
1156
1199
  hiddenHomepageModules?: HomepageModule[];
1157
1200
  /**
1158
- * reordering the home page modules
1159
- * eg: reorderedHomepageModules = [HomepageModule.MyLibrary, HomepageModule.Watchlist]
1160
- *
1161
- * **Note**: This option does not apply to the classic homepage.
1162
- * To access the updated modular homepage, set
1163
- * `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
1164
- * To use it, you need to import `HomepageModule` enum.
1201
+ * Reorder home page modules.
1202
+ * To specify the modules, import the `HomepageModule` enum.
1203
+ * For example: `reorderedHomepageModules = [HomepageModule.MyLibrary, HomepageModule.Watchlist]`
1204
+ * **Note**: This attribute is not supported in the classic (v1) homepage.
1165
1205
  *
1166
1206
  * Supported embed types: `AppEmbed`
1167
1207
  * @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl, 10.1.0.sw
@@ -1170,16 +1210,19 @@ export interface HomePageConfig {
1170
1210
  * import { HomepageModule } from '@thoughtspot/visual-embed-sdk';
1171
1211
  *
1172
1212
  * const embed = new AppEmbed('#tsEmbed', {
1173
- * ... //other embed view config
1213
+ * ...//V2/V3 navigation and home page experience attributes
1174
1214
  * reorderedHomepageModules:[HomepageModule.Favorite,HomepageModule.MyLibrary],
1215
+ * //... other embed view configuration attributes
1175
1216
  * })
1176
1217
  * ```
1177
1218
  */
1178
1219
  reorderedHomepageModules?: HomepageModule[];
1179
1220
  /**
1180
- * homepageLeftNavItems : Show or hide the left navigation bar items.
1181
- * There are 8 eight home navigation list items.
1182
- * To hide these items, specify the string in the array.
1221
+ * Controls the visibility of the menu items
1222
+ * on the home page left navigation panel.
1223
+ * To specify the menu items, import the `HomeLeftNavItem` enum.
1224
+ *
1225
+ * **Note**: This attribute is not supported in the classic (v1) homepage.
1183
1226
  *
1184
1227
  * Supported embed types: `AppEmbed`
1185
1228
  * @example
@@ -1187,15 +1230,11 @@ export interface HomePageConfig {
1187
1230
  * import { HomeLeftNavItem } from '@thoughtspot/visual-embed-sdk';
1188
1231
  *
1189
1232
  * const embed = new AppEmbed('#tsEmbed', {
1190
- * ... //other embed view config
1233
+ * //... V2/V3 experience attributes
1191
1234
  * hiddenHomeLeftNavItems : [HomeLeftNavItem.Home,HomeLeftNavItem.Answers],
1235
+ * ... //other embed view configuration attributes
1192
1236
  * })
1193
1237
  * ```
1194
- *
1195
- * **Note**: This option does not apply to the classic homepage.
1196
- * To access the updated modular homepage, set
1197
- * `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
1198
- * To use it, you need to import `HomeLeftNavItem` enum.
1199
1238
  * @version SDK: 1.28.0 | ThoughtSpot: 9.12.5.cl, 10.1.0.sw
1200
1239
  */
1201
1240
  hiddenHomeLeftNavItems?: HomeLeftNavItem[];
@@ -1748,10 +1787,11 @@ export enum RuntimeFilterOp {
1748
1787
  }
1749
1788
 
1750
1789
  /**
1751
- * Home page module that can be hidden.
1752
- * **Note**: This option does not apply to the classic homepage.
1753
- * To access the updated modular homepage, set
1754
- * `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
1790
+ * Home page modules that can be hidden
1791
+ * via `hiddenHomepageModules` and reordered via
1792
+ * `reorderedHomepageModules`.
1793
+ *
1794
+ * **Note**: This option is not supported in the classic (v1) experience.
1755
1795
  * @version SDK: 1.28.0 | ThoughtSpot: 9.12.5.cl, 10.1.0.sw
1756
1796
  */
1757
1797
 
@@ -1765,7 +1805,7 @@ export enum HomepageModule {
1765
1805
  */
1766
1806
  Watchlist = 'WATCHLIST',
1767
1807
  /**
1768
- * favorite objects
1808
+ * Favorite module
1769
1809
  */
1770
1810
  Favorite = 'FAVORITE',
1771
1811
  /**
@@ -2960,6 +3000,28 @@ export enum EmbedEvent {
2960
3000
  * @version SDK: 1.39.0 | ThoughtSpot: 10.10.0.cl
2961
3001
  */
2962
3002
  PreviewSpotterData = 'PreviewSpotterData',
3003
+ /**
3004
+ * Emitted when user opens up the Add to Coaching modal on any visualization in Spotter Embed.
3005
+ * @example
3006
+ * ```js
3007
+ * spotterEmbed.on(EmbedEvent.AddToCoaching, (payload) => {
3008
+ * console.log('payload', payload);
3009
+ * })
3010
+ *```
3011
+ * @version SDK: 1.45.0 | ThoughtSpot: 26.2.0.cl
3012
+ */
3013
+ AddToCoaching = 'addToCoaching',
3014
+ /**
3015
+ * Emitted when user opens up the data model instructions modal in Spotter embed.
3016
+ * @example
3017
+ * ```js
3018
+ * spotterEmbed.on(EmbedEvent.DataModelInstructions, (payload) => {
3019
+ * console.log('payload', payload);
3020
+ * })
3021
+ * ```
3022
+ * @version SDK: 1.45.0 | ThoughtSpot: 26.2.0.cl
3023
+ */
3024
+ DataModelInstructions = 'DataModelInstructions',
2963
3025
  /**
2964
3026
  * Emitted when the Spotter query is triggered in Spotter embed.
2965
3027
  * @example
@@ -4385,6 +4447,26 @@ export enum HostEvent {
4385
4447
  * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
4386
4448
  */
4387
4449
  PreviewSpotterData = 'PreviewSpotterData',
4450
+ /**
4451
+ * Opens the Add to Coaching modal from a visualization in Spotter Embed.
4452
+ * @param - `vizId ` refers to the Visualization ID in Spotter embed and is required.
4453
+ * @example
4454
+ * ```js
4455
+ * spotterEmbed.trigger(HostEvent.AddToCoaching, { vizId: '730496d6-6903-4601-937e-2c691821af3c' });
4456
+ *
4457
+ *```
4458
+ * @version SDK: 1.45.0 | ThoughtSpot: 26.2.0.cl
4459
+ */
4460
+ AddToCoaching = 'addToCoaching',
4461
+ /**
4462
+ * Opens the data model instructions modal in Spotter Embed.
4463
+ * @example
4464
+ * ```js
4465
+ * spotterEmbed.trigger(HostEvent.DataModelInstructions);
4466
+ * ```
4467
+ * @version SDK: 1.45.0 | ThoughtSpot: 26.2.0.cl
4468
+ */
4469
+ DataModelInstructions = 'DataModelInstructions',
4388
4470
  /**
4389
4471
  * Resets the Spotter Embed Conversation.
4390
4472
  * @example
@@ -4488,6 +4570,16 @@ export enum HostEvent {
4488
4570
  * @version SDK: 1.45.0 | ThoughtSpot: 26.2.0.cl
4489
4571
  */
4490
4572
  StartNewSpotterConversation = 'StartNewSpotterConversation',
4573
+
4574
+ /**
4575
+ * Get the current context of the embedded page.
4576
+ * @example
4577
+ * ```js
4578
+ * const context = await liveboardEmbed.trigger(HostEvent.GetPageContext);
4579
+ * ```
4580
+ * @version SDK: 1.45.0 | ThoughtSpot: 26.2.0.cl
4581
+ */
4582
+ GetPageContext = 'GetPageContext',
4491
4583
  }
4492
4584
 
4493
4585
  /**
@@ -6298,6 +6390,9 @@ export enum EmbedErrorCodes {
6298
6390
 
6299
6391
  /** Error parsing api intercept body */
6300
6392
  PARSING_API_INTERCEPT_BODY_ERROR = 'PARSING_API_INTERCEPT_BODY_ERROR',
6393
+
6394
+ /** Failed to update embed parameters during pre-render */
6395
+ UPDATE_PARAMS_FAILED = 'UPDATE_PARAMS_FAILED',
6301
6396
  }
6302
6397
 
6303
6398
  /**
@@ -6371,6 +6466,14 @@ export interface EmbedErrorDetailsEvent {
6371
6466
  /** Additional context-specific for backward compatibility */
6372
6467
  [key: string]: any;
6373
6468
  }
6469
+
6470
+ export enum ContextType {
6471
+ Search = 'search-answer',
6472
+ Liveboard = 'liveboard',
6473
+ Answer = 'answer',
6474
+ Spotter = 'spotter',
6475
+ }
6476
+
6374
6477
  export interface DefaultAppInitData {
6375
6478
  customisations: CustomisationsInterface;
6376
6479
  authToken: string;
@@ -1,5 +1,5 @@
1
1
  import { ERROR_MESSAGE } from '../errors';
2
- import { HostEvent, MessagePayload } from '../types';
2
+ import { ContextType, HostEvent, MessagePayload } from '../types';
3
3
  import { logger } from '../utils/logger';
4
4
  import { handlePresentEvent } from '../utils';
5
5
  import { getEmbedConfig } from '../embed/embedConfig';
@@ -22,12 +22,13 @@ export const reload = (iFrame: HTMLIFrameElement) => {
22
22
  * @param message
23
23
  * @param message.type
24
24
  * @param message.data
25
+ * @param message.context
25
26
  * @param thoughtSpotHost
26
27
  * @param channel
27
28
  */
28
29
  function postIframeMessage(
29
30
  iFrame: HTMLIFrameElement,
30
- message: { type: HostEvent; data: any },
31
+ message: { type: HostEvent; data: any, context?: any },
31
32
  thoughtSpotHost: string,
32
33
  channel?: MessageChannel,
33
34
  ) {
@@ -42,12 +43,14 @@ export const TRIGGER_TIMEOUT = 30000;
42
43
  * @param messageType
43
44
  * @param thoughtSpotHost
44
45
  * @param data
46
+ * @param context
45
47
  */
46
48
  export function processTrigger(
47
49
  iFrame: HTMLIFrameElement,
48
50
  messageType: HostEvent,
49
51
  thoughtSpotHost: string,
50
52
  data: any,
53
+ context?: ContextType,
51
54
  ): Promise<any> {
52
55
  return new Promise<any>((res, rej) => {
53
56
  if (messageType === HostEvent.Reload) {
@@ -83,6 +86,6 @@ export function processTrigger(
83
86
  res(new Error(ERROR_MESSAGE.TRIGGER_TIMED_OUT));
84
87
  }, TRIGGER_TIMEOUT);
85
88
 
86
- return postIframeMessage(iFrame, { type: messageType, data }, thoughtSpotHost, channel);
89
+ return postIframeMessage(iFrame, { type: messageType, data, context }, thoughtSpotHost, channel);
87
90
  });
88
91
  }
package/src/utils.spec.ts CHANGED
@@ -20,9 +20,11 @@ import {
20
20
  calculateVisibleElementData,
21
21
  formatTemplate,
22
22
  isValidCssMargin,
23
+ resetValueFromWindow,
23
24
  } from './utils';
24
25
  import { RuntimeFilterOp } from './types';
25
26
  import { logger } from './utils/logger';
27
+ import { ERROR_MESSAGE } from './errors';
26
28
 
27
29
  // Mock logger
28
30
  jest.mock('./utils/logger', () => ({
@@ -747,3 +749,79 @@ describe('isValidCssMargin', () => {
747
749
  expect(isValidCssMargin('10')).toBe(false); // missing unit
748
750
  });
749
751
  });
752
+
753
+ describe('getValueFromWindow and storeValueInWindow', () => {
754
+ describe('SSR environment handling', () => {
755
+ let originalWindow: typeof globalThis.window;
756
+ beforeEach(() => {
757
+ originalWindow = global.window;
758
+ });
759
+
760
+ afterEach(() => {
761
+ global.window = originalWindow;
762
+ });
763
+
764
+ test('storeValueInWindow should log error in SSR environment', () => {
765
+ delete global.window;
766
+
767
+ const result = storeValueInWindow('testKey', 'testValue');
768
+
769
+ expect(logger.error).toHaveBeenCalledWith(
770
+ ERROR_MESSAGE.SSR_ENVIRONMENT_ERROR
771
+ );
772
+ expect(result).toBe('testValue');
773
+ });
774
+
775
+ test('getValueFromWindow should log error in SSR environment', () => {
776
+ delete global.window;
777
+
778
+ const result = getValueFromWindow('testKey');
779
+
780
+ expect(logger.error).toHaveBeenCalledWith(
781
+ ERROR_MESSAGE.SSR_ENVIRONMENT_ERROR
782
+ );
783
+ expect(result).toBeUndefined();
784
+ });
785
+
786
+ test('resetValueFromWindow should log error in SSR environment', () => {
787
+ delete global.window;
788
+
789
+ const result = resetValueFromWindow('testKey');
790
+
791
+ expect(logger.error).toHaveBeenCalledWith(
792
+ ERROR_MESSAGE.SSR_ENVIRONMENT_ERROR
793
+ );
794
+ expect(result).toBe(false);
795
+ });
796
+ });
797
+ describe('resetValueFromWindow', () => {
798
+ beforeEach(() => {
799
+ (window as any)._tsEmbedSDK = {};
800
+ });
801
+
802
+ test('should reset existing key and return true', () => {
803
+ storeValueInWindow('keyToReset', 'someValue');
804
+ expect(getValueFromWindow('keyToReset')).toBe('someValue');
805
+
806
+ const result = resetValueFromWindow('keyToReset');
807
+
808
+ expect(result).toBe(true);
809
+ expect(getValueFromWindow('keyToReset')).toBe(undefined);
810
+ });
811
+
812
+ test('should return false when key does not exist', () => {
813
+ const result = resetValueFromWindow('nonExistentKey');
814
+ expect(result).toBe(false);
815
+ });
816
+
817
+ test('should only reset the specified key', () => {
818
+ storeValueInWindow('key1', 'value1');
819
+ storeValueInWindow('key2', 'value2');
820
+
821
+ resetValueFromWindow('key1');
822
+
823
+ expect(getValueFromWindow('key1')).toBe(undefined);
824
+ expect(getValueFromWindow('key2')).toBe('value2');
825
+ });
826
+ });
827
+ });