@thoughtspot/visual-embed-sdk 1.32.0-alpha.0 → 1.32.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/README.md +20 -0
  2. package/cjs/package.json +6 -4
  3. package/cjs/src/auth.d.ts +14 -16
  4. package/cjs/src/auth.d.ts.map +1 -1
  5. package/cjs/src/auth.js +57 -66
  6. package/cjs/src/auth.js.map +1 -1
  7. package/cjs/src/auth.spec.d.ts +12 -0
  8. package/cjs/src/auth.spec.d.ts.map +1 -1
  9. package/cjs/src/auth.spec.js +89 -67
  10. package/cjs/src/auth.spec.js.map +1 -1
  11. package/cjs/src/authToken.d.ts +1 -1
  12. package/cjs/src/authToken.d.ts.map +1 -1
  13. package/cjs/src/authToken.js +10 -4
  14. package/cjs/src/authToken.js.map +1 -1
  15. package/cjs/src/embed/app.spec.js +4 -2
  16. package/cjs/src/embed/app.spec.js.map +1 -1
  17. package/cjs/src/embed/base.d.ts.map +1 -1
  18. package/cjs/src/embed/base.js +2 -0
  19. package/cjs/src/embed/base.js.map +1 -1
  20. package/cjs/src/embed/base.spec.js +1 -0
  21. package/cjs/src/embed/base.spec.js.map +1 -1
  22. package/cjs/src/embed/embed.spec.js +3 -0
  23. package/cjs/src/embed/embed.spec.js.map +1 -1
  24. package/cjs/src/embed/events.spec.js +3 -0
  25. package/cjs/src/embed/events.spec.js.map +1 -1
  26. package/cjs/src/embed/liveboard.d.ts +24 -0
  27. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  28. package/cjs/src/embed/liveboard.js +30 -0
  29. package/cjs/src/embed/liveboard.js.map +1 -1
  30. package/cjs/src/embed/liveboard.spec.js +33 -0
  31. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  32. package/cjs/src/embed/pinboard.spec.js +3 -0
  33. package/cjs/src/embed/pinboard.spec.js.map +1 -1
  34. package/cjs/src/embed/sage.spec.js +3 -0
  35. package/cjs/src/embed/sage.spec.js.map +1 -1
  36. package/cjs/src/embed/search.spec.js +1 -0
  37. package/cjs/src/embed/search.spec.js.map +1 -1
  38. package/cjs/src/embed/ts-embed-trigger.spec.js +3 -0
  39. package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -1
  40. package/cjs/src/embed/ts-embed.d.ts +7 -1
  41. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  42. package/cjs/src/embed/ts-embed.js +13 -3
  43. package/cjs/src/embed/ts-embed.js.map +1 -1
  44. package/cjs/src/embed/ts-embed.spec.js +23 -3
  45. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  46. package/cjs/src/index.d.ts +2 -1
  47. package/cjs/src/index.d.ts.map +1 -1
  48. package/cjs/src/index.js +2 -1
  49. package/cjs/src/index.js.map +1 -1
  50. package/cjs/src/mixpanel-service.d.ts +2 -1
  51. package/cjs/src/mixpanel-service.d.ts.map +1 -1
  52. package/cjs/src/mixpanel-service.js +1 -0
  53. package/cjs/src/mixpanel-service.js.map +1 -1
  54. package/cjs/src/mixpanel-service.spec.js +7 -0
  55. package/cjs/src/mixpanel-service.spec.js.map +1 -1
  56. package/cjs/src/react/index.d.ts +1 -1
  57. package/cjs/src/react/index.d.ts.map +1 -1
  58. package/cjs/src/react/index.js +2 -1
  59. package/cjs/src/react/index.js.map +1 -1
  60. package/cjs/src/react/index.spec.js +6 -0
  61. package/cjs/src/react/index.spec.js.map +1 -1
  62. package/cjs/src/tokenizedFetch.d.ts +8 -0
  63. package/cjs/src/tokenizedFetch.d.ts.map +1 -1
  64. package/cjs/src/tokenizedFetch.js +8 -0
  65. package/cjs/src/tokenizedFetch.js.map +1 -1
  66. package/cjs/src/types.d.ts +49 -25
  67. package/cjs/src/types.d.ts.map +1 -1
  68. package/cjs/src/types.js +36 -25
  69. package/cjs/src/types.js.map +1 -1
  70. package/cjs/src/utils/authService/authService.d.ts +1 -0
  71. package/cjs/src/utils/authService/authService.d.ts.map +1 -1
  72. package/cjs/src/utils/authService/authService.js +1 -0
  73. package/cjs/src/utils/authService/authService.js.map +1 -1
  74. package/cjs/src/utils/authService/authService.spec.js +18 -5
  75. package/cjs/src/utils/authService/authService.spec.js.map +1 -1
  76. package/cjs/src/utils/authService/tokenizedAuthService.d.ts +15 -2
  77. package/cjs/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
  78. package/cjs/src/utils/authService/tokenizedAuthService.js +39 -9
  79. package/cjs/src/utils/authService/tokenizedAuthService.js.map +1 -1
  80. package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
  81. package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
  82. package/cjs/src/utils/authService/tokenizedAuthService.spec.js +32 -0
  83. package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -0
  84. package/cjs/src/utils/global-styles.d.ts +2 -0
  85. package/cjs/src/utils/global-styles.d.ts.map +1 -0
  86. package/cjs/src/utils/global-styles.js +44 -0
  87. package/cjs/src/utils/global-styles.js.map +1 -0
  88. package/cjs/src/utils/graphql/preview-service.d.ts +3 -0
  89. package/cjs/src/utils/graphql/preview-service.d.ts.map +1 -0
  90. package/cjs/src/utils/graphql/preview-service.js +30 -0
  91. package/cjs/src/utils/graphql/preview-service.js.map +1 -0
  92. package/cjs/src/utils/processData.js +2 -2
  93. package/cjs/src/utils/processData.js.map +1 -1
  94. package/cjs/src/utils/processData.spec.js +3 -2
  95. package/cjs/src/utils/processData.spec.js.map +1 -1
  96. package/cjs/src/utils/sessionInfoService.d.ts +66 -0
  97. package/cjs/src/utils/sessionInfoService.d.ts.map +1 -0
  98. package/cjs/src/utils/sessionInfoService.js +92 -0
  99. package/cjs/src/utils/sessionInfoService.js.map +1 -0
  100. package/dist/src/auth.d.ts +14 -16
  101. package/dist/src/auth.d.ts.map +1 -1
  102. package/dist/src/auth.spec.d.ts +12 -0
  103. package/dist/src/auth.spec.d.ts.map +1 -1
  104. package/dist/src/authToken.d.ts +1 -1
  105. package/dist/src/authToken.d.ts.map +1 -1
  106. package/dist/src/embed/base.d.ts.map +1 -1
  107. package/dist/src/embed/liveboard.d.ts +24 -0
  108. package/dist/src/embed/liveboard.d.ts.map +1 -1
  109. package/dist/src/embed/ts-embed.d.ts +7 -1
  110. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  111. package/dist/src/index.d.ts +2 -1
  112. package/dist/src/index.d.ts.map +1 -1
  113. package/dist/src/mixpanel-service.d.ts +2 -1
  114. package/dist/src/mixpanel-service.d.ts.map +1 -1
  115. package/dist/src/react/index.d.ts +1 -1
  116. package/dist/src/react/index.d.ts.map +1 -1
  117. package/dist/src/tokenizedFetch.d.ts +8 -0
  118. package/dist/src/tokenizedFetch.d.ts.map +1 -1
  119. package/dist/src/types.d.ts +49 -25
  120. package/dist/src/types.d.ts.map +1 -1
  121. package/dist/src/utils/authService/authService.d.ts +1 -0
  122. package/dist/src/utils/authService/authService.d.ts.map +1 -1
  123. package/dist/src/utils/authService/tokenizedAuthService.d.ts +15 -2
  124. package/dist/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
  125. package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
  126. package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
  127. package/dist/src/utils/global-styles.d.ts +2 -0
  128. package/dist/src/utils/global-styles.d.ts.map +1 -0
  129. package/dist/src/utils/graphql/preview-service.d.ts +3 -0
  130. package/dist/src/utils/graphql/preview-service.d.ts.map +1 -0
  131. package/dist/src/utils/sessionInfoService.d.ts +66 -0
  132. package/dist/src/utils/sessionInfoService.d.ts.map +1 -0
  133. package/dist/tsembed-react.es.js +298 -93
  134. package/dist/tsembed-react.js +298 -92
  135. package/dist/tsembed.es.js +306 -103
  136. package/dist/tsembed.js +306 -103
  137. package/dist/visual-embed-sdk-react-full.d.ts +169 -44
  138. package/dist/visual-embed-sdk-react.d.ts +169 -44
  139. package/dist/visual-embed-sdk.d.ts +169 -44
  140. package/lib/package.json +6 -4
  141. package/lib/src/auth.d.ts +14 -16
  142. package/lib/src/auth.d.ts.map +1 -1
  143. package/lib/src/auth.js +56 -63
  144. package/lib/src/auth.js.map +1 -1
  145. package/lib/src/auth.spec.d.ts +12 -0
  146. package/lib/src/auth.spec.d.ts.map +1 -1
  147. package/lib/src/auth.spec.js +88 -66
  148. package/lib/src/auth.spec.js.map +1 -1
  149. package/lib/src/authToken.d.ts +1 -1
  150. package/lib/src/authToken.d.ts.map +1 -1
  151. package/lib/src/authToken.js +10 -4
  152. package/lib/src/authToken.js.map +1 -1
  153. package/lib/src/embed/app.spec.js +4 -2
  154. package/lib/src/embed/app.spec.js.map +1 -1
  155. package/lib/src/embed/base.d.ts.map +1 -1
  156. package/lib/src/embed/base.js +3 -1
  157. package/lib/src/embed/base.js.map +1 -1
  158. package/lib/src/embed/base.spec.js +1 -0
  159. package/lib/src/embed/base.spec.js.map +1 -1
  160. package/lib/src/embed/embed.spec.js +2 -0
  161. package/lib/src/embed/embed.spec.js.map +1 -1
  162. package/lib/src/embed/events.spec.js +2 -0
  163. package/lib/src/embed/events.spec.js.map +1 -1
  164. package/lib/src/embed/liveboard.d.ts +24 -0
  165. package/lib/src/embed/liveboard.d.ts.map +1 -1
  166. package/lib/src/embed/liveboard.js +30 -0
  167. package/lib/src/embed/liveboard.js.map +1 -1
  168. package/lib/src/embed/liveboard.spec.js +33 -0
  169. package/lib/src/embed/liveboard.spec.js.map +1 -1
  170. package/lib/src/embed/pinboard.spec.js +2 -0
  171. package/lib/src/embed/pinboard.spec.js.map +1 -1
  172. package/lib/src/embed/sage.spec.js +2 -0
  173. package/lib/src/embed/sage.spec.js.map +1 -1
  174. package/lib/src/embed/search.spec.js +1 -0
  175. package/lib/src/embed/search.spec.js.map +1 -1
  176. package/lib/src/embed/ts-embed-trigger.spec.js +2 -0
  177. package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -1
  178. package/lib/src/embed/ts-embed.d.ts +7 -1
  179. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  180. package/lib/src/embed/ts-embed.js +13 -3
  181. package/lib/src/embed/ts-embed.js.map +1 -1
  182. package/lib/src/embed/ts-embed.spec.js +23 -3
  183. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  184. package/lib/src/index.d.ts +2 -1
  185. package/lib/src/index.d.ts.map +1 -1
  186. package/lib/src/index.js +2 -1
  187. package/lib/src/index.js.map +1 -1
  188. package/lib/src/mixpanel-service.d.ts +2 -1
  189. package/lib/src/mixpanel-service.d.ts.map +1 -1
  190. package/lib/src/mixpanel-service.js +1 -0
  191. package/lib/src/mixpanel-service.js.map +1 -1
  192. package/lib/src/mixpanel-service.spec.js +7 -0
  193. package/lib/src/mixpanel-service.spec.js.map +1 -1
  194. package/lib/src/react/index.d.ts +1 -1
  195. package/lib/src/react/index.d.ts.map +1 -1
  196. package/lib/src/react/index.js +1 -1
  197. package/lib/src/react/index.js.map +1 -1
  198. package/lib/src/react/index.spec.js +6 -0
  199. package/lib/src/react/index.spec.js.map +1 -1
  200. package/lib/src/tokenizedFetch.d.ts +8 -0
  201. package/lib/src/tokenizedFetch.d.ts.map +1 -1
  202. package/lib/src/tokenizedFetch.js +8 -0
  203. package/lib/src/tokenizedFetch.js.map +1 -1
  204. package/lib/src/types.d.ts +49 -25
  205. package/lib/src/types.d.ts.map +1 -1
  206. package/lib/src/types.js +36 -25
  207. package/lib/src/types.js.map +1 -1
  208. package/lib/src/utils/authService/authService.d.ts +1 -0
  209. package/lib/src/utils/authService/authService.d.ts.map +1 -1
  210. package/lib/src/utils/authService/authService.js +1 -0
  211. package/lib/src/utils/authService/authService.js.map +1 -1
  212. package/lib/src/utils/authService/authService.spec.js +18 -5
  213. package/lib/src/utils/authService/authService.spec.js.map +1 -1
  214. package/lib/src/utils/authService/tokenizedAuthService.d.ts +15 -2
  215. package/lib/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
  216. package/lib/src/utils/authService/tokenizedAuthService.js +37 -8
  217. package/lib/src/utils/authService/tokenizedAuthService.js.map +1 -1
  218. package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
  219. package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
  220. package/lib/src/utils/authService/tokenizedAuthService.spec.js +29 -0
  221. package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -0
  222. package/lib/src/utils/global-styles.d.ts +2 -0
  223. package/lib/src/utils/global-styles.d.ts.map +1 -0
  224. package/lib/src/utils/global-styles.js +40 -0
  225. package/lib/src/utils/global-styles.js.map +1 -0
  226. package/lib/src/utils/graphql/preview-service.d.ts +3 -0
  227. package/lib/src/utils/graphql/preview-service.d.ts.map +1 -0
  228. package/lib/src/utils/graphql/preview-service.js +26 -0
  229. package/lib/src/utils/graphql/preview-service.js.map +1 -0
  230. package/lib/src/utils/processData.js +3 -3
  231. package/lib/src/utils/processData.js.map +1 -1
  232. package/lib/src/utils/processData.spec.js +3 -2
  233. package/lib/src/utils/processData.spec.js.map +1 -1
  234. package/lib/src/utils/sessionInfoService.d.ts +66 -0
  235. package/lib/src/utils/sessionInfoService.d.ts.map +1 -0
  236. package/lib/src/utils/sessionInfoService.js +85 -0
  237. package/lib/src/utils/sessionInfoService.js.map +1 -0
  238. package/lib/src/visual-embed-sdk.d.ts +174 -45
  239. package/package.json +6 -4
  240. package/src/auth.spec.ts +92 -72
  241. package/src/auth.ts +57 -75
  242. package/src/authToken.ts +9 -4
  243. package/src/embed/app.spec.ts +4 -2
  244. package/src/embed/base.spec.ts +1 -0
  245. package/src/embed/base.ts +3 -0
  246. package/src/embed/embed.spec.ts +2 -0
  247. package/src/embed/events.spec.ts +2 -0
  248. package/src/embed/liveboard.spec.ts +36 -0
  249. package/src/embed/liveboard.ts +61 -1
  250. package/src/embed/pinboard.spec.ts +2 -0
  251. package/src/embed/sage.spec.ts +3 -0
  252. package/src/embed/search.spec.ts +1 -0
  253. package/src/embed/ts-embed-trigger.spec.ts +3 -0
  254. package/src/embed/ts-embed.spec.ts +26 -3
  255. package/src/embed/ts-embed.ts +15 -4
  256. package/src/index.ts +2 -1
  257. package/src/mixpanel-service.spec.ts +12 -3
  258. package/src/mixpanel-service.ts +3 -1
  259. package/src/react/index.spec.tsx +7 -0
  260. package/src/react/index.tsx +1 -0
  261. package/src/tokenizedFetch.ts +8 -0
  262. package/src/types.ts +55 -29
  263. package/src/utils/authService/authService.spec.ts +18 -5
  264. package/src/utils/authService/authService.ts +1 -0
  265. package/src/utils/authService/tokenizedAuthService.spec.ts +36 -0
  266. package/src/utils/authService/tokenizedAuthService.ts +38 -8
  267. package/src/utils/global-styles.ts +40 -0
  268. package/src/utils/graphql/preview-service.ts +31 -0
  269. package/src/utils/processData.spec.ts +3 -2
  270. package/src/utils/processData.ts +3 -3
  271. package/src/utils/sessionInfoService.ts +101 -0
package/dist/tsembed.js CHANGED
@@ -1462,26 +1462,33 @@
1462
1462
  /**
1463
1463
  * Emitted when user wants to intercept the search execution
1464
1464
  *
1465
- * Make isOnBeforeGetVizDataEnabled : true to use this embed
1466
- * event
1465
+ * Set IsOnBeforeGetVizDataInterceptEnabled : true to use
1466
+ * this embed event
1467
1467
  *
1468
1468
  *```js
1469
- * searchEmbed.on(EmbedEvent.OnBeforeGetVizData, (payload, responder) => {
1470
- * responder({
1471
- * data: {
1472
- * execute: true,
1473
- * error: {errorText: "My own customised error"}
1474
- * }})
1475
- * })
1469
+ * searchEmbed.on(EmbedEvent.OnBeforeGetVizDataIntercept,
1470
+ * (payload, responder) => {
1471
+ * responder({
1472
+ * data: {
1473
+ * execute: true,
1474
+ * }})
1475
+ * })
1476
1476
  *```
1477
- * @version SDK : 1.29.0 | Thoughtspot : 10.1.0.cl
1477
+ * @version SDK : 1.29.0 | Thoughtspot : 10.2.0.cl
1478
1478
  */
1479
1479
  EmbedEvent["OnBeforeGetVizDataIntercept"] = "onBeforeGetVizDataIntercept";
1480
1480
  /**
1481
- * Emitted when runtime parameters changes
1482
- * @version SDK : 1.29.0 | Thoughtspot : 10.1.0.cl
1481
+ * Emitted when parameter changes in an answer
1482
+ * or liveboard
1483
+ *
1484
+ * ```js
1485
+ * liveboardEmbed.on(EmbedEvent.ParameterChanged, (payload) => {
1486
+ * console.log('payload', payload);
1487
+ * })
1488
+ *```
1489
+ * @version SDK : 1.29.0 | Thoughtspot : 10.2.0.cl
1483
1490
  */
1484
- EmbedEvent["ParameterChanged"] = "ParameterChanged";
1491
+ EmbedEvent["ParameterChanged"] = "parameterChanged";
1485
1492
  })(exports.EmbedEvent || (exports.EmbedEvent = {}));
1486
1493
  (function (HostEvent) {
1487
1494
  /**
@@ -1678,7 +1685,7 @@
1678
1685
  * sorting, toggling of legends, and data drill down.
1679
1686
  * @example
1680
1687
  * ```js
1681
- * liveboardEmbed.trigger(HostEvent.getexportrequestforcurrentpinboard).then(
1688
+ * liveboardEmbed.trigger(HostEvent.getExportRequestForCurrentPinboard).then(
1682
1689
  * data=>console.log(data))
1683
1690
  * ```
1684
1691
  * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1.sw
@@ -2288,15 +2295,6 @@
2288
2295
  * @version SDK: 1.29.0 | Thoughtspot: 10.1.0.cl
2289
2296
  */
2290
2297
  HostEvent["ResetLiveboardPersonalisedView"] = "ResetLiveboardPersonalisedView";
2291
- /**
2292
- * Trigger CreateLiveboard for liveboard list page & Pin Modal
2293
- * @example
2294
- * ```js
2295
- * liveboardEmbed.trigger(HostEvent.CreateLiveboard);
2296
- *
2297
- * @version SDK: 1.29.0 | Thoughtspot: 10.1.0.cl
2298
- */
2299
- HostEvent["CreateLiveboard"] = "CreateLiveboard";
2300
2298
  /**
2301
2299
  * Triggers Update RuntimeParameters for answers and liveboard
2302
2300
  * @example
@@ -2312,8 +2310,10 @@
2312
2310
  /**
2313
2311
  * Triggers GetParameters to fetch the runtime parameters
2314
2312
  * ```js
2315
- * liveboardEmbed.trigger(HostEvent.GetParameters);
2316
- *
2313
+ * liveboardEmbed.trigger(HostEvent.GetParameters).then((parameter) => {
2314
+ * console.log('parameters', parameter);
2315
+ * });
2316
+ *```
2317
2317
  * @version SDK: 1.29.0 | Thoughtspot: 10.1.0.cl
2318
2318
  */
2319
2319
  HostEvent["GetParameters"] = "GetParameters";
@@ -3253,6 +3253,17 @@
3253
3253
  * @version SDK : 1.28.3 | Thoughtspot: 9.12.0.cl
3254
3254
  */
3255
3255
  Action["TML"] = "tml";
3256
+ /**
3257
+ * Action Id for CreateLiveboard for liveboard list page & Pin Modal
3258
+ * @example
3259
+ * ```js
3260
+ * hiddenAction: [Action.CreateLiveboard]
3261
+ * disabledActions: [Action.CreateLiveboard]
3262
+ * ```
3263
+ *
3264
+ * @version SDK: 1.32.0 | Thoughtspot: 10.1.0.cl
3265
+ */
3266
+ Action["CreateLiveboard"] = "CreateLiveboard";
3256
3267
  /**
3257
3268
  * Action ID for to hide Verified Liveboard Banner
3258
3269
  * @example
@@ -5670,6 +5681,7 @@
5670
5681
 
5671
5682
  const EndPoints = {
5672
5683
  AUTH_VERIFICATION: '/callosum/v1/session/info',
5684
+ SESSION_INFO: '/callosum/v1/session/info',
5673
5685
  SAML_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/saml/login?targetURLPath=${targetUrl}`,
5674
5686
  OIDC_LOGIN_TEMPLATE: (targetUrl) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
5675
5687
  TOKEN_LOGIN: '/callosum/v1/session/login/token',
@@ -5785,7 +5797,7 @@
5785
5797
  const INVALID_TOKEN_ERR = 'Invalid token received form token callback or authToken endpoint.';
5786
5798
  let cachedAuthToken = null;
5787
5799
  // This method can be used to get the authToken using the embedConfig
5788
- const getAuthenticationToken = async (embedConfig) => {
5800
+ async function getAuthenticationToken(embedConfig) {
5789
5801
  // Since we don't have token validation enabled , we cannot tell if the
5790
5802
  // cached token is valid or not. So we will always fetch a new token.
5791
5803
  if (cachedAuthToken && !embedConfig.disableTokenVerification) {
@@ -5808,11 +5820,17 @@
5808
5820
  const response = await fetchAuthTokenService(authEndpoint);
5809
5821
  authToken = await response.text();
5810
5822
  }
5811
- // this will throw error if the token is not valid
5812
- await validateAuthToken(embedConfig, authToken);
5823
+ try {
5824
+ // this will throw error if the token is not valid
5825
+ await validateAuthToken(embedConfig, authToken);
5826
+ }
5827
+ catch (e) {
5828
+ logger.error(`Received invalid token from getAuthToken callback or authToken endpoint. Error : ${e.message}`);
5829
+ throw e;
5830
+ }
5813
5831
  cachedAuthToken = authToken;
5814
5832
  return authToken;
5815
- };
5833
+ }
5816
5834
  const validateAuthToken = async (embedConfig, authToken, suppressAlert) => {
5817
5835
  if (embedConfig.disableTokenVerification) {
5818
5836
  logger.info('Token verification is disabled. Assuming token is valid.');
@@ -5873,8 +5891,16 @@
5873
5891
  /**
5874
5892
  * Fetch wrapper that adds the authentication token to the request.
5875
5893
  * Use this to call the ThoughtSpot APIs when using the visual embed sdk.
5894
+ * The interface for this method is the same as Web `Fetch`.
5895
+ *
5876
5896
  * @param input
5877
5897
  * @param init
5898
+ * @example
5899
+ * ```js
5900
+ * tokenizedFetch("<TS_ORIGIN>/api/rest/2.0/auth/session/user", {
5901
+ * // .. fetch options ..
5902
+ * });
5903
+ *```
5878
5904
  * @version SDK: 1.28.0
5879
5905
  * @group Global methods
5880
5906
  */
@@ -12542,6 +12568,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
12542
12568
  function initMixpanel(sessionInfo) {
12543
12569
  var _a;
12544
12570
  if (!sessionInfo || !sessionInfo.mixpanelToken) {
12571
+ logger.error('Mixpanel token not found in session info');
12545
12572
  return;
12546
12573
  }
12547
12574
  // On a public cluster the user is anonymous, so don't set the identify to
@@ -12912,49 +12939,124 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
12912
12939
  * @param url
12913
12940
  * @param options
12914
12941
  */
12915
- function tokenisedFailureLoggedFetch(url, options = {}) {
12942
+ function tokenizedFailureLoggedFetch(url, options = {}) {
12916
12943
  return tokenizedFetch(url, options).then(async (r) => {
12917
12944
  var _a;
12918
12945
  if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
12919
- logger.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
12946
+ logger.error(`Failed to fetch ${url}`, await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
12920
12947
  }
12921
12948
  return r;
12922
12949
  });
12923
12950
  }
12924
12951
  /**
12952
+ * Fetches the session info from the ThoughtSpot server.
12925
12953
  *
12926
- * @param authVerificationUrl
12954
+ * @param thoughtspotHost
12955
+ * @returns {Promise<any>}
12956
+ * @example
12957
+ * ```js
12958
+ * const response = await sessionInfoService();
12959
+ * ```
12927
12960
  */
12928
- function fetchSessionInfoService(authVerificationUrl) {
12929
- return tokenisedFailureLoggedFetch(authVerificationUrl, {
12930
- credentials: 'include',
12931
- });
12961
+ async function fetchSessionInfoService(thoughtspotHost) {
12962
+ const sessionInfoPath = `${thoughtspotHost}${EndPoints.SESSION_INFO}`;
12963
+ const response = await tokenizedFailureLoggedFetch(sessionInfoPath);
12964
+ if (!response.ok) {
12965
+ throw new Error(`Failed to fetch session info: ${response.statusText}`);
12966
+ }
12967
+ const data = await response.json();
12968
+ return data;
12932
12969
  }
12933
12970
  /**
12934
12971
  *
12935
12972
  * @param thoughtSpotHost
12936
12973
  */
12937
12974
  async function fetchLogoutService(thoughtSpotHost) {
12938
- return tokenisedFailureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
12975
+ return tokenizedFailureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
12939
12976
  credentials: 'include',
12940
12977
  method: 'POST',
12941
12978
  headers: {
12942
12979
  'x-requested-by': 'ThoughtSpot',
12943
12980
  },
12944
12981
  });
12982
+ }
12983
+ /**
12984
+ * Is active service to check if the user is logged in.
12985
+ *
12986
+ * @param thoughtSpotHost
12987
+ * @version SDK: 1.28.4 | ThoughtSpot: *
12988
+ */
12989
+ async function isActiveService(thoughtSpotHost) {
12990
+ const isActiveUrl = `${thoughtSpotHost}${EndPoints.IS_ACTIVE}`;
12991
+ try {
12992
+ const res = await tokenizedFetch(isActiveUrl, {
12993
+ credentials: 'include',
12994
+ });
12995
+ return res.ok;
12996
+ }
12997
+ catch (e) {
12998
+ logger.warn(`Is Logged In Service failed : ${e.message}`);
12999
+ }
13000
+ return false;
12945
13001
  }
12946
13002
 
13003
+ let sessionInfo = null;
13004
+ /**
13005
+ * Returns the session info object and caches it for future use.
13006
+ * Once fetched the session info object is cached and returned from the cache on
13007
+ * subsequent calls.
13008
+ *
13009
+ * @example ```js
13010
+ * const sessionInfo = await getSessionInfo();
13011
+ * console.log(sessionInfo);
13012
+ * ```
13013
+ * @version SDK: 1.28.3 | ThoughtSpot: *
13014
+ * @returns {Promise<SessionInfo>} The session info object.
13015
+ */
13016
+ async function getSessionInfo() {
13017
+ if (!sessionInfo) {
13018
+ const host = getEmbedConfig().thoughtSpotHost;
13019
+ const sessionResponse = await fetchSessionInfoService(host);
13020
+ const processedSessionInfo = getSessionDetails(sessionResponse);
13021
+ sessionInfo = processedSessionInfo;
13022
+ }
13023
+ return sessionInfo;
13024
+ }
13025
+ /**
13026
+ * Processes the session info response and returns the session info object.
13027
+ *
13028
+ * @param sessionInfoResp {any} Response from the session info API.
13029
+ * @returns {SessionInfo} The session info object.
13030
+ * @example ```js
13031
+ * const sessionInfoResp = await fetch(sessionInfoPath);
13032
+ * const sessionInfo = getSessionDetails(sessionInfoResp);
13033
+ * console.log(sessionInfo);
13034
+ * ```
13035
+ * @version SDK: 1.28.3 | ThoughtSpot: *
13036
+ */
13037
+ const getSessionDetails = (sessionInfoResp) => {
13038
+ const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
13039
+ const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
13040
+ const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
13041
+ ? prodMixpanelToken
13042
+ : devMixpanelToken;
13043
+ return {
13044
+ userGUID: sessionInfoResp.userGUID,
13045
+ mixpanelToken,
13046
+ isPublicUser: sessionInfoResp.configInfo.isPublicUser,
13047
+ releaseVersion: sessionInfoResp.releaseVersion,
13048
+ clusterId: sessionInfoResp.configInfo.selfClusterId,
13049
+ clusterName: sessionInfoResp.configInfo.selfClusterName,
13050
+ ...sessionInfoResp,
13051
+ };
13052
+ };
13053
+
12947
13054
  // eslint-disable-next-line import/no-mutable-exports
12948
13055
  let loggedInStatus = false;
12949
13056
  // eslint-disable-next-line import/no-mutable-exports
12950
13057
  let samlAuthWindow = null;
12951
13058
  // eslint-disable-next-line import/no-mutable-exports
12952
13059
  let samlCompletionPromise = null;
12953
- let sessionInfo = null;
12954
- let sessionInfoResolver = null;
12955
- const sessionInfoPromise = new Promise((resolve) => {
12956
- sessionInfoResolver = resolve;
12957
- });
12958
13060
  let releaseVersion = '';
12959
13061
  const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
12960
13062
  (function (AuthFailureType) {
@@ -13016,12 +13118,18 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13016
13118
  /**
13017
13119
  *
13018
13120
  */
13019
- function notifyAuthSuccess() {
13121
+ async function notifyAuthSuccess() {
13020
13122
  if (!authEE) {
13021
13123
  logger.error('SDK not initialized');
13022
13124
  return;
13023
13125
  }
13024
- authEE.emit(exports.AuthStatus.SUCCESS, sessionInfo);
13126
+ try {
13127
+ const sessionInfo = await getSessionInfo();
13128
+ authEE.emit(exports.AuthStatus.SUCCESS, sessionInfo);
13129
+ }
13130
+ catch (e) {
13131
+ logger.error('Failed to get session info');
13132
+ }
13025
13133
  }
13026
13134
  /**
13027
13135
  *
@@ -13044,65 +13152,49 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13044
13152
  }
13045
13153
  authEE.emit(exports.AuthStatus.LOGOUT);
13046
13154
  }
13047
- const initSession = (sessionDetails) => {
13048
- const embedConfig = getEmbedConfig();
13049
- if (sessionInfo == null) {
13050
- sessionInfo = sessionDetails;
13051
- if (!embedConfig.disableSDKTracking) {
13052
- initMixpanel(sessionInfo);
13053
- }
13054
- sessionInfoResolver(sessionInfo);
13055
- }
13056
- };
13057
- const getSessionDetails = (sessionInfoResp) => {
13058
- const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
13059
- const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
13060
- const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
13061
- ? prodMixpanelToken
13062
- : devMixpanelToken;
13063
- return {
13064
- userGUID: sessionInfoResp.userGUID,
13065
- mixpanelToken,
13066
- isPublicUser: sessionInfoResp.configInfo.isPublicUser,
13067
- releaseVersion: sessionInfoResp.releaseVersion,
13068
- clusterId: sessionInfoResp.configInfo.selfClusterId,
13069
- clusterName: sessionInfoResp.configInfo.selfClusterName,
13070
- ...sessionInfoResp,
13071
- };
13072
- };
13073
13155
  /**
13074
13156
  * Check if we are logged into the ThoughtSpot cluster
13075
13157
  * @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
13076
13158
  */
13077
13159
  async function isLoggedIn(thoughtSpotHost) {
13078
- const authVerificationUrl = `${thoughtSpotHost}${EndPoints.AUTH_VERIFICATION}`;
13079
- let response = null;
13080
13160
  try {
13081
- response = await fetchSessionInfoService(authVerificationUrl);
13082
- const sessionInfoResp = await response.json();
13083
- const sessionDetails = getSessionDetails(sessionInfoResp);
13084
- // Store user session details from session info
13085
- initSession(sessionDetails);
13086
- releaseVersion = sessionInfoResp.releaseVersion;
13161
+ const response = await isActiveService(thoughtSpotHost);
13162
+ return response;
13087
13163
  }
13088
13164
  catch (e) {
13089
13165
  return false;
13090
13166
  }
13091
- return response.status === 200;
13092
13167
  }
13093
13168
  /**
13094
- * Return releaseVersion if available
13169
+ * Services to be called after the login is successful,
13170
+ * This should be called after the cookie is set for cookie auth or
13171
+ * after the token is set for cookieless.
13172
+ *
13173
+ * @return {Promise<void>}
13174
+ * @example
13175
+ * ```js
13176
+ * await postLoginService();
13177
+ * ```
13178
+ * @version SDK: 1.28.3 | ThoughtSpot: *
13095
13179
  */
13096
- function getReleaseVersion() {
13097
- return releaseVersion;
13180
+ async function postLoginService() {
13181
+ try {
13182
+ const sessionInfo = await getSessionInfo();
13183
+ releaseVersion = sessionInfo.releaseVersion;
13184
+ const embedConfig = getEmbedConfig();
13185
+ if (!embedConfig.disableSDKTracking) {
13186
+ initMixpanel(sessionInfo);
13187
+ }
13188
+ }
13189
+ catch (e) {
13190
+ logger.error('Post login services failed.', e.message);
13191
+ }
13098
13192
  }
13099
13193
  /**
13100
- * Return a promise that resolves with the session information when
13101
- * authentication is successful. And info is available.
13102
- * @group Global methods
13194
+ * Return releaseVersion if available
13103
13195
  */
13104
- function getSessionInfo() {
13105
- return sessionInfoPromise;
13196
+ function getReleaseVersion() {
13197
+ return releaseVersion;
13106
13198
  }
13107
13199
  /**
13108
13200
  * Check if we are stuck at the SSO redirect URL
@@ -13132,7 +13224,14 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13132
13224
  }
13133
13225
  loggedInStatus = await isLoggedIn(thoughtSpotHost);
13134
13226
  if (!loggedInStatus) {
13135
- const authToken = await getAuthenticationToken(embedConfig);
13227
+ let authToken;
13228
+ try {
13229
+ authToken = await getAuthenticationToken(embedConfig);
13230
+ }
13231
+ catch (e) {
13232
+ loggedInStatus = false;
13233
+ throw e;
13234
+ }
13136
13235
  let resp;
13137
13236
  try {
13138
13237
  resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
@@ -13217,15 +13316,14 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13217
13316
  authElem.textContent = triggerText;
13218
13317
  authElem.addEventListener('click', openPopup, { once: true });
13219
13318
  }
13220
- samlCompletionPromise = samlCompletionPromise
13221
- || new Promise((resolve, reject) => {
13222
- window.addEventListener('message', (e) => {
13223
- if (e.data.type === exports.EmbedEvent.SAMLComplete) {
13224
- e.source.close();
13225
- resolve();
13226
- }
13227
- });
13319
+ samlCompletionPromise = samlCompletionPromise || new Promise((resolve, reject) => {
13320
+ window.addEventListener('message', (e) => {
13321
+ if (e.data.type === exports.EmbedEvent.SAMLComplete) {
13322
+ e.source.close();
13323
+ resolve();
13324
+ }
13228
13325
  });
13326
+ });
13229
13327
  authEE === null || authEE === void 0 ? void 0 : authEE.once(exports.AuthEvent.TRIGGER_SSO_POPUP, openPopup);
13230
13328
  return samlCompletionPromise;
13231
13329
  }
@@ -13287,7 +13385,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13287
13385
  const { thoughtSpotHost } = embedConfig;
13288
13386
  await fetchLogoutService(thoughtSpotHost);
13289
13387
  resetCachedAuthToken();
13290
- const thoughtspotIframes = document.querySelectorAll('[data-ts-iframe=\'true\']');
13388
+ const thoughtspotIframes = document.querySelectorAll("[data-ts-iframe='true']");
13291
13389
  if (thoughtspotIframes === null || thoughtspotIframes === void 0 ? void 0 : thoughtspotIframes.length) {
13292
13390
  thoughtspotIframes.forEach((el) => {
13293
13391
  el.parentElement.innerHTML = embedConfig.loginFailedMessage;
@@ -13341,6 +13439,8 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13341
13439
  notifyAuthFailure(exports.AuthFailureType.SDK);
13342
13440
  }
13343
13441
  else {
13442
+ // Post login service is called after successful login.
13443
+ postLoginService();
13344
13444
  notifyAuthSDKSuccess();
13345
13445
  }
13346
13446
  }, () => {
@@ -13632,13 +13732,13 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13632
13732
  };
13633
13733
  }
13634
13734
  /**
13735
+ * Responds to AuthInit sent from host signifying successful authentication in host.
13635
13736
  *
13636
13737
  * @param e
13738
+ * @returns {any}
13637
13739
  */
13638
13740
  function processAuthInit(e) {
13639
13741
  var _a, _b;
13640
- // Store user session details sent by app.
13641
- initSession(e.data);
13642
13742
  notifyAuthSuccess();
13643
13743
  // Expose only allowed details (eg: userGUID) back to SDK users.
13644
13744
  return {
@@ -13774,7 +13874,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13774
13874
  });
13775
13875
  }
13776
13876
 
13777
- var name="@thoughtspot/visual-embed-sdk";var version="1.32.0-alpha.0";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"6.7.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embedded","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"45 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
13877
+ var name="@thoughtspot/visual-embed-sdk";var version="1.32.0-alpha.2";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","current-git-branch":"^1.1.0","dts-bundle":"^0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"6.7.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^5.3.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embedded","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"46 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
13778
13878
 
13779
13879
  /**
13780
13880
  * Copyright (c) 2022
@@ -13872,6 +13972,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
13872
13972
  });
13873
13973
  }
13874
13974
  catch (e) {
13975
+ logger.error(`Received invalid token. Error : ${e === null || e === void 0 ? void 0 : e.message}`);
13875
13976
  processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
13876
13977
  }
13877
13978
  }
@@ -14030,7 +14131,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
14030
14131
  * @param query
14031
14132
  */
14032
14133
  getEmbedBasePath(query) {
14033
- let queryString = query;
14134
+ let queryString = (query.startsWith('?')) ? query : `?${query}`;
14034
14135
  if (this.shouldEncodeUrlQueryParams) {
14035
14136
  queryString = `?base64UrlEncodedFlags=${getEncodedQueryParamsString(queryString.substr(1))}`;
14036
14137
  }
@@ -14477,7 +14578,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
14477
14578
  isRegisteredBySDK,
14478
14579
  });
14479
14580
  if (this.isRendered) {
14480
- this.handleError('Please register event handlers before calling render');
14581
+ logger.warn('Please register event handlers before calling render');
14481
14582
  }
14482
14583
  const callbacks = this.eventHandlerMap.get(messageType) || [];
14483
14584
  callbacks.push({ options, callback });
@@ -14748,6 +14849,13 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
14748
14849
  class V1Embed extends TsEmbed {
14749
14850
  constructor(domSelector, viewConfig) {
14750
14851
  super(domSelector, viewConfig);
14852
+ /**
14853
+ * Only for testing purposes.
14854
+ *
14855
+ * @hidden
14856
+ */
14857
+ // eslint-disable-next-line camelcase
14858
+ this.test__executeCallbacks = this.executeCallbacks;
14751
14859
  this.viewConfig = { excludeRuntimeFiltersfromURL: false, ...viewConfig };
14752
14860
  }
14753
14861
  /**
@@ -14770,7 +14878,9 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
14770
14878
  const filterQuery = getFilterQuery(runtimeFilters || []);
14771
14879
  queryString = [filterQuery, queryString].filter(Boolean).join('&');
14772
14880
  }
14773
- return this.getV1EmbedBasePath(queryString);
14881
+ return (this.viewConfig.enableV2Shell_experimental)
14882
+ ? this.getEmbedBasePath(queryString)
14883
+ : this.getV1EmbedBasePath(queryString);
14774
14884
  }
14775
14885
  /**
14776
14886
  * @inheritdoc
@@ -15046,6 +15156,71 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
15046
15156
  }
15047
15157
  }
15048
15158
 
15159
+ /* eslint-disable quotes */
15160
+ const getPreviewQuery = `
15161
+ query GetEurekaVizSnapshots(
15162
+ $vizId: String!, $liveboardId: String!) {
15163
+ getEurekaVizSnapshot(
15164
+ id: $vizId
15165
+ reportBookId: $liveboardId
15166
+ reportBookType: "PINBOARD_ANSWER_BOOK"
15167
+ version: 9999999
15168
+ ) {
15169
+ id
15170
+ vizContent
15171
+ snapshotType
15172
+ createdMs
15173
+ }
15174
+ }
15175
+ `;
15176
+ async function getPreview(thoughtSpotHost, vizId, liveboardId) {
15177
+ return graphqlQuery({
15178
+ query: getPreviewQuery,
15179
+ variables: { vizId, liveboardId },
15180
+ thoughtSpotHost,
15181
+ });
15182
+ }
15183
+
15184
+ const addPreviewStylesIfNotPresent = () => {
15185
+ const styleEl = document.getElementById('ts-preview-style');
15186
+ if (styleEl) {
15187
+ return;
15188
+ }
15189
+ const previewStyles = `
15190
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ag-grid-community@32.0.2/styles/ag-grid.min.css">
15191
+ <style id="ts-preview-style">
15192
+ .ts-viz-preview-loader {
15193
+ position: absolute;
15194
+ top: 0;
15195
+ left: 0;
15196
+ right: 0;
15197
+ bottom: 0;
15198
+ display: flex;
15199
+ justify-content: center;
15200
+ align-items: center;
15201
+ background: linear-gradient(-45deg, #eee 40%, #fafafa 50%, #eee 60%);
15202
+ background-size: 300%;
15203
+ background-position-x: 100%;
15204
+ animation: shimmer 1s infinite linear;
15205
+ z-index: 999;
15206
+ filter: grayscale(0.7);
15207
+ }
15208
+
15209
+ @keyframes shimmer {
15210
+ to {
15211
+ background-position-x: 0%
15212
+ }
15213
+ }
15214
+
15215
+ .ts-viz-preview-loader .table-module__fullContainer {
15216
+ width: 100%;
15217
+ height: 100%;
15218
+ }
15219
+ </style>
15220
+ `;
15221
+ document.head.insertAdjacentHTML('beforeend', previewStyles);
15222
+ };
15223
+
15049
15224
  /**
15050
15225
  * Copyright (c) 2022
15051
15226
  *
@@ -15188,6 +15363,33 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
15188
15363
  super.trigger(exports.HostEvent.Navigate, path);
15189
15364
  }
15190
15365
  }
15366
+ async showPreviewLoader() {
15367
+ if (!this.viewConfig.showPreviewLoader || !this.viewConfig.vizId) {
15368
+ return;
15369
+ }
15370
+ try {
15371
+ const preview = await getPreview(this.thoughtSpotHost, this.viewConfig.vizId, this.viewConfig.liveboardId);
15372
+ if (!preview.vizContent) {
15373
+ return;
15374
+ }
15375
+ addPreviewStylesIfNotPresent();
15376
+ const div = document.createElement('div');
15377
+ div.innerHTML = `
15378
+ <div class=ts-viz-preview-loader>
15379
+ ${preview.vizContent}
15380
+ </div>
15381
+ `;
15382
+ const previewDiv = div.firstElementChild;
15383
+ this.el.appendChild(previewDiv);
15384
+ this.el.style.position = 'relative';
15385
+ this.on(exports.EmbedEvent.Data, () => {
15386
+ previewDiv.remove();
15387
+ });
15388
+ }
15389
+ catch (error) {
15390
+ console.error('Error fetching preview', error);
15391
+ }
15392
+ }
15191
15393
  beforePrerenderVisible() {
15192
15394
  var _a;
15193
15395
  const embedObj = (_a = this.insertedDomEl) === null || _a === void 0 ? void 0 : _a[this.embedNodeKey];
@@ -15232,6 +15434,7 @@ mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!]
15232
15434
  super.render();
15233
15435
  const src = this.getIFrameSrc();
15234
15436
  await this.renderV1Embed(src);
15437
+ this.showPreviewLoader();
15235
15438
  return this;
15236
15439
  }
15237
15440
  navigateToLiveboard(liveboardId, vizId, activeTabId) {