@thoughtspot/visual-embed-sdk 1.28.0-preRender → 1.28.0

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 (216) hide show
  1. package/README.md +1 -1
  2. package/cjs/package.json +3 -4
  3. package/cjs/src/auth.d.ts +16 -1
  4. package/cjs/src/auth.d.ts.map +1 -1
  5. package/cjs/src/auth.js +7 -3
  6. package/cjs/src/auth.js.map +1 -1
  7. package/cjs/src/auth.spec.d.ts.map +1 -1
  8. package/cjs/src/auth.spec.js +9 -0
  9. package/cjs/src/auth.spec.js.map +1 -1
  10. package/cjs/src/embed/app.d.ts +150 -7
  11. package/cjs/src/embed/app.d.ts.map +1 -1
  12. package/cjs/src/embed/app.js +5 -5
  13. package/cjs/src/embed/app.js.map +1 -1
  14. package/cjs/src/embed/app.spec.js +19 -1
  15. package/cjs/src/embed/app.spec.js.map +1 -1
  16. package/cjs/src/embed/base.d.ts +1 -1
  17. package/cjs/src/embed/base.d.ts.map +1 -1
  18. package/cjs/src/embed/base.js +5 -8
  19. package/cjs/src/embed/base.js.map +1 -1
  20. package/cjs/src/embed/base.spec.js +1 -1
  21. package/cjs/src/embed/base.spec.js.map +1 -1
  22. package/cjs/src/embed/embed.spec.js +0 -15
  23. package/cjs/src/embed/embed.spec.js.map +1 -1
  24. package/cjs/src/embed/liveboard.d.ts +113 -4
  25. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  26. package/cjs/src/embed/liveboard.js +2 -2
  27. package/cjs/src/embed/liveboard.js.map +1 -1
  28. package/cjs/src/embed/liveboard.spec.js +20 -1
  29. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  30. package/cjs/src/embed/pinboard.spec.js +20 -1
  31. package/cjs/src/embed/pinboard.spec.js.map +1 -1
  32. package/cjs/src/embed/sage.d.ts +1 -1
  33. package/cjs/src/embed/sage.d.ts.map +1 -1
  34. package/cjs/src/embed/sage.js +2 -2
  35. package/cjs/src/embed/sage.js.map +1 -1
  36. package/cjs/src/embed/search-bar.d.ts +37 -6
  37. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  38. package/cjs/src/embed/search-bar.js +2 -2
  39. package/cjs/src/embed/search-bar.js.map +1 -1
  40. package/cjs/src/embed/search.d.ts +85 -2
  41. package/cjs/src/embed/search.d.ts.map +1 -1
  42. package/cjs/src/embed/search.js +6 -6
  43. package/cjs/src/embed/search.js.map +1 -1
  44. package/cjs/src/embed/search.spec.js +25 -1
  45. package/cjs/src/embed/search.spec.js.map +1 -1
  46. package/cjs/src/embed/ts-embed-trigger.spec.d.ts +2 -0
  47. package/cjs/src/embed/ts-embed-trigger.spec.d.ts.map +1 -0
  48. package/cjs/src/embed/ts-embed-trigger.spec.js +34 -0
  49. package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -0
  50. package/cjs/src/embed/ts-embed.d.ts +2 -2
  51. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  52. package/cjs/src/embed/ts-embed.js +18 -13
  53. package/cjs/src/embed/ts-embed.js.map +1 -1
  54. package/cjs/src/embed/ts-embed.spec.js +64 -25
  55. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  56. package/cjs/src/index.d.ts +2 -1
  57. package/cjs/src/index.d.ts.map +1 -1
  58. package/cjs/src/index.js +3 -1
  59. package/cjs/src/index.js.map +1 -1
  60. package/cjs/src/react/index.spec.js +13 -1
  61. package/cjs/src/react/index.spec.js.map +1 -1
  62. package/cjs/src/test/test-utils.d.ts +1 -0
  63. package/cjs/src/test/test-utils.d.ts.map +1 -1
  64. package/cjs/src/test/test-utils.js +10 -1
  65. package/cjs/src/test/test-utils.js.map +1 -1
  66. package/cjs/src/tokenizedFetch.d.ts +9 -0
  67. package/cjs/src/tokenizedFetch.d.ts.map +1 -1
  68. package/cjs/src/tokenizedFetch.js +9 -0
  69. package/cjs/src/tokenizedFetch.js.map +1 -1
  70. package/cjs/src/types.d.ts +279 -43
  71. package/cjs/src/types.d.ts.map +1 -1
  72. package/cjs/src/types.js +95 -20
  73. package/cjs/src/types.js.map +1 -1
  74. package/cjs/src/utils/authService/authService.d.ts.map +1 -1
  75. package/cjs/src/utils/authService/authService.js +9 -3
  76. package/cjs/src/utils/authService/authService.js.map +1 -1
  77. package/cjs/src/utils/authService/authService.spec.js +22 -0
  78. package/cjs/src/utils/authService/authService.spec.js.map +1 -1
  79. package/dist/src/auth.d.ts +16 -1
  80. package/dist/src/auth.d.ts.map +1 -1
  81. package/dist/src/auth.spec.d.ts.map +1 -1
  82. package/dist/src/embed/app.d.ts +150 -7
  83. package/dist/src/embed/app.d.ts.map +1 -1
  84. package/dist/src/embed/base.d.ts +1 -1
  85. package/dist/src/embed/base.d.ts.map +1 -1
  86. package/dist/src/embed/liveboard.d.ts +113 -4
  87. package/dist/src/embed/liveboard.d.ts.map +1 -1
  88. package/dist/src/embed/sage.d.ts +1 -1
  89. package/dist/src/embed/sage.d.ts.map +1 -1
  90. package/dist/src/embed/search-bar.d.ts +37 -6
  91. package/dist/src/embed/search-bar.d.ts.map +1 -1
  92. package/dist/src/embed/search.d.ts +85 -2
  93. package/dist/src/embed/search.d.ts.map +1 -1
  94. package/dist/src/embed/ts-embed-trigger.spec.d.ts +2 -0
  95. package/dist/src/embed/ts-embed-trigger.spec.d.ts.map +1 -0
  96. package/dist/src/embed/ts-embed.d.ts +2 -2
  97. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  98. package/dist/src/index.d.ts +2 -1
  99. package/dist/src/index.d.ts.map +1 -1
  100. package/dist/src/test/test-utils.d.ts +1 -0
  101. package/dist/src/test/test-utils.d.ts.map +1 -1
  102. package/dist/src/tokenizedFetch.d.ts +9 -0
  103. package/dist/src/tokenizedFetch.d.ts.map +1 -1
  104. package/dist/src/types.d.ts +279 -43
  105. package/dist/src/types.d.ts.map +1 -1
  106. package/dist/src/utils/authService/authService.d.ts.map +1 -1
  107. package/dist/tsembed-react.es.js +1543 -1445
  108. package/dist/tsembed-react.js +6614 -6529
  109. package/dist/tsembed.es.js +1921 -1826
  110. package/dist/tsembed.js +15342 -15259
  111. package/dist/visual-embed-sdk-react-full.d.ts +692 -64
  112. package/dist/visual-embed-sdk-react.d.ts +692 -64
  113. package/dist/visual-embed-sdk.d.ts +692 -64
  114. package/lib/package.json +3 -4
  115. package/lib/src/auth.d.ts +16 -1
  116. package/lib/src/auth.d.ts.map +1 -1
  117. package/lib/src/auth.js +8 -4
  118. package/lib/src/auth.js.map +1 -1
  119. package/lib/src/auth.spec.d.ts.map +1 -1
  120. package/lib/src/auth.spec.js +9 -0
  121. package/lib/src/auth.spec.js.map +1 -1
  122. package/lib/src/embed/app.d.ts +150 -7
  123. package/lib/src/embed/app.d.ts.map +1 -1
  124. package/lib/src/embed/app.js +5 -5
  125. package/lib/src/embed/app.js.map +1 -1
  126. package/lib/src/embed/app.spec.js +19 -1
  127. package/lib/src/embed/app.spec.js.map +1 -1
  128. package/lib/src/embed/base.d.ts +1 -1
  129. package/lib/src/embed/base.d.ts.map +1 -1
  130. package/lib/src/embed/base.js +5 -8
  131. package/lib/src/embed/base.js.map +1 -1
  132. package/lib/src/embed/base.spec.js +2 -2
  133. package/lib/src/embed/base.spec.js.map +1 -1
  134. package/lib/src/embed/embed.spec.js +2 -17
  135. package/lib/src/embed/embed.spec.js.map +1 -1
  136. package/lib/src/embed/liveboard.d.ts +113 -4
  137. package/lib/src/embed/liveboard.d.ts.map +1 -1
  138. package/lib/src/embed/liveboard.js +3 -3
  139. package/lib/src/embed/liveboard.js.map +1 -1
  140. package/lib/src/embed/liveboard.spec.js +20 -1
  141. package/lib/src/embed/liveboard.spec.js.map +1 -1
  142. package/lib/src/embed/pinboard.spec.js +20 -1
  143. package/lib/src/embed/pinboard.spec.js.map +1 -1
  144. package/lib/src/embed/sage.d.ts +1 -1
  145. package/lib/src/embed/sage.d.ts.map +1 -1
  146. package/lib/src/embed/sage.js +2 -2
  147. package/lib/src/embed/sage.js.map +1 -1
  148. package/lib/src/embed/search-bar.d.ts +37 -6
  149. package/lib/src/embed/search-bar.d.ts.map +1 -1
  150. package/lib/src/embed/search-bar.js +2 -2
  151. package/lib/src/embed/search-bar.js.map +1 -1
  152. package/lib/src/embed/search.d.ts +85 -2
  153. package/lib/src/embed/search.d.ts.map +1 -1
  154. package/lib/src/embed/search.js +7 -7
  155. package/lib/src/embed/search.js.map +1 -1
  156. package/lib/src/embed/search.spec.js +25 -1
  157. package/lib/src/embed/search.spec.js.map +1 -1
  158. package/lib/src/embed/ts-embed-trigger.spec.d.ts +2 -0
  159. package/lib/src/embed/ts-embed-trigger.spec.d.ts.map +1 -0
  160. package/lib/src/embed/ts-embed-trigger.spec.js +32 -0
  161. package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -0
  162. package/lib/src/embed/ts-embed.d.ts +2 -2
  163. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  164. package/lib/src/embed/ts-embed.js +21 -16
  165. package/lib/src/embed/ts-embed.js.map +1 -1
  166. package/lib/src/embed/ts-embed.spec.js +57 -18
  167. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  168. package/lib/src/index.d.ts +2 -1
  169. package/lib/src/index.d.ts.map +1 -1
  170. package/lib/src/index.js +2 -1
  171. package/lib/src/index.js.map +1 -1
  172. package/lib/src/react/index.spec.js +13 -1
  173. package/lib/src/react/index.spec.js.map +1 -1
  174. package/lib/src/test/test-utils.d.ts +1 -0
  175. package/lib/src/test/test-utils.d.ts.map +1 -1
  176. package/lib/src/test/test-utils.js +8 -0
  177. package/lib/src/test/test-utils.js.map +1 -1
  178. package/lib/src/tokenizedFetch.d.ts +9 -0
  179. package/lib/src/tokenizedFetch.d.ts.map +1 -1
  180. package/lib/src/tokenizedFetch.js +9 -0
  181. package/lib/src/tokenizedFetch.js.map +1 -1
  182. package/lib/src/types.d.ts +279 -43
  183. package/lib/src/types.d.ts.map +1 -1
  184. package/lib/src/types.js +95 -20
  185. package/lib/src/types.js.map +1 -1
  186. package/lib/src/utils/authService/authService.d.ts.map +1 -1
  187. package/lib/src/utils/authService/authService.js +9 -3
  188. package/lib/src/utils/authService/authService.js.map +1 -1
  189. package/lib/src/utils/authService/authService.spec.js +23 -1
  190. package/lib/src/utils/authService/authService.spec.js.map +1 -1
  191. package/lib/src/visual-embed-sdk.d.ts +699 -68
  192. package/package.json +3 -4
  193. package/src/auth.spec.ts +10 -0
  194. package/src/auth.ts +27 -8
  195. package/src/embed/app.spec.ts +24 -1
  196. package/src/embed/app.ts +154 -13
  197. package/src/embed/base.spec.ts +3 -3
  198. package/src/embed/base.ts +13 -17
  199. package/src/embed/embed.spec.ts +0 -18
  200. package/src/embed/liveboard.spec.ts +24 -1
  201. package/src/embed/liveboard.ts +121 -15
  202. package/src/embed/pinboard.spec.ts +24 -1
  203. package/src/embed/sage.ts +2 -2
  204. package/src/embed/search-bar.tsx +38 -7
  205. package/src/embed/search.spec.ts +29 -1
  206. package/src/embed/search.ts +93 -9
  207. package/src/embed/ts-embed-trigger.spec.ts +39 -0
  208. package/src/embed/ts-embed.spec.ts +71 -30
  209. package/src/embed/ts-embed.ts +48 -45
  210. package/src/index.ts +2 -0
  211. package/src/react/index.spec.tsx +30 -0
  212. package/src/test/test-utils.ts +9 -0
  213. package/src/tokenizedFetch.ts +9 -0
  214. package/src/types.ts +288 -50
  215. package/src/utils/authService/authService.spec.ts +31 -4
  216. package/src/utils/authService/authService.ts +14 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.28.0-preRender",
3
+ "version": "1.28.0",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
@@ -38,7 +38,7 @@
38
38
  "size-limit": [
39
39
  {
40
40
  "path": "dist/tsembed.js",
41
- "limit": "44 kB"
41
+ "limit": "45 kB"
42
42
  }
43
43
  ],
44
44
  "scripts": {
@@ -67,8 +67,7 @@
67
67
  "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",
68
68
  "check-size": "npm run build && size-limit",
69
69
  "publish-dev": "npm publish --tag dev",
70
- "publish-prod": "npm publish --tag latest",
71
- "nirmay": "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"
70
+ "publish-prod": "npm publish --tag latest"
72
71
  },
73
72
  "peerDependencies": {
74
73
  "react": "> 16.8.0",
package/src/auth.spec.ts CHANGED
@@ -3,6 +3,7 @@ import * as authService from './utils/authService/authService';
3
3
  import * as tokenAuthService from './utils/authService/tokenizedAuthService';
4
4
  import * as checkReleaseVersionInBetaInstance from './utils';
5
5
  import * as mixPanelService from './mixpanel-service';
6
+ import * as EmbedConfig from './embed/embedConfig';
6
7
  import { AuthType, EmbedEvent } from './types';
7
8
  import { executeAfterWait } from './test/test-utils';
8
9
  import { resetCachedAuthToken } from './authToken';
@@ -130,6 +131,15 @@ describe('Unit test for auth', () => {
130
131
  expect(sessionInfo).toStrictEqual(mockSessionInfo);
131
132
  });
132
133
 
134
+ test('Disable mixpanel when disableSDKTracking flag is set', () => {
135
+ jest.clearAllMocks();
136
+ jest.resetAllMocks();
137
+ jest.spyOn(mixPanelService, 'initMixpanel');
138
+ jest.spyOn(EmbedConfig, 'getEmbedConfig').mockReturnValue({ disableSDKTracking: true });
139
+ authInstance.initSession(mockSessionInfo);
140
+ expect(mixPanelService.initMixpanel).not.toBeCalled();
141
+ });
142
+
133
143
  test('doCookielessTokenAuth: when authEndpoint and getAuthToken are not there, it throw error', async () => {
134
144
  try {
135
145
  await authInstance.doCookielessTokenAuth(
package/src/auth.ts CHANGED
@@ -1,19 +1,20 @@
1
1
  import EventEmitter from 'eventemitter3';
2
+ import { getAuthenticationToken, resetCachedAuthToken } from './authToken';
2
3
  import { initMixpanel } from './mixpanel-service';
3
4
  import {
4
- AuthType, DOMSelector, EmbedConfig, EmbedEvent, Param,
5
+ AuthType, DOMSelector, EmbedConfig, EmbedEvent,
5
6
  } from './types';
6
7
  import { getDOMNode, getRedirectUrl } from './utils';
7
8
  import {
8
- fetchSessionInfoService,
9
+ EndPoints,
10
+ fetchAuthPostService,
9
11
  fetchAuthService,
10
12
  fetchBasicAuthService,
11
13
  fetchLogoutService,
12
- fetchAuthPostService,
13
- EndPoints,
14
+ fetchSessionInfoService,
14
15
  } from './utils/authService';
15
- import { getAuthenticationToken, resetCachedAuthToken } from './authToken';
16
16
  import { logger } from './utils/logger';
17
+ import { getEmbedConfig } from './embed/embedConfig';
17
18
 
18
19
  // eslint-disable-next-line import/no-mutable-exports
19
20
  export let loggedInStatus = false;
@@ -117,7 +118,22 @@ export interface AuthEventEmitter {
117
118
  *
118
119
  * @param {@link AuthEvent}
119
120
  */
120
- emit(event: AuthEvent): void;
121
+ emit(event: AuthEvent, ...args: any[]): boolean;
122
+ /**
123
+ * Remove listener from the emitter returned from init.
124
+ *
125
+ * @param event
126
+ * @param listener
127
+ * @param context
128
+ * @param once
129
+ */
130
+ off(event: AuthStatus, listener: (...args: any[]) => void, context: any, once: boolean): this;
131
+ /**
132
+ * Remove all the event listeners
133
+ *
134
+ * @param event
135
+ */
136
+ removeAllListeners(event: AuthStatus): this;
121
137
  }
122
138
 
123
139
  /**
@@ -196,9 +212,12 @@ export function notifyLogout(): void {
196
212
  }
197
213
 
198
214
  export const initSession = (sessionDetails: sessionInfoInterface) => {
215
+ const embedConfig = getEmbedConfig();
199
216
  if (sessionInfo == null) {
200
217
  sessionInfo = sessionDetails;
201
- initMixpanel(sessionInfo);
218
+ if (!embedConfig.disableSDKTracking) {
219
+ initMixpanel(sessionInfo);
220
+ }
202
221
  sessionInfoResolver(sessionInfo);
203
222
  }
204
223
  };
@@ -473,7 +492,7 @@ export const logout = async (embedConfig: EmbedConfig): Promise<boolean> => {
473
492
  const { thoughtSpotHost } = embedConfig;
474
493
  await fetchLogoutService(thoughtSpotHost);
475
494
  resetCachedAuthToken();
476
- const thoughtspotIframes = document.querySelectorAll('[data-ts-iframe=\'true\']');
495
+ const thoughtspotIframes = document.querySelectorAll("[data-ts-iframe='true']");
477
496
  if (thoughtspotIframes?.length) {
478
497
  thoughtspotIframes.forEach((el) => {
479
498
  el.parentElement.innerHTML = embedConfig.loginFailedMessage;
@@ -213,6 +213,7 @@ describe('App embed tests', () => {
213
213
  values: [1000],
214
214
  },
215
215
  ],
216
+ excludeRuntimeFiltersfromURL: false,
216
217
  } as AppViewConfig);
217
218
 
218
219
  appEmbed.render();
@@ -224,7 +225,7 @@ describe('App embed tests', () => {
224
225
  });
225
226
  });
226
227
 
227
- test('should not apply runtime filters if excludeRuntimeFiltersfromURL is true', async () => {
228
+ test('should not append runtime filters in URL if excludeRuntimeFiltersfromURL is true', async () => {
228
229
  const appEmbed = new AppEmbed(getRootEl(), {
229
230
  ...defaultViewConfig,
230
231
  showPrimaryNavbar: true,
@@ -247,6 +248,28 @@ describe('App embed tests', () => {
247
248
  });
248
249
  });
249
250
 
251
+ test('should not append runtime filters in URL if excludeRuntimeFiltersfromURL is undefined', async () => {
252
+ const appEmbed = new AppEmbed(getRootEl(), {
253
+ ...defaultViewConfig,
254
+ showPrimaryNavbar: true,
255
+ runtimeFilters: [
256
+ {
257
+ columnName: 'sales',
258
+ operator: RuntimeFilterOp.EQ,
259
+ values: [1000],
260
+ },
261
+ ],
262
+ } as AppViewConfig);
263
+
264
+ appEmbed.render();
265
+ await executeAfterWait(() => {
266
+ expectUrlMatchesWithParams(
267
+ getIFrameSrc(),
268
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=false&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`,
269
+ );
270
+ });
271
+ });
272
+
250
273
  test('should disable and hide actions', async () => {
251
274
  const appEmbed = new AppEmbed(getRootEl(), {
252
275
  ...defaultViewConfig,
package/src/embed/app.ts CHANGED
@@ -9,11 +9,11 @@
9
9
  * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
10
10
  */
11
11
 
12
- import { logger } from '../utils/logger';
13
- import { getQueryParamString } from '../utils';
14
12
  import {
15
- Param, DOMSelector, HostEvent, ViewConfig, EmbedEvent, MessagePayload,
13
+ DOMSelector, EmbedEvent, HostEvent, MessagePayload, Param, ViewConfig,
16
14
  } from '../types';
15
+ import { getQueryParamString } from '../utils';
16
+ import { logger } from '../utils/logger';
17
17
  import { V1Embed } from './ts-embed';
18
18
 
19
19
  /**
@@ -61,6 +61,16 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
61
61
  * If true, the top navigation bar within the ThoughtSpot app
62
62
  * is displayed. By default, the navigation bar is hidden.
63
63
  * This flag also controls the homepage left navigation bar.
64
+ *
65
+ * @default true
66
+ * @version SDK: 1.2.0 | Thoughtspot: 8.4.0.cl
67
+ * @example
68
+ * ```js
69
+ * const embed = new AppEmbed('#tsEmbed', {
70
+ * ... // other options
71
+ * showPrimaryNavbar:true,
72
+ * })
73
+ * ```
64
74
  */
65
75
  showPrimaryNavbar?: boolean;
66
76
  /**
@@ -69,23 +79,78 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
69
79
  * nav-bars are visible, this flag will only hide the homepage left nav-bar.
70
80
  * The showPrimaryNavbar flag takes precedence over the hideHomepageLeftNav.
71
81
  *
82
+ *
83
+ * **Note**: This option does not apply to the classic homepage.
84
+ * To access the updated modular homepage, set
85
+ * `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
86
+ *
72
87
  * @default false
73
- * @version SDK: 1.27.0 | Thoughtspot: 9.8.0.cl
88
+ * @version SDK: 1.28.0 | Thoughtspot: 9.12.5.cl
89
+ *
90
+ * @example
91
+ * ```js
92
+ * const embed = new AppEmbed('#tsEmbed', {
93
+ * ... // other options
94
+ * hideHomepageLeftNav : true,
95
+ * })
96
+ * ```
74
97
  */
75
98
  hideHomepageLeftNav?: boolean;
76
99
  /**
77
100
  * Control the visibility of the help (?) and profile buttons on the
78
101
  * Global nav-bar. By default, these buttons are visible on the nav-bar.
102
+ *
103
+ * @default false
104
+ * @version SDK: 1.2.0 | Thoughtspot: 8.4.0.cl
105
+ * @example
106
+ * ```js
107
+ * const embed = new AppEmbed('#tsEmbed', {
108
+ * ... // other options
109
+ * disableProfileAndHelp: true,
110
+ * })
111
+ * ```
79
112
  */
80
113
  disableProfileAndHelp?: boolean;
81
114
  /**
82
115
  * Control the visibility of the application switcher button on the nav-bar.
83
116
  * By default, the application switcher is shown.
117
+ *
118
+ *
119
+ * **Note**: This option does not apply to the classic homepage.
120
+ * To access the updated modular homepage, set
121
+ * `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
122
+ *
123
+ * @version SDK: 1.28.0 | Thoughtspot: 9.12.5.cl
124
+ * @default false
125
+ *
126
+ * @example
127
+ * ```js
128
+ * const embed = new AppEmbed('#tsEmbed', {
129
+ * ... // other options
130
+ * hideApplicationSwitcher : true,
131
+ * })
132
+ * ```
84
133
  */
85
134
  hideApplicationSwitcher?: boolean;
86
135
  /**
87
136
  * Control the visibility of the Org switcher button on the nav-bar.
88
137
  * By default, the Org switcher button is shown.
138
+ *
139
+ *
140
+ * **Note**: This option does not apply to the classic homepage.
141
+ * To access the updated modular homepage, set
142
+ * `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
143
+ *
144
+ * @version SDK: 1.28.0 | Thoughtspot: 9.12.5.cl
145
+ * @default true
146
+ *
147
+ * @example
148
+ * ```js
149
+ * const embed = new AppEmbed('#tsEmbed', {
150
+ * ... // other options
151
+ * hideOrgSwitcher : true,
152
+ * })
153
+ * ```
89
154
  */
90
155
  hideOrgSwitcher?: boolean;
91
156
  /**
@@ -97,9 +162,13 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
97
162
  * For eg, if you want the component to open to a specific Liveboard
98
163
  * you could set the path to `pinboard/<liveboardId>/tab/<tabId>`.
99
164
  *
165
+ * @version SDK: 1.1.0 | Thoughtspot: 9.4.0.cl
100
166
  * @example
101
- * ```
102
- * <AppEmbed path="pinboard/1234/tab/7464" />
167
+ * ```js
168
+ * const embed = new AppEmbed('#tsEmbed', {
169
+ * ... // other options
170
+ * path:"pinboard/1234/tab/7464"
171
+ * })
103
172
  * ```
104
173
  */
105
174
  path?: string;
@@ -109,16 +178,46 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
109
178
  *
110
179
  * Use this to open to particular page in the app. To open to a specific
111
180
  * path within the app, use the `path` attribute which is more flexible.
181
+ *
182
+ * @version SDK: 1.1.0 | Thoughtspot: 9.4.0.cl
183
+ * @example
184
+ * ```js
185
+ * const embed = new AppEmbed('#tsEmbed', {
186
+ * ... // other options
187
+ * pageId : Page.Answers | Page.Data
188
+ * })
189
+ * ```
112
190
  */
113
191
  pageId?: Page;
114
192
  /**
115
193
  * This puts a filter tag on the application. All metadata lists in the
116
194
  * application, such as Liveboards and answers, would be filtered by this
117
195
  * tag.
196
+ *
197
+ * @version SDK: 1.1.0 | Thoughtspot: 9.4.0.cl
198
+ * @example
199
+ * ```js
200
+ * const embed = new AppEmbed('#tsEmbed', {
201
+ * ... // other options
202
+ * tag:'value',
203
+ * })
204
+ * ```
118
205
  */
119
206
  tag?: string;
120
207
  /**
121
208
  * The array of GUIDs to be hidden
209
+ *
210
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
211
+ * @example
212
+ * ```js
213
+ * const embed = new AppEmbed('#tsEmbed', {
214
+ * ... // other options
215
+ * hideObjects: [
216
+ * '430496d6-6903-4601-937e-2c691821af3c',
217
+ * 'f547ec54-2a37-4516-a222-2b06719af726'
218
+ * ]
219
+ * })
220
+ * ```
122
221
  */
123
222
  hideObjects?: string[];
124
223
  /**
@@ -132,7 +231,15 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
132
231
  /**
133
232
  * If set to true, the Search Assist feature is enabled.
134
233
  *
234
+ * @default true
135
235
  * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
236
+ * @example
237
+ * ```js
238
+ * const embed = new AppEmbed('#tsEmbed', {
239
+ * ... // other options
240
+ * enableSearchAssist: true,
241
+ * })
242
+ * ```
136
243
  */
137
244
  enableSearchAssist?: boolean;
138
245
  /**
@@ -140,6 +247,13 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
140
247
  * according to the height of the pages which support fullHeight mode.
141
248
  *
142
249
  * @version SDK: 1.21.0 | ThoughtSpot: 9.4.0.cl, 9.4.0-sw
250
+ * @example
251
+ * ```js
252
+ * const embed = new AppEmbed('#tsEmbed', {
253
+ * ... // other options
254
+ * fullHeight: true,
255
+ * })
256
+ * ```
143
257
  */
144
258
  fullHeight?: boolean;
145
259
  /**
@@ -155,6 +269,13 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
155
269
  *
156
270
  * @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl
157
271
  * @default false
272
+ * @example
273
+ * ```js
274
+ * const embed = new AppEmbed('#tsEmbed', {
275
+ * ... // other options
276
+ * hideLiveboardHeader : true,
277
+ * })
278
+ * ```
158
279
  */
159
280
  hideLiveboardHeader?: boolean;
160
281
  /**
@@ -162,6 +283,13 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
162
283
  *
163
284
  * @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl
164
285
  * @default false
286
+ * @example
287
+ * ```js
288
+ * const embed = new AppEmbed('#tsEmbed', {
289
+ * ... // other options
290
+ * showLiveboardTitle:true,
291
+ * })
292
+ * ```
165
293
  */
166
294
  showLiveboardTitle?: boolean;
167
295
  /**
@@ -169,13 +297,28 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
169
297
  *
170
298
  * @version SDK: 1.26.0 | Thoughtspot: 9.7.0.cl
171
299
  * @default false
300
+ * @example
301
+ * ```js
302
+ * const embed = new AppEmbed('#tsEmbed', {
303
+ * ... // other options
304
+ * showLiveboardDescription:true,
305
+ * })
306
+ * ```
172
307
  */
173
308
  showLiveboardDescription?: boolean;
174
309
  /**
175
- * Flag to control new Modular Home experience
310
+ * Flag to control new Modular Home experience.
176
311
  *
177
312
  * @default false
178
- * @version SDK: 1.27.0 | Thoughtspot: 9.8.0.cl
313
+ * @version SDK: 1.28.0 | Thoughtspot: 9.12.5.cl
314
+ *
315
+ * @example
316
+ * ```js
317
+ * const embed = new AppEmbed('#tsEmbed', {
318
+ * ... // other options
319
+ * modularHomeExperience : true,
320
+ * })
321
+ * ```
179
322
  */
180
323
  modularHomeExperience?: boolean;
181
324
  /**
@@ -295,9 +438,7 @@ export class AppEmbed extends V1Embed {
295
438
  * @param pageId The ID of the page to be embedded.
296
439
  */
297
440
  public getIFrameSrc(): string {
298
- const {
299
- pageId, path, modularHomeExperience,
300
- } = this.viewConfig;
441
+ const { pageId, path, modularHomeExperience } = this.viewConfig;
301
442
  const pageRoute = this.formatPath(path) || this.getPageRoute(pageId, modularHomeExperience);
302
443
  let url = `${this.getRootIframeSrc()}/${pageRoute}`;
303
444
 
@@ -414,10 +555,10 @@ export class AppEmbed extends V1Embed {
414
555
  * @param renderOptions An object containing the page ID
415
556
  * to be embedded.
416
557
  */
417
- public render(): AppEmbed {
558
+ public async render(): Promise<AppEmbed> {
418
559
  super.render();
419
560
  const src = this.getIFrameSrc();
420
- this.renderV1Embed(src);
561
+ await this.renderV1Embed(src);
421
562
 
422
563
  return this;
423
564
  }
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable no-console */
2
2
  /* eslint-disable @typescript-eslint/no-shadow */
3
3
  import EventEmitter from 'eventemitter3';
4
- import { EmbedConfig } from '../index';
5
4
  import * as auth from '../auth';
6
- import * as authService from '../utils/authService/authService';
7
5
  import * as authTokenService from '../authToken';
8
6
  import * as index from '../index';
7
+ import { EmbedConfig } from '../index';
8
+ import * as authService from '../utils/authService/authService';
9
9
  import * as base from './base';
10
10
  import * as embedConfigInstance from './embedConfig';
11
11
 
@@ -13,8 +13,8 @@ import {
13
13
  executeAfterWait,
14
14
  getAllIframeEl,
15
15
  getDocumentBody,
16
- getRootEl,
17
16
  getIFrameSrc,
17
+ getRootEl,
18
18
  } from '../test/test-utils';
19
19
  import * as tokenizedFetchInstance from '../tokenizedFetch';
20
20
  import { logger } from '../utils/logger';
package/src/embed/base.ts CHANGED
@@ -10,27 +10,27 @@
10
10
  */
11
11
  import EventEmitter from 'eventemitter3';
12
12
  import uniq from 'lodash/uniq';
13
- import { logger, setGlobalLogLevelOverride } from '../utils/logger';
14
- import { tokenizedFetch } from '../tokenizedFetch';
15
- import { EndPoints } from '../utils/authService/authService';
16
- import { getThoughtSpotHost } from '../config';
17
- import {
18
- AuthType, EmbedConfig, LogLevel, PrefetchFeatures,
19
- } from '../types';
20
13
  import {
21
- authenticate,
22
- logout as _logout,
14
+ AuthEvent,
15
+ AuthEventEmitter,
23
16
  AuthFailureType,
24
17
  AuthStatus,
25
- AuthEvent,
18
+ logout as _logout,
19
+ authenticate,
26
20
  notifyAuthFailure,
27
21
  notifyAuthSDKSuccess,
28
22
  notifyAuthSuccess,
29
23
  notifyLogout,
30
24
  setAuthEE,
31
- AuthEventEmitter,
32
25
  } from '../auth';
33
- import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
26
+ import { getThoughtSpotHost } from '../config';
27
+ import { MIXPANEL_EVENT, uploadMixpanelEvent } from '../mixpanel-service';
28
+ import { tokenizedFetch } from '../tokenizedFetch';
29
+ import {
30
+ AuthType, EmbedConfig, LogLevel, PrefetchFeatures,
31
+ } from '../types';
32
+ import { EndPoints } from '../utils/authService/authService';
33
+ import { logger, setGlobalLogLevelOverride } from '../utils/logger';
34
34
  import { getEmbedConfig, setEmbedConfig } from './embedConfig';
35
35
 
36
36
  const CONFIG_DEFAULTS: Partial<EmbedConfig> = {
@@ -133,10 +133,6 @@ function sanity(embedConfig: EmbedConfig) {
133
133
  throw new Error('ThoughtSpot host not provided');
134
134
  }
135
135
  if (embedConfig.authType === AuthType.TrustedAuthToken) {
136
- if (!embedConfig.username) {
137
- throw new Error('Username not provided with Trusted auth');
138
- }
139
-
140
136
  if (!embedConfig.authEndpoint && typeof embedConfig.getAuthToken !== 'function') {
141
137
  throw new Error('Trusted auth should provide either authEndpoint or getAuthToken');
142
138
  }
@@ -253,7 +249,7 @@ export const renderInQueue = (fn: (next?: (val?: any) => void) => Promise<any>):
253
249
  return renderQueue;
254
250
  }
255
251
  // Sending an empty function to keep it consistent with the above usage.
256
- return fn(() => {}); // eslint-disable-line @typescript-eslint/no-empty-function
252
+ return fn(() => { }); // eslint-disable-line @typescript-eslint/no-empty-function
257
253
  };
258
254
 
259
255
  /**
@@ -50,24 +50,6 @@ describe('test view config', () => {
50
50
  expect(iframe.style.height).toBe(`${height}px`);
51
51
  });
52
52
  });
53
-
54
- test('trying to register event handler after render should throw error', async () => {
55
- spyOn(logger, 'error');
56
- const onErrorSpy = jest.fn();
57
- const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
58
- searchEmbed
59
- .on(EmbedEvent.Error, onErrorSpy)
60
- .render()
61
- .on(EmbedEvent.Load, () => null);
62
- await executeAfterWait(() => {
63
- expect(onErrorSpy).toHaveBeenCalledWith(
64
- {
65
- error: 'Please register event handlers before calling render',
66
- },
67
- expect.any(Function),
68
- );
69
- }, EVENT_WAIT_TIME);
70
- });
71
53
  });
72
54
 
73
55
  describe('Custom CSS Url', () => {
@@ -182,6 +182,7 @@ describe('Liveboard/viz embed tests', () => {
182
182
  values: [1000],
183
183
  },
184
184
  ],
185
+ excludeRuntimeFiltersfromURL: false,
185
186
  } as LiveboardViewConfig);
186
187
  liveboardEmbed.render();
187
188
  await executeAfterWait(() => {
@@ -208,7 +209,29 @@ describe('Liveboard/viz embed tests', () => {
208
209
  });
209
210
  });
210
211
 
211
- test('should not apply runtime filters if excludeRuntimeFiltersfromURL is true', async () => {
212
+ test('should not append runtime filters in URL if excludeRuntimeFiltersfromURL is true', async () => {
213
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
214
+ ...defaultViewConfig,
215
+ liveboardId,
216
+ vizId,
217
+ runtimeFilters: [
218
+ {
219
+ columnName: 'sales',
220
+ operator: RuntimeFilterOp.EQ,
221
+ values: [1000],
222
+ },
223
+ ],
224
+ } as LiveboardViewConfig);
225
+ liveboardEmbed.render();
226
+ await executeAfterWait(() => {
227
+ expectUrlMatchesWithParams(
228
+ getIFrameSrc(),
229
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}${prefixParamsVizEmbed}#/embed/viz/${liveboardId}/${vizId}`,
230
+ );
231
+ });
232
+ });
233
+
234
+ test('should not append runtime filters in URL if excludeRuntimeFiltersfromURL is undefined', async () => {
212
235
  const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
213
236
  ...defaultViewConfig,
214
237
  liveboardId,