@thoughtspot/visual-embed-sdk 1.20.0-prerender.2 → 1.20.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 (182) hide show
  1. package/README.md +1 -1
  2. package/dist/src/auth.d.ts +2 -38
  3. package/dist/src/auth.d.ts.map +1 -1
  4. package/dist/src/config.d.ts +0 -1
  5. package/dist/src/config.d.ts.map +1 -1
  6. package/dist/src/embed/app.d.ts +5 -17
  7. package/dist/src/embed/app.d.ts.map +1 -1
  8. package/dist/src/embed/base.d.ts +9 -20
  9. package/dist/src/embed/base.d.ts.map +1 -1
  10. package/dist/src/embed/liveboard.d.ts +5 -17
  11. package/dist/src/embed/liveboard.d.ts.map +1 -1
  12. package/dist/src/embed/search-bar.d.ts +0 -3
  13. package/dist/src/embed/search-bar.d.ts.map +1 -1
  14. package/dist/src/embed/search.d.ts +5 -9
  15. package/dist/src/embed/search.d.ts.map +1 -1
  16. package/dist/src/embed/ts-embed.d.ts +6 -43
  17. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  18. package/dist/src/errors.d.ts.map +1 -1
  19. package/dist/src/index.d.ts.map +1 -1
  20. package/dist/src/mixpanel-service.d.ts +0 -8
  21. package/dist/src/mixpanel-service.d.ts.map +1 -1
  22. package/dist/src/react/index.d.ts.map +1 -1
  23. package/dist/src/react/util.d.ts +0 -4
  24. package/dist/src/react/util.d.ts.map +1 -1
  25. package/dist/src/test/test-utils.d.ts +2 -11
  26. package/dist/src/test/test-utils.d.ts.map +1 -1
  27. package/dist/src/types.d.ts +76 -273
  28. package/dist/src/types.d.ts.map +1 -1
  29. package/dist/src/utils/answerService.d.ts +0 -7
  30. package/dist/src/utils/answerService.d.ts.map +1 -1
  31. package/dist/src/utils/authService.d.ts +0 -30
  32. package/dist/src/utils/authService.d.ts.map +1 -1
  33. package/dist/src/utils/processData.d.ts +0 -12
  34. package/dist/src/utils/processData.d.ts.map +1 -1
  35. package/dist/src/utils/processTrigger.d.ts +0 -7
  36. package/dist/src/utils/processTrigger.d.ts.map +1 -1
  37. package/dist/src/utils.d.ts +0 -12
  38. package/dist/src/utils.d.ts.map +1 -1
  39. package/dist/tsembed.es.js +262 -637
  40. package/dist/tsembed.js +261 -629
  41. package/lib/package.json +8 -3
  42. package/lib/src/auth.d.ts +2 -38
  43. package/lib/src/auth.d.ts.map +1 -1
  44. package/lib/src/auth.js +25 -70
  45. package/lib/src/auth.js.map +1 -1
  46. package/lib/src/auth.spec.js +5 -14
  47. package/lib/src/auth.spec.js.map +1 -1
  48. package/lib/src/config.d.ts +0 -1
  49. package/lib/src/config.d.ts.map +1 -1
  50. package/lib/src/config.js +3 -5
  51. package/lib/src/config.js.map +1 -1
  52. package/lib/src/config.spec.js.map +1 -1
  53. package/lib/src/embed/app.d.ts +5 -17
  54. package/lib/src/embed/app.d.ts.map +1 -1
  55. package/lib/src/embed/app.js +15 -25
  56. package/lib/src/embed/app.js.map +1 -1
  57. package/lib/src/embed/app.spec.js +12 -12
  58. package/lib/src/embed/app.spec.js.map +1 -1
  59. package/lib/src/embed/base.d.ts +9 -20
  60. package/lib/src/embed/base.d.ts.map +1 -1
  61. package/lib/src/embed/base.js +15 -31
  62. package/lib/src/embed/base.js.map +1 -1
  63. package/lib/src/embed/base.spec.js.map +1 -1
  64. package/lib/src/embed/embed.spec.js +1 -1
  65. package/lib/src/embed/embed.spec.js.map +1 -1
  66. package/lib/src/embed/liveboard.d.ts +5 -17
  67. package/lib/src/embed/liveboard.d.ts.map +1 -1
  68. package/lib/src/embed/liveboard.js +37 -49
  69. package/lib/src/embed/liveboard.js.map +1 -1
  70. package/lib/src/embed/liveboard.spec.js +30 -37
  71. package/lib/src/embed/liveboard.spec.js.map +1 -1
  72. package/lib/src/embed/pinboard.spec.js +26 -14
  73. package/lib/src/embed/pinboard.spec.js.map +1 -1
  74. package/lib/src/embed/search-bar.d.ts +0 -3
  75. package/lib/src/embed/search-bar.d.ts.map +1 -1
  76. package/lib/src/embed/search-bar.js +6 -5
  77. package/lib/src/embed/search-bar.js.map +1 -1
  78. package/lib/src/embed/search.d.ts +5 -9
  79. package/lib/src/embed/search.d.ts.map +1 -1
  80. package/lib/src/embed/search.js +14 -18
  81. package/lib/src/embed/search.js.map +1 -1
  82. package/lib/src/embed/search.spec.js +19 -16
  83. package/lib/src/embed/search.spec.js.map +1 -1
  84. package/lib/src/embed/searchEmbed-basic-auth.spec.js +0 -4
  85. package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -1
  86. package/lib/src/embed/ts-embed.d.ts +6 -43
  87. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  88. package/lib/src/embed/ts-embed.js +72 -117
  89. package/lib/src/embed/ts-embed.js.map +1 -1
  90. package/lib/src/embed/ts-embed.spec.js +24 -23
  91. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  92. package/lib/src/errors.d.ts.map +1 -1
  93. package/lib/src/errors.js.map +1 -1
  94. package/lib/src/index.d.ts.map +1 -1
  95. package/lib/src/index.js +2 -2
  96. package/lib/src/index.js.map +1 -1
  97. package/lib/src/mixpanel-service.d.ts +0 -8
  98. package/lib/src/mixpanel-service.d.ts.map +1 -1
  99. package/lib/src/mixpanel-service.js +1 -13
  100. package/lib/src/mixpanel-service.js.map +1 -1
  101. package/lib/src/mixpanel-service.spec.js.map +1 -1
  102. package/lib/src/react/index.d.ts.map +1 -1
  103. package/lib/src/react/index.js +6 -6
  104. package/lib/src/react/index.js.map +1 -1
  105. package/lib/src/react/index.spec.js +6 -15
  106. package/lib/src/react/index.spec.js.map +1 -1
  107. package/lib/src/react/util.d.ts +0 -4
  108. package/lib/src/react/util.d.ts.map +1 -1
  109. package/lib/src/react/util.js +0 -4
  110. package/lib/src/react/util.js.map +1 -1
  111. package/lib/src/test/test-utils.d.ts +2 -11
  112. package/lib/src/test/test-utils.d.ts.map +1 -1
  113. package/lib/src/test/test-utils.js +25 -36
  114. package/lib/src/test/test-utils.js.map +1 -1
  115. package/lib/src/types.d.ts +76 -273
  116. package/lib/src/types.d.ts.map +1 -1
  117. package/lib/src/types.js +54 -200
  118. package/lib/src/types.js.map +1 -1
  119. package/lib/src/utils/answerService.d.ts +0 -7
  120. package/lib/src/utils/answerService.d.ts.map +1 -1
  121. package/lib/src/utils/answerService.js +0 -7
  122. package/lib/src/utils/answerService.js.map +1 -1
  123. package/lib/src/utils/answerService.spec.js.map +1 -1
  124. package/lib/src/utils/authService.d.ts +0 -30
  125. package/lib/src/utils/authService.d.ts.map +1 -1
  126. package/lib/src/utils/authService.js +2 -39
  127. package/lib/src/utils/authService.js.map +1 -1
  128. package/lib/src/utils/authService.spec.js.map +1 -1
  129. package/lib/src/utils/processData.d.ts +0 -12
  130. package/lib/src/utils/processData.d.ts.map +1 -1
  131. package/lib/src/utils/processData.js +5 -33
  132. package/lib/src/utils/processData.js.map +1 -1
  133. package/lib/src/utils/processData.spec.js.map +1 -1
  134. package/lib/src/utils/processTrigger.d.ts +0 -7
  135. package/lib/src/utils/processTrigger.d.ts.map +1 -1
  136. package/lib/src/utils/processTrigger.js +3 -17
  137. package/lib/src/utils/processTrigger.js.map +1 -1
  138. package/lib/src/utils/processTrigger.spec.js.map +1 -1
  139. package/lib/src/utils.d.ts +0 -12
  140. package/lib/src/utils.d.ts.map +1 -1
  141. package/lib/src/utils.js +19 -24
  142. package/lib/src/utils.js.map +1 -1
  143. package/lib/src/utils.spec.js.map +1 -1
  144. package/lib/src/visual-embed-sdk.d.ts +102 -406
  145. package/package.json +8 -3
  146. package/src/auth.spec.ts +150 -68
  147. package/src/auth.ts +108 -102
  148. package/src/config.spec.ts +4 -2
  149. package/src/config.ts +3 -5
  150. package/src/embed/app.spec.ts +14 -25
  151. package/src/embed/app.ts +35 -47
  152. package/src/embed/base.spec.ts +9 -3
  153. package/src/embed/base.ts +53 -51
  154. package/src/embed/embed.spec.ts +6 -5
  155. package/src/embed/liveboard.spec.ts +37 -56
  156. package/src/embed/liveboard.ts +64 -66
  157. package/src/embed/pinboard.spec.ts +29 -26
  158. package/src/embed/search-bar.tsx +8 -10
  159. package/src/embed/search.spec.ts +21 -31
  160. package/src/embed/search.ts +25 -26
  161. package/src/embed/searchEmbed-basic-auth.spec.ts +28 -22
  162. package/src/embed/ts-embed.spec.ts +148 -70
  163. package/src/embed/ts-embed.ts +157 -147
  164. package/src/errors.ts +6 -3
  165. package/src/index.ts +10 -4
  166. package/src/mixpanel-service.spec.ts +3 -1
  167. package/src/mixpanel-service.ts +1 -13
  168. package/src/react/index.spec.tsx +13 -37
  169. package/src/react/index.tsx +57 -38
  170. package/src/react/util.ts +4 -8
  171. package/src/test/test-utils.ts +39 -43
  172. package/src/types.ts +78 -270
  173. package/src/utils/answerService.spec.ts +5 -3
  174. package/src/utils/answerService.ts +17 -21
  175. package/src/utils/authService.spec.ts +41 -26
  176. package/src/utils/authService.ts +21 -47
  177. package/src/utils/processData.spec.ts +59 -26
  178. package/src/utils/processData.ts +14 -36
  179. package/src/utils/processTrigger.spec.ts +6 -1
  180. package/src/utils/processTrigger.ts +9 -18
  181. package/src/utils.spec.ts +12 -8
  182. package/src/utils.ts +26 -25
@@ -11,9 +11,11 @@ describe('Unit test for getAnswerServiceInstance', () => {
11
11
 
12
12
  test('fetchData, when api giving answer data', async () => {
13
13
  const mockAnswerResponse = { data: {} };
14
- global.fetch = jest.fn(() => Promise.resolve({
15
- json: () => mockAnswerResponse,
16
- }));
14
+ global.fetch = jest.fn(() =>
15
+ Promise.resolve({
16
+ json: () => mockAnswerResponse,
17
+ }),
18
+ );
17
19
  const answerService = getAnswerServiceInstance(
18
20
  session,
19
21
  query,
@@ -1,12 +1,5 @@
1
1
  import { SessionInterface, OperationType } from '../types';
2
2
 
3
- /**
4
- *
5
- * @param session
6
- * @param query
7
- * @param operation
8
- * @param thoughtSpotHost
9
- */
10
3
  export function getAnswerServiceInstance(
11
4
  session: SessionInterface,
12
5
  query: string,
@@ -17,21 +10,24 @@ export function getAnswerServiceInstance(
17
10
 
18
11
  const fetchQuery = async (variables: any) => {
19
12
  try {
20
- const response = await fetch(`${thoughtSpotHost}/prism/?op=${operation}`, {
21
- method: 'POST',
22
- headers: {
23
- 'content-type': 'application/json;charset=UTF-8',
24
- 'x-requested-by': 'ThoughtSpot',
25
- accept: '*/*',
26
- 'accept-language': 'en-us',
13
+ const response = await fetch(
14
+ `${thoughtSpotHost}/prism/?op=${operation}`,
15
+ {
16
+ method: 'POST',
17
+ headers: {
18
+ 'content-type': 'application/json;charset=UTF-8',
19
+ 'x-requested-by': 'ThoughtSpot',
20
+ accept: '*/*',
21
+ 'accept-language': 'en-us',
22
+ },
23
+ body: JSON.stringify({
24
+ operationName: operation,
25
+ query,
26
+ variables,
27
+ }),
28
+ credentials: 'include',
27
29
  },
28
- body: JSON.stringify({
29
- operationName: operation,
30
- query,
31
- variables,
32
- }),
33
- credentials: 'include',
34
- });
30
+ );
35
31
  const result = await response.json();
36
32
  return result.data;
37
33
  } catch (error) {
@@ -19,28 +19,34 @@ describe('Unit test for authService', () => {
19
19
  global.fetch = window.fetch;
20
20
  });
21
21
  test('fetchSessionInfoService', async () => {
22
- global.fetch = jest.fn(() => Promise.resolve({
23
- json: () => ({ success: true }),
24
- status: 200,
25
- ok: true,
26
- }));
22
+ global.fetch = jest.fn(() =>
23
+ Promise.resolve({
24
+ json: () => ({ success: true }),
25
+ status: 200,
26
+ ok: true,
27
+ }),
28
+ );
27
29
  const response = await fetchSessionInfoService(authVerificationUrl);
28
30
  expect(response.status).toBe(200);
29
31
  expect(fetch).toHaveBeenCalledTimes(1);
30
32
  });
31
33
 
32
34
  test('fetchAuthTokenService', async () => {
33
- global.fetch = jest.fn(() => Promise.resolve({
34
- text: () => ({ success: true }),
35
- ok: true,
36
- }));
35
+ global.fetch = jest.fn(() =>
36
+ Promise.resolve({
37
+ text: () => ({ success: true }),
38
+ ok: true,
39
+ }),
40
+ );
37
41
  const response = await fetchAuthTokenService(authEndpoint);
38
42
  expect(response.text()).toStrictEqual({ success: true });
39
43
  expect(fetch).toBeCalled();
40
44
  });
41
45
 
42
46
  test('fetchAuthService', async () => {
43
- global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
47
+ global.fetch = jest.fn(() =>
48
+ Promise.resolve({ success: true, ok: true }),
49
+ );
44
50
  await fetchAuthService(thoughtSpotHost, username, authToken);
45
51
  expect(fetch).toBeCalledWith(
46
52
  `${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`,
@@ -52,33 +58,42 @@ describe('Unit test for authService', () => {
52
58
  });
53
59
 
54
60
  test('fetchAuthPostService', async () => {
55
- global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
61
+ global.fetch = jest.fn(() =>
62
+ Promise.resolve({ success: true, ok: true }),
63
+ );
56
64
  await fetchAuthPostService(thoughtSpotHost, username, authToken);
57
- expect(fetch).toBeCalledWith(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}`, {
58
- method: 'POST',
59
- credentials: 'include',
60
- redirect: 'manual',
61
- body: 'username=tsuser&auth_token=token',
62
- headers: {
63
- 'content-type': 'application/x-www-form-urlencoded',
64
- 'x-requested-by': 'ThoughtSpot',
65
+ expect(fetch).toBeCalledWith(
66
+ `${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}`,
67
+ {
68
+ method: 'POST',
69
+ credentials: 'include',
70
+ redirect: 'manual',
71
+ body: 'username=tsuser&auth_token=token',
72
+ headers: {
73
+ 'content-type': 'application/x-www-form-urlencoded',
74
+ 'x-requested-by': 'ThoughtSpot',
75
+ },
65
76
  },
66
- });
77
+ );
67
78
  });
68
79
 
69
80
  test('fetchBasicAuthService called with manual redirect', async () => {
70
- global.fetch = jest.fn(() => Promise.resolve({ success: true, ok: true }));
81
+ global.fetch = jest.fn(() =>
82
+ Promise.resolve({ success: true, ok: true }),
83
+ );
71
84
  await fetchBasicAuthService(thoughtSpotHost, username, password);
72
85
  expect(fetch).toBeCalled();
73
86
  });
74
87
 
75
88
  test('log error on API failures', async () => {
76
89
  jest.spyOn(global.console, 'error').mockImplementation(() => undefined);
77
- global.fetch = jest.fn(() => Promise.resolve({
78
- text: () => Promise.resolve('error'),
79
- status: 500,
80
- ok: false,
81
- }));
90
+ global.fetch = jest.fn(() =>
91
+ Promise.resolve({
92
+ text: () => Promise.resolve('error'),
93
+ status: 500,
94
+ ok: false,
95
+ }),
96
+ );
82
97
  await fetchSessionInfoService(authVerificationUrl);
83
98
  expect(global.console.error).toHaveBeenCalledWith('Failure', 'error');
84
99
  });
@@ -1,12 +1,10 @@
1
1
  // eslint-disable-next-line import/no-cycle
2
2
  import { EndPoints } from '../auth';
3
3
 
4
- /**
5
- *
6
- * @param url
7
- * @param options
8
- */
9
- function failureLoggedFetch(url: string, options: RequestInit = {}): Promise<Response> {
4
+ function failureLoggedFetch(
5
+ url: string,
6
+ options: RequestInit = {},
7
+ ): Promise<Response> {
10
8
  return fetch(url, options).then(async (r) => {
11
9
  if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
12
10
  console.error('Failure', await r.text?.());
@@ -15,30 +13,20 @@ function failureLoggedFetch(url: string, options: RequestInit = {}): Promise<Res
15
13
  });
16
14
  }
17
15
 
18
- /**
19
- *
20
- * @param authVerificationUrl
21
- */
22
- export function fetchSessionInfoService(authVerificationUrl: string): Promise<any> {
16
+ export function fetchSessionInfoService(
17
+ authVerificationUrl: string,
18
+ ): Promise<any> {
23
19
  return failureLoggedFetch(authVerificationUrl, {
24
20
  credentials: 'include',
25
21
  });
26
22
  }
27
23
 
28
- /**
29
- *
30
- * @param authEndpoint
31
- */
32
- export async function fetchAuthTokenService(authEndpoint: string): Promise<any> {
24
+ export async function fetchAuthTokenService(
25
+ authEndpoint: string,
26
+ ): Promise<any> {
33
27
  return fetch(authEndpoint);
34
28
  }
35
29
 
36
- /**
37
- *
38
- * @param thoughtSpotHost
39
- * @param username
40
- * @param authToken
41
- */
42
30
  export async function fetchAuthService(
43
31
  thoughtSpotHost: string,
44
32
  username: string,
@@ -48,19 +36,12 @@ export async function fetchAuthService(
48
36
  `${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?username=${username}&auth_token=${authToken}`,
49
37
  {
50
38
  credentials: 'include',
51
- // We do not want to follow the redirect, as it starts giving a CORS
52
- // error
39
+ // We do not want to follow the redirect, as it starts giving a CORS error
53
40
  redirect: 'manual',
54
41
  },
55
42
  );
56
43
  }
57
44
 
58
- /**
59
- *
60
- * @param thoughtSpotHost
61
- * @param username
62
- * @param authToken
63
- */
64
45
  export async function fetchAuthPostService(
65
46
  thoughtSpotHost: string,
66
47
  username: string,
@@ -72,22 +53,15 @@ export async function fetchAuthPostService(
72
53
  'content-type': 'application/x-www-form-urlencoded',
73
54
  'x-requested-by': 'ThoughtSpot',
74
55
  },
75
- body: `username=${encodeURIComponent(username)}&auth_token=${encodeURIComponent(
76
- authToken,
77
- )}`,
56
+ body: `username=${encodeURIComponent(
57
+ username,
58
+ )}&auth_token=${encodeURIComponent(authToken)}`,
78
59
  credentials: 'include',
79
- // We do not want to follow the redirect, as it starts giving a CORS
80
- // error
60
+ // We do not want to follow the redirect, as it starts giving a CORS error
81
61
  redirect: 'manual',
82
62
  });
83
63
  }
84
64
 
85
- /**
86
- *
87
- * @param thoughtSpotHost
88
- * @param username
89
- * @param password
90
- */
91
65
  export async function fetchBasicAuthService(
92
66
  thoughtSpotHost: string,
93
67
  username: string,
@@ -99,16 +73,16 @@ export async function fetchBasicAuthService(
99
73
  'content-type': 'application/x-www-form-urlencoded',
100
74
  'x-requested-by': 'ThoughtSpot',
101
75
  },
102
- body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
76
+ body: `username=${encodeURIComponent(
77
+ username,
78
+ )}&password=${encodeURIComponent(password)}`,
103
79
  credentials: 'include',
104
80
  });
105
81
  }
106
82
 
107
- /**
108
- *
109
- * @param thoughtSpotHost
110
- */
111
- export async function fetchLogoutService(thoughtSpotHost: string): Promise<any> {
83
+ export async function fetchLogoutService(
84
+ thoughtSpotHost: string,
85
+ ): Promise<any> {
112
86
  return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
113
87
  credentials: 'include',
114
88
  method: 'POST',
@@ -26,17 +26,24 @@ describe('Unit test for process data', () => {
26
26
  operation: OperationType.GetChartWithData,
27
27
  },
28
28
  };
29
- jest.spyOn(answerServiceInstance, 'getAnswerServiceInstance').mockReturnValue(
30
- answerService,
31
- );
29
+ jest.spyOn(
30
+ answerServiceInstance,
31
+ 'getAnswerServiceInstance',
32
+ ).mockReturnValue(answerService);
32
33
  expect(
33
- processDataInstance.processCustomAction(processChartData, thoughtSpotHost),
34
+ processDataInstance.processCustomAction(
35
+ processChartData,
36
+ thoughtSpotHost,
37
+ ),
34
38
  ).toStrictEqual(processChartData);
35
39
  });
36
40
 
37
41
  test('ProcessData, when Action is CustomAction', async () => {
38
42
  const processedData = { type: EmbedEvent.CustomAction };
39
- jest.spyOn(processDataInstance, 'processCustomAction').mockImplementation(async () => ({}));
43
+ jest.spyOn(
44
+ processDataInstance,
45
+ 'processCustomAction',
46
+ ).mockImplementation(async () => ({}));
40
47
  expect(
41
48
  processDataInstance.processEventData(
42
49
  EmbedEvent.CustomAction,
@@ -49,12 +56,20 @@ describe('Unit test for process data', () => {
49
56
 
50
57
  test('ProcessData, when Action is non CustomAction', () => {
51
58
  const processedData = { type: EmbedEvent.Data };
52
- jest.spyOn(processDataInstance, 'processCustomAction').mockImplementation(async () => ({}));
59
+ jest.spyOn(
60
+ processDataInstance,
61
+ 'processCustomAction',
62
+ ).mockImplementation(async () => ({}));
53
63
  jest.spyOn(
54
64
  answerServiceInstance,
55
65
  'getAnswerServiceInstance',
56
66
  ).mockImplementation(async () => ({}));
57
- processDataInstance.processEventData(EmbedEvent.Data, processedData, thoughtSpotHost, null);
67
+ processDataInstance.processEventData(
68
+ EmbedEvent.Data,
69
+ processedData,
70
+ thoughtSpotHost,
71
+ null,
72
+ );
58
73
  expect(processDataInstance.processCustomAction).not.toBeCalled();
59
74
  });
60
75
 
@@ -67,7 +82,9 @@ describe('Unit test for process data', () => {
67
82
  const e = { type: EmbedEvent.AuthInit, data: sessionInfo };
68
83
  jest.spyOn(auth, 'initSession').mockReturnValue(null);
69
84
  jest.spyOn(base, 'notifyAuthSuccess');
70
- expect(processDataInstance.processEventData(e.type, e, '', null)).toEqual({
85
+ expect(
86
+ processDataInstance.processEventData(e.type, e, '', null),
87
+ ).toEqual({
71
88
  type: e.type,
72
89
  data: {
73
90
  userGUID: sessionInfo.userGUID,
@@ -86,10 +103,14 @@ describe('Unit test for process data', () => {
86
103
  });
87
104
  jest.spyOn(window, 'alert').mockImplementation(() => undefined);
88
105
  const el: any = {};
89
- expect(processDataInstance.processEventData(e.type, e, '', el)).toEqual({
90
- type: e.type,
91
- });
92
- expect(base.notifyAuthFailure).toBeCalledWith(auth.AuthFailureType.NO_COOKIE_ACCESS);
106
+ expect(processDataInstance.processEventData(e.type, e, '', el)).toEqual(
107
+ {
108
+ type: e.type,
109
+ },
110
+ );
111
+ expect(base.notifyAuthFailure).toBeCalledWith(
112
+ auth.AuthFailureType.NO_COOKIE_ACCESS,
113
+ );
93
114
  expect(window.alert).toBeCalled();
94
115
  expect(el.innerHTML).toBe('Hello');
95
116
  });
@@ -104,10 +125,14 @@ describe('Unit test for process data', () => {
104
125
  jest.spyOn(window, 'alert').mockReset();
105
126
  jest.spyOn(window, 'alert').mockImplementation(() => undefined);
106
127
  const el: any = {};
107
- expect(processDataInstance.processEventData(e.type, e, '', el)).toEqual({
108
- type: e.type,
109
- });
110
- expect(base.notifyAuthFailure).toBeCalledWith(auth.AuthFailureType.NO_COOKIE_ACCESS);
128
+ expect(processDataInstance.processEventData(e.type, e, '', el)).toEqual(
129
+ {
130
+ type: e.type,
131
+ },
132
+ );
133
+ expect(base.notifyAuthFailure).toBeCalledWith(
134
+ auth.AuthFailureType.NO_COOKIE_ACCESS,
135
+ );
111
136
  expect(window.alert).not.toBeCalled();
112
137
  expect(el.innerHTML).toBe('Hello');
113
138
  });
@@ -119,10 +144,14 @@ describe('Unit test for process data', () => {
119
144
  loginFailedMessage: 'Hello',
120
145
  });
121
146
  const el: any = {};
122
- expect(processDataInstance.processEventData(e.type, e, '', el)).toEqual({
123
- type: e.type,
124
- });
125
- expect(base.notifyAuthFailure).toBeCalledWith(auth.AuthFailureType.OTHER);
147
+ expect(processDataInstance.processEventData(e.type, e, '', el)).toEqual(
148
+ {
149
+ type: e.type,
150
+ },
151
+ );
152
+ expect(base.notifyAuthFailure).toBeCalledWith(
153
+ auth.AuthFailureType.OTHER,
154
+ );
126
155
  expect(el.innerHTML).toBe('Hello');
127
156
  });
128
157
 
@@ -134,9 +163,11 @@ describe('Unit test for process data', () => {
134
163
  authType: AuthType.None,
135
164
  });
136
165
  const el: any = {};
137
- expect(processDataInstance.processEventData(e.type, e, '', el)).toEqual({
138
- type: e.type,
139
- });
166
+ expect(processDataInstance.processEventData(e.type, e, '', el)).toEqual(
167
+ {
168
+ type: e.type,
169
+ },
170
+ );
140
171
  expect(base.notifyAuthFailure).not.toBeCalled();
141
172
  expect(el.innerHTML).not.toBe('Hello');
142
173
  });
@@ -152,9 +183,11 @@ describe('Unit test for process data', () => {
152
183
  const e = { type: EmbedEvent.AuthLogout };
153
184
  jest.spyOn(base, 'notifyLogout');
154
185
  const el: any = {};
155
- expect(processDataInstance.processEventData(e.type, e, '', el)).toEqual({
156
- type: e.type,
157
- });
186
+ expect(processDataInstance.processEventData(e.type, e, '', el)).toEqual(
187
+ {
188
+ type: e.type,
189
+ },
190
+ );
158
191
  expect(base.notifyLogout).toBeCalled();
159
192
  expect(el.innerHTML).toBe('Hello');
160
193
  expect(base.getEmbedConfig().autoLogin).toBe(false);
@@ -9,19 +9,20 @@ import { AuthFailureType, initSession } from '../auth';
9
9
  import { AuthType, EmbedEvent, OperationType } from '../types';
10
10
  import { getAnswerServiceInstance } from './answerService';
11
11
 
12
- /**
13
- *
14
- * @param e
15
- * @param thoughtSpotHost
16
- */
17
12
  export function processCustomAction(e: any, thoughtSpotHost: string) {
18
13
  if (
19
- [OperationType.GetChartWithData, OperationType.GetTableWithHeadlineData].includes(
20
- e.data?.operation,
21
- )
14
+ [
15
+ OperationType.GetChartWithData,
16
+ OperationType.GetTableWithHeadlineData,
17
+ ].includes(e.data?.operation)
22
18
  ) {
23
19
  const { session, query, operation } = e.data;
24
- const answerService = getAnswerServiceInstance(session, query, operation, thoughtSpotHost);
20
+ const answerService = getAnswerServiceInstance(
21
+ session,
22
+ query,
23
+ operation,
24
+ thoughtSpotHost,
25
+ );
25
26
  return {
26
27
  ...e,
27
28
  answerService,
@@ -30,10 +31,6 @@ export function processCustomAction(e: any, thoughtSpotHost: string) {
30
31
  return e;
31
32
  }
32
33
 
33
- /**
34
- *
35
- * @param e
36
- */
37
34
  function processAuthInit(e: any) {
38
35
  // Store user session details sent by app.
39
36
  initSession(e.data);
@@ -48,13 +45,11 @@ function processAuthInit(e: any) {
48
45
  };
49
46
  }
50
47
 
51
- /**
52
- *
53
- * @param e
54
- * @param containerEl
55
- */
56
48
  function processNoCookieAccess(e: any, containerEl: Element) {
57
- const { loginFailedMessage, suppressNoCookieAccessAlert } = getEmbedConfig();
49
+ const {
50
+ loginFailedMessage,
51
+ suppressNoCookieAccessAlert,
52
+ } = getEmbedConfig();
58
53
  if (!suppressNoCookieAccessAlert) {
59
54
  // eslint-disable-next-line no-alert
60
55
  alert(
@@ -67,11 +62,6 @@ function processNoCookieAccess(e: any, containerEl: Element) {
67
62
  return e;
68
63
  }
69
64
 
70
- /**
71
- *
72
- * @param e
73
- * @param containerEl
74
- */
75
65
  function processAuthFailure(e: any, containerEl: Element) {
76
66
  const { loginFailedMessage, authType } = getEmbedConfig();
77
67
  if (authType !== AuthType.None) {
@@ -82,11 +72,6 @@ function processAuthFailure(e: any, containerEl: Element) {
82
72
  return e;
83
73
  }
84
74
 
85
- /**
86
- *
87
- * @param e
88
- * @param containerEl
89
- */
90
75
  function processAuthLogout(e: any, containerEl: Element) {
91
76
  const { loginFailedMessage } = getEmbedConfig();
92
77
  // eslint-disable-next-line no-param-reassign
@@ -96,13 +81,6 @@ function processAuthLogout(e: any, containerEl: Element) {
96
81
  return e;
97
82
  }
98
83
 
99
- /**
100
- *
101
- * @param type
102
- * @param e
103
- * @param thoughtSpotHost
104
- * @param containerEl
105
- */
106
84
  export function processEventData(
107
85
  type: EmbedEvent,
108
86
  e: any,
@@ -17,7 +17,12 @@ describe('Unit test for processTrigger', () => {
17
17
  const messageType = HostEvent.Reload;
18
18
  const thoughtSpotHost = 'http://localhost:3000';
19
19
  const data = {};
20
- _processTriggerInstance.processTrigger(iFrameElement, messageType, thoughtSpotHost, data);
20
+ _processTriggerInstance.processTrigger(
21
+ iFrameElement,
22
+ messageType,
23
+ thoughtSpotHost,
24
+ data,
25
+ );
21
26
  expect(divFrame.childNodes[0]).not.toBe(iFrameElement);
22
27
  });
23
28
 
@@ -3,8 +3,6 @@ import { HostEvent } from '../types';
3
3
 
4
4
  /**
5
5
  * Reloads the ThoughtSpot iframe.
6
- *
7
- * @param iFrame
8
6
  */
9
7
  function reload(iFrame: HTMLIFrameElement) {
10
8
  const oldFrame = iFrame.cloneNode();
@@ -15,13 +13,6 @@ function reload(iFrame: HTMLIFrameElement) {
15
13
 
16
14
  /**
17
15
  * Post Iframe message.
18
- *
19
- * @param iFrame
20
- * @param message
21
- * @param message.type
22
- * @param message.data
23
- * @param thoughtSpotHost
24
- * @param channel
25
16
  */
26
17
  function postIframeMessage(
27
18
  iFrame: HTMLIFrameElement,
@@ -29,18 +20,13 @@ function postIframeMessage(
29
20
  thoughtSpotHost: string,
30
21
  channel?: MessageChannel,
31
22
  ) {
32
- return iFrame.contentWindow.postMessage(message, thoughtSpotHost, [channel?.port2]);
23
+ return iFrame.contentWindow.postMessage(message, thoughtSpotHost, [
24
+ channel?.port2,
25
+ ]);
33
26
  }
34
27
 
35
28
  const TRIGGER_TIMEOUT = 30000;
36
29
 
37
- /**
38
- *
39
- * @param iFrame
40
- * @param messageType
41
- * @param thoughtSpotHost
42
- * @param data
43
- */
44
30
  export function processTrigger(
45
31
  iFrame: HTMLIFrameElement,
46
32
  messageType: HostEvent,
@@ -68,6 +54,11 @@ export function processTrigger(
68
54
  res(new Error(ERROR_MESSAGE.TRIGGER_TIMED_OUT));
69
55
  }, TRIGGER_TIMEOUT);
70
56
 
71
- return postIframeMessage(iFrame, { type: messageType, data }, thoughtSpotHost, channel);
57
+ return postIframeMessage(
58
+ iFrame,
59
+ { type: messageType, data },
60
+ thoughtSpotHost,
61
+ channel,
62
+ );
72
63
  });
73
64
  }
package/src/utils.spec.ts CHANGED
@@ -77,7 +77,9 @@ describe('unit test for utils', () => {
77
77
  expect(appendToUrlHash('http://myhost:3000', 'hashFrag')).toBe(
78
78
  'http://myhost:3000#hashFrag',
79
79
  );
80
- expect(appendToUrlHash('http://xyz.com/#foo', 'bar')).toBe('http://xyz.com/#foobar');
80
+ expect(appendToUrlHash('http://xyz.com/#foo', 'bar')).toBe(
81
+ 'http://xyz.com/#foobar',
82
+ );
81
83
  });
82
84
 
83
85
  describe('getRedirectURL', () => {
@@ -85,7 +87,9 @@ describe('unit test for utils', () => {
85
87
  expect(getRedirectUrl('http://myhost:3000', 'hashFrag')).toBe(
86
88
  'http://myhost:3000#hashFrag',
87
89
  );
88
- expect(getRedirectUrl('http://xyz.com/#foo', 'bar')).toBe('http://xyz.com/#foobar');
90
+ expect(getRedirectUrl('http://xyz.com/#foo', 'bar')).toBe(
91
+ 'http://xyz.com/#foobar',
92
+ );
89
93
  });
90
94
 
91
95
  test('Should return correct value when path is set', () => {
@@ -93,13 +97,13 @@ describe('unit test for utils', () => {
93
97
  get: () => 'http://myhost:3000',
94
98
  });
95
99
 
96
- expect(getRedirectUrl('http://myhost:3000/', 'hashFrag', '/bar')).toBe(
97
- 'http://myhost:3000/bar#hashFrag',
98
- );
100
+ expect(
101
+ getRedirectUrl('http://myhost:3000/', 'hashFrag', '/bar'),
102
+ ).toBe('http://myhost:3000/bar#hashFrag');
99
103
 
100
- expect(getRedirectUrl('http://myhost:3000/#/foo', 'hashFrag', '#/bar')).toBe(
101
- 'http://myhost:3000/#/barhashFrag',
102
- );
104
+ expect(
105
+ getRedirectUrl('http://myhost:3000/#/foo', 'hashFrag', '#/bar'),
106
+ ).toBe('http://myhost:3000/#/barhashFrag');
103
107
  });
104
108
  });
105
109