@thoughtspot/visual-embed-sdk 1.44.1 → 1.44.3

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 (246) hide show
  1. package/cjs/package.json +6 -5
  2. package/cjs/src/api-intercept.d.ts.map +1 -1
  3. package/cjs/src/api-intercept.js +8 -3
  4. package/cjs/src/api-intercept.js.map +1 -1
  5. package/cjs/src/api-intercept.spec.js +19 -3
  6. package/cjs/src/api-intercept.spec.js.map +1 -1
  7. package/cjs/src/auth.spec.js +43 -42
  8. package/cjs/src/auth.spec.js.map +1 -1
  9. package/cjs/src/authToken.spec.js +3 -3
  10. package/cjs/src/authToken.spec.js.map +1 -1
  11. package/cjs/src/embed/app.d.ts +17 -0
  12. package/cjs/src/embed/app.d.ts.map +1 -1
  13. package/cjs/src/embed/app.js +9 -5
  14. package/cjs/src/embed/app.js.map +1 -1
  15. package/cjs/src/embed/app.spec.js +96 -6
  16. package/cjs/src/embed/app.spec.js.map +1 -1
  17. package/cjs/src/embed/base.d.ts +1 -1
  18. package/cjs/src/embed/base.d.ts.map +1 -1
  19. package/cjs/src/embed/base.js +4 -0
  20. package/cjs/src/embed/base.js.map +1 -1
  21. package/cjs/src/embed/base.spec.js +71 -15
  22. package/cjs/src/embed/base.spec.js.map +1 -1
  23. package/cjs/src/embed/bodyless-conversation.spec.js +2 -2
  24. package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
  25. package/cjs/src/embed/conversation.d.ts.map +1 -1
  26. package/cjs/src/embed/conversation.js +6 -1
  27. package/cjs/src/embed/conversation.js.map +1 -1
  28. package/cjs/src/embed/conversation.spec.js +8 -3
  29. package/cjs/src/embed/conversation.spec.js.map +1 -1
  30. package/cjs/src/embed/embed.spec.js +101 -2
  31. package/cjs/src/embed/embed.spec.js.map +1 -1
  32. package/cjs/src/embed/events.spec.js +2 -2
  33. package/cjs/src/embed/events.spec.js.map +1 -1
  34. package/cjs/src/embed/hostEventClient/host-event-client.spec.js +1 -1
  35. package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  36. package/cjs/src/embed/liveboard.d.ts +18 -0
  37. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  38. package/cjs/src/embed/liveboard.js +13 -6
  39. package/cjs/src/embed/liveboard.js.map +1 -1
  40. package/cjs/src/embed/liveboard.spec.js +114 -26
  41. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  42. package/cjs/src/embed/pinboard.spec.js +1 -1
  43. package/cjs/src/embed/pinboard.spec.js.map +1 -1
  44. package/cjs/src/embed/sage.spec.js +2 -2
  45. package/cjs/src/embed/sage.spec.js.map +1 -1
  46. package/cjs/src/embed/search.spec.js +118 -2
  47. package/cjs/src/embed/search.spec.js.map +1 -1
  48. package/cjs/src/embed/ts-embed-trigger.spec.js +2 -3
  49. package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -1
  50. package/cjs/src/embed/ts-embed.d.ts +3 -2
  51. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  52. package/cjs/src/embed/ts-embed.js +51 -17
  53. package/cjs/src/embed/ts-embed.js.map +1 -1
  54. package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
  55. package/cjs/src/embed/ts-embed.spec.js +335 -71
  56. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  57. package/cjs/src/errors.d.ts +8 -0
  58. package/cjs/src/errors.d.ts.map +1 -1
  59. package/cjs/src/errors.js +8 -0
  60. package/cjs/src/errors.js.map +1 -1
  61. package/cjs/src/mixpanel-service.spec.js +1 -1
  62. package/cjs/src/mixpanel-service.spec.js.map +1 -1
  63. package/cjs/src/react/index.spec.js +3 -4
  64. package/cjs/src/react/index.spec.js.map +1 -1
  65. package/cjs/src/test/test-utils.js +1 -1
  66. package/cjs/src/test/test-utils.js.map +1 -1
  67. package/cjs/src/types.d.ts +194 -1
  68. package/cjs/src/types.d.ts.map +1 -1
  69. package/cjs/src/types.js +94 -2
  70. package/cjs/src/types.js.map +1 -1
  71. package/cjs/src/utils/authService/authService.spec.js +8 -8
  72. package/cjs/src/utils/authService/authService.spec.js.map +1 -1
  73. package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
  74. package/cjs/src/utils/graphql/answerService/answerService.spec.js +1 -1
  75. package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  76. package/cjs/src/utils/graphql/graphql-request.spec.js +1 -1
  77. package/cjs/src/utils/graphql/graphql-request.spec.js.map +1 -1
  78. package/cjs/src/utils/graphql/sourceService.spec.js +1 -1
  79. package/cjs/src/utils/graphql/sourceService.spec.js.map +1 -1
  80. package/cjs/src/utils/logger.spec.d.ts +5 -20
  81. package/cjs/src/utils/logger.spec.d.ts.map +1 -1
  82. package/cjs/src/utils/processData.spec.js +17 -17
  83. package/cjs/src/utils/processData.spec.js.map +1 -1
  84. package/cjs/src/utils/processTrigger.spec.js +8 -8
  85. package/cjs/src/utils/processTrigger.spec.js.map +1 -1
  86. package/cjs/src/utils.d.ts +16 -3
  87. package/cjs/src/utils.d.ts.map +1 -1
  88. package/cjs/src/utils.js +60 -5
  89. package/cjs/src/utils.js.map +1 -1
  90. package/cjs/src/utils.spec.js +72 -10
  91. package/cjs/src/utils.spec.js.map +1 -1
  92. package/dist/{index-BE9gGzRX.js → index-D0n5LIka.js} +1 -1
  93. package/dist/src/api-intercept.d.ts.map +1 -1
  94. package/dist/src/embed/app.d.ts +17 -0
  95. package/dist/src/embed/app.d.ts.map +1 -1
  96. package/dist/src/embed/base.d.ts +1 -1
  97. package/dist/src/embed/base.d.ts.map +1 -1
  98. package/dist/src/embed/conversation.d.ts.map +1 -1
  99. package/dist/src/embed/liveboard.d.ts +18 -0
  100. package/dist/src/embed/liveboard.d.ts.map +1 -1
  101. package/dist/src/embed/ts-embed.d.ts +3 -2
  102. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  103. package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
  104. package/dist/src/errors.d.ts +8 -0
  105. package/dist/src/errors.d.ts.map +1 -1
  106. package/dist/src/types.d.ts +194 -1
  107. package/dist/src/types.d.ts.map +1 -1
  108. package/dist/src/utils/logger.spec.d.ts +5 -20
  109. package/dist/src/utils/logger.spec.d.ts.map +1 -1
  110. package/dist/src/utils.d.ts +16 -3
  111. package/dist/src/utils.d.ts.map +1 -1
  112. package/dist/tsembed-react.es.js +282 -74
  113. package/dist/tsembed-react.js +281 -73
  114. package/dist/tsembed.es.js +282 -74
  115. package/dist/tsembed.js +281 -73
  116. package/dist/visual-embed-sdk-react-full.d.ts +185 -3
  117. package/dist/visual-embed-sdk-react.d.ts +184 -2
  118. package/dist/visual-embed-sdk.d.ts +185 -3
  119. package/lib/package.json +6 -5
  120. package/lib/src/api-intercept.d.ts.map +1 -1
  121. package/lib/src/api-intercept.js +9 -4
  122. package/lib/src/api-intercept.js.map +1 -1
  123. package/lib/src/api-intercept.spec.js +20 -4
  124. package/lib/src/api-intercept.spec.js.map +1 -1
  125. package/lib/src/auth.spec.js +43 -42
  126. package/lib/src/auth.spec.js.map +1 -1
  127. package/lib/src/authToken.spec.js +3 -3
  128. package/lib/src/authToken.spec.js.map +1 -1
  129. package/lib/src/embed/app.d.ts +17 -0
  130. package/lib/src/embed/app.d.ts.map +1 -1
  131. package/lib/src/embed/app.js +10 -6
  132. package/lib/src/embed/app.js.map +1 -1
  133. package/lib/src/embed/app.spec.js +96 -6
  134. package/lib/src/embed/app.spec.js.map +1 -1
  135. package/lib/src/embed/base.d.ts +1 -1
  136. package/lib/src/embed/base.d.ts.map +1 -1
  137. package/lib/src/embed/base.js +5 -1
  138. package/lib/src/embed/base.js.map +1 -1
  139. package/lib/src/embed/base.spec.js +72 -16
  140. package/lib/src/embed/base.spec.js.map +1 -1
  141. package/lib/src/embed/bodyless-conversation.spec.js +2 -2
  142. package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
  143. package/lib/src/embed/conversation.d.ts.map +1 -1
  144. package/lib/src/embed/conversation.js +7 -2
  145. package/lib/src/embed/conversation.js.map +1 -1
  146. package/lib/src/embed/conversation.spec.js +9 -4
  147. package/lib/src/embed/conversation.spec.js.map +1 -1
  148. package/lib/src/embed/embed.spec.js +103 -4
  149. package/lib/src/embed/embed.spec.js.map +1 -1
  150. package/lib/src/embed/events.spec.js +2 -2
  151. package/lib/src/embed/events.spec.js.map +1 -1
  152. package/lib/src/embed/hostEventClient/host-event-client.spec.js +2 -2
  153. package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  154. package/lib/src/embed/liveboard.d.ts +18 -0
  155. package/lib/src/embed/liveboard.d.ts.map +1 -1
  156. package/lib/src/embed/liveboard.js +15 -8
  157. package/lib/src/embed/liveboard.js.map +1 -1
  158. package/lib/src/embed/liveboard.spec.js +114 -26
  159. package/lib/src/embed/liveboard.spec.js.map +1 -1
  160. package/lib/src/embed/pinboard.spec.js +1 -1
  161. package/lib/src/embed/pinboard.spec.js.map +1 -1
  162. package/lib/src/embed/sage.spec.js +2 -2
  163. package/lib/src/embed/sage.spec.js.map +1 -1
  164. package/lib/src/embed/search.spec.js +118 -2
  165. package/lib/src/embed/search.spec.js.map +1 -1
  166. package/lib/src/embed/ts-embed-trigger.spec.js +2 -3
  167. package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -1
  168. package/lib/src/embed/ts-embed.d.ts +3 -2
  169. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  170. package/lib/src/embed/ts-embed.js +52 -18
  171. package/lib/src/embed/ts-embed.js.map +1 -1
  172. package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
  173. package/lib/src/embed/ts-embed.spec.js +336 -72
  174. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  175. package/lib/src/errors.d.ts +8 -0
  176. package/lib/src/errors.d.ts.map +1 -1
  177. package/lib/src/errors.js +8 -0
  178. package/lib/src/errors.js.map +1 -1
  179. package/lib/src/mixpanel-service.spec.js +1 -1
  180. package/lib/src/mixpanel-service.spec.js.map +1 -1
  181. package/lib/src/react/index.spec.js +3 -4
  182. package/lib/src/react/index.spec.js.map +1 -1
  183. package/lib/src/test/test-utils.js +1 -1
  184. package/lib/src/test/test-utils.js.map +1 -1
  185. package/lib/src/types.d.ts +194 -1
  186. package/lib/src/types.d.ts.map +1 -1
  187. package/lib/src/types.js +93 -1
  188. package/lib/src/types.js.map +1 -1
  189. package/lib/src/utils/authService/authService.spec.js +8 -8
  190. package/lib/src/utils/authService/authService.spec.js.map +1 -1
  191. package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -1
  192. package/lib/src/utils/graphql/answerService/answerService.spec.js +1 -1
  193. package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  194. package/lib/src/utils/graphql/graphql-request.spec.js +1 -1
  195. package/lib/src/utils/graphql/graphql-request.spec.js.map +1 -1
  196. package/lib/src/utils/graphql/sourceService.spec.js +1 -1
  197. package/lib/src/utils/graphql/sourceService.spec.js.map +1 -1
  198. package/lib/src/utils/logger.spec.d.ts +5 -20
  199. package/lib/src/utils/logger.spec.d.ts.map +1 -1
  200. package/lib/src/utils/processData.spec.js +17 -17
  201. package/lib/src/utils/processData.spec.js.map +1 -1
  202. package/lib/src/utils/processTrigger.spec.js +8 -8
  203. package/lib/src/utils/processTrigger.spec.js.map +1 -1
  204. package/lib/src/utils.d.ts +16 -3
  205. package/lib/src/utils.d.ts.map +1 -1
  206. package/lib/src/utils.js +57 -4
  207. package/lib/src/utils.js.map +1 -1
  208. package/lib/src/utils.spec.js +73 -11
  209. package/lib/src/utils.spec.js.map +1 -1
  210. package/package.json +6 -5
  211. package/src/api-intercept.spec.ts +23 -10
  212. package/src/api-intercept.ts +9 -4
  213. package/src/auth.spec.ts +53 -51
  214. package/src/authToken.spec.ts +3 -3
  215. package/src/embed/app.spec.ts +128 -7
  216. package/src/embed/app.ts +30 -4
  217. package/src/embed/base.spec.ts +95 -21
  218. package/src/embed/base.ts +5 -2
  219. package/src/embed/bodyless-conversation.spec.ts +2 -2
  220. package/src/embed/conversation.spec.ts +9 -4
  221. package/src/embed/conversation.ts +7 -2
  222. package/src/embed/embed.spec.ts +122 -2
  223. package/src/embed/events.spec.ts +2 -2
  224. package/src/embed/hostEventClient/host-event-client.spec.ts +2 -2
  225. package/src/embed/liveboard.spec.ts +137 -29
  226. package/src/embed/liveboard.ts +36 -6
  227. package/src/embed/pinboard.spec.ts +1 -1
  228. package/src/embed/sage.spec.ts +2 -2
  229. package/src/embed/search.spec.ts +133 -2
  230. package/src/embed/ts-embed-trigger.spec.ts +2 -3
  231. package/src/embed/ts-embed.spec.ts +424 -91
  232. package/src/embed/ts-embed.ts +56 -19
  233. package/src/errors.ts +8 -0
  234. package/src/mixpanel-service.spec.ts +1 -1
  235. package/src/react/index.spec.tsx +4 -5
  236. package/src/test/test-utils.ts +2 -2
  237. package/src/types.ts +206 -1
  238. package/src/utils/authService/authService.spec.ts +17 -17
  239. package/src/utils/authService/tokenizedAuthService.spec.ts +4 -4
  240. package/src/utils/graphql/answerService/answerService.spec.ts +3 -3
  241. package/src/utils/graphql/graphql-request.spec.ts +2 -2
  242. package/src/utils/graphql/sourceService.spec.ts +1 -1
  243. package/src/utils/processData.spec.ts +26 -26
  244. package/src/utils/processTrigger.spec.ts +8 -8
  245. package/src/utils.spec.ts +100 -11
  246. package/src/utils.ts +59 -7
@@ -57,6 +57,9 @@ import {
57
57
  ContextMenuTriggerOptions,
58
58
  DefaultAppInitData,
59
59
  AllEmbedViewConfig as ViewConfig,
60
+ EmbedErrorDetailsEvent,
61
+ ErrorDetailsTypes,
62
+ EmbedErrorCodes,
60
63
  } from '../types';
61
64
  import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
62
65
  import { processEventData, processAuthFailure } from '../utils/processData';
@@ -218,20 +221,24 @@ export class TsEmbed {
218
221
  * Throws error encountered during initialization.
219
222
  */
220
223
  private throwInitError() {
221
- this.handleError('You need to init the ThoughtSpot SDK module first');
224
+ this.handleError({
225
+ errorType: ErrorDetailsTypes.VALIDATION_ERROR,
226
+ message: ERROR_MESSAGE.INIT_SDK_REQUIRED,
227
+ code: EmbedErrorCodes.INIT_ERROR,
228
+ error : ERROR_MESSAGE.INIT_SDK_REQUIRED,
229
+ });
222
230
  }
223
231
 
224
232
  /**
225
233
  * Handles errors within the SDK
226
234
  * @param error The error message or object
235
+ * @param errorDetails The error details
227
236
  */
228
- protected handleError(error: string | Record<string, unknown>) {
237
+ protected handleError(errorDetails: EmbedErrorDetailsEvent) {
229
238
  this.isError = true;
230
- this.executeCallbacks(EmbedEvent.Error, {
231
- error,
232
- });
239
+ this.executeCallbacks(EmbedEvent.Error, errorDetails);
233
240
  // Log error
234
- logger.error(error);
241
+ logger.error(errorDetails);
235
242
  }
236
243
 
237
244
  /**
@@ -325,11 +332,14 @@ export class TsEmbed {
325
332
  window.addEventListener('online', onlineEventListener);
326
333
 
327
334
  const offlineEventListener = (e: Event) => {
328
- const offlineWarning = ERROR_MESSAGE.OFFLINE_WARNING;
329
- this.executeCallbacks(EmbedEvent.Error, {
330
- offlineWarning,
331
- });
332
- logger.warn(offlineWarning);
335
+ const errorDetails = {
336
+ errorType: ErrorDetailsTypes.NETWORK,
337
+ message: ERROR_MESSAGE.OFFLINE_WARNING,
338
+ code: EmbedErrorCodes.NETWORK_ERROR,
339
+ offlineWarning : ERROR_MESSAGE.OFFLINE_WARNING,
340
+ };
341
+ this.executeCallbacks(EmbedEvent.Error, errorDetails);
342
+ logger.warn(errorDetails);
333
343
  };
334
344
  window.addEventListener('offline', offlineEventListener);
335
345
 
@@ -444,9 +454,11 @@ export class TsEmbed {
444
454
  ]);
445
455
  if (customActionsResult.errors.length > 0) {
446
456
  this.handleError({
447
- type: 'CUSTOM_ACTION_VALIDATION',
448
- message: customActionsResult.errors,
449
- });
457
+ errorType: ErrorDetailsTypes.VALIDATION_ERROR,
458
+ message: customActionsResult.errors,
459
+ code: EmbedErrorCodes.CUSTOM_ACTION_VALIDATION,
460
+ error : { type: EmbedErrorCodes.CUSTOM_ACTION_VALIDATION, message: customActionsResult.errors }
461
+ });
450
462
  }
451
463
  const baseInitData = {
452
464
  customisations: getCustomisations(this.embedConfig, this.viewConfig),
@@ -658,12 +670,22 @@ export class TsEmbed {
658
670
  };
659
671
 
660
672
  if (Array.isArray(visibleActions) && Array.isArray(hiddenActions)) {
661
- this.handleError('You cannot have both hidden actions and visible actions');
673
+ this.handleError({
674
+ errorType: ErrorDetailsTypes.VALIDATION_ERROR,
675
+ message: ERROR_MESSAGE.CONFLICTING_ACTIONS_CONFIG,
676
+ code: EmbedErrorCodes.CONFLICTING_ACTIONS_CONFIG,
677
+ error : ERROR_MESSAGE.CONFLICTING_ACTIONS_CONFIG,
678
+ });
662
679
  return queryParams;
663
680
  }
664
681
 
665
682
  if (Array.isArray(visibleTabs) && Array.isArray(hiddenTabs)) {
666
- this.handleError('You cannot have both hidden Tabs and visible Tabs');
683
+ this.handleError({
684
+ errorType: ErrorDetailsTypes.VALIDATION_ERROR,
685
+ message: ERROR_MESSAGE.CONFLICTING_TABS_CONFIG,
686
+ code: EmbedErrorCodes.CONFLICTING_TABS_CONFIG,
687
+ error : ERROR_MESSAGE.CONFLICTING_TABS_CONFIG,
688
+ });
667
689
  return queryParams;
668
690
  }
669
691
  if (primaryAction) {
@@ -916,7 +938,12 @@ export class TsEmbed {
916
938
  error: JSON.stringify(error),
917
939
  });
918
940
  this.handleInsertionIntoDOM(this.embedConfig.loginFailedMessage);
919
- this.handleError(error);
941
+ this.handleError({
942
+ errorType: ErrorDetailsTypes.API,
943
+ message: error.message || ERROR_MESSAGE.LOGIN_FAILED,
944
+ code: EmbedErrorCodes.LOGIN_FAILED,
945
+ error : error,
946
+ });
920
947
  });
921
948
  });
922
949
  }
@@ -1323,12 +1350,22 @@ export class TsEmbed {
1323
1350
  uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_TRIGGER}-${messageType}`);
1324
1351
 
1325
1352
  if (!this.isRendered) {
1326
- this.handleError('Please call render before triggering events');
1353
+ this.handleError({
1354
+ errorType: ErrorDetailsTypes.VALIDATION_ERROR,
1355
+ message: ERROR_MESSAGE.RENDER_BEFORE_EVENTS_REQUIRED,
1356
+ code: EmbedErrorCodes.RENDER_NOT_CALLED,
1357
+ error: ERROR_MESSAGE.RENDER_BEFORE_EVENTS_REQUIRED,
1358
+ });
1327
1359
  return null;
1328
1360
  }
1329
1361
 
1330
1362
  if (!messageType) {
1331
- this.handleError('Host event type is undefined');
1363
+ this.handleError({
1364
+ errorType: ErrorDetailsTypes.VALIDATION_ERROR,
1365
+ message: ERROR_MESSAGE.HOST_EVENT_TYPE_UNDEFINED,
1366
+ code: EmbedErrorCodes.HOST_EVENT_TYPE_UNDEFINED,
1367
+ error: ERROR_MESSAGE.HOST_EVENT_TYPE_UNDEFINED,
1368
+ });
1332
1369
  return null;
1333
1370
  }
1334
1371
 
package/src/errors.ts CHANGED
@@ -20,6 +20,14 @@ export const ERROR_MESSAGE = {
20
20
  RENDER_CALLED_BEFORE_INIT: 'Looks like render was called before calling init, the render won\'t start until init is called.\nFor more info check\n1. https://developers.thoughtspot.com/docs/Function_init#_init\n2.https://developers.thoughtspot.com/docs/getting-started#initSdk',
21
21
  SPOTTER_AGENT_NOT_INITIALIZED: 'SpotterAgent not initialized',
22
22
  OFFLINE_WARNING : 'Network not Detected. Embed is offline. Please reconnect and refresh',
23
+ INIT_SDK_REQUIRED: 'You need to init the ThoughtSpot SDK module first',
24
+ CONFLICTING_ACTIONS_CONFIG: 'You cannot have both hidden actions and visible actions',
25
+ CONFLICTING_TABS_CONFIG: 'You cannot have both hidden Tabs and visible Tabs',
26
+ RENDER_BEFORE_EVENTS_REQUIRED: 'Please call render before triggering events',
27
+ HOST_EVENT_TYPE_UNDEFINED: 'Host event type is undefined',
28
+ LOGIN_FAILED: 'Login failed',
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.',
23
31
  };
24
32
 
25
33
  export const CUSTOM_ACTIONS_ERROR_MESSAGE = {
@@ -82,7 +82,7 @@ describe('Unit test for mixpanel', () => {
82
82
  });
83
83
 
84
84
  test('init mixpanel with no mixpanel token', () => {
85
- jest.spyOn(logger, 'error').mockReturnValueOnce(true);
85
+ jest.spyOn(logger, 'error').mockImplementation(() => {});
86
86
  initMixpanel({ test: 'dummy' } as any);
87
87
  expect(logger.error).toHaveBeenCalled();
88
88
  expect(mixpanel.register_once).not.toHaveBeenCalled();
@@ -34,11 +34,11 @@ beforeAll(() => {
34
34
  thoughtSpotHost,
35
35
  authType: AuthType.None,
36
36
  });
37
- jest.spyOn(auth, 'postLoginService').mockReturnValue(true);
37
+ jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve(undefined));
38
38
  jest.spyOn(sessionService, 'getSessionInfo').mockReturnValue({
39
39
  userGUID: 'abcd',
40
- });
41
- spyOn(window, 'alert');
40
+ } as any);
41
+ jest.spyOn(window, 'alert');
42
42
  });
43
43
 
44
44
  describe('React Components', () => {
@@ -60,7 +60,7 @@ describe('React Components', () => {
60
60
  );
61
61
  });
62
62
 
63
- it('Should attach event listeners', async (done) => {
63
+ it('Should attach event listeners', async () => {
64
64
  const userGUID = 'absfdfgd';
65
65
  const { container } = render(
66
66
  <SearchEmbed
@@ -69,7 +69,6 @@ describe('React Components', () => {
69
69
  }}
70
70
  onAuthInit={(e) => {
71
71
  expect(e.data.userGUID).toEqual(userGUID);
72
- done();
73
72
  }}
74
73
  />,
75
74
  );
@@ -8,8 +8,8 @@ import { Action, AuthType } from '../types';
8
8
  if (!(global.fetch as any).mockResponse) {
9
9
  console.log('mocking fetch');
10
10
  global.fetch = jest.fn(() => Promise.resolve({
11
- json: () => ({ mixpanelAccessToken: '' }),
12
- }));
11
+ json: () => Promise.resolve({ mixpanelAccessToken: '' }),
12
+ } as Response));
13
13
  }
14
14
 
15
15
  export const defaultParamsWithoutHiddenActions = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=${AuthType.None}&blockNonEmbedFullAppAccess=true`;
package/src/types.ts CHANGED
@@ -1584,6 +1584,38 @@ export interface LiveboardAppEmbedViewConfig {
1584
1584
  * ```
1585
1585
  */
1586
1586
  isEnhancedFilterInteractivityEnabled?: boolean;
1587
+ /**
1588
+ * Show or hide masked filter chips
1589
+ *
1590
+ * Supported embed types: `AppEmbed`, `LiveboardEmbed`
1591
+ * @version SDK: 1.45.0 | Thoughtspot: 26.2.0.cl
1592
+ * @default false
1593
+ * @example
1594
+ * ```js
1595
+ * // Replace <EmbedComponent> with embed component name. For example, AppEmbed or LiveboardEmbed
1596
+ * const embed = new <EmbedComponent>('#tsEmbed', {
1597
+ * ... // other embed view config
1598
+ * showMaskedFilterChip: true,
1599
+ * })
1600
+ * ```
1601
+ */
1602
+ showMaskedFilterChip?: boolean;
1603
+ /**
1604
+ * Enable or disable Liveboard styling and grouping
1605
+ *
1606
+ * Supported embed types: `AppEmbed`, `LiveboardEmbed`
1607
+ * @version SDK: 1.45.0 | Thoughtspot: 26.2.0.cl
1608
+ * @default false
1609
+ * @example
1610
+ * ```js
1611
+ * // Replace <EmbedComponent> with embed component name. For example, AppEmbed or LiveboardEmbed
1612
+ * const embed = new <EmbedComponent>('#tsEmbed', {
1613
+ * ... // other embed view config
1614
+ * isLiveboardMasterpiecesEnabled: true,
1615
+ * })
1616
+ * ```
1617
+ */
1618
+ isLiveboardMasterpiecesEnabled?: boolean;
1587
1619
  }
1588
1620
 
1589
1621
  export interface AllEmbedViewConfig
@@ -2045,6 +2077,7 @@ export enum EmbedEvent {
2045
2077
  * SearchEmbed.on(EmbedEvent.Error, (error) => {
2046
2078
  * console.log(error);
2047
2079
  * // { type: "Error", data: { errorType: "API", error: { message: '...', error: '...' } } }
2080
+ * // { errorType: "API", message: '...', code: '...' } new format
2048
2081
  * });
2049
2082
  * ```
2050
2083
  * @example
@@ -2056,6 +2089,7 @@ export enum EmbedEvent {
2056
2089
  * // message: "Fullscreen API is not enabled",
2057
2090
  * // stack: "..."
2058
2091
  * // } }}
2092
+ * // { errorType: "FULLSCREEN", message: "Fullscreen API is not enabled", code: '...' } new format
2059
2093
  * })
2060
2094
  * ```
2061
2095
  */
@@ -2213,7 +2247,8 @@ export enum EmbedEvent {
2213
2247
  */
2214
2248
  ALL = '*',
2215
2249
  /**
2216
- * Emitted when an Answer is saved in the app
2250
+ * Emitted when an Answer is saved in the app.
2251
+ * Use start:true to subscribe to when save is initiated, or end:true to subscribe to when save is completed. Default is end:true.
2217
2252
  * @Version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw
2218
2253
  * @example
2219
2254
  *```js
@@ -2248,6 +2283,7 @@ export enum EmbedEvent {
2248
2283
  Download = 'download',
2249
2284
  /**
2250
2285
  * Emitted when the download action is triggered on an Answer.
2286
+ * Use start:true to subscribe to when download is initiated, or end:true to subscribe to when download is completed. Default is end:true.
2251
2287
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl, 9.4.0.sw
2252
2288
  * @example
2253
2289
  *```js
@@ -2262,6 +2298,7 @@ export enum EmbedEvent {
2262
2298
  DownloadAsPng = 'downloadAsPng',
2263
2299
  /**
2264
2300
  * Emitted when the Download as PDF action is triggered on an Answer
2301
+ * Use start:true to subscribe to when download as PDF is initiated, or end:true to subscribe to when download as PDF is completed. Default is end:true.
2265
2302
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw
2266
2303
  * @example
2267
2304
  *```js
@@ -2276,6 +2313,7 @@ export enum EmbedEvent {
2276
2313
  DownloadAsPdf = 'downloadAsPdf',
2277
2314
  /**
2278
2315
  * Emitted when the Download as CSV action is triggered on an Answer.
2316
+ * Use start:true to subscribe to when download as CSV is initiated, or end:true to subscribe to when download as CSV is completed. Default is end:true.
2279
2317
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw
2280
2318
  * @example
2281
2319
  *```js
@@ -2290,6 +2328,7 @@ export enum EmbedEvent {
2290
2328
  DownloadAsCsv = 'downloadAsCsv',
2291
2329
  /**
2292
2330
  * Emitted when the Download as XLSX action is triggered on an Answer.
2331
+ * Use start:true to subscribe to when download as XLSX is initiated, or end:true to subscribe to when download as XLSX is completed. Default is end:true.
2293
2332
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw
2294
2333
  * @example
2295
2334
  *```js
@@ -2304,6 +2343,7 @@ export enum EmbedEvent {
2304
2343
  DownloadAsXlsx = 'downloadAsXlsx',
2305
2344
  /**
2306
2345
  * Emitted when an Answer is deleted in the app
2346
+ * Use start:true to subscribe to when delete is initiated, or end:true to subscribe to when delete is completed. Default is end:true.
2307
2347
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw
2308
2348
  * @example
2309
2349
  *```js
@@ -2330,6 +2370,7 @@ export enum EmbedEvent {
2330
2370
  /**
2331
2371
  * Emitted when a user initiates the Pin action to
2332
2372
  * add an Answer to a Liveboard.
2373
+ * Use start:true to subscribe to when pin is initiated, or end:true to subscribe to when pin is completed. Default is end:true.
2333
2374
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw
2334
2375
  * @example
2335
2376
  *```js
@@ -2443,6 +2484,7 @@ export enum EmbedEvent {
2443
2484
  /**
2444
2485
  * Emitted when the **Export TML** action is triggered on an
2445
2486
  * an embedded object in the app
2487
+ * Use start:true to subscribe to when export is initiated, or end:true to subscribe to when export is completed. Default is end:true.
2446
2488
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw
2447
2489
  * @example
2448
2490
  *```js
@@ -2468,6 +2510,7 @@ export enum EmbedEvent {
2468
2510
  SaveAsView = 'saveAsView',
2469
2511
  /**
2470
2512
  * Emitted when the user creates a copy of an Answer.
2513
+ * Use start:true to subscribe to when copy and edit is initiated, or end:true to subscribe to when copy and edit is completed. Default is end:true.
2471
2514
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw
2472
2515
  * @example
2473
2516
  *```js
@@ -4543,6 +4586,8 @@ export enum Param {
4543
4586
  HideLiveboardHeader = 'hideLiveboardHeader',
4544
4587
  ShowLiveboardDescription = 'showLiveboardDescription',
4545
4588
  ShowLiveboardTitle = 'showLiveboardTitle',
4589
+ ShowMaskedFilterChip = 'showMaskedFilterChip',
4590
+ IsLiveboardMasterpiecesEnabled = 'isLiveboardMasterpiecesEnabled',
4546
4591
  HiddenTabs = 'hideTabs',
4547
4592
  VisibleTabs = 'visibleTabs',
4548
4593
  HideTabPanel = 'hideTabPanel',
@@ -6166,6 +6211,166 @@ export enum LogLevel {
6166
6211
  TRACE = 'TRACE',
6167
6212
  }
6168
6213
 
6214
+ /**
6215
+ * Error types emitted by embedded components.
6216
+ *
6217
+ * These enum values categorize different types of errors that can occur during
6218
+ * the lifecycle of an embedded ThoughtSpot component. Use these values to implement
6219
+ * specific error handling logic based on the error category.
6220
+ *
6221
+ * @see {@link EmbedErrorDetailsEvent} - The error event object structure
6222
+ * @see {@link EmbedEvent.Error} - The event that emits these errors
6223
+ * @version SDK: 1.44.2 | ThoughtSpot: 26.2.0.cl
6224
+ * @group Error Handling
6225
+ */
6226
+ export enum ErrorDetailsTypes {
6227
+ /** API call failure */
6228
+ API = 'API',
6229
+ /** General validation error */
6230
+ VALIDATION_ERROR = 'VALIDATION_ERROR',
6231
+ /** Network connectivity or request error */
6232
+ NETWORK = 'NETWORK',
6233
+ }
6234
+
6235
+ /**
6236
+ * Specific error codes for embedded component errors.
6237
+ *
6238
+ * These codes provide granular identification of errors that occur in embedded components.
6239
+ * They are returned in the {@link EmbedErrorDetailsEvent.code} property and allow for
6240
+ * precise error handling and debugging.
6241
+ *
6242
+ * The codes are organized into categories:
6243
+ * - **Worksheet ID not found or does not exist**: Errors related to applying or updating filters
6244
+ * - **Liveboard ID missing**: Errors related to missing liveboard ID
6245
+ * - **Conflicting actions configuration**: Errors related to conflicting actions configuration
6246
+ * - **Conflicting tabs configuration**: Errors related to conflicting tabs configuration
6247
+ * - **Initialization error**: Errors related to initialization error
6248
+ * - **Network error**: Errors related to network error
6249
+ * - **Custom action validation**: Errors related to custom action validation
6250
+ * - **Login failed**: Errors related to login failed
6251
+ * - **Render not called**: Errors related to render not called
6252
+ * - **Host event type undefined or invalid**: Errors related to host event type undefined or invalid
6253
+ *
6254
+ * @version SDK: 1.44.2 | ThoughtSpot: 26.2.0.cl
6255
+ * @group Error Handling
6256
+ * @see {@link EmbedErrorDetailsEvent} - The error event object that includes these codes
6257
+ * @see {@link ErrorDetailsTypes} - General error type categories
6258
+ *
6259
+ * @example
6260
+ * Handle specific error codes
6261
+ *
6262
+ * embed.on(EmbedEvent.Error, (error) => {
6263
+ * if (error.code === EmbedErrorCodes.WORKSHEET_ID_NOT_FOUND) {
6264
+ * console.error('Worksheet ID not found:', error.message);
6265
+ * }
6266
+ * });
6267
+ * */
6268
+ export enum EmbedErrorCodes {
6269
+ /** Worksheet ID not found or does not exist */
6270
+ WORKSHEET_ID_NOT_FOUND = 'WORKSHEET_ID_NOT_FOUND',
6271
+
6272
+ /** Required Liveboard ID is missing from configuration */
6273
+ LIVEBOARD_ID_MISSING = 'LIVEBOARD_ID_MISSING',
6274
+
6275
+ /** Conflicting action configuration detected (e.g., both hiddenActions and visibleActions specified) */
6276
+ CONFLICTING_ACTIONS_CONFIG = 'CONFLICTING_ACTIONS_CONFIG',
6277
+
6278
+ /** Conflicting tab configuration detected (e.g., both hiddenTabs and visibleTabs specified) */
6279
+ CONFLICTING_TABS_CONFIG = 'CONFLICTING_TABS_CONFIG',
6280
+
6281
+ /** Error during component initialization */
6282
+ INIT_ERROR = 'INIT_ERROR',
6283
+
6284
+ /** Network connectivity or request error */
6285
+ NETWORK_ERROR = 'NETWORK_ERROR',
6286
+
6287
+ /** Custom action validation failed */
6288
+ CUSTOM_ACTION_VALIDATION = 'CUSTOM_ACTION_VALIDATION',
6289
+
6290
+ /** Authentication/login failed */
6291
+ LOGIN_FAILED = 'LOGIN_FAILED',
6292
+
6293
+ /** Render method was not called before attempting to use the component */
6294
+ RENDER_NOT_CALLED = 'RENDER_NOT_CALLED',
6295
+
6296
+ /** Host event type is undefined or invalid */
6297
+ HOST_EVENT_TYPE_UNDEFINED = 'HOST_EVENT_TYPE_UNDEFINED',
6298
+
6299
+ /** Error parsing api intercept body */
6300
+ PARSING_API_INTERCEPT_BODY_ERROR = 'PARSING_API_INTERCEPT_BODY_ERROR',
6301
+ }
6302
+
6303
+ /**
6304
+ * Error event object emitted when an error occurs in an embedded component.
6305
+ *
6306
+ * This interface defines the structure of error objects returned by the {@link EmbedEvent.Error}
6307
+ * event. It provides detailed information about what went wrong, including the error type,
6308
+ * a human-readable message, and a machine-readable error code.
6309
+ *
6310
+ * ## Properties
6311
+ *
6312
+ * - **errorType**: One of the predefined {@link ErrorDetailsTypes} values
6313
+ * - **message**: Human-readable error description (string or array of strings for multiple errors)
6314
+ * - **code**: Machine-readable error identifier for programmatic handling
6315
+ * - **[key: string]**: Additional context-specific for backward compatibility
6316
+ *
6317
+ * ## Usage
6318
+ *
6319
+ * Listen to the {@link EmbedEvent.Error} event to receive instances of this object
6320
+ * and implement appropriate error handling logic based on the `errorType`.
6321
+ *
6322
+ * @version SDK: 1.44.2 | ThoughtSpot: 26.2.0.cl
6323
+ * @group Error Handling
6324
+ * @see {@link ErrorDetailsTypes} - Available error type values
6325
+ * @see {@link EmbedEvent.Error} - The event that emits this object
6326
+ *
6327
+ * @example
6328
+ * Handle specific error types
6329
+ *
6330
+ * embed.on(EmbedEvent.Error, (error) => {
6331
+ * switch (error.code) {
6332
+ * case EmbedErrorCodes.WORKSHEET_ID_NOT_FOUND:
6333
+ * console.error('Worksheet ID not found:', error.message, error.code);
6334
+ * break;
6335
+ * default:
6336
+ * console.error('Unknown error:', error);
6337
+ * }
6338
+ * });
6339
+ * *
6340
+ * @example
6341
+ * Handle multiple error messages
6342
+ *
6343
+ * embed.on(EmbedEvent.Error, (error) => {
6344
+ * const messages = Array.isArray(error.message)
6345
+ * ? error.message
6346
+ * : [error.message];
6347
+ *
6348
+ * messages.forEach(msg => console.error(msg));
6349
+ * });
6350
+ * *
6351
+ * @example
6352
+ * Access additional error context
6353
+ *
6354
+ * embed.on(EmbedEvent.Error, (error) => {
6355
+ * console.error('Error Details:', {
6356
+ * type: error.errorType,
6357
+ * message: error.message,
6358
+ * code: error.code,
6359
+ * // Additional context fields vary by error type
6360
+ * ...error
6361
+ * });
6362
+ * });
6363
+ * */
6364
+ export interface EmbedErrorDetailsEvent {
6365
+ /** The type of error that occurred */
6366
+ errorType: ErrorDetailsTypes;
6367
+ /** Human-readable error message(s) describing what went wrong */
6368
+ message: string | string[];
6369
+ /** Machine-readable error code for programmatic error handling */
6370
+ code: EmbedErrorCodes;
6371
+ /** Additional context-specific for backward compatibility */
6372
+ [key: string]: any;
6373
+ }
6169
6374
  export interface DefaultAppInitData {
6170
6375
  customisations: CustomisationsInterface;
6171
6376
  authToken: string;
@@ -25,11 +25,11 @@ describe('Unit test for authService', () => {
25
25
  json: () => ({ success: true }),
26
26
  status: 200,
27
27
  ok: true,
28
- }));
28
+ } as any));
29
29
  const response = await fetchSessionInfoService(thoughtSpotHost);
30
30
  expect(response.success).toBe(true);
31
31
  expect(fetch).toHaveBeenCalledTimes(1);
32
- expect(fetch).toBeCalledWith(`${thoughtSpotHost}${EndPoints.SESSION_INFO}`, {
32
+ expect(fetch).toHaveBeenCalledWith(`${thoughtSpotHost}${EndPoints.SESSION_INFO}`, {
33
33
  credentials: 'include',
34
34
  });
35
35
  });
@@ -38,16 +38,16 @@ describe('Unit test for authService', () => {
38
38
  global.fetch = jest.fn(() => Promise.resolve({
39
39
  text: () => ({ success: true }),
40
40
  ok: true,
41
- }));
41
+ } as any));
42
42
  const response = await fetchAuthTokenService(authEndpoint);
43
43
  expect(response.text()).toStrictEqual({ success: true });
44
- expect(fetch).toBeCalled();
44
+ expect(fetch).toHaveBeenCalled();
45
45
  });
46
46
 
47
47
  test('fetchAuthService', async () => {
48
- global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
48
+ global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true } as any));
49
49
  await fetchAuthService(thoughtSpotHost, username, authToken);
50
- expect(fetch).toBeCalledWith(
50
+ expect(fetch).toHaveBeenCalledWith(
51
51
  `${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`,
52
52
  {
53
53
  credentials: 'include',
@@ -57,9 +57,9 @@ describe('Unit test for authService', () => {
57
57
  });
58
58
 
59
59
  test('fetchAuthService without username', async () => {
60
- global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
60
+ global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true } as any));
61
61
  await fetchAuthService(thoughtSpotHost, undefined, authToken);
62
- expect(fetch).toBeCalledWith(
62
+ expect(fetch).toHaveBeenCalledWith(
63
63
  `${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?auth_token=${authToken}`,
64
64
  {
65
65
  credentials: 'include',
@@ -69,9 +69,9 @@ describe('Unit test for authService', () => {
69
69
  });
70
70
 
71
71
  test('fetchAuthPostService', async () => {
72
- global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
72
+ global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true } as any));
73
73
  await fetchAuthPostService(thoughtSpotHost, username, authToken);
74
- expect(fetch).toBeCalledWith(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}`, {
74
+ expect(fetch).toHaveBeenCalledWith(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}`, {
75
75
  method: 'POST',
76
76
  credentials: 'include',
77
77
  redirect: 'manual',
@@ -84,9 +84,9 @@ describe('Unit test for authService', () => {
84
84
  });
85
85
 
86
86
  test('fetchAuthPostService without username', async () => {
87
- global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
87
+ global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true } as any));
88
88
  await fetchAuthPostService(thoughtSpotHost, undefined, authToken);
89
- expect(fetch).toBeCalledWith(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}`, {
89
+ expect(fetch).toHaveBeenCalledWith(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}`, {
90
90
  method: 'POST',
91
91
  credentials: 'include',
92
92
  redirect: 'manual',
@@ -99,9 +99,9 @@ describe('Unit test for authService', () => {
99
99
  });
100
100
 
101
101
  test('fetchBasicAuthService called with manual redirect', async () => {
102
- global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
102
+ global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true } as any));
103
103
  await fetchBasicAuthService(thoughtSpotHost, username, password);
104
- expect(fetch).toBeCalled();
104
+ expect(fetch).toHaveBeenCalled();
105
105
  });
106
106
 
107
107
  test('log error on API failures', async () => {
@@ -110,7 +110,7 @@ describe('Unit test for authService', () => {
110
110
  text: () => Promise.resolve('error'),
111
111
  status: 500,
112
112
  ok: false,
113
- }));
113
+ } as any));
114
114
  try {
115
115
  await fetchSessionInfoService(authVerificationUrl);
116
116
  } catch (e) {
@@ -127,9 +127,9 @@ describe('Unit test for authService', () => {
127
127
  });
128
128
 
129
129
  test('verifyTokenService if token api works', async () => {
130
- global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
130
+ global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true } as any));
131
131
  await verifyTokenService(thoughtSpotHost, authToken);
132
- expect(fetch).toBeCalledWith(`${thoughtSpotHost}${EndPoints.IS_ACTIVE}`, {
132
+ expect(fetch).toHaveBeenCalledWith(`${thoughtSpotHost}${EndPoints.IS_ACTIVE}`, {
133
133
  credentials: 'omit',
134
134
  headers: {
135
135
  Authorization: `Bearer ${authToken}`,
@@ -13,7 +13,7 @@ describe('tokenizedAuthService', () => {
13
13
  test('isActiveService if fetch returns ok', async () => {
14
14
  jest.spyOn(tokenizedFetchModule, 'tokenizedFetch').mockResolvedValueOnce({
15
15
  ok: true,
16
- });
16
+ } as any);
17
17
 
18
18
  const isActiveResp = await isActiveService('http://thoughtspotHost');
19
19
 
@@ -22,7 +22,7 @@ describe('tokenizedAuthService', () => {
22
22
  test('isActiveService if fetch returns not ok', async () => {
23
23
  jest.spyOn(tokenizedFetchModule, 'tokenizedFetch').mockResolvedValueOnce({
24
24
  ok: false,
25
- });
25
+ } as any);
26
26
 
27
27
  const isActiveResp = await isActiveService('http://thoughtspotHost');
28
28
 
@@ -68,7 +68,7 @@ describe('fetchPreauthInfoService', () => {
68
68
  userGUID: 'userGUID',
69
69
  },
70
70
  }),
71
- });
71
+ } as any);
72
72
 
73
73
  const result = await fetchPreauthInfoService(thoughtspotHost);
74
74
  const response = await result.json();
@@ -87,7 +87,7 @@ describe('fetchPreauthInfoService', () => {
87
87
  statusText: 'Internal Server Error',
88
88
  json: jest.fn().mockResolvedValue({}),
89
89
  text: jest.fn().mockResolvedValue('Internal Server Error'),
90
- });
90
+ } as any);
91
91
 
92
92
  try {
93
93
  await fetchPreauthInfoService(thoughtspotHost);
@@ -66,7 +66,7 @@ describe('Answer service tests', () => {
66
66
  'query Bla {}',
67
67
  { a: 1 },
68
68
  );
69
- expect(fetchMock).toBeCalledWith('https://tshost/prism/?op=Bla', expect.objectContaining({
69
+ expect(fetchMock).toHaveBeenCalledWith('https://tshost/prism/?op=Bla', expect.objectContaining({
70
70
  body: JSON.stringify({
71
71
  operationName: 'Bla',
72
72
  query: 'query Bla {}',
@@ -142,7 +142,7 @@ describe('Answer service tests', () => {
142
142
  thougthspotHost: '/test',
143
143
  authType: AuthType.TrustedAuthTokenCookieless,
144
144
  };
145
- jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValueOnce(mockEmbedConfig);
145
+ jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValueOnce(mockEmbedConfig as any);
146
146
  jest.spyOn(authTokenInstance, 'getAuthenticationToken').mockReturnValueOnce(Promise.resolve('token'));
147
147
  const mockTokenizedFetch = jest.spyOn(tokenizedFetch, 'tokenizedFetch');
148
148
  answerService.fetchCSVBlob(undefined, true);
@@ -172,7 +172,7 @@ describe('Answer service tests', () => {
172
172
  thougthspotHost: '/test',
173
173
  authType: AuthType.TrustedAuthTokenCookieless,
174
174
  };
175
- jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValueOnce(mockEmbedConfig);
175
+ jest.spyOn(embedConfigInstance, 'getEmbedConfig').mockReturnValueOnce(mockEmbedConfig as any);
176
176
  jest.spyOn(authTokenInstance, 'getAuthenticationToken').mockReturnValueOnce(Promise.resolve('token'));
177
177
  const mockTokenizedFetch = jest.spyOn(tokenizedFetch, 'tokenizedFetch');
178
178
  answerService.fetchPNGBlob(undefined, true);