@thoughtspot/visual-embed-sdk 1.46.4 → 1.46.5-beta.1

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 (172) hide show
  1. package/cjs/package.json +2 -2
  2. package/cjs/src/auth.d.ts +2 -1
  3. package/cjs/src/auth.d.ts.map +1 -1
  4. package/cjs/src/auth.js +2 -1
  5. package/cjs/src/auth.js.map +1 -1
  6. package/cjs/src/authToken.d.ts.map +1 -1
  7. package/cjs/src/authToken.js.map +1 -1
  8. package/cjs/src/css-variables.d.ts +51 -17
  9. package/cjs/src/css-variables.d.ts.map +1 -1
  10. package/cjs/src/embed/app.d.ts +1 -0
  11. package/cjs/src/embed/app.d.ts.map +1 -1
  12. package/cjs/src/embed/app.js +10 -1
  13. package/cjs/src/embed/app.js.map +1 -1
  14. package/cjs/src/embed/app.spec.js +46 -1
  15. package/cjs/src/embed/app.spec.js.map +1 -1
  16. package/cjs/src/embed/base.d.ts.map +1 -1
  17. package/cjs/src/embed/base.js.map +1 -1
  18. package/cjs/src/embed/base.spec.js.map +1 -1
  19. package/cjs/src/embed/events.spec.js +72 -0
  20. package/cjs/src/embed/events.spec.js.map +1 -1
  21. package/cjs/src/embed/hostEventClient/contracts.d.ts +74 -3
  22. package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  23. package/cjs/src/embed/hostEventClient/contracts.js +7 -0
  24. package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
  25. package/cjs/src/embed/hostEventClient/host-event-client.d.ts +10 -0
  26. package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  27. package/cjs/src/embed/hostEventClient/host-event-client.js +46 -9
  28. package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
  29. package/cjs/src/embed/hostEventClient/host-event-client.spec.js +155 -0
  30. package/cjs/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  31. package/cjs/src/embed/liveboard.d.ts +1 -0
  32. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  33. package/cjs/src/embed/liveboard.js +11 -2
  34. package/cjs/src/embed/liveboard.js.map +1 -1
  35. package/cjs/src/embed/liveboard.spec.js +96 -2
  36. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  37. package/cjs/src/embed/sage.d.ts.map +1 -1
  38. package/cjs/src/embed/sage.js.map +1 -1
  39. package/cjs/src/embed/search.spec.js.map +1 -1
  40. package/cjs/src/embed/ts-embed.d.ts +41 -2
  41. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  42. package/cjs/src/embed/ts-embed.js +41 -2
  43. package/cjs/src/embed/ts-embed.js.map +1 -1
  44. package/cjs/src/react/index.d.ts.map +1 -1
  45. package/cjs/src/react/index.js +58 -53
  46. package/cjs/src/react/index.js.map +1 -1
  47. package/cjs/src/types.d.ts +730 -32
  48. package/cjs/src/types.d.ts.map +1 -1
  49. package/cjs/src/types.js +734 -3
  50. package/cjs/src/types.js.map +1 -1
  51. package/cjs/src/utils/graphql/answerService/answerService.d.ts +4 -2
  52. package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  53. package/cjs/src/utils/graphql/answerService/answerService.js +4 -2
  54. package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
  55. package/cjs/src/utils/graphql/preview-service.d.ts.map +1 -1
  56. package/cjs/src/utils/graphql/preview-service.js.map +1 -1
  57. package/cjs/src/utils/processData.d.ts.map +1 -1
  58. package/cjs/src/utils/processData.js.map +1 -1
  59. package/dist/{index-DGV_zh53.js → index-DW2wEHqy.js} +1 -1
  60. package/dist/src/auth.d.ts +2 -1
  61. package/dist/src/auth.d.ts.map +1 -1
  62. package/dist/src/authToken.d.ts.map +1 -1
  63. package/dist/src/css-variables.d.ts +51 -17
  64. package/dist/src/css-variables.d.ts.map +1 -1
  65. package/dist/src/embed/app.d.ts +1 -0
  66. package/dist/src/embed/app.d.ts.map +1 -1
  67. package/dist/src/embed/base.d.ts.map +1 -1
  68. package/dist/src/embed/hostEventClient/contracts.d.ts +74 -3
  69. package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  70. package/dist/src/embed/hostEventClient/host-event-client.d.ts +10 -0
  71. package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  72. package/dist/src/embed/liveboard.d.ts +1 -0
  73. package/dist/src/embed/liveboard.d.ts.map +1 -1
  74. package/dist/src/embed/sage.d.ts.map +1 -1
  75. package/dist/src/embed/ts-embed.d.ts +41 -2
  76. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  77. package/dist/src/react/index.d.ts.map +1 -1
  78. package/dist/src/types.d.ts +730 -32
  79. package/dist/src/types.d.ts.map +1 -1
  80. package/dist/src/utils/graphql/answerService/answerService.d.ts +4 -2
  81. package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  82. package/dist/src/utils/graphql/preview-service.d.ts.map +1 -1
  83. package/dist/src/utils/processData.d.ts.map +1 -1
  84. package/dist/tsembed-react.es.js +917 -77
  85. package/dist/tsembed-react.js +915 -75
  86. package/dist/tsembed.es.js +859 -24
  87. package/dist/tsembed.js +857 -22
  88. package/dist/visual-embed-sdk-react-full.d.ts +892 -54
  89. package/dist/visual-embed-sdk-react.d.ts +892 -54
  90. package/dist/visual-embed-sdk.d.ts +912 -56
  91. package/lib/package.json +2 -2
  92. package/lib/src/auth.d.ts +2 -1
  93. package/lib/src/auth.d.ts.map +1 -1
  94. package/lib/src/auth.js +2 -1
  95. package/lib/src/auth.js.map +1 -1
  96. package/lib/src/authToken.d.ts.map +1 -1
  97. package/lib/src/authToken.js.map +1 -1
  98. package/lib/src/css-variables.d.ts +51 -17
  99. package/lib/src/css-variables.d.ts.map +1 -1
  100. package/lib/src/embed/app.d.ts +1 -0
  101. package/lib/src/embed/app.d.ts.map +1 -1
  102. package/lib/src/embed/app.js +10 -1
  103. package/lib/src/embed/app.js.map +1 -1
  104. package/lib/src/embed/app.spec.js +46 -1
  105. package/lib/src/embed/app.spec.js.map +1 -1
  106. package/lib/src/embed/base.d.ts.map +1 -1
  107. package/lib/src/embed/base.js.map +1 -1
  108. package/lib/src/embed/base.spec.js.map +1 -1
  109. package/lib/src/embed/events.spec.js +73 -1
  110. package/lib/src/embed/events.spec.js.map +1 -1
  111. package/lib/src/embed/hostEventClient/contracts.d.ts +74 -3
  112. package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  113. package/lib/src/embed/hostEventClient/contracts.js +7 -0
  114. package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
  115. package/lib/src/embed/hostEventClient/host-event-client.d.ts +10 -0
  116. package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  117. package/lib/src/embed/hostEventClient/host-event-client.js +46 -9
  118. package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
  119. package/lib/src/embed/hostEventClient/host-event-client.spec.js +155 -0
  120. package/lib/src/embed/hostEventClient/host-event-client.spec.js.map +1 -1
  121. package/lib/src/embed/liveboard.d.ts +1 -0
  122. package/lib/src/embed/liveboard.d.ts.map +1 -1
  123. package/lib/src/embed/liveboard.js +11 -2
  124. package/lib/src/embed/liveboard.js.map +1 -1
  125. package/lib/src/embed/liveboard.spec.js +96 -2
  126. package/lib/src/embed/liveboard.spec.js.map +1 -1
  127. package/lib/src/embed/sage.d.ts.map +1 -1
  128. package/lib/src/embed/sage.js.map +1 -1
  129. package/lib/src/embed/search.spec.js.map +1 -1
  130. package/lib/src/embed/ts-embed.d.ts +41 -2
  131. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  132. package/lib/src/embed/ts-embed.js +42 -3
  133. package/lib/src/embed/ts-embed.js.map +1 -1
  134. package/lib/src/react/index.d.ts.map +1 -1
  135. package/lib/src/react/index.js +58 -53
  136. package/lib/src/react/index.js.map +1 -1
  137. package/lib/src/types.d.ts +730 -32
  138. package/lib/src/types.d.ts.map +1 -1
  139. package/lib/src/types.js +734 -3
  140. package/lib/src/types.js.map +1 -1
  141. package/lib/src/utils/graphql/answerService/answerService.d.ts +4 -2
  142. package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
  143. package/lib/src/utils/graphql/answerService/answerService.js +4 -2
  144. package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
  145. package/lib/src/utils/graphql/preview-service.d.ts.map +1 -1
  146. package/lib/src/utils/graphql/preview-service.js.map +1 -1
  147. package/lib/src/utils/processData.d.ts.map +1 -1
  148. package/lib/src/utils/processData.js.map +1 -1
  149. package/lib/src/visual-embed-sdk.d.ts +912 -56
  150. package/package.json +2 -2
  151. package/src/auth.spec.ts +1 -1
  152. package/src/auth.ts +2 -1
  153. package/src/authToken.ts +0 -1
  154. package/src/css-variables.ts +51 -17
  155. package/src/embed/app.spec.ts +62 -3
  156. package/src/embed/app.ts +10 -1
  157. package/src/embed/base.spec.ts +1 -2
  158. package/src/embed/base.ts +1 -4
  159. package/src/embed/events.spec.ts +88 -0
  160. package/src/embed/hostEventClient/contracts.ts +74 -2
  161. package/src/embed/hostEventClient/host-event-client.spec.ts +257 -0
  162. package/src/embed/hostEventClient/host-event-client.ts +70 -15
  163. package/src/embed/liveboard.spec.ts +126 -2
  164. package/src/embed/liveboard.ts +11 -2
  165. package/src/embed/sage.ts +0 -1
  166. package/src/embed/search.spec.ts +0 -2
  167. package/src/embed/ts-embed.ts +43 -3
  168. package/src/react/index.tsx +76 -72
  169. package/src/types.ts +739 -31
  170. package/src/utils/graphql/answerService/answerService.ts +4 -5
  171. package/src/utils/graphql/preview-service.ts +0 -1
  172. package/src/utils/processData.ts +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.46.4",
3
+ "version": "1.46.5-beta.1",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
@@ -57,7 +57,7 @@
57
57
  "test": "npm run test-sdk",
58
58
  "posttest": "cat ./coverage/sdk/lcov.info | npx coveralls-next || echo 'Warning: Coveralls upload failed but not breaking the build.'",
59
59
  "is-publish-allowed": "node scripts/is-publish-allowed.js",
60
- "prepublishOnly": "npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build",
60
+ "prepublishOnly": "npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build",
61
61
  "check-size": "npm run build && size-limit",
62
62
  "publish-dev": "npm publish --tag dev",
63
63
  "publish-prod": "npm publish --tag latest",
package/src/auth.spec.ts CHANGED
@@ -283,7 +283,7 @@ describe('Unit test for auth', () => {
283
283
  text: () => Promise.resolve('abc'),
284
284
  } as any));
285
285
  jest.spyOn(authService, 'fetchAuthPostService').mockImplementation(() =>
286
-
286
+
287
287
  Promise.reject({
288
288
  status: 500,
289
289
  }));
package/src/auth.ts CHANGED
@@ -54,7 +54,8 @@ export enum AuthFailureType {
54
54
  /**
55
55
  * The current authentication token or session has expired.
56
56
  *
57
- * Emitted when the embed receives an auth-expiry signal and starts auth refresh handling.
57
+ * Emitted when the embed receives an auth-expiry signal and starts auth refresh
58
+ * handling.
58
59
  */
59
60
  EXPIRY = 'EXPIRY',
60
61
  /**
package/src/authToken.ts CHANGED
@@ -83,7 +83,6 @@ export const validateAuthToken = async (
83
83
 
84
84
  if (cachedAuthToken && cachedAuthToken === authToken) {
85
85
  if (!embedConfig.suppressErrorAlerts && !suppressAlert) {
86
-
87
86
  alert(ERROR_MESSAGE.DUPLICATE_TOKEN_ERR);
88
87
  }
89
88
  throw new Error(ERROR_MESSAGE.DUPLICATE_TOKEN_ERR);
@@ -517,42 +517,54 @@ export interface CustomCssVariables {
517
517
  /**
518
518
  * Padding of the groups in the Liveboard.
519
519
  *
520
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
520
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
521
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
522
+ * this CSS variable.
521
523
  */
522
524
  '--ts-var-liveboard-group-padding'?: string;
523
525
 
524
526
  /**
525
527
  * Font size of the title of the groups in the Liveboard.
526
528
  *
527
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
529
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
530
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
531
+ * this CSS variable.
528
532
  */
529
533
  '--ts-var-liveboard-group-title-font-size'?: string;
530
534
 
531
535
  /**
532
536
  * Font weight of the title of the groups in the Liveboard.
533
537
  *
534
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
538
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
539
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
540
+ * this CSS variable.
535
541
  */
536
542
  '--ts-var-liveboard-group-title-font-weight'?: string;
537
543
 
538
544
  /**
539
545
  * Font size of the title of the tiles inside the groups in the Liveboard.
540
546
  *
541
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
547
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
548
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
549
+ * this CSS variable.
542
550
  */
543
551
  '--ts-var-liveboard-group-tile-title-font-size'?: string;
544
552
 
545
553
  /**
546
554
  * Font weight of the title of the tiles inside the groups in the Liveboard.
547
555
  *
548
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
556
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
557
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
558
+ * this CSS variable.
549
559
  */
550
560
  '--ts-var-liveboard-group-tile-title-font-weight'?: string;
551
561
 
552
562
  /**
553
563
  * Padding of the group tiles in the Liveboard.
554
564
  *
555
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
565
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
566
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
567
+ * this CSS variable.
556
568
  */
557
569
  '--ts-var-liveboard-group-tile-padding'?: string;
558
570
 
@@ -564,14 +576,18 @@ export interface CustomCssVariables {
564
576
  /**
565
577
  * Background color of the groups in the Liveboard.
566
578
  *
567
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
579
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
580
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
581
+ * this CSS variable.
568
582
  */
569
583
  '--ts-var-liveboard-group-background'?: string;
570
584
 
571
585
  /**
572
586
  * Border color of the groups in the Liveboard.
573
587
  *
574
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
588
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
589
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
590
+ * this CSS variable.
575
591
  */
576
592
  '--ts-var-liveboard-group-border-color'?: string;
577
593
 
@@ -588,63 +604,81 @@ export interface CustomCssVariables {
588
604
  /**
589
605
  * Font color of the title of the groups in the Liveboard.
590
606
  *
591
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
607
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
608
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
609
+ * this CSS variable.
592
610
  */
593
611
  '--ts-var-liveboard-group-title-font-color'?: string;
594
612
 
595
613
  /**
596
614
  * Font color of the description of the groups in the Liveboard.
597
615
  *
598
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
616
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
617
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
618
+ * this CSS variable.
599
619
  */
600
620
  '--ts-var-liveboard-group-description-font-color'?: string;
601
621
 
602
622
  /**
603
623
  * Font color of the title of the tiles inside the groups in the Liveboard.
604
624
  *
605
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
625
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
626
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
627
+ * this CSS variable.
606
628
  */
607
629
  '--ts-var-liveboard-group-tile-title-font-color'?: string;
608
630
 
609
631
  /**
610
632
  * Font color of the description of the tiles inside the groups in the Liveboard.
611
633
  *
612
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
634
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
635
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
636
+ * this CSS variable.
613
637
  */
614
638
  '--ts-var-liveboard-group-tile-description-font-color'?: string;
615
639
 
616
640
  /**
617
641
  * Background color of the tiles inside the groups in the Liveboard.
618
642
  *
619
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
643
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
644
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
645
+ * this CSS variable.
620
646
  */
621
647
  '--ts-var-liveboard-group-tile-background'?: string;
622
648
 
623
649
  /**
624
650
  * Background color of the filter chips in the Liveboard.
625
651
  *
626
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
652
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
653
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
654
+ * this CSS variable.
627
655
  */
628
656
  '--ts-var-liveboard-chip-background'?: string;
629
657
 
630
658
  /**
631
659
  * Font color of the filter chips in the Liveboard.
632
660
  *
633
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
661
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
662
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
663
+ * this CSS variable.
634
664
  */
635
665
  '--ts-var-liveboard-chip-color'?: string;
636
666
 
637
667
  /**
638
668
  * Background color of the filter chips in the Liveboard on hover.
639
669
  *
640
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
670
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
671
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
672
+ * this CSS variable.
641
673
  */
642
674
  '--ts-var-liveboard-chip--hover-background'?: string;
643
675
 
644
676
  /**
645
677
  * Background color of the filter chips in the Liveboard on active.
646
678
  *
647
- * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying this CSS variable.
679
+ * Please enable the Liveboard Masterpieces feature in your ThoughtSpot instance and
680
+ * then set the isLiveboardMasterpiecesEnabled SDK flag to true to start modifying
681
+ * this CSS variable.
648
682
  */
649
683
  '--ts-var-liveboard-chip--active-background'?: string;
650
684
 
@@ -1247,6 +1247,7 @@ describe('App embed tests', () => {
1247
1247
  });
1248
1248
 
1249
1249
  test('should register event handlers to adjust iframe height', async () => {
1250
+ jest.spyOn(logger, 'error').mockImplementation(() => {});
1250
1251
  let embedHeightCallback: any = () => { };
1251
1252
  const onSpy = jest.spyOn(AppEmbed.prototype, 'on').mockImplementation((event, callback) => {
1252
1253
  if (event === EmbedEvent.RouteChange) {
@@ -1638,8 +1639,8 @@ describe('App embed tests', () => {
1638
1639
 
1639
1640
  describe('IFrame height management', () => {
1640
1641
  let mockIFrame: HTMLIFrameElement;
1641
-
1642
1642
  beforeEach(() => {
1643
+ jest.spyOn(logger, 'error').mockImplementation(() => {});
1643
1644
  mockIFrame = document.createElement('iframe');
1644
1645
  mockIFrame.getBoundingClientRect = jest.fn().mockReturnValue({
1645
1646
  top: 100,
@@ -1691,13 +1692,16 @@ describe('App embed tests', () => {
1691
1692
  fullHeight: true,
1692
1693
  } as AppViewConfig) as any;
1693
1694
 
1694
- // Set up the mock iframe
1695
+ // Set up the mock iframe with a height that differs from defaultHeight by > threshold
1696
+ mockIFrame.getBoundingClientRect = jest.fn().mockReturnValue({
1697
+ top: 100, left: 150, bottom: 100, right: 800, width: 650, height: 0,
1698
+ });
1695
1699
  appEmbed.iFrame = mockIFrame;
1696
1700
  document.body.appendChild(mockIFrame);
1697
1701
 
1698
1702
  await appEmbed.render();
1699
1703
  const mockEvent = {
1700
- data: 0, // This will make it use the default height
1704
+ data: 0, // This will make it use the default height (500); change = |500 - 0| = 500 >= 30
1701
1705
  type: EmbedEvent.EmbedHeight,
1702
1706
  };
1703
1707
  appEmbed.updateIFrameHeight(mockEvent);
@@ -1705,6 +1709,61 @@ describe('App embed tests', () => {
1705
1709
  // Should use the default height
1706
1710
  expect(mockIFrame.style.height).toBe('500px');
1707
1711
  });
1712
+
1713
+ test('should skip height update when change is below threshold', async () => {
1714
+ const appEmbed = new AppEmbed(getRootEl(), {
1715
+ ...defaultViewConfig,
1716
+ fullHeight: true,
1717
+ } as AppViewConfig) as any;
1718
+
1719
+ appEmbed.iFrame = mockIFrame;
1720
+ document.body.appendChild(mockIFrame);
1721
+ await appEmbed.render();
1722
+
1723
+ const spySetIFrameHeight = jest.spyOn(appEmbed, 'setIFrameHeight');
1724
+
1725
+ // currentHeight is 500; heightToSet will be max(510, 500) = 510; change = 10 < 30
1726
+ appEmbed.updateIFrameHeight({ data: 510, type: EmbedEvent.EmbedHeight });
1727
+
1728
+ expect(spySetIFrameHeight).not.toHaveBeenCalled();
1729
+ });
1730
+
1731
+ test('should update height when change meets threshold', async () => {
1732
+ const appEmbed = new AppEmbed(getRootEl(), {
1733
+ ...defaultViewConfig,
1734
+ fullHeight: true,
1735
+ } as AppViewConfig) as any;
1736
+
1737
+ appEmbed.iFrame = mockIFrame;
1738
+ document.body.appendChild(mockIFrame);
1739
+ await appEmbed.render();
1740
+
1741
+ const spySetIFrameHeight = jest.spyOn(appEmbed, 'setIFrameHeight');
1742
+
1743
+ // currentHeight is 500; heightToSet = max(600, 500) = 600; change = 100 >= 30
1744
+ appEmbed.updateIFrameHeight({ data: 600, type: EmbedEvent.EmbedHeight });
1745
+
1746
+ expect(spySetIFrameHeight).toHaveBeenCalledWith(600);
1747
+ });
1748
+
1749
+ test('should use defaultHeight when data is below it and check threshold', async () => {
1750
+ const appEmbed = new AppEmbed(getRootEl(), {
1751
+ ...defaultViewConfig,
1752
+ fullHeight: true,
1753
+ minimumHeight: 800,
1754
+ } as AppViewConfig) as any;
1755
+
1756
+ appEmbed.iFrame = mockIFrame;
1757
+ document.body.appendChild(mockIFrame);
1758
+ await appEmbed.render();
1759
+
1760
+ const spySetIFrameHeight = jest.spyOn(appEmbed, 'setIFrameHeight');
1761
+
1762
+ // currentHeight is 500; heightToSet = max(100, 800) = 800; change = 300 >= 30
1763
+ appEmbed.updateIFrameHeight({ data: 100, type: EmbedEvent.EmbedHeight });
1764
+
1765
+ expect(spySetIFrameHeight).toHaveBeenCalledWith(800);
1766
+ });
1708
1767
  });
1709
1768
  });
1710
1769
 
package/src/embed/app.ts CHANGED
@@ -1115,13 +1115,22 @@ export class AppEmbed extends V1Embed {
1115
1115
  return url;
1116
1116
  }
1117
1117
 
1118
+ private HEIGHT_CHANAGE_THRESHOLD = 30;
1118
1119
  /**
1119
1120
  * Set the iframe height as per the computed height received
1120
1121
  * from the ThoughtSpot app.
1121
1122
  * @param data The event payload
1122
1123
  */
1123
1124
  protected updateIFrameHeight = (data: MessagePayload) => {
1124
- this.setIFrameHeight(Math.max(data.data, this.defaultHeight));
1125
+ logger.error('Updating iframe height', data);
1126
+ const currentHeight = this.iFrame.getBoundingClientRect().height;
1127
+ const heightToSet = Math.max(data.data, this.defaultHeight);
1128
+ const heightChange = Math.abs(heightToSet - currentHeight);
1129
+ if (heightChange < this.HEIGHT_CHANAGE_THRESHOLD) {
1130
+ logger.info('Height change is less than the threshold, skipping height update', { heightChange, heightToSet, currentHeight });
1131
+ return;
1132
+ }
1133
+ this.setIFrameHeight(heightToSet);
1125
1134
  this.sendFullHeightLazyLoadData();
1126
1135
  };
1127
1136
 
@@ -1,5 +1,4 @@
1
-
2
- /* eslint-disable @typescript-eslint/no-shadow */
1
+ /* eslint-disable @typescript-eslint/no-shadow */
3
2
  import EventEmitter from 'eventemitter3';
4
3
  import { EmbedConfig } from '../index';
5
4
  import * as auth from '../auth';
package/src/embed/base.ts CHANGED
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  /**
4
2
  * Copyright (c) 2022
5
3
  *
@@ -115,7 +113,6 @@ export const prefetch = (
115
113
  additionalFlags?: { [key: string]: string | number | boolean },
116
114
  ): void => {
117
115
  if (url === '') {
118
-
119
116
  logger.warn('The prefetch method does not have a valid URL');
120
117
  } else {
121
118
  const features = prefetchFeatures || [PrefetchFeatures.FullApp];
@@ -322,7 +319,7 @@ export const renderInQueue = (fn: (next?: (val?: any) => void) => Promise<any>):
322
319
  return renderQueue;
323
320
  }
324
321
  // Sending an empty function to keep it consistent with the above usage.
325
- return fn(() => {});
322
+ return fn(() => {});
326
323
  };
327
324
 
328
325
  /**
@@ -2,6 +2,7 @@ import { logger } from '../utils/logger';
2
2
  import {
3
3
  init,
4
4
  AuthType,
5
+ Action,
5
6
  EmbedEvent,
6
7
  SearchEmbed,
7
8
  PinboardEmbed,
@@ -254,6 +255,75 @@ describe('test communication between host app and ThoughtSpot', () => {
254
255
  };
255
256
  expect(mockPort.postMessage).toHaveBeenCalledWith(heightObj);
256
257
  });
258
+ test('should handle UpdatePersonalizedView as alias for UpdatePersonalisedView', async () => {
259
+ const handler = jest.fn();
260
+
261
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
262
+ ...defaultViewConfig,
263
+ liveboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
264
+ } as LiveboardViewConfig);
265
+ liveboardEmbed.on(EmbedEvent.UpdatePersonalizedView, handler).render();
266
+
267
+ await executeAfterWait(() => {
268
+ const iframe = getIFrameEl();
269
+ postMessageToParent(iframe.contentWindow, {
270
+ type: EmbedEvent.UpdatePersonalisedView,
271
+ data: PAYLOAD,
272
+ });
273
+ });
274
+
275
+ await executeAfterWait(() => {
276
+ expect(handler).toHaveBeenCalled();
277
+ expect(handler.mock.calls[0][0].data).toBe(PAYLOAD);
278
+ }, EVENT_WAIT_TIME);
279
+ });
280
+
281
+ test('should handle SavePersonalizedView as alias for SavePersonalisedView', async () => {
282
+ const handler = jest.fn();
283
+
284
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
285
+ ...defaultViewConfig,
286
+ liveboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
287
+ } as LiveboardViewConfig);
288
+ liveboardEmbed.on(EmbedEvent.SavePersonalizedView, handler).render();
289
+
290
+ await executeAfterWait(() => {
291
+ const iframe = getIFrameEl();
292
+ postMessageToParent(iframe.contentWindow, {
293
+ type: EmbedEvent.SavePersonalisedView,
294
+ data: PAYLOAD,
295
+ });
296
+ });
297
+
298
+ await executeAfterWait(() => {
299
+ expect(handler).toHaveBeenCalled();
300
+ expect(handler.mock.calls[0][0].data).toBe(PAYLOAD);
301
+ }, EVENT_WAIT_TIME);
302
+ });
303
+
304
+ test('should handle DeletePersonalizedView as alias for DeletePersonalisedView', async () => {
305
+ const handler = jest.fn();
306
+
307
+ const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
308
+ ...defaultViewConfig,
309
+ liveboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
310
+ } as LiveboardViewConfig);
311
+ liveboardEmbed.on(EmbedEvent.DeletePersonalizedView, handler).render();
312
+
313
+ await executeAfterWait(() => {
314
+ const iframe = getIFrameEl();
315
+ postMessageToParent(iframe.contentWindow, {
316
+ type: EmbedEvent.DeletePersonalisedView,
317
+ data: PAYLOAD,
318
+ });
319
+ });
320
+
321
+ await executeAfterWait(() => {
322
+ expect(handler).toHaveBeenCalled();
323
+ expect(handler.mock.calls[0][0].data).toBe(PAYLOAD);
324
+ }, EVENT_WAIT_TIME);
325
+ });
326
+
257
327
  test('ALL event listener should fire for all events with the event type set correctly', async () => {
258
328
  const embed = new AppEmbed(getRootEl(), defaultViewConfig);
259
329
  const spy = jest.fn();
@@ -286,3 +356,21 @@ describe('test communication between host app and ThoughtSpot', () => {
286
356
  }, EVENT_WAIT_TIME);
287
357
  });
288
358
  });
359
+
360
+ describe('Americanized enum alias values', () => {
361
+ test('EmbedEvent aliases should resolve to the same values as their British counterparts', () => {
362
+ expect(EmbedEvent.UpdatePersonalizedView).toBe(EmbedEvent.UpdatePersonalisedView);
363
+ expect(EmbedEvent.SavePersonalizedView).toBe(EmbedEvent.SavePersonalisedView);
364
+ expect(EmbedEvent.DeletePersonalizedView).toBe(EmbedEvent.DeletePersonalisedView);
365
+ });
366
+
367
+ test('HostEvent aliases should resolve to the same values as their British counterparts', () => {
368
+ expect(HostEvent.ResetLiveboardPersonalizedView).toBe(HostEvent.ResetLiveboardPersonalisedView);
369
+ expect(HostEvent.UpdatePersonalizedView).toBe(HostEvent.UpdatePersonalisedView);
370
+ });
371
+
372
+ test('Action aliases should resolve to the same values as their British counterparts', () => {
373
+ expect(Action.PersonalizedViewsDropdown).toBe(Action.PersonalisedViewsDropdown);
374
+ expect(Action.OrganizeFavorites).toBe(Action.OrganiseFavourites);
375
+ });
376
+ });
@@ -1,4 +1,11 @@
1
- import { ContextType, HostEvent } from '../../types';
1
+ import { ContextType, HostEvent, RuntimeFilter } from '../../types';
2
+ import { SessionInterface } from '../../utils/graphql/answerService/answerService';
3
+
4
+ export interface LiveboardTab {
5
+ id: string;
6
+ name: string;
7
+ [key: string]: any;
8
+ }
2
9
 
3
10
  export enum UIPassthroughEvent {
4
11
  PinAnswerToLiveboard = 'addVizToPinboard',
@@ -8,6 +15,13 @@ export enum UIPassthroughEvent {
8
15
  GetAnswerConfig = 'getAnswerPageConfig',
9
16
  GetLiveboardConfig = 'getPinboardPageConfig',
10
17
  GetUnsavedAnswerTML = 'getUnsavedAnswerTML',
18
+ GetAnswerSession = 'getAnswerSession',
19
+ GetFilters = 'getFilters',
20
+ GetIframeUrl = 'getIframeUrl',
21
+ GetParameters = 'getParameters',
22
+ GetTML = 'getTML',
23
+ GetTabs = 'getTabs',
24
+ GetExportRequestForCurrentPinboard = 'getExportRequestForCurrentPinboard',
11
25
  }
12
26
 
13
27
  // UI Passthrough Contract
@@ -73,6 +87,57 @@ export type UIPassthroughContractBase = {
73
87
  tml: string;
74
88
  };
75
89
  };
90
+ [UIPassthroughEvent.GetAnswerSession]: {
91
+ request: {
92
+ vizId?: string;
93
+ };
94
+ response: {
95
+ session: SessionInterface;
96
+ embedAnswerData?: Record<string, any>;
97
+ };
98
+ };
99
+ [UIPassthroughEvent.GetFilters]: {
100
+ request: {
101
+ vizId?: string;
102
+ };
103
+ response: {
104
+ liveboardFilters: Record<string, any>[];
105
+ runtimeFilters: RuntimeFilter[];
106
+ };
107
+ };
108
+ [UIPassthroughEvent.GetIframeUrl]: {
109
+ request: Record<string, never>;
110
+ response: {
111
+ iframeUrl: string;
112
+ };
113
+ };
114
+ [UIPassthroughEvent.GetParameters]: {
115
+ request: Record<string, never>;
116
+ response: {
117
+ parameters: Record<string, any>[];
118
+ };
119
+ };
120
+ [UIPassthroughEvent.GetTML]: {
121
+ request: {
122
+ vizId?: string;
123
+ includeNonExecutedSearchTokens?: boolean;
124
+ };
125
+ response: Record<string, any>;
126
+ };
127
+ [UIPassthroughEvent.GetTabs]: {
128
+ request: Record<string, never>;
129
+ response: {
130
+ orderedTabIds: string[];
131
+ numberOfTabs: number;
132
+ Tabs: LiveboardTab[];
133
+ };
134
+ };
135
+ [UIPassthroughEvent.GetExportRequestForCurrentPinboard]: {
136
+ request: Record<string, never>;
137
+ response: {
138
+ v2Content: string;
139
+ };
140
+ };
76
141
  };
77
142
 
78
143
  // UI Passthrough Request and Response
@@ -86,7 +151,7 @@ export type UIPassthroughResponse<
86
151
 
87
152
  export type UIPassthroughArrayResponse<ApiName extends keyof UIPassthroughContractBase> =
88
153
  Array<{
89
- redId?: string;
154
+ refId?: string;
90
155
  value?: UIPassthroughResponse<ApiName>;
91
156
  error?: any;
92
157
  }>
@@ -95,6 +160,13 @@ export type UIPassthroughArrayResponse<ApiName extends keyof UIPassthroughContra
95
160
  export type EmbedApiHostEventMapping = {
96
161
  [HostEvent.Pin]: UIPassthroughEvent.PinAnswerToLiveboard;
97
162
  [HostEvent.SaveAnswer]: UIPassthroughEvent.SaveAnswer;
163
+ [HostEvent.GetAnswerSession]: UIPassthroughEvent.GetAnswerSession;
164
+ [HostEvent.GetFilters]: UIPassthroughEvent.GetFilters;
165
+ [HostEvent.GetIframeUrl]: UIPassthroughEvent.GetIframeUrl;
166
+ [HostEvent.GetParameters]: UIPassthroughEvent.GetParameters;
167
+ [HostEvent.GetTML]: UIPassthroughEvent.GetTML;
168
+ [HostEvent.GetTabs]: UIPassthroughEvent.GetTabs;
169
+ [HostEvent.getExportRequestForCurrentPinboard]: UIPassthroughEvent.GetExportRequestForCurrentPinboard;
98
170
  }
99
171
 
100
172
  // Host Event Request and Response