@thoughtspot/visual-embed-sdk 1.8.0-plugins.4 → 1.8.0
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/dist/src/embed/base.d.ts +4 -2
- package/dist/src/embed/liveboard.d.ts +1 -1
- package/dist/src/embed/search.d.ts +4 -0
- package/dist/src/embed/ts-embed.d.ts +2 -19
- package/dist/src/index.d.ts +2 -2
- package/dist/src/types.d.ts +14 -55
- package/dist/tsembed.es.js +14 -67
- package/dist/tsembed.js +14 -67
- package/lib/package.json +3 -2
- package/lib/src/embed/base.d.ts +4 -2
- package/lib/src/embed/base.js +4 -0
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +1 -1
- package/lib/src/embed/search.d.ts +4 -0
- package/lib/src/embed/search.js +1 -4
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +2 -19
- package/lib/src/embed/ts-embed.js +1 -17
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +5 -24
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/index.spec.js +1 -1
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +14 -55
- package/lib/src/types.js +6 -45
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/processData.js +1 -1
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +27 -78
- package/package.json +3 -2
- package/src/embed/base.ts +6 -2
- package/src/embed/liveboard.ts +1 -1
- package/src/embed/search.ts +5 -3
- package/src/embed/ts-embed.spec.ts +6 -29
- package/src/embed/ts-embed.ts +1 -35
- package/src/index.ts +0 -2
- package/src/react/index.spec.tsx +1 -1
- package/src/types.ts +12 -57
- package/src/utils/processData.ts +1 -1
- package/src/utils/plugin.ts +0 -2
|
@@ -34,9 +34,6 @@ describe('Unit test case for ts embed', () => {
|
|
|
34
34
|
mixpanelInstance,
|
|
35
35
|
'uploadMixpanelEvent',
|
|
36
36
|
);
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
document.body.innerHTML = getDocumentBody();
|
|
39
|
-
});
|
|
40
37
|
describe('when thoughtSpotHost have value and authPromise return success response', () => {
|
|
41
38
|
beforeAll(() => {
|
|
42
39
|
init({
|
|
@@ -46,6 +43,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
46
43
|
});
|
|
47
44
|
|
|
48
45
|
beforeEach(() => {
|
|
46
|
+
document.body.innerHTML = getDocumentBody();
|
|
49
47
|
jest.spyOn(window, 'addEventListener').mockImplementationOnce(
|
|
50
48
|
(event, handler, options) => {
|
|
51
49
|
handler({
|
|
@@ -100,6 +98,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
100
98
|
});
|
|
101
99
|
|
|
102
100
|
beforeEach(() => {
|
|
101
|
+
document.body.innerHTML = getDocumentBody();
|
|
103
102
|
jest.spyOn(
|
|
104
103
|
baseInstance,
|
|
105
104
|
'getAuthPromise',
|
|
@@ -207,6 +206,10 @@ describe('Unit test case for ts embed', () => {
|
|
|
207
206
|
});
|
|
208
207
|
});
|
|
209
208
|
|
|
209
|
+
beforeEach(() => {
|
|
210
|
+
document.body.innerHTML = getDocumentBody();
|
|
211
|
+
});
|
|
212
|
+
|
|
210
213
|
test('Error should be true', async () => {
|
|
211
214
|
const tsEmbed = new SearchEmbed(getRootEl(), {});
|
|
212
215
|
tsEmbed.render();
|
|
@@ -297,30 +300,4 @@ describe('Unit test case for ts embed', () => {
|
|
|
297
300
|
);
|
|
298
301
|
});
|
|
299
302
|
});
|
|
300
|
-
|
|
301
|
-
describe('additionalFlags config', () => {
|
|
302
|
-
beforeEach(() => {
|
|
303
|
-
jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(
|
|
304
|
-
() => 'http://tshost',
|
|
305
|
-
);
|
|
306
|
-
});
|
|
307
|
-
it('should set the additional flags correctly on the iframe src', async () => {
|
|
308
|
-
const appEmbed = new AppEmbed(getRootEl(), {
|
|
309
|
-
frameParams: {
|
|
310
|
-
width: '100%',
|
|
311
|
-
height: '100%',
|
|
312
|
-
},
|
|
313
|
-
additionalFlags: {
|
|
314
|
-
foo: 'bar',
|
|
315
|
-
baz: 1,
|
|
316
|
-
bool: true,
|
|
317
|
-
},
|
|
318
|
-
});
|
|
319
|
-
await appEmbed.render();
|
|
320
|
-
expect(getIFrameSrc()).toBe(
|
|
321
|
-
`http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}` +
|
|
322
|
-
'&foo=bar&baz=1&bool=true#/home',
|
|
323
|
-
);
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
303
|
});
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -28,12 +28,10 @@ import {
|
|
|
28
28
|
RuntimeFilter,
|
|
29
29
|
Param,
|
|
30
30
|
EmbedConfig,
|
|
31
|
-
Plugin,
|
|
32
31
|
} from '../types';
|
|
33
32
|
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
|
|
34
33
|
import { getProcessData } from '../utils/processData';
|
|
35
34
|
import { processTrigger } from '../utils/processTrigger';
|
|
36
|
-
// eslint-disable-next-line import/no-cycle
|
|
37
35
|
import pkgInfo from '../../package.json';
|
|
38
36
|
import { getAuthPromise, getEmbedConfig, renderInQueue } from './base';
|
|
39
37
|
|
|
@@ -104,7 +102,7 @@ export interface ViewConfig {
|
|
|
104
102
|
/**
|
|
105
103
|
* The list of actions to display from the primary menu, more menu
|
|
106
104
|
* (...), and the contextual menu.
|
|
107
|
-
*
|
|
105
|
+
* * _since 1.6.0_
|
|
108
106
|
*/
|
|
109
107
|
visibleActions?: Action[];
|
|
110
108
|
/**
|
|
@@ -112,20 +110,6 @@ export interface ViewConfig {
|
|
|
112
110
|
* visualization, or Liveboard.
|
|
113
111
|
*/
|
|
114
112
|
runtimeFilters?: RuntimeFilter[];
|
|
115
|
-
/**
|
|
116
|
-
* This is an object (key/val) of override flags which will be applied
|
|
117
|
-
* to the internal embedded object. This can be used to add any
|
|
118
|
-
* URL flag.
|
|
119
|
-
* @version 1.8.0
|
|
120
|
-
*/
|
|
121
|
-
additionalFlags?: { [key: string]: string | number | boolean };
|
|
122
|
-
/**
|
|
123
|
-
* Provide a list of plugins, the plugins are executed in the order
|
|
124
|
-
* provided below,
|
|
125
|
-
*
|
|
126
|
-
* @version alpha
|
|
127
|
-
*/
|
|
128
|
-
plugins?: Plugin[];
|
|
129
113
|
}
|
|
130
114
|
|
|
131
115
|
/**
|
|
@@ -194,8 +178,6 @@ export class TsEmbed {
|
|
|
194
178
|
this.isError = false;
|
|
195
179
|
this.viewConfig = viewConfig;
|
|
196
180
|
this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
|
|
197
|
-
this.registerPlugins(viewConfig?.plugins);
|
|
198
|
-
|
|
199
181
|
if (!this.embedConfig.suppressNoCookieAccessAlert) {
|
|
200
182
|
this.on(EmbedEvent.NoCookieAccess, () => {
|
|
201
183
|
// eslint-disable-next-line no-alert
|
|
@@ -206,18 +188,6 @@ export class TsEmbed {
|
|
|
206
188
|
}
|
|
207
189
|
}
|
|
208
190
|
|
|
209
|
-
private registerPlugins(plugins: Plugin[]) {
|
|
210
|
-
if (!plugins) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
plugins.forEach((plugin) => {
|
|
214
|
-
Object.keys(plugin.handlers).forEach((eventName: EmbedEvent) => {
|
|
215
|
-
const listener = plugin[eventName];
|
|
216
|
-
this.on(eventName, listener);
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
|
|
221
191
|
/**
|
|
222
192
|
* Gets a reference to the root DOM node where
|
|
223
193
|
* the embedded content will appear.
|
|
@@ -357,7 +327,6 @@ export class TsEmbed {
|
|
|
357
327
|
disabledActionReason,
|
|
358
328
|
hiddenActions,
|
|
359
329
|
visibleActions,
|
|
360
|
-
additionalFlags,
|
|
361
330
|
} = this.viewConfig;
|
|
362
331
|
|
|
363
332
|
if (Array.isArray(visibleActions) && Array.isArray(hiddenActions)) {
|
|
@@ -379,9 +348,6 @@ export class TsEmbed {
|
|
|
379
348
|
if (Array.isArray(visibleActions)) {
|
|
380
349
|
queryParams[Param.VisibleActions] = visibleActions;
|
|
381
350
|
}
|
|
382
|
-
if (additionalFlags && additionalFlags.constructor.name === 'Object') {
|
|
383
|
-
Object.assign(queryParams, additionalFlags);
|
|
384
|
-
}
|
|
385
351
|
return queryParams;
|
|
386
352
|
}
|
|
387
353
|
|
package/src/index.ts
CHANGED
package/src/react/index.spec.tsx
CHANGED
|
@@ -31,7 +31,7 @@ describe('React Components', () => {
|
|
|
31
31
|
await waitFor(() => getIFrameEl(container));
|
|
32
32
|
|
|
33
33
|
expect(getIFrameSrc(container)).toBe(
|
|
34
|
-
`http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&hideAction=[%22editACopy%22,%22saveAsView%22
|
|
34
|
+
`http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&hideAction=[%22editACopy%22,%22saveAsView%22]&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true#/embed/answer`,
|
|
35
35
|
);
|
|
36
36
|
});
|
|
37
37
|
|
package/src/types.ts
CHANGED
|
@@ -68,6 +68,11 @@ export interface EmbedConfig {
|
|
|
68
68
|
* and returns a Promise that resolves to the `auth token` string.
|
|
69
69
|
* For trusted authentication, the `authEndpoint` or `getAuthToken`
|
|
70
70
|
* attribute is required.
|
|
71
|
+
*
|
|
72
|
+
* It is advisable to fetch a new token inside this method and not
|
|
73
|
+
* reuse and older issued token, as because when auth expires this is
|
|
74
|
+
* called again and if it is called with an older token the authentication
|
|
75
|
+
* will not succeed.
|
|
71
76
|
*/
|
|
72
77
|
getAuthToken?: () => Promise<string>;
|
|
73
78
|
/**
|
|
@@ -114,7 +119,7 @@ export interface EmbedConfig {
|
|
|
114
119
|
|
|
115
120
|
/**
|
|
116
121
|
* Re-login when session expires with the previous login options
|
|
117
|
-
* @default
|
|
122
|
+
* @default false
|
|
118
123
|
*/
|
|
119
124
|
autoLogin?: boolean;
|
|
120
125
|
|
|
@@ -135,7 +140,6 @@ export interface EmbedConfig {
|
|
|
135
140
|
|
|
136
141
|
/**
|
|
137
142
|
* Dynamic CSS Url to be injected in the loaded application.
|
|
138
|
-
* You would also need to set `style-src` in the CSP settings.
|
|
139
143
|
* @version 1.6.0 or later
|
|
140
144
|
* @default ''
|
|
141
145
|
*/
|
|
@@ -283,39 +287,18 @@ export enum EmbedEvent {
|
|
|
283
287
|
* @return dataSourceIds - the list of data sources
|
|
284
288
|
*/
|
|
285
289
|
DataSourceSelected = 'dataSourceSelected',
|
|
286
|
-
/**
|
|
287
|
-
* One or more data columns have been selected.
|
|
288
|
-
* @return columnIds - the list of columns
|
|
289
|
-
* @version SDK: 1.9.0 | ThoughtSpot: 8.2.0.cl
|
|
290
|
-
*/
|
|
291
|
-
AddRemoveColumns = 'addRemoveColumns',
|
|
292
290
|
/**
|
|
293
291
|
* A custom action has been triggered
|
|
294
292
|
* @return actionId - The id of the custom action
|
|
295
293
|
* @return data - The answer or Liveboard data
|
|
296
294
|
*/
|
|
297
295
|
CustomAction = 'customAction',
|
|
298
|
-
/**
|
|
299
|
-
* A click has been triggered on table/chart
|
|
300
|
-
* @return ContextMenuInputPoints - data point that is double clicked
|
|
301
|
-
* @version 1.10.0
|
|
302
|
-
*/
|
|
303
|
-
VizPointClick = 'vizPointClick',
|
|
304
|
-
|
|
305
296
|
/**
|
|
306
297
|
* A double click has been triggered on table/chart
|
|
307
298
|
* @return ContextMenuInputPoints - data point that is double clicked
|
|
308
299
|
* @version 1.5.0 or later
|
|
309
300
|
*/
|
|
310
301
|
VizPointDoubleClick = 'vizPointDoubleClick',
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Event troggered when rendering a chart, call the supplied
|
|
314
|
-
* callback with the config overrides.
|
|
315
|
-
* @version 1.10.0
|
|
316
|
-
*/
|
|
317
|
-
GetVizConfigOverrides = 'getVizConfigOverrides',
|
|
318
|
-
|
|
319
302
|
/**
|
|
320
303
|
* An error has occurred.
|
|
321
304
|
* @return error - An error object or message
|
|
@@ -418,17 +401,11 @@ export enum HostEvent {
|
|
|
418
401
|
*/
|
|
419
402
|
SetVisibleVizs = 'SetPinboardVisibleVizs',
|
|
420
403
|
/**
|
|
421
|
-
* Update the runtime filters
|
|
422
|
-
* on to the existing runtime filters if they exist.
|
|
404
|
+
* Update the runtime filters
|
|
423
405
|
* @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
|
|
424
406
|
* @version 1.8.0 or later
|
|
425
407
|
*/
|
|
426
408
|
UpdateRuntimeFilters = 'UpdateRuntimeFilters',
|
|
427
|
-
/**
|
|
428
|
-
* Highlight the point in the chart defined by the InputPoint passed.
|
|
429
|
-
* @verion 1.10.0
|
|
430
|
-
*/
|
|
431
|
-
HighlightPoint = 'HighlightPoint',
|
|
432
409
|
}
|
|
433
410
|
|
|
434
411
|
/**
|
|
@@ -459,6 +436,7 @@ export enum DataSourceVisualMode {
|
|
|
459
436
|
export enum Param {
|
|
460
437
|
DataSources = 'dataSources',
|
|
461
438
|
DataSourceMode = 'dataSourceMode',
|
|
439
|
+
ExpandAllDataSource = 'expandAllDataSource',
|
|
462
440
|
DisableActions = 'disableAction',
|
|
463
441
|
DisableActionReason = 'disableHint',
|
|
464
442
|
ForceTable = 'forceTable',
|
|
@@ -535,6 +513,10 @@ export enum Action {
|
|
|
535
513
|
PinboardInfo = 'pinboardInfo',
|
|
536
514
|
LiveboardInfo = 'pinboardInfo',
|
|
537
515
|
SendAnswerFeedback = 'sendFeedback',
|
|
516
|
+
/**
|
|
517
|
+
* @deprecated Will be removed in next version
|
|
518
|
+
*/
|
|
519
|
+
CustomAction = 'customAction',
|
|
538
520
|
DownloadEmbraceQueries = 'downloadEmbraceQueries',
|
|
539
521
|
Pin = 'pin',
|
|
540
522
|
AnalysisInfo = 'analysisInfo',
|
|
@@ -550,26 +532,6 @@ export enum Action {
|
|
|
550
532
|
DrillDown = 'DRILL',
|
|
551
533
|
RequestAccess = 'requestAccess',
|
|
552
534
|
QueryDetailsButtons = 'queryDetailsButtons',
|
|
553
|
-
/**
|
|
554
|
-
* @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
|
|
555
|
-
*/
|
|
556
|
-
Monitor = 'createMonitor',
|
|
557
|
-
/**
|
|
558
|
-
* @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
|
|
559
|
-
*/
|
|
560
|
-
AnswerDelete = 'onDeleteAnswer',
|
|
561
|
-
/**
|
|
562
|
-
* @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
|
|
563
|
-
*/
|
|
564
|
-
AnswerChartSwitcher = 'answerChartSwitcher',
|
|
565
|
-
/**
|
|
566
|
-
* @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
|
|
567
|
-
*/
|
|
568
|
-
AddToFavorites = 'addToFavorites',
|
|
569
|
-
/**
|
|
570
|
-
* @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
|
|
571
|
-
*/
|
|
572
|
-
EditDetails = 'editDetails',
|
|
573
535
|
}
|
|
574
536
|
|
|
575
537
|
export interface SessionInterface {
|
|
@@ -587,10 +549,3 @@ export enum OperationType {
|
|
|
587
549
|
export interface AnswerServiceType {
|
|
588
550
|
getAnswer?: (offset: number, batchSize: number) => any;
|
|
589
551
|
}
|
|
590
|
-
|
|
591
|
-
export interface Plugin {
|
|
592
|
-
name: string;
|
|
593
|
-
handlers: {
|
|
594
|
-
[key in EmbedEvent]?: (payload: any, cb: (data: any) => void) => void;
|
|
595
|
-
};
|
|
596
|
-
}
|
package/src/utils/processData.ts
CHANGED
|
@@ -39,7 +39,7 @@ function processAuthInit(e: any) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function processAuthExpire(e: any) {
|
|
42
|
-
const { autoLogin =
|
|
42
|
+
const { autoLogin = false } = getEmbedConfig(); // Set default to false
|
|
43
43
|
if (autoLogin) {
|
|
44
44
|
handleAuth();
|
|
45
45
|
}
|
package/src/utils/plugin.ts
DELETED