Skip to content

Commit facf4a5

Browse files
SCAL-234606 Add forced token generation flags in embed sdk (#68)
1 parent f054a30 commit facf4a5

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

src/embed/liveboard.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,23 @@ describe('Liveboard/viz embed tests', () => {
172172
});
173173
});
174174

175+
test('should enable viz oAuthPollingInterval true', async () => {
176+
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
177+
oAuthPollingInterval: 1000,
178+
isForceRedirect: true,
179+
dataSourceId: '12356',
180+
...defaultViewConfig,
181+
liveboardId,
182+
} as LiveboardViewConfig);
183+
liveboardEmbed.render();
184+
await executeAfterWait(() => {
185+
expectUrlMatchesWithParams(
186+
getIFrameSrc(),
187+
`http://${thoughtSpotHost}/?embedApp=true${defaultParams}&oAuthPollingInterval=1000&isForceRedirect=true&dataSourceId=12356${prefixParams}#/embed/viz/${liveboardId}`,
188+
);
189+
});
190+
});
191+
175192
test('should disable viz transformations when enableVizTransformations false', async () => {
176193
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
177194
enableVizTransformations: false,

src/embed/liveboard.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,45 @@ export interface LiveboardViewConfig
338338
* ```
339339
*/
340340
hideIrrelevantChipsInLiveboardTabs?: boolean;
341+
342+
/**
343+
* The Liveboard to run on regular intervals to fetch the cdw token.
344+
* @hidden
345+
* @version SDK: 1.35.0 | ThoughtSpot:10.6.0.cl
346+
* @example
347+
* ```js
348+
* const embed = new LiveboardEmbed('#embed-container', {
349+
* ... // other options
350+
* oAuthPollingInterval: value in milliseconds,
351+
* })
352+
*/
353+
oAuthPollingInterval?: number;
354+
355+
/**
356+
* The Liveboard is set to force a token fetch during the initial load.
357+
* @hidden
358+
* @version SDK: 1.35.0 | ThoughtSpot:10.6.0.cl
359+
* @example
360+
* ```js
361+
* const embed = new LiveboardEmbed('#embed-container', {
362+
* ... // other options
363+
* isForceRedirect: false,
364+
* })
365+
*/
366+
isForceRedirect?: boolean;
367+
368+
/**
369+
* The source connection ID for authentication.
370+
* @hidden
371+
* @version SDK: 1.35.0 | ThoughtSpot:10.6.0.cl
372+
* @example
373+
* ```js
374+
* const embed = new LiveboardEmbed('#embed-container', {
375+
* ... // other options
376+
* dataSourceId: '',
377+
* })
378+
*/
379+
dataSourceId?: string;
341380
}
342381

343382
/**
@@ -399,6 +438,9 @@ export class LiveboardEmbed extends V1Embed {
399438
enable2ColumnLayout,
400439
dataPanelV2 = false,
401440
enableCustomColumnGroups = false,
441+
oAuthPollingInterval,
442+
isForceRedirect,
443+
dataSourceId,
402444
} = this.viewConfig;
403445

404446
const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval
@@ -445,6 +487,18 @@ export class LiveboardEmbed extends V1Embed {
445487
params[Param.enableAskSage] = enableAskSage;
446488
}
447489

490+
if (oAuthPollingInterval !== undefined) {
491+
params[Param.OauthPollingInterval] = oAuthPollingInterval;
492+
}
493+
494+
if (isForceRedirect) {
495+
params[Param.IsForceRedirect] = isForceRedirect;
496+
}
497+
498+
if (dataSourceId !== undefined) {
499+
params[Param.DataSourceId] = dataSourceId;
500+
}
501+
448502
params[Param.LiveboardHeaderSticky] = isLiveboardHeaderSticky;
449503
params[Param.LiveboardHeaderV2] = isLiveboardCompactHeaderEnabled;
450504
params[Param.ShowLiveboardVerifiedBadge] = showLiveboardVerifiedBadge;

src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3316,6 +3316,9 @@ export enum Param {
33163316
IsUnifiedSearchExperienceEnabled = 'isUnifiedSearchExperienceEnabled',
33173317
OverrideOrgId = 'orgId',
33183318
EnableFlipTooltipToContextMenu = 'flipTooltipToContextMenuEnabled',
3319+
OauthPollingInterval = 'oAuthPollingInterval',
3320+
IsForceRedirect = 'isForceRedirect',
3321+
DataSourceId = 'dataSourceId',
33193322
}
33203323

33213324
/**

0 commit comments

Comments
 (0)