@thoughtspot/visual-embed-sdk 1.28.0-preRender → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/cjs/package.json +3 -4
- package/cjs/src/auth.d.ts +16 -1
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +7 -3
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/auth.spec.d.ts.map +1 -1
- package/cjs/src/auth.spec.js +9 -0
- package/cjs/src/auth.spec.js.map +1 -1
- package/cjs/src/embed/app.d.ts +150 -7
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +5 -5
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +19 -1
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/base.d.ts +1 -1
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +5 -8
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +1 -1
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/embed.spec.js +0 -15
- package/cjs/src/embed/embed.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +113 -4
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js +2 -2
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +20 -1
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/pinboard.spec.js +20 -1
- package/cjs/src/embed/pinboard.spec.js.map +1 -1
- package/cjs/src/embed/sage.d.ts +1 -1
- package/cjs/src/embed/sage.d.ts.map +1 -1
- package/cjs/src/embed/sage.js +2 -2
- package/cjs/src/embed/sage.js.map +1 -1
- package/cjs/src/embed/search-bar.d.ts +37 -6
- package/cjs/src/embed/search-bar.d.ts.map +1 -1
- package/cjs/src/embed/search-bar.js +2 -2
- package/cjs/src/embed/search-bar.js.map +1 -1
- package/cjs/src/embed/search.d.ts +85 -2
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +6 -6
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/search.spec.js +25 -1
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed-trigger.spec.d.ts +2 -0
- package/cjs/src/embed/ts-embed-trigger.spec.d.ts.map +1 -0
- package/cjs/src/embed/ts-embed-trigger.spec.js +34 -0
- package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -0
- package/cjs/src/embed/ts-embed.d.ts +2 -2
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +18 -13
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +64 -25
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +2 -1
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +3 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +13 -1
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/test/test-utils.d.ts +1 -0
- package/cjs/src/test/test-utils.d.ts.map +1 -1
- package/cjs/src/test/test-utils.js +10 -1
- package/cjs/src/test/test-utils.js.map +1 -1
- package/cjs/src/tokenizedFetch.d.ts +9 -0
- package/cjs/src/tokenizedFetch.d.ts.map +1 -1
- package/cjs/src/tokenizedFetch.js +9 -0
- package/cjs/src/tokenizedFetch.js.map +1 -1
- package/cjs/src/types.d.ts +279 -43
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +95 -20
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/authService/authService.d.ts.map +1 -1
- package/cjs/src/utils/authService/authService.js +9 -3
- package/cjs/src/utils/authService/authService.js.map +1 -1
- package/cjs/src/utils/authService/authService.spec.js +22 -0
- package/cjs/src/utils/authService/authService.spec.js.map +1 -1
- package/dist/src/auth.d.ts +16 -1
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/auth.spec.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +150 -7
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts +1 -1
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +113 -4
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/sage.d.ts +1 -1
- package/dist/src/embed/sage.d.ts.map +1 -1
- package/dist/src/embed/search-bar.d.ts +37 -6
- package/dist/src/embed/search-bar.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +85 -2
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed-trigger.spec.d.ts +2 -0
- package/dist/src/embed/ts-embed-trigger.spec.d.ts.map +1 -0
- package/dist/src/embed/ts-embed.d.ts +2 -2
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/test/test-utils.d.ts +1 -0
- package/dist/src/test/test-utils.d.ts.map +1 -1
- package/dist/src/tokenizedFetch.d.ts +9 -0
- package/dist/src/tokenizedFetch.d.ts.map +1 -1
- package/dist/src/types.d.ts +279 -43
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/authService/authService.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +1543 -1445
- package/dist/tsembed-react.js +6614 -6529
- package/dist/tsembed.es.js +1921 -1826
- package/dist/tsembed.js +15342 -15259
- package/dist/visual-embed-sdk-react-full.d.ts +692 -64
- package/dist/visual-embed-sdk-react.d.ts +692 -64
- package/dist/visual-embed-sdk.d.ts +692 -64
- package/lib/package.json +3 -4
- package/lib/src/auth.d.ts +16 -1
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +8 -4
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.d.ts.map +1 -1
- package/lib/src/auth.spec.js +9 -0
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/embed/app.d.ts +150 -7
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +5 -5
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +19 -1
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts +1 -1
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +5 -8
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +2 -2
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +2 -17
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +113 -4
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js +3 -3
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +20 -1
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.spec.js +20 -1
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/sage.d.ts +1 -1
- package/lib/src/embed/sage.d.ts.map +1 -1
- package/lib/src/embed/sage.js +2 -2
- package/lib/src/embed/sage.js.map +1 -1
- package/lib/src/embed/search-bar.d.ts +37 -6
- package/lib/src/embed/search-bar.d.ts.map +1 -1
- package/lib/src/embed/search-bar.js +2 -2
- package/lib/src/embed/search-bar.js.map +1 -1
- package/lib/src/embed/search.d.ts +85 -2
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +7 -7
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/search.spec.js +25 -1
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed-trigger.spec.d.ts +2 -0
- package/lib/src/embed/ts-embed-trigger.spec.d.ts.map +1 -0
- package/lib/src/embed/ts-embed-trigger.spec.js +32 -0
- package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -0
- package/lib/src/embed/ts-embed.d.ts +2 -2
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +21 -16
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +57 -18
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -1
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -1
- package/lib/src/index.js.map +1 -1
- package/lib/src/react/index.spec.js +13 -1
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/test/test-utils.d.ts +1 -0
- package/lib/src/test/test-utils.d.ts.map +1 -1
- package/lib/src/test/test-utils.js +8 -0
- package/lib/src/test/test-utils.js.map +1 -1
- package/lib/src/tokenizedFetch.d.ts +9 -0
- package/lib/src/tokenizedFetch.d.ts.map +1 -1
- package/lib/src/tokenizedFetch.js +9 -0
- package/lib/src/tokenizedFetch.js.map +1 -1
- package/lib/src/types.d.ts +279 -43
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +95 -20
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService/authService.d.ts.map +1 -1
- package/lib/src/utils/authService/authService.js +9 -3
- package/lib/src/utils/authService/authService.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +23 -1
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +699 -68
- package/package.json +3 -4
- package/src/auth.spec.ts +10 -0
- package/src/auth.ts +27 -8
- package/src/embed/app.spec.ts +24 -1
- package/src/embed/app.ts +154 -13
- package/src/embed/base.spec.ts +3 -3
- package/src/embed/base.ts +13 -17
- package/src/embed/embed.spec.ts +0 -18
- package/src/embed/liveboard.spec.ts +24 -1
- package/src/embed/liveboard.ts +121 -15
- package/src/embed/pinboard.spec.ts +24 -1
- package/src/embed/sage.ts +2 -2
- package/src/embed/search-bar.tsx +38 -7
- package/src/embed/search.spec.ts +29 -1
- package/src/embed/search.ts +93 -9
- package/src/embed/ts-embed-trigger.spec.ts +39 -0
- package/src/embed/ts-embed.spec.ts +71 -30
- package/src/embed/ts-embed.ts +48 -45
- package/src/index.ts +2 -0
- package/src/react/index.spec.tsx +30 -0
- package/src/test/test-utils.ts +9 -0
- package/src/tokenizedFetch.ts +9 -0
- package/src/types.ts +288 -50
- package/src/utils/authService/authService.spec.ts +31 -4
- package/src/utils/authService/authService.ts +14 -13
package/dist/tsembed-react.es.js
CHANGED
|
@@ -564,6 +564,7 @@ var AuthType;
|
|
|
564
564
|
* .then((data) => data.token);
|
|
565
565
|
* }
|
|
566
566
|
* });
|
|
567
|
+
* });
|
|
567
568
|
* ```
|
|
568
569
|
*/
|
|
569
570
|
AuthType["TrustedAuthToken"] = "AuthServer";
|
|
@@ -596,17 +597,40 @@ var AuthType;
|
|
|
596
597
|
*/
|
|
597
598
|
AuthType["Basic"] = "Basic";
|
|
598
599
|
})(AuthType || (AuthType = {}));
|
|
600
|
+
/**
|
|
601
|
+
*
|
|
602
|
+
* This option does not apply to the classic homepage experience.
|
|
603
|
+
* To access the updated modular homepage,
|
|
604
|
+
* set `modularHomeExperience` to `true`
|
|
605
|
+
* (available as Early Access feature in 9.12.5.cl).
|
|
606
|
+
*
|
|
607
|
+
*/
|
|
599
608
|
var HomeLeftNavItem;
|
|
600
609
|
(function (HomeLeftNavItem) {
|
|
601
|
-
|
|
610
|
+
/**
|
|
611
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
612
|
+
*/
|
|
613
|
+
HomeLeftNavItem["SearchData"] = "search-data";
|
|
614
|
+
/**
|
|
615
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
616
|
+
*/
|
|
602
617
|
HomeLeftNavItem["Home"] = "insights-home";
|
|
618
|
+
/**
|
|
619
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
620
|
+
*/
|
|
603
621
|
HomeLeftNavItem["Liveboards"] = "liveboards";
|
|
622
|
+
/**
|
|
623
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
624
|
+
*/
|
|
604
625
|
HomeLeftNavItem["Answers"] = "answers";
|
|
626
|
+
/**
|
|
627
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
628
|
+
*/
|
|
605
629
|
HomeLeftNavItem["MonitorSubscription"] = "monitor-alerts";
|
|
630
|
+
/**
|
|
631
|
+
* @version SDK: 1.28.0| ThoughtSpot: 9.12.5.cl
|
|
632
|
+
*/
|
|
606
633
|
HomeLeftNavItem["SpotIQAnalysis"] = "spotiq-analysis";
|
|
607
|
-
HomeLeftNavItem["Tutorials"] = "tutorials";
|
|
608
|
-
HomeLeftNavItem["Documentation"] = "documentation";
|
|
609
|
-
HomeLeftNavItem["Community"] = "community";
|
|
610
634
|
})(HomeLeftNavItem || (HomeLeftNavItem = {}));
|
|
611
635
|
/**
|
|
612
636
|
* A map of the supported runtime filter operations
|
|
@@ -672,7 +696,12 @@ var RuntimeFilterOp;
|
|
|
672
696
|
RuntimeFilterOp["IN"] = "IN";
|
|
673
697
|
})(RuntimeFilterOp || (RuntimeFilterOp = {}));
|
|
674
698
|
/**
|
|
675
|
-
* Home page module that can be hidden
|
|
699
|
+
* Home page module that can be hidden.
|
|
700
|
+
* **Note**: This option does not apply to the classic homepage.
|
|
701
|
+
* To access the updated modular homepage, set
|
|
702
|
+
* `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
|
|
703
|
+
*
|
|
704
|
+
* @version SDK: 1.28.0 | Thoughtspot: 9.12.5.cl
|
|
676
705
|
*/
|
|
677
706
|
// eslint-disable-next-line no-shadow
|
|
678
707
|
var HomepageModule;
|
|
@@ -801,7 +830,7 @@ var EmbedEvent;
|
|
|
801
830
|
* @returns nonFilteredColumns - The columns that were not filtered
|
|
802
831
|
* @example
|
|
803
832
|
*```js
|
|
804
|
-
* searchEmbed.trigger(
|
|
833
|
+
* searchEmbed.trigger(EmbedEvent.DrillDown, {
|
|
805
834
|
* points: {
|
|
806
835
|
* clickedPoint,
|
|
807
836
|
* selectedPoints: selectedPoint
|
|
@@ -893,7 +922,7 @@ var EmbedEvent;
|
|
|
893
922
|
* @important
|
|
894
923
|
* @example
|
|
895
924
|
* ```js
|
|
896
|
-
* embed.on(
|
|
925
|
+
* embed.on(EmbedEvent.VizPointClick, ({data}) => {
|
|
897
926
|
* console.log(
|
|
898
927
|
* data.vizId, // viz id
|
|
899
928
|
* data.clickedPoint.selectedAttributes[0].value,
|
|
@@ -908,19 +937,21 @@ var EmbedEvent;
|
|
|
908
937
|
/**
|
|
909
938
|
* An error has occurred. This event is fired for the following error types:
|
|
910
939
|
*
|
|
911
|
-
*
|
|
940
|
+
* API - API call failure error.
|
|
912
941
|
*
|
|
913
|
-
*
|
|
942
|
+
* FULLSCREEN - Error when presenting a Liveboard or visualization in full screen
|
|
943
|
+
* mode.
|
|
914
944
|
*
|
|
915
|
-
*
|
|
945
|
+
* SINGLE_VALUE_FILTER - Error due to multiple values in the single value filter.
|
|
916
946
|
*
|
|
917
|
-
*
|
|
947
|
+
* NON_EXIST_FILTER - Error due to a non-existent filter.
|
|
918
948
|
*
|
|
919
|
-
*
|
|
949
|
+
* INVALID_DATE_VALUE - Invalid date value error.
|
|
920
950
|
*
|
|
921
|
-
*
|
|
951
|
+
* INVALID_OPERATOR - Use of invalid operator during filter application.
|
|
922
952
|
*
|
|
923
953
|
* For more information, see [Developer Documentation](https://developers.thoughtspot.com/docs/events-app-integration#errorType)
|
|
954
|
+
*
|
|
924
955
|
* @returns error - An error object or message
|
|
925
956
|
* @example
|
|
926
957
|
* ```js
|
|
@@ -1485,7 +1516,7 @@ var EmbedEvent;
|
|
|
1485
1516
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
1486
1517
|
* @example
|
|
1487
1518
|
*```js
|
|
1488
|
-
* liveboardEmbed.trigger(
|
|
1519
|
+
* liveboardEmbed.trigger(EmbedEvent.Delete,
|
|
1489
1520
|
* {vizId: '730496d6-6903-4601-937e-2c691821af3c'})
|
|
1490
1521
|
*```
|
|
1491
1522
|
*/
|
|
@@ -1496,7 +1527,7 @@ var EmbedEvent;
|
|
|
1496
1527
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
1497
1528
|
* @example
|
|
1498
1529
|
*```js
|
|
1499
|
-
* liveboardEmbed.trigger(
|
|
1530
|
+
* liveboardEmbed.trigger(EmbedEvent.SchedulesList)
|
|
1500
1531
|
*```
|
|
1501
1532
|
*/
|
|
1502
1533
|
EmbedEvent["SchedulesList"] = "schedule-list";
|
|
@@ -1506,7 +1537,7 @@ var EmbedEvent;
|
|
|
1506
1537
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
1507
1538
|
* @example
|
|
1508
1539
|
*```js
|
|
1509
|
-
* liveboardEmbed.trigger(
|
|
1540
|
+
* liveboardEmbed.trigger(EmbedEvent.Cancel)
|
|
1510
1541
|
*```
|
|
1511
1542
|
*/
|
|
1512
1543
|
EmbedEvent["Cancel"] = "cancel";
|
|
@@ -1516,7 +1547,7 @@ var EmbedEvent;
|
|
|
1516
1547
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
1517
1548
|
* @example
|
|
1518
1549
|
*```js
|
|
1519
|
-
* liveboardEmbed.trigger(
|
|
1550
|
+
* liveboardEmbed.trigger(EmbedEvent.Explore, {
|
|
1520
1551
|
* vizId: '730496d6-6903-4601-937e-2c691821af3c'})
|
|
1521
1552
|
*```
|
|
1522
1553
|
*/
|
|
@@ -1527,7 +1558,7 @@ var EmbedEvent;
|
|
|
1527
1558
|
* @version SDK: 1.15.0 | ThoughtSpot: 8.7.0.cl, 8.8.1.sw
|
|
1528
1559
|
* @example
|
|
1529
1560
|
*```js
|
|
1530
|
-
* liveboardEmbed.trigger(
|
|
1561
|
+
* liveboardEmbed.trigger(EmbedEvent.CopyLink, {
|
|
1531
1562
|
* vizId: '730496d6-6903-4601-937e-2c691821af3c'})
|
|
1532
1563
|
*```
|
|
1533
1564
|
*/
|
|
@@ -1798,10 +1829,13 @@ var HostEvent;
|
|
|
1798
1829
|
* _String_. The name of the column to filter on.
|
|
1799
1830
|
* `operator`
|
|
1800
1831
|
* Runtime filter operator to apply. For information,
|
|
1801
|
-
* see
|
|
1832
|
+
* see https://developers.thoughtspot.com/docs/?pageid=runtime-filters#rtOperator.
|
|
1802
1833
|
* `values`
|
|
1803
1834
|
* List of operands. Some operators such as EQ, LE allow a single value, whereas
|
|
1804
1835
|
* operators such as BW and IN accept multiple operands.
|
|
1836
|
+
* **Note**: `HostEvent.UpdateRuntimeFilters` is not supported in
|
|
1837
|
+
* Search embedding (SearchEmbed) and Natural Language Search
|
|
1838
|
+
* embedding (SageEmbed).
|
|
1805
1839
|
*
|
|
1806
1840
|
* @param - {@link RuntimeFilter}[] an array of {@link RuntimeFilter} Types.
|
|
1807
1841
|
* @example
|
|
@@ -2326,6 +2360,7 @@ var HostEvent;
|
|
|
2326
2360
|
/**
|
|
2327
2361
|
*
|
|
2328
2362
|
* Get the currents visible and runtime filters applied on a Liveboard
|
|
2363
|
+
*
|
|
2329
2364
|
* @example
|
|
2330
2365
|
* liveboardEmbed.trigger(HostEvent.GetFilters)
|
|
2331
2366
|
* @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
|
|
@@ -2334,12 +2369,13 @@ var HostEvent;
|
|
|
2334
2369
|
/**
|
|
2335
2370
|
*
|
|
2336
2371
|
* Update the visible filters on the Liveboard.
|
|
2372
|
+
*
|
|
2337
2373
|
* @param - filter: filter object containing column name and filter operation and values
|
|
2338
2374
|
* @example
|
|
2339
2375
|
*
|
|
2340
2376
|
* ```js
|
|
2341
2377
|
* liveboardEmbed.trigger(HostEvent.UpdateFilters, {
|
|
2342
|
-
* filter: { column: 'column name', oper: '
|
|
2378
|
+
* filter: { column: 'column name', oper: 'IN', values: [1,2,3], is_mandatory: false }
|
|
2343
2379
|
* })
|
|
2344
2380
|
* ```
|
|
2345
2381
|
* @version SDK: 1.23.0 | ThoughtSpot: 9.4.0.cl
|
|
@@ -2426,6 +2462,32 @@ var HostEvent;
|
|
|
2426
2462
|
* @version SDK: 1.29.0 | Thoughtspot: 9.12.0.cl
|
|
2427
2463
|
*/
|
|
2428
2464
|
HostEvent["AskSage"] = "AskSage";
|
|
2465
|
+
/**
|
|
2466
|
+
* Trigger UpdateCrossFilter for Liveboard
|
|
2467
|
+
*
|
|
2468
|
+
* @example
|
|
2469
|
+
* ```js
|
|
2470
|
+
* liveboardEmbed.trigger(HostEvent.UpdateCrossFilter, {
|
|
2471
|
+
* vizId: 'b535c760-8bbe-4e6f-bb26-af56b4129a1e',
|
|
2472
|
+
* conditions: [
|
|
2473
|
+
* { columnName: 'Category', values: ['mfgr#12','mfgr#14'] },
|
|
2474
|
+
* { columnName: 'color', values: ['mint','hot'] },
|
|
2475
|
+
* ],
|
|
2476
|
+
* });
|
|
2477
|
+
* ```
|
|
2478
|
+
* @version SDK: 1.29.0 | Thoughtspot: 10.0.0.cl
|
|
2479
|
+
*/
|
|
2480
|
+
HostEvent["UpdateCrossFilter"] = "UpdateCrossFilter";
|
|
2481
|
+
/**
|
|
2482
|
+
* Trigger ResetLiveboardPersonalisedView for Liveboard
|
|
2483
|
+
*
|
|
2484
|
+
* @example
|
|
2485
|
+
* ```js
|
|
2486
|
+
* liveboardEmbed.trigger(HostEvent.ResetLiveboardPersonalisedView);
|
|
2487
|
+
* ```
|
|
2488
|
+
* @version SDK: 1.29.0 | Thoughtspot: 10.1.0.cl
|
|
2489
|
+
*/
|
|
2490
|
+
HostEvent["ResetLiveboardPersonalisedView"] = "ResetLiveboardPersonalisedView";
|
|
2429
2491
|
})(HostEvent || (HostEvent = {}));
|
|
2430
2492
|
/**
|
|
2431
2493
|
* The different visual modes that the data sources panel within
|
|
@@ -3400,6 +3462,7 @@ var Action;
|
|
|
3400
3462
|
Action["AskAi"] = "AskAi";
|
|
3401
3463
|
/**
|
|
3402
3464
|
* The **Add KPI to Watchlist** action on Home page watchlist.
|
|
3465
|
+
*
|
|
3403
3466
|
* @example
|
|
3404
3467
|
* ```js
|
|
3405
3468
|
* disabledActions: [Action.AddToWatchlist]
|
|
@@ -3409,6 +3472,7 @@ var Action;
|
|
|
3409
3472
|
Action["AddToWatchlist"] = "addToWatchlist";
|
|
3410
3473
|
/**
|
|
3411
3474
|
* The **Remove from watchlist** menu action on KPI watchlist.
|
|
3475
|
+
*
|
|
3412
3476
|
* @example
|
|
3413
3477
|
* ```js
|
|
3414
3478
|
* disabledActions: [Action.RemoveFromWatchlist]
|
|
@@ -3418,6 +3482,7 @@ var Action;
|
|
|
3418
3482
|
Action["RemoveFromWatchlist"] = "removeFromWatchlist";
|
|
3419
3483
|
/**
|
|
3420
3484
|
* The **Copy KPI Link** menu action on KPI watchlist.
|
|
3485
|
+
*
|
|
3421
3486
|
* @example
|
|
3422
3487
|
* ```js
|
|
3423
3488
|
* disabledActions: [Action.CopyKpiLink]
|
|
@@ -3425,6 +3490,16 @@ var Action;
|
|
|
3425
3490
|
* @version SDK : 1.27.9 | Thoughtspot: 9.12.5.cl
|
|
3426
3491
|
*/
|
|
3427
3492
|
Action["CopyKpiLink"] = "copyKpiLink";
|
|
3493
|
+
/**
|
|
3494
|
+
* Action ID for AI Highlights button
|
|
3495
|
+
*
|
|
3496
|
+
* @example
|
|
3497
|
+
* ```js
|
|
3498
|
+
* hiddenAction: [Action.AIHighlights]
|
|
3499
|
+
* ```
|
|
3500
|
+
* @version SDK: 1.27.10 | Thoughtspot: 9.12.5.cl
|
|
3501
|
+
*/
|
|
3502
|
+
Action["AIHighlights"] = "AIHighlights";
|
|
3428
3503
|
})(Action || (Action = {}));
|
|
3429
3504
|
var PrefetchFeatures;
|
|
3430
3505
|
(function (PrefetchFeatures) {
|
|
@@ -5728,6 +5803,8 @@ function isEqual(value, other) {
|
|
|
5728
5803
|
|
|
5729
5804
|
var isEqual_1 = isEqual;
|
|
5730
5805
|
|
|
5806
|
+
var name="@thoughtspot/visual-embed-sdk";var version="1.28.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/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.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-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",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","is-publish-allowed":"node scripts/is-publish-allowed.js",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","check-size":"npm run build && size-limit","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","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",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",tslib:"^2.5.3","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","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@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","current-git-branch":"^1.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-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",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,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"45 kB"}],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};
|
|
5807
|
+
|
|
5731
5808
|
/**
|
|
5732
5809
|
* Checks if `value` is `undefined`.
|
|
5733
5810
|
*
|
|
@@ -5880,7 +5957,7 @@ async function verifyTokenService(thoughtSpotHost, authToken) {
|
|
|
5880
5957
|
return res.ok;
|
|
5881
5958
|
}
|
|
5882
5959
|
catch (e) {
|
|
5883
|
-
logger.
|
|
5960
|
+
logger.warn(`Token Verification Service failed : ${e.message}`);
|
|
5884
5961
|
}
|
|
5885
5962
|
return false;
|
|
5886
5963
|
}
|
|
@@ -5898,7 +5975,10 @@ async function fetchAuthTokenService(authEndpoint) {
|
|
|
5898
5975
|
* @param authToken
|
|
5899
5976
|
*/
|
|
5900
5977
|
async function fetchAuthService(thoughtSpotHost, username, authToken) {
|
|
5901
|
-
|
|
5978
|
+
const fetchUrlParams = username
|
|
5979
|
+
? `username=${username}&auth_token=${authToken}`
|
|
5980
|
+
: `auth_token=${authToken}`;
|
|
5981
|
+
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}?${fetchUrlParams}`, {
|
|
5902
5982
|
credentials: 'include',
|
|
5903
5983
|
// We do not want to follow the redirect, as it starts giving a CORS
|
|
5904
5984
|
// error
|
|
@@ -5912,13 +5992,16 @@ async function fetchAuthService(thoughtSpotHost, username, authToken) {
|
|
|
5912
5992
|
* @param authToken
|
|
5913
5993
|
*/
|
|
5914
5994
|
async function fetchAuthPostService(thoughtSpotHost, username, authToken) {
|
|
5995
|
+
const bodyPrams = username
|
|
5996
|
+
? `username=${encodeURIComponent(username)}&auth_token=${encodeURIComponent(authToken)}`
|
|
5997
|
+
: `auth_token=${encodeURIComponent(authToken)}`;
|
|
5915
5998
|
return failureLoggedFetch(`${thoughtSpotHost}${EndPoints.TOKEN_LOGIN}`, {
|
|
5916
5999
|
method: 'POST',
|
|
5917
6000
|
headers: {
|
|
5918
6001
|
'content-type': 'application/x-www-form-urlencoded',
|
|
5919
6002
|
'x-requested-by': 'ThoughtSpot',
|
|
5920
6003
|
},
|
|
5921
|
-
body:
|
|
6004
|
+
body: bodyPrams,
|
|
5922
6005
|
credentials: 'include',
|
|
5923
6006
|
// We do not want to follow the redirect, as it starts giving a CORS
|
|
5924
6007
|
// error
|
|
@@ -5998,747 +6081,215 @@ const resetCachedAuthToken = () => {
|
|
|
5998
6081
|
cachedAuthToken = null;
|
|
5999
6082
|
};
|
|
6000
6083
|
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
*
|
|
6005
|
-
* @returns {@link EmbedConfig} The configuration embed was initialized with.
|
|
6006
|
-
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
6007
|
-
* @group Global methods
|
|
6008
|
-
*/
|
|
6009
|
-
const getEmbedConfig = () => config;
|
|
6010
|
-
|
|
6011
|
-
const tokenizedFetch = async (input, init) => {
|
|
6012
|
-
const embedConfig = getEmbedConfig();
|
|
6013
|
-
if (embedConfig.authType !== AuthType.TrustedAuthTokenCookieless) {
|
|
6014
|
-
return fetch(input, init);
|
|
6015
|
-
}
|
|
6016
|
-
const req = new Request(input, init);
|
|
6017
|
-
const authToken = await getAuthenticationToken(embedConfig);
|
|
6018
|
-
if (authToken) {
|
|
6019
|
-
req.headers.append('Authorization', `Bearer ${authToken}`);
|
|
6020
|
-
}
|
|
6021
|
-
return fetch(req);
|
|
6084
|
+
var Config = {
|
|
6085
|
+
DEBUG: false,
|
|
6086
|
+
LIB_VERSION: '2.45.0'
|
|
6022
6087
|
};
|
|
6023
6088
|
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
'accept-language': 'en-us',
|
|
6042
|
-
},
|
|
6043
|
-
body: JSON.stringify({
|
|
6044
|
-
operationName,
|
|
6045
|
-
query,
|
|
6046
|
-
variables,
|
|
6047
|
-
}),
|
|
6048
|
-
credentials: 'include',
|
|
6049
|
-
});
|
|
6050
|
-
const result = await response.json();
|
|
6051
|
-
const dataValues = Object.values(result.data);
|
|
6052
|
-
return (isCompositeQuery) ? result.data : dataValues[0];
|
|
6053
|
-
}
|
|
6054
|
-
catch (error) {
|
|
6055
|
-
return error;
|
|
6056
|
-
}
|
|
6089
|
+
// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
|
|
6090
|
+
var window$1;
|
|
6091
|
+
if (typeof(window) === 'undefined') {
|
|
6092
|
+
var loc = {
|
|
6093
|
+
hostname: ''
|
|
6094
|
+
};
|
|
6095
|
+
window$1 = {
|
|
6096
|
+
navigator: { userAgent: '' },
|
|
6097
|
+
document: {
|
|
6098
|
+
location: loc,
|
|
6099
|
+
referrer: ''
|
|
6100
|
+
},
|
|
6101
|
+
screen: { width: 0, height: 0 },
|
|
6102
|
+
location: loc
|
|
6103
|
+
};
|
|
6104
|
+
} else {
|
|
6105
|
+
window$1 = window;
|
|
6057
6106
|
}
|
|
6058
6107
|
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
name
|
|
6064
|
-
description
|
|
6065
|
-
authorName
|
|
6066
|
-
authorDisplayName
|
|
6067
|
-
isExternal
|
|
6068
|
-
type
|
|
6069
|
-
created
|
|
6070
|
-
modified
|
|
6071
|
-
columns {
|
|
6072
|
-
id
|
|
6073
|
-
name
|
|
6074
|
-
author
|
|
6075
|
-
authorDisplayName
|
|
6076
|
-
description
|
|
6077
|
-
dataType
|
|
6078
|
-
type
|
|
6079
|
-
modified
|
|
6080
|
-
ownerName
|
|
6081
|
-
owner
|
|
6082
|
-
dataRecency
|
|
6083
|
-
sources {
|
|
6084
|
-
tableId
|
|
6085
|
-
tableName
|
|
6086
|
-
columnId
|
|
6087
|
-
columnName
|
|
6088
|
-
__typename
|
|
6089
|
-
}
|
|
6090
|
-
synonyms
|
|
6091
|
-
cohortAnswerId
|
|
6092
|
-
__typename
|
|
6093
|
-
}
|
|
6094
|
-
relationships
|
|
6095
|
-
destinationRelationships
|
|
6096
|
-
dataSourceId
|
|
6097
|
-
__typename
|
|
6098
|
-
}
|
|
6099
|
-
}
|
|
6100
|
-
`;
|
|
6101
|
-
const sourceDetailCache = new Map();
|
|
6102
|
-
/**
|
|
6103
|
-
*
|
|
6104
|
-
* @param thoughtSpotHost
|
|
6105
|
-
* @param sourceId
|
|
6106
|
-
*/
|
|
6107
|
-
async function getSourceDetail(thoughtSpotHost, sourceId) {
|
|
6108
|
-
if (sourceDetailCache.get(sourceId)) {
|
|
6109
|
-
return sourceDetailCache.get(sourceId);
|
|
6110
|
-
}
|
|
6111
|
-
const details = await graphqlQuery({
|
|
6112
|
-
query: getSourceDetailQuery,
|
|
6113
|
-
variables: {
|
|
6114
|
-
ids: [sourceId],
|
|
6115
|
-
},
|
|
6116
|
-
thoughtSpotHost,
|
|
6117
|
-
});
|
|
6118
|
-
const souceDetails = details[0];
|
|
6119
|
-
if (souceDetails) {
|
|
6120
|
-
sourceDetailCache.set(sourceId, souceDetails);
|
|
6121
|
-
}
|
|
6122
|
-
return souceDetails;
|
|
6123
|
-
}
|
|
6108
|
+
/*
|
|
6109
|
+
* Saved references to long variable names, so that closure compiler can
|
|
6110
|
+
* minimize file size.
|
|
6111
|
+
*/
|
|
6124
6112
|
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6113
|
+
var ArrayProto = Array.prototype;
|
|
6114
|
+
var FuncProto = Function.prototype;
|
|
6115
|
+
var ObjProto = Object.prototype;
|
|
6116
|
+
var slice = ArrayProto.slice;
|
|
6117
|
+
var toString = ObjProto.toString;
|
|
6118
|
+
var hasOwnProperty$9 = ObjProto.hasOwnProperty;
|
|
6119
|
+
var windowConsole = window$1.console;
|
|
6120
|
+
var navigator = window$1.navigator;
|
|
6121
|
+
var document$1 = window$1.document;
|
|
6122
|
+
var windowOpera = window$1.opera;
|
|
6123
|
+
var screen = window$1.screen;
|
|
6124
|
+
var userAgent = navigator.userAgent;
|
|
6125
|
+
var nativeBind = FuncProto.bind;
|
|
6126
|
+
var nativeForEach = ArrayProto.forEach;
|
|
6127
|
+
var nativeIndexOf = ArrayProto.indexOf;
|
|
6128
|
+
var nativeMap = ArrayProto.map;
|
|
6129
|
+
var nativeIsArray = Array.isArray;
|
|
6130
|
+
var breaker = {};
|
|
6131
|
+
var _ = {
|
|
6132
|
+
trim: function(str) {
|
|
6133
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
|
6134
|
+
return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
6132
6135
|
}
|
|
6133
|
-
}
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6136
|
+
};
|
|
6137
|
+
|
|
6138
|
+
// Console override
|
|
6139
|
+
var console$1 = {
|
|
6140
|
+
/** @type {function(...*)} */
|
|
6141
|
+
log: function() {
|
|
6142
|
+
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6143
|
+
try {
|
|
6144
|
+
windowConsole.log.apply(windowConsole, arguments);
|
|
6145
|
+
} catch (err) {
|
|
6146
|
+
_.each(arguments, function(arg) {
|
|
6147
|
+
windowConsole.log(arg);
|
|
6148
|
+
});
|
|
6149
|
+
}
|
|
6150
|
+
}
|
|
6151
|
+
},
|
|
6152
|
+
/** @type {function(...*)} */
|
|
6153
|
+
warn: function() {
|
|
6154
|
+
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6155
|
+
var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
|
|
6156
|
+
try {
|
|
6157
|
+
windowConsole.warn.apply(windowConsole, args);
|
|
6158
|
+
} catch (err) {
|
|
6159
|
+
_.each(args, function(arg) {
|
|
6160
|
+
windowConsole.warn(arg);
|
|
6161
|
+
});
|
|
6162
|
+
}
|
|
6163
|
+
}
|
|
6164
|
+
},
|
|
6165
|
+
/** @type {function(...*)} */
|
|
6166
|
+
error: function() {
|
|
6167
|
+
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6168
|
+
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6169
|
+
try {
|
|
6170
|
+
windowConsole.error.apply(windowConsole, args);
|
|
6171
|
+
} catch (err) {
|
|
6172
|
+
_.each(args, function(arg) {
|
|
6173
|
+
windowConsole.error(arg);
|
|
6174
|
+
});
|
|
6175
|
+
}
|
|
6176
|
+
}
|
|
6177
|
+
},
|
|
6178
|
+
/** @type {function(...*)} */
|
|
6179
|
+
critical: function() {
|
|
6180
|
+
if (!_.isUndefined(windowConsole) && windowConsole) {
|
|
6181
|
+
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6182
|
+
try {
|
|
6183
|
+
windowConsole.error.apply(windowConsole, args);
|
|
6184
|
+
} catch (err) {
|
|
6185
|
+
_.each(args, function(arg) {
|
|
6186
|
+
windowConsole.error(arg);
|
|
6187
|
+
});
|
|
6153
6188
|
}
|
|
6154
6189
|
}
|
|
6155
6190
|
}
|
|
6156
|
-
}
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6191
|
+
};
|
|
6192
|
+
|
|
6193
|
+
var log_func_with_prefix = function(func, prefix) {
|
|
6194
|
+
return function() {
|
|
6195
|
+
arguments[0] = '[' + prefix + '] ' + arguments[0];
|
|
6196
|
+
return func.apply(console$1, arguments);
|
|
6197
|
+
};
|
|
6198
|
+
};
|
|
6199
|
+
var console_with_prefix = function(prefix) {
|
|
6200
|
+
return {
|
|
6201
|
+
log: log_func_with_prefix(console$1.log, prefix),
|
|
6202
|
+
error: log_func_with_prefix(console$1.error, prefix),
|
|
6203
|
+
critical: log_func_with_prefix(console$1.critical, prefix)
|
|
6204
|
+
};
|
|
6205
|
+
};
|
|
6206
|
+
|
|
6207
|
+
|
|
6208
|
+
// UNDERSCORE
|
|
6209
|
+
// Embed part of the Underscore Library
|
|
6210
|
+
_.bind = function(func, context) {
|
|
6211
|
+
var args, bound;
|
|
6212
|
+
if (nativeBind && func.bind === nativeBind) {
|
|
6213
|
+
return nativeBind.apply(func, slice.call(arguments, 1));
|
|
6214
|
+
}
|
|
6215
|
+
if (!_.isFunction(func)) {
|
|
6216
|
+
throw new TypeError();
|
|
6217
|
+
}
|
|
6218
|
+
args = slice.call(arguments, 2);
|
|
6219
|
+
bound = function() {
|
|
6220
|
+
if (!(this instanceof bound)) {
|
|
6221
|
+
return func.apply(context, args.concat(slice.call(arguments)));
|
|
6173
6222
|
}
|
|
6223
|
+
var ctor = {};
|
|
6224
|
+
ctor.prototype = func.prototype;
|
|
6225
|
+
var self = new ctor();
|
|
6226
|
+
ctor.prototype = null;
|
|
6227
|
+
var result = func.apply(self, args.concat(slice.call(arguments)));
|
|
6228
|
+
if (Object(result) === result) {
|
|
6229
|
+
return result;
|
|
6230
|
+
}
|
|
6231
|
+
return self;
|
|
6232
|
+
};
|
|
6233
|
+
return bound;
|
|
6234
|
+
};
|
|
6235
|
+
|
|
6236
|
+
/**
|
|
6237
|
+
* @param {*=} obj
|
|
6238
|
+
* @param {function(...*)=} iterator
|
|
6239
|
+
* @param {Object=} context
|
|
6240
|
+
*/
|
|
6241
|
+
_.each = function(obj, iterator, context) {
|
|
6242
|
+
if (obj === null || obj === undefined) {
|
|
6243
|
+
return;
|
|
6174
6244
|
}
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
name
|
|
6189
|
-
type
|
|
6190
|
-
aggregationType
|
|
6191
|
-
dataType
|
|
6192
|
-
}
|
|
6193
|
-
}
|
|
6194
|
-
data(deadline: $deadline, pagination: $dataPaginationParams)
|
|
6195
|
-
}
|
|
6245
|
+
if (nativeForEach && obj.forEach === nativeForEach) {
|
|
6246
|
+
obj.forEach(iterator, context);
|
|
6247
|
+
} else if (obj.length === +obj.length) {
|
|
6248
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
|
6249
|
+
if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
|
|
6250
|
+
return;
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
} else {
|
|
6254
|
+
for (var key in obj) {
|
|
6255
|
+
if (hasOwnProperty$9.call(obj, key)) {
|
|
6256
|
+
if (iterator.call(context, obj[key], key, obj) === breaker) {
|
|
6257
|
+
return;
|
|
6196
6258
|
}
|
|
6197
6259
|
}
|
|
6198
6260
|
}
|
|
6199
6261
|
}
|
|
6200
|
-
|
|
6262
|
+
};
|
|
6201
6263
|
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
(
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
}
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
* graphql queries in the context of the answer on which the
|
|
6212
|
-
* custom action was triggered.
|
|
6213
|
-
*
|
|
6214
|
-
* @example
|
|
6215
|
-
* ```js
|
|
6216
|
-
* embed.on(EmbedEvent.CustomAction, e => {
|
|
6217
|
-
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
6218
|
-
* 'col name 1'
|
|
6219
|
-
* ]);
|
|
6220
|
-
* const data = await underlying.fetchData(0, 100);
|
|
6221
|
-
* })
|
|
6222
|
-
* ```
|
|
6223
|
-
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
6224
|
-
* @group Events
|
|
6225
|
-
*/
|
|
6226
|
-
class AnswerService {
|
|
6227
|
-
/**
|
|
6228
|
-
* Should not need to be called directly.
|
|
6229
|
-
*
|
|
6230
|
-
* @param session
|
|
6231
|
-
* @param answer
|
|
6232
|
-
* @param thoughtSpotHost
|
|
6233
|
-
* @param selectedPoints
|
|
6234
|
-
*/
|
|
6235
|
-
constructor(session, answer, thoughtSpotHost, selectedPoints) {
|
|
6236
|
-
this.session = session;
|
|
6237
|
-
this.answer = answer;
|
|
6238
|
-
this.thoughtSpotHost = thoughtSpotHost;
|
|
6239
|
-
this.selectedPoints = selectedPoints;
|
|
6240
|
-
this.session = removeTypename(session);
|
|
6241
|
-
}
|
|
6242
|
-
/**
|
|
6243
|
-
* Get the details about the source used in the answer.
|
|
6244
|
-
* This can be used to get the list of all columns in the data source for example.
|
|
6245
|
-
*/
|
|
6246
|
-
async getSourceDetail() {
|
|
6247
|
-
const sourceId = this.answer.sources[0].header.guid;
|
|
6248
|
-
return getSourceDetail(this.thoughtSpotHost, sourceId);
|
|
6249
|
-
}
|
|
6250
|
-
/**
|
|
6251
|
-
* Remove columnIds and return updated answer session.
|
|
6252
|
-
*
|
|
6253
|
-
* @param columnIds
|
|
6254
|
-
* @returns
|
|
6255
|
-
*/
|
|
6256
|
-
async removeColumns(columnIds) {
|
|
6257
|
-
return this.executeQuery(removeColumns, {
|
|
6258
|
-
logicalColumnIds: columnIds,
|
|
6259
|
-
});
|
|
6260
|
-
}
|
|
6261
|
-
/**
|
|
6262
|
-
* Add columnIds and return updated answer session.
|
|
6263
|
-
*
|
|
6264
|
-
* @param columnIds
|
|
6265
|
-
* @returns
|
|
6266
|
-
*/
|
|
6267
|
-
async addColumns(columnIds) {
|
|
6268
|
-
return this.executeQuery(addColumns, {
|
|
6269
|
-
columns: columnIds.map((colId) => ({ logicalColumnId: colId })),
|
|
6270
|
-
});
|
|
6271
|
-
}
|
|
6272
|
-
/**
|
|
6273
|
-
* Fetch data from the answer.
|
|
6274
|
-
*
|
|
6275
|
-
* @param offset
|
|
6276
|
-
* @param size
|
|
6277
|
-
* @returns
|
|
6278
|
-
*/
|
|
6279
|
-
async fetchData(offset = 0, size = 1000) {
|
|
6280
|
-
const { answer } = await this.executeQuery(getAnswerData, {
|
|
6281
|
-
deadline: 0,
|
|
6282
|
-
dataPaginationParams: {
|
|
6283
|
-
isClientPaginated: true,
|
|
6284
|
-
offset,
|
|
6285
|
-
size,
|
|
6286
|
-
},
|
|
6287
|
-
});
|
|
6288
|
-
const { columns, data } = answer.visualizations.find((viz) => !!viz.data) || {};
|
|
6289
|
-
return {
|
|
6290
|
-
columns,
|
|
6291
|
-
data,
|
|
6292
|
-
};
|
|
6293
|
-
}
|
|
6294
|
-
/**
|
|
6295
|
-
* Fetch the data for the answer as a CSV blob. This might be
|
|
6296
|
-
* quicker for larger data.
|
|
6297
|
-
*
|
|
6298
|
-
* @param userLocale
|
|
6299
|
-
* @param includeInfo Include the CSV header in the output
|
|
6300
|
-
* @returns Response
|
|
6301
|
-
*/
|
|
6302
|
-
async fetchCSVBlob(userLocale = 'en-us', includeInfo = false) {
|
|
6303
|
-
const fetchUrl = this.getFetchCSVBlobUrl(userLocale, includeInfo);
|
|
6304
|
-
return tokenizedFetch(fetchUrl, {
|
|
6305
|
-
credentials: 'include',
|
|
6306
|
-
});
|
|
6307
|
-
}
|
|
6308
|
-
/**
|
|
6309
|
-
* Just get the internal URL for this answer's data
|
|
6310
|
-
* as a CSV blob.
|
|
6311
|
-
*
|
|
6312
|
-
* @param userLocale
|
|
6313
|
-
* @param includeInfo
|
|
6314
|
-
* @returns
|
|
6315
|
-
*/
|
|
6316
|
-
getFetchCSVBlobUrl(userLocale = 'en-us', includeInfo = false) {
|
|
6317
|
-
return `${this.thoughtSpotHost}/prism/download/answer/csv?sessionId=${this.session.sessionId}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data&hideCsvHeader=${!includeInfo}`;
|
|
6318
|
-
}
|
|
6319
|
-
/**
|
|
6320
|
-
* Get underlying data given a point and the output column names.
|
|
6321
|
-
* In case of a context menu action, the selectedPoints are
|
|
6322
|
-
* automatically passed.
|
|
6323
|
-
*
|
|
6324
|
-
* @param outputColumnNames
|
|
6325
|
-
* @param selectedPoints
|
|
6326
|
-
* @example
|
|
6327
|
-
* ```js
|
|
6328
|
-
* embed.on(EmbedEvent.CustomAction, e => {
|
|
6329
|
-
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
6330
|
-
* 'col name 1' // The column should exist in the data source.
|
|
6331
|
-
* ]);
|
|
6332
|
-
* const data = await underlying.fetchData(0, 100);
|
|
6333
|
-
* })
|
|
6334
|
-
* ```
|
|
6335
|
-
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
6336
|
-
*/
|
|
6337
|
-
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
6338
|
-
if (!selectedPoints && !this.selectedPoints) {
|
|
6339
|
-
throw new Error('Needs to be triggered in context of a point');
|
|
6340
|
-
}
|
|
6341
|
-
if (!selectedPoints) {
|
|
6342
|
-
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
6343
|
-
}
|
|
6344
|
-
const sourceDetail = await this.getSourceDetail();
|
|
6345
|
-
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
6346
|
-
const unAggAnswer = await graphqlQuery({
|
|
6347
|
-
query: getUnaggregatedAnswerSession,
|
|
6348
|
-
variables: {
|
|
6349
|
-
session: this.session,
|
|
6350
|
-
columns: selectedPoints,
|
|
6351
|
-
},
|
|
6352
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
6353
|
-
});
|
|
6354
|
-
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
6355
|
-
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
6356
|
-
.map((c) => c.column.referencedColumns[0].guid));
|
|
6357
|
-
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
6358
|
-
if (columnsToAdd.length) {
|
|
6359
|
-
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
6360
|
-
}
|
|
6361
|
-
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
6362
|
-
if (columnsToRemove.length) {
|
|
6363
|
-
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
6364
|
-
}
|
|
6365
|
-
return unaggAnswerSession;
|
|
6366
|
-
}
|
|
6367
|
-
/**
|
|
6368
|
-
* Execute a custom graphql query in the context of the answer.
|
|
6369
|
-
*
|
|
6370
|
-
* @param query graphql query
|
|
6371
|
-
* @param variables graphql variables
|
|
6372
|
-
* @returns
|
|
6373
|
-
*/
|
|
6374
|
-
async executeQuery(query, variables) {
|
|
6375
|
-
const data = await graphqlQuery({
|
|
6376
|
-
query,
|
|
6377
|
-
variables: {
|
|
6378
|
-
session: this.session,
|
|
6379
|
-
...variables,
|
|
6380
|
-
},
|
|
6381
|
-
thoughtSpotHost: this.thoughtSpotHost,
|
|
6382
|
-
isCompositeQuery: false,
|
|
6383
|
-
});
|
|
6384
|
-
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
6385
|
-
return data;
|
|
6386
|
-
}
|
|
6387
|
-
/**
|
|
6388
|
-
* Get the internal session details for the answer.
|
|
6389
|
-
*
|
|
6390
|
-
* @returns
|
|
6391
|
-
*/
|
|
6392
|
-
getSession() {
|
|
6393
|
-
return this.session;
|
|
6394
|
-
}
|
|
6395
|
-
}
|
|
6396
|
-
/**
|
|
6397
|
-
*
|
|
6398
|
-
* @param sourceDetail
|
|
6399
|
-
* @param colNames
|
|
6400
|
-
*/
|
|
6401
|
-
function getGuidsFromColumnNames(sourceDetail, colNames) {
|
|
6402
|
-
const cols = sourceDetail.columns.reduce((colSet, col) => {
|
|
6403
|
-
colSet[col.name] = col;
|
|
6404
|
-
return colSet;
|
|
6405
|
-
}, {});
|
|
6406
|
-
return new Set(colNames.map((colName) => {
|
|
6407
|
-
const col = cols[colName];
|
|
6408
|
-
return col.id;
|
|
6409
|
-
}));
|
|
6410
|
-
}
|
|
6411
|
-
/**
|
|
6412
|
-
*
|
|
6413
|
-
* @param selectedPoints
|
|
6414
|
-
*/
|
|
6415
|
-
function getSelectedPointsForUnderlyingDataQuery(selectedPoints) {
|
|
6416
|
-
const underlyingDataPoint = [];
|
|
6417
|
-
/**
|
|
6418
|
-
*
|
|
6419
|
-
* @param colVal
|
|
6420
|
-
*/
|
|
6421
|
-
function addPointFromColVal(colVal) {
|
|
6422
|
-
var _a;
|
|
6423
|
-
const dataType = colVal.column.dataType;
|
|
6424
|
-
const id = colVal.column.id;
|
|
6425
|
-
let dataValue;
|
|
6426
|
-
if (dataType === 'DATE') {
|
|
6427
|
-
if (Number.isFinite(colVal.value)) {
|
|
6428
|
-
dataValue = [{
|
|
6429
|
-
epochRange: {
|
|
6430
|
-
startEpoch: colVal.value,
|
|
6431
|
-
},
|
|
6432
|
-
}];
|
|
6433
|
-
// Case for custom calendar.
|
|
6434
|
-
}
|
|
6435
|
-
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
6436
|
-
dataValue = [{
|
|
6437
|
-
epochRange: {
|
|
6438
|
-
startEpoch: colVal.value.v.s,
|
|
6439
|
-
endEpoch: colVal.value.v.e,
|
|
6440
|
-
},
|
|
6441
|
-
}];
|
|
6442
|
-
}
|
|
6443
|
-
}
|
|
6444
|
-
else {
|
|
6445
|
-
dataValue = [{ value: colVal.value }];
|
|
6446
|
-
}
|
|
6447
|
-
underlyingDataPoint.push({
|
|
6448
|
-
columnId: colVal.column.id,
|
|
6449
|
-
dataValue,
|
|
6450
|
-
});
|
|
6451
|
-
}
|
|
6452
|
-
selectedPoints.forEach((p) => {
|
|
6453
|
-
p.selectedAttributes.forEach(addPointFromColVal);
|
|
6454
|
-
});
|
|
6455
|
-
return underlyingDataPoint;
|
|
6456
|
-
}
|
|
6457
|
-
|
|
6458
|
-
const ERROR_MESSAGE = {
|
|
6459
|
-
INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
|
|
6460
|
-
LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
|
|
6461
|
-
TRIGGER_TIMED_OUT: 'Trigger timedout in getting response',
|
|
6462
|
-
SEARCHEMBED_BETA_WRANING_MESSAGE: 'Search Embed is in Beta in this release.',
|
|
6463
|
-
SAGE_EMBED_BETA_WARNING_MESSAGE: 'Sage Embed is in Beta in this release.',
|
|
6264
|
+
_.extend = function(obj) {
|
|
6265
|
+
_.each(slice.call(arguments, 1), function(source) {
|
|
6266
|
+
for (var prop in source) {
|
|
6267
|
+
if (source[prop] !== void 0) {
|
|
6268
|
+
obj[prop] = source[prop];
|
|
6269
|
+
}
|
|
6270
|
+
}
|
|
6271
|
+
});
|
|
6272
|
+
return obj;
|
|
6464
6273
|
};
|
|
6465
6274
|
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
* Utilities related to reading configuration objects
|
|
6470
|
-
*
|
|
6471
|
-
* @summary Config-related utils
|
|
6472
|
-
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
6473
|
-
*/
|
|
6474
|
-
const urlRegex = new RegExp([
|
|
6475
|
-
'(^(https?:)//)?',
|
|
6476
|
-
'(([^:/?#]*)(?::([0-9]+))?)',
|
|
6477
|
-
'(/{0,1}[^?#]*)',
|
|
6478
|
-
'(\\?[^#]*|)',
|
|
6479
|
-
'(#.*|)$', // hash
|
|
6480
|
-
].join(''));
|
|
6481
|
-
/**
|
|
6482
|
-
* Parse and construct the ThoughtSpot hostname or IP address
|
|
6483
|
-
* from the embed configuration object.
|
|
6484
|
-
*
|
|
6485
|
-
* @param config
|
|
6486
|
-
*/
|
|
6487
|
-
const getThoughtSpotHost = (config) => {
|
|
6488
|
-
if (!config.thoughtSpotHost) {
|
|
6489
|
-
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
6490
|
-
}
|
|
6491
|
-
const urlParts = config.thoughtSpotHost.match(urlRegex);
|
|
6492
|
-
if (!urlParts) {
|
|
6493
|
-
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
6494
|
-
}
|
|
6495
|
-
const protocol = urlParts[2] || window.location.protocol;
|
|
6496
|
-
const host = urlParts[3];
|
|
6497
|
-
let path = urlParts[6];
|
|
6498
|
-
// Lose the trailing / if any
|
|
6499
|
-
if (path.charAt(path.length - 1) === '/') {
|
|
6500
|
-
path = path.substring(0, path.length - 1);
|
|
6501
|
-
}
|
|
6502
|
-
// const urlParams = urlParts[7];
|
|
6503
|
-
// const hash = urlParts[8];
|
|
6504
|
-
return `${protocol}//${host}${path}`;
|
|
6505
|
-
};
|
|
6506
|
-
const getV2BasePath = (config) => {
|
|
6507
|
-
if (config.basepath) {
|
|
6508
|
-
return config.basepath;
|
|
6509
|
-
}
|
|
6510
|
-
const tsHost = getThoughtSpotHost(config);
|
|
6511
|
-
// This is to handle when e2e's. Search is run on pods for
|
|
6512
|
-
// comp-blink-test-pipeline with baseUrl=https://localhost:8443.
|
|
6513
|
-
// This is to handle when the developer is developing in their local
|
|
6514
|
-
// environment.
|
|
6515
|
-
if (tsHost.includes('://localhost') && !tsHost.includes(':8443')) {
|
|
6516
|
-
return '';
|
|
6517
|
-
}
|
|
6518
|
-
return 'v2';
|
|
6519
|
-
};
|
|
6520
|
-
/**
|
|
6521
|
-
* It is a good idea to keep URLs under 2000 chars.
|
|
6522
|
-
* If this is ever breached, since we pass view configuration through
|
|
6523
|
-
* URL params, we would like to log a warning.
|
|
6524
|
-
* Reference: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
|
|
6525
|
-
*/
|
|
6526
|
-
const URL_MAX_LENGTH = 2000;
|
|
6527
|
-
/**
|
|
6528
|
-
* The default CSS dimensions of the embedded app
|
|
6529
|
-
*/
|
|
6530
|
-
const DEFAULT_EMBED_WIDTH = '100%';
|
|
6531
|
-
const DEFAULT_EMBED_HEIGHT = '100%';
|
|
6275
|
+
_.isArray = nativeIsArray || function(obj) {
|
|
6276
|
+
return toString.call(obj) === '[object Array]';
|
|
6277
|
+
};
|
|
6532
6278
|
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6279
|
+
// from a comment on http://dbj.org/dbj/?p=286
|
|
6280
|
+
// fails on only one very rare and deliberate custom object:
|
|
6281
|
+
// var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
|
|
6282
|
+
_.isFunction = function(f) {
|
|
6283
|
+
try {
|
|
6284
|
+
return /^\s*\bfunction\b/.test(f);
|
|
6285
|
+
} catch (x) {
|
|
6286
|
+
return false;
|
|
6287
|
+
}
|
|
6536
6288
|
};
|
|
6537
6289
|
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
var loc = {
|
|
6542
|
-
hostname: ''
|
|
6543
|
-
};
|
|
6544
|
-
window$1 = {
|
|
6545
|
-
navigator: { userAgent: '' },
|
|
6546
|
-
document: {
|
|
6547
|
-
location: loc,
|
|
6548
|
-
referrer: ''
|
|
6549
|
-
},
|
|
6550
|
-
screen: { width: 0, height: 0 },
|
|
6551
|
-
location: loc
|
|
6552
|
-
};
|
|
6553
|
-
} else {
|
|
6554
|
-
window$1 = window;
|
|
6555
|
-
}
|
|
6556
|
-
|
|
6557
|
-
/*
|
|
6558
|
-
* Saved references to long variable names, so that closure compiler can
|
|
6559
|
-
* minimize file size.
|
|
6560
|
-
*/
|
|
6561
|
-
|
|
6562
|
-
var ArrayProto = Array.prototype;
|
|
6563
|
-
var FuncProto = Function.prototype;
|
|
6564
|
-
var ObjProto = Object.prototype;
|
|
6565
|
-
var slice = ArrayProto.slice;
|
|
6566
|
-
var toString = ObjProto.toString;
|
|
6567
|
-
var hasOwnProperty$9 = ObjProto.hasOwnProperty;
|
|
6568
|
-
var windowConsole = window$1.console;
|
|
6569
|
-
var navigator = window$1.navigator;
|
|
6570
|
-
var document$1 = window$1.document;
|
|
6571
|
-
var windowOpera = window$1.opera;
|
|
6572
|
-
var screen = window$1.screen;
|
|
6573
|
-
var userAgent = navigator.userAgent;
|
|
6574
|
-
var nativeBind = FuncProto.bind;
|
|
6575
|
-
var nativeForEach = ArrayProto.forEach;
|
|
6576
|
-
var nativeIndexOf = ArrayProto.indexOf;
|
|
6577
|
-
var nativeMap = ArrayProto.map;
|
|
6578
|
-
var nativeIsArray = Array.isArray;
|
|
6579
|
-
var breaker = {};
|
|
6580
|
-
var _ = {
|
|
6581
|
-
trim: function(str) {
|
|
6582
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
|
6583
|
-
return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
6584
|
-
}
|
|
6585
|
-
};
|
|
6586
|
-
|
|
6587
|
-
// Console override
|
|
6588
|
-
var console$1 = {
|
|
6589
|
-
/** @type {function(...*)} */
|
|
6590
|
-
log: function() {
|
|
6591
|
-
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6592
|
-
try {
|
|
6593
|
-
windowConsole.log.apply(windowConsole, arguments);
|
|
6594
|
-
} catch (err) {
|
|
6595
|
-
_.each(arguments, function(arg) {
|
|
6596
|
-
windowConsole.log(arg);
|
|
6597
|
-
});
|
|
6598
|
-
}
|
|
6599
|
-
}
|
|
6600
|
-
},
|
|
6601
|
-
/** @type {function(...*)} */
|
|
6602
|
-
warn: function() {
|
|
6603
|
-
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6604
|
-
var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
|
|
6605
|
-
try {
|
|
6606
|
-
windowConsole.warn.apply(windowConsole, args);
|
|
6607
|
-
} catch (err) {
|
|
6608
|
-
_.each(args, function(arg) {
|
|
6609
|
-
windowConsole.warn(arg);
|
|
6610
|
-
});
|
|
6611
|
-
}
|
|
6612
|
-
}
|
|
6613
|
-
},
|
|
6614
|
-
/** @type {function(...*)} */
|
|
6615
|
-
error: function() {
|
|
6616
|
-
if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
|
|
6617
|
-
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6618
|
-
try {
|
|
6619
|
-
windowConsole.error.apply(windowConsole, args);
|
|
6620
|
-
} catch (err) {
|
|
6621
|
-
_.each(args, function(arg) {
|
|
6622
|
-
windowConsole.error(arg);
|
|
6623
|
-
});
|
|
6624
|
-
}
|
|
6625
|
-
}
|
|
6626
|
-
},
|
|
6627
|
-
/** @type {function(...*)} */
|
|
6628
|
-
critical: function() {
|
|
6629
|
-
if (!_.isUndefined(windowConsole) && windowConsole) {
|
|
6630
|
-
var args = ['Mixpanel error:'].concat(_.toArray(arguments));
|
|
6631
|
-
try {
|
|
6632
|
-
windowConsole.error.apply(windowConsole, args);
|
|
6633
|
-
} catch (err) {
|
|
6634
|
-
_.each(args, function(arg) {
|
|
6635
|
-
windowConsole.error(arg);
|
|
6636
|
-
});
|
|
6637
|
-
}
|
|
6638
|
-
}
|
|
6639
|
-
}
|
|
6640
|
-
};
|
|
6641
|
-
|
|
6642
|
-
var log_func_with_prefix = function(func, prefix) {
|
|
6643
|
-
return function() {
|
|
6644
|
-
arguments[0] = '[' + prefix + '] ' + arguments[0];
|
|
6645
|
-
return func.apply(console$1, arguments);
|
|
6646
|
-
};
|
|
6647
|
-
};
|
|
6648
|
-
var console_with_prefix = function(prefix) {
|
|
6649
|
-
return {
|
|
6650
|
-
log: log_func_with_prefix(console$1.log, prefix),
|
|
6651
|
-
error: log_func_with_prefix(console$1.error, prefix),
|
|
6652
|
-
critical: log_func_with_prefix(console$1.critical, prefix)
|
|
6653
|
-
};
|
|
6654
|
-
};
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
// UNDERSCORE
|
|
6658
|
-
// Embed part of the Underscore Library
|
|
6659
|
-
_.bind = function(func, context) {
|
|
6660
|
-
var args, bound;
|
|
6661
|
-
if (nativeBind && func.bind === nativeBind) {
|
|
6662
|
-
return nativeBind.apply(func, slice.call(arguments, 1));
|
|
6663
|
-
}
|
|
6664
|
-
if (!_.isFunction(func)) {
|
|
6665
|
-
throw new TypeError();
|
|
6666
|
-
}
|
|
6667
|
-
args = slice.call(arguments, 2);
|
|
6668
|
-
bound = function() {
|
|
6669
|
-
if (!(this instanceof bound)) {
|
|
6670
|
-
return func.apply(context, args.concat(slice.call(arguments)));
|
|
6671
|
-
}
|
|
6672
|
-
var ctor = {};
|
|
6673
|
-
ctor.prototype = func.prototype;
|
|
6674
|
-
var self = new ctor();
|
|
6675
|
-
ctor.prototype = null;
|
|
6676
|
-
var result = func.apply(self, args.concat(slice.call(arguments)));
|
|
6677
|
-
if (Object(result) === result) {
|
|
6678
|
-
return result;
|
|
6679
|
-
}
|
|
6680
|
-
return self;
|
|
6681
|
-
};
|
|
6682
|
-
return bound;
|
|
6683
|
-
};
|
|
6684
|
-
|
|
6685
|
-
/**
|
|
6686
|
-
* @param {*=} obj
|
|
6687
|
-
* @param {function(...*)=} iterator
|
|
6688
|
-
* @param {Object=} context
|
|
6689
|
-
*/
|
|
6690
|
-
_.each = function(obj, iterator, context) {
|
|
6691
|
-
if (obj === null || obj === undefined) {
|
|
6692
|
-
return;
|
|
6693
|
-
}
|
|
6694
|
-
if (nativeForEach && obj.forEach === nativeForEach) {
|
|
6695
|
-
obj.forEach(iterator, context);
|
|
6696
|
-
} else if (obj.length === +obj.length) {
|
|
6697
|
-
for (var i = 0, l = obj.length; i < l; i++) {
|
|
6698
|
-
if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
|
|
6699
|
-
return;
|
|
6700
|
-
}
|
|
6701
|
-
}
|
|
6702
|
-
} else {
|
|
6703
|
-
for (var key in obj) {
|
|
6704
|
-
if (hasOwnProperty$9.call(obj, key)) {
|
|
6705
|
-
if (iterator.call(context, obj[key], key, obj) === breaker) {
|
|
6706
|
-
return;
|
|
6707
|
-
}
|
|
6708
|
-
}
|
|
6709
|
-
}
|
|
6710
|
-
}
|
|
6711
|
-
};
|
|
6712
|
-
|
|
6713
|
-
_.extend = function(obj) {
|
|
6714
|
-
_.each(slice.call(arguments, 1), function(source) {
|
|
6715
|
-
for (var prop in source) {
|
|
6716
|
-
if (source[prop] !== void 0) {
|
|
6717
|
-
obj[prop] = source[prop];
|
|
6718
|
-
}
|
|
6719
|
-
}
|
|
6720
|
-
});
|
|
6721
|
-
return obj;
|
|
6722
|
-
};
|
|
6723
|
-
|
|
6724
|
-
_.isArray = nativeIsArray || function(obj) {
|
|
6725
|
-
return toString.call(obj) === '[object Array]';
|
|
6726
|
-
};
|
|
6727
|
-
|
|
6728
|
-
// from a comment on http://dbj.org/dbj/?p=286
|
|
6729
|
-
// fails on only one very rare and deliberate custom object:
|
|
6730
|
-
// var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
|
|
6731
|
-
_.isFunction = function(f) {
|
|
6732
|
-
try {
|
|
6733
|
-
return /^\s*\bfunction\b/.test(f);
|
|
6734
|
-
} catch (x) {
|
|
6735
|
-
return false;
|
|
6736
|
-
}
|
|
6737
|
-
};
|
|
6738
|
-
|
|
6739
|
-
_.isArguments = function(obj) {
|
|
6740
|
-
return !!(obj && hasOwnProperty$9.call(obj, 'callee'));
|
|
6741
|
-
};
|
|
6290
|
+
_.isArguments = function(obj) {
|
|
6291
|
+
return !!(obj && hasOwnProperty$9.call(obj, 'callee'));
|
|
6292
|
+
};
|
|
6742
6293
|
|
|
6743
6294
|
_.toArray = function(iterable) {
|
|
6744
6295
|
if (!iterable) {
|
|
@@ -12587,746 +12138,1290 @@ function initMixpanel(sessionInfo) {
|
|
|
12587
12138
|
}
|
|
12588
12139
|
}
|
|
12589
12140
|
|
|
12590
|
-
|
|
12591
|
-
|
|
12592
|
-
|
|
12593
|
-
|
|
12141
|
+
let config = {};
|
|
12142
|
+
/**
|
|
12143
|
+
* Gets the configuration embed was initialized with.
|
|
12144
|
+
*
|
|
12145
|
+
* @returns {@link EmbedConfig} The configuration embed was initialized with.
|
|
12146
|
+
* @version SDK: 1.19.0 | ThoughtSpot: *
|
|
12147
|
+
* @group Global methods
|
|
12148
|
+
*/
|
|
12149
|
+
const getEmbedConfig = () => config;
|
|
12594
12150
|
|
|
12595
|
-
/**
|
|
12596
|
-
*
|
|
12597
|
-
*
|
|
12598
|
-
*
|
|
12599
|
-
* @
|
|
12600
|
-
* @
|
|
12601
|
-
|
|
12602
|
-
|
|
12151
|
+
/**
|
|
12152
|
+
* Fetch wrapper that adds the authentication token to the request.
|
|
12153
|
+
* Use this to call the ThoughtSpot APIs when using the visual embed sdk.
|
|
12154
|
+
*
|
|
12155
|
+
* @param input
|
|
12156
|
+
* @param init
|
|
12157
|
+
* @version SDK: 1.28.0
|
|
12158
|
+
* @group Global methods
|
|
12159
|
+
*/
|
|
12160
|
+
const tokenizedFetch = async (input, init) => {
|
|
12161
|
+
const embedConfig = getEmbedConfig();
|
|
12162
|
+
if (embedConfig.authType !== AuthType.TrustedAuthTokenCookieless) {
|
|
12163
|
+
return fetch(input, init);
|
|
12164
|
+
}
|
|
12165
|
+
const req = new Request(input, init);
|
|
12166
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12167
|
+
if (authToken) {
|
|
12168
|
+
req.headers.append('Authorization', `Bearer ${authToken}`);
|
|
12169
|
+
}
|
|
12170
|
+
return fetch(req);
|
|
12171
|
+
};
|
|
12603
12172
|
|
|
12604
|
-
|
|
12605
|
-
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12613
|
-
|
|
12614
|
-
|
|
12615
|
-
|
|
12616
|
-
|
|
12617
|
-
|
|
12618
|
-
|
|
12619
|
-
|
|
12620
|
-
|
|
12621
|
-
|
|
12622
|
-
|
|
12623
|
-
|
|
12624
|
-
|
|
12625
|
-
|
|
12626
|
-
|
|
12627
|
-
* @constructor
|
|
12628
|
-
* @private
|
|
12629
|
-
*/
|
|
12630
|
-
function EE(fn, context, once) {
|
|
12631
|
-
this.fn = fn;
|
|
12632
|
-
this.context = context;
|
|
12633
|
-
this.once = once || false;
|
|
12634
|
-
}
|
|
12635
|
-
|
|
12636
|
-
/**
|
|
12637
|
-
* Add a listener for a given event.
|
|
12638
|
-
*
|
|
12639
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
12640
|
-
* @param {(String|Symbol)} event The event name.
|
|
12641
|
-
* @param {Function} fn The listener function.
|
|
12642
|
-
* @param {*} context The context to invoke the listener with.
|
|
12643
|
-
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
12644
|
-
* @returns {EventEmitter}
|
|
12645
|
-
* @private
|
|
12646
|
-
*/
|
|
12647
|
-
function addListener(emitter, event, fn, context, once) {
|
|
12648
|
-
if (typeof fn !== 'function') {
|
|
12649
|
-
throw new TypeError('The listener must be a function');
|
|
12650
|
-
}
|
|
12651
|
-
|
|
12652
|
-
var listener = new EE(fn, context || emitter, once)
|
|
12653
|
-
, evt = prefix ? prefix + event : event;
|
|
12654
|
-
|
|
12655
|
-
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
12656
|
-
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
12657
|
-
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
12658
|
-
|
|
12659
|
-
return emitter;
|
|
12660
|
-
}
|
|
12661
|
-
|
|
12662
|
-
/**
|
|
12663
|
-
* Clear event by name.
|
|
12664
|
-
*
|
|
12665
|
-
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
12666
|
-
* @param {(String|Symbol)} evt The Event name.
|
|
12667
|
-
* @private
|
|
12668
|
-
*/
|
|
12669
|
-
function clearEvent(emitter, evt) {
|
|
12670
|
-
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
12671
|
-
else delete emitter._events[evt];
|
|
12672
|
-
}
|
|
12673
|
-
|
|
12674
|
-
/**
|
|
12675
|
-
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
12676
|
-
* `EventEmitter` interface.
|
|
12677
|
-
*
|
|
12678
|
-
* @constructor
|
|
12679
|
-
* @public
|
|
12680
|
-
*/
|
|
12681
|
-
function EventEmitter() {
|
|
12682
|
-
this._events = new Events();
|
|
12683
|
-
this._eventsCount = 0;
|
|
12684
|
-
}
|
|
12685
|
-
|
|
12686
|
-
/**
|
|
12687
|
-
* Return an array listing the events for which the emitter has registered
|
|
12688
|
-
* listeners.
|
|
12689
|
-
*
|
|
12690
|
-
* @returns {Array}
|
|
12691
|
-
* @public
|
|
12692
|
-
*/
|
|
12693
|
-
EventEmitter.prototype.eventNames = function eventNames() {
|
|
12694
|
-
var names = []
|
|
12695
|
-
, events
|
|
12696
|
-
, name;
|
|
12697
|
-
|
|
12698
|
-
if (this._eventsCount === 0) return names;
|
|
12699
|
-
|
|
12700
|
-
for (name in (events = this._events)) {
|
|
12701
|
-
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
12702
|
-
}
|
|
12703
|
-
|
|
12704
|
-
if (Object.getOwnPropertySymbols) {
|
|
12705
|
-
return names.concat(Object.getOwnPropertySymbols(events));
|
|
12706
|
-
}
|
|
12707
|
-
|
|
12708
|
-
return names;
|
|
12709
|
-
};
|
|
12710
|
-
|
|
12711
|
-
/**
|
|
12712
|
-
* Return the listeners registered for a given event.
|
|
12713
|
-
*
|
|
12714
|
-
* @param {(String|Symbol)} event The event name.
|
|
12715
|
-
* @returns {Array} The registered listeners.
|
|
12716
|
-
* @public
|
|
12717
|
-
*/
|
|
12718
|
-
EventEmitter.prototype.listeners = function listeners(event) {
|
|
12719
|
-
var evt = prefix ? prefix + event : event
|
|
12720
|
-
, handlers = this._events[evt];
|
|
12721
|
-
|
|
12722
|
-
if (!handlers) return [];
|
|
12723
|
-
if (handlers.fn) return [handlers.fn];
|
|
12724
|
-
|
|
12725
|
-
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
12726
|
-
ee[i] = handlers[i].fn;
|
|
12727
|
-
}
|
|
12728
|
-
|
|
12729
|
-
return ee;
|
|
12730
|
-
};
|
|
12731
|
-
|
|
12732
|
-
/**
|
|
12733
|
-
* Return the number of listeners listening to a given event.
|
|
12734
|
-
*
|
|
12735
|
-
* @param {(String|Symbol)} event The event name.
|
|
12736
|
-
* @returns {Number} The number of listeners.
|
|
12737
|
-
* @public
|
|
12738
|
-
*/
|
|
12739
|
-
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
12740
|
-
var evt = prefix ? prefix + event : event
|
|
12741
|
-
, listeners = this._events[evt];
|
|
12742
|
-
|
|
12743
|
-
if (!listeners) return 0;
|
|
12744
|
-
if (listeners.fn) return 1;
|
|
12745
|
-
return listeners.length;
|
|
12746
|
-
};
|
|
12747
|
-
|
|
12748
|
-
/**
|
|
12749
|
-
* Calls each of the listeners registered for a given event.
|
|
12750
|
-
*
|
|
12751
|
-
* @param {(String|Symbol)} event The event name.
|
|
12752
|
-
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
12753
|
-
* @public
|
|
12754
|
-
*/
|
|
12755
|
-
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
12756
|
-
var evt = prefix ? prefix + event : event;
|
|
12757
|
-
|
|
12758
|
-
if (!this._events[evt]) return false;
|
|
12759
|
-
|
|
12760
|
-
var listeners = this._events[evt]
|
|
12761
|
-
, len = arguments.length
|
|
12762
|
-
, args
|
|
12763
|
-
, i;
|
|
12764
|
-
|
|
12765
|
-
if (listeners.fn) {
|
|
12766
|
-
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
12767
|
-
|
|
12768
|
-
switch (len) {
|
|
12769
|
-
case 1: return listeners.fn.call(listeners.context), true;
|
|
12770
|
-
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
12771
|
-
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
12772
|
-
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
12773
|
-
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
12774
|
-
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
12775
|
-
}
|
|
12776
|
-
|
|
12777
|
-
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
12778
|
-
args[i - 1] = arguments[i];
|
|
12779
|
-
}
|
|
12780
|
-
|
|
12781
|
-
listeners.fn.apply(listeners.context, args);
|
|
12782
|
-
} else {
|
|
12783
|
-
var length = listeners.length
|
|
12784
|
-
, j;
|
|
12785
|
-
|
|
12786
|
-
for (i = 0; i < length; i++) {
|
|
12787
|
-
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
12788
|
-
|
|
12789
|
-
switch (len) {
|
|
12790
|
-
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
12791
|
-
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
12792
|
-
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
12793
|
-
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
12794
|
-
default:
|
|
12795
|
-
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
12796
|
-
args[j - 1] = arguments[j];
|
|
12797
|
-
}
|
|
12798
|
-
|
|
12799
|
-
listeners[i].fn.apply(listeners[i].context, args);
|
|
12800
|
-
}
|
|
12801
|
-
}
|
|
12802
|
-
}
|
|
12803
|
-
|
|
12804
|
-
return true;
|
|
12805
|
-
};
|
|
12806
|
-
|
|
12807
|
-
/**
|
|
12808
|
-
* Add a listener for a given event.
|
|
12809
|
-
*
|
|
12810
|
-
* @param {(String|Symbol)} event The event name.
|
|
12811
|
-
* @param {Function} fn The listener function.
|
|
12812
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
12813
|
-
* @returns {EventEmitter} `this`.
|
|
12814
|
-
* @public
|
|
12815
|
-
*/
|
|
12816
|
-
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
12817
|
-
return addListener(this, event, fn, context, false);
|
|
12818
|
-
};
|
|
12819
|
-
|
|
12820
|
-
/**
|
|
12821
|
-
* Add a one-time listener for a given event.
|
|
12822
|
-
*
|
|
12823
|
-
* @param {(String|Symbol)} event The event name.
|
|
12824
|
-
* @param {Function} fn The listener function.
|
|
12825
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
12826
|
-
* @returns {EventEmitter} `this`.
|
|
12827
|
-
* @public
|
|
12828
|
-
*/
|
|
12829
|
-
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
12830
|
-
return addListener(this, event, fn, context, true);
|
|
12831
|
-
};
|
|
12832
|
-
|
|
12833
|
-
/**
|
|
12834
|
-
* Remove the listeners of a given event.
|
|
12835
|
-
*
|
|
12836
|
-
* @param {(String|Symbol)} event The event name.
|
|
12837
|
-
* @param {Function} fn Only remove the listeners that match this function.
|
|
12838
|
-
* @param {*} context Only remove the listeners that have this context.
|
|
12839
|
-
* @param {Boolean} once Only remove one-time listeners.
|
|
12840
|
-
* @returns {EventEmitter} `this`.
|
|
12841
|
-
* @public
|
|
12842
|
-
*/
|
|
12843
|
-
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
12844
|
-
var evt = prefix ? prefix + event : event;
|
|
12845
|
-
|
|
12846
|
-
if (!this._events[evt]) return this;
|
|
12847
|
-
if (!fn) {
|
|
12848
|
-
clearEvent(this, evt);
|
|
12849
|
-
return this;
|
|
12850
|
-
}
|
|
12851
|
-
|
|
12852
|
-
var listeners = this._events[evt];
|
|
12853
|
-
|
|
12854
|
-
if (listeners.fn) {
|
|
12855
|
-
if (
|
|
12856
|
-
listeners.fn === fn &&
|
|
12857
|
-
(!once || listeners.once) &&
|
|
12858
|
-
(!context || listeners.context === context)
|
|
12859
|
-
) {
|
|
12860
|
-
clearEvent(this, evt);
|
|
12861
|
-
}
|
|
12862
|
-
} else {
|
|
12863
|
-
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
12864
|
-
if (
|
|
12865
|
-
listeners[i].fn !== fn ||
|
|
12866
|
-
(once && !listeners[i].once) ||
|
|
12867
|
-
(context && listeners[i].context !== context)
|
|
12868
|
-
) {
|
|
12869
|
-
events.push(listeners[i]);
|
|
12870
|
-
}
|
|
12871
|
-
}
|
|
12872
|
-
|
|
12873
|
-
//
|
|
12874
|
-
// Reset the array, or remove it completely if we have no more listeners.
|
|
12875
|
-
//
|
|
12876
|
-
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
12877
|
-
else clearEvent(this, evt);
|
|
12878
|
-
}
|
|
12879
|
-
|
|
12880
|
-
return this;
|
|
12881
|
-
};
|
|
12882
|
-
|
|
12883
|
-
/**
|
|
12884
|
-
* Remove all listeners, or those of the specified event.
|
|
12885
|
-
*
|
|
12886
|
-
* @param {(String|Symbol)} [event] The event name.
|
|
12887
|
-
* @returns {EventEmitter} `this`.
|
|
12888
|
-
* @public
|
|
12889
|
-
*/
|
|
12890
|
-
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
12891
|
-
var evt;
|
|
12892
|
-
|
|
12893
|
-
if (event) {
|
|
12894
|
-
evt = prefix ? prefix + event : event;
|
|
12895
|
-
if (this._events[evt]) clearEvent(this, evt);
|
|
12896
|
-
} else {
|
|
12897
|
-
this._events = new Events();
|
|
12898
|
-
this._eventsCount = 0;
|
|
12899
|
-
}
|
|
12900
|
-
|
|
12901
|
-
return this;
|
|
12902
|
-
};
|
|
12903
|
-
|
|
12904
|
-
//
|
|
12905
|
-
// Alias methods names because people roll like that.
|
|
12906
|
-
//
|
|
12907
|
-
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
12908
|
-
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
12909
|
-
|
|
12910
|
-
//
|
|
12911
|
-
// Expose the prefix.
|
|
12912
|
-
//
|
|
12913
|
-
EventEmitter.prefixed = prefix;
|
|
12914
|
-
|
|
12915
|
-
//
|
|
12916
|
-
// Allow `EventEmitter` to be imported as module namespace.
|
|
12917
|
-
//
|
|
12918
|
-
EventEmitter.EventEmitter = EventEmitter;
|
|
12919
|
-
|
|
12920
|
-
//
|
|
12921
|
-
// Expose the module.
|
|
12922
|
-
//
|
|
12923
|
-
{
|
|
12924
|
-
module.exports = EventEmitter;
|
|
12925
|
-
}
|
|
12926
|
-
});
|
|
12927
|
-
|
|
12928
|
-
/** Used as references for various `Number` constants. */
|
|
12929
|
-
var INFINITY = 1 / 0;
|
|
12930
|
-
|
|
12931
|
-
/**
|
|
12932
|
-
* Creates a set object of `values`.
|
|
12933
|
-
*
|
|
12934
|
-
* @private
|
|
12935
|
-
* @param {Array} values The values to add to the set.
|
|
12936
|
-
* @returns {Object} Returns the new set.
|
|
12937
|
-
*/
|
|
12938
|
-
var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY) ? noop_1 : function(values) {
|
|
12939
|
-
return new _Set(values);
|
|
12940
|
-
};
|
|
12173
|
+
/**
|
|
12174
|
+
*
|
|
12175
|
+
* @param url
|
|
12176
|
+
* @param options
|
|
12177
|
+
*/
|
|
12178
|
+
function tokenisedFailureLoggedFetch(url, options = {}) {
|
|
12179
|
+
return tokenizedFetch(url, options).then(async (r) => {
|
|
12180
|
+
var _a;
|
|
12181
|
+
if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
|
|
12182
|
+
logger.error('Failure', await ((_a = r.text) === null || _a === void 0 ? void 0 : _a.call(r)));
|
|
12183
|
+
}
|
|
12184
|
+
return r;
|
|
12185
|
+
});
|
|
12186
|
+
}
|
|
12187
|
+
/**
|
|
12188
|
+
*
|
|
12189
|
+
* @param authVerificationUrl
|
|
12190
|
+
*/
|
|
12191
|
+
function fetchSessionInfoService(authVerificationUrl) {
|
|
12192
|
+
return tokenisedFailureLoggedFetch(authVerificationUrl, {
|
|
12193
|
+
credentials: 'include',
|
|
12194
|
+
});
|
|
12195
|
+
}
|
|
12941
12196
|
|
|
12197
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12198
|
+
let loggedInStatus = false;
|
|
12199
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12200
|
+
let samlAuthWindow = null;
|
|
12201
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
12202
|
+
let samlCompletionPromise = null;
|
|
12203
|
+
let sessionInfo = null;
|
|
12204
|
+
let sessionInfoResolver = null;
|
|
12205
|
+
const sessionInfoPromise = new Promise((resolve) => {
|
|
12206
|
+
sessionInfoResolver = resolve;
|
|
12207
|
+
});
|
|
12208
|
+
let releaseVersion = '';
|
|
12209
|
+
const SSO_REDIRECTION_MARKER_GUID = '5e16222e-ef02-43e9-9fbd-24226bf3ce5b';
|
|
12210
|
+
/**
|
|
12211
|
+
* Enum for auth failure types. This is the parameter passed to the listner
|
|
12212
|
+
* of {@link AuthStatus.FAILURE}.
|
|
12213
|
+
*
|
|
12214
|
+
* @group Authentication / Init
|
|
12215
|
+
*/
|
|
12216
|
+
var AuthFailureType;
|
|
12217
|
+
(function (AuthFailureType) {
|
|
12218
|
+
AuthFailureType["SDK"] = "SDK";
|
|
12219
|
+
AuthFailureType["NO_COOKIE_ACCESS"] = "NO_COOKIE_ACCESS";
|
|
12220
|
+
AuthFailureType["EXPIRY"] = "EXPIRY";
|
|
12221
|
+
AuthFailureType["OTHER"] = "OTHER";
|
|
12222
|
+
})(AuthFailureType || (AuthFailureType = {}));
|
|
12223
|
+
/**
|
|
12224
|
+
* Enum for auth status emitted by the emitter returned from {@link init}.
|
|
12225
|
+
*
|
|
12226
|
+
* @group Authentication / Init
|
|
12227
|
+
*/
|
|
12228
|
+
var AuthStatus;
|
|
12229
|
+
(function (AuthStatus) {
|
|
12230
|
+
/**
|
|
12231
|
+
* Emits when the SDK fails to authenticate
|
|
12232
|
+
*/
|
|
12233
|
+
AuthStatus["FAILURE"] = "FAILURE";
|
|
12234
|
+
/**
|
|
12235
|
+
* Emits when the SDK authenticates successfully
|
|
12236
|
+
*/
|
|
12237
|
+
AuthStatus["SDK_SUCCESS"] = "SDK_SUCCESS";
|
|
12238
|
+
/**
|
|
12239
|
+
* Emits when the app sends an authentication success message
|
|
12240
|
+
*/
|
|
12241
|
+
AuthStatus["SUCCESS"] = "SUCCESS";
|
|
12242
|
+
/**
|
|
12243
|
+
* Emits when a user logs out
|
|
12244
|
+
*/
|
|
12245
|
+
AuthStatus["LOGOUT"] = "LOGOUT";
|
|
12246
|
+
/**
|
|
12247
|
+
* Emitted when inPopup is true in the SAMLRedirect flow and the
|
|
12248
|
+
* popup is waiting to be triggered either programmatically
|
|
12249
|
+
* or by the trigger button.
|
|
12250
|
+
*
|
|
12251
|
+
* @version SDK: 1.19.0
|
|
12252
|
+
*/
|
|
12253
|
+
AuthStatus["WAITING_FOR_POPUP"] = "WAITING_FOR_POPUP";
|
|
12254
|
+
})(AuthStatus || (AuthStatus = {}));
|
|
12255
|
+
/**
|
|
12256
|
+
* Events which can be triggered on the emitter returned from {@link init}.
|
|
12257
|
+
*
|
|
12258
|
+
* @group Authentication / Init
|
|
12259
|
+
*/
|
|
12260
|
+
var AuthEvent;
|
|
12261
|
+
(function (AuthEvent) {
|
|
12262
|
+
/**
|
|
12263
|
+
* Manually trigger the SSO popup. This is useful when
|
|
12264
|
+
* authStatus is SAMLRedirect/OIDCRedirect and inPopup is set to true
|
|
12265
|
+
*/
|
|
12266
|
+
AuthEvent["TRIGGER_SSO_POPUP"] = "TRIGGER_SSO_POPUP";
|
|
12267
|
+
})(AuthEvent || (AuthEvent = {}));
|
|
12268
|
+
/**
|
|
12269
|
+
*
|
|
12270
|
+
*/
|
|
12271
|
+
function notifyAuthSDKSuccess() {
|
|
12272
|
+
{
|
|
12273
|
+
logger.error('SDK not initialized');
|
|
12274
|
+
return;
|
|
12275
|
+
}
|
|
12276
|
+
}
|
|
12277
|
+
/**
|
|
12278
|
+
*
|
|
12279
|
+
*/
|
|
12280
|
+
function notifyAuthSuccess() {
|
|
12281
|
+
{
|
|
12282
|
+
logger.error('SDK not initialized');
|
|
12283
|
+
return;
|
|
12284
|
+
}
|
|
12285
|
+
}
|
|
12286
|
+
/**
|
|
12287
|
+
*
|
|
12288
|
+
* @param failureType
|
|
12289
|
+
*/
|
|
12290
|
+
function notifyAuthFailure(failureType) {
|
|
12291
|
+
{
|
|
12292
|
+
logger.error('SDK not initialized');
|
|
12293
|
+
return;
|
|
12294
|
+
}
|
|
12295
|
+
}
|
|
12296
|
+
/**
|
|
12297
|
+
*
|
|
12298
|
+
*/
|
|
12299
|
+
function notifyLogout() {
|
|
12300
|
+
{
|
|
12301
|
+
logger.error('SDK not initialized');
|
|
12302
|
+
return;
|
|
12303
|
+
}
|
|
12304
|
+
}
|
|
12305
|
+
const initSession = (sessionDetails) => {
|
|
12306
|
+
const embedConfig = getEmbedConfig();
|
|
12307
|
+
if (sessionInfo == null) {
|
|
12308
|
+
sessionInfo = sessionDetails;
|
|
12309
|
+
if (!embedConfig.disableSDKTracking) {
|
|
12310
|
+
initMixpanel(sessionInfo);
|
|
12311
|
+
}
|
|
12312
|
+
sessionInfoResolver(sessionInfo);
|
|
12313
|
+
}
|
|
12314
|
+
};
|
|
12315
|
+
const getSessionDetails = (sessionInfoResp) => {
|
|
12316
|
+
const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
|
|
12317
|
+
const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
|
|
12318
|
+
const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
|
|
12319
|
+
? prodMixpanelToken
|
|
12320
|
+
: devMixpanelToken;
|
|
12321
|
+
return {
|
|
12322
|
+
userGUID: sessionInfoResp.userGUID,
|
|
12323
|
+
mixpanelToken,
|
|
12324
|
+
isPublicUser: sessionInfoResp.configInfo.isPublicUser,
|
|
12325
|
+
releaseVersion: sessionInfoResp.releaseVersion,
|
|
12326
|
+
clusterId: sessionInfoResp.configInfo.selfClusterId,
|
|
12327
|
+
clusterName: sessionInfoResp.configInfo.selfClusterName,
|
|
12328
|
+
...sessionInfoResp,
|
|
12329
|
+
};
|
|
12330
|
+
};
|
|
12331
|
+
/**
|
|
12332
|
+
* Check if we are logged into the ThoughtSpot cluster
|
|
12333
|
+
*
|
|
12334
|
+
* @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
|
|
12335
|
+
*/
|
|
12336
|
+
async function isLoggedIn(thoughtSpotHost) {
|
|
12337
|
+
const authVerificationUrl = `${thoughtSpotHost}${EndPoints.AUTH_VERIFICATION}`;
|
|
12338
|
+
let response = null;
|
|
12339
|
+
try {
|
|
12340
|
+
response = await fetchSessionInfoService(authVerificationUrl);
|
|
12341
|
+
const sessionInfoResp = await response.json();
|
|
12342
|
+
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
12343
|
+
// Store user session details from session info
|
|
12344
|
+
initSession(sessionDetails);
|
|
12345
|
+
releaseVersion = sessionInfoResp.releaseVersion;
|
|
12346
|
+
}
|
|
12347
|
+
catch (e) {
|
|
12348
|
+
return false;
|
|
12349
|
+
}
|
|
12350
|
+
return response.status === 200;
|
|
12351
|
+
}
|
|
12352
|
+
/**
|
|
12353
|
+
* Return releaseVersion if available
|
|
12354
|
+
*/
|
|
12355
|
+
function getReleaseVersion() {
|
|
12356
|
+
return releaseVersion;
|
|
12357
|
+
}
|
|
12358
|
+
/**
|
|
12359
|
+
* Check if we are stuck at the SSO redirect URL
|
|
12360
|
+
*/
|
|
12361
|
+
function isAtSSORedirectUrl() {
|
|
12362
|
+
return window.location.href.indexOf(SSO_REDIRECTION_MARKER_GUID) >= 0;
|
|
12363
|
+
}
|
|
12942
12364
|
/**
|
|
12365
|
+
* Remove the SSO redirect URL marker
|
|
12366
|
+
*/
|
|
12367
|
+
function removeSSORedirectUrlMarker() {
|
|
12368
|
+
// Note (sunny): This will leave a # around even if it was not in the URL
|
|
12369
|
+
// to begin with. Trying to remove the hash by changing window.location will
|
|
12370
|
+
// reload the page which we don't want. We'll live with adding an
|
|
12371
|
+
// unnecessary hash to the parent page URL until we find any use case where
|
|
12372
|
+
// that creates an issue.
|
|
12373
|
+
window.location.hash = window.location.hash.replace(SSO_REDIRECTION_MARKER_GUID, '');
|
|
12374
|
+
}
|
|
12375
|
+
/**
|
|
12376
|
+
* Perform token based authentication
|
|
12377
|
+
*
|
|
12378
|
+
* @param embedConfig The embed configuration
|
|
12379
|
+
*/
|
|
12380
|
+
const doTokenAuth = async (embedConfig) => {
|
|
12381
|
+
const { thoughtSpotHost, username, authEndpoint, getAuthToken, } = embedConfig;
|
|
12382
|
+
if (!authEndpoint && !getAuthToken) {
|
|
12383
|
+
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12384
|
+
}
|
|
12385
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12386
|
+
if (!loggedInStatus) {
|
|
12387
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12388
|
+
let resp;
|
|
12389
|
+
try {
|
|
12390
|
+
resp = await fetchAuthPostService(thoughtSpotHost, username, authToken);
|
|
12391
|
+
}
|
|
12392
|
+
catch (e) {
|
|
12393
|
+
resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
12394
|
+
}
|
|
12395
|
+
// token login issues a 302 when successful
|
|
12396
|
+
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
12397
|
+
if (loggedInStatus && embedConfig.detectCookieAccessSlow) {
|
|
12398
|
+
// When 3rd party cookie access is blocked, this will fail because
|
|
12399
|
+
// cookies will not be sent with the call.
|
|
12400
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12401
|
+
}
|
|
12402
|
+
}
|
|
12403
|
+
return loggedInStatus;
|
|
12404
|
+
};
|
|
12405
|
+
/**
|
|
12406
|
+
* Validate embedConfig parameters required for cookielessTokenAuth
|
|
12407
|
+
*
|
|
12408
|
+
* @param embedConfig The embed configuration
|
|
12409
|
+
*/
|
|
12410
|
+
const doCookielessTokenAuth = async (embedConfig) => {
|
|
12411
|
+
const { authEndpoint, getAuthToken } = embedConfig;
|
|
12412
|
+
if (!authEndpoint && !getAuthToken) {
|
|
12413
|
+
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12414
|
+
}
|
|
12415
|
+
let authSuccess = false;
|
|
12416
|
+
try {
|
|
12417
|
+
const authToken = await getAuthenticationToken(embedConfig);
|
|
12418
|
+
if (authToken) {
|
|
12419
|
+
authSuccess = true;
|
|
12420
|
+
}
|
|
12421
|
+
}
|
|
12422
|
+
catch {
|
|
12423
|
+
authSuccess = false;
|
|
12424
|
+
}
|
|
12425
|
+
return authSuccess;
|
|
12426
|
+
};
|
|
12427
|
+
/**
|
|
12428
|
+
* Perform basic authentication to the ThoughtSpot cluster using the cluster
|
|
12429
|
+
* credentials.
|
|
12943
12430
|
*
|
|
12944
|
-
*
|
|
12945
|
-
*
|
|
12431
|
+
* Warning: This feature is primarily intended for developer testing. It is
|
|
12432
|
+
* strongly advised not to use this authentication method in production.
|
|
12433
|
+
*
|
|
12434
|
+
* @param embedConfig The embed configuration
|
|
12946
12435
|
*/
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12436
|
+
const doBasicAuth = async (embedConfig) => {
|
|
12437
|
+
const { thoughtSpotHost, username, password } = embedConfig;
|
|
12438
|
+
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
12439
|
+
if (!loggedIn) {
|
|
12440
|
+
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
12441
|
+
loggedInStatus = response.ok;
|
|
12442
|
+
if (embedConfig.detectCookieAccessSlow) {
|
|
12443
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12952
12444
|
}
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12445
|
+
}
|
|
12446
|
+
else {
|
|
12447
|
+
loggedInStatus = true;
|
|
12448
|
+
}
|
|
12449
|
+
return loggedInStatus;
|
|
12450
|
+
};
|
|
12956
12451
|
/**
|
|
12957
12452
|
*
|
|
12958
|
-
* @param
|
|
12453
|
+
* @param ssoURL
|
|
12454
|
+
* @param triggerContainer
|
|
12455
|
+
* @param triggerText
|
|
12959
12456
|
*/
|
|
12960
|
-
function
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
}
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12457
|
+
async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
|
|
12458
|
+
const openPopup = () => {
|
|
12459
|
+
if (samlAuthWindow === null || samlAuthWindow.closed) {
|
|
12460
|
+
samlAuthWindow = window.open(ssoURL, '_blank', 'location=no,height=570,width=520,scrollbars=yes,status=yes');
|
|
12461
|
+
}
|
|
12462
|
+
else {
|
|
12463
|
+
samlAuthWindow.focus();
|
|
12464
|
+
}
|
|
12465
|
+
};
|
|
12466
|
+
const containerEl = getDOMNode(triggerContainer);
|
|
12467
|
+
if (containerEl) {
|
|
12468
|
+
containerEl.innerHTML = '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
|
|
12469
|
+
const authElem = document.getElementById('ts-auth-btn');
|
|
12470
|
+
authElem.textContent = triggerText;
|
|
12471
|
+
authElem.addEventListener('click', openPopup, { once: true });
|
|
12472
|
+
}
|
|
12473
|
+
samlCompletionPromise = samlCompletionPromise
|
|
12474
|
+
|| new Promise((resolve, reject) => {
|
|
12475
|
+
window.addEventListener('message', (e) => {
|
|
12476
|
+
if (e.data.type === EmbedEvent.SAMLComplete) {
|
|
12477
|
+
e.source.close();
|
|
12478
|
+
resolve();
|
|
12479
|
+
}
|
|
12480
|
+
});
|
|
12481
|
+
});
|
|
12482
|
+
return samlCompletionPromise;
|
|
12483
|
+
}
|
|
12979
12484
|
/**
|
|
12980
|
-
*
|
|
12981
|
-
* of {@link AuthStatus.FAILURE}.
|
|
12485
|
+
* Perform SAML authentication
|
|
12982
12486
|
*
|
|
12983
|
-
* @
|
|
12487
|
+
* @param embedConfig The embed configuration
|
|
12488
|
+
* @param ssoEndPoint
|
|
12984
12489
|
*/
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
}
|
|
12490
|
+
const doSSOAuth = async (embedConfig, ssoEndPoint) => {
|
|
12491
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12492
|
+
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
12493
|
+
if (loggedIn) {
|
|
12494
|
+
if (isAtSSORedirectUrl()) {
|
|
12495
|
+
removeSSORedirectUrlMarker();
|
|
12496
|
+
}
|
|
12497
|
+
loggedInStatus = true;
|
|
12498
|
+
return;
|
|
12499
|
+
}
|
|
12500
|
+
// we have already tried authentication and it did not succeed, restore
|
|
12501
|
+
// the current URL to the original one and invoke the callback.
|
|
12502
|
+
if (isAtSSORedirectUrl()) {
|
|
12503
|
+
removeSSORedirectUrlMarker();
|
|
12504
|
+
loggedInStatus = false;
|
|
12505
|
+
return;
|
|
12506
|
+
}
|
|
12507
|
+
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
12508
|
+
if (embedConfig.inPopup) {
|
|
12509
|
+
await samlPopupFlow(ssoURL, embedConfig.authTriggerContainer, embedConfig.authTriggerText);
|
|
12510
|
+
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
12511
|
+
return;
|
|
12512
|
+
}
|
|
12513
|
+
window.location.href = ssoURL;
|
|
12514
|
+
};
|
|
12515
|
+
const doSamlAuth = async (embedConfig) => {
|
|
12516
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12517
|
+
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
12518
|
+
// loaded again and the same JS will execute again.
|
|
12519
|
+
const ssoRedirectUrl = embedConfig.inPopup
|
|
12520
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
12521
|
+
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
12522
|
+
// bring back the page to the same URL
|
|
12523
|
+
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
12524
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
12525
|
+
return loggedInStatus;
|
|
12526
|
+
};
|
|
12527
|
+
const doOIDCAuth = async (embedConfig) => {
|
|
12528
|
+
const { thoughtSpotHost } = embedConfig;
|
|
12529
|
+
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
12530
|
+
// loaded again and the same JS will execute again.
|
|
12531
|
+
const ssoRedirectUrl = embedConfig.noRedirect || embedConfig.inPopup
|
|
12532
|
+
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
12533
|
+
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
12534
|
+
// bring back the page to the same URL
|
|
12535
|
+
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
12536
|
+
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
12537
|
+
return loggedInStatus;
|
|
12538
|
+
};
|
|
12992
12539
|
/**
|
|
12993
|
-
*
|
|
12540
|
+
* Perform authentication on the ThoughtSpot cluster
|
|
12994
12541
|
*
|
|
12995
|
-
* @
|
|
12542
|
+
* @param embedConfig The embed configuration
|
|
12996
12543
|
*/
|
|
12997
|
-
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
|
|
13002
|
-
|
|
13003
|
-
|
|
13004
|
-
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
12544
|
+
const authenticate = async (embedConfig) => {
|
|
12545
|
+
const { authType } = embedConfig;
|
|
12546
|
+
switch (authType) {
|
|
12547
|
+
case AuthType.SSO:
|
|
12548
|
+
case AuthType.SAMLRedirect:
|
|
12549
|
+
case AuthType.SAML:
|
|
12550
|
+
return doSamlAuth(embedConfig);
|
|
12551
|
+
case AuthType.OIDC:
|
|
12552
|
+
case AuthType.OIDCRedirect:
|
|
12553
|
+
return doOIDCAuth(embedConfig);
|
|
12554
|
+
case AuthType.AuthServer:
|
|
12555
|
+
case AuthType.TrustedAuthToken:
|
|
12556
|
+
return doTokenAuth(embedConfig);
|
|
12557
|
+
case AuthType.TrustedAuthTokenCookieless:
|
|
12558
|
+
return doCookielessTokenAuth(embedConfig);
|
|
12559
|
+
case AuthType.Basic:
|
|
12560
|
+
return doBasicAuth(embedConfig);
|
|
12561
|
+
default:
|
|
12562
|
+
return Promise.resolve(true);
|
|
12563
|
+
}
|
|
12564
|
+
};
|
|
12565
|
+
|
|
12566
|
+
const ERROR_MESSAGE = {
|
|
12567
|
+
INVALID_THOUGHTSPOT_HOST: 'Error parsing ThoughtSpot host. Please provide a valid URL.',
|
|
12568
|
+
LIVEBOARD_VIZ_ID_VALIDATION: 'Please provide either liveboardId or pinboardId',
|
|
12569
|
+
TRIGGER_TIMED_OUT: 'Trigger timedout in getting response',
|
|
12570
|
+
SEARCHEMBED_BETA_WRANING_MESSAGE: 'Search Embed is in Beta in this release.',
|
|
12571
|
+
SAGE_EMBED_BETA_WARNING_MESSAGE: 'Sage Embed is in Beta in this release.',
|
|
12572
|
+
};
|
|
12573
|
+
|
|
13024
12574
|
/**
|
|
13025
|
-
*
|
|
12575
|
+
* Copyright (c) 2023
|
|
13026
12576
|
*
|
|
13027
|
-
*
|
|
12577
|
+
* Utilities related to reading configuration objects
|
|
12578
|
+
*
|
|
12579
|
+
* @summary Config-related utils
|
|
12580
|
+
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
13028
12581
|
*/
|
|
13029
|
-
|
|
13030
|
-
(
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
})(AuthEvent || (AuthEvent = {}));
|
|
12582
|
+
const urlRegex = new RegExp([
|
|
12583
|
+
'(^(https?:)//)?',
|
|
12584
|
+
'(([^:/?#]*)(?::([0-9]+))?)',
|
|
12585
|
+
'(/{0,1}[^?#]*)',
|
|
12586
|
+
'(\\?[^#]*|)',
|
|
12587
|
+
'(#.*|)$', // hash
|
|
12588
|
+
].join(''));
|
|
13037
12589
|
/**
|
|
12590
|
+
* Parse and construct the ThoughtSpot hostname or IP address
|
|
12591
|
+
* from the embed configuration object.
|
|
13038
12592
|
*
|
|
12593
|
+
* @param config
|
|
13039
12594
|
*/
|
|
13040
|
-
|
|
13041
|
-
{
|
|
13042
|
-
|
|
13043
|
-
|
|
12595
|
+
const getThoughtSpotHost = (config) => {
|
|
12596
|
+
if (!config.thoughtSpotHost) {
|
|
12597
|
+
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
12598
|
+
}
|
|
12599
|
+
const urlParts = config.thoughtSpotHost.match(urlRegex);
|
|
12600
|
+
if (!urlParts) {
|
|
12601
|
+
throw new Error(ERROR_MESSAGE.INVALID_THOUGHTSPOT_HOST);
|
|
12602
|
+
}
|
|
12603
|
+
const protocol = urlParts[2] || window.location.protocol;
|
|
12604
|
+
const host = urlParts[3];
|
|
12605
|
+
let path = urlParts[6];
|
|
12606
|
+
// Lose the trailing / if any
|
|
12607
|
+
if (path.charAt(path.length - 1) === '/') {
|
|
12608
|
+
path = path.substring(0, path.length - 1);
|
|
12609
|
+
}
|
|
12610
|
+
// const urlParams = urlParts[7];
|
|
12611
|
+
// const hash = urlParts[8];
|
|
12612
|
+
return `${protocol}//${host}${path}`;
|
|
12613
|
+
};
|
|
12614
|
+
const getV2BasePath = (config) => {
|
|
12615
|
+
if (config.basepath) {
|
|
12616
|
+
return config.basepath;
|
|
12617
|
+
}
|
|
12618
|
+
const tsHost = getThoughtSpotHost(config);
|
|
12619
|
+
// This is to handle when e2e's. Search is run on pods for
|
|
12620
|
+
// comp-blink-test-pipeline with baseUrl=https://localhost:8443.
|
|
12621
|
+
// This is to handle when the developer is developing in their local
|
|
12622
|
+
// environment.
|
|
12623
|
+
if (tsHost.includes('://localhost') && !tsHost.includes(':8443')) {
|
|
12624
|
+
return '';
|
|
13044
12625
|
}
|
|
13045
|
-
|
|
12626
|
+
return 'v2';
|
|
12627
|
+
};
|
|
13046
12628
|
/**
|
|
13047
|
-
*
|
|
12629
|
+
* It is a good idea to keep URLs under 2000 chars.
|
|
12630
|
+
* If this is ever breached, since we pass view configuration through
|
|
12631
|
+
* URL params, we would like to log a warning.
|
|
12632
|
+
* Reference: https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
|
|
13048
12633
|
*/
|
|
13049
|
-
|
|
13050
|
-
{
|
|
13051
|
-
logger.error('SDK not initialized');
|
|
13052
|
-
return;
|
|
13053
|
-
}
|
|
13054
|
-
}
|
|
12634
|
+
const URL_MAX_LENGTH = 2000;
|
|
13055
12635
|
/**
|
|
13056
|
-
*
|
|
13057
|
-
* @param failureType
|
|
12636
|
+
* The default CSS dimensions of the embedded app
|
|
13058
12637
|
*/
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
return;
|
|
13063
|
-
}
|
|
13064
|
-
}
|
|
12638
|
+
const DEFAULT_EMBED_WIDTH = '100%';
|
|
12639
|
+
const DEFAULT_EMBED_HEIGHT = '100%';
|
|
12640
|
+
|
|
13065
12641
|
/**
|
|
13066
12642
|
*
|
|
12643
|
+
* @param root0
|
|
12644
|
+
* @param root0.query
|
|
12645
|
+
* @param root0.variables
|
|
12646
|
+
* @param root0.thoughtSpotHost
|
|
12647
|
+
* @param root0.isCompositeQuery
|
|
13067
12648
|
*/
|
|
13068
|
-
function
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
|
|
12649
|
+
async function graphqlQuery({ query, variables, thoughtSpotHost, isCompositeQuery = false, }) {
|
|
12650
|
+
const operationName = getOperationNameFromQuery(query);
|
|
12651
|
+
try {
|
|
12652
|
+
const response = await fetch(`${thoughtSpotHost}/prism/?op=${operationName}`, {
|
|
12653
|
+
method: 'POST',
|
|
12654
|
+
headers: {
|
|
12655
|
+
'content-type': 'application/json;charset=UTF-8',
|
|
12656
|
+
'x-requested-by': 'ThoughtSpot',
|
|
12657
|
+
accept: '*/*',
|
|
12658
|
+
'accept-language': 'en-us',
|
|
12659
|
+
},
|
|
12660
|
+
body: JSON.stringify({
|
|
12661
|
+
operationName,
|
|
12662
|
+
query,
|
|
12663
|
+
variables,
|
|
12664
|
+
}),
|
|
12665
|
+
credentials: 'include',
|
|
12666
|
+
});
|
|
12667
|
+
const result = await response.json();
|
|
12668
|
+
const dataValues = Object.values(result.data);
|
|
12669
|
+
return (isCompositeQuery) ? result.data : dataValues[0];
|
|
13072
12670
|
}
|
|
13073
|
-
|
|
13074
|
-
|
|
13075
|
-
if (sessionInfo == null) {
|
|
13076
|
-
sessionInfo = sessionDetails;
|
|
13077
|
-
initMixpanel(sessionInfo);
|
|
13078
|
-
sessionInfoResolver(sessionInfo);
|
|
12671
|
+
catch (error) {
|
|
12672
|
+
return error;
|
|
13079
12673
|
}
|
|
13080
|
-
}
|
|
13081
|
-
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
12674
|
+
}
|
|
12675
|
+
|
|
12676
|
+
const getSourceDetailQuery = `
|
|
12677
|
+
query GetSourceDetail($ids: [GUID!]!) {
|
|
12678
|
+
getSourceDetailById(ids: $ids, type: LOGICAL_TABLE) {
|
|
12679
|
+
id
|
|
12680
|
+
name
|
|
12681
|
+
description
|
|
12682
|
+
authorName
|
|
12683
|
+
authorDisplayName
|
|
12684
|
+
isExternal
|
|
12685
|
+
type
|
|
12686
|
+
created
|
|
12687
|
+
modified
|
|
12688
|
+
columns {
|
|
12689
|
+
id
|
|
12690
|
+
name
|
|
12691
|
+
author
|
|
12692
|
+
authorDisplayName
|
|
12693
|
+
description
|
|
12694
|
+
dataType
|
|
12695
|
+
type
|
|
12696
|
+
modified
|
|
12697
|
+
ownerName
|
|
12698
|
+
owner
|
|
12699
|
+
dataRecency
|
|
12700
|
+
sources {
|
|
12701
|
+
tableId
|
|
12702
|
+
tableName
|
|
12703
|
+
columnId
|
|
12704
|
+
columnName
|
|
12705
|
+
__typename
|
|
12706
|
+
}
|
|
12707
|
+
synonyms
|
|
12708
|
+
cohortAnswerId
|
|
12709
|
+
__typename
|
|
12710
|
+
}
|
|
12711
|
+
relationships
|
|
12712
|
+
destinationRelationships
|
|
12713
|
+
dataSourceId
|
|
12714
|
+
__typename
|
|
12715
|
+
}
|
|
12716
|
+
}
|
|
12717
|
+
`;
|
|
12718
|
+
const sourceDetailCache = new Map();
|
|
13097
12719
|
/**
|
|
13098
|
-
* Check if we are logged into the ThoughtSpot cluster
|
|
13099
12720
|
*
|
|
13100
|
-
* @param thoughtSpotHost
|
|
12721
|
+
* @param thoughtSpotHost
|
|
12722
|
+
* @param sourceId
|
|
13101
12723
|
*/
|
|
13102
|
-
async function
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
try {
|
|
13106
|
-
response = await fetchSessionInfoService(authVerificationUrl);
|
|
13107
|
-
const sessionInfoResp = await response.json();
|
|
13108
|
-
const sessionDetails = getSessionDetails(sessionInfoResp);
|
|
13109
|
-
// Store user session details from session info
|
|
13110
|
-
initSession(sessionDetails);
|
|
13111
|
-
releaseVersion = sessionInfoResp.releaseVersion;
|
|
12724
|
+
async function getSourceDetail(thoughtSpotHost, sourceId) {
|
|
12725
|
+
if (sourceDetailCache.get(sourceId)) {
|
|
12726
|
+
return sourceDetailCache.get(sourceId);
|
|
13112
12727
|
}
|
|
13113
|
-
|
|
13114
|
-
|
|
12728
|
+
const details = await graphqlQuery({
|
|
12729
|
+
query: getSourceDetailQuery,
|
|
12730
|
+
variables: {
|
|
12731
|
+
ids: [sourceId],
|
|
12732
|
+
},
|
|
12733
|
+
thoughtSpotHost,
|
|
12734
|
+
});
|
|
12735
|
+
const souceDetails = details[0];
|
|
12736
|
+
if (souceDetails) {
|
|
12737
|
+
sourceDetailCache.set(sourceId, souceDetails);
|
|
13115
12738
|
}
|
|
13116
|
-
return
|
|
13117
|
-
}
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13130
|
-
|
|
13131
|
-
|
|
13132
|
-
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
12739
|
+
return souceDetails;
|
|
12740
|
+
}
|
|
12741
|
+
|
|
12742
|
+
const bachSessionId = `
|
|
12743
|
+
id {
|
|
12744
|
+
sessionId
|
|
12745
|
+
genNo
|
|
12746
|
+
acSession {
|
|
12747
|
+
sessionId
|
|
12748
|
+
genNo
|
|
12749
|
+
}
|
|
12750
|
+
}
|
|
12751
|
+
`;
|
|
12752
|
+
const getUnaggregatedAnswerSession = `
|
|
12753
|
+
mutation GetUnAggregatedAnswerSession($session: BachSessionIdInput!, $columns: [UserPointSelectionInput!]!) {
|
|
12754
|
+
Answer__getUnaggregatedAnswer(session: $session, columns: $columns) {
|
|
12755
|
+
${bachSessionId}
|
|
12756
|
+
answer {
|
|
12757
|
+
visualizations {
|
|
12758
|
+
... on TableViz {
|
|
12759
|
+
columns {
|
|
12760
|
+
column {
|
|
12761
|
+
id
|
|
12762
|
+
name
|
|
12763
|
+
referencedColumns {
|
|
12764
|
+
guid
|
|
12765
|
+
displayName
|
|
12766
|
+
}
|
|
12767
|
+
}
|
|
12768
|
+
}
|
|
12769
|
+
}
|
|
12770
|
+
}
|
|
12771
|
+
}
|
|
12772
|
+
}
|
|
12773
|
+
}
|
|
12774
|
+
`;
|
|
12775
|
+
const removeColumns = `
|
|
12776
|
+
mutation RemoveColumns($session: BachSessionIdInput!, $logicalColumnIds: [GUID!], $columnIds: [GUID!]) {
|
|
12777
|
+
Answer__removeColumns(
|
|
12778
|
+
session: $session
|
|
12779
|
+
logicalColumnIds: $logicalColumnIds
|
|
12780
|
+
columnIds: $columnIds
|
|
12781
|
+
) {
|
|
12782
|
+
${bachSessionId}
|
|
12783
|
+
}
|
|
12784
|
+
}
|
|
12785
|
+
`;
|
|
12786
|
+
const addColumns = `
|
|
12787
|
+
mutation AddColumns($session: BachSessionIdInput!, $columns: [AnswerColumnInfo!]!) {
|
|
12788
|
+
Answer__addColumn(session: $session, columns: $columns) {
|
|
12789
|
+
${bachSessionId}
|
|
12790
|
+
}
|
|
12791
|
+
}
|
|
12792
|
+
`;
|
|
12793
|
+
const getAnswerData = `
|
|
12794
|
+
query GetTableWithHeadlineData($session: BachSessionIdInput!, $deadline: Int!, $dataPaginationParams: DataPaginationParamsInput!) {
|
|
12795
|
+
getAnswer(session: $session) {
|
|
12796
|
+
${bachSessionId}
|
|
12797
|
+
answer {
|
|
12798
|
+
id
|
|
12799
|
+
visualizations {
|
|
12800
|
+
id
|
|
12801
|
+
... on TableViz {
|
|
12802
|
+
columns {
|
|
12803
|
+
column {
|
|
12804
|
+
id
|
|
12805
|
+
name
|
|
12806
|
+
type
|
|
12807
|
+
aggregationType
|
|
12808
|
+
dataType
|
|
12809
|
+
}
|
|
12810
|
+
}
|
|
12811
|
+
data(deadline: $deadline, pagination: $dataPaginationParams)
|
|
12812
|
+
}
|
|
12813
|
+
}
|
|
12814
|
+
}
|
|
12815
|
+
}
|
|
12816
|
+
}
|
|
12817
|
+
`;
|
|
12818
|
+
|
|
12819
|
+
// eslint-disable-next-line no-shadow
|
|
12820
|
+
var OperationType;
|
|
12821
|
+
(function (OperationType) {
|
|
12822
|
+
OperationType["GetChartWithData"] = "GetChartWithData";
|
|
12823
|
+
OperationType["GetTableWithHeadlineData"] = "GetTableWithHeadlineData";
|
|
12824
|
+
})(OperationType || (OperationType = {}));
|
|
13141
12825
|
/**
|
|
13142
|
-
*
|
|
12826
|
+
* Class representing the answer service provided with the
|
|
12827
|
+
* custom action payload. This service could be used to run
|
|
12828
|
+
* graphql queries in the context of the answer on which the
|
|
12829
|
+
* custom action was triggered.
|
|
13143
12830
|
*
|
|
13144
|
-
* @
|
|
12831
|
+
* @example
|
|
12832
|
+
* ```js
|
|
12833
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
12834
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
12835
|
+
* 'col name 1'
|
|
12836
|
+
* ]);
|
|
12837
|
+
* const data = await underlying.fetchData(0, 100);
|
|
12838
|
+
* })
|
|
12839
|
+
* ```
|
|
12840
|
+
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
12841
|
+
* @group Events
|
|
13145
12842
|
*/
|
|
13146
|
-
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
|
|
12843
|
+
class AnswerService {
|
|
12844
|
+
/**
|
|
12845
|
+
* Should not need to be called directly.
|
|
12846
|
+
*
|
|
12847
|
+
* @param session
|
|
12848
|
+
* @param answer
|
|
12849
|
+
* @param thoughtSpotHost
|
|
12850
|
+
* @param selectedPoints
|
|
12851
|
+
*/
|
|
12852
|
+
constructor(session, answer, thoughtSpotHost, selectedPoints) {
|
|
12853
|
+
this.session = session;
|
|
12854
|
+
this.answer = answer;
|
|
12855
|
+
this.thoughtSpotHost = thoughtSpotHost;
|
|
12856
|
+
this.selectedPoints = selectedPoints;
|
|
12857
|
+
this.session = removeTypename(session);
|
|
13150
12858
|
}
|
|
13151
|
-
|
|
13152
|
-
|
|
13153
|
-
|
|
13154
|
-
|
|
13155
|
-
|
|
13156
|
-
|
|
13157
|
-
|
|
13158
|
-
catch (e) {
|
|
13159
|
-
resp = await fetchAuthService(thoughtSpotHost, username, authToken);
|
|
13160
|
-
}
|
|
13161
|
-
// token login issues a 302 when successful
|
|
13162
|
-
loggedInStatus = resp.ok || resp.type === 'opaqueredirect';
|
|
13163
|
-
if (loggedInStatus && embedConfig.detectCookieAccessSlow) {
|
|
13164
|
-
// When 3rd party cookie access is blocked, this will fail because
|
|
13165
|
-
// cookies will not be sent with the call.
|
|
13166
|
-
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
13167
|
-
}
|
|
12859
|
+
/**
|
|
12860
|
+
* Get the details about the source used in the answer.
|
|
12861
|
+
* This can be used to get the list of all columns in the data source for example.
|
|
12862
|
+
*/
|
|
12863
|
+
async getSourceDetail() {
|
|
12864
|
+
const sourceId = this.answer.sources[0].header.guid;
|
|
12865
|
+
return getSourceDetail(this.thoughtSpotHost, sourceId);
|
|
13168
12866
|
}
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
|
|
13172
|
-
|
|
13173
|
-
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
throw new Error('Either auth endpoint or getAuthToken function must be provided');
|
|
12867
|
+
/**
|
|
12868
|
+
* Remove columnIds and return updated answer session.
|
|
12869
|
+
*
|
|
12870
|
+
* @param columnIds
|
|
12871
|
+
* @returns
|
|
12872
|
+
*/
|
|
12873
|
+
async removeColumns(columnIds) {
|
|
12874
|
+
return this.executeQuery(removeColumns, {
|
|
12875
|
+
logicalColumnIds: columnIds,
|
|
12876
|
+
});
|
|
13180
12877
|
}
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
|
|
13184
|
-
|
|
13185
|
-
|
|
13186
|
-
|
|
12878
|
+
/**
|
|
12879
|
+
* Add columnIds and return updated answer session.
|
|
12880
|
+
*
|
|
12881
|
+
* @param columnIds
|
|
12882
|
+
* @returns
|
|
12883
|
+
*/
|
|
12884
|
+
async addColumns(columnIds) {
|
|
12885
|
+
return this.executeQuery(addColumns, {
|
|
12886
|
+
columns: columnIds.map((colId) => ({ logicalColumnId: colId })),
|
|
12887
|
+
});
|
|
13187
12888
|
}
|
|
13188
|
-
|
|
13189
|
-
|
|
12889
|
+
/**
|
|
12890
|
+
* Fetch data from the answer.
|
|
12891
|
+
*
|
|
12892
|
+
* @param offset
|
|
12893
|
+
* @param size
|
|
12894
|
+
* @returns
|
|
12895
|
+
*/
|
|
12896
|
+
async fetchData(offset = 0, size = 1000) {
|
|
12897
|
+
const { answer } = await this.executeQuery(getAnswerData, {
|
|
12898
|
+
deadline: 0,
|
|
12899
|
+
dataPaginationParams: {
|
|
12900
|
+
isClientPaginated: true,
|
|
12901
|
+
offset,
|
|
12902
|
+
size,
|
|
12903
|
+
},
|
|
12904
|
+
});
|
|
12905
|
+
const { columns, data } = answer.visualizations.find((viz) => !!viz.data) || {};
|
|
12906
|
+
return {
|
|
12907
|
+
columns,
|
|
12908
|
+
data,
|
|
12909
|
+
};
|
|
13190
12910
|
}
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
const loggedIn = await isLoggedIn(thoughtSpotHost);
|
|
13205
|
-
if (!loggedIn) {
|
|
13206
|
-
const response = await fetchBasicAuthService(thoughtSpotHost, username, password);
|
|
13207
|
-
loggedInStatus = response.ok;
|
|
13208
|
-
if (embedConfig.detectCookieAccessSlow) {
|
|
13209
|
-
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
13210
|
-
}
|
|
12911
|
+
/**
|
|
12912
|
+
* Fetch the data for the answer as a CSV blob. This might be
|
|
12913
|
+
* quicker for larger data.
|
|
12914
|
+
*
|
|
12915
|
+
* @param userLocale
|
|
12916
|
+
* @param includeInfo Include the CSV header in the output
|
|
12917
|
+
* @returns Response
|
|
12918
|
+
*/
|
|
12919
|
+
async fetchCSVBlob(userLocale = 'en-us', includeInfo = false) {
|
|
12920
|
+
const fetchUrl = this.getFetchCSVBlobUrl(userLocale, includeInfo);
|
|
12921
|
+
return tokenizedFetch(fetchUrl, {
|
|
12922
|
+
credentials: 'include',
|
|
12923
|
+
});
|
|
13211
12924
|
}
|
|
13212
|
-
|
|
13213
|
-
|
|
12925
|
+
/**
|
|
12926
|
+
* Just get the internal URL for this answer's data
|
|
12927
|
+
* as a CSV blob.
|
|
12928
|
+
*
|
|
12929
|
+
* @param userLocale
|
|
12930
|
+
* @param includeInfo
|
|
12931
|
+
* @returns
|
|
12932
|
+
*/
|
|
12933
|
+
getFetchCSVBlobUrl(userLocale = 'en-us', includeInfo = false) {
|
|
12934
|
+
return `${this.thoughtSpotHost}/prism/download/answer/csv?sessionId=${this.session.sessionId}&genNo=${this.session.genNo}&userLocale=${userLocale}&exportFileName=data&hideCsvHeader=${!includeInfo}`;
|
|
13214
12935
|
}
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
|
|
13225
|
-
|
|
13226
|
-
|
|
12936
|
+
/**
|
|
12937
|
+
* Get underlying data given a point and the output column names.
|
|
12938
|
+
* In case of a context menu action, the selectedPoints are
|
|
12939
|
+
* automatically passed.
|
|
12940
|
+
*
|
|
12941
|
+
* @param outputColumnNames
|
|
12942
|
+
* @param selectedPoints
|
|
12943
|
+
* @example
|
|
12944
|
+
* ```js
|
|
12945
|
+
* embed.on(EmbedEvent.CustomAction, e => {
|
|
12946
|
+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
|
|
12947
|
+
* 'col name 1' // The column should exist in the data source.
|
|
12948
|
+
* ]);
|
|
12949
|
+
* const data = await underlying.fetchData(0, 100);
|
|
12950
|
+
* })
|
|
12951
|
+
* ```
|
|
12952
|
+
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
|
|
12953
|
+
*/
|
|
12954
|
+
async getUnderlyingDataForPoint(outputColumnNames, selectedPoints) {
|
|
12955
|
+
if (!selectedPoints && !this.selectedPoints) {
|
|
12956
|
+
throw new Error('Needs to be triggered in context of a point');
|
|
13227
12957
|
}
|
|
13228
|
-
|
|
13229
|
-
|
|
12958
|
+
if (!selectedPoints) {
|
|
12959
|
+
selectedPoints = getSelectedPointsForUnderlyingDataQuery(this.selectedPoints);
|
|
13230
12960
|
}
|
|
13231
|
-
|
|
13232
|
-
|
|
13233
|
-
|
|
13234
|
-
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
|
|
12961
|
+
const sourceDetail = await this.getSourceDetail();
|
|
12962
|
+
const ouputColumnGuids = getGuidsFromColumnNames(sourceDetail, outputColumnNames);
|
|
12963
|
+
const unAggAnswer = await graphqlQuery({
|
|
12964
|
+
query: getUnaggregatedAnswerSession,
|
|
12965
|
+
variables: {
|
|
12966
|
+
session: this.session,
|
|
12967
|
+
columns: selectedPoints,
|
|
12968
|
+
},
|
|
12969
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
12970
|
+
});
|
|
12971
|
+
const unaggAnswerSession = new AnswerService(unAggAnswer.id, unAggAnswer.answer, this.thoughtSpotHost);
|
|
12972
|
+
const currentColumns = new Set(unAggAnswer.answer.visualizations[0].columns
|
|
12973
|
+
.map((c) => c.column.referencedColumns[0].guid));
|
|
12974
|
+
const columnsToAdd = [...ouputColumnGuids].filter((col) => !currentColumns.has(col));
|
|
12975
|
+
if (columnsToAdd.length) {
|
|
12976
|
+
await unaggAnswerSession.addColumns(columnsToAdd);
|
|
12977
|
+
}
|
|
12978
|
+
const columnsToRemove = [...currentColumns].filter((col) => !ouputColumnGuids.has(col));
|
|
12979
|
+
if (columnsToRemove.length) {
|
|
12980
|
+
await unaggAnswerSession.removeColumns(columnsToRemove);
|
|
12981
|
+
}
|
|
12982
|
+
return unaggAnswerSession;
|
|
13238
12983
|
}
|
|
13239
|
-
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
12984
|
+
/**
|
|
12985
|
+
* Execute a custom graphql query in the context of the answer.
|
|
12986
|
+
*
|
|
12987
|
+
* @param query graphql query
|
|
12988
|
+
* @param variables graphql variables
|
|
12989
|
+
* @returns
|
|
12990
|
+
*/
|
|
12991
|
+
async executeQuery(query, variables) {
|
|
12992
|
+
const data = await graphqlQuery({
|
|
12993
|
+
query,
|
|
12994
|
+
variables: {
|
|
12995
|
+
session: this.session,
|
|
12996
|
+
...variables,
|
|
12997
|
+
},
|
|
12998
|
+
thoughtSpotHost: this.thoughtSpotHost,
|
|
12999
|
+
isCompositeQuery: false,
|
|
13247
13000
|
});
|
|
13248
|
-
|
|
13001
|
+
this.session = deepMerge(this.session, (data === null || data === void 0 ? void 0 : data.id) || {});
|
|
13002
|
+
return data;
|
|
13003
|
+
}
|
|
13004
|
+
/**
|
|
13005
|
+
* Get the internal session details for the answer.
|
|
13006
|
+
*
|
|
13007
|
+
* @returns
|
|
13008
|
+
*/
|
|
13009
|
+
getSession() {
|
|
13010
|
+
return this.session;
|
|
13011
|
+
}
|
|
13249
13012
|
}
|
|
13250
13013
|
/**
|
|
13251
|
-
* Perform SAML authentication
|
|
13252
13014
|
*
|
|
13253
|
-
* @param
|
|
13254
|
-
* @param
|
|
13015
|
+
* @param sourceDetail
|
|
13016
|
+
* @param colNames
|
|
13255
13017
|
*/
|
|
13256
|
-
|
|
13257
|
-
const
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
|
|
13265
|
-
|
|
13266
|
-
// we have already tried authentication and it did not succeed, restore
|
|
13267
|
-
// the current URL to the original one and invoke the callback.
|
|
13268
|
-
if (isAtSSORedirectUrl()) {
|
|
13269
|
-
removeSSORedirectUrlMarker();
|
|
13270
|
-
loggedInStatus = false;
|
|
13271
|
-
return;
|
|
13272
|
-
}
|
|
13273
|
-
const ssoURL = `${thoughtSpotHost}${ssoEndPoint}`;
|
|
13274
|
-
if (embedConfig.inPopup) {
|
|
13275
|
-
await samlPopupFlow(ssoURL, embedConfig.authTriggerContainer, embedConfig.authTriggerText);
|
|
13276
|
-
loggedInStatus = await isLoggedIn(thoughtSpotHost);
|
|
13277
|
-
return;
|
|
13278
|
-
}
|
|
13279
|
-
window.location.href = ssoURL;
|
|
13280
|
-
};
|
|
13281
|
-
const doSamlAuth = async (embedConfig) => {
|
|
13282
|
-
const { thoughtSpotHost } = embedConfig;
|
|
13283
|
-
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
13284
|
-
// loaded again and the same JS will execute again.
|
|
13285
|
-
const ssoRedirectUrl = embedConfig.inPopup
|
|
13286
|
-
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
13287
|
-
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
13288
|
-
// bring back the page to the same URL
|
|
13289
|
-
const ssoEndPoint = `${EndPoints.SAML_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
13290
|
-
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
13291
|
-
return loggedInStatus;
|
|
13292
|
-
};
|
|
13293
|
-
const doOIDCAuth = async (embedConfig) => {
|
|
13294
|
-
const { thoughtSpotHost } = embedConfig;
|
|
13295
|
-
// redirect for SSO, when the SSO authentication is done, this page will be
|
|
13296
|
-
// loaded again and the same JS will execute again.
|
|
13297
|
-
const ssoRedirectUrl = embedConfig.noRedirect || embedConfig.inPopup
|
|
13298
|
-
? `${thoughtSpotHost}/v2/#/embed/saml-complete`
|
|
13299
|
-
: getRedirectUrl(window.location.href, SSO_REDIRECTION_MARKER_GUID, embedConfig.redirectPath);
|
|
13300
|
-
// bring back the page to the same URL
|
|
13301
|
-
const ssoEndPoint = `${EndPoints.OIDC_LOGIN_TEMPLATE(encodeURIComponent(ssoRedirectUrl))}`;
|
|
13302
|
-
await doSSOAuth(embedConfig, ssoEndPoint);
|
|
13303
|
-
return loggedInStatus;
|
|
13304
|
-
};
|
|
13018
|
+
function getGuidsFromColumnNames(sourceDetail, colNames) {
|
|
13019
|
+
const cols = sourceDetail.columns.reduce((colSet, col) => {
|
|
13020
|
+
colSet[col.name] = col;
|
|
13021
|
+
return colSet;
|
|
13022
|
+
}, {});
|
|
13023
|
+
return new Set(colNames.map((colName) => {
|
|
13024
|
+
const col = cols[colName];
|
|
13025
|
+
return col.id;
|
|
13026
|
+
}));
|
|
13027
|
+
}
|
|
13305
13028
|
/**
|
|
13306
|
-
* Perform authentication on the ThoughtSpot cluster
|
|
13307
13029
|
*
|
|
13308
|
-
* @param
|
|
13030
|
+
* @param selectedPoints
|
|
13309
13031
|
*/
|
|
13310
|
-
|
|
13311
|
-
const
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13032
|
+
function getSelectedPointsForUnderlyingDataQuery(selectedPoints) {
|
|
13033
|
+
const underlyingDataPoint = [];
|
|
13034
|
+
/**
|
|
13035
|
+
*
|
|
13036
|
+
* @param colVal
|
|
13037
|
+
*/
|
|
13038
|
+
function addPointFromColVal(colVal) {
|
|
13039
|
+
var _a;
|
|
13040
|
+
const dataType = colVal.column.dataType;
|
|
13041
|
+
const id = colVal.column.id;
|
|
13042
|
+
let dataValue;
|
|
13043
|
+
if (dataType === 'DATE') {
|
|
13044
|
+
if (Number.isFinite(colVal.value)) {
|
|
13045
|
+
dataValue = [{
|
|
13046
|
+
epochRange: {
|
|
13047
|
+
startEpoch: colVal.value,
|
|
13048
|
+
},
|
|
13049
|
+
}];
|
|
13050
|
+
// Case for custom calendar.
|
|
13051
|
+
}
|
|
13052
|
+
else if ((_a = colVal.value) === null || _a === void 0 ? void 0 : _a.v) {
|
|
13053
|
+
dataValue = [{
|
|
13054
|
+
epochRange: {
|
|
13055
|
+
startEpoch: colVal.value.v.s,
|
|
13056
|
+
endEpoch: colVal.value.v.e,
|
|
13057
|
+
},
|
|
13058
|
+
}];
|
|
13059
|
+
}
|
|
13060
|
+
}
|
|
13061
|
+
else {
|
|
13062
|
+
dataValue = [{ value: colVal.value }];
|
|
13063
|
+
}
|
|
13064
|
+
underlyingDataPoint.push({
|
|
13065
|
+
columnId: colVal.column.id,
|
|
13066
|
+
dataValue,
|
|
13067
|
+
});
|
|
13329
13068
|
}
|
|
13069
|
+
selectedPoints.forEach((p) => {
|
|
13070
|
+
p.selectedAttributes.forEach(addPointFromColVal);
|
|
13071
|
+
});
|
|
13072
|
+
return underlyingDataPoint;
|
|
13073
|
+
}
|
|
13074
|
+
|
|
13075
|
+
var eventemitter3 = createCommonjsModule(function (module) {
|
|
13076
|
+
|
|
13077
|
+
var has = Object.prototype.hasOwnProperty
|
|
13078
|
+
, prefix = '~';
|
|
13079
|
+
|
|
13080
|
+
/**
|
|
13081
|
+
* Constructor to create a storage for our `EE` objects.
|
|
13082
|
+
* An `Events` instance is a plain object whose properties are event names.
|
|
13083
|
+
*
|
|
13084
|
+
* @constructor
|
|
13085
|
+
* @private
|
|
13086
|
+
*/
|
|
13087
|
+
function Events() {}
|
|
13088
|
+
|
|
13089
|
+
//
|
|
13090
|
+
// We try to not inherit from `Object.prototype`. In some engines creating an
|
|
13091
|
+
// instance in this way is faster than calling `Object.create(null)` directly.
|
|
13092
|
+
// If `Object.create(null)` is not supported we prefix the event names with a
|
|
13093
|
+
// character to make sure that the built-in object properties are not
|
|
13094
|
+
// overridden or used as an attack vector.
|
|
13095
|
+
//
|
|
13096
|
+
if (Object.create) {
|
|
13097
|
+
Events.prototype = Object.create(null);
|
|
13098
|
+
|
|
13099
|
+
//
|
|
13100
|
+
// This hack is needed because the `__proto__` property is still inherited in
|
|
13101
|
+
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
|
|
13102
|
+
//
|
|
13103
|
+
if (!new Events().__proto__) prefix = false;
|
|
13104
|
+
}
|
|
13105
|
+
|
|
13106
|
+
/**
|
|
13107
|
+
* Representation of a single event listener.
|
|
13108
|
+
*
|
|
13109
|
+
* @param {Function} fn The listener function.
|
|
13110
|
+
* @param {*} context The context to invoke the listener with.
|
|
13111
|
+
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
|
|
13112
|
+
* @constructor
|
|
13113
|
+
* @private
|
|
13114
|
+
*/
|
|
13115
|
+
function EE(fn, context, once) {
|
|
13116
|
+
this.fn = fn;
|
|
13117
|
+
this.context = context;
|
|
13118
|
+
this.once = once || false;
|
|
13119
|
+
}
|
|
13120
|
+
|
|
13121
|
+
/**
|
|
13122
|
+
* Add a listener for a given event.
|
|
13123
|
+
*
|
|
13124
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
13125
|
+
* @param {(String|Symbol)} event The event name.
|
|
13126
|
+
* @param {Function} fn The listener function.
|
|
13127
|
+
* @param {*} context The context to invoke the listener with.
|
|
13128
|
+
* @param {Boolean} once Specify if the listener is a one-time listener.
|
|
13129
|
+
* @returns {EventEmitter}
|
|
13130
|
+
* @private
|
|
13131
|
+
*/
|
|
13132
|
+
function addListener(emitter, event, fn, context, once) {
|
|
13133
|
+
if (typeof fn !== 'function') {
|
|
13134
|
+
throw new TypeError('The listener must be a function');
|
|
13135
|
+
}
|
|
13136
|
+
|
|
13137
|
+
var listener = new EE(fn, context || emitter, once)
|
|
13138
|
+
, evt = prefix ? prefix + event : event;
|
|
13139
|
+
|
|
13140
|
+
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
13141
|
+
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
13142
|
+
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
13143
|
+
|
|
13144
|
+
return emitter;
|
|
13145
|
+
}
|
|
13146
|
+
|
|
13147
|
+
/**
|
|
13148
|
+
* Clear event by name.
|
|
13149
|
+
*
|
|
13150
|
+
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
|
|
13151
|
+
* @param {(String|Symbol)} evt The Event name.
|
|
13152
|
+
* @private
|
|
13153
|
+
*/
|
|
13154
|
+
function clearEvent(emitter, evt) {
|
|
13155
|
+
if (--emitter._eventsCount === 0) emitter._events = new Events();
|
|
13156
|
+
else delete emitter._events[evt];
|
|
13157
|
+
}
|
|
13158
|
+
|
|
13159
|
+
/**
|
|
13160
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
13161
|
+
* `EventEmitter` interface.
|
|
13162
|
+
*
|
|
13163
|
+
* @constructor
|
|
13164
|
+
* @public
|
|
13165
|
+
*/
|
|
13166
|
+
function EventEmitter() {
|
|
13167
|
+
this._events = new Events();
|
|
13168
|
+
this._eventsCount = 0;
|
|
13169
|
+
}
|
|
13170
|
+
|
|
13171
|
+
/**
|
|
13172
|
+
* Return an array listing the events for which the emitter has registered
|
|
13173
|
+
* listeners.
|
|
13174
|
+
*
|
|
13175
|
+
* @returns {Array}
|
|
13176
|
+
* @public
|
|
13177
|
+
*/
|
|
13178
|
+
EventEmitter.prototype.eventNames = function eventNames() {
|
|
13179
|
+
var names = []
|
|
13180
|
+
, events
|
|
13181
|
+
, name;
|
|
13182
|
+
|
|
13183
|
+
if (this._eventsCount === 0) return names;
|
|
13184
|
+
|
|
13185
|
+
for (name in (events = this._events)) {
|
|
13186
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
13187
|
+
}
|
|
13188
|
+
|
|
13189
|
+
if (Object.getOwnPropertySymbols) {
|
|
13190
|
+
return names.concat(Object.getOwnPropertySymbols(events));
|
|
13191
|
+
}
|
|
13192
|
+
|
|
13193
|
+
return names;
|
|
13194
|
+
};
|
|
13195
|
+
|
|
13196
|
+
/**
|
|
13197
|
+
* Return the listeners registered for a given event.
|
|
13198
|
+
*
|
|
13199
|
+
* @param {(String|Symbol)} event The event name.
|
|
13200
|
+
* @returns {Array} The registered listeners.
|
|
13201
|
+
* @public
|
|
13202
|
+
*/
|
|
13203
|
+
EventEmitter.prototype.listeners = function listeners(event) {
|
|
13204
|
+
var evt = prefix ? prefix + event : event
|
|
13205
|
+
, handlers = this._events[evt];
|
|
13206
|
+
|
|
13207
|
+
if (!handlers) return [];
|
|
13208
|
+
if (handlers.fn) return [handlers.fn];
|
|
13209
|
+
|
|
13210
|
+
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
13211
|
+
ee[i] = handlers[i].fn;
|
|
13212
|
+
}
|
|
13213
|
+
|
|
13214
|
+
return ee;
|
|
13215
|
+
};
|
|
13216
|
+
|
|
13217
|
+
/**
|
|
13218
|
+
* Return the number of listeners listening to a given event.
|
|
13219
|
+
*
|
|
13220
|
+
* @param {(String|Symbol)} event The event name.
|
|
13221
|
+
* @returns {Number} The number of listeners.
|
|
13222
|
+
* @public
|
|
13223
|
+
*/
|
|
13224
|
+
EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
|
13225
|
+
var evt = prefix ? prefix + event : event
|
|
13226
|
+
, listeners = this._events[evt];
|
|
13227
|
+
|
|
13228
|
+
if (!listeners) return 0;
|
|
13229
|
+
if (listeners.fn) return 1;
|
|
13230
|
+
return listeners.length;
|
|
13231
|
+
};
|
|
13232
|
+
|
|
13233
|
+
/**
|
|
13234
|
+
* Calls each of the listeners registered for a given event.
|
|
13235
|
+
*
|
|
13236
|
+
* @param {(String|Symbol)} event The event name.
|
|
13237
|
+
* @returns {Boolean} `true` if the event had listeners, else `false`.
|
|
13238
|
+
* @public
|
|
13239
|
+
*/
|
|
13240
|
+
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
13241
|
+
var evt = prefix ? prefix + event : event;
|
|
13242
|
+
|
|
13243
|
+
if (!this._events[evt]) return false;
|
|
13244
|
+
|
|
13245
|
+
var listeners = this._events[evt]
|
|
13246
|
+
, len = arguments.length
|
|
13247
|
+
, args
|
|
13248
|
+
, i;
|
|
13249
|
+
|
|
13250
|
+
if (listeners.fn) {
|
|
13251
|
+
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
|
13252
|
+
|
|
13253
|
+
switch (len) {
|
|
13254
|
+
case 1: return listeners.fn.call(listeners.context), true;
|
|
13255
|
+
case 2: return listeners.fn.call(listeners.context, a1), true;
|
|
13256
|
+
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
|
13257
|
+
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
|
13258
|
+
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
|
13259
|
+
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
|
13260
|
+
}
|
|
13261
|
+
|
|
13262
|
+
for (i = 1, args = new Array(len -1); i < len; i++) {
|
|
13263
|
+
args[i - 1] = arguments[i];
|
|
13264
|
+
}
|
|
13265
|
+
|
|
13266
|
+
listeners.fn.apply(listeners.context, args);
|
|
13267
|
+
} else {
|
|
13268
|
+
var length = listeners.length
|
|
13269
|
+
, j;
|
|
13270
|
+
|
|
13271
|
+
for (i = 0; i < length; i++) {
|
|
13272
|
+
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
|
13273
|
+
|
|
13274
|
+
switch (len) {
|
|
13275
|
+
case 1: listeners[i].fn.call(listeners[i].context); break;
|
|
13276
|
+
case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
|
13277
|
+
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
|
13278
|
+
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
|
13279
|
+
default:
|
|
13280
|
+
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
|
13281
|
+
args[j - 1] = arguments[j];
|
|
13282
|
+
}
|
|
13283
|
+
|
|
13284
|
+
listeners[i].fn.apply(listeners[i].context, args);
|
|
13285
|
+
}
|
|
13286
|
+
}
|
|
13287
|
+
}
|
|
13288
|
+
|
|
13289
|
+
return true;
|
|
13290
|
+
};
|
|
13291
|
+
|
|
13292
|
+
/**
|
|
13293
|
+
* Add a listener for a given event.
|
|
13294
|
+
*
|
|
13295
|
+
* @param {(String|Symbol)} event The event name.
|
|
13296
|
+
* @param {Function} fn The listener function.
|
|
13297
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
13298
|
+
* @returns {EventEmitter} `this`.
|
|
13299
|
+
* @public
|
|
13300
|
+
*/
|
|
13301
|
+
EventEmitter.prototype.on = function on(event, fn, context) {
|
|
13302
|
+
return addListener(this, event, fn, context, false);
|
|
13303
|
+
};
|
|
13304
|
+
|
|
13305
|
+
/**
|
|
13306
|
+
* Add a one-time listener for a given event.
|
|
13307
|
+
*
|
|
13308
|
+
* @param {(String|Symbol)} event The event name.
|
|
13309
|
+
* @param {Function} fn The listener function.
|
|
13310
|
+
* @param {*} [context=this] The context to invoke the listener with.
|
|
13311
|
+
* @returns {EventEmitter} `this`.
|
|
13312
|
+
* @public
|
|
13313
|
+
*/
|
|
13314
|
+
EventEmitter.prototype.once = function once(event, fn, context) {
|
|
13315
|
+
return addListener(this, event, fn, context, true);
|
|
13316
|
+
};
|
|
13317
|
+
|
|
13318
|
+
/**
|
|
13319
|
+
* Remove the listeners of a given event.
|
|
13320
|
+
*
|
|
13321
|
+
* @param {(String|Symbol)} event The event name.
|
|
13322
|
+
* @param {Function} fn Only remove the listeners that match this function.
|
|
13323
|
+
* @param {*} context Only remove the listeners that have this context.
|
|
13324
|
+
* @param {Boolean} once Only remove one-time listeners.
|
|
13325
|
+
* @returns {EventEmitter} `this`.
|
|
13326
|
+
* @public
|
|
13327
|
+
*/
|
|
13328
|
+
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
13329
|
+
var evt = prefix ? prefix + event : event;
|
|
13330
|
+
|
|
13331
|
+
if (!this._events[evt]) return this;
|
|
13332
|
+
if (!fn) {
|
|
13333
|
+
clearEvent(this, evt);
|
|
13334
|
+
return this;
|
|
13335
|
+
}
|
|
13336
|
+
|
|
13337
|
+
var listeners = this._events[evt];
|
|
13338
|
+
|
|
13339
|
+
if (listeners.fn) {
|
|
13340
|
+
if (
|
|
13341
|
+
listeners.fn === fn &&
|
|
13342
|
+
(!once || listeners.once) &&
|
|
13343
|
+
(!context || listeners.context === context)
|
|
13344
|
+
) {
|
|
13345
|
+
clearEvent(this, evt);
|
|
13346
|
+
}
|
|
13347
|
+
} else {
|
|
13348
|
+
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
|
13349
|
+
if (
|
|
13350
|
+
listeners[i].fn !== fn ||
|
|
13351
|
+
(once && !listeners[i].once) ||
|
|
13352
|
+
(context && listeners[i].context !== context)
|
|
13353
|
+
) {
|
|
13354
|
+
events.push(listeners[i]);
|
|
13355
|
+
}
|
|
13356
|
+
}
|
|
13357
|
+
|
|
13358
|
+
//
|
|
13359
|
+
// Reset the array, or remove it completely if we have no more listeners.
|
|
13360
|
+
//
|
|
13361
|
+
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
|
13362
|
+
else clearEvent(this, evt);
|
|
13363
|
+
}
|
|
13364
|
+
|
|
13365
|
+
return this;
|
|
13366
|
+
};
|
|
13367
|
+
|
|
13368
|
+
/**
|
|
13369
|
+
* Remove all listeners, or those of the specified event.
|
|
13370
|
+
*
|
|
13371
|
+
* @param {(String|Symbol)} [event] The event name.
|
|
13372
|
+
* @returns {EventEmitter} `this`.
|
|
13373
|
+
* @public
|
|
13374
|
+
*/
|
|
13375
|
+
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
13376
|
+
var evt;
|
|
13377
|
+
|
|
13378
|
+
if (event) {
|
|
13379
|
+
evt = prefix ? prefix + event : event;
|
|
13380
|
+
if (this._events[evt]) clearEvent(this, evt);
|
|
13381
|
+
} else {
|
|
13382
|
+
this._events = new Events();
|
|
13383
|
+
this._eventsCount = 0;
|
|
13384
|
+
}
|
|
13385
|
+
|
|
13386
|
+
return this;
|
|
13387
|
+
};
|
|
13388
|
+
|
|
13389
|
+
//
|
|
13390
|
+
// Alias methods names because people roll like that.
|
|
13391
|
+
//
|
|
13392
|
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
13393
|
+
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
|
13394
|
+
|
|
13395
|
+
//
|
|
13396
|
+
// Expose the prefix.
|
|
13397
|
+
//
|
|
13398
|
+
EventEmitter.prefixed = prefix;
|
|
13399
|
+
|
|
13400
|
+
//
|
|
13401
|
+
// Allow `EventEmitter` to be imported as module namespace.
|
|
13402
|
+
//
|
|
13403
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
13404
|
+
|
|
13405
|
+
//
|
|
13406
|
+
// Expose the module.
|
|
13407
|
+
//
|
|
13408
|
+
{
|
|
13409
|
+
module.exports = EventEmitter;
|
|
13410
|
+
}
|
|
13411
|
+
});
|
|
13412
|
+
|
|
13413
|
+
/** Used as references for various `Number` constants. */
|
|
13414
|
+
var INFINITY = 1 / 0;
|
|
13415
|
+
|
|
13416
|
+
/**
|
|
13417
|
+
* Creates a set object of `values`.
|
|
13418
|
+
*
|
|
13419
|
+
* @private
|
|
13420
|
+
* @param {Array} values The values to add to the set.
|
|
13421
|
+
* @returns {Object} Returns the new set.
|
|
13422
|
+
*/
|
|
13423
|
+
var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY) ? noop_1 : function(values) {
|
|
13424
|
+
return new _Set(values);
|
|
13330
13425
|
};
|
|
13331
13426
|
|
|
13332
13427
|
/* eslint-disable camelcase */
|
|
@@ -13542,8 +13637,6 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
|
|
|
13542
13637
|
});
|
|
13543
13638
|
}
|
|
13544
13639
|
|
|
13545
|
-
var name="@thoughtspot/visual-embed-sdk";var version="1.28.0-preRender";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/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.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-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",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","is-publish-allowed":"node scripts/is-publish-allowed.js",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","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",nirmay:"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"};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","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",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",tslib:"^2.5.3","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","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@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","current-git-branch":"^1.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-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",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,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.js",limit:"44 kB"}],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};
|
|
13546
|
-
|
|
13547
13640
|
/**
|
|
13548
13641
|
* Copyright (c) 2022
|
|
13549
13642
|
*
|
|
@@ -13689,7 +13782,7 @@ class TsEmbed {
|
|
|
13689
13782
|
this.thoughtSpotV2Base = getV2BasePath(this.embedConfig);
|
|
13690
13783
|
this.eventHandlerMap = new Map();
|
|
13691
13784
|
this.isError = false;
|
|
13692
|
-
this.viewConfig = viewConfig;
|
|
13785
|
+
this.viewConfig = { excludeRuntimeFiltersfromURL: true, ...viewConfig };
|
|
13693
13786
|
this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
|
|
13694
13787
|
this.registerAppInit();
|
|
13695
13788
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_EMBED_CREATE, {
|
|
@@ -13919,10 +14012,7 @@ class TsEmbed {
|
|
|
13919
14012
|
const queryParams = this.shouldEncodeUrlQueryParams
|
|
13920
14013
|
? `?base64UrlEncodedFlags=${getEncodedQueryParamsString(queryString)}`
|
|
13921
14014
|
: `?${queryString}`;
|
|
13922
|
-
|
|
13923
|
-
if (!isUndefined(this.embedConfig.enableReactShell)) {
|
|
13924
|
-
host = this.embedConfig.enableReactShell ? '/v2' : '/v1';
|
|
13925
|
-
}
|
|
14015
|
+
const host = this.thoughtSpotHost;
|
|
13926
14016
|
const path = `${host}/${queryParams}#`;
|
|
13927
14017
|
return path;
|
|
13928
14018
|
}
|
|
@@ -14311,6 +14401,14 @@ class TsEmbed {
|
|
|
14311
14401
|
*/
|
|
14312
14402
|
trigger(messageType, data = {}) {
|
|
14313
14403
|
uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_TRIGGER}-${messageType}`);
|
|
14404
|
+
if (!this.isRendered) {
|
|
14405
|
+
this.handleError('Please call render before triggering events');
|
|
14406
|
+
return null;
|
|
14407
|
+
}
|
|
14408
|
+
if (!messageType) {
|
|
14409
|
+
this.handleError('Host event type is undefined');
|
|
14410
|
+
return null;
|
|
14411
|
+
}
|
|
14314
14412
|
return processTrigger(this.iFrame, messageType, this.thoughtSpotHost, data);
|
|
14315
14413
|
}
|
|
14316
14414
|
/**
|
|
@@ -14320,7 +14418,7 @@ class TsEmbed {
|
|
|
14320
14418
|
*
|
|
14321
14419
|
* @param args
|
|
14322
14420
|
*/
|
|
14323
|
-
render() {
|
|
14421
|
+
async render() {
|
|
14324
14422
|
this.isRendered = true;
|
|
14325
14423
|
return this;
|
|
14326
14424
|
}
|
|
@@ -14525,7 +14623,7 @@ class TsEmbed {
|
|
|
14525
14623
|
class V1Embed extends TsEmbed {
|
|
14526
14624
|
constructor(domSelector, viewConfig) {
|
|
14527
14625
|
super(domSelector, viewConfig);
|
|
14528
|
-
this.viewConfig = viewConfig;
|
|
14626
|
+
this.viewConfig = { excludeRuntimeFiltersfromURL: true, ...viewConfig };
|
|
14529
14627
|
}
|
|
14530
14628
|
/**
|
|
14531
14629
|
* Render the app in an iframe and set up event handlers
|
|
@@ -14625,10 +14723,10 @@ class SearchBarEmbed extends TsEmbed {
|
|
|
14625
14723
|
/**
|
|
14626
14724
|
* Render the embedded ThoughtSpot search
|
|
14627
14725
|
*/
|
|
14628
|
-
render() {
|
|
14726
|
+
async render() {
|
|
14629
14727
|
super.render();
|
|
14630
14728
|
const src = this.getIFrameSrc();
|
|
14631
|
-
this.renderIFrame(src);
|
|
14729
|
+
await this.renderIFrame(src);
|
|
14632
14730
|
return this;
|
|
14633
14731
|
}
|
|
14634
14732
|
}
|
|
@@ -14722,10 +14820,10 @@ class SageEmbed extends V1Embed {
|
|
|
14722
14820
|
*
|
|
14723
14821
|
* @returns {SageEmbed} Eureka/Sage embed
|
|
14724
14822
|
*/
|
|
14725
|
-
render() {
|
|
14823
|
+
async render() {
|
|
14726
14824
|
super.render();
|
|
14727
14825
|
const src = this.getIFrameSrc();
|
|
14728
|
-
this.renderV1Embed(src);
|
|
14826
|
+
await this.renderV1Embed(src);
|
|
14729
14827
|
return this;
|
|
14730
14828
|
}
|
|
14731
14829
|
}
|
|
@@ -14771,7 +14869,7 @@ class SearchEmbed extends TsEmbed {
|
|
|
14771
14869
|
}
|
|
14772
14870
|
getEmbedParams() {
|
|
14773
14871
|
var _a;
|
|
14774
|
-
const { hideResults, enableSearchAssist, forceTable, searchOptions, runtimeFilters, dataSource, dataSources, excludeRuntimeFiltersfromURL, hideSearchBar, dataPanelV2 = false, useLastSelectedSources = false, runtimeParameters, } = this.viewConfig;
|
|
14872
|
+
const { hideResults, expandAllDataSource, enableSearchAssist, forceTable, searchOptions, runtimeFilters, dataSource, dataSources, excludeRuntimeFiltersfromURL = true, hideSearchBar, dataPanelV2 = false, useLastSelectedSources = false, runtimeParameters, } = this.viewConfig;
|
|
14775
14873
|
const queryParams = this.getBaseQueryParams();
|
|
14776
14874
|
queryParams[Param.HideActions] = [
|
|
14777
14875
|
...((_a = queryParams[Param.HideActions]) !== null && _a !== void 0 ? _a : []),
|
|
@@ -14838,11 +14936,11 @@ class SearchEmbed extends TsEmbed {
|
|
|
14838
14936
|
/**
|
|
14839
14937
|
* Render the embedded ThoughtSpot search
|
|
14840
14938
|
*/
|
|
14841
|
-
render() {
|
|
14939
|
+
async render() {
|
|
14842
14940
|
super.render();
|
|
14843
14941
|
const { answerId } = this.viewConfig;
|
|
14844
14942
|
const src = this.getIFrameSrc();
|
|
14845
|
-
this.renderIFrame(src);
|
|
14943
|
+
await this.renderIFrame(src);
|
|
14846
14944
|
getAuthPromise().then(() => {
|
|
14847
14945
|
if (checkReleaseVersionInBeta(getReleaseVersion(), getEmbedConfig().suppressSearchEmbedBetaWarning
|
|
14848
14946
|
|| getEmbedConfig().suppressErrorAlerts)) {
|
|
@@ -14982,7 +15080,7 @@ class AppEmbed extends V1Embed {
|
|
|
14982
15080
|
* @param pageId The ID of the page to be embedded.
|
|
14983
15081
|
*/
|
|
14984
15082
|
getIFrameSrc() {
|
|
14985
|
-
const { pageId, path, modularHomeExperience
|
|
15083
|
+
const { pageId, path, modularHomeExperience } = this.viewConfig;
|
|
14986
15084
|
const pageRoute = this.formatPath(path) || this.getPageRoute(pageId, modularHomeExperience);
|
|
14987
15085
|
let url = `${this.getRootIframeSrc()}/${pageRoute}`;
|
|
14988
15086
|
const tsPostHashParams = this.getThoughtSpotPostUrlParams();
|
|
@@ -15067,10 +15165,10 @@ class AppEmbed extends V1Embed {
|
|
|
15067
15165
|
* @param renderOptions An object containing the page ID
|
|
15068
15166
|
* to be embedded.
|
|
15069
15167
|
*/
|
|
15070
|
-
render() {
|
|
15168
|
+
async render() {
|
|
15071
15169
|
super.render();
|
|
15072
15170
|
const src = this.getIFrameSrc();
|
|
15073
|
-
this.renderV1Embed(src);
|
|
15171
|
+
await this.renderV1Embed(src);
|
|
15074
15172
|
return this;
|
|
15075
15173
|
}
|
|
15076
15174
|
}
|
|
@@ -15257,10 +15355,10 @@ class LiveboardEmbed extends V1Embed {
|
|
|
15257
15355
|
* @param renderOptions An object specifying the Liveboard ID,
|
|
15258
15356
|
* visualization ID and the runtime filters.
|
|
15259
15357
|
*/
|
|
15260
|
-
render() {
|
|
15358
|
+
async render() {
|
|
15261
15359
|
super.render();
|
|
15262
15360
|
const src = this.getIFrameSrc();
|
|
15263
|
-
this.renderV1Embed(src);
|
|
15361
|
+
await this.renderV1Embed(src);
|
|
15264
15362
|
return this;
|
|
15265
15363
|
}
|
|
15266
15364
|
navigateToLiveboard(liveboardId, vizId, activeTabId) {
|