@thoughtspot/visual-embed-sdk 1.47.1 → 1.47.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 (159) hide show
  1. package/cjs/package.json +3 -3
  2. package/cjs/src/embed/app.d.ts +19 -1
  3. package/cjs/src/embed/app.d.ts.map +1 -1
  4. package/cjs/src/embed/app.js +7 -1
  5. package/cjs/src/embed/app.js.map +1 -1
  6. package/cjs/src/embed/app.spec.js +141 -0
  7. package/cjs/src/embed/app.spec.js.map +1 -1
  8. package/cjs/src/embed/conversation.d.ts +2 -1
  9. package/cjs/src/embed/conversation.d.ts.map +1 -1
  10. package/cjs/src/embed/conversation.js.map +1 -1
  11. package/cjs/src/embed/hostEventClient/contracts.d.ts +4 -1
  12. package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  13. package/cjs/src/embed/hostEventClient/host-event-client.spec.js +2 -2
  14. package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  15. package/cjs/src/embed/liveboard.d.ts +13 -0
  16. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  17. package/cjs/src/embed/liveboard.js +7 -1
  18. package/cjs/src/embed/liveboard.js.map +1 -1
  19. package/cjs/src/embed/liveboard.spec.js +54 -0
  20. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  21. package/cjs/src/embed/search.d.ts +24 -1
  22. package/cjs/src/embed/search.d.ts.map +1 -1
  23. package/cjs/src/embed/search.js +15 -2
  24. package/cjs/src/embed/search.js.map +1 -1
  25. package/cjs/src/embed/search.spec.js +99 -0
  26. package/cjs/src/embed/search.spec.js.map +1 -1
  27. package/cjs/src/embed/spotter-utils.d.ts +3 -0
  28. package/cjs/src/embed/spotter-utils.d.ts.map +1 -1
  29. package/cjs/src/embed/spotter-utils.js +11 -3
  30. package/cjs/src/embed/spotter-utils.js.map +1 -1
  31. package/cjs/src/embed/spotter-utils.spec.js +51 -0
  32. package/cjs/src/embed/spotter-utils.spec.js.map +1 -1
  33. package/cjs/src/embed/ts-embed.d.ts +14 -1
  34. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  35. package/cjs/src/embed/ts-embed.js +29 -3
  36. package/cjs/src/embed/ts-embed.js.map +1 -1
  37. package/cjs/src/embed/ts-embed.spec.js +139 -0
  38. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  39. package/cjs/src/index.d.ts +2 -2
  40. package/cjs/src/index.d.ts.map +1 -1
  41. package/cjs/src/index.js +8 -1
  42. package/cjs/src/index.js.map +1 -1
  43. package/cjs/src/mixpanel-service.d.ts.map +1 -1
  44. package/cjs/src/mixpanel-service.js +2 -0
  45. package/cjs/src/mixpanel-service.js.map +1 -1
  46. package/cjs/src/mixpanel-service.spec.js +2 -0
  47. package/cjs/src/mixpanel-service.spec.js.map +1 -1
  48. package/cjs/src/test/test-utils.d.ts +1 -0
  49. package/cjs/src/test/test-utils.d.ts.map +1 -1
  50. package/cjs/src/test/test-utils.js +26 -1
  51. package/cjs/src/test/test-utils.js.map +1 -1
  52. package/cjs/src/types.d.ts +532 -6
  53. package/cjs/src/types.d.ts.map +1 -1
  54. package/cjs/src/types.js +225 -3
  55. package/cjs/src/types.js.map +1 -1
  56. package/dist/{index-CUgxBnPm.js → index-DZq20cR6.js} +1 -1
  57. package/dist/src/embed/app.d.ts +19 -1
  58. package/dist/src/embed/app.d.ts.map +1 -1
  59. package/dist/src/embed/conversation.d.ts +2 -1
  60. package/dist/src/embed/conversation.d.ts.map +1 -1
  61. package/dist/src/embed/hostEventClient/contracts.d.ts +4 -1
  62. package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  63. package/dist/src/embed/liveboard.d.ts +13 -0
  64. package/dist/src/embed/liveboard.d.ts.map +1 -1
  65. package/dist/src/embed/search.d.ts +24 -1
  66. package/dist/src/embed/search.d.ts.map +1 -1
  67. package/dist/src/embed/spotter-utils.d.ts +3 -0
  68. package/dist/src/embed/spotter-utils.d.ts.map +1 -1
  69. package/dist/src/embed/ts-embed.d.ts +14 -1
  70. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  71. package/dist/src/index.d.ts +2 -2
  72. package/dist/src/index.d.ts.map +1 -1
  73. package/dist/src/mixpanel-service.d.ts.map +1 -1
  74. package/dist/src/test/test-utils.d.ts +1 -0
  75. package/dist/src/test/test-utils.d.ts.map +1 -1
  76. package/dist/src/types.d.ts +532 -6
  77. package/dist/src/types.d.ts.map +1 -1
  78. package/dist/tsembed-react.es.js +299 -17
  79. package/dist/tsembed-react.js +298 -16
  80. package/dist/tsembed.es.js +300 -18
  81. package/dist/tsembed.js +298 -16
  82. package/dist/visual-embed-sdk-react-full.d.ts +572 -6
  83. package/dist/visual-embed-sdk-react.d.ts +572 -6
  84. package/dist/visual-embed-sdk.d.ts +600 -6
  85. package/lib/package.json +3 -3
  86. package/lib/src/embed/app.d.ts +19 -1
  87. package/lib/src/embed/app.d.ts.map +1 -1
  88. package/lib/src/embed/app.js +7 -1
  89. package/lib/src/embed/app.js.map +1 -1
  90. package/lib/src/embed/app.spec.js +142 -1
  91. package/lib/src/embed/app.spec.js.map +1 -1
  92. package/lib/src/embed/conversation.d.ts +2 -1
  93. package/lib/src/embed/conversation.d.ts.map +1 -1
  94. package/lib/src/embed/conversation.js.map +1 -1
  95. package/lib/src/embed/hostEventClient/contracts.d.ts +4 -1
  96. package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  97. package/lib/src/embed/hostEventClient/host-event-client.spec.js +2 -2
  98. package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  99. package/lib/src/embed/liveboard.d.ts +13 -0
  100. package/lib/src/embed/liveboard.d.ts.map +1 -1
  101. package/lib/src/embed/liveboard.js +7 -1
  102. package/lib/src/embed/liveboard.js.map +1 -1
  103. package/lib/src/embed/liveboard.spec.js +54 -0
  104. package/lib/src/embed/liveboard.spec.js.map +1 -1
  105. package/lib/src/embed/search.d.ts +24 -1
  106. package/lib/src/embed/search.d.ts.map +1 -1
  107. package/lib/src/embed/search.js +15 -2
  108. package/lib/src/embed/search.js.map +1 -1
  109. package/lib/src/embed/search.spec.js +100 -1
  110. package/lib/src/embed/search.spec.js.map +1 -1
  111. package/lib/src/embed/spotter-utils.d.ts +3 -0
  112. package/lib/src/embed/spotter-utils.d.ts.map +1 -1
  113. package/lib/src/embed/spotter-utils.js +11 -3
  114. package/lib/src/embed/spotter-utils.js.map +1 -1
  115. package/lib/src/embed/spotter-utils.spec.js +51 -0
  116. package/lib/src/embed/spotter-utils.spec.js.map +1 -1
  117. package/lib/src/embed/ts-embed.d.ts +14 -1
  118. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  119. package/lib/src/embed/ts-embed.js +28 -2
  120. package/lib/src/embed/ts-embed.js.map +1 -1
  121. package/lib/src/embed/ts-embed.spec.js +139 -0
  122. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  123. package/lib/src/index.d.ts +2 -2
  124. package/lib/src/index.d.ts.map +1 -1
  125. package/lib/src/index.js +2 -2
  126. package/lib/src/index.js.map +1 -1
  127. package/lib/src/mixpanel-service.d.ts.map +1 -1
  128. package/lib/src/mixpanel-service.js +2 -0
  129. package/lib/src/mixpanel-service.js.map +1 -1
  130. package/lib/src/mixpanel-service.spec.js +2 -0
  131. package/lib/src/mixpanel-service.spec.js.map +1 -1
  132. package/lib/src/test/test-utils.d.ts +1 -0
  133. package/lib/src/test/test-utils.d.ts.map +1 -1
  134. package/lib/src/test/test-utils.js +25 -1
  135. package/lib/src/test/test-utils.js.map +1 -1
  136. package/lib/src/types.d.ts +532 -6
  137. package/lib/src/types.d.ts.map +1 -1
  138. package/lib/src/types.js +224 -2
  139. package/lib/src/types.js.map +1 -1
  140. package/lib/src/visual-embed-sdk.d.ts +600 -6
  141. package/package.json +3 -3
  142. package/src/embed/app.spec.ts +179 -0
  143. package/src/embed/app.ts +29 -0
  144. package/src/embed/conversation.ts +2 -1
  145. package/src/embed/hostEventClient/contracts.ts +2 -1
  146. package/src/embed/hostEventClient/host-event-client.spec.ts +2 -2
  147. package/src/embed/liveboard.spec.ts +73 -0
  148. package/src/embed/liveboard.ts +23 -0
  149. package/src/embed/search.spec.ts +118 -0
  150. package/src/embed/search.ts +43 -1
  151. package/src/embed/spotter-utils.spec.ts +52 -0
  152. package/src/embed/spotter-utils.ts +19 -3
  153. package/src/embed/ts-embed.spec.ts +185 -0
  154. package/src/embed/ts-embed.ts +29 -3
  155. package/src/index.ts +16 -0
  156. package/src/mixpanel-service.spec.ts +2 -0
  157. package/src/mixpanel-service.ts +2 -0
  158. package/src/test/test-utils.ts +33 -1
  159. package/src/types.ts +561 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.47.1",
3
+ "version": "1.47.3",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
@@ -70,7 +70,7 @@
70
70
  "dependencies": {
71
71
  "classnames": "^2.3.1",
72
72
  "eventemitter3": "^4.0.7",
73
- "lodash": "^4.17.23",
73
+ "lodash": "^4.18.1",
74
74
  "mixpanel-browser": "2.47.0",
75
75
  "ts-deepmerge": "^6.0.2",
76
76
  "tslib": "^2.5.3",
@@ -126,7 +126,7 @@
126
126
  "jest-environment-jsdom": "^29.7.0",
127
127
  "jest-fetch-mock": "^3.0.3",
128
128
  "jsdom": "^17.0.0",
129
- "prettier": "2.1.2",
129
+ "prettier": "3.8.1",
130
130
  "react": "^16.14.0",
131
131
  "react-dom": "^16.14.0",
132
132
  "react-resizable": "^1.11.0",
@@ -21,6 +21,8 @@ import {
21
21
  defaultParamsForPinboardEmbed,
22
22
  defaultParamsWithoutHiddenActions,
23
23
  expectUrlMatchesWithParams,
24
+ postMessageToParent,
25
+ testVisualOverridesInEmbed,
24
26
  } from '../test/test-utils';
25
27
  import { version } from '../../package.json';
26
28
  import * as config from '../config';
@@ -805,6 +807,53 @@ describe('App embed tests', () => {
805
807
  });
806
808
  });
807
809
 
810
+ test('Should add newChartsLibrary true to the iframe src', async () => {
811
+ const appEmbed = new AppEmbed(getRootEl(), {
812
+ ...defaultViewConfig,
813
+ showPrimaryNavbar: false,
814
+ newChartsLibrary: true,
815
+ } as AppViewConfig);
816
+
817
+ appEmbed.render();
818
+ await executeAfterWait(() => {
819
+ expectUrlMatchesWithParams(
820
+ getIFrameSrc(),
821
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&muzeChartPhase1EnabledGA=true${defaultParams}${defaultParamsPost}#/home`,
822
+ );
823
+ });
824
+ });
825
+
826
+ test('Should add newChartsLibrary false to the iframe src', async () => {
827
+ const appEmbed = new AppEmbed(getRootEl(), {
828
+ ...defaultViewConfig,
829
+ showPrimaryNavbar: false,
830
+ newChartsLibrary: false,
831
+ } as AppViewConfig);
832
+
833
+ appEmbed.render();
834
+ await executeAfterWait(() => {
835
+ expectUrlMatchesWithParams(
836
+ getIFrameSrc(),
837
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&muzeChartPhase1EnabledGA=false${defaultParams}${defaultParamsPost}#/home`,
838
+ );
839
+ });
840
+ });
841
+
842
+ test('Should not add newChartsLibrary to the iframe src when not specified', async () => {
843
+ const appEmbed = new AppEmbed(getRootEl(), {
844
+ ...defaultViewConfig,
845
+ showPrimaryNavbar: false,
846
+ } as AppViewConfig);
847
+
848
+ appEmbed.render();
849
+ await executeAfterWait(() => {
850
+ expectUrlMatchesWithParams(
851
+ getIFrameSrc(),
852
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`,
853
+ );
854
+ });
855
+ });
856
+
808
857
  test('Should add enableSearchAssist flagto the iframe src', async () => {
809
858
  const appEmbed = new AppEmbed(getRootEl(), {
810
859
  ...defaultViewConfig,
@@ -1208,6 +1257,44 @@ describe('App embed tests', () => {
1208
1257
  });
1209
1258
  });
1210
1259
 
1260
+ test('should set enableLiveboardDataCache to true in url', async () => {
1261
+ const appEmbed = new AppEmbed(getRootEl(), {
1262
+ ...defaultViewConfig,
1263
+ enableLiveboardDataCache: true,
1264
+ } as AppViewConfig);
1265
+ appEmbed.render();
1266
+ await executeAfterWait(() => {
1267
+ expectUrlMatchesWithParams(
1268
+ getIFrameSrc(),
1269
+ `http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&enableLiveboardDataCache=true${defaultParamsPost}#/home`,
1270
+ );
1271
+ });
1272
+ });
1273
+
1274
+ test('should set enableLiveboardDataCache to false in url', async () => {
1275
+ const appEmbed = new AppEmbed(getRootEl(), {
1276
+ ...defaultViewConfig,
1277
+ enableLiveboardDataCache: false,
1278
+ } as AppViewConfig);
1279
+ appEmbed.render();
1280
+ await executeAfterWait(() => {
1281
+ expectUrlMatchesWithParams(
1282
+ getIFrameSrc(),
1283
+ `http://${thoughtSpotHost}/?embedApp=true&profileAndHelpInNavBarHidden=false&enableLiveboardDataCache=false${defaultParamsPost}#/home`,
1284
+ );
1285
+ });
1286
+ });
1287
+
1288
+ test('should not set enableLiveboardDataCache in url when not provided', async () => {
1289
+ const appEmbed = new AppEmbed(getRootEl(), {
1290
+ ...defaultViewConfig,
1291
+ } as AppViewConfig);
1292
+ appEmbed.render();
1293
+ await executeAfterWait(() => {
1294
+ expect(getIFrameSrc()).not.toContain('enableLiveboardDataCache');
1295
+ });
1296
+ });
1297
+
1211
1298
  test('Should add HomePageSearchBarMode flag with object search to the iframe src', async () => {
1212
1299
  const appEmbed = new AppEmbed(getRootEl(), {
1213
1300
  ...defaultViewConfig,
@@ -1774,4 +1861,96 @@ describe('App Embed Default Height and Minimum Height Handling', () => {
1774
1861
  });
1775
1862
  });
1776
1863
 
1864
+ describe('AppEmbed visualOverrides tests', () => {
1865
+ test('should include visualOverridesParams in APP_INIT when visualOverrides config is provided', async () => {
1866
+ const visualOverrides = {
1867
+ chart: {
1868
+ legend: {
1869
+ show: true,
1870
+ position: 'bottom' as const,
1871
+ },
1872
+ },
1873
+ };
1874
+ const appEmbed = new AppEmbed(getRootEl(), {
1875
+ ...defaultViewConfig,
1876
+ visualOverrides,
1877
+ } as AppViewConfig);
1878
+
1879
+ mockMessageChannel();
1880
+ await testVisualOverridesInEmbed(appEmbed, visualOverrides);
1881
+ });
1882
+
1883
+ test('should not include visualOverridesParams when visualOverrides is not provided', async () => {
1884
+ const appEmbed = new AppEmbed(getRootEl(), {
1885
+ ...defaultViewConfig,
1886
+ } as AppViewConfig);
1887
+
1888
+ const mockEmbedEventPayload = {
1889
+ type: EmbedEvent.APP_INIT,
1890
+ data: {},
1891
+ };
1892
+
1893
+ mockMessageChannel();
1894
+ appEmbed.render();
1895
+
1896
+ const mockPort: any = {
1897
+ postMessage: jest.fn(),
1898
+ };
1899
+
1900
+ await executeAfterWait(() => {
1901
+ const iframe = getIFrameEl();
1902
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
1903
+ });
1904
+
1905
+ await executeAfterWait(() => {
1906
+ const callArgs = mockPort.postMessage.mock.calls[0][0];
1907
+ expect(callArgs.type).toBe(EmbedEvent.APP_INIT);
1908
+ if (callArgs.data.embedParams) {
1909
+ expect(callArgs.data.embedParams.visualOverridesParams).toBeUndefined();
1910
+ }
1911
+ });
1912
+ });
1913
+
1914
+ test('should pass visualOverrides with table config in AppEmbed', async () => {
1915
+ const visualOverrides = {
1916
+ table: {
1917
+ display: {
1918
+ tableTheme: 'ZEBRA',
1919
+ tableContentDensity: 'COMPACT',
1920
+ },
1921
+ },
1922
+ };
1923
+ const appEmbed = new AppEmbed(getRootEl(), {
1924
+ ...defaultViewConfig,
1925
+ visualOverrides,
1926
+ } as AppViewConfig);
1927
+
1928
+ mockMessageChannel();
1929
+ await testVisualOverridesInEmbed(appEmbed, visualOverrides);
1930
+ });
1931
+
1932
+ test('should pass visualOverrides with both chart and table configs', async () => {
1933
+ const visualOverrides = {
1934
+ chart: {
1935
+ legend: {
1936
+ show: true,
1937
+ position: 'right' as const,
1938
+ },
1939
+ },
1940
+ table: {
1941
+ display: {
1942
+ tableTheme: 'STRIPED',
1943
+ },
1944
+ },
1945
+ };
1946
+ const appEmbed = new AppEmbed(getRootEl(), {
1947
+ ...defaultViewConfig,
1948
+ visualOverrides,
1949
+ } as AppViewConfig);
1950
+
1951
+ mockMessageChannel();
1952
+ await testVisualOverridesInEmbed(appEmbed, visualOverrides);
1953
+ });
1954
+ });
1955
+
1777
1956
 
package/src/embed/app.ts CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  MessagePayload,
19
19
  AllEmbedViewConfig,
20
20
  DefaultAppInitData,
21
+ VisualizationOverrides,
21
22
  } from '../types';
22
23
  import { V1Embed } from './ts-embed';
23
24
  import { SpotterChatViewConfig, SpotterSidebarViewConfig } from './conversation';
@@ -785,6 +786,25 @@ export interface AppViewConfig extends AllEmbedViewConfig {
785
786
  * @version SDK: 1.48.0 | ThoughtSpot: 26.5.0.cl
786
787
  */
787
788
  enableHomepageAnnouncement?: boolean;
789
+ /**
790
+ * If set to true, enables visualization data caching on the Liveboard.
791
+ * @type {boolean}
792
+ * @version SDK: 1.49.0 | ThoughtSpot: 26.6.0.cl
793
+ * @example
794
+ * ```js
795
+ * const embed = new AppEmbed('#tsEmbed', {
796
+ * ... // other options
797
+ * enableLiveboardDataCache: true,
798
+ * })
799
+ * ```
800
+ */
801
+ enableLiveboardDataCache?: boolean;
802
+
803
+ /**
804
+ * Visual overrides to customize the chart or table properties.
805
+ * @version SDK: 1.49.0 | ThoughtSpot: 26.6.0.cl
806
+ */
807
+ visualOverrides?: VisualizationOverrides;
788
808
  }
789
809
 
790
810
  /**
@@ -862,6 +882,7 @@ export class AppEmbed extends V1Embed {
862
882
  showLiveboardDescription = true,
863
883
  showMaskedFilterChip = false,
864
884
  isLiveboardMasterpiecesEnabled = false,
885
+ newChartsLibrary,
865
886
  hideHomepageLeftNav = false,
866
887
  modularHomeExperience = false,
867
888
  isLiveboardHeaderSticky = true,
@@ -894,6 +915,7 @@ export class AppEmbed extends V1Embed {
894
915
  isThisPeriodInDateFiltersEnabled,
895
916
  enableHomepageAnnouncement = false,
896
917
  isContinuousLiveboardPDFEnabled,
918
+ enableLiveboardDataCache,
897
919
  } = this.viewConfig;
898
920
 
899
921
  let params: any = {};
@@ -906,6 +928,9 @@ export class AppEmbed extends V1Embed {
906
928
  params[Param.ShowLiveboardDescription] = !!showLiveboardDescription;
907
929
  params[Param.ShowMaskedFilterChip] = showMaskedFilterChip;
908
930
  params[Param.IsLiveboardMasterpiecesEnabled] = isLiveboardMasterpiecesEnabled;
931
+ if (newChartsLibrary !== undefined) {
932
+ params[Param.EnableNewChartLibrary] = newChartsLibrary;
933
+ }
909
934
  params[Param.LiveboardHeaderSticky] = isLiveboardHeaderSticky;
910
935
  params[Param.IsFullAppEmbed] = true;
911
936
  params[Param.LiveboardHeaderV2] = isLiveboardCompactHeaderEnabled;
@@ -1036,6 +1061,10 @@ export class AppEmbed extends V1Embed {
1036
1061
 
1037
1062
  this.defaultHeight = minimumHeight || this.defaultHeight;
1038
1063
 
1064
+ if (enableLiveboardDataCache !== undefined) {
1065
+ params[Param.EnableLiveboardDataCache] = enableLiveboardDataCache;
1066
+ }
1067
+
1039
1068
  params[Param.DataPanelV2Enabled] = dataPanelV2;
1040
1069
  params[Param.HideHomepageLeftNav] = hideHomepageLeftNav;
1041
1070
  params[Param.ModularHomeExperienceEnabled] = modularHomeExperience;
@@ -1,6 +1,6 @@
1
1
  import isUndefined from 'lodash/isUndefined';
2
2
  import { ERROR_MESSAGE } from '../errors';
3
- import { Param, BaseViewConfig, RuntimeFilter, RuntimeParameter, ErrorDetailsTypes, EmbedErrorCodes, DefaultAppInitData } from '../types';
3
+ import { Param, BaseViewConfig, RuntimeFilter, RuntimeParameter, ErrorDetailsTypes, EmbedErrorCodes, DefaultAppInitData, VisualizationOverrides } from '../types';
4
4
  import { TsEmbed } from './ts-embed';
5
5
  import { buildSpotterSidebarAppInitData } from './spotter-utils';
6
6
  import { getQueryParamString, getFilterQuery, getRuntimeParameters, setParamIfDefined } from '../utils';
@@ -360,6 +360,7 @@ export interface ConversationViewConfig extends SpotterEmbedViewConfig {}
360
360
  export interface SpotterAppInitData extends DefaultAppInitData {
361
361
  embedParams?: {
362
362
  spotterSidebarConfig?: SpotterSidebarViewConfig;
363
+ visualOverridesParams?: VisualizationOverrides | null;
363
364
  };
364
365
  }
365
366
 
@@ -137,7 +137,8 @@ export type UIPassthroughContractBase = {
137
137
  [UIPassthroughEvent.GetExportRequestForCurrentPinboard]: {
138
138
  request: Record<string, never>;
139
139
  response: {
140
- v2Content: string;
140
+ data: { v2Content: string };
141
+ type: UIPassthroughEvent.GetExportRequestForCurrentPinboard;
141
142
  };
142
143
  };
143
144
  [UIPassthroughEvent.UpdateFilters]: {
@@ -494,11 +494,11 @@ describe('HostEventClient', () => {
494
494
  const { client } = createHostEventClient();
495
495
  mockProcessTrigger
496
496
  .mockResolvedValueOnce(mockGetAvailablePassthroughs())
497
- .mockResolvedValueOnce([{ value: { v2Content: 'exportData' } }]);
497
+ .mockResolvedValueOnce([{ value: { data: { v2Content: 'exportData' }, type: 'getExportRequestForCurrentPinboard' } }]);
498
498
 
499
499
  const result = await client.triggerHostEvent(HostEvent.getExportRequestForCurrentPinboard, {});
500
500
 
501
- expect(result).toEqual({ v2Content: 'exportData' });
501
+ expect(result).toEqual({ data: { v2Content: 'exportData' }, type: 'getExportRequestForCurrentPinboard' });
502
502
  });
503
503
 
504
504
  it('should fall back to legacy for GetFilters when passthrough returns null', async () => {
@@ -427,6 +427,47 @@ describe('Liveboard/viz embed tests', () => {
427
427
  });
428
428
  });
429
429
 
430
+ test('should set enableLiveboardDataCache to true in url', async () => {
431
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
432
+ enableLiveboardDataCache: true,
433
+ ...defaultViewConfig,
434
+ liveboardId,
435
+ } as LiveboardViewConfig);
436
+ liveboardEmbed.render();
437
+ await executeAfterWait(() => {
438
+ expectUrlMatchesWithParams(
439
+ getIFrameSrc(),
440
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&enableLiveboardDataCache=true${prefixParams}#/embed/viz/${liveboardId}`,
441
+ );
442
+ });
443
+ });
444
+
445
+ test('should set enableLiveboardDataCache to false in url', async () => {
446
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
447
+ enableLiveboardDataCache: false,
448
+ ...defaultViewConfig,
449
+ liveboardId,
450
+ } as LiveboardViewConfig);
451
+ liveboardEmbed.render();
452
+ await executeAfterWait(() => {
453
+ expectUrlMatchesWithParams(
454
+ getIFrameSrc(),
455
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&enableLiveboardDataCache=false${prefixParams}#/embed/viz/${liveboardId}`,
456
+ );
457
+ });
458
+ });
459
+
460
+ test('should not set enableLiveboardDataCache in url when not provided', async () => {
461
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
462
+ ...defaultViewConfig,
463
+ liveboardId,
464
+ } as LiveboardViewConfig);
465
+ liveboardEmbed.render();
466
+ await executeAfterWait(() => {
467
+ expect(getIFrameSrc()).not.toContain('enableLiveboardDataCache');
468
+ });
469
+ });
470
+
430
471
  test('should render viz', async () => {
431
472
  const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
432
473
  ...defaultViewConfig,
@@ -593,6 +634,38 @@ describe('Liveboard/viz embed tests', () => {
593
634
  });
594
635
  });
595
636
 
637
+ test('Should add newChartsLibrary flag set to true to the iframe src', async () => {
638
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
639
+ ...defaultViewConfig,
640
+ liveboardId,
641
+ newChartsLibrary: true,
642
+ } as LiveboardViewConfig);
643
+
644
+ liveboardEmbed.render();
645
+ await executeAfterWait(() => {
646
+ expectUrlMatchesWithParams(
647
+ getIFrameSrc(),
648
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&muzeChartPhase1EnabledGA=true${prefixParams}#/embed/viz/${liveboardId}`,
649
+ );
650
+ });
651
+ });
652
+
653
+ test('Should add newChartsLibrary flag set to false to the iframe src', async () => {
654
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
655
+ ...defaultViewConfig,
656
+ liveboardId,
657
+ newChartsLibrary: false,
658
+ } as LiveboardViewConfig);
659
+
660
+ liveboardEmbed.render();
661
+ await executeAfterWait(() => {
662
+ expectUrlMatchesWithParams(
663
+ getIFrameSrc(),
664
+ `http://${thoughtSpotHost}/?embedApp=true${defaultParams}&muzeChartPhase1EnabledGA=false${prefixParams}#/embed/viz/${liveboardId}`,
665
+ );
666
+ });
667
+ });
668
+
596
669
  test('Should add hideIrrelevantFiltersAtTabLevel flag to the iframe src', async () => {
597
670
  const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
598
671
  ...defaultViewConfig,
@@ -534,6 +534,19 @@ export interface LiveboardViewConfig extends BaseViewConfig, LiveboardOtherViewC
534
534
  * ```
535
535
  */
536
536
  spotterChatConfig?: SpotterChatViewConfig;
537
+ /**
538
+ * If set to true, enables visualization data caching on the Liveboard.
539
+ * @type {boolean}
540
+ * @version SDK: 1.49.0 | ThoughtSpot: 26.6.0.cl
541
+ * @example
542
+ * ```js
543
+ * const embed = new LiveboardEmbed('#embed-container', {
544
+ * ... // other options
545
+ * enableLiveboardDataCache: true,
546
+ * })
547
+ * ```
548
+ */
549
+ enableLiveboardDataCache?: boolean;
537
550
  }
538
551
 
539
552
  /**
@@ -606,6 +619,7 @@ export class LiveboardEmbed extends V1Embed {
606
619
  hideIrrelevantChipsInLiveboardTabs = false,
607
620
  showMaskedFilterChip = false,
608
621
  isLiveboardMasterpiecesEnabled = false,
622
+ newChartsLibrary,
609
623
  isEnhancedFilterInteractivityEnabled = false,
610
624
  enableAskSage,
611
625
  enable2ColumnLayout,
@@ -627,6 +641,7 @@ export class LiveboardEmbed extends V1Embed {
627
641
  spotterChatConfig,
628
642
  isThisPeriodInDateFiltersEnabled,
629
643
  isContinuousLiveboardPDFEnabled,
644
+ enableLiveboardDataCache,
630
645
  } = this.viewConfig;
631
646
 
632
647
  const preventLiveboardFilterRemoval = this.viewConfig.preventLiveboardFilterRemoval
@@ -744,6 +759,14 @@ export class LiveboardEmbed extends V1Embed {
744
759
  params[Param.IsWYSIWYGLiveboardPDFEnabled] = isContinuousLiveboardPDFEnabled;
745
760
  }
746
761
 
762
+ if (enableLiveboardDataCache !== undefined) {
763
+ params[Param.EnableLiveboardDataCache] = enableLiveboardDataCache;
764
+ }
765
+
766
+ if (newChartsLibrary !== undefined) {
767
+ params[Param.EnableNewChartLibrary] = newChartsLibrary;
768
+ }
769
+
747
770
  params[Param.LiveboardHeaderSticky] = isLiveboardHeaderSticky;
748
771
  params[Param.LiveboardHeaderV2] = isLiveboardCompactHeaderEnabled;
749
772
  params[Param.ShowLiveboardVerifiedBadge] = showLiveboardVerifiedBadge;
@@ -17,6 +17,7 @@ import {
17
17
  expectUrlMatchesWithParams,
18
18
  getIFrameEl,
19
19
  postMessageToParent,
20
+ testVisualOverridesInEmbed,
20
21
  } from '../test/test-utils';
21
22
  import { version } from '../../package.json';
22
23
  import { SearchBarEmbed } from './search-bar';
@@ -524,6 +525,34 @@ describe('Search embed tests', () => {
524
525
  });
525
526
  });
526
527
 
528
+ test('Should add newChartsLibrary flag set to true to the iframe src', async () => {
529
+ const searchEmbed = new SearchEmbed(getRootEl(), {
530
+ ...defaultViewConfig,
531
+ newChartsLibrary: true,
532
+ });
533
+ searchEmbed.render();
534
+ await executeAfterWait(() => {
535
+ expectUrlMatchesWithParams(
536
+ getIFrameSrc(),
537
+ `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&enableDataPanelV2=true&muzeChartPhase1EnabledGA=true&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
538
+ );
539
+ });
540
+ });
541
+
542
+ test('Should add newChartsLibrary flag set to false to the iframe src', async () => {
543
+ const searchEmbed = new SearchEmbed(getRootEl(), {
544
+ ...defaultViewConfig,
545
+ newChartsLibrary: false,
546
+ });
547
+ searchEmbed.render();
548
+ await executeAfterWait(() => {
549
+ expectUrlMatchesWithParams(
550
+ getIFrameSrc(),
551
+ `http://${thoughtSpotHost}/v2/?${defaultParamsWithHiddenActions}&enableDataPanelV2=true&muzeChartPhase1EnabledGA=false&dataSourceMode=expand&useLastSelectedSources=false${prefixParams}#/embed/answer`,
552
+ );
553
+ });
554
+ });
555
+
527
556
  test('should set dataPanelCustomGroupsAccordionInitialState to EXPAND_FIRST when passed', async () => {
528
557
  const searchEmbed = new SearchBarEmbed(getRootEl() as any, {
529
558
  ...defaultViewConfig,
@@ -811,3 +840,92 @@ describe('SearchBarEmbed tests', () => {
811
840
  });
812
841
  });
813
842
  });
843
+
844
+ describe('SearchEmbed visualOverrides tests', () => {
845
+ test('should pass visualOverrides in embedParams when visualOverrides config is provided', async () => {
846
+ const visualOverrides = {
847
+ chart: {
848
+ legend: {
849
+ show: true,
850
+ position: 'bottom' as const,
851
+ },
852
+ },
853
+ };
854
+ const searchEmbed = new SearchEmbed(getRootEl(), {
855
+ ...defaultViewConfig,
856
+ visualOverrides,
857
+ });
858
+
859
+ await testVisualOverridesInEmbed(searchEmbed, visualOverrides);
860
+ });
861
+
862
+ test('should not include visualOverridesParams when visualOverrides is not provided', async () => {
863
+ const searchEmbed = new SearchEmbed(getRootEl(), {
864
+ ...defaultViewConfig,
865
+ });
866
+ const mockEmbedEventPayload = {
867
+ type: EmbedEvent.APP_INIT,
868
+ data: {},
869
+ };
870
+
871
+ searchEmbed.render();
872
+
873
+ const mockPort: any = {
874
+ postMessage: jest.fn(),
875
+ };
876
+
877
+ await executeAfterWait(() => {
878
+ const iframe = getIFrameEl();
879
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
880
+ });
881
+
882
+ await executeAfterWait(() => {
883
+ const callArgs = mockPort.postMessage.mock.calls[0][0];
884
+ expect(callArgs.type).toBe(EmbedEvent.APP_INIT);
885
+ expect(callArgs.data.embedParams?.visualOverridesParams).toBeUndefined();
886
+ });
887
+ });
888
+
889
+ test('should pass visualOverrides with complex chart config', async () => {
890
+ const visualOverrides = {
891
+ chart: {
892
+ legend: {
893
+ show: true,
894
+ position: 'right' as const,
895
+ colorPalette: {
896
+ colors: ['#ff0000', '#00ff00', '#0000ff'],
897
+ },
898
+ },
899
+ columns: [
900
+ {
901
+ name: 'Revenue',
902
+ color: '#1f77b4',
903
+ },
904
+ ],
905
+ },
906
+ };
907
+ const searchEmbed = new SearchEmbed(getRootEl(), {
908
+ ...defaultViewConfig,
909
+ visualOverrides,
910
+ });
911
+
912
+ await testVisualOverridesInEmbed(searchEmbed, visualOverrides);
913
+ });
914
+
915
+ test('should pass visualOverrides with table config', async () => {
916
+ const visualOverrides = {
917
+ table: {
918
+ display: {
919
+ tableTheme: 'ZEBRA',
920
+ tableContentDensity: 'COMPACT',
921
+ },
922
+ },
923
+ };
924
+ const searchEmbed = new SearchEmbed(getRootEl(), {
925
+ ...defaultViewConfig,
926
+ visualOverrides,
927
+ });
928
+
929
+ await testVisualOverridesInEmbed(searchEmbed, visualOverrides);
930
+ });
931
+ });