@thoughtspot/visual-embed-sdk 1.8.0-plugins.6 → 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.
Files changed (42) hide show
  1. package/dist/src/embed/base.d.ts +4 -2
  2. package/dist/src/embed/liveboard.d.ts +1 -1
  3. package/dist/src/embed/search.d.ts +4 -0
  4. package/dist/src/embed/ts-embed.d.ts +2 -20
  5. package/dist/src/index.d.ts +2 -2
  6. package/dist/src/types.d.ts +15 -57
  7. package/dist/tsembed.es.js +15 -75
  8. package/dist/tsembed.js +15 -75
  9. package/lib/package.json +3 -2
  10. package/lib/src/embed/base.d.ts +4 -2
  11. package/lib/src/embed/base.js +4 -0
  12. package/lib/src/embed/base.js.map +1 -1
  13. package/lib/src/embed/liveboard.d.ts +1 -1
  14. package/lib/src/embed/search.d.ts +4 -0
  15. package/lib/src/embed/search.js +1 -4
  16. package/lib/src/embed/search.js.map +1 -1
  17. package/lib/src/embed/ts-embed.d.ts +2 -20
  18. package/lib/src/embed/ts-embed.js +2 -24
  19. package/lib/src/embed/ts-embed.js.map +1 -1
  20. package/lib/src/embed/ts-embed.spec.js +5 -24
  21. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  22. package/lib/src/index.d.ts +2 -2
  23. package/lib/src/index.js.map +1 -1
  24. package/lib/src/react/index.spec.js +1 -1
  25. package/lib/src/react/index.spec.js.map +1 -1
  26. package/lib/src/types.d.ts +15 -57
  27. package/lib/src/types.js +6 -46
  28. package/lib/src/types.js.map +1 -1
  29. package/lib/src/utils/processData.js +1 -1
  30. package/lib/src/utils/processData.js.map +1 -1
  31. package/lib/src/visual-embed-sdk.d.ts +28 -81
  32. package/package.json +3 -2
  33. package/src/embed/base.ts +6 -2
  34. package/src/embed/liveboard.ts +1 -1
  35. package/src/embed/search.ts +5 -3
  36. package/src/embed/ts-embed.spec.ts +6 -29
  37. package/src/embed/ts-embed.ts +2 -45
  38. package/src/index.ts +0 -2
  39. package/src/react/index.spec.tsx +1 -1
  40. package/src/types.ts +12 -58
  41. package/src/utils/processData.ts +1 -1
  42. package/src/utils/plugin.ts +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.8.0-plugins.6",
3
+ "version": "1.8.0",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
@@ -34,7 +34,7 @@
34
34
  "test": "npm run test-sdk && npm run test-docs && npx istanbul-merge --out ./coverage/coverage.json ./coverage/docs/coverage-final.json ./coverage/sdk/coverage-final.json && npx istanbul report --include ./coverage/coverage.json --dir ./coverage lcov",
35
35
  "posttest": "cat ./coverage/lcov.info | coveralls",
36
36
  "prepublishOnly": "npm run test; npm run tsc; npm run bundle-dts; npm run build",
37
- "publish-dev": "npm publish --tag plugins",
37
+ "publish-dev": "npm publish --tag dev",
38
38
  "publish-prod": "npm publish --tag latest"
39
39
  },
40
40
  "peerDependencies": {
@@ -65,6 +65,7 @@
65
65
  "asciidoctor": "^2.2.1",
66
66
  "babel-jest": "^26.6.3",
67
67
  "babel-preset-gatsby": "^1.10.0",
68
+ "classnames": "^2.3.1",
68
69
  "command-line-args": "^5.1.1",
69
70
  "coveralls": "^3.1.0",
70
71
  "dts-bundle": "0.7.3",
package/src/embed/base.ts CHANGED
@@ -19,12 +19,13 @@ export let authPromise: Promise<void>;
19
19
  /**
20
20
  * Perform authentication on the ThoughtSpot app as applicable.
21
21
  */
22
- export const handleAuth = (): void => {
22
+ export const handleAuth = (): Promise<void> => {
23
23
  const authConfig = {
24
24
  ...config,
25
25
  thoughtSpotHost: getThoughtSpotHost(config),
26
26
  };
27
27
  authPromise = authenticate(authConfig);
28
+ return authPromise;
28
29
  };
29
30
 
30
31
  export const getEmbedConfig = (): EmbedConfig => config;
@@ -55,8 +56,10 @@ export const prefetch = (url?: string): void => {
55
56
  * authentication if applicable.
56
57
  * @param embedConfig The configuration object containing ThoughtSpot host,
57
58
  * authentication mechanism and so on.
59
+ *
60
+ * @returns authPromise Promise which resolves when authentication is complete.
58
61
  */
59
- export const init = (embedConfig: EmbedConfig): void => {
62
+ export const init = (embedConfig: EmbedConfig): Promise<void> => {
60
63
  config = embedConfig;
61
64
  handleAuth();
62
65
 
@@ -68,6 +71,7 @@ export const init = (embedConfig: EmbedConfig): void => {
68
71
  if (config.callPrefetch) {
69
72
  prefetch(config.thoughtSpotHost);
70
73
  }
74
+ return authPromise;
71
75
  };
72
76
 
73
77
  let renderQueue: Promise<any> = Promise.resolve();
@@ -35,7 +35,7 @@ export interface LiveboardViewConfig extends ViewConfig {
35
35
  * This is the minimum height(in pixels) for a full height Liveboard.
36
36
  * Setting this height helps resolves issues with empty Liveboards and
37
37
  * other screens navigable from a Liveboard.
38
- * @version 1.5.0 or later
38
+ * *_since 1.5.0_
39
39
  * @default 500
40
40
  */
41
41
  defaultHeight?: number;
@@ -49,6 +49,10 @@ export interface SearchViewConfig extends ViewConfig {
49
49
  * using raw answer data.
50
50
  */
51
51
  hideResults?: boolean;
52
+ /**
53
+ * If set to true, expands all the data sources panel.
54
+ */
55
+ expandAllDataSource?: boolean;
52
56
  /**
53
57
  * If set to true, the Search Assist feature is enabled.
54
58
  */
@@ -80,9 +84,6 @@ export interface SearchViewConfig extends ViewConfig {
80
84
  export const HiddenActionItemByDefaultForSearchEmbed = [
81
85
  Action.EditACopy,
82
86
  Action.SaveAsView,
83
- Action.UpdateTML,
84
- Action.EditTML,
85
- Action.AnswerDelete,
86
87
  ];
87
88
 
88
89
  /**
@@ -126,6 +127,7 @@ export class SearchEmbed extends TsEmbed {
126
127
  private getIFrameSrc(answerId: string, dataSources?: string[]) {
127
128
  const {
128
129
  hideResults,
130
+ expandAllDataSource,
129
131
  enableSearchAssist,
130
132
  forceTable,
131
133
  searchOptions,
@@ -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
  });
@@ -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
- * @version 1.6.0 or later
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
  /**
@@ -149,8 +133,6 @@ export class TsEmbed {
149
133
 
150
134
  protected embedConfig: EmbedConfig;
151
135
 
152
- protected hasVizConfigOverride: boolean;
153
-
154
136
  /**
155
137
  * The ThoughtSpot hostname or IP address
156
138
  */
@@ -196,8 +178,6 @@ export class TsEmbed {
196
178
  this.isError = false;
197
179
  this.viewConfig = viewConfig;
198
180
  this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
199
- this.registerPlugins(viewConfig?.plugins);
200
-
201
181
  if (!this.embedConfig.suppressNoCookieAccessAlert) {
202
182
  this.on(EmbedEvent.NoCookieAccess, () => {
203
183
  // eslint-disable-next-line no-alert
@@ -208,18 +188,6 @@ export class TsEmbed {
208
188
  }
209
189
  }
210
190
 
211
- private registerPlugins(plugins: Plugin[]) {
212
- if (!plugins) {
213
- return;
214
- }
215
- plugins.forEach((plugin) => {
216
- Object.keys(plugin.handlers).forEach((eventName: EmbedEvent) => {
217
- const listener = plugin.handlers[eventName];
218
- this.on(eventName, listener);
219
- });
220
- });
221
- }
222
-
223
191
  /**
224
192
  * Gets a reference to the root DOM node where
225
193
  * the embedded content will appear.
@@ -359,7 +327,6 @@ export class TsEmbed {
359
327
  disabledActionReason,
360
328
  hiddenActions,
361
329
  visibleActions,
362
- additionalFlags,
363
330
  } = this.viewConfig;
364
331
 
365
332
  if (Array.isArray(visibleActions) && Array.isArray(hiddenActions)) {
@@ -381,12 +348,6 @@ export class TsEmbed {
381
348
  if (Array.isArray(visibleActions)) {
382
349
  queryParams[Param.VisibleActions] = visibleActions;
383
350
  }
384
- if (this.hasVizConfigOverride) {
385
- queryParams[Param.hasVizConfigOverride] = true;
386
- }
387
- if (additionalFlags && additionalFlags.constructor.name === 'Object') {
388
- Object.assign(queryParams, additionalFlags);
389
- }
390
351
  return queryParams;
391
352
  }
392
353
 
@@ -540,7 +501,7 @@ export class TsEmbed {
540
501
  ): void {
541
502
  const callbacks = this.eventHandlerMap.get(eventType) || [];
542
503
  callbacks.forEach((callback) =>
543
- callback.call(this, data, (payload) => {
504
+ callback(data, (payload) => {
544
505
  this.triggerEventOnPort(eventPort, payload);
545
506
  }),
546
507
  );
@@ -622,10 +583,6 @@ export class TsEmbed {
622
583
  );
623
584
  }
624
585
 
625
- if (messageType === EmbedEvent.GetVizConfigOverrides) {
626
- this.hasVizConfigOverride = true;
627
- }
628
-
629
586
  const callbacks = this.eventHandlerMap.get(messageType) || [];
630
587
  callbacks.push(callback);
631
588
  this.eventHandlerMap.set(messageType, callbacks);
package/src/index.ts CHANGED
@@ -25,7 +25,6 @@ import {
25
25
  DataSourceVisualMode,
26
26
  Action,
27
27
  EmbedConfig,
28
- Plugin,
29
28
  } from './types';
30
29
 
31
30
  export {
@@ -48,5 +47,4 @@ export {
48
47
  SearchViewConfig,
49
48
  LiveboardViewConfig,
50
49
  AppViewConfig,
51
- Plugin,
52
50
  };
@@ -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,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true#/embed/answer`,
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 true
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. The runtime filters passed here are extended
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',
@@ -482,7 +460,6 @@ export enum Param {
482
460
  ViewPortWidth = 'viewPortWidth',
483
461
  VisibleActions = 'visibleAction',
484
462
  CustomCSSUrl = 'customCssUrl',
485
- hasVizConfigOverride = 'hasVizConfigOverride',
486
463
  }
487
464
 
488
465
  /**
@@ -536,6 +513,10 @@ export enum Action {
536
513
  PinboardInfo = 'pinboardInfo',
537
514
  LiveboardInfo = 'pinboardInfo',
538
515
  SendAnswerFeedback = 'sendFeedback',
516
+ /**
517
+ * @deprecated Will be removed in next version
518
+ */
519
+ CustomAction = 'customAction',
539
520
  DownloadEmbraceQueries = 'downloadEmbraceQueries',
540
521
  Pin = 'pin',
541
522
  AnalysisInfo = 'analysisInfo',
@@ -551,26 +532,6 @@ export enum Action {
551
532
  DrillDown = 'DRILL',
552
533
  RequestAccess = 'requestAccess',
553
534
  QueryDetailsButtons = 'queryDetailsButtons',
554
- /**
555
- * @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
556
- */
557
- Monitor = 'createMonitor',
558
- /**
559
- * @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
560
- */
561
- AnswerDelete = 'onDeleteAnswer',
562
- /**
563
- * @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
564
- */
565
- AnswerChartSwitcher = 'answerChartSwitcher',
566
- /**
567
- * @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
568
- */
569
- AddToFavorites = 'addToFavorites',
570
- /**
571
- * @version SDK: 1.8.0 | ThoughtSpot: 8.1.0.cl
572
- */
573
- EditDetails = 'editDetails',
574
535
  }
575
536
 
576
537
  export interface SessionInterface {
@@ -588,10 +549,3 @@ export enum OperationType {
588
549
  export interface AnswerServiceType {
589
550
  getAnswer?: (offset: number, batchSize: number) => any;
590
551
  }
591
-
592
- export interface Plugin {
593
- name: string;
594
- handlers: {
595
- [key in EmbedEvent]?: (payload: any, cb: (data: any) => void) => void;
596
- };
597
- }
@@ -39,7 +39,7 @@ function processAuthInit(e: any) {
39
39
  }
40
40
 
41
41
  function processAuthExpire(e: any) {
42
- const { autoLogin = true } = getEmbedConfig(); // Set default to true
42
+ const { autoLogin = false } = getEmbedConfig(); // Set default to false
43
43
  if (autoLogin) {
44
44
  handleAuth();
45
45
  }
@@ -1,2 +0,0 @@
1
-
2
-