@thoughtspot/visual-embed-sdk 1.35.3 → 1.35.5-hostEvent.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.
- package/cjs/package.json +1 -1
- package/cjs/src/auth.spec.js +12 -0
- package/cjs/src/auth.spec.js.map +1 -1
- package/cjs/src/authToken.spec.js +1 -1
- package/cjs/src/authToken.spec.js.map +1 -1
- package/cjs/src/embed/bodyless-conversation.spec.js +0 -1
- package/cjs/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.d.ts +97 -0
- package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -0
- package/cjs/src/embed/hostEventClient/contracts.js +16 -0
- package/cjs/src/embed/hostEventClient/contracts.js.map +1 -0
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts +14 -0
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -0
- package/cjs/src/embed/hostEventClient/host-event-client.js +50 -0
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -0
- package/cjs/src/embed/hostEventClient/host-event-client.spec.d.ts +2 -0
- package/cjs/src/embed/hostEventClient/host-event-client.spec.d.ts.map +1 -0
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +171 -0
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -0
- package/cjs/src/embed/liveboard.d.ts +2 -1
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +1 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +30 -0
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/search.spec.js +11 -0
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts +2 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts.map +1 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js +104 -0
- package/cjs/src/embed/searchEmbed-basic-auth.spec.js.map +1 -0
- package/cjs/src/embed/ts-embed.d.ts +13 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +16 -3
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +26 -1
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/hostEventsTypeMapping.d.ts +2 -0
- package/cjs/src/hostEventsTypeMapping.d.ts.map +1 -0
- package/cjs/src/hostEventsTypeMapping.js +4 -0
- package/cjs/src/hostEventsTypeMapping.js.map +1 -0
- package/cjs/src/index.d.ts +2 -1
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +3 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/react/all-types-export.d.ts +1 -1
- package/cjs/src/react/all-types-export.d.ts.map +1 -1
- package/cjs/src/react/all-types-export.js +2 -1
- package/cjs/src/react/all-types-export.js.map +1 -1
- package/cjs/src/types.d.ts +13 -3
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +12 -2
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/embedApi/contracts.d.ts +101 -0
- package/cjs/src/utils/embedApi/contracts.d.ts.map +1 -0
- package/cjs/src/utils/embedApi/contracts.js +17 -0
- package/cjs/src/utils/embedApi/contracts.js.map +1 -0
- package/cjs/src/utils/embedApi/embedApiClient.d.ts +12 -0
- package/cjs/src/utils/embedApi/embedApiClient.d.ts.map +1 -0
- package/cjs/src/utils/embedApi/embedApiClient.js +46 -0
- package/cjs/src/utils/embedApi/embedApiClient.js.map +1 -0
- package/cjs/src/utils/embedApi/processEmbedApi.d.ts +9 -0
- package/cjs/src/utils/embedApi/processEmbedApi.d.ts.map +1 -0
- package/cjs/src/utils/embedApi/processEmbedApi.js +18 -0
- package/cjs/src/utils/embedApi/processEmbedApi.js.map +1 -0
- package/dist/{index-BaGHDCpW.js → index-CbltIawo.js} +1 -1
- package/dist/index-CzwzS0P4.js +7370 -0
- package/dist/src/embed/hostEventClient/contracts.d.ts +97 -0
- package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -0
- package/dist/src/embed/hostEventClient/host-event-client.d.ts +14 -0
- package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -0
- package/dist/src/embed/hostEventClient/host-event-client.spec.d.ts +2 -0
- package/dist/src/embed/hostEventClient/host-event-client.spec.d.ts.map +1 -0
- package/dist/src/embed/liveboard.d.ts +2 -1
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts +2 -0
- package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts.map +1 -0
- package/dist/src/embed/ts-embed.d.ts +13 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/dist/src/hostEventsTypeMapping.d.ts +2 -0
- package/dist/src/hostEventsTypeMapping.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/react/all-types-export.d.ts +1 -1
- package/dist/src/react/all-types-export.d.ts.map +1 -1
- package/dist/src/types.d.ts +13 -3
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/embedApi/contracts.d.ts +101 -0
- package/dist/src/utils/embedApi/contracts.d.ts.map +1 -0
- package/dist/src/utils/embedApi/embedApiClient.d.ts +12 -0
- package/dist/src/utils/embedApi/embedApiClient.d.ts.map +1 -0
- package/dist/src/utils/embedApi/processEmbedApi.d.ts +9 -0
- package/dist/src/utils/embedApi/processEmbedApi.d.ts.map +1 -0
- package/dist/tsembed-react.es.js +86 -8
- package/dist/tsembed-react.js +85 -7
- package/dist/tsembed.es.js +87 -9
- package/dist/tsembed.js +85 -7
- package/dist/visual-embed-sdk-react-full.d.ts +134 -6
- package/dist/visual-embed-sdk-react.d.ts +134 -6
- package/dist/visual-embed-sdk.d.ts +134 -6
- package/lib/package.json +1 -1
- package/lib/src/auth.spec.js +12 -0
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/authToken.spec.js +1 -1
- package/lib/src/authToken.spec.js.map +1 -1
- package/lib/src/embed/bodyless-conversation.spec.js +0 -1
- package/lib/src/embed/bodyless-conversation.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.d.ts +97 -0
- package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -0
- package/lib/src/embed/hostEventClient/contracts.js +13 -0
- package/lib/src/embed/hostEventClient/contracts.js.map +1 -0
- package/lib/src/embed/hostEventClient/host-event-client.d.ts +14 -0
- package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -0
- package/lib/src/embed/hostEventClient/host-event-client.js +46 -0
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -0
- package/lib/src/embed/hostEventClient/host-event-client.spec.d.ts +2 -0
- package/lib/src/embed/hostEventClient/host-event-client.spec.d.ts.map +1 -0
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +169 -0
- package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -0
- package/lib/src/embed/liveboard.d.ts +2 -1
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +1 -1
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +30 -0
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/search.spec.js +11 -0
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts +2 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts.map +1 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.js +101 -0
- package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +1 -0
- package/lib/src/embed/ts-embed.d.ts +13 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +16 -3
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +28 -3
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/hostEventsTypeMapping.d.ts +2 -0
- package/lib/src/hostEventsTypeMapping.d.ts.map +1 -0
- package/lib/src/hostEventsTypeMapping.js +2 -0
- package/lib/src/hostEventsTypeMapping.js.map +1 -0
- package/lib/src/index.d.ts +2 -1
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -1
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/all-types-export.d.ts +1 -1
- package/lib/src/react/all-types-export.d.ts.map +1 -1
- package/lib/src/react/all-types-export.js +1 -1
- package/lib/src/react/all-types-export.js.map +1 -1
- package/lib/src/types.d.ts +13 -3
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +12 -2
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/embedApi/contracts.d.ts +101 -0
- package/lib/src/utils/embedApi/contracts.d.ts.map +1 -0
- package/lib/src/utils/embedApi/contracts.js +14 -0
- package/lib/src/utils/embedApi/contracts.js.map +1 -0
- package/lib/src/utils/embedApi/embedApiClient.d.ts +12 -0
- package/lib/src/utils/embedApi/embedApiClient.d.ts.map +1 -0
- package/lib/src/utils/embedApi/embedApiClient.js +42 -0
- package/lib/src/utils/embedApi/embedApiClient.js.map +1 -0
- package/lib/src/utils/embedApi/processEmbedApi.d.ts +9 -0
- package/lib/src/utils/embedApi/processEmbedApi.d.ts.map +1 -0
- package/lib/src/utils/embedApi/processEmbedApi.js +14 -0
- package/lib/src/utils/embedApi/processEmbedApi.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +145 -6
- package/package.json +1 -1
- package/src/auth.spec.ts +13 -0
- package/src/authToken.spec.ts +1 -1
- package/src/embed/bodyless-conversation.spec.ts +0 -1
- package/src/embed/hostEventClient/contracts.ts +108 -0
- package/src/embed/hostEventClient/host-event-client.spec.ts +234 -0
- package/src/embed/hostEventClient/host-event-client.ts +81 -0
- package/src/embed/liveboard.spec.ts +32 -0
- package/src/embed/liveboard.ts +5 -1
- package/src/embed/search.spec.ts +15 -0
- package/src/embed/ts-embed.spec.ts +40 -1
- package/src/embed/ts-embed.ts +26 -5
- package/src/index.ts +2 -0
- package/src/react/all-types-export.ts +1 -0
- package/src/types.ts +12 -2
|
@@ -29,7 +29,8 @@ declare module '@thoughtspot/visual-embed-sdk' {
|
|
|
29
29
|
import { tokenizedFetch } from '@thoughtspot/visual-embed-sdk/tokenizedFetch';
|
|
30
30
|
import { getAnswerFromQuery } from '@thoughtspot/visual-embed-sdk/utils/graphql/nlsService/nls-answer-service';
|
|
31
31
|
import { createLiveboardWithAnswers } from '@thoughtspot/visual-embed-sdk/utils/liveboardService/liveboardService';
|
|
32
|
-
|
|
32
|
+
import { UiPassthroughEvent } from '@thoughtspot/visual-embed-sdk/embed/hostEventClient/contracts';
|
|
33
|
+
export { init, logout, prefetch, executeTML, exportTML, executeTMLInput, exportTMLInput, getEmbedConfig as getInitConfig, getSessionInfo, tokenizedFetch, getAnswerFromQuery, createLiveboardWithAnswers, SearchEmbed, SearchBarEmbed, PinboardEmbed, LiveboardEmbed, SageEmbed, AppEmbed, BodylessConversation, BodylessConversationViewConfig, ConversationEmbed, ConversationViewConfig, AuthFailureType, AuthStatus, AuthEvent, AuthEventEmitter, AnswerService, SessionInterface, UnderlyingDataPoint, Page, AuthType, RuntimeFilter, RuntimeFilterOp, EmbedEvent, HostEvent, DataSourceVisualMode, Action, ContextMenuTriggerOptions, EmbedConfig, SearchViewConfig, SearchBarViewConfig, LiveboardViewConfig, SageViewConfig, AppViewConfig, PrefetchFeatures, FrameParams, HomeLeftNavItem, HomepageModule, DOMSelector, MessageOptions, MessageCallback, MessagePayload, CustomisationsInterface, CustomStyles, customCssInterface, CustomCssVariables, RuntimeParameter, LogLevel, uploadMixpanelEvent, MIXPANEL_EVENT, HomePageSearchBarMode, VizPoint, CustomActionPayload, UiPassthroughEvent, };
|
|
33
34
|
export { resetCachedAuthToken } from '@thoughtspot/visual-embed-sdk/authToken';
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -679,6 +680,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
679
680
|
*/
|
|
680
681
|
import { DOMSelector, HostEvent, ViewConfig } from '@thoughtspot/visual-embed-sdk/types';
|
|
681
682
|
import { V1Embed } from '@thoughtspot/visual-embed-sdk/embed/ts-embed';
|
|
683
|
+
import { HostEventRequest, HostEventResponse } from '@thoughtspot/visual-embed-sdk/embed/hostEventClient/contracts';
|
|
682
684
|
/**
|
|
683
685
|
* The configuration for the embedded Liveboard or visualization page view.
|
|
684
686
|
* @group Embed components
|
|
@@ -1056,7 +1058,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/liveboard' {
|
|
|
1056
1058
|
* @param messageType The event type
|
|
1057
1059
|
* @param data The payload to send with the message
|
|
1058
1060
|
*/
|
|
1059
|
-
trigger(messageType:
|
|
1061
|
+
trigger<HostEventT extends HostEvent>(messageType: HostEventT, data?: HostEventRequest<HostEventT>): Promise<HostEventResponse<HostEventT>>;
|
|
1060
1062
|
/**
|
|
1061
1063
|
* Render an embedded ThoughtSpot Liveboard or visualization
|
|
1062
1064
|
* @param renderOptions An object specifying the Liveboard ID,
|
|
@@ -3466,8 +3468,8 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
3466
3468
|
*
|
|
3467
3469
|
* **Note**: This event is deprecated in v1.21.0.
|
|
3468
3470
|
* To fire an event when a download action is initiated on a chart or table,
|
|
3469
|
-
* use `EmbedEvent.DownloadAsPng`, `EmbedEvent.DownloadAsPDF`,
|
|
3470
|
-
* or `EmbedEvent.DownloadAsXLSX`
|
|
3471
|
+
* use `EmbedEvent.DownloadAsPng`, `EmbedEvent.DownloadAsPDF`,
|
|
3472
|
+
* `EmbedEvent.DownloadAsCSV`, or `EmbedEvent.DownloadAsXLSX`
|
|
3471
3473
|
* @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1.sw
|
|
3472
3474
|
* @example
|
|
3473
3475
|
*```js
|
|
@@ -4948,7 +4950,17 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
4948
4950
|
* ```
|
|
4949
4951
|
* @version SDK: 1.36.0 | Thoughtspot: 10.6.0.cl
|
|
4950
4952
|
*/
|
|
4951
|
-
UpdatePersonalisedView = "UpdatePersonalisedView"
|
|
4953
|
+
UpdatePersonalisedView = "UpdatePersonalisedView",
|
|
4954
|
+
/**
|
|
4955
|
+
* Triggers the action to get the current view of the liveboard
|
|
4956
|
+
* @version SDK: 1.34.0 | Thoughtspot: 10.6.0.cl
|
|
4957
|
+
*/
|
|
4958
|
+
SaveAnswer = "saveAnswer",
|
|
4959
|
+
/**
|
|
4960
|
+
* EmbedApi
|
|
4961
|
+
* @hidden
|
|
4962
|
+
*/
|
|
4963
|
+
UiPassthrough = "UiPassthrough"
|
|
4952
4964
|
}
|
|
4953
4965
|
/**
|
|
4954
4966
|
* The different visual modes that the data sources panel within
|
|
@@ -7131,6 +7143,105 @@ declare module '@thoughtspot/visual-embed-sdk/utils/liveboardService/liveboardSe
|
|
|
7131
7143
|
export const createLiveboardWithAnswers: (answers: AnswerService[], name: string) => Promise<any>;
|
|
7132
7144
|
}
|
|
7133
7145
|
|
|
7146
|
+
declare module '@thoughtspot/visual-embed-sdk/embed/hostEventClient/contracts' {
|
|
7147
|
+
import { HostEvent } from '@thoughtspot/visual-embed-sdk/types';
|
|
7148
|
+
export enum UiPassthroughEvent {
|
|
7149
|
+
addVizToPinboard = "addVizToPinboard",
|
|
7150
|
+
saveAnswer = "saveAnswer",
|
|
7151
|
+
getA3AnalysisColumns = "getA3AnalysisColumns",
|
|
7152
|
+
getDiscoverabilityStatus = "getDiscoverabilityStatus",
|
|
7153
|
+
getAvailableUiPassthroughs = "getAvailableUiPassthroughs",
|
|
7154
|
+
getAnswerPageConfig = "getAnswerPageConfig",
|
|
7155
|
+
getPinboardPageConfig = "getPinboardPageConfig",
|
|
7156
|
+
UiPassthroughEventNotFound = "UiPassthroughEventNotFound"
|
|
7157
|
+
}
|
|
7158
|
+
export type UiPassthroughContractBase = {
|
|
7159
|
+
[UiPassthroughEvent.addVizToPinboard]: {
|
|
7160
|
+
request: {
|
|
7161
|
+
vizId?: string;
|
|
7162
|
+
newVizName: string;
|
|
7163
|
+
newVizDescription?: string;
|
|
7164
|
+
pinboardId?: string;
|
|
7165
|
+
tabId?: string;
|
|
7166
|
+
newPinboardName?: string;
|
|
7167
|
+
newTabName?: string;
|
|
7168
|
+
};
|
|
7169
|
+
response: {
|
|
7170
|
+
pinboardId: string;
|
|
7171
|
+
tabId: string;
|
|
7172
|
+
vizId: string;
|
|
7173
|
+
};
|
|
7174
|
+
};
|
|
7175
|
+
[UiPassthroughEvent.saveAnswer]: {
|
|
7176
|
+
request: {
|
|
7177
|
+
name: string;
|
|
7178
|
+
description: string;
|
|
7179
|
+
vizId: string;
|
|
7180
|
+
isDiscoverable?: boolean;
|
|
7181
|
+
};
|
|
7182
|
+
response: {
|
|
7183
|
+
answerId: string;
|
|
7184
|
+
errors?: any;
|
|
7185
|
+
};
|
|
7186
|
+
};
|
|
7187
|
+
[UiPassthroughEvent.getA3AnalysisColumns]: {
|
|
7188
|
+
request: {
|
|
7189
|
+
vizId?: string;
|
|
7190
|
+
};
|
|
7191
|
+
response: {
|
|
7192
|
+
data?: any;
|
|
7193
|
+
errors?: any;
|
|
7194
|
+
};
|
|
7195
|
+
};
|
|
7196
|
+
[UiPassthroughEvent.getDiscoverabilityStatus]: {
|
|
7197
|
+
request: any;
|
|
7198
|
+
response: {
|
|
7199
|
+
shouldShowDiscoverability: boolean;
|
|
7200
|
+
isDiscoverabilityCheckboxUnselectedPerOrg: boolean;
|
|
7201
|
+
};
|
|
7202
|
+
};
|
|
7203
|
+
[UiPassthroughEvent.getAvailableUiPassthroughs]: {
|
|
7204
|
+
request: any;
|
|
7205
|
+
response: {
|
|
7206
|
+
keys: string[];
|
|
7207
|
+
};
|
|
7208
|
+
};
|
|
7209
|
+
[UiPassthroughEvent.getAnswerPageConfig]: {
|
|
7210
|
+
request: {
|
|
7211
|
+
vizId?: string;
|
|
7212
|
+
};
|
|
7213
|
+
response: any;
|
|
7214
|
+
};
|
|
7215
|
+
[UiPassthroughEvent.getPinboardPageConfig]: {
|
|
7216
|
+
request: any;
|
|
7217
|
+
response: any;
|
|
7218
|
+
};
|
|
7219
|
+
[UiPassthroughEvent.UiPassthroughEventNotFound]: {
|
|
7220
|
+
request: any;
|
|
7221
|
+
response: any;
|
|
7222
|
+
};
|
|
7223
|
+
};
|
|
7224
|
+
export type UiPassthroughRequest<T extends keyof UiPassthroughContractBase> = UiPassthroughContractBase[T]['request'];
|
|
7225
|
+
export type UiPassthroughResponse<T extends keyof UiPassthroughContractBase> = UiPassthroughContractBase[T]['response'];
|
|
7226
|
+
export type UiPassthroughArrayResponse<ApiName extends keyof UiPassthroughContractBase> = Promise<Array<{
|
|
7227
|
+
redId?: string;
|
|
7228
|
+
value?: UiPassthroughResponse<ApiName>;
|
|
7229
|
+
error?: any;
|
|
7230
|
+
}>>;
|
|
7231
|
+
export type EmbedApiHostEventMapping = {
|
|
7232
|
+
[HostEvent.Pin]: UiPassthroughEvent.addVizToPinboard;
|
|
7233
|
+
[HostEvent.SaveAnswer]: UiPassthroughEvent.saveAnswer;
|
|
7234
|
+
'hostEventNotMapped': UiPassthroughEvent.UiPassthroughEventNotFound;
|
|
7235
|
+
};
|
|
7236
|
+
export type FlattenType<T> = T extends infer R ? {
|
|
7237
|
+
[K in keyof R]: R[K];
|
|
7238
|
+
} : never;
|
|
7239
|
+
export type HostEventRequest<HostEventT extends HostEvent> = HostEventT extends keyof EmbedApiHostEventMapping ? FlattenType<UiPassthroughRequest<EmbedApiHostEventMapping[HostEventT]>> : any;
|
|
7240
|
+
export type HostEventResponse<HostEventT extends HostEvent> = HostEventT extends keyof EmbedApiHostEventMapping ? {
|
|
7241
|
+
value?: UiPassthroughResponse<EmbedApiHostEventMapping[HostEventT]>;
|
|
7242
|
+
} : any;
|
|
7243
|
+
}
|
|
7244
|
+
|
|
7134
7245
|
declare module '@thoughtspot/visual-embed-sdk/authToken' {
|
|
7135
7246
|
import { EmbedConfig } from '@thoughtspot/visual-embed-sdk/types';
|
|
7136
7247
|
/**
|
|
@@ -7158,8 +7269,10 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
7158
7269
|
* @summary Base classes
|
|
7159
7270
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
7160
7271
|
*/
|
|
7272
|
+
import { HostEventRequest, HostEventResponse } from '@thoughtspot/visual-embed-sdk/embed/hostEventClient/contracts';
|
|
7161
7273
|
import { AnswerService } from '@thoughtspot/visual-embed-sdk/utils/graphql/answerService/answerService';
|
|
7162
7274
|
import { DOMSelector, HostEvent, EmbedEvent, MessageCallback, EmbedConfig, MessageOptions, ViewConfig } from '@thoughtspot/visual-embed-sdk/types';
|
|
7275
|
+
import { HostEventClient, UiPassthroughHandler } from '@thoughtspot/visual-embed-sdk/embed/hostEventClient/host-event-client';
|
|
7163
7276
|
/**
|
|
7164
7277
|
* Global prefix for all Thoughtspot postHash Params.
|
|
7165
7278
|
*/
|
|
@@ -7202,6 +7315,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
7202
7315
|
* A flag that is set to true post render.
|
|
7203
7316
|
*/
|
|
7204
7317
|
protected isRendered: boolean;
|
|
7318
|
+
protected hostEventClient: HostEventClient;
|
|
7205
7319
|
constructor(domSelector: DOMSelector, viewConfig?: ViewConfig);
|
|
7206
7320
|
/**
|
|
7207
7321
|
* Handles errors within the SDK
|
|
@@ -7323,8 +7437,17 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
7323
7437
|
* Triggers an event to the embedded app
|
|
7324
7438
|
* @param messageType The event type
|
|
7325
7439
|
* @param data The payload to send with the message
|
|
7440
|
+
* @returns A promise that resolves with the response from the embedded app
|
|
7441
|
+
*/
|
|
7442
|
+
trigger<HostEventT extends HostEvent>(messageType: HostEventT, data?: HostEventRequest<HostEventT>): Promise<HostEventResponse<HostEventT>>;
|
|
7443
|
+
/**
|
|
7444
|
+
* Triggers an event to the embedded app, skipping the UI flow.
|
|
7445
|
+
* @param {UiPassthroughEvent} apiName - The name of the API to be triggered.
|
|
7446
|
+
* @param {UiPassthroughRequest} parameters - The parameters to be passed to the API.
|
|
7447
|
+
* @returns {Promise<UiPassthroughRequest>} - A promise that resolves with the response
|
|
7448
|
+
* from the embedded app.
|
|
7326
7449
|
*/
|
|
7327
|
-
|
|
7450
|
+
triggerUiPassThrough: UiPassthroughHandler;
|
|
7328
7451
|
/**
|
|
7329
7452
|
* Marks the ThoughtSpot object to have been rendered
|
|
7330
7453
|
* Needs to be overridden by subclasses to do the actual
|
|
@@ -7444,3 +7567,19 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
7444
7567
|
}
|
|
7445
7568
|
}
|
|
7446
7569
|
|
|
7570
|
+
declare module '@thoughtspot/visual-embed-sdk/embed/hostEventClient/host-event-client' {
|
|
7571
|
+
import { HostEvent } from '@thoughtspot/visual-embed-sdk/types';
|
|
7572
|
+
import { UiPassthroughArrayResponse, UiPassthroughEvent, HostEventRequest, HostEventResponse, UiPassthroughRequest, FlattenType } from '@thoughtspot/visual-embed-sdk/embed/hostEventClient/contracts';
|
|
7573
|
+
type UiPassthroughHandlerWithIframe = <UiPassthroughEventT extends UiPassthroughEvent>(iFrame: HTMLIFrameElement, apiName: UiPassthroughEventT, parameters: FlattenType<UiPassthroughRequest<UiPassthroughEventT>>) => UiPassthroughArrayResponse<UiPassthroughEventT>;
|
|
7574
|
+
export type UiPassthroughHandler = <UiPassthroughEventT extends UiPassthroughEvent>(apiName: UiPassthroughEventT, parameters: FlattenType<UiPassthroughRequest<UiPassthroughEventT>>) => UiPassthroughArrayResponse<UiPassthroughEventT>;
|
|
7575
|
+
export class HostEventClient {
|
|
7576
|
+
thoughtSpotHost: string;
|
|
7577
|
+
constructor(thoughtSpotHost: string);
|
|
7578
|
+
executeUiPassthroughApi: UiPassthroughHandlerWithIframe;
|
|
7579
|
+
handleUiPassthroughForHostEvent: UiPassthroughHandlerWithIframe;
|
|
7580
|
+
hostEventFallback(iFrame: HTMLIFrameElement, hostEvent: HostEvent, data: any): Promise<any>;
|
|
7581
|
+
executeHostEvent<T extends HostEvent>(iFrame: HTMLIFrameElement, hostEvent: HostEvent, payload?: HostEventRequest<T>): Promise<HostEventResponse<HostEvent>>;
|
|
7582
|
+
}
|
|
7583
|
+
export {};
|
|
7584
|
+
}
|
|
7585
|
+
|
package/package.json
CHANGED
package/src/auth.spec.ts
CHANGED
|
@@ -125,6 +125,7 @@ describe('Unit test for auth', () => {
|
|
|
125
125
|
afterEach(() => {
|
|
126
126
|
authTokenService.resetCachedAuthToken();
|
|
127
127
|
SessionService.resetCachedSessionInfo();
|
|
128
|
+
jest.resetAllMocks();
|
|
128
129
|
});
|
|
129
130
|
test('endpoints, SAML_LOGIN_TEMPLATE', () => {
|
|
130
131
|
const ssoTemplateUrl = authService.EndPoints.SAML_LOGIN_TEMPLATE(thoughtSpotHost);
|
|
@@ -137,6 +138,8 @@ describe('Unit test for auth', () => {
|
|
|
137
138
|
expect(sessionInfo.mixpanelToken).toEqual('prodKey');
|
|
138
139
|
expect(sessionInfo.isPublicUser).toEqual(false);
|
|
139
140
|
await SessionService.getSessionInfo();
|
|
141
|
+
const cachedInfo = SessionService.getCachedSessionInfo();
|
|
142
|
+
expect(cachedInfo).toEqual(sessionInfo);
|
|
140
143
|
expect(tokenAuthService.fetchSessionInfoService).toHaveBeenCalledTimes(1);
|
|
141
144
|
});
|
|
142
145
|
|
|
@@ -148,6 +151,16 @@ describe('Unit test for auth', () => {
|
|
|
148
151
|
expect(mixPanelService.initMixpanel).not.toBeCalled();
|
|
149
152
|
});
|
|
150
153
|
|
|
154
|
+
test('Log error is postLogin faild', async () => {
|
|
155
|
+
jest.spyOn(mixPanelService, 'initMixpanel');
|
|
156
|
+
jest.spyOn(SessionService, 'getSessionInfo').mockRejectedValueOnce(mockSessionInfo);
|
|
157
|
+
jest.spyOn(EmbedConfig, 'getEmbedConfig').mockReturnValue({ disableSDKTracking: true });
|
|
158
|
+
jest.spyOn(logger, 'error').mockResolvedValue(true);
|
|
159
|
+
await authInstance.postLoginService();
|
|
160
|
+
expect(mixPanelService.initMixpanel).not.toBeCalled();
|
|
161
|
+
expect(logger.error).toBeCalled();
|
|
162
|
+
});
|
|
163
|
+
|
|
151
164
|
test('doCookielessTokenAuth: when authEndpoint and getAuthToken are not there, it throw error', async () => {
|
|
152
165
|
try {
|
|
153
166
|
await authInstance.doCookielessTokenAuth(
|
package/src/authToken.spec.ts
CHANGED
|
@@ -15,7 +15,7 @@ describe('AuthToken Unit tests', () => {
|
|
|
15
15
|
expect(authServiceInstance.verifyTokenService).not.toBeCalled();
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
test
|
|
18
|
+
test('getAuthenticationToken: When verification is enabled', async () => {
|
|
19
19
|
resetCachedAuthToken();
|
|
20
20
|
jest.clearAllMocks();
|
|
21
21
|
jest.spyOn(authServiceInstance, 'verifyTokenService').mockImplementation(() => true);
|
|
@@ -123,7 +123,6 @@ describe('BodylessConversation', () => {
|
|
|
123
123
|
|
|
124
124
|
const conversationEmbed = new BodylessConversation(viewConfig);
|
|
125
125
|
const result = await conversationEmbed.sendMessage('userMessage');
|
|
126
|
-
console.log(result.container);
|
|
127
126
|
const iframeSrc = getIFrameSrc(result.container);
|
|
128
127
|
expectUrlToHaveParamsWithValues(iframeSrc, {
|
|
129
128
|
sessionId: 'sessionId',
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { HostEvent } from '../../types';
|
|
2
|
+
|
|
3
|
+
export enum UiPassthroughEvent {
|
|
4
|
+
addVizToPinboard = 'addVizToPinboard',
|
|
5
|
+
saveAnswer = 'saveAnswer',
|
|
6
|
+
getA3AnalysisColumns = 'getA3AnalysisColumns',
|
|
7
|
+
getDiscoverabilityStatus = 'getDiscoverabilityStatus',
|
|
8
|
+
getAvailableUiPassthroughs = 'getAvailableUiPassthroughs',
|
|
9
|
+
getAnswerPageConfig = 'getAnswerPageConfig',
|
|
10
|
+
getPinboardPageConfig = 'getPinboardPageConfig',
|
|
11
|
+
UiPassthroughEventNotFound = 'UiPassthroughEventNotFound',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type UiPassthroughContractBase = {
|
|
15
|
+
[UiPassthroughEvent.addVizToPinboard]: {
|
|
16
|
+
request: {
|
|
17
|
+
vizId?: string;
|
|
18
|
+
newVizName: string;
|
|
19
|
+
newVizDescription?: string;
|
|
20
|
+
pinboardId?: string;
|
|
21
|
+
tabId?: string;
|
|
22
|
+
newPinboardName?: string;
|
|
23
|
+
newTabName?: string;
|
|
24
|
+
};
|
|
25
|
+
response: {
|
|
26
|
+
pinboardId: string;
|
|
27
|
+
tabId: string;
|
|
28
|
+
vizId: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
[UiPassthroughEvent.saveAnswer]: {
|
|
32
|
+
request: {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
vizId: string;
|
|
36
|
+
isDiscoverable?: boolean;
|
|
37
|
+
};
|
|
38
|
+
response: {
|
|
39
|
+
answerId: string,
|
|
40
|
+
errors?: any;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
[UiPassthroughEvent.getA3AnalysisColumns]: {
|
|
44
|
+
request: {
|
|
45
|
+
vizId?: string;
|
|
46
|
+
};
|
|
47
|
+
response: {
|
|
48
|
+
data?: any;
|
|
49
|
+
errors?: any;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
[UiPassthroughEvent.getDiscoverabilityStatus]: {
|
|
53
|
+
request: any;
|
|
54
|
+
response: {
|
|
55
|
+
shouldShowDiscoverability: boolean;
|
|
56
|
+
isDiscoverabilityCheckboxUnselectedPerOrg: boolean;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
[UiPassthroughEvent.getAvailableUiPassthroughs]: {
|
|
60
|
+
request: any;
|
|
61
|
+
response: {
|
|
62
|
+
keys: string[];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
[UiPassthroughEvent.getAnswerPageConfig]: {
|
|
66
|
+
request: {
|
|
67
|
+
vizId?: string;
|
|
68
|
+
};
|
|
69
|
+
response: any;
|
|
70
|
+
};
|
|
71
|
+
[UiPassthroughEvent.getPinboardPageConfig]: {
|
|
72
|
+
request: any;
|
|
73
|
+
response: any;
|
|
74
|
+
};
|
|
75
|
+
[UiPassthroughEvent.UiPassthroughEventNotFound]: {
|
|
76
|
+
request: any;
|
|
77
|
+
response: any;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type UiPassthroughRequest<T extends keyof UiPassthroughContractBase> = UiPassthroughContractBase[T]['request'];
|
|
82
|
+
export type UiPassthroughResponse<T extends keyof UiPassthroughContractBase> = UiPassthroughContractBase[T]['response'];
|
|
83
|
+
|
|
84
|
+
export type UiPassthroughArrayResponse<ApiName extends keyof UiPassthroughContractBase> =
|
|
85
|
+
Promise<Array<{
|
|
86
|
+
redId?: string;
|
|
87
|
+
value?: UiPassthroughResponse<ApiName>;
|
|
88
|
+
error?: any;
|
|
89
|
+
}>>
|
|
90
|
+
|
|
91
|
+
export type EmbedApiHostEventMapping = {
|
|
92
|
+
[HostEvent.Pin]: UiPassthroughEvent.addVizToPinboard;
|
|
93
|
+
[HostEvent.SaveAnswer]: UiPassthroughEvent.saveAnswer;
|
|
94
|
+
'hostEventNotMapped': UiPassthroughEvent.UiPassthroughEventNotFound;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type FlattenType<T> = T extends infer R ? { [K in keyof R]: R[K] } : never;
|
|
98
|
+
|
|
99
|
+
export type HostEventRequest<HostEventT extends HostEvent> =
|
|
100
|
+
HostEventT extends keyof EmbedApiHostEventMapping ?
|
|
101
|
+
FlattenType<UiPassthroughRequest<EmbedApiHostEventMapping[HostEventT]>> : any;
|
|
102
|
+
|
|
103
|
+
export type HostEventResponse<HostEventT extends HostEvent> =
|
|
104
|
+
HostEventT extends keyof EmbedApiHostEventMapping ?
|
|
105
|
+
{
|
|
106
|
+
value?: UiPassthroughResponse<EmbedApiHostEventMapping[HostEventT]>
|
|
107
|
+
}
|
|
108
|
+
: any;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { getIFrameEl } from '../../test/test-utils';
|
|
2
|
+
import { HostEvent } from '../../types';
|
|
3
|
+
import { processTrigger } from '../../utils/processTrigger';
|
|
4
|
+
import {
|
|
5
|
+
UiPassthroughEvent,
|
|
6
|
+
UiPassthroughRequest,
|
|
7
|
+
UiPassthroughArrayResponse,
|
|
8
|
+
HostEventRequest,
|
|
9
|
+
} from './contracts';
|
|
10
|
+
import { HostEventClient } from './host-event-client';
|
|
11
|
+
|
|
12
|
+
jest.mock('../../utils/processTrigger');
|
|
13
|
+
|
|
14
|
+
const mockProcessTrigger = processTrigger as jest.Mock;
|
|
15
|
+
|
|
16
|
+
const createHostEventClient = () => {
|
|
17
|
+
const mockIframe = getIFrameEl();
|
|
18
|
+
const mockThoughtSpotHost = 'http://localhost';
|
|
19
|
+
const client = new HostEventClient(mockThoughtSpotHost);
|
|
20
|
+
return { client, mockIframe, mockThoughtSpotHost };
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
describe('HostEventClient', () => {
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
jest.clearAllMocks();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('executeUiPassthroughApi', () => {
|
|
29
|
+
it('should call processTrigger with correct parameters and return response', async () => {
|
|
30
|
+
const { client, mockIframe, mockThoughtSpotHost } = createHostEventClient();
|
|
31
|
+
|
|
32
|
+
const apiName = UiPassthroughEvent.addVizToPinboard;
|
|
33
|
+
const parameters: UiPassthroughRequest<typeof apiName> = {
|
|
34
|
+
newVizName: 'testViz',
|
|
35
|
+
};
|
|
36
|
+
const triggerResponse = Promise.resolve([
|
|
37
|
+
{ value: { pinboardId: 'testPinboard', tabId: 'testTab', vizId: 'testVizId' } },
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
mockProcessTrigger.mockResolvedValue(triggerResponse);
|
|
41
|
+
|
|
42
|
+
const result = await client.executeUiPassthroughApi(getIFrameEl(), apiName, parameters);
|
|
43
|
+
|
|
44
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(
|
|
45
|
+
mockIframe,
|
|
46
|
+
HostEvent.UiPassthrough,
|
|
47
|
+
mockThoughtSpotHost,
|
|
48
|
+
{
|
|
49
|
+
type: apiName,
|
|
50
|
+
parameters,
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
expect(result).toEqual(await triggerResponse);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('handleUiPassthroughForHostEvent', () => {
|
|
58
|
+
it('should return the value from the first valid response', async () => {
|
|
59
|
+
const { client } = createHostEventClient();
|
|
60
|
+
const apiName = UiPassthroughEvent.addVizToPinboard;
|
|
61
|
+
const parameters: UiPassthroughRequest<typeof apiName> = {
|
|
62
|
+
newVizName: 'testViz',
|
|
63
|
+
};
|
|
64
|
+
const triggerResponse = Promise.resolve([
|
|
65
|
+
{ value: { pinboardId: 'testPinboard', tabId: 'testTab', vizId: 'testVizId' } },
|
|
66
|
+
]);
|
|
67
|
+
mockProcessTrigger.mockResolvedValue(triggerResponse);
|
|
68
|
+
|
|
69
|
+
const result = await client.handleUiPassthroughForHostEvent(getIFrameEl(),
|
|
70
|
+
apiName, parameters);
|
|
71
|
+
|
|
72
|
+
expect(result).toEqual({
|
|
73
|
+
pinboardId: 'testPinboard',
|
|
74
|
+
tabId: 'testTab',
|
|
75
|
+
vizId: 'testVizId',
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should throw an error if no valid response is found', async () => {
|
|
80
|
+
const { client } = createHostEventClient();
|
|
81
|
+
const apiName = UiPassthroughEvent.addVizToPinboard;
|
|
82
|
+
const parameters: UiPassthroughRequest<typeof apiName> = {
|
|
83
|
+
newVizName: 'testViz',
|
|
84
|
+
};
|
|
85
|
+
const triggerResponse: UiPassthroughArrayResponse<typeof apiName> = Promise.resolve([]);
|
|
86
|
+
mockProcessTrigger.mockResolvedValue(triggerResponse);
|
|
87
|
+
|
|
88
|
+
await expect(client.handleUiPassthroughForHostEvent(getIFrameEl(), apiName, parameters))
|
|
89
|
+
.rejects.toEqual({ error: 'No answer found.' });
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should throw an error if no valid response is found for vizId', async () => {
|
|
93
|
+
const { client } = createHostEventClient();
|
|
94
|
+
const apiName = UiPassthroughEvent.addVizToPinboard;
|
|
95
|
+
const parameters: UiPassthroughRequest<typeof apiName> = {
|
|
96
|
+
newVizName: 'testViz',
|
|
97
|
+
vizId: 'testVizId',
|
|
98
|
+
};
|
|
99
|
+
const triggerResponse: UiPassthroughArrayResponse<typeof apiName> = Promise.resolve([]);
|
|
100
|
+
mockProcessTrigger.mockResolvedValue(triggerResponse);
|
|
101
|
+
|
|
102
|
+
await expect(client.handleUiPassthroughForHostEvent(getIFrameEl(), apiName, parameters))
|
|
103
|
+
.rejects.toEqual({ error: 'No answer found for vizId: testVizId.' });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should throw an error if the response contains errors', async () => {
|
|
107
|
+
const { client } = createHostEventClient();
|
|
108
|
+
const apiName = UiPassthroughEvent.addVizToPinboard;
|
|
109
|
+
const parameters: UiPassthroughRequest<typeof apiName> = {
|
|
110
|
+
newVizName: 'testViz',
|
|
111
|
+
};
|
|
112
|
+
const triggerResponse: UiPassthroughArrayResponse<typeof apiName> = Promise.resolve([
|
|
113
|
+
{ error: 'Some error' },
|
|
114
|
+
]);
|
|
115
|
+
mockProcessTrigger.mockResolvedValue(triggerResponse);
|
|
116
|
+
|
|
117
|
+
await expect(client.handleUiPassthroughForHostEvent(getIFrameEl(), apiName, parameters))
|
|
118
|
+
.rejects.toEqual({ error: 'Some error' });
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe('executeHostEvent', () => {
|
|
123
|
+
it('should call handleUiPassthroughForHostEvent for Pin event', async () => {
|
|
124
|
+
const { client } = createHostEventClient();
|
|
125
|
+
const hostEvent = HostEvent.Pin;
|
|
126
|
+
const payload: HostEventRequest<typeof hostEvent> = {
|
|
127
|
+
newVizName: 'testViz',
|
|
128
|
+
};
|
|
129
|
+
const mockResponse = {
|
|
130
|
+
value: {
|
|
131
|
+
pinboardId: 'testPinboard',
|
|
132
|
+
tabId: 'testTab',
|
|
133
|
+
vizId: 'testVizId',
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
mockProcessTrigger.mockResolvedValue([mockResponse]);
|
|
138
|
+
|
|
139
|
+
const result = await client.executeHostEvent(getIFrameEl(), hostEvent, payload);
|
|
140
|
+
|
|
141
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(
|
|
142
|
+
getIFrameEl(),
|
|
143
|
+
HostEvent.UiPassthrough,
|
|
144
|
+
'http://localhost',
|
|
145
|
+
{ parameters: payload, type: UiPassthroughEvent.addVizToPinboard },
|
|
146
|
+
);
|
|
147
|
+
expect(result).toEqual(mockResponse.value);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should call handleUiPassthroughForHostEvent for SaveAnswer event', async () => {
|
|
151
|
+
const { client } = createHostEventClient();
|
|
152
|
+
const hostEvent = HostEvent.SaveAnswer;
|
|
153
|
+
const payload: HostEventRequest<typeof hostEvent> = {
|
|
154
|
+
name: 'Test Answer',
|
|
155
|
+
description: 'Test Description',
|
|
156
|
+
vizId: 'testVizId',
|
|
157
|
+
};
|
|
158
|
+
const mockResponse = { answerId: 'testAnswerId' };
|
|
159
|
+
jest.spyOn(client, 'handleUiPassthroughForHostEvent').mockResolvedValue(mockResponse);
|
|
160
|
+
|
|
161
|
+
const result = await client.executeHostEvent(getIFrameEl(), hostEvent, payload);
|
|
162
|
+
|
|
163
|
+
expect(client.handleUiPassthroughForHostEvent).toHaveBeenCalledWith(
|
|
164
|
+
null,
|
|
165
|
+
UiPassthroughEvent.saveAnswer,
|
|
166
|
+
payload,
|
|
167
|
+
);
|
|
168
|
+
expect(result).toEqual(mockResponse);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('should call hostEventFallback for unmapped events', async () => {
|
|
172
|
+
const { client } = createHostEventClient();
|
|
173
|
+
const hostEvent = 'testEvent' as HostEvent;
|
|
174
|
+
const payload = { data: 'testData' };
|
|
175
|
+
const mockResponse = { fallbackResponse: 'data' };
|
|
176
|
+
jest.spyOn(client, 'hostEventFallback').mockResolvedValue(mockResponse);
|
|
177
|
+
|
|
178
|
+
const result = await client.executeHostEvent(getIFrameEl(), hostEvent, payload);
|
|
179
|
+
|
|
180
|
+
expect(client.hostEventFallback).toHaveBeenCalledWith(null, hostEvent, payload);
|
|
181
|
+
expect(result).toEqual(mockResponse);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('should call fallback for Pin event', async () => {
|
|
185
|
+
const { client } = createHostEventClient();
|
|
186
|
+
const hostEvent = HostEvent.Pin;
|
|
187
|
+
const payload: HostEventRequest<typeof hostEvent> = {} as any;
|
|
188
|
+
const mockResponse = {
|
|
189
|
+
value: {
|
|
190
|
+
pinboardId: 'testPinboard',
|
|
191
|
+
tabId: 'testTab',
|
|
192
|
+
vizId: 'testVizId',
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
mockProcessTrigger.mockResolvedValue([mockResponse]);
|
|
197
|
+
|
|
198
|
+
const result = await client.executeHostEvent(getIFrameEl(), hostEvent, payload);
|
|
199
|
+
|
|
200
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(
|
|
201
|
+
getIFrameEl(),
|
|
202
|
+
HostEvent.Pin,
|
|
203
|
+
'http://localhost',
|
|
204
|
+
{},
|
|
205
|
+
);
|
|
206
|
+
expect(result).toEqual([mockResponse]);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('should call fallback for SaveAnswer event', async () => {
|
|
210
|
+
const { client } = createHostEventClient();
|
|
211
|
+
const hostEvent = HostEvent.SaveAnswer;
|
|
212
|
+
const payload: HostEventRequest<typeof hostEvent> = {} as any;
|
|
213
|
+
const mockResponse = {
|
|
214
|
+
value: {
|
|
215
|
+
pinboardId: 'testPinboard',
|
|
216
|
+
tabId: 'testTab',
|
|
217
|
+
vizId: 'testVizId',
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
mockProcessTrigger.mockResolvedValue([mockResponse]);
|
|
222
|
+
|
|
223
|
+
const result = await client.executeHostEvent(getIFrameEl(), hostEvent, payload);
|
|
224
|
+
|
|
225
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(
|
|
226
|
+
getIFrameEl(),
|
|
227
|
+
HostEvent.Save,
|
|
228
|
+
'http://localhost',
|
|
229
|
+
{},
|
|
230
|
+
);
|
|
231
|
+
expect(result).toEqual([mockResponse]);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
});
|