@thoughtspot/visual-embed-sdk 1.32.3 → 1.32.4

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 (110) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/embed/base.d.ts.map +1 -1
  3. package/cjs/src/embed/base.js +5 -6
  4. package/cjs/src/embed/base.js.map +1 -1
  5. package/cjs/src/embed/embed.spec.js +0 -19
  6. package/cjs/src/embed/embed.spec.js.map +1 -1
  7. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  8. package/cjs/src/embed/ts-embed.js +2 -7
  9. package/cjs/src/embed/ts-embed.js.map +1 -1
  10. package/cjs/src/embed/ts-embed.spec.js +0 -9
  11. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  12. package/cjs/src/types.d.ts +0 -9
  13. package/cjs/src/types.d.ts.map +1 -1
  14. package/cjs/src/types.js +0 -1
  15. package/cjs/src/types.js.map +1 -1
  16. package/cjs/src/utils/graphql/answerService/answer-queries.d.ts +1 -0
  17. package/cjs/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
  18. package/cjs/src/utils/graphql/answerService/answer-queries.js +9 -2
  19. package/cjs/src/utils/graphql/answerService/answer-queries.js.map +1 -1
  20. package/cjs/src/utils/graphql/answerService/answerService.d.ts +1 -0
  21. package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  22. package/cjs/src/utils/graphql/answerService/answerService.js +4 -0
  23. package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
  24. package/cjs/src/utils/graphql/answerService/answerService.spec.js +35 -0
  25. package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  26. package/cjs/src/utils/graphql/graphql-request.spec.d.ts +2 -0
  27. package/cjs/src/utils/graphql/graphql-request.spec.d.ts.map +1 -0
  28. package/cjs/src/utils/graphql/graphql-request.spec.js +36 -0
  29. package/cjs/src/utils/graphql/graphql-request.spec.js.map +1 -0
  30. package/cjs/src/utils/processTrigger.d.ts +1 -0
  31. package/cjs/src/utils/processTrigger.d.ts.map +1 -1
  32. package/cjs/src/utils/processTrigger.js +3 -3
  33. package/cjs/src/utils/processTrigger.js.map +1 -1
  34. package/cjs/src/utils/processTrigger.spec.js +10 -0
  35. package/cjs/src/utils/processTrigger.spec.js.map +1 -1
  36. package/cjs/src/utils.d.ts.map +1 -1
  37. package/cjs/src/utils.js +1 -5
  38. package/cjs/src/utils.js.map +1 -1
  39. package/dist/src/embed/base.d.ts.map +1 -1
  40. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  41. package/dist/src/types.d.ts +0 -9
  42. package/dist/src/types.d.ts.map +1 -1
  43. package/dist/src/utils/graphql/answerService/answer-queries.d.ts +1 -0
  44. package/dist/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
  45. package/dist/src/utils/graphql/answerService/answerService.d.ts +1 -0
  46. package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  47. package/dist/src/utils/graphql/graphql-request.spec.d.ts +2 -0
  48. package/dist/src/utils/graphql/graphql-request.spec.d.ts.map +1 -0
  49. package/dist/src/utils/processTrigger.d.ts +1 -0
  50. package/dist/src/utils/processTrigger.d.ts.map +1 -1
  51. package/dist/src/utils.d.ts.map +1 -1
  52. package/dist/tsembed-react.es.js +16 -15
  53. package/dist/tsembed-react.js +16 -15
  54. package/dist/tsembed.es.js +21 -21
  55. package/dist/tsembed.js +21 -21
  56. package/dist/visual-embed-sdk-react-full.d.ts +1 -9
  57. package/dist/visual-embed-sdk-react.d.ts +1 -9
  58. package/dist/visual-embed-sdk.d.ts +1 -9
  59. package/lib/package.json +1 -1
  60. package/lib/src/embed/base.d.ts.map +1 -1
  61. package/lib/src/embed/base.js +5 -6
  62. package/lib/src/embed/base.js.map +1 -1
  63. package/lib/src/embed/embed.spec.js +0 -19
  64. package/lib/src/embed/embed.spec.js.map +1 -1
  65. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  66. package/lib/src/embed/ts-embed.js +2 -7
  67. package/lib/src/embed/ts-embed.js.map +1 -1
  68. package/lib/src/embed/ts-embed.spec.js +0 -9
  69. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  70. package/lib/src/types.d.ts +0 -9
  71. package/lib/src/types.d.ts.map +1 -1
  72. package/lib/src/types.js +0 -1
  73. package/lib/src/types.js.map +1 -1
  74. package/lib/src/utils/graphql/answerService/answer-queries.d.ts +1 -0
  75. package/lib/src/utils/graphql/answerService/answer-queries.d.ts.map +1 -1
  76. package/lib/src/utils/graphql/answerService/answer-queries.js +8 -1
  77. package/lib/src/utils/graphql/answerService/answer-queries.js.map +1 -1
  78. package/lib/src/utils/graphql/answerService/answerService.d.ts +1 -0
  79. package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  80. package/lib/src/utils/graphql/answerService/answerService.js +4 -0
  81. package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
  82. package/lib/src/utils/graphql/answerService/answerService.spec.js +36 -1
  83. package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  84. package/lib/src/utils/graphql/graphql-request.spec.d.ts +2 -0
  85. package/lib/src/utils/graphql/graphql-request.spec.d.ts.map +1 -0
  86. package/lib/src/utils/graphql/graphql-request.spec.js +33 -0
  87. package/lib/src/utils/graphql/graphql-request.spec.js.map +1 -0
  88. package/lib/src/utils/processTrigger.d.ts +1 -0
  89. package/lib/src/utils/processTrigger.d.ts.map +1 -1
  90. package/lib/src/utils/processTrigger.js +1 -1
  91. package/lib/src/utils/processTrigger.js.map +1 -1
  92. package/lib/src/utils/processTrigger.spec.js +10 -0
  93. package/lib/src/utils/processTrigger.spec.js.map +1 -1
  94. package/lib/src/utils.d.ts.map +1 -1
  95. package/lib/src/utils.js +1 -5
  96. package/lib/src/utils.js.map +1 -1
  97. package/lib/src/visual-embed-sdk.d.ts +1 -9
  98. package/package.json +1 -1
  99. package/src/embed/base.ts +0 -1
  100. package/src/embed/embed.spec.ts +0 -22
  101. package/src/embed/ts-embed.spec.ts +0 -11
  102. package/src/embed/ts-embed.ts +0 -7
  103. package/src/types.ts +0 -9
  104. package/src/utils/graphql/answerService/answer-queries.ts +9 -1
  105. package/src/utils/graphql/answerService/answerService.spec.ts +45 -0
  106. package/src/utils/graphql/answerService/answerService.ts +8 -0
  107. package/src/utils/graphql/graphql-request.spec.ts +38 -0
  108. package/src/utils/processTrigger.spec.ts +19 -0
  109. package/src/utils/processTrigger.ts +1 -1
  110. package/src/utils.ts +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.32.3",
3
+ "version": "1.32.4",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
package/src/embed/base.ts CHANGED
@@ -198,7 +198,6 @@ export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
198
198
  const { password, ...configToTrack } = getEmbedConfig();
199
199
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
200
200
  ...configToTrack,
201
- usedCustomizationSheet: embedConfig.customizations?.style?.customCSSUrl != null,
202
201
  usedCustomizationVariables: embedConfig.customizations?.style?.customCSS?.variables != null,
203
202
  usedCustomizationRules:
204
203
  embedConfig.customizations?.style?.customCSS?.rules_UNSTABLE != null,
@@ -53,25 +53,3 @@ describe('test view config', () => {
53
53
  });
54
54
  });
55
55
  });
56
-
57
- describe('Custom CSS Url', () => {
58
- beforeEach(() => {
59
- document.body.innerHTML = getDocumentBody();
60
- });
61
-
62
- test('passing customCssUrl should set the correct query params on the iframe', async (done) => {
63
- init({
64
- thoughtSpotHost,
65
- authType: AuthType.None,
66
- customCssUrl: 'bla.com/foo.css',
67
- });
68
-
69
- const embed = new SearchEmbed(getRootEl(), defaultViewConfig);
70
- embed.render();
71
- executeAfterWait(() => {
72
- const iframe = getIFrameEl();
73
- expect(iframe.src.includes('customCssUrl=bla.com/foo.css')).toBe(true);
74
- done();
75
- });
76
- });
77
- });
@@ -56,7 +56,6 @@ beforeAll(() => {
56
56
  const customisations = {
57
57
  style: {
58
58
  customCSS: {},
59
- customCSSUrl: 'http://localhost:3000',
60
59
  },
61
60
  content: {},
62
61
  };
@@ -64,7 +63,6 @@ const customisations = {
64
63
  const customisationsView = {
65
64
  style: {
66
65
  customCSS: {},
67
- customCSSUrl: 'http://localhost:8000',
68
66
  },
69
67
  content: {
70
68
  strings: {
@@ -95,7 +93,6 @@ describe('Unit test case for ts embed', () => {
95
93
  init({
96
94
  thoughtSpotHost: 'tshost',
97
95
  customizations: customisations,
98
- customCssUrl: 'http://localhost:5000',
99
96
  authType: AuthType.TrustedAuthTokenCookieless,
100
97
  getAuthToken: () => Promise.resolve('test_auth_token2'),
101
98
  });
@@ -136,7 +133,6 @@ describe('Unit test case for ts embed', () => {
136
133
  thoughtSpotHost: 'tshost',
137
134
  authType: AuthType.None,
138
135
  customizations: customisations,
139
- customCssUrl: 'http://localhost:5000',
140
136
  });
141
137
  });
142
138
 
@@ -199,9 +195,6 @@ describe('Unit test case for ts embed', () => {
199
195
  reorderedHomepageModules: [],
200
196
  },
201
197
  });
202
- expect(getIFrameSrc()).toContain(
203
- `customCssUrl=${customisationsView.style.customCSSUrl}`,
204
- );
205
198
  });
206
199
 
207
200
  test('hide home page modules from view Config should be part of app_init payload', async () => {
@@ -601,7 +594,6 @@ describe('Unit test case for ts embed', () => {
601
594
  init({
602
595
  thoughtSpotHost: 'tshost',
603
596
  customizations: customisations,
604
- customCssUrl: 'http://localhost:5000',
605
597
  authType: AuthType.TrustedAuthTokenCookieless,
606
598
  getAuthToken: () => Promise.resolve('test_auth_token1'),
607
599
  });
@@ -655,7 +647,6 @@ describe('Unit test case for ts embed', () => {
655
647
  init({
656
648
  thoughtSpotHost: 'tshost',
657
649
  customizations: customisations,
658
- customCssUrl: 'http://localhost:5000',
659
650
  authType: AuthType.TrustedAuthTokenCookieless,
660
651
  getAuthToken: () => Promise.reject(),
661
652
  });
@@ -790,7 +781,6 @@ describe('Unit test case for ts embed', () => {
790
781
  init({
791
782
  thoughtSpotHost: 'tshost',
792
783
  customizations: customisations,
793
- customCssUrl: 'http://localhost:5000',
794
784
  authType: AuthType.TrustedAuthToken,
795
785
  username: 'tsadmin',
796
786
  getAuthToken: () => Promise.resolve('test_auth_token3'),
@@ -819,7 +809,6 @@ describe('Unit test case for ts embed', () => {
819
809
  init({
820
810
  thoughtSpotHost: 'tshost',
821
811
  customizations: customisations,
822
- customCssUrl: 'http://localhost:5000',
823
812
  authType: AuthType.TrustedAuthToken,
824
813
  username: 'tsadmin',
825
814
  getAuthToken: () => Promise.resolve('test_auth_token4'),
@@ -454,13 +454,6 @@ export class TsEmbed {
454
454
  return queryParams;
455
455
  }
456
456
 
457
- // TODO remove embedConfig.customCssUrl
458
- const cssUrlParam = customizations?.style?.customCSSUrl || this.embedConfig.customCssUrl;
459
-
460
- if (cssUrlParam) {
461
- queryParams[Param.CustomCSSUrl] = cssUrlParam;
462
- }
463
-
464
457
  if (disabledActions?.length) {
465
458
  queryParams[Param.DisableActions] = disabledActions;
466
459
  }
package/src/types.ts CHANGED
@@ -255,7 +255,6 @@ export interface customCssInterface {
255
255
  * Styles within the {@link CustomisationsInterface}.
256
256
  */
257
257
  export interface CustomStyles {
258
- customCSSUrl?: string;
259
258
  customCSS?: customCssInterface;
260
259
  }
261
260
 
@@ -449,13 +448,6 @@ export interface EmbedConfig {
449
448
  */
450
449
  queueMultiRenders?: boolean;
451
450
 
452
- /**
453
- * Dynamic CSS URL to be injected in the loaded application.
454
- * You would also need to set `style-src` in the CSP settings.
455
- * @version SDK: 1.6.0 | ThoughtSpot: ts8.nov.cl, 8.4.1.sw
456
- * @default ''
457
- */
458
- customCssUrl?: string;
459
451
  /**
460
452
  * [AuthServer|Basic] Detect if third-party party cookies are enabled by doing an
461
453
  * additional call. This is slower and should be avoided. Listen to the
@@ -3080,7 +3072,6 @@ export enum Param {
3080
3072
  ViewPortHeight = 'viewPortHeight',
3081
3073
  ViewPortWidth = 'viewPortWidth',
3082
3074
  VisibleActions = 'visibleAction',
3083
- CustomCSSUrl = 'customCssUrl',
3084
3075
  DisableLoginRedirect = 'disableLoginRedirect',
3085
3076
  visibleVizs = 'pinboardVisibleVizs',
3086
3077
  LiveboardV2Enabled = 'isPinboardV2Enabled',
@@ -101,7 +101,6 @@ export const getAnswer = `
101
101
  isDiscoverable
102
102
  isHidden
103
103
  modifiedAt
104
- tags
105
104
  }
106
105
  visualizations {
107
106
  ... on TableViz {
@@ -164,3 +163,12 @@ export const addVizToLiveboard = `
164
163
  }
165
164
  }
166
165
  `;
166
+
167
+ export const getSQLQuery = `
168
+ mutation GetSQLQuery($session: BachSessionIdInput!) {
169
+ Answer__getQuery(session: $session) {
170
+ ${bachSessionId}
171
+ sql
172
+ }
173
+ }
174
+ `;
@@ -3,7 +3,9 @@ import { AuthType, RuntimeFilterOp, VizPoint } from '../../../types';
3
3
  import { AnswerService } from './answerService';
4
4
  import {
5
5
  getAnswerData, removeColumns, addFilter, addColumns,
6
+ getSQLQuery,
6
7
  } from './answer-queries';
8
+ import * as queries from './answer-queries';
7
9
  import * as authTokenInstance from '../../../authToken';
8
10
  import * as tokenizedFetch from '../../../tokenizedFetch';
9
11
  import * as embedConfigInstance from '../../../embed/embedConfig';
@@ -34,6 +36,23 @@ describe('Answer service tests', () => {
34
36
  beforeEach(() => {
35
37
  fetchMock.resetMocks();
36
38
  });
39
+
40
+ test('should call executeQuery with correct parameters to add columns', async () => {
41
+ const service = createAnswerService();
42
+ const executeQuerySpy = jest.spyOn(service, 'executeQuery').mockResolvedValue({
43
+ id: { genNo: 2 },
44
+
45
+ });
46
+
47
+ const columnIds = ['col1', 'col2'];
48
+ const result = await service.addColumns(columnIds);
49
+
50
+ expect(executeQuerySpy).toHaveBeenCalledWith(queries.addColumns, {
51
+ columns: columnIds.map((colId) => ({ logicalColumnId: colId })),
52
+ });
53
+ expect(result.id.genNo).toBe(2);
54
+ });
55
+
37
56
  test('Execute query should execute the supplied graphql on the session', async () => {
38
57
  fetchMock.mockResponseOnce(JSON.stringify({
39
58
  data: {
@@ -404,4 +423,30 @@ describe('Answer service tests', () => {
404
423
  }),
405
424
  );
406
425
  });
426
+
427
+ test('Get SQL query should call the right API', async () => {
428
+ fetchMock.mockResponseOnce(JSON.stringify({
429
+ data: {
430
+ Answer__getQuery: {
431
+ id: {},
432
+ sql: 'SELECT * FROM table',
433
+ },
434
+ },
435
+ }));
436
+ const answerService = createAnswerService();
437
+ const sql = await answerService.getSQLQuery();
438
+ expect(fetchMock).toHaveBeenCalledWith(
439
+ 'https://tshost/prism/?op=GetSQLQuery',
440
+ expect.objectContaining({
441
+ body: JSON.stringify({
442
+ operationName: 'GetSQLQuery',
443
+ query: getSQLQuery,
444
+ variables: {
445
+ session: defaultSession,
446
+ },
447
+ }),
448
+ }),
449
+ );
450
+ expect(sql).toBe('SELECT * FROM table');
451
+ });
407
452
  });
@@ -173,6 +173,14 @@ export class AnswerService {
173
173
  );
174
174
  }
175
175
 
176
+ public async getSQLQuery(): Promise<string> {
177
+ const { sql } = await this.executeQuery(
178
+ queries.getSQLQuery,
179
+ {},
180
+ );
181
+ return sql;
182
+ }
183
+
176
184
  /**
177
185
  * Fetch data from the answer.
178
186
  * @param offset
@@ -0,0 +1,38 @@
1
+ import 'jest-fetch-mock';
2
+ import { getSourceDetail } from './sourceService';
3
+ import * as tokenizedFetchUtil from '../../tokenizedFetch';
4
+ import { graphqlQuery } from './graphql-request';
5
+
6
+ const getSourceDetailQuery = `
7
+ query GetSourceDetail($ids: [GUID!]!) {
8
+ getSourceDetailById(ids: $ids, type: LOGICAL_TABLE) {
9
+ id
10
+ name
11
+ }
12
+ }
13
+ `;
14
+
15
+ const thoughtSpotHost = 'TSHOST';
16
+
17
+ describe('graphQl tests', () => {
18
+ test('should call tokenizedFetch with correct parameters when graphqlQuery is called', async () => {
19
+ jest.spyOn(tokenizedFetchUtil, 'tokenizedFetch');
20
+
21
+ const details = await graphqlQuery({
22
+ query: getSourceDetailQuery,
23
+ variables: {
24
+ ids: [2],
25
+ },
26
+ thoughtSpotHost,
27
+ });
28
+
29
+ expect(tokenizedFetchUtil.tokenizedFetch).toBeCalledWith('TSHOST/prism/?op=GetSourceDetail', {
30
+ body: '{"operationName":"GetSourceDetail","query":"\\n query GetSourceDetail($ids: [GUID!]!) {\\n getSourceDetailById(ids: $ids, type: LOGICAL_TABLE) {\\n id\\n name\\n }\\n } \\n","variables":{"ids":[2]}}',
31
+ credentials: 'include',
32
+ headers: {
33
+ accept: '*/*', 'accept-language': 'en-us', 'content-type': 'application/json;charset=UTF-8', 'x-requested-by': 'ThoughtSpot',
34
+ },
35
+ method: 'POST',
36
+ });
37
+ });
38
+ });
@@ -67,4 +67,23 @@ describe('Unit test for processTrigger', () => {
67
67
  expect(messageChannelMock.port1.close).toBeCalled();
68
68
  expect(triggerPromise).rejects.toEqual(res.data.error);
69
69
  });
70
+
71
+ test('should close channel.port1 when timeout exceeds TRIGGER_TIMEOUT', async () => {
72
+ const messageType = HostEvent.Search;
73
+ const thoughtSpotHost = 'http://localhost:3000';
74
+ const data = {};
75
+ mockMessageChannel();
76
+
77
+ const triggerPromise = _processTriggerInstance.processTrigger(
78
+ iFrame,
79
+ messageType,
80
+ thoughtSpotHost,
81
+ data,
82
+ );
83
+
84
+ jest.advanceTimersByTime(_processTriggerInstance.TRIGGER_TIMEOUT);
85
+
86
+ expect(messageChannelMock.port1.close).toBeCalled();
87
+ await expect(triggerPromise).resolves.toBeInstanceOf(Error);
88
+ });
70
89
  });
@@ -31,7 +31,7 @@ function postIframeMessage(
31
31
  return iFrame.contentWindow.postMessage(message, thoughtSpotHost, [channel?.port2]);
32
32
  }
33
33
 
34
- const TRIGGER_TIMEOUT = 30000;
34
+ export const TRIGGER_TIMEOUT = 30000;
35
35
 
36
36
  /**
37
37
  *
package/src/utils.ts CHANGED
@@ -206,7 +206,6 @@ export const getCustomisations = (
206
206
  embedConfig: EmbedConfig,
207
207
  viewConfig: ViewConfig,
208
208
  ): CustomisationsInterface => {
209
- const customCssUrlFromEmbedConfig = embedConfig.customCssUrl;
210
209
  const customizationsFromViewConfig = viewConfig.customizations;
211
210
  const customizationsFromEmbedConfig = embedConfig.customizations
212
211
  || ((embedConfig as any).customisations as CustomisationsInterface);
@@ -219,10 +218,6 @@ export const getCustomisations = (
219
218
  ...customizationsFromEmbedConfig?.style?.customCSS,
220
219
  ...customizationsFromViewConfig?.style?.customCSS,
221
220
  },
222
- customCSSUrl:
223
- customizationsFromViewConfig?.style?.customCSSUrl
224
- || customizationsFromEmbedConfig?.style?.customCSSUrl
225
- || customCssUrlFromEmbedConfig,
226
221
  },
227
222
  content: {
228
223
  ...customizationsFromEmbedConfig?.content,