@thoughtspot/visual-embed-sdk 1.30.0 → 1.31.0-alpha.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 (48) hide show
  1. package/README.md +1 -1
  2. package/cjs/package.json +1 -1
  3. package/cjs/src/auth.d.ts.map +1 -1
  4. package/cjs/src/auth.js +2 -2
  5. package/cjs/src/auth.js.map +1 -1
  6. package/cjs/src/embed/base.spec.js +1 -1
  7. package/cjs/src/embed/base.spec.js.map +1 -1
  8. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  9. package/cjs/src/embed/liveboard.js.map +1 -1
  10. package/cjs/src/embed/ts-embed.d.ts +1 -1
  11. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  12. package/cjs/src/embed/ts-embed.js +6 -12
  13. package/cjs/src/embed/ts-embed.js.map +1 -1
  14. package/cjs/src/react/index.spec.js +2 -14
  15. package/cjs/src/react/index.spec.js.map +1 -1
  16. package/dist/src/auth.d.ts.map +1 -1
  17. package/dist/src/embed/liveboard.d.ts.map +1 -1
  18. package/dist/src/embed/ts-embed.d.ts +1 -1
  19. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  20. package/dist/tsembed-react.es.js +7024 -7030
  21. package/dist/tsembed-react.js +7047 -7053
  22. package/dist/tsembed.es.js +7077 -7083
  23. package/dist/tsembed.js +7063 -7069
  24. package/lib/package.json +1 -1
  25. package/lib/src/auth.d.ts.map +1 -1
  26. package/lib/src/auth.js +3 -3
  27. package/lib/src/auth.js.map +1 -1
  28. package/lib/src/embed/base.spec.js +2 -2
  29. package/lib/src/embed/base.spec.js.map +1 -1
  30. package/lib/src/embed/liveboard.d.ts.map +1 -1
  31. package/lib/src/embed/liveboard.js +1 -1
  32. package/lib/src/embed/liveboard.js.map +1 -1
  33. package/lib/src/embed/ts-embed.d.ts +1 -1
  34. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  35. package/lib/src/embed/ts-embed.js +9 -15
  36. package/lib/src/embed/ts-embed.js.map +1 -1
  37. package/lib/src/react/index.spec.js +3 -15
  38. package/lib/src/react/index.spec.js.map +1 -1
  39. package/lib/src/utils/authService/authService.spec.js +1 -1
  40. package/lib/src/utils/authService/authService.spec.js.map +1 -1
  41. package/lib/src/visual-embed-sdk.d.ts +1 -1
  42. package/package.json +1 -1
  43. package/src/auth.ts +6 -6
  44. package/src/embed/base.spec.ts +3 -3
  45. package/src/embed/liveboard.ts +8 -1
  46. package/src/embed/ts-embed.ts +41 -44
  47. package/src/react/index.spec.tsx +59 -47
  48. package/src/utils/authService/authService.spec.ts +4 -4
package/src/auth.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import EventEmitter from 'eventemitter3';
2
- import { getAuthenticationToken, resetCachedAuthToken } from './authToken';
3
2
  import { initMixpanel } from './mixpanel-service';
4
3
  import {
5
- AuthType, DOMSelector, EmbedConfig, EmbedEvent,
4
+ AuthType, DOMSelector, EmbedConfig, EmbedEvent, Param,
6
5
  } from './types';
7
6
  import { getDOMNode, getRedirectUrl } from './utils';
8
7
  import {
9
- EndPoints,
10
- fetchAuthPostService,
8
+ fetchSessionInfoService,
11
9
  fetchAuthService,
12
10
  fetchBasicAuthService,
13
11
  fetchLogoutService,
14
- fetchSessionInfoService,
12
+ fetchAuthPostService,
13
+ EndPoints,
15
14
  } from './utils/authService';
15
+ import { getAuthenticationToken, resetCachedAuthToken } from './authToken';
16
16
  import { logger } from './utils/logger';
17
17
  import { getEmbedConfig } from './embed/embedConfig';
18
18
 
@@ -476,7 +476,7 @@ export const logout = async (embedConfig: EmbedConfig): Promise<boolean> => {
476
476
  const { thoughtSpotHost } = embedConfig;
477
477
  await fetchLogoutService(thoughtSpotHost);
478
478
  resetCachedAuthToken();
479
- const thoughtspotIframes = document.querySelectorAll("[data-ts-iframe='true']");
479
+ const thoughtspotIframes = document.querySelectorAll('[data-ts-iframe=\'true\']');
480
480
  if (thoughtspotIframes?.length) {
481
481
  thoughtspotIframes.forEach((el) => {
482
482
  el.parentElement.innerHTML = embedConfig.loginFailedMessage;
@@ -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';
4
5
  import * as auth from '../auth';
6
+ import * as authService from '../utils/authService/authService';
5
7
  import * as authTokenService from '../authToken';
6
8
  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
- getIFrameSrc,
17
16
  getRootEl,
17
+ getIFrameSrc,
18
18
  } from '../test/test-utils';
19
19
  import * as tokenizedFetchInstance from '../tokenizedFetch';
20
20
  import { logger } from '../utils/logger';
@@ -10,9 +10,16 @@
10
10
 
11
11
  import { ERROR_MESSAGE } from '../errors';
12
12
  import {
13
- DOMSelector, EmbedEvent, HostEvent, MessagePayload, Param, ViewConfig,
13
+ EmbedEvent,
14
+ MessagePayload,
15
+ Param,
16
+ RuntimeFilter,
17
+ DOMSelector,
18
+ HostEvent,
19
+ ViewConfig,
14
20
  } from '../types';
15
21
  import { getQueryParamString, isUndefined } from '../utils';
22
+ import { getAuthPromise } from './base';
16
23
  import { V1Embed } from './ts-embed';
17
24
 
18
25
  /**
@@ -7,54 +7,57 @@
7
7
  */
8
8
 
9
9
  import isEqual from 'lodash/isEqual';
10
- import pkgInfo from '../../package.json';
11
- import { AuthFailureType } from '../auth';
10
+ import { logger } from '../utils/logger';
12
11
  import { getAuthenticationToken } from '../authToken';
12
+ import { AnswerService } from '../utils/graphql/answerService/answerService';
13
+ import {
14
+ getEncodedQueryParamsString,
15
+ getCssDimension,
16
+ getOffsetTop,
17
+ embedEventStatus,
18
+ setAttributes,
19
+ getCustomisations,
20
+ getRuntimeFilters,
21
+ getDOMNode,
22
+ getFilterQuery,
23
+ getQueryParamString,
24
+ getRuntimeParameters,
25
+ setStyleProperties,
26
+ removeStyleProperties,
27
+ isUndefined,
28
+ } from '../utils';
13
29
  import {
14
- DEFAULT_EMBED_HEIGHT,
15
- DEFAULT_EMBED_WIDTH,
16
- URL_MAX_LENGTH,
17
30
  getThoughtSpotHost,
31
+ URL_MAX_LENGTH,
32
+ DEFAULT_EMBED_WIDTH,
33
+ DEFAULT_EMBED_HEIGHT,
18
34
  getV2BasePath,
19
35
  } from '../config';
20
- import { MIXPANEL_EVENT, uploadMixpanelEvent } from '../mixpanel-service';
21
36
  import {
22
- Action,
23
37
  AuthType,
24
- ContextMenuTriggerOptions,
25
38
  DOMSelector,
26
- EmbedConfig,
27
- EmbedEvent,
28
39
  HostEvent,
40
+ EmbedEvent,
29
41
  MessageCallback,
30
- MessageCallbackObj,
31
- MessageOptions,
42
+ Action,
32
43
  Param,
44
+ EmbedConfig,
45
+ MessageOptions,
46
+ MessagePayload,
47
+ MessageCallbackObj,
33
48
  ViewConfig,
49
+ FrameParams,
50
+ ContextMenuTriggerOptions,
51
+ RuntimeFilter,
34
52
  } from '../types';
35
- import {
36
- embedEventStatus,
37
- getCssDimension,
38
- getCustomisations,
39
- getDOMNode,
40
- getEncodedQueryParamsString,
41
- getFilterQuery,
42
- getOffsetTop,
43
- getQueryParamString,
44
- getRuntimeFilters,
45
- getRuntimeParameters,
46
- isUndefined,
47
- removeStyleProperties,
48
- setAttributes,
49
- setStyleProperties,
50
- } from '../utils';
51
- import { AnswerService } from '../utils/graphql/answerService/answerService';
52
- import { logger } from '../utils/logger';
53
- import { processAuthFailure, processEventData } from '../utils/processData';
53
+ import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
54
+ import { processEventData, processAuthFailure } from '../utils/processData';
54
55
  import { processTrigger } from '../utils/processTrigger';
56
+ import pkgInfo from '../../package.json';
55
57
  import {
56
- getAuthPromise, handleAuth, notifyAuthFailure, renderInQueue,
58
+ getAuthPromise, renderInQueue, handleAuth, notifyAuthFailure,
57
59
  } from './base';
60
+ import { AuthFailureType } from '../auth';
58
61
  import { getEmbedConfig } from './embedConfig';
59
62
 
60
63
  const { version } = pkgInfo;
@@ -588,7 +591,6 @@ export class TsEmbed {
588
591
  * @param url - The URL of the embedded ThoughtSpot app.
589
592
  */
590
593
  protected async renderIFrame(url: string): Promise<any> {
591
- console.log('here 7');
592
594
  if (this.isError) {
593
595
  return null;
594
596
  }
@@ -598,10 +600,8 @@ export class TsEmbed {
598
600
  if (url.length > URL_MAX_LENGTH) {
599
601
  // warn: The URL is too long
600
602
  }
601
- console.log('here 8');
602
603
 
603
604
  return renderInQueue((nextInQueue) => {
604
- console.log('here 6');
605
605
  const initTimestamp = Date.now();
606
606
 
607
607
  this.executeCallbacks(EmbedEvent.Init, {
@@ -614,7 +614,6 @@ export class TsEmbed {
614
614
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
615
615
  return getAuthPromise()
616
616
  ?.then((isLoggedIn: boolean) => {
617
- console.log('here 9', isLoggedIn);
618
617
  if (!isLoggedIn) {
619
618
  this.handleInsertionIntoDOM(this.embedConfig.loginFailedMessage);
620
619
  return;
@@ -639,9 +638,7 @@ export class TsEmbed {
639
638
  this.iFrame.addEventListener('error', () => {
640
639
  nextInQueue();
641
640
  });
642
- console.log('here 10', this.iFrame);
643
641
  this.handleInsertionIntoDOM(this.iFrame);
644
- console.log('here 11', document.body.innerHTML);
645
642
  const prefetchIframe = document.querySelectorAll('.prefetchIframe');
646
643
  if (prefetchIframe.length) {
647
644
  prefetchIframe.forEach((el) => {
@@ -685,7 +682,7 @@ export class TsEmbed {
685
682
  protected connectPreRendered(): boolean {
686
683
  const preRenderIds = this.getPreRenderIds();
687
684
  this.preRenderWrapper = this.preRenderWrapper
688
- || document.getElementById(preRenderIds.wrapper);
685
+ || document.getElementById(preRenderIds.wrapper);
689
686
 
690
687
  this.preRenderChild = this.preRenderChild || document.getElementById(preRenderIds.child);
691
688
 
@@ -1090,11 +1087,11 @@ export class TsEmbed {
1090
1087
  ) {
1091
1088
  logger.warn(
1092
1089
  `${viewConfig.embedComponentType || 'Component'} was pre-rendered with `
1093
- + `"${key}" as "${JSON.stringify(preRenderedObject.viewConfig[key])}" `
1094
- + `but a different value "${JSON.stringify(viewConfig[key])}" `
1095
- + 'was passed to the Embed component. '
1096
- + 'The new value provided is ignored, the value provided during '
1097
- + 'preRender is used.',
1090
+ + `"${key}" as "${JSON.stringify(preRenderedObject.viewConfig[key])}" `
1091
+ + `but a different value "${JSON.stringify(viewConfig[key])}" `
1092
+ + 'was passed to the Embed component. '
1093
+ + 'The new value provided is ignored, the value provided during '
1094
+ + 'preRender is used.',
1098
1095
  );
1099
1096
  }
1100
1097
  });
@@ -15,15 +15,12 @@ import {
15
15
  mockMessageChannel,
16
16
  } from '../test/test-utils';
17
17
  import {
18
- SearchEmbed,
19
- AppEmbed,
20
- LiveboardEmbed,
21
- useEmbedRef,
22
- SearchBarEmbed,
23
- PreRenderedLiveboardEmbed,
18
+ SearchEmbed, AppEmbed, LiveboardEmbed, useEmbedRef, SearchBarEmbed, PreRenderedLiveboardEmbed,
24
19
  } from './index';
25
20
  import * as allExports from './index';
26
- import { AuthType, init } from '../index';
21
+ import {
22
+ AuthType, init,
23
+ } from '../index';
27
24
 
28
25
  import { version } from '../../package.json';
29
26
 
@@ -46,9 +43,11 @@ describe('React Components', () => {
46
43
 
47
44
  await waitFor(() => getIFrameEl(container));
48
45
 
49
- expect(getIFrameEl(container).parentElement.classList.contains('embedClass')).toBe(
50
- true,
51
- );
46
+ expect(
47
+ getIFrameEl(container).parentElement.classList.contains(
48
+ 'embedClass',
49
+ ),
50
+ ).toBe(true);
52
51
  expect(getIFrameSrc(container)).toBe(
53
52
  `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&overrideConsoleLogs=true&clientLogLevel=ERROR&enableDataPanelV2=false&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true&collapseSearchBarInitially=false&enableCustomColumnGroups=false&dataPanelCustomGroupsAccordionInitialState=EXPAND_ALL#/embed/answer`,
54
53
  );
@@ -145,53 +144,60 @@ describe('React Components', () => {
145
144
  });
146
145
 
147
146
  it('Should have the correct container element', async () => {
148
- const { container } = render(<LiveboardEmbed liveboardId="abcd" className="def" />);
149
-
150
- await waitFor(() => getIFrameEl(container));
151
- expect(container.querySelector('div')).not.toBe(null);
152
- expect(container.querySelector('div').classList.contains('def')).toBe(true);
153
-
154
- const { container: containerSibling } = render(
155
- <LiveboardEmbed liveboardId="abcd" className="def" insertAsSibling={true} />,
147
+ const { container } = render(
148
+ <LiveboardEmbed liveboardId="abcd" className="def" />,
156
149
  );
157
- await waitFor(() => getIFrameEl(containerSibling));
158
- expect(containerSibling.querySelector('span')).not.toBe(null);
159
- expect(containerSibling.querySelector('span').style.position).toBe('absolute');
160
- expect(getIFrameEl(containerSibling).classList.contains('def')).toBe(true);
161
- expect(containerSibling.querySelector('div')).toBe(null);
162
- });
163
-
164
- it('Should have the correct container element', async () => {
165
- const { container } = render(<LiveboardEmbed liveboardId="abcd" className="def" />);
166
150
 
167
151
  await waitFor(() => getIFrameEl(container));
168
152
  expect(container.querySelector('div')).not.toBe(null);
169
- expect(container.querySelector('div').classList.contains('def')).toBe(true);
153
+ expect(
154
+ container.querySelector('div').classList.contains('def'),
155
+ ).toBe(true);
170
156
 
171
157
  const { container: containerSibling } = render(
172
- <LiveboardEmbed liveboardId="abcd" className="def" insertAsSibling={true} />,
158
+ <LiveboardEmbed
159
+ liveboardId="abcd"
160
+ className="def"
161
+ insertAsSibling={true}
162
+ />,
173
163
  );
174
164
  await waitFor(() => getIFrameEl(containerSibling));
175
165
  expect(containerSibling.querySelector('span')).not.toBe(null);
176
- expect(containerSibling.querySelector('span').style.position).toBe('absolute');
177
- expect(getIFrameEl(containerSibling).classList.contains('def')).toBe(true);
166
+ expect(containerSibling.querySelector('span').style.position).toBe(
167
+ 'absolute',
168
+ );
169
+ expect(
170
+ getIFrameEl(containerSibling).classList.contains('def'),
171
+ ).toBe(true);
178
172
  expect(containerSibling.querySelector('div')).toBe(null);
179
173
  });
180
174
 
181
175
  it('Should have the correct container element', async () => {
182
- const { container } = render(<LiveboardEmbed liveboardId="abcd" className="def" />);
176
+ const { container } = render(
177
+ <LiveboardEmbed liveboardId="abcd" className="def" />,
178
+ );
183
179
 
184
180
  await waitFor(() => getIFrameEl(container));
185
181
  expect(container.querySelector('div')).not.toBe(null);
186
- expect(container.querySelector('div').classList.contains('def')).toBe(true);
182
+ expect(
183
+ container.querySelector('div').classList.contains('def'),
184
+ ).toBe(true);
187
185
 
188
186
  const { container: containerSibling } = render(
189
- <LiveboardEmbed liveboardId="abcd" className="def" insertAsSibling={true} />,
187
+ <LiveboardEmbed
188
+ liveboardId="abcd"
189
+ className="def"
190
+ insertAsSibling={true}
191
+ />,
190
192
  );
191
193
  await waitFor(() => getIFrameEl(containerSibling));
192
194
  expect(containerSibling.querySelector('span')).not.toBe(null);
193
- expect(containerSibling.querySelector('span').style.position).toBe('absolute');
194
- expect(getIFrameEl(containerSibling).classList.contains('def')).toBe(true);
195
+ expect(containerSibling.querySelector('span').style.position).toBe(
196
+ 'absolute',
197
+ );
198
+ expect(
199
+ getIFrameEl(containerSibling).classList.contains('def'),
200
+ ).toBe(true);
195
201
  expect(containerSibling.querySelector('div')).toBe(null);
196
202
  });
197
203
  });
@@ -211,9 +217,11 @@ describe('React Components', () => {
211
217
 
212
218
  await waitFor(() => getIFrameEl(container));
213
219
 
214
- expect(getIFrameEl(container).parentElement.classList.contains('embedClass')).toBe(
215
- true,
216
- );
220
+ expect(
221
+ getIFrameEl(container).parentElement.classList.contains(
222
+ 'embedClass',
223
+ ),
224
+ ).toBe(true);
217
225
  expect(getIFrameSrc(container)).toBe(
218
226
  `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&blockNonEmbedFullAppAccess=true&hideAction=[%22${Action.ReportError}%22]&overrideConsoleLogs=true&clientLogLevel=ERROR&dataSources=[%22test%22]&searchTokenString=%5Brevenue%5D&executeSearch=true&useLastSelectedSources=false&isSearchEmbed=true#/embed/search-bar-embed`,
219
227
  );
@@ -233,9 +241,7 @@ describe('React Components', () => {
233
241
  );
234
242
 
235
243
  await waitFor(() => getIFrameEl());
236
- const preRenderWrapper = document.body.querySelector(
237
- `#${preRenderId}`,
238
- ) as HTMLDivElement;
244
+ const preRenderWrapper = document.body.querySelector(`#${preRenderId}`) as HTMLDivElement;
239
245
 
240
246
  expect(preRenderWrapper).toBeInstanceOf(HTMLDivElement);
241
247
  expect((preRenderWrapper as HTMLDivElement).childElementCount).toBe(1);
@@ -250,7 +256,11 @@ describe('React Components', () => {
250
256
  unobserve: jest.fn(),
251
257
  }));
252
258
  const { container: libContainer } = render(
253
- <LiveboardEmbed className="embedClass" preRenderId="test" liveboardId="libId" />,
259
+ <LiveboardEmbed
260
+ className="embedClass"
261
+ preRenderId="test"
262
+ liveboardId="libId"
263
+ />,
254
264
  );
255
265
 
256
266
  expect(preRenderWrapper.style.opacity).toBe('');
@@ -266,9 +276,11 @@ describe('allExports', () => {
266
276
  });
267
277
 
268
278
  it('should not have undefined exports', () => {
269
- Object.keys(allExports)
270
- .forEach(
271
- (exportKey) => expect(Boolean(allExports[exportKey])).toBe(true),
272
- );
279
+ Object.keys(allExports).forEach(
280
+ (exportKey) => expect(
281
+ Boolean(allExports[exportKey]),
282
+ )
283
+ .toBe(true),
284
+ );
273
285
  });
274
286
  });
@@ -1,11 +1,11 @@
1
1
  import {
2
- EndPoints,
3
- fetchAuthPostService,
4
- fetchAuthService,
2
+ fetchSessionInfoService,
5
3
  fetchAuthTokenService,
4
+ fetchAuthService,
6
5
  fetchBasicAuthService,
7
- fetchSessionInfoService,
6
+ fetchAuthPostService,
8
7
  verifyTokenService,
8
+ EndPoints,
9
9
  } from '.';
10
10
  import { logger } from '../logger';
11
11