@thoughtspot/visual-embed-sdk 1.5.0 → 1.6.0-alpha.3

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 (66) hide show
  1. package/README.md +8 -8
  2. package/dist/src/embed/app.d.ts +14 -3
  3. package/dist/src/embed/liveboard.d.ts +101 -0
  4. package/dist/src/embed/liveboard.spec.d.ts +1 -0
  5. package/dist/src/embed/search.d.ts +0 -4
  6. package/dist/src/embed/ts-embed.d.ts +2 -11
  7. package/dist/src/errors.d.ts +1 -1
  8. package/dist/src/index.d.ts +2 -2
  9. package/dist/src/react/index.d.ts +4 -3
  10. package/dist/src/types.d.ts +22 -20
  11. package/dist/tsembed.es.js +83 -71
  12. package/dist/tsembed.js +82 -69
  13. package/lib/package.json +1 -2
  14. package/lib/src/embed/app.d.ts +14 -3
  15. package/lib/src/embed/app.js +25 -2
  16. package/lib/src/embed/app.js.map +1 -1
  17. package/lib/src/embed/app.spec.js +32 -0
  18. package/lib/src/embed/app.spec.js.map +1 -1
  19. package/lib/src/embed/events.spec.js +55 -2
  20. package/lib/src/embed/events.spec.js.map +1 -1
  21. package/lib/src/embed/liveboard.d.ts +101 -0
  22. package/lib/src/embed/liveboard.js +115 -0
  23. package/lib/src/embed/liveboard.js.map +1 -0
  24. package/lib/src/embed/liveboard.spec.d.ts +1 -0
  25. package/lib/src/embed/liveboard.spec.js +159 -0
  26. package/lib/src/embed/liveboard.spec.js.map +1 -0
  27. package/lib/src/embed/pinboard.spec.js +1 -1
  28. package/lib/src/embed/pinboard.spec.js.map +1 -1
  29. package/lib/src/embed/search.d.ts +0 -4
  30. package/lib/src/embed/search.js +1 -1
  31. package/lib/src/embed/search.js.map +1 -1
  32. package/lib/src/embed/ts-embed.d.ts +2 -11
  33. package/lib/src/embed/ts-embed.js +2 -22
  34. package/lib/src/embed/ts-embed.js.map +1 -1
  35. package/lib/src/embed/ts-embed.spec.js +63 -6
  36. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  37. package/lib/src/errors.d.ts +1 -1
  38. package/lib/src/errors.js +1 -1
  39. package/lib/src/errors.js.map +1 -1
  40. package/lib/src/index.d.ts +2 -2
  41. package/lib/src/index.js +2 -2
  42. package/lib/src/index.js.map +1 -1
  43. package/lib/src/react/index.d.ts +4 -3
  44. package/lib/src/react/index.js +3 -2
  45. package/lib/src/react/index.js.map +1 -1
  46. package/lib/src/types.d.ts +22 -20
  47. package/lib/src/types.js +19 -18
  48. package/lib/src/types.js.map +1 -1
  49. package/lib/src/utils/fetchAnswers.d.ts +3 -0
  50. package/lib/src/utils/fetchAnswers.js +49 -0
  51. package/lib/src/utils/fetchAnswers.js.map +1 -0
  52. package/lib/src/visual-embed-sdk.d.ts +78 -62
  53. package/package.json +1 -2
  54. package/src/embed/app.spec.ts +41 -0
  55. package/src/embed/app.ts +28 -3
  56. package/src/embed/events.spec.ts +64 -5
  57. package/src/embed/liveboard.spec.ts +199 -0
  58. package/src/embed/{pinboard.ts → liveboard.ts} +60 -42
  59. package/src/embed/pinboard.spec.ts +11 -11
  60. package/src/embed/search.ts +0 -5
  61. package/src/embed/ts-embed.spec.ts +81 -8
  62. package/src/embed/ts-embed.ts +3 -24
  63. package/src/errors.ts +2 -2
  64. package/src/index.ts +7 -2
  65. package/src/react/index.tsx +14 -8
  66. package/src/types.ts +22 -20
@@ -5,8 +5,9 @@ import {
5
5
  EmbedEvent,
6
6
  SearchEmbed,
7
7
  PinboardEmbed,
8
- PinboardViewConfig,
8
+ LiveboardViewConfig,
9
9
  AppEmbed,
10
+ LiveboardEmbed,
10
11
  } from '../index';
11
12
  import { Action } from '../types';
12
13
  import { getDocumentBody, getIFrameSrc, getRootEl } from '../test/test-utils';
@@ -24,6 +25,7 @@ const defaultViewConfig = {
24
25
  },
25
26
  };
26
27
  const pinboardId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
28
+ const liveboardId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
27
29
  const thoughtSpotHost = 'tshost';
28
30
  const defaultParamsForPinboardEmbed = `hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}`;
29
31
 
@@ -119,29 +121,78 @@ describe('Unit test case for ts embed', () => {
119
121
  });
120
122
 
121
123
  describe('when visible actions are set', () => {
122
- test('should throw error when there are both visible and hidden actions', async () => {
124
+ test('should throw error when there are both visible and hidden actions - pinboard', async () => {
123
125
  spyOn(console, 'log');
124
126
  const pinboardEmbed = new PinboardEmbed(getRootEl(), {
125
127
  hiddenActions: [Action.DownloadAsCsv],
126
128
  visibleActions: [Action.DownloadAsCsv],
127
129
  ...defaultViewConfig,
128
130
  pinboardId,
129
- } as PinboardViewConfig);
131
+ } as LiveboardViewConfig);
130
132
  await pinboardEmbed.render();
131
133
  expect(pinboardEmbed['isError']).toBe(true);
132
134
  expect(console.log).toHaveBeenCalledWith(
133
135
  'You cannot have both hidden actions and visible actions',
134
136
  );
135
137
  });
136
- test('should not throw error when there are only visible or hidden actions', async () => {
138
+ test('should not throw error when there are only visible or hidden actions - pinboard', async () => {
137
139
  const pinboardEmbed = new PinboardEmbed(getRootEl(), {
138
140
  hiddenActions: [Action.DownloadAsCsv],
139
141
  ...defaultViewConfig,
140
142
  pinboardId,
141
- } as PinboardViewConfig);
143
+ } as LiveboardViewConfig);
142
144
  pinboardEmbed.render();
143
145
  expect(pinboardEmbed['isError']).toBe(false);
144
146
  });
147
+
148
+ async function testActionsForLiveboards(
149
+ hiddenActions: Array<Action>,
150
+ visibleActions: Array<Action>,
151
+ ) {
152
+ spyOn(console, 'log');
153
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
154
+ hiddenActions,
155
+ visibleActions,
156
+ ...defaultViewConfig,
157
+ liveboardId,
158
+ } as LiveboardViewConfig);
159
+ await liveboardEmbed.render();
160
+ expect(liveboardEmbed['isError']).toBe(true);
161
+ expect(console.log).toHaveBeenCalledWith(
162
+ 'You cannot have both hidden actions and visible actions',
163
+ );
164
+ }
165
+ test('should throw error when there are both visible and hidden action arrays', async () => {
166
+ await testActionsForLiveboards(
167
+ [Action.DownloadAsCsv],
168
+ [Action.DownloadAsCsv],
169
+ );
170
+ });
171
+ test('should throw error when there are both visible and hidden actions arrays as empty', async () => {
172
+ await testActionsForLiveboards([], []);
173
+ });
174
+ test('should throw error when there are both visible and hidden actions - one of them is an empty array', async () => {
175
+ await testActionsForLiveboards([], [Action.DownloadAsCsv]);
176
+ });
177
+
178
+ test('should not throw error when there are only visible or hidden actions', async () => {
179
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
180
+ hiddenActions: [Action.DownloadAsCsv],
181
+ ...defaultViewConfig,
182
+ liveboardId,
183
+ } as LiveboardViewConfig);
184
+ liveboardEmbed.render();
185
+ expect(liveboardEmbed['isError']).toBe(false);
186
+ });
187
+ test('should not throw error when there are only visible or hidden actions', async () => {
188
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
189
+ visibleActions: [Action.DownloadAsCsv],
190
+ ...defaultViewConfig,
191
+ liveboardId,
192
+ } as LiveboardViewConfig);
193
+ liveboardEmbed.render();
194
+ expect(liveboardEmbed['isError']).toBe(false);
195
+ });
145
196
  });
146
197
 
147
198
  describe('when thoughtSpotHost is empty', () => {
@@ -180,7 +231,7 @@ describe('Unit test case for ts embed', () => {
180
231
  });
181
232
 
182
233
  describe('Naviage to Page API', () => {
183
- const path = 'pinboard/e0836cad-4fdf-42d4-bd97-567a6b2a6058';
234
+ const path = 'viz/e0836cad-4fdf-42d4-bd97-567a6b2a6058';
184
235
  beforeEach(() => {
185
236
  jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(
186
237
  () => 'http://tshost',
@@ -189,10 +240,10 @@ describe('Unit test case for ts embed', () => {
189
240
 
190
241
  test('when app is PinboardEmbed after navigateToPage function call, new path should be set to iframe', async () => {
191
242
  const pinboardEmbed = new PinboardEmbed(getRootEl(), {
192
- pinboardId: '123',
243
+ pinboardId: 'e0836cad-4fdf-42d4-bd97-567a6b2a6058',
193
244
  });
194
245
  await pinboardEmbed.render();
195
- pinboardEmbed.navigateToPage(path);
246
+ // pinboardEmbed.navigateToPage(path);
196
247
  expect(getIFrameSrc()).toBe(
197
248
  `http://${thoughtSpotHost}/?embedApp=true&${defaultParamsForPinboardEmbed}&isLiveboardEmbed=true#/embed/${path}`,
198
249
  );
@@ -227,4 +278,26 @@ describe('Unit test case for ts embed', () => {
227
278
  );
228
279
  });
229
280
  });
281
+ describe('Naviage to Page API - Pinboard', () => {
282
+ const path = 'pinboard/e0836cad-4fdf-42d4-bd97-567a6b2a6058';
283
+ beforeEach(() => {
284
+ jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(
285
+ () => 'http://tshost',
286
+ );
287
+ });
288
+
289
+ test('when app is AppEmbed after navigateToPage function call, new path should be set to iframe', async () => {
290
+ const appEmbed = new AppEmbed(getRootEl(), {
291
+ frameParams: {
292
+ width: '100%',
293
+ height: '100%',
294
+ },
295
+ });
296
+ await appEmbed.render();
297
+ appEmbed.navigateToPage(path);
298
+ expect(getIFrameSrc()).toBe(
299
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&${defaultParamsForPinboardEmbed}#/${path}`,
300
+ );
301
+ });
302
+ });
230
303
  });
@@ -105,7 +105,7 @@ export interface ViewConfig {
105
105
  visibleActions?: Action[];
106
106
  /**
107
107
  * The list of runtime filters to apply to a search answer,
108
- * visualization, or pinboard.
108
+ * visualization, or Liveboard.
109
109
  */
110
110
  runtimeFilters?: RuntimeFilter[];
111
111
  }
@@ -327,7 +327,7 @@ export class TsEmbed {
327
327
  visibleActions,
328
328
  } = this.viewConfig;
329
329
 
330
- if (visibleActions?.length && hiddenActions?.length) {
330
+ if (Array.isArray(visibleActions) && Array.isArray(hiddenActions)) {
331
331
  this.handleError(
332
332
  'You cannot have both hidden actions and visible actions',
333
333
  );
@@ -351,7 +351,7 @@ export class TsEmbed {
351
351
 
352
352
  /**
353
353
  * Constructs the base URL string to load v1 of the ThoughtSpot app.
354
- * This is used for embedding pinboards, visualizations, and full application.
354
+ * This is used for embedding Liveboards, visualizations, and full application.
355
355
  * @param queryString The query string to append to the URL.
356
356
  * @param isAppEmbed A Boolean parameter to specify if you are embedding
357
357
  * the full application.
@@ -587,27 +587,6 @@ export class TsEmbed {
587
587
  return this;
588
588
  }
589
589
 
590
- /**
591
- * Navigates users to the specified application page.
592
- * Use this method to navigate users from the embedded
593
- * ThoughtSpot context to a specific page in your app.
594
- * @param path The page path string.
595
- * For example, to navigate users to a pinboard page,
596
- * define the method as navigateToPage('pinboard/&lt;pinboardId&gt;').
597
- */
598
- public navigateToPage(path: string): void {
599
- const iframeSrc = this.iFrame?.src;
600
- if (iframeSrc) {
601
- const embedPath = '#/embed';
602
- const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
603
- this.iFrame.src = `${
604
- iframeSrc.split(currentPath)[0]
605
- }${currentPath}/${path.replace(/^\/?#?\//, '')}`;
606
- } else {
607
- console.log('Please call render before invoking this method');
608
- }
609
- }
610
-
611
590
  /**
612
591
  * Triggers an event on specific Port registered against
613
592
  * for the EmbedEvent
package/src/errors.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export const ERROR_MESSAGE = {
2
2
  INVALID_THOUGHTSPOT_HOST:
3
3
  'Error parsing ThoughtSpot host. Please provide a valid URL.',
4
- PINBOARD_VIZ_ID_VALIDATION:
5
- 'Please provide either pinboardId or both pinboardId and vizId',
4
+ LIVEBOARD_VIZ_ID_VALIDATION:
5
+ 'Please provide either liveboardId or pinboardId',
6
6
  };
package/src/index.ts CHANGED
@@ -10,7 +10,11 @@
10
10
 
11
11
  import { AppEmbed, Page, AppViewConfig } from './embed/app';
12
12
  import { init, prefetch } from './embed/base';
13
- import { PinboardEmbed, PinboardViewConfig } from './embed/pinboard';
13
+ import {
14
+ PinboardEmbed,
15
+ LiveboardViewConfig,
16
+ LiveboardEmbed,
17
+ } from './embed/liveboard';
14
18
  import { SearchEmbed, SearchViewConfig } from './embed/search';
15
19
  import {
16
20
  AuthType,
@@ -28,6 +32,7 @@ export {
28
32
  prefetch,
29
33
  SearchEmbed,
30
34
  PinboardEmbed,
35
+ LiveboardEmbed,
31
36
  AppEmbed,
32
37
  // types
33
38
  Page,
@@ -40,6 +45,6 @@ export {
40
45
  Action,
41
46
  EmbedConfig,
42
47
  SearchViewConfig,
43
- PinboardViewConfig,
48
+ LiveboardViewConfig,
44
49
  AppViewConfig,
45
50
  };
@@ -2,9 +2,9 @@ import React from 'react';
2
2
  import { SearchEmbed as _SearchEmbed, SearchViewConfig } from '../embed/search';
3
3
  import { AppEmbed as _AppEmbed, AppViewConfig } from '../embed/app';
4
4
  import {
5
- PinboardEmbed as _PinboardEmbed,
6
- PinboardViewConfig,
7
- } from '../embed/pinboard';
5
+ LiveboardEmbed as _LiveboardEmbed,
6
+ LiveboardViewConfig,
7
+ } from '../embed/liveboard';
8
8
  import { TsEmbed, ViewConfig } from '../embed/ts-embed';
9
9
 
10
10
  import { EmbedEvent, MessageCallback } from '../types';
@@ -55,10 +55,16 @@ export const AppEmbed = componentFactory<
55
55
  AppViewConfig
56
56
  >(_AppEmbed);
57
57
 
58
- interface PinboardProps extends EmbedProps, PinboardViewConfig {}
58
+ interface LiveboardProps extends EmbedProps, LiveboardViewConfig {}
59
+
60
+ export const LiveboardEmbed = componentFactory<
61
+ typeof _LiveboardEmbed,
62
+ LiveboardProps,
63
+ LiveboardViewConfig
64
+ >(_LiveboardEmbed);
59
65
 
60
66
  export const PinboardEmbed = componentFactory<
61
- typeof _PinboardEmbed,
62
- PinboardProps,
63
- PinboardViewConfig
64
- >(_PinboardEmbed);
67
+ typeof _LiveboardEmbed,
68
+ LiveboardProps,
69
+ LiveboardViewConfig
70
+ >(_LiveboardEmbed);
package/src/types.ts CHANGED
@@ -124,13 +124,14 @@ export interface EmbedConfig {
124
124
  * When there are multiple embeds, queue the render of embed to start
125
125
  * after the previous embed's render is complete. This helps in the load performance
126
126
  * by decreasing the load on the browser.
127
+ * * _Version 1.5.0 or later _
127
128
  * @default false
128
129
  */
129
130
  queueMultiRenders?: boolean;
130
131
 
131
132
  /**
132
133
  * Dynamic CSS Url to be injected in the loaded application.
133
- * _Since: 1.6.0_
134
+ * * _Version 1.6.0 or later _
134
135
  * @default ''
135
136
  */
136
137
  customCssUrl?: string;
@@ -212,7 +213,7 @@ export enum RuntimeFilterOp {
212
213
  }
213
214
 
214
215
  /**
215
- * A filter that can be applied to ThoughtSpot answers, pinboards, or
216
+ * A filter that can be applied to ThoughtSpot answers, Liveboards, or
216
217
  * visualizations at runtime.
217
218
  */
218
219
  export interface RuntimeFilter {
@@ -252,12 +253,12 @@ export enum EmbedEvent {
252
253
  */
253
254
  Load = 'load',
254
255
  /**
255
- * Data pertaining to answer or pinboard is received
256
- * @return data - The answer or pinboard data
256
+ * Data pertaining to answer or Liveboard is received
257
+ * @return data - The answer or Liveboard data
257
258
  */
258
259
  Data = 'data',
259
260
  /**
260
- * Search/answer/pinboard filters have been applied/updated
261
+ * Search/answer/Liveboard filters have been applied/updated
261
262
  * @hidden
262
263
  */
263
264
  FiltersChanged = 'filtersChanged',
@@ -280,13 +281,13 @@ export enum EmbedEvent {
280
281
  /**
281
282
  * A custom action has been triggered
282
283
  * @return actionId - The id of the custom action
283
- * @return data - The answer or pinboard data
284
+ * @return data - The answer or Liveboard data
284
285
  */
285
286
  CustomAction = 'customAction',
286
287
  /**
287
288
  * A double click has been triggered on table/chart
288
289
  * @return ContextMenuInputPoints - data point that is double clicked
289
- * * _since: 1.5.0_
290
+ * * _Version 1.5.0 or later _
290
291
  */
291
292
  VizPointDoubleClick = 'vizPointDoubleClick',
292
293
  /**
@@ -304,8 +305,8 @@ export enum EmbedEvent {
304
305
  */
305
306
  AuthExpire = 'ThoughtspotAuthExpired',
306
307
  /**
307
- * The height of the embedded pinboard or visualization has been computed.
308
- * @return data - The height of the embedded pinboard or visualization
308
+ * The height of the embedded Liveboard or visualization has been computed.
309
+ * @return data - The height of the embedded Liveboard or visualization
309
310
  * @hidden
310
311
  */
311
312
  EmbedHeight = 'EMBED_HEIGHT',
@@ -317,7 +318,6 @@ export enum EmbedEvent {
317
318
  EmbedIframeCenter = 'EmbedIframeCenter',
318
319
  /**
319
320
  * Detects the route change.
320
- * @hidden
321
321
  */
322
322
  RouteChange = 'ROUTE_CHANGE',
323
323
  /**
@@ -340,12 +340,12 @@ export enum EmbedEvent {
340
340
  SAMLComplete = 'samlComplete',
341
341
  /**
342
342
  * Emitted when any modal is opened in the app
343
- * * _since: 1.6.0_
343
+ * * _Version 1.6.0 or later _
344
344
  */
345
345
  DialogOpen = 'dialog-open',
346
346
  /**
347
347
  * Emitted when any modal is closed in the app
348
- * * _since: 1.6.0_
348
+ * * _Version 1.6.0 or later _
349
349
  */
350
350
  DialogClose = 'dialog-close',
351
351
  }
@@ -368,7 +368,7 @@ export enum HostEvent {
368
368
  * eg. { selectedPoints: []}
369
369
  * @param columnGuid - a string guid of the column to drill by. This is optional,
370
370
  * if not provided it will auto drill by the configured column. \
371
- * * _since: 1.5.0_
371
+ * * _Version 1.5.0 or later _
372
372
  */
373
373
  DrillDown = 'triggerDrillDown',
374
374
  /**
@@ -382,10 +382,10 @@ export enum HostEvent {
382
382
  */
383
383
  Reload = 'reload',
384
384
  /**
385
- * Set the visible Vizs on a pinboard/liveboard.
386
- * @param - an array of ids of vizs to show, the ids not passed
385
+ * Set the visible visualizations on a Liveboard.
386
+ * @param - an array of ids of visualizations to show, the ids not passed
387
387
  * will be hidden.
388
- * _since: 1.6.0_
388
+ * * _Version 1.6.0 or later _
389
389
  */
390
390
  SetVisibleVizs = 'SetPinboardVisibleVizs',
391
391
  }
@@ -418,11 +418,10 @@ export enum DataSourceVisualMode {
418
418
  export enum Param {
419
419
  DataSources = 'dataSources',
420
420
  DataSourceMode = 'dataSourceMode',
421
- ExpandAllDataSource = 'expandAllDataSource',
422
421
  DisableActions = 'disableAction',
423
422
  DisableActionReason = 'disableHint',
424
423
  ForceTable = 'forceTable',
425
- preventPinboardFilterRemoval = 'preventPinboardFilterRemoval',
424
+ preventLiveboardFilterRemoval = 'preventPinboardFilterRemoval', // update-TSCB
426
425
  SearchQuery = 'searchQuery',
427
426
  HideActions = 'hideAction',
428
427
  HideObjects = 'hideObjects',
@@ -445,7 +444,7 @@ export enum Param {
445
444
 
446
445
  /**
447
446
  * The list of actions that can be performed on visual ThoughtSpot
448
- * entities, such as answers and pinboards.
447
+ * entities, such as answers and Liveboards.
449
448
  */
450
449
  // eslint-disable-next-line no-shadow
451
450
  export enum Action {
@@ -456,7 +455,6 @@ export enum Action {
456
455
  MakeACopy = 'makeACopy',
457
456
  EditACopy = 'editACopy',
458
457
  CopyLink = 'embedDocument',
459
- PinboardSnapshot = 'pinboardSnapshot',
460
458
  ResetLayout = 'resetLayout',
461
459
  Schedule = 'schedule',
462
460
  SchedulesList = 'schedule-list',
@@ -489,7 +487,11 @@ export enum Action {
489
487
  Describe = 'describe',
490
488
  Relate = 'relate',
491
489
  CustomizeHeadlines = 'customizeHeadlines',
490
+ /**
491
+ * @hidden
492
+ */
492
493
  PinboardInfo = 'pinboardInfo',
494
+ LiveboardInfo = 'pinboardInfo',
493
495
  SendAnswerFeedback = 'sendFeedback',
494
496
  /**
495
497
  * @deprecated Will be removed in next version