@thoughtspot/visual-embed-sdk 1.20.0 → 1.20.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 (73) hide show
  1. package/dist/src/auth.d.ts +38 -4
  2. package/dist/src/auth.d.ts.map +1 -1
  3. package/dist/src/embed/app.d.ts +2 -2
  4. package/dist/src/embed/base.d.ts +25 -14
  5. package/dist/src/embed/base.d.ts.map +1 -1
  6. package/dist/src/embed/liveboard.d.ts +13 -3
  7. package/dist/src/embed/liveboard.d.ts.map +1 -1
  8. package/dist/src/embed/search-bar.d.ts +4 -1
  9. package/dist/src/embed/search-bar.d.ts.map +1 -1
  10. package/dist/src/embed/search.d.ts +2 -2
  11. package/dist/src/embed/ts-embed.d.ts +35 -1
  12. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  13. package/dist/src/index.d.ts +3 -3
  14. package/dist/src/index.d.ts.map +1 -1
  15. package/dist/src/react/index.d.ts.map +1 -1
  16. package/dist/src/types.d.ts +201 -27
  17. package/dist/src/types.d.ts.map +1 -1
  18. package/dist/tsembed.es.js +247 -38
  19. package/dist/tsembed.js +228 -38
  20. package/lib/package.json +2 -3
  21. package/lib/src/auth.d.ts +38 -4
  22. package/lib/src/auth.d.ts.map +1 -1
  23. package/lib/src/auth.js +17 -2
  24. package/lib/src/auth.js.map +1 -1
  25. package/lib/src/embed/app.d.ts +2 -2
  26. package/lib/src/embed/app.js +1 -1
  27. package/lib/src/embed/base.d.ts +25 -14
  28. package/lib/src/embed/base.d.ts.map +1 -1
  29. package/lib/src/embed/base.js +24 -4
  30. package/lib/src/embed/base.js.map +1 -1
  31. package/lib/src/embed/base.spec.js +2 -2
  32. package/lib/src/embed/base.spec.js.map +1 -1
  33. package/lib/src/embed/liveboard.d.ts +13 -3
  34. package/lib/src/embed/liveboard.d.ts.map +1 -1
  35. package/lib/src/embed/liveboard.js +12 -2
  36. package/lib/src/embed/liveboard.js.map +1 -1
  37. package/lib/src/embed/search-bar.d.ts +4 -1
  38. package/lib/src/embed/search-bar.d.ts.map +1 -1
  39. package/lib/src/embed/search-bar.js +1 -1
  40. package/lib/src/embed/search-bar.js.map +1 -1
  41. package/lib/src/embed/search.d.ts +2 -2
  42. package/lib/src/embed/search.js +1 -1
  43. package/lib/src/embed/ts-embed.d.ts +35 -1
  44. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  45. package/lib/src/embed/ts-embed.js +35 -2
  46. package/lib/src/embed/ts-embed.js.map +1 -1
  47. package/lib/src/index.d.ts +3 -3
  48. package/lib/src/index.d.ts.map +1 -1
  49. package/lib/src/index.js +1 -1
  50. package/lib/src/index.js.map +1 -1
  51. package/lib/src/react/index.d.ts.map +1 -1
  52. package/lib/src/react/index.js +4 -2
  53. package/lib/src/react/index.js.map +1 -1
  54. package/lib/src/react/index.spec.js +14 -2
  55. package/lib/src/react/index.spec.js.map +1 -1
  56. package/lib/src/types.d.ts +201 -27
  57. package/lib/src/types.d.ts.map +1 -1
  58. package/lib/src/types.js +155 -24
  59. package/lib/src/types.js.map +1 -1
  60. package/lib/src/visual-embed-sdk.d.ts +323 -57
  61. package/package.json +2 -3
  62. package/src/auth.ts +51 -5
  63. package/src/embed/app.ts +2 -2
  64. package/src/embed/base.spec.ts +3 -3
  65. package/src/embed/base.ts +30 -9
  66. package/src/embed/liveboard.ts +13 -3
  67. package/src/embed/search-bar.tsx +4 -1
  68. package/src/embed/search.ts +2 -2
  69. package/src/embed/ts-embed.ts +35 -2
  70. package/src/index.ts +24 -2
  71. package/src/react/index.spec.tsx +35 -2
  72. package/src/react/index.tsx +10 -2
  73. package/src/types.ts +202 -26
package/dist/tsembed.js CHANGED
@@ -208,7 +208,47 @@
208
208
  AuthType["SAML"] = "SSO_SAML";
209
209
  /**
210
210
  * SSO using SAML
211
- * Will make the host application redirect to the SAML Idp.
211
+ * Will make the host application redirect to the SAML Idp. Use this
212
+ * when the idp does not allow itself to be embedded.
213
+ *
214
+ * This redirects the host application to the SAML Idp. The host application
215
+ * will be redirected back to the ThoughtSpot app after authentication.
216
+ * @example
217
+ * ```js
218
+ * init({
219
+ * // ...
220
+ * authType: AuthType.SAMLRedirect,
221
+ * });
222
+ * ```
223
+ *
224
+ * This opens the SAML Idp in a popup window. The popup is triggered
225
+ * when the user clicks the trigger button. The popup window will be
226
+ * closed automatically after authentication.
227
+ * @example
228
+ * ```js
229
+ * init({
230
+ * // ...
231
+ * authType: AuthType.SAMLRedirect,
232
+ * authTriggerText: 'Login with SAML',
233
+ * authTriggerContainer: '#embed-container',
234
+ * inPopup: true,
235
+ * });
236
+ * ```
237
+ *
238
+ * Can also use event to trigger the popup flow. Works the same
239
+ * as above example.
240
+ * @example
241
+ * ```js
242
+ * const authEE = init({
243
+ * // ...
244
+ * authType: AuthType.SAMLRedirect,
245
+ * inPopup: true,
246
+ * });
247
+ *
248
+ * someButtonOnYourPage.addEventListener('click', () => {
249
+ * authEE.emit(AuthEvent.TRIGGER_SSO_POPUP);
250
+ * });
251
+ * ```
212
252
  */
213
253
  AuthType["SAMLRedirect"] = "SSO_SAML";
214
254
  /**
@@ -220,6 +260,7 @@
220
260
  /**
221
261
  * SSO using OIDC
222
262
  * Will make the host application redirect to the OIDC Idp.
263
+ * See code samples in {@link SAMLRedirect}.
223
264
  */
224
265
  AuthType["OIDCRedirect"] = "SSO_OIDC";
225
266
  /**
@@ -232,6 +273,18 @@
232
273
  * Trusted authentication server, Use your own authentication server
233
274
  * which returns a bearer token, generated using the secret_key obtained from
234
275
  * ThoughtSpot.
276
+ *
277
+ * @example
278
+ * ```js
279
+ * init({
280
+ * // ...
281
+ * authType: AuthType.TrustedAuthToken,
282
+ * getAuthToken: () => {
283
+ * return fetch('https://my-backend.app/ts-token')
284
+ * .then((response) => response.json())
285
+ * .then((data) => data.token);
286
+ * }
287
+ * ```
235
288
  */
236
289
  AuthType["TrustedAuthToken"] = "AuthServer";
237
290
  /**
@@ -470,6 +523,12 @@
470
523
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
471
524
  */
472
525
  EmbedEvent["Download"] = "download";
526
+ /**
527
+ * Emitted when the download action is triggered on an answer
528
+ *
529
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl, 9.4.0-sw
530
+ */
531
+ EmbedEvent["DownloadAsPng"] = "downloadAsPng";
473
532
  /**
474
533
  * Emitted when the Download as PDF action is triggered on an answer
475
534
  * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
@@ -635,11 +694,13 @@
635
694
  * @param - searchQuery - The search query
636
695
  * @param - execute - execute the existing / updated query
637
696
  * @example
697
+ * ```js
638
698
  * searchEmbed.trigger(HostEvent.Search, {
639
- * searchQuery: "[sales] by [item type],
640
- * "dataSourceIds: ["cd252e5c-b552-49a8-821d-3eadaa049cca"]
641
- * "execute": true
699
+ * searchQuery: "[sales] by [item type],
700
+ * dataSourceIds: ["cd252e5c-b552-49a8-821d-3eadaa049cca"]
701
+ * execute: true
642
702
  * })
703
+ * ```
643
704
  */
644
705
  HostEvent["Search"] = "search";
645
706
  /**
@@ -648,10 +709,14 @@
648
709
  * eg. { selectedPoints: []}
649
710
  * @param - columnGuid - a string guid of the column to drill by. This is optional,
650
711
  * if not provided it will auto drill by the configured column.
651
- * @example searchEmbed.trigger(HostEvent.DrillDown, {
652
- * points: clickedPointData,
653
- * autoDrillDown: true,
712
+ * @example
713
+ * ```js
714
+ * searchEmbed.trigger(HostEvent.DrillDown, {
715
+ * points: clickedPointData,
716
+ * autoDrillDown: true,
654
717
  * })
718
+ * ```
719
+ *
655
720
  * @version SDK: 1.5.0 | ThoughtSpot: ts7.oct.cl, 7.2.1
656
721
  */
657
722
  HostEvent["DrillDown"] = "triggerDrillDown";
@@ -690,7 +755,10 @@
690
755
  * Navigate to a specific page in App embed without any reload.
691
756
  * This is the same as calling `appEmbed.navigateToPage(path, true)`
692
757
  * @param - path - the path to navigate to (can be a number[1/-1] to go forward/back)
693
- * @example appEmbed.navigateToPage(-1)
758
+ * @example
759
+ * ```js
760
+ * appEmbed.navigateToPage(-1)
761
+ * ```
694
762
  * @version SDK: 1.12.0 | ThoughtSpot 8.4.0.cl, 8.4.1-sw
695
763
  */
696
764
  HostEvent["Navigate"] = "Navigate";
@@ -698,27 +766,39 @@
698
766
  * Opens the filter panel for a particular column.
699
767
  * Works with Search embed.
700
768
  * @param - { columnId: string, name: string, type: INT64/CHAR/DATE, dataType: ATTRIBUTE/MEASURE }
701
- * @example searchEmbed.trigger(HostEvent.OpenFilter, { columnId: '123', name: 'column name', type: 'INT64', dataType: 'ATTRIBUTE' })
769
+ * @example
770
+ * ```js
771
+ * searchEmbed.trigger(HostEvent.OpenFilter, { columnId: '123', name: 'column name', type: 'INT64', dataType: 'ATTRIBUTE' })
772
+ * ```
702
773
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
703
774
  */
704
775
  HostEvent["OpenFilter"] = "openFilter";
705
776
  /**
706
777
  * Adds the columns to the current Search.
707
778
  * @param - { columnIds: string[] }
708
- * @example searchEmbed.trigger(HostEvent.AddColumns, { columnIds: ['123', '456'] })
779
+ * @example
780
+ * ```js
781
+ * searchEmbed.trigger(HostEvent.AddColumns, { columnIds: ['123', '456'] })
782
+ * ```
709
783
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
710
784
  */
711
785
  HostEvent["AddColumns"] = "addColumns";
712
786
  /**
713
787
  * Removes a column from the current Search.
714
788
  * @param - { columnId: string }
715
- * @example - searchEmbed.trigger(HostEvent.RemoveColumn, { columnId: '123' })
789
+ * @example
790
+ * ```js
791
+ * searchEmbed.trigger(HostEvent.RemoveColumn, { columnId: '123' })
792
+ * ```
716
793
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
717
794
  */
718
795
  HostEvent["RemoveColumn"] = "removeColumn";
719
796
  /**
720
797
  * Gets the current pinboard content.
721
- * @example liveboardEmbed.trigger(HostEvent.getExportRequestForCurrentPinboard)
798
+ * @example
799
+ * ```js
800
+ * liveboardEmbed.trigger(HostEvent.getExportRequestForCurrentPinboard)
801
+ * ```
722
802
  * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
723
803
  */
724
804
  HostEvent["getExportRequestForCurrentPinboard"] = "getExportRequestForCurrentPinboard";
@@ -727,87 +807,124 @@
727
807
  * @param - incase of Liveboard embed, takes in an object with vizId as a key
728
808
  * can be left empty for search and visualization embeds
729
809
  * @example
810
+ * ```js
730
811
  * liveboardEmbed.trigger(HostEvent.Pin, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
731
812
  * vizEmbed.trigger(HostEvent.Pin)
732
813
  * searchEmbed.trigger(HostEvent.Pin)
814
+ * ```
733
815
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
734
816
  */
735
817
  HostEvent["Pin"] = "pin";
736
818
  /**
737
819
  * Triggers the Show Liveboard details action on a Liveboard
738
- * @example liveboardEmbed.trigger(HostEvent.LiveboardInfo)
820
+ * @example
821
+ * ```js
822
+ * liveboardEmbed.trigger(HostEvent.LiveboardInfo)
823
+ * ```
739
824
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
740
825
  */
741
826
  HostEvent["LiveboardInfo"] = "pinboardInfo";
742
827
  /**
743
828
  * Triggers the Schedule action on a Liveboard
744
- * @example liveboardEmbed.trigger(HostEvent.Schedule)
829
+ * @example
830
+ * ```js
831
+ * liveboardEmbed.trigger(HostEvent.Schedule)
832
+ * ```
745
833
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
746
834
  */
747
835
  HostEvent["Schedule"] = "subscription";
748
836
  /**
749
837
  * Triggers the Manage schedule action on a Liveboard
750
- * @example liveboardEmbed.trigger(HostEvent.ScheduleList)
838
+ * @example
839
+ * ```js
840
+ * liveboardEmbed.trigger(HostEvent.ScheduleList)
841
+ * ```
751
842
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
752
843
  */
753
844
  HostEvent["SchedulesList"] = "schedule-list";
754
845
  /**
755
846
  * Triggers the Export TML action on a Liveboard
756
- * @example liveboardEmbed.trigger(HostEvent.ExportTML)
847
+ * @example
848
+ * ```js
849
+ * liveboardEmbed.trigger(HostEvent.ExportTML)
850
+ * ```
757
851
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
758
852
  */
759
853
  HostEvent["ExportTML"] = "exportTSL";
760
854
  /**
761
855
  * Triggers the Edit TML action on a Liveboard
762
- * @example liveboardEmbed.trigger(HostEvent.EditTML)
856
+ * @example
857
+ * ```js
858
+ * liveboardEmbed.trigger(HostEvent.EditTML)
859
+ * ```
763
860
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
764
861
  */
765
862
  HostEvent["EditTML"] = "editTSL";
766
863
  /**
767
864
  * Triggers the Update TML action on a Liveboard
768
- * @example liveboardEmbed.trigger(HostEvent.UpdateTML)
865
+ * @example
866
+ * ```js
867
+ * liveboardEmbed.trigger(HostEvent.UpdateTML)
868
+ * ```
769
869
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
770
870
  */
771
871
  HostEvent["UpdateTML"] = "updateTSL";
772
872
  /**
773
873
  * Triggers the Download PDF action on a Liveboard
774
- * @example liveboardEmbed.trigger(HostEvent.DownloadAsPDF)
874
+ * @example
875
+ * ```js
876
+ * liveboardEmbed.trigger(HostEvent.DownloadAsPDF)
877
+ * ```
775
878
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
776
879
  */
777
880
  HostEvent["DownloadAsPdf"] = "downloadAsPdf";
778
881
  /**
779
882
  * Triggers the Make a copy action on a Liveboard, search or visualization
780
883
  * @example
884
+ * ```js
781
885
  * liveboardEmbed.trigger(HostEvent.MakeACopy, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
782
886
  * vizEmbed.trigger(HostEvent.MakeACopy)
783
887
  * searchEmbed.trigger(HostEvent.MakeACopy)
888
+ * ```
784
889
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
785
890
  */
786
891
  HostEvent["MakeACopy"] = "makeACopy";
787
892
  /**
788
893
  * Triggers the Delete action on a Liveboard
789
- * @example appEmbed.trigger(HostEvent.Remove)
894
+ * @example
895
+ * ```js
896
+ * appEmbed.trigger(HostEvent.Remove)
897
+ * ```
790
898
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
791
899
  */
792
900
  HostEvent["Remove"] = "delete";
793
901
  /**
794
902
  * Triggers the Explore action on a visualization
795
903
  * @param - an object with vizId as a key
796
- * @example liveboardEmbed.trigger(HostEvent.Explore, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
904
+ * @example
905
+ * ```js
906
+ * liveboardEmbed.trigger(HostEvent.Explore, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
907
+ * ```
797
908
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
798
909
  */
799
910
  HostEvent["Explore"] = "explore";
800
911
  /**
801
912
  * Triggers the Create alert action on a visualization
802
913
  * @param - an object with vizId as a key
803
- * @example liveboardEmbed.trigger(HostEvent.CreateMonitor {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
914
+ * @example
915
+ * ```js
916
+ * liveboardEmbed.trigger(HostEvent.CreateMonitor {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
917
+ * ```
804
918
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
805
919
  */
806
920
  HostEvent["CreateMonitor"] = "createMonitor";
807
921
  /**
808
922
  * Triggers the Manage alert action on a visualization
809
923
  * @param - an object with vizId as a key
810
- * @example liveboardEmbed.trigger(HostEvent.ManageMonitor, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
924
+ * @example
925
+ * ```js
926
+ * liveboardEmbed.trigger(HostEvent.ManageMonitor, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
927
+ * ```
811
928
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
812
929
  */
813
930
  HostEvent["ManageMonitor"] = "manageMonitor";
@@ -825,9 +942,11 @@
825
942
  * Triggers the Copy link action on a Liveboard or visualization
826
943
  * @param - object - to trigger the action for a specfic visualization in Liveboard embed, pass in vizId as a key
827
944
  * @example
945
+ * ```js
828
946
  * liveboardEmbed.trigger(HostEvent.CopyLink)
829
947
  * liveboardEmbed.trigger(HostEvent.CopyLink, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
830
948
  * vizEmbed.trigger((HostEvent.CopyLink)
949
+ * ```
831
950
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
832
951
  */
833
952
  HostEvent["CopyLink"] = "embedDocument";
@@ -835,15 +954,20 @@
835
954
  * Triggers the Present action on a Liveboard or visualization
836
955
  * @param - object - to trigger the action for a specfic visualization in Liveboard embed, pass in vizId as a key
837
956
  * @example
957
+ * ```js
838
958
  * liveboardEmbed.trigger(HostEvent.Present)
839
959
  * liveboardEmbed.trigger(HostEvent.Present, {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
840
960
  * vizEmbed.trigger((HostEvent.Present)
961
+ * ```
841
962
  * @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1-sw
842
963
  */
843
964
  HostEvent["Present"] = "present";
844
965
  /**
845
966
  * Get TML for the current search.
846
- * @example searchEmbed.trigger(HostEvent.GetTML)
967
+ * @example
968
+ * ```js
969
+ * searchEmbed.trigger(HostEvent.GetTML)
970
+ * ```
847
971
  * @version SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl, 9.0.1-sw
848
972
  */
849
973
  HostEvent["GetTML"] = "getTML";
@@ -1066,6 +1190,7 @@
1066
1190
  Action["ReplaySearch"] = "replaySearch";
1067
1191
  Action["ShowUnderlyingData"] = "showUnderlyingData";
1068
1192
  Action["Download"] = "download";
1193
+ Action["DownloadAsPng"] = "downloadAsPng";
1069
1194
  Action["DownloadAsPdf"] = "downloadAsPdf";
1070
1195
  Action["DownloadAsCsv"] = "downloadAsCSV";
1071
1196
  Action["DownloadAsXlsx"] = "downloadAsXLSX";
@@ -8914,7 +9039,8 @@
8914
9039
  })(exports.AuthStatus || (exports.AuthStatus = {}));
8915
9040
  (function (AuthEvent) {
8916
9041
  /**
8917
- * Manually trigger the SSO popup.
9042
+ * Manually trigger the SSO popup. This is useful with
9043
+ * authStatus: SAMLRedirect/OIDCRedicre and inPopup: true
8918
9044
  */
8919
9045
  AuthEvent["TRIGGER_SSO_POPUP"] = "TRIGGER_SSO_POPUP";
8920
9046
  })(exports.AuthEvent || (exports.AuthEvent = {}));
@@ -8974,8 +9100,9 @@
8974
9100
  return releaseVersion;
8975
9101
  }
8976
9102
  /**
8977
- * Return a promise that resolves with the session info when authentication is
9103
+ * Return a promise that resolves with the session information when authentication is
8978
9104
  * successful. And info is available.
9105
+ * @group Global methods
8979
9106
  */
8980
9107
  function getSessionInfo() {
8981
9108
  return sessionInfoPromise;
@@ -9212,6 +9339,13 @@
9212
9339
  authType: exports.AuthType.None,
9213
9340
  };
9214
9341
  let authPromise;
9342
+ /**
9343
+ * Gets the configuration embed was initialized with.
9344
+ *
9345
+ * @returns {@link EmbedConfig} The configuration embed was initialized with.
9346
+ * @version SDK: 1.19.0 | ThoughtSpot: *
9347
+ * @group Global methods
9348
+ */
9215
9349
  const getEmbedConfig = () => config;
9216
9350
  const getAuthPromise = () => authPromise;
9217
9351
  /**
@@ -9242,6 +9376,7 @@
9242
9376
  * @param url The URL provided for prefetch
9243
9377
  * @param prefetchFeatures Specify features which needs to be prefetched.
9244
9378
  * @version SDK: 1.4.0 | ThoughtSpot: ts7.sep.cl, 7.2.1
9379
+ * @group Global methods
9245
9380
  */
9246
9381
  const prefetch = (url, prefetchFeatures) => {
9247
9382
  if (url === '') {
@@ -9288,13 +9423,24 @@
9288
9423
  }
9289
9424
  /**
9290
9425
  * Initializes the Visual Embed SDK globally and perform
9291
- * authentication if applicable.
9426
+ * authentication if applicable. This function needs to be called before any ThoughtSpot
9427
+ * component like liveboard etc can be embedded. But need not wait for AuthEvent.SUCCESS
9428
+ * to actually embed. That is handled internally.
9292
9429
  * @param embedConfig The configuration object containing ThoughtSpot host,
9293
9430
  * authentication mechanism and so on.
9294
- * example: authStatus = init(config);
9295
- * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
9296
- * @returns event emitter which emits events on authentication success, failure and logout. See {@link AuthStatus}
9431
+ *
9432
+ * @example
9433
+ * ```js
9434
+ * const authStatus = init({
9435
+ * thoughtSpotHost: 'https://my.thoughtspot.cloud',
9436
+ * authType: AuthType.None,
9437
+ * });
9438
+ * authStatus.on(AuthStatus.FAILURE, (reason) => { // do something here });
9439
+ * ```
9440
+ *
9441
+ * @returns {@link AuthEventEmitter} event emitter which emits events on authentication success, failure and logout. See {@link AuthStatus}
9297
9442
  * @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
9443
+ * @group Authentication / Init
9298
9444
  */
9299
9445
  const init = (embedConfig) => {
9300
9446
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -9336,6 +9482,7 @@
9336
9482
  * @param doNotDisableAutoLogin This flag when passed will not disable autoLogin
9337
9483
  * @returns Promise which resolves when logout completes.
9338
9484
  * @version SDK: 1.10.1 | ThoughtSpot: 8.2.0.cl, 8.4.1-sw
9485
+ * @group Global methods
9339
9486
  */
9340
9487
  const logout$1 = (doNotDisableAutoLogin = false) => {
9341
9488
  if (!doNotDisableAutoLogin) {
@@ -9525,7 +9672,7 @@
9525
9672
  });
9526
9673
  }
9527
9674
 
9528
- var name="@thoughtspot/visual-embed-sdk";var version="1.20.0";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**"];var exports$1={".":"./lib/src/index.js","./react":{"import":"./lib/src/react/index.js",require:"./cjs/src/react.index.js",types:"./lib/src/react/index.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/index.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","dts-bundle":"0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"6.7.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
9675
+ var name="@thoughtspot/visual-embed-sdk";var version="1.20.2";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**"];var exports$1={".":"./lib/src/index.js","./react":{"import":"./lib/src/react/index.js",require:"./cjs/src/react.index.js",types:"./lib/src/react/index.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/index.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","ts-deepmerge":"^6.0.2","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","dts-bundle":"0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"6.7.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
9529
9676
 
9530
9677
  /**
9531
9678
  * Copyright (c) 2022
@@ -10004,6 +10151,20 @@
10004
10151
  * @param messageType The message type
10005
10152
  * @param callback A callback as a function
10006
10153
  * @param options The message options
10154
+ * @example
10155
+ * ```js
10156
+ * tsEmbed.on(EmbedEvent.Error, (data) => {
10157
+ * console.error(data);
10158
+ * });
10159
+ * ```
10160
+ * @example
10161
+ * ```js
10162
+ * tsEmbed.on(EmbedEvent.Save, (data) => {
10163
+ * console.log("Answer save clicked", data);
10164
+ * }, {
10165
+ * start: true // This will trigger the callback on start of save
10166
+ * });
10167
+ * ```
10007
10168
  */
10008
10169
  on(messageType, callback, options = { start: false }) {
10009
10170
  if (this.isRendered) {
@@ -10098,6 +10259,8 @@
10098
10259
  * Base class for embedding v1 experience
10099
10260
  * Note: The v1 version of ThoughtSpot Blink works on the AngularJS stack
10100
10261
  * which is currently under migration to v2
10262
+ *
10263
+ * @inheritdoc
10101
10264
  */
10102
10265
  class V1Embed extends TsEmbed {
10103
10266
  constructor(domSelector, viewConfig) {
@@ -10105,13 +10268,30 @@
10105
10268
  this.viewConfig = viewConfig;
10106
10269
  }
10107
10270
  /**
10108
- * Render the app in an iframe and set up event handlers
10271
+ * Render the ap p in an iframe and set up event handlers
10109
10272
  * @param iframeSrc
10110
10273
  */
10111
10274
  renderV1Embed(iframeSrc) {
10112
10275
  return this.renderIFrame(iframeSrc, this.viewConfig.frameParams);
10113
10276
  }
10114
- // @override
10277
+ /**
10278
+ * @inheritdoc TsEmbed.on
10279
+ *
10280
+ * @example
10281
+ * ```js
10282
+ * tsEmbed.on(EmbedEvent.Error, (data) => {
10283
+ * console.error(data);
10284
+ * });
10285
+ * ```
10286
+ * @example
10287
+ * ```js
10288
+ * tsEmbed.on(EmbedEvent.Save, (data) => {
10289
+ * console.log("Answer save clicked", data);
10290
+ * }, {
10291
+ * start: true // This will trigger the callback on start of save
10292
+ * });
10293
+ * ```
10294
+ */
10115
10295
  on(messageType, callback, options = { start: false }) {
10116
10296
  const eventType = this.getCompatibleEventType(messageType);
10117
10297
  uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_ON}-${messageType}`);
@@ -10161,7 +10341,7 @@
10161
10341
  })(exports.Page || (exports.Page = {}));
10162
10342
  /**
10163
10343
  * Embeds full ThoughtSpot experience in a host application.
10164
- * @Category App Embed
10344
+ * @group Embed components
10165
10345
  */
10166
10346
  class AppEmbed extends V1Embed {
10167
10347
  // eslint-disable-next-line no-useless-constructor
@@ -10294,8 +10474,18 @@
10294
10474
  * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
10295
10475
  */
10296
10476
  /**
10297
- * Embed a ThoughtSpot Liveboard or visualization
10298
- * @Category Liveboards and Charts
10477
+ * Embed a ThoughtSpot Liveboard or a Thoughtspot visualization. When rendered it already
10478
+ * waits for the authentication to complete, so no need to wait for AuthStatus.SUCCESS.
10479
+ * @example
10480
+ * ```js
10481
+ * import { .. } from '@thoughtspot/visual-embed-sdk';
10482
+ * init({ ... });
10483
+ * const embed = new LiveboardEmbed("#container", {
10484
+ * liveboardId: <your-id-here>,
10485
+ * // .. other params here.
10486
+ * })
10487
+ * ```
10488
+ * @group Embed components
10299
10489
  */
10300
10490
  class LiveboardEmbed extends V1Embed {
10301
10491
  // eslint-disable-next-line no-useless-constructor
@@ -10438,7 +10628,7 @@
10438
10628
  /**
10439
10629
  * Embed ThoughtSpot search
10440
10630
  *
10441
- * @Category Search Embed
10631
+ * @group Embed components
10442
10632
  */
10443
10633
  class SearchEmbed extends TsEmbed {
10444
10634
  constructor(domSelector, viewConfig) {
@@ -10530,8 +10720,8 @@
10530
10720
  /**
10531
10721
  * Embed ThoughtSpot search bar
10532
10722
  *
10533
- * @Category Search Embed
10534
10723
  * @version: SDK: 1.18.0 | ThoughtSpot: 8.10.0.cl, 9.0.1-sw
10724
+ * @group Embed components
10535
10725
  */
10536
10726
  class SearchBarEmbed extends TsEmbed {
10537
10727
  constructor(domSelector, viewConfig) {
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
@@ -135,8 +135,7 @@
135
135
  "ts-jest": "^26.5.5",
136
136
  "ts-loader": "8.0.4",
137
137
  "typedoc": "0.21.6",
138
- "typedoc-neo-theme": "^1.1.0",
139
- "typedoc-plugin-toc-group": "0.0.5",
138
+ "typedoc-plugin-toc-group": "thoughtspot/typedoc-plugin-toc-group",
140
139
  "typescript": "^4.9.4",
141
140
  "url-search-params-polyfill": "^8.1.0",
142
141
  "util": "^0.12.4"
package/lib/src/auth.d.ts CHANGED
@@ -12,12 +12,21 @@ export declare const EndPoints: {
12
12
  BASIC_LOGIN: string;
13
13
  LOGOUT: string;
14
14
  };
15
+ /**
16
+ * Enum for auth failure types. This is the parameter passed to the listner
17
+ * of {@link AuthStatus.FAILURE}.
18
+ * @group Authentication / Init
19
+ */
15
20
  export declare enum AuthFailureType {
16
21
  SDK = "SDK",
17
22
  NO_COOKIE_ACCESS = "NO_COOKIE_ACCESS",
18
23
  EXPIRY = "EXPIRY",
19
24
  OTHER = "OTHER"
20
25
  }
26
+ /**
27
+ * Enum for auth status emitted by the emitter returned from {@link init}.
28
+ * @group Authentication / Init
29
+ */
21
30
  export declare enum AuthStatus {
22
31
  /**
23
32
  * Emits when the SDK fails to authenticate
@@ -43,14 +52,38 @@ export declare enum AuthStatus {
43
52
  */
44
53
  WAITING_FOR_POPUP = "WAITING_FOR_POPUP"
45
54
  }
55
+ /**
56
+ * Event emitter returned from {@link init}.
57
+ * @group Authentication / Init
58
+ */
59
+ export interface AuthEventEmitter {
60
+ /**
61
+ * Registed a listener on Auth failure.
62
+ * @param event
63
+ * @param listener
64
+ */
65
+ on(event: AuthStatus.FAILURE, listener: (failureType: AuthFailureType) => void): this;
66
+ on(event: AuthStatus.SDK_SUCCESS | AuthStatus.LOGOUT | AuthStatus.WAITING_FOR_POPUP, listener: () => void): this;
67
+ on(event: AuthStatus.SUCCESS, listener: (sessionInfo: any) => void): this;
68
+ /**
69
+ * Trigger an event on the emitter returned from init.
70
+ * @param {@link AuthEvent}
71
+ */
72
+ emit(event: AuthEvent): void;
73
+ }
74
+ /**
75
+ * Events which can be triggered on the emitter returned from {@link init}.
76
+ * @group Authentication / Init
77
+ */
46
78
  export declare enum AuthEvent {
47
79
  /**
48
- * Manually trigger the SSO popup.
80
+ * Manually trigger the SSO popup. This is useful with
81
+ * authStatus: SAMLRedirect/OIDCRedicre and inPopup: true
49
82
  */
50
83
  TRIGGER_SSO_POPUP = "TRIGGER_SSO_POPUP"
51
84
  }
52
- export declare function getAuthEE(): EventEmitter;
53
- export declare function setAuthEE(eventEmitter: EventEmitter): void;
85
+ export declare function getAuthEE(): EventEmitter<AuthStatus | AuthEvent>;
86
+ export declare function setAuthEE(eventEmitter: EventEmitter<AuthStatus | AuthEvent>): void;
54
87
  export declare function notifyAuthSDKSuccess(): void;
55
88
  export declare function notifyAuthSuccess(): void;
56
89
  export declare function notifyAuthFailure(failureType: AuthFailureType): void;
@@ -60,8 +93,9 @@ export declare function notifyLogout(): void;
60
93
  */
61
94
  export declare function getReleaseVersion(): string;
62
95
  /**
63
- * Return a promise that resolves with the session info when authentication is
96
+ * Return a promise that resolves with the session information when authentication is
64
97
  * successful. And info is available.
98
+ * @group Global methods
65
99
  */
66
100
  export declare function getSessionInfo(): Promise<any>;
67
101
  export declare function initSession(sessionDetails: any): void;