@thoughtspot/visual-embed-sdk 1.35.5-hostEvent.1 → 1.35.5-hostEvent.3

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 (52) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/embed/hostEventClient/contracts.d.ts +6 -22
  3. package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  4. package/cjs/src/embed/hostEventClient/contracts.js +0 -2
  5. package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
  6. package/cjs/src/embed/hostEventClient/host-event-client.d.ts +3 -6
  7. package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  8. package/cjs/src/embed/hostEventClient/host-event-client.js +22 -22
  9. package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
  10. package/cjs/src/embed/ts-embed.d.ts +3 -3
  11. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  12. package/cjs/src/embed/ts-embed.js +11 -11
  13. package/cjs/src/embed/ts-embed.js.map +1 -1
  14. package/cjs/src/types.d.ts +1 -1
  15. package/cjs/src/types.js +1 -1
  16. package/dist/index-CENLvayL.js +7370 -0
  17. package/dist/index-DFwi_pV_.js +7370 -0
  18. package/dist/src/embed/hostEventClient/contracts.d.ts +6 -22
  19. package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  20. package/dist/src/embed/hostEventClient/host-event-client.d.ts +3 -6
  21. package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  22. package/dist/src/embed/ts-embed.d.ts +3 -3
  23. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  24. package/dist/src/types.d.ts +1 -1
  25. package/dist/tsembed-react.es.js +37 -39
  26. package/dist/tsembed-react.js +36 -38
  27. package/dist/tsembed.es.js +37 -39
  28. package/dist/tsembed.js +36 -38
  29. package/dist/visual-embed-sdk-react-full.d.ts +10 -29
  30. package/dist/visual-embed-sdk-react.d.ts +10 -29
  31. package/dist/visual-embed-sdk.d.ts +10 -29
  32. package/lib/package.json +1 -1
  33. package/lib/src/embed/hostEventClient/contracts.d.ts +6 -22
  34. package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  35. package/lib/src/embed/hostEventClient/contracts.js +0 -2
  36. package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
  37. package/lib/src/embed/hostEventClient/host-event-client.d.ts +3 -6
  38. package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  39. package/lib/src/embed/hostEventClient/host-event-client.js +22 -22
  40. package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
  41. package/lib/src/embed/ts-embed.d.ts +3 -3
  42. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  43. package/lib/src/embed/ts-embed.js +11 -11
  44. package/lib/src/embed/ts-embed.js.map +1 -1
  45. package/lib/src/types.d.ts +1 -1
  46. package/lib/src/types.js +1 -1
  47. package/lib/src/visual-embed-sdk.d.ts +13 -32
  48. package/package.json +1 -1
  49. package/src/embed/hostEventClient/contracts.ts +4 -20
  50. package/src/embed/hostEventClient/host-event-client.ts +31 -34
  51. package/src/embed/ts-embed.ts +13 -4
  52. package/src/types.ts +1 -1
@@ -4,20 +4,9 @@ import {
4
4
  UiPassthroughArrayResponse,
5
5
  UiPassthroughEvent, HostEventRequest, HostEventResponse,
6
6
  UiPassthroughRequest,
7
- FlattenType,
7
+ UiPassthroughResponse,
8
8
  } from './contracts';
9
9
 
10
- type UiPassthroughHandlerWithIframe = <UiPassthroughEventT extends UiPassthroughEvent>(
11
- iFrame: HTMLIFrameElement,
12
- apiName: UiPassthroughEventT,
13
- parameters: FlattenType<UiPassthroughRequest<UiPassthroughEventT>>,
14
- ) => UiPassthroughArrayResponse<UiPassthroughEventT>;
15
-
16
- export type UiPassthroughHandler = <UiPassthroughEventT extends UiPassthroughEvent>(
17
- apiName: UiPassthroughEventT,
18
- parameters: FlattenType<UiPassthroughRequest<UiPassthroughEventT>>,
19
- ) => UiPassthroughArrayResponse<UiPassthroughEventT>;
20
-
21
10
  export class HostEventClient {
22
11
  thoughtSpotHost: string;
23
12
 
@@ -25,7 +14,11 @@ export class HostEventClient {
25
14
  this.thoughtSpotHost = thoughtSpotHost;
26
15
  }
27
16
 
28
- executeUiPassthroughApi:UiPassthroughHandlerWithIframe = async (iFrame, apiName, parameters) => {
17
+ public async executeUiPassthroughApi<UiPassthroughEventT extends UiPassthroughEvent>(
18
+ iFrame: HTMLIFrameElement,
19
+ apiName: UiPassthroughEventT,
20
+ parameters: UiPassthroughRequest<UiPassthroughEventT>,
21
+ ): UiPassthroughArrayResponse<UiPassthroughEventT> {
29
22
  const res = await processTrigger(iFrame, HostEvent.UiPassthrough, this.thoughtSpotHost, {
30
23
  type: apiName,
31
24
  parameters,
@@ -34,36 +27,40 @@ export class HostEventClient {
34
27
  return res;
35
28
  }
36
29
 
37
- handleUiPassthroughForHostEvent:UiPassthroughHandlerWithIframe =
38
- async (iFrame, apiName, parameters) => {
39
- const response = (await this.executeUiPassthroughApi(iFrame, apiName, parameters))
40
- ?.filter?.((r) => r.error || r.value)[0];
30
+ public async handleUiPassthroughForHostEvent<UiPassthroughEventT extends UiPassthroughEvent>(
31
+ iFrame: HTMLIFrameElement,
32
+ apiName: UiPassthroughEventT,
33
+ parameters: UiPassthroughRequest<UiPassthroughEventT>,
34
+ ): Promise<UiPassthroughResponse<UiPassthroughEventT>> {
35
+ const response = (await this.executeUiPassthroughApi(iFrame, apiName, parameters))
36
+ ?.filter?.((r) => r.error || r.value)[0];
41
37
 
42
- if (!response) {
43
- const error = `No answer found${parameters.vizId ? ` for vizId: ${parameters.vizId}` : ''}.`;
44
- // eslint-disable-next-line no-throw-literal
45
- throw { error };
46
- }
38
+ if (!response) {
39
+ const error = `No answer found${parameters.vizId ? ` for vizId: ${parameters.vizId}` : ''}.`;
40
+ // eslint-disable-next-line no-throw-literal
41
+ throw { error };
42
+ }
47
43
 
48
- const errors = response.error || (response.value as any)?.errors;
49
- if (errors) {
50
- // eslint-disable-next-line no-throw-literal
51
- throw { error: response.error };
52
- }
44
+ const errors = response.error || (response.value as any)?.errors;
45
+ if (errors) {
46
+ // eslint-disable-next-line no-throw-literal
47
+ throw { error: response.error };
48
+ }
53
49
 
54
- return { ...response.value };
55
- }
50
+ return { ...response.value };
51
+ }
56
52
 
57
- async hostEventFallback(
53
+ public async hostEventFallback(
58
54
  iFrame: HTMLIFrameElement, hostEvent: HostEvent, data: any,
59
55
  ): Promise<any> {
60
56
  return processTrigger(iFrame, hostEvent, this.thoughtSpotHost, data);
61
57
  }
62
58
 
63
- async executeHostEvent<T extends HostEvent>(
64
- iFrame: HTMLIFrameElement, hostEvent: HostEvent, payload?: HostEventRequest<T>,
65
- ):
66
- Promise<HostEventResponse<HostEvent>> {
59
+ public async executeHostEvent<T extends HostEvent>(
60
+ iFrame: HTMLIFrameElement,
61
+ hostEvent: HostEvent,
62
+ payload?: HostEventRequest<T>,
63
+ ): Promise<HostEventResponse<HostEvent>> {
67
64
  if (hostEvent === HostEvent.Pin && payload?.newVizName) {
68
65
  return this.handleUiPassthroughForHostEvent(
69
66
  iFrame, UiPassthroughEvent.addVizToPinboard, payload,
@@ -9,7 +9,13 @@
9
9
  import isEqual from 'lodash/isEqual';
10
10
  import isEmpty from 'lodash/isEmpty';
11
11
  import isObject from 'lodash/isObject';
12
- import { HostEventRequest, HostEventResponse } from './hostEventClient/contracts';
12
+ import {
13
+ HostEventRequest,
14
+ HostEventResponse,
15
+ UiPassthroughArrayResponse,
16
+ UiPassthroughEvent,
17
+ UiPassthroughRequest,
18
+ } from './hostEventClient/contracts';
13
19
  import { logger } from '../utils/logger';
14
20
  import { getAuthenticationToken } from '../authToken';
15
21
  import { AnswerService } from '../utils/graphql/answerService/answerService';
@@ -63,7 +69,7 @@ import {
63
69
  import { AuthFailureType } from '../auth';
64
70
  import { getEmbedConfig } from './embedConfig';
65
71
  import { ERROR_MESSAGE } from '../errors';
66
- import { HostEventClient, UiPassthroughHandler } from './hostEventClient/host-event-client';
72
+ import { HostEventClient } from './hostEventClient/host-event-client';
67
73
 
68
74
  const { version } = pkgInfo;
69
75
 
@@ -1015,11 +1021,14 @@ export class TsEmbed {
1015
1021
  * Triggers an event to the embedded app, skipping the UI flow.
1016
1022
  * @param {UiPassthroughEvent} apiName - The name of the API to be triggered.
1017
1023
  * @param {UiPassthroughRequest} parameters - The parameters to be passed to the API.
1018
- * @returns {Promise<UiPassthroughRequest>} - A promise that resolves with the response
1024
+ * @returns {Promise<UiPassthroughRequest>} - A promise that resolves with the response
1019
1025
  * from the embedded app.
1020
1026
  */
1021
1027
  // eslint-disable-next-line arrow-body-style
1022
- public triggerUiPassThrough: UiPassthroughHandler = (apiName, parameters) => {
1028
+ public triggerUiPassThrough<UiPassthroughEventT extends UiPassthroughEvent>(
1029
+ apiName: UiPassthroughEventT,
1030
+ parameters: UiPassthroughRequest<UiPassthroughEventT>,
1031
+ ): UiPassthroughArrayResponse<UiPassthroughEventT> {
1023
1032
  return this.hostEventClient.executeUiPassthroughApi(this.iFrame, apiName, parameters);
1024
1033
  }
1025
1034
 
package/src/types.ts CHANGED
@@ -3201,7 +3201,7 @@ export enum HostEvent {
3201
3201
  UpdatePersonalisedView = 'UpdatePersonalisedView',
3202
3202
  /**
3203
3203
  * Triggers the action to get the current view of the liveboard
3204
- * @version SDK: 1.34.0 | Thoughtspot: 10.6.0.cl
3204
+ * @version SDK: 1.36.0 | Thoughtspot: 10.6.0.cl
3205
3205
  */
3206
3206
  SaveAnswer = 'saveAnswer',
3207
3207
  /**