@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.
- package/cjs/package.json +1 -1
- package/cjs/src/embed/hostEventClient/contracts.d.ts +6 -22
- package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.js +0 -2
- package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts +3 -6
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.js +22 -22
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +3 -3
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +11 -11
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/types.d.ts +1 -1
- package/cjs/src/types.js +1 -1
- package/dist/index-CENLvayL.js +7370 -0
- package/dist/index-DFwi_pV_.js +7370 -0
- package/dist/src/embed/hostEventClient/contracts.d.ts +6 -22
- package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/host-event-client.d.ts +3 -6
- package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +3 -3
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/tsembed-react.es.js +37 -39
- package/dist/tsembed-react.js +36 -38
- package/dist/tsembed.es.js +37 -39
- package/dist/tsembed.js +36 -38
- package/dist/visual-embed-sdk-react-full.d.ts +10 -29
- package/dist/visual-embed-sdk-react.d.ts +10 -29
- package/dist/visual-embed-sdk.d.ts +10 -29
- package/lib/package.json +1 -1
- package/lib/src/embed/hostEventClient/contracts.d.ts +6 -22
- package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.js +0 -2
- package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts +3 -6
- package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.js +22 -22
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +3 -3
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +11 -11
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/types.d.ts +1 -1
- package/lib/src/types.js +1 -1
- package/lib/src/visual-embed-sdk.d.ts +13 -32
- package/package.json +1 -1
- package/src/embed/hostEventClient/contracts.ts +4 -20
- package/src/embed/hostEventClient/host-event-client.ts +31 -34
- package/src/embed/ts-embed.ts +13 -4
- package/src/types.ts +1 -1
|
@@ -4,20 +4,9 @@ import {
|
|
|
4
4
|
UiPassthroughArrayResponse,
|
|
5
5
|
UiPassthroughEvent, HostEventRequest, HostEventResponse,
|
|
6
6
|
UiPassthroughRequest,
|
|
7
|
-
|
|
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
|
-
|
|
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
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
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,
|
|
65
|
-
|
|
66
|
-
|
|
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,
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -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 {
|
|
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
|
|
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
|
|
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.
|
|
3204
|
+
* @version SDK: 1.36.0 | Thoughtspot: 10.6.0.cl
|
|
3205
3205
|
*/
|
|
3206
3206
|
SaveAnswer = 'saveAnswer',
|
|
3207
3207
|
/**
|