@thoughtspot/visual-embed-sdk 1.42.1-alpha.6 → 1.42.2

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 (202) hide show
  1. package/cjs/package.json +3 -2
  2. package/cjs/src/css-variables.d.ts +0 -48
  3. package/cjs/src/css-variables.d.ts.map +1 -1
  4. package/cjs/src/embed/app.d.ts +20 -0
  5. package/cjs/src/embed/app.d.ts.map +1 -1
  6. package/cjs/src/embed/app.js +9 -4
  7. package/cjs/src/embed/app.js.map +1 -1
  8. package/cjs/src/embed/app.spec.js +62 -0
  9. package/cjs/src/embed/app.spec.js.map +1 -1
  10. package/cjs/src/embed/bodyless-conversation.d.ts +1 -1
  11. package/cjs/src/embed/conversation.d.ts +16 -0
  12. package/cjs/src/embed/conversation.d.ts.map +1 -1
  13. package/cjs/src/embed/conversation.js +5 -2
  14. package/cjs/src/embed/conversation.js.map +1 -1
  15. package/cjs/src/embed/conversation.spec.js +25 -1
  16. package/cjs/src/embed/conversation.spec.js.map +1 -1
  17. package/cjs/src/embed/hostEventClient/contracts.d.ts +1 -11
  18. package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  19. package/cjs/src/embed/hostEventClient/contracts.js +0 -1
  20. package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
  21. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  22. package/cjs/src/embed/liveboard.js +5 -1
  23. package/cjs/src/embed/liveboard.js.map +1 -1
  24. package/cjs/src/embed/liveboard.spec.js +46 -0
  25. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  26. package/cjs/src/embed/sage.d.ts +4 -4
  27. package/cjs/src/embed/search.d.ts.map +1 -1
  28. package/cjs/src/embed/search.js +1 -3
  29. package/cjs/src/embed/search.js.map +1 -1
  30. package/cjs/src/embed/ts-embed.d.ts +0 -2
  31. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  32. package/cjs/src/embed/ts-embed.js +14 -42
  33. package/cjs/src/embed/ts-embed.js.map +1 -1
  34. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  35. package/cjs/src/errors.js +1 -1
  36. package/cjs/src/errors.js.map +1 -1
  37. package/cjs/src/index.d.ts +2 -2
  38. package/cjs/src/index.d.ts.map +1 -1
  39. package/cjs/src/index.js +1 -2
  40. package/cjs/src/index.js.map +1 -1
  41. package/cjs/src/react/all-types-export.d.ts +1 -1
  42. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  43. package/cjs/src/react/all-types-export.js +3 -2
  44. package/cjs/src/react/all-types-export.js.map +1 -1
  45. package/cjs/src/react/util.d.ts +1 -0
  46. package/cjs/src/react/util.d.ts.map +1 -1
  47. package/cjs/src/types.d.ts +58 -93
  48. package/cjs/src/types.d.ts.map +1 -1
  49. package/cjs/src/types.js +21 -46
  50. package/cjs/src/types.js.map +1 -1
  51. package/cjs/src/utils/custom-actions.d.ts.map +1 -1
  52. package/cjs/src/utils/custom-actions.js +9 -0
  53. package/cjs/src/utils/custom-actions.js.map +1 -1
  54. package/cjs/src/utils/custom-actions.spec.js +20 -0
  55. package/cjs/src/utils/custom-actions.spec.js.map +1 -1
  56. package/cjs/src/utils/processData.d.ts +1 -1
  57. package/cjs/src/utils/processData.d.ts.map +1 -1
  58. package/cjs/src/utils/processData.js +8 -8
  59. package/cjs/src/utils/processData.js.map +1 -1
  60. package/cjs/src/utils/processData.spec.js.map +1 -1
  61. package/dist/{index-DvNA626T.js → index-CjbriUI0.js} +1 -1
  62. package/dist/src/css-variables.d.ts +0 -48
  63. package/dist/src/css-variables.d.ts.map +1 -1
  64. package/dist/src/embed/app.d.ts +20 -0
  65. package/dist/src/embed/app.d.ts.map +1 -1
  66. package/dist/src/embed/bodyless-conversation.d.ts +1 -1
  67. package/dist/src/embed/conversation.d.ts +16 -0
  68. package/dist/src/embed/conversation.d.ts.map +1 -1
  69. package/dist/src/embed/hostEventClient/contracts.d.ts +1 -11
  70. package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  71. package/dist/src/embed/liveboard.d.ts.map +1 -1
  72. package/dist/src/embed/sage.d.ts +4 -4
  73. package/dist/src/embed/search.d.ts.map +1 -1
  74. package/dist/src/embed/ts-embed.d.ts +0 -2
  75. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  76. package/dist/src/index.d.ts +2 -2
  77. package/dist/src/index.d.ts.map +1 -1
  78. package/dist/src/react/all-types-export.d.ts +1 -1
  79. package/dist/src/react/all-types-export.d.ts.map +1 -1
  80. package/dist/src/react/util.d.ts +1 -0
  81. package/dist/src/react/util.d.ts.map +1 -1
  82. package/dist/src/types.d.ts +58 -93
  83. package/dist/src/types.d.ts.map +1 -1
  84. package/dist/src/utils/custom-actions.d.ts.map +1 -1
  85. package/dist/src/utils/processData.d.ts +1 -1
  86. package/dist/src/utils/processData.d.ts.map +1 -1
  87. package/dist/tsembed-react.es.js +84 -219
  88. package/dist/tsembed-react.js +228 -439
  89. package/dist/tsembed.es.js +85 -220
  90. package/dist/tsembed.js +228 -439
  91. package/dist/visual-embed-sdk-react-full.d.ts +104 -160
  92. package/dist/visual-embed-sdk-react.d.ts +95 -155
  93. package/dist/visual-embed-sdk.d.ts +95 -158
  94. package/lib/package.json +3 -2
  95. package/lib/src/css-variables.d.ts +0 -48
  96. package/lib/src/css-variables.d.ts.map +1 -1
  97. package/lib/src/embed/app.d.ts +20 -0
  98. package/lib/src/embed/app.d.ts.map +1 -1
  99. package/lib/src/embed/app.js +9 -4
  100. package/lib/src/embed/app.js.map +1 -1
  101. package/lib/src/embed/app.spec.js +62 -0
  102. package/lib/src/embed/app.spec.js.map +1 -1
  103. package/lib/src/embed/bodyless-conversation.d.ts +1 -1
  104. package/lib/src/embed/conversation.d.ts +16 -0
  105. package/lib/src/embed/conversation.d.ts.map +1 -1
  106. package/lib/src/embed/conversation.js +5 -2
  107. package/lib/src/embed/conversation.js.map +1 -1
  108. package/lib/src/embed/conversation.spec.js +25 -1
  109. package/lib/src/embed/conversation.spec.js.map +1 -1
  110. package/lib/src/embed/hostEventClient/contracts.d.ts +1 -11
  111. package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  112. package/lib/src/embed/hostEventClient/contracts.js +0 -1
  113. package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
  114. package/lib/src/embed/liveboard.d.ts.map +1 -1
  115. package/lib/src/embed/liveboard.js +5 -1
  116. package/lib/src/embed/liveboard.js.map +1 -1
  117. package/lib/src/embed/liveboard.spec.js +47 -1
  118. package/lib/src/embed/liveboard.spec.js.map +1 -1
  119. package/lib/src/embed/sage.d.ts +4 -4
  120. package/lib/src/embed/search.d.ts.map +1 -1
  121. package/lib/src/embed/search.js +1 -3
  122. package/lib/src/embed/search.js.map +1 -1
  123. package/lib/src/embed/ts-embed.d.ts +0 -2
  124. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  125. package/lib/src/embed/ts-embed.js +14 -42
  126. package/lib/src/embed/ts-embed.js.map +1 -1
  127. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  128. package/lib/src/errors.js +1 -1
  129. package/lib/src/errors.js.map +1 -1
  130. package/lib/src/index.d.ts +2 -2
  131. package/lib/src/index.d.ts.map +1 -1
  132. package/lib/src/index.js +2 -2
  133. package/lib/src/index.js.map +1 -1
  134. package/lib/src/react/all-types-export.d.ts +1 -1
  135. package/lib/src/react/all-types-export.d.ts.map +1 -1
  136. package/lib/src/react/all-types-export.js +1 -1
  137. package/lib/src/react/all-types-export.js.map +1 -1
  138. package/lib/src/react/util.d.ts +1 -0
  139. package/lib/src/react/util.d.ts.map +1 -1
  140. package/lib/src/types.d.ts +58 -93
  141. package/lib/src/types.d.ts.map +1 -1
  142. package/lib/src/types.js +20 -45
  143. package/lib/src/types.js.map +1 -1
  144. package/lib/src/utils/custom-actions.d.ts.map +1 -1
  145. package/lib/src/utils/custom-actions.js +9 -0
  146. package/lib/src/utils/custom-actions.js.map +1 -1
  147. package/lib/src/utils/custom-actions.spec.js +20 -0
  148. package/lib/src/utils/custom-actions.spec.js.map +1 -1
  149. package/lib/src/utils/processData.d.ts +1 -1
  150. package/lib/src/utils/processData.d.ts.map +1 -1
  151. package/lib/src/utils/processData.js +8 -8
  152. package/lib/src/utils/processData.js.map +1 -1
  153. package/lib/src/utils/processData.spec.js.map +1 -1
  154. package/package.json +3 -2
  155. package/src/css-variables.ts +0 -58
  156. package/src/embed/app.spec.ts +87 -0
  157. package/src/embed/app.ts +35 -4
  158. package/src/embed/bodyless-conversation.ts +1 -1
  159. package/src/embed/conversation.spec.ts +35 -1
  160. package/src/embed/conversation.ts +22 -0
  161. package/src/embed/hostEventClient/contracts.ts +0 -10
  162. package/src/embed/liveboard.spec.ts +60 -0
  163. package/src/embed/liveboard.ts +9 -0
  164. package/src/embed/sage.ts +4 -4
  165. package/src/embed/search.ts +1 -3
  166. package/src/embed/ts-embed.spec.ts +7 -7
  167. package/src/embed/ts-embed.ts +31 -67
  168. package/src/errors.ts +1 -1
  169. package/src/index.ts +0 -2
  170. package/src/react/all-types-export.ts +2 -1
  171. package/src/types.ts +56 -94
  172. package/src/utils/custom-actions.spec.ts +22 -0
  173. package/src/utils/custom-actions.ts +11 -0
  174. package/src/utils/processData.spec.ts +1 -0
  175. package/src/utils/processData.ts +11 -11
  176. package/cjs/src/api-intercept.d.ts +0 -31
  177. package/cjs/src/api-intercept.d.ts.map +0 -1
  178. package/cjs/src/api-intercept.js +0 -117
  179. package/cjs/src/api-intercept.js.map +0 -1
  180. package/cjs/src/api-intercept.spec.d.ts +0 -2
  181. package/cjs/src/api-intercept.spec.d.ts.map +0 -1
  182. package/cjs/src/api-intercept.spec.js +0 -122
  183. package/cjs/src/api-intercept.spec.js.map +0 -1
  184. package/dist/index-BCC3Z072.js +0 -7371
  185. package/dist/index-BEzW4MDA.js +0 -7371
  186. package/dist/index-BaESA9rq.js +0 -7371
  187. package/dist/index-CFNZIcKr.js +0 -7447
  188. package/dist/index-DFnPKcjZ.js +0 -7447
  189. package/dist/index-DhFH7b7U.js +0 -7447
  190. package/dist/src/api-intercept.d.ts +0 -31
  191. package/dist/src/api-intercept.d.ts.map +0 -1
  192. package/dist/src/api-intercept.spec.d.ts +0 -2
  193. package/dist/src/api-intercept.spec.d.ts.map +0 -1
  194. package/lib/src/api-intercept.d.ts +0 -31
  195. package/lib/src/api-intercept.d.ts.map +0 -1
  196. package/lib/src/api-intercept.js +0 -110
  197. package/lib/src/api-intercept.js.map +0 -1
  198. package/lib/src/api-intercept.spec.d.ts +0 -2
  199. package/lib/src/api-intercept.spec.d.ts.map +0 -1
  200. package/lib/src/api-intercept.spec.js +0 -119
  201. package/lib/src/api-intercept.spec.js.map +0 -1
  202. package/src/api-intercept.ts +0 -136
package/src/types.ts CHANGED
@@ -329,7 +329,7 @@ export interface CustomisationsInterface {
329
329
  * if a trusted authentication server is used.
330
330
  * @group Authentication / Init
331
331
  */
332
- export interface EmbedConfig extends InterceptV2Flags {
332
+ export interface EmbedConfig {
333
333
  /**
334
334
  * The ThoughtSpot cluster hostname or IP address.
335
335
  */
@@ -726,7 +726,7 @@ export interface FrameParams {
726
726
  /**
727
727
  * The common configuration object for an embedded view.
728
728
  */
729
- export interface BaseViewConfig extends InterceptV2Flags {
729
+ export interface BaseViewConfig {
730
730
  /**
731
731
  * @hidden
732
732
  */
@@ -1512,6 +1512,24 @@ export interface LiveboardAppEmbedViewConfig {
1512
1512
  * ```
1513
1513
  */
1514
1514
  liveboardXLSXCSVDownload?: boolean;
1515
+ /**
1516
+ * This flag is used to enable or disable the new centralized Liveboard filter UX (v2).
1517
+ * When enabled, a unified modal is used to manage and update multiple filters at once,
1518
+ * replacing the older individual filter interactions.
1519
+ * To enable this feature on your instance, contact ThoughtSpot Support.
1520
+ *
1521
+ * Supported embed types: `AppEmbed`, `LiveboardEmbed`
1522
+ * @version SDK: 1.42.0 | ThoughtSpot: 10.15.0.cl
1523
+ * @example
1524
+ * ```js
1525
+ * // Replace <EmbedComponent> with embed component name. For example, AppEmbed or LiveboardEmbed
1526
+ * const embed = new <EmbedComponent>('#tsEmbed', {
1527
+ * ... // other embed view config
1528
+ * isCentralizedLiveboardFilterUXEnabled: true,
1529
+ * })
1530
+ * ```
1531
+ */
1532
+ isCentralizedLiveboardFilterUXEnabled?: boolean;
1515
1533
  /**
1516
1534
  * This flag is used to enable or disable the link parameters in liveboard.
1517
1535
  *
@@ -1527,7 +1545,22 @@ export interface LiveboardAppEmbedViewConfig {
1527
1545
  * ```
1528
1546
  */
1529
1547
  isLinkParametersEnabled?: boolean;
1530
-
1548
+
1549
+ /**
1550
+ * This flag is used to enable or disable the enhanced filter interactivity in liveboard.
1551
+ *
1552
+ * Supported embed types: `AppEmbed`, `LiveboardEmbed`
1553
+ * @version SDK: 1.42.0 | ThoughtSpot: 10.15.0.cl
1554
+ * @example
1555
+ * ```js
1556
+ * // Replace <EmbedComponent> with embed component name. For example, AppEmbed or LiveboardEmbed
1557
+ * const embed = new <EmbedComponent>('#tsEmbed', {
1558
+ * ... // other embed view config
1559
+ * isEnhancedFilterInteractivityEnabled: true,
1560
+ * })
1561
+ * ```
1562
+ */
1563
+ isEnhancedFilterInteractivityEnabled?: boolean;
1531
1564
  }
1532
1565
 
1533
1566
  export interface AllEmbedViewConfig extends BaseViewConfig, SearchLiveboardCommonViewConfig, HomePageConfig, LiveboardAppEmbedViewConfig { }
@@ -2774,7 +2807,7 @@ export enum EmbedEvent {
2774
2807
  * the table visualization.
2775
2808
  *
2776
2809
  * If the Row-Level Security (RLS) rules are applied on the
2777
- * Worksheet or Model, exercise caution when changing column
2810
+ * Model, exercise caution when changing column
2778
2811
  * or table cell values to maintain data security.
2779
2812
  *
2780
2813
  * @example
@@ -2832,7 +2865,7 @@ export enum EmbedEvent {
2832
2865
  */
2833
2866
  SpotterData = 'SpotterData',
2834
2867
  /**
2835
- * Emitted when user opens up the worksheet preview modal in Spotter embed.
2868
+ * Emitted when user opens up the data source preview modal in Spotter embed.
2836
2869
  * @example
2837
2870
  * ```js
2838
2871
  * spotterEmbed.on(EmbedEvent.PreviewSpotterData, (payload) => {
@@ -2920,21 +2953,6 @@ export enum EmbedEvent {
2920
2953
  * @version SDK: 1.41.0 | ThoughtSpot: 10.12.0.cl
2921
2954
  */
2922
2955
  OrgSwitched = 'orgSwitched',
2923
- /**
2924
- * Emitted when the user intercepts a URL.
2925
- *
2926
- * Supported on all embed types.
2927
- *
2928
- * @example
2929
- * ```js
2930
- * embed.on(EmbedEvent.ApiIntercept, (payload) => {
2931
- * console.log('payload', payload);
2932
- * })
2933
- * ```
2934
- *
2935
- * @version SDK: 1.42.0 | ThoughtSpot: 10.14.0.cl
2936
- */
2937
- ApiIntercept = 'ApiIntercept',
2938
2956
  }
2939
2957
 
2940
2958
  /**
@@ -3074,9 +3092,7 @@ export enum HostEvent {
3074
3092
  */
3075
3093
  Reload = 'reload',
3076
3094
  /**
3077
- * Get iframe URL for the current embed view on the playground.
3078
- * Developers can use this URL to embed a ThoughtSpot object
3079
- * in apps like Salesforce or Sharepoint.
3095
+ * Get iframe URL for the current embed view.
3080
3096
  * @example
3081
3097
  * ```js
3082
3098
  * const url = embed.trigger(HostEvent.GetIframeUrl);
@@ -4148,7 +4164,7 @@ export enum HostEvent {
4148
4164
  */
4149
4165
  EditLastPrompt = 'EditLastPrompt',
4150
4166
  /**
4151
- * Opens the Worksheet preview modal in Spotter Embed.
4167
+ * Opens the data source preview modal in Spotter Embed.
4152
4168
  * @example
4153
4169
  * ```js
4154
4170
  * spotterEmbed.trigger(HostEvent.PreviewSpotterData);
@@ -4276,6 +4292,7 @@ export enum Param {
4276
4292
  HideResult = 'hideResult',
4277
4293
  UseLastSelectedDataSource = 'useLastSelectedSources',
4278
4294
  Tag = 'tag',
4295
+ HideTagFilterChips = 'hideTagFilterChips',
4279
4296
  AutoLogin = 'autoLogin',
4280
4297
  searchTokenString = 'searchTokenString',
4281
4298
  executeSearch = 'executeSearch',
@@ -4364,6 +4381,7 @@ export enum Param {
4364
4381
  ShowLiveboardReverifyBanner = 'showLiveboardReverifyBanner',
4365
4382
  LiveboardHeaderV2 = 'isLiveboardHeaderV2Enabled',
4366
4383
  HideIrrelevantFiltersInTab = 'hideIrrelevantFiltersAtTabLevel',
4384
+ IsEnhancedFilterInteractivityEnabled = 'isLiveboardPermissionV2Enabled',
4367
4385
  SpotterEnabled = 'isSpotterExperienceEnabled',
4368
4386
  IsUnifiedSearchExperienceEnabled = 'isUnifiedSearchExperienceEnabled',
4369
4387
  OverrideOrgId = 'orgId',
@@ -4380,7 +4398,9 @@ export enum Param {
4380
4398
  RootMarginForLazyLoad = 'rootMarginForLazyLoad',
4381
4399
  LiveboardXLSXCSVDownload = 'isLiveboardXLSXCSVDownloadEnabled',
4382
4400
  isPNGInScheduledEmailsEnabled = 'isPNGInScheduledEmailsEnabled',
4401
+ isCentralizedLiveboardFilterUXEnabled = 'isCentralizedLiveboardFilterUXEnabled',
4383
4402
  isLinkParametersEnabled = 'isLinkParametersEnabled',
4403
+ EnablePastConversationsSidebar = 'enablePastConversationsSidebar',
4384
4404
  }
4385
4405
 
4386
4406
  /**
@@ -4494,7 +4514,7 @@ export enum Action {
4494
4514
  */
4495
4515
  SchedulesList = 'schedule-list',
4496
4516
  /**
4497
- * The **Share** action on a Liveboard, Answer, or Worksheet.
4517
+ * The **Share** action on a Liveboard, Answer, or Model.
4498
4518
  * Allows users to share an object with other users and groups.
4499
4519
  * @example
4500
4520
  * ```js
@@ -4953,7 +4973,7 @@ export enum Action {
4953
4973
  AnswerChartSwitcher = 'answerChartSwitcher',
4954
4974
  /**
4955
4975
  * The Favorites icon (*) for Answers,
4956
- * Liveboard, and data objects like Worksheet, Model,
4976
+ * Liveboard, and data objects like Model,
4957
4977
  * Tables and Views.
4958
4978
  * Allows adding an object to the user's favorites list.
4959
4979
  * @example
@@ -5703,6 +5723,16 @@ export enum Action {
5703
5723
  * @version SDK: 1.42.0 | ThoughtSpot Cloud: 10.14.0.cl
5704
5724
  */
5705
5725
  RemoveAttachment = 'removeAttachment',
5726
+ /**
5727
+ * The **Style panel** on a Liveboard.
5728
+ * Controls the visibility of the Liveboard style panel.
5729
+ * @example
5730
+ * ```js
5731
+ * hiddenActions: [Action.LiveboardStylePanel]
5732
+ * ```
5733
+ * @version SDK: 1.43.0 | ThoughtSpot Cloud: 10.15.0.cl
5734
+ */
5735
+ LiveboardStylePanel = 'liveboardStylePanel',
5706
5736
  }
5707
5737
 
5708
5738
  export interface AnswerServiceType {
@@ -5911,71 +5941,3 @@ export interface DefaultAppInitData {
5911
5941
  hiddenListColumns: ListPageColumns[];
5912
5942
  customActions: CustomAction[];
5913
5943
  }
5914
-
5915
- /**
5916
- * Enum for the type of API intercepted
5917
- */
5918
- export enum InterceptedApiType {
5919
- /**
5920
- * The apis that are use to get the metadata for the embed
5921
- */
5922
- METADATA = 'METADATA',
5923
- /**
5924
- * The apis that are use to get the data for the embed
5925
- */
5926
- ANSWER_DATA = 'ANSWER_DATA',
5927
- /**
5928
- * This will intercept all the apis
5929
- */
5930
- ALL = 'ALL',
5931
- /**
5932
- * The apis that are use to get the data for the liveboard
5933
- */
5934
- LIVEBOARD_DATA = 'LIVEBOARD_DATA',
5935
- }
5936
-
5937
-
5938
- export type InterceptV2Flags = {
5939
- /**
5940
- * Enable intercepting the apis
5941
- *
5942
- * @example
5943
- * ```js
5944
- * const embed = new LiveboardEmbed('#embed', {
5945
- * ...viewConfig,
5946
- * enableApiIntercept: true,
5947
- * interceptUrls: [InterceptedApiType.DATA],
5948
- * })
5949
- * ```
5950
- *
5951
- */
5952
- enableApiIntercept?: boolean;
5953
- /**
5954
- * The apis to intercept
5955
- *
5956
- * @example
5957
- * ```js
5958
- * const embed = new LiveboardEmbed('#embed', {
5959
- * ...viewConfig,
5960
- * enableApiIntercept: true,
5961
- * interceptUrls: [InterceptedApiType.DATA],
5962
- * })
5963
- * ```
5964
- */
5965
- interceptUrls?: (string | InterceptedApiType)[];
5966
- /**
5967
- * The timeout for the intercept, default is 30000ms
5968
- * the api will error out if the timeout is reached
5969
- *
5970
- * @example
5971
- * ```js
5972
- * const embed = new LiveboardEmbed('#embed', {
5973
- * ...viewConfig,
5974
- * enableApiIntercept: true,
5975
- * interceptUrls: [InterceptedApiType.ALL],
5976
- * interceptTimeout: 1000,
5977
- * })
5978
- * ```
5979
- */
5980
- interceptTimeout?: number;
5981
- }
@@ -428,4 +428,26 @@ describe('getCustomActions function', () => {
428
428
  expect(result.errors[0]).toContain("Position 'PRIMARY' is not supported for spotter-level custom actions. Supported positions: MENU, CONTEXTMENU");
429
429
  });
430
430
  });
431
+
432
+ describe('Warnings', () => {
433
+ test('should warn when action name length exceeds 30 characters', () => {
434
+ // Arrange
435
+ const longName = 'A'.repeat(31);
436
+ const action: CustomAction = {
437
+ id: 'long-name-id',
438
+ name: longName,
439
+ target: CustomActionTarget.LIVEBOARD,
440
+ position: CustomActionsPosition.PRIMARY,
441
+ };
442
+
443
+ // Act
444
+ const result = getCustomActions([action]);
445
+
446
+ // Assert
447
+ expect(result.actions).toHaveLength(1);
448
+ expect(logger.warn).toHaveBeenCalledWith([
449
+ `Custom action name '${longName}' exceeds 30 characters. This may cause display or truncation issues in the UI.`
450
+ ]);
451
+ });
452
+ });
431
453
  });
@@ -2,6 +2,7 @@ import { CustomAction, CustomActionsPosition, CustomActionTarget } from '../type
2
2
  import { arrayIncludesString } from '../utils';
3
3
  import sortBy from 'lodash/sortBy';
4
4
  import { CUSTOM_ACTIONS_ERROR_MESSAGE } from '../errors';
5
+ import { logger } from './logger';
5
6
 
6
7
  export interface CustomActionsValidationResult {
7
8
  actions: CustomAction[];
@@ -208,6 +209,16 @@ export const getCustomActions = (customActions: CustomAction[]): CustomActionsVa
208
209
  }
209
210
  });
210
211
 
212
+ // Step 4: Collect warnings for long custom action names
213
+ const MAX_ACTION_NAME_LENGTH = 30;
214
+ const warnings = finalValidActions
215
+ .filter(action => action.name.length > MAX_ACTION_NAME_LENGTH)
216
+ .map(action => `Custom action name '${action.name}' exceeds ${MAX_ACTION_NAME_LENGTH} characters. This may cause display or truncation issues in the UI.`);
217
+
218
+ if (warnings.length > 0) {
219
+ logger.warn(warnings);
220
+ }
221
+
211
222
  const sortedActions = sortBy(finalValidActions, (a) => a.name.toLocaleLowerCase());
212
223
 
213
224
  return {
@@ -1,3 +1,4 @@
1
+ import { disable } from 'mixpanel-browser';
1
2
  import * as processDataInstance from './processData';
2
3
  import * as answerServiceInstance from './graphql/answerService/answerService';
3
4
  import * as auth from '../auth';
@@ -10,9 +10,9 @@ import { AuthType, CustomActionPayload, EmbedEvent } from '../types';
10
10
  import { AnswerService } from './graphql/answerService/answerService';
11
11
  import { resetCachedAuthToken } from '../authToken';
12
12
  import { ERROR_MESSAGE } from '../errors';
13
+ import { logger } from '../utils/logger';
13
14
  import { handleExitPresentMode } from '../utils';
14
15
  import { resetCachedPreauthInfo, resetCachedSessionInfo } from './sessionInfoService';
15
- import { processApiIntercept } from '../api-intercept';
16
16
 
17
17
  /**
18
18
  * Process the ExitPresentMode event and handle default fullscreen exit
@@ -21,7 +21,7 @@ import { processApiIntercept } from '../api-intercept';
21
21
  function processExitPresentMode(e: any) {
22
22
  const embedConfig = getEmbedConfig();
23
23
  const disableFullscreenPresentation = embedConfig?.disableFullscreenPresentation ?? true;
24
-
24
+
25
25
  if (!disableFullscreenPresentation) {
26
26
  handleExitPresentMode();
27
27
  }
@@ -103,7 +103,7 @@ export function processAuthFailure(e: any, containerEl: Element) {
103
103
  const {
104
104
  loginFailedMessage, authType, disableLoginFailurePage, autoLogin,
105
105
  } = getEmbedConfig();
106
-
106
+
107
107
  const isEmbeddedSSO = authType === AuthType.EmbeddedSSO;
108
108
  const isTrustedAuth = authType === AuthType.TrustedAuthToken || authType === AuthType.TrustedAuthTokenCookieless;
109
109
  const isEmbeddedSSOInfoFailure = isEmbeddedSSO && e?.data?.type === AuthFailureType.UNAUTHENTICATED_FAILURE;
@@ -144,26 +144,26 @@ function processAuthLogout(e: any, containerEl: Element) {
144
144
  */
145
145
  export function processEventData(
146
146
  type: EmbedEvent,
147
- eventData: any,
147
+ e: any,
148
148
  thoughtSpotHost: string,
149
149
  containerEl: Element,
150
150
  ): any {
151
151
  switch (type) {
152
152
  case EmbedEvent.CustomAction:
153
- return processCustomAction(eventData, thoughtSpotHost);
153
+ return processCustomAction(e, thoughtSpotHost);
154
154
  case EmbedEvent.AuthInit:
155
- return processAuthInit(eventData);
155
+ return processAuthInit(e);
156
156
  case EmbedEvent.NoCookieAccess:
157
- return processNoCookieAccess(eventData, containerEl);
157
+ return processNoCookieAccess(e, containerEl);
158
158
  case EmbedEvent.AuthFailure:
159
- return processAuthFailure(eventData, containerEl);
159
+ return processAuthFailure(e, containerEl);
160
160
  case EmbedEvent.AuthLogout:
161
- return processAuthLogout(eventData, containerEl);
161
+ return processAuthLogout(e, containerEl);
162
162
  case EmbedEvent.ExitPresentMode:
163
- return processExitPresentMode(eventData);
163
+ return processExitPresentMode(e);
164
164
  case EmbedEvent.CLEAR_INFO_CACHE:
165
165
  return processClearInfoCache();
166
166
  default:
167
167
  }
168
- return eventData;
168
+ return e;
169
169
  }
@@ -1,31 +0,0 @@
1
- import { BaseViewConfig, EmbedConfig, InterceptV2Flags, EmbedEvent } from "./types";
2
- export declare const processApiIntercept: (eventData: any) => Promise<any>;
3
- export declare const getInterceptInitData: (embedConfig: EmbedConfig, viewConfig: BaseViewConfig) => InterceptV2Flags;
4
- export declare const handleInterceptEvent: (params: {
5
- eventData: any;
6
- executeEvent: (eventType: EmbedEvent, data: any) => void;
7
- embedConfig: EmbedConfig;
8
- viewConfig: BaseViewConfig;
9
- getUnsavedAnswerTml: (props: {
10
- sessionId?: string;
11
- vizId?: string;
12
- }) => Promise<{
13
- tml: string;
14
- }>;
15
- }) => Promise<void>;
16
- export declare const processLegacyInterceptResponse: (payload: any) => {
17
- data: {
18
- execute: any;
19
- response: {
20
- body: {
21
- errors: {
22
- title: any;
23
- message: any;
24
- isUserError: boolean;
25
- }[];
26
- data: {};
27
- };
28
- };
29
- };
30
- };
31
- //# sourceMappingURL=api-intercept.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-intercept.d.ts","sourceRoot":"","sources":["../../src/api-intercept.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAwBxG,eAAO,MAAM,mBAAmB,cAAqB,GAAG,iBAGvD,CAAA;AAeD,eAAO,MAAM,oBAAoB,gBAAiB,WAAW,cAAc,cAAc,KAAG,gBAwB3F,CAAA;AAoBD,eAAO,MAAM,oBAAoB;eAA+B,GAAG;8BAA4B,UAAU,QAAQ,GAAG,KAAK,IAAI;iBAAe,WAAW;gBAAc,cAAc;iCAA+B;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,QAAQ;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;mBAyBpR,CAAA;AAED,eAAO,MAAM,8BAA8B,YAAa,GAAG;;;;;;;;;;;;;;CAoB1D,CAAA"}
@@ -1,117 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processLegacyInterceptResponse = exports.handleInterceptEvent = exports.getInterceptInitData = exports.processApiIntercept = void 0;
4
- const config_1 = require("./config");
5
- const embedConfig_1 = require("./embed/embedConfig");
6
- const types_1 = require("./types");
7
- const logger_1 = require("./utils/logger");
8
- const defaultUrls = {
9
- [types_1.InterceptedApiType.METADATA]: [
10
- '/prism/?op=CreateAnswerSession',
11
- '/prism/?op=GetV2SourceDetail',
12
- ],
13
- [types_1.InterceptedApiType.ANSWER_DATA]: [
14
- '/prism/?op=GetChartWithData',
15
- '/prism/?op=GetTableWithHeadlineData',
16
- ],
17
- [types_1.InterceptedApiType.LIVEBOARD_DATA]: [
18
- '/prism/?op=LoadContextBook'
19
- ],
20
- };
21
- const formatInterceptUrl = (url) => {
22
- const host = (0, config_1.getThoughtSpotHost)((0, embedConfig_1.getEmbedConfig)());
23
- if (url.startsWith('/'))
24
- return `${host}${url}`;
25
- return url;
26
- };
27
- const processApiIntercept = async (eventData) => {
28
- return JSON.parse(eventData.data);
29
- };
30
- exports.processApiIntercept = processApiIntercept;
31
- const processInterceptUrls = (interceptUrls) => {
32
- let processedUrls = [...interceptUrls];
33
- Object.entries(defaultUrls).forEach(([apiType, apiTypeUrls]) => {
34
- if (!processedUrls.includes(apiType))
35
- return;
36
- processedUrls = processedUrls.filter(url => url !== apiType);
37
- processedUrls = [...processedUrls, ...apiTypeUrls];
38
- });
39
- return processedUrls.map(url => formatInterceptUrl(url));
40
- };
41
- const getInterceptInitData = (embedConfig, viewConfig) => {
42
- const enableApiIntercept = (embedConfig.enableApiIntercept || viewConfig.enableApiIntercept) && (viewConfig.enableApiIntercept !== false);
43
- if (!enableApiIntercept)
44
- return {
45
- enableApiIntercept: false,
46
- };
47
- const combinedUrls = [...(embedConfig.interceptUrls || []), ...(viewConfig.interceptUrls || [])];
48
- if (viewConfig.isOnBeforeGetVizDataInterceptEnabled) {
49
- combinedUrls.push(types_1.InterceptedApiType.ANSWER_DATA);
50
- }
51
- const shouldInterceptAll = combinedUrls.includes(types_1.InterceptedApiType.ALL);
52
- const interceptUrls = shouldInterceptAll ? [types_1.InterceptedApiType.ALL] : processInterceptUrls(combinedUrls);
53
- const interceptTimeout = embedConfig.interceptTimeout || viewConfig.interceptTimeout;
54
- return {
55
- interceptUrls,
56
- interceptTimeout,
57
- enableApiIntercept,
58
- };
59
- };
60
- exports.getInterceptInitData = getInterceptInitData;
61
- /**
62
- *
63
- * @param fetchInit
64
- */
65
- const parseInterceptData = (eventDataString) => {
66
- try {
67
- const { input, init } = JSON.parse(eventDataString);
68
- init.body = JSON.parse(init.body);
69
- const parsedInit = { input, init };
70
- return [parsedInit, null];
71
- }
72
- catch (error) {
73
- return [null, error];
74
- }
75
- };
76
- const handleInterceptEvent = async (params) => {
77
- var _a, _b, _c, _d, _e;
78
- const { eventData, executeEvent, viewConfig, getUnsavedAnswerTml } = params;
79
- const [interceptData, bodyParseError] = parseInterceptData(eventData.data);
80
- if (bodyParseError) {
81
- executeEvent(types_1.EmbedEvent.Error, {
82
- error: 'Error parsing api intercept body',
83
- });
84
- logger_1.logger.error('Error parsing request body', bodyParseError);
85
- return;
86
- }
87
- const { input: requestUrl, init } = interceptData;
88
- const sessionId = (_c = (_b = (_a = init === null || init === void 0 ? void 0 : init.body) === null || _a === void 0 ? void 0 : _a.variables) === null || _b === void 0 ? void 0 : _b.session) === null || _c === void 0 ? void 0 : _c.sessionId;
89
- const vizId = (_e = (_d = init === null || init === void 0 ? void 0 : init.body) === null || _d === void 0 ? void 0 : _d.variables) === null || _e === void 0 ? void 0 : _e.contextBookId;
90
- if (defaultUrls.ANSWER_DATA.includes(requestUrl) && viewConfig.isOnBeforeGetVizDataInterceptEnabled) {
91
- const answerTml = await getUnsavedAnswerTml({ sessionId, vizId });
92
- executeEvent(types_1.EmbedEvent.OnBeforeGetVizDataIntercept, { data: { data: answerTml } });
93
- }
94
- executeEvent(types_1.EmbedEvent.ApiIntercept, interceptData);
95
- };
96
- exports.handleInterceptEvent = handleInterceptEvent;
97
- const processLegacyInterceptResponse = (payload) => {
98
- var _a, _b, _c;
99
- const payloadToSend = {
100
- execute: (_a = payload === null || payload === void 0 ? void 0 : payload.data) === null || _a === void 0 ? void 0 : _a.execute,
101
- response: {
102
- body: {
103
- errors: [
104
- {
105
- title: (_b = payload === null || payload === void 0 ? void 0 : payload.data) === null || _b === void 0 ? void 0 : _b.errorText,
106
- message: (_c = payload === null || payload === void 0 ? void 0 : payload.data) === null || _c === void 0 ? void 0 : _c.errorDescription,
107
- isUserError: true,
108
- },
109
- ],
110
- data: {},
111
- },
112
- },
113
- };
114
- return { data: payloadToSend };
115
- };
116
- exports.processLegacyInterceptResponse = processLegacyInterceptResponse;
117
- //# sourceMappingURL=api-intercept.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-intercept.js","sourceRoot":"","sources":["../../src/api-intercept.ts"],"names":[],"m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CAAC,CAAC;QAClE,YAAY,CAAC,kBAAU,CAAC,2BAA2B,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;KACvF;IAED,YAAY,CAAC,kBAAU,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AACzD,CAAC,CAAA;AAzBY,QAAA,oBAAoB,wBAyBhC;AAEM,MAAM,8BAA8B,GAAG,CAAC,OAAY,EAAE,EAAE;;IAE3D,MAAM,aAAa,GAAG;QAClB,OAAO,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,0CAAE,OAAO;QAC/B,QAAQ,EAAE;YACN,IAAI,EAAE;gBACF,MAAM,EAAE;oBACJ;wBACI,KAAK,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,0CAAE,SAAS;wBAC/B,OAAO,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,0CAAE,gBAAgB;wBACxC,WAAW,EAAE,IAAI;qBACpB;iBACJ;gBACD,IAAI,EAAE,EAAE;aACX;SACJ;KACJ,CAAC;IAGF,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AACnC,CAAC,CAAA;AApBY,QAAA,8BAA8B,kCAoB1C"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=api-intercept.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-intercept.spec.d.ts","sourceRoot":"","sources":["../../src/api-intercept.spec.ts"],"names":[],"mappings":""}
@@ -1,122 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const api_intercept_1 = require("./api-intercept");
5
- const types_1 = require("./types");
6
- const embedCfg = tslib_1.__importStar(require("./embed/embedConfig"));
7
- const cfg = tslib_1.__importStar(require("./config"));
8
- const logger_1 = require("./utils/logger");
9
- describe('api-intercept', () => {
10
- beforeEach(() => {
11
- jest.restoreAllMocks();
12
- jest.clearAllMocks();
13
- });
14
- describe('getInterceptInitData', () => {
15
- test('returns disabled when not enabled in either config', () => {
16
- const init = (0, api_intercept_1.getInterceptInitData)({}, {});
17
- expect(init).toEqual({ enableApiIntercept: false });
18
- });
19
- test('merges urls and expands api types, formats with host', () => {
20
- jest.spyOn(embedCfg, 'getEmbedConfig').mockReturnValue({ thoughtSpotHost: 'http://tshost' });
21
- jest.spyOn(cfg, 'getThoughtSpotHost').mockReturnValue('http://tshost');
22
- const embedConfig = { enableApiIntercept: true };
23
- const viewConfig = { interceptUrls: [types_1.InterceptedApiType.METADATA, '/custom/path'] };
24
- const init = (0, api_intercept_1.getInterceptInitData)(embedConfig, viewConfig);
25
- expect(init.enableApiIntercept).toBe(true);
26
- expect(init.interceptUrls).toEqual(expect.arrayContaining([
27
- 'http://tshost/prism/?op=CreateAnswerSession',
28
- 'http://tshost/prism/?op=GetV2SourceDetail',
29
- 'http://tshost/custom/path',
30
- ]));
31
- });
32
- test('honors InterceptedApiType.ALL and interceptTimeout', () => {
33
- const embedConfig = { enableApiIntercept: true, interceptTimeout: 2500 };
34
- const viewConfig = { interceptUrls: [types_1.InterceptedApiType.ALL] };
35
- const init = (0, api_intercept_1.getInterceptInitData)(embedConfig, viewConfig);
36
- expect(init).toEqual({
37
- enableApiIntercept: true,
38
- interceptUrls: [types_1.InterceptedApiType.ALL],
39
- interceptTimeout: 2500,
40
- });
41
- });
42
- test('legacy flag isOnBeforeGetVizDataInterceptEnabled adds ANSWER_DATA', () => {
43
- jest.spyOn(embedCfg, 'getEmbedConfig').mockReturnValue({ thoughtSpotHost: 'http://tshost' });
44
- jest.spyOn(cfg, 'getThoughtSpotHost').mockReturnValue('http://tshost');
45
- const embedConfig = { enableApiIntercept: true };
46
- const viewConfig = { isOnBeforeGetVizDataInterceptEnabled: true, interceptUrls: [] };
47
- const init = (0, api_intercept_1.getInterceptInitData)(embedConfig, viewConfig);
48
- // Should expand to concrete ANSWER_DATA URLs
49
- expect(init.interceptUrls).toEqual(expect.arrayContaining([
50
- 'http://tshost/prism/?op=GetChartWithData',
51
- 'http://tshost/prism/?op=GetTableWithHeadlineData',
52
- ]));
53
- });
54
- test('viewConfig enableApiIntercept=false overrides embed config', () => {
55
- const embedConfig = { enableApiIntercept: true };
56
- const viewConfig = { enableApiIntercept: false };
57
- const init = (0, api_intercept_1.getInterceptInitData)(embedConfig, viewConfig);
58
- expect(init).toEqual({ enableApiIntercept: false });
59
- });
60
- });
61
- describe('processApiIntercept', () => {
62
- test('parses data JSON string', async () => {
63
- const result = await (0, api_intercept_1.processApiIntercept)({ data: JSON.stringify({ foo: 'bar' }) });
64
- expect(result).toEqual({ foo: 'bar' });
65
- });
66
- });
67
- describe('handleInterceptEvent', () => {
68
- test('emits error on body parse failure', async () => {
69
- const executeEvent = jest.fn();
70
- const loggerErrSpy = jest.spyOn(logger_1.logger, 'error').mockImplementation(() => undefined);
71
- await (0, api_intercept_1.handleInterceptEvent)({
72
- eventData: { data: 'not-a-json' },
73
- executeEvent,
74
- embedConfig: {},
75
- viewConfig: {},
76
- getUnsavedAnswerTml: jest.fn(),
77
- });
78
- expect(executeEvent).toHaveBeenCalledWith(types_1.EmbedEvent.Error, { error: 'Error parsing api intercept body' });
79
- loggerErrSpy.mockReset();
80
- });
81
- test('calls getUnsavedAnswerTml and emits legacy + ApiIntercept events when applicable', async () => {
82
- const executeEvent = jest.fn();
83
- const getUnsavedAnswerTml = jest.fn().mockResolvedValue({ tml: 'TML_STRING' });
84
- const eventPayload = {
85
- input: '/prism/?op=GetChartWithData',
86
- init: {
87
- body: JSON.stringify({
88
- variables: {
89
- session: { sessionId: 'S1' },
90
- contextBookId: 'V1',
91
- },
92
- }),
93
- },
94
- };
95
- await (0, api_intercept_1.handleInterceptEvent)({
96
- eventData: { data: JSON.stringify(eventPayload) },
97
- executeEvent,
98
- embedConfig: {},
99
- viewConfig: { isOnBeforeGetVizDataInterceptEnabled: true },
100
- getUnsavedAnswerTml,
101
- });
102
- expect(getUnsavedAnswerTml).toHaveBeenCalledWith({ sessionId: 'S1', vizId: 'V1' });
103
- expect(executeEvent).toHaveBeenCalledWith(types_1.EmbedEvent.OnBeforeGetVizDataIntercept, { data: { data: { tml: 'TML_STRING' } } });
104
- expect(executeEvent).toHaveBeenCalledWith(types_1.EmbedEvent.ApiIntercept, expect.objectContaining({ input: '/prism/?op=GetChartWithData' }));
105
- });
106
- });
107
- describe('processLegacyInterceptResponse', () => {
108
- test('wraps legacy error payload as expected', () => {
109
- const payload = { data: { errorText: 'Title', errorDescription: 'Desc' } };
110
- const res = (0, api_intercept_1.processLegacyInterceptResponse)(payload);
111
- expect(Array.isArray(res)).toBe(true);
112
- expect(res[0]).toEqual(expect.objectContaining({
113
- errors: [
114
- expect.objectContaining({
115
- errorObj: expect.objectContaining({ title: 'Title', desc: 'Desc' }),
116
- }),
117
- ],
118
- }));
119
- });
120
- });
121
- });
122
- //# sourceMappingURL=api-intercept.spec.js.map