@thoughtspot/visual-embed-sdk 1.36.0 → 1.36.2
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.d.ts.map +1 -1
- package/cjs/src/auth.js +2 -1
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/css-variables.d.ts +8 -0
- package/cjs/src/css-variables.d.ts.map +1 -1
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +2 -2
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +24 -0
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.js +8 -3
- package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/cjs/src/embed/hostEventClient/host-event-client.spec.js +54 -0
- package/cjs/src/embed/hostEventClient/host-event-client.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/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/types.d.ts +72 -8
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +72 -8
- 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/cjs/src/utils/resetServices.d.ts +8 -0
- package/cjs/src/utils/resetServices.d.ts.map +1 -0
- package/cjs/src/utils/resetServices.js +18 -0
- package/cjs/src/utils/resetServices.js.map +1 -0
- package/cjs/src/utils/resetServices.spec.d.ts +2 -0
- package/cjs/src/utils/resetServices.spec.d.ts.map +1 -0
- package/cjs/src/utils/resetServices.spec.js +18 -0
- package/cjs/src/utils/resetServices.spec.js.map +1 -0
- package/cjs/src/utils/sessionInfoService.d.ts +14 -2
- package/cjs/src/utils/sessionInfoService.d.ts.map +1 -1
- package/cjs/src/utils/sessionInfoService.js +18 -3
- package/cjs/src/utils/sessionInfoService.js.map +1 -1
- package/dist/{index-V2oBuwy6.js → index-B3hd6DTM.js} +1 -1
- package/dist/index-BBBimG1x.js +7370 -0
- package/dist/index-BGnxP5NY.js +7370 -0
- package/dist/index-CENLvayL.js +7370 -0
- package/dist/index-CR5u7BMC.js +7370 -0
- package/dist/index-CbltIawo.js +7370 -0
- package/dist/index-CoQfqaHj.js +7370 -0
- package/dist/index-CzwzS0P4.js +7370 -0
- package/dist/index-D-9WUCUl.js +7370 -0
- package/dist/index-DFwi_pV_.js +7370 -0
- package/dist/index-DOIjN0N_.js +7370 -0
- package/dist/index-DYBx8SuE.js +7370 -0
- package/dist/index-DaLHJaLd.js +7370 -0
- package/dist/index-DnJX-gN2.js +7370 -0
- package/dist/index-DpuhnTj2.js +7370 -0
- package/dist/index-IDmSUe93.js +7370 -0
- package/dist/index-nWevLycs.js +7370 -0
- package/dist/index-vxW97_xb.js +7370 -0
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/css-variables.d.ts +8 -0
- package/dist/src/css-variables.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/hostEventClient/host-event-client.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/hostEventsTypeMapping.d.ts +2 -0
- package/dist/src/hostEventsTypeMapping.d.ts.map +1 -0
- package/dist/src/types.d.ts +72 -8
- 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/src/utils/resetServices.d.ts +8 -0
- package/dist/src/utils/resetServices.d.ts.map +1 -0
- package/dist/src/utils/resetServices.spec.d.ts +2 -0
- package/dist/src/utils/resetServices.spec.d.ts.map +1 -0
- package/dist/src/utils/sessionInfoService.d.ts +14 -2
- package/dist/src/utils/sessionInfoService.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +85 -15
- package/dist/tsembed-react.js +84 -14
- package/dist/tsembed.es.js +126 -18
- package/dist/tsembed.js +125 -17
- package/dist/visual-embed-sdk-react-full.d.ts +94 -10
- package/dist/visual-embed-sdk-react.d.ts +94 -10
- package/dist/visual-embed-sdk.d.ts +94 -10
- package/lib/package.json +1 -1
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +3 -2
- package/lib/src/auth.js.map +1 -1
- package/lib/src/css-variables.d.ts +8 -0
- package/lib/src/css-variables.d.ts.map +1 -1
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +2 -2
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +24 -0
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.js +8 -3
- package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
- package/lib/src/embed/hostEventClient/host-event-client.spec.js +54 -0
- package/lib/src/embed/hostEventClient/host-event-client.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/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/types.d.ts +72 -8
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +72 -8
- 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/utils/resetServices.d.ts +8 -0
- package/lib/src/utils/resetServices.d.ts.map +1 -0
- package/lib/src/utils/resetServices.js +14 -0
- package/lib/src/utils/resetServices.js.map +1 -0
- package/lib/src/utils/resetServices.spec.d.ts +2 -0
- package/lib/src/utils/resetServices.spec.d.ts.map +1 -0
- package/lib/src/utils/resetServices.spec.js +15 -0
- package/lib/src/utils/resetServices.spec.js.map +1 -0
- package/lib/src/utils/sessionInfoService.d.ts +14 -2
- package/lib/src/utils/sessionInfoService.d.ts.map +1 -1
- package/lib/src/utils/sessionInfoService.js +16 -2
- package/lib/src/utils/sessionInfoService.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +94 -10
- package/package.json +1 -1
- package/src/auth.ts +3 -2
- package/src/css-variables.ts +10 -0
- package/src/embed/base.spec.ts +26 -0
- package/src/embed/base.ts +2 -2
- package/src/embed/hostEventClient/host-event-client.spec.ts +61 -0
- package/src/embed/hostEventClient/host-event-client.ts +8 -3
- package/src/types.ts +72 -8
- package/src/utils/resetServices.spec.ts +15 -0
- package/src/utils/resetServices.ts +14 -0
- package/src/utils/sessionInfoService.ts +17 -2
package/src/embed/base.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import EventEmitter from 'eventemitter3';
|
|
11
11
|
import { registerReportingObserver } from '../utils/reporting';
|
|
12
|
-
import { resetCachedAuthToken } from '../authToken';
|
|
13
12
|
import { logger, setGlobalLogLevelOverride } from '../utils/logger';
|
|
14
13
|
import { tokenizedFetch } from '../tokenizedFetch';
|
|
15
14
|
import { EndPoints } from '../utils/authService/authService';
|
|
@@ -34,6 +33,7 @@ import {
|
|
|
34
33
|
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
|
|
35
34
|
import { getEmbedConfig, setEmbedConfig } from './embedConfig';
|
|
36
35
|
import { getQueryParamString } from '../utils';
|
|
36
|
+
import { resetAllCachedServices } from '../utils/resetServices';
|
|
37
37
|
|
|
38
38
|
const CONFIG_DEFAULTS: Partial<EmbedConfig> = {
|
|
39
39
|
loginFailedMessage: 'Not logged in',
|
|
@@ -193,7 +193,7 @@ function backwardCompat(embedConfig: EmbedConfig): EmbedConfig {
|
|
|
193
193
|
*/
|
|
194
194
|
export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
|
|
195
195
|
sanity(embedConfig);
|
|
196
|
-
|
|
196
|
+
resetAllCachedServices();
|
|
197
197
|
embedConfig = setEmbedConfig(
|
|
198
198
|
backwardCompat({
|
|
199
199
|
...CONFIG_DEFAULTS,
|
|
@@ -133,6 +133,7 @@ describe('HostEventClient', () => {
|
|
|
133
133
|
const mockResponse = {
|
|
134
134
|
value: {
|
|
135
135
|
pinboardId: 'testPinboard',
|
|
136
|
+
liveboardId: 'testPinboard',
|
|
136
137
|
tabId: 'testTab',
|
|
137
138
|
vizId: 'testVizId',
|
|
138
139
|
},
|
|
@@ -250,5 +251,65 @@ describe('HostEventClient', () => {
|
|
|
250
251
|
);
|
|
251
252
|
expect(result).toEqual([mockResponse]);
|
|
252
253
|
});
|
|
254
|
+
|
|
255
|
+
it('Pin response support pinboardId as well', async () => {
|
|
256
|
+
const { client, mockIframe } = createHostEventClient();
|
|
257
|
+
const hostEvent = HostEvent.Pin;
|
|
258
|
+
const payload: HostEventRequest<typeof hostEvent> = {
|
|
259
|
+
newVizDescription: 'Test Description',
|
|
260
|
+
vizId: 'testVizId',
|
|
261
|
+
newVizName: 'Test Answer',
|
|
262
|
+
newLiveboardName: 'testLiveboard',
|
|
263
|
+
} as any;
|
|
264
|
+
const mockResponse = [{
|
|
265
|
+
value: {
|
|
266
|
+
pinboardId: 'testLiveboard',
|
|
267
|
+
liveboardId: 'testPinboard',
|
|
268
|
+
tabId: 'testTab',
|
|
269
|
+
vizId: 'testVizId',
|
|
270
|
+
},
|
|
271
|
+
refId: 'testVizId',
|
|
272
|
+
}];
|
|
273
|
+
mockProcessTrigger.mockResolvedValue(mockResponse);
|
|
274
|
+
const result = await client.triggerHostEvent(hostEvent, payload);
|
|
275
|
+
expect(result.liveboardId).toBe('testLiveboard');
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('should request liveboardId as well', async () => {
|
|
279
|
+
const { client, mockIframe } = createHostEventClient();
|
|
280
|
+
const hostEvent = HostEvent.Pin;
|
|
281
|
+
const payload: HostEventRequest<typeof hostEvent> = {
|
|
282
|
+
liveboardId: 'test',
|
|
283
|
+
newVizName: 'Test Answer',
|
|
284
|
+
newPinboardName: 'testLiveboard1',
|
|
285
|
+
newLiveboardName: 'testLiveboard',
|
|
286
|
+
} as any;
|
|
287
|
+
const mockResponse = [{
|
|
288
|
+
value: {
|
|
289
|
+
pinboardId: 'testLiveboard',
|
|
290
|
+
tabId: 'testTab',
|
|
291
|
+
vizId: 'testVizId',
|
|
292
|
+
},
|
|
293
|
+
refId: 'testVizId',
|
|
294
|
+
}];
|
|
295
|
+
mockProcessTrigger.mockResolvedValue(mockResponse);
|
|
296
|
+
const result = await client.triggerHostEvent(hostEvent, payload);
|
|
297
|
+
expect(result.liveboardId).toBe('testLiveboard');
|
|
298
|
+
expect(mockProcessTrigger).toHaveBeenCalledWith(
|
|
299
|
+
mockIframe,
|
|
300
|
+
HostEvent.UIPassthrough,
|
|
301
|
+
mockThoughtSpotHost,
|
|
302
|
+
{
|
|
303
|
+
parameters: { ...payload, pinboardId: 'test', newPinboardName: 'testLiveboard' },
|
|
304
|
+
type: 'addVizToPinboard',
|
|
305
|
+
},
|
|
306
|
+
);
|
|
307
|
+
expect(result).toEqual({
|
|
308
|
+
pinboardId: 'testLiveboard',
|
|
309
|
+
tabId: 'testTab',
|
|
310
|
+
vizId: 'testVizId',
|
|
311
|
+
liveboardId: 'testLiveboard',
|
|
312
|
+
});
|
|
313
|
+
});
|
|
253
314
|
});
|
|
254
315
|
});
|
|
@@ -98,13 +98,18 @@ export class HostEventClient {
|
|
|
98
98
|
|
|
99
99
|
const formattedPayload = {
|
|
100
100
|
...payload,
|
|
101
|
-
pinboardId: payload.liveboardId,
|
|
102
|
-
newPinboardName: payload.newLiveboardName,
|
|
101
|
+
pinboardId: payload.liveboardId ?? (payload as any).pinboardId,
|
|
102
|
+
newPinboardName: payload.newLiveboardName ?? (payload as any).newPinboardName,
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
const data = await this.handleHostEventWithParam(
|
|
106
106
|
UIPassthroughEvent.PinAnswerToLiveboard, formattedPayload,
|
|
107
107
|
);
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
...data,
|
|
111
|
+
liveboardId: (data as any).pinboardId,
|
|
112
|
+
};
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
protected async handleSaveAnswerEvent(
|
package/src/types.ts
CHANGED
|
@@ -2615,16 +2615,63 @@ export enum HostEvent {
|
|
|
2615
2615
|
*/
|
|
2616
2616
|
getExportRequestForCurrentPinboard = 'getExportRequestForCurrentPinboard',
|
|
2617
2617
|
/**
|
|
2618
|
-
* Trigger
|
|
2619
|
-
*
|
|
2620
|
-
*
|
|
2621
|
-
* a
|
|
2618
|
+
* Trigger **Pin** action on an embedded object.
|
|
2619
|
+
* If no parameters are defined, the pin action is triggered
|
|
2620
|
+
* for the Answer that the user is currently on
|
|
2621
|
+
* and a modal opens for Liveboard selection.
|
|
2622
|
+
* To add an Answer or visualization to a Liveboard programmatically without
|
|
2623
|
+
* showing requiring additional user input via *Pin to Liveboard* modal, define
|
|
2624
|
+
* the following parameters:
|
|
2625
|
+
*
|
|
2626
|
+
* @param
|
|
2627
|
+
* `vizId`- GUID of the saved Answer or visualization to pin to a Liveboard.
|
|
2628
|
+
* Optional when pinning a new chart or table generated from a Search query.
|
|
2629
|
+
* @param
|
|
2630
|
+
* `liveboardID` - GUID of the Liveboard to pin an Answer. If there is no Liveboard,
|
|
2631
|
+
* specify the `newLiveboardName` parameter to create a new Liveboard.
|
|
2632
|
+
* @param
|
|
2633
|
+
* `tabId` - GUID of the Liveboard tab. Adds the Answer to the Liveboard tab
|
|
2634
|
+
* specified in the code.
|
|
2635
|
+
* @param
|
|
2636
|
+
* `newVizName` - Name string for the Answer or visualization. If defined,
|
|
2637
|
+
* this parameter adds a new visualization object or creates a copy of the
|
|
2638
|
+
* Answer or visualization specified in `vizId`.
|
|
2639
|
+
* Required attribute.
|
|
2640
|
+
* @param
|
|
2641
|
+
* `newLiveboardName` - Name string for the Liveboard.
|
|
2642
|
+
* Creates a new Liveboard object with the specified name.
|
|
2643
|
+
* @param
|
|
2644
|
+
* `newTabName` - Name of the tab. Adds a new tab Liveboard specified
|
|
2645
|
+
* in the code.
|
|
2646
|
+
*
|
|
2622
2647
|
* @example
|
|
2623
2648
|
* ```js
|
|
2624
|
-
* appEmbed.trigger(HostEvent.Pin
|
|
2649
|
+
* const pinResponse = await appEmbed.trigger(HostEvent.Pin, {
|
|
2650
|
+
* vizId: "123",
|
|
2651
|
+
* newVizName: "Sales by region",
|
|
2652
|
+
* liveboardId: "123",
|
|
2653
|
+
* tabId: "123"
|
|
2654
|
+
* });
|
|
2625
2655
|
* ```
|
|
2656
|
+
* @example
|
|
2626
2657
|
* ```js
|
|
2627
|
-
*
|
|
2658
|
+
* const pinResponse = await appEmbed.trigger(HostEvent.Pin, {
|
|
2659
|
+
* newVizName: "Total sales of Jackets",
|
|
2660
|
+
* liveboardId: "123"
|
|
2661
|
+
* });
|
|
2662
|
+
* ```
|
|
2663
|
+
*
|
|
2664
|
+
* @example
|
|
2665
|
+
* ```js
|
|
2666
|
+
* const pinResponse = await searchEmbed.trigger(HostEvent.Pin, {
|
|
2667
|
+
* newVizName: "Sales by state",
|
|
2668
|
+
* newLiveboardName: "Sales",
|
|
2669
|
+
* newTabName: "Products"
|
|
2670
|
+
* });
|
|
2671
|
+
* ```
|
|
2672
|
+
* @example
|
|
2673
|
+
* ```js
|
|
2674
|
+
* appEmbed.trigger(HostEvent.Pin)
|
|
2628
2675
|
* ```
|
|
2629
2676
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
2630
2677
|
*/
|
|
@@ -3280,8 +3327,25 @@ export enum HostEvent {
|
|
|
3280
3327
|
*/
|
|
3281
3328
|
InfoSuccess = 'InfoSuccess',
|
|
3282
3329
|
/**
|
|
3283
|
-
*
|
|
3284
|
-
*
|
|
3330
|
+
* Trigger the save action for an Answer.
|
|
3331
|
+
* To programmatically save an answer without opening the
|
|
3332
|
+
* *Describe your Answer* modal, define the `name` and `description`
|
|
3333
|
+
* properties.
|
|
3334
|
+
* If no parameters are specified, the save action is
|
|
3335
|
+
* triggered with a modal to prompt users to
|
|
3336
|
+
* add a name and description for the Answer.
|
|
3337
|
+
* @param - optional attributes to set Answer properties.
|
|
3338
|
+
* `name` - Name string for the Answer.
|
|
3339
|
+
* `description` - Description text for the Answer.
|
|
3340
|
+
*
|
|
3341
|
+
* @example
|
|
3342
|
+
* ```js
|
|
3343
|
+
* const saveAnswerResponse = await searchEmbed.trigger(HostEvent.SaveAnswer, {
|
|
3344
|
+
* name: "Sales by states",
|
|
3345
|
+
* description: "Total sales by states in MidWest"
|
|
3346
|
+
* });
|
|
3347
|
+
* ```
|
|
3348
|
+
* @version SDK: 1.36.0 | ThoughtSpot: 10.6.0.cl
|
|
3285
3349
|
*/
|
|
3286
3350
|
SaveAnswer = 'saveAnswer',
|
|
3287
3351
|
/**
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as authToken from '../authToken';
|
|
2
|
+
import { resetAllCachedServices } from './resetServices';
|
|
3
|
+
import * as sessionInfoService from './sessionInfoService';
|
|
4
|
+
|
|
5
|
+
describe('resetAllServices', () => {
|
|
6
|
+
it('should reset all services', () => {
|
|
7
|
+
const resetCachedAuthTokenSpy = jest.spyOn(authToken, 'resetCachedAuthToken');
|
|
8
|
+
const resetCachedSessionInfoSpy = jest.spyOn(sessionInfoService, 'resetCachedSessionInfo');
|
|
9
|
+
const resetCachedPreauthInfoSpy = jest.spyOn(sessionInfoService, 'resetCachedPreauthInfo');
|
|
10
|
+
resetAllCachedServices();
|
|
11
|
+
expect(resetCachedAuthTokenSpy).toHaveBeenCalled();
|
|
12
|
+
expect(resetCachedSessionInfoSpy).toHaveBeenCalled();
|
|
13
|
+
expect(resetCachedPreauthInfoSpy).toHaveBeenCalled();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resetCachedAuthToken } from '../authToken';
|
|
2
|
+
import { resetCachedPreauthInfo, resetCachedSessionInfo } from './sessionInfoService';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This function resets all the services that are cached in the SDK.
|
|
6
|
+
* This is to be called when the user logs out of the application and also
|
|
7
|
+
* when init is called again.
|
|
8
|
+
* @version SDK: 1.30.2 | ThoughtSpot: *
|
|
9
|
+
*/
|
|
10
|
+
export function resetAllCachedServices(): void {
|
|
11
|
+
resetCachedAuthToken();
|
|
12
|
+
resetCachedSessionInfo();
|
|
13
|
+
resetCachedPreauthInfo();
|
|
14
|
+
}
|
|
@@ -79,9 +79,10 @@ export async function getPreauthInfo(allowCache = true): Promise<PreauthInfo> {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
|
-
* Returns the session info object and caches it for future use.
|
|
82
|
+
* Returns the cached session info object and caches it for future use.
|
|
83
83
|
* Once fetched the session info object is cached and returned from the cache on
|
|
84
84
|
* subsequent calls.
|
|
85
|
+
* This cache is cleared when inti is called OR resetCachedSessionInfo is called.
|
|
85
86
|
* @example ```js
|
|
86
87
|
* const sessionInfo = await getSessionInfo();
|
|
87
88
|
* console.log(sessionInfo);
|
|
@@ -152,9 +153,23 @@ export const getSessionDetails = (sessionInfoResp: any): SessionInfo => {
|
|
|
152
153
|
* const sessionInfo = await getSessionInfo();
|
|
153
154
|
* console.log(sessionInfo);
|
|
154
155
|
* ```
|
|
155
|
-
* @version SDK: 1.28.3 | ThoughtSpot
|
|
156
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
156
157
|
* @returns {void}
|
|
157
158
|
*/
|
|
158
159
|
export function resetCachedSessionInfo(): void {
|
|
159
160
|
sessionInfo = null;
|
|
160
161
|
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Resets the cached preauth info object and forces a new fetch on the next call.
|
|
165
|
+
* @example ```js
|
|
166
|
+
* resetCachedPreauthInfo();
|
|
167
|
+
* const preauthInfo = await getPreauthInfo();
|
|
168
|
+
* console.log(preauthInfo);
|
|
169
|
+
* ```
|
|
170
|
+
* @version SDK: 1.28.3 | ThoughtSpot: *
|
|
171
|
+
* @returns {void}
|
|
172
|
+
*/
|
|
173
|
+
export function resetCachedPreauthInfo(): void {
|
|
174
|
+
preauthInfo = null;
|
|
175
|
+
}
|