@thoughtspot/visual-embed-sdk 1.29.1-alpha.0 → 1.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/README.md +1 -1
  2. package/cjs/package.json +2 -1
  3. package/cjs/src/auth.d.ts +0 -15
  4. package/cjs/src/auth.d.ts.map +1 -1
  5. package/cjs/src/auth.js +2 -13
  6. package/cjs/src/auth.js.map +1 -1
  7. package/cjs/src/authToken.d.ts +1 -2
  8. package/cjs/src/authToken.d.ts.map +1 -1
  9. package/cjs/src/authToken.js +9 -3
  10. package/cjs/src/authToken.js.map +1 -1
  11. package/cjs/src/authToken.spec.d.ts +2 -0
  12. package/cjs/src/authToken.spec.d.ts.map +1 -0
  13. package/cjs/src/authToken.spec.js +29 -0
  14. package/cjs/src/authToken.spec.js.map +1 -0
  15. package/cjs/src/config.d.ts +0 -1
  16. package/cjs/src/config.d.ts.map +1 -1
  17. package/cjs/src/config.js +0 -2
  18. package/cjs/src/config.js.map +1 -1
  19. package/cjs/src/embed/app.d.ts +73 -43
  20. package/cjs/src/embed/app.d.ts.map +1 -1
  21. package/cjs/src/embed/app.js +45 -12
  22. package/cjs/src/embed/app.js.map +1 -1
  23. package/cjs/src/embed/app.spec.js +21 -0
  24. package/cjs/src/embed/app.spec.js.map +1 -1
  25. package/cjs/src/embed/base.d.ts +1 -7
  26. package/cjs/src/embed/base.d.ts.map +1 -1
  27. package/cjs/src/embed/base.js +9 -15
  28. package/cjs/src/embed/base.js.map +1 -1
  29. package/cjs/src/embed/base.spec.js +3 -1
  30. package/cjs/src/embed/base.spec.js.map +1 -1
  31. package/cjs/src/embed/embedConfig.d.ts +0 -2
  32. package/cjs/src/embed/embedConfig.d.ts.map +1 -1
  33. package/cjs/src/embed/embedConfig.js +0 -2
  34. package/cjs/src/embed/embedConfig.js.map +1 -1
  35. package/cjs/src/embed/liveboard.d.ts +14 -28
  36. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  37. package/cjs/src/embed/liveboard.js +9 -9
  38. package/cjs/src/embed/liveboard.js.map +1 -1
  39. package/cjs/src/embed/liveboard.spec.js +79 -4
  40. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  41. package/cjs/src/embed/sage.d.ts +5 -21
  42. package/cjs/src/embed/sage.d.ts.map +1 -1
  43. package/cjs/src/embed/sage.js +2 -23
  44. package/cjs/src/embed/sage.js.map +1 -1
  45. package/cjs/src/embed/sage.spec.js +20 -31
  46. package/cjs/src/embed/sage.spec.js.map +1 -1
  47. package/cjs/src/embed/search-bar.d.ts +0 -11
  48. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  49. package/cjs/src/embed/search-bar.js +0 -2
  50. package/cjs/src/embed/search-bar.js.map +1 -1
  51. package/cjs/src/embed/search.d.ts +60 -29
  52. package/cjs/src/embed/search.d.ts.map +1 -1
  53. package/cjs/src/embed/search.js +43 -9
  54. package/cjs/src/embed/search.js.map +1 -1
  55. package/cjs/src/embed/search.spec.js +34 -0
  56. package/cjs/src/embed/search.spec.js.map +1 -1
  57. package/cjs/src/embed/ts-embed.d.ts +1 -31
  58. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  59. package/cjs/src/embed/ts-embed.js +34 -43
  60. package/cjs/src/embed/ts-embed.js.map +1 -1
  61. package/cjs/src/embed/ts-embed.spec.js +83 -9
  62. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  63. package/cjs/src/errors.js +1 -1
  64. package/cjs/src/errors.js.map +1 -1
  65. package/cjs/src/index.d.ts +0 -1
  66. package/cjs/src/index.d.ts.map +1 -1
  67. package/cjs/src/index.js +0 -1
  68. package/cjs/src/index.js.map +1 -1
  69. package/cjs/src/mixpanel-service.d.ts +0 -1
  70. package/cjs/src/mixpanel-service.d.ts.map +1 -1
  71. package/cjs/src/mixpanel-service.js +0 -1
  72. package/cjs/src/mixpanel-service.js.map +1 -1
  73. package/cjs/src/react/index.d.ts +1 -12
  74. package/cjs/src/react/index.d.ts.map +1 -1
  75. package/cjs/src/react/index.js +1 -11
  76. package/cjs/src/react/index.js.map +1 -1
  77. package/cjs/src/react/index.spec.js +15 -3
  78. package/cjs/src/react/index.spec.js.map +1 -1
  79. package/cjs/src/test/test-utils.d.ts +0 -2
  80. package/cjs/src/test/test-utils.d.ts.map +1 -1
  81. package/cjs/src/test/test-utils.js +0 -2
  82. package/cjs/src/test/test-utils.js.map +1 -1
  83. package/cjs/src/tokenizedFetch.d.ts +0 -1
  84. package/cjs/src/tokenizedFetch.d.ts.map +1 -1
  85. package/cjs/src/tokenizedFetch.js +0 -1
  86. package/cjs/src/tokenizedFetch.js.map +1 -1
  87. package/cjs/src/types.d.ts +245 -366
  88. package/cjs/src/types.d.ts.map +1 -1
  89. package/cjs/src/types.js +196 -296
  90. package/cjs/src/types.js.map +1 -1
  91. package/cjs/src/utils/authService/authService.d.ts +0 -1
  92. package/cjs/src/utils/authService/authService.d.ts.map +1 -1
  93. package/cjs/src/utils/authService/authService.js +0 -1
  94. package/cjs/src/utils/authService/authService.js.map +1 -1
  95. package/cjs/src/utils/graphql/answerService/answer-queries.d.ts +2 -0
  96. package/cjs/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
  97. package/cjs/src/utils/graphql/answerService/answer-queries.js +57 -1
  98. package/cjs/src/utils/graphql/answerService/answer-queries.js.map +1 -1
  99. package/cjs/src/utils/graphql/answerService/answerService.d.ts +37 -12
  100. package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  101. package/cjs/src/utils/graphql/answerService/answerService.js +70 -14
  102. package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
  103. package/cjs/src/utils/graphql/answerService/answerService.spec.js +78 -0
  104. package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  105. package/cjs/src/utils/logger.d.ts.map +1 -1
  106. package/cjs/src/utils/logger.js +3 -5
  107. package/cjs/src/utils/logger.js.map +1 -1
  108. package/cjs/src/utils/processData.js +1 -1
  109. package/cjs/src/utils/processData.js.map +1 -1
  110. package/cjs/src/utils/processData.spec.js +1 -1
  111. package/cjs/src/utils/processData.spec.js.map +1 -1
  112. package/cjs/src/utils/processTrigger.d.ts +0 -1
  113. package/cjs/src/utils/processTrigger.d.ts.map +1 -1
  114. package/cjs/src/utils/processTrigger.js +0 -2
  115. package/cjs/src/utils/processTrigger.js.map +1 -1
  116. package/cjs/src/utils.d.ts +2 -10
  117. package/cjs/src/utils.d.ts.map +1 -1
  118. package/cjs/src/utils.js +19 -13
  119. package/cjs/src/utils.js.map +1 -1
  120. package/dist/src/auth.d.ts +0 -15
  121. package/dist/src/auth.d.ts.map +1 -1
  122. package/dist/src/authToken.d.ts +1 -2
  123. package/dist/src/authToken.d.ts.map +1 -1
  124. package/dist/src/authToken.spec.d.ts +2 -0
  125. package/dist/src/authToken.spec.d.ts.map +1 -0
  126. package/dist/src/config.d.ts +0 -1
  127. package/dist/src/config.d.ts.map +1 -1
  128. package/dist/src/embed/app.d.ts +73 -43
  129. package/dist/src/embed/app.d.ts.map +1 -1
  130. package/dist/src/embed/base.d.ts +1 -7
  131. package/dist/src/embed/base.d.ts.map +1 -1
  132. package/dist/src/embed/embedConfig.d.ts +0 -2
  133. package/dist/src/embed/embedConfig.d.ts.map +1 -1
  134. package/dist/src/embed/liveboard.d.ts +14 -28
  135. package/dist/src/embed/liveboard.d.ts.map +1 -1
  136. package/dist/src/embed/sage.d.ts +5 -21
  137. package/dist/src/embed/sage.d.ts.map +1 -1
  138. package/dist/src/embed/search-bar.d.ts +0 -11
  139. package/dist/src/embed/search-bar.d.ts.map +1 -1
  140. package/dist/src/embed/search.d.ts +60 -29
  141. package/dist/src/embed/search.d.ts.map +1 -1
  142. package/dist/src/embed/ts-embed.d.ts +1 -31
  143. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  144. package/dist/src/index.d.ts +0 -1
  145. package/dist/src/index.d.ts.map +1 -1
  146. package/dist/src/mixpanel-service.d.ts +0 -1
  147. package/dist/src/mixpanel-service.d.ts.map +1 -1
  148. package/dist/src/react/index.d.ts +1 -12
  149. package/dist/src/react/index.d.ts.map +1 -1
  150. package/dist/src/test/test-utils.d.ts +0 -2
  151. package/dist/src/test/test-utils.d.ts.map +1 -1
  152. package/dist/src/tokenizedFetch.d.ts +0 -1
  153. package/dist/src/tokenizedFetch.d.ts.map +1 -1
  154. package/dist/src/types.d.ts +245 -366
  155. package/dist/src/types.d.ts.map +1 -1
  156. package/dist/src/utils/authService/authService.d.ts +0 -1
  157. package/dist/src/utils/authService/authService.d.ts.map +1 -1
  158. package/dist/src/utils/graphql/answerService/answer-queries.d.ts +2 -0
  159. package/dist/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
  160. package/dist/src/utils/graphql/answerService/answerService.d.ts +37 -12
  161. package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  162. package/dist/src/utils/logger.d.ts.map +1 -1
  163. package/dist/src/utils/processTrigger.d.ts +0 -1
  164. package/dist/src/utils/processTrigger.d.ts.map +1 -1
  165. package/dist/src/utils.d.ts +2 -10
  166. package/dist/src/utils.d.ts.map +1 -1
  167. package/dist/tsembed-react.es.js +2331 -2358
  168. package/dist/tsembed-react.js +3475 -3498
  169. package/dist/tsembed.es.js +3690 -3922
  170. package/dist/tsembed.js +15218 -15442
  171. package/dist/visual-embed-sdk-react-full.d.ts +431 -564
  172. package/dist/visual-embed-sdk-react.d.ts +434 -567
  173. package/dist/visual-embed-sdk.d.ts +430 -552
  174. package/lib/package.json +2 -1
  175. package/lib/src/auth.d.ts +0 -15
  176. package/lib/src/auth.d.ts.map +1 -1
  177. package/lib/src/auth.js +3 -14
  178. package/lib/src/auth.js.map +1 -1
  179. package/lib/src/authToken.d.ts +1 -2
  180. package/lib/src/authToken.d.ts.map +1 -1
  181. package/lib/src/authToken.js +9 -3
  182. package/lib/src/authToken.js.map +1 -1
  183. package/lib/src/authToken.spec.d.ts +2 -0
  184. package/lib/src/authToken.spec.d.ts.map +1 -0
  185. package/lib/src/authToken.spec.js +26 -0
  186. package/lib/src/authToken.spec.js.map +1 -0
  187. package/lib/src/config.d.ts +0 -1
  188. package/lib/src/config.d.ts.map +1 -1
  189. package/lib/src/config.js +0 -2
  190. package/lib/src/config.js.map +1 -1
  191. package/lib/src/embed/app.d.ts +73 -43
  192. package/lib/src/embed/app.d.ts.map +1 -1
  193. package/lib/src/embed/app.js +44 -11
  194. package/lib/src/embed/app.js.map +1 -1
  195. package/lib/src/embed/app.spec.js +22 -1
  196. package/lib/src/embed/app.spec.js.map +1 -1
  197. package/lib/src/embed/base.d.ts +1 -7
  198. package/lib/src/embed/base.d.ts.map +1 -1
  199. package/lib/src/embed/base.js +8 -14
  200. package/lib/src/embed/base.js.map +1 -1
  201. package/lib/src/embed/base.spec.js +4 -2
  202. package/lib/src/embed/base.spec.js.map +1 -1
  203. package/lib/src/embed/embedConfig.d.ts +0 -2
  204. package/lib/src/embed/embedConfig.d.ts.map +1 -1
  205. package/lib/src/embed/embedConfig.js +0 -2
  206. package/lib/src/embed/embedConfig.js.map +1 -1
  207. package/lib/src/embed/liveboard.d.ts +14 -28
  208. package/lib/src/embed/liveboard.d.ts.map +1 -1
  209. package/lib/src/embed/liveboard.js +10 -10
  210. package/lib/src/embed/liveboard.js.map +1 -1
  211. package/lib/src/embed/liveboard.spec.js +79 -4
  212. package/lib/src/embed/liveboard.spec.js.map +1 -1
  213. package/lib/src/embed/sage.d.ts +5 -21
  214. package/lib/src/embed/sage.d.ts.map +1 -1
  215. package/lib/src/embed/sage.js +2 -23
  216. package/lib/src/embed/sage.js.map +1 -1
  217. package/lib/src/embed/sage.spec.js +20 -31
  218. package/lib/src/embed/sage.spec.js.map +1 -1
  219. package/lib/src/embed/search-bar.d.ts +0 -11
  220. package/lib/src/embed/search-bar.d.ts.map +1 -1
  221. package/lib/src/embed/search-bar.js +0 -2
  222. package/lib/src/embed/search-bar.js.map +1 -1
  223. package/lib/src/embed/search.d.ts +60 -29
  224. package/lib/src/embed/search.d.ts.map +1 -1
  225. package/lib/src/embed/search.js +43 -9
  226. package/lib/src/embed/search.js.map +1 -1
  227. package/lib/src/embed/search.spec.js +35 -1
  228. package/lib/src/embed/search.spec.js.map +1 -1
  229. package/lib/src/embed/ts-embed.d.ts +1 -31
  230. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  231. package/lib/src/embed/ts-embed.js +37 -46
  232. package/lib/src/embed/ts-embed.js.map +1 -1
  233. package/lib/src/embed/ts-embed.spec.js +83 -9
  234. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  235. package/lib/src/errors.js +1 -1
  236. package/lib/src/errors.js.map +1 -1
  237. package/lib/src/index.d.ts +0 -1
  238. package/lib/src/index.d.ts.map +1 -1
  239. package/lib/src/index.js +0 -1
  240. package/lib/src/index.js.map +1 -1
  241. package/lib/src/mixpanel-service.d.ts +0 -1
  242. package/lib/src/mixpanel-service.d.ts.map +1 -1
  243. package/lib/src/mixpanel-service.js +0 -1
  244. package/lib/src/mixpanel-service.js.map +1 -1
  245. package/lib/src/react/index.d.ts +1 -12
  246. package/lib/src/react/index.d.ts.map +1 -1
  247. package/lib/src/react/index.js +1 -11
  248. package/lib/src/react/index.js.map +1 -1
  249. package/lib/src/react/index.spec.js +16 -4
  250. package/lib/src/react/index.spec.js.map +1 -1
  251. package/lib/src/test/test-utils.d.ts +0 -2
  252. package/lib/src/test/test-utils.d.ts.map +1 -1
  253. package/lib/src/test/test-utils.js +0 -2
  254. package/lib/src/test/test-utils.js.map +1 -1
  255. package/lib/src/tokenizedFetch.d.ts +0 -1
  256. package/lib/src/tokenizedFetch.d.ts.map +1 -1
  257. package/lib/src/tokenizedFetch.js +0 -1
  258. package/lib/src/tokenizedFetch.js.map +1 -1
  259. package/lib/src/types.d.ts +245 -366
  260. package/lib/src/types.d.ts.map +1 -1
  261. package/lib/src/types.js +196 -296
  262. package/lib/src/types.js.map +1 -1
  263. package/lib/src/utils/authService/authService.d.ts +0 -1
  264. package/lib/src/utils/authService/authService.d.ts.map +1 -1
  265. package/lib/src/utils/authService/authService.js +0 -1
  266. package/lib/src/utils/authService/authService.js.map +1 -1
  267. package/lib/src/utils/authService/authService.spec.js +1 -1
  268. package/lib/src/utils/authService/authService.spec.js.map +1 -1
  269. package/lib/src/utils/graphql/answerService/answer-queries.d.ts +2 -0
  270. package/lib/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
  271. package/lib/src/utils/graphql/answerService/answer-queries.js +56 -0
  272. package/lib/src/utils/graphql/answerService/answer-queries.js.map +1 -1
  273. package/lib/src/utils/graphql/answerService/answerService.d.ts +37 -12
  274. package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  275. package/lib/src/utils/graphql/answerService/answerService.js +71 -15
  276. package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
  277. package/lib/src/utils/graphql/answerService/answerService.spec.js +80 -2
  278. package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  279. package/lib/src/utils/logger.d.ts.map +1 -1
  280. package/lib/src/utils/logger.js +2 -3
  281. package/lib/src/utils/logger.js.map +1 -1
  282. package/lib/src/utils/processData.js +1 -1
  283. package/lib/src/utils/processData.js.map +1 -1
  284. package/lib/src/utils/processData.spec.js +1 -1
  285. package/lib/src/utils/processData.spec.js.map +1 -1
  286. package/lib/src/utils/processTrigger.d.ts +0 -1
  287. package/lib/src/utils/processTrigger.d.ts.map +1 -1
  288. package/lib/src/utils/processTrigger.js +0 -2
  289. package/lib/src/utils/processTrigger.js.map +1 -1
  290. package/lib/src/utils.d.ts +2 -10
  291. package/lib/src/utils.d.ts.map +1 -1
  292. package/lib/src/utils.js +17 -12
  293. package/lib/src/utils.js.map +1 -1
  294. package/lib/src/visual-embed-sdk.d.ts +436 -558
  295. package/package.json +3 -1
  296. package/src/auth.spec.ts +72 -66
  297. package/src/auth.ts +53 -54
  298. package/src/authToken.spec.ts +31 -0
  299. package/src/authToken.ts +12 -12
  300. package/src/config.ts +0 -2
  301. package/src/embed/app.spec.ts +39 -5
  302. package/src/embed/app.ts +108 -50
  303. package/src/embed/base.spec.ts +5 -4
  304. package/src/embed/base.ts +30 -36
  305. package/src/embed/embed.spec.ts +0 -2
  306. package/src/embed/embedConfig.ts +0 -2
  307. package/src/embed/events.spec.ts +0 -2
  308. package/src/embed/liveboard.spec.ts +104 -11
  309. package/src/embed/liveboard.ts +25 -38
  310. package/src/embed/pinboard.spec.ts +0 -2
  311. package/src/embed/sage.spec.ts +20 -38
  312. package/src/embed/sage.ts +5 -38
  313. package/src/embed/search-bar.tsx +0 -11
  314. package/src/embed/search.spec.ts +48 -2
  315. package/src/embed/search.ts +94 -38
  316. package/src/embed/ts-embed-trigger.spec.ts +0 -3
  317. package/src/embed/ts-embed.spec.ts +109 -32
  318. package/src/embed/ts-embed.ts +68 -79
  319. package/src/errors.ts +1 -1
  320. package/src/index.ts +1 -3
  321. package/src/mixpanel-service.spec.ts +3 -4
  322. package/src/mixpanel-service.ts +1 -4
  323. package/src/react/index.spec.tsx +48 -67
  324. package/src/react/index.tsx +1 -13
  325. package/src/test/test-utils.ts +0 -2
  326. package/src/tokenizedFetch.ts +0 -1
  327. package/src/types.ts +245 -365
  328. package/src/utils/authService/authService.spec.ts +8 -13
  329. package/src/utils/authService/authService.ts +0 -2
  330. package/src/utils/authService/tokenizedAuthService.ts +8 -38
  331. package/src/utils/graphql/answerService/answer-queries.ts +58 -0
  332. package/src/utils/graphql/answerService/answerService.spec.ts +88 -2
  333. package/src/utils/graphql/answerService/answerService.ts +87 -16
  334. package/src/utils/logger.ts +2 -3
  335. package/src/utils/processData.spec.ts +3 -4
  336. package/src/utils/processData.ts +4 -2
  337. package/src/utils/processTrigger.ts +0 -2
  338. package/src/utils.ts +21 -13
  339. package/cjs/src/utils/sessionInfoService.d.ts +0 -66
  340. package/cjs/src/utils/sessionInfoService.d.ts.map +0 -1
  341. package/cjs/src/utils/sessionInfoService.js +0 -92
  342. package/cjs/src/utils/sessionInfoService.js.map +0 -1
  343. package/lib/src/utils/sessionInfoService.d.ts +0 -66
  344. package/lib/src/utils/sessionInfoService.d.ts.map +0 -1
  345. package/lib/src/utils/sessionInfoService.js +0 -85
  346. package/lib/src/utils/sessionInfoService.js.map +0 -1
  347. package/src/utils/sessionInfoService.ts +0 -101
@@ -1,11 +1,11 @@
1
1
  import {
2
- fetchSessionInfoService,
3
- fetchAuthTokenService,
2
+ EndPoints,
3
+ fetchAuthPostService,
4
4
  fetchAuthService,
5
+ fetchAuthTokenService,
5
6
  fetchBasicAuthService,
6
- fetchAuthPostService,
7
+ fetchSessionInfoService,
7
8
  verifyTokenService,
8
- EndPoints,
9
9
  } from '.';
10
10
  import { logger } from '../logger';
11
11
 
@@ -26,10 +26,9 @@ describe('Unit test for authService', () => {
26
26
  status: 200,
27
27
  ok: true,
28
28
  }));
29
- const response = await fetchSessionInfoService(thoughtSpotHost);
30
- expect(response.success).toBe(true);
29
+ const response = await fetchSessionInfoService(authVerificationUrl);
30
+ expect(response.status).toBe(200);
31
31
  expect(fetch).toHaveBeenCalledTimes(1);
32
- expect(fetch).toBeCalledWith(`${thoughtSpotHost}${EndPoints.SESSION_INFO}`, {});
33
32
  });
34
33
 
35
34
  test('fetchAuthTokenService', async () => {
@@ -109,12 +108,8 @@ describe('Unit test for authService', () => {
109
108
  status: 500,
110
109
  ok: false,
111
110
  }));
112
- try {
113
- await fetchSessionInfoService(authVerificationUrl);
114
- } catch (e) {
115
- expect(e.message).toContain('Failed to fetch session info');
116
- }
117
- expect(logger.error).toHaveBeenCalledWith('Failed to fetch http://localhost:3000/callosum/v1/session/info', 'error');
111
+ await fetchSessionInfoService(authVerificationUrl);
112
+ expect(logger.error).toHaveBeenCalledWith('Failure', 'error');
118
113
  });
119
114
 
120
115
  test('verifyTokenService', async () => {
@@ -2,7 +2,6 @@ import { logger } from '../logger';
2
2
 
3
3
  export const EndPoints = {
4
4
  AUTH_VERIFICATION: '/callosum/v1/session/info',
5
- SESSION_INFO: '/callosum/v1/session/info',
6
5
  SAML_LOGIN_TEMPLATE: (targetUrl: string) => `/callosum/v1/saml/login?targetURLPath=${targetUrl}`,
7
6
  OIDC_LOGIN_TEMPLATE: (targetUrl: string) => `/callosum/v1/oidc/login?targetURLPath=${targetUrl}`,
8
7
  TOKEN_LOGIN: '/callosum/v1/session/login/token',
@@ -29,7 +28,6 @@ function failureLoggedFetch(url: string, options: RequestInit = {}): Promise<Res
29
28
 
30
29
  /**
31
30
  * Service to validate a auth token against a ThoughtSpot host.
32
- *
33
31
  * @param thoughtSpotHost : ThoughtSpot host to verify the token against.
34
32
  * @param authToken : Auth token to verify.
35
33
  */
@@ -7,33 +7,23 @@ import { EndPoints } from './authService';
7
7
  * @param url
8
8
  * @param options
9
9
  */
10
- function tokenizedFailureLoggedFetch(url: string, options: RequestInit = {}): Promise<Response> {
10
+ function tokenisedFailureLoggedFetch(url: string, options: RequestInit = {}): Promise<Response> {
11
11
  return tokenizedFetch(url, options).then(async (r) => {
12
12
  if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
13
- logger.error(`Failed to fetch ${url}`, await r.text?.());
13
+ logger.error('Failure', await r.text?.());
14
14
  }
15
15
  return r;
16
16
  });
17
17
  }
18
18
 
19
19
  /**
20
- * Fetches the session info from the ThoughtSpot server.
21
20
  *
22
- * @param thoughtspotHost
23
- * @returns {Promise<any>}
24
- * @example
25
- * ```js
26
- * const response = await sessionInfoService();
27
- * ```
21
+ * @param authVerificationUrl
28
22
  */
29
- export async function fetchSessionInfoService(thoughtspotHost: string): Promise<any> {
30
- const sessionInfoPath = `${thoughtspotHost}${EndPoints.SESSION_INFO}`;
31
- const response = await tokenizedFailureLoggedFetch(sessionInfoPath);
32
- if (!response.ok) {
33
- throw new Error(`Failed to fetch session info: ${response.statusText}`);
34
- }
35
- const data = await response.json();
36
- return data;
23
+ export function fetchSessionInfoService(authVerificationUrl: string): Promise<any> {
24
+ return tokenisedFailureLoggedFetch(authVerificationUrl, {
25
+ credentials: 'include',
26
+ });
37
27
  }
38
28
 
39
29
  /**
@@ -41,7 +31,7 @@ export async function fetchSessionInfoService(thoughtspotHost: string): Promise<
41
31
  * @param thoughtSpotHost
42
32
  */
43
33
  export async function fetchLogoutService(thoughtSpotHost: string): Promise<any> {
44
- return tokenizedFailureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
34
+ return tokenisedFailureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
45
35
  credentials: 'include',
46
36
  method: 'POST',
47
37
  headers: {
@@ -49,23 +39,3 @@ export async function fetchLogoutService(thoughtSpotHost: string): Promise<any>
49
39
  },
50
40
  });
51
41
  }
52
-
53
- /**
54
- * Is active service to check if the user is logged in.
55
- *
56
- * @param thoughtSpotHost
57
- * @version SDK: 1.28.4 | ThoughtSpot: *
58
- */
59
- export async function isActiveService(thoughtSpotHost: string): Promise<boolean> {
60
- const isActiveUrl = `${thoughtSpotHost}${EndPoints.IS_ACTIVE}`;
61
- try {
62
- const res = await tokenizedFetch(isActiveUrl, {
63
- credentials: 'include',
64
- });
65
- return res.ok;
66
- } catch (e) {
67
- logger.warn(`Is Logged In Service failed : ${e.message}`);
68
- }
69
-
70
- return false;
71
- }
@@ -53,6 +53,64 @@ export const addColumns = `
53
53
  }
54
54
  `;
55
55
 
56
+ export const addFilter = `
57
+ mutation AddUpdateFilter($session: BachSessionIdInput!, $params: AddUpdateFilterInput!) {
58
+ Answer__addUpdateFilter(session: $session, params: $params) {
59
+ ${bachSessionId}
60
+ }
61
+ }
62
+ `;
63
+
64
+ export const getAnswer = `
65
+ query GetAnswer($session: BachSessionIdInput!) {
66
+ getAnswer(session: $session) {
67
+ ${bachSessionId}
68
+ answer {
69
+ id
70
+ sources {
71
+ header {
72
+ guid
73
+ displayName
74
+ }
75
+ }
76
+ filterGroups {
77
+ columnInfo {
78
+ name
79
+ referencedColumns {
80
+ guid
81
+ displayName
82
+ }
83
+ }
84
+ filters {
85
+ filterContent {
86
+ filterType
87
+ negate
88
+ value {
89
+ key
90
+ }
91
+ }
92
+ }
93
+ }
94
+ visualizations {
95
+ ... on TableViz {
96
+ columns {
97
+ column {
98
+ id
99
+ name
100
+ referencedColumns {
101
+ guid
102
+ displayName
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ `;
113
+
56
114
  export const getAnswerData = `
57
115
  query GetTableWithHeadlineData($session: BachSessionIdInput!, $deadline: Int!, $dataPaginationParams: DataPaginationParamsInput!) {
58
116
  getAnswer(session: $session) {
@@ -1,7 +1,7 @@
1
1
  import 'jest-fetch-mock';
2
- import { AuthType, VizPoint } from '../../../types';
2
+ import { AuthType, RuntimeFilterOp, VizPoint } from '../../../types';
3
3
  import { AnswerService } from './answerService';
4
- import { getAnswerData, removeColumns } from './answer-queries';
4
+ import { getAnswerData, removeColumns, addFilter } from './answer-queries';
5
5
  import * as authTokenInstance from '../../../authToken';
6
6
  import * as tokenizedFetch from '../../../tokenizedFetch';
7
7
  import * as embedConfigInstance from '../../../embed/embedConfig';
@@ -266,4 +266,90 @@ describe('Answer service tests', () => {
266
266
  const answerService = createAnswerService({}, null);
267
267
  await expect(answerService.getUnderlyingDataForPoint(['col2'])).rejects.toThrow();
268
268
  });
269
+
270
+ test('addFilter should call the right API', async () => {
271
+ fetchMock.mockResponses(
272
+ JSON.stringify({
273
+ data: {
274
+ getSourceDetailById: [{
275
+ columns: [{
276
+ id: 'id1',
277
+ name: 'col1',
278
+ }],
279
+ }],
280
+ },
281
+ }),
282
+ JSON.stringify({
283
+ data: {
284
+ Answer__addUpdateFilter: {
285
+ id: {
286
+ genNo: 2,
287
+ },
288
+ },
289
+ },
290
+ }),
291
+ );
292
+ const answerService = createAnswerService({
293
+ sources: [{
294
+ header: {
295
+ guid: 'source1',
296
+ },
297
+ }],
298
+ });
299
+ const session = await answerService.addFilter('col1', RuntimeFilterOp.IN, [2]);
300
+ expect(fetchMock).toHaveBeenCalledWith(
301
+ 'https://tshost/prism/?op=AddUpdateFilter',
302
+ expect.objectContaining({
303
+ body: JSON.stringify({
304
+ operationName: 'AddUpdateFilter',
305
+ query: addFilter,
306
+ variables: {
307
+ session: defaultSession,
308
+ params: {
309
+ filterContent: [{
310
+ filterType: 'IN',
311
+ value: [{
312
+ type: 'DOUBLE',
313
+ doubleValue: 2,
314
+ }],
315
+ }],
316
+ filterGroupId: {
317
+ logicalColumnId: 'id1',
318
+ },
319
+ },
320
+ },
321
+ }),
322
+ }),
323
+ );
324
+ });
325
+
326
+ test('Should fetch answer if not passed', async () => {
327
+ fetchMock.mockResponses(JSON.stringify({
328
+ data: {
329
+ getAnswer: {
330
+ id: {},
331
+ answer: {
332
+ visualizations: [{
333
+ columns: [{
334
+ column: {
335
+ id: 'id1',
336
+ name: 'col1',
337
+ },
338
+ }],
339
+ }],
340
+ sources: [{
341
+ header: {
342
+ guid: 'source1',
343
+ displayName: 'source1',
344
+ },
345
+ }],
346
+ filterGroups: [],
347
+ },
348
+ },
349
+ },
350
+ }));
351
+ const answerService = new AnswerService(defaultSession, null, 'https://tshost');
352
+ const answer = await answerService.getAnswer();
353
+ expect(answer.sources[0].header.guid).toBe('source1');
354
+ });
269
355
  });
@@ -1,6 +1,8 @@
1
1
  import { tokenizedFetch } from '../../../tokenizedFetch';
2
- import type { ColumnValue, VizPoint } from '../../../types';
3
- import { deepMerge, removeTypename } from '../../../utils';
2
+ import type {
3
+ ColumnValue, RuntimeFilter, RuntimeFilterOp, VizPoint,
4
+ } from '../../../types';
5
+ import { deepMerge, getTypeFromValue, removeTypename } from '../../../utils';
4
6
  import { graphqlQuery } from '../graphql-request';
5
7
  import { getSourceDetail } from '../sourceService';
6
8
  import * as queries from './answer-queries';
@@ -27,7 +29,6 @@ export interface UnderlyingDataPoint {
27
29
  * custom action payload. This service could be used to run
28
30
  * graphql queries in the context of the answer on which the
29
31
  * custom action was triggered.
30
- *
31
32
  * @example
32
33
  * ```js
33
34
  * embed.on(EmbedEvent.CustomAction, e => {
@@ -37,13 +38,24 @@ export interface UnderlyingDataPoint {
37
38
  * const data = await underlying.fetchData(0, 100);
38
39
  * })
39
40
  * ```
41
+ * @example
42
+ * ```js
43
+ * embed.on(EmbedEvent.Data, async (e) => {
44
+ * const service = await embed.getAnswerService();
45
+ * await service.addColumns([
46
+ * "<column guid>"
47
+ * ]);
48
+ * console.log(await service.fetchData());
49
+ * });
50
+ * ```
40
51
  * @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
41
52
  * @group Events
42
53
  */
43
54
  export class AnswerService {
55
+ private answer: Promise<any>;
56
+
44
57
  /**
45
58
  * Should not need to be called directly.
46
- *
47
59
  * @param session
48
60
  * @param answer
49
61
  * @param thoughtSpotHost
@@ -51,11 +63,19 @@ export class AnswerService {
51
63
  */
52
64
  constructor(
53
65
  private session: SessionInterface,
54
- private answer: any,
66
+ answer: any,
55
67
  private thoughtSpotHost: string,
56
68
  private selectedPoints?: VizPoint[],
57
69
  ) {
58
70
  this.session = removeTypename(session);
71
+ if (!answer) {
72
+ this.answer = this.executeQuery(
73
+ queries.getAnswer,
74
+ {},
75
+ ).then((data) => data?.answer);
76
+ } else {
77
+ this.answer = answer;
78
+ }
59
79
  }
60
80
 
61
81
  /**
@@ -63,7 +83,7 @@ export class AnswerService {
63
83
  * This can be used to get the list of all columns in the data source for example.
64
84
  */
65
85
  public async getSourceDetail() {
66
- const sourceId = this.answer.sources[0].header.guid;
86
+ const sourceId = (await this.answer).sources[0].header.guid;
67
87
  return getSourceDetail(
68
88
  this.thoughtSpotHost,
69
89
  sourceId,
@@ -72,7 +92,6 @@ export class AnswerService {
72
92
 
73
93
  /**
74
94
  * Remove columnIds and return updated answer session.
75
- *
76
95
  * @param columnIds
77
96
  * @returns
78
97
  */
@@ -87,7 +106,6 @@ export class AnswerService {
87
106
 
88
107
  /**
89
108
  * Add columnIds and return updated answer session.
90
- *
91
109
  * @param columnIds
92
110
  * @returns
93
111
  */
@@ -100,9 +118,63 @@ export class AnswerService {
100
118
  );
101
119
  }
102
120
 
121
+ /**
122
+ * Add columns by names and return updated answer session.
123
+ * @param columnNames
124
+ * @returns
125
+ * @example
126
+ * ```js
127
+ * embed.on(EmbedEvent.Data, async (e) => {
128
+ * const service = await embed.getAnswerService();
129
+ * await service.addColumnsByNames([
130
+ * "col name 1",
131
+ * "col name 2"
132
+ * ]);
133
+ * console.log(await service.fetchData());
134
+ * });
135
+ */
136
+ public async addColumnsByNames(columnNames: string[]) {
137
+ const sourceDetail = await this.getSourceDetail();
138
+ const columnGuids = getGuidsFromColumnNames(sourceDetail, columnNames);
139
+ return this.addColumns([...columnGuids]);
140
+ }
141
+
142
+ /**
143
+ * Add a filter to the answer.
144
+ * @param columnName
145
+ * @param operator
146
+ * @param values
147
+ * @returns
148
+ */
149
+ public async addFilter(columnName: string, operator: RuntimeFilterOp, values: RuntimeFilter['values']) {
150
+ const sourceDetail = await this.getSourceDetail();
151
+ const columnGuids = getGuidsFromColumnNames(sourceDetail, [columnName]);
152
+ return this.executeQuery(
153
+ queries.addFilter,
154
+ {
155
+ params: {
156
+ filterContent: [{
157
+ filterType: operator,
158
+ value: values.map(
159
+ (v) => {
160
+ const [type, prefix] = getTypeFromValue(v);
161
+ return {
162
+ type: type.toUpperCase(),
163
+ [`${prefix}Value`]: v,
164
+ };
165
+ },
166
+ ),
167
+ }],
168
+ filterGroupId: {
169
+ logicalColumnId: columnGuids.values().next().value,
170
+ },
171
+ },
172
+ },
173
+ );
174
+ }
175
+
103
176
  /**
104
177
  * Fetch data from the answer.
105
- *
106
178
  * @param offset
107
179
  * @param size
108
180
  * @returns
@@ -131,7 +203,6 @@ export class AnswerService {
131
203
  /**
132
204
  * Fetch the data for the answer as a CSV blob. This might be
133
205
  * quicker for larger data.
134
- *
135
206
  * @param userLocale
136
207
  * @param includeInfo Include the CSV header in the output
137
208
  * @returns Response
@@ -146,7 +217,6 @@ export class AnswerService {
146
217
  /**
147
218
  * Just get the internal URL for this answer's data
148
219
  * as a CSV blob.
149
- *
150
220
  * @param userLocale
151
221
  * @param includeInfo
152
222
  * @returns
@@ -159,7 +229,6 @@ export class AnswerService {
159
229
  * Get underlying data given a point and the output column names.
160
230
  * In case of a context menu action, the selectedPoints are
161
231
  * automatically passed.
162
- *
163
232
  * @param outputColumnNames
164
233
  * @param selectedPoints
165
234
  * @example
@@ -224,7 +293,6 @@ export class AnswerService {
224
293
 
225
294
  /**
226
295
  * Execute a custom graphql query in the context of the answer.
227
- *
228
296
  * @param query graphql query
229
297
  * @param variables graphql variables
230
298
  * @returns
@@ -246,12 +314,15 @@ export class AnswerService {
246
314
 
247
315
  /**
248
316
  * Get the internal session details for the answer.
249
- *
250
317
  * @returns
251
318
  */
252
319
  public getSession() {
253
320
  return this.session;
254
321
  }
322
+
323
+ public getAnswer() {
324
+ return this.answer;
325
+ }
255
326
  }
256
327
 
257
328
  /**
@@ -261,12 +332,12 @@ export class AnswerService {
261
332
  */
262
333
  function getGuidsFromColumnNames(sourceDetail: any, colNames: string[]) {
263
334
  const cols = sourceDetail.columns.reduce((colSet: any, col: any) => {
264
- colSet[col.name] = col;
335
+ colSet[col.name.toLowerCase()] = col;
265
336
  return colSet;
266
337
  }, {});
267
338
 
268
339
  return new Set(colNames.map((colName) => {
269
- const col = cols[colName];
340
+ const col = cols[colName.toLowerCase()];
270
341
  return col.id;
271
342
  }));
272
343
  }
@@ -1,11 +1,10 @@
1
- import isUndefined from 'lodash/isUndefined';
2
- import noop from 'lodash/noop';
1
+ import { isUndefined } from '../utils';
3
2
  import { LogLevel } from '../types';
4
3
 
5
4
  const logFunctions: {
6
5
  [key: string]: (...args: any[]) => void;
7
6
  } = {
8
- [LogLevel.SILENT]: noop,
7
+ [LogLevel.SILENT]: () => undefined,
9
8
  [LogLevel.ERROR]: console.error,
10
9
  [LogLevel.WARN]: console.warn,
11
10
  [LogLevel.INFO]: console.info,
@@ -4,11 +4,9 @@ import * as auth from '../auth';
4
4
  import * as base from '../embed/base';
5
5
  import * as embedConfigInstance from '../embed/embedConfig';
6
6
  import { EmbedEvent, AuthType } from '../types';
7
- import * as sessionInfoService from './sessionInfoService';
8
7
 
9
8
  describe('Unit test for process data', () => {
10
9
  beforeAll(() => {
11
- jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve({}));
12
10
  base.init({
13
11
  thoughtSpotHost: 'https://tshost',
14
12
  authType: AuthType.None,
@@ -37,7 +35,7 @@ describe('Unit test for process data', () => {
37
35
  expect.objectContaining({
38
36
  ...processedData,
39
37
  answerService: {
40
- answer: undefined,
38
+ answer: {},
41
39
  selectedPoints: undefined,
42
40
  session: undefined,
43
41
  thoughtSpotHost: 'http://localhost',
@@ -60,14 +58,15 @@ describe('Unit test for process data', () => {
60
58
  isPublicUser: false,
61
59
  };
62
60
  const e = { type: EmbedEvent.AuthInit, data: sessionInfo };
61
+ jest.spyOn(auth, 'initSession').mockReturnValue(null);
63
62
  jest.spyOn(base, 'notifyAuthSuccess');
64
- jest.spyOn(sessionInfoService, 'getSessionInfoSync').mockReturnValue(sessionInfo);
65
63
  expect(processDataInstance.processEventData(e.type, e, '', null)).toEqual({
66
64
  type: e.type,
67
65
  data: {
68
66
  userGUID: sessionInfo.userGUID,
69
67
  },
70
68
  });
69
+ expect(auth.initSession).toBeCalledWith(sessionInfo);
71
70
  expect(base.notifyAuthSuccess).toBeCalled();
72
71
  });
73
72
 
@@ -5,7 +5,7 @@ import {
5
5
  notifyAuthSuccess,
6
6
  notifyLogout,
7
7
  } from '../embed/base';
8
- import { AuthFailureType } from '../auth';
8
+ import { AuthFailureType, initSession } from '../auth';
9
9
  import { AuthType, CustomActionPayload, EmbedEvent } from '../types';
10
10
  import { AnswerService } from './graphql/answerService/answerService';
11
11
  import { resetCachedAuthToken } from '../authToken';
@@ -19,7 +19,7 @@ export function processCustomAction(e: any, thoughtSpotHost: string) {
19
19
  const { session, embedAnswerData, contextMenuPoints } = e.data as CustomActionPayload;
20
20
  const answerService = new AnswerService(
21
21
  session,
22
- embedAnswerData,
22
+ embedAnswerData || {},
23
23
  thoughtSpotHost,
24
24
  contextMenuPoints?.selectedPoints,
25
25
  );
@@ -34,6 +34,8 @@ export function processCustomAction(e: any, thoughtSpotHost: string) {
34
34
  * @param e
35
35
  */
36
36
  function processAuthInit(e: any) {
37
+ // Store user session details sent by app.
38
+ initSession(e.data);
37
39
  notifyAuthSuccess();
38
40
 
39
41
  // Expose only allowed details (eg: userGUID) back to SDK users.
@@ -3,7 +3,6 @@ import { HostEvent } from '../types';
3
3
 
4
4
  /**
5
5
  * Reloads the ThoughtSpot iframe.
6
- *
7
6
  * @param iFrame
8
7
  */
9
8
  export const reload = (iFrame: HTMLIFrameElement) => {
@@ -16,7 +15,6 @@ export const reload = (iFrame: HTMLIFrameElement) => {
16
15
 
17
16
  /**
18
17
  * Post iframe message.
19
- *
20
18
  * @param iFrame
21
19
  * @param message
22
20
  * @param message.type