@thoughtspot/visual-embed-sdk 1.13.0 → 1.14.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 (59) hide show
  1. package/CHANGELOG.md +7 -2
  2. package/dist/src/embed/app.d.ts +4 -3
  3. package/dist/src/embed/base.d.ts +1 -1
  4. package/dist/src/embed/liveboard.d.ts +6 -8
  5. package/dist/src/embed/pinboard.d.ts +91 -0
  6. package/dist/src/embed/search.d.ts +1 -1
  7. package/dist/src/embed/ts-embed.d.ts +4 -4
  8. package/dist/src/types.d.ts +83 -76
  9. package/dist/src/utils/authService.d.ts +1 -0
  10. package/dist/src/utils/plugin.d.ts +0 -0
  11. package/dist/src/v1/api.d.ts +19 -0
  12. package/dist/tsembed.es.js +103 -76
  13. package/dist/tsembed.js +103 -76
  14. package/lib/package.json +1 -1
  15. package/lib/src/auth.js +8 -2
  16. package/lib/src/auth.js.map +1 -1
  17. package/lib/src/auth.spec.js +18 -0
  18. package/lib/src/auth.spec.js.map +1 -1
  19. package/lib/src/embed/app.d.ts +4 -3
  20. package/lib/src/embed/app.js +2 -1
  21. package/lib/src/embed/app.js.map +1 -1
  22. package/lib/src/embed/base.d.ts +1 -1
  23. package/lib/src/embed/base.js +1 -1
  24. package/lib/src/embed/liveboard.d.ts +6 -8
  25. package/lib/src/embed/liveboard.js.map +1 -1
  26. package/lib/src/embed/pinboard.d.ts +91 -0
  27. package/lib/src/embed/pinboard.js +110 -0
  28. package/lib/src/embed/pinboard.js.map +1 -0
  29. package/lib/src/embed/search.d.ts +1 -1
  30. package/lib/src/embed/ts-embed.d.ts +4 -4
  31. package/lib/src/types.d.ts +83 -76
  32. package/lib/src/types.js +73 -68
  33. package/lib/src/types.js.map +1 -1
  34. package/lib/src/utils/authService.d.ts +1 -0
  35. package/lib/src/utils/authService.js +13 -0
  36. package/lib/src/utils/authService.js.map +1 -1
  37. package/lib/src/utils/authService.spec.js +15 -1
  38. package/lib/src/utils/authService.spec.js.map +1 -1
  39. package/lib/src/utils/plugin.d.ts +0 -0
  40. package/lib/src/utils/plugin.js +1 -0
  41. package/lib/src/utils/plugin.js.map +1 -0
  42. package/lib/src/utils/processData.js +7 -5
  43. package/lib/src/utils/processData.js.map +1 -1
  44. package/lib/src/utils/processData.spec.js +14 -0
  45. package/lib/src/utils/processData.spec.js.map +1 -1
  46. package/lib/src/visual-embed-sdk.d.ts +99 -93
  47. package/package.json +1 -1
  48. package/src/auth.spec.ts +39 -0
  49. package/src/auth.ts +11 -5
  50. package/src/embed/app.ts +4 -3
  51. package/src/embed/base.ts +1 -1
  52. package/src/embed/liveboard.ts +6 -8
  53. package/src/embed/search.ts +1 -1
  54. package/src/embed/ts-embed.ts +4 -4
  55. package/src/types.ts +83 -76
  56. package/src/utils/authService.spec.ts +21 -0
  57. package/src/utils/authService.ts +20 -0
  58. package/src/utils/processData.spec.ts +17 -0
  59. package/src/utils/processData.ts +7 -5
package/src/auth.spec.ts CHANGED
@@ -240,6 +240,45 @@ describe('Unit test for auth', () => {
240
240
  expect(isLoggedIn).toBe(false);
241
241
  });
242
242
 
243
+ test('doTokenAuth: when user is not loggedIn & fetchAuthPostService failed than fetchAuthService should call', async () => {
244
+ jest.spyOn(window, 'alert').mockImplementation(() => undefined);
245
+ jest.spyOn(authService, 'fetchSessionInfoService').mockImplementation(
246
+ () => false,
247
+ );
248
+ jest.spyOn(
249
+ authService,
250
+ 'fetchAuthTokenService',
251
+ ).mockImplementation(() => ({ text: () => Promise.resolve('abc') }));
252
+ jest.spyOn(authService, 'fetchAuthPostService').mockImplementation(() =>
253
+ // eslint-disable-next-line prefer-promise-reject-errors
254
+ Promise.reject({
255
+ status: 500,
256
+ }),
257
+ );
258
+ jest.spyOn(authService, 'fetchAuthService').mockImplementation(() =>
259
+ Promise.resolve({
260
+ status: 200,
261
+ type: 'opaqueredirect',
262
+ }),
263
+ );
264
+ expect(
265
+ await authInstance.doTokenAuth(
266
+ embedConfig.doTokenAuthSuccess('authToken2'),
267
+ ),
268
+ ).toBe(true);
269
+ expect(authService.fetchSessionInfoService).toBeCalled();
270
+ expect(authService.fetchAuthPostService).toBeCalledWith(
271
+ thoughtSpotHost,
272
+ username,
273
+ 'authToken2',
274
+ );
275
+ expect(authService.fetchAuthService).toBeCalledWith(
276
+ thoughtSpotHost,
277
+ username,
278
+ 'authToken2',
279
+ );
280
+ });
281
+
243
282
  describe('doBasicAuth', () => {
244
283
  beforeEach(() => {
245
284
  global.fetch = window.fetch;
package/src/auth.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  fetchAuthService,
9
9
  fetchBasicAuthService,
10
10
  fetchLogoutService,
11
+ fetchAuthPostService,
11
12
  } from './utils/authService';
12
13
 
13
14
  // eslint-disable-next-line import/no-mutable-exports
@@ -157,11 +158,16 @@ export const doTokenAuth = async (
157
158
  const response = await fetchAuthTokenService(authEndpoint);
158
159
  authToken = await response.text();
159
160
  }
160
- const resp = await fetchAuthService(
161
- thoughtSpotHost,
162
- username,
163
- authToken,
164
- );
161
+ let resp;
162
+ try {
163
+ resp = await fetchAuthPostService(
164
+ thoughtSpotHost,
165
+ username,
166
+ authToken,
167
+ );
168
+ } catch (e) {
169
+ resp = await fetchAuthService(thoughtSpotHost, username, authToken);
170
+ }
165
171
  // token login issues a 302 when successful
166
172
  loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
167
173
  if (loggedInStatus && embedConfig.detectCookieAccessSlow) {
package/src/embed/app.ts CHANGED
@@ -87,13 +87,13 @@ export interface AppViewConfig extends ViewConfig {
87
87
  * Render liveboards using the new v2 rendering mode
88
88
  * This is a transient flag which is primarily meant for internal use
89
89
  * @default false
90
- * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
90
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
91
91
  * @hidden
92
92
  */
93
93
  liveboardV2?: boolean;
94
94
  /**
95
95
  * If set to true, the Search Assist feature is enabled.
96
- * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl
96
+ * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
97
97
  */
98
98
  enableSearchAssist?: boolean;
99
99
  }
@@ -203,7 +203,8 @@ export class AppEmbed extends V1Embed {
203
203
  * @param path string | number The string, set to iframe src and navigate to new page
204
204
  * eg: appEmbed.navigateToPage('pinboards')
205
205
  * When used with `noReload` this can also be a number like 1/-1 to go forward/back.
206
- * @param noReload boolean Trigger the navigation without reloading the page (version: 1.12.0 | 8.4.0.cl)
206
+ * @param noReload boolean Trigger the navigation without reloading the page
207
+ * @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl, 8.4.1-sw
207
208
  */
208
209
  public navigateToPage(path: string | number, noReload = false): void {
209
210
  if (!this.iFrame) {
package/src/embed/base.ts CHANGED
@@ -146,7 +146,7 @@ export function disableAutoLogin(): void {
146
146
  *
147
147
  * @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
148
148
  * @returns Promise which resolves when logout completes.
149
- * @version SDK: 1.10.1 | ThoughtSpot: *
149
+ * @version SDK: 1.10.1 | ThoughtSpot: 8.2.0.cl, 8.4.1-sw
150
150
  */
151
151
  export const logout = (doNotDisableAutoLogin = false): Promise<boolean> => {
152
152
  if (!doNotDisableAutoLogin) {
@@ -35,7 +35,7 @@ export interface LiveboardViewConfig extends ViewConfig {
35
35
  * This is the minimum height(in pixels) for a full height Liveboard.
36
36
  * Setting this height helps resolves issues with empty Liveboards and
37
37
  * other screens navigable from a Liveboard.
38
- * @version 1.5.0 or later
38
+ * @version SDK: 1.5.0 | ThoughtSpot: ts7.oct.cl, 7.2.1
39
39
  * @default 500
40
40
  */
41
41
  defaultHeight?: number;
@@ -49,7 +49,7 @@ export interface LiveboardViewConfig extends ViewConfig {
49
49
  */
50
50
  liveboardId?: string;
51
51
  /**
52
- * To support backward compatibilty
52
+ * To support backward compatibility
53
53
  * @hidden
54
54
  */
55
55
  pinboardId?: string;
@@ -66,7 +66,7 @@ export interface LiveboardViewConfig extends ViewConfig {
66
66
  * Array of viz ids which should be visible when the liveboard
67
67
  * first renders. This can be changed by triggering the "SetVisibleVizs"
68
68
  * event.
69
- * @version 1.9.1 or later
69
+ * @version SDK: 1.9.1 | ThoughtSpot: 8.1.0.cl, 8.4.1-sw
70
70
  */
71
71
  visibleVizs?: string[];
72
72
  /**
@@ -75,16 +75,14 @@ export interface LiveboardViewConfig extends ViewConfig {
75
75
  */
76
76
  preventPinboardFilterRemoval?: boolean;
77
77
  /**
78
- * Render embedded liveboards and visualizations using the new v2 rendering mode
79
- * This is a transient flag which is primarily meant for internal use
78
+ * Render embedded Liveboards and visualizations in the new Liveboard experience mode
80
79
  * @default false
81
- * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl
82
- * @hidden
80
+ * @version SDK: 1.14.0 | ThoughtSpot: 8.6.0.cl, 8.8.1-sw
83
81
  */
84
82
  liveboardV2?: boolean;
85
83
  /**
86
84
  * Tab Id of the Liveboard that is supposed to be active
87
- * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl
85
+ * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
88
86
  */
89
87
  activeTabId?: string;
90
88
  }
@@ -58,7 +58,7 @@ export interface SearchViewConfig extends ViewConfig {
58
58
  expandAllDataSource?: boolean;
59
59
  /**
60
60
  * If set to true, the Search Assist feature is enabled.
61
- * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl
61
+ * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
62
62
  */
63
63
  enableSearchAssist?: boolean;
64
64
  /**
@@ -118,12 +118,12 @@ export interface ViewConfig {
118
118
  /**
119
119
  * The list of actions to display from the primary menu, more menu
120
120
  * (...), and the contextual menu.
121
- * @version 1.6.0 or later
121
+ * @version SDK: 1.6.0 | ThoughtSpot: ts8.nov.cl, 8.4.1-sw
122
122
  */
123
123
  visibleActions?: Action[];
124
124
  /**
125
125
  * Show alert messages and toast messages in the embedded view.
126
- * @version 1.11.0 | ThoughtSpot: 8.3.0.cl
126
+ * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
127
127
  */
128
128
  showAlerts?: boolean;
129
129
  /**
@@ -133,7 +133,7 @@ export interface ViewConfig {
133
133
  runtimeFilters?: RuntimeFilter[];
134
134
  /**
135
135
  * The locale/language to use for the embedded view.
136
- * @version 1.9.4 or later
136
+ * @version SDK: 1.9.4 | ThoughtSpot 8.1.0.cl, 8.4.1-sw
137
137
  */
138
138
  locale?: string;
139
139
  /**
@@ -143,7 +143,7 @@ export interface ViewConfig {
143
143
  * Warning: This option is for advanced use only and is used internally
144
144
  * to control embed behavior in non-regular ways. We do not publish the
145
145
  * list of supported keys and values associated with each.
146
- * @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl
146
+ * @version SDK: 1.9.0 | ThoughtSpot: 8.1.0.cl, 8.4.1-sw
147
147
  */
148
148
  additionalFlags?: { [key: string]: string | number | boolean };
149
149
  }