@thoughtspot/visual-embed-sdk 1.44.2 → 1.44.4-HE-beta.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/README.md +1 -1
- package/cjs/package.json +1 -1
- package/cjs/src/embed/app.d.ts +44 -32
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/base.d.ts +1 -1
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +4 -0
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +60 -0
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/conversation.d.ts +7 -0
- package/cjs/src/embed/conversation.d.ts.map +1 -1
- package/cjs/src/embed/conversation.js +9 -0
- package/cjs/src/embed/conversation.js.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.d.ts +20 -3
- package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/contracts.js +6 -1
- package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts +8 -8
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.js +18 -18
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +7 -7
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +10 -4
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +12 -2
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +1 -1
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/sage.d.ts +7 -0
- package/cjs/src/embed/sage.d.ts.map +1 -1
- package/cjs/src/embed/sage.js +9 -0
- package/cjs/src/embed/sage.js.map +1 -1
- package/cjs/src/embed/search-bar.d.ts +7 -0
- package/cjs/src/embed/search-bar.d.ts.map +1 -1
- package/cjs/src/embed/search-bar.js +9 -0
- package/cjs/src/embed/search-bar.js.map +1 -1
- package/cjs/src/embed/search.d.ts +7 -0
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +9 -0
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +9 -3
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +41 -8
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +156 -24
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/errors.d.ts +2 -0
- package/cjs/src/errors.d.ts.map +1 -1
- package/cjs/src/errors.js +2 -0
- package/cjs/src/errors.js.map +1 -1
- package/cjs/src/index.d.ts +2 -2
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +5 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/types.d.ts +142 -45
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +91 -16
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/logger.spec.d.ts +20 -5
- package/cjs/src/utils/logger.spec.d.ts.map +1 -1
- package/cjs/src/utils/processTrigger.d.ts +3 -2
- package/cjs/src/utils/processTrigger.d.ts.map +1 -1
- package/cjs/src/utils/processTrigger.js +4 -2
- package/cjs/src/utils/processTrigger.js.map +1 -1
- package/cjs/src/utils.d.ts +15 -4
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +38 -6
- package/cjs/src/utils.js.map +1 -1
- package/cjs/src/utils.spec.js +53 -0
- package/cjs/src/utils.spec.js.map +1 -1
- package/dist/index-BFdRRz03.js +7371 -0
- package/dist/index-BUfrYJ3w.js +7371 -0
- package/dist/index-CI6s4VMY.js +7371 -0
- package/dist/{index-CSFjfTVk.js → index-CWQnMX2L.js} +1 -1
- package/dist/index-CaW-1mu5.js +7371 -0
- package/dist/index-CcSgNJVi.js +7371 -0
- package/dist/index-Djtv-y7A.js +7371 -0
- package/dist/index-UY-4yjBN.js +7371 -0
- package/dist/src/embed/app.d.ts +44 -32
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +1 -1
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/conversation.d.ts +7 -0
- package/dist/src/embed/conversation.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/contracts.d.ts +20 -3
- package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/host-event-client.d.ts +8 -8
- package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +10 -4
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/sage.d.ts +7 -0
- package/dist/src/embed/sage.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts +7 -0
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +7 -0
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +9 -3
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/errors.d.ts +2 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +142 -45
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/logger.spec.d.ts +20 -5
- package/dist/src/utils/logger.spec.d.ts.map +1 -1
- package/dist/src/utils/processTrigger.d.ts +3 -2
- package/dist/src/utils/processTrigger.d.ts.map +1 -1
- package/dist/src/utils.d.ts +15 -4
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +288 -95
- package/dist/tsembed-react.js +287 -94
- package/dist/tsembed.es.js +289 -96
- package/dist/tsembed.js +314 -121
- package/dist/visual-embed-sdk-react-full.d.ts +246 -83
- package/dist/visual-embed-sdk-react.d.ts +251 -90
- package/dist/visual-embed-sdk.d.ts +299 -93
- package/lib/package.json +1 -1
- package/lib/src/embed/app.d.ts +44 -32
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -1
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +5 -1
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +61 -1
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/conversation.d.ts +7 -0
- package/lib/src/embed/conversation.d.ts.map +1 -1
- package/lib/src/embed/conversation.js +9 -0
- package/lib/src/embed/conversation.js.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.d.ts +20 -3
- package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/contracts.js +5 -0
- package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts +8 -8
- package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.js +18 -18
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +7 -7
- package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +10 -4
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +12 -2
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +1 -1
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/sage.d.ts +7 -0
- package/lib/src/embed/sage.d.ts.map +1 -1
- package/lib/src/embed/sage.js +9 -0
- package/lib/src/embed/sage.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts +7 -0
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +9 -0
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts +7 -0
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +9 -0
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +9 -3
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +41 -8
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +156 -24
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/errors.d.ts +2 -0
- package/lib/src/errors.d.ts.map +1 -1
- package/lib/src/errors.js +2 -0
- package/lib/src/errors.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/types.d.ts +142 -45
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +90 -15
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/logger.spec.d.ts +20 -5
- package/lib/src/utils/logger.spec.d.ts.map +1 -1
- package/lib/src/utils/processTrigger.d.ts +3 -2
- package/lib/src/utils/processTrigger.d.ts.map +1 -1
- package/lib/src/utils/processTrigger.js +4 -2
- package/lib/src/utils/processTrigger.js.map +1 -1
- package/lib/src/utils.d.ts +15 -4
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +35 -5
- package/lib/src/utils.js.map +1 -1
- package/lib/src/utils.spec.js +54 -1
- package/lib/src/utils.spec.js.map +1 -1
- package/package.json +1 -1
- package/src/embed/app.ts +45 -32
- package/src/embed/base.spec.ts +79 -1
- package/src/embed/base.ts +5 -2
- package/src/embed/conversation.ts +11 -0
- package/src/embed/hostEventClient/contracts.ts +23 -4
- package/src/embed/hostEventClient/host-event-client.spec.ts +7 -1
- package/src/embed/hostEventClient/host-event-client.ts +22 -11
- package/src/embed/liveboard.spec.ts +1 -1
- package/src/embed/liveboard.ts +18 -5
- package/src/embed/sage.ts +11 -0
- package/src/embed/search-bar.tsx +11 -0
- package/src/embed/search.ts +11 -0
- package/src/embed/ts-embed.spec.ts +205 -18
- package/src/embed/ts-embed.ts +45 -9
- package/src/errors.ts +2 -0
- package/src/index.ts +6 -0
- package/src/types.ts +146 -43
- package/src/utils/processTrigger.ts +6 -3
- package/src/utils.spec.ts +78 -0
- package/src/utils.ts +35 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HostEvent } from '../../types';
|
|
1
|
+
import { ContextType, HostEvent } from '../../types';
|
|
2
2
|
import { processTrigger as processTriggerService } from '../../utils/processTrigger';
|
|
3
3
|
import { getEmbedConfig } from '../embedConfig';
|
|
4
4
|
import {
|
|
@@ -23,7 +23,7 @@ export class HostEventClient {
|
|
|
23
23
|
* @param {any} data Data to send with the host event
|
|
24
24
|
* @returns {Promise<any>} - the response from the process trigger
|
|
25
25
|
*/
|
|
26
|
-
protected async processTrigger(message: HostEvent, data: any): Promise<any> {
|
|
26
|
+
protected async processTrigger(message: HostEvent, data: any, context?: ContextType): Promise<any> {
|
|
27
27
|
if (!this.iFrame) {
|
|
28
28
|
throw new Error('Iframe element is not set');
|
|
29
29
|
}
|
|
@@ -34,14 +34,16 @@ export class HostEventClient {
|
|
|
34
34
|
message,
|
|
35
35
|
thoughtspotHost,
|
|
36
36
|
data,
|
|
37
|
+
context,
|
|
37
38
|
);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
public async handleHostEventWithParam<UIPassthroughEventT extends UIPassthroughEvent>(
|
|
41
42
|
apiName: UIPassthroughEventT,
|
|
42
43
|
parameters: UIPassthroughRequest<UIPassthroughEventT>,
|
|
44
|
+
context?: ContextType,
|
|
43
45
|
): Promise<UIPassthroughResponse<UIPassthroughEventT>> {
|
|
44
|
-
const response = (await this.triggerUIPassthroughApi(apiName, parameters))
|
|
46
|
+
const response = (await this.triggerUIPassthroughApi(apiName, parameters, context as ContextType))
|
|
45
47
|
?.filter?.((r) => r.error || r.value)[0];
|
|
46
48
|
|
|
47
49
|
if (!response) {
|
|
@@ -65,8 +67,9 @@ export class HostEventClient {
|
|
|
65
67
|
public async hostEventFallback(
|
|
66
68
|
hostEvent: HostEvent,
|
|
67
69
|
data: any,
|
|
70
|
+
context?: ContextType,
|
|
68
71
|
): Promise<any> {
|
|
69
|
-
return this.processTrigger(hostEvent, data);
|
|
72
|
+
return this.processTrigger(hostEvent, data, context);
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
/**
|
|
@@ -80,20 +83,22 @@ export class HostEventClient {
|
|
|
80
83
|
public async triggerUIPassthroughApi<UIPassthroughEventT extends UIPassthroughEvent>(
|
|
81
84
|
apiName: UIPassthroughEventT,
|
|
82
85
|
parameters: UIPassthroughRequest<UIPassthroughEventT>,
|
|
86
|
+
context?: ContextType,
|
|
83
87
|
): Promise<UIPassthroughArrayResponse<UIPassthroughEventT>> {
|
|
84
88
|
const res = await this.processTrigger(HostEvent.UIPassthrough, {
|
|
85
89
|
type: apiName,
|
|
86
90
|
parameters,
|
|
87
|
-
});
|
|
91
|
+
}, context);
|
|
88
92
|
|
|
89
93
|
return res;
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
protected async handlePinEvent(
|
|
93
97
|
payload: HostEventRequest<HostEvent.Pin>,
|
|
94
|
-
|
|
98
|
+
context?: ContextType,
|
|
99
|
+
): Promise<HostEventResponse<HostEvent.Pin, ContextType>> {
|
|
95
100
|
if (!payload || !('newVizName' in payload)) {
|
|
96
|
-
return this.hostEventFallback(HostEvent.Pin, payload);
|
|
101
|
+
return this.hostEventFallback(HostEvent.Pin, payload, context);
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
const formattedPayload = {
|
|
@@ -104,6 +109,7 @@ export class HostEventClient {
|
|
|
104
109
|
|
|
105
110
|
const data = await this.handleHostEventWithParam(
|
|
106
111
|
UIPassthroughEvent.PinAnswerToLiveboard, formattedPayload,
|
|
112
|
+
context as ContextType,
|
|
107
113
|
);
|
|
108
114
|
|
|
109
115
|
return {
|
|
@@ -114,14 +120,16 @@ export class HostEventClient {
|
|
|
114
120
|
|
|
115
121
|
protected async handleSaveAnswerEvent(
|
|
116
122
|
payload: HostEventRequest<HostEvent.SaveAnswer>,
|
|
123
|
+
context?: ContextType,
|
|
117
124
|
): Promise<any> {
|
|
118
125
|
if (!payload || !('name' in payload) || !('description' in payload)) {
|
|
119
126
|
// Save is the fallback for SaveAnswer
|
|
120
|
-
return this.hostEventFallback(HostEvent.Save, payload);
|
|
127
|
+
return this.hostEventFallback(HostEvent.Save, payload, context);
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
const data = await this.handleHostEventWithParam(
|
|
124
131
|
UIPassthroughEvent.SaveAnswer, payload,
|
|
132
|
+
context as ContextType,
|
|
125
133
|
);
|
|
126
134
|
return {
|
|
127
135
|
...data,
|
|
@@ -132,19 +140,22 @@ export class HostEventClient {
|
|
|
132
140
|
public async triggerHostEvent<
|
|
133
141
|
HostEventT extends HostEvent,
|
|
134
142
|
PayloadT,
|
|
143
|
+
ContextT extends ContextType,
|
|
135
144
|
>(
|
|
136
145
|
hostEvent: HostEventT,
|
|
137
146
|
payload?: TriggerPayload<PayloadT, HostEventT>,
|
|
138
|
-
|
|
147
|
+
context?: ContextT,
|
|
148
|
+
): Promise<TriggerResponse<PayloadT, HostEventT, ContextType>> {
|
|
139
149
|
switch (hostEvent) {
|
|
140
150
|
case HostEvent.Pin:
|
|
141
|
-
return this.handlePinEvent(payload as HostEventRequest<HostEvent.Pin
|
|
151
|
+
return this.handlePinEvent(payload as HostEventRequest<HostEvent.Pin>, context as ContextType) as any;
|
|
142
152
|
case HostEvent.SaveAnswer:
|
|
143
153
|
return this.handleSaveAnswerEvent(
|
|
144
154
|
payload as HostEventRequest<HostEvent.SaveAnswer>,
|
|
155
|
+
context as ContextType,
|
|
145
156
|
) as any;
|
|
146
157
|
default:
|
|
147
|
-
return this.hostEventFallback(hostEvent, payload);
|
|
158
|
+
return this.hostEventFallback(hostEvent, payload, context);
|
|
148
159
|
}
|
|
149
160
|
}
|
|
150
161
|
}
|
|
@@ -1495,7 +1495,7 @@ describe('Liveboard/viz embed tests', () => {
|
|
|
1495
1495
|
await liveboardEmbed.trigger(HostEvent.Save);
|
|
1496
1496
|
expect(mockProcessTrigger).toHaveBeenCalledWith(HostEvent.Save, {
|
|
1497
1497
|
vizId: 'testViz',
|
|
1498
|
-
});
|
|
1498
|
+
}, undefined);
|
|
1499
1499
|
});
|
|
1500
1500
|
});
|
|
1501
1501
|
});
|
package/src/embed/liveboard.ts
CHANGED
|
@@ -22,12 +22,13 @@ import {
|
|
|
22
22
|
LiveboardAppEmbedViewConfig,
|
|
23
23
|
ErrorDetailsTypes,
|
|
24
24
|
EmbedErrorCodes,
|
|
25
|
+
ContextType,
|
|
25
26
|
} from '../types';
|
|
26
27
|
import { calculateVisibleElementData, getQueryParamString, isUndefined, isValidCssMargin } from '../utils';
|
|
27
28
|
import { getAuthPromise } from './base';
|
|
28
29
|
import { TsEmbed, V1Embed } from './ts-embed';
|
|
29
30
|
import { addPreviewStylesIfNotPresent } from '../utils/global-styles';
|
|
30
|
-
import { TriggerPayload, TriggerResponse } from './hostEventClient/contracts';
|
|
31
|
+
import { TriggerPayload, TriggerResponse, PageContextOptions } from './hostEventClient/contracts';
|
|
31
32
|
import { logger } from '../utils/logger';
|
|
32
33
|
|
|
33
34
|
|
|
@@ -83,7 +84,7 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
|
|
|
83
84
|
* Setting this height helps resolve issues with empty Liveboards and
|
|
84
85
|
* other screens navigable from a Liveboard.
|
|
85
86
|
*
|
|
86
|
-
* @version SDK: 1.44.2 | ThoughtSpot:
|
|
87
|
+
* @version SDK: 1.44.2 | ThoughtSpot: 10.15.0.cl
|
|
87
88
|
* @default 500
|
|
88
89
|
* @example
|
|
89
90
|
* ```js
|
|
@@ -642,6 +643,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
642
643
|
}
|
|
643
644
|
|
|
644
645
|
private sendFullHeightLazyLoadData = () => {
|
|
646
|
+
console.log('sendFullHeightLazyLoadData', this.iFrame);
|
|
645
647
|
const data = calculateVisibleElementData(this.iFrame);
|
|
646
648
|
this.trigger(HostEvent.VisibleEmbedCoordinates, data);
|
|
647
649
|
}
|
|
@@ -800,10 +802,11 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
800
802
|
* @param {any} data The payload to send with the message
|
|
801
803
|
* @returns A promise that resolves with the response from the embedded app
|
|
802
804
|
*/
|
|
803
|
-
public trigger<HostEventT extends HostEvent, PayloadT>(
|
|
805
|
+
public trigger<HostEventT extends HostEvent, PayloadT, ContextT extends ContextType>(
|
|
804
806
|
messageType: HostEventT,
|
|
805
807
|
data: TriggerPayload<PayloadT, HostEventT> = ({} as any),
|
|
806
|
-
|
|
808
|
+
context?: ContextT,
|
|
809
|
+
): Promise<TriggerResponse<PayloadT, HostEventT, ContextT>> {
|
|
807
810
|
const dataWithVizId: any = data;
|
|
808
811
|
if (messageType === HostEvent.SetActiveTab) {
|
|
809
812
|
this.setActiveTab(data as { tabId: string });
|
|
@@ -812,7 +815,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
812
815
|
if (typeof dataWithVizId === 'object' && this.viewConfig.vizId) {
|
|
813
816
|
dataWithVizId.vizId = this.viewConfig.vizId;
|
|
814
817
|
}
|
|
815
|
-
return super.trigger(messageType, dataWithVizId);
|
|
818
|
+
return super.trigger(messageType, dataWithVizId, context);
|
|
816
819
|
}
|
|
817
820
|
/**
|
|
818
821
|
* Destroys the ThoughtSpot embed, and remove any nodes from the DOM.
|
|
@@ -889,6 +892,16 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
889
892
|
|
|
890
893
|
return url;
|
|
891
894
|
}
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Get the current context of the embedded liveboard.
|
|
898
|
+
* @returns The current context object containing the page type and object ids.
|
|
899
|
+
* @version SDK: 1.46.0 | ThoughtSpot: 26.3.0.cl
|
|
900
|
+
*/
|
|
901
|
+
public async getCurrentContext(): Promise<PageContextOptions> {
|
|
902
|
+
const context = await super.getCurrentContext();
|
|
903
|
+
return context;
|
|
904
|
+
}
|
|
892
905
|
}
|
|
893
906
|
|
|
894
907
|
/**
|
package/src/embed/sage.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @author Mourya Balabhadra <mourya.balabhadra@thoughtspot.com>
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { PageContextOptions } from './hostEventClient/contracts';
|
|
9
10
|
import { DOMSelector, Param, BaseViewConfig, SearchLiveboardCommonViewConfig } from '../types';
|
|
10
11
|
import { getQueryParamString } from '../utils';
|
|
11
12
|
import { V1Embed } from './ts-embed';
|
|
@@ -229,4 +230,14 @@ export class SageEmbed extends V1Embed {
|
|
|
229
230
|
|
|
230
231
|
return this;
|
|
231
232
|
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Get the current context of the embedded SageEmbed.
|
|
236
|
+
* @returns The current context object containing the page type and object ids.
|
|
237
|
+
* @version SDK: 1.46.0 | ThoughtSpot: 26.3.0.cl
|
|
238
|
+
*/
|
|
239
|
+
public async getCurrentContext(): Promise<PageContextOptions> {
|
|
240
|
+
const context = await super.getCurrentContext();
|
|
241
|
+
return context;
|
|
242
|
+
}
|
|
232
243
|
}
|
package/src/embed/search-bar.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { SearchLiveboardCommonViewConfig, BaseViewConfig, DefaultAppInitData, Pa
|
|
|
2
2
|
import { getQueryParamString } from '../utils';
|
|
3
3
|
import { TsEmbed } from './ts-embed';
|
|
4
4
|
import { SearchOptions } from './search';
|
|
5
|
+
import { PageContextOptions } from './hostEventClient/contracts';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @group Embed components
|
|
@@ -198,4 +199,14 @@ export class SearchBarEmbed extends TsEmbed {
|
|
|
198
199
|
const defaultAppInitData = await super.getAppInitData();
|
|
199
200
|
return { ...defaultAppInitData, ...this.getSearchInitData() };
|
|
200
201
|
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Get the current context of the embedded search bar.
|
|
205
|
+
* @returns The current context object containing the page type and object ids.
|
|
206
|
+
* @version SDK: 1.46.0 | ThoughtSpot: 26.3.0.cl
|
|
207
|
+
*/
|
|
208
|
+
public async getCurrentContext(): Promise<PageContextOptions> {
|
|
209
|
+
const context = await super.getCurrentContext();
|
|
210
|
+
return context;
|
|
211
|
+
}
|
|
201
212
|
}
|
package/src/embed/search.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { getAuthPromise } from './base';
|
|
|
27
27
|
import { getReleaseVersion } from '../auth';
|
|
28
28
|
import { getEmbedConfig } from './embedConfig';
|
|
29
29
|
import { getInterceptInitData } from '../api-intercept';
|
|
30
|
+
import { PageContextOptions } from './hostEventClient/contracts';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Configuration for search options.
|
|
@@ -523,4 +524,14 @@ export class SearchEmbed extends TsEmbed {
|
|
|
523
524
|
});
|
|
524
525
|
return this;
|
|
525
526
|
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Get the current context of the embedded search.
|
|
530
|
+
* @returns The current context object containing the page type and object ids.
|
|
531
|
+
* @version SDK: 1.46.0 | ThoughtSpot: 26.3.0.cl
|
|
532
|
+
*/
|
|
533
|
+
public async getCurrentContext(): Promise<PageContextOptions> {
|
|
534
|
+
const context = await super.getCurrentContext();
|
|
535
|
+
return context;
|
|
536
|
+
}
|
|
526
537
|
}
|
|
@@ -204,6 +204,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
204
204
|
parameters: payload,
|
|
205
205
|
type: UIPassthroughEvent.PinAnswerToLiveboard,
|
|
206
206
|
},
|
|
207
|
+
undefined,
|
|
207
208
|
);
|
|
208
209
|
});
|
|
209
210
|
});
|
|
@@ -224,6 +225,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
224
225
|
HostEvent.Save,
|
|
225
226
|
'http://tshost',
|
|
226
227
|
{},
|
|
228
|
+
undefined,
|
|
227
229
|
);
|
|
228
230
|
});
|
|
229
231
|
});
|
|
@@ -245,6 +247,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
245
247
|
HostEvent.Save,
|
|
246
248
|
'http://tshost',
|
|
247
249
|
false,
|
|
250
|
+
undefined,
|
|
248
251
|
);
|
|
249
252
|
});
|
|
250
253
|
});
|
|
@@ -1331,6 +1334,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1331
1334
|
HostEvent.InfoSuccess,
|
|
1332
1335
|
'http://tshost',
|
|
1333
1336
|
expect.objectContaining({ info: expect.any(Object) }),
|
|
1337
|
+
undefined,
|
|
1334
1338
|
);
|
|
1335
1339
|
});
|
|
1336
1340
|
});
|
|
@@ -1467,6 +1471,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1467
1471
|
HostEvent.InfoSuccess,
|
|
1468
1472
|
'http://tshost',
|
|
1469
1473
|
expect.objectContaining({ info: expect.any(Object) }),
|
|
1474
|
+
undefined,
|
|
1470
1475
|
);
|
|
1471
1476
|
});
|
|
1472
1477
|
});
|
|
@@ -1481,6 +1486,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1481
1486
|
HostEvent.InfoSuccess,
|
|
1482
1487
|
'http://tshost',
|
|
1483
1488
|
expect.objectContaining({ info: expect.any(Object) }),
|
|
1489
|
+
undefined,
|
|
1484
1490
|
);
|
|
1485
1491
|
});
|
|
1486
1492
|
});
|
|
@@ -1495,6 +1501,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1495
1501
|
HostEvent.InfoSuccess,
|
|
1496
1502
|
'http://tshost',
|
|
1497
1503
|
expect.objectContaining({ info: expect.any(Object) }),
|
|
1504
|
+
undefined,
|
|
1498
1505
|
);
|
|
1499
1506
|
});
|
|
1500
1507
|
});
|
|
@@ -1509,6 +1516,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1509
1516
|
HostEvent.InfoSuccess,
|
|
1510
1517
|
'http://tshost',
|
|
1511
1518
|
expect.objectContaining({ info: expect.any(Object) }),
|
|
1519
|
+
undefined,
|
|
1512
1520
|
);
|
|
1513
1521
|
});
|
|
1514
1522
|
});
|
|
@@ -2483,6 +2491,44 @@ describe('Unit test case for ts embed', () => {
|
|
|
2483
2491
|
expect(libEmbed.preRender).toHaveBeenCalledTimes(0);
|
|
2484
2492
|
});
|
|
2485
2493
|
|
|
2494
|
+
it('should set overflow:hidden when hidePreRender and remove when showPreRender', async () => {
|
|
2495
|
+
createRootEleForEmbed();
|
|
2496
|
+
|
|
2497
|
+
(window as any).ResizeObserver = window.ResizeObserver
|
|
2498
|
+
|| jest.fn().mockImplementation(() => ({
|
|
2499
|
+
disconnect: jest.fn(),
|
|
2500
|
+
observe: jest.fn(),
|
|
2501
|
+
unobserve: jest.fn(),
|
|
2502
|
+
}));
|
|
2503
|
+
|
|
2504
|
+
const libEmbed = new LiveboardEmbed('#tsEmbedDiv', {
|
|
2505
|
+
preRenderId: 'overflow-test',
|
|
2506
|
+
liveboardId: 'myLiveboardId',
|
|
2507
|
+
});
|
|
2508
|
+
|
|
2509
|
+
await libEmbed.preRender();
|
|
2510
|
+
await waitFor(() => !!getIFrameEl());
|
|
2511
|
+
|
|
2512
|
+
const preRenderIds = libEmbed.getPreRenderIds();
|
|
2513
|
+
const preRenderWrapper = document.getElementById(preRenderIds.wrapper);
|
|
2514
|
+
|
|
2515
|
+
// After preRender (calls hidePreRender by default)
|
|
2516
|
+
// should have overflow:hidden
|
|
2517
|
+
expect(preRenderWrapper.style.overflow).toBe('hidden');
|
|
2518
|
+
expect(preRenderWrapper.style.opacity).toBe('0');
|
|
2519
|
+
|
|
2520
|
+
// After showPreRender, overflow should be removed
|
|
2521
|
+
// to inherit from CSS
|
|
2522
|
+
libEmbed.showPreRender();
|
|
2523
|
+
expect(preRenderWrapper.style.overflow).toBe('');
|
|
2524
|
+
expect(preRenderWrapper.style.opacity).toBe('');
|
|
2525
|
+
|
|
2526
|
+
// After hidePreRender again, overflow should be hidden
|
|
2527
|
+
libEmbed.hidePreRender();
|
|
2528
|
+
expect(preRenderWrapper.style.overflow).toBe('hidden');
|
|
2529
|
+
expect(preRenderWrapper.style.opacity).toBe('0');
|
|
2530
|
+
});
|
|
2531
|
+
|
|
2486
2532
|
it('it should connect with another object', async () => {
|
|
2487
2533
|
createRootEleForEmbed();
|
|
2488
2534
|
mockMessageChannel();
|
|
@@ -4017,7 +4063,7 @@ describe('Destroy error handling', () => {
|
|
|
4017
4063
|
}).not.toThrow();
|
|
4018
4064
|
|
|
4019
4065
|
expect(logSpy).toHaveBeenCalledWith('Error destroying TS Embed', expect.any(Error));
|
|
4020
|
-
logSpy.
|
|
4066
|
+
logSpy.mockReset();
|
|
4021
4067
|
});
|
|
4022
4068
|
});
|
|
4023
4069
|
|
|
@@ -4060,11 +4106,12 @@ describe('Fullscreen change handler behavior', () => {
|
|
|
4060
4106
|
document.dispatchEvent(event);
|
|
4061
4107
|
|
|
4062
4108
|
await executeAfterWait(() => {
|
|
4063
|
-
expect(mockProcessTrigger).
|
|
4109
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(
|
|
4064
4110
|
expect.any(Object),
|
|
4065
4111
|
HostEvent.ExitPresentMode,
|
|
4066
4112
|
expect.any(String),
|
|
4067
4113
|
expect.any(Object),
|
|
4114
|
+
undefined,
|
|
4068
4115
|
);
|
|
4069
4116
|
});
|
|
4070
4117
|
});
|
|
@@ -4107,19 +4154,7 @@ describe('Fullscreen change handler behavior', () => {
|
|
|
4107
4154
|
});
|
|
4108
4155
|
|
|
4109
4156
|
describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
4110
|
-
|
|
4111
|
-
init({
|
|
4112
|
-
thoughtSpotHost: 'tshost',
|
|
4113
|
-
authType: AuthType.None,
|
|
4114
|
-
});
|
|
4115
|
-
});
|
|
4116
|
-
|
|
4117
|
-
afterEach(() => {
|
|
4118
|
-
const rootEle = document.getElementById('myRoot');
|
|
4119
|
-
rootEle?.remove();
|
|
4120
|
-
});
|
|
4121
|
-
|
|
4122
|
-
test('should trigger UpdateEmbedParams when showPreRender connects to existing prerendered component', async () => {
|
|
4157
|
+
const setupPreRenderTest = async (preRenderId: string, initialConfig: Partial<LiveboardViewConfig>) => {
|
|
4123
4158
|
createRootEleForEmbed();
|
|
4124
4159
|
mockMessageChannel();
|
|
4125
4160
|
|
|
@@ -4131,8 +4166,8 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
4131
4166
|
}));
|
|
4132
4167
|
|
|
4133
4168
|
const embed1 = new LiveboardEmbed('#tsEmbedDiv', {
|
|
4134
|
-
preRenderId
|
|
4135
|
-
|
|
4169
|
+
preRenderId,
|
|
4170
|
+
...initialConfig,
|
|
4136
4171
|
});
|
|
4137
4172
|
|
|
4138
4173
|
await embed1.preRender();
|
|
@@ -4143,6 +4178,24 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
4143
4178
|
mockProcessTrigger.mockClear();
|
|
4144
4179
|
mockProcessTrigger.mockResolvedValue({});
|
|
4145
4180
|
|
|
4181
|
+
return embed1;
|
|
4182
|
+
};
|
|
4183
|
+
|
|
4184
|
+
beforeAll(() => {
|
|
4185
|
+
init({
|
|
4186
|
+
thoughtSpotHost: 'tshost',
|
|
4187
|
+
authType: AuthType.None,
|
|
4188
|
+
});
|
|
4189
|
+
});
|
|
4190
|
+
|
|
4191
|
+
afterEach(() => {
|
|
4192
|
+
const rootEle = document.getElementById('myRoot');
|
|
4193
|
+
rootEle?.remove();
|
|
4194
|
+
});
|
|
4195
|
+
|
|
4196
|
+
test('should trigger UpdateEmbedParams when showPreRender connects to existing prerendered component', async () => {
|
|
4197
|
+
await setupPreRenderTest('update-params-test', { liveboardId: 'original-lb' });
|
|
4198
|
+
|
|
4146
4199
|
const embed2 = new LiveboardEmbed('#tsEmbedDiv', {
|
|
4147
4200
|
preRenderId: 'update-params-test',
|
|
4148
4201
|
liveboardId: 'updated-lb',
|
|
@@ -4151,14 +4204,148 @@ describe('ShowPreRender with UpdateEmbedParams', () => {
|
|
|
4151
4204
|
embed2.showPreRender();
|
|
4152
4205
|
|
|
4153
4206
|
await executeAfterWait(() => {
|
|
4154
|
-
expect(mockProcessTrigger).
|
|
4207
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(
|
|
4155
4208
|
expect.any(Object),
|
|
4156
4209
|
HostEvent.UpdateEmbedParams,
|
|
4157
4210
|
expect.any(String),
|
|
4158
4211
|
expect.objectContaining({
|
|
4159
4212
|
liveboardId: 'updated-lb',
|
|
4160
4213
|
}),
|
|
4214
|
+
undefined,
|
|
4161
4215
|
);
|
|
4162
4216
|
});
|
|
4163
4217
|
});
|
|
4218
|
+
|
|
4219
|
+
test('should trigger UpdateEmbedParams with runtime filters and visible vizs', async () => {
|
|
4220
|
+
await setupPreRenderTest('url-param-test', { liveboardId: 'original-lb' });
|
|
4221
|
+
|
|
4222
|
+
const embed2 = new LiveboardEmbed('#tsEmbedDiv', {
|
|
4223
|
+
preRenderId: 'url-param-test',
|
|
4224
|
+
liveboardId: 'original-lb',
|
|
4225
|
+
visibleVizs: ['viz-1'],
|
|
4226
|
+
runtimeFilters: [
|
|
4227
|
+
{
|
|
4228
|
+
columnName: 'Color',
|
|
4229
|
+
operator: RuntimeFilterOp.IN,
|
|
4230
|
+
values: ['red', 'blue'],
|
|
4231
|
+
},
|
|
4232
|
+
{
|
|
4233
|
+
columnName: 'Region',
|
|
4234
|
+
operator: RuntimeFilterOp.EQ,
|
|
4235
|
+
values: ['North'],
|
|
4236
|
+
},
|
|
4237
|
+
],
|
|
4238
|
+
});
|
|
4239
|
+
|
|
4240
|
+
embed2.showPreRender();
|
|
4241
|
+
|
|
4242
|
+
await executeAfterWait(() => {
|
|
4243
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(
|
|
4244
|
+
expect.any(Object),
|
|
4245
|
+
HostEvent.UpdateEmbedParams,
|
|
4246
|
+
expect.any(String),
|
|
4247
|
+
expect.objectContaining({
|
|
4248
|
+
liveboardId: 'original-lb',
|
|
4249
|
+
visibleVizs: ['viz-1'],
|
|
4250
|
+
runtimeFilters: [
|
|
4251
|
+
{
|
|
4252
|
+
columnName: 'Color',
|
|
4253
|
+
operator: RuntimeFilterOp.IN,
|
|
4254
|
+
values: ['red', 'blue'],
|
|
4255
|
+
},
|
|
4256
|
+
{
|
|
4257
|
+
columnName: 'Region',
|
|
4258
|
+
operator: RuntimeFilterOp.EQ,
|
|
4259
|
+
values: ['North'],
|
|
4260
|
+
},
|
|
4261
|
+
],
|
|
4262
|
+
}),
|
|
4263
|
+
undefined,
|
|
4264
|
+
);
|
|
4265
|
+
});
|
|
4266
|
+
});
|
|
4267
|
+
|
|
4268
|
+
test('should trigger UpdateEmbedParams with updated config', async () => {
|
|
4269
|
+
await setupPreRenderTest('preserve-config-test', {
|
|
4270
|
+
liveboardId: 'original-lb',
|
|
4271
|
+
runtimeFilters: [
|
|
4272
|
+
{
|
|
4273
|
+
columnName: 'Color',
|
|
4274
|
+
operator: RuntimeFilterOp.IN,
|
|
4275
|
+
values: ['red', 'blue'],
|
|
4276
|
+
},
|
|
4277
|
+
],
|
|
4278
|
+
});
|
|
4279
|
+
|
|
4280
|
+
const embed2 = new LiveboardEmbed('#tsEmbedDiv', {
|
|
4281
|
+
preRenderId: 'preserve-config-test',
|
|
4282
|
+
liveboardId: 'original-lb',
|
|
4283
|
+
visibleVizs: ['viz-1', 'viz-2'],
|
|
4284
|
+
runtimeFilters: [
|
|
4285
|
+
{
|
|
4286
|
+
columnName: 'Region',
|
|
4287
|
+
operator: RuntimeFilterOp.EQ,
|
|
4288
|
+
values: ['North'],
|
|
4289
|
+
},
|
|
4290
|
+
],
|
|
4291
|
+
});
|
|
4292
|
+
|
|
4293
|
+
embed2.showPreRender();
|
|
4294
|
+
|
|
4295
|
+
await executeAfterWait(() => {
|
|
4296
|
+
expect(mockProcessTrigger).toHaveBeenLastCalledWith(
|
|
4297
|
+
expect.any(Object),
|
|
4298
|
+
HostEvent.UpdateEmbedParams,
|
|
4299
|
+
expect.any(String),
|
|
4300
|
+
expect.objectContaining({
|
|
4301
|
+
liveboardId: 'original-lb',
|
|
4302
|
+
visibleVizs: ['viz-1', 'viz-2'],
|
|
4303
|
+
runtimeFilters: [
|
|
4304
|
+
{
|
|
4305
|
+
columnName: 'Region',
|
|
4306
|
+
operator: RuntimeFilterOp.EQ,
|
|
4307
|
+
values: ['North'],
|
|
4308
|
+
},
|
|
4309
|
+
],
|
|
4310
|
+
}),
|
|
4311
|
+
undefined,
|
|
4312
|
+
);
|
|
4313
|
+
});
|
|
4314
|
+
});
|
|
4315
|
+
|
|
4316
|
+
test('should handle error when getUpdateEmbedParamsObject fails during showPreRender', async () => {
|
|
4317
|
+
await setupPreRenderTest('error-test', { liveboardId: 'original-lb' });
|
|
4318
|
+
|
|
4319
|
+
const handleErrorSpy = jest.spyOn(LiveboardEmbed.prototype as any, 'handleError');
|
|
4320
|
+
|
|
4321
|
+
const embed2 = new LiveboardEmbed('#tsEmbedDiv', {
|
|
4322
|
+
preRenderId: 'error-test',
|
|
4323
|
+
liveboardId: 'updated-lb',
|
|
4324
|
+
});
|
|
4325
|
+
|
|
4326
|
+
const mockError = new Error('Failed to get params');
|
|
4327
|
+
jest.spyOn(embed2 as any, 'getUpdateEmbedParamsObject').mockRejectedValue(mockError);
|
|
4328
|
+
|
|
4329
|
+
embed2.showPreRender();
|
|
4330
|
+
|
|
4331
|
+
await executeAfterWait(() => {
|
|
4332
|
+
expect(handleErrorSpy).toHaveBeenCalledWith(
|
|
4333
|
+
expect.objectContaining({
|
|
4334
|
+
errorType: ErrorDetailsTypes.API,
|
|
4335
|
+
message: 'Failed to get params',
|
|
4336
|
+
code: EmbedErrorCodes.UPDATE_PARAMS_FAILED,
|
|
4337
|
+
error: 'Failed to get params',
|
|
4338
|
+
}),
|
|
4339
|
+
);
|
|
4340
|
+
|
|
4341
|
+
expect(mockProcessTrigger).not.toHaveBeenCalledWith(
|
|
4342
|
+
expect.any(Object),
|
|
4343
|
+
HostEvent.UpdateEmbedParams,
|
|
4344
|
+
expect.any(String),
|
|
4345
|
+
expect.any(Object),
|
|
4346
|
+
);
|
|
4347
|
+
});
|
|
4348
|
+
|
|
4349
|
+
handleErrorSpy.mockRestore();
|
|
4350
|
+
});
|
|
4164
4351
|
});
|