@thoughtspot/visual-embed-sdk 1.23.0-alpha.0 → 1.23.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 (86) hide show
  1. package/README.md +1 -1
  2. package/cjs/package.json +8 -1
  3. package/cjs/src/css-variables.d.ts +1 -1
  4. package/cjs/src/css-variables.d.ts.map +1 -1
  5. package/cjs/src/embed/liveboard.d.ts +6 -0
  6. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  7. package/cjs/src/embed/liveboard.js +4 -1
  8. package/cjs/src/embed/liveboard.js.map +1 -1
  9. package/cjs/src/embed/liveboard.spec.js +12 -0
  10. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  11. package/cjs/src/embed/sage.d.ts +1 -0
  12. package/cjs/src/embed/sage.d.ts.map +1 -1
  13. package/cjs/src/embed/sage.js +1 -0
  14. package/cjs/src/embed/sage.js.map +1 -1
  15. package/cjs/src/embed/search.d.ts +4 -0
  16. package/cjs/src/embed/search.d.ts.map +1 -1
  17. package/cjs/src/embed/search.js +1 -1
  18. package/cjs/src/embed/search.js.map +1 -1
  19. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  20. package/cjs/src/embed/ts-embed.js +11 -1
  21. package/cjs/src/embed/ts-embed.js.map +1 -1
  22. package/cjs/src/embed/ts-embed.spec.js +69 -0
  23. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  24. package/cjs/src/react/index.spec.js +12 -0
  25. package/cjs/src/react/index.spec.js.map +1 -1
  26. package/cjs/src/types.d.ts +869 -213
  27. package/cjs/src/types.d.ts.map +1 -1
  28. package/cjs/src/types.js +827 -194
  29. package/cjs/src/types.js.map +1 -1
  30. package/dist/src/css-variables.d.ts +1 -1
  31. package/dist/src/css-variables.d.ts.map +1 -1
  32. package/dist/src/embed/liveboard.d.ts +6 -0
  33. package/dist/src/embed/liveboard.d.ts.map +1 -1
  34. package/dist/src/embed/sage.d.ts +1 -0
  35. package/dist/src/embed/sage.d.ts.map +1 -1
  36. package/dist/src/embed/search.d.ts +4 -0
  37. package/dist/src/embed/search.d.ts.map +1 -1
  38. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  39. package/dist/src/types.d.ts +869 -213
  40. package/dist/src/types.d.ts.map +1 -1
  41. package/dist/tsembed-react.es.js +845 -198
  42. package/dist/tsembed-react.js +826 -189
  43. package/dist/tsembed.es.js +845 -198
  44. package/dist/tsembed.js +826 -189
  45. package/dist/visual-embed-sdk-react-full.d.ts +881 -214
  46. package/dist/visual-embed-sdk-react.d.ts +881 -214
  47. package/dist/visual-embed-sdk.d.ts +881 -214
  48. package/lib/package.json +8 -1
  49. package/lib/src/css-variables.d.ts +1 -1
  50. package/lib/src/css-variables.d.ts.map +1 -1
  51. package/lib/src/embed/liveboard.d.ts +6 -0
  52. package/lib/src/embed/liveboard.d.ts.map +1 -1
  53. package/lib/src/embed/liveboard.js +4 -1
  54. package/lib/src/embed/liveboard.js.map +1 -1
  55. package/lib/src/embed/liveboard.spec.js +12 -0
  56. package/lib/src/embed/liveboard.spec.js.map +1 -1
  57. package/lib/src/embed/sage.d.ts +1 -0
  58. package/lib/src/embed/sage.d.ts.map +1 -1
  59. package/lib/src/embed/sage.js +1 -0
  60. package/lib/src/embed/sage.js.map +1 -1
  61. package/lib/src/embed/search.d.ts +4 -0
  62. package/lib/src/embed/search.d.ts.map +1 -1
  63. package/lib/src/embed/search.js +1 -1
  64. package/lib/src/embed/search.js.map +1 -1
  65. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  66. package/lib/src/embed/ts-embed.js +11 -1
  67. package/lib/src/embed/ts-embed.js.map +1 -1
  68. package/lib/src/embed/ts-embed.spec.js +69 -0
  69. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  70. package/lib/src/react/index.spec.js +12 -0
  71. package/lib/src/react/index.spec.js.map +1 -1
  72. package/lib/src/types.d.ts +869 -213
  73. package/lib/src/types.d.ts.map +1 -1
  74. package/lib/src/types.js +827 -194
  75. package/lib/src/types.js.map +1 -1
  76. package/lib/src/visual-embed-sdk.d.ts +881 -214
  77. package/package.json +8 -1
  78. package/src/css-variables.ts +1 -1
  79. package/src/embed/liveboard.spec.ts +16 -0
  80. package/src/embed/liveboard.ts +10 -0
  81. package/src/embed/sage.ts +1 -0
  82. package/src/embed/search.ts +5 -0
  83. package/src/embed/ts-embed.spec.ts +79 -0
  84. package/src/embed/ts-embed.ts +13 -1
  85. package/src/react/index.spec.tsx +29 -0
  86. package/src/types.ts +883 -213
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.23.0-alpha.0",
3
+ "version": "1.23.0",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
@@ -35,6 +35,13 @@
35
35
  ]
36
36
  }
37
37
  },
38
+ "typesVersions": {
39
+ "*": {
40
+ "react": [
41
+ "./lib/src/react/index.d.ts"
42
+ ]
43
+ }
44
+ },
38
45
  "scripts": {
39
46
  "lint": "eslint 'src/**'",
40
47
  "lint:fix": "eslint 'src/**/*.*' --fix",
@@ -149,7 +149,7 @@ export interface CustomCssVariables {
149
149
  * Background color of the primary buttons. For example, the primary buttons such as
150
150
  * Pin* and *Save*.
151
151
  */
152
- '---ts-var-button--primary-background'?: string;
152
+ '--ts-var-button--primary-background'?: string;
153
153
 
154
154
  /**
155
155
  * Background color of the primary buttons on hover.
@@ -302,6 +302,22 @@ describe('Liveboard/viz embed tests', () => {
302
302
  });
303
303
  });
304
304
 
305
+ test('Should set hideTabPanel option', async () => {
306
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
307
+ liveboardId,
308
+ activeTabId,
309
+ liveboardV2: true,
310
+ hideTabPanel: true,
311
+ } as LiveboardViewConfig);
312
+ liveboardEmbed.render();
313
+ await executeAfterWait(() => {
314
+ expectUrlMatchesWithParams(
315
+ getIFrameSrc(),
316
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&hideTabPanel=true&isLiveboardEmbed=true&isPinboardV2Enabled=true#/embed/viz/${liveboardId}/tab/${activeTabId}`,
317
+ );
318
+ });
319
+ });
320
+
305
321
  test('navigateToLiveboard should trigger the navigate event with the correct path', (done) => {
306
322
  mockMessageChannel();
307
323
  const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
@@ -99,6 +99,12 @@ export interface LiveboardViewConfig extends ViewConfig {
99
99
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
100
100
  */
101
101
  activeTabId?: string;
102
+ /**
103
+ * Hide tab Panel of embedded LB
104
+ *
105
+ * @version SDK: 1.25.0 | Thoughtspot: 9.6.0.cl
106
+ */
107
+ hideTabPanel?: boolean;
102
108
  }
103
109
 
104
110
  /**
@@ -146,6 +152,7 @@ export class LiveboardEmbed extends V1Embed {
146
152
  visibleVizs,
147
153
  liveboardV2,
148
154
  vizId,
155
+ hideTabPanel,
149
156
  activeTabId,
150
157
  } = this.viewConfig;
151
158
 
@@ -174,6 +181,9 @@ export class LiveboardEmbed extends V1Embed {
174
181
  if (liveboardV2 !== undefined) {
175
182
  params[Param.LiveboardV2Enabled] = liveboardV2;
176
183
  }
184
+ if (hideTabPanel) {
185
+ params[Param.HideTabPanel] = hideTabPanel;
186
+ }
177
187
  const queryParams = getQueryParamString(params, true);
178
188
 
179
189
  return queryParams;
package/src/embed/sage.ts CHANGED
@@ -51,6 +51,7 @@ export const HiddenActionItemByDefaultForSageEmbed = [
51
51
  /**
52
52
  * Embed ThoughtSpot LLM and GPT based natural language search component.
53
53
  *
54
+ * @version: SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl, 9.5.1-sw
54
55
  * @group Embed components
55
56
  */
56
57
  export class SageEmbed extends V1Embed {
@@ -60,6 +60,10 @@ export interface SearchViewConfig extends ViewConfig {
60
60
  * using raw answer data.
61
61
  */
62
62
  hideResults?: boolean;
63
+ /**
64
+ * If set to true, expands all the data sources panel.
65
+ */
66
+ expandAllDataSource?: boolean;
63
67
  /**
64
68
  * If set to true, the Search Assist feature is enabled.
65
69
  *
@@ -150,6 +154,7 @@ export class SearchEmbed extends TsEmbed {
150
154
  protected getEmbedParams(): string {
151
155
  const {
152
156
  hideResults,
157
+ expandAllDataSource,
153
158
  enableSearchAssist,
154
159
  forceTable,
155
160
  searchOptions,
@@ -36,6 +36,8 @@ const defaultViewConfig = {
36
36
  };
37
37
  const pinboardId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
38
38
  const liveboardId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
39
+ const tabId1 = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
40
+ const tabId2 = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
39
41
  const thoughtSpotHost = 'tshost';
40
42
  const defaultParamsPost = '';
41
43
 
@@ -582,6 +584,83 @@ describe('Unit test case for ts embed', () => {
582
584
  });
583
585
  });
584
586
 
587
+ describe('when visible Tabs are set', () => {
588
+ test('should throw error when there are both visible and hidden Tabs - pinboard', async () => {
589
+ spyOn(console, 'error');
590
+ const pinboardEmbed = new PinboardEmbed(getRootEl(), {
591
+ visibleTabs: [tabId1],
592
+ hiddenTabs: [tabId2],
593
+ ...defaultViewConfig,
594
+ pinboardId,
595
+ } as LiveboardViewConfig);
596
+ await pinboardEmbed.render();
597
+ expect(pinboardEmbed['isError']).toBe(true);
598
+ expect(console.error).toHaveBeenCalledWith(
599
+ 'You cannot have both hidden Tabs and visible Tabs',
600
+ );
601
+ });
602
+ test('should not throw error when there are only visible or hidden Tabs - pinboard', async () => {
603
+ const pinboardEmbed = new PinboardEmbed(getRootEl(), {
604
+ hiddenTabs: [tabId1],
605
+ ...defaultViewConfig,
606
+ pinboardId,
607
+ } as LiveboardViewConfig);
608
+ pinboardEmbed.render();
609
+ expect(pinboardEmbed['isError']).toBe(false);
610
+ });
611
+
612
+ /**
613
+ *
614
+ * @param hiddenTabs
615
+ * @param visibleTabs
616
+ */
617
+ async function testTabsForLiveboards(
618
+ hiddenTabs: Array<string>,
619
+ visibleTabs: Array<string>,
620
+ ) {
621
+ spyOn(console, 'error');
622
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
623
+ hiddenTabs,
624
+ visibleTabs,
625
+ ...defaultViewConfig,
626
+ liveboardId,
627
+ } as LiveboardViewConfig);
628
+ await liveboardEmbed.render();
629
+ expect(liveboardEmbed['isError']).toBe(true);
630
+ expect(console.error).toHaveBeenCalledWith(
631
+ 'You cannot have both hidden Tabs and visible Tabs',
632
+ );
633
+ }
634
+ test('should throw error when there are both visible and hidden Tab arrays', async () => {
635
+ await testTabsForLiveboards([tabId1], [tabId2]);
636
+ });
637
+ test('should throw error when there are both visible and hidden Tab arrays as empty', async () => {
638
+ await testTabsForLiveboards([], []);
639
+ });
640
+ test('should throw error when there are both visible and hidden Tabs - one of them is an empty array', async () => {
641
+ await testTabsForLiveboards([], [tabId2]);
642
+ });
643
+
644
+ test('should not throw error when there are only visible or hidden Tab', async () => {
645
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
646
+ hiddenTabs: [tabId2],
647
+ ...defaultViewConfig,
648
+ liveboardId,
649
+ } as LiveboardViewConfig);
650
+ liveboardEmbed.render();
651
+ expect(liveboardEmbed['isError']).toBe(false);
652
+ });
653
+ test('should not throw error when there are only visible or hidden Tabs', async () => {
654
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
655
+ visibleTabs: [tabId1],
656
+ ...defaultViewConfig,
657
+ liveboardId,
658
+ } as LiveboardViewConfig);
659
+ liveboardEmbed.render();
660
+ expect(liveboardEmbed['isError']).toBe(false);
661
+ });
662
+ });
663
+
585
664
  describe('when thoughtSpotHost is empty', () => {
586
665
  beforeAll(() => {
587
666
  jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => '');
@@ -358,6 +358,8 @@ export class TsEmbed {
358
358
  disabledActionReason,
359
359
  hiddenActions,
360
360
  visibleActions,
361
+ hiddenTabs,
362
+ visibleTabs,
361
363
  showAlerts,
362
364
  additionalFlags,
363
365
  locale,
@@ -375,6 +377,11 @@ export class TsEmbed {
375
377
  return queryParams;
376
378
  }
377
379
 
380
+ if (Array.isArray(visibleTabs) && Array.isArray(hiddenTabs)) {
381
+ this.handleError('You cannot have both hidden Tabs and visible Tabs');
382
+ return queryParams;
383
+ }
384
+
378
385
  // TODO remove embedConfig.customCssUrl
379
386
  const cssUrlParam = customizations?.style?.customCSSUrl || this.embedConfig.customCssUrl;
380
387
 
@@ -392,7 +399,12 @@ export class TsEmbed {
392
399
  if (Array.isArray(visibleActions)) {
393
400
  queryParams[Param.VisibleActions] = visibleActions;
394
401
  }
395
-
402
+ if (Array.isArray(hiddenTabs)) {
403
+ queryParams[Param.HiddenTabs] = hiddenTabs;
404
+ }
405
+ if (Array.isArray(visibleTabs)) {
406
+ queryParams[Param.VisibleTabs] = visibleTabs;
407
+ }
396
408
  /**
397
409
  * Default behavior for context menu will be left-click
398
410
  * from version 9.2.0.cl the user have an option to override context
@@ -197,6 +197,35 @@ describe('React Components', () => {
197
197
  ).toBe(true);
198
198
  expect(containerSibling.querySelector('div')).toBe(null);
199
199
  });
200
+
201
+ it('Should have the correct container element', async () => {
202
+ const { container } = render(
203
+ <LiveboardEmbed liveboardId="abcd" className="def" />,
204
+ );
205
+
206
+ await waitFor(() => getIFrameEl(container));
207
+ expect(container.querySelector('div')).not.toBe(null);
208
+ expect(
209
+ container.querySelector('div').classList.contains('def'),
210
+ ).toBe(true);
211
+
212
+ const { container: containerSibling } = render(
213
+ <LiveboardEmbed
214
+ liveboardId="abcd"
215
+ className="def"
216
+ insertAsSibling={true}
217
+ />,
218
+ );
219
+ await waitFor(() => getIFrameEl(containerSibling));
220
+ expect(containerSibling.querySelector('span')).not.toBe(null);
221
+ expect(containerSibling.querySelector('span').style.position).toBe(
222
+ 'absolute',
223
+ );
224
+ expect(
225
+ getIFrameEl(containerSibling).classList.contains('def'),
226
+ ).toBe(true);
227
+ expect(containerSibling.querySelector('div')).toBe(null);
228
+ });
200
229
  });
201
230
 
202
231
  describe('SearchBarEmbed', () => {